@helia/routers 3.1.2-1e9745c0 → 3.1.2-28a70912

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,17 +1,17 @@
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 Mf=Object.create;var pn=Object.defineProperty;var Vf=Object.getOwnPropertyDescriptor;var $f=Object.getOwnPropertyNames;var qf=Object.getPrototypeOf,Hf=Object.prototype.hasOwnProperty;var Ws=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Et=(e,t)=>{for(var r in t)pn(e,r,{get:t[r],enumerable:!0})},Zs=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of $f(t))!Hf.call(e,o)&&o!==r&&pn(e,o,{get:()=>t[o],enumerable:!(n=Vf(t,o))||n.enumerable});return e};var Uo=(e,t,r)=>(r=e!=null?Mf(qf(e)):{},Zs(t||!e||!e.__esModule?pn(r,"default",{value:e,enumerable:!0}):r,e)),zf=e=>Zs(pn({},"__esModule",{value:!0}),e);var Is=Ws((L1,As)=>{var U1=function(){typeof As<"u"&&(As.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",l=Math.trunc||function(g){var d=g-g%1;return d==0&&(g<0||g===0&&1/g!=1/0)?-0:d},u=v.prototype,f=(v.fromDate=function(g){return new v(+g)},v.fromInt64BE=k(0,1,2,3,0,4),v.fromInt64LE=k(3,2,1,0,4,0),v.fromString=function(h){var d,x=new v,h=(h+="").replace(/^\s*[+\-]?\d+/,function(S){var S=+S,I=1970+(S-1970)%400;return x.year=S-I,I}).replace(/(?:Z|([+\-]\d{2}):?(\d{2}))$/,function(p,S,I){return S<0&&(I*=-1),d=6e4*(60*+S+ +I),""}).replace(/\.\d+$/,function(p){return x.nano=+(p+c).substr(1,9),""}).split(/\D+/);if(1<h.length?h[1]--:h[1]=0,x.time=d=Date.UTC.apply(Date,h)-(d||0),isNaN(d))throw new TypeError("Invalid Date");return w(x)},v.fromTimeT=function(g){return D(g,0)},u.year=0,u.time=0,u.nano=0,u.addNano=function(g){return this.nano+=+g||0,this},u.getNano=function(){var g=w(this);return(g.time%1e3*a+ +g.nano+1e9)%1e9},u.getTimeT=function(){var d=w(this),g=Math.floor(d.time/1e3),d=d.year;return d&&(g+=d*r*e/t),g},u.getYear=function(){return this.toDate().getUTCFullYear()+this.year},u.toDate=function(){return C(w(this).time)},u.toJSON=function(){return this.toString().replace(/0{1,6}Z$/,"Z")},u.toString=function(g){var d=this,x=d.toDate(),h={H:function(){return N(x.getUTCHours())},L:function(){return R(x.getUTCMilliseconds(),3)},M:function(){return N(x.getUTCMinutes())},N:function(){return R(d.getNano(),9)},S:function(){return N(x.getUTCSeconds())},Y:function(){var p=d.getYear();return 999999<p?"+"+p:9999<p?"+"+R(p,6):0<=p?R(p,4):-999999<=p?"-"+R(-p,6):p},a:function(){return y[x.getUTCDay()]},b:function(){return m[x.getUTCMonth()]},d:function(){return N(x.getUTCDate())},e:function(){return function(p){return(9<p?"":" ")+(0|p)}(x.getUTCDate())},m:function(){return N(x.getUTCMonth()+1)}};return function p(S){return S.replace(/%./g,function(I){var T=I[1],A=B[T],T=h[T];return A?p(A):T?T():I})}(g||f)},u.writeInt64BE=P(0,1,2,3,0,4),u.writeInt64LE=P(3,2,1,0,4,0),"%Y-%m-%dT%H:%M:%S.%NZ"),m=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],y=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],B={"%":"%",F:"%Y-%m-%d",n:`
3
- `,R:"%H:%M",T:"%H:%M:%S",t:" ",X:"%T",Z:"GMT",z:"+0000"};return v;function v(g,d,x){var h=this;if(!(h instanceof v))return new v(g,d,x);h.time=+g||0,h.nano=+d||0,h.year=+x||0,w(h)}function w(g){var d,x,h,p=g.year,S=g.time,I=g.nano,A=((I<0||a<=I)&&(I-=(x=Math.floor(I/a))*a,S+=x,x=1),p%t);return(S<-i||i<S||A)&&((d=l(S/o))&&(p+=d*t,S-=d*o),(h=C(S)).setUTCFullYear(A+h.getUTCFullYear()),h=(S=+h)+(d=l((p-=A)/t))*o,d&&-i<=h&&h<=i&&(p-=d*t,S=h),x=1),x&&(g.year=p,g.time=S,g.nano=I),g}function C(g){var d=new Date(0);return d.setTime(g),d}function D(p,h){p=+p||0;var x=l((h=(h|0)*s)/n)+l(p/n),h=h%n+p%n,p=l(h/n);return p&&(x+=p,h-=p*n),new v(1e3*h,0,x*t)}function P(g,d,x,h,p,S){return function(A,T){var L=w(this);A=A||new Array(8),E(A,T|=0);var z=Math.floor(L.time/1e3),L=L.year*(r*e/t),O=l(L/s)+l(z/s),L=L%s+z%s,z=Math.floor(L/s);return z&&(O+=z,L-=z*s),I(A,T+p,O),I(A,T+S,L),A};function I(A,T,O){A[T+g]=O>>24&255,A[T+d]=O>>16&255,A[T+x]=O>>8&255,A[T+h]=255&O}}function k(g,d,x,h,p,S){return function(A,T){E(A,T|=0);var O=I(A,T+p);return D(I(A,T+S),O)};function I(A,T){return 16777216*A[T+g]+(A[T+d]<<16|A[T+x]<<8|A[T+h])}}function E(g,d){if(g=g&&g.length,g==null)throw new TypeError("Invalid Buffer");if(g<d+8)throw new RangeError("Out of range")}function N(g){return(9<g?"":"0")+(0|g)}function R(g,d){return(c+(0|g)).substr(-d)}}()});var Ef=Ws((TE,Rs)=>{"use strict";var y0=Object.prototype.hasOwnProperty,bt="~";function fn(){}Object.create&&(fn.prototype=Object.create(null),new fn().__proto__||(bt=!1));function g0(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function bf(e,t,r,n,o){if(typeof r!="function")throw new TypeError("The listener must be a function");var i=new g0(r,n||e,o),s=bt?bt+t:t;return e._events[s]?e._events[s].fn?e._events[s]=[e._events[s],i]:e._events[s].push(i):(e._events[s]=i,e._eventsCount++),e}function Ao(e,t){--e._eventsCount===0?e._events=new fn:delete e._events[t]}function yt(){this._events=new fn,this._eventsCount=0}yt.prototype.eventNames=function(){var t=[],r,n;if(this._eventsCount===0)return t;for(n in r=this._events)y0.call(r,n)&&t.push(bt?n.slice(1):n);return Object.getOwnPropertySymbols?t.concat(Object.getOwnPropertySymbols(r)):t};yt.prototype.listeners=function(t){var r=bt?bt+t:t,n=this._events[r];if(!n)return[];if(n.fn)return[n.fn];for(var o=0,i=n.length,s=new Array(i);o<i;o++)s[o]=n[o].fn;return s};yt.prototype.listenerCount=function(t){var r=bt?bt+t:t,n=this._events[r];return n?n.fn?1:n.length:0};yt.prototype.emit=function(t,r,n,o,i,s){var a=bt?bt+t:t;if(!this._events[a])return!1;var c=this._events[a],l=arguments.length,u,f;if(c.fn){switch(c.once&&this.removeListener(t,c.fn,void 0,!0),l){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(f=1,u=new Array(l-1);f<l;f++)u[f-1]=arguments[f];c.fn.apply(c.context,u)}else{var m=c.length,y;for(f=0;f<m;f++)switch(c[f].once&&this.removeListener(t,c[f].fn,void 0,!0),l){case 1:c[f].fn.call(c[f].context);break;case 2:c[f].fn.call(c[f].context,r);break;case 3:c[f].fn.call(c[f].context,r,n);break;case 4:c[f].fn.call(c[f].context,r,n,o);break;default:if(!u)for(y=1,u=new Array(l-1);y<l;y++)u[y-1]=arguments[y];c[f].fn.apply(c[f].context,u)}}return!0};yt.prototype.on=function(t,r,n){return bf(this,t,r,n,!1)};yt.prototype.once=function(t,r,n){return bf(this,t,r,n,!0)};yt.prototype.removeListener=function(t,r,n,o){var i=bt?bt+t:t;if(!this._events[i])return this;if(!r)return Ao(this,i),this;var s=this._events[i];if(s.fn)s.fn===r&&(!o||s.once)&&(!n||s.context===n)&&Ao(this,i);else{for(var a=0,c=[],l=s.length;a<l;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:Ao(this,i)}return this};yt.prototype.removeAllListeners=function(t){var r;return t?(r=bt?bt+t:t,this._events[r]&&Ao(this,r)):(this._events=new fn,this._eventsCount=0),this};yt.prototype.off=yt.prototype.removeListener;yt.prototype.addListener=yt.prototype.on;yt.prefixed=bt;yt.EventEmitter=yt;typeof Rs<"u"&&(Rs.exports=yt)});var F0={};Et(F0,{delegatedHTTPRouting:()=>Pf,delegatedHTTPRoutingDefaults:()=>Do,httpGatewayRouting:()=>Kf,libp2pRouting:()=>Ff});var Ys=Symbol.for("@libp2p/content-routing");var Lo=Symbol.for("@libp2p/peer-id");var Xs=Symbol.for("@libp2p/peer-routing");var rt=class extends Error{static name="InvalidParametersError";constructor(t="Invalid parameters"){super(t),this.name="InvalidParametersError"}},He=class extends Error{static name="InvalidPublicKeyError";constructor(t="Invalid public key"){super(t),this.name="InvalidPublicKeyError"}};var St=class extends Error{static name="NotFoundError";constructor(t="Not found"){super(t),this.name="NotFoundError"}};var mn=class extends Error{static name="InvalidCIDError";constructor(t="Invalid CID"){super(t),this.name="InvalidCIDError"}},ze=class extends Error{static name="InvalidMultihashError";constructor(t="Invalid Multihash"){super(t),this.name="InvalidMultihashError"}};var je=class extends Error{static name="UnsupportedKeyTypeError";constructor(t="Unsupported key type"){super(t),this.name="UnsupportedKeyTypeError"}};var Mo={};Et(Mo,{base32:()=>Zt,base32hex:()=>el,base32hexpad:()=>nl,base32hexpadupper:()=>ol,base32hexupper:()=>rl,base32pad:()=>Qf,base32padupper:()=>tl,base32upper:()=>Jf,base32z:()=>il});var z0=new Uint8Array(0);function Js(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}function ne(e){if(e instanceof Uint8Array&&e.constructor.name==="Uint8Array")return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")}function Qs(e){return new TextEncoder().encode(e)}function ta(e){return new TextDecoder().decode(e)}function jf(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),l=Math.log(a)/Math.log(256),u=Math.log(256)/Math.log(a);function f(B){if(B instanceof Uint8Array||(ArrayBuffer.isView(B)?B=new Uint8Array(B.buffer,B.byteOffset,B.byteLength):Array.isArray(B)&&(B=Uint8Array.from(B))),!(B instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(B.length===0)return"";for(var v=0,w=0,C=0,D=B.length;C!==D&&B[C]===0;)C++,v++;for(var P=(D-C)*u+1>>>0,k=new Uint8Array(P);C!==D;){for(var E=B[C],N=0,R=P-1;(E!==0||N<w)&&R!==-1;R--,N++)E+=256*k[R]>>>0,k[R]=E%a>>>0,E=E/a>>>0;if(E!==0)throw new Error("Non-zero carry");w=N,C++}for(var g=P-w;g!==P&&k[g]===0;)g++;for(var d=c.repeat(v);g<P;++g)d+=e.charAt(k[g]);return d}function m(B){if(typeof B!="string")throw new TypeError("Expected String");if(B.length===0)return new Uint8Array;var v=0;if(B[v]!==" "){for(var w=0,C=0;B[v]===c;)w++,v++;for(var D=(B.length-v)*l+1>>>0,P=new Uint8Array(D);B[v];){var k=r[B.charCodeAt(v)];if(k===255)return;for(var E=0,N=D-1;(k!==0||E<C)&&N!==-1;N--,E++)k+=a*P[N]>>>0,P[N]=k%256>>>0,k=k/256>>>0;if(k!==0)throw new Error("Non-zero carry");C=E,v++}if(B[v]!==" "){for(var R=D-C;R!==D&&P[R]===0;)R++;for(var g=new Uint8Array(w+(D-R)),d=w;R!==D;)g[d++]=P[R++];return g}}}function y(B){var v=m(B);if(v)return v;throw new Error(`Non-${t} character`)}return{encode:f,decodeUnsafe:m,decode:y}}var Gf=jf,Wf=Gf,ra=Wf;var Oo=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")}},ko=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 na(this,t)}},Ko=class{decoders;constructor(t){this.decoders=t}or(t){return na(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 na(e,t){return new Ko({...e.decoders??{[e.prefix]:e},...t.decoders??{[t.prefix]:t}})}var Fo=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 Oo(t,r,n),this.decoder=new ko(t,r,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function Ge({name:e,prefix:t,encode:r,decode:n}){return new Fo(e,t,r,n)}function pe({name:e,prefix:t,alphabet:r}){let{encode:n,decode:o}=ra(r,e);return Ge({prefix:t,name:e,encode:n,decode:i=>ne(o(i))})}function Zf(e,t,r,n){let o=e.length;for(;e[o-1]==="=";)--o;let i=new Uint8Array(o*r/8|0),s=0,a=0,c=0;for(let l=0;l<o;++l){let u=t[e[l]];if(u===void 0)throw new SyntaxError(`Non-${n} character`);a=a<<r|u,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 Yf(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 Xf(e){let t={};for(let r=0;r<e.length;++r)t[e[r]]=r;return t}function Q({name:e,prefix:t,bitsPerChar:r,alphabet:n}){let o=Xf(n);return Ge({prefix:t,name:e,encode(i){return Yf(i,n,r)},decode(i){return Zf(i,o,r,e)}})}var Zt=Q({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Jf=Q({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Qf=Q({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),tl=Q({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),el=Q({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),rl=Q({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),nl=Q({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),ol=Q({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),il=Q({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Vo={};Et(Vo,{base58btc:()=>j,base58flickr:()=>sl});var j=pe({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),sl=pe({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Ho={};Et(Ho,{base64:()=>$o,base64pad:()=>al,base64url:()=>qo,base64urlpad:()=>cl});var $o=Q({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),al=Q({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),qo=Q({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),cl=Q({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});function ul(e,t){try{if(typeof e=="string"&&e.length>0)return fl(e);if(typeof e=="number"&&isFinite(e))return t?.long?dl(e):ll(e);throw new Error("Value is not a string or number.")}catch(r){let n=hl(r)?`${r.message}. value=${JSON.stringify(e)}`:"An unknown error has occured.";throw new Error(n)}}function fl(e){if(e=String(e),e.length>100)throw new Error("Value exceeds the maximum length of 100 characters.");let t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(!t)return NaN;let r=parseFloat(t[1]),n=(t[2]||"ms").toLowerCase();switch(n){case"years":case"year":case"yrs":case"yr":case"y":return r*315576e5;case"weeks":case"week":case"w":return r*6048e5;case"days":case"day":case"d":return r*864e5;case"hours":case"hour":case"hrs":case"hr":case"h":return r*36e5;case"minutes":case"minute":case"mins":case"min":case"m":return r*6e4;case"seconds":case"second":case"secs":case"sec":case"s":return r*1e3;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:throw new Error(`The unit ${n} was matched, but no matching case exists.`)}}var gn=ul;function ll(e){let t=Math.abs(e);return t>=864e5?`${Math.round(e/864e5)}d`:t>=36e5?`${Math.round(e/36e5)}h`:t>=6e4?`${Math.round(e/6e4)}m`:t>=1e3?`${Math.round(e/1e3)}s`:`${e}ms`}function dl(e){let t=Math.abs(e);return t>=864e5?yn(e,t,864e5,"day"):t>=36e5?yn(e,t,36e5,"hour"):t>=6e4?yn(e,t,6e4,"minute"):t>=1e3?yn(e,t,1e3,"second"):`${e} ms`}function yn(e,t,r,n){let o=t>=r*1.5;return`${Math.round(e/r)} ${n}${o?"s":""}`}function hl(e){return typeof e=="object"&&e!==null&&"message"in e}function zo(e){r.debug=r,r.default=r,r.coerce=c,r.disable=i,r.enable=o,r.enabled=s,r.humanize=gn,r.destroy=l,Object.keys(e).forEach(u=>{r[u]=e[u]}),r.names=[],r.skips=[],r.formatters={};function t(u){let f=0;for(let m=0;m<u.length;m++)f=(f<<5)-f+u.charCodeAt(m),f|=0;return r.colors[Math.abs(f)%r.colors.length]}r.selectColor=t;function r(u){let f,m=null,y,B;function v(...w){if(!v.enabled)return;let C=v,D=Number(new Date),P=D-(f||D);C.diff=P,C.prev=f,C.curr=D,f=D,w[0]=r.coerce(w[0]),typeof w[0]!="string"&&w.unshift("%O");let k=0;w[0]=w[0].replace(/%([a-zA-Z%])/g,(N,R)=>{if(N==="%%")return"%";k++;let g=r.formatters[R];if(typeof g=="function"){let d=w[k];N=g.call(C,d),w.splice(k,1),k--}return N}),r.formatArgs.call(C,w),(C.log||r.log).apply(C,w)}return v.namespace=u,v.useColors=r.useColors(),v.color=r.selectColor(u),v.extend=n,v.destroy=r.destroy,Object.defineProperty(v,"enabled",{enumerable:!0,configurable:!1,get:()=>m!==null?m:(y!==r.namespaces&&(y=r.namespaces,B=r.enabled(u)),B),set:w=>{m=w}}),typeof r.init=="function"&&r.init(v),v}function n(u,f){let m=r(this.namespace+(typeof f>"u"?":":f)+u);return m.log=this.log,m}function o(u){r.save(u),r.namespaces=u,r.names=[],r.skips=[];let f,m=(typeof u=="string"?u:"").split(/[\s,]+/),y=m.length;for(f=0;f<y;f++)m[f]&&(u=m[f].replace(/\*/g,".*?"),u[0]==="-"?r.skips.push(new RegExp("^"+u.substr(1)+"$")):r.names.push(new RegExp("^"+u+"$")))}function i(){let u=[...r.names.map(a),...r.skips.map(a).map(f=>"-"+f)].join(",");return r.enable(""),u}function s(u){if(u[u.length-1]==="*")return!0;let f,m;for(f=0,m=r.skips.length;f<m;f++)if(r.skips[f].test(u))return!1;for(f=0,m=r.names.length;f<m;f++)if(r.names[f].test(u))return!0;return!1}function a(u){return u.toString().substring(2,u.toString().length-2).replace(/\.\*\?$/,"*")}function c(u){return u instanceof Error?u.stack??u.message:u}function l(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return r.setupFormatters(r.formatters),r.enable(r.load()),r}var xn=bl(),pl=["#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 ml(){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 yl(e){if(e[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+e[0]+(this.useColors?"%c ":" ")+"+"+gn(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 gl=console.debug??console.log??(()=>{});function xl(e){try{e?xn?.setItem("debug",e):xn?.removeItem("debug")}catch{}}function wl(){let e;try{e=xn?.getItem("debug")}catch{}return!e&&typeof globalThis.process<"u"&&"env"in globalThis.process&&(e=globalThis.process.env.DEBUG),e}function bl(){try{return localStorage}catch{}}function El(e){e.j=function(t){try{return JSON.stringify(t)}catch(r){return"[UnexpectedJSONParseError]: "+r.message}}}var oa=zo({formatArgs:yl,save:xl,load:wl,useColors:ml,setupFormatters:El,colors:pl,storage:xn,log:gl});var vt=oa;vt.formatters.b=e=>e==null?"undefined":j.baseEncode(e);vt.formatters.t=e=>e==null?"undefined":Zt.baseEncode(e);vt.formatters.m=e=>e==null?"undefined":$o.baseEncode(e);vt.formatters.p=e=>e==null?"undefined":e.toString();vt.formatters.c=e=>e==null?"undefined":e.toString();vt.formatters.k=e=>e==null?"undefined":e.toString();vt.formatters.a=e=>e==null?"undefined":e.toString();vt.formatters.e=e=>e==null?"undefined":ia(e.stack)??ia(e.message)??e.toString();function Sl(e){let t=()=>{};return t.enabled=!1,t.color="",t.diff=0,t.log=()=>{},t.namespace=e,t.destroy=()=>!0,t.extend=()=>t,t}function me(e){let t=Sl(`${e}:trace`);return vt.enabled(`${e}:trace`)&&vt.names.map(r=>r.toString()).find(r=>r.includes(":trace"))!=null&&(t=vt(`${e}:trace`)),Object.assign(vt(e),{error:vt(`${e}:error`),trace:t})}function ia(e){if(e!=null&&(e=e.trim(),e.length!==0))return e}var jo={};Et(jo,{base36:()=>We,base36upper:()=>vl});var We=pe({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),vl=pe({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Al=ca,sa=128,Il=127,Tl=~Il,Cl=Math.pow(2,31);function ca(e,t,r){t=t||[],r=r||0;for(var n=r;e>=Cl;)t[r++]=e&255|sa,e/=128;for(;e&Tl;)t[r++]=e&255|sa,e>>>=7;return t[r]=e|0,ca.bytes=r-n+1,t}var Bl=Go,_l=128,aa=127;function Go(e,n){var r=0,n=n||0,o=0,i=n,s,a=e.length;do{if(i>=a)throw Go.bytes=0,new RangeError("Could not decode varint");s=e[i++],r+=o<28?(s&aa)<<o:(s&aa)*Math.pow(2,o),o+=7}while(s>=_l);return Go.bytes=i-n,r}var Pl=Math.pow(2,7),Dl=Math.pow(2,14),Nl=Math.pow(2,21),Rl=Math.pow(2,28),Ul=Math.pow(2,35),Ll=Math.pow(2,42),Ol=Math.pow(2,49),kl=Math.pow(2,56),Kl=Math.pow(2,63),Fl=function(e){return e<Pl?1:e<Dl?2:e<Nl?3:e<Rl?4:e<Ul?5:e<Ll?6:e<Ol?7:e<kl?8:e<Kl?9:10},Ml={encode:Al,decode:Bl,encodingLength:Fl},Vl=Ml,Tr=Vl;function Cr(e,t=0){return[Tr.decode(e,t),Tr.decode.bytes]}function Ze(e,t,r=0){return Tr.encode(e,t,r),t}function Ye(e){return Tr.encodingLength(e)}function Ft(e,t){let r=t.byteLength,n=Ye(e),o=n+Ye(r),i=new Uint8Array(o+r);return Ze(e,i,0),Ze(r,i,n),i.set(t,o),new Xe(e,r,t,i)}function Ce(e){let t=ne(e),[r,n]=Cr(t),[o,i]=Cr(t.subarray(n)),s=t.subarray(n+i);if(s.byteLength!==o)throw new Error("Incorrect length");return new Xe(r,o,s,t)}function ua(e,t){if(e===t)return!0;{let r=t;return e.code===r.code&&e.size===r.size&&r.bytes instanceof Uint8Array&&Js(e.bytes,r.bytes)}}var Xe=class{code;size;digest;bytes;constructor(t,r,n,o){this.code=t,this.size=r,this.digest=n,this.bytes=o}};function fa(e,t){let{bytes:r,version:n}=e;switch(n){case 0:return ql(r,Wo(e),t??j.encoder);default:return Hl(r,Wo(e),t??Zt.encoder)}}var la=new WeakMap;function Wo(e){let t=la.get(e);if(t==null){let r=new Map;return la.set(e,r),r}return t}var $=class e{code;version;multihash;bytes;"/";constructor(t,r,n,o){this.code=r,this.version=t,this.multihash=n,this.bytes=o,this["/"]=o}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:t,multihash:r}=this;if(t!==Br)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==zl)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=Ft(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&&ua(t.multihash,n.multihash)}toString(t){return fa(this,t)}toJSON(){return{"/":fa(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(t){if(t==null)return null;let r=t;if(r instanceof e)return r;if(r["/"]!=null&&r["/"]===r.bytes||r.asCID===r){let{version:n,code:o,multihash:i,bytes:s}=r;return new e(n,o,i,s??da(n,o,i.bytes))}else if(r[jl]===!0){let{version:n,multihash:o,code:i}=r,s=Ce(o);return e.create(n,i,s)}else return null}static create(t,r,n){if(typeof r!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(t){case 0:{if(r!==Br)throw new Error(`Version 0 CID must use dag-pb (code: ${Br}) block encoding`);return new e(t,r,n,n.bytes)}case 1:{let o=da(t,r,n.bytes);return new e(t,r,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return e.create(0,Br,t)}static createV1(t,r){return e.create(1,t,r)}static decode(t){let[r,n]=e.decodeFirst(t);if(n.length!==0)throw new Error("Incorrect length");return r}static decodeFirst(t){let r=e.inspectBytes(t),n=r.size-r.multihashSize,o=ne(t.subarray(n,n+r.multihashSize));if(o.byteLength!==r.multihashSize)throw new Error("Incorrect length");let i=o.subarray(r.multihashSize-r.digestSize),s=new Xe(r.multihashCode,r.digestSize,i,o);return[r.version===0?e.createV0(s):e.createV1(r.codec,s),t.subarray(r.size)]}static inspectBytes(t){let r=0,n=()=>{let[f,m]=Cr(t.subarray(r));return r+=m,f},o=n(),i=Br;if(o===18?(o=0,r=0):i=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let s=r,a=n(),c=n(),l=r+c,u=l-s;return{version:o,codec:i,multihashCode:a,digestSize:c,multihashSize:u,size:l}}static parse(t,r){let[n,o]=$l(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 Wo(i).set(n,t),i}};function $l(e,t){switch(e[0]){case"Q":{let r=t??j;return[j.prefix,r.decode(`${j.prefix}${e}`)]}case j.prefix:{let r=t??j;return[j.prefix,r.decode(e)]}case Zt.prefix:{let r=t??Zt;return[Zt.prefix,r.decode(e)]}case We.prefix:{let r=t??We;return[We.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 ql(e,t,r){let{prefix:n}=r;if(n!==j.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 Hl(e,t,r){let{prefix:n}=r,o=t.get(n);if(o==null){let i=r.encode(e);return t.set(n,i),i}else return o}var Br=112,zl=18;function da(e,t,r){let n=Ye(e),o=n+Ye(t),i=new Uint8Array(o+r.byteLength);return Ze(e,i,0),Ze(t,i,n),i.set(r,o),i}var jl=Symbol.for("@ipld/js-cid/CID");var Zo={};Et(Zo,{identity:()=>It});var ha=0,Gl="identity",pa=ne;function Wl(e){return Ft(ha,pa(e))}var It={code:ha,name:Gl,encode:pa,digest:Wl};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 oe(e=0){return new Uint8Array(e)}function Tt(e=0){return new Uint8Array(e)}function Lt(e,t){t==null&&(t=e.reduce((o,i)=>o+i.length,0));let r=Tt(t),n=0;for(let o of e)r.set(o,n),n+=o.length;return r}var ya=Symbol.for("@achingbrain/uint8arraylist");function ma(e,t){if(t==null||t<0)throw new RangeError("index is out of bounds");let r=0;for(let n of e){let o=r+n.byteLength;if(t<o)return{buf:n,index:t-r};r=o}throw new RangeError("index is out of bounds")}function Je(e){return!!e?.[ya]}var Ct=class e{bufs;length;[ya]=!0;constructor(...t){this.bufs=[],this.length=0,t.length>0&&this.appendAll(t)}*[Symbol.iterator](){yield*this.bufs}get byteLength(){return this.length}append(...t){this.appendAll(t)}appendAll(t){let r=0;for(let n of t)if(n instanceof Uint8Array)r+=n.byteLength,this.bufs.push(n);else if(Je(n))r+=n.byteLength,this.bufs.push(...n.bufs);else throw new Error("Could not append value, must be an Uint8Array or a Uint8ArrayList");this.length+=r}prepend(...t){this.prependAll(t)}prependAll(t){let r=0;for(let n of t.reverse())if(n instanceof Uint8Array)r+=n.byteLength,this.bufs.unshift(n);else if(Je(n))r+=n.byteLength,this.bufs.unshift(...n.bufs);else throw new Error("Could not prepend value, must be an Uint8Array or a Uint8ArrayList");this.length+=r}get(t){let r=ma(this.bufs,t);return r.buf[r.index]}set(t,r){let n=ma(this.bufs,t);n.buf[n.index]=r}write(t,r=0){if(t instanceof Uint8Array)for(let n=0;n<t.length;n++)this.set(r+n,t[n]);else if(Je(t))for(let n=0;n<t.length;n++)this.set(r+n,t.get(n));else throw new Error("Could not write value, must be an Uint8Array or a Uint8ArrayList")}consume(t){if(t=Math.trunc(t),!(Number.isNaN(t)||t<=0)){if(t===this.byteLength){this.bufs=[],this.length=0;return}for(;this.bufs.length>0;)if(t>=this.bufs[0].byteLength)t-=this.bufs[0].byteLength,this.length-=this.bufs[0].byteLength,this.bufs.shift();else{this.bufs[0]=this.bufs[0].subarray(t),this.length-=t;break}}}slice(t,r){let{bufs:n,length:o}=this._subList(t,r);return Lt(n,o)}subarray(t,r){let{bufs:n,length:o}=this._subList(t,r);return n.length===1?n[0]:Lt(n,o)}sublist(t,r){let{bufs:n,length:o}=this._subList(t,r),i=new e;return i.length=o,i.bufs=[...n],i}_subList(t,r){if(t=t??0,r=r??this.length,t<0&&(t=this.length+t),r<0&&(r=this.length+r),t<0||r>this.length)throw new RangeError("index is out of bounds");if(t===r)return{bufs:[],length:0};if(t===0&&r===this.length)return{bufs:this.bufs,length:this.length};let n=[],o=0;for(let i=0;i<this.bufs.length;i++){let s=this.bufs[i],a=o,c=a+s.byteLength;if(o=c,t>=c)continue;let l=t>=a&&t<c,u=r>a&&r<=c;if(l&&u){if(t===a&&r===c){n.push(s);break}let f=t-a;n.push(s.subarray(f,f+(r-t)));break}if(l){if(t===0){n.push(s);continue}n.push(s.subarray(t-a));continue}if(u){if(r===c){n.push(s);break}n.push(s.subarray(0,r-a));break}n.push(s)}return{bufs:n,length:r-t}}indexOf(t,r=0){if(!Je(t)&&!(t instanceof Uint8Array))throw new TypeError('The "value" argument must be a Uint8ArrayList or Uint8Array');let n=t instanceof Uint8Array?t:t.subarray();if(r=Number(r??0),isNaN(r)&&(r=0),r<0&&(r=this.length+r),r<0&&(r=0),t.length===0)return r>this.length?this.length:r;let o=n.byteLength;if(o===0)throw new TypeError("search must be at least 1 byte long");let i=256,s=new Int32Array(i);for(let f=0;f<i;f++)s[f]=-1;for(let f=0;f<o;f++)s[n[f]]=f;let a=s,c=this.byteLength-n.byteLength,l=n.byteLength-1,u;for(let f=r;f<=c;f+=u){u=0;for(let m=l;m>=0;m--){let y=this.get(f+m);if(n[m]!==y){u=Math.max(1,m-a[y]);break}}if(u===0)return f}return-1}getInt8(t){let r=this.subarray(t,t+1);return new DataView(r.buffer,r.byteOffset,r.byteLength).getInt8(0)}setInt8(t,r){let n=Tt(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setInt8(0,r),this.write(n,t)}getInt16(t,r){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt16(0,r)}setInt16(t,r,n){let o=oe(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=oe(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=oe(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigInt64(0,r,n),this.write(o,t)}getUint8(t){let r=this.subarray(t,t+1);return new DataView(r.buffer,r.byteOffset,r.byteLength).getUint8(0)}setUint8(t,r){let n=Tt(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setUint8(0,r),this.write(n,t)}getUint16(t,r){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint16(0,r)}setUint16(t,r,n){let o=oe(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=oe(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=oe(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=oe(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=oe(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 Yo={};Et(Yo,{base10:()=>Zl});var Zl=pe({prefix:"9",name:"base10",alphabet:"0123456789"});var Xo={};Et(Xo,{base16:()=>Yl,base16upper:()=>Xl});var Yl=Q({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Xl=Q({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Jo={};Et(Jo,{base2:()=>Jl});var Jl=Q({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Qo={};Et(Qo,{base256emoji:()=>nd});var ga=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),Ql=ga.reduce((e,t,r)=>(e[r]=t,e),[]),td=ga.reduce((e,t,r)=>{let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);return e[n]=r,e},[]);function ed(e){return e.reduce((t,r)=>(t+=Ql[r],t),"")}function rd(e){let t=[];for(let r of e){let n=r.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${r}`);let o=td[n];if(o==null)throw new Error(`Non-base256emoji character: ${r}`);t.push(o)}return new Uint8Array(t)}var nd=Ge({prefix:"\u{1F680}",name:"base256emoji",encode:ed,decode:rd});var ti={};Et(ti,{base8:()=>od});var od=Q({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var ei={};Et(ei,{identity:()=>id});var id=Ge({prefix:"\0",name:"identity",encode:e=>ta(e),decode:e=>Qs(e)});var Vm=new TextEncoder,$m=new TextDecoder;var oi={};Et(oi,{sha256:()=>_r,sha512:()=>cd});function ni({name:e,code:t,encode:r}){return new ri(e,t,r)}var ri=class{name;code;encode;constructor(t,r,n){this.name=t,this.code=r,this.encode=n}digest(t){if(t instanceof Uint8Array){let r=this.encode(t);return r instanceof Uint8Array?Ft(this.code,r):r.then(n=>Ft(this.code,n))}else throw Error("Unknown type, must be binary type")}};function wa(e){return async t=>new Uint8Array(await crypto.subtle.digest(e,t))}var _r=ni({name:"sha2-256",code:18,encode:wa("SHA-256")}),cd=ni({name:"sha2-512",code:19,encode:wa("SHA-512")});var Pr={...ei,...Jo,...ti,...Yo,...Xo,...Mo,...jo,...Vo,...Ho,...Qo},ty={...oi,...Zo};function Ea(e,t,r,n){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:n}}}var ba=Ea("utf8","u",e=>"u"+new TextDecoder("utf8").decode(e),e=>new TextEncoder().encode(e.substring(1))),ii=Ea("ascii","a",e=>{let t="a";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return t},e=>{e=e.substring(1);let t=Tt(e.length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t}),ud={utf8:ba,"utf-8":ba,hex:Pr.base16,latin1:ii,ascii:ii,binary:ii,...Pr},bn=ud;function M(e,t="utf8"){let r=bn[t];if(r==null)throw new Error(`Unsupported encoding "${t}"`);return r.decoder.decode(`${r.prefix}${e}`)}function V(e,t="utf8"){let r=bn[t];if(r==null)throw new Error(`Unsupported encoding "${t}"`);return r.encoder.encode(e).substring(1)}var fd=parseInt("11111",2),si=parseInt("10000000",2),ld=parseInt("01111111",2),Sa={0:Dr,1:Dr,2:dd,3:md,4:yd,5:pd,6:hd,16:Dr,22:Dr,48:Dr};function ie(e,t={offset:0}){let r=e[t.offset]&fd;if(t.offset++,Sa[r]!=null)return Sa[r](e,t);throw new Error("No decoder for tag "+r)}function Nr(e,t){let r=0;if((e[t.offset]&si)===si){let n=e[t.offset]&ld,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 Dr(e,t){Nr(e,t);let r=[];for(;!(t.offset>=e.byteLength);){let n=ie(e,t);if(n===null)break;r.push(n)}return r}function dd(e,t){let r=Nr(e,t),n=t.offset,o=t.offset+r,i=[];for(let s=n;s<o;s++)s===n&&e[s]===0||i.push(e[s]);return t.offset+=r,Uint8Array.from(i)}function hd(e,t){let r=Nr(e,t),n=t.offset+r,o=e[t.offset];t.offset++;let i=0,s=0;o<40?(i=0,s=o):o<80?(i=1,s=o-40):(i=2,s=o-80);let a=`${i}.${s}`,c=[];for(;t.offset<n;){let l=e[t.offset];if(t.offset++,c.push(l&127),l<128){c.reverse();let u=0;for(let f=0;f<c.length;f++)u+=c[f]<<f*7;a+=`.${u}`,c=[]}}return a}function pd(e,t){return t.offset++,null}function md(e,t){let r=Nr(e,t),n=e[t.offset];t.offset++;let o=e.subarray(t.offset,t.offset+r-1);if(t.offset+=r,n!==0)throw new Error("Unused bits in bit string is unimplemented");return o}function yd(e,t){let r=Nr(e,t),n=e.subarray(t.offset,t.offset+r);return t.offset+=r,n}function gd(e){let t=e.toString(16);t.length%2===1&&(t="0"+t);let r=new Ct;for(let n=0;n<t.length;n+=2)r.append(Uint8Array.from([parseInt(`${t[n]}${t[n+1]}`,16)]));return r}function ai(e){if(e.byteLength<128)return Uint8Array.from([e.byteLength]);let t=gd(e.byteLength);return new Ct(Uint8Array.from([t.byteLength|si]),t)}function At(e){let t=new Ct,r=128;return(e.subarray()[0]&r)===r&&t.append(Uint8Array.from([0])),t.append(e),new Ct(Uint8Array.from([2]),ai(t),t)}function En(e){let t=Uint8Array.from([0]),r=new Ct(t,e);return new Ct(Uint8Array.from([3]),ai(r),r)}function ye(e,t=48){let r=new Ct;for(let n of e)r.append(n);return new Ct(Uint8Array.from([t]),ai(r),r)}async function va(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 xd=Uint8Array.from([6,8,42,134,72,206,61,3,1,7]),wd=Uint8Array.from([6,5,43,129,4,0,34]),bd=Uint8Array.from([6,5,43,129,4,0,35]),Ed={ext:!0,kty:"EC",crv:"P-256"},Sd={ext:!0,kty:"EC",crv:"P-384"},vd={ext:!0,kty:"EC",crv:"P-521"},ci=32,ui=48,fi=66;function li(e){let t=ie(e);return Aa(t)}function Aa(e){let t=e[1][1][0],r=1,n,o;if(t.byteLength===ci*2+1)return n=V(t.subarray(r,r+ci),"base64url"),o=V(t.subarray(r+ci),"base64url"),new Qe({...Ed,key_ops:["verify"],x:n,y:o});if(t.byteLength===ui*2+1)return n=V(t.subarray(r,r+ui),"base64url"),o=V(t.subarray(r+ui),"base64url"),new Qe({...Sd,key_ops:["verify"],x:n,y:o});if(t.byteLength===fi*2+1)return n=V(t.subarray(r,r+fi),"base64url"),o=V(t.subarray(r+fi),"base64url"),new Qe({...vd,key_ops:["verify"],x:n,y:o});throw new rt(`coordinates were wrong length, got ${t.byteLength}, expected 65, 97 or 133`)}function Ia(e){return ye([At(Uint8Array.from([1])),ye([Ad(e.crv)],160),ye([En(new Ct(Uint8Array.from([4]),M(e.x??"","base64url"),M(e.y??"","base64url")))],161)]).subarray()}function Ad(e){if(e==="P-256")return xd;if(e==="P-384")return wd;if(e==="P-521")return bd;throw new rt(`Invalid curve ${e}`)}var Qe=class{type="ECDSA";jwk;_raw;constructor(t){this.jwk=t}get raw(){return this._raw==null&&(this._raw=Ia(this.jwk)),this._raw}toMultihash(){return It.digest(tr(this))}toCID(){return $.createV1(114,this.toMultihash())}toString(){return j.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 va(this.jwk,r,t,n)}};var _e=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function rr(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Rr(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function ht(e,...t){if(!rr(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function Ca(e){if(typeof e!="function"||typeof e.create!="function")throw new Error("Hash should be wrapped by utils.createHasher");Rr(e.outputLen),Rr(e.blockLen)}function nr(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function Ba(e,t){ht(e);let r=t.outputLen;if(e.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}function ae(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function Sn(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function Mt(e,t){return e<<32-t|e>>>t}var _a=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",Id=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Yt(e){if(ht(e),_a)return e.toHex();let t="";for(let r=0;r<e.length;r++)t+=Id[e[r]];return t}var se={_0:48,_9:57,A:65,F:70,a:97,f:102};function Ta(e){if(e>=se._0&&e<=se._9)return e-se._0;if(e>=se.A&&e<=se.F)return e-(se.A-10);if(e>=se.a&&e<=se.f)return e-(se.a-10)}function or(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);if(_a)return Uint8Array.fromHex(e);let t=e.length,r=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);let n=new Uint8Array(r);for(let o=0,i=0;o<r;o++,i+=2){let s=Ta(e.charCodeAt(i)),a=Ta(e.charCodeAt(i+1));if(s===void 0||a===void 0){let c=e[i]+e[i+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+i)}n[o]=s*16+a}return n}function Pa(e){if(typeof e!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(e))}function Ur(e){return typeof e=="string"&&(e=Pa(e)),ht(e),e}function Bt(...e){let t=0;for(let n=0;n<e.length;n++){let o=e[n];ht(o),t+=o.length}let r=new Uint8Array(t);for(let n=0,o=0;n<e.length;n++){let i=e[n];r.set(i,o),o+=i.length}return r}var er=class{};function di(e){let t=n=>e().update(Ur(n)).digest(),r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>e(),t}function Lr(e=32){if(_e&&typeof _e.getRandomValues=="function")return _e.getRandomValues(new Uint8Array(e));if(_e&&typeof _e.randomBytes=="function")return Uint8Array.from(_e.randomBytes(e));throw new Error("crypto.getRandomValues must be defined")}function Td(e,t,r,n){if(typeof e.setBigUint64=="function")return e.setBigUint64(t,r,n);let o=BigInt(32),i=BigInt(4294967295),s=Number(r>>o&i),a=Number(r&i),c=n?4:0,l=n?0:4;e.setUint32(t+c,s,n),e.setUint32(t+l,a,n)}function Da(e,t,r){return e&t^~e&r}function Na(e,t,r){return e&t^e&r^t&r}var Or=class extends er{constructor(t,r,n,o){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=t,this.outputLen=r,this.padOffset=n,this.isLE=o,this.buffer=new Uint8Array(t),this.view=Sn(this.buffer)}update(t){nr(this),t=Ur(t),ht(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=Sn(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){nr(this),Ba(t,this),this.finished=!0;let{buffer:r,view:n,blockLen:o,isLE:i}=this,{pos:s}=this;r[s++]=128,ae(this.buffer.subarray(s)),this.padOffset>o-s&&(this.process(n,0),s=0);for(let f=s;f<o;f++)r[f]=0;Td(n,o-8,BigInt(this.length*8),i),this.process(n,0);let a=Sn(t),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let l=c/4,u=this.get();if(l>u.length)throw new Error("_sha2: outputLen bigger than state");for(let f=0;f<l;f++)a.setUint32(4*f,u[f],i)}digest(){let{buffer:t,outputLen:r}=this;this.digestInto(t);let n=t.slice(0,r);return this.destroy(),n}_cloneInto(t){t||(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()}},ce=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var ct=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]);var vn=BigInt(4294967295),Ra=BigInt(32);function Cd(e,t=!1){return t?{h:Number(e&vn),l:Number(e>>Ra&vn)}:{h:Number(e>>Ra&vn)|0,l:Number(e&vn)|0}}function Ua(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}=Cd(e[i],t);[n[i],o[i]]=[s,a]}return[n,o]}var hi=(e,t,r)=>e>>>r,pi=(e,t,r)=>e<<32-r|t>>>r,Pe=(e,t,r)=>e>>>r|t<<32-r,De=(e,t,r)=>e<<32-r|t>>>r,kr=(e,t,r)=>e<<64-r|t>>>r-32,Kr=(e,t,r)=>e>>>r-32|t<<64-r;function Xt(e,t,r,n){let o=(t>>>0)+(n>>>0);return{h:e+r+(o/2**32|0)|0,l:o|0}}var La=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0),Oa=(e,t,r,n)=>t+r+n+(e/2**32|0)|0,ka=(e,t,r,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0),Ka=(e,t,r,n,o)=>t+r+n+o+(e/2**32|0)|0,Fa=(e,t,r,n,o)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0)+(o>>>0),Ma=(e,t,r,n,o,i)=>t+r+n+o+i+(e/2**32|0)|0;var _d=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]),ge=new Uint32Array(64),An=class extends Or{constructor(t=32){super(64,t,8,!1),this.A=ce[0]|0,this.B=ce[1]|0,this.C=ce[2]|0,this.D=ce[3]|0,this.E=ce[4]|0,this.F=ce[5]|0,this.G=ce[6]|0,this.H=ce[7]|0}get(){let{A:t,B:r,C:n,D:o,E:i,F:s,G:a,H:c}=this;return[t,r,n,o,i,s,a,c]}set(t,r,n,o,i,s,a,c){this.A=t|0,this.B=r|0,this.C=n|0,this.D=o|0,this.E=i|0,this.F=s|0,this.G=a|0,this.H=c|0}process(t,r){for(let f=0;f<16;f++,r+=4)ge[f]=t.getUint32(r,!1);for(let f=16;f<64;f++){let m=ge[f-15],y=ge[f-2],B=Mt(m,7)^Mt(m,18)^m>>>3,v=Mt(y,17)^Mt(y,19)^y>>>10;ge[f]=v+ge[f-7]+B+ge[f-16]|0}let{A:n,B:o,C:i,D:s,E:a,F:c,G:l,H:u}=this;for(let f=0;f<64;f++){let m=Mt(a,6)^Mt(a,11)^Mt(a,25),y=u+m+Da(a,c,l)+_d[f]+ge[f]|0,v=(Mt(n,2)^Mt(n,13)^Mt(n,22))+Na(n,o,i)|0;u=l,l=c,c=a,a=s+y|0,s=i,i=o,o=n,n=y+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,l=l+this.G|0,u=u+this.H|0,this.set(n,o,i,s,a,c,l,u)}roundClean(){ae(ge)}destroy(){this.set(0,0,0,0,0,0,0,0),ae(this.buffer)}};var Va=Ua(["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))),Pd=Va[0],Dd=Va[1],xe=new Uint32Array(80),we=new Uint32Array(80),mi=class extends Or{constructor(t=64){super(128,t,16,!1),this.Ah=ct[0]|0,this.Al=ct[1]|0,this.Bh=ct[2]|0,this.Bl=ct[3]|0,this.Ch=ct[4]|0,this.Cl=ct[5]|0,this.Dh=ct[6]|0,this.Dl=ct[7]|0,this.Eh=ct[8]|0,this.El=ct[9]|0,this.Fh=ct[10]|0,this.Fl=ct[11]|0,this.Gh=ct[12]|0,this.Gl=ct[13]|0,this.Hh=ct[14]|0,this.Hl=ct[15]|0}get(){let{Ah:t,Al:r,Bh:n,Bl:o,Ch:i,Cl:s,Dh:a,Dl:c,Eh:l,El:u,Fh:f,Fl:m,Gh:y,Gl:B,Hh:v,Hl:w}=this;return[t,r,n,o,i,s,a,c,l,u,f,m,y,B,v,w]}set(t,r,n,o,i,s,a,c,l,u,f,m,y,B,v,w){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=l|0,this.El=u|0,this.Fh=f|0,this.Fl=m|0,this.Gh=y|0,this.Gl=B|0,this.Hh=v|0,this.Hl=w|0}process(t,r){for(let P=0;P<16;P++,r+=4)xe[P]=t.getUint32(r),we[P]=t.getUint32(r+=4);for(let P=16;P<80;P++){let k=xe[P-15]|0,E=we[P-15]|0,N=Pe(k,E,1)^Pe(k,E,8)^hi(k,E,7),R=De(k,E,1)^De(k,E,8)^pi(k,E,7),g=xe[P-2]|0,d=we[P-2]|0,x=Pe(g,d,19)^kr(g,d,61)^hi(g,d,6),h=De(g,d,19)^Kr(g,d,61)^pi(g,d,6),p=ka(R,h,we[P-7],we[P-16]),S=Ka(p,N,x,xe[P-7],xe[P-16]);xe[P]=S|0,we[P]=p|0}let{Ah:n,Al:o,Bh:i,Bl:s,Ch:a,Cl:c,Dh:l,Dl:u,Eh:f,El:m,Fh:y,Fl:B,Gh:v,Gl:w,Hh:C,Hl:D}=this;for(let P=0;P<80;P++){let k=Pe(f,m,14)^Pe(f,m,18)^kr(f,m,41),E=De(f,m,14)^De(f,m,18)^Kr(f,m,41),N=f&y^~f&v,R=m&B^~m&w,g=Fa(D,E,R,Dd[P],we[P]),d=Ma(g,C,k,N,Pd[P],xe[P]),x=g|0,h=Pe(n,o,28)^kr(n,o,34)^kr(n,o,39),p=De(n,o,28)^Kr(n,o,34)^Kr(n,o,39),S=n&i^n&a^i&a,I=o&s^o&c^s&c;C=v|0,D=w|0,v=y|0,w=B|0,y=f|0,B=m|0,{h:f,l:m}=Xt(l|0,u|0,d|0,x|0),l=a|0,u=c|0,a=i|0,c=s|0,i=n|0,s=o|0;let A=La(x,p,I);n=Oa(A,d,h,S),o=A|0}({h:n,l:o}=Xt(this.Ah|0,this.Al|0,n|0,o|0)),{h:i,l:s}=Xt(this.Bh|0,this.Bl|0,i|0,s|0),{h:a,l:c}=Xt(this.Ch|0,this.Cl|0,a|0,c|0),{h:l,l:u}=Xt(this.Dh|0,this.Dl|0,l|0,u|0),{h:f,l:m}=Xt(this.Eh|0,this.El|0,f|0,m|0),{h:y,l:B}=Xt(this.Fh|0,this.Fl|0,y|0,B|0),{h:v,l:w}=Xt(this.Gh|0,this.Gl|0,v|0,w|0),{h:C,l:D}=Xt(this.Hh|0,this.Hl|0,C|0,D|0),this.set(n,o,i,s,a,c,l,u,f,m,y,B,v,w,C,D)}roundClean(){ae(xe,we)}destroy(){ae(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};var In=di(()=>new An);var $a=di(()=>new mi);var xi=BigInt(0),gi=BigInt(1);function ue(e,t){if(typeof t!="boolean")throw new Error(e+" boolean expected, got "+t)}function Fr(e){let t=e.toString(16);return t.length&1?"0"+t:t}function qa(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);return e===""?xi:BigInt("0x"+e)}function ir(e){return qa(Yt(e))}function Ne(e){return ht(e),qa(Yt(Uint8Array.from(e).reverse()))}function Tn(e,t){return or(e.toString(16).padStart(t*2,"0"))}function sr(e,t){return Tn(e,t).reverse()}function Z(e,t,r){let n;if(typeof t=="string")try{n=or(t)}catch(i){throw new Error(e+" must be hex string or Uint8Array, cause: "+i)}else if(rr(t))n=Uint8Array.from(t);else throw new Error(e+" must be hex string or Uint8Array");let o=n.length;if(typeof r=="number"&&o!==r)throw new Error(e+" of length "+r+" expected, got "+o);return n}var yi=e=>typeof e=="bigint"&&xi<=e;function Ha(e,t,r){return yi(e)&&yi(t)&&yi(r)&&t<=e&&e<r}function be(e,t,r,n){if(!Ha(t,r,n))throw new Error("expected valid "+e+": "+r+" <= n < "+n+", got "+t)}function za(e){let t;for(t=0;e>xi;e>>=gi,t+=1);return t}var Re=e=>(gi<<BigInt(e))-gi;function ja(e,t,r){if(typeof e!="number"||e<2)throw new Error("hashLen must be a number");if(typeof t!="number"||t<2)throw new Error("qByteLen must be a number");if(typeof r!="function")throw new Error("hmacFn must be a function");let n=y=>new Uint8Array(y),o=y=>Uint8Array.of(y),i=n(e),s=n(e),a=0,c=()=>{i.fill(1),s.fill(0),a=0},l=(...y)=>r(s,i,...y),u=(y=n(0))=>{s=l(o(0),y),i=l(),y.length!==0&&(s=l(o(1),y),i=l())},f=()=>{if(a++>=1e3)throw new Error("drbg: tried 1000 values");let y=0,B=[];for(;y<t;){i=l();let v=i.slice();B.push(v),y+=i.length}return Bt(...B)};return(y,B)=>{c(),u(y);let v;for(;!(v=B(f()));)u();return c(),v}}function Ee(e,t,r={}){if(!e||typeof e!="object")throw new Error("expected valid options object");function n(o,i,s){let a=e[o];if(s&&a===void 0)return;let c=typeof a;if(c!==i||a===null)throw new Error(`param "${o}" is invalid: expected ${i}, got ${c}`)}Object.entries(t).forEach(([o,i])=>n(o,i,!1)),Object.entries(r).forEach(([o,i])=>n(o,i,!0))}function ar(e){let t=new WeakMap;return(r,...n)=>{let o=t.get(r);if(o!==void 0)return o;let i=e(r,...n);return t.set(r,i),i}}var xt=BigInt(0),it=BigInt(1),Ue=BigInt(2),Nd=BigInt(3),Za=BigInt(4),Ya=BigInt(5),Xa=BigInt(8);function X(e,t){let r=e%t;return r>=xt?r:t+r}function Y(e,t,r){let n=e;for(;t-- >xt;)n*=n,n%=r;return n}function Ga(e,t){if(e===xt)throw new Error("invert: expected non-zero number");if(t<=xt)throw new Error("invert: expected positive modulus, got "+t);let r=X(e,t),n=t,o=xt,i=it,s=it,a=xt;for(;r!==xt;){let l=n/r,u=n%r,f=o-s*l,m=i-a*l;n=r,r=u,o=s,i=a,s=f,a=m}if(n!==it)throw new Error("invert: does not exist");return X(o,t)}function Ja(e,t){let r=(e.ORDER+it)/Za,n=e.pow(t,r);if(!e.eql(e.sqr(n),t))throw new Error("Cannot find square root");return n}function Rd(e,t){let r=(e.ORDER-Ya)/Xa,n=e.mul(t,Ue),o=e.pow(n,r),i=e.mul(t,o),s=e.mul(e.mul(i,Ue),o),a=e.mul(i,e.sub(s,e.ONE));if(!e.eql(e.sqr(a),t))throw new Error("Cannot find square root");return a}function Ud(e){if(e<BigInt(3))throw new Error("sqrt is not defined for small field");let t=e-it,r=0;for(;t%Ue===xt;)t/=Ue,r++;let n=Ue,o=Vt(e);for(;Wa(o,n)===1;)if(n++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(r===1)return Ja;let i=o.pow(n,t),s=(t+it)/Ue;return function(c,l){if(c.is0(l))return l;if(Wa(c,l)!==1)throw new Error("Cannot find square root");let u=r,f=c.mul(c.ONE,i),m=c.pow(l,t),y=c.pow(l,s);for(;!c.eql(m,c.ONE);){if(c.is0(m))return c.ZERO;let B=1,v=c.sqr(m);for(;!c.eql(v,c.ONE);)if(B++,v=c.sqr(v),B===u)throw new Error("Cannot find square root");let w=it<<BigInt(u-B-1),C=c.pow(f,w);u=B,f=c.sqr(C),m=c.mul(m,f),y=c.mul(y,C)}return y}}function Ld(e){return e%Za===Nd?Ja:e%Xa===Ya?Rd:Ud(e)}var Qa=(e,t)=>(X(e,t)&it)===it,Od=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function wi(e){let t={ORDER:"bigint",MASK:"bigint",BYTES:"number",BITS:"number"},r=Od.reduce((n,o)=>(n[o]="function",n),t);return Ee(e,r),e}function kd(e,t,r){if(r<xt)throw new Error("invalid exponent, negatives unsupported");if(r===xt)return e.ONE;if(r===it)return t;let n=e.ONE,o=t;for(;r>xt;)r&it&&(n=e.mul(n,o)),o=e.sqr(o),r>>=it;return n}function Mr(e,t,r=!1){let n=new Array(t.length).fill(r?e.ZERO:void 0),o=t.reduce((s,a,c)=>e.is0(a)?s:(n[c]=s,e.mul(s,a)),e.ONE),i=e.inv(o);return t.reduceRight((s,a,c)=>e.is0(a)?s:(n[c]=e.mul(s,n[c]),e.mul(s,a)),i),n}function Wa(e,t){let r=(e.ORDER-it)/Ue,n=e.pow(t,r),o=e.eql(n,e.ONE),i=e.eql(n,e.ZERO),s=e.eql(n,e.neg(e.ONE));if(!o&&!i&&!s)throw new Error("invalid Legendre symbol result");return o?1:i?0:-1}function tc(e,t){t!==void 0&&Rr(t);let r=t!==void 0?t:e.toString(2).length,n=Math.ceil(r/8);return{nBitLength:r,nByteLength:n}}function Vt(e,t,r=!1,n={}){if(e<=xt)throw new Error("invalid field: expected ORDER > 0, got "+e);let o,i;if(typeof t=="object"&&t!=null){if(n.sqrt||r)throw new Error("cannot specify opts in two arguments");let u=t;u.BITS&&(o=u.BITS),u.sqrt&&(i=u.sqrt),typeof u.isLE=="boolean"&&(r=u.isLE)}else typeof t=="number"&&(o=t),n.sqrt&&(i=n.sqrt);let{nBitLength:s,nByteLength:a}=tc(e,o);if(a>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let c,l=Object.freeze({ORDER:e,isLE:r,BITS:s,BYTES:a,MASK:Re(s),ZERO:xt,ONE:it,create:u=>X(u,e),isValid:u=>{if(typeof u!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof u);return xt<=u&&u<e},is0:u=>u===xt,isValidNot0:u=>!l.is0(u)&&l.isValid(u),isOdd:u=>(u&it)===it,neg:u=>X(-u,e),eql:(u,f)=>u===f,sqr:u=>X(u*u,e),add:(u,f)=>X(u+f,e),sub:(u,f)=>X(u-f,e),mul:(u,f)=>X(u*f,e),pow:(u,f)=>kd(l,u,f),div:(u,f)=>X(u*Ga(f,e),e),sqrN:u=>u*u,addN:(u,f)=>u+f,subN:(u,f)=>u-f,mulN:(u,f)=>u*f,inv:u=>Ga(u,e),sqrt:i||(u=>(c||(c=Ld(e)),c(l,u))),toBytes:u=>r?sr(u,a):Tn(u,a),fromBytes:u=>{if(u.length!==a)throw new Error("Field.fromBytes: expected "+a+" bytes, got "+u.length);return r?Ne(u):ir(u)},invertBatch:u=>Mr(l,u),cmov:(u,f,m)=>m?f:u});return Object.freeze(l)}function ec(e){if(typeof e!="bigint")throw new Error("field order must be bigint");let t=e.toString(2).length;return Math.ceil(t/8)}function bi(e){let t=ec(e);return t+Math.ceil(t/2)}function rc(e,t,r=!1){let n=e.length,o=ec(t),i=bi(t);if(n<16||n<i||n>1024)throw new Error("expected "+i+"-1024 bytes of input, got "+n);let s=r?Ne(e):ir(e),a=X(s,t-it)+it;return r?sr(a,o):Tn(a,o)}var ur=BigInt(0),Le=BigInt(1);function cr(e,t){let r=t.negate();return e?r:t}function Cn(e,t,r){let n=t==="pz"?s=>s.pz:s=>s.ez,o=Mr(e.Fp,r.map(n));return r.map((s,a)=>s.toAffine(o[a])).map(e.fromAffine)}function sc(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+e)}function Ei(e,t){sc(e,t);let r=Math.ceil(t/e)+1,n=2**(e-1),o=2**e,i=Re(e),s=BigInt(e);return{windows:r,windowSize:n,mask:i,maxNumber:o,shiftBy:s}}function nc(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+=Le);let l=t*n,u=l+Math.abs(a)-1,f=a===0,m=a<0,y=t%2!==0;return{nextN:c,offset:u,isZero:f,isNeg:m,isNegF:y,offsetF:l}}function Kd(e,t){if(!Array.isArray(e))throw new Error("array expected");e.forEach((r,n)=>{if(!(r instanceof t))throw new Error("invalid point at index "+n)})}function Fd(e,t){if(!Array.isArray(e))throw new Error("array of scalars expected");e.forEach((r,n)=>{if(!t.isValid(r))throw new Error("invalid scalar at index "+n)})}var Si=new WeakMap,ac=new WeakMap;function vi(e){return ac.get(e)||1}function oc(e){if(e!==ur)throw new Error("invalid wNAF")}function Bn(e,t){return{constTimeNegate:cr,hasPrecomputes(r){return vi(r)!==1},unsafeLadder(r,n,o=e.ZERO){let i=r;for(;n>ur;)n&Le&&(o=o.add(i)),i=i.double(),n>>=Le;return o},precomputeWindow(r,n){let{windows:o,windowSize:i}=Ei(n,t),s=[],a=r,c=a;for(let l=0;l<o;l++){c=a,s.push(c);for(let u=1;u<i;u++)c=c.add(a),s.push(c);a=c.double()}return s},wNAF(r,n,o){let i=e.ZERO,s=e.BASE,a=Ei(r,t);for(let c=0;c<a.windows;c++){let{nextN:l,offset:u,isZero:f,isNeg:m,isNegF:y,offsetF:B}=nc(o,c,a);o=l,f?s=s.add(cr(y,n[B])):i=i.add(cr(m,n[u]))}return oc(o),{p:i,f:s}},wNAFUnsafe(r,n,o,i=e.ZERO){let s=Ei(r,t);for(let a=0;a<s.windows&&o!==ur;a++){let{nextN:c,offset:l,isZero:u,isNeg:f}=nc(o,a,s);if(o=c,!u){let m=n[l];i=i.add(f?m.negate():m)}}return oc(o),i},getPrecomputes(r,n,o){let i=Si.get(n);return i||(i=this.precomputeWindow(n,r),r!==1&&(typeof o=="function"&&(i=o(i)),Si.set(n,i))),i},wNAFCached(r,n,o){let i=vi(r);return this.wNAF(i,this.getPrecomputes(i,r,o),n)},wNAFCachedUnsafe(r,n,o,i){let s=vi(r);return s===1?this.unsafeLadder(r,n,i):this.wNAFUnsafe(s,this.getPrecomputes(s,r,o),n,i)},setWindowSize(r,n){sc(n,t),ac.set(r,n),Si.delete(r)}}}function cc(e,t,r,n){let o=t,i=e.ZERO,s=e.ZERO;for(;r>ur||n>ur;)r&Le&&(i=i.add(o)),n&Le&&(s=s.add(o)),o=o.double(),r>>=Le,n>>=Le;return{p1:i,p2:s}}function _n(e,t,r,n){Kd(r,e),Fd(n,t);let o=r.length,i=n.length;if(o!==i)throw new Error("arrays of points and scalars must have equal length");let s=e.ZERO,a=za(BigInt(o)),c=1;a>12?c=a-3:a>4?c=a-2:a>0&&(c=2);let l=Re(c),u=new Array(Number(l)+1).fill(s),f=Math.floor((t.BITS-1)/c)*c,m=s;for(let y=f;y>=0;y-=c){u.fill(s);for(let v=0;v<i;v++){let w=n[v],C=Number(w>>BigInt(y)&l);u[C]=u[C].add(r[v])}let B=s;for(let v=u.length-1,w=s;v>0;v--)w=w.add(u[v]),B=B.add(w);if(m=m.add(B),y!==0)for(let v=0;v<c;v++)m=m.double()}return m}function ic(e,t){if(t){if(t.ORDER!==e)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return wi(t),t}else return Vt(e)}function Pn(e,t,r={}){if(!t||typeof t!="object")throw new Error(`expected valid ${e} CURVE object`);for(let a of["p","n","h"]){let c=t[a];if(!(typeof c=="bigint"&&c>ur))throw new Error(`CURVE.${a} must be positive bigint`)}let n=ic(t.p,r.Fp),o=ic(t.n,r.Fn),s=["Gx","Gy","a",e==="weierstrass"?"b":"d"];for(let a of s)if(!n.isValid(t[a]))throw new Error(`CURVE.${a} must be valid field element of CURVE.Fp`);return{Fp:n,Fn:o}}var Jt=BigInt(0),wt=BigInt(1),Ai=BigInt(2),Md=BigInt(8),Vd={zip215:!0};function $d(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 qd(e,t={}){let{Fp:r,Fn:n}=Pn("edwards",e,t),{h:o,n:i}=e;Ee(t,{},{uvRatio:"function"});let s=Ai<<BigInt(n.BYTES*8)-wt,a=v=>r.create(v),c=t.uvRatio||((v,w)=>{try{return{isValid:!0,value:r.sqrt(r.div(v,w))}}catch{return{isValid:!1,value:Jt}}});if(!$d(r,e,e.Gx,e.Gy))throw new Error("bad curve params: generator point");function l(v,w,C=!1){let D=C?wt:Jt;return be("coordinate "+v,w,D,s),w}function u(v){if(!(v instanceof y))throw new Error("ExtendedPoint expected")}let f=ar((v,w)=>{let{ex:C,ey:D,ez:P}=v,k=v.is0();w==null&&(w=k?Md:r.inv(P));let E=a(C*w),N=a(D*w),R=a(P*w);if(k)return{x:Jt,y:wt};if(R!==wt)throw new Error("invZ was invalid");return{x:E,y:N}}),m=ar(v=>{let{a:w,d:C}=e;if(v.is0())throw new Error("bad point: ZERO");let{ex:D,ey:P,ez:k,et:E}=v,N=a(D*D),R=a(P*P),g=a(k*k),d=a(g*g),x=a(N*w),h=a(g*a(x+R)),p=a(d+a(C*a(N*R)));if(h!==p)throw new Error("bad point: equation left != right (1)");let S=a(D*P),I=a(k*E);if(S!==I)throw new Error("bad point: equation left != right (2)");return!0});class y{constructor(w,C,D,P){this.ex=l("x",w),this.ey=l("y",C),this.ez=l("z",D,!0),this.et=l("t",P),Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(w){if(w instanceof y)throw new Error("extended point not allowed");let{x:C,y:D}=w||{};return l("x",C),l("y",D),new y(C,D,wt,a(C*D))}static normalizeZ(w){return Cn(y,"ez",w)}static msm(w,C){return _n(y,n,w,C)}_setWindowSize(w){this.precompute(w)}precompute(w=8,C=!0){return B.setWindowSize(this,w),C||this.multiply(Ai),this}assertValidity(){m(this)}equals(w){u(w);let{ex:C,ey:D,ez:P}=this,{ex:k,ey:E,ez:N}=w,R=a(C*N),g=a(k*P),d=a(D*N),x=a(E*P);return R===g&&d===x}is0(){return this.equals(y.ZERO)}negate(){return new y(a(-this.ex),this.ey,this.ez,a(-this.et))}double(){let{a:w}=e,{ex:C,ey:D,ez:P}=this,k=a(C*C),E=a(D*D),N=a(Ai*a(P*P)),R=a(w*k),g=C+D,d=a(a(g*g)-k-E),x=R+E,h=x-N,p=R-E,S=a(d*h),I=a(x*p),A=a(d*p),T=a(h*x);return new y(S,I,T,A)}add(w){u(w);let{a:C,d:D}=e,{ex:P,ey:k,ez:E,et:N}=this,{ex:R,ey:g,ez:d,et:x}=w,h=a(P*R),p=a(k*g),S=a(N*D*x),I=a(E*d),A=a((P+k)*(R+g)-h-p),T=I-S,O=I+S,L=a(p-C*h),z=a(A*T),H=a(O*L),F=a(A*L),et=a(T*O);return new y(z,H,et,F)}subtract(w){return this.add(w.negate())}multiply(w){let C=w;be("scalar",C,wt,i);let{p:D,f:P}=B.wNAFCached(this,C,y.normalizeZ);return y.normalizeZ([D,P])[0]}multiplyUnsafe(w,C=y.ZERO){let D=w;return be("scalar",D,Jt,i),D===Jt?y.ZERO:this.is0()||D===wt?this:B.wNAFCachedUnsafe(this,D,y.normalizeZ,C)}isSmallOrder(){return this.multiplyUnsafe(o).is0()}isTorsionFree(){return B.wNAFCachedUnsafe(this,i).is0()}toAffine(w){return f(this,w)}clearCofactor(){return o===wt?this:this.multiplyUnsafe(o)}static fromBytes(w,C=!1){return ht(w),this.fromHex(w,C)}static fromHex(w,C=!1){let{d:D,a:P}=e,k=r.BYTES;w=Z("pointHex",w,k),ue("zip215",C);let E=w.slice(),N=w[k-1];E[k-1]=N&-129;let R=Ne(E),g=C?s:r.ORDER;be("pointHex.y",R,Jt,g);let d=a(R*R),x=a(d-wt),h=a(D*d-P),{isValid:p,value:S}=c(x,h);if(!p)throw new Error("Point.fromHex: invalid y coordinate");let I=(S&wt)===wt,A=(N&128)!==0;if(!C&&S===Jt&&A)throw new Error("Point.fromHex: x=0 and x_0=1");return A!==I&&(S=a(-S)),y.fromAffine({x:S,y:R})}static fromPrivateScalar(w){return y.BASE.multiply(w)}toBytes(){let{x:w,y:C}=this.toAffine(),D=sr(C,r.BYTES);return D[D.length-1]|=w&wt?128:0,D}toRawBytes(){return this.toBytes()}toHex(){return Yt(this.toBytes())}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}y.BASE=new y(e.Gx,e.Gy,wt,a(e.Gx*e.Gy)),y.ZERO=new y(Jt,wt,wt,Jt),y.Fp=r,y.Fn=n;let B=Bn(y,n.BYTES*8);return y}function Hd(e,t){Ee(t,{hash:"function"},{adjustScalarBytes:"function",randomBytes:"function",domain:"function",prehash:"function",mapToCurve:"function"});let{prehash:r,hash:n}=t,{BASE:o,Fp:i,Fn:s}=e,a=s.ORDER,c=t.randomBytes||Lr,l=t.adjustScalarBytes||(E=>E),u=t.domain||((E,N,R)=>{if(ue("phflag",R),N.length||R)throw new Error("Contexts/pre-hash are not supported");return E});function f(E){return s.create(E)}function m(E){return f(Ne(E))}function y(E){let N=i.BYTES;E=Z("private key",E,N);let R=Z("hashed private key",n(E),2*N),g=l(R.slice(0,N)),d=R.slice(N,2*N),x=m(g);return{head:g,prefix:d,scalar:x}}function B(E){let{head:N,prefix:R,scalar:g}=y(E),d=o.multiply(g),x=d.toBytes();return{head:N,prefix:R,scalar:g,point:d,pointBytes:x}}function v(E){return B(E).pointBytes}function w(E=Uint8Array.of(),...N){let R=Bt(...N);return m(n(u(R,Z("context",E),!!r)))}function C(E,N,R={}){E=Z("message",E),r&&(E=r(E));let{prefix:g,scalar:d,pointBytes:x}=B(N),h=w(R.context,g,E),p=o.multiply(h).toBytes(),S=w(R.context,p,x,E),I=f(h+S*d);be("signature.s",I,Jt,a);let A=i.BYTES,T=Bt(p,sr(I,A));return Z("result",T,A*2)}let D=Vd;function P(E,N,R,g=D){let{context:d,zip215:x}=g,h=i.BYTES;E=Z("signature",E,2*h),N=Z("message",N),R=Z("publicKey",R,h),x!==void 0&&ue("zip215",x),r&&(N=r(N));let p=Ne(E.slice(h,2*h)),S,I,A;try{S=e.fromHex(R,x),I=e.fromHex(E.slice(0,h),x),A=o.multiplyUnsafe(p)}catch{return!1}if(!x&&S.isSmallOrder())return!1;let T=w(d,I.toBytes(),S.toBytes(),N);return I.add(S.multiplyUnsafe(T)).subtract(A).clearCofactor().is0()}return o.precompute(8),{getPublicKey:v,sign:C,verify:P,utils:{getExtendedPublicKey:B,randomPrivateKey:()=>c(i.BYTES),precompute(E=8,N=e.BASE){return N.precompute(E,!1)}},Point:e}}function zd(e){let t={a:e.a,d:e.d,p:e.Fp.ORDER,n:e.n,h:e.h,Gx:e.Gx,Gy:e.Gy},r=e.Fp,n=Vt(t.n,e.nBitLength,!0),o={Fp:r,Fn:n,uvRatio:e.uvRatio},i={hash:e.hash,randomBytes:e.randomBytes,adjustScalarBytes:e.adjustScalarBytes,domain:e.domain,prehash:e.prehash,mapToCurve:e.mapToCurve};return{CURVE:t,curveOpts:o,eddsaOpts:i}}function jd(e,t){return Object.assign({},t,{ExtendedPoint:t.Point,CURVE:e})}function uc(e){let{CURVE:t,curveOpts:r,eddsaOpts:n}=zd(e),o=qd(t,r),i=Hd(o,n);return jd(e,i)}var ig=BigInt(0),Gd=BigInt(1),fc=BigInt(2),sg=BigInt(3),Wd=BigInt(5),Zd=BigInt(8),Dn={p:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"),n:BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),h:Zd,a:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),d:BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),Gx:BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),Gy:BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")};function Yd(e){let t=BigInt(10),r=BigInt(20),n=BigInt(40),o=BigInt(80),i=Dn.p,a=e*e%i*e%i,c=Y(a,fc,i)*a%i,l=Y(c,Gd,i)*e%i,u=Y(l,Wd,i)*l%i,f=Y(u,t,i)*u%i,m=Y(f,r,i)*f%i,y=Y(m,n,i)*m%i,B=Y(y,o,i)*y%i,v=Y(B,o,i)*y%i,w=Y(v,t,i)*u%i;return{pow_p_5_8:Y(w,fc,i)*e%i,b2:a}}function Xd(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}var lc=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");function Jd(e,t){let r=Dn.p,n=X(t*t*t,r),o=X(n*n*t,r),i=Yd(e*o).pow_p_5_8,s=X(e*n*i,r),a=X(t*s*s,r),c=s,l=X(s*lc,r),u=a===e,f=a===X(-e,r),m=a===X(-e*lc,r);return u&&(s=c),(f||m)&&(s=l),Qa(s,r)&&(s=X(-s,r)),{isValid:u||f,value:s}}var Qd=Vt(Dn.p,void 0,!0),th={...Dn,Fp:Qd,hash:$a,adjustScalarBytes:Xd,uvRatio:Jd},dc=uc(th);var Vr=class extends Error{constructor(t="An error occurred while verifying a message"){super(t),this.name="VerificationError"}},Nn=class extends Error{constructor(t="Missing Web Crypto API"){super(t),this.name="WebCryptoMissingError"}};var hc={get(e=globalThis){let t=e.crypto;if(t?.subtle==null)throw new Nn("Missing Web Crypto API. The most likely cause of this error is that this page is being accessed from an insecure context (i.e. not HTTPS). For more information and possible resolutions see https://github.com/libp2p/js-libp2p/blob/main/packages/crypto/README.md#web-crypto-api");return t}};var Ot=hc;var Rn=32;var Ii,eh=(async()=>{try{return await Ot.get().subtle.generateKey({name:"Ed25519"},!0,["sign","verify"]),!0}catch{return!1}})();async function rh(e,t,r){if(e.buffer instanceof ArrayBuffer){let n=await Ot.get().subtle.importKey("raw",e.buffer,{name:"Ed25519"},!1,["verify"]);return await Ot.get().subtle.verify({name:"Ed25519"},n,t,r instanceof Uint8Array?r:r.subarray())}throw new TypeError("WebCrypto does not support SharedArrayBuffer for Ed25519 keys")}function nh(e,t,r){return dc.verify(t,r instanceof Uint8Array?r:r.subarray(),e)}async function pc(e,t,r){return Ii==null&&(Ii=await eh),Ii?rh(e,t,r):nh(e,t,r)}function Un(e){return e==null?!1:typeof e.then=="function"&&typeof e.catch=="function"&&typeof e.finally=="function"}var Ln=class{type="Ed25519";raw;constructor(t){this.raw=Ti(t,Rn)}toMultihash(){return It.digest(tr(this))}toCID(){return $.createV1(114,this.toMultihash())}toString(){return j.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=pc(this.raw,r,t);return Un(o)?o.then(i=>(n?.signal?.throwIfAborted(),i)):o}};function Ci(e){return e=Ti(e,Rn),new Ln(e)}function Ti(e,t){if(e=Uint8Array.from(e??[]),e.length!==t)throw new rt(`Key must be a Uint8Array of length ${t}, got ${e.length}`);return e}var ih=Math.pow(2,7),sh=Math.pow(2,14),ah=Math.pow(2,21),Bi=Math.pow(2,28),_i=Math.pow(2,35),Pi=Math.pow(2,42),Di=Math.pow(2,49),J=128,pt=127;function Qt(e){if(e<ih)return 1;if(e<sh)return 2;if(e<ah)return 3;if(e<Bi)return 4;if(e<_i)return 5;if(e<Pi)return 6;if(e<Di)return 7;if(Number.MAX_SAFE_INTEGER!=null&&e>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function $r(e,t,r=0){switch(Qt(e)){case 8:t[r++]=e&255|J,e/=128;case 7:t[r++]=e&255|J,e/=128;case 6:t[r++]=e&255|J,e/=128;case 5:t[r++]=e&255|J,e/=128;case 4:t[r++]=e&255|J,e>>>=7;case 3:t[r++]=e&255|J,e>>>=7;case 2:t[r++]=e&255|J,e>>>=7;case 1:{t[r++]=e&255,e>>>=7;break}default:throw new Error("unreachable")}return t}function Ni(e,t){let r=e[t],n=0;if(n+=r&pt,r<J||(r=e[t+1],n+=(r&pt)<<7,r<J)||(r=e[t+2],n+=(r&pt)<<14,r<J)||(r=e[t+3],n+=(r&pt)<<21,r<J)||(r=e[t+4],n+=(r&pt)*Bi,r<J)||(r=e[t+5],n+=(r&pt)*_i,r<J)||(r=e[t+6],n+=(r&pt)*Pi,r<J)||(r=e[t+7],n+=(r&pt)*Di,r<J))return n;throw new RangeError("Could not decode varint")}function ch(e,t){let r=e.get(t),n=0;if(n+=r&pt,r<J||(r=e.get(t+1),n+=(r&pt)<<7,r<J)||(r=e.get(t+2),n+=(r&pt)<<14,r<J)||(r=e.get(t+3),n+=(r&pt)<<21,r<J)||(r=e.get(t+4),n+=(r&pt)*Bi,r<J)||(r=e.get(t+5),n+=(r&pt)*_i,r<J)||(r=e.get(t+6),n+=(r&pt)*Pi,r<J)||(r=e.get(t+7),n+=(r&pt)*Di,r<J))return n;throw new RangeError("Could not decode varint")}function Ri(e,t=0){return e instanceof Uint8Array?Ni(e,t):ch(e,t)}var Ui=new Float32Array([-0]),Se=new Uint8Array(Ui.buffer);function yc(e,t,r){Ui[0]=e,t[r]=Se[0],t[r+1]=Se[1],t[r+2]=Se[2],t[r+3]=Se[3]}function gc(e,t){return Se[0]=e[t],Se[1]=e[t+1],Se[2]=e[t+2],Se[3]=e[t+3],Ui[0]}var Li=new Float64Array([-0]),mt=new Uint8Array(Li.buffer);function xc(e,t,r){Li[0]=e,t[r]=mt[0],t[r+1]=mt[1],t[r+2]=mt[2],t[r+3]=mt[3],t[r+4]=mt[4],t[r+5]=mt[5],t[r+6]=mt[6],t[r+7]=mt[7]}function wc(e,t){return mt[0]=e[t],mt[1]=e[t+1],mt[2]=e[t+2],mt[3]=e[t+3],mt[4]=e[t+4],mt[5]=e[t+5],mt[6]=e[t+6],mt[7]=e[t+7],Li[0]}var fh=BigInt(Number.MAX_SAFE_INTEGER),lh=BigInt(Number.MIN_SAFE_INTEGER),_t=class e{lo;hi;constructor(t,r){this.lo=t|0,this.hi=r|0}toNumber(t=!1){if(!t&&this.hi>>>31>0){let r=~this.lo+1>>>0,n=~this.hi>>>0;return r===0&&(n=n+1>>>0),-(r+n*4294967296)}return this.lo+this.hi*4294967296}toBigInt(t=!1){if(t)return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31){let r=~this.lo+1>>>0,n=~this.hi>>>0;return r===0&&(n=n+1>>>0),-(BigInt(r)+(BigInt(n)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toString(t=!1){return this.toBigInt(t).toString()}zzEncode(){let t=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^t)>>>0,this.lo=(this.lo<<1^t)>>>0,this}zzDecode(){let t=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^t)>>>0,this.hi=(this.hi>>>1^t)>>>0,this}length(){let t=this.lo,r=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return n===0?r===0?t<16384?t<128?1:2:t<2097152?3:4:r<16384?r<128?5:6:r<2097152?7:8:n<128?9:10}static fromBigInt(t){if(t===0n)return Oe;if(t<fh&&t>lh)return this.fromNumber(Number(t));let r=t<0n;r&&(t=-t);let n=t>>32n,o=t-(n<<32n);return r&&(n=~n|0n,o=~o|0n,++o>bc&&(o=0n,++n>bc&&(n=0n))),new e(Number(o),Number(n))}static fromNumber(t){if(t===0)return Oe;let r=t<0;r&&(t=-t);let n=t>>>0,o=(t-n)/4294967296>>>0;return r&&(o=~o>>>0,n=~n>>>0,++n>4294967295&&(n=0,++o>4294967295&&(o=0))),new e(n,o)}static from(t){return typeof t=="number"?e.fromNumber(t):typeof t=="bigint"?e.fromBigInt(t):typeof t=="string"?e.fromBigInt(BigInt(t)):t.low!=null||t.high!=null?new e(t.low>>>0,t.high>>>0):Oe}},Oe=new _t(0,0);Oe.toBigInt=function(){return 0n};Oe.zzEncode=Oe.zzDecode=function(){return this};Oe.length=function(){return 1};var bc=4294967296n;function Ec(e){let t=0,r=0;for(let n=0;n<e.length;++n)r=e.charCodeAt(n),r<128?t+=1:r<2048?t+=2:(r&64512)===55296&&(e.charCodeAt(n+1)&64512)===56320?(++n,t+=4):t+=3;return t}function Sc(e,t,r){if(r-t<1)return"";let o,i=[],s=0,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 Oi(e,t,r){let n=r,o,i;for(let s=0;s<e.length;++s)o=e.charCodeAt(s),o<128?t[r++]=o:o<2048?(t[r++]=o>>6|192,t[r++]=o&63|128):(o&64512)===55296&&((i=e.charCodeAt(s+1))&64512)===56320?(o=65536+((o&1023)<<10)+(i&1023),++s,t[r++]=o>>18|240,t[r++]=o>>12&63|128,t[r++]=o>>6&63|128,t[r++]=o&63|128):(t[r++]=o>>12|224,t[r++]=o>>6&63|128,t[r++]=o&63|128);return r-n}function $t(e,t){return RangeError(`index out of range: ${e.pos} + ${t??1} > ${e.len}`)}function On(e,t){return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0}var ki=class{buf;pos;len;_slice=Uint8Array.prototype.subarray;constructor(t){this.buf=t,this.pos=0,this.len=t.length}uint32(){let t=4294967295;if(t=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(t=(t|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return t;if((this.pos+=5)>this.len)throw this.pos=this.len,$t(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 $t(this,4);return On(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw $t(this,4);return On(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw $t(this,4);let t=gc(this.buf,this.pos);return this.pos+=4,t}double(){if(this.pos+8>this.len)throw $t(this,4);let t=wc(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 $t(this,t);return this.pos+=t,r===n?new Uint8Array(0):this.buf.subarray(r,n)}string(){let t=this.bytes();return Sc(t,0,t.length)}skip(t){if(typeof t=="number"){if(this.pos+t>this.len)throw $t(this,t);this.pos+=t}else do if(this.pos>=this.len)throw $t(this);while((this.buf[this.pos++]&128)!==0);return this}skipType(t){switch(t){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(t=this.uint32()&7)!==4;)this.skipType(t);break;case 5:this.skip(4);break;default:throw Error(`invalid wire type ${t} at offset ${this.pos}`)}return this}readLongVarint(){let t=new _t(0,0),r=0;if(this.len-this.pos>4){for(;r<4;++r)if(t.lo=(t.lo|(this.buf[this.pos]&127)<<r*7)>>>0,this.buf[this.pos++]<128)return t;if(t.lo=(t.lo|(this.buf[this.pos]&127)<<28)>>>0,t.hi=(t.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return t;r=0}else{for(;r<3;++r){if(this.pos>=this.len)throw $t(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 $t(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 $t(this,8);let t=On(this.buf,this.pos+=4),r=On(this.buf,this.pos+=4);return new _t(t,r)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){let t=Ni(this.buf,this.pos);return this.pos+=Qt(t),t}uint64String(){return this.readLongVarint().toString(!0)}sint64(){return this.readLongVarint().zzDecode().toBigInt()}sint64Number(){return this.readLongVarint().zzDecode().toNumber()}sint64String(){return this.readLongVarint().zzDecode().toString()}fixed64(){return this.readFixed64().toBigInt()}fixed64Number(){return this.readFixed64().toNumber()}fixed64String(){return this.readFixed64().toString()}sfixed64(){return this.readFixed64().toBigInt()}sfixed64Number(){return this.readFixed64().toNumber()}sfixed64String(){return this.readFixed64().toString()}};function Ki(e){return new ki(e instanceof Uint8Array?e:e.subarray())}function fr(e,t,r){let n=Ki(e);return t.decode(n,void 0,r)}function Fi(e){let t=e??8192,r=t>>>1,n,o=t;return function(s){if(s<1||s>r)return Tt(s);o+s>t&&(n=Tt(t),o=0);let a=n.subarray(o,o+=s);return(o&7)!==0&&(o=(o|7)+1),a}}var ke=class{fn;len;next;val;constructor(t,r,n){this.fn=t,this.len=r,this.next=void 0,this.val=n}};function Mi(){}var $i=class{head;tail;len;next;constructor(t){this.head=t.head,this.tail=t.tail,this.len=t.len,this.next=t.states}},dh=Fi();function hh(e){return globalThis.Buffer!=null?Tt(e):dh(e)}var Hr=class{len;head;tail;states;constructor(){this.len=0,this.head=new ke(Mi,0,0),this.tail=this.head,this.states=null}_push(t,r,n){return this.tail=this.tail.next=new ke(t,r,n),this.len+=r,this}uint32(t){return this.len+=(this.tail=this.tail.next=new qi((t=t>>>0)<128?1:t<16384?2:t<2097152?3:t<268435456?4:5,t)).len,this}int32(t){return t<0?this._push(kn,10,_t.fromNumber(t)):this.uint32(t)}sint32(t){return this.uint32((t<<1^t>>31)>>>0)}uint64(t){let r=_t.fromBigInt(t);return this._push(kn,r.length(),r)}uint64Number(t){return this._push($r,Qt(t),t)}uint64String(t){return this.uint64(BigInt(t))}int64(t){return this.uint64(t)}int64Number(t){return this.uint64Number(t)}int64String(t){return this.uint64String(t)}sint64(t){let r=_t.fromBigInt(t).zzEncode();return this._push(kn,r.length(),r)}sint64Number(t){let r=_t.fromNumber(t).zzEncode();return this._push(kn,r.length(),r)}sint64String(t){return this.sint64(BigInt(t))}bool(t){return this._push(Vi,1,t?1:0)}fixed32(t){return this._push(qr,4,t>>>0)}sfixed32(t){return this.fixed32(t)}fixed64(t){let r=_t.fromBigInt(t);return this._push(qr,4,r.lo)._push(qr,4,r.hi)}fixed64Number(t){let r=_t.fromNumber(t);return this._push(qr,4,r.lo)._push(qr,4,r.hi)}fixed64String(t){return this.fixed64(BigInt(t))}sfixed64(t){return this.fixed64(t)}sfixed64Number(t){return this.fixed64Number(t)}sfixed64String(t){return this.fixed64String(t)}float(t){return this._push(yc,4,t)}double(t){return this._push(xc,8,t)}bytes(t){let r=t.length>>>0;return r===0?this._push(Vi,1,0):this.uint32(r)._push(mh,r,t)}string(t){let r=Ec(t);return r!==0?this.uint32(r)._push(Oi,r,t):this._push(Vi,1,0)}fork(){return this.states=new $i(this),this.head=this.tail=new ke(Mi,0,0),this.len=0,this}reset(){return this.states!=null?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new ke(Mi,0,0),this.len=0),this}ldelim(){let t=this.head,r=this.tail,n=this.len;return this.reset().uint32(n),n!==0&&(this.tail.next=t.next,this.tail=r,this.len+=n),this}finish(){let t=this.head.next,r=hh(this.len),n=0;for(;t!=null;)t.fn(t.val,r,n),n+=t.len,t=t.next;return r}};function Vi(e,t,r){t[r]=e&255}function ph(e,t,r){for(;e>127;)t[r++]=e&127|128,e>>>=7;t[r]=e}var qi=class extends ke{next;constructor(t,r){super(ph,t,r),this.next=void 0}};function kn(e,t,r){for(;e.hi!==0;)t[r++]=e.lo&127|128,e.lo=(e.lo>>>7|e.hi<<25)>>>0,e.hi>>>=7;for(;e.lo>127;)t[r++]=e.lo&127|128,e.lo=e.lo>>>7;t[r++]=e.lo}function qr(e,t,r){t[r]=e&255,t[r+1]=e>>>8&255,t[r+2]=e>>>16&255,t[r+3]=e>>>24}function mh(e,t,r){t.set(e,r)}globalThis.Buffer!=null&&(Hr.prototype.bytes=function(e){let t=e.length>>>0;return this.uint32(t),t>0&&this._push(yh,t,e),this},Hr.prototype.string=function(e){let t=globalThis.Buffer.byteLength(e);return this.uint32(t),t>0&&this._push(gh,t,e),this});function yh(e,t,r){t.set(e,r)}function gh(e,t,r){e.length<40?Oi(e,t,r):t.utf8Write!=null?t.utf8Write(e,r):t.set(M(e),r)}function Hi(){return new Hr}function lr(e,t){let r=Hi();return t.encode(e,r,{lengthDelimited:!1}),r.finish()}var dr;(function(e){e[e.VARINT=0]="VARINT",e[e.BIT64=1]="BIT64",e[e.LENGTH_DELIMITED=2]="LENGTH_DELIMITED",e[e.START_GROUP=3]="START_GROUP",e[e.END_GROUP=4]="END_GROUP",e[e.BIT32=5]="BIT32"})(dr||(dr={}));function Kn(e,t,r,n){return{name:e,type:t,encode:r,decode:n}}function zr(e){function t(o){if(e[o.toString()]==null)throw new Error("Invalid enum value");return e[o]}let r=function(i,s){let a=t(i);s.int32(a)},n=function(i){let s=i.int32();return t(s)};return Kn("enum",dr.VARINT,r,n)}function hr(e,t){return Kn("message",dr.LENGTH_DELIMITED,e,t)}var tt;(function(e){e.RSA="RSA",e.Ed25519="Ed25519",e.secp256k1="secp256k1",e.ECDSA="ECDSA"})(tt||(tt={}));var zi;(function(e){e[e.RSA=0]="RSA",e[e.Ed25519=1]="Ed25519",e[e.secp256k1=2]="secp256k1",e[e.ECDSA=3]="ECDSA"})(zi||(zi={}));(function(e){e.codec=()=>zr(zi)})(tt||(tt={}));var te;(function(e){let t;e.codec=()=>(t==null&&(t=hr((r,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),r.Type!=null&&(n.uint32(8),tt.codec().encode(r.Type,n)),r.Data!=null&&(n.uint32(18),n.bytes(r.Data)),o.lengthDelimited!==!1&&n.ldelim()},(r,n,o={})=>{let i={},s=n==null?r.len:r.pos+n;for(;r.pos<s;){let a=r.uint32();switch(a>>>3){case 1:{i.Type=tt.codec().decode(r);break}case 2:{i.Data=r.bytes();break}default:{r.skipType(a&7);break}}}return i})),t),e.encode=r=>lr(r,e.codec()),e.decode=(r,n)=>fr(r,e.codec(),n)})(te||(te={}));var ji;(function(e){let t;e.codec=()=>(t==null&&(t=hr((r,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),r.Type!=null&&(n.uint32(8),tt.codec().encode(r.Type,n)),r.Data!=null&&(n.uint32(18),n.bytes(r.Data)),o.lengthDelimited!==!1&&n.ldelim()},(r,n,o={})=>{let i={},s=n==null?r.len:r.pos+n;for(;r.pos<s;){let a=r.uint32();switch(a>>>3){case 1:{i.Type=tt.codec().decode(r);break}case 2:{i.Data=r.bytes();break}default:{r.skipType(a&7);break}}}return i})),t),e.encode=r=>lr(r,e.codec()),e.decode=(r,n)=>fr(r,e.codec(),n)})(ji||(ji={}));var Gr={};Et(Gr,{MAX_RSA_KEY_SIZE:()=>Gi,generateRSAKeyPair:()=>Bc,jwkToJWKKeyPair:()=>_c,jwkToPkcs1:()=>Eh,jwkToPkix:()=>Xi,jwkToRSAPrivateKey:()=>es,pkcs1MessageToJwk:()=>Zi,pkcs1MessageToRSAPrivateKey:()=>Ji,pkcs1ToJwk:()=>bh,pkcs1ToRSAPrivateKey:()=>Cc,pkixMessageToJwk:()=>Yi,pkixMessageToRSAPublicKey:()=>ts,pkixToJwk:()=>Sh,pkixToRSAPublicKey:()=>Qi});var Fn=In;var pr=class{type="RSA";jwk;_raw;_multihash;constructor(t,r){this.jwk=t,this._multihash=r}get raw(){return this._raw==null&&(this._raw=Gr.jwkToPkix(this.jwk)),this._raw}toMultihash(){return this._multihash}toCID(){return $.createV1(114,this._multihash)}toString(){return j.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 Tc(this.jwk,r,t,n)}},jr=class{type="RSA";jwk;_raw;publicKey;constructor(t,r){this.jwk=t,this.publicKey=r}get raw(){return this._raw==null&&(this._raw=Gr.jwkToPkcs1(this.jwk)),this._raw}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:W(this.raw,t.raw)}sign(t,r){return Ic(this.jwk,t,r)}};var Gi=8192,Wi=18,xh=1062,wh=Uint8Array.from([48,13,6,9,42,134,72,134,247,13,1,1,1,5,0]);function bh(e){let t=ie(e);return Zi(t)}function Zi(e){return{n:V(e[1],"base64url"),e:V(e[2],"base64url"),d:V(e[3],"base64url"),p:V(e[4],"base64url"),q:V(e[5],"base64url"),dp:V(e[6],"base64url"),dq:V(e[7],"base64url"),qi:V(e[8],"base64url"),kty:"RSA"}}function Eh(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 rt("JWK was missing components");return ye([At(Uint8Array.from([0])),At(M(e.n,"base64url")),At(M(e.e,"base64url")),At(M(e.d,"base64url")),At(M(e.p,"base64url")),At(M(e.q,"base64url")),At(M(e.dp,"base64url")),At(M(e.dq,"base64url")),At(M(e.qi,"base64url"))]).subarray()}function Sh(e){let t=ie(e,{offset:0});return Yi(t)}function Yi(e){let t=ie(e[1],{offset:0});return{kty:"RSA",n:V(t[0],"base64url"),e:V(t[1],"base64url")}}function Xi(e){if(e.n==null||e.e==null)throw new rt("JWK was missing components");return ye([wh,En(ye([At(M(e.n,"base64url")),At(M(e.e,"base64url"))]))]).subarray()}function Cc(e){let t=ie(e);return Ji(t)}function Ji(e){let t=Zi(e);return es(t)}function Qi(e,t){if(e.byteLength>=xh)throw new He("Key size is too large");let r=ie(e,{offset:0});return ts(r,e,t)}function ts(e,t,r){let n=Yi(e);if(r==null){let o=Fn(te.encode({Type:tt.RSA,Data:t}));r=Ft(Wi,o)}return new pr(n,r)}function es(e){if(Dc(e)>Gi)throw new rt("Key size is too large");let t=_c(e),r=Fn(te.encode({Type:tt.RSA,Data:Xi(t.publicKey)})),n=Ft(Wi,r);return new jr(t.privateKey,new pr(t.publicKey,n))}async function Bc(e){if(e>Gi)throw new rt("Key size is too large");let t=await Pc(e),r=Fn(te.encode({Type:tt.RSA,Data:Xi(t.publicKey)})),n=Ft(Wi,r);return new jr(t.privateKey,new pr(t.publicKey,n))}function _c(e){if(e==null)throw new rt("Missing key parameter");return{privateKey:e,publicKey:{kty:e.kty,n:e.n,e:e.e}}}async function Pc(e,t){let r=await Ot.get().subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:e,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-256"}},!0,["sign","verify"]);t?.signal?.throwIfAborted();let n=await vh(r,t);return{privateKey:n[0],publicKey:n[1]}}async function Ic(e,t,r){let n=await Ot.get().subtle.importKey("jwk",e,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["sign"]);r?.signal?.throwIfAborted();let o=await Ot.get().subtle.sign({name:"RSASSA-PKCS1-v1_5"},n,t instanceof Uint8Array?t:t.subarray());return r?.signal?.throwIfAborted(),new Uint8Array(o,0,o.byteLength)}async function Tc(e,t,r,n){let o=await Ot.get().subtle.importKey("jwk",e,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["verify"]);n?.signal?.throwIfAborted();let i=await Ot.get().subtle.verify({name:"RSASSA-PKCS1-v1_5"},o,t,r instanceof Uint8Array?r:r.subarray());return n?.signal?.throwIfAborted(),i}async function vh(e,t){if(e.privateKey==null||e.publicKey==null)throw new rt("Private and public key are required");let r=await Promise.all([Ot.get().subtle.exportKey("jwk",e.privateKey),Ot.get().subtle.exportKey("jwk",e.publicKey)]);return t?.signal?.throwIfAborted(),r}function Dc(e){if(e.kty!=="RSA")throw new rt("invalid key type");if(e.n==null)throw new rt("invalid key modulus");return M(e.n,"base64url").length*8}var Mn=class extends er{constructor(t,r){super(),this.finished=!1,this.destroyed=!1,Ca(t);let n=Ur(r);if(this.iHash=t.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let o=this.blockLen,i=new Uint8Array(o);i.set(n.length>o?t.create().update(n).digest():n);for(let s=0;s<i.length;s++)i[s]^=54;this.iHash.update(i),this.oHash=t.create();for(let s=0;s<i.length;s++)i[s]^=106;this.oHash.update(i),ae(i)}update(t){return nr(this),this.iHash.update(t),this}digestInto(t){nr(this),ht(t,this.outputLen),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){let t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));let{oHash:r,iHash:n,finished:o,destroyed:i,blockLen:s,outputLen:a}=this;return t=t,t.finished=o,t.destroyed=i,t.blockLen=s,t.outputLen=a,t.oHash=r._cloneInto(t.oHash),t.iHash=n._cloneInto(t.iHash),t}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},rs=(e,t,r)=>new Mn(e,t).update(r).digest();rs.create=(e,t)=>new Mn(e,t);function Nc(e){e.lowS!==void 0&&ue("lowS",e.lowS),e.prehash!==void 0&&ue("prehash",e.prehash)}var ns=class extends Error{constructor(t=""){super(t)}},fe={Err:ns,_tlv:{encode:(e,t)=>{let{Err:r}=fe;if(e<0||e>256)throw new r("tlv.encode: wrong tag");if(t.length&1)throw new r("tlv.encode: unpadded data");let n=t.length/2,o=Fr(n);if(o.length/2&128)throw new r("tlv.encode: long form length too big");let i=n>127?Fr(o.length/2|128):"";return Fr(e)+i+o+t},decode(e,t){let{Err:r}=fe,n=0;if(e<0||e>256)throw new r("tlv.encode: wrong tag");if(t.length<2||t[n++]!==e)throw new r("tlv.decode: wrong tlv");let o=t[n++],i=!!(o&128),s=0;if(!i)s=o;else{let c=o&127;if(!c)throw new r("tlv.decode(long): indefinite length not supported");if(c>4)throw new r("tlv.decode(long): byte length is too big");let l=t.subarray(n,n+c);if(l.length!==c)throw new r("tlv.decode: length bytes not complete");if(l[0]===0)throw new r("tlv.decode(long): zero leftmost byte");for(let u of l)s=s<<8|u;if(n+=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}=fe;if(e<Wr)throw new t("integer: negative integers are not allowed");let r=Fr(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}=fe;if(e[0]&128)throw new t("invalid signature integer: negative");if(e[0]===0&&!(e[1]&128))throw new t("invalid signature integer: unnecessary leading zero");return ir(e)}},toSig(e){let{Err:t,_int:r,_tlv:n}=fe,o=Z("signature",e),{v:i,l:s}=n.decode(48,o);if(s.length)throw new t("invalid signature: left bytes after parsing");let{v:a,l:c}=n.decode(2,i),{v:l,l:u}=n.decode(2,c);if(u.length)throw new t("invalid signature: left bytes after parsing");return{r:r.decode(a),s:r.decode(l)}},hexFromSig(e){let{_tlv:t,_int:r}=fe,n=t.encode(2,r.encode(e.r)),o=t.encode(2,r.encode(e.s)),i=n+o;return t.encode(48,i)}},Wr=BigInt(0),Zr=BigInt(1),Ah=BigInt(2),Vn=BigInt(3),Ih=BigInt(4);function Th(e,t,r){function n(o){let i=e.sqr(o),s=e.mul(i,o);return e.add(e.add(s,e.mul(o,t)),r)}return n}function Rc(e,t,r){let{BYTES:n}=e;function o(i){let s;if(typeof i=="bigint")s=i;else{let a=Z("private key",i);if(t){if(!t.includes(a.length*2))throw new Error("invalid private key");let c=new Uint8Array(n);c.set(a,c.length-a.length),a=c}try{s=e.fromBytes(a)}catch{throw new Error(`invalid private key: expected ui8a of size ${n}, got ${typeof i}`)}}if(r&&(s=e.create(s)),!e.isValidNot0(s))throw new Error("invalid private key: out of range [1..N-1]");return s}return o}function Ch(e,t={}){let{Fp:r,Fn:n}=Pn("weierstrass",e,t),{h:o,n:i}=e;Ee(t,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object",wrapPrivateKey:"boolean"});let{endo:s}=t;if(s&&(!r.is0(e.a)||typeof s.beta!="bigint"||typeof s.splitScalar!="function"))throw new Error('invalid endo: expected "beta": bigint and "splitScalar": function');function a(){if(!r.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}function c(g,d,x){let{x:h,y:p}=d.toAffine(),S=r.toBytes(h);if(ue("isCompressed",x),x){a();let I=!r.isOdd(p);return Bt(Uc(I),S)}else return Bt(Uint8Array.of(4),S,r.toBytes(p))}function l(g){ht(g);let d=r.BYTES,x=d+1,h=2*d+1,p=g.length,S=g[0],I=g.subarray(1);if(p===x&&(S===2||S===3)){let A=r.fromBytes(I);if(!r.isValid(A))throw new Error("bad point: is not on curve, wrong x");let T=m(A),O;try{O=r.sqrt(T)}catch(H){let F=H instanceof Error?": "+H.message:"";throw new Error("bad point: is not on curve, sqrt error"+F)}a();let L=r.isOdd(O);return(S&1)===1!==L&&(O=r.neg(O)),{x:A,y:O}}else if(p===h&&S===4){let A=r.fromBytes(I.subarray(d*0,d*1)),T=r.fromBytes(I.subarray(d*1,d*2));if(!y(A,T))throw new Error("bad point: is not on curve");return{x:A,y:T}}else throw new Error(`bad point: got length ${p}, expected compressed=${x} or uncompressed=${h}`)}let u=t.toBytes||c,f=t.fromBytes||l,m=Th(r,e.a,e.b);function y(g,d){let x=r.sqr(d),h=m(g);return r.eql(x,h)}if(!y(e.Gx,e.Gy))throw new Error("bad curve params: generator point");let B=r.mul(r.pow(e.a,Vn),Ih),v=r.mul(r.sqr(e.b),BigInt(27));if(r.is0(r.add(B,v)))throw new Error("bad curve params: a or b");function w(g,d,x=!1){if(!r.isValid(d)||x&&r.is0(d))throw new Error(`bad point coordinate ${g}`);return d}function C(g){if(!(g instanceof E))throw new Error("ProjectivePoint expected")}let D=ar((g,d)=>{let{px:x,py:h,pz:p}=g;if(r.eql(p,r.ONE))return{x,y:h};let S=g.is0();d==null&&(d=S?r.ONE:r.inv(p));let I=r.mul(x,d),A=r.mul(h,d),T=r.mul(p,d);if(S)return{x:r.ZERO,y:r.ZERO};if(!r.eql(T,r.ONE))throw new Error("invZ was invalid");return{x:I,y:A}}),P=ar(g=>{if(g.is0()){if(t.allowInfinityPoint&&!r.is0(g.py))return;throw new Error("bad point: ZERO")}let{x:d,y:x}=g.toAffine();if(!r.isValid(d)||!r.isValid(x))throw new Error("bad point: x or y not field elements");if(!y(d,x))throw new Error("bad point: equation left != right");if(!g.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});function k(g,d,x,h,p){return x=new E(r.mul(x.px,g),x.py,x.pz),d=cr(h,d),x=cr(p,x),d.add(x)}class E{constructor(d,x,h){this.px=w("x",d),this.py=w("y",x,!0),this.pz=w("z",h),Object.freeze(this)}static fromAffine(d){let{x,y:h}=d||{};if(!d||!r.isValid(x)||!r.isValid(h))throw new Error("invalid affine point");if(d instanceof E)throw new Error("projective point not allowed");return r.is0(x)&&r.is0(h)?E.ZERO:new E(x,h,r.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(d){return Cn(E,"pz",d)}static fromBytes(d){return ht(d),E.fromHex(d)}static fromHex(d){let x=E.fromAffine(f(Z("pointHex",d)));return x.assertValidity(),x}static fromPrivateKey(d){let x=Rc(n,t.allowedPrivateKeyLengths,t.wrapPrivateKey);return E.BASE.multiply(x(d))}static msm(d,x){return _n(E,n,d,x)}precompute(d=8,x=!0){return R.setWindowSize(this,d),x||this.multiply(Vn),this}_setWindowSize(d){this.precompute(d)}assertValidity(){P(this)}hasEvenY(){let{y:d}=this.toAffine();if(!r.isOdd)throw new Error("Field doesn't support isOdd");return!r.isOdd(d)}equals(d){C(d);let{px:x,py:h,pz:p}=this,{px:S,py:I,pz:A}=d,T=r.eql(r.mul(x,A),r.mul(S,p)),O=r.eql(r.mul(h,A),r.mul(I,p));return T&&O}negate(){return new E(this.px,r.neg(this.py),this.pz)}double(){let{a:d,b:x}=e,h=r.mul(x,Vn),{px:p,py:S,pz:I}=this,A=r.ZERO,T=r.ZERO,O=r.ZERO,L=r.mul(p,p),z=r.mul(S,S),H=r.mul(I,I),F=r.mul(p,S);return F=r.add(F,F),O=r.mul(p,I),O=r.add(O,O),A=r.mul(d,O),T=r.mul(h,H),T=r.add(A,T),A=r.sub(z,T),T=r.add(z,T),T=r.mul(A,T),A=r.mul(F,A),O=r.mul(h,O),H=r.mul(d,H),F=r.sub(L,H),F=r.mul(d,F),F=r.add(F,O),O=r.add(L,L),L=r.add(O,L),L=r.add(L,H),L=r.mul(L,F),T=r.add(T,L),H=r.mul(S,I),H=r.add(H,H),L=r.mul(H,F),A=r.sub(A,L),O=r.mul(H,z),O=r.add(O,O),O=r.add(O,O),new E(A,T,O)}add(d){C(d);let{px:x,py:h,pz:p}=this,{px:S,py:I,pz:A}=d,T=r.ZERO,O=r.ZERO,L=r.ZERO,z=e.a,H=r.mul(e.b,Vn),F=r.mul(x,S),et=r.mul(h,I),ot=r.mul(p,A),dt=r.add(x,h),G=r.add(S,I);dt=r.mul(dt,G),G=r.add(F,et),dt=r.sub(dt,G),G=r.add(x,p);let gt=r.add(S,A);return G=r.mul(G,gt),gt=r.add(F,ot),G=r.sub(G,gt),gt=r.add(h,p),T=r.add(I,A),gt=r.mul(gt,T),T=r.add(et,ot),gt=r.sub(gt,T),L=r.mul(z,G),T=r.mul(H,ot),L=r.add(T,L),T=r.sub(et,L),L=r.add(et,L),O=r.mul(T,L),et=r.add(F,F),et=r.add(et,F),ot=r.mul(z,ot),G=r.mul(H,G),et=r.add(et,ot),ot=r.sub(F,ot),ot=r.mul(z,ot),G=r.add(G,ot),F=r.mul(et,G),O=r.add(O,F),F=r.mul(gt,G),T=r.mul(dt,T),T=r.sub(T,F),F=r.mul(dt,et),L=r.mul(gt,L),L=r.add(L,F),new E(T,O,L)}subtract(d){return this.add(d.negate())}is0(){return this.equals(E.ZERO)}multiply(d){let{endo:x}=t;if(!n.isValidNot0(d))throw new Error("invalid scalar: out of range");let h,p,S=I=>R.wNAFCached(this,I,E.normalizeZ);if(x){let{k1neg:I,k1:A,k2neg:T,k2:O}=x.splitScalar(d),{p:L,f:z}=S(A),{p:H,f:F}=S(O);p=z.add(F),h=k(x.beta,L,H,I,T)}else{let{p:I,f:A}=S(d);h=I,p=A}return E.normalizeZ([h,p])[0]}multiplyUnsafe(d){let{endo:x}=t,h=this;if(!n.isValid(d))throw new Error("invalid scalar: out of range");if(d===Wr||h.is0())return E.ZERO;if(d===Zr)return h;if(R.hasPrecomputes(this))return this.multiply(d);if(x){let{k1neg:p,k1:S,k2neg:I,k2:A}=x.splitScalar(d),{p1:T,p2:O}=cc(E,h,S,A);return k(x.beta,T,O,p,I)}else return R.wNAFCachedUnsafe(h,d)}multiplyAndAddUnsafe(d,x,h){let p=this.multiplyUnsafe(x).add(d.multiplyUnsafe(h));return p.is0()?void 0:p}toAffine(d){return D(this,d)}isTorsionFree(){let{isTorsionFree:d}=t;return o===Zr?!0:d?d(E,this):R.wNAFCachedUnsafe(this,i).is0()}clearCofactor(){let{clearCofactor:d}=t;return o===Zr?this:d?d(E,this):this.multiplyUnsafe(o)}toBytes(d=!0){return ue("isCompressed",d),this.assertValidity(),u(E,this,d)}toRawBytes(d=!0){return this.toBytes(d)}toHex(d=!0){return Yt(this.toBytes(d))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}E.BASE=new E(e.Gx,e.Gy,r.ONE),E.ZERO=new E(r.ZERO,r.ONE,r.ZERO),E.Fp=r,E.Fn=n;let N=n.BITS,R=Bn(E,t.endo?Math.ceil(N/2):N);return E}function Uc(e){return Uint8Array.of(e?2:3)}function Bh(e,t,r={}){Ee(t,{hash:"function"},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"});let n=t.randomBytes||Lr,o=t.hmac||((h,...p)=>rs(t.hash,h,Bt(...p))),{Fp:i,Fn:s}=e,{ORDER:a,BITS:c}=s;function l(h){let p=a>>Zr;return h>p}function u(h){return l(h)?s.neg(h):h}function f(h,p){if(!s.isValidNot0(p))throw new Error(`invalid signature ${h}: out of range 1..CURVE.n`)}class m{constructor(p,S,I){f("r",p),f("s",S),this.r=p,this.s=S,I!=null&&(this.recovery=I),Object.freeze(this)}static fromCompact(p){let S=s.BYTES,I=Z("compactSignature",p,S*2);return new m(s.fromBytes(I.subarray(0,S)),s.fromBytes(I.subarray(S,S*2)))}static fromDER(p){let{r:S,s:I}=fe.toSig(Z("DER",p));return new m(S,I)}assertValidity(){}addRecoveryBit(p){return new m(this.r,this.s,p)}recoverPublicKey(p){let S=i.ORDER,{r:I,s:A,recovery:T}=this;if(T==null||![0,1,2,3].includes(T))throw new Error("recovery id invalid");if(a*Ah<S&&T>1)throw new Error("recovery id is ambiguous for h>1 curve");let L=T===2||T===3?I+a:I;if(!i.isValid(L))throw new Error("recovery id 2 or 3 invalid");let z=i.toBytes(L),H=e.fromHex(Bt(Uc((T&1)===0),z)),F=s.inv(L),et=P(Z("msgHash",p)),ot=s.create(-et*F),dt=s.create(A*F),G=e.BASE.multiplyUnsafe(ot).add(H.multiplyUnsafe(dt));if(G.is0())throw new Error("point at infinify");return G.assertValidity(),G}hasHighS(){return l(this.s)}normalizeS(){return this.hasHighS()?new m(this.r,s.neg(this.s),this.recovery):this}toBytes(p){if(p==="compact")return Bt(s.toBytes(this.r),s.toBytes(this.s));if(p==="der")return or(fe.hexFromSig(this));throw new Error("invalid format")}toDERRawBytes(){return this.toBytes("der")}toDERHex(){return Yt(this.toBytes("der"))}toCompactRawBytes(){return this.toBytes("compact")}toCompactHex(){return Yt(this.toBytes("compact"))}}let y=Rc(s,r.allowedPrivateKeyLengths,r.wrapPrivateKey),B={isValidPrivateKey(h){try{return y(h),!0}catch{return!1}},normPrivateKeyToScalar:y,randomPrivateKey:()=>{let h=a;return rc(n(bi(h)),h)},precompute(h=8,p=e.BASE){return p.precompute(h,!1)}};function v(h,p=!0){return e.fromPrivateKey(h).toBytes(p)}function w(h){if(typeof h=="bigint")return!1;if(h instanceof e)return!0;let S=Z("key",h).length,I=i.BYTES,A=I+1,T=2*I+1;if(!(r.allowedPrivateKeyLengths||s.BYTES===A))return S===A||S===T}function C(h,p,S=!0){if(w(h)===!0)throw new Error("first arg must be private key");if(w(p)===!1)throw new Error("second arg must be public key");return e.fromHex(p).multiply(y(h)).toBytes(S)}let D=t.bits2int||function(h){if(h.length>8192)throw new Error("input is too large");let p=ir(h),S=h.length*8-c;return S>0?p>>BigInt(S):p},P=t.bits2int_modN||function(h){return s.create(D(h))},k=Re(c);function E(h){return be("num < 2^"+c,h,Wr,k),s.toBytes(h)}function N(h,p,S=R){if(["recovered","canonical"].some(dt=>dt in S))throw new Error("sign() legacy options not supported");let{hash:I}=t,{lowS:A,prehash:T,extraEntropy:O}=S;A==null&&(A=!0),h=Z("msgHash",h),Nc(S),T&&(h=Z("prehashed msgHash",I(h)));let L=P(h),z=y(p),H=[E(z),E(L)];if(O!=null&&O!==!1){let dt=O===!0?n(i.BYTES):O;H.push(Z("extraEntropy",dt))}let F=Bt(...H),et=L;function ot(dt){let G=D(dt);if(!s.isValidNot0(G))return;let gt=s.inv(G),Ir=e.BASE.multiply(G).toAffine(),$e=s.create(Ir.x);if($e===Wr)return;let Te=s.create(gt*s.create(et+$e*z));if(Te===Wr)return;let Ro=(Ir.x===$e?0:2)|Number(Ir.y&Zr),qe=Te;return A&&l(Te)&&(qe=u(Te),Ro^=1),new m($e,qe,Ro)}return{seed:F,k2sig:ot}}let R={lowS:t.lowS,prehash:!1},g={lowS:t.lowS,prehash:!1};function d(h,p,S=R){let{seed:I,k2sig:A}=N(h,p,S);return ja(t.hash.outputLen,s.BYTES,o)(I,A)}e.BASE.precompute(8);function x(h,p,S,I=g){let A=h;p=Z("msgHash",p),S=Z("publicKey",S),Nc(I);let{lowS:T,prehash:O,format:L}=I;if("strict"in I)throw new Error("options.strict was renamed to lowS");if(L!==void 0&&!["compact","der","js"].includes(L))throw new Error('format must be "compact", "der" or "js"');let z=typeof A=="string"||rr(A),H=!z&&!L&&typeof A=="object"&&A!==null&&typeof A.r=="bigint"&&typeof A.s=="bigint";if(!z&&!H)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let F,et;try{if(H)if(L===void 0||L==="js")F=new m(A.r,A.s);else throw new Error("invalid format");if(z){try{L!=="compact"&&(F=m.fromDER(A))}catch(qe){if(!(qe instanceof fe.Err))throw qe}!F&&L!=="der"&&(F=m.fromCompact(A))}et=e.fromHex(S)}catch{return!1}if(!F||T&&F.hasHighS())return!1;O&&(p=t.hash(p));let{r:ot,s:dt}=F,G=P(p),gt=s.inv(dt),Ir=s.create(G*gt),$e=s.create(ot*gt),Te=e.BASE.multiplyUnsafe(Ir).add(et.multiplyUnsafe($e));return Te.is0()?!1:s.create(Te.x)===ot}return Object.freeze({getPublicKey:v,getSharedSecret:C,sign:d,verify:x,utils:B,Point:e,Signature:m})}function _h(e){let t={a:e.a,b:e.b,p:e.Fp.ORDER,n:e.n,h:e.h,Gx:e.Gx,Gy:e.Gy},r=e.Fp,n=Vt(t.n,e.nBitLength),o={Fp:r,Fn:n,allowedPrivateKeyLengths:e.allowedPrivateKeyLengths,allowInfinityPoint:e.allowInfinityPoint,endo:e.endo,wrapPrivateKey:e.wrapPrivateKey,isTorsionFree:e.isTorsionFree,clearCofactor:e.clearCofactor,fromBytes:e.fromBytes,toBytes:e.toBytes};return{CURVE:t,curveOpts:o}}function Ph(e){let{CURVE:t,curveOpts:r}=_h(e),n={hash:e.hash,hmac:e.hmac,randomBytes:e.randomBytes,lowS:e.lowS,bits2int:e.bits2int,bits2int_modN:e.bits2int_modN};return{CURVE:t,curveOpts:r,ecdsaOpts:n}}function Dh(e,t){return Object.assign({},t,{ProjectivePoint:t.Point,CURVE:e})}function Lc(e){let{CURVE:t,curveOpts:r,ecdsaOpts:n}=Ph(e),o=Ch(t,r),i=Bh(o,n,r);return Dh(e,i)}function Oc(e,t){let r=n=>Lc({...e,hash:n});return{...r(t),create:r}}var $n={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},jx=BigInt(0),Nh=BigInt(1),os=BigInt(2),kc=(e,t)=>(e+t/os)/t;function Rh(e){let t=$n.p,r=BigInt(3),n=BigInt(6),o=BigInt(11),i=BigInt(22),s=BigInt(23),a=BigInt(44),c=BigInt(88),l=e*e*e%t,u=l*l*e%t,f=Y(u,r,t)*u%t,m=Y(f,r,t)*u%t,y=Y(m,os,t)*l%t,B=Y(y,o,t)*y%t,v=Y(B,i,t)*B%t,w=Y(v,a,t)*v%t,C=Y(w,c,t)*w%t,D=Y(C,a,t)*v%t,P=Y(D,r,t)*u%t,k=Y(P,s,t)*B%t,E=Y(k,n,t)*l%t,N=Y(E,os,t);if(!is.eql(is.sqr(N),e))throw new Error("Cannot find square root");return N}var is=Vt($n.p,void 0,void 0,{sqrt:Rh}),mr=Oc({...$n,Fp:is,lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:e=>{let t=$n.n,r=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-Nh*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),i=r,s=BigInt("0x100000000000000000000000000000000"),a=kc(i*e,t),c=kc(-n*e,t),l=X(e-a*r-c*o,t),u=X(-a*n-c*i,t),f=l>s,m=u>s;if(f&&(l=t-l),m&&(u=t-u),l>s||u>s)throw new Error("splitScalar: Endomorphism failed, k="+e);return{k1neg:f,k1:l,k2neg:m,k2:u}}}},In);function Kc(e,t,r,n){let o=_r.digest(r instanceof Uint8Array?r:r.subarray());if(Un(o))return o.then(({digest:i})=>(n?.signal?.throwIfAborted(),mr.verify(t,i,e))).catch(i=>{throw i.name==="AbortError"?i:new Vr(String(i))});try{return n?.signal?.throwIfAborted(),mr.verify(t,o.digest,e)}catch(i){throw new Vr(String(i))}}var qn=class{type="secp256k1";raw;_key;constructor(t){this._key=Mc(t),this.raw=Fc(this._key)}toMultihash(){return It.digest(tr(this))}toCID(){return $.createV1(114,this.toMultihash())}toString(){return j.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 Kc(this._key,r,t,n)}};function ss(e){return new qn(e)}function Fc(e){return mr.ProjectivePoint.fromHex(e).toRawBytes(!0)}function Mc(e){try{return mr.ProjectivePoint.fromHex(e),e}catch(t){throw new He(String(t))}}function Vc(e,t){let{Type:r,Data:n}=te.decode(e),o=n??new Uint8Array;switch(r){case tt.RSA:return Qi(o,t);case tt.Ed25519:return Ci(o);case tt.secp256k1:return ss(o);case tt.ECDSA:return li(o);default:throw new je}}function Hn(e){let{Type:t,Data:r}=te.decode(e.digest),n=r??new Uint8Array;switch(t){case tt.Ed25519:return Ci(n);case tt.secp256k1:return ss(n);case tt.ECDSA:return li(n);default:throw new je}}function tr(e){return te.encode({Type:tt[e.type],Data:e.raw})}var $c=Symbol.for("nodejs.util.inspect.custom"),Uh=114,Yr=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()})`}[Lo]=!0;toString(){return this.string==null&&(this.string=j.encode(this.multihash.bytes).slice(1)),this.string}toMultihash(){return this.multihash}toCID(){return $.createV1(Uh,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")}[$c](){return`PeerId(${this.toString()})`}},zn=class extends Yr{type="RSA";publicKey;constructor(t){super({...t,type:"RSA"}),this.publicKey=t.publicKey}},jn=class extends Yr{type="Ed25519";publicKey;constructor(t){super({...t,type:"Ed25519"}),this.publicKey=t.publicKey}},Gn=class extends Yr{type="secp256k1";publicKey;constructor(t){super({...t,type:"secp256k1"}),this.publicKey=t.publicKey}},Lh=2336,Xr=class{type="url";multihash;publicKey;url;constructor(t){this.url=t.toString(),this.multihash=It.digest(M(this.url))}[$c](){return`PeerId(${this.url})`}[Lo]=!0;toString(){return this.toCID().toString()}toMultihash(){return this.multihash}toCID(){return $.createV1(Lh,this.toMultihash())}toJSON(){return this.toString()}equals(t){return t==null?!1:(t instanceof Uint8Array&&(t=V(t)),t.toString()===this.toString())}};var Oh=114,qc=2336;function Hc(e,t){let r;if(e.charAt(0)==="1"||e.charAt(0)==="Q")r=Ce(j.decode(`z${e}`));else{if(e.startsWith("k51qzi5uqu5")||e.startsWith("kzwfwjn5ji4")||e.startsWith("k2k4r8")||e.startsWith("bafz"))return as($.parse(e));if(t==null)throw new rt('Please pass a multibase decoder for strings that do not start with "1" or "Q"');r=Ce(t.decode(e))}return zc(r)}function zc(e){if(Kh(e))return new zn({multihash:e});if(kh(e))try{let t=Hn(e);if(t.type==="Ed25519")return new jn({multihash:e,publicKey:t});if(t.type==="secp256k1")return new Gn({multihash:e,publicKey:t})}catch{let r=V(e.digest);return new Xr(new URL(r))}throw new ze("Supplied PeerID Multihash is invalid")}function as(e){if(e?.multihash==null||e.version==null||e.version===1&&e.code!==Oh&&e.code!==qc)throw new mn("Supplied PeerID CID is invalid");if(e.code===qc){let t=V(e.multihash.digest);return new Xr(new URL(t))}return zc(e.multihash)}function kh(e){return e.code===It.code}function Kh(e){return e.code===_r.code}var ut=class extends Error{static name="InvalidMultiaddrError";name="InvalidMultiaddrError"},le=class extends Error{static name="ValidationError";name="ValidationError"},Jr=class extends Error{static name="InvalidParametersError";name="InvalidParametersError"},Wn=class extends Error{static name="UnknownProtocolError";name="UnknownProtocolError"};var Zn=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",l=2**(8*o)-1;for(;;){let u=this.readAtomically(()=>{let f=this.readChar();if(f===void 0)return;let m=Number.parseInt(f,t);if(!Number.isNaN(m))return m});if(u===void 0)break;if(i*=t,i+=u,i>l||(s+=1,r!==void 0&&s>r))return}if(s!==0)return!n&&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 Fh=45,Mh=15,Yn=new Zn;function cs(e){if(!(e.length>Mh))return Yn.new(e).parseWith(()=>Yn.readIPv4Addr())}function us(e){if(e.includes("%")&&(e=e.split("%")[0]),!(e.length>Fh))return Yn.new(e).parseWith(()=>Yn.readIPv6Addr())}function Xn(e){return!!cs(e)}function Gc(e){return!!us(e)}function ls(e){return t=>V(t,e)}function ds(e){return t=>M(t,e)}function yr(e){return new DataView(e.buffer).getUint16(e.byteOffset).toString()}function Ke(e){let t=new ArrayBuffer(2);return new DataView(t).setUint16(0,typeof e=="string"?parseInt(e):e),new Uint8Array(t)}function Wc(e){let t=e.split(":");if(t.length!==2)throw new Error(`failed to parse onion addr: ["'${t.join('", "')}'"]' does not contain a port number`);if(t[0].length!==16)throw new Error(`failed to parse onion addr: ${t[0]} not a Tor onion address.`);let r=M(t[0],"base32"),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=Ke(n);return Lt([r,o],r.length+o.length)}function Zc(e){let t=e.split(":");if(t.length!==2)throw new Error(`failed to parse onion addr: ["'${t.join('", "')}'"]' does not contain a port number`);if(t[0].length!==56)throw new Error(`failed to parse onion addr: ${t[0]} not a Tor onion3 address.`);let r=Zt.decode(`b${t[0]}`),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=Ke(n);return Lt([r,o],r.length+o.length)}function hs(e){let t=e.subarray(0,e.length-2),r=e.subarray(e.length-2),n=V(t,"base32"),o=yr(r);return`${n}:${o}`}var ps=function(e){e=e.toString().trim();let t=new Uint8Array(4);return e.split(/\./g).forEach((r,n)=>{let o=parseInt(r,10);if(isNaN(o)||o<0||o>255)throw new ut("Invalid byte value in IP address");t[n]=o}),t},Yc=function(e){let t=0;e=e.toString().trim();let r=e.split(":",8),n;for(n=0;n<r.length;n++){let i=Xn(r[n]),s;i&&(s=ps(r[n]),r[n]=V(s.subarray(0,2),"base16")),s!=null&&++n<8&&r.splice(n,0,V(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 ut("Invalid byte value in IP address");o[t++]=i>>8&255,o[t++]=i&255}return o},Xc=function(e){if(e.byteLength!==4)throw new ut("IPv4 address was incorrect length");let t=[];for(let r=0;r<e.byteLength;r++)t.push(e[r]);return t.join(".")},Jc=function(e){if(e.byteLength!==16)throw new ut("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 ut(`Invalid IPv6 address "${r}"`)}};function Qc(e){try{let t=new URL(`http://[${e}]`);return t.hostname.substring(1,t.hostname.length-1)}catch{throw new ut(`Invalid IPv6 address "${e}"`)}}var fs=Object.values(Pr).map(e=>e.decoder),Vh=function(){let e=fs[0].or(fs[1]);return fs.slice(2).forEach(t=>e=e.or(t)),e}();function tu(e){return Vh.decode(e)}function eu(e){return t=>e.encoder.encode(t)}function $h(e){if(parseInt(e).toString()!==e)throw new le("Value must be an integer")}function qh(e){if(e<0)throw new le("Value must be a positive integer, or zero")}function Hh(e){return t=>{if(t>e)throw new le(`Value must be smaller than or equal to ${e}`)}}function zh(...e){return t=>{for(let r of e)r(t)}}var Qr=zh($h,qh,Hh(65535));var st=-1,ms=class{protocolsByCode=new Map;protocolsByName=new Map;getProtocol(t){let r;if(typeof t=="string"?r=this.protocolsByName.get(t):r=this.protocolsByCode.get(t),r==null)throw new Wn(`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)}))}},Pt=new ms,Ep=[{code:4,name:"ip4",size:32,valueToBytes:ps,bytesToValue:Xc,validate:e=>{if(!Xn(e))throw new le(`Invalid IPv4 address "${e}"`)}},{code:6,name:"tcp",size:16,valueToBytes:Ke,bytesToValue:yr,validate:Qr},{code:273,name:"udp",size:16,valueToBytes:Ke,bytesToValue:yr,validate:Qr},{code:33,name:"dccp",size:16,valueToBytes:Ke,bytesToValue:yr,validate:Qr},{code:41,name:"ip6",size:128,valueToBytes:Yc,bytesToValue:Jc,stringToValue:Qc,validate:e=>{if(!Gc(e))throw new le(`Invalid IPv6 address "${e}"`)}},{code:42,name:"ip6zone",size:st},{code:43,name:"ipcidr",size:8,bytesToValue:ls("base10"),valueToBytes:ds("base10")},{code:53,name:"dns",size:st,resolvable:!0},{code:54,name:"dns4",size:st,resolvable:!0},{code:55,name:"dns6",size:st,resolvable:!0},{code:56,name:"dnsaddr",size:st,resolvable:!0},{code:132,name:"sctp",size:16,valueToBytes:Ke,bytesToValue:yr,validate:Qr},{code:301,name:"udt"},{code:302,name:"utp"},{code:400,name:"unix",size:st,path:!0,stringToValue:e=>decodeURIComponent(e),valueToString:e=>encodeURIComponent(e)},{code:421,name:"p2p",aliases:["ipfs"],size:st,bytesToValue:ls("base58btc"),valueToBytes:e=>e.startsWith("Q")||e.startsWith("1")?ds("base58btc")(e):$.parse(e).multihash.bytes},{code:444,name:"onion",size:96,bytesToValue:hs,valueToBytes:Wc},{code:445,name:"onion3",size:296,bytesToValue:hs,valueToBytes:Zc},{code:446,name:"garlic64",size:st},{code:447,name:"garlic32",size:st},{code:448,name:"tls"},{code:449,name:"sni",size:st},{code:454,name:"noise"},{code:460,name:"quic"},{code:461,name:"quic-v1"},{code:465,name:"webtransport"},{code:466,name:"certhash",size:st,bytesToValue:eu(qo),valueToBytes:tu},{code:480,name:"http"},{code:481,name:"http-path",size:st,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:st}];Ep.forEach(e=>{Pt.addProtocol(e)});function ru(e){let t=[],r=0;for(;r<e.length;){let n=Ri(e,r),o=Pt.getProtocol(n),i=Qt(n),s=Sp(o,e,r+i),a=0;s>0&&o.size===st&&(a=Qt(s));let c=i+a+s,l={code:n,name:o.name,bytes:e.subarray(r,r+c)};if(s>0){let u=r+i+a,f=e.subarray(u,u+s);l.value=o.bytesToValue?.(f)??V(f)}t.push(l),r+=c}return t}function nu(e){let t=0,r=[];for(let n of e){if(n.bytes==null){let o=Pt.getProtocol(n.code),i=Qt(n.code),s,a=0,c=0;n.value!=null&&(s=o.valueToBytes?.(n.value)??M(n.value),a=s.byteLength,o.size===st&&(c=Qt(a)));let l=new Uint8Array(i+c+a),u=0;$r(n.code,l,u),u+=i,s!=null&&(o.size===st&&($r(a,l,u),u+=c),l.set(s,u)),n.bytes=l}r.push(n.bytes),t+=n.bytes.byteLength}return Lt(r,t)}function ou(e){if(e.charAt(0)!=="/")throw new ut('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=Pt.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 ut(`Component ${o} was missing value`);r="value"}else if(r==="value"){let l={code:c.code,name:c.name};if(c.size!=null&&c.size!==0){if(n==="")throw new ut(`Component ${o} was missing value`);l.value=c.stringToValue?.(n)??n}t.push(l),n="",o="",r="protocol"}}}if(o!==""&&n!=="")throw new ut("Incomplete multiaddr");return t}function iu(e){return`/${e.flatMap(t=>{if(t.value==null)return t.name;let r=Pt.getProtocol(t.code);if(r==null)throw new ut(`Unknown protocol code ${t.code}`);return[t.name,r.valueToString?.(t.value)??t.value]}).join("/")}`}function Sp(e,t,r){return e.size==null||e.size===0?0:e.size>0?e.size/8:Ri(t,r)}var vp=Symbol.for("nodejs.util.inspect.custom"),vs=Symbol.for("@multiformats/multiaddr"),Ap=[53,54,55,56],Ss=class extends Error{constructor(t="No available resolver"){super(t),this.name="NoAvailableResolverError"}};function Ip(e){if(e==null&&(e="/"),au(e))return e.getComponents();if(e instanceof Uint8Array)return ru(e);if(typeof e=="string")return e=e.replace(/\/(\/)+/,"/").replace(/(\/)+$/,""),e===""&&(e="/"),ou(e);if(Array.isArray(e))return e;throw new ut("Must be a string, Uint8Array, Component[], or another Multiaddr")}var ro=class e{[vs]=!0;#t;#n;#e;constructor(t="/",r={}){this.#t=Ip(t),r.validate!==!1&&Tp(this)}get bytes(){return this.#e==null&&(this.#e=nu(this.#t)),this.#e}toString(){return this.#n==null&&(this.#n=iu(this.#t)),this.#n}toJSON(){return this.toString()}toOptions(){let t,r,n,o,i="";for(let{code:a,name:c,value:l}of this.#t)a===42&&(i=`%${l??""}`),Ap.includes(a)&&(r="tcp",o=443,n=`${l??""}${i}`,t=a===55?6:4),(a===6||a===273)&&(r=c==="tcp"?"tcp":"udp",o=parseInt(l??"")),(a===4||a===41)&&(r="tcp",n=`${l??""}${i}`,t=a===41?6:4);if(t==null||r==null||n==null||o==null)throw new Error('multiaddr must have a valid format: "/{ip4, ip6, dns4, dns6, dnsaddr}/{address}/{tcp, udp}/{port}".');return{family:t,host:n,transport:r,port:o}}getComponents(){return[...this.#t]}protos(){return this.#t.map(({code:t,value:r})=>{let n=Pt.getProtocol(t);return{code:t,size:n.size??0,name:n.name,resolvable:!!n.resolvable,path:!!n.path}})}protoCodes(){return this.#t.map(({code:t})=>t)}protoNames(){return this.#t.map(({name:t})=>t)}tuples(){return this.#t.map(({code:t,value:r})=>{if(r==null)return[t];let n=Pt.getProtocol(t),o=[t];return r!=null&&o.push(n.valueToBytes?.(r)??M(r)),o})}stringTuples(){return this.#t.map(({code:t,value:r})=>r==null?[t]:[t,r])}encapsulate(t){let r=new e(t);return new e([...this.#t,...r.getComponents()],{validate:!1})}decapsulate(t){let r=t.toString(),n=this.toString(),o=n.lastIndexOf(r);if(o<0)throw new Jr(`Address ${this.toString()} does not contain subaddress: ${t.toString()}`);return new e(n.slice(0,o),{validate:!1})}decapsulateCode(t){let r;for(let n=this.#t.length-1;n>-1;n--)if(this.#t[n].code===t){r=n;break}return new e(this.#t.slice(0,r),{validate:!1})}getPeerId(){try{let t=[];this.#t.forEach(({code:n,value:o})=>{n===421&&t.push([n,o]),n===290&&(t=[])});let r=t.pop();if(r?.[1]!=null){let n=r[1];return n[0]==="Q"||n[0]==="1"?V(j.decode(`z${n}`),"base58btc"):V($.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){for(let t of this.#t)if(Pt.getProtocol(t.code).path)return t.value??null;return null}equals(t){return W(this.bytes,t.bytes)}async resolve(t){let r=this.protos().find(i=>i.resolvable);if(r==null)return[this];let n=su.get(r.name);if(n==null)throw new Ss(`no available resolver for ${r.name}`);return(await n(this,t)).map(i=>Fe(i))}nodeAddress(){let t=this.toOptions();if(t.transport!=="tcp"&&t.transport!=="udp")throw new Error(`multiaddr must have a valid format - no protocol with name: "${t.transport}". Must have a valid transport protocol: "{tcp, udp}"`);return{family:t.family,address:t.host,port:t.port}}isThinWaistAddress(){return!(this.#t.length!==2||this.#t[0].code!==4&&this.#t[0].code!==41||this.#t[1].code!==6&&this.#t[1].code!==273)}[vp](){return`Multiaddr(${this.toString()})`}};function Tp(e){e.getComponents().forEach(t=>{let r=Pt.getProtocol(t.code);t.value!=null&&r.validate?.(t.value)})}var $b=parseInt("0xFFFF",16),qb=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);var su=new Map;function au(e){return!!e?.[vs]}function Fe(e){return new ro(e)}function en(e){let t=new globalThis.AbortController;function r(){t.abort();for(let i of e)i?.removeEventListener!=null&&i.removeEventListener("abort",r)}for(let i of e){if(i?.aborted===!0){r();break}i?.addEventListener!=null&&i.addEventListener("abort",r)}function n(){for(let i of e)i?.removeEventListener!=null&&i.removeEventListener("abort",r)}let o=t.signal;return o.clear=n,o}async function*no(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 Dp="/",Np=new TextEncoder().encode(Dp),N1=Np[0];var d0=Uo(Is(),1);var qt=class extends Error{static name="SignatureVerificationError";constructor(t="Record signature verification failed"){super(t),this.name="SignatureVerificationError"}},oo=class extends Error{static name="RecordExpiredError";constructor(t="Record has expired"){super(t),this.name="RecordExpiredError"}},gr=class extends Error{static name="UnsupportedValidityError";constructor(t="The validity type is unsupported"){super(t),this.name="UnsupportedValidityError"}},io=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"}},ao=class extends Error{static name="InvalidRecordDataError";constructor(t="Invalid record data"){super(t),this.name="InvalidRecordDataError"}},rn=class extends Error{static name="InvalidEmbeddedPublicKeyError";constructor(t="Invalid embedded public key"){super(t),this.name="InvalidEmbeddedPublicKeyError"}};var Ht;(function(e){let t;(function(o){o.EOL="EOL"})(t=e.ValidityType||(e.ValidityType={}));let r;(function(o){o[o.EOL=0]="EOL"})(r||(r={})),function(o){o.codec=()=>zr(r)}(t=e.ValidityType||(e.ValidityType={}));let n;e.codec=()=>(n==null&&(n=hr((o,i,s={})=>{s.lengthDelimited!==!1&&i.fork(),o.value!=null&&(i.uint32(10),i.bytes(o.value)),o.signatureV1!=null&&(i.uint32(18),i.bytes(o.signatureV1)),o.validityType!=null&&(i.uint32(24),e.ValidityType.codec().encode(o.validityType,i)),o.validity!=null&&(i.uint32(34),i.bytes(o.validity)),o.sequence!=null&&(i.uint32(40),i.uint64(o.sequence)),o.ttl!=null&&(i.uint32(48),i.uint64(o.ttl)),o.pubKey!=null&&(i.uint32(58),i.bytes(o.pubKey)),o.signatureV2!=null&&(i.uint32(66),i.bytes(o.signatureV2)),o.data!=null&&(i.uint32(74),i.bytes(o.data)),s.lengthDelimited!==!1&&i.ldelim()},(o,i,s={})=>{let a={},c=i==null?o.len:o.pos+i;for(;o.pos<c;){let l=o.uint32();switch(l>>>3){case 1:{a.value=o.bytes();break}case 2:{a.signatureV1=o.bytes();break}case 3:{a.validityType=e.ValidityType.codec().decode(o);break}case 4:{a.validity=o.bytes();break}case 5:{a.sequence=o.uint64();break}case 6:{a.ttl=o.uint64();break}case 7:{a.pubKey=o.bytes();break}case 8:{a.signatureV2=o.bytes();break}case 9:{a.data=o.bytes();break}default:{o.skipType(l&7);break}}}return a})),n),e.encode=o=>lr(o,e.codec()),e.decode=(o,i)=>fr(o,e.codec(),i)})(Ht||(Ht={}));var Rp=["string","number","bigint","symbol"],Up=["Function","Generator","AsyncGenerator","GeneratorFunction","AsyncGeneratorFunction","AsyncFunction","Observable","Array","Buffer","Object","RegExp","Date","Error","Map","Set","WeakMap","WeakSet","ArrayBuffer","SharedArrayBuffer","DataView","Promise","URL","HTMLElement","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","BigInt64Array","BigUint64Array"];function fu(e){if(e===null)return"null";if(e===void 0)return"undefined";if(e===!0||e===!1)return"boolean";let t=typeof e;if(Rp.includes(t))return t;if(t==="function")return"Function";if(Array.isArray(e))return"Array";if(Lp(e))return"Buffer";let r=Op(e);return r||"Object"}function Lp(e){return e&&e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer.call(null,e)}function Op(e){let t=Object.prototype.toString.call(e).slice(8,-1);if(Up.includes(t))return t}var b=class{constructor(t,r,n){this.major=t,this.majorEncoded=t<<5,this.name=r,this.terminal=n}toString(){return`Type[${this.major}].${this.name}`}compare(t){return this.major<t.major?-1:this.major>t.major?1:0}};b.uint=new b(0,"uint",!0);b.negint=new b(1,"negint",!0);b.bytes=new b(2,"bytes",!0);b.string=new b(3,"string",!0);b.array=new b(4,"array",!1);b.map=new b(5,"map",!1);b.tag=new b(6,"tag",!1);b.float=new b(7,"float",!0);b.false=new b(7,"false",!0);b.true=new b(7,"true",!0);b.null=new b(7,"null",!0);b.undefined=new b(7,"undefined",!0);b.break=new b(7,"break",!0);var U=class{constructor(t,r,n){this.type=t,this.value=r,this.encodedLength=n,this.encodedBytes=void 0,this.byteValue=void 0}toString(){return`Token[${this.type}].${this.value}`}};var xr=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&typeof globalThis.Buffer.isBuffer=="function",kp=new TextDecoder,Kp=new TextEncoder;function co(e){return xr&&globalThis.Buffer.isBuffer(e)}function pu(e){return e instanceof Uint8Array?co(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e:Uint8Array.from(e)}var mu=xr?(e,t,r)=>r-t>64?globalThis.Buffer.from(e.subarray(t,r)).toString("utf8"):du(e,t,r):(e,t,r)=>r-t>64?kp.decode(e.subarray(t,r)):du(e,t,r),yu=xr?e=>e.length>64?globalThis.Buffer.from(e):lu(e):e=>e.length>64?Kp.encode(e):lu(e);var wr=xr?(e,t,r)=>co(e)?new Uint8Array(e.subarray(t,r)):e.slice(t,r):(e,t,r)=>e.slice(t,r),gu=xr?(e,t)=>(e=e.map(r=>r instanceof Uint8Array?r:globalThis.Buffer.from(r)),pu(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},xu=xr?e=>globalThis.Buffer.allocUnsafe(e):e=>new Uint8Array(e);function wu(e,t){if(co(e)&&co(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 lu(e){let t=[],r=0;for(let n=0;n<e.length;n++){let o=e.charCodeAt(n);o<128?t[r++]=o:o<2048?(t[r++]=o>>6|192,t[r++]=o&63|128):(o&64512)===55296&&n+1<e.length&&(e.charCodeAt(n+1)&64512)===56320?(o=65536+((o&1023)<<10)+(e.charCodeAt(++n)&1023),t[r++]=o>>18|240,t[r++]=o>>12&63|128,t[r++]=o>>6&63|128,t[r++]=o&63|128):(t[r++]=o>>12|224,t[r++]=o>>6&63|128,t[r++]=o&63|128)}return t}function du(e,t,r){let n=[];for(;t<r;){let o=e[t],i=null,s=o>239?4:o>223?3:o>191?2:1;if(t+s<=r){let a,c,l,u;switch(s){case 1:o<128&&(i=o);break;case 2:a=e[t+1],(a&192)===128&&(u=(o&31)<<6|a&63,u>127&&(i=u));break;case 3:a=e[t+1],c=e[t+2],(a&192)===128&&(c&192)===128&&(u=(o&15)<<12|(a&63)<<6|c&63,u>2047&&(u<55296||u>57343)&&(i=u));break;case 4:a=e[t+1],c=e[t+2],l=e[t+3],(a&192)===128&&(c&192)===128&&(l&192)===128&&(u=(o&15)<<18|(a&63)<<12|(c&63)<<6|l&63,u>65535&&u<1114112&&(i=u))}}i===null?(i=65533,s=1):i>65535&&(i-=65536,n.push(i>>>10&1023|55296),i=56320|i&1023),n.push(i),t+=s}return Fp(n)}var hu=4096;function Fp(e){let t=e.length;if(t<=hu)return String.fromCharCode.apply(String,e);let r="",n=0;for(;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=hu));return r}var Mp=256,uo=class{constructor(t=Mp){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=xu(this.chunkSize),this.chunks.push(r),this.maxCursor+=r.length,this._initReuseChunk===null&&(this._initReuseChunk=r),r.set(t,0)):(this.chunks.push(t),this.maxCursor+=t.length)}this.cursor+=t.length}toBytes(t=!1){let r;if(this.chunks.length===1){let n=this.chunks[0];t&&this.cursor>n.length/2?(r=this.cursor===n.length?n:n.subarray(0,this.cursor),this._initReuseChunk=null,this.chunks=[]):r=wr(n,0,this.cursor)}else r=gu(this.chunks,this.cursor);return t&&this.reset(),r}};var K="CBOR decode error:",Ts="CBOR encode error:",nn=[];nn[23]=1;nn[24]=2;nn[25]=3;nn[26]=5;nn[27]=9;function de(e,t,r){if(e.length-t<r)throw new Error(`${K} not enough data for type`)}var at=[24,256,65536,4294967296,BigInt("18446744073709551616")];function Dt(e,t,r){de(e,t,1);let n=e[t];if(r.strict===!0&&n<at[0])throw new Error(`${K} integer encoded in more bytes than necessary (strict decode)`);return n}function Nt(e,t,r){de(e,t,2);let n=e[t]<<8|e[t+1];if(r.strict===!0&&n<at[1])throw new Error(`${K} integer encoded in more bytes than necessary (strict decode)`);return n}function Rt(e,t,r){de(e,t,4);let n=e[t]*16777216+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3];if(r.strict===!0&&n<at[2])throw new Error(`${K} integer encoded in more bytes than necessary (strict decode)`);return n}function Ut(e,t,r){de(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<at[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 bu(e,t,r,n){return new U(b.uint,Dt(e,t+1,n),2)}function Eu(e,t,r,n){return new U(b.uint,Nt(e,t+1,n),3)}function Su(e,t,r,n){return new U(b.uint,Rt(e,t+1,n),5)}function vu(e,t,r,n){return new U(b.uint,Ut(e,t+1,n),9)}function kt(e,t){return ft(e,0,t.value)}function ft(e,t,r){if(r<at[0]){let n=Number(r);e.push([t|n])}else if(r<at[1]){let n=Number(r);e.push([t|24,n])}else if(r<at[2]){let n=Number(r);e.push([t|25,n>>>8,n&255])}else if(r<at[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<at[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 ft.encodedSize(t.value)};ft.encodedSize=function(t){return t<at[0]?1:t<at[1]?2:t<at[2]?3:t<at[3]?5:9};kt.compareTokens=function(t,r){return t.value<r.value?-1:t.value>r.value?1:0};function Au(e,t,r,n){return new U(b.negint,-1-Dt(e,t+1,n),2)}function Iu(e,t,r,n){return new U(b.negint,-1-Nt(e,t+1,n),3)}function Tu(e,t,r,n){return new U(b.negint,-1-Rt(e,t+1,n),5)}var Cs=BigInt(-1),Cu=BigInt(1);function Bu(e,t,r,n){let o=Ut(e,t+1,n);if(typeof o!="bigint"){let i=-1-o;if(i>=Number.MIN_SAFE_INTEGER)return new U(b.negint,i,9)}if(n.allowBigInt!==!0)throw new Error(`${K} integers outside of the safe integer range are not supported`);return new U(b.negint,Cs-BigInt(o),9)}function fo(e,t){let r=t.value,n=typeof r=="bigint"?r*Cs-Cu:r*-1-1;ft(e,t.type.majorEncoded,n)}fo.encodedSize=function(t){let r=t.value,n=typeof r=="bigint"?r*Cs-Cu:r*-1-1;return n<at[0]?1:n<at[1]?2:n<at[2]?3:n<at[3]?5:9};fo.compareTokens=function(t,r){return t.value<r.value?1:t.value>r.value?-1:0};function on(e,t,r,n){de(e,t,r+n);let o=wr(e,t+r,t+r+n);return new U(b.bytes,o,r+n)}function _u(e,t,r,n){return on(e,t,1,r)}function Pu(e,t,r,n){return on(e,t,2,Dt(e,t+1,n))}function Du(e,t,r,n){return on(e,t,3,Nt(e,t+1,n))}function Nu(e,t,r,n){return on(e,t,5,Rt(e,t+1,n))}function Ru(e,t,r,n){let o=Ut(e,t+1,n);if(typeof o=="bigint")throw new Error(`${K} 64-bit integer bytes lengths not supported`);return on(e,t,9,o)}function lo(e){return e.encodedBytes===void 0&&(e.encodedBytes=e.type===b.string?yu(e.value):e.value),e.encodedBytes}function br(e,t){let r=lo(t);ft(e,t.type.majorEncoded,r.length),e.push(r)}br.encodedSize=function(t){let r=lo(t);return ft.encodedSize(r.length)+r.length};br.compareTokens=function(t,r){return $p(lo(t),lo(r))};function $p(e,t){return e.length<t.length?-1:e.length>t.length?1:wu(e,t)}function sn(e,t,r,n,o){let i=r+n;de(e,t,i);let s=new U(b.string,mu(e,t+r,t+i),i);return o.retainStringBytes===!0&&(s.byteValue=wr(e,t+r,t+i)),s}function Uu(e,t,r,n){return sn(e,t,1,r,n)}function Lu(e,t,r,n){return sn(e,t,2,Dt(e,t+1,n),n)}function Ou(e,t,r,n){return sn(e,t,3,Nt(e,t+1,n),n)}function ku(e,t,r,n){return sn(e,t,5,Rt(e,t+1,n),n)}function Ku(e,t,r,n){let o=Ut(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 Fu=br;function Er(e,t,r,n){return new U(b.array,n,r)}function Mu(e,t,r,n){return Er(e,t,1,r)}function Vu(e,t,r,n){return Er(e,t,2,Dt(e,t+1,n))}function $u(e,t,r,n){return Er(e,t,3,Nt(e,t+1,n))}function qu(e,t,r,n){return Er(e,t,5,Rt(e,t+1,n))}function Hu(e,t,r,n){let o=Ut(e,t+1,n);if(typeof o=="bigint")throw new Error(`${K} 64-bit integer array lengths not supported`);return Er(e,t,9,o)}function zu(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${K} indefinite length items not allowed`);return Er(e,t,1,1/0)}function ho(e,t){ft(e,b.array.majorEncoded,t.value)}ho.compareTokens=kt.compareTokens;ho.encodedSize=function(t){return ft.encodedSize(t.value)};function Sr(e,t,r,n){return new U(b.map,n,r)}function ju(e,t,r,n){return Sr(e,t,1,r)}function Gu(e,t,r,n){return Sr(e,t,2,Dt(e,t+1,n))}function Wu(e,t,r,n){return Sr(e,t,3,Nt(e,t+1,n))}function Zu(e,t,r,n){return Sr(e,t,5,Rt(e,t+1,n))}function Yu(e,t,r,n){let o=Ut(e,t+1,n);if(typeof o=="bigint")throw new Error(`${K} 64-bit integer map lengths not supported`);return Sr(e,t,9,o)}function Xu(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${K} indefinite length items not allowed`);return Sr(e,t,1,1/0)}function po(e,t){ft(e,b.map.majorEncoded,t.value)}po.compareTokens=kt.compareTokens;po.encodedSize=function(t){return ft.encodedSize(t.value)};function Ju(e,t,r,n){return new U(b.tag,r,1)}function Qu(e,t,r,n){return new U(b.tag,Dt(e,t+1,n),2)}function tf(e,t,r,n){return new U(b.tag,Nt(e,t+1,n),3)}function ef(e,t,r,n){return new U(b.tag,Rt(e,t+1,n),5)}function rf(e,t,r,n){return new U(b.tag,Ut(e,t+1,n),9)}function mo(e,t){ft(e,b.tag.majorEncoded,t.value)}mo.compareTokens=kt.compareTokens;mo.encodedSize=function(t){return ft.encodedSize(t.value)};var Wp=20,Zp=21,Yp=22,Xp=23;function nf(e,t,r,n){if(n.allowUndefined===!1)throw new Error(`${K} undefined values are not supported`);return n.coerceUndefinedToNull===!0?new U(b.null,null,1):new U(b.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 U(b.break,void 0,1)}function Bs(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 U(b.float,e,t)}function sf(e,t,r,n){return Bs(_s(e,t+1),3,n)}function af(e,t,r,n){return Bs(Ps(e,t+1),5,n)}function cf(e,t,r,n){return Bs(df(e,t+1),9,n)}function yo(e,t,r){let n=t.value;if(n===!1)e.push([b.float.majorEncoded|Wp]);else if(n===!0)e.push([b.float.majorEncoded|Zp]);else if(n===null)e.push([b.float.majorEncoded|Yp]);else if(n===void 0)e.push([b.float.majorEncoded|Xp]);else{let o,i=!1;(!r||r.float64!==!0)&&(ff(n),o=_s(zt,1),n===o||Number.isNaN(n)?(zt[0]=249,e.push(zt.slice(0,3)),i=!0):(lf(n),o=Ps(zt,1),n===o&&(zt[0]=250,e.push(zt.slice(0,5)),i=!0))),i||(Jp(n),o=df(zt,1),zt[0]=251,e.push(zt.slice(0,9)))}}yo.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){ff(n);let o=_s(zt,1);if(n===o||Number.isNaN(n))return 3;if(lf(n),o=Ps(zt,1),n===o)return 5}return 9};var uf=new ArrayBuffer(9),Kt=new DataView(uf,1),zt=new Uint8Array(uf,0);function ff(e){if(e===1/0)Kt.setUint16(0,31744,!1);else if(e===-1/0)Kt.setUint16(0,64512,!1);else if(Number.isNaN(e))Kt.setUint16(0,32256,!1);else{Kt.setFloat32(0,e);let t=Kt.getUint32(0),r=(t&2139095040)>>23,n=t&8388607;if(r===255)Kt.setUint16(0,31744,!1);else if(r===0)Kt.setUint16(0,(e&2147483648)>>16|n>>13,!1);else{let o=r-127;o<-24?Kt.setUint16(0,0):o<-14?Kt.setUint16(0,(t&2147483648)>>16|1<<24+o,!1):Kt.setUint16(0,(t&2147483648)>>16|o+15<<10|n>>13,!1)}}}function _s(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 lf(e){Kt.setFloat32(0,e,!1)}function Ps(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 Jp(e){Kt.setFloat64(0,e,!1)}function df(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)}yo.compareTokens=kt.compareTokens;function q(e,t,r){throw new Error(`${K} encountered invalid minor (${r}) for major ${e[t]>>>5}`)}function go(e){return()=>{throw new Error(`${K} ${e}`)}}var _=[];for(let e=0;e<=23;e++)_[e]=q;_[24]=bu;_[25]=Eu;_[26]=Su;_[27]=vu;_[28]=q;_[29]=q;_[30]=q;_[31]=q;for(let e=32;e<=55;e++)_[e]=q;_[56]=Au;_[57]=Iu;_[58]=Tu;_[59]=Bu;_[60]=q;_[61]=q;_[62]=q;_[63]=q;for(let e=64;e<=87;e++)_[e]=_u;_[88]=Pu;_[89]=Du;_[90]=Nu;_[91]=Ru;_[92]=q;_[93]=q;_[94]=q;_[95]=go("indefinite length bytes/strings are not supported");for(let e=96;e<=119;e++)_[e]=Uu;_[120]=Lu;_[121]=Ou;_[122]=ku;_[123]=Ku;_[124]=q;_[125]=q;_[126]=q;_[127]=go("indefinite length bytes/strings are not supported");for(let e=128;e<=151;e++)_[e]=Mu;_[152]=Vu;_[153]=$u;_[154]=qu;_[155]=Hu;_[156]=q;_[157]=q;_[158]=q;_[159]=zu;for(let e=160;e<=183;e++)_[e]=ju;_[184]=Gu;_[185]=Wu;_[186]=Zu;_[187]=Yu;_[188]=q;_[189]=q;_[190]=q;_[191]=Xu;for(let e=192;e<=215;e++)_[e]=Ju;_[216]=Qu;_[217]=tf;_[218]=ef;_[219]=rf;_[220]=q;_[221]=q;_[222]=q;_[223]=q;for(let e=224;e<=243;e++)_[e]=go("simple values are not supported");_[244]=q;_[245]=q;_[246]=q;_[247]=nf;_[248]=go("simple values are not supported");_[249]=sf;_[250]=af;_[251]=cf;_[252]=q;_[253]=q;_[254]=q;_[255]=of;var jt=[];for(let e=0;e<24;e++)jt[e]=new U(b.uint,e,1);for(let e=-1;e>=-24;e--)jt[31-e]=new U(b.negint,e,1);jt[64]=new U(b.bytes,new Uint8Array(0),1);jt[96]=new U(b.string,"",1);jt[128]=new U(b.array,0,1);jt[160]=new U(b.map,0,1);jt[244]=new U(b.false,!1,1);jt[245]=new U(b.true,!0,1);jt[246]=new U(b.null,null,1);function t0(){let e=[];return e[b.uint.major]=kt,e[b.negint.major]=fo,e[b.bytes.major]=br,e[b.string.major]=Fu,e[b.array.major]=ho,e[b.map.major]=po,e[b.tag.major]=mo,e[b.float.major]=yo,e}var P2=t0(),D2=new uo,xo=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(`${Ts} object contains circular references`);return new e(r,t)}},ve={null:new U(b.null,null),undefined:new U(b.undefined,void 0),true:new U(b.true,!0),false:new U(b.false,!1),emptyArray:new U(b.array,0),emptyMap:new U(b.map,0)},Ae={number(e,t,r,n){return!Number.isInteger(e)||!Number.isSafeInteger(e)?new U(b.float,e):e>=0?new U(b.uint,e):new U(b.negint,e)},bigint(e,t,r,n){return e>=BigInt(0)?new U(b.uint,e):new U(b.negint,e)},Uint8Array(e,t,r,n){return new U(b.bytes,e)},string(e,t,r,n){return new U(b.string,e)},boolean(e,t,r,n){return e?ve.true:ve.false},null(e,t,r,n){return ve.null},undefined(e,t,r,n){return ve.undefined},ArrayBuffer(e,t,r,n){return new U(b.bytes,new Uint8Array(e))},DataView(e,t,r,n){return new U(b.bytes,new Uint8Array(e.buffer,e.byteOffset,e.byteLength))},Array(e,t,r,n){if(!e.length)return r.addBreakTokens===!0?[ve.emptyArray,new U(b.break)]:ve.emptyArray;n=xo.createCheck(n,e);let o=[],i=0;for(let s of e)o[i++]=Ds(s,r,n);return r.addBreakTokens?[new U(b.array,e.length),o,new U(b.break)]:[new U(b.array,e.length),o]},Object(e,t,r,n){let o=t!=="Object",i=o?e.keys():Object.keys(e),s=o?e.size:i.length;if(!s)return r.addBreakTokens===!0?[ve.emptyMap,new U(b.break)]:ve.emptyMap;n=xo.createCheck(n,e);let a=[],c=0;for(let l of i)a[c++]=[Ds(l,r,n),Ds(o?e.get(l):e[l],r,n)];return e0(a,r),r.addBreakTokens?[new U(b.map,s),a,new U(b.break)]:[new U(b.map,s),a]}};Ae.Map=Ae.Object;Ae.Buffer=Ae.Uint8Array;for(let e of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))Ae[`${e}Array`]=Ae.DataView;function Ds(e,t={},r){let n=fu(e),o=t&&t.typeEncoders&&t.typeEncoders[n]||Ae[n];if(typeof o=="function"){let s=o(e,n,t,r);if(s!=null)return s}let i=Ae[n];if(!i)throw new Error(`${Ts} unsupported type: ${n}`);return i(e,n,t,r)}function e0(e,t){t.mapSorter&&e.sort(t.mapSorter)}var r0={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0},wo=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=_[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}},an=Symbol.for("DONE"),bo=Symbol.for("BREAK");function n0(e,t,r){let n=[];for(let o=0;o<e.value;o++){let i=vr(t,r);if(i===bo){if(e.value===1/0)break;throw new Error(`${K} got unexpected break to lengthed array`)}if(i===an)throw new Error(`${K} found array but not enough entries (got ${o}, expected ${e.value})`);n[o]=i}return n}function o0(e,t,r){let n=r.useMaps===!0,o=n?void 0:{},i=n?new Map:void 0;for(let s=0;s<e.value;s++){let a=vr(t,r);if(a===bo){if(e.value===1/0)break;throw new Error(`${K} got unexpected break to lengthed map`)}if(a===an)throw new Error(`${K} found map but not enough entries (got ${s} [no key], expected ${e.value})`);if(n!==!0&&typeof a!="string")throw new Error(`${K} non-string keys not supported (got ${typeof a})`);if(r.rejectDuplicateMapKeys===!0&&(n&&i.has(a)||!n&&a in o))throw new Error(`${K} found repeat map key "${a}"`);let c=vr(t,r);if(c===an)throw new Error(`${K} found map but not enough entries (got ${s} [no value], expected ${e.value})`);n?i.set(a,c):o[a]=c}return n?i:o}function vr(e,t){if(e.done())return an;let r=e.next();if(r.type===b.break)return bo;if(r.type.terminal)return r.value;if(r.type===b.array)return n0(r,e,t);if(r.type===b.map)return o0(r,e,t);if(r.type===b.tag){if(t.tags&&typeof t.tags[r.value]=="function"){let n=vr(e,t);return t.tags[r.value](n)}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({},r0,t);let r=t.tokenizer||new wo(e,t),n=vr(r,t);if(n===an)throw new Error(`${K} did not find any content to decode`);if(n===bo)throw new Error(`${K} got unexpected break`);return[n,e.subarray(r.pos())]}function Ns(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 a0=me("ipns:utils"),pf=M("/ipns/");var c0=0,u0=18;function mf(e){let t;if(e.pubKey!=null)try{t=Vc(e.pubKey)}catch(r){throw a0.error(r),r}if(t!=null)return t}function yf(e){let t=M("ipns-signature:");return Lt([t,e])}function Ve(e){return"signatureV1"in e?Ht.encode({value:M(e.value),signatureV1:e.signatureV1,validityType:e.validityType,validity:M(e.validity),sequence:e.sequence,ttl:e.ttl,pubKey:e.pubKey,signatureV2:e.signatureV2,data:e.data}):Ht.encode({pubKey:e.pubKey,signatureV2:e.signatureV2,data:e.data})}function ee(e){let t=Ht.decode(e);if(t.sequence!=null&&(t.sequence=BigInt(t.sequence)),t.ttl!=null&&(t.ttl=BigInt(t.ttl)),t.signatureV2==null||t.data==null)throw new qt("Missing data or signatureV2");let r=gf(t.data),n=f0(r.Value),o=V(r.Validity);if(t.value!=null&&t.signatureV1!=null)return l0(t),{value:n,validityType:Ht.ValidityType.EOL,validity:o,sequence:r.Sequence,ttl:r.TTL,pubKey:t.pubKey,signatureV1:t.signatureV1,signatureV2:t.signatureV2,data:t.data};if(t.signatureV2!=null)return{value:n,validityType:Ht.ValidityType.EOL,validity:o,sequence:r.Sequence,ttl:r.TTL,pubKey:t.pubKey,signatureV2:t.signatureV2,data:t.data};throw new Error("invalid record: does not include signatureV1 or signatureV2")}function cn(e){return Lt([pf,e.bytes])}function he(e){let t=Ce(e.slice(pf.length));if(!Eo(t,c0)&&!Eo(t,u0))throw new ze("Multihash in IPNS key was not identity or sha2-256");return t}function gf(e){let t=Ns(e);if(t.ValidityType===0)t.ValidityType=Ht.ValidityType.EOL;else throw new gr("The validity type is unsupported");return Number.isInteger(t.Sequence)&&(t.Sequence=BigInt(t.Sequence)),Number.isInteger(t.TTL)&&(t.TTL=BigInt(t.TTL)),t}function f0(e){let t=V(e).trim();if(t.startsWith("/"))return t;try{return`/ipfs/${$.decode(e).toV1().toString()}`}catch{}try{return`/ipfs/${$.parse(t).toV1().toString()}`}catch{}throw new so("Value must be a valid content path starting with /")}function l0(e){if(e.data==null)throw new ao("Record data is missing");let t=gf(e.data);if(!W(t.Value,e.value??new Uint8Array(0)))throw new qt('Field "value" did not match between protobuf and CBOR');if(!W(t.Validity,e.validity??new Uint8Array(0)))throw new qt('Field "validity" did not match between protobuf and CBOR');if(t.ValidityType!==e.validityType)throw new qt('Field "validityType" did not match between protobuf and CBOR');if(t.Sequence!==e.sequence)throw new qt('Field "sequence" did not match between protobuf and CBOR');if(t.TTL!==e.ttl)throw new qt('Field "ttl" did not match between protobuf and CBOR')}function Eo(e,t){return e.code===t}var eE=me("ipns"),rE=5*60*1e9,h0="/ipns/",nE=h0.length;var xf=Uo(Is(),1);var So=me("ipns:validator"),p0=1024*10,m0=async(e,t)=>{let r=ee(t),n;try{let o=yf(r.data);n=await e.verify(o,r.signatureV2)}catch{n=!1}if(!n)throw So.error("record signature verification failed"),new qt("Record signature verification failed");if(r.validityType===Ht.ValidityType.EOL){if(xf.default.fromString(r.validity).toDate().getTime()<Date.now())throw So.error("record has expired"),new oo("record has expired")}else if(r.validityType!=null)throw So.error("the validity type is unsupported"),new gr("The validity type is unsupported");So("ipns record for %s is valid",r.value)};async function wf(e,t){if(t.byteLength>p0)throw new io("The record is too large");let r=he(e),n;Eo(r,0)&&(n=Hn(r));let o=ee(t),i=mf(o)??n;if(i==null)throw new rn("Could not extract public key from IPNS record or routing key");let s=cn(i.toMultihash());if(!W(s,e))throw new rn("Embedded public key did not match routing key");await m0(i,t)}var vo=class extends Error{name="InvalidMessageLengthError";code="ERR_INVALID_MESSAGE_LENGTH"};async function*un(e,t={}){let r=/\r?\n/,n=new TextDecoder("utf8"),o="";for await(let i of e){if(typeof i=="string"&&(i=new TextEncoder().encode(i)),Je(i)&&(i=i.subarray()),o+=n.decode(i,{stream:!0}),o.length>(t?.maxMessageLength??o.length))throw new vo("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 re(){let e={};return e.promise=new Promise((t,r)=>{e.resolve=t,e.reject=r}),e}var Us=Uo(Ef(),1);var ln=class extends Error{constructor(t){super(t),this.name="TimeoutError"}},Ls=class extends Error{constructor(t){super(),this.name="AbortError",this.message=t}},Sf=e=>globalThis.DOMException===void 0?new Ls(e):new DOMException(e),vf=e=>{let t=e.reason===void 0?Sf("This operation was aborted."):e.reason;return t instanceof Error?t:Sf(t)};function Os(e,t){let{milliseconds:r,fallback:n,message:o,customTimers:i={setTimeout,clearTimeout}}=t,s,a,l=new Promise((u,f)=>{if(typeof r!="number"||Math.sign(r)!==1)throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${r}\``);if(t.signal){let{signal:y}=t;y.aborted&&f(vf(y)),a=()=>{f(vf(y))},y.addEventListener("abort",a,{once:!0})}if(r===Number.POSITIVE_INFINITY){e.then(u,f);return}let m=new ln;s=i.setTimeout.call(void 0,()=>{if(n){try{u(n())}catch(y){f(y)}return}typeof e.cancel=="function"&&e.cancel(),o===!1?u():o instanceof Error?f(o):(m.message=o??`Promise timed out after ${r} milliseconds`,f(m))},r),(async()=>{try{u(await e)}catch(y){f(y)}})()}).finally(()=>{l.clear(),a&&t.signal&&t.signal.removeEventListener("abort",a)});return l.clear=()=>{i.clearTimeout.call(void 0,s),s=void 0},l}function ks(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 dn=class{#t=[];enqueue(t,r){r={priority:0,...r};let n={priority:r.priority,id:r.id,run:t};if(this.size===0||this.#t[this.size-1].priority>=r.priority){this.#t.push(n);return}let o=ks(this.#t,n,(i,s)=>s.priority-i.priority);this.#t.splice(o,0,n)}setPriority(t,r){let n=this.#t.findIndex(i=>i.id===t);if(n===-1)throw new ReferenceError(`No promise function with the id "${t}" exists in the queue.`);let[o]=this.#t.splice(n,1);this.enqueue(o.run,{priority:r,id:t})}dequeue(){return this.#t.shift()?.run}filter(t){return this.#t.filter(r=>r.priority===t.priority).map(r=>r.run)}get size(){return this.#t.length}};var hn=class extends Us.default{#t;#n;#e=0;#h;#a;#p=0;#o;#c;#r;#m;#i=0;#u;#s;#y;#w=1n;timeout;constructor(t){if(super(),t={carryoverConcurrencyCount:!1,intervalCap:Number.POSITIVE_INFINITY,interval:0,concurrency:Number.POSITIVE_INFINITY,autoStart:!0,queueClass:dn,...t},!(typeof t.intervalCap=="number"&&t.intervalCap>=1))throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${t.intervalCap?.toString()??""}\` (${typeof t.intervalCap})`);if(t.interval===void 0||!(Number.isFinite(t.interval)&&t.interval>=0))throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${t.interval?.toString()??""}\` (${typeof t.interval})`);this.#t=t.carryoverConcurrencyCount,this.#n=t.intervalCap===Number.POSITIVE_INFINITY||t.interval===0,this.#h=t.intervalCap,this.#a=t.interval,this.#r=new t.queueClass,this.#m=t.queueClass,this.concurrency=t.concurrency,this.timeout=t.timeout,this.#y=t.throwOnTimeout===!0,this.#s=t.autoStart===!1}get#b(){return this.#n||this.#e<this.#h}get#E(){return this.#i<this.#u}#S(){this.#i--,this.#f(),this.emit("next")}#v(){this.#x(),this.#g(),this.#c=void 0}get#A(){let t=Date.now();if(this.#o===void 0){let r=this.#p-t;if(r<0)this.#e=this.#t?this.#i:0;else return this.#c===void 0&&(this.#c=setTimeout(()=>{this.#v()},r)),!0}return!1}#f(){if(this.#r.size===0)return this.#o&&clearInterval(this.#o),this.#o=void 0,this.emit("empty"),this.#i===0&&this.emit("idle"),!1;if(!this.#s){let t=!this.#A;if(this.#b&&this.#E){let r=this.#r.dequeue();return r?(this.emit("active"),r(),t&&this.#g(),!0):!1}}return!1}#g(){this.#n||this.#o!==void 0||(this.#o=setInterval(()=>{this.#x()},this.#a),this.#p=Date.now()+this.#a)}#x(){this.#e===0&&this.#i===0&&this.#o&&(clearInterval(this.#o),this.#o=void 0),this.#e=this.#t?this.#i:0,this.#l()}#l(){for(;this.#f(););}get concurrency(){return this.#u}set concurrency(t){if(!(typeof t=="number"&&t>=1))throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${t}\` (${typeof t})`);this.#u=t,this.#l()}async#I(t){return new Promise((r,n)=>{t.addEventListener("abort",()=>{n(t.reason)},{once:!0})})}setPriority(t,r){this.#r.setPriority(t,r)}async add(t,r={}){return r.id??=(this.#w++).toString(),r={timeout:this.timeout,throwOnTimeout:this.#y,...r},new Promise((n,o)=>{this.#r.enqueue(async()=>{this.#i++,this.#e++;try{r.signal?.throwIfAborted();let i=t({signal:r.signal});r.timeout&&(i=Os(Promise.resolve(i),{milliseconds:r.timeout})),r.signal&&(i=Promise.race([i,this.#I(r.signal)]));let s=await i;n(s),this.emit("completed",s)}catch(i){if(i instanceof ln&&!r.throwOnTimeout){n();return}o(i),this.emit("error",i)}finally{this.#S()}},r),this.emit("add"),this.#f()})}async addAll(t,r){return Promise.all(t.map(async n=>this.add(n,r)))}start(){return this.#s?(this.#s=!1,this.#l(),this):this}pause(){this.#s=!0}clear(){this.#r=new this.#m}async onEmpty(){this.#r.size!==0&&await this.#d("empty")}async onSizeLessThan(t){this.#r.size<t||await this.#d("next",()=>this.#r.size<t)}async onIdle(){this.#i===0&&this.#r.size===0||await this.#d("idle")}async#d(t,r){return new Promise(n=>{let o=()=>{r&&!r()||(this.off(t,o),n())};this.on(t,o)})}get size(){return this.#r.size}sizeBy(t){return this.#r.filter(t).length}get pending(){return this.#i}get isPaused(){return this.#s}};var Ar=class extends Error{static name="InvalidRequestError";constructor(t="Invalid request"){super(t),this.name="InvalidRequestError"}},Gt=class extends Error{static name="BadResponseError";constructor(t="Bad response"){super(t),this.name="BadResponseError"}};function x0(e){return e[Symbol.asyncIterator]!=null}function w0(e){if(x0(e))return(async()=>{for await(let t of e)return t})();for(let t of e)return t}var Io=w0;function b0(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 Af=b0;function E0(e){return e[Symbol.asyncIterator]!=null}function S0(e,t){let r=0;if(E0(e))return async function*(){for await(let c of e)yield t(c,r++)}();let n=Af(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 To=S0;var If=M("/ipns/");function Tf(e){return W(e.subarray(0,If.byteLength),If)}var Co=class{client;constructor(t){this.client=t}async*findProviders(t,r={}){yield*To(this.client.getProviders(t,r),n=>({id:n.ID,multiaddrs:n.Addrs??[]}))}async provide(){}async cancelReprovide(){}async put(t,r,n){if(!Tf(t))return;let o=he(t),i=$.createV1(114,o),s=ee(r);await this.client.putIPNS(i,s,n)}async get(t,r){if(!Tf(t))throw new St("Not found");let n=he(t),o=$.createV1(114,n);try{let i=await this.client.getIPNS(o,r);return Ve(i)}catch(i){throw i.name==="BadResponseError"?new St("Not found"):i}}},Bo=class{client;constructor(t){this.client=t}async findPeer(t,r={}){let n=await Io(this.client.getPeers(t,r));if(n!=null)return{id:n.ID,multiaddrs:n.Addrs??[]};throw new St("Not found")}async*getClosestPeers(t,r={}){}};var lt=me("delegated-routing-v1-http-api-client"),_o={concurrentRequests:4,timeout:3e4,cacheTTL:5*60*1e3,cacheName:"delegated-routing-v1-cache"},Po=class{started;httpQueue;shutDownController;clientUrl;timeout;contentRouting;peerRouting;filterAddrs;filterProtocols;inFlightRequests;cacheName;cache;cacheTTL;constructor(t,r={}){this.started=!1,this.shutDownController=new AbortController,this.shutDownController.signal,this.httpQueue=new hn({concurrency:r.concurrentRequests??_o.concurrentRequests}),this.inFlightRequests=new Map,this.clientUrl=t instanceof URL?t:new URL(t),this.timeout=r.timeout??_o.timeout,this.filterAddrs=r.filterAddrs,this.filterProtocols=r.filterProtocols,this.contentRouting=new Co(this),this.peerRouting=new Bo(this),this.cacheName=r.cacheName??_o.cacheName,this.cacheTTL=r.cacheTTL??_o.cacheTTL}get[Ys](){return this.contentRouting}get[Xs](){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&&lt("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={}){lt("getProviders starts: %c",t);let n=AbortSignal.timeout(this.timeout),o=en([this.shutDownController.signal,n,r.signal]);let i=re(),s=re();this.httpQueue.add(async()=>(i.resolve(),s.promise));try{await i.promise;let a=new URL(`${this.clientUrl}routing/v1/providers/${t.toString()}`);this.#n(a,r.filterAddrs,r.filterProtocols);let c={headers:{Accept:"application/x-ndjson"},signal:o},l=await this.#e(a.toString(),c);if(l==null)throw new Gt("No response received");if(!l.ok)throw l.status===404?new St("No matching records found"):l.status===422?new Ar("Request does not conform to schema or semantic constraints"):new Gt(`Unexpected status code: ${l.status}`);if(l.body==null)throw new Gt("Routing response had no body");let u=l.headers.get("Content-Type");if(u==null)throw new Gt("No Content-Type header received");if(u?.startsWith("application/json")){let f=await l.json();for(let m of f.Providers){let y=this.#t(m);y!=null&&(yield y)}}else if(u.includes("application/x-ndjson"))for await(let f of un(no(l.body))){let m=this.#t(f);m!=null&&(yield m)}else throw new Gt(`Unsupported Content-Type: ${u}`)}finally{o.clear(),s.resolve(),lt("getProviders finished: %c",t)}}async*getPeers(t,r={}){lt("getPeers starts: %c",t);let n=AbortSignal.timeout(this.timeout),o=en([this.shutDownController.signal,n,r.signal]);let i=re(),s=re();this.httpQueue.add(async()=>(i.resolve(),s.promise));try{await i.promise;let a=new URL(`${this.clientUrl}routing/v1/peers/${t.toCID().toString()}`);this.#n(a,r.filterAddrs,r.filterProtocols);let c={headers:{Accept:"application/x-ndjson"},signal:o},l=await this.#e(a.toString(),c);if(l.status===404)throw new St("No matching records found");if(l.status===422)throw new Ar("Request does not conform to schema or semantic constraints");if(l.body==null)throw new Gt("Routing response had no body");if(l.headers.get("Content-Type")==="application/json"){let f=await l.json();for(let m of f.Peers){let y=this.#t(m);y!=null&&(yield y)}}else for await(let f of un(no(l.body))){let m=this.#t(f);m!=null&&(yield m)}}catch(a){lt.error("getPeers errored:",a)}finally{o.clear(),s.resolve(),lt("getPeers finished: %c",t)}}async getIPNS(t,r={}){lt("getIPNS starts: %s",t);let n=AbortSignal.timeout(this.timeout),o=en([this.shutDownController.signal,n,r.signal]);let i=re(),s=re();this.httpQueue.add(async()=>(i.resolve(),s.promise));let a=`${this.clientUrl}routing/v1/ipns/${t}`;try{await i.promise;let c={headers:{Accept:"application/vnd.ipfs.ipns-record"},signal:o},l=await this.#e(a,c);if(lt("getIPNS GET %s %d",a,l.status),l.status===404)throw new St("No matching records found");if(l.status===422)throw new Ar("Request does not conform to schema or semantic constraints");if(l.body==null)throw new Gt("GET ipns response had no body");let u=await l.arrayBuffer(),f=new Uint8Array(u,0,u.byteLength);return r.validate!==!1&&await wf(cn(t.multihash),f),ee(f)}catch(c){throw lt.error("getIPNS GET %s error:",a,c),c}finally{o.clear(),s.resolve(),lt("getIPNS finished: %s",t)}}async putIPNS(t,r,n={}){lt("putIPNS starts: %c",t);let o=AbortSignal.timeout(this.timeout),i=en([this.shutDownController.signal,o,n.signal]);let s=re(),a=re();this.httpQueue.add(async()=>(s.resolve(),a.promise));let c=`${this.clientUrl}routing/v1/ipns/${t}`;try{await s.promise;let l=Ve(r),u={method:"PUT",headers:{"Content-Type":"application/vnd.ipfs.ipns-record"},body:l,signal:i},f=await this.#e(c,u);if(lt("putIPNS PUT %s %d",c,f.status),f.status!==200)throw new Gt("PUT ipns response had status other than 200")}catch(l){throw lt.error("putIPNS PUT %s error:",c,l.stack),l}finally{i.clear(),a.resolve(),lt("putIPNS finished: %c",t)}}#t(t){try{let r=[],n=t.Addrs?.map(Fe)??[];return t.Protocols!=null&&r.push(...t.Protocols),t.Protocol!=null&&(r.push(t.Protocol),delete t.Protocol),{...t,Schema:"peer",ID:Hc(t.ID),Addrs:n,Protocols:r}}catch(r){lt.error("could not conform record to peer schema",r)}}#n(t,r,n){if(r!=null||this.filterAddrs!=null){let o=r?.join(",")??this.filterAddrs?.join(",")??"";o!==""&&t.searchParams.set("filter-addrs",o)}if(n!=null||this.filterProtocols!=null){let o=n?.join(",")??this.filterProtocols?.join(",")??"";o!==""&&t.searchParams.set("filter-protocols",o)}}async#e(t,r){let n=r.method??"GET",o=`${n}-${t}`;if(n==="GET"){let c=await this.cache?.match(t);if(c!=null){if(parseInt(c.headers.get("x-cache-expires")??"0",10)>Date.now())return lt("returning cached response for %s",o),c;await this.cache?.delete(t)}}let i=this.inFlightRequests.get(o);if(i!=null){let c=await i;return lt("deduplicating outgoing request for %s",o),c.clone()}let s=fetch(t,r).then(async c=>{if(this.cache!=null&&c.ok&&n==="GET"){let l=Date.now()+this.cacheTTL,u=new Headers(c.headers);u.set("x-cache-expires",l.toString());let f=new Response(c.clone().body,{status:c.status,statusText:c.statusText,headers:u});await this.cache.put(t,f)}return c}).finally(()=>{this.inFlightRequests.delete(o)});return this.inFlightRequests.set(o,s),await s}};function Cf(e,t={}){return new Po(new URL(e),t)}function Do(){return{filterProtocols:["unknown","transport-bitswap","transport-ipfs-gateway-http"],filterAddrs:["https","webtransport","webrtc","webrtc-direct","wss","tls"]}}var Bf=M("/ipns/");function _f(e){return W(e.subarray(0,Bf.byteLength),Bf)}var Ks=class{client;constructor(t,r={}){this.client=Cf(t,r)}async provide(t,r){}async cancelReprovide(t,r){}async*findProviders(t,r){yield*To(this.client.getProviders(t,r),n=>({id:n.ID,multiaddrs:n.Addrs,protocols:n.Protocols}))}async put(t,r,n){if(!_f(t))return;let o=he(t),i=$.createV1(114,o),s=ee(r);await this.client.putIPNS(i,s,n)}async get(t,r){if(!_f(t))throw new St("Not found");let n=he(t),o=$.createV1(114,n);try{let i=await this.client.getIPNS(o,r);return Ve(i)}catch(i){throw i.name==="BadResponseError"?new St("Not found"):i}}async findPeer(t,r){let n=await Io(this.client.getPeers(t,r));if(n!=null)return{id:n.ID,multiaddrs:n.Addrs??[]};throw new St("Not found")}async*getClosestPeers(t,r){}};function Pf(e,t){let r=t??Do();return new Ks(new URL(e),r)}var Df="[a-fA-F\\d:]",Ie=e=>e&&e.includeBoundaries?`(?:(?<=\\s|^)(?=${Df})|(?<=${Df})(?=\\s|$))`:"",Wt="(?: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}",nt="[a-fA-F\\d]{1,4}",No=`
2
+ "use strict";var HeliaRouters=(()=>{var Tf=Object.create;var un=Object.defineProperty;var Bf=Object.getOwnPropertyDescriptor;var Cf=Object.getOwnPropertyNames;var _f=Object.getPrototypeOf,Pf=Object.prototype.hasOwnProperty;var Ks=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Et=(e,t)=>{for(var r in t)un(e,r,{get:t[r],enumerable:!0})},Fs=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Cf(t))!Pf.call(e,o)&&o!==r&&un(e,o,{get:()=>t[o],enumerable:!(n=Bf(t,o))||n.enumerable});return e};var To=(e,t,r)=>(r=e!=null?Tf(_f(e)):{},Fs(t||!e||!e.__esModule?un(r,"default",{value:e,enumerable:!0}):r,e)),Uf=e=>Fs(un({},"__esModule",{value:!0}),e);var ps=Ks((Kb,hs)=>{var kb=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",l=Math.trunc||function(g){var d=g-g%1;return d==0&&(g<0||g===0&&1/g!=1/0)?-0:d},u=v.prototype,f=(v.fromDate=function(g){return new v(+g)},v.fromInt64BE=K(0,1,2,3,0,4),v.fromInt64LE=K(3,2,1,0,4,0),v.fromString=function(h){var d,x=new v,h=(h+="").replace(/^\s*[+\-]?\d+/,function(S){var S=+S,I=1970+(S-1970)%400;return x.year=S-I,I}).replace(/(?:Z|([+\-]\d{2}):?(\d{2}))$/,function(m,S,I){return S<0&&(I*=-1),d=6e4*(60*+S+ +I),""}).replace(/\.\d+$/,function(m){return x.nano=+(m+c).substr(1,9),""}).split(/\D+/);if(1<h.length?h[1]--:h[1]=0,x.time=d=Date.UTC.apply(Date,h)-(d||0),isNaN(d))throw new TypeError("Invalid Date");return w(x)},v.fromTimeT=function(g){return U(g,0)},u.year=0,u.time=0,u.nano=0,u.addNano=function(g){return this.nano+=+g||0,this},u.getNano=function(){var g=w(this);return(g.time%1e3*a+ +g.nano+1e9)%1e9},u.getTimeT=function(){var d=w(this),g=Math.floor(d.time/1e3),d=d.year;return d&&(g+=d*r*e/t),g},u.getYear=function(){return this.toDate().getUTCFullYear()+this.year},u.toDate=function(){return C(w(this).time)},u.toJSON=function(){return this.toString().replace(/0{1,6}Z$/,"Z")},u.toString=function(g){var d=this,x=d.toDate(),h={H:function(){return N(x.getUTCHours())},L:function(){return R(x.getUTCMilliseconds(),3)},M:function(){return N(x.getUTCMinutes())},N:function(){return R(d.getNano(),9)},S:function(){return N(x.getUTCSeconds())},Y:function(){var m=d.getYear();return 999999<m?"+"+m:9999<m?"+"+R(m,6):0<=m?R(m,4):-999999<=m?"-"+R(-m,6):m},a:function(){return p[x.getUTCDay()]},b:function(){return y[x.getUTCMonth()]},d:function(){return N(x.getUTCDate())},e:function(){return function(m){return(9<m?"":" ")+(0|m)}(x.getUTCDate())},m:function(){return N(x.getUTCMonth()+1)}};return function m(S){return S.replace(/%./g,function(I){var B=I[1],A=T[B],B=h[B];return A?m(A):B?B():I})}(g||f)},u.writeInt64BE=P(0,1,2,3,0,4),u.writeInt64LE=P(3,2,1,0,4,0),"%Y-%m-%dT%H:%M:%S.%NZ"),y=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],p=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],T={"%":"%",F:"%Y-%m-%d",n:`
3
+ `,R:"%H:%M",T:"%H:%M:%S",t:" ",X:"%T",Z:"GMT",z:"+0000"};return v;function v(g,d,x){var h=this;if(!(h instanceof v))return new v(g,d,x);h.time=+g||0,h.nano=+d||0,h.year=+x||0,w(h)}function w(g){var d,x,h,m=g.year,S=g.time,I=g.nano,A=((I<0||a<=I)&&(I-=(x=Math.floor(I/a))*a,S+=x,x=1),m%t);return(S<-i||i<S||A)&&((d=l(S/o))&&(m+=d*t,S-=d*o),(h=C(S)).setUTCFullYear(A+h.getUTCFullYear()),h=(S=+h)+(d=l((m-=A)/t))*o,d&&-i<=h&&h<=i&&(m-=d*t,S=h),x=1),x&&(g.year=m,g.time=S,g.nano=I),g}function C(g){var d=new Date(0);return d.setTime(g),d}function U(m,h){m=+m||0;var x=l((h=(h|0)*s)/n)+l(m/n),h=h%n+m%n,m=l(h/n);return m&&(x+=m,h-=m*n),new v(1e3*h,0,x*t)}function P(g,d,x,h,m,S){return function(A,B){var D=w(this);A=A||new Array(8),E(A,B|=0);var j=Math.floor(D.time/1e3),D=D.year*(r*e/t),k=l(D/s)+l(j/s),D=D%s+j%s,j=Math.floor(D/s);return j&&(k+=j,D-=j*s),I(A,B+m,k),I(A,B+S,D),A};function I(A,B,k){A[B+g]=k>>24&255,A[B+d]=k>>16&255,A[B+x]=k>>8&255,A[B+h]=255&k}}function K(g,d,x,h,m,S){return function(A,B){E(A,B|=0);var k=I(A,B+m);return U(I(A,B+S),k)};function I(A,B){return 16777216*A[B+g]+(A[B+d]<<16|A[B+x]<<8|A[B+h])}}function E(g,d){if(g=g&&g.length,g==null)throw new TypeError("Invalid Buffer");if(g<d+8)throw new RangeError("Out of range")}function N(g){return(9<g?"":"0")+(0|g)}function R(g,d){return(c+(0|g)).substr(-d)}}()});var af=Ks((C2,Ss)=>{"use strict";var Up=Object.prototype.hasOwnProperty,bt="~";function on(){}Object.create&&(on.prototype=Object.create(null),new on().__proto__||(bt=!1));function Np(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function sf(e,t,r,n,o){if(typeof r!="function")throw new TypeError("The listener must be a function");var i=new Np(r,n||e,o),s=bt?bt+t:t;return e._events[s]?e._events[s].fn?e._events[s]=[e._events[s],i]:e._events[s].push(i):(e._events[s]=i,e._eventsCount++),e}function yo(e,t){--e._eventsCount===0?e._events=new on:delete e._events[t]}function yt(){this._events=new on,this._eventsCount=0}yt.prototype.eventNames=function(){var t=[],r,n;if(this._eventsCount===0)return t;for(n in r=this._events)Up.call(r,n)&&t.push(bt?n.slice(1):n);return Object.getOwnPropertySymbols?t.concat(Object.getOwnPropertySymbols(r)):t};yt.prototype.listeners=function(t){var r=bt?bt+t:t,n=this._events[r];if(!n)return[];if(n.fn)return[n.fn];for(var o=0,i=n.length,s=new Array(i);o<i;o++)s[o]=n[o].fn;return s};yt.prototype.listenerCount=function(t){var r=bt?bt+t:t,n=this._events[r];return n?n.fn?1:n.length:0};yt.prototype.emit=function(t,r,n,o,i,s){var a=bt?bt+t:t;if(!this._events[a])return!1;var c=this._events[a],l=arguments.length,u,f;if(c.fn){switch(c.once&&this.removeListener(t,c.fn,void 0,!0),l){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(f=1,u=new Array(l-1);f<l;f++)u[f-1]=arguments[f];c.fn.apply(c.context,u)}else{var y=c.length,p;for(f=0;f<y;f++)switch(c[f].once&&this.removeListener(t,c[f].fn,void 0,!0),l){case 1:c[f].fn.call(c[f].context);break;case 2:c[f].fn.call(c[f].context,r);break;case 3:c[f].fn.call(c[f].context,r,n);break;case 4:c[f].fn.call(c[f].context,r,n,o);break;default:if(!u)for(p=1,u=new Array(l-1);p<l;p++)u[p-1]=arguments[p];c[f].fn.apply(c[f].context,u)}}return!0};yt.prototype.on=function(t,r,n){return sf(this,t,r,n,!1)};yt.prototype.once=function(t,r,n){return sf(this,t,r,n,!0)};yt.prototype.removeListener=function(t,r,n,o){var i=bt?bt+t:t;if(!this._events[i])return this;if(!r)return yo(this,i),this;var s=this._events[i];if(s.fn)s.fn===r&&(!o||s.once)&&(!n||s.context===n)&&yo(this,i);else{for(var a=0,c=[],l=s.length;a<l;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:yo(this,i)}return this};yt.prototype.removeAllListeners=function(t){var r;return t?(r=bt?bt+t:t,this._events[r]&&yo(this,r)):(this._events=new on,this._eventsCount=0),this};yt.prototype.off=yt.prototype.removeListener;yt.prototype.addListener=yt.prototype.on;yt.prefixed=bt;yt.EventEmitter=yt;typeof Ss<"u"&&(Ss.exports=yt)});var t0={};Et(t0,{delegatedHTTPRouting:()=>yf,delegatedHTTPRoutingDefaults:()=>vo,httpGatewayRouting:()=>Af,libp2pRouting:()=>If});var Os=Symbol.for("@libp2p/content-routing");var Bo=Symbol.for("@libp2p/peer-id");var Ms=Symbol.for("@libp2p/peer-routing");var nt=class extends Error{static name="InvalidParametersError";constructor(t="Invalid parameters"){super(t),this.name="InvalidParametersError"}},Ve=class extends Error{static name="InvalidPublicKeyError";constructor(t="Invalid public key"){super(t),this.name="InvalidPublicKeyError"}};var St=class extends Error{static name="NotFoundError";constructor(t="Not found"){super(t),this.name="NotFoundError"}};var fn=class extends Error{static name="InvalidCIDError";constructor(t="Invalid CID"){super(t),this.name="InvalidCIDError"}},$e=class extends Error{static name="InvalidMultihashError";constructor(t="Invalid Multihash"){super(t),this.name="InvalidMultihashError"}};var qe=class extends Error{static name="UnsupportedKeyTypeError";constructor(t="Unsupported key type"){super(t),this.name="UnsupportedKeyTypeError"}};var No={};Et(No,{base32:()=>Ft,base32hex:()=>Vf,base32hexpad:()=>qf,base32hexpadupper:()=>Hf,base32hexupper:()=>$f,base32pad:()=>Of,base32padupper:()=>Mf,base32upper:()=>Ff,base32z:()=>zf});var s0=new Uint8Array(0);function Vs(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 ee(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 $s(e){return new TextEncoder().encode(e)}function qs(e){return new TextDecoder().decode(e)}function Nf(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),l=Math.log(a)/Math.log(256),u=Math.log(256)/Math.log(a);function f(T){if(T instanceof Uint8Array||(ArrayBuffer.isView(T)?T=new Uint8Array(T.buffer,T.byteOffset,T.byteLength):Array.isArray(T)&&(T=Uint8Array.from(T))),!(T instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(T.length===0)return"";for(var v=0,w=0,C=0,U=T.length;C!==U&&T[C]===0;)C++,v++;for(var P=(U-C)*u+1>>>0,K=new Uint8Array(P);C!==U;){for(var E=T[C],N=0,R=P-1;(E!==0||N<w)&&R!==-1;R--,N++)E+=256*K[R]>>>0,K[R]=E%a>>>0,E=E/a>>>0;if(E!==0)throw new Error("Non-zero carry");w=N,C++}for(var g=P-w;g!==P&&K[g]===0;)g++;for(var d=c.repeat(v);g<P;++g)d+=e.charAt(K[g]);return d}function y(T){if(typeof T!="string")throw new TypeError("Expected String");if(T.length===0)return new Uint8Array;var v=0;if(T[v]!==" "){for(var w=0,C=0;T[v]===c;)w++,v++;for(var U=(T.length-v)*l+1>>>0,P=new Uint8Array(U);T[v];){var K=r[T.charCodeAt(v)];if(K===255)return;for(var E=0,N=U-1;(K!==0||E<C)&&N!==-1;N--,E++)K+=a*P[N]>>>0,P[N]=K%256>>>0,K=K/256>>>0;if(K!==0)throw new Error("Non-zero carry");C=E,v++}if(T[v]!==" "){for(var R=U-C;R!==U&&P[R]===0;)R++;for(var g=new Uint8Array(w+(U-R)),d=w;R!==U;)g[d++]=P[R++];return g}}}function p(T){var v=y(T);if(v)return v;throw new Error(`Non-${t} character`)}return{encode:f,decodeUnsafe:y,decode:p}}var Rf=Nf,Lf=Rf,zs=Lf;var Co=class{name;prefix;baseEncode;constructor(t,r,n){this.name=t,this.prefix=r,this.baseEncode=n}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}},_o=class{name;prefix;baseDecode;prefixCodePoint;constructor(t,r,n){this.name=t,this.prefix=r;let o=r.codePointAt(0);if(o===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=o,this.baseDecode=n}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return js(this,t)}},Po=class{decoders;constructor(t){this.decoders=t}or(t){return js(this,t)}decode(t){let r=t[0],n=this.decoders[r];if(n!=null)return n.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function js(e,t){return new Po({...e.decoders??{[e.prefix]:e},...t.decoders??{[t.prefix]:t}})}var Uo=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(t,r,n,o){this.name=t,this.prefix=r,this.baseEncode=n,this.baseDecode=o,this.encoder=new Co(t,r,n),this.decoder=new _o(t,r,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function He({name:e,prefix:t,encode:r,decode:n}){return new Uo(e,t,r,n)}function de({name:e,prefix:t,alphabet:r}){let{encode:n,decode:o}=zs(r,e);return He({prefix:t,name:e,encode:n,decode:i=>ee(o(i))})}function Df(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 l=0;l<o;++l){let u=t[e[l]];if(u===void 0)throw new SyntaxError(`Non-${n} character`);a=a<<r|u,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 kf(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 Kf(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=Kf(n);return He({prefix:t,name:e,encode(i){return kf(i,n,r)},decode(i){return Df(i,o,r,e)}})}var Ft=tt({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Ff=tt({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Of=tt({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Mf=tt({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Vf=tt({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),$f=tt({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),qf=tt({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Hf=tt({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),zf=tt({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Ro={};Et(Ro,{base58btc:()=>G,base58flickr:()=>jf});var G=de({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),jf=de({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Do={};Et(Do,{base64:()=>Lo,base64pad:()=>Gf,base64url:()=>Zf,base64urlpad:()=>Wf});var Lo=tt({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Gf=tt({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Zf=tt({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Wf=tt({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});function Yf(e,t){try{if(typeof e=="string"&&e.length>0)return Xf(e);if(typeof e=="number"&&isFinite(e))return t?.long?Qf(e):Jf(e);throw new Error("Value is not a string or number.")}catch(r){let n=tl(r)?`${r.message}. value=${JSON.stringify(e)}`:"An unknown error has occured.";throw new Error(n)}}function Xf(e){if(e=String(e),e.length>100)throw new Error("Value exceeds the maximum length of 100 characters.");let t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(!t)return NaN;let r=parseFloat(t[1]),n=(t[2]||"ms").toLowerCase();switch(n){case"years":case"year":case"yrs":case"yr":case"y":return r*315576e5;case"weeks":case"week":case"w":return r*6048e5;case"days":case"day":case"d":return r*864e5;case"hours":case"hour":case"hrs":case"hr":case"h":return r*36e5;case"minutes":case"minute":case"mins":case"min":case"m":return r*6e4;case"seconds":case"second":case"secs":case"sec":case"s":return r*1e3;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:throw new Error(`The unit ${n} was matched, but no matching case exists.`)}}var dn=Yf;function Jf(e){let t=Math.abs(e);return t>=864e5?`${Math.round(e/864e5)}d`:t>=36e5?`${Math.round(e/36e5)}h`:t>=6e4?`${Math.round(e/6e4)}m`:t>=1e3?`${Math.round(e/1e3)}s`:`${e}ms`}function Qf(e){let t=Math.abs(e);return t>=864e5?ln(e,t,864e5,"day"):t>=36e5?ln(e,t,36e5,"hour"):t>=6e4?ln(e,t,6e4,"minute"):t>=1e3?ln(e,t,1e3,"second"):`${e} ms`}function ln(e,t,r,n){let o=t>=r*1.5;return`${Math.round(e/r)} ${n}${o?"s":""}`}function tl(e){return typeof e=="object"&&e!==null&&"message"in e}function ko(e){r.debug=r,r.default=r,r.coerce=c,r.disable=i,r.enable=o,r.enabled=s,r.humanize=dn,r.destroy=l,Object.keys(e).forEach(u=>{r[u]=e[u]}),r.names=[],r.skips=[],r.formatters={};function t(u){let f=0;for(let y=0;y<u.length;y++)f=(f<<5)-f+u.charCodeAt(y),f|=0;return r.colors[Math.abs(f)%r.colors.length]}r.selectColor=t;function r(u){let f,y=null,p,T;function v(...w){if(!v.enabled)return;let C=v,U=Number(new Date),P=U-(f||U);C.diff=P,C.prev=f,C.curr=U,f=U,w[0]=r.coerce(w[0]),typeof w[0]!="string"&&w.unshift("%O");let K=0;w[0]=w[0].replace(/%([a-zA-Z%])/g,(N,R)=>{if(N==="%%")return"%";K++;let g=r.formatters[R];if(typeof g=="function"){let d=w[K];N=g.call(C,d),w.splice(K,1),K--}return N}),r.formatArgs.call(C,w),(C.log||r.log).apply(C,w)}return v.namespace=u,v.useColors=r.useColors(),v.color=r.selectColor(u),v.extend=n,v.destroy=r.destroy,Object.defineProperty(v,"enabled",{enumerable:!0,configurable:!1,get:()=>y!==null?y:(p!==r.namespaces&&(p=r.namespaces,T=r.enabled(u)),T),set:w=>{y=w}}),typeof r.init=="function"&&r.init(v),v}function n(u,f){let y=r(this.namespace+(typeof f>"u"?":":f)+u);return y.log=this.log,y}function o(u){r.save(u),r.namespaces=u,r.names=[],r.skips=[];let f,y=(typeof u=="string"?u:"").split(/[\s,]+/),p=y.length;for(f=0;f<p;f++)y[f]&&(u=y[f].replace(/\*/g,".*?"),u[0]==="-"?r.skips.push(new RegExp("^"+u.substr(1)+"$")):r.names.push(new RegExp("^"+u+"$")))}function i(){let u=[...r.names.map(a),...r.skips.map(a).map(f=>"-"+f)].join(",");return r.enable(""),u}function s(u){if(u[u.length-1]==="*")return!0;let f,y;for(f=0,y=r.skips.length;f<y;f++)if(r.skips[f].test(u))return!1;for(f=0,y=r.names.length;f<y;f++)if(r.names[f].test(u))return!0;return!1}function a(u){return u.toString().substring(2,u.toString().length-2).replace(/\.\*\?$/,"*")}function c(u){return u instanceof Error?u.stack??u.message:u}function l(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return r.setupFormatters(r.formatters),r.enable(r.load()),r}var hn=al(),el=["#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 rl(){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 nl(e){if(e[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+e[0]+(this.useColors?"%c ":" ")+"+"+dn(this.diff),!this.useColors)return;let t="color: "+this.color;e.splice(1,0,t,"color: inherit");let r=0,n=0;e[0].replace(/%[a-zA-Z%]/g,o=>{o!=="%%"&&(r++,o==="%c"&&(n=r))}),e.splice(n,0,t)}var ol=console.debug??console.log??(()=>{});function il(e){try{e?hn?.setItem("debug",e):hn?.removeItem("debug")}catch{}}function sl(){let e;try{e=hn?.getItem("debug")}catch{}return!e&&typeof globalThis.process<"u"&&"env"in globalThis.process&&(e=globalThis.process.env.DEBUG),e}function al(){try{return localStorage}catch{}}function cl(e){e.j=function(t){try{return JSON.stringify(t)}catch(r){return"[UnexpectedJSONParseError]: "+r.message}}}var Gs=ko({formatArgs:nl,save:il,load:sl,useColors:rl,setupFormatters:cl,colors:el,storage:hn,log:ol});var vt=Gs;vt.formatters.b=e=>e==null?"undefined":G.baseEncode(e);vt.formatters.t=e=>e==null?"undefined":Ft.baseEncode(e);vt.formatters.m=e=>e==null?"undefined":Lo.baseEncode(e);vt.formatters.p=e=>e==null?"undefined":e.toString();vt.formatters.c=e=>e==null?"undefined":e.toString();vt.formatters.k=e=>e==null?"undefined":e.toString();vt.formatters.a=e=>e==null?"undefined":e.toString();vt.formatters.e=e=>e==null?"undefined":Zs(e.stack)??Zs(e.message)??e.toString();function ul(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 he(e){let t=ul(`${e}:trace`);return vt.enabled(`${e}:trace`)&&vt.names.map(r=>r.toString()).find(r=>r.includes(":trace"))!=null&&(t=vt(`${e}:trace`)),Object.assign(vt(e),{error:vt(`${e}:error`),trace:t})}function Zs(e){if(e!=null&&(e=e.trim(),e.length!==0))return e}var Ko={};Et(Ko,{base36:()=>ze,base36upper:()=>fl});var ze=de({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),fl=de({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var ll=Xs,Ws=128,dl=127,hl=~dl,pl=Math.pow(2,31);function Xs(e,t,r){t=t||[],r=r||0;for(var n=r;e>=pl;)t[r++]=e&255|Ws,e/=128;for(;e&hl;)t[r++]=e&255|Ws,e>>>=7;return t[r]=e|0,Xs.bytes=r-n+1,t}var ml=Fo,yl=128,Ys=127;function Fo(e,n){var r=0,n=n||0,o=0,i=n,s,a=e.length;do{if(i>=a)throw Fo.bytes=0,new RangeError("Could not decode varint");s=e[i++],r+=o<28?(s&Ys)<<o:(s&Ys)*Math.pow(2,o),o+=7}while(s>=yl);return Fo.bytes=i-n,r}var gl=Math.pow(2,7),xl=Math.pow(2,14),wl=Math.pow(2,21),bl=Math.pow(2,28),El=Math.pow(2,35),Sl=Math.pow(2,42),vl=Math.pow(2,49),Al=Math.pow(2,56),Il=Math.pow(2,63),Tl=function(e){return e<gl?1:e<xl?2:e<wl?3:e<bl?4:e<El?5:e<Sl?6:e<vl?7:e<Al?8:e<Il?9:10},Bl={encode:ll,decode:ml,encodingLength:Tl},Cl=Bl,Ir=Cl;function Tr(e,t=0){return[Ir.decode(e,t),Ir.decode.bytes]}function je(e,t,r=0){return Ir.encode(e,t,r),t}function Ge(e){return Ir.encodingLength(e)}function Ot(e,t){let r=t.byteLength,n=Ge(e),o=n+Ge(r),i=new Uint8Array(o+r);return je(e,i,0),je(r,i,n),i.set(t,o),new Ze(e,r,t,i)}function re(e){let t=ee(e),[r,n]=Tr(t),[o,i]=Tr(t.subarray(n)),s=t.subarray(n+i);if(s.byteLength!==o)throw new Error("Incorrect length");return new Ze(r,o,s,t)}function Js(e,t){if(e===t)return!0;{let r=t;return e.code===r.code&&e.size===r.size&&r.bytes instanceof Uint8Array&&Vs(e.bytes,r.bytes)}}var Ze=class{code;size;digest;bytes;constructor(t,r,n,o){this.code=t,this.size=r,this.digest=n,this.bytes=o}};function Qs(e,t){let{bytes:r,version:n}=e;switch(n){case 0:return Pl(r,Oo(e),t??G.encoder);default:return Ul(r,Oo(e),t??Ft.encoder)}}var ta=new WeakMap;function Oo(e){let t=ta.get(e);if(t==null){let r=new Map;return ta.set(e,r),r}return t}var $=class e{code;version;multihash;bytes;"/";constructor(t,r,n,o){this.code=r,this.version=t,this.multihash=n,this.bytes=o,this["/"]=o}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:t,multihash:r}=this;if(t!==Br)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==Nl)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=Ot(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&&Js(t.multihash,n.multihash)}toString(t){return Qs(this,t)}toJSON(){return{"/":Qs(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??ea(n,o,i.bytes))}else if(r[Rl]===!0){let{version:n,multihash:o,code:i}=r,s=re(o);return e.create(n,i,s)}else return null}static create(t,r,n){if(typeof r!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(t){case 0:{if(r!==Br)throw new Error(`Version 0 CID must use dag-pb (code: ${Br}) block encoding`);return new e(t,r,n,n.bytes)}case 1:{let o=ea(t,r,n.bytes);return new e(t,r,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return e.create(0,Br,t)}static createV1(t,r){return e.create(1,t,r)}static decode(t){let[r,n]=e.decodeFirst(t);if(n.length!==0)throw new Error("Incorrect length");return r}static decodeFirst(t){let r=e.inspectBytes(t),n=r.size-r.multihashSize,o=ee(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 Ze(r.multihashCode,r.digestSize,i,o);return[r.version===0?e.createV0(s):e.createV1(r.codec,s),t.subarray(r.size)]}static inspectBytes(t){let r=0,n=()=>{let[f,y]=Tr(t.subarray(r));return r+=y,f},o=n(),i=Br;if(o===18?(o=0,r=0):i=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let s=r,a=n(),c=n(),l=r+c,u=l-s;return{version:o,codec:i,multihashCode:a,digestSize:c,multihashSize:u,size:l}}static parse(t,r){let[n,o]=_l(t,r),i=e.decode(o);if(i.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Oo(i).set(n,t),i}};function _l(e,t){switch(e[0]){case"Q":{let r=t??G;return[G.prefix,r.decode(`${G.prefix}${e}`)]}case G.prefix:{let r=t??G;return[G.prefix,r.decode(e)]}case Ft.prefix:{let r=t??Ft;return[Ft.prefix,r.decode(e)]}case ze.prefix:{let r=t??ze;return[ze.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 Pl(e,t,r){let{prefix:n}=r;if(n!==G.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);let o=t.get(n);if(o==null){let i=r.encode(e).slice(1);return t.set(n,i),i}else return o}function Ul(e,t,r){let{prefix:n}=r,o=t.get(n);if(o==null){let i=r.encode(e);return t.set(n,i),i}else return o}var Br=112,Nl=18;function ea(e,t,r){let n=Ge(e),o=n+Ge(t),i=new Uint8Array(o+r.byteLength);return je(e,i,0),je(t,i,n),i.set(r,o),i}var Rl=Symbol.for("@ipld/js-cid/CID");var Mo={};Et(Mo,{identity:()=>Bt});var ra=0,Ll="identity",na=ee;function Dl(e){return Ot(ra,na(e))}var Bt={code:ra,name:Ll,encode:na,digest:Dl};function Y(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}function ne(e=0){return new Uint8Array(e)}function At(e=0){return new Uint8Array(e)}function dt(e,t){t==null&&(t=e.reduce((o,i)=>o+i.length,0));let r=At(t),n=0;for(let o of e)r.set(o,n),n+=o.length;return r}var ia=Symbol.for("@achingbrain/uint8arraylist");function oa(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 We(e){return!!e?.[ia]}var Ct=class e{bufs;length;[ia]=!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(We(n))r+=n.byteLength,this.bufs.push(...n.bufs);else throw new Error("Could not append value, must be an Uint8Array or a Uint8ArrayList");this.length+=r}prepend(...t){this.prependAll(t)}prependAll(t){let r=0;for(let n of t.reverse())if(n instanceof Uint8Array)r+=n.byteLength,this.bufs.unshift(n);else if(We(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=oa(this.bufs,t);return r.buf[r.index]}set(t,r){let n=oa(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(We(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 dt(n,o)}subarray(t,r){let{bufs:n,length:o}=this._subList(t,r);return n.length===1?n[0]:dt(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 l=t>=a&&t<c,u=r>a&&r<=c;if(l&&u){if(t===a&&r===c){n.push(s);break}let f=t-a;n.push(s.subarray(f,f+(r-t)));break}if(l){if(t===0){n.push(s);continue}n.push(s.subarray(t-a));continue}if(u){if(r===c){n.push(s);break}n.push(s.subarray(0,r-a));break}n.push(s)}return{bufs:n,length:r-t}}indexOf(t,r=0){if(!We(t)&&!(t instanceof Uint8Array))throw new TypeError('The "value" argument must be a Uint8ArrayList or Uint8Array');let n=t instanceof Uint8Array?t:t.subarray();if(r=Number(r??0),isNaN(r)&&(r=0),r<0&&(r=this.length+r),r<0&&(r=0),t.length===0)return r>this.length?this.length:r;let o=n.byteLength;if(o===0)throw new TypeError("search must be at least 1 byte long");let i=256,s=new Int32Array(i);for(let f=0;f<i;f++)s[f]=-1;for(let f=0;f<o;f++)s[n[f]]=f;let a=s,c=this.byteLength-n.byteLength,l=n.byteLength-1,u;for(let f=r;f<=c;f+=u){u=0;for(let y=l;y>=0;y--){let p=this.get(f+y);if(n[y]!==p){u=Math.max(1,y-a[p]);break}}if(u===0)return f}return-1}getInt8(t){let r=this.subarray(t,t+1);return new DataView(r.buffer,r.byteOffset,r.byteLength).getInt8(0)}setInt8(t,r){let n=At(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=ne(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=ne(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=ne(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=At(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=ne(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=ne(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=ne(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=ne(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=ne(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat64(0,r,n),this.write(o,t)}equals(t){if(t==null||!(t instanceof e)||t.bufs.length!==this.bufs.length)return!1;for(let r=0;r<this.bufs.length;r++)if(!Y(this.bufs[r],t.bufs[r]))return!1;return!0}static fromUint8Arrays(t,r){let n=new e;return n.bufs=t,r==null&&(r=t.reduce((o,i)=>o+i.byteLength,0)),n.length=r,n}};var Vo={};Et(Vo,{base10:()=>kl});var kl=de({prefix:"9",name:"base10",alphabet:"0123456789"});var $o={};Et($o,{base16:()=>Kl,base16upper:()=>Fl});var Kl=tt({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Fl=tt({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var qo={};Et(qo,{base2:()=>Ol});var Ol=tt({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Ho={};Et(Ho,{base256emoji:()=>Hl});var sa=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}"),Ml=sa.reduce((e,t,r)=>(e[r]=t,e),[]),Vl=sa.reduce((e,t,r)=>{let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);return e[n]=r,e},[]);function $l(e){return e.reduce((t,r)=>(t+=Ml[r],t),"")}function ql(e){let t=[];for(let r of e){let n=r.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${r}`);let o=Vl[n];if(o==null)throw new Error(`Non-base256emoji character: ${r}`);t.push(o)}return new Uint8Array(t)}var Hl=He({prefix:"\u{1F680}",name:"base256emoji",encode:$l,decode:ql});var zo={};Et(zo,{base8:()=>zl});var zl=tt({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var jo={};Et(jo,{identity:()=>jl});var jl=He({prefix:"\0",name:"identity",encode:e=>qs(e),decode:e=>$s(e)});var rm=new TextEncoder,nm=new TextDecoder;var Wo={};Et(Wo,{sha256:()=>Cr,sha512:()=>Wl});function Zo({name:e,code:t,encode:r}){return new Go(e,t,r)}var Go=class{name;code;encode;constructor(t,r,n){this.name=t,this.code=r,this.encode=n}digest(t){if(t instanceof Uint8Array){let r=this.encode(t);return r instanceof Uint8Array?Ot(this.code,r):r.then(n=>Ot(this.code,n))}else throw Error("Unknown type, must be binary type")}};function ca(e){return async t=>new Uint8Array(await crypto.subtle.digest(e,t))}var Cr=Zo({name:"sha2-256",code:18,encode:ca("SHA-256")}),Wl=Zo({name:"sha2-512",code:19,encode:ca("SHA-512")});var _r={...jo,...qo,...zo,...Vo,...$o,...No,...Ko,...Ro,...Do,...Ho},mm={...Wo,...Mo};function fa(e,t,r,n){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:n}}}var ua=fa("utf8","u",e=>"u"+new TextDecoder("utf8").decode(e),e=>new TextEncoder().encode(e.substring(1))),Yo=fa("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=At(e.length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t}),Yl={utf8:ua,"utf-8":ua,hex:_r.base16,latin1:Yo,ascii:Yo,binary:Yo,..._r},mn=Yl;function V(e,t="utf8"){let r=mn[t];if(r==null)throw new Error(`Unsupported encoding "${t}"`);return r.decoder.decode(`${r.prefix}${e}`)}function M(e,t="utf8"){let r=mn[t];if(r==null)throw new Error(`Unsupported encoding "${t}"`);return r.encoder.encode(e).substring(1)}var Xl=parseInt("11111",2),Xo=parseInt("10000000",2),Jl=parseInt("01111111",2),la={0:Pr,1:Pr,2:Ql,3:rd,4:nd,5:ed,6:td,16:Pr,22:Pr,48:Pr};function oe(e,t={offset:0}){let r=e[t.offset]&Xl;if(t.offset++,la[r]!=null)return la[r](e,t);throw new Error("No decoder for tag "+r)}function Ur(e,t){let r=0;if((e[t.offset]&Xo)===Xo){let n=e[t.offset]&Jl,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 Pr(e,t){Ur(e,t);let r=[];for(;!(t.offset>=e.byteLength);){let n=oe(e,t);if(n===null)break;r.push(n)}return r}function Ql(e,t){let r=Ur(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 td(e,t){let r=Ur(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 l=e[t.offset];if(t.offset++,c.push(l&127),l<128){c.reverse();let u=0;for(let f=0;f<c.length;f++)u+=c[f]<<f*7;a+=`.${u}`,c=[]}}return a}function ed(e,t){return t.offset++,null}function rd(e,t){let r=Ur(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 nd(e,t){let r=Ur(e,t),n=e.subarray(t.offset,t.offset+r);return t.offset+=r,n}function od(e){let t=e.toString(16);t.length%2===1&&(t="0"+t);let r=new Ct;for(let n=0;n<t.length;n+=2)r.append(Uint8Array.from([parseInt(`${t[n]}${t[n+1]}`,16)]));return r}function Jo(e){if(e.byteLength<128)return Uint8Array.from([e.byteLength]);let t=od(e.byteLength);return new Ct(Uint8Array.from([t.byteLength|Xo]),t)}function It(e){let t=new Ct,r=128;return(e.subarray()[0]&r)===r&&t.append(Uint8Array.from([0])),t.append(e),new Ct(Uint8Array.from([2]),Jo(t),t)}function yn(e){let t=Uint8Array.from([0]),r=new Ct(t,e);return new Ct(Uint8Array.from([3]),Jo(r),r)}function me(e,t=48){let r=new Ct;for(let n of e)r.append(n);return new Ct(Uint8Array.from([t]),Jo(r),r)}async function da(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 id=Uint8Array.from([6,8,42,134,72,206,61,3,1,7]),sd=Uint8Array.from([6,5,43,129,4,0,34]),ad=Uint8Array.from([6,5,43,129,4,0,35]),cd={ext:!0,kty:"EC",crv:"P-256"},ud={ext:!0,kty:"EC",crv:"P-384"},fd={ext:!0,kty:"EC",crv:"P-521"},Qo=32,ti=48,ei=66;function ri(e){let t=oe(e);return ha(t)}function ha(e){let t=e[1][1][0],r=1,n,o;if(t.byteLength===Qo*2+1)return n=M(t.subarray(r,r+Qo),"base64url"),o=M(t.subarray(r+Qo),"base64url"),new Ye({...cd,key_ops:["verify"],x:n,y:o});if(t.byteLength===ti*2+1)return n=M(t.subarray(r,r+ti),"base64url"),o=M(t.subarray(r+ti),"base64url"),new Ye({...ud,key_ops:["verify"],x:n,y:o});if(t.byteLength===ei*2+1)return n=M(t.subarray(r,r+ei),"base64url"),o=M(t.subarray(r+ei),"base64url"),new Ye({...fd,key_ops:["verify"],x:n,y:o});throw new nt(`coordinates were wrong length, got ${t.byteLength}, expected 65, 97 or 133`)}function pa(e){return me([It(Uint8Array.from([1])),me([ld(e.crv)],160),me([yn(new Ct(Uint8Array.from([4]),V(e.x??"","base64url"),V(e.y??"","base64url")))],161)]).subarray()}function ld(e){if(e==="P-256")return id;if(e==="P-384")return sd;if(e==="P-521")return ad;throw new nt(`Invalid curve ${e}`)}var Ye=class{type="ECDSA";jwk;_raw;constructor(t){this.jwk=t}get raw(){return this._raw==null&&(this._raw=pa(this.jwk)),this._raw}toMultihash(){return Bt.digest(Xe(this))}toCID(){return $.createV1(114,this.toMultihash())}toString(){return G.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:Y(this.raw,t.raw)}async verify(t,r,n){return da(this.jwk,r,t,n)}};var Te=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function Qe(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Nr(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function ht(e,...t){if(!Qe(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function ya(e){if(typeof e!="function"||typeof e.create!="function")throw new Error("Hash should be wrapped by utils.createHasher");Nr(e.outputLen),Nr(e.blockLen)}function tr(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 ga(e,t){ht(e);let r=t.outputLen;if(e.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}function se(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function gn(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function Mt(e,t){return e<<32-t|e>>>t}var xa=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",dd=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Wt(e){if(ht(e),xa)return e.toHex();let t="";for(let r=0;r<e.length;r++)t+=dd[e[r]];return t}var ie={_0:48,_9:57,A:65,F:70,a:97,f:102};function ma(e){if(e>=ie._0&&e<=ie._9)return e-ie._0;if(e>=ie.A&&e<=ie.F)return e-(ie.A-10);if(e>=ie.a&&e<=ie.f)return e-(ie.a-10)}function er(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);if(xa)return Uint8Array.fromHex(e);let t=e.length,r=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);let n=new Uint8Array(r);for(let o=0,i=0;o<r;o++,i+=2){let s=ma(e.charCodeAt(i)),a=ma(e.charCodeAt(i+1));if(s===void 0||a===void 0){let c=e[i]+e[i+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+i)}n[o]=s*16+a}return n}function wa(e){if(typeof e!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(e))}function Rr(e){return typeof e=="string"&&(e=wa(e)),ht(e),e}function _t(...e){let t=0;for(let n=0;n<e.length;n++){let o=e[n];ht(o),t+=o.length}let r=new Uint8Array(t);for(let n=0,o=0;n<e.length;n++){let i=e[n];r.set(i,o),o+=i.length}return r}var Je=class{};function ni(e){let t=n=>e().update(Rr(n)).digest(),r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>e(),t}function Lr(e=32){if(Te&&typeof Te.getRandomValues=="function")return Te.getRandomValues(new Uint8Array(e));if(Te&&typeof Te.randomBytes=="function")return Uint8Array.from(Te.randomBytes(e));throw new Error("crypto.getRandomValues must be defined")}function hd(e,t,r,n){if(typeof e.setBigUint64=="function")return e.setBigUint64(t,r,n);let o=BigInt(32),i=BigInt(4294967295),s=Number(r>>o&i),a=Number(r&i),c=n?4:0,l=n?0:4;e.setUint32(t+c,s,n),e.setUint32(t+l,a,n)}function ba(e,t,r){return e&t^~e&r}function Ea(e,t,r){return e&t^e&r^t&r}var Dr=class extends Je{constructor(t,r,n,o){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=t,this.outputLen=r,this.padOffset=n,this.isLE=o,this.buffer=new Uint8Array(t),this.view=gn(this.buffer)}update(t){tr(this),t=Rr(t),ht(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=gn(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){tr(this),ga(t,this),this.finished=!0;let{buffer:r,view:n,blockLen:o,isLE:i}=this,{pos:s}=this;r[s++]=128,se(this.buffer.subarray(s)),this.padOffset>o-s&&(this.process(n,0),s=0);for(let f=s;f<o;f++)r[f]=0;hd(n,o-8,BigInt(this.length*8),i),this.process(n,0);let a=gn(t),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let l=c/4,u=this.get();if(l>u.length)throw new Error("_sha2: outputLen bigger than state");for(let f=0;f<l;f++)a.setUint32(4*f,u[f],i)}digest(){let{buffer:t,outputLen:r}=this;this.digestInto(t);let n=t.slice(0,r);return this.destroy(),n}_cloneInto(t){t||(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()}},ae=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var ct=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]);var xn=BigInt(4294967295),Sa=BigInt(32);function pd(e,t=!1){return t?{h:Number(e&xn),l:Number(e>>Sa&xn)}:{h:Number(e>>Sa&xn)|0,l:Number(e&xn)|0}}function va(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}=pd(e[i],t);[n[i],o[i]]=[s,a]}return[n,o]}var oi=(e,t,r)=>e>>>r,ii=(e,t,r)=>e<<32-r|t>>>r,Be=(e,t,r)=>e>>>r|t<<32-r,Ce=(e,t,r)=>e<<32-r|t>>>r,kr=(e,t,r)=>e<<64-r|t>>>r-32,Kr=(e,t,r)=>e>>>r-32|t<<64-r;function Yt(e,t,r,n){let o=(t>>>0)+(n>>>0);return{h:e+r+(o/2**32|0)|0,l:o|0}}var Aa=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0),Ia=(e,t,r,n)=>t+r+n+(e/2**32|0)|0,Ta=(e,t,r,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0),Ba=(e,t,r,n,o)=>t+r+n+o+(e/2**32|0)|0,Ca=(e,t,r,n,o)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0)+(o>>>0),_a=(e,t,r,n,o,i)=>t+r+n+o+i+(e/2**32|0)|0;var yd=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),ye=new Uint32Array(64),wn=class extends Dr{constructor(t=32){super(64,t,8,!1),this.A=ae[0]|0,this.B=ae[1]|0,this.C=ae[2]|0,this.D=ae[3]|0,this.E=ae[4]|0,this.F=ae[5]|0,this.G=ae[6]|0,this.H=ae[7]|0}get(){let{A:t,B:r,C:n,D:o,E:i,F:s,G:a,H:c}=this;return[t,r,n,o,i,s,a,c]}set(t,r,n,o,i,s,a,c){this.A=t|0,this.B=r|0,this.C=n|0,this.D=o|0,this.E=i|0,this.F=s|0,this.G=a|0,this.H=c|0}process(t,r){for(let f=0;f<16;f++,r+=4)ye[f]=t.getUint32(r,!1);for(let f=16;f<64;f++){let y=ye[f-15],p=ye[f-2],T=Mt(y,7)^Mt(y,18)^y>>>3,v=Mt(p,17)^Mt(p,19)^p>>>10;ye[f]=v+ye[f-7]+T+ye[f-16]|0}let{A:n,B:o,C:i,D:s,E:a,F:c,G:l,H:u}=this;for(let f=0;f<64;f++){let y=Mt(a,6)^Mt(a,11)^Mt(a,25),p=u+y+ba(a,c,l)+yd[f]+ye[f]|0,v=(Mt(n,2)^Mt(n,13)^Mt(n,22))+Ea(n,o,i)|0;u=l,l=c,c=a,a=s+p|0,s=i,i=o,o=n,n=p+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,l=l+this.G|0,u=u+this.H|0,this.set(n,o,i,s,a,c,l,u)}roundClean(){se(ye)}destroy(){this.set(0,0,0,0,0,0,0,0),se(this.buffer)}};var Pa=va(["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))),gd=Pa[0],xd=Pa[1],ge=new Uint32Array(80),xe=new Uint32Array(80),si=class extends Dr{constructor(t=64){super(128,t,16,!1),this.Ah=ct[0]|0,this.Al=ct[1]|0,this.Bh=ct[2]|0,this.Bl=ct[3]|0,this.Ch=ct[4]|0,this.Cl=ct[5]|0,this.Dh=ct[6]|0,this.Dl=ct[7]|0,this.Eh=ct[8]|0,this.El=ct[9]|0,this.Fh=ct[10]|0,this.Fl=ct[11]|0,this.Gh=ct[12]|0,this.Gl=ct[13]|0,this.Hh=ct[14]|0,this.Hl=ct[15]|0}get(){let{Ah:t,Al:r,Bh:n,Bl:o,Ch:i,Cl:s,Dh:a,Dl:c,Eh:l,El:u,Fh:f,Fl:y,Gh:p,Gl:T,Hh:v,Hl:w}=this;return[t,r,n,o,i,s,a,c,l,u,f,y,p,T,v,w]}set(t,r,n,o,i,s,a,c,l,u,f,y,p,T,v,w){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=l|0,this.El=u|0,this.Fh=f|0,this.Fl=y|0,this.Gh=p|0,this.Gl=T|0,this.Hh=v|0,this.Hl=w|0}process(t,r){for(let P=0;P<16;P++,r+=4)ge[P]=t.getUint32(r),xe[P]=t.getUint32(r+=4);for(let P=16;P<80;P++){let K=ge[P-15]|0,E=xe[P-15]|0,N=Be(K,E,1)^Be(K,E,8)^oi(K,E,7),R=Ce(K,E,1)^Ce(K,E,8)^ii(K,E,7),g=ge[P-2]|0,d=xe[P-2]|0,x=Be(g,d,19)^kr(g,d,61)^oi(g,d,6),h=Ce(g,d,19)^Kr(g,d,61)^ii(g,d,6),m=Ta(R,h,xe[P-7],xe[P-16]),S=Ba(m,N,x,ge[P-7],ge[P-16]);ge[P]=S|0,xe[P]=m|0}let{Ah:n,Al:o,Bh:i,Bl:s,Ch:a,Cl:c,Dh:l,Dl:u,Eh:f,El:y,Fh:p,Fl:T,Gh:v,Gl:w,Hh:C,Hl:U}=this;for(let P=0;P<80;P++){let K=Be(f,y,14)^Be(f,y,18)^kr(f,y,41),E=Ce(f,y,14)^Ce(f,y,18)^Kr(f,y,41),N=f&p^~f&v,R=y&T^~y&w,g=Ca(U,E,R,xd[P],xe[P]),d=_a(g,C,K,N,gd[P],ge[P]),x=g|0,h=Be(n,o,28)^kr(n,o,34)^kr(n,o,39),m=Ce(n,o,28)^Kr(n,o,34)^Kr(n,o,39),S=n&i^n&a^i&a,I=o&s^o&c^s&c;C=v|0,U=w|0,v=p|0,w=T|0,p=f|0,T=y|0,{h:f,l:y}=Yt(l|0,u|0,d|0,x|0),l=a|0,u=c|0,a=i|0,c=s|0,i=n|0,s=o|0;let A=Aa(x,m,I);n=Ia(A,d,h,S),o=A|0}({h:n,l:o}=Yt(this.Ah|0,this.Al|0,n|0,o|0)),{h:i,l:s}=Yt(this.Bh|0,this.Bl|0,i|0,s|0),{h:a,l:c}=Yt(this.Ch|0,this.Cl|0,a|0,c|0),{h:l,l:u}=Yt(this.Dh|0,this.Dl|0,l|0,u|0),{h:f,l:y}=Yt(this.Eh|0,this.El|0,f|0,y|0),{h:p,l:T}=Yt(this.Fh|0,this.Fl|0,p|0,T|0),{h:v,l:w}=Yt(this.Gh|0,this.Gl|0,v|0,w|0),{h:C,l:U}=Yt(this.Hh|0,this.Hl|0,C|0,U|0),this.set(n,o,i,s,a,c,l,u,f,y,p,T,v,w,C,U)}roundClean(){se(ge,xe)}destroy(){se(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};var bn=ni(()=>new wn);var Ua=ni(()=>new si);var ui=BigInt(0),ci=BigInt(1);function ce(e,t){if(typeof t!="boolean")throw new Error(e+" boolean expected, got "+t)}function Fr(e){let t=e.toString(16);return t.length&1?"0"+t:t}function Na(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);return e===""?ui:BigInt("0x"+e)}function rr(e){return Na(Wt(e))}function _e(e){return ht(e),Na(Wt(Uint8Array.from(e).reverse()))}function En(e,t){return er(e.toString(16).padStart(t*2,"0"))}function nr(e,t){return En(e,t).reverse()}function X(e,t,r){let n;if(typeof t=="string")try{n=er(t)}catch(i){throw new Error(e+" must be hex string or Uint8Array, cause: "+i)}else if(Qe(t))n=Uint8Array.from(t);else throw new Error(e+" must be hex string or Uint8Array");let o=n.length;if(typeof r=="number"&&o!==r)throw new Error(e+" of length "+r+" expected, got "+o);return n}var ai=e=>typeof e=="bigint"&&ui<=e;function Ra(e,t,r){return ai(e)&&ai(t)&&ai(r)&&t<=e&&e<r}function we(e,t,r,n){if(!Ra(t,r,n))throw new Error("expected valid "+e+": "+r+" <= n < "+n+", got "+t)}function La(e){let t;for(t=0;e>ui;e>>=ci,t+=1);return t}var Pe=e=>(ci<<BigInt(e))-ci;function Da(e,t,r){if(typeof e!="number"||e<2)throw new Error("hashLen must be a number");if(typeof t!="number"||t<2)throw new Error("qByteLen must be a number");if(typeof r!="function")throw new Error("hmacFn must be a function");let n=p=>new Uint8Array(p),o=p=>Uint8Array.of(p),i=n(e),s=n(e),a=0,c=()=>{i.fill(1),s.fill(0),a=0},l=(...p)=>r(s,i,...p),u=(p=n(0))=>{s=l(o(0),p),i=l(),p.length!==0&&(s=l(o(1),p),i=l())},f=()=>{if(a++>=1e3)throw new Error("drbg: tried 1000 values");let p=0,T=[];for(;p<t;){i=l();let v=i.slice();T.push(v),p+=i.length}return _t(...T)};return(p,T)=>{c(),u(p);let v;for(;!(v=T(f()));)u();return c(),v}}function be(e,t,r={}){if(!e||typeof e!="object")throw new Error("expected valid options object");function n(o,i,s){let a=e[o];if(s&&a===void 0)return;let c=typeof a;if(c!==i||a===null)throw new Error(`param "${o}" is invalid: expected ${i}, got ${c}`)}Object.entries(t).forEach(([o,i])=>n(o,i,!1)),Object.entries(r).forEach(([o,i])=>n(o,i,!0))}function or(e){let t=new WeakMap;return(r,...n)=>{let o=t.get(r);if(o!==void 0)return o;let i=e(r,...n);return t.set(r,i),i}}var xt=BigInt(0),st=BigInt(1),Ue=BigInt(2),wd=BigInt(3),Fa=BigInt(4),Oa=BigInt(5),Ma=BigInt(8);function Q(e,t){let r=e%t;return r>=xt?r:t+r}function J(e,t,r){let n=e;for(;t-- >xt;)n*=n,n%=r;return n}function ka(e,t){if(e===xt)throw new Error("invert: expected non-zero number");if(t<=xt)throw new Error("invert: expected positive modulus, got "+t);let r=Q(e,t),n=t,o=xt,i=st,s=st,a=xt;for(;r!==xt;){let l=n/r,u=n%r,f=o-s*l,y=i-a*l;n=r,r=u,o=s,i=a,s=f,a=y}if(n!==st)throw new Error("invert: does not exist");return Q(o,t)}function Va(e,t){let r=(e.ORDER+st)/Fa,n=e.pow(t,r);if(!e.eql(e.sqr(n),t))throw new Error("Cannot find square root");return n}function bd(e,t){let r=(e.ORDER-Oa)/Ma,n=e.mul(t,Ue),o=e.pow(n,r),i=e.mul(t,o),s=e.mul(e.mul(i,Ue),o),a=e.mul(i,e.sub(s,e.ONE));if(!e.eql(e.sqr(a),t))throw new Error("Cannot find square root");return a}function Ed(e){if(e<BigInt(3))throw new Error("sqrt is not defined for small field");let t=e-st,r=0;for(;t%Ue===xt;)t/=Ue,r++;let n=Ue,o=Vt(e);for(;Ka(o,n)===1;)if(n++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(r===1)return Va;let i=o.pow(n,t),s=(t+st)/Ue;return function(c,l){if(c.is0(l))return l;if(Ka(c,l)!==1)throw new Error("Cannot find square root");let u=r,f=c.mul(c.ONE,i),y=c.pow(l,t),p=c.pow(l,s);for(;!c.eql(y,c.ONE);){if(c.is0(y))return c.ZERO;let T=1,v=c.sqr(y);for(;!c.eql(v,c.ONE);)if(T++,v=c.sqr(v),T===u)throw new Error("Cannot find square root");let w=st<<BigInt(u-T-1),C=c.pow(f,w);u=T,f=c.sqr(C),y=c.mul(y,f),p=c.mul(p,C)}return p}}function Sd(e){return e%Fa===wd?Va:e%Ma===Oa?bd:Ed(e)}var $a=(e,t)=>(Q(e,t)&st)===st,vd=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function fi(e){let t={ORDER:"bigint",MASK:"bigint",BYTES:"number",BITS:"number"},r=vd.reduce((n,o)=>(n[o]="function",n),t);return be(e,r),e}function Ad(e,t,r){if(r<xt)throw new Error("invalid exponent, negatives unsupported");if(r===xt)return e.ONE;if(r===st)return t;let n=e.ONE,o=t;for(;r>xt;)r&st&&(n=e.mul(n,o)),o=e.sqr(o),r>>=st;return n}function Or(e,t,r=!1){let n=new Array(t.length).fill(r?e.ZERO:void 0),o=t.reduce((s,a,c)=>e.is0(a)?s:(n[c]=s,e.mul(s,a)),e.ONE),i=e.inv(o);return t.reduceRight((s,a,c)=>e.is0(a)?s:(n[c]=e.mul(s,n[c]),e.mul(s,a)),i),n}function Ka(e,t){let r=(e.ORDER-st)/Ue,n=e.pow(t,r),o=e.eql(n,e.ONE),i=e.eql(n,e.ZERO),s=e.eql(n,e.neg(e.ONE));if(!o&&!i&&!s)throw new Error("invalid Legendre symbol result");return o?1:i?0:-1}function qa(e,t){t!==void 0&&Nr(t);let r=t!==void 0?t:e.toString(2).length,n=Math.ceil(r/8);return{nBitLength:r,nByteLength:n}}function Vt(e,t,r=!1,n={}){if(e<=xt)throw new Error("invalid field: expected ORDER > 0, got "+e);let o,i;if(typeof t=="object"&&t!=null){if(n.sqrt||r)throw new Error("cannot specify opts in two arguments");let u=t;u.BITS&&(o=u.BITS),u.sqrt&&(i=u.sqrt),typeof u.isLE=="boolean"&&(r=u.isLE)}else typeof t=="number"&&(o=t),n.sqrt&&(i=n.sqrt);let{nBitLength:s,nByteLength:a}=qa(e,o);if(a>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let c,l=Object.freeze({ORDER:e,isLE:r,BITS:s,BYTES:a,MASK:Pe(s),ZERO:xt,ONE:st,create:u=>Q(u,e),isValid:u=>{if(typeof u!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof u);return xt<=u&&u<e},is0:u=>u===xt,isValidNot0:u=>!l.is0(u)&&l.isValid(u),isOdd:u=>(u&st)===st,neg:u=>Q(-u,e),eql:(u,f)=>u===f,sqr:u=>Q(u*u,e),add:(u,f)=>Q(u+f,e),sub:(u,f)=>Q(u-f,e),mul:(u,f)=>Q(u*f,e),pow:(u,f)=>Ad(l,u,f),div:(u,f)=>Q(u*ka(f,e),e),sqrN:u=>u*u,addN:(u,f)=>u+f,subN:(u,f)=>u-f,mulN:(u,f)=>u*f,inv:u=>ka(u,e),sqrt:i||(u=>(c||(c=Sd(e)),c(l,u))),toBytes:u=>r?nr(u,a):En(u,a),fromBytes:u=>{if(u.length!==a)throw new Error("Field.fromBytes: expected "+a+" bytes, got "+u.length);return r?_e(u):rr(u)},invertBatch:u=>Or(l,u),cmov:(u,f,y)=>y?f:u});return Object.freeze(l)}function Ha(e){if(typeof e!="bigint")throw new Error("field order must be bigint");let t=e.toString(2).length;return Math.ceil(t/8)}function li(e){let t=Ha(e);return t+Math.ceil(t/2)}function za(e,t,r=!1){let n=e.length,o=Ha(t),i=li(t);if(n<16||n<i||n>1024)throw new Error("expected "+i+"-1024 bytes of input, got "+n);let s=r?_e(e):rr(e),a=Q(s,t-st)+st;return r?nr(a,o):En(a,o)}var sr=BigInt(0),Ne=BigInt(1);function ir(e,t){let r=t.negate();return e?r:t}function Sn(e,t,r){let n=t==="pz"?s=>s.pz:s=>s.ez,o=Or(e.Fp,r.map(n));return r.map((s,a)=>s.toAffine(o[a])).map(e.fromAffine)}function Wa(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+e)}function di(e,t){Wa(e,t);let r=Math.ceil(t/e)+1,n=2**(e-1),o=2**e,i=Pe(e),s=BigInt(e);return{windows:r,windowSize:n,mask:i,maxNumber:o,shiftBy:s}}function ja(e,t,r){let{windowSize:n,mask:o,maxNumber:i,shiftBy:s}=r,a=Number(e&o),c=e>>s;a>n&&(a-=i,c+=Ne);let l=t*n,u=l+Math.abs(a)-1,f=a===0,y=a<0,p=t%2!==0;return{nextN:c,offset:u,isZero:f,isNeg:y,isNegF:p,offsetF:l}}function Id(e,t){if(!Array.isArray(e))throw new Error("array expected");e.forEach((r,n)=>{if(!(r instanceof t))throw new Error("invalid point at index "+n)})}function Td(e,t){if(!Array.isArray(e))throw new Error("array of scalars expected");e.forEach((r,n)=>{if(!t.isValid(r))throw new Error("invalid scalar at index "+n)})}var hi=new WeakMap,Ya=new WeakMap;function pi(e){return Ya.get(e)||1}function Ga(e){if(e!==sr)throw new Error("invalid wNAF")}function vn(e,t){return{constTimeNegate:ir,hasPrecomputes(r){return pi(r)!==1},unsafeLadder(r,n,o=e.ZERO){let i=r;for(;n>sr;)n&Ne&&(o=o.add(i)),i=i.double(),n>>=Ne;return o},precomputeWindow(r,n){let{windows:o,windowSize:i}=di(n,t),s=[],a=r,c=a;for(let l=0;l<o;l++){c=a,s.push(c);for(let u=1;u<i;u++)c=c.add(a),s.push(c);a=c.double()}return s},wNAF(r,n,o){let i=e.ZERO,s=e.BASE,a=di(r,t);for(let c=0;c<a.windows;c++){let{nextN:l,offset:u,isZero:f,isNeg:y,isNegF:p,offsetF:T}=ja(o,c,a);o=l,f?s=s.add(ir(p,n[T])):i=i.add(ir(y,n[u]))}return Ga(o),{p:i,f:s}},wNAFUnsafe(r,n,o,i=e.ZERO){let s=di(r,t);for(let a=0;a<s.windows&&o!==sr;a++){let{nextN:c,offset:l,isZero:u,isNeg:f}=ja(o,a,s);if(o=c,!u){let y=n[l];i=i.add(f?y.negate():y)}}return Ga(o),i},getPrecomputes(r,n,o){let i=hi.get(n);return i||(i=this.precomputeWindow(n,r),r!==1&&(typeof o=="function"&&(i=o(i)),hi.set(n,i))),i},wNAFCached(r,n,o){let i=pi(r);return this.wNAF(i,this.getPrecomputes(i,r,o),n)},wNAFCachedUnsafe(r,n,o,i){let s=pi(r);return s===1?this.unsafeLadder(r,n,i):this.wNAFUnsafe(s,this.getPrecomputes(s,r,o),n,i)},setWindowSize(r,n){Wa(n,t),Ya.set(r,n),hi.delete(r)}}}function Xa(e,t,r,n){let o=t,i=e.ZERO,s=e.ZERO;for(;r>sr||n>sr;)r&Ne&&(i=i.add(o)),n&Ne&&(s=s.add(o)),o=o.double(),r>>=Ne,n>>=Ne;return{p1:i,p2:s}}function An(e,t,r,n){Id(r,e),Td(n,t);let o=r.length,i=n.length;if(o!==i)throw new Error("arrays of points and scalars must have equal length");let s=e.ZERO,a=La(BigInt(o)),c=1;a>12?c=a-3:a>4?c=a-2:a>0&&(c=2);let l=Pe(c),u=new Array(Number(l)+1).fill(s),f=Math.floor((t.BITS-1)/c)*c,y=s;for(let p=f;p>=0;p-=c){u.fill(s);for(let v=0;v<i;v++){let w=n[v],C=Number(w>>BigInt(p)&l);u[C]=u[C].add(r[v])}let T=s;for(let v=u.length-1,w=s;v>0;v--)w=w.add(u[v]),T=T.add(w);if(y=y.add(T),p!==0)for(let v=0;v<c;v++)y=y.double()}return y}function Za(e,t){if(t){if(t.ORDER!==e)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return fi(t),t}else return Vt(e)}function In(e,t,r={}){if(!t||typeof t!="object")throw new Error(`expected valid ${e} CURVE object`);for(let a of["p","n","h"]){let c=t[a];if(!(typeof c=="bigint"&&c>sr))throw new Error(`CURVE.${a} must be positive bigint`)}let n=Za(t.p,r.Fp),o=Za(t.n,r.Fn),s=["Gx","Gy","a",e==="weierstrass"?"b":"d"];for(let a of s)if(!n.isValid(t[a]))throw new Error(`CURVE.${a} must be valid field element of CURVE.Fp`);return{Fp:n,Fn:o}}var Xt=BigInt(0),wt=BigInt(1),mi=BigInt(2),Bd=BigInt(8),Cd={zip215:!0};function _d(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 Pd(e,t={}){let{Fp:r,Fn:n}=In("edwards",e,t),{h:o,n:i}=e;be(t,{},{uvRatio:"function"});let s=mi<<BigInt(n.BYTES*8)-wt,a=v=>r.create(v),c=t.uvRatio||((v,w)=>{try{return{isValid:!0,value:r.sqrt(r.div(v,w))}}catch{return{isValid:!1,value:Xt}}});if(!_d(r,e,e.Gx,e.Gy))throw new Error("bad curve params: generator point");function l(v,w,C=!1){let U=C?wt:Xt;return we("coordinate "+v,w,U,s),w}function u(v){if(!(v instanceof p))throw new Error("ExtendedPoint expected")}let f=or((v,w)=>{let{ex:C,ey:U,ez:P}=v,K=v.is0();w==null&&(w=K?Bd:r.inv(P));let E=a(C*w),N=a(U*w),R=a(P*w);if(K)return{x:Xt,y:wt};if(R!==wt)throw new Error("invZ was invalid");return{x:E,y:N}}),y=or(v=>{let{a:w,d:C}=e;if(v.is0())throw new Error("bad point: ZERO");let{ex:U,ey:P,ez:K,et:E}=v,N=a(U*U),R=a(P*P),g=a(K*K),d=a(g*g),x=a(N*w),h=a(g*a(x+R)),m=a(d+a(C*a(N*R)));if(h!==m)throw new Error("bad point: equation left != right (1)");let S=a(U*P),I=a(K*E);if(S!==I)throw new Error("bad point: equation left != right (2)");return!0});class p{constructor(w,C,U,P){this.ex=l("x",w),this.ey=l("y",C),this.ez=l("z",U,!0),this.et=l("t",P),Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(w){if(w instanceof p)throw new Error("extended point not allowed");let{x:C,y:U}=w||{};return l("x",C),l("y",U),new p(C,U,wt,a(C*U))}static normalizeZ(w){return Sn(p,"ez",w)}static msm(w,C){return An(p,n,w,C)}_setWindowSize(w){this.precompute(w)}precompute(w=8,C=!0){return T.setWindowSize(this,w),C||this.multiply(mi),this}assertValidity(){y(this)}equals(w){u(w);let{ex:C,ey:U,ez:P}=this,{ex:K,ey:E,ez:N}=w,R=a(C*N),g=a(K*P),d=a(U*N),x=a(E*P);return R===g&&d===x}is0(){return this.equals(p.ZERO)}negate(){return new p(a(-this.ex),this.ey,this.ez,a(-this.et))}double(){let{a:w}=e,{ex:C,ey:U,ez:P}=this,K=a(C*C),E=a(U*U),N=a(mi*a(P*P)),R=a(w*K),g=C+U,d=a(a(g*g)-K-E),x=R+E,h=x-N,m=R-E,S=a(d*h),I=a(x*m),A=a(d*m),B=a(h*x);return new p(S,I,B,A)}add(w){u(w);let{a:C,d:U}=e,{ex:P,ey:K,ez:E,et:N}=this,{ex:R,ey:g,ez:d,et:x}=w,h=a(P*R),m=a(K*g),S=a(N*U*x),I=a(E*d),A=a((P+K)*(R+g)-h-m),B=I-S,k=I+S,D=a(m-C*h),j=a(A*B),z=a(k*D),O=a(A*D),rt=a(B*k);return new p(j,z,rt,O)}subtract(w){return this.add(w.negate())}multiply(w){let C=w;we("scalar",C,wt,i);let{p:U,f:P}=T.wNAFCached(this,C,p.normalizeZ);return p.normalizeZ([U,P])[0]}multiplyUnsafe(w,C=p.ZERO){let U=w;return we("scalar",U,Xt,i),U===Xt?p.ZERO:this.is0()||U===wt?this:T.wNAFCachedUnsafe(this,U,p.normalizeZ,C)}isSmallOrder(){return this.multiplyUnsafe(o).is0()}isTorsionFree(){return T.wNAFCachedUnsafe(this,i).is0()}toAffine(w){return f(this,w)}clearCofactor(){return o===wt?this:this.multiplyUnsafe(o)}static fromBytes(w,C=!1){return ht(w),this.fromHex(w,C)}static fromHex(w,C=!1){let{d:U,a:P}=e,K=r.BYTES;w=X("pointHex",w,K),ce("zip215",C);let E=w.slice(),N=w[K-1];E[K-1]=N&-129;let R=_e(E),g=C?s:r.ORDER;we("pointHex.y",R,Xt,g);let d=a(R*R),x=a(d-wt),h=a(U*d-P),{isValid:m,value:S}=c(x,h);if(!m)throw new Error("Point.fromHex: invalid y coordinate");let I=(S&wt)===wt,A=(N&128)!==0;if(!C&&S===Xt&&A)throw new Error("Point.fromHex: x=0 and x_0=1");return A!==I&&(S=a(-S)),p.fromAffine({x:S,y:R})}static fromPrivateScalar(w){return p.BASE.multiply(w)}toBytes(){let{x:w,y:C}=this.toAffine(),U=nr(C,r.BYTES);return U[U.length-1]|=w&wt?128:0,U}toRawBytes(){return this.toBytes()}toHex(){return Wt(this.toBytes())}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}p.BASE=new p(e.Gx,e.Gy,wt,a(e.Gx*e.Gy)),p.ZERO=new p(Xt,wt,wt,Xt),p.Fp=r,p.Fn=n;let T=vn(p,n.BYTES*8);return p}function Ud(e,t){be(t,{hash:"function"},{adjustScalarBytes:"function",randomBytes:"function",domain:"function",prehash:"function",mapToCurve:"function"});let{prehash:r,hash:n}=t,{BASE:o,Fp:i,Fn:s}=e,a=s.ORDER,c=t.randomBytes||Lr,l=t.adjustScalarBytes||(E=>E),u=t.domain||((E,N,R)=>{if(ce("phflag",R),N.length||R)throw new Error("Contexts/pre-hash are not supported");return E});function f(E){return s.create(E)}function y(E){return f(_e(E))}function p(E){let N=i.BYTES;E=X("private key",E,N);let R=X("hashed private key",n(E),2*N),g=l(R.slice(0,N)),d=R.slice(N,2*N),x=y(g);return{head:g,prefix:d,scalar:x}}function T(E){let{head:N,prefix:R,scalar:g}=p(E),d=o.multiply(g),x=d.toBytes();return{head:N,prefix:R,scalar:g,point:d,pointBytes:x}}function v(E){return T(E).pointBytes}function w(E=Uint8Array.of(),...N){let R=_t(...N);return y(n(u(R,X("context",E),!!r)))}function C(E,N,R={}){E=X("message",E),r&&(E=r(E));let{prefix:g,scalar:d,pointBytes:x}=T(N),h=w(R.context,g,E),m=o.multiply(h).toBytes(),S=w(R.context,m,x,E),I=f(h+S*d);we("signature.s",I,Xt,a);let A=i.BYTES,B=_t(m,nr(I,A));return X("result",B,A*2)}let U=Cd;function P(E,N,R,g=U){let{context:d,zip215:x}=g,h=i.BYTES;E=X("signature",E,2*h),N=X("message",N),R=X("publicKey",R,h),x!==void 0&&ce("zip215",x),r&&(N=r(N));let m=_e(E.slice(h,2*h)),S,I,A;try{S=e.fromHex(R,x),I=e.fromHex(E.slice(0,h),x),A=o.multiplyUnsafe(m)}catch{return!1}if(!x&&S.isSmallOrder())return!1;let B=w(d,I.toBytes(),S.toBytes(),N);return I.add(S.multiplyUnsafe(B)).subtract(A).clearCofactor().is0()}return o.precompute(8),{getPublicKey:v,sign:C,verify:P,utils:{getExtendedPublicKey:T,randomPrivateKey:()=>c(i.BYTES),precompute(E=8,N=e.BASE){return N.precompute(E,!1)}},Point:e}}function Nd(e){let t={a:e.a,d:e.d,p:e.Fp.ORDER,n:e.n,h:e.h,Gx:e.Gx,Gy:e.Gy},r=e.Fp,n=Vt(t.n,e.nBitLength,!0),o={Fp:r,Fn:n,uvRatio:e.uvRatio},i={hash:e.hash,randomBytes:e.randomBytes,adjustScalarBytes:e.adjustScalarBytes,domain:e.domain,prehash:e.prehash,mapToCurve:e.mapToCurve};return{CURVE:t,curveOpts:o,eddsaOpts:i}}function Rd(e,t){return Object.assign({},t,{ExtendedPoint:t.Point,CURVE:e})}function Ja(e){let{CURVE:t,curveOpts:r,eddsaOpts:n}=Nd(e),o=Pd(t,r),i=Ud(o,n);return Rd(e,i)}var by=BigInt(0),Ld=BigInt(1),Qa=BigInt(2),Ey=BigInt(3),Dd=BigInt(5),kd=BigInt(8),Tn={p:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"),n:BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),h:kd,a:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),d:BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),Gx:BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),Gy:BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")};function Kd(e){let t=BigInt(10),r=BigInt(20),n=BigInt(40),o=BigInt(80),i=Tn.p,a=e*e%i*e%i,c=J(a,Qa,i)*a%i,l=J(c,Ld,i)*e%i,u=J(l,Dd,i)*l%i,f=J(u,t,i)*u%i,y=J(f,r,i)*f%i,p=J(y,n,i)*y%i,T=J(p,o,i)*p%i,v=J(T,o,i)*p%i,w=J(v,t,i)*u%i;return{pow_p_5_8:J(w,Qa,i)*e%i,b2:a}}function Fd(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}var tc=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");function Od(e,t){let r=Tn.p,n=Q(t*t*t,r),o=Q(n*n*t,r),i=Kd(e*o).pow_p_5_8,s=Q(e*n*i,r),a=Q(t*s*s,r),c=s,l=Q(s*tc,r),u=a===e,f=a===Q(-e,r),y=a===Q(-e*tc,r);return u&&(s=c),(f||y)&&(s=l),$a(s,r)&&(s=Q(-s,r)),{isValid:u||f,value:s}}var Md=Vt(Tn.p,void 0,!0),Vd={...Tn,Fp:Md,hash:Ua,adjustScalarBytes:Fd,uvRatio:Od},ec=Ja(Vd);var Mr=class extends Error{constructor(t="An error occurred while verifying a message"){super(t),this.name="VerificationError"}},Bn=class extends Error{constructor(t="Missing Web Crypto API"){super(t),this.name="WebCryptoMissingError"}};var rc={get(e=globalThis){let t=e.crypto;if(t?.subtle==null)throw new Bn("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 Dt=rc;var Cn=32;var yi,$d=(async()=>{try{return await Dt.get().subtle.generateKey({name:"Ed25519"},!0,["sign","verify"]),!0}catch{return!1}})();async function qd(e,t,r){if(e.buffer instanceof ArrayBuffer){let n=await Dt.get().subtle.importKey("raw",e.buffer,{name:"Ed25519"},!1,["verify"]);return await Dt.get().subtle.verify({name:"Ed25519"},n,t,r instanceof Uint8Array?r:r.subarray())}throw new TypeError("WebCrypto does not support SharedArrayBuffer for Ed25519 keys")}function Hd(e,t,r){return ec.verify(t,r instanceof Uint8Array?r:r.subarray(),e)}async function nc(e,t,r){return yi==null&&(yi=await $d),yi?qd(e,t,r):Hd(e,t,r)}function _n(e){return e==null?!1:typeof e.then=="function"&&typeof e.catch=="function"&&typeof e.finally=="function"}var Pn=class{type="Ed25519";raw;constructor(t){this.raw=gi(t,Cn)}toMultihash(){return Bt.digest(Xe(this))}toCID(){return $.createV1(114,this.toMultihash())}toString(){return G.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:Y(this.raw,t.raw)}verify(t,r,n){n?.signal?.throwIfAborted();let o=nc(this.raw,r,t);return _n(o)?o.then(i=>(n?.signal?.throwIfAborted(),i)):o}};function xi(e){return e=gi(e,Cn),new Pn(e)}function gi(e,t){if(e=Uint8Array.from(e??[]),e.length!==t)throw new nt(`Key must be a Uint8Array of length ${t}, got ${e.length}`);return e}var jd=Math.pow(2,7),Gd=Math.pow(2,14),Zd=Math.pow(2,21),wi=Math.pow(2,28),bi=Math.pow(2,35),Ei=Math.pow(2,42),Si=Math.pow(2,49),H=128,pt=127;function Tt(e){if(e<jd)return 1;if(e<Gd)return 2;if(e<Zd)return 3;if(e<wi)return 4;if(e<bi)return 5;if(e<Ei)return 6;if(e<Si)return 7;if(Number.MAX_SAFE_INTEGER!=null&&e>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function vi(e,t,r=0){switch(Tt(e)){case 8:t[r++]=e&255|H,e/=128;case 7:t[r++]=e&255|H,e/=128;case 6:t[r++]=e&255|H,e/=128;case 5:t[r++]=e&255|H,e/=128;case 4:t[r++]=e&255|H,e>>>=7;case 3:t[r++]=e&255|H,e>>>=7;case 2:t[r++]=e&255|H,e>>>=7;case 1:{t[r++]=e&255,e>>>=7;break}default:throw new Error("unreachable")}return t}function Wd(e,t,r=0){switch(Tt(e)){case 8:t.set(r++,e&255|H),e/=128;case 7:t.set(r++,e&255|H),e/=128;case 6:t.set(r++,e&255|H),e/=128;case 5:t.set(r++,e&255|H),e/=128;case 4:t.set(r++,e&255|H),e>>>=7;case 3:t.set(r++,e&255|H),e>>>=7;case 2:t.set(r++,e&255|H),e>>>=7;case 1:{t.set(r++,e&255),e>>>=7;break}default:throw new Error("unreachable")}return t}function Ai(e,t){let r=e[t],n=0;if(n+=r&pt,r<H||(r=e[t+1],n+=(r&pt)<<7,r<H)||(r=e[t+2],n+=(r&pt)<<14,r<H)||(r=e[t+3],n+=(r&pt)<<21,r<H)||(r=e[t+4],n+=(r&pt)*wi,r<H)||(r=e[t+5],n+=(r&pt)*bi,r<H)||(r=e[t+6],n+=(r&pt)*Ei,r<H)||(r=e[t+7],n+=(r&pt)*Si,r<H))return n;throw new RangeError("Could not decode varint")}function Yd(e,t){let r=e.get(t),n=0;if(n+=r&pt,r<H||(r=e.get(t+1),n+=(r&pt)<<7,r<H)||(r=e.get(t+2),n+=(r&pt)<<14,r<H)||(r=e.get(t+3),n+=(r&pt)<<21,r<H)||(r=e.get(t+4),n+=(r&pt)*wi,r<H)||(r=e.get(t+5),n+=(r&pt)*bi,r<H)||(r=e.get(t+6),n+=(r&pt)*Ei,r<H)||(r=e.get(t+7),n+=(r&pt)*Si,r<H))return n;throw new RangeError("Could not decode varint")}function ar(e,t,r=0){return t==null&&(t=At(Tt(e))),t instanceof Uint8Array?vi(e,t,r):Wd(e,t,r)}function Re(e,t=0){return e instanceof Uint8Array?Ai(e,t):Yd(e,t)}var Ii=new Float32Array([-0]),Ee=new Uint8Array(Ii.buffer);function sc(e,t,r){Ii[0]=e,t[r]=Ee[0],t[r+1]=Ee[1],t[r+2]=Ee[2],t[r+3]=Ee[3]}function ac(e,t){return Ee[0]=e[t],Ee[1]=e[t+1],Ee[2]=e[t+2],Ee[3]=e[t+3],Ii[0]}var Ti=new Float64Array([-0]),mt=new Uint8Array(Ti.buffer);function cc(e,t,r){Ti[0]=e,t[r]=mt[0],t[r+1]=mt[1],t[r+2]=mt[2],t[r+3]=mt[3],t[r+4]=mt[4],t[r+5]=mt[5],t[r+6]=mt[6],t[r+7]=mt[7]}function uc(e,t){return mt[0]=e[t],mt[1]=e[t+1],mt[2]=e[t+2],mt[3]=e[t+3],mt[4]=e[t+4],mt[5]=e[t+5],mt[6]=e[t+6],mt[7]=e[t+7],Ti[0]}var Xd=BigInt(Number.MAX_SAFE_INTEGER),Jd=BigInt(Number.MIN_SAFE_INTEGER),Pt=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 Le;if(t<Xd&&t>Jd)return this.fromNumber(Number(t));let r=t<0n;r&&(t=-t);let n=t>>32n,o=t-(n<<32n);return r&&(n=~n|0n,o=~o|0n,++o>fc&&(o=0n,++n>fc&&(n=0n))),new e(Number(o),Number(n))}static fromNumber(t){if(t===0)return Le;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):Le}},Le=new Pt(0,0);Le.toBigInt=function(){return 0n};Le.zzEncode=Le.zzDecode=function(){return this};Le.length=function(){return 1};var fc=4294967296n;function lc(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 dc(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 Bi(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 $t(e,t){return RangeError(`index out of range: ${e.pos} + ${t??1} > ${e.len}`)}function Un(e,t){return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0}var Ci=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,$t(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 $t(this,4);return Un(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw $t(this,4);return Un(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw $t(this,4);let t=ac(this.buf,this.pos);return this.pos+=4,t}double(){if(this.pos+8>this.len)throw $t(this,4);let t=uc(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 $t(this,t);return this.pos+=t,r===n?new Uint8Array(0):this.buf.subarray(r,n)}string(){let t=this.bytes();return dc(t,0,t.length)}skip(t){if(typeof t=="number"){if(this.pos+t>this.len)throw $t(this,t);this.pos+=t}else do if(this.pos>=this.len)throw $t(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 Pt(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 $t(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 $t(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 $t(this,8);let t=Un(this.buf,this.pos+=4),r=Un(this.buf,this.pos+=4);return new Pt(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=Ai(this.buf,this.pos);return this.pos+=Tt(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 _i(e){return new Ci(e instanceof Uint8Array?e:e.subarray())}function cr(e,t,r){let n=_i(e);return t.decode(n,void 0,r)}function Pi(e){let t=e??8192,r=t>>>1,n,o=t;return function(s){if(s<1||s>r)return At(s);o+s>t&&(n=At(t),o=0);let a=n.subarray(o,o+=s);return(o&7)!==0&&(o=(o|7)+1),a}}var De=class{fn;len;next;val;constructor(t,r,n){this.fn=t,this.len=r,this.next=void 0,this.val=n}};function Ui(){}var Ri=class{head;tail;len;next;constructor(t){this.head=t.head,this.tail=t.tail,this.len=t.len,this.next=t.states}},Qd=Pi();function th(e){return globalThis.Buffer!=null?At(e):Qd(e)}var $r=class{len;head;tail;states;constructor(){this.len=0,this.head=new De(Ui,0,0),this.tail=this.head,this.states=null}_push(t,r,n){return this.tail=this.tail.next=new De(t,r,n),this.len+=r,this}uint32(t){return this.len+=(this.tail=this.tail.next=new Li((t=t>>>0)<128?1:t<16384?2:t<2097152?3:t<268435456?4:5,t)).len,this}int32(t){return t<0?this._push(Nn,10,Pt.fromNumber(t)):this.uint32(t)}sint32(t){return this.uint32((t<<1^t>>31)>>>0)}uint64(t){let r=Pt.fromBigInt(t);return this._push(Nn,r.length(),r)}uint64Number(t){return this._push(vi,Tt(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=Pt.fromBigInt(t).zzEncode();return this._push(Nn,r.length(),r)}sint64Number(t){let r=Pt.fromNumber(t).zzEncode();return this._push(Nn,r.length(),r)}sint64String(t){return this.sint64(BigInt(t))}bool(t){return this._push(Ni,1,t?1:0)}fixed32(t){return this._push(Vr,4,t>>>0)}sfixed32(t){return this.fixed32(t)}fixed64(t){let r=Pt.fromBigInt(t);return this._push(Vr,4,r.lo)._push(Vr,4,r.hi)}fixed64Number(t){let r=Pt.fromNumber(t);return this._push(Vr,4,r.lo)._push(Vr,4,r.hi)}fixed64String(t){return this.fixed64(BigInt(t))}sfixed64(t){return this.fixed64(t)}sfixed64Number(t){return this.fixed64Number(t)}sfixed64String(t){return this.fixed64String(t)}float(t){return this._push(sc,4,t)}double(t){return this._push(cc,8,t)}bytes(t){let r=t.length>>>0;return r===0?this._push(Ni,1,0):this.uint32(r)._push(rh,r,t)}string(t){let r=lc(t);return r!==0?this.uint32(r)._push(Bi,r,t):this._push(Ni,1,0)}fork(){return this.states=new Ri(this),this.head=this.tail=new De(Ui,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 De(Ui,0,0),this.len=0),this}ldelim(){let t=this.head,r=this.tail,n=this.len;return this.reset().uint32(n),n!==0&&(this.tail.next=t.next,this.tail=r,this.len+=n),this}finish(){let t=this.head.next,r=th(this.len),n=0;for(;t!=null;)t.fn(t.val,r,n),n+=t.len,t=t.next;return r}};function Ni(e,t,r){t[r]=e&255}function eh(e,t,r){for(;e>127;)t[r++]=e&127|128,e>>>=7;t[r]=e}var Li=class extends De{next;constructor(t,r){super(eh,t,r),this.next=void 0}};function Nn(e,t,r){for(;e.hi!==0;)t[r++]=e.lo&127|128,e.lo=(e.lo>>>7|e.hi<<25)>>>0,e.hi>>>=7;for(;e.lo>127;)t[r++]=e.lo&127|128,e.lo=e.lo>>>7;t[r++]=e.lo}function Vr(e,t,r){t[r]=e&255,t[r+1]=e>>>8&255,t[r+2]=e>>>16&255,t[r+3]=e>>>24}function rh(e,t,r){t.set(e,r)}globalThis.Buffer!=null&&($r.prototype.bytes=function(e){let t=e.length>>>0;return this.uint32(t),t>0&&this._push(nh,t,e),this},$r.prototype.string=function(e){let t=globalThis.Buffer.byteLength(e);return this.uint32(t),t>0&&this._push(oh,t,e),this});function nh(e,t,r){t.set(e,r)}function oh(e,t,r){e.length<40?Bi(e,t,r):t.utf8Write!=null?t.utf8Write(e,r):t.set(V(e),r)}function Di(){return new $r}function ur(e,t){let r=Di();return t.encode(e,r,{lengthDelimited:!1}),r.finish()}var fr;(function(e){e[e.VARINT=0]="VARINT",e[e.BIT64=1]="BIT64",e[e.LENGTH_DELIMITED=2]="LENGTH_DELIMITED",e[e.START_GROUP=3]="START_GROUP",e[e.END_GROUP=4]="END_GROUP",e[e.BIT32=5]="BIT32"})(fr||(fr={}));function Rn(e,t,r,n){return{name:e,type:t,encode:r,decode:n}}function qr(e){function t(o){if(e[o.toString()]==null)throw new Error("Invalid enum value");return e[o]}let r=function(i,s){let a=t(i);s.int32(a)},n=function(i){let s=i.int32();return t(s)};return Rn("enum",fr.VARINT,r,n)}function lr(e,t){return Rn("message",fr.LENGTH_DELIMITED,e,t)}var et;(function(e){e.RSA="RSA",e.Ed25519="Ed25519",e.secp256k1="secp256k1",e.ECDSA="ECDSA"})(et||(et={}));var ki;(function(e){e[e.RSA=0]="RSA",e[e.Ed25519=1]="Ed25519",e[e.secp256k1=2]="secp256k1",e[e.ECDSA=3]="ECDSA"})(ki||(ki={}));(function(e){e.codec=()=>qr(ki)})(et||(et={}));var Jt;(function(e){let t;e.codec=()=>(t==null&&(t=lr((r,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),r.Type!=null&&(n.uint32(8),et.codec().encode(r.Type,n)),r.Data!=null&&(n.uint32(18),n.bytes(r.Data)),o.lengthDelimited!==!1&&n.ldelim()},(r,n,o={})=>{let i={},s=n==null?r.len:r.pos+n;for(;r.pos<s;){let a=r.uint32();switch(a>>>3){case 1:{i.Type=et.codec().decode(r);break}case 2:{i.Data=r.bytes();break}default:{r.skipType(a&7);break}}}return i})),t),e.encode=r=>ur(r,e.codec()),e.decode=(r,n)=>cr(r,e.codec(),n)})(Jt||(Jt={}));var Ki;(function(e){let t;e.codec=()=>(t==null&&(t=lr((r,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),r.Type!=null&&(n.uint32(8),et.codec().encode(r.Type,n)),r.Data!=null&&(n.uint32(18),n.bytes(r.Data)),o.lengthDelimited!==!1&&n.ldelim()},(r,n,o={})=>{let i={},s=n==null?r.len:r.pos+n;for(;r.pos<s;){let a=r.uint32();switch(a>>>3){case 1:{i.Type=et.codec().decode(r);break}case 2:{i.Data=r.bytes();break}default:{r.skipType(a&7);break}}}return i})),t),e.encode=r=>ur(r,e.codec()),e.decode=(r,n)=>cr(r,e.codec(),n)})(Ki||(Ki={}));var zr={};Et(zr,{MAX_RSA_KEY_SIZE:()=>Fi,generateRSAKeyPair:()=>xc,jwkToJWKKeyPair:()=>wc,jwkToPkcs1:()=>ch,jwkToPkix:()=>$i,jwkToRSAPrivateKey:()=>ji,pkcs1MessageToJwk:()=>Mi,pkcs1MessageToRSAPrivateKey:()=>qi,pkcs1ToJwk:()=>ah,pkcs1ToRSAPrivateKey:()=>gc,pkixMessageToJwk:()=>Vi,pkixMessageToRSAPublicKey:()=>zi,pkixToJwk:()=>uh,pkixToRSAPublicKey:()=>Hi});var Ln=bn;var dr=class{type="RSA";jwk;_raw;_multihash;constructor(t,r){this.jwk=t,this._multihash=r}get raw(){return this._raw==null&&(this._raw=zr.jwkToPkix(this.jwk)),this._raw}toMultihash(){return this._multihash}toCID(){return $.createV1(114,this._multihash)}toString(){return G.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:Y(this.raw,t.raw)}verify(t,r,n){return yc(this.jwk,r,t,n)}},Hr=class{type="RSA";jwk;_raw;publicKey;constructor(t,r){this.jwk=t,this.publicKey=r}get raw(){return this._raw==null&&(this._raw=zr.jwkToPkcs1(this.jwk)),this._raw}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:Y(this.raw,t.raw)}sign(t,r){return mc(this.jwk,t,r)}};var Fi=8192,Oi=18,ih=1062,sh=Uint8Array.from([48,13,6,9,42,134,72,134,247,13,1,1,1,5,0]);function ah(e){let t=oe(e);return Mi(t)}function Mi(e){return{n:M(e[1],"base64url"),e:M(e[2],"base64url"),d:M(e[3],"base64url"),p:M(e[4],"base64url"),q:M(e[5],"base64url"),dp:M(e[6],"base64url"),dq:M(e[7],"base64url"),qi:M(e[8],"base64url"),kty:"RSA"}}function ch(e){if(e.n==null||e.e==null||e.d==null||e.p==null||e.q==null||e.dp==null||e.dq==null||e.qi==null)throw new nt("JWK was missing components");return me([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 uh(e){let t=oe(e,{offset:0});return Vi(t)}function Vi(e){let t=oe(e[1],{offset:0});return{kty:"RSA",n:M(t[0],"base64url"),e:M(t[1],"base64url")}}function $i(e){if(e.n==null||e.e==null)throw new nt("JWK was missing components");return me([sh,yn(me([It(V(e.n,"base64url")),It(V(e.e,"base64url"))]))]).subarray()}function gc(e){let t=oe(e);return qi(t)}function qi(e){let t=Mi(e);return ji(t)}function Hi(e,t){if(e.byteLength>=ih)throw new Ve("Key size is too large");let r=oe(e,{offset:0});return zi(r,e,t)}function zi(e,t,r){let n=Vi(e);if(r==null){let o=Ln(Jt.encode({Type:et.RSA,Data:t}));r=Ot(Oi,o)}return new dr(n,r)}function ji(e){if(Ec(e)>Fi)throw new nt("Key size is too large");let t=wc(e),r=Ln(Jt.encode({Type:et.RSA,Data:$i(t.publicKey)})),n=Ot(Oi,r);return new Hr(t.privateKey,new dr(t.publicKey,n))}async function xc(e){if(e>Fi)throw new nt("Key size is too large");let t=await bc(e),r=Ln(Jt.encode({Type:et.RSA,Data:$i(t.publicKey)})),n=Ot(Oi,r);return new Hr(t.privateKey,new dr(t.publicKey,n))}function wc(e){if(e==null)throw new nt("Missing key parameter");return{privateKey:e,publicKey:{kty:e.kty,n:e.n,e:e.e}}}async function bc(e,t){let r=await Dt.get().subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:e,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-256"}},!0,["sign","verify"]);t?.signal?.throwIfAborted();let n=await fh(r,t);return{privateKey:n[0],publicKey:n[1]}}async function mc(e,t,r){let n=await Dt.get().subtle.importKey("jwk",e,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["sign"]);r?.signal?.throwIfAborted();let o=await Dt.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 yc(e,t,r,n){let o=await Dt.get().subtle.importKey("jwk",e,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["verify"]);n?.signal?.throwIfAborted();let i=await Dt.get().subtle.verify({name:"RSASSA-PKCS1-v1_5"},o,t,r instanceof Uint8Array?r:r.subarray());return n?.signal?.throwIfAborted(),i}async function fh(e,t){if(e.privateKey==null||e.publicKey==null)throw new nt("Private and public key are required");let r=await Promise.all([Dt.get().subtle.exportKey("jwk",e.privateKey),Dt.get().subtle.exportKey("jwk",e.publicKey)]);return t?.signal?.throwIfAborted(),r}function Ec(e){if(e.kty!=="RSA")throw new nt("invalid key type");if(e.n==null)throw new nt("invalid key modulus");return V(e.n,"base64url").length*8}var Dn=class extends Je{constructor(t,r){super(),this.finished=!1,this.destroyed=!1,ya(t);let n=Rr(r);if(this.iHash=t.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let o=this.blockLen,i=new Uint8Array(o);i.set(n.length>o?t.create().update(n).digest():n);for(let s=0;s<i.length;s++)i[s]^=54;this.iHash.update(i),this.oHash=t.create();for(let s=0;s<i.length;s++)i[s]^=106;this.oHash.update(i),se(i)}update(t){return tr(this),this.iHash.update(t),this}digestInto(t){tr(this),ht(t,this.outputLen),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){let t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));let{oHash:r,iHash:n,finished:o,destroyed:i,blockLen:s,outputLen:a}=this;return t=t,t.finished=o,t.destroyed=i,t.blockLen=s,t.outputLen=a,t.oHash=r._cloneInto(t.oHash),t.iHash=n._cloneInto(t.iHash),t}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},Gi=(e,t,r)=>new Dn(e,t).update(r).digest();Gi.create=(e,t)=>new Dn(e,t);function Sc(e){e.lowS!==void 0&&ce("lowS",e.lowS),e.prehash!==void 0&&ce("prehash",e.prehash)}var Zi=class extends Error{constructor(t=""){super(t)}},ue={Err:Zi,_tlv:{encode:(e,t)=>{let{Err:r}=ue;if(e<0||e>256)throw new r("tlv.encode: wrong tag");if(t.length&1)throw new r("tlv.encode: unpadded data");let n=t.length/2,o=Fr(n);if(o.length/2&128)throw new r("tlv.encode: long form length too big");let i=n>127?Fr(o.length/2|128):"";return Fr(e)+i+o+t},decode(e,t){let{Err:r}=ue,n=0;if(e<0||e>256)throw new r("tlv.encode: wrong tag");if(t.length<2||t[n++]!==e)throw new r("tlv.decode: wrong tlv");let o=t[n++],i=!!(o&128),s=0;if(!i)s=o;else{let c=o&127;if(!c)throw new r("tlv.decode(long): indefinite length not supported");if(c>4)throw new r("tlv.decode(long): byte length is too big");let l=t.subarray(n,n+c);if(l.length!==c)throw new r("tlv.decode: length bytes not complete");if(l[0]===0)throw new r("tlv.decode(long): zero leftmost byte");for(let u of l)s=s<<8|u;if(n+=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}=ue;if(e<jr)throw new t("integer: negative integers are not allowed");let r=Fr(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}=ue;if(e[0]&128)throw new t("invalid signature integer: negative");if(e[0]===0&&!(e[1]&128))throw new t("invalid signature integer: unnecessary leading zero");return rr(e)}},toSig(e){let{Err:t,_int:r,_tlv:n}=ue,o=X("signature",e),{v:i,l:s}=n.decode(48,o);if(s.length)throw new t("invalid signature: left bytes after parsing");let{v:a,l:c}=n.decode(2,i),{v:l,l:u}=n.decode(2,c);if(u.length)throw new t("invalid signature: left bytes after parsing");return{r:r.decode(a),s:r.decode(l)}},hexFromSig(e){let{_tlv:t,_int:r}=ue,n=t.encode(2,r.encode(e.r)),o=t.encode(2,r.encode(e.s)),i=n+o;return t.encode(48,i)}},jr=BigInt(0),Gr=BigInt(1),lh=BigInt(2),kn=BigInt(3),dh=BigInt(4);function hh(e,t,r){function n(o){let i=e.sqr(o),s=e.mul(i,o);return e.add(e.add(s,e.mul(o,t)),r)}return n}function vc(e,t,r){let{BYTES:n}=e;function o(i){let s;if(typeof i=="bigint")s=i;else{let a=X("private key",i);if(t){if(!t.includes(a.length*2))throw new Error("invalid private key");let c=new Uint8Array(n);c.set(a,c.length-a.length),a=c}try{s=e.fromBytes(a)}catch{throw new Error(`invalid private key: expected ui8a of size ${n}, got ${typeof i}`)}}if(r&&(s=e.create(s)),!e.isValidNot0(s))throw new Error("invalid private key: out of range [1..N-1]");return s}return o}function ph(e,t={}){let{Fp:r,Fn:n}=In("weierstrass",e,t),{h:o,n:i}=e;be(t,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object",wrapPrivateKey:"boolean"});let{endo:s}=t;if(s&&(!r.is0(e.a)||typeof s.beta!="bigint"||typeof s.splitScalar!="function"))throw new Error('invalid endo: expected "beta": bigint and "splitScalar": function');function a(){if(!r.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}function c(g,d,x){let{x:h,y:m}=d.toAffine(),S=r.toBytes(h);if(ce("isCompressed",x),x){a();let I=!r.isOdd(m);return _t(Ac(I),S)}else return _t(Uint8Array.of(4),S,r.toBytes(m))}function l(g){ht(g);let d=r.BYTES,x=d+1,h=2*d+1,m=g.length,S=g[0],I=g.subarray(1);if(m===x&&(S===2||S===3)){let A=r.fromBytes(I);if(!r.isValid(A))throw new Error("bad point: is not on curve, wrong x");let B=y(A),k;try{k=r.sqrt(B)}catch(z){let O=z instanceof Error?": "+z.message:"";throw new Error("bad point: is not on curve, sqrt error"+O)}a();let D=r.isOdd(k);return(S&1)===1!==D&&(k=r.neg(k)),{x:A,y:k}}else if(m===h&&S===4){let A=r.fromBytes(I.subarray(d*0,d*1)),B=r.fromBytes(I.subarray(d*1,d*2));if(!p(A,B))throw new Error("bad point: is not on curve");return{x:A,y:B}}else throw new Error(`bad point: got length ${m}, expected compressed=${x} or uncompressed=${h}`)}let u=t.toBytes||c,f=t.fromBytes||l,y=hh(r,e.a,e.b);function p(g,d){let x=r.sqr(d),h=y(g);return r.eql(x,h)}if(!p(e.Gx,e.Gy))throw new Error("bad curve params: generator point");let T=r.mul(r.pow(e.a,kn),dh),v=r.mul(r.sqr(e.b),BigInt(27));if(r.is0(r.add(T,v)))throw new Error("bad curve params: a or b");function w(g,d,x=!1){if(!r.isValid(d)||x&&r.is0(d))throw new Error(`bad point coordinate ${g}`);return d}function C(g){if(!(g instanceof E))throw new Error("ProjectivePoint expected")}let U=or((g,d)=>{let{px:x,py:h,pz:m}=g;if(r.eql(m,r.ONE))return{x,y:h};let S=g.is0();d==null&&(d=S?r.ONE:r.inv(m));let I=r.mul(x,d),A=r.mul(h,d),B=r.mul(m,d);if(S)return{x:r.ZERO,y:r.ZERO};if(!r.eql(B,r.ONE))throw new Error("invZ was invalid");return{x:I,y:A}}),P=or(g=>{if(g.is0()){if(t.allowInfinityPoint&&!r.is0(g.py))return;throw new Error("bad point: ZERO")}let{x:d,y:x}=g.toAffine();if(!r.isValid(d)||!r.isValid(x))throw new Error("bad point: x or y not field elements");if(!p(d,x))throw new Error("bad point: equation left != right");if(!g.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});function K(g,d,x,h,m){return x=new E(r.mul(x.px,g),x.py,x.pz),d=ir(h,d),x=ir(m,x),d.add(x)}class E{constructor(d,x,h){this.px=w("x",d),this.py=w("y",x,!0),this.pz=w("z",h),Object.freeze(this)}static fromAffine(d){let{x,y:h}=d||{};if(!d||!r.isValid(x)||!r.isValid(h))throw new Error("invalid affine point");if(d instanceof E)throw new Error("projective point not allowed");return r.is0(x)&&r.is0(h)?E.ZERO:new E(x,h,r.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(d){return Sn(E,"pz",d)}static fromBytes(d){return ht(d),E.fromHex(d)}static fromHex(d){let x=E.fromAffine(f(X("pointHex",d)));return x.assertValidity(),x}static fromPrivateKey(d){let x=vc(n,t.allowedPrivateKeyLengths,t.wrapPrivateKey);return E.BASE.multiply(x(d))}static msm(d,x){return An(E,n,d,x)}precompute(d=8,x=!0){return R.setWindowSize(this,d),x||this.multiply(kn),this}_setWindowSize(d){this.precompute(d)}assertValidity(){P(this)}hasEvenY(){let{y:d}=this.toAffine();if(!r.isOdd)throw new Error("Field doesn't support isOdd");return!r.isOdd(d)}equals(d){C(d);let{px:x,py:h,pz:m}=this,{px:S,py:I,pz:A}=d,B=r.eql(r.mul(x,A),r.mul(S,m)),k=r.eql(r.mul(h,A),r.mul(I,m));return B&&k}negate(){return new E(this.px,r.neg(this.py),this.pz)}double(){let{a:d,b:x}=e,h=r.mul(x,kn),{px:m,py:S,pz:I}=this,A=r.ZERO,B=r.ZERO,k=r.ZERO,D=r.mul(m,m),j=r.mul(S,S),z=r.mul(I,I),O=r.mul(m,S);return O=r.add(O,O),k=r.mul(m,I),k=r.add(k,k),A=r.mul(d,k),B=r.mul(h,z),B=r.add(A,B),A=r.sub(j,B),B=r.add(j,B),B=r.mul(A,B),A=r.mul(O,A),k=r.mul(h,k),z=r.mul(d,z),O=r.sub(D,z),O=r.mul(d,O),O=r.add(O,k),k=r.add(D,D),D=r.add(k,D),D=r.add(D,z),D=r.mul(D,O),B=r.add(B,D),z=r.mul(S,I),z=r.add(z,z),D=r.mul(z,O),A=r.sub(A,D),k=r.mul(z,j),k=r.add(k,k),k=r.add(k,k),new E(A,B,k)}add(d){C(d);let{px:x,py:h,pz:m}=this,{px:S,py:I,pz:A}=d,B=r.ZERO,k=r.ZERO,D=r.ZERO,j=e.a,z=r.mul(e.b,kn),O=r.mul(x,S),rt=r.mul(h,I),it=r.mul(m,A),lt=r.add(x,h),W=r.add(S,I);lt=r.mul(lt,W),W=r.add(O,rt),lt=r.sub(lt,W),W=r.add(x,m);let gt=r.add(S,A);return W=r.mul(W,gt),gt=r.add(O,it),W=r.sub(W,gt),gt=r.add(h,m),B=r.add(I,A),gt=r.mul(gt,B),B=r.add(rt,it),gt=r.sub(gt,B),D=r.mul(j,W),B=r.mul(z,it),D=r.add(B,D),B=r.sub(rt,D),D=r.add(rt,D),k=r.mul(B,D),rt=r.add(O,O),rt=r.add(rt,O),it=r.mul(j,it),W=r.mul(z,W),rt=r.add(rt,it),it=r.sub(O,it),it=r.mul(j,it),W=r.add(W,it),O=r.mul(rt,W),k=r.add(k,O),O=r.mul(gt,W),B=r.mul(lt,B),B=r.sub(B,O),O=r.mul(lt,rt),D=r.mul(gt,D),D=r.add(D,O),new E(B,k,D)}subtract(d){return this.add(d.negate())}is0(){return this.equals(E.ZERO)}multiply(d){let{endo:x}=t;if(!n.isValidNot0(d))throw new Error("invalid scalar: out of range");let h,m,S=I=>R.wNAFCached(this,I,E.normalizeZ);if(x){let{k1neg:I,k1:A,k2neg:B,k2:k}=x.splitScalar(d),{p:D,f:j}=S(A),{p:z,f:O}=S(k);m=j.add(O),h=K(x.beta,D,z,I,B)}else{let{p:I,f:A}=S(d);h=I,m=A}return E.normalizeZ([h,m])[0]}multiplyUnsafe(d){let{endo:x}=t,h=this;if(!n.isValid(d))throw new Error("invalid scalar: out of range");if(d===jr||h.is0())return E.ZERO;if(d===Gr)return h;if(R.hasPrecomputes(this))return this.multiply(d);if(x){let{k1neg:m,k1:S,k2neg:I,k2:A}=x.splitScalar(d),{p1:B,p2:k}=Xa(E,h,S,A);return K(x.beta,B,k,m,I)}else return R.wNAFCachedUnsafe(h,d)}multiplyAndAddUnsafe(d,x,h){let m=this.multiplyUnsafe(x).add(d.multiplyUnsafe(h));return m.is0()?void 0:m}toAffine(d){return U(this,d)}isTorsionFree(){let{isTorsionFree:d}=t;return o===Gr?!0:d?d(E,this):R.wNAFCachedUnsafe(this,i).is0()}clearCofactor(){let{clearCofactor:d}=t;return o===Gr?this:d?d(E,this):this.multiplyUnsafe(o)}toBytes(d=!0){return ce("isCompressed",d),this.assertValidity(),u(E,this,d)}toRawBytes(d=!0){return this.toBytes(d)}toHex(d=!0){return Wt(this.toBytes(d))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}E.BASE=new E(e.Gx,e.Gy,r.ONE),E.ZERO=new E(r.ZERO,r.ONE,r.ZERO),E.Fp=r,E.Fn=n;let N=n.BITS,R=vn(E,t.endo?Math.ceil(N/2):N);return E}function Ac(e){return Uint8Array.of(e?2:3)}function mh(e,t,r={}){be(t,{hash:"function"},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"});let n=t.randomBytes||Lr,o=t.hmac||((h,...m)=>Gi(t.hash,h,_t(...m))),{Fp:i,Fn:s}=e,{ORDER:a,BITS:c}=s;function l(h){let m=a>>Gr;return h>m}function u(h){return l(h)?s.neg(h):h}function f(h,m){if(!s.isValidNot0(m))throw new Error(`invalid signature ${h}: out of range 1..CURVE.n`)}class y{constructor(m,S,I){f("r",m),f("s",S),this.r=m,this.s=S,I!=null&&(this.recovery=I),Object.freeze(this)}static fromCompact(m){let S=s.BYTES,I=X("compactSignature",m,S*2);return new y(s.fromBytes(I.subarray(0,S)),s.fromBytes(I.subarray(S,S*2)))}static fromDER(m){let{r:S,s:I}=ue.toSig(X("DER",m));return new y(S,I)}assertValidity(){}addRecoveryBit(m){return new y(this.r,this.s,m)}recoverPublicKey(m){let S=i.ORDER,{r:I,s:A,recovery:B}=this;if(B==null||![0,1,2,3].includes(B))throw new Error("recovery id invalid");if(a*lh<S&&B>1)throw new Error("recovery id is ambiguous for h>1 curve");let D=B===2||B===3?I+a:I;if(!i.isValid(D))throw new Error("recovery id 2 or 3 invalid");let j=i.toBytes(D),z=e.fromHex(_t(Ac((B&1)===0),j)),O=s.inv(D),rt=P(X("msgHash",m)),it=s.create(-rt*O),lt=s.create(A*O),W=e.BASE.multiplyUnsafe(it).add(z.multiplyUnsafe(lt));if(W.is0())throw new Error("point at infinify");return W.assertValidity(),W}hasHighS(){return l(this.s)}normalizeS(){return this.hasHighS()?new y(this.r,s.neg(this.s),this.recovery):this}toBytes(m){if(m==="compact")return _t(s.toBytes(this.r),s.toBytes(this.s));if(m==="der")return er(ue.hexFromSig(this));throw new Error("invalid format")}toDERRawBytes(){return this.toBytes("der")}toDERHex(){return Wt(this.toBytes("der"))}toCompactRawBytes(){return this.toBytes("compact")}toCompactHex(){return Wt(this.toBytes("compact"))}}let p=vc(s,r.allowedPrivateKeyLengths,r.wrapPrivateKey),T={isValidPrivateKey(h){try{return p(h),!0}catch{return!1}},normPrivateKeyToScalar:p,randomPrivateKey:()=>{let h=a;return za(n(li(h)),h)},precompute(h=8,m=e.BASE){return m.precompute(h,!1)}};function v(h,m=!0){return e.fromPrivateKey(h).toBytes(m)}function w(h){if(typeof h=="bigint")return!1;if(h instanceof e)return!0;let S=X("key",h).length,I=i.BYTES,A=I+1,B=2*I+1;if(!(r.allowedPrivateKeyLengths||s.BYTES===A))return S===A||S===B}function C(h,m,S=!0){if(w(h)===!0)throw new Error("first arg must be private key");if(w(m)===!1)throw new Error("second arg must be public key");return e.fromHex(m).multiply(p(h)).toBytes(S)}let U=t.bits2int||function(h){if(h.length>8192)throw new Error("input is too large");let m=rr(h),S=h.length*8-c;return S>0?m>>BigInt(S):m},P=t.bits2int_modN||function(h){return s.create(U(h))},K=Pe(c);function E(h){return we("num < 2^"+c,h,jr,K),s.toBytes(h)}function N(h,m,S=R){if(["recovered","canonical"].some(lt=>lt in S))throw new Error("sign() legacy options not supported");let{hash:I}=t,{lowS:A,prehash:B,extraEntropy:k}=S;A==null&&(A=!0),h=X("msgHash",h),Sc(S),B&&(h=X("prehashed msgHash",I(h)));let D=P(h),j=p(m),z=[E(j),E(D)];if(k!=null&&k!==!1){let lt=k===!0?n(i.BYTES):k;z.push(X("extraEntropy",lt))}let O=_t(...z),rt=D;function it(lt){let W=U(lt);if(!s.isValidNot0(W))return;let gt=s.inv(W),Ar=e.BASE.multiply(W).toAffine(),Oe=s.create(Ar.x);if(Oe===jr)return;let Ie=s.create(gt*s.create(rt+Oe*j));if(Ie===jr)return;let Io=(Ar.x===Oe?0:2)|Number(Ar.y&Gr),Me=Ie;return A&&l(Ie)&&(Me=u(Ie),Io^=1),new y(Oe,Me,Io)}return{seed:O,k2sig:it}}let R={lowS:t.lowS,prehash:!1},g={lowS:t.lowS,prehash:!1};function d(h,m,S=R){let{seed:I,k2sig:A}=N(h,m,S);return Da(t.hash.outputLen,s.BYTES,o)(I,A)}e.BASE.precompute(8);function x(h,m,S,I=g){let A=h;m=X("msgHash",m),S=X("publicKey",S),Sc(I);let{lowS:B,prehash:k,format:D}=I;if("strict"in I)throw new Error("options.strict was renamed to lowS");if(D!==void 0&&!["compact","der","js"].includes(D))throw new Error('format must be "compact", "der" or "js"');let j=typeof A=="string"||Qe(A),z=!j&&!D&&typeof A=="object"&&A!==null&&typeof A.r=="bigint"&&typeof A.s=="bigint";if(!j&&!z)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let O,rt;try{if(z)if(D===void 0||D==="js")O=new y(A.r,A.s);else throw new Error("invalid format");if(j){try{D!=="compact"&&(O=y.fromDER(A))}catch(Me){if(!(Me instanceof ue.Err))throw Me}!O&&D!=="der"&&(O=y.fromCompact(A))}rt=e.fromHex(S)}catch{return!1}if(!O||B&&O.hasHighS())return!1;k&&(m=t.hash(m));let{r:it,s:lt}=O,W=P(m),gt=s.inv(lt),Ar=s.create(W*gt),Oe=s.create(it*gt),Ie=e.BASE.multiplyUnsafe(Ar).add(rt.multiplyUnsafe(Oe));return Ie.is0()?!1:s.create(Ie.x)===it}return Object.freeze({getPublicKey:v,getSharedSecret:C,sign:d,verify:x,utils:T,Point:e,Signature:y})}function yh(e){let t={a:e.a,b:e.b,p:e.Fp.ORDER,n:e.n,h:e.h,Gx:e.Gx,Gy:e.Gy},r=e.Fp,n=Vt(t.n,e.nBitLength),o={Fp:r,Fn:n,allowedPrivateKeyLengths:e.allowedPrivateKeyLengths,allowInfinityPoint:e.allowInfinityPoint,endo:e.endo,wrapPrivateKey:e.wrapPrivateKey,isTorsionFree:e.isTorsionFree,clearCofactor:e.clearCofactor,fromBytes:e.fromBytes,toBytes:e.toBytes};return{CURVE:t,curveOpts:o}}function gh(e){let{CURVE:t,curveOpts:r}=yh(e),n={hash:e.hash,hmac:e.hmac,randomBytes:e.randomBytes,lowS:e.lowS,bits2int:e.bits2int,bits2int_modN:e.bits2int_modN};return{CURVE:t,curveOpts:r,ecdsaOpts:n}}function xh(e,t){return Object.assign({},t,{ProjectivePoint:t.Point,CURVE:e})}function Ic(e){let{CURVE:t,curveOpts:r,ecdsaOpts:n}=gh(e),o=ph(t,r),i=mh(o,n,r);return xh(e,i)}function Tc(e,t){let r=n=>Ic({...e,hash:n});return{...r(t),create:r}}var Kn={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},ax=BigInt(0),wh=BigInt(1),Wi=BigInt(2),Bc=(e,t)=>(e+t/Wi)/t;function bh(e){let t=Kn.p,r=BigInt(3),n=BigInt(6),o=BigInt(11),i=BigInt(22),s=BigInt(23),a=BigInt(44),c=BigInt(88),l=e*e*e%t,u=l*l*e%t,f=J(u,r,t)*u%t,y=J(f,r,t)*u%t,p=J(y,Wi,t)*l%t,T=J(p,o,t)*p%t,v=J(T,i,t)*T%t,w=J(v,a,t)*v%t,C=J(w,c,t)*w%t,U=J(C,a,t)*v%t,P=J(U,r,t)*u%t,K=J(P,s,t)*T%t,E=J(K,n,t)*l%t,N=J(E,Wi,t);if(!Yi.eql(Yi.sqr(N),e))throw new Error("Cannot find square root");return N}var Yi=Vt(Kn.p,void 0,void 0,{sqrt:bh}),hr=Tc({...Kn,Fp:Yi,lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:e=>{let t=Kn.n,r=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-wh*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),i=r,s=BigInt("0x100000000000000000000000000000000"),a=Bc(i*e,t),c=Bc(-n*e,t),l=Q(e-a*r-c*o,t),u=Q(-a*n-c*i,t),f=l>s,y=u>s;if(f&&(l=t-l),y&&(u=t-u),l>s||u>s)throw new Error("splitScalar: Endomorphism failed, k="+e);return{k1neg:f,k1:l,k2neg:y,k2:u}}}},bn);function Cc(e,t,r,n){let o=Cr.digest(r instanceof Uint8Array?r:r.subarray());if(_n(o))return o.then(({digest:i})=>(n?.signal?.throwIfAborted(),hr.verify(t,i,e))).catch(i=>{throw i.name==="AbortError"?i:new Mr(String(i))});try{return n?.signal?.throwIfAborted(),hr.verify(t,o.digest,e)}catch(i){throw new Mr(String(i))}}var Fn=class{type="secp256k1";raw;_key;constructor(t){this._key=Pc(t),this.raw=_c(this._key)}toMultihash(){return Bt.digest(Xe(this))}toCID(){return $.createV1(114,this.toMultihash())}toString(){return G.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:Y(this.raw,t.raw)}verify(t,r,n){return Cc(this._key,r,t,n)}};function Xi(e){return new Fn(e)}function _c(e){return hr.ProjectivePoint.fromHex(e).toRawBytes(!0)}function Pc(e){try{return hr.ProjectivePoint.fromHex(e),e}catch(t){throw new Ve(String(t))}}function Uc(e,t){let{Type:r,Data:n}=Jt.decode(e),o=n??new Uint8Array;switch(r){case et.RSA:return Hi(o,t);case et.Ed25519:return xi(o);case et.secp256k1:return Xi(o);case et.ECDSA:return ri(o);default:throw new qe}}function On(e){let{Type:t,Data:r}=Jt.decode(e.digest),n=r??new Uint8Array;switch(t){case et.Ed25519:return xi(n);case et.secp256k1:return Xi(n);case et.ECDSA:return ri(n);default:throw new qe}}function Xe(e){return Jt.encode({Type:et[e.type],Data:e.raw})}var Nc=Symbol.for("nodejs.util.inspect.custom"),Eh=114,Zr=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()})`}[Bo]=!0;toString(){return this.string==null&&(this.string=G.encode(this.multihash.bytes).slice(1)),this.string}toMultihash(){return this.multihash}toCID(){return $.createV1(Eh,this.multihash)}toJSON(){return this.toString()}equals(t){if(t==null)return!1;if(t instanceof Uint8Array)return Y(this.multihash.bytes,t);if(typeof t=="string")return this.toString()===t;if(t?.toMultihash()?.bytes!=null)return Y(this.multihash.bytes,t.toMultihash().bytes);throw new Error("not valid Id")}[Nc](){return`PeerId(${this.toString()})`}},Mn=class extends Zr{type="RSA";publicKey;constructor(t){super({...t,type:"RSA"}),this.publicKey=t.publicKey}},Vn=class extends Zr{type="Ed25519";publicKey;constructor(t){super({...t,type:"Ed25519"}),this.publicKey=t.publicKey}},$n=class extends Zr{type="secp256k1";publicKey;constructor(t){super({...t,type:"secp256k1"}),this.publicKey=t.publicKey}},Sh=2336,Wr=class{type="url";multihash;publicKey;url;constructor(t){this.url=t.toString(),this.multihash=Bt.digest(V(this.url))}[Nc](){return`PeerId(${this.url})`}[Bo]=!0;toString(){return this.toCID().toString()}toMultihash(){return this.multihash}toCID(){return $.createV1(Sh,this.toMultihash())}toJSON(){return this.toString()}equals(t){return t==null?!1:(t instanceof Uint8Array&&(t=M(t)),t.toString()===this.toString())}};var vh=114,Rc=2336;function Lc(e,t){let r;if(e.charAt(0)==="1"||e.charAt(0)==="Q")r=re(G.decode(`z${e}`));else{if(e.startsWith("k51qzi5uqu5")||e.startsWith("kzwfwjn5ji4")||e.startsWith("k2k4r8")||e.startsWith("bafz"))return Ji($.parse(e));if(t==null)throw new nt('Please pass a multibase decoder for strings that do not start with "1" or "Q"');r=re(t.decode(e))}return Dc(r)}function Dc(e){if(Ih(e))return new Mn({multihash:e});if(Ah(e))try{let t=On(e);if(t.type==="Ed25519")return new Vn({multihash:e,publicKey:t});if(t.type==="secp256k1")return new $n({multihash:e,publicKey:t})}catch{let r=M(e.digest);return new Wr(new URL(r))}throw new $e("Supplied PeerID Multihash is invalid")}function Ji(e){if(e?.multihash==null||e.version==null||e.version===1&&e.code!==vh&&e.code!==Rc)throw new fn("Supplied PeerID CID is invalid");if(e.code===Rc){let t=M(e.multihash.digest);return new Wr(new URL(t))}return Dc(e.multihash)}function Ah(e){return e.code===Bt.code}function Ih(e){return e.code===Cr.code}var qn=class{index=0;input="";new(t){return this.index=0,this.input=t,this}readAtomically(t){let r=this.index,n=t();return n===void 0&&(this.index=r),n}parseWith(t){let r=t();if(this.index===this.input.length)return r}peekChar(){if(!(this.index>=this.input.length))return this.input[this.index]}readChar(){if(!(this.index>=this.input.length))return this.input[this.index++]}readGivenChar(t){return this.readAtomically(()=>{let r=this.readChar();if(r===t)return r})}readSeparator(t,r,n){return this.readAtomically(()=>{if(!(r>0&&this.readGivenChar(t)===void 0))return n()})}readNumber(t,r,n,o){return this.readAtomically(()=>{let i=0,s=0,a=this.peekChar();if(a===void 0)return;let c=a==="0",l=2**(8*o)-1;for(;;){let u=this.readAtomically(()=>{let f=this.readChar();if(f===void 0)return;let y=Number.parseInt(f,t);if(!Number.isNaN(y))return y});if(u===void 0)break;if(i*=t,i+=u,i>l||(s+=1,r!==void 0&&s>r))return}if(s!==0)return!n&&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 kc=45,Th=15,pr=new qn;function Qi(e){if(!(e.length>Th))return pr.new(e).parseWith(()=>pr.readIPv4Addr())}function ts(e){if(e.includes("%")&&(e=e.split("%")[0]),!(e.length>kc))return pr.new(e).parseWith(()=>pr.readIPv6Addr())}function Hn(e,t=!1){if(e.includes("%")&&(e=e.split("%")[0]),e.length>kc)return;let r=pr.new(e).parseWith(()=>pr.readIPAddr());if(r)return t&&r.length===4?Uint8Array.from([0,0,0,0,0,0,0,0,0,0,255,255,r[0],r[1],r[2],r[3]]):r}var xw=parseInt("0xFFFF",16),ww=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);function Oc(e){return!!Qi(e)}function Mc(e){return!!ts(e)}function zn(e){return!!Hn(e)}var Vc=Oc,Uh=Mc,es=function(e){let t=0;if(e=e.toString().trim(),Vc(e)){let r=new Uint8Array(t+4);return e.split(/\./g).forEach(n=>{r[t++]=parseInt(n,10)&255}),r}if(Uh(e)){let r=e.split(":",8),n;for(n=0;n<r.length;n++){let i=Vc(r[n]),s;i&&(s=es(r[n]),r[n]=M(s.slice(0,2),"base16")),s!=null&&++n<8&&r.splice(n,0,M(s.slice(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++){let i=parseInt(r[n],16);o[t++]=i>>8&255,o[t++]=i&255}return o}throw new Error("invalid ip address")},$c=function(e,t=0,r){t=~~t,r=r??e.length-t;let n=new DataView(e.buffer);if(r===4){let o=[];for(let i=0;i<r;i++)o.push(e[t+i]);return o.join(".")}if(r===16){let o=[];for(let i=0;i<r;i+=2)o.push(n.getUint16(t+i).toString(16));return o.join(":").replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}return""};var mr={},rs={},Rh=[[4,32,"ip4"],[6,16,"tcp"],[33,16,"dccp"],[41,128,"ip6"],[42,-1,"ip6zone"],[43,8,"ipcidr"],[53,-1,"dns",!0],[54,-1,"dns4",!0],[55,-1,"dns6",!0],[56,-1,"dnsaddr",!0],[132,16,"sctp"],[273,16,"udp"],[275,0,"p2p-webrtc-star"],[276,0,"p2p-webrtc-direct"],[277,0,"p2p-stardust"],[280,0,"webrtc-direct"],[281,0,"webrtc"],[290,0,"p2p-circuit"],[301,0,"udt"],[302,0,"utp"],[400,-1,"unix",!1,!0],[421,-1,"ipfs"],[421,-1,"p2p"],[443,0,"https"],[444,96,"onion"],[445,296,"onion3"],[446,-1,"garlic64"],[448,0,"tls"],[449,-1,"sni"],[460,0,"quic"],[461,0,"quic-v1"],[465,0,"webtransport"],[466,-1,"certhash"],[477,0,"ws"],[478,0,"wss"],[479,0,"p2p-websocket-star"],[480,0,"http"],[481,-1,"http-path"],[777,-1,"memory"]];Rh.forEach(e=>{let t=Lh(...e);rs[t.code]=t,mr[t.name]=t});function Lh(e,t,r,n,o){return{code:e,size:t,name:r,resolvable:!!n,path:!!o}}function Z(e){if(typeof e=="number"){if(rs[e]!=null)return rs[e];throw new Error(`no protocol with code: ${e}`)}else if(typeof e=="string"){if(mr[e]!=null)return mr[e];throw new Error(`no protocol with name: ${e}`)}throw new Error(`invalid protocol id type: ${typeof e}`)}var rb=Z("ip4"),nb=Z("ip6"),ob=Z("ipcidr");function ss(e,t){switch(Z(e).code){case 4:case 41:return kh(t);case 42:return is(t);case 43:return M(t,"base10");case 6:case 273:case 33:case 132:return zc(t).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return is(t);case 421:return Mh(t);case 444:return Hc(t);case 445:return Hc(t);case 466:return Oh(t);case 481:return globalThis.encodeURIComponent(is(t));default:return M(t,"base16")}}function as(e,t){switch(Z(e).code){case 4:return qc(t);case 41:return qc(t);case 42:return os(t);case 43:return V(t,"base10");case 6:case 273:case 33:case 132:return cs(parseInt(t,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return os(t);case 421:return Kh(t);case 444:return Vh(t);case 445:return $h(t);case 466:return Fh(t);case 481:return os(globalThis.decodeURIComponent(t));default:return V(t,"base16")}}var ns=Object.values(_r).map(e=>e.decoder),Dh=function(){let e=ns[0].or(ns[1]);return ns.slice(2).forEach(t=>e=e.or(t)),e}();function qc(e){if(!zn(e))throw new Error("invalid ip address");return es(e)}function kh(e){let t=$c(e,0,e.length);if(t==null)throw new Error("ipBuff is required");if(!zn(t))throw new Error("invalid ip address");return t}function cs(e){let t=new ArrayBuffer(2);return new DataView(t).setUint16(0,e),new Uint8Array(t)}function zc(e){return new DataView(e.buffer).getUint16(e.byteOffset)}function os(e){let t=V(e),r=Uint8Array.from(ar(t.length));return dt([r,t],r.length+t.length)}function is(e){let t=Re(e);if(e=e.slice(Tt(t)),e.length!==t)throw new Error("inconsistent lengths");return M(e)}function Kh(e){let t;e[0]==="Q"||e[0]==="1"?t=re(G.decode(`z${e}`)).bytes:t=$.parse(e).multihash.bytes;let r=Uint8Array.from(ar(t.length));return dt([r,t],r.length+t.length)}function Fh(e){let t=Dh.decode(e),r=Uint8Array.from(ar(t.length));return dt([r,t],r.length+t.length)}function Oh(e){let t=Re(e),r=e.slice(Tt(t));if(r.length!==t)throw new Error("inconsistent lengths");return"u"+M(r,"base64url")}function Mh(e){let t=Re(e),r=e.slice(Tt(t));if(r.length!==t)throw new Error("inconsistent lengths");return M(r,"base58btc")}function Vh(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=Ft.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=cs(n);return dt([r,o],r.length+o.length)}function $h(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=Ft.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=cs(n);return dt([r,o],r.length+o.length)}function Hc(e){let t=e.slice(0,e.length-2),r=e.slice(e.length-2),n=M(t,"base32"),o=zc(r);return`${n}:${o}`}function jc(e){e=us(e);let t=[],r=[],n=null,o=e.split("/").slice(1);if(o.length===1&&o[0]==="")return{bytes:new Uint8Array,string:"/",tuples:[],stringTuples:[],path:null};for(let i=0;i<o.length;i++){let s=o[i],a=Z(s);if(a.size===0){t.push([a.code]),r.push([a.code]);continue}if(i++,i>=o.length)throw new jn("invalid address: "+e);if(a.path===!0){n=us(o.slice(i).join("/")),t.push([a.code,as(a.code,n)]),r.push([a.code,n]);break}let c=as(a.code,o[i]);t.push([a.code,c]),r.push([a.code,ss(a.code,c)])}return{string:Gc(r),bytes:Gn(t),tuples:t,stringTuples:r,path:n}}function fs(e){let t=[],r=[],n=null,o=0;for(;o<e.length;){let i=Re(e,o),s=Tt(i),a=Z(i),c=qh(a,e.slice(o+s));if(c===0){t.push([i]),r.push([i]),o+=s;continue}let l=e.slice(o+s,o+s+c);if(o+=c+s,o>e.length)throw new jn("Invalid address Uint8Array: "+M(e,"base16"));t.push([i,l]);let u=ss(i,l);if(r.push([i,u]),a.path===!0){n=u;break}}return{bytes:Uint8Array.from(e),string:Gc(r),tuples:t,stringTuples:r,path:n}}function Gc(e){let t=[];return e.map(r=>{let n=Z(r[0]);return t.push(n.name),r.length>1&&r[1]!=null&&t.push(r[1]),null}),us(t.join("/"))}function Gn(e){return dt(e.map(t=>{let r=Z(t[0]),n=Uint8Array.from(ar(r.code));return t.length>1&&t[1]!=null&&(n=dt([n,t[1]])),n}))}function qh(e,t){if(e.size>0)return e.size/8;if(e.size===0)return 0;{let r=Re(t instanceof Uint8Array?t:Uint8Array.from(t));return r+Tt(r)}}function us(e){return"/"+e.trim().split("/").filter(t=>t).join("/")}var jn=class extends Error{static name="ParseError";name="ParseError";constructor(t){super(`Error parsing address: ${t}`)}};var Hh=Symbol.for("nodejs.util.inspect.custom"),ds=Symbol.for("@multiformats/js-multiaddr/multiaddr"),zh=[Z("dns").code,Z("dns4").code,Z("dns6").code,Z("dnsaddr").code],ls=class extends Error{constructor(t="No available resolver"){super(t),this.name="NoAvailableResolverError"}},Zn=class e{bytes;#t;#r;#e;#a;[ds]=!0;constructor(t){t==null&&(t="");let r;if(t instanceof Uint8Array)r=fs(t);else if(typeof t=="string"){if(t.length>0&&t.charAt(0)!=="/")throw new Error(`multiaddr "${t}" must start with a "/"`);r=jc(t)}else if(Wc(t))r=fs(t.bytes);else throw new Error("addr must be a string, Buffer, or another Multiaddr");this.bytes=r.bytes,this.#t=r.string,this.#r=r.tuples,this.#e=r.stringTuples,this.#a=r.path}toString(){return this.#t}toJSON(){return this.toString()}toOptions(){let t,r,n,o,i="",s=Z("tcp"),a=Z("udp"),c=Z("ip4"),l=Z("ip6"),u=Z("dns6"),f=Z("ip6zone");for(let[p,T]of this.stringTuples())p===f.code&&(i=`%${T??""}`),zh.includes(p)&&(r=s.name==="tcp"?"tcp":"udp",o=443,n=`${T??""}${i}`,t=p===u.code?6:4),(p===s.code||p===a.code)&&(r=Z(p).name==="tcp"?"tcp":"udp",o=parseInt(T??"")),(p===c.code||p===l.code)&&(r=Z(p).name==="tcp"?"tcp":"udp",n=`${T??""}${i}`,t=p===l.code?6:4);if(t==null||r==null||n==null||o==null)throw new Error('multiaddr must have a valid format: "/{ip4, ip6, dns4, dns6, dnsaddr}/{address}/{tcp, udp}/{port}".');return{family:t,host:n,transport:r,port:o}}protos(){return this.#r.map(([t])=>Object.assign({},Z(t)))}protoCodes(){return this.#r.map(([t])=>t)}protoNames(){return this.#r.map(([t])=>Z(t).name)}tuples(){return this.#r.map(([t,r])=>r==null?[t]:[t,r])}stringTuples(){return this.#e.map(([t,r])=>r==null?[t]:[t,r])}encapsulate(t){return t=new e(t),new e(this.toString()+t.toString())}decapsulate(t){let r=t.toString(),n=this.toString(),o=n.lastIndexOf(r);if(o<0)throw new Error(`Address ${this.toString()} does not contain subaddress: ${t.toString()}`);return new e(n.slice(0,o))}decapsulateCode(t){let r=this.tuples();for(let n=r.length-1;n>=0;n--)if(r[n][0]===t)return new e(Gn(r.slice(0,n)));return this}getPeerId(){try{let t=[];this.stringTuples().forEach(([n,o])=>{n===mr.p2p.code&&t.push([n,o]),n===mr["p2p-circuit"].code&&(t=[])});let r=t.pop();if(r?.[1]!=null){let n=r[1];return n[0]==="Q"||n[0]==="1"?M(G.decode(`z${n}`),"base58btc"):M($.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){return this.#a}equals(t){return Y(this.bytes,t.bytes)}async resolve(t){let r=this.protos().find(i=>i.resolvable);if(r==null)return[this];let n=Zc.get(r.name);if(n==null)throw new ls(`no available resolver for ${r.name}`);return(await n(this,t)).map(i=>ke(i))}nodeAddress(){let t=this.toOptions();if(t.transport!=="tcp"&&t.transport!=="udp")throw new Error(`multiaddr must have a valid format - no protocol with name: "${t.transport}". Must have a valid transport protocol: "{tcp, udp}"`);return{family:t.family,address:t.host,port:t.port}}isThinWaistAddress(t){let r=(t??this).protos();return!(r.length!==2||r[0].code!==4&&r[0].code!==41||r[1].code!==6&&r[1].code!==273)}[Hh](){return`Multiaddr(${this.#t})`}};var Zc=new Map;function Wc(e){return!!e?.[ds]}function ke(e){return new Zn(e)}function Yr(e){let t=new globalThis.AbortController;function r(){t.abort();for(let i of e)i?.removeEventListener!=null&&i.removeEventListener("abort",r)}for(let i of e){if(i?.aborted===!0){r();break}i?.addEventListener!=null&&i.addEventListener("abort",r)}function n(){for(let i of e)i?.removeEventListener!=null&&i.removeEventListener("abort",r)}let o=t.signal;return o.clear=n,o}async function*Wn(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 jh="/",Gh=new TextEncoder().encode(jh),Lb=Gh[0];var Bp=To(ps(),1);var qt=class extends Error{static name="SignatureVerificationError";constructor(t="Record signature verification failed"){super(t),this.name="SignatureVerificationError"}},Yn=class extends Error{static name="RecordExpiredError";constructor(t="Record has expired"){super(t),this.name="RecordExpiredError"}},yr=class extends Error{static name="UnsupportedValidityError";constructor(t="The validity type is unsupported"){super(t),this.name="UnsupportedValidityError"}},Xn=class extends Error{static name="RecordTooLargeError";constructor(t="The record is too large"){super(t),this.name="RecordTooLargeError"}},Jn=class extends Error{static name="InvalidValueError";constructor(t="Value must be a valid content path starting with /"){super(t),this.name="InvalidValueError"}},Qn=class extends Error{static name="InvalidRecordDataError";constructor(t="Invalid record data"){super(t),this.name="InvalidRecordDataError"}},Xr=class extends Error{static name="InvalidEmbeddedPublicKeyError";constructor(t="Invalid embedded public key"){super(t),this.name="InvalidEmbeddedPublicKeyError"}};var Ht;(function(e){let t;(function(o){o.EOL="EOL"})(t=e.ValidityType||(e.ValidityType={}));let r;(function(o){o[o.EOL=0]="EOL"})(r||(r={})),function(o){o.codec=()=>qr(r)}(t=e.ValidityType||(e.ValidityType={}));let n;e.codec=()=>(n==null&&(n=lr((o,i,s={})=>{s.lengthDelimited!==!1&&i.fork(),o.value!=null&&(i.uint32(10),i.bytes(o.value)),o.signatureV1!=null&&(i.uint32(18),i.bytes(o.signatureV1)),o.validityType!=null&&(i.uint32(24),e.ValidityType.codec().encode(o.validityType,i)),o.validity!=null&&(i.uint32(34),i.bytes(o.validity)),o.sequence!=null&&(i.uint32(40),i.uint64(o.sequence)),o.ttl!=null&&(i.uint32(48),i.uint64(o.ttl)),o.pubKey!=null&&(i.uint32(58),i.bytes(o.pubKey)),o.signatureV2!=null&&(i.uint32(66),i.bytes(o.signatureV2)),o.data!=null&&(i.uint32(74),i.bytes(o.data)),s.lengthDelimited!==!1&&i.ldelim()},(o,i,s={})=>{let a={},c=i==null?o.len:o.pos+i;for(;o.pos<c;){let l=o.uint32();switch(l>>>3){case 1:{a.value=o.bytes();break}case 2:{a.signatureV1=o.bytes();break}case 3:{a.validityType=e.ValidityType.codec().decode(o);break}case 4:{a.validity=o.bytes();break}case 5:{a.sequence=o.uint64();break}case 6:{a.ttl=o.uint64();break}case 7:{a.pubKey=o.bytes();break}case 8:{a.signatureV2=o.bytes();break}case 9:{a.data=o.bytes();break}default:{o.skipType(l&7);break}}}return a})),n),e.encode=o=>ur(o,e.codec()),e.decode=(o,i)=>cr(o,e.codec(),i)})(Ht||(Ht={}));var Zh=["string","number","bigint","symbol"],Wh=["Function","Generator","AsyncGenerator","GeneratorFunction","AsyncGeneratorFunction","AsyncFunction","Observable","Array","Buffer","Object","RegExp","Date","Error","Map","Set","WeakMap","WeakSet","ArrayBuffer","SharedArrayBuffer","DataView","Promise","URL","HTMLElement","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","BigInt64Array","BigUint64Array"];function Yc(e){if(e===null)return"null";if(e===void 0)return"undefined";if(e===!0||e===!1)return"boolean";let t=typeof e;if(Zh.includes(t))return t;if(t==="function")return"Function";if(Array.isArray(e))return"Array";if(Yh(e))return"Buffer";let r=Xh(e);return r||"Object"}function Yh(e){return e&&e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer.call(null,e)}function Xh(e){let t=Object.prototype.toString.call(e).slice(8,-1);if(Wh.includes(t))return t}var b=class{constructor(t,r,n){this.major=t,this.majorEncoded=t<<5,this.name=r,this.terminal=n}toString(){return`Type[${this.major}].${this.name}`}compare(t){return this.major<t.major?-1:this.major>t.major?1:0}};b.uint=new b(0,"uint",!0);b.negint=new b(1,"negint",!0);b.bytes=new b(2,"bytes",!0);b.string=new b(3,"string",!0);b.array=new b(4,"array",!1);b.map=new b(5,"map",!1);b.tag=new b(6,"tag",!1);b.float=new b(7,"float",!0);b.false=new b(7,"false",!0);b.true=new b(7,"true",!0);b.null=new b(7,"null",!0);b.undefined=new b(7,"undefined",!0);b.break=new b(7,"break",!0);var L=class{constructor(t,r,n){this.type=t,this.value=r,this.encodedLength=n,this.encodedBytes=void 0,this.byteValue=void 0}toString(){return`Token[${this.type}].${this.value}`}};var gr=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&typeof globalThis.Buffer.isBuffer=="function",Jh=new TextDecoder,Qh=new TextEncoder;function to(e){return gr&&globalThis.Buffer.isBuffer(e)}function tu(e){return e instanceof Uint8Array?to(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e:Uint8Array.from(e)}var eu=gr?(e,t,r)=>r-t>64?globalThis.Buffer.from(e.subarray(t,r)).toString("utf8"):Jc(e,t,r):(e,t,r)=>r-t>64?Jh.decode(e.subarray(t,r)):Jc(e,t,r),ru=gr?e=>e.length>64?globalThis.Buffer.from(e):Xc(e):e=>e.length>64?Qh.encode(e):Xc(e);var xr=gr?(e,t,r)=>to(e)?new Uint8Array(e.subarray(t,r)):e.slice(t,r):(e,t,r)=>e.slice(t,r),nu=gr?(e,t)=>(e=e.map(r=>r instanceof Uint8Array?r:globalThis.Buffer.from(r)),tu(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},ou=gr?e=>globalThis.Buffer.allocUnsafe(e):e=>new Uint8Array(e);function iu(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 Xc(e){let t=[],r=0;for(let n=0;n<e.length;n++){let o=e.charCodeAt(n);o<128?t[r++]=o:o<2048?(t[r++]=o>>6|192,t[r++]=o&63|128):(o&64512)===55296&&n+1<e.length&&(e.charCodeAt(n+1)&64512)===56320?(o=65536+((o&1023)<<10)+(e.charCodeAt(++n)&1023),t[r++]=o>>18|240,t[r++]=o>>12&63|128,t[r++]=o>>6&63|128,t[r++]=o&63|128):(t[r++]=o>>12|224,t[r++]=o>>6&63|128,t[r++]=o&63|128)}return t}function Jc(e,t,r){let n=[];for(;t<r;){let o=e[t],i=null,s=o>239?4:o>223?3:o>191?2:1;if(t+s<=r){let a,c,l,u;switch(s){case 1:o<128&&(i=o);break;case 2:a=e[t+1],(a&192)===128&&(u=(o&31)<<6|a&63,u>127&&(i=u));break;case 3:a=e[t+1],c=e[t+2],(a&192)===128&&(c&192)===128&&(u=(o&15)<<12|(a&63)<<6|c&63,u>2047&&(u<55296||u>57343)&&(i=u));break;case 4:a=e[t+1],c=e[t+2],l=e[t+3],(a&192)===128&&(c&192)===128&&(l&192)===128&&(u=(o&15)<<18|(a&63)<<12|(c&63)<<6|l&63,u>65535&&u<1114112&&(i=u))}}i===null?(i=65533,s=1):i>65535&&(i-=65536,n.push(i>>>10&1023|55296),i=56320|i&1023),n.push(i),t+=s}return tp(n)}var Qc=4096;function tp(e){let t=e.length;if(t<=Qc)return String.fromCharCode.apply(String,e);let r="",n=0;for(;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=Qc));return r}var ep=256,eo=class{constructor(t=ep){this.chunkSize=t,this.cursor=0,this.maxCursor=-1,this.chunks=[],this._initReuseChunk=null}reset(){this.cursor=0,this.maxCursor=-1,this.chunks.length&&(this.chunks=[]),this._initReuseChunk!==null&&(this.chunks.push(this._initReuseChunk),this.maxCursor=this._initReuseChunk.length-1)}push(t){let r=this.chunks[this.chunks.length-1];if(this.cursor+t.length<=this.maxCursor+1){let o=r.length-(this.maxCursor-this.cursor)-1;r.set(t,o)}else{if(r){let o=r.length-(this.maxCursor-this.cursor)-1;o<r.length&&(this.chunks[this.chunks.length-1]=r.subarray(0,o),this.maxCursor=this.cursor-1)}t.length<64&&t.length<this.chunkSize?(r=ou(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=xr(n,0,this.cursor)}else r=nu(this.chunks,this.cursor);return t&&this.reset(),r}};var F="CBOR decode error:",ms="CBOR encode error:",Jr=[];Jr[23]=1;Jr[24]=2;Jr[25]=3;Jr[26]=5;Jr[27]=9;function fe(e,t,r){if(e.length-t<r)throw new Error(`${F} not enough data for type`)}var at=[24,256,65536,4294967296,BigInt("18446744073709551616")];function Ut(e,t,r){fe(e,t,1);let n=e[t];if(r.strict===!0&&n<at[0])throw new Error(`${F} integer encoded in more bytes than necessary (strict decode)`);return n}function Nt(e,t,r){fe(e,t,2);let n=e[t]<<8|e[t+1];if(r.strict===!0&&n<at[1])throw new Error(`${F} integer encoded in more bytes than necessary (strict decode)`);return n}function Rt(e,t,r){fe(e,t,4);let n=e[t]*16777216+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3];if(r.strict===!0&&n<at[2])throw new Error(`${F} integer encoded in more bytes than necessary (strict decode)`);return n}function Lt(e,t,r){fe(e,t,8);let n=e[t]*16777216+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3],o=e[t+4]*16777216+(e[t+5]<<16)+(e[t+6]<<8)+e[t+7],i=(BigInt(n)<<BigInt(32))+BigInt(o);if(r.strict===!0&&i<at[3])throw new Error(`${F} integer encoded in more bytes than necessary (strict decode)`);if(i<=Number.MAX_SAFE_INTEGER)return Number(i);if(r.allowBigInt===!0)return i;throw new Error(`${F} integers outside of the safe integer range are not supported`)}function su(e,t,r,n){return new L(b.uint,Ut(e,t+1,n),2)}function au(e,t,r,n){return new L(b.uint,Nt(e,t+1,n),3)}function cu(e,t,r,n){return new L(b.uint,Rt(e,t+1,n),5)}function uu(e,t,r,n){return new L(b.uint,Lt(e,t+1,n),9)}function kt(e,t){return ut(e,0,t.value)}function ut(e,t,r){if(r<at[0]){let n=Number(r);e.push([t|n])}else if(r<at[1]){let n=Number(r);e.push([t|24,n])}else if(r<at[2]){let n=Number(r);e.push([t|25,n>>>8,n&255])}else if(r<at[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<at[4]){let o=[t|27,0,0,0,0,0,0,0],i=Number(n&BigInt(4294967295)),s=Number(n>>BigInt(32)&BigInt(4294967295));o[8]=i&255,i=i>>8,o[7]=i&255,i=i>>8,o[6]=i&255,i=i>>8,o[5]=i&255,o[4]=s&255,s=s>>8,o[3]=s&255,s=s>>8,o[2]=s&255,s=s>>8,o[1]=s&255,e.push(o)}else throw new Error(`${F} encountered BigInt larger than allowable range`)}}kt.encodedSize=function(t){return ut.encodedSize(t.value)};ut.encodedSize=function(t){return t<at[0]?1:t<at[1]?2:t<at[2]?3:t<at[3]?5:9};kt.compareTokens=function(t,r){return t.value<r.value?-1:t.value>r.value?1:0};function fu(e,t,r,n){return new L(b.negint,-1-Ut(e,t+1,n),2)}function lu(e,t,r,n){return new L(b.negint,-1-Nt(e,t+1,n),3)}function du(e,t,r,n){return new L(b.negint,-1-Rt(e,t+1,n),5)}var ys=BigInt(-1),hu=BigInt(1);function pu(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 L(b.negint,i,9)}if(n.allowBigInt!==!0)throw new Error(`${F} integers outside of the safe integer range are not supported`);return new L(b.negint,ys-BigInt(o),9)}function ro(e,t){let r=t.value,n=typeof r=="bigint"?r*ys-hu:r*-1-1;ut(e,t.type.majorEncoded,n)}ro.encodedSize=function(t){let r=t.value,n=typeof r=="bigint"?r*ys-hu:r*-1-1;return n<at[0]?1:n<at[1]?2:n<at[2]?3:n<at[3]?5:9};ro.compareTokens=function(t,r){return t.value<r.value?1:t.value>r.value?-1:0};function Qr(e,t,r,n){fe(e,t,r+n);let o=xr(e,t+r,t+r+n);return new L(b.bytes,o,r+n)}function mu(e,t,r,n){return Qr(e,t,1,r)}function yu(e,t,r,n){return Qr(e,t,2,Ut(e,t+1,n))}function gu(e,t,r,n){return Qr(e,t,3,Nt(e,t+1,n))}function xu(e,t,r,n){return Qr(e,t,5,Rt(e,t+1,n))}function wu(e,t,r,n){let o=Lt(e,t+1,n);if(typeof o=="bigint")throw new Error(`${F} 64-bit integer bytes lengths not supported`);return Qr(e,t,9,o)}function no(e){return e.encodedBytes===void 0&&(e.encodedBytes=e.type===b.string?ru(e.value):e.value),e.encodedBytes}function wr(e,t){let r=no(t);ut(e,t.type.majorEncoded,r.length),e.push(r)}wr.encodedSize=function(t){let r=no(t);return ut.encodedSize(r.length)+r.length};wr.compareTokens=function(t,r){return np(no(t),no(r))};function np(e,t){return e.length<t.length?-1:e.length>t.length?1:iu(e,t)}function tn(e,t,r,n,o){let i=r+n;fe(e,t,i);let s=new L(b.string,eu(e,t+r,t+i),i);return o.retainStringBytes===!0&&(s.byteValue=xr(e,t+r,t+i)),s}function bu(e,t,r,n){return tn(e,t,1,r,n)}function Eu(e,t,r,n){return tn(e,t,2,Ut(e,t+1,n),n)}function Su(e,t,r,n){return tn(e,t,3,Nt(e,t+1,n),n)}function vu(e,t,r,n){return tn(e,t,5,Rt(e,t+1,n),n)}function Au(e,t,r,n){let o=Lt(e,t+1,n);if(typeof o=="bigint")throw new Error(`${F} 64-bit integer string lengths not supported`);return tn(e,t,9,o,n)}var Iu=wr;function br(e,t,r,n){return new L(b.array,n,r)}function Tu(e,t,r,n){return br(e,t,1,r)}function Bu(e,t,r,n){return br(e,t,2,Ut(e,t+1,n))}function Cu(e,t,r,n){return br(e,t,3,Nt(e,t+1,n))}function _u(e,t,r,n){return br(e,t,5,Rt(e,t+1,n))}function Pu(e,t,r,n){let o=Lt(e,t+1,n);if(typeof o=="bigint")throw new Error(`${F} 64-bit integer array lengths not supported`);return br(e,t,9,o)}function Uu(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${F} indefinite length items not allowed`);return br(e,t,1,1/0)}function oo(e,t){ut(e,b.array.majorEncoded,t.value)}oo.compareTokens=kt.compareTokens;oo.encodedSize=function(t){return ut.encodedSize(t.value)};function Er(e,t,r,n){return new L(b.map,n,r)}function Nu(e,t,r,n){return Er(e,t,1,r)}function Ru(e,t,r,n){return Er(e,t,2,Ut(e,t+1,n))}function Lu(e,t,r,n){return Er(e,t,3,Nt(e,t+1,n))}function Du(e,t,r,n){return Er(e,t,5,Rt(e,t+1,n))}function ku(e,t,r,n){let o=Lt(e,t+1,n);if(typeof o=="bigint")throw new Error(`${F} 64-bit integer map lengths not supported`);return Er(e,t,9,o)}function Ku(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${F} indefinite length items not allowed`);return Er(e,t,1,1/0)}function io(e,t){ut(e,b.map.majorEncoded,t.value)}io.compareTokens=kt.compareTokens;io.encodedSize=function(t){return ut.encodedSize(t.value)};function Fu(e,t,r,n){return new L(b.tag,r,1)}function Ou(e,t,r,n){return new L(b.tag,Ut(e,t+1,n),2)}function Mu(e,t,r,n){return new L(b.tag,Nt(e,t+1,n),3)}function Vu(e,t,r,n){return new L(b.tag,Rt(e,t+1,n),5)}function $u(e,t,r,n){return new L(b.tag,Lt(e,t+1,n),9)}function so(e,t){ut(e,b.tag.majorEncoded,t.value)}so.compareTokens=kt.compareTokens;so.encodedSize=function(t){return ut.encodedSize(t.value)};var up=20,fp=21,lp=22,dp=23;function qu(e,t,r,n){if(n.allowUndefined===!1)throw new Error(`${F} undefined values are not supported`);return n.coerceUndefinedToNull===!0?new L(b.null,null,1):new L(b.undefined,void 0,1)}function Hu(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${F} indefinite length items not allowed`);return new L(b.break,void 0,1)}function gs(e,t,r){if(r){if(r.allowNaN===!1&&Number.isNaN(e))throw new Error(`${F} NaN values are not supported`);if(r.allowInfinity===!1&&(e===1/0||e===-1/0))throw new Error(`${F} Infinity values are not supported`)}return new L(b.float,e,t)}function zu(e,t,r,n){return gs(xs(e,t+1),3,n)}function ju(e,t,r,n){return gs(ws(e,t+1),5,n)}function Gu(e,t,r,n){return gs(Xu(e,t+1),9,n)}function ao(e,t,r){let n=t.value;if(n===!1)e.push([b.float.majorEncoded|up]);else if(n===!0)e.push([b.float.majorEncoded|fp]);else if(n===null)e.push([b.float.majorEncoded|lp]);else if(n===void 0)e.push([b.float.majorEncoded|dp]);else{let o,i=!1;(!r||r.float64!==!0)&&(Wu(n),o=xs(zt,1),n===o||Number.isNaN(n)?(zt[0]=249,e.push(zt.slice(0,3)),i=!0):(Yu(n),o=ws(zt,1),n===o&&(zt[0]=250,e.push(zt.slice(0,5)),i=!0))),i||(hp(n),o=Xu(zt,1),zt[0]=251,e.push(zt.slice(0,9)))}}ao.encodedSize=function(t,r){let n=t.value;if(n===!1||n===!0||n===null||n===void 0)return 1;if(!r||r.float64!==!0){Wu(n);let o=xs(zt,1);if(n===o||Number.isNaN(n))return 3;if(Yu(n),o=ws(zt,1),n===o)return 5}return 9};var Zu=new ArrayBuffer(9),Kt=new DataView(Zu,1),zt=new Uint8Array(Zu,0);function Wu(e){if(e===1/0)Kt.setUint16(0,31744,!1);else if(e===-1/0)Kt.setUint16(0,64512,!1);else if(Number.isNaN(e))Kt.setUint16(0,32256,!1);else{Kt.setFloat32(0,e);let t=Kt.getUint32(0),r=(t&2139095040)>>23,n=t&8388607;if(r===255)Kt.setUint16(0,31744,!1);else if(r===0)Kt.setUint16(0,(e&2147483648)>>16|n>>13,!1);else{let o=r-127;o<-24?Kt.setUint16(0,0):o<-14?Kt.setUint16(0,(t&2147483648)>>16|1<<24+o,!1):Kt.setUint16(0,(t&2147483648)>>16|o+15<<10|n>>13,!1)}}}function xs(e,t){if(e.length-t<2)throw new Error(`${F} not enough data for float16`);let r=(e[t]<<8)+e[t+1];if(r===31744)return 1/0;if(r===64512)return-1/0;if(r===32256)return NaN;let n=r>>10&31,o=r&1023,i;return n===0?i=o*2**-24:n!==31?i=(o+1024)*2**(n-25):i=o===0?1/0:NaN,r&32768?-i:i}function Yu(e){Kt.setFloat32(0,e,!1)}function ws(e,t){if(e.length-t<4)throw new Error(`${F} not enough data for float32`);let r=(e.byteOffset||0)+t;return new DataView(e.buffer,r,4).getFloat32(0,!1)}function hp(e){Kt.setFloat64(0,e,!1)}function Xu(e,t){if(e.length-t<8)throw new Error(`${F} not enough data for float64`);let r=(e.byteOffset||0)+t;return new DataView(e.buffer,r,8).getFloat64(0,!1)}ao.compareTokens=kt.compareTokens;function q(e,t,r){throw new Error(`${F} encountered invalid minor (${r}) for major ${e[t]>>>5}`)}function co(e){return()=>{throw new Error(`${F} ${e}`)}}var _=[];for(let e=0;e<=23;e++)_[e]=q;_[24]=su;_[25]=au;_[26]=cu;_[27]=uu;_[28]=q;_[29]=q;_[30]=q;_[31]=q;for(let e=32;e<=55;e++)_[e]=q;_[56]=fu;_[57]=lu;_[58]=du;_[59]=pu;_[60]=q;_[61]=q;_[62]=q;_[63]=q;for(let e=64;e<=87;e++)_[e]=mu;_[88]=yu;_[89]=gu;_[90]=xu;_[91]=wu;_[92]=q;_[93]=q;_[94]=q;_[95]=co("indefinite length bytes/strings are not supported");for(let e=96;e<=119;e++)_[e]=bu;_[120]=Eu;_[121]=Su;_[122]=vu;_[123]=Au;_[124]=q;_[125]=q;_[126]=q;_[127]=co("indefinite length bytes/strings are not supported");for(let e=128;e<=151;e++)_[e]=Tu;_[152]=Bu;_[153]=Cu;_[154]=_u;_[155]=Pu;_[156]=q;_[157]=q;_[158]=q;_[159]=Uu;for(let e=160;e<=183;e++)_[e]=Nu;_[184]=Ru;_[185]=Lu;_[186]=Du;_[187]=ku;_[188]=q;_[189]=q;_[190]=q;_[191]=Ku;for(let e=192;e<=215;e++)_[e]=Fu;_[216]=Ou;_[217]=Mu;_[218]=Vu;_[219]=$u;_[220]=q;_[221]=q;_[222]=q;_[223]=q;for(let e=224;e<=243;e++)_[e]=co("simple values are not supported");_[244]=q;_[245]=q;_[246]=q;_[247]=qu;_[248]=co("simple values are not supported");_[249]=zu;_[250]=ju;_[251]=Gu;_[252]=q;_[253]=q;_[254]=q;_[255]=Hu;var jt=[];for(let e=0;e<24;e++)jt[e]=new L(b.uint,e,1);for(let e=-1;e>=-24;e--)jt[31-e]=new L(b.negint,e,1);jt[64]=new L(b.bytes,new Uint8Array(0),1);jt[96]=new L(b.string,"",1);jt[128]=new L(b.array,0,1);jt[160]=new L(b.map,0,1);jt[244]=new L(b.false,!1,1);jt[245]=new L(b.true,!0,1);jt[246]=new L(b.null,null,1);function mp(){let e=[];return e[b.uint.major]=kt,e[b.negint.major]=ro,e[b.bytes.major]=wr,e[b.string.major]=Iu,e[b.array.major]=oo,e[b.map.major]=io,e[b.tag.major]=so,e[b.float.major]=ao,e}var N1=mp(),R1=new eo,uo=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(`${ms} object contains circular references`);return new e(r,t)}},Se={null:new L(b.null,null),undefined:new L(b.undefined,void 0),true:new L(b.true,!0),false:new L(b.false,!1),emptyArray:new L(b.array,0),emptyMap:new L(b.map,0)},ve={number(e,t,r,n){return!Number.isInteger(e)||!Number.isSafeInteger(e)?new L(b.float,e):e>=0?new L(b.uint,e):new L(b.negint,e)},bigint(e,t,r,n){return e>=BigInt(0)?new L(b.uint,e):new L(b.negint,e)},Uint8Array(e,t,r,n){return new L(b.bytes,e)},string(e,t,r,n){return new L(b.string,e)},boolean(e,t,r,n){return e?Se.true:Se.false},null(e,t,r,n){return Se.null},undefined(e,t,r,n){return Se.undefined},ArrayBuffer(e,t,r,n){return new L(b.bytes,new Uint8Array(e))},DataView(e,t,r,n){return new L(b.bytes,new Uint8Array(e.buffer,e.byteOffset,e.byteLength))},Array(e,t,r,n){if(!e.length)return r.addBreakTokens===!0?[Se.emptyArray,new L(b.break)]:Se.emptyArray;n=uo.createCheck(n,e);let o=[],i=0;for(let s of e)o[i++]=bs(s,r,n);return r.addBreakTokens?[new L(b.array,e.length),o,new L(b.break)]:[new L(b.array,e.length),o]},Object(e,t,r,n){let o=t!=="Object",i=o?e.keys():Object.keys(e),s=o?e.size:i.length;if(!s)return r.addBreakTokens===!0?[Se.emptyMap,new L(b.break)]:Se.emptyMap;n=uo.createCheck(n,e);let a=[],c=0;for(let l of i)a[c++]=[bs(l,r,n),bs(o?e.get(l):e[l],r,n)];return yp(a,r),r.addBreakTokens?[new L(b.map,s),a,new L(b.break)]:[new L(b.map,s),a]}};ve.Map=ve.Object;ve.Buffer=ve.Uint8Array;for(let e of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))ve[`${e}Array`]=ve.DataView;function bs(e,t={},r){let n=Yc(e),o=t&&t.typeEncoders&&t.typeEncoders[n]||ve[n];if(typeof o=="function"){let s=o(e,n,t,r);if(s!=null)return s}let i=ve[n];if(!i)throw new Error(`${ms} unsupported type: ${n}`);return i(e,n,t,r)}function yp(e,t){t.mapSorter&&e.sort(t.mapSorter)}var gp={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0},fo=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=_[t];if(!n)throw new Error(`${F} no decoder for major type ${t>>>5} (byte 0x${t.toString(16).padStart(2,"0")})`);let o=t&31;r=n(this.data,this._pos,o,this.options)}return this._pos+=r.encodedLength,r}},en=Symbol.for("DONE"),lo=Symbol.for("BREAK");function xp(e,t,r){let n=[];for(let o=0;o<e.value;o++){let i=Sr(t,r);if(i===lo){if(e.value===1/0)break;throw new Error(`${F} got unexpected break to lengthed array`)}if(i===en)throw new Error(`${F} found array but not enough entries (got ${o}, expected ${e.value})`);n[o]=i}return n}function wp(e,t,r){let n=r.useMaps===!0,o=n?void 0:{},i=n?new Map:void 0;for(let s=0;s<e.value;s++){let a=Sr(t,r);if(a===lo){if(e.value===1/0)break;throw new Error(`${F} got unexpected break to lengthed map`)}if(a===en)throw new Error(`${F} found map but not enough entries (got ${s} [no key], expected ${e.value})`);if(n!==!0&&typeof a!="string")throw new Error(`${F} non-string keys not supported (got ${typeof a})`);if(r.rejectDuplicateMapKeys===!0&&(n&&i.has(a)||!n&&a in o))throw new Error(`${F} found repeat map key "${a}"`);let c=Sr(t,r);if(c===en)throw new Error(`${F} found map but not enough entries (got ${s} [no value], expected ${e.value})`);n?i.set(a,c):o[a]=c}return n?i:o}function Sr(e,t){if(e.done())return en;let r=e.next();if(r.type===b.break)return lo;if(r.type.terminal)return r.value;if(r.type===b.array)return xp(r,e,t);if(r.type===b.map)return wp(r,e,t);if(r.type===b.tag){if(t.tags&&typeof t.tags[r.value]=="function"){let n=Sr(e,t);return t.tags[r.value](n)}throw new Error(`${F} tag not supported (${r.value})`)}throw new Error("unsupported")}function Ju(e,t){if(!(e instanceof Uint8Array))throw new Error(`${F} data to decode must be a Uint8Array`);t=Object.assign({},gp,t);let r=t.tokenizer||new fo(e,t),n=Sr(r,t);if(n===en)throw new Error(`${F} did not find any content to decode`);if(n===lo)throw new Error(`${F} got unexpected break`);return[n,e.subarray(r.pos())]}function Es(e,t){let[r,n]=Ju(e,t);if(n.length>0)throw new Error(`${F} too many terminals, data makes no sense`);return r}var Sp=he("ipns:utils"),Qu=V("/ipns/");var vp=0,Ap=18;function tf(e){let t;if(e.pubKey!=null)try{t=Uc(e.pubKey)}catch(r){throw Sp.error(r),r}if(t!=null)return t}function ef(e){let t=V("ipns-signature:");return dt([t,e])}function Fe(e){return"signatureV1"in e?Ht.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}):Ht.encode({pubKey:e.pubKey,signatureV2:e.signatureV2,data:e.data})}function Qt(e){let t=Ht.decode(e);if(t.sequence!=null&&(t.sequence=BigInt(t.sequence)),t.ttl!=null&&(t.ttl=BigInt(t.ttl)),t.signatureV2==null||t.data==null)throw new qt("Missing data or signatureV2");let r=rf(t.data),n=Ip(r.Value),o=M(r.Validity);if(t.value!=null&&t.signatureV1!=null)return Tp(t),{value:n,validityType:Ht.ValidityType.EOL,validity:o,sequence:r.Sequence,ttl:r.TTL,pubKey:t.pubKey,signatureV1:t.signatureV1,signatureV2:t.signatureV2,data:t.data};if(t.signatureV2!=null)return{value:n,validityType:Ht.ValidityType.EOL,validity:o,sequence:r.Sequence,ttl:r.TTL,pubKey:t.pubKey,signatureV2:t.signatureV2,data:t.data};throw new Error("invalid record: does not include signatureV1 or signatureV2")}function rn(e){return dt([Qu,e.bytes])}function le(e){let t=re(e.slice(Qu.length));if(!ho(t,vp)&&!ho(t,Ap))throw new $e("Multihash in IPNS key was not identity or sha2-256");return t}function rf(e){let t=Es(e);if(t.ValidityType===0)t.ValidityType=Ht.ValidityType.EOL;else throw new yr("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 Ip(e){let t=M(e).trim();if(t.startsWith("/"))return t;try{return`/ipfs/${$.decode(e).toV1().toString()}`}catch{}try{return`/ipfs/${$.parse(t).toV1().toString()}`}catch{}throw new Jn("Value must be a valid content path starting with /")}function Tp(e){if(e.data==null)throw new Qn("Record data is missing");let t=rf(e.data);if(!Y(t.Value,e.value??new Uint8Array(0)))throw new qt('Field "value" did not match between protobuf and CBOR');if(!Y(t.Validity,e.validity??new Uint8Array(0)))throw new qt('Field "validity" did not match between protobuf and CBOR');if(t.ValidityType!==e.validityType)throw new qt('Field "validityType" did not match between protobuf and CBOR');if(t.Sequence!==e.sequence)throw new qt('Field "sequence" did not match between protobuf and CBOR');if(t.TTL!==e.ttl)throw new qt('Field "ttl" did not match between protobuf and CBOR')}function ho(e,t){return e.code===t}var n2=he("ipns"),o2=5*60*1e9,Cp="/ipns/",i2=Cp.length;var nf=To(ps(),1);var po=he("ipns:validator"),_p=1024*10,Pp=async(e,t)=>{let r=Qt(t),n;try{let o=ef(r.data);n=await e.verify(o,r.signatureV2)}catch{n=!1}if(!n)throw po.error("record signature verification failed"),new qt("Record signature verification failed");if(r.validityType===Ht.ValidityType.EOL){if(nf.default.fromString(r.validity).toDate().getTime()<Date.now())throw po.error("record has expired"),new Yn("record has expired")}else if(r.validityType!=null)throw po.error("the validity type is unsupported"),new yr("The validity type is unsupported");po("ipns record for %s is valid",r.value)};async function of(e,t){if(t.byteLength>_p)throw new Xn("The record is too large");let r=le(e),n;ho(r,0)&&(n=On(r));let o=Qt(t),i=tf(o)??n;if(i==null)throw new Xr("Could not extract public key from IPNS record or routing key");let s=rn(i.toMultihash());if(!Y(s,e))throw new Xr("Embedded public key did not match routing key");await Pp(i,t)}var mo=class extends Error{name="InvalidMessageLengthError";code="ERR_INVALID_MESSAGE_LENGTH"};async function*nn(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)),We(i)&&(i=i.subarray()),o+=n.decode(i,{stream:!0}),o.length>(t?.maxMessageLength??o.length))throw new mo("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 te(){let e={};return e.promise=new Promise((t,r)=>{e.resolve=t,e.reject=r}),e}var vs=To(af(),1);var sn=class extends Error{constructor(t){super(t),this.name="TimeoutError"}},As=class extends Error{constructor(t){super(),this.name="AbortError",this.message=t}},cf=e=>globalThis.DOMException===void 0?new As(e):new DOMException(e),uf=e=>{let t=e.reason===void 0?cf("This operation was aborted."):e.reason;return t instanceof Error?t:cf(t)};function Is(e,t){let{milliseconds:r,fallback:n,message:o,customTimers:i={setTimeout,clearTimeout}}=t,s,a,l=new Promise((u,f)=>{if(typeof r!="number"||Math.sign(r)!==1)throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${r}\``);if(t.signal){let{signal:p}=t;p.aborted&&f(uf(p)),a=()=>{f(uf(p))},p.addEventListener("abort",a,{once:!0})}if(r===Number.POSITIVE_INFINITY){e.then(u,f);return}let y=new sn;s=i.setTimeout.call(void 0,()=>{if(n){try{u(n())}catch(p){f(p)}return}typeof e.cancel=="function"&&e.cancel(),o===!1?u():o instanceof Error?f(o):(y.message=o??`Promise timed out after ${r} milliseconds`,f(y))},r),(async()=>{try{u(await e)}catch(p){f(p)}})()}).finally(()=>{l.clear(),a&&t.signal&&t.signal.removeEventListener("abort",a)});return l.clear=()=>{i.clearTimeout.call(void 0,s),s=void 0},l}function Ts(e,t,r){let n=0,o=e.length;for(;o>0;){let i=Math.trunc(o/2),s=n+i;r(e[s],t)<=0?(n=++s,o-=i+1):o=i}return n}var an=class{#t=[];enqueue(t,r){r={priority:0,...r};let n={priority:r.priority,id:r.id,run:t};if(this.size===0||this.#t[this.size-1].priority>=r.priority){this.#t.push(n);return}let o=Ts(this.#t,n,(i,s)=>s.priority-i.priority);this.#t.splice(o,0,n)}setPriority(t,r){let n=this.#t.findIndex(i=>i.id===t);if(n===-1)throw new ReferenceError(`No promise function with the id "${t}" exists in the queue.`);let[o]=this.#t.splice(n,1);this.enqueue(o.run,{priority:r,id:t})}dequeue(){return this.#t.shift()?.run}filter(t){return this.#t.filter(r=>r.priority===t.priority).map(r=>r.run)}get size(){return this.#t.length}};var cn=class extends vs.default{#t;#r;#e=0;#a;#c;#p=0;#o;#u;#n;#m;#i=0;#f;#s;#y;#w=1n;timeout;constructor(t){if(super(),t={carryoverConcurrencyCount:!1,intervalCap:Number.POSITIVE_INFINITY,interval:0,concurrency:Number.POSITIVE_INFINITY,autoStart:!0,queueClass:an,...t},!(typeof t.intervalCap=="number"&&t.intervalCap>=1))throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${t.intervalCap?.toString()??""}\` (${typeof t.intervalCap})`);if(t.interval===void 0||!(Number.isFinite(t.interval)&&t.interval>=0))throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${t.interval?.toString()??""}\` (${typeof t.interval})`);this.#t=t.carryoverConcurrencyCount,this.#r=t.intervalCap===Number.POSITIVE_INFINITY||t.interval===0,this.#a=t.intervalCap,this.#c=t.interval,this.#n=new t.queueClass,this.#m=t.queueClass,this.concurrency=t.concurrency,this.timeout=t.timeout,this.#y=t.throwOnTimeout===!0,this.#s=t.autoStart===!1}get#b(){return this.#r||this.#e<this.#a}get#E(){return this.#i<this.#f}#S(){this.#i--,this.#l(),this.emit("next")}#v(){this.#x(),this.#g(),this.#u=void 0}get#A(){let t=Date.now();if(this.#o===void 0){let r=this.#p-t;if(r<0)this.#e=this.#t?this.#i:0;else return this.#u===void 0&&(this.#u=setTimeout(()=>{this.#v()},r)),!0}return!1}#l(){if(this.#n.size===0)return this.#o&&clearInterval(this.#o),this.#o=void 0,this.emit("empty"),this.#i===0&&this.emit("idle"),!1;if(!this.#s){let t=!this.#A;if(this.#b&&this.#E){let r=this.#n.dequeue();return r?(this.emit("active"),r(),t&&this.#g(),!0):!1}}return!1}#g(){this.#r||this.#o!==void 0||(this.#o=setInterval(()=>{this.#x()},this.#c),this.#p=Date.now()+this.#c)}#x(){this.#e===0&&this.#i===0&&this.#o&&(clearInterval(this.#o),this.#o=void 0),this.#e=this.#t?this.#i:0,this.#d()}#d(){for(;this.#l(););}get concurrency(){return this.#f}set concurrency(t){if(!(typeof t=="number"&&t>=1))throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${t}\` (${typeof t})`);this.#f=t,this.#d()}async#I(t){return new Promise((r,n)=>{t.addEventListener("abort",()=>{n(t.reason)},{once:!0})})}setPriority(t,r){this.#n.setPriority(t,r)}async add(t,r={}){return r.id??=(this.#w++).toString(),r={timeout:this.timeout,throwOnTimeout:this.#y,...r},new Promise((n,o)=>{this.#n.enqueue(async()=>{this.#i++,this.#e++;try{r.signal?.throwIfAborted();let i=t({signal:r.signal});r.timeout&&(i=Is(Promise.resolve(i),{milliseconds:r.timeout})),r.signal&&(i=Promise.race([i,this.#I(r.signal)]));let s=await i;n(s),this.emit("completed",s)}catch(i){if(i instanceof sn&&!r.throwOnTimeout){n();return}o(i),this.emit("error",i)}finally{this.#S()}},r),this.emit("add"),this.#l()})}async addAll(t,r){return Promise.all(t.map(async n=>this.add(n,r)))}start(){return this.#s?(this.#s=!1,this.#d(),this):this}pause(){this.#s=!0}clear(){this.#n=new this.#m}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.#i===0&&this.#n.size===0||await this.#h("idle")}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.#i}get isPaused(){return this.#s}};var vr=class extends Error{static name="InvalidRequestError";constructor(t="Invalid request"){super(t),this.name="InvalidRequestError"}},Gt=class extends Error{static name="BadResponseError";constructor(t="Bad response"){super(t),this.name="BadResponseError"}};function Rp(e){return e[Symbol.asyncIterator]!=null}function Lp(e){if(Rp(e))return(async()=>{for await(let t of e)return t})();for(let t of e)return t}var go=Lp;function Dp(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 ff=Dp;function kp(e){return e[Symbol.asyncIterator]!=null}function Kp(e,t){let r=0;if(kp(e))return async function*(){for await(let c of e)yield t(c,r++)}();let n=ff(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 xo=Kp;var lf=V("/ipns/");function df(e){return Y(e.subarray(0,lf.byteLength),lf)}var wo=class{client;constructor(t){this.client=t}async*findProviders(t,r={}){yield*xo(this.client.getProviders(t,r),n=>({id:n.ID,multiaddrs:n.Addrs??[]}))}async provide(){}async cancelReprovide(){}async put(t,r,n){if(!df(t))return;let o=le(t),i=$.createV1(114,o),s=Qt(r);await this.client.putIPNS(i,s,n)}async get(t,r){if(!df(t))throw new St("Not found");let n=le(t),o=$.createV1(114,n);try{let i=await this.client.getIPNS(o,r);return Fe(i)}catch(i){throw i.name==="BadResponseError"?new St("Not found"):i}}},bo=class{client;constructor(t){this.client=t}async findPeer(t,r={}){let n=await go(this.client.getPeers(t,r));if(n!=null)return{id:n.ID,multiaddrs:n.Addrs??[]};throw new St("Not found")}async*getClosestPeers(t,r={}){}};var ft=he("delegated-routing-v1-http-api-client"),Eo={concurrentRequests:4,timeout:3e4,cacheTTL:5*60*1e3,cacheName:"delegated-routing-v1-cache"},So=class{started;httpQueue;shutDownController;clientUrl;timeout;contentRouting;peerRouting;filterAddrs;filterProtocols;inFlightRequests;cacheName;cache;cacheTTL;constructor(t,r={}){this.started=!1,this.shutDownController=new AbortController,this.shutDownController.signal,this.httpQueue=new cn({concurrency:r.concurrentRequests??Eo.concurrentRequests}),this.inFlightRequests=new Map,this.clientUrl=t instanceof URL?t:new URL(t),this.timeout=r.timeout??Eo.timeout,this.filterAddrs=r.filterAddrs,this.filterProtocols=r.filterProtocols,this.contentRouting=new wo(this),this.peerRouting=new bo(this),this.cacheName=r.cacheName??Eo.cacheName,this.cacheTTL=r.cacheTTL??Eo.cacheTTL}get[Os](){return this.contentRouting}get[Ms](){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&&ft("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={}){ft("getProviders starts: %c",t);let n=AbortSignal.timeout(this.timeout),o=Yr([this.shutDownController.signal,n,r.signal]);let i=te(),s=te();this.httpQueue.add(async()=>(i.resolve(),s.promise));try{await i.promise;let a=new URL(`${this.clientUrl}routing/v1/providers/${t.toString()}`);this.#r(a,r.filterAddrs,r.filterProtocols);let c={headers:{Accept:"application/x-ndjson"},signal:o},l=await this.#e(a.toString(),c);if(l==null)throw new Gt("No response received");if(!l.ok)throw l.status===404?new St("No matching records found"):l.status===422?new vr("Request does not conform to schema or semantic constraints"):new Gt(`Unexpected status code: ${l.status}`);if(l.body==null)throw new Gt("Routing response had no body");let u=l.headers.get("Content-Type");if(u==null)throw new Gt("No Content-Type header received");if(u?.startsWith("application/json")){let f=await l.json();for(let y of f.Providers){let p=this.#t(y);p!=null&&(yield p)}}else if(u.includes("application/x-ndjson"))for await(let f of nn(Wn(l.body))){let y=this.#t(f);y!=null&&(yield y)}else throw new Gt(`Unsupported Content-Type: ${u}`)}finally{o.clear(),s.resolve(),ft("getProviders finished: %c",t)}}async*getPeers(t,r={}){ft("getPeers starts: %c",t);let n=AbortSignal.timeout(this.timeout),o=Yr([this.shutDownController.signal,n,r.signal]);let i=te(),s=te();this.httpQueue.add(async()=>(i.resolve(),s.promise));try{await i.promise;let a=new URL(`${this.clientUrl}routing/v1/peers/${t.toCID().toString()}`);this.#r(a,r.filterAddrs,r.filterProtocols);let c={headers:{Accept:"application/x-ndjson"},signal:o},l=await this.#e(a.toString(),c);if(l.status===404)throw new St("No matching records found");if(l.status===422)throw new vr("Request does not conform to schema or semantic constraints");if(l.body==null)throw new Gt("Routing response had no body");if(l.headers.get("Content-Type")==="application/json"){let f=await l.json();for(let y of f.Peers){let p=this.#t(y);p!=null&&(yield p)}}else for await(let f of nn(Wn(l.body))){let y=this.#t(f);y!=null&&(yield y)}}catch(a){ft.error("getPeers errored:",a)}finally{o.clear(),s.resolve(),ft("getPeers finished: %c",t)}}async getIPNS(t,r={}){ft("getIPNS starts: %s",t);let n=AbortSignal.timeout(this.timeout),o=Yr([this.shutDownController.signal,n,r.signal]);let i=te(),s=te();this.httpQueue.add(async()=>(i.resolve(),s.promise));let a=`${this.clientUrl}routing/v1/ipns/${t}`;try{await i.promise;let c={headers:{Accept:"application/vnd.ipfs.ipns-record"},signal:o},l=await this.#e(a,c);if(ft("getIPNS GET %s %d",a,l.status),l.status===404)throw new St("No matching records found");if(l.status===422)throw new vr("Request does not conform to schema or semantic constraints");if(l.body==null)throw new Gt("GET ipns response had no body");let u=await l.arrayBuffer(),f=new Uint8Array(u,0,u.byteLength);return r.validate!==!1&&await of(rn(t.multihash),f),Qt(f)}catch(c){throw ft.error("getIPNS GET %s error:",a,c),c}finally{o.clear(),s.resolve(),ft("getIPNS finished: %s",t)}}async putIPNS(t,r,n={}){ft("putIPNS starts: %c",t);let o=AbortSignal.timeout(this.timeout),i=Yr([this.shutDownController.signal,o,n.signal]);let s=te(),a=te();this.httpQueue.add(async()=>(s.resolve(),a.promise));let c=`${this.clientUrl}routing/v1/ipns/${t}`;try{await s.promise;let l=Fe(r),u={method:"PUT",headers:{"Content-Type":"application/vnd.ipfs.ipns-record"},body:l,signal:i},f=await this.#e(c,u);if(ft("putIPNS PUT %s %d",c,f.status),f.status!==200)throw new Gt("PUT ipns response had status other than 200")}catch(l){throw ft.error("putIPNS PUT %s error:",c,l.stack),l}finally{i.clear(),a.resolve(),ft("putIPNS finished: %c",t)}}#t(t){try{let r=[],n=t.Addrs?.map(ke)??[];return t.Protocols!=null&&r.push(...t.Protocols),t.Protocol!=null&&(r.push(t.Protocol),delete t.Protocol),{...t,Schema:"peer",ID:Lc(t.ID),Addrs:n,Protocols:r}}catch(r){ft.error("could not conform record to peer schema",r)}}#r(t,r,n){if(r!=null||this.filterAddrs!=null){let o=r?.join(",")??this.filterAddrs?.join(",")??"";o!==""&&t.searchParams.set("filter-addrs",o)}if(n!=null||this.filterProtocols!=null){let o=n?.join(",")??this.filterProtocols?.join(",")??"";o!==""&&t.searchParams.set("filter-protocols",o)}}async#e(t,r){let n=r.method??"GET",o=`${n}-${t}`;if(n==="GET"){let c=await this.cache?.match(t);if(c!=null){if(parseInt(c.headers.get("x-cache-expires")??"0",10)>Date.now())return ft("returning cached response for %s",o),c;await this.cache?.delete(t)}}let i=this.inFlightRequests.get(o);if(i!=null){let c=await i;return ft("deduplicating outgoing request for %s",o),c.clone()}let s=fetch(t,r).then(async c=>{if(this.cache!=null&&c.ok&&n==="GET"){let l=Date.now()+this.cacheTTL,u=new Headers(c.headers);u.set("x-cache-expires",l.toString());let f=new Response(c.clone().body,{status:c.status,statusText:c.statusText,headers:u});await this.cache.put(t,f)}return c}).finally(()=>{this.inFlightRequests.delete(o)});return this.inFlightRequests.set(o,s),await s}};function hf(e,t={}){return new So(new URL(e),t)}function vo(){return{filterProtocols:["unknown","transport-bitswap","transport-ipfs-gateway-http"],filterAddrs:["https","webtransport","webrtc","webrtc-direct","wss","tls"]}}var pf=V("/ipns/");function mf(e){return Y(e.subarray(0,pf.byteLength),pf)}var Bs=class{client;constructor(t,r={}){this.client=hf(t,r)}async provide(t,r){}async cancelReprovide(t,r){}async*findProviders(t,r){yield*xo(this.client.getProviders(t,r),n=>({id:n.ID,multiaddrs:n.Addrs,protocols:n.Protocols}))}async put(t,r,n){if(!mf(t))return;let o=le(t),i=$.createV1(114,o),s=Qt(r);await this.client.putIPNS(i,s,n)}async get(t,r){if(!mf(t))throw new St("Not found");let n=le(t),o=$.createV1(114,n);try{let i=await this.client.getIPNS(o,r);return Fe(i)}catch(i){throw i.name==="BadResponseError"?new St("Not found"):i}}async findPeer(t,r){let n=await go(this.client.getPeers(t,r));if(n!=null)return{id:n.ID,multiaddrs:n.Addrs??[]};throw new St("Not found")}async*getClosestPeers(t,r){}};function yf(e,t){let r=t??vo();return new Bs(new URL(e),r)}var gf="[a-fA-F\\d:]",Ae=e=>e&&e.includeBoundaries?`(?:(?<=\\s|^)(?=${gf})|(?<=${gf})(?=\\s|$))`:"",Zt="(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}",ot="[a-fA-F\\d]{1,4}",Ao=`
4
4
  (?:
5
- (?:${nt}:){7}(?:${nt}|:)| // 1:2:3:4:5:6:7:: 1:2:3:4:5:6:7:8
6
- (?:${nt}:){6}(?:${Wt}|:${nt}|:)| // 1:2:3:4:5:6:: 1:2:3:4:5:6::8 1:2:3:4:5:6::8 1:2:3:4:5:6::1.2.3.4
7
- (?:${nt}:){5}(?::${Wt}|(?::${nt}){1,2}|:)| // 1:2:3:4:5:: 1:2:3:4:5::7:8 1:2:3:4:5::8 1:2:3:4:5::7:1.2.3.4
8
- (?:${nt}:){4}(?:(?::${nt}){0,1}:${Wt}|(?::${nt}){1,3}|:)| // 1:2:3:4:: 1:2:3:4::6:7:8 1:2:3:4::8 1:2:3:4::6:7:1.2.3.4
9
- (?:${nt}:){3}(?:(?::${nt}){0,2}:${Wt}|(?::${nt}){1,4}|:)| // 1:2:3:: 1:2:3::5:6:7:8 1:2:3::8 1:2:3::5:6:7:1.2.3.4
10
- (?:${nt}:){2}(?:(?::${nt}){0,3}:${Wt}|(?::${nt}){1,5}|:)| // 1:2:: 1:2::4:5:6:7:8 1:2::8 1:2::4:5:6:7:1.2.3.4
11
- (?:${nt}:){1}(?:(?::${nt}){0,4}:${Wt}|(?::${nt}){1,6}|:)| // 1:: 1::3:4:5:6:7:8 1::8 1::3:4:5:6:7:1.2.3.4
12
- (?::(?:(?::${nt}){0,5}:${Wt}|(?::${nt}){1,7}|:)) // ::2:3:4:5:6:7:8 ::2:3:4:5:6:7:8 ::8 ::1.2.3.4
5
+ (?:${ot}:){7}(?:${ot}|:)| // 1:2:3:4:5:6:7:: 1:2:3:4:5:6:7:8
6
+ (?:${ot}:){6}(?:${Zt}|:${ot}|:)| // 1:2:3:4:5:6:: 1:2:3:4:5:6::8 1:2:3:4:5:6::8 1:2:3:4:5:6::1.2.3.4
7
+ (?:${ot}:){5}(?::${Zt}|(?::${ot}){1,2}|:)| // 1:2:3:4:5:: 1:2:3:4:5::7:8 1:2:3:4:5::8 1:2:3:4:5::7:1.2.3.4
8
+ (?:${ot}:){4}(?:(?::${ot}){0,1}:${Zt}|(?::${ot}){1,3}|:)| // 1:2:3:4:: 1:2:3:4::6:7:8 1:2:3:4::8 1:2:3:4::6:7:1.2.3.4
9
+ (?:${ot}:){3}(?:(?::${ot}){0,2}:${Zt}|(?::${ot}){1,4}|:)| // 1:2:3:: 1:2:3::5:6:7:8 1:2:3::8 1:2:3::5:6:7:1.2.3.4
10
+ (?:${ot}:){2}(?:(?::${ot}){0,3}:${Zt}|(?::${ot}){1,5}|:)| // 1:2:: 1:2::4:5:6:7:8 1:2::8 1:2::4:5:6:7:1.2.3.4
11
+ (?:${ot}:){1}(?:(?::${ot}){0,4}:${Zt}|(?::${ot}){1,6}|:)| // 1:: 1::3:4:5:6:7:8 1::8 1::3:4:5:6:7:1.2.3.4
12
+ (?::(?:(?::${ot}){0,5}:${Zt}|(?::${ot}){1,7}|:)) // ::2:3:4:5:6:7:8 ::2:3:4:5:6:7:8 ::8 ::1.2.3.4
13
13
  )(?:%[0-9a-zA-Z]{1,})? // %eth0 %1
14
- `.replace(/\s*\/\/.*$/gm,"").replace(/\n/g,"").trim(),v0=new RegExp(`(?:^${Wt}$)|(?:^${No}$)`),A0=new RegExp(`^${Wt}$`),I0=new RegExp(`^${No}$`),Fs=e=>e&&e.exact?v0:new RegExp(`(?:${Ie(e)}${Wt}${Ie(e)})|(?:${Ie(e)}${No}${Ie(e)})`,"g");Fs.v4=e=>e&&e.exact?A0:new RegExp(`${Ie(e)}${Wt}${Ie(e)}`,"g");Fs.v6=e=>e&&e.exact?I0:new RegExp(`${Ie(e)}${No}${Ie(e)}`,"g");var Ms=Fs;function Vs(e){let t=(...r)=>e(...r);return Object.defineProperty(t,"name",{value:`functionTimeout(${e.name||"<anonymous>"})`,configurable:!0}),t}function Nf(){return!1}var{toString:T0}=Object.prototype;function $s(e){return T0.call(e)==="[object RegExp]"}var Rf={global:"g",ignoreCase:"i",multiline:"m",dotAll:"s",sticky:"y",unicode:"u"};function qs(e,t={}){if(!$s(e))throw new TypeError("Expected a RegExp instance");let r=Object.keys(Rf).map(o=>(typeof t[o]=="boolean"?t[o]:e[o])?Rf[o]:"").join(""),n=new RegExp(t.source||e.source,r);return n.lastIndex=typeof t.lastIndex=="number"?t.lastIndex:e.lastIndex,n}function Hs(e,t,{timeout:r}={}){try{return Vs(()=>qs(e).test(t),{timeout:r})()}catch(n){if(Nf(n))return!1;throw n}}var C0=15,B0=45,Uf={timeout:400};function zs(e){return e.length>B0?!1:Hs(Ms.v6({exact:!0}),e,Uf)}function Lf(e){return e.length>C0?!1:Hs(Ms.v4({exact:!0}),e,Uf)}var Of={http:"80",https:"443",ws:"80",wss:"443"},_0=["http","https","ws","wss"];function kf(e,t){t=t??{};let r=t.defaultDnsType??"dns",{scheme:n,hostname:o,port:i,path:s}=P0(e),a=[D0(o,r),N0(i,n),R0(n)];s!=null&&a.push(U0(s));let c="/"+a.filter(l=>!!l).reduce((l,u)=>l.concat(u),[]).join("/");return Fe(c)}function P0(e){let[t]=e.split(":");_0.includes(t)||(e="http"+e.substring(t.length));let{protocol:r,hostname:n,port:o,pathname:i,search:s}=new URL(e);if(o==null||o===""){let c=L0(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 D0(e,t){if(!(e==null||e==="")){if(Lf(e))return["ip4",e];if(zs(e))return["ip6",e];if(e[0]==="["){let r=e.substring(1,e.length-1);if(zs(r))return["ip6",r]}return[t,e]}}function N0(e,t){if(!(e==null||e===""))return t==="udp"?["udp",e]:["tcp",e]}function R0(e){if(e.match(/^tcp$|^udp$/)==null)return e==="https"?["/tls/http"]:e==="wss"?["/tls/ws"]:[e]}function U0(e){if(!(e==null||e===""))return["http-path",encodeURIComponent(e)]}function L0(e){if(!(e==null||e===""||Of[e]==null))return Of[e]}var O0=["https://trustless-gateway.link","https://4everland.io"],k0=2336;function K0(e){return e=e.toString(),{id:as($.createV1(k0,It.digest(M(e)))),multiaddrs:[kf(e)]}}var js=class{gateways;shuffle;constructor(t={}){this.gateways=(t.gateways??O0).map(r=>K0(r)),this.shuffle=t.shuffle??!0}async*findProviders(t,r){yield*(this.shuffle?this.gateways.toSorted(()=>Math.random()>.5?1:-1):this.gateways).map(n=>({...n,protocols:["transport-ipfs-gateway-http"]}))}};function Kf(e={}){return new js(e)}var Gs=class{libp2p;constructor(t){this.libp2p=t}async provide(t,r){await this.libp2p.contentRouting.provide(t,r)}async cancelReprovide(t,r){await this.libp2p.contentRouting.cancelReprovide(t,r)}async*findProviders(t,r){yield*this.libp2p.contentRouting.findProviders(t,r)}async put(t,r,n){await this.libp2p.contentRouting.put(t,r,n)}async get(t,r){return this.libp2p.contentRouting.get(t,r)}async findPeer(t,r){return this.libp2p.peerRouting.findPeer(t,r)}async*getClosestPeers(t,r){yield*this.libp2p.peerRouting.getClosestPeers(t,r)}};function Ff(e){return new Gs(e)}return zf(F0);})();
14
+ `.replace(/\s*\/\/.*$/gm,"").replace(/\n/g,"").trim(),Fp=new RegExp(`(?:^${Zt}$)|(?:^${Ao}$)`),Op=new RegExp(`^${Zt}$`),Mp=new RegExp(`^${Ao}$`),Cs=e=>e&&e.exact?Fp:new RegExp(`(?:${Ae(e)}${Zt}${Ae(e)})|(?:${Ae(e)}${Ao}${Ae(e)})`,"g");Cs.v4=e=>e&&e.exact?Op:new RegExp(`${Ae(e)}${Zt}${Ae(e)}`,"g");Cs.v6=e=>e&&e.exact?Mp:new RegExp(`${Ae(e)}${Ao}${Ae(e)}`,"g");var _s=Cs;function Ps(e){let t=(...r)=>e(...r);return Object.defineProperty(t,"name",{value:`functionTimeout(${e.name||"<anonymous>"})`,configurable:!0}),t}function xf(){return!1}var{toString:Vp}=Object.prototype;function Us(e){return Vp.call(e)==="[object RegExp]"}var wf={global:"g",ignoreCase:"i",multiline:"m",dotAll:"s",sticky:"y",unicode:"u"};function Ns(e,t={}){if(!Us(e))throw new TypeError("Expected a RegExp instance");let r=Object.keys(wf).map(o=>(typeof t[o]=="boolean"?t[o]:e[o])?wf[o]:"").join(""),n=new RegExp(t.source||e.source,r);return n.lastIndex=typeof t.lastIndex=="number"?t.lastIndex:e.lastIndex,n}function Rs(e,t,{timeout:r}={}){try{return Ps(()=>Ns(e).test(t),{timeout:r})()}catch(n){if(xf(n))return!1;throw n}}var $p=15,qp=45,bf={timeout:400};function Ls(e){return e.length>qp?!1:Rs(_s.v6({exact:!0}),e,bf)}function Ef(e){return e.length>$p?!1:Rs(_s.v4({exact:!0}),e,bf)}var Sf={http:"80",https:"443",ws:"80",wss:"443"},Hp=["http","https","ws","wss"];function vf(e,t){t=t??{};let r=t.defaultDnsType??"dns",{scheme:n,hostname:o,port:i,path:s}=zp(e),a=[jp(o,r),Gp(i,n),Zp(n)];s!=null&&a.push(Wp(s));let c="/"+a.filter(l=>!!l).reduce((l,u)=>l.concat(u),[]).join("/");return ke(c)}function zp(e){let[t]=e.split(":");Hp.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=Yp(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 jp(e,t){if(!(e==null||e==="")){if(Ef(e))return["ip4",e];if(Ls(e))return["ip6",e];if(e[0]==="["){let r=e.substring(1,e.length-1);if(Ls(r))return["ip6",r]}return[t,e]}}function Gp(e,t){if(!(e==null||e===""))return t==="udp"?["udp",e]:["tcp",e]}function Zp(e){if(e.match(/^tcp$|^udp$/)==null)return e==="https"?["/tls/http"]:e==="wss"?["/tls/ws"]:[e]}function Wp(e){if(!(e==null||e===""))return["http-path",encodeURIComponent(e)]}function Yp(e){if(!(e==null||e===""||Sf[e]==null))return Sf[e]}var Xp=["https://trustless-gateway.link","https://4everland.io"],Jp=2336;function Qp(e){return e=e.toString(),{id:Ji($.createV1(Jp,Bt.digest(V(e)))),multiaddrs:[vf(e)]}}var Ds=class{gateways;shuffle;constructor(t={}){this.gateways=(t.gateways??Xp).map(r=>Qp(r)),this.shuffle=t.shuffle??!0}async*findProviders(t,r){yield*(this.shuffle?this.gateways.toSorted(()=>Math.random()>.5?1:-1):this.gateways).map(n=>({...n,protocols:["transport-ipfs-gateway-http"]}))}};function Af(e={}){return new Ds(e)}var ks=class{libp2p;constructor(t){this.libp2p=t}async provide(t,r){await this.libp2p.contentRouting.provide(t,r)}async cancelReprovide(t,r){await this.libp2p.contentRouting.cancelReprovide(t,r)}async*findProviders(t,r){yield*this.libp2p.contentRouting.findProviders(t,r)}async put(t,r,n){await this.libp2p.contentRouting.put(t,r,n)}async get(t,r){return this.libp2p.contentRouting.get(t,r)}async findPeer(t,r){return this.libp2p.peerRouting.findPeer(t,r)}async*getClosestPeers(t,r){yield*this.libp2p.peerRouting.getClosestPeers(t,r)}};function If(e){return new ks(e)}return Uf(t0);})();
15
15
  /*! Bundled license information:
16
16
 
17
17
  @noble/hashes/esm/utils.js: