@helia/routers 3.1.2-50a97662 → 3.1.2-7a52e951

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,6 +1,6 @@
1
1
  (function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.HeliaRouters = factory()}(typeof self !== 'undefined' ? self : this, function () {
2
2
  "use strict";var HeliaRouters=(()=>{var kf=Object.create;var dn=Object.defineProperty;var Kf=Object.getOwnPropertyDescriptor;var Of=Object.getOwnPropertyNames;var Ff=Object.getPrototypeOf,Mf=Object.prototype.hasOwnProperty;var Hs=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Bt=(e,t)=>{for(var r in t)dn(e,r,{get:t[r],enumerable:!0})},zs=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Of(t))!Mf.call(e,o)&&o!==r&&dn(e,o,{get:()=>t[o],enumerable:!(n=Kf(t,o))||n.enumerable});return e};var Io=(e,t,r)=>(r=e!=null?kf(Ff(e)):{},zs(t||!e||!e.__esModule?dn(r,"default",{value:e,enumerable:!0}):r,e)),Vf=e=>zs(dn({},"__esModule",{value:!0}),e);var bs=Hs((Db,ws)=>{var Lb=function(){typeof ws<"u"&&(ws.exports=y);var e=86400,t=3200,r=146097*t/400,n=e*r,o=1e3*n,i=864e13,s=4294967296,c=1e6,a="000000000",l=Math.trunc||function(g){var A=g-g%1;return A==0&&(g<0||g===0&&1/g!=1/0)?-0:A},u=y.prototype,f=(y.fromDate=function(g){return new y(+g)},y.fromInt64BE=d(0,1,2,3,0,4),y.fromInt64LE=d(3,2,1,0,4,0),y.fromString=function(I){var A,R=new y,I=(I+="").replace(/^\s*[+\-]?\d+/,function(U){var U=+U,$=1970+(U-1970)%400;return R.year=U-$,$}).replace(/(?:Z|([+\-]\d{2}):?(\d{2}))$/,function(C,U,$){return U<0&&($*=-1),A=6e4*(60*+U+ +$),""}).replace(/\.\d+$/,function(C){return R.nano=+(C+a).substr(1,9),""}).split(/\D+/);if(1<I.length?I[1]--:I[1]=0,R.time=A=Date.UTC.apply(Date,I)-(A||0),isNaN(A))throw new TypeError("Invalid Date");return k(R)},y.fromTimeT=function(g){return z(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=k(this);return(g.time%1e3*c+ +g.nano+1e9)%1e9},u.getTimeT=function(){var A=k(this),g=Math.floor(A.time/1e3),A=A.year;return A&&(g+=A*r*e/t),g},u.getYear=function(){return this.toDate().getUTCFullYear()+this.year},u.toDate=function(){return O(k(this).time)},u.toJSON=function(){return this.toString().replace(/0{1,6}Z$/,"Z")},u.toString=function(g){var A=this,R=A.toDate(),I={H:function(){return N(R.getUTCHours())},L:function(){return L(R.getUTCMilliseconds(),3)},M:function(){return N(R.getUTCMinutes())},N:function(){return L(A.getNano(),9)},S:function(){return N(R.getUTCSeconds())},Y:function(){var C=A.getYear();return 999999<C?"+"+C:9999<C?"+"+L(C,6):0<=C?L(C,4):-999999<=C?"-"+L(-C,6):C},a:function(){return S[R.getUTCDay()]},b:function(){return p[R.getUTCMonth()]},d:function(){return N(R.getUTCDate())},e:function(){return function(C){return(9<C?"":" ")+(0|C)}(R.getUTCDate())},m:function(){return N(R.getUTCMonth()+1)}};return function C(U){return U.replace(/%./g,function($){var w=$[1],x=_[w],w=I[w];return x?C(x):w?w():$})}(g||f)},u.writeInt64BE=T(0,1,2,3,0,4),u.writeInt64LE=T(3,2,1,0,4,0),"%Y-%m-%dT%H:%M:%S.%NZ"),p=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],S=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],_={"%":"%",F:"%Y-%m-%d",n:`
3
- `,R:"%H:%M",T:"%H:%M:%S",t:" ",X:"%T",Z:"GMT",z:"+0000"};return y;function y(g,A,R){var I=this;if(!(I instanceof y))return new y(g,A,R);I.time=+g||0,I.nano=+A||0,I.year=+R||0,k(I)}function k(g){var A,R,I,C=g.year,U=g.time,$=g.nano,x=(($<0||c<=$)&&($-=(R=Math.floor($/c))*c,U+=R,R=1),C%t);return(U<-i||i<U||x)&&((A=l(U/o))&&(C+=A*t,U-=A*o),(I=O(U)).setUTCFullYear(x+I.getUTCFullYear()),I=(U=+I)+(A=l((C-=x)/t))*o,A&&-i<=I&&I<=i&&(C-=A*t,U=I),R=1),R&&(g.year=C,g.time=U,g.nano=$),g}function O(g){var A=new Date(0);return A.setTime(g),A}function z(C,I){C=+C||0;var R=l((I=(I|0)*s)/n)+l(C/n),I=I%n+C%n,C=l(I/n);return C&&(R+=C,I-=C*n),new y(1e3*I,0,R*t)}function T(g,A,R,I,C,U){return function(x,w){var E=k(this);x=x||new Array(8),v(x,w|=0);var h=Math.floor(E.time/1e3),E=E.year*(r*e/t),K=l(E/s)+l(h/s),E=E%s+h%s,h=Math.floor(E/s);return h&&(K+=h,E-=h*s),$(x,w+C,K),$(x,w+U,E),x};function $(x,w,K){x[w+g]=K>>24&255,x[w+A]=K>>16&255,x[w+R]=K>>8&255,x[w+I]=255&K}}function d(g,A,R,I,C,U){return function(x,w){v(x,w|=0);var K=$(x,w+C);return z($(x,w+U),K)};function $(x,w){return 16777216*x[w+g]+(x[w+A]<<16|x[w+R]<<8|x[w+I])}}function v(g,A){if(g=g&&g.length,g==null)throw new TypeError("Invalid Buffer");if(g<A+8)throw new RangeError("Out of range")}function N(g){return(9<g?"":"0")+(0|g)}function L(g,A){return(a+(0|g)).substr(-A)}}()});var hf=Hs((T2,Bs)=>{"use strict";var Rp=Object.prototype.hasOwnProperty,Tt="~";function cn(){}Object.create&&(cn.prototype=Object.create(null),new cn().__proto__||(Tt=!1));function Lp(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function df(e,t,r,n,o){if(typeof r!="function")throw new TypeError("The listener must be a function");var i=new Lp(r,n||e,o),s=Tt?Tt+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 cn:delete e._events[t]}function vt(){this._events=new cn,this._eventsCount=0}vt.prototype.eventNames=function(){var t=[],r,n;if(this._eventsCount===0)return t;for(n in r=this._events)Rp.call(r,n)&&t.push(Tt?n.slice(1):n);return Object.getOwnPropertySymbols?t.concat(Object.getOwnPropertySymbols(r)):t};vt.prototype.listeners=function(t){var r=Tt?Tt+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};vt.prototype.listenerCount=function(t){var r=Tt?Tt+t:t,n=this._events[r];return n?n.fn?1:n.length:0};vt.prototype.emit=function(t,r,n,o,i,s){var c=Tt?Tt+t:t;if(!this._events[c])return!1;var a=this._events[c],l=arguments.length,u,f;if(a.fn){switch(a.once&&this.removeListener(t,a.fn,void 0,!0),l){case 1:return a.fn.call(a.context),!0;case 2:return a.fn.call(a.context,r),!0;case 3:return a.fn.call(a.context,r,n),!0;case 4:return a.fn.call(a.context,r,n,o),!0;case 5:return a.fn.call(a.context,r,n,o,i),!0;case 6:return a.fn.call(a.context,r,n,o,i,s),!0}for(f=1,u=new Array(l-1);f<l;f++)u[f-1]=arguments[f];a.fn.apply(a.context,u)}else{var p=a.length,S;for(f=0;f<p;f++)switch(a[f].once&&this.removeListener(t,a[f].fn,void 0,!0),l){case 1:a[f].fn.call(a[f].context);break;case 2:a[f].fn.call(a[f].context,r);break;case 3:a[f].fn.call(a[f].context,r,n);break;case 4:a[f].fn.call(a[f].context,r,n,o);break;default:if(!u)for(S=1,u=new Array(l-1);S<l;S++)u[S-1]=arguments[S];a[f].fn.apply(a[f].context,u)}}return!0};vt.prototype.on=function(t,r,n){return df(this,t,r,n,!1)};vt.prototype.once=function(t,r,n){return df(this,t,r,n,!0)};vt.prototype.removeListener=function(t,r,n,o){var i=Tt?Tt+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 c=0,a=[],l=s.length;c<l;c++)(s[c].fn!==r||o&&!s[c].once||n&&s[c].context!==n)&&a.push(s[c]);a.length?this._events[i]=a.length===1?a[0]:a:yo(this,i)}return this};vt.prototype.removeAllListeners=function(t){var r;return t?(r=Tt?Tt+t:t,this._events[r]&&yo(this,r)):(this._events=new cn,this._eventsCount=0),this};vt.prototype.off=vt.prototype.removeListener;vt.prototype.addListener=vt.prototype.on;vt.prefixed=Tt;vt.EventEmitter=vt;typeof Bs<"u"&&(Bs.exports=vt)});var r0={};Bt(r0,{delegatedHTTPRouting:()=>Sf,delegatedHTTPRoutingDefaults:()=>vo,httpGatewayRouting:()=>_f,libp2pRouting:()=>Uf});var js=Symbol.for("@libp2p/content-routing");var To=Symbol.for("@libp2p/peer-id");var Gs=Symbol.for("@libp2p/peer-routing");var ut=class extends Error{static name="InvalidParametersError";constructor(t="Invalid parameters"){super(t),this.name="InvalidParametersError"}},We=class extends Error{static name="InvalidPublicKeyError";constructor(t="Invalid public key"){super(t),this.name="InvalidPublicKeyError"}};var Pt=class extends Error{static name="NotFoundError";constructor(t="Not found"){super(t),this.name="NotFoundError"}};var hn=class extends Error{static name="InvalidCIDError";constructor(t="Invalid CID"){super(t),this.name="InvalidCIDError"}},Xe=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 Uo={};Bt(Uo,{base32:()=>jt,base32hex:()=>Xf,base32hexpad:()=>Qf,base32hexpadupper:()=>tl,base32hexupper:()=>Jf,base32pad:()=>Yf,base32padupper:()=>Wf,base32upper:()=>Zf,base32z:()=>el});var c0=new Uint8Array(0);function Zs(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 ce(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 Ys(e){return new TextEncoder().encode(e)}function Ws(e){return new TextDecoder().decode(e)}function qf(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var o=0;o<e.length;o++){var i=e.charAt(o),s=i.charCodeAt(0);if(r[s]!==255)throw new TypeError(i+" is ambiguous");r[s]=o}var c=e.length,a=e.charAt(0),l=Math.log(c)/Math.log(256),u=Math.log(256)/Math.log(c);function f(_){if(_ instanceof Uint8Array||(ArrayBuffer.isView(_)?_=new Uint8Array(_.buffer,_.byteOffset,_.byteLength):Array.isArray(_)&&(_=Uint8Array.from(_))),!(_ instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(_.length===0)return"";for(var y=0,k=0,O=0,z=_.length;O!==z&&_[O]===0;)O++,y++;for(var T=(z-O)*u+1>>>0,d=new Uint8Array(T);O!==z;){for(var v=_[O],N=0,L=T-1;(v!==0||N<k)&&L!==-1;L--,N++)v+=256*d[L]>>>0,d[L]=v%c>>>0,v=v/c>>>0;if(v!==0)throw new Error("Non-zero carry");k=N,O++}for(var g=T-k;g!==T&&d[g]===0;)g++;for(var A=a.repeat(y);g<T;++g)A+=e.charAt(d[g]);return A}function p(_){if(typeof _!="string")throw new TypeError("Expected String");if(_.length===0)return new Uint8Array;var y=0;if(_[y]!==" "){for(var k=0,O=0;_[y]===a;)k++,y++;for(var z=(_.length-y)*l+1>>>0,T=new Uint8Array(z);_[y];){var d=r[_.charCodeAt(y)];if(d===255)return;for(var v=0,N=z-1;(d!==0||v<O)&&N!==-1;N--,v++)d+=c*T[N]>>>0,T[N]=d%256>>>0,d=d/256>>>0;if(d!==0)throw new Error("Non-zero carry");O=v,y++}if(_[y]!==" "){for(var L=z-O;L!==z&&T[L]===0;)L++;for(var g=new Uint8Array(k+(z-L)),A=k;L!==z;)g[A++]=T[L++];return g}}}function S(_){var y=p(_);if(y)return y;throw new Error(`Non-${t} character`)}return{encode:f,decodeUnsafe:p,decode:S}}var $f=qf,Hf=$f,Js=Hf;var Co=class{name;prefix;baseEncode;constructor(t,r,n){this.name=t,this.prefix=r,this.baseEncode=n}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}},Bo=class{name;prefix;baseDecode;prefixCodePoint;constructor(t,r,n){this.name=t,this.prefix=r;let o=r.codePointAt(0);if(o===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=o,this.baseDecode=n}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return Qs(this,t)}},Po=class{decoders;constructor(t){this.decoders=t}or(t){return Qs(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 Qs(e,t){return new Po({...e.decoders??{[e.prefix]:e},...t.decoders??{[t.prefix]:t}})}var _o=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(t,r,n,o){this.name=t,this.prefix=r,this.baseEncode=n,this.baseDecode=o,this.encoder=new Co(t,r,n),this.decoder=new Bo(t,r,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function Qe({name:e,prefix:t,encode:r,decode:n}){return new _o(e,t,r,n)}function Se({name:e,prefix:t,alphabet:r}){let{encode:n,decode:o}=Js(r,e);return Qe({prefix:t,name:e,encode:n,decode:i=>ce(o(i))})}function zf(e,t,r,n){let o=e.length;for(;e[o-1]==="=";)--o;let i=new Uint8Array(o*r/8|0),s=0,c=0,a=0;for(let l=0;l<o;++l){let u=t[e[l]];if(u===void 0)throw new SyntaxError(`Non-${n} character`);c=c<<r|u,s+=r,s>=8&&(s-=8,i[a++]=255&c>>s)}if(s>=r||(255&c<<8-s)!==0)throw new SyntaxError("Unexpected end of data");return i}function jf(e,t,r){let n=t[t.length-1]==="=",o=(1<<r)-1,i="",s=0,c=0;for(let a=0;a<e.length;++a)for(c=c<<8|e[a],s+=8;s>r;)s-=r,i+=t[o&c>>s];if(s!==0&&(i+=t[o&c<<r-s]),n)for(;(i.length*r&7)!==0;)i+="=";return i}function Gf(e){let t={};for(let r=0;r<e.length;++r)t[e[r]]=r;return t}function it({name:e,prefix:t,bitsPerChar:r,alphabet:n}){let o=Gf(n);return Qe({prefix:t,name:e,encode(i){return jf(i,n,r)},decode(i){return zf(i,o,r,e)}})}var jt=it({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Zf=it({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Yf=it({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Wf=it({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Xf=it({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Jf=it({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Qf=it({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),tl=it({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),el=it({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var No={};Bt(No,{base58btc:()=>Q,base58flickr:()=>rl});var Q=Se({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),rl=Se({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Lo={};Bt(Lo,{base64:()=>Ro,base64pad:()=>nl,base64url:()=>ol,base64urlpad:()=>il});var Ro=it({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),nl=it({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),ol=it({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),il=it({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});function sl(e,t){try{if(typeof e=="string"&&e.length>0)return al(e);if(typeof e=="number"&&isFinite(e))return t?.long?ul(e):cl(e);throw new Error("Value is not a string or number.")}catch(r){let n=fl(r)?`${r.message}. value=${JSON.stringify(e)}`:"An unknown error has occured.";throw new Error(n)}}function al(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 mn=sl;function cl(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 ul(e){let t=Math.abs(e);return t>=864e5?pn(e,t,864e5,"day"):t>=36e5?pn(e,t,36e5,"hour"):t>=6e4?pn(e,t,6e4,"minute"):t>=1e3?pn(e,t,1e3,"second"):`${e} ms`}function pn(e,t,r,n){let o=t>=r*1.5;return`${Math.round(e/r)} ${n}${o?"s":""}`}function fl(e){return typeof e=="object"&&e!==null&&"message"in e}function Do(e){r.debug=r,r.default=r,r.coerce=a,r.disable=i,r.enable=o,r.enabled=s,r.humanize=mn,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 p=0;p<u.length;p++)f=(f<<5)-f+u.charCodeAt(p),f|=0;return r.colors[Math.abs(f)%r.colors.length]}r.selectColor=t;function r(u){let f,p=null,S,_;function y(...k){if(!y.enabled)return;let O=y,z=Number(new Date),T=z-(f||z);O.diff=T,O.prev=f,O.curr=z,f=z,k[0]=r.coerce(k[0]),typeof k[0]!="string"&&k.unshift("%O");let d=0;k[0]=k[0].replace(/%([a-zA-Z%])/g,(N,L)=>{if(N==="%%")return"%";d++;let g=r.formatters[L];if(typeof g=="function"){let A=k[d];N=g.call(O,A),k.splice(d,1),d--}return N}),r.formatArgs.call(O,k),(O.log||r.log).apply(O,k)}return y.namespace=u,y.useColors=r.useColors(),y.color=r.selectColor(u),y.extend=n,y.destroy=r.destroy,Object.defineProperty(y,"enabled",{enumerable:!0,configurable:!1,get:()=>p!==null?p:(S!==r.namespaces&&(S=r.namespaces,_=r.enabled(u)),_),set:k=>{p=k}}),typeof r.init=="function"&&r.init(y),y}function n(u,f){let p=r(this.namespace+(typeof f>"u"?":":f)+u);return p.log=this.log,p}function o(u){r.save(u),r.namespaces=u,r.names=[],r.skips=[];let f,p=(typeof u=="string"?u:"").split(/[\s,]+/),S=p.length;for(f=0;f<S;f++)p[f]&&(u=p[f].replace(/\*/g,".*?"),u[0]==="-"?r.skips.push(new RegExp("^"+u.substr(1)+"$")):r.names.push(new RegExp("^"+u+"$")))}function i(){let u=[...r.names.map(c),...r.skips.map(c).map(f=>"-"+f)].join(",");return r.enable(""),u}function s(u){if(u[u.length-1]==="*")return!0;let f,p;for(f=0,p=r.skips.length;f<p;f++)if(r.skips[f].test(u))return!1;for(f=0,p=r.names.length;f<p;f++)if(r.names[f].test(u))return!0;return!1}function c(u){return u.toString().substring(2,u.toString().length-2).replace(/\.\*\?$/,"*")}function a(u){return u instanceof Error?u.stack??u.message:u}function l(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return r.setupFormatters(r.formatters),r.enable(r.load()),r}var yn=gl(),ll=["#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 dl(){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 hl(e){if(e[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+e[0]+(this.useColors?"%c ":" ")+"+"+mn(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 pl=console.debug??console.log??(()=>{});function ml(e){try{e?yn?.setItem("debug",e):yn?.removeItem("debug")}catch{}}function yl(){let e;try{e=yn?.getItem("debug")}catch{}return!e&&typeof globalThis.process<"u"&&"env"in globalThis.process&&(e=globalThis.process.env.DEBUG),e}function gl(){try{return localStorage}catch{}}function xl(e){e.j=function(t){try{return JSON.stringify(t)}catch(r){return"[UnexpectedJSONParseError]: "+r.message}}}var ta=Do({formatArgs:hl,save:ml,load:yl,useColors:dl,setupFormatters:xl,colors:ll,storage:yn,log:pl});var _t=ta;_t.formatters.b=e=>e==null?"undefined":Q.baseEncode(e);_t.formatters.t=e=>e==null?"undefined":jt.baseEncode(e);_t.formatters.m=e=>e==null?"undefined":Ro.baseEncode(e);_t.formatters.p=e=>e==null?"undefined":e.toString();_t.formatters.c=e=>e==null?"undefined":e.toString();_t.formatters.k=e=>e==null?"undefined":e.toString();_t.formatters.a=e=>e==null?"undefined":e.toString();_t.formatters.e=e=>e==null?"undefined":ea(e.stack)??ea(e.message)??e.toString();function wl(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 ve(e){let t=wl(`${e}:trace`);return _t.enabled(`${e}:trace`)&&_t.names.map(r=>r.toString()).find(r=>r.includes(":trace"))!=null&&(t=_t(`${e}:trace`)),Object.assign(_t(e),{error:_t(`${e}:error`),trace:t})}function ea(e){if(e!=null&&(e=e.trim(),e.length!==0))return e}var ko={};Bt(ko,{base36:()=>tr,base36upper:()=>bl});var tr=Se({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),bl=Se({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var El=oa,ra=128,Sl=127,vl=~Sl,Al=Math.pow(2,31);function oa(e,t,r){t=t||[],r=r||0;for(var n=r;e>=Al;)t[r++]=e&255|ra,e/=128;for(;e&vl;)t[r++]=e&255|ra,e>>>=7;return t[r]=e|0,oa.bytes=r-n+1,t}var Il=Ko,Tl=128,na=127;function Ko(e,n){var r=0,n=n||0,o=0,i=n,s,c=e.length;do{if(i>=c)throw Ko.bytes=0,new RangeError("Could not decode varint");s=e[i++],r+=o<28?(s&na)<<o:(s&na)*Math.pow(2,o),o+=7}while(s>=Tl);return Ko.bytes=i-n,r}var Cl=Math.pow(2,7),Bl=Math.pow(2,14),Pl=Math.pow(2,21),_l=Math.pow(2,28),Ul=Math.pow(2,35),Nl=Math.pow(2,42),Rl=Math.pow(2,49),Ll=Math.pow(2,56),Dl=Math.pow(2,63),kl=function(e){return e<Cl?1:e<Bl?2:e<Pl?3:e<_l?4:e<Ul?5:e<Nl?6:e<Rl?7:e<Ll?8:e<Dl?9:10},Kl={encode:El,decode:Il,encodingLength:kl},Ol=Kl,Ur=Ol;function Nr(e,t=0){return[Ur.decode(e,t),Ur.decode.bytes]}function er(e,t,r=0){return Ur.encode(e,t,r),t}function rr(e){return Ur.encodingLength(e)}function Gt(e,t){let r=t.byteLength,n=rr(e),o=n+rr(r),i=new Uint8Array(o+r);return er(e,i,0),er(r,i,n),i.set(t,o),new nr(e,r,t,i)}function ue(e){let t=ce(e),[r,n]=Nr(t),[o,i]=Nr(t.subarray(n)),s=t.subarray(n+i);if(s.byteLength!==o)throw new Error("Incorrect length");return new nr(r,o,s,t)}function ia(e,t){if(e===t)return!0;{let r=t;return e.code===r.code&&e.size===r.size&&r.bytes instanceof Uint8Array&&Zs(e.bytes,r.bytes)}}var nr=class{code;size;digest;bytes;constructor(t,r,n,o){this.code=t,this.size=r,this.digest=n,this.bytes=o}};function sa(e,t){let{bytes:r,version:n}=e;switch(n){case 0:return Ml(r,Oo(e),t??Q.encoder);default:return Vl(r,Oo(e),t??jt.encoder)}}var aa=new WeakMap;function Oo(e){let t=aa.get(e);if(t==null){let r=new Map;return aa.set(e,r),r}return t}var Z=class e{code;version;multihash;bytes;"/";constructor(t,r,n,o){this.code=r,this.version=t,this.multihash=n,this.bytes=o,this["/"]=o}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:t,multihash:r}=this;if(t!==Rr)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==ql)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=Gt(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&&ia(t.multihash,n.multihash)}toString(t){return sa(this,t)}toJSON(){return{"/":sa(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??ca(n,o,i.bytes))}else if(r[$l]===!0){let{version:n,multihash:o,code:i}=r,s=ue(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!==Rr)throw new Error(`Version 0 CID must use dag-pb (code: ${Rr}) block encoding`);return new e(t,r,n,n.bytes)}case 1:{let o=ca(t,r,n.bytes);return new e(t,r,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return e.create(0,Rr,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=ce(t.subarray(n,n+r.multihashSize));if(o.byteLength!==r.multihashSize)throw new Error("Incorrect length");let i=o.subarray(r.multihashSize-r.digestSize),s=new nr(r.multihashCode,r.digestSize,i,o);return[r.version===0?e.createV0(s):e.createV1(r.codec,s),t.subarray(r.size)]}static inspectBytes(t){let r=0,n=()=>{let[f,p]=Nr(t.subarray(r));return r+=p,f},o=n(),i=Rr;if(o===18?(o=0,r=0):i=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let s=r,c=n(),a=n(),l=r+a,u=l-s;return{version:o,codec:i,multihashCode:c,digestSize:a,multihashSize:u,size:l}}static parse(t,r){let[n,o]=Fl(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 Fl(e,t){switch(e[0]){case"Q":{let r=t??Q;return[Q.prefix,r.decode(`${Q.prefix}${e}`)]}case Q.prefix:{let r=t??Q;return[Q.prefix,r.decode(e)]}case jt.prefix:{let r=t??jt;return[jt.prefix,r.decode(e)]}case tr.prefix:{let r=t??tr;return[tr.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 Ml(e,t,r){let{prefix:n}=r;if(n!==Q.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 Vl(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 Rr=112,ql=18;function ca(e,t,r){let n=rr(e),o=n+rr(t),i=new Uint8Array(o+r.byteLength);return er(e,i,0),er(t,i,n),i.set(r,o),i}var $l=Symbol.for("@ipld/js-cid/CID");var Fo={};Bt(Fo,{identity:()=>Dt});var ua=0,Hl="identity",fa=ce;function zl(e){return Gt(ua,fa(e))}var Dt={code:ua,name:Hl,encode:fa,digest:zl};function rt(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}function fe(e=0){return new Uint8Array(e)}function Ut(e=0){return new Uint8Array(e)}function bt(e,t){t==null&&(t=e.reduce((o,i)=>o+i.length,0));let r=Ut(t),n=0;for(let o of e)r.set(o,n),n+=o.length;return r}var da=Symbol.for("@achingbrain/uint8arraylist");function la(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 or(e){return!!e?.[da]}var kt=class e{bufs;length;[da]=!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(or(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(or(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=la(this.bufs,t);return r.buf[r.index]}set(t,r){let n=la(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(or(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 bt(n,o)}subarray(t,r){let{bufs:n,length:o}=this._subList(t,r);return n.length===1?n[0]:bt(n,o)}sublist(t,r){let{bufs:n,length:o}=this._subList(t,r),i=new e;return i.length=o,i.bufs=[...n],i}_subList(t,r){if(t=t??0,r=r??this.length,t<0&&(t=this.length+t),r<0&&(r=this.length+r),t<0||r>this.length)throw new RangeError("index is out of bounds");if(t===r)return{bufs:[],length:0};if(t===0&&r===this.length)return{bufs:this.bufs,length:this.length};let n=[],o=0;for(let i=0;i<this.bufs.length;i++){let s=this.bufs[i],c=o,a=c+s.byteLength;if(o=a,t>=a)continue;let l=t>=c&&t<a,u=r>c&&r<=a;if(l&&u){if(t===c&&r===a){n.push(s);break}let f=t-c;n.push(s.subarray(f,f+(r-t)));break}if(l){if(t===0){n.push(s);continue}n.push(s.subarray(t-c));continue}if(u){if(r===a){n.push(s);break}n.push(s.subarray(0,r-c));break}n.push(s)}return{bufs:n,length:r-t}}indexOf(t,r=0){if(!or(t)&&!(t instanceof Uint8Array))throw new TypeError('The "value" argument must be a Uint8ArrayList or Uint8Array');let n=t instanceof Uint8Array?t:t.subarray();if(r=Number(r??0),isNaN(r)&&(r=0),r<0&&(r=this.length+r),r<0&&(r=0),t.length===0)return r>this.length?this.length:r;let o=n.byteLength;if(o===0)throw new TypeError("search must be at least 1 byte long");let i=256,s=new Int32Array(i);for(let f=0;f<i;f++)s[f]=-1;for(let f=0;f<o;f++)s[n[f]]=f;let c=s,a=this.byteLength-n.byteLength,l=n.byteLength-1,u;for(let f=r;f<=a;f+=u){u=0;for(let p=l;p>=0;p--){let S=this.get(f+p);if(n[p]!==S){u=Math.max(1,p-c[S]);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=Ut(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setInt8(0,r),this.write(n,t)}getInt16(t,r){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt16(0,r)}setInt16(t,r,n){let o=fe(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt16(0,r,n),this.write(o,t)}getInt32(t,r){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt32(0,r)}setInt32(t,r,n){let o=fe(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt32(0,r,n),this.write(o,t)}getBigInt64(t,r){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigInt64(0,r)}setBigInt64(t,r,n){let o=fe(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigInt64(0,r,n),this.write(o,t)}getUint8(t){let r=this.subarray(t,t+1);return new DataView(r.buffer,r.byteOffset,r.byteLength).getUint8(0)}setUint8(t,r){let n=Ut(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setUint8(0,r),this.write(n,t)}getUint16(t,r){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint16(0,r)}setUint16(t,r,n){let o=fe(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint16(0,r,n),this.write(o,t)}getUint32(t,r){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint32(0,r)}setUint32(t,r,n){let o=fe(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint32(0,r,n),this.write(o,t)}getBigUint64(t,r){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigUint64(0,r)}setBigUint64(t,r,n){let o=fe(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigUint64(0,r,n),this.write(o,t)}getFloat32(t,r){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat32(0,r)}setFloat32(t,r,n){let o=fe(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat32(0,r,n),this.write(o,t)}getFloat64(t,r){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat64(0,r)}setFloat64(t,r,n){let o=fe(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat64(0,r,n),this.write(o,t)}equals(t){if(t==null||!(t instanceof e)||t.bufs.length!==this.bufs.length)return!1;for(let r=0;r<this.bufs.length;r++)if(!rt(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 Mo={};Bt(Mo,{base10:()=>jl});var jl=Se({prefix:"9",name:"base10",alphabet:"0123456789"});var Vo={};Bt(Vo,{base16:()=>Gl,base16upper:()=>Zl});var Gl=it({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Zl=it({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var qo={};Bt(qo,{base2:()=>Yl});var Yl=it({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var $o={};Bt($o,{base256emoji:()=>td});var ha=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}"),Wl=ha.reduce((e,t,r)=>(e[r]=t,e),[]),Xl=ha.reduce((e,t,r)=>{let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);return e[n]=r,e},[]);function Jl(e){return e.reduce((t,r)=>(t+=Wl[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=Xl[n];if(o==null)throw new Error(`Non-base256emoji character: ${r}`);t.push(o)}return new Uint8Array(t)}var td=Qe({prefix:"\u{1F680}",name:"base256emoji",encode:Jl,decode:Ql});var Ho={};Bt(Ho,{base8:()=>ed});var ed=it({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var zo={};Bt(zo,{identity:()=>rd});var rd=Qe({prefix:"\0",name:"identity",encode:e=>Ws(e),decode:e=>Ys(e)});var om=new TextEncoder,im=new TextDecoder;var Zo={};Bt(Zo,{sha256:()=>Lr,sha512:()=>id});function Go({name:e,code:t,encode:r}){return new jo(e,t,r)}var jo=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?Gt(this.code,r):r.then(n=>Gt(this.code,n))}else throw Error("Unknown type, must be binary type")}};function ma(e){return async t=>new Uint8Array(await crypto.subtle.digest(e,t))}var Lr=Go({name:"sha2-256",code:18,encode:ma("SHA-256")}),id=Go({name:"sha2-512",code:19,encode:ma("SHA-512")});var Dr={...zo,...qo,...Ho,...Mo,...Vo,...Uo,...ko,...No,...Lo,...$o},gm={...Zo,...Fo};function ga(e,t,r,n){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:n}}}var ya=ga("utf8","u",e=>"u"+new TextDecoder("utf8").decode(e),e=>new TextEncoder().encode(e.substring(1))),Yo=ga("ascii","a",e=>{let t="a";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return t},e=>{e=e.substring(1);let t=Ut(e.length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t}),sd={utf8:ya,"utf-8":ya,hex:Dr.base16,latin1:Yo,ascii:Yo,binary:Yo,...Dr},xn=sd;function H(e,t="utf8"){let r=xn[t];if(r==null)throw new Error(`Unsupported encoding "${t}"`);return r.decoder.decode(`${r.prefix}${e}`)}function q(e,t="utf8"){let r=xn[t];if(r==null)throw new Error(`Unsupported encoding "${t}"`);return r.encoder.encode(e).substring(1)}var ad=parseInt("11111",2),Wo=parseInt("10000000",2),cd=parseInt("01111111",2),xa={0:kr,1:kr,2:ud,3:dd,4:hd,5:ld,6:fd,16:kr,22:kr,48:kr};function le(e,t={offset:0}){let r=e[t.offset]&ad;if(t.offset++,xa[r]!=null)return xa[r](e,t);throw new Error("No decoder for tag "+r)}function Kr(e,t){let r=0;if((e[t.offset]&Wo)===Wo){let n=e[t.offset]&cd,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 kr(e,t){Kr(e,t);let r=[];for(;!(t.offset>=e.byteLength);){let n=le(e,t);if(n===null)break;r.push(n)}return r}function ud(e,t){let r=Kr(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 fd(e,t){let r=Kr(e,t),n=t.offset+r,o=e[t.offset];t.offset++;let i=0,s=0;o<40?(i=0,s=o):o<80?(i=1,s=o-40):(i=2,s=o-80);let c=`${i}.${s}`,a=[];for(;t.offset<n;){let l=e[t.offset];if(t.offset++,a.push(l&127),l<128){a.reverse();let u=0;for(let f=0;f<a.length;f++)u+=a[f]<<f*7;c+=`.${u}`,a=[]}}return c}function ld(e,t){return t.offset++,null}function dd(e,t){let r=Kr(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 hd(e,t){let r=Kr(e,t),n=e.subarray(t.offset,t.offset+r);return t.offset+=r,n}function pd(e){let t=e.toString(16);t.length%2===1&&(t="0"+t);let r=new kt;for(let n=0;n<t.length;n+=2)r.append(Uint8Array.from([parseInt(`${t[n]}${t[n+1]}`,16)]));return r}function Xo(e){if(e.byteLength<128)return Uint8Array.from([e.byteLength]);let t=pd(e.byteLength);return new kt(Uint8Array.from([t.byteLength|Wo]),t)}function Nt(e){let t=new kt,r=128;return(e.subarray()[0]&r)===r&&t.append(Uint8Array.from([0])),t.append(e),new kt(Uint8Array.from([2]),Xo(t),t)}function wn(e){let t=Uint8Array.from([0]),r=new kt(t,e);return new kt(Uint8Array.from([3]),Xo(r),r)}function Ie(e,t=48){let r=new kt;for(let n of e)r.append(n);return new kt(Uint8Array.from([t]),Xo(r),r)}async function wa(e,t,r){let n=await crypto.subtle.importKey("jwk",e,{name:"ECDSA",namedCurve:e.crv??"P-256"},!1,["verify"]);return crypto.subtle.verify({name:"ECDSA",hash:{name:"SHA-256"}},n,t,r.subarray())}var md=Uint8Array.from([6,8,42,134,72,206,61,3,1,7]),yd=Uint8Array.from([6,5,43,129,4,0,34]),gd=Uint8Array.from([6,5,43,129,4,0,35]),xd={ext:!0,kty:"EC",crv:"P-256"},wd={ext:!0,kty:"EC",crv:"P-384"},bd={ext:!0,kty:"EC",crv:"P-521"},Jo=32,Qo=48,ti=66;function ei(e){let t=le(e);return ba(t)}function ba(e){let t=e[1][1][0],r=1,n,o;if(t.byteLength===Jo*2+1)return n=q(t.subarray(r,r+Jo),"base64url"),o=q(t.subarray(r+Jo),"base64url"),new ir({...xd,key_ops:["verify"],x:n,y:o});if(t.byteLength===Qo*2+1)return n=q(t.subarray(r,r+Qo),"base64url"),o=q(t.subarray(r+Qo),"base64url"),new ir({...wd,key_ops:["verify"],x:n,y:o});if(t.byteLength===ti*2+1)return n=q(t.subarray(r,r+ti),"base64url"),o=q(t.subarray(r+ti),"base64url"),new ir({...bd,key_ops:["verify"],x:n,y:o});throw new ut(`coordinates were wrong length, got ${t.byteLength}, expected 65, 97 or 133`)}function Ea(e){return Ie([Nt(Uint8Array.from([1])),Ie([Ed(e.crv)],160),Ie([wn(new kt(Uint8Array.from([4]),H(e.x??"","base64url"),H(e.y??"","base64url")))],161)]).subarray()}function Ed(e){if(e==="P-256")return md;if(e==="P-384")return yd;if(e==="P-521")return gd;throw new ut(`Invalid curve ${e}`)}var ir=class{type="ECDSA";jwk;_raw;constructor(t){this.jwk=t}get raw(){return this._raw==null&&(this._raw=Ea(this.jwk)),this._raw}toMultihash(){return Dt.digest(sr(this))}toCID(){return Z.createV1(114,this.toMultihash())}toString(){return Q.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:rt(this.raw,t.raw)}async verify(t,r){return wa(this.jwk,r,t)}};var ke=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function Sd(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function bn(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function Ke(e,...t){if(!Sd(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 Sa(e){if(typeof e!="function"||typeof e.create!="function")throw new Error("Hash should be wrapped by utils.createHasher");bn(e.outputLen),bn(e.blockLen)}function cr(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function va(e,t){Ke(e);let r=t.outputLen;if(e.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}function de(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function En(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function Zt(e,t){return e<<32-t|e>>>t}function Aa(e){if(typeof e!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(e))}function Or(e){return typeof e=="string"&&(e=Aa(e)),Ke(e),e}function ri(...e){let t=0;for(let n=0;n<e.length;n++){let o=e[n];Ke(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 ar=class{};function ni(e){let t=n=>e().update(Or(n)).digest(),r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>e(),t}function Sn(e=32){if(ke&&typeof ke.getRandomValues=="function")return ke.getRandomValues(new Uint8Array(e));if(ke&&typeof ke.randomBytes=="function")return Uint8Array.from(ke.randomBytes(e));throw new Error("crypto.getRandomValues must be defined")}function vd(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),c=Number(r&i),a=n?4:0,l=n?0:4;e.setUint32(t+a,s,n),e.setUint32(t+l,c,n)}function Ia(e,t,r){return e&t^~e&r}function Ta(e,t,r){return e&t^e&r^t&r}var Fr=class extends ar{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=En(this.buffer)}update(t){cr(this),t=Or(t),Ke(t);let{view:r,buffer:n,blockLen:o}=this,i=t.length;for(let s=0;s<i;){let c=Math.min(o-this.pos,i-s);if(c===o){let a=En(t);for(;o<=i-s;s+=o)this.process(a,s);continue}n.set(t.subarray(s,s+c),this.pos),this.pos+=c,s+=c,this.pos===o&&(this.process(r,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){cr(this),va(t,this),this.finished=!0;let{buffer:r,view:n,blockLen:o,isLE:i}=this,{pos:s}=this;r[s++]=128,de(this.buffer.subarray(s)),this.padOffset>o-s&&(this.process(n,0),s=0);for(let f=s;f<o;f++)r[f]=0;vd(n,o-8,BigInt(this.length*8),i),this.process(n,0);let c=En(t),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let l=a/4,u=this.get();if(l>u.length)throw new Error("_sha2: outputLen bigger than state");for(let f=0;f<l;f++)c.setUint32(4*f,u[f],i)}digest(){let{buffer:t,outputLen:r}=this;this.digestInto(t);let n=t.slice(0,r);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());let{blockLen:r,buffer:n,length:o,finished:i,destroyed:s,pos:c}=this;return t.destroyed=s,t.finished=i,t.length=o,t.pos=c,o%r&&t.buffer.set(n),t}clone(){return this._cloneInto()}},he=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var yt=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]);var vn=BigInt(4294967295),Ca=BigInt(32);function Ad(e,t=!1){return t?{h:Number(e&vn),l:Number(e>>Ca&vn)}:{h:Number(e>>Ca&vn)|0,l:Number(e&vn)|0}}function Ba(e,t=!1){let r=e.length,n=new Uint32Array(r),o=new Uint32Array(r);for(let i=0;i<r;i++){let{h:s,l:c}=Ad(e[i],t);[n[i],o[i]]=[s,c]}return[n,o]}var oi=(e,t,r)=>e>>>r,ii=(e,t,r)=>e<<32-r|t>>>r,Oe=(e,t,r)=>e>>>r|t<<32-r,Fe=(e,t,r)=>e<<32-r|t>>>r,Mr=(e,t,r)=>e<<64-r|t>>>r-32,Vr=(e,t,r)=>e>>>r-32|t<<64-r;function re(e,t,r,n){let o=(t>>>0)+(n>>>0);return{h:e+r+(o/2**32|0)|0,l:o|0}}var Pa=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0),_a=(e,t,r,n)=>t+r+n+(e/2**32|0)|0,Ua=(e,t,r,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0),Na=(e,t,r,n,o)=>t+r+n+o+(e/2**32|0)|0,Ra=(e,t,r,n,o)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0)+(o>>>0),La=(e,t,r,n,o,i)=>t+r+n+o+i+(e/2**32|0)|0;var Td=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]),Te=new Uint32Array(64),An=class extends Fr{constructor(t=32){super(64,t,8,!1),this.A=he[0]|0,this.B=he[1]|0,this.C=he[2]|0,this.D=he[3]|0,this.E=he[4]|0,this.F=he[5]|0,this.G=he[6]|0,this.H=he[7]|0}get(){let{A:t,B:r,C:n,D:o,E:i,F:s,G:c,H:a}=this;return[t,r,n,o,i,s,c,a]}set(t,r,n,o,i,s,c,a){this.A=t|0,this.B=r|0,this.C=n|0,this.D=o|0,this.E=i|0,this.F=s|0,this.G=c|0,this.H=a|0}process(t,r){for(let f=0;f<16;f++,r+=4)Te[f]=t.getUint32(r,!1);for(let f=16;f<64;f++){let p=Te[f-15],S=Te[f-2],_=Zt(p,7)^Zt(p,18)^p>>>3,y=Zt(S,17)^Zt(S,19)^S>>>10;Te[f]=y+Te[f-7]+_+Te[f-16]|0}let{A:n,B:o,C:i,D:s,E:c,F:a,G:l,H:u}=this;for(let f=0;f<64;f++){let p=Zt(c,6)^Zt(c,11)^Zt(c,25),S=u+p+Ia(c,a,l)+Td[f]+Te[f]|0,y=(Zt(n,2)^Zt(n,13)^Zt(n,22))+Ta(n,o,i)|0;u=l,l=a,a=c,c=s+S|0,s=i,i=o,o=n,n=S+y|0}n=n+this.A|0,o=o+this.B|0,i=i+this.C|0,s=s+this.D|0,c=c+this.E|0,a=a+this.F|0,l=l+this.G|0,u=u+this.H|0,this.set(n,o,i,s,c,a,l,u)}roundClean(){de(Te)}destroy(){this.set(0,0,0,0,0,0,0,0),de(this.buffer)}};var Da=Ba(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(e=>BigInt(e))),Cd=Da[0],Bd=Da[1],Ce=new Uint32Array(80),Be=new Uint32Array(80),si=class extends Fr{constructor(t=64){super(128,t,16,!1),this.Ah=yt[0]|0,this.Al=yt[1]|0,this.Bh=yt[2]|0,this.Bl=yt[3]|0,this.Ch=yt[4]|0,this.Cl=yt[5]|0,this.Dh=yt[6]|0,this.Dl=yt[7]|0,this.Eh=yt[8]|0,this.El=yt[9]|0,this.Fh=yt[10]|0,this.Fl=yt[11]|0,this.Gh=yt[12]|0,this.Gl=yt[13]|0,this.Hh=yt[14]|0,this.Hl=yt[15]|0}get(){let{Ah:t,Al:r,Bh:n,Bl:o,Ch:i,Cl:s,Dh:c,Dl:a,Eh:l,El:u,Fh:f,Fl:p,Gh:S,Gl:_,Hh:y,Hl:k}=this;return[t,r,n,o,i,s,c,a,l,u,f,p,S,_,y,k]}set(t,r,n,o,i,s,c,a,l,u,f,p,S,_,y,k){this.Ah=t|0,this.Al=r|0,this.Bh=n|0,this.Bl=o|0,this.Ch=i|0,this.Cl=s|0,this.Dh=c|0,this.Dl=a|0,this.Eh=l|0,this.El=u|0,this.Fh=f|0,this.Fl=p|0,this.Gh=S|0,this.Gl=_|0,this.Hh=y|0,this.Hl=k|0}process(t,r){for(let T=0;T<16;T++,r+=4)Ce[T]=t.getUint32(r),Be[T]=t.getUint32(r+=4);for(let T=16;T<80;T++){let d=Ce[T-15]|0,v=Be[T-15]|0,N=Oe(d,v,1)^Oe(d,v,8)^oi(d,v,7),L=Fe(d,v,1)^Fe(d,v,8)^ii(d,v,7),g=Ce[T-2]|0,A=Be[T-2]|0,R=Oe(g,A,19)^Mr(g,A,61)^oi(g,A,6),I=Fe(g,A,19)^Vr(g,A,61)^ii(g,A,6),C=Ua(L,I,Be[T-7],Be[T-16]),U=Na(C,N,R,Ce[T-7],Ce[T-16]);Ce[T]=U|0,Be[T]=C|0}let{Ah:n,Al:o,Bh:i,Bl:s,Ch:c,Cl:a,Dh:l,Dl:u,Eh:f,El:p,Fh:S,Fl:_,Gh:y,Gl:k,Hh:O,Hl:z}=this;for(let T=0;T<80;T++){let d=Oe(f,p,14)^Oe(f,p,18)^Mr(f,p,41),v=Fe(f,p,14)^Fe(f,p,18)^Vr(f,p,41),N=f&S^~f&y,L=p&_^~p&k,g=Ra(z,v,L,Bd[T],Be[T]),A=La(g,O,d,N,Cd[T],Ce[T]),R=g|0,I=Oe(n,o,28)^Mr(n,o,34)^Mr(n,o,39),C=Fe(n,o,28)^Vr(n,o,34)^Vr(n,o,39),U=n&i^n&c^i&c,$=o&s^o&a^s&a;O=y|0,z=k|0,y=S|0,k=_|0,S=f|0,_=p|0,{h:f,l:p}=re(l|0,u|0,A|0,R|0),l=c|0,u=a|0,c=i|0,a=s|0,i=n|0,s=o|0;let x=Pa(R,C,$);n=_a(x,A,I,U),o=x|0}({h:n,l:o}=re(this.Ah|0,this.Al|0,n|0,o|0)),{h:i,l:s}=re(this.Bh|0,this.Bl|0,i|0,s|0),{h:c,l:a}=re(this.Ch|0,this.Cl|0,c|0,a|0),{h:l,l:u}=re(this.Dh|0,this.Dl|0,l|0,u|0),{h:f,l:p}=re(this.Eh|0,this.El|0,f|0,p|0),{h:S,l:_}=re(this.Fh|0,this.Fl|0,S|0,_|0),{h:y,l:k}=re(this.Gh|0,this.Gl|0,y|0,k|0),{h:O,l:z}=re(this.Hh|0,this.Hl|0,O|0,z|0),this.set(n,o,i,s,c,a,l,u,f,p,S,_,y,k,O,z)}roundClean(){de(Ce,Be)}destroy(){de(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};var In=ni(()=>new An);var ka=ni(()=>new si);var fi=BigInt(0),ui=BigInt(1);function ur(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function li(e){if(!ur(e))throw new Error("Uint8Array expected")}function ne(e,t){if(typeof t!="boolean")throw new Error(e+" boolean expected, got "+t)}function qr(e){let t=e.toString(16);return t.length&1?"0"+t:t}function Fa(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);return e===""?fi:BigInt("0x"+e)}var Ma=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",Pd=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Pe(e){if(li(e),Ma)return e.toHex();let t="";for(let r=0;r<e.length;r++)t+=Pd[e[r]];return t}var pe={_0:48,_9:57,A:65,F:70,a:97,f:102};function Ka(e){if(e>=pe._0&&e<=pe._9)return e-pe._0;if(e>=pe.A&&e<=pe.F)return e-(pe.A-10);if(e>=pe.a&&e<=pe.f)return e-(pe.a-10)}function $r(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);if(Ma)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=Ka(e.charCodeAt(i)),c=Ka(e.charCodeAt(i+1));if(s===void 0||c===void 0){let a=e[i]+e[i+1];throw new Error('hex string expected, got non-hex character "'+a+'" at index '+i)}n[o]=s*16+c}return n}function me(e){return Fa(Pe(e))}function Me(e){return li(e),Fa(Pe(Uint8Array.from(e).reverse()))}function Ve(e,t){return $r(e.toString(16).padStart(t*2,"0"))}function fr(e,t){return Ve(e,t).reverse()}function nt(e,t,r){let n;if(typeof t=="string")try{n=$r(t)}catch(i){throw new Error(e+" must be hex string or Uint8Array, cause: "+i)}else if(ur(t))n=Uint8Array.from(t);else throw new Error(e+" must be hex string or Uint8Array");let o=n.length;if(typeof r=="number"&&o!==r)throw new Error(e+" of length "+r+" expected, got "+o);return n}function _e(...e){let t=0;for(let n=0;n<e.length;n++){let o=e[n];li(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 ai=e=>typeof e=="bigint"&&fi<=e;function Tn(e,t,r){return ai(e)&&ai(t)&&ai(r)&&t<=e&&e<r}function Kt(e,t,r,n){if(!Tn(t,r,n))throw new Error("expected valid "+e+": "+r+" <= n < "+n+", got "+t)}function Va(e){let t;for(t=0;e>fi;e>>=ui,t+=1);return t}var qe=e=>(ui<<BigInt(e))-ui,ci=e=>new Uint8Array(e),Oa=e=>Uint8Array.from(e);function qa(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=ci(e),o=ci(e),i=0,s=()=>{n.fill(1),o.fill(0),i=0},c=(...f)=>r(o,n,...f),a=(f=ci(0))=>{o=c(Oa([0]),f),n=c(),f.length!==0&&(o=c(Oa([1]),f),n=c())},l=()=>{if(i++>=1e3)throw new Error("drbg: tried 1000 values");let f=0,p=[];for(;f<t;){n=c();let S=n.slice();p.push(S),f+=n.length}return _e(...p)};return(f,p)=>{s(),a(f);let S;for(;!(S=p(l()));)a();return s(),S}}var _d={bigint:e=>typeof e=="bigint",function:e=>typeof e=="function",boolean:e=>typeof e=="boolean",string:e=>typeof e=="string",stringOrUint8Array:e=>typeof e=="string"||ur(e),isSafeInteger:e=>Number.isSafeInteger(e),array:e=>Array.isArray(e),field:(e,t)=>t.Fp.isValid(e),hash:e=>typeof e=="function"&&Number.isSafeInteger(e.outputLen)};function ye(e,t,r={}){let n=(o,i,s)=>{let c=_d[i];if(typeof c!="function")throw new Error("invalid validator function");let a=e[o];if(!(s&&a===void 0)&&!c(a,e))throw new Error("param "+String(o)+" is invalid. Expected "+i+", got "+a)};for(let[o,i]of Object.entries(t))n(o,i,!1);for(let[o,i]of Object.entries(r))n(o,i,!0);return e}function lr(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 At=BigInt(0),dt=BigInt(1),$e=BigInt(2),Ud=BigInt(3),Ha=BigInt(4),za=BigInt(5),ja=BigInt(8);function tt(e,t){let r=e%t;return r>=At?r:t+r}function ot(e,t,r){let n=e;for(;t-- >At;)n*=n,n%=r;return n}function Cn(e,t){if(e===At)throw new Error("invert: expected non-zero number");if(t<=At)throw new Error("invert: expected positive modulus, got "+t);let r=tt(e,t),n=t,o=At,i=dt,s=dt,c=At;for(;r!==At;){let l=n/r,u=n%r,f=o-s*l,p=i-c*l;n=r,r=u,o=s,i=c,s=f,c=p}if(n!==dt)throw new Error("invert: does not exist");return tt(o,t)}function Ga(e,t){let r=(e.ORDER+dt)/Ha,n=e.pow(t,r);if(!e.eql(e.sqr(n),t))throw new Error("Cannot find square root");return n}function Nd(e,t){let r=(e.ORDER-za)/ja,n=e.mul(t,$e),o=e.pow(n,r),i=e.mul(t,o),s=e.mul(e.mul(i,$e),o),c=e.mul(i,e.sub(s,e.ONE));if(!e.eql(e.sqr(c),t))throw new Error("Cannot find square root");return c}function Rd(e){if(e<BigInt(3))throw new Error("sqrt is not defined for small field");let t=e-dt,r=0;for(;t%$e===At;)t/=$e,r++;let n=$e,o=ge(e);for(;$a(o,n)===1;)if(n++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(r===1)return Ga;let i=o.pow(n,t),s=(t+dt)/$e;return function(a,l){if(a.is0(l))return l;if($a(a,l)!==1)throw new Error("Cannot find square root");let u=r,f=a.mul(a.ONE,i),p=a.pow(l,t),S=a.pow(l,s);for(;!a.eql(p,a.ONE);){if(a.is0(p))return a.ZERO;let _=1,y=a.sqr(p);for(;!a.eql(y,a.ONE);)if(_++,y=a.sqr(y),_===u)throw new Error("Cannot find square root");let k=dt<<BigInt(u-_-1),O=a.pow(f,k);u=_,f=a.sqr(O),p=a.mul(p,f),S=a.mul(S,O)}return S}}function Ld(e){return e%Ha===Ud?Ga:e%ja===za?Nd:Rd(e)}var Za=(e,t)=>(tt(e,t)&dt)===dt,Dd=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function di(e){let t={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},r=Dd.reduce((n,o)=>(n[o]="function",n),t);return ye(e,r)}function kd(e,t,r){if(r<At)throw new Error("invalid exponent, negatives unsupported");if(r===At)return e.ONE;if(r===dt)return t;let n=e.ONE,o=t;for(;r>At;)r&dt&&(n=e.mul(n,o)),o=e.sqr(o),r>>=dt;return n}function dr(e,t,r=!1){let n=new Array(t.length).fill(r?e.ZERO:void 0),o=t.reduce((s,c,a)=>e.is0(c)?s:(n[a]=s,e.mul(s,c)),e.ONE),i=e.inv(o);return t.reduceRight((s,c,a)=>e.is0(c)?s:(n[a]=e.mul(s,n[a]),e.mul(s,c)),i),n}function $a(e,t){let r=(e.ORDER-dt)/$e,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 hi(e,t){t!==void 0&&bn(t);let r=t!==void 0?t:e.toString(2).length,n=Math.ceil(r/8);return{nBitLength:r,nByteLength:n}}function ge(e,t,r=!1,n={}){if(e<=At)throw new Error("invalid field: expected ORDER > 0, got "+e);let{nBitLength:o,nByteLength:i}=hi(e,t);if(i>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let s,c=Object.freeze({ORDER:e,isLE:r,BITS:o,BYTES:i,MASK:qe(o),ZERO:At,ONE:dt,create:a=>tt(a,e),isValid:a=>{if(typeof a!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof a);return At<=a&&a<e},is0:a=>a===At,isOdd:a=>(a&dt)===dt,neg:a=>tt(-a,e),eql:(a,l)=>a===l,sqr:a=>tt(a*a,e),add:(a,l)=>tt(a+l,e),sub:(a,l)=>tt(a-l,e),mul:(a,l)=>tt(a*l,e),pow:(a,l)=>kd(c,a,l),div:(a,l)=>tt(a*Cn(l,e),e),sqrN:a=>a*a,addN:(a,l)=>a+l,subN:(a,l)=>a-l,mulN:(a,l)=>a*l,inv:a=>Cn(a,e),sqrt:n.sqrt||(a=>(s||(s=Ld(e)),s(c,a))),toBytes:a=>r?fr(a,i):Ve(a,i),fromBytes:a=>{if(a.length!==i)throw new Error("Field.fromBytes: expected "+i+" bytes, got "+a.length);return r?Me(a):me(a)},invertBatch:a=>dr(c,a),cmov:(a,l,u)=>u?l:a});return Object.freeze(c)}function Ya(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 pi(e){let t=Ya(e);return t+Math.ceil(t/2)}function Wa(e,t,r=!1){let n=e.length,o=Ya(t),i=pi(t);if(n<16||n<i||n>1024)throw new Error("expected "+i+"-1024 bytes of input, got "+n);let s=r?Me(e):me(e),c=tt(s,t-dt)+dt;return r?fr(c,o):Ve(c,o)}var Xa=BigInt(0),wi=BigInt(1);function mi(e,t){let r=t.negate();return e?r:t}function Qa(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+e)}function yi(e,t){Qa(e,t);let r=Math.ceil(t/e)+1,n=2**(e-1),o=2**e,i=qe(e),s=BigInt(e);return{windows:r,windowSize:n,mask:i,maxNumber:o,shiftBy:s}}function Ja(e,t,r){let{windowSize:n,mask:o,maxNumber:i,shiftBy:s}=r,c=Number(e&o),a=e>>s;c>n&&(c-=i,a+=wi);let l=t*n,u=l+Math.abs(c)-1,f=c===0,p=c<0,S=t%2!==0;return{nextN:a,offset:u,isZero:f,isNeg:p,isNegF:S,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 Od(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 gi=new WeakMap,tc=new WeakMap;function xi(e){return tc.get(e)||1}function Bn(e,t){return{constTimeNegate:mi,hasPrecomputes(r){return xi(r)!==1},unsafeLadder(r,n,o=e.ZERO){let i=r;for(;n>Xa;)n&wi&&(o=o.add(i)),i=i.double(),n>>=wi;return o},precomputeWindow(r,n){let{windows:o,windowSize:i}=yi(n,t),s=[],c=r,a=c;for(let l=0;l<o;l++){a=c,s.push(a);for(let u=1;u<i;u++)a=a.add(c),s.push(a);c=a.double()}return s},wNAF(r,n,o){let i=e.ZERO,s=e.BASE,c=yi(r,t);for(let a=0;a<c.windows;a++){let{nextN:l,offset:u,isZero:f,isNeg:p,isNegF:S,offsetF:_}=Ja(o,a,c);o=l,f?s=s.add(mi(S,n[_])):i=i.add(mi(p,n[u]))}return{p:i,f:s}},wNAFUnsafe(r,n,o,i=e.ZERO){let s=yi(r,t);for(let c=0;c<s.windows&&o!==Xa;c++){let{nextN:a,offset:l,isZero:u,isNeg:f}=Ja(o,c,s);if(o=a,!u){let p=n[l];i=i.add(f?p.negate():p)}}return i},getPrecomputes(r,n,o){let i=gi.get(n);return i||(i=this.precomputeWindow(n,r),r!==1&&gi.set(n,o(i))),i},wNAFCached(r,n,o){let i=xi(r);return this.wNAF(i,this.getPrecomputes(i,r,o),n)},wNAFCachedUnsafe(r,n,o,i){let s=xi(r);return s===1?this.unsafeLadder(r,n,i):this.wNAFUnsafe(s,this.getPrecomputes(s,r,o),n,i)},setWindowSize(r,n){Qa(n,t),tc.set(r,n),gi.delete(r)}}}function Pn(e,t,r,n){Kd(r,e),Od(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,c=Va(BigInt(o)),a=1;c>12?a=c-3:c>4?a=c-2:c>0&&(a=2);let l=qe(a),u=new Array(Number(l)+1).fill(s),f=Math.floor((t.BITS-1)/a)*a,p=s;for(let S=f;S>=0;S-=a){u.fill(s);for(let y=0;y<i;y++){let k=n[y],O=Number(k>>BigInt(S)&l);u[O]=u[O].add(r[y])}let _=s;for(let y=u.length-1,k=s;y>0;y--)k=k.add(u[y]),_=_.add(k);if(p=p.add(_),S!==0)for(let y=0;y<a;y++)p=p.double()}return p}function Hr(e){return di(e.Fp),ye(e,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...hi(e.n,e.nBitLength),...e,p:e.Fp.ORDER})}var oe=BigInt(0),It=BigInt(1),ec=BigInt(2),Fd=BigInt(8),Md={zip215:!0};function Vd(e){let t=Hr(e);return ye(e,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...t})}function rc(e){let t=Vd(e),{Fp:r,n,prehash:o,hash:i,randomBytes:s,nByteLength:c,h:a}=t,l=ec<<BigInt(c*8)-It,u=r.create,f=ge(t.n,t.nBitLength);function p(E,h){let b=r.sqr(E),B=r.sqr(h),F=r.add(r.mul(t.a,b),B),V=r.add(r.ONE,r.mul(t.d,r.mul(b,B)));return r.eql(F,V)}if(!p(t.Gx,t.Gy))throw new Error("bad curve params: generator point");let S=t.uvRatio||((E,h)=>{try{return{isValid:!0,value:r.sqrt(E*r.inv(h))}}catch{return{isValid:!1,value:oe}}}),_=t.adjustScalarBytes||(E=>E),y=t.domain||((E,h,b)=>{if(ne("phflag",b),h.length||b)throw new Error("Contexts/pre-hash are not supported");return E});function k(E,h,b=!1){let B=b?It:oe;Kt("coordinate "+E,h,B,l)}function O(E){if(!(E instanceof d))throw new Error("ExtendedPoint expected")}let z=lr((E,h)=>{let{ex:b,ey:B,ez:F}=E,V=E.is0();h==null&&(h=V?Fd:r.inv(F));let j=u(b*h),G=u(B*h),W=u(F*h);if(V)return{x:oe,y:It};if(W!==It)throw new Error("invZ was invalid");return{x:j,y:G}}),T=lr(E=>{let{a:h,d:b}=t;if(E.is0())throw new Error("bad point: ZERO");let{ex:B,ey:F,ez:V,et:j}=E,G=u(B*B),W=u(F*F),J=u(V*V),ct=u(J*J),st=u(G*h),mt=u(J*u(st+W)),Ct=u(ct+u(b*u(G*W)));if(mt!==Ct)throw new Error("bad point: equation left != right (1)");let lt=u(B*F),wt=u(V*j);if(lt!==wt)throw new Error("bad point: equation left != right (2)");return!0});class d{constructor(h,b,B,F){k("x",h),k("y",b),k("z",B,!0),k("t",F),this.ex=h,this.ey=b,this.ez=B,this.et=F,Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(h){if(h instanceof d)throw new Error("extended point not allowed");let{x:b,y:B}=h||{};return k("x",b),k("y",B),new d(b,B,It,u(b*B))}static normalizeZ(h){let b=dr(r,h.map(B=>B.ez));return h.map((B,F)=>B.toAffine(b[F])).map(d.fromAffine)}static msm(h,b){return Pn(d,f,h,b)}_setWindowSize(h){L.setWindowSize(this,h)}assertValidity(){T(this)}equals(h){O(h);let{ex:b,ey:B,ez:F}=this,{ex:V,ey:j,ez:G}=h,W=u(b*G),J=u(V*F),ct=u(B*G),st=u(j*F);return W===J&&ct===st}is0(){return this.equals(d.ZERO)}negate(){return new d(u(-this.ex),this.ey,this.ez,u(-this.et))}double(){let{a:h}=t,{ex:b,ey:B,ez:F}=this,V=u(b*b),j=u(B*B),G=u(ec*u(F*F)),W=u(h*V),J=b+B,ct=u(u(J*J)-V-j),st=W+j,mt=st-G,Ct=W-j,lt=u(ct*mt),wt=u(st*Ct),Lt=u(ct*Ct),zt=u(mt*st);return new d(lt,wt,zt,Lt)}add(h){O(h);let{a:b,d:B}=t,{ex:F,ey:V,ez:j,et:G}=this,{ex:W,ey:J,ez:ct,et:st}=h,mt=u(F*W),Ct=u(V*J),lt=u(G*B*st),wt=u(j*ct),Lt=u((F+V)*(W+J)-mt-Ct),zt=wt-lt,_r=wt+lt,$s=u(Ct-b*mt),Nf=u(Lt*zt),Rf=u(_r*$s),Lf=u(Lt*$s),Df=u(zt*_r);return new d(Nf,Rf,Df,Lf)}subtract(h){return this.add(h.negate())}wNAF(h){return L.wNAFCached(this,h,d.normalizeZ)}multiply(h){let b=h;Kt("scalar",b,It,n);let{p:B,f:F}=this.wNAF(b);return d.normalizeZ([B,F])[0]}multiplyUnsafe(h,b=d.ZERO){let B=h;return Kt("scalar",B,oe,n),B===oe?N:this.is0()||B===It?this:L.wNAFCachedUnsafe(this,B,d.normalizeZ,b)}isSmallOrder(){return this.multiplyUnsafe(a).is0()}isTorsionFree(){return L.unsafeLadder(this,n).is0()}toAffine(h){return z(this,h)}clearCofactor(){let{h}=t;return h===It?this:this.multiplyUnsafe(h)}static fromHex(h,b=!1){let{d:B,a:F}=t,V=r.BYTES;h=nt("pointHex",h,V),ne("zip215",b);let j=h.slice(),G=h[V-1];j[V-1]=G&-129;let W=Me(j),J=b?l:r.ORDER;Kt("pointHex.y",W,oe,J);let ct=u(W*W),st=u(ct-It),mt=u(B*ct-F),{isValid:Ct,value:lt}=S(st,mt);if(!Ct)throw new Error("Point.fromHex: invalid y coordinate");let wt=(lt&It)===It,Lt=(G&128)!==0;if(!b&&lt===oe&&Lt)throw new Error("Point.fromHex: x=0 and x_0=1");return Lt!==wt&&(lt=u(-lt)),d.fromAffine({x:lt,y:W})}static fromPrivateKey(h){let{scalar:b}=R(h);return v.multiply(b)}toRawBytes(){let{x:h,y:b}=this.toAffine(),B=fr(b,r.BYTES);return B[B.length-1]|=h&It?128:0,B}toHex(){return Pe(this.toRawBytes())}}d.BASE=new d(t.Gx,t.Gy,It,u(t.Gx*t.Gy)),d.ZERO=new d(oe,It,It,oe);let{BASE:v,ZERO:N}=d,L=Bn(d,c*8);function g(E){return tt(E,n)}function A(E){return g(Me(E))}function R(E){let h=r.BYTES;E=nt("private key",E,h);let b=nt("hashed private key",i(E),2*h),B=_(b.slice(0,h)),F=b.slice(h,2*h),V=A(B);return{head:B,prefix:F,scalar:V}}function I(E){let{head:h,prefix:b,scalar:B}=R(E),F=v.multiply(B),V=F.toRawBytes();return{head:h,prefix:b,scalar:B,point:F,pointBytes:V}}function C(E){return I(E).pointBytes}function U(E=Uint8Array.of(),...h){let b=_e(...h);return A(i(y(b,nt("context",E),!!o)))}function $(E,h,b={}){E=nt("message",E),o&&(E=o(E));let{prefix:B,scalar:F,pointBytes:V}=I(h),j=U(b.context,B,E),G=v.multiply(j).toRawBytes(),W=U(b.context,G,V,E),J=g(j+W*F);Kt("signature.s",J,oe,n);let ct=_e(G,fr(J,r.BYTES));return nt("result",ct,r.BYTES*2)}let x=Md;function w(E,h,b,B=x){let{context:F,zip215:V}=B,j=r.BYTES;E=nt("signature",E,2*j),h=nt("message",h),b=nt("publicKey",b,j),V!==void 0&&ne("zip215",V),o&&(h=o(h));let G=Me(E.slice(j,2*j)),W,J,ct;try{W=d.fromHex(b,V),J=d.fromHex(E.slice(0,j),V),ct=v.multiplyUnsafe(G)}catch{return!1}if(!V&&W.isSmallOrder())return!1;let st=U(F,J.toRawBytes(),W.toRawBytes(),h);return J.add(W.multiplyUnsafe(st)).subtract(ct).clearCofactor().equals(d.ZERO)}return v._setWindowSize(8),{CURVE:t,getPublicKey:C,sign:$,verify:w,ExtendedPoint:d,utils:{getExtendedPublicKey:I,randomPrivateKey:()=>s(r.BYTES),precompute(E=8,h=d.BASE){return h._setWindowSize(E),h.multiply(BigInt(3)),h}}}}var bi=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),nc=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),by=BigInt(0),qd=BigInt(1),oc=BigInt(2),Ey=BigInt(3),$d=BigInt(5),Hd=BigInt(8);function zd(e){let t=BigInt(10),r=BigInt(20),n=BigInt(40),o=BigInt(80),i=bi,c=e*e%i*e%i,a=ot(c,oc,i)*c%i,l=ot(a,qd,i)*e%i,u=ot(l,$d,i)*l%i,f=ot(u,t,i)*u%i,p=ot(f,r,i)*f%i,S=ot(p,n,i)*p%i,_=ot(S,o,i)*S%i,y=ot(_,o,i)*S%i,k=ot(y,t,i)*u%i;return{pow_p_5_8:ot(k,oc,i)*e%i,b2:c}}function jd(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}function Gd(e,t){let r=bi,n=tt(t*t*t,r),o=tt(n*n*t,r),i=zd(e*o).pow_p_5_8,s=tt(e*n*i,r),c=tt(t*s*s,r),a=s,l=tt(s*nc,r),u=c===e,f=c===tt(-e,r),p=c===tt(-e*nc,r);return u&&(s=a),(f||p)&&(s=l),Za(s,r)&&(s=tt(-s,r)),{isValid:u||f,value:s}}var ic=ge(bi,void 0,!0),Zd={a:ic.create(BigInt(-1)),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:ic,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:Hd,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:ka,randomBytes:Sn,adjustScalarBytes:jd,uvRatio:Gd},sc=rc(Zd);var _n=32;function ac(e,t,r){return sc.verify(t,r instanceof Uint8Array?r:r.subarray(),e)}var Un=class{type="Ed25519";raw;constructor(t){this.raw=Ei(t,_n)}toMultihash(){return Dt.digest(sr(this))}toCID(){return Z.createV1(114,this.toMultihash())}toString(){return Q.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:rt(this.raw,t.raw)}verify(t,r){return ac(this.raw,r,t)}};function Si(e){return e=Ei(e,_n),new Un(e)}function Ei(e,t){if(e=Uint8Array.from(e??[]),e.length!==t)throw new ut(`Key must be a Uint8Array of length ${t}, got ${e.length}`);return e}var Wd=Math.pow(2,7),Xd=Math.pow(2,14),Jd=Math.pow(2,21),vi=Math.pow(2,28),Ai=Math.pow(2,35),Ii=Math.pow(2,42),Ti=Math.pow(2,49),X=128,Et=127;function Rt(e){if(e<Wd)return 1;if(e<Xd)return 2;if(e<Jd)return 3;if(e<vi)return 4;if(e<Ai)return 5;if(e<Ii)return 6;if(e<Ti)return 7;if(Number.MAX_SAFE_INTEGER!=null&&e>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function Ci(e,t,r=0){switch(Rt(e)){case 8:t[r++]=e&255|X,e/=128;case 7:t[r++]=e&255|X,e/=128;case 6:t[r++]=e&255|X,e/=128;case 5:t[r++]=e&255|X,e/=128;case 4:t[r++]=e&255|X,e>>>=7;case 3:t[r++]=e&255|X,e>>>=7;case 2:t[r++]=e&255|X,e>>>=7;case 1:{t[r++]=e&255,e>>>=7;break}default:throw new Error("unreachable")}return t}function Qd(e,t,r=0){switch(Rt(e)){case 8:t.set(r++,e&255|X),e/=128;case 7:t.set(r++,e&255|X),e/=128;case 6:t.set(r++,e&255|X),e/=128;case 5:t.set(r++,e&255|X),e/=128;case 4:t.set(r++,e&255|X),e>>>=7;case 3:t.set(r++,e&255|X),e>>>=7;case 2:t.set(r++,e&255|X),e>>>=7;case 1:{t.set(r++,e&255),e>>>=7;break}default:throw new Error("unreachable")}return t}function Bi(e,t){let r=e[t],n=0;if(n+=r&Et,r<X||(r=e[t+1],n+=(r&Et)<<7,r<X)||(r=e[t+2],n+=(r&Et)<<14,r<X)||(r=e[t+3],n+=(r&Et)<<21,r<X)||(r=e[t+4],n+=(r&Et)*vi,r<X)||(r=e[t+5],n+=(r&Et)*Ai,r<X)||(r=e[t+6],n+=(r&Et)*Ii,r<X)||(r=e[t+7],n+=(r&Et)*Ti,r<X))return n;throw new RangeError("Could not decode varint")}function th(e,t){let r=e.get(t),n=0;if(n+=r&Et,r<X||(r=e.get(t+1),n+=(r&Et)<<7,r<X)||(r=e.get(t+2),n+=(r&Et)<<14,r<X)||(r=e.get(t+3),n+=(r&Et)<<21,r<X)||(r=e.get(t+4),n+=(r&Et)*vi,r<X)||(r=e.get(t+5),n+=(r&Et)*Ai,r<X)||(r=e.get(t+6),n+=(r&Et)*Ii,r<X)||(r=e.get(t+7),n+=(r&Et)*Ti,r<X))return n;throw new RangeError("Could not decode varint")}function hr(e,t,r=0){return t==null&&(t=Ut(Rt(e))),t instanceof Uint8Array?Ci(e,t,r):Qd(e,t,r)}function He(e,t=0){return e instanceof Uint8Array?Bi(e,t):th(e,t)}var Pi=new Float32Array([-0]),Ue=new Uint8Array(Pi.buffer);function fc(e,t,r){Pi[0]=e,t[r]=Ue[0],t[r+1]=Ue[1],t[r+2]=Ue[2],t[r+3]=Ue[3]}function lc(e,t){return Ue[0]=e[t],Ue[1]=e[t+1],Ue[2]=e[t+2],Ue[3]=e[t+3],Pi[0]}var _i=new Float64Array([-0]),St=new Uint8Array(_i.buffer);function dc(e,t,r){_i[0]=e,t[r]=St[0],t[r+1]=St[1],t[r+2]=St[2],t[r+3]=St[3],t[r+4]=St[4],t[r+5]=St[5],t[r+6]=St[6],t[r+7]=St[7]}function hc(e,t){return St[0]=e[t],St[1]=e[t+1],St[2]=e[t+2],St[3]=e[t+3],St[4]=e[t+4],St[5]=e[t+5],St[6]=e[t+6],St[7]=e[t+7],_i[0]}var eh=BigInt(Number.MAX_SAFE_INTEGER),rh=BigInt(Number.MIN_SAFE_INTEGER),Ot=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 ze;if(t<eh&&t>rh)return this.fromNumber(Number(t));let r=t<0n;r&&(t=-t);let n=t>>32n,o=t-(n<<32n);return r&&(n=~n|0n,o=~o|0n,++o>pc&&(o=0n,++n>pc&&(n=0n))),new e(Number(o),Number(n))}static fromNumber(t){if(t===0)return ze;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):ze}},ze=new Ot(0,0);ze.toBigInt=function(){return 0n};ze.zzEncode=ze.zzDecode=function(){return this};ze.length=function(){return 1};var pc=4294967296n;function mc(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 yc(e,t,r){if(r-t<1)return"";let o,i=[],s=0,c;for(;t<r;)c=e[t++],c<128?i[s++]=c:c>191&&c<224?i[s++]=(c&31)<<6|e[t++]&63:c>239&&c<365?(c=((c&7)<<18|(e[t++]&63)<<12|(e[t++]&63)<<6|e[t++]&63)-65536,i[s++]=55296+(c>>10),i[s++]=56320+(c&1023)):i[s++]=(c&15)<<12|(e[t++]&63)<<6|e[t++]&63,s>8191&&((o??(o=[])).push(String.fromCharCode.apply(String,i)),s=0);return o!=null?(s>0&&o.push(String.fromCharCode.apply(String,i.slice(0,s))),o.join("")):String.fromCharCode.apply(String,i.slice(0,s))}function Ui(e,t,r){let n=r,o,i;for(let s=0;s<e.length;++s)o=e.charCodeAt(s),o<128?t[r++]=o:o<2048?(t[r++]=o>>6|192,t[r++]=o&63|128):(o&64512)===55296&&((i=e.charCodeAt(s+1))&64512)===56320?(o=65536+((o&1023)<<10)+(i&1023),++s,t[r++]=o>>18|240,t[r++]=o>>12&63|128,t[r++]=o>>6&63|128,t[r++]=o&63|128):(t[r++]=o>>12|224,t[r++]=o>>6&63|128,t[r++]=o&63|128);return r-n}function Yt(e,t){return RangeError(`index out of range: ${e.pos} + ${t??1} > ${e.len}`)}function Nn(e,t){return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0}var Ni=class{buf;pos;len;_slice=Uint8Array.prototype.subarray;constructor(t){this.buf=t,this.pos=0,this.len=t.length}uint32(){let t=4294967295;if(t=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(t=(t|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return t;if((this.pos+=5)>this.len)throw this.pos=this.len,Yt(this,10);return t}int32(){return this.uint32()|0}sint32(){let t=this.uint32();return t>>>1^-(t&1)|0}bool(){return this.uint32()!==0}fixed32(){if(this.pos+4>this.len)throw Yt(this,4);return Nn(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw Yt(this,4);return Nn(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw Yt(this,4);let t=lc(this.buf,this.pos);return this.pos+=4,t}double(){if(this.pos+8>this.len)throw Yt(this,4);let t=hc(this.buf,this.pos);return this.pos+=8,t}bytes(){let t=this.uint32(),r=this.pos,n=this.pos+t;if(n>this.len)throw Yt(this,t);return this.pos+=t,r===n?new Uint8Array(0):this.buf.subarray(r,n)}string(){let t=this.bytes();return yc(t,0,t.length)}skip(t){if(typeof t=="number"){if(this.pos+t>this.len)throw Yt(this,t);this.pos+=t}else do if(this.pos>=this.len)throw Yt(this);while((this.buf[this.pos++]&128)!==0);return this}skipType(t){switch(t){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(t=this.uint32()&7)!==4;)this.skipType(t);break;case 5:this.skip(4);break;default:throw Error(`invalid wire type ${t} at offset ${this.pos}`)}return this}readLongVarint(){let t=new Ot(0,0),r=0;if(this.len-this.pos>4){for(;r<4;++r)if(t.lo=(t.lo|(this.buf[this.pos]&127)<<r*7)>>>0,this.buf[this.pos++]<128)return t;if(t.lo=(t.lo|(this.buf[this.pos]&127)<<28)>>>0,t.hi=(t.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return t;r=0}else{for(;r<3;++r){if(this.pos>=this.len)throw Yt(this);if(t.lo=(t.lo|(this.buf[this.pos]&127)<<r*7)>>>0,this.buf[this.pos++]<128)return t}return t.lo=(t.lo|(this.buf[this.pos++]&127)<<r*7)>>>0,t}if(this.len-this.pos>4){for(;r<5;++r)if(t.hi=(t.hi|(this.buf[this.pos]&127)<<r*7+3)>>>0,this.buf[this.pos++]<128)return t}else for(;r<5;++r){if(this.pos>=this.len)throw Yt(this);if(t.hi=(t.hi|(this.buf[this.pos]&127)<<r*7+3)>>>0,this.buf[this.pos++]<128)return t}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw Yt(this,8);let t=Nn(this.buf,this.pos+=4),r=Nn(this.buf,this.pos+=4);return new Ot(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=Bi(this.buf,this.pos);return this.pos+=Rt(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 Ri(e){return new Ni(e instanceof Uint8Array?e:e.subarray())}function pr(e,t,r){let n=Ri(e);return t.decode(n,void 0,r)}function Li(e){let t=e??8192,r=t>>>1,n,o=t;return function(s){if(s<1||s>r)return Ut(s);o+s>t&&(n=Ut(t),o=0);let c=n.subarray(o,o+=s);return(o&7)!==0&&(o=(o|7)+1),c}}var je=class{fn;len;next;val;constructor(t,r,n){this.fn=t,this.len=r,this.next=void 0,this.val=n}};function Di(){}var Ki=class{head;tail;len;next;constructor(t){this.head=t.head,this.tail=t.tail,this.len=t.len,this.next=t.states}},nh=Li();function oh(e){return globalThis.Buffer!=null?Ut(e):nh(e)}var jr=class{len;head;tail;states;constructor(){this.len=0,this.head=new je(Di,0,0),this.tail=this.head,this.states=null}_push(t,r,n){return this.tail=this.tail.next=new je(t,r,n),this.len+=r,this}uint32(t){return this.len+=(this.tail=this.tail.next=new Oi((t=t>>>0)<128?1:t<16384?2:t<2097152?3:t<268435456?4:5,t)).len,this}int32(t){return t<0?this._push(Rn,10,Ot.fromNumber(t)):this.uint32(t)}sint32(t){return this.uint32((t<<1^t>>31)>>>0)}uint64(t){let r=Ot.fromBigInt(t);return this._push(Rn,r.length(),r)}uint64Number(t){return this._push(Ci,Rt(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=Ot.fromBigInt(t).zzEncode();return this._push(Rn,r.length(),r)}sint64Number(t){let r=Ot.fromNumber(t).zzEncode();return this._push(Rn,r.length(),r)}sint64String(t){return this.sint64(BigInt(t))}bool(t){return this._push(ki,1,t?1:0)}fixed32(t){return this._push(zr,4,t>>>0)}sfixed32(t){return this.fixed32(t)}fixed64(t){let r=Ot.fromBigInt(t);return this._push(zr,4,r.lo)._push(zr,4,r.hi)}fixed64Number(t){let r=Ot.fromNumber(t);return this._push(zr,4,r.lo)._push(zr,4,r.hi)}fixed64String(t){return this.fixed64(BigInt(t))}sfixed64(t){return this.fixed64(t)}sfixed64Number(t){return this.fixed64Number(t)}sfixed64String(t){return this.fixed64String(t)}float(t){return this._push(fc,4,t)}double(t){return this._push(dc,8,t)}bytes(t){let r=t.length>>>0;return r===0?this._push(ki,1,0):this.uint32(r)._push(sh,r,t)}string(t){let r=mc(t);return r!==0?this.uint32(r)._push(Ui,r,t):this._push(ki,1,0)}fork(){return this.states=new Ki(this),this.head=this.tail=new je(Di,0,0),this.len=0,this}reset(){return this.states!=null?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new je(Di,0,0),this.len=0),this}ldelim(){let t=this.head,r=this.tail,n=this.len;return this.reset().uint32(n),n!==0&&(this.tail.next=t.next,this.tail=r,this.len+=n),this}finish(){let t=this.head.next,r=oh(this.len),n=0;for(;t!=null;)t.fn(t.val,r,n),n+=t.len,t=t.next;return r}};function ki(e,t,r){t[r]=e&255}function ih(e,t,r){for(;e>127;)t[r++]=e&127|128,e>>>=7;t[r]=e}var Oi=class extends je{next;constructor(t,r){super(ih,t,r),this.next=void 0}};function Rn(e,t,r){for(;e.hi!==0;)t[r++]=e.lo&127|128,e.lo=(e.lo>>>7|e.hi<<25)>>>0,e.hi>>>=7;for(;e.lo>127;)t[r++]=e.lo&127|128,e.lo=e.lo>>>7;t[r++]=e.lo}function zr(e,t,r){t[r]=e&255,t[r+1]=e>>>8&255,t[r+2]=e>>>16&255,t[r+3]=e>>>24}function sh(e,t,r){t.set(e,r)}globalThis.Buffer!=null&&(jr.prototype.bytes=function(e){let t=e.length>>>0;return this.uint32(t),t>0&&this._push(ah,t,e),this},jr.prototype.string=function(e){let t=globalThis.Buffer.byteLength(e);return this.uint32(t),t>0&&this._push(ch,t,e),this});function ah(e,t,r){t.set(e,r)}function ch(e,t,r){e.length<40?Ui(e,t,r):t.utf8Write!=null?t.utf8Write(e,r):t.set(H(e),r)}function Fi(){return new jr}function mr(e,t){let r=Fi();return t.encode(e,r,{lengthDelimited:!1}),r.finish()}var yr;(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"})(yr||(yr={}));function Ln(e,t,r,n){return{name:e,type:t,encode:r,decode:n}}function Gr(e){function t(o){if(e[o.toString()]==null)throw new Error("Invalid enum value");return e[o]}let r=function(i,s){let c=t(i);s.int32(c)},n=function(i){let s=i.int32();return t(s)};return Ln("enum",yr.VARINT,r,n)}function gr(e,t){return Ln("message",yr.LENGTH_DELIMITED,e,t)}var at;(function(e){e.RSA="RSA",e.Ed25519="Ed25519",e.secp256k1="secp256k1",e.ECDSA="ECDSA"})(at||(at={}));var Mi;(function(e){e[e.RSA=0]="RSA",e[e.Ed25519=1]="Ed25519",e[e.secp256k1=2]="secp256k1",e[e.ECDSA=3]="ECDSA"})(Mi||(Mi={}));(function(e){e.codec=()=>Gr(Mi)})(at||(at={}));var ie;(function(e){let t;e.codec=()=>(t==null&&(t=gr((r,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),r.Type!=null&&(n.uint32(8),at.codec().encode(r.Type,n)),r.Data!=null&&(n.uint32(18),n.bytes(r.Data)),o.lengthDelimited!==!1&&n.ldelim()},(r,n,o={})=>{let i={},s=n==null?r.len:r.pos+n;for(;r.pos<s;){let c=r.uint32();switch(c>>>3){case 1:{i.Type=at.codec().decode(r);break}case 2:{i.Data=r.bytes();break}default:{r.skipType(c&7);break}}}return i})),t),e.encode=r=>mr(r,e.codec()),e.decode=(r,n)=>pr(r,e.codec(),n)})(ie||(ie={}));var Vi;(function(e){let t;e.codec=()=>(t==null&&(t=gr((r,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),r.Type!=null&&(n.uint32(8),at.codec().encode(r.Type,n)),r.Data!=null&&(n.uint32(18),n.bytes(r.Data)),o.lengthDelimited!==!1&&n.ldelim()},(r,n,o={})=>{let i={},s=n==null?r.len:r.pos+n;for(;r.pos<s;){let c=r.uint32();switch(c>>>3){case 1:{i.Type=at.codec().decode(r);break}case 2:{i.Data=r.bytes();break}default:{r.skipType(c&7);break}}}return i})),t),e.encode=r=>mr(r,e.codec()),e.decode=(r,n)=>pr(r,e.codec(),n)})(Vi||(Vi={}));var Zr=class extends Error{constructor(t="An error occurred while verifying a message"){super(t),this.name="VerificationError"}},Dn=class extends Error{constructor(t="Missing Web Crypto API"){super(t),this.name="WebCryptoMissingError"}};var wc={get(e=globalThis){let t=e.crypto;if(t?.subtle==null)throw new Dn("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 Ne=wc;var Wr={};Bt(Wr,{MAX_RSA_KEY_SIZE:()=>qi,generateRSAKeyPair:()=>vc,jwkToJWKKeyPair:()=>Ac,jwkToPkcs1:()=>dh,jwkToPkix:()=>ji,jwkToRSAPrivateKey:()=>Wi,pkcs1MessageToJwk:()=>Hi,pkcs1MessageToRSAPrivateKey:()=>Gi,pkcs1ToJwk:()=>lh,pkcs1ToRSAPrivateKey:()=>Sc,pkixMessageToJwk:()=>zi,pkixMessageToRSAPublicKey:()=>Yi,pkixToJwk:()=>hh,pkixToRSAPublicKey:()=>Zi});var kn=In;var xr=class{type="RSA";jwk;_raw;_multihash;constructor(t,r){this.jwk=t,this._multihash=r}get raw(){return this._raw==null&&(this._raw=Wr.jwkToPkix(this.jwk)),this._raw}toMultihash(){return this._multihash}toCID(){return Z.createV1(114,this._multihash)}toString(){return Q.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:rt(this.raw,t.raw)}verify(t,r){return Ec(this.jwk,r,t)}},Yr=class{type="RSA";jwk;_raw;publicKey;constructor(t,r){this.jwk=t,this.publicKey=r}get raw(){return this._raw==null&&(this._raw=Wr.jwkToPkcs1(this.jwk)),this._raw}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:rt(this.raw,t.raw)}sign(t){return bc(this.jwk,t)}};var qi=8192,$i=18,uh=1062,fh=Uint8Array.from([48,13,6,9,42,134,72,134,247,13,1,1,1,5,0]);function lh(e){let t=le(e);return Hi(t)}function Hi(e){return{n:q(e[1],"base64url"),e:q(e[2],"base64url"),d:q(e[3],"base64url"),p:q(e[4],"base64url"),q:q(e[5],"base64url"),dp:q(e[6],"base64url"),dq:q(e[7],"base64url"),qi:q(e[8],"base64url"),kty:"RSA"}}function dh(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 ut("JWK was missing components");return Ie([Nt(Uint8Array.from([0])),Nt(H(e.n,"base64url")),Nt(H(e.e,"base64url")),Nt(H(e.d,"base64url")),Nt(H(e.p,"base64url")),Nt(H(e.q,"base64url")),Nt(H(e.dp,"base64url")),Nt(H(e.dq,"base64url")),Nt(H(e.qi,"base64url"))]).subarray()}function hh(e){let t=le(e,{offset:0});return zi(t)}function zi(e){let t=le(e[1],{offset:0});return{kty:"RSA",n:q(t[0],"base64url"),e:q(t[1],"base64url")}}function ji(e){if(e.n==null||e.e==null)throw new ut("JWK was missing components");return Ie([fh,wn(Ie([Nt(H(e.n,"base64url")),Nt(H(e.e,"base64url"))]))]).subarray()}function Sc(e){let t=le(e);return Gi(t)}function Gi(e){let t=Hi(e);return Wi(t)}function Zi(e,t){if(e.byteLength>=uh)throw new We("Key size is too large");let r=le(e,{offset:0});return Yi(r,e,t)}function Yi(e,t,r){let n=zi(e);if(r==null){let o=kn(ie.encode({Type:at.RSA,Data:t}));r=Gt($i,o)}return new xr(n,r)}function Wi(e){if(Tc(e)>qi)throw new ut("Key size is too large");let t=Ac(e),r=kn(ie.encode({Type:at.RSA,Data:ji(t.publicKey)})),n=Gt($i,r);return new Yr(t.privateKey,new xr(t.publicKey,n))}async function vc(e){if(e>qi)throw new ut("Key size is too large");let t=await Ic(e),r=kn(ie.encode({Type:at.RSA,Data:ji(t.publicKey)})),n=Gt($i,r);return new Yr(t.privateKey,new xr(t.publicKey,n))}function Ac(e){if(e==null)throw new ut("Missing key parameter");return{privateKey:e,publicKey:{kty:e.kty,n:e.n,e:e.e}}}async function Ic(e){let t=await Ne.get().subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:e,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-256"}},!0,["sign","verify"]),r=await ph(t);return{privateKey:r[0],publicKey:r[1]}}async function bc(e,t){let r=await Ne.get().subtle.importKey("jwk",e,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["sign"]),n=await Ne.get().subtle.sign({name:"RSASSA-PKCS1-v1_5"},r,t instanceof Uint8Array?t:t.subarray());return new Uint8Array(n,0,n.byteLength)}async function Ec(e,t,r){let n=await Ne.get().subtle.importKey("jwk",e,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["verify"]);return Ne.get().subtle.verify({name:"RSASSA-PKCS1-v1_5"},n,t,r instanceof Uint8Array?r:r.subarray())}async function ph(e){if(e.privateKey==null||e.publicKey==null)throw new ut("Private and public key are required");return Promise.all([Ne.get().subtle.exportKey("jwk",e.privateKey),Ne.get().subtle.exportKey("jwk",e.publicKey)])}function Tc(e){if(e.kty!=="RSA")throw new ut("invalid key type");if(e.n==null)throw new ut("invalid key modulus");return H(e.n,"base64url").length*8}var Kn=class extends ar{constructor(t,r){super(),this.finished=!1,this.destroyed=!1,Sa(t);let n=Or(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),de(i)}update(t){return cr(this),this.iHash.update(t),this}digestInto(t){cr(this),Ke(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:c}=this;return t=t,t.finished=o,t.destroyed=i,t.blockLen=s,t.outputLen=c,t.oHash=r._cloneInto(t.oHash),t.iHash=n._cloneInto(t.iHash),t}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},Xi=(e,t,r)=>new Kn(e,t).update(r).digest();Xi.create=(e,t)=>new Kn(e,t);function Cc(e){e.lowS!==void 0&&ne("lowS",e.lowS),e.prehash!==void 0&&ne("prehash",e.prehash)}function mh(e){let t=Hr(e);ye(t,{a:"field",b:"field"},{allowInfinityPoint:"boolean",allowedPrivateKeyLengths:"array",clearCofactor:"function",fromBytes:"function",isTorsionFree:"function",toBytes:"function",wrapPrivateKey:"boolean"});let{endo:r,Fp:n,a:o}=t;if(r){if(!n.eql(o,n.ZERO))throw new Error("invalid endo: CURVE.a must be 0");if(typeof r!="object"||typeof r.beta!="bigint"||typeof r.splitScalar!="function")throw new Error('invalid endo: expected "beta": bigint and "splitScalar": function')}return Object.freeze({...t})}var ts=class extends Error{constructor(t=""){super(t)}},xe={Err:ts,_tlv:{encode:(e,t)=>{let{Err:r}=xe;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=qr(n);if(o.length/2&128)throw new r("tlv.encode: long form length too big");let i=n>127?qr(o.length/2|128):"";return qr(e)+i+o+t},decode(e,t){let{Err:r}=xe,n=0;if(e<0||e>256)throw new r("tlv.encode: wrong tag");if(t.length<2||t[n++]!==e)throw new r("tlv.decode: wrong tlv");let o=t[n++],i=!!(o&128),s=0;if(!i)s=o;else{let a=o&127;if(!a)throw new r("tlv.decode(long): indefinite length not supported");if(a>4)throw new r("tlv.decode(long): byte length is too big");let l=t.subarray(n,n+a);if(l.length!==a)throw new r("tlv.decode: length bytes not complete");if(l[0]===0)throw new r("tlv.decode(long): zero leftmost byte");for(let u of l)s=s<<8|u;if(n+=a,s<128)throw new r("tlv.decode(long): not minimal encoding")}let c=t.subarray(n,n+s);if(c.length!==s)throw new r("tlv.decode: wrong value length");return{v:c,l:t.subarray(n+s)}}},_int:{encode(e){let{Err:t}=xe;if(e<we)throw new t("integer: negative integers are not allowed");let r=qr(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}=xe;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 me(e)}},toSig(e){let{Err:t,_int:r,_tlv:n}=xe,o=nt("signature",e),{v:i,l:s}=n.decode(48,o);if(s.length)throw new t("invalid signature: left bytes after parsing");let{v:c,l:a}=n.decode(2,i),{v:l,l:u}=n.decode(2,a);if(u.length)throw new t("invalid signature: left bytes after parsing");return{r:r.decode(c),s:r.decode(l)}},hexFromSig(e){let{_tlv:t,_int:r}=xe,n=t.encode(2,r.encode(e.r)),o=t.encode(2,r.encode(e.s)),i=n+o;return t.encode(48,i)}};function Ji(e,t){return Pe(Ve(e,t))}var we=BigInt(0),ht=BigInt(1),Zg=BigInt(2),Qi=BigInt(3),yh=BigInt(4);function gh(e){let t=mh(e),{Fp:r}=t,n=ge(t.n,t.nBitLength),o=t.toBytes||((T,d,v)=>{let N=d.toAffine();return _e(Uint8Array.from([4]),r.toBytes(N.x),r.toBytes(N.y))}),i=t.fromBytes||(T=>{let d=T.subarray(1),v=r.fromBytes(d.subarray(0,r.BYTES)),N=r.fromBytes(d.subarray(r.BYTES,2*r.BYTES));return{x:v,y:N}});function s(T){let{a:d,b:v}=t,N=r.sqr(T),L=r.mul(N,T);return r.add(r.add(L,r.mul(T,d)),v)}function c(T,d){let v=r.sqr(d),N=s(T);return r.eql(v,N)}if(!c(t.Gx,t.Gy))throw new Error("bad curve params: generator point");let a=r.mul(r.pow(t.a,Qi),yh),l=r.mul(r.sqr(t.b),BigInt(27));if(r.is0(r.add(a,l)))throw new Error("bad curve params: a or b");function u(T){return Tn(T,ht,t.n)}function f(T){let{allowedPrivateKeyLengths:d,nByteLength:v,wrapPrivateKey:N,n:L}=t;if(d&&typeof T!="bigint"){if(ur(T)&&(T=Pe(T)),typeof T!="string"||!d.includes(T.length))throw new Error("invalid private key");T=T.padStart(v*2,"0")}let g;try{g=typeof T=="bigint"?T:me(nt("private key",T,v))}catch{throw new Error("invalid private key, expected hex or "+v+" bytes, got "+typeof T)}return N&&(g=tt(g,L)),Kt("private key",g,ht,L),g}function p(T){if(!(T instanceof y))throw new Error("ProjectivePoint expected")}let S=lr((T,d)=>{let{px:v,py:N,pz:L}=T;if(r.eql(L,r.ONE))return{x:v,y:N};let g=T.is0();d==null&&(d=g?r.ONE:r.inv(L));let A=r.mul(v,d),R=r.mul(N,d),I=r.mul(L,d);if(g)return{x:r.ZERO,y:r.ZERO};if(!r.eql(I,r.ONE))throw new Error("invZ was invalid");return{x:A,y:R}}),_=lr(T=>{if(T.is0()){if(t.allowInfinityPoint&&!r.is0(T.py))return;throw new Error("bad point: ZERO")}let{x:d,y:v}=T.toAffine();if(!r.isValid(d)||!r.isValid(v))throw new Error("bad point: x or y not FE");if(!c(d,v))throw new Error("bad point: equation left != right");if(!T.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class y{constructor(d,v,N){if(d==null||!r.isValid(d))throw new Error("x required");if(v==null||!r.isValid(v)||r.is0(v))throw new Error("y required");if(N==null||!r.isValid(N))throw new Error("z required");this.px=d,this.py=v,this.pz=N,Object.freeze(this)}static fromAffine(d){let{x:v,y:N}=d||{};if(!d||!r.isValid(v)||!r.isValid(N))throw new Error("invalid affine point");if(d instanceof y)throw new Error("projective point not allowed");let L=g=>r.eql(g,r.ZERO);return L(v)&&L(N)?y.ZERO:new y(v,N,r.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(d){let v=dr(r,d.map(N=>N.pz));return d.map((N,L)=>N.toAffine(v[L])).map(y.fromAffine)}static fromHex(d){let v=y.fromAffine(i(nt("pointHex",d)));return v.assertValidity(),v}static fromPrivateKey(d){return y.BASE.multiply(f(d))}static msm(d,v){return Pn(y,n,d,v)}_setWindowSize(d){z.setWindowSize(this,d)}assertValidity(){_(this)}hasEvenY(){let{y:d}=this.toAffine();if(r.isOdd)return!r.isOdd(d);throw new Error("Field doesn't support isOdd")}equals(d){p(d);let{px:v,py:N,pz:L}=this,{px:g,py:A,pz:R}=d,I=r.eql(r.mul(v,R),r.mul(g,L)),C=r.eql(r.mul(N,R),r.mul(A,L));return I&&C}negate(){return new y(this.px,r.neg(this.py),this.pz)}double(){let{a:d,b:v}=t,N=r.mul(v,Qi),{px:L,py:g,pz:A}=this,R=r.ZERO,I=r.ZERO,C=r.ZERO,U=r.mul(L,L),$=r.mul(g,g),x=r.mul(A,A),w=r.mul(L,g);return w=r.add(w,w),C=r.mul(L,A),C=r.add(C,C),R=r.mul(d,C),I=r.mul(N,x),I=r.add(R,I),R=r.sub($,I),I=r.add($,I),I=r.mul(R,I),R=r.mul(w,R),C=r.mul(N,C),x=r.mul(d,x),w=r.sub(U,x),w=r.mul(d,w),w=r.add(w,C),C=r.add(U,U),U=r.add(C,U),U=r.add(U,x),U=r.mul(U,w),I=r.add(I,U),x=r.mul(g,A),x=r.add(x,x),U=r.mul(x,w),R=r.sub(R,U),C=r.mul(x,$),C=r.add(C,C),C=r.add(C,C),new y(R,I,C)}add(d){p(d);let{px:v,py:N,pz:L}=this,{px:g,py:A,pz:R}=d,I=r.ZERO,C=r.ZERO,U=r.ZERO,$=t.a,x=r.mul(t.b,Qi),w=r.mul(v,g),K=r.mul(N,A),E=r.mul(L,R),h=r.add(v,N),b=r.add(g,A);h=r.mul(h,b),b=r.add(w,K),h=r.sub(h,b),b=r.add(v,L);let B=r.add(g,R);return b=r.mul(b,B),B=r.add(w,E),b=r.sub(b,B),B=r.add(N,L),I=r.add(A,R),B=r.mul(B,I),I=r.add(K,E),B=r.sub(B,I),U=r.mul($,b),I=r.mul(x,E),U=r.add(I,U),I=r.sub(K,U),U=r.add(K,U),C=r.mul(I,U),K=r.add(w,w),K=r.add(K,w),E=r.mul($,E),b=r.mul(x,b),K=r.add(K,E),E=r.sub(w,E),E=r.mul($,E),b=r.add(b,E),w=r.mul(K,b),C=r.add(C,w),w=r.mul(B,b),I=r.mul(h,I),I=r.sub(I,w),w=r.mul(h,K),U=r.mul(B,U),U=r.add(U,w),new y(I,C,U)}subtract(d){return this.add(d.negate())}is0(){return this.equals(y.ZERO)}wNAF(d){return z.wNAFCached(this,d,y.normalizeZ)}multiplyUnsafe(d){let{endo:v,n:N}=t;Kt("scalar",d,we,N);let L=y.ZERO;if(d===we)return L;if(this.is0()||d===ht)return this;if(!v||z.hasPrecomputes(this))return z.wNAFCachedUnsafe(this,d,y.normalizeZ);let{k1neg:g,k1:A,k2neg:R,k2:I}=v.splitScalar(d),C=L,U=L,$=this;for(;A>we||I>we;)A&ht&&(C=C.add($)),I&ht&&(U=U.add($)),$=$.double(),A>>=ht,I>>=ht;return g&&(C=C.negate()),R&&(U=U.negate()),U=new y(r.mul(U.px,v.beta),U.py,U.pz),C.add(U)}multiply(d){let{endo:v,n:N}=t;Kt("scalar",d,ht,N);let L,g;if(v){let{k1neg:A,k1:R,k2neg:I,k2:C}=v.splitScalar(d),{p:U,f:$}=this.wNAF(R),{p:x,f:w}=this.wNAF(C);U=z.constTimeNegate(A,U),x=z.constTimeNegate(I,x),x=new y(r.mul(x.px,v.beta),x.py,x.pz),L=U.add(x),g=$.add(w)}else{let{p:A,f:R}=this.wNAF(d);L=A,g=R}return y.normalizeZ([L,g])[0]}multiplyAndAddUnsafe(d,v,N){let L=y.BASE,g=(R,I)=>I===we||I===ht||!R.equals(L)?R.multiplyUnsafe(I):R.multiply(I),A=g(this,v).add(g(d,N));return A.is0()?void 0:A}toAffine(d){return S(this,d)}isTorsionFree(){let{h:d,isTorsionFree:v}=t;if(d===ht)return!0;if(v)return v(y,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h:d,clearCofactor:v}=t;return d===ht?this:v?v(y,this):this.multiplyUnsafe(t.h)}toRawBytes(d=!0){return ne("isCompressed",d),this.assertValidity(),o(y,this,d)}toHex(d=!0){return ne("isCompressed",d),Pe(this.toRawBytes(d))}}y.BASE=new y(t.Gx,t.Gy,r.ONE),y.ZERO=new y(r.ZERO,r.ONE,r.ZERO);let{endo:k,nBitLength:O}=t,z=Bn(y,k?Math.ceil(O/2):O);return{CURVE:t,ProjectivePoint:y,normPrivateKeyToScalar:f,weierstrassEquation:s,isWithinCurveOrder:u}}function xh(e){let t=Hr(e);return ye(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}function Bc(e){let t=xh(e),{Fp:r,n,nByteLength:o,nBitLength:i}=t,s=r.BYTES+1,c=2*r.BYTES+1;function a(x){return tt(x,n)}function l(x){return Cn(x,n)}let{ProjectivePoint:u,normPrivateKeyToScalar:f,weierstrassEquation:p,isWithinCurveOrder:S}=gh({...t,toBytes(x,w,K){let E=w.toAffine(),h=r.toBytes(E.x),b=_e;return ne("isCompressed",K),K?b(Uint8Array.from([w.hasEvenY()?2:3]),h):b(Uint8Array.from([4]),h,r.toBytes(E.y))},fromBytes(x){let w=x.length,K=x[0],E=x.subarray(1);if(w===s&&(K===2||K===3)){let h=me(E);if(!Tn(h,ht,r.ORDER))throw new Error("Point is not on curve");let b=p(h),B;try{B=r.sqrt(b)}catch(j){let G=j instanceof Error?": "+j.message:"";throw new Error("Point is not on curve"+G)}let F=(B&ht)===ht;return(K&1)===1!==F&&(B=r.neg(B)),{x:h,y:B}}else if(w===c&&K===4){let h=r.fromBytes(E.subarray(0,r.BYTES)),b=r.fromBytes(E.subarray(r.BYTES,2*r.BYTES));return{x:h,y:b}}else{let h=s,b=c;throw new Error("invalid Point, expected length of "+h+", or uncompressed "+b+", got "+w)}}});function _(x){let w=n>>ht;return x>w}function y(x){return _(x)?a(-x):x}let k=(x,w,K)=>me(x.slice(w,K));class O{constructor(w,K,E){Kt("r",w,ht,n),Kt("s",K,ht,n),this.r=w,this.s=K,E!=null&&(this.recovery=E),Object.freeze(this)}static fromCompact(w){let K=o;return w=nt("compactSignature",w,K*2),new O(k(w,0,K),k(w,K,2*K))}static fromDER(w){let{r:K,s:E}=xe.toSig(nt("DER",w));return new O(K,E)}assertValidity(){}addRecoveryBit(w){return new O(this.r,this.s,w)}recoverPublicKey(w){let{r:K,s:E,recovery:h}=this,b=L(nt("msgHash",w));if(h==null||![0,1,2,3].includes(h))throw new Error("recovery id invalid");let B=h===2||h===3?K+t.n:K;if(B>=r.ORDER)throw new Error("recovery id 2 or 3 invalid");let F=(h&1)===0?"02":"03",V=u.fromHex(F+Ji(B,r.BYTES)),j=l(B),G=a(-b*j),W=a(E*j),J=u.BASE.multiplyAndAddUnsafe(V,G,W);if(!J)throw new Error("point at infinify");return J.assertValidity(),J}hasHighS(){return _(this.s)}normalizeS(){return this.hasHighS()?new O(this.r,a(-this.s),this.recovery):this}toDERRawBytes(){return $r(this.toDERHex())}toDERHex(){return xe.hexFromSig(this)}toCompactRawBytes(){return $r(this.toCompactHex())}toCompactHex(){let w=o;return Ji(this.r,w)+Ji(this.s,w)}}let z={isValidPrivateKey(x){try{return f(x),!0}catch{return!1}},normPrivateKeyToScalar:f,randomPrivateKey:()=>{let x=pi(t.n);return Wa(t.randomBytes(x),t.n)},precompute(x=8,w=u.BASE){return w._setWindowSize(x),w.multiply(BigInt(3)),w}};function T(x,w=!0){return u.fromPrivateKey(x).toRawBytes(w)}function d(x){if(typeof x=="bigint")return!1;if(x instanceof u)return!0;let K=nt("key",x).length,E=r.BYTES,h=E+1,b=2*E+1;if(!(t.allowedPrivateKeyLengths||o===h))return K===h||K===b}function v(x,w,K=!0){if(d(x)===!0)throw new Error("first arg must be private key");if(d(w)===!1)throw new Error("second arg must be public key");return u.fromHex(w).multiply(f(x)).toRawBytes(K)}let N=t.bits2int||function(x){if(x.length>8192)throw new Error("input is too large");let w=me(x),K=x.length*8-i;return K>0?w>>BigInt(K):w},L=t.bits2int_modN||function(x){return a(N(x))},g=qe(i);function A(x){return Kt("num < 2^"+i,x,we,g),Ve(x,o)}function R(x,w,K=I){if(["recovered","canonical"].some(st=>st in K))throw new Error("sign() legacy options not supported");let{hash:E,randomBytes:h}=t,{lowS:b,prehash:B,extraEntropy:F}=K;b==null&&(b=!0),x=nt("msgHash",x),Cc(K),B&&(x=nt("prehashed msgHash",E(x)));let V=L(x),j=f(w),G=[A(j),A(V)];if(F!=null&&F!==!1){let st=F===!0?h(r.BYTES):F;G.push(nt("extraEntropy",st))}let W=_e(...G),J=V;function ct(st){let mt=N(st);if(!S(mt))return;let Ct=l(mt),lt=u.BASE.multiply(mt).toAffine(),wt=a(lt.x);if(wt===we)return;let Lt=a(Ct*a(J+wt*j));if(Lt===we)return;let zt=(lt.x===wt?0:2)|Number(lt.y&ht),_r=Lt;return b&&_(Lt)&&(_r=y(Lt),zt^=1),new O(wt,_r,zt)}return{seed:W,k2sig:ct}}let I={lowS:t.lowS,prehash:!1},C={lowS:t.lowS,prehash:!1};function U(x,w,K=I){let{seed:E,k2sig:h}=R(x,w,K),b=t;return qa(b.hash.outputLen,b.nByteLength,b.hmac)(E,h)}u.BASE._setWindowSize(8);function $(x,w,K,E=C){let h=x;w=nt("msgHash",w),K=nt("publicKey",K);let{lowS:b,prehash:B,format:F}=E;if(Cc(E),"strict"in E)throw new Error("options.strict was renamed to lowS");if(F!==void 0&&F!=="compact"&&F!=="der")throw new Error("format must be compact or der");let V=typeof h=="string"||ur(h),j=!V&&!F&&typeof h=="object"&&h!==null&&typeof h.r=="bigint"&&typeof h.s=="bigint";if(!V&&!j)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let G,W;try{if(j&&(G=new O(h.r,h.s)),V){try{F!=="compact"&&(G=O.fromDER(h))}catch(zt){if(!(zt instanceof xe.Err))throw zt}!G&&F!=="der"&&(G=O.fromCompact(h))}W=u.fromHex(K)}catch{return!1}if(!G||b&&G.hasHighS())return!1;B&&(w=t.hash(w));let{r:J,s:ct}=G,st=L(w),mt=l(ct),Ct=a(st*mt),lt=a(J*mt),wt=u.BASE.multiplyAndAddUnsafe(W,Ct,lt)?.toAffine();return wt?a(wt.x)===J:!1}return{CURVE:t,getPublicKey:T,getSharedSecret:v,sign:U,verify:$,ProjectivePoint:u,Signature:O,utils:z}}function wh(e){return{hash:e,hmac:(t,...r)=>Xi(e,t,ri(...r)),randomBytes:Sn}}function Pc(e,t){let r=n=>Bc({...e,...wh(n)});return{...r(t),create:r}}var Nc=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),_c=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),bh=BigInt(0),Eh=BigInt(1),es=BigInt(2),Uc=(e,t)=>(e+t/es)/t;function Sh(e){let t=Nc,r=BigInt(3),n=BigInt(6),o=BigInt(11),i=BigInt(22),s=BigInt(23),c=BigInt(44),a=BigInt(88),l=e*e*e%t,u=l*l*e%t,f=ot(u,r,t)*u%t,p=ot(f,r,t)*u%t,S=ot(p,es,t)*l%t,_=ot(S,o,t)*S%t,y=ot(_,i,t)*_%t,k=ot(y,c,t)*y%t,O=ot(k,a,t)*k%t,z=ot(O,c,t)*y%t,T=ot(z,r,t)*u%t,d=ot(T,s,t)*_%t,v=ot(d,n,t)*l%t,N=ot(v,es,t);if(!rs.eql(rs.sqr(N),e))throw new Error("Cannot find square root");return N}var rs=ge(Nc,void 0,void 0,{sqrt:Sh}),wr=Pc({a:bh,b:BigInt(7),Fp:rs,n:_c,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:e=>{let t=_c,r=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-Eh*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),i=r,s=BigInt("0x100000000000000000000000000000000"),c=Uc(i*e,t),a=Uc(-n*e,t),l=tt(e-c*r-a*o,t),u=tt(-c*n-a*i,t),f=l>s,p=u>s;if(f&&(l=t-l),p&&(u=t-u),l>s||u>s)throw new Error("splitScalar: Endomorphism failed, k="+e);return{k1neg:f,k1:l,k2neg:p,k2:u}}}},In);function Rc(e){return e==null?!1:typeof e.then=="function"&&typeof e.catch=="function"&&typeof e.finally=="function"}function Lc(e,t,r){let n=Lr.digest(r instanceof Uint8Array?r:r.subarray());if(Rc(n))return n.then(({digest:o})=>wr.verify(t,o,e)).catch(o=>{throw new Zr(String(o))});try{return wr.verify(t,n.digest,e)}catch(o){throw new Zr(String(o))}}var On=class{type="secp256k1";raw;_key;constructor(t){this._key=kc(t),this.raw=Dc(this._key)}toMultihash(){return Dt.digest(sr(this))}toCID(){return Z.createV1(114,this.toMultihash())}toString(){return Q.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:rt(this.raw,t.raw)}verify(t,r){return Lc(this._key,r,t)}};function ns(e){return new On(e)}function Dc(e){return wr.ProjectivePoint.fromHex(e).toRawBytes(!0)}function kc(e){try{return wr.ProjectivePoint.fromHex(e),e}catch(t){throw new We(String(t))}}function Kc(e,t){let{Type:r,Data:n}=ie.decode(e),o=n??new Uint8Array;switch(r){case at.RSA:return Zi(o,t);case at.Ed25519:return Si(o);case at.secp256k1:return ns(o);case at.ECDSA:return ei(o);default:throw new Je}}function Fn(e){let{Type:t,Data:r}=ie.decode(e.digest),n=r??new Uint8Array;switch(t){case at.Ed25519:return Si(n);case at.secp256k1:return ns(n);case at.ECDSA:return ei(n);default:throw new Je}}function sr(e){return ie.encode({Type:at[e.type],Data:e.raw})}var Oc=Symbol.for("nodejs.util.inspect.custom"),vh=114,Xr=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()})`}[To]=!0;toString(){return this.string==null&&(this.string=Q.encode(this.multihash.bytes).slice(1)),this.string}toMultihash(){return this.multihash}toCID(){return Z.createV1(vh,this.multihash)}toJSON(){return this.toString()}equals(t){if(t==null)return!1;if(t instanceof Uint8Array)return rt(this.multihash.bytes,t);if(typeof t=="string")return this.toString()===t;if(t?.toMultihash()?.bytes!=null)return rt(this.multihash.bytes,t.toMultihash().bytes);throw new Error("not valid Id")}[Oc](){return`PeerId(${this.toString()})`}},Mn=class extends Xr{type="RSA";publicKey;constructor(t){super({...t,type:"RSA"}),this.publicKey=t.publicKey}},Vn=class extends Xr{type="Ed25519";publicKey;constructor(t){super({...t,type:"Ed25519"}),this.publicKey=t.publicKey}},qn=class extends Xr{type="secp256k1";publicKey;constructor(t){super({...t,type:"secp256k1"}),this.publicKey=t.publicKey}},Ah=2336,Jr=class{type="url";multihash;publicKey;url;constructor(t){this.url=t.toString(),this.multihash=Dt.digest(H(this.url))}[Oc](){return`PeerId(${this.url})`}[To]=!0;toString(){return this.toCID().toString()}toMultihash(){return this.multihash}toCID(){return Z.createV1(Ah,this.toMultihash())}toJSON(){return this.toString()}equals(t){return t==null?!1:(t instanceof Uint8Array&&(t=q(t)),t.toString()===this.toString())}};var Ih=114,Fc=2336;function Mc(e,t){let r;if(e.charAt(0)==="1"||e.charAt(0)==="Q")r=ue(Q.decode(`z${e}`));else{if(e.startsWith("k51qzi5uqu5")||e.startsWith("kzwfwjn5ji4")||e.startsWith("k2k4r8")||e.startsWith("bafz"))return os(Z.parse(e));if(t==null)throw new ut('Please pass a multibase decoder for strings that do not start with "1" or "Q"');r=ue(t.decode(e))}return Vc(r)}function Vc(e){if(Ch(e))return new Mn({multihash:e});if(Th(e))try{let t=Fn(e);if(t.type==="Ed25519")return new Vn({multihash:e,publicKey:t});if(t.type==="secp256k1")return new qn({multihash:e,publicKey:t})}catch{let r=q(e.digest);return new Jr(new URL(r))}throw new Xe("Supplied PeerID Multihash is invalid")}function os(e){if(e?.multihash==null||e.version==null||e.version===1&&e.code!==Ih&&e.code!==Fc)throw new hn("Supplied PeerID CID is invalid");if(e.code===Fc){let t=q(e.multihash.digest);return new Jr(new URL(t))}return Vc(e.multihash)}function Th(e){return e.code===Dt.code}function Ch(e){return e.code===Lr.code}var $n=class{index=0;input="";new(t){return this.index=0,this.input=t,this}readAtomically(t){let r=this.index,n=t();return n===void 0&&(this.index=r),n}parseWith(t){let r=t();if(this.index===this.input.length)return r}peekChar(){if(!(this.index>=this.input.length))return this.input[this.index]}readChar(){if(!(this.index>=this.input.length))return this.input[this.index++]}readGivenChar(t){return this.readAtomically(()=>{let r=this.readChar();if(r===t)return r})}readSeparator(t,r,n){return this.readAtomically(()=>{if(!(r>0&&this.readGivenChar(t)===void 0))return n()})}readNumber(t,r,n,o){return this.readAtomically(()=>{let i=0,s=0,c=this.peekChar();if(c===void 0)return;let a=c==="0",l=2**(8*o)-1;for(;;){let u=this.readAtomically(()=>{let f=this.readChar();if(f===void 0)return;let p=Number.parseInt(f,t);if(!Number.isNaN(p))return p});if(u===void 0)break;if(i*=t,i+=u,i>l||(s+=1,r!==void 0&&s>r))return}if(s!==0)return!n&&a&&s>1?void 0:i})}readIPv4Addr(){return this.readAtomically(()=>{let t=new Uint8Array(4);for(let r=0;r<t.length;r++){let n=this.readSeparator(".",r,()=>this.readNumber(10,3,!1,1));if(n===void 0)return;t[r]=n}return t})}readIPv6Addr(){let t=r=>{for(let n=0;n<r.length/2;n++){let o=n*2;if(n<r.length-3){let s=this.readSeparator(":",n,()=>this.readIPv4Addr());if(s!==void 0)return r[o]=s[0],r[o+1]=s[1],r[o+2]=s[2],r[o+3]=s[3],[o+4,!0]}let i=this.readSeparator(":",n,()=>this.readNumber(16,4,!0,2));if(i===void 0)return[o,!1];r[o]=i>>8,r[o+1]=i&255}return[r.length,!1]};return this.readAtomically(()=>{let r=new Uint8Array(16),[n,o]=t(r);if(n===16)return r;if(o||this.readGivenChar(":")===void 0||this.readGivenChar(":")===void 0)return;let i=new Uint8Array(14),s=16-(n+2),[c]=t(i.subarray(0,s));return r.set(i.subarray(0,c),16-c),r})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var qc=45,Bh=15,br=new $n;function is(e){if(!(e.length>Bh))return br.new(e).parseWith(()=>br.readIPv4Addr())}function ss(e){if(e.includes("%")&&(e=e.split("%")[0]),!(e.length>qc))return br.new(e).parseWith(()=>br.readIPv6Addr())}function Hn(e,t=!1){if(e.includes("%")&&(e=e.split("%")[0]),e.length>qc)return;let r=br.new(e).parseWith(()=>br.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 yw=parseInt("0xFFFF",16),gw=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);function zc(e){return!!is(e)}function jc(e){return!!ss(e)}function zn(e){return!!Hn(e)}var Gc=zc,Rh=jc,as=function(e){let t=0;if(e=e.toString().trim(),Gc(e)){let r=new Uint8Array(t+4);return e.split(/\./g).forEach(n=>{r[t++]=parseInt(n,10)&255}),r}if(Rh(e)){let r=e.split(":",8),n;for(n=0;n<r.length;n++){let i=Gc(r[n]),s;i&&(s=as(r[n]),r[n]=q(s.slice(0,2),"base16")),s!=null&&++n<8&&r.splice(n,0,q(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")},Zc=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 Er={},cs={},Dh=[[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"]];Dh.forEach(e=>{let t=kh(...e);cs[t.code]=t,Er[t.name]=t});function kh(e,t,r,n,o){return{code:e,size:t,name:r,resolvable:!!n,path:!!o}}function et(e){if(typeof e=="number"){if(cs[e]!=null)return cs[e];throw new Error(`no protocol with code: ${e}`)}else if(typeof e=="string"){if(Er[e]!=null)return Er[e];throw new Error(`no protocol with name: ${e}`)}throw new Error(`invalid protocol id type: ${typeof e}`)}var tb=et("ip4"),eb=et("ip6"),rb=et("ipcidr");function ds(e,t){switch(et(e).code){case 4:case 41:return Oh(t);case 42:return ls(t);case 43:return q(t,"base10");case 6:case 273:case 33:case 132:return Xc(t).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return ls(t);case 421:return qh(t);case 444:return Wc(t);case 445:return Wc(t);case 466:return Vh(t);case 481:return globalThis.encodeURIComponent(ls(t));default:return q(t,"base16")}}function hs(e,t){switch(et(e).code){case 4:return Yc(t);case 41:return Yc(t);case 42:return fs(t);case 43:return H(t,"base10");case 6:case 273:case 33:case 132:return ps(parseInt(t,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return fs(t);case 421:return Fh(t);case 444:return $h(t);case 445:return Hh(t);case 466:return Mh(t);case 481:return fs(globalThis.decodeURIComponent(t));default:return H(t,"base16")}}var us=Object.values(Dr).map(e=>e.decoder),Kh=function(){let e=us[0].or(us[1]);return us.slice(2).forEach(t=>e=e.or(t)),e}();function Yc(e){if(!zn(e))throw new Error("invalid ip address");return as(e)}function Oh(e){let t=Zc(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 ps(e){let t=new ArrayBuffer(2);return new DataView(t).setUint16(0,e),new Uint8Array(t)}function Xc(e){return new DataView(e.buffer).getUint16(e.byteOffset)}function fs(e){let t=H(e),r=Uint8Array.from(hr(t.length));return bt([r,t],r.length+t.length)}function ls(e){let t=He(e);if(e=e.slice(Rt(t)),e.length!==t)throw new Error("inconsistent lengths");return q(e)}function Fh(e){let t;e[0]==="Q"||e[0]==="1"?t=ue(Q.decode(`z${e}`)).bytes:t=Z.parse(e).multihash.bytes;let r=Uint8Array.from(hr(t.length));return bt([r,t],r.length+t.length)}function Mh(e){let t=Kh.decode(e),r=Uint8Array.from(hr(t.length));return bt([r,t],r.length+t.length)}function Vh(e){let t=He(e),r=e.slice(Rt(t));if(r.length!==t)throw new Error("inconsistent lengths");return"u"+q(r,"base64url")}function qh(e){let t=He(e),r=e.slice(Rt(t));if(r.length!==t)throw new Error("inconsistent lengths");return q(r,"base58btc")}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!==16)throw new Error(`failed to parse onion addr: ${t[0]} not a Tor onion address.`);let r=jt.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=ps(n);return bt([r,o],r.length+o.length)}function Hh(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=jt.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=ps(n);return bt([r,o],r.length+o.length)}function Wc(e){let t=e.slice(0,e.length-2),r=e.slice(e.length-2),n=q(t,"base32"),o=Xc(r);return`${n}:${o}`}function Jc(e){e=ms(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],c=et(s);if(c.size===0){t.push([c.code]),r.push([c.code]);continue}if(i++,i>=o.length)throw new jn("invalid address: "+e);if(c.path===!0){n=ms(o.slice(i).join("/")),t.push([c.code,hs(c.code,n)]),r.push([c.code,n]);break}let a=hs(c.code,o[i]);t.push([c.code,a]),r.push([c.code,ds(c.code,a)])}return{string:Qc(r),bytes:Gn(t),tuples:t,stringTuples:r,path:n}}function ys(e){let t=[],r=[],n=null,o=0;for(;o<e.length;){let i=He(e,o),s=Rt(i),c=et(i),a=zh(c,e.slice(o+s));if(a===0){t.push([i]),r.push([i]),o+=s;continue}let l=e.slice(o+s,o+s+a);if(o+=a+s,o>e.length)throw new jn("Invalid address Uint8Array: "+q(e,"base16"));t.push([i,l]);let u=ds(i,l);if(r.push([i,u]),c.path===!0){n=u;break}}return{bytes:Uint8Array.from(e),string:Qc(r),tuples:t,stringTuples:r,path:n}}function Qc(e){let t=[];return e.map(r=>{let n=et(r[0]);return t.push(n.name),r.length>1&&r[1]!=null&&t.push(r[1]),null}),ms(t.join("/"))}function Gn(e){return bt(e.map(t=>{let r=et(t[0]),n=Uint8Array.from(hr(r.code));return t.length>1&&t[1]!=null&&(n=bt([n,t[1]])),n}))}function zh(e,t){if(e.size>0)return e.size/8;if(e.size===0)return 0;{let r=He(t instanceof Uint8Array?t:Uint8Array.from(t));return r+Rt(r)}}function ms(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 jh=Symbol.for("nodejs.util.inspect.custom"),xs=Symbol.for("@multiformats/js-multiaddr/multiaddr"),Gh=[et("dns").code,et("dns4").code,et("dns6").code,et("dnsaddr").code],gs=class extends Error{constructor(t="No available resolver"){super(t),this.name="NoAvailableResolverError"}},Zn=class e{bytes;#t;#r;#e;#a;[xs]=!0;constructor(t){t==null&&(t="");let r;if(t instanceof Uint8Array)r=ys(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(eu(t))r=ys(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=et("tcp"),c=et("udp"),a=et("ip4"),l=et("ip6"),u=et("dns6"),f=et("ip6zone");for(let[S,_]of this.stringTuples())S===f.code&&(i=`%${_??""}`),Gh.includes(S)&&(r=s.name==="tcp"?"tcp":"udp",o=443,n=`${_??""}${i}`,t=S===u.code?6:4),(S===s.code||S===c.code)&&(r=et(S).name==="tcp"?"tcp":"udp",o=parseInt(_??"")),(S===a.code||S===l.code)&&(r=et(S).name==="tcp"?"tcp":"udp",n=`${_??""}${i}`,t=S===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({},et(t)))}protoCodes(){return this.#r.map(([t])=>t)}protoNames(){return this.#r.map(([t])=>et(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===Er.p2p.code&&t.push([n,o]),n===Er["p2p-circuit"].code&&(t=[])});let r=t.pop();if(r?.[1]!=null){let n=r[1];return n[0]==="Q"||n[0]==="1"?q(Q.decode(`z${n}`),"base58btc"):q(Z.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){return this.#a}equals(t){return rt(this.bytes,t.bytes)}async resolve(t){let r=this.protos().find(i=>i.resolvable);if(r==null)return[this];let n=tu.get(r.name);if(n==null)throw new gs(`no available resolver for ${r.name}`);return(await n(this,t)).map(i=>Ge(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)}[jh](){return`Multiaddr(${this.#t})`}};var tu=new Map;function eu(e){return!!e?.[xs]}function Ge(e){return new Zn(e)}function Qr(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*Yn(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 Zh="/",Yh=new TextEncoder().encode(Zh),Nb=Yh[0];var Pp=Io(bs(),1);var Wt=class extends Error{static name="SignatureVerificationError";constructor(t="Record signature verification failed"){super(t),this.name="SignatureVerificationError"}},Wn=class extends Error{static name="RecordExpiredError";constructor(t="Record has expired"){super(t),this.name="RecordExpiredError"}},Sr=class extends Error{static name="UnsupportedValidityError";constructor(t="The validity type is unsupported"){super(t),this.name="UnsupportedValidityError"}},Xn=class extends Error{static name="RecordTooLargeError";constructor(t="The record is too large"){super(t),this.name="RecordTooLargeError"}},Jn=class extends Error{static name="InvalidValueError";constructor(t="Value must be a valid content path starting with /"){super(t),this.name="InvalidValueError"}},Qn=class extends Error{static name="InvalidRecordDataError";constructor(t="Invalid record data"){super(t),this.name="InvalidRecordDataError"}},tn=class extends Error{static name="InvalidEmbeddedPublicKeyError";constructor(t="Invalid embedded public key"){super(t),this.name="InvalidEmbeddedPublicKeyError"}};var Xt;(function(e){let t;(function(o){o.EOL="EOL"})(t=e.ValidityType||(e.ValidityType={}));let r;(function(o){o[o.EOL=0]="EOL"})(r||(r={})),function(o){o.codec=()=>Gr(r)}(t=e.ValidityType||(e.ValidityType={}));let n;e.codec=()=>(n==null&&(n=gr((o,i,s={})=>{s.lengthDelimited!==!1&&i.fork(),o.value!=null&&(i.uint32(10),i.bytes(o.value)),o.signatureV1!=null&&(i.uint32(18),i.bytes(o.signatureV1)),o.validityType!=null&&(i.uint32(24),e.ValidityType.codec().encode(o.validityType,i)),o.validity!=null&&(i.uint32(34),i.bytes(o.validity)),o.sequence!=null&&(i.uint32(40),i.uint64(o.sequence)),o.ttl!=null&&(i.uint32(48),i.uint64(o.ttl)),o.pubKey!=null&&(i.uint32(58),i.bytes(o.pubKey)),o.signatureV2!=null&&(i.uint32(66),i.bytes(o.signatureV2)),o.data!=null&&(i.uint32(74),i.bytes(o.data)),s.lengthDelimited!==!1&&i.ldelim()},(o,i,s={})=>{let c={},a=i==null?o.len:o.pos+i;for(;o.pos<a;){let l=o.uint32();switch(l>>>3){case 1:{c.value=o.bytes();break}case 2:{c.signatureV1=o.bytes();break}case 3:{c.validityType=e.ValidityType.codec().decode(o);break}case 4:{c.validity=o.bytes();break}case 5:{c.sequence=o.uint64();break}case 6:{c.ttl=o.uint64();break}case 7:{c.pubKey=o.bytes();break}case 8:{c.signatureV2=o.bytes();break}case 9:{c.data=o.bytes();break}default:{o.skipType(l&7);break}}}return c})),n),e.encode=o=>mr(o,e.codec()),e.decode=(o,i)=>pr(o,e.codec(),i)})(Xt||(Xt={}));var Wh=["string","number","bigint","symbol"],Xh=["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 ru(e){if(e===null)return"null";if(e===void 0)return"undefined";if(e===!0||e===!1)return"boolean";let t=typeof e;if(Wh.includes(t))return t;if(t==="function")return"Function";if(Array.isArray(e))return"Array";if(Jh(e))return"Buffer";let r=Qh(e);return r||"Object"}function Jh(e){return e&&e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer.call(null,e)}function Qh(e){let t=Object.prototype.toString.call(e).slice(8,-1);if(Xh.includes(t))return t}var m=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}};m.uint=new m(0,"uint",!0);m.negint=new m(1,"negint",!0);m.bytes=new m(2,"bytes",!0);m.string=new m(3,"string",!0);m.array=new m(4,"array",!1);m.map=new m(5,"map",!1);m.tag=new m(6,"tag",!1);m.float=new m(7,"float",!0);m.false=new m(7,"false",!0);m.true=new m(7,"true",!0);m.null=new m(7,"null",!0);m.undefined=new m(7,"undefined",!0);m.break=new m(7,"break",!0);var D=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 vr=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&typeof globalThis.Buffer.isBuffer=="function",tp=new TextDecoder,ep=new TextEncoder;function to(e){return vr&&globalThis.Buffer.isBuffer(e)}function su(e){return e instanceof Uint8Array?to(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e:Uint8Array.from(e)}var au=vr?(e,t,r)=>r-t>64?globalThis.Buffer.from(e.subarray(t,r)).toString("utf8"):ou(e,t,r):(e,t,r)=>r-t>64?tp.decode(e.subarray(t,r)):ou(e,t,r),cu=vr?e=>e.length>64?globalThis.Buffer.from(e):nu(e):e=>e.length>64?ep.encode(e):nu(e);var Ar=vr?(e,t,r)=>to(e)?new Uint8Array(e.subarray(t,r)):e.slice(t,r):(e,t,r)=>e.slice(t,r),uu=vr?(e,t)=>(e=e.map(r=>r instanceof Uint8Array?r:globalThis.Buffer.from(r)),su(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},fu=vr?e=>globalThis.Buffer.allocUnsafe(e):e=>new Uint8Array(e);function lu(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 nu(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 ou(e,t,r){let n=[];for(;t<r;){let o=e[t],i=null,s=o>239?4:o>223?3:o>191?2:1;if(t+s<=r){let c,a,l,u;switch(s){case 1:o<128&&(i=o);break;case 2:c=e[t+1],(c&192)===128&&(u=(o&31)<<6|c&63,u>127&&(i=u));break;case 3:c=e[t+1],a=e[t+2],(c&192)===128&&(a&192)===128&&(u=(o&15)<<12|(c&63)<<6|a&63,u>2047&&(u<55296||u>57343)&&(i=u));break;case 4:c=e[t+1],a=e[t+2],l=e[t+3],(c&192)===128&&(a&192)===128&&(l&192)===128&&(u=(o&15)<<18|(c&63)<<12|(a&63)<<6|l&63,u>65535&&u<1114112&&(i=u))}}i===null?(i=65533,s=1):i>65535&&(i-=65536,n.push(i>>>10&1023|55296),i=56320|i&1023),n.push(i),t+=s}return rp(n)}var iu=4096;function rp(e){let t=e.length;if(t<=iu)return String.fromCharCode.apply(String,e);let r="",n=0;for(;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=iu));return r}var np=256,eo=class{constructor(t=np){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=fu(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=Ar(n,0,this.cursor)}else r=uu(this.chunks,this.cursor);return t&&this.reset(),r}};var M="CBOR decode error:",Es="CBOR encode error:",en=[];en[23]=1;en[24]=2;en[25]=3;en[26]=5;en[27]=9;function be(e,t,r){if(e.length-t<r)throw new Error(`${M} not enough data for type`)}var pt=[24,256,65536,4294967296,BigInt("18446744073709551616")];function Ft(e,t,r){be(e,t,1);let n=e[t];if(r.strict===!0&&n<pt[0])throw new Error(`${M} integer encoded in more bytes than necessary (strict decode)`);return n}function Mt(e,t,r){be(e,t,2);let n=e[t]<<8|e[t+1];if(r.strict===!0&&n<pt[1])throw new Error(`${M} integer encoded in more bytes than necessary (strict decode)`);return n}function Vt(e,t,r){be(e,t,4);let n=e[t]*16777216+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3];if(r.strict===!0&&n<pt[2])throw new Error(`${M} integer encoded in more bytes than necessary (strict decode)`);return n}function qt(e,t,r){be(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<pt[3])throw new Error(`${M} integer encoded in more bytes than necessary (strict decode)`);if(i<=Number.MAX_SAFE_INTEGER)return Number(i);if(r.allowBigInt===!0)return i;throw new Error(`${M} integers outside of the safe integer range are not supported`)}function du(e,t,r,n){return new D(m.uint,Ft(e,t+1,n),2)}function hu(e,t,r,n){return new D(m.uint,Mt(e,t+1,n),3)}function pu(e,t,r,n){return new D(m.uint,Vt(e,t+1,n),5)}function mu(e,t,r,n){return new D(m.uint,qt(e,t+1,n),9)}function $t(e,t){return gt(e,0,t.value)}function gt(e,t,r){if(r<pt[0]){let n=Number(r);e.push([t|n])}else if(r<pt[1]){let n=Number(r);e.push([t|24,n])}else if(r<pt[2]){let n=Number(r);e.push([t|25,n>>>8,n&255])}else if(r<pt[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<pt[4]){let o=[t|27,0,0,0,0,0,0,0],i=Number(n&BigInt(4294967295)),s=Number(n>>BigInt(32)&BigInt(4294967295));o[8]=i&255,i=i>>8,o[7]=i&255,i=i>>8,o[6]=i&255,i=i>>8,o[5]=i&255,o[4]=s&255,s=s>>8,o[3]=s&255,s=s>>8,o[2]=s&255,s=s>>8,o[1]=s&255,e.push(o)}else throw new Error(`${M} encountered BigInt larger than allowable range`)}}$t.encodedSize=function(t){return gt.encodedSize(t.value)};gt.encodedSize=function(t){return t<pt[0]?1:t<pt[1]?2:t<pt[2]?3:t<pt[3]?5:9};$t.compareTokens=function(t,r){return t.value<r.value?-1:t.value>r.value?1:0};function yu(e,t,r,n){return new D(m.negint,-1-Ft(e,t+1,n),2)}function gu(e,t,r,n){return new D(m.negint,-1-Mt(e,t+1,n),3)}function xu(e,t,r,n){return new D(m.negint,-1-Vt(e,t+1,n),5)}var Ss=BigInt(-1),wu=BigInt(1);function bu(e,t,r,n){let o=qt(e,t+1,n);if(typeof o!="bigint"){let i=-1-o;if(i>=Number.MIN_SAFE_INTEGER)return new D(m.negint,i,9)}if(n.allowBigInt!==!0)throw new Error(`${M} integers outside of the safe integer range are not supported`);return new D(m.negint,Ss-BigInt(o),9)}function ro(e,t){let r=t.value,n=typeof r=="bigint"?r*Ss-wu:r*-1-1;gt(e,t.type.majorEncoded,n)}ro.encodedSize=function(t){let r=t.value,n=typeof r=="bigint"?r*Ss-wu:r*-1-1;return n<pt[0]?1:n<pt[1]?2:n<pt[2]?3:n<pt[3]?5:9};ro.compareTokens=function(t,r){return t.value<r.value?1:t.value>r.value?-1:0};function rn(e,t,r,n){be(e,t,r+n);let o=Ar(e,t+r,t+r+n);return new D(m.bytes,o,r+n)}function Eu(e,t,r,n){return rn(e,t,1,r)}function Su(e,t,r,n){return rn(e,t,2,Ft(e,t+1,n))}function vu(e,t,r,n){return rn(e,t,3,Mt(e,t+1,n))}function Au(e,t,r,n){return rn(e,t,5,Vt(e,t+1,n))}function Iu(e,t,r,n){let o=qt(e,t+1,n);if(typeof o=="bigint")throw new Error(`${M} 64-bit integer bytes lengths not supported`);return rn(e,t,9,o)}function no(e){return e.encodedBytes===void 0&&(e.encodedBytes=e.type===m.string?cu(e.value):e.value),e.encodedBytes}function Ir(e,t){let r=no(t);gt(e,t.type.majorEncoded,r.length),e.push(r)}Ir.encodedSize=function(t){let r=no(t);return gt.encodedSize(r.length)+r.length};Ir.compareTokens=function(t,r){return ip(no(t),no(r))};function ip(e,t){return e.length<t.length?-1:e.length>t.length?1:lu(e,t)}function nn(e,t,r,n,o){let i=r+n;be(e,t,i);let s=new D(m.string,au(e,t+r,t+i),i);return o.retainStringBytes===!0&&(s.byteValue=Ar(e,t+r,t+i)),s}function Tu(e,t,r,n){return nn(e,t,1,r,n)}function Cu(e,t,r,n){return nn(e,t,2,Ft(e,t+1,n),n)}function Bu(e,t,r,n){return nn(e,t,3,Mt(e,t+1,n),n)}function Pu(e,t,r,n){return nn(e,t,5,Vt(e,t+1,n),n)}function _u(e,t,r,n){let o=qt(e,t+1,n);if(typeof o=="bigint")throw new Error(`${M} 64-bit integer string lengths not supported`);return nn(e,t,9,o,n)}var Uu=Ir;function Tr(e,t,r,n){return new D(m.array,n,r)}function Nu(e,t,r,n){return Tr(e,t,1,r)}function Ru(e,t,r,n){return Tr(e,t,2,Ft(e,t+1,n))}function Lu(e,t,r,n){return Tr(e,t,3,Mt(e,t+1,n))}function Du(e,t,r,n){return Tr(e,t,5,Vt(e,t+1,n))}function ku(e,t,r,n){let o=qt(e,t+1,n);if(typeof o=="bigint")throw new Error(`${M} 64-bit integer array lengths not supported`);return Tr(e,t,9,o)}function Ku(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${M} indefinite length items not allowed`);return Tr(e,t,1,1/0)}function oo(e,t){gt(e,m.array.majorEncoded,t.value)}oo.compareTokens=$t.compareTokens;oo.encodedSize=function(t){return gt.encodedSize(t.value)};function Cr(e,t,r,n){return new D(m.map,n,r)}function Ou(e,t,r,n){return Cr(e,t,1,r)}function Fu(e,t,r,n){return Cr(e,t,2,Ft(e,t+1,n))}function Mu(e,t,r,n){return Cr(e,t,3,Mt(e,t+1,n))}function Vu(e,t,r,n){return Cr(e,t,5,Vt(e,t+1,n))}function qu(e,t,r,n){let o=qt(e,t+1,n);if(typeof o=="bigint")throw new Error(`${M} 64-bit integer map lengths not supported`);return Cr(e,t,9,o)}function $u(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${M} indefinite length items not allowed`);return Cr(e,t,1,1/0)}function io(e,t){gt(e,m.map.majorEncoded,t.value)}io.compareTokens=$t.compareTokens;io.encodedSize=function(t){return gt.encodedSize(t.value)};function Hu(e,t,r,n){return new D(m.tag,r,1)}function zu(e,t,r,n){return new D(m.tag,Ft(e,t+1,n),2)}function ju(e,t,r,n){return new D(m.tag,Mt(e,t+1,n),3)}function Gu(e,t,r,n){return new D(m.tag,Vt(e,t+1,n),5)}function Zu(e,t,r,n){return new D(m.tag,qt(e,t+1,n),9)}function so(e,t){gt(e,m.tag.majorEncoded,t.value)}so.compareTokens=$t.compareTokens;so.encodedSize=function(t){return gt.encodedSize(t.value)};var lp=20,dp=21,hp=22,pp=23;function Yu(e,t,r,n){if(n.allowUndefined===!1)throw new Error(`${M} undefined values are not supported`);return n.coerceUndefinedToNull===!0?new D(m.null,null,1):new D(m.undefined,void 0,1)}function Wu(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${M} indefinite length items not allowed`);return new D(m.break,void 0,1)}function vs(e,t,r){if(r){if(r.allowNaN===!1&&Number.isNaN(e))throw new Error(`${M} NaN values are not supported`);if(r.allowInfinity===!1&&(e===1/0||e===-1/0))throw new Error(`${M} Infinity values are not supported`)}return new D(m.float,e,t)}function Xu(e,t,r,n){return vs(As(e,t+1),3,n)}function Ju(e,t,r,n){return vs(Is(e,t+1),5,n)}function Qu(e,t,r,n){return vs(nf(e,t+1),9,n)}function ao(e,t,r){let n=t.value;if(n===!1)e.push([m.float.majorEncoded|lp]);else if(n===!0)e.push([m.float.majorEncoded|dp]);else if(n===null)e.push([m.float.majorEncoded|hp]);else if(n===void 0)e.push([m.float.majorEncoded|pp]);else{let o,i=!1;(!r||r.float64!==!0)&&(ef(n),o=As(Jt,1),n===o||Number.isNaN(n)?(Jt[0]=249,e.push(Jt.slice(0,3)),i=!0):(rf(n),o=Is(Jt,1),n===o&&(Jt[0]=250,e.push(Jt.slice(0,5)),i=!0))),i||(mp(n),o=nf(Jt,1),Jt[0]=251,e.push(Jt.slice(0,9)))}}ao.encodedSize=function(t,r){let n=t.value;if(n===!1||n===!0||n===null||n===void 0)return 1;if(!r||r.float64!==!0){ef(n);let o=As(Jt,1);if(n===o||Number.isNaN(n))return 3;if(rf(n),o=Is(Jt,1),n===o)return 5}return 9};var tf=new ArrayBuffer(9),Ht=new DataView(tf,1),Jt=new Uint8Array(tf,0);function ef(e){if(e===1/0)Ht.setUint16(0,31744,!1);else if(e===-1/0)Ht.setUint16(0,64512,!1);else if(Number.isNaN(e))Ht.setUint16(0,32256,!1);else{Ht.setFloat32(0,e);let t=Ht.getUint32(0),r=(t&2139095040)>>23,n=t&8388607;if(r===255)Ht.setUint16(0,31744,!1);else if(r===0)Ht.setUint16(0,(e&2147483648)>>16|n>>13,!1);else{let o=r-127;o<-24?Ht.setUint16(0,0):o<-14?Ht.setUint16(0,(t&2147483648)>>16|1<<24+o,!1):Ht.setUint16(0,(t&2147483648)>>16|o+15<<10|n>>13,!1)}}}function As(e,t){if(e.length-t<2)throw new Error(`${M} not enough data for float16`);let r=(e[t]<<8)+e[t+1];if(r===31744)return 1/0;if(r===64512)return-1/0;if(r===32256)return NaN;let n=r>>10&31,o=r&1023,i;return n===0?i=o*2**-24:n!==31?i=(o+1024)*2**(n-25):i=o===0?1/0:NaN,r&32768?-i:i}function rf(e){Ht.setFloat32(0,e,!1)}function Is(e,t){if(e.length-t<4)throw new Error(`${M} not enough data for float32`);let r=(e.byteOffset||0)+t;return new DataView(e.buffer,r,4).getFloat32(0,!1)}function mp(e){Ht.setFloat64(0,e,!1)}function nf(e,t){if(e.length-t<8)throw new Error(`${M} not enough data for float64`);let r=(e.byteOffset||0)+t;return new DataView(e.buffer,r,8).getFloat64(0,!1)}ao.compareTokens=$t.compareTokens;function Y(e,t,r){throw new Error(`${M} encountered invalid minor (${r}) for major ${e[t]>>>5}`)}function co(e){return()=>{throw new Error(`${M} ${e}`)}}var P=[];for(let e=0;e<=23;e++)P[e]=Y;P[24]=du;P[25]=hu;P[26]=pu;P[27]=mu;P[28]=Y;P[29]=Y;P[30]=Y;P[31]=Y;for(let e=32;e<=55;e++)P[e]=Y;P[56]=yu;P[57]=gu;P[58]=xu;P[59]=bu;P[60]=Y;P[61]=Y;P[62]=Y;P[63]=Y;for(let e=64;e<=87;e++)P[e]=Eu;P[88]=Su;P[89]=vu;P[90]=Au;P[91]=Iu;P[92]=Y;P[93]=Y;P[94]=Y;P[95]=co("indefinite length bytes/strings are not supported");for(let e=96;e<=119;e++)P[e]=Tu;P[120]=Cu;P[121]=Bu;P[122]=Pu;P[123]=_u;P[124]=Y;P[125]=Y;P[126]=Y;P[127]=co("indefinite length bytes/strings are not supported");for(let e=128;e<=151;e++)P[e]=Nu;P[152]=Ru;P[153]=Lu;P[154]=Du;P[155]=ku;P[156]=Y;P[157]=Y;P[158]=Y;P[159]=Ku;for(let e=160;e<=183;e++)P[e]=Ou;P[184]=Fu;P[185]=Mu;P[186]=Vu;P[187]=qu;P[188]=Y;P[189]=Y;P[190]=Y;P[191]=$u;for(let e=192;e<=215;e++)P[e]=Hu;P[216]=zu;P[217]=ju;P[218]=Gu;P[219]=Zu;P[220]=Y;P[221]=Y;P[222]=Y;P[223]=Y;for(let e=224;e<=243;e++)P[e]=co("simple values are not supported");P[244]=Y;P[245]=Y;P[246]=Y;P[247]=Yu;P[248]=co("simple values are not supported");P[249]=Xu;P[250]=Ju;P[251]=Qu;P[252]=Y;P[253]=Y;P[254]=Y;P[255]=Wu;var Qt=[];for(let e=0;e<24;e++)Qt[e]=new D(m.uint,e,1);for(let e=-1;e>=-24;e--)Qt[31-e]=new D(m.negint,e,1);Qt[64]=new D(m.bytes,new Uint8Array(0),1);Qt[96]=new D(m.string,"",1);Qt[128]=new D(m.array,0,1);Qt[160]=new D(m.map,0,1);Qt[244]=new D(m.false,!1,1);Qt[245]=new D(m.true,!0,1);Qt[246]=new D(m.null,null,1);function gp(){let e=[];return e[m.uint.major]=$t,e[m.negint.major]=ro,e[m.bytes.major]=Ir,e[m.string.major]=Uu,e[m.array.major]=oo,e[m.map.major]=io,e[m.tag.major]=so,e[m.float.major]=ao,e}var _1=gp(),U1=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(`${Es} object contains circular references`);return new e(r,t)}},Re={null:new D(m.null,null),undefined:new D(m.undefined,void 0),true:new D(m.true,!0),false:new D(m.false,!1),emptyArray:new D(m.array,0),emptyMap:new D(m.map,0)},Le={number(e,t,r,n){return!Number.isInteger(e)||!Number.isSafeInteger(e)?new D(m.float,e):e>=0?new D(m.uint,e):new D(m.negint,e)},bigint(e,t,r,n){return e>=BigInt(0)?new D(m.uint,e):new D(m.negint,e)},Uint8Array(e,t,r,n){return new D(m.bytes,e)},string(e,t,r,n){return new D(m.string,e)},boolean(e,t,r,n){return e?Re.true:Re.false},null(e,t,r,n){return Re.null},undefined(e,t,r,n){return Re.undefined},ArrayBuffer(e,t,r,n){return new D(m.bytes,new Uint8Array(e))},DataView(e,t,r,n){return new D(m.bytes,new Uint8Array(e.buffer,e.byteOffset,e.byteLength))},Array(e,t,r,n){if(!e.length)return r.addBreakTokens===!0?[Re.emptyArray,new D(m.break)]:Re.emptyArray;n=uo.createCheck(n,e);let o=[],i=0;for(let s of e)o[i++]=Ts(s,r,n);return r.addBreakTokens?[new D(m.array,e.length),o,new D(m.break)]:[new D(m.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?[Re.emptyMap,new D(m.break)]:Re.emptyMap;n=uo.createCheck(n,e);let c=[],a=0;for(let l of i)c[a++]=[Ts(l,r,n),Ts(o?e.get(l):e[l],r,n)];return xp(c,r),r.addBreakTokens?[new D(m.map,s),c,new D(m.break)]:[new D(m.map,s),c]}};Le.Map=Le.Object;Le.Buffer=Le.Uint8Array;for(let e of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))Le[`${e}Array`]=Le.DataView;function Ts(e,t={},r){let n=ru(e),o=t&&t.typeEncoders&&t.typeEncoders[n]||Le[n];if(typeof o=="function"){let s=o(e,n,t,r);if(s!=null)return s}let i=Le[n];if(!i)throw new Error(`${Es} unsupported type: ${n}`);return i(e,n,t,r)}function xp(e,t){t.mapSorter&&e.sort(t.mapSorter)}var wp={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=Qt[t];if(r===void 0){let n=P[t];if(!n)throw new Error(`${M} no decoder for major type ${t>>>5} (byte 0x${t.toString(16).padStart(2,"0")})`);let o=t&31;r=n(this.data,this._pos,o,this.options)}return this._pos+=r.encodedLength,r}},on=Symbol.for("DONE"),lo=Symbol.for("BREAK");function bp(e,t,r){let n=[];for(let o=0;o<e.value;o++){let i=Br(t,r);if(i===lo){if(e.value===1/0)break;throw new Error(`${M} got unexpected break to lengthed array`)}if(i===on)throw new Error(`${M} found array but not enough entries (got ${o}, expected ${e.value})`);n[o]=i}return n}function Ep(e,t,r){let n=r.useMaps===!0,o=n?void 0:{},i=n?new Map:void 0;for(let s=0;s<e.value;s++){let c=Br(t,r);if(c===lo){if(e.value===1/0)break;throw new Error(`${M} got unexpected break to lengthed map`)}if(c===on)throw new Error(`${M} found map but not enough entries (got ${s} [no key], expected ${e.value})`);if(n!==!0&&typeof c!="string")throw new Error(`${M} non-string keys not supported (got ${typeof c})`);if(r.rejectDuplicateMapKeys===!0&&(n&&i.has(c)||!n&&c in o))throw new Error(`${M} found repeat map key "${c}"`);let a=Br(t,r);if(a===on)throw new Error(`${M} found map but not enough entries (got ${s} [no value], expected ${e.value})`);n?i.set(c,a):o[c]=a}return n?i:o}function Br(e,t){if(e.done())return on;let r=e.next();if(r.type===m.break)return lo;if(r.type.terminal)return r.value;if(r.type===m.array)return bp(r,e,t);if(r.type===m.map)return Ep(r,e,t);if(r.type===m.tag){if(t.tags&&typeof t.tags[r.value]=="function"){let n=Br(e,t);return t.tags[r.value](n)}throw new Error(`${M} tag not supported (${r.value})`)}throw new Error("unsupported")}function of(e,t){if(!(e instanceof Uint8Array))throw new Error(`${M} data to decode must be a Uint8Array`);t=Object.assign({},wp,t);let r=t.tokenizer||new fo(e,t),n=Br(r,t);if(n===on)throw new Error(`${M} did not find any content to decode`);if(n===lo)throw new Error(`${M} got unexpected break`);return[n,e.subarray(r.pos())]}function Cs(e,t){let[r,n]=of(e,t);if(n.length>0)throw new Error(`${M} too many terminals, data makes no sense`);return r}var Ap=ve("ipns:utils"),sf=H("/ipns/");var Ip=0,Tp=18;function af(e){let t;if(e.pubKey!=null)try{t=Kc(e.pubKey)}catch(r){throw Ap.error(r),r}if(t!=null)return t}function cf(e){let t=H("ipns-signature:");return bt([t,e])}function Ye(e){return"signatureV1"in e?Xt.encode({value:H(e.value),signatureV1:e.signatureV1,validityType:e.validityType,validity:H(e.validity),sequence:e.sequence,ttl:e.ttl,pubKey:e.pubKey,signatureV2:e.signatureV2,data:e.data}):Xt.encode({pubKey:e.pubKey,signatureV2:e.signatureV2,data:e.data})}function se(e){let t=Xt.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 Wt("Missing data or signatureV2");let r=uf(t.data),n=Cp(r.Value),o=q(r.Validity);if(t.value!=null&&t.signatureV1!=null)return Bp(t),{value:n,validityType:Xt.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:Xt.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 sn(e){return bt([sf,e.bytes])}function Ee(e){let t=ue(e.slice(sf.length));if(!ho(t,Ip)&&!ho(t,Tp))throw new Xe("Multihash in IPNS key was not identity or sha2-256");return t}function uf(e){let t=Cs(e);if(t.ValidityType===0)t.ValidityType=Xt.ValidityType.EOL;else throw new Sr("The validity type is unsupported");return Number.isInteger(t.Sequence)&&(t.Sequence=BigInt(t.Sequence)),Number.isInteger(t.TTL)&&(t.TTL=BigInt(t.TTL)),t}function Cp(e){let t=q(e).trim();if(t.startsWith("/"))return t;try{return`/ipfs/${Z.decode(e).toV1().toString()}`}catch{}try{return`/ipfs/${Z.parse(t).toV1().toString()}`}catch{}throw new Jn("Value must be a valid content path starting with /")}function Bp(e){if(e.data==null)throw new Qn("Record data is missing");let t=uf(e.data);if(!rt(t.Value,e.value??new Uint8Array(0)))throw new Wt('Field "value" did not match between protobuf and CBOR');if(!rt(t.Validity,e.validity??new Uint8Array(0)))throw new Wt('Field "validity" did not match between protobuf and CBOR');if(t.ValidityType!==e.validityType)throw new Wt('Field "validityType" did not match between protobuf and CBOR');if(t.Sequence!==e.sequence)throw new Wt('Field "sequence" did not match between protobuf and CBOR');if(t.TTL!==e.ttl)throw new Wt('Field "ttl" did not match between protobuf and CBOR')}function ho(e,t){return e.code===t}var e2=ve("ipns"),r2=5*60*1e9,_p="/ipns/",n2=_p.length;var ff=Io(bs(),1);var po=ve("ipns:validator"),Up=1024*10,Np=async(e,t)=>{let r=se(t),n;try{let o=cf(r.data);n=await e.verify(o,r.signatureV2)}catch{n=!1}if(!n)throw po.error("record signature verification failed"),new Wt("Record signature verification failed");if(r.validityType===Xt.ValidityType.EOL){if(ff.default.fromString(r.validity).toDate().getTime()<Date.now())throw po.error("record has expired"),new Wn("record has expired")}else if(r.validityType!=null)throw po.error("the validity type is unsupported"),new Sr("The validity type is unsupported");po("ipns record for %s is valid",r.value)};async function lf(e,t){if(t.byteLength>Up)throw new Xn("The record is too large");let r=Ee(e),n;ho(r,0)&&(n=Fn(r));let o=se(t),i=af(o)??n;if(i==null)throw new tn("Could not extract public key from IPNS record or routing key");let s=sn(i.toMultihash());if(!rt(s,e))throw new tn("Embedded public key did not match routing key");await Np(i,t)}var mo=class extends Error{name="InvalidMessageLengthError";code="ERR_INVALID_MESSAGE_LENGTH"};async function*an(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)),or(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 c=0;c<s.length;c++)yield JSON.parse(s[c])}o+=n.decode(),o!==""&&(yield JSON.parse(o))}function ae(){let e={};return e.promise=new Promise((t,r)=>{e.resolve=t,e.reject=r}),e}var Ps=Io(hf(),1);var un=class extends Error{constructor(t){super(t),this.name="TimeoutError"}},_s=class extends Error{constructor(t){super(),this.name="AbortError",this.message=t}},pf=e=>globalThis.DOMException===void 0?new _s(e):new DOMException(e),mf=e=>{let t=e.reason===void 0?pf("This operation was aborted."):e.reason;return t instanceof Error?t:pf(t)};function Us(e,t){let{milliseconds:r,fallback:n,message:o,customTimers:i={setTimeout,clearTimeout}}=t,s,c,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:S}=t;S.aborted&&f(mf(S)),c=()=>{f(mf(S))},S.addEventListener("abort",c,{once:!0})}if(r===Number.POSITIVE_INFINITY){e.then(u,f);return}let p=new un;s=i.setTimeout.call(void 0,()=>{if(n){try{u(n())}catch(S){f(S)}return}typeof e.cancel=="function"&&e.cancel(),o===!1?u():o instanceof Error?f(o):(p.message=o??`Promise timed out after ${r} milliseconds`,f(p))},r),(async()=>{try{u(await e)}catch(S){f(S)}})()}).finally(()=>{l.clear(),c&&t.signal&&t.signal.removeEventListener("abort",c)});return l.clear=()=>{i.clearTimeout.call(void 0,s),s=void 0},l}function Ns(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 fn=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=Ns(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 ln=class extends Ps.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:fn,...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=Us(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 un&&!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 Pr=class extends Error{static name="InvalidRequestError";constructor(t="Invalid request"){super(t),this.name="InvalidRequestError"}},te=class extends Error{static name="BadResponseError";constructor(t="Bad response"){super(t),this.name="BadResponseError"}};function Dp(e){return e[Symbol.asyncIterator]!=null}function kp(e){if(Dp(e))return(async()=>{for await(let t of e)return t})();for(let t of e)return t}var go=kp;function Kp(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 yf=Kp;function Op(e){return e[Symbol.asyncIterator]!=null}function Fp(e,t){let r=0;if(Op(e))return async function*(){for await(let a of e)yield t(a,r++)}();let n=yf(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 await(let a of n)yield t(a,r++)}();let c=t;return function*(){yield s;for(let a of n)yield c(a,r++)}()}var xo=Fp;var gf=H("/ipns/");function xf(e){return rt(e.subarray(0,gf.byteLength),gf)}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(!xf(t))return;let o=Ee(t),i=Z.createV1(114,o),s=se(r);await this.client.putIPNS(i,s,n)}async get(t,r){if(!xf(t))throw new Pt("Not found");let n=Ee(t),o=Z.createV1(114,n);try{let i=await this.client.getIPNS(o,r);return Ye(i)}catch(i){throw i.name==="BadResponseError"?new Pt("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 Pt("Not found")}async*getClosestPeers(t,r={}){}};var xt=ve("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 ln({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[js](){return this.contentRouting}get[Gs](){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&&xt("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={}){xt("getProviders starts: %c",t);let n=AbortSignal.timeout(this.timeout),o=Qr([this.shutDownController.signal,n,r.signal]);let i=ae(),s=ae();this.httpQueue.add(async()=>(i.resolve(),s.promise));try{await i.promise;let c=new URL(`${this.clientUrl}routing/v1/providers/${t.toString()}`);this.#r(c,r.filterAddrs,r.filterProtocols);let a={headers:{Accept:"application/x-ndjson"},signal:o},l=await this.#e(c.toString(),a);if(l==null)throw new te("No response received");if(!l.ok)throw l.status===404?new Pt("No matching records found"):l.status===422?new Pr("Request does not conform to schema or semantic constraints"):new te(`Unexpected status code: ${l.status}`);if(l.body==null)throw new te("Routing response had no body");let u=l.headers.get("Content-Type");if(u==null)throw new te("No Content-Type header received");if(u?.startsWith("application/json")){let f=await l.json();for(let p of f.Providers){let S=this.#t(p);S!=null&&(yield S)}}else if(u.includes("application/x-ndjson"))for await(let f of an(Yn(l.body))){let p=this.#t(f);p!=null&&(yield p)}else throw new te(`Unsupported Content-Type: ${u}`)}finally{o.clear(),s.resolve(),xt("getProviders finished: %c",t)}}async*getPeers(t,r={}){xt("getPeers starts: %c",t);let n=AbortSignal.timeout(this.timeout),o=Qr([this.shutDownController.signal,n,r.signal]);let i=ae(),s=ae();this.httpQueue.add(async()=>(i.resolve(),s.promise));try{await i.promise;let c=new URL(`${this.clientUrl}routing/v1/peers/${t.toCID().toString()}`);this.#r(c,r.filterAddrs,r.filterProtocols);let a={headers:{Accept:"application/x-ndjson"},signal:o},l=await this.#e(c.toString(),a);if(l.status===404)throw new Pt("No matching records found");if(l.status===422)throw new Pr("Request does not conform to schema or semantic constraints");if(l.body==null)throw new te("Routing response had no body");if(l.headers.get("Content-Type")==="application/json"){let f=await l.json();for(let p of f.Peers){let S=this.#t(p);S!=null&&(yield S)}}else for await(let f of an(Yn(l.body))){let p=this.#t(f);p!=null&&(yield p)}}catch(c){xt.error("getPeers errored:",c)}finally{o.clear(),s.resolve(),xt("getPeers finished: %c",t)}}async getIPNS(t,r={}){xt("getIPNS starts: %s",t);let n=AbortSignal.timeout(this.timeout),o=Qr([this.shutDownController.signal,n,r.signal]);let i=ae(),s=ae();this.httpQueue.add(async()=>(i.resolve(),s.promise));let c=`${this.clientUrl}routing/v1/ipns/${t}`;try{await i.promise;let a={headers:{Accept:"application/vnd.ipfs.ipns-record"},signal:o},l=await this.#e(c,a);if(xt("getIPNS GET %s %d",c,l.status),l.status===404)throw new Pt("No matching records found");if(l.status===422)throw new Pr("Request does not conform to schema or semantic constraints");if(l.body==null)throw new te("GET ipns response had no body");let u=await l.arrayBuffer(),f=new Uint8Array(u,0,u.byteLength);return r.validate!==!1&&await lf(sn(t.multihash),f),se(f)}catch(a){throw xt.error("getIPNS GET %s error:",c,a),a}finally{o.clear(),s.resolve(),xt("getIPNS finished: %s",t)}}async putIPNS(t,r,n={}){xt("putIPNS starts: %c",t);let o=AbortSignal.timeout(this.timeout),i=Qr([this.shutDownController.signal,o,n.signal]);let s=ae(),c=ae();this.httpQueue.add(async()=>(s.resolve(),c.promise));let a=`${this.clientUrl}routing/v1/ipns/${t}`;try{await s.promise;let l=Ye(r),u={method:"PUT",headers:{"Content-Type":"application/vnd.ipfs.ipns-record"},body:l,signal:i},f=await this.#e(a,u);if(xt("putIPNS PUT %s %d",a,f.status),f.status!==200)throw new te("PUT ipns response had status other than 200")}catch(l){throw xt.error("putIPNS PUT %s error:",a,l.stack),l}finally{i.clear(),c.resolve(),xt("putIPNS finished: %c",t)}}#t(t){try{let r=[],n=t.Addrs?.map(Ge)??[];return t.Protocols!=null&&r.push(...t.Protocols),t.Protocol!=null&&(r.push(t.Protocol),delete t.Protocol),{...t,Schema:"peer",ID:Mc(t.ID),Addrs:n,Protocols:r}}catch(r){xt.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 a=await this.cache?.match(t);if(a!=null){if(parseInt(a.headers.get("x-cache-expires")??"0",10)>Date.now())return xt("returning cached response for %s",o),a;await this.cache?.delete(t)}}let i=this.inFlightRequests.get(o);if(i!=null){let a=await i;return xt("deduplicating outgoing request for %s",o),a.clone()}let s=fetch(t,r).then(async a=>{if(this.cache!=null&&a.ok&&n==="GET"){let l=Date.now()+this.cacheTTL,u=new Headers(a.headers);u.set("x-cache-expires",l.toString());let f=new Response(a.clone().body,{status:a.status,statusText:a.statusText,headers:u});await this.cache.put(t,f)}return a}).finally(()=>{this.inFlightRequests.delete(o)});return this.inFlightRequests.set(o,s),await s}};function wf(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 bf=H("/ipns/");function Ef(e){return rt(e.subarray(0,bf.byteLength),bf)}var Rs=class{client;constructor(t,r={}){this.client=wf(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(!Ef(t))return;let o=Ee(t),i=Z.createV1(114,o),s=se(r);await this.client.putIPNS(i,s,n)}async get(t,r){if(!Ef(t))throw new Pt("Not found");let n=Ee(t),o=Z.createV1(114,n);try{let i=await this.client.getIPNS(o,r);return Ye(i)}catch(i){throw i.name==="BadResponseError"?new Pt("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 Pt("Not found")}async*getClosestPeers(t,r){}};function Sf(e,t){let r=t??vo();return new Rs(new URL(e),r)}var vf="[a-fA-F\\d:]",De=e=>e&&e.includeBoundaries?`(?:(?<=\\s|^)(?=${vf})|(?<=${vf})(?=\\s|$))`:"",ee="(?: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}",ft="[a-fA-F\\d]{1,4}",Ao=`
3
+ `,R:"%H:%M",T:"%H:%M:%S",t:" ",X:"%T",Z:"GMT",z:"+0000"};return y;function y(g,A,R){var I=this;if(!(I instanceof y))return new y(g,A,R);I.time=+g||0,I.nano=+A||0,I.year=+R||0,k(I)}function k(g){var A,R,I,C=g.year,U=g.time,$=g.nano,x=(($<0||c<=$)&&($-=(R=Math.floor($/c))*c,U+=R,R=1),C%t);return(U<-i||i<U||x)&&((A=l(U/o))&&(C+=A*t,U-=A*o),(I=O(U)).setUTCFullYear(x+I.getUTCFullYear()),I=(U=+I)+(A=l((C-=x)/t))*o,A&&-i<=I&&I<=i&&(C-=A*t,U=I),R=1),R&&(g.year=C,g.time=U,g.nano=$),g}function O(g){var A=new Date(0);return A.setTime(g),A}function z(C,I){C=+C||0;var R=l((I=(I|0)*s)/n)+l(C/n),I=I%n+C%n,C=l(I/n);return C&&(R+=C,I-=C*n),new y(1e3*I,0,R*t)}function T(g,A,R,I,C,U){return function(x,w){var E=k(this);x=x||new Array(8),v(x,w|=0);var h=Math.floor(E.time/1e3),E=E.year*(r*e/t),K=l(E/s)+l(h/s),E=E%s+h%s,h=Math.floor(E/s);return h&&(K+=h,E-=h*s),$(x,w+C,K),$(x,w+U,E),x};function $(x,w,K){x[w+g]=K>>24&255,x[w+A]=K>>16&255,x[w+R]=K>>8&255,x[w+I]=255&K}}function d(g,A,R,I,C,U){return function(x,w){v(x,w|=0);var K=$(x,w+C);return z($(x,w+U),K)};function $(x,w){return 16777216*x[w+g]+(x[w+A]<<16|x[w+R]<<8|x[w+I])}}function v(g,A){if(g=g&&g.length,g==null)throw new TypeError("Invalid Buffer");if(g<A+8)throw new RangeError("Out of range")}function N(g){return(9<g?"":"0")+(0|g)}function L(g,A){return(a+(0|g)).substr(-A)}}()});var hf=Hs((T2,Bs)=>{"use strict";var Rp=Object.prototype.hasOwnProperty,Tt="~";function cn(){}Object.create&&(cn.prototype=Object.create(null),new cn().__proto__||(Tt=!1));function Lp(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function df(e,t,r,n,o){if(typeof r!="function")throw new TypeError("The listener must be a function");var i=new Lp(r,n||e,o),s=Tt?Tt+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 cn:delete e._events[t]}function vt(){this._events=new cn,this._eventsCount=0}vt.prototype.eventNames=function(){var t=[],r,n;if(this._eventsCount===0)return t;for(n in r=this._events)Rp.call(r,n)&&t.push(Tt?n.slice(1):n);return Object.getOwnPropertySymbols?t.concat(Object.getOwnPropertySymbols(r)):t};vt.prototype.listeners=function(t){var r=Tt?Tt+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};vt.prototype.listenerCount=function(t){var r=Tt?Tt+t:t,n=this._events[r];return n?n.fn?1:n.length:0};vt.prototype.emit=function(t,r,n,o,i,s){var c=Tt?Tt+t:t;if(!this._events[c])return!1;var a=this._events[c],l=arguments.length,u,f;if(a.fn){switch(a.once&&this.removeListener(t,a.fn,void 0,!0),l){case 1:return a.fn.call(a.context),!0;case 2:return a.fn.call(a.context,r),!0;case 3:return a.fn.call(a.context,r,n),!0;case 4:return a.fn.call(a.context,r,n,o),!0;case 5:return a.fn.call(a.context,r,n,o,i),!0;case 6:return a.fn.call(a.context,r,n,o,i,s),!0}for(f=1,u=new Array(l-1);f<l;f++)u[f-1]=arguments[f];a.fn.apply(a.context,u)}else{var p=a.length,S;for(f=0;f<p;f++)switch(a[f].once&&this.removeListener(t,a[f].fn,void 0,!0),l){case 1:a[f].fn.call(a[f].context);break;case 2:a[f].fn.call(a[f].context,r);break;case 3:a[f].fn.call(a[f].context,r,n);break;case 4:a[f].fn.call(a[f].context,r,n,o);break;default:if(!u)for(S=1,u=new Array(l-1);S<l;S++)u[S-1]=arguments[S];a[f].fn.apply(a[f].context,u)}}return!0};vt.prototype.on=function(t,r,n){return df(this,t,r,n,!1)};vt.prototype.once=function(t,r,n){return df(this,t,r,n,!0)};vt.prototype.removeListener=function(t,r,n,o){var i=Tt?Tt+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 c=0,a=[],l=s.length;c<l;c++)(s[c].fn!==r||o&&!s[c].once||n&&s[c].context!==n)&&a.push(s[c]);a.length?this._events[i]=a.length===1?a[0]:a:yo(this,i)}return this};vt.prototype.removeAllListeners=function(t){var r;return t?(r=Tt?Tt+t:t,this._events[r]&&yo(this,r)):(this._events=new cn,this._eventsCount=0),this};vt.prototype.off=vt.prototype.removeListener;vt.prototype.addListener=vt.prototype.on;vt.prefixed=Tt;vt.EventEmitter=vt;typeof Bs<"u"&&(Bs.exports=vt)});var r0={};Bt(r0,{delegatedHTTPRouting:()=>Sf,delegatedHTTPRoutingDefaults:()=>vo,httpGatewayRouting:()=>_f,libp2pRouting:()=>Uf});var js=Symbol.for("@libp2p/content-routing");var To=Symbol.for("@libp2p/peer-id");var Gs=Symbol.for("@libp2p/peer-routing");var ut=class extends Error{static name="InvalidParametersError";constructor(t="Invalid parameters"){super(t),this.name="InvalidParametersError"}},We=class extends Error{static name="InvalidPublicKeyError";constructor(t="Invalid public key"){super(t),this.name="InvalidPublicKeyError"}};var Pt=class extends Error{static name="NotFoundError";constructor(t="Not found"){super(t),this.name="NotFoundError"}};var hn=class extends Error{static name="InvalidCIDError";constructor(t="Invalid CID"){super(t),this.name="InvalidCIDError"}},Xe=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 Uo={};Bt(Uo,{base32:()=>jt,base32hex:()=>Xf,base32hexpad:()=>Qf,base32hexpadupper:()=>tl,base32hexupper:()=>Jf,base32pad:()=>Yf,base32padupper:()=>Wf,base32upper:()=>Zf,base32z:()=>el});var c0=new Uint8Array(0);function Zs(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 ce(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 Ys(e){return new TextEncoder().encode(e)}function Ws(e){return new TextDecoder().decode(e)}function qf(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var o=0;o<e.length;o++){var i=e.charAt(o),s=i.charCodeAt(0);if(r[s]!==255)throw new TypeError(i+" is ambiguous");r[s]=o}var c=e.length,a=e.charAt(0),l=Math.log(c)/Math.log(256),u=Math.log(256)/Math.log(c);function f(_){if(_ instanceof Uint8Array||(ArrayBuffer.isView(_)?_=new Uint8Array(_.buffer,_.byteOffset,_.byteLength):Array.isArray(_)&&(_=Uint8Array.from(_))),!(_ instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(_.length===0)return"";for(var y=0,k=0,O=0,z=_.length;O!==z&&_[O]===0;)O++,y++;for(var T=(z-O)*u+1>>>0,d=new Uint8Array(T);O!==z;){for(var v=_[O],N=0,L=T-1;(v!==0||N<k)&&L!==-1;L--,N++)v+=256*d[L]>>>0,d[L]=v%c>>>0,v=v/c>>>0;if(v!==0)throw new Error("Non-zero carry");k=N,O++}for(var g=T-k;g!==T&&d[g]===0;)g++;for(var A=a.repeat(y);g<T;++g)A+=e.charAt(d[g]);return A}function p(_){if(typeof _!="string")throw new TypeError("Expected String");if(_.length===0)return new Uint8Array;var y=0;if(_[y]!==" "){for(var k=0,O=0;_[y]===a;)k++,y++;for(var z=(_.length-y)*l+1>>>0,T=new Uint8Array(z);_[y];){var d=r[_.charCodeAt(y)];if(d===255)return;for(var v=0,N=z-1;(d!==0||v<O)&&N!==-1;N--,v++)d+=c*T[N]>>>0,T[N]=d%256>>>0,d=d/256>>>0;if(d!==0)throw new Error("Non-zero carry");O=v,y++}if(_[y]!==" "){for(var L=z-O;L!==z&&T[L]===0;)L++;for(var g=new Uint8Array(k+(z-L)),A=k;L!==z;)g[A++]=T[L++];return g}}}function S(_){var y=p(_);if(y)return y;throw new Error(`Non-${t} character`)}return{encode:f,decodeUnsafe:p,decode:S}}var $f=qf,Hf=$f,Js=Hf;var Co=class{name;prefix;baseEncode;constructor(t,r,n){this.name=t,this.prefix=r,this.baseEncode=n}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}},Bo=class{name;prefix;baseDecode;prefixCodePoint;constructor(t,r,n){this.name=t,this.prefix=r;let o=r.codePointAt(0);if(o===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=o,this.baseDecode=n}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return Qs(this,t)}},Po=class{decoders;constructor(t){this.decoders=t}or(t){return Qs(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 Qs(e,t){return new Po({...e.decoders??{[e.prefix]:e},...t.decoders??{[t.prefix]:t}})}var _o=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(t,r,n,o){this.name=t,this.prefix=r,this.baseEncode=n,this.baseDecode=o,this.encoder=new Co(t,r,n),this.decoder=new Bo(t,r,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function Qe({name:e,prefix:t,encode:r,decode:n}){return new _o(e,t,r,n)}function Se({name:e,prefix:t,alphabet:r}){let{encode:n,decode:o}=Js(r,e);return Qe({prefix:t,name:e,encode:n,decode:i=>ce(o(i))})}function zf(e,t,r,n){let o=e.length;for(;e[o-1]==="=";)--o;let i=new Uint8Array(o*r/8|0),s=0,c=0,a=0;for(let l=0;l<o;++l){let u=t[e[l]];if(u===void 0)throw new SyntaxError(`Non-${n} character`);c=c<<r|u,s+=r,s>=8&&(s-=8,i[a++]=255&c>>s)}if(s>=r||(255&c<<8-s)!==0)throw new SyntaxError("Unexpected end of data");return i}function jf(e,t,r){let n=t[t.length-1]==="=",o=(1<<r)-1,i="",s=0,c=0;for(let a=0;a<e.length;++a)for(c=c<<8|e[a],s+=8;s>r;)s-=r,i+=t[o&c>>s];if(s!==0&&(i+=t[o&c<<r-s]),n)for(;(i.length*r&7)!==0;)i+="=";return i}function Gf(e){let t={};for(let r=0;r<e.length;++r)t[e[r]]=r;return t}function it({name:e,prefix:t,bitsPerChar:r,alphabet:n}){let o=Gf(n);return Qe({prefix:t,name:e,encode(i){return jf(i,n,r)},decode(i){return zf(i,o,r,e)}})}var jt=it({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Zf=it({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Yf=it({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Wf=it({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Xf=it({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Jf=it({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Qf=it({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),tl=it({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),el=it({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var No={};Bt(No,{base58btc:()=>Q,base58flickr:()=>rl});var Q=Se({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),rl=Se({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Lo={};Bt(Lo,{base64:()=>Ro,base64pad:()=>nl,base64url:()=>ol,base64urlpad:()=>il});var Ro=it({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),nl=it({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),ol=it({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),il=it({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});function sl(e,t){try{if(typeof e=="string"&&e.length>0)return al(e);if(typeof e=="number"&&isFinite(e))return t?.long?ul(e):cl(e);throw new Error("Value is not a string or number.")}catch(r){let n=fl(r)?`${r.message}. value=${JSON.stringify(e)}`:"An unknown error has occured.";throw new Error(n)}}function al(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 mn=sl;function cl(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 ul(e){let t=Math.abs(e);return t>=864e5?pn(e,t,864e5,"day"):t>=36e5?pn(e,t,36e5,"hour"):t>=6e4?pn(e,t,6e4,"minute"):t>=1e3?pn(e,t,1e3,"second"):`${e} ms`}function pn(e,t,r,n){let o=t>=r*1.5;return`${Math.round(e/r)} ${n}${o?"s":""}`}function fl(e){return typeof e=="object"&&e!==null&&"message"in e}function Do(e){r.debug=r,r.default=r,r.coerce=a,r.disable=i,r.enable=o,r.enabled=s,r.humanize=mn,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 p=0;p<u.length;p++)f=(f<<5)-f+u.charCodeAt(p),f|=0;return r.colors[Math.abs(f)%r.colors.length]}r.selectColor=t;function r(u){let f,p=null,S,_;function y(...k){if(!y.enabled)return;let O=y,z=Number(new Date),T=z-(f||z);O.diff=T,O.prev=f,O.curr=z,f=z,k[0]=r.coerce(k[0]),typeof k[0]!="string"&&k.unshift("%O");let d=0;k[0]=k[0].replace(/%([a-zA-Z%])/g,(N,L)=>{if(N==="%%")return"%";d++;let g=r.formatters[L];if(typeof g=="function"){let A=k[d];N=g.call(O,A),k.splice(d,1),d--}return N}),r.formatArgs.call(O,k),(O.log||r.log).apply(O,k)}return y.namespace=u,y.useColors=r.useColors(),y.color=r.selectColor(u),y.extend=n,y.destroy=r.destroy,Object.defineProperty(y,"enabled",{enumerable:!0,configurable:!1,get:()=>p!==null?p:(S!==r.namespaces&&(S=r.namespaces,_=r.enabled(u)),_),set:k=>{p=k}}),typeof r.init=="function"&&r.init(y),y}function n(u,f){let p=r(this.namespace+(typeof f>"u"?":":f)+u);return p.log=this.log,p}function o(u){r.save(u),r.namespaces=u,r.names=[],r.skips=[];let f,p=(typeof u=="string"?u:"").split(/[\s,]+/),S=p.length;for(f=0;f<S;f++)p[f]&&(u=p[f].replace(/\*/g,".*?"),u[0]==="-"?r.skips.push(new RegExp("^"+u.substr(1)+"$")):r.names.push(new RegExp("^"+u+"$")))}function i(){let u=[...r.names.map(c),...r.skips.map(c).map(f=>"-"+f)].join(",");return r.enable(""),u}function s(u){if(u[u.length-1]==="*")return!0;let f,p;for(f=0,p=r.skips.length;f<p;f++)if(r.skips[f].test(u))return!1;for(f=0,p=r.names.length;f<p;f++)if(r.names[f].test(u))return!0;return!1}function c(u){return u.toString().substring(2,u.toString().length-2).replace(/\.\*\?$/,"*")}function a(u){return u instanceof Error?u.stack??u.message:u}function l(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return r.setupFormatters(r.formatters),r.enable(r.load()),r}var yn=gl(),ll=["#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 dl(){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 hl(e){if(e[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+e[0]+(this.useColors?"%c ":" ")+"+"+mn(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 pl=console.debug??console.log??(()=>{});function ml(e){try{e?yn?.setItem("debug",e):yn?.removeItem("debug")}catch{}}function yl(){let e;try{e=yn?.getItem("debug")}catch{}return!e&&typeof globalThis.process<"u"&&"env"in globalThis.process&&(e=globalThis.process.env.DEBUG),e}function gl(){try{return localStorage}catch{}}function xl(e){e.j=function(t){try{return JSON.stringify(t)}catch(r){return"[UnexpectedJSONParseError]: "+r.message}}}var ta=Do({formatArgs:hl,save:ml,load:yl,useColors:dl,setupFormatters:xl,colors:ll,storage:yn,log:pl});var _t=ta;_t.formatters.b=e=>e==null?"undefined":Q.baseEncode(e);_t.formatters.t=e=>e==null?"undefined":jt.baseEncode(e);_t.formatters.m=e=>e==null?"undefined":Ro.baseEncode(e);_t.formatters.p=e=>e==null?"undefined":e.toString();_t.formatters.c=e=>e==null?"undefined":e.toString();_t.formatters.k=e=>e==null?"undefined":e.toString();_t.formatters.a=e=>e==null?"undefined":e.toString();_t.formatters.e=e=>e==null?"undefined":ea(e.stack)??ea(e.message)??e.toString();function wl(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 ve(e){let t=wl(`${e}:trace`);return _t.enabled(`${e}:trace`)&&_t.names.map(r=>r.toString()).find(r=>r.includes(":trace"))!=null&&(t=_t(`${e}:trace`)),Object.assign(_t(e),{error:_t(`${e}:error`),trace:t})}function ea(e){if(e!=null&&(e=e.trim(),e.length!==0))return e}var ko={};Bt(ko,{base36:()=>tr,base36upper:()=>bl});var tr=Se({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),bl=Se({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var El=oa,ra=128,Sl=127,vl=~Sl,Al=Math.pow(2,31);function oa(e,t,r){t=t||[],r=r||0;for(var n=r;e>=Al;)t[r++]=e&255|ra,e/=128;for(;e&vl;)t[r++]=e&255|ra,e>>>=7;return t[r]=e|0,oa.bytes=r-n+1,t}var Il=Ko,Tl=128,na=127;function Ko(e,n){var r=0,n=n||0,o=0,i=n,s,c=e.length;do{if(i>=c)throw Ko.bytes=0,new RangeError("Could not decode varint");s=e[i++],r+=o<28?(s&na)<<o:(s&na)*Math.pow(2,o),o+=7}while(s>=Tl);return Ko.bytes=i-n,r}var Cl=Math.pow(2,7),Bl=Math.pow(2,14),Pl=Math.pow(2,21),_l=Math.pow(2,28),Ul=Math.pow(2,35),Nl=Math.pow(2,42),Rl=Math.pow(2,49),Ll=Math.pow(2,56),Dl=Math.pow(2,63),kl=function(e){return e<Cl?1:e<Bl?2:e<Pl?3:e<_l?4:e<Ul?5:e<Nl?6:e<Rl?7:e<Ll?8:e<Dl?9:10},Kl={encode:El,decode:Il,encodingLength:kl},Ol=Kl,Ur=Ol;function Nr(e,t=0){return[Ur.decode(e,t),Ur.decode.bytes]}function er(e,t,r=0){return Ur.encode(e,t,r),t}function rr(e){return Ur.encodingLength(e)}function Gt(e,t){let r=t.byteLength,n=rr(e),o=n+rr(r),i=new Uint8Array(o+r);return er(e,i,0),er(r,i,n),i.set(t,o),new nr(e,r,t,i)}function ue(e){let t=ce(e),[r,n]=Nr(t),[o,i]=Nr(t.subarray(n)),s=t.subarray(n+i);if(s.byteLength!==o)throw new Error("Incorrect length");return new nr(r,o,s,t)}function ia(e,t){if(e===t)return!0;{let r=t;return e.code===r.code&&e.size===r.size&&r.bytes instanceof Uint8Array&&Zs(e.bytes,r.bytes)}}var nr=class{code;size;digest;bytes;constructor(t,r,n,o){this.code=t,this.size=r,this.digest=n,this.bytes=o}};function sa(e,t){let{bytes:r,version:n}=e;switch(n){case 0:return Ml(r,Oo(e),t??Q.encoder);default:return Vl(r,Oo(e),t??jt.encoder)}}var aa=new WeakMap;function Oo(e){let t=aa.get(e);if(t==null){let r=new Map;return aa.set(e,r),r}return t}var Z=class e{code;version;multihash;bytes;"/";constructor(t,r,n,o){this.code=r,this.version=t,this.multihash=n,this.bytes=o,this["/"]=o}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:t,multihash:r}=this;if(t!==Rr)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==ql)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=Gt(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&&ia(t.multihash,n.multihash)}toString(t){return sa(this,t)}toJSON(){return{"/":sa(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??ca(n,o,i.bytes))}else if(r[$l]===!0){let{version:n,multihash:o,code:i}=r,s=ue(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!==Rr)throw new Error(`Version 0 CID must use dag-pb (code: ${Rr}) block encoding`);return new e(t,r,n,n.bytes)}case 1:{let o=ca(t,r,n.bytes);return new e(t,r,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return e.create(0,Rr,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=ce(t.subarray(n,n+r.multihashSize));if(o.byteLength!==r.multihashSize)throw new Error("Incorrect length");let i=o.subarray(r.multihashSize-r.digestSize),s=new nr(r.multihashCode,r.digestSize,i,o);return[r.version===0?e.createV0(s):e.createV1(r.codec,s),t.subarray(r.size)]}static inspectBytes(t){let r=0,n=()=>{let[f,p]=Nr(t.subarray(r));return r+=p,f},o=n(),i=Rr;if(o===18?(o=0,r=0):i=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let s=r,c=n(),a=n(),l=r+a,u=l-s;return{version:o,codec:i,multihashCode:c,digestSize:a,multihashSize:u,size:l}}static parse(t,r){let[n,o]=Fl(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 Fl(e,t){switch(e[0]){case"Q":{let r=t??Q;return[Q.prefix,r.decode(`${Q.prefix}${e}`)]}case Q.prefix:{let r=t??Q;return[Q.prefix,r.decode(e)]}case jt.prefix:{let r=t??jt;return[jt.prefix,r.decode(e)]}case tr.prefix:{let r=t??tr;return[tr.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 Ml(e,t,r){let{prefix:n}=r;if(n!==Q.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 Vl(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 Rr=112,ql=18;function ca(e,t,r){let n=rr(e),o=n+rr(t),i=new Uint8Array(o+r.byteLength);return er(e,i,0),er(t,i,n),i.set(r,o),i}var $l=Symbol.for("@ipld/js-cid/CID");var Fo={};Bt(Fo,{identity:()=>Dt});var ua=0,Hl="identity",fa=ce;function zl(e){return Gt(ua,fa(e))}var Dt={code:ua,name:Hl,encode:fa,digest:zl};function rt(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}function fe(e=0){return new Uint8Array(e)}function Ut(e=0){return new Uint8Array(e)}function bt(e,t){t==null&&(t=e.reduce((o,i)=>o+i.length,0));let r=Ut(t),n=0;for(let o of e)r.set(o,n),n+=o.length;return r}var da=Symbol.for("@achingbrain/uint8arraylist");function la(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 or(e){return!!e?.[da]}var kt=class e{bufs;length;[da]=!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(or(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(or(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=la(this.bufs,t);return r.buf[r.index]}set(t,r){let n=la(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(or(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 bt(n,o)}subarray(t,r){let{bufs:n,length:o}=this._subList(t,r);return n.length===1?n[0]:bt(n,o)}sublist(t,r){let{bufs:n,length:o}=this._subList(t,r),i=new e;return i.length=o,i.bufs=[...n],i}_subList(t,r){if(t=t??0,r=r??this.length,t<0&&(t=this.length+t),r<0&&(r=this.length+r),t<0||r>this.length)throw new RangeError("index is out of bounds");if(t===r)return{bufs:[],length:0};if(t===0&&r===this.length)return{bufs:this.bufs,length:this.length};let n=[],o=0;for(let i=0;i<this.bufs.length;i++){let s=this.bufs[i],c=o,a=c+s.byteLength;if(o=a,t>=a)continue;let l=t>=c&&t<a,u=r>c&&r<=a;if(l&&u){if(t===c&&r===a){n.push(s);break}let f=t-c;n.push(s.subarray(f,f+(r-t)));break}if(l){if(t===0){n.push(s);continue}n.push(s.subarray(t-c));continue}if(u){if(r===a){n.push(s);break}n.push(s.subarray(0,r-c));break}n.push(s)}return{bufs:n,length:r-t}}indexOf(t,r=0){if(!or(t)&&!(t instanceof Uint8Array))throw new TypeError('The "value" argument must be a Uint8ArrayList or Uint8Array');let n=t instanceof Uint8Array?t:t.subarray();if(r=Number(r??0),isNaN(r)&&(r=0),r<0&&(r=this.length+r),r<0&&(r=0),t.length===0)return r>this.length?this.length:r;let o=n.byteLength;if(o===0)throw new TypeError("search must be at least 1 byte long");let i=256,s=new Int32Array(i);for(let f=0;f<i;f++)s[f]=-1;for(let f=0;f<o;f++)s[n[f]]=f;let c=s,a=this.byteLength-n.byteLength,l=n.byteLength-1,u;for(let f=r;f<=a;f+=u){u=0;for(let p=l;p>=0;p--){let S=this.get(f+p);if(n[p]!==S){u=Math.max(1,p-c[S]);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=Ut(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setInt8(0,r),this.write(n,t)}getInt16(t,r){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt16(0,r)}setInt16(t,r,n){let o=fe(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt16(0,r,n),this.write(o,t)}getInt32(t,r){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt32(0,r)}setInt32(t,r,n){let o=fe(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt32(0,r,n),this.write(o,t)}getBigInt64(t,r){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigInt64(0,r)}setBigInt64(t,r,n){let o=fe(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigInt64(0,r,n),this.write(o,t)}getUint8(t){let r=this.subarray(t,t+1);return new DataView(r.buffer,r.byteOffset,r.byteLength).getUint8(0)}setUint8(t,r){let n=Ut(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setUint8(0,r),this.write(n,t)}getUint16(t,r){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint16(0,r)}setUint16(t,r,n){let o=fe(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint16(0,r,n),this.write(o,t)}getUint32(t,r){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint32(0,r)}setUint32(t,r,n){let o=fe(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint32(0,r,n),this.write(o,t)}getBigUint64(t,r){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigUint64(0,r)}setBigUint64(t,r,n){let o=fe(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigUint64(0,r,n),this.write(o,t)}getFloat32(t,r){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat32(0,r)}setFloat32(t,r,n){let o=fe(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat32(0,r,n),this.write(o,t)}getFloat64(t,r){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat64(0,r)}setFloat64(t,r,n){let o=fe(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat64(0,r,n),this.write(o,t)}equals(t){if(t==null||!(t instanceof e)||t.bufs.length!==this.bufs.length)return!1;for(let r=0;r<this.bufs.length;r++)if(!rt(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 Mo={};Bt(Mo,{base10:()=>jl});var jl=Se({prefix:"9",name:"base10",alphabet:"0123456789"});var Vo={};Bt(Vo,{base16:()=>Gl,base16upper:()=>Zl});var Gl=it({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Zl=it({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var qo={};Bt(qo,{base2:()=>Yl});var Yl=it({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var $o={};Bt($o,{base256emoji:()=>td});var ha=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}"),Wl=ha.reduce((e,t,r)=>(e[r]=t,e),[]),Xl=ha.reduce((e,t,r)=>{let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);return e[n]=r,e},[]);function Jl(e){return e.reduce((t,r)=>(t+=Wl[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=Xl[n];if(o==null)throw new Error(`Non-base256emoji character: ${r}`);t.push(o)}return new Uint8Array(t)}var td=Qe({prefix:"\u{1F680}",name:"base256emoji",encode:Jl,decode:Ql});var Ho={};Bt(Ho,{base8:()=>ed});var ed=it({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var zo={};Bt(zo,{identity:()=>rd});var rd=Qe({prefix:"\0",name:"identity",encode:e=>Ws(e),decode:e=>Ys(e)});var om=new TextEncoder,im=new TextDecoder;var Zo={};Bt(Zo,{sha256:()=>Lr,sha512:()=>id});function Go({name:e,code:t,encode:r}){return new jo(e,t,r)}var jo=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?Gt(this.code,r):r.then(n=>Gt(this.code,n))}else throw Error("Unknown type, must be binary type")}};function ma(e){return async t=>new Uint8Array(await crypto.subtle.digest(e,t))}var Lr=Go({name:"sha2-256",code:18,encode:ma("SHA-256")}),id=Go({name:"sha2-512",code:19,encode:ma("SHA-512")});var Dr={...zo,...qo,...Ho,...Mo,...Vo,...Uo,...ko,...No,...Lo,...$o},gm={...Zo,...Fo};function ga(e,t,r,n){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:n}}}var ya=ga("utf8","u",e=>"u"+new TextDecoder("utf8").decode(e),e=>new TextEncoder().encode(e.substring(1))),Yo=ga("ascii","a",e=>{let t="a";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return t},e=>{e=e.substring(1);let t=Ut(e.length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t}),sd={utf8:ya,"utf-8":ya,hex:Dr.base16,latin1:Yo,ascii:Yo,binary:Yo,...Dr},xn=sd;function H(e,t="utf8"){let r=xn[t];if(r==null)throw new Error(`Unsupported encoding "${t}"`);return r.decoder.decode(`${r.prefix}${e}`)}function q(e,t="utf8"){let r=xn[t];if(r==null)throw new Error(`Unsupported encoding "${t}"`);return r.encoder.encode(e).substring(1)}var ad=parseInt("11111",2),Wo=parseInt("10000000",2),cd=parseInt("01111111",2),xa={0:kr,1:kr,2:ud,3:dd,4:hd,5:ld,6:fd,16:kr,22:kr,48:kr};function le(e,t={offset:0}){let r=e[t.offset]&ad;if(t.offset++,xa[r]!=null)return xa[r](e,t);throw new Error("No decoder for tag "+r)}function Kr(e,t){let r=0;if((e[t.offset]&Wo)===Wo){let n=e[t.offset]&cd,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 kr(e,t){Kr(e,t);let r=[];for(;!(t.offset>=e.byteLength);){let n=le(e,t);if(n===null)break;r.push(n)}return r}function ud(e,t){let r=Kr(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 fd(e,t){let r=Kr(e,t),n=t.offset+r,o=e[t.offset];t.offset++;let i=0,s=0;o<40?(i=0,s=o):o<80?(i=1,s=o-40):(i=2,s=o-80);let c=`${i}.${s}`,a=[];for(;t.offset<n;){let l=e[t.offset];if(t.offset++,a.push(l&127),l<128){a.reverse();let u=0;for(let f=0;f<a.length;f++)u+=a[f]<<f*7;c+=`.${u}`,a=[]}}return c}function ld(e,t){return t.offset++,null}function dd(e,t){let r=Kr(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 hd(e,t){let r=Kr(e,t),n=e.subarray(t.offset,t.offset+r);return t.offset+=r,n}function pd(e){let t=e.toString(16);t.length%2===1&&(t="0"+t);let r=new kt;for(let n=0;n<t.length;n+=2)r.append(Uint8Array.from([parseInt(`${t[n]}${t[n+1]}`,16)]));return r}function Xo(e){if(e.byteLength<128)return Uint8Array.from([e.byteLength]);let t=pd(e.byteLength);return new kt(Uint8Array.from([t.byteLength|Wo]),t)}function Nt(e){let t=new kt,r=128;return(e.subarray()[0]&r)===r&&t.append(Uint8Array.from([0])),t.append(e),new kt(Uint8Array.from([2]),Xo(t),t)}function wn(e){let t=Uint8Array.from([0]),r=new kt(t,e);return new kt(Uint8Array.from([3]),Xo(r),r)}function Ie(e,t=48){let r=new kt;for(let n of e)r.append(n);return new kt(Uint8Array.from([t]),Xo(r),r)}async function wa(e,t,r){let n=await crypto.subtle.importKey("jwk",e,{name:"ECDSA",namedCurve:e.crv??"P-256"},!1,["verify"]);return crypto.subtle.verify({name:"ECDSA",hash:{name:"SHA-256"}},n,t,r.subarray())}var md=Uint8Array.from([6,8,42,134,72,206,61,3,1,7]),yd=Uint8Array.from([6,5,43,129,4,0,34]),gd=Uint8Array.from([6,5,43,129,4,0,35]),xd={ext:!0,kty:"EC",crv:"P-256"},wd={ext:!0,kty:"EC",crv:"P-384"},bd={ext:!0,kty:"EC",crv:"P-521"},Jo=32,Qo=48,ti=66;function ei(e){let t=le(e);return ba(t)}function ba(e){let t=e[1][1][0],r=1,n,o;if(t.byteLength===Jo*2+1)return n=q(t.subarray(r,r+Jo),"base64url"),o=q(t.subarray(r+Jo),"base64url"),new ir({...xd,key_ops:["verify"],x:n,y:o});if(t.byteLength===Qo*2+1)return n=q(t.subarray(r,r+Qo),"base64url"),o=q(t.subarray(r+Qo),"base64url"),new ir({...wd,key_ops:["verify"],x:n,y:o});if(t.byteLength===ti*2+1)return n=q(t.subarray(r,r+ti),"base64url"),o=q(t.subarray(r+ti),"base64url"),new ir({...bd,key_ops:["verify"],x:n,y:o});throw new ut(`coordinates were wrong length, got ${t.byteLength}, expected 65, 97 or 133`)}function Ea(e){return Ie([Nt(Uint8Array.from([1])),Ie([Ed(e.crv)],160),Ie([wn(new kt(Uint8Array.from([4]),H(e.x??"","base64url"),H(e.y??"","base64url")))],161)]).subarray()}function Ed(e){if(e==="P-256")return md;if(e==="P-384")return yd;if(e==="P-521")return gd;throw new ut(`Invalid curve ${e}`)}var ir=class{type="ECDSA";jwk;_raw;constructor(t){this.jwk=t}get raw(){return this._raw==null&&(this._raw=Ea(this.jwk)),this._raw}toMultihash(){return Dt.digest(sr(this))}toCID(){return Z.createV1(114,this.toMultihash())}toString(){return Q.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:rt(this.raw,t.raw)}async verify(t,r){return wa(this.jwk,r,t)}};var ke=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function Sd(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function bn(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function Ke(e,...t){if(!Sd(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 Sa(e){if(typeof e!="function"||typeof e.create!="function")throw new Error("Hash should be wrapped by utils.createHasher");bn(e.outputLen),bn(e.blockLen)}function cr(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function va(e,t){Ke(e);let r=t.outputLen;if(e.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}function de(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function En(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function Zt(e,t){return e<<32-t|e>>>t}function Aa(e){if(typeof e!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(e))}function Or(e){return typeof e=="string"&&(e=Aa(e)),Ke(e),e}function ri(...e){let t=0;for(let n=0;n<e.length;n++){let o=e[n];Ke(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 ar=class{};function ni(e){let t=n=>e().update(Or(n)).digest(),r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>e(),t}function Sn(e=32){if(ke&&typeof ke.getRandomValues=="function")return ke.getRandomValues(new Uint8Array(e));if(ke&&typeof ke.randomBytes=="function")return Uint8Array.from(ke.randomBytes(e));throw new Error("crypto.getRandomValues must be defined")}function vd(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),c=Number(r&i),a=n?4:0,l=n?0:4;e.setUint32(t+a,s,n),e.setUint32(t+l,c,n)}function Ia(e,t,r){return e&t^~e&r}function Ta(e,t,r){return e&t^e&r^t&r}var Fr=class extends ar{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=En(this.buffer)}update(t){cr(this),t=Or(t),Ke(t);let{view:r,buffer:n,blockLen:o}=this,i=t.length;for(let s=0;s<i;){let c=Math.min(o-this.pos,i-s);if(c===o){let a=En(t);for(;o<=i-s;s+=o)this.process(a,s);continue}n.set(t.subarray(s,s+c),this.pos),this.pos+=c,s+=c,this.pos===o&&(this.process(r,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){cr(this),va(t,this),this.finished=!0;let{buffer:r,view:n,blockLen:o,isLE:i}=this,{pos:s}=this;r[s++]=128,de(this.buffer.subarray(s)),this.padOffset>o-s&&(this.process(n,0),s=0);for(let f=s;f<o;f++)r[f]=0;vd(n,o-8,BigInt(this.length*8),i),this.process(n,0);let c=En(t),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let l=a/4,u=this.get();if(l>u.length)throw new Error("_sha2: outputLen bigger than state");for(let f=0;f<l;f++)c.setUint32(4*f,u[f],i)}digest(){let{buffer:t,outputLen:r}=this;this.digestInto(t);let n=t.slice(0,r);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());let{blockLen:r,buffer:n,length:o,finished:i,destroyed:s,pos:c}=this;return t.destroyed=s,t.finished=i,t.length=o,t.pos=c,o%r&&t.buffer.set(n),t}clone(){return this._cloneInto()}},he=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var yt=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]);var vn=BigInt(4294967295),Ca=BigInt(32);function Ad(e,t=!1){return t?{h:Number(e&vn),l:Number(e>>Ca&vn)}:{h:Number(e>>Ca&vn)|0,l:Number(e&vn)|0}}function Ba(e,t=!1){let r=e.length,n=new Uint32Array(r),o=new Uint32Array(r);for(let i=0;i<r;i++){let{h:s,l:c}=Ad(e[i],t);[n[i],o[i]]=[s,c]}return[n,o]}var oi=(e,t,r)=>e>>>r,ii=(e,t,r)=>e<<32-r|t>>>r,Oe=(e,t,r)=>e>>>r|t<<32-r,Fe=(e,t,r)=>e<<32-r|t>>>r,Mr=(e,t,r)=>e<<64-r|t>>>r-32,Vr=(e,t,r)=>e>>>r-32|t<<64-r;function re(e,t,r,n){let o=(t>>>0)+(n>>>0);return{h:e+r+(o/2**32|0)|0,l:o|0}}var Pa=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0),_a=(e,t,r,n)=>t+r+n+(e/2**32|0)|0,Ua=(e,t,r,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0),Na=(e,t,r,n,o)=>t+r+n+o+(e/2**32|0)|0,Ra=(e,t,r,n,o)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0)+(o>>>0),La=(e,t,r,n,o,i)=>t+r+n+o+i+(e/2**32|0)|0;var Td=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]),Te=new Uint32Array(64),An=class extends Fr{constructor(t=32){super(64,t,8,!1),this.A=he[0]|0,this.B=he[1]|0,this.C=he[2]|0,this.D=he[3]|0,this.E=he[4]|0,this.F=he[5]|0,this.G=he[6]|0,this.H=he[7]|0}get(){let{A:t,B:r,C:n,D:o,E:i,F:s,G:c,H:a}=this;return[t,r,n,o,i,s,c,a]}set(t,r,n,o,i,s,c,a){this.A=t|0,this.B=r|0,this.C=n|0,this.D=o|0,this.E=i|0,this.F=s|0,this.G=c|0,this.H=a|0}process(t,r){for(let f=0;f<16;f++,r+=4)Te[f]=t.getUint32(r,!1);for(let f=16;f<64;f++){let p=Te[f-15],S=Te[f-2],_=Zt(p,7)^Zt(p,18)^p>>>3,y=Zt(S,17)^Zt(S,19)^S>>>10;Te[f]=y+Te[f-7]+_+Te[f-16]|0}let{A:n,B:o,C:i,D:s,E:c,F:a,G:l,H:u}=this;for(let f=0;f<64;f++){let p=Zt(c,6)^Zt(c,11)^Zt(c,25),S=u+p+Ia(c,a,l)+Td[f]+Te[f]|0,y=(Zt(n,2)^Zt(n,13)^Zt(n,22))+Ta(n,o,i)|0;u=l,l=a,a=c,c=s+S|0,s=i,i=o,o=n,n=S+y|0}n=n+this.A|0,o=o+this.B|0,i=i+this.C|0,s=s+this.D|0,c=c+this.E|0,a=a+this.F|0,l=l+this.G|0,u=u+this.H|0,this.set(n,o,i,s,c,a,l,u)}roundClean(){de(Te)}destroy(){this.set(0,0,0,0,0,0,0,0),de(this.buffer)}};var Da=Ba(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(e=>BigInt(e))),Cd=Da[0],Bd=Da[1],Ce=new Uint32Array(80),Be=new Uint32Array(80),si=class extends Fr{constructor(t=64){super(128,t,16,!1),this.Ah=yt[0]|0,this.Al=yt[1]|0,this.Bh=yt[2]|0,this.Bl=yt[3]|0,this.Ch=yt[4]|0,this.Cl=yt[5]|0,this.Dh=yt[6]|0,this.Dl=yt[7]|0,this.Eh=yt[8]|0,this.El=yt[9]|0,this.Fh=yt[10]|0,this.Fl=yt[11]|0,this.Gh=yt[12]|0,this.Gl=yt[13]|0,this.Hh=yt[14]|0,this.Hl=yt[15]|0}get(){let{Ah:t,Al:r,Bh:n,Bl:o,Ch:i,Cl:s,Dh:c,Dl:a,Eh:l,El:u,Fh:f,Fl:p,Gh:S,Gl:_,Hh:y,Hl:k}=this;return[t,r,n,o,i,s,c,a,l,u,f,p,S,_,y,k]}set(t,r,n,o,i,s,c,a,l,u,f,p,S,_,y,k){this.Ah=t|0,this.Al=r|0,this.Bh=n|0,this.Bl=o|0,this.Ch=i|0,this.Cl=s|0,this.Dh=c|0,this.Dl=a|0,this.Eh=l|0,this.El=u|0,this.Fh=f|0,this.Fl=p|0,this.Gh=S|0,this.Gl=_|0,this.Hh=y|0,this.Hl=k|0}process(t,r){for(let T=0;T<16;T++,r+=4)Ce[T]=t.getUint32(r),Be[T]=t.getUint32(r+=4);for(let T=16;T<80;T++){let d=Ce[T-15]|0,v=Be[T-15]|0,N=Oe(d,v,1)^Oe(d,v,8)^oi(d,v,7),L=Fe(d,v,1)^Fe(d,v,8)^ii(d,v,7),g=Ce[T-2]|0,A=Be[T-2]|0,R=Oe(g,A,19)^Mr(g,A,61)^oi(g,A,6),I=Fe(g,A,19)^Vr(g,A,61)^ii(g,A,6),C=Ua(L,I,Be[T-7],Be[T-16]),U=Na(C,N,R,Ce[T-7],Ce[T-16]);Ce[T]=U|0,Be[T]=C|0}let{Ah:n,Al:o,Bh:i,Bl:s,Ch:c,Cl:a,Dh:l,Dl:u,Eh:f,El:p,Fh:S,Fl:_,Gh:y,Gl:k,Hh:O,Hl:z}=this;for(let T=0;T<80;T++){let d=Oe(f,p,14)^Oe(f,p,18)^Mr(f,p,41),v=Fe(f,p,14)^Fe(f,p,18)^Vr(f,p,41),N=f&S^~f&y,L=p&_^~p&k,g=Ra(z,v,L,Bd[T],Be[T]),A=La(g,O,d,N,Cd[T],Ce[T]),R=g|0,I=Oe(n,o,28)^Mr(n,o,34)^Mr(n,o,39),C=Fe(n,o,28)^Vr(n,o,34)^Vr(n,o,39),U=n&i^n&c^i&c,$=o&s^o&a^s&a;O=y|0,z=k|0,y=S|0,k=_|0,S=f|0,_=p|0,{h:f,l:p}=re(l|0,u|0,A|0,R|0),l=c|0,u=a|0,c=i|0,a=s|0,i=n|0,s=o|0;let x=Pa(R,C,$);n=_a(x,A,I,U),o=x|0}({h:n,l:o}=re(this.Ah|0,this.Al|0,n|0,o|0)),{h:i,l:s}=re(this.Bh|0,this.Bl|0,i|0,s|0),{h:c,l:a}=re(this.Ch|0,this.Cl|0,c|0,a|0),{h:l,l:u}=re(this.Dh|0,this.Dl|0,l|0,u|0),{h:f,l:p}=re(this.Eh|0,this.El|0,f|0,p|0),{h:S,l:_}=re(this.Fh|0,this.Fl|0,S|0,_|0),{h:y,l:k}=re(this.Gh|0,this.Gl|0,y|0,k|0),{h:O,l:z}=re(this.Hh|0,this.Hl|0,O|0,z|0),this.set(n,o,i,s,c,a,l,u,f,p,S,_,y,k,O,z)}roundClean(){de(Ce,Be)}destroy(){de(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};var In=ni(()=>new An);var ka=ni(()=>new si);var fi=BigInt(0),ui=BigInt(1);function ur(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function li(e){if(!ur(e))throw new Error("Uint8Array expected")}function ne(e,t){if(typeof t!="boolean")throw new Error(e+" boolean expected, got "+t)}function qr(e){let t=e.toString(16);return t.length&1?"0"+t:t}function Fa(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);return e===""?fi:BigInt("0x"+e)}var Ma=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",Pd=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Pe(e){if(li(e),Ma)return e.toHex();let t="";for(let r=0;r<e.length;r++)t+=Pd[e[r]];return t}var pe={_0:48,_9:57,A:65,F:70,a:97,f:102};function Ka(e){if(e>=pe._0&&e<=pe._9)return e-pe._0;if(e>=pe.A&&e<=pe.F)return e-(pe.A-10);if(e>=pe.a&&e<=pe.f)return e-(pe.a-10)}function $r(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);if(Ma)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=Ka(e.charCodeAt(i)),c=Ka(e.charCodeAt(i+1));if(s===void 0||c===void 0){let a=e[i]+e[i+1];throw new Error('hex string expected, got non-hex character "'+a+'" at index '+i)}n[o]=s*16+c}return n}function me(e){return Fa(Pe(e))}function Me(e){return li(e),Fa(Pe(Uint8Array.from(e).reverse()))}function Ve(e,t){return $r(e.toString(16).padStart(t*2,"0"))}function fr(e,t){return Ve(e,t).reverse()}function nt(e,t,r){let n;if(typeof t=="string")try{n=$r(t)}catch(i){throw new Error(e+" must be hex string or Uint8Array, cause: "+i)}else if(ur(t))n=Uint8Array.from(t);else throw new Error(e+" must be hex string or Uint8Array");let o=n.length;if(typeof r=="number"&&o!==r)throw new Error(e+" of length "+r+" expected, got "+o);return n}function _e(...e){let t=0;for(let n=0;n<e.length;n++){let o=e[n];li(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 ai=e=>typeof e=="bigint"&&fi<=e;function Tn(e,t,r){return ai(e)&&ai(t)&&ai(r)&&t<=e&&e<r}function Kt(e,t,r,n){if(!Tn(t,r,n))throw new Error("expected valid "+e+": "+r+" <= n < "+n+", got "+t)}function Va(e){let t;for(t=0;e>fi;e>>=ui,t+=1);return t}var qe=e=>(ui<<BigInt(e))-ui,ci=e=>new Uint8Array(e),Oa=e=>Uint8Array.from(e);function qa(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=ci(e),o=ci(e),i=0,s=()=>{n.fill(1),o.fill(0),i=0},c=(...f)=>r(o,n,...f),a=(f=ci(0))=>{o=c(Oa([0]),f),n=c(),f.length!==0&&(o=c(Oa([1]),f),n=c())},l=()=>{if(i++>=1e3)throw new Error("drbg: tried 1000 values");let f=0,p=[];for(;f<t;){n=c();let S=n.slice();p.push(S),f+=n.length}return _e(...p)};return(f,p)=>{s(),a(f);let S;for(;!(S=p(l()));)a();return s(),S}}var _d={bigint:e=>typeof e=="bigint",function:e=>typeof e=="function",boolean:e=>typeof e=="boolean",string:e=>typeof e=="string",stringOrUint8Array:e=>typeof e=="string"||ur(e),isSafeInteger:e=>Number.isSafeInteger(e),array:e=>Array.isArray(e),field:(e,t)=>t.Fp.isValid(e),hash:e=>typeof e=="function"&&Number.isSafeInteger(e.outputLen)};function ye(e,t,r={}){let n=(o,i,s)=>{let c=_d[i];if(typeof c!="function")throw new Error("invalid validator function");let a=e[o];if(!(s&&a===void 0)&&!c(a,e))throw new Error("param "+String(o)+" is invalid. Expected "+i+", got "+a)};for(let[o,i]of Object.entries(t))n(o,i,!1);for(let[o,i]of Object.entries(r))n(o,i,!0);return e}function lr(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 At=BigInt(0),dt=BigInt(1),$e=BigInt(2),Ud=BigInt(3),Ha=BigInt(4),za=BigInt(5),ja=BigInt(8);function tt(e,t){let r=e%t;return r>=At?r:t+r}function ot(e,t,r){let n=e;for(;t-- >At;)n*=n,n%=r;return n}function Cn(e,t){if(e===At)throw new Error("invert: expected non-zero number");if(t<=At)throw new Error("invert: expected positive modulus, got "+t);let r=tt(e,t),n=t,o=At,i=dt,s=dt,c=At;for(;r!==At;){let l=n/r,u=n%r,f=o-s*l,p=i-c*l;n=r,r=u,o=s,i=c,s=f,c=p}if(n!==dt)throw new Error("invert: does not exist");return tt(o,t)}function Ga(e,t){let r=(e.ORDER+dt)/Ha,n=e.pow(t,r);if(!e.eql(e.sqr(n),t))throw new Error("Cannot find square root");return n}function Nd(e,t){let r=(e.ORDER-za)/ja,n=e.mul(t,$e),o=e.pow(n,r),i=e.mul(t,o),s=e.mul(e.mul(i,$e),o),c=e.mul(i,e.sub(s,e.ONE));if(!e.eql(e.sqr(c),t))throw new Error("Cannot find square root");return c}function Rd(e){if(e<BigInt(3))throw new Error("sqrt is not defined for small field");let t=e-dt,r=0;for(;t%$e===At;)t/=$e,r++;let n=$e,o=ge(e);for(;$a(o,n)===1;)if(n++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(r===1)return Ga;let i=o.pow(n,t),s=(t+dt)/$e;return function(a,l){if(a.is0(l))return l;if($a(a,l)!==1)throw new Error("Cannot find square root");let u=r,f=a.mul(a.ONE,i),p=a.pow(l,t),S=a.pow(l,s);for(;!a.eql(p,a.ONE);){if(a.is0(p))return a.ZERO;let _=1,y=a.sqr(p);for(;!a.eql(y,a.ONE);)if(_++,y=a.sqr(y),_===u)throw new Error("Cannot find square root");let k=dt<<BigInt(u-_-1),O=a.pow(f,k);u=_,f=a.sqr(O),p=a.mul(p,f),S=a.mul(S,O)}return S}}function Ld(e){return e%Ha===Ud?Ga:e%ja===za?Nd:Rd(e)}var Za=(e,t)=>(tt(e,t)&dt)===dt,Dd=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function di(e){let t={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},r=Dd.reduce((n,o)=>(n[o]="function",n),t);return ye(e,r)}function kd(e,t,r){if(r<At)throw new Error("invalid exponent, negatives unsupported");if(r===At)return e.ONE;if(r===dt)return t;let n=e.ONE,o=t;for(;r>At;)r&dt&&(n=e.mul(n,o)),o=e.sqr(o),r>>=dt;return n}function dr(e,t,r=!1){let n=new Array(t.length).fill(r?e.ZERO:void 0),o=t.reduce((s,c,a)=>e.is0(c)?s:(n[a]=s,e.mul(s,c)),e.ONE),i=e.inv(o);return t.reduceRight((s,c,a)=>e.is0(c)?s:(n[a]=e.mul(s,n[a]),e.mul(s,c)),i),n}function $a(e,t){let r=(e.ORDER-dt)/$e,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 hi(e,t){t!==void 0&&bn(t);let r=t!==void 0?t:e.toString(2).length,n=Math.ceil(r/8);return{nBitLength:r,nByteLength:n}}function ge(e,t,r=!1,n={}){if(e<=At)throw new Error("invalid field: expected ORDER > 0, got "+e);let{nBitLength:o,nByteLength:i}=hi(e,t);if(i>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let s,c=Object.freeze({ORDER:e,isLE:r,BITS:o,BYTES:i,MASK:qe(o),ZERO:At,ONE:dt,create:a=>tt(a,e),isValid:a=>{if(typeof a!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof a);return At<=a&&a<e},is0:a=>a===At,isOdd:a=>(a&dt)===dt,neg:a=>tt(-a,e),eql:(a,l)=>a===l,sqr:a=>tt(a*a,e),add:(a,l)=>tt(a+l,e),sub:(a,l)=>tt(a-l,e),mul:(a,l)=>tt(a*l,e),pow:(a,l)=>kd(c,a,l),div:(a,l)=>tt(a*Cn(l,e),e),sqrN:a=>a*a,addN:(a,l)=>a+l,subN:(a,l)=>a-l,mulN:(a,l)=>a*l,inv:a=>Cn(a,e),sqrt:n.sqrt||(a=>(s||(s=Ld(e)),s(c,a))),toBytes:a=>r?fr(a,i):Ve(a,i),fromBytes:a=>{if(a.length!==i)throw new Error("Field.fromBytes: expected "+i+" bytes, got "+a.length);return r?Me(a):me(a)},invertBatch:a=>dr(c,a),cmov:(a,l,u)=>u?l:a});return Object.freeze(c)}function Ya(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 pi(e){let t=Ya(e);return t+Math.ceil(t/2)}function Wa(e,t,r=!1){let n=e.length,o=Ya(t),i=pi(t);if(n<16||n<i||n>1024)throw new Error("expected "+i+"-1024 bytes of input, got "+n);let s=r?Me(e):me(e),c=tt(s,t-dt)+dt;return r?fr(c,o):Ve(c,o)}var Xa=BigInt(0),wi=BigInt(1);function mi(e,t){let r=t.negate();return e?r:t}function Qa(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+e)}function yi(e,t){Qa(e,t);let r=Math.ceil(t/e)+1,n=2**(e-1),o=2**e,i=qe(e),s=BigInt(e);return{windows:r,windowSize:n,mask:i,maxNumber:o,shiftBy:s}}function Ja(e,t,r){let{windowSize:n,mask:o,maxNumber:i,shiftBy:s}=r,c=Number(e&o),a=e>>s;c>n&&(c-=i,a+=wi);let l=t*n,u=l+Math.abs(c)-1,f=c===0,p=c<0,S=t%2!==0;return{nextN:a,offset:u,isZero:f,isNeg:p,isNegF:S,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 Od(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 gi=new WeakMap,tc=new WeakMap;function xi(e){return tc.get(e)||1}function Bn(e,t){return{constTimeNegate:mi,hasPrecomputes(r){return xi(r)!==1},unsafeLadder(r,n,o=e.ZERO){let i=r;for(;n>Xa;)n&wi&&(o=o.add(i)),i=i.double(),n>>=wi;return o},precomputeWindow(r,n){let{windows:o,windowSize:i}=yi(n,t),s=[],c=r,a=c;for(let l=0;l<o;l++){a=c,s.push(a);for(let u=1;u<i;u++)a=a.add(c),s.push(a);c=a.double()}return s},wNAF(r,n,o){let i=e.ZERO,s=e.BASE,c=yi(r,t);for(let a=0;a<c.windows;a++){let{nextN:l,offset:u,isZero:f,isNeg:p,isNegF:S,offsetF:_}=Ja(o,a,c);o=l,f?s=s.add(mi(S,n[_])):i=i.add(mi(p,n[u]))}return{p:i,f:s}},wNAFUnsafe(r,n,o,i=e.ZERO){let s=yi(r,t);for(let c=0;c<s.windows&&o!==Xa;c++){let{nextN:a,offset:l,isZero:u,isNeg:f}=Ja(o,c,s);if(o=a,!u){let p=n[l];i=i.add(f?p.negate():p)}}return i},getPrecomputes(r,n,o){let i=gi.get(n);return i||(i=this.precomputeWindow(n,r),r!==1&&gi.set(n,o(i))),i},wNAFCached(r,n,o){let i=xi(r);return this.wNAF(i,this.getPrecomputes(i,r,o),n)},wNAFCachedUnsafe(r,n,o,i){let s=xi(r);return s===1?this.unsafeLadder(r,n,i):this.wNAFUnsafe(s,this.getPrecomputes(s,r,o),n,i)},setWindowSize(r,n){Qa(n,t),tc.set(r,n),gi.delete(r)}}}function Pn(e,t,r,n){Kd(r,e),Od(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,c=Va(BigInt(o)),a=1;c>12?a=c-3:c>4?a=c-2:c>0&&(a=2);let l=qe(a),u=new Array(Number(l)+1).fill(s),f=Math.floor((t.BITS-1)/a)*a,p=s;for(let S=f;S>=0;S-=a){u.fill(s);for(let y=0;y<i;y++){let k=n[y],O=Number(k>>BigInt(S)&l);u[O]=u[O].add(r[y])}let _=s;for(let y=u.length-1,k=s;y>0;y--)k=k.add(u[y]),_=_.add(k);if(p=p.add(_),S!==0)for(let y=0;y<a;y++)p=p.double()}return p}function Hr(e){return di(e.Fp),ye(e,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...hi(e.n,e.nBitLength),...e,p:e.Fp.ORDER})}var oe=BigInt(0),It=BigInt(1),ec=BigInt(2),Fd=BigInt(8),Md={zip215:!0};function Vd(e){let t=Hr(e);return ye(e,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...t})}function rc(e){let t=Vd(e),{Fp:r,n,prehash:o,hash:i,randomBytes:s,nByteLength:c,h:a}=t,l=ec<<BigInt(c*8)-It,u=r.create,f=ge(t.n,t.nBitLength);function p(E,h){let b=r.sqr(E),B=r.sqr(h),F=r.add(r.mul(t.a,b),B),V=r.add(r.ONE,r.mul(t.d,r.mul(b,B)));return r.eql(F,V)}if(!p(t.Gx,t.Gy))throw new Error("bad curve params: generator point");let S=t.uvRatio||((E,h)=>{try{return{isValid:!0,value:r.sqrt(E*r.inv(h))}}catch{return{isValid:!1,value:oe}}}),_=t.adjustScalarBytes||(E=>E),y=t.domain||((E,h,b)=>{if(ne("phflag",b),h.length||b)throw new Error("Contexts/pre-hash are not supported");return E});function k(E,h,b=!1){let B=b?It:oe;Kt("coordinate "+E,h,B,l)}function O(E){if(!(E instanceof d))throw new Error("ExtendedPoint expected")}let z=lr((E,h)=>{let{ex:b,ey:B,ez:F}=E,V=E.is0();h==null&&(h=V?Fd:r.inv(F));let j=u(b*h),G=u(B*h),W=u(F*h);if(V)return{x:oe,y:It};if(W!==It)throw new Error("invZ was invalid");return{x:j,y:G}}),T=lr(E=>{let{a:h,d:b}=t;if(E.is0())throw new Error("bad point: ZERO");let{ex:B,ey:F,ez:V,et:j}=E,G=u(B*B),W=u(F*F),J=u(V*V),ct=u(J*J),st=u(G*h),mt=u(J*u(st+W)),Ct=u(ct+u(b*u(G*W)));if(mt!==Ct)throw new Error("bad point: equation left != right (1)");let lt=u(B*F),wt=u(V*j);if(lt!==wt)throw new Error("bad point: equation left != right (2)");return!0});class d{constructor(h,b,B,F){k("x",h),k("y",b),k("z",B,!0),k("t",F),this.ex=h,this.ey=b,this.ez=B,this.et=F,Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(h){if(h instanceof d)throw new Error("extended point not allowed");let{x:b,y:B}=h||{};return k("x",b),k("y",B),new d(b,B,It,u(b*B))}static normalizeZ(h){let b=dr(r,h.map(B=>B.ez));return h.map((B,F)=>B.toAffine(b[F])).map(d.fromAffine)}static msm(h,b){return Pn(d,f,h,b)}_setWindowSize(h){L.setWindowSize(this,h)}assertValidity(){T(this)}equals(h){O(h);let{ex:b,ey:B,ez:F}=this,{ex:V,ey:j,ez:G}=h,W=u(b*G),J=u(V*F),ct=u(B*G),st=u(j*F);return W===J&&ct===st}is0(){return this.equals(d.ZERO)}negate(){return new d(u(-this.ex),this.ey,this.ez,u(-this.et))}double(){let{a:h}=t,{ex:b,ey:B,ez:F}=this,V=u(b*b),j=u(B*B),G=u(ec*u(F*F)),W=u(h*V),J=b+B,ct=u(u(J*J)-V-j),st=W+j,mt=st-G,Ct=W-j,lt=u(ct*mt),wt=u(st*Ct),Lt=u(ct*Ct),zt=u(mt*st);return new d(lt,wt,zt,Lt)}add(h){O(h);let{a:b,d:B}=t,{ex:F,ey:V,ez:j,et:G}=this,{ex:W,ey:J,ez:ct,et:st}=h,mt=u(F*W),Ct=u(V*J),lt=u(G*B*st),wt=u(j*ct),Lt=u((F+V)*(W+J)-mt-Ct),zt=wt-lt,_r=wt+lt,$s=u(Ct-b*mt),Nf=u(Lt*zt),Rf=u(_r*$s),Lf=u(Lt*$s),Df=u(zt*_r);return new d(Nf,Rf,Df,Lf)}subtract(h){return this.add(h.negate())}wNAF(h){return L.wNAFCached(this,h,d.normalizeZ)}multiply(h){let b=h;Kt("scalar",b,It,n);let{p:B,f:F}=this.wNAF(b);return d.normalizeZ([B,F])[0]}multiplyUnsafe(h,b=d.ZERO){let B=h;return Kt("scalar",B,oe,n),B===oe?N:this.is0()||B===It?this:L.wNAFCachedUnsafe(this,B,d.normalizeZ,b)}isSmallOrder(){return this.multiplyUnsafe(a).is0()}isTorsionFree(){return L.unsafeLadder(this,n).is0()}toAffine(h){return z(this,h)}clearCofactor(){let{h}=t;return h===It?this:this.multiplyUnsafe(h)}static fromHex(h,b=!1){let{d:B,a:F}=t,V=r.BYTES;h=nt("pointHex",h,V),ne("zip215",b);let j=h.slice(),G=h[V-1];j[V-1]=G&-129;let W=Me(j),J=b?l:r.ORDER;Kt("pointHex.y",W,oe,J);let ct=u(W*W),st=u(ct-It),mt=u(B*ct-F),{isValid:Ct,value:lt}=S(st,mt);if(!Ct)throw new Error("Point.fromHex: invalid y coordinate");let wt=(lt&It)===It,Lt=(G&128)!==0;if(!b&&lt===oe&&Lt)throw new Error("Point.fromHex: x=0 and x_0=1");return Lt!==wt&&(lt=u(-lt)),d.fromAffine({x:lt,y:W})}static fromPrivateKey(h){let{scalar:b}=R(h);return v.multiply(b)}toRawBytes(){let{x:h,y:b}=this.toAffine(),B=fr(b,r.BYTES);return B[B.length-1]|=h&It?128:0,B}toHex(){return Pe(this.toRawBytes())}}d.BASE=new d(t.Gx,t.Gy,It,u(t.Gx*t.Gy)),d.ZERO=new d(oe,It,It,oe);let{BASE:v,ZERO:N}=d,L=Bn(d,c*8);function g(E){return tt(E,n)}function A(E){return g(Me(E))}function R(E){let h=r.BYTES;E=nt("private key",E,h);let b=nt("hashed private key",i(E),2*h),B=_(b.slice(0,h)),F=b.slice(h,2*h),V=A(B);return{head:B,prefix:F,scalar:V}}function I(E){let{head:h,prefix:b,scalar:B}=R(E),F=v.multiply(B),V=F.toRawBytes();return{head:h,prefix:b,scalar:B,point:F,pointBytes:V}}function C(E){return I(E).pointBytes}function U(E=Uint8Array.of(),...h){let b=_e(...h);return A(i(y(b,nt("context",E),!!o)))}function $(E,h,b={}){E=nt("message",E),o&&(E=o(E));let{prefix:B,scalar:F,pointBytes:V}=I(h),j=U(b.context,B,E),G=v.multiply(j).toRawBytes(),W=U(b.context,G,V,E),J=g(j+W*F);Kt("signature.s",J,oe,n);let ct=_e(G,fr(J,r.BYTES));return nt("result",ct,r.BYTES*2)}let x=Md;function w(E,h,b,B=x){let{context:F,zip215:V}=B,j=r.BYTES;E=nt("signature",E,2*j),h=nt("message",h),b=nt("publicKey",b,j),V!==void 0&&ne("zip215",V),o&&(h=o(h));let G=Me(E.slice(j,2*j)),W,J,ct;try{W=d.fromHex(b,V),J=d.fromHex(E.slice(0,j),V),ct=v.multiplyUnsafe(G)}catch{return!1}if(!V&&W.isSmallOrder())return!1;let st=U(F,J.toRawBytes(),W.toRawBytes(),h);return J.add(W.multiplyUnsafe(st)).subtract(ct).clearCofactor().equals(d.ZERO)}return v._setWindowSize(8),{CURVE:t,getPublicKey:C,sign:$,verify:w,ExtendedPoint:d,utils:{getExtendedPublicKey:I,randomPrivateKey:()=>s(r.BYTES),precompute(E=8,h=d.BASE){return h._setWindowSize(E),h.multiply(BigInt(3)),h}}}}var bi=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),nc=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),by=BigInt(0),qd=BigInt(1),oc=BigInt(2),Ey=BigInt(3),$d=BigInt(5),Hd=BigInt(8);function zd(e){let t=BigInt(10),r=BigInt(20),n=BigInt(40),o=BigInt(80),i=bi,c=e*e%i*e%i,a=ot(c,oc,i)*c%i,l=ot(a,qd,i)*e%i,u=ot(l,$d,i)*l%i,f=ot(u,t,i)*u%i,p=ot(f,r,i)*f%i,S=ot(p,n,i)*p%i,_=ot(S,o,i)*S%i,y=ot(_,o,i)*S%i,k=ot(y,t,i)*u%i;return{pow_p_5_8:ot(k,oc,i)*e%i,b2:c}}function jd(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}function Gd(e,t){let r=bi,n=tt(t*t*t,r),o=tt(n*n*t,r),i=zd(e*o).pow_p_5_8,s=tt(e*n*i,r),c=tt(t*s*s,r),a=s,l=tt(s*nc,r),u=c===e,f=c===tt(-e,r),p=c===tt(-e*nc,r);return u&&(s=a),(f||p)&&(s=l),Za(s,r)&&(s=tt(-s,r)),{isValid:u||f,value:s}}var ic=ge(bi,void 0,!0),Zd={a:ic.create(BigInt(-1)),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:ic,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:Hd,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:ka,randomBytes:Sn,adjustScalarBytes:jd,uvRatio:Gd},sc=rc(Zd);var _n=32;function ac(e,t,r){return sc.verify(t,r instanceof Uint8Array?r:r.subarray(),e)}var Un=class{type="Ed25519";raw;constructor(t){this.raw=Ei(t,_n)}toMultihash(){return Dt.digest(sr(this))}toCID(){return Z.createV1(114,this.toMultihash())}toString(){return Q.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:rt(this.raw,t.raw)}verify(t,r){return ac(this.raw,r,t)}};function Si(e){return e=Ei(e,_n),new Un(e)}function Ei(e,t){if(e=Uint8Array.from(e??[]),e.length!==t)throw new ut(`Key must be a Uint8Array of length ${t}, got ${e.length}`);return e}var Wd=Math.pow(2,7),Xd=Math.pow(2,14),Jd=Math.pow(2,21),vi=Math.pow(2,28),Ai=Math.pow(2,35),Ii=Math.pow(2,42),Ti=Math.pow(2,49),X=128,Et=127;function Rt(e){if(e<Wd)return 1;if(e<Xd)return 2;if(e<Jd)return 3;if(e<vi)return 4;if(e<Ai)return 5;if(e<Ii)return 6;if(e<Ti)return 7;if(Number.MAX_SAFE_INTEGER!=null&&e>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function Ci(e,t,r=0){switch(Rt(e)){case 8:t[r++]=e&255|X,e/=128;case 7:t[r++]=e&255|X,e/=128;case 6:t[r++]=e&255|X,e/=128;case 5:t[r++]=e&255|X,e/=128;case 4:t[r++]=e&255|X,e>>>=7;case 3:t[r++]=e&255|X,e>>>=7;case 2:t[r++]=e&255|X,e>>>=7;case 1:{t[r++]=e&255,e>>>=7;break}default:throw new Error("unreachable")}return t}function Qd(e,t,r=0){switch(Rt(e)){case 8:t.set(r++,e&255|X),e/=128;case 7:t.set(r++,e&255|X),e/=128;case 6:t.set(r++,e&255|X),e/=128;case 5:t.set(r++,e&255|X),e/=128;case 4:t.set(r++,e&255|X),e>>>=7;case 3:t.set(r++,e&255|X),e>>>=7;case 2:t.set(r++,e&255|X),e>>>=7;case 1:{t.set(r++,e&255),e>>>=7;break}default:throw new Error("unreachable")}return t}function Bi(e,t){let r=e[t],n=0;if(n+=r&Et,r<X||(r=e[t+1],n+=(r&Et)<<7,r<X)||(r=e[t+2],n+=(r&Et)<<14,r<X)||(r=e[t+3],n+=(r&Et)<<21,r<X)||(r=e[t+4],n+=(r&Et)*vi,r<X)||(r=e[t+5],n+=(r&Et)*Ai,r<X)||(r=e[t+6],n+=(r&Et)*Ii,r<X)||(r=e[t+7],n+=(r&Et)*Ti,r<X))return n;throw new RangeError("Could not decode varint")}function th(e,t){let r=e.get(t),n=0;if(n+=r&Et,r<X||(r=e.get(t+1),n+=(r&Et)<<7,r<X)||(r=e.get(t+2),n+=(r&Et)<<14,r<X)||(r=e.get(t+3),n+=(r&Et)<<21,r<X)||(r=e.get(t+4),n+=(r&Et)*vi,r<X)||(r=e.get(t+5),n+=(r&Et)*Ai,r<X)||(r=e.get(t+6),n+=(r&Et)*Ii,r<X)||(r=e.get(t+7),n+=(r&Et)*Ti,r<X))return n;throw new RangeError("Could not decode varint")}function hr(e,t,r=0){return t==null&&(t=Ut(Rt(e))),t instanceof Uint8Array?Ci(e,t,r):Qd(e,t,r)}function He(e,t=0){return e instanceof Uint8Array?Bi(e,t):th(e,t)}var Pi=new Float32Array([-0]),Ue=new Uint8Array(Pi.buffer);function fc(e,t,r){Pi[0]=e,t[r]=Ue[0],t[r+1]=Ue[1],t[r+2]=Ue[2],t[r+3]=Ue[3]}function lc(e,t){return Ue[0]=e[t],Ue[1]=e[t+1],Ue[2]=e[t+2],Ue[3]=e[t+3],Pi[0]}var _i=new Float64Array([-0]),St=new Uint8Array(_i.buffer);function dc(e,t,r){_i[0]=e,t[r]=St[0],t[r+1]=St[1],t[r+2]=St[2],t[r+3]=St[3],t[r+4]=St[4],t[r+5]=St[5],t[r+6]=St[6],t[r+7]=St[7]}function hc(e,t){return St[0]=e[t],St[1]=e[t+1],St[2]=e[t+2],St[3]=e[t+3],St[4]=e[t+4],St[5]=e[t+5],St[6]=e[t+6],St[7]=e[t+7],_i[0]}var eh=BigInt(Number.MAX_SAFE_INTEGER),rh=BigInt(Number.MIN_SAFE_INTEGER),Ot=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 ze;if(t<eh&&t>rh)return this.fromNumber(Number(t));let r=t<0n;r&&(t=-t);let n=t>>32n,o=t-(n<<32n);return r&&(n=~n|0n,o=~o|0n,++o>pc&&(o=0n,++n>pc&&(n=0n))),new e(Number(o),Number(n))}static fromNumber(t){if(t===0)return ze;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):ze}},ze=new Ot(0,0);ze.toBigInt=function(){return 0n};ze.zzEncode=ze.zzDecode=function(){return this};ze.length=function(){return 1};var pc=4294967296n;function mc(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 yc(e,t,r){if(r-t<1)return"";let o,i=[],s=0,c;for(;t<r;)c=e[t++],c<128?i[s++]=c:c>191&&c<224?i[s++]=(c&31)<<6|e[t++]&63:c>239&&c<365?(c=((c&7)<<18|(e[t++]&63)<<12|(e[t++]&63)<<6|e[t++]&63)-65536,i[s++]=55296+(c>>10),i[s++]=56320+(c&1023)):i[s++]=(c&15)<<12|(e[t++]&63)<<6|e[t++]&63,s>8191&&((o??(o=[])).push(String.fromCharCode.apply(String,i)),s=0);return o!=null?(s>0&&o.push(String.fromCharCode.apply(String,i.slice(0,s))),o.join("")):String.fromCharCode.apply(String,i.slice(0,s))}function Ui(e,t,r){let n=r,o,i;for(let s=0;s<e.length;++s)o=e.charCodeAt(s),o<128?t[r++]=o:o<2048?(t[r++]=o>>6|192,t[r++]=o&63|128):(o&64512)===55296&&((i=e.charCodeAt(s+1))&64512)===56320?(o=65536+((o&1023)<<10)+(i&1023),++s,t[r++]=o>>18|240,t[r++]=o>>12&63|128,t[r++]=o>>6&63|128,t[r++]=o&63|128):(t[r++]=o>>12|224,t[r++]=o>>6&63|128,t[r++]=o&63|128);return r-n}function Yt(e,t){return RangeError(`index out of range: ${e.pos} + ${t??1} > ${e.len}`)}function Nn(e,t){return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0}var Ni=class{buf;pos;len;_slice=Uint8Array.prototype.subarray;constructor(t){this.buf=t,this.pos=0,this.len=t.length}uint32(){let t=4294967295;if(t=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(t=(t|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return t;if((this.pos+=5)>this.len)throw this.pos=this.len,Yt(this,10);return t}int32(){return this.uint32()|0}sint32(){let t=this.uint32();return t>>>1^-(t&1)|0}bool(){return this.uint32()!==0}fixed32(){if(this.pos+4>this.len)throw Yt(this,4);return Nn(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw Yt(this,4);return Nn(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw Yt(this,4);let t=lc(this.buf,this.pos);return this.pos+=4,t}double(){if(this.pos+8>this.len)throw Yt(this,4);let t=hc(this.buf,this.pos);return this.pos+=8,t}bytes(){let t=this.uint32(),r=this.pos,n=this.pos+t;if(n>this.len)throw Yt(this,t);return this.pos+=t,r===n?new Uint8Array(0):this.buf.subarray(r,n)}string(){let t=this.bytes();return yc(t,0,t.length)}skip(t){if(typeof t=="number"){if(this.pos+t>this.len)throw Yt(this,t);this.pos+=t}else do if(this.pos>=this.len)throw Yt(this);while((this.buf[this.pos++]&128)!==0);return this}skipType(t){switch(t){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(t=this.uint32()&7)!==4;)this.skipType(t);break;case 5:this.skip(4);break;default:throw Error(`invalid wire type ${t} at offset ${this.pos}`)}return this}readLongVarint(){let t=new Ot(0,0),r=0;if(this.len-this.pos>4){for(;r<4;++r)if(t.lo=(t.lo|(this.buf[this.pos]&127)<<r*7)>>>0,this.buf[this.pos++]<128)return t;if(t.lo=(t.lo|(this.buf[this.pos]&127)<<28)>>>0,t.hi=(t.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return t;r=0}else{for(;r<3;++r){if(this.pos>=this.len)throw Yt(this);if(t.lo=(t.lo|(this.buf[this.pos]&127)<<r*7)>>>0,this.buf[this.pos++]<128)return t}return t.lo=(t.lo|(this.buf[this.pos++]&127)<<r*7)>>>0,t}if(this.len-this.pos>4){for(;r<5;++r)if(t.hi=(t.hi|(this.buf[this.pos]&127)<<r*7+3)>>>0,this.buf[this.pos++]<128)return t}else for(;r<5;++r){if(this.pos>=this.len)throw Yt(this);if(t.hi=(t.hi|(this.buf[this.pos]&127)<<r*7+3)>>>0,this.buf[this.pos++]<128)return t}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw Yt(this,8);let t=Nn(this.buf,this.pos+=4),r=Nn(this.buf,this.pos+=4);return new Ot(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=Bi(this.buf,this.pos);return this.pos+=Rt(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 Ri(e){return new Ni(e instanceof Uint8Array?e:e.subarray())}function pr(e,t,r){let n=Ri(e);return t.decode(n,void 0,r)}function Li(e){let t=e??8192,r=t>>>1,n,o=t;return function(s){if(s<1||s>r)return Ut(s);o+s>t&&(n=Ut(t),o=0);let c=n.subarray(o,o+=s);return(o&7)!==0&&(o=(o|7)+1),c}}var je=class{fn;len;next;val;constructor(t,r,n){this.fn=t,this.len=r,this.next=void 0,this.val=n}};function Di(){}var Ki=class{head;tail;len;next;constructor(t){this.head=t.head,this.tail=t.tail,this.len=t.len,this.next=t.states}},nh=Li();function oh(e){return globalThis.Buffer!=null?Ut(e):nh(e)}var jr=class{len;head;tail;states;constructor(){this.len=0,this.head=new je(Di,0,0),this.tail=this.head,this.states=null}_push(t,r,n){return this.tail=this.tail.next=new je(t,r,n),this.len+=r,this}uint32(t){return this.len+=(this.tail=this.tail.next=new Oi((t=t>>>0)<128?1:t<16384?2:t<2097152?3:t<268435456?4:5,t)).len,this}int32(t){return t<0?this._push(Rn,10,Ot.fromNumber(t)):this.uint32(t)}sint32(t){return this.uint32((t<<1^t>>31)>>>0)}uint64(t){let r=Ot.fromBigInt(t);return this._push(Rn,r.length(),r)}uint64Number(t){return this._push(Ci,Rt(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=Ot.fromBigInt(t).zzEncode();return this._push(Rn,r.length(),r)}sint64Number(t){let r=Ot.fromNumber(t).zzEncode();return this._push(Rn,r.length(),r)}sint64String(t){return this.sint64(BigInt(t))}bool(t){return this._push(ki,1,t?1:0)}fixed32(t){return this._push(zr,4,t>>>0)}sfixed32(t){return this.fixed32(t)}fixed64(t){let r=Ot.fromBigInt(t);return this._push(zr,4,r.lo)._push(zr,4,r.hi)}fixed64Number(t){let r=Ot.fromNumber(t);return this._push(zr,4,r.lo)._push(zr,4,r.hi)}fixed64String(t){return this.fixed64(BigInt(t))}sfixed64(t){return this.fixed64(t)}sfixed64Number(t){return this.fixed64Number(t)}sfixed64String(t){return this.fixed64String(t)}float(t){return this._push(fc,4,t)}double(t){return this._push(dc,8,t)}bytes(t){let r=t.length>>>0;return r===0?this._push(ki,1,0):this.uint32(r)._push(sh,r,t)}string(t){let r=mc(t);return r!==0?this.uint32(r)._push(Ui,r,t):this._push(ki,1,0)}fork(){return this.states=new Ki(this),this.head=this.tail=new je(Di,0,0),this.len=0,this}reset(){return this.states!=null?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new je(Di,0,0),this.len=0),this}ldelim(){let t=this.head,r=this.tail,n=this.len;return this.reset().uint32(n),n!==0&&(this.tail.next=t.next,this.tail=r,this.len+=n),this}finish(){let t=this.head.next,r=oh(this.len),n=0;for(;t!=null;)t.fn(t.val,r,n),n+=t.len,t=t.next;return r}};function ki(e,t,r){t[r]=e&255}function ih(e,t,r){for(;e>127;)t[r++]=e&127|128,e>>>=7;t[r]=e}var Oi=class extends je{next;constructor(t,r){super(ih,t,r),this.next=void 0}};function Rn(e,t,r){for(;e.hi!==0;)t[r++]=e.lo&127|128,e.lo=(e.lo>>>7|e.hi<<25)>>>0,e.hi>>>=7;for(;e.lo>127;)t[r++]=e.lo&127|128,e.lo=e.lo>>>7;t[r++]=e.lo}function zr(e,t,r){t[r]=e&255,t[r+1]=e>>>8&255,t[r+2]=e>>>16&255,t[r+3]=e>>>24}function sh(e,t,r){t.set(e,r)}globalThis.Buffer!=null&&(jr.prototype.bytes=function(e){let t=e.length>>>0;return this.uint32(t),t>0&&this._push(ah,t,e),this},jr.prototype.string=function(e){let t=globalThis.Buffer.byteLength(e);return this.uint32(t),t>0&&this._push(ch,t,e),this});function ah(e,t,r){t.set(e,r)}function ch(e,t,r){e.length<40?Ui(e,t,r):t.utf8Write!=null?t.utf8Write(e,r):t.set(H(e),r)}function Fi(){return new jr}function mr(e,t){let r=Fi();return t.encode(e,r,{lengthDelimited:!1}),r.finish()}var yr;(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"})(yr||(yr={}));function Ln(e,t,r,n){return{name:e,type:t,encode:r,decode:n}}function Gr(e){function t(o){if(e[o.toString()]==null)throw new Error("Invalid enum value");return e[o]}let r=function(i,s){let c=t(i);s.int32(c)},n=function(i){let s=i.int32();return t(s)};return Ln("enum",yr.VARINT,r,n)}function gr(e,t){return Ln("message",yr.LENGTH_DELIMITED,e,t)}var at;(function(e){e.RSA="RSA",e.Ed25519="Ed25519",e.secp256k1="secp256k1",e.ECDSA="ECDSA"})(at||(at={}));var Mi;(function(e){e[e.RSA=0]="RSA",e[e.Ed25519=1]="Ed25519",e[e.secp256k1=2]="secp256k1",e[e.ECDSA=3]="ECDSA"})(Mi||(Mi={}));(function(e){e.codec=()=>Gr(Mi)})(at||(at={}));var ie;(function(e){let t;e.codec=()=>(t==null&&(t=gr((r,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),r.Type!=null&&(n.uint32(8),at.codec().encode(r.Type,n)),r.Data!=null&&(n.uint32(18),n.bytes(r.Data)),o.lengthDelimited!==!1&&n.ldelim()},(r,n,o={})=>{let i={},s=n==null?r.len:r.pos+n;for(;r.pos<s;){let c=r.uint32();switch(c>>>3){case 1:{i.Type=at.codec().decode(r);break}case 2:{i.Data=r.bytes();break}default:{r.skipType(c&7);break}}}return i})),t),e.encode=r=>mr(r,e.codec()),e.decode=(r,n)=>pr(r,e.codec(),n)})(ie||(ie={}));var Vi;(function(e){let t;e.codec=()=>(t==null&&(t=gr((r,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),r.Type!=null&&(n.uint32(8),at.codec().encode(r.Type,n)),r.Data!=null&&(n.uint32(18),n.bytes(r.Data)),o.lengthDelimited!==!1&&n.ldelim()},(r,n,o={})=>{let i={},s=n==null?r.len:r.pos+n;for(;r.pos<s;){let c=r.uint32();switch(c>>>3){case 1:{i.Type=at.codec().decode(r);break}case 2:{i.Data=r.bytes();break}default:{r.skipType(c&7);break}}}return i})),t),e.encode=r=>mr(r,e.codec()),e.decode=(r,n)=>pr(r,e.codec(),n)})(Vi||(Vi={}));var Zr=class extends Error{constructor(t="An error occurred while verifying a message"){super(t),this.name="VerificationError"}},Dn=class extends Error{constructor(t="Missing Web Crypto API"){super(t),this.name="WebCryptoMissingError"}};var wc={get(e=globalThis){let t=e.crypto;if(t?.subtle==null)throw new Dn("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 Ne=wc;var Wr={};Bt(Wr,{MAX_RSA_KEY_SIZE:()=>qi,generateRSAKeyPair:()=>vc,jwkToJWKKeyPair:()=>Ac,jwkToPkcs1:()=>dh,jwkToPkix:()=>ji,jwkToRSAPrivateKey:()=>Wi,pkcs1MessageToJwk:()=>Hi,pkcs1MessageToRSAPrivateKey:()=>Gi,pkcs1ToJwk:()=>lh,pkcs1ToRSAPrivateKey:()=>Sc,pkixMessageToJwk:()=>zi,pkixMessageToRSAPublicKey:()=>Yi,pkixToJwk:()=>hh,pkixToRSAPublicKey:()=>Zi});var kn=In;var xr=class{type="RSA";jwk;_raw;_multihash;constructor(t,r){this.jwk=t,this._multihash=r}get raw(){return this._raw==null&&(this._raw=Wr.jwkToPkix(this.jwk)),this._raw}toMultihash(){return this._multihash}toCID(){return Z.createV1(114,this._multihash)}toString(){return Q.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:rt(this.raw,t.raw)}verify(t,r){return Ec(this.jwk,r,t)}},Yr=class{type="RSA";jwk;_raw;publicKey;constructor(t,r){this.jwk=t,this.publicKey=r}get raw(){return this._raw==null&&(this._raw=Wr.jwkToPkcs1(this.jwk)),this._raw}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:rt(this.raw,t.raw)}sign(t){return bc(this.jwk,t)}};var qi=8192,$i=18,uh=1062,fh=Uint8Array.from([48,13,6,9,42,134,72,134,247,13,1,1,1,5,0]);function lh(e){let t=le(e);return Hi(t)}function Hi(e){return{n:q(e[1],"base64url"),e:q(e[2],"base64url"),d:q(e[3],"base64url"),p:q(e[4],"base64url"),q:q(e[5],"base64url"),dp:q(e[6],"base64url"),dq:q(e[7],"base64url"),qi:q(e[8],"base64url"),kty:"RSA"}}function dh(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 ut("JWK was missing components");return Ie([Nt(Uint8Array.from([0])),Nt(H(e.n,"base64url")),Nt(H(e.e,"base64url")),Nt(H(e.d,"base64url")),Nt(H(e.p,"base64url")),Nt(H(e.q,"base64url")),Nt(H(e.dp,"base64url")),Nt(H(e.dq,"base64url")),Nt(H(e.qi,"base64url"))]).subarray()}function hh(e){let t=le(e,{offset:0});return zi(t)}function zi(e){let t=le(e[1],{offset:0});return{kty:"RSA",n:q(t[0],"base64url"),e:q(t[1],"base64url")}}function ji(e){if(e.n==null||e.e==null)throw new ut("JWK was missing components");return Ie([fh,wn(Ie([Nt(H(e.n,"base64url")),Nt(H(e.e,"base64url"))]))]).subarray()}function Sc(e){let t=le(e);return Gi(t)}function Gi(e){let t=Hi(e);return Wi(t)}function Zi(e,t){if(e.byteLength>=uh)throw new We("Key size is too large");let r=le(e,{offset:0});return Yi(r,e,t)}function Yi(e,t,r){let n=zi(e);if(r==null){let o=kn(ie.encode({Type:at.RSA,Data:t}));r=Gt($i,o)}return new xr(n,r)}function Wi(e){if(Tc(e)>qi)throw new ut("Key size is too large");let t=Ac(e),r=kn(ie.encode({Type:at.RSA,Data:ji(t.publicKey)})),n=Gt($i,r);return new Yr(t.privateKey,new xr(t.publicKey,n))}async function vc(e){if(e>qi)throw new ut("Key size is too large");let t=await Ic(e),r=kn(ie.encode({Type:at.RSA,Data:ji(t.publicKey)})),n=Gt($i,r);return new Yr(t.privateKey,new xr(t.publicKey,n))}function Ac(e){if(e==null)throw new ut("Missing key parameter");return{privateKey:e,publicKey:{kty:e.kty,n:e.n,e:e.e}}}async function Ic(e){let t=await Ne.get().subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:e,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-256"}},!0,["sign","verify"]),r=await ph(t);return{privateKey:r[0],publicKey:r[1]}}async function bc(e,t){let r=await Ne.get().subtle.importKey("jwk",e,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["sign"]),n=await Ne.get().subtle.sign({name:"RSASSA-PKCS1-v1_5"},r,t instanceof Uint8Array?t:t.subarray());return new Uint8Array(n,0,n.byteLength)}async function Ec(e,t,r){let n=await Ne.get().subtle.importKey("jwk",e,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["verify"]);return Ne.get().subtle.verify({name:"RSASSA-PKCS1-v1_5"},n,t,r instanceof Uint8Array?r:r.subarray())}async function ph(e){if(e.privateKey==null||e.publicKey==null)throw new ut("Private and public key are required");return Promise.all([Ne.get().subtle.exportKey("jwk",e.privateKey),Ne.get().subtle.exportKey("jwk",e.publicKey)])}function Tc(e){if(e.kty!=="RSA")throw new ut("invalid key type");if(e.n==null)throw new ut("invalid key modulus");return H(e.n,"base64url").length*8}var Kn=class extends ar{constructor(t,r){super(),this.finished=!1,this.destroyed=!1,Sa(t);let n=Or(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),de(i)}update(t){return cr(this),this.iHash.update(t),this}digestInto(t){cr(this),Ke(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:c}=this;return t=t,t.finished=o,t.destroyed=i,t.blockLen=s,t.outputLen=c,t.oHash=r._cloneInto(t.oHash),t.iHash=n._cloneInto(t.iHash),t}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},Xi=(e,t,r)=>new Kn(e,t).update(r).digest();Xi.create=(e,t)=>new Kn(e,t);function Cc(e){e.lowS!==void 0&&ne("lowS",e.lowS),e.prehash!==void 0&&ne("prehash",e.prehash)}function mh(e){let t=Hr(e);ye(t,{a:"field",b:"field"},{allowInfinityPoint:"boolean",allowedPrivateKeyLengths:"array",clearCofactor:"function",fromBytes:"function",isTorsionFree:"function",toBytes:"function",wrapPrivateKey:"boolean"});let{endo:r,Fp:n,a:o}=t;if(r){if(!n.eql(o,n.ZERO))throw new Error("invalid endo: CURVE.a must be 0");if(typeof r!="object"||typeof r.beta!="bigint"||typeof r.splitScalar!="function")throw new Error('invalid endo: expected "beta": bigint and "splitScalar": function')}return Object.freeze({...t})}var ts=class extends Error{constructor(t=""){super(t)}},xe={Err:ts,_tlv:{encode:(e,t)=>{let{Err:r}=xe;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=qr(n);if(o.length/2&128)throw new r("tlv.encode: long form length too big");let i=n>127?qr(o.length/2|128):"";return qr(e)+i+o+t},decode(e,t){let{Err:r}=xe,n=0;if(e<0||e>256)throw new r("tlv.encode: wrong tag");if(t.length<2||t[n++]!==e)throw new r("tlv.decode: wrong tlv");let o=t[n++],i=!!(o&128),s=0;if(!i)s=o;else{let a=o&127;if(!a)throw new r("tlv.decode(long): indefinite length not supported");if(a>4)throw new r("tlv.decode(long): byte length is too big");let l=t.subarray(n,n+a);if(l.length!==a)throw new r("tlv.decode: length bytes not complete");if(l[0]===0)throw new r("tlv.decode(long): zero leftmost byte");for(let u of l)s=s<<8|u;if(n+=a,s<128)throw new r("tlv.decode(long): not minimal encoding")}let c=t.subarray(n,n+s);if(c.length!==s)throw new r("tlv.decode: wrong value length");return{v:c,l:t.subarray(n+s)}}},_int:{encode(e){let{Err:t}=xe;if(e<we)throw new t("integer: negative integers are not allowed");let r=qr(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}=xe;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 me(e)}},toSig(e){let{Err:t,_int:r,_tlv:n}=xe,o=nt("signature",e),{v:i,l:s}=n.decode(48,o);if(s.length)throw new t("invalid signature: left bytes after parsing");let{v:c,l:a}=n.decode(2,i),{v:l,l:u}=n.decode(2,a);if(u.length)throw new t("invalid signature: left bytes after parsing");return{r:r.decode(c),s:r.decode(l)}},hexFromSig(e){let{_tlv:t,_int:r}=xe,n=t.encode(2,r.encode(e.r)),o=t.encode(2,r.encode(e.s)),i=n+o;return t.encode(48,i)}};function Ji(e,t){return Pe(Ve(e,t))}var we=BigInt(0),ht=BigInt(1),Zg=BigInt(2),Qi=BigInt(3),yh=BigInt(4);function gh(e){let t=mh(e),{Fp:r}=t,n=ge(t.n,t.nBitLength),o=t.toBytes||((T,d,v)=>{let N=d.toAffine();return _e(Uint8Array.from([4]),r.toBytes(N.x),r.toBytes(N.y))}),i=t.fromBytes||(T=>{let d=T.subarray(1),v=r.fromBytes(d.subarray(0,r.BYTES)),N=r.fromBytes(d.subarray(r.BYTES,2*r.BYTES));return{x:v,y:N}});function s(T){let{a:d,b:v}=t,N=r.sqr(T),L=r.mul(N,T);return r.add(r.add(L,r.mul(T,d)),v)}function c(T,d){let v=r.sqr(d),N=s(T);return r.eql(v,N)}if(!c(t.Gx,t.Gy))throw new Error("bad curve params: generator point");let a=r.mul(r.pow(t.a,Qi),yh),l=r.mul(r.sqr(t.b),BigInt(27));if(r.is0(r.add(a,l)))throw new Error("bad curve params: a or b");function u(T){return Tn(T,ht,t.n)}function f(T){let{allowedPrivateKeyLengths:d,nByteLength:v,wrapPrivateKey:N,n:L}=t;if(d&&typeof T!="bigint"){if(ur(T)&&(T=Pe(T)),typeof T!="string"||!d.includes(T.length))throw new Error("invalid private key");T=T.padStart(v*2,"0")}let g;try{g=typeof T=="bigint"?T:me(nt("private key",T,v))}catch{throw new Error("invalid private key, expected hex or "+v+" bytes, got "+typeof T)}return N&&(g=tt(g,L)),Kt("private key",g,ht,L),g}function p(T){if(!(T instanceof y))throw new Error("ProjectivePoint expected")}let S=lr((T,d)=>{let{px:v,py:N,pz:L}=T;if(r.eql(L,r.ONE))return{x:v,y:N};let g=T.is0();d==null&&(d=g?r.ONE:r.inv(L));let A=r.mul(v,d),R=r.mul(N,d),I=r.mul(L,d);if(g)return{x:r.ZERO,y:r.ZERO};if(!r.eql(I,r.ONE))throw new Error("invZ was invalid");return{x:A,y:R}}),_=lr(T=>{if(T.is0()){if(t.allowInfinityPoint&&!r.is0(T.py))return;throw new Error("bad point: ZERO")}let{x:d,y:v}=T.toAffine();if(!r.isValid(d)||!r.isValid(v))throw new Error("bad point: x or y not FE");if(!c(d,v))throw new Error("bad point: equation left != right");if(!T.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class y{constructor(d,v,N){if(d==null||!r.isValid(d))throw new Error("x required");if(v==null||!r.isValid(v)||r.is0(v))throw new Error("y required");if(N==null||!r.isValid(N))throw new Error("z required");this.px=d,this.py=v,this.pz=N,Object.freeze(this)}static fromAffine(d){let{x:v,y:N}=d||{};if(!d||!r.isValid(v)||!r.isValid(N))throw new Error("invalid affine point");if(d instanceof y)throw new Error("projective point not allowed");let L=g=>r.eql(g,r.ZERO);return L(v)&&L(N)?y.ZERO:new y(v,N,r.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(d){let v=dr(r,d.map(N=>N.pz));return d.map((N,L)=>N.toAffine(v[L])).map(y.fromAffine)}static fromHex(d){let v=y.fromAffine(i(nt("pointHex",d)));return v.assertValidity(),v}static fromPrivateKey(d){return y.BASE.multiply(f(d))}static msm(d,v){return Pn(y,n,d,v)}_setWindowSize(d){z.setWindowSize(this,d)}assertValidity(){_(this)}hasEvenY(){let{y:d}=this.toAffine();if(r.isOdd)return!r.isOdd(d);throw new Error("Field doesn't support isOdd")}equals(d){p(d);let{px:v,py:N,pz:L}=this,{px:g,py:A,pz:R}=d,I=r.eql(r.mul(v,R),r.mul(g,L)),C=r.eql(r.mul(N,R),r.mul(A,L));return I&&C}negate(){return new y(this.px,r.neg(this.py),this.pz)}double(){let{a:d,b:v}=t,N=r.mul(v,Qi),{px:L,py:g,pz:A}=this,R=r.ZERO,I=r.ZERO,C=r.ZERO,U=r.mul(L,L),$=r.mul(g,g),x=r.mul(A,A),w=r.mul(L,g);return w=r.add(w,w),C=r.mul(L,A),C=r.add(C,C),R=r.mul(d,C),I=r.mul(N,x),I=r.add(R,I),R=r.sub($,I),I=r.add($,I),I=r.mul(R,I),R=r.mul(w,R),C=r.mul(N,C),x=r.mul(d,x),w=r.sub(U,x),w=r.mul(d,w),w=r.add(w,C),C=r.add(U,U),U=r.add(C,U),U=r.add(U,x),U=r.mul(U,w),I=r.add(I,U),x=r.mul(g,A),x=r.add(x,x),U=r.mul(x,w),R=r.sub(R,U),C=r.mul(x,$),C=r.add(C,C),C=r.add(C,C),new y(R,I,C)}add(d){p(d);let{px:v,py:N,pz:L}=this,{px:g,py:A,pz:R}=d,I=r.ZERO,C=r.ZERO,U=r.ZERO,$=t.a,x=r.mul(t.b,Qi),w=r.mul(v,g),K=r.mul(N,A),E=r.mul(L,R),h=r.add(v,N),b=r.add(g,A);h=r.mul(h,b),b=r.add(w,K),h=r.sub(h,b),b=r.add(v,L);let B=r.add(g,R);return b=r.mul(b,B),B=r.add(w,E),b=r.sub(b,B),B=r.add(N,L),I=r.add(A,R),B=r.mul(B,I),I=r.add(K,E),B=r.sub(B,I),U=r.mul($,b),I=r.mul(x,E),U=r.add(I,U),I=r.sub(K,U),U=r.add(K,U),C=r.mul(I,U),K=r.add(w,w),K=r.add(K,w),E=r.mul($,E),b=r.mul(x,b),K=r.add(K,E),E=r.sub(w,E),E=r.mul($,E),b=r.add(b,E),w=r.mul(K,b),C=r.add(C,w),w=r.mul(B,b),I=r.mul(h,I),I=r.sub(I,w),w=r.mul(h,K),U=r.mul(B,U),U=r.add(U,w),new y(I,C,U)}subtract(d){return this.add(d.negate())}is0(){return this.equals(y.ZERO)}wNAF(d){return z.wNAFCached(this,d,y.normalizeZ)}multiplyUnsafe(d){let{endo:v,n:N}=t;Kt("scalar",d,we,N);let L=y.ZERO;if(d===we)return L;if(this.is0()||d===ht)return this;if(!v||z.hasPrecomputes(this))return z.wNAFCachedUnsafe(this,d,y.normalizeZ);let{k1neg:g,k1:A,k2neg:R,k2:I}=v.splitScalar(d),C=L,U=L,$=this;for(;A>we||I>we;)A&ht&&(C=C.add($)),I&ht&&(U=U.add($)),$=$.double(),A>>=ht,I>>=ht;return g&&(C=C.negate()),R&&(U=U.negate()),U=new y(r.mul(U.px,v.beta),U.py,U.pz),C.add(U)}multiply(d){let{endo:v,n:N}=t;Kt("scalar",d,ht,N);let L,g;if(v){let{k1neg:A,k1:R,k2neg:I,k2:C}=v.splitScalar(d),{p:U,f:$}=this.wNAF(R),{p:x,f:w}=this.wNAF(C);U=z.constTimeNegate(A,U),x=z.constTimeNegate(I,x),x=new y(r.mul(x.px,v.beta),x.py,x.pz),L=U.add(x),g=$.add(w)}else{let{p:A,f:R}=this.wNAF(d);L=A,g=R}return y.normalizeZ([L,g])[0]}multiplyAndAddUnsafe(d,v,N){let L=y.BASE,g=(R,I)=>I===we||I===ht||!R.equals(L)?R.multiplyUnsafe(I):R.multiply(I),A=g(this,v).add(g(d,N));return A.is0()?void 0:A}toAffine(d){return S(this,d)}isTorsionFree(){let{h:d,isTorsionFree:v}=t;if(d===ht)return!0;if(v)return v(y,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h:d,clearCofactor:v}=t;return d===ht?this:v?v(y,this):this.multiplyUnsafe(t.h)}toRawBytes(d=!0){return ne("isCompressed",d),this.assertValidity(),o(y,this,d)}toHex(d=!0){return ne("isCompressed",d),Pe(this.toRawBytes(d))}}y.BASE=new y(t.Gx,t.Gy,r.ONE),y.ZERO=new y(r.ZERO,r.ONE,r.ZERO);let{endo:k,nBitLength:O}=t,z=Bn(y,k?Math.ceil(O/2):O);return{CURVE:t,ProjectivePoint:y,normPrivateKeyToScalar:f,weierstrassEquation:s,isWithinCurveOrder:u}}function xh(e){let t=Hr(e);return ye(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}function Bc(e){let t=xh(e),{Fp:r,n,nByteLength:o,nBitLength:i}=t,s=r.BYTES+1,c=2*r.BYTES+1;function a(x){return tt(x,n)}function l(x){return Cn(x,n)}let{ProjectivePoint:u,normPrivateKeyToScalar:f,weierstrassEquation:p,isWithinCurveOrder:S}=gh({...t,toBytes(x,w,K){let E=w.toAffine(),h=r.toBytes(E.x),b=_e;return ne("isCompressed",K),K?b(Uint8Array.from([w.hasEvenY()?2:3]),h):b(Uint8Array.from([4]),h,r.toBytes(E.y))},fromBytes(x){let w=x.length,K=x[0],E=x.subarray(1);if(w===s&&(K===2||K===3)){let h=me(E);if(!Tn(h,ht,r.ORDER))throw new Error("Point is not on curve");let b=p(h),B;try{B=r.sqrt(b)}catch(j){let G=j instanceof Error?": "+j.message:"";throw new Error("Point is not on curve"+G)}let F=(B&ht)===ht;return(K&1)===1!==F&&(B=r.neg(B)),{x:h,y:B}}else if(w===c&&K===4){let h=r.fromBytes(E.subarray(0,r.BYTES)),b=r.fromBytes(E.subarray(r.BYTES,2*r.BYTES));return{x:h,y:b}}else{let h=s,b=c;throw new Error("invalid Point, expected length of "+h+", or uncompressed "+b+", got "+w)}}});function _(x){let w=n>>ht;return x>w}function y(x){return _(x)?a(-x):x}let k=(x,w,K)=>me(x.slice(w,K));class O{constructor(w,K,E){Kt("r",w,ht,n),Kt("s",K,ht,n),this.r=w,this.s=K,E!=null&&(this.recovery=E),Object.freeze(this)}static fromCompact(w){let K=o;return w=nt("compactSignature",w,K*2),new O(k(w,0,K),k(w,K,2*K))}static fromDER(w){let{r:K,s:E}=xe.toSig(nt("DER",w));return new O(K,E)}assertValidity(){}addRecoveryBit(w){return new O(this.r,this.s,w)}recoverPublicKey(w){let{r:K,s:E,recovery:h}=this,b=L(nt("msgHash",w));if(h==null||![0,1,2,3].includes(h))throw new Error("recovery id invalid");let B=h===2||h===3?K+t.n:K;if(B>=r.ORDER)throw new Error("recovery id 2 or 3 invalid");let F=(h&1)===0?"02":"03",V=u.fromHex(F+Ji(B,r.BYTES)),j=l(B),G=a(-b*j),W=a(E*j),J=u.BASE.multiplyAndAddUnsafe(V,G,W);if(!J)throw new Error("point at infinify");return J.assertValidity(),J}hasHighS(){return _(this.s)}normalizeS(){return this.hasHighS()?new O(this.r,a(-this.s),this.recovery):this}toDERRawBytes(){return $r(this.toDERHex())}toDERHex(){return xe.hexFromSig(this)}toCompactRawBytes(){return $r(this.toCompactHex())}toCompactHex(){let w=o;return Ji(this.r,w)+Ji(this.s,w)}}let z={isValidPrivateKey(x){try{return f(x),!0}catch{return!1}},normPrivateKeyToScalar:f,randomPrivateKey:()=>{let x=pi(t.n);return Wa(t.randomBytes(x),t.n)},precompute(x=8,w=u.BASE){return w._setWindowSize(x),w.multiply(BigInt(3)),w}};function T(x,w=!0){return u.fromPrivateKey(x).toRawBytes(w)}function d(x){if(typeof x=="bigint")return!1;if(x instanceof u)return!0;let K=nt("key",x).length,E=r.BYTES,h=E+1,b=2*E+1;if(!(t.allowedPrivateKeyLengths||o===h))return K===h||K===b}function v(x,w,K=!0){if(d(x)===!0)throw new Error("first arg must be private key");if(d(w)===!1)throw new Error("second arg must be public key");return u.fromHex(w).multiply(f(x)).toRawBytes(K)}let N=t.bits2int||function(x){if(x.length>8192)throw new Error("input is too large");let w=me(x),K=x.length*8-i;return K>0?w>>BigInt(K):w},L=t.bits2int_modN||function(x){return a(N(x))},g=qe(i);function A(x){return Kt("num < 2^"+i,x,we,g),Ve(x,o)}function R(x,w,K=I){if(["recovered","canonical"].some(st=>st in K))throw new Error("sign() legacy options not supported");let{hash:E,randomBytes:h}=t,{lowS:b,prehash:B,extraEntropy:F}=K;b==null&&(b=!0),x=nt("msgHash",x),Cc(K),B&&(x=nt("prehashed msgHash",E(x)));let V=L(x),j=f(w),G=[A(j),A(V)];if(F!=null&&F!==!1){let st=F===!0?h(r.BYTES):F;G.push(nt("extraEntropy",st))}let W=_e(...G),J=V;function ct(st){let mt=N(st);if(!S(mt))return;let Ct=l(mt),lt=u.BASE.multiply(mt).toAffine(),wt=a(lt.x);if(wt===we)return;let Lt=a(Ct*a(J+wt*j));if(Lt===we)return;let zt=(lt.x===wt?0:2)|Number(lt.y&ht),_r=Lt;return b&&_(Lt)&&(_r=y(Lt),zt^=1),new O(wt,_r,zt)}return{seed:W,k2sig:ct}}let I={lowS:t.lowS,prehash:!1},C={lowS:t.lowS,prehash:!1};function U(x,w,K=I){let{seed:E,k2sig:h}=R(x,w,K),b=t;return qa(b.hash.outputLen,b.nByteLength,b.hmac)(E,h)}u.BASE._setWindowSize(8);function $(x,w,K,E=C){let h=x;w=nt("msgHash",w),K=nt("publicKey",K);let{lowS:b,prehash:B,format:F}=E;if(Cc(E),"strict"in E)throw new Error("options.strict was renamed to lowS");if(F!==void 0&&F!=="compact"&&F!=="der")throw new Error("format must be compact or der");let V=typeof h=="string"||ur(h),j=!V&&!F&&typeof h=="object"&&h!==null&&typeof h.r=="bigint"&&typeof h.s=="bigint";if(!V&&!j)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let G,W;try{if(j&&(G=new O(h.r,h.s)),V){try{F!=="compact"&&(G=O.fromDER(h))}catch(zt){if(!(zt instanceof xe.Err))throw zt}!G&&F!=="der"&&(G=O.fromCompact(h))}W=u.fromHex(K)}catch{return!1}if(!G||b&&G.hasHighS())return!1;B&&(w=t.hash(w));let{r:J,s:ct}=G,st=L(w),mt=l(ct),Ct=a(st*mt),lt=a(J*mt),wt=u.BASE.multiplyAndAddUnsafe(W,Ct,lt)?.toAffine();return wt?a(wt.x)===J:!1}return{CURVE:t,getPublicKey:T,getSharedSecret:v,sign:U,verify:$,ProjectivePoint:u,Signature:O,utils:z}}function wh(e){return{hash:e,hmac:(t,...r)=>Xi(e,t,ri(...r)),randomBytes:Sn}}function Pc(e,t){let r=n=>Bc({...e,...wh(n)});return{...r(t),create:r}}var Nc=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),_c=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),bh=BigInt(0),Eh=BigInt(1),es=BigInt(2),Uc=(e,t)=>(e+t/es)/t;function Sh(e){let t=Nc,r=BigInt(3),n=BigInt(6),o=BigInt(11),i=BigInt(22),s=BigInt(23),c=BigInt(44),a=BigInt(88),l=e*e*e%t,u=l*l*e%t,f=ot(u,r,t)*u%t,p=ot(f,r,t)*u%t,S=ot(p,es,t)*l%t,_=ot(S,o,t)*S%t,y=ot(_,i,t)*_%t,k=ot(y,c,t)*y%t,O=ot(k,a,t)*k%t,z=ot(O,c,t)*y%t,T=ot(z,r,t)*u%t,d=ot(T,s,t)*_%t,v=ot(d,n,t)*l%t,N=ot(v,es,t);if(!rs.eql(rs.sqr(N),e))throw new Error("Cannot find square root");return N}var rs=ge(Nc,void 0,void 0,{sqrt:Sh}),wr=Pc({a:bh,b:BigInt(7),Fp:rs,n:_c,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:e=>{let t=_c,r=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-Eh*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),i=r,s=BigInt("0x100000000000000000000000000000000"),c=Uc(i*e,t),a=Uc(-n*e,t),l=tt(e-c*r-a*o,t),u=tt(-c*n-a*i,t),f=l>s,p=u>s;if(f&&(l=t-l),p&&(u=t-u),l>s||u>s)throw new Error("splitScalar: Endomorphism failed, k="+e);return{k1neg:f,k1:l,k2neg:p,k2:u}}}},In);function Rc(e){return e==null?!1:typeof e.then=="function"&&typeof e.catch=="function"&&typeof e.finally=="function"}function Lc(e,t,r){let n=Lr.digest(r instanceof Uint8Array?r:r.subarray());if(Rc(n))return n.then(({digest:o})=>wr.verify(t,o,e)).catch(o=>{throw new Zr(String(o))});try{return wr.verify(t,n.digest,e)}catch(o){throw new Zr(String(o))}}var On=class{type="secp256k1";raw;_key;constructor(t){this._key=kc(t),this.raw=Dc(this._key)}toMultihash(){return Dt.digest(sr(this))}toCID(){return Z.createV1(114,this.toMultihash())}toString(){return Q.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:rt(this.raw,t.raw)}verify(t,r){return Lc(this._key,r,t)}};function ns(e){return new On(e)}function Dc(e){return wr.ProjectivePoint.fromHex(e).toRawBytes(!0)}function kc(e){try{return wr.ProjectivePoint.fromHex(e),e}catch(t){throw new We(String(t))}}function Kc(e,t){let{Type:r,Data:n}=ie.decode(e),o=n??new Uint8Array;switch(r){case at.RSA:return Zi(o,t);case at.Ed25519:return Si(o);case at.secp256k1:return ns(o);case at.ECDSA:return ei(o);default:throw new Je}}function Fn(e){let{Type:t,Data:r}=ie.decode(e.digest),n=r??new Uint8Array;switch(t){case at.Ed25519:return Si(n);case at.secp256k1:return ns(n);case at.ECDSA:return ei(n);default:throw new Je}}function sr(e){return ie.encode({Type:at[e.type],Data:e.raw})}var Oc=Symbol.for("nodejs.util.inspect.custom"),vh=114,Xr=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()})`}[To]=!0;toString(){return this.string==null&&(this.string=Q.encode(this.multihash.bytes).slice(1)),this.string}toMultihash(){return this.multihash}toCID(){return Z.createV1(vh,this.multihash)}toJSON(){return this.toString()}equals(t){if(t==null)return!1;if(t instanceof Uint8Array)return rt(this.multihash.bytes,t);if(typeof t=="string")return this.toString()===t;if(t?.toMultihash()?.bytes!=null)return rt(this.multihash.bytes,t.toMultihash().bytes);throw new Error("not valid Id")}[Oc](){return`PeerId(${this.toString()})`}},Mn=class extends Xr{type="RSA";publicKey;constructor(t){super({...t,type:"RSA"}),this.publicKey=t.publicKey}},Vn=class extends Xr{type="Ed25519";publicKey;constructor(t){super({...t,type:"Ed25519"}),this.publicKey=t.publicKey}},qn=class extends Xr{type="secp256k1";publicKey;constructor(t){super({...t,type:"secp256k1"}),this.publicKey=t.publicKey}},Ah=2336,Jr=class{type="url";multihash;publicKey;url;constructor(t){this.url=t.toString(),this.multihash=Dt.digest(H(this.url))}[Oc](){return`PeerId(${this.url})`}[To]=!0;toString(){return this.toCID().toString()}toMultihash(){return this.multihash}toCID(){return Z.createV1(Ah,this.toMultihash())}toJSON(){return this.toString()}equals(t){return t==null?!1:(t instanceof Uint8Array&&(t=q(t)),t.toString()===this.toString())}};var Ih=114,Fc=2336;function Mc(e,t){let r;if(e.charAt(0)==="1"||e.charAt(0)==="Q")r=ue(Q.decode(`z${e}`));else{if(e.startsWith("k51qzi5uqu5")||e.startsWith("kzwfwjn5ji4")||e.startsWith("k2k4r8")||e.startsWith("bafz"))return os(Z.parse(e));if(t==null)throw new ut('Please pass a multibase decoder for strings that do not start with "1" or "Q"');r=ue(t.decode(e))}return Vc(r)}function Vc(e){if(Ch(e))return new Mn({multihash:e});if(Th(e))try{let t=Fn(e);if(t.type==="Ed25519")return new Vn({multihash:e,publicKey:t});if(t.type==="secp256k1")return new qn({multihash:e,publicKey:t})}catch{let r=q(e.digest);return new Jr(new URL(r))}throw new Xe("Supplied PeerID Multihash is invalid")}function os(e){if(e?.multihash==null||e.version==null||e.version===1&&e.code!==Ih&&e.code!==Fc)throw new hn("Supplied PeerID CID is invalid");if(e.code===Fc){let t=q(e.multihash.digest);return new Jr(new URL(t))}return Vc(e.multihash)}function Th(e){return e.code===Dt.code}function Ch(e){return e.code===Lr.code}var $n=class{index=0;input="";new(t){return this.index=0,this.input=t,this}readAtomically(t){let r=this.index,n=t();return n===void 0&&(this.index=r),n}parseWith(t){let r=t();if(this.index===this.input.length)return r}peekChar(){if(!(this.index>=this.input.length))return this.input[this.index]}readChar(){if(!(this.index>=this.input.length))return this.input[this.index++]}readGivenChar(t){return this.readAtomically(()=>{let r=this.readChar();if(r===t)return r})}readSeparator(t,r,n){return this.readAtomically(()=>{if(!(r>0&&this.readGivenChar(t)===void 0))return n()})}readNumber(t,r,n,o){return this.readAtomically(()=>{let i=0,s=0,c=this.peekChar();if(c===void 0)return;let a=c==="0",l=2**(8*o)-1;for(;;){let u=this.readAtomically(()=>{let f=this.readChar();if(f===void 0)return;let p=Number.parseInt(f,t);if(!Number.isNaN(p))return p});if(u===void 0)break;if(i*=t,i+=u,i>l||(s+=1,r!==void 0&&s>r))return}if(s!==0)return!n&&a&&s>1?void 0:i})}readIPv4Addr(){return this.readAtomically(()=>{let t=new Uint8Array(4);for(let r=0;r<t.length;r++){let n=this.readSeparator(".",r,()=>this.readNumber(10,3,!1,1));if(n===void 0)return;t[r]=n}return t})}readIPv6Addr(){let t=r=>{for(let n=0;n<r.length/2;n++){let o=n*2;if(n<r.length-3){let s=this.readSeparator(":",n,()=>this.readIPv4Addr());if(s!==void 0)return r[o]=s[0],r[o+1]=s[1],r[o+2]=s[2],r[o+3]=s[3],[o+4,!0]}let i=this.readSeparator(":",n,()=>this.readNumber(16,4,!0,2));if(i===void 0)return[o,!1];r[o]=i>>8,r[o+1]=i&255}return[r.length,!1]};return this.readAtomically(()=>{let r=new Uint8Array(16),[n,o]=t(r);if(n===16)return r;if(o||this.readGivenChar(":")===void 0||this.readGivenChar(":")===void 0)return;let i=new Uint8Array(14),s=16-(n+2),[c]=t(i.subarray(0,s));return r.set(i.subarray(0,c),16-c),r})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var qc=45,Bh=15,br=new $n;function is(e){if(!(e.length>Bh))return br.new(e).parseWith(()=>br.readIPv4Addr())}function ss(e){if(e.includes("%")&&(e=e.split("%")[0]),!(e.length>qc))return br.new(e).parseWith(()=>br.readIPv6Addr())}function Hn(e,t=!1){if(e.includes("%")&&(e=e.split("%")[0]),e.length>qc)return;let r=br.new(e).parseWith(()=>br.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 yw=parseInt("0xFFFF",16),gw=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);function zc(e){return!!is(e)}function jc(e){return!!ss(e)}function zn(e){return!!Hn(e)}var Gc=zc,Rh=jc,as=function(e){let t=0;if(e=e.toString().trim(),Gc(e)){let r=new Uint8Array(t+4);return e.split(/\./g).forEach(n=>{r[t++]=parseInt(n,10)&255}),r}if(Rh(e)){let r=e.split(":",8),n;for(n=0;n<r.length;n++){let i=Gc(r[n]),s;i&&(s=as(r[n]),r[n]=q(s.slice(0,2),"base16")),s!=null&&++n<8&&r.splice(n,0,q(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")},Zc=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 Er={},cs={},Dh=[[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"]];Dh.forEach(e=>{let t=kh(...e);cs[t.code]=t,Er[t.name]=t});function kh(e,t,r,n,o){return{code:e,size:t,name:r,resolvable:!!n,path:!!o}}function et(e){if(typeof e=="number"){if(cs[e]!=null)return cs[e];throw new Error(`no protocol with code: ${e}`)}else if(typeof e=="string"){if(Er[e]!=null)return Er[e];throw new Error(`no protocol with name: ${e}`)}throw new Error(`invalid protocol id type: ${typeof e}`)}var tb=et("ip4"),eb=et("ip6"),rb=et("ipcidr");function ds(e,t){switch(et(e).code){case 4:case 41:return Oh(t);case 42:return ls(t);case 43:return q(t,"base10");case 6:case 273:case 33:case 132:return Xc(t).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return ls(t);case 421:return qh(t);case 444:return Wc(t);case 445:return Wc(t);case 466:return Vh(t);case 481:return globalThis.encodeURIComponent(ls(t));default:return q(t,"base16")}}function hs(e,t){switch(et(e).code){case 4:return Yc(t);case 41:return Yc(t);case 42:return fs(t);case 43:return H(t,"base10");case 6:case 273:case 33:case 132:return ps(parseInt(t,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return fs(t);case 421:return Fh(t);case 444:return $h(t);case 445:return Hh(t);case 466:return Mh(t);case 481:return fs(globalThis.decodeURIComponent(t));default:return H(t,"base16")}}var us=Object.values(Dr).map(e=>e.decoder),Kh=function(){let e=us[0].or(us[1]);return us.slice(2).forEach(t=>e=e.or(t)),e}();function Yc(e){if(!zn(e))throw new Error("invalid ip address");return as(e)}function Oh(e){let t=Zc(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 ps(e){let t=new ArrayBuffer(2);return new DataView(t).setUint16(0,e),new Uint8Array(t)}function Xc(e){return new DataView(e.buffer).getUint16(e.byteOffset)}function fs(e){let t=H(e),r=Uint8Array.from(hr(t.length));return bt([r,t],r.length+t.length)}function ls(e){let t=He(e);if(e=e.slice(Rt(t)),e.length!==t)throw new Error("inconsistent lengths");return q(e)}function Fh(e){let t;e[0]==="Q"||e[0]==="1"?t=ue(Q.decode(`z${e}`)).bytes:t=Z.parse(e).multihash.bytes;let r=Uint8Array.from(hr(t.length));return bt([r,t],r.length+t.length)}function Mh(e){let t=Kh.decode(e),r=Uint8Array.from(hr(t.length));return bt([r,t],r.length+t.length)}function Vh(e){let t=He(e),r=e.slice(Rt(t));if(r.length!==t)throw new Error("inconsistent lengths");return"u"+q(r,"base64url")}function qh(e){let t=He(e),r=e.slice(Rt(t));if(r.length!==t)throw new Error("inconsistent lengths");return q(r,"base58btc")}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!==16)throw new Error(`failed to parse onion addr: ${t[0]} not a Tor onion address.`);let r=jt.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=ps(n);return bt([r,o],r.length+o.length)}function Hh(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=jt.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=ps(n);return bt([r,o],r.length+o.length)}function Wc(e){let t=e.slice(0,e.length-2),r=e.slice(e.length-2),n=q(t,"base32"),o=Xc(r);return`${n}:${o}`}function Jc(e){e=ms(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],c=et(s);if(c.size===0){t.push([c.code]),r.push([c.code]);continue}if(i++,i>=o.length)throw new jn("invalid address: "+e);if(c.path===!0){n=ms(o.slice(i).join("/")),t.push([c.code,hs(c.code,n)]),r.push([c.code,n]);break}let a=hs(c.code,o[i]);t.push([c.code,a]),r.push([c.code,ds(c.code,a)])}return{string:Qc(r),bytes:Gn(t),tuples:t,stringTuples:r,path:n}}function ys(e){let t=[],r=[],n=null,o=0;for(;o<e.length;){let i=He(e,o),s=Rt(i),c=et(i),a=zh(c,e.slice(o+s));if(a===0){t.push([i]),r.push([i]),o+=s;continue}let l=e.slice(o+s,o+s+a);if(o+=a+s,o>e.length)throw new jn("Invalid address Uint8Array: "+q(e,"base16"));t.push([i,l]);let u=ds(i,l);if(r.push([i,u]),c.path===!0){n=u;break}}return{bytes:Uint8Array.from(e),string:Qc(r),tuples:t,stringTuples:r,path:n}}function Qc(e){let t=[];return e.map(r=>{let n=et(r[0]);return t.push(n.name),r.length>1&&r[1]!=null&&t.push(r[1]),null}),ms(t.join("/"))}function Gn(e){return bt(e.map(t=>{let r=et(t[0]),n=Uint8Array.from(hr(r.code));return t.length>1&&t[1]!=null&&(n=bt([n,t[1]])),n}))}function zh(e,t){if(e.size>0)return e.size/8;if(e.size===0)return 0;{let r=He(t instanceof Uint8Array?t:Uint8Array.from(t));return r+Rt(r)}}function ms(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 jh=Symbol.for("nodejs.util.inspect.custom"),xs=Symbol.for("@multiformats/js-multiaddr/multiaddr"),Gh=[et("dns").code,et("dns4").code,et("dns6").code,et("dnsaddr").code],gs=class extends Error{constructor(t="No available resolver"){super(t),this.name="NoAvailableResolverError"}},Zn=class e{bytes;#t;#r;#e;#a;[xs]=!0;constructor(t){t==null&&(t="");let r;if(t instanceof Uint8Array)r=ys(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(eu(t))r=ys(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=et("tcp"),c=et("udp"),a=et("ip4"),l=et("ip6"),u=et("dns6"),f=et("ip6zone");for(let[S,_]of this.stringTuples())S===f.code&&(i=`%${_??""}`),Gh.includes(S)&&(r=s.name==="tcp"?"tcp":"udp",o=443,n=`${_??""}${i}`,t=S===u.code?6:4),(S===s.code||S===c.code)&&(r=et(S).name==="tcp"?"tcp":"udp",o=parseInt(_??"")),(S===a.code||S===l.code)&&(r=et(S).name==="tcp"?"tcp":"udp",n=`${_??""}${i}`,t=S===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({},et(t)))}protoCodes(){return this.#r.map(([t])=>t)}protoNames(){return this.#r.map(([t])=>et(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===Er.p2p.code&&t.push([n,o]),n===Er["p2p-circuit"].code&&(t=[])});let r=t.pop();if(r?.[1]!=null){let n=r[1];return n[0]==="Q"||n[0]==="1"?q(Q.decode(`z${n}`),"base58btc"):q(Z.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){return this.#a}equals(t){return rt(this.bytes,t.bytes)}async resolve(t){let r=this.protos().find(i=>i.resolvable);if(r==null)return[this];let n=tu.get(r.name);if(n==null)throw new gs(`no available resolver for ${r.name}`);return(await n(this,t)).map(i=>Ge(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)}[jh](){return`Multiaddr(${this.#t})`}};var tu=new Map;function eu(e){return!!e?.[xs]}function Ge(e){return new Zn(e)}function Qr(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*Yn(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 Zh="/",Yh=new TextEncoder().encode(Zh),Nb=Yh[0];var Pp=Io(bs(),1);var Wt=class extends Error{static name="SignatureVerificationError";constructor(t="Record signature verification failed"){super(t),this.name="SignatureVerificationError"}},Wn=class extends Error{static name="RecordExpiredError";constructor(t="Record has expired"){super(t),this.name="RecordExpiredError"}},Sr=class extends Error{static name="UnsupportedValidityError";constructor(t="The validity type is unsupported"){super(t),this.name="UnsupportedValidityError"}},Xn=class extends Error{static name="RecordTooLargeError";constructor(t="The record is too large"){super(t),this.name="RecordTooLargeError"}},Jn=class extends Error{static name="InvalidValueError";constructor(t="Value must be a valid content path starting with /"){super(t),this.name="InvalidValueError"}},Qn=class extends Error{static name="InvalidRecordDataError";constructor(t="Invalid record data"){super(t),this.name="InvalidRecordDataError"}},tn=class extends Error{static name="InvalidEmbeddedPublicKeyError";constructor(t="Invalid embedded public key"){super(t),this.name="InvalidEmbeddedPublicKeyError"}};var Xt;(function(e){let t;(function(o){o.EOL="EOL"})(t=e.ValidityType||(e.ValidityType={}));let r;(function(o){o[o.EOL=0]="EOL"})(r||(r={})),function(o){o.codec=()=>Gr(r)}(t=e.ValidityType||(e.ValidityType={}));let n;e.codec=()=>(n==null&&(n=gr((o,i,s={})=>{s.lengthDelimited!==!1&&i.fork(),o.value!=null&&(i.uint32(10),i.bytes(o.value)),o.signatureV1!=null&&(i.uint32(18),i.bytes(o.signatureV1)),o.validityType!=null&&(i.uint32(24),e.ValidityType.codec().encode(o.validityType,i)),o.validity!=null&&(i.uint32(34),i.bytes(o.validity)),o.sequence!=null&&(i.uint32(40),i.uint64(o.sequence)),o.ttl!=null&&(i.uint32(48),i.uint64(o.ttl)),o.pubKey!=null&&(i.uint32(58),i.bytes(o.pubKey)),o.signatureV2!=null&&(i.uint32(66),i.bytes(o.signatureV2)),o.data!=null&&(i.uint32(74),i.bytes(o.data)),s.lengthDelimited!==!1&&i.ldelim()},(o,i,s={})=>{let c={},a=i==null?o.len:o.pos+i;for(;o.pos<a;){let l=o.uint32();switch(l>>>3){case 1:{c.value=o.bytes();break}case 2:{c.signatureV1=o.bytes();break}case 3:{c.validityType=e.ValidityType.codec().decode(o);break}case 4:{c.validity=o.bytes();break}case 5:{c.sequence=o.uint64();break}case 6:{c.ttl=o.uint64();break}case 7:{c.pubKey=o.bytes();break}case 8:{c.signatureV2=o.bytes();break}case 9:{c.data=o.bytes();break}default:{o.skipType(l&7);break}}}return c})),n),e.encode=o=>mr(o,e.codec()),e.decode=(o,i)=>pr(o,e.codec(),i)})(Xt||(Xt={}));var Wh=["string","number","bigint","symbol"],Xh=["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 ru(e){if(e===null)return"null";if(e===void 0)return"undefined";if(e===!0||e===!1)return"boolean";let t=typeof e;if(Wh.includes(t))return t;if(t==="function")return"Function";if(Array.isArray(e))return"Array";if(Jh(e))return"Buffer";let r=Qh(e);return r||"Object"}function Jh(e){return e&&e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer.call(null,e)}function Qh(e){let t=Object.prototype.toString.call(e).slice(8,-1);if(Xh.includes(t))return t}var m=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}};m.uint=new m(0,"uint",!0);m.negint=new m(1,"negint",!0);m.bytes=new m(2,"bytes",!0);m.string=new m(3,"string",!0);m.array=new m(4,"array",!1);m.map=new m(5,"map",!1);m.tag=new m(6,"tag",!1);m.float=new m(7,"float",!0);m.false=new m(7,"false",!0);m.true=new m(7,"true",!0);m.null=new m(7,"null",!0);m.undefined=new m(7,"undefined",!0);m.break=new m(7,"break",!0);var D=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 vr=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&typeof globalThis.Buffer.isBuffer=="function",tp=new TextDecoder,ep=new TextEncoder;function to(e){return vr&&globalThis.Buffer.isBuffer(e)}function su(e){return e instanceof Uint8Array?to(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e:Uint8Array.from(e)}var au=vr?(e,t,r)=>r-t>64?globalThis.Buffer.from(e.subarray(t,r)).toString("utf8"):ou(e,t,r):(e,t,r)=>r-t>64?tp.decode(e.subarray(t,r)):ou(e,t,r),cu=vr?e=>e.length>64?globalThis.Buffer.from(e):nu(e):e=>e.length>64?ep.encode(e):nu(e);var Ar=vr?(e,t,r)=>to(e)?new Uint8Array(e.subarray(t,r)):e.slice(t,r):(e,t,r)=>e.slice(t,r),uu=vr?(e,t)=>(e=e.map(r=>r instanceof Uint8Array?r:globalThis.Buffer.from(r)),su(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},fu=vr?e=>globalThis.Buffer.allocUnsafe(e):e=>new Uint8Array(e);function lu(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 nu(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 ou(e,t,r){let n=[];for(;t<r;){let o=e[t],i=null,s=o>239?4:o>223?3:o>191?2:1;if(t+s<=r){let c,a,l,u;switch(s){case 1:o<128&&(i=o);break;case 2:c=e[t+1],(c&192)===128&&(u=(o&31)<<6|c&63,u>127&&(i=u));break;case 3:c=e[t+1],a=e[t+2],(c&192)===128&&(a&192)===128&&(u=(o&15)<<12|(c&63)<<6|a&63,u>2047&&(u<55296||u>57343)&&(i=u));break;case 4:c=e[t+1],a=e[t+2],l=e[t+3],(c&192)===128&&(a&192)===128&&(l&192)===128&&(u=(o&15)<<18|(c&63)<<12|(a&63)<<6|l&63,u>65535&&u<1114112&&(i=u))}}i===null?(i=65533,s=1):i>65535&&(i-=65536,n.push(i>>>10&1023|55296),i=56320|i&1023),n.push(i),t+=s}return rp(n)}var iu=4096;function rp(e){let t=e.length;if(t<=iu)return String.fromCharCode.apply(String,e);let r="",n=0;for(;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=iu));return r}var np=256,eo=class{constructor(t=np){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=fu(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=Ar(n,0,this.cursor)}else r=uu(this.chunks,this.cursor);return t&&this.reset(),r}};var M="CBOR decode error:",Es="CBOR encode error:",en=[];en[23]=1;en[24]=2;en[25]=3;en[26]=5;en[27]=9;function be(e,t,r){if(e.length-t<r)throw new Error(`${M} not enough data for type`)}var pt=[24,256,65536,4294967296,BigInt("18446744073709551616")];function Ft(e,t,r){be(e,t,1);let n=e[t];if(r.strict===!0&&n<pt[0])throw new Error(`${M} integer encoded in more bytes than necessary (strict decode)`);return n}function Mt(e,t,r){be(e,t,2);let n=e[t]<<8|e[t+1];if(r.strict===!0&&n<pt[1])throw new Error(`${M} integer encoded in more bytes than necessary (strict decode)`);return n}function Vt(e,t,r){be(e,t,4);let n=e[t]*16777216+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3];if(r.strict===!0&&n<pt[2])throw new Error(`${M} integer encoded in more bytes than necessary (strict decode)`);return n}function qt(e,t,r){be(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<pt[3])throw new Error(`${M} integer encoded in more bytes than necessary (strict decode)`);if(i<=Number.MAX_SAFE_INTEGER)return Number(i);if(r.allowBigInt===!0)return i;throw new Error(`${M} integers outside of the safe integer range are not supported`)}function du(e,t,r,n){return new D(m.uint,Ft(e,t+1,n),2)}function hu(e,t,r,n){return new D(m.uint,Mt(e,t+1,n),3)}function pu(e,t,r,n){return new D(m.uint,Vt(e,t+1,n),5)}function mu(e,t,r,n){return new D(m.uint,qt(e,t+1,n),9)}function $t(e,t){return gt(e,0,t.value)}function gt(e,t,r){if(r<pt[0]){let n=Number(r);e.push([t|n])}else if(r<pt[1]){let n=Number(r);e.push([t|24,n])}else if(r<pt[2]){let n=Number(r);e.push([t|25,n>>>8,n&255])}else if(r<pt[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<pt[4]){let o=[t|27,0,0,0,0,0,0,0],i=Number(n&BigInt(4294967295)),s=Number(n>>BigInt(32)&BigInt(4294967295));o[8]=i&255,i=i>>8,o[7]=i&255,i=i>>8,o[6]=i&255,i=i>>8,o[5]=i&255,o[4]=s&255,s=s>>8,o[3]=s&255,s=s>>8,o[2]=s&255,s=s>>8,o[1]=s&255,e.push(o)}else throw new Error(`${M} encountered BigInt larger than allowable range`)}}$t.encodedSize=function(t){return gt.encodedSize(t.value)};gt.encodedSize=function(t){return t<pt[0]?1:t<pt[1]?2:t<pt[2]?3:t<pt[3]?5:9};$t.compareTokens=function(t,r){return t.value<r.value?-1:t.value>r.value?1:0};function yu(e,t,r,n){return new D(m.negint,-1-Ft(e,t+1,n),2)}function gu(e,t,r,n){return new D(m.negint,-1-Mt(e,t+1,n),3)}function xu(e,t,r,n){return new D(m.negint,-1-Vt(e,t+1,n),5)}var Ss=BigInt(-1),wu=BigInt(1);function bu(e,t,r,n){let o=qt(e,t+1,n);if(typeof o!="bigint"){let i=-1-o;if(i>=Number.MIN_SAFE_INTEGER)return new D(m.negint,i,9)}if(n.allowBigInt!==!0)throw new Error(`${M} integers outside of the safe integer range are not supported`);return new D(m.negint,Ss-BigInt(o),9)}function ro(e,t){let r=t.value,n=typeof r=="bigint"?r*Ss-wu:r*-1-1;gt(e,t.type.majorEncoded,n)}ro.encodedSize=function(t){let r=t.value,n=typeof r=="bigint"?r*Ss-wu:r*-1-1;return n<pt[0]?1:n<pt[1]?2:n<pt[2]?3:n<pt[3]?5:9};ro.compareTokens=function(t,r){return t.value<r.value?1:t.value>r.value?-1:0};function rn(e,t,r,n){be(e,t,r+n);let o=Ar(e,t+r,t+r+n);return new D(m.bytes,o,r+n)}function Eu(e,t,r,n){return rn(e,t,1,r)}function Su(e,t,r,n){return rn(e,t,2,Ft(e,t+1,n))}function vu(e,t,r,n){return rn(e,t,3,Mt(e,t+1,n))}function Au(e,t,r,n){return rn(e,t,5,Vt(e,t+1,n))}function Iu(e,t,r,n){let o=qt(e,t+1,n);if(typeof o=="bigint")throw new Error(`${M} 64-bit integer bytes lengths not supported`);return rn(e,t,9,o)}function no(e){return e.encodedBytes===void 0&&(e.encodedBytes=e.type===m.string?cu(e.value):e.value),e.encodedBytes}function Ir(e,t){let r=no(t);gt(e,t.type.majorEncoded,r.length),e.push(r)}Ir.encodedSize=function(t){let r=no(t);return gt.encodedSize(r.length)+r.length};Ir.compareTokens=function(t,r){return ip(no(t),no(r))};function ip(e,t){return e.length<t.length?-1:e.length>t.length?1:lu(e,t)}function nn(e,t,r,n,o){let i=r+n;be(e,t,i);let s=new D(m.string,au(e,t+r,t+i),i);return o.retainStringBytes===!0&&(s.byteValue=Ar(e,t+r,t+i)),s}function Tu(e,t,r,n){return nn(e,t,1,r,n)}function Cu(e,t,r,n){return nn(e,t,2,Ft(e,t+1,n),n)}function Bu(e,t,r,n){return nn(e,t,3,Mt(e,t+1,n),n)}function Pu(e,t,r,n){return nn(e,t,5,Vt(e,t+1,n),n)}function _u(e,t,r,n){let o=qt(e,t+1,n);if(typeof o=="bigint")throw new Error(`${M} 64-bit integer string lengths not supported`);return nn(e,t,9,o,n)}var Uu=Ir;function Tr(e,t,r,n){return new D(m.array,n,r)}function Nu(e,t,r,n){return Tr(e,t,1,r)}function Ru(e,t,r,n){return Tr(e,t,2,Ft(e,t+1,n))}function Lu(e,t,r,n){return Tr(e,t,3,Mt(e,t+1,n))}function Du(e,t,r,n){return Tr(e,t,5,Vt(e,t+1,n))}function ku(e,t,r,n){let o=qt(e,t+1,n);if(typeof o=="bigint")throw new Error(`${M} 64-bit integer array lengths not supported`);return Tr(e,t,9,o)}function Ku(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${M} indefinite length items not allowed`);return Tr(e,t,1,1/0)}function oo(e,t){gt(e,m.array.majorEncoded,t.value)}oo.compareTokens=$t.compareTokens;oo.encodedSize=function(t){return gt.encodedSize(t.value)};function Cr(e,t,r,n){return new D(m.map,n,r)}function Ou(e,t,r,n){return Cr(e,t,1,r)}function Fu(e,t,r,n){return Cr(e,t,2,Ft(e,t+1,n))}function Mu(e,t,r,n){return Cr(e,t,3,Mt(e,t+1,n))}function Vu(e,t,r,n){return Cr(e,t,5,Vt(e,t+1,n))}function qu(e,t,r,n){let o=qt(e,t+1,n);if(typeof o=="bigint")throw new Error(`${M} 64-bit integer map lengths not supported`);return Cr(e,t,9,o)}function $u(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${M} indefinite length items not allowed`);return Cr(e,t,1,1/0)}function io(e,t){gt(e,m.map.majorEncoded,t.value)}io.compareTokens=$t.compareTokens;io.encodedSize=function(t){return gt.encodedSize(t.value)};function Hu(e,t,r,n){return new D(m.tag,r,1)}function zu(e,t,r,n){return new D(m.tag,Ft(e,t+1,n),2)}function ju(e,t,r,n){return new D(m.tag,Mt(e,t+1,n),3)}function Gu(e,t,r,n){return new D(m.tag,Vt(e,t+1,n),5)}function Zu(e,t,r,n){return new D(m.tag,qt(e,t+1,n),9)}function so(e,t){gt(e,m.tag.majorEncoded,t.value)}so.compareTokens=$t.compareTokens;so.encodedSize=function(t){return gt.encodedSize(t.value)};var lp=20,dp=21,hp=22,pp=23;function Yu(e,t,r,n){if(n.allowUndefined===!1)throw new Error(`${M} undefined values are not supported`);return n.coerceUndefinedToNull===!0?new D(m.null,null,1):new D(m.undefined,void 0,1)}function Wu(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${M} indefinite length items not allowed`);return new D(m.break,void 0,1)}function vs(e,t,r){if(r){if(r.allowNaN===!1&&Number.isNaN(e))throw new Error(`${M} NaN values are not supported`);if(r.allowInfinity===!1&&(e===1/0||e===-1/0))throw new Error(`${M} Infinity values are not supported`)}return new D(m.float,e,t)}function Xu(e,t,r,n){return vs(As(e,t+1),3,n)}function Ju(e,t,r,n){return vs(Is(e,t+1),5,n)}function Qu(e,t,r,n){return vs(nf(e,t+1),9,n)}function ao(e,t,r){let n=t.value;if(n===!1)e.push([m.float.majorEncoded|lp]);else if(n===!0)e.push([m.float.majorEncoded|dp]);else if(n===null)e.push([m.float.majorEncoded|hp]);else if(n===void 0)e.push([m.float.majorEncoded|pp]);else{let o,i=!1;(!r||r.float64!==!0)&&(ef(n),o=As(Jt,1),n===o||Number.isNaN(n)?(Jt[0]=249,e.push(Jt.slice(0,3)),i=!0):(rf(n),o=Is(Jt,1),n===o&&(Jt[0]=250,e.push(Jt.slice(0,5)),i=!0))),i||(mp(n),o=nf(Jt,1),Jt[0]=251,e.push(Jt.slice(0,9)))}}ao.encodedSize=function(t,r){let n=t.value;if(n===!1||n===!0||n===null||n===void 0)return 1;if(!r||r.float64!==!0){ef(n);let o=As(Jt,1);if(n===o||Number.isNaN(n))return 3;if(rf(n),o=Is(Jt,1),n===o)return 5}return 9};var tf=new ArrayBuffer(9),Ht=new DataView(tf,1),Jt=new Uint8Array(tf,0);function ef(e){if(e===1/0)Ht.setUint16(0,31744,!1);else if(e===-1/0)Ht.setUint16(0,64512,!1);else if(Number.isNaN(e))Ht.setUint16(0,32256,!1);else{Ht.setFloat32(0,e);let t=Ht.getUint32(0),r=(t&2139095040)>>23,n=t&8388607;if(r===255)Ht.setUint16(0,31744,!1);else if(r===0)Ht.setUint16(0,(e&2147483648)>>16|n>>13,!1);else{let o=r-127;o<-24?Ht.setUint16(0,0):o<-14?Ht.setUint16(0,(t&2147483648)>>16|1<<24+o,!1):Ht.setUint16(0,(t&2147483648)>>16|o+15<<10|n>>13,!1)}}}function As(e,t){if(e.length-t<2)throw new Error(`${M} not enough data for float16`);let r=(e[t]<<8)+e[t+1];if(r===31744)return 1/0;if(r===64512)return-1/0;if(r===32256)return NaN;let n=r>>10&31,o=r&1023,i;return n===0?i=o*2**-24:n!==31?i=(o+1024)*2**(n-25):i=o===0?1/0:NaN,r&32768?-i:i}function rf(e){Ht.setFloat32(0,e,!1)}function Is(e,t){if(e.length-t<4)throw new Error(`${M} not enough data for float32`);let r=(e.byteOffset||0)+t;return new DataView(e.buffer,r,4).getFloat32(0,!1)}function mp(e){Ht.setFloat64(0,e,!1)}function nf(e,t){if(e.length-t<8)throw new Error(`${M} not enough data for float64`);let r=(e.byteOffset||0)+t;return new DataView(e.buffer,r,8).getFloat64(0,!1)}ao.compareTokens=$t.compareTokens;function Y(e,t,r){throw new Error(`${M} encountered invalid minor (${r}) for major ${e[t]>>>5}`)}function co(e){return()=>{throw new Error(`${M} ${e}`)}}var P=[];for(let e=0;e<=23;e++)P[e]=Y;P[24]=du;P[25]=hu;P[26]=pu;P[27]=mu;P[28]=Y;P[29]=Y;P[30]=Y;P[31]=Y;for(let e=32;e<=55;e++)P[e]=Y;P[56]=yu;P[57]=gu;P[58]=xu;P[59]=bu;P[60]=Y;P[61]=Y;P[62]=Y;P[63]=Y;for(let e=64;e<=87;e++)P[e]=Eu;P[88]=Su;P[89]=vu;P[90]=Au;P[91]=Iu;P[92]=Y;P[93]=Y;P[94]=Y;P[95]=co("indefinite length bytes/strings are not supported");for(let e=96;e<=119;e++)P[e]=Tu;P[120]=Cu;P[121]=Bu;P[122]=Pu;P[123]=_u;P[124]=Y;P[125]=Y;P[126]=Y;P[127]=co("indefinite length bytes/strings are not supported");for(let e=128;e<=151;e++)P[e]=Nu;P[152]=Ru;P[153]=Lu;P[154]=Du;P[155]=ku;P[156]=Y;P[157]=Y;P[158]=Y;P[159]=Ku;for(let e=160;e<=183;e++)P[e]=Ou;P[184]=Fu;P[185]=Mu;P[186]=Vu;P[187]=qu;P[188]=Y;P[189]=Y;P[190]=Y;P[191]=$u;for(let e=192;e<=215;e++)P[e]=Hu;P[216]=zu;P[217]=ju;P[218]=Gu;P[219]=Zu;P[220]=Y;P[221]=Y;P[222]=Y;P[223]=Y;for(let e=224;e<=243;e++)P[e]=co("simple values are not supported");P[244]=Y;P[245]=Y;P[246]=Y;P[247]=Yu;P[248]=co("simple values are not supported");P[249]=Xu;P[250]=Ju;P[251]=Qu;P[252]=Y;P[253]=Y;P[254]=Y;P[255]=Wu;var Qt=[];for(let e=0;e<24;e++)Qt[e]=new D(m.uint,e,1);for(let e=-1;e>=-24;e--)Qt[31-e]=new D(m.negint,e,1);Qt[64]=new D(m.bytes,new Uint8Array(0),1);Qt[96]=new D(m.string,"",1);Qt[128]=new D(m.array,0,1);Qt[160]=new D(m.map,0,1);Qt[244]=new D(m.false,!1,1);Qt[245]=new D(m.true,!0,1);Qt[246]=new D(m.null,null,1);function gp(){let e=[];return e[m.uint.major]=$t,e[m.negint.major]=ro,e[m.bytes.major]=Ir,e[m.string.major]=Uu,e[m.array.major]=oo,e[m.map.major]=io,e[m.tag.major]=so,e[m.float.major]=ao,e}var _1=gp(),U1=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(`${Es} object contains circular references`);return new e(r,t)}},Re={null:new D(m.null,null),undefined:new D(m.undefined,void 0),true:new D(m.true,!0),false:new D(m.false,!1),emptyArray:new D(m.array,0),emptyMap:new D(m.map,0)},Le={number(e,t,r,n){return!Number.isInteger(e)||!Number.isSafeInteger(e)?new D(m.float,e):e>=0?new D(m.uint,e):new D(m.negint,e)},bigint(e,t,r,n){return e>=BigInt(0)?new D(m.uint,e):new D(m.negint,e)},Uint8Array(e,t,r,n){return new D(m.bytes,e)},string(e,t,r,n){return new D(m.string,e)},boolean(e,t,r,n){return e?Re.true:Re.false},null(e,t,r,n){return Re.null},undefined(e,t,r,n){return Re.undefined},ArrayBuffer(e,t,r,n){return new D(m.bytes,new Uint8Array(e))},DataView(e,t,r,n){return new D(m.bytes,new Uint8Array(e.buffer,e.byteOffset,e.byteLength))},Array(e,t,r,n){if(!e.length)return r.addBreakTokens===!0?[Re.emptyArray,new D(m.break)]:Re.emptyArray;n=uo.createCheck(n,e);let o=[],i=0;for(let s of e)o[i++]=Ts(s,r,n);return r.addBreakTokens?[new D(m.array,e.length),o,new D(m.break)]:[new D(m.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?[Re.emptyMap,new D(m.break)]:Re.emptyMap;n=uo.createCheck(n,e);let c=[],a=0;for(let l of i)c[a++]=[Ts(l,r,n),Ts(o?e.get(l):e[l],r,n)];return xp(c,r),r.addBreakTokens?[new D(m.map,s),c,new D(m.break)]:[new D(m.map,s),c]}};Le.Map=Le.Object;Le.Buffer=Le.Uint8Array;for(let e of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))Le[`${e}Array`]=Le.DataView;function Ts(e,t={},r){let n=ru(e),o=t&&t.typeEncoders&&t.typeEncoders[n]||Le[n];if(typeof o=="function"){let s=o(e,n,t,r);if(s!=null)return s}let i=Le[n];if(!i)throw new Error(`${Es} unsupported type: ${n}`);return i(e,n,t,r)}function xp(e,t){t.mapSorter&&e.sort(t.mapSorter)}var wp={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=Qt[t];if(r===void 0){let n=P[t];if(!n)throw new Error(`${M} no decoder for major type ${t>>>5} (byte 0x${t.toString(16).padStart(2,"0")})`);let o=t&31;r=n(this.data,this._pos,o,this.options)}return this._pos+=r.encodedLength,r}},on=Symbol.for("DONE"),lo=Symbol.for("BREAK");function bp(e,t,r){let n=[];for(let o=0;o<e.value;o++){let i=Br(t,r);if(i===lo){if(e.value===1/0)break;throw new Error(`${M} got unexpected break to lengthed array`)}if(i===on)throw new Error(`${M} found array but not enough entries (got ${o}, expected ${e.value})`);n[o]=i}return n}function Ep(e,t,r){let n=r.useMaps===!0,o=n?void 0:{},i=n?new Map:void 0;for(let s=0;s<e.value;s++){let c=Br(t,r);if(c===lo){if(e.value===1/0)break;throw new Error(`${M} got unexpected break to lengthed map`)}if(c===on)throw new Error(`${M} found map but not enough entries (got ${s} [no key], expected ${e.value})`);if(n!==!0&&typeof c!="string")throw new Error(`${M} non-string keys not supported (got ${typeof c})`);if(r.rejectDuplicateMapKeys===!0&&(n&&i.has(c)||!n&&c in o))throw new Error(`${M} found repeat map key "${c}"`);let a=Br(t,r);if(a===on)throw new Error(`${M} found map but not enough entries (got ${s} [no value], expected ${e.value})`);n?i.set(c,a):o[c]=a}return n?i:o}function Br(e,t){if(e.done())return on;let r=e.next();if(r.type===m.break)return lo;if(r.type.terminal)return r.value;if(r.type===m.array)return bp(r,e,t);if(r.type===m.map)return Ep(r,e,t);if(r.type===m.tag){if(t.tags&&typeof t.tags[r.value]=="function"){let n=Br(e,t);return t.tags[r.value](n)}throw new Error(`${M} tag not supported (${r.value})`)}throw new Error("unsupported")}function of(e,t){if(!(e instanceof Uint8Array))throw new Error(`${M} data to decode must be a Uint8Array`);t=Object.assign({},wp,t);let r=t.tokenizer||new fo(e,t),n=Br(r,t);if(n===on)throw new Error(`${M} did not find any content to decode`);if(n===lo)throw new Error(`${M} got unexpected break`);return[n,e.subarray(r.pos())]}function Cs(e,t){let[r,n]=of(e,t);if(n.length>0)throw new Error(`${M} too many terminals, data makes no sense`);return r}var Ap=ve("ipns:utils"),sf=H("/ipns/");var Ip=0,Tp=18;function af(e){let t;if(e.pubKey!=null)try{t=Kc(e.pubKey)}catch(r){throw Ap.error(r),r}if(t!=null)return t}function cf(e){let t=H("ipns-signature:");return bt([t,e])}function Ye(e){return"signatureV1"in e?Xt.encode({value:H(e.value),signatureV1:e.signatureV1,validityType:e.validityType,validity:H(e.validity),sequence:e.sequence,ttl:e.ttl,pubKey:e.pubKey,signatureV2:e.signatureV2,data:e.data}):Xt.encode({pubKey:e.pubKey,signatureV2:e.signatureV2,data:e.data})}function se(e){let t=Xt.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 Wt("Missing data or signatureV2");let r=uf(t.data),n=Cp(r.Value),o=q(r.Validity);if(t.value!=null&&t.signatureV1!=null)return Bp(t),{value:n,validityType:Xt.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:Xt.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 sn(e){return bt([sf,e.bytes])}function Ee(e){let t=ue(e.slice(sf.length));if(!ho(t,Ip)&&!ho(t,Tp))throw new Xe("Multihash in IPNS key was not identity or sha2-256");return t}function uf(e){let t=Cs(e);if(t.ValidityType===0)t.ValidityType=Xt.ValidityType.EOL;else throw new Sr("The validity type is unsupported");return Number.isInteger(t.Sequence)&&(t.Sequence=BigInt(t.Sequence)),Number.isInteger(t.TTL)&&(t.TTL=BigInt(t.TTL)),t}function Cp(e){let t=q(e).trim();if(t.startsWith("/"))return t;try{return`/ipfs/${Z.decode(e).toV1().toString()}`}catch{}try{return`/ipfs/${Z.parse(t).toV1().toString()}`}catch{}throw new Jn("Value must be a valid content path starting with /")}function Bp(e){if(e.data==null)throw new Qn("Record data is missing");let t=uf(e.data);if(!rt(t.Value,e.value??new Uint8Array(0)))throw new Wt('Field "value" did not match between protobuf and CBOR');if(!rt(t.Validity,e.validity??new Uint8Array(0)))throw new Wt('Field "validity" did not match between protobuf and CBOR');if(t.ValidityType!==e.validityType)throw new Wt('Field "validityType" did not match between protobuf and CBOR');if(t.Sequence!==e.sequence)throw new Wt('Field "sequence" did not match between protobuf and CBOR');if(t.TTL!==e.ttl)throw new Wt('Field "ttl" did not match between protobuf and CBOR')}function ho(e,t){return e.code===t}var e2=ve("ipns"),r2=5*60*1e9,_p="/ipns/",n2=_p.length;var ff=Io(bs(),1);var po=ve("ipns:validator"),Up=1024*10,Np=async(e,t)=>{let r=se(t),n;try{let o=cf(r.data);n=await e.verify(o,r.signatureV2)}catch{n=!1}if(!n)throw po.error("record signature verification failed"),new Wt("Record signature verification failed");if(r.validityType===Xt.ValidityType.EOL){if(ff.default.fromString(r.validity).toDate().getTime()<Date.now())throw po.error("record has expired"),new Wn("record has expired")}else if(r.validityType!=null)throw po.error("the validity type is unsupported"),new Sr("The validity type is unsupported");po("ipns record for %s is valid",r.value)};async function lf(e,t){if(t.byteLength>Up)throw new Xn("The record is too large");let r=Ee(e),n;ho(r,0)&&(n=Fn(r));let o=se(t),i=af(o)??n;if(i==null)throw new tn("Could not extract public key from IPNS record or routing key");let s=sn(i.toMultihash());if(!rt(s,e))throw new tn("Embedded public key did not match routing key");await Np(i,t)}var mo=class extends Error{name="InvalidMessageLengthError";code="ERR_INVALID_MESSAGE_LENGTH"};async function*an(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)),or(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 c=0;c<s.length;c++)yield JSON.parse(s[c])}o+=n.decode(),o!==""&&(yield JSON.parse(o))}function ae(){let e={};return e.promise=new Promise((t,r)=>{e.resolve=t,e.reject=r}),e}var Ps=Io(hf(),1);var un=class extends Error{constructor(t){super(t),this.name="TimeoutError"}},_s=class extends Error{constructor(t){super(),this.name="AbortError",this.message=t}},pf=e=>globalThis.DOMException===void 0?new _s(e):new DOMException(e),mf=e=>{let t=e.reason===void 0?pf("This operation was aborted."):e.reason;return t instanceof Error?t:pf(t)};function Us(e,t){let{milliseconds:r,fallback:n,message:o,customTimers:i={setTimeout,clearTimeout}}=t,s,c,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:S}=t;S.aborted&&f(mf(S)),c=()=>{f(mf(S))},S.addEventListener("abort",c,{once:!0})}if(r===Number.POSITIVE_INFINITY){e.then(u,f);return}let p=new un;s=i.setTimeout.call(void 0,()=>{if(n){try{u(n())}catch(S){f(S)}return}typeof e.cancel=="function"&&e.cancel(),o===!1?u():o instanceof Error?f(o):(p.message=o??`Promise timed out after ${r} milliseconds`,f(p))},r),(async()=>{try{u(await e)}catch(S){f(S)}})()}).finally(()=>{l.clear(),c&&t.signal&&t.signal.removeEventListener("abort",c)});return l.clear=()=>{i.clearTimeout.call(void 0,s),s=void 0},l}function Ns(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 fn=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=Ns(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 ln=class extends Ps.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:fn,...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=Us(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 un&&!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 Pr=class extends Error{static name="InvalidRequestError";constructor(t="Invalid request"){super(t),this.name="InvalidRequestError"}},te=class extends Error{static name="BadResponseError";constructor(t="Bad response"){super(t),this.name="BadResponseError"}};function Dp(e){return e[Symbol.asyncIterator]!=null}function kp(e){if(Dp(e))return(async()=>{for await(let t of e)return t})();for(let t of e)return t}var go=kp;function Kp(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 yf=Kp;function Op(e){return e[Symbol.asyncIterator]!=null}function Fp(e,t){let r=0;if(Op(e))return async function*(){for await(let a of e)yield t(a,r++)}();let n=yf(e),{value:o,done:i}=n.next();if(i===!0)return function*(){}();let s=t(o,r++);if(typeof s.then=="function")return async function*(){yield await s;for(let a of n)yield t(a,r++)}();let c=t;return function*(){yield s;for(let a of n)yield c(a,r++)}()}var xo=Fp;var gf=H("/ipns/");function xf(e){return rt(e.subarray(0,gf.byteLength),gf)}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(!xf(t))return;let o=Ee(t),i=Z.createV1(114,o),s=se(r);await this.client.putIPNS(i,s,n)}async get(t,r){if(!xf(t))throw new Pt("Not found");let n=Ee(t),o=Z.createV1(114,n);try{let i=await this.client.getIPNS(o,r);return Ye(i)}catch(i){throw i.name==="BadResponseError"?new Pt("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 Pt("Not found")}async*getClosestPeers(t,r={}){}};var xt=ve("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 ln({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[js](){return this.contentRouting}get[Gs](){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&&xt("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={}){xt("getProviders starts: %c",t);let n=AbortSignal.timeout(this.timeout),o=Qr([this.shutDownController.signal,n,r.signal]);let i=ae(),s=ae();this.httpQueue.add(async()=>(i.resolve(),s.promise));try{await i.promise;let c=new URL(`${this.clientUrl}routing/v1/providers/${t.toString()}`);this.#r(c,r.filterAddrs,r.filterProtocols);let a={headers:{Accept:"application/x-ndjson"},signal:o},l=await this.#e(c.toString(),a);if(l==null)throw new te("No response received");if(!l.ok)throw l.status===404?new Pt("No matching records found"):l.status===422?new Pr("Request does not conform to schema or semantic constraints"):new te(`Unexpected status code: ${l.status}`);if(l.body==null)throw new te("Routing response had no body");let u=l.headers.get("Content-Type");if(u==null)throw new te("No Content-Type header received");if(u?.startsWith("application/json")){let f=await l.json();for(let p of f.Providers){let S=this.#t(p);S!=null&&(yield S)}}else if(u.includes("application/x-ndjson"))for await(let f of an(Yn(l.body))){let p=this.#t(f);p!=null&&(yield p)}else throw new te(`Unsupported Content-Type: ${u}`)}finally{o.clear(),s.resolve(),xt("getProviders finished: %c",t)}}async*getPeers(t,r={}){xt("getPeers starts: %c",t);let n=AbortSignal.timeout(this.timeout),o=Qr([this.shutDownController.signal,n,r.signal]);let i=ae(),s=ae();this.httpQueue.add(async()=>(i.resolve(),s.promise));try{await i.promise;let c=new URL(`${this.clientUrl}routing/v1/peers/${t.toCID().toString()}`);this.#r(c,r.filterAddrs,r.filterProtocols);let a={headers:{Accept:"application/x-ndjson"},signal:o},l=await this.#e(c.toString(),a);if(l.status===404)throw new Pt("No matching records found");if(l.status===422)throw new Pr("Request does not conform to schema or semantic constraints");if(l.body==null)throw new te("Routing response had no body");if(l.headers.get("Content-Type")==="application/json"){let f=await l.json();for(let p of f.Peers){let S=this.#t(p);S!=null&&(yield S)}}else for await(let f of an(Yn(l.body))){let p=this.#t(f);p!=null&&(yield p)}}catch(c){xt.error("getPeers errored:",c)}finally{o.clear(),s.resolve(),xt("getPeers finished: %c",t)}}async getIPNS(t,r={}){xt("getIPNS starts: %s",t);let n=AbortSignal.timeout(this.timeout),o=Qr([this.shutDownController.signal,n,r.signal]);let i=ae(),s=ae();this.httpQueue.add(async()=>(i.resolve(),s.promise));let c=`${this.clientUrl}routing/v1/ipns/${t}`;try{await i.promise;let a={headers:{Accept:"application/vnd.ipfs.ipns-record"},signal:o},l=await this.#e(c,a);if(xt("getIPNS GET %s %d",c,l.status),l.status===404)throw new Pt("No matching records found");if(l.status===422)throw new Pr("Request does not conform to schema or semantic constraints");if(l.body==null)throw new te("GET ipns response had no body");let u=await l.arrayBuffer(),f=new Uint8Array(u,0,u.byteLength);return r.validate!==!1&&await lf(sn(t.multihash),f),se(f)}catch(a){throw xt.error("getIPNS GET %s error:",c,a),a}finally{o.clear(),s.resolve(),xt("getIPNS finished: %s",t)}}async putIPNS(t,r,n={}){xt("putIPNS starts: %c",t);let o=AbortSignal.timeout(this.timeout),i=Qr([this.shutDownController.signal,o,n.signal]);let s=ae(),c=ae();this.httpQueue.add(async()=>(s.resolve(),c.promise));let a=`${this.clientUrl}routing/v1/ipns/${t}`;try{await s.promise;let l=Ye(r),u={method:"PUT",headers:{"Content-Type":"application/vnd.ipfs.ipns-record"},body:l,signal:i},f=await this.#e(a,u);if(xt("putIPNS PUT %s %d",a,f.status),f.status!==200)throw new te("PUT ipns response had status other than 200")}catch(l){throw xt.error("putIPNS PUT %s error:",a,l.stack),l}finally{i.clear(),c.resolve(),xt("putIPNS finished: %c",t)}}#t(t){try{let r=[],n=t.Addrs?.map(Ge)??[];return t.Protocols!=null&&r.push(...t.Protocols),t.Protocol!=null&&(r.push(t.Protocol),delete t.Protocol),{...t,Schema:"peer",ID:Mc(t.ID),Addrs:n,Protocols:r}}catch(r){xt.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 a=await this.cache?.match(t);if(a!=null){if(parseInt(a.headers.get("x-cache-expires")??"0",10)>Date.now())return xt("returning cached response for %s",o),a;await this.cache?.delete(t)}}let i=this.inFlightRequests.get(o);if(i!=null){let a=await i;return xt("deduplicating outgoing request for %s",o),a.clone()}let s=fetch(t,r).then(async a=>{if(this.cache!=null&&a.ok&&n==="GET"){let l=Date.now()+this.cacheTTL,u=new Headers(a.headers);u.set("x-cache-expires",l.toString());let f=new Response(a.clone().body,{status:a.status,statusText:a.statusText,headers:u});await this.cache.put(t,f)}return a}).finally(()=>{this.inFlightRequests.delete(o)});return this.inFlightRequests.set(o,s),await s}};function wf(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 bf=H("/ipns/");function Ef(e){return rt(e.subarray(0,bf.byteLength),bf)}var Rs=class{client;constructor(t,r={}){this.client=wf(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(!Ef(t))return;let o=Ee(t),i=Z.createV1(114,o),s=se(r);await this.client.putIPNS(i,s,n)}async get(t,r){if(!Ef(t))throw new Pt("Not found");let n=Ee(t),o=Z.createV1(114,n);try{let i=await this.client.getIPNS(o,r);return Ye(i)}catch(i){throw i.name==="BadResponseError"?new Pt("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 Pt("Not found")}async*getClosestPeers(t,r){}};function Sf(e,t){let r=t??vo();return new Rs(new URL(e),r)}var vf="[a-fA-F\\d:]",De=e=>e&&e.includeBoundaries?`(?:(?<=\\s|^)(?=${vf})|(?<=${vf})(?=\\s|$))`:"",ee="(?: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}",ft="[a-fA-F\\d]{1,4}",Ao=`
4
4
  (?:
5
5
  (?:${ft}:){7}(?:${ft}|:)| // 1:2:3:4:5:6:7:: 1:2:3:4:5:6:7:8
6
6
  (?:${ft}:){6}(?:${ee}|:${ft}|:)| // 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