@helia/routers 5.1.1-eb1908b3 → 5.1.1-f6cc7640

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,27 +1,27 @@
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 gl=Object.create;var Cn=Object.defineProperty;var bl=Object.getOwnPropertyDescriptor;var xl=Object.getOwnPropertyNames;var wl=Object.getPrototypeOf,El=Object.prototype.hasOwnProperty;var Ea=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Et=(e,t)=>{for(var r in t)Cn(e,r,{get:t[r],enumerable:!0})},Sa=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of xl(t))!El.call(e,o)&&o!==r&&Cn(e,o,{get:()=>t[o],enumerable:!(n=bl(t,o))||n.enumerable});return e};var Go=(e,t,r)=>(r=e!=null?gl(wl(e)):{},Sa(t||!e||!e.__esModule?Cn(r,"default",{value:e,enumerable:!0}):r,e)),Sl=e=>Sa(Cn({},"__esModule",{value:!0}),e);var js=Ea((x1,Hs)=>{var b1=(function(){typeof Hs<"u"&&(Hs.exports=v);var e=86400,t=3200,r=146097*t/400,n=e*r,o=1e3*n,i=864e13,s=4294967296,a=1e6,c="000000000",u=Math.trunc||function(w){var C=w-w%1;return C==0&&(w<0||w===0&&1/w!=1/0)?-0:C},f=v.prototype,l=(v.fromDate=function(w){return new v(+w)},v.fromInt64BE=U(0,1,2,3,0,4),v.fromInt64LE=U(3,2,1,0,4,0),v.fromString=function(P){var C,N=new v,P=(P+="").replace(/^\s*[+\-]?\d+/,function(g){var g=+g,T=1970+(g-1970)%400;return N.year=g-T,T}).replace(/(?:Z|([+\-]\d{2}):?(\d{2}))$/,function(d,g,T){return g<0&&(T*=-1),C=6e4*(60*+g+ +T),""}).replace(/\.\d+$/,function(d){return N.nano=+(d+c).substr(1,9),""}).split(/\D+/);if(1<P.length?P[1]--:P[1]=0,N.time=C=Date.UTC.apply(Date,P)-(C||0),isNaN(C))throw new TypeError("Invalid Date");return y(N)},v.fromTimeT=function(w){return A(w,0)},f.year=0,f.time=0,f.nano=0,f.addNano=function(w){return this.nano+=+w||0,this},f.getNano=function(){var w=y(this);return(w.time%1e3*a+ +w.nano+1e9)%1e9},f.getTimeT=function(){var C=y(this),w=Math.floor(C.time/1e3),C=C.year;return C&&(w+=C*r*e/t),w},f.getYear=function(){return this.toDate().getUTCFullYear()+this.year},f.toDate=function(){return S(y(this).time)},f.toJSON=function(){return this.toString().replace(/0{1,6}Z$/,"Z")},f.toString=function(w){var C=this,N=C.toDate(),P={H:function(){return M(N.getUTCHours())},L:function(){return L(N.getUTCMilliseconds(),3)},M:function(){return M(N.getUTCMinutes())},N:function(){return L(C.getNano(),9)},S:function(){return M(N.getUTCSeconds())},Y:function(){var d=C.getYear();return 999999<d?"+"+d:9999<d?"+"+L(d,6):0<=d?L(d,4):-999999<=d?"-"+L(-d,6):d},a:function(){return m[N.getUTCDay()]},b:function(){return h[N.getUTCMonth()]},d:function(){return M(N.getUTCDate())},e:function(){return(function(d){return(9<d?"":" ")+(0|d)})(N.getUTCDate())},m:function(){return M(N.getUTCMonth()+1)}};return(function d(g){return g.replace(/%./g,function(T){var x=T[1],b=E[x],x=P[x];return b?d(b):x?x():T})})(w||l)},f.writeInt64BE=_(0,1,2,3,0,4),f.writeInt64LE=_(3,2,1,0,4,0),"%Y-%m-%dT%H:%M:%S.%NZ"),h=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],m=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],E={"%":"%",F:"%Y-%m-%d",n:`
3
- `,R:"%H:%M",T:"%H:%M:%S",t:" ",X:"%T",Z:"GMT",z:"+0000"};return v;function v(w,C,N){var P=this;if(!(P instanceof v))return new v(w,C,N);P.time=+w||0,P.nano=+C||0,P.year=+N||0,y(P)}function y(w){var C,N,P,d=w.year,g=w.time,T=w.nano,b=((T<0||a<=T)&&(T-=(N=Math.floor(T/a))*a,g+=N,N=1),d%t);return(g<-i||i<g||b)&&((C=u(g/o))&&(d+=C*t,g-=C*o),(P=S(g)).setUTCFullYear(b+P.getUTCFullYear()),P=(g=+P)+(C=u((d-=b)/t))*o,C&&-i<=P&&P<=i&&(d-=C*t,g=P),N=1),N&&(w.year=d,w.time=g,w.nano=T),w}function S(w){var C=new Date(0);return C.setTime(w),C}function A(d,P){d=+d||0;var N=u((P=(P|0)*s)/n)+u(d/n),P=P%n+d%n,d=u(P/n);return d&&(N+=d,P-=d*n),new v(1e3*P,0,N*t)}function _(w,C,N,P,d,g){return function(b,x){var R=y(this);b=b||new Array(8),F(b,x|=0);var D=Math.floor(R.time/1e3),R=R.year*(r*e/t),I=u(R/s)+u(D/s),R=R%s+D%s,D=Math.floor(R/s);return D&&(I+=D,R-=D*s),T(b,x+d,I),T(b,x+g,R),b};function T(b,x,I){b[x+w]=I>>24&255,b[x+C]=I>>16&255,b[x+N]=I>>8&255,b[x+P]=255&I}}function U(w,C,N,P,d,g){return function(b,x){F(b,x|=0);var I=T(b,x+d);return A(T(b,x+g),I)};function T(b,x){return 16777216*b[x+w]+(b[x+C]<<16|b[x+N]<<8|b[x+P])}}function F(w,C){if(w=w&&w.length,w==null)throw new TypeError("Invalid Buffer");if(w<C+8)throw new RangeError("Out of range")}function M(w){return(9<w?"":"0")+(0|w)}function L(w,C){return(c+(0|w)).substr(-C)}})()});var Qf=Ea((xE,oa)=>{"use strict";var J0=Object.prototype.hasOwnProperty,vt="~";function Tn(){}Object.create&&(Tn.prototype=Object.create(null),new Tn().__proto__||(vt=!1));function Q0(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function Jf(e,t,r,n,o){if(typeof r!="function")throw new TypeError("The listener must be a function");var i=new Q0(r,n||e,o),s=vt?vt+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 $o(e,t){--e._eventsCount===0?e._events=new Tn:delete e._events[t]}function wt(){this._events=new Tn,this._eventsCount=0}wt.prototype.eventNames=function(){var t=[],r,n;if(this._eventsCount===0)return t;for(n in r=this._events)J0.call(r,n)&&t.push(vt?n.slice(1):n);return Object.getOwnPropertySymbols?t.concat(Object.getOwnPropertySymbols(r)):t};wt.prototype.listeners=function(t){var r=vt?vt+t:t,n=this._events[r];if(!n)return[];if(n.fn)return[n.fn];for(var o=0,i=n.length,s=new Array(i);o<i;o++)s[o]=n[o].fn;return s};wt.prototype.listenerCount=function(t){var r=vt?vt+t:t,n=this._events[r];return n?n.fn?1:n.length:0};wt.prototype.emit=function(t,r,n,o,i,s){var a=vt?vt+t:t;if(!this._events[a])return!1;var c=this._events[a],u=arguments.length,f,l;if(c.fn){switch(c.once&&this.removeListener(t,c.fn,void 0,!0),u){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,r),!0;case 3:return c.fn.call(c.context,r,n),!0;case 4:return c.fn.call(c.context,r,n,o),!0;case 5:return c.fn.call(c.context,r,n,o,i),!0;case 6:return c.fn.call(c.context,r,n,o,i,s),!0}for(l=1,f=new Array(u-1);l<u;l++)f[l-1]=arguments[l];c.fn.apply(c.context,f)}else{var h=c.length,m;for(l=0;l<h;l++)switch(c[l].once&&this.removeListener(t,c[l].fn,void 0,!0),u){case 1:c[l].fn.call(c[l].context);break;case 2:c[l].fn.call(c[l].context,r);break;case 3:c[l].fn.call(c[l].context,r,n);break;case 4:c[l].fn.call(c[l].context,r,n,o);break;default:if(!f)for(m=1,f=new Array(u-1);m<u;m++)f[m-1]=arguments[m];c[l].fn.apply(c[l].context,f)}}return!0};wt.prototype.on=function(t,r,n){return Jf(this,t,r,n,!1)};wt.prototype.once=function(t,r,n){return Jf(this,t,r,n,!0)};wt.prototype.removeListener=function(t,r,n,o){var i=vt?vt+t:t;if(!this._events[i])return this;if(!r)return $o(this,i),this;var s=this._events[i];if(s.fn)s.fn===r&&(!o||s.once)&&(!n||s.context===n)&&$o(this,i);else{for(var a=0,c=[],u=s.length;a<u;a++)(s[a].fn!==r||o&&!s[a].once||n&&s[a].context!==n)&&c.push(s[a]);c.length?this._events[i]=c.length===1?c[0]:c:$o(this,i)}return this};wt.prototype.removeAllListeners=function(t){var r;return t?(r=vt?vt+t:t,this._events[r]&&$o(this,r)):(this._events=new Tn,this._eventsCount=0),this};wt.prototype.off=wt.prototype.removeListener;wt.prototype.addListener=wt.prototype.on;wt.prefixed=vt;wt.EventEmitter=wt;typeof oa<"u"&&(oa.exports=wt)});var Sm={};Et(Sm,{delegatedHTTPRouting:()=>al,delegatedHTTPRoutingDefaults:()=>Yo,httpGatewayRouting:()=>ml,libp2pRouting:()=>yl});var va=Symbol.for("@libp2p/content-routing");var et=class extends Error{static name="InvalidParametersError";constructor(t="Invalid parameters"){super(t),this.name="InvalidParametersError"}},rr=class extends Error{static name="InvalidPublicKeyError";constructor(t="Invalid public key"){super(t),this.name="InvalidPublicKeyError"}};var At=class extends Error{static name="NotFoundError";constructor(t="Not found"){super(t),this.name="NotFoundError"}};var _n=class extends Error{static name="InvalidCIDError";constructor(t="Invalid CID"){super(t),this.name="InvalidCIDError"}},nr=class extends Error{static name="InvalidMultihashError";constructor(t="Invalid Multihash"){super(t),this.name="InvalidMultihashError"}};var or=class extends Error{static name="UnsupportedKeyTypeError";constructor(t="Unsupported key type"){super(t),this.name="UnsupportedKeyTypeError"}};var Bn=Symbol.for("@libp2p/peer-id");function Ta(e){return!!e?.[Bn]}var Aa=Symbol.for("@libp2p/peer-routing");var ti={};Et(ti,{base58btc:()=>X,base58flickr:()=>Bl});var _m=new Uint8Array(0);function Ia(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 ue(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 Ca(e){return new TextEncoder().encode(e)}function _a(e){return new TextDecoder().decode(e)}function vl(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var o=0;o<e.length;o++){var i=e.charAt(o),s=i.charCodeAt(0);if(r[s]!==255)throw new TypeError(i+" is ambiguous");r[s]=o}var a=e.length,c=e.charAt(0),u=Math.log(a)/Math.log(256),f=Math.log(256)/Math.log(a);function l(E){if(E instanceof Uint8Array||(ArrayBuffer.isView(E)?E=new Uint8Array(E.buffer,E.byteOffset,E.byteLength):Array.isArray(E)&&(E=Uint8Array.from(E))),!(E instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(E.length===0)return"";for(var v=0,y=0,S=0,A=E.length;S!==A&&E[S]===0;)S++,v++;for(var _=(A-S)*f+1>>>0,U=new Uint8Array(_);S!==A;){for(var F=E[S],M=0,L=_-1;(F!==0||M<y)&&L!==-1;L--,M++)F+=256*U[L]>>>0,U[L]=F%a>>>0,F=F/a>>>0;if(F!==0)throw new Error("Non-zero carry");y=M,S++}for(var w=_-y;w!==_&&U[w]===0;)w++;for(var C=c.repeat(v);w<_;++w)C+=e.charAt(U[w]);return C}function h(E){if(typeof E!="string")throw new TypeError("Expected String");if(E.length===0)return new Uint8Array;var v=0;if(E[v]!==" "){for(var y=0,S=0;E[v]===c;)y++,v++;for(var A=(E.length-v)*u+1>>>0,_=new Uint8Array(A);E[v];){var U=r[E.charCodeAt(v)];if(U===255)return;for(var F=0,M=A-1;(U!==0||F<S)&&M!==-1;M--,F++)U+=a*_[M]>>>0,_[M]=U%256>>>0,U=U/256>>>0;if(U!==0)throw new Error("Non-zero carry");S=F,v++}if(E[v]!==" "){for(var L=A-S;L!==A&&_[L]===0;)L++;for(var w=new Uint8Array(y+(A-L)),C=y;L!==A;)w[C++]=_[L++];return w}}}function m(E){var v=h(E);if(v)return v;throw new Error(`Non-${t} character`)}return{encode:l,decodeUnsafe:h,decode:m}}var Tl=vl,Al=Tl,Ra=Al;var Wo=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")}},Xo=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 Da(this,t)}},Jo=class{decoders;constructor(t){this.decoders=t}or(t){return Da(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 Da(e,t){return new Jo({...e.decoders??{[e.prefix]:e},...t.decoders??{[t.prefix]:t}})}var Qo=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 Wo(t,r,n),this.decoder=new Xo(t,r,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function ir({name:e,prefix:t,encode:r,decode:n}){return new Qo(e,t,r,n)}function Ee({name:e,prefix:t,alphabet:r}){let{encode:n,decode:o}=Ra(r,e);return ir({prefix:t,name:e,encode:n,decode:i=>ue(o(i))})}function Il(e,t,r,n){let o=e.length;for(;e[o-1]==="=";)--o;let i=new Uint8Array(o*r/8|0),s=0,a=0,c=0;for(let u=0;u<o;++u){let f=t[e[u]];if(f===void 0)throw new SyntaxError(`Non-${n} character`);a=a<<r|f,s+=r,s>=8&&(s-=8,i[c++]=255&a>>s)}if(s>=r||(255&a<<8-s)!==0)throw new SyntaxError("Unexpected end of data");return i}function Cl(e,t,r){let n=t[t.length-1]==="=",o=(1<<r)-1,i="",s=0,a=0;for(let c=0;c<e.length;++c)for(a=a<<8|e[c],s+=8;s>r;)s-=r,i+=t[o&a>>s];if(s!==0&&(i+=t[o&a<<r-s]),n)for(;(i.length*r&7)!==0;)i+="=";return i}function _l(e){let t={};for(let r=0;r<e.length;++r)t[e[r]]=r;return t}function rt({name:e,prefix:t,bitsPerChar:r,alphabet:n}){let o=_l(n);return ir({prefix:t,name:e,encode(i){return Cl(i,n,r)},decode(i){return Il(i,o,r,e)}})}var X=Ee({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Bl=Ee({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var ei={};Et(ei,{base32:()=>te,base32hex:()=>Ol,base32hexpad:()=>Ll,base32hexpadupper:()=>Nl,base32hexupper:()=>Fl,base32pad:()=>Dl,base32padupper:()=>Pl,base32upper:()=>Rl,base32z:()=>Ul});var te=rt({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Rl=rt({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Dl=rt({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Pl=rt({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Ol=rt({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Fl=rt({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Ll=rt({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Nl=rt({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Ul=rt({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var ri={};Et(ri,{base36:()=>sr,base36upper:()=>kl});var sr=Ee({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),kl=Ee({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var ee={};Et(ee,{Digest:()=>Ke,create:()=>Vt,decode:()=>Se,equals:()=>oi,hasCode:()=>nd});var Kl=Fa,Pa=128,$l=127,Ml=~$l,Vl=Math.pow(2,31);function Fa(e,t,r){t=t||[],r=r||0;for(var n=r;e>=Vl;)t[r++]=e&255|Pa,e/=128;for(;e&Ml;)t[r++]=e&255|Pa,e>>>=7;return t[r]=e|0,Fa.bytes=r-n+1,t}var ql=ni,zl=128,Oa=127;function ni(e,n){var r=0,n=n||0,o=0,i=n,s,a=e.length;do{if(i>=a)throw ni.bytes=0,new RangeError("Could not decode varint");s=e[i++],r+=o<28?(s&Oa)<<o:(s&Oa)*Math.pow(2,o),o+=7}while(s>=zl);return ni.bytes=i-n,r}var Hl=Math.pow(2,7),jl=Math.pow(2,14),Yl=Math.pow(2,21),Zl=Math.pow(2,28),Gl=Math.pow(2,35),Wl=Math.pow(2,42),Xl=Math.pow(2,49),Jl=Math.pow(2,56),Ql=Math.pow(2,63),td=function(e){return e<Hl?1:e<jl?2:e<Yl?3:e<Zl?4:e<Gl?5:e<Wl?6:e<Xl?7:e<Jl?8:e<Ql?9:10},ed={encode:Kl,decode:ql,encodingLength:td},rd=ed,Kr=rd;function $r(e,t=0){return[Kr.decode(e,t),Kr.decode.bytes]}function ar(e,t,r=0){return Kr.encode(e,t,r),t}function cr(e){return Kr.encodingLength(e)}function Vt(e,t){let r=t.byteLength,n=cr(e),o=n+cr(r),i=new Uint8Array(o+r);return ar(e,i,0),ar(r,i,n),i.set(t,o),new Ke(e,r,t,i)}function Se(e){let t=ue(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 Ke(r,o,s,t)}function oi(e,t){if(e===t)return!0;{let r=t;return e.code===r.code&&e.size===r.size&&r.bytes instanceof Uint8Array&&Ia(e.bytes,r.bytes)}}var Ke=class{code;size;digest;bytes;constructor(t,r,n,o){this.code=t,this.size=r,this.digest=n,this.bytes=o}};function nd(e,t){return e.code===t}function La(e,t){let{bytes:r,version:n}=e;return n===0?id(r,ii(e),t??X.encoder):sd(r,ii(e),t??te.encoder)}var Na=new WeakMap;function ii(e){let t=Na.get(e);if(t==null){let r=new Map;return Na.set(e,r),r}return t}var H=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!==Mr)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==ad)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=Vt(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&&oi(t.multihash,n.multihash)}toString(t){return La(this,t)}toJSON(){return{"/":La(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??Ua(n,o,i.bytes))}else if(r[cd]===!0){let{version:n,multihash:o,code:i}=r,s=Se(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!==Mr)throw new Error(`Version 0 CID must use dag-pb (code: ${Mr}) block encoding`);return new e(t,r,n,n.bytes)}case 1:{let o=Ua(t,r,n.bytes);return new e(t,r,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return e.create(0,Mr,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=ue(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 Ke(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,h]=$r(t.subarray(r));return r+=h,l},o=n(),i=Mr;if(o===18?(o=0,r=0):i=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let s=r,a=n(),c=n(),u=r+c,f=u-s;return{version:o,codec:i,multihashCode:a,digestSize:c,multihashSize:f,size:u}}static parse(t,r){let[n,o]=od(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 ii(i).set(n,t),i}};function od(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 te.prefix:{let r=t??te;return[te.prefix,r.decode(e)]}case sr.prefix:{let r=t??sr;return[sr.prefix,r.decode(e)]}default:{if(t==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[e[0],t.decode(e)]}}}function id(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 sd(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 Mr=112,ad=18;function Ua(e,t,r){let n=cr(e),o=n+cr(t),i=new Uint8Array(o+r.byteLength);return ar(e,i,0),ar(t,i,n),i.set(r,o),i}var cd=Symbol.for("@ipld/js-cid/CID");var si={};Et(si,{identity:()=>St});var ka=0,ud="identity",Ka=ue;function fd(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 Vt(ka,Ka(e))}var St={code:ka,name:ud,encode:Ka,digest:fd};function W(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 fe(e=0){return new Uint8Array(e)}function _t(e=0){return new Uint8Array(e)}function Nt(e,t){t==null&&(t=e.reduce((o,i)=>o+i.length,0));let r=_t(t),n=0;for(let o of e)r.set(o,n),n+=o.length;return r}var Ma=Symbol.for("@achingbrain/uint8arraylist");function $a(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 ur(e){return!!e?.[Ma]}var Bt=class e{bufs;length;[Ma]=!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(ur(n)){r+=n.byteLength;for(let o of n.bufs)this.bufs.push(o)}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(ur(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=$a(this.bufs,t);return r.buf[r.index]}set(t,r){let n=$a(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(ur(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 Nt(n,o)}subarray(t,r){let{bufs:n,length:o}=this._subList(t,r);return n.length===1?n[0]:Nt(n,o)}sublist(t,r){let{bufs:n,length:o}=this._subList(t,r),i=new e;return i.length=o,i.bufs=n,i}_subList(t,r){if(t=t??0,r=r??this.length,t<0&&(t=this.length+t),r<0&&(r=this.length+r),t<0||r>this.length)throw new RangeError("index is out of bounds");if(t===r)return{bufs:[],length:0};if(t===0&&r===this.length)return{bufs:[...this.bufs],length:this.length};let n=[],o=0;for(let i=0;i<this.bufs.length;i++){let s=this.bufs[i],a=o,c=a+s.byteLength;if(o=c,t>=c)continue;let u=t>=a&&t<c,f=r>a&&r<=c;if(u&&f){if(t===a&&r===c){n.push(s);break}let l=t-a;n.push(s.subarray(l,l+(r-t)));break}if(u){if(t===0){n.push(s);continue}n.push(s.subarray(t-a));continue}if(f){if(r===c){n.push(s);break}n.push(s.subarray(0,r-a));break}n.push(s)}return{bufs:n,length:r-t}}indexOf(t,r=0){if(!ur(t)&&!(t instanceof Uint8Array))throw new TypeError('The "value" argument must be a Uint8ArrayList or Uint8Array');let n=t instanceof Uint8Array?t:t.subarray();if(r=Number(r??0),isNaN(r)&&(r=0),r<0&&(r=this.length+r),r<0&&(r=0),t.length===0)return r>this.length?this.length:r;let o=n.byteLength;if(o===0)throw new TypeError("search must be at least 1 byte long");let i=256,s=new Int32Array(i);for(let l=0;l<i;l++)s[l]=-1;for(let l=0;l<o;l++)s[n[l]]=l;let a=s,c=this.byteLength-n.byteLength,u=n.byteLength-1,f;for(let l=r;l<=c;l+=f){f=0;for(let h=u;h>=0;h--){let m=this.get(l+h);if(n[h]!==m){f=Math.max(1,h-a[m]);break}}if(f===0)return l}return-1}getInt8(t){let r=this.subarray(t,t+1);return new DataView(r.buffer,r.byteOffset,r.byteLength).getInt8(0)}setInt8(t,r){let n=_t(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setInt8(0,r),this.write(n,t)}getInt16(t,r){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt16(0,r)}setInt16(t,r,n){let o=fe(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=fe(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=fe(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigInt64(0,r,n),this.write(o,t)}getUint8(t){let r=this.subarray(t,t+1);return new DataView(r.buffer,r.byteOffset,r.byteLength).getUint8(0)}setUint8(t,r){let n=_t(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setUint8(0,r),this.write(n,t)}getUint16(t,r){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint16(0,r)}setUint16(t,r,n){let o=fe(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=fe(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=fe(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=fe(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=fe(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(!W(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 ai={};Et(ai,{base10:()=>ld});var ld=Ee({prefix:"9",name:"base10",alphabet:"0123456789"});var ci={};Et(ci,{base16:()=>dd,base16upper:()=>hd});var dd=rt({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),hd=rt({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var ui={};Et(ui,{base2:()=>pd});var pd=rt({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var fi={};Et(fi,{base256emoji:()=>xd});var Va=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}"),md=Va.reduce((e,t,r)=>(e[r]=t,e),[]),yd=Va.reduce((e,t,r)=>{let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);return e[n]=r,e},[]);function gd(e){return e.reduce((t,r)=>(t+=md[r],t),"")}function bd(e){let t=[];for(let r of e){let n=r.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${r}`);let o=yd[n];if(o==null)throw new Error(`Non-base256emoji character: ${r}`);t.push(o)}return new Uint8Array(t)}var xd=ir({prefix:"\u{1F680}",name:"base256emoji",encode:gd,decode:bd});var hi={};Et(hi,{base64:()=>li,base64pad:()=>wd,base64url:()=>di,base64urlpad:()=>Ed});var li=rt({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),wd=rt({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),di=rt({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Ed=rt({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var pi={};Et(pi,{base8:()=>Sd});var Sd=rt({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var mi={};Et(mi,{identity:()=>vd});var vd=ir({prefix:"\0",name:"identity",encode:e=>_a(e),decode:e=>Ca(e)});var ly=new TextEncoder,dy=new TextDecoder;var qa=85;var bi={};Et(bi,{sha256:()=>Vr,sha512:()=>Id});var Ad=20;function gi({name:e,code:t,encode:r,minDigestLength:n,maxDigestLength:o}){return new yi(e,t,r,n,o)}var yi=class{name;code;encode;minDigestLength;maxDigestLength;constructor(t,r,n,o,i){this.name=t,this.code=r,this.encode=n,this.minDigestLength=o??Ad,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 Vt(t,e)}function Ya(e){return async t=>new Uint8Array(await crypto.subtle.digest(e,t))}var Vr=gi({name:"sha2-256",code:18,encode:Ya("SHA-256")}),Id=gi({name:"sha2-512",code:19,encode:Ya("SHA-512")});var qr={...mi,...ui,...pi,...ai,...ci,...ei,...ri,...ti,...hi,...fi},Ty={...bi,...si};function Ga(e,t,r,n){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:n}}}var Za=Ga("utf8","u",e=>"u"+new TextDecoder("utf8").decode(e),e=>new TextEncoder().encode(e.substring(1))),xi=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=_t(e.length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t}),Cd={utf8:Za,"utf-8":Za,hex:qr.base16,latin1:xi,ascii:xi,binary:xi,...qr},Dn=Cd;function V(e,t="utf8"){let r=Dn[t];if(r==null)throw new Error(`Unsupported encoding "${t}"`);return r.decoder.decode(`${r.prefix}${e}`)}function z(e,t="utf8"){let r=Dn[t];if(r==null)throw new Error(`Unsupported encoding "${t}"`);return r.encoder.encode(e).substring(1)}var _d=parseInt("11111",2),wi=parseInt("10000000",2),Bd=parseInt("01111111",2),Wa={0:zr,1:zr,2:Rd,3:Od,4:Fd,5:Pd,6:Dd,16:zr,22:zr,48:zr};function le(e,t={offset:0}){let r=e[t.offset]&_d;if(t.offset++,Wa[r]!=null)return Wa[r](e,t);throw new Error("No decoder for tag "+r)}function Hr(e,t){let r=0;if((e[t.offset]&wi)===wi){let n=e[t.offset]&Bd,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 zr(e,t){Hr(e,t);let r=[];for(;!(t.offset>=e.byteLength);){let n=le(e,t);if(n===null)break;r.push(n)}return r}function Rd(e,t){let r=Hr(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 Dd(e,t){let r=Hr(e,t),n=t.offset+r,o=e[t.offset];t.offset++;let i=0,s=0;o<40?(i=0,s=o):o<80?(i=1,s=o-40):(i=2,s=o-80);let a=`${i}.${s}`,c=[];for(;t.offset<n;){let u=e[t.offset];if(t.offset++,c.push(u&127),u<128){c.reverse();let f=0;for(let l=0;l<c.length;l++)f+=c[l]<<l*7;a+=`.${f}`,c=[]}}return a}function Pd(e,t){return t.offset++,null}function Od(e,t){let r=Hr(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 Fd(e,t){let r=Hr(e,t),n=e.subarray(t.offset,t.offset+r);return t.offset+=r,n}function Ld(e){let t=e.toString(16);t.length%2===1&&(t="0"+t);let r=new Bt;for(let n=0;n<t.length;n+=2)r.append(Uint8Array.from([parseInt(`${t[n]}${t[n+1]}`,16)]));return r}function Ei(e){if(e.byteLength<128)return Uint8Array.from([e.byteLength]);let t=Ld(e.byteLength);return new Bt(Uint8Array.from([t.byteLength|wi]),t)}function It(e){let t=new Bt,r=128;return(e.subarray()[0]&r)===r&&t.append(Uint8Array.from([0])),t.append(e),new Bt(Uint8Array.from([2]),Ei(t),t)}function Pn(e){let t=Uint8Array.from([0]),r=new Bt(t,e);return new Bt(Uint8Array.from([3]),Ei(r),r)}function ve(e,t=48){let r=new Bt;for(let n of e)r.append(n);return new Bt(Uint8Array.from([t]),Ei(r),r)}async function Xa(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 Nd=Uint8Array.from([6,8,42,134,72,206,61,3,1,7]),Ud=Uint8Array.from([6,5,43,129,4,0,34]),kd=Uint8Array.from([6,5,43,129,4,0,35]),Kd={ext:!0,kty:"EC",crv:"P-256"},$d={ext:!0,kty:"EC",crv:"P-384"},Md={ext:!0,kty:"EC",crv:"P-521"},Si=32,vi=48,Ti=66;function Ai(e){let t=le(e);return Ja(t)}function Ja(e){let t=e[1][1][0],r=1,n,o;if(t.byteLength===Si*2+1)return n=z(t.subarray(r,r+Si),"base64url"),o=z(t.subarray(r+Si),"base64url"),new fr({...Kd,key_ops:["verify"],x:n,y:o});if(t.byteLength===vi*2+1)return n=z(t.subarray(r,r+vi),"base64url"),o=z(t.subarray(r+vi),"base64url"),new fr({...$d,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 fr({...Md,key_ops:["verify"],x:n,y:o});throw new et(`coordinates were wrong length, got ${t.byteLength}, expected 65, 97 or 133`)}function Qa(e){return ve([It(Uint8Array.from([1])),ve([Vd(e.crv)],160),ve([Pn(new Bt(Uint8Array.from([4]),V(e.x??"","base64url"),V(e.y??"","base64url")))],161)]).subarray()}function Vd(e){if(e==="P-256")return Nd;if(e==="P-384")return Ud;if(e==="P-521")return kd;throw new et(`Invalid curve ${e}`)}var fr=class{type="ECDSA";jwk;_raw;constructor(t){this.jwk=t}get raw(){return this._raw==null&&(this._raw=Qa(this.jwk)),this._raw}toMultihash(){return St.digest(lr(this))}toCID(){return H.createV1(114,this.toMultihash())}toString(){return X.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:W(this.raw,t.raw)}async verify(t,r,n){return Xa(this.jwk,r,t,n)}};function Ii(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"&&"BYTES_PER_ELEMENT"in e&&e.BYTES_PER_ELEMENT===1}function Te(e,t=""){if(typeof e!="number"){let r=t&&`"${t}" `;throw new TypeError(`${r}expected number, got ${typeof e}`)}if(!Number.isSafeInteger(e)||e<0){let r=t&&`"${t}" `;throw new RangeError(`${r}expected integer >= 0, got ${e}`)}}function Rt(e,t,r=""){let n=Ii(e),o=e?.length,i=t!==void 0;if(!n||i&&o!==t){let s=r&&`"${r}" `,a=i?` of length ${t}`:"",c=n?`length=${o}`:`type=${typeof e}`,u=s+"expected Uint8Array"+a+", got "+c;throw n?new RangeError(u):new TypeError(u)}return e}function On(e){if(typeof e!="function"||typeof e.create!="function")throw new TypeError("Hash must wrapped by utils.createHasher");if(Te(e.outputLen),Te(e.blockLen),e.outputLen<1)throw new Error('"outputLen" must be >= 1');if(e.blockLen<1)throw new Error('"blockLen" must be >= 1')}function dr(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 Fn(e,t){Rt(e,void 0,"digestInto() output");let r=t.outputLen;if(e.length<r)throw new RangeError('"digestInto() output" expected to be of length >='+r)}function he(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function Ln(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function qt(e,t){return e<<32-t|e>>>t}var ec=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",qd=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Nn(e){if(Rt(e),ec)return e.toHex();let t="";for(let r=0;r<e.length;r++)t+=qd[e[r]];return t}var de={_0:48,_9:57,A:65,F:70,a:97,f:102};function tc(e){if(e>=de._0&&e<=de._9)return e-de._0;if(e>=de.A&&e<=de.F)return e-(de.A-10);if(e>=de.a&&e<=de.f)return e-(de.a-10)}function jr(e){if(typeof e!="string")throw new TypeError("hex string expected, got "+typeof e);if(ec)try{return Uint8Array.fromHex(e)}catch(o){throw o instanceof SyntaxError?new RangeError(o.message):o}let t=e.length,r=t/2;if(t%2)throw new RangeError("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=tc(e.charCodeAt(i)),a=tc(e.charCodeAt(i+1));if(s===void 0||a===void 0){let c=e[i]+e[i+1];throw new RangeError('hex string expected, got non-hex character "'+c+'" at index '+i)}n[o]=s*16+a}return n}function Ci(...e){let t=0;for(let n=0;n<e.length;n++){let o=e[n];Rt(o),t+=o.length}let r=new Uint8Array(t);for(let n=0,o=0;n<e.length;n++){let i=e[n];r.set(i,o),o+=i.length}return r}function _i(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.canXOF=n.canXOF,r.create=o=>e(o),Object.assign(r,t),Object.freeze(r)}function rc(e=32){Te(e,"bytesLength");let t=typeof globalThis=="object"?globalThis.crypto:null;if(typeof t?.getRandomValues!="function")throw new Error("crypto.getRandomValues must be defined");if(e>65536)throw new RangeError(`"bytesLength" expected <= 65536, got ${e}`);return t.getRandomValues(new Uint8Array(e))}var Bi=e=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])});function nc(e,t,r){return e&t^~e&r}function oc(e,t,r){return e&t^e&r^t&r}var Yr=class{blockLen;outputLen;canXOF=!1;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=Ln(this.buffer)}update(t){dr(this),Rt(t);let{view:r,buffer:n,blockLen:o}=this,i=t.length;for(let s=0;s<i;){let a=Math.min(o-this.pos,i-s);if(a===o){let c=Ln(t);for(;o<=i-s;s+=o)this.process(c,s);continue}n.set(t.subarray(s,s+a),this.pos),this.pos+=a,s+=a,this.pos===o&&(this.process(r,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){dr(this),Fn(t,this),this.finished=!0;let{buffer:r,view:n,blockLen:o,isLE:i}=this,{pos:s}=this;r[s++]=128,he(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 a=Ln(t),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen must be aligned to 32bit");let u=c/4,f=this.get();if(u>f.length)throw new Error("_sha2: outputLen bigger than state");for(let l=0;l<u;l++)a.setUint32(4*l,f[l],i)}digest(){let{buffer:t,outputLen:r}=this;this.digestInto(t);let n=t.slice(0,r);return this.destroy(),n}_cloneInto(t){t||=new this.constructor,t.set(...this.get());let{blockLen:r,buffer:n,length:o,finished:i,destroyed:s,pos:a}=this;return t.destroyed=s,t.finished=i,t.length=o,t.pos=a,o%r&&t.buffer.set(n),t}clone(){return this._cloneInto()}},pe=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var mt=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]);var Un=BigInt(4294967295),ic=BigInt(32);function zd(e,t=!1){return t?{h:Number(e&Un),l:Number(e>>ic&Un)}:{h:Number(e>>ic&Un)|0,l:Number(e&Un)|0}}function sc(e,t=!1){let r=e.length,n=new Uint32Array(r),o=new Uint32Array(r);for(let i=0;i<r;i++){let{h:s,l:a}=zd(e[i],t);[n[i],o[i]]=[s,a]}return[n,o]}var Ri=(e,t,r)=>e>>>r,Di=(e,t,r)=>e<<32-r|t>>>r,$e=(e,t,r)=>e>>>r|t<<32-r,Me=(e,t,r)=>e<<32-r|t>>>r,Zr=(e,t,r)=>e<<64-r|t>>>r-32,Gr=(e,t,r)=>e>>>r-32|t<<64-r;function re(e,t,r,n){let o=(t>>>0)+(n>>>0);return{h:e+r+(o/2**32|0)|0,l:o|0}}var ac=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0),cc=(e,t,r,n)=>t+r+n+(e/2**32|0)|0,uc=(e,t,r,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0),fc=(e,t,r,n,o)=>t+r+n+o+(e/2**32|0)|0,lc=(e,t,r,n,o)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0)+(o>>>0),dc=(e,t,r,n,o,i)=>t+r+n+o+i+(e/2**32|0)|0;var jd=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]),Ae=new Uint32Array(64),Pi=class extends Yr{constructor(t){super(64,t,8,!1)}get(){let{A:t,B:r,C:n,D:o,E:i,F:s,G:a,H:c}=this;return[t,r,n,o,i,s,a,c]}set(t,r,n,o,i,s,a,c){this.A=t|0,this.B=r|0,this.C=n|0,this.D=o|0,this.E=i|0,this.F=s|0,this.G=a|0,this.H=c|0}process(t,r){for(let l=0;l<16;l++,r+=4)Ae[l]=t.getUint32(r,!1);for(let l=16;l<64;l++){let h=Ae[l-15],m=Ae[l-2],E=qt(h,7)^qt(h,18)^h>>>3,v=qt(m,17)^qt(m,19)^m>>>10;Ae[l]=v+Ae[l-7]+E+Ae[l-16]|0}let{A:n,B:o,C:i,D:s,E:a,F:c,G:u,H:f}=this;for(let l=0;l<64;l++){let h=qt(a,6)^qt(a,11)^qt(a,25),m=f+h+nc(a,c,u)+jd[l]+Ae[l]|0,v=(qt(n,2)^qt(n,13)^qt(n,22))+oc(n,o,i)|0;f=u,u=c,c=a,a=s+m|0,s=i,i=o,o=n,n=m+v|0}n=n+this.A|0,o=o+this.B|0,i=i+this.C|0,s=s+this.D|0,a=a+this.E|0,c=c+this.F|0,u=u+this.G|0,f=f+this.H|0,this.set(n,o,i,s,a,c,u,f)}roundClean(){he(Ae)}destroy(){this.destroyed=!0,this.set(0,0,0,0,0,0,0,0),he(this.buffer)}},Oi=class extends Pi{A=pe[0]|0;B=pe[1]|0;C=pe[2]|0;D=pe[3]|0;E=pe[4]|0;F=pe[5]|0;G=pe[6]|0;H=pe[7]|0;constructor(){super(32)}};var hc=sc(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(e=>BigInt(e))),Yd=hc[0],Zd=hc[1],Ie=new Uint32Array(80),Ce=new Uint32Array(80),Fi=class extends Yr{constructor(t){super(128,t,16,!1)}get(){let{Ah:t,Al:r,Bh:n,Bl:o,Ch:i,Cl:s,Dh:a,Dl:c,Eh:u,El:f,Fh:l,Fl:h,Gh:m,Gl:E,Hh:v,Hl:y}=this;return[t,r,n,o,i,s,a,c,u,f,l,h,m,E,v,y]}set(t,r,n,o,i,s,a,c,u,f,l,h,m,E,v,y){this.Ah=t|0,this.Al=r|0,this.Bh=n|0,this.Bl=o|0,this.Ch=i|0,this.Cl=s|0,this.Dh=a|0,this.Dl=c|0,this.Eh=u|0,this.El=f|0,this.Fh=l|0,this.Fl=h|0,this.Gh=m|0,this.Gl=E|0,this.Hh=v|0,this.Hl=y|0}process(t,r){for(let _=0;_<16;_++,r+=4)Ie[_]=t.getUint32(r),Ce[_]=t.getUint32(r+=4);for(let _=16;_<80;_++){let U=Ie[_-15]|0,F=Ce[_-15]|0,M=$e(U,F,1)^$e(U,F,8)^Ri(U,F,7),L=Me(U,F,1)^Me(U,F,8)^Di(U,F,7),w=Ie[_-2]|0,C=Ce[_-2]|0,N=$e(w,C,19)^Zr(w,C,61)^Ri(w,C,6),P=Me(w,C,19)^Gr(w,C,61)^Di(w,C,6),d=uc(L,P,Ce[_-7],Ce[_-16]),g=fc(d,M,N,Ie[_-7],Ie[_-16]);Ie[_]=g|0,Ce[_]=d|0}let{Ah:n,Al:o,Bh:i,Bl:s,Ch:a,Cl:c,Dh:u,Dl:f,Eh:l,El:h,Fh:m,Fl:E,Gh:v,Gl:y,Hh:S,Hl:A}=this;for(let _=0;_<80;_++){let U=$e(l,h,14)^$e(l,h,18)^Zr(l,h,41),F=Me(l,h,14)^Me(l,h,18)^Gr(l,h,41),M=l&m^~l&v,L=h&E^~h&y,w=lc(A,F,L,Zd[_],Ce[_]),C=dc(w,S,U,M,Yd[_],Ie[_]),N=w|0,P=$e(n,o,28)^Zr(n,o,34)^Zr(n,o,39),d=Me(n,o,28)^Gr(n,o,34)^Gr(n,o,39),g=n&i^n&a^i&a,T=o&s^o&c^s&c;S=v|0,A=y|0,v=m|0,y=E|0,m=l|0,E=h|0,{h:l,l:h}=re(u|0,f|0,C|0,N|0),u=a|0,f=c|0,a=i|0,c=s|0,i=n|0,s=o|0;let b=ac(N,d,T);n=cc(b,C,P,g),o=b|0}({h:n,l:o}=re(this.Ah|0,this.Al|0,n|0,o|0)),{h:i,l:s}=re(this.Bh|0,this.Bl|0,i|0,s|0),{h:a,l:c}=re(this.Ch|0,this.Cl|0,a|0,c|0),{h:u,l:f}=re(this.Dh|0,this.Dl|0,u|0,f|0),{h:l,l:h}=re(this.Eh|0,this.El|0,l|0,h|0),{h:m,l:E}=re(this.Fh|0,this.Fl|0,m|0,E|0),{h:v,l:y}=re(this.Gh|0,this.Gl|0,v|0,y|0),{h:S,l:A}=re(this.Hh|0,this.Hl|0,S|0,A|0),this.set(n,o,i,s,a,c,u,f,l,h,m,E,v,y,S,A)}roundClean(){he(Ie,Ce)}destroy(){this.destroyed=!0,he(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}},Li=class extends Fi{Ah=mt[0]|0;Al=mt[1]|0;Bh=mt[2]|0;Bl=mt[3]|0;Ch=mt[4]|0;Cl=mt[5]|0;Dh=mt[6]|0;Dl=mt[7]|0;Eh=mt[8]|0;El=mt[9]|0;Fh=mt[10]|0;Fl=mt[11]|0;Gh=mt[12]|0;Gl=mt[13]|0;Hh=mt[14]|0;Hl=mt[15]|0;constructor(){super(64)}};var hr=_i(()=>new Oi,Bi(1));var kn=_i(()=>new Li,Bi(3));var Y=(e,t,r)=>Rt(e,t,r),Ui=Te,pr=Nn,ct=(...e)=>Ci(...e),mr=e=>jr(e),Ve=Ii,Wr=e=>rc(e),$n=BigInt(0),Ni=BigInt(1);function zt(e,t=""){if(typeof e!="boolean"){let r=t&&`"${t}" `;throw new TypeError(r+"expected boolean, got type="+typeof e)}return e}function Mn(e){if(typeof e=="bigint"){if(!Kn(e))throw new RangeError("positive bigint expected, got "+e)}else Ui(e);return e}function Ht(e,t=""){if(typeof e!="number"){let r=t&&`"${t}" `;throw new TypeError(r+"expected number, got type="+typeof e)}if(!Number.isSafeInteger(e)){let r=t&&`"${t}" `;throw new RangeError(r+"expected safe integer, got "+e)}}function Xr(e){let t=Mn(e).toString(16);return t.length&1?"0"+t:t}function pc(e){if(typeof e!="string")throw new TypeError("hex string expected, got "+typeof e);return e===""?$n:BigInt("0x"+e)}function qe(e){return pc(Nn(e))}function ne(e){return pc(Nn(Jr(Rt(e)).reverse()))}function Vn(e,t){if(Te(t),t===0)throw new RangeError("zero length");e=Mn(e);let r=e.toString(16);if(r.length>t*2)throw new RangeError("number too large");return jr(r.padStart(t*2,"0"))}function ki(e,t){return Vn(e,t).reverse()}function mc(e,t){if(e=Y(e),t=Y(t),e.length!==t.length)return!1;let r=0;for(let n=0;n<e.length;n++)r|=e[n]^t[n];return r===0}function Jr(e){return Uint8Array.from(Y(e))}function qn(e){if(typeof e!="string")throw new TypeError("ascii string expected, got "+typeof e);return Uint8Array.from(e,(t,r)=>{let n=t.charCodeAt(0);if(t.length!==1||n>127)throw new RangeError(`string contains non-ASCII character "${e[r]}" with code ${n} at position ${r}`);return n})}var Kn=e=>typeof e=="bigint"&&$n<=e;function Gd(e,t,r){return Kn(e)&&Kn(t)&&Kn(r)&&t<=e&&e<r}function yr(e,t,r,n){if(!Gd(t,r,n))throw new RangeError("expected valid "+e+": "+r+" <= n < "+n+", got "+t)}function gr(e){if(e<$n)throw new Error("expected non-negative bigint, got "+e);let t;for(t=0;e>$n;e>>=Ni,t+=1);return t}var Qr=e=>(Ni<<BigInt(e))-Ni;function yc(e,t,r){if(Te(e,"hashLen"),Te(t,"qByteLen"),typeof r!="function")throw new TypeError("hmacFn must be a function");let n=y=>new Uint8Array(y),o=Uint8Array.of(),i=Uint8Array.of(0),s=Uint8Array.of(1),a=1e3,c=n(e),u=n(e),f=0,l=()=>{c.fill(1),u.fill(0),f=0},h=(...y)=>r(u,ct(c,...y)),m=(y=o)=>{u=h(i,y),c=h(),y.length!==0&&(u=h(s,y),c=h())},E=()=>{if(f++>=a)throw new Error("drbg: tried max amount of iterations");let y=0,S=[];for(;y<t;){c=h();let A=c.slice();S.push(A),y+=c.length}return ct(...S)};return(y,S)=>{l(),m(y);let A;for(;(A=S(E()))===void 0;)m();return l(),A}}function jt(e,t={},r={}){if(Object.prototype.toString.call(e)!=="[object Object]")throw new TypeError("expected valid options object");function n(i,s,a){if(!a&&s!=="function"&&!Object.hasOwn(e,i))throw new TypeError(`param "${i}" is invalid: expected own property`);let c=e[i];if(a&&c===void 0)return;let u=typeof c;if(u!==s||c===null)throw new TypeError(`param "${i}" is invalid: expected ${s}, got ${u}`)}let o=(i,s)=>Object.entries(i).forEach(([a,c])=>n(a,c,s));o(t,!1),o(r,!0)}var Ki=()=>{throw new Error("not implemented")};var yt=BigInt(0),nt=BigInt(1),ze=BigInt(2),wc=BigInt(3),Ec=BigInt(4),Sc=BigInt(5),Wd=BigInt(7),vc=BigInt(8),Xd=BigInt(9),Tc=BigInt(16);function it(e,t){if(t<=yt)throw new Error("mod: expected positive modulus, got "+t);let r=e%t;return r>=yt?r:t+r}function J(e,t,r){if(t<yt)throw new Error("pow2: expected non-negative exponent, got "+t);let n=e;for(;t-- >yt;)n*=n,n%=r;return n}function gc(e,t){if(e===yt)throw new Error("invert: expected non-zero number");if(t<=yt)throw new Error("invert: expected positive modulus, got "+t);let r=it(e,t),n=t,o=yt,i=nt,s=nt,a=yt;for(;r!==yt;){let u=n/r,f=n-r*u,l=o-s*u,h=i-a*u;n=r,r=f,o=s,i=a,s=l,a=h}if(n!==nt)throw new Error("invert: does not exist");return it(o,t)}function $i(e,t,r){let n=e;if(!n.eql(n.sqr(t),r))throw new Error("Cannot find square root")}function Ac(e,t){let r=e,n=(r.ORDER+nt)/Ec,o=r.pow(t,n);return $i(r,o,t),o}function Jd(e,t){let r=e,n=(r.ORDER-Sc)/vc,o=r.mul(t,ze),i=r.pow(o,n),s=r.mul(t,i),a=r.mul(r.mul(s,ze),i),c=r.mul(s,r.sub(a,r.ONE));return $i(r,c,t),c}function Qd(e){let t=br(e),r=Ic(e),n=r(t,t.neg(t.ONE)),o=r(t,n),i=r(t,t.neg(n)),s=(e+Wd)/Tc;return((a,c)=>{let u=a,f=u.pow(c,s),l=u.mul(f,n),h=u.mul(f,o),m=u.mul(f,i),E=u.eql(u.sqr(l),c),v=u.eql(u.sqr(h),c);f=u.cmov(f,l,E),l=u.cmov(m,h,v);let y=u.eql(u.sqr(l),c),S=u.cmov(f,l,y);return $i(u,S,c),S})}function Ic(e){if(e<wc)throw new Error("sqrt is not defined for small field");let t=e-nt,r=0;for(;t%ze===yt;)t/=ze,r++;let n=ze,o=br(e);for(;bc(o,n)===1;)if(n++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(r===1)return Ac;let i=o.pow(n,t),s=(t+nt)/ze;return function(c,u){let f=c;if(f.is0(u))return u;if(bc(f,u)!==1)throw new Error("Cannot find square root");let l=r,h=f.mul(f.ONE,i),m=f.pow(u,t),E=f.pow(u,s);for(;!f.eql(m,f.ONE);){if(f.is0(m))return f.ZERO;let v=1,y=f.sqr(m);for(;!f.eql(y,f.ONE);)if(v++,y=f.sqr(y),v===l)throw new Error("Cannot find square root");let S=nt<<BigInt(l-v-1),A=f.pow(h,S);l=v,h=f.sqr(A),m=f.mul(m,h),E=f.mul(E,A)}return E}}function th(e){return e%Ec===wc?Ac:e%vc===Sc?Jd:e%Tc===Xd?Qd(e):Ic(e)}var me=(e,t)=>(it(e,t)&nt)===nt,eh=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Mi(e){let t={ORDER:"bigint",BYTES:"number",BITS:"number"},r=eh.reduce((n,o)=>(n[o]="function",n),t);if(jt(e,r),Ht(e.BYTES,"BYTES"),Ht(e.BITS,"BITS"),e.BYTES<1||e.BITS<1)throw new Error("invalid field: expected BYTES/BITS > 0");if(e.ORDER<=nt)throw new Error("invalid field: expected ORDER > 1, got "+e.ORDER);return e}function rh(e,t,r){let n=e;if(r<yt)throw new Error("invalid exponent, negatives unsupported");if(r===yt)return n.ONE;if(r===nt)return t;let o=n.ONE,i=t;for(;r>yt;)r&nt&&(o=n.mul(o,i)),i=n.sqr(i),r>>=nt;return o}function tn(e,t,r=!1){let n=e,o=new Array(t.length).fill(r?n.ZERO:void 0),i=t.reduce((a,c,u)=>n.is0(c)?a:(o[u]=a,n.mul(a,c)),n.ONE),s=n.inv(i);return t.reduceRight((a,c,u)=>n.is0(c)?a:(o[u]=n.mul(a,o[u]),n.mul(a,c)),s),o}function bc(e,t){let r=e,n=(r.ORDER-nt)/ze,o=r.pow(t,n),i=r.eql(o,r.ONE),s=r.eql(o,r.ZERO),a=r.eql(o,r.neg(r.ONE));if(!i&&!s&&!a)throw new Error("invalid Legendre symbol result");return i?1:s?0:-1}function nh(e,t){if(t!==void 0&&Ui(t),e<=yt)throw new Error("invalid n length: expected positive n, got "+e);if(t!==void 0&&t<1)throw new Error("invalid n length: expected positive bit length, got "+t);let r=gr(e);if(t!==void 0&&t<r)throw new Error(`invalid n length: expected bit length (${r}) >= n.length (${t})`);let n=t!==void 0?t:r,o=Math.ceil(n/8);return{nBitLength:n,nByteLength:o}}var xc=new WeakMap,zn=class{ORDER;BITS;BYTES;isLE;ZERO=yt;ONE=nt;_lengths;_mod;constructor(t,r={}){if(t<=nt)throw new Error("invalid field: expected ORDER > 1, got "+t);let n;this.isLE=!1,r!=null&&typeof r=="object"&&(typeof r.BITS=="number"&&(n=r.BITS),typeof r.sqrt=="function"&&Object.defineProperty(this,"sqrt",{value:r.sqrt,enumerable:!0}),typeof r.isLE=="boolean"&&(this.isLE=r.isLE),r.allowedLengths&&(this._lengths=Object.freeze(r.allowedLengths.slice())),typeof r.modFromBytes=="boolean"&&(this._mod=r.modFromBytes));let{nBitLength:o,nByteLength:i}=nh(t,n);if(i>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");this.ORDER=t,this.BITS=o,this.BYTES=i,Object.freeze(this)}create(t){return it(t,this.ORDER)}isValid(t){if(typeof t!="bigint")throw new TypeError("invalid field element: expected bigint, got "+typeof t);return yt<=t&&t<this.ORDER}is0(t){return t===yt}isValidNot0(t){return!this.is0(t)&&this.isValid(t)}isOdd(t){return(t&nt)===nt}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 rh(this,t,r)}div(t,r){return it(t*gc(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 gc(t,this.ORDER)}sqrt(t){let r=xc.get(this);return r||xc.set(this,r=th(this.ORDER)),r(this,t)}toBytes(t){return this.isLE?ki(t,this.BYTES):Vn(t,this.BYTES)}fromBytes(t,r=!1){Y(t);let{_lengths:n,BYTES:o,isLE:i,ORDER:s,_mod:a}=this;if(n){if(t.length<1||!n.includes(t.length)||t.length>o)throw new Error("Field.fromBytes: expected "+n+" bytes, got "+t.length);let u=new Uint8Array(o);u.set(t,i?0:u.length-t.length),t=u}if(t.length!==o)throw new Error("Field.fromBytes: expected "+o+" bytes, got "+t.length);let c=i?ne(t):qe(t);if(a&&(c=it(c,s)),!r&&!this.isValid(c))throw new Error("invalid field element: outside of range 0..ORDER");return c}invertBatch(t){return tn(this,t)}cmov(t,r,n){return zt(n,"condition"),n?r:t}};Object.freeze(zn.prototype);function br(e,t={}){return new zn(e,t)}function Cc(e){if(typeof e!="bigint")throw new Error("field order must be bigint");if(e<=nt)throw new Error("field order must be greater than 1");let t=gr(e-nt);return Math.ceil(t/8)}function Vi(e){let t=Cc(e);return t+Math.ceil(t/2)}function qi(e,t,r=!1){Y(e);let n=e.length,o=Cc(t),i=Math.max(Vi(t),16);if(n<i||n>1024)throw new Error("expected "+i+"-1024 bytes of input, got "+n);let s=r?ne(e):qe(e),a=it(s,t-nt)+nt;return r?ki(a,o):Vn(a,o)}var xr=BigInt(0),He=BigInt(1);function en(e,t){let r=t.negate();return e?r:t}function je(e,t){let r=tn(e.Fp,t.map(n=>n.Z));return t.map((n,o)=>e.fromAffine(n.toAffine(r[o])))}function Dc(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+e)}function zi(e,t){Dc(e,t);let r=Math.ceil(t/e)+1,n=2**(e-1),o=2**e,i=Qr(e),s=BigInt(e);return{windows:r,windowSize:n,mask:i,maxNumber:o,shiftBy:s}}function _c(e,t,r){let{windowSize:n,mask:o,maxNumber:i,shiftBy:s}=r,a=Number(e&o),c=e>>s;a>n&&(a-=i,c+=He);let u=t*n,f=u+Math.abs(a)-1,l=a===0,h=a<0,m=t%2!==0;return{nextN:c,offset:f,isZero:l,isNeg:h,isNegF:m,offsetF:u}}var Hi=new WeakMap,Pc=new WeakMap;function ji(e){return Pc.get(e)||1}function Bc(e){if(e!==xr)throw new Error("invalid wNAF")}var wr=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>xr;)r&He&&(n=n.add(o)),o=o.double(),r>>=He;return n}precomputeWindow(t,r){let{windows:n,windowSize:o}=zi(r,this.bits),i=[],s=t,a=s;for(let c=0;c<n;c++){a=s,i.push(a);for(let u=1;u<o;u++)a=a.add(s),i.push(a);s=a.double()}return i}wNAF(t,r,n){if(!this.Fn.isValid(n))throw new Error("invalid scalar");let o=this.ZERO,i=this.BASE,s=zi(t,this.bits);for(let a=0;a<s.windows;a++){let{nextN:c,offset:u,isZero:f,isNeg:l,isNegF:h,offsetF:m}=_c(n,a,s);n=c,f?i=i.add(en(h,r[m])):o=o.add(en(l,r[u]))}return Bc(n),{p:o,f:i}}wNAFUnsafe(t,r,n,o=this.ZERO){let i=zi(t,this.bits);for(let s=0;s<i.windows&&n!==xr;s++){let{nextN:a,offset:c,isZero:u,isNeg:f}=_c(n,s,i);if(n=a,!u){let l=r[c];o=o.add(f?l.negate():l)}}return Bc(n),o}getPrecomputes(t,r,n){let o=Hi.get(r);return o||(o=this.precomputeWindow(r,t),t!==1&&(typeof n=="function"&&(o=n(o)),Hi.set(r,o))),o}cached(t,r,n){let o=ji(t);return this.wNAF(o,this.getPrecomputes(o,t,n),r)}unsafe(t,r,n,o){let i=ji(t);return i===1?this._unsafeLadder(t,r,o):this.wNAFUnsafe(i,this.getPrecomputes(i,t,n),r,o)}createCache(t,r){Dc(r,this.bits),Pc.set(t,r),Hi.delete(t)}hasCache(t){return ji(t)!==1}};function Oc(e,t,r,n){let o=t,i=e.ZERO,s=e.ZERO;for(;r>xr||n>xr;)r&He&&(i=i.add(o)),n&He&&(s=s.add(o)),o=o.double(),r>>=He,n>>=He;return{p1:i,p2:s}}function Rc(e,t,r){if(t){if(t.ORDER!==e)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return Mi(t),t}else return br(e,{isLE:r})}function Hn(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 c of["p","n","h"]){let u=t[c];if(!(typeof u=="bigint"&&u>xr))throw new Error(`CURVE.${c} must be positive bigint`)}let o=Rc(t.p,r.Fp,n),i=Rc(t.n,r.Fn,n),a=["Gx","Gy","a",e==="weierstrass"?"b":"d"];for(let c of a)if(!o.isValid(t[c]))throw new Error(`CURVE.${c} must be valid field element of CURVE.Fp`);return t=Object.freeze(Object.assign({},t)),{CURVE:t,Fp:o,Fn:i}}function jn(e,t){return function(n){let o=e(n);return{secretKey:o,publicKey:t(o)}}}var _e=BigInt(0),lt=BigInt(1),Yi=BigInt(2),oh=BigInt(8);function ih(e,t,r,n){let o=e.sqr(r),i=e.sqr(n),s=e.add(e.mul(t.a,o),i),a=e.add(e.ONE,e.mul(t.d,e.mul(o,i)));return e.eql(s,a)}function Fc(e,t={}){let r=t,n=Hn("edwards",e,r,r.FpFnLE),{Fp:o,Fn:i}=n,s=n.CURVE,{h:a}=s;jt(r,{},{uvRatio:"function"});let c=Yi<<BigInt(i.BYTES*8)-lt,u=v=>o.create(v),f=r.uvRatio===void 0?(v,y)=>{try{return{isValid:!0,value:o.sqrt(o.div(v,y))}}catch{return{isValid:!1,value:_e}}}:r.uvRatio;if(!ih(o,s,s.Gx,s.Gy))throw new Error("bad curve params: generator point");function l(v,y,S=!1){let A=S?lt:_e;return yr("coordinate "+v,y,A,c),y}function h(v){if(!(v instanceof m))throw new Error("EdwardsPoint expected")}class m{static BASE=new m(s.Gx,s.Gy,lt,u(s.Gx*s.Gy));static ZERO=new m(_e,lt,lt,_e);static Fp=o;static Fn=i;X;Y;Z;T;constructor(y,S,A,_){this.X=l("x",y),this.Y=l("y",S),this.Z=l("z",A,!0),this.T=l("t",_),Object.freeze(this)}static CURVE(){return s}static fromAffine(y){if(y instanceof m)throw new Error("extended point not allowed");let{x:S,y:A}=y||{};return l("x",S),l("y",A),new m(S,A,lt,u(S*A))}static fromBytes(y,S=!1){let A=o.BYTES,{a:_,d:U}=s;y=Jr(Y(y,A,"point")),zt(S,"zip215");let F=Jr(y),M=y[A-1];F[A-1]=M&-129;let L=ne(F),w=S?c:o.ORDER;yr("point.y",L,_e,w);let C=u(L*L),N=u(C-lt),P=u(U*C-_),{isValid:d,value:g}=f(N,P);if(!d)throw new Error("bad point: invalid y coordinate");let T=(g&lt)===lt,b=(M&128)!==0;if(!S&&g===_e&&b)throw new Error("bad point: x=0 and x_0=1");return b!==T&&(g=u(-g)),m.fromAffine({x:g,y:L})}static fromHex(y,S=!1){return m.fromBytes(mr(y),S)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(y=8,S=!0){return E.createCache(this,y),S||this.multiply(Yi),this}assertValidity(){let y=this,{a:S,d:A}=s;if(y.is0())throw new Error("bad point: ZERO");let{X:_,Y:U,Z:F,T:M}=y,L=u(_*_),w=u(U*U),C=u(F*F),N=u(C*C),P=u(L*S),d=u(C*u(P+w)),g=u(N+u(A*u(L*w)));if(d!==g)throw new Error("bad point: equation left != right (1)");let T=u(_*U),b=u(F*M);if(T!==b)throw new Error("bad point: equation left != right (2)")}equals(y){h(y);let{X:S,Y:A,Z:_}=this,{X:U,Y:F,Z:M}=y,L=u(S*M),w=u(U*_),C=u(A*M),N=u(F*_);return L===w&&C===N}is0(){return this.equals(m.ZERO)}negate(){return new m(u(-this.X),this.Y,this.Z,u(-this.T))}double(){let{a:y}=s,{X:S,Y:A,Z:_}=this,U=u(S*S),F=u(A*A),M=u(Yi*u(_*_)),L=u(y*U),w=S+A,C=u(u(w*w)-U-F),N=L+F,P=N-M,d=L-F,g=u(C*P),T=u(N*d),b=u(C*d),x=u(P*N);return new m(g,T,x,b)}add(y){h(y);let{a:S,d:A}=s,{X:_,Y:U,Z:F,T:M}=this,{X:L,Y:w,Z:C,T:N}=y,P=u(_*L),d=u(U*w),g=u(M*A*N),T=u(F*C),b=u((_+U)*(L+w)-P-d),x=T-g,I=T+g,R=u(d-S*P),D=u(b*x),k=u(I*R),$=u(b*R),j=u(x*I);return new m(D,k,j,$)}subtract(y){return h(y),this.add(y.negate())}multiply(y){if(!i.isValidNot0(y))throw new RangeError("invalid scalar: expected 1 <= sc < curve.n");let{p:S,f:A}=E.cached(this,y,_=>je(m,_));return je(m,[S,A])[0]}multiplyUnsafe(y){if(!i.isValid(y))throw new RangeError("invalid scalar: expected 0 <= sc < curve.n");return y===_e?m.ZERO:this.is0()||y===lt?this:E.unsafe(this,y,S=>je(m,S))}isSmallOrder(){return this.clearCofactor().is0()}isTorsionFree(){return E.unsafe(this,s.n).is0()}toAffine(y){let S=this,A=y,{X:_,Y:U,Z:F}=S,M=S.is0();A==null&&(A=M?oh:o.inv(F));let L=u(_*A),w=u(U*A),C=o.mul(F,A);if(M)return{x:_e,y:lt};if(C!==lt)throw new Error("invZ was invalid");return{x:L,y:w}}clearCofactor(){return a===lt?this:this.multiplyUnsafe(a)}toBytes(){let{x:y,y:S}=this.toAffine(),A=o.toBytes(S);return A[A.length-1]|=y&lt?128:0,A}toHex(){return pr(this.toBytes())}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let E=new wr(m,i.BITS);return i.BITS>=8&&m.BASE.precompute(8),Object.freeze(m.prototype),Object.freeze(m),m}var Yn=class{static BASE;static ZERO;static Fp;static Fn;ep;constructor(t){this.ep=t}static fromBytes(t){Ki()}static fromHex(t){Ki()}get x(){return this.toAffine().x}get y(){return this.toAffine().y}clearCofactor(){return this}assertValidity(){this.ep.assertValidity()}toAffine(t){return this.ep.toAffine(t)}toHex(){return pr(this.toBytes())}toString(){return this.toHex()}isTorsionFree(){return!0}isSmallOrder(){return!1}add(t){return this.assertSame(t),this.init(this.ep.add(t.ep))}subtract(t){return this.assertSame(t),this.init(this.ep.subtract(t.ep))}multiply(t){return this.init(this.ep.multiply(t))}multiplyUnsafe(t){return this.init(this.ep.multiplyUnsafe(t))}double(){return this.init(this.ep.double())}negate(){return this.init(this.ep.negate())}precompute(t,r){return this.ep.precompute(t,r),this}};function Lc(e,t,r={}){if(typeof t!="function")throw new Error('"hash" function param is required');let n=t,o=r;jt(o,{},{adjustScalarBytes:"function",randomBytes:"function",domain:"function",prehash:"function",zip215:"boolean",mapToCurve:"function"});let{prehash:i}=o,{BASE:s,Fp:a,Fn:c}=e,u=n.outputLen,f=2*a.BYTES;if(u!==void 0&&(Ht(u,"hash.outputLen"),u!==f))throw new Error(`hash.outputLen must be ${f}, got ${u}`);let l=o.randomBytes===void 0?Wr:o.randomBytes,h=o.adjustScalarBytes===void 0?d=>d:o.adjustScalarBytes,m=o.domain===void 0?(d,g,T)=>{if(zt(T,"phflag"),g.length||T)throw new Error("Contexts/pre-hash are not supported");return d}:o.domain;function E(d){return c.create(ne(d))}function v(d){let g=L.secretKey;Y(d,L.secretKey,"secretKey");let T=Y(n(d),2*g,"hashedSecretKey"),b=h(T.slice(0,g)),x=T.slice(g,2*g),I=E(b);return{head:b,prefix:x,scalar:I}}function y(d){let{head:g,prefix:T,scalar:b}=v(d),x=s.multiply(b),I=x.toBytes();return{head:g,prefix:T,scalar:b,point:x,pointBytes:I}}function S(d){return y(d).pointBytes}function A(d=Uint8Array.of(),...g){let T=ct(...g);return E(n(m(T,Y(d,void 0,"context"),!!i)))}function _(d,g,T={}){d=Y(d,void 0,"message"),i&&(d=i(d));let{prefix:b,scalar:x,pointBytes:I}=y(g),R=A(T.context,b,d),D=s.multiply(R).toBytes(),k=A(T.context,D,I,d),$=c.create(R+k*x);if(!c.isValid($))throw new Error("sign failed: invalid s");let j=ct(D,c.toBytes($));return Y(j,L.signature,"result")}let U={zip215:o.zip215};function F(d,g,T,b=U){let{context:x}=b,I=b.zip215===void 0?!!U.zip215:b.zip215,R=L.signature;d=Y(d,R,"signature"),g=Y(g,void 0,"message"),T=Y(T,L.publicKey,"publicKey"),I!==void 0&&zt(I,"zip215"),i&&(g=i(g));let D=R/2,k=d.subarray(0,D),$=ne(d.subarray(D,R)),j,G,q;try{j=e.fromBytes(T,I),G=e.fromBytes(k,I),q=s.multiplyUnsafe($)}catch{return!1}if(!I&&j.isSmallOrder())return!1;let at=A(x,k,T,g);return G.add(j.multiplyUnsafe(at)).subtract(q).clearCofactor().is0()}let M=a.BYTES,L={secretKey:M,publicKey:M,signature:2*M,seed:M};function w(d){return d=d===void 0?l(L.seed):d,Y(d,L.seed,"seed")}function C(d){return Ve(d)&&d.length===L.secretKey}function N(d,g){try{return!!e.fromBytes(d,g===void 0?U.zip215:g)}catch{return!1}}let P={getExtendedPublicKey:y,randomSecretKey:w,isValidSecretKey:C,isValidPublicKey:N,toMontgomery(d){let{y:g}=e.fromBytes(d),T=L.publicKey,b=T===32;if(!b&&T!==57)throw new Error("only defined for 25519 and 448");let x=b?a.div(lt+g,lt-g):a.div(g-lt,g+lt);return a.toBytes(x)},toMontgomerySecret(d){let g=L.secretKey;Y(d,g);let T=n(d.subarray(0,g));return h(T).subarray(0,g)}};return Object.freeze(L),Object.freeze(P),Object.freeze({keygen:jn(w,S),getPublicKey:S,sign:_,verify:F,utils:P,Point:e,lengths:L})}function rn(e,t){if(Ht(e),Ht(t),t<0||t>4)throw new Error("invalid I2OSP length: "+t);if(e<0||e>2**(8*t)-1)throw new Error("invalid I2OSP input: "+e);let r=Array.from({length:t}).fill(0);for(let n=t-1;n>=0;n--)r[n]=e&255,e>>>=8;return new Uint8Array(r)}function sh(e,t){let r=new Uint8Array(e.length);for(let n=0;n<e.length;n++)r[n]=e[n]^t[n];return r}function ah(e){if(!Ve(e)&&typeof e!="string")throw new Error("DST must be Uint8Array or ascii string");let t=typeof e=="string"?qn(e):e;if(t.length===0)throw new Error("DST must be non-empty");return t}function Zi(e,t,r,n){Y(e),Ht(r),t=ah(t),t.length>255&&(t=n(ct(qn("H2C-OVERSIZE-DST-"),t)));let{outputLen:o,blockLen:i}=n,s=Math.ceil(r/o);if(r>65535||s>255)throw new Error("expand_message_xmd: invalid lenInBytes");let a=ct(t,rn(t.length,1)),c=new Uint8Array(i),u=rn(r,2),f=new Array(s),l=n(ct(c,e,u,rn(0,1),a));f[0]=n(ct(l,rn(1,1),a));for(let m=1;m<s;m++){let E=[sh(l,f[m-1]),rn(m+1,1),a];f[m]=n(ct(...E))}return ct(...f).slice(0,r)}var Nc="HashToScalar-";var ch=BigInt(0),ye=BigInt(1),Uc=BigInt(2);var uh=BigInt(5),fh=BigInt(8),Er=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"),Ji={p:Er,n:BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),h:fh,a:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),d:BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),Gx:BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),Gy:BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")};function lh(e){let t=BigInt(10),r=BigInt(20),n=BigInt(40),o=BigInt(80),i=Er,a=e*e%i*e%i,c=J(a,Uc,i)*a%i,u=J(c,ye,i)*e%i,f=J(u,uh,i)*u%i,l=J(f,t,i)*f%i,h=J(l,r,i)*l%i,m=J(h,n,i)*h%i,E=J(m,o,i)*m%i,v=J(E,o,i)*m%i,y=J(v,t,i)*f%i;return{pow_p_5_8:J(y,Uc,i)*e%i,b2:a}}function dh(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}var Gi=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");function Qi(e,t){let r=Er,n=it(t*t*t,r),o=it(n*n*t,r),i=lh(e*o).pow_p_5_8,s=it(e*n*i,r),a=it(t*s*s,r),c=s,u=it(s*Gi,r),f=a===e,l=a===it(-e,r),h=a===it(-e*Gi,r);return f&&(s=c),(l||h)&&(s=u),me(s,r)&&(s=it(-s,r)),{isValid:f||l,value:s}}var Re=Fc(Ji,{uvRatio:Qi}),Be=Re.Fp,$c=Re.Fn;function hh(e){return Lc(Re,kn,Object.assign({adjustScalarBytes:dh,zip215:!0},e))}var Mc=hh({});var Wi=Gi,ph=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),mh=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),yh=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),gh=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952"),kc=e=>Qi(ye,e),bh=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),Xi=e=>Be.create(ne(e)&bh);function Kc(e){let{d:t}=Ji,r=Er,n=S=>Be.create(S),o=n(Wi*e*e),i=n((o+ye)*yh),s=BigInt(-1),a=n((s-t*o)*n(o+t)),{isValid:c,value:u}=Qi(i,a),f=n(u*e);me(f,r)||(f=n(-f)),c||(u=f),c||(s=o);let l=n(s*(o-ye)*gh-a),h=u*u,m=n((u+u)*a),E=n(l*ph),v=n(ye-h),y=n(ye+h);return new Re(n(m*y),n(v*E),n(E*y),n(m*v))}var De=class e extends Yn{static BASE=new e(Re.BASE);static ZERO=new e(Re.ZERO);static Fp=Be;static Fn=$c;constructor(t){super(t)}static fromAffine(t){return new e(Re.fromAffine(t))}assertSame(t){if(!(t instanceof e))throw new Error("RistrettoPoint expected")}init(t){return new e(t)}static fromBytes(t){Rt(t,32);let{a:r,d:n}=Ji,o=Er,i=U=>Be.create(U),s=Xi(t);if(!mc(Be.toBytes(s),t)||me(s,o))throw new Error("invalid ristretto255 encoding 1");let a=i(s*s),c=i(ye+r*a),u=i(ye-r*a),f=i(c*c),l=i(u*u),h=i(r*n*f-l),{isValid:m,value:E}=kc(i(h*l)),v=i(E*u),y=i(E*v*h),S=i((s+s)*v);me(S,o)&&(S=i(-S));let A=i(c*y),_=i(S*A);if(!m||me(_,o)||A===ch)throw new Error("invalid ristretto255 encoding 2");return new e(new Re(S,A,ye,_))}static fromHex(t){return e.fromBytes(jr(t))}toBytes(){let{X:t,Y:r,Z:n,T:o}=this.ep,i=Er,s=y=>Be.create(y),a=s(s(n+r)*s(n-r)),c=s(t*r),u=s(c*c),{value:f}=kc(s(a*u)),l=s(f*a),h=s(f*c),m=s(l*h*o),E;if(me(o*m,i)){let y=s(r*Wi),S=s(t*Wi);t=y,r=S,E=s(l*mh)}else E=h;me(t*m,i)&&(r=s(-r));let v=s((n-r)*E);return me(v,i)&&(v=s(-v)),Be.toBytes(v)}equals(t){this.assertSame(t);let{X:r,Y:n}=this.ep,{X:o,Y:i}=t.ep,s=u=>Be.create(u),a=s(r*i)===s(n*o),c=s(n*i)===s(r*o);return a||c}is0(){return this.equals(e.ZERO)}};Object.freeze(De.BASE);Object.freeze(De.ZERO);Object.freeze(De.prototype);Object.freeze(De);var xh=Object.freeze({Point:De,hashToCurve(e,t){let r=t?.DST===void 0?"ristretto255_XMD:SHA-512_R255MAP_RO_":t.DST,n=Zi(e,r,64,kn);return xh.deriveToCurve(n)},hashToScalar(e,t={DST:Nc}){let r=Zi(e,t.DST,64,kn);return $c.create(ne(r))},deriveToCurve(e){Rt(e,64);let t=Xi(e.subarray(0,32)),r=Kc(t),n=Xi(e.subarray(32,64)),o=Kc(n);return new De(r.add(o))}});var nn=class extends Error{constructor(t="An error occurred while verifying a message"){super(t),this.name="VerificationError"}},Zn=class extends Error{constructor(t="Missing Web Crypto API"){super(t),this.name="WebCryptoMissingError"}};var Vc={get(e=globalThis){let t=e.crypto;if(t?.subtle==null)throw new Zn("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 Ut=Vc;var Gn=32;var ts,wh=(async()=>{try{return await Ut.get().subtle.generateKey({name:"Ed25519"},!0,["sign","verify"]),!0}catch{return!1}})();async function Eh(e,t,r){if(e.buffer instanceof ArrayBuffer){let n=await Ut.get().subtle.importKey("raw",e.buffer,{name:"Ed25519"},!1,["verify"]);return await Ut.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 Sh(e,t,r){return Mc.verify(t,r instanceof Uint8Array?r:r.subarray(),e)}async function qc(e,t,r){return ts==null&&(ts=await wh),ts?Eh(e,t,r):Sh(e,t,r)}function Wn(e){return e==null?!1:typeof e.then=="function"&&typeof e.catch=="function"&&typeof e.finally=="function"}var Xn=class{type="Ed25519";raw;constructor(t){this.raw=es(t,Gn)}toMultihash(){return St.digest(lr(this))}toCID(){return H.createV1(114,this.toMultihash())}toString(){return X.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:W(this.raw,t.raw)}verify(t,r,n){n?.signal?.throwIfAborted();let o=qc(this.raw,r,t);return Wn(o)?o.then(i=>(n?.signal?.throwIfAborted(),i)):o}};function rs(e){return e=es(e,Gn),new Xn(e)}function es(e,t){if(e=Uint8Array.from(e??[]),e.length!==t)throw new et(`Key must be a Uint8Array of length ${t}, got ${e.length}`);return e}var Th=Math.pow(2,7),Ah=Math.pow(2,14),Ih=Math.pow(2,21),ns=Math.pow(2,28),os=Math.pow(2,35),is=Math.pow(2,42),ss=Math.pow(2,49),Q=128,bt=127;function oe(e){if(e<Th)return 1;if(e<Ah)return 2;if(e<Ih)return 3;if(e<ns)return 4;if(e<os)return 5;if(e<is)return 6;if(e<ss)return 7;if(Number.MAX_SAFE_INTEGER!=null&&e>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function on(e,t,r=0){switch(oe(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 as(e,t){let r=e[t],n=0;if(n+=r&bt,r<Q||(r=e[t+1],n+=(r&bt)<<7,r<Q)||(r=e[t+2],n+=(r&bt)<<14,r<Q)||(r=e[t+3],n+=(r&bt)<<21,r<Q)||(r=e[t+4],n+=(r&bt)*ns,r<Q)||(r=e[t+5],n+=(r&bt)*os,r<Q)||(r=e[t+6],n+=(r&bt)*is,r<Q)||(r=e[t+7],n+=(r&bt)*ss,r<Q))return n;throw new RangeError("Could not decode varint")}function Ch(e,t){let r=e.get(t),n=0;if(n+=r&bt,r<Q||(r=e.get(t+1),n+=(r&bt)<<7,r<Q)||(r=e.get(t+2),n+=(r&bt)<<14,r<Q)||(r=e.get(t+3),n+=(r&bt)<<21,r<Q)||(r=e.get(t+4),n+=(r&bt)*ns,r<Q)||(r=e.get(t+5),n+=(r&bt)*os,r<Q)||(r=e.get(t+6),n+=(r&bt)*is,r<Q)||(r=e.get(t+7),n+=(r&bt)*ss,r<Q))return n;throw new RangeError("Could not decode varint")}function cs(e,t=0){return e instanceof Uint8Array?as(e,t):Ch(e,t)}var us=new Float32Array([-0]),Pe=new Uint8Array(us.buffer);function Hc(e,t,r){us[0]=e,t[r]=Pe[0],t[r+1]=Pe[1],t[r+2]=Pe[2],t[r+3]=Pe[3]}function jc(e,t){return Pe[0]=e[t],Pe[1]=e[t+1],Pe[2]=e[t+2],Pe[3]=e[t+3],us[0]}var fs=new Float64Array([-0]),xt=new Uint8Array(fs.buffer);function Yc(e,t,r){fs[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 Zc(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],fs[0]}var Bh=BigInt(Number.MAX_SAFE_INTEGER),Rh=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 Ye;if(t<Bh&&t>Rh)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>Gc&&(o=0n,++n>Gc&&(n=0n))),new e(Number(o),Number(n))}static fromNumber(t){if(t===0)return Ye;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):Ye}},Ye=new Dt(0,0);Ye.toBigInt=function(){return 0n};Ye.zzEncode=Ye.zzDecode=function(){return this};Ye.length=function(){return 1};var Gc=4294967296n;function Wc(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 Xc(e,t,r){if(r-t<1)return"";let o,i=[],s=0,a;for(;t<r;)a=e[t++],a<128?i[s++]=a:a>191&&a<224?i[s++]=(a&31)<<6|e[t++]&63:a>239&&a<365?(a=((a&7)<<18|(e[t++]&63)<<12|(e[t++]&63)<<6|e[t++]&63)-65536,i[s++]=55296+(a>>10),i[s++]=56320+(a&1023)):i[s++]=(a&15)<<12|(e[t++]&63)<<6|e[t++]&63,s>8191&&((o??(o=[])).push(String.fromCharCode.apply(String,i)),s=0);return o!=null?(s>0&&o.push(String.fromCharCode.apply(String,i.slice(0,s))),o.join("")):String.fromCharCode.apply(String,i.slice(0,s))}function ls(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 Yt(e,t){return RangeError(`index out of range: ${e.pos} + ${t??1} > ${e.len}`)}function Jn(e,t){return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0}var ds=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,Yt(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 Yt(this,4);return Jn(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw Yt(this,4);return Jn(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw Yt(this,4);let t=jc(this.buf,this.pos);return this.pos+=4,t}double(){if(this.pos+8>this.len)throw Yt(this,4);let t=Zc(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 Yt(this,t);return this.pos+=t,r===n?new Uint8Array(0):this.buf.subarray(r,n)}string(){let t=this.bytes();return Xc(t,0,t.length)}skip(t){if(typeof t=="number"){if(this.pos+t>this.len)throw Yt(this,t);this.pos+=t}else do if(this.pos>=this.len)throw Yt(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 Yt(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 Yt(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 Yt(this,8);let t=Jn(this.buf,this.pos+=4),r=Jn(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=as(this.buf,this.pos);return this.pos+=oe(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 sn(e){return new ds(e instanceof Uint8Array?e:e.subarray())}function Sr(e,t,r){let n=sn(e);return t.decode(n,void 0,r)}function hs(e){let t=e??8192,r=t>>>1,n,o=t;return function(s){if(s<1||s>r)return _t(s);o+s>t&&(n=_t(t),o=0);let a=n.subarray(o,o+=s);return(o&7)!==0&&(o=(o|7)+1),a}}var Ze=class{fn;len;next;val;constructor(t,r,n){this.fn=t,this.len=r,this.next=void 0,this.val=n}};function ps(){}var ys=class{head;tail;len;next;constructor(t){this.head=t.head,this.tail=t.tail,this.len=t.len,this.next=t.states}},Dh=hs();function Ph(e){return globalThis.Buffer!=null?_t(e):Dh(e)}var cn=class{len;head;tail;states;constructor(){this.len=0,this.head=new Ze(ps,0,0),this.tail=this.head,this.states=null}_push(t,r,n){return this.tail=this.tail.next=new Ze(t,r,n),this.len+=r,this}uint32(t){return this.len+=(this.tail=this.tail.next=new gs((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(Qn,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(Qn,r.length(),r)}uint64Number(t){return this._push(on,oe(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(Qn,r.length(),r)}sint64Number(t){let r=Dt.fromNumber(t).zzEncode();return this._push(Qn,r.length(),r)}sint64String(t){return this.sint64(BigInt(t))}bool(t){return this._push(ms,1,t?1:0)}fixed32(t){return this._push(an,4,t>>>0)}sfixed32(t){return this.fixed32(t)}fixed64(t){let r=Dt.fromBigInt(t);return this._push(an,4,r.lo)._push(an,4,r.hi)}fixed64Number(t){let r=Dt.fromNumber(t);return this._push(an,4,r.lo)._push(an,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(Hc,4,t)}double(t){return this._push(Yc,8,t)}bytes(t){let r=t.length>>>0;return r===0?this._push(ms,1,0):this.uint32(r)._push(Fh,r,t)}string(t){let r=Wc(t);return r!==0?this.uint32(r)._push(ls,r,t):this._push(ms,1,0)}fork(){return this.states=new ys(this),this.head=this.tail=new Ze(ps,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 Ze(ps,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=Ph(this.len),n=0;for(;t!=null;)t.fn(t.val,r,n),n+=t.len,t=t.next;return r}};function ms(e,t,r){t[r]=e&255}function Oh(e,t,r){for(;e>127;)t[r++]=e&127|128,e>>>=7;t[r]=e}var gs=class extends Ze{next;constructor(t,r){super(Oh,t,r),this.next=void 0}};function Qn(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 an(e,t,r){t[r]=e&255,t[r+1]=e>>>8&255,t[r+2]=e>>>16&255,t[r+3]=e>>>24}function Fh(e,t,r){t.set(e,r)}globalThis.Buffer!=null&&(cn.prototype.bytes=function(e){let t=e.length>>>0;return this.uint32(t),t>0&&this._push(Lh,t,e),this},cn.prototype.string=function(e){let t=globalThis.Buffer.byteLength(e);return this.uint32(t),t>0&&this._push(Nh,t,e),this});function Lh(e,t,r){t.set(e,r)}function Nh(e,t,r){e.length<40?ls(e,t,r):t.utf8Write!=null?t.utf8Write(e,r):t.set(V(e),r)}function bs(){return new cn}function vr(e,t){let r=bs();return t.encode(e,r,{lengthDelimited:!1}),r.finish()}function*Tr(e,t,r){let n=sn(e);yield*t.stream(n,void 0,"$",r)}var to={VARINT:0,BIT64:1,LENGTH_DELIMITED:2,START_GROUP:3,END_GROUP:4,BIT32:5};function eo(e,t,r,n,o){return{name:e,type:t,encode:r,decode:n,stream:o}}function un(e){function t(i){if(e[i.toString()]==null)throw new Error("Invalid enum value");return e[i]}let r=function(s,a){let c=t(s);a.int32(c)},n=function(s){let a=s.int32();return t(a)},o=function*(s){let a=s.int32();yield t(a)};return eo("enum",to.VARINT,r,n,o)}function Ar(e,t,r){return eo("message",to.LENGTH_DELIMITED,e,t,r)}var tt;(function(e){e.RSA="RSA",e.Ed25519="Ed25519",e.secp256k1="secp256k1",e.ECDSA="ECDSA"})(tt||(tt={}));var xs;(function(e){e[e.RSA=0]="RSA",e[e.Ed25519=1]="Ed25519",e[e.secp256k1=2]="secp256k1",e[e.ECDSA=3]="ECDSA"})(xs||(xs={}));(function(e){e.codec=()=>un(xs)})(tt||(tt={}));var ie;(function(e){let t;e.codec=()=>(t==null&&(t=Ar((i,s,a={})=>{a.lengthDelimited!==!1&&s.fork(),i.Type!=null&&(s.uint32(8),tt.codec().encode(i.Type,s)),i.Data!=null&&(s.uint32(18),s.bytes(i.Data)),a.lengthDelimited!==!1&&s.ldelim()},(i,s,a={})=>{let c={},u=s==null?i.len:i.pos+s;for(;i.pos<u;){let f=i.uint32();switch(f>>>3){case 1:{c.Type=tt.codec().decode(i);break}case 2:{c.Data=i.bytes();break}default:{i.skipType(f&7);break}}}return c},function*(i,s,a,c={}){let u=s==null?i.len:i.pos+s;for(;i.pos<u;){let f=i.uint32();switch(f>>>3){case 1:{yield{field:`${a}.Type`,value:tt.codec().decode(i)};break}case 2:{yield{field:`${a}.Data`,value:i.bytes()};break}default:{i.skipType(f&7);break}}}})),t);function r(i){return vr(i,e.codec())}e.encode=r;function n(i,s){return Sr(i,e.codec(),s)}e.decode=n;function o(i,s){return Tr(i,e.codec(),s)}e.stream=o})(ie||(ie={}));var ws;(function(e){let t;e.codec=()=>(t==null&&(t=Ar((i,s,a={})=>{a.lengthDelimited!==!1&&s.fork(),i.Type!=null&&(s.uint32(8),tt.codec().encode(i.Type,s)),i.Data!=null&&(s.uint32(18),s.bytes(i.Data)),a.lengthDelimited!==!1&&s.ldelim()},(i,s,a={})=>{let c={},u=s==null?i.len:i.pos+s;for(;i.pos<u;){let f=i.uint32();switch(f>>>3){case 1:{c.Type=tt.codec().decode(i);break}case 2:{c.Data=i.bytes();break}default:{i.skipType(f&7);break}}}return c},function*(i,s,a,c={}){let u=s==null?i.len:i.pos+s;for(;i.pos<u;){let f=i.uint32();switch(f>>>3){case 1:{yield{field:`${a}.Type`,value:tt.codec().decode(i)};break}case 2:{yield{field:`${a}.Data`,value:i.bytes()};break}default:{i.skipType(f&7);break}}}})),t);function r(i){return vr(i,e.codec())}e.encode=r;function n(i,s){return Sr(i,e.codec(),s)}e.decode=n;function o(i,s){return Tr(i,e.codec(),s)}e.stream=o})(ws||(ws={}));var ln={};Et(ln,{MAX_RSA_KEY_SIZE:()=>Es,generateRSAKeyPair:()=>nu,jwkToJWKKeyPair:()=>ou,jwkToPkcs1:()=>$h,jwkToPkix:()=>As,jwkToRSAPrivateKey:()=>Bs,pkcs1MessageToJwk:()=>vs,pkcs1MessageToRSAPrivateKey:()=>Is,pkcs1ToJwk:()=>Kh,pkcs1ToRSAPrivateKey:()=>ru,pkixMessageToJwk:()=>Ts,pkixMessageToRSAPublicKey:()=>_s,pkixToJwk:()=>Mh,pkixToRSAPublicKey:()=>Cs});var Ir=class{type="RSA";jwk;_raw;_multihash;constructor(t,r){this.jwk=t,this._multihash=r}get raw(){return this._raw==null&&(this._raw=ln.jwkToPkix(this.jwk)),this._raw}toMultihash(){return this._multihash}toCID(){return H.createV1(114,this._multihash)}toString(){return X.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:W(this.raw,t.raw)}verify(t,r,n){return eu(this.jwk,r,t,n)}},fn=class{type="RSA";jwk;_raw;publicKey;constructor(t,r){this.jwk=t,this.publicKey=r}get raw(){return this._raw==null&&(this._raw=ln.jwkToPkcs1(this.jwk)),this._raw}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:W(this.raw,t.raw)}sign(t,r){return tu(this.jwk,t,r)}};var Es=8192,Ss=18,Uh=1062,kh=Uint8Array.from([48,13,6,9,42,134,72,134,247,13,1,1,1,5,0]);function Kh(e){let t=le(e);return vs(t)}function vs(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 $h(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 et("JWK was missing components");return ve([It(Uint8Array.from([0])),It(V(e.n,"base64url")),It(V(e.e,"base64url")),It(V(e.d,"base64url")),It(V(e.p,"base64url")),It(V(e.q,"base64url")),It(V(e.dp,"base64url")),It(V(e.dq,"base64url")),It(V(e.qi,"base64url"))]).subarray()}function Mh(e){let t=le(e,{offset:0});return Ts(t)}function Ts(e){let t=le(e[1],{offset:0});return{kty:"RSA",n:z(t[0],"base64url"),e:z(t[1],"base64url")}}function As(e){if(e.n==null||e.e==null)throw new et("JWK was missing components");return ve([kh,Pn(ve([It(V(e.n,"base64url")),It(V(e.e,"base64url"))]))]).subarray()}function ru(e){let t=le(e);return Is(t)}function Is(e){let t=vs(e);return Bs(t)}function Cs(e,t){if(e.byteLength>=Uh)throw new rr("Key size is too large");let r=le(e,{offset:0});return _s(r,e,t)}function _s(e,t,r){let n=Ts(e);if(r==null){let o=hr(ie.encode({Type:tt.RSA,Data:t}));r=Vt(Ss,o)}return new Ir(n,r)}function Bs(e){if(su(e)>Es)throw new et("Key size is too large");let t=ou(e),r=hr(ie.encode({Type:tt.RSA,Data:As(t.publicKey)})),n=Vt(Ss,r);return new fn(t.privateKey,new Ir(t.publicKey,n))}async function nu(e){if(e>Es)throw new et("Key size is too large");let t=await iu(e),r=hr(ie.encode({Type:tt.RSA,Data:As(t.publicKey)})),n=Vt(Ss,r);return new fn(t.privateKey,new Ir(t.publicKey,n))}function ou(e){if(e==null)throw new et("Missing key parameter");return{privateKey:e,publicKey:{kty:e.kty,n:e.n,e:e.e}}}async function iu(e,t){let r=await Ut.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 Vh(r,t);return{privateKey:n[0],publicKey:n[1]}}async function tu(e,t,r){let n=await Ut.get().subtle.importKey("jwk",e,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["sign"]);r?.signal?.throwIfAborted();let o=await Ut.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 eu(e,t,r,n){let o=await Ut.get().subtle.importKey("jwk",e,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["verify"]);n?.signal?.throwIfAborted();let i=await Ut.get().subtle.verify({name:"RSASSA-PKCS1-v1_5"},o,t,r instanceof Uint8Array?r:r.subarray());return n?.signal?.throwIfAborted(),i}async function Vh(e,t){if(e.privateKey==null||e.publicKey==null)throw new et("Private and public key are required");let r=await Promise.all([Ut.get().subtle.exportKey("jwk",e.privateKey),Ut.get().subtle.exportKey("jwk",e.publicKey)]);return t?.signal?.throwIfAborted(),r}function su(e){if(e.kty!=="RSA")throw new et("invalid key type");if(e.n==null)throw new et("invalid key modulus");return V(e.n,"base64url").length*8}var ro=class{oHash;iHash;blockLen;outputLen;canXOF=!1;finished=!1;destroyed=!1;constructor(t,r){if(On(t),Rt(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),he(o)}update(t){return dr(this),this.iHash.update(t),this}digestInto(t){dr(this),Fn(t,this),this.finished=!0;let r=t.subarray(0,this.outputLen);this.iHash.digestInto(r),this.oHash.update(r),this.oHash.digestInto(r),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:a}=this;return t=t,t.finished=o,t.destroyed=i,t.blockLen=s,t.outputLen=a,t.oHash=r._cloneInto(t.oHash),t.iHash=n._cloneInto(t.iHash),t}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},au=(()=>{let e=((t,r,n)=>new ro(t,r).update(n).digest());return e.create=(t,r)=>new ro(t,r),e})();var cu=(e,t)=>(e+(e>=0?t:-t)/uu)/t;function qh(e,t,r){yr("scalar",e,se,r);let[[n,o],[i,s]]=t,a=cu(s*e,r),c=cu(-o*e,r),u=e-a*n-c*i,f=-a*o-c*s,l=u<se,h=f<se;l&&(u=-u),h&&(f=-f);let m=Qr(Math.ceil(gr(r)/2))+Oe;if(u<se||u>=m||f<se||f>=m)throw new Error("splitScalar (endomorphism): failed for k");return{k1neg:l,k1:u,k2neg:h,k2:f}}function Ds(e){if(!["compact","recovered","der"].includes(e))throw new Error('Signature format must be "compact", "recovered", or "der"');return e}function Rs(e,t){jt(e);let r={};for(let n of Object.keys(t))r[n]=e[n]===void 0?t[n]:e[n];return zt(r.lowS,"lowS"),zt(r.prehash,"prehash"),r.format!==void 0&&Ds(r.format),r}var Ps=class extends Error{constructor(t=""){super(t)}},Zt={Err:Ps,_tlv:{encode:(e,t)=>{let{Err:r}=Zt;if(Ht(e,"tag"),e<0||e>255)throw new r("tlv.encode: wrong tag");if(typeof t!="string")throw new TypeError('"data" expected string, got type='+typeof t);if(t.length&1)throw new r("tlv.encode: unpadded data");let n=t.length/2,o=Xr(n);if(o.length/2&128)throw new r("tlv.encode: long form length too big");let i=n>127?Xr(o.length/2|128):"";return Xr(e)+i+o+t},decode(e,t){let{Err:r}=Zt;t=Y(t,void 0,"DER data");let n=0;if(e<0||e>255)throw new r("tlv.encode: wrong tag");if(t.length<2||t[n++]!==e)throw new r("tlv.decode: wrong tlv");let o=t[n++],i=!!(o&128),s=0;if(!i)s=o;else{let c=o&127;if(!c)throw new r("tlv.decode(long): indefinite length not supported");if(c>4)throw new r("tlv.decode(long): byte length is too big");let u=t.subarray(n,n+c);if(u.length!==c)throw new r("tlv.decode: length bytes not complete");if(u[0]===0)throw new r("tlv.decode(long): zero leftmost byte");for(let f of u)s=s<<8|f;if(n+=c,s<128)throw new r("tlv.decode(long): not minimal encoding")}let a=t.subarray(n,n+s);if(a.length!==s)throw new r("tlv.decode: wrong value length");return{v:a,l:t.subarray(n+s)}}},_int:{encode(e){let{Err:t}=Zt;if(Mn(e),e<se)throw new t("integer: negative integers are not allowed");let r=Xr(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}=Zt;if(e.length<1)throw new t("invalid signature integer: empty");if(e[0]&128)throw new t("invalid signature integer: negative");if(e.length>1&&e[0]===0&&!(e[1]&128))throw new t("invalid signature integer: unnecessary leading zero");return qe(e)}},toSig(e){let{Err:t,_int:r,_tlv:n}=Zt,o=Y(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:a,l:c}=n.decode(2,i),{v:u,l:f}=n.decode(2,c);if(f.length)throw new t("invalid signature: left bytes after parsing");return{r:r.decode(a),s:r.decode(u)}},hexFromSig(e){let{_tlv:t,_int:r}=Zt,n=t.encode(2,r.encode(e.r)),o=t.encode(2,r.encode(e.s)),i=n+o;return t.encode(48,i)}};Object.freeze(Zt._tlv);Object.freeze(Zt._int);Object.freeze(Zt);var se=BigInt(0),Oe=BigInt(1),uu=BigInt(2),no=BigInt(3),zh=BigInt(4);function fu(e,t={}){let r=Hn("weierstrass",e,t),n=r.Fp,o=r.Fn,i=r.CURVE,{h:s,n:a}=i;jt(t,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object"});let{endo:c,allowInfinityPoint:u}=t;if(c&&(!n.is0(i.a)||typeof c.beta!="bigint"||!Array.isArray(c.basises)))throw new Error('invalid endo: expected "beta": bigint and "basises": array');let f=du(n,o);function l(){if(!n.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}function h(P,d,g){if(u&&d.is0())return Uint8Array.of(0);let{x:T,y:b}=d.toAffine(),x=n.toBytes(T);if(zt(g,"isCompressed"),g){l();let I=!n.isOdd(b);return ct(lu(I),x)}else return ct(Uint8Array.of(4),x,n.toBytes(b))}function m(P){Y(P,void 0,"Point");let{publicKey:d,publicKeyUncompressed:g}=f,T=P.length,b=P[0],x=P.subarray(1);if(u&&T===1&&b===0)return{x:n.ZERO,y:n.ZERO};if(T===d&&(b===2||b===3)){let I=n.fromBytes(x);if(!n.isValid(I))throw new Error("bad point: is not on curve, wrong x");let R=y(I),D;try{D=n.sqrt(R)}catch(j){let G=j instanceof Error?": "+j.message:"";throw new Error("bad point: is not on curve, sqrt error"+G)}l();let k=n.isOdd(D);return(b&1)===1!==k&&(D=n.neg(D)),{x:I,y:D}}else if(T===g&&b===4){let I=n.BYTES,R=n.fromBytes(x.subarray(0,I)),D=n.fromBytes(x.subarray(I,I*2));if(!S(R,D))throw new Error("bad point: is not on curve");return{x:R,y:D}}else throw new Error(`bad point: got length ${T}, expected compressed=${d} or uncompressed=${g}`)}let E=t.toBytes===void 0?h:t.toBytes,v=t.fromBytes===void 0?m:t.fromBytes;function y(P){let d=n.sqr(P),g=n.mul(d,P);return n.add(n.add(g,n.mul(P,i.a)),i.b)}function S(P,d){let g=n.sqr(d),T=y(P);return n.eql(g,T)}if(!S(i.Gx,i.Gy))throw new Error("bad curve params: generator point");let A=n.mul(n.pow(i.a,no),zh),_=n.mul(n.sqr(i.b),BigInt(27));if(n.is0(n.add(A,_)))throw new Error("bad curve params: a or b");function U(P,d,g=!1){if(!n.isValid(d)||g&&n.is0(d))throw new Error(`bad point coordinate ${P}`);return d}function F(P){if(!(P instanceof w))throw new Error("Weierstrass Point expected")}function M(P){if(!c||!c.basises)throw new Error("no endo");return qh(P,c.basises,o.ORDER)}function L(P,d,g,T,b){return g=new w(n.mul(g.X,P),g.Y,g.Z),d=en(T,d),g=en(b,g),d.add(g)}class w{static BASE=new w(i.Gx,i.Gy,n.ONE);static ZERO=new w(n.ZERO,n.ONE,n.ZERO);static Fp=n;static Fn=o;X;Y;Z;constructor(d,g,T){this.X=U("x",d),this.Y=U("y",g,!0),this.Z=U("z",T),Object.freeze(this)}static CURVE(){return i}static fromAffine(d){let{x:g,y:T}=d||{};if(!d||!n.isValid(g)||!n.isValid(T))throw new Error("invalid affine point");if(d instanceof w)throw new Error("projective point not allowed");return n.is0(g)&&n.is0(T)?w.ZERO:new w(g,T,n.ONE)}static fromBytes(d){let g=w.fromAffine(v(Y(d,void 0,"point")));return g.assertValidity(),g}static fromHex(d){return w.fromBytes(mr(d))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(d=8,g=!0){return N.createCache(this,d),g||this.multiply(no),this}assertValidity(){let d=this;if(d.is0()){if(t.allowInfinityPoint&&n.is0(d.X)&&n.eql(d.Y,n.ONE)&&n.is0(d.Z))return;throw new Error("bad point: ZERO")}let{x:g,y:T}=d.toAffine();if(!n.isValid(g)||!n.isValid(T))throw new Error("bad point: x or y not field elements");if(!S(g,T))throw new Error("bad point: equation left != right");if(!d.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){let{y:d}=this.toAffine();if(!n.isOdd)throw new Error("Field doesn't support isOdd");return!n.isOdd(d)}equals(d){F(d);let{X:g,Y:T,Z:b}=this,{X:x,Y:I,Z:R}=d,D=n.eql(n.mul(g,R),n.mul(x,b)),k=n.eql(n.mul(T,R),n.mul(I,b));return D&&k}negate(){return new w(this.X,n.neg(this.Y),this.Z)}double(){let{a:d,b:g}=i,T=n.mul(g,no),{X:b,Y:x,Z:I}=this,R=n.ZERO,D=n.ZERO,k=n.ZERO,$=n.mul(b,b),j=n.mul(x,x),G=n.mul(I,I),q=n.mul(b,x);return q=n.add(q,q),k=n.mul(b,I),k=n.add(k,k),R=n.mul(d,k),D=n.mul(T,G),D=n.add(R,D),R=n.sub(j,D),D=n.add(j,D),D=n.mul(R,D),R=n.mul(q,R),k=n.mul(T,k),G=n.mul(d,G),q=n.sub($,G),q=n.mul(d,q),q=n.add(q,k),k=n.add($,$),$=n.add(k,$),$=n.add($,G),$=n.mul($,q),D=n.add(D,$),G=n.mul(x,I),G=n.add(G,G),$=n.mul(G,q),R=n.sub(R,$),k=n.mul(G,j),k=n.add(k,k),k=n.add(k,k),new w(R,D,k)}add(d){F(d);let{X:g,Y:T,Z:b}=this,{X:x,Y:I,Z:R}=d,D=n.ZERO,k=n.ZERO,$=n.ZERO,j=i.a,G=n.mul(i.b,no),q=n.mul(g,x),at=n.mul(T,I),ut=n.mul(b,R),ft=n.add(g,T),ot=n.add(x,I);ft=n.mul(ft,ot),ot=n.add(q,at),ft=n.sub(ft,ot),ot=n.add(g,b);let Tt=n.add(x,R);return ot=n.mul(ot,Tt),Tt=n.add(q,ut),ot=n.sub(ot,Tt),Tt=n.add(T,b),D=n.add(I,R),Tt=n.mul(Tt,D),D=n.add(at,ut),Tt=n.sub(Tt,D),$=n.mul(j,ot),D=n.mul(G,ut),$=n.add(D,$),D=n.sub(at,$),$=n.add(at,$),k=n.mul(D,$),at=n.add(q,q),at=n.add(at,q),ut=n.mul(j,ut),ot=n.mul(G,ot),at=n.add(at,ut),ut=n.sub(q,ut),ut=n.mul(j,ut),ot=n.add(ot,ut),q=n.mul(at,ot),k=n.add(k,q),q=n.mul(Tt,ot),D=n.mul(ft,D),D=n.sub(D,q),q=n.mul(ft,at),$=n.mul(Tt,$),$=n.add($,q),new w(D,k,$)}subtract(d){return F(d),this.add(d.negate())}is0(){return this.equals(w.ZERO)}multiply(d){let{endo:g}=t;if(!o.isValidNot0(d))throw new RangeError("invalid scalar: out of range");let T,b,x=I=>N.cached(this,I,R=>je(w,R));if(g){let{k1neg:I,k1:R,k2neg:D,k2:k}=M(d),{p:$,f:j}=x(R),{p:G,f:q}=x(k);b=j.add(q),T=L(g.beta,$,G,I,D)}else{let{p:I,f:R}=x(d);T=I,b=R}return je(w,[T,b])[0]}multiplyUnsafe(d){let{endo:g}=t,T=this,b=d;if(!o.isValid(b))throw new RangeError("invalid scalar: out of range");if(b===se||T.is0())return w.ZERO;if(b===Oe)return T;if(N.hasCache(this))return this.multiply(b);if(g){let{k1neg:x,k1:I,k2neg:R,k2:D}=M(b),{p1:k,p2:$}=Oc(w,T,I,D);return L(g.beta,k,$,x,R)}else return N.unsafe(T,b)}toAffine(d){let g=this,T=d,{X:b,Y:x,Z:I}=g;if(n.eql(I,n.ONE))return{x:b,y:x};let R=g.is0();T==null&&(T=R?n.ONE:n.inv(I));let D=n.mul(b,T),k=n.mul(x,T),$=n.mul(I,T);if(R)return{x:n.ZERO,y:n.ZERO};if(!n.eql($,n.ONE))throw new Error("invZ was invalid");return{x:D,y:k}}isTorsionFree(){let{isTorsionFree:d}=t;return s===Oe?!0:d?d(w,this):N.unsafe(this,a).is0()}clearCofactor(){let{clearCofactor:d}=t;return s===Oe?this:d?d(w,this):this.multiplyUnsafe(s)}isSmallOrder(){return s===Oe?this.is0():this.clearCofactor().is0()}toBytes(d=!0){return zt(d,"isCompressed"),this.assertValidity(),E(w,this,d)}toHex(d=!0){return pr(this.toBytes(d))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let C=o.BITS,N=new wr(w,t.endo?Math.ceil(C/2):C);return C>=8&&w.BASE.precompute(8),Object.freeze(w.prototype),Object.freeze(w),w}function lu(e){return Uint8Array.of(e?2:3)}function du(e,t){return{secretKey:t.BYTES,publicKey:1+e.BYTES,publicKeyUncompressed:1+2*e.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function Hh(e,t={}){let{Fn:r}=e,n=t.randomBytes===void 0?Wr:t.randomBytes,o=Object.assign(du(e.Fp,r),{seed:Math.max(Vi(r.ORDER),16)});function i(m){try{let E=r.fromBytes(m);return r.isValidNot0(E)}catch{return!1}}function s(m,E){let{publicKey:v,publicKeyUncompressed:y}=o;try{let S=m.length;return E===!0&&S!==v||E===!1&&S!==y?!1:!!e.fromBytes(m)}catch{return!1}}function a(m){return m=m===void 0?n(o.seed):m,qi(Y(m,o.seed,"seed"),r.ORDER)}function c(m,E=!0){return e.BASE.multiply(r.fromBytes(m)).toBytes(E)}function u(m){let{secretKey:E,publicKey:v,publicKeyUncompressed:y}=o,S=r._lengths;if(!Ve(m))return;let A=Y(m,void 0,"key").length,_=A===v||A===y,U=A===E||!!S?.includes(A);if(!(_&&U))return _}function f(m,E,v=!0){if(u(m)===!0)throw new Error("first arg must be private key");if(u(E)===!1)throw new Error("second arg must be public key");let y=r.fromBytes(m);return e.fromBytes(E).multiply(y).toBytes(v)}let l={isValidSecretKey:i,isValidPublicKey:s,randomSecretKey:a},h=jn(a,c);return Object.freeze(l),Object.freeze(o),Object.freeze({getPublicKey:c,getSharedSecret:f,keygen:h,Point:e,utils:l,lengths:o})}function hu(e,t,r={}){let n=t;On(n),jt(r,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"}),r=Object.assign({},r);let o=r.randomBytes===void 0?Wr:r.randomBytes,i=r.hmac===void 0?(b,x)=>au(n,b,x):r.hmac,{Fp:s,Fn:a}=e,{ORDER:c,BITS:u}=a,{keygen:f,getPublicKey:l,getSharedSecret:h,utils:m,lengths:E}=Hh(e,r),v={prehash:!0,lowS:typeof r.lowS=="boolean"?r.lowS:!0,format:"compact",extraEntropy:!1},y=c*uu+Oe<s.ORDER;function S(b){let x=c>>Oe;return b>x}function A(b,x){if(!a.isValidNot0(x))throw new Error(`invalid signature ${b}: out of range 1..Point.Fn.ORDER`);return x}function _(){if(y)throw new Error('"recovered" sig type is not supported for cofactor >2 curves')}function U(b,x){Ds(x);let I=E.signature,R=x==="compact"?I:x==="recovered"?I+1:void 0;return Y(b,R)}class F{r;s;recovery;constructor(x,I,R){if(this.r=A("r",x),this.s=A("s",I),R!=null){if(_(),![0,1,2,3].includes(R))throw new Error("invalid recovery id");this.recovery=R}Object.freeze(this)}static fromBytes(x,I=v.format){U(x,I);let R;if(I==="der"){let{r:j,s:G}=Zt.toSig(Y(x));return new F(j,G)}I==="recovered"&&(R=x[0],I="compact",x=x.subarray(1));let D=E.signature/2,k=x.subarray(0,D),$=x.subarray(D,D*2);return new F(a.fromBytes(k),a.fromBytes($),R)}static fromHex(x,I){return this.fromBytes(mr(x),I)}assertRecovery(){let{recovery:x}=this;if(x==null)throw new Error("invalid recovery id: must be present");return x}addRecoveryBit(x){return new F(this.r,this.s,x)}recoverPublicKey(x){let{r:I,s:R}=this,D=this.assertRecovery(),k=D===2||D===3?I+c:I;if(!s.isValid(k))throw new Error("invalid recovery id: sig.r+curve.n != R.x");let $=s.toBytes(k),j=e.fromBytes(ct(lu((D&1)===0),$)),G=a.inv(k),q=L(Y(x,void 0,"msgHash")),at=a.create(-q*G),ut=a.create(R*G),ft=e.BASE.multiplyUnsafe(at).add(j.multiplyUnsafe(ut));if(ft.is0())throw new Error("invalid recovery: point at infinify");return ft.assertValidity(),ft}hasHighS(){return S(this.s)}toBytes(x=v.format){if(Ds(x),x==="der")return mr(Zt.hexFromSig(this));let{r:I,s:R}=this,D=a.toBytes(I),k=a.toBytes(R);return x==="recovered"?(_(),ct(Uint8Array.of(this.assertRecovery()),D,k)):ct(D,k)}toHex(x){return pr(this.toBytes(x))}}Object.freeze(F.prototype),Object.freeze(F);let M=r.bits2int===void 0?function(x){if(x.length>8192)throw new Error("input is too large");let I=qe(x),R=x.length*8-u;return R>0?I>>BigInt(R):I}:r.bits2int,L=r.bits2int_modN===void 0?function(x){return a.create(M(x))}:r.bits2int_modN,w=Qr(u);function C(b){return yr("num < 2^"+u,b,se,w),a.toBytes(b)}function N(b,x){return Y(b,void 0,"message"),x?Y(n(b),void 0,"prehashed message"):b}function P(b,x,I){let{lowS:R,prehash:D,extraEntropy:k}=Rs(I,v);b=N(b,D);let $=L(b),j=a.fromBytes(x);if(!a.isValidNot0(j))throw new Error("invalid private key");let G=[C(j),C($)];if(k!=null&&k!==!1){let ft=k===!0?o(E.secretKey):k;G.push(Y(ft,void 0,"extraEntropy"))}let q=ct(...G),at=$;function ut(ft){let ot=M(ft);if(!a.isValidNot0(ot))return;let Tt=a.inv(ot),er=e.BASE.multiply(ot).toAffine(),kr=a.create(er.x);if(kr===se)return;let In=a.create(Tt*a.create(at+kr*j));if(In===se)return;let xa=(er.x===kr?0:2)|Number(er.y&Oe),wa=In;return R&&S(In)&&(wa=a.neg(In),xa^=1),new F(kr,wa,y?void 0:xa)}return{seed:q,k2sig:ut}}function d(b,x,I={}){let{seed:R,k2sig:D}=P(b,x,I);return yc(n.outputLen,a.BYTES,i)(R,D).toBytes(I.format)}function g(b,x,I,R={}){let{lowS:D,prehash:k,format:$}=Rs(R,v);if(I=Y(I,void 0,"publicKey"),x=N(x,k),!Ve(b)){let j=b instanceof F?", use sig.toBytes()":"";throw new Error("verify expects Uint8Array signature"+j)}U(b,$);try{let j=F.fromBytes(b,$),G=e.fromBytes(I);if(D&&j.hasHighS())return!1;let{r:q,s:at}=j,ut=L(x),ft=a.inv(at),ot=a.create(ut*ft),Tt=a.create(q*ft),er=e.BASE.multiplyUnsafe(ot).add(G.multiplyUnsafe(Tt));return er.is0()?!1:a.create(er.x)===q}catch{return!1}}function T(b,x,I={}){let{prehash:R}=Rs(I,v);return x=N(x,R),F.fromBytes(b,"recovered").recoverPublicKey(x).toBytes()}return Object.freeze({keygen:f,getPublicKey:l,getSharedSecret:h,utils:m,lengths:E,Point:e,sign:d,verify:g,recoverPublicKey:T,Signature:F,hash:n})}var Fs={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},jh={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]};var pu=BigInt(2);function Yh(e){let t=Fs.p,r=BigInt(3),n=BigInt(6),o=BigInt(11),i=BigInt(22),s=BigInt(23),a=BigInt(44),c=BigInt(88),u=e*e*e%t,f=u*u*e%t,l=J(f,r,t)*f%t,h=J(l,r,t)*f%t,m=J(h,pu,t)*u%t,E=J(m,o,t)*m%t,v=J(E,i,t)*E%t,y=J(v,a,t)*v%t,S=J(y,c,t)*y%t,A=J(S,a,t)*v%t,_=J(A,r,t)*f%t,U=J(_,s,t)*E%t,F=J(U,n,t)*u%t,M=J(F,pu,t);if(!Os.eql(Os.sqr(M),e))throw new Error("Cannot find square root");return M}var Os=br(Fs.p,{sqrt:Yh}),Zh=fu(Fs,{Fp:Os,endo:jh}),Cr=hu(Zh,hr);function mu(e,t,r,n){let o=Vr.digest(r instanceof Uint8Array?r:r.subarray());if(Wn(o))return o.then(({digest:i})=>(n?.signal?.throwIfAborted(),Cr.verify(t,i,e,{prehash:!1,format:"der"}))).catch(i=>{throw i.name==="AbortError"?i:new nn(String(i))});try{return n?.signal?.throwIfAborted(),Cr.verify(t,o.digest,e,{prehash:!1,format:"der"})}catch(i){throw new nn(String(i))}}var oo=class{type="secp256k1";raw;_key;constructor(t){this._key=gu(t),this.raw=yu(this._key)}toMultihash(){return St.digest(lr(this))}toCID(){return H.createV1(114,this.toMultihash())}toString(){return X.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:W(this.raw,t.raw)}verify(t,r,n){return mu(this._key,r,t,n)}};function Ls(e){return new oo(e)}function yu(e){return Cr.Point.fromBytes(e).toBytes()}function gu(e){try{return Cr.Point.fromBytes(e),e}catch(t){throw new rr(String(t))}}function bu(e,t){let{Type:r,Data:n}=ie.decode(e),o=n??new Uint8Array;switch(r){case tt.RSA:return Cs(o,t);case tt.Ed25519:return rs(o);case tt.secp256k1:return Ls(o);case tt.ECDSA:return Ai(o);default:throw new or}}function io(e){let{Type:t,Data:r}=ie.decode(e.digest),n=r??new Uint8Array;switch(t){case tt.Ed25519:return rs(n);case tt.secp256k1:return Ls(n);case tt.ECDSA:return Ai(n);default:throw new or}}function lr(e){return ie.encode({Type:tt[e.type],Data:e.raw})}var xu=Symbol.for("nodejs.util.inspect.custom"),Gh=114,dn=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()})`}[Bn]=!0;toString(){return this.string==null&&(this.string=X.encode(this.multihash.bytes).slice(1)),this.string}toMultihash(){return this.multihash}toCID(){return H.createV1(Gh,this.multihash)}toJSON(){return this.toString()}equals(t){if(t==null)return!1;if(t instanceof Uint8Array)return W(this.multihash.bytes,t);if(typeof t=="string")return this.toString()===t;if(t?.toMultihash()?.bytes!=null)return W(this.multihash.bytes,t.toMultihash().bytes);throw new Error("not valid Id")}[xu](){return`PeerId(${this.toString()})`}},so=class extends dn{type="RSA";publicKey;constructor(t){super({...t,type:"RSA"}),this.publicKey=t.publicKey}},ao=class extends dn{type="Ed25519";publicKey;constructor(t){super({...t,type:"Ed25519"}),this.publicKey=t.publicKey}},co=class extends dn{type="secp256k1";publicKey;constructor(t){super({...t,type:"secp256k1"}),this.publicKey=t.publicKey}},Wh=2336,hn=class{type="url";multihash;publicKey;url;constructor(t){this.url=t.toString(),this.multihash=St.digest(V(this.url))}[xu](){return`PeerId(${this.url})`}[Bn]=!0;toString(){return this.toCID().toString()}toMultihash(){return this.multihash}toCID(){return H.createV1(Wh,this.toMultihash())}toJSON(){return this.toString()}equals(t){return t==null?!1:(t instanceof Uint8Array&&(t=z(t)),t.toString()===this.toString())}};var Xh=114,wu=2336;function Eu(e,t){let r;if(e.charAt(0)==="1"||e.charAt(0)==="Q")r=Se(X.decode(`z${e}`));else{if(e.startsWith("k51qzi5uqu5")||e.startsWith("kzwfwjn5ji4")||e.startsWith("k2k4r8")||e.startsWith("bafz"))return Ns(H.parse(e));if(t==null)throw new et('Please pass a multibase decoder for strings that do not start with "1" or "Q"');r=Se(t.decode(e))}return uo(r)}function uo(e){if(Qh(e))return new so({multihash:e});if(Jh(e))try{let t=io(e);if(t.type==="Ed25519")return new ao({multihash:e,publicKey:t});if(t.type==="secp256k1")return new co({multihash:e,publicKey:t})}catch{let r=z(e.digest);return new hn(new URL(r))}throw new nr("Supplied PeerID Multihash is invalid")}function Ns(e){if(e?.multihash==null||e.version==null||e.version===1&&e.code!==Xh&&e.code!==wu)throw new _n("Supplied PeerID CID is invalid");if(e.code===wu){let t=z(e.multihash.digest);return new hn(new URL(t))}return uo(e.multihash)}function Jh(e){return e.code===St.code}function Qh(e){return e.code===Vr.code}var gt=class extends Error{static name="InvalidMultiaddrError";name="InvalidMultiaddrError"},ge=class extends Error{static name="ValidationError";name="ValidationError"},fo=class extends Error{static name="InvalidParametersError";name="InvalidParametersError"},lo=class extends Error{static name="UnknownProtocolError";name="UnknownProtocolError"};var ho=class{index=0;input="";new(t){return this.index=0,this.input=t,this}readAtomically(t){let r=this.index,n=t();return n===void 0&&(this.index=r),n}parseWith(t){let r=t();if(this.index===this.input.length)return r}peekChar(){if(!(this.index>=this.input.length))return this.input[this.index]}readChar(){if(!(this.index>=this.input.length))return this.input[this.index++]}readGivenChar(t){return this.readAtomically(()=>{let r=this.readChar();if(r===t)return r})}readSeparator(t,r,n){return this.readAtomically(()=>{if(!(r>0&&this.readGivenChar(t)===void 0))return n()})}readNumber(t,r,n,o){return this.readAtomically(()=>{let i=0,s=0,a=this.peekChar();if(a===void 0)return;let c=a==="0",u=2**(8*o)-1;for(;;){let f=this.readAtomically(()=>{let l=this.readChar();if(l===void 0)return;let h=Number.parseInt(l,t);if(!Number.isNaN(h))return h});if(f===void 0)break;if(i*=t,i+=f,i>u||(s+=1,r!==void 0&&s>r))return}if(s!==0)return!n&&c&&s>1?void 0:i})}readIPv4Addr(){return this.readAtomically(()=>{let t=new Uint8Array(4);for(let r=0;r<t.length;r++){let n=this.readSeparator(".",r,()=>this.readNumber(10,3,!1,1));if(n===void 0)return;t[r]=n}return t})}readIPv6Addr(){let t=r=>{for(let n=0;n<r.length/2;n++){let o=n*2;if(n<r.length-3){let s=this.readSeparator(":",n,()=>this.readIPv4Addr());if(s!==void 0)return r[o]=s[0],r[o+1]=s[1],r[o+2]=s[2],r[o+3]=s[3],[o+4,!0]}let i=this.readSeparator(":",n,()=>this.readNumber(16,4,!0,2));if(i===void 0)return[o,!1];r[o]=i>>8,r[o+1]=i&255}return[r.length,!1]};return this.readAtomically(()=>{let r=new Uint8Array(16),[n,o]=t(r);if(n===16)return r;if(o||this.readGivenChar(":")===void 0||this.readGivenChar(":")===void 0)return;let i=new Uint8Array(14),s=16-(n+2),[a]=t(i.subarray(0,s));return r.set(i.subarray(0,a),16-a),r})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var tp=45,ep=15,po=new ho;function Su(e){if(!(e.length>ep))return po.new(e).parseWith(()=>po.readIPv4Addr())}function vu(e){if(e.includes("%")&&(e=e.split("%")[0]),!(e.length>tp))return po.new(e).parseWith(()=>po.readIPv6Addr())}function mo(e){return!!Su(e)}function Tu(e){return!!vu(e)}function ks(e){return t=>z(t,e)}function Ks(e){return t=>V(t,e)}function _r(e){return new DataView(e.buffer).getUint16(e.byteOffset).toString()}function Ge(e){let t=new ArrayBuffer(2);return new DataView(t).setUint16(0,typeof e=="string"?parseInt(e):e),new Uint8Array(t)}function Au(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=V(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=Ge(n);return Nt([r,o],r.length+o.length)}function Iu(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=te.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=Ge(n);return Nt([r,o],r.length+o.length)}function $s(e){let t=e.subarray(0,e.length-2),r=e.subarray(e.length-2),n=z(t,"base32"),o=_r(r);return`${n}:${o}`}var Ms=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 gt("Invalid byte value in IP address");t[n]=o}),t},Cu=function(e){let t=0;e=e.toString().trim();let r=e.split(":",8),n;for(n=0;n<r.length;n++){let i=mo(r[n]),s;i&&(s=Ms(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 gt("Invalid byte value in IP address");o[t++]=i>>8&255,o[t++]=i&255}return o},_u=function(e){if(e.byteLength!==4)throw new gt("IPv4 address was incorrect length");let t=[];for(let r=0;r<e.byteLength;r++)t.push(e[r]);return t.join(".")},Bu=function(e){if(e.byteLength!==16)throw new gt("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 gt(`Invalid IPv6 address "${r}"`)}};function Ru(e){try{let t=new URL(`http://[${e}]`);return t.hostname.substring(1,t.hostname.length-1)}catch{throw new gt(`Invalid IPv6 address "${e}"`)}}var Us=Object.values(qr).map(e=>e.decoder),rp=(function(){let e=Us[0].or(Us[1]);return Us.slice(2).forEach(t=>e=e.or(t)),e})();function Du(e){return rp.decode(e)}function Pu(e){return t=>e.encoder.encode(t)}function np(e){if(parseInt(e).toString()!==e)throw new ge("Value must be an integer")}function op(e){if(e<0)throw new ge("Value must be a positive integer, or zero")}function ip(e){return t=>{if(t>e)throw new ge(`Value must be smaller than or equal to ${e}`)}}function sp(...e){return t=>{for(let r of e)r(t)}}var pn=sp(np,op,ip(65535));var dt=-1,Vs=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 lo(`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)}))}},be=new Vs,Yp=[{code:4,name:"ip4",size:32,valueToBytes:Ms,bytesToValue:_u,validate:e=>{if(!mo(e))throw new ge(`Invalid IPv4 address "${e}"`)}},{code:6,name:"tcp",size:16,valueToBytes:Ge,bytesToValue:_r,validate:pn},{code:273,name:"udp",size:16,valueToBytes:Ge,bytesToValue:_r,validate:pn},{code:33,name:"dccp",size:16,valueToBytes:Ge,bytesToValue:_r,validate:pn},{code:41,name:"ip6",size:128,valueToBytes:Cu,bytesToValue:Bu,stringToValue:Ru,validate:e=>{if(!Tu(e))throw new ge(`Invalid IPv6 address "${e}"`)}},{code:42,name:"ip6zone",size:dt},{code:43,name:"ipcidr",size:8,bytesToValue:ks("base10"),valueToBytes:Ks("base10")},{code:53,name:"dns",size:dt},{code:54,name:"dns4",size:dt},{code:55,name:"dns6",size:dt},{code:56,name:"dnsaddr",size:dt},{code:132,name:"sctp",size:16,valueToBytes:Ge,bytesToValue:_r,validate:pn},{code:301,name:"udt"},{code:302,name:"utp"},{code:400,name:"unix",size:dt,stringToValue:e=>decodeURIComponent(e),valueToString:e=>encodeURIComponent(e)},{code:421,name:"p2p",aliases:["ipfs"],size:dt,bytesToValue:ks("base58btc"),valueToBytes:e=>e.startsWith("Q")||e.startsWith("1")?Ks("base58btc")(e):H.parse(e).multihash.bytes},{code:444,name:"onion",size:96,bytesToValue:$s,valueToBytes:Au},{code:445,name:"onion3",size:296,bytesToValue:$s,valueToBytes:Iu},{code:446,name:"garlic64",size:dt},{code:447,name:"garlic32",size:dt},{code:448,name:"tls"},{code:449,name:"sni",size:dt},{code:454,name:"noise"},{code:460,name:"quic"},{code:461,name:"quic-v1"},{code:465,name:"webtransport"},{code:466,name:"certhash",size:dt,bytesToValue:Pu(di),valueToBytes:Du},{code:480,name:"http"},{code:481,name:"http-path",size:dt,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:dt}];Yp.forEach(e=>{be.addProtocol(e)});function Ou(e){let t=[],r=0;for(;r<e.length;){let n=cs(e,r),o=be.getProtocol(n),i=oe(n),s=Zp(o,e,r+i),a=0;s>0&&o.size===dt&&(a=oe(s));let c=i+a+s,u={code:n,name:o.name,bytes:e.subarray(r,r+c)};if(s>0){let f=r+i+a,l=e.subarray(f,f+s);u.value=o.bytesToValue?.(l)??z(l)}t.push(u),r+=c}return t}function Fu(e){let t=0,r=[];for(let n of e){if(n.bytes==null){let o=be.getProtocol(n.code),i=oe(n.code),s,a=0,c=0;n.value!=null&&(s=o.valueToBytes?.(n.value)??V(n.value),a=s.byteLength,o.size===dt&&(c=oe(a)));let u=new Uint8Array(i+c+a),f=0;on(n.code,u,f),f+=i,s!=null&&(o.size===dt&&(on(a,u,f),f+=c),u.set(s,f)),n.bytes=u}r.push(n.bytes),t+=n.bytes.byteLength}return Nt(r,t)}function Lu(e){if(e.charAt(0)!=="/")throw new gt('String multiaddr must start with "/"');let t=[],r="protocol",n="",o="";for(let i=1;i<e.length;i++){let s=e.charAt(i);s!=="/"&&(r==="protocol"?o+=e.charAt(i):n+=e.charAt(i));let a=i===e.length-1;if(s==="/"||a){let c=be.getProtocol(o);if(r==="protocol"){if(c.size==null||c.size===0){t.push({code:c.code,name:c.name}),n="",o="",r="protocol";continue}else if(a)throw new gt(`Component ${o} was missing value`);r="value"}else if(r==="value"){let u={code:c.code,name:c.name};if(c.size!=null&&c.size!==0){if(n==="")throw new gt(`Component ${o} was missing value`);u.value=c.stringToValue?.(n)??n}t.push(u),n="",o="",r="protocol"}}}if(o!==""&&n!=="")throw new gt("Incomplete multiaddr");return t}function Nu(e){return`/${e.flatMap(t=>{if(t.value==null)return t.name;let r=be.getProtocol(t.code);if(r==null)throw new gt(`Unknown protocol code ${t.code}`);return[t.name,r.valueToString?.(t.value)??t.value]}).join("/")}`}function Zp(e,t,r){return e.size==null||e.size===0?0:e.size>0?e.size/8:cs(t,r)}var Gp=Symbol.for("nodejs.util.inspect.custom"),qs=Symbol.for("@multiformats/multiaddr");function Wp(e){if(e==null&&(e="/"),Uu(e))return e.getComponents();if(e instanceof Uint8Array)return Ou(e);if(typeof e=="string")return e=e.replace(/\/(\/)+/,"/").replace(/(\/)+$/,""),e===""&&(e="/"),Lu(e);if(Array.isArray(e))return e;throw new gt("Must be a string, Uint8Array, Component[], or another Multiaddr")}var yo=class e{[qs]=!0;#t;#n;#r;constructor(t="/",r={}){this.#t=Wp(t),r.validate!==!1&&Xp(this)}get bytes(){return this.#r==null&&(this.#r=Fu(this.#t)),this.#r}toString(){return this.#n==null&&(this.#n=Nu(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 fo(`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 W(this.bytes,t.bytes)}[Gp](){return`Multiaddr(${this.toString()})`}};function Xp(e){e.getComponents().forEach(t=>{let r=be.getProtocol(t.code);t.value!=null&&r.validate?.(t.value)})}function Uu(e){return!!e?.[qs]}function go(e){return new yo(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*mn(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 Jp(e,t){if(typeof e=="string")return Qp(e);if(typeof e=="number")return r0(e,t);throw Error(`Value provided to ms() must be a string or number. value=${JSON.stringify(e)}`)}var bo=Jp;function Qp(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 t0(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 e0(e){let t=Math.abs(e);return t>=315576e5?We(e,t,315576e5,"year"):t>=26298e5?We(e,t,26298e5,"month"):t>=6048e5?We(e,t,6048e5,"week"):t>=864e5?We(e,t,864e5,"day"):t>=36e5?We(e,t,36e5,"hour"):t>=6e4?We(e,t,6e4,"minute"):t>=1e3?We(e,t,1e3,"second"):`${e} ms`}function r0(e,t){if(typeof e!="number"||!Number.isFinite(e))throw Error("Value provided to ms.format() must be of type number.");return t?.long?e0(e):t0(e)}function We(e,t,r,n){let o=t>=r*1.5;return`${Math.round(e/r)} ${n}${o?"s":""}`}function zs(e){r.debug=r,r.default=r,r.coerce=c,r.disable=i,r.enable=o,r.enabled=s,r.humanize=bo,r.destroy=u,Object.keys(e).forEach(f=>{r[f]=e[f]}),r.names=[],r.skips=[],r.formatters={};function t(f){let l=0;for(let h=0;h<f.length;h++)l=(l<<5)-l+f.charCodeAt(h),l|=0;return r.colors[Math.abs(l)%r.colors.length]}r.selectColor=t;function r(f,l){let h,m=null,E,v;function y(...S){if(!y.enabled)return;let A=y,_=Number(new Date),U=_-(h||_);A.diff=U,A.prev=h,A.curr=_,h=_,S[0]=r.coerce(S[0]),typeof S[0]!="string"&&S.unshift("%O");let F=0;S[0]=S[0].replace(/%([a-zA-Z%])/g,(L,w)=>{if(L==="%%")return"%";F++;let C=r.formatters[w];if(typeof C=="function"){let N=S[F];L=C.call(A,N),S.splice(F,1),F--}return L}),r.formatArgs.call(A,S),l?.onLog!=null&&l.onLog(...S),(A.log||r.log).apply(A,S)}return y.namespace=f,y.useColors=r.useColors(),y.color=r.selectColor(f),y.extend=n,y.destroy=r.destroy,Object.defineProperty(y,"enabled",{enumerable:!0,configurable:!1,get:()=>m!==null?m:(E!==r.namespaces&&(E=r.namespaces,v=r.enabled(f)),v),set:S=>{m=S}}),typeof r.init=="function"&&r.init(y),y}function n(f,l){let h=r(this.namespace+(typeof l>"u"?":":l)+f);return h.log=this.log,h}function o(f){r.save(f),r.namespaces=f,r.names=[],r.skips=[];let l,h=(typeof f=="string"?f:"").split(/[\s,]+/),m=h.length;for(l=0;l<m;l++)h[l]&&(f=h[l].replace(/\*/g,".*?"),f[0]==="-"?r.skips.push(new RegExp("^"+f.substr(1)+"$")):r.names.push(new RegExp("^"+f+"$")))}function i(){let f=[...r.names.map(a),...r.skips.map(a).map(l=>"-"+l)].join(",");return r.enable(""),f}function s(f){if(f[f.length-1]==="*")return!0;let l,h;for(l=0,h=r.skips.length;l<h;l++)if(r.skips[l].test(f))return!1;for(l=0,h=r.names.length;l<h;l++)if(r.names[l].test(f))return!0;return!1}function a(f){return f.toString().substring(2,f.toString().length-2).replace(/\.\*\?$/,"*")}function c(f){return f instanceof Error?f.stack??f.message:f}function u(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return r.setupFormatters(r.formatters),r.enable(r.load()),r}var xo=u0(),n0=["#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 o0(){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 i0(e){if(e[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+e[0]+(this.useColors?"%c ":" ")+"+"+bo(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 s0=console.debug??console.log??(()=>{});function a0(e){try{e?xo?.setItem("debug",e):xo?.removeItem("debug")}catch{}}function c0(){let e;try{e=xo?.getItem("debug")}catch{}return!e&&typeof globalThis.process<"u"&&"env"in globalThis.process&&(e=globalThis.process.env.DEBUG),e}function u0(){try{return localStorage}catch{}}function f0(e){e.j=function(t){try{return JSON.stringify(t)}catch(r){return"[UnexpectedJSONParseError]: "+r.message}}}var ku=zs({formatArgs:i0,save:a0,load:c0,useColors:o0,setupFormatters:f0,colors:n0,storage:xo,log:s0});var Ct=ku;Ct.formatters.b=e=>e==null?"undefined":X.baseEncode(e);Ct.formatters.t=e=>e==null?"undefined":te.baseEncode(e);Ct.formatters.m=e=>e==null?"undefined":li.baseEncode(e);Ct.formatters.p=e=>e==null?"undefined":e.toString();Ct.formatters.c=e=>e==null?"undefined":e.toString();Ct.formatters.k=e=>e==null?"undefined":e.toString();Ct.formatters.a=e=>e==null?"undefined":e.toString();function Ku(e,t=""){let r=$u(e.message),n=$u(e.stack);return r!=null&&n!=null?n.includes(r)?`${n.split(`
2
+ "use strict";var HeliaRouters=(()=>{var Sg=Object.create;var oi=Object.defineProperty;var vg=Object.getOwnPropertyDescriptor;var Ag=Object.getOwnPropertyNames;var Tg=Object.getPrototypeOf,Cg=Object.prototype.hasOwnProperty;var Cl=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),$=(e,t)=>{for(var r in t)oi(e,r,{get:t[r],enumerable:!0})},Il=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Ag(t))!Cg.call(e,o)&&o!==r&&oi(e,o,{get:()=>t[o],enumerable:!(n=vg(t,o))||n.enumerable});return e};var ii=(e,t,r)=>(r=e!=null?Sg(Tg(e)):{},Il(t||!e||!e.__esModule?oi(r,"default",{value:e,enumerable:!0}):r,e)),Ig=e=>Il(oi({},"__esModule",{value:!0}),e);var cs=Cl((wI,ju)=>{var xI=(function(){typeof ju<"u"&&(ju.exports=g);var e=86400,t=3200,r=146097*t/400,n=e*r,o=1e3*n,i=864e13,s=4294967296,a=1e6,c="000000000",u=Math.trunc||function(b){var D=b-b%1;return D==0&&(b<0||b===0&&1/b!=1/0)?-0:D},f=g.prototype,l=(g.fromDate=function(b){return new g(+b)},g.fromInt64BE=C(0,1,2,3,0,4),g.fromInt64LE=C(3,2,1,0,4,0),g.fromString=function(P){var D,k=new g,P=(P+="").replace(/^\s*[+\-]?\d+/,function(S){var S=+S,_=1970+(S-1970)%400;return k.year=S-_,_}).replace(/(?:Z|([+\-]\d{2}):?(\d{2}))$/,function(p,S,_){return S<0&&(_*=-1),D=6e4*(60*+S+ +_),""}).replace(/\.\d+$/,function(p){return k.nano=+(p+c).substr(1,9),""}).split(/\D+/);if(1<P.length?P[1]--:P[1]=0,k.time=D=Date.UTC.apply(Date,P)-(D||0),isNaN(D))throw new TypeError("Invalid Date");return m(k)},g.fromTimeT=function(b){return E(b,0)},f.year=0,f.time=0,f.nano=0,f.addNano=function(b){return this.nano+=+b||0,this},f.getNano=function(){var b=m(this);return(b.time%1e3*a+ +b.nano+1e9)%1e9},f.getTimeT=function(){var D=m(this),b=Math.floor(D.time/1e3),D=D.year;return D&&(b+=D*r*e/t),b},f.getYear=function(){return this.toDate().getUTCFullYear()+this.year},f.toDate=function(){return y(m(this).time)},f.toJSON=function(){return this.toString().replace(/0{1,6}Z$/,"Z")},f.toString=function(b){var D=this,k=D.toDate(),P={H:function(){return U(k.getUTCHours())},L:function(){return I(k.getUTCMilliseconds(),3)},M:function(){return U(k.getUTCMinutes())},N:function(){return I(D.getNano(),9)},S:function(){return U(k.getUTCSeconds())},Y:function(){var p=D.getYear();return 999999<p?"+"+p:9999<p?"+"+I(p,6):0<=p?I(p,4):-999999<=p?"-"+I(-p,6):p},a:function(){return x[k.getUTCDay()]},b:function(){return d[k.getUTCMonth()]},d:function(){return U(k.getUTCDate())},e:function(){return(function(p){return(9<p?"":" ")+(0|p)})(k.getUTCDate())},m:function(){return U(k.getUTCMonth()+1)}};return(function p(S){return S.replace(/%./g,function(_){var T=_[1],A=h[T],T=P[T];return A?p(A):T?T():_})})(b||l)},f.writeInt64BE=v(0,1,2,3,0,4),f.writeInt64LE=v(3,2,1,0,4,0),"%Y-%m-%dT%H:%M:%S.%NZ"),d=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],x=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],h={"%":"%",F:"%Y-%m-%d",n:`
3
+ `,R:"%H:%M",T:"%H:%M:%S",t:" ",X:"%T",Z:"GMT",z:"+0000"};return g;function g(b,D,k){var P=this;if(!(P instanceof g))return new g(b,D,k);P.time=+b||0,P.nano=+D||0,P.year=+k||0,m(P)}function m(b){var D,k,P,p=b.year,S=b.time,_=b.nano,A=((_<0||a<=_)&&(_-=(k=Math.floor(_/a))*a,S+=k,k=1),p%t);return(S<-i||i<S||A)&&((D=u(S/o))&&(p+=D*t,S-=D*o),(P=y(S)).setUTCFullYear(A+P.getUTCFullYear()),P=(S=+P)+(D=u((p-=A)/t))*o,D&&-i<=P&&P<=i&&(p-=D*t,S=P),k=1),k&&(b.year=p,b.time=S,b.nano=_),b}function y(b){var D=new Date(0);return D.setTime(b),D}function E(p,P){p=+p||0;var k=u((P=(P|0)*s)/n)+u(p/n),P=P%n+p%n,p=u(P/n);return p&&(k+=p,P-=p*n),new g(1e3*P,0,k*t)}function v(b,D,k,P,p,S){return function(A,T){var N=m(this);A=A||new Array(8),B(A,T|=0);var F=Math.floor(N.time/1e3),N=N.year*(r*e/t),L=u(N/s)+u(F/s),N=N%s+F%s,F=Math.floor(N/s);return F&&(L+=F,N-=F*s),_(A,T+p,L),_(A,T+S,N),A};function _(A,T,L){A[T+b]=L>>24&255,A[T+D]=L>>16&255,A[T+k]=L>>8&255,A[T+P]=255&L}}function C(b,D,k,P,p,S){return function(A,T){B(A,T|=0);var L=_(A,T+p);return E(_(A,T+S),L)};function _(A,T){return 16777216*A[T+b]+(A[T+D]<<16|A[T+k]<<8|A[T+P])}}function B(b,D){if(b=b&&b.length,b==null)throw new TypeError("Invalid Buffer");if(b<D+8)throw new RangeError("Out of range")}function U(b){return(9<b?"":"0")+(0|b)}function I(b,D){return(c+(0|b)).substr(-D)}})()});var Y0=Cl((pL,jf)=>{"use strict";var Y6=Object.prototype.hasOwnProperty,_t="~";function Jo(){}Object.create&&(Jo.prototype=Object.create(null),new Jo().__proto__||(_t=!1));function Z6(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function G0(e,t,r,n,o){if(typeof r!="function")throw new TypeError("The listener must be a function");var i=new Z6(r,n||e,o),s=_t?_t+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 Fs(e,t){--e._eventsCount===0?e._events=new Jo:delete e._events[t]}function At(){this._events=new Jo,this._eventsCount=0}At.prototype.eventNames=function(){var t=[],r,n;if(this._eventsCount===0)return t;for(n in r=this._events)Y6.call(r,n)&&t.push(_t?n.slice(1):n);return Object.getOwnPropertySymbols?t.concat(Object.getOwnPropertySymbols(r)):t};At.prototype.listeners=function(t){var r=_t?_t+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};At.prototype.listenerCount=function(t){var r=_t?_t+t:t,n=this._events[r];return n?n.fn?1:n.length:0};At.prototype.emit=function(t,r,n,o,i,s){var a=_t?_t+t:t;if(!this._events[a])return!1;var c=this._events[a],u=arguments.length,f,l;if(c.fn){switch(c.once&&this.removeListener(t,c.fn,void 0,!0),u){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,r),!0;case 3:return c.fn.call(c.context,r,n),!0;case 4:return c.fn.call(c.context,r,n,o),!0;case 5:return c.fn.call(c.context,r,n,o,i),!0;case 6:return c.fn.call(c.context,r,n,o,i,s),!0}for(l=1,f=new Array(u-1);l<u;l++)f[l-1]=arguments[l];c.fn.apply(c.context,f)}else{var d=c.length,x;for(l=0;l<d;l++)switch(c[l].once&&this.removeListener(t,c[l].fn,void 0,!0),u){case 1:c[l].fn.call(c[l].context);break;case 2:c[l].fn.call(c[l].context,r);break;case 3:c[l].fn.call(c[l].context,r,n);break;case 4:c[l].fn.call(c[l].context,r,n,o);break;default:if(!f)for(x=1,f=new Array(u-1);x<u;x++)f[x-1]=arguments[x];c[l].fn.apply(c[l].context,f)}}return!0};At.prototype.on=function(t,r,n){return G0(this,t,r,n,!1)};At.prototype.once=function(t,r,n){return G0(this,t,r,n,!0)};At.prototype.removeListener=function(t,r,n,o){var i=_t?_t+t:t;if(!this._events[i])return this;if(!r)return Fs(this,i),this;var s=this._events[i];if(s.fn)s.fn===r&&(!o||s.once)&&(!n||s.context===n)&&Fs(this,i);else{for(var a=0,c=[],u=s.length;a<u;a++)(s[a].fn!==r||o&&!s[a].once||n&&s[a].context!==n)&&c.push(s[a]);c.length?this._events[i]=c.length===1?c[0]:c:Fs(this,i)}return this};At.prototype.removeAllListeners=function(t){var r;return t?(r=_t?_t+t:t,this._events[r]&&Fs(this,r)):(this._events=new Jo,this._eventsCount=0),this};At.prototype.off=At.prototype.removeListener;At.prototype.addListener=At.prototype.on;At.prefixed=_t;At.EventEmitter=At;typeof jf<"u"&&(jf.exports=At)});var N8={};$(N8,{delegatedHTTPRouting:()=>hg,delegatedHTTPRoutingDefaults:()=>Xs,httpGatewayRouting:()=>wg,libp2pRouting:()=>Eg});var Bl=Symbol.for("@libp2p/content-routing");var W=class extends Error{static name="InvalidParametersError";constructor(t="Invalid parameters"){super(t),this.name="InvalidParametersError"}},qr=class extends Error{static name="InvalidPublicKeyError";constructor(t="Invalid public key"){super(t),this.name="InvalidPublicKeyError"}};var Ut=class extends Error{static name="NotFoundError";constructor(t="Not found"){super(t),this.name="NotFoundError"}};var si=class extends Error{static name="InvalidCIDError";constructor(t="Invalid CID"){super(t),this.name="InvalidCIDError"}},je=class extends Error{static name="InvalidMultihashError";constructor(t="Invalid Multihash"){super(t),this.name="InvalidMultihashError"}};var Hr=class extends Error{static name="UnsupportedKeyTypeError";constructor(t="Unsupported key type"){super(t),this.name="UnsupportedKeyTypeError"}};var ai=Symbol.for("@libp2p/peer-id");function Dl(e){return!!e?.[ai]}var _l=Symbol.for("@libp2p/peer-routing");var ra={};$(ra,{base58btc:()=>ht,base58flickr:()=>Ng});var M8=new Uint8Array(0);function Ll(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){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 Ul(e){return new TextEncoder().encode(e)}function Rl(e){return new TextDecoder().decode(e)}function Bg(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var o=0;o<e.length;o++){var i=e.charAt(o),s=i.charCodeAt(0);if(r[s]!==255)throw new TypeError(i+" is ambiguous");r[s]=o}var a=e.length,c=e.charAt(0),u=Math.log(a)/Math.log(256),f=Math.log(256)/Math.log(a);function l(h){if(h instanceof Uint8Array||(ArrayBuffer.isView(h)?h=new Uint8Array(h.buffer,h.byteOffset,h.byteLength):Array.isArray(h)&&(h=Uint8Array.from(h))),!(h instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(h.length===0)return"";for(var g=0,m=0,y=0,E=h.length;y!==E&&h[y]===0;)y++,g++;for(var v=(E-y)*f+1>>>0,C=new Uint8Array(v);y!==E;){for(var B=h[y],U=0,I=v-1;(B!==0||U<m)&&I!==-1;I--,U++)B+=256*C[I]>>>0,C[I]=B%a>>>0,B=B/a>>>0;if(B!==0)throw new Error("Non-zero carry");m=U,y++}for(var b=v-m;b!==v&&C[b]===0;)b++;for(var D=c.repeat(g);b<v;++b)D+=e.charAt(C[b]);return D}function d(h){if(typeof h!="string")throw new TypeError("Expected String");if(h.length===0)return new Uint8Array;var g=0;if(h[g]!==" "){for(var m=0,y=0;h[g]===c;)m++,g++;for(var E=(h.length-g)*u+1>>>0,v=new Uint8Array(E);h[g];){var C=r[h.charCodeAt(g)];if(C===255)return;for(var B=0,U=E-1;(C!==0||B<y)&&U!==-1;U--,B++)C+=a*v[U]>>>0,v[U]=C%256>>>0,C=C/256>>>0;if(C!==0)throw new Error("Non-zero carry");y=B,g++}if(h[g]!==" "){for(var I=E-y;I!==E&&v[I]===0;)I++;for(var b=new Uint8Array(m+(E-I)),D=m;I!==E;)b[D++]=v[I++];return b}}}function x(h){var g=d(h);if(g)return g;throw new Error(`Non-${t} character`)}return{encode:l,decodeUnsafe:d,decode:x}}var Dg=Bg,_g=Dg,Fl=_g;var Js=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")}},Qs=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 Pl(this,t)}},ta=class{decoders;constructor(t){this.decoders=t}or(t){return Pl(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 Pl(e,t){return new ta({...e.decoders??{[e.prefix]:e},...t.decoders??{[t.prefix]:t}})}var ea=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 Js(t,r,n),this.decoder=new Qs(t,r,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function jr({name:e,prefix:t,encode:r,decode:n}){return new ea(e,t,r,n)}function Ge({name:e,prefix:t,alphabet:r}){let{encode:n,decode:o}=Fl(r,e);return jr({prefix:t,name:e,encode:n,decode:i=>Ie(o(i))})}function Lg(e,t,r,n){let o=e.length;for(;e[o-1]==="=";)--o;let i=new Uint8Array(o*r/8|0),s=0,a=0,c=0;for(let u=0;u<o;++u){let f=t[e[u]];if(f===void 0)throw new SyntaxError(`Non-${n} character`);a=a<<r|f,s+=r,s>=8&&(s-=8,i[c++]=255&a>>s)}if(s>=r||(255&a<<8-s)!==0)throw new SyntaxError("Unexpected end of data");return i}function Ug(e,t,r){let n=t[t.length-1]==="=",o=(1<<r)-1,i="",s=0,a=0;for(let c=0;c<e.length;++c)for(a=a<<8|e[c],s+=8;s>r;)s-=r,i+=t[o&a>>s];if(s!==0&&(i+=t[o&a<<r-s]),n)for(;(i.length*r&7)!==0;)i+="=";return i}function Rg(e){let t={};for(let r=0;r<e.length;++r)t[e[r]]=r;return t}function J({name:e,prefix:t,bitsPerChar:r,alphabet:n}){let o=Rg(n);return jr({prefix:t,name:e,encode(i){return Ug(i,n,r)},decode(i){return Lg(i,o,r,e)}})}var ht=Ge({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Ng=Ge({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var na={};$(na,{base32:()=>Gr,base32hex:()=>kg,base32hexpad:()=>Mg,base32hexpadupper:()=>$g,base32hexupper:()=>Vg,base32pad:()=>Pg,base32padupper:()=>Og,base32upper:()=>Fg,base32z:()=>Kg});var Gr=J({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Fg=J({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Pg=J({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Og=J({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),kg=J({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Vg=J({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Mg=J({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),$g=J({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Kg=J({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var oa={};$(oa,{base36:()=>qn,base36upper:()=>zg});var qn=Ge({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),zg=Ge({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var qg=Vl,Ol=128,Hg=127,jg=~Hg,Gg=Math.pow(2,31);function Vl(e,t,r){t=t||[],r=r||0;for(var n=r;e>=Gg;)t[r++]=e&255|Ol,e/=128;for(;e&jg;)t[r++]=e&255|Ol,e>>>=7;return t[r]=e|0,Vl.bytes=r-n+1,t}var Yg=ia,Zg=128,kl=127;function ia(e,n){var r=0,n=n||0,o=0,i=n,s,a=e.length;do{if(i>=a)throw ia.bytes=0,new RangeError("Could not decode varint");s=e[i++],r+=o<28?(s&kl)<<o:(s&kl)*Math.pow(2,o),o+=7}while(s>=Zg);return ia.bytes=i-n,r}var Xg=Math.pow(2,7),Wg=Math.pow(2,14),Jg=Math.pow(2,21),Qg=Math.pow(2,28),ty=Math.pow(2,35),ey=Math.pow(2,42),ry=Math.pow(2,49),ny=Math.pow(2,56),oy=Math.pow(2,63),iy=function(e){return e<Xg?1:e<Wg?2:e<Jg?3:e<Qg?4:e<ty?5:e<ey?6:e<ry?7:e<ny?8:e<oy?9:10},sy={encode:qg,decode:Yg,encodingLength:iy},ay=sy,Hn=ay;function jn(e,t=0){return[Hn.decode(e,t),Hn.decode.bytes]}function Yr(e,t,r=0){return Hn.encode(e,t,r),t}function Zr(e){return Hn.encodingLength(e)}function ge(e,t){let r=t.byteLength,n=Zr(e),o=n+Zr(r),i=new Uint8Array(o+r);return Yr(e,i,0),Yr(r,i,n),i.set(t,o),new Xr(e,r,t,i)}function Ml(e){let t=Ie(e),[r,n]=jn(t),[o,i]=jn(t.subarray(n)),s=t.subarray(n+i);if(s.byteLength!==o)throw new Error("Incorrect length");return new Xr(r,o,s,t)}function $l(e,t){if(e===t)return!0;{let r=t;return e.code===r.code&&e.size===r.size&&r.bytes instanceof Uint8Array&&Ll(e.bytes,r.bytes)}}var Xr=class{code;size;digest;bytes;constructor(t,r,n,o){this.code=t,this.size=r,this.digest=n,this.bytes=o}};function Kl(e,t){let{bytes:r,version:n}=e;return n===0?uy(r,sa(e),t??ht.encoder):fy(r,sa(e),t??Gr.encoder)}var zl=new WeakMap;function sa(e){let t=zl.get(e);if(t==null){let r=new Map;return zl.set(e,r),r}return t}var Yt=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!==Yn)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==ly)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=ge(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&&$l(t.multihash,n.multihash)}toString(t){return Kl(this,t)}toJSON(){return{"/":Kl(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??ql(n,o,i.bytes))}else if(r[hy]===!0){let{version:n,multihash:o,code:i}=r,s=Ml(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!==Yn)throw new Error(`Version 0 CID must use dag-pb (code: ${Yn}) block encoding`);return new e(t,r,n,n.bytes)}case 1:{let o=ql(t,r,n.bytes);return new e(t,r,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return e.create(0,Yn,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=Ie(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 Xr(r.multihashCode,r.digestSize,i,o);return[r.version===0?e.createV0(s):e.createV1(r.codec,s),t.subarray(r.size)]}static inspectBytes(t){let r=0,n=()=>{let[l,d]=jn(t.subarray(r));return r+=d,l},o=n(),i=Yn;if(o===18?(o=0,r=0):i=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let s=r,a=n(),c=n(),u=r+c,f=u-s;return{version:o,codec:i,multihashCode:a,digestSize:c,multihashSize:f,size:u}}static parse(t,r){let[n,o]=cy(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 sa(i).set(n,t),i}};function cy(e,t){switch(e[0]){case"Q":{let r=t??ht;return[ht.prefix,r.decode(`${ht.prefix}${e}`)]}case ht.prefix:{let r=t??ht;return[ht.prefix,r.decode(e)]}case Gr.prefix:{let r=t??Gr;return[Gr.prefix,r.decode(e)]}case qn.prefix:{let r=t??qn;return[qn.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 uy(e,t,r){let{prefix:n}=r;if(n!==ht.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 fy(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 Yn=112,ly=18;function ql(e,t,r){let n=Zr(e),o=n+Zr(t),i=new Uint8Array(o+r.byteLength);return Yr(e,i,0),Yr(t,i,n),i.set(r,o),i}var hy=Symbol.for("@ipld/js-cid/CID");var aa={};$(aa,{identity:()=>wr});var Hl=0,dy="identity",jl=Ie;function py(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 ge(Hl,jl(e))}var wr={code:Hl,name:dy,encode:jl,digest:py};function ee(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}async function Gl(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}function Be(e=0){return new Uint8Array(e)}function Ot(e=0){return new Uint8Array(e)}function ui(e,t){t==null&&(t=e.reduce((o,i)=>o+i.length,0));let r=Ot(t),n=0;for(let o of e)r.set(o,n),n+=o.length;return r}var Zl=Symbol.for("@achingbrain/uint8arraylist");function Yl(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 fi(e){return!!e?.[Zl]}var kt=class e{bufs;length;[Zl]=!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(fi(n)){r+=n.byteLength;for(let o of n.bufs)this.bufs.push(o)}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(fi(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=Yl(this.bufs,t);return r.buf[r.index]}set(t,r){let n=Yl(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(fi(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 ui(n,o)}subarray(t,r){let{bufs:n,length:o}=this._subList(t,r);return n.length===1?n[0]:ui(n,o)}sublist(t,r){let{bufs:n,length:o}=this._subList(t,r),i=new e;return i.length=o,i.bufs=n,i}_subList(t,r){if(t=t??0,r=r??this.length,t<0&&(t=this.length+t),r<0&&(r=this.length+r),t<0||r>this.length)throw new RangeError("index is out of bounds");if(t===r)return{bufs:[],length:0};if(t===0&&r===this.length)return{bufs:[...this.bufs],length:this.length};let n=[],o=0;for(let i=0;i<this.bufs.length;i++){let s=this.bufs[i],a=o,c=a+s.byteLength;if(o=c,t>=c)continue;let u=t>=a&&t<c,f=r>a&&r<=c;if(u&&f){if(t===a&&r===c){n.push(s);break}let l=t-a;n.push(s.subarray(l,l+(r-t)));break}if(u){if(t===0){n.push(s);continue}n.push(s.subarray(t-a));continue}if(f){if(r===c){n.push(s);break}n.push(s.subarray(0,r-a));break}n.push(s)}return{bufs:n,length:r-t}}indexOf(t,r=0){if(!fi(t)&&!(t instanceof Uint8Array))throw new TypeError('The "value" argument must be a Uint8ArrayList or Uint8Array');let n=t instanceof Uint8Array?t:t.subarray();if(r=Number(r??0),isNaN(r)&&(r=0),r<0&&(r=this.length+r),r<0&&(r=0),t.length===0)return r>this.length?this.length:r;let o=n.byteLength;if(o===0)throw new TypeError("search must be at least 1 byte long");let i=256,s=new Int32Array(i);for(let l=0;l<i;l++)s[l]=-1;for(let l=0;l<o;l++)s[n[l]]=l;let a=s,c=this.byteLength-n.byteLength,u=n.byteLength-1,f;for(let l=r;l<=c;l+=f){f=0;for(let d=u;d>=0;d--){let x=this.get(l+d);if(n[d]!==x){f=Math.max(1,d-a[x]);break}}if(f===0)return l}return-1}getInt8(t){let r=this.subarray(t,t+1);return new DataView(r.buffer,r.byteOffset,r.byteLength).getInt8(0)}setInt8(t,r){let n=Ot(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=Be(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=Be(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=Be(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=Ot(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=Be(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=Be(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=Be(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=Be(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=Be(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(!ee(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 ca={};$(ca,{base10:()=>my});var my=Ge({prefix:"9",name:"base10",alphabet:"0123456789"});var ua={};$(ua,{base16:()=>gy,base16upper:()=>yy});var gy=J({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),yy=J({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var fa={};$(fa,{base2:()=>by});var by=J({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var la={};$(la,{base256emoji:()=>vy});var Xl=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}"),xy=Xl.reduce((e,t,r)=>(e[r]=t,e),[]),wy=Xl.reduce((e,t,r)=>{let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);return e[n]=r,e},[]);function Ey(e){return e.reduce((t,r)=>(t+=xy[r],t),"")}function Sy(e){let t=[];for(let r of e){let n=r.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${r}`);let o=wy[n];if(o==null)throw new Error(`Non-base256emoji character: ${r}`);t.push(o)}return new Uint8Array(t)}var vy=jr({prefix:"\u{1F680}",name:"base256emoji",encode:Ey,decode:Sy});var ha={};$(ha,{base64:()=>Ay,base64pad:()=>Ty,base64url:()=>Cy,base64urlpad:()=>Iy});var Ay=J({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Ty=J({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Cy=J({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Iy=J({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var da={};$(da,{base8:()=>By});var By=J({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var pa={};$(pa,{identity:()=>Dy});var Dy=jr({prefix:"\0",name:"identity",encode:e=>Rl(e),decode:e=>Ul(e)});var A4=new TextEncoder,T4=new TextDecoder;var ba={};$(ba,{sha256:()=>ya,sha512:()=>Ry});var Uy=20;function ga({name:e,code:t,encode:r,minDigestLength:n,maxDigestLength:o}){return new ma(e,t,r,n,o)}var ma=class{name;code;encode;minDigestLength;maxDigestLength;constructor(t,r,n,o,i){this.name=t,this.code=r,this.encode=n,this.minDigestLength=o??Uy,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?Wl(n,this.code,r?.truncate):n.then(o=>Wl(o,this.code,r?.truncate))}else throw Error("Unknown type, must be binary type")}};function Wl(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 ge(t,e)}function Ql(e){return async t=>new Uint8Array(await crypto.subtle.digest(e,t))}var ya=ga({name:"sha2-256",code:18,encode:Ql("SHA-256")}),Ry=ga({name:"sha2-512",code:19,encode:Ql("SHA-512")});var xa={...pa,...fa,...da,...ca,...ua,...na,...oa,...ra,...ha,...la},O4={...ba,...aa};function eh(e,t,r,n){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:n}}}var th=eh("utf8","u",e=>"u"+new TextDecoder("utf8").decode(e),e=>new TextEncoder().encode(e.substring(1))),wa=eh("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=Ot(e.length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t}),Ny={utf8:th,"utf-8":th,hex:xa.base16,latin1:wa,ascii:wa,binary:wa,...xa},li=Ny;function at(e,t="utf8"){let r=li[t];if(r==null)throw new Error(`Unsupported encoding "${t}"`);return r.decoder.decode(`${r.prefix}${e}`)}function ct(e,t="utf8"){let r=li[t];if(r==null)throw new Error(`Unsupported encoding "${t}"`);return r.encoder.encode(e).substring(1)}var Fy=parseInt("11111",2),Ea=parseInt("10000000",2),Py=parseInt("01111111",2),rh={0:Zn,1:Zn,2:Oy,3:My,4:$y,5:Vy,6:ky,16:Zn,22:Zn,48:Zn};function De(e,t={offset:0}){let r=e[t.offset]&Fy;if(t.offset++,rh[r]!=null)return rh[r](e,t);throw new Error("No decoder for tag "+r)}function Xn(e,t){let r=0;if((e[t.offset]&Ea)===Ea){let n=e[t.offset]&Py,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 Zn(e,t){Xn(e,t);let r=[];for(;!(t.offset>=e.byteLength);){let n=De(e,t);if(n===null)break;r.push(n)}return r}function Oy(e,t){let r=Xn(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 ky(e,t){let r=Xn(e,t),n=t.offset+r,o=e[t.offset];t.offset++;let i=0,s=0;o<40?(i=0,s=o):o<80?(i=1,s=o-40):(i=2,s=o-80);let a=`${i}.${s}`,c=[];for(;t.offset<n;){let u=e[t.offset];if(t.offset++,c.push(u&127),u<128){c.reverse();let f=0;for(let l=0;l<c.length;l++)f+=c[l]<<l*7;a+=`.${f}`,c=[]}}return a}function Vy(e,t){return t.offset++,null}function My(e,t){let r=Xn(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 $y(e,t){let r=Xn(e,t),n=e.subarray(t.offset,t.offset+r);return t.offset+=r,n}function Ky(e){let t=e.toString(16);t.length%2===1&&(t="0"+t);let r=new kt;for(let n=0;n<t.length;n+=2)r.append(Uint8Array.from([parseInt(`${t[n]}${t[n+1]}`,16)]));return r}function Sa(e){if(e.byteLength<128)return Uint8Array.from([e.byteLength]);let t=Ky(e.byteLength);return new kt(Uint8Array.from([t.byteLength|Ea]),t)}function Rt(e){let t=new kt,r=128;return(e.subarray()[0]&r)===r&&t.append(Uint8Array.from([0])),t.append(e),new kt(Uint8Array.from([2]),Sa(t),t)}function hi(e){let t=Uint8Array.from([0]),r=new kt(t,e);return new kt(Uint8Array.from([3]),Sa(r),r)}function Ye(e,t=48){let r=new kt;for(let n of e)r.append(n);return new kt(Uint8Array.from([t]),Sa(r),r)}var zy=Uint8Array.from([6,8,42,134,72,206,61,3,1,7]),qy=Uint8Array.from([6,5,43,129,4,0,34]),Hy=Uint8Array.from([6,5,43,129,4,0,35]),jy={ext:!0,kty:"EC",crv:"P-256"},Gy={ext:!0,kty:"EC",crv:"P-384"},Yy={ext:!0,kty:"EC",crv:"P-521"},va=32,Aa=48,Ta=66;function Ca(e){let t=De(e);return nh(t)}function nh(e){let t=e[1][1][0],r=1,n,o;if(t.byteLength===va*2+1)return n=ct(t.subarray(r,r+va),"base64url"),o=ct(t.subarray(r+va),"base64url"),new Wr({...jy,key_ops:["verify"],x:n,y:o});if(t.byteLength===Aa*2+1)return n=ct(t.subarray(r,r+Aa),"base64url"),o=ct(t.subarray(r+Aa),"base64url"),new Wr({...Gy,key_ops:["verify"],x:n,y:o});if(t.byteLength===Ta*2+1)return n=ct(t.subarray(r,r+Ta),"base64url"),o=ct(t.subarray(r+Ta),"base64url"),new Wr({...Yy,key_ops:["verify"],x:n,y:o});throw new W(`coordinates were wrong length, got ${t.byteLength}, expected 65, 97 or 133`)}function oh(e){return Ye([Rt(Uint8Array.from([1])),Ye([Zy(e.crv)],160),Ye([hi(new kt(Uint8Array.from([4]),at(e.x??"","base64url"),at(e.y??"","base64url")))],161)]).subarray()}function Zy(e){if(e==="P-256")return zy;if(e==="P-384")return qy;if(e==="P-521")return Hy;throw new W(`Invalid curve ${e}`)}var Wr=class{type="ECDSA";jwk;_raw;constructor(t){this.jwk=t}get raw(){return this._raw==null&&(this._raw=oh(this.jwk)),this._raw}toMultihash(){return wr.digest(Jr(this))}toCID(){return Yt.createV1(114,this.toMultihash())}toString(){return ht.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:ee(this.raw,t.raw)}async verify(t,r,n){return Gl(this.jwk,r,t,n)}};function Ia(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"&&"BYTES_PER_ELEMENT"in e&&e.BYTES_PER_ELEMENT===1}function Ze(e,t=""){if(typeof e!="number"){let r=t&&`"${t}" `;throw new TypeError(`${r}expected number, got ${typeof e}`)}if(!Number.isSafeInteger(e)||e<0){let r=t&&`"${t}" `;throw new RangeError(`${r}expected integer >= 0, got ${e}`)}}function Vt(e,t,r=""){let n=Ia(e),o=e?.length,i=t!==void 0;if(!n||i&&o!==t){let s=r&&`"${r}" `,a=i?` of length ${t}`:"",c=n?`length=${o}`:`type=${typeof e}`,u=s+"expected Uint8Array"+a+", got "+c;throw n?new RangeError(u):new TypeError(u)}return e}function di(e){if(typeof e!="function"||typeof e.create!="function")throw new TypeError("Hash must wrapped by utils.createHasher");if(Ze(e.outputLen),Ze(e.blockLen),e.outputLen<1)throw new Error('"outputLen" must be >= 1');if(e.blockLen<1)throw new Error('"blockLen" must be >= 1')}function Qr(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 pi(e,t){Vt(e,void 0,"digestInto() output");let r=t.outputLen;if(e.length<r)throw new RangeError('"digestInto() output" expected to be of length >='+r)}function Le(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function mi(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function re(e,t){return e<<32-t|e>>>t}var sh=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",Xy=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function gi(e){if(Vt(e),sh)return e.toHex();let t="";for(let r=0;r<e.length;r++)t+=Xy[e[r]];return t}var _e={_0:48,_9:57,A:65,F:70,a:97,f:102};function ih(e){if(e>=_e._0&&e<=_e._9)return e-_e._0;if(e>=_e.A&&e<=_e.F)return e-(_e.A-10);if(e>=_e.a&&e<=_e.f)return e-(_e.a-10)}function Wn(e){if(typeof e!="string")throw new TypeError("hex string expected, got "+typeof e);if(sh)try{return Uint8Array.fromHex(e)}catch(o){throw o instanceof SyntaxError?new RangeError(o.message):o}let t=e.length,r=t/2;if(t%2)throw new RangeError("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=ih(e.charCodeAt(i)),a=ih(e.charCodeAt(i+1));if(s===void 0||a===void 0){let c=e[i]+e[i+1];throw new RangeError('hex string expected, got non-hex character "'+c+'" at index '+i)}n[o]=s*16+a}return n}function Ba(...e){let t=0;for(let n=0;n<e.length;n++){let o=e[n];Vt(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 Da(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.canXOF=n.canXOF,r.create=o=>e(o),Object.assign(r,t),Object.freeze(r)}function ah(e=32){Ze(e,"bytesLength");let t=typeof globalThis=="object"?globalThis.crypto:null;if(typeof t?.getRandomValues!="function")throw new Error("crypto.getRandomValues must be defined");if(e>65536)throw new RangeError(`"bytesLength" expected <= 65536, got ${e}`);return t.getRandomValues(new Uint8Array(e))}var _a=e=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])});function ch(e,t,r){return e&t^~e&r}function uh(e,t,r){return e&t^e&r^t&r}var Jn=class{blockLen;outputLen;canXOF=!1;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=mi(this.buffer)}update(t){Qr(this),Vt(t);let{view:r,buffer:n,blockLen:o}=this,i=t.length;for(let s=0;s<i;){let a=Math.min(o-this.pos,i-s);if(a===o){let c=mi(t);for(;o<=i-s;s+=o)this.process(c,s);continue}n.set(t.subarray(s,s+a),this.pos),this.pos+=a,s+=a,this.pos===o&&(this.process(r,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){Qr(this),pi(t,this),this.finished=!0;let{buffer:r,view:n,blockLen:o,isLE:i}=this,{pos:s}=this;r[s++]=128,Le(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 a=mi(t),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen must be aligned to 32bit");let u=c/4,f=this.get();if(u>f.length)throw new Error("_sha2: outputLen bigger than state");for(let l=0;l<u;l++)a.setUint32(4*l,f[l],i)}digest(){let{buffer:t,outputLen:r}=this;this.digestInto(t);let n=t.slice(0,r);return this.destroy(),n}_cloneInto(t){t||=new this.constructor,t.set(...this.get());let{blockLen:r,buffer:n,length:o,finished:i,destroyed:s,pos:a}=this;return t.destroyed=s,t.finished=i,t.length=o,t.pos=a,o%r&&t.buffer.set(n),t}clone(){return this._cloneInto()}},Ue=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var yt=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]);var yi=BigInt(4294967295),fh=BigInt(32);function Wy(e,t=!1){return t?{h:Number(e&yi),l:Number(e>>fh&yi)}:{h:Number(e>>fh&yi)|0,l:Number(e&yi)|0}}function lh(e,t=!1){let r=e.length,n=new Uint32Array(r),o=new Uint32Array(r);for(let i=0;i<r;i++){let{h:s,l:a}=Wy(e[i],t);[n[i],o[i]]=[s,a]}return[n,o]}var La=(e,t,r)=>e>>>r,Ua=(e,t,r)=>e<<32-r|t>>>r,Er=(e,t,r)=>e>>>r|t<<32-r,Sr=(e,t,r)=>e<<32-r|t>>>r,Qn=(e,t,r)=>e<<64-r|t>>>r-32,to=(e,t,r)=>e>>>r-32|t<<64-r;function ye(e,t,r,n){let o=(t>>>0)+(n>>>0);return{h:e+r+(o/2**32|0)|0,l:o|0}}var hh=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0),dh=(e,t,r,n)=>t+r+n+(e/2**32|0)|0,ph=(e,t,r,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0),mh=(e,t,r,n,o)=>t+r+n+o+(e/2**32|0)|0,gh=(e,t,r,n,o)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0)+(o>>>0),yh=(e,t,r,n,o,i)=>t+r+n+o+i+(e/2**32|0)|0;var Qy=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]),Xe=new Uint32Array(64),Ra=class extends Jn{constructor(t){super(64,t,8,!1)}get(){let{A:t,B:r,C:n,D:o,E:i,F:s,G:a,H:c}=this;return[t,r,n,o,i,s,a,c]}set(t,r,n,o,i,s,a,c){this.A=t|0,this.B=r|0,this.C=n|0,this.D=o|0,this.E=i|0,this.F=s|0,this.G=a|0,this.H=c|0}process(t,r){for(let l=0;l<16;l++,r+=4)Xe[l]=t.getUint32(r,!1);for(let l=16;l<64;l++){let d=Xe[l-15],x=Xe[l-2],h=re(d,7)^re(d,18)^d>>>3,g=re(x,17)^re(x,19)^x>>>10;Xe[l]=g+Xe[l-7]+h+Xe[l-16]|0}let{A:n,B:o,C:i,D:s,E:a,F:c,G:u,H:f}=this;for(let l=0;l<64;l++){let d=re(a,6)^re(a,11)^re(a,25),x=f+d+ch(a,c,u)+Qy[l]+Xe[l]|0,g=(re(n,2)^re(n,13)^re(n,22))+uh(n,o,i)|0;f=u,u=c,c=a,a=s+x|0,s=i,i=o,o=n,n=x+g|0}n=n+this.A|0,o=o+this.B|0,i=i+this.C|0,s=s+this.D|0,a=a+this.E|0,c=c+this.F|0,u=u+this.G|0,f=f+this.H|0,this.set(n,o,i,s,a,c,u,f)}roundClean(){Le(Xe)}destroy(){this.destroyed=!0,this.set(0,0,0,0,0,0,0,0),Le(this.buffer)}},Na=class extends Ra{A=Ue[0]|0;B=Ue[1]|0;C=Ue[2]|0;D=Ue[3]|0;E=Ue[4]|0;F=Ue[5]|0;G=Ue[6]|0;H=Ue[7]|0;constructor(){super(32)}};var bh=lh(["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))),tb=bh[0],eb=bh[1],We=new Uint32Array(80),Je=new Uint32Array(80),Fa=class extends Jn{constructor(t){super(128,t,16,!1)}get(){let{Ah:t,Al:r,Bh:n,Bl:o,Ch:i,Cl:s,Dh:a,Dl:c,Eh:u,El:f,Fh:l,Fl:d,Gh:x,Gl:h,Hh:g,Hl:m}=this;return[t,r,n,o,i,s,a,c,u,f,l,d,x,h,g,m]}set(t,r,n,o,i,s,a,c,u,f,l,d,x,h,g,m){this.Ah=t|0,this.Al=r|0,this.Bh=n|0,this.Bl=o|0,this.Ch=i|0,this.Cl=s|0,this.Dh=a|0,this.Dl=c|0,this.Eh=u|0,this.El=f|0,this.Fh=l|0,this.Fl=d|0,this.Gh=x|0,this.Gl=h|0,this.Hh=g|0,this.Hl=m|0}process(t,r){for(let v=0;v<16;v++,r+=4)We[v]=t.getUint32(r),Je[v]=t.getUint32(r+=4);for(let v=16;v<80;v++){let C=We[v-15]|0,B=Je[v-15]|0,U=Er(C,B,1)^Er(C,B,8)^La(C,B,7),I=Sr(C,B,1)^Sr(C,B,8)^Ua(C,B,7),b=We[v-2]|0,D=Je[v-2]|0,k=Er(b,D,19)^Qn(b,D,61)^La(b,D,6),P=Sr(b,D,19)^to(b,D,61)^Ua(b,D,6),p=ph(I,P,Je[v-7],Je[v-16]),S=mh(p,U,k,We[v-7],We[v-16]);We[v]=S|0,Je[v]=p|0}let{Ah:n,Al:o,Bh:i,Bl:s,Ch:a,Cl:c,Dh:u,Dl:f,Eh:l,El:d,Fh:x,Fl:h,Gh:g,Gl:m,Hh:y,Hl:E}=this;for(let v=0;v<80;v++){let C=Er(l,d,14)^Er(l,d,18)^Qn(l,d,41),B=Sr(l,d,14)^Sr(l,d,18)^to(l,d,41),U=l&x^~l&g,I=d&h^~d&m,b=gh(E,B,I,eb[v],Je[v]),D=yh(b,y,C,U,tb[v],We[v]),k=b|0,P=Er(n,o,28)^Qn(n,o,34)^Qn(n,o,39),p=Sr(n,o,28)^to(n,o,34)^to(n,o,39),S=n&i^n&a^i&a,_=o&s^o&c^s&c;y=g|0,E=m|0,g=x|0,m=h|0,x=l|0,h=d|0,{h:l,l:d}=ye(u|0,f|0,D|0,k|0),u=a|0,f=c|0,a=i|0,c=s|0,i=n|0,s=o|0;let A=hh(k,p,_);n=dh(A,D,P,S),o=A|0}({h:n,l:o}=ye(this.Ah|0,this.Al|0,n|0,o|0)),{h:i,l:s}=ye(this.Bh|0,this.Bl|0,i|0,s|0),{h:a,l:c}=ye(this.Ch|0,this.Cl|0,a|0,c|0),{h:u,l:f}=ye(this.Dh|0,this.Dl|0,u|0,f|0),{h:l,l:d}=ye(this.Eh|0,this.El|0,l|0,d|0),{h:x,l:h}=ye(this.Fh|0,this.Fl|0,x|0,h|0),{h:g,l:m}=ye(this.Gh|0,this.Gl|0,g|0,m|0),{h:y,l:E}=ye(this.Hh|0,this.Hl|0,y|0,E|0),this.set(n,o,i,s,a,c,u,f,l,d,x,h,g,m,y,E)}roundClean(){Le(We,Je)}destroy(){this.destroyed=!0,Le(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}},Pa=class extends Fa{Ah=yt[0]|0;Al=yt[1]|0;Bh=yt[2]|0;Bl=yt[3]|0;Ch=yt[4]|0;Cl=yt[5]|0;Dh=yt[6]|0;Dl=yt[7]|0;Eh=yt[8]|0;El=yt[9]|0;Fh=yt[10]|0;Fl=yt[11]|0;Gh=yt[12]|0;Gl=yt[13]|0;Hh=yt[14]|0;Hl=yt[15]|0;constructor(){super(64)}};var tn=Da(()=>new Na,_a(1));var bi=Da(()=>new Pa,_a(3));var H=(e,t,r)=>Vt(e,t,r),ka=Ze,en=gi,ut=(...e)=>Ba(...e),rn=e=>Wn(e),vr=Ia,eo=e=>ah(e),wi=BigInt(0),Oa=BigInt(1);function ne(e,t=""){if(typeof e!="boolean"){let r=t&&`"${t}" `;throw new TypeError(r+"expected boolean, got type="+typeof e)}return e}function Ei(e){if(typeof e=="bigint"){if(!xi(e))throw new RangeError("positive bigint expected, got "+e)}else ka(e);return e}function oe(e,t=""){if(typeof e!="number"){let r=t&&`"${t}" `;throw new TypeError(r+"expected number, got type="+typeof e)}if(!Number.isSafeInteger(e)){let r=t&&`"${t}" `;throw new RangeError(r+"expected safe integer, got "+e)}}function ro(e){let t=Ei(e).toString(16);return t.length&1?"0"+t:t}function xh(e){if(typeof e!="string")throw new TypeError("hex string expected, got "+typeof e);return e===""?wi:BigInt("0x"+e)}function Ar(e){return xh(gi(e))}function be(e){return xh(gi(no(Vt(e)).reverse()))}function Si(e,t){if(Ze(t),t===0)throw new RangeError("zero length");e=Ei(e);let r=e.toString(16);if(r.length>t*2)throw new RangeError("number too large");return Wn(r.padStart(t*2,"0"))}function Va(e,t){return Si(e,t).reverse()}function wh(e,t){if(e=H(e),t=H(t),e.length!==t.length)return!1;let r=0;for(let n=0;n<e.length;n++)r|=e[n]^t[n];return r===0}function no(e){return Uint8Array.from(H(e))}function vi(e){if(typeof e!="string")throw new TypeError("ascii string expected, got "+typeof e);return Uint8Array.from(e,(t,r)=>{let n=t.charCodeAt(0);if(t.length!==1||n>127)throw new RangeError(`string contains non-ASCII character "${e[r]}" with code ${n} at position ${r}`);return n})}var xi=e=>typeof e=="bigint"&&wi<=e;function rb(e,t,r){return xi(e)&&xi(t)&&xi(r)&&t<=e&&e<r}function nn(e,t,r,n){if(!rb(t,r,n))throw new RangeError("expected valid "+e+": "+r+" <= n < "+n+", got "+t)}function on(e){if(e<wi)throw new Error("expected non-negative bigint, got "+e);let t;for(t=0;e>wi;e>>=Oa,t+=1);return t}var oo=e=>(Oa<<BigInt(e))-Oa;function Eh(e,t,r){if(Ze(e,"hashLen"),Ze(t,"qByteLen"),typeof r!="function")throw new TypeError("hmacFn must be a function");let n=m=>new Uint8Array(m),o=Uint8Array.of(),i=Uint8Array.of(0),s=Uint8Array.of(1),a=1e3,c=n(e),u=n(e),f=0,l=()=>{c.fill(1),u.fill(0),f=0},d=(...m)=>r(u,ut(c,...m)),x=(m=o)=>{u=d(i,m),c=d(),m.length!==0&&(u=d(s,m),c=d())},h=()=>{if(f++>=a)throw new Error("drbg: tried max amount of iterations");let m=0,y=[];for(;m<t;){c=d();let E=c.slice();y.push(E),m+=c.length}return ut(...y)};return(m,y)=>{l(),x(m);let E;for(;(E=y(h()))===void 0;)x();return l(),E}}function ie(e,t={},r={}){if(Object.prototype.toString.call(e)!=="[object Object]")throw new TypeError("expected valid options object");function n(i,s,a){if(!a&&s!=="function"&&!Object.hasOwn(e,i))throw new TypeError(`param "${i}" is invalid: expected own property`);let c=e[i];if(a&&c===void 0)return;let u=typeof c;if(u!==s||c===null)throw new TypeError(`param "${i}" is invalid: expected ${s}, got ${u}`)}let o=(i,s)=>Object.entries(i).forEach(([a,c])=>n(a,c,s));o(t,!1),o(r,!0)}var Ma=()=>{throw new Error("not implemented")};var bt=BigInt(0),Q=BigInt(1),Tr=BigInt(2),Th=BigInt(3),Ch=BigInt(4),Ih=BigInt(5),nb=BigInt(7),Bh=BigInt(8),ob=BigInt(9),Dh=BigInt(16);function ot(e,t){if(t<=bt)throw new Error("mod: expected positive modulus, got "+t);let r=e%t;return r>=bt?r:t+r}function Y(e,t,r){if(t<bt)throw new Error("pow2: expected non-negative exponent, got "+t);let n=e;for(;t-- >bt;)n*=n,n%=r;return n}function Sh(e,t){if(e===bt)throw new Error("invert: expected non-zero number");if(t<=bt)throw new Error("invert: expected positive modulus, got "+t);let r=ot(e,t),n=t,o=bt,i=Q,s=Q,a=bt;for(;r!==bt;){let u=n/r,f=n-r*u,l=o-s*u,d=i-a*u;n=r,r=f,o=s,i=a,s=l,a=d}if(n!==Q)throw new Error("invert: does not exist");return ot(o,t)}function $a(e,t,r){let n=e;if(!n.eql(n.sqr(t),r))throw new Error("Cannot find square root")}function _h(e,t){let r=e,n=(r.ORDER+Q)/Ch,o=r.pow(t,n);return $a(r,o,t),o}function ib(e,t){let r=e,n=(r.ORDER-Ih)/Bh,o=r.mul(t,Tr),i=r.pow(o,n),s=r.mul(t,i),a=r.mul(r.mul(s,Tr),i),c=r.mul(s,r.sub(a,r.ONE));return $a(r,c,t),c}function sb(e){let t=sn(e),r=Lh(e),n=r(t,t.neg(t.ONE)),o=r(t,n),i=r(t,t.neg(n)),s=(e+nb)/Dh;return((a,c)=>{let u=a,f=u.pow(c,s),l=u.mul(f,n),d=u.mul(f,o),x=u.mul(f,i),h=u.eql(u.sqr(l),c),g=u.eql(u.sqr(d),c);f=u.cmov(f,l,h),l=u.cmov(x,d,g);let m=u.eql(u.sqr(l),c),y=u.cmov(f,l,m);return $a(u,y,c),y})}function Lh(e){if(e<Th)throw new Error("sqrt is not defined for small field");let t=e-Q,r=0;for(;t%Tr===bt;)t/=Tr,r++;let n=Tr,o=sn(e);for(;vh(o,n)===1;)if(n++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(r===1)return _h;let i=o.pow(n,t),s=(t+Q)/Tr;return function(c,u){let f=c;if(f.is0(u))return u;if(vh(f,u)!==1)throw new Error("Cannot find square root");let l=r,d=f.mul(f.ONE,i),x=f.pow(u,t),h=f.pow(u,s);for(;!f.eql(x,f.ONE);){if(f.is0(x))return f.ZERO;let g=1,m=f.sqr(x);for(;!f.eql(m,f.ONE);)if(g++,m=f.sqr(m),g===l)throw new Error("Cannot find square root");let y=Q<<BigInt(l-g-1),E=f.pow(d,y);l=g,d=f.sqr(E),x=f.mul(x,d),h=f.mul(h,E)}return h}}function ab(e){return e%Ch===Th?_h:e%Bh===Ih?ib:e%Dh===ob?sb(e):Lh(e)}var Re=(e,t)=>(ot(e,t)&Q)===Q,cb=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Ka(e){let t={ORDER:"bigint",BYTES:"number",BITS:"number"},r=cb.reduce((n,o)=>(n[o]="function",n),t);if(ie(e,r),oe(e.BYTES,"BYTES"),oe(e.BITS,"BITS"),e.BYTES<1||e.BITS<1)throw new Error("invalid field: expected BYTES/BITS > 0");if(e.ORDER<=Q)throw new Error("invalid field: expected ORDER > 1, got "+e.ORDER);return e}function ub(e,t,r){let n=e;if(r<bt)throw new Error("invalid exponent, negatives unsupported");if(r===bt)return n.ONE;if(r===Q)return t;let o=n.ONE,i=t;for(;r>bt;)r&Q&&(o=n.mul(o,i)),i=n.sqr(i),r>>=Q;return o}function io(e,t,r=!1){let n=e,o=new Array(t.length).fill(r?n.ZERO:void 0),i=t.reduce((a,c,u)=>n.is0(c)?a:(o[u]=a,n.mul(a,c)),n.ONE),s=n.inv(i);return t.reduceRight((a,c,u)=>n.is0(c)?a:(o[u]=n.mul(a,o[u]),n.mul(a,c)),s),o}function vh(e,t){let r=e,n=(r.ORDER-Q)/Tr,o=r.pow(t,n),i=r.eql(o,r.ONE),s=r.eql(o,r.ZERO),a=r.eql(o,r.neg(r.ONE));if(!i&&!s&&!a)throw new Error("invalid Legendre symbol result");return i?1:s?0:-1}function fb(e,t){if(t!==void 0&&ka(t),e<=bt)throw new Error("invalid n length: expected positive n, got "+e);if(t!==void 0&&t<1)throw new Error("invalid n length: expected positive bit length, got "+t);let r=on(e);if(t!==void 0&&t<r)throw new Error(`invalid n length: expected bit length (${r}) >= n.length (${t})`);let n=t!==void 0?t:r,o=Math.ceil(n/8);return{nBitLength:n,nByteLength:o}}var Ah=new WeakMap,Ai=class{ORDER;BITS;BYTES;isLE;ZERO=bt;ONE=Q;_lengths;_mod;constructor(t,r={}){if(t<=Q)throw new Error("invalid field: expected ORDER > 1, got "+t);let n;this.isLE=!1,r!=null&&typeof r=="object"&&(typeof r.BITS=="number"&&(n=r.BITS),typeof r.sqrt=="function"&&Object.defineProperty(this,"sqrt",{value:r.sqrt,enumerable:!0}),typeof r.isLE=="boolean"&&(this.isLE=r.isLE),r.allowedLengths&&(this._lengths=Object.freeze(r.allowedLengths.slice())),typeof r.modFromBytes=="boolean"&&(this._mod=r.modFromBytes));let{nBitLength:o,nByteLength:i}=fb(t,n);if(i>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");this.ORDER=t,this.BITS=o,this.BYTES=i,Object.freeze(this)}create(t){return ot(t,this.ORDER)}isValid(t){if(typeof t!="bigint")throw new TypeError("invalid field element: expected bigint, got "+typeof t);return bt<=t&&t<this.ORDER}is0(t){return t===bt}isValidNot0(t){return!this.is0(t)&&this.isValid(t)}isOdd(t){return(t&Q)===Q}neg(t){return ot(-t,this.ORDER)}eql(t,r){return t===r}sqr(t){return ot(t*t,this.ORDER)}add(t,r){return ot(t+r,this.ORDER)}sub(t,r){return ot(t-r,this.ORDER)}mul(t,r){return ot(t*r,this.ORDER)}pow(t,r){return ub(this,t,r)}div(t,r){return ot(t*Sh(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 Sh(t,this.ORDER)}sqrt(t){let r=Ah.get(this);return r||Ah.set(this,r=ab(this.ORDER)),r(this,t)}toBytes(t){return this.isLE?Va(t,this.BYTES):Si(t,this.BYTES)}fromBytes(t,r=!1){H(t);let{_lengths:n,BYTES:o,isLE:i,ORDER:s,_mod:a}=this;if(n){if(t.length<1||!n.includes(t.length)||t.length>o)throw new Error("Field.fromBytes: expected "+n+" bytes, got "+t.length);let u=new Uint8Array(o);u.set(t,i?0:u.length-t.length),t=u}if(t.length!==o)throw new Error("Field.fromBytes: expected "+o+" bytes, got "+t.length);let c=i?be(t):Ar(t);if(a&&(c=ot(c,s)),!r&&!this.isValid(c))throw new Error("invalid field element: outside of range 0..ORDER");return c}invertBatch(t){return io(this,t)}cmov(t,r,n){return ne(n,"condition"),n?r:t}};Object.freeze(Ai.prototype);function sn(e,t={}){return new Ai(e,t)}function Uh(e){if(typeof e!="bigint")throw new Error("field order must be bigint");if(e<=Q)throw new Error("field order must be greater than 1");let t=on(e-Q);return Math.ceil(t/8)}function za(e){let t=Uh(e);return t+Math.ceil(t/2)}function qa(e,t,r=!1){H(e);let n=e.length,o=Uh(t),i=Math.max(za(t),16);if(n<i||n>1024)throw new Error("expected "+i+"-1024 bytes of input, got "+n);let s=r?be(e):Ar(e),a=ot(s,t-Q)+Q;return r?Va(a,o):Si(a,o)}var an=BigInt(0),Cr=BigInt(1);function so(e,t){let r=t.negate();return e?r:t}function Ir(e,t){let r=io(e.Fp,t.map(n=>n.Z));return t.map((n,o)=>e.fromAffine(n.toAffine(r[o])))}function Ph(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+e)}function Ha(e,t){Ph(e,t);let r=Math.ceil(t/e)+1,n=2**(e-1),o=2**e,i=oo(e),s=BigInt(e);return{windows:r,windowSize:n,mask:i,maxNumber:o,shiftBy:s}}function Rh(e,t,r){let{windowSize:n,mask:o,maxNumber:i,shiftBy:s}=r,a=Number(e&o),c=e>>s;a>n&&(a-=i,c+=Cr);let u=t*n,f=u+Math.abs(a)-1,l=a===0,d=a<0,x=t%2!==0;return{nextN:c,offset:f,isZero:l,isNeg:d,isNegF:x,offsetF:u}}var ja=new WeakMap,Oh=new WeakMap;function Ga(e){return Oh.get(e)||1}function Nh(e){if(e!==an)throw new Error("invalid wNAF")}var cn=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>an;)r&Cr&&(n=n.add(o)),o=o.double(),r>>=Cr;return n}precomputeWindow(t,r){let{windows:n,windowSize:o}=Ha(r,this.bits),i=[],s=t,a=s;for(let c=0;c<n;c++){a=s,i.push(a);for(let u=1;u<o;u++)a=a.add(s),i.push(a);s=a.double()}return i}wNAF(t,r,n){if(!this.Fn.isValid(n))throw new Error("invalid scalar");let o=this.ZERO,i=this.BASE,s=Ha(t,this.bits);for(let a=0;a<s.windows;a++){let{nextN:c,offset:u,isZero:f,isNeg:l,isNegF:d,offsetF:x}=Rh(n,a,s);n=c,f?i=i.add(so(d,r[x])):o=o.add(so(l,r[u]))}return Nh(n),{p:o,f:i}}wNAFUnsafe(t,r,n,o=this.ZERO){let i=Ha(t,this.bits);for(let s=0;s<i.windows&&n!==an;s++){let{nextN:a,offset:c,isZero:u,isNeg:f}=Rh(n,s,i);if(n=a,!u){let l=r[c];o=o.add(f?l.negate():l)}}return Nh(n),o}getPrecomputes(t,r,n){let o=ja.get(r);return o||(o=this.precomputeWindow(r,t),t!==1&&(typeof n=="function"&&(o=n(o)),ja.set(r,o))),o}cached(t,r,n){let o=Ga(t);return this.wNAF(o,this.getPrecomputes(o,t,n),r)}unsafe(t,r,n,o){let i=Ga(t);return i===1?this._unsafeLadder(t,r,o):this.wNAFUnsafe(i,this.getPrecomputes(i,t,n),r,o)}createCache(t,r){Ph(r,this.bits),Oh.set(t,r),ja.delete(t)}hasCache(t){return Ga(t)!==1}};function kh(e,t,r,n){let o=t,i=e.ZERO,s=e.ZERO;for(;r>an||n>an;)r&Cr&&(i=i.add(o)),n&Cr&&(s=s.add(o)),o=o.double(),r>>=Cr,n>>=Cr;return{p1:i,p2:s}}function Fh(e,t,r){if(t){if(t.ORDER!==e)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return Ka(t),t}else return sn(e,{isLE:r})}function Ti(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 c of["p","n","h"]){let u=t[c];if(!(typeof u=="bigint"&&u>an))throw new Error(`CURVE.${c} must be positive bigint`)}let o=Fh(t.p,r.Fp,n),i=Fh(t.n,r.Fn,n),a=["Gx","Gy","a",e==="weierstrass"?"b":"d"];for(let c of a)if(!o.isValid(t[c]))throw new Error(`CURVE.${c} must be valid field element of CURVE.Fp`);return t=Object.freeze(Object.assign({},t)),{CURVE:t,Fp:o,Fn:i}}function Ci(e,t){return function(n){let o=e(n);return{secretKey:o,publicKey:t(o)}}}var Qe=BigInt(0),dt=BigInt(1),Ya=BigInt(2),lb=BigInt(8);function hb(e,t,r,n){let o=e.sqr(r),i=e.sqr(n),s=e.add(e.mul(t.a,o),i),a=e.add(e.ONE,e.mul(t.d,e.mul(o,i)));return e.eql(s,a)}function Vh(e,t={}){let r=t,n=Ti("edwards",e,r,r.FpFnLE),{Fp:o,Fn:i}=n,s=n.CURVE,{h:a}=s;ie(r,{},{uvRatio:"function"});let c=Ya<<BigInt(i.BYTES*8)-dt,u=g=>o.create(g),f=r.uvRatio===void 0?(g,m)=>{try{return{isValid:!0,value:o.sqrt(o.div(g,m))}}catch{return{isValid:!1,value:Qe}}}:r.uvRatio;if(!hb(o,s,s.Gx,s.Gy))throw new Error("bad curve params: generator point");function l(g,m,y=!1){let E=y?dt:Qe;return nn("coordinate "+g,m,E,c),m}function d(g){if(!(g instanceof x))throw new Error("EdwardsPoint expected")}class x{static BASE=new x(s.Gx,s.Gy,dt,u(s.Gx*s.Gy));static ZERO=new x(Qe,dt,dt,Qe);static Fp=o;static Fn=i;X;Y;Z;T;constructor(m,y,E,v){this.X=l("x",m),this.Y=l("y",y),this.Z=l("z",E,!0),this.T=l("t",v),Object.freeze(this)}static CURVE(){return s}static fromAffine(m){if(m instanceof x)throw new Error("extended point not allowed");let{x:y,y:E}=m||{};return l("x",y),l("y",E),new x(y,E,dt,u(y*E))}static fromBytes(m,y=!1){let E=o.BYTES,{a:v,d:C}=s;m=no(H(m,E,"point")),ne(y,"zip215");let B=no(m),U=m[E-1];B[E-1]=U&-129;let I=be(B),b=y?c:o.ORDER;nn("point.y",I,Qe,b);let D=u(I*I),k=u(D-dt),P=u(C*D-v),{isValid:p,value:S}=f(k,P);if(!p)throw new Error("bad point: invalid y coordinate");let _=(S&dt)===dt,A=(U&128)!==0;if(!y&&S===Qe&&A)throw new Error("bad point: x=0 and x_0=1");return A!==_&&(S=u(-S)),x.fromAffine({x:S,y:I})}static fromHex(m,y=!1){return x.fromBytes(rn(m),y)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(m=8,y=!0){return h.createCache(this,m),y||this.multiply(Ya),this}assertValidity(){let m=this,{a:y,d:E}=s;if(m.is0())throw new Error("bad point: ZERO");let{X:v,Y:C,Z:B,T:U}=m,I=u(v*v),b=u(C*C),D=u(B*B),k=u(D*D),P=u(I*y),p=u(D*u(P+b)),S=u(k+u(E*u(I*b)));if(p!==S)throw new Error("bad point: equation left != right (1)");let _=u(v*C),A=u(B*U);if(_!==A)throw new Error("bad point: equation left != right (2)")}equals(m){d(m);let{X:y,Y:E,Z:v}=this,{X:C,Y:B,Z:U}=m,I=u(y*U),b=u(C*v),D=u(E*U),k=u(B*v);return I===b&&D===k}is0(){return this.equals(x.ZERO)}negate(){return new x(u(-this.X),this.Y,this.Z,u(-this.T))}double(){let{a:m}=s,{X:y,Y:E,Z:v}=this,C=u(y*y),B=u(E*E),U=u(Ya*u(v*v)),I=u(m*C),b=y+E,D=u(u(b*b)-C-B),k=I+B,P=k-U,p=I-B,S=u(D*P),_=u(k*p),A=u(D*p),T=u(P*k);return new x(S,_,T,A)}add(m){d(m);let{a:y,d:E}=s,{X:v,Y:C,Z:B,T:U}=this,{X:I,Y:b,Z:D,T:k}=m,P=u(v*I),p=u(C*b),S=u(U*E*k),_=u(B*D),A=u((v+C)*(I+b)-P-p),T=_-S,L=_+S,N=u(p-y*P),F=u(A*T),V=u(L*N),K=u(A*N),q=u(T*L);return new x(F,V,q,K)}subtract(m){return d(m),this.add(m.negate())}multiply(m){if(!i.isValidNot0(m))throw new RangeError("invalid scalar: expected 1 <= sc < curve.n");let{p:y,f:E}=h.cached(this,m,v=>Ir(x,v));return Ir(x,[y,E])[0]}multiplyUnsafe(m){if(!i.isValid(m))throw new RangeError("invalid scalar: expected 0 <= sc < curve.n");return m===Qe?x.ZERO:this.is0()||m===dt?this:h.unsafe(this,m,y=>Ir(x,y))}isSmallOrder(){return this.clearCofactor().is0()}isTorsionFree(){return h.unsafe(this,s.n).is0()}toAffine(m){let y=this,E=m,{X:v,Y:C,Z:B}=y,U=y.is0();E==null&&(E=U?lb:o.inv(B));let I=u(v*E),b=u(C*E),D=o.mul(B,E);if(U)return{x:Qe,y:dt};if(D!==dt)throw new Error("invZ was invalid");return{x:I,y:b}}clearCofactor(){return a===dt?this:this.multiplyUnsafe(a)}toBytes(){let{x:m,y}=this.toAffine(),E=o.toBytes(y);return E[E.length-1]|=m&dt?128:0,E}toHex(){return en(this.toBytes())}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let h=new cn(x,i.BITS);return i.BITS>=8&&x.BASE.precompute(8),Object.freeze(x.prototype),Object.freeze(x),x}var Ii=class{static BASE;static ZERO;static Fp;static Fn;ep;constructor(t){this.ep=t}static fromBytes(t){Ma()}static fromHex(t){Ma()}get x(){return this.toAffine().x}get y(){return this.toAffine().y}clearCofactor(){return this}assertValidity(){this.ep.assertValidity()}toAffine(t){return this.ep.toAffine(t)}toHex(){return en(this.toBytes())}toString(){return this.toHex()}isTorsionFree(){return!0}isSmallOrder(){return!1}add(t){return this.assertSame(t),this.init(this.ep.add(t.ep))}subtract(t){return this.assertSame(t),this.init(this.ep.subtract(t.ep))}multiply(t){return this.init(this.ep.multiply(t))}multiplyUnsafe(t){return this.init(this.ep.multiplyUnsafe(t))}double(){return this.init(this.ep.double())}negate(){return this.init(this.ep.negate())}precompute(t,r){return this.ep.precompute(t,r),this}};function Mh(e,t,r={}){if(typeof t!="function")throw new Error('"hash" function param is required');let n=t,o=r;ie(o,{},{adjustScalarBytes:"function",randomBytes:"function",domain:"function",prehash:"function",zip215:"boolean",mapToCurve:"function"});let{prehash:i}=o,{BASE:s,Fp:a,Fn:c}=e,u=n.outputLen,f=2*a.BYTES;if(u!==void 0&&(oe(u,"hash.outputLen"),u!==f))throw new Error(`hash.outputLen must be ${f}, got ${u}`);let l=o.randomBytes===void 0?eo:o.randomBytes,d=o.adjustScalarBytes===void 0?p=>p:o.adjustScalarBytes,x=o.domain===void 0?(p,S,_)=>{if(ne(_,"phflag"),S.length||_)throw new Error("Contexts/pre-hash are not supported");return p}:o.domain;function h(p){return c.create(be(p))}function g(p){let S=I.secretKey;H(p,I.secretKey,"secretKey");let _=H(n(p),2*S,"hashedSecretKey"),A=d(_.slice(0,S)),T=_.slice(S,2*S),L=h(A);return{head:A,prefix:T,scalar:L}}function m(p){let{head:S,prefix:_,scalar:A}=g(p),T=s.multiply(A),L=T.toBytes();return{head:S,prefix:_,scalar:A,point:T,pointBytes:L}}function y(p){return m(p).pointBytes}function E(p=Uint8Array.of(),...S){let _=ut(...S);return h(n(x(_,H(p,void 0,"context"),!!i)))}function v(p,S,_={}){p=H(p,void 0,"message"),i&&(p=i(p));let{prefix:A,scalar:T,pointBytes:L}=m(S),N=E(_.context,A,p),F=s.multiply(N).toBytes(),V=E(_.context,F,L,p),K=c.create(N+V*T);if(!c.isValid(K))throw new Error("sign failed: invalid s");let q=ut(F,c.toBytes(K));return H(q,I.signature,"result")}let C={zip215:o.zip215};function B(p,S,_,A=C){let{context:T}=A,L=A.zip215===void 0?!!C.zip215:A.zip215,N=I.signature;p=H(p,N,"signature"),S=H(S,void 0,"message"),_=H(_,I.publicKey,"publicKey"),L!==void 0&&ne(L,"zip215"),i&&(S=i(S));let F=N/2,V=p.subarray(0,F),K=be(p.subarray(F,N)),q,G,z;try{q=e.fromBytes(_,L),G=e.fromBytes(V,L),z=s.multiplyUnsafe(K)}catch{return!1}if(!L&&q.isSmallOrder())return!1;let st=E(T,V,_,S);return G.add(q.multiplyUnsafe(st)).subtract(z).clearCofactor().is0()}let U=a.BYTES,I={secretKey:U,publicKey:U,signature:2*U,seed:U};function b(p){return p=p===void 0?l(I.seed):p,H(p,I.seed,"seed")}function D(p){return vr(p)&&p.length===I.secretKey}function k(p,S){try{return!!e.fromBytes(p,S===void 0?C.zip215:S)}catch{return!1}}let P={getExtendedPublicKey:m,randomSecretKey:b,isValidSecretKey:D,isValidPublicKey:k,toMontgomery(p){let{y:S}=e.fromBytes(p),_=I.publicKey,A=_===32;if(!A&&_!==57)throw new Error("only defined for 25519 and 448");let T=A?a.div(dt+S,dt-S):a.div(S-dt,S+dt);return a.toBytes(T)},toMontgomerySecret(p){let S=I.secretKey;H(p,S);let _=n(p.subarray(0,S));return d(_).subarray(0,S)}};return Object.freeze(I),Object.freeze(P),Object.freeze({keygen:Ci(b,y),getPublicKey:y,sign:v,verify:B,utils:P,Point:e,lengths:I})}function ao(e,t){if(oe(e),oe(t),t<0||t>4)throw new Error("invalid I2OSP length: "+t);if(e<0||e>2**(8*t)-1)throw new Error("invalid I2OSP input: "+e);let r=Array.from({length:t}).fill(0);for(let n=t-1;n>=0;n--)r[n]=e&255,e>>>=8;return new Uint8Array(r)}function db(e,t){let r=new Uint8Array(e.length);for(let n=0;n<e.length;n++)r[n]=e[n]^t[n];return r}function pb(e){if(!vr(e)&&typeof e!="string")throw new Error("DST must be Uint8Array or ascii string");let t=typeof e=="string"?vi(e):e;if(t.length===0)throw new Error("DST must be non-empty");return t}function Za(e,t,r,n){H(e),oe(r),t=pb(t),t.length>255&&(t=n(ut(vi("H2C-OVERSIZE-DST-"),t)));let{outputLen:o,blockLen:i}=n,s=Math.ceil(r/o);if(r>65535||s>255)throw new Error("expand_message_xmd: invalid lenInBytes");let a=ut(t,ao(t.length,1)),c=new Uint8Array(i),u=ao(r,2),f=new Array(s),l=n(ut(c,e,u,ao(0,1),a));f[0]=n(ut(l,ao(1,1),a));for(let x=1;x<s;x++){let h=[db(l,f[x-1]),ao(x+1,1),a];f[x]=n(ut(...h))}return ut(...f).slice(0,r)}var $h="HashToScalar-";var mb=BigInt(0),Ne=BigInt(1),Kh=BigInt(2);var gb=BigInt(5),yb=BigInt(8),un=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"),Qa={p:un,n:BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),h:yb,a:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),d:BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),Gx:BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),Gy:BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")};function bb(e){let t=BigInt(10),r=BigInt(20),n=BigInt(40),o=BigInt(80),i=un,a=e*e%i*e%i,c=Y(a,Kh,i)*a%i,u=Y(c,Ne,i)*e%i,f=Y(u,gb,i)*u%i,l=Y(f,t,i)*f%i,d=Y(l,r,i)*l%i,x=Y(d,n,i)*d%i,h=Y(x,o,i)*x%i,g=Y(h,o,i)*x%i,m=Y(g,t,i)*f%i;return{pow_p_5_8:Y(m,Kh,i)*e%i,b2:a}}function xb(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}var Xa=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");function tc(e,t){let r=un,n=ot(t*t*t,r),o=ot(n*n*t,r),i=bb(e*o).pow_p_5_8,s=ot(e*n*i,r),a=ot(t*s*s,r),c=s,u=ot(s*Xa,r),f=a===e,l=a===ot(-e,r),d=a===ot(-e*Xa,r);return f&&(s=c),(l||d)&&(s=u),Re(s,r)&&(s=ot(-s,r)),{isValid:f||l,value:s}}var er=Vh(Qa,{uvRatio:tc}),tr=er.Fp,Hh=er.Fn;function wb(e){return Mh(er,bi,Object.assign({adjustScalarBytes:xb,zip215:!0},e))}var jh=wb({});var Wa=Xa,Eb=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),Sb=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),vb=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),Ab=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952"),zh=e=>tc(Ne,e),Tb=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),Ja=e=>tr.create(be(e)&Tb);function qh(e){let{d:t}=Qa,r=un,n=y=>tr.create(y),o=n(Wa*e*e),i=n((o+Ne)*vb),s=BigInt(-1),a=n((s-t*o)*n(o+t)),{isValid:c,value:u}=tc(i,a),f=n(u*e);Re(f,r)||(f=n(-f)),c||(u=f),c||(s=o);let l=n(s*(o-Ne)*Ab-a),d=u*u,x=n((u+u)*a),h=n(l*Eb),g=n(Ne-d),m=n(Ne+d);return new er(n(x*m),n(g*h),n(h*m),n(x*g))}var rr=class e extends Ii{static BASE=new e(er.BASE);static ZERO=new e(er.ZERO);static Fp=tr;static Fn=Hh;constructor(t){super(t)}static fromAffine(t){return new e(er.fromAffine(t))}assertSame(t){if(!(t instanceof e))throw new Error("RistrettoPoint expected")}init(t){return new e(t)}static fromBytes(t){Vt(t,32);let{a:r,d:n}=Qa,o=un,i=C=>tr.create(C),s=Ja(t);if(!wh(tr.toBytes(s),t)||Re(s,o))throw new Error("invalid ristretto255 encoding 1");let a=i(s*s),c=i(Ne+r*a),u=i(Ne-r*a),f=i(c*c),l=i(u*u),d=i(r*n*f-l),{isValid:x,value:h}=zh(i(d*l)),g=i(h*u),m=i(h*g*d),y=i((s+s)*g);Re(y,o)&&(y=i(-y));let E=i(c*m),v=i(y*E);if(!x||Re(v,o)||E===mb)throw new Error("invalid ristretto255 encoding 2");return new e(new er(y,E,Ne,v))}static fromHex(t){return e.fromBytes(Wn(t))}toBytes(){let{X:t,Y:r,Z:n,T:o}=this.ep,i=un,s=m=>tr.create(m),a=s(s(n+r)*s(n-r)),c=s(t*r),u=s(c*c),{value:f}=zh(s(a*u)),l=s(f*a),d=s(f*c),x=s(l*d*o),h;if(Re(o*x,i)){let m=s(r*Wa),y=s(t*Wa);t=m,r=y,h=s(l*Sb)}else h=d;Re(t*x,i)&&(r=s(-r));let g=s((n-r)*h);return Re(g,i)&&(g=s(-g)),tr.toBytes(g)}equals(t){this.assertSame(t);let{X:r,Y:n}=this.ep,{X:o,Y:i}=t.ep,s=u=>tr.create(u),a=s(r*i)===s(n*o),c=s(n*i)===s(r*o);return a||c}is0(){return this.equals(e.ZERO)}};Object.freeze(rr.BASE);Object.freeze(rr.ZERO);Object.freeze(rr.prototype);Object.freeze(rr);var Cb=Object.freeze({Point:rr,hashToCurve(e,t){let r=t?.DST===void 0?"ristretto255_XMD:SHA-512_R255MAP_RO_":t.DST,n=Za(e,r,64,bi);return Cb.deriveToCurve(n)},hashToScalar(e,t={DST:$h}){let r=Za(e,t.DST,64,bi);return Hh.create(be(r))},deriveToCurve(e){Vt(e,64);let t=Ja(e.subarray(0,32)),r=qh(t),n=Ja(e.subarray(32,64)),o=qh(n);return new rr(r.add(o))}});var co=class extends Error{constructor(t="An error occurred while verifying a message"){super(t),this.name="VerificationError"}},Bi=class extends Error{constructor(t="Missing Web Crypto API"){super(t),this.name="WebCryptoMissingError"}};var Gh={get(e=globalThis){let t=e.crypto;if(t?.subtle==null)throw new Bi("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 Zt=Gh;var Di=32;var ec,Ib=(async()=>{try{return await Zt.get().subtle.generateKey({name:"Ed25519"},!0,["sign","verify"]),!0}catch{return!1}})();async function Bb(e,t,r){if(e.buffer instanceof ArrayBuffer){let n=await Zt.get().subtle.importKey("raw",e.buffer,{name:"Ed25519"},!1,["verify"]);return await Zt.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 Db(e,t,r){return jh.verify(t,r instanceof Uint8Array?r:r.subarray(),e)}async function Yh(e,t,r){return ec==null&&(ec=await Ib),ec?Bb(e,t,r):Db(e,t,r)}function _i(e){return e==null?!1:typeof e.then=="function"&&typeof e.catch=="function"&&typeof e.finally=="function"}var Li=class{type="Ed25519";raw;constructor(t){this.raw=rc(t,Di)}toMultihash(){return wr.digest(Jr(this))}toCID(){return Yt.createV1(114,this.toMultihash())}toString(){return ht.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:ee(this.raw,t.raw)}verify(t,r,n){n?.signal?.throwIfAborted();let o=Yh(this.raw,r,t);return _i(o)?o.then(i=>(n?.signal?.throwIfAborted(),i)):o}};function nc(e){return e=rc(e,Di),new Li(e)}function rc(e,t){if(e=Uint8Array.from(e??[]),e.length!==t)throw new W(`Key must be a Uint8Array of length ${t}, got ${e.length}`);return e}var Lb=Math.pow(2,7),Ub=Math.pow(2,14),Rb=Math.pow(2,21),Xh=Math.pow(2,28),Wh=Math.pow(2,35),Jh=Math.pow(2,42),Qh=Math.pow(2,49),Ct=128,nr=127;function uo(e){if(e<Lb)return 1;if(e<Ub)return 2;if(e<Rb)return 3;if(e<Xh)return 4;if(e<Wh)return 5;if(e<Jh)return 6;if(e<Qh)return 7;if(Number.MAX_SAFE_INTEGER!=null&&e>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function td(e,t,r=0){switch(uo(e)){case 8:t[r++]=e&255|Ct,e/=128;case 7:t[r++]=e&255|Ct,e/=128;case 6:t[r++]=e&255|Ct,e/=128;case 5:t[r++]=e&255|Ct,e/=128;case 4:t[r++]=e&255|Ct,e>>>=7;case 3:t[r++]=e&255|Ct,e>>>=7;case 2:t[r++]=e&255|Ct,e>>>=7;case 1:{t[r++]=e&255,e>>>=7;break}default:throw new Error("unreachable")}return t}function ed(e,t){let r=e[t],n=0;if(n+=r&nr,r<Ct||(r=e[t+1],n+=(r&nr)<<7,r<Ct)||(r=e[t+2],n+=(r&nr)<<14,r<Ct)||(r=e[t+3],n+=(r&nr)<<21,r<Ct)||(r=e[t+4],n+=(r&nr)*Xh,r<Ct)||(r=e[t+5],n+=(r&nr)*Wh,r<Ct)||(r=e[t+6],n+=(r&nr)*Jh,r<Ct)||(r=e[t+7],n+=(r&nr)*Qh,r<Ct))return n;throw new RangeError("Could not decode varint")}var oc=new Float32Array([-0]),or=new Uint8Array(oc.buffer);function rd(e,t,r){oc[0]=e,t[r]=or[0],t[r+1]=or[1],t[r+2]=or[2],t[r+3]=or[3]}function nd(e,t){return or[0]=e[t],or[1]=e[t+1],or[2]=e[t+2],or[3]=e[t+3],oc[0]}var ic=new Float64Array([-0]),Et=new Uint8Array(ic.buffer);function od(e,t,r){ic[0]=e,t[r]=Et[0],t[r+1]=Et[1],t[r+2]=Et[2],t[r+3]=Et[3],t[r+4]=Et[4],t[r+5]=Et[5],t[r+6]=Et[6],t[r+7]=Et[7]}function id(e,t){return Et[0]=e[t],Et[1]=e[t+1],Et[2]=e[t+2],Et[3]=e[t+3],Et[4]=e[t+4],Et[5]=e[t+5],Et[6]=e[t+6],Et[7]=e[t+7],ic[0]}var Nb=BigInt(Number.MAX_SAFE_INTEGER),Fb=BigInt(Number.MIN_SAFE_INTEGER),Mt=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 Br;if(t<Nb&&t>Fb)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>sd&&(o=0n,++n>sd&&(n=0n))),new e(Number(o),Number(n))}static fromNumber(t){if(t===0)return Br;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):Br}},Br=new Mt(0,0);Br.toBigInt=function(){return 0n};Br.zzEncode=Br.zzDecode=function(){return this};Br.length=function(){return 1};var sd=4294967296n;function ad(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 cd(e,t,r){if(r-t<1)return"";let o,i=[],s=0,a;for(;t<r;)a=e[t++],a<128?i[s++]=a:a>191&&a<224?i[s++]=(a&31)<<6|e[t++]&63:a>239&&a<365?(a=((a&7)<<18|(e[t++]&63)<<12|(e[t++]&63)<<6|e[t++]&63)-65536,i[s++]=55296+(a>>10),i[s++]=56320+(a&1023)):i[s++]=(a&15)<<12|(e[t++]&63)<<6|e[t++]&63,s>8191&&((o??(o=[])).push(String.fromCharCode.apply(String,i)),s=0);return o!=null?(s>0&&o.push(String.fromCharCode.apply(String,i.slice(0,s))),o.join("")):String.fromCharCode.apply(String,i.slice(0,s))}function sc(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 se(e,t){return RangeError(`index out of range: ${e.pos} + ${t??1} > ${e.len}`)}function Ui(e,t){return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0}var ac=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,se(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 se(this,4);return Ui(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw se(this,4);return Ui(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw se(this,4);let t=nd(this.buf,this.pos);return this.pos+=4,t}double(){if(this.pos+8>this.len)throw se(this,4);let t=id(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 se(this,t);return this.pos+=t,r===n?new Uint8Array(0):this.buf.subarray(r,n)}string(){let t=this.bytes();return cd(t,0,t.length)}skip(t){if(typeof t=="number"){if(this.pos+t>this.len)throw se(this,t);this.pos+=t}else do if(this.pos>=this.len)throw se(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 Mt(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 se(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 se(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 se(this,8);let t=Ui(this.buf,this.pos+=4),r=Ui(this.buf,this.pos+=4);return new Mt(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=ed(this.buf,this.pos);return this.pos+=uo(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 fo(e){return new ac(e instanceof Uint8Array?e:e.subarray())}function Ri(e,t,r){let n=fo(e);return t.decode(n,void 0,r)}function cc(e){let t=e??8192,r=t>>>1,n,o=t;return function(s){if(s<1||s>r)return Ot(s);o+s>t&&(n=Ot(t),o=0);let a=n.subarray(o,o+=s);return(o&7)!==0&&(o=(o|7)+1),a}}var Dr=class{fn;len;next;val;constructor(t,r,n){this.fn=t,this.len=r,this.next=void 0,this.val=n}};function uc(){}var lc=class{head;tail;len;next;constructor(t){this.head=t.head,this.tail=t.tail,this.len=t.len,this.next=t.states}},Pb=cc();function Ob(e){return globalThis.Buffer!=null?Ot(e):Pb(e)}var ho=class{len;head;tail;states;constructor(){this.len=0,this.head=new Dr(uc,0,0),this.tail=this.head,this.states=null}_push(t,r,n){return this.tail=this.tail.next=new Dr(t,r,n),this.len+=r,this}uint32(t){return this.len+=(this.tail=this.tail.next=new hc((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(Ni,10,Mt.fromNumber(t)):this.uint32(t)}sint32(t){return this.uint32((t<<1^t>>31)>>>0)}uint64(t){let r=Mt.fromBigInt(t);return this._push(Ni,r.length(),r)}uint64Number(t){return this._push(td,uo(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=Mt.fromBigInt(t).zzEncode();return this._push(Ni,r.length(),r)}sint64Number(t){let r=Mt.fromNumber(t).zzEncode();return this._push(Ni,r.length(),r)}sint64String(t){return this.sint64(BigInt(t))}bool(t){return this._push(fc,1,t?1:0)}fixed32(t){return this._push(lo,4,t>>>0)}sfixed32(t){return this.fixed32(t)}fixed64(t){let r=Mt.fromBigInt(t);return this._push(lo,4,r.lo)._push(lo,4,r.hi)}fixed64Number(t){let r=Mt.fromNumber(t);return this._push(lo,4,r.lo)._push(lo,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(rd,4,t)}double(t){return this._push(od,8,t)}bytes(t){let r=t.length>>>0;return r===0?this._push(fc,1,0):this.uint32(r)._push(Vb,r,t)}string(t){let r=ad(t);return r!==0?this.uint32(r)._push(sc,r,t):this._push(fc,1,0)}fork(){return this.states=new lc(this),this.head=this.tail=new Dr(uc,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 Dr(uc,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=Ob(this.len),n=0;for(;t!=null;)t.fn(t.val,r,n),n+=t.len,t=t.next;return r}};function fc(e,t,r){t[r]=e&255}function kb(e,t,r){for(;e>127;)t[r++]=e&127|128,e>>>=7;t[r]=e}var hc=class extends Dr{next;constructor(t,r){super(kb,t,r),this.next=void 0}};function Ni(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 lo(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 Vb(e,t,r){t.set(e,r)}globalThis.Buffer!=null&&(ho.prototype.bytes=function(e){let t=e.length>>>0;return this.uint32(t),t>0&&this._push(Mb,t,e),this},ho.prototype.string=function(e){let t=globalThis.Buffer.byteLength(e);return this.uint32(t),t>0&&this._push($b,t,e),this});function Mb(e,t,r){t.set(e,r)}function $b(e,t,r){e.length<40?sc(e,t,r):t.utf8Write!=null?t.utf8Write(e,r):t.set(at(e),r)}function dc(){return new ho}function Fi(e,t){let r=dc();return t.encode(e,r,{lengthDelimited:!1}),r.finish()}function*Pi(e,t,r){let n=fo(e);yield*t.stream(n,void 0,"$",r)}var Oi={VARINT:0,BIT64:1,LENGTH_DELIMITED:2,START_GROUP:3,END_GROUP:4,BIT32:5};function ki(e,t,r,n,o){return{name:e,type:t,encode:r,decode:n,stream:o}}function pc(e){function t(i){if(e[i.toString()]==null)throw new Error("Invalid enum value");return e[i]}let r=function(s,a){let c=t(s);a.int32(c)},n=function(s){let a=s.int32();return t(a)},o=function*(s){let a=s.int32();yield t(a)};return ki("enum",Oi.VARINT,r,n,o)}function Vi(e,t,r){return ki("message",Oi.LENGTH_DELIMITED,e,t,r)}var Z;(function(e){e.RSA="RSA",e.Ed25519="Ed25519",e.secp256k1="secp256k1",e.ECDSA="ECDSA"})(Z||(Z={}));var mc;(function(e){e[e.RSA=0]="RSA",e[e.Ed25519=1]="Ed25519",e[e.secp256k1=2]="secp256k1",e[e.ECDSA=3]="ECDSA"})(mc||(mc={}));(function(e){e.codec=()=>pc(mc)})(Z||(Z={}));var xe;(function(e){let t;e.codec=()=>(t==null&&(t=Vi((i,s,a={})=>{a.lengthDelimited!==!1&&s.fork(),i.Type!=null&&(s.uint32(8),Z.codec().encode(i.Type,s)),i.Data!=null&&(s.uint32(18),s.bytes(i.Data)),a.lengthDelimited!==!1&&s.ldelim()},(i,s,a={})=>{let c={},u=s==null?i.len:i.pos+s;for(;i.pos<u;){let f=i.uint32();switch(f>>>3){case 1:{c.Type=Z.codec().decode(i);break}case 2:{c.Data=i.bytes();break}default:{i.skipType(f&7);break}}}return c},function*(i,s,a,c={}){let u=s==null?i.len:i.pos+s;for(;i.pos<u;){let f=i.uint32();switch(f>>>3){case 1:{yield{field:`${a}.Type`,value:Z.codec().decode(i)};break}case 2:{yield{field:`${a}.Data`,value:i.bytes()};break}default:{i.skipType(f&7);break}}}})),t);function r(i){return Fi(i,e.codec())}e.encode=r;function n(i,s){return Ri(i,e.codec(),s)}e.decode=n;function o(i,s){return Pi(i,e.codec(),s)}e.stream=o})(xe||(xe={}));var gc;(function(e){let t;e.codec=()=>(t==null&&(t=Vi((i,s,a={})=>{a.lengthDelimited!==!1&&s.fork(),i.Type!=null&&(s.uint32(8),Z.codec().encode(i.Type,s)),i.Data!=null&&(s.uint32(18),s.bytes(i.Data)),a.lengthDelimited!==!1&&s.ldelim()},(i,s,a={})=>{let c={},u=s==null?i.len:i.pos+s;for(;i.pos<u;){let f=i.uint32();switch(f>>>3){case 1:{c.Type=Z.codec().decode(i);break}case 2:{c.Data=i.bytes();break}default:{i.skipType(f&7);break}}}return c},function*(i,s,a,c={}){let u=s==null?i.len:i.pos+s;for(;i.pos<u;){let f=i.uint32();switch(f>>>3){case 1:{yield{field:`${a}.Type`,value:Z.codec().decode(i)};break}case 2:{yield{field:`${a}.Data`,value:i.bytes()};break}default:{i.skipType(f&7);break}}}})),t);function r(i){return Fi(i,e.codec())}e.encode=r;function n(i,s){return Ri(i,e.codec(),s)}e.decode=n;function o(i,s){return Pi(i,e.codec(),s)}e.stream=o})(gc||(gc={}));var mo={};$(mo,{MAX_RSA_KEY_SIZE:()=>yc,generateRSAKeyPair:()=>pd,jwkToJWKKeyPair:()=>md,jwkToPkcs1:()=>Hb,jwkToPkix:()=>Ec,jwkToRSAPrivateKey:()=>Tc,pkcs1MessageToJwk:()=>xc,pkcs1MessageToRSAPrivateKey:()=>Sc,pkcs1ToJwk:()=>qb,pkcs1ToRSAPrivateKey:()=>dd,pkixMessageToJwk:()=>wc,pkixMessageToRSAPublicKey:()=>Ac,pkixToJwk:()=>jb,pkixToRSAPublicKey:()=>vc});var fn=class{type="RSA";jwk;_raw;_multihash;constructor(t,r){this.jwk=t,this._multihash=r}get raw(){return this._raw==null&&(this._raw=mo.jwkToPkix(this.jwk)),this._raw}toMultihash(){return this._multihash}toCID(){return Yt.createV1(114,this._multihash)}toString(){return ht.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:ee(this.raw,t.raw)}verify(t,r,n){return hd(this.jwk,r,t,n)}},po=class{type="RSA";jwk;_raw;publicKey;constructor(t,r){this.jwk=t,this.publicKey=r}get raw(){return this._raw==null&&(this._raw=mo.jwkToPkcs1(this.jwk)),this._raw}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:ee(this.raw,t.raw)}sign(t,r){return ld(this.jwk,t,r)}};var yc=8192,bc=18,Kb=1062,zb=Uint8Array.from([48,13,6,9,42,134,72,134,247,13,1,1,1,5,0]);function qb(e){let t=De(e);return xc(t)}function xc(e){return{n:ct(e[1],"base64url"),e:ct(e[2],"base64url"),d:ct(e[3],"base64url"),p:ct(e[4],"base64url"),q:ct(e[5],"base64url"),dp:ct(e[6],"base64url"),dq:ct(e[7],"base64url"),qi:ct(e[8],"base64url"),kty:"RSA"}}function Hb(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 W("JWK was missing components");return Ye([Rt(Uint8Array.from([0])),Rt(at(e.n,"base64url")),Rt(at(e.e,"base64url")),Rt(at(e.d,"base64url")),Rt(at(e.p,"base64url")),Rt(at(e.q,"base64url")),Rt(at(e.dp,"base64url")),Rt(at(e.dq,"base64url")),Rt(at(e.qi,"base64url"))]).subarray()}function jb(e){let t=De(e,{offset:0});return wc(t)}function wc(e){let t=De(e[1],{offset:0});return{kty:"RSA",n:ct(t[0],"base64url"),e:ct(t[1],"base64url")}}function Ec(e){if(e.n==null||e.e==null)throw new W("JWK was missing components");return Ye([zb,hi(Ye([Rt(at(e.n,"base64url")),Rt(at(e.e,"base64url"))]))]).subarray()}function dd(e){let t=De(e);return Sc(t)}function Sc(e){let t=xc(e);return Tc(t)}function vc(e,t){if(e.byteLength>=Kb)throw new qr("Key size is too large");let r=De(e,{offset:0});return Ac(r,e,t)}function Ac(e,t,r){let n=wc(e);if(r==null){let o=tn(xe.encode({Type:Z.RSA,Data:t}));r=ge(bc,o)}return new fn(n,r)}function Tc(e){if(yd(e)>yc)throw new W("Key size is too large");let t=md(e),r=tn(xe.encode({Type:Z.RSA,Data:Ec(t.publicKey)})),n=ge(bc,r);return new po(t.privateKey,new fn(t.publicKey,n))}async function pd(e){if(e>yc)throw new W("Key size is too large");let t=await gd(e),r=tn(xe.encode({Type:Z.RSA,Data:Ec(t.publicKey)})),n=ge(bc,r);return new po(t.privateKey,new fn(t.publicKey,n))}function md(e){if(e==null)throw new W("Missing key parameter");return{privateKey:e,publicKey:{kty:e.kty,n:e.n,e:e.e}}}async function gd(e,t){let r=await Zt.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 Gb(r,t);return{privateKey:n[0],publicKey:n[1]}}async function ld(e,t,r){let n=await Zt.get().subtle.importKey("jwk",e,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["sign"]);r?.signal?.throwIfAborted();let o=await Zt.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 hd(e,t,r,n){let o=await Zt.get().subtle.importKey("jwk",e,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["verify"]);n?.signal?.throwIfAborted();let i=await Zt.get().subtle.verify({name:"RSASSA-PKCS1-v1_5"},o,t,r instanceof Uint8Array?r:r.subarray());return n?.signal?.throwIfAborted(),i}async function Gb(e,t){if(e.privateKey==null||e.publicKey==null)throw new W("Private and public key are required");let r=await Promise.all([Zt.get().subtle.exportKey("jwk",e.privateKey),Zt.get().subtle.exportKey("jwk",e.publicKey)]);return t?.signal?.throwIfAborted(),r}function yd(e){if(e.kty!=="RSA")throw new W("invalid key type");if(e.n==null)throw new W("invalid key modulus");return at(e.n,"base64url").length*8}var Mi=class{oHash;iHash;blockLen;outputLen;canXOF=!1;finished=!1;destroyed=!1;constructor(t,r){if(di(t),Vt(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),Le(o)}update(t){return Qr(this),this.iHash.update(t),this}digestInto(t){Qr(this),pi(t,this),this.finished=!0;let r=t.subarray(0,this.outputLen);this.iHash.digestInto(r),this.oHash.update(r),this.oHash.digestInto(r),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:a}=this;return t=t,t.finished=o,t.destroyed=i,t.blockLen=s,t.outputLen=a,t.oHash=r._cloneInto(t.oHash),t.iHash=n._cloneInto(t.iHash),t}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},bd=(()=>{let e=((t,r,n)=>new Mi(t,r).update(n).digest());return e.create=(t,r)=>new Mi(t,r),e})();var xd=(e,t)=>(e+(e>=0?t:-t)/wd)/t;function Yb(e,t,r){nn("scalar",e,we,r);let[[n,o],[i,s]]=t,a=xd(s*e,r),c=xd(-o*e,r),u=e-a*n-c*i,f=-a*o-c*s,l=u<we,d=f<we;l&&(u=-u),d&&(f=-f);let x=oo(Math.ceil(on(r)/2))+ir;if(u<we||u>=x||f<we||f>=x)throw new Error("splitScalar (endomorphism): failed for k");return{k1neg:l,k1:u,k2neg:d,k2:f}}function Ic(e){if(!["compact","recovered","der"].includes(e))throw new Error('Signature format must be "compact", "recovered", or "der"');return e}function Cc(e,t){ie(e);let r={};for(let n of Object.keys(t))r[n]=e[n]===void 0?t[n]:e[n];return ne(r.lowS,"lowS"),ne(r.prehash,"prehash"),r.format!==void 0&&Ic(r.format),r}var Bc=class extends Error{constructor(t=""){super(t)}},ae={Err:Bc,_tlv:{encode:(e,t)=>{let{Err:r}=ae;if(oe(e,"tag"),e<0||e>255)throw new r("tlv.encode: wrong tag");if(typeof t!="string")throw new TypeError('"data" expected string, got type='+typeof t);if(t.length&1)throw new r("tlv.encode: unpadded data");let n=t.length/2,o=ro(n);if(o.length/2&128)throw new r("tlv.encode: long form length too big");let i=n>127?ro(o.length/2|128):"";return ro(e)+i+o+t},decode(e,t){let{Err:r}=ae;t=H(t,void 0,"DER data");let n=0;if(e<0||e>255)throw new r("tlv.encode: wrong tag");if(t.length<2||t[n++]!==e)throw new r("tlv.decode: wrong tlv");let o=t[n++],i=!!(o&128),s=0;if(!i)s=o;else{let c=o&127;if(!c)throw new r("tlv.decode(long): indefinite length not supported");if(c>4)throw new r("tlv.decode(long): byte length is too big");let u=t.subarray(n,n+c);if(u.length!==c)throw new r("tlv.decode: length bytes not complete");if(u[0]===0)throw new r("tlv.decode(long): zero leftmost byte");for(let f of u)s=s<<8|f;if(n+=c,s<128)throw new r("tlv.decode(long): not minimal encoding")}let a=t.subarray(n,n+s);if(a.length!==s)throw new r("tlv.decode: wrong value length");return{v:a,l:t.subarray(n+s)}}},_int:{encode(e){let{Err:t}=ae;if(Ei(e),e<we)throw new t("integer: negative integers are not allowed");let r=ro(e);if(Number.parseInt(r[0],16)&8&&(r="00"+r),r.length&1)throw new t("unexpected DER parsing assertion: unpadded hex");return r},decode(e){let{Err:t}=ae;if(e.length<1)throw new t("invalid signature integer: empty");if(e[0]&128)throw new t("invalid signature integer: negative");if(e.length>1&&e[0]===0&&!(e[1]&128))throw new t("invalid signature integer: unnecessary leading zero");return Ar(e)}},toSig(e){let{Err:t,_int:r,_tlv:n}=ae,o=H(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:a,l:c}=n.decode(2,i),{v:u,l:f}=n.decode(2,c);if(f.length)throw new t("invalid signature: left bytes after parsing");return{r:r.decode(a),s:r.decode(u)}},hexFromSig(e){let{_tlv:t,_int:r}=ae,n=t.encode(2,r.encode(e.r)),o=t.encode(2,r.encode(e.s)),i=n+o;return t.encode(48,i)}};Object.freeze(ae._tlv);Object.freeze(ae._int);Object.freeze(ae);var we=BigInt(0),ir=BigInt(1),wd=BigInt(2),$i=BigInt(3),Zb=BigInt(4);function Ed(e,t={}){let r=Ti("weierstrass",e,t),n=r.Fp,o=r.Fn,i=r.CURVE,{h:s,n:a}=i;ie(t,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object"});let{endo:c,allowInfinityPoint:u}=t;if(c&&(!n.is0(i.a)||typeof c.beta!="bigint"||!Array.isArray(c.basises)))throw new Error('invalid endo: expected "beta": bigint and "basises": array');let f=vd(n,o);function l(){if(!n.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}function d(P,p,S){if(u&&p.is0())return Uint8Array.of(0);let{x:_,y:A}=p.toAffine(),T=n.toBytes(_);if(ne(S,"isCompressed"),S){l();let L=!n.isOdd(A);return ut(Sd(L),T)}else return ut(Uint8Array.of(4),T,n.toBytes(A))}function x(P){H(P,void 0,"Point");let{publicKey:p,publicKeyUncompressed:S}=f,_=P.length,A=P[0],T=P.subarray(1);if(u&&_===1&&A===0)return{x:n.ZERO,y:n.ZERO};if(_===p&&(A===2||A===3)){let L=n.fromBytes(T);if(!n.isValid(L))throw new Error("bad point: is not on curve, wrong x");let N=m(L),F;try{F=n.sqrt(N)}catch(q){let G=q instanceof Error?": "+q.message:"";throw new Error("bad point: is not on curve, sqrt error"+G)}l();let V=n.isOdd(F);return(A&1)===1!==V&&(F=n.neg(F)),{x:L,y:F}}else if(_===S&&A===4){let L=n.BYTES,N=n.fromBytes(T.subarray(0,L)),F=n.fromBytes(T.subarray(L,L*2));if(!y(N,F))throw new Error("bad point: is not on curve");return{x:N,y:F}}else throw new Error(`bad point: got length ${_}, expected compressed=${p} or uncompressed=${S}`)}let h=t.toBytes===void 0?d:t.toBytes,g=t.fromBytes===void 0?x:t.fromBytes;function m(P){let p=n.sqr(P),S=n.mul(p,P);return n.add(n.add(S,n.mul(P,i.a)),i.b)}function y(P,p){let S=n.sqr(p),_=m(P);return n.eql(S,_)}if(!y(i.Gx,i.Gy))throw new Error("bad curve params: generator point");let E=n.mul(n.pow(i.a,$i),Zb),v=n.mul(n.sqr(i.b),BigInt(27));if(n.is0(n.add(E,v)))throw new Error("bad curve params: a or b");function C(P,p,S=!1){if(!n.isValid(p)||S&&n.is0(p))throw new Error(`bad point coordinate ${P}`);return p}function B(P){if(!(P instanceof b))throw new Error("Weierstrass Point expected")}function U(P){if(!c||!c.basises)throw new Error("no endo");return Yb(P,c.basises,o.ORDER)}function I(P,p,S,_,A){return S=new b(n.mul(S.X,P),S.Y,S.Z),p=so(_,p),S=so(A,S),p.add(S)}class b{static BASE=new b(i.Gx,i.Gy,n.ONE);static ZERO=new b(n.ZERO,n.ONE,n.ZERO);static Fp=n;static Fn=o;X;Y;Z;constructor(p,S,_){this.X=C("x",p),this.Y=C("y",S,!0),this.Z=C("z",_),Object.freeze(this)}static CURVE(){return i}static fromAffine(p){let{x:S,y:_}=p||{};if(!p||!n.isValid(S)||!n.isValid(_))throw new Error("invalid affine point");if(p instanceof b)throw new Error("projective point not allowed");return n.is0(S)&&n.is0(_)?b.ZERO:new b(S,_,n.ONE)}static fromBytes(p){let S=b.fromAffine(g(H(p,void 0,"point")));return S.assertValidity(),S}static fromHex(p){return b.fromBytes(rn(p))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(p=8,S=!0){return k.createCache(this,p),S||this.multiply($i),this}assertValidity(){let p=this;if(p.is0()){if(t.allowInfinityPoint&&n.is0(p.X)&&n.eql(p.Y,n.ONE)&&n.is0(p.Z))return;throw new Error("bad point: ZERO")}let{x:S,y:_}=p.toAffine();if(!n.isValid(S)||!n.isValid(_))throw new Error("bad point: x or y not field elements");if(!y(S,_))throw new Error("bad point: equation left != right");if(!p.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){let{y:p}=this.toAffine();if(!n.isOdd)throw new Error("Field doesn't support isOdd");return!n.isOdd(p)}equals(p){B(p);let{X:S,Y:_,Z:A}=this,{X:T,Y:L,Z:N}=p,F=n.eql(n.mul(S,N),n.mul(T,A)),V=n.eql(n.mul(_,N),n.mul(L,A));return F&&V}negate(){return new b(this.X,n.neg(this.Y),this.Z)}double(){let{a:p,b:S}=i,_=n.mul(S,$i),{X:A,Y:T,Z:L}=this,N=n.ZERO,F=n.ZERO,V=n.ZERO,K=n.mul(A,A),q=n.mul(T,T),G=n.mul(L,L),z=n.mul(A,T);return z=n.add(z,z),V=n.mul(A,L),V=n.add(V,V),N=n.mul(p,V),F=n.mul(_,G),F=n.add(N,F),N=n.sub(q,F),F=n.add(q,F),F=n.mul(N,F),N=n.mul(z,N),V=n.mul(_,V),G=n.mul(p,G),z=n.sub(K,G),z=n.mul(p,z),z=n.add(z,V),V=n.add(K,K),K=n.add(V,K),K=n.add(K,G),K=n.mul(K,z),F=n.add(F,K),G=n.mul(T,L),G=n.add(G,G),K=n.mul(G,z),N=n.sub(N,K),V=n.mul(G,q),V=n.add(V,V),V=n.add(V,V),new b(N,F,V)}add(p){B(p);let{X:S,Y:_,Z:A}=this,{X:T,Y:L,Z:N}=p,F=n.ZERO,V=n.ZERO,K=n.ZERO,q=i.a,G=n.mul(i.b,$i),z=n.mul(S,T),st=n.mul(_,L),ft=n.mul(A,N),lt=n.add(S,_),nt=n.add(T,L);lt=n.mul(lt,nt),nt=n.add(z,st),lt=n.sub(lt,nt),nt=n.add(S,A);let Lt=n.add(T,N);return nt=n.mul(nt,Lt),Lt=n.add(z,ft),nt=n.sub(nt,Lt),Lt=n.add(_,A),F=n.add(L,N),Lt=n.mul(Lt,F),F=n.add(st,ft),Lt=n.sub(Lt,F),K=n.mul(q,nt),F=n.mul(G,ft),K=n.add(F,K),F=n.sub(st,K),K=n.add(st,K),V=n.mul(F,K),st=n.add(z,z),st=n.add(st,z),ft=n.mul(q,ft),nt=n.mul(G,nt),st=n.add(st,ft),ft=n.sub(z,ft),ft=n.mul(q,ft),nt=n.add(nt,ft),z=n.mul(st,nt),V=n.add(V,z),z=n.mul(Lt,nt),F=n.mul(lt,F),F=n.sub(F,z),z=n.mul(lt,st),K=n.mul(Lt,K),K=n.add(K,z),new b(F,V,K)}subtract(p){return B(p),this.add(p.negate())}is0(){return this.equals(b.ZERO)}multiply(p){let{endo:S}=t;if(!o.isValidNot0(p))throw new RangeError("invalid scalar: out of range");let _,A,T=L=>k.cached(this,L,N=>Ir(b,N));if(S){let{k1neg:L,k1:N,k2neg:F,k2:V}=U(p),{p:K,f:q}=T(N),{p:G,f:z}=T(V);A=q.add(z),_=I(S.beta,K,G,L,F)}else{let{p:L,f:N}=T(p);_=L,A=N}return Ir(b,[_,A])[0]}multiplyUnsafe(p){let{endo:S}=t,_=this,A=p;if(!o.isValid(A))throw new RangeError("invalid scalar: out of range");if(A===we||_.is0())return b.ZERO;if(A===ir)return _;if(k.hasCache(this))return this.multiply(A);if(S){let{k1neg:T,k1:L,k2neg:N,k2:F}=U(A),{p1:V,p2:K}=kh(b,_,L,F);return I(S.beta,V,K,T,N)}else return k.unsafe(_,A)}toAffine(p){let S=this,_=p,{X:A,Y:T,Z:L}=S;if(n.eql(L,n.ONE))return{x:A,y:T};let N=S.is0();_==null&&(_=N?n.ONE:n.inv(L));let F=n.mul(A,_),V=n.mul(T,_),K=n.mul(L,_);if(N)return{x:n.ZERO,y:n.ZERO};if(!n.eql(K,n.ONE))throw new Error("invZ was invalid");return{x:F,y:V}}isTorsionFree(){let{isTorsionFree:p}=t;return s===ir?!0:p?p(b,this):k.unsafe(this,a).is0()}clearCofactor(){let{clearCofactor:p}=t;return s===ir?this:p?p(b,this):this.multiplyUnsafe(s)}isSmallOrder(){return s===ir?this.is0():this.clearCofactor().is0()}toBytes(p=!0){return ne(p,"isCompressed"),this.assertValidity(),h(b,this,p)}toHex(p=!0){return en(this.toBytes(p))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let D=o.BITS,k=new cn(b,t.endo?Math.ceil(D/2):D);return D>=8&&b.BASE.precompute(8),Object.freeze(b.prototype),Object.freeze(b),b}function Sd(e){return Uint8Array.of(e?2:3)}function vd(e,t){return{secretKey:t.BYTES,publicKey:1+e.BYTES,publicKeyUncompressed:1+2*e.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function Xb(e,t={}){let{Fn:r}=e,n=t.randomBytes===void 0?eo:t.randomBytes,o=Object.assign(vd(e.Fp,r),{seed:Math.max(za(r.ORDER),16)});function i(x){try{let h=r.fromBytes(x);return r.isValidNot0(h)}catch{return!1}}function s(x,h){let{publicKey:g,publicKeyUncompressed:m}=o;try{let y=x.length;return h===!0&&y!==g||h===!1&&y!==m?!1:!!e.fromBytes(x)}catch{return!1}}function a(x){return x=x===void 0?n(o.seed):x,qa(H(x,o.seed,"seed"),r.ORDER)}function c(x,h=!0){return e.BASE.multiply(r.fromBytes(x)).toBytes(h)}function u(x){let{secretKey:h,publicKey:g,publicKeyUncompressed:m}=o,y=r._lengths;if(!vr(x))return;let E=H(x,void 0,"key").length,v=E===g||E===m,C=E===h||!!y?.includes(E);if(!(v&&C))return v}function f(x,h,g=!0){if(u(x)===!0)throw new Error("first arg must be private key");if(u(h)===!1)throw new Error("second arg must be public key");let m=r.fromBytes(x);return e.fromBytes(h).multiply(m).toBytes(g)}let l={isValidSecretKey:i,isValidPublicKey:s,randomSecretKey:a},d=Ci(a,c);return Object.freeze(l),Object.freeze(o),Object.freeze({getPublicKey:c,getSharedSecret:f,keygen:d,Point:e,utils:l,lengths:o})}function Ad(e,t,r={}){let n=t;di(n),ie(r,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"}),r=Object.assign({},r);let o=r.randomBytes===void 0?eo:r.randomBytes,i=r.hmac===void 0?(A,T)=>bd(n,A,T):r.hmac,{Fp:s,Fn:a}=e,{ORDER:c,BITS:u}=a,{keygen:f,getPublicKey:l,getSharedSecret:d,utils:x,lengths:h}=Xb(e,r),g={prehash:!0,lowS:typeof r.lowS=="boolean"?r.lowS:!0,format:"compact",extraEntropy:!1},m=c*wd+ir<s.ORDER;function y(A){let T=c>>ir;return A>T}function E(A,T){if(!a.isValidNot0(T))throw new Error(`invalid signature ${A}: out of range 1..Point.Fn.ORDER`);return T}function v(){if(m)throw new Error('"recovered" sig type is not supported for cofactor >2 curves')}function C(A,T){Ic(T);let L=h.signature,N=T==="compact"?L:T==="recovered"?L+1:void 0;return H(A,N)}class B{r;s;recovery;constructor(T,L,N){if(this.r=E("r",T),this.s=E("s",L),N!=null){if(v(),![0,1,2,3].includes(N))throw new Error("invalid recovery id");this.recovery=N}Object.freeze(this)}static fromBytes(T,L=g.format){C(T,L);let N;if(L==="der"){let{r:q,s:G}=ae.toSig(H(T));return new B(q,G)}L==="recovered"&&(N=T[0],L="compact",T=T.subarray(1));let F=h.signature/2,V=T.subarray(0,F),K=T.subarray(F,F*2);return new B(a.fromBytes(V),a.fromBytes(K),N)}static fromHex(T,L){return this.fromBytes(rn(T),L)}assertRecovery(){let{recovery:T}=this;if(T==null)throw new Error("invalid recovery id: must be present");return T}addRecoveryBit(T){return new B(this.r,this.s,T)}recoverPublicKey(T){let{r:L,s:N}=this,F=this.assertRecovery(),V=F===2||F===3?L+c:L;if(!s.isValid(V))throw new Error("invalid recovery id: sig.r+curve.n != R.x");let K=s.toBytes(V),q=e.fromBytes(ut(Sd((F&1)===0),K)),G=a.inv(V),z=I(H(T,void 0,"msgHash")),st=a.create(-z*G),ft=a.create(N*G),lt=e.BASE.multiplyUnsafe(st).add(q.multiplyUnsafe(ft));if(lt.is0())throw new Error("invalid recovery: point at infinify");return lt.assertValidity(),lt}hasHighS(){return y(this.s)}toBytes(T=g.format){if(Ic(T),T==="der")return rn(ae.hexFromSig(this));let{r:L,s:N}=this,F=a.toBytes(L),V=a.toBytes(N);return T==="recovered"?(v(),ut(Uint8Array.of(this.assertRecovery()),F,V)):ut(F,V)}toHex(T){return en(this.toBytes(T))}}Object.freeze(B.prototype),Object.freeze(B);let U=r.bits2int===void 0?function(T){if(T.length>8192)throw new Error("input is too large");let L=Ar(T),N=T.length*8-u;return N>0?L>>BigInt(N):L}:r.bits2int,I=r.bits2int_modN===void 0?function(T){return a.create(U(T))}:r.bits2int_modN,b=oo(u);function D(A){return nn("num < 2^"+u,A,we,b),a.toBytes(A)}function k(A,T){return H(A,void 0,"message"),T?H(n(A),void 0,"prehashed message"):A}function P(A,T,L){let{lowS:N,prehash:F,extraEntropy:V}=Cc(L,g);A=k(A,F);let K=I(A),q=a.fromBytes(T);if(!a.isValidNot0(q))throw new Error("invalid private key");let G=[D(q),D(K)];if(V!=null&&V!==!1){let lt=V===!0?o(h.secretKey):V;G.push(H(lt,void 0,"extraEntropy"))}let z=ut(...G),st=K;function ft(lt){let nt=U(lt);if(!a.isValidNot0(nt))return;let Lt=a.inv(nt),zr=e.BASE.multiply(nt).toAffine(),zn=a.create(zr.x);if(zn===we)return;let ni=a.create(Lt*a.create(st+zn*q));if(ni===we)return;let Al=(zr.x===zn?0:2)|Number(zr.y&ir),Tl=ni;return N&&y(ni)&&(Tl=a.neg(ni),Al^=1),new B(zn,Tl,m?void 0:Al)}return{seed:z,k2sig:ft}}function p(A,T,L={}){let{seed:N,k2sig:F}=P(A,T,L);return Eh(n.outputLen,a.BYTES,i)(N,F).toBytes(L.format)}function S(A,T,L,N={}){let{lowS:F,prehash:V,format:K}=Cc(N,g);if(L=H(L,void 0,"publicKey"),T=k(T,V),!vr(A)){let q=A instanceof B?", use sig.toBytes()":"";throw new Error("verify expects Uint8Array signature"+q)}C(A,K);try{let q=B.fromBytes(A,K),G=e.fromBytes(L);if(F&&q.hasHighS())return!1;let{r:z,s:st}=q,ft=I(T),lt=a.inv(st),nt=a.create(ft*lt),Lt=a.create(z*lt),zr=e.BASE.multiplyUnsafe(nt).add(G.multiplyUnsafe(Lt));return zr.is0()?!1:a.create(zr.x)===z}catch{return!1}}function _(A,T,L={}){let{prehash:N}=Cc(L,g);return T=k(T,N),B.fromBytes(A,"recovered").recoverPublicKey(T).toBytes()}return Object.freeze({keygen:f,getPublicKey:l,getSharedSecret:d,utils:x,lengths:h,Point:e,sign:p,verify:S,recoverPublicKey:_,Signature:B,hash:n})}var _c={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},Wb={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]};var Td=BigInt(2);function Jb(e){let t=_c.p,r=BigInt(3),n=BigInt(6),o=BigInt(11),i=BigInt(22),s=BigInt(23),a=BigInt(44),c=BigInt(88),u=e*e*e%t,f=u*u*e%t,l=Y(f,r,t)*f%t,d=Y(l,r,t)*f%t,x=Y(d,Td,t)*u%t,h=Y(x,o,t)*x%t,g=Y(h,i,t)*h%t,m=Y(g,a,t)*g%t,y=Y(m,c,t)*m%t,E=Y(y,a,t)*g%t,v=Y(E,r,t)*f%t,C=Y(v,s,t)*h%t,B=Y(C,n,t)*u%t,U=Y(B,Td,t);if(!Dc.eql(Dc.sqr(U),e))throw new Error("Cannot find square root");return U}var Dc=sn(_c.p,{sqrt:Jb}),Qb=Ed(_c,{Fp:Dc,endo:Wb}),ln=Ad(Qb,tn);function Cd(e,t,r,n){let o=ya.digest(r instanceof Uint8Array?r:r.subarray());if(_i(o))return o.then(({digest:i})=>(n?.signal?.throwIfAborted(),ln.verify(t,i,e,{prehash:!1,format:"der"}))).catch(i=>{throw i.name==="AbortError"?i:new co(String(i))});try{return n?.signal?.throwIfAborted(),ln.verify(t,o.digest,e,{prehash:!1,format:"der"})}catch(i){throw new co(String(i))}}var Ki=class{type="secp256k1";raw;_key;constructor(t){this._key=Bd(t),this.raw=Id(this._key)}toMultihash(){return wr.digest(Jr(this))}toCID(){return Yt.createV1(114,this.toMultihash())}toString(){return ht.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:ee(this.raw,t.raw)}verify(t,r,n){return Cd(this._key,r,t,n)}};function Lc(e){return new Ki(e)}function Id(e){return ln.Point.fromBytes(e).toBytes()}function Bd(e){try{return ln.Point.fromBytes(e),e}catch(t){throw new qr(String(t))}}function Dd(e,t){let{Type:r,Data:n}=xe.decode(e),o=n??new Uint8Array;switch(r){case Z.RSA:return vc(o,t);case Z.Ed25519:return nc(o);case Z.secp256k1:return Lc(o);case Z.ECDSA:return Ca(o);default:throw new Hr}}function zi(e){let{Type:t,Data:r}=xe.decode(e.digest),n=r??new Uint8Array;switch(t){case Z.Ed25519:return nc(n);case Z.secp256k1:return Lc(n);case Z.ECDSA:return Ca(n);default:throw new Hr}}function Jr(e){return xe.encode({Type:Z[e.type],Data:e.raw})}var Pc={};$(Pc,{base58btc:()=>Nt,base58flickr:()=>sx});var l5=new Uint8Array(0);function _d(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 Fe(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 Ld(e){return new TextEncoder().encode(e)}function Ud(e){return new TextDecoder().decode(e)}function tx(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var o=0;o<e.length;o++){var i=e.charAt(o),s=i.charCodeAt(0);if(r[s]!==255)throw new TypeError(i+" is ambiguous");r[s]=o}var a=e.length,c=e.charAt(0),u=Math.log(a)/Math.log(256),f=Math.log(256)/Math.log(a);function l(h){if(h instanceof Uint8Array||(ArrayBuffer.isView(h)?h=new Uint8Array(h.buffer,h.byteOffset,h.byteLength):Array.isArray(h)&&(h=Uint8Array.from(h))),!(h instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(h.length===0)return"";for(var g=0,m=0,y=0,E=h.length;y!==E&&h[y]===0;)y++,g++;for(var v=(E-y)*f+1>>>0,C=new Uint8Array(v);y!==E;){for(var B=h[y],U=0,I=v-1;(B!==0||U<m)&&I!==-1;I--,U++)B+=256*C[I]>>>0,C[I]=B%a>>>0,B=B/a>>>0;if(B!==0)throw new Error("Non-zero carry");m=U,y++}for(var b=v-m;b!==v&&C[b]===0;)b++;for(var D=c.repeat(g);b<v;++b)D+=e.charAt(C[b]);return D}function d(h){if(typeof h!="string")throw new TypeError("Expected String");if(h.length===0)return new Uint8Array;var g=0;if(h[g]!==" "){for(var m=0,y=0;h[g]===c;)m++,g++;for(var E=(h.length-g)*u+1>>>0,v=new Uint8Array(E);h[g];){var C=r[h.charCodeAt(g)];if(C===255)return;for(var B=0,U=E-1;(C!==0||B<y)&&U!==-1;U--,B++)C+=a*v[U]>>>0,v[U]=C%256>>>0,C=C/256>>>0;if(C!==0)throw new Error("Non-zero carry");y=B,g++}if(h[g]!==" "){for(var I=E-y;I!==E&&v[I]===0;)I++;for(var b=new Uint8Array(m+(E-I)),D=m;I!==E;)b[D++]=v[I++];return b}}}function x(h){var g=d(h);if(g)return g;throw new Error(`Non-${t} character`)}return{encode:l,decodeUnsafe:d,decode:x}}var ex=tx,rx=ex,Nd=rx;var Uc=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")}},Rc=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 Fd(this,t)}},Nc=class{decoders;constructor(t){this.decoders=t}or(t){return Fd(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 Fd(e,t){return new Nc({...e.decoders??{[e.prefix]:e},...t.decoders??{[t.prefix]:t}})}var Fc=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 Uc(t,r,n),this.decoder=new Rc(t,r,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function hn({name:e,prefix:t,encode:r,decode:n}){return new Fc(e,t,r,n)}function sr({name:e,prefix:t,alphabet:r}){let{encode:n,decode:o}=Nd(r,e);return hn({prefix:t,name:e,encode:n,decode:i=>Fe(o(i))})}function nx(e,t,r,n){let o=e.length;for(;e[o-1]==="=";)--o;let i=new Uint8Array(o*r/8|0),s=0,a=0,c=0;for(let u=0;u<o;++u){let f=t[e[u]];if(f===void 0)throw new SyntaxError(`Non-${n} character`);a=a<<r|f,s+=r,s>=8&&(s-=8,i[c++]=255&a>>s)}if(s>=r||(255&a<<8-s)!==0)throw new SyntaxError("Unexpected end of data");return i}function ox(e,t,r){let n=t[t.length-1]==="=",o=(1<<r)-1,i="",s=0,a=0;for(let c=0;c<e.length;++c)for(a=a<<8|e[c],s+=8;s>r;)s-=r,i+=t[o&a>>s];if(s!==0&&(i+=t[o&a<<r-s]),n)for(;(i.length*r&7)!==0;)i+="=";return i}function ix(e){let t={};for(let r=0;r<e.length;++r)t[e[r]]=r;return t}function tt({name:e,prefix:t,bitsPerChar:r,alphabet:n}){let o=ix(n);return hn({prefix:t,name:e,encode(i){return ox(i,n,r)},decode(i){return nx(i,o,r,e)}})}var Nt=sr({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),sx=sr({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Oc={};$(Oc,{base32:()=>dn,base32hex:()=>fx,base32hexpad:()=>hx,base32hexpadupper:()=>dx,base32hexupper:()=>lx,base32pad:()=>cx,base32padupper:()=>ux,base32upper:()=>ax,base32z:()=>px});var dn=tt({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),ax=tt({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),cx=tt({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),ux=tt({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),fx=tt({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),lx=tt({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),hx=tt({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),dx=tt({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),px=tt({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var kc={};$(kc,{base36:()=>go,base36upper:()=>mx});var go=sr({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),mx=sr({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var gx=kd,Pd=128,yx=127,bx=~yx,xx=Math.pow(2,31);function kd(e,t,r){t=t||[],r=r||0;for(var n=r;e>=xx;)t[r++]=e&255|Pd,e/=128;for(;e&bx;)t[r++]=e&255|Pd,e>>>=7;return t[r]=e|0,kd.bytes=r-n+1,t}var wx=Vc,Ex=128,Od=127;function Vc(e,n){var r=0,n=n||0,o=0,i=n,s,a=e.length;do{if(i>=a)throw Vc.bytes=0,new RangeError("Could not decode varint");s=e[i++],r+=o<28?(s&Od)<<o:(s&Od)*Math.pow(2,o),o+=7}while(s>=Ex);return Vc.bytes=i-n,r}var Sx=Math.pow(2,7),vx=Math.pow(2,14),Ax=Math.pow(2,21),Tx=Math.pow(2,28),Cx=Math.pow(2,35),Ix=Math.pow(2,42),Bx=Math.pow(2,49),Dx=Math.pow(2,56),_x=Math.pow(2,63),Lx=function(e){return e<Sx?1:e<vx?2:e<Ax?3:e<Tx?4:e<Cx?5:e<Ix?6:e<Bx?7:e<Dx?8:e<_x?9:10},Ux={encode:gx,decode:wx,encodingLength:Lx},Rx=Ux,yo=Rx;function bo(e,t=0){return[yo.decode(e,t),yo.decode.bytes]}function pn(e,t,r=0){return yo.encode(e,t,r),t}function mn(e){return yo.encodingLength(e)}function yn(e,t){let r=t.byteLength,n=mn(e),o=n+mn(r),i=new Uint8Array(o+r);return pn(e,i,0),pn(r,i,n),i.set(t,o),new gn(e,r,t,i)}function xo(e){let t=Fe(e),[r,n]=bo(t),[o,i]=bo(t.subarray(n)),s=t.subarray(n+i);if(s.byteLength!==o)throw new Error("Incorrect length");return new gn(r,o,s,t)}function Vd(e,t){if(e===t)return!0;{let r=t;return e.code===r.code&&e.size===r.size&&r.bytes instanceof Uint8Array&&_d(e.bytes,r.bytes)}}var gn=class{code;size;digest;bytes;constructor(t,r,n,o){this.code=t,this.size=r,this.digest=n,this.bytes=o}};function Md(e,t){let{bytes:r,version:n}=e;return n===0?Fx(r,Mc(e),t??Nt.encoder):Px(r,Mc(e),t??dn.encoder)}var $d=new WeakMap;function Mc(e){let t=$d.get(e);if(t==null){let r=new Map;return $d.set(e,r),r}return t}var Pe=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!==wo)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==Ox)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=yn(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&&Vd(t.multihash,n.multihash)}toString(t){return Md(this,t)}toJSON(){return{"/":Md(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??Kd(n,o,i.bytes))}else if(r[kx]===!0){let{version:n,multihash:o,code:i}=r,s=xo(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!==wo)throw new Error(`Version 0 CID must use dag-pb (code: ${wo}) block encoding`);return new e(t,r,n,n.bytes)}case 1:{let o=Kd(t,r,n.bytes);return new e(t,r,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return e.create(0,wo,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=Fe(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 gn(r.multihashCode,r.digestSize,i,o);return[r.version===0?e.createV0(s):e.createV1(r.codec,s),t.subarray(r.size)]}static inspectBytes(t){let r=0,n=()=>{let[l,d]=bo(t.subarray(r));return r+=d,l},o=n(),i=wo;if(o===18?(o=0,r=0):i=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let s=r,a=n(),c=n(),u=r+c,f=u-s;return{version:o,codec:i,multihashCode:a,digestSize:c,multihashSize:f,size:u}}static parse(t,r){let[n,o]=Nx(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 Mc(i).set(n,t),i}};function Nx(e,t){switch(e[0]){case"Q":{let r=t??Nt;return[Nt.prefix,r.decode(`${Nt.prefix}${e}`)]}case Nt.prefix:{let r=t??Nt;return[Nt.prefix,r.decode(e)]}case dn.prefix:{let r=t??dn;return[dn.prefix,r.decode(e)]}case go.prefix:{let r=t??go;return[go.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 Fx(e,t,r){let{prefix:n}=r;if(n!==Nt.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 Px(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 wo=112,Ox=18;function Kd(e,t,r){let n=mn(e),o=n+mn(t),i=new Uint8Array(o+r.byteLength);return pn(e,i,0),pn(t,i,n),i.set(r,o),i}var kx=Symbol.for("@ipld/js-cid/CID");var $c={};$($c,{identity:()=>Eo});var zd=0,Vx="identity",qd=Fe;function Mx(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 yn(zd,qd(e))}var Eo={code:zd,name:Vx,encode:qd,digest:Mx};var Hc={};$(Hc,{sha256:()=>qc,sha512:()=>Kx});var $x=20;function zc({name:e,code:t,encode:r,minDigestLength:n,maxDigestLength:o}){return new Kc(e,t,r,n,o)}var Kc=class{name;code;encode;minDigestLength;maxDigestLength;constructor(t,r,n,o,i){this.name=t,this.code=r,this.encode=n,this.minDigestLength=o??$x,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?Hd(n,this.code,r?.truncate):n.then(o=>Hd(o,this.code,r?.truncate))}else throw Error("Unknown type, must be binary type")}};function Hd(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 yn(t,e)}function Gd(e){return async t=>new Uint8Array(await crypto.subtle.digest(e,t))}var qc=zc({name:"sha2-256",code:18,encode:Gd("SHA-256")}),Kx=zc({name:"sha2-512",code:19,encode:Gd("SHA-512")});var jc={};$(jc,{base10:()=>zx});var zx=sr({prefix:"9",name:"base10",alphabet:"0123456789"});var Gc={};$(Gc,{base16:()=>qx,base16upper:()=>Hx});var qx=tt({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Hx=tt({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Yc={};$(Yc,{base2:()=>jx});var jx=tt({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Zc={};$(Zc,{base256emoji:()=>Wx});var Yd=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}"),Gx=Yd.reduce((e,t,r)=>(e[r]=t,e),[]),Yx=Yd.reduce((e,t,r)=>{let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);return e[n]=r,e},[]);function Zx(e){return e.reduce((t,r)=>(t+=Gx[r],t),"")}function Xx(e){let t=[];for(let r of e){let n=r.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${r}`);let o=Yx[n];if(o==null)throw new Error(`Non-base256emoji character: ${r}`);t.push(o)}return new Uint8Array(t)}var Wx=hn({prefix:"\u{1F680}",name:"base256emoji",encode:Zx,decode:Xx});var Xc={};$(Xc,{base64:()=>Jx,base64pad:()=>Qx,base64url:()=>tw,base64urlpad:()=>ew});var Jx=tt({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Qx=tt({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),tw=tt({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),ew=tt({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Wc={};$(Wc,{base8:()=>rw});var rw=tt({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Jc={};$(Jc,{identity:()=>nw});var nw=hn({prefix:"\0",name:"identity",encode:e=>Ud(e),decode:e=>Ld(e)});var k5=new TextEncoder,V5=new TextDecoder;var Qc={...Jc,...Yc,...Wc,...jc,...Gc,...Oc,...kc,...Pc,...Xc,...Zc},X5={...Hc,...$c};function Zd(e=0){return new Uint8Array(e)}function Wd(e,t,r,n){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:n}}}var Xd=Wd("utf8","u",e=>"u"+new TextDecoder("utf8").decode(e),e=>new TextEncoder().encode(e.substring(1))),tu=Wd("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=Zd(e.length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t}),sw={utf8:Xd,"utf-8":Xd,hex:Qc.base16,latin1:tu,ascii:tu,binary:tu,...Qc},Hi=sw;function So(e,t="utf8"){let r=Hi[t];if(r==null)throw new Error(`Unsupported encoding "${t}"`);return r.encoder.encode(e).substring(1)}function eu(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 Jd(e,t="utf8"){let r=Hi[t];if(r==null)throw new Error(`Unsupported encoding "${t}"`);return r.decoder.decode(`${r.prefix}${e}`)}var Qd=Symbol.for("nodejs.util.inspect.custom"),aw=114,vo=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()})`}[ai]=!0;toString(){return this.string==null&&(this.string=Nt.encode(this.multihash.bytes).slice(1)),this.string}toMultihash(){return this.multihash}toCID(){return Pe.createV1(aw,this.multihash)}toJSON(){return this.toString()}equals(t){if(t==null)return!1;if(t instanceof Uint8Array)return eu(this.multihash.bytes,t);if(typeof t=="string")return this.toString()===t;if(t?.toMultihash()?.bytes!=null)return eu(this.multihash.bytes,t.toMultihash().bytes);throw new Error("not valid Id")}[Qd](){return`PeerId(${this.toString()})`}},ji=class extends vo{type="RSA";publicKey;constructor(t){super({...t,type:"RSA"}),this.publicKey=t.publicKey}},Gi=class extends vo{type="Ed25519";publicKey;constructor(t){super({...t,type:"Ed25519"}),this.publicKey=t.publicKey}},Yi=class extends vo{type="secp256k1";publicKey;constructor(t){super({...t,type:"secp256k1"}),this.publicKey=t.publicKey}},cw=2336,Ao=class{type="url";multihash;publicKey;url;constructor(t){this.url=t.toString(),this.multihash=Eo.digest(Jd(this.url))}[Qd](){return`PeerId(${this.url})`}[ai]=!0;toString(){return this.toCID().toString()}toMultihash(){return this.multihash}toCID(){return Pe.createV1(cw,this.toMultihash())}toJSON(){return this.toString()}equals(t){return t==null?!1:(t instanceof Uint8Array&&(t=So(t)),t.toString()===this.toString())}};var uw=114,tp=2336;function ep(e,t){let r;if(e.charAt(0)==="1"||e.charAt(0)==="Q")r=xo(Nt.decode(`z${e}`));else{if(e.startsWith("k51qzi5uqu5")||e.startsWith("kzwfwjn5ji4")||e.startsWith("k2k4r8")||e.startsWith("bafz"))return ru(Pe.parse(e));if(t==null)throw new W('Please pass a multibase decoder for strings that do not start with "1" or "Q"');r=xo(t.decode(e))}return Zi(r)}function Zi(e){if(lw(e))return new ji({multihash:e});if(fw(e))try{let t=zi(e);if(t.type==="Ed25519")return new Gi({multihash:e,publicKey:t});if(t.type==="secp256k1")return new Yi({multihash:e,publicKey:t})}catch{let r=So(e.digest);return new Ao(new URL(r))}throw new je("Supplied PeerID Multihash is invalid")}function ru(e){if(e?.multihash==null||e.version==null||e.version===1&&e.code!==uw&&e.code!==tp)throw new si("Supplied PeerID CID is invalid");if(e.code===tp){let t=So(e.multihash.digest);return new Ao(new URL(t))}return Zi(e.multihash)}function fw(e){return e.code===Eo.code}function lw(e){return e.code===qc.code}function ar(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 Xt(e=0){return new Uint8Array(e)}var hw=Math.pow(2,7),dw=Math.pow(2,14),pw=Math.pow(2,21),nu=Math.pow(2,28),ou=Math.pow(2,35),iu=Math.pow(2,42),su=Math.pow(2,49),X=128,St=127;function Ee(e){if(e<hw)return 1;if(e<dw)return 2;if(e<pw)return 3;if(e<nu)return 4;if(e<ou)return 5;if(e<iu)return 6;if(e<su)return 7;if(Number.MAX_SAFE_INTEGER!=null&&e>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function To(e,t,r=0){switch(Ee(e)){case 8:t[r++]=e&255|X,e/=128;case 7:t[r++]=e&255|X,e/=128;case 6:t[r++]=e&255|X,e/=128;case 5:t[r++]=e&255|X,e/=128;case 4:t[r++]=e&255|X,e>>>=7;case 3:t[r++]=e&255|X,e>>>=7;case 2:t[r++]=e&255|X,e>>>=7;case 1:{t[r++]=e&255,e>>>=7;break}default:throw new Error("unreachable")}return t}function au(e,t){let r=e[t],n=0;if(n+=r&St,r<X||(r=e[t+1],n+=(r&St)<<7,r<X)||(r=e[t+2],n+=(r&St)<<14,r<X)||(r=e[t+3],n+=(r&St)<<21,r<X)||(r=e[t+4],n+=(r&St)*nu,r<X)||(r=e[t+5],n+=(r&St)*ou,r<X)||(r=e[t+6],n+=(r&St)*iu,r<X)||(r=e[t+7],n+=(r&St)*su,r<X))return n;throw new RangeError("Could not decode varint")}function mw(e,t){let r=e.get(t),n=0;if(n+=r&St,r<X||(r=e.get(t+1),n+=(r&St)<<7,r<X)||(r=e.get(t+2),n+=(r&St)<<14,r<X)||(r=e.get(t+3),n+=(r&St)<<21,r<X)||(r=e.get(t+4),n+=(r&St)*nu,r<X)||(r=e.get(t+5),n+=(r&St)*ou,r<X)||(r=e.get(t+6),n+=(r&St)*iu,r<X)||(r=e.get(t+7),n+=(r&St)*su,r<X))return n;throw new RangeError("Could not decode varint")}function cu(e,t=0){return e instanceof Uint8Array?au(e,t):mw(e,t)}function yw(e){return e.buffer instanceof ArrayBuffer}function Co(e){return yw(e)?e:e.slice()}function bw(e){return e?.buffer instanceof ArrayBuffer}function uu(e){if(bw(e))return e;let t=e.slice();return new Uint8Array(t.buffer,0,t.byteLength)}function _r(e,t){t==null&&(t=e.reduce((o,i)=>o+i.length,0));let r=Xt(t),n=0;for(let o of e)r.set(o,n),n+=o.length;return uu(r)}var pu={};$(pu,{base10:()=>Cw});var OA=new Uint8Array(0);function rp(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 Lr(e);if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return Lr(new Uint8Array(e.buffer,e.byteOffset,e.byteLength));throw new Error("Unknown type, must be binary type")}function np(e){return new TextEncoder().encode(e)}function op(e){return new TextDecoder().decode(e)}function xw(e){return e?.buffer instanceof ArrayBuffer}function Lr(e){return xw(e)?e:e.slice()}function ww(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var o=0;o<e.length;o++){var i=e.charAt(o),s=i.charCodeAt(0);if(r[s]!==255)throw new TypeError(i+" is ambiguous");r[s]=o}var a=e.length,c=e.charAt(0),u=Math.log(a)/Math.log(256),f=Math.log(256)/Math.log(a);function l(h){if(h instanceof Uint8Array||(ArrayBuffer.isView(h)?h=new Uint8Array(h.buffer,h.byteOffset,h.byteLength):Array.isArray(h)&&(h=Uint8Array.from(h))),!(h instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(h.length===0)return"";for(var g=0,m=0,y=0,E=h.length;y!==E&&h[y]===0;)y++,g++;for(var v=(E-y)*f+1>>>0,C=new Uint8Array(v);y!==E;){for(var B=h[y],U=0,I=v-1;(B!==0||U<m)&&I!==-1;I--,U++)B+=256*C[I]>>>0,C[I]=B%a>>>0,B=B/a>>>0;if(B!==0)throw new Error("Non-zero carry");m=U,y++}for(var b=v-m;b!==v&&C[b]===0;)b++;for(var D=c.repeat(g);b<v;++b)D+=e.charAt(C[b]);return D}function d(h){if(typeof h!="string")throw new TypeError("Expected String");if(h.length===0)return new Uint8Array;var g=0;if(h[g]!==" "){for(var m=0,y=0;h[g]===c;)m++,g++;for(var E=(h.length-g)*u+1>>>0,v=new Uint8Array(E);h[g];){var C=r[h.charCodeAt(g)];if(C===255)return;for(var B=0,U=E-1;(C!==0||B<y)&&U!==-1;U--,B++)C+=a*v[U]>>>0,v[U]=C%256>>>0,C=C/256>>>0;if(C!==0)throw new Error("Non-zero carry");y=B,g++}if(h[g]!==" "){for(var I=E-y;I!==E&&v[I]===0;)I++;for(var b=new Uint8Array(m+(E-I)),D=m;I!==E;)b[D++]=v[I++];return b}}}function x(h){var g=d(h);if(g)return g;throw new Error(`Non-${t} character`)}return{encode:l,decodeUnsafe:d,decode:x}}var Ew=ww,Sw=Ew,sp=Sw;var fu=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")}},lu=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 ap(this,t)}},hu=class{decoders;constructor(t){this.decoders=t}or(t){return ap(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 ap(e,t){return new hu({...e.decoders??{[e.prefix]:e},...t.decoders??{[t.prefix]:t}})}var du=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 fu(t,r,n),this.decoder=new lu(t,r,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function xn({name:e,prefix:t,encode:r,decode:n}){return new du(e,t,r,n)}function cr({name:e,prefix:t,alphabet:r}){let{encode:n,decode:o}=sp(r,e);return xn({prefix:t,name:e,encode:n,decode:i=>Oe(o(i))})}function vw(e,t,r,n){let o=e.length;for(;e[o-1]==="=";)--o;let i=new Uint8Array(o*r/8|0),s=0,a=0,c=0;for(let u=0;u<o;++u){let f=t[e[u]];if(f===void 0)throw new SyntaxError(`Non-${n} character`);a=a<<r|f,s+=r,s>=8&&(s-=8,i[c++]=255&a>>s)}if(s>=r||(255&a<<8-s)!==0)throw new SyntaxError("Unexpected end of data");return i}function Aw(e,t,r){let n=t[t.length-1]==="=",o=(1<<r)-1,i="",s=0,a=0;for(let c=0;c<e.length;++c)for(a=a<<8|e[c],s+=8;s>r;)s-=r,i+=t[o&a>>s];if(s!==0&&(i+=t[o&a<<r-s]),n)for(;(i.length*r&7)!==0;)i+="=";return i}function Tw(e){let t={};for(let r=0;r<e.length;++r)t[e[r]]=r;return t}function et({name:e,prefix:t,bitsPerChar:r,alphabet:n}){let o=Tw(n);return xn({prefix:t,name:e,encode(i){return Aw(i,n,r)},decode(i){return vw(i,o,r,e)}})}var Cw=cr({prefix:"9",name:"base10",alphabet:"0123456789"});var mu={};$(mu,{base16:()=>Iw,base16upper:()=>Bw});var Iw=et({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Bw=et({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var gu={};$(gu,{base2:()=>Dw});var Dw=et({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var yu={};$(yu,{base256emoji:()=>Nw});var cp=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}"),_w=cp.reduce((e,t,r)=>(e[r]=t,e),[]),Lw=cp.reduce((e,t,r)=>{let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);return e[n]=r,e},[]);function Uw(e){return e.reduce((t,r)=>(t+=_w[r],t),"")}function Rw(e){let t=[];for(let r of e){let n=r.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${r}`);let o=Lw[n];if(o==null)throw new Error(`Non-base256emoji character: ${r}`);t.push(o)}return new Uint8Array(t)}var Nw=xn({prefix:"\u{1F680}",name:"base256emoji",encode:Uw,decode:Rw});var bu={};$(bu,{base32:()=>ur,base32hex:()=>kw,base32hexpad:()=>Mw,base32hexpadupper:()=>$w,base32hexupper:()=>Vw,base32pad:()=>Pw,base32padupper:()=>Ow,base32upper:()=>Fw,base32z:()=>Kw});var ur=et({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Fw=et({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Pw=et({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Ow=et({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),kw=et({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Vw=et({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Mw=et({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),$w=et({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Kw=et({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var xu={};$(xu,{base36:()=>wn,base36upper:()=>zw});var wn=cr({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),zw=cr({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var wu={};$(wu,{base58btc:()=>Se,base58flickr:()=>qw});var Se=cr({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),qw=cr({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Su={};$(Su,{base64:()=>Hw,base64pad:()=>jw,base64url:()=>Eu,base64urlpad:()=>Gw});var Hw=et({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),jw=et({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Eu=et({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Gw=et({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var vu={};$(vu,{base8:()=>Yw});var Yw=et({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Au={};$(Au,{identity:()=>Zw});var Zw=xn({prefix:"\0",name:"identity",encode:e=>op(e),decode:e=>np(e)});var QA=new TextEncoder,tT=new TextDecoder;var Iu={};$(Iu,{identity:()=>Cu});var Jw=lp,up=128,Qw=127,t2=~Qw,e2=Math.pow(2,31);function lp(e,t,r){t=t||[],r=r||0;for(var n=r;e>=e2;)t[r++]=e&255|up,e/=128;for(;e&t2;)t[r++]=e&255|up,e>>>=7;return t[r]=e|0,lp.bytes=r-n+1,t}var r2=Tu,n2=128,fp=127;function Tu(e,n){var r=0,n=n||0,o=0,i=n,s,a=e.length;do{if(i>=a)throw Tu.bytes=0,new RangeError("Could not decode varint");s=e[i++],r+=o<28?(s&fp)<<o:(s&fp)*Math.pow(2,o),o+=7}while(s>=n2);return Tu.bytes=i-n,r}var o2=Math.pow(2,7),i2=Math.pow(2,14),s2=Math.pow(2,21),a2=Math.pow(2,28),c2=Math.pow(2,35),u2=Math.pow(2,42),f2=Math.pow(2,49),l2=Math.pow(2,56),h2=Math.pow(2,63),d2=function(e){return e<o2?1:e<i2?2:e<s2?3:e<a2?4:e<c2?5:e<u2?6:e<f2?7:e<l2?8:e<h2?9:10},p2={encode:Jw,decode:r2,encodingLength:d2},m2=p2,Io=m2;function Bo(e,t=0){return[Io.decode(e,t),Io.decode.bytes]}function En(e,t,r=0){return Io.encode(e,t,r),t}function Sn(e){return Io.encodingLength(e)}function An(e,t){let r=t.byteLength,n=Sn(e),o=n+Sn(r),i=new Uint8Array(o+r);return En(e,i,0),En(r,i,n),i.set(t,o),new vn(e,r,t,i)}function Wi(e){let t=Oe(e),[r,n]=Bo(t),[o,i]=Bo(t.subarray(n)),s=t.subarray(n+i);if(s.byteLength!==o)throw new Error("Incorrect length");return new vn(r,o,s,t)}function hp(e,t){if(e===t)return!0;{let r=t;return e.code===r.code&&e.size===r.size&&r.bytes instanceof Uint8Array&&rp(e.bytes,r.bytes)}}var vn=class{code;size;digest;bytes;constructor(t,r,n,o){this.code=t,this.size=r,this.digest=Lr(n),this.bytes=Lr(o)}};var dp=0,g2="identity",pp=Oe;function y2(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 An(dp,pp(e))}var Cu={code:dp,name:g2,encode:pp,digest:y2};var _u={};$(_u,{sha256:()=>x2,sha512:()=>w2});var b2=20;function Du({name:e,code:t,encode:r,minDigestLength:n,maxDigestLength:o}){return new Bu(e,t,r,n,o)}var Bu=class{name;code;encode;minDigestLength;maxDigestLength;constructor(t,r,n,o,i){this.name=t,this.code=r,this.encode=n,this.minDigestLength=o??b2,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?mp(n,this.code,r?.truncate):n.then(o=>mp(o,this.code,r?.truncate))}else throw Error("Unknown type, must be binary type")}};function mp(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 An(t,e)}function yp(e){return async t=>new Uint8Array(await crypto.subtle.digest(e,t))}var x2=Du({name:"sha2-256",code:18,encode:yp("SHA-256")}),w2=Du({name:"sha2-512",code:19,encode:yp("SHA-512")});function bp(e,t){let{bytes:r,version:n}=e;return n===0?S2(r,Lu(e),t??Se.encoder):v2(r,Lu(e),t??ur.encoder)}var xp=new WeakMap;function Lu(e){let t=xp.get(e);if(t==null){let r=new Map;return xp.set(e,r),r}return t}var Ft=class e{code;version;multihash;bytes;"/";constructor(t,r,n,o){this.code=r,this.version=t,this.multihash=n,this.bytes=Lr(o),this["/"]=this.bytes}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!==Do)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==A2)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=An(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&&hp(t.multihash,n.multihash)}toString(t){return bp(this,t)}toJSON(){return{"/":bp(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??wp(n,o,i.bytes))}else if(r[T2]===!0){let{version:n,multihash:o,code:i}=r,s=Wi(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!==Do)throw new Error(`Version 0 CID must use dag-pb (code: ${Do}) block encoding`);return new e(t,r,n,n.bytes)}case 1:{let o=wp(t,r,n.bytes);return new e(t,r,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return e.create(0,Do,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 vn(r.multihashCode,r.digestSize,i,o);return[r.version===0?e.createV0(s):e.createV1(r.codec,s),t.subarray(r.size)]}static inspectBytes(t){let r=0,n=()=>{let[l,d]=Bo(t.subarray(r));return r+=d,l},o=n(),i=Do;if(o===18?(o=0,r=0):i=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let s=r,a=n(),c=n(),u=r+c,f=u-s;return{version:o,codec:i,multihashCode:a,digestSize:c,multihashSize:f,size:u}}static parse(t,r){let[n,o]=E2(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 Lu(i).set(n,t),i}};function E2(e,t){switch(e[0]){case"Q":{let r=t??Se;return[Se.prefix,r.decode(`${Se.prefix}${e}`)]}case Se.prefix:{let r=t??Se;return[Se.prefix,r.decode(e)]}case ur.prefix:{let r=t??ur;return[ur.prefix,r.decode(e)]}case wn.prefix:{let r=t??wn;return[wn.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 S2(e,t,r){let{prefix:n}=r;if(n!==Se.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 v2(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 Do=112,A2=18;function wp(e,t,r){let n=Sn(e),o=n+Sn(t),i=new Uint8Array(o+r.byteLength);return En(e,i,0),En(t,i,n),i.set(r,o),i}var T2=Symbol.for("@ipld/js-cid/CID");var _o={...Au,...gu,...vu,...pu,...mu,...bu,...xu,...wu,...Su,...yu},ST={..._u,...Iu};function Sp(e,t,r,n){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:n}}}var Ep=Sp("utf8","u",e=>"u"+new TextDecoder("utf8").decode(e),e=>new TextEncoder().encode(e.substring(1))),Uu=Sp("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=Xt(e.length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t}),C2={utf8:Ep,"utf-8":Ep,hex:_o.base16,latin1:Uu,ascii:Uu,binary:Uu,..._o},Ji=C2;function xt(e,t="utf8"){let r=Ji[t];if(r==null)throw new Error(`Unsupported encoding "${t}"`);return r.decoder.decode(`${r.prefix}${e}`)}function $t(e,t="utf8"){let r=Ji[t];if(r==null)throw new Error(`Unsupported encoding "${t}"`);return r.encoder.encode(e).substring(1)}var wt=class extends Error{static name="InvalidMultiaddrError";name="InvalidMultiaddrError"},ke=class extends Error{static name="ValidationError";name="ValidationError"},Qi=class extends Error{static name="InvalidParametersError";name="InvalidParametersError"},ts=class extends Error{static name="UnknownProtocolError";name="UnknownProtocolError"};var es=class{index=0;input="";new(t){return this.index=0,this.input=t,this}readAtomically(t){let r=this.index,n=t();return n===void 0&&(this.index=r),n}parseWith(t){let r=t();if(this.index===this.input.length)return r}peekChar(){if(!(this.index>=this.input.length))return this.input[this.index]}readChar(){if(!(this.index>=this.input.length))return this.input[this.index++]}readGivenChar(t){return this.readAtomically(()=>{let r=this.readChar();if(r===t)return r})}readSeparator(t,r,n){return this.readAtomically(()=>{if(!(r>0&&this.readGivenChar(t)===void 0))return n()})}readNumber(t,r,n,o){return this.readAtomically(()=>{let i=0,s=0,a=this.peekChar();if(a===void 0)return;let c=a==="0",u=2**(8*o)-1;for(;;){let f=this.readAtomically(()=>{let l=this.readChar();if(l===void 0)return;let d=Number.parseInt(l,t);if(!Number.isNaN(d))return d});if(f===void 0)break;if(i*=t,i+=f,i>u||(s+=1,r!==void 0&&s>r))return}if(s!==0)return!n&&c&&s>1?void 0:i})}readIPv4Addr(){return this.readAtomically(()=>{let t=new Uint8Array(4);for(let r=0;r<t.length;r++){let n=this.readSeparator(".",r,()=>this.readNumber(10,3,!1,1));if(n===void 0)return;t[r]=n}return t})}readIPv6Addr(){let t=r=>{for(let n=0;n<r.length/2;n++){let o=n*2;if(n<r.length-3){let s=this.readSeparator(":",n,()=>this.readIPv4Addr());if(s!==void 0)return r[o]=s[0],r[o+1]=s[1],r[o+2]=s[2],r[o+3]=s[3],[o+4,!0]}let i=this.readSeparator(":",n,()=>this.readNumber(16,4,!0,2));if(i===void 0)return[o,!1];r[o]=i>>8,r[o+1]=i&255}return[r.length,!1]};return this.readAtomically(()=>{let r=new Uint8Array(16),[n,o]=t(r);if(n===16)return r;if(o||this.readGivenChar(":")===void 0||this.readGivenChar(":")===void 0)return;let i=new Uint8Array(14),s=16-(n+2),[a]=t(i.subarray(0,s));return r.set(i.subarray(0,a),16-a),r})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var I2=45,B2=15,rs=new es;function vp(e){if(!(e.length>B2))return rs.new(e).parseWith(()=>rs.readIPv4Addr())}function Ap(e){if(e.includes("%")&&(e=e.split("%")[0]),!(e.length>I2))return rs.new(e).parseWith(()=>rs.readIPv6Addr())}function ns(e){return!!vp(e)}function Tp(e){return!!Ap(e)}function Nu(e){return t=>$t(t,e)}function Fu(e){return t=>xt(t,e)}function Cn(e){return new DataView(e.buffer).getUint16(e.byteOffset).toString()}function Ur(e){let t=new ArrayBuffer(2);return new DataView(t).setUint16(0,typeof e=="string"?parseInt(e):e),new Uint8Array(t)}function Cp(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=xt(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=Ur(n);return _r([r,o],r.length+o.length)}function Ip(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=ur.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=Ur(n);return _r([r,o],r.length+o.length)}function Pu(e){let t=e.subarray(0,e.length-2),r=e.subarray(e.length-2),n=$t(t,"base32"),o=Cn(r);return`${n}:${o}`}var Ou=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 wt("Invalid byte value in IP address");t[n]=o}),t},Bp=function(e){let t=0;e=e.toString().trim();let r=e.split(":",8),n;for(n=0;n<r.length;n++){let i=ns(r[n]),s;i&&(s=Ou(r[n]),r[n]=$t(s.subarray(0,2),"base16")),s!=null&&++n<8&&r.splice(n,0,$t(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 wt("Invalid byte value in IP address");o[t++]=i>>8&255,o[t++]=i&255}return o},Dp=function(e){if(e.byteLength!==4)throw new wt("IPv4 address was incorrect length");let t=[];for(let r=0;r<e.byteLength;r++)t.push(e[r]);return t.join(".")},_p=function(e){if(e.byteLength!==16)throw new wt("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 wt(`Invalid IPv6 address "${r}"`)}};function Lp(e){try{let t=new URL(`http://[${e}]`);return t.hostname.substring(1,t.hostname.length-1)}catch{throw new wt(`Invalid IPv6 address "${e}"`)}}var Ru=Object.values(_o).map(e=>e.decoder),D2=(function(){let e=Ru[0].or(Ru[1]);return Ru.slice(2).forEach(t=>e=e.or(t)),e})();function Up(e){return D2.decode(e)}function Rp(e){return t=>e.encoder.encode(t)}function _2(e){if(parseInt(e).toString()!==e)throw new ke("Value must be an integer")}function L2(e){if(e<0)throw new ke("Value must be a positive integer, or zero")}function U2(e){return t=>{if(t>e)throw new ke(`Value must be smaller than or equal to ${e}`)}}function R2(...e){return t=>{for(let r of e)r(t)}}var Lo=R2(_2,L2,U2(65535));var pt=-1,ku=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 ts(`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)}))}},Ve=new ku,w1=[{code:4,name:"ip4",size:32,valueToBytes:Ou,bytesToValue:Dp,validate:e=>{if(!ns(e))throw new ke(`Invalid IPv4 address "${e}"`)}},{code:6,name:"tcp",size:16,valueToBytes:Ur,bytesToValue:Cn,validate:Lo},{code:273,name:"udp",size:16,valueToBytes:Ur,bytesToValue:Cn,validate:Lo},{code:33,name:"dccp",size:16,valueToBytes:Ur,bytesToValue:Cn,validate:Lo},{code:41,name:"ip6",size:128,valueToBytes:Bp,bytesToValue:_p,stringToValue:Lp,validate:e=>{if(!Tp(e))throw new ke(`Invalid IPv6 address "${e}"`)}},{code:42,name:"ip6zone",size:pt},{code:43,name:"ipcidr",size:8,bytesToValue:Nu("base10"),valueToBytes:Fu("base10")},{code:53,name:"dns",size:pt},{code:54,name:"dns4",size:pt},{code:55,name:"dns6",size:pt},{code:56,name:"dnsaddr",size:pt},{code:132,name:"sctp",size:16,valueToBytes:Ur,bytesToValue:Cn,validate:Lo},{code:301,name:"udt"},{code:302,name:"utp"},{code:400,name:"unix",size:pt,stringToValue:e=>decodeURIComponent(e),valueToString:e=>encodeURIComponent(e)},{code:421,name:"p2p",aliases:["ipfs"],size:pt,bytesToValue:Nu("base58btc"),valueToBytes:e=>e.startsWith("Q")||e.startsWith("1")?Fu("base58btc")(e):Ft.parse(e).multihash.bytes},{code:444,name:"onion",size:96,bytesToValue:Pu,valueToBytes:Cp},{code:445,name:"onion3",size:296,bytesToValue:Pu,valueToBytes:Ip},{code:446,name:"garlic64",size:pt},{code:447,name:"garlic32",size:pt},{code:448,name:"tls"},{code:449,name:"sni",size:pt},{code:454,name:"noise"},{code:460,name:"quic"},{code:461,name:"quic-v1"},{code:465,name:"webtransport"},{code:466,name:"certhash",size:pt,bytesToValue:Rp(Eu),valueToBytes:Up},{code:480,name:"http"},{code:481,name:"http-path",size:pt,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:pt}];w1.forEach(e=>{Ve.addProtocol(e)});function Np(e){let t=[],r=0;for(;r<e.length;){let n=cu(e,r),o=Ve.getProtocol(n),i=Ee(n),s=E1(o,e,r+i),a=0;s>0&&o.size===pt&&(a=Ee(s));let c=i+a+s,u={code:n,name:o.name,bytes:Co(e.subarray(r,r+c))};if(s>0){let f=r+i+a,l=e.subarray(f,f+s);u.value=o.bytesToValue?.(l)??$t(l)}t.push(u),r+=c}return t}function Fp(e){let t=0,r=[];for(let n of e){if(n.bytes==null){let o=Ve.getProtocol(n.code),i=Ee(n.code),s,a=0,c=0;n.value!=null&&(s=o.valueToBytes?.(n.value)??xt(n.value),a=s.byteLength,o.size===pt&&(c=Ee(a)));let u=new Uint8Array(i+c+a),f=0;To(n.code,u,f),f+=i,s!=null&&(o.size===pt&&(To(a,u,f),f+=c),u.set(s,f)),n.bytes=u}r.push(n.bytes),t+=n.bytes.byteLength}return _r(r,t)}function Pp(e){if(e.charAt(0)!=="/")throw new wt('String multiaddr must start with "/"');let t=[],r="protocol",n="",o="";for(let i=1;i<e.length;i++){let s=e.charAt(i);s!=="/"&&(r==="protocol"?o+=e.charAt(i):n+=e.charAt(i));let a=i===e.length-1;if(s==="/"||a){let c=Ve.getProtocol(o);if(r==="protocol"){if(c.size==null||c.size===0){t.push({code:c.code,name:c.name}),n="",o="",r="protocol";continue}else if(a)throw new wt(`Component ${o} was missing value`);r="value"}else if(r==="value"){let u={code:c.code,name:c.name};if(c.size!=null&&c.size!==0){if(n==="")throw new wt(`Component ${o} was missing value`);u.value=c.stringToValue?.(n)??n}t.push(u),n="",o="",r="protocol"}}}if(o!==""&&n!=="")throw new wt("Incomplete multiaddr");return t}function Op(e){return`/${e.flatMap(t=>{if(t.value==null)return t.name;let r=Ve.getProtocol(t.code);if(r==null)throw new wt(`Unknown protocol code ${t.code}`);return[t.name,r.valueToString?.(t.value)??t.value]}).join("/")}`}function E1(e,t,r){return e.size==null||e.size===0?0:e.size>0?e.size/8:cu(t,r)}var S1=Symbol.for("nodejs.util.inspect.custom"),Vu=Symbol.for("@multiformats/multiaddr");function v1(e){if(e==null&&(e="/"),kp(e))return e.getComponents();if(e instanceof Uint8Array)return Np(e);if(typeof e=="string")return e=e.replace(/\/(\/)+/,"/").replace(/(\/)+$/,""),e===""&&(e="/"),Pp(e);if(Array.isArray(e))return e;throw new wt("Must be a string, Uint8Array, Component[], or another Multiaddr")}var os=class e{[Vu]=!0;#t;#e;#r;constructor(t="/",r={}){this.#t=v1(t),r.validate!==!1&&A1(this)}get bytes(){return this.#r==null&&(this.#r=Fp(this.#t)),this.#r}toString(){return this.#e==null&&(this.#e=Op(this.#t)),this.#e}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 Qi(`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 ar(this.bytes,t.bytes)}[S1](){return`Multiaddr(${this.toString()})`}};function A1(e){e.getComponents().forEach(t=>{let r=Ve.getProtocol(t.code);t.value!=null&&r.validate?.(t.value)})}function kp(e){return!!e?.[Vu]}function is(e){return new os(e)}function In(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*Uo(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 PC=new Uint8Array(0);function Vp(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 T1(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var o=0;o<e.length;o++){var i=e.charAt(o),s=i.charCodeAt(0);if(r[s]!==255)throw new TypeError(i+" is ambiguous");r[s]=o}var a=e.length,c=e.charAt(0),u=Math.log(a)/Math.log(256),f=Math.log(256)/Math.log(a);function l(h){if(h instanceof Uint8Array||(ArrayBuffer.isView(h)?h=new Uint8Array(h.buffer,h.byteOffset,h.byteLength):Array.isArray(h)&&(h=Uint8Array.from(h))),!(h instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(h.length===0)return"";for(var g=0,m=0,y=0,E=h.length;y!==E&&h[y]===0;)y++,g++;for(var v=(E-y)*f+1>>>0,C=new Uint8Array(v);y!==E;){for(var B=h[y],U=0,I=v-1;(B!==0||U<m)&&I!==-1;I--,U++)B+=256*C[I]>>>0,C[I]=B%a>>>0,B=B/a>>>0;if(B!==0)throw new Error("Non-zero carry");m=U,y++}for(var b=v-m;b!==v&&C[b]===0;)b++;for(var D=c.repeat(g);b<v;++b)D+=e.charAt(C[b]);return D}function d(h){if(typeof h!="string")throw new TypeError("Expected String");if(h.length===0)return new Uint8Array;var g=0;if(h[g]!==" "){for(var m=0,y=0;h[g]===c;)m++,g++;for(var E=(h.length-g)*u+1>>>0,v=new Uint8Array(E);h[g];){var C=r[h.charCodeAt(g)];if(C===255)return;for(var B=0,U=E-1;(C!==0||B<y)&&U!==-1;U--,B++)C+=a*v[U]>>>0,v[U]=C%256>>>0,C=C/256>>>0;if(C!==0)throw new Error("Non-zero carry");y=B,g++}if(h[g]!==" "){for(var I=E-y;I!==E&&v[I]===0;)I++;for(var b=new Uint8Array(m+(E-I)),D=m;I!==E;)b[D++]=v[I++];return b}}}function x(h){var g=d(h);if(g)return g;throw new Error(`Non-${t} character`)}return{encode:l,decodeUnsafe:d,decode:x}}var C1=T1,I1=C1,Mp=I1;var Mu=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")}},$u=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 $p(this,t)}},Ku=class{decoders;constructor(t){this.decoders=t}or(t){return $p(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 $p(e,t){return new Ku({...e.decoders??{[e.prefix]:e},...t.decoders??{[t.prefix]:t}})}var zu=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 Mu(t,r,n),this.decoder=new $u(t,r,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function Kp({name:e,prefix:t,encode:r,decode:n}){return new zu(e,t,r,n)}function qu({name:e,prefix:t,alphabet:r}){let{encode:n,decode:o}=Mp(r,e);return Kp({prefix:t,name:e,encode:n,decode:i=>Vp(o(i))})}function B1(e,t,r,n){let o=e.length;for(;e[o-1]==="=";)--o;let i=new Uint8Array(o*r/8|0),s=0,a=0,c=0;for(let u=0;u<o;++u){let f=t[e[u]];if(f===void 0)throw new SyntaxError(`Non-${n} character`);a=a<<r|f,s+=r,s>=8&&(s-=8,i[c++]=255&a>>s)}if(s>=r||(255&a<<8-s)!==0)throw new SyntaxError("Unexpected end of data");return i}function D1(e,t,r){let n=t[t.length-1]==="=",o=(1<<r)-1,i="",s=0,a=0;for(let c=0;c<e.length;++c)for(a=a<<8|e[c],s+=8;s>r;)s-=r,i+=t[o&a>>s];if(s!==0&&(i+=t[o&a<<r-s]),n)for(;(i.length*r&7)!==0;)i+="=";return i}function _1(e){let t={};for(let r=0;r<e.length;++r)t[e[r]]=r;return t}function It({name:e,prefix:t,bitsPerChar:r,alphabet:n}){let o=_1(n);return Kp({prefix:t,name:e,encode(i){return D1(i,n,r)},decode(i){return B1(i,o,r,e)}})}var zp=It({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),zC=It({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),qC=It({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),HC=It({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),jC=It({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),GC=It({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),YC=It({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),ZC=It({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),XC=It({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var qp=qu({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),QC=qu({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Hp=It({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),rI=It({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),nI=It({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),oI=It({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});function L1(e,t){if(typeof e=="string")return U1(e);if(typeof e=="number")return F1(e,t);throw Error(`Value provided to ms() must be a string or number. value=${JSON.stringify(e)}`)}var ss=L1;function U1(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 R1(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 N1(e){let t=Math.abs(e);return t>=315576e5?Rr(e,t,315576e5,"year"):t>=26298e5?Rr(e,t,26298e5,"month"):t>=6048e5?Rr(e,t,6048e5,"week"):t>=864e5?Rr(e,t,864e5,"day"):t>=36e5?Rr(e,t,36e5,"hour"):t>=6e4?Rr(e,t,6e4,"minute"):t>=1e3?Rr(e,t,1e3,"second"):`${e} ms`}function F1(e,t){if(typeof e!="number"||!Number.isFinite(e))throw Error("Value provided to ms.format() must be of type number.");return t?.long?N1(e):R1(e)}function Rr(e,t,r,n){let o=t>=r*1.5;return`${Math.round(e/r)} ${n}${o?"s":""}`}function Hu(e){r.debug=r,r.default=r,r.coerce=c,r.disable=i,r.enable=o,r.enabled=s,r.humanize=ss,r.destroy=u,Object.keys(e).forEach(f=>{r[f]=e[f]}),r.names=[],r.skips=[],r.formatters={};function t(f){let l=0;for(let d=0;d<f.length;d++)l=(l<<5)-l+f.charCodeAt(d),l|=0;return r.colors[Math.abs(l)%r.colors.length]}r.selectColor=t;function r(f,l){let d,x=null,h,g;function m(...y){if(!m.enabled)return;let E=m,v=Number(new Date),C=v-(d||v);E.diff=C,E.prev=d,E.curr=v,d=v,y[0]=r.coerce(y[0]),typeof y[0]!="string"&&y.unshift("%O");let B=0;y[0]=y[0].replace(/%([a-zA-Z%])/g,(I,b)=>{if(I==="%%")return"%";B++;let D=r.formatters[b];if(typeof D=="function"){let k=y[B];I=D.call(E,k),y.splice(B,1),B--}return I}),r.formatArgs.call(E,y),l?.onLog!=null&&l.onLog(...y),(E.log||r.log).apply(E,y)}return m.namespace=f,m.useColors=r.useColors(),m.color=r.selectColor(f),m.extend=n,m.destroy=r.destroy,Object.defineProperty(m,"enabled",{enumerable:!0,configurable:!1,get:()=>x!==null?x:(h!==r.namespaces&&(h=r.namespaces,g=r.enabled(f)),g),set:y=>{x=y}}),typeof r.init=="function"&&r.init(m),m}function n(f,l){let d=r(this.namespace+(typeof l>"u"?":":l)+f);return d.log=this.log,d}function o(f){r.save(f),r.namespaces=f,r.names=[],r.skips=[];let l,d=(typeof f=="string"?f:"").split(/[\s,]+/),x=d.length;for(l=0;l<x;l++)d[l]&&(f=d[l].replace(/\*/g,".*?"),f[0]==="-"?r.skips.push(new RegExp("^"+f.substr(1)+"$")):r.names.push(new RegExp("^"+f+"$")))}function i(){let f=[...r.names.map(a),...r.skips.map(a).map(l=>"-"+l)].join(",");return r.enable(""),f}function s(f){if(f[f.length-1]==="*")return!0;let l,d;for(l=0,d=r.skips.length;l<d;l++)if(r.skips[l].test(f))return!1;for(l=0,d=r.names.length;l<d;l++)if(r.names[l].test(f))return!0;return!1}function a(f){return f.toString().substring(2,f.toString().length-2).replace(/\.\*\?$/,"*")}function c(f){return f instanceof Error?f.stack??f.message:f}function u(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return r.setupFormatters(r.formatters),r.enable(r.load()),r}var as=K1(),P1=["#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 O1(){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 k1(e){if(e[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+e[0]+(this.useColors?"%c ":" ")+"+"+ss(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 V1=console.debug??console.log??(()=>{});function M1(e){try{e?as?.setItem("debug",e):as?.removeItem("debug")}catch{}}function $1(){let e;try{e=as?.getItem("debug")}catch{}return!e&&typeof globalThis.process<"u"&&"env"in globalThis.process&&(e=globalThis.process.env.DEBUG),e}function K1(){try{return localStorage}catch{}}function z1(e){e.j=function(t){try{return JSON.stringify(t)}catch(r){return"[UnexpectedJSONParseError]: "+r.message}}}var jp=Hu({formatArgs:k1,save:M1,load:$1,useColors:O1,setupFormatters:z1,colors:P1,storage:as,log:V1});var Pt=jp;Pt.formatters.b=e=>e==null?"undefined":qp.baseEncode(e);Pt.formatters.t=e=>e==null?"undefined":zp.baseEncode(e);Pt.formatters.m=e=>e==null?"undefined":Hp.baseEncode(e);Pt.formatters.p=e=>e==null?"undefined":e.toString();Pt.formatters.c=e=>e==null?"undefined":e.toString();Pt.formatters.k=e=>e==null?"undefined":e.toString();Pt.formatters.a=e=>e==null?"undefined":e.toString();function Gp(e,t=""){let r=Yp(e.message),n=Yp(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 l0(e){return e instanceof AggregateError||e?.name==="AggregateError"&&Array.isArray(e.errors)}function Mu(e,t=""){if(l0(e)){let r=Ku(e,t);return e.errors.length>0?(t=`${t} `,r+=`
11
- ${t}${e.errors.map(n=>`${Mu(n,`${t}`)}`).join(`
10
+ ${t}`)}`:r!=null?`${r}`:`${e.toString()}`}function q1(e){return e instanceof AggregateError||e?.name==="AggregateError"&&Array.isArray(e.errors)}function Zp(e,t=""){if(q1(e)){let r=Gp(e,t);return e.errors.length>0?(t=`${t} `,r+=`
11
+ ${t}${e.errors.map(n=>`${Zp(n,`${t}`)}`).join(`
12
12
  ${t}`)}`):r+=`
13
- ${t}[Error list was empty]`,r.trim()}return Ku(e,t)}Ct.formatters.e=e=>e==null?"undefined":Mu(e);function d0(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 Xe(e,t){let r=d0(`${e}:trace`);return Ct.enabled(`${e}:trace`)&&Ct.names.map(n=>n.toString()).find(n=>n.includes(":trace"))!=null&&(r=Ct(`${e}:trace`,t)),Object.assign(Ct(e,t),{error:Ct(`${e}:error`,t),trace:r,newScope:n=>Xe(`${e}:${n}`,t)})}function $u(e){if(e!=null&&(e=e.trim(),e.length!==0))return e}var Z0=Go(js(),1);var Gt=class extends Error{static name="SignatureVerificationError";constructor(t="Record signature verification failed"){super(t),this.name="SignatureVerificationError"}},wo=class extends Error{static name="RecordExpiredError";constructor(t="Record has expired"){super(t),this.name="RecordExpiredError"}},Rr=class extends Error{static name="UnsupportedValidityError";constructor(t="The validity type is unsupported"){super(t),this.name="UnsupportedValidityError"}},Eo=class extends Error{static name="RecordTooLargeError";constructor(t="The record is too large"){super(t),this.name="RecordTooLargeError"}},So=class extends Error{static name="InvalidValueError";constructor(t="Value must be a valid content path starting with /"){super(t),this.name="InvalidValueError"}},vo=class extends Error{static name="InvalidRecordDataError";constructor(t="Invalid record data"){super(t),this.name="InvalidRecordDataError"}},yn=class extends Error{static name="InvalidEmbeddedPublicKeyError";constructor(t="Invalid embedded public key"){super(t),this.name="InvalidEmbeddedPublicKeyError"}};var Wt;(function(e){let t;(function(a){a.EOL="EOL"})(t=e.ValidityType||(e.ValidityType={}));let r;(function(a){a[a.EOL=0]="EOL"})(r||(r={})),(function(a){a.codec=()=>un(r)})(t=e.ValidityType||(e.ValidityType={}));let n;e.codec=()=>(n==null&&(n=Ar((a,c,u={})=>{u.lengthDelimited!==!1&&c.fork(),a.value!=null&&(c.uint32(10),c.bytes(a.value)),a.signatureV1!=null&&(c.uint32(18),c.bytes(a.signatureV1)),a.validityType!=null&&(c.uint32(24),e.ValidityType.codec().encode(a.validityType,c)),a.validity!=null&&(c.uint32(34),c.bytes(a.validity)),a.sequence!=null&&(c.uint32(40),c.uint64(a.sequence)),a.ttl!=null&&(c.uint32(48),c.uint64(a.ttl)),a.pubKey!=null&&(c.uint32(58),c.bytes(a.pubKey)),a.signatureV2!=null&&(c.uint32(66),c.bytes(a.signatureV2)),a.data!=null&&(c.uint32(74),c.bytes(a.data)),u.lengthDelimited!==!1&&c.ldelim()},(a,c,u={})=>{let f={},l=c==null?a.len:a.pos+c;for(;a.pos<l;){let h=a.uint32();switch(h>>>3){case 1:{f.value=a.bytes();break}case 2:{f.signatureV1=a.bytes();break}case 3:{f.validityType=e.ValidityType.codec().decode(a);break}case 4:{f.validity=a.bytes();break}case 5:{f.sequence=a.uint64();break}case 6:{f.ttl=a.uint64();break}case 7:{f.pubKey=a.bytes();break}case 8:{f.signatureV2=a.bytes();break}case 9:{f.data=a.bytes();break}default:{a.skipType(h&7);break}}}return f},function*(a,c,u,f={}){let l=c==null?a.len:a.pos+c;for(;a.pos<l;){let h=a.uint32();switch(h>>>3){case 1:{yield{field:`${u}.value`,value:a.bytes()};break}case 2:{yield{field:`${u}.signatureV1`,value:a.bytes()};break}case 3:{yield{field:`${u}.validityType`,value:e.ValidityType.codec().decode(a)};break}case 4:{yield{field:`${u}.validity`,value:a.bytes()};break}case 5:{yield{field:`${u}.sequence`,value:a.uint64()};break}case 6:{yield{field:`${u}.ttl`,value:a.uint64()};break}case 7:{yield{field:`${u}.pubKey`,value:a.bytes()};break}case 8:{yield{field:`${u}.signatureV2`,value:a.bytes()};break}case 9:{yield{field:`${u}.data`,value:a.bytes()};break}default:{a.skipType(h&7);break}}}})),n);function o(a){return vr(a,e.codec())}e.encode=o;function i(a,c){return Sr(a,e.codec(),c)}e.decode=i;function s(a,c){return Tr(a,e.codec(),c)}e.stream=s})(Wt||(Wt={}));var h0=["Object","RegExp","Date","Error","Map","Set","WeakMap","WeakSet","ArrayBuffer","SharedArrayBuffer","DataView","Promise","URL","HTMLElement","Int8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","BigInt64Array","BigUint64Array","Tagged"];function Vu(e){if(e===null)return"null";if(e===void 0)return"undefined";if(e===!0||e===!1)return"boolean";let t=typeof e;if(t==="string"||t==="number"||t==="bigint"||t==="symbol")return t;if(t==="function")return"Function";if(Array.isArray(e))return"Array";if(e instanceof Uint8Array)return"Uint8Array";if(e.constructor===Object)return"Object";let r=p0(e);return r||"Object"}function p0(e){let t=Object.prototype.toString.call(e).slice(8,-1);if(h0.includes(t))return t}var p=class{constructor(t,r,n){this.major=t,this.majorEncoded=t<<5,this.name=r,this.terminal=n}toString(){return`Type[${this.major}].${this.name}`}compare(t){return this.major<t.major?-1:this.major>t.major?1:0}static equals(t,r){return t===r||t.major===r.major&&t.name===r.name}};p.uint=new p(0,"uint",!0);p.negint=new p(1,"negint",!0);p.bytes=new p(2,"bytes",!0);p.string=new p(3,"string",!0);p.array=new p(4,"array",!1);p.map=new p(5,"map",!1);p.tag=new p(6,"tag",!1);p.float=new p(7,"float",!0);p.false=new p(7,"false",!0);p.true=new p(7,"true",!0);p.null=new p(7,"null",!0);p.undefined=new p(7,"undefined",!0);p.break=new p(7,"break",!0);var O=class{constructor(t,r,n){this.type=t,this.value=r,this.encodedLength=n,this.encodedBytes=void 0,this.byteValue=void 0}toString(){return`Token[${this.type}].${this.value}`}};var gn=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&typeof globalThis.Buffer.isBuffer=="function",m0=new TextEncoder;function To(e){return gn&&globalThis.Buffer.isBuffer(e)}function bn(e){return e instanceof Uint8Array?To(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e:Uint8Array.from(e)}var y0=24,g0=200,Ys=gn?e=>e.length>=y0?globalThis.Buffer.from(e):qu(e):e=>e.length>=g0?m0.encode(e):qu(e),ae=e=>Uint8Array.from(e),zu=gn?(e,t,r)=>To(e)?new Uint8Array(e.subarray(t,r)):e.slice(t,r):(e,t,r)=>e.slice(t,r),Hu=gn?(e,t)=>(e=e.map(r=>r instanceof Uint8Array?r:globalThis.Buffer.from(r)),bn(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},ju=gn?e=>globalThis.Buffer.allocUnsafe(e):e=>new Uint8Array(e);function Ao(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 qu(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):(o>=55296&&o<=57343&&(o=65533),t[r++]=o>>12|224,t[r++]=o>>6&63|128,t[r++]=o&63|128)}return t}var b0=256,xn=class{constructor(t=b0){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=ju(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=zu(n,0,this.cursor)}else r=Hu(this.chunks,this.cursor);return t&&this.reset(),r}},Io=class{constructor(t){this.dest=t,this.cursor=0,this.chunks=[t]}reset(){this.cursor=0}push(t){if(this.cursor+t.length>this.dest.length)throw new Error("write out of bounds, destination buffer is too small");this.dest.set(t,this.cursor),this.cursor+=t.length}toBytes(t=!1){let r=this.dest.subarray(0,this.cursor);return t&&this.reset(),r}};var K="CBOR decode error:",Zs="CBOR encode error:",wn=[];wn[23]=1;wn[24]=2;wn[25]=3;wn[26]=5;wn[27]=9;function xe(e,t,r){if(e.length-t<r)throw new Error(`${K} not enough data for type`)}var ht=[24,256,65536,4294967296,BigInt("18446744073709551616")];function Pt(e,t,r){xe(e,t,1);let n=e[t];if(r.strict===!0&&n<ht[0])throw new Error(`${K} integer encoded in more bytes than necessary (strict decode)`);return n}function Ot(e,t,r){xe(e,t,2);let n=e[t]<<8|e[t+1];if(r.strict===!0&&n<ht[1])throw new Error(`${K} integer encoded in more bytes than necessary (strict decode)`);return n}function Ft(e,t,r){xe(e,t,4);let n=e[t]*16777216+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3];if(r.strict===!0&&n<ht[2])throw new Error(`${K} integer encoded in more bytes than necessary (strict decode)`);return n}function Lt(e,t,r){xe(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<ht[3])throw new Error(`${K} 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(`${K} integers outside of the safe integer range are not supported`)}function Yu(e,t,r,n){return new O(p.uint,Pt(e,t+1,n),2)}function Zu(e,t,r,n){return new O(p.uint,Ot(e,t+1,n),3)}function Gu(e,t,r,n){return new O(p.uint,Ft(e,t+1,n),5)}function Wu(e,t,r,n){return new O(p.uint,Lt(e,t+1,n),9)}function kt(e,t){return pt(e,0,t.value)}function pt(e,t,r){if(r<ht[0]){let n=Number(r);e.push([t|n])}else if(r<ht[1]){let n=Number(r);e.push([t|24,n])}else if(r<ht[2]){let n=Number(r);e.push([t|25,n>>>8,n&255])}else if(r<ht[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<ht[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(`${K} encountered BigInt larger than allowable range`)}}kt.encodedSize=function(t){return pt.encodedSize(t.value)};pt.encodedSize=function(t){return t<ht[0]?1:t<ht[1]?2:t<ht[2]?3:t<ht[3]?5:9};kt.compareTokens=function(t,r){return t.value<r.value?-1:t.value>r.value?1:0};function Xu(e,t,r,n){return new O(p.negint,-1-Pt(e,t+1,n),2)}function Ju(e,t,r,n){return new O(p.negint,-1-Ot(e,t+1,n),3)}function Qu(e,t,r,n){return new O(p.negint,-1-Ft(e,t+1,n),5)}var Gs=BigInt(-1),tf=BigInt(1);function ef(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 O(p.negint,i,9)}if(n.allowBigInt!==!0)throw new Error(`${K} integers outside of the safe integer range are not supported`);return new O(p.negint,Gs-BigInt(o),9)}function Co(e,t){let r=t.value,n=typeof r=="bigint"?r*Gs-tf:r*-1-1;pt(e,t.type.majorEncoded,n)}Co.encodedSize=function(t){let r=t.value,n=typeof r=="bigint"?r*Gs-tf:r*-1-1;return n<ht[0]?1:n<ht[1]?2:n<ht[2]?3:n<ht[3]?5:9};Co.compareTokens=function(t,r){return t.value<r.value?1:t.value>r.value?-1:0};function En(e,t,r,n){xe(e,t,r+n);let o=e.slice(t+r,t+r+n);return new O(p.bytes,o,r+n)}function rf(e,t,r,n){return En(e,t,1,r)}function nf(e,t,r,n){return En(e,t,2,Pt(e,t+1,n))}function of(e,t,r,n){return En(e,t,3,Ot(e,t+1,n))}function sf(e,t,r,n){return En(e,t,5,Ft(e,t+1,n))}function af(e,t,r,n){let o=Lt(e,t+1,n);if(typeof o=="bigint")throw new Error(`${K} 64-bit integer bytes lengths not supported`);return En(e,t,9,o)}function _o(e){return e.encodedBytes===void 0&&(e.encodedBytes=p.equals(e.type,p.string)?Ys(e.value):e.value),e.encodedBytes}function Dr(e,t){let r=_o(t);pt(e,t.type.majorEncoded,r.length),e.push(r)}Dr.encodedSize=function(t){let r=_o(t);return pt.encodedSize(r.length)+r.length};Dr.compareTokens=function(t,r){return w0(_o(t),_o(r))};function w0(e,t){return e.length<t.length?-1:e.length>t.length?1:Ao(e,t)}var cf=new TextDecoder,S0=32;function v0(e,t,r){if(r-t<S0){let o="";for(let i=t;i<r;i++){let s=e[i];if(s&128)return cf.decode(e.subarray(t,r));o+=String.fromCharCode(s)}return o}return cf.decode(e.subarray(t,r))}function Sn(e,t,r,n,o){let i=r+n;xe(e,t,i);let s=new O(p.string,v0(e,t+r,t+i),i);return o.retainStringBytes===!0&&(s.byteValue=e.slice(t+r,t+i)),s}function uf(e,t,r,n){return Sn(e,t,1,r,n)}function ff(e,t,r,n){return Sn(e,t,2,Pt(e,t+1,n),n)}function lf(e,t,r,n){return Sn(e,t,3,Ot(e,t+1,n),n)}function df(e,t,r,n){return Sn(e,t,5,Ft(e,t+1,n),n)}function hf(e,t,r,n){let o=Lt(e,t+1,n);if(typeof o=="bigint")throw new Error(`${K} 64-bit integer string lengths not supported`);return Sn(e,t,9,o,n)}var pf=Dr;function Pr(e,t,r,n){return new O(p.array,n,r)}function mf(e,t,r,n){return Pr(e,t,1,r)}function yf(e,t,r,n){return Pr(e,t,2,Pt(e,t+1,n))}function gf(e,t,r,n){return Pr(e,t,3,Ot(e,t+1,n))}function bf(e,t,r,n){return Pr(e,t,5,Ft(e,t+1,n))}function xf(e,t,r,n){let o=Lt(e,t+1,n);if(typeof o=="bigint")throw new Error(`${K} 64-bit integer array lengths not supported`);return Pr(e,t,9,o)}function wf(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${K} indefinite length items not allowed`);return Pr(e,t,1,1/0)}function Bo(e,t){pt(e,p.array.majorEncoded,t.value)}Bo.compareTokens=kt.compareTokens;Bo.encodedSize=function(t){return pt.encodedSize(t.value)};function Or(e,t,r,n){return new O(p.map,n,r)}function Ef(e,t,r,n){return Or(e,t,1,r)}function Sf(e,t,r,n){return Or(e,t,2,Pt(e,t+1,n))}function vf(e,t,r,n){return Or(e,t,3,Ot(e,t+1,n))}function Tf(e,t,r,n){return Or(e,t,5,Ft(e,t+1,n))}function Af(e,t,r,n){let o=Lt(e,t+1,n);if(typeof o=="bigint")throw new Error(`${K} 64-bit integer map lengths not supported`);return Or(e,t,9,o)}function If(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${K} indefinite length items not allowed`);return Or(e,t,1,1/0)}function Ro(e,t){pt(e,p.map.majorEncoded,t.value)}Ro.compareTokens=kt.compareTokens;Ro.encodedSize=function(t){return pt.encodedSize(t.value)};function Cf(e,t,r,n){return new O(p.tag,r,1)}function _f(e,t,r,n){return new O(p.tag,Pt(e,t+1,n),2)}function Bf(e,t,r,n){return new O(p.tag,Ot(e,t+1,n),3)}function Rf(e,t,r,n){return new O(p.tag,Ft(e,t+1,n),5)}function Df(e,t,r,n){return new O(p.tag,Lt(e,t+1,n),9)}function Do(e,t){pt(e,p.tag.majorEncoded,t.value)}Do.compareTokens=kt.compareTokens;Do.encodedSize=function(t){return pt.encodedSize(t.value)};var Ws=20,Xs=21,Js=22,Qs=23;function Pf(e,t,r,n){if(n.allowUndefined===!1)throw new Error(`${K} undefined values are not supported`);return n.coerceUndefinedToNull===!0?new O(p.null,null,1):new O(p.undefined,void 0,1)}function Of(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${K} indefinite length items not allowed`);return new O(p.break,void 0,1)}function ta(e,t,r){if(r){if(r.allowNaN===!1&&Number.isNaN(e))throw new Error(`${K} NaN values are not supported`);if(r.allowInfinity===!1&&(e===1/0||e===-1/0))throw new Error(`${K} Infinity values are not supported`)}return new O(p.float,e,t)}function Ff(e,t,r,n){return ta(ea(e,t+1),3,n)}function Lf(e,t,r,n){return ta(ra(e,t+1),5,n)}function Nf(e,t,r,n){return ta($f(e,t+1),9,n)}function Po(e,t,r){let n=t.value;if(n===!1)e.push([p.float.majorEncoded|Ws]);else if(n===!0)e.push([p.float.majorEncoded|Xs]);else if(n===null)e.push([p.float.majorEncoded|Js]);else if(n===void 0)e.push([p.float.majorEncoded|Qs]);else{let o,i=!1;(!r||r.float64!==!0)&&(kf(n),o=ea(Xt,1),n===o||Number.isNaN(n)?(Xt[0]=249,e.push(Xt.slice(0,3)),i=!0):(Kf(n),o=ra(Xt,1),n===o&&(Xt[0]=250,e.push(Xt.slice(0,5)),i=!0))),i||(_0(n),o=$f(Xt,1),Xt[0]=251,e.push(Xt.slice(0,9)))}}Po.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){kf(n);let o=ea(Xt,1);if(n===o||Number.isNaN(n))return 3;if(Kf(n),o=ra(Xt,1),n===o)return 5}return 9};var Uf=new ArrayBuffer(9),Kt=new DataView(Uf,1),Xt=new Uint8Array(Uf,0);function kf(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,(t&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 ea(e,t){if(e.length-t<2)throw new Error(`${K} 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 Kf(e){Kt.setFloat32(0,e,!1)}function ra(e,t){if(e.length-t<4)throw new Error(`${K} not enough data for float32`);let r=(e.byteOffset||0)+t;return new DataView(e.buffer,r,4).getFloat32(0,!1)}function _0(e){Kt.setFloat64(0,e,!1)}function $f(e,t){if(e.length-t<8)throw new Error(`${K} not enough data for float64`);let r=(e.byteOffset||0)+t;return new DataView(e.buffer,r,8).getFloat64(0,!1)}Po.compareTokens=kt.compareTokens;function Z(e,t,r){throw new Error(`${K} encountered invalid minor (${r}) for major ${e[t]>>>5}`)}function Oo(e){return()=>{throw new Error(`${K} ${e}`)}}var B=[];for(let e=0;e<=23;e++)B[e]=Z;B[24]=Yu;B[25]=Zu;B[26]=Gu;B[27]=Wu;B[28]=Z;B[29]=Z;B[30]=Z;B[31]=Z;for(let e=32;e<=55;e++)B[e]=Z;B[56]=Xu;B[57]=Ju;B[58]=Qu;B[59]=ef;B[60]=Z;B[61]=Z;B[62]=Z;B[63]=Z;for(let e=64;e<=87;e++)B[e]=rf;B[88]=nf;B[89]=of;B[90]=sf;B[91]=af;B[92]=Z;B[93]=Z;B[94]=Z;B[95]=Oo("indefinite length bytes/strings are not supported");for(let e=96;e<=119;e++)B[e]=uf;B[120]=ff;B[121]=lf;B[122]=df;B[123]=hf;B[124]=Z;B[125]=Z;B[126]=Z;B[127]=Oo("indefinite length bytes/strings are not supported");for(let e=128;e<=151;e++)B[e]=mf;B[152]=yf;B[153]=gf;B[154]=bf;B[155]=xf;B[156]=Z;B[157]=Z;B[158]=Z;B[159]=wf;for(let e=160;e<=183;e++)B[e]=Ef;B[184]=Sf;B[185]=vf;B[186]=Tf;B[187]=Af;B[188]=Z;B[189]=Z;B[190]=Z;B[191]=If;for(let e=192;e<=215;e++)B[e]=Cf;B[216]=_f;B[217]=Bf;B[218]=Rf;B[219]=Df;B[220]=Z;B[221]=Z;B[222]=Z;B[223]=Z;for(let e=224;e<=243;e++)B[e]=Oo("simple values are not supported");B[244]=Z;B[245]=Z;B[246]=Z;B[247]=Pf;B[248]=Oo("simple values are not supported");B[249]=Ff;B[250]=Lf;B[251]=Nf;B[252]=Z;B[253]=Z;B[254]=Z;B[255]=Of;var Jt=[];for(let e=0;e<24;e++)Jt[e]=new O(p.uint,e,1);for(let e=-1;e>=-24;e--)Jt[31-e]=new O(p.negint,e,1);Jt[64]=new O(p.bytes,new Uint8Array(0),1);Jt[96]=new O(p.string,"",1);Jt[128]=new O(p.array,0,1);Jt[160]=new O(p.map,0,1);Jt[244]=new O(p.false,!1,1);Jt[245]=new O(p.true,!0,1);Jt[246]=new O(p.null,null,1);function Mf(e){switch(e.type){case p.false:return ae([244]);case p.true:return ae([245]);case p.null:return ae([246]);case p.bytes:return e.value.length?void 0:ae([64]);case p.string:return e.value===""?ae([96]):void 0;case p.array:return e.value===0?ae([128]):void 0;case p.map:return e.value===0?ae([160]):void 0;case p.uint:return e.value<24?ae([Number(e.value)]):void 0;case p.negint:if(e.value>=-24)return ae([31-Number(e.value)])}}var qf=Object.freeze({float64:!0,mapSorter:F0,quickEncodeToken:Mf});function R0(){let e=[];return e[p.uint.major]=kt,e[p.negint.major]=Co,e[p.bytes.major]=Dr,e[p.string.major]=pf,e[p.array.major]=Bo,e[p.map.major]=Ro,e[p.tag.major]=Do,e[p.float.major]=Po,e}var D0=R0(),P0=new xn,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(`${Zs} object contains circular references`);return new e(r,t)}},Fe={null:new O(p.null,null),undefined:new O(p.undefined,void 0),true:new O(p.true,!0),false:new O(p.false,!1),emptyArray:new O(p.array,0),emptyMap:new O(p.map,0)},Le={number(e,t,r,n){return!Number.isInteger(e)||!Number.isSafeInteger(e)?new O(p.float,e):e>=0?new O(p.uint,e):new O(p.negint,e)},bigint(e,t,r,n){return e>=BigInt(0)?new O(p.uint,e):new O(p.negint,e)},Uint8Array(e,t,r,n){return new O(p.bytes,e)},string(e,t,r,n){return new O(p.string,e)},boolean(e,t,r,n){return e?Fe.true:Fe.false},null(e,t,r,n){return Fe.null},undefined(e,t,r,n){return Fe.undefined},ArrayBuffer(e,t,r,n){return new O(p.bytes,new Uint8Array(e))},DataView(e,t,r,n){return new O(p.bytes,new Uint8Array(e.buffer,e.byteOffset,e.byteLength))},Array(e,t,r,n){if(!e.length)return r.addBreakTokens===!0?[Fe.emptyArray,new O(p.break)]:Fe.emptyArray;n=Fo.createCheck(n,e);let o=[],i=0;for(let s of e)o[i++]=Fr(s,r,n);return r.addBreakTokens?[new O(p.array,e.length),o,new O(p.break)]:[new O(p.array,e.length),o]},Object(e,t,r,n){let o=t!=="Object",i=o?e.keys():Object.keys(e),s=o?e.size:i.length,a;if(s){a=new Array(s),n=Fo.createCheck(n,e);let c=!o&&r.ignoreUndefinedProperties,u=0;for(let f of i){let l=o?e.get(f):e[f];c&&l===void 0||(a[u++]=[Fr(f,r,n),Fr(l,r,n)])}u<s&&(a.length=u)}return a?.length?(O0(a,r),r.addBreakTokens?[new O(p.map,a.length),a,new O(p.break)]:[new O(p.map,a.length),a]):r.addBreakTokens===!0?[Fe.emptyMap,new O(p.break)]:Fe.emptyMap},Tagged(e,t,r,n){return[new O(p.tag,e.tag),Fr(e.value,r,n)]}};Le.Map=Le.Object;Le.Buffer=Le.Uint8Array;for(let e of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))Le[`${e}Array`]=Le.DataView;function Fr(e,t={},r){let n=Vu(e),o=t&&t.typeEncoders&&t.typeEncoders[n]||Le[n];if(typeof o=="function"){let s=o(e,n,t,r);if(s!=null)return s}let i=Le[n];if(!i)throw new Error(`${Zs} unsupported type: ${n}`);return i(e,n,t,r)}function O0(e,t){t.mapSorter&&e.sort(t.mapSorter)}function F0(e,t){if(e[0]instanceof O&&t[0]instanceof O){let r=e[0],n=t[0];return r._keyBytes||(r._keyBytes=Vf(r.value)),n._keyBytes||(n._keyBytes=Vf(n.value)),Ao(r._keyBytes,n._keyBytes)}throw new Error("rfc8949MapSorter: complex key types are not supported yet")}function Vf(e){return L0(e,D0,qf)}function zf(e,t,r,n){if(Array.isArray(t))for(let o of t)zf(e,o,r,n);else r[t.type.major](e,t,n)}var l2=p.uint.majorEncoded,d2=p.negint.majorEncoded,h2=p.bytes.majorEncoded,p2=p.string.majorEncoded,m2=p.array.majorEncoded,y2=p.float.majorEncoded|Ws,g2=p.float.majorEncoded|Xs,b2=p.float.majorEncoded|Js,x2=p.float.majorEncoded|Qs,w2=BigInt(-1),E2=BigInt(1);function L0(e,t,r,n){let o=n instanceof Uint8Array,i=o?new Io(n):P0,s=Fr(e,r);if(!Array.isArray(s)&&r.quickEncodeToken){let a=r.quickEncodeToken(s);if(a)return o?(i.push(a),i.toBytes()):a;let c=t[s.type.major];if(c.encodedSize){let u=c.encodedSize(s,r);if(o||(i=new xn(u)),c(i,s,r),i.chunks.length!==1)throw new Error(`Unexpected error: pre-calculated length for ${s} was wrong`);return o?i.toBytes():bn(i.chunks[0])}}return i.reset(),zf(i,s,t,r),i.toBytes(!0)}var N0={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=Jt[t];if(r===void 0){let n=B[t];if(!n)throw new Error(`${K} 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}},Ne=Symbol.for("DONE"),Lr=Symbol.for("BREAK");function U0(e,t,r){let n=[];for(let o=0;o<e.value;o++){let i=Ue(t,r);if(i===Lr){if(e.value===1/0)break;throw new Error(`${K} got unexpected break to lengthed array`)}if(i===Ne)throw new Error(`${K} found array but not enough entries (got ${o}, expected ${e.value})`);n[o]=i}return n}function k0(e,t,r){let n=r.useMaps===!0,o=r.rejectDuplicateMapKeys===!0,i=n?void 0:{},s=n?new Map:void 0;for(let a=0;a<e.value;a++){let c=Ue(t,r);if(c===Lr){if(e.value===1/0)break;throw new Error(`${K} got unexpected break to lengthed map`)}if(c===Ne)throw new Error(`${K} found map but not enough entries (got ${a} [no key], expected ${e.value})`);if(!n&&typeof c!="string")throw new Error(`${K} non-string keys not supported (got ${typeof c})`);if(o&&(n&&s.has(c)||!n&&Object.hasOwn(i,c)))throw new Error(`${K} found repeat map key "${c}"`);let u=Ue(t,r);if(u===Ne)throw new Error(`${K} found map but not enough entries (got ${a} [no value], expected ${e.value})`);n?s.set(c,u):i[c]=u}return n?s:i}function*K0(e,t,r){for(let n=0;n<e.value;n++){let o=Ue(t,r);if(o===Lr){if(e.value===1/0)break;throw new Error(`${K} got unexpected break to lengthed map`)}if(o===Ne)throw new Error(`${K} found map but not enough entries (got ${n} [no key], expected ${e.value})`);let i=Ue(t,r);if(i===Ne)throw new Error(`${K} found map but not enough entries (got ${n} [no value], expected ${e.value})`);yield[o,i]}}function $0(e,t){let r=!1,n=function(){if(r)throw new Error(`${K} tag decode() may only be called once`);r=!0;let o=Ue(e,t);if(o===Ne)throw new Error(`${K} tag content missing`);if(o===Lr)throw new Error(`${K} got unexpected break in tag content`);return o};return n.entries=function(){if(r)throw new Error(`${K} tag decode() may only be called once`);r=!0;let o=e.next();if(!p.equals(o.type,p.map))throw new Error(`${K} entries() requires map content, got ${o.type.name}`);let i=[];for(let s of K0(o,e,t))i.push(s);return i},Object.defineProperty(n,"_called",{get(){return r},enumerable:!1}),n}function Ue(e,t){if(e.done())return Ne;let r=e.next();if(p.equals(r.type,p.break))return Lr;if(r.type.terminal)return r.value;if(p.equals(r.type,p.array))return U0(r,e,t);if(p.equals(r.type,p.map))return k0(r,e,t);if(p.equals(r.type,p.tag)){if(t.tags&&typeof t.tags[r.value]=="function"){let n=$0(e,t),o=t.tags[r.value](n);if(!n._called)throw new Error(`${K} tag decoder must call decode() or entries()`);return o}throw new Error(`${K} tag not supported (${r.value})`)}throw new Error("unsupported")}function Hf(e,t){if(!(e instanceof Uint8Array))throw new Error(`${K} data to decode must be a Uint8Array`);t=Object.assign({},N0,t);let r=bn(e),n=t.tokenizer||new Lo(r,t),o=Ue(n,t);if(o===Ne)throw new Error(`${K} did not find any content to decode`);if(o===Lr)throw new Error(`${K} got unexpected break`);return[o,e.subarray(n.pos())]}function na(e,t){let[r,n]=Hf(e,t);if(n.length>0)throw new Error(`${K} too many terminals, data makes no sense`);return r}var No=class e{constructor(t,r){if(typeof t!="number"||!Number.isInteger(t)||t<0)throw new TypeError("Tagged: tag must be a non-negative integer");this.tag=t,this.value=r}static decoder(t){return r=>new e(t,r())}static preserve(...t){let r={};for(let n of t)r[n]=e.decoder(n);return r}};Object.defineProperty(No.prototype,Symbol.toStringTag,{value:"Tagged"});var q0=Xe("ipns:utils"),jf=V("/ipns/");var z0=0,H0=18;function Yf(e){let t;if(e.pubKey!=null)try{t=bu(e.pubKey)}catch(r){throw q0.error(r),r}if(t!=null)return t}function Zf(e){let t=V("ipns-signature:");return Nt([t,e])}function Qe(e){return"signatureV1"in e?Wt.encode({value:V(e.value),signatureV1:e.signatureV1,validityType:e.validityType,validity:V(e.validity),sequence:e.sequence,ttl:e.ttl,pubKey:e.pubKey,signatureV2:e.signatureV2,data:e.data}):Wt.encode({pubKey:e.pubKey,signatureV2:e.signatureV2,data:e.data})}function ce(e){let t=Wt.decode(e);if(t.sequence!=null&&(t.sequence=BigInt(t.sequence)),t.ttl!=null&&(t.ttl=BigInt(t.ttl)),t.signatureV2==null||t.data==null)throw new Gt("Missing data or signatureV2");let r=Gf(t.data),n=j0(r.Value),o=z(r.Validity);if(t.value!=null&&t.signatureV1!=null)return Y0(t),{value:n,validityType:Wt.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:Wt.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 vn(e){return Nt([jf,e.bytes])}function we(e){let t=Se(e.slice(jf.length));if(!Uo(t,z0)&&!Uo(t,H0))throw new nr("Multihash in IPNS key was not identity or sha2-256");return t}function Gf(e){let t=na(e);if(t.ValidityType===0)t.ValidityType=Wt.ValidityType.EOL;else throw new Rr("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 j0(e){let t=z(e).trim();if(t.startsWith("/"))return t;try{return`/ipfs/${H.decode(e).toV1().toString()}`}catch{}try{return`/ipfs/${H.parse(t).toV1().toString()}`}catch{}throw new So("Value must be a valid content path starting with /")}function Y0(e){if(e.data==null)throw new vo("Record data is missing");let t=Gf(e.data);if(!W(t.Value,e.value??new Uint8Array(0)))throw new Gt('Field "value" did not match between protobuf and CBOR');if(!W(t.Validity,e.validity??new Uint8Array(0)))throw new Gt('Field "validity" did not match between protobuf and CBOR');if(t.ValidityType!==e.validityType)throw new Gt('Field "validityType" did not match between protobuf and CBOR');if(t.Sequence!==e.sequence)throw new Gt('Field "sequence" did not match between protobuf and CBOR');if(t.TTL!==e.ttl)throw new Gt('Field "ttl" did not match between protobuf and CBOR')}function Uo(e,t){return e.code===t}var Z2=Xe("ipns"),G2=300*1e9,G0="/ipns/",W2=G0.length;var Wf=Go(js(),1);var ko=Xe("ipns:validator"),W0=1024*10;async function X0(e,t){let r=ce(t),n;try{let o=Zf(r.data);n=await e.verify(o,r.signatureV2)}catch{n=!1}if(!n)throw ko.error("record signature verification failed"),new Gt("Record signature verification failed");if(r.validityType===Wt.ValidityType.EOL){if(Wf.default.fromString(r.validity).toDate().getTime()<Date.now())throw ko.error("record has expired"),new wo("record has expired")}else if(r.validityType!=null)throw ko.error("the validity type is unsupported"),new Rr("The validity type is unsupported");ko("ipns record for %s is valid",r.value)}async function Xf(e,t){if(t.byteLength>W0)throw new Eo("The record is too large");let r=we(e),n;Uo(r,0)&&(n=io(r));let o=ce(t),i=Yf(o)??n;if(i==null)throw new yn("Could not extract public key from IPNS record or routing key");let s=vn(i.toMultihash());if(!W(s,e))throw new yn("Embedded public key did not match routing key");await X0(i,t)}var Ko=class extends Error{name="InvalidMessageLengthError";code="ERR_INVALID_MESSAGE_LENGTH"};async function*Nr(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)),ur(i)&&(i=i.subarray()),o+=n.decode(i,{stream:!0}),o.length>(t?.maxMessageLength??o.length))throw new Ko("Incoming message too long");let s=o.split(r);o=s.pop()??"";for(let a=0;a<s.length;a++)yield JSON.parse(s[a])}o+=n.decode(),o!==""&&(yield JSON.parse(o))}function $t(){let e={};return e.promise=new Promise((t,r)=>{e.resolve=t,e.reject=r}),e}var ia=Go(Qf(),1);var sa=class e extends Error{name="TimeoutError";constructor(t,r){super(t,r),Error.captureStackTrace?.(this,e)}},tl=e=>e.reason??new DOMException("This operation was aborted.","AbortError");function aa(e,t){let{milliseconds:r,fallback:n,message:o,customTimers:i={setTimeout,clearTimeout},signal:s}=t,a,c,f=new Promise((l,h)=>{if(typeof r!="number"||Math.sign(r)!==1)throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${r}\``);if(s?.aborted){h(tl(s));return}if(s&&(c=()=>{h(tl(s))},s.addEventListener("abort",c,{once:!0})),e.then(l,h),r===Number.POSITIVE_INFINITY)return;let m=new sa;a=i.setTimeout.call(void 0,()=>{if(n){try{l(n())}catch(E){h(E)}return}typeof e.cancel=="function"&&e.cancel(),o===!1?l():o instanceof Error?h(o):(m.message=o??`Promise timed out after ${r} milliseconds`,h(m))},r)}).finally(()=>{f.clear(),c&&s&&s.removeEventListener("abort",c)});return f.clear=()=>{i.clearTimeout.call(void 0,a),a=void 0},f}function ca(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 Ur=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=ca(this.#t,i,(a,c)=>c.priority-a.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})}remove(t){let r=this.#t.findIndex(n=>typeof t=="string"?n.id===t:n.run===t);r!==-1&&this.#t.splice(r,1)}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 An=class extends ia.default{#t;#n;#r=0;#h;#m=!1;#x=!1;#c;#C=0;#w=0;#u;#f;#a;#s=[];#i=0;#e;#_;#o=0;#y;#l;#O=1n;#g=new Map;#E=new Set;timeout;constructor(t){if(super(),t={carryoverIntervalCount:!1,intervalCap:Number.POSITIVE_INFINITY,interval:0,concurrency:Number.POSITIVE_INFINITY,autoStart:!0,queueClass:Ur,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.#e=new t.queueClass,this.#_=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()}#S(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)}#F(t){this.#a?this.#s.push(t):this.#r++}#L(){this.#a?this.#s.length>this.#i&&this.#s.pop():this.#r>0&&this.#r--}#v(){return this.#s.length-this.#i}get#N(){return this.#n?!0:this.#a?this.#v()<this.#h:this.#r<this.#h}get#U(){return this.#o<this.#y}#k(){this.#o--,this.#o===0&&this.emit("pendingZero"),this.#b(),this.emit("next")}#K(){this.#f=void 0,this.#D(),this.#R()}#$(t){if(this.#a){if(this.#S(t),this.#v()>=this.#h){let n=this.#s[this.#i],o=this.#c-(t-n);return this.#T(o),!0}return!1}if(this.#u===void 0){let r=this.#C-t;if(r<0){if(this.#w>0){let n=t-this.#w;if(n<this.#c)return this.#T(this.#c-n),!0}this.#r=this.#t?this.#o:0}else return this.#T(r),!0}return!1}#T(t){this.#f===void 0&&(this.#f=setTimeout(()=>{this.#K()},t))}#A(){this.#u&&(clearInterval(this.#u),this.#u=void 0)}#B(){this.#f&&(clearTimeout(this.#f),this.#f=void 0)}#b(){if(this.#e.size===0){if(this.#A(),this.emit("empty"),this.#o===0){if(this.#B(),this.#a&&this.#i>0){let r=Date.now();this.#S(r)}this.emit("idle")}return!1}let t=!1;if(!this.#l){let r=Date.now(),n=!this.#$(r);if(this.#N&&this.#U){let o=this.#e.dequeue();this.#n||(this.#F(r),this.#p()),this.emit("active"),o(),n&&this.#R(),t=!0}}return t}#R(){this.#n||this.#u!==void 0||this.#a||(this.#u=setInterval(()=>{this.#D()},this.#c),this.#C=Date.now()+this.#c)}#D(){this.#a||(this.#r===0&&this.#o===0&&this.#u&&this.#A(),this.#r=this.#t?this.#o:0),this.#I(),this.#p()}#I(){for(;this.#b(););}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.#e.setPriority(t,r)}async add(t,r={}){return r={timeout:this.timeout,...r,id:r.id??(this.#O++).toString()},new Promise((n,o)=>{let i=Symbol(`task-${r.id}`),s=()=>{},a=async()=>{s(),this.#o++,this.#g.set(i,{id:r.id,priority:r.priority??0,startTime:Date.now(),timeout:r.timeout});let u;try{try{r.signal?.throwIfAborted()}catch(h){throw this.#V(),this.#g.delete(i),h}this.#w=Date.now();let f=t({signal:r.signal});if(r.timeout&&(f=aa(Promise.resolve(f),{milliseconds:r.timeout,message:`Task timed out after ${r.timeout}ms (queue has ${this.#o} running, ${this.#e.size} waiting)`})),r.signal){let{signal:h}=r;f=Promise.race([f,new Promise((m,E)=>{u=()=>{E(h.reason)},h.addEventListener("abort",u,{once:!0})})])}let l=await f;n(l),this.emit("completed",l)}catch(f){o(f),this.emit("error",f)}finally{u&&r.signal?.removeEventListener("abort",u),this.#g.delete(i),queueMicrotask(()=>{this.#k()})}};this.#e.enqueue(a,r);let c=()=>{if(this.#e instanceof Ur){this.#e.remove(a);return}this.#e.remove?.(r.id)};if(r.signal){let{signal:u}=r,f=()=>{s(),c(),o(u.reason),this.#b(),this.emit("next")};if(s=()=>{u.removeEventListener("abort",f),this.#E.delete(s)},u.aborted){f();return}u.addEventListener("abort",f,{once:!0}),this.#E.add(s)}this.emit("add"),this.#b()})}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(){for(let t of this.#E)t();this.#e=new this.#_,this.#A(),this.#P(),this.emit("empty"),this.#o===0&&(this.#B(),this.emit("idle")),this.emit("next")}async onEmpty(){this.#e.size!==0&&await this.#d("empty")}async onSizeLessThan(t){this.#e.size<t||await this.#d("next",()=>this.#e.size<t)}async onIdle(){this.#o===0&&this.#e.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.#e.size}sizeBy(t){return this.#e.filter(t).length}get pending(){return this.#o}get isPaused(){return this.#l}#M(){this.#n||(this.on("add",()=>{this.#e.size>0&&this.#p()}),this.on("next",()=>{this.#p()}))}#p(){this.#n||this.#x||(this.#x=!0,queueMicrotask(()=>{this.#x=!1,this.#P()}))}#V(){this.#n||(this.#L(),this.#p())}#P(){let t=this.#m;if(this.#n||this.#e.size===0){t&&(this.#m=!1,this.emit("rateLimitCleared"));return}let r;if(this.#a){let o=Date.now();this.#S(o),r=this.#v()}else r=this.#r;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.#e.size>0||this.isRateLimited&&this.#e.size>0}get runningTasks(){return[...this.#g.values()].map(t=>({...t}))}};var tr=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 tm(e){return e[Symbol.asyncIterator]!=null}function em(e){if(tm(e))return(async()=>{for await(let t of e)return t})();for(let t of e)return t}var Mo=em;function rm(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 el=rm;function nm(e){return e[Symbol.asyncIterator]!=null}function om(e,t){let r=0;if(nm(e))return(async function*(){for await(let c of e)yield t(c,r++)})();let n=el(e),{value:o,done:i}=n.next();if(i===!0)return(function*(){})();let s=t(o,r++);if(typeof s.then=="function")return(async function*(){yield await s;for(let c of n)yield t(c,r++)})();let a=t;return(function*(){yield s;for(let c of n)yield a(c,r++)})()}var Vo=om;var rl=V("/ipns/");function nl(e){return W(e.subarray(0,rl.byteLength),rl)}var qo=class{client;constructor(t){this.client=t}async*findProviders(t,r={}){try{yield*Vo(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(!nl(t))return;let o=we(t),i=H.createV1(114,o),s=ce(r);await this.client.putIPNS(i,s,n)}async get(t,r){if(!nl(t))throw new At("Not found");let n=we(t),o=H.createV1(114,n);try{let i=await this.client.getIPNS(o,r);return Qe(i)}catch(i){throw i.name==="BadResponseError"?new At("Not found"):i}}toString(){return`DelegatedRoutingV1HttpApiClientContentRouting(${this.client.url})`}},zo=class{client;constructor(t){this.client=t}async findPeer(t,r={}){let n=await Mo(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=H.decode(t)}catch{try{n=uo(ee.decode(t))}catch{n=H.createV1(qa,St.digest(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 Ho={concurrentRequests:4,timeout:3e4,cacheTTL:300*1e3,cacheName:"delegated-routing-v1-cache"},jo=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 An({concurrency:r.concurrentRequests??Ho.concurrentRequests}),this.inFlightRequests=new Map,this.url=r.url instanceof URL?r.url:new URL(r.url),this.timeout=r.timeout??Ho.timeout,this.filterAddrs=r.filterAddrs,this.filterProtocols=r.filterProtocols,this.contentRouting=new qo(this),this.peerRouting=new zo(this),this.cacheName=r.cacheName??Ho.cacheName,this.cacheTTL=r.cacheTTL??Ho.cacheTTL}get[va](){return this.contentRouting}get[Aa](){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=$t(),s=$t(),a=0;this.httpQueue.add(async()=>(i.resolve(),s.promise));try{await i.promise;let c=new URL(`${this.url}routing/v1/providers/${t}`);this.#n(c,r.filterAddrs,r.filterProtocols);let u={headers:{accept:"application/x-ndjson, application/json;q=0.8"},signal:o},f=await this.#r(c.toString(),u);if(!f.ok){if(f.status===404)return;throw f.status===422?new tr("Request does not conform to schema or semantic constraints"):new Mt(`Unexpected status code: ${f.status}`)}let l=f.headers.get("Content-Type");if(l==null)throw new Mt("No Content-Type header received");if(f.body==null){if(l!=="application/x-ndjson")throw new Mt("Routing response had no body");return}if(l.startsWith("application/json")){let m=(await f.json()).Providers??[];for(let E of m){let v=this.#t(E);v!=null&&(a++,yield v)}}else if(l.includes("application/x-ndjson"))for await(let h of Nr(mn(f.body))){let m=this.#t(h);m!=null&&(a++,yield m)}else throw new Mt(`Unsupported Content-Type: ${l}`)}finally{o.clear(),s.resolve(),this.log("getProviders finished found %d providers for %c",a,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=$t(),s=$t();this.httpQueue.add(async()=>(i.resolve(),s.promise));try{await i.promise;let a=new URL(`${this.url}routing/v1/peers/${t.toCID().toString()}`);this.#n(a,r.filterAddrs,r.filterProtocols);let c={headers:{Accept:"application/x-ndjson"},signal:o},u=await this.#r(a.toString(),c);if(u.status===404)return;if(u.status===422)throw new tr("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 h=(await u.json()).Peers??[];for(let m of h){let E=this.#t(m);E!=null&&(yield E)}}else for await(let l of Nr(mn(u.body))){let h=this.#t(l);h!=null&&(yield h)}}catch(a){this.log.error("getPeers errored - %e",a)}finally{o.clear(),s.resolve(),this.log("getPeers finished: %c",t)}}async*getClosestPeers(t,r={}){let n;if(Ta(t))n=t.toCID().toString();else if(H.asCID(t)===t||t instanceof H)n=t.toV1().toString();else throw new et("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=$t(),a=$t();this.httpQueue.add(async()=>(s.resolve(),a.promise));try{await s.promise;let c=new URL(`${this.url}routing/v1/dht/closest/peers/${n}`);this.#n(c,r.filterAddrs,r.filterProtocols);let u={headers:{Accept:"application/x-ndjson"},signal:i},f=await this.#r(c.toString(),u);if(f.status===404)return;if(f.status===422)throw new tr("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 m=(await f.json()).Peers??[];for(let E of m){let v=this.#t(E);v!=null&&(yield v)}}else for await(let h of Nr(mn(f.body))){let m=this.#t(h);m!=null&&(yield m)}}catch(c){this.log.error("getClosestPeers errored - %e",c)}finally{i.clear(),a.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=$t(),s=$t();this.httpQueue.add(async()=>(i.resolve(),s.promise));let a=`${this.url}routing/v1/ipns/${t}`;try{await i.promise;let c={headers:{Accept:"application/vnd.ipfs.ipns-record"},signal:o},u=await this.#r(a,c);if(this.log("getIPNS GET %s %d",a,u.status),u.status===404)throw new At("No matching records found");if(u.status===422)throw new tr("Request does not conform to schema or semantic constraints");if(!u.ok)throw new Mt(`Unexpected status code: ${u.status}`);let f=u.headers.get("Content-Type");if(f==null||!f.includes("application/vnd.ipfs.ipns-record"))throw new At("No matching records found");if(u.body==null)throw new Mt("GET ipns response had no body");let l=await u.arrayBuffer(),h=new Uint8Array(l,0,l.byteLength);return r.validate!==!1&&await Xf(vn(t.multihash),h),ce(h)}catch(c){throw this.log.error("getIPNS GET %s error - %e",a,c),c}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=$t(),a=$t();this.httpQueue.add(async()=>(s.resolve(),a.promise));let c=`${this.url}routing/v1/ipns/${t}`;try{await s.promise;let u=Qe(r),f={method:"PUT",headers:{"Content-Type":"application/vnd.ipfs.ipns-record"},body:u,signal:i},l=await this.#r(c,f);if(this.log("putIPNS PUT %s %d",c,l.status),l.status!==200)throw new Mt("PUT ipns response had status other than 200")}catch(u){throw this.log.error("putIPNS PUT %s error - %e",c,u.stack),u}finally{i.clear(),a.resolve(),this.log("putIPNS finished: %c",t)}}#t(t){try{let r=[],n=t.Addrs?.map(go)??[];return t.Protocols!=null&&r.push(...t.Protocols),t.Protocol!=null&&(r.push(t.Protocol),delete t.Protocol),{...t,Schema:"peer",ID:Eu(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#r(t,r){let n=r.method??"GET",o=`${n}-${t}`;if(n==="GET"){let c=await this.cache?.match(t);if(c!=null){if(parseInt(c.headers.get("x-cache-expires")??"0",10)>Date.now())return this.log("returning cached response for %s",o),this.logResponse(c),c;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 c=await i;return this.log("deduplicating outgoing request for %s",o),c.clone()}this.log("outgoing request:"),this.logRequest(t,r);let s=fetch(t,r).then(async c=>{if(this.log("incoming response:"),this.logResponse(c),this.cache!=null&&c.ok&&n==="GET"){let u=Date.now()+this.cacheTTL,f=new Headers(c.headers);f.set("x-cache-expires",u.toString());let l=new Response(c.clone().body,{status:c.status,statusText:c.statusText,headers:f});await this.cache.put(t,l)}return c}).finally(()=>{this.inFlightRequests.delete(o)});return this.inFlightRequests.set(o,s),await s}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 ol(e){return t=>new jo(t,e)}function Yo(e){return{url:"https://delegated-ipfs.dev",filterProtocols:["unknown","transport-bitswap","transport-ipfs-gateway-http"],filterAddrs:["https","webtransport","webrtc","webrtc-direct","wss","tls"]}}var il=V("/ipns/");function sl(e){return W(e.subarray(0,il.byteLength),il)}var ua=class{name="delegated-http-router";client;constructor(t,r){this.client=ol(r)(t)}async provide(t,r){}async cancelReprovide(t,r){}async*findProviders(t,r){yield*Vo(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(!sl(t))return;let o=we(t),i=H.createV1(114,o),s=ce(r);await this.client.putIPNS(i,s,n)}async get(t,r){if(!sl(t))throw new At("Not found");let n=we(t),o=H.createV1(114,n);try{let i=await this.client.getIPNS(o,r);return Qe(i)}catch(i){throw i.name==="BadResponseError"?new At("Not found"):i}}async findPeer(t,r){let n=await Mo(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 al(e){return t=>new ua(t,Yo(e))}var cl="[a-fA-F\\d:]",ke=e=>e&&e.includeBoundaries?`(?:(?<=\\s|^)(?=${cl})|(?<=${cl})(?=\\s|$))`:"",Qt="(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}",st="[a-fA-F\\d]{1,4}",Zo=`
13
+ ${t}[Error list was empty]`,r.trim()}return Gp(e,t)}Pt.formatters.e=e=>e==null?"undefined":Zp(e);function H1(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 ce(e,t){let r=H1(`${e}:trace`);return Pt.enabled(`${e}:trace`)&&Pt.names.map(n=>n.toString()).find(n=>n.includes(":trace"))!=null&&(r=Pt(`${e}:trace`,t)),Object.assign(Pt(e,t),{error:Pt(`${e}:error`,t),trace:r,newScope:n=>ce(`${e}:${n}`,t)})}function Yp(e){if(e!=null&&(e=e.trim(),e.length!==0))return e}var q6=ii(cs(),1);var Wu={};$(Wu,{base10:()=>J1});var EI=new Uint8Array(0);function Xp(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 Me(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 Wp(e){return new TextEncoder().encode(e)}function Jp(e){return new TextDecoder().decode(e)}function j1(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var o=0;o<e.length;o++){var i=e.charAt(o),s=i.charCodeAt(0);if(r[s]!==255)throw new TypeError(i+" is ambiguous");r[s]=o}var a=e.length,c=e.charAt(0),u=Math.log(a)/Math.log(256),f=Math.log(256)/Math.log(a);function l(h){if(h instanceof Uint8Array||(ArrayBuffer.isView(h)?h=new Uint8Array(h.buffer,h.byteOffset,h.byteLength):Array.isArray(h)&&(h=Uint8Array.from(h))),!(h instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(h.length===0)return"";for(var g=0,m=0,y=0,E=h.length;y!==E&&h[y]===0;)y++,g++;for(var v=(E-y)*f+1>>>0,C=new Uint8Array(v);y!==E;){for(var B=h[y],U=0,I=v-1;(B!==0||U<m)&&I!==-1;I--,U++)B+=256*C[I]>>>0,C[I]=B%a>>>0,B=B/a>>>0;if(B!==0)throw new Error("Non-zero carry");m=U,y++}for(var b=v-m;b!==v&&C[b]===0;)b++;for(var D=c.repeat(g);b<v;++b)D+=e.charAt(C[b]);return D}function d(h){if(typeof h!="string")throw new TypeError("Expected String");if(h.length===0)return new Uint8Array;var g=0;if(h[g]!==" "){for(var m=0,y=0;h[g]===c;)m++,g++;for(var E=(h.length-g)*u+1>>>0,v=new Uint8Array(E);h[g];){var C=r[h.charCodeAt(g)];if(C===255)return;for(var B=0,U=E-1;(C!==0||B<y)&&U!==-1;U--,B++)C+=a*v[U]>>>0,v[U]=C%256>>>0,C=C/256>>>0;if(C!==0)throw new Error("Non-zero carry");y=B,g++}if(h[g]!==" "){for(var I=E-y;I!==E&&v[I]===0;)I++;for(var b=new Uint8Array(m+(E-I)),D=m;I!==E;)b[D++]=v[I++];return b}}}function x(h){var g=d(h);if(g)return g;throw new Error(`Non-${t} character`)}return{encode:l,decodeUnsafe:d,decode:x}}var G1=j1,Y1=G1,tm=Y1;var Gu=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")}},Yu=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 em(this,t)}},Zu=class{decoders;constructor(t){this.decoders=t}or(t){return em(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 em(e,t){return new Zu({...e.decoders??{[e.prefix]:e},...t.decoders??{[t.prefix]:t}})}var Xu=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 Gu(t,r,n),this.decoder=new Yu(t,r,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function Bn({name:e,prefix:t,encode:r,decode:n}){return new Xu(e,t,r,n)}function fr({name:e,prefix:t,alphabet:r}){let{encode:n,decode:o}=tm(r,e);return Bn({prefix:t,name:e,encode:n,decode:i=>Me(o(i))})}function Z1(e,t,r,n){let o=e.length;for(;e[o-1]==="=";)--o;let i=new Uint8Array(o*r/8|0),s=0,a=0,c=0;for(let u=0;u<o;++u){let f=t[e[u]];if(f===void 0)throw new SyntaxError(`Non-${n} character`);a=a<<r|f,s+=r,s>=8&&(s-=8,i[c++]=255&a>>s)}if(s>=r||(255&a<<8-s)!==0)throw new SyntaxError("Unexpected end of data");return i}function X1(e,t,r){let n=t[t.length-1]==="=",o=(1<<r)-1,i="",s=0,a=0;for(let c=0;c<e.length;++c)for(a=a<<8|e[c],s+=8;s>r;)s-=r,i+=t[o&a>>s];if(s!==0&&(i+=t[o&a<<r-s]),n)for(;(i.length*r&7)!==0;)i+="=";return i}function W1(e){let t={};for(let r=0;r<e.length;++r)t[e[r]]=r;return t}function rt({name:e,prefix:t,bitsPerChar:r,alphabet:n}){let o=W1(n);return Bn({prefix:t,name:e,encode(i){return X1(i,n,r)},decode(i){return Z1(i,o,r,e)}})}var J1=fr({prefix:"9",name:"base10",alphabet:"0123456789"});var Ju={};$(Ju,{base16:()=>Q1,base16upper:()=>tE});var Q1=rt({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),tE=rt({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Qu={};$(Qu,{base2:()=>eE});var eE=rt({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var tf={};$(tf,{base256emoji:()=>sE});var rm=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}"),rE=rm.reduce((e,t,r)=>(e[r]=t,e),[]),nE=rm.reduce((e,t,r)=>{let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);return e[n]=r,e},[]);function oE(e){return e.reduce((t,r)=>(t+=rE[r],t),"")}function iE(e){let t=[];for(let r of e){let n=r.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${r}`);let o=nE[n];if(o==null)throw new Error(`Non-base256emoji character: ${r}`);t.push(o)}return new Uint8Array(t)}var sE=Bn({prefix:"\u{1F680}",name:"base256emoji",encode:oE,decode:iE});var ef={};$(ef,{base32:()=>Dn,base32hex:()=>fE,base32hexpad:()=>hE,base32hexpadupper:()=>dE,base32hexupper:()=>lE,base32pad:()=>cE,base32padupper:()=>uE,base32upper:()=>aE,base32z:()=>pE});var Dn=rt({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),aE=rt({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),cE=rt({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),uE=rt({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),fE=rt({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),lE=rt({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),hE=rt({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),dE=rt({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),pE=rt({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var rf={};$(rf,{base36:()=>_n,base36upper:()=>mE});var _n=fr({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),mE=fr({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var nf={};$(nf,{base58btc:()=>ve,base58flickr:()=>gE});var ve=fr({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),gE=fr({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var of={};$(of,{base64:()=>yE,base64pad:()=>bE,base64url:()=>xE,base64urlpad:()=>wE});var yE=rt({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),bE=rt({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),xE=rt({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),wE=rt({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var sf={};$(sf,{base8:()=>EE});var EE=rt({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var af={};$(af,{identity:()=>SE});var SE=Bn({prefix:"\0",name:"identity",encode:e=>Jp(e),decode:e=>Wp(e)});var OI=new TextEncoder,kI=new TextDecoder;var nm=85;var lf={};$(lf,{identity:()=>ff});var $e={};$($e,{Digest:()=>Nr,create:()=>Fr,decode:()=>Fo,equals:()=>uf,hasCode:()=>KE});var AE=am,im=128,TE=127,CE=~TE,IE=Math.pow(2,31);function am(e,t,r){t=t||[],r=r||0;for(var n=r;e>=IE;)t[r++]=e&255|im,e/=128;for(;e&CE;)t[r++]=e&255|im,e>>>=7;return t[r]=e|0,am.bytes=r-n+1,t}var BE=cf,DE=128,sm=127;function cf(e,n){var r=0,n=n||0,o=0,i=n,s,a=e.length;do{if(i>=a)throw cf.bytes=0,new RangeError("Could not decode varint");s=e[i++],r+=o<28?(s&sm)<<o:(s&sm)*Math.pow(2,o),o+=7}while(s>=DE);return cf.bytes=i-n,r}var _E=Math.pow(2,7),LE=Math.pow(2,14),UE=Math.pow(2,21),RE=Math.pow(2,28),NE=Math.pow(2,35),FE=Math.pow(2,42),PE=Math.pow(2,49),OE=Math.pow(2,56),kE=Math.pow(2,63),VE=function(e){return e<_E?1:e<LE?2:e<UE?3:e<RE?4:e<NE?5:e<FE?6:e<PE?7:e<OE?8:e<kE?9:10},ME={encode:AE,decode:BE,encodingLength:VE},$E=ME,Ro=$E;function No(e,t=0){return[Ro.decode(e,t),Ro.decode.bytes]}function Ln(e,t,r=0){return Ro.encode(e,t,r),t}function Un(e){return Ro.encodingLength(e)}function Fr(e,t){let r=t.byteLength,n=Un(e),o=n+Un(r),i=new Uint8Array(o+r);return Ln(e,i,0),Ln(r,i,n),i.set(t,o),new Nr(e,r,t,i)}function Fo(e){let t=Me(e),[r,n]=No(t),[o,i]=No(t.subarray(n)),s=t.subarray(n+i);if(s.byteLength!==o)throw new Error("Incorrect length");return new Nr(r,o,s,t)}function uf(e,t){if(e===t)return!0;{let r=t;return e.code===r.code&&e.size===r.size&&r.bytes instanceof Uint8Array&&Xp(e.bytes,r.bytes)}}var Nr=class{code;size;digest;bytes;constructor(t,r,n,o){this.code=t,this.size=r,this.digest=n,this.bytes=o}};function KE(e,t){return e.code===t}var cm=0,zE="identity",um=Me;function qE(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 Fr(cm,um(e))}var ff={code:cm,name:zE,encode:um,digest:qE};var pf={};$(pf,{sha256:()=>jE,sha512:()=>GE});var HE=20;function df({name:e,code:t,encode:r,minDigestLength:n,maxDigestLength:o}){return new hf(e,t,r,n,o)}var hf=class{name;code;encode;minDigestLength;maxDigestLength;constructor(t,r,n,o,i){this.name=t,this.code=r,this.encode=n,this.minDigestLength=o??HE,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?fm(n,this.code,r?.truncate):n.then(o=>fm(o,this.code,r?.truncate))}else throw Error("Unknown type, must be binary type")}};function fm(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 Fr(t,e)}function hm(e){return async t=>new Uint8Array(await crypto.subtle.digest(e,t))}var jE=df({name:"sha2-256",code:18,encode:hm("SHA-256")}),GE=df({name:"sha2-512",code:19,encode:hm("SHA-512")});function dm(e,t){let{bytes:r,version:n}=e;return n===0?ZE(r,mf(e),t??ve.encoder):XE(r,mf(e),t??Dn.encoder)}var pm=new WeakMap;function mf(e){let t=pm.get(e);if(t==null){let r=new Map;return pm.set(e,r),r}return t}var Bt=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!==Po)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==WE)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=Fr(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&&uf(t.multihash,n.multihash)}toString(t){return dm(this,t)}toJSON(){return{"/":dm(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??mm(n,o,i.bytes))}else if(r[JE]===!0){let{version:n,multihash:o,code:i}=r,s=Fo(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!==Po)throw new Error(`Version 0 CID must use dag-pb (code: ${Po}) block encoding`);return new e(t,r,n,n.bytes)}case 1:{let o=mm(t,r,n.bytes);return new e(t,r,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return e.create(0,Po,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=Me(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 Nr(r.multihashCode,r.digestSize,i,o);return[r.version===0?e.createV0(s):e.createV1(r.codec,s),t.subarray(r.size)]}static inspectBytes(t){let r=0,n=()=>{let[l,d]=No(t.subarray(r));return r+=d,l},o=n(),i=Po;if(o===18?(o=0,r=0):i=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let s=r,a=n(),c=n(),u=r+c,f=u-s;return{version:o,codec:i,multihashCode:a,digestSize:c,multihashSize:f,size:u}}static parse(t,r){let[n,o]=YE(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 mf(i).set(n,t),i}};function YE(e,t){switch(e[0]){case"Q":{let r=t??ve;return[ve.prefix,r.decode(`${ve.prefix}${e}`)]}case ve.prefix:{let r=t??ve;return[ve.prefix,r.decode(e)]}case Dn.prefix:{let r=t??Dn;return[Dn.prefix,r.decode(e)]}case _n.prefix:{let r=t??_n;return[_n.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 ZE(e,t,r){let{prefix:n}=r;if(n!==ve.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 XE(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 Po=112,WE=18;function mm(e,t,r){let n=Un(e),o=n+Un(t),i=new Uint8Array(o+r.byteLength);return Ln(e,i,0),Ln(t,i,n),i.set(r,o),i}var JE=Symbol.for("@ipld/js-cid/CID");var gf={...af,...Qu,...sf,...Wu,...Ju,...ef,...rf,...nf,...of,...tf},sB={...pf,...lf};function Ae(e=0){return new Uint8Array(e)}function ym(e,t,r,n){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:n}}}var gm=ym("utf8","u",e=>"u"+new TextDecoder("utf8").decode(e),e=>new TextEncoder().encode(e.substring(1))),yf=ym("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=Ae(e.length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t}),QE={utf8:gm,"utf-8":gm,hex:gf.base16,latin1:yf,ascii:yf,binary:yf,...gf},fs=QE;function Te(e,t="utf8"){let r=fs[t];if(r==null)throw new Error(`Unsupported encoding "${t}"`);return r.decoder.decode(`${r.prefix}${e}`)}var ue=class extends Error{static name="SignatureVerificationError";constructor(t="Record signature verification failed"){super(t),this.name="SignatureVerificationError"}},ls=class extends Error{static name="RecordExpiredError";constructor(t="Record has expired"){super(t),this.name="RecordExpiredError"}},Rn=class extends Error{static name="UnsupportedValidityError";constructor(t="The validity type is unsupported"){super(t),this.name="UnsupportedValidityError"}},hs=class extends Error{static name="RecordTooLargeError";constructor(t="The record is too large"){super(t),this.name="RecordTooLargeError"}},ds=class extends Error{static name="InvalidValueError";constructor(t="Value must be a valid content path starting with /"){super(t),this.name="InvalidValueError"}},ps=class extends Error{static name="InvalidRecordDataError";constructor(t="Invalid record data"){super(t),this.name="InvalidRecordDataError"}},Oo=class extends Error{static name="InvalidEmbeddedPublicKeyError";constructor(t="Invalid embedded public key"){super(t),this.name="InvalidEmbeddedPublicKeyError"}};var t6=Math.pow(2,7),e6=Math.pow(2,14),r6=Math.pow(2,21),bm=Math.pow(2,28),xm=Math.pow(2,35),wm=Math.pow(2,42),Em=Math.pow(2,49),Dt=128,lr=127;function ko(e){if(e<t6)return 1;if(e<e6)return 2;if(e<r6)return 3;if(e<bm)return 4;if(e<xm)return 5;if(e<wm)return 6;if(e<Em)return 7;if(Number.MAX_SAFE_INTEGER!=null&&e>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function Sm(e,t,r=0){switch(ko(e)){case 8:t[r++]=e&255|Dt,e/=128;case 7:t[r++]=e&255|Dt,e/=128;case 6:t[r++]=e&255|Dt,e/=128;case 5:t[r++]=e&255|Dt,e/=128;case 4:t[r++]=e&255|Dt,e>>>=7;case 3:t[r++]=e&255|Dt,e>>>=7;case 2:t[r++]=e&255|Dt,e>>>=7;case 1:{t[r++]=e&255,e>>>=7;break}default:throw new Error("unreachable")}return t}function vm(e,t){let r=e[t],n=0;if(n+=r&lr,r<Dt||(r=e[t+1],n+=(r&lr)<<7,r<Dt)||(r=e[t+2],n+=(r&lr)<<14,r<Dt)||(r=e[t+3],n+=(r&lr)<<21,r<Dt)||(r=e[t+4],n+=(r&lr)*bm,r<Dt)||(r=e[t+5],n+=(r&lr)*xm,r<Dt)||(r=e[t+6],n+=(r&lr)*wm,r<Dt)||(r=e[t+7],n+=(r&lr)*Em,r<Dt))return n;throw new RangeError("Could not decode varint")}var bf=new Float32Array([-0]),hr=new Uint8Array(bf.buffer);function Am(e,t,r){bf[0]=e,t[r]=hr[0],t[r+1]=hr[1],t[r+2]=hr[2],t[r+3]=hr[3]}function Tm(e,t){return hr[0]=e[t],hr[1]=e[t+1],hr[2]=e[t+2],hr[3]=e[t+3],bf[0]}var xf=new Float64Array([-0]),vt=new Uint8Array(xf.buffer);function Cm(e,t,r){xf[0]=e,t[r]=vt[0],t[r+1]=vt[1],t[r+2]=vt[2],t[r+3]=vt[3],t[r+4]=vt[4],t[r+5]=vt[5],t[r+6]=vt[6],t[r+7]=vt[7]}function Im(e,t){return vt[0]=e[t],vt[1]=e[t+1],vt[2]=e[t+2],vt[3]=e[t+3],vt[4]=e[t+4],vt[5]=e[t+5],vt[6]=e[t+6],vt[7]=e[t+7],xf[0]}var n6=BigInt(Number.MAX_SAFE_INTEGER),o6=BigInt(Number.MIN_SAFE_INTEGER),Kt=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 Pr;if(t<n6&&t>o6)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>Bm&&(o=0n,++n>Bm&&(n=0n))),new e(Number(o),Number(n))}static fromNumber(t){if(t===0)return Pr;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):Pr}},Pr=new Kt(0,0);Pr.toBigInt=function(){return 0n};Pr.zzEncode=Pr.zzDecode=function(){return this};Pr.length=function(){return 1};var Bm=4294967296n;function Dm(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 _m(e,t,r){if(r-t<1)return"";let o,i=[],s=0,a;for(;t<r;)a=e[t++],a<128?i[s++]=a:a>191&&a<224?i[s++]=(a&31)<<6|e[t++]&63:a>239&&a<365?(a=((a&7)<<18|(e[t++]&63)<<12|(e[t++]&63)<<6|e[t++]&63)-65536,i[s++]=55296+(a>>10),i[s++]=56320+(a&1023)):i[s++]=(a&15)<<12|(e[t++]&63)<<6|e[t++]&63,s>8191&&((o??(o=[])).push(String.fromCharCode.apply(String,i)),s=0);return o!=null?(s>0&&o.push(String.fromCharCode.apply(String,i.slice(0,s))),o.join("")):String.fromCharCode.apply(String,i.slice(0,s))}function wf(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 fe(e,t){return RangeError(`index out of range: ${e.pos} + ${t??1} > ${e.len}`)}function ms(e,t){return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0}var Ef=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,fe(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 fe(this,4);return ms(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw fe(this,4);return ms(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw fe(this,4);let t=Tm(this.buf,this.pos);return this.pos+=4,t}double(){if(this.pos+8>this.len)throw fe(this,4);let t=Im(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 fe(this,t);return this.pos+=t,r===n?new Uint8Array(0):this.buf.subarray(r,n)}string(){let t=this.bytes();return _m(t,0,t.length)}skip(t){if(typeof t=="number"){if(this.pos+t>this.len)throw fe(this,t);this.pos+=t}else do if(this.pos>=this.len)throw fe(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 Kt(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 fe(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 fe(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 fe(this,8);let t=ms(this.buf,this.pos+=4),r=ms(this.buf,this.pos+=4);return new Kt(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=vm(this.buf,this.pos);return this.pos+=ko(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 Vo(e){return new Ef(e instanceof Uint8Array?e:e.subarray())}function Sf(e,t,r){let n=Vo(e);return t.decode(n,void 0,r)}function vf(e){let t=e??8192,r=t>>>1,n,o=t;return function(s){if(s<1||s>r)return Ae(s);o+s>t&&(n=Ae(t),o=0);let a=n.subarray(o,o+=s);return(o&7)!==0&&(o=(o|7)+1),a}}var Or=class{fn;len;next;val;constructor(t,r,n){this.fn=t,this.len=r,this.next=void 0,this.val=n}};function Af(){}var Cf=class{head;tail;len;next;constructor(t){this.head=t.head,this.tail=t.tail,this.len=t.len,this.next=t.states}},i6=vf();function s6(e){return globalThis.Buffer!=null?Ae(e):i6(e)}var $o=class{len;head;tail;states;constructor(){this.len=0,this.head=new Or(Af,0,0),this.tail=this.head,this.states=null}_push(t,r,n){return this.tail=this.tail.next=new Or(t,r,n),this.len+=r,this}uint32(t){return this.len+=(this.tail=this.tail.next=new If((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(gs,10,Kt.fromNumber(t)):this.uint32(t)}sint32(t){return this.uint32((t<<1^t>>31)>>>0)}uint64(t){let r=Kt.fromBigInt(t);return this._push(gs,r.length(),r)}uint64Number(t){return this._push(Sm,ko(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=Kt.fromBigInt(t).zzEncode();return this._push(gs,r.length(),r)}sint64Number(t){let r=Kt.fromNumber(t).zzEncode();return this._push(gs,r.length(),r)}sint64String(t){return this.sint64(BigInt(t))}bool(t){return this._push(Tf,1,t?1:0)}fixed32(t){return this._push(Mo,4,t>>>0)}sfixed32(t){return this.fixed32(t)}fixed64(t){let r=Kt.fromBigInt(t);return this._push(Mo,4,r.lo)._push(Mo,4,r.hi)}fixed64Number(t){let r=Kt.fromNumber(t);return this._push(Mo,4,r.lo)._push(Mo,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(Am,4,t)}double(t){return this._push(Cm,8,t)}bytes(t){let r=t.length>>>0;return r===0?this._push(Tf,1,0):this.uint32(r)._push(c6,r,t)}string(t){let r=Dm(t);return r!==0?this.uint32(r)._push(wf,r,t):this._push(Tf,1,0)}fork(){return this.states=new Cf(this),this.head=this.tail=new Or(Af,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 Or(Af,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=s6(this.len),n=0;for(;t!=null;)t.fn(t.val,r,n),n+=t.len,t=t.next;return r}};function Tf(e,t,r){t[r]=e&255}function a6(e,t,r){for(;e>127;)t[r++]=e&127|128,e>>>=7;t[r]=e}var If=class extends Or{next;constructor(t,r){super(a6,t,r),this.next=void 0}};function gs(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 Mo(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 c6(e,t,r){t.set(e,r)}globalThis.Buffer!=null&&($o.prototype.bytes=function(e){let t=e.length>>>0;return this.uint32(t),t>0&&this._push(u6,t,e),this},$o.prototype.string=function(e){let t=globalThis.Buffer.byteLength(e);return this.uint32(t),t>0&&this._push(f6,t,e),this});function u6(e,t,r){t.set(e,r)}function f6(e,t,r){e.length<40?wf(e,t,r):t.utf8Write!=null?t.utf8Write(e,r):t.set(Te(e),r)}function Bf(){return new $o}function Df(e,t){let r=Bf();return t.encode(e,r,{lengthDelimited:!1}),r.finish()}function*_f(e,t,r){let n=Vo(e);yield*t.stream(n,void 0,"$",r)}var ys={VARINT:0,BIT64:1,LENGTH_DELIMITED:2,START_GROUP:3,END_GROUP:4,BIT32:5};function bs(e,t,r,n,o){return{name:e,type:t,encode:r,decode:n,stream:o}}function Lf(e){function t(i){if(e[i.toString()]==null)throw new Error("Invalid enum value");return e[i]}let r=function(s,a){let c=t(s);a.int32(c)},n=function(s){let a=s.int32();return t(a)},o=function*(s){let a=s.int32();yield t(a)};return bs("enum",ys.VARINT,r,n,o)}function Uf(e,t,r){return bs("message",ys.LENGTH_DELIMITED,e,t,r)}var le;(function(e){let t;(function(a){a.EOL="EOL"})(t=e.ValidityType||(e.ValidityType={}));let r;(function(a){a[a.EOL=0]="EOL"})(r||(r={})),(function(a){a.codec=()=>Lf(r)})(t=e.ValidityType||(e.ValidityType={}));let n;e.codec=()=>(n==null&&(n=Uf((a,c,u={})=>{u.lengthDelimited!==!1&&c.fork(),a.value!=null&&(c.uint32(10),c.bytes(a.value)),a.signatureV1!=null&&(c.uint32(18),c.bytes(a.signatureV1)),a.validityType!=null&&(c.uint32(24),e.ValidityType.codec().encode(a.validityType,c)),a.validity!=null&&(c.uint32(34),c.bytes(a.validity)),a.sequence!=null&&(c.uint32(40),c.uint64(a.sequence)),a.ttl!=null&&(c.uint32(48),c.uint64(a.ttl)),a.pubKey!=null&&(c.uint32(58),c.bytes(a.pubKey)),a.signatureV2!=null&&(c.uint32(66),c.bytes(a.signatureV2)),a.data!=null&&(c.uint32(74),c.bytes(a.data)),u.lengthDelimited!==!1&&c.ldelim()},(a,c,u={})=>{let f={},l=c==null?a.len:a.pos+c;for(;a.pos<l;){let d=a.uint32();switch(d>>>3){case 1:{f.value=a.bytes();break}case 2:{f.signatureV1=a.bytes();break}case 3:{f.validityType=e.ValidityType.codec().decode(a);break}case 4:{f.validity=a.bytes();break}case 5:{f.sequence=a.uint64();break}case 6:{f.ttl=a.uint64();break}case 7:{f.pubKey=a.bytes();break}case 8:{f.signatureV2=a.bytes();break}case 9:{f.data=a.bytes();break}default:{a.skipType(d&7);break}}}return f},function*(a,c,u,f={}){let l=c==null?a.len:a.pos+c;for(;a.pos<l;){let d=a.uint32();switch(d>>>3){case 1:{yield{field:`${u}.value`,value:a.bytes()};break}case 2:{yield{field:`${u}.signatureV1`,value:a.bytes()};break}case 3:{yield{field:`${u}.validityType`,value:e.ValidityType.codec().decode(a)};break}case 4:{yield{field:`${u}.validity`,value:a.bytes()};break}case 5:{yield{field:`${u}.sequence`,value:a.uint64()};break}case 6:{yield{field:`${u}.ttl`,value:a.uint64()};break}case 7:{yield{field:`${u}.pubKey`,value:a.bytes()};break}case 8:{yield{field:`${u}.signatureV2`,value:a.bytes()};break}case 9:{yield{field:`${u}.data`,value:a.bytes()};break}default:{a.skipType(d&7);break}}}})),n);function o(a){return Df(a,e.codec())}e.encode=o;function i(a,c){return Sf(a,e.codec(),c)}e.decode=i;function s(a,c){return _f(a,e.codec(),c)}e.stream=s})(le||(le={}));var l6=["Object","RegExp","Date","Error","Map","Set","WeakMap","WeakSet","ArrayBuffer","SharedArrayBuffer","DataView","Promise","URL","HTMLElement","Int8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","BigInt64Array","BigUint64Array","Tagged"];function Um(e){if(e===null)return"null";if(e===void 0)return"undefined";if(e===!0||e===!1)return"boolean";let t=typeof e;if(t==="string"||t==="number"||t==="bigint"||t==="symbol")return t;if(t==="function")return"Function";if(Array.isArray(e))return"Array";if(e instanceof Uint8Array)return"Uint8Array";if(e.constructor===Object)return"Object";let r=h6(e);return r||"Object"}function h6(e){let t=Object.prototype.toString.call(e).slice(8,-1);if(l6.includes(t))return t}var w=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}static equals(t,r){return t===r||t.major===r.major&&t.name===r.name}};w.uint=new w(0,"uint",!0);w.negint=new w(1,"negint",!0);w.bytes=new w(2,"bytes",!0);w.string=new w(3,"string",!0);w.array=new w(4,"array",!1);w.map=new w(5,"map",!1);w.tag=new w(6,"tag",!1);w.float=new w(7,"float",!0);w.false=new w(7,"false",!0);w.true=new w(7,"true",!0);w.null=new w(7,"null",!0);w.undefined=new w(7,"undefined",!0);w.break=new w(7,"break",!0);var O=class{constructor(t,r,n){this.type=t,this.value=r,this.encodedLength=n,this.encodedBytes=void 0,this.byteValue=void 0}toString(){return`Token[${this.type}].${this.value}`}};var Ko=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&typeof globalThis.Buffer.isBuffer=="function",d6=new TextEncoder;function xs(e){return Ko&&globalThis.Buffer.isBuffer(e)}function zo(e){return e instanceof Uint8Array?xs(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e:Uint8Array.from(e)}var p6=24,m6=200,Rf=Ko?e=>e.length>=p6?globalThis.Buffer.from(e):Rm(e):e=>e.length>=m6?d6.encode(e):Rm(e),Ce=e=>Uint8Array.from(e),Nm=Ko?(e,t,r)=>xs(e)?new Uint8Array(e.subarray(t,r)):e.slice(t,r):(e,t,r)=>e.slice(t,r),Fm=Ko?(e,t)=>(e=e.map(r=>r instanceof Uint8Array?r:globalThis.Buffer.from(r)),zo(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},Pm=Ko?e=>globalThis.Buffer.allocUnsafe(e):e=>new Uint8Array(e);function ws(e,t){if(xs(e)&&xs(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 Rm(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):(o>=55296&&o<=57343&&(o=65533),t[r++]=o>>12|224,t[r++]=o>>6&63|128,t[r++]=o&63|128)}return t}var g6=256,qo=class{constructor(t=g6){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=Pm(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=Nm(n,0,this.cursor)}else r=Fm(this.chunks,this.cursor);return t&&this.reset(),r}},Es=class{constructor(t){this.dest=t,this.cursor=0,this.chunks=[t]}reset(){this.cursor=0}push(t){if(this.cursor+t.length>this.dest.length)throw new Error("write out of bounds, destination buffer is too small");this.dest.set(t,this.cursor),this.cursor+=t.length}toBytes(t=!1){let r=this.dest.subarray(0,this.cursor);return t&&this.reset(),r}};var M="CBOR decode error:",Nf="CBOR encode error:",Ho=[];Ho[23]=1;Ho[24]=2;Ho[25]=3;Ho[26]=5;Ho[27]=9;function Ke(e,t,r){if(e.length-t<r)throw new Error(`${M} not enough data for type`)}var mt=[24,256,65536,4294967296,BigInt("18446744073709551616")];function zt(e,t,r){Ke(e,t,1);let n=e[t];if(r.strict===!0&&n<mt[0])throw new Error(`${M} integer encoded in more bytes than necessary (strict decode)`);return n}function qt(e,t,r){Ke(e,t,2);let n=e[t]<<8|e[t+1];if(r.strict===!0&&n<mt[1])throw new Error(`${M} integer encoded in more bytes than necessary (strict decode)`);return n}function Ht(e,t,r){Ke(e,t,4);let n=e[t]*16777216+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3];if(r.strict===!0&&n<mt[2])throw new Error(`${M} integer encoded in more bytes than necessary (strict decode)`);return n}function jt(e,t,r){Ke(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<mt[3])throw new Error(`${M} integer encoded in more bytes than necessary (strict decode)`);if(i<=Number.MAX_SAFE_INTEGER)return Number(i);if(r.allowBigInt===!0)return i;throw new Error(`${M} integers outside of the safe integer range are not supported`)}function Om(e,t,r,n){return new O(w.uint,zt(e,t+1,n),2)}function km(e,t,r,n){return new O(w.uint,qt(e,t+1,n),3)}function Vm(e,t,r,n){return new O(w.uint,Ht(e,t+1,n),5)}function Mm(e,t,r,n){return new O(w.uint,jt(e,t+1,n),9)}function Wt(e,t){return gt(e,0,t.value)}function gt(e,t,r){if(r<mt[0]){let n=Number(r);e.push([t|n])}else if(r<mt[1]){let n=Number(r);e.push([t|24,n])}else if(r<mt[2]){let n=Number(r);e.push([t|25,n>>>8,n&255])}else if(r<mt[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<mt[4]){let o=[t|27,0,0,0,0,0,0,0],i=Number(n&BigInt(4294967295)),s=Number(n>>BigInt(32)&BigInt(4294967295));o[8]=i&255,i=i>>8,o[7]=i&255,i=i>>8,o[6]=i&255,i=i>>8,o[5]=i&255,o[4]=s&255,s=s>>8,o[3]=s&255,s=s>>8,o[2]=s&255,s=s>>8,o[1]=s&255,e.push(o)}else throw new Error(`${M} encountered BigInt larger than allowable range`)}}Wt.encodedSize=function(t){return gt.encodedSize(t.value)};gt.encodedSize=function(t){return t<mt[0]?1:t<mt[1]?2:t<mt[2]?3:t<mt[3]?5:9};Wt.compareTokens=function(t,r){return t.value<r.value?-1:t.value>r.value?1:0};function $m(e,t,r,n){return new O(w.negint,-1-zt(e,t+1,n),2)}function Km(e,t,r,n){return new O(w.negint,-1-qt(e,t+1,n),3)}function zm(e,t,r,n){return new O(w.negint,-1-Ht(e,t+1,n),5)}var Ff=BigInt(-1),qm=BigInt(1);function Hm(e,t,r,n){let o=jt(e,t+1,n);if(typeof o!="bigint"){let i=-1-o;if(i>=Number.MIN_SAFE_INTEGER)return new O(w.negint,i,9)}if(n.allowBigInt!==!0)throw new Error(`${M} integers outside of the safe integer range are not supported`);return new O(w.negint,Ff-BigInt(o),9)}function Ss(e,t){let r=t.value,n=typeof r=="bigint"?r*Ff-qm:r*-1-1;gt(e,t.type.majorEncoded,n)}Ss.encodedSize=function(t){let r=t.value,n=typeof r=="bigint"?r*Ff-qm:r*-1-1;return n<mt[0]?1:n<mt[1]?2:n<mt[2]?3:n<mt[3]?5:9};Ss.compareTokens=function(t,r){return t.value<r.value?1:t.value>r.value?-1:0};function jo(e,t,r,n){Ke(e,t,r+n);let o=e.slice(t+r,t+r+n);return new O(w.bytes,o,r+n)}function jm(e,t,r,n){return jo(e,t,1,r)}function Gm(e,t,r,n){return jo(e,t,2,zt(e,t+1,n))}function Ym(e,t,r,n){return jo(e,t,3,qt(e,t+1,n))}function Zm(e,t,r,n){return jo(e,t,5,Ht(e,t+1,n))}function Xm(e,t,r,n){let o=jt(e,t+1,n);if(typeof o=="bigint")throw new Error(`${M} 64-bit integer bytes lengths not supported`);return jo(e,t,9,o)}function vs(e){return e.encodedBytes===void 0&&(e.encodedBytes=w.equals(e.type,w.string)?Rf(e.value):e.value),e.encodedBytes}function Nn(e,t){let r=vs(t);gt(e,t.type.majorEncoded,r.length),e.push(r)}Nn.encodedSize=function(t){let r=vs(t);return gt.encodedSize(r.length)+r.length};Nn.compareTokens=function(t,r){return b6(vs(t),vs(r))};function b6(e,t){return e.length<t.length?-1:e.length>t.length?1:ws(e,t)}var Wm=new TextDecoder,w6=32;function E6(e,t,r){if(r-t<w6){let o="";for(let i=t;i<r;i++){let s=e[i];if(s&128)return Wm.decode(e.subarray(t,r));o+=String.fromCharCode(s)}return o}return Wm.decode(e.subarray(t,r))}function Go(e,t,r,n,o){let i=r+n;Ke(e,t,i);let s=new O(w.string,E6(e,t+r,t+i),i);return o.retainStringBytes===!0&&(s.byteValue=e.slice(t+r,t+i)),s}function Jm(e,t,r,n){return Go(e,t,1,r,n)}function Qm(e,t,r,n){return Go(e,t,2,zt(e,t+1,n),n)}function t0(e,t,r,n){return Go(e,t,3,qt(e,t+1,n),n)}function e0(e,t,r,n){return Go(e,t,5,Ht(e,t+1,n),n)}function r0(e,t,r,n){let o=jt(e,t+1,n);if(typeof o=="bigint")throw new Error(`${M} 64-bit integer string lengths not supported`);return Go(e,t,9,o,n)}var n0=Nn;function Fn(e,t,r,n){return new O(w.array,n,r)}function o0(e,t,r,n){return Fn(e,t,1,r)}function i0(e,t,r,n){return Fn(e,t,2,zt(e,t+1,n))}function s0(e,t,r,n){return Fn(e,t,3,qt(e,t+1,n))}function a0(e,t,r,n){return Fn(e,t,5,Ht(e,t+1,n))}function c0(e,t,r,n){let o=jt(e,t+1,n);if(typeof o=="bigint")throw new Error(`${M} 64-bit integer array lengths not supported`);return Fn(e,t,9,o)}function u0(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${M} indefinite length items not allowed`);return Fn(e,t,1,1/0)}function As(e,t){gt(e,w.array.majorEncoded,t.value)}As.compareTokens=Wt.compareTokens;As.encodedSize=function(t){return gt.encodedSize(t.value)};function Pn(e,t,r,n){return new O(w.map,n,r)}function f0(e,t,r,n){return Pn(e,t,1,r)}function l0(e,t,r,n){return Pn(e,t,2,zt(e,t+1,n))}function h0(e,t,r,n){return Pn(e,t,3,qt(e,t+1,n))}function d0(e,t,r,n){return Pn(e,t,5,Ht(e,t+1,n))}function p0(e,t,r,n){let o=jt(e,t+1,n);if(typeof o=="bigint")throw new Error(`${M} 64-bit integer map lengths not supported`);return Pn(e,t,9,o)}function m0(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${M} indefinite length items not allowed`);return Pn(e,t,1,1/0)}function Ts(e,t){gt(e,w.map.majorEncoded,t.value)}Ts.compareTokens=Wt.compareTokens;Ts.encodedSize=function(t){return gt.encodedSize(t.value)};function g0(e,t,r,n){return new O(w.tag,r,1)}function y0(e,t,r,n){return new O(w.tag,zt(e,t+1,n),2)}function b0(e,t,r,n){return new O(w.tag,qt(e,t+1,n),3)}function x0(e,t,r,n){return new O(w.tag,Ht(e,t+1,n),5)}function w0(e,t,r,n){return new O(w.tag,jt(e,t+1,n),9)}function Cs(e,t){gt(e,w.tag.majorEncoded,t.value)}Cs.compareTokens=Wt.compareTokens;Cs.encodedSize=function(t){return gt.encodedSize(t.value)};var Pf=20,Of=21,kf=22,Vf=23;function E0(e,t,r,n){if(n.allowUndefined===!1)throw new Error(`${M} undefined values are not supported`);return n.coerceUndefinedToNull===!0?new O(w.null,null,1):new O(w.undefined,void 0,1)}function S0(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${M} indefinite length items not allowed`);return new O(w.break,void 0,1)}function Mf(e,t,r){if(r){if(r.allowNaN===!1&&Number.isNaN(e))throw new Error(`${M} NaN values are not supported`);if(r.allowInfinity===!1&&(e===1/0||e===-1/0))throw new Error(`${M} Infinity values are not supported`)}return new O(w.float,e,t)}function v0(e,t,r,n){return Mf($f(e,t+1),3,n)}function A0(e,t,r,n){return Mf(Kf(e,t+1),5,n)}function T0(e,t,r,n){return Mf(D0(e,t+1),9,n)}function Is(e,t,r){let n=t.value;if(n===!1)e.push([w.float.majorEncoded|Pf]);else if(n===!0)e.push([w.float.majorEncoded|Of]);else if(n===null)e.push([w.float.majorEncoded|kf]);else if(n===void 0)e.push([w.float.majorEncoded|Vf]);else{let o,i=!1;(!r||r.float64!==!0)&&(I0(n),o=$f(he,1),n===o||Number.isNaN(n)?(he[0]=249,e.push(he.slice(0,3)),i=!0):(B0(n),o=Kf(he,1),n===o&&(he[0]=250,e.push(he.slice(0,5)),i=!0))),i||(C6(n),o=D0(he,1),he[0]=251,e.push(he.slice(0,9)))}}Is.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){I0(n);let o=$f(he,1);if(n===o||Number.isNaN(n))return 3;if(B0(n),o=Kf(he,1),n===o)return 5}return 9};var C0=new ArrayBuffer(9),Jt=new DataView(C0,1),he=new Uint8Array(C0,0);function I0(e){if(e===1/0)Jt.setUint16(0,31744,!1);else if(e===-1/0)Jt.setUint16(0,64512,!1);else if(Number.isNaN(e))Jt.setUint16(0,32256,!1);else{Jt.setFloat32(0,e);let t=Jt.getUint32(0),r=(t&2139095040)>>23,n=t&8388607;if(r===255)Jt.setUint16(0,31744,!1);else if(r===0)Jt.setUint16(0,(t&2147483648)>>16|n>>13,!1);else{let o=r-127;o<-24?Jt.setUint16(0,0):o<-14?Jt.setUint16(0,(t&2147483648)>>16|1<<24+o,!1):Jt.setUint16(0,(t&2147483648)>>16|o+15<<10|n>>13,!1)}}}function $f(e,t){if(e.length-t<2)throw new Error(`${M} not enough data for float16`);let r=(e[t]<<8)+e[t+1];if(r===31744)return 1/0;if(r===64512)return-1/0;if(r===32256)return NaN;let n=r>>10&31,o=r&1023,i;return n===0?i=o*2**-24:n!==31?i=(o+1024)*2**(n-25):i=o===0?1/0:NaN,r&32768?-i:i}function B0(e){Jt.setFloat32(0,e,!1)}function Kf(e,t){if(e.length-t<4)throw new Error(`${M} not enough data for float32`);let r=(e.byteOffset||0)+t;return new DataView(e.buffer,r,4).getFloat32(0,!1)}function C6(e){Jt.setFloat64(0,e,!1)}function D0(e,t){if(e.length-t<8)throw new Error(`${M} not enough data for float64`);let r=(e.byteOffset||0)+t;return new DataView(e.buffer,r,8).getFloat64(0,!1)}Is.compareTokens=Wt.compareTokens;function j(e,t,r){throw new Error(`${M} encountered invalid minor (${r}) for major ${e[t]>>>5}`)}function Bs(e){return()=>{throw new Error(`${M} ${e}`)}}var R=[];for(let e=0;e<=23;e++)R[e]=j;R[24]=Om;R[25]=km;R[26]=Vm;R[27]=Mm;R[28]=j;R[29]=j;R[30]=j;R[31]=j;for(let e=32;e<=55;e++)R[e]=j;R[56]=$m;R[57]=Km;R[58]=zm;R[59]=Hm;R[60]=j;R[61]=j;R[62]=j;R[63]=j;for(let e=64;e<=87;e++)R[e]=jm;R[88]=Gm;R[89]=Ym;R[90]=Zm;R[91]=Xm;R[92]=j;R[93]=j;R[94]=j;R[95]=Bs("indefinite length bytes/strings are not supported");for(let e=96;e<=119;e++)R[e]=Jm;R[120]=Qm;R[121]=t0;R[122]=e0;R[123]=r0;R[124]=j;R[125]=j;R[126]=j;R[127]=Bs("indefinite length bytes/strings are not supported");for(let e=128;e<=151;e++)R[e]=o0;R[152]=i0;R[153]=s0;R[154]=a0;R[155]=c0;R[156]=j;R[157]=j;R[158]=j;R[159]=u0;for(let e=160;e<=183;e++)R[e]=f0;R[184]=l0;R[185]=h0;R[186]=d0;R[187]=p0;R[188]=j;R[189]=j;R[190]=j;R[191]=m0;for(let e=192;e<=215;e++)R[e]=g0;R[216]=y0;R[217]=b0;R[218]=x0;R[219]=w0;R[220]=j;R[221]=j;R[222]=j;R[223]=j;for(let e=224;e<=243;e++)R[e]=Bs("simple values are not supported");R[244]=j;R[245]=j;R[246]=j;R[247]=E0;R[248]=Bs("simple values are not supported");R[249]=v0;R[250]=A0;R[251]=T0;R[252]=j;R[253]=j;R[254]=j;R[255]=S0;var de=[];for(let e=0;e<24;e++)de[e]=new O(w.uint,e,1);for(let e=-1;e>=-24;e--)de[31-e]=new O(w.negint,e,1);de[64]=new O(w.bytes,new Uint8Array(0),1);de[96]=new O(w.string,"",1);de[128]=new O(w.array,0,1);de[160]=new O(w.map,0,1);de[244]=new O(w.false,!1,1);de[245]=new O(w.true,!0,1);de[246]=new O(w.null,null,1);function _0(e){switch(e.type){case w.false:return Ce([244]);case w.true:return Ce([245]);case w.null:return Ce([246]);case w.bytes:return e.value.length?void 0:Ce([64]);case w.string:return e.value===""?Ce([96]):void 0;case w.array:return e.value===0?Ce([128]):void 0;case w.map:return e.value===0?Ce([160]):void 0;case w.uint:return e.value<24?Ce([Number(e.value)]):void 0;case w.negint:if(e.value>=-24)return Ce([31-Number(e.value)])}}var U0=Object.freeze({float64:!0,mapSorter:U6,quickEncodeToken:_0});function B6(){let e=[];return e[w.uint.major]=Wt,e[w.negint.major]=Ss,e[w.bytes.major]=Nn,e[w.string.major]=n0,e[w.array.major]=As,e[w.map.major]=Ts,e[w.tag.major]=Cs,e[w.float.major]=Is,e}var D6=B6(),_6=new qo,Ds=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(`${Nf} object contains circular references`);return new e(r,t)}},dr={null:new O(w.null,null),undefined:new O(w.undefined,void 0),true:new O(w.true,!0),false:new O(w.false,!1),emptyArray:new O(w.array,0),emptyMap:new O(w.map,0)},pr={number(e,t,r,n){return!Number.isInteger(e)||!Number.isSafeInteger(e)?new O(w.float,e):e>=0?new O(w.uint,e):new O(w.negint,e)},bigint(e,t,r,n){return e>=BigInt(0)?new O(w.uint,e):new O(w.negint,e)},Uint8Array(e,t,r,n){return new O(w.bytes,e)},string(e,t,r,n){return new O(w.string,e)},boolean(e,t,r,n){return e?dr.true:dr.false},null(e,t,r,n){return dr.null},undefined(e,t,r,n){return dr.undefined},ArrayBuffer(e,t,r,n){return new O(w.bytes,new Uint8Array(e))},DataView(e,t,r,n){return new O(w.bytes,new Uint8Array(e.buffer,e.byteOffset,e.byteLength))},Array(e,t,r,n){if(!e.length)return r.addBreakTokens===!0?[dr.emptyArray,new O(w.break)]:dr.emptyArray;n=Ds.createCheck(n,e);let o=[],i=0;for(let s of e)o[i++]=On(s,r,n);return r.addBreakTokens?[new O(w.array,e.length),o,new O(w.break)]:[new O(w.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,a;if(s){a=new Array(s),n=Ds.createCheck(n,e);let c=!o&&r.ignoreUndefinedProperties,u=0;for(let f of i){let l=o?e.get(f):e[f];c&&l===void 0||(a[u++]=[On(f,r,n),On(l,r,n)])}u<s&&(a.length=u)}return a?.length?(L6(a,r),r.addBreakTokens?[new O(w.map,a.length),a,new O(w.break)]:[new O(w.map,a.length),a]):r.addBreakTokens===!0?[dr.emptyMap,new O(w.break)]:dr.emptyMap},Tagged(e,t,r,n){return[new O(w.tag,e.tag),On(e.value,r,n)]}};pr.Map=pr.Object;pr.Buffer=pr.Uint8Array;for(let e of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))pr[`${e}Array`]=pr.DataView;function On(e,t={},r){let n=Um(e),o=t&&t.typeEncoders&&t.typeEncoders[n]||pr[n];if(typeof o=="function"){let s=o(e,n,t,r);if(s!=null)return s}let i=pr[n];if(!i)throw new Error(`${Nf} unsupported type: ${n}`);return i(e,n,t,r)}function L6(e,t){t.mapSorter&&e.sort(t.mapSorter)}function U6(e,t){if(e[0]instanceof O&&t[0]instanceof O){let r=e[0],n=t[0];return r._keyBytes||(r._keyBytes=L0(r.value)),n._keyBytes||(n._keyBytes=L0(n.value)),ws(r._keyBytes,n._keyBytes)}throw new Error("rfc8949MapSorter: complex key types are not supported yet")}function L0(e){return R6(e,D6,U0)}function R0(e,t,r,n){if(Array.isArray(t))for(let o of t)R0(e,o,r,n);else r[t.type.major](e,t,n)}var $D=w.uint.majorEncoded,KD=w.negint.majorEncoded,zD=w.bytes.majorEncoded,qD=w.string.majorEncoded,HD=w.array.majorEncoded,jD=w.float.majorEncoded|Pf,GD=w.float.majorEncoded|Of,YD=w.float.majorEncoded|kf,ZD=w.float.majorEncoded|Vf,XD=BigInt(-1),WD=BigInt(1);function R6(e,t,r,n){let o=n instanceof Uint8Array,i=o?new Es(n):_6,s=On(e,r);if(!Array.isArray(s)&&r.quickEncodeToken){let a=r.quickEncodeToken(s);if(a)return o?(i.push(a),i.toBytes()):a;let c=t[s.type.major];if(c.encodedSize){let u=c.encodedSize(s,r);if(o||(i=new qo(u)),c(i,s,r),i.chunks.length!==1)throw new Error(`Unexpected error: pre-calculated length for ${s} was wrong`);return o?i.toBytes():zo(i.chunks[0])}}return i.reset(),R0(i,s,t,r),i.toBytes(!0)}var N6={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0},_s=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=de[t];if(r===void 0){let n=R[t];if(!n)throw new Error(`${M} no decoder for major type ${t>>>5} (byte 0x${t.toString(16).padStart(2,"0")})`);let o=t&31;r=n(this.data,this._pos,o,this.options)}return this._pos+=r.encodedLength,r}},mr=Symbol.for("DONE"),kn=Symbol.for("BREAK");function F6(e,t,r){let n=[];for(let o=0;o<e.value;o++){let i=gr(t,r);if(i===kn){if(e.value===1/0)break;throw new Error(`${M} got unexpected break to lengthed array`)}if(i===mr)throw new Error(`${M} found array but not enough entries (got ${o}, expected ${e.value})`);n[o]=i}return n}function P6(e,t,r){let n=r.useMaps===!0,o=r.rejectDuplicateMapKeys===!0,i=n?void 0:{},s=n?new Map:void 0;for(let a=0;a<e.value;a++){let c=gr(t,r);if(c===kn){if(e.value===1/0)break;throw new Error(`${M} got unexpected break to lengthed map`)}if(c===mr)throw new Error(`${M} found map but not enough entries (got ${a} [no key], expected ${e.value})`);if(!n&&typeof c!="string")throw new Error(`${M} non-string keys not supported (got ${typeof c})`);if(o&&(n&&s.has(c)||!n&&Object.hasOwn(i,c)))throw new Error(`${M} found repeat map key "${c}"`);let u=gr(t,r);if(u===mr)throw new Error(`${M} found map but not enough entries (got ${a} [no value], expected ${e.value})`);n?s.set(c,u):i[c]=u}return n?s:i}function*O6(e,t,r){for(let n=0;n<e.value;n++){let o=gr(t,r);if(o===kn){if(e.value===1/0)break;throw new Error(`${M} got unexpected break to lengthed map`)}if(o===mr)throw new Error(`${M} found map but not enough entries (got ${n} [no key], expected ${e.value})`);let i=gr(t,r);if(i===mr)throw new Error(`${M} found map but not enough entries (got ${n} [no value], expected ${e.value})`);yield[o,i]}}function k6(e,t){let r=!1,n=function(){if(r)throw new Error(`${M} tag decode() may only be called once`);r=!0;let o=gr(e,t);if(o===mr)throw new Error(`${M} tag content missing`);if(o===kn)throw new Error(`${M} got unexpected break in tag content`);return o};return n.entries=function(){if(r)throw new Error(`${M} tag decode() may only be called once`);r=!0;let o=e.next();if(!w.equals(o.type,w.map))throw new Error(`${M} entries() requires map content, got ${o.type.name}`);let i=[];for(let s of O6(o,e,t))i.push(s);return i},Object.defineProperty(n,"_called",{get(){return r},enumerable:!1}),n}function gr(e,t){if(e.done())return mr;let r=e.next();if(w.equals(r.type,w.break))return kn;if(r.type.terminal)return r.value;if(w.equals(r.type,w.array))return F6(r,e,t);if(w.equals(r.type,w.map))return P6(r,e,t);if(w.equals(r.type,w.tag)){if(t.tags&&typeof t.tags[r.value]=="function"){let n=k6(e,t),o=t.tags[r.value](n);if(!n._called)throw new Error(`${M} tag decoder must call decode() or entries()`);return o}throw new Error(`${M} tag not supported (${r.value})`)}throw new Error("unsupported")}function N0(e,t){if(!(e instanceof Uint8Array))throw new Error(`${M} data to decode must be a Uint8Array`);t=Object.assign({},N6,t);let r=zo(e),n=t.tokenizer||new _s(r,t),o=gr(n,t);if(o===mr)throw new Error(`${M} did not find any content to decode`);if(o===kn)throw new Error(`${M} got unexpected break`);return[o,e.subarray(n.pos())]}function Yo(e,t){let[r,n]=N0(e,t);if(n.length>0)throw new Error(`${M} too many terminals, data makes no sense`);return r}var Ls=class e{constructor(t,r){if(typeof t!="number"||!Number.isInteger(t)||t<0)throw new TypeError("Tagged: tag must be a non-negative integer");this.tag=t,this.value=r}static decoder(t){return r=>new e(t,r())}static preserve(...t){let r={};for(let n of t)r[n]=e.decoder(n);return r}};Object.defineProperty(Ls.prototype,Symbol.toStringTag,{value:"Tagged"});function zf(e,t){t==null&&(t=e.reduce((o,i)=>o+i.length,0));let r=Ae(t),n=0;for(let o of e)r.set(o,n),n+=o.length;return r}function Vr(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 qf(e,t="utf8"){let r=fs[t];if(r==null)throw new Error(`Unsupported encoding "${t}"`);return r.encoder.encode(e).substring(1)}var V6=ce("ipns:utils"),O0=Te("/ipns/");var M6=0,$6=18;function k0(e){let t;if(e.pubKey!=null)try{t=Dd(e.pubKey)}catch(r){throw V6.error(r),r}if(t!=null)return t}function V0(e){let t=Te("ipns-signature:");return zf([t,e])}function Zo(e){return"signatureV1"in e?le.encode({value:Te(e.value),signatureV1:e.signatureV1,validityType:e.validityType,validity:Te(e.validity),sequence:e.sequence,ttl:e.ttl,pubKey:e.pubKey,signatureV2:e.signatureV2,data:e.data}):le.encode({pubKey:e.pubKey,signatureV2:e.signatureV2,data:e.data})}function yr(e){let t=le.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 ue("Missing data or signatureV2");let r=M0(t.data),n=K6(r.Value),o=qf(r.Validity);if(t.value!=null&&t.signatureV1!=null)return z6(t),{value:n,validityType:le.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:le.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 Xo(e){return zf([O0,e.bytes])}function Vn(e){let t=Fo(e.slice(O0.length));if(!Us(t,M6)&&!Us(t,$6))throw new je("Multihash in IPNS key was not identity or sha2-256");return t}function M0(e){let t=Yo(e);if(t.ValidityType===0)t.ValidityType=le.ValidityType.EOL;else throw new Rn("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 K6(e){let t=qf(e).trim();if(t.startsWith("/"))return t;try{return`/ipfs/${Bt.decode(e).toV1().toString()}`}catch{}try{return`/ipfs/${Bt.parse(t).toV1().toString()}`}catch{}throw new ds("Value must be a valid content path starting with /")}function z6(e){if(e.data==null)throw new ps("Record data is missing");let t=M0(e.data);if(!Vr(t.Value,e.value??new Uint8Array(0)))throw new ue('Field "value" did not match between protobuf and CBOR');if(!Vr(t.Validity,e.validity??new Uint8Array(0)))throw new ue('Field "validity" did not match between protobuf and CBOR');if(t.ValidityType!==e.validityType)throw new ue('Field "validityType" did not match between protobuf and CBOR');if(t.Sequence!==e.sequence)throw new ue('Field "sequence" did not match between protobuf and CBOR');if(t.TTL!==e.ttl)throw new ue('Field "ttl" did not match between protobuf and CBOR')}function Us(e,t){return e.code===t}var U_=ce("ipns"),R_=300*1e9,H6="/ipns/",N_=H6.length;var $0=ii(cs(),1);var Rs=ce("ipns:validator"),j6=1024*10;async function G6(e,t){let r=yr(t),n;try{let o=V0(r.data);n=await e.verify(o,r.signatureV2)}catch{n=!1}if(!n)throw Rs.error("record signature verification failed"),new ue("Record signature verification failed");if(r.validityType===le.ValidityType.EOL){if($0.default.fromString(r.validity).toDate().getTime()<Date.now())throw Rs.error("record has expired"),new ls("record has expired")}else if(r.validityType!=null)throw Rs.error("the validity type is unsupported"),new Rn("The validity type is unsupported");Rs("ipns record for %s is valid",r.value)}async function K0(e,t){if(t.byteLength>j6)throw new hs("The record is too large");let r=Vn(e),n;Us(r,0)&&(n=zi(r));let o=yr(t),i=k0(o)??n;if(i==null)throw new Oo("Could not extract public key from IPNS record or routing key");let s=Xo(i.toMultihash());if(!Vr(s,e))throw new Oo("Embedded public key did not match routing key");await G6(i,t)}function ze(e=0){return new Uint8Array(e)}function Wo(e=0){return new Uint8Array(e)}function Hf(e,t){t==null&&(t=e.reduce((o,i)=>o+i.length,0));let r=Wo(t),n=0;for(let o of e)r.set(o,n),n+=o.length;return r}function z0(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}var j0=Symbol.for("@achingbrain/uint8arraylist");function q0(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 Mn(e){return!!e?.[j0]}var H0=class e{bufs;length;[j0]=!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(Mn(n)){r+=n.byteLength;for(let o of n.bufs)this.bufs.push(o)}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(Mn(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=q0(this.bufs,t);return r.buf[r.index]}set(t,r){let n=q0(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(Mn(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 Hf(n,o)}subarray(t,r){let{bufs:n,length:o}=this._subList(t,r);return n.length===1?n[0]:Hf(n,o)}sublist(t,r){let{bufs:n,length:o}=this._subList(t,r),i=new e;return i.length=o,i.bufs=n,i}_subList(t,r){if(t=t??0,r=r??this.length,t<0&&(t=this.length+t),r<0&&(r=this.length+r),t<0||r>this.length)throw new RangeError("index is out of bounds");if(t===r)return{bufs:[],length:0};if(t===0&&r===this.length)return{bufs:[...this.bufs],length:this.length};let n=[],o=0;for(let i=0;i<this.bufs.length;i++){let s=this.bufs[i],a=o,c=a+s.byteLength;if(o=c,t>=c)continue;let u=t>=a&&t<c,f=r>a&&r<=c;if(u&&f){if(t===a&&r===c){n.push(s);break}let l=t-a;n.push(s.subarray(l,l+(r-t)));break}if(u){if(t===0){n.push(s);continue}n.push(s.subarray(t-a));continue}if(f){if(r===c){n.push(s);break}n.push(s.subarray(0,r-a));break}n.push(s)}return{bufs:n,length:r-t}}indexOf(t,r=0){if(!Mn(t)&&!(t instanceof Uint8Array))throw new TypeError('The "value" argument must be a Uint8ArrayList or Uint8Array');let n=t instanceof Uint8Array?t:t.subarray();if(r=Number(r??0),isNaN(r)&&(r=0),r<0&&(r=this.length+r),r<0&&(r=0),t.length===0)return r>this.length?this.length:r;let o=n.byteLength;if(o===0)throw new TypeError("search must be at least 1 byte long");let i=256,s=new Int32Array(i);for(let l=0;l<i;l++)s[l]=-1;for(let l=0;l<o;l++)s[n[l]]=l;let a=s,c=this.byteLength-n.byteLength,u=n.byteLength-1,f;for(let l=r;l<=c;l+=f){f=0;for(let d=u;d>=0;d--){let x=this.get(l+d);if(n[d]!==x){f=Math.max(1,d-a[x]);break}}if(f===0)return l}return-1}getInt8(t){let r=this.subarray(t,t+1);return new DataView(r.buffer,r.byteOffset,r.byteLength).getInt8(0)}setInt8(t,r){let n=Wo(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=ze(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=ze(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=ze(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=Wo(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=ze(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=ze(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=ze(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=ze(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=ze(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(!z0(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 Ns=class extends Error{name="InvalidMessageLengthError";code="ERR_INVALID_MESSAGE_LENGTH"};async function*$n(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)),Mn(i)&&(i=i.subarray()),o+=n.decode(i,{stream:!0}),o.length>(t?.maxMessageLength??o.length))throw new Ns("Incoming message too long");let s=o.split(r);o=s.pop()??"";for(let a=0;a<s.length;a++)yield JSON.parse(s[a])}o+=n.decode(),o!==""&&(yield JSON.parse(o))}function Qt(){let e={};return e.promise=new Promise((t,r)=>{e.resolve=t,e.reject=r}),e}var Gf=ii(Y0(),1);var Yf=class e extends Error{name="TimeoutError";constructor(t,r){super(t,r),Error.captureStackTrace?.(this,e)}},Z0=e=>e.reason??new DOMException("This operation was aborted.","AbortError");function Zf(e,t){let{milliseconds:r,fallback:n,message:o,customTimers:i={setTimeout,clearTimeout},signal:s}=t,a,c,f=new Promise((l,d)=>{if(typeof r!="number"||Math.sign(r)!==1)throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${r}\``);if(s?.aborted){d(Z0(s));return}if(s&&(c=()=>{d(Z0(s))},s.addEventListener("abort",c,{once:!0})),e.then(l,d),r===Number.POSITIVE_INFINITY)return;let x=new Yf;a=i.setTimeout.call(void 0,()=>{if(n){try{l(n())}catch(h){d(h)}return}typeof e.cancel=="function"&&e.cancel(),o===!1?l():o instanceof Error?d(o):(x.message=o??`Promise timed out after ${r} milliseconds`,d(x))},r)}).finally(()=>{f.clear(),c&&s&&s.removeEventListener("abort",c)});return f.clear=()=>{i.clearTimeout.call(void 0,a),a=void 0},f}function Xf(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 X6=100,Kn=class{#t=[];#e=0;enqueue(t,r){let{priority:n=0,id:o}=r??{},{size:i}=this,s={priority:n,id:o,run:t};if(i===0){this.#t.length=0,this.#e=0,this.#t.push(s);return}if(this.#t.at(-1).priority>=n){this.#t.push(s);return}this.#r();let a=Xf(this.#t,s,(c,u)=>u.priority-c.priority);this.#t.splice(a,0,s)}setPriority(t,r){let n=this.#t.findIndex((i,s)=>s>=this.#e&&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})}remove(t){let r=this.#t.findIndex((n,o)=>o<this.#e?!1:typeof t=="string"?n.id===t:n.run===t);r!==-1&&this.#t.splice(r,1)}dequeue(){if(this.#e===this.#t.length)return;let t=this.#t[this.#e];return this.#e++,this.#e===this.#t.length?(this.#t.length=0,this.#e=0):this.#e>X6&&this.#e>this.#t.length/2&&this.#r(),t?.run}filter(t){let r=[];for(let n=this.#e;n<this.#t.length;n++){let o=this.#t[n];o.priority===t.priority&&r.push(o.run)}return r}get size(){return this.#t.length-this.#e}#r(){this.#e!==0&&(this.#t.splice(0,this.#e),this.#e=0)}};var Qo=class extends Gf.default{#t;#e;#r=0;#d;#m=!1;#x=!1;#c;#I=0;#w=0;#u;#f;#a;#s=[];#i=0;#n;#B;#o=0;#g;#l;#R=1n;#y=new Map;#E=new Set;timeout;constructor(t){if(super(),t={carryoverIntervalCount:!1,intervalCap:Number.POSITIVE_INFINITY,interval:0,concurrency:Number.POSITIVE_INFINITY,autoStart:!0,queueClass:Kn,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.#e=t.intervalCap===Number.POSITIVE_INFINITY||t.interval===0,this.#d=t.intervalCap,this.#c=t.interval,this.#a=t.strict,this.#n=new t.queueClass,this.#B=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.#$()}#S(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.#r++}#F(){this.#a?this.#s.length>this.#i&&this.#s.pop():this.#r>0&&this.#r--}#v(){return this.#s.length-this.#i}get#P(){return this.#e?!0:this.#a?this.#v()<this.#d:this.#r<this.#d}get#O(){return this.#o<this.#g}#k(){this.#o--,this.#o===0&&this.emit("pendingZero"),this.#b(),this.emit("next")}#V(){this.#f=void 0,this.#L(),this.#_()}#M(t){if(this.#a){if(this.#S(t),this.#v()>=this.#d){let n=this.#s[this.#i],o=this.#c-(t-n);return this.#A(o),!0}return!1}if(this.#u===void 0){let r=this.#I-t;if(r<0){if(this.#w>0){let n=t-this.#w;if(n<this.#c)return this.#A(this.#c-n),!0}this.#r=this.#t?this.#o:0}else return this.#A(r),!0}return!1}#A(t){this.#f===void 0&&(this.#f=setTimeout(()=>{this.#V()},t))}#T(){this.#u&&(clearInterval(this.#u),this.#u=void 0)}#D(){this.#f&&(clearTimeout(this.#f),this.#f=void 0)}#b(){if(this.#n.size===0){if(this.#T(),this.emit("empty"),this.#o===0){if(this.#D(),this.#a&&this.#i>0){let r=Date.now();this.#S(r)}this.emit("idle")}return!1}let t=!1;if(!this.#l){let r=Date.now(),n=!this.#M(r);if(this.#P&&this.#O){let o=this.#n.dequeue();this.#e||(this.#N(r),this.#p()),this.emit("active"),o(),n&&this.#_(),t=!0}}return t}#_(){this.#e||this.#u!==void 0||this.#a||(this.#u=setInterval(()=>{this.#L()},this.#c),this.#I=Date.now()+this.#c)}#L(){this.#a||(this.#r===0&&this.#o===0&&this.#u&&this.#T(),this.#r=this.#t?this.#o:0),this.#C(),this.#p()}#C(){for(;this.#b(););}get concurrency(){return this.#g}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.#g=t,this.#C()}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.#n.setPriority(t,r)}async add(t,r={}){return r={timeout:this.timeout,...r,id:r.id??(this.#R++).toString()},new Promise((n,o)=>{let i=Symbol(`task-${r.id}`),s=()=>{},a=async()=>{s(),this.#o++,this.#y.set(i,{id:r.id,priority:r.priority??0,startTime:Date.now(),timeout:r.timeout});let u;try{try{r.signal?.throwIfAborted()}catch(d){throw this.#K(),this.#y.delete(i),d}this.#w=Date.now();let f=t({signal:r.signal});if(r.timeout&&(f=Zf(Promise.resolve(f),{milliseconds:r.timeout,message:`Task timed out after ${r.timeout}ms (queue has ${this.#o} running, ${this.#n.size} waiting)`})),r.signal){let{signal:d}=r;f=Promise.race([f,new Promise((x,h)=>{u=()=>{h(d.reason)},d.addEventListener("abort",u,{once:!0})})])}let l=await f;n(l),this.emit("completed",l)}catch(f){o(f),this.emit("error",f)}finally{u&&r.signal?.removeEventListener("abort",u),this.#y.delete(i),queueMicrotask(()=>{this.#k()})}};this.#n.enqueue(a,r);let c=()=>{if(this.#n instanceof Kn){this.#n.remove(a);return}this.#n.remove?.(r.id)};if(r.signal){let{signal:u}=r,f=()=>{s(),c(),o(u.reason),this.#b(),this.emit("next")};if(s=()=>{u.removeEventListener("abort",f),this.#E.delete(s)},u.aborted){f();return}u.addEventListener("abort",f,{once:!0}),this.#E.add(s)}this.emit("add"),this.#b()})}async addAll(t,r){return Promise.all(t.map(async n=>this.add(n,r)))}start(){return this.#l?(this.#l=!1,this.#C(),this):this}pause(){this.#l=!0}clear(){for(let t of this.#E)t();this.#n=new this.#B,this.#T(),this.#U(),this.emit("empty"),this.#o===0&&(this.#D(),this.emit("idle")),this.emit("next")}async onEmpty(){this.#n.size!==0&&await this.#h("empty")}async onSizeLessThan(t){this.#n.size<t||await this.#h("next",()=>this.#n.size<t)}async onIdle(){this.#o===0&&this.#n.size===0||await this.#h("idle")}async onPendingZero(){this.#o!==0&&await this.#h("pendingZero")}async onRateLimit(){this.isRateLimited||await this.#h("rateLimit")}async onRateLimitCleared(){this.isRateLimited&&await this.#h("rateLimitCleared")}onError(){return new Promise((t,r)=>{let n=o=>{this.off("error",n),r(o)};this.on("error",n)})}async#h(t,r){return new Promise(n=>{let o=()=>{r&&!r()||(this.off(t,o),n())};this.on(t,o)})}get size(){return this.#n.size}sizeBy(t){return this.#n.filter(t).length}get pending(){return this.#o}get isPaused(){return this.#l}#$(){this.#e||(this.on("add",()=>{this.#n.size>0&&this.#p()}),this.on("next",()=>{this.#p()}))}#p(){this.#e||this.#x||(this.#x=!0,queueMicrotask(()=>{this.#x=!1,this.#U()}))}#K(){this.#e||(this.#F(),this.#p())}#U(){let t=this.#m;if(this.#e||this.#n.size===0){t&&(this.#m=!1,this.emit("rateLimitCleared"));return}let r;if(this.#a){let o=Date.now();this.#S(o),r=this.#v()}else r=this.#r;let n=r>=this.#d;n!==t&&(this.#m=n,this.emit(n?"rateLimit":"rateLimitCleared"))}get isRateLimited(){return this.#m}get isSaturated(){return this.#o===this.#g&&this.#n.size>0||this.isRateLimited&&this.#n.size>0}get runningTasks(){return[...this.#y.values()].map(t=>({...t}))}};var Mr=class extends Error{static name="InvalidRequestError";constructor(t="Invalid request"){super(t),this.name="InvalidRequestError"}},te=class extends Error{static name="BadResponseError";constructor(t="Bad response"){super(t),this.name="BadResponseError"}};function W6(e){return e[Symbol.asyncIterator]!=null}function J6(e){if(W6(e))return(async()=>{for await(let t of e)return t})();for(let t of e)return t}var Ps=J6;function Q6(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 X0=Q6;function t8(e){return e[Symbol.asyncIterator]!=null}function e8(e,t){let r=0;if(t8(e))return(async function*(){for await(let c of e)yield t(c,r++)})();let n=X0(e),{value:o,done:i}=n.next();if(i===!0)return(function*(){})();let s=t(o,r++);if(typeof s.then=="function")return(async function*(){yield await s;for(let c of n)yield t(c,r++)})();let a=t;return(function*(){yield s;for(let c of n)yield a(c,r++)})()}var Os=e8;var W0=Te("/ipns/");function J0(e){return Vr(e.subarray(0,W0.byteLength),W0)}var ks=class{client;constructor(t){this.client=t}async*findProviders(t,r={}){try{yield*Os(this.client.getProviders(t,r),n=>({id:n.ID,multiaddrs:n.Addrs??[],routing:"delegated-http-routing-v1"}))}catch(n){if(n instanceof Ut)return;throw n}}async provide(){}async cancelReprovide(){}async put(t,r,n){if(!J0(t))return;let o=Vn(t),i=Bt.createV1(114,o),s=yr(r);await this.client.putIPNS(i,s,n)}async get(t,r){if(!J0(t))throw new Ut("Not found");let n=Vn(t),o=Bt.createV1(114,n);try{let i=await this.client.getIPNS(o,r);return Zo(i)}catch(i){throw i.name==="BadResponseError"?new Ut("Not found"):i}}toString(){return`DelegatedRoutingV1HttpApiClientContentRouting(${this.client.url})`}},Vs=class{client;constructor(t){this.client=t}async findPeer(t,r={}){let n=await Ps(this.client.getPeers(t,r));if(n!=null)return{id:n.ID,multiaddrs:n.Addrs??[]};throw new Ut("Not found")}async*getClosestPeers(t,r={}){let n;try{n=Bt.decode(t)}catch{try{n=Zi($e.decode(t))}catch{n=Bt.createV1(nm,ff.digest(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 Ms={concurrentRequests:4,timeout:3e4,cacheTTL:300*1e3,cacheName:"delegated-routing-v1-cache"},$s=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 Qo({concurrency:r.concurrentRequests??Ms.concurrentRequests}),this.inFlightRequests=new Map,this.url=r.url instanceof URL?r.url:new URL(r.url),this.timeout=r.timeout??Ms.timeout,this.filterAddrs=r.filterAddrs,this.filterProtocols=r.filterProtocols,this.contentRouting=new ks(this),this.peerRouting=new Vs(this),this.cacheName=r.cacheName??Ms.cacheName,this.cacheTTL=r.cacheTTL??Ms.cacheTTL}get[Bl](){return this.contentRouting}get[_l](){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=In([this.shutDownController.signal,n,r.signal]);let i=Qt(),s=Qt(),a=0;this.httpQueue.add(async()=>(i.resolve(),s.promise));try{await i.promise;let c=new URL(`${this.url}routing/v1/providers/${t}`);this.#e(c,r.filterAddrs,r.filterProtocols);let u={headers:{accept:"application/x-ndjson, application/json;q=0.8"},signal:o},f=await this.#r(c.toString(),u);if(!f.ok){if(f.status===404)return;throw f.status===422?new Mr("Request does not conform to schema or semantic constraints"):new te(`Unexpected status code: ${f.status}`)}let l=f.headers.get("Content-Type");if(l==null)throw new te("No Content-Type header received");if(f.body==null){if(l!=="application/x-ndjson")throw new te("Routing response had no body");return}if(l.startsWith("application/json")){let x=(await f.json()).Providers??[];for(let h of x){let g=this.#t(h);g!=null&&(a++,yield g)}}else if(l.includes("application/x-ndjson"))for await(let d of $n(Uo(f.body))){let x=this.#t(d);x!=null&&(a++,yield x)}else throw new te(`Unsupported Content-Type: ${l}`)}finally{o.clear(),s.resolve(),this.log("getProviders finished found %d providers for %c",a,t)}}async*getPeers(t,r={}){this.log("getPeers starts: %c",t);let n=AbortSignal.timeout(this.timeout),o=In([this.shutDownController.signal,n,r.signal]);let i=Qt(),s=Qt();this.httpQueue.add(async()=>(i.resolve(),s.promise));try{await i.promise;let a=new URL(`${this.url}routing/v1/peers/${t.toCID().toString()}`);this.#e(a,r.filterAddrs,r.filterProtocols);let c={headers:{Accept:"application/x-ndjson"},signal:o},u=await this.#r(a.toString(),c);if(u.status===404)return;if(u.status===422)throw new Mr("Request does not conform to schema or semantic constraints");if(u.body==null)throw new te("Routing response had no body");if(u.headers.get("Content-Type")?.startsWith("application/json")){let d=(await u.json()).Peers??[];for(let x of d){let h=this.#t(x);h!=null&&(yield h)}}else for await(let l of $n(Uo(u.body))){let d=this.#t(l);d!=null&&(yield d)}}catch(a){this.log.error("getPeers errored - %e",a)}finally{o.clear(),s.resolve(),this.log("getPeers finished: %c",t)}}async*getClosestPeers(t,r={}){let n;if(Dl(t))n=t.toCID().toString();else if(Bt.asCID(t)===t||t instanceof Bt)n=t.toV1().toString();else throw new W("Key must be CID or PeerId");this.log("getClosestPeers starts: %s",n);let o=AbortSignal.timeout(this.timeout),i=In([this.shutDownController.signal,o,r.signal]);let s=Qt(),a=Qt();this.httpQueue.add(async()=>(s.resolve(),a.promise));try{await s.promise;let c=new URL(`${this.url}routing/v1/dht/closest/peers/${n}`);this.#e(c,r.filterAddrs,r.filterProtocols);let u={headers:{Accept:"application/x-ndjson"},signal:i},f=await this.#r(c.toString(),u);if(f.status===404)return;if(f.status===422)throw new Mr("Request does not conform to schema or semantic constraints");if(f.body==null)throw new te("Routing response had no body");if(f.headers.get("Content-Type")?.startsWith("application/json")){let x=(await f.json()).Peers??[];for(let h of x){let g=this.#t(h);g!=null&&(yield g)}}else for await(let d of $n(Uo(f.body))){let x=this.#t(d);x!=null&&(yield x)}}catch(c){this.log.error("getClosestPeers errored - %e",c)}finally{i.clear(),a.resolve(),this.log("getClosestPeers finished: %s",n)}}async getIPNS(t,r={}){this.log("getIPNS starts: %s",t);let n=AbortSignal.timeout(this.timeout),o=In([this.shutDownController.signal,n,r.signal]);let i=Qt(),s=Qt();this.httpQueue.add(async()=>(i.resolve(),s.promise));let a=`${this.url}routing/v1/ipns/${t}`;try{await i.promise;let c={headers:{Accept:"application/vnd.ipfs.ipns-record"},signal:o},u=await this.#r(a,c);if(this.log("getIPNS GET %s %d",a,u.status),u.status===404)throw new Ut("No matching records found");if(u.status===422)throw new Mr("Request does not conform to schema or semantic constraints");if(!u.ok)throw new te(`Unexpected status code: ${u.status}`);let f=u.headers.get("Content-Type");if(f==null||!f.includes("application/vnd.ipfs.ipns-record"))throw new Ut("No matching records found");if(u.body==null)throw new te("GET ipns response had no body");let l=await u.arrayBuffer(),d=new Uint8Array(l,0,l.byteLength);return r.validate!==!1&&await K0(Xo(t.multihash),d),yr(d)}catch(c){throw this.log.error("getIPNS GET %s error - %e",a,c),c}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=In([this.shutDownController.signal,o,n.signal]);let s=Qt(),a=Qt();this.httpQueue.add(async()=>(s.resolve(),a.promise));let c=`${this.url}routing/v1/ipns/${t}`;try{await s.promise;let u=Zo(r),f={method:"PUT",headers:{"Content-Type":"application/vnd.ipfs.ipns-record"},body:u,signal:i},l=await this.#r(c,f);if(this.log("putIPNS PUT %s %d",c,l.status),l.status!==200)throw new te("PUT ipns response had status other than 200")}catch(u){throw this.log.error("putIPNS PUT %s error - %e",c,u.stack),u}finally{i.clear(),a.resolve(),this.log("putIPNS finished: %c",t)}}#t(t){try{let r=[],n=t.Addrs?.map(is)??[];return t.Protocols!=null&&r.push(...t.Protocols),t.Protocol!=null&&(r.push(t.Protocol),delete t.Protocol),{...t,Schema:"peer",ID:ep(t.ID),Addrs:n,Protocols:r}}catch(r){this.log.error("could not conform record to peer schema - %e",r)}}#e(t,r,n){if(r!=null||this.filterAddrs!=null){let o=r?.join(",")??this.filterAddrs?.join(",")??"";o!==""&&t.searchParams.set("filter-addrs",o)}if(n!=null||this.filterProtocols!=null){let o=n?.join(",")??this.filterProtocols?.join(",")??"";o!==""&&t.searchParams.set("filter-protocols",o)}}async#r(t,r){let n=r.method??"GET",o=`${n}-${t}`;if(n==="GET"){let c=await this.cache?.match(t);if(c!=null){if(parseInt(c.headers.get("x-cache-expires")??"0",10)>Date.now())return this.log("returning cached response for %s",o),this.logResponse(c),c;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 c=await i;return this.log("deduplicating outgoing request for %s",o),c.clone()}this.log("outgoing request:"),this.logRequest(t,r);let s=fetch(t,r).then(async c=>{if(this.log("incoming response:"),this.logResponse(c),this.cache!=null&&c.ok&&n==="GET"){let u=Date.now()+this.cacheTTL,f=new Headers(c.headers);f.set("x-cache-expires",u.toString());let l=new Response(c.clone().body,{status:c.status,statusText:c.statusText,headers:f});await this.cache.put(t,l)}return c}).finally(()=>{this.inFlightRequests.delete(o)});return this.inFlightRequests.set(o,s),await s}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 Q0(e){return t=>new $s(t,e)}var m8=ii(cs(),1);var qe=class extends Error{static name="SignatureVerificationError";constructor(t="Record signature verification failed"){super(t),this.name="SignatureVerificationError"}};var Ks=class extends Error{static name="UnsupportedValidityError";constructor(t="The validity type is unsupported"){super(t),this.name="UnsupportedValidityError"}};var zs=class extends Error{static name="InvalidValueError";constructor(t="Value must be a valid content path starting with /"){super(t),this.name="InvalidValueError"}},qs=class extends Error{static name="InvalidRecordDataError";constructor(t="Invalid record data"){super(t),this.name="InvalidRecordDataError"}};var Wf=new Float32Array([-0]),br=new Uint8Array(Wf.buffer);function tg(e,t,r){Wf[0]=e,t[r]=br[0],t[r+1]=br[1],t[r+2]=br[2],t[r+3]=br[3]}function eg(e,t){return br[0]=e[t],br[1]=e[t+1],br[2]=e[t+2],br[3]=e[t+3],Wf[0]}var Jf=new Float64Array([-0]),Tt=new Uint8Array(Jf.buffer);function rg(e,t,r){Jf[0]=e,t[r]=Tt[0],t[r+1]=Tt[1],t[r+2]=Tt[2],t[r+3]=Tt[3],t[r+4]=Tt[4],t[r+5]=Tt[5],t[r+6]=Tt[6],t[r+7]=Tt[7]}function ng(e,t){return Tt[0]=e[t],Tt[1]=e[t+1],Tt[2]=e[t+2],Tt[3]=e[t+3],Tt[4]=e[t+4],Tt[5]=e[t+5],Tt[6]=e[t+6],Tt[7]=e[t+7],Jf[0]}var r8=BigInt(Number.MAX_SAFE_INTEGER),n8=BigInt(Number.MIN_SAFE_INTEGER),Gt=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 $r;if(t<r8&&t>n8)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>og&&(o=0n,++n>og&&(n=0n))),new e(Number(o),Number(n))}static fromNumber(t){if(t===0)return $r;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):$r}},$r=new Gt(0,0);$r.toBigInt=function(){return 0n};$r.zzEncode=$r.zzDecode=function(){return this};$r.length=function(){return 1};var og=4294967296n;function ig(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 sg(e,t,r){if(r-t<1)return"";let o,i=[],s=0,a;for(;t<r;)a=e[t++],a<128?i[s++]=a:a>191&&a<224?i[s++]=(a&31)<<6|e[t++]&63:a>239&&a<365?(a=((a&7)<<18|(e[t++]&63)<<12|(e[t++]&63)<<6|e[t++]&63)-65536,i[s++]=55296+(a>>10),i[s++]=56320+(a&1023)):i[s++]=(a&15)<<12|(e[t++]&63)<<6|e[t++]&63,s>8191&&((o??(o=[])).push(String.fromCharCode.apply(String,i)),s=0);return o!=null?(s>0&&o.push(String.fromCharCode.apply(String,i.slice(0,s))),o.join("")):String.fromCharCode.apply(String,i.slice(0,s))}function Qf(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 pe(e,t){return RangeError(`index out of range: ${e.pos} + ${t??1} > ${e.len}`)}function Hs(e,t){return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0}var tl=class{buf;pos;len;_slice=Uint8Array.prototype.subarray;constructor(t){this.buf=Co(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,pe(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 pe(this,4);return Hs(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw pe(this,4);return Hs(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw pe(this,4);let t=eg(this.buf,this.pos);return this.pos+=4,t}double(){if(this.pos+8>this.len)throw pe(this,4);let t=ng(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 pe(this,t);return this.pos+=t,r===n?new Uint8Array(0):this.buf.subarray(r,n)}string(){let t=this.bytes();return sg(t,0,t.length)}skip(t){if(typeof t=="number"){if(this.pos+t>this.len)throw pe(this,t);this.pos+=t}else do if(this.pos>=this.len)throw pe(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 Gt(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 pe(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 pe(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 pe(this,8);let t=Hs(this.buf,this.pos+=4),r=Hs(this.buf,this.pos+=4);return new Gt(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=au(this.buf,this.pos);return this.pos+=Ee(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 ti(e){return new tl(e instanceof Uint8Array?e:e.subarray())}function el(e,t,r){let n=ti(e);return t.decode(n,void 0,r)}function rl(e){let t=e??8192,r=t>>>1,n,o=t;return function(s){if(s<1||s>r)return Xt(s);o+s>t&&(n=Xt(t),o=0);let a=n.subarray(o,o+=s);return(o&7)!==0&&(o=(o|7)+1),a}}var Kr=class{fn;len;next;val;constructor(t,r,n){this.fn=t,this.len=r,this.next=void 0,this.val=n}};function nl(){}var il=class{head;tail;len;next;constructor(t){this.head=t.head,this.tail=t.tail,this.len=t.len,this.next=t.states}},o8=rl();function i8(e){return globalThis.Buffer!=null?Xt(e):o8(e)}var ri=class{len;head;tail;states;constructor(){this.len=0,this.head=new Kr(nl,0,0),this.tail=this.head,this.states=null}_push(t,r,n){return this.tail=this.tail.next=new Kr(t,r,n),this.len+=r,this}uint32(t){return this.len+=(this.tail=this.tail.next=new sl((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(js,10,Gt.fromNumber(t)):this.uint32(t)}sint32(t){return this.uint32((t<<1^t>>31)>>>0)}uint64(t){let r=Gt.fromBigInt(t);return this._push(js,r.length(),r)}uint64Number(t){return this._push(To,Ee(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=Gt.fromBigInt(t).zzEncode();return this._push(js,r.length(),r)}sint64Number(t){let r=Gt.fromNumber(t).zzEncode();return this._push(js,r.length(),r)}sint64String(t){return this.sint64(BigInt(t))}bool(t){return this._push(ol,1,t?1:0)}fixed32(t){return this._push(ei,4,t>>>0)}sfixed32(t){return this.fixed32(t)}fixed64(t){let r=Gt.fromBigInt(t);return this._push(ei,4,r.lo)._push(ei,4,r.hi)}fixed64Number(t){let r=Gt.fromNumber(t);return this._push(ei,4,r.lo)._push(ei,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(tg,4,t)}double(t){return this._push(rg,8,t)}bytes(t){let r=t.length>>>0;return r===0?this._push(ol,1,0):this.uint32(r)._push(a8,r,t)}string(t){let r=ig(t);return r!==0?this.uint32(r)._push(Qf,r,t):this._push(ol,1,0)}fork(){return this.states=new il(this),this.head=this.tail=new Kr(nl,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 Kr(nl,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=i8(this.len),n=0;for(;t!=null;)t.fn(t.val,r,n),n+=t.len,t=t.next;return r}};function ol(e,t,r){t[r]=e&255}function s8(e,t,r){for(;e>127;)t[r++]=e&127|128,e>>>=7;t[r]=e}var sl=class extends Kr{next;constructor(t,r){super(s8,t,r),this.next=void 0}};function js(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 ei(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 a8(e,t,r){t.set(e,r)}globalThis.Buffer!=null&&(ri.prototype.bytes=function(e){let t=e.length>>>0;return this.uint32(t),t>0&&this._push(c8,t,e),this},ri.prototype.string=function(e){let t=globalThis.Buffer.byteLength(e);return this.uint32(t),t>0&&this._push(u8,t,e),this});function c8(e,t,r){t.set(e,r)}function u8(e,t,r){e.length<40?Qf(e,t,r):t.utf8Write!=null?t.utf8Write(e,r):t.set(xt(e),r)}function al(){return new ri}function cl(e,t){let r=al();return t.encode(e,r,{lengthDelimited:!1}),r.finish()}function*ul(e,t,r){let n=ti(e);yield*t.stream(n,void 0,"$",r)}var Gs={VARINT:0,BIT64:1,LENGTH_DELIMITED:2,START_GROUP:3,END_GROUP:4,BIT32:5};function Ys(e,t,r,n,o){return{name:e,type:t,encode:r,decode:n,stream:o}}function fl(e){function t(i){if(e[i.toString()]==null)throw new Error("Invalid enum value");return e[i]}let r=function(s,a){let c=t(s);a.int32(c)},n=function(s){let a=s.int32();return t(a)},o=function*(s){let a=s.int32();yield t(a)};return Ys("enum",Gs.VARINT,r,n,o)}function ll(e,t,r){return Ys("message",Gs.LENGTH_DELIMITED,e,t,r)}var He;(function(e){let t;(function(a){a.EOL="EOL"})(t=e.ValidityType||(e.ValidityType={}));let r;(function(a){a[a.EOL=0]="EOL"})(r||(r={})),(function(a){a.codec=()=>fl(r)})(t=e.ValidityType||(e.ValidityType={}));let n;e.codec=()=>(n==null&&(n=ll((a,c,u={})=>{u.lengthDelimited!==!1&&c.fork(),a.value!=null&&(c.uint32(10),c.bytes(a.value)),a.signatureV1!=null&&(c.uint32(18),c.bytes(a.signatureV1)),a.validityType!=null&&(c.uint32(24),e.ValidityType.codec().encode(a.validityType,c)),a.validity!=null&&(c.uint32(34),c.bytes(a.validity)),a.sequence!=null&&(c.uint32(40),c.uint64(a.sequence)),a.ttl!=null&&(c.uint32(48),c.uint64(a.ttl)),a.pubKey!=null&&(c.uint32(58),c.bytes(a.pubKey)),a.signatureV2!=null&&(c.uint32(66),c.bytes(a.signatureV2)),a.data!=null&&(c.uint32(74),c.bytes(a.data)),u.lengthDelimited!==!1&&c.ldelim()},(a,c,u={})=>{let f={},l=c==null?a.len:a.pos+c;for(;a.pos<l;){let d=a.uint32();switch(d>>>3){case 1:{f.value=a.bytes();break}case 2:{f.signatureV1=a.bytes();break}case 3:{f.validityType=e.ValidityType.codec().decode(a);break}case 4:{f.validity=a.bytes();break}case 5:{f.sequence=a.uint64();break}case 6:{f.ttl=a.uint64();break}case 7:{f.pubKey=a.bytes();break}case 8:{f.signatureV2=a.bytes();break}case 9:{f.data=a.bytes();break}default:{a.skipType(d&7);break}}}return f},function*(a,c,u,f={}){let l=c==null?a.len:a.pos+c;for(;a.pos<l;){let d=a.uint32();switch(d>>>3){case 1:{yield{field:`${u}.value`,value:a.bytes()};break}case 2:{yield{field:`${u}.signatureV1`,value:a.bytes()};break}case 3:{yield{field:`${u}.validityType`,value:e.ValidityType.codec().decode(a)};break}case 4:{yield{field:`${u}.validity`,value:a.bytes()};break}case 5:{yield{field:`${u}.sequence`,value:a.uint64()};break}case 6:{yield{field:`${u}.ttl`,value:a.uint64()};break}case 7:{yield{field:`${u}.pubKey`,value:a.bytes()};break}case 8:{yield{field:`${u}.signatureV2`,value:a.bytes()};break}case 9:{yield{field:`${u}.data`,value:a.bytes()};break}default:{a.skipType(d&7);break}}}})),n);function o(a){return cl(a,e.codec())}e.encode=o;function i(a,c){return el(a,e.codec(),c)}e.decode=i;function s(a,c){return ul(a,e.codec(),c)}e.stream=s})(He||(He={}));var WU=ce("ipns:utils"),f8=xt("/ipns/");var l8=0,h8=18;function hl(e){return"signatureV1"in e?He.encode({value:xt(e.value),signatureV1:e.signatureV1,validityType:e.validityType,validity:xt(e.validity),sequence:e.sequence,ttl:e.ttl,pubKey:e.pubKey,signatureV2:e.signatureV2,data:e.data}):He.encode({pubKey:e.pubKey,signatureV2:e.signatureV2,data:e.data})}function dl(e){let t=He.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 qe("Missing data or signatureV2");let r=ug(t.data),n=d8(r.Value),o=$t(r.Validity);if(t.value!=null&&t.signatureV1!=null)return p8(t),{value:n,validityType:He.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:He.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 Zs(e){let t=Wi(e.slice(f8.length));if(!cg(t,l8)&&!cg(t,h8))throw new je("Multihash in IPNS key was not identity or sha2-256");return t}function ug(e){let t=Yo(e);if(t.ValidityType===0)t.ValidityType=He.ValidityType.EOL;else throw new Ks("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 d8(e){let t=$t(e).trim();if(t.startsWith("/"))return t;try{return`/ipfs/${Ft.decode(e).toV1().toString()}`}catch{}try{return`/ipfs/${Ft.parse(t).toV1().toString()}`}catch{}throw new zs("Value must be a valid content path starting with /")}function p8(e){if(e.data==null)throw new qs("Record data is missing");let t=ug(e.data);if(!ar(t.Value,e.value??new Uint8Array(0)))throw new qe('Field "value" did not match between protobuf and CBOR');if(!ar(t.Validity,e.validity??new Uint8Array(0)))throw new qe('Field "validity" did not match between protobuf and CBOR');if(t.ValidityType!==e.validityType)throw new qe('Field "validityType" did not match between protobuf and CBOR');if(t.Sequence!==e.sequence)throw new qe('Field "sequence" did not match between protobuf and CBOR');if(t.TTL!==e.ttl)throw new qe('Field "ttl" did not match between protobuf and CBOR')}function cg(e,t){return e.code===t}var eR=ce("ipns"),rR=300*1e9,g8="/ipns/",nR=g8.length;function Xs(e){return{url:"https://delegated-ipfs.dev",filterProtocols:["unknown","transport-bitswap","transport-ipfs-gateway-http"],filterAddrs:["https","webtransport","webrtc","webrtc-direct","wss","tls"]}}var fg=xt("/ipns/");function lg(e){return ar(e.subarray(0,fg.byteLength),fg)}var pl=class{name="delegated-http-router";client;constructor(t,r){this.client=Q0(r)(t)}async provide(t,r){}async cancelReprovide(t,r){}async*findProviders(t,r){yield*Os(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(!lg(t))return;let o=Zs(t),i=Ft.createV1(114,o),s=dl(r);await this.client.putIPNS(i,s,n)}async get(t,r){if(!lg(t))throw new Ut("Not found");let n=Zs(t),o=Ft.createV1(114,n);try{let i=await this.client.getIPNS(o,r);return hl(i)}catch(i){throw i.name==="BadResponseError"?new Ut("Not found"):i}}async findPeer(t,r){let n=await Ps(this.client.getPeers(t,r));if(n!=null)return{id:n.ID,multiaddrs:n.Addrs??[]};throw new Ut("Not found")}async*getClosestPeers(t,r){}toString(){return`DelegatedHTTPRouter(${this.client.url})`}};function hg(e){return t=>new pl(t,Xs(e))}var dg="[a-fA-F\\d:]",xr=e=>e&&e.includeBoundaries?`(?:(?<=\\s|^)(?=${dg})|(?<=${dg})(?=\\s|$))`:"",me="(?: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}",it="[a-fA-F\\d]{1,4}",Ws=`
14
14
  (?:
15
- (?:${st}:){7}(?:${st}|:)| // 1:2:3:4:5:6:7:: 1:2:3:4:5:6:7:8
16
- (?:${st}:){6}(?:${Qt}|:${st}|:)| // 1:2:3:4:5:6:: 1:2:3:4:5:6::8 1:2:3:4:5:6::8 1:2:3:4:5:6::1.2.3.4
17
- (?:${st}:){5}(?::${Qt}|(?::${st}){1,2}|:)| // 1:2:3:4:5:: 1:2:3:4:5::7:8 1:2:3:4:5::8 1:2:3:4:5::7:1.2.3.4
18
- (?:${st}:){4}(?:(?::${st}){0,1}:${Qt}|(?::${st}){1,3}|:)| // 1:2:3:4:: 1:2:3:4::6:7:8 1:2:3:4::8 1:2:3:4::6:7:1.2.3.4
19
- (?:${st}:){3}(?:(?::${st}){0,2}:${Qt}|(?::${st}){1,4}|:)| // 1:2:3:: 1:2:3::5:6:7:8 1:2:3::8 1:2:3::5:6:7:1.2.3.4
20
- (?:${st}:){2}(?:(?::${st}){0,3}:${Qt}|(?::${st}){1,5}|:)| // 1:2:: 1:2::4:5:6:7:8 1:2::8 1:2::4:5:6:7:1.2.3.4
21
- (?:${st}:){1}(?:(?::${st}){0,4}:${Qt}|(?::${st}){1,6}|:)| // 1:: 1::3:4:5:6:7:8 1::8 1::3:4:5:6:7:1.2.3.4
22
- (?::(?:(?::${st}){0,5}:${Qt}|(?::${st}){1,7}|:)) // ::2:3:4:5:6:7:8 ::2:3:4:5:6:7:8 ::8 ::1.2.3.4
15
+ (?:${it}:){7}(?:${it}|:)| // 1:2:3:4:5:6:7:: 1:2:3:4:5:6:7:8
16
+ (?:${it}:){6}(?:${me}|:${it}|:)| // 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
17
+ (?:${it}:){5}(?::${me}|(?::${it}){1,2}|:)| // 1:2:3:4:5:: 1:2:3:4:5::7:8 1:2:3:4:5::8 1:2:3:4:5::7:1.2.3.4
18
+ (?:${it}:){4}(?:(?::${it}){0,1}:${me}|(?::${it}){1,3}|:)| // 1:2:3:4:: 1:2:3:4::6:7:8 1:2:3:4::8 1:2:3:4::6:7:1.2.3.4
19
+ (?:${it}:){3}(?:(?::${it}){0,2}:${me}|(?::${it}){1,4}|:)| // 1:2:3:: 1:2:3::5:6:7:8 1:2:3::8 1:2:3::5:6:7:1.2.3.4
20
+ (?:${it}:){2}(?:(?::${it}){0,3}:${me}|(?::${it}){1,5}|:)| // 1:2:: 1:2::4:5:6:7:8 1:2::8 1:2::4:5:6:7:1.2.3.4
21
+ (?:${it}:){1}(?:(?::${it}){0,4}:${me}|(?::${it}){1,6}|:)| // 1:: 1::3:4:5:6:7:8 1::8 1::3:4:5:6:7:1.2.3.4
22
+ (?::(?:(?::${it}){0,5}:${me}|(?::${it}){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(),im=new RegExp(`(?:^${Qt}$)|(?:^${Zo}$)`),sm=new RegExp(`^${Qt}$`),am=new RegExp(`^${Zo}$`),fa=e=>e&&e.exact?im:new RegExp(`(?:${ke(e)}${Qt}${ke(e)})|(?:${ke(e)}${Zo}${ke(e)})`,"g");fa.v4=e=>e&&e.exact?sm:new RegExp(`${ke(e)}${Qt}${ke(e)}`,"g");fa.v6=e=>e&&e.exact?am:new RegExp(`${ke(e)}${Zo}${ke(e)}`,"g");var la=fa;function da(e){let t=(...r)=>e(...r);return Object.defineProperty(t,"name",{value:`functionTimeout(${e.name||"<anonymous>"})`,configurable:!0}),t}function ul(){return!1}var{toString:cm}=Object.prototype;function ha(e){return cm.call(e)==="[object RegExp]"}var fl={global:"g",ignoreCase:"i",multiline:"m",dotAll:"s",sticky:"y",unicode:"u"};function pa(e,t={}){if(!ha(e))throw new TypeError("Expected a RegExp instance");let r=Object.keys(fl).map(o=>(typeof t[o]=="boolean"?t[o]:e[o])?fl[o]:"").join(""),n=new RegExp(t.source||e.source,r);return n.lastIndex=typeof t.lastIndex=="number"?t.lastIndex:e.lastIndex,n}function ma(e,t,{timeout:r}={}){try{return da(()=>pa(e).test(t),{timeout:r})()}catch(n){if(ul(n))return!1;throw n}}var um=15,fm=45,ll={timeout:400};function ya(e){return e.length>fm?!1:ma(la.v6({exact:!0}),e,ll)}function dl(e){return e.length>um?!1:ma(la.v4({exact:!0}),e,ll)}var hl={http:"80",https:"443",ws:"80",wss:"443"},lm=["http","https","ws","wss"];function pl(e,t){t=t??{};let r=t.defaultDnsType??"dns",{scheme:n,hostname:o,port:i,path:s}=dm(e),a=[hm(o,r),pm(i,n),mm(n)];s!=null&&a.push(ym(s));let c="/"+a.filter(u=>!!u).reduce((u,f)=>u.concat(f),[]).join("/");return go(c)}function dm(e){let[t]=e.split(":");lm.includes(t)||(e="http"+e.substring(t.length));let{protocol:r,hostname:n,port:o,pathname:i,search:s}=new URL(e);if(o==null||o===""){let c=gm(t);c!=null&&(o=c),c==null&&r==="http:"&&(o="80")}let a;return i!=null&&i!==""&&i!=="/"&&(i.startsWith("/")&&(i=i.substring(1)),a=i),s!=null&&s!==""&&(a=a??"",a+=s),{scheme:t,hostname:n,port:o,path:a}}function hm(e,t){if(!(e==null||e==="")){if(dl(e))return["ip4",e];if(ya(e))return["ip6",e];if(e[0]==="["){let r=e.substring(1,e.length-1);if(ya(r))return["ip6",r]}return[t,e]}}function pm(e,t){if(!(e==null||e===""))return t==="udp"?["udp",e]:["tcp",e]}function mm(e){if(e.match(/^tcp$|^udp$/)==null)return e==="https"?["/tls/http"]:e==="wss"?["/tls/ws"]:[e]}function ym(e){if(!(e==null||e===""))return["http-path",encodeURIComponent(e)]}function gm(e){if(!(e==null||e===""||hl[e]==null))return hl[e]}var bm=["https://trustless-gateway.link","https://4everland.io"],xm=2336;function wm(e){return e=e.toString(),{id:Ns(H.createV1(xm,St.digest(V(e)))),multiaddrs:[pl(e)]}}function Em(e){return new URL(z(e.id.toMultihash().digest))}var ga=class{name="http-gateway-router";gateways;shuffle;constructor(t={}){this.gateways=(t.gateways??bm).map(r=>wm(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=>Em(t)).join(", ")}])`}};function ml(e={}){return new ga(e)}var ba=class{name="libp2p-router";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 yl(e){return new ba(e)}return Sl(Sm);})();
24
+ `.replace(/\s*\/\/.*$/gm,"").replace(/\n/g,"").trim(),y8=new RegExp(`(?:^${me}$)|(?:^${Ws}$)`),b8=new RegExp(`^${me}$`),x8=new RegExp(`^${Ws}$`),ml=e=>e&&e.exact?y8:new RegExp(`(?:${xr(e)}${me}${xr(e)})|(?:${xr(e)}${Ws}${xr(e)})`,"g");ml.v4=e=>e&&e.exact?b8:new RegExp(`${xr(e)}${me}${xr(e)}`,"g");ml.v6=e=>e&&e.exact?x8:new RegExp(`${xr(e)}${Ws}${xr(e)}`,"g");var gl=ml;function yl(e){let t=(...r)=>e(...r);return Object.defineProperty(t,"name",{value:`functionTimeout(${e.name||"<anonymous>"})`,configurable:!0}),t}function pg(){return!1}var{toString:w8}=Object.prototype;function bl(e){return w8.call(e)==="[object RegExp]"}var mg={global:"g",ignoreCase:"i",multiline:"m",dotAll:"s",sticky:"y",unicode:"u"};function xl(e,t={}){if(!bl(e))throw new TypeError("Expected a RegExp instance");let r=Object.keys(mg).map(o=>(typeof t[o]=="boolean"?t[o]:e[o])?mg[o]:"").join(""),n=new RegExp(t.source||e.source,r);return n.lastIndex=typeof t.lastIndex=="number"?t.lastIndex:e.lastIndex,n}function wl(e,t,{timeout:r}={}){try{return yl(()=>xl(e).test(t),{timeout:r})()}catch(n){if(pg(n))return!1;throw n}}var E8=15,S8=45,gg={timeout:400};function El(e){return e.length>S8?!1:wl(gl.v6({exact:!0}),e,gg)}function yg(e){return e.length>E8?!1:wl(gl.v4({exact:!0}),e,gg)}var bg={http:"80",https:"443",ws:"80",wss:"443"},v8=["http","https","ws","wss"];function xg(e,t){t=t??{};let r=t.defaultDnsType??"dns",{scheme:n,hostname:o,port:i,path:s}=A8(e),a=[T8(o,r),C8(i,n),I8(n)];s!=null&&a.push(B8(s));let c="/"+a.filter(u=>!!u).reduce((u,f)=>u.concat(f),[]).join("/");return is(c)}function A8(e){let[t]=e.split(":");v8.includes(t)||(e="http"+e.substring(t.length));let{protocol:r,hostname:n,port:o,pathname:i,search:s}=new URL(e);if(o==null||o===""){let c=D8(t);c!=null&&(o=c),c==null&&r==="http:"&&(o="80")}let a;return i!=null&&i!==""&&i!=="/"&&(i.startsWith("/")&&(i=i.substring(1)),a=i),s!=null&&s!==""&&(a=a??"",a+=s),{scheme:t,hostname:n,port:o,path:a}}function T8(e,t){if(!(e==null||e==="")){if(yg(e))return["ip4",e];if(El(e))return["ip6",e];if(e[0]==="["){let r=e.substring(1,e.length-1);if(El(r))return["ip6",r]}return[t,e]}}function C8(e,t){if(!(e==null||e===""))return t==="udp"?["udp",e]:["tcp",e]}function I8(e){if(e.match(/^tcp$|^udp$/)==null)return e==="https"?["/tls/http"]:e==="wss"?["/tls/ws"]:[e]}function B8(e){if(!(e==null||e===""))return["http-path",encodeURIComponent(e)]}function D8(e){if(!(e==null||e===""||bg[e]==null))return bg[e]}var _8=["https://trustless-gateway.link","https://4everland.io"],L8=2336;function U8(e){return e=e.toString(),{id:ru(Ft.createV1(L8,Cu.digest(xt(e)))),multiaddrs:[xg(e)]}}function R8(e){return new URL($t(e.id.toMultihash().digest))}var Sl=class{name="http-gateway-router";gateways;shuffle;constructor(t={}){this.gateways=(t.gateways??_8).map(r=>U8(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=>R8(t)).join(", ")}])`}};function wg(e={}){return new Sl(e)}var vl=class{name="libp2p-router";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 Eg(e){return new vl(e)}return Ig(N8);})();
25
25
  /*! Bundled license information:
26
26
 
27
27
  @noble/curves/utils.js: