@helia/routers 2.2.0 → 3.0.0-15de32f
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/README.md +2 -2
- package/dist/index.min.js +11 -81
- package/dist/src/http-gateway-routing.d.ts +2 -2
- package/dist/src/http-gateway-routing.d.ts.map +1 -1
- package/dist/src/http-gateway-routing.js +2 -2
- package/dist/src/http-gateway-routing.js.map +1 -1
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.d.ts.map +1 -1
- package/package.json +13 -13
- package/src/http-gateway-routing.ts +5 -5
- package/src/index.ts +1 -1
- package/LICENSE +0 -4
- package/dist/typedoc-urls.json +0 -7
package/dist/index.min.js
CHANGED
|
@@ -1,49 +1,19 @@
|
|
|
1
1
|
(function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.HeliaRouters = factory()}(typeof self !== 'undefined' ? self : this, function () {
|
|
2
|
-
"use strict";var HeliaRouters=(()=>{var
|
|
3
|
-
`,R:"%H:%M",T:"%H:%M:%S",t:" ",X:"%T",Z:"GMT",z:"+0000"};return w;function w(g,v,D){var R=this;if(!(R instanceof w))return new w(g,v,D);R.time=+g||0,R.nano=+v||0,R.year=+D||0,d(R)}function d(g){var v,D,R,N=g.year,H=g.time,A=g.nano,S=((A<0||a<=A)&&(A-=(D=Math.floor(A/a))*a,H+=D,D=1),N%e);return(H<-i||i<H||S)&&((v=f(H/o))&&(N+=v*e,H-=v*o),(R=E(H)).setUTCFullYear(S+R.getUTCFullYear()),R=(H=+R)+(v=f((N-=S)/e))*o,v&&-i<=R&&R<=i&&(N-=v*e,H=R),D=1),D&&(g.year=N,g.time=H,g.nano=A),g}function E(g){var v=new Date(0);return v.setTime(g),v}function k(N,R){N=+N||0;var D=f((R=(R|0)*s)/n)+f(N/n),R=R%n+N%n,N=f(R/n);return N&&(D+=N,R-=N*n),new w(1e3*R,0,D*e)}function x(g,v,D,R,N,H){return function(S,m){var B=d(this);S=S||new Array(8),F(S,m|=0);var V=Math.floor(B.time/1e3),B=B.year*(t*r/e),p=f(B/s)+f(V/s),B=B%s+V%s,V=Math.floor(B/s);return V&&(p+=V,B-=V*s),A(S,m+N,p),A(S,m+H,B),S};function A(S,m,p){S[m+g]=p>>24&255,S[m+v]=p>>16&255,S[m+D]=p>>8&255,S[m+R]=255&p}}function C(g,v,D,R,N,H){return function(S,m){F(S,m|=0);var p=A(S,m+N);return k(A(S,m+H),p)};function A(S,m){return 16777216*S[m+g]+(S[m+v]<<16|S[m+D]<<8|S[m+R])}}function F(g,v){if(g=g&&g.length,g==null)throw new TypeError("Invalid Buffer");if(g<v+8)throw new RangeError("Out of range")}function P(g){return(9<g?"":"0")+(0|g)}function U(g,v){return(c+(0|g)).substr(-v)}}()});var Vf=_i((Jv,Sa)=>{"use strict";var Nm=Object.prototype.hasOwnProperty,Ne="~";function kn(){}Object.create&&(kn.prototype=Object.create(null),new kn().__proto__||(Ne=!1));function Um(r,e,t){this.fn=r,this.context=e,this.once=t||!1}function Pf(r,e,t,n,o){if(typeof t!="function")throw new TypeError("The listener must be a function");var i=new Um(t,n||r,o),s=Ne?Ne+e:e;return r._events[s]?r._events[s].fn?r._events[s]=[r._events[s],i]:r._events[s].push(i):(r._events[s]=i,r._eventsCount++),r}function Bi(r,e){--r._eventsCount===0?r._events=new kn:delete r._events[e]}function Ie(){this._events=new kn,this._eventsCount=0}Ie.prototype.eventNames=function(){var e=[],t,n;if(this._eventsCount===0)return e;for(n in t=this._events)Nm.call(t,n)&&e.push(Ne?n.slice(1):n);return Object.getOwnPropertySymbols?e.concat(Object.getOwnPropertySymbols(t)):e};Ie.prototype.listeners=function(e){var t=Ne?Ne+e:e,n=this._events[t];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};Ie.prototype.listenerCount=function(e){var t=Ne?Ne+e:e,n=this._events[t];return n?n.fn?1:n.length:0};Ie.prototype.emit=function(e,t,n,o,i,s){var a=Ne?Ne+e:e;if(!this._events[a])return!1;var c=this._events[a],f=arguments.length,u,l;if(c.fn){switch(c.once&&this.removeListener(e,c.fn,void 0,!0),f){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,t),!0;case 3:return c.fn.call(c.context,t,n),!0;case 4:return c.fn.call(c.context,t,n,o),!0;case 5:return c.fn.call(c.context,t,n,o,i),!0;case 6:return c.fn.call(c.context,t,n,o,i,s),!0}for(l=1,u=new Array(f-1);l<f;l++)u[l-1]=arguments[l];c.fn.apply(c.context,u)}else{var h=c.length,b;for(l=0;l<h;l++)switch(c[l].once&&this.removeListener(e,c[l].fn,void 0,!0),f){case 1:c[l].fn.call(c[l].context);break;case 2:c[l].fn.call(c[l].context,t);break;case 3:c[l].fn.call(c[l].context,t,n);break;case 4:c[l].fn.call(c[l].context,t,n,o);break;default:if(!u)for(b=1,u=new Array(f-1);b<f;b++)u[b-1]=arguments[b];c[l].fn.apply(c[l].context,u)}}return!0};Ie.prototype.on=function(e,t,n){return Pf(this,e,t,n,!1)};Ie.prototype.once=function(e,t,n){return Pf(this,e,t,n,!0)};Ie.prototype.removeListener=function(e,t,n,o){var i=Ne?Ne+e:e;if(!this._events[i])return this;if(!t)return Bi(this,i),this;var s=this._events[i];if(s.fn)s.fn===t&&(!o||s.once)&&(!n||s.context===n)&&Bi(this,i);else{for(var a=0,c=[],f=s.length;a<f;a++)(s[a].fn!==t||o&&!s[a].once||n&&s[a].context!==n)&&c.push(s[a]);c.length?this._events[i]=c.length===1?c[0]:c:Bi(this,i)}return this};Ie.prototype.removeAllListeners=function(e){var t;return e?(t=Ne?Ne+e:e,this._events[t]&&Bi(this,t)):(this._events=new kn,this._eventsCount=0),this};Ie.prototype.off=Ie.prototype.removeListener;Ie.prototype.addListener=Ie.prototype.on;Ie.prefixed=Ne;Ie.EventEmitter=Ie;typeof Sa<"u"&&(Sa.exports=Ie)});var Xm={};ke(Xm,{delegatedHTTPRouting:()=>zf,delegatedHTTPRoutingDefaults:()=>Ni,httpGatewayRouting:()=>Qf,libp2pRouting:()=>eh});var Za=Symbol.for("@libp2p/content-routing");var Li=Symbol.for("@libp2p/peer-id");var Wa=Symbol.for("@libp2p/peer-routing");var Ee=class extends Error{static name="InvalidParametersError";constructor(e="Invalid parameters"){super(e),this.name="InvalidParametersError"}},lr=class extends Error{static name="InvalidPublicKeyError";constructor(e="Invalid public key"){super(e),this.name="InvalidPublicKeyError"}};var Re=class extends Error{static name="NotFoundError";constructor(e="Not found"){super(e),this.name="NotFoundError"}};var Ln=class extends Error{static name="InvalidCIDError";constructor(e="Invalid CID"){super(e),this.name="InvalidCIDError"}},fr=class extends Error{static name="InvalidMultihashError";constructor(e="Invalid Multihash"){super(e),this.name="InvalidMultihashError"}};var hr=class extends Error{static name="UnsupportedKeyTypeError";constructor(e="Unsupported key type"){super(e),this.name="UnsupportedKeyTypeError"}};var dr=(r,...e)=>{try{[...e]}catch{}};var Oi={};ke(Oi,{base32:()=>Ge,base32hex:()=>Bh,base32hexpad:()=>Sh,base32hexpadupper:()=>Ih,base32hexupper:()=>Ah,base32pad:()=>vh,base32padupper:()=>Eh,base32upper:()=>bh,base32z:()=>Th});var ig=new Uint8Array(0);function Ya(r,e){if(r===e)return!0;if(r.byteLength!==e.byteLength)return!1;for(let t=0;t<r.byteLength;t++)if(r[t]!==e[t])return!1;return!0}function mt(r){if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")}function Ja(r){return new TextEncoder().encode(r)}function Xa(r){return new TextDecoder().decode(r)}function mh(r,e){if(r.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),n=0;n<t.length;n++)t[n]=255;for(var o=0;o<r.length;o++){var i=r.charAt(o),s=i.charCodeAt(0);if(t[s]!==255)throw new TypeError(i+" is ambiguous");t[s]=o}var a=r.length,c=r.charAt(0),f=Math.log(a)/Math.log(256),u=Math.log(256)/Math.log(a);function l(I){if(I instanceof Uint8Array||(ArrayBuffer.isView(I)?I=new Uint8Array(I.buffer,I.byteOffset,I.byteLength):Array.isArray(I)&&(I=Uint8Array.from(I))),!(I instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(I.length===0)return"";for(var w=0,d=0,E=0,k=I.length;E!==k&&I[E]===0;)E++,w++;for(var x=(k-E)*u+1>>>0,C=new Uint8Array(x);E!==k;){for(var F=I[E],P=0,U=x-1;(F!==0||P<d)&&U!==-1;U--,P++)F+=256*C[U]>>>0,C[U]=F%a>>>0,F=F/a>>>0;if(F!==0)throw new Error("Non-zero carry");d=P,E++}for(var g=x-d;g!==x&&C[g]===0;)g++;for(var v=c.repeat(w);g<x;++g)v+=r.charAt(C[g]);return v}function h(I){if(typeof I!="string")throw new TypeError("Expected String");if(I.length===0)return new Uint8Array;var w=0;if(I[w]!==" "){for(var d=0,E=0;I[w]===c;)d++,w++;for(var k=(I.length-w)*f+1>>>0,x=new Uint8Array(k);I[w];){var C=t[I.charCodeAt(w)];if(C===255)return;for(var F=0,P=k-1;(C!==0||F<E)&&P!==-1;P--,F++)C+=a*x[P]>>>0,x[P]=C%256>>>0,C=C/256>>>0;if(C!==0)throw new Error("Non-zero carry");E=F,w++}if(I[w]!==" "){for(var U=k-E;U!==k&&x[U]===0;)U++;for(var g=new Uint8Array(d+(k-U)),v=d;U!==k;)g[v++]=x[U++];return g}}}function b(I){var w=h(I);if(w)return w;throw new Error(`Non-${e} character`)}return{encode:l,decodeUnsafe:h,decode:b}}var gh=mh,yh=gh,ec=yh;var Pi=class{name;prefix;baseEncode;constructor(e,t,n){this.name=e,this.prefix=t,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},Vi=class{name;prefix;baseDecode;prefixCodePoint;constructor(e,t,n){this.name=e,this.prefix=t;let o=t.codePointAt(0);if(o===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=o,this.baseDecode=n}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return tc(this,e)}},Fi=class{decoders;constructor(e){this.decoders=e}or(e){return tc(this,e)}decode(e){let t=e[0],n=this.decoders[t];if(n!=null)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function tc(r,e){return new Fi({...r.decoders??{[r.prefix]:r},...e.decoders??{[e.prefix]:e}})}var Di=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(e,t,n,o){this.name=e,this.prefix=t,this.baseEncode=n,this.baseDecode=o,this.encoder=new Pi(e,t,n),this.decoder=new Vi(e,t,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};function pr({name:r,prefix:e,encode:t,decode:n}){return new Di(r,e,t,n)}function Ut({name:r,prefix:e,alphabet:t}){let{encode:n,decode:o}=ec(t,r);return pr({prefix:e,name:r,encode:n,decode:i=>mt(o(i))})}function wh(r,e,t,n){let o={};for(let u=0;u<e.length;++u)o[e[u]]=u;let i=r.length;for(;r[i-1]==="=";)--i;let s=new Uint8Array(i*t/8|0),a=0,c=0,f=0;for(let u=0;u<i;++u){let l=o[r[u]];if(l===void 0)throw new SyntaxError(`Non-${n} character`);c=c<<t|l,a+=t,a>=8&&(a-=8,s[f++]=255&c>>a)}if(a>=t||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return s}function xh(r,e,t){let n=e[e.length-1]==="=",o=(1<<t)-1,i="",s=0,a=0;for(let c=0;c<r.length;++c)for(a=a<<8|r[c],s+=8;s>t;)s-=t,i+=e[o&a>>s];if(s!==0&&(i+=e[o&a<<t-s]),n)for(;i.length*t&7;)i+="=";return i}function se({name:r,prefix:e,bitsPerChar:t,alphabet:n}){return pr({prefix:e,name:r,encode(o){return xh(o,n,t)},decode(o){return wh(o,n,t,r)}})}var Ge=se({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),bh=se({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),vh=se({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Eh=se({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Bh=se({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Ah=se({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Sh=se({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Ih=se({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Th=se({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Mi={};ke(Mi,{base58btc:()=>re,base58flickr:()=>kh});var re=Ut({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),kh=Ut({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Hi={};ke(Hi,{base64:()=>$i,base64pad:()=>Ch,base64url:()=>Nh,base64urlpad:()=>Uh});var $i=se({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Ch=se({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Nh=se({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Uh=se({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});function Rh(r,e){try{if(typeof r=="string"&&r.length>0)return _h(r);if(typeof r=="number"&&isFinite(r))return e?.long?Ph(r):Lh(r);throw new Error("Value is not a string or number.")}catch(t){let n=Vh(t)?`${t.message}. value=${JSON.stringify(r)}`:"An unknown error has occured.";throw new Error(n)}}function _h(r){if(r=String(r),r.length>100)throw new Error("Value exceeds the maximum length of 100 characters.");let e=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(r);if(!e)return NaN;let t=parseFloat(e[1]),n=(e[2]||"ms").toLowerCase();switch(n){case"years":case"year":case"yrs":case"yr":case"y":return t*315576e5;case"weeks":case"week":case"w":return t*6048e5;case"days":case"day":case"d":return t*864e5;case"hours":case"hour":case"hrs":case"hr":case"h":return t*36e5;case"minutes":case"minute":case"mins":case"min":case"m":return t*6e4;case"seconds":case"second":case"secs":case"sec":case"s":return t*1e3;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return t;default:throw new Error(`The unit ${n} was matched, but no matching case exists.`)}}var Vn=Rh;function Lh(r){let e=Math.abs(r);return e>=864e5?`${Math.round(r/864e5)}d`:e>=36e5?`${Math.round(r/36e5)}h`:e>=6e4?`${Math.round(r/6e4)}m`:e>=1e3?`${Math.round(r/1e3)}s`:`${r}ms`}function Ph(r){let e=Math.abs(r);return e>=864e5?Pn(r,e,864e5,"day"):e>=36e5?Pn(r,e,36e5,"hour"):e>=6e4?Pn(r,e,6e4,"minute"):e>=1e3?Pn(r,e,1e3,"second"):`${r} ms`}function Pn(r,e,t,n){let o=e>=t*1.5;return`${Math.round(r/t)} ${n}${o?"s":""}`}function Vh(r){return typeof r=="object"&&r!==null&&"message"in r}function Ki(r){t.debug=t,t.default=t,t.coerce=c,t.disable=i,t.enable=o,t.enabled=s,t.humanize=Vn,t.destroy=f,Object.keys(r).forEach(u=>{t[u]=r[u]}),t.names=[],t.skips=[],t.formatters={};function e(u){let l=0;for(let h=0;h<u.length;h++)l=(l<<5)-l+u.charCodeAt(h),l|=0;return t.colors[Math.abs(l)%t.colors.length]}t.selectColor=e;function t(u){let l,h=null,b,I;function w(...d){if(!w.enabled)return;let E=w,k=Number(new Date),x=k-(l||k);E.diff=x,E.prev=l,E.curr=k,l=k,d[0]=t.coerce(d[0]),typeof d[0]!="string"&&d.unshift("%O");let C=0;d[0]=d[0].replace(/%([a-zA-Z%])/g,(P,U)=>{if(P==="%%")return"%";C++;let g=t.formatters[U];if(typeof g=="function"){let v=d[C];P=g.call(E,v),d.splice(C,1),C--}return P}),t.formatArgs.call(E,d),(E.log||t.log).apply(E,d)}return w.namespace=u,w.useColors=t.useColors(),w.color=t.selectColor(u),w.extend=n,w.destroy=t.destroy,Object.defineProperty(w,"enabled",{enumerable:!0,configurable:!1,get:()=>h!==null?h:(b!==t.namespaces&&(b=t.namespaces,I=t.enabled(u)),I),set:d=>{h=d}}),typeof t.init=="function"&&t.init(w),w}function n(u,l){let h=t(this.namespace+(typeof l>"u"?":":l)+u);return h.log=this.log,h}function o(u){t.save(u),t.namespaces=u,t.names=[],t.skips=[];let l,h=(typeof u=="string"?u:"").split(/[\s,]+/),b=h.length;for(l=0;l<b;l++)h[l]&&(u=h[l].replace(/\*/g,".*?"),u[0]==="-"?t.skips.push(new RegExp("^"+u.substr(1)+"$")):t.names.push(new RegExp("^"+u+"$")))}function i(){let u=[...t.names.map(a),...t.skips.map(a).map(l=>"-"+l)].join(",");return t.enable(""),u}function s(u){if(u[u.length-1]==="*")return!0;let l,h;for(l=0,h=t.skips.length;l<h;l++)if(t.skips[l].test(u))return!1;for(l=0,h=t.names.length;l<h;l++)if(t.names[l].test(u))return!0;return!1}function a(u){return u.toString().substring(2,u.toString().length-2).replace(/\.\*\?$/,"*")}function c(u){return u instanceof Error?u.stack??u.message:u}function f(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return t.setupFormatters(t.formatters),t.enable(t.load()),t}var Fn=Kh(),Fh=["#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 Dh(){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 Oh(r){if(r[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+r[0]+(this.useColors?"%c ":" ")+"+"+Vn(this.diff),!this.useColors)return;let e="color: "+this.color;r.splice(1,0,e,"color: inherit");let t=0,n=0;r[0].replace(/%[a-zA-Z%]/g,o=>{o!=="%%"&&(t++,o==="%c"&&(n=t))}),r.splice(n,0,e)}var Mh=console.debug??console.log??(()=>{});function $h(r){try{r?Fn?.setItem("debug",r):Fn?.removeItem("debug")}catch{}}function Hh(){let r;try{r=Fn?.getItem("debug")}catch{}return!r&&typeof globalThis.process<"u"&&"env"in globalThis.process&&(r=globalThis.process.env.DEBUG),r}function Kh(){try{return localStorage}catch{}}function qh(r){r.j=function(e){try{return JSON.stringify(e)}catch(t){return"[UnexpectedJSONParseError]: "+t.message}}}var rc=Ki({formatArgs:Oh,save:$h,load:Hh,useColors:Dh,setupFormatters:qh,colors:Fh,storage:Fn,log:Mh});var _e=rc;_e.formatters.b=r=>r==null?"undefined":re.baseEncode(r);_e.formatters.t=r=>r==null?"undefined":Ge.baseEncode(r);_e.formatters.m=r=>r==null?"undefined":$i.baseEncode(r);_e.formatters.p=r=>r==null?"undefined":r.toString();_e.formatters.c=r=>r==null?"undefined":r.toString();_e.formatters.k=r=>r==null?"undefined":r.toString();_e.formatters.a=r=>r==null?"undefined":r.toString();_e.formatters.e=r=>r==null?"undefined":nc(r.stack)??nc(r.message)??r.toString();function zh(r){let e=()=>{};return e.enabled=!1,e.color="",e.diff=0,e.log=()=>{},e.namespace=r,e.destroy=()=>!0,e.extend=()=>e,e}function Rt(r){let e=zh(`${r}:trace`);return _e.enabled(`${r}:trace`)&&_e.names.map(t=>t.toString()).find(t=>t.includes(":trace"))!=null&&(e=_e(`${r}:trace`)),Object.assign(_e(r),{error:_e(`${r}:error`),trace:e})}function nc(r){if(r!=null&&(r=r.trim(),r.length!==0))return r}var qi={};ke(qi,{base36:()=>mr,base36upper:()=>jh});var mr=Ut({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),jh=Ut({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Gh=sc,oc=128,Zh=127,Wh=~Zh,Yh=Math.pow(2,31);function sc(r,e,t){e=e||[],t=t||0;for(var n=t;r>=Yh;)e[t++]=r&255|oc,r/=128;for(;r&Wh;)e[t++]=r&255|oc,r>>>=7;return e[t]=r|0,sc.bytes=t-n+1,e}var Jh=zi,Xh=128,ic=127;function zi(r,n){var t=0,n=n||0,o=0,i=n,s,a=r.length;do{if(i>=a)throw zi.bytes=0,new RangeError("Could not decode varint");s=r[i++],t+=o<28?(s&ic)<<o:(s&ic)*Math.pow(2,o),o+=7}while(s>=Xh);return zi.bytes=i-n,t}var Qh=Math.pow(2,7),ed=Math.pow(2,14),td=Math.pow(2,21),rd=Math.pow(2,28),nd=Math.pow(2,35),od=Math.pow(2,42),id=Math.pow(2,49),sd=Math.pow(2,56),ad=Math.pow(2,63),cd=function(r){return r<Qh?1:r<ed?2:r<td?3:r<rd?4:r<nd?5:r<od?6:r<id?7:r<sd?8:r<ad?9:10},ud={encode:Gh,decode:Jh,encodingLength:cd},ld=ud,Zr=ld;function Wr(r,e=0){return[Zr.decode(r,e),Zr.decode.bytes]}function gr(r,e,t=0){return Zr.encode(r,e,t),e}function yr(r){return Zr.encodingLength(r)}function Ze(r,e){let t=e.byteLength,n=yr(r),o=n+yr(t),i=new Uint8Array(o+t);return gr(r,i,0),gr(t,i,n),i.set(e,o),new wr(r,t,e,i)}function gt(r){let e=mt(r),[t,n]=Wr(e),[o,i]=Wr(e.subarray(n)),s=e.subarray(n+i);if(s.byteLength!==o)throw new Error("Incorrect length");return new wr(t,o,s,e)}function ac(r,e){if(r===e)return!0;{let t=e;return r.code===t.code&&r.size===t.size&&t.bytes instanceof Uint8Array&&Ya(r.bytes,t.bytes)}}var wr=class{code;size;digest;bytes;constructor(e,t,n,o){this.code=e,this.size=t,this.digest=n,this.bytes=o}};function cc(r,e){let{bytes:t,version:n}=r;switch(n){case 0:return hd(t,ji(r),e??re.encoder);default:return dd(t,ji(r),e??Ge.encoder)}}var uc=new WeakMap;function ji(r){let e=uc.get(r);if(e==null){let t=new Map;return uc.set(r,t),t}return e}var X=class r{code;version;multihash;bytes;"/";constructor(e,t,n,o){this.code=t,this.version=e,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:e,multihash:t}=this;if(e!==Yr)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==pd)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return r.createV0(t)}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:e,digest:t}=this.multihash,n=Ze(e,t);return r.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(e){return r.equals(this,e)}static equals(e,t){let n=t;return n!=null&&e.code===n.code&&e.version===n.version&&ac(e.multihash,n.multihash)}toString(e){return cc(this,e)}toJSON(){return{"/":cc(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(e){if(e==null)return null;let t=e;if(t instanceof r)return t;if(t["/"]!=null&&t["/"]===t.bytes||t.asCID===t){let{version:n,code:o,multihash:i,bytes:s}=t;return new r(n,o,i,s??lc(n,o,i.bytes))}else if(t[md]===!0){let{version:n,multihash:o,code:i}=t,s=gt(o);return r.create(n,i,s)}else return null}static create(e,t,n){if(typeof t!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(e){case 0:{if(t!==Yr)throw new Error(`Version 0 CID must use dag-pb (code: ${Yr}) block encoding`);return new r(e,t,n,n.bytes)}case 1:{let o=lc(e,t,n.bytes);return new r(e,t,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return r.create(0,Yr,e)}static createV1(e,t){return r.create(1,e,t)}static decode(e){let[t,n]=r.decodeFirst(e);if(n.length!==0)throw new Error("Incorrect length");return t}static decodeFirst(e){let t=r.inspectBytes(e),n=t.size-t.multihashSize,o=mt(e.subarray(n,n+t.multihashSize));if(o.byteLength!==t.multihashSize)throw new Error("Incorrect length");let i=o.subarray(t.multihashSize-t.digestSize),s=new wr(t.multihashCode,t.digestSize,i,o);return[t.version===0?r.createV0(s):r.createV1(t.codec,s),e.subarray(t.size)]}static inspectBytes(e){let t=0,n=()=>{let[l,h]=Wr(e.subarray(t));return t+=h,l},o=n(),i=Yr;if(o===18?(o=0,t=0):i=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let s=t,a=n(),c=n(),f=t+c,u=f-s;return{version:o,codec:i,multihashCode:a,digestSize:c,multihashSize:u,size:f}}static parse(e,t){let[n,o]=fd(e,t),i=r.decode(o);if(i.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return ji(i).set(n,e),i}};function fd(r,e){switch(r[0]){case"Q":{let t=e??re;return[re.prefix,t.decode(`${re.prefix}${r}`)]}case re.prefix:{let t=e??re;return[re.prefix,t.decode(r)]}case Ge.prefix:{let t=e??Ge;return[Ge.prefix,t.decode(r)]}case mr.prefix:{let t=e??mr;return[mr.prefix,t.decode(r)]}default:{if(e==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[r[0],e.decode(r)]}}}function hd(r,e,t){let{prefix:n}=t;if(n!==re.prefix)throw Error(`Cannot string encode V0 in ${t.name} encoding`);let o=e.get(n);if(o==null){let i=t.encode(r).slice(1);return e.set(n,i),i}else return o}function dd(r,e,t){let{prefix:n}=t,o=e.get(n);if(o==null){let i=t.encode(r);return e.set(n,i),i}else return o}var Yr=112,pd=18;function lc(r,e,t){let n=yr(r),o=n+yr(e),i=new Uint8Array(o+t.byteLength);return gr(r,i,0),gr(e,i,n),i.set(t,o),i}var md=Symbol.for("@ipld/js-cid/CID");var Gi={};ke(Gi,{identity:()=>We});var fc=0,gd="identity",hc=mt;function yd(r){return Ze(fc,hc(r))}var We={code:fc,name:gd,encode:hc,digest:yd};function ce(r,e){if(r===e)return!0;if(r.byteLength!==e.byteLength)return!1;for(let t=0;t<r.byteLength;t++)if(r[t]!==e[t])return!1;return!0}function dc(r){if(!Number.isSafeInteger(r)||r<0)throw new Error(`positive integer expected, not ${r}`)}function wd(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}function xr(r,...e){if(!wd(r))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(r.length))throw new Error(`Uint8Array expected of length ${e}, not of length=${r.length}`)}function pc(r){if(typeof r!="function"||typeof r.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");dc(r.outputLen),dc(r.blockLen)}function br(r,e=!0){if(r.destroyed)throw new Error("Hash instance has been destroyed");if(e&&r.finished)throw new Error("Hash#digest() has already been called")}function mc(r,e){xr(r);let t=e.outputLen;if(r.length<t)throw new Error(`digestInto() expects output buffer of length at least ${t}`)}var Wt=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;var On=r=>new DataView(r.buffer,r.byteOffset,r.byteLength),Ye=(r,e)=>r<<32-e|r>>>e;var Hg=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function gc(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}function Jr(r){return typeof r=="string"&&(r=gc(r)),xr(r),r}function Zi(...r){let e=0;for(let n=0;n<r.length;n++){let o=r[n];xr(o),e+=o.length}let t=new Uint8Array(e);for(let n=0,o=0;n<r.length;n++){let i=r[n];t.set(i,o),o+=i.length}return t}var vr=class{clone(){return this._cloneInto()}},Kg={}.toString;function Mn(r){let e=n=>r().update(Jr(n)).digest(),t=r();return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=()=>r(),e}function $n(r=32){if(Wt&&typeof Wt.getRandomValues=="function")return Wt.getRandomValues(new Uint8Array(r));if(Wt&&typeof Wt.randomBytes=="function")return Wt.randomBytes(r);throw new Error("crypto.getRandomValues must be defined")}function xd(r,e,t,n){if(typeof r.setBigUint64=="function")return r.setBigUint64(e,t,n);let o=BigInt(32),i=BigInt(4294967295),s=Number(t>>o&i),a=Number(t&i),c=n?4:0,f=n?0:4;r.setUint32(e+c,s,n),r.setUint32(e+f,a,n)}var yc=(r,e,t)=>r&e^~r&t,wc=(r,e,t)=>r&e^r&t^e&t,Er=class extends vr{constructor(e,t,n,o){super(),this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=o,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=On(this.buffer)}update(e){br(this);let{view:t,buffer:n,blockLen:o}=this;e=Jr(e);let i=e.length;for(let s=0;s<i;){let a=Math.min(o-this.pos,i-s);if(a===o){let c=On(e);for(;o<=i-s;s+=o)this.process(c,s);continue}n.set(e.subarray(s,s+a),this.pos),this.pos+=a,s+=a,this.pos===o&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){br(this),mc(e,this),this.finished=!0;let{buffer:t,view:n,blockLen:o,isLE:i}=this,{pos:s}=this;t[s++]=128,this.buffer.subarray(s).fill(0),this.padOffset>o-s&&(this.process(n,0),s=0);for(let l=s;l<o;l++)t[l]=0;xd(n,o-8,BigInt(this.length*8),i),this.process(n,0);let a=On(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let f=c/4,u=this.get();if(f>u.length)throw new Error("_sha2: outputLen bigger than state");for(let l=0;l<f;l++)a.setUint32(4*l,u[l],i)}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let n=e.slice(0,t);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());let{blockLen:t,buffer:n,length:o,finished:i,destroyed:s,pos:a}=this;return e.length=o,e.pos=a,e.finished=i,e.destroyed=s,o%t&&e.buffer.set(n),e}};var Hn=BigInt(4294967295),Wi=BigInt(32);function xc(r,e=!1){return e?{h:Number(r&Hn),l:Number(r>>Wi&Hn)}:{h:Number(r>>Wi&Hn)|0,l:Number(r&Hn)|0}}function bd(r,e=!1){let t=new Uint32Array(r.length),n=new Uint32Array(r.length);for(let o=0;o<r.length;o++){let{h:i,l:s}=xc(r[o],e);[t[o],n[o]]=[i,s]}return[t,n]}var vd=(r,e)=>BigInt(r>>>0)<<Wi|BigInt(e>>>0),Ed=(r,e,t)=>r>>>t,Bd=(r,e,t)=>r<<32-t|e>>>t,Ad=(r,e,t)=>r>>>t|e<<32-t,Sd=(r,e,t)=>r<<32-t|e>>>t,Id=(r,e,t)=>r<<64-t|e>>>t-32,Td=(r,e,t)=>r>>>t-32|e<<64-t,kd=(r,e)=>e,Cd=(r,e)=>r,Nd=(r,e,t)=>r<<t|e>>>32-t,Ud=(r,e,t)=>e<<t|r>>>32-t,Rd=(r,e,t)=>e<<t-32|r>>>64-t,_d=(r,e,t)=>r<<t-32|e>>>64-t;function Ld(r,e,t,n){let o=(e>>>0)+(n>>>0);return{h:r+t+(o/2**32|0)|0,l:o|0}}var Pd=(r,e,t)=>(r>>>0)+(e>>>0)+(t>>>0),Vd=(r,e,t,n)=>e+t+n+(r/2**32|0)|0,Fd=(r,e,t,n)=>(r>>>0)+(e>>>0)+(t>>>0)+(n>>>0),Dd=(r,e,t,n,o)=>e+t+n+o+(r/2**32|0)|0,Od=(r,e,t,n,o)=>(r>>>0)+(e>>>0)+(t>>>0)+(n>>>0)+(o>>>0),Md=(r,e,t,n,o,i)=>e+t+n+o+i+(r/2**32|0)|0;var $d={fromBig:xc,split:bd,toBig:vd,shrSH:Ed,shrSL:Bd,rotrSH:Ad,rotrSL:Sd,rotrBH:Id,rotrBL:Td,rotr32H:kd,rotr32L:Cd,rotlSH:Nd,rotlSL:Ud,rotlBH:Rd,rotlBL:_d,add:Ld,add3L:Pd,add3H:Vd,add4L:Fd,add4H:Dd,add5H:Md,add5L:Od},K=$d;var[Hd,Kd]=K.split(["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(r=>BigInt(r))),Lt=new Uint32Array(80),Pt=new Uint32Array(80),Yi=class extends Er{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){let{Ah:e,Al:t,Bh:n,Bl:o,Ch:i,Cl:s,Dh:a,Dl:c,Eh:f,El:u,Fh:l,Fl:h,Gh:b,Gl:I,Hh:w,Hl:d}=this;return[e,t,n,o,i,s,a,c,f,u,l,h,b,I,w,d]}set(e,t,n,o,i,s,a,c,f,u,l,h,b,I,w,d){this.Ah=e|0,this.Al=t|0,this.Bh=n|0,this.Bl=o|0,this.Ch=i|0,this.Cl=s|0,this.Dh=a|0,this.Dl=c|0,this.Eh=f|0,this.El=u|0,this.Fh=l|0,this.Fl=h|0,this.Gh=b|0,this.Gl=I|0,this.Hh=w|0,this.Hl=d|0}process(e,t){for(let x=0;x<16;x++,t+=4)Lt[x]=e.getUint32(t),Pt[x]=e.getUint32(t+=4);for(let x=16;x<80;x++){let C=Lt[x-15]|0,F=Pt[x-15]|0,P=K.rotrSH(C,F,1)^K.rotrSH(C,F,8)^K.shrSH(C,F,7),U=K.rotrSL(C,F,1)^K.rotrSL(C,F,8)^K.shrSL(C,F,7),g=Lt[x-2]|0,v=Pt[x-2]|0,D=K.rotrSH(g,v,19)^K.rotrBH(g,v,61)^K.shrSH(g,v,6),R=K.rotrSL(g,v,19)^K.rotrBL(g,v,61)^K.shrSL(g,v,6),N=K.add4L(U,R,Pt[x-7],Pt[x-16]),H=K.add4H(N,P,D,Lt[x-7],Lt[x-16]);Lt[x]=H|0,Pt[x]=N|0}let{Ah:n,Al:o,Bh:i,Bl:s,Ch:a,Cl:c,Dh:f,Dl:u,Eh:l,El:h,Fh:b,Fl:I,Gh:w,Gl:d,Hh:E,Hl:k}=this;for(let x=0;x<80;x++){let C=K.rotrSH(l,h,14)^K.rotrSH(l,h,18)^K.rotrBH(l,h,41),F=K.rotrSL(l,h,14)^K.rotrSL(l,h,18)^K.rotrBL(l,h,41),P=l&b^~l&w,U=h&I^~h&d,g=K.add5L(k,F,U,Kd[x],Pt[x]),v=K.add5H(g,E,C,P,Hd[x],Lt[x]),D=g|0,R=K.rotrSH(n,o,28)^K.rotrBH(n,o,34)^K.rotrBH(n,o,39),N=K.rotrSL(n,o,28)^K.rotrBL(n,o,34)^K.rotrBL(n,o,39),H=n&i^n&a^i&a,A=o&s^o&c^s&c;E=w|0,k=d|0,w=b|0,d=I|0,b=l|0,I=h|0,{h:l,l:h}=K.add(f|0,u|0,v|0,D|0),f=a|0,u=c|0,a=i|0,c=s|0,i=n|0,s=o|0;let S=K.add3L(D,N,A);n=K.add3H(S,v,R,H),o=S|0}({h:n,l:o}=K.add(this.Ah|0,this.Al|0,n|0,o|0)),{h:i,l:s}=K.add(this.Bh|0,this.Bl|0,i|0,s|0),{h:a,l:c}=K.add(this.Ch|0,this.Cl|0,a|0,c|0),{h:f,l:u}=K.add(this.Dh|0,this.Dl|0,f|0,u|0),{h:l,l:h}=K.add(this.Eh|0,this.El|0,l|0,h|0),{h:b,l:I}=K.add(this.Fh|0,this.Fl|0,b|0,I|0),{h:w,l:d}=K.add(this.Gh|0,this.Gl|0,w|0,d|0),{h:E,l:k}=K.add(this.Hh|0,this.Hl|0,E|0,k|0),this.set(n,o,i,s,a,c,f,u,l,h,b,I,w,d,E,k)}roundClean(){Lt.fill(0),Pt.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};var bc=Mn(()=>new Yi);var qn={};ke(qn,{aInRange:()=>Le,abool:()=>Je,abytes:()=>Br,bitGet:()=>Wd,bitLen:()=>ts,bitMask:()=>Qr,bitSet:()=>Yd,bytesToHex:()=>wt,bytesToNumberBE:()=>xt,bytesToNumberLE:()=>Ft,concatBytes:()=>bt,createHmacDrbg:()=>rs,ensureBytes:()=>ae,equalBytes:()=>Gd,hexToBytes:()=>Jt,hexToNumber:()=>es,inRange:()=>Xr,isBytes:()=>Vt,memoized:()=>Qt,notImplemented:()=>Xd,numberToBytesBE:()=>Dt,numberToBytesLE:()=>Xt,numberToHexUnpadded:()=>Yt,numberToVarBytesBE:()=>jd,utf8ToBytes:()=>Zd,validateObject:()=>at});var Qi=BigInt(0),Kn=BigInt(1),qd=BigInt(2);function Vt(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}function Br(r){if(!Vt(r))throw new Error("Uint8Array expected")}function Je(r,e){if(typeof e!="boolean")throw new Error(`${r} must be valid boolean, got "${e}".`)}var zd=Array.from({length:256},(r,e)=>e.toString(16).padStart(2,"0"));function wt(r){Br(r);let e="";for(let t=0;t<r.length;t++)e+=zd[r[t]];return e}function Yt(r){let e=r.toString(16);return e.length&1?`0${e}`:e}function es(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return BigInt(r===""?"0":`0x${r}`)}var yt={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function vc(r){if(r>=yt._0&&r<=yt._9)return r-yt._0;if(r>=yt._A&&r<=yt._F)return r-(yt._A-10);if(r>=yt._a&&r<=yt._f)return r-(yt._a-10)}function Jt(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);let e=r.length,t=e/2;if(e%2)throw new Error("padded hex string expected, got unpadded hex of length "+e);let n=new Uint8Array(t);for(let o=0,i=0;o<t;o++,i+=2){let s=vc(r.charCodeAt(i)),a=vc(r.charCodeAt(i+1));if(s===void 0||a===void 0){let c=r[i]+r[i+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+i)}n[o]=s*16+a}return n}function xt(r){return es(wt(r))}function Ft(r){return Br(r),es(wt(Uint8Array.from(r).reverse()))}function Dt(r,e){return Jt(r.toString(16).padStart(e*2,"0"))}function Xt(r,e){return Dt(r,e).reverse()}function jd(r){return Jt(Yt(r))}function ae(r,e,t){let n;if(typeof e=="string")try{n=Jt(e)}catch(i){throw new Error(`${r} must be valid hex string, got "${e}". Cause: ${i}`)}else if(Vt(e))n=Uint8Array.from(e);else throw new Error(`${r} must be hex string or Uint8Array`);let o=n.length;if(typeof t=="number"&&o!==t)throw new Error(`${r} expected ${t} bytes, got ${o}`);return n}function bt(...r){let e=0;for(let n=0;n<r.length;n++){let o=r[n];Br(o),e+=o.length}let t=new Uint8Array(e);for(let n=0,o=0;n<r.length;n++){let i=r[n];t.set(i,o),o+=i.length}return t}function Gd(r,e){if(r.length!==e.length)return!1;let t=0;for(let n=0;n<r.length;n++)t|=r[n]^e[n];return t===0}function Zd(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}var Ji=r=>typeof r=="bigint"&&Qi<=r;function Xr(r,e,t){return Ji(r)&&Ji(e)&&Ji(t)&&e<=r&&r<t}function Le(r,e,t,n){if(!Xr(e,t,n))throw new Error(`expected valid ${r}: ${t} <= n < ${n}, got ${typeof e} ${e}`)}function ts(r){let e;for(e=0;r>Qi;r>>=Kn,e+=1);return e}function Wd(r,e){return r>>BigInt(e)&Kn}function Yd(r,e,t){return r|(t?Kn:Qi)<<BigInt(e)}var Qr=r=>(qd<<BigInt(r-1))-Kn,Xi=r=>new Uint8Array(r),Ec=r=>Uint8Array.from(r);function rs(r,e,t){if(typeof r!="number"||r<2)throw new Error("hashLen must be a number");if(typeof e!="number"||e<2)throw new Error("qByteLen must be a number");if(typeof t!="function")throw new Error("hmacFn must be a function");let n=Xi(r),o=Xi(r),i=0,s=()=>{n.fill(1),o.fill(0),i=0},a=(...l)=>t(o,n,...l),c=(l=Xi())=>{o=a(Ec([0]),l),n=a(),l.length!==0&&(o=a(Ec([1]),l),n=a())},f=()=>{if(i++>=1e3)throw new Error("drbg: tried 1000 values");let l=0,h=[];for(;l<e;){n=a();let b=n.slice();h.push(b),l+=n.length}return bt(...h)};return(l,h)=>{s(),c(l);let b;for(;!(b=h(f()));)c();return s(),b}}var Jd={bigint:r=>typeof r=="bigint",function:r=>typeof r=="function",boolean:r=>typeof r=="boolean",string:r=>typeof r=="string",stringOrUint8Array:r=>typeof r=="string"||Vt(r),isSafeInteger:r=>Number.isSafeInteger(r),array:r=>Array.isArray(r),field:(r,e)=>e.Fp.isValid(r),hash:r=>typeof r=="function"&&Number.isSafeInteger(r.outputLen)};function at(r,e,t={}){let n=(o,i,s)=>{let a=Jd[i];if(typeof a!="function")throw new Error(`Invalid validator "${i}", expected function`);let c=r[o];if(!(s&&c===void 0)&&!a(c,r))throw new Error(`Invalid param ${String(o)}=${c} (${typeof c}), expected ${i}`)};for(let[o,i]of Object.entries(e))n(o,i,!1);for(let[o,i]of Object.entries(t))n(o,i,!0);return r}var Xd=()=>{throw new Error("not implemented")};function Qt(r){let e=new WeakMap;return(t,...n)=>{let o=e.get(t);if(o!==void 0)return o;let i=r(t,...n);return e.set(t,i),i}}var fe=BigInt(0),oe=BigInt(1),er=BigInt(2),Qd=BigInt(3),ns=BigInt(4),Bc=BigInt(5),Ac=BigInt(8),e0=BigInt(9),t0=BigInt(16);function Q(r,e){let t=r%e;return t>=fe?t:e+t}function r0(r,e,t){if(t<=fe||e<fe)throw new Error("Expected power/modulo > 0");if(t===oe)return fe;let n=oe;for(;e>fe;)e&oe&&(n=n*r%t),r=r*r%t,e>>=oe;return n}function ie(r,e,t){let n=r;for(;e-- >fe;)n*=n,n%=t;return n}function zn(r,e){if(r===fe||e<=fe)throw new Error(`invert: expected positive integers, got n=${r} mod=${e}`);let t=Q(r,e),n=e,o=fe,i=oe,s=oe,a=fe;for(;t!==fe;){let f=n/t,u=n%t,l=o-s*f,h=i-a*f;n=t,t=u,o=s,i=a,s=l,a=h}if(n!==oe)throw new Error("invert: does not exist");return Q(o,e)}function n0(r){let e=(r-oe)/er,t,n,o;for(t=r-oe,n=0;t%er===fe;t/=er,n++);for(o=er;o<r&&r0(o,e,r)!==r-oe;o++);if(n===1){let s=(r+oe)/ns;return function(c,f){let u=c.pow(f,s);if(!c.eql(c.sqr(u),f))throw new Error("Cannot find square root");return u}}let i=(t+oe)/er;return function(a,c){if(a.pow(c,e)===a.neg(a.ONE))throw new Error("Cannot find square root");let f=n,u=a.pow(a.mul(a.ONE,o),t),l=a.pow(c,i),h=a.pow(c,t);for(;!a.eql(h,a.ONE);){if(a.eql(h,a.ZERO))return a.ZERO;let b=1;for(let w=a.sqr(h);b<f&&!a.eql(w,a.ONE);b++)w=a.sqr(w);let I=a.pow(u,oe<<BigInt(f-b-1));u=a.sqr(I),l=a.mul(l,I),h=a.mul(h,u),f=b}return l}}function o0(r){if(r%ns===Qd){let e=(r+oe)/ns;return function(n,o){let i=n.pow(o,e);if(!n.eql(n.sqr(i),o))throw new Error("Cannot find square root");return i}}if(r%Ac===Bc){let e=(r-Bc)/Ac;return function(n,o){let i=n.mul(o,er),s=n.pow(i,e),a=n.mul(o,s),c=n.mul(n.mul(a,er),s),f=n.mul(a,n.sub(c,n.ONE));if(!n.eql(n.sqr(f),o))throw new Error("Cannot find square root");return f}}return r%t0,n0(r)}var Sc=(r,e)=>(Q(r,e)&oe)===oe,i0=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function os(r){let e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},t=i0.reduce((n,o)=>(n[o]="function",n),e);return at(r,t)}function s0(r,e,t){if(t<fe)throw new Error("Expected power > 0");if(t===fe)return r.ONE;if(t===oe)return e;let n=r.ONE,o=e;for(;t>fe;)t&oe&&(n=r.mul(n,o)),o=r.sqr(o),t>>=oe;return n}function a0(r,e){let t=new Array(e.length),n=e.reduce((i,s,a)=>r.is0(s)?i:(t[a]=i,r.mul(i,s)),r.ONE),o=r.inv(n);return e.reduceRight((i,s,a)=>r.is0(s)?i:(t[a]=r.mul(i,t[a]),r.mul(i,s)),o),t}function is(r,e){let t=e!==void 0?e:r.toString(2).length,n=Math.ceil(t/8);return{nBitLength:t,nByteLength:n}}function Ot(r,e,t=!1,n={}){if(r<=fe)throw new Error(`Expected Field ORDER > 0, got ${r}`);let{nBitLength:o,nByteLength:i}=is(r,e);if(i>2048)throw new Error("Field lengths over 2048 bytes are not supported");let s=o0(r),a=Object.freeze({ORDER:r,BITS:o,BYTES:i,MASK:Qr(o),ZERO:fe,ONE:oe,create:c=>Q(c,r),isValid:c=>{if(typeof c!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof c}`);return fe<=c&&c<r},is0:c=>c===fe,isOdd:c=>(c&oe)===oe,neg:c=>Q(-c,r),eql:(c,f)=>c===f,sqr:c=>Q(c*c,r),add:(c,f)=>Q(c+f,r),sub:(c,f)=>Q(c-f,r),mul:(c,f)=>Q(c*f,r),pow:(c,f)=>s0(a,c,f),div:(c,f)=>Q(c*zn(f,r),r),sqrN:c=>c*c,addN:(c,f)=>c+f,subN:(c,f)=>c-f,mulN:(c,f)=>c*f,inv:c=>zn(c,r),sqrt:n.sqrt||(c=>s(a,c)),invertBatch:c=>a0(a,c),cmov:(c,f,u)=>u?f:c,toBytes:c=>t?Xt(c,i):Dt(c,i),fromBytes:c=>{if(c.length!==i)throw new Error(`Fp.fromBytes: expected ${i}, got ${c.length}`);return t?Ft(c):xt(c)}});return Object.freeze(a)}function Ic(r){if(typeof r!="bigint")throw new Error("field order must be bigint");let e=r.toString(2).length;return Math.ceil(e/8)}function ss(r){let e=Ic(r);return e+Math.ceil(e/2)}function Tc(r,e,t=!1){let n=r.length,o=Ic(e),i=ss(e);if(n<16||n<i||n>1024)throw new Error(`expected ${i}-1024 bytes of input, got ${n}`);let s=t?xt(r):Ft(r),a=Q(s,e-oe)+oe;return t?Xt(a,o):Dt(a,o)}var u0=BigInt(0),as=BigInt(1),cs=new WeakMap,kc=new WeakMap;function jn(r,e){let t=(i,s)=>{let a=s.negate();return i?a:s},n=i=>{if(!Number.isSafeInteger(i)||i<=0||i>e)throw new Error(`Wrong window size=${i}, should be [1..${e}]`)},o=i=>{n(i);let s=Math.ceil(e/i)+1,a=2**(i-1);return{windows:s,windowSize:a}};return{constTimeNegate:t,unsafeLadder(i,s){let a=r.ZERO,c=i;for(;s>u0;)s&as&&(a=a.add(c)),c=c.double(),s>>=as;return a},precomputeWindow(i,s){let{windows:a,windowSize:c}=o(s),f=[],u=i,l=u;for(let h=0;h<a;h++){l=u,f.push(l);for(let b=1;b<c;b++)l=l.add(u),f.push(l);u=l.double()}return f},wNAF(i,s,a){let{windows:c,windowSize:f}=o(i),u=r.ZERO,l=r.BASE,h=BigInt(2**i-1),b=2**i,I=BigInt(i);for(let w=0;w<c;w++){let d=w*f,E=Number(a&h);a>>=I,E>f&&(E-=b,a+=as);let k=d,x=d+Math.abs(E)-1,C=w%2!==0,F=E<0;E===0?l=l.add(t(C,s[k])):u=u.add(t(F,s[x]))}return{p:u,f:l}},wNAFCached(i,s,a){let c=kc.get(i)||1,f=cs.get(i);return f||(f=this.precomputeWindow(i,c),c!==1&&cs.set(i,a(f))),this.wNAF(c,f,s)},setWindowSize(i,s){n(s),kc.set(i,s),cs.delete(i)}}}function Gn(r,e,t,n){if(!Array.isArray(t)||!Array.isArray(n)||n.length!==t.length)throw new Error("arrays of points and scalars must have equal length");n.forEach((u,l)=>{if(!e.isValid(u))throw new Error(`wrong scalar at index ${l}`)}),t.forEach((u,l)=>{if(!(u instanceof r))throw new Error(`wrong point at index ${l}`)});let o=ts(BigInt(t.length)),i=o>12?o-3:o>4?o-2:o?2:1,s=(1<<i)-1,a=new Array(s+1).fill(r.ZERO),c=Math.floor((e.BITS-1)/i)*i,f=r.ZERO;for(let u=c;u>=0;u-=i){a.fill(r.ZERO);for(let h=0;h<n.length;h++){let b=n[h],I=Number(b>>BigInt(u)&BigInt(s));a[I]=a[I].add(t[h])}let l=r.ZERO;for(let h=a.length-1,b=r.ZERO;h>0;h--)b=b.add(a[h]),l=l.add(b);if(f=f.add(l),u!==0)for(let h=0;h<i;h++)f=f.double()}return f}function en(r){return os(r.Fp),at(r,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...is(r.n,r.nBitLength),...r,p:r.Fp.ORDER})}var Xe=BigInt(0),Pe=BigInt(1),Zn=BigInt(2),l0=BigInt(8),f0={zip215:!0};function h0(r){let e=en(r);return at(r,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...e})}function Cc(r){let e=h0(r),{Fp:t,n,prehash:o,hash:i,randomBytes:s,nByteLength:a,h:c}=e,f=Zn<<BigInt(a*8)-Pe,u=t.create,l=Ot(e.n,e.nBitLength),h=e.uvRatio||((m,p)=>{try{return{isValid:!0,value:t.sqrt(m*t.inv(p))}}catch{return{isValid:!1,value:Xe}}}),b=e.adjustScalarBytes||(m=>m),I=e.domain||((m,p,B)=>{if(Je("phflag",B),p.length||B)throw new Error("Contexts/pre-hash are not supported");return m});function w(m,p){Le("coordinate "+m,p,Xe,f)}function d(m){if(!(m instanceof x))throw new Error("ExtendedPoint expected")}let E=Qt((m,p)=>{let{ex:B,ey:V,ez:O}=m,M=m.is0();p==null&&(p=M?l0:t.inv(O));let q=u(B*p),G=u(V*p),z=u(O*p);if(M)return{x:Xe,y:Pe};if(z!==Pe)throw new Error("invZ was invalid");return{x:q,y:G}}),k=Qt(m=>{let{a:p,d:B}=e;if(m.is0())throw new Error("bad point: ZERO");let{ex:V,ey:O,ez:M,et:q}=m,G=u(V*V),z=u(O*O),J=u(M*M),te=u(J*J),de=u(G*p),pe=u(J*u(de+z)),we=u(te+u(B*u(G*z)));if(pe!==we)throw new Error("bad point: equation left != right (1)");let Te=u(V*O),le=u(M*q);if(Te!==le)throw new Error("bad point: equation left != right (2)");return!0});class x{constructor(p,B,V,O){this.ex=p,this.ey=B,this.ez=V,this.et=O,w("x",p),w("y",B),w("z",V),w("t",O),Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(p){if(p instanceof x)throw new Error("extended point not allowed");let{x:B,y:V}=p||{};return w("x",B),w("y",V),new x(B,V,Pe,u(B*V))}static normalizeZ(p){let B=t.invertBatch(p.map(V=>V.ez));return p.map((V,O)=>V.toAffine(B[O])).map(x.fromAffine)}static msm(p,B){return Gn(x,l,p,B)}_setWindowSize(p){P.setWindowSize(this,p)}assertValidity(){k(this)}equals(p){d(p);let{ex:B,ey:V,ez:O}=this,{ex:M,ey:q,ez:G}=p,z=u(B*G),J=u(M*O),te=u(V*G),de=u(q*O);return z===J&&te===de}is0(){return this.equals(x.ZERO)}negate(){return new x(u(-this.ex),this.ey,this.ez,u(-this.et))}double(){let{a:p}=e,{ex:B,ey:V,ez:O}=this,M=u(B*B),q=u(V*V),G=u(Zn*u(O*O)),z=u(p*M),J=B+V,te=u(u(J*J)-M-q),de=z+q,pe=de-G,we=z-q,Te=u(te*pe),le=u(de*we),Ue=u(te*we),pt=u(pe*de);return new x(Te,le,pt,Ue)}add(p){d(p);let{a:B,d:V}=e,{ex:O,ey:M,ez:q,et:G}=this,{ex:z,ey:J,ez:te,et:de}=p;if(B===BigInt(-1)){let Ma=u((M-O)*(J+z)),$a=u((M+O)*(J-z)),Ri=u($a-Ma);if(Ri===Xe)return this.double();let Ha=u(q*Zn*de),Ka=u(G*Zn*te),qa=Ka+Ha,za=$a+Ma,ja=Ka-Ha,ih=u(qa*Ri),sh=u(za*ja),ah=u(qa*ja),ch=u(Ri*za);return new x(ih,sh,ch,ah)}let pe=u(O*z),we=u(M*J),Te=u(G*V*de),le=u(q*te),Ue=u((O+M)*(z+J)-pe-we),pt=le-Te,jr=le+Te,Gr=u(we-B*pe),th=u(Ue*pt),rh=u(jr*Gr),nh=u(Ue*Gr),oh=u(pt*jr);return new x(th,rh,oh,nh)}subtract(p){return this.add(p.negate())}wNAF(p){return P.wNAFCached(this,p,x.normalizeZ)}multiply(p){let B=p;Le("scalar",B,Pe,n);let{p:V,f:O}=this.wNAF(B);return x.normalizeZ([V,O])[0]}multiplyUnsafe(p){let B=p;return Le("scalar",B,Xe,n),B===Xe?F:this.equals(F)||B===Pe?this:this.equals(C)?this.wNAF(B).p:P.unsafeLadder(this,B)}isSmallOrder(){return this.multiplyUnsafe(c).is0()}isTorsionFree(){return P.unsafeLadder(this,n).is0()}toAffine(p){return E(this,p)}clearCofactor(){let{h:p}=e;return p===Pe?this:this.multiplyUnsafe(p)}static fromHex(p,B=!1){let{d:V,a:O}=e,M=t.BYTES;p=ae("pointHex",p,M),Je("zip215",B);let q=p.slice(),G=p[M-1];q[M-1]=G&-129;let z=Ft(q),J=B?f:t.ORDER;Le("pointHex.y",z,Xe,J);let te=u(z*z),de=u(te-Pe),pe=u(V*te-O),{isValid:we,value:Te}=h(de,pe);if(!we)throw new Error("Point.fromHex: invalid y coordinate");let le=(Te&Pe)===Pe,Ue=(G&128)!==0;if(!B&&Te===Xe&&Ue)throw new Error("Point.fromHex: x=0 and x_0=1");return Ue!==le&&(Te=u(-Te)),x.fromAffine({x:Te,y:z})}static fromPrivateKey(p){return v(p).point}toRawBytes(){let{x:p,y:B}=this.toAffine(),V=Xt(B,t.BYTES);return V[V.length-1]|=p&Pe?128:0,V}toHex(){return wt(this.toRawBytes())}}x.BASE=new x(e.Gx,e.Gy,Pe,u(e.Gx*e.Gy)),x.ZERO=new x(Xe,Pe,Pe,Xe);let{BASE:C,ZERO:F}=x,P=jn(x,a*8);function U(m){return Q(m,n)}function g(m){return U(Ft(m))}function v(m){let p=a;m=ae("private key",m,p);let B=ae("hashed private key",i(m),2*p),V=b(B.slice(0,p)),O=B.slice(p,2*p),M=g(V),q=C.multiply(M),G=q.toRawBytes();return{head:V,prefix:O,scalar:M,point:q,pointBytes:G}}function D(m){return v(m).pointBytes}function R(m=new Uint8Array,...p){let B=bt(...p);return g(i(I(B,ae("context",m),!!o)))}function N(m,p,B={}){m=ae("message",m),o&&(m=o(m));let{prefix:V,scalar:O,pointBytes:M}=v(p),q=R(B.context,V,m),G=C.multiply(q).toRawBytes(),z=R(B.context,G,M,m),J=U(q+z*O);Le("signature.s",J,Xe,n);let te=bt(G,Xt(J,t.BYTES));return ae("result",te,a*2)}let H=f0;function A(m,p,B,V=H){let{context:O,zip215:M}=V,q=t.BYTES;m=ae("signature",m,2*q),p=ae("message",p),M!==void 0&&Je("zip215",M),o&&(p=o(p));let G=Ft(m.slice(q,2*q)),z,J,te;try{z=x.fromHex(B,M),J=x.fromHex(m.slice(0,q),M),te=C.multiplyUnsafe(G)}catch{return!1}if(!M&&z.isSmallOrder())return!1;let de=R(O,J.toRawBytes(),z.toRawBytes(),p);return J.add(z.multiplyUnsafe(de)).subtract(te).clearCofactor().equals(x.ZERO)}return C._setWindowSize(8),{CURVE:e,getPublicKey:D,sign:N,verify:A,ExtendedPoint:x,utils:{getExtendedPublicKey:v,randomPrivateKey:()=>s(t.BYTES),precompute(m=8,p=x.BASE){return p._setWindowSize(m),p.multiply(BigInt(3)),p}}}}var us=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),Nc=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),hy=BigInt(0),d0=BigInt(1),Uc=BigInt(2),dy=BigInt(3),p0=BigInt(5),m0=BigInt(8);function g0(r){let e=BigInt(10),t=BigInt(20),n=BigInt(40),o=BigInt(80),i=us,a=r*r%i*r%i,c=ie(a,Uc,i)*a%i,f=ie(c,d0,i)*r%i,u=ie(f,p0,i)*f%i,l=ie(u,e,i)*u%i,h=ie(l,t,i)*l%i,b=ie(h,n,i)*h%i,I=ie(b,o,i)*b%i,w=ie(I,o,i)*b%i,d=ie(w,e,i)*u%i;return{pow_p_5_8:ie(d,Uc,i)*r%i,b2:a}}function y0(r){return r[0]&=248,r[31]&=127,r[31]|=64,r}function w0(r,e){let t=us,n=Q(e*e*e,t),o=Q(n*n*e,t),i=g0(r*o).pow_p_5_8,s=Q(r*n*i,t),a=Q(e*s*s,t),c=s,f=Q(s*Nc,t),u=a===r,l=a===Q(-r,t),h=a===Q(-r*Nc,t);return u&&(s=c),(l||h)&&(s=f),Sc(s,t)&&(s=Q(-s,t)),{isValid:u||l,value:s}}var x0=Ot(us,void 0,!0),b0={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:x0,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:m0,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:bc,randomBytes:$n,adjustScalarBytes:y0,uvRatio:w0},Rc=Cc(b0);var Wn=32;function _c(r,e,t){return Rc.verify(e,t instanceof Uint8Array?t:t.subarray(),r)}var Yn=class{type="Ed25519";raw;constructor(e){this.raw=ls(e,Wn)}toMultihash(){return We.digest(Jn(this))}toCID(){return X.createV1(114,this.toMultihash())}toString(){return re.encode(this.toMultihash().bytes).substring(1)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:ce(this.raw,e.raw)}verify(e,t){return _c(this.raw,t,e)}};function fs(r){return r=ls(r,Wn),new Yn(r)}function ls(r,e){if(r=Uint8Array.from(r??[]),r.length!==e)throw new Ee(`Key must be a Uint8Array of length ${e}, got ${r.length}`);return r}function Qe(r=0){return new Uint8Array(r)}var E0=Math.pow(2,7),B0=Math.pow(2,14),A0=Math.pow(2,21),hs=Math.pow(2,28),ds=Math.pow(2,35),ps=Math.pow(2,42),ms=Math.pow(2,49),Y=128,Be=127;function Ve(r){if(r<E0)return 1;if(r<B0)return 2;if(r<A0)return 3;if(r<hs)return 4;if(r<ds)return 5;if(r<ps)return 6;if(r<ms)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function gs(r,e,t=0){switch(Ve(r)){case 8:e[t++]=r&255|Y,r/=128;case 7:e[t++]=r&255|Y,r/=128;case 6:e[t++]=r&255|Y,r/=128;case 5:e[t++]=r&255|Y,r/=128;case 4:e[t++]=r&255|Y,r>>>=7;case 3:e[t++]=r&255|Y,r>>>=7;case 2:e[t++]=r&255|Y,r>>>=7;case 1:{e[t++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return e}function S0(r,e,t=0){switch(Ve(r)){case 8:e.set(t++,r&255|Y),r/=128;case 7:e.set(t++,r&255|Y),r/=128;case 6:e.set(t++,r&255|Y),r/=128;case 5:e.set(t++,r&255|Y),r/=128;case 4:e.set(t++,r&255|Y),r>>>=7;case 3:e.set(t++,r&255|Y),r>>>=7;case 2:e.set(t++,r&255|Y),r>>>=7;case 1:{e.set(t++,r&255),r>>>=7;break}default:throw new Error("unreachable")}return e}function ys(r,e){let t=r[e],n=0;if(n+=t&Be,t<Y||(t=r[e+1],n+=(t&Be)<<7,t<Y)||(t=r[e+2],n+=(t&Be)<<14,t<Y)||(t=r[e+3],n+=(t&Be)<<21,t<Y)||(t=r[e+4],n+=(t&Be)*hs,t<Y)||(t=r[e+5],n+=(t&Be)*ds,t<Y)||(t=r[e+6],n+=(t&Be)*ps,t<Y)||(t=r[e+7],n+=(t&Be)*ms,t<Y))return n;throw new RangeError("Could not decode varint")}function I0(r,e){let t=r.get(e),n=0;if(n+=t&Be,t<Y||(t=r.get(e+1),n+=(t&Be)<<7,t<Y)||(t=r.get(e+2),n+=(t&Be)<<14,t<Y)||(t=r.get(e+3),n+=(t&Be)<<21,t<Y)||(t=r.get(e+4),n+=(t&Be)*hs,t<Y)||(t=r.get(e+5),n+=(t&Be)*ds,t<Y)||(t=r.get(e+6),n+=(t&Be)*ps,t<Y)||(t=r.get(e+7),n+=(t&Be)*ms,t<Y))return n;throw new RangeError("Could not decode varint")}function Ar(r,e,t=0){return e==null&&(e=Qe(Ve(r))),e instanceof Uint8Array?gs(r,e,t):S0(r,e,t)}function tr(r,e=0){return r instanceof Uint8Array?ys(r,e):I0(r,e)}var ws=new Float32Array([-0]),Mt=new Uint8Array(ws.buffer);function Vc(r,e,t){ws[0]=r,e[t]=Mt[0],e[t+1]=Mt[1],e[t+2]=Mt[2],e[t+3]=Mt[3]}function Fc(r,e){return Mt[0]=r[e],Mt[1]=r[e+1],Mt[2]=r[e+2],Mt[3]=r[e+3],ws[0]}var xs=new Float64Array([-0]),Ae=new Uint8Array(xs.buffer);function Dc(r,e,t){xs[0]=r,e[t]=Ae[0],e[t+1]=Ae[1],e[t+2]=Ae[2],e[t+3]=Ae[3],e[t+4]=Ae[4],e[t+5]=Ae[5],e[t+6]=Ae[6],e[t+7]=Ae[7]}function Oc(r,e){return Ae[0]=r[e],Ae[1]=r[e+1],Ae[2]=r[e+2],Ae[3]=r[e+3],Ae[4]=r[e+4],Ae[5]=r[e+5],Ae[6]=r[e+6],Ae[7]=r[e+7],xs[0]}var T0=BigInt(Number.MAX_SAFE_INTEGER),k0=BigInt(Number.MIN_SAFE_INTEGER),De=class r{lo;hi;constructor(e,t){this.lo=e|0,this.hi=t|0}toNumber(e=!1){if(!e&&this.hi>>>31>0){let t=~this.lo+1>>>0,n=~this.hi>>>0;return t===0&&(n=n+1>>>0),-(t+n*4294967296)}return this.lo+this.hi*4294967296}toBigInt(e=!1){if(e)return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31){let t=~this.lo+1>>>0,n=~this.hi>>>0;return t===0&&(n=n+1>>>0),-(BigInt(t)+(BigInt(n)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toString(e=!1){return this.toBigInt(e).toString()}zzEncode(){let e=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^e)>>>0,this.lo=(this.lo<<1^e)>>>0,this}zzDecode(){let e=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^e)>>>0,this.hi=(this.hi>>>1^e)>>>0,this}length(){let e=this.lo,t=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return n===0?t===0?e<16384?e<128?1:2:e<2097152?3:4:t<16384?t<128?5:6:t<2097152?7:8:n<128?9:10}static fromBigInt(e){if(e===0n)return rr;if(e<T0&&e>k0)return this.fromNumber(Number(e));let t=e<0n;t&&(e=-e);let n=e>>32n,o=e-(n<<32n);return t&&(n=~n|0n,o=~o|0n,++o>Mc&&(o=0n,++n>Mc&&(n=0n))),new r(Number(o),Number(n))}static fromNumber(e){if(e===0)return rr;let t=e<0;t&&(e=-e);let n=e>>>0,o=(e-n)/4294967296>>>0;return t&&(o=~o>>>0,n=~n>>>0,++n>4294967295&&(n=0,++o>4294967295&&(o=0))),new r(n,o)}static from(e){return typeof e=="number"?r.fromNumber(e):typeof e=="bigint"?r.fromBigInt(e):typeof e=="string"?r.fromBigInt(BigInt(e)):e.low!=null||e.high!=null?new r(e.low>>>0,e.high>>>0):rr}},rr=new De(0,0);rr.toBigInt=function(){return 0n};rr.zzEncode=rr.zzDecode=function(){return this};rr.length=function(){return 1};var Mc=4294967296n;function $c(r){let e=0,t=0;for(let n=0;n<r.length;++n)t=r.charCodeAt(n),t<128?e+=1:t<2048?e+=2:(t&64512)===55296&&(r.charCodeAt(n+1)&64512)===56320?(++n,e+=4):e+=3;return e}function Hc(r,e,t){if(t-e<1)return"";let o,i=[],s=0,a;for(;e<t;)a=r[e++],a<128?i[s++]=a:a>191&&a<224?i[s++]=(a&31)<<6|r[e++]&63:a>239&&a<365?(a=((a&7)<<18|(r[e++]&63)<<12|(r[e++]&63)<<6|r[e++]&63)-65536,i[s++]=55296+(a>>10),i[s++]=56320+(a&1023)):i[s++]=(a&15)<<12|(r[e++]&63)<<6|r[e++]&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 bs(r,e,t){let n=t,o,i;for(let s=0;s<r.length;++s)o=r.charCodeAt(s),o<128?e[t++]=o:o<2048?(e[t++]=o>>6|192,e[t++]=o&63|128):(o&64512)===55296&&((i=r.charCodeAt(s+1))&64512)===56320?(o=65536+((o&1023)<<10)+(i&1023),++s,e[t++]=o>>18|240,e[t++]=o>>12&63|128,e[t++]=o>>6&63|128,e[t++]=o&63|128):(e[t++]=o>>12|224,e[t++]=o>>6&63|128,e[t++]=o&63|128);return t-n}function et(r,e){return RangeError(`index out of range: ${r.pos} + ${e??1} > ${r.len}`)}function Xn(r,e){return(r[e-4]|r[e-3]<<8|r[e-2]<<16|r[e-1]<<24)>>>0}var vs=class{buf;pos;len;_slice=Uint8Array.prototype.subarray;constructor(e){this.buf=e,this.pos=0,this.len=e.length}uint32(){let e=4294967295;if(e=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(e=(e|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return e;if((this.pos+=5)>this.len)throw this.pos=this.len,et(this,10);return e}int32(){return this.uint32()|0}sint32(){let e=this.uint32();return e>>>1^-(e&1)|0}bool(){return this.uint32()!==0}fixed32(){if(this.pos+4>this.len)throw et(this,4);return Xn(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw et(this,4);return Xn(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw et(this,4);let e=Fc(this.buf,this.pos);return this.pos+=4,e}double(){if(this.pos+8>this.len)throw et(this,4);let e=Oc(this.buf,this.pos);return this.pos+=8,e}bytes(){let e=this.uint32(),t=this.pos,n=this.pos+e;if(n>this.len)throw et(this,e);return this.pos+=e,t===n?new Uint8Array(0):this.buf.subarray(t,n)}string(){let e=this.bytes();return Hc(e,0,e.length)}skip(e){if(typeof e=="number"){if(this.pos+e>this.len)throw et(this,e);this.pos+=e}else do if(this.pos>=this.len)throw et(this);while(this.buf[this.pos++]&128);return this}skipType(e){switch(e){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(e=this.uint32()&7)!==4;)this.skipType(e);break;case 5:this.skip(4);break;default:throw Error(`invalid wire type ${e} at offset ${this.pos}`)}return this}readLongVarint(){let e=new De(0,0),t=0;if(this.len-this.pos>4){for(;t<4;++t)if(e.lo=(e.lo|(this.buf[this.pos]&127)<<t*7)>>>0,this.buf[this.pos++]<128)return e;if(e.lo=(e.lo|(this.buf[this.pos]&127)<<28)>>>0,e.hi=(e.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return e;t=0}else{for(;t<3;++t){if(this.pos>=this.len)throw et(this);if(e.lo=(e.lo|(this.buf[this.pos]&127)<<t*7)>>>0,this.buf[this.pos++]<128)return e}return e.lo=(e.lo|(this.buf[this.pos++]&127)<<t*7)>>>0,e}if(this.len-this.pos>4){for(;t<5;++t)if(e.hi=(e.hi|(this.buf[this.pos]&127)<<t*7+3)>>>0,this.buf[this.pos++]<128)return e}else for(;t<5;++t){if(this.pos>=this.len)throw et(this);if(e.hi=(e.hi|(this.buf[this.pos]&127)<<t*7+3)>>>0,this.buf[this.pos++]<128)return e}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw et(this,8);let e=Xn(this.buf,this.pos+=4),t=Xn(this.buf,this.pos+=4);return new De(e,t)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){let e=ys(this.buf,this.pos);return this.pos+=Ve(e),e}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 Es(r){return new vs(r instanceof Uint8Array?r:r.subarray())}function Sr(r,e,t){let n=Es(r);return e.decode(n,void 0,t)}var Bs={};ke(Bs,{base10:()=>C0});var C0=Ut({prefix:"9",name:"base10",alphabet:"0123456789"});var As={};ke(As,{base16:()=>N0,base16upper:()=>U0});var N0=se({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),U0=se({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Ss={};ke(Ss,{base2:()=>R0});var R0=se({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Is={};ke(Is,{base256emoji:()=>F0});var qc=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}"),_0=qc.reduce((r,e,t)=>(r[t]=e,r),[]),L0=qc.reduce((r,e,t)=>{let n=e.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${e}`);return r[n]=t,r},[]);function P0(r){return r.reduce((e,t)=>(e+=_0[t],e),"")}function V0(r){let e=[];for(let t of r){let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);let o=L0[n];if(o==null)throw new Error(`Non-base256emoji character: ${t}`);e.push(o)}return new Uint8Array(e)}var F0=pr({prefix:"\u{1F680}",name:"base256emoji",encode:P0,decode:V0});var Ts={};ke(Ts,{base8:()=>D0});var D0=se({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var ks={};ke(ks,{identity:()=>O0});var O0=pr({prefix:"\0",name:"identity",encode:r=>Xa(r),decode:r=>Ja(r)});var Zy=new TextEncoder,Wy=new TextDecoder;var Us={};ke(Us,{sha256:()=>tn,sha512:()=>H0});function Ns({name:r,code:e,encode:t}){return new Cs(r,e,t)}var Cs=class{name;code;encode;constructor(e,t,n){this.name=e,this.code=t,this.encode=n}digest(e){if(e instanceof Uint8Array){let t=this.encode(e);return t instanceof Uint8Array?Ze(this.code,t):t.then(n=>Ze(this.code,n))}else throw Error("Unknown type, must be binary type")}};function jc(r){return async e=>new Uint8Array(await crypto.subtle.digest(r,e))}var tn=Ns({name:"sha2-256",code:18,encode:jc("SHA-256")}),H0=Ns({name:"sha2-512",code:19,encode:jc("SHA-512")});var rn={...ks,...Ss,...Ts,...Bs,...As,...Oi,...qi,...Mi,...Hi,...Is},aw={...Us,...Gi};function Zc(r,e,t,n){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:n}}}var Gc=Zc("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),Rs=Zc("ascii","a",r=>{let e="a";for(let t=0;t<r.length;t++)e+=String.fromCharCode(r[t]);return e},r=>{r=r.substring(1);let e=Qe(r.length);for(let t=0;t<r.length;t++)e[t]=r.charCodeAt(t);return e}),K0={utf8:Gc,"utf-8":Gc,hex:rn.base16,latin1:Rs,ascii:Rs,binary:Rs,...rn},Qn=K0;function Z(r,e="utf8"){let t=Qn[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return t.decoder.decode(`${t.prefix}${r}`)}function _s(r){let e=r??8192,t=e>>>1,n,o=e;return function(s){if(s<1||s>t)return Qe(s);o+s>e&&(n=Qe(e),o=0);let a=n.subarray(o,o+=s);return o&7&&(o=(o|7)+1),a}}var nr=class{fn;len;next;val;constructor(e,t,n){this.fn=e,this.len=t,this.next=void 0,this.val=n}};function Ls(){}var Vs=class{head;tail;len;next;constructor(e){this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}},q0=_s();function z0(r){return globalThis.Buffer!=null?Qe(r):q0(r)}var on=class{len;head;tail;states;constructor(){this.len=0,this.head=new nr(Ls,0,0),this.tail=this.head,this.states=null}_push(e,t,n){return this.tail=this.tail.next=new nr(e,t,n),this.len+=t,this}uint32(e){return this.len+=(this.tail=this.tail.next=new Fs((e=e>>>0)<128?1:e<16384?2:e<2097152?3:e<268435456?4:5,e)).len,this}int32(e){return e<0?this._push(eo,10,De.fromNumber(e)):this.uint32(e)}sint32(e){return this.uint32((e<<1^e>>31)>>>0)}uint64(e){let t=De.fromBigInt(e);return this._push(eo,t.length(),t)}uint64Number(e){return this._push(gs,Ve(e),e)}uint64String(e){return this.uint64(BigInt(e))}int64(e){return this.uint64(e)}int64Number(e){return this.uint64Number(e)}int64String(e){return this.uint64String(e)}sint64(e){let t=De.fromBigInt(e).zzEncode();return this._push(eo,t.length(),t)}sint64Number(e){let t=De.fromNumber(e).zzEncode();return this._push(eo,t.length(),t)}sint64String(e){return this.sint64(BigInt(e))}bool(e){return this._push(Ps,1,e?1:0)}fixed32(e){return this._push(nn,4,e>>>0)}sfixed32(e){return this.fixed32(e)}fixed64(e){let t=De.fromBigInt(e);return this._push(nn,4,t.lo)._push(nn,4,t.hi)}fixed64Number(e){let t=De.fromNumber(e);return this._push(nn,4,t.lo)._push(nn,4,t.hi)}fixed64String(e){return this.fixed64(BigInt(e))}sfixed64(e){return this.fixed64(e)}sfixed64Number(e){return this.fixed64Number(e)}sfixed64String(e){return this.fixed64String(e)}float(e){return this._push(Vc,4,e)}double(e){return this._push(Dc,8,e)}bytes(e){let t=e.length>>>0;return t===0?this._push(Ps,1,0):this.uint32(t)._push(G0,t,e)}string(e){let t=$c(e);return t!==0?this.uint32(t)._push(bs,t,e):this._push(Ps,1,0)}fork(){return this.states=new Vs(this),this.head=this.tail=new nr(Ls,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 nr(Ls,0,0),this.len=0),this}ldelim(){let e=this.head,t=this.tail,n=this.len;return this.reset().uint32(n),n!==0&&(this.tail.next=e.next,this.tail=t,this.len+=n),this}finish(){let e=this.head.next,t=z0(this.len),n=0;for(;e!=null;)e.fn(e.val,t,n),n+=e.len,e=e.next;return t}};function Ps(r,e,t){e[t]=r&255}function j0(r,e,t){for(;r>127;)e[t++]=r&127|128,r>>>=7;e[t]=r}var Fs=class extends nr{next;constructor(e,t){super(j0,e,t),this.next=void 0}};function eo(r,e,t){for(;r.hi!==0;)e[t++]=r.lo&127|128,r.lo=(r.lo>>>7|r.hi<<25)>>>0,r.hi>>>=7;for(;r.lo>127;)e[t++]=r.lo&127|128,r.lo=r.lo>>>7;e[t++]=r.lo}function nn(r,e,t){e[t]=r&255,e[t+1]=r>>>8&255,e[t+2]=r>>>16&255,e[t+3]=r>>>24}function G0(r,e,t){e.set(r,t)}globalThis.Buffer!=null&&(on.prototype.bytes=function(r){let e=r.length>>>0;return this.uint32(e),e>0&&this._push(Z0,e,r),this},on.prototype.string=function(r){let e=globalThis.Buffer.byteLength(r);return this.uint32(e),e>0&&this._push(W0,e,r),this});function Z0(r,e,t){e.set(r,t)}function W0(r,e,t){r.length<40?bs(r,e,t):e.utf8Write!=null?e.utf8Write(r,t):e.set(Z(r),t)}function Ds(){return new on}function Ir(r,e){let t=Ds();return e.encode(r,t,{lengthDelimited:!1}),t.finish()}var Tr;(function(r){r[r.VARINT=0]="VARINT",r[r.BIT64=1]="BIT64",r[r.LENGTH_DELIMITED=2]="LENGTH_DELIMITED",r[r.START_GROUP=3]="START_GROUP",r[r.END_GROUP=4]="END_GROUP",r[r.BIT32=5]="BIT32"})(Tr||(Tr={}));function to(r,e,t,n){return{name:r,type:e,encode:t,decode:n}}function sn(r){function e(o){if(r[o.toString()]==null)throw new Error("Invalid enum value");return r[o]}let t=function(i,s){let a=e(i);s.int32(a)},n=function(i){let s=i.int32();return e(s)};return to("enum",Tr.VARINT,t,n)}function kr(r,e){return to("message",Tr.LENGTH_DELIMITED,r,e)}var he;(function(r){r.RSA="RSA",r.Ed25519="Ed25519",r.secp256k1="secp256k1"})(he||(he={}));var Os;(function(r){r[r.RSA=0]="RSA",r[r.Ed25519=1]="Ed25519",r[r.secp256k1=2]="secp256k1"})(Os||(Os={}));(function(r){r.codec=()=>sn(Os)})(he||(he={}));var ct;(function(r){let e;r.codec=()=>(e==null&&(e=kr((t,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),t.Type!=null&&(n.uint32(8),he.codec().encode(t.Type,n)),t.Data!=null&&(n.uint32(18),n.bytes(t.Data)),o.lengthDelimited!==!1&&n.ldelim()},(t,n,o={})=>{let i={},s=n==null?t.len:t.pos+n;for(;t.pos<s;){let a=t.uint32();switch(a>>>3){case 1:{i.Type=he.codec().decode(t);break}case 2:{i.Data=t.bytes();break}default:{t.skipType(a&7);break}}}return i})),e),r.encode=t=>Ir(t,r.codec()),r.decode=(t,n)=>Sr(t,r.codec(),n)})(ct||(ct={}));var Ms;(function(r){let e;r.codec=()=>(e==null&&(e=kr((t,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),t.Type!=null&&(n.uint32(8),he.codec().encode(t.Type,n)),t.Data!=null&&(n.uint32(18),n.bytes(t.Data)),o.lengthDelimited!==!1&&n.ldelim()},(t,n,o={})=>{let i={},s=n==null?t.len:t.pos+n;for(;t.pos<s;){let a=t.uint32();switch(a>>>3){case 1:{i.Type=he.codec().decode(t);break}case 2:{i.Data=t.bytes();break}default:{t.skipType(a&7);break}}}return i})),e),r.encode=t=>Ir(t,r.codec()),r.decode=(t,n)=>Sr(t,r.codec(),n)})(Ms||(Ms={}));var gn={};ke(gn,{MAX_RSA_KEY_SIZE:()=>Go,generateRSAKeyPair:()=>zu,jwkToJWKKeyPair:()=>ju,jwkToPkcs1:()=>fp,jwkToPkix:()=>Ws,jwkToRSAPrivateKey:()=>qu,pkcs1ToJwk:()=>$u,pkcs1ToRSAPrivateKey:()=>Ku,pkixToJwk:()=>Hu,pkixToRSAPublicKey:()=>Ys});var Y0=new Uint32Array([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]),$t=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Ht=new Uint32Array(64),$s=class extends Er{constructor(){super(64,32,8,!1),this.A=$t[0]|0,this.B=$t[1]|0,this.C=$t[2]|0,this.D=$t[3]|0,this.E=$t[4]|0,this.F=$t[5]|0,this.G=$t[6]|0,this.H=$t[7]|0}get(){let{A:e,B:t,C:n,D:o,E:i,F:s,G:a,H:c}=this;return[e,t,n,o,i,s,a,c]}set(e,t,n,o,i,s,a,c){this.A=e|0,this.B=t|0,this.C=n|0,this.D=o|0,this.E=i|0,this.F=s|0,this.G=a|0,this.H=c|0}process(e,t){for(let l=0;l<16;l++,t+=4)Ht[l]=e.getUint32(t,!1);for(let l=16;l<64;l++){let h=Ht[l-15],b=Ht[l-2],I=Ye(h,7)^Ye(h,18)^h>>>3,w=Ye(b,17)^Ye(b,19)^b>>>10;Ht[l]=w+Ht[l-7]+I+Ht[l-16]|0}let{A:n,B:o,C:i,D:s,E:a,F:c,G:f,H:u}=this;for(let l=0;l<64;l++){let h=Ye(a,6)^Ye(a,11)^Ye(a,25),b=u+h+yc(a,c,f)+Y0[l]+Ht[l]|0,w=(Ye(n,2)^Ye(n,13)^Ye(n,22))+wc(n,o,i)|0;u=f,f=c,c=a,a=s+b|0,s=i,i=o,o=n,n=b+w|0}n=n+this.A|0,o=o+this.B|0,i=i+this.C|0,s=s+this.D|0,a=a+this.E|0,c=c+this.F|0,f=f+this.G|0,u=u+this.H|0,this.set(n,o,i,s,a,c,f,u)}roundClean(){Ht.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var Cr=Mn(()=>new $s);var j=_n(Yc());function or(r,e){let t=0;if(r.length===1)return r[0];for(let n=r.length-1;n>=0;n--)t+=r[r.length-1-n]*Math.pow(2,e*n);return t}function Kt(r,e,t=-1){let n=t,o=r,i=0,s=Math.pow(2,e);for(let a=1;a<8;a++){if(r<s){let c;if(n<0)c=new ArrayBuffer(a),i=a;else{if(n<a)return new ArrayBuffer(0);c=new ArrayBuffer(n),i=n}let f=new Uint8Array(c);for(let u=a-1;u>=0;u--){let l=Math.pow(2,u*e);f[i-u-1]=Math.floor(o/l),o-=f[i-u-1]*l}return c}s*=Math.pow(2,e)}return new ArrayBuffer(0)}function oo(...r){let e=0,t=0;for(let i of r)e+=i.length;let n=new ArrayBuffer(e),o=new Uint8Array(n);for(let i of r)o.set(i,t),t+=i.length;return o}function Ks(){let r=new Uint8Array(this.valueHex);if(this.valueHex.byteLength>=2){let a=r[0]===255&&r[1]&128,c=r[0]===0&&(r[1]&128)===0;(a||c)&&this.warnings.push("Needlessly long format")}let e=new ArrayBuffer(this.valueHex.byteLength),t=new Uint8Array(e);for(let a=0;a<this.valueHex.byteLength;a++)t[a]=0;t[0]=r[0]&128;let n=or(t,8),o=new ArrayBuffer(this.valueHex.byteLength),i=new Uint8Array(o);for(let a=0;a<this.valueHex.byteLength;a++)i[a]=r[a];return i[0]&=127,or(i,8)-n}function Jc(r){let e=r<0?r*-1:r,t=128;for(let n=1;n<8;n++){if(e<=t){if(r<0){let s=t-e,a=Kt(s,8,n),c=new Uint8Array(a);return c[0]|=128,a}let o=Kt(e,8,n),i=new Uint8Array(o);if(i[0]&128){let s=o.slice(0),a=new Uint8Array(s);o=new ArrayBuffer(o.byteLength+1),i=new Uint8Array(o);for(let c=0;c<s.byteLength;c++)i[c+1]=a[c];i[0]=0}return o}t*=Math.pow(2,8)}return new ArrayBuffer(0)}function Xc(r,e){if(r.byteLength!==e.byteLength)return!1;let t=new Uint8Array(r),n=new Uint8Array(e);for(let o=0;o<t.length;o++)if(t[o]!==n[o])return!1;return!0}function Fe(r,e){let t=r.toString(10);if(e<t.length)return"";let n=e-t.length,o=new Array(n);for(let s=0;s<n;s++)o[s]="0";return o.join("").concat(t)}var Hw=Math.log(2);function io(){if(typeof BigInt>"u")throw new Error("BigInt is not defined. Your environment doesn't implement BigInt.")}function qs(r){let e=0,t=0;for(let o=0;o<r.length;o++){let i=r[o];e+=i.byteLength}let n=new Uint8Array(e);for(let o=0;o<r.length;o++){let i=r[o];n.set(new Uint8Array(i),t),t+=i.byteLength}return n.buffer}function St(r,e,t,n){return e instanceof Uint8Array?e.byteLength?t<0?(r.error="Wrong parameter: inputOffset less than zero",!1):n<0?(r.error="Wrong parameter: inputLength less than zero",!1):e.byteLength-t-n<0?(r.error="End of input reached before message was fully decoded (inconsistent offset and length values)",!1):!0:(r.error="Wrong parameter: inputBuffer has zero length",!1):(r.error="Wrong parameter: inputBuffer must be 'Uint8Array'",!1)}var cn=class{constructor(){this.items=[]}write(e){this.items.push(e)}final(){return qs(this.items)}},an=[new Uint8Array([1])],Qc="0123456789";var Lr="",tt=new ArrayBuffer(0),zs=new Uint8Array(0),un="EndOfContent",tu="OCTET STRING",ru="BIT STRING";function It(r){var e;return e=class extends r{constructor(...n){var o;super(...n);let i=n[0]||{};this.isHexOnly=(o=i.isHexOnly)!==null&&o!==void 0?o:!1,this.valueHexView=i.valueHex?j.BufferSourceConverter.toUint8Array(i.valueHex):zs}get valueHex(){return this.valueHexView.slice().buffer}set valueHex(n){this.valueHexView=new Uint8Array(n)}fromBER(n,o,i){let s=n instanceof ArrayBuffer?new Uint8Array(n):n;if(!St(this,s,o,i))return-1;let a=o+i;return this.valueHexView=s.subarray(o,a),this.valueHexView.length?(this.blockLength=i,a):(this.warnings.push("Zero buffer length"),o)}toBER(n=!1){return this.isHexOnly?n?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.byteLength===this.valueHexView.buffer.byteLength?this.valueHexView.buffer:this.valueHexView.slice().buffer:(this.error="Flag 'isHexOnly' is not set, abort",tt)}toJSON(){return{...super.toJSON(),isHexOnly:this.isHexOnly,valueHex:j.Convert.ToHex(this.valueHexView)}}},e.NAME="hexBlock",e}var Et=class{constructor({blockLength:e=0,error:t=Lr,warnings:n=[],valueBeforeDecode:o=zs}={}){this.blockLength=e,this.error=t,this.warnings=n,this.valueBeforeDecodeView=j.BufferSourceConverter.toUint8Array(o)}static blockName(){return this.NAME}get valueBeforeDecode(){return this.valueBeforeDecodeView.slice().buffer}set valueBeforeDecode(e){this.valueBeforeDecodeView=new Uint8Array(e)}toJSON(){return{blockName:this.constructor.NAME,blockLength:this.blockLength,error:this.error,warnings:this.warnings,valueBeforeDecode:j.Convert.ToHex(this.valueBeforeDecodeView)}}};Et.NAME="baseBlock";var Se=class extends Et{fromBER(e,t,n){throw TypeError("User need to make a specific function in a class which extends 'ValueBlock'")}toBER(e,t){throw TypeError("User need to make a specific function in a class which extends 'ValueBlock'")}};Se.NAME="valueBlock";var so=class extends It(Et){constructor({idBlock:e={}}={}){var t,n,o,i;super(),e?(this.isHexOnly=(t=e.isHexOnly)!==null&&t!==void 0?t:!1,this.valueHexView=e.valueHex?j.BufferSourceConverter.toUint8Array(e.valueHex):zs,this.tagClass=(n=e.tagClass)!==null&&n!==void 0?n:-1,this.tagNumber=(o=e.tagNumber)!==null&&o!==void 0?o:-1,this.isConstructed=(i=e.isConstructed)!==null&&i!==void 0?i:!1):(this.tagClass=-1,this.tagNumber=-1,this.isConstructed=!1)}toBER(e=!1){let t=0;switch(this.tagClass){case 1:t|=0;break;case 2:t|=64;break;case 3:t|=128;break;case 4:t|=192;break;default:return this.error="Unknown tag class",tt}if(this.isConstructed&&(t|=32),this.tagNumber<31&&!this.isHexOnly){let o=new Uint8Array(1);if(!e){let i=this.tagNumber;i&=31,t|=i,o[0]=t}return o.buffer}if(!this.isHexOnly){let o=Kt(this.tagNumber,7),i=new Uint8Array(o),s=o.byteLength,a=new Uint8Array(s+1);if(a[0]=t|31,!e){for(let c=0;c<s-1;c++)a[c+1]=i[c]|128;a[s]=i[s-1]}return a.buffer}let n=new Uint8Array(this.valueHexView.byteLength+1);if(n[0]=t|31,!e){let o=this.valueHexView;for(let i=0;i<o.length-1;i++)n[i+1]=o[i]|128;n[this.valueHexView.byteLength]=o[o.length-1]}return n.buffer}fromBER(e,t,n){let o=j.BufferSourceConverter.toUint8Array(e);if(!St(this,o,t,n))return-1;let i=o.subarray(t,t+n);if(i.length===0)return this.error="Zero buffer length",-1;switch(i[0]&192){case 0:this.tagClass=1;break;case 64:this.tagClass=2;break;case 128:this.tagClass=3;break;case 192:this.tagClass=4;break;default:return this.error="Unknown tag class",-1}this.isConstructed=(i[0]&32)===32,this.isHexOnly=!1;let a=i[0]&31;if(a!==31)this.tagNumber=a,this.blockLength=1;else{let c=1,f=this.valueHexView=new Uint8Array(255),u=255;for(;i[c]&128;){if(f[c-1]=i[c]&127,c++,c>=i.length)return this.error="End of input reached before message was fully decoded",-1;if(c===u){u+=255;let h=new Uint8Array(u);for(let b=0;b<f.length;b++)h[b]=f[b];f=this.valueHexView=new Uint8Array(u)}}this.blockLength=c+1,f[c-1]=i[c]&127;let l=new Uint8Array(c);for(let h=0;h<c;h++)l[h]=f[h];f=this.valueHexView=new Uint8Array(c),f.set(l),this.blockLength<=9?this.tagNumber=or(f,7):(this.isHexOnly=!0,this.warnings.push("Tag too long, represented as hex-coded"))}if(this.tagClass===1&&this.isConstructed)switch(this.tagNumber){case 1:case 2:case 5:case 6:case 9:case 13:case 14:case 23:case 24:case 31:case 32:case 33:case 34:return this.error="Constructed encoding used for primitive type",-1}return t+this.blockLength}toJSON(){return{...super.toJSON(),tagClass:this.tagClass,tagNumber:this.tagNumber,isConstructed:this.isConstructed}}};so.NAME="identificationBlock";var ao=class extends Et{constructor({lenBlock:e={}}={}){var t,n,o;super(),this.isIndefiniteForm=(t=e.isIndefiniteForm)!==null&&t!==void 0?t:!1,this.longFormUsed=(n=e.longFormUsed)!==null&&n!==void 0?n:!1,this.length=(o=e.length)!==null&&o!==void 0?o:0}fromBER(e,t,n){let o=j.BufferSourceConverter.toUint8Array(e);if(!St(this,o,t,n))return-1;let i=o.subarray(t,t+n);if(i.length===0)return this.error="Zero buffer length",-1;if(i[0]===255)return this.error="Length block 0xFF is reserved by standard",-1;if(this.isIndefiniteForm=i[0]===128,this.isIndefiniteForm)return this.blockLength=1,t+this.blockLength;if(this.longFormUsed=!!(i[0]&128),this.longFormUsed===!1)return this.length=i[0],this.blockLength=1,t+this.blockLength;let s=i[0]&127;if(s>8)return this.error="Too big integer",-1;if(s+1>i.length)return this.error="End of input reached before message was fully decoded",-1;let a=t+1,c=o.subarray(a,a+s);return c[s-1]===0&&this.warnings.push("Needlessly long encoded length"),this.length=or(c,8),this.longFormUsed&&this.length<=127&&this.warnings.push("Unnecessary usage of long length form"),this.blockLength=s+1,t+this.blockLength}toBER(e=!1){let t,n;if(this.length>127&&(this.longFormUsed=!0),this.isIndefiniteForm)return t=new ArrayBuffer(1),e===!1&&(n=new Uint8Array(t),n[0]=128),t;if(this.longFormUsed){let o=Kt(this.length,8);if(o.byteLength>127)return this.error="Too big length",tt;if(t=new ArrayBuffer(o.byteLength+1),e)return t;let i=new Uint8Array(o);n=new Uint8Array(t),n[0]=o.byteLength|128;for(let s=0;s<o.byteLength;s++)n[s+1]=i[s];return t}return t=new ArrayBuffer(1),e===!1&&(n=new Uint8Array(t),n[0]=this.length),t}toJSON(){return{...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,longFormUsed:this.longFormUsed,length:this.length}}};ao.NAME="lengthBlock";var _={},xe=class extends Et{constructor({name:e=Lr,optional:t=!1,primitiveSchema:n,...o}={},i){super(o),this.name=e,this.optional=t,n&&(this.primitiveSchema=n),this.idBlock=new so(o),this.lenBlock=new ao(o),this.valueBlock=i?new i(o):new Se(o)}fromBER(e,t,n){let o=this.valueBlock.fromBER(e,t,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length);return o===-1?(this.error=this.valueBlock.error,o):(this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),o)}toBER(e,t){let n=t||new cn;t||nu(this);let o=this.idBlock.toBER(e);if(n.write(o),this.lenBlock.isIndefiniteForm)n.write(new Uint8Array([128]).buffer),this.valueBlock.toBER(e,n),n.write(new ArrayBuffer(2));else{let i=this.valueBlock.toBER(e);this.lenBlock.length=i.byteLength;let s=this.lenBlock.toBER(e);n.write(s),n.write(i)}return t?tt:n.final()}toJSON(){let e={...super.toJSON(),idBlock:this.idBlock.toJSON(),lenBlock:this.lenBlock.toJSON(),valueBlock:this.valueBlock.toJSON(),name:this.name,optional:this.optional};return this.primitiveSchema&&(e.primitiveSchema=this.primitiveSchema.toJSON()),e}toString(e="ascii"){return e==="ascii"?this.onAsciiEncoding():j.Convert.ToHex(this.toBER())}onAsciiEncoding(){return`${this.constructor.NAME} : ${j.Convert.ToHex(this.valueBlock.valueBeforeDecodeView)}`}isEqual(e){if(this===e)return!0;if(!(e instanceof this.constructor))return!1;let t=this.toBER(),n=e.toBER();return Xc(t,n)}};xe.NAME="BaseBlock";function nu(r){if(r instanceof _.Constructed)for(let e of r.valueBlock.value)nu(e)&&(r.lenBlock.isIndefiniteForm=!0);return!!r.lenBlock.isIndefiniteForm}var co=class extends xe{constructor({value:e=Lr,...t}={},n){super(t,n),e&&this.fromString(e)}getValue(){return this.valueBlock.value}setValue(e){this.valueBlock.value=e}fromBER(e,t,n){let o=this.valueBlock.fromBER(e,t,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length);return o===-1?(this.error=this.valueBlock.error,o):(this.fromBuffer(this.valueBlock.valueHexView),this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),o)}onAsciiEncoding(){return`${this.constructor.NAME} : '${this.valueBlock.value}'`}};co.NAME="BaseStringBlock";var uo=class extends It(Se){constructor({isHexOnly:e=!0,...t}={}){super(t),this.isHexOnly=e}};uo.NAME="PrimitiveValueBlock";var ou,lo=class extends xe{constructor(e={}){super(e,uo),this.idBlock.isConstructed=!1}};ou=lo;_.Primitive=ou;lo.NAME="PRIMITIVE";function ip(r,e){if(r instanceof e)return r;let t=new e;return t.idBlock=r.idBlock,t.lenBlock=r.lenBlock,t.warnings=r.warnings,t.valueBeforeDecodeView=r.valueBeforeDecodeView,t}function zo(r,e=0,t=r.length){let n=e,o=new xe({},Se),i=new Et;if(!St(i,r,e,t))return o.error=i.error,{offset:-1,result:o};if(!r.subarray(e,e+t).length)return o.error="Zero buffer length",{offset:-1,result:o};let a=o.idBlock.fromBER(r,e,t);if(o.idBlock.warnings.length&&o.warnings.concat(o.idBlock.warnings),a===-1)return o.error=o.idBlock.error,{offset:-1,result:o};if(e=a,t-=o.idBlock.blockLength,a=o.lenBlock.fromBER(r,e,t),o.lenBlock.warnings.length&&o.warnings.concat(o.lenBlock.warnings),a===-1)return o.error=o.lenBlock.error,{offset:-1,result:o};if(e=a,t-=o.lenBlock.blockLength,!o.idBlock.isConstructed&&o.lenBlock.isIndefiniteForm)return o.error="Indefinite length form used for primitive encoding form",{offset:-1,result:o};let c=xe;switch(o.idBlock.tagClass){case 1:if(o.idBlock.tagNumber>=37&&o.idBlock.isHexOnly===!1)return o.error="UNIVERSAL 37 and upper tags are reserved by ASN.1 standard",{offset:-1,result:o};switch(o.idBlock.tagNumber){case 0:if(o.idBlock.isConstructed&&o.lenBlock.length>0)return o.error="Type [UNIVERSAL 0] is reserved",{offset:-1,result:o};c=_.EndOfContent;break;case 1:c=_.Boolean;break;case 2:c=_.Integer;break;case 3:c=_.BitString;break;case 4:c=_.OctetString;break;case 5:c=_.Null;break;case 6:c=_.ObjectIdentifier;break;case 10:c=_.Enumerated;break;case 12:c=_.Utf8String;break;case 13:c=_.RelativeObjectIdentifier;break;case 14:c=_.TIME;break;case 15:return o.error="[UNIVERSAL 15] is reserved by ASN.1 standard",{offset:-1,result:o};case 16:c=_.Sequence;break;case 17:c=_.Set;break;case 18:c=_.NumericString;break;case 19:c=_.PrintableString;break;case 20:c=_.TeletexString;break;case 21:c=_.VideotexString;break;case 22:c=_.IA5String;break;case 23:c=_.UTCTime;break;case 24:c=_.GeneralizedTime;break;case 25:c=_.GraphicString;break;case 26:c=_.VisibleString;break;case 27:c=_.GeneralString;break;case 28:c=_.UniversalString;break;case 29:c=_.CharacterString;break;case 30:c=_.BmpString;break;case 31:c=_.DATE;break;case 32:c=_.TimeOfDay;break;case 33:c=_.DateTime;break;case 34:c=_.Duration;break;default:{let f=o.idBlock.isConstructed?new _.Constructed:new _.Primitive;f.idBlock=o.idBlock,f.lenBlock=o.lenBlock,f.warnings=o.warnings,o=f}}break;case 2:case 3:case 4:default:c=o.idBlock.isConstructed?_.Constructed:_.Primitive}return o=ip(o,c),a=o.fromBER(r,e,o.lenBlock.isIndefiniteForm?t:o.lenBlock.length),o.valueBeforeDecodeView=r.subarray(n,n+o.blockLength),{offset:a,result:o}}function js(r){if(!r.byteLength){let e=new xe({},Se);return e.error="Input buffer has zero length",{offset:-1,result:e}}return zo(j.BufferSourceConverter.toUint8Array(r).slice(),0,r.byteLength)}function sp(r,e){return r?1:e}var ut=class extends Se{constructor({value:e=[],isIndefiniteForm:t=!1,...n}={}){super(n),this.value=e,this.isIndefiniteForm=t}fromBER(e,t,n){let o=j.BufferSourceConverter.toUint8Array(e);if(!St(this,o,t,n))return-1;if(this.valueBeforeDecodeView=o.subarray(t,t+n),this.valueBeforeDecodeView.length===0)return this.warnings.push("Zero buffer length"),t;let i=t;for(;sp(this.isIndefiniteForm,n)>0;){let s=zo(o,i,n);if(s.offset===-1)return this.error=s.result.error,this.warnings.concat(s.result.warnings),-1;if(i=s.offset,this.blockLength+=s.result.blockLength,n-=s.result.blockLength,this.value.push(s.result),this.isIndefiniteForm&&s.result.constructor.NAME===un)break}return this.isIndefiniteForm&&(this.value[this.value.length-1].constructor.NAME===un?this.value.pop():this.warnings.push("No EndOfContent block encoded")),i}toBER(e,t){let n=t||new cn;for(let o=0;o<this.value.length;o++)this.value[o].toBER(e,n);return t?tt:n.final()}toJSON(){let e={...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,value:[]};for(let t of this.value)e.value.push(t.toJSON());return e}};ut.NAME="ConstructedValueBlock";var iu,qt=class extends xe{constructor(e={}){super(e,ut),this.idBlock.isConstructed=!0}fromBER(e,t,n){this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm;let o=this.valueBlock.fromBER(e,t,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length);return o===-1?(this.error=this.valueBlock.error,o):(this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),o)}onAsciiEncoding(){let e=[];for(let n of this.valueBlock.value)e.push(n.toString("ascii").split(`
|
|
4
|
-
`).map(o=>` ${o}`).join(`
|
|
5
|
-
`));let t=this.idBlock.tagClass===3?`[${this.idBlock.tagNumber}]`:this.constructor.NAME;return e.length?`${t} :
|
|
6
|
-
${e.join(`
|
|
7
|
-
`)}`:`${t} :`}};iu=qt;_.Constructed=iu;qt.NAME="CONSTRUCTED";var fo=class extends Se{fromBER(e,t,n){return t}toBER(e){return tt}};fo.override="EndOfContentValueBlock";var su,ho=class extends xe{constructor(e={}){super(e,fo),this.idBlock.tagClass=1,this.idBlock.tagNumber=0}};su=ho;_.EndOfContent=su;ho.NAME=un;var au,Ur=class extends xe{constructor(e={}){super(e,Se),this.idBlock.tagClass=1,this.idBlock.tagNumber=5}fromBER(e,t,n){return this.lenBlock.length>0&&this.warnings.push("Non-zero length of value block for Null type"),this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.blockLength+=n,t+n>e.byteLength?(this.error="End of input reached before message was fully decoded (inconsistent offset and length values)",-1):t+n}toBER(e,t){let n=new ArrayBuffer(2);if(!e){let o=new Uint8Array(n);o[0]=5,o[1]=0}return t&&t.write(n),n}onAsciiEncoding(){return`${this.constructor.NAME}`}};au=Ur;_.Null=au;Ur.NAME="NULL";var po=class extends It(Se){constructor({value:e,...t}={}){super(t),t.valueHex?this.valueHexView=j.BufferSourceConverter.toUint8Array(t.valueHex):this.valueHexView=new Uint8Array(1),e&&(this.value=e)}get value(){for(let e of this.valueHexView)if(e>0)return!0;return!1}set value(e){this.valueHexView[0]=e?255:0}fromBER(e,t,n){let o=j.BufferSourceConverter.toUint8Array(e);return St(this,o,t,n)?(this.valueHexView=o.subarray(t,t+n),n>1&&this.warnings.push("Boolean value encoded in more then 1 octet"),this.isHexOnly=!0,Ks.call(this),this.blockLength=n,t+n):-1}toBER(){return this.valueHexView.slice()}toJSON(){return{...super.toJSON(),value:this.value}}};po.NAME="BooleanValueBlock";var cu,mo=class extends xe{constructor(e={}){super(e,po),this.idBlock.tagClass=1,this.idBlock.tagNumber=1}getValue(){return this.valueBlock.value}setValue(e){this.valueBlock.value=e}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.getValue}`}};cu=mo;_.Boolean=cu;mo.NAME="BOOLEAN";var go=class extends It(ut){constructor({isConstructed:e=!1,...t}={}){super(t),this.isConstructed=e}fromBER(e,t,n){let o=0;if(this.isConstructed){if(this.isHexOnly=!1,o=ut.prototype.fromBER.call(this,e,t,n),o===-1)return o;for(let i=0;i<this.value.length;i++){let s=this.value[i].constructor.NAME;if(s===un){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, OCTET STRING may consists of OCTET STRINGs only",-1}if(s!==tu)return this.error="OCTET STRING may consists of OCTET STRINGs only",-1}}else this.isHexOnly=!0,o=super.fromBER(e,t,n),this.blockLength=n;return o}toBER(e,t){return this.isConstructed?ut.prototype.toBER.call(this,e,t):e?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),isConstructed:this.isConstructed}}};go.NAME="OctetStringValueBlock";var uu,yo=class r extends xe{constructor({idBlock:e={},lenBlock:t={},...n}={}){var o,i;(o=n.isConstructed)!==null&&o!==void 0||(n.isConstructed=!!(!((i=n.value)===null||i===void 0)&&i.length)),super({idBlock:{isConstructed:n.isConstructed,...e},lenBlock:{...t,isIndefiniteForm:!!n.isIndefiniteForm},...n},go),this.idBlock.tagClass=1,this.idBlock.tagNumber=4}fromBER(e,t,n){if(this.valueBlock.isConstructed=this.idBlock.isConstructed,this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm,n===0)return this.idBlock.error.length===0&&(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length===0&&(this.blockLength+=this.lenBlock.blockLength),t;if(!this.valueBlock.isConstructed){let i=(e instanceof ArrayBuffer?new Uint8Array(e):e).subarray(t,t+n);try{if(i.byteLength){let s=zo(i,0,i.byteLength);s.offset!==-1&&s.offset===n&&(this.valueBlock.value=[s.result])}}catch{}}return super.fromBER(e,t,n)}onAsciiEncoding(){return this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length?qt.prototype.onAsciiEncoding.call(this):`${this.constructor.NAME} : ${j.Convert.ToHex(this.valueBlock.valueHexView)}`}getValue(){if(!this.idBlock.isConstructed)return this.valueBlock.valueHexView.slice().buffer;let e=[];for(let t of this.valueBlock.value)t instanceof r&&e.push(t.valueBlock.valueHexView);return j.BufferSourceConverter.concat(e)}};uu=yo;_.OctetString=uu;yo.NAME=tu;var wo=class extends It(ut){constructor({unusedBits:e=0,isConstructed:t=!1,...n}={}){super(n),this.unusedBits=e,this.isConstructed=t,this.blockLength=this.valueHexView.byteLength}fromBER(e,t,n){if(!n)return t;let o=-1;if(this.isConstructed){if(o=ut.prototype.fromBER.call(this,e,t,n),o===-1)return o;for(let a of this.value){let c=a.constructor.NAME;if(c===un){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, BIT STRING may consists of BIT STRINGs only",-1}if(c!==ru)return this.error="BIT STRING may consists of BIT STRINGs only",-1;let f=a.valueBlock;if(this.unusedBits>0&&f.unusedBits>0)return this.error='Using of "unused bits" inside constructive BIT STRING allowed for least one only',-1;this.unusedBits=f.unusedBits}return o}let i=j.BufferSourceConverter.toUint8Array(e);if(!St(this,i,t,n))return-1;let s=i.subarray(t,t+n);if(this.unusedBits=s[0],this.unusedBits>7)return this.error="Unused bits for BitString must be in range 0-7",-1;if(!this.unusedBits){let a=s.subarray(1);try{if(a.byteLength){let c=zo(a,0,a.byteLength);c.offset!==-1&&c.offset===n-1&&(this.value=[c.result])}}catch{}}return this.valueHexView=s.subarray(1),this.blockLength=s.length,t+n}toBER(e,t){if(this.isConstructed)return ut.prototype.toBER.call(this,e,t);if(e)return new ArrayBuffer(this.valueHexView.byteLength+1);if(!this.valueHexView.byteLength)return tt;let n=new Uint8Array(this.valueHexView.length+1);return n[0]=this.unusedBits,n.set(this.valueHexView,1),n.buffer}toJSON(){return{...super.toJSON(),unusedBits:this.unusedBits,isConstructed:this.isConstructed}}};wo.NAME="BitStringValueBlock";var lu,Rr=class extends xe{constructor({idBlock:e={},lenBlock:t={},...n}={}){var o,i;(o=n.isConstructed)!==null&&o!==void 0||(n.isConstructed=!!(!((i=n.value)===null||i===void 0)&&i.length)),super({idBlock:{isConstructed:n.isConstructed,...e},lenBlock:{...t,isIndefiniteForm:!!n.isIndefiniteForm},...n},wo),this.idBlock.tagClass=1,this.idBlock.tagNumber=3}fromBER(e,t,n){return this.valueBlock.isConstructed=this.idBlock.isConstructed,this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm,super.fromBER(e,t,n)}onAsciiEncoding(){if(this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length)return qt.prototype.onAsciiEncoding.call(this);{let e=[],t=this.valueBlock.valueHexView;for(let o of t)e.push(o.toString(2).padStart(8,"0"));let n=e.join("");return`${this.constructor.NAME} : ${n.substring(0,n.length-this.valueBlock.unusedBits)}`}}};lu=Rr;_.BitString=lu;Rr.NAME=ru;var fu;function ap(r,e){let t=new Uint8Array([0]),n=new Uint8Array(r),o=new Uint8Array(e),i=n.slice(0),s=i.length-1,a=o.slice(0),c=a.length-1,f=0,u=c<s?s:c,l=0;for(let h=u;h>=0;h--,l++){switch(!0){case l<a.length:f=i[s-l]+a[c-l]+t[0];break;default:f=i[s-l]+t[0]}switch(t[0]=f/10,!0){case l>=i.length:i=oo(new Uint8Array([f%10]),i);break;default:i[s-l]=f%10}}return t[0]>0&&(i=oo(t,i)),i}function eu(r){if(r>=an.length)for(let e=an.length;e<=r;e++){let t=new Uint8Array([0]),n=an[e-1].slice(0);for(let o=n.length-1;o>=0;o--){let i=new Uint8Array([(n[o]<<1)+t[0]]);t[0]=i[0]/10,n[o]=i[0]%10}t[0]>0&&(n=oo(t,n)),an.push(n)}return an[r]}function cp(r,e){let t=0,n=new Uint8Array(r),o=new Uint8Array(e),i=n.slice(0),s=i.length-1,a=o.slice(0),c=a.length-1,f,u=0;for(let l=c;l>=0;l--,u++)switch(f=i[s-u]-a[c-u]-t,!0){case f<0:t=1,i[s-u]=f+10;break;default:t=0,i[s-u]=f}if(t>0)for(let l=s-c+1;l>=0;l--,u++)if(f=i[s-u]-t,f<0)t=1,i[s-u]=f+10;else{t=0,i[s-u]=f;break}return i.slice()}var ln=class extends It(Se){constructor({value:e,...t}={}){super(t),this._valueDec=0,t.valueHex&&this.setValueHex(),e!==void 0&&(this.valueDec=e)}setValueHex(){this.valueHexView.length>=4?(this.warnings.push("Too big Integer for decoding, hex only"),this.isHexOnly=!0,this._valueDec=0):(this.isHexOnly=!1,this.valueHexView.length>0&&(this._valueDec=Ks.call(this)))}set valueDec(e){this._valueDec=e,this.isHexOnly=!1,this.valueHexView=new Uint8Array(Jc(e))}get valueDec(){return this._valueDec}fromDER(e,t,n,o=0){let i=this.fromBER(e,t,n);if(i===-1)return i;let s=this.valueHexView;return s[0]===0&&s[1]&128?this.valueHexView=s.subarray(1):o!==0&&s.length<o&&(o-s.length>1&&(o=s.length+1),this.valueHexView=s.subarray(o-s.length)),i}toDER(e=!1){let t=this.valueHexView;switch(!0){case(t[0]&128)!==0:{let n=new Uint8Array(this.valueHexView.length+1);n[0]=0,n.set(t,1),this.valueHexView=n}break;case(t[0]===0&&(t[1]&128)===0):this.valueHexView=this.valueHexView.subarray(1);break}return this.toBER(e)}fromBER(e,t,n){let o=super.fromBER(e,t,n);return o===-1||this.setValueHex(),o}toBER(e){return e?new ArrayBuffer(this.valueHexView.length):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}toString(){let e=this.valueHexView.length*8-1,t=new Uint8Array(this.valueHexView.length*8/3),n=0,o,i=this.valueHexView,s="",a=!1;for(let c=i.byteLength-1;c>=0;c--){o=i[c];for(let f=0;f<8;f++){if((o&1)===1)switch(n){case e:t=cp(eu(n),t),s="-";break;default:t=ap(t,eu(n))}n++,o>>=1}}for(let c=0;c<t.length;c++)t[c]&&(a=!0),a&&(s+=Qc.charAt(t[c]));return a===!1&&(s+=Qc.charAt(0)),s}};fu=ln;ln.NAME="IntegerValueBlock";Object.defineProperty(fu.prototype,"valueHex",{set:function(r){this.valueHexView=new Uint8Array(r),this.setValueHex()},get:function(){return this.valueHexView.slice().buffer}});var hu,be=class r extends xe{constructor(e={}){super(e,ln),this.idBlock.tagClass=1,this.idBlock.tagNumber=2}toBigInt(){return io(),BigInt(this.valueBlock.toString())}static fromBigInt(e){io();let t=BigInt(e),n=new cn,o=t.toString(16).replace(/^-/,""),i=new Uint8Array(j.Convert.FromHex(o));if(t<0){let a=new Uint8Array(i.length+(i[0]&128?1:0));a[0]|=128;let f=BigInt(`0x${j.Convert.ToHex(a)}`)+t,u=j.BufferSourceConverter.toUint8Array(j.Convert.FromHex(f.toString(16)));u[0]|=128,n.write(u)}else i[0]&128&&n.write(new Uint8Array([0])),n.write(i);return new r({valueHex:n.final()})}convertToDER(){let e=new r({valueHex:this.valueBlock.valueHexView});return e.valueBlock.toDER(),e}convertFromDER(){return new r({valueHex:this.valueBlock.valueHexView[0]===0?this.valueBlock.valueHexView.subarray(1):this.valueBlock.valueHexView})}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()}`}};hu=be;_.Integer=hu;be.NAME="INTEGER";var du,xo=class extends be{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=10}};du=xo;_.Enumerated=du;xo.NAME="ENUMERATED";var fn=class extends It(Se){constructor({valueDec:e=-1,isFirstSid:t=!1,...n}={}){super(n),this.valueDec=e,this.isFirstSid=t}fromBER(e,t,n){if(!n)return t;let o=j.BufferSourceConverter.toUint8Array(e);if(!St(this,o,t,n))return-1;let i=o.subarray(t,t+n);this.valueHexView=new Uint8Array(n);for(let a=0;a<n&&(this.valueHexView[a]=i[a]&127,this.blockLength++,!!(i[a]&128));a++);let s=new Uint8Array(this.blockLength);for(let a=0;a<this.blockLength;a++)s[a]=this.valueHexView[a];return this.valueHexView=s,i[this.blockLength-1]&128?(this.error="End of input reached before message was fully decoded",-1):(this.valueHexView[0]===0&&this.warnings.push("Needlessly long format of SID encoding"),this.blockLength<=8?this.valueDec=or(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),t+this.blockLength)}set valueBigInt(e){io();let t=BigInt(e).toString(2);for(;t.length%7;)t="0"+t;let n=new Uint8Array(t.length/7);for(let o=0;o<n.length;o++)n[o]=parseInt(t.slice(o*7,o*7+7),2)+(o+1<n.length?128:0);this.fromBER(n.buffer,0,n.length)}toBER(e){if(this.isHexOnly){if(e)return new ArrayBuffer(this.valueHexView.byteLength);let o=this.valueHexView,i=new Uint8Array(this.blockLength);for(let s=0;s<this.blockLength-1;s++)i[s]=o[s]|128;return i[this.blockLength-1]=o[this.blockLength-1],i.buffer}let t=Kt(this.valueDec,7);if(t.byteLength===0)return this.error="Error during encoding SID value",tt;let n=new Uint8Array(t.byteLength);if(!e){let o=new Uint8Array(t),i=t.byteLength-1;for(let s=0;s<i;s++)n[s]=o[s]|128;n[i]=o[i]}return n}toString(){let e="";if(this.isHexOnly)e=j.Convert.ToHex(this.valueHexView);else if(this.isFirstSid){let t=this.valueDec;this.valueDec<=39?e="0.":this.valueDec<=79?(e="1.",t-=40):(e="2.",t-=80),e+=t.toString()}else e=this.valueDec.toString();return e}toJSON(){return{...super.toJSON(),valueDec:this.valueDec,isFirstSid:this.isFirstSid}}};fn.NAME="sidBlock";var bo=class extends Se{constructor({value:e=Lr,...t}={}){super(t),this.value=[],e&&this.fromString(e)}fromBER(e,t,n){let o=t;for(;n>0;){let i=new fn;if(o=i.fromBER(e,o,n),o===-1)return this.blockLength=0,this.error=i.error,o;this.value.length===0&&(i.isFirstSid=!0),this.blockLength+=i.blockLength,n-=i.blockLength,this.value.push(i)}return o}toBER(e){let t=[];for(let n=0;n<this.value.length;n++){let o=this.value[n].toBER(e);if(o.byteLength===0)return this.error=this.value[n].error,tt;t.push(o)}return qs(t)}fromString(e){this.value=[];let t=0,n=0,o="",i=!1;do if(n=e.indexOf(".",t),n===-1?o=e.substring(t):o=e.substring(t,n),t=n+1,i){let s=this.value[0],a=0;switch(s.valueDec){case 0:break;case 1:a=40;break;case 2:a=80;break;default:this.value=[];return}let c=parseInt(o,10);if(isNaN(c))return;s.valueDec=c+a,i=!1}else{let s=new fn;if(o>Number.MAX_SAFE_INTEGER){io();let a=BigInt(o);s.valueBigInt=a}else if(s.valueDec=parseInt(o,10),isNaN(s.valueDec))return;this.value.length||(s.isFirstSid=!0,i=!0),this.value.push(s)}while(n!==-1)}toString(){let e="",t=!1;for(let n=0;n<this.value.length;n++){t=this.value[n].isHexOnly;let o=this.value[n].toString();n!==0&&(e=`${e}.`),t?(o=`{${o}}`,this.value[n].isFirstSid?e=`2.{${o} - 80}`:e+=o):e+=o}return e}toJSON(){let e={...super.toJSON(),value:this.toString(),sidArray:[]};for(let t=0;t<this.value.length;t++)e.sidArray.push(this.value[t].toJSON());return e}};bo.NAME="ObjectIdentifierValueBlock";var pu,_r=class extends xe{constructor(e={}){super(e,bo),this.idBlock.tagClass=1,this.idBlock.tagNumber=6}getValue(){return this.valueBlock.toString()}setValue(e){this.valueBlock.fromString(e)}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()||"empty"}`}toJSON(){return{...super.toJSON(),value:this.getValue()}}};pu=_r;_.ObjectIdentifier=pu;_r.NAME="OBJECT IDENTIFIER";var hn=class extends It(Et){constructor({valueDec:e=0,...t}={}){super(t),this.valueDec=e}fromBER(e,t,n){if(n===0)return t;let o=j.BufferSourceConverter.toUint8Array(e);if(!St(this,o,t,n))return-1;let i=o.subarray(t,t+n);this.valueHexView=new Uint8Array(n);for(let a=0;a<n&&(this.valueHexView[a]=i[a]&127,this.blockLength++,!!(i[a]&128));a++);let s=new Uint8Array(this.blockLength);for(let a=0;a<this.blockLength;a++)s[a]=this.valueHexView[a];return this.valueHexView=s,i[this.blockLength-1]&128?(this.error="End of input reached before message was fully decoded",-1):(this.valueHexView[0]===0&&this.warnings.push("Needlessly long format of SID encoding"),this.blockLength<=8?this.valueDec=or(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),t+this.blockLength)}toBER(e){if(this.isHexOnly){if(e)return new ArrayBuffer(this.valueHexView.byteLength);let o=this.valueHexView,i=new Uint8Array(this.blockLength);for(let s=0;s<this.blockLength-1;s++)i[s]=o[s]|128;return i[this.blockLength-1]=o[this.blockLength-1],i.buffer}let t=Kt(this.valueDec,7);if(t.byteLength===0)return this.error="Error during encoding SID value",tt;let n=new Uint8Array(t.byteLength);if(!e){let o=new Uint8Array(t),i=t.byteLength-1;for(let s=0;s<i;s++)n[s]=o[s]|128;n[i]=o[i]}return n.buffer}toString(){let e="";return this.isHexOnly?e=j.Convert.ToHex(this.valueHexView):e=this.valueDec.toString(),e}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}};hn.NAME="relativeSidBlock";var vo=class extends Se{constructor({value:e=Lr,...t}={}){super(t),this.value=[],e&&this.fromString(e)}fromBER(e,t,n){let o=t;for(;n>0;){let i=new hn;if(o=i.fromBER(e,o,n),o===-1)return this.blockLength=0,this.error=i.error,o;this.blockLength+=i.blockLength,n-=i.blockLength,this.value.push(i)}return o}toBER(e,t){let n=[];for(let o=0;o<this.value.length;o++){let i=this.value[o].toBER(e);if(i.byteLength===0)return this.error=this.value[o].error,tt;n.push(i)}return qs(n)}fromString(e){this.value=[];let t=0,n=0,o="";do{n=e.indexOf(".",t),n===-1?o=e.substring(t):o=e.substring(t,n),t=n+1;let i=new hn;if(i.valueDec=parseInt(o,10),isNaN(i.valueDec))return!0;this.value.push(i)}while(n!==-1);return!0}toString(){let e="",t=!1;for(let n=0;n<this.value.length;n++){t=this.value[n].isHexOnly;let o=this.value[n].toString();n!==0&&(e=`${e}.`),t&&(o=`{${o}}`),e+=o}return e}toJSON(){let e={...super.toJSON(),value:this.toString(),sidArray:[]};for(let t=0;t<this.value.length;t++)e.sidArray.push(this.value[t].toJSON());return e}};vo.NAME="RelativeObjectIdentifierValueBlock";var mu,Eo=class extends xe{constructor(e={}){super(e,vo),this.idBlock.tagClass=1,this.idBlock.tagNumber=13}getValue(){return this.valueBlock.toString()}setValue(e){this.valueBlock.fromString(e)}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()||"empty"}`}toJSON(){return{...super.toJSON(),value:this.getValue()}}};mu=Eo;_.RelativeObjectIdentifier=mu;Eo.NAME="RelativeObjectIdentifier";var gu,Bt=class extends qt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=16}};gu=Bt;_.Sequence=gu;Bt.NAME="SEQUENCE";var yu,Bo=class extends qt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=17}};yu=Bo;_.Set=yu;Bo.NAME="SET";var Ao=class extends It(Se){constructor({...e}={}){super(e),this.isHexOnly=!0,this.value=Lr}toJSON(){return{...super.toJSON(),value:this.value}}};Ao.NAME="StringValueBlock";var So=class extends Ao{};So.NAME="SimpleStringValueBlock";var Ce=class extends co{constructor({...e}={}){super(e,So)}fromBuffer(e){this.valueBlock.value=String.fromCharCode.apply(null,j.BufferSourceConverter.toUint8Array(e))}fromString(e){let t=e.length,n=this.valueBlock.valueHexView=new Uint8Array(t);for(let o=0;o<t;o++)n[o]=e.charCodeAt(o);this.valueBlock.value=e}};Ce.NAME="SIMPLE STRING";var Io=class extends Ce{fromBuffer(e){this.valueBlock.valueHexView=j.BufferSourceConverter.toUint8Array(e);try{this.valueBlock.value=j.Convert.ToUtf8String(e)}catch(t){this.warnings.push(`Error during "decodeURIComponent": ${t}, using raw string`),this.valueBlock.value=j.Convert.ToBinary(e)}}fromString(e){this.valueBlock.valueHexView=new Uint8Array(j.Convert.FromUtf8String(e)),this.valueBlock.value=e}};Io.NAME="Utf8StringValueBlock";var wu,At=class extends Io{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=12}};wu=At;_.Utf8String=wu;At.NAME="UTF8String";var To=class extends Ce{fromBuffer(e){this.valueBlock.value=j.Convert.ToUtf16String(e),this.valueBlock.valueHexView=j.BufferSourceConverter.toUint8Array(e)}fromString(e){this.valueBlock.value=e,this.valueBlock.valueHexView=new Uint8Array(j.Convert.FromUtf16String(e))}};To.NAME="BmpStringValueBlock";var xu,ko=class extends To{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=30}};xu=ko;_.BmpString=xu;ko.NAME="BMPString";var Co=class extends Ce{fromBuffer(e){let t=ArrayBuffer.isView(e)?e.slice().buffer:e.slice(0),n=new Uint8Array(t);for(let o=0;o<n.length;o+=4)n[o]=n[o+3],n[o+1]=n[o+2],n[o+2]=0,n[o+3]=0;this.valueBlock.value=String.fromCharCode.apply(null,new Uint32Array(t))}fromString(e){let t=e.length,n=this.valueBlock.valueHexView=new Uint8Array(t*4);for(let o=0;o<t;o++){let i=Kt(e.charCodeAt(o),8),s=new Uint8Array(i);if(s.length>4)continue;let a=4-s.length;for(let c=s.length-1;c>=0;c--)n[o*4+c+a]=s[c]}this.valueBlock.value=e}};Co.NAME="UniversalStringValueBlock";var bu,No=class extends Co{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=28}};bu=No;_.UniversalString=bu;No.NAME="UniversalString";var vu,Uo=class extends Ce{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=18}};vu=Uo;_.NumericString=vu;Uo.NAME="NumericString";var Eu,Ro=class extends Ce{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=19}};Eu=Ro;_.PrintableString=Eu;Ro.NAME="PrintableString";var Bu,_o=class extends Ce{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=20}};Bu=_o;_.TeletexString=Bu;_o.NAME="TeletexString";var Au,Lo=class extends Ce{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=21}};Au=Lo;_.VideotexString=Au;Lo.NAME="VideotexString";var Su,Po=class extends Ce{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=22}};Su=Po;_.IA5String=Su;Po.NAME="IA5String";var Iu,Vo=class extends Ce{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=25}};Iu=Vo;_.GraphicString=Iu;Vo.NAME="GraphicString";var Tu,dn=class extends Ce{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=26}};Tu=dn;_.VisibleString=Tu;dn.NAME="VisibleString";var ku,Fo=class extends Ce{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=27}};ku=Fo;_.GeneralString=ku;Fo.NAME="GeneralString";var Cu,Do=class extends Ce{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=29}};Cu=Do;_.CharacterString=Cu;Do.NAME="CharacterString";var Nu,pn=class extends dn{constructor({value:e,valueDate:t,...n}={}){if(super(n),this.year=0,this.month=0,this.day=0,this.hour=0,this.minute=0,this.second=0,e){this.fromString(e),this.valueBlock.valueHexView=new Uint8Array(e.length);for(let o=0;o<e.length;o++)this.valueBlock.valueHexView[o]=e.charCodeAt(o)}t&&(this.fromDate(t),this.valueBlock.valueHexView=new Uint8Array(this.toBuffer())),this.idBlock.tagClass=1,this.idBlock.tagNumber=23}fromBuffer(e){this.fromString(String.fromCharCode.apply(null,j.BufferSourceConverter.toUint8Array(e)))}toBuffer(){let e=this.toString(),t=new ArrayBuffer(e.length),n=new Uint8Array(t);for(let o=0;o<e.length;o++)n[o]=e.charCodeAt(o);return t}fromDate(e){this.year=e.getUTCFullYear(),this.month=e.getUTCMonth()+1,this.day=e.getUTCDate(),this.hour=e.getUTCHours(),this.minute=e.getUTCMinutes(),this.second=e.getUTCSeconds()}toDate(){return new Date(Date.UTC(this.year,this.month-1,this.day,this.hour,this.minute,this.second))}fromString(e){let n=/(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})Z/ig.exec(e);if(n===null){this.error="Wrong input string for conversion";return}let o=parseInt(n[1],10);o>=50?this.year=1900+o:this.year=2e3+o,this.month=parseInt(n[2],10),this.day=parseInt(n[3],10),this.hour=parseInt(n[4],10),this.minute=parseInt(n[5],10),this.second=parseInt(n[6],10)}toString(e="iso"){if(e==="iso"){let t=new Array(7);return t[0]=Fe(this.year<2e3?this.year-1900:this.year-2e3,2),t[1]=Fe(this.month,2),t[2]=Fe(this.day,2),t[3]=Fe(this.hour,2),t[4]=Fe(this.minute,2),t[5]=Fe(this.second,2),t[6]="Z",t.join("")}return super.toString(e)}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.toDate().toISOString()}`}toJSON(){return{...super.toJSON(),year:this.year,month:this.month,day:this.day,hour:this.hour,minute:this.minute,second:this.second}}};Nu=pn;_.UTCTime=Nu;pn.NAME="UTCTime";var Uu,Oo=class extends pn{constructor(e={}){var t;super(e),(t=this.millisecond)!==null&&t!==void 0||(this.millisecond=0),this.idBlock.tagClass=1,this.idBlock.tagNumber=24}fromDate(e){super.fromDate(e),this.millisecond=e.getUTCMilliseconds()}toDate(){return new Date(Date.UTC(this.year,this.month-1,this.day,this.hour,this.minute,this.second,this.millisecond))}fromString(e){let t=!1,n="",o="",i=0,s,a=0,c=0;if(e[e.length-1]==="Z")n=e.substring(0,e.length-1),t=!0;else{let l=new Number(e[e.length-1]);if(isNaN(l.valueOf()))throw new Error("Wrong input string for conversion");n=e}if(t){if(n.indexOf("+")!==-1)throw new Error("Wrong input string for conversion");if(n.indexOf("-")!==-1)throw new Error("Wrong input string for conversion")}else{let l=1,h=n.indexOf("+"),b="";if(h===-1&&(h=n.indexOf("-"),l=-1),h!==-1){if(b=n.substring(h+1),n=n.substring(0,h),b.length!==2&&b.length!==4)throw new Error("Wrong input string for conversion");let I=parseInt(b.substring(0,2),10);if(isNaN(I.valueOf()))throw new Error("Wrong input string for conversion");if(a=l*I,b.length===4){if(I=parseInt(b.substring(2,4),10),isNaN(I.valueOf()))throw new Error("Wrong input string for conversion");c=l*I}}}let f=n.indexOf(".");if(f===-1&&(f=n.indexOf(",")),f!==-1){let l=new Number(`0${n.substring(f)}`);if(isNaN(l.valueOf()))throw new Error("Wrong input string for conversion");i=l.valueOf(),o=n.substring(0,f)}else o=n;switch(!0){case o.length===8:if(s=/(\d{4})(\d{2})(\d{2})/ig,f!==-1)throw new Error("Wrong input string for conversion");break;case o.length===10:if(s=/(\d{4})(\d{2})(\d{2})(\d{2})/ig,f!==-1){let l=60*i;this.minute=Math.floor(l),l=60*(l-this.minute),this.second=Math.floor(l),l=1e3*(l-this.second),this.millisecond=Math.floor(l)}break;case o.length===12:if(s=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})/ig,f!==-1){let l=60*i;this.second=Math.floor(l),l=1e3*(l-this.second),this.millisecond=Math.floor(l)}break;case o.length===14:if(s=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/ig,f!==-1){let l=1e3*i;this.millisecond=Math.floor(l)}break;default:throw new Error("Wrong input string for conversion")}let u=s.exec(o);if(u===null)throw new Error("Wrong input string for conversion");for(let l=1;l<u.length;l++)switch(l){case 1:this.year=parseInt(u[l],10);break;case 2:this.month=parseInt(u[l],10);break;case 3:this.day=parseInt(u[l],10);break;case 4:this.hour=parseInt(u[l],10)+a;break;case 5:this.minute=parseInt(u[l],10)+c;break;case 6:this.second=parseInt(u[l],10);break;default:throw new Error("Wrong input string for conversion")}if(t===!1){let l=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);this.year=l.getUTCFullYear(),this.month=l.getUTCMonth(),this.day=l.getUTCDay(),this.hour=l.getUTCHours(),this.minute=l.getUTCMinutes(),this.second=l.getUTCSeconds(),this.millisecond=l.getUTCMilliseconds()}}toString(e="iso"){if(e==="iso"){let t=[];return t.push(Fe(this.year,4)),t.push(Fe(this.month,2)),t.push(Fe(this.day,2)),t.push(Fe(this.hour,2)),t.push(Fe(this.minute,2)),t.push(Fe(this.second,2)),this.millisecond!==0&&(t.push("."),t.push(Fe(this.millisecond,3))),t.push("Z"),t.join("")}return super.toString(e)}toJSON(){return{...super.toJSON(),millisecond:this.millisecond}}};Uu=Oo;_.GeneralizedTime=Uu;Oo.NAME="GeneralizedTime";var Ru,Mo=class extends At{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=31}};Ru=Mo;_.DATE=Ru;Mo.NAME="DATE";var _u,$o=class extends At{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=32}};_u=$o;_.TimeOfDay=_u;$o.NAME="TimeOfDay";var Lu,Ho=class extends At{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=33}};Lu=Ho;_.DateTime=Lu;Ho.NAME="DateTime";var Pu,Ko=class extends At{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=34}};Pu=Ko;_.Duration=Pu;Ko.NAME="Duration";var Vu,qo=class extends At{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=14}};Vu=qo;_.TIME=Vu;qo.NAME="TIME";function ne(r,e="utf8"){let t=Qn[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return t.encoder.encode(r).substring(1)}var mn=class extends Error{constructor(e="An error occurred while verifying a message"){super(e),this.name="VerificationError"}},jo=class extends Error{constructor(e="Missing Web Crypto API"){super(e),this.name="WebCryptoMissingError"}};var Fu={get(r=globalThis){let e=r.crypto;if(e?.subtle==null)throw new jo("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 e}};var zt=Fu;async function Du(r){let e=await zt.get().subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:r,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-256"}},!0,["sign","verify"]),t=await lp(e);return{privateKey:t[0],publicKey:t[1]}}async function Ou(r,e){let t=await zt.get().subtle.importKey("jwk",r,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["sign"]),n=await zt.get().subtle.sign({name:"RSASSA-PKCS1-v1_5"},t,e instanceof Uint8Array?e:e.subarray());return new Uint8Array(n,0,n.byteLength)}async function Mu(r,e,t){let n=await zt.get().subtle.importKey("jwk",r,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["verify"]);return zt.get().subtle.verify({name:"RSASSA-PKCS1-v1_5"},n,e,t instanceof Uint8Array?t:t.subarray())}async function lp(r){if(r.privateKey==null||r.publicKey==null)throw new Ee("Private and public key are required");return Promise.all([zt.get().subtle.exportKey("jwk",r.privateKey),zt.get().subtle.exportKey("jwk",r.publicKey)])}function Gs(r){if(r.kty!=="RSA")throw new Ee("invalid key type");if(r.n==null)throw new Ee("invalid key modulus");return Z(r.n,"base64url").length*8}var Pr=class{type="RSA";_key;_raw;_multihash;constructor(e,t){this._key=e,this._multihash=t}get raw(){return this._raw==null&&(this._raw=gn.jwkToPkix(this._key)),this._raw}toMultihash(){return this._multihash}toCID(){return X.createV1(114,this._multihash)}toString(){return re.encode(this.toMultihash().bytes).substring(1)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:ce(this.raw,e.raw)}verify(e,t){return Mu(this._key,t,e)}},yn=class{type="RSA";_key;_raw;publicKey;constructor(e,t){this._key=e,this.publicKey=t}get raw(){return this._raw==null&&(this._raw=gn.jwkToPkcs1(this._key)),this._raw}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:ce(this.raw,e.raw)}sign(e){return Ou(this._key,e)}};var Go=8192,Zs=18;function $u(r){let{result:e}=js(r),t=e.valueBlock.value;return{n:lt(t[1]),e:lt(t[2]),d:lt(t[3]),p:lt(t[4]),q:lt(t[5]),dp:lt(t[6]),dq:lt(t[7]),qi:lt(t[8]),kty:"RSA",alg:"RS256"}}function fp(r){if(r.n==null||r.e==null||r.d==null||r.p==null||r.q==null||r.dp==null||r.dq==null||r.qi==null)throw new Ee("JWK was missing components");let t=new Bt({value:[new be({value:0}),be.fromBigInt(ft(Z(r.n,"base64url"))),be.fromBigInt(ft(Z(r.e,"base64url"))),be.fromBigInt(ft(Z(r.d,"base64url"))),be.fromBigInt(ft(Z(r.p,"base64url"))),be.fromBigInt(ft(Z(r.q,"base64url"))),be.fromBigInt(ft(Z(r.dp,"base64url"))),be.fromBigInt(ft(Z(r.dq,"base64url"))),be.fromBigInt(ft(Z(r.qi,"base64url")))]}).toBER();return new Uint8Array(t,0,t.byteLength)}function Hu(r){let{result:e}=js(r),t=e.valueBlock.value[1].valueBlock.value[0].valueBlock.value;return{kty:"RSA",n:lt(t[0]),e:lt(t[1])}}function Ws(r){if(r.n==null||r.e==null)throw new Ee("JWK was missing components");let t=new Bt({value:[new Bt({value:[new _r({value:"1.2.840.113549.1.1.1"}),new Ur]}),new Rr({valueHex:new Bt({value:[be.fromBigInt(ft(Z(r.n,"base64url"))),be.fromBigInt(ft(Z(r.e,"base64url")))]}).toBER()})]}).toBER();return new Uint8Array(t,0,t.byteLength)}function lt(r){let e=r.valueBlock.valueHexView;for(;e[0]===0;)e=e.subarray(1);return ne(e,"base64url")}function ft(r){let e=[];return r.forEach(function(t){let n=t.toString(16);n.length%2>0&&(n=`0${n}`),e.push(n)}),BigInt("0x"+e.join(""))}function Ku(r){let e=$u(r);return qu(e)}function Ys(r){let e=Hu(r);if(Gs(e)>Go)throw new lr("Key size is too large");let t=Cr(ct.encode({Type:he.RSA,Data:r})),n=Ze(Zs,t);return new Pr(e,n)}function qu(r){if(Gs(r)>Go)throw new Ee("Key size is too large");let e=ju(r),t=Cr(ct.encode({Type:he.RSA,Data:Ws(e.publicKey)})),n=Ze(Zs,t);return new yn(e.privateKey,new Pr(e.publicKey,n))}async function zu(r){if(r>Go)throw new Ee("Key size is too large");let e=await Du(r),t=Cr(ct.encode({Type:he.RSA,Data:Ws(e.publicKey)})),n=Ze(Zs,t);return new yn(e.privateKey,new Pr(e.publicKey,n))}function ju(r){if(r==null)throw new Ee("Missing key parameter");return{privateKey:r,publicKey:{kty:r.kty,n:r.n,e:r.e}}}var Zo=class extends vr{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,pc(e);let n=Jr(t);if(this.iHash=e.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?e.create().update(n).digest():n);for(let s=0;s<i.length;s++)i[s]^=54;this.iHash.update(i),this.oHash=e.create();for(let s=0;s<i.length;s++)i[s]^=106;this.oHash.update(i),i.fill(0)}update(e){return br(this),this.iHash.update(e),this}digestInto(e){br(this),xr(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){let e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));let{oHash:t,iHash:n,finished:o,destroyed:i,blockLen:s,outputLen:a}=this;return e=e,e.finished=o,e.destroyed=i,e.blockLen=s,e.outputLen=a,e.oHash=t._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},Js=(r,e,t)=>new Zo(r,e).update(t).digest();Js.create=(r,e)=>new Zo(r,e);function Gu(r){r.lowS!==void 0&&Je("lowS",r.lowS),r.prehash!==void 0&&Je("prehash",r.prehash)}function hp(r){let e=en(r);at(e,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});let{endo:t,Fp:n,a:o}=e;if(t){if(!n.eql(o,n.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if(typeof t!="object"||typeof t.beta!="bigint"||typeof t.splitScalar!="function")throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...e})}var{bytesToNumberBE:dp,hexToBytes:pp}=qn,Tt={Err:class extends Error{constructor(e=""){super(e)}},_tlv:{encode:(r,e)=>{let{Err:t}=Tt;if(r<0||r>256)throw new t("tlv.encode: wrong tag");if(e.length&1)throw new t("tlv.encode: unpadded data");let n=e.length/2,o=Yt(n);if(o.length/2&128)throw new t("tlv.encode: long form length too big");let i=n>127?Yt(o.length/2|128):"";return`${Yt(r)}${i}${o}${e}`},decode(r,e){let{Err:t}=Tt,n=0;if(r<0||r>256)throw new t("tlv.encode: wrong tag");if(e.length<2||e[n++]!==r)throw new t("tlv.decode: wrong tlv");let o=e[n++],i=!!(o&128),s=0;if(!i)s=o;else{let c=o&127;if(!c)throw new t("tlv.decode(long): indefinite length not supported");if(c>4)throw new t("tlv.decode(long): byte length is too big");let f=e.subarray(n,n+c);if(f.length!==c)throw new t("tlv.decode: length bytes not complete");if(f[0]===0)throw new t("tlv.decode(long): zero leftmost byte");for(let u of f)s=s<<8|u;if(n+=c,s<128)throw new t("tlv.decode(long): not minimal encoding")}let a=e.subarray(n,n+s);if(a.length!==s)throw new t("tlv.decode: wrong value length");return{v:a,l:e.subarray(n+s)}}},_int:{encode(r){let{Err:e}=Tt;if(r<kt)throw new e("integer: negative integers are not allowed");let t=Yt(r);if(Number.parseInt(t[0],16)&8&&(t="00"+t),t.length&1)throw new e("unexpected assertion");return t},decode(r){let{Err:e}=Tt;if(r[0]&128)throw new e("Invalid signature integer: negative");if(r[0]===0&&!(r[1]&128))throw new e("Invalid signature integer: unnecessary leading zero");return dp(r)}},toSig(r){let{Err:e,_int:t,_tlv:n}=Tt,o=typeof r=="string"?pp(r):r;Br(o);let{v:i,l:s}=n.decode(48,o);if(s.length)throw new e("Invalid signature: left bytes after parsing");let{v:a,l:c}=n.decode(2,i),{v:f,l:u}=n.decode(2,c);if(u.length)throw new e("Invalid signature: left bytes after parsing");return{r:t.decode(a),s:t.decode(f)}},hexFromSig(r){let{_tlv:e,_int:t}=Tt,n=`${e.encode(2,t.encode(r.r))}${e.encode(2,t.encode(r.s))}`;return e.encode(48,n)}},kt=BigInt(0),me=BigInt(1),bx=BigInt(2),Zu=BigInt(3),vx=BigInt(4);function mp(r){let e=hp(r),{Fp:t}=e,n=Ot(e.n,e.nBitLength),o=e.toBytes||((w,d,E)=>{let k=d.toAffine();return bt(Uint8Array.from([4]),t.toBytes(k.x),t.toBytes(k.y))}),i=e.fromBytes||(w=>{let d=w.subarray(1),E=t.fromBytes(d.subarray(0,t.BYTES)),k=t.fromBytes(d.subarray(t.BYTES,2*t.BYTES));return{x:E,y:k}});function s(w){let{a:d,b:E}=e,k=t.sqr(w),x=t.mul(k,w);return t.add(t.add(x,t.mul(w,d)),E)}if(!t.eql(t.sqr(e.Gy),s(e.Gx)))throw new Error("bad generator point: equation left != right");function a(w){return Xr(w,me,e.n)}function c(w){let{allowedPrivateKeyLengths:d,nByteLength:E,wrapPrivateKey:k,n:x}=e;if(d&&typeof w!="bigint"){if(Vt(w)&&(w=wt(w)),typeof w!="string"||!d.includes(w.length))throw new Error("Invalid key");w=w.padStart(E*2,"0")}let C;try{C=typeof w=="bigint"?w:xt(ae("private key",w,E))}catch{throw new Error(`private key must be ${E} bytes, hex or bigint, not ${typeof w}`)}return k&&(C=Q(C,x)),Le("private key",C,me,x),C}function f(w){if(!(w instanceof h))throw new Error("ProjectivePoint expected")}let u=Qt((w,d)=>{let{px:E,py:k,pz:x}=w;if(t.eql(x,t.ONE))return{x:E,y:k};let C=w.is0();d==null&&(d=C?t.ONE:t.inv(x));let F=t.mul(E,d),P=t.mul(k,d),U=t.mul(x,d);if(C)return{x:t.ZERO,y:t.ZERO};if(!t.eql(U,t.ONE))throw new Error("invZ was invalid");return{x:F,y:P}}),l=Qt(w=>{if(w.is0()){if(e.allowInfinityPoint&&!t.is0(w.py))return;throw new Error("bad point: ZERO")}let{x:d,y:E}=w.toAffine();if(!t.isValid(d)||!t.isValid(E))throw new Error("bad point: x or y not FE");let k=t.sqr(E),x=s(d);if(!t.eql(k,x))throw new Error("bad point: equation left != right");if(!w.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class h{constructor(d,E,k){if(this.px=d,this.py=E,this.pz=k,d==null||!t.isValid(d))throw new Error("x required");if(E==null||!t.isValid(E))throw new Error("y required");if(k==null||!t.isValid(k))throw new Error("z required");Object.freeze(this)}static fromAffine(d){let{x:E,y:k}=d||{};if(!d||!t.isValid(E)||!t.isValid(k))throw new Error("invalid affine point");if(d instanceof h)throw new Error("projective point not allowed");let x=C=>t.eql(C,t.ZERO);return x(E)&&x(k)?h.ZERO:new h(E,k,t.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(d){let E=t.invertBatch(d.map(k=>k.pz));return d.map((k,x)=>k.toAffine(E[x])).map(h.fromAffine)}static fromHex(d){let E=h.fromAffine(i(ae("pointHex",d)));return E.assertValidity(),E}static fromPrivateKey(d){return h.BASE.multiply(c(d))}static msm(d,E){return Gn(h,n,d,E)}_setWindowSize(d){I.setWindowSize(this,d)}assertValidity(){l(this)}hasEvenY(){let{y:d}=this.toAffine();if(t.isOdd)return!t.isOdd(d);throw new Error("Field doesn't support isOdd")}equals(d){f(d);let{px:E,py:k,pz:x}=this,{px:C,py:F,pz:P}=d,U=t.eql(t.mul(E,P),t.mul(C,x)),g=t.eql(t.mul(k,P),t.mul(F,x));return U&&g}negate(){return new h(this.px,t.neg(this.py),this.pz)}double(){let{a:d,b:E}=e,k=t.mul(E,Zu),{px:x,py:C,pz:F}=this,P=t.ZERO,U=t.ZERO,g=t.ZERO,v=t.mul(x,x),D=t.mul(C,C),R=t.mul(F,F),N=t.mul(x,C);return N=t.add(N,N),g=t.mul(x,F),g=t.add(g,g),P=t.mul(d,g),U=t.mul(k,R),U=t.add(P,U),P=t.sub(D,U),U=t.add(D,U),U=t.mul(P,U),P=t.mul(N,P),g=t.mul(k,g),R=t.mul(d,R),N=t.sub(v,R),N=t.mul(d,N),N=t.add(N,g),g=t.add(v,v),v=t.add(g,v),v=t.add(v,R),v=t.mul(v,N),U=t.add(U,v),R=t.mul(C,F),R=t.add(R,R),v=t.mul(R,N),P=t.sub(P,v),g=t.mul(R,D),g=t.add(g,g),g=t.add(g,g),new h(P,U,g)}add(d){f(d);let{px:E,py:k,pz:x}=this,{px:C,py:F,pz:P}=d,U=t.ZERO,g=t.ZERO,v=t.ZERO,D=e.a,R=t.mul(e.b,Zu),N=t.mul(E,C),H=t.mul(k,F),A=t.mul(x,P),S=t.add(E,k),m=t.add(C,F);S=t.mul(S,m),m=t.add(N,H),S=t.sub(S,m),m=t.add(E,x);let p=t.add(C,P);return m=t.mul(m,p),p=t.add(N,A),m=t.sub(m,p),p=t.add(k,x),U=t.add(F,P),p=t.mul(p,U),U=t.add(H,A),p=t.sub(p,U),v=t.mul(D,m),U=t.mul(R,A),v=t.add(U,v),U=t.sub(H,v),v=t.add(H,v),g=t.mul(U,v),H=t.add(N,N),H=t.add(H,N),A=t.mul(D,A),m=t.mul(R,m),H=t.add(H,A),A=t.sub(N,A),A=t.mul(D,A),m=t.add(m,A),N=t.mul(H,m),g=t.add(g,N),N=t.mul(p,m),U=t.mul(S,U),U=t.sub(U,N),N=t.mul(S,H),v=t.mul(p,v),v=t.add(v,N),new h(U,g,v)}subtract(d){return this.add(d.negate())}is0(){return this.equals(h.ZERO)}wNAF(d){return I.wNAFCached(this,d,h.normalizeZ)}multiplyUnsafe(d){Le("scalar",d,kt,e.n);let E=h.ZERO;if(d===kt)return E;if(d===me)return this;let{endo:k}=e;if(!k)return I.unsafeLadder(this,d);let{k1neg:x,k1:C,k2neg:F,k2:P}=k.splitScalar(d),U=E,g=E,v=this;for(;C>kt||P>kt;)C&me&&(U=U.add(v)),P&me&&(g=g.add(v)),v=v.double(),C>>=me,P>>=me;return x&&(U=U.negate()),F&&(g=g.negate()),g=new h(t.mul(g.px,k.beta),g.py,g.pz),U.add(g)}multiply(d){let{endo:E,n:k}=e;Le("scalar",d,me,k);let x,C;if(E){let{k1neg:F,k1:P,k2neg:U,k2:g}=E.splitScalar(d),{p:v,f:D}=this.wNAF(P),{p:R,f:N}=this.wNAF(g);v=I.constTimeNegate(F,v),R=I.constTimeNegate(U,R),R=new h(t.mul(R.px,E.beta),R.py,R.pz),x=v.add(R),C=D.add(N)}else{let{p:F,f:P}=this.wNAF(d);x=F,C=P}return h.normalizeZ([x,C])[0]}multiplyAndAddUnsafe(d,E,k){let x=h.BASE,C=(P,U)=>U===kt||U===me||!P.equals(x)?P.multiplyUnsafe(U):P.multiply(U),F=C(this,E).add(C(d,k));return F.is0()?void 0:F}toAffine(d){return u(this,d)}isTorsionFree(){let{h:d,isTorsionFree:E}=e;if(d===me)return!0;if(E)return E(h,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h:d,clearCofactor:E}=e;return d===me?this:E?E(h,this):this.multiplyUnsafe(e.h)}toRawBytes(d=!0){return Je("isCompressed",d),this.assertValidity(),o(h,this,d)}toHex(d=!0){return Je("isCompressed",d),wt(this.toRawBytes(d))}}h.BASE=new h(e.Gx,e.Gy,t.ONE),h.ZERO=new h(t.ZERO,t.ONE,t.ZERO);let b=e.nBitLength,I=jn(h,e.endo?Math.ceil(b/2):b);return{CURVE:e,ProjectivePoint:h,normPrivateKeyToScalar:c,weierstrassEquation:s,isWithinCurveOrder:a}}function gp(r){let e=en(r);return at(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function Wu(r){let e=gp(r),{Fp:t,n}=e,o=t.BYTES+1,i=2*t.BYTES+1;function s(A){return Q(A,n)}function a(A){return zn(A,n)}let{ProjectivePoint:c,normPrivateKeyToScalar:f,weierstrassEquation:u,isWithinCurveOrder:l}=mp({...e,toBytes(A,S,m){let p=S.toAffine(),B=t.toBytes(p.x),V=bt;return Je("isCompressed",m),m?V(Uint8Array.from([S.hasEvenY()?2:3]),B):V(Uint8Array.from([4]),B,t.toBytes(p.y))},fromBytes(A){let S=A.length,m=A[0],p=A.subarray(1);if(S===o&&(m===2||m===3)){let B=xt(p);if(!Xr(B,me,t.ORDER))throw new Error("Point is not on curve");let V=u(B),O;try{O=t.sqrt(V)}catch(G){let z=G instanceof Error?": "+G.message:"";throw new Error("Point is not on curve"+z)}let M=(O&me)===me;return(m&1)===1!==M&&(O=t.neg(O)),{x:B,y:O}}else if(S===i&&m===4){let B=t.fromBytes(p.subarray(0,t.BYTES)),V=t.fromBytes(p.subarray(t.BYTES,2*t.BYTES));return{x:B,y:V}}else throw new Error(`Point of length ${S} was invalid. Expected ${o} compressed bytes or ${i} uncompressed bytes`)}}),h=A=>wt(Dt(A,e.nByteLength));function b(A){let S=n>>me;return A>S}function I(A){return b(A)?s(-A):A}let w=(A,S,m)=>xt(A.slice(S,m));class d{constructor(S,m,p){this.r=S,this.s=m,this.recovery=p,this.assertValidity()}static fromCompact(S){let m=e.nByteLength;return S=ae("compactSignature",S,m*2),new d(w(S,0,m),w(S,m,2*m))}static fromDER(S){let{r:m,s:p}=Tt.toSig(ae("DER",S));return new d(m,p)}assertValidity(){Le("r",this.r,me,n),Le("s",this.s,me,n)}addRecoveryBit(S){return new d(this.r,this.s,S)}recoverPublicKey(S){let{r:m,s:p,recovery:B}=this,V=P(ae("msgHash",S));if(B==null||![0,1,2,3].includes(B))throw new Error("recovery id invalid");let O=B===2||B===3?m+e.n:m;if(O>=t.ORDER)throw new Error("recovery id 2 or 3 invalid");let M=B&1?"03":"02",q=c.fromHex(M+h(O)),G=a(O),z=s(-V*G),J=s(p*G),te=c.BASE.multiplyAndAddUnsafe(q,z,J);if(!te)throw new Error("point at infinify");return te.assertValidity(),te}hasHighS(){return b(this.s)}normalizeS(){return this.hasHighS()?new d(this.r,s(-this.s),this.recovery):this}toDERRawBytes(){return Jt(this.toDERHex())}toDERHex(){return Tt.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Jt(this.toCompactHex())}toCompactHex(){return h(this.r)+h(this.s)}}let E={isValidPrivateKey(A){try{return f(A),!0}catch{return!1}},normPrivateKeyToScalar:f,randomPrivateKey:()=>{let A=ss(e.n);return Tc(e.randomBytes(A),e.n)},precompute(A=8,S=c.BASE){return S._setWindowSize(A),S.multiply(BigInt(3)),S}};function k(A,S=!0){return c.fromPrivateKey(A).toRawBytes(S)}function x(A){let S=Vt(A),m=typeof A=="string",p=(S||m)&&A.length;return S?p===o||p===i:m?p===2*o||p===2*i:A instanceof c}function C(A,S,m=!0){if(x(A))throw new Error("first arg must be private key");if(!x(S))throw new Error("second arg must be public key");return c.fromHex(S).multiply(f(A)).toRawBytes(m)}let F=e.bits2int||function(A){let S=xt(A),m=A.length*8-e.nBitLength;return m>0?S>>BigInt(m):S},P=e.bits2int_modN||function(A){return s(F(A))},U=Qr(e.nBitLength);function g(A){return Le(`num < 2^${e.nBitLength}`,A,kt,U),Dt(A,e.nByteLength)}function v(A,S,m=D){if(["recovered","canonical"].some(pe=>pe in m))throw new Error("sign() legacy options not supported");let{hash:p,randomBytes:B}=e,{lowS:V,prehash:O,extraEntropy:M}=m;V==null&&(V=!0),A=ae("msgHash",A),Gu(m),O&&(A=ae("prehashed msgHash",p(A)));let q=P(A),G=f(S),z=[g(G),g(q)];if(M!=null&&M!==!1){let pe=M===!0?B(t.BYTES):M;z.push(ae("extraEntropy",pe))}let J=bt(...z),te=q;function de(pe){let we=F(pe);if(!l(we))return;let Te=a(we),le=c.BASE.multiply(we).toAffine(),Ue=s(le.x);if(Ue===kt)return;let pt=s(Te*s(te+Ue*G));if(pt===kt)return;let jr=(le.x===Ue?0:2)|Number(le.y&me),Gr=pt;return V&&b(pt)&&(Gr=I(pt),jr^=1),new d(Ue,Gr,jr)}return{seed:J,k2sig:de}}let D={lowS:e.lowS,prehash:!1},R={lowS:e.lowS,prehash:!1};function N(A,S,m=D){let{seed:p,k2sig:B}=v(A,S,m),V=e;return rs(V.hash.outputLen,V.nByteLength,V.hmac)(p,B)}c.BASE._setWindowSize(8);function H(A,S,m,p=R){let B=A;if(S=ae("msgHash",S),m=ae("publicKey",m),"strict"in p)throw new Error("options.strict was renamed to lowS");Gu(p);let{lowS:V,prehash:O}=p,M,q;try{if(typeof B=="string"||Vt(B))try{M=d.fromDER(B)}catch(le){if(!(le instanceof Tt.Err))throw le;M=d.fromCompact(B)}else if(typeof B=="object"&&typeof B.r=="bigint"&&typeof B.s=="bigint"){let{r:le,s:Ue}=B;M=new d(le,Ue)}else throw new Error("PARSE");q=c.fromHex(m)}catch(le){if(le.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(V&&M.hasHighS())return!1;O&&(S=e.hash(S));let{r:G,s:z}=M,J=P(S),te=a(z),de=s(J*te),pe=s(G*te),we=c.BASE.multiplyAndAddUnsafe(q,de,pe)?.toAffine();return we?s(we.x)===G:!1}return{CURVE:e,getPublicKey:k,getSharedSecret:C,sign:N,verify:H,ProjectivePoint:c,Signature:d,utils:E}}function yp(r){return{hash:r,hmac:(e,...t)=>Js(r,e,Zi(...t)),randomBytes:$n}}function Yu(r,e){let t=n=>Wu({...r,...yp(n)});return Object.freeze({...t(e),create:t})}var Qu=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),Ju=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),wp=BigInt(1),Xs=BigInt(2),Xu=(r,e)=>(r+e/Xs)/e;function xp(r){let e=Qu,t=BigInt(3),n=BigInt(6),o=BigInt(11),i=BigInt(22),s=BigInt(23),a=BigInt(44),c=BigInt(88),f=r*r*r%e,u=f*f*r%e,l=ie(u,t,e)*u%e,h=ie(l,t,e)*u%e,b=ie(h,Xs,e)*f%e,I=ie(b,o,e)*b%e,w=ie(I,i,e)*I%e,d=ie(w,a,e)*w%e,E=ie(d,c,e)*d%e,k=ie(E,a,e)*w%e,x=ie(k,t,e)*u%e,C=ie(x,s,e)*I%e,F=ie(C,n,e)*f%e,P=ie(F,Xs,e);if(!Qs.eql(Qs.sqr(P),r))throw new Error("Cannot find square root");return P}var Qs=Ot(Qu,void 0,void 0,{sqrt:xp}),ir=Yu({a:BigInt(0),b:BigInt(7),Fp:Qs,n:Ju,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:r=>{let e=Ju,t=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-wp*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),i=t,s=BigInt("0x100000000000000000000000000000000"),a=Xu(i*r,e),c=Xu(-n*r,e),f=Q(r-a*t-c*o,e),u=Q(-a*n-c*i,e),l=f>s,h=u>s;if(l&&(f=e-f),h&&(u=e-u),f>s||u>s)throw new Error("splitScalar: Endomorphism failed, k="+r);return{k1neg:l,k1:f,k2neg:h,k2:u}}}},Cr),Nx=BigInt(0);var Ux=ir.ProjectivePoint;function Oe(r,e){e==null&&(e=r.reduce((o,i)=>o+i.length,0));let t=Qe(e),n=0;for(let o of r)t.set(o,n),n+=o.length;return t}function el(r){return r==null?!1:typeof r.then=="function"&&typeof r.catch=="function"&&typeof r.finally=="function"}function tl(r,e,t){let n=tn.digest(t instanceof Uint8Array?t:t.subarray());if(el(n))return n.then(({digest:o})=>ir.verify(e,o,r)).catch(o=>{throw new mn(String(o))});try{return ir.verify(e,n.digest,r)}catch(o){throw new mn(String(o))}}var Wo=class{type="secp256k1";raw;_key;constructor(e){this._key=nl(e),this.raw=rl(this._key)}toMultihash(){return We.digest(Jn(this))}toCID(){return X.createV1(114,this.toMultihash())}toString(){return re.encode(this.toMultihash().bytes).substring(1)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:ce(this.raw,e.raw)}verify(e,t){return tl(this._key,t,e)}};function ea(r){return new Wo(r)}function rl(r){return ir.ProjectivePoint.fromHex(r).toRawBytes(!0)}function nl(r){try{return ir.ProjectivePoint.fromHex(r),r}catch(e){throw new lr(String(e))}}function ol(r){let{Type:e,Data:t}=ct.decode(r),n=t??new Uint8Array;switch(e){case he.RSA:return Ys(n);case he.Ed25519:return fs(n);case he.secp256k1:return ea(n);default:throw new hr}}function Yo(r){let{Type:e,Data:t}=ct.decode(r.digest),n=t??new Uint8Array;switch(e){case he.Ed25519:return fs(n);case he.secp256k1:return ea(n);default:throw new hr}}function Jn(r){return ct.encode({Type:he[r.type],Data:r.raw})}var il=Symbol.for("nodejs.util.inspect.custom"),bp=114,wn=class{type;multihash;publicKey;string;constructor(e){this.type=e.type,this.multihash=e.multihash,Object.defineProperty(this,"string",{enumerable:!1,writable:!0})}get[Symbol.toStringTag](){return`PeerId(${this.toString()})`}[Li]=!0;toString(){return this.string==null&&(this.string=re.encode(this.multihash.bytes).slice(1)),this.string}toMultihash(){return this.multihash}toCID(){return X.createV1(bp,this.multihash)}toJSON(){return this.toString()}equals(e){if(e==null)return!1;if(e instanceof Uint8Array)return ce(this.multihash.bytes,e);if(typeof e=="string")return this.toString()===e;if(e?.toMultihash()?.bytes!=null)return ce(this.multihash.bytes,e.toMultihash().bytes);throw new Error("not valid Id")}[il](){return`PeerId(${this.toString()})`}},Jo=class extends wn{type="RSA";publicKey;constructor(e){super({...e,type:"RSA"}),this.publicKey=e.publicKey}},Xo=class extends wn{type="Ed25519";publicKey;constructor(e){super({...e,type:"Ed25519"}),this.publicKey=e.publicKey}},Qo=class extends wn{type="secp256k1";publicKey;constructor(e){super({...e,type:"secp256k1"}),this.publicKey=e.publicKey}},vp=2336,xn=class{type="url";multihash;publicKey;url;constructor(e){this.url=e.toString(),this.multihash=We.digest(Z(this.url))}[il](){return`PeerId(${this.url})`}[Li]=!0;toString(){return this.toCID().toString()}toMultihash(){return this.multihash}toCID(){return X.createV1(vp,this.toMultihash())}toJSON(){return this.toString()}equals(e){return e==null?!1:(e instanceof Uint8Array&&(e=ne(e)),e.toString()===this.toString())}};var Ep=114,sl=2336;function al(r,e){let t;if(r.charAt(0)==="1"||r.charAt(0)==="Q")t=gt(re.decode(`z${r}`));else{if(e==null)throw new Ee('Please pass a multibase decoder for strings that do not start with "1" or "Q"');t=gt(e.decode(r))}return cl(t)}function cl(r){if(Ap(r))return new Jo({multihash:r});if(Bp(r))try{let e=Yo(r);if(e.type==="Ed25519")return new Xo({multihash:r,publicKey:e});if(e.type==="secp256k1")return new Qo({multihash:r,publicKey:e})}catch{let t=ne(r.digest);return new xn(new URL(t))}throw new fr("Supplied PeerID Multihash is invalid")}function ul(r){if(r?.multihash==null||r.version==null||r.version===1&&r.code!==Ep&&r.code!==sl)throw new Ln("Supplied PeerID CID is invalid");if(r.code===sl){let e=ne(r.multihash.digest);return new xn(new URL(e))}return cl(r.multihash)}function Bp(r){return r.code===We.code}function Ap(r){return r.code===tn.code}var ei=class{index=0;input="";new(e){return this.index=0,this.input=e,this}readAtomically(e){let t=this.index,n=e();return n===void 0&&(this.index=t),n}parseWith(e){let t=e();if(this.index===this.input.length)return t}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(e){return this.readAtomically(()=>{let t=this.readChar();if(t===e)return t})}readSeparator(e,t,n){return this.readAtomically(()=>{if(!(t>0&&this.readGivenChar(e)===void 0))return n()})}readNumber(e,t,n,o){return this.readAtomically(()=>{let i=0,s=0,a=this.peekChar();if(a===void 0)return;let c=a==="0",f=2**(8*o)-1;for(;;){let u=this.readAtomically(()=>{let l=this.readChar();if(l===void 0)return;let h=Number.parseInt(l,e);if(!Number.isNaN(h))return h});if(u===void 0)break;if(i*=e,i+=u,i>f||(s+=1,t!==void 0&&s>t))return}if(s!==0)return!n&&c&&s>1?void 0:i})}readIPv4Addr(){return this.readAtomically(()=>{let e=new Uint8Array(4);for(let t=0;t<e.length;t++){let n=this.readSeparator(".",t,()=>this.readNumber(10,3,!1,1));if(n===void 0)return;e[t]=n}return e})}readIPv6Addr(){let e=t=>{for(let n=0;n<t.length/2;n++){let o=n*2;if(n<t.length-3){let s=this.readSeparator(":",n,()=>this.readIPv4Addr());if(s!==void 0)return t[o]=s[0],t[o+1]=s[1],t[o+2]=s[2],t[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];t[o]=i>>8,t[o+1]=i&255}return[t.length,!1]};return this.readAtomically(()=>{let t=new Uint8Array(16),[n,o]=e(t);if(n===16)return t;if(o||this.readGivenChar(":")===void 0||this.readGivenChar(":")===void 0)return;let i=new Uint8Array(14),s=16-(n+2),[a]=e(i.subarray(0,s));return t.set(i.subarray(0,a),16-a),t})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var ll=45,Sp=15,Vr=new ei;function ta(r){if(!(r.length>Sp))return Vr.new(r).parseWith(()=>Vr.readIPv4Addr())}function ra(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>ll))return Vr.new(r).parseWith(()=>Vr.readIPv6Addr())}function ti(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>ll))return Vr.new(r).parseWith(()=>Vr.readIPAddr())}var jb=parseInt("0xFFFF",16),Gb=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);function dl(r){return!!ta(r)}function pl(r){return!!ra(r)}function ri(r){return!!ti(r)}var ml=dl,Np=pl,na=function(r){let e=0;if(r=r.toString().trim(),ml(r)){let t=new Uint8Array(e+4);return r.split(/\./g).forEach(n=>{t[e++]=parseInt(n,10)&255}),t}if(Np(r)){let t=r.split(":",8),n;for(n=0;n<t.length;n++){let i=ml(t[n]),s;i&&(s=na(t[n]),t[n]=ne(s.slice(0,2),"base16")),s!=null&&++n<8&&t.splice(n,0,ne(s.slice(2,4),"base16"))}if(t[0]==="")for(;t.length<8;)t.unshift("0");else if(t[t.length-1]==="")for(;t.length<8;)t.push("0");else if(t.length<8){for(n=0;n<t.length&&t[n]!=="";n++);let i=[n,1];for(n=9-t.length;n>0;n--)i.push("0");t.splice.apply(t,i)}let o=new Uint8Array(e+16);for(n=0;n<t.length;n++){let i=parseInt(t[n],16);o[e++]=i>>8&255,o[e++]=i&255}return o}throw new Error("invalid ip address")},gl=function(r,e=0,t){e=~~e,t=t??r.length-e;let n=new DataView(r.buffer);if(t===4){let o=[];for(let i=0;i<t;i++)o.push(r[e+i]);return o.join(".")}if(t===16){let o=[];for(let i=0;i<t;i+=2)o.push(n.getUint16(e+i).toString(16));return o.join(":").replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}return""};var Fr={},oa={},Rp=[[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"]];Rp.forEach(r=>{let e=_p(...r);oa[e.code]=e,Fr[e.name]=e});function _p(r,e,t,n,o){return{code:r,size:e,name:t,resolvable:!!n,path:!!o}}function ee(r){if(typeof r=="number"){if(oa[r]!=null)return oa[r];throw new Error(`no protocol with code: ${r}`)}else if(typeof r=="string"){if(Fr[r]!=null)return Fr[r];throw new Error(`no protocol with name: ${r}`)}throw new Error(`invalid protocol id type: ${typeof r}`)}var N1=ee("ip4"),U1=ee("ip6"),R1=ee("ipcidr");function ca(r,e){switch(ee(r).code){case 4:case 41:return Pp(e);case 42:return aa(e);case 6:case 273:case 33:case 132:return xl(e).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return aa(e);case 421:return Op(e);case 444:return wl(e);case 445:return wl(e);case 466:return Dp(e);case 481:return globalThis.encodeURIComponent(aa(e));default:return ne(e,"base16")}}function ua(r,e){switch(ee(r).code){case 4:return yl(e);case 41:return yl(e);case 42:return sa(e);case 6:case 273:case 33:case 132:return la(parseInt(e,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return sa(e);case 421:return Vp(e);case 444:return Mp(e);case 445:return $p(e);case 466:return Fp(e);case 481:return sa(globalThis.decodeURIComponent(e));default:return Z(e,"base16")}}var ia=Object.values(rn).map(r=>r.decoder),Lp=function(){let r=ia[0].or(ia[1]);return ia.slice(2).forEach(e=>r=r.or(e)),r}();function yl(r){if(!ri(r))throw new Error("invalid ip address");return na(r)}function Pp(r){let e=gl(r,0,r.length);if(e==null)throw new Error("ipBuff is required");if(!ri(e))throw new Error("invalid ip address");return e}function la(r){let e=new ArrayBuffer(2);return new DataView(e).setUint16(0,r),new Uint8Array(e)}function xl(r){return new DataView(r.buffer).getUint16(r.byteOffset)}function sa(r){let e=Z(r),t=Uint8Array.from(Ar(e.length));return Oe([t,e],t.length+e.length)}function aa(r){let e=tr(r);if(r=r.slice(Ve(e)),r.length!==e)throw new Error("inconsistent lengths");return ne(r)}function Vp(r){let e;r[0]==="Q"||r[0]==="1"?e=gt(re.decode(`z${r}`)).bytes:e=X.parse(r).multihash.bytes;let t=Uint8Array.from(Ar(e.length));return Oe([t,e],t.length+e.length)}function Fp(r){let e=Lp.decode(r),t=Uint8Array.from(Ar(e.length));return Oe([t,e],t.length+e.length)}function Dp(r){let e=tr(r),t=r.slice(Ve(e));if(t.length!==e)throw new Error("inconsistent lengths");return"u"+ne(t,"base64url")}function Op(r){let e=tr(r),t=r.slice(Ve(e));if(t.length!==e)throw new Error("inconsistent lengths");return ne(t,"base58btc")}function Mp(r){let e=r.split(":");if(e.length!==2)throw new Error(`failed to parse onion addr: ["'${e.join('", "')}'"]' does not contain a port number`);if(e[0].length!==16)throw new Error(`failed to parse onion addr: ${e[0]} not a Tor onion address.`);let t=Ge.decode("b"+e[0]),n=parseInt(e[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=la(n);return Oe([t,o],t.length+o.length)}function $p(r){let e=r.split(":");if(e.length!==2)throw new Error(`failed to parse onion addr: ["'${e.join('", "')}'"]' does not contain a port number`);if(e[0].length!==56)throw new Error(`failed to parse onion addr: ${e[0]} not a Tor onion3 address.`);let t=Ge.decode(`b${e[0]}`),n=parseInt(e[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=la(n);return Oe([t,o],t.length+o.length)}function wl(r){let e=r.slice(0,r.length-2),t=r.slice(r.length-2),n=ne(e,"base32"),o=xl(t);return`${n}:${o}`}function bl(r){r=fa(r);let e=[],t=[],n=null,o=r.split("/").slice(1);if(o.length===1&&o[0]==="")return{bytes:new Uint8Array,string:"/",tuples:[],stringTuples:[],path:null};for(let i=0;i<o.length;i++){let s=o[i],a=ee(s);if(a.size===0){e.push([a.code]),t.push([a.code]);continue}if(i++,i>=o.length)throw El("invalid address: "+r);if(a.path===!0){n=fa(o.slice(i).join("/")),e.push([a.code,ua(a.code,n)]),t.push([a.code,n]);break}let c=ua(a.code,o[i]);e.push([a.code,c]),t.push([a.code,ca(a.code,c)])}return{string:vl(t),bytes:da(e),tuples:e,stringTuples:t,path:n}}function ha(r){let e=[],t=[],n=null,o=0;for(;o<r.length;){let i=tr(r,o),s=Ve(i),a=ee(i),c=Hp(a,r.slice(o+s));if(c===0){e.push([i]),t.push([i]),o+=s;continue}let f=r.slice(o+s,o+s+c);if(o+=c+s,o>r.length)throw El("Invalid address Uint8Array: "+ne(r,"base16"));e.push([i,f]);let u=ca(i,f);if(t.push([i,u]),a.path===!0){n=u;break}}return{bytes:Uint8Array.from(r),string:vl(t),tuples:e,stringTuples:t,path:n}}function vl(r){let e=[];return r.map(t=>{let n=ee(t[0]);return e.push(n.name),t.length>1&&t[1]!=null&&e.push(t[1]),null}),fa(e.join("/"))}function da(r){return Oe(r.map(e=>{let t=ee(e[0]),n=Uint8Array.from(Ar(t.code));return e.length>1&&e[1]!=null&&(n=Oe([n,e[1]])),n}))}function Hp(r,e){if(r.size>0)return r.size/8;if(r.size===0)return 0;{let t=tr(e instanceof Uint8Array?e:Uint8Array.from(e));return t+Ve(t)}}function fa(r){return"/"+r.trim().split("/").filter(e=>e).join("/")}function El(r){return new Error("Error parsing address: "+r)}var Kp=Symbol.for("nodejs.util.inspect.custom"),ma=Symbol.for("@multiformats/js-multiaddr/multiaddr"),qp=[ee("dns").code,ee("dns4").code,ee("dns6").code,ee("dnsaddr").code],pa=class extends Error{constructor(e="No available resolver"){super(e),this.name="NoAvailableResolverError"}},ni=class r{bytes;#e;#r;#t;#a;[ma]=!0;constructor(e){e==null&&(e="");let t;if(e instanceof Uint8Array)t=ha(e);else if(typeof e=="string"){if(e.length>0&&e.charAt(0)!=="/")throw new Error(`multiaddr "${e}" must start with a "/"`);t=bl(e)}else if(Al(e))t=ha(e.bytes);else throw new Error("addr must be a string, Buffer, or another Multiaddr");this.bytes=t.bytes,this.#e=t.string,this.#r=t.tuples,this.#t=t.stringTuples,this.#a=t.path}toString(){return this.#e}toJSON(){return this.toString()}toOptions(){let e,t,n,o,i="",s=ee("tcp"),a=ee("udp"),c=ee("ip4"),f=ee("ip6"),u=ee("dns6"),l=ee("ip6zone");for(let[b,I]of this.stringTuples())b===l.code&&(i=`%${I??""}`),qp.includes(b)&&(t=s.name,o=443,n=`${I??""}${i}`,e=b===u.code?6:4),(b===s.code||b===a.code)&&(t=ee(b).name,o=parseInt(I??"")),(b===c.code||b===f.code)&&(t=ee(b).name,n=`${I??""}${i}`,e=b===f.code?6:4);if(e==null||t==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:e,host:n,transport:t,port:o}}protos(){return this.#r.map(([e])=>Object.assign({},ee(e)))}protoCodes(){return this.#r.map(([e])=>e)}protoNames(){return this.#r.map(([e])=>ee(e).name)}tuples(){return this.#r}stringTuples(){return this.#t}encapsulate(e){return e=new r(e),new r(this.toString()+e.toString())}decapsulate(e){let t=e.toString(),n=this.toString(),o=n.lastIndexOf(t);if(o<0)throw new Error(`Address ${this.toString()} does not contain subaddress: ${e.toString()}`);return new r(n.slice(0,o))}decapsulateCode(e){let t=this.tuples();for(let n=t.length-1;n>=0;n--)if(t[n][0]===e)return new r(da(t.slice(0,n)));return this}getPeerId(){try{let e=[];this.stringTuples().forEach(([n,o])=>{n===Fr.p2p.code&&e.push([n,o]),n===Fr["p2p-circuit"].code&&(e=[])});let t=e.pop();if(t?.[1]!=null){let n=t[1];return n[0]==="Q"||n[0]==="1"?ne(re.decode(`z${n}`),"base58btc"):ne(X.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){return this.#a}equals(e){return ce(this.bytes,e.bytes)}async resolve(e){let t=this.protos().find(i=>i.resolvable);if(t==null)return[this];let n=Bl.get(t.name);if(n==null)throw new pa(`no available resolver for ${t.name}`);return(await n(this,e)).map(i=>sr(i))}nodeAddress(){let e=this.toOptions();if(e.transport!=="tcp"&&e.transport!=="udp")throw new Error(`multiaddr must have a valid format - no protocol with name: "${e.transport}". Must have a valid transport protocol: "{tcp, udp}"`);return{family:e.family,address:e.host,port:e.port}}isThinWaistAddress(e){let t=(e??this).protos();return!(t.length!==2||t[0].code!==4&&t[0].code!==41||t[1].code!==6&&t[1].code!==273)}[Kp](){return`Multiaddr(${this.#e})`}};var Bl=new Map;function Al(r){return!!r?.[ma]}function sr(r){return new ni(r)}function bn(r){let e=new globalThis.AbortController;function t(){e.abort();for(let i of r)i?.removeEventListener!=null&&i.removeEventListener("abort",t)}for(let i of r){if(i?.aborted===!0){t();break}i?.addEventListener!=null&&i.addEventListener("abort",t)}function n(){for(let i of r)i?.removeEventListener!=null&&i.removeEventListener("abort",t)}let o=e.signal;return o.clear=n,o}async function*oi(r,e={}){let t=r.getReader();try{for(;;){let n=await t.read();if(n.done)return;yield n.value}}finally{e.preventCancel!==!0&&await t.cancel(),t.releaseLock()}}var zp="/",jp=new TextEncoder().encode(zp),s2=jp[0];var Im=_n(ya(),1);var rt=class extends Error{static name="SignatureVerificationError";constructor(e="Record signature verification failed"){super(e),this.name="SignatureVerificationError"}},ii=class extends Error{static name="RecordExpiredError";constructor(e="Record has expired"){super(e),this.name="RecordExpiredError"}},Dr=class extends Error{static name="UnsupportedValidityError";constructor(e="The validity type is unsupported"){super(e),this.name="UnsupportedValidityError"}},si=class extends Error{static name="RecordTooLargeError";constructor(e="The record is too large"){super(e),this.name="RecordTooLargeError"}},ai=class extends Error{static name="InvalidValueError";constructor(e="Value must be a valid content path starting with /"){super(e),this.name="InvalidValueError"}},ci=class extends Error{static name="InvalidRecordDataError";constructor(e="Invalid record data"){super(e),this.name="InvalidRecordDataError"}},vn=class extends Error{static name="InvalidEmbeddedPublicKeyError";constructor(e="Invalid embedded public key"){super(e),this.name="InvalidEmbeddedPublicKeyError"}};var nt;(function(r){let e;(function(o){o.EOL="EOL"})(e=r.ValidityType||(r.ValidityType={}));let t;(function(o){o[o.EOL=0]="EOL"})(t||(t={})),function(o){o.codec=()=>sn(t)}(e=r.ValidityType||(r.ValidityType={}));let n;r.codec=()=>(n==null&&(n=kr((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),r.ValidityType.codec().encode(o.validityType,i)),o.validity!=null&&(i.uint32(34),i.bytes(o.validity)),o.sequence!=null&&(i.uint32(40),i.uint64(o.sequence)),o.ttl!=null&&(i.uint32(48),i.uint64(o.ttl)),o.pubKey!=null&&(i.uint32(58),i.bytes(o.pubKey)),o.signatureV2!=null&&(i.uint32(66),i.bytes(o.signatureV2)),o.data!=null&&(i.uint32(74),i.bytes(o.data)),s.lengthDelimited!==!1&&i.ldelim()},(o,i,s={})=>{let a={},c=i==null?o.len:o.pos+i;for(;o.pos<c;){let f=o.uint32();switch(f>>>3){case 1:{a.value=o.bytes();break}case 2:{a.signatureV1=o.bytes();break}case 3:{a.validityType=r.ValidityType.codec().decode(o);break}case 4:{a.validity=o.bytes();break}case 5:{a.sequence=o.uint64();break}case 6:{a.ttl=o.uint64();break}case 7:{a.pubKey=o.bytes();break}case 8:{a.signatureV2=o.bytes();break}case 9:{a.data=o.bytes();break}default:{o.skipType(f&7);break}}}return a})),n),r.encode=o=>Ir(o,r.codec()),r.decode=(o,i)=>Sr(o,r.codec(),i)})(nt||(nt={}));var Gp=["string","number","bigint","symbol"],Zp=["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 Sl(r){if(r===null)return"null";if(r===void 0)return"undefined";if(r===!0||r===!1)return"boolean";let e=typeof r;if(Gp.includes(e))return e;if(e==="function")return"Function";if(Array.isArray(r))return"Array";if(Wp(r))return"Buffer";let t=Yp(r);return t||"Object"}function Wp(r){return r&&r.constructor&&r.constructor.isBuffer&&r.constructor.isBuffer.call(null,r)}function Yp(r){let e=Object.prototype.toString.call(r).slice(8,-1);if(Zp.includes(e))return e}var y=class{constructor(e,t,n){this.major=e,this.majorEncoded=e<<5,this.name=t,this.terminal=n}toString(){return`Type[${this.major}].${this.name}`}compare(e){return this.major<e.major?-1:this.major>e.major?1:0}};y.uint=new y(0,"uint",!0);y.negint=new y(1,"negint",!0);y.bytes=new y(2,"bytes",!0);y.string=new y(3,"string",!0);y.array=new y(4,"array",!1);y.map=new y(5,"map",!1);y.tag=new y(6,"tag",!1);y.float=new y(7,"float",!0);y.false=new y(7,"false",!0);y.true=new y(7,"true",!0);y.null=new y(7,"null",!0);y.undefined=new y(7,"undefined",!0);y.break=new y(7,"break",!0);var L=class{constructor(e,t,n){this.type=e,this.value=t,this.encodedLength=n,this.encodedBytes=void 0,this.byteValue=void 0}toString(){return`Token[${this.type}].${this.value}`}};var Or=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&typeof globalThis.Buffer.isBuffer=="function",Jp=new TextDecoder,Xp=new TextEncoder;function ui(r){return Or&&globalThis.Buffer.isBuffer(r)}function Cl(r){return r instanceof Uint8Array?ui(r)?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r:Uint8Array.from(r)}var Nl=Or?(r,e,t)=>t-e>64?globalThis.Buffer.from(r.subarray(e,t)).toString("utf8"):Tl(r,e,t):(r,e,t)=>t-e>64?Jp.decode(r.subarray(e,t)):Tl(r,e,t),Ul=Or?r=>r.length>64?globalThis.Buffer.from(r):Il(r):r=>r.length>64?Xp.encode(r):Il(r);var Mr=Or?(r,e,t)=>ui(r)?new Uint8Array(r.subarray(e,t)):r.slice(e,t):(r,e,t)=>r.slice(e,t),Rl=Or?(r,e)=>(r=r.map(t=>t instanceof Uint8Array?t:globalThis.Buffer.from(t)),Cl(globalThis.Buffer.concat(r,e))):(r,e)=>{let t=new Uint8Array(e),n=0;for(let o of r)n+o.length>t.length&&(o=o.subarray(0,t.length-n)),t.set(o,n),n+=o.length;return t},_l=Or?r=>globalThis.Buffer.allocUnsafe(r):r=>new Uint8Array(r);function Ll(r,e){if(ui(r)&&ui(e))return r.compare(e);for(let t=0;t<r.length;t++)if(r[t]!==e[t])return r[t]<e[t]?-1:1;return 0}function Il(r){let e=[],t=0;for(let n=0;n<r.length;n++){let o=r.charCodeAt(n);o<128?e[t++]=o:o<2048?(e[t++]=o>>6|192,e[t++]=o&63|128):(o&64512)===55296&&n+1<r.length&&(r.charCodeAt(n+1)&64512)===56320?(o=65536+((o&1023)<<10)+(r.charCodeAt(++n)&1023),e[t++]=o>>18|240,e[t++]=o>>12&63|128,e[t++]=o>>6&63|128,e[t++]=o&63|128):(e[t++]=o>>12|224,e[t++]=o>>6&63|128,e[t++]=o&63|128)}return e}function Tl(r,e,t){let n=[];for(;e<t;){let o=r[e],i=null,s=o>239?4:o>223?3:o>191?2:1;if(e+s<=t){let a,c,f,u;switch(s){case 1:o<128&&(i=o);break;case 2:a=r[e+1],(a&192)===128&&(u=(o&31)<<6|a&63,u>127&&(i=u));break;case 3:a=r[e+1],c=r[e+2],(a&192)===128&&(c&192)===128&&(u=(o&15)<<12|(a&63)<<6|c&63,u>2047&&(u<55296||u>57343)&&(i=u));break;case 4:a=r[e+1],c=r[e+2],f=r[e+3],(a&192)===128&&(c&192)===128&&(f&192)===128&&(u=(o&15)<<18|(a&63)<<12|(c&63)<<6|f&63,u>65535&&u<1114112&&(i=u))}}i===null?(i=65533,s=1):i>65535&&(i-=65536,n.push(i>>>10&1023|55296),i=56320|i&1023),n.push(i),e+=s}return Qp(n)}var kl=4096;function Qp(r){let e=r.length;if(e<=kl)return String.fromCharCode.apply(String,r);let t="",n=0;for(;n<e;)t+=String.fromCharCode.apply(String,r.slice(n,n+=kl));return t}var em=256,li=class{constructor(e=em){this.chunkSize=e,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(e){let t=this.chunks[this.chunks.length-1];if(this.cursor+e.length<=this.maxCursor+1){let o=t.length-(this.maxCursor-this.cursor)-1;t.set(e,o)}else{if(t){let o=t.length-(this.maxCursor-this.cursor)-1;o<t.length&&(this.chunks[this.chunks.length-1]=t.subarray(0,o),this.maxCursor=this.cursor-1)}e.length<64&&e.length<this.chunkSize?(t=_l(this.chunkSize),this.chunks.push(t),this.maxCursor+=t.length,this._initReuseChunk===null&&(this._initReuseChunk=t),t.set(e,0)):(this.chunks.push(e),this.maxCursor+=e.length)}this.cursor+=e.length}toBytes(e=!1){let t;if(this.chunks.length===1){let n=this.chunks[0];e&&this.cursor>n.length/2?(t=this.cursor===n.length?n:n.subarray(0,this.cursor),this._initReuseChunk=null,this.chunks=[]):t=Mr(n,0,this.cursor)}else t=Rl(this.chunks,this.cursor);return e&&this.reset(),t}};var $="CBOR decode error:",wa="CBOR encode error:",En=[];En[23]=1;En[24]=2;En[25]=3;En[26]=5;En[27]=9;function Ct(r,e,t){if(r.length-e<t)throw new Error(`${$} not enough data for type`)}var ge=[24,256,65536,4294967296,BigInt("18446744073709551616")];function Me(r,e,t){Ct(r,e,1);let n=r[e];if(t.strict===!0&&n<ge[0])throw new Error(`${$} integer encoded in more bytes than necessary (strict decode)`);return n}function $e(r,e,t){Ct(r,e,2);let n=r[e]<<8|r[e+1];if(t.strict===!0&&n<ge[1])throw new Error(`${$} integer encoded in more bytes than necessary (strict decode)`);return n}function He(r,e,t){Ct(r,e,4);let n=r[e]*16777216+(r[e+1]<<16)+(r[e+2]<<8)+r[e+3];if(t.strict===!0&&n<ge[2])throw new Error(`${$} integer encoded in more bytes than necessary (strict decode)`);return n}function Ke(r,e,t){Ct(r,e,8);let n=r[e]*16777216+(r[e+1]<<16)+(r[e+2]<<8)+r[e+3],o=r[e+4]*16777216+(r[e+5]<<16)+(r[e+6]<<8)+r[e+7],i=(BigInt(n)<<BigInt(32))+BigInt(o);if(t.strict===!0&&i<ge[3])throw new Error(`${$} integer encoded in more bytes than necessary (strict decode)`);if(i<=Number.MAX_SAFE_INTEGER)return Number(i);if(t.allowBigInt===!0)return i;throw new Error(`${$} integers outside of the safe integer range are not supported`)}function Pl(r,e,t,n){return new L(y.uint,Me(r,e+1,n),2)}function Vl(r,e,t,n){return new L(y.uint,$e(r,e+1,n),3)}function Fl(r,e,t,n){return new L(y.uint,He(r,e+1,n),5)}function Dl(r,e,t,n){return new L(y.uint,Ke(r,e+1,n),9)}function ze(r,e){return ve(r,0,e.value)}function ve(r,e,t){if(t<ge[0]){let n=Number(t);r.push([e|n])}else if(t<ge[1]){let n=Number(t);r.push([e|24,n])}else if(t<ge[2]){let n=Number(t);r.push([e|25,n>>>8,n&255])}else if(t<ge[3]){let n=Number(t);r.push([e|26,n>>>24&255,n>>>16&255,n>>>8&255,n&255])}else{let n=BigInt(t);if(n<ge[4]){let o=[e|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,r.push(o)}else throw new Error(`${$} encountered BigInt larger than allowable range`)}}ze.encodedSize=function(e){return ve.encodedSize(e.value)};ve.encodedSize=function(e){return e<ge[0]?1:e<ge[1]?2:e<ge[2]?3:e<ge[3]?5:9};ze.compareTokens=function(e,t){return e.value<t.value?-1:e.value>t.value?1:0};function Ol(r,e,t,n){return new L(y.negint,-1-Me(r,e+1,n),2)}function Ml(r,e,t,n){return new L(y.negint,-1-$e(r,e+1,n),3)}function $l(r,e,t,n){return new L(y.negint,-1-He(r,e+1,n),5)}var xa=BigInt(-1),Hl=BigInt(1);function Kl(r,e,t,n){let o=Ke(r,e+1,n);if(typeof o!="bigint"){let i=-1-o;if(i>=Number.MIN_SAFE_INTEGER)return new L(y.negint,i,9)}if(n.allowBigInt!==!0)throw new Error(`${$} integers outside of the safe integer range are not supported`);return new L(y.negint,xa-BigInt(o),9)}function fi(r,e){let t=e.value,n=typeof t=="bigint"?t*xa-Hl:t*-1-1;ve(r,e.type.majorEncoded,n)}fi.encodedSize=function(e){let t=e.value,n=typeof t=="bigint"?t*xa-Hl:t*-1-1;return n<ge[0]?1:n<ge[1]?2:n<ge[2]?3:n<ge[3]?5:9};fi.compareTokens=function(e,t){return e.value<t.value?1:e.value>t.value?-1:0};function Bn(r,e,t,n){Ct(r,e,t+n);let o=Mr(r,e+t,e+t+n);return new L(y.bytes,o,t+n)}function ql(r,e,t,n){return Bn(r,e,1,t)}function zl(r,e,t,n){return Bn(r,e,2,Me(r,e+1,n))}function jl(r,e,t,n){return Bn(r,e,3,$e(r,e+1,n))}function Gl(r,e,t,n){return Bn(r,e,5,He(r,e+1,n))}function Zl(r,e,t,n){let o=Ke(r,e+1,n);if(typeof o=="bigint")throw new Error(`${$} 64-bit integer bytes lengths not supported`);return Bn(r,e,9,o)}function hi(r){return r.encodedBytes===void 0&&(r.encodedBytes=r.type===y.string?Ul(r.value):r.value),r.encodedBytes}function $r(r,e){let t=hi(e);ve(r,e.type.majorEncoded,t.length),r.push(t)}$r.encodedSize=function(e){let t=hi(e);return ve.encodedSize(t.length)+t.length};$r.compareTokens=function(e,t){return rm(hi(e),hi(t))};function rm(r,e){return r.length<e.length?-1:r.length>e.length?1:Ll(r,e)}function An(r,e,t,n,o){let i=t+n;Ct(r,e,i);let s=new L(y.string,Nl(r,e+t,e+i),i);return o.retainStringBytes===!0&&(s.byteValue=Mr(r,e+t,e+i)),s}function Wl(r,e,t,n){return An(r,e,1,t,n)}function Yl(r,e,t,n){return An(r,e,2,Me(r,e+1,n),n)}function Jl(r,e,t,n){return An(r,e,3,$e(r,e+1,n),n)}function Xl(r,e,t,n){return An(r,e,5,He(r,e+1,n),n)}function Ql(r,e,t,n){let o=Ke(r,e+1,n);if(typeof o=="bigint")throw new Error(`${$} 64-bit integer string lengths not supported`);return An(r,e,9,o,n)}var ef=$r;function Hr(r,e,t,n){return new L(y.array,n,t)}function tf(r,e,t,n){return Hr(r,e,1,t)}function rf(r,e,t,n){return Hr(r,e,2,Me(r,e+1,n))}function nf(r,e,t,n){return Hr(r,e,3,$e(r,e+1,n))}function of(r,e,t,n){return Hr(r,e,5,He(r,e+1,n))}function sf(r,e,t,n){let o=Ke(r,e+1,n);if(typeof o=="bigint")throw new Error(`${$} 64-bit integer array lengths not supported`);return Hr(r,e,9,o)}function af(r,e,t,n){if(n.allowIndefinite===!1)throw new Error(`${$} indefinite length items not allowed`);return Hr(r,e,1,1/0)}function di(r,e){ve(r,y.array.majorEncoded,e.value)}di.compareTokens=ze.compareTokens;di.encodedSize=function(e){return ve.encodedSize(e.value)};function Kr(r,e,t,n){return new L(y.map,n,t)}function cf(r,e,t,n){return Kr(r,e,1,t)}function uf(r,e,t,n){return Kr(r,e,2,Me(r,e+1,n))}function lf(r,e,t,n){return Kr(r,e,3,$e(r,e+1,n))}function ff(r,e,t,n){return Kr(r,e,5,He(r,e+1,n))}function hf(r,e,t,n){let o=Ke(r,e+1,n);if(typeof o=="bigint")throw new Error(`${$} 64-bit integer map lengths not supported`);return Kr(r,e,9,o)}function df(r,e,t,n){if(n.allowIndefinite===!1)throw new Error(`${$} indefinite length items not allowed`);return Kr(r,e,1,1/0)}function pi(r,e){ve(r,y.map.majorEncoded,e.value)}pi.compareTokens=ze.compareTokens;pi.encodedSize=function(e){return ve.encodedSize(e.value)};function pf(r,e,t,n){return new L(y.tag,t,1)}function mf(r,e,t,n){return new L(y.tag,Me(r,e+1,n),2)}function gf(r,e,t,n){return new L(y.tag,$e(r,e+1,n),3)}function yf(r,e,t,n){return new L(y.tag,He(r,e+1,n),5)}function wf(r,e,t,n){return new L(y.tag,Ke(r,e+1,n),9)}function mi(r,e){ve(r,y.tag.majorEncoded,e.value)}mi.compareTokens=ze.compareTokens;mi.encodedSize=function(e){return ve.encodedSize(e.value)};var cm=20,um=21,lm=22,fm=23;function xf(r,e,t,n){if(n.allowUndefined===!1)throw new Error(`${$} undefined values are not supported`);return n.coerceUndefinedToNull===!0?new L(y.null,null,1):new L(y.undefined,void 0,1)}function bf(r,e,t,n){if(n.allowIndefinite===!1)throw new Error(`${$} indefinite length items not allowed`);return new L(y.break,void 0,1)}function ba(r,e,t){if(t){if(t.allowNaN===!1&&Number.isNaN(r))throw new Error(`${$} NaN values are not supported`);if(t.allowInfinity===!1&&(r===1/0||r===-1/0))throw new Error(`${$} Infinity values are not supported`)}return new L(y.float,r,e)}function vf(r,e,t,n){return ba(va(r,e+1),3,n)}function Ef(r,e,t,n){return ba(Ea(r,e+1),5,n)}function Bf(r,e,t,n){return ba(Tf(r,e+1),9,n)}function gi(r,e,t){let n=e.value;if(n===!1)r.push([y.float.majorEncoded|cm]);else if(n===!0)r.push([y.float.majorEncoded|um]);else if(n===null)r.push([y.float.majorEncoded|lm]);else if(n===void 0)r.push([y.float.majorEncoded|fm]);else{let o,i=!1;(!t||t.float64!==!0)&&(Sf(n),o=va(ot,1),n===o||Number.isNaN(n)?(ot[0]=249,r.push(ot.slice(0,3)),i=!0):(If(n),o=Ea(ot,1),n===o&&(ot[0]=250,r.push(ot.slice(0,5)),i=!0))),i||(hm(n),o=Tf(ot,1),ot[0]=251,r.push(ot.slice(0,9)))}}gi.encodedSize=function(e,t){let n=e.value;if(n===!1||n===!0||n===null||n===void 0)return 1;if(!t||t.float64!==!0){Sf(n);let o=va(ot,1);if(n===o||Number.isNaN(n))return 3;if(If(n),o=Ea(ot,1),n===o)return 5}return 9};var Af=new ArrayBuffer(9),je=new DataView(Af,1),ot=new Uint8Array(Af,0);function Sf(r){if(r===1/0)je.setUint16(0,31744,!1);else if(r===-1/0)je.setUint16(0,64512,!1);else if(Number.isNaN(r))je.setUint16(0,32256,!1);else{je.setFloat32(0,r);let e=je.getUint32(0),t=(e&2139095040)>>23,n=e&8388607;if(t===255)je.setUint16(0,31744,!1);else if(t===0)je.setUint16(0,(r&2147483648)>>16|n>>13,!1);else{let o=t-127;o<-24?je.setUint16(0,0):o<-14?je.setUint16(0,(e&2147483648)>>16|1<<24+o,!1):je.setUint16(0,(e&2147483648)>>16|o+15<<10|n>>13,!1)}}}function va(r,e){if(r.length-e<2)throw new Error(`${$} not enough data for float16`);let t=(r[e]<<8)+r[e+1];if(t===31744)return 1/0;if(t===64512)return-1/0;if(t===32256)return NaN;let n=t>>10&31,o=t&1023,i;return n===0?i=o*2**-24:n!==31?i=(o+1024)*2**(n-25):i=o===0?1/0:NaN,t&32768?-i:i}function If(r){je.setFloat32(0,r,!1)}function Ea(r,e){if(r.length-e<4)throw new Error(`${$} not enough data for float32`);let t=(r.byteOffset||0)+e;return new DataView(r.buffer,t,4).getFloat32(0,!1)}function hm(r){je.setFloat64(0,r,!1)}function Tf(r,e){if(r.length-e<8)throw new Error(`${$} not enough data for float64`);let t=(r.byteOffset||0)+e;return new DataView(r.buffer,t,8).getFloat64(0,!1)}gi.compareTokens=ze.compareTokens;function W(r,e,t){throw new Error(`${$} encountered invalid minor (${t}) for major ${r[e]>>>5}`)}function yi(r){return()=>{throw new Error(`${$} ${r}`)}}var T=[];for(let r=0;r<=23;r++)T[r]=W;T[24]=Pl;T[25]=Vl;T[26]=Fl;T[27]=Dl;T[28]=W;T[29]=W;T[30]=W;T[31]=W;for(let r=32;r<=55;r++)T[r]=W;T[56]=Ol;T[57]=Ml;T[58]=$l;T[59]=Kl;T[60]=W;T[61]=W;T[62]=W;T[63]=W;for(let r=64;r<=87;r++)T[r]=ql;T[88]=zl;T[89]=jl;T[90]=Gl;T[91]=Zl;T[92]=W;T[93]=W;T[94]=W;T[95]=yi("indefinite length bytes/strings are not supported");for(let r=96;r<=119;r++)T[r]=Wl;T[120]=Yl;T[121]=Jl;T[122]=Xl;T[123]=Ql;T[124]=W;T[125]=W;T[126]=W;T[127]=yi("indefinite length bytes/strings are not supported");for(let r=128;r<=151;r++)T[r]=tf;T[152]=rf;T[153]=nf;T[154]=of;T[155]=sf;T[156]=W;T[157]=W;T[158]=W;T[159]=af;for(let r=160;r<=183;r++)T[r]=cf;T[184]=uf;T[185]=lf;T[186]=ff;T[187]=hf;T[188]=W;T[189]=W;T[190]=W;T[191]=df;for(let r=192;r<=215;r++)T[r]=pf;T[216]=mf;T[217]=gf;T[218]=yf;T[219]=wf;T[220]=W;T[221]=W;T[222]=W;T[223]=W;for(let r=224;r<=243;r++)T[r]=yi("simple values are not supported");T[244]=W;T[245]=W;T[246]=W;T[247]=xf;T[248]=yi("simple values are not supported");T[249]=vf;T[250]=Ef;T[251]=Bf;T[252]=W;T[253]=W;T[254]=W;T[255]=bf;var it=[];for(let r=0;r<24;r++)it[r]=new L(y.uint,r,1);for(let r=-1;r>=-24;r--)it[31-r]=new L(y.negint,r,1);it[64]=new L(y.bytes,new Uint8Array(0),1);it[96]=new L(y.string,"",1);it[128]=new L(y.array,0,1);it[160]=new L(y.map,0,1);it[244]=new L(y.false,!1,1);it[245]=new L(y.true,!0,1);it[246]=new L(y.null,null,1);function pm(){let r=[];return r[y.uint.major]=ze,r[y.negint.major]=fi,r[y.bytes.major]=$r,r[y.string.major]=ef,r[y.array.major]=di,r[y.map.major]=pi,r[y.tag.major]=mi,r[y.float.major]=gi,r}var ov=pm(),iv=new li,wi=class r{constructor(e,t){this.obj=e,this.parent=t}includes(e){let t=this;do if(t.obj===e)return!0;while(t=t.parent);return!1}static createCheck(e,t){if(e&&e.includes(t))throw new Error(`${wa} object contains circular references`);return new r(t,e)}},jt={null:new L(y.null,null),undefined:new L(y.undefined,void 0),true:new L(y.true,!0),false:new L(y.false,!1),emptyArray:new L(y.array,0),emptyMap:new L(y.map,0)},Gt={number(r,e,t,n){return!Number.isInteger(r)||!Number.isSafeInteger(r)?new L(y.float,r):r>=0?new L(y.uint,r):new L(y.negint,r)},bigint(r,e,t,n){return r>=BigInt(0)?new L(y.uint,r):new L(y.negint,r)},Uint8Array(r,e,t,n){return new L(y.bytes,r)},string(r,e,t,n){return new L(y.string,r)},boolean(r,e,t,n){return r?jt.true:jt.false},null(r,e,t,n){return jt.null},undefined(r,e,t,n){return jt.undefined},ArrayBuffer(r,e,t,n){return new L(y.bytes,new Uint8Array(r))},DataView(r,e,t,n){return new L(y.bytes,new Uint8Array(r.buffer,r.byteOffset,r.byteLength))},Array(r,e,t,n){if(!r.length)return t.addBreakTokens===!0?[jt.emptyArray,new L(y.break)]:jt.emptyArray;n=wi.createCheck(n,r);let o=[],i=0;for(let s of r)o[i++]=Ba(s,t,n);return t.addBreakTokens?[new L(y.array,r.length),o,new L(y.break)]:[new L(y.array,r.length),o]},Object(r,e,t,n){let o=e!=="Object",i=o?r.keys():Object.keys(r),s=o?r.size:i.length;if(!s)return t.addBreakTokens===!0?[jt.emptyMap,new L(y.break)]:jt.emptyMap;n=wi.createCheck(n,r);let a=[],c=0;for(let f of i)a[c++]=[Ba(f,t,n),Ba(o?r.get(f):r[f],t,n)];return mm(a,t),t.addBreakTokens?[new L(y.map,s),a,new L(y.break)]:[new L(y.map,s),a]}};Gt.Map=Gt.Object;Gt.Buffer=Gt.Uint8Array;for(let r of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))Gt[`${r}Array`]=Gt.DataView;function Ba(r,e={},t){let n=Sl(r),o=e&&e.typeEncoders&&e.typeEncoders[n]||Gt[n];if(typeof o=="function"){let s=o(r,n,e,t);if(s!=null)return s}let i=Gt[n];if(!i)throw new Error(`${wa} unsupported type: ${n}`);return i(r,n,e,t)}function mm(r,e){e.mapSorter&&r.sort(e.mapSorter)}var gm={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0},xi=class{constructor(e,t={}){this._pos=0,this.data=e,this.options=t}pos(){return this._pos}done(){return this._pos>=this.data.length}next(){let e=this.data[this._pos],t=it[e];if(t===void 0){let n=T[e];if(!n)throw new Error(`${$} no decoder for major type ${e>>>5} (byte 0x${e.toString(16).padStart(2,"0")})`);let o=e&31;t=n(this.data,this._pos,o,this.options)}return this._pos+=t.encodedLength,t}},Sn=Symbol.for("DONE"),bi=Symbol.for("BREAK");function ym(r,e,t){let n=[];for(let o=0;o<r.value;o++){let i=qr(e,t);if(i===bi){if(r.value===1/0)break;throw new Error(`${$} got unexpected break to lengthed array`)}if(i===Sn)throw new Error(`${$} found array but not enough entries (got ${o}, expected ${r.value})`);n[o]=i}return n}function wm(r,e,t){let n=t.useMaps===!0,o=n?void 0:{},i=n?new Map:void 0;for(let s=0;s<r.value;s++){let a=qr(e,t);if(a===bi){if(r.value===1/0)break;throw new Error(`${$} got unexpected break to lengthed map`)}if(a===Sn)throw new Error(`${$} found map but not enough entries (got ${s} [no key], expected ${r.value})`);if(n!==!0&&typeof a!="string")throw new Error(`${$} non-string keys not supported (got ${typeof a})`);if(t.rejectDuplicateMapKeys===!0&&(n&&i.has(a)||!n&&a in o))throw new Error(`${$} found repeat map key "${a}"`);let c=qr(e,t);if(c===Sn)throw new Error(`${$} found map but not enough entries (got ${s} [no value], expected ${r.value})`);n?i.set(a,c):o[a]=c}return n?i:o}function qr(r,e){if(r.done())return Sn;let t=r.next();if(t.type===y.break)return bi;if(t.type.terminal)return t.value;if(t.type===y.array)return ym(t,r,e);if(t.type===y.map)return wm(t,r,e);if(t.type===y.tag){if(e.tags&&typeof e.tags[t.value]=="function"){let n=qr(r,e);return e.tags[t.value](n)}throw new Error(`${$} tag not supported (${t.value})`)}throw new Error("unsupported")}function kf(r,e){if(!(r instanceof Uint8Array))throw new Error(`${$} data to decode must be a Uint8Array`);e=Object.assign({},gm,e);let t=e.tokenizer||new xi(r,e),n=qr(t,e);if(n===Sn)throw new Error(`${$} did not find any content to decode`);if(n===bi)throw new Error(`${$} got unexpected break`);return[n,r.subarray(t.pos())]}function Aa(r,e){let[t,n]=kf(r,e);if(n.length>0)throw new Error(`${$} too many terminals, data makes no sense`);return t}var vm=Rt("ipns:utils"),Cf=Z("/ipns/");var Em=0,Bm=18;function Nf(r){let e;if(r.pubKey!=null)try{e=ol(r.pubKey)}catch(t){throw vm.error(t),t}if(e!=null)return e}function Uf(r){let e=Z("ipns-signature:");return Oe([e,r])}function cr(r){return"signatureV1"in r?nt.encode({value:Z(r.value),signatureV1:r.signatureV1,validityType:r.validityType,validity:Z(r.validity),sequence:r.sequence,ttl:r.ttl,pubKey:r.pubKey,signatureV2:r.signatureV2,data:r.data}):nt.encode({pubKey:r.pubKey,signatureV2:r.signatureV2,data:r.data})}function ht(r){let e=nt.decode(r);if(e.sequence!=null&&(e.sequence=BigInt(e.sequence)),e.ttl!=null&&(e.ttl=BigInt(e.ttl)),e.signatureV2==null||e.data==null)throw new rt("Missing data or signatureV2");let t=Rf(e.data),n=Am(t.Value),o=ne(t.Validity);if(e.value!=null&&e.signatureV1!=null)return Sm(e),{value:n,validityType:nt.ValidityType.EOL,validity:o,sequence:t.Sequence,ttl:t.TTL,pubKey:e.pubKey,signatureV1:e.signatureV1,signatureV2:e.signatureV2,data:e.data};if(e.signatureV2!=null)return{value:n,validityType:nt.ValidityType.EOL,validity:o,sequence:t.Sequence,ttl:t.TTL,pubKey:e.pubKey,signatureV2:e.signatureV2,data:e.data};throw new Error("invalid record: does not include signatureV1 or signatureV2")}function In(r){return Oe([Cf,r.bytes])}function Nt(r){let e=gt(r.slice(Cf.length));if(!vi(e,Em)&&!vi(e,Bm))throw new fr("Multihash in IPNS key was not identity or sha2-256");return e}function Rf(r){let e=Aa(r);if(e.ValidityType===0)e.ValidityType=nt.ValidityType.EOL;else throw new Dr("The validity type is unsupported");return Number.isInteger(e.Sequence)&&(e.Sequence=BigInt(e.Sequence)),Number.isInteger(e.TTL)&&(e.TTL=BigInt(e.TTL)),e}function Am(r){let e=ne(r).trim();if(e.startsWith("/"))return e;try{return`/ipfs/${X.decode(r).toV1().toString()}`}catch{}try{return`/ipfs/${X.parse(e).toV1().toString()}`}catch{}throw new ai("Value must be a valid content path starting with /")}function Sm(r){if(r.data==null)throw new ci("Record data is missing");let e=Rf(r.data);if(!ce(e.Value,r.value??new Uint8Array(0)))throw new rt('Field "value" did not match between protobuf and CBOR');if(!ce(e.Validity,r.validity??new Uint8Array(0)))throw new rt('Field "validity" did not match between protobuf and CBOR');if(e.ValidityType!==r.validityType)throw new rt('Field "validityType" did not match between protobuf and CBOR');if(e.Sequence!==r.sequence)throw new rt('Field "sequence" did not match between protobuf and CBOR');if(e.TTL!==r.ttl)throw new rt('Field "ttl" did not match between protobuf and CBOR')}function vi(r,e){return r.code===e}var Cv=Rt("ipns"),Nv=60*60*1e9,Tm="/ipns/",Uv=Tm.length;var _f=_n(ya(),1);var Ei=Rt("ipns:validator"),km=1024*10,Cm=async(r,e)=>{let t=ht(e),n;try{let o=Uf(t.data);n=await r.verify(o,t.signatureV2)}catch{n=!1}if(!n)throw Ei.error("record signature verification failed"),new rt("Record signature verification failed");if(t.validityType===nt.ValidityType.EOL){if(_f.default.fromString(t.validity).toDate().getTime()<Date.now())throw Ei.error("record has expired"),new ii("record has expired")}else if(t.validityType!=null)throw Ei.error("the validity type is unsupported"),new Dr("The validity type is unsupported");Ei("ipns record for %s is valid",t.value)};async function Lf(r,e){if(e.byteLength>km)throw new si("The record is too large");let t=Nt(r),n;vi(t,0)&&(n=Yo(t));let o=ht(e),i=Nf(o)??n;if(i==null)throw new vn("Could not extract public key from IPNS record or routing key");let s=In(i.toMultihash());if(!ce(r,s))throw new vn("Embedded public key did not match routing key");await Cm(i,e)}async function*Tn(r){let e=/\r?\n/,t=new TextDecoder("utf8"),n="";for await(let o of r){typeof o=="string"&&(o=new TextEncoder().encode(o)),n+=t.decode(o,{stream:!0});let i=n.split(e);n=i.pop()??"";for(let s=0;s<i.length;s++)yield JSON.parse(i[s])}n+=t.decode(),n!==""&&(yield JSON.parse(n))}function dt(){let r={};return r.promise=new Promise((e,t)=>{r.resolve=e,r.reject=t}),r}var Ia=_n(Vf(),1);var Cn=class extends Error{constructor(e){super(e),this.name="TimeoutError"}},Ta=class extends Error{constructor(e){super(),this.name="AbortError",this.message=e}},Ff=r=>globalThis.DOMException===void 0?new Ta(r):new DOMException(r),Df=r=>{let e=r.reason===void 0?Ff("This operation was aborted."):r.reason;return e instanceof Error?e:Ff(e)};function ka(r,e){let{milliseconds:t,fallback:n,message:o,customTimers:i={setTimeout,clearTimeout}}=e,s,c=new Promise((f,u)=>{if(typeof t!="number"||Math.sign(t)!==1)throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${t}\``);if(e.signal){let{signal:h}=e;h.aborted&&u(Df(h));let b=()=>{u(Df(h))};h.addEventListener("abort",b,{once:!0}),r.finally(()=>{h.removeEventListener("abort",b)})}if(t===Number.POSITIVE_INFINITY){r.then(f,u);return}let l=new Cn;s=i.setTimeout.call(void 0,()=>{if(n){try{f(n())}catch(h){u(h)}return}typeof r.cancel=="function"&&r.cancel(),o===!1?f():o instanceof Error?u(o):(l.message=o??`Promise timed out after ${t} milliseconds`,u(l))},t),(async()=>{try{f(await r)}catch(h){u(h)}})()}).finally(()=>{c.clear()});return c.clear=()=>{i.clearTimeout.call(void 0,s),s=void 0},c}function Ca(r,e,t){let n=0,o=r.length;for(;o>0;){let i=Math.trunc(o/2),s=n+i;t(r[s],e)<=0?(n=++s,o-=i+1):o=i}return n}var Nn=class{#e=[];enqueue(e,t){t={priority:0,...t};let n={priority:t.priority,run:e};if(this.size&&this.#e[this.size-1].priority>=t.priority){this.#e.push(n);return}let o=Ca(this.#e,n,(i,s)=>s.priority-i.priority);this.#e.splice(o,0,n)}dequeue(){return this.#e.shift()?.run}filter(e){return this.#e.filter(t=>t.priority===e.priority).map(t=>t.run)}get size(){return this.#e.length}};var Un=class extends Ia.default{#e;#r;#t=0;#a;#c;#p=0;#o;#u;#n;#m;#i=0;#l;#s;#g;timeout;constructor(e){if(super(),e={carryoverConcurrencyCount:!1,intervalCap:Number.POSITIVE_INFINITY,interval:0,concurrency:Number.POSITIVE_INFINITY,autoStart:!0,queueClass:Nn,...e},!(typeof e.intervalCap=="number"&&e.intervalCap>=1))throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${e.intervalCap?.toString()??""}\` (${typeof e.intervalCap})`);if(e.interval===void 0||!(Number.isFinite(e.interval)&&e.interval>=0))throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${e.interval?.toString()??""}\` (${typeof e.interval})`);this.#e=e.carryoverConcurrencyCount,this.#r=e.intervalCap===Number.POSITIVE_INFINITY||e.interval===0,this.#a=e.intervalCap,this.#c=e.interval,this.#n=new e.queueClass,this.#m=e.queueClass,this.concurrency=e.concurrency,this.timeout=e.timeout,this.#g=e.throwOnTimeout===!0,this.#s=e.autoStart===!1}get#x(){return this.#r||this.#t<this.#a}get#b(){return this.#i<this.#l}#v(){this.#i--,this.#f(),this.emit("next")}#E(){this.#w(),this.#y(),this.#u=void 0}get#B(){let e=Date.now();if(this.#o===void 0){let t=this.#p-e;if(t<0)this.#t=this.#e?this.#i:0;else return this.#u===void 0&&(this.#u=setTimeout(()=>{this.#E()},t)),!0}return!1}#f(){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 e=!this.#B;if(this.#x&&this.#b){let t=this.#n.dequeue();return t?(this.emit("active"),t(),e&&this.#y(),!0):!1}}return!1}#y(){this.#r||this.#o!==void 0||(this.#o=setInterval(()=>{this.#w()},this.#c),this.#p=Date.now()+this.#c)}#w(){this.#t===0&&this.#i===0&&this.#o&&(clearInterval(this.#o),this.#o=void 0),this.#t=this.#e?this.#i:0,this.#h()}#h(){for(;this.#f(););}get concurrency(){return this.#l}set concurrency(e){if(!(typeof e=="number"&&e>=1))throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${e}\` (${typeof e})`);this.#l=e,this.#h()}async#A(e){return new Promise((t,n)=>{e.addEventListener("abort",()=>{n(e.reason)},{once:!0})})}async add(e,t={}){return t={timeout:this.timeout,throwOnTimeout:this.#g,...t},new Promise((n,o)=>{this.#n.enqueue(async()=>{this.#i++,this.#t++;try{t.signal?.throwIfAborted();let i=e({signal:t.signal});t.timeout&&(i=ka(Promise.resolve(i),{milliseconds:t.timeout})),t.signal&&(i=Promise.race([i,this.#A(t.signal)]));let s=await i;n(s),this.emit("completed",s)}catch(i){if(i instanceof Cn&&!t.throwOnTimeout){n();return}o(i),this.emit("error",i)}finally{this.#v()}},t),this.emit("add"),this.#f()})}async addAll(e,t){return Promise.all(e.map(async n=>this.add(n,t)))}start(){return this.#s?(this.#s=!1,this.#h(),this):this}pause(){this.#s=!0}clear(){this.#n=new this.#m}async onEmpty(){this.#n.size!==0&&await this.#d("empty")}async onSizeLessThan(e){this.#n.size<e||await this.#d("next",()=>this.#n.size<e)}async onIdle(){this.#i===0&&this.#n.size===0||await this.#d("idle")}async#d(e,t){return new Promise(n=>{let o=()=>{t&&!t()||(this.off(e,o),n())};this.on(e,o)})}get size(){return this.#n.size}sizeBy(e){return this.#n.filter(e).length}get pending(){return this.#i}get isPaused(){return this.#s}};var zr=class extends Error{static name="InvalidRequestError";constructor(e="Invalid request"){super(e),this.name="InvalidRequestError"}},ur=class extends Error{static name="BadResponseError";constructor(e="Bad response"){super(e),this.name="BadResponseError"}};function Rm(r){return r[Symbol.asyncIterator]!=null}function _m(r){if(Rm(r))return(async()=>{for await(let e of r)return e})();for(let e of r)return e}var Ai=_m;function Lm(r){let[e,t]=r[Symbol.asyncIterator]!=null?[r[Symbol.asyncIterator](),Symbol.asyncIterator]:[r[Symbol.iterator](),Symbol.iterator],n=[];return{peek:()=>e.next(),push:o=>{n.push(o)},next:()=>n.length>0?{done:!1,value:n.shift()}:e.next(),[t](){return this}}}var Of=Lm;function Pm(r){return r[Symbol.asyncIterator]!=null}function Vm(r,e){let t=0;if(Pm(r))return async function*(){for await(let c of r)yield e(c,t++)}();let n=Of(r),{value:o,done:i}=n.next();if(i===!0)return function*(){}();let s=e(o,t++);if(typeof s.then=="function")return async function*(){yield await s;for await(let c of n)yield e(c,t++)}();let a=e;return function*(){yield s;for(let c of n)yield a(c,t++)}()}var Si=Vm;var Mf=Z("/ipns/");function $f(r){return ce(r.subarray(0,Mf.byteLength),Mf)}var Ii=class{client;constructor(e){this.client=e}async*findProviders(e,t={}){yield*Si(this.client.getProviders(e,t),n=>({id:n.ID,multiaddrs:n.Addrs??[]}))}async provide(){}async cancelReprovide(){}async put(e,t,n){if(!$f(e))return;let o=Nt(e),i=X.createV1(114,o),s=ht(t);await this.client.putIPNS(i,s,n)}async get(e,t){if(!$f(e))throw new Re("Not found");let n=Nt(e),o=X.createV1(114,n);try{let i=await this.client.getIPNS(o,t);return cr(i)}catch(i){throw i.name==="BadResponseError"?new Re("Not found"):i}}},Ti=class{client;constructor(e){this.client=e}async findPeer(e,t={}){let n=await Ai(this.client.getPeers(e,t));if(n!=null)return{id:n.ID,multiaddrs:n.Addrs??[]};throw new Re("Not found")}async*getClosestPeers(e,t={}){}};var ye=Rt("delegated-routing-v1-http-api-client"),ki={concurrentRequests:4,timeout:3e4,cacheTTL:5*60*1e3,cacheName:"delegated-routing-v1-cache"},Ci=class{started;httpQueue;shutDownController;clientUrl;timeout;contentRouting;peerRouting;filterAddrs;filterProtocols;inFlightRequests;cacheName;cache;cacheTTL;constructor(e,t={}){this.started=!1,this.shutDownController=new AbortController,dr(1/0,this.shutDownController.signal),this.httpQueue=new Un({concurrency:t.concurrentRequests??ki.concurrentRequests}),this.inFlightRequests=new Map,this.clientUrl=e instanceof URL?e:new URL(e),this.timeout=t.timeout??ki.timeout,this.filterAddrs=t.filterAddrs,this.filterProtocols=t.filterProtocols,this.contentRouting=new Ii(this),this.peerRouting=new Ti(this),this.cacheName=t.cacheName??ki.cacheName,this.cacheTTL=t.cacheTTL??ki.cacheTTL}get[Za](){return this.contentRouting}get[Wa](){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&&ye("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(e,t={}){ye("getProviders starts: %c",e);let n=AbortSignal.timeout(this.timeout),o=bn([this.shutDownController.signal,n,t.signal]);dr(1/0,n,o);let i=dt(),s=dt();this.httpQueue.add(async()=>(i.resolve(),s.promise));try{await i.promise;let a=new URL(`${this.clientUrl}routing/v1/providers/${e.toString()}`);this.#r(a,t.filterAddrs,t.filterProtocols);let c={headers:{Accept:"application/x-ndjson"},signal:o},f=await this.#t(a.toString(),c);if(f.status===404)throw new Re("No matching records found");if(f.status===422)throw new zr("Request does not conform to schema or semantic constraints");if(f.body==null)throw new ur("Routing response had no body");if(f.headers.get("Content-Type")==="application/json"){let l=await f.json();for(let h of l.Providers){let b=this.#e(h);b!=null&&(yield b)}}else for await(let l of Tn(oi(f.body))){let h=this.#e(l);h!=null&&(yield h)}}catch(a){ye.error("getProviders errored:",a)}finally{o.clear(),s.resolve(),ye("getProviders finished: %c",e)}}async*getPeers(e,t={}){ye("getPeers starts: %c",e);let n=AbortSignal.timeout(this.timeout),o=bn([this.shutDownController.signal,n,t.signal]);dr(1/0,n,o);let i=dt(),s=dt();this.httpQueue.add(async()=>(i.resolve(),s.promise));try{await i.promise;let a=new URL(`${this.clientUrl}routing/v1/peers/${e.toCID().toString()}`);this.#r(a,t.filterAddrs,t.filterProtocols);let c={headers:{Accept:"application/x-ndjson"},signal:o},f=await this.#t(a.toString(),c);if(f.status===404)throw new Re("No matching records found");if(f.status===422)throw new zr("Request does not conform to schema or semantic constraints");if(f.body==null)throw new ur("Routing response had no body");if(f.headers.get("Content-Type")==="application/json"){let l=await f.json();for(let h of l.Peers){let b=this.#e(h);b!=null&&(yield b)}}else for await(let l of Tn(oi(f.body))){let h=this.#e(l);h!=null&&(yield h)}}catch(a){ye.error("getPeers errored:",a)}finally{o.clear(),s.resolve(),ye("getPeers finished: %c",e)}}async getIPNS(e,t={}){ye("getIPNS starts: %s",e);let n=AbortSignal.timeout(this.timeout),o=bn([this.shutDownController.signal,n,t.signal]);dr(1/0,n,o);let i=dt(),s=dt();this.httpQueue.add(async()=>(i.resolve(),s.promise));let a=`${this.clientUrl}routing/v1/ipns/${e}`;try{await i.promise;let c={headers:{Accept:"application/vnd.ipfs.ipns-record"},signal:o},f=await this.#t(a,c);if(ye("getIPNS GET %s %d",a,f.status),f.status===404)throw new Re("No matching records found");if(f.status===422)throw new zr("Request does not conform to schema or semantic constraints");if(f.body==null)throw new ur("GET ipns response had no body");let u=await f.arrayBuffer(),l=new Uint8Array(u,0,u.byteLength);return t.validate!==!1&&await Lf(In(e.multihash),l),ht(l)}catch(c){throw ye.error("getIPNS GET %s error:",a,c),c}finally{o.clear(),s.resolve(),ye("getIPNS finished: %s",e)}}async putIPNS(e,t,n={}){ye("putIPNS starts: %c",e);let o=AbortSignal.timeout(this.timeout),i=bn([this.shutDownController.signal,o,n.signal]);dr(1/0,o,i);let s=dt(),a=dt();this.httpQueue.add(async()=>(s.resolve(),a.promise));let c=`${this.clientUrl}routing/v1/ipns/${e}`;try{await s.promise;let f=cr(t),u={method:"PUT",headers:{"Content-Type":"application/vnd.ipfs.ipns-record"},body:f,signal:i},l=await this.#t(c,u);if(ye("putIPNS PUT %s %d",c,l.status),l.status!==200)throw new ur("PUT ipns response had status other than 200")}catch(f){throw ye.error("putIPNS PUT %s error:",c,f.stack),f}finally{i.clear(),a.resolve(),ye("putIPNS finished: %c",e)}}#e(e){try{let t=[],n=e.Addrs?.map(sr)??[];return e.Protocols!=null&&t.push(...e.Protocols),e.Protocol!=null&&(t.push(e.Protocol),delete e.Protocol),{...e,Schema:"peer",ID:al(e.ID),Addrs:n,Protocols:t}}catch(t){ye.error("could not conform record to peer schema",t)}}#r(e,t,n){if(t!=null||this.filterAddrs!=null){let o=t?.join(",")??this.filterAddrs?.join(",")??"";o!==""&&e.searchParams.set("filter-addrs",o)}if(n!=null||this.filterProtocols!=null){let o=n?.join(",")??this.filterProtocols?.join(",")??"";o!==""&&e.searchParams.set("filter-protocols",o)}}async#t(e,t){let n=t.method??"GET",o=`${n}-${e}`;if(n==="GET"){let c=await this.cache?.match(e);if(c!=null){if(parseInt(c.headers.get("x-cache-expires")??"0",10)>Date.now())return ye("returning cached response for %s",o),c;await this.cache?.delete(e)}}let i=this.inFlightRequests.get(o);if(i!=null){let c=await i;return ye("deduplicating outgoing request for %s",o),c.clone()}let s=fetch(e,t).then(async c=>{if(this.cache!=null&&c.ok&&n==="GET"){let f=Date.now()+this.cacheTTL,u=new Headers(c.headers);u.set("x-cache-expires",f.toString());let l=new Response(c.clone().body,{status:c.status,statusText:c.statusText,headers:u});await this.cache.put(e,l)}return c}).finally(()=>{this.inFlightRequests.delete(o)});return this.inFlightRequests.set(o,s),await s}};function Hf(r,e={}){return new Ci(new URL(r),e)}function Ni(){return{filterProtocols:["unknown","transport-bitswap","transport-ipfs-gateway-http"],filterAddrs:["https","webtransport","webrtc","webrtc-direct","wss","tls"]}}var Kf=Z("/ipns/");function qf(r){return ce(r.subarray(0,Kf.byteLength),Kf)}var Na=class{client;constructor(e,t={}){this.client=Hf(e,t)}async provide(e,t){}async cancelReprovide(e,t){}async*findProviders(e,t){yield*Si(this.client.getProviders(e,t),n=>({id:n.ID,multiaddrs:n.Addrs,protocols:n.Protocols}))}async put(e,t,n){if(!qf(e))return;let o=Nt(e),i=X.createV1(114,o),s=ht(t);await this.client.putIPNS(i,s,n)}async get(e,t){if(!qf(e))throw new Re("Not found");let n=Nt(e),o=X.createV1(114,n);try{let i=await this.client.getIPNS(o,t);return cr(i)}catch(i){throw i.name==="BadResponseError"?new Re("Not found"):i}}async findPeer(e,t){let n=await Ai(this.client.getPeers(e,t));if(n!=null)return{id:n.ID,multiaddrs:n.Addrs??[]};throw new Re("Not found")}async*getClosestPeers(e,t){}};function zf(r,e){let t=e??Ni();return new Na(new URL(r),t)}var jf="[a-fA-F\\d:]",Zt=r=>r&&r.includeBoundaries?`(?:(?<=\\s|^)(?=${jf})|(?<=${jf})(?=\\s|$))`:"",st="(?: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}",ue="[a-fA-F\\d]{1,4}",Ui=`
|
|
2
|
+
"use strict";var HeliaRouters=(()=>{var pf=Object.create;var en=Object.defineProperty;var mf=Object.getOwnPropertyDescriptor;var gf=Object.getOwnPropertyNames;var yf=Object.getPrototypeOf,xf=Object.prototype.hasOwnProperty;var Rs=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),At=(e,t)=>{for(var r in t)en(e,r,{get:t[r],enumerable:!0})},_s=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of gf(t))!xf.call(e,o)&&o!==r&&en(e,o,{get:()=>t[o],enumerable:!(n=mf(t,o))||n.enumerable});return e};var wo=(e,t,r)=>(r=e!=null?pf(yf(e)):{},_s(t||!e||!e.__esModule?en(r,"default",{value:e,enumerable:!0}):r,e)),wf=e=>_s(en({},"__esModule",{value:!0}),e);var rs=Rs((pb,es)=>{var hb=function(){typeof es<"u"&&(es.exports=y);var e=86400,t=3200,r=146097*t/400,n=e*r,o=1e3*n,i=864e13,s=4294967296,a=1e6,c="000000000",l=Math.trunc||function(w){var E=w-w%1;return E==0&&(w<0||w===0&&1/w!=1/0)?-0:E},u=y.prototype,f=(y.fromDate=function(w){return new y(+w)},y.fromInt64BE=P(0,1,2,3,0,4),y.fromInt64LE=P(3,2,1,0,4,0),y.fromString=function(_){var E,F=new y,_=(_+="").replace(/^\s*[+\-]?\d+/,function(K){var K=+K,A=1970+(K-1970)%400;return F.year=K-A,A}).replace(/(?:Z|([+\-]\d{2}):?(\d{2}))$/,function(U,K,A){return K<0&&(A*=-1),E=6e4*(60*+K+ +A),""}).replace(/\.\d+$/,function(U){return F.nano=+(U+c).substr(1,9),""}).split(/\D+/);if(1<_.length?_[1]--:_[1]=0,F.time=E=Date.UTC.apply(Date,_)-(E||0),isNaN(E))throw new TypeError("Invalid Date");return h(F)},y.fromTimeT=function(w){return C(w,0)},u.year=0,u.time=0,u.nano=0,u.addNano=function(w){return this.nano+=+w||0,this},u.getNano=function(){var w=h(this);return(w.time%1e3*a+ +w.nano+1e9)%1e9},u.getTimeT=function(){var E=h(this),w=Math.floor(E.time/1e3),E=E.year;return E&&(w+=E*r*e/t),w},u.getYear=function(){return this.toDate().getUTCFullYear()+this.year},u.toDate=function(){return v(h(this).time)},u.toJSON=function(){return this.toString().replace(/0{1,6}Z$/,"Z")},u.toString=function(w){var E=this,F=E.toDate(),_={H:function(){return k(F.getUTCHours())},L:function(){return R(F.getUTCMilliseconds(),3)},M:function(){return k(F.getUTCMinutes())},N:function(){return R(E.getNano(),9)},S:function(){return k(F.getUTCSeconds())},Y:function(){var U=E.getYear();return 999999<U?"+"+U:9999<U?"+"+R(U,6):0<=U?R(U,4):-999999<=U?"-"+R(-U,6):U},a:function(){return b[F.getUTCDay()]},b:function(){return d[F.getUTCMonth()]},d:function(){return k(F.getUTCDate())},e:function(){return function(U){return(9<U?"":" ")+(0|U)}(F.getUTCDate())},m:function(){return k(F.getUTCMonth()+1)}};return function U(K){return K.replace(/%./g,function(A){var m=A[1],I=T[m],m=_[m];return I?U(I):m?m():A})}(w||f)},u.writeInt64BE=x(0,1,2,3,0,4),u.writeInt64LE=x(3,2,1,0,4,0),"%Y-%m-%dT%H:%M:%S.%NZ"),d=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],b=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],T={"%":"%",F:"%Y-%m-%d",n:`
|
|
3
|
+
`,R:"%H:%M",T:"%H:%M:%S",t:" ",X:"%T",Z:"GMT",z:"+0000"};return y;function y(w,E,F){var _=this;if(!(_ instanceof y))return new y(w,E,F);_.time=+w||0,_.nano=+E||0,_.year=+F||0,h(_)}function h(w){var E,F,_,U=w.year,K=w.time,A=w.nano,I=((A<0||a<=A)&&(A-=(F=Math.floor(A/a))*a,K+=F,F=1),U%t);return(K<-i||i<K||I)&&((E=l(K/o))&&(U+=E*t,K-=E*o),(_=v(K)).setUTCFullYear(I+_.getUTCFullYear()),_=(K=+_)+(E=l((U-=I)/t))*o,E&&-i<=_&&_<=i&&(U-=E*t,K=_),F=1),F&&(w.year=U,w.time=K,w.nano=A),w}function v(w){var E=new Date(0);return E.setTime(w),E}function C(U,_){U=+U||0;var F=l((_=(_|0)*s)/n)+l(U/n),_=_%n+U%n,U=l(_/n);return U&&(F+=U,_-=U*n),new y(1e3*_,0,F*t)}function x(w,E,F,_,U,K){return function(I,m){var S=h(this);I=I||new Array(8),D(I,m|=0);var N=Math.floor(S.time/1e3),S=S.year*(r*e/t),p=l(S/s)+l(N/s),S=S%s+N%s,N=Math.floor(S/s);return N&&(p+=N,S-=N*s),A(I,m+U,p),A(I,m+K,S),I};function A(I,m,p){I[m+w]=p>>24&255,I[m+E]=p>>16&255,I[m+F]=p>>8&255,I[m+_]=255&p}}function P(w,E,F,_,U,K){return function(I,m){D(I,m|=0);var p=A(I,m+U);return C(A(I,m+K),p)};function A(I,m){return 16777216*I[m+w]+(I[m+E]<<16|I[m+F]<<8|I[m+_])}}function D(w,E){if(w=w&&w.length,w==null)throw new TypeError("Invalid Buffer");if(w<E+8)throw new RangeError("Out of range")}function k(w){return(9<w?"":"0")+(0|w)}function R(w,E){return(c+(0|w)).substr(-E)}}()});var Vu=Rs((i2,fs)=>{"use strict";var Pp=Object.prototype.hasOwnProperty,It="~";function Xr(){}Object.create&&(Xr.prototype=Object.create(null),new Xr().__proto__||(It=!1));function Rp(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function Mu(e,t,r,n,o){if(typeof r!="function")throw new TypeError("The listener must be a function");var i=new Rp(r,n||e,o),s=It?It+t:t;return e._events[s]?e._events[s].fn?e._events[s]=[e._events[s],i]:e._events[s].push(i):(e._events[s]=i,e._eventsCount++),e}function co(e,t){--e._eventsCount===0?e._events=new Xr:delete e._events[t]}function St(){this._events=new Xr,this._eventsCount=0}St.prototype.eventNames=function(){var t=[],r,n;if(this._eventsCount===0)return t;for(n in r=this._events)Pp.call(r,n)&&t.push(It?n.slice(1):n);return Object.getOwnPropertySymbols?t.concat(Object.getOwnPropertySymbols(r)):t};St.prototype.listeners=function(t){var r=It?It+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};St.prototype.listenerCount=function(t){var r=It?It+t:t,n=this._events[r];return n?n.fn?1:n.length:0};St.prototype.emit=function(t,r,n,o,i,s){var a=It?It+t:t;if(!this._events[a])return!1;var c=this._events[a],l=arguments.length,u,f;if(c.fn){switch(c.once&&this.removeListener(t,c.fn,void 0,!0),l){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,r),!0;case 3:return c.fn.call(c.context,r,n),!0;case 4:return c.fn.call(c.context,r,n,o),!0;case 5:return c.fn.call(c.context,r,n,o,i),!0;case 6:return c.fn.call(c.context,r,n,o,i,s),!0}for(f=1,u=new Array(l-1);f<l;f++)u[f-1]=arguments[f];c.fn.apply(c.context,u)}else{var d=c.length,b;for(f=0;f<d;f++)switch(c[f].once&&this.removeListener(t,c[f].fn,void 0,!0),l){case 1:c[f].fn.call(c[f].context);break;case 2:c[f].fn.call(c[f].context,r);break;case 3:c[f].fn.call(c[f].context,r,n);break;case 4:c[f].fn.call(c[f].context,r,n,o);break;default:if(!u)for(b=1,u=new Array(l-1);b<l;b++)u[b-1]=arguments[b];c[f].fn.apply(c[f].context,u)}}return!0};St.prototype.on=function(t,r,n){return Mu(this,t,r,n,!1)};St.prototype.once=function(t,r,n){return Mu(this,t,r,n,!0)};St.prototype.removeListener=function(t,r,n,o){var i=It?It+t:t;if(!this._events[i])return this;if(!r)return co(this,i),this;var s=this._events[i];if(s.fn)s.fn===r&&(!o||s.once)&&(!n||s.context===n)&&co(this,i);else{for(var a=0,c=[],l=s.length;a<l;a++)(s[a].fn!==r||o&&!s[a].once||n&&s[a].context!==n)&&c.push(s[a]);c.length?this._events[i]=c.length===1?c[0]:c:co(this,i)}return this};St.prototype.removeAllListeners=function(t){var r;return t?(r=It?It+t:t,this._events[r]&&co(this,r)):(this._events=new Xr,this._eventsCount=0),this};St.prototype.off=St.prototype.removeListener;St.prototype.addListener=St.prototype.on;St.prefixed=It;St.EventEmitter=St;typeof fs<"u"&&(fs.exports=St)});var Qp={};At(Qp,{delegatedHTTPRouting:()=>Yu,delegatedHTTPRoutingDefaults:()=>go,httpGatewayRouting:()=>nf,libp2pRouting:()=>of});var Ls=Symbol.for("@libp2p/content-routing");var bo=Symbol.for("@libp2p/peer-id");var ks=Symbol.for("@libp2p/peer-routing");var xt=class extends Error{static name="InvalidParametersError";constructor(t="Invalid parameters"){super(t),this.name="InvalidParametersError"}},Ze=class extends Error{static name="InvalidPublicKeyError";constructor(t="Invalid public key"){super(t),this.name="InvalidPublicKeyError"}};var Bt=class extends Error{static name="NotFoundError";constructor(t="Not found"){super(t),this.name="NotFoundError"}};var rn=class extends Error{static name="InvalidCIDError";constructor(t="Invalid CID"){super(t),this.name="InvalidCIDError"}},je=class extends Error{static name="InvalidMultihashError";constructor(t="Invalid Multihash"){super(t),this.name="InvalidMultihashError"}};var Ye=class extends Error{static name="UnsupportedKeyTypeError";constructor(t="Unsupported key type"){super(t),this.name="UnsupportedKeyTypeError"}};var Io={};At(Io,{base32:()=>Kt,base32hex:()=>Cf,base32hexpad:()=>Nf,base32hexpadupper:()=>Pf,base32hexupper:()=>Uf,base32pad:()=>Tf,base32padupper:()=>Bf,base32upper:()=>If,base32z:()=>Rf});var i0=new Uint8Array(0);function Ds(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 ae(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 Fs(e){return new TextEncoder().encode(e)}function Os(e){return new TextDecoder().decode(e)}function bf(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var o=0;o<e.length;o++){var i=e.charAt(o),s=i.charCodeAt(0);if(r[s]!==255)throw new TypeError(i+" is ambiguous");r[s]=o}var a=e.length,c=e.charAt(0),l=Math.log(a)/Math.log(256),u=Math.log(256)/Math.log(a);function f(T){if(T instanceof Uint8Array||(ArrayBuffer.isView(T)?T=new Uint8Array(T.buffer,T.byteOffset,T.byteLength):Array.isArray(T)&&(T=Uint8Array.from(T))),!(T instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(T.length===0)return"";for(var y=0,h=0,v=0,C=T.length;v!==C&&T[v]===0;)v++,y++;for(var x=(C-v)*u+1>>>0,P=new Uint8Array(x);v!==C;){for(var D=T[v],k=0,R=x-1;(D!==0||k<h)&&R!==-1;R--,k++)D+=256*P[R]>>>0,P[R]=D%a>>>0,D=D/a>>>0;if(D!==0)throw new Error("Non-zero carry");h=k,v++}for(var w=x-h;w!==x&&P[w]===0;)w++;for(var E=c.repeat(y);w<x;++w)E+=e.charAt(P[w]);return E}function d(T){if(typeof T!="string")throw new TypeError("Expected String");if(T.length===0)return new Uint8Array;var y=0;if(T[y]!==" "){for(var h=0,v=0;T[y]===c;)h++,y++;for(var C=(T.length-y)*l+1>>>0,x=new Uint8Array(C);T[y];){var P=r[T.charCodeAt(y)];if(P===255)return;for(var D=0,k=C-1;(P!==0||D<v)&&k!==-1;k--,D++)P+=a*x[k]>>>0,x[k]=P%256>>>0,P=P/256>>>0;if(P!==0)throw new Error("Non-zero carry");v=D,y++}if(T[y]!==" "){for(var R=C-v;R!==C&&x[R]===0;)R++;for(var w=new Uint8Array(h+(C-R)),E=h;R!==C;)w[E++]=x[R++];return w}}}function b(T){var y=d(T);if(y)return y;throw new Error(`Non-${t} character`)}return{encode:f,decodeUnsafe:d,decode:b}}var Ef=bf,Sf=Ef,Vs=Sf;var Eo=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")}},So=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 Ks(this,t)}},vo=class{decoders;constructor(t){this.decoders=t}or(t){return Ks(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 Ks(e,t){return new vo({...e.decoders??{[e.prefix]:e},...t.decoders??{[t.prefix]:t}})}var Ao=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 Eo(t,r,n),this.decoder=new So(t,r,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function We({name:e,prefix:t,encode:r,decode:n}){return new Ao(e,t,r,n)}function xe({name:e,prefix:t,alphabet:r}){let{encode:n,decode:o}=Vs(r,e);return We({prefix:t,name:e,encode:n,decode:i=>ae(o(i))})}function vf(e,t,r,n){let o={};for(let u=0;u<t.length;++u)o[t[u]]=u;let i=e.length;for(;e[i-1]==="=";)--i;let s=new Uint8Array(i*r/8|0),a=0,c=0,l=0;for(let u=0;u<i;++u){let f=o[e[u]];if(f===void 0)throw new SyntaxError(`Non-${n} character`);c=c<<r|f,a+=r,a>=8&&(a-=8,s[l++]=255&c>>a)}if(a>=r||(255&c<<8-a)!==0)throw new SyntaxError("Unexpected end of data");return s}function Af(e,t,r){let n=t[t.length-1]==="=",o=(1<<r)-1,i="",s=0,a=0;for(let c=0;c<e.length;++c)for(a=a<<8|e[c],s+=8;s>r;)s-=r,i+=t[o&a>>s];if(s!==0&&(i+=t[o&a<<r-s]),n)for(;(i.length*r&7)!==0;)i+="=";return i}function st({name:e,prefix:t,bitsPerChar:r,alphabet:n}){return We({prefix:t,name:e,encode(o){return Af(o,n,r)},decode(o){return vf(o,n,r,e)}})}var Kt=st({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),If=st({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Tf=st({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Bf=st({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Cf=st({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Uf=st({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Nf=st({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Pf=st({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Rf=st({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var To={};At(To,{base58btc:()=>et,base58flickr:()=>_f});var et=xe({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),_f=xe({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Co={};At(Co,{base64:()=>Bo,base64pad:()=>Lf,base64url:()=>kf,base64urlpad:()=>Df});var Bo=st({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Lf=st({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),kf=st({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Df=st({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});function Ff(e,t){try{if(typeof e=="string"&&e.length>0)return Of(e);if(typeof e=="number"&&isFinite(e))return t?.long?Vf(e):Mf(e);throw new Error("Value is not a string or number.")}catch(r){let n=Kf(r)?`${r.message}. value=${JSON.stringify(e)}`:"An unknown error has occured.";throw new Error(n)}}function Of(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 on=Ff;function Mf(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 Vf(e){let t=Math.abs(e);return t>=864e5?nn(e,t,864e5,"day"):t>=36e5?nn(e,t,36e5,"hour"):t>=6e4?nn(e,t,6e4,"minute"):t>=1e3?nn(e,t,1e3,"second"):`${e} ms`}function nn(e,t,r,n){let o=t>=r*1.5;return`${Math.round(e/r)} ${n}${o?"s":""}`}function Kf(e){return typeof e=="object"&&e!==null&&"message"in e}function Uo(e){r.debug=r,r.default=r,r.coerce=c,r.disable=i,r.enable=o,r.enabled=s,r.humanize=on,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 d=0;d<u.length;d++)f=(f<<5)-f+u.charCodeAt(d),f|=0;return r.colors[Math.abs(f)%r.colors.length]}r.selectColor=t;function r(u){let f,d=null,b,T;function y(...h){if(!y.enabled)return;let v=y,C=Number(new Date),x=C-(f||C);v.diff=x,v.prev=f,v.curr=C,f=C,h[0]=r.coerce(h[0]),typeof h[0]!="string"&&h.unshift("%O");let P=0;h[0]=h[0].replace(/%([a-zA-Z%])/g,(k,R)=>{if(k==="%%")return"%";P++;let w=r.formatters[R];if(typeof w=="function"){let E=h[P];k=w.call(v,E),h.splice(P,1),P--}return k}),r.formatArgs.call(v,h),(v.log||r.log).apply(v,h)}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:()=>d!==null?d:(b!==r.namespaces&&(b=r.namespaces,T=r.enabled(u)),T),set:h=>{d=h}}),typeof r.init=="function"&&r.init(y),y}function n(u,f){let d=r(this.namespace+(typeof f>"u"?":":f)+u);return d.log=this.log,d}function o(u){r.save(u),r.namespaces=u,r.names=[],r.skips=[];let f,d=(typeof u=="string"?u:"").split(/[\s,]+/),b=d.length;for(f=0;f<b;f++)d[f]&&(u=d[f].replace(/\*/g,".*?"),u[0]==="-"?r.skips.push(new RegExp("^"+u.substr(1)+"$")):r.names.push(new RegExp("^"+u+"$")))}function i(){let u=[...r.names.map(a),...r.skips.map(a).map(f=>"-"+f)].join(",");return r.enable(""),u}function s(u){if(u[u.length-1]==="*")return!0;let f,d;for(f=0,d=r.skips.length;f<d;f++)if(r.skips[f].test(u))return!1;for(f=0,d=r.names.length;f<d;f++)if(r.names[f].test(u))return!0;return!1}function a(u){return u.toString().substring(2,u.toString().length-2).replace(/\.\*\?$/,"*")}function c(u){return u instanceof Error?u.stack??u.message:u}function l(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return r.setupFormatters(r.formatters),r.enable(r.load()),r}var sn=jf(),qf=["#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 $f(){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 zf(e){if(e[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+e[0]+(this.useColors?"%c ":" ")+"+"+on(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 Hf=console.debug??console.log??(()=>{});function Gf(e){try{e?sn?.setItem("debug",e):sn?.removeItem("debug")}catch{}}function Zf(){let e;try{e=sn?.getItem("debug")}catch{}return!e&&typeof globalThis.process<"u"&&"env"in globalThis.process&&(e=globalThis.process.env.DEBUG),e}function jf(){try{return localStorage}catch{}}function Yf(e){e.j=function(t){try{return JSON.stringify(t)}catch(r){return"[UnexpectedJSONParseError]: "+r.message}}}var qs=Uo({formatArgs:zf,save:Gf,load:Zf,useColors:$f,setupFormatters:Yf,colors:qf,storage:sn,log:Hf});var Ct=qs;Ct.formatters.b=e=>e==null?"undefined":et.baseEncode(e);Ct.formatters.t=e=>e==null?"undefined":Kt.baseEncode(e);Ct.formatters.m=e=>e==null?"undefined":Bo.baseEncode(e);Ct.formatters.p=e=>e==null?"undefined":e.toString();Ct.formatters.c=e=>e==null?"undefined":e.toString();Ct.formatters.k=e=>e==null?"undefined":e.toString();Ct.formatters.a=e=>e==null?"undefined":e.toString();Ct.formatters.e=e=>e==null?"undefined":$s(e.stack)??$s(e.message)??e.toString();function Wf(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 we(e){let t=Wf(`${e}:trace`);return Ct.enabled(`${e}:trace`)&&Ct.names.map(r=>r.toString()).find(r=>r.includes(":trace"))!=null&&(t=Ct(`${e}:trace`)),Object.assign(Ct(e),{error:Ct(`${e}:error`),trace:t})}function $s(e){if(e!=null&&(e=e.trim(),e.length!==0))return e}var No={};At(No,{base36:()=>Xe,base36upper:()=>Xf});var Xe=xe({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Xf=xe({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Jf=Gs,zs=128,Qf=127,tl=~Qf,el=Math.pow(2,31);function Gs(e,t,r){t=t||[],r=r||0;for(var n=r;e>=el;)t[r++]=e&255|zs,e/=128;for(;e&tl;)t[r++]=e&255|zs,e>>>=7;return t[r]=e|0,Gs.bytes=r-n+1,t}var rl=Po,nl=128,Hs=127;function Po(e,n){var r=0,n=n||0,o=0,i=n,s,a=e.length;do{if(i>=a)throw Po.bytes=0,new RangeError("Could not decode varint");s=e[i++],r+=o<28?(s&Hs)<<o:(s&Hs)*Math.pow(2,o),o+=7}while(s>=nl);return Po.bytes=i-n,r}var ol=Math.pow(2,7),il=Math.pow(2,14),sl=Math.pow(2,21),al=Math.pow(2,28),cl=Math.pow(2,35),ul=Math.pow(2,42),fl=Math.pow(2,49),ll=Math.pow(2,56),dl=Math.pow(2,63),hl=function(e){return e<ol?1:e<il?2:e<sl?3:e<al?4:e<cl?5:e<ul?6:e<fl?7:e<ll?8:e<dl?9:10},pl={encode:Jf,decode:rl,encodingLength:hl},ml=pl,Ir=ml;function Tr(e,t=0){return[Ir.decode(e,t),Ir.decode.bytes]}function Je(e,t,r=0){return Ir.encode(e,t,r),t}function Qe(e){return Ir.encodingLength(e)}function qt(e,t){let r=t.byteLength,n=Qe(e),o=n+Qe(r),i=new Uint8Array(o+r);return Je(e,i,0),Je(r,i,n),i.set(t,o),new tr(e,r,t,i)}function ce(e){let t=ae(e),[r,n]=Tr(t),[o,i]=Tr(t.subarray(n)),s=t.subarray(n+i);if(s.byteLength!==o)throw new Error("Incorrect length");return new tr(r,o,s,t)}function Zs(e,t){if(e===t)return!0;{let r=t;return e.code===r.code&&e.size===r.size&&r.bytes instanceof Uint8Array&&Ds(e.bytes,r.bytes)}}var tr=class{code;size;digest;bytes;constructor(t,r,n,o){this.code=t,this.size=r,this.digest=n,this.bytes=o}};function js(e,t){let{bytes:r,version:n}=e;switch(n){case 0:return yl(r,Ro(e),t??et.encoder);default:return xl(r,Ro(e),t??Kt.encoder)}}var Ys=new WeakMap;function Ro(e){let t=Ys.get(e);if(t==null){let r=new Map;return Ys.set(e,r),r}return t}var X=class e{code;version;multihash;bytes;"/";constructor(t,r,n,o){this.code=r,this.version=t,this.multihash=n,this.bytes=o,this["/"]=o}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:t,multihash:r}=this;if(t!==Br)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==wl)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=qt(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&&Zs(t.multihash,n.multihash)}toString(t){return js(this,t)}toJSON(){return{"/":js(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??Ws(n,o,i.bytes))}else if(r[bl]===!0){let{version:n,multihash:o,code:i}=r,s=ce(o);return e.create(n,i,s)}else return null}static create(t,r,n){if(typeof r!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(t){case 0:{if(r!==Br)throw new Error(`Version 0 CID must use dag-pb (code: ${Br}) block encoding`);return new e(t,r,n,n.bytes)}case 1:{let o=Ws(t,r,n.bytes);return new e(t,r,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return e.create(0,Br,t)}static createV1(t,r){return e.create(1,t,r)}static decode(t){let[r,n]=e.decodeFirst(t);if(n.length!==0)throw new Error("Incorrect length");return r}static decodeFirst(t){let r=e.inspectBytes(t),n=r.size-r.multihashSize,o=ae(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 tr(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,d]=Tr(t.subarray(r));return r+=d,f},o=n(),i=Br;if(o===18?(o=0,r=0):i=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let s=r,a=n(),c=n(),l=r+c,u=l-s;return{version:o,codec:i,multihashCode:a,digestSize:c,multihashSize:u,size:l}}static parse(t,r){let[n,o]=gl(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 Ro(i).set(n,t),i}};function gl(e,t){switch(e[0]){case"Q":{let r=t??et;return[et.prefix,r.decode(`${et.prefix}${e}`)]}case et.prefix:{let r=t??et;return[et.prefix,r.decode(e)]}case Kt.prefix:{let r=t??Kt;return[Kt.prefix,r.decode(e)]}case Xe.prefix:{let r=t??Xe;return[Xe.prefix,r.decode(e)]}default:{if(t==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[e[0],t.decode(e)]}}}function yl(e,t,r){let{prefix:n}=r;if(n!==et.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 xl(e,t,r){let{prefix:n}=r,o=t.get(n);if(o==null){let i=r.encode(e);return t.set(n,i),i}else return o}var Br=112,wl=18;function Ws(e,t,r){let n=Qe(e),o=n+Qe(t),i=new Uint8Array(o+r.byteLength);return Je(e,i,0),Je(t,i,n),i.set(r,o),i}var bl=Symbol.for("@ipld/js-cid/CID");var _o={};At(_o,{identity:()=>$t});var Xs=0,El="identity",Js=ae;function Sl(e){return qt(Xs,Js(e))}var $t={code:Xs,name:El,encode:Js,digest:Sl};function ot(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 Qs(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function vl(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function er(e,...t){if(!vl(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 ta(e){if(typeof e!="function"||typeof e.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");Qs(e.outputLen),Qs(e.blockLen)}function rr(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 ea(e,t){er(e);let r=t.outputLen;if(e.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}var Le=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function cn(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function zt(e,t){return e<<32-t|e>>>t}function ra(e){if(typeof e!="string")throw new Error("utf8ToBytes expected string, got "+typeof e);return new Uint8Array(new TextEncoder().encode(e))}function Cr(e){return typeof e=="string"&&(e=ra(e)),er(e),e}function Lo(...e){let t=0;for(let n=0;n<e.length;n++){let o=e[n];er(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 nr=class{clone(){return this._cloneInto()}};function un(e){let t=n=>e().update(Cr(n)).digest(),r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>e(),t}function fn(e=32){if(Le&&typeof Le.getRandomValues=="function")return Le.getRandomValues(new Uint8Array(e));if(Le&&typeof Le.randomBytes=="function")return Le.randomBytes(e);throw new Error("crypto.getRandomValues must be defined")}function Al(e,t,r,n){if(typeof e.setBigUint64=="function")return e.setBigUint64(t,r,n);let o=BigInt(32),i=BigInt(4294967295),s=Number(r>>o&i),a=Number(r&i),c=n?4:0,l=n?0:4;e.setUint32(t+c,s,n),e.setUint32(t+l,a,n)}function na(e,t,r){return e&t^~e&r}function oa(e,t,r){return e&t^e&r^t&r}var or=class extends nr{constructor(t,r,n,o){super(),this.blockLen=t,this.outputLen=r,this.padOffset=n,this.isLE=o,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=cn(this.buffer)}update(t){rr(this);let{view:r,buffer:n,blockLen:o}=this;t=Cr(t);let i=t.length;for(let s=0;s<i;){let a=Math.min(o-this.pos,i-s);if(a===o){let c=cn(t);for(;o<=i-s;s+=o)this.process(c,s);continue}n.set(t.subarray(s,s+a),this.pos),this.pos+=a,s+=a,this.pos===o&&(this.process(r,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){rr(this),ea(t,this),this.finished=!0;let{buffer:r,view:n,blockLen:o,isLE:i}=this,{pos:s}=this;r[s++]=128,this.buffer.subarray(s).fill(0),this.padOffset>o-s&&(this.process(n,0),s=0);for(let f=s;f<o;f++)r[f]=0;Al(n,o-8,BigInt(this.length*8),i),this.process(n,0);let a=cn(t),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let l=c/4,u=this.get();if(l>u.length)throw new Error("_sha2: outputLen bigger than state");for(let f=0;f<l;f++)a.setUint32(4*f,u[f],i)}digest(){let{buffer:t,outputLen:r}=this;this.digestInto(t);let n=t.slice(0,r);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());let{blockLen:r,buffer:n,length:o,finished:i,destroyed:s,pos:a}=this;return t.length=o,t.pos=a,t.finished=i,t.destroyed=s,o%r&&t.buffer.set(n),t}};var ln=BigInt(4294967295),ko=BigInt(32);function ia(e,t=!1){return t?{h:Number(e&ln),l:Number(e>>ko&ln)}:{h:Number(e>>ko&ln)|0,l:Number(e&ln)|0}}function Il(e,t=!1){let r=new Uint32Array(e.length),n=new Uint32Array(e.length);for(let o=0;o<e.length;o++){let{h:i,l:s}=ia(e[o],t);[r[o],n[o]]=[i,s]}return[r,n]}var Tl=(e,t)=>BigInt(e>>>0)<<ko|BigInt(t>>>0),Bl=(e,t,r)=>e>>>r,Cl=(e,t,r)=>e<<32-r|t>>>r,Ul=(e,t,r)=>e>>>r|t<<32-r,Nl=(e,t,r)=>e<<32-r|t>>>r,Pl=(e,t,r)=>e<<64-r|t>>>r-32,Rl=(e,t,r)=>e>>>r-32|t<<64-r,_l=(e,t)=>t,Ll=(e,t)=>e,kl=(e,t,r)=>e<<r|t>>>32-r,Dl=(e,t,r)=>t<<r|e>>>32-r,Fl=(e,t,r)=>t<<r-32|e>>>64-r,Ol=(e,t,r)=>e<<r-32|t>>>64-r;function Ml(e,t,r,n){let o=(t>>>0)+(n>>>0);return{h:e+r+(o/2**32|0)|0,l:o|0}}var Vl=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0),Kl=(e,t,r,n)=>t+r+n+(e/2**32|0)|0,ql=(e,t,r,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0),$l=(e,t,r,n,o)=>t+r+n+o+(e/2**32|0)|0,zl=(e,t,r,n,o)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0)+(o>>>0),Hl=(e,t,r,n,o,i)=>t+r+n+o+i+(e/2**32|0)|0;var Gl={fromBig:ia,split:Il,toBig:Tl,shrSH:Bl,shrSL:Cl,rotrSH:Ul,rotrSL:Nl,rotrBH:Pl,rotrBL:Rl,rotr32H:_l,rotr32L:Ll,rotlSH:kl,rotlSL:Dl,rotlBH:Fl,rotlBL:Ol,add:Ml,add3L:Vl,add3H:Kl,add4L:ql,add4H:$l,add5H:Hl,add5L:zl},$=Gl;var[Zl,jl]=$.split(["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))),Ee=new Uint32Array(80),Se=new Uint32Array(80),Do=class extends or{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){let{Ah:t,Al:r,Bh:n,Bl:o,Ch:i,Cl:s,Dh:a,Dl:c,Eh:l,El:u,Fh:f,Fl:d,Gh:b,Gl:T,Hh:y,Hl:h}=this;return[t,r,n,o,i,s,a,c,l,u,f,d,b,T,y,h]}set(t,r,n,o,i,s,a,c,l,u,f,d,b,T,y,h){this.Ah=t|0,this.Al=r|0,this.Bh=n|0,this.Bl=o|0,this.Ch=i|0,this.Cl=s|0,this.Dh=a|0,this.Dl=c|0,this.Eh=l|0,this.El=u|0,this.Fh=f|0,this.Fl=d|0,this.Gh=b|0,this.Gl=T|0,this.Hh=y|0,this.Hl=h|0}process(t,r){for(let x=0;x<16;x++,r+=4)Ee[x]=t.getUint32(r),Se[x]=t.getUint32(r+=4);for(let x=16;x<80;x++){let P=Ee[x-15]|0,D=Se[x-15]|0,k=$.rotrSH(P,D,1)^$.rotrSH(P,D,8)^$.shrSH(P,D,7),R=$.rotrSL(P,D,1)^$.rotrSL(P,D,8)^$.shrSL(P,D,7),w=Ee[x-2]|0,E=Se[x-2]|0,F=$.rotrSH(w,E,19)^$.rotrBH(w,E,61)^$.shrSH(w,E,6),_=$.rotrSL(w,E,19)^$.rotrBL(w,E,61)^$.shrSL(w,E,6),U=$.add4L(R,_,Se[x-7],Se[x-16]),K=$.add4H(U,k,F,Ee[x-7],Ee[x-16]);Ee[x]=K|0,Se[x]=U|0}let{Ah:n,Al:o,Bh:i,Bl:s,Ch:a,Cl:c,Dh:l,Dl:u,Eh:f,El:d,Fh:b,Fl:T,Gh:y,Gl:h,Hh:v,Hl:C}=this;for(let x=0;x<80;x++){let P=$.rotrSH(f,d,14)^$.rotrSH(f,d,18)^$.rotrBH(f,d,41),D=$.rotrSL(f,d,14)^$.rotrSL(f,d,18)^$.rotrBL(f,d,41),k=f&b^~f&y,R=d&T^~d&h,w=$.add5L(C,D,R,jl[x],Se[x]),E=$.add5H(w,v,P,k,Zl[x],Ee[x]),F=w|0,_=$.rotrSH(n,o,28)^$.rotrBH(n,o,34)^$.rotrBH(n,o,39),U=$.rotrSL(n,o,28)^$.rotrBL(n,o,34)^$.rotrBL(n,o,39),K=n&i^n&a^i&a,A=o&s^o&c^s&c;v=y|0,C=h|0,y=b|0,h=T|0,b=f|0,T=d|0,{h:f,l:d}=$.add(l|0,u|0,E|0,F|0),l=a|0,u=c|0,a=i|0,c=s|0,i=n|0,s=o|0;let I=$.add3L(F,U,A);n=$.add3H(I,E,_,K),o=I|0}({h:n,l:o}=$.add(this.Ah|0,this.Al|0,n|0,o|0)),{h:i,l:s}=$.add(this.Bh|0,this.Bl|0,i|0,s|0),{h:a,l:c}=$.add(this.Ch|0,this.Cl|0,a|0,c|0),{h:l,l:u}=$.add(this.Dh|0,this.Dl|0,l|0,u|0),{h:f,l:d}=$.add(this.Eh|0,this.El|0,f|0,d|0),{h:b,l:T}=$.add(this.Fh|0,this.Fl|0,b|0,T|0),{h:y,l:h}=$.add(this.Gh|0,this.Gl|0,y|0,h|0),{h:v,l:C}=$.add(this.Hh|0,this.Hl|0,v|0,C|0),this.set(n,o,i,s,a,c,l,u,f,d,b,T,y,h,v,C)}roundClean(){Ee.fill(0),Se.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};var sa=un(()=>new Do);var pn={};At(pn,{aInRange:()=>Ut,abool:()=>Ht,abytes:()=>ir,bitGet:()=>td,bitLen:()=>Vo,bitMask:()=>Nr,bitSet:()=>ed,bytesToHex:()=>fe,bytesToNumberBE:()=>le,bytesToNumberLE:()=>Ae,concatBytes:()=>de,createHmacDrbg:()=>Ko,ensureBytes:()=>it,equalBytes:()=>Jl,hexToBytes:()=>De,hexToNumber:()=>Mo,inRange:()=>Ur,isBytes:()=>ve,memoized:()=>Oe,notImplemented:()=>nd,numberToBytesBE:()=>Ie,numberToBytesLE:()=>Fe,numberToHexUnpadded:()=>ke,numberToVarBytesBE:()=>Xl,utf8ToBytes:()=>Ql,validateObject:()=>re});var dn=BigInt(0),hn=BigInt(1),Yl=BigInt(2);function ve(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function ir(e){if(!ve(e))throw new Error("Uint8Array expected")}function Ht(e,t){if(typeof t!="boolean")throw new Error(e+" boolean expected, got "+t)}var Wl=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function fe(e){ir(e);let t="";for(let r=0;r<e.length;r++)t+=Wl[e[r]];return t}function ke(e){let t=e.toString(16);return t.length&1?"0"+t:t}function Mo(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);return e===""?dn:BigInt("0x"+e)}var ue={_0:48,_9:57,A:65,F:70,a:97,f:102};function aa(e){if(e>=ue._0&&e<=ue._9)return e-ue._0;if(e>=ue.A&&e<=ue.F)return e-(ue.A-10);if(e>=ue.a&&e<=ue.f)return e-(ue.a-10)}function De(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof 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=aa(e.charCodeAt(i)),a=aa(e.charCodeAt(i+1));if(s===void 0||a===void 0){let c=e[i]+e[i+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+i)}n[o]=s*16+a}return n}function le(e){return Mo(fe(e))}function Ae(e){return ir(e),Mo(fe(Uint8Array.from(e).reverse()))}function Ie(e,t){return De(e.toString(16).padStart(t*2,"0"))}function Fe(e,t){return Ie(e,t).reverse()}function Xl(e){return De(ke(e))}function it(e,t,r){let n;if(typeof t=="string")try{n=De(t)}catch(i){throw new Error(e+" must be hex string or Uint8Array, cause: "+i)}else if(ve(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 de(...e){let t=0;for(let n=0;n<e.length;n++){let o=e[n];ir(o),t+=o.length}let r=new Uint8Array(t);for(let n=0,o=0;n<e.length;n++){let i=e[n];r.set(i,o),o+=i.length}return r}function Jl(e,t){if(e.length!==t.length)return!1;let r=0;for(let n=0;n<e.length;n++)r|=e[n]^t[n];return r===0}function Ql(e){if(typeof e!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(e))}var Fo=e=>typeof e=="bigint"&&dn<=e;function Ur(e,t,r){return Fo(e)&&Fo(t)&&Fo(r)&&t<=e&&e<r}function Ut(e,t,r,n){if(!Ur(t,r,n))throw new Error("expected valid "+e+": "+r+" <= n < "+n+", got "+t)}function Vo(e){let t;for(t=0;e>dn;e>>=hn,t+=1);return t}function td(e,t){return e>>BigInt(t)&hn}function ed(e,t,r){return e|(r?hn:dn)<<BigInt(t)}var Nr=e=>(Yl<<BigInt(e-1))-hn,Oo=e=>new Uint8Array(e),ca=e=>Uint8Array.from(e);function Ko(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=Oo(e),o=Oo(e),i=0,s=()=>{n.fill(1),o.fill(0),i=0},a=(...f)=>r(o,n,...f),c=(f=Oo())=>{o=a(ca([0]),f),n=a(),f.length!==0&&(o=a(ca([1]),f),n=a())},l=()=>{if(i++>=1e3)throw new Error("drbg: tried 1000 values");let f=0,d=[];for(;f<t;){n=a();let b=n.slice();d.push(b),f+=n.length}return de(...d)};return(f,d)=>{s(),c(f);let b;for(;!(b=d(l()));)c();return s(),b}}var rd={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"||ve(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 re(e,t,r={}){let n=(o,i,s)=>{let a=rd[i];if(typeof a!="function")throw new Error("invalid validator function");let c=e[o];if(!(s&&c===void 0)&&!a(c,e))throw new Error("param "+String(o)+" is invalid. Expected "+i+", got "+c)};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}var nd=()=>{throw new Error("not implemented")};function Oe(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 ct=BigInt(0),rt=BigInt(1),Me=BigInt(2),od=BigInt(3),qo=BigInt(4),ua=BigInt(5),fa=BigInt(8),id=BigInt(9),sd=BigInt(16);function J(e,t){let r=e%t;return r>=ct?r:t+r}function ad(e,t,r){if(t<ct)throw new Error("invalid exponent, negatives unsupported");if(r<=ct)throw new Error("invalid modulus");if(r===rt)return ct;let n=rt;for(;t>ct;)t&rt&&(n=n*e%r),e=e*e%r,t>>=rt;return n}function nt(e,t,r){let n=e;for(;t-- >ct;)n*=n,n%=r;return n}function mn(e,t){if(e===ct)throw new Error("invert: expected non-zero number");if(t<=ct)throw new Error("invert: expected positive modulus, got "+t);let r=J(e,t),n=t,o=ct,i=rt,s=rt,a=ct;for(;r!==ct;){let l=n/r,u=n%r,f=o-s*l,d=i-a*l;n=r,r=u,o=s,i=a,s=f,a=d}if(n!==rt)throw new Error("invert: does not exist");return J(o,t)}function cd(e){let t=(e-rt)/Me,r,n,o;for(r=e-rt,n=0;r%Me===ct;r/=Me,n++);for(o=Me;o<e&&ad(o,t,e)!==e-rt;o++)if(o>1e3)throw new Error("Cannot find square root: likely non-prime P");if(n===1){let s=(e+rt)/qo;return function(c,l){let u=c.pow(l,s);if(!c.eql(c.sqr(u),l))throw new Error("Cannot find square root");return u}}let i=(r+rt)/Me;return function(a,c){if(a.pow(c,t)===a.neg(a.ONE))throw new Error("Cannot find square root");let l=n,u=a.pow(a.mul(a.ONE,o),r),f=a.pow(c,i),d=a.pow(c,r);for(;!a.eql(d,a.ONE);){if(a.eql(d,a.ZERO))return a.ZERO;let b=1;for(let y=a.sqr(d);b<l&&!a.eql(y,a.ONE);b++)y=a.sqr(y);let T=a.pow(u,rt<<BigInt(l-b-1));u=a.sqr(T),f=a.mul(f,T),d=a.mul(d,u),l=b}return f}}function ud(e){if(e%qo===od){let t=(e+rt)/qo;return function(n,o){let i=n.pow(o,t);if(!n.eql(n.sqr(i),o))throw new Error("Cannot find square root");return i}}if(e%fa===ua){let t=(e-ua)/fa;return function(n,o){let i=n.mul(o,Me),s=n.pow(i,t),a=n.mul(o,s),c=n.mul(n.mul(a,Me),s),l=n.mul(a,n.sub(c,n.ONE));if(!n.eql(n.sqr(l),o))throw new Error("Cannot find square root");return l}}return e%sd,cd(e)}var la=(e,t)=>(J(e,t)&rt)===rt,fd=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function $o(e){let t={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},r=fd.reduce((n,o)=>(n[o]="function",n),t);return re(e,r)}function ld(e,t,r){if(r<ct)throw new Error("invalid exponent, negatives unsupported");if(r===ct)return e.ONE;if(r===rt)return t;let n=e.ONE,o=t;for(;r>ct;)r&rt&&(n=e.mul(n,o)),o=e.sqr(o),r>>=rt;return n}function dd(e,t){let r=new Array(t.length),n=t.reduce((i,s,a)=>e.is0(s)?i:(r[a]=i,e.mul(i,s)),e.ONE),o=e.inv(n);return t.reduceRight((i,s,a)=>e.is0(s)?i:(r[a]=e.mul(i,r[a]),e.mul(i,s)),o),r}function zo(e,t){let r=t!==void 0?t:e.toString(2).length,n=Math.ceil(r/8);return{nBitLength:r,nByteLength:n}}function Te(e,t,r=!1,n={}){if(e<=ct)throw new Error("invalid field: expected ORDER > 0, got "+e);let{nBitLength:o,nByteLength:i}=zo(e,t);if(i>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let s,a=Object.freeze({ORDER:e,isLE:r,BITS:o,BYTES:i,MASK:Nr(o),ZERO:ct,ONE:rt,create:c=>J(c,e),isValid:c=>{if(typeof c!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof c);return ct<=c&&c<e},is0:c=>c===ct,isOdd:c=>(c&rt)===rt,neg:c=>J(-c,e),eql:(c,l)=>c===l,sqr:c=>J(c*c,e),add:(c,l)=>J(c+l,e),sub:(c,l)=>J(c-l,e),mul:(c,l)=>J(c*l,e),pow:(c,l)=>ld(a,c,l),div:(c,l)=>J(c*mn(l,e),e),sqrN:c=>c*c,addN:(c,l)=>c+l,subN:(c,l)=>c-l,mulN:(c,l)=>c*l,inv:c=>mn(c,e),sqrt:n.sqrt||(c=>(s||(s=ud(e)),s(a,c))),invertBatch:c=>dd(a,c),cmov:(c,l,u)=>u?l:c,toBytes:c=>r?Fe(c,i):Ie(c,i),fromBytes:c=>{if(c.length!==i)throw new Error("Field.fromBytes: expected "+i+" bytes, got "+c.length);return r?Ae(c):le(c)}});return Object.freeze(a)}function da(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 Ho(e){let t=da(e);return t+Math.ceil(t/2)}function ha(e,t,r=!1){let n=e.length,o=da(t),i=Ho(t);if(n<16||n<i||n>1024)throw new Error("expected "+i+"-1024 bytes of input, got "+n);let s=r?Ae(e):le(e),a=J(s,t-rt)+rt;return r?Fe(a,o):Ie(a,o)}var pa=BigInt(0),gn=BigInt(1);function Go(e,t){let r=t.negate();return e?r:t}function ma(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+e)}function Zo(e,t){ma(e,t);let r=Math.ceil(t/e)+1,n=2**(e-1);return{windows:r,windowSize:n}}function hd(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 pd(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 jo=new WeakMap,ga=new WeakMap;function Yo(e){return ga.get(e)||1}function yn(e,t){return{constTimeNegate:Go,hasPrecomputes(r){return Yo(r)!==1},unsafeLadder(r,n,o=e.ZERO){let i=r;for(;n>pa;)n&gn&&(o=o.add(i)),i=i.double(),n>>=gn;return o},precomputeWindow(r,n){let{windows:o,windowSize:i}=Zo(n,t),s=[],a=r,c=a;for(let l=0;l<o;l++){c=a,s.push(c);for(let u=1;u<i;u++)c=c.add(a),s.push(c);a=c.double()}return s},wNAF(r,n,o){let{windows:i,windowSize:s}=Zo(r,t),a=e.ZERO,c=e.BASE,l=BigInt(2**r-1),u=2**r,f=BigInt(r);for(let d=0;d<i;d++){let b=d*s,T=Number(o&l);o>>=f,T>s&&(T-=u,o+=gn);let y=b,h=b+Math.abs(T)-1,v=d%2!==0,C=T<0;T===0?c=c.add(Go(v,n[y])):a=a.add(Go(C,n[h]))}return{p:a,f:c}},wNAFUnsafe(r,n,o,i=e.ZERO){let{windows:s,windowSize:a}=Zo(r,t),c=BigInt(2**r-1),l=2**r,u=BigInt(r);for(let f=0;f<s;f++){let d=f*a;if(o===pa)break;let b=Number(o&c);if(o>>=u,b>a&&(b-=l,o+=gn),b===0)continue;let T=n[d+Math.abs(b)-1];b<0&&(T=T.negate()),i=i.add(T)}return i},getPrecomputes(r,n,o){let i=jo.get(n);return i||(i=this.precomputeWindow(n,r),r!==1&&jo.set(n,o(i))),i},wNAFCached(r,n,o){let i=Yo(r);return this.wNAF(i,this.getPrecomputes(i,r,o),n)},wNAFCachedUnsafe(r,n,o,i){let s=Yo(r);return s===1?this.unsafeLadder(r,n,i):this.wNAFUnsafe(s,this.getPrecomputes(s,r,o),n,i)},setWindowSize(r,n){ma(n,t),ga.set(r,n),jo.delete(r)}}}function xn(e,t,r,n){if(hd(r,e),pd(n,t),r.length!==n.length)throw new Error("arrays of points and scalars must have equal length");let o=e.ZERO,i=Vo(BigInt(r.length)),s=i>12?i-3:i>4?i-2:i?2:1,a=(1<<s)-1,c=new Array(a+1).fill(o),l=Math.floor((t.BITS-1)/s)*s,u=o;for(let f=l;f>=0;f-=s){c.fill(o);for(let b=0;b<n.length;b++){let T=n[b],y=Number(T>>BigInt(f)&BigInt(a));c[y]=c[y].add(r[b])}let d=o;for(let b=c.length-1,T=o;b>0;b--)T=T.add(c[b]),d=d.add(T);if(u=u.add(d),f!==0)for(let b=0;b<s;b++)u=u.double()}return u}function Pr(e){return $o(e.Fp),re(e,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...zo(e.n,e.nBitLength),...e,p:e.Fp.ORDER})}var Gt=BigInt(0),Nt=BigInt(1),wn=BigInt(2),md=BigInt(8),gd={zip215:!0};function yd(e){let t=Pr(e);return re(e,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...t})}function ya(e){let t=yd(e),{Fp:r,n,prehash:o,hash:i,randomBytes:s,nByteLength:a,h:c}=t,l=wn<<BigInt(a*8)-Nt,u=r.create,f=Te(t.n,t.nBitLength),d=t.uvRatio||((m,p)=>{try{return{isValid:!0,value:r.sqrt(m*r.inv(p))}}catch{return{isValid:!1,value:Gt}}}),b=t.adjustScalarBytes||(m=>m),T=t.domain||((m,p,S)=>{if(Ht("phflag",S),p.length||S)throw new Error("Contexts/pre-hash are not supported");return m});function y(m,p){Ut("coordinate "+m,p,Gt,l)}function h(m){if(!(m instanceof x))throw new Error("ExtendedPoint expected")}let v=Oe((m,p)=>{let{ex:S,ey:N,ez:O}=m,M=m.is0();p==null&&(p=M?md:r.inv(O));let z=u(S*p),Z=u(N*p),q=u(O*p);if(M)return{x:Gt,y:Nt};if(q!==Nt)throw new Error("invZ was invalid");return{x:z,y:Z}}),C=Oe(m=>{let{a:p,d:S}=t;if(m.is0())throw new Error("bad point: ZERO");let{ex:N,ey:O,ez:M,et:z}=m,Z=u(N*N),q=u(O*O),W=u(M*M),tt=u(W*W),ft=u(Z*p),lt=u(W*u(ft+q)),mt=u(tt+u(S*u(Z*q)));if(lt!==mt)throw new Error("bad point: equation left != right (1)");let yt=u(N*O),Tt=u(M*z);if(yt!==Tt)throw new Error("bad point: equation left != right (2)");return!0});class x{constructor(p,S,N,O){this.ex=p,this.ey=S,this.ez=N,this.et=O,y("x",p),y("y",S),y("z",N),y("t",O),Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(p){if(p instanceof x)throw new Error("extended point not allowed");let{x:S,y:N}=p||{};return y("x",S),y("y",N),new x(S,N,Nt,u(S*N))}static normalizeZ(p){let S=r.invertBatch(p.map(N=>N.ez));return p.map((N,O)=>N.toAffine(S[O])).map(x.fromAffine)}static msm(p,S){return xn(x,f,p,S)}_setWindowSize(p){k.setWindowSize(this,p)}assertValidity(){C(this)}equals(p){h(p);let{ex:S,ey:N,ez:O}=this,{ex:M,ey:z,ez:Z}=p,q=u(S*Z),W=u(M*O),tt=u(N*Z),ft=u(z*O);return q===W&&tt===ft}is0(){return this.equals(x.ZERO)}negate(){return new x(u(-this.ex),this.ey,this.ez,u(-this.et))}double(){let{a:p}=t,{ex:S,ey:N,ez:O}=this,M=u(S*S),z=u(N*N),Z=u(wn*u(O*O)),q=u(p*M),W=S+N,tt=u(u(W*W)-M-z),ft=q+z,lt=ft-Z,mt=q-z,yt=u(tt*lt),Tt=u(ft*mt),vt=u(tt*mt),ee=u(lt*ft);return new x(yt,Tt,ee,vt)}add(p){h(p);let{a:S,d:N}=t,{ex:O,ey:M,ez:z,et:Z}=this,{ex:q,ey:W,ez:tt,et:ft}=p;if(S===BigInt(-1)){let Is=u((M-O)*(W+q)),Ts=u((M+O)*(W-q)),xo=u(Ts-Is);if(xo===Gt)return this.double();let Bs=u(z*wn*ft),Cs=u(Z*wn*tt),Us=Cs+Bs,Ns=Ts+Is,Ps=Cs-Bs,ff=u(Us*xo),lf=u(Ns*Ps),df=u(Us*Ps),hf=u(xo*Ns);return new x(ff,lf,hf,df)}let lt=u(O*q),mt=u(M*W),yt=u(Z*N*ft),Tt=u(z*tt),vt=u((O+M)*(q+W)-lt-mt),ee=Tt-yt,se=Tt+yt,Ar=u(mt-S*lt),sf=u(vt*ee),af=u(se*Ar),cf=u(vt*Ar),uf=u(ee*se);return new x(sf,af,uf,cf)}subtract(p){return this.add(p.negate())}wNAF(p){return k.wNAFCached(this,p,x.normalizeZ)}multiply(p){let S=p;Ut("scalar",S,Nt,n);let{p:N,f:O}=this.wNAF(S);return x.normalizeZ([N,O])[0]}multiplyUnsafe(p,S=x.ZERO){let N=p;return Ut("scalar",N,Gt,n),N===Gt?D:this.is0()||N===Nt?this:k.wNAFCachedUnsafe(this,N,x.normalizeZ,S)}isSmallOrder(){return this.multiplyUnsafe(c).is0()}isTorsionFree(){return k.unsafeLadder(this,n).is0()}toAffine(p){return v(this,p)}clearCofactor(){let{h:p}=t;return p===Nt?this:this.multiplyUnsafe(p)}static fromHex(p,S=!1){let{d:N,a:O}=t,M=r.BYTES;p=it("pointHex",p,M),Ht("zip215",S);let z=p.slice(),Z=p[M-1];z[M-1]=Z&-129;let q=Ae(z),W=S?l:r.ORDER;Ut("pointHex.y",q,Gt,W);let tt=u(q*q),ft=u(tt-Nt),lt=u(N*tt-O),{isValid:mt,value:yt}=d(ft,lt);if(!mt)throw new Error("Point.fromHex: invalid y coordinate");let Tt=(yt&Nt)===Nt,vt=(Z&128)!==0;if(!S&&yt===Gt&&vt)throw new Error("Point.fromHex: x=0 and x_0=1");return vt!==Tt&&(yt=u(-yt)),x.fromAffine({x:yt,y:q})}static fromPrivateKey(p){return E(p).point}toRawBytes(){let{x:p,y:S}=this.toAffine(),N=Fe(S,r.BYTES);return N[N.length-1]|=p&Nt?128:0,N}toHex(){return fe(this.toRawBytes())}}x.BASE=new x(t.Gx,t.Gy,Nt,u(t.Gx*t.Gy)),x.ZERO=new x(Gt,Nt,Nt,Gt);let{BASE:P,ZERO:D}=x,k=yn(x,a*8);function R(m){return J(m,n)}function w(m){return R(Ae(m))}function E(m){let p=r.BYTES;m=it("private key",m,p);let S=it("hashed private key",i(m),2*p),N=b(S.slice(0,p)),O=S.slice(p,2*p),M=w(N),z=P.multiply(M),Z=z.toRawBytes();return{head:N,prefix:O,scalar:M,point:z,pointBytes:Z}}function F(m){return E(m).pointBytes}function _(m=new Uint8Array,...p){let S=de(...p);return w(i(T(S,it("context",m),!!o)))}function U(m,p,S={}){m=it("message",m),o&&(m=o(m));let{prefix:N,scalar:O,pointBytes:M}=E(p),z=_(S.context,N,m),Z=P.multiply(z).toRawBytes(),q=_(S.context,Z,M,m),W=R(z+q*O);Ut("signature.s",W,Gt,n);let tt=de(Z,Fe(W,r.BYTES));return it("result",tt,r.BYTES*2)}let K=gd;function A(m,p,S,N=K){let{context:O,zip215:M}=N,z=r.BYTES;m=it("signature",m,2*z),p=it("message",p),S=it("publicKey",S,z),M!==void 0&&Ht("zip215",M),o&&(p=o(p));let Z=Ae(m.slice(z,2*z)),q,W,tt;try{q=x.fromHex(S,M),W=x.fromHex(m.slice(0,z),M),tt=P.multiplyUnsafe(Z)}catch{return!1}if(!M&&q.isSmallOrder())return!1;let ft=_(O,W.toRawBytes(),q.toRawBytes(),p);return W.add(q.multiplyUnsafe(ft)).subtract(tt).clearCofactor().equals(x.ZERO)}return P._setWindowSize(8),{CURVE:t,getPublicKey:F,sign:U,verify:A,ExtendedPoint:x,utils:{getExtendedPublicKey:E,randomPrivateKey:()=>s(r.BYTES),precompute(m=8,p=x.BASE){return p._setWindowSize(m),p.multiply(BigInt(3)),p}}}}var Wo=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),xa=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),lm=BigInt(0),xd=BigInt(1),wa=BigInt(2),dm=BigInt(3),wd=BigInt(5),bd=BigInt(8);function Ed(e){let t=BigInt(10),r=BigInt(20),n=BigInt(40),o=BigInt(80),i=Wo,a=e*e%i*e%i,c=nt(a,wa,i)*a%i,l=nt(c,xd,i)*e%i,u=nt(l,wd,i)*l%i,f=nt(u,t,i)*u%i,d=nt(f,r,i)*f%i,b=nt(d,n,i)*d%i,T=nt(b,o,i)*b%i,y=nt(T,o,i)*b%i,h=nt(y,t,i)*u%i;return{pow_p_5_8:nt(h,wa,i)*e%i,b2:a}}function Sd(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}function vd(e,t){let r=Wo,n=J(t*t*t,r),o=J(n*n*t,r),i=Ed(e*o).pow_p_5_8,s=J(e*n*i,r),a=J(t*s*s,r),c=s,l=J(s*xa,r),u=a===e,f=a===J(-e,r),d=a===J(-e*xa,r);return u&&(s=c),(f||d)&&(s=l),la(s,r)&&(s=J(-s,r)),{isValid:u||f,value:s}}var Ad=Te(Wo,void 0,!0),Id={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:Ad,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:bd,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:sa,randomBytes:fn,adjustScalarBytes:Sd,uvRatio:vd},ba=ya(Id);var bn=32;function Ea(e,t,r){return ba.verify(t,r instanceof Uint8Array?r:r.subarray(),e)}var En=class{type="Ed25519";raw;constructor(t){this.raw=Xo(t,bn)}toMultihash(){return $t.digest(Sn(this))}toCID(){return X.createV1(114,this.toMultihash())}toString(){return et.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:ot(this.raw,t.raw)}verify(t,r){return Ea(this.raw,r,t)}};function Jo(e){return e=Xo(e,bn),new En(e)}function Xo(e,t){if(e=Uint8Array.from(e??[]),e.length!==t)throw new xt(`Key must be a Uint8Array of length ${t}, got ${e.length}`);return e}function he(e=0){return new Uint8Array(e)}function Pt(e=0){return new Uint8Array(e)}var Bd=Math.pow(2,7),Cd=Math.pow(2,14),Ud=Math.pow(2,21),Qo=Math.pow(2,28),ti=Math.pow(2,35),ei=Math.pow(2,42),ri=Math.pow(2,49),Y=128,wt=127;function Rt(e){if(e<Bd)return 1;if(e<Cd)return 2;if(e<Ud)return 3;if(e<Qo)return 4;if(e<ti)return 5;if(e<ei)return 6;if(e<ri)return 7;if(Number.MAX_SAFE_INTEGER!=null&&e>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function ni(e,t,r=0){switch(Rt(e)){case 8:t[r++]=e&255|Y,e/=128;case 7:t[r++]=e&255|Y,e/=128;case 6:t[r++]=e&255|Y,e/=128;case 5:t[r++]=e&255|Y,e/=128;case 4:t[r++]=e&255|Y,e>>>=7;case 3:t[r++]=e&255|Y,e>>>=7;case 2:t[r++]=e&255|Y,e>>>=7;case 1:{t[r++]=e&255,e>>>=7;break}default:throw new Error("unreachable")}return t}function Nd(e,t,r=0){switch(Rt(e)){case 8:t.set(r++,e&255|Y),e/=128;case 7:t.set(r++,e&255|Y),e/=128;case 6:t.set(r++,e&255|Y),e/=128;case 5:t.set(r++,e&255|Y),e/=128;case 4:t.set(r++,e&255|Y),e>>>=7;case 3:t.set(r++,e&255|Y),e>>>=7;case 2:t.set(r++,e&255|Y),e>>>=7;case 1:{t.set(r++,e&255),e>>>=7;break}default:throw new Error("unreachable")}return t}function oi(e,t){let r=e[t],n=0;if(n+=r&wt,r<Y||(r=e[t+1],n+=(r&wt)<<7,r<Y)||(r=e[t+2],n+=(r&wt)<<14,r<Y)||(r=e[t+3],n+=(r&wt)<<21,r<Y)||(r=e[t+4],n+=(r&wt)*Qo,r<Y)||(r=e[t+5],n+=(r&wt)*ti,r<Y)||(r=e[t+6],n+=(r&wt)*ei,r<Y)||(r=e[t+7],n+=(r&wt)*ri,r<Y))return n;throw new RangeError("Could not decode varint")}function Pd(e,t){let r=e.get(t),n=0;if(n+=r&wt,r<Y||(r=e.get(t+1),n+=(r&wt)<<7,r<Y)||(r=e.get(t+2),n+=(r&wt)<<14,r<Y)||(r=e.get(t+3),n+=(r&wt)<<21,r<Y)||(r=e.get(t+4),n+=(r&wt)*Qo,r<Y)||(r=e.get(t+5),n+=(r&wt)*ti,r<Y)||(r=e.get(t+6),n+=(r&wt)*ei,r<Y)||(r=e.get(t+7),n+=(r&wt)*ri,r<Y))return n;throw new RangeError("Could not decode varint")}function sr(e,t,r=0){return t==null&&(t=Pt(Rt(e))),t instanceof Uint8Array?ni(e,t,r):Nd(e,t,r)}function Ve(e,t=0){return e instanceof Uint8Array?oi(e,t):Pd(e,t)}var ii=new Float32Array([-0]),Be=new Uint8Array(ii.buffer);function Aa(e,t,r){ii[0]=e,t[r]=Be[0],t[r+1]=Be[1],t[r+2]=Be[2],t[r+3]=Be[3]}function Ia(e,t){return Be[0]=e[t],Be[1]=e[t+1],Be[2]=e[t+2],Be[3]=e[t+3],ii[0]}var si=new Float64Array([-0]),bt=new Uint8Array(si.buffer);function Ta(e,t,r){si[0]=e,t[r]=bt[0],t[r+1]=bt[1],t[r+2]=bt[2],t[r+3]=bt[3],t[r+4]=bt[4],t[r+5]=bt[5],t[r+6]=bt[6],t[r+7]=bt[7]}function Ba(e,t){return bt[0]=e[t],bt[1]=e[t+1],bt[2]=e[t+2],bt[3]=e[t+3],bt[4]=e[t+4],bt[5]=e[t+5],bt[6]=e[t+6],bt[7]=e[t+7],si[0]}var Rd=BigInt(Number.MAX_SAFE_INTEGER),_d=BigInt(Number.MIN_SAFE_INTEGER),_t=class e{lo;hi;constructor(t,r){this.lo=t|0,this.hi=r|0}toNumber(t=!1){if(!t&&this.hi>>>31>0){let r=~this.lo+1>>>0,n=~this.hi>>>0;return r===0&&(n=n+1>>>0),-(r+n*4294967296)}return this.lo+this.hi*4294967296}toBigInt(t=!1){if(t)return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31){let r=~this.lo+1>>>0,n=~this.hi>>>0;return r===0&&(n=n+1>>>0),-(BigInt(r)+(BigInt(n)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toString(t=!1){return this.toBigInt(t).toString()}zzEncode(){let t=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^t)>>>0,this.lo=(this.lo<<1^t)>>>0,this}zzDecode(){let t=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^t)>>>0,this.hi=(this.hi>>>1^t)>>>0,this}length(){let t=this.lo,r=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return n===0?r===0?t<16384?t<128?1:2:t<2097152?3:4:r<16384?r<128?5:6:r<2097152?7:8:n<128?9:10}static fromBigInt(t){if(t===0n)return Ke;if(t<Rd&&t>_d)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>Ca&&(o=0n,++n>Ca&&(n=0n))),new e(Number(o),Number(n))}static fromNumber(t){if(t===0)return Ke;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):Ke}},Ke=new _t(0,0);Ke.toBigInt=function(){return 0n};Ke.zzEncode=Ke.zzDecode=function(){return this};Ke.length=function(){return 1};var Ca=4294967296n;function Ua(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 Na(e,t,r){if(r-t<1)return"";let o,i=[],s=0,a;for(;t<r;)a=e[t++],a<128?i[s++]=a:a>191&&a<224?i[s++]=(a&31)<<6|e[t++]&63:a>239&&a<365?(a=((a&7)<<18|(e[t++]&63)<<12|(e[t++]&63)<<6|e[t++]&63)-65536,i[s++]=55296+(a>>10),i[s++]=56320+(a&1023)):i[s++]=(a&15)<<12|(e[t++]&63)<<6|e[t++]&63,s>8191&&((o??(o=[])).push(String.fromCharCode.apply(String,i)),s=0);return o!=null?(s>0&&o.push(String.fromCharCode.apply(String,i.slice(0,s))),o.join("")):String.fromCharCode.apply(String,i.slice(0,s))}function ai(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 Zt(e,t){return RangeError(`index out of range: ${e.pos} + ${t??1} > ${e.len}`)}function vn(e,t){return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0}var ci=class{buf;pos;len;_slice=Uint8Array.prototype.subarray;constructor(t){this.buf=t,this.pos=0,this.len=t.length}uint32(){let t=4294967295;if(t=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(t=(t|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return t;if((this.pos+=5)>this.len)throw this.pos=this.len,Zt(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 Zt(this,4);return vn(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw Zt(this,4);return vn(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw Zt(this,4);let t=Ia(this.buf,this.pos);return this.pos+=4,t}double(){if(this.pos+8>this.len)throw Zt(this,4);let t=Ba(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 Zt(this,t);return this.pos+=t,r===n?new Uint8Array(0):this.buf.subarray(r,n)}string(){let t=this.bytes();return Na(t,0,t.length)}skip(t){if(typeof t=="number"){if(this.pos+t>this.len)throw Zt(this,t);this.pos+=t}else do if(this.pos>=this.len)throw Zt(this);while((this.buf[this.pos++]&128)!==0);return this}skipType(t){switch(t){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(t=this.uint32()&7)!==4;)this.skipType(t);break;case 5:this.skip(4);break;default:throw Error(`invalid wire type ${t} at offset ${this.pos}`)}return this}readLongVarint(){let t=new _t(0,0),r=0;if(this.len-this.pos>4){for(;r<4;++r)if(t.lo=(t.lo|(this.buf[this.pos]&127)<<r*7)>>>0,this.buf[this.pos++]<128)return t;if(t.lo=(t.lo|(this.buf[this.pos]&127)<<28)>>>0,t.hi=(t.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return t;r=0}else{for(;r<3;++r){if(this.pos>=this.len)throw Zt(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 Zt(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 Zt(this,8);let t=vn(this.buf,this.pos+=4),r=vn(this.buf,this.pos+=4);return new _t(t,r)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){let t=oi(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 ui(e){return new ci(e instanceof Uint8Array?e:e.subarray())}function ar(e,t,r){let n=ui(e);return t.decode(n,void 0,r)}var fi={};At(fi,{base10:()=>Ld});var Ld=xe({prefix:"9",name:"base10",alphabet:"0123456789"});var li={};At(li,{base16:()=>kd,base16upper:()=>Dd});var kd=st({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Dd=st({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var di={};At(di,{base2:()=>Fd});var Fd=st({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var hi={};At(hi,{base256emoji:()=>qd});var Ra=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}"),Od=Ra.reduce((e,t,r)=>(e[r]=t,e),[]),Md=Ra.reduce((e,t,r)=>{let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);return e[n]=r,e},[]);function Vd(e){return e.reduce((t,r)=>(t+=Od[r],t),"")}function Kd(e){let t=[];for(let r of e){let n=r.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${r}`);let o=Md[n];if(o==null)throw new Error(`Non-base256emoji character: ${r}`);t.push(o)}return new Uint8Array(t)}var qd=We({prefix:"\u{1F680}",name:"base256emoji",encode:Vd,decode:Kd});var pi={};At(pi,{base8:()=>$d});var $d=st({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var mi={};At(mi,{identity:()=>zd});var zd=We({prefix:"\0",name:"identity",encode:e=>Os(e),decode:e=>Fs(e)});var Zm=new TextEncoder,jm=new TextDecoder;var xi={};At(xi,{sha256:()=>Rr,sha512:()=>Zd});function yi({name:e,code:t,encode:r}){return new gi(e,t,r)}var gi=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?qt(this.code,r):r.then(n=>qt(this.code,n))}else throw Error("Unknown type, must be binary type")}};function La(e){return async t=>new Uint8Array(await crypto.subtle.digest(e,t))}var Rr=yi({name:"sha2-256",code:18,encode:La("SHA-256")}),Zd=yi({name:"sha2-512",code:19,encode:La("SHA-512")});var _r={...mi,...di,...pi,...fi,...li,...Io,...No,...To,...Co,...hi},sg={...xi,..._o};function Da(e,t,r,n){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:n}}}var ka=Da("utf8","u",e=>"u"+new TextDecoder("utf8").decode(e),e=>new TextEncoder().encode(e.substring(1))),wi=Da("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=Pt(e.length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t}),jd={utf8:ka,"utf-8":ka,hex:_r.base16,latin1:wi,ascii:wi,binary:wi,..._r},An=jd;function H(e,t="utf8"){let r=An[t];if(r==null)throw new Error(`Unsupported encoding "${t}"`);return r.decoder.decode(`${r.prefix}${e}`)}function bi(e){let t=e??8192,r=t>>>1,n,o=t;return function(s){if(s<1||s>r)return Pt(s);o+s>t&&(n=Pt(t),o=0);let a=n.subarray(o,o+=s);return(o&7)!==0&&(o=(o|7)+1),a}}var qe=class{fn;len;next;val;constructor(t,r,n){this.fn=t,this.len=r,this.next=void 0,this.val=n}};function Ei(){}var vi=class{head;tail;len;next;constructor(t){this.head=t.head,this.tail=t.tail,this.len=t.len,this.next=t.states}},Yd=bi();function Wd(e){return globalThis.Buffer!=null?Pt(e):Yd(e)}var kr=class{len;head;tail;states;constructor(){this.len=0,this.head=new qe(Ei,0,0),this.tail=this.head,this.states=null}_push(t,r,n){return this.tail=this.tail.next=new qe(t,r,n),this.len+=r,this}uint32(t){return this.len+=(this.tail=this.tail.next=new Ai((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(In,10,_t.fromNumber(t)):this.uint32(t)}sint32(t){return this.uint32((t<<1^t>>31)>>>0)}uint64(t){let r=_t.fromBigInt(t);return this._push(In,r.length(),r)}uint64Number(t){return this._push(ni,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=_t.fromBigInt(t).zzEncode();return this._push(In,r.length(),r)}sint64Number(t){let r=_t.fromNumber(t).zzEncode();return this._push(In,r.length(),r)}sint64String(t){return this.sint64(BigInt(t))}bool(t){return this._push(Si,1,t?1:0)}fixed32(t){return this._push(Lr,4,t>>>0)}sfixed32(t){return this.fixed32(t)}fixed64(t){let r=_t.fromBigInt(t);return this._push(Lr,4,r.lo)._push(Lr,4,r.hi)}fixed64Number(t){let r=_t.fromNumber(t);return this._push(Lr,4,r.lo)._push(Lr,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(Aa,4,t)}double(t){return this._push(Ta,8,t)}bytes(t){let r=t.length>>>0;return r===0?this._push(Si,1,0):this.uint32(r)._push(Jd,r,t)}string(t){let r=Ua(t);return r!==0?this.uint32(r)._push(ai,r,t):this._push(Si,1,0)}fork(){return this.states=new vi(this),this.head=this.tail=new qe(Ei,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 qe(Ei,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=Wd(this.len),n=0;for(;t!=null;)t.fn(t.val,r,n),n+=t.len,t=t.next;return r}};function Si(e,t,r){t[r]=e&255}function Xd(e,t,r){for(;e>127;)t[r++]=e&127|128,e>>>=7;t[r]=e}var Ai=class extends qe{next;constructor(t,r){super(Xd,t,r),this.next=void 0}};function In(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 Lr(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 Jd(e,t,r){t.set(e,r)}globalThis.Buffer!=null&&(kr.prototype.bytes=function(e){let t=e.length>>>0;return this.uint32(t),t>0&&this._push(Qd,t,e),this},kr.prototype.string=function(e){let t=globalThis.Buffer.byteLength(e);return this.uint32(t),t>0&&this._push(th,t,e),this});function Qd(e,t,r){t.set(e,r)}function th(e,t,r){e.length<40?ai(e,t,r):t.utf8Write!=null?t.utf8Write(e,r):t.set(H(e),r)}function Ii(){return new kr}function cr(e,t){let r=Ii();return t.encode(e,r,{lengthDelimited:!1}),r.finish()}var ur;(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"})(ur||(ur={}));function Tn(e,t,r,n){return{name:e,type:t,encode:r,decode:n}}function Dr(e){function t(o){if(e[o.toString()]==null)throw new Error("Invalid enum value");return e[o]}let r=function(i,s){let a=t(i);s.int32(a)},n=function(i){let s=i.int32();return t(s)};return Tn("enum",ur.VARINT,r,n)}function fr(e,t){return Tn("message",ur.LENGTH_DELIMITED,e,t)}var ut;(function(e){e.RSA="RSA",e.Ed25519="Ed25519",e.secp256k1="secp256k1"})(ut||(ut={}));var Ti;(function(e){e[e.RSA=0]="RSA",e[e.Ed25519=1]="Ed25519",e[e.secp256k1=2]="secp256k1"})(Ti||(Ti={}));(function(e){e.codec=()=>Dr(Ti)})(ut||(ut={}));var ne;(function(e){let t;e.codec=()=>(t==null&&(t=fr((r,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),r.Type!=null&&(n.uint32(8),ut.codec().encode(r.Type,n)),r.Data!=null&&(n.uint32(18),n.bytes(r.Data)),o.lengthDelimited!==!1&&n.ldelim()},(r,n,o={})=>{let i={},s=n==null?r.len:r.pos+n;for(;r.pos<s;){let a=r.uint32();switch(a>>>3){case 1:{i.Type=ut.codec().decode(r);break}case 2:{i.Data=r.bytes();break}default:{r.skipType(a&7);break}}}return i})),t),e.encode=r=>cr(r,e.codec()),e.decode=(r,n)=>ar(r,e.codec(),n)})(ne||(ne={}));var Bi;(function(e){let t;e.codec=()=>(t==null&&(t=fr((r,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),r.Type!=null&&(n.uint32(8),ut.codec().encode(r.Type,n)),r.Data!=null&&(n.uint32(18),n.bytes(r.Data)),o.lengthDelimited!==!1&&n.ldelim()},(r,n,o={})=>{let i={},s=n==null?r.len:r.pos+n;for(;r.pos<s;){let a=r.uint32();switch(a>>>3){case 1:{i.Type=ut.codec().decode(r);break}case 2:{i.Data=r.bytes();break}default:{r.skipType(a&7);break}}}return i})),t),e.encode=r=>cr(r,e.codec()),e.decode=(r,n)=>ar(r,e.codec(),n)})(Bi||(Bi={}));var Mr={};At(Mr,{MAX_RSA_KEY_SIZE:()=>Ri,generateRSAKeyPair:()=>Xa,jwkToJWKKeyPair:()=>Ja,jwkToPkcs1:()=>dh,jwkToPkix:()=>Li,jwkToRSAPrivateKey:()=>Wa,pkcs1ToJwk:()=>Za,pkcs1ToRSAPrivateKey:()=>Ya,pkixToJwk:()=>ja,pkixToRSAPublicKey:()=>ki});var eh=new Uint32Array([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]),Ce=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Ue=new Uint32Array(64),Ci=class extends or{constructor(){super(64,32,8,!1),this.A=Ce[0]|0,this.B=Ce[1]|0,this.C=Ce[2]|0,this.D=Ce[3]|0,this.E=Ce[4]|0,this.F=Ce[5]|0,this.G=Ce[6]|0,this.H=Ce[7]|0}get(){let{A:t,B:r,C:n,D:o,E:i,F:s,G:a,H:c}=this;return[t,r,n,o,i,s,a,c]}set(t,r,n,o,i,s,a,c){this.A=t|0,this.B=r|0,this.C=n|0,this.D=o|0,this.E=i|0,this.F=s|0,this.G=a|0,this.H=c|0}process(t,r){for(let f=0;f<16;f++,r+=4)Ue[f]=t.getUint32(r,!1);for(let f=16;f<64;f++){let d=Ue[f-15],b=Ue[f-2],T=zt(d,7)^zt(d,18)^d>>>3,y=zt(b,17)^zt(b,19)^b>>>10;Ue[f]=y+Ue[f-7]+T+Ue[f-16]|0}let{A:n,B:o,C:i,D:s,E:a,F:c,G:l,H:u}=this;for(let f=0;f<64;f++){let d=zt(a,6)^zt(a,11)^zt(a,25),b=u+d+na(a,c,l)+eh[f]+Ue[f]|0,y=(zt(n,2)^zt(n,13)^zt(n,22))+oa(n,o,i)|0;u=l,l=c,c=a,a=s+b|0,s=i,i=o,o=n,n=b+y|0}n=n+this.A|0,o=o+this.B|0,i=i+this.C|0,s=s+this.D|0,a=a+this.E|0,c=c+this.F|0,l=l+this.G|0,u=u+this.H|0,this.set(n,o,i,s,a,c,l,u)}roundClean(){Ue.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var lr=un(()=>new Ci);function G(e,t="utf8"){let r=An[t];if(r==null)throw new Error(`Unsupported encoding "${t}"`);return r.encoder.encode(e).substring(1)}function Et(e,t){t==null&&(t=e.reduce((o,i)=>o+i.length,0));let r=Pt(t),n=0;for(let o of e)r.set(o,n),n+=o.length;return r}var Ma=Symbol.for("@achingbrain/uint8arraylist");function Oa(e,t){if(t==null||t<0)throw new RangeError("index is out of bounds");let r=0;for(let n of e){let o=r+n.byteLength;if(t<o)return{buf:n,index:t-r};r=o}throw new RangeError("index is out of bounds")}function dr(e){return!!e?.[Ma]}var jt=class e{bufs;length;[Ma]=!0;constructor(...t){this.bufs=[],this.length=0,t.length>0&&this.appendAll(t)}*[Symbol.iterator](){yield*this.bufs}get byteLength(){return this.length}append(...t){this.appendAll(t)}appendAll(t){let r=0;for(let n of t)if(n instanceof Uint8Array)r+=n.byteLength,this.bufs.push(n);else if(dr(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(dr(n))r+=n.byteLength,this.bufs.unshift(...n.bufs);else throw new Error("Could not prepend value, must be an Uint8Array or a Uint8ArrayList");this.length+=r}get(t){let r=Oa(this.bufs,t);return r.buf[r.index]}set(t,r){let n=Oa(this.bufs,t);n.buf[n.index]=r}write(t,r=0){if(t instanceof Uint8Array)for(let n=0;n<t.length;n++)this.set(r+n,t[n]);else if(dr(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 Et(n,o)}subarray(t,r){let{bufs:n,length:o}=this._subList(t,r);return n.length===1?n[0]:Et(n,o)}sublist(t,r){let{bufs:n,length:o}=this._subList(t,r),i=new e;return i.length=o,i.bufs=[...n],i}_subList(t,r){if(t=t??0,r=r??this.length,t<0&&(t=this.length+t),r<0&&(r=this.length+r),t<0||r>this.length)throw new RangeError("index is out of bounds");if(t===r)return{bufs:[],length:0};if(t===0&&r===this.length)return{bufs:this.bufs,length:this.length};let n=[],o=0;for(let i=0;i<this.bufs.length;i++){let s=this.bufs[i],a=o,c=a+s.byteLength;if(o=c,t>=c)continue;let l=t>=a&&t<c,u=r>a&&r<=c;if(l&&u){if(t===a&&r===c){n.push(s);break}let f=t-a;n.push(s.subarray(f,f+(r-t)));break}if(l){if(t===0){n.push(s);continue}n.push(s.subarray(t-a));continue}if(u){if(r===c){n.push(s);break}n.push(s.subarray(0,r-a));break}n.push(s)}return{bufs:n,length:r-t}}indexOf(t,r=0){if(!dr(t)&&!(t instanceof Uint8Array))throw new TypeError('The "value" argument must be a Uint8ArrayList or Uint8Array');let n=t instanceof Uint8Array?t:t.subarray();if(r=Number(r??0),isNaN(r)&&(r=0),r<0&&(r=this.length+r),r<0&&(r=0),t.length===0)return r>this.length?this.length:r;let o=n.byteLength;if(o===0)throw new TypeError("search must be at least 1 byte long");let i=256,s=new Int32Array(i);for(let f=0;f<i;f++)s[f]=-1;for(let f=0;f<o;f++)s[n[f]]=f;let a=s,c=this.byteLength-n.byteLength,l=n.byteLength-1,u;for(let f=r;f<=c;f+=u){u=0;for(let d=l;d>=0;d--){let b=this.get(f+d);if(n[d]!==b){u=Math.max(1,d-a[b]);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=Pt(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=he(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=he(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=he(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=Pt(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=he(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=he(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=he(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=he(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=he(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(!ot(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 rh=parseInt("11111",2),Ni=parseInt("10000000",2),nh=parseInt("01111111",2),Va={2:oh,3:ah,5:sh,6:ih,16:Ui,22:Ui,48:Ui};function Fr(e,t={offset:0}){let r=e[t.offset]&rh;if(t.offset++,Va[r]!=null)return Va[r](e,t);throw new Error("No decoder for tag "+r)}function Bn(e,t){let r=0;if((e[t.offset]&Ni)===Ni){let n=e[t.offset]&nh,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 Ui(e,t){Bn(e,t);let r=[];for(;!(t.offset>=e.byteLength);){let n=Fr(e,t);if(n===null)break;r.push(n)}return r}function oh(e,t){let r=Bn(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 ih(e,t){let r=Bn(e,t);return t.offset+=r,["oid-unimplemented"]}function sh(e,t){return t.offset++,null}function ah(e,t){let r=Bn(e,t),n=e[t.offset];t.offset++;let o=e.subarray(t.offset,t.offset+r);if(t.offset+=r,n!==0)throw new Error("Unused bits in bit string is unimplemented");return Fr(o,{offset:0})}function ch(e){let t=e.toString(16);t.length%2===1&&(t="0"+t);let r=new jt;for(let n=0;n<t.length;n+=2)r.append(Uint8Array.from([parseInt(`${t[n]}${t[n+1]}`,16)]));return r}function Pi(e){if(e.byteLength<128)return Uint8Array.from([e.byteLength]);let t=ch(e.byteLength);return new jt(Uint8Array.from([t.byteLength|Ni]),t)}function Ot(e){let t=new jt,r=parseInt("10000000",2);return(e.subarray()[0]&r)===r&&t.append(Uint8Array.from([0])),t.append(e),new jt(Uint8Array.from([2]),Pi(t),t)}function Ka(e){let t=Uint8Array.from([0]),r=new jt(t,e);return new jt(Uint8Array.from([3]),Pi(r),r)}function Cn(e){let t=new jt;for(let r of e)t.append(r);return new jt(Uint8Array.from([48]),Pi(t),t)}var Or=class extends Error{constructor(t="An error occurred while verifying a message"){super(t),this.name="VerificationError"}},Un=class extends Error{constructor(t="Missing Web Crypto API"){super(t),this.name="WebCryptoMissingError"}};var qa={get(e=globalThis){let t=e.crypto;if(t?.subtle==null)throw new Un("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=qa;async function $a(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 uh(t);return{privateKey:r[0],publicKey:r[1]}}async function za(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 Ha(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 uh(e){if(e.privateKey==null||e.publicKey==null)throw new xt("Private and public key are required");return Promise.all([Ne.get().subtle.exportKey("jwk",e.privateKey),Ne.get().subtle.exportKey("jwk",e.publicKey)])}function Ga(e){if(e.kty!=="RSA")throw new xt("invalid key type");if(e.n==null)throw new xt("invalid key modulus");return H(e.n,"base64url").length*8}var hr=class{type="RSA";_key;_raw;_multihash;constructor(t,r){this._key=t,this._multihash=r}get raw(){return this._raw==null&&(this._raw=Mr.jwkToPkix(this._key)),this._raw}toMultihash(){return this._multihash}toCID(){return X.createV1(114,this._multihash)}toString(){return et.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:ot(this.raw,t.raw)}verify(t,r){return Ha(this._key,r,t)}},Vr=class{type="RSA";_key;_raw;publicKey;constructor(t,r){this._key=t,this.publicKey=r}get raw(){return this._raw==null&&(this._raw=Mr.jwkToPkcs1(this._key)),this._raw}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:ot(this.raw,t.raw)}sign(t){return za(this._key,t)}};var Ri=8192,_i=18,fh=1062,lh=Uint8Array.from([48,13,6,9,42,134,72,134,247,13,1,1,1,5,0]);function Za(e){let t=Fr(e);return{n:G(t[1],"base64url"),e:G(t[2],"base64url"),d:G(t[3],"base64url"),p:G(t[4],"base64url"),q:G(t[5],"base64url"),dp:G(t[6],"base64url"),dq:G(t[7],"base64url"),qi:G(t[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 xt("JWK was missing components");return Cn([Ot(Uint8Array.from([0])),Ot(H(e.n,"base64url")),Ot(H(e.e,"base64url")),Ot(H(e.d,"base64url")),Ot(H(e.p,"base64url")),Ot(H(e.q,"base64url")),Ot(H(e.dp,"base64url")),Ot(H(e.dq,"base64url")),Ot(H(e.qi,"base64url"))]).subarray()}function ja(e){let t=Fr(e,{offset:0});return{kty:"RSA",n:G(t[1][0],"base64url"),e:G(t[1][1],"base64url")}}function Li(e){if(e.n==null||e.e==null)throw new xt("JWK was missing components");return Cn([lh,Ka(Cn([Ot(H(e.n,"base64url")),Ot(H(e.e,"base64url"))]))]).subarray()}function Ya(e){let t=Za(e);return Wa(t)}function ki(e,t){if(e.byteLength>=fh)throw new Ze("Key size is too large");let r=ja(e);if(t==null){let n=lr(ne.encode({Type:ut.RSA,Data:e}));t=qt(_i,n)}return new hr(r,t)}function Wa(e){if(Ga(e)>Ri)throw new xt("Key size is too large");let t=Ja(e),r=lr(ne.encode({Type:ut.RSA,Data:Li(t.publicKey)})),n=qt(_i,r);return new Vr(t.privateKey,new hr(t.publicKey,n))}async function Xa(e){if(e>Ri)throw new xt("Key size is too large");let t=await $a(e),r=lr(ne.encode({Type:ut.RSA,Data:Li(t.publicKey)})),n=qt(_i,r);return new Vr(t.privateKey,new hr(t.publicKey,n))}function Ja(e){if(e==null)throw new xt("Missing key parameter");return{privateKey:e,publicKey:{kty:e.kty,n:e.n,e:e.e}}}var Nn=class extends nr{constructor(t,r){super(),this.finished=!1,this.destroyed=!1,ta(t);let n=Cr(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),i.fill(0)}update(t){return rr(this),this.iHash.update(t),this}digestInto(t){rr(this),er(t,this.outputLen),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){let t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));let{oHash:r,iHash:n,finished:o,destroyed:i,blockLen:s,outputLen:a}=this;return t=t,t.finished=o,t.destroyed=i,t.blockLen=s,t.outputLen=a,t.oHash=r._cloneInto(t.oHash),t.iHash=n._cloneInto(t.iHash),t}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},Di=(e,t,r)=>new Nn(e,t).update(r).digest();Di.create=(e,t)=>new Nn(e,t);function Qa(e){e.lowS!==void 0&&Ht("lowS",e.lowS),e.prehash!==void 0&&Ht("prehash",e.prehash)}function hh(e){let t=Pr(e);re(t,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});let{endo:r,Fp:n,a:o}=t;if(r){if(!n.eql(o,n.ZERO))throw new Error("invalid endomorphism, can only be defined for Koblitz curves that have a=0");if(typeof r!="object"||typeof r.beta!="bigint"||typeof r.splitScalar!="function")throw new Error("invalid endomorphism, expected beta: bigint and splitScalar: function")}return Object.freeze({...t})}var{bytesToNumberBE:ph,hexToBytes:mh}=pn,Fi=class extends Error{constructor(t=""){super(t)}},pe={Err:Fi,_tlv:{encode:(e,t)=>{let{Err:r}=pe;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=ke(n);if(o.length/2&128)throw new r("tlv.encode: long form length too big");let i=n>127?ke(o.length/2|128):"";return ke(e)+i+o+t},decode(e,t){let{Err:r}=pe,n=0;if(e<0||e>256)throw new r("tlv.encode: wrong tag");if(t.length<2||t[n++]!==e)throw new r("tlv.decode: wrong tlv");let o=t[n++],i=!!(o&128),s=0;if(!i)s=o;else{let c=o&127;if(!c)throw new r("tlv.decode(long): indefinite length not supported");if(c>4)throw new r("tlv.decode(long): byte length is too big");let l=t.subarray(n,n+c);if(l.length!==c)throw new r("tlv.decode: length bytes not complete");if(l[0]===0)throw new r("tlv.decode(long): zero leftmost byte");for(let u of l)s=s<<8|u;if(n+=c,s<128)throw new r("tlv.decode(long): not minimal encoding")}let a=t.subarray(n,n+s);if(a.length!==s)throw new r("tlv.decode: wrong value length");return{v:a,l:t.subarray(n+s)}}},_int:{encode(e){let{Err:t}=pe;if(e<me)throw new t("integer: negative integers are not allowed");let r=ke(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}=pe;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 ph(e)}},toSig(e){let{Err:t,_int:r,_tlv:n}=pe,o=typeof e=="string"?mh(e):e;ir(o);let{v:i,l:s}=n.decode(48,o);if(s.length)throw new t("invalid signature: left bytes after parsing");let{v:a,l:c}=n.decode(2,i),{v:l,l:u}=n.decode(2,c);if(u.length)throw new t("invalid signature: left bytes after parsing");return{r:r.decode(a),s:r.decode(l)}},hexFromSig(e){let{_tlv:t,_int:r}=pe,n=t.encode(2,r.encode(e.r)),o=t.encode(2,r.encode(e.s)),i=n+o;return t.encode(48,i)}},me=BigInt(0),dt=BigInt(1),Cy=BigInt(2),tc=BigInt(3),Uy=BigInt(4);function gh(e){let t=hh(e),{Fp:r}=t,n=Te(t.n,t.nBitLength),o=t.toBytes||((y,h,v)=>{let C=h.toAffine();return de(Uint8Array.from([4]),r.toBytes(C.x),r.toBytes(C.y))}),i=t.fromBytes||(y=>{let h=y.subarray(1),v=r.fromBytes(h.subarray(0,r.BYTES)),C=r.fromBytes(h.subarray(r.BYTES,2*r.BYTES));return{x:v,y:C}});function s(y){let{a:h,b:v}=t,C=r.sqr(y),x=r.mul(C,y);return r.add(r.add(x,r.mul(y,h)),v)}if(!r.eql(r.sqr(t.Gy),s(t.Gx)))throw new Error("bad generator point: equation left != right");function a(y){return Ur(y,dt,t.n)}function c(y){let{allowedPrivateKeyLengths:h,nByteLength:v,wrapPrivateKey:C,n:x}=t;if(h&&typeof y!="bigint"){if(ve(y)&&(y=fe(y)),typeof y!="string"||!h.includes(y.length))throw new Error("invalid private key");y=y.padStart(v*2,"0")}let P;try{P=typeof y=="bigint"?y:le(it("private key",y,v))}catch{throw new Error("invalid private key, expected hex or "+v+" bytes, got "+typeof y)}return C&&(P=J(P,x)),Ut("private key",P,dt,x),P}function l(y){if(!(y instanceof d))throw new Error("ProjectivePoint expected")}let u=Oe((y,h)=>{let{px:v,py:C,pz:x}=y;if(r.eql(x,r.ONE))return{x:v,y:C};let P=y.is0();h==null&&(h=P?r.ONE:r.inv(x));let D=r.mul(v,h),k=r.mul(C,h),R=r.mul(x,h);if(P)return{x:r.ZERO,y:r.ZERO};if(!r.eql(R,r.ONE))throw new Error("invZ was invalid");return{x:D,y:k}}),f=Oe(y=>{if(y.is0()){if(t.allowInfinityPoint&&!r.is0(y.py))return;throw new Error("bad point: ZERO")}let{x:h,y:v}=y.toAffine();if(!r.isValid(h)||!r.isValid(v))throw new Error("bad point: x or y not FE");let C=r.sqr(v),x=s(h);if(!r.eql(C,x))throw new Error("bad point: equation left != right");if(!y.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class d{constructor(h,v,C){if(this.px=h,this.py=v,this.pz=C,h==null||!r.isValid(h))throw new Error("x required");if(v==null||!r.isValid(v))throw new Error("y required");if(C==null||!r.isValid(C))throw new Error("z required");Object.freeze(this)}static fromAffine(h){let{x:v,y:C}=h||{};if(!h||!r.isValid(v)||!r.isValid(C))throw new Error("invalid affine point");if(h instanceof d)throw new Error("projective point not allowed");let x=P=>r.eql(P,r.ZERO);return x(v)&&x(C)?d.ZERO:new d(v,C,r.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(h){let v=r.invertBatch(h.map(C=>C.pz));return h.map((C,x)=>C.toAffine(v[x])).map(d.fromAffine)}static fromHex(h){let v=d.fromAffine(i(it("pointHex",h)));return v.assertValidity(),v}static fromPrivateKey(h){return d.BASE.multiply(c(h))}static msm(h,v){return xn(d,n,h,v)}_setWindowSize(h){T.setWindowSize(this,h)}assertValidity(){f(this)}hasEvenY(){let{y:h}=this.toAffine();if(r.isOdd)return!r.isOdd(h);throw new Error("Field doesn't support isOdd")}equals(h){l(h);let{px:v,py:C,pz:x}=this,{px:P,py:D,pz:k}=h,R=r.eql(r.mul(v,k),r.mul(P,x)),w=r.eql(r.mul(C,k),r.mul(D,x));return R&&w}negate(){return new d(this.px,r.neg(this.py),this.pz)}double(){let{a:h,b:v}=t,C=r.mul(v,tc),{px:x,py:P,pz:D}=this,k=r.ZERO,R=r.ZERO,w=r.ZERO,E=r.mul(x,x),F=r.mul(P,P),_=r.mul(D,D),U=r.mul(x,P);return U=r.add(U,U),w=r.mul(x,D),w=r.add(w,w),k=r.mul(h,w),R=r.mul(C,_),R=r.add(k,R),k=r.sub(F,R),R=r.add(F,R),R=r.mul(k,R),k=r.mul(U,k),w=r.mul(C,w),_=r.mul(h,_),U=r.sub(E,_),U=r.mul(h,U),U=r.add(U,w),w=r.add(E,E),E=r.add(w,E),E=r.add(E,_),E=r.mul(E,U),R=r.add(R,E),_=r.mul(P,D),_=r.add(_,_),E=r.mul(_,U),k=r.sub(k,E),w=r.mul(_,F),w=r.add(w,w),w=r.add(w,w),new d(k,R,w)}add(h){l(h);let{px:v,py:C,pz:x}=this,{px:P,py:D,pz:k}=h,R=r.ZERO,w=r.ZERO,E=r.ZERO,F=t.a,_=r.mul(t.b,tc),U=r.mul(v,P),K=r.mul(C,D),A=r.mul(x,k),I=r.add(v,C),m=r.add(P,D);I=r.mul(I,m),m=r.add(U,K),I=r.sub(I,m),m=r.add(v,x);let p=r.add(P,k);return m=r.mul(m,p),p=r.add(U,A),m=r.sub(m,p),p=r.add(C,x),R=r.add(D,k),p=r.mul(p,R),R=r.add(K,A),p=r.sub(p,R),E=r.mul(F,m),R=r.mul(_,A),E=r.add(R,E),R=r.sub(K,E),E=r.add(K,E),w=r.mul(R,E),K=r.add(U,U),K=r.add(K,U),A=r.mul(F,A),m=r.mul(_,m),K=r.add(K,A),A=r.sub(U,A),A=r.mul(F,A),m=r.add(m,A),U=r.mul(K,m),w=r.add(w,U),U=r.mul(p,m),R=r.mul(I,R),R=r.sub(R,U),U=r.mul(I,K),E=r.mul(p,E),E=r.add(E,U),new d(R,w,E)}subtract(h){return this.add(h.negate())}is0(){return this.equals(d.ZERO)}wNAF(h){return T.wNAFCached(this,h,d.normalizeZ)}multiplyUnsafe(h){let{endo:v,n:C}=t;Ut("scalar",h,me,C);let x=d.ZERO;if(h===me)return x;if(this.is0()||h===dt)return this;if(!v||T.hasPrecomputes(this))return T.wNAFCachedUnsafe(this,h,d.normalizeZ);let{k1neg:P,k1:D,k2neg:k,k2:R}=v.splitScalar(h),w=x,E=x,F=this;for(;D>me||R>me;)D&dt&&(w=w.add(F)),R&dt&&(E=E.add(F)),F=F.double(),D>>=dt,R>>=dt;return P&&(w=w.negate()),k&&(E=E.negate()),E=new d(r.mul(E.px,v.beta),E.py,E.pz),w.add(E)}multiply(h){let{endo:v,n:C}=t;Ut("scalar",h,dt,C);let x,P;if(v){let{k1neg:D,k1:k,k2neg:R,k2:w}=v.splitScalar(h),{p:E,f:F}=this.wNAF(k),{p:_,f:U}=this.wNAF(w);E=T.constTimeNegate(D,E),_=T.constTimeNegate(R,_),_=new d(r.mul(_.px,v.beta),_.py,_.pz),x=E.add(_),P=F.add(U)}else{let{p:D,f:k}=this.wNAF(h);x=D,P=k}return d.normalizeZ([x,P])[0]}multiplyAndAddUnsafe(h,v,C){let x=d.BASE,P=(k,R)=>R===me||R===dt||!k.equals(x)?k.multiplyUnsafe(R):k.multiply(R),D=P(this,v).add(P(h,C));return D.is0()?void 0:D}toAffine(h){return u(this,h)}isTorsionFree(){let{h,isTorsionFree:v}=t;if(h===dt)return!0;if(v)return v(d,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h,clearCofactor:v}=t;return h===dt?this:v?v(d,this):this.multiplyUnsafe(t.h)}toRawBytes(h=!0){return Ht("isCompressed",h),this.assertValidity(),o(d,this,h)}toHex(h=!0){return Ht("isCompressed",h),fe(this.toRawBytes(h))}}d.BASE=new d(t.Gx,t.Gy,r.ONE),d.ZERO=new d(r.ZERO,r.ONE,r.ZERO);let b=t.nBitLength,T=yn(d,t.endo?Math.ceil(b/2):b);return{CURVE:t,ProjectivePoint:d,normPrivateKeyToScalar:c,weierstrassEquation:s,isWithinCurveOrder:a}}function yh(e){let t=Pr(e);return re(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}function ec(e){let t=yh(e),{Fp:r,n}=t,o=r.BYTES+1,i=2*r.BYTES+1;function s(A){return J(A,n)}function a(A){return mn(A,n)}let{ProjectivePoint:c,normPrivateKeyToScalar:l,weierstrassEquation:u,isWithinCurveOrder:f}=gh({...t,toBytes(A,I,m){let p=I.toAffine(),S=r.toBytes(p.x),N=de;return Ht("isCompressed",m),m?N(Uint8Array.from([I.hasEvenY()?2:3]),S):N(Uint8Array.from([4]),S,r.toBytes(p.y))},fromBytes(A){let I=A.length,m=A[0],p=A.subarray(1);if(I===o&&(m===2||m===3)){let S=le(p);if(!Ur(S,dt,r.ORDER))throw new Error("Point is not on curve");let N=u(S),O;try{O=r.sqrt(N)}catch(Z){let q=Z instanceof Error?": "+Z.message:"";throw new Error("Point is not on curve"+q)}let M=(O&dt)===dt;return(m&1)===1!==M&&(O=r.neg(O)),{x:S,y:O}}else if(I===i&&m===4){let S=r.fromBytes(p.subarray(0,r.BYTES)),N=r.fromBytes(p.subarray(r.BYTES,2*r.BYTES));return{x:S,y:N}}else{let S=o,N=i;throw new Error("invalid Point, expected length of "+S+", or uncompressed "+N+", got "+I)}}}),d=A=>fe(Ie(A,t.nByteLength));function b(A){let I=n>>dt;return A>I}function T(A){return b(A)?s(-A):A}let y=(A,I,m)=>le(A.slice(I,m));class h{constructor(I,m,p){this.r=I,this.s=m,this.recovery=p,this.assertValidity()}static fromCompact(I){let m=t.nByteLength;return I=it("compactSignature",I,m*2),new h(y(I,0,m),y(I,m,2*m))}static fromDER(I){let{r:m,s:p}=pe.toSig(it("DER",I));return new h(m,p)}assertValidity(){Ut("r",this.r,dt,n),Ut("s",this.s,dt,n)}addRecoveryBit(I){return new h(this.r,this.s,I)}recoverPublicKey(I){let{r:m,s:p,recovery:S}=this,N=k(it("msgHash",I));if(S==null||![0,1,2,3].includes(S))throw new Error("recovery id invalid");let O=S===2||S===3?m+t.n:m;if(O>=r.ORDER)throw new Error("recovery id 2 or 3 invalid");let M=(S&1)===0?"02":"03",z=c.fromHex(M+d(O)),Z=a(O),q=s(-N*Z),W=s(p*Z),tt=c.BASE.multiplyAndAddUnsafe(z,q,W);if(!tt)throw new Error("point at infinify");return tt.assertValidity(),tt}hasHighS(){return b(this.s)}normalizeS(){return this.hasHighS()?new h(this.r,s(-this.s),this.recovery):this}toDERRawBytes(){return De(this.toDERHex())}toDERHex(){return pe.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return De(this.toCompactHex())}toCompactHex(){return d(this.r)+d(this.s)}}let v={isValidPrivateKey(A){try{return l(A),!0}catch{return!1}},normPrivateKeyToScalar:l,randomPrivateKey:()=>{let A=Ho(t.n);return ha(t.randomBytes(A),t.n)},precompute(A=8,I=c.BASE){return I._setWindowSize(A),I.multiply(BigInt(3)),I}};function C(A,I=!0){return c.fromPrivateKey(A).toRawBytes(I)}function x(A){let I=ve(A),m=typeof A=="string",p=(I||m)&&A.length;return I?p===o||p===i:m?p===2*o||p===2*i:A instanceof c}function P(A,I,m=!0){if(x(A))throw new Error("first arg must be private key");if(!x(I))throw new Error("second arg must be public key");return c.fromHex(I).multiply(l(A)).toRawBytes(m)}let D=t.bits2int||function(A){if(A.length>8192)throw new Error("input is too large");let I=le(A),m=A.length*8-t.nBitLength;return m>0?I>>BigInt(m):I},k=t.bits2int_modN||function(A){return s(D(A))},R=Nr(t.nBitLength);function w(A){return Ut("num < 2^"+t.nBitLength,A,me,R),Ie(A,t.nByteLength)}function E(A,I,m=F){if(["recovered","canonical"].some(lt=>lt in m))throw new Error("sign() legacy options not supported");let{hash:p,randomBytes:S}=t,{lowS:N,prehash:O,extraEntropy:M}=m;N==null&&(N=!0),A=it("msgHash",A),Qa(m),O&&(A=it("prehashed msgHash",p(A)));let z=k(A),Z=l(I),q=[w(Z),w(z)];if(M!=null&&M!==!1){let lt=M===!0?S(r.BYTES):M;q.push(it("extraEntropy",lt))}let W=de(...q),tt=z;function ft(lt){let mt=D(lt);if(!f(mt))return;let yt=a(mt),Tt=c.BASE.multiply(mt).toAffine(),vt=s(Tt.x);if(vt===me)return;let ee=s(yt*s(tt+vt*Z));if(ee===me)return;let se=(Tt.x===vt?0:2)|Number(Tt.y&dt),Ar=ee;return N&&b(ee)&&(Ar=T(ee),se^=1),new h(vt,Ar,se)}return{seed:W,k2sig:ft}}let F={lowS:t.lowS,prehash:!1},_={lowS:t.lowS,prehash:!1};function U(A,I,m=F){let{seed:p,k2sig:S}=E(A,I,m),N=t;return Ko(N.hash.outputLen,N.nByteLength,N.hmac)(p,S)}c.BASE._setWindowSize(8);function K(A,I,m,p=_){let S=A;I=it("msgHash",I),m=it("publicKey",m);let{lowS:N,prehash:O,format:M}=p;if(Qa(p),"strict"in p)throw new Error("options.strict was renamed to lowS");if(M!==void 0&&M!=="compact"&&M!=="der")throw new Error("format must be compact or der");let z=typeof S=="string"||ve(S),Z=!z&&!M&&typeof S=="object"&&S!==null&&typeof S.r=="bigint"&&typeof S.s=="bigint";if(!z&&!Z)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let q,W;try{if(Z&&(q=new h(S.r,S.s)),z){try{M!=="compact"&&(q=h.fromDER(S))}catch(se){if(!(se instanceof pe.Err))throw se}!q&&M!=="der"&&(q=h.fromCompact(S))}W=c.fromHex(m)}catch{return!1}if(!q||N&&q.hasHighS())return!1;O&&(I=t.hash(I));let{r:tt,s:ft}=q,lt=k(I),mt=a(ft),yt=s(lt*mt),Tt=s(tt*mt),vt=c.BASE.multiplyAndAddUnsafe(W,yt,Tt)?.toAffine();return vt?s(vt.x)===tt:!1}return{CURVE:t,getPublicKey:C,getSharedSecret:P,sign:U,verify:K,ProjectivePoint:c,Signature:h,utils:v}}function xh(e){return{hash:e,hmac:(t,...r)=>Di(e,t,Lo(...r)),randomBytes:fn}}function rc(e,t){let r=n=>ec({...e,...xh(n)});return{...r(t),create:r}}var ic=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),nc=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),wh=BigInt(1),Oi=BigInt(2),oc=(e,t)=>(e+t/Oi)/t;function bh(e){let t=ic,r=BigInt(3),n=BigInt(6),o=BigInt(11),i=BigInt(22),s=BigInt(23),a=BigInt(44),c=BigInt(88),l=e*e*e%t,u=l*l*e%t,f=nt(u,r,t)*u%t,d=nt(f,r,t)*u%t,b=nt(d,Oi,t)*l%t,T=nt(b,o,t)*b%t,y=nt(T,i,t)*T%t,h=nt(y,a,t)*y%t,v=nt(h,c,t)*h%t,C=nt(v,a,t)*y%t,x=nt(C,r,t)*u%t,P=nt(x,s,t)*T%t,D=nt(P,n,t)*l%t,k=nt(D,Oi,t);if(!Mi.eql(Mi.sqr(k),e))throw new Error("Cannot find square root");return k}var Mi=Te(ic,void 0,void 0,{sqrt:bh}),$e=rc({a:BigInt(0),b:BigInt(7),Fp:Mi,n:nc,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:e=>{let t=nc,r=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-wh*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),i=r,s=BigInt("0x100000000000000000000000000000000"),a=oc(i*e,t),c=oc(-n*e,t),l=J(e-a*r-c*o,t),u=J(-a*n-c*i,t),f=l>s,d=u>s;if(f&&(l=t-l),d&&(u=t-u),l>s||u>s)throw new Error("splitScalar: Endomorphism failed, k="+e);return{k1neg:f,k1:l,k2neg:d,k2:u}}}},lr),Oy=BigInt(0);var My=$e.ProjectivePoint;function sc(e){return e==null?!1:typeof e.then=="function"&&typeof e.catch=="function"&&typeof e.finally=="function"}function ac(e,t,r){let n=Rr.digest(r instanceof Uint8Array?r:r.subarray());if(sc(n))return n.then(({digest:o})=>$e.verify(t,o,e)).catch(o=>{throw new Or(String(o))});try{return $e.verify(t,n.digest,e)}catch(o){throw new Or(String(o))}}var Pn=class{type="secp256k1";raw;_key;constructor(t){this._key=uc(t),this.raw=cc(this._key)}toMultihash(){return $t.digest(Sn(this))}toCID(){return X.createV1(114,this.toMultihash())}toString(){return et.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:ot(this.raw,t.raw)}verify(t,r){return ac(this._key,r,t)}};function Vi(e){return new Pn(e)}function cc(e){return $e.ProjectivePoint.fromHex(e).toRawBytes(!0)}function uc(e){try{return $e.ProjectivePoint.fromHex(e),e}catch(t){throw new Ze(String(t))}}function fc(e,t){let{Type:r,Data:n}=ne.decode(e),o=n??new Uint8Array;switch(r){case ut.RSA:return ki(o,t);case ut.Ed25519:return Jo(o);case ut.secp256k1:return Vi(o);default:throw new Ye}}function Rn(e){let{Type:t,Data:r}=ne.decode(e.digest),n=r??new Uint8Array;switch(t){case ut.Ed25519:return Jo(n);case ut.secp256k1:return Vi(n);default:throw new Ye}}function Sn(e){return ne.encode({Type:ut[e.type],Data:e.raw})}var lc=Symbol.for("nodejs.util.inspect.custom"),Eh=114,Kr=class{type;multihash;publicKey;string;constructor(t){this.type=t.type,this.multihash=t.multihash,Object.defineProperty(this,"string",{enumerable:!1,writable:!0})}get[Symbol.toStringTag](){return`PeerId(${this.toString()})`}[bo]=!0;toString(){return this.string==null&&(this.string=et.encode(this.multihash.bytes).slice(1)),this.string}toMultihash(){return this.multihash}toCID(){return X.createV1(Eh,this.multihash)}toJSON(){return this.toString()}equals(t){if(t==null)return!1;if(t instanceof Uint8Array)return ot(this.multihash.bytes,t);if(typeof t=="string")return this.toString()===t;if(t?.toMultihash()?.bytes!=null)return ot(this.multihash.bytes,t.toMultihash().bytes);throw new Error("not valid Id")}[lc](){return`PeerId(${this.toString()})`}},_n=class extends Kr{type="RSA";publicKey;constructor(t){super({...t,type:"RSA"}),this.publicKey=t.publicKey}},Ln=class extends Kr{type="Ed25519";publicKey;constructor(t){super({...t,type:"Ed25519"}),this.publicKey=t.publicKey}},kn=class extends Kr{type="secp256k1";publicKey;constructor(t){super({...t,type:"secp256k1"}),this.publicKey=t.publicKey}},Sh=2336,qr=class{type="url";multihash;publicKey;url;constructor(t){this.url=t.toString(),this.multihash=$t.digest(H(this.url))}[lc](){return`PeerId(${this.url})`}[bo]=!0;toString(){return this.toCID().toString()}toMultihash(){return this.multihash}toCID(){return X.createV1(Sh,this.toMultihash())}toJSON(){return this.toString()}equals(t){return t==null?!1:(t instanceof Uint8Array&&(t=G(t)),t.toString()===this.toString())}};var vh=114,dc=2336;function hc(e,t){let r;if(e.charAt(0)==="1"||e.charAt(0)==="Q")r=ce(et.decode(`z${e}`));else{if(t==null)throw new xt('Please pass a multibase decoder for strings that do not start with "1" or "Q"');r=ce(t.decode(e))}return pc(r)}function pc(e){if(Ih(e))return new _n({multihash:e});if(Ah(e))try{let t=Rn(e);if(t.type==="Ed25519")return new Ln({multihash:e,publicKey:t});if(t.type==="secp256k1")return new kn({multihash:e,publicKey:t})}catch{let r=G(e.digest);return new qr(new URL(r))}throw new je("Supplied PeerID Multihash is invalid")}function mc(e){if(e?.multihash==null||e.version==null||e.version===1&&e.code!==vh&&e.code!==dc)throw new rn("Supplied PeerID CID is invalid");if(e.code===dc){let t=G(e.multihash.digest);return new qr(new URL(t))}return pc(e.multihash)}function Ah(e){return e.code===$t.code}function Ih(e){return e.code===Rr.code}var Dn=class{index=0;input="";new(t){return this.index=0,this.input=t,this}readAtomically(t){let r=this.index,n=t();return n===void 0&&(this.index=r),n}parseWith(t){let r=t();if(this.index===this.input.length)return r}peekChar(){if(!(this.index>=this.input.length))return this.input[this.index]}readChar(){if(!(this.index>=this.input.length))return this.input[this.index++]}readGivenChar(t){return this.readAtomically(()=>{let r=this.readChar();if(r===t)return r})}readSeparator(t,r,n){return this.readAtomically(()=>{if(!(r>0&&this.readGivenChar(t)===void 0))return n()})}readNumber(t,r,n,o){return this.readAtomically(()=>{let i=0,s=0,a=this.peekChar();if(a===void 0)return;let c=a==="0",l=2**(8*o)-1;for(;;){let u=this.readAtomically(()=>{let f=this.readChar();if(f===void 0)return;let d=Number.parseInt(f,t);if(!Number.isNaN(d))return d});if(u===void 0)break;if(i*=t,i+=u,i>l||(s+=1,r!==void 0&&s>r))return}if(s!==0)return!n&&c&&s>1?void 0:i})}readIPv4Addr(){return this.readAtomically(()=>{let t=new Uint8Array(4);for(let r=0;r<t.length;r++){let n=this.readSeparator(".",r,()=>this.readNumber(10,3,!1,1));if(n===void 0)return;t[r]=n}return t})}readIPv6Addr(){let t=r=>{for(let n=0;n<r.length/2;n++){let o=n*2;if(n<r.length-3){let s=this.readSeparator(":",n,()=>this.readIPv4Addr());if(s!==void 0)return r[o]=s[0],r[o+1]=s[1],r[o+2]=s[2],r[o+3]=s[3],[o+4,!0]}let i=this.readSeparator(":",n,()=>this.readNumber(16,4,!0,2));if(i===void 0)return[o,!1];r[o]=i>>8,r[o+1]=i&255}return[r.length,!1]};return this.readAtomically(()=>{let r=new Uint8Array(16),[n,o]=t(r);if(n===16)return r;if(o||this.readGivenChar(":")===void 0||this.readGivenChar(":")===void 0)return;let i=new Uint8Array(14),s=16-(n+2),[a]=t(i.subarray(0,s));return r.set(i.subarray(0,a),16-a),r})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var gc=45,Th=15,pr=new Dn;function Ki(e){if(!(e.length>Th))return pr.new(e).parseWith(()=>pr.readIPv4Addr())}function qi(e){if(e.includes("%")&&(e=e.split("%")[0]),!(e.length>gc))return pr.new(e).parseWith(()=>pr.readIPv6Addr())}function Fn(e,t=!1){if(e.includes("%")&&(e=e.split("%")[0]),e.length>gc)return;let r=pr.new(e).parseWith(()=>pr.readIPAddr());if(r)return t&&r.length===4?Uint8Array.from([0,0,0,0,0,0,0,0,0,0,255,255,r[0],r[1],r[2],r[3]]):r}var Yx=parseInt("0xFFFF",16),Wx=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);function wc(e){return!!Ki(e)}function bc(e){return!!qi(e)}function On(e){return!!Fn(e)}var Ec=wc,Ph=bc,$i=function(e){let t=0;if(e=e.toString().trim(),Ec(e)){let r=new Uint8Array(t+4);return e.split(/\./g).forEach(n=>{r[t++]=parseInt(n,10)&255}),r}if(Ph(e)){let r=e.split(":",8),n;for(n=0;n<r.length;n++){let i=Ec(r[n]),s;i&&(s=$i(r[n]),r[n]=G(s.slice(0,2),"base16")),s!=null&&++n<8&&r.splice(n,0,G(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")},Sc=function(e,t=0,r){t=~~t,r=r??e.length-t;let n=new DataView(e.buffer);if(r===4){let o=[];for(let i=0;i<r;i++)o.push(e[t+i]);return o.join(".")}if(r===16){let o=[];for(let i=0;i<r;i+=2)o.push(n.getUint16(t+i).toString(16));return o.join(":").replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}return""};var mr={},zi={},_h=[[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"]];_h.forEach(e=>{let t=Lh(...e);zi[t.code]=t,mr[t.name]=t});function Lh(e,t,r,n,o){return{code:e,size:t,name:r,resolvable:!!n,path:!!o}}function Q(e){if(typeof e=="number"){if(zi[e]!=null)return zi[e];throw new Error(`no protocol with code: ${e}`)}else if(typeof e=="string"){if(mr[e]!=null)return mr[e];throw new Error(`no protocol with name: ${e}`)}throw new Error(`invalid protocol id type: ${typeof e}`)}var _w=Q("ip4"),Lw=Q("ip6"),kw=Q("ipcidr");function ji(e,t){switch(Q(e).code){case 4:case 41:return Dh(t);case 42:return Zi(t);case 43:return G(t,"base10");case 6:case 273:case 33:case 132:return Ic(t).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return Zi(t);case 421:return Vh(t);case 444:return Ac(t);case 445:return Ac(t);case 466:return Mh(t);case 481:return globalThis.encodeURIComponent(Zi(t));default:return G(t,"base16")}}function Yi(e,t){switch(Q(e).code){case 4:return vc(t);case 41:return vc(t);case 42:return Gi(t);case 43:return H(t,"base10");case 6:case 273:case 33:case 132:return Wi(parseInt(t,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return Gi(t);case 421:return Fh(t);case 444:return Kh(t);case 445:return qh(t);case 466:return Oh(t);case 481:return Gi(globalThis.decodeURIComponent(t));default:return H(t,"base16")}}var Hi=Object.values(_r).map(e=>e.decoder),kh=function(){let e=Hi[0].or(Hi[1]);return Hi.slice(2).forEach(t=>e=e.or(t)),e}();function vc(e){if(!On(e))throw new Error("invalid ip address");return $i(e)}function Dh(e){let t=Sc(e,0,e.length);if(t==null)throw new Error("ipBuff is required");if(!On(t))throw new Error("invalid ip address");return t}function Wi(e){let t=new ArrayBuffer(2);return new DataView(t).setUint16(0,e),new Uint8Array(t)}function Ic(e){return new DataView(e.buffer).getUint16(e.byteOffset)}function Gi(e){let t=H(e),r=Uint8Array.from(sr(t.length));return Et([r,t],r.length+t.length)}function Zi(e){let t=Ve(e);if(e=e.slice(Rt(t)),e.length!==t)throw new Error("inconsistent lengths");return G(e)}function Fh(e){let t;e[0]==="Q"||e[0]==="1"?t=ce(et.decode(`z${e}`)).bytes:t=X.parse(e).multihash.bytes;let r=Uint8Array.from(sr(t.length));return Et([r,t],r.length+t.length)}function Oh(e){let t=kh.decode(e),r=Uint8Array.from(sr(t.length));return Et([r,t],r.length+t.length)}function Mh(e){let t=Ve(e),r=e.slice(Rt(t));if(r.length!==t)throw new Error("inconsistent lengths");return"u"+G(r,"base64url")}function Vh(e){let t=Ve(e),r=e.slice(Rt(t));if(r.length!==t)throw new Error("inconsistent lengths");return G(r,"base58btc")}function Kh(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=Kt.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=Wi(n);return Et([r,o],r.length+o.length)}function qh(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=Kt.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=Wi(n);return Et([r,o],r.length+o.length)}function Ac(e){let t=e.slice(0,e.length-2),r=e.slice(e.length-2),n=G(t,"base32"),o=Ic(r);return`${n}:${o}`}function Tc(e){e=Xi(e);let t=[],r=[],n=null,o=e.split("/").slice(1);if(o.length===1&&o[0]==="")return{bytes:new Uint8Array,string:"/",tuples:[],stringTuples:[],path:null};for(let i=0;i<o.length;i++){let s=o[i],a=Q(s);if(a.size===0){t.push([a.code]),r.push([a.code]);continue}if(i++,i>=o.length)throw new Mn("invalid address: "+e);if(a.path===!0){n=Xi(o.slice(i).join("/")),t.push([a.code,Yi(a.code,n)]),r.push([a.code,n]);break}let c=Yi(a.code,o[i]);t.push([a.code,c]),r.push([a.code,ji(a.code,c)])}return{string:Bc(r),bytes:Vn(t),tuples:t,stringTuples:r,path:n}}function Ji(e){let t=[],r=[],n=null,o=0;for(;o<e.length;){let i=Ve(e,o),s=Rt(i),a=Q(i),c=$h(a,e.slice(o+s));if(c===0){t.push([i]),r.push([i]),o+=s;continue}let l=e.slice(o+s,o+s+c);if(o+=c+s,o>e.length)throw new Mn("Invalid address Uint8Array: "+G(e,"base16"));t.push([i,l]);let u=ji(i,l);if(r.push([i,u]),a.path===!0){n=u;break}}return{bytes:Uint8Array.from(e),string:Bc(r),tuples:t,stringTuples:r,path:n}}function Bc(e){let t=[];return e.map(r=>{let n=Q(r[0]);return t.push(n.name),r.length>1&&r[1]!=null&&t.push(r[1]),null}),Xi(t.join("/"))}function Vn(e){return Et(e.map(t=>{let r=Q(t[0]),n=Uint8Array.from(sr(r.code));return t.length>1&&t[1]!=null&&(n=Et([n,t[1]])),n}))}function $h(e,t){if(e.size>0)return e.size/8;if(e.size===0)return 0;{let r=Ve(t instanceof Uint8Array?t:Uint8Array.from(t));return r+Rt(r)}}function Xi(e){return"/"+e.trim().split("/").filter(t=>t).join("/")}var Mn=class extends Error{static name="ParseError";name="ParseError";constructor(t){super(`Error parsing address: ${t}`)}};var zh=Symbol.for("nodejs.util.inspect.custom"),ts=Symbol.for("@multiformats/js-multiaddr/multiaddr"),Hh=[Q("dns").code,Q("dns4").code,Q("dns6").code,Q("dnsaddr").code],Qi=class extends Error{constructor(t="No available resolver"){super(t),this.name="NoAvailableResolverError"}},Kn=class e{bytes;#t;#r;#e;#a;[ts]=!0;constructor(t){t==null&&(t="");let r;if(t instanceof Uint8Array)r=Ji(t);else if(typeof t=="string"){if(t.length>0&&t.charAt(0)!=="/")throw new Error(`multiaddr "${t}" must start with a "/"`);r=Tc(t)}else if(Uc(t))r=Ji(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=Q("tcp"),a=Q("udp"),c=Q("ip4"),l=Q("ip6"),u=Q("dns6"),f=Q("ip6zone");for(let[b,T]of this.stringTuples())b===f.code&&(i=`%${T??""}`),Hh.includes(b)&&(r=s.name==="tcp"?"tcp":"udp",o=443,n=`${T??""}${i}`,t=b===u.code?6:4),(b===s.code||b===a.code)&&(r=Q(b).name==="tcp"?"tcp":"udp",o=parseInt(T??"")),(b===c.code||b===l.code)&&(r=Q(b).name==="tcp"?"tcp":"udp",n=`${T??""}${i}`,t=b===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({},Q(t)))}protoCodes(){return this.#r.map(([t])=>t)}protoNames(){return this.#r.map(([t])=>Q(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(Vn(r.slice(0,n)));return this}getPeerId(){try{let t=[];this.stringTuples().forEach(([n,o])=>{n===mr.p2p.code&&t.push([n,o]),n===mr["p2p-circuit"].code&&(t=[])});let r=t.pop();if(r?.[1]!=null){let n=r[1];return n[0]==="Q"||n[0]==="1"?G(et.decode(`z${n}`),"base58btc"):G(X.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){return this.#a}equals(t){return ot(this.bytes,t.bytes)}async resolve(t){let r=this.protos().find(i=>i.resolvable);if(r==null)return[this];let n=Cc.get(r.name);if(n==null)throw new Qi(`no available resolver for ${r.name}`);return(await n(this,t)).map(i=>ze(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)}[zh](){return`Multiaddr(${this.#t})`}};var Cc=new Map;function Uc(e){return!!e?.[ts]}function ze(e){return new Kn(e)}function $r(e){let t=new globalThis.AbortController;function r(){t.abort();for(let i of e)i?.removeEventListener!=null&&i.removeEventListener("abort",r)}for(let i of e){if(i?.aborted===!0){r();break}i?.addEventListener!=null&&i.addEventListener("abort",r)}function n(){for(let i of e)i?.removeEventListener!=null&&i.removeEventListener("abort",r)}let o=t.signal;return o.clear=n,o}async function*qn(e,t={}){let r=e.getReader();try{for(;;){let n=await r.read();if(n.done)return;yield n.value}}finally{t.preventCancel!==!0&&await r.cancel(),r.releaseLock()}}var Gh="/",Zh=new TextEncoder().encode(Gh),lb=Zh[0];var Bp=wo(rs(),1);var Yt=class extends Error{static name="SignatureVerificationError";constructor(t="Record signature verification failed"){super(t),this.name="SignatureVerificationError"}},$n=class extends Error{static name="RecordExpiredError";constructor(t="Record has expired"){super(t),this.name="RecordExpiredError"}},gr=class extends Error{static name="UnsupportedValidityError";constructor(t="The validity type is unsupported"){super(t),this.name="UnsupportedValidityError"}},zn=class extends Error{static name="RecordTooLargeError";constructor(t="The record is too large"){super(t),this.name="RecordTooLargeError"}},Hn=class extends Error{static name="InvalidValueError";constructor(t="Value must be a valid content path starting with /"){super(t),this.name="InvalidValueError"}},Gn=class extends Error{static name="InvalidRecordDataError";constructor(t="Invalid record data"){super(t),this.name="InvalidRecordDataError"}},zr=class extends Error{static name="InvalidEmbeddedPublicKeyError";constructor(t="Invalid embedded public key"){super(t),this.name="InvalidEmbeddedPublicKeyError"}};var Wt;(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=()=>Dr(r)}(t=e.ValidityType||(e.ValidityType={}));let n;e.codec=()=>(n==null&&(n=fr((o,i,s={})=>{s.lengthDelimited!==!1&&i.fork(),o.value!=null&&(i.uint32(10),i.bytes(o.value)),o.signatureV1!=null&&(i.uint32(18),i.bytes(o.signatureV1)),o.validityType!=null&&(i.uint32(24),e.ValidityType.codec().encode(o.validityType,i)),o.validity!=null&&(i.uint32(34),i.bytes(o.validity)),o.sequence!=null&&(i.uint32(40),i.uint64(o.sequence)),o.ttl!=null&&(i.uint32(48),i.uint64(o.ttl)),o.pubKey!=null&&(i.uint32(58),i.bytes(o.pubKey)),o.signatureV2!=null&&(i.uint32(66),i.bytes(o.signatureV2)),o.data!=null&&(i.uint32(74),i.bytes(o.data)),s.lengthDelimited!==!1&&i.ldelim()},(o,i,s={})=>{let a={},c=i==null?o.len:o.pos+i;for(;o.pos<c;){let l=o.uint32();switch(l>>>3){case 1:{a.value=o.bytes();break}case 2:{a.signatureV1=o.bytes();break}case 3:{a.validityType=e.ValidityType.codec().decode(o);break}case 4:{a.validity=o.bytes();break}case 5:{a.sequence=o.uint64();break}case 6:{a.ttl=o.uint64();break}case 7:{a.pubKey=o.bytes();break}case 8:{a.signatureV2=o.bytes();break}case 9:{a.data=o.bytes();break}default:{o.skipType(l&7);break}}}return a})),n),e.encode=o=>cr(o,e.codec()),e.decode=(o,i)=>ar(o,e.codec(),i)})(Wt||(Wt={}));var jh=["string","number","bigint","symbol"],Yh=["Function","Generator","AsyncGenerator","GeneratorFunction","AsyncGeneratorFunction","AsyncFunction","Observable","Array","Buffer","Object","RegExp","Date","Error","Map","Set","WeakMap","WeakSet","ArrayBuffer","SharedArrayBuffer","DataView","Promise","URL","HTMLElement","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","BigInt64Array","BigUint64Array"];function Nc(e){if(e===null)return"null";if(e===void 0)return"undefined";if(e===!0||e===!1)return"boolean";let t=typeof e;if(jh.includes(t))return t;if(t==="function")return"Function";if(Array.isArray(e))return"Array";if(Wh(e))return"Buffer";let r=Xh(e);return r||"Object"}function Wh(e){return e&&e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer.call(null,e)}function Xh(e){let t=Object.prototype.toString.call(e).slice(8,-1);if(Yh.includes(t))return t}var g=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}};g.uint=new g(0,"uint",!0);g.negint=new g(1,"negint",!0);g.bytes=new g(2,"bytes",!0);g.string=new g(3,"string",!0);g.array=new g(4,"array",!1);g.map=new g(5,"map",!1);g.tag=new g(6,"tag",!1);g.float=new g(7,"float",!0);g.false=new g(7,"false",!0);g.true=new g(7,"true",!0);g.null=new g(7,"null",!0);g.undefined=new g(7,"undefined",!0);g.break=new g(7,"break",!0);var L=class{constructor(t,r,n){this.type=t,this.value=r,this.encodedLength=n,this.encodedBytes=void 0,this.byteValue=void 0}toString(){return`Token[${this.type}].${this.value}`}};var yr=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&typeof globalThis.Buffer.isBuffer=="function",Jh=new TextDecoder,Qh=new TextEncoder;function Zn(e){return yr&&globalThis.Buffer.isBuffer(e)}function Lc(e){return e instanceof Uint8Array?Zn(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e:Uint8Array.from(e)}var kc=yr?(e,t,r)=>r-t>64?globalThis.Buffer.from(e.subarray(t,r)).toString("utf8"):Rc(e,t,r):(e,t,r)=>r-t>64?Jh.decode(e.subarray(t,r)):Rc(e,t,r),Dc=yr?e=>e.length>64?globalThis.Buffer.from(e):Pc(e):e=>e.length>64?Qh.encode(e):Pc(e);var xr=yr?(e,t,r)=>Zn(e)?new Uint8Array(e.subarray(t,r)):e.slice(t,r):(e,t,r)=>e.slice(t,r),Fc=yr?(e,t)=>(e=e.map(r=>r instanceof Uint8Array?r:globalThis.Buffer.from(r)),Lc(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},Oc=yr?e=>globalThis.Buffer.allocUnsafe(e):e=>new Uint8Array(e);function Mc(e,t){if(Zn(e)&&Zn(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 Pc(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 Rc(e,t,r){let n=[];for(;t<r;){let o=e[t],i=null,s=o>239?4:o>223?3:o>191?2:1;if(t+s<=r){let a,c,l,u;switch(s){case 1:o<128&&(i=o);break;case 2:a=e[t+1],(a&192)===128&&(u=(o&31)<<6|a&63,u>127&&(i=u));break;case 3:a=e[t+1],c=e[t+2],(a&192)===128&&(c&192)===128&&(u=(o&15)<<12|(a&63)<<6|c&63,u>2047&&(u<55296||u>57343)&&(i=u));break;case 4:a=e[t+1],c=e[t+2],l=e[t+3],(a&192)===128&&(c&192)===128&&(l&192)===128&&(u=(o&15)<<18|(a&63)<<12|(c&63)<<6|l&63,u>65535&&u<1114112&&(i=u))}}i===null?(i=65533,s=1):i>65535&&(i-=65536,n.push(i>>>10&1023|55296),i=56320|i&1023),n.push(i),t+=s}return tp(n)}var _c=4096;function tp(e){let t=e.length;if(t<=_c)return String.fromCharCode.apply(String,e);let r="",n=0;for(;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=_c));return r}var ep=256,jn=class{constructor(t=ep){this.chunkSize=t,this.cursor=0,this.maxCursor=-1,this.chunks=[],this._initReuseChunk=null}reset(){this.cursor=0,this.maxCursor=-1,this.chunks.length&&(this.chunks=[]),this._initReuseChunk!==null&&(this.chunks.push(this._initReuseChunk),this.maxCursor=this._initReuseChunk.length-1)}push(t){let r=this.chunks[this.chunks.length-1];if(this.cursor+t.length<=this.maxCursor+1){let o=r.length-(this.maxCursor-this.cursor)-1;r.set(t,o)}else{if(r){let o=r.length-(this.maxCursor-this.cursor)-1;o<r.length&&(this.chunks[this.chunks.length-1]=r.subarray(0,o),this.maxCursor=this.cursor-1)}t.length<64&&t.length<this.chunkSize?(r=Oc(this.chunkSize),this.chunks.push(r),this.maxCursor+=r.length,this._initReuseChunk===null&&(this._initReuseChunk=r),r.set(t,0)):(this.chunks.push(t),this.maxCursor+=t.length)}this.cursor+=t.length}toBytes(t=!1){let r;if(this.chunks.length===1){let n=this.chunks[0];t&&this.cursor>n.length/2?(r=this.cursor===n.length?n:n.subarray(0,this.cursor),this._initReuseChunk=null,this.chunks=[]):r=xr(n,0,this.cursor)}else r=Fc(this.chunks,this.cursor);return t&&this.reset(),r}};var V="CBOR decode error:",ns="CBOR encode error:",Hr=[];Hr[23]=1;Hr[24]=2;Hr[25]=3;Hr[26]=5;Hr[27]=9;function ge(e,t,r){if(e.length-t<r)throw new Error(`${V} not enough data for type`)}var ht=[24,256,65536,4294967296,BigInt("18446744073709551616")];function Lt(e,t,r){ge(e,t,1);let n=e[t];if(r.strict===!0&&n<ht[0])throw new Error(`${V} integer encoded in more bytes than necessary (strict decode)`);return n}function kt(e,t,r){ge(e,t,2);let n=e[t]<<8|e[t+1];if(r.strict===!0&&n<ht[1])throw new Error(`${V} integer encoded in more bytes than necessary (strict decode)`);return n}function Dt(e,t,r){ge(e,t,4);let n=e[t]*16777216+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3];if(r.strict===!0&&n<ht[2])throw new Error(`${V} integer encoded in more bytes than necessary (strict decode)`);return n}function Ft(e,t,r){ge(e,t,8);let n=e[t]*16777216+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3],o=e[t+4]*16777216+(e[t+5]<<16)+(e[t+6]<<8)+e[t+7],i=(BigInt(n)<<BigInt(32))+BigInt(o);if(r.strict===!0&&i<ht[3])throw new Error(`${V} 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(`${V} integers outside of the safe integer range are not supported`)}function Vc(e,t,r,n){return new L(g.uint,Lt(e,t+1,n),2)}function Kc(e,t,r,n){return new L(g.uint,kt(e,t+1,n),3)}function qc(e,t,r,n){return new L(g.uint,Dt(e,t+1,n),5)}function $c(e,t,r,n){return new L(g.uint,Ft(e,t+1,n),9)}function Mt(e,t){return gt(e,0,t.value)}function gt(e,t,r){if(r<ht[0]){let n=Number(r);e.push([t|n])}else if(r<ht[1]){let n=Number(r);e.push([t|24,n])}else if(r<ht[2]){let n=Number(r);e.push([t|25,n>>>8,n&255])}else if(r<ht[3]){let n=Number(r);e.push([t|26,n>>>24&255,n>>>16&255,n>>>8&255,n&255])}else{let n=BigInt(r);if(n<ht[4]){let o=[t|27,0,0,0,0,0,0,0],i=Number(n&BigInt(4294967295)),s=Number(n>>BigInt(32)&BigInt(4294967295));o[8]=i&255,i=i>>8,o[7]=i&255,i=i>>8,o[6]=i&255,i=i>>8,o[5]=i&255,o[4]=s&255,s=s>>8,o[3]=s&255,s=s>>8,o[2]=s&255,s=s>>8,o[1]=s&255,e.push(o)}else throw new Error(`${V} encountered BigInt larger than allowable range`)}}Mt.encodedSize=function(t){return gt.encodedSize(t.value)};gt.encodedSize=function(t){return t<ht[0]?1:t<ht[1]?2:t<ht[2]?3:t<ht[3]?5:9};Mt.compareTokens=function(t,r){return t.value<r.value?-1:t.value>r.value?1:0};function zc(e,t,r,n){return new L(g.negint,-1-Lt(e,t+1,n),2)}function Hc(e,t,r,n){return new L(g.negint,-1-kt(e,t+1,n),3)}function Gc(e,t,r,n){return new L(g.negint,-1-Dt(e,t+1,n),5)}var os=BigInt(-1),Zc=BigInt(1);function jc(e,t,r,n){let o=Ft(e,t+1,n);if(typeof o!="bigint"){let i=-1-o;if(i>=Number.MIN_SAFE_INTEGER)return new L(g.negint,i,9)}if(n.allowBigInt!==!0)throw new Error(`${V} integers outside of the safe integer range are not supported`);return new L(g.negint,os-BigInt(o),9)}function Yn(e,t){let r=t.value,n=typeof r=="bigint"?r*os-Zc:r*-1-1;gt(e,t.type.majorEncoded,n)}Yn.encodedSize=function(t){let r=t.value,n=typeof r=="bigint"?r*os-Zc:r*-1-1;return n<ht[0]?1:n<ht[1]?2:n<ht[2]?3:n<ht[3]?5:9};Yn.compareTokens=function(t,r){return t.value<r.value?1:t.value>r.value?-1:0};function Gr(e,t,r,n){ge(e,t,r+n);let o=xr(e,t+r,t+r+n);return new L(g.bytes,o,r+n)}function Yc(e,t,r,n){return Gr(e,t,1,r)}function Wc(e,t,r,n){return Gr(e,t,2,Lt(e,t+1,n))}function Xc(e,t,r,n){return Gr(e,t,3,kt(e,t+1,n))}function Jc(e,t,r,n){return Gr(e,t,5,Dt(e,t+1,n))}function Qc(e,t,r,n){let o=Ft(e,t+1,n);if(typeof o=="bigint")throw new Error(`${V} 64-bit integer bytes lengths not supported`);return Gr(e,t,9,o)}function Wn(e){return e.encodedBytes===void 0&&(e.encodedBytes=e.type===g.string?Dc(e.value):e.value),e.encodedBytes}function wr(e,t){let r=Wn(t);gt(e,t.type.majorEncoded,r.length),e.push(r)}wr.encodedSize=function(t){let r=Wn(t);return gt.encodedSize(r.length)+r.length};wr.compareTokens=function(t,r){return np(Wn(t),Wn(r))};function np(e,t){return e.length<t.length?-1:e.length>t.length?1:Mc(e,t)}function Zr(e,t,r,n,o){let i=r+n;ge(e,t,i);let s=new L(g.string,kc(e,t+r,t+i),i);return o.retainStringBytes===!0&&(s.byteValue=xr(e,t+r,t+i)),s}function tu(e,t,r,n){return Zr(e,t,1,r,n)}function eu(e,t,r,n){return Zr(e,t,2,Lt(e,t+1,n),n)}function ru(e,t,r,n){return Zr(e,t,3,kt(e,t+1,n),n)}function nu(e,t,r,n){return Zr(e,t,5,Dt(e,t+1,n),n)}function ou(e,t,r,n){let o=Ft(e,t+1,n);if(typeof o=="bigint")throw new Error(`${V} 64-bit integer string lengths not supported`);return Zr(e,t,9,o,n)}var iu=wr;function br(e,t,r,n){return new L(g.array,n,r)}function su(e,t,r,n){return br(e,t,1,r)}function au(e,t,r,n){return br(e,t,2,Lt(e,t+1,n))}function cu(e,t,r,n){return br(e,t,3,kt(e,t+1,n))}function uu(e,t,r,n){return br(e,t,5,Dt(e,t+1,n))}function fu(e,t,r,n){let o=Ft(e,t+1,n);if(typeof o=="bigint")throw new Error(`${V} 64-bit integer array lengths not supported`);return br(e,t,9,o)}function lu(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${V} indefinite length items not allowed`);return br(e,t,1,1/0)}function Xn(e,t){gt(e,g.array.majorEncoded,t.value)}Xn.compareTokens=Mt.compareTokens;Xn.encodedSize=function(t){return gt.encodedSize(t.value)};function Er(e,t,r,n){return new L(g.map,n,r)}function du(e,t,r,n){return Er(e,t,1,r)}function hu(e,t,r,n){return Er(e,t,2,Lt(e,t+1,n))}function pu(e,t,r,n){return Er(e,t,3,kt(e,t+1,n))}function mu(e,t,r,n){return Er(e,t,5,Dt(e,t+1,n))}function gu(e,t,r,n){let o=Ft(e,t+1,n);if(typeof o=="bigint")throw new Error(`${V} 64-bit integer map lengths not supported`);return Er(e,t,9,o)}function yu(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${V} indefinite length items not allowed`);return Er(e,t,1,1/0)}function Jn(e,t){gt(e,g.map.majorEncoded,t.value)}Jn.compareTokens=Mt.compareTokens;Jn.encodedSize=function(t){return gt.encodedSize(t.value)};function xu(e,t,r,n){return new L(g.tag,r,1)}function wu(e,t,r,n){return new L(g.tag,Lt(e,t+1,n),2)}function bu(e,t,r,n){return new L(g.tag,kt(e,t+1,n),3)}function Eu(e,t,r,n){return new L(g.tag,Dt(e,t+1,n),5)}function Su(e,t,r,n){return new L(g.tag,Ft(e,t+1,n),9)}function Qn(e,t){gt(e,g.tag.majorEncoded,t.value)}Qn.compareTokens=Mt.compareTokens;Qn.encodedSize=function(t){return gt.encodedSize(t.value)};var up=20,fp=21,lp=22,dp=23;function vu(e,t,r,n){if(n.allowUndefined===!1)throw new Error(`${V} undefined values are not supported`);return n.coerceUndefinedToNull===!0?new L(g.null,null,1):new L(g.undefined,void 0,1)}function Au(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${V} indefinite length items not allowed`);return new L(g.break,void 0,1)}function is(e,t,r){if(r){if(r.allowNaN===!1&&Number.isNaN(e))throw new Error(`${V} NaN values are not supported`);if(r.allowInfinity===!1&&(e===1/0||e===-1/0))throw new Error(`${V} Infinity values are not supported`)}return new L(g.float,e,t)}function Iu(e,t,r,n){return is(ss(e,t+1),3,n)}function Tu(e,t,r,n){return is(as(e,t+1),5,n)}function Bu(e,t,r,n){return is(Pu(e,t+1),9,n)}function to(e,t,r){let n=t.value;if(n===!1)e.push([g.float.majorEncoded|up]);else if(n===!0)e.push([g.float.majorEncoded|fp]);else if(n===null)e.push([g.float.majorEncoded|lp]);else if(n===void 0)e.push([g.float.majorEncoded|dp]);else{let o,i=!1;(!r||r.float64!==!0)&&(Uu(n),o=ss(Xt,1),n===o||Number.isNaN(n)?(Xt[0]=249,e.push(Xt.slice(0,3)),i=!0):(Nu(n),o=as(Xt,1),n===o&&(Xt[0]=250,e.push(Xt.slice(0,5)),i=!0))),i||(hp(n),o=Pu(Xt,1),Xt[0]=251,e.push(Xt.slice(0,9)))}}to.encodedSize=function(t,r){let n=t.value;if(n===!1||n===!0||n===null||n===void 0)return 1;if(!r||r.float64!==!0){Uu(n);let o=ss(Xt,1);if(n===o||Number.isNaN(n))return 3;if(Nu(n),o=as(Xt,1),n===o)return 5}return 9};var Cu=new ArrayBuffer(9),Vt=new DataView(Cu,1),Xt=new Uint8Array(Cu,0);function Uu(e){if(e===1/0)Vt.setUint16(0,31744,!1);else if(e===-1/0)Vt.setUint16(0,64512,!1);else if(Number.isNaN(e))Vt.setUint16(0,32256,!1);else{Vt.setFloat32(0,e);let t=Vt.getUint32(0),r=(t&2139095040)>>23,n=t&8388607;if(r===255)Vt.setUint16(0,31744,!1);else if(r===0)Vt.setUint16(0,(e&2147483648)>>16|n>>13,!1);else{let o=r-127;o<-24?Vt.setUint16(0,0):o<-14?Vt.setUint16(0,(t&2147483648)>>16|1<<24+o,!1):Vt.setUint16(0,(t&2147483648)>>16|o+15<<10|n>>13,!1)}}}function ss(e,t){if(e.length-t<2)throw new Error(`${V} 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 Nu(e){Vt.setFloat32(0,e,!1)}function as(e,t){if(e.length-t<4)throw new Error(`${V} not enough data for float32`);let r=(e.byteOffset||0)+t;return new DataView(e.buffer,r,4).getFloat32(0,!1)}function hp(e){Vt.setFloat64(0,e,!1)}function Pu(e,t){if(e.length-t<8)throw new Error(`${V} not enough data for float64`);let r=(e.byteOffset||0)+t;return new DataView(e.buffer,r,8).getFloat64(0,!1)}to.compareTokens=Mt.compareTokens;function j(e,t,r){throw new Error(`${V} encountered invalid minor (${r}) for major ${e[t]>>>5}`)}function eo(e){return()=>{throw new Error(`${V} ${e}`)}}var B=[];for(let e=0;e<=23;e++)B[e]=j;B[24]=Vc;B[25]=Kc;B[26]=qc;B[27]=$c;B[28]=j;B[29]=j;B[30]=j;B[31]=j;for(let e=32;e<=55;e++)B[e]=j;B[56]=zc;B[57]=Hc;B[58]=Gc;B[59]=jc;B[60]=j;B[61]=j;B[62]=j;B[63]=j;for(let e=64;e<=87;e++)B[e]=Yc;B[88]=Wc;B[89]=Xc;B[90]=Jc;B[91]=Qc;B[92]=j;B[93]=j;B[94]=j;B[95]=eo("indefinite length bytes/strings are not supported");for(let e=96;e<=119;e++)B[e]=tu;B[120]=eu;B[121]=ru;B[122]=nu;B[123]=ou;B[124]=j;B[125]=j;B[126]=j;B[127]=eo("indefinite length bytes/strings are not supported");for(let e=128;e<=151;e++)B[e]=su;B[152]=au;B[153]=cu;B[154]=uu;B[155]=fu;B[156]=j;B[157]=j;B[158]=j;B[159]=lu;for(let e=160;e<=183;e++)B[e]=du;B[184]=hu;B[185]=pu;B[186]=mu;B[187]=gu;B[188]=j;B[189]=j;B[190]=j;B[191]=yu;for(let e=192;e<=215;e++)B[e]=xu;B[216]=wu;B[217]=bu;B[218]=Eu;B[219]=Su;B[220]=j;B[221]=j;B[222]=j;B[223]=j;for(let e=224;e<=243;e++)B[e]=eo("simple values are not supported");B[244]=j;B[245]=j;B[246]=j;B[247]=vu;B[248]=eo("simple values are not supported");B[249]=Iu;B[250]=Tu;B[251]=Bu;B[252]=j;B[253]=j;B[254]=j;B[255]=Au;var Jt=[];for(let e=0;e<24;e++)Jt[e]=new L(g.uint,e,1);for(let e=-1;e>=-24;e--)Jt[31-e]=new L(g.negint,e,1);Jt[64]=new L(g.bytes,new Uint8Array(0),1);Jt[96]=new L(g.string,"",1);Jt[128]=new L(g.array,0,1);Jt[160]=new L(g.map,0,1);Jt[244]=new L(g.false,!1,1);Jt[245]=new L(g.true,!0,1);Jt[246]=new L(g.null,null,1);function mp(){let e=[];return e[g.uint.major]=Mt,e[g.negint.major]=Yn,e[g.bytes.major]=wr,e[g.string.major]=iu,e[g.array.major]=Xn,e[g.map.major]=Jn,e[g.tag.major]=Qn,e[g.float.major]=to,e}var u1=mp(),f1=new jn,ro=class e{constructor(t,r){this.obj=t,this.parent=r}includes(t){let r=this;do if(r.obj===t)return!0;while(r=r.parent);return!1}static createCheck(t,r){if(t&&t.includes(r))throw new Error(`${ns} object contains circular references`);return new e(r,t)}},Pe={null:new L(g.null,null),undefined:new L(g.undefined,void 0),true:new L(g.true,!0),false:new L(g.false,!1),emptyArray:new L(g.array,0),emptyMap:new L(g.map,0)},Re={number(e,t,r,n){return!Number.isInteger(e)||!Number.isSafeInteger(e)?new L(g.float,e):e>=0?new L(g.uint,e):new L(g.negint,e)},bigint(e,t,r,n){return e>=BigInt(0)?new L(g.uint,e):new L(g.negint,e)},Uint8Array(e,t,r,n){return new L(g.bytes,e)},string(e,t,r,n){return new L(g.string,e)},boolean(e,t,r,n){return e?Pe.true:Pe.false},null(e,t,r,n){return Pe.null},undefined(e,t,r,n){return Pe.undefined},ArrayBuffer(e,t,r,n){return new L(g.bytes,new Uint8Array(e))},DataView(e,t,r,n){return new L(g.bytes,new Uint8Array(e.buffer,e.byteOffset,e.byteLength))},Array(e,t,r,n){if(!e.length)return r.addBreakTokens===!0?[Pe.emptyArray,new L(g.break)]:Pe.emptyArray;n=ro.createCheck(n,e);let o=[],i=0;for(let s of e)o[i++]=cs(s,r,n);return r.addBreakTokens?[new L(g.array,e.length),o,new L(g.break)]:[new L(g.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?[Pe.emptyMap,new L(g.break)]:Pe.emptyMap;n=ro.createCheck(n,e);let a=[],c=0;for(let l of i)a[c++]=[cs(l,r,n),cs(o?e.get(l):e[l],r,n)];return gp(a,r),r.addBreakTokens?[new L(g.map,s),a,new L(g.break)]:[new L(g.map,s),a]}};Re.Map=Re.Object;Re.Buffer=Re.Uint8Array;for(let e of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))Re[`${e}Array`]=Re.DataView;function cs(e,t={},r){let n=Nc(e),o=t&&t.typeEncoders&&t.typeEncoders[n]||Re[n];if(typeof o=="function"){let s=o(e,n,t,r);if(s!=null)return s}let i=Re[n];if(!i)throw new Error(`${ns} unsupported type: ${n}`);return i(e,n,t,r)}function gp(e,t){t.mapSorter&&e.sort(t.mapSorter)}var yp={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0},no=class{constructor(t,r={}){this._pos=0,this.data=t,this.options=r}pos(){return this._pos}done(){return this._pos>=this.data.length}next(){let t=this.data[this._pos],r=Jt[t];if(r===void 0){let n=B[t];if(!n)throw new Error(`${V} no decoder for major type ${t>>>5} (byte 0x${t.toString(16).padStart(2,"0")})`);let o=t&31;r=n(this.data,this._pos,o,this.options)}return this._pos+=r.encodedLength,r}},jr=Symbol.for("DONE"),oo=Symbol.for("BREAK");function xp(e,t,r){let n=[];for(let o=0;o<e.value;o++){let i=Sr(t,r);if(i===oo){if(e.value===1/0)break;throw new Error(`${V} got unexpected break to lengthed array`)}if(i===jr)throw new Error(`${V} found array but not enough entries (got ${o}, expected ${e.value})`);n[o]=i}return n}function wp(e,t,r){let n=r.useMaps===!0,o=n?void 0:{},i=n?new Map:void 0;for(let s=0;s<e.value;s++){let a=Sr(t,r);if(a===oo){if(e.value===1/0)break;throw new Error(`${V} got unexpected break to lengthed map`)}if(a===jr)throw new Error(`${V} found map but not enough entries (got ${s} [no key], expected ${e.value})`);if(n!==!0&&typeof a!="string")throw new Error(`${V} non-string keys not supported (got ${typeof a})`);if(r.rejectDuplicateMapKeys===!0&&(n&&i.has(a)||!n&&a in o))throw new Error(`${V} found repeat map key "${a}"`);let c=Sr(t,r);if(c===jr)throw new Error(`${V} found map but not enough entries (got ${s} [no value], expected ${e.value})`);n?i.set(a,c):o[a]=c}return n?i:o}function Sr(e,t){if(e.done())return jr;let r=e.next();if(r.type===g.break)return oo;if(r.type.terminal)return r.value;if(r.type===g.array)return xp(r,e,t);if(r.type===g.map)return wp(r,e,t);if(r.type===g.tag){if(t.tags&&typeof t.tags[r.value]=="function"){let n=Sr(e,t);return t.tags[r.value](n)}throw new Error(`${V} tag not supported (${r.value})`)}throw new Error("unsupported")}function Ru(e,t){if(!(e instanceof Uint8Array))throw new Error(`${V} data to decode must be a Uint8Array`);t=Object.assign({},yp,t);let r=t.tokenizer||new no(e,t),n=Sr(r,t);if(n===jr)throw new Error(`${V} did not find any content to decode`);if(n===oo)throw new Error(`${V} got unexpected break`);return[n,e.subarray(r.pos())]}function us(e,t){let[r,n]=Ru(e,t);if(n.length>0)throw new Error(`${V} too many terminals, data makes no sense`);return r}var Sp=we("ipns:utils"),_u=H("/ipns/");var vp=0,Ap=18;function Lu(e){let t;if(e.pubKey!=null)try{t=fc(e.pubKey)}catch(r){throw Sp.error(r),r}if(t!=null)return t}function ku(e){let t=H("ipns-signature:");return Et([t,e])}function Ge(e){return"signatureV1"in e?Wt.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}):Wt.encode({pubKey:e.pubKey,signatureV2:e.signatureV2,data:e.data})}function oe(e){let t=Wt.decode(e);if(t.sequence!=null&&(t.sequence=BigInt(t.sequence)),t.ttl!=null&&(t.ttl=BigInt(t.ttl)),t.signatureV2==null||t.data==null)throw new Yt("Missing data or signatureV2");let r=Du(t.data),n=Ip(r.Value),o=G(r.Validity);if(t.value!=null&&t.signatureV1!=null)return Tp(t),{value:n,validityType:Wt.ValidityType.EOL,validity:o,sequence:r.Sequence,ttl:r.TTL,pubKey:t.pubKey,signatureV1:t.signatureV1,signatureV2:t.signatureV2,data:t.data};if(t.signatureV2!=null)return{value:n,validityType:Wt.ValidityType.EOL,validity:o,sequence:r.Sequence,ttl:r.TTL,pubKey:t.pubKey,signatureV2:t.signatureV2,data:t.data};throw new Error("invalid record: does not include signatureV1 or signatureV2")}function Yr(e){return Et([_u,e.bytes])}function ye(e){let t=ce(e.slice(_u.length));if(!io(t,vp)&&!io(t,Ap))throw new je("Multihash in IPNS key was not identity or sha2-256");return t}function Du(e){let t=us(e);if(t.ValidityType===0)t.ValidityType=Wt.ValidityType.EOL;else throw new gr("The validity type is unsupported");return Number.isInteger(t.Sequence)&&(t.Sequence=BigInt(t.Sequence)),Number.isInteger(t.TTL)&&(t.TTL=BigInt(t.TTL)),t}function Ip(e){let t=G(e).trim();if(t.startsWith("/"))return t;try{return`/ipfs/${X.decode(e).toV1().toString()}`}catch{}try{return`/ipfs/${X.parse(t).toV1().toString()}`}catch{}throw new Hn("Value must be a valid content path starting with /")}function Tp(e){if(e.data==null)throw new Gn("Record data is missing");let t=Du(e.data);if(!ot(t.Value,e.value??new Uint8Array(0)))throw new Yt('Field "value" did not match between protobuf and CBOR');if(!ot(t.Validity,e.validity??new Uint8Array(0)))throw new Yt('Field "validity" did not match between protobuf and CBOR');if(t.ValidityType!==e.validityType)throw new Yt('Field "validityType" did not match between protobuf and CBOR');if(t.Sequence!==e.sequence)throw new Yt('Field "sequence" did not match between protobuf and CBOR');if(t.TTL!==e.ttl)throw new Yt('Field "ttl" did not match between protobuf and CBOR')}function io(e,t){return e.code===t}var L1=we("ipns"),k1=60*60*1e9,Cp="/ipns/",D1=Cp.length;var Fu=wo(rs(),1);var so=we("ipns:validator"),Up=1024*10,Np=async(e,t)=>{let r=oe(t),n;try{let o=ku(r.data);n=await e.verify(o,r.signatureV2)}catch{n=!1}if(!n)throw so.error("record signature verification failed"),new Yt("Record signature verification failed");if(r.validityType===Wt.ValidityType.EOL){if(Fu.default.fromString(r.validity).toDate().getTime()<Date.now())throw so.error("record has expired"),new $n("record has expired")}else if(r.validityType!=null)throw so.error("the validity type is unsupported"),new gr("The validity type is unsupported");so("ipns record for %s is valid",r.value)};async function Ou(e,t){if(t.byteLength>Up)throw new zn("The record is too large");let r=ye(e),n;io(r,0)&&(n=Rn(r));let o=oe(t),i=Lu(o)??n;if(i==null)throw new zr("Could not extract public key from IPNS record or routing key");let s=Yr(i.toMultihash());if(!ot(s,e))throw new zr("Embedded public key did not match routing key");await Np(i,t)}var ao=class extends Error{name="InvalidMessageLengthError";code="ERR_INVALID_MESSAGE_LENGTH"};async function*Wr(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)),dr(i)&&(i=i.subarray()),o+=n.decode(i,{stream:!0}),o.length>(t?.maxMessageLength??o.length))throw new ao("Incoming message too long");let s=o.split(r);o=s.pop()??"";for(let a=0;a<s.length;a++)yield JSON.parse(s[a])}o+=n.decode(),o!==""&&(yield JSON.parse(o))}function ie(){let e={};return e.promise=new Promise((t,r)=>{e.resolve=t,e.reject=r}),e}var ls=wo(Vu(),1);var Jr=class extends Error{constructor(t){super(t),this.name="TimeoutError"}},ds=class extends Error{constructor(t){super(),this.name="AbortError",this.message=t}},Ku=e=>globalThis.DOMException===void 0?new ds(e):new DOMException(e),qu=e=>{let t=e.reason===void 0?Ku("This operation was aborted."):e.reason;return t instanceof Error?t:Ku(t)};function hs(e,t){let{milliseconds:r,fallback:n,message:o,customTimers:i={setTimeout,clearTimeout}}=t,s,a,l=new Promise((u,f)=>{if(typeof r!="number"||Math.sign(r)!==1)throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${r}\``);if(t.signal){let{signal:b}=t;b.aborted&&f(qu(b)),a=()=>{f(qu(b))},b.addEventListener("abort",a,{once:!0})}if(r===Number.POSITIVE_INFINITY){e.then(u,f);return}let d=new Jr;s=i.setTimeout.call(void 0,()=>{if(n){try{u(n())}catch(b){f(b)}return}typeof e.cancel=="function"&&e.cancel(),o===!1?u():o instanceof Error?f(o):(d.message=o??`Promise timed out after ${r} milliseconds`,f(d))},r),(async()=>{try{u(await e)}catch(b){f(b)}})()}).finally(()=>{l.clear(),a&&t.signal&&t.signal.removeEventListener("abort",a)});return l.clear=()=>{i.clearTimeout.call(void 0,s),s=void 0},l}function ps(e,t,r){let n=0,o=e.length;for(;o>0;){let i=Math.trunc(o/2),s=n+i;r(e[s],t)<=0?(n=++s,o-=i+1):o=i}return n}var Qr=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=ps(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 tn=class extends ls.default{#t;#r;#e=0;#a;#c;#p=0;#o;#u;#n;#m;#i=0;#f;#s;#g;#w=1n;timeout;constructor(t){if(super(),t={carryoverConcurrencyCount:!1,intervalCap:Number.POSITIVE_INFINITY,interval:0,concurrency:Number.POSITIVE_INFINITY,autoStart:!0,queueClass:Qr,...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.#g=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.#y(),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.#y(),!0):!1}}return!1}#y(){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.#g,...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=hs(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 Jr&&!r.throwOnTimeout){n();return}o(i),this.emit("error",i)}finally{this.#S()}},r),this.emit("add"),this.#l()})}async addAll(t,r){return Promise.all(t.map(async n=>this.add(n,r)))}start(){return this.#s?(this.#s=!1,this.#d(),this):this}pause(){this.#s=!0}clear(){this.#n=new this.#m}async onEmpty(){this.#n.size!==0&&await this.#h("empty")}async onSizeLessThan(t){this.#n.size<t||await this.#h("next",()=>this.#n.size<t)}async onIdle(){this.#i===0&&this.#n.size===0||await this.#h("idle")}async#h(t,r){return new Promise(n=>{let o=()=>{r&&!r()||(this.off(t,o),n())};this.on(t,o)})}get size(){return this.#n.size}sizeBy(t){return this.#n.filter(t).length}get pending(){return this.#i}get isPaused(){return this.#s}};var vr=class extends Error{static name="InvalidRequestError";constructor(t="Invalid request"){super(t),this.name="InvalidRequestError"}},Qt=class extends Error{static name="BadResponseError";constructor(t="Bad response"){super(t),this.name="BadResponseError"}};function _p(e){return e[Symbol.asyncIterator]!=null}function Lp(e){if(_p(e))return(async()=>{for await(let t of e)return t})();for(let t of e)return t}var uo=Lp;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 $u=kp;function Dp(e){return e[Symbol.asyncIterator]!=null}function Fp(e,t){let r=0;if(Dp(e))return async function*(){for await(let c of e)yield t(c,r++)}();let n=$u(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 c of n)yield t(c,r++)}();let a=t;return function*(){yield s;for(let c of n)yield a(c,r++)}()}var fo=Fp;var zu=H("/ipns/");function Hu(e){return ot(e.subarray(0,zu.byteLength),zu)}var lo=class{client;constructor(t){this.client=t}async*findProviders(t,r={}){yield*fo(this.client.getProviders(t,r),n=>({id:n.ID,multiaddrs:n.Addrs??[]}))}async provide(){}async cancelReprovide(){}async put(t,r,n){if(!Hu(t))return;let o=ye(t),i=X.createV1(114,o),s=oe(r);await this.client.putIPNS(i,s,n)}async get(t,r){if(!Hu(t))throw new Bt("Not found");let n=ye(t),o=X.createV1(114,n);try{let i=await this.client.getIPNS(o,r);return Ge(i)}catch(i){throw i.name==="BadResponseError"?new Bt("Not found"):i}}},ho=class{client;constructor(t){this.client=t}async findPeer(t,r={}){let n=await uo(this.client.getPeers(t,r));if(n!=null)return{id:n.ID,multiaddrs:n.Addrs??[]};throw new Bt("Not found")}async*getClosestPeers(t,r={}){}};var pt=we("delegated-routing-v1-http-api-client"),po={concurrentRequests:4,timeout:3e4,cacheTTL:5*60*1e3,cacheName:"delegated-routing-v1-cache"},mo=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 tn({concurrency:r.concurrentRequests??po.concurrentRequests}),this.inFlightRequests=new Map,this.clientUrl=t instanceof URL?t:new URL(t),this.timeout=r.timeout??po.timeout,this.filterAddrs=r.filterAddrs,this.filterProtocols=r.filterProtocols,this.contentRouting=new lo(this),this.peerRouting=new ho(this),this.cacheName=r.cacheName??po.cacheName,this.cacheTTL=r.cacheTTL??po.cacheTTL}get[Ls](){return this.contentRouting}get[ks](){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&&pt("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={}){pt("getProviders starts: %c",t);let n=AbortSignal.timeout(this.timeout),o=$r([this.shutDownController.signal,n,r.signal]);let i=ie(),s=ie();this.httpQueue.add(async()=>(i.resolve(),s.promise));try{await i.promise;let a=new URL(`${this.clientUrl}routing/v1/providers/${t.toString()}`);this.#r(a,r.filterAddrs,r.filterProtocols);let c={headers:{Accept:"application/x-ndjson"},signal:o},l=await this.#e(a.toString(),c);if(l==null)throw new Qt("No response received");if(!l.ok)throw l.status===404?new Bt("No matching records found"):l.status===422?new vr("Request does not conform to schema or semantic constraints"):new Qt(`Unexpected status code: ${l.status}`);if(l.body==null)throw new Qt("Routing response had no body");let u=l.headers.get("Content-Type");if(u==null)throw new Qt("No Content-Type header received");if(u?.startsWith("application/json")){let f=await l.json();for(let d of f.Providers){let b=this.#t(d);b!=null&&(yield b)}}else if(u.includes("application/x-ndjson"))for await(let f of Wr(qn(l.body))){let d=this.#t(f);d!=null&&(yield d)}else throw new Qt(`Unsupported Content-Type: ${u}`)}catch(a){pt.error("getProviders errored:",a)}finally{o.clear(),s.resolve(),pt("getProviders finished: %c",t)}}async*getPeers(t,r={}){pt("getPeers starts: %c",t);let n=AbortSignal.timeout(this.timeout),o=$r([this.shutDownController.signal,n,r.signal]);let i=ie(),s=ie();this.httpQueue.add(async()=>(i.resolve(),s.promise));try{await i.promise;let a=new URL(`${this.clientUrl}routing/v1/peers/${t.toCID().toString()}`);this.#r(a,r.filterAddrs,r.filterProtocols);let c={headers:{Accept:"application/x-ndjson"},signal:o},l=await this.#e(a.toString(),c);if(l.status===404)throw new Bt("No matching records found");if(l.status===422)throw new vr("Request does not conform to schema or semantic constraints");if(l.body==null)throw new Qt("Routing response had no body");if(l.headers.get("Content-Type")==="application/json"){let f=await l.json();for(let d of f.Peers){let b=this.#t(d);b!=null&&(yield b)}}else for await(let f of Wr(qn(l.body))){let d=this.#t(f);d!=null&&(yield d)}}catch(a){pt.error("getPeers errored:",a)}finally{o.clear(),s.resolve(),pt("getPeers finished: %c",t)}}async getIPNS(t,r={}){pt("getIPNS starts: %s",t);let n=AbortSignal.timeout(this.timeout),o=$r([this.shutDownController.signal,n,r.signal]);let i=ie(),s=ie();this.httpQueue.add(async()=>(i.resolve(),s.promise));let a=`${this.clientUrl}routing/v1/ipns/${t}`;try{await i.promise;let c={headers:{Accept:"application/vnd.ipfs.ipns-record"},signal:o},l=await this.#e(a,c);if(pt("getIPNS GET %s %d",a,l.status),l.status===404)throw new Bt("No matching records found");if(l.status===422)throw new vr("Request does not conform to schema or semantic constraints");if(l.body==null)throw new Qt("GET ipns response had no body");let u=await l.arrayBuffer(),f=new Uint8Array(u,0,u.byteLength);return r.validate!==!1&&await Ou(Yr(t.multihash),f),oe(f)}catch(c){throw pt.error("getIPNS GET %s error:",a,c),c}finally{o.clear(),s.resolve(),pt("getIPNS finished: %s",t)}}async putIPNS(t,r,n={}){pt("putIPNS starts: %c",t);let o=AbortSignal.timeout(this.timeout),i=$r([this.shutDownController.signal,o,n.signal]);let s=ie(),a=ie();this.httpQueue.add(async()=>(s.resolve(),a.promise));let c=`${this.clientUrl}routing/v1/ipns/${t}`;try{await s.promise;let l=Ge(r),u={method:"PUT",headers:{"Content-Type":"application/vnd.ipfs.ipns-record"},body:l,signal:i},f=await this.#e(c,u);if(pt("putIPNS PUT %s %d",c,f.status),f.status!==200)throw new Qt("PUT ipns response had status other than 200")}catch(l){throw pt.error("putIPNS PUT %s error:",c,l.stack),l}finally{i.clear(),a.resolve(),pt("putIPNS finished: %c",t)}}#t(t){try{let r=[],n=t.Addrs?.map(ze)??[];return t.Protocols!=null&&r.push(...t.Protocols),t.Protocol!=null&&(r.push(t.Protocol),delete t.Protocol),{...t,Schema:"peer",ID:hc(t.ID),Addrs:n,Protocols:r}}catch(r){pt.error("could not conform record to peer schema",r)}}#r(t,r,n){if(r!=null||this.filterAddrs!=null){let o=r?.join(",")??this.filterAddrs?.join(",")??"";o!==""&&t.searchParams.set("filter-addrs",o)}if(n!=null||this.filterProtocols!=null){let o=n?.join(",")??this.filterProtocols?.join(",")??"";o!==""&&t.searchParams.set("filter-protocols",o)}}async#e(t,r){let n=r.method??"GET",o=`${n}-${t}`;if(n==="GET"){let c=await this.cache?.match(t);if(c!=null){if(parseInt(c.headers.get("x-cache-expires")??"0",10)>Date.now())return pt("returning cached response for %s",o),c;await this.cache?.delete(t)}}let i=this.inFlightRequests.get(o);if(i!=null){let c=await i;return pt("deduplicating outgoing request for %s",o),c.clone()}let s=fetch(t,r).then(async c=>{if(this.cache!=null&&c.ok&&n==="GET"){let l=Date.now()+this.cacheTTL,u=new Headers(c.headers);u.set("x-cache-expires",l.toString());let f=new Response(c.clone().body,{status:c.status,statusText:c.statusText,headers:u});await this.cache.put(t,f)}return c}).finally(()=>{this.inFlightRequests.delete(o)});return this.inFlightRequests.set(o,s),await s}};function Gu(e,t={}){return new mo(new URL(e),t)}function go(){return{filterProtocols:["unknown","transport-bitswap","transport-ipfs-gateway-http"],filterAddrs:["https","webtransport","webrtc","webrtc-direct","wss","tls"]}}var Zu=H("/ipns/");function ju(e){return ot(e.subarray(0,Zu.byteLength),Zu)}var ms=class{client;constructor(t,r={}){this.client=Gu(t,r)}async provide(t,r){}async cancelReprovide(t,r){}async*findProviders(t,r){yield*fo(this.client.getProviders(t,r),n=>({id:n.ID,multiaddrs:n.Addrs,protocols:n.Protocols}))}async put(t,r,n){if(!ju(t))return;let o=ye(t),i=X.createV1(114,o),s=oe(r);await this.client.putIPNS(i,s,n)}async get(t,r){if(!ju(t))throw new Bt("Not found");let n=ye(t),o=X.createV1(114,n);try{let i=await this.client.getIPNS(o,r);return Ge(i)}catch(i){throw i.name==="BadResponseError"?new Bt("Not found"):i}}async findPeer(t,r){let n=await uo(this.client.getPeers(t,r));if(n!=null)return{id:n.ID,multiaddrs:n.Addrs??[]};throw new Bt("Not found")}async*getClosestPeers(t,r){}};function Yu(e,t){let r=t??go();return new ms(new URL(e),r)}var Wu="[a-fA-F\\d:]",_e=e=>e&&e.includeBoundaries?`(?:(?<=\\s|^)(?=${Wu})|(?<=${Wu})(?=\\s|$))`:"",te="(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}",at="[a-fA-F\\d]{1,4}",yo=`
|
|
8
4
|
(?:
|
|
9
|
-
(?:${
|
|
10
|
-
(?:${
|
|
11
|
-
(?:${
|
|
12
|
-
(?:${
|
|
13
|
-
(?:${
|
|
14
|
-
(?:${
|
|
15
|
-
(?:${
|
|
16
|
-
(?::(?:(?::${
|
|
5
|
+
(?:${at}:){7}(?:${at}|:)| // 1:2:3:4:5:6:7:: 1:2:3:4:5:6:7:8
|
|
6
|
+
(?:${at}:){6}(?:${te}|:${at}|:)| // 1:2:3:4:5:6:: 1:2:3:4:5:6::8 1:2:3:4:5:6::8 1:2:3:4:5:6::1.2.3.4
|
|
7
|
+
(?:${at}:){5}(?::${te}|(?::${at}){1,2}|:)| // 1:2:3:4:5:: 1:2:3:4:5::7:8 1:2:3:4:5::8 1:2:3:4:5::7:1.2.3.4
|
|
8
|
+
(?:${at}:){4}(?:(?::${at}){0,1}:${te}|(?::${at}){1,3}|:)| // 1:2:3:4:: 1:2:3:4::6:7:8 1:2:3:4::8 1:2:3:4::6:7:1.2.3.4
|
|
9
|
+
(?:${at}:){3}(?:(?::${at}){0,2}:${te}|(?::${at}){1,4}|:)| // 1:2:3:: 1:2:3::5:6:7:8 1:2:3::8 1:2:3::5:6:7:1.2.3.4
|
|
10
|
+
(?:${at}:){2}(?:(?::${at}){0,3}:${te}|(?::${at}){1,5}|:)| // 1:2:: 1:2::4:5:6:7:8 1:2::8 1:2::4:5:6:7:1.2.3.4
|
|
11
|
+
(?:${at}:){1}(?:(?::${at}){0,4}:${te}|(?::${at}){1,6}|:)| // 1:: 1::3:4:5:6:7:8 1::8 1::3:4:5:6:7:1.2.3.4
|
|
12
|
+
(?::(?:(?::${at}){0,5}:${te}|(?::${at}){1,7}|:)) // ::2:3:4:5:6:7:8 ::2:3:4:5:6:7:8 ::8 ::1.2.3.4
|
|
17
13
|
)(?:%[0-9a-zA-Z]{1,})? // %eth0 %1
|
|
18
|
-
`.replace(/\s*\/\/.*$/gm,"").replace(/\n/g,"").trim(),
|
|
14
|
+
`.replace(/\s*\/\/.*$/gm,"").replace(/\n/g,"").trim(),Op=new RegExp(`(?:^${te}$)|(?:^${yo}$)`),Mp=new RegExp(`^${te}$`),Vp=new RegExp(`^${yo}$`),gs=e=>e&&e.exact?Op:new RegExp(`(?:${_e(e)}${te}${_e(e)})|(?:${_e(e)}${yo}${_e(e)})`,"g");gs.v4=e=>e&&e.exact?Mp:new RegExp(`${_e(e)}${te}${_e(e)}`,"g");gs.v6=e=>e&&e.exact?Vp:new RegExp(`${_e(e)}${yo}${_e(e)}`,"g");var ys=gs;function xs(e){let t=(...r)=>e(...r);return Object.defineProperty(t,"name",{value:`functionTimeout(${e.name||"<anonymous>"})`,configurable:!0}),t}function Xu(){return!1}var{toString:Kp}=Object.prototype;function ws(e){return Kp.call(e)==="[object RegExp]"}var Ju={global:"g",ignoreCase:"i",multiline:"m",dotAll:"s",sticky:"y",unicode:"u"};function bs(e,t={}){if(!ws(e))throw new TypeError("Expected a RegExp instance");let r=Object.keys(Ju).map(o=>(typeof t[o]=="boolean"?t[o]:e[o])?Ju[o]:"").join(""),n=new RegExp(t.source||e.source,r);return n.lastIndex=typeof t.lastIndex=="number"?t.lastIndex:e.lastIndex,n}function Es(e,t,{timeout:r}={}){try{return xs(()=>bs(e).test(t),{timeout:r})()}catch(n){if(Xu(n))return!1;throw n}}var qp=15,$p=45,Qu={timeout:400};function Ss(e){return e.length>$p?!1:Es(ys.v6({exact:!0}),e,Qu)}function tf(e){return e.length>qp?!1:Es(ys.v4({exact:!0}),e,Qu)}var ef={http:"80",https:"443",ws:"80",wss:"443"},zp=["http","https","ws","wss"];function rf(e,t){t=t??{};let r=t.defaultDnsType??"dns4",{scheme:n,hostname:o,port:i}=Hp(e),a="/"+[Gp(o,r),Zp(i,n),jp(n)].filter(c=>!!c).reduce((c,l)=>c.concat(l),[]).join("/");return ze(a)}function Hp(e){let[t]=e.split(":");zp.includes(t)||(e="http"+e.substring(t.length));let{protocol:r,hostname:n,port:o}=new URL(e);if(o==null||o===""){let i=Yp(t);i!=null&&(o=i),i==null&&r==="http:"&&(o="80")}return{scheme:t,hostname:n,port:o}}function Gp(e,t){if(!(e==null||e==="")){if(tf(e))return["ip4",e];if(Ss(e))return["ip6",e];if(e[0]==="["){let r=e.substring(1,e.length-1);if(Ss(r))return["ip6",r]}return[t,e]}}function Zp(e,t){if(!(e==null||e===""))return t==="udp"?["udp",e]:["tcp",e]}function jp(e){if(e.match(/^tcp$|^udp$/)==null)return[e]}function Yp(e){if(!(e==null||e===""||ef[e]==null))return ef[e]}var Wp=["https://trustless-gateway.link","https://4everland.io"],Xp=2336;function Jp(e){return e=e.toString(),{id:mc(X.createV1(Xp,$t.digest(H(e)))),multiaddrs:[rf(e)]}}var vs=class{gateways;constructor(t={}){this.gateways=(t.gateways??Wp).map(r=>Jp(r))}async*findProviders(t,r){yield*this.gateways.toSorted(()=>Math.random()>.5?1:-1).map(n=>({...n,protocols:["transport-ipfs-gateway-http"]}))}};function nf(e={}){return new vs(e)}var As=class{libp2p;constructor(t){this.libp2p=t}async provide(t,r){await this.libp2p.contentRouting.provide(t,r)}async cancelReprovide(t,r){await this.libp2p.contentRouting.cancelReprovide(t,r)}async*findProviders(t,r){yield*this.libp2p.contentRouting.findProviders(t,r)}async put(t,r,n){await this.libp2p.contentRouting.put(t,r,n)}async get(t,r){return this.libp2p.contentRouting.get(t,r)}async findPeer(t,r){return this.libp2p.peerRouting.findPeer(t,r)}async*getClosestPeers(t,r){yield*this.libp2p.peerRouting.getClosestPeers(t,r)}};function of(e){return new As(e)}return wf(Qp);})();
|
|
19
15
|
/*! Bundled license information:
|
|
20
16
|
|
|
21
|
-
pvtsutils/build/index.js:
|
|
22
|
-
(*!
|
|
23
|
-
* MIT License
|
|
24
|
-
*
|
|
25
|
-
* Copyright (c) 2017-2022 Peculiar Ventures, LLC
|
|
26
|
-
*
|
|
27
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
28
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
29
|
-
* in the Software without restriction, including without limitation the rights
|
|
30
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
31
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
32
|
-
* furnished to do so, subject to the following conditions:
|
|
33
|
-
*
|
|
34
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
35
|
-
* copies or substantial portions of the Software.
|
|
36
|
-
*
|
|
37
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
38
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
39
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
40
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
41
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
42
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
43
|
-
* SOFTWARE.
|
|
44
|
-
*
|
|
45
|
-
*)
|
|
46
|
-
|
|
47
17
|
@noble/hashes/esm/utils.js:
|
|
48
18
|
(*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
49
19
|
|
|
@@ -62,46 +32,6 @@ pvtsutils/build/index.js:
|
|
|
62
32
|
@noble/curves/esm/ed25519.js:
|
|
63
33
|
(*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
64
34
|
|
|
65
|
-
pvutils/build/utils.es.js:
|
|
66
|
-
(*!
|
|
67
|
-
Copyright (c) Peculiar Ventures, LLC
|
|
68
|
-
*)
|
|
69
|
-
|
|
70
|
-
asn1js/build/index.es.js:
|
|
71
|
-
(*!
|
|
72
|
-
* Copyright (c) 2014, GMO GlobalSign
|
|
73
|
-
* Copyright (c) 2015-2022, Peculiar Ventures
|
|
74
|
-
* All rights reserved.
|
|
75
|
-
*
|
|
76
|
-
* Author 2014-2019, Yury Strozhevsky
|
|
77
|
-
*
|
|
78
|
-
* Redistribution and use in source and binary forms, with or without modification,
|
|
79
|
-
* are permitted provided that the following conditions are met:
|
|
80
|
-
*
|
|
81
|
-
* * Redistributions of source code must retain the above copyright notice, this
|
|
82
|
-
* list of conditions and the following disclaimer.
|
|
83
|
-
*
|
|
84
|
-
* * Redistributions in binary form must reproduce the above copyright notice, this
|
|
85
|
-
* list of conditions and the following disclaimer in the documentation and/or
|
|
86
|
-
* other materials provided with the distribution.
|
|
87
|
-
*
|
|
88
|
-
* * Neither the name of the copyright holder nor the names of its
|
|
89
|
-
* contributors may be used to endorse or promote products derived from
|
|
90
|
-
* this software without specific prior written permission.
|
|
91
|
-
*
|
|
92
|
-
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
93
|
-
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
94
|
-
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
95
|
-
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
|
96
|
-
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
97
|
-
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
98
|
-
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
|
99
|
-
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
100
|
-
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
101
|
-
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
102
|
-
*
|
|
103
|
-
*)
|
|
104
|
-
|
|
105
35
|
@noble/curves/esm/abstract/weierstrass.js:
|
|
106
36
|
(*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
107
37
|
|