@helia/delegated-routing-v1-http-api-client 4.2.0 → 4.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.min.js +3 -3
- package/dist/src/client.d.ts +3 -2
- package/dist/src/client.d.ts.map +1 -1
- package/dist/src/client.js +17 -16
- package/dist/src/client.js.map +1 -1
- package/dist/src/index.d.ts +14 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js.map +1 -1
- package/package.json +1 -1
- package/src/client.ts +21 -17
- package/src/index.ts +16 -1
package/dist/index.min.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
(function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.HeliaDelegatedRoutingV1HttpApiClient = factory()}(typeof self !== 'undefined' ? self : this, function () {
|
|
2
|
-
"use strict";var HeliaDelegatedRoutingV1HttpApiClient=(()=>{var Uf=Object.create;var Cn=Object.defineProperty;var Rf=Object.getOwnPropertyDescriptor;var _f=Object.getOwnPropertyNames;var Lf=Object.getPrototypeOf,Vf=Object.prototype.hasOwnProperty;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,$=g.time,A=g.nano,S=((A<0||a<=A)&&(A-=(D=Math.floor(A/a))*a,$+=D,D=1),N%e);return($<-i||i<$||S)&&((v=f($/o))&&(N+=v*e,$-=v*o),(R=E($)).setUTCFullYear(S+R.getUTCFullYear()),R=($=+R)+(v=f((N-=S)/e))*o,v&&-i<=R&&R<=i&&(N-=v*e,$=R),D=1),D&&(g.year=N,g.time=$,g.nano=A),g}function E(g){var v=new Date(0);return v.setTime(g),v}function C(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,$){return function(S,m){var B=d(this);S=S||new Array(8),F(S,m|=0);var P=Math.floor(B.time/1e3),B=B.year*(t*r/e),p=f(B/s)+f(P/s),B=B%s+P%s,P=Math.floor(B/s);return P&&(p+=P,B-=P*s),A(S,m+N,p),A(S,m+$,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 T(g,v,D,R,N,$){return function(S,m){F(S,m|=0);var p=A(S,m+N);return C(A(S,m+$),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 V(g){return(9<g?"":"0")+(0|g)}function U(g,v){return(c+(0|g)).substr(-v)}}()});var mf=Ai((sv,ga)=>{"use strict";var Xp=Object.prototype.hasOwnProperty,Te="~";function An(){}Object.create&&(An.prototype=Object.create(null),new An().__proto__||(Te=!1));function Qp(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 Qp(t,n||r,o),s=Te?Te+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 xi(r,e){--r._eventsCount===0?r._events=new An:delete r._events[e]}function Se(){this._events=new An,this._eventsCount=0}Se.prototype.eventNames=function(){var e=[],t,n;if(this._eventsCount===0)return e;for(n in t=this._events)Xp.call(t,n)&&e.push(Te?n.slice(1):n);return Object.getOwnPropertySymbols?e.concat(Object.getOwnPropertySymbols(t)):e};Se.prototype.listeners=function(e){var t=Te?Te+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};Se.prototype.listenerCount=function(e){var t=Te?Te+e:e,n=this._events[t];return n?n.fn?1:n.length:0};Se.prototype.emit=function(e,t,n,o,i,s){var a=Te?Te+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};Se.prototype.on=function(e,t,n){return pf(this,e,t,n,!1)};Se.prototype.once=function(e,t,n){return pf(this,e,t,n,!0)};Se.prototype.removeListener=function(e,t,n,o){var i=Te?Te+e:e;if(!this._events[i])return this;if(!t)return xi(this,i),this;var s=this._events[i];if(s.fn)s.fn===t&&(!o||s.once)&&(!n||s.context===n)&&xi(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:xi(this,i)}return this};Se.prototype.removeAllListeners=function(e){var t;return e?(t=Te?Te+e:e,this._events[t]&&xi(this,t)):(this._events=new An,this._eventsCount=0),this};Se.prototype.off=Se.prototype.removeListener;Se.prototype.addListener=Se.prototype.on;Se.prefixed=Te;Se.EventEmitter=Se;typeof ga<"u"&&(ga.exports=Se)});var sm={};ke(sm,{createDelegatedRoutingV1HttpApiClient:()=>im});var Na=Symbol.for("@libp2p/content-routing");var Si=Symbol.for("@libp2p/peer-id");var Ua=Symbol.for("@libp2p/peer-routing");var ve=class extends Error{static name="InvalidParametersError";constructor(e="Invalid parameters"){super(e),this.name="InvalidParametersError"}},or=class extends Error{static name="InvalidPublicKeyError";constructor(e="Invalid public key"){super(e),this.name="InvalidPublicKeyError"}};var nt=class extends Error{static name="NotFoundError";constructor(e="Not found"){super(e),this.name="NotFoundError"}};var ir=class extends Error{static name="InvalidMultihashError";constructor(e="Invalid Multihash"){super(e),this.name="InvalidMultihashError"}};var sr=class extends Error{static name="UnsupportedKeyTypeError";constructor(e="Unsupported key type"){super(e),this.name="UnsupportedKeyTypeError"}};var ar=(r,...e)=>{try{[...e]}catch{}};var Ni={};ke(Ni,{base32:()=>ze,base32hex:()=>zf,base32hexpad:()=>Gf,base32hexpadupper:()=>Zf,base32hexupper:()=>jf,base32pad:()=>Kf,base32padupper:()=>qf,base32upper:()=>$f,base32z:()=>Wf});var dm=new Uint8Array(0);function Ra(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 ft(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 _a(r){return new TextEncoder().encode(r)}function La(r){return new TextDecoder().decode(r)}function Ff(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,C=I.length;E!==C&&I[E]===0;)E++,w++;for(var x=(C-E)*u+1>>>0,T=new Uint8Array(x);E!==C;){for(var F=I[E],V=0,U=x-1;(F!==0||V<d)&&U!==-1;U--,V++)F+=256*T[U]>>>0,T[U]=F%a>>>0,F=F/a>>>0;if(F!==0)throw new Error("Non-zero carry");d=V,E++}for(var g=x-d;g!==x&&T[g]===0;)g++;for(var v=c.repeat(w);g<x;++g)v+=r.charAt(T[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 C=(I.length-w)*f+1>>>0,x=new Uint8Array(C);I[w];){var T=t[I.charCodeAt(w)];if(T===255)return;for(var F=0,V=C-1;(T!==0||F<E)&&V!==-1;V--,F++)T+=a*x[V]>>>0,x[V]=T%256>>>0,T=T/256>>>0;if(T!==0)throw new Error("Non-zero carry");E=F,w++}if(I[w]!==" "){for(var U=C-E;U!==C&&x[U]===0;)U++;for(var g=new Uint8Array(d+(C-U)),v=d;U!==C;)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 Df=Ff,Of=Df,Pa=Of;var Ii=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")}},ki=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 Fa(this,e)}},Ci=class{decoders;constructor(e){this.decoders=e}or(e){return Fa(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 Fa(r,e){return new Ci({...r.decoders??{[r.prefix]:r},...e.decoders??{[e.prefix]:e}})}var Ti=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 Ii(e,t,n),this.decoder=new ki(e,t,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};function cr({name:r,prefix:e,encode:t,decode:n}){return new Ti(r,e,t,n)}function kt({name:r,prefix:e,alphabet:t}){let{encode:n,decode:o}=Pa(t,r);return cr({prefix:e,name:r,encode:n,decode:i=>ft(o(i))})}function Mf(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 Hf(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 cr({prefix:e,name:r,encode(o){return Hf(o,n,t)},decode(o){return Mf(o,n,t,r)}})}var ze=se({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),$f=se({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Kf=se({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),qf=se({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),zf=se({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),jf=se({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Gf=se({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Zf=se({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Wf=se({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Ui={};ke(Ui,{base58btc:()=>te,base58flickr:()=>Jf});var te=kt({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Jf=kt({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var _i={};ke(_i,{base64:()=>Ri,base64pad:()=>Yf,base64url:()=>Xf,base64urlpad:()=>Qf});var Ri=se({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Yf=se({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Xf=se({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Qf=se({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});function eh(r,e){try{if(typeof r=="string"&&r.length>0)return th(r);if(typeof r=="number"&&isFinite(r))return e?.long?nh(r):rh(r);throw new Error("Value is not a string or number.")}catch(t){let n=oh(t)?`${t.message}. value=${JSON.stringify(r)}`:"An unknown error has occured.";throw new Error(n)}}function th(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 Un=eh;function rh(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 nh(r){let e=Math.abs(r);return e>=864e5?Nn(r,e,864e5,"day"):e>=36e5?Nn(r,e,36e5,"hour"):e>=6e4?Nn(r,e,6e4,"minute"):e>=1e3?Nn(r,e,1e3,"second"):`${r} ms`}function Nn(r,e,t,n){let o=e>=t*1.5;return`${Math.round(r/t)} ${n}${o?"s":""}`}function oh(r){return typeof r=="object"&&r!==null&&"message"in r}function Li(r){t.debug=t,t.default=t,t.coerce=c,t.disable=i,t.enable=o,t.enabled=s,t.humanize=Un,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,C=Number(new Date),x=C-(l||C);E.diff=x,E.prev=l,E.curr=C,l=C,d[0]=t.coerce(d[0]),typeof d[0]!="string"&&d.unshift("%O");let T=0;d[0]=d[0].replace(/%([a-zA-Z%])/g,(V,U)=>{if(V==="%%")return"%";T++;let g=t.formatters[U];if(typeof g=="function"){let v=d[T];V=g.call(E,v),d.splice(T,1),T--}return V}),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 Rn=fh(),ih=["#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 sh(){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 ah(r){if(r[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+r[0]+(this.useColors?"%c ":" ")+"+"+Un(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 ch=console.debug??console.log??(()=>{});function uh(r){try{r?Rn?.setItem("debug",r):Rn?.removeItem("debug")}catch{}}function lh(){let r;try{r=Rn?.getItem("debug")}catch{}return!r&&typeof globalThis.process<"u"&&"env"in globalThis.process&&(r=globalThis.process.env.DEBUG),r}function fh(){try{return localStorage}catch{}}function hh(r){r.j=function(e){try{return JSON.stringify(e)}catch(t){return"[UnexpectedJSONParseError]: "+t.message}}}var Da=Li({formatArgs:ah,save:uh,load:lh,useColors:sh,setupFormatters:hh,colors:ih,storage:Rn,log:ch});var Ue=Da;Ue.formatters.b=r=>r==null?"undefined":te.baseEncode(r);Ue.formatters.t=r=>r==null?"undefined":ze.baseEncode(r);Ue.formatters.m=r=>r==null?"undefined":Ri.baseEncode(r);Ue.formatters.p=r=>r==null?"undefined":r.toString();Ue.formatters.c=r=>r==null?"undefined":r.toString();Ue.formatters.k=r=>r==null?"undefined":r.toString();Ue.formatters.a=r=>r==null?"undefined":r.toString();Ue.formatters.e=r=>r==null?"undefined":Oa(r.stack)??Oa(r.message)??r.toString();function dh(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 Ct(r){let e=dh(`${r}:trace`);return Ue.enabled(`${r}:trace`)&&Ue.names.map(t=>t.toString()).find(t=>t.includes(":trace"))!=null&&(e=Ue(`${r}:trace`)),Object.assign(Ue(r),{error:Ue(`${r}:error`),trace:e})}function Oa(r){if(r!=null&&(r=r.trim(),r.length!==0))return r}var Vi={};ke(Vi,{base36:()=>ur,base36upper:()=>ph});var ur=kt({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),ph=kt({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var mh=$a,Ma=128,gh=127,yh=~gh,wh=Math.pow(2,31);function $a(r,e,t){e=e||[],t=t||0;for(var n=t;r>=wh;)e[t++]=r&255|Ma,r/=128;for(;r&yh;)e[t++]=r&255|Ma,r>>>=7;return e[t]=r|0,$a.bytes=t-n+1,e}var xh=Pi,bh=128,Ha=127;function Pi(r,n){var t=0,n=n||0,o=0,i=n,s,a=r.length;do{if(i>=a)throw Pi.bytes=0,new RangeError("Could not decode varint");s=r[i++],t+=o<28?(s&Ha)<<o:(s&Ha)*Math.pow(2,o),o+=7}while(s>=bh);return Pi.bytes=i-n,t}var vh=Math.pow(2,7),Eh=Math.pow(2,14),Bh=Math.pow(2,21),Ah=Math.pow(2,28),Sh=Math.pow(2,35),Ih=Math.pow(2,42),kh=Math.pow(2,49),Ch=Math.pow(2,56),Th=Math.pow(2,63),Nh=function(r){return r<vh?1:r<Eh?2:r<Bh?3:r<Ah?4:r<Sh?5:r<Ih?6:r<kh?7:r<Ch?8:r<Th?9:10},Uh={encode:mh,decode:xh,encodingLength:Nh},Rh=Uh,Kr=Rh;function qr(r,e=0){return[Kr.decode(r,e),Kr.decode.bytes]}function lr(r,e,t=0){return Kr.encode(r,e,t),e}function fr(r){return Kr.encodingLength(r)}function je(r,e){let t=e.byteLength,n=fr(r),o=n+fr(t),i=new Uint8Array(o+t);return lr(r,i,0),lr(t,i,n),i.set(e,o),new hr(r,t,e,i)}function ht(r){let e=ft(r),[t,n]=qr(e),[o,i]=qr(e.subarray(n)),s=e.subarray(n+i);if(s.byteLength!==o)throw new Error("Incorrect length");return new hr(t,o,s,e)}function Ka(r,e){if(r===e)return!0;{let t=e;return r.code===t.code&&r.size===t.size&&t.bytes instanceof Uint8Array&&Ra(r.bytes,t.bytes)}}var hr=class{code;size;digest;bytes;constructor(e,t,n,o){this.code=e,this.size=t,this.digest=n,this.bytes=o}};function qa(r,e){let{bytes:t,version:n}=r;switch(n){case 0:return Lh(t,Fi(r),e??te.encoder);default:return Vh(t,Fi(r),e??ze.encoder)}}var za=new WeakMap;function Fi(r){let e=za.get(r);if(e==null){let t=new Map;return za.set(r,t),t}return e}var ie=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!==zr)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==Ph)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=je(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&&Ka(e.multihash,n.multihash)}toString(e){return qa(this,e)}toJSON(){return{"/":qa(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??ja(n,o,i.bytes))}else if(t[Fh]===!0){let{version:n,multihash:o,code:i}=t,s=ht(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!==zr)throw new Error(`Version 0 CID must use dag-pb (code: ${zr}) block encoding`);return new r(e,t,n,n.bytes)}case 1:{let o=ja(e,t,n.bytes);return new r(e,t,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return r.create(0,zr,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=ft(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 hr(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]=qr(e.subarray(t));return t+=h,l},o=n(),i=zr;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]=_h(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 Fi(i).set(n,e),i}};function _h(r,e){switch(r[0]){case"Q":{let t=e??te;return[te.prefix,t.decode(`${te.prefix}${r}`)]}case te.prefix:{let t=e??te;return[te.prefix,t.decode(r)]}case ze.prefix:{let t=e??ze;return[ze.prefix,t.decode(r)]}case ur.prefix:{let t=e??ur;return[ur.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 Lh(r,e,t){let{prefix:n}=t;if(n!==te.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 Vh(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 zr=112,Ph=18;function ja(r,e,t){let n=fr(r),o=n+fr(e),i=new Uint8Array(o+t.byteLength);return lr(r,i,0),lr(e,i,n),i.set(t,o),i}var Fh=Symbol.for("@ipld/js-cid/CID");var Di={};ke(Di,{identity:()=>dt});var Ga=0,Dh="identity",Za=ft;function Oh(r){return je(Ga,Za(r))}var dt={code:Ga,name:Dh,encode:Za,digest:Oh};function ue(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 Wa(r){if(!Number.isSafeInteger(r)||r<0)throw new Error(`positive integer expected, not ${r}`)}function Mh(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}function dr(r,...e){if(!Mh(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 Ja(r){if(typeof r!="function"||typeof r.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");Wa(r.outputLen),Wa(r.blockLen)}function pr(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 Ya(r,e){dr(r);let t=e.outputLen;if(r.length<t)throw new Error(`digestInto() expects output buffer of length at least ${t}`)}var zt=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;var Ln=r=>new DataView(r.buffer,r.byteOffset,r.byteLength),Ge=(r,e)=>r<<32-e|r>>>e;var Jm=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function Xa(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=Xa(r)),dr(r),r}function Oi(...r){let e=0;for(let n=0;n<r.length;n++){let o=r[n];dr(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 mr=class{clone(){return this._cloneInto()}},Ym={}.toString;function Vn(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 Pn(r=32){if(zt&&typeof zt.getRandomValues=="function")return zt.getRandomValues(new Uint8Array(r));if(zt&&typeof zt.randomBytes=="function")return zt.randomBytes(r);throw new Error("crypto.getRandomValues must be defined")}function Hh(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 Qa=(r,e,t)=>r&e^~r&t,ec=(r,e,t)=>r&e^r&t^e&t,gr=class extends mr{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=Ln(this.buffer)}update(e){pr(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=Ln(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){pr(this),Ya(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;Hh(n,o-8,BigInt(this.length*8),i),this.process(n,0);let a=Ln(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 Fn=BigInt(4294967295),Mi=BigInt(32);function tc(r,e=!1){return e?{h:Number(r&Fn),l:Number(r>>Mi&Fn)}:{h:Number(r>>Mi&Fn)|0,l:Number(r&Fn)|0}}function $h(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}=tc(r[o],e);[t[o],n[o]]=[i,s]}return[t,n]}var Kh=(r,e)=>BigInt(r>>>0)<<Mi|BigInt(e>>>0),qh=(r,e,t)=>r>>>t,zh=(r,e,t)=>r<<32-t|e>>>t,jh=(r,e,t)=>r>>>t|e<<32-t,Gh=(r,e,t)=>r<<32-t|e>>>t,Zh=(r,e,t)=>r<<64-t|e>>>t-32,Wh=(r,e,t)=>r>>>t-32|e<<64-t,Jh=(r,e)=>e,Yh=(r,e)=>r,Xh=(r,e,t)=>r<<t|e>>>32-t,Qh=(r,e,t)=>e<<t|r>>>32-t,ed=(r,e,t)=>e<<t-32|r>>>64-t,td=(r,e,t)=>r<<t-32|e>>>64-t;function rd(r,e,t,n){let o=(e>>>0)+(n>>>0);return{h:r+t+(o/2**32|0)|0,l:o|0}}var nd=(r,e,t)=>(r>>>0)+(e>>>0)+(t>>>0),od=(r,e,t,n)=>e+t+n+(r/2**32|0)|0,id=(r,e,t,n)=>(r>>>0)+(e>>>0)+(t>>>0)+(n>>>0),sd=(r,e,t,n,o)=>e+t+n+o+(r/2**32|0)|0,ad=(r,e,t,n,o)=>(r>>>0)+(e>>>0)+(t>>>0)+(n>>>0)+(o>>>0),cd=(r,e,t,n,o,i)=>e+t+n+o+i+(r/2**32|0)|0;var ud={fromBig:tc,split:$h,toBig:Kh,shrSH:qh,shrSL:zh,rotrSH:jh,rotrSL:Gh,rotrBH:Zh,rotrBL:Wh,rotr32H:Jh,rotr32L:Yh,rotlSH:Xh,rotlSL:Qh,rotlBH:ed,rotlBL:td,add:rd,add3L:nd,add3H:od,add4L:id,add4H:sd,add5H:cd,add5L:ad},K=ud;var[ld,fd]=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))),Nt=new Uint32Array(80),Ut=new Uint32Array(80),Hi=class extends gr{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)Nt[x]=e.getUint32(t),Ut[x]=e.getUint32(t+=4);for(let x=16;x<80;x++){let T=Nt[x-15]|0,F=Ut[x-15]|0,V=K.rotrSH(T,F,1)^K.rotrSH(T,F,8)^K.shrSH(T,F,7),U=K.rotrSL(T,F,1)^K.rotrSL(T,F,8)^K.shrSL(T,F,7),g=Nt[x-2]|0,v=Ut[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,Ut[x-7],Ut[x-16]),$=K.add4H(N,V,D,Nt[x-7],Nt[x-16]);Nt[x]=$|0,Ut[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:C}=this;for(let x=0;x<80;x++){let T=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),V=l&b^~l&w,U=h&I^~h&d,g=K.add5L(C,F,U,fd[x],Ut[x]),v=K.add5H(g,E,T,V,ld[x],Nt[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),$=n&i^n&a^i&a,A=o&s^o&c^s&c;E=w|0,C=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,$),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:C}=K.add(this.Hh|0,this.Hl|0,E|0,C|0),this.set(n,o,i,s,a,c,f,u,l,h,b,I,w,d,E,C)}roundClean(){Nt.fill(0),Ut.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 rc=Vn(()=>new Hi);var On={};ke(On,{aInRange:()=>Re,abool:()=>Ze,abytes:()=>yr,bitGet:()=>yd,bitLen:()=>ji,bitMask:()=>Zr,bitSet:()=>wd,bytesToHex:()=>mt,bytesToNumberBE:()=>gt,bytesToNumberLE:()=>_t,concatBytes:()=>yt,createHmacDrbg:()=>Gi,ensureBytes:()=>ae,equalBytes:()=>md,hexToBytes:()=>Gt,hexToNumber:()=>zi,inRange:()=>Gr,isBytes:()=>Rt,memoized:()=>Wt,notImplemented:()=>bd,numberToBytesBE:()=>Lt,numberToBytesLE:()=>Zt,numberToHexUnpadded:()=>jt,numberToVarBytesBE:()=>pd,utf8ToBytes:()=>gd,validateObject:()=>ot});var qi=BigInt(0),Dn=BigInt(1),hd=BigInt(2);function Rt(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}function yr(r){if(!Rt(r))throw new Error("Uint8Array expected")}function Ze(r,e){if(typeof e!="boolean")throw new Error(`${r} must be valid boolean, got "${e}".`)}var dd=Array.from({length:256},(r,e)=>e.toString(16).padStart(2,"0"));function mt(r){yr(r);let e="";for(let t=0;t<r.length;t++)e+=dd[r[t]];return e}function jt(r){let e=r.toString(16);return e.length&1?`0${e}`:e}function zi(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return BigInt(r===""?"0":`0x${r}`)}var pt={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function nc(r){if(r>=pt._0&&r<=pt._9)return r-pt._0;if(r>=pt._A&&r<=pt._F)return r-(pt._A-10);if(r>=pt._a&&r<=pt._f)return r-(pt._a-10)}function Gt(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=nc(r.charCodeAt(i)),a=nc(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 gt(r){return zi(mt(r))}function _t(r){return yr(r),zi(mt(Uint8Array.from(r).reverse()))}function Lt(r,e){return Gt(r.toString(16).padStart(e*2,"0"))}function Zt(r,e){return Lt(r,e).reverse()}function pd(r){return Gt(jt(r))}function ae(r,e,t){let n;if(typeof e=="string")try{n=Gt(e)}catch(i){throw new Error(`${r} must be valid hex string, got "${e}". Cause: ${i}`)}else if(Rt(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 yt(...r){let e=0;for(let n=0;n<r.length;n++){let o=r[n];yr(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 md(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 gd(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}var $i=r=>typeof r=="bigint"&&qi<=r;function Gr(r,e,t){return $i(r)&&$i(e)&&$i(t)&&e<=r&&r<t}function Re(r,e,t,n){if(!Gr(e,t,n))throw new Error(`expected valid ${r}: ${t} <= n < ${n}, got ${typeof e} ${e}`)}function ji(r){let e;for(e=0;r>qi;r>>=Dn,e+=1);return e}function yd(r,e){return r>>BigInt(e)&Dn}function wd(r,e,t){return r|(t?Dn:qi)<<BigInt(e)}var Zr=r=>(hd<<BigInt(r-1))-Dn,Ki=r=>new Uint8Array(r),oc=r=>Uint8Array.from(r);function Gi(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=Ki(r),o=Ki(r),i=0,s=()=>{n.fill(1),o.fill(0),i=0},a=(...l)=>t(o,n,...l),c=(l=Ki())=>{o=a(oc([0]),l),n=a(),l.length!==0&&(o=a(oc([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 yt(...h)};return(l,h)=>{s(),c(l);let b;for(;!(b=h(f()));)c();return s(),b}}var xd={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"||Rt(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 ot(r,e,t={}){let n=(o,i,s)=>{let a=xd[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 bd=()=>{throw new Error("not implemented")};function Wt(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 le=BigInt(0),re=BigInt(1),Jt=BigInt(2),vd=BigInt(3),Zi=BigInt(4),ic=BigInt(5),sc=BigInt(8),Ed=BigInt(9),Bd=BigInt(16);function X(r,e){let t=r%e;return t>=le?t:e+t}function Ad(r,e,t){if(t<=le||e<le)throw new Error("Expected power/modulo > 0");if(t===re)return le;let n=re;for(;e>le;)e&re&&(n=n*r%t),r=r*r%t,e>>=re;return n}function ne(r,e,t){let n=r;for(;e-- >le;)n*=n,n%=t;return n}function Mn(r,e){if(r===le||e<=le)throw new Error(`invert: expected positive integers, got n=${r} mod=${e}`);let t=X(r,e),n=e,o=le,i=re,s=re,a=le;for(;t!==le;){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!==re)throw new Error("invert: does not exist");return X(o,e)}function Sd(r){let e=(r-re)/Jt,t,n,o;for(t=r-re,n=0;t%Jt===le;t/=Jt,n++);for(o=Jt;o<r&&Ad(o,e,r)!==r-re;o++);if(n===1){let s=(r+re)/Zi;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+re)/Jt;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,re<<BigInt(f-b-1));u=a.sqr(I),l=a.mul(l,I),h=a.mul(h,u),f=b}return l}}function Id(r){if(r%Zi===vd){let e=(r+re)/Zi;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%sc===ic){let e=(r-ic)/sc;return function(n,o){let i=n.mul(o,Jt),s=n.pow(i,e),a=n.mul(o,s),c=n.mul(n.mul(a,Jt),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%Bd,Sd(r)}var ac=(r,e)=>(X(r,e)&re)===re,kd=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Wi(r){let e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},t=kd.reduce((n,o)=>(n[o]="function",n),e);return ot(r,t)}function Cd(r,e,t){if(t<le)throw new Error("Expected power > 0");if(t===le)return r.ONE;if(t===re)return e;let n=r.ONE,o=e;for(;t>le;)t&re&&(n=r.mul(n,o)),o=r.sqr(o),t>>=re;return n}function Td(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 Ji(r,e){let t=e!==void 0?e:r.toString(2).length,n=Math.ceil(t/8);return{nBitLength:t,nByteLength:n}}function Vt(r,e,t=!1,n={}){if(r<=le)throw new Error(`Expected Field ORDER > 0, got ${r}`);let{nBitLength:o,nByteLength:i}=Ji(r,e);if(i>2048)throw new Error("Field lengths over 2048 bytes are not supported");let s=Id(r),a=Object.freeze({ORDER:r,BITS:o,BYTES:i,MASK:Zr(o),ZERO:le,ONE:re,create:c=>X(c,r),isValid:c=>{if(typeof c!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof c}`);return le<=c&&c<r},is0:c=>c===le,isOdd:c=>(c&re)===re,neg:c=>X(-c,r),eql:(c,f)=>c===f,sqr:c=>X(c*c,r),add:(c,f)=>X(c+f,r),sub:(c,f)=>X(c-f,r),mul:(c,f)=>X(c*f,r),pow:(c,f)=>Cd(a,c,f),div:(c,f)=>X(c*Mn(f,r),r),sqrN:c=>c*c,addN:(c,f)=>c+f,subN:(c,f)=>c-f,mulN:(c,f)=>c*f,inv:c=>Mn(c,r),sqrt:n.sqrt||(c=>s(a,c)),invertBatch:c=>Td(a,c),cmov:(c,f,u)=>u?f:c,toBytes:c=>t?Zt(c,i):Lt(c,i),fromBytes:c=>{if(c.length!==i)throw new Error(`Fp.fromBytes: expected ${i}, got ${c.length}`);return t?_t(c):gt(c)}});return Object.freeze(a)}function cc(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 Yi(r){let e=cc(r);return e+Math.ceil(e/2)}function uc(r,e,t=!1){let n=r.length,o=cc(e),i=Yi(e);if(n<16||n<i||n>1024)throw new Error(`expected ${i}-1024 bytes of input, got ${n}`);let s=t?gt(r):_t(r),a=X(s,e-re)+re;return t?Zt(a,o):Lt(a,o)}var Ud=BigInt(0),Xi=BigInt(1),Qi=new WeakMap,lc=new WeakMap;function Hn(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>Ud;)s&Xi&&(a=a.add(c)),c=c.double(),s>>=Xi;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+=Xi);let C=d,x=d+Math.abs(E)-1,T=w%2!==0,F=E<0;E===0?l=l.add(t(T,s[C])):u=u.add(t(F,s[x]))}return{p:u,f:l}},wNAFCached(i,s,a){let c=lc.get(i)||1,f=Qi.get(i);return f||(f=this.precomputeWindow(i,c),c!==1&&Qi.set(i,a(f))),this.wNAF(c,f,s)},setWindowSize(i,s){n(s),lc.set(i,s),Qi.delete(i)}}}function $n(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=ji(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 Wr(r){return Wi(r.Fp),ot(r,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Ji(r.n,r.nBitLength),...r,p:r.Fp.ORDER})}var We=BigInt(0),_e=BigInt(1),Kn=BigInt(2),Rd=BigInt(8),_d={zip215:!0};function Ld(r){let e=Wr(r);return ot(r,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...e})}function fc(r){let e=Ld(r),{Fp:t,n,prehash:o,hash:i,randomBytes:s,nByteLength:a,h:c}=e,f=Kn<<BigInt(a*8)-_e,u=t.create,l=Vt(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:We}}}),b=e.adjustScalarBytes||(m=>m),I=e.domain||((m,p,B)=>{if(Ze("phflag",B),p.length||B)throw new Error("Contexts/pre-hash are not supported");return m});function w(m,p){Re("coordinate "+m,p,We,f)}function d(m){if(!(m instanceof x))throw new Error("ExtendedPoint expected")}let E=Wt((m,p)=>{let{ex:B,ey:P,ez:O}=m,M=m.is0();p==null&&(p=M?Rd:t.inv(O));let q=u(B*p),G=u(P*p),z=u(O*p);if(M)return{x:We,y:_e};if(z!==_e)throw new Error("invZ was invalid");return{x:q,y:G}}),C=Wt(m=>{let{a:p,d:B}=e;if(m.is0())throw new Error("bad point: ZERO");let{ex:P,ey:O,ez:M,et:q}=m,G=u(P*P),z=u(O*O),Y=u(M*M),ee=u(Y*Y),he=u(G*p),de=u(Y*u(he+z)),ye=u(ee+u(B*u(G*z)));if(de!==ye)throw new Error("bad point: equation left != right (1)");let Ie=u(P*O),ce=u(M*q);if(Ie!==ce)throw new Error("bad point: equation left != right (2)");return!0});class x{constructor(p,B,P,O){this.ex=p,this.ey=B,this.ez=P,this.et=O,w("x",p),w("y",B),w("z",P),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:P}=p||{};return w("x",B),w("y",P),new x(B,P,_e,u(B*P))}static normalizeZ(p){let B=t.invertBatch(p.map(P=>P.ez));return p.map((P,O)=>P.toAffine(B[O])).map(x.fromAffine)}static msm(p,B){return $n(x,l,p,B)}_setWindowSize(p){V.setWindowSize(this,p)}assertValidity(){C(this)}equals(p){d(p);let{ex:B,ey:P,ez:O}=this,{ex:M,ey:q,ez:G}=p,z=u(B*G),Y=u(M*O),ee=u(P*G),he=u(q*O);return z===Y&&ee===he}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:P,ez:O}=this,M=u(B*B),q=u(P*P),G=u(Kn*u(O*O)),z=u(p*M),Y=B+P,ee=u(u(Y*Y)-M-q),he=z+q,de=he-G,ye=z-q,Ie=u(ee*de),ce=u(he*ye),Ne=u(ee*ye),lt=u(de*he);return new x(Ie,ce,lt,Ne)}add(p){d(p);let{a:B,d:P}=e,{ex:O,ey:M,ez:q,et:G}=this,{ex:z,ey:Y,ez:ee,et:he}=p;if(B===BigInt(-1)){let Ea=u((M-O)*(Y+z)),Ba=u((M+O)*(Y-z)),Bi=u(Ba-Ea);if(Bi===We)return this.double();let Aa=u(q*Kn*he),Sa=u(G*Kn*ee),Ia=Sa+Aa,ka=Ba+Ea,Ca=Sa-Aa,kf=u(Ia*Bi),Cf=u(ka*Ca),Tf=u(Ia*Ca),Nf=u(Bi*ka);return new x(kf,Cf,Nf,Tf)}let de=u(O*z),ye=u(M*Y),Ie=u(G*P*he),ce=u(q*ee),Ne=u((O+M)*(z+Y)-de-ye),lt=ce-Ie,Hr=ce+Ie,$r=u(ye-B*de),Bf=u(Ne*lt),Af=u(Hr*$r),Sf=u(Ne*$r),If=u(lt*Hr);return new x(Bf,Af,If,Sf)}subtract(p){return this.add(p.negate())}wNAF(p){return V.wNAFCached(this,p,x.normalizeZ)}multiply(p){let B=p;Re("scalar",B,_e,n);let{p:P,f:O}=this.wNAF(B);return x.normalizeZ([P,O])[0]}multiplyUnsafe(p){let B=p;return Re("scalar",B,We,n),B===We?F:this.equals(F)||B===_e?this:this.equals(T)?this.wNAF(B).p:V.unsafeLadder(this,B)}isSmallOrder(){return this.multiplyUnsafe(c).is0()}isTorsionFree(){return V.unsafeLadder(this,n).is0()}toAffine(p){return E(this,p)}clearCofactor(){let{h:p}=e;return p===_e?this:this.multiplyUnsafe(p)}static fromHex(p,B=!1){let{d:P,a:O}=e,M=t.BYTES;p=ae("pointHex",p,M),Ze("zip215",B);let q=p.slice(),G=p[M-1];q[M-1]=G&-129;let z=_t(q),Y=B?f:t.ORDER;Re("pointHex.y",z,We,Y);let ee=u(z*z),he=u(ee-_e),de=u(P*ee-O),{isValid:ye,value:Ie}=h(he,de);if(!ye)throw new Error("Point.fromHex: invalid y coordinate");let ce=(Ie&_e)===_e,Ne=(G&128)!==0;if(!B&&Ie===We&&Ne)throw new Error("Point.fromHex: x=0 and x_0=1");return Ne!==ce&&(Ie=u(-Ie)),x.fromAffine({x:Ie,y:z})}static fromPrivateKey(p){return v(p).point}toRawBytes(){let{x:p,y:B}=this.toAffine(),P=Zt(B,t.BYTES);return P[P.length-1]|=p&_e?128:0,P}toHex(){return mt(this.toRawBytes())}}x.BASE=new x(e.Gx,e.Gy,_e,u(e.Gx*e.Gy)),x.ZERO=new x(We,_e,_e,We);let{BASE:T,ZERO:F}=x,V=Hn(x,a*8);function U(m){return X(m,n)}function g(m){return U(_t(m))}function v(m){let p=a;m=ae("private key",m,p);let B=ae("hashed private key",i(m),2*p),P=b(B.slice(0,p)),O=B.slice(p,2*p),M=g(P),q=T.multiply(M),G=q.toRawBytes();return{head:P,prefix:O,scalar:M,point:q,pointBytes:G}}function D(m){return v(m).pointBytes}function R(m=new Uint8Array,...p){let B=yt(...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:P,scalar:O,pointBytes:M}=v(p),q=R(B.context,P,m),G=T.multiply(q).toRawBytes(),z=R(B.context,G,M,m),Y=U(q+z*O);Re("signature.s",Y,We,n);let ee=yt(G,Zt(Y,t.BYTES));return ae("result",ee,a*2)}let $=_d;function A(m,p,B,P=$){let{context:O,zip215:M}=P,q=t.BYTES;m=ae("signature",m,2*q),p=ae("message",p),M!==void 0&&Ze("zip215",M),o&&(p=o(p));let G=_t(m.slice(q,2*q)),z,Y,ee;try{z=x.fromHex(B,M),Y=x.fromHex(m.slice(0,q),M),ee=T.multiplyUnsafe(G)}catch{return!1}if(!M&&z.isSmallOrder())return!1;let he=R(O,Y.toRawBytes(),z.toRawBytes(),p);return Y.add(z.multiplyUnsafe(he)).subtract(ee).clearCofactor().equals(x.ZERO)}return T._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 es=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),hc=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),bg=BigInt(0),Vd=BigInt(1),dc=BigInt(2),vg=BigInt(3),Pd=BigInt(5),Fd=BigInt(8);function Dd(r){let e=BigInt(10),t=BigInt(20),n=BigInt(40),o=BigInt(80),i=es,a=r*r%i*r%i,c=ne(a,dc,i)*a%i,f=ne(c,Vd,i)*r%i,u=ne(f,Pd,i)*f%i,l=ne(u,e,i)*u%i,h=ne(l,t,i)*l%i,b=ne(h,n,i)*h%i,I=ne(b,o,i)*b%i,w=ne(I,o,i)*b%i,d=ne(w,e,i)*u%i;return{pow_p_5_8:ne(d,dc,i)*r%i,b2:a}}function Od(r){return r[0]&=248,r[31]&=127,r[31]|=64,r}function Md(r,e){let t=es,n=X(e*e*e,t),o=X(n*n*e,t),i=Dd(r*o).pow_p_5_8,s=X(r*n*i,t),a=X(e*s*s,t),c=s,f=X(s*hc,t),u=a===r,l=a===X(-r,t),h=a===X(-r*hc,t);return u&&(s=c),(l||h)&&(s=f),ac(s,t)&&(s=X(-s,t)),{isValid:u||l,value:s}}var Hd=Vt(es,void 0,!0),$d={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:Hd,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:Fd,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:rc,randomBytes:Pn,adjustScalarBytes:Od,uvRatio:Md},pc=fc($d);var qn=32;function mc(r,e,t){return pc.verify(e,t instanceof Uint8Array?t:t.subarray(),r)}var zn=class{type="Ed25519";raw;constructor(e){this.raw=ts(e,qn)}toMultihash(){return dt.digest(jn(this))}toCID(){return ie.createV1(114,this.toMultihash())}toString(){return te.encode(this.toMultihash().bytes).substring(1)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:ue(this.raw,e.raw)}verify(e,t){return mc(this.raw,t,e)}};function rs(r){return r=ts(r,qn),new zn(r)}function ts(r,e){if(r=Uint8Array.from(r??[]),r.length!==e)throw new ve(`Key must be a Uint8Array of length ${e}, got ${r.length}`);return r}function Je(r=0){return new Uint8Array(r)}var qd=Math.pow(2,7),zd=Math.pow(2,14),jd=Math.pow(2,21),ns=Math.pow(2,28),os=Math.pow(2,35),is=Math.pow(2,42),ss=Math.pow(2,49),W=128,Ee=127;function Le(r){if(r<qd)return 1;if(r<zd)return 2;if(r<jd)return 3;if(r<ns)return 4;if(r<os)return 5;if(r<is)return 6;if(r<ss)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function as(r,e,t=0){switch(Le(r)){case 8:e[t++]=r&255|W,r/=128;case 7:e[t++]=r&255|W,r/=128;case 6:e[t++]=r&255|W,r/=128;case 5:e[t++]=r&255|W,r/=128;case 4:e[t++]=r&255|W,r>>>=7;case 3:e[t++]=r&255|W,r>>>=7;case 2:e[t++]=r&255|W,r>>>=7;case 1:{e[t++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return e}function Gd(r,e,t=0){switch(Le(r)){case 8:e.set(t++,r&255|W),r/=128;case 7:e.set(t++,r&255|W),r/=128;case 6:e.set(t++,r&255|W),r/=128;case 5:e.set(t++,r&255|W),r/=128;case 4:e.set(t++,r&255|W),r>>>=7;case 3:e.set(t++,r&255|W),r>>>=7;case 2:e.set(t++,r&255|W),r>>>=7;case 1:{e.set(t++,r&255),r>>>=7;break}default:throw new Error("unreachable")}return e}function cs(r,e){let t=r[e],n=0;if(n+=t&Ee,t<W||(t=r[e+1],n+=(t&Ee)<<7,t<W)||(t=r[e+2],n+=(t&Ee)<<14,t<W)||(t=r[e+3],n+=(t&Ee)<<21,t<W)||(t=r[e+4],n+=(t&Ee)*ns,t<W)||(t=r[e+5],n+=(t&Ee)*os,t<W)||(t=r[e+6],n+=(t&Ee)*is,t<W)||(t=r[e+7],n+=(t&Ee)*ss,t<W))return n;throw new RangeError("Could not decode varint")}function Zd(r,e){let t=r.get(e),n=0;if(n+=t&Ee,t<W||(t=r.get(e+1),n+=(t&Ee)<<7,t<W)||(t=r.get(e+2),n+=(t&Ee)<<14,t<W)||(t=r.get(e+3),n+=(t&Ee)<<21,t<W)||(t=r.get(e+4),n+=(t&Ee)*ns,t<W)||(t=r.get(e+5),n+=(t&Ee)*os,t<W)||(t=r.get(e+6),n+=(t&Ee)*is,t<W)||(t=r.get(e+7),n+=(t&Ee)*ss,t<W))return n;throw new RangeError("Could not decode varint")}function wr(r,e,t=0){return e==null&&(e=Je(Le(r))),e instanceof Uint8Array?as(r,e,t):Gd(r,e,t)}function Yt(r,e=0){return r instanceof Uint8Array?cs(r,e):Zd(r,e)}var us=new Float32Array([-0]),Pt=new Uint8Array(us.buffer);function wc(r,e,t){us[0]=r,e[t]=Pt[0],e[t+1]=Pt[1],e[t+2]=Pt[2],e[t+3]=Pt[3]}function xc(r,e){return Pt[0]=r[e],Pt[1]=r[e+1],Pt[2]=r[e+2],Pt[3]=r[e+3],us[0]}var ls=new Float64Array([-0]),Be=new Uint8Array(ls.buffer);function bc(r,e,t){ls[0]=r,e[t]=Be[0],e[t+1]=Be[1],e[t+2]=Be[2],e[t+3]=Be[3],e[t+4]=Be[4],e[t+5]=Be[5],e[t+6]=Be[6],e[t+7]=Be[7]}function vc(r,e){return Be[0]=r[e],Be[1]=r[e+1],Be[2]=r[e+2],Be[3]=r[e+3],Be[4]=r[e+4],Be[5]=r[e+5],Be[6]=r[e+6],Be[7]=r[e+7],ls[0]}var Wd=BigInt(Number.MAX_SAFE_INTEGER),Jd=BigInt(Number.MIN_SAFE_INTEGER),Pe=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 Xt;if(e<Wd&&e>Jd)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>Ec&&(o=0n,++n>Ec&&(n=0n))),new r(Number(o),Number(n))}static fromNumber(e){if(e===0)return Xt;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):Xt}},Xt=new Pe(0,0);Xt.toBigInt=function(){return 0n};Xt.zzEncode=Xt.zzDecode=function(){return this};Xt.length=function(){return 1};var Ec=4294967296n;function Bc(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 Ac(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 fs(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 Ye(r,e){return RangeError(`index out of range: ${r.pos} + ${e??1} > ${r.len}`)}function Gn(r,e){return(r[e-4]|r[e-3]<<8|r[e-2]<<16|r[e-1]<<24)>>>0}var hs=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,Ye(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 Ye(this,4);return Gn(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw Ye(this,4);return Gn(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw Ye(this,4);let e=xc(this.buf,this.pos);return this.pos+=4,e}double(){if(this.pos+8>this.len)throw Ye(this,4);let e=vc(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 Ye(this,e);return this.pos+=e,t===n?new Uint8Array(0):this.buf.subarray(t,n)}string(){let e=this.bytes();return Ac(e,0,e.length)}skip(e){if(typeof e=="number"){if(this.pos+e>this.len)throw Ye(this,e);this.pos+=e}else do if(this.pos>=this.len)throw Ye(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 Pe(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 Ye(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 Ye(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 Ye(this,8);let e=Gn(this.buf,this.pos+=4),t=Gn(this.buf,this.pos+=4);return new Pe(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=cs(this.buf,this.pos);return this.pos+=Le(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 ds(r){return new hs(r instanceof Uint8Array?r:r.subarray())}function xr(r,e,t){let n=ds(r);return e.decode(n,void 0,t)}var ps={};ke(ps,{base10:()=>Yd});var Yd=kt({prefix:"9",name:"base10",alphabet:"0123456789"});var ms={};ke(ms,{base16:()=>Xd,base16upper:()=>Qd});var Xd=se({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Qd=se({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var gs={};ke(gs,{base2:()=>e0});var e0=se({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var ys={};ke(ys,{base256emoji:()=>i0});var Ic=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}"),t0=Ic.reduce((r,e,t)=>(r[t]=e,r),[]),r0=Ic.reduce((r,e,t)=>{let n=e.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${e}`);return r[n]=t,r},[]);function n0(r){return r.reduce((e,t)=>(e+=t0[t],e),"")}function o0(r){let e=[];for(let t of r){let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);let o=r0[n];if(o==null)throw new Error(`Non-base256emoji character: ${t}`);e.push(o)}return new Uint8Array(e)}var i0=cr({prefix:"\u{1F680}",name:"base256emoji",encode:n0,decode:o0});var ws={};ke(ws,{base8:()=>s0});var s0=se({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var xs={};ke(xs,{identity:()=>a0});var a0=cr({prefix:"\0",name:"identity",encode:r=>La(r),decode:r=>_a(r)});var ry=new TextEncoder,ny=new TextDecoder;var Es={};ke(Es,{sha256:()=>Jr,sha512:()=>l0});function vs({name:r,code:e,encode:t}){return new bs(r,e,t)}var bs=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?je(this.code,t):t.then(n=>je(this.code,n))}else throw Error("Unknown type, must be binary type")}};function Cc(r){return async e=>new Uint8Array(await crypto.subtle.digest(r,e))}var Jr=vs({name:"sha2-256",code:18,encode:Cc("SHA-256")}),l0=vs({name:"sha2-512",code:19,encode:Cc("SHA-512")});var Yr={...xs,...gs,...ws,...ps,...ms,...Ni,...Vi,...Ui,..._i,...ys},my={...Es,...Di};function Nc(r,e,t,n){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:n}}}var Tc=Nc("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),Bs=Nc("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=Je(r.length);for(let t=0;t<r.length;t++)e[t]=r.charCodeAt(t);return e}),f0={utf8:Tc,"utf-8":Tc,hex:Yr.base16,latin1:Bs,ascii:Bs,binary:Bs,...Yr},Zn=f0;function J(r,e="utf8"){let t=Zn[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return t.decoder.decode(`${t.prefix}${r}`)}function As(r){let e=r??8192,t=e>>>1,n,o=e;return function(s){if(s<1||s>t)return Je(s);o+s>e&&(n=Je(e),o=0);let a=n.subarray(o,o+=s);return o&7&&(o=(o|7)+1),a}}var Qt=class{fn;len;next;val;constructor(e,t,n){this.fn=e,this.len=t,this.next=void 0,this.val=n}};function Ss(){}var ks=class{head;tail;len;next;constructor(e){this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}},h0=As();function d0(r){return globalThis.Buffer!=null?Je(r):h0(r)}var Qr=class{len;head;tail;states;constructor(){this.len=0,this.head=new Qt(Ss,0,0),this.tail=this.head,this.states=null}_push(e,t,n){return this.tail=this.tail.next=new Qt(e,t,n),this.len+=t,this}uint32(e){return this.len+=(this.tail=this.tail.next=new Cs((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(Wn,10,Pe.fromNumber(e)):this.uint32(e)}sint32(e){return this.uint32((e<<1^e>>31)>>>0)}uint64(e){let t=Pe.fromBigInt(e);return this._push(Wn,t.length(),t)}uint64Number(e){return this._push(as,Le(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=Pe.fromBigInt(e).zzEncode();return this._push(Wn,t.length(),t)}sint64Number(e){let t=Pe.fromNumber(e).zzEncode();return this._push(Wn,t.length(),t)}sint64String(e){return this.sint64(BigInt(e))}bool(e){return this._push(Is,1,e?1:0)}fixed32(e){return this._push(Xr,4,e>>>0)}sfixed32(e){return this.fixed32(e)}fixed64(e){let t=Pe.fromBigInt(e);return this._push(Xr,4,t.lo)._push(Xr,4,t.hi)}fixed64Number(e){let t=Pe.fromNumber(e);return this._push(Xr,4,t.lo)._push(Xr,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(wc,4,e)}double(e){return this._push(bc,8,e)}bytes(e){let t=e.length>>>0;return t===0?this._push(Is,1,0):this.uint32(t)._push(m0,t,e)}string(e){let t=Bc(e);return t!==0?this.uint32(t)._push(fs,t,e):this._push(Is,1,0)}fork(){return this.states=new ks(this),this.head=this.tail=new Qt(Ss,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 Qt(Ss,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=d0(this.len),n=0;for(;e!=null;)e.fn(e.val,t,n),n+=e.len,e=e.next;return t}};function Is(r,e,t){e[t]=r&255}function p0(r,e,t){for(;r>127;)e[t++]=r&127|128,r>>>=7;e[t]=r}var Cs=class extends Qt{next;constructor(e,t){super(p0,e,t),this.next=void 0}};function Wn(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 Xr(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 m0(r,e,t){e.set(r,t)}globalThis.Buffer!=null&&(Qr.prototype.bytes=function(r){let e=r.length>>>0;return this.uint32(e),e>0&&this._push(g0,e,r),this},Qr.prototype.string=function(r){let e=globalThis.Buffer.byteLength(r);return this.uint32(e),e>0&&this._push(y0,e,r),this});function g0(r,e,t){e.set(r,t)}function y0(r,e,t){r.length<40?fs(r,e,t):e.utf8Write!=null?e.utf8Write(r,t):e.set(J(r),t)}function Ts(){return new Qr}function br(r,e){let t=Ts();return e.encode(r,t,{lengthDelimited:!1}),t.finish()}var vr;(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"})(vr||(vr={}));function Jn(r,e,t,n){return{name:r,type:e,encode:t,decode:n}}function en(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 Jn("enum",vr.VARINT,t,n)}function Er(r,e){return Jn("message",vr.LENGTH_DELIMITED,r,e)}var fe;(function(r){r.RSA="RSA",r.Ed25519="Ed25519",r.secp256k1="secp256k1"})(fe||(fe={}));var Ns;(function(r){r[r.RSA=0]="RSA",r[r.Ed25519=1]="Ed25519",r[r.secp256k1=2]="secp256k1"})(Ns||(Ns={}));(function(r){r.codec=()=>en(Ns)})(fe||(fe={}));var it;(function(r){let e;r.codec=()=>(e==null&&(e=Er((t,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),t.Type!=null&&(n.uint32(8),fe.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=fe.codec().decode(t);break}case 2:{i.Data=t.bytes();break}default:{t.skipType(a&7);break}}}return i})),e),r.encode=t=>br(t,r.codec()),r.decode=(t,n)=>xr(t,r.codec(),n)})(it||(it={}));var Us;(function(r){let e;r.codec=()=>(e==null&&(e=Er((t,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),t.Type!=null&&(n.uint32(8),fe.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=fe.codec().decode(t);break}case 2:{i.Data=t.bytes();break}default:{t.skipType(a&7);break}}}return i})),e),r.encode=t=>br(t,r.codec()),r.decode=(t,n)=>xr(t,r.codec(),n)})(Us||(Us={}));var fn={};ke(fn,{MAX_RSA_KEY_SIZE:()=>$o,generateRSAKeyPair:()=>ku,jwkToJWKKeyPair:()=>Cu,jwkToPkcs1:()=>_0,jwkToPkix:()=>Ms,jwkToRSAPrivateKey:()=>Iu,pkcs1ToJwk:()=>Bu,pkcs1ToRSAPrivateKey:()=>Su,pkixToJwk:()=>Au,pkixToRSAPublicKey:()=>Hs});var w0=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]),Ft=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Dt=new Uint32Array(64),Rs=class extends gr{constructor(){super(64,32,8,!1),this.A=Ft[0]|0,this.B=Ft[1]|0,this.C=Ft[2]|0,this.D=Ft[3]|0,this.E=Ft[4]|0,this.F=Ft[5]|0,this.G=Ft[6]|0,this.H=Ft[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)Dt[l]=e.getUint32(t,!1);for(let l=16;l<64;l++){let h=Dt[l-15],b=Dt[l-2],I=Ge(h,7)^Ge(h,18)^h>>>3,w=Ge(b,17)^Ge(b,19)^b>>>10;Dt[l]=w+Dt[l-7]+I+Dt[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=Ge(a,6)^Ge(a,11)^Ge(a,25),b=u+h+Qa(a,c,f)+w0[l]+Dt[l]|0,w=(Ge(n,2)^Ge(n,13)^Ge(n,22))+ec(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(){Dt.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var Br=Vn(()=>new Rs);var j=Tn(Rc());function er(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 Ot(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 Qn(...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 Ls(){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=er(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,er(i,8)-n}function _c(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=Ot(s,8,n),c=new Uint8Array(a);return c[0]|=128,a}let o=Ot(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 Lc(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 Ve(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 Jy=Math.log(2);function eo(){if(typeof BigInt>"u")throw new Error("BigInt is not defined. Your environment doesn't implement BigInt.")}function Vs(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 Et(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 rn=class{constructor(){this.items=[]}write(e){this.items.push(e)}final(){return Vs(this.items)}},tn=[new Uint8Array([1])],Vc="0123456789";var Cr="",Xe=new ArrayBuffer(0),Ps=new Uint8Array(0),nn="EndOfContent",Fc="OCTET STRING",Dc="BIT STRING";function Bt(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):Ps}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(!Et(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",Xe)}toJSON(){return{...super.toJSON(),isHexOnly:this.isHexOnly,valueHex:j.Convert.ToHex(this.valueHexView)}}},e.NAME="hexBlock",e}var xt=class{constructor({blockLength:e=0,error:t=Cr,warnings:n=[],valueBeforeDecode:o=Ps}={}){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)}}};xt.NAME="baseBlock";var Ae=class extends xt{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'")}};Ae.NAME="valueBlock";var to=class extends Bt(xt){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):Ps,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",Xe}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=Ot(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(!Et(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=er(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}}};to.NAME="identificationBlock";var ro=class extends xt{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(!Et(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=er(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=Ot(this.length,8);if(o.byteLength>127)return this.error="Too big length",Xe;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}}};ro.NAME="lengthBlock";var _={},we=class extends xt{constructor({name:e=Cr,optional:t=!1,primitiveSchema:n,...o}={},i){super(o),this.name=e,this.optional=t,n&&(this.primitiveSchema=n),this.idBlock=new to(o),this.lenBlock=new ro(o),this.valueBlock=i?new i(o):new Ae(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 rn;t||Oc(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?Xe: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 Lc(t,n)}};we.NAME="BaseBlock";function Oc(r){if(r instanceof _.Constructed)for(let e of r.valueBlock.value)Oc(e)&&(r.lenBlock.isIndefiniteForm=!0);return!!r.lenBlock.isIndefiniteForm}var no=class extends we{constructor({value:e=Cr,...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}'`}};no.NAME="BaseStringBlock";var oo=class extends Bt(Ae){constructor({isHexOnly:e=!0,...t}={}){super(t),this.isHexOnly=e}};oo.NAME="PrimitiveValueBlock";var Mc,io=class extends we{constructor(e={}){super(e,oo),this.idBlock.isConstructed=!1}};Mc=io;_.Primitive=Mc;io.NAME="PRIMITIVE";function k0(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 Mo(r,e=0,t=r.length){let n=e,o=new we({},Ae),i=new xt;if(!Et(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=we;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=k0(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 Fs(r){if(!r.byteLength){let e=new we({},Ae);return e.error="Input buffer has zero length",{offset:-1,result:e}}return Mo(j.BufferSourceConverter.toUint8Array(r).slice(),0,r.byteLength)}function C0(r,e){return r?1:e}var st=class extends Ae{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(!Et(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(;C0(this.isIndefiniteForm,n)>0;){let s=Mo(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===nn)break}return this.isIndefiniteForm&&(this.value[this.value.length-1].constructor.NAME===nn?this.value.pop():this.warnings.push("No EndOfContent block encoded")),i}toBER(e,t){let n=t||new rn;for(let o=0;o<this.value.length;o++)this.value[o].toBER(e,n);return t?Xe:n.final()}toJSON(){let e={...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,value:[]};for(let t of this.value)e.value.push(t.toJSON());return e}};st.NAME="ConstructedValueBlock";var Hc,Mt=class extends we{constructor(e={}){super(e,st),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(`
|
|
2
|
+
"use strict";var HeliaDelegatedRoutingV1HttpApiClient=(()=>{var Uf=Object.create;var Cn=Object.defineProperty;var Rf=Object.getOwnPropertyDescriptor;var _f=Object.getOwnPropertyNames;var Lf=Object.getPrototypeOf,Vf=Object.prototype.hasOwnProperty;var Si=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),ke=(r,e)=>{for(var t in e)Cn(r,t,{get:e[t],enumerable:!0})},Ta=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of _f(e))!Vf.call(r,o)&&o!==t&&Cn(r,o,{get:()=>e[o],enumerable:!(n=Rf(e,o))||n.enumerable});return r};var Tn=(r,e,t)=>(t=r!=null?Uf(Lf(r)):{},Ta(e||!r||!r.__esModule?Cn(t,"default",{value:r,enumerable:!0}):t,r)),Pf=r=>Ta(Cn({},"__esModule",{value:!0}),r);var Rc=Si(Ar=>{"use strict";var x0="[object ArrayBuffer]",wt=class r{static isArrayBuffer(e){return Object.prototype.toString.call(e)===x0}static toArrayBuffer(e){return this.isArrayBuffer(e)?e:e.byteLength===e.buffer.byteLength||e.byteOffset===0&&e.byteLength===e.buffer.byteLength?e.buffer:this.toUint8Array(e.buffer).slice(e.byteOffset,e.byteOffset+e.byteLength).buffer}static toUint8Array(e){return this.toView(e,Uint8Array)}static toView(e,t){if(e.constructor===t)return e;if(this.isArrayBuffer(e))return new t(e);if(this.isArrayBufferView(e))return new t(e.buffer,e.byteOffset,e.byteLength);throw new TypeError("The provided value is not of type '(ArrayBuffer or ArrayBufferView)'")}static isBufferSource(e){return this.isArrayBufferView(e)||this.isArrayBuffer(e)}static isArrayBufferView(e){return ArrayBuffer.isView(e)||e&&this.isArrayBuffer(e.buffer)}static isEqual(e,t){let n=r.toUint8Array(e),o=r.toUint8Array(t);if(n.length!==o.byteLength)return!1;for(let i=0;i<n.length;i++)if(n[i]!==o[i])return!1;return!0}static concat(...e){let t;Array.isArray(e[0])&&!(e[1]instanceof Function)||Array.isArray(e[0])&&e[1]instanceof Function?t=e[0]:e[e.length-1]instanceof Function?t=e.slice(0,e.length-1):t=e;let n=0;for(let s of t)n+=s.byteLength;let o=new Uint8Array(n),i=0;for(let s of t){let a=this.toUint8Array(s);o.set(a,i),i+=a.length}return e[e.length-1]instanceof Function?this.toView(o,e[e.length-1]):o.buffer}},Ls="string",b0=/^[0-9a-f]+$/i,v0=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/,E0=/^[a-zA-Z0-9-_]+$/,Yn=class{static fromString(e){let t=unescape(encodeURIComponent(e)),n=new Uint8Array(t.length);for(let o=0;o<t.length;o++)n[o]=t.charCodeAt(o);return n.buffer}static toString(e){let t=wt.toUint8Array(e),n="";for(let i=0;i<t.length;i++)n+=String.fromCharCode(t[i]);return decodeURIComponent(escape(n))}},$e=class{static toString(e,t=!1){let n=wt.toArrayBuffer(e),o=new DataView(n),i="";for(let s=0;s<n.byteLength;s+=2){let a=o.getUint16(s,t);i+=String.fromCharCode(a)}return i}static fromString(e,t=!1){let n=new ArrayBuffer(e.length*2),o=new DataView(n);for(let i=0;i<e.length;i++)o.setUint16(i*2,e.charCodeAt(i),t);return n}},Xn=class r{static isHex(e){return typeof e===Ls&&b0.test(e)}static isBase64(e){return typeof e===Ls&&v0.test(e)}static isBase64Url(e){return typeof e===Ls&&E0.test(e)}static ToString(e,t="utf8"){let n=wt.toUint8Array(e);switch(t.toLowerCase()){case"utf8":return this.ToUtf8String(n);case"binary":return this.ToBinary(n);case"hex":return this.ToHex(n);case"base64":return this.ToBase64(n);case"base64url":return this.ToBase64Url(n);case"utf16le":return $e.toString(n,!0);case"utf16":case"utf16be":return $e.toString(n);default:throw new Error(`Unknown type of encoding '${t}'`)}}static FromString(e,t="utf8"){if(!e)return new ArrayBuffer(0);switch(t.toLowerCase()){case"utf8":return this.FromUtf8String(e);case"binary":return this.FromBinary(e);case"hex":return this.FromHex(e);case"base64":return this.FromBase64(e);case"base64url":return this.FromBase64Url(e);case"utf16le":return $e.fromString(e,!0);case"utf16":case"utf16be":return $e.fromString(e);default:throw new Error(`Unknown type of encoding '${t}'`)}}static ToBase64(e){let t=wt.toUint8Array(e);if(typeof btoa<"u"){let n=this.ToString(t,"binary");return btoa(n)}else return Buffer.from(t).toString("base64")}static FromBase64(e){let t=this.formatString(e);if(!t)return new ArrayBuffer(0);if(!r.isBase64(t))throw new TypeError("Argument 'base64Text' is not Base64 encoded");return typeof atob<"u"?this.FromBinary(atob(t)):new Uint8Array(Buffer.from(t,"base64")).buffer}static FromBase64Url(e){let t=this.formatString(e);if(!t)return new ArrayBuffer(0);if(!r.isBase64Url(t))throw new TypeError("Argument 'base64url' is not Base64Url encoded");return this.FromBase64(this.Base64Padding(t.replace(/\-/g,"+").replace(/\_/g,"/")))}static ToBase64Url(e){return this.ToBase64(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/\=/g,"")}static FromUtf8String(e,t=r.DEFAULT_UTF8_ENCODING){switch(t){case"ascii":return this.FromBinary(e);case"utf8":return Yn.fromString(e);case"utf16":case"utf16be":return $e.fromString(e);case"utf16le":case"usc2":return $e.fromString(e,!0);default:throw new Error(`Unknown type of encoding '${t}'`)}}static ToUtf8String(e,t=r.DEFAULT_UTF8_ENCODING){switch(t){case"ascii":return this.ToBinary(e);case"utf8":return Yn.toString(e);case"utf16":case"utf16be":return $e.toString(e);case"utf16le":case"usc2":return $e.toString(e,!0);default:throw new Error(`Unknown type of encoding '${t}'`)}}static FromBinary(e){let t=e.length,n=new Uint8Array(t);for(let o=0;o<t;o++)n[o]=e.charCodeAt(o);return n.buffer}static ToBinary(e){let t=wt.toUint8Array(e),n="";for(let o=0;o<t.length;o++)n+=String.fromCharCode(t[o]);return n}static ToHex(e){let t=wt.toUint8Array(e),n="",o=t.length;for(let i=0;i<o;i++){let s=t[i];s<16&&(n+="0"),n+=s.toString(16)}return n}static FromHex(e){let t=this.formatString(e);if(!t)return new ArrayBuffer(0);if(!r.isHex(t))throw new TypeError("Argument 'hexString' is not HEX encoded");t.length%2&&(t=`0${t}`);let n=new Uint8Array(t.length/2);for(let o=0;o<t.length;o=o+2){let i=t.slice(o,o+2);n[o/2]=parseInt(i,16)}return n.buffer}static ToUtf16String(e,t=!1){return $e.toString(e,t)}static FromUtf16String(e,t=!1){return $e.fromString(e,t)}static Base64Padding(e){let t=4-e.length%4;if(t<4)for(let n=0;n<t;n++)e+="=";return e}static formatString(e){return e?.replace(/[\n\r\t ]/g,"")||""}};Xn.DEFAULT_UTF8_ENCODING="utf8";function B0(r,...e){let t=arguments[0];for(let n=1;n<arguments.length;n++){let o=arguments[n];for(let i in o)t[i]=o[i]}return t}function A0(...r){let e=r.map(o=>o.byteLength).reduce((o,i)=>o+i),t=new Uint8Array(e),n=0;return r.map(o=>new Uint8Array(o)).forEach(o=>{for(let i of o)t[n++]=i}),t.buffer}function S0(r,e){if(!(r&&e)||r.byteLength!==e.byteLength)return!1;let t=new Uint8Array(r),n=new Uint8Array(e);for(let o=0;o<r.byteLength;o++)if(t[o]!==n[o])return!1;return!0}Ar.BufferSourceConverter=wt;Ar.Convert=Xn;Ar.assign=B0;Ar.combine=A0;Ar.isEqual=S0});var ua=Si((w1,ca)=>{var y1=function(){typeof ca<"u"&&(ca.exports=w);var r=86400,e=3200,t=146097*e/400,n=r*t,o=1e3*n,i=864e13,s=4294967296,a=1e6,c="000000000",f=Math.trunc||function(g){var v=g-g%1;return v==0&&(g<0||g===0&&1/g!=1/0)?-0:v},u=w.prototype,l=(w.fromDate=function(g){return new w(+g)},w.fromInt64BE=T(0,1,2,3,0,4),w.fromInt64LE=T(3,2,1,0,4,0),w.fromString=function(R){var v,D=new w,R=(R+="").replace(/^\s*[+\-]?\d+/,function($){var $=+$,A=1970+($-1970)%400;return D.year=$-A,A}).replace(/(?:Z|([+\-]\d{2}):?(\d{2}))$/,function(N,$,A){return $<0&&(A*=-1),v=6e4*(60*+$+ +A),""}).replace(/\.\d+$/,function(N){return D.nano=+(N+c).substr(1,9),""}).split(/\D+/);if(1<R.length?R[1]--:R[1]=0,D.time=v=Date.UTC.apply(Date,R)-(v||0),isNaN(v))throw new TypeError("Invalid Date");return d(D)},w.fromTimeT=function(g){return C(g,0)},u.year=0,u.time=0,u.nano=0,u.addNano=function(g){return this.nano+=+g||0,this},u.getNano=function(){var g=d(this);return(g.time%1e3*a+ +g.nano+1e9)%1e9},u.getTimeT=function(){var v=d(this),g=Math.floor(v.time/1e3),v=v.year;return v&&(g+=v*t*r/e),g},u.getYear=function(){return this.toDate().getUTCFullYear()+this.year},u.toDate=function(){return E(d(this).time)},u.toJSON=function(){return this.toString().replace(/0{1,6}Z$/,"Z")},u.toString=function(g){var v=this,D=v.toDate(),R={H:function(){return V(D.getUTCHours())},L:function(){return U(D.getUTCMilliseconds(),3)},M:function(){return V(D.getUTCMinutes())},N:function(){return U(v.getNano(),9)},S:function(){return V(D.getUTCSeconds())},Y:function(){var N=v.getYear();return 999999<N?"+"+N:9999<N?"+"+U(N,6):0<=N?U(N,4):-999999<=N?"-"+U(-N,6):N},a:function(){return b[D.getUTCDay()]},b:function(){return h[D.getUTCMonth()]},d:function(){return V(D.getUTCDate())},e:function(){return function(N){return(9<N?"":" ")+(0|N)}(D.getUTCDate())},m:function(){return V(D.getUTCMonth()+1)}};return function N($){return $.replace(/%./g,function(A){var m=A[1],S=I[m],m=R[m];return S?N(S):m?m():A})}(g||l)},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"),h=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],b=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],I={"%":"%",F:"%Y-%m-%d",n:`
|
|
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,$=g.time,A=g.nano,S=((A<0||a<=A)&&(A-=(D=Math.floor(A/a))*a,$+=D,D=1),N%e);return($<-i||i<$||S)&&((v=f($/o))&&(N+=v*e,$-=v*o),(R=E($)).setUTCFullYear(S+R.getUTCFullYear()),R=($=+R)+(v=f((N-=S)/e))*o,v&&-i<=R&&R<=i&&(N-=v*e,$=R),D=1),D&&(g.year=N,g.time=$,g.nano=A),g}function E(g){var v=new Date(0);return v.setTime(g),v}function C(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,$){return function(S,m){var B=d(this);S=S||new Array(8),F(S,m|=0);var P=Math.floor(B.time/1e3),B=B.year*(t*r/e),p=f(B/s)+f(P/s),B=B%s+P%s,P=Math.floor(B/s);return P&&(p+=P,B-=P*s),A(S,m+N,p),A(S,m+$,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 T(g,v,D,R,N,$){return function(S,m){F(S,m|=0);var p=A(S,m+N);return C(A(S,m+$),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 V(g){return(9<g?"":"0")+(0|g)}function U(g,v){return(c+(0|g)).substr(-v)}}()});var mf=Si((sv,ya)=>{"use strict";var Xp=Object.prototype.hasOwnProperty,Te="~";function An(){}Object.create&&(An.prototype=Object.create(null),new An().__proto__||(Te=!1));function Qp(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 Qp(t,n||r,o),s=Te?Te+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 xi(r,e){--r._eventsCount===0?r._events=new An:delete r._events[e]}function Se(){this._events=new An,this._eventsCount=0}Se.prototype.eventNames=function(){var e=[],t,n;if(this._eventsCount===0)return e;for(n in t=this._events)Xp.call(t,n)&&e.push(Te?n.slice(1):n);return Object.getOwnPropertySymbols?e.concat(Object.getOwnPropertySymbols(t)):e};Se.prototype.listeners=function(e){var t=Te?Te+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};Se.prototype.listenerCount=function(e){var t=Te?Te+e:e,n=this._events[t];return n?n.fn?1:n.length:0};Se.prototype.emit=function(e,t,n,o,i,s){var a=Te?Te+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};Se.prototype.on=function(e,t,n){return pf(this,e,t,n,!1)};Se.prototype.once=function(e,t,n){return pf(this,e,t,n,!0)};Se.prototype.removeListener=function(e,t,n,o){var i=Te?Te+e:e;if(!this._events[i])return this;if(!t)return xi(this,i),this;var s=this._events[i];if(s.fn)s.fn===t&&(!o||s.once)&&(!n||s.context===n)&&xi(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:xi(this,i)}return this};Se.prototype.removeAllListeners=function(e){var t;return e?(t=Te?Te+e:e,this._events[t]&&xi(this,t)):(this._events=new An,this._eventsCount=0),this};Se.prototype.off=Se.prototype.removeListener;Se.prototype.addListener=Se.prototype.on;Se.prefixed=Te;Se.EventEmitter=Se;typeof ya<"u"&&(ya.exports=Se)});var sm={};ke(sm,{createDelegatedRoutingV1HttpApiClient:()=>im});var Na=Symbol.for("@libp2p/content-routing");var Ii=Symbol.for("@libp2p/peer-id");var Ua=Symbol.for("@libp2p/peer-routing");var ve=class extends Error{static name="InvalidParametersError";constructor(e="Invalid parameters"){super(e),this.name="InvalidParametersError"}},or=class extends Error{static name="InvalidPublicKeyError";constructor(e="Invalid public key"){super(e),this.name="InvalidPublicKeyError"}};var nt=class extends Error{static name="NotFoundError";constructor(e="Not found"){super(e),this.name="NotFoundError"}};var ir=class extends Error{static name="InvalidMultihashError";constructor(e="Invalid Multihash"){super(e),this.name="InvalidMultihashError"}};var sr=class extends Error{static name="UnsupportedKeyTypeError";constructor(e="Unsupported key type"){super(e),this.name="UnsupportedKeyTypeError"}};var ar=(r,...e)=>{try{[...e]}catch{}};var Ui={};ke(Ui,{base32:()=>ze,base32hex:()=>zf,base32hexpad:()=>Gf,base32hexpadupper:()=>Zf,base32hexupper:()=>jf,base32pad:()=>Kf,base32padupper:()=>qf,base32upper:()=>$f,base32z:()=>Wf});var dm=new Uint8Array(0);function Ra(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 ft(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 _a(r){return new TextEncoder().encode(r)}function La(r){return new TextDecoder().decode(r)}function Ff(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,C=I.length;E!==C&&I[E]===0;)E++,w++;for(var x=(C-E)*u+1>>>0,T=new Uint8Array(x);E!==C;){for(var F=I[E],V=0,U=x-1;(F!==0||V<d)&&U!==-1;U--,V++)F+=256*T[U]>>>0,T[U]=F%a>>>0,F=F/a>>>0;if(F!==0)throw new Error("Non-zero carry");d=V,E++}for(var g=x-d;g!==x&&T[g]===0;)g++;for(var v=c.repeat(w);g<x;++g)v+=r.charAt(T[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 C=(I.length-w)*f+1>>>0,x=new Uint8Array(C);I[w];){var T=t[I.charCodeAt(w)];if(T===255)return;for(var F=0,V=C-1;(T!==0||F<E)&&V!==-1;V--,F++)T+=a*x[V]>>>0,x[V]=T%256>>>0,T=T/256>>>0;if(T!==0)throw new Error("Non-zero carry");E=F,w++}if(I[w]!==" "){for(var U=C-E;U!==C&&x[U]===0;)U++;for(var g=new Uint8Array(d+(C-U)),v=d;U!==C;)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 Df=Ff,Of=Df,Pa=Of;var ki=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")}},Ci=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 Fa(this,e)}},Ti=class{decoders;constructor(e){this.decoders=e}or(e){return Fa(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 Fa(r,e){return new Ti({...r.decoders??{[r.prefix]:r},...e.decoders??{[e.prefix]:e}})}var Ni=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 ki(e,t,n),this.decoder=new Ci(e,t,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};function cr({name:r,prefix:e,encode:t,decode:n}){return new Ni(r,e,t,n)}function kt({name:r,prefix:e,alphabet:t}){let{encode:n,decode:o}=Pa(t,r);return cr({prefix:e,name:r,encode:n,decode:i=>ft(o(i))})}function Mf(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 Hf(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 cr({prefix:e,name:r,encode(o){return Hf(o,n,t)},decode(o){return Mf(o,n,t,r)}})}var ze=se({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),$f=se({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Kf=se({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),qf=se({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),zf=se({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),jf=se({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Gf=se({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Zf=se({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Wf=se({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Ri={};ke(Ri,{base58btc:()=>te,base58flickr:()=>Jf});var te=kt({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Jf=kt({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Li={};ke(Li,{base64:()=>_i,base64pad:()=>Yf,base64url:()=>Xf,base64urlpad:()=>Qf});var _i=se({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Yf=se({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Xf=se({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Qf=se({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});function eh(r,e){try{if(typeof r=="string"&&r.length>0)return th(r);if(typeof r=="number"&&isFinite(r))return e?.long?nh(r):rh(r);throw new Error("Value is not a string or number.")}catch(t){let n=oh(t)?`${t.message}. value=${JSON.stringify(r)}`:"An unknown error has occured.";throw new Error(n)}}function th(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 Un=eh;function rh(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 nh(r){let e=Math.abs(r);return e>=864e5?Nn(r,e,864e5,"day"):e>=36e5?Nn(r,e,36e5,"hour"):e>=6e4?Nn(r,e,6e4,"minute"):e>=1e3?Nn(r,e,1e3,"second"):`${r} ms`}function Nn(r,e,t,n){let o=e>=t*1.5;return`${Math.round(r/t)} ${n}${o?"s":""}`}function oh(r){return typeof r=="object"&&r!==null&&"message"in r}function Vi(r){t.debug=t,t.default=t,t.coerce=c,t.disable=i,t.enable=o,t.enabled=s,t.humanize=Un,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,C=Number(new Date),x=C-(l||C);E.diff=x,E.prev=l,E.curr=C,l=C,d[0]=t.coerce(d[0]),typeof d[0]!="string"&&d.unshift("%O");let T=0;d[0]=d[0].replace(/%([a-zA-Z%])/g,(V,U)=>{if(V==="%%")return"%";T++;let g=t.formatters[U];if(typeof g=="function"){let v=d[T];V=g.call(E,v),d.splice(T,1),T--}return V}),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 Rn=fh(),ih=["#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 sh(){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 ah(r){if(r[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+r[0]+(this.useColors?"%c ":" ")+"+"+Un(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 ch=console.debug??console.log??(()=>{});function uh(r){try{r?Rn?.setItem("debug",r):Rn?.removeItem("debug")}catch{}}function lh(){let r;try{r=Rn?.getItem("debug")}catch{}return!r&&typeof globalThis.process<"u"&&"env"in globalThis.process&&(r=globalThis.process.env.DEBUG),r}function fh(){try{return localStorage}catch{}}function hh(r){r.j=function(e){try{return JSON.stringify(e)}catch(t){return"[UnexpectedJSONParseError]: "+t.message}}}var Da=Vi({formatArgs:ah,save:uh,load:lh,useColors:sh,setupFormatters:hh,colors:ih,storage:Rn,log:ch});var Ue=Da;Ue.formatters.b=r=>r==null?"undefined":te.baseEncode(r);Ue.formatters.t=r=>r==null?"undefined":ze.baseEncode(r);Ue.formatters.m=r=>r==null?"undefined":_i.baseEncode(r);Ue.formatters.p=r=>r==null?"undefined":r.toString();Ue.formatters.c=r=>r==null?"undefined":r.toString();Ue.formatters.k=r=>r==null?"undefined":r.toString();Ue.formatters.a=r=>r==null?"undefined":r.toString();Ue.formatters.e=r=>r==null?"undefined":Oa(r.stack)??Oa(r.message)??r.toString();function dh(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 Ct(r){let e=dh(`${r}:trace`);return Ue.enabled(`${r}:trace`)&&Ue.names.map(t=>t.toString()).find(t=>t.includes(":trace"))!=null&&(e=Ue(`${r}:trace`)),Object.assign(Ue(r),{error:Ue(`${r}:error`),trace:e})}function Oa(r){if(r!=null&&(r=r.trim(),r.length!==0))return r}var Pi={};ke(Pi,{base36:()=>ur,base36upper:()=>ph});var ur=kt({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),ph=kt({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var mh=$a,Ma=128,gh=127,yh=~gh,wh=Math.pow(2,31);function $a(r,e,t){e=e||[],t=t||0;for(var n=t;r>=wh;)e[t++]=r&255|Ma,r/=128;for(;r&yh;)e[t++]=r&255|Ma,r>>>=7;return e[t]=r|0,$a.bytes=t-n+1,e}var xh=Fi,bh=128,Ha=127;function Fi(r,n){var t=0,n=n||0,o=0,i=n,s,a=r.length;do{if(i>=a)throw Fi.bytes=0,new RangeError("Could not decode varint");s=r[i++],t+=o<28?(s&Ha)<<o:(s&Ha)*Math.pow(2,o),o+=7}while(s>=bh);return Fi.bytes=i-n,t}var vh=Math.pow(2,7),Eh=Math.pow(2,14),Bh=Math.pow(2,21),Ah=Math.pow(2,28),Sh=Math.pow(2,35),Ih=Math.pow(2,42),kh=Math.pow(2,49),Ch=Math.pow(2,56),Th=Math.pow(2,63),Nh=function(r){return r<vh?1:r<Eh?2:r<Bh?3:r<Ah?4:r<Sh?5:r<Ih?6:r<kh?7:r<Ch?8:r<Th?9:10},Uh={encode:mh,decode:xh,encodingLength:Nh},Rh=Uh,Kr=Rh;function qr(r,e=0){return[Kr.decode(r,e),Kr.decode.bytes]}function lr(r,e,t=0){return Kr.encode(r,e,t),e}function fr(r){return Kr.encodingLength(r)}function je(r,e){let t=e.byteLength,n=fr(r),o=n+fr(t),i=new Uint8Array(o+t);return lr(r,i,0),lr(t,i,n),i.set(e,o),new hr(r,t,e,i)}function ht(r){let e=ft(r),[t,n]=qr(e),[o,i]=qr(e.subarray(n)),s=e.subarray(n+i);if(s.byteLength!==o)throw new Error("Incorrect length");return new hr(t,o,s,e)}function Ka(r,e){if(r===e)return!0;{let t=e;return r.code===t.code&&r.size===t.size&&t.bytes instanceof Uint8Array&&Ra(r.bytes,t.bytes)}}var hr=class{code;size;digest;bytes;constructor(e,t,n,o){this.code=e,this.size=t,this.digest=n,this.bytes=o}};function qa(r,e){let{bytes:t,version:n}=r;switch(n){case 0:return Lh(t,Di(r),e??te.encoder);default:return Vh(t,Di(r),e??ze.encoder)}}var za=new WeakMap;function Di(r){let e=za.get(r);if(e==null){let t=new Map;return za.set(r,t),t}return e}var ie=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!==zr)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==Ph)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=je(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&&Ka(e.multihash,n.multihash)}toString(e){return qa(this,e)}toJSON(){return{"/":qa(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??ja(n,o,i.bytes))}else if(t[Fh]===!0){let{version:n,multihash:o,code:i}=t,s=ht(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!==zr)throw new Error(`Version 0 CID must use dag-pb (code: ${zr}) block encoding`);return new r(e,t,n,n.bytes)}case 1:{let o=ja(e,t,n.bytes);return new r(e,t,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return r.create(0,zr,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=ft(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 hr(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]=qr(e.subarray(t));return t+=h,l},o=n(),i=zr;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]=_h(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 Di(i).set(n,e),i}};function _h(r,e){switch(r[0]){case"Q":{let t=e??te;return[te.prefix,t.decode(`${te.prefix}${r}`)]}case te.prefix:{let t=e??te;return[te.prefix,t.decode(r)]}case ze.prefix:{let t=e??ze;return[ze.prefix,t.decode(r)]}case ur.prefix:{let t=e??ur;return[ur.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 Lh(r,e,t){let{prefix:n}=t;if(n!==te.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 Vh(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 zr=112,Ph=18;function ja(r,e,t){let n=fr(r),o=n+fr(e),i=new Uint8Array(o+t.byteLength);return lr(r,i,0),lr(e,i,n),i.set(t,o),i}var Fh=Symbol.for("@ipld/js-cid/CID");var Oi={};ke(Oi,{identity:()=>dt});var Ga=0,Dh="identity",Za=ft;function Oh(r){return je(Ga,Za(r))}var dt={code:Ga,name:Dh,encode:Za,digest:Oh};function ue(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 Wa(r){if(!Number.isSafeInteger(r)||r<0)throw new Error(`positive integer expected, not ${r}`)}function Mh(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}function dr(r,...e){if(!Mh(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 Ja(r){if(typeof r!="function"||typeof r.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");Wa(r.outputLen),Wa(r.blockLen)}function pr(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 Ya(r,e){dr(r);let t=e.outputLen;if(r.length<t)throw new Error(`digestInto() expects output buffer of length at least ${t}`)}var zt=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;var Ln=r=>new DataView(r.buffer,r.byteOffset,r.byteLength),Ge=(r,e)=>r<<32-e|r>>>e;var Jm=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function Xa(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=Xa(r)),dr(r),r}function Mi(...r){let e=0;for(let n=0;n<r.length;n++){let o=r[n];dr(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 mr=class{clone(){return this._cloneInto()}},Ym={}.toString;function Vn(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 Pn(r=32){if(zt&&typeof zt.getRandomValues=="function")return zt.getRandomValues(new Uint8Array(r));if(zt&&typeof zt.randomBytes=="function")return zt.randomBytes(r);throw new Error("crypto.getRandomValues must be defined")}function Hh(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 Qa=(r,e,t)=>r&e^~r&t,ec=(r,e,t)=>r&e^r&t^e&t,gr=class extends mr{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=Ln(this.buffer)}update(e){pr(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=Ln(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){pr(this),Ya(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;Hh(n,o-8,BigInt(this.length*8),i),this.process(n,0);let a=Ln(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 Fn=BigInt(4294967295),Hi=BigInt(32);function tc(r,e=!1){return e?{h:Number(r&Fn),l:Number(r>>Hi&Fn)}:{h:Number(r>>Hi&Fn)|0,l:Number(r&Fn)|0}}function $h(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}=tc(r[o],e);[t[o],n[o]]=[i,s]}return[t,n]}var Kh=(r,e)=>BigInt(r>>>0)<<Hi|BigInt(e>>>0),qh=(r,e,t)=>r>>>t,zh=(r,e,t)=>r<<32-t|e>>>t,jh=(r,e,t)=>r>>>t|e<<32-t,Gh=(r,e,t)=>r<<32-t|e>>>t,Zh=(r,e,t)=>r<<64-t|e>>>t-32,Wh=(r,e,t)=>r>>>t-32|e<<64-t,Jh=(r,e)=>e,Yh=(r,e)=>r,Xh=(r,e,t)=>r<<t|e>>>32-t,Qh=(r,e,t)=>e<<t|r>>>32-t,ed=(r,e,t)=>e<<t-32|r>>>64-t,td=(r,e,t)=>r<<t-32|e>>>64-t;function rd(r,e,t,n){let o=(e>>>0)+(n>>>0);return{h:r+t+(o/2**32|0)|0,l:o|0}}var nd=(r,e,t)=>(r>>>0)+(e>>>0)+(t>>>0),od=(r,e,t,n)=>e+t+n+(r/2**32|0)|0,id=(r,e,t,n)=>(r>>>0)+(e>>>0)+(t>>>0)+(n>>>0),sd=(r,e,t,n,o)=>e+t+n+o+(r/2**32|0)|0,ad=(r,e,t,n,o)=>(r>>>0)+(e>>>0)+(t>>>0)+(n>>>0)+(o>>>0),cd=(r,e,t,n,o,i)=>e+t+n+o+i+(r/2**32|0)|0;var ud={fromBig:tc,split:$h,toBig:Kh,shrSH:qh,shrSL:zh,rotrSH:jh,rotrSL:Gh,rotrBH:Zh,rotrBL:Wh,rotr32H:Jh,rotr32L:Yh,rotlSH:Xh,rotlSL:Qh,rotlBH:ed,rotlBL:td,add:rd,add3L:nd,add3H:od,add4L:id,add4H:sd,add5H:cd,add5L:ad},K=ud;var[ld,fd]=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))),Nt=new Uint32Array(80),Ut=new Uint32Array(80),$i=class extends gr{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)Nt[x]=e.getUint32(t),Ut[x]=e.getUint32(t+=4);for(let x=16;x<80;x++){let T=Nt[x-15]|0,F=Ut[x-15]|0,V=K.rotrSH(T,F,1)^K.rotrSH(T,F,8)^K.shrSH(T,F,7),U=K.rotrSL(T,F,1)^K.rotrSL(T,F,8)^K.shrSL(T,F,7),g=Nt[x-2]|0,v=Ut[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,Ut[x-7],Ut[x-16]),$=K.add4H(N,V,D,Nt[x-7],Nt[x-16]);Nt[x]=$|0,Ut[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:C}=this;for(let x=0;x<80;x++){let T=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),V=l&b^~l&w,U=h&I^~h&d,g=K.add5L(C,F,U,fd[x],Ut[x]),v=K.add5H(g,E,T,V,ld[x],Nt[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),$=n&i^n&a^i&a,A=o&s^o&c^s&c;E=w|0,C=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,$),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:C}=K.add(this.Hh|0,this.Hl|0,E|0,C|0),this.set(n,o,i,s,a,c,f,u,l,h,b,I,w,d,E,C)}roundClean(){Nt.fill(0),Ut.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 rc=Vn(()=>new $i);var On={};ke(On,{aInRange:()=>Re,abool:()=>Ze,abytes:()=>yr,bitGet:()=>yd,bitLen:()=>Gi,bitMask:()=>Zr,bitSet:()=>wd,bytesToHex:()=>mt,bytesToNumberBE:()=>gt,bytesToNumberLE:()=>_t,concatBytes:()=>yt,createHmacDrbg:()=>Zi,ensureBytes:()=>ae,equalBytes:()=>md,hexToBytes:()=>Gt,hexToNumber:()=>ji,inRange:()=>Gr,isBytes:()=>Rt,memoized:()=>Wt,notImplemented:()=>bd,numberToBytesBE:()=>Lt,numberToBytesLE:()=>Zt,numberToHexUnpadded:()=>jt,numberToVarBytesBE:()=>pd,utf8ToBytes:()=>gd,validateObject:()=>ot});var zi=BigInt(0),Dn=BigInt(1),hd=BigInt(2);function Rt(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}function yr(r){if(!Rt(r))throw new Error("Uint8Array expected")}function Ze(r,e){if(typeof e!="boolean")throw new Error(`${r} must be valid boolean, got "${e}".`)}var dd=Array.from({length:256},(r,e)=>e.toString(16).padStart(2,"0"));function mt(r){yr(r);let e="";for(let t=0;t<r.length;t++)e+=dd[r[t]];return e}function jt(r){let e=r.toString(16);return e.length&1?`0${e}`:e}function ji(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return BigInt(r===""?"0":`0x${r}`)}var pt={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function nc(r){if(r>=pt._0&&r<=pt._9)return r-pt._0;if(r>=pt._A&&r<=pt._F)return r-(pt._A-10);if(r>=pt._a&&r<=pt._f)return r-(pt._a-10)}function Gt(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=nc(r.charCodeAt(i)),a=nc(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 gt(r){return ji(mt(r))}function _t(r){return yr(r),ji(mt(Uint8Array.from(r).reverse()))}function Lt(r,e){return Gt(r.toString(16).padStart(e*2,"0"))}function Zt(r,e){return Lt(r,e).reverse()}function pd(r){return Gt(jt(r))}function ae(r,e,t){let n;if(typeof e=="string")try{n=Gt(e)}catch(i){throw new Error(`${r} must be valid hex string, got "${e}". Cause: ${i}`)}else if(Rt(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 yt(...r){let e=0;for(let n=0;n<r.length;n++){let o=r[n];yr(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 md(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 gd(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}var Ki=r=>typeof r=="bigint"&&zi<=r;function Gr(r,e,t){return Ki(r)&&Ki(e)&&Ki(t)&&e<=r&&r<t}function Re(r,e,t,n){if(!Gr(e,t,n))throw new Error(`expected valid ${r}: ${t} <= n < ${n}, got ${typeof e} ${e}`)}function Gi(r){let e;for(e=0;r>zi;r>>=Dn,e+=1);return e}function yd(r,e){return r>>BigInt(e)&Dn}function wd(r,e,t){return r|(t?Dn:zi)<<BigInt(e)}var Zr=r=>(hd<<BigInt(r-1))-Dn,qi=r=>new Uint8Array(r),oc=r=>Uint8Array.from(r);function Zi(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=qi(r),o=qi(r),i=0,s=()=>{n.fill(1),o.fill(0),i=0},a=(...l)=>t(o,n,...l),c=(l=qi())=>{o=a(oc([0]),l),n=a(),l.length!==0&&(o=a(oc([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 yt(...h)};return(l,h)=>{s(),c(l);let b;for(;!(b=h(f()));)c();return s(),b}}var xd={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"||Rt(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 ot(r,e,t={}){let n=(o,i,s)=>{let a=xd[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 bd=()=>{throw new Error("not implemented")};function Wt(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 le=BigInt(0),re=BigInt(1),Jt=BigInt(2),vd=BigInt(3),Wi=BigInt(4),ic=BigInt(5),sc=BigInt(8),Ed=BigInt(9),Bd=BigInt(16);function X(r,e){let t=r%e;return t>=le?t:e+t}function Ad(r,e,t){if(t<=le||e<le)throw new Error("Expected power/modulo > 0");if(t===re)return le;let n=re;for(;e>le;)e&re&&(n=n*r%t),r=r*r%t,e>>=re;return n}function ne(r,e,t){let n=r;for(;e-- >le;)n*=n,n%=t;return n}function Mn(r,e){if(r===le||e<=le)throw new Error(`invert: expected positive integers, got n=${r} mod=${e}`);let t=X(r,e),n=e,o=le,i=re,s=re,a=le;for(;t!==le;){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!==re)throw new Error("invert: does not exist");return X(o,e)}function Sd(r){let e=(r-re)/Jt,t,n,o;for(t=r-re,n=0;t%Jt===le;t/=Jt,n++);for(o=Jt;o<r&&Ad(o,e,r)!==r-re;o++);if(n===1){let s=(r+re)/Wi;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+re)/Jt;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,re<<BigInt(f-b-1));u=a.sqr(I),l=a.mul(l,I),h=a.mul(h,u),f=b}return l}}function Id(r){if(r%Wi===vd){let e=(r+re)/Wi;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%sc===ic){let e=(r-ic)/sc;return function(n,o){let i=n.mul(o,Jt),s=n.pow(i,e),a=n.mul(o,s),c=n.mul(n.mul(a,Jt),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%Bd,Sd(r)}var ac=(r,e)=>(X(r,e)&re)===re,kd=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Ji(r){let e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},t=kd.reduce((n,o)=>(n[o]="function",n),e);return ot(r,t)}function Cd(r,e,t){if(t<le)throw new Error("Expected power > 0");if(t===le)return r.ONE;if(t===re)return e;let n=r.ONE,o=e;for(;t>le;)t&re&&(n=r.mul(n,o)),o=r.sqr(o),t>>=re;return n}function Td(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 Yi(r,e){let t=e!==void 0?e:r.toString(2).length,n=Math.ceil(t/8);return{nBitLength:t,nByteLength:n}}function Vt(r,e,t=!1,n={}){if(r<=le)throw new Error(`Expected Field ORDER > 0, got ${r}`);let{nBitLength:o,nByteLength:i}=Yi(r,e);if(i>2048)throw new Error("Field lengths over 2048 bytes are not supported");let s=Id(r),a=Object.freeze({ORDER:r,BITS:o,BYTES:i,MASK:Zr(o),ZERO:le,ONE:re,create:c=>X(c,r),isValid:c=>{if(typeof c!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof c}`);return le<=c&&c<r},is0:c=>c===le,isOdd:c=>(c&re)===re,neg:c=>X(-c,r),eql:(c,f)=>c===f,sqr:c=>X(c*c,r),add:(c,f)=>X(c+f,r),sub:(c,f)=>X(c-f,r),mul:(c,f)=>X(c*f,r),pow:(c,f)=>Cd(a,c,f),div:(c,f)=>X(c*Mn(f,r),r),sqrN:c=>c*c,addN:(c,f)=>c+f,subN:(c,f)=>c-f,mulN:(c,f)=>c*f,inv:c=>Mn(c,r),sqrt:n.sqrt||(c=>s(a,c)),invertBatch:c=>Td(a,c),cmov:(c,f,u)=>u?f:c,toBytes:c=>t?Zt(c,i):Lt(c,i),fromBytes:c=>{if(c.length!==i)throw new Error(`Fp.fromBytes: expected ${i}, got ${c.length}`);return t?_t(c):gt(c)}});return Object.freeze(a)}function cc(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 Xi(r){let e=cc(r);return e+Math.ceil(e/2)}function uc(r,e,t=!1){let n=r.length,o=cc(e),i=Xi(e);if(n<16||n<i||n>1024)throw new Error(`expected ${i}-1024 bytes of input, got ${n}`);let s=t?gt(r):_t(r),a=X(s,e-re)+re;return t?Zt(a,o):Lt(a,o)}var Ud=BigInt(0),Qi=BigInt(1),es=new WeakMap,lc=new WeakMap;function Hn(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>Ud;)s&Qi&&(a=a.add(c)),c=c.double(),s>>=Qi;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+=Qi);let C=d,x=d+Math.abs(E)-1,T=w%2!==0,F=E<0;E===0?l=l.add(t(T,s[C])):u=u.add(t(F,s[x]))}return{p:u,f:l}},wNAFCached(i,s,a){let c=lc.get(i)||1,f=es.get(i);return f||(f=this.precomputeWindow(i,c),c!==1&&es.set(i,a(f))),this.wNAF(c,f,s)},setWindowSize(i,s){n(s),lc.set(i,s),es.delete(i)}}}function $n(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=Gi(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 Wr(r){return Ji(r.Fp),ot(r,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Yi(r.n,r.nBitLength),...r,p:r.Fp.ORDER})}var We=BigInt(0),_e=BigInt(1),Kn=BigInt(2),Rd=BigInt(8),_d={zip215:!0};function Ld(r){let e=Wr(r);return ot(r,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...e})}function fc(r){let e=Ld(r),{Fp:t,n,prehash:o,hash:i,randomBytes:s,nByteLength:a,h:c}=e,f=Kn<<BigInt(a*8)-_e,u=t.create,l=Vt(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:We}}}),b=e.adjustScalarBytes||(m=>m),I=e.domain||((m,p,B)=>{if(Ze("phflag",B),p.length||B)throw new Error("Contexts/pre-hash are not supported");return m});function w(m,p){Re("coordinate "+m,p,We,f)}function d(m){if(!(m instanceof x))throw new Error("ExtendedPoint expected")}let E=Wt((m,p)=>{let{ex:B,ey:P,ez:O}=m,M=m.is0();p==null&&(p=M?Rd:t.inv(O));let q=u(B*p),G=u(P*p),z=u(O*p);if(M)return{x:We,y:_e};if(z!==_e)throw new Error("invZ was invalid");return{x:q,y:G}}),C=Wt(m=>{let{a:p,d:B}=e;if(m.is0())throw new Error("bad point: ZERO");let{ex:P,ey:O,ez:M,et:q}=m,G=u(P*P),z=u(O*O),Y=u(M*M),ee=u(Y*Y),he=u(G*p),de=u(Y*u(he+z)),ye=u(ee+u(B*u(G*z)));if(de!==ye)throw new Error("bad point: equation left != right (1)");let Ie=u(P*O),ce=u(M*q);if(Ie!==ce)throw new Error("bad point: equation left != right (2)");return!0});class x{constructor(p,B,P,O){this.ex=p,this.ey=B,this.ez=P,this.et=O,w("x",p),w("y",B),w("z",P),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:P}=p||{};return w("x",B),w("y",P),new x(B,P,_e,u(B*P))}static normalizeZ(p){let B=t.invertBatch(p.map(P=>P.ez));return p.map((P,O)=>P.toAffine(B[O])).map(x.fromAffine)}static msm(p,B){return $n(x,l,p,B)}_setWindowSize(p){V.setWindowSize(this,p)}assertValidity(){C(this)}equals(p){d(p);let{ex:B,ey:P,ez:O}=this,{ex:M,ey:q,ez:G}=p,z=u(B*G),Y=u(M*O),ee=u(P*G),he=u(q*O);return z===Y&&ee===he}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:P,ez:O}=this,M=u(B*B),q=u(P*P),G=u(Kn*u(O*O)),z=u(p*M),Y=B+P,ee=u(u(Y*Y)-M-q),he=z+q,de=he-G,ye=z-q,Ie=u(ee*de),ce=u(he*ye),Ne=u(ee*ye),lt=u(de*he);return new x(Ie,ce,lt,Ne)}add(p){d(p);let{a:B,d:P}=e,{ex:O,ey:M,ez:q,et:G}=this,{ex:z,ey:Y,ez:ee,et:he}=p;if(B===BigInt(-1)){let Ea=u((M-O)*(Y+z)),Ba=u((M+O)*(Y-z)),Ai=u(Ba-Ea);if(Ai===We)return this.double();let Aa=u(q*Kn*he),Sa=u(G*Kn*ee),Ia=Sa+Aa,ka=Ba+Ea,Ca=Sa-Aa,kf=u(Ia*Ai),Cf=u(ka*Ca),Tf=u(Ia*Ca),Nf=u(Ai*ka);return new x(kf,Cf,Nf,Tf)}let de=u(O*z),ye=u(M*Y),Ie=u(G*P*he),ce=u(q*ee),Ne=u((O+M)*(z+Y)-de-ye),lt=ce-Ie,Hr=ce+Ie,$r=u(ye-B*de),Bf=u(Ne*lt),Af=u(Hr*$r),Sf=u(Ne*$r),If=u(lt*Hr);return new x(Bf,Af,If,Sf)}subtract(p){return this.add(p.negate())}wNAF(p){return V.wNAFCached(this,p,x.normalizeZ)}multiply(p){let B=p;Re("scalar",B,_e,n);let{p:P,f:O}=this.wNAF(B);return x.normalizeZ([P,O])[0]}multiplyUnsafe(p){let B=p;return Re("scalar",B,We,n),B===We?F:this.equals(F)||B===_e?this:this.equals(T)?this.wNAF(B).p:V.unsafeLadder(this,B)}isSmallOrder(){return this.multiplyUnsafe(c).is0()}isTorsionFree(){return V.unsafeLadder(this,n).is0()}toAffine(p){return E(this,p)}clearCofactor(){let{h:p}=e;return p===_e?this:this.multiplyUnsafe(p)}static fromHex(p,B=!1){let{d:P,a:O}=e,M=t.BYTES;p=ae("pointHex",p,M),Ze("zip215",B);let q=p.slice(),G=p[M-1];q[M-1]=G&-129;let z=_t(q),Y=B?f:t.ORDER;Re("pointHex.y",z,We,Y);let ee=u(z*z),he=u(ee-_e),de=u(P*ee-O),{isValid:ye,value:Ie}=h(he,de);if(!ye)throw new Error("Point.fromHex: invalid y coordinate");let ce=(Ie&_e)===_e,Ne=(G&128)!==0;if(!B&&Ie===We&&Ne)throw new Error("Point.fromHex: x=0 and x_0=1");return Ne!==ce&&(Ie=u(-Ie)),x.fromAffine({x:Ie,y:z})}static fromPrivateKey(p){return v(p).point}toRawBytes(){let{x:p,y:B}=this.toAffine(),P=Zt(B,t.BYTES);return P[P.length-1]|=p&_e?128:0,P}toHex(){return mt(this.toRawBytes())}}x.BASE=new x(e.Gx,e.Gy,_e,u(e.Gx*e.Gy)),x.ZERO=new x(We,_e,_e,We);let{BASE:T,ZERO:F}=x,V=Hn(x,a*8);function U(m){return X(m,n)}function g(m){return U(_t(m))}function v(m){let p=a;m=ae("private key",m,p);let B=ae("hashed private key",i(m),2*p),P=b(B.slice(0,p)),O=B.slice(p,2*p),M=g(P),q=T.multiply(M),G=q.toRawBytes();return{head:P,prefix:O,scalar:M,point:q,pointBytes:G}}function D(m){return v(m).pointBytes}function R(m=new Uint8Array,...p){let B=yt(...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:P,scalar:O,pointBytes:M}=v(p),q=R(B.context,P,m),G=T.multiply(q).toRawBytes(),z=R(B.context,G,M,m),Y=U(q+z*O);Re("signature.s",Y,We,n);let ee=yt(G,Zt(Y,t.BYTES));return ae("result",ee,a*2)}let $=_d;function A(m,p,B,P=$){let{context:O,zip215:M}=P,q=t.BYTES;m=ae("signature",m,2*q),p=ae("message",p),M!==void 0&&Ze("zip215",M),o&&(p=o(p));let G=_t(m.slice(q,2*q)),z,Y,ee;try{z=x.fromHex(B,M),Y=x.fromHex(m.slice(0,q),M),ee=T.multiplyUnsafe(G)}catch{return!1}if(!M&&z.isSmallOrder())return!1;let he=R(O,Y.toRawBytes(),z.toRawBytes(),p);return Y.add(z.multiplyUnsafe(he)).subtract(ee).clearCofactor().equals(x.ZERO)}return T._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 ts=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),hc=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),bg=BigInt(0),Vd=BigInt(1),dc=BigInt(2),vg=BigInt(3),Pd=BigInt(5),Fd=BigInt(8);function Dd(r){let e=BigInt(10),t=BigInt(20),n=BigInt(40),o=BigInt(80),i=ts,a=r*r%i*r%i,c=ne(a,dc,i)*a%i,f=ne(c,Vd,i)*r%i,u=ne(f,Pd,i)*f%i,l=ne(u,e,i)*u%i,h=ne(l,t,i)*l%i,b=ne(h,n,i)*h%i,I=ne(b,o,i)*b%i,w=ne(I,o,i)*b%i,d=ne(w,e,i)*u%i;return{pow_p_5_8:ne(d,dc,i)*r%i,b2:a}}function Od(r){return r[0]&=248,r[31]&=127,r[31]|=64,r}function Md(r,e){let t=ts,n=X(e*e*e,t),o=X(n*n*e,t),i=Dd(r*o).pow_p_5_8,s=X(r*n*i,t),a=X(e*s*s,t),c=s,f=X(s*hc,t),u=a===r,l=a===X(-r,t),h=a===X(-r*hc,t);return u&&(s=c),(l||h)&&(s=f),ac(s,t)&&(s=X(-s,t)),{isValid:u||l,value:s}}var Hd=Vt(ts,void 0,!0),$d={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:Hd,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:Fd,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:rc,randomBytes:Pn,adjustScalarBytes:Od,uvRatio:Md},pc=fc($d);var qn=32;function mc(r,e,t){return pc.verify(e,t instanceof Uint8Array?t:t.subarray(),r)}var zn=class{type="Ed25519";raw;constructor(e){this.raw=rs(e,qn)}toMultihash(){return dt.digest(jn(this))}toCID(){return ie.createV1(114,this.toMultihash())}toString(){return te.encode(this.toMultihash().bytes).substring(1)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:ue(this.raw,e.raw)}verify(e,t){return mc(this.raw,t,e)}};function ns(r){return r=rs(r,qn),new zn(r)}function rs(r,e){if(r=Uint8Array.from(r??[]),r.length!==e)throw new ve(`Key must be a Uint8Array of length ${e}, got ${r.length}`);return r}function Je(r=0){return new Uint8Array(r)}var qd=Math.pow(2,7),zd=Math.pow(2,14),jd=Math.pow(2,21),os=Math.pow(2,28),is=Math.pow(2,35),ss=Math.pow(2,42),as=Math.pow(2,49),W=128,Ee=127;function Le(r){if(r<qd)return 1;if(r<zd)return 2;if(r<jd)return 3;if(r<os)return 4;if(r<is)return 5;if(r<ss)return 6;if(r<as)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function cs(r,e,t=0){switch(Le(r)){case 8:e[t++]=r&255|W,r/=128;case 7:e[t++]=r&255|W,r/=128;case 6:e[t++]=r&255|W,r/=128;case 5:e[t++]=r&255|W,r/=128;case 4:e[t++]=r&255|W,r>>>=7;case 3:e[t++]=r&255|W,r>>>=7;case 2:e[t++]=r&255|W,r>>>=7;case 1:{e[t++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return e}function Gd(r,e,t=0){switch(Le(r)){case 8:e.set(t++,r&255|W),r/=128;case 7:e.set(t++,r&255|W),r/=128;case 6:e.set(t++,r&255|W),r/=128;case 5:e.set(t++,r&255|W),r/=128;case 4:e.set(t++,r&255|W),r>>>=7;case 3:e.set(t++,r&255|W),r>>>=7;case 2:e.set(t++,r&255|W),r>>>=7;case 1:{e.set(t++,r&255),r>>>=7;break}default:throw new Error("unreachable")}return e}function us(r,e){let t=r[e],n=0;if(n+=t&Ee,t<W||(t=r[e+1],n+=(t&Ee)<<7,t<W)||(t=r[e+2],n+=(t&Ee)<<14,t<W)||(t=r[e+3],n+=(t&Ee)<<21,t<W)||(t=r[e+4],n+=(t&Ee)*os,t<W)||(t=r[e+5],n+=(t&Ee)*is,t<W)||(t=r[e+6],n+=(t&Ee)*ss,t<W)||(t=r[e+7],n+=(t&Ee)*as,t<W))return n;throw new RangeError("Could not decode varint")}function Zd(r,e){let t=r.get(e),n=0;if(n+=t&Ee,t<W||(t=r.get(e+1),n+=(t&Ee)<<7,t<W)||(t=r.get(e+2),n+=(t&Ee)<<14,t<W)||(t=r.get(e+3),n+=(t&Ee)<<21,t<W)||(t=r.get(e+4),n+=(t&Ee)*os,t<W)||(t=r.get(e+5),n+=(t&Ee)*is,t<W)||(t=r.get(e+6),n+=(t&Ee)*ss,t<W)||(t=r.get(e+7),n+=(t&Ee)*as,t<W))return n;throw new RangeError("Could not decode varint")}function wr(r,e,t=0){return e==null&&(e=Je(Le(r))),e instanceof Uint8Array?cs(r,e,t):Gd(r,e,t)}function Yt(r,e=0){return r instanceof Uint8Array?us(r,e):Zd(r,e)}var ls=new Float32Array([-0]),Pt=new Uint8Array(ls.buffer);function wc(r,e,t){ls[0]=r,e[t]=Pt[0],e[t+1]=Pt[1],e[t+2]=Pt[2],e[t+3]=Pt[3]}function xc(r,e){return Pt[0]=r[e],Pt[1]=r[e+1],Pt[2]=r[e+2],Pt[3]=r[e+3],ls[0]}var fs=new Float64Array([-0]),Be=new Uint8Array(fs.buffer);function bc(r,e,t){fs[0]=r,e[t]=Be[0],e[t+1]=Be[1],e[t+2]=Be[2],e[t+3]=Be[3],e[t+4]=Be[4],e[t+5]=Be[5],e[t+6]=Be[6],e[t+7]=Be[7]}function vc(r,e){return Be[0]=r[e],Be[1]=r[e+1],Be[2]=r[e+2],Be[3]=r[e+3],Be[4]=r[e+4],Be[5]=r[e+5],Be[6]=r[e+6],Be[7]=r[e+7],fs[0]}var Wd=BigInt(Number.MAX_SAFE_INTEGER),Jd=BigInt(Number.MIN_SAFE_INTEGER),Pe=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 Xt;if(e<Wd&&e>Jd)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>Ec&&(o=0n,++n>Ec&&(n=0n))),new r(Number(o),Number(n))}static fromNumber(e){if(e===0)return Xt;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):Xt}},Xt=new Pe(0,0);Xt.toBigInt=function(){return 0n};Xt.zzEncode=Xt.zzDecode=function(){return this};Xt.length=function(){return 1};var Ec=4294967296n;function Bc(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 Ac(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 hs(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 Ye(r,e){return RangeError(`index out of range: ${r.pos} + ${e??1} > ${r.len}`)}function Gn(r,e){return(r[e-4]|r[e-3]<<8|r[e-2]<<16|r[e-1]<<24)>>>0}var ds=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,Ye(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 Ye(this,4);return Gn(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw Ye(this,4);return Gn(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw Ye(this,4);let e=xc(this.buf,this.pos);return this.pos+=4,e}double(){if(this.pos+8>this.len)throw Ye(this,4);let e=vc(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 Ye(this,e);return this.pos+=e,t===n?new Uint8Array(0):this.buf.subarray(t,n)}string(){let e=this.bytes();return Ac(e,0,e.length)}skip(e){if(typeof e=="number"){if(this.pos+e>this.len)throw Ye(this,e);this.pos+=e}else do if(this.pos>=this.len)throw Ye(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 Pe(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 Ye(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 Ye(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 Ye(this,8);let e=Gn(this.buf,this.pos+=4),t=Gn(this.buf,this.pos+=4);return new Pe(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=us(this.buf,this.pos);return this.pos+=Le(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 ps(r){return new ds(r instanceof Uint8Array?r:r.subarray())}function xr(r,e,t){let n=ps(r);return e.decode(n,void 0,t)}var ms={};ke(ms,{base10:()=>Yd});var Yd=kt({prefix:"9",name:"base10",alphabet:"0123456789"});var gs={};ke(gs,{base16:()=>Xd,base16upper:()=>Qd});var Xd=se({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Qd=se({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var ys={};ke(ys,{base2:()=>e0});var e0=se({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var ws={};ke(ws,{base256emoji:()=>i0});var Ic=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}"),t0=Ic.reduce((r,e,t)=>(r[t]=e,r),[]),r0=Ic.reduce((r,e,t)=>{let n=e.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${e}`);return r[n]=t,r},[]);function n0(r){return r.reduce((e,t)=>(e+=t0[t],e),"")}function o0(r){let e=[];for(let t of r){let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);let o=r0[n];if(o==null)throw new Error(`Non-base256emoji character: ${t}`);e.push(o)}return new Uint8Array(e)}var i0=cr({prefix:"\u{1F680}",name:"base256emoji",encode:n0,decode:o0});var xs={};ke(xs,{base8:()=>s0});var s0=se({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var bs={};ke(bs,{identity:()=>a0});var a0=cr({prefix:"\0",name:"identity",encode:r=>La(r),decode:r=>_a(r)});var ry=new TextEncoder,ny=new TextDecoder;var Bs={};ke(Bs,{sha256:()=>Jr,sha512:()=>l0});function Es({name:r,code:e,encode:t}){return new vs(r,e,t)}var vs=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?je(this.code,t):t.then(n=>je(this.code,n))}else throw Error("Unknown type, must be binary type")}};function Cc(r){return async e=>new Uint8Array(await crypto.subtle.digest(r,e))}var Jr=Es({name:"sha2-256",code:18,encode:Cc("SHA-256")}),l0=Es({name:"sha2-512",code:19,encode:Cc("SHA-512")});var Yr={...bs,...ys,...xs,...ms,...gs,...Ui,...Pi,...Ri,...Li,...ws},my={...Bs,...Oi};function Nc(r,e,t,n){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:n}}}var Tc=Nc("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),As=Nc("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=Je(r.length);for(let t=0;t<r.length;t++)e[t]=r.charCodeAt(t);return e}),f0={utf8:Tc,"utf-8":Tc,hex:Yr.base16,latin1:As,ascii:As,binary:As,...Yr},Zn=f0;function J(r,e="utf8"){let t=Zn[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return t.decoder.decode(`${t.prefix}${r}`)}function Ss(r){let e=r??8192,t=e>>>1,n,o=e;return function(s){if(s<1||s>t)return Je(s);o+s>e&&(n=Je(e),o=0);let a=n.subarray(o,o+=s);return o&7&&(o=(o|7)+1),a}}var Qt=class{fn;len;next;val;constructor(e,t,n){this.fn=e,this.len=t,this.next=void 0,this.val=n}};function Is(){}var Cs=class{head;tail;len;next;constructor(e){this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}},h0=Ss();function d0(r){return globalThis.Buffer!=null?Je(r):h0(r)}var Qr=class{len;head;tail;states;constructor(){this.len=0,this.head=new Qt(Is,0,0),this.tail=this.head,this.states=null}_push(e,t,n){return this.tail=this.tail.next=new Qt(e,t,n),this.len+=t,this}uint32(e){return this.len+=(this.tail=this.tail.next=new Ts((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(Wn,10,Pe.fromNumber(e)):this.uint32(e)}sint32(e){return this.uint32((e<<1^e>>31)>>>0)}uint64(e){let t=Pe.fromBigInt(e);return this._push(Wn,t.length(),t)}uint64Number(e){return this._push(cs,Le(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=Pe.fromBigInt(e).zzEncode();return this._push(Wn,t.length(),t)}sint64Number(e){let t=Pe.fromNumber(e).zzEncode();return this._push(Wn,t.length(),t)}sint64String(e){return this.sint64(BigInt(e))}bool(e){return this._push(ks,1,e?1:0)}fixed32(e){return this._push(Xr,4,e>>>0)}sfixed32(e){return this.fixed32(e)}fixed64(e){let t=Pe.fromBigInt(e);return this._push(Xr,4,t.lo)._push(Xr,4,t.hi)}fixed64Number(e){let t=Pe.fromNumber(e);return this._push(Xr,4,t.lo)._push(Xr,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(wc,4,e)}double(e){return this._push(bc,8,e)}bytes(e){let t=e.length>>>0;return t===0?this._push(ks,1,0):this.uint32(t)._push(m0,t,e)}string(e){let t=Bc(e);return t!==0?this.uint32(t)._push(hs,t,e):this._push(ks,1,0)}fork(){return this.states=new Cs(this),this.head=this.tail=new Qt(Is,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 Qt(Is,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=d0(this.len),n=0;for(;e!=null;)e.fn(e.val,t,n),n+=e.len,e=e.next;return t}};function ks(r,e,t){e[t]=r&255}function p0(r,e,t){for(;r>127;)e[t++]=r&127|128,r>>>=7;e[t]=r}var Ts=class extends Qt{next;constructor(e,t){super(p0,e,t),this.next=void 0}};function Wn(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 Xr(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 m0(r,e,t){e.set(r,t)}globalThis.Buffer!=null&&(Qr.prototype.bytes=function(r){let e=r.length>>>0;return this.uint32(e),e>0&&this._push(g0,e,r),this},Qr.prototype.string=function(r){let e=globalThis.Buffer.byteLength(r);return this.uint32(e),e>0&&this._push(y0,e,r),this});function g0(r,e,t){e.set(r,t)}function y0(r,e,t){r.length<40?hs(r,e,t):e.utf8Write!=null?e.utf8Write(r,t):e.set(J(r),t)}function Ns(){return new Qr}function br(r,e){let t=Ns();return e.encode(r,t,{lengthDelimited:!1}),t.finish()}var vr;(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"})(vr||(vr={}));function Jn(r,e,t,n){return{name:r,type:e,encode:t,decode:n}}function en(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 Jn("enum",vr.VARINT,t,n)}function Er(r,e){return Jn("message",vr.LENGTH_DELIMITED,r,e)}var fe;(function(r){r.RSA="RSA",r.Ed25519="Ed25519",r.secp256k1="secp256k1"})(fe||(fe={}));var Us;(function(r){r[r.RSA=0]="RSA",r[r.Ed25519=1]="Ed25519",r[r.secp256k1=2]="secp256k1"})(Us||(Us={}));(function(r){r.codec=()=>en(Us)})(fe||(fe={}));var it;(function(r){let e;r.codec=()=>(e==null&&(e=Er((t,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),t.Type!=null&&(n.uint32(8),fe.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=fe.codec().decode(t);break}case 2:{i.Data=t.bytes();break}default:{t.skipType(a&7);break}}}return i})),e),r.encode=t=>br(t,r.codec()),r.decode=(t,n)=>xr(t,r.codec(),n)})(it||(it={}));var Rs;(function(r){let e;r.codec=()=>(e==null&&(e=Er((t,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),t.Type!=null&&(n.uint32(8),fe.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=fe.codec().decode(t);break}case 2:{i.Data=t.bytes();break}default:{t.skipType(a&7);break}}}return i})),e),r.encode=t=>br(t,r.codec()),r.decode=(t,n)=>xr(t,r.codec(),n)})(Rs||(Rs={}));var fn={};ke(fn,{MAX_RSA_KEY_SIZE:()=>$o,generateRSAKeyPair:()=>ku,jwkToJWKKeyPair:()=>Cu,jwkToPkcs1:()=>_0,jwkToPkix:()=>Hs,jwkToRSAPrivateKey:()=>Iu,pkcs1ToJwk:()=>Bu,pkcs1ToRSAPrivateKey:()=>Su,pkixToJwk:()=>Au,pkixToRSAPublicKey:()=>$s});var w0=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]),Ft=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Dt=new Uint32Array(64),_s=class extends gr{constructor(){super(64,32,8,!1),this.A=Ft[0]|0,this.B=Ft[1]|0,this.C=Ft[2]|0,this.D=Ft[3]|0,this.E=Ft[4]|0,this.F=Ft[5]|0,this.G=Ft[6]|0,this.H=Ft[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)Dt[l]=e.getUint32(t,!1);for(let l=16;l<64;l++){let h=Dt[l-15],b=Dt[l-2],I=Ge(h,7)^Ge(h,18)^h>>>3,w=Ge(b,17)^Ge(b,19)^b>>>10;Dt[l]=w+Dt[l-7]+I+Dt[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=Ge(a,6)^Ge(a,11)^Ge(a,25),b=u+h+Qa(a,c,f)+w0[l]+Dt[l]|0,w=(Ge(n,2)^Ge(n,13)^Ge(n,22))+ec(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(){Dt.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var Br=Vn(()=>new _s);var j=Tn(Rc());function er(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 Ot(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 Qn(...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 Vs(){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=er(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,er(i,8)-n}function _c(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=Ot(s,8,n),c=new Uint8Array(a);return c[0]|=128,a}let o=Ot(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 Lc(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 Ve(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 Jy=Math.log(2);function eo(){if(typeof BigInt>"u")throw new Error("BigInt is not defined. Your environment doesn't implement BigInt.")}function Ps(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 Et(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 rn=class{constructor(){this.items=[]}write(e){this.items.push(e)}final(){return Ps(this.items)}},tn=[new Uint8Array([1])],Vc="0123456789";var Cr="",Xe=new ArrayBuffer(0),Fs=new Uint8Array(0),nn="EndOfContent",Fc="OCTET STRING",Dc="BIT STRING";function Bt(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):Fs}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(!Et(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",Xe)}toJSON(){return{...super.toJSON(),isHexOnly:this.isHexOnly,valueHex:j.Convert.ToHex(this.valueHexView)}}},e.NAME="hexBlock",e}var xt=class{constructor({blockLength:e=0,error:t=Cr,warnings:n=[],valueBeforeDecode:o=Fs}={}){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)}}};xt.NAME="baseBlock";var Ae=class extends xt{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'")}};Ae.NAME="valueBlock";var to=class extends Bt(xt){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):Fs,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",Xe}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=Ot(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(!Et(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=er(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}}};to.NAME="identificationBlock";var ro=class extends xt{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(!Et(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=er(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=Ot(this.length,8);if(o.byteLength>127)return this.error="Too big length",Xe;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}}};ro.NAME="lengthBlock";var _={},we=class extends xt{constructor({name:e=Cr,optional:t=!1,primitiveSchema:n,...o}={},i){super(o),this.name=e,this.optional=t,n&&(this.primitiveSchema=n),this.idBlock=new to(o),this.lenBlock=new ro(o),this.valueBlock=i?new i(o):new Ae(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 rn;t||Oc(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?Xe: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 Lc(t,n)}};we.NAME="BaseBlock";function Oc(r){if(r instanceof _.Constructed)for(let e of r.valueBlock.value)Oc(e)&&(r.lenBlock.isIndefiniteForm=!0);return!!r.lenBlock.isIndefiniteForm}var no=class extends we{constructor({value:e=Cr,...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}'`}};no.NAME="BaseStringBlock";var oo=class extends Bt(Ae){constructor({isHexOnly:e=!0,...t}={}){super(t),this.isHexOnly=e}};oo.NAME="PrimitiveValueBlock";var Mc,io=class extends we{constructor(e={}){super(e,oo),this.idBlock.isConstructed=!1}};Mc=io;_.Primitive=Mc;io.NAME="PRIMITIVE";function k0(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 Mo(r,e=0,t=r.length){let n=e,o=new we({},Ae),i=new xt;if(!Et(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=we;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=k0(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 Ds(r){if(!r.byteLength){let e=new we({},Ae);return e.error="Input buffer has zero length",{offset:-1,result:e}}return Mo(j.BufferSourceConverter.toUint8Array(r).slice(),0,r.byteLength)}function C0(r,e){return r?1:e}var st=class extends Ae{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(!Et(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(;C0(this.isIndefiniteForm,n)>0;){let s=Mo(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===nn)break}return this.isIndefiniteForm&&(this.value[this.value.length-1].constructor.NAME===nn?this.value.pop():this.warnings.push("No EndOfContent block encoded")),i}toBER(e,t){let n=t||new rn;for(let o=0;o<this.value.length;o++)this.value[o].toBER(e,n);return t?Xe:n.final()}toJSON(){let e={...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,value:[]};for(let t of this.value)e.value.push(t.toJSON());return e}};st.NAME="ConstructedValueBlock";var Hc,Mt=class extends we{constructor(e={}){super(e,st),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
4
|
`).map(o=>` ${o}`).join(`
|
|
5
5
|
`));let t=this.idBlock.tagClass===3?`[${this.idBlock.tagNumber}]`:this.constructor.NAME;return e.length?`${t} :
|
|
6
6
|
${e.join(`
|
|
7
|
-
`)}`:`${t} :`}};Hc=Mt;_.Constructed=Hc;Mt.NAME="CONSTRUCTED";var so=class extends Ae{fromBER(e,t,n){return t}toBER(e){return Xe}};so.override="EndOfContentValueBlock";var $c,ao=class extends we{constructor(e={}){super(e,so),this.idBlock.tagClass=1,this.idBlock.tagNumber=0}};$c=ao;_.EndOfContent=$c;ao.NAME=nn;var Kc,Sr=class extends we{constructor(e={}){super(e,Ae),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}`}};Kc=Sr;_.Null=Kc;Sr.NAME="NULL";var co=class extends Bt(Ae){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 Et(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,Ls.call(this),this.blockLength=n,t+n):-1}toBER(){return this.valueHexView.slice()}toJSON(){return{...super.toJSON(),value:this.value}}};co.NAME="BooleanValueBlock";var qc,uo=class extends we{constructor(e={}){super(e,co),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}`}};qc=uo;_.Boolean=qc;uo.NAME="BOOLEAN";var lo=class extends Bt(st){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=st.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===nn){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, OCTET STRING may consists of OCTET STRINGs only",-1}if(s!==Fc)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?st.prototype.toBER.call(this,e,t):e?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),isConstructed:this.isConstructed}}};lo.NAME="OctetStringValueBlock";var zc,fo=class r extends we{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},lo),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=Mo(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?Mt.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)}};zc=fo;_.OctetString=zc;fo.NAME=Fc;var ho=class extends Bt(st){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=st.prototype.fromBER.call(this,e,t,n),o===-1)return o;for(let a of this.value){let c=a.constructor.NAME;if(c===nn){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, BIT STRING may consists of BIT STRINGs only",-1}if(c!==Dc)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(!Et(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=Mo(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 st.prototype.toBER.call(this,e,t);if(e)return new ArrayBuffer(this.valueHexView.byteLength+1);if(!this.valueHexView.byteLength)return Xe;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}}};ho.NAME="BitStringValueBlock";var jc,Ir=class extends we{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},ho),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 Mt.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)}`}}};jc=Ir;_.BitString=jc;Ir.NAME=Dc;var Gc;function T0(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=Qn(new Uint8Array([f%10]),i);break;default:i[s-l]=f%10}}return t[0]>0&&(i=Qn(t,i)),i}function Pc(r){if(r>=tn.length)for(let e=tn.length;e<=r;e++){let t=new Uint8Array([0]),n=tn[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=Qn(t,n)),tn.push(n)}return tn[r]}function N0(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 on=class extends Bt(Ae){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=Ls.call(this)))}set valueDec(e){this._valueDec=e,this.isHexOnly=!1,this.valueHexView=new Uint8Array(_c(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=N0(Pc(n),t),s="-";break;default:t=T0(t,Pc(n))}n++,o>>=1}}for(let c=0;c<t.length;c++)t[c]&&(a=!0),a&&(s+=Vc.charAt(t[c]));return a===!1&&(s+=Vc.charAt(0)),s}};Gc=on;on.NAME="IntegerValueBlock";Object.defineProperty(Gc.prototype,"valueHex",{set:function(r){this.valueHexView=new Uint8Array(r),this.setValueHex()},get:function(){return this.valueHexView.slice().buffer}});var Zc,xe=class r extends we{constructor(e={}){super(e,on),this.idBlock.tagClass=1,this.idBlock.tagNumber=2}toBigInt(){return eo(),BigInt(this.valueBlock.toString())}static fromBigInt(e){eo();let t=BigInt(e),n=new rn,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()}`}};Zc=xe;_.Integer=Zc;xe.NAME="INTEGER";var Wc,po=class extends xe{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=10}};Wc=po;_.Enumerated=Wc;po.NAME="ENUMERATED";var sn=class extends Bt(Ae){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(!Et(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=er(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),t+this.blockLength)}set valueBigInt(e){eo();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=Ot(this.valueDec,7);if(t.byteLength===0)return this.error="Error during encoding SID value",Xe;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}}};sn.NAME="sidBlock";var mo=class extends Ae{constructor({value:e=Cr,...t}={}){super(t),this.value=[],e&&this.fromString(e)}fromBER(e,t,n){let o=t;for(;n>0;){let i=new sn;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,Xe;t.push(o)}return Vs(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 sn;if(o>Number.MAX_SAFE_INTEGER){eo();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}};mo.NAME="ObjectIdentifierValueBlock";var Jc,kr=class extends we{constructor(e={}){super(e,mo),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()}}};Jc=kr;_.ObjectIdentifier=Jc;kr.NAME="OBJECT IDENTIFIER";var an=class extends Bt(xt){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(!Et(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=er(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=Ot(this.valueDec,7);if(t.byteLength===0)return this.error="Error during encoding SID value",Xe;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}}};an.NAME="relativeSidBlock";var go=class extends Ae{constructor({value:e=Cr,...t}={}){super(t),this.value=[],e&&this.fromString(e)}fromBER(e,t,n){let o=t;for(;n>0;){let i=new an;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,Xe;n.push(i)}return Vs(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 an;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}};go.NAME="RelativeObjectIdentifierValueBlock";var Yc,yo=class extends we{constructor(e={}){super(e,go),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()}}};Yc=yo;_.RelativeObjectIdentifier=Yc;yo.NAME="RelativeObjectIdentifier";var Xc,bt=class extends Mt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=16}};Xc=bt;_.Sequence=Xc;bt.NAME="SEQUENCE";var Qc,wo=class extends Mt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=17}};Qc=wo;_.Set=Qc;wo.NAME="SET";var xo=class extends Bt(Ae){constructor({...e}={}){super(e),this.isHexOnly=!0,this.value=Cr}toJSON(){return{...super.toJSON(),value:this.value}}};xo.NAME="StringValueBlock";var bo=class extends xo{};bo.NAME="SimpleStringValueBlock";var Ce=class extends no{constructor({...e}={}){super(e,bo)}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 vo=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}};vo.NAME="Utf8StringValueBlock";var eu,vt=class extends vo{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=12}};eu=vt;_.Utf8String=eu;vt.NAME="UTF8String";var Eo=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))}};Eo.NAME="BmpStringValueBlock";var tu,Bo=class extends Eo{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=30}};tu=Bo;_.BmpString=tu;Bo.NAME="BMPString";var Ao=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=Ot(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}};Ao.NAME="UniversalStringValueBlock";var ru,So=class extends Ao{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=28}};ru=So;_.UniversalString=ru;So.NAME="UniversalString";var nu,Io=class extends Ce{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=18}};nu=Io;_.NumericString=nu;Io.NAME="NumericString";var ou,ko=class extends Ce{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=19}};ou=ko;_.PrintableString=ou;ko.NAME="PrintableString";var iu,Co=class extends Ce{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=20}};iu=Co;_.TeletexString=iu;Co.NAME="TeletexString";var su,To=class extends Ce{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=21}};su=To;_.VideotexString=su;To.NAME="VideotexString";var au,No=class extends Ce{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=22}};au=No;_.IA5String=au;No.NAME="IA5String";var cu,Uo=class extends Ce{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=25}};cu=Uo;_.GraphicString=cu;Uo.NAME="GraphicString";var uu,cn=class extends Ce{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=26}};uu=cn;_.VisibleString=uu;cn.NAME="VisibleString";var lu,Ro=class extends Ce{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=27}};lu=Ro;_.GeneralString=lu;Ro.NAME="GeneralString";var fu,_o=class extends Ce{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=29}};fu=_o;_.CharacterString=fu;_o.NAME="CharacterString";var hu,un=class extends cn{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]=Ve(this.year<2e3?this.year-1900:this.year-2e3,2),t[1]=Ve(this.month,2),t[2]=Ve(this.day,2),t[3]=Ve(this.hour,2),t[4]=Ve(this.minute,2),t[5]=Ve(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}}};hu=un;_.UTCTime=hu;un.NAME="UTCTime";var du,Lo=class extends un{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(Ve(this.year,4)),t.push(Ve(this.month,2)),t.push(Ve(this.day,2)),t.push(Ve(this.hour,2)),t.push(Ve(this.minute,2)),t.push(Ve(this.second,2)),this.millisecond!==0&&(t.push("."),t.push(Ve(this.millisecond,3))),t.push("Z"),t.join("")}return super.toString(e)}toJSON(){return{...super.toJSON(),millisecond:this.millisecond}}};du=Lo;_.GeneralizedTime=du;Lo.NAME="GeneralizedTime";var pu,Vo=class extends vt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=31}};pu=Vo;_.DATE=pu;Vo.NAME="DATE";var mu,Po=class extends vt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=32}};mu=Po;_.TimeOfDay=mu;Po.NAME="TimeOfDay";var gu,Fo=class extends vt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=33}};gu=Fo;_.DateTime=gu;Fo.NAME="DateTime";var yu,Do=class extends vt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=34}};yu=Do;_.Duration=yu;Do.NAME="Duration";var wu,Oo=class extends vt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=14}};wu=Oo;_.TIME=wu;Oo.NAME="TIME";function oe(r,e="utf8"){let t=Zn[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return t.encoder.encode(r).substring(1)}var ln=class extends Error{constructor(e="An error occurred while verifying a message"){super(e),this.name="VerificationError"}},Ho=class extends Error{constructor(e="Missing Web Crypto API"){super(e),this.name="WebCryptoMissingError"}};var xu={get(r=globalThis){let e=r.crypto;if(e?.subtle==null)throw new Ho("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 Ht=xu;async function bu(r){let e=await Ht.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 R0(e);return{privateKey:t[0],publicKey:t[1]}}async function vu(r,e){let t=await Ht.get().subtle.importKey("jwk",r,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["sign"]),n=await Ht.get().subtle.sign({name:"RSASSA-PKCS1-v1_5"},t,e instanceof Uint8Array?e:e.subarray());return new Uint8Array(n,0,n.byteLength)}async function Eu(r,e,t){let n=await Ht.get().subtle.importKey("jwk",r,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["verify"]);return Ht.get().subtle.verify({name:"RSASSA-PKCS1-v1_5"},n,e,t instanceof Uint8Array?t:t.subarray())}async function R0(r){if(r.privateKey==null||r.publicKey==null)throw new ve("Private and public key are required");return Promise.all([Ht.get().subtle.exportKey("jwk",r.privateKey),Ht.get().subtle.exportKey("jwk",r.publicKey)])}function Ds(r){if(r.kty!=="RSA")throw new ve("invalid key type");if(r.n==null)throw new ve("invalid key modulus");return J(r.n,"base64url").length*8}var Tr=class{type="RSA";_key;_raw;_multihash;constructor(e,t){this._key=e,this._multihash=t}get raw(){return this._raw==null&&(this._raw=fn.jwkToPkix(this._key)),this._raw}toMultihash(){return this._multihash}toCID(){return ie.createV1(114,this._multihash)}toString(){return te.encode(this.toMultihash().bytes).substring(1)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:ue(this.raw,e.raw)}verify(e,t){return Eu(this._key,t,e)}},hn=class{type="RSA";_key;_raw;publicKey;constructor(e,t){this._key=e,this.publicKey=t}get raw(){return this._raw==null&&(this._raw=fn.jwkToPkcs1(this._key)),this._raw}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:ue(this.raw,e.raw)}sign(e){return vu(this._key,e)}};var $o=8192,Os=18;function Bu(r){let{result:e}=Fs(r),t=e.valueBlock.value;return{n:at(t[1]),e:at(t[2]),d:at(t[3]),p:at(t[4]),q:at(t[5]),dp:at(t[6]),dq:at(t[7]),qi:at(t[8]),kty:"RSA",alg:"RS256"}}function _0(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 ve("JWK was missing components");let t=new bt({value:[new xe({value:0}),xe.fromBigInt(ct(J(r.n,"base64url"))),xe.fromBigInt(ct(J(r.e,"base64url"))),xe.fromBigInt(ct(J(r.d,"base64url"))),xe.fromBigInt(ct(J(r.p,"base64url"))),xe.fromBigInt(ct(J(r.q,"base64url"))),xe.fromBigInt(ct(J(r.dp,"base64url"))),xe.fromBigInt(ct(J(r.dq,"base64url"))),xe.fromBigInt(ct(J(r.qi,"base64url")))]}).toBER();return new Uint8Array(t,0,t.byteLength)}function Au(r){let{result:e}=Fs(r),t=e.valueBlock.value[1].valueBlock.value[0].valueBlock.value;return{kty:"RSA",n:at(t[0]),e:at(t[1])}}function Ms(r){if(r.n==null||r.e==null)throw new ve("JWK was missing components");let t=new bt({value:[new bt({value:[new kr({value:"1.2.840.113549.1.1.1"}),new Sr]}),new Ir({valueHex:new bt({value:[xe.fromBigInt(ct(J(r.n,"base64url"))),xe.fromBigInt(ct(J(r.e,"base64url")))]}).toBER()})]}).toBER();return new Uint8Array(t,0,t.byteLength)}function at(r){let e=r.valueBlock.valueHexView;for(;e[0]===0;)e=e.subarray(1);return oe(e,"base64url")}function ct(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 Su(r){let e=Bu(r);return Iu(e)}function Hs(r){let e=Au(r);if(Ds(e)>$o)throw new or("Key size is too large");let t=Br(it.encode({Type:fe.RSA,Data:r})),n=je(Os,t);return new Tr(e,n)}function Iu(r){if(Ds(r)>$o)throw new ve("Key size is too large");let e=Cu(r),t=Br(it.encode({Type:fe.RSA,Data:Ms(e.publicKey)})),n=je(Os,t);return new hn(e.privateKey,new Tr(e.publicKey,n))}async function ku(r){if(r>$o)throw new ve("Key size is too large");let e=await bu(r),t=Br(it.encode({Type:fe.RSA,Data:Ms(e.publicKey)})),n=je(Os,t);return new hn(e.privateKey,new Tr(e.publicKey,n))}function Cu(r){if(r==null)throw new ve("Missing key parameter");return{privateKey:r,publicKey:{kty:r.kty,n:r.n,e:r.e}}}var Ko=class extends mr{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,Ja(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 pr(this),this.iHash.update(e),this}digestInto(e){pr(this),dr(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()}},$s=(r,e,t)=>new Ko(r,e).update(t).digest();$s.create=(r,e)=>new Ko(r,e);function Tu(r){r.lowS!==void 0&&Ze("lowS",r.lowS),r.prehash!==void 0&&Ze("prehash",r.prehash)}function L0(r){let e=Wr(r);ot(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:V0,hexToBytes:P0}=On,At={Err:class extends Error{constructor(e=""){super(e)}},_tlv:{encode:(r,e)=>{let{Err:t}=At;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=jt(n);if(o.length/2&128)throw new t("tlv.encode: long form length too big");let i=n>127?jt(o.length/2|128):"";return`${jt(r)}${i}${o}${e}`},decode(r,e){let{Err:t}=At,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}=At;if(r<St)throw new e("integer: negative integers are not allowed");let t=jt(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}=At;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 V0(r)}},toSig(r){let{Err:e,_int:t,_tlv:n}=At,o=typeof r=="string"?P0(r):r;yr(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}=At,n=`${e.encode(2,t.encode(r.r))}${e.encode(2,t.encode(r.s))}`;return e.encode(48,n)}},St=BigInt(0),pe=BigInt(1),Cw=BigInt(2),Nu=BigInt(3),Tw=BigInt(4);function F0(r){let e=L0(r),{Fp:t}=e,n=Vt(e.n,e.nBitLength),o=e.toBytes||((w,d,E)=>{let C=d.toAffine();return yt(Uint8Array.from([4]),t.toBytes(C.x),t.toBytes(C.y))}),i=e.fromBytes||(w=>{let d=w.subarray(1),E=t.fromBytes(d.subarray(0,t.BYTES)),C=t.fromBytes(d.subarray(t.BYTES,2*t.BYTES));return{x:E,y:C}});function s(w){let{a:d,b:E}=e,C=t.sqr(w),x=t.mul(C,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 Gr(w,pe,e.n)}function c(w){let{allowedPrivateKeyLengths:d,nByteLength:E,wrapPrivateKey:C,n:x}=e;if(d&&typeof w!="bigint"){if(Rt(w)&&(w=mt(w)),typeof w!="string"||!d.includes(w.length))throw new Error("Invalid key");w=w.padStart(E*2,"0")}let T;try{T=typeof w=="bigint"?w:gt(ae("private key",w,E))}catch{throw new Error(`private key must be ${E} bytes, hex or bigint, not ${typeof w}`)}return C&&(T=X(T,x)),Re("private key",T,pe,x),T}function f(w){if(!(w instanceof h))throw new Error("ProjectivePoint expected")}let u=Wt((w,d)=>{let{px:E,py:C,pz:x}=w;if(t.eql(x,t.ONE))return{x:E,y:C};let T=w.is0();d==null&&(d=T?t.ONE:t.inv(x));let F=t.mul(E,d),V=t.mul(C,d),U=t.mul(x,d);if(T)return{x:t.ZERO,y:t.ZERO};if(!t.eql(U,t.ONE))throw new Error("invZ was invalid");return{x:F,y:V}}),l=Wt(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 C=t.sqr(E),x=s(d);if(!t.eql(C,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,C){if(this.px=d,this.py=E,this.pz=C,d==null||!t.isValid(d))throw new Error("x required");if(E==null||!t.isValid(E))throw new Error("y required");if(C==null||!t.isValid(C))throw new Error("z required");Object.freeze(this)}static fromAffine(d){let{x:E,y:C}=d||{};if(!d||!t.isValid(E)||!t.isValid(C))throw new Error("invalid affine point");if(d instanceof h)throw new Error("projective point not allowed");let x=T=>t.eql(T,t.ZERO);return x(E)&&x(C)?h.ZERO:new h(E,C,t.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(d){let E=t.invertBatch(d.map(C=>C.pz));return d.map((C,x)=>C.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 $n(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:C,pz:x}=this,{px:T,py:F,pz:V}=d,U=t.eql(t.mul(E,V),t.mul(T,x)),g=t.eql(t.mul(C,V),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,C=t.mul(E,Nu),{px:x,py:T,pz:F}=this,V=t.ZERO,U=t.ZERO,g=t.ZERO,v=t.mul(x,x),D=t.mul(T,T),R=t.mul(F,F),N=t.mul(x,T);return N=t.add(N,N),g=t.mul(x,F),g=t.add(g,g),V=t.mul(d,g),U=t.mul(C,R),U=t.add(V,U),V=t.sub(D,U),U=t.add(D,U),U=t.mul(V,U),V=t.mul(N,V),g=t.mul(C,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(T,F),R=t.add(R,R),v=t.mul(R,N),V=t.sub(V,v),g=t.mul(R,D),g=t.add(g,g),g=t.add(g,g),new h(V,U,g)}add(d){f(d);let{px:E,py:C,pz:x}=this,{px:T,py:F,pz:V}=d,U=t.ZERO,g=t.ZERO,v=t.ZERO,D=e.a,R=t.mul(e.b,Nu),N=t.mul(E,T),$=t.mul(C,F),A=t.mul(x,V),S=t.add(E,C),m=t.add(T,F);S=t.mul(S,m),m=t.add(N,$),S=t.sub(S,m),m=t.add(E,x);let p=t.add(T,V);return m=t.mul(m,p),p=t.add(N,A),m=t.sub(m,p),p=t.add(C,x),U=t.add(F,V),p=t.mul(p,U),U=t.add($,A),p=t.sub(p,U),v=t.mul(D,m),U=t.mul(R,A),v=t.add(U,v),U=t.sub($,v),v=t.add($,v),g=t.mul(U,v),$=t.add(N,N),$=t.add($,N),A=t.mul(D,A),m=t.mul(R,m),$=t.add($,A),A=t.sub(N,A),A=t.mul(D,A),m=t.add(m,A),N=t.mul($,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,$),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){Re("scalar",d,St,e.n);let E=h.ZERO;if(d===St)return E;if(d===pe)return this;let{endo:C}=e;if(!C)return I.unsafeLadder(this,d);let{k1neg:x,k1:T,k2neg:F,k2:V}=C.splitScalar(d),U=E,g=E,v=this;for(;T>St||V>St;)T&pe&&(U=U.add(v)),V&pe&&(g=g.add(v)),v=v.double(),T>>=pe,V>>=pe;return x&&(U=U.negate()),F&&(g=g.negate()),g=new h(t.mul(g.px,C.beta),g.py,g.pz),U.add(g)}multiply(d){let{endo:E,n:C}=e;Re("scalar",d,pe,C);let x,T;if(E){let{k1neg:F,k1:V,k2neg:U,k2:g}=E.splitScalar(d),{p:v,f:D}=this.wNAF(V),{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),T=D.add(N)}else{let{p:F,f:V}=this.wNAF(d);x=F,T=V}return h.normalizeZ([x,T])[0]}multiplyAndAddUnsafe(d,E,C){let x=h.BASE,T=(V,U)=>U===St||U===pe||!V.equals(x)?V.multiplyUnsafe(U):V.multiply(U),F=T(this,E).add(T(d,C));return F.is0()?void 0:F}toAffine(d){return u(this,d)}isTorsionFree(){let{h:d,isTorsionFree:E}=e;if(d===pe)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===pe?this:E?E(h,this):this.multiplyUnsafe(e.h)}toRawBytes(d=!0){return Ze("isCompressed",d),this.assertValidity(),o(h,this,d)}toHex(d=!0){return Ze("isCompressed",d),mt(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=Hn(h,e.endo?Math.ceil(b/2):b);return{CURVE:e,ProjectivePoint:h,normPrivateKeyToScalar:c,weierstrassEquation:s,isWithinCurveOrder:a}}function D0(r){let e=Wr(r);return ot(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function Uu(r){let e=D0(r),{Fp:t,n}=e,o=t.BYTES+1,i=2*t.BYTES+1;function s(A){return X(A,n)}function a(A){return Mn(A,n)}let{ProjectivePoint:c,normPrivateKeyToScalar:f,weierstrassEquation:u,isWithinCurveOrder:l}=F0({...e,toBytes(A,S,m){let p=S.toAffine(),B=t.toBytes(p.x),P=yt;return Ze("isCompressed",m),m?P(Uint8Array.from([S.hasEvenY()?2:3]),B):P(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=gt(p);if(!Gr(B,pe,t.ORDER))throw new Error("Point is not on curve");let P=u(B),O;try{O=t.sqrt(P)}catch(G){let z=G instanceof Error?": "+G.message:"";throw new Error("Point is not on curve"+z)}let M=(O&pe)===pe;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)),P=t.fromBytes(p.subarray(t.BYTES,2*t.BYTES));return{x:B,y:P}}else throw new Error(`Point of length ${S} was invalid. Expected ${o} compressed bytes or ${i} uncompressed bytes`)}}),h=A=>mt(Lt(A,e.nByteLength));function b(A){let S=n>>pe;return A>S}function I(A){return b(A)?s(-A):A}let w=(A,S,m)=>gt(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}=At.toSig(ae("DER",S));return new d(m,p)}assertValidity(){Re("r",this.r,pe,n),Re("s",this.s,pe,n)}addRecoveryBit(S){return new d(this.r,this.s,S)}recoverPublicKey(S){let{r:m,s:p,recovery:B}=this,P=V(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(-P*G),Y=s(p*G),ee=c.BASE.multiplyAndAddUnsafe(q,z,Y);if(!ee)throw new Error("point at infinify");return ee.assertValidity(),ee}hasHighS(){return b(this.s)}normalizeS(){return this.hasHighS()?new d(this.r,s(-this.s),this.recovery):this}toDERRawBytes(){return Gt(this.toDERHex())}toDERHex(){return At.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Gt(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=Yi(e.n);return uc(e.randomBytes(A),e.n)},precompute(A=8,S=c.BASE){return S._setWindowSize(A),S.multiply(BigInt(3)),S}};function C(A,S=!0){return c.fromPrivateKey(A).toRawBytes(S)}function x(A){let S=Rt(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 T(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=gt(A),m=A.length*8-e.nBitLength;return m>0?S>>BigInt(m):S},V=e.bits2int_modN||function(A){return s(F(A))},U=Zr(e.nBitLength);function g(A){return Re(`num < 2^${e.nBitLength}`,A,St,U),Lt(A,e.nByteLength)}function v(A,S,m=D){if(["recovered","canonical"].some(de=>de in m))throw new Error("sign() legacy options not supported");let{hash:p,randomBytes:B}=e,{lowS:P,prehash:O,extraEntropy:M}=m;P==null&&(P=!0),A=ae("msgHash",A),Tu(m),O&&(A=ae("prehashed msgHash",p(A)));let q=V(A),G=f(S),z=[g(G),g(q)];if(M!=null&&M!==!1){let de=M===!0?B(t.BYTES):M;z.push(ae("extraEntropy",de))}let Y=yt(...z),ee=q;function he(de){let ye=F(de);if(!l(ye))return;let Ie=a(ye),ce=c.BASE.multiply(ye).toAffine(),Ne=s(ce.x);if(Ne===St)return;let lt=s(Ie*s(ee+Ne*G));if(lt===St)return;let Hr=(ce.x===Ne?0:2)|Number(ce.y&pe),$r=lt;return P&&b(lt)&&($r=I(lt),Hr^=1),new d(Ne,$r,Hr)}return{seed:Y,k2sig:he}}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),P=e;return Gi(P.hash.outputLen,P.nByteLength,P.hmac)(p,B)}c.BASE._setWindowSize(8);function $(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");Tu(p);let{lowS:P,prehash:O}=p,M,q;try{if(typeof B=="string"||Rt(B))try{M=d.fromDER(B)}catch(ce){if(!(ce instanceof At.Err))throw ce;M=d.fromCompact(B)}else if(typeof B=="object"&&typeof B.r=="bigint"&&typeof B.s=="bigint"){let{r:ce,s:Ne}=B;M=new d(ce,Ne)}else throw new Error("PARSE");q=c.fromHex(m)}catch(ce){if(ce.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(P&&M.hasHighS())return!1;O&&(S=e.hash(S));let{r:G,s:z}=M,Y=V(S),ee=a(z),he=s(Y*ee),de=s(G*ee),ye=c.BASE.multiplyAndAddUnsafe(q,he,de)?.toAffine();return ye?s(ye.x)===G:!1}return{CURVE:e,getPublicKey:C,getSharedSecret:T,sign:N,verify:$,ProjectivePoint:c,Signature:d,utils:E}}function O0(r){return{hash:r,hmac:(e,...t)=>$s(r,e,Oi(...t)),randomBytes:Pn}}function Ru(r,e){let t=n=>Uu({...r,...O0(n)});return Object.freeze({...t(e),create:t})}var Vu=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),_u=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),M0=BigInt(1),Ks=BigInt(2),Lu=(r,e)=>(r+e/Ks)/e;function H0(r){let e=Vu,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=ne(u,t,e)*u%e,h=ne(l,t,e)*u%e,b=ne(h,Ks,e)*f%e,I=ne(b,o,e)*b%e,w=ne(I,i,e)*I%e,d=ne(w,a,e)*w%e,E=ne(d,c,e)*d%e,C=ne(E,a,e)*w%e,x=ne(C,t,e)*u%e,T=ne(x,s,e)*I%e,F=ne(T,n,e)*f%e,V=ne(F,Ks,e);if(!qs.eql(qs.sqr(V),r))throw new Error("Cannot find square root");return V}var qs=Vt(Vu,void 0,void 0,{sqrt:H0}),tr=Ru({a:BigInt(0),b:BigInt(7),Fp:qs,n:_u,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:r=>{let e=_u,t=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-M0*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),i=t,s=BigInt("0x100000000000000000000000000000000"),a=Lu(i*r,e),c=Lu(-n*r,e),f=X(r-a*t-c*o,e),u=X(-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}}}},Br),Dw=BigInt(0);var Ow=tr.ProjectivePoint;function Fe(r,e){e==null&&(e=r.reduce((o,i)=>o+i.length,0));let t=Je(e),n=0;for(let o of r)t.set(o,n),n+=o.length;return t}function Pu(r){return r==null?!1:typeof r.then=="function"&&typeof r.catch=="function"&&typeof r.finally=="function"}function Fu(r,e,t){let n=Jr.digest(t instanceof Uint8Array?t:t.subarray());if(Pu(n))return n.then(({digest:o})=>tr.verify(e,o,r)).catch(o=>{throw new ln(String(o))});try{return tr.verify(e,n.digest,r)}catch(o){throw new ln(String(o))}}var qo=class{type="secp256k1";raw;_key;constructor(e){this._key=Ou(e),this.raw=Du(this._key)}toMultihash(){return dt.digest(jn(this))}toCID(){return ie.createV1(114,this.toMultihash())}toString(){return te.encode(this.toMultihash().bytes).substring(1)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:ue(this.raw,e.raw)}verify(e,t){return Fu(this._key,t,e)}};function zs(r){return new qo(r)}function Du(r){return tr.ProjectivePoint.fromHex(r).toRawBytes(!0)}function Ou(r){try{return tr.ProjectivePoint.fromHex(r),r}catch(e){throw new or(String(e))}}function Mu(r){let{Type:e,Data:t}=it.decode(r),n=t??new Uint8Array;switch(e){case fe.RSA:return Hs(n);case fe.Ed25519:return rs(n);case fe.secp256k1:return zs(n);default:throw new sr}}function zo(r){let{Type:e,Data:t}=it.decode(r.digest),n=t??new Uint8Array;switch(e){case fe.Ed25519:return rs(n);case fe.secp256k1:return zs(n);default:throw new sr}}function jn(r){return it.encode({Type:fe[r.type],Data:r.raw})}var Hu=Symbol.for("nodejs.util.inspect.custom"),$0=114,dn=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()})`}[Si]=!0;toString(){return this.string==null&&(this.string=te.encode(this.multihash.bytes).slice(1)),this.string}toMultihash(){return this.multihash}toCID(){return ie.createV1($0,this.multihash)}toJSON(){return this.toString()}equals(e){if(e==null)return!1;if(e instanceof Uint8Array)return ue(this.multihash.bytes,e);if(typeof e=="string")return this.toString()===e;if(e?.toMultihash()?.bytes!=null)return ue(this.multihash.bytes,e.toMultihash().bytes);throw new Error("not valid Id")}[Hu](){return`PeerId(${this.toString()})`}},jo=class extends dn{type="RSA";publicKey;constructor(e){super({...e,type:"RSA"}),this.publicKey=e.publicKey}},Go=class extends dn{type="Ed25519";publicKey;constructor(e){super({...e,type:"Ed25519"}),this.publicKey=e.publicKey}},Zo=class extends dn{type="secp256k1";publicKey;constructor(e){super({...e,type:"secp256k1"}),this.publicKey=e.publicKey}},K0=2336,Wo=class{type="url";multihash;publicKey;url;constructor(e){this.url=e.toString(),this.multihash=dt.digest(J(this.url))}[Hu](){return`PeerId(${this.url})`}[Si]=!0;toString(){return this.toCID().toString()}toMultihash(){return this.multihash}toCID(){return ie.createV1(K0,this.toMultihash())}toJSON(){return this.toString()}equals(e){return e==null?!1:(e instanceof Uint8Array&&(e=oe(e)),e.toString()===this.toString())}};function $u(r,e){let t;if(r.charAt(0)==="1"||r.charAt(0)==="Q")t=ht(te.decode(`z${r}`));else{if(e==null)throw new ve('Please pass a multibase decoder for strings that do not start with "1" or "Q"');t=ht(e.decode(r))}return q0(t)}function q0(r){if(j0(r))return new jo({multihash:r});if(z0(r))try{let e=zo(r);if(e.type==="Ed25519")return new Go({multihash:r,publicKey:e});if(e.type==="secp256k1")return new Zo({multihash:r,publicKey:e})}catch{let t=oe(r.digest);return new Wo(new URL(t))}throw new ir("Supplied PeerID Multihash is invalid")}function z0(r){return r.code===dt.code}function j0(r){return r.code===Jr.code}var Jo=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 Ku=45,G0=15,Nr=new Jo;function js(r){if(!(r.length>G0))return Nr.new(r).parseWith(()=>Nr.readIPv4Addr())}function Gs(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>Ku))return Nr.new(r).parseWith(()=>Nr.readIPv6Addr())}function Yo(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>Ku))return Nr.new(r).parseWith(()=>Nr.readIPAddr())}var tb=parseInt("0xFFFF",16),rb=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);function ju(r){return!!js(r)}function Gu(r){return!!Gs(r)}function Xo(r){return!!Yo(r)}var Zu=ju,X0=Gu,Zs=function(r){let e=0;if(r=r.toString().trim(),Zu(r)){let t=new Uint8Array(e+4);return r.split(/\./g).forEach(n=>{t[e++]=parseInt(n,10)&255}),t}if(X0(r)){let t=r.split(":",8),n;for(n=0;n<t.length;n++){let i=Zu(t[n]),s;i&&(s=Zs(t[n]),t[n]=oe(s.slice(0,2),"base16")),s!=null&&++n<8&&t.splice(n,0,oe(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")},Wu=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 Ur={},Ws={},ep=[[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"]];ep.forEach(r=>{let e=tp(...r);Ws[e.code]=e,Ur[e.name]=e});function tp(r,e,t,n,o){return{code:r,size:e,name:t,resolvable:!!n,path:!!o}}function Q(r){if(typeof r=="number"){if(Ws[r]!=null)return Ws[r];throw new Error(`no protocol with code: ${r}`)}else if(typeof r=="string"){if(Ur[r]!=null)return Ur[r];throw new Error(`no protocol with name: ${r}`)}throw new Error(`invalid protocol id type: ${typeof r}`)}var Ob=Q("ip4"),Mb=Q("ip6"),Hb=Q("ipcidr");function Qs(r,e){switch(Q(r).code){case 4:case 41:return np(e);case 42:return Xs(e);case 6:case 273:case 33:case 132:return Xu(e).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return Xs(e);case 421:return ap(e);case 444:return Yu(e);case 445:return Yu(e);case 466:return sp(e);case 481:return globalThis.encodeURIComponent(Xs(e));default:return oe(e,"base16")}}function ea(r,e){switch(Q(r).code){case 4:return Ju(e);case 41:return Ju(e);case 42:return Ys(e);case 6:case 273:case 33:case 132:return ta(parseInt(e,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return Ys(e);case 421:return op(e);case 444:return cp(e);case 445:return up(e);case 466:return ip(e);case 481:return Ys(globalThis.decodeURIComponent(e));default:return J(e,"base16")}}var Js=Object.values(Yr).map(r=>r.decoder),rp=function(){let r=Js[0].or(Js[1]);return Js.slice(2).forEach(e=>r=r.or(e)),r}();function Ju(r){if(!Xo(r))throw new Error("invalid ip address");return Zs(r)}function np(r){let e=Wu(r,0,r.length);if(e==null)throw new Error("ipBuff is required");if(!Xo(e))throw new Error("invalid ip address");return e}function ta(r){let e=new ArrayBuffer(2);return new DataView(e).setUint16(0,r),new Uint8Array(e)}function Xu(r){return new DataView(r.buffer).getUint16(r.byteOffset)}function Ys(r){let e=J(r),t=Uint8Array.from(wr(e.length));return Fe([t,e],t.length+e.length)}function Xs(r){let e=Yt(r);if(r=r.slice(Le(e)),r.length!==e)throw new Error("inconsistent lengths");return oe(r)}function op(r){let e;r[0]==="Q"||r[0]==="1"?e=ht(te.decode(`z${r}`)).bytes:e=ie.parse(r).multihash.bytes;let t=Uint8Array.from(wr(e.length));return Fe([t,e],t.length+e.length)}function ip(r){let e=rp.decode(r),t=Uint8Array.from(wr(e.length));return Fe([t,e],t.length+e.length)}function sp(r){let e=Yt(r),t=r.slice(Le(e));if(t.length!==e)throw new Error("inconsistent lengths");return"u"+oe(t,"base64url")}function ap(r){let e=Yt(r),t=r.slice(Le(e));if(t.length!==e)throw new Error("inconsistent lengths");return oe(t,"base58btc")}function cp(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=ze.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=ta(n);return Fe([t,o],t.length+o.length)}function up(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=ze.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=ta(n);return Fe([t,o],t.length+o.length)}function Yu(r){let e=r.slice(0,r.length-2),t=r.slice(r.length-2),n=oe(e,"base32"),o=Xu(t);return`${n}:${o}`}function Qu(r){r=ra(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=Q(s);if(a.size===0){e.push([a.code]),t.push([a.code]);continue}if(i++,i>=o.length)throw tl("invalid address: "+r);if(a.path===!0){n=ra(o.slice(i).join("/")),e.push([a.code,ea(a.code,n)]),t.push([a.code,n]);break}let c=ea(a.code,o[i]);e.push([a.code,c]),t.push([a.code,Qs(a.code,c)])}return{string:el(t),bytes:oa(e),tuples:e,stringTuples:t,path:n}}function na(r){let e=[],t=[],n=null,o=0;for(;o<r.length;){let i=Yt(r,o),s=Le(i),a=Q(i),c=lp(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 tl("Invalid address Uint8Array: "+oe(r,"base16"));e.push([i,f]);let u=Qs(i,f);if(t.push([i,u]),a.path===!0){n=u;break}}return{bytes:Uint8Array.from(r),string:el(t),tuples:e,stringTuples:t,path:n}}function el(r){let e=[];return r.map(t=>{let n=Q(t[0]);return e.push(n.name),t.length>1&&t[1]!=null&&e.push(t[1]),null}),ra(e.join("/"))}function oa(r){return Fe(r.map(e=>{let t=Q(e[0]),n=Uint8Array.from(wr(t.code));return e.length>1&&e[1]!=null&&(n=Fe([n,e[1]])),n}))}function lp(r,e){if(r.size>0)return r.size/8;if(r.size===0)return 0;{let t=Yt(e instanceof Uint8Array?e:Uint8Array.from(e));return t+Le(t)}}function ra(r){return"/"+r.trim().split("/").filter(e=>e).join("/")}function tl(r){return new Error("Error parsing address: "+r)}var fp=Symbol.for("nodejs.util.inspect.custom"),sa=Symbol.for("@multiformats/js-multiaddr/multiaddr"),hp=[Q("dns").code,Q("dns4").code,Q("dns6").code,Q("dnsaddr").code],ia=class extends Error{constructor(e="No available resolver"){super(e),this.name="NoAvailableResolverError"}},Qo=class r{bytes;#e;#r;#t;#a;[sa]=!0;constructor(e){e==null&&(e="");let t;if(e instanceof Uint8Array)t=na(e);else if(typeof e=="string"){if(e.length>0&&e.charAt(0)!=="/")throw new Error(`multiaddr "${e}" must start with a "/"`);t=Qu(e)}else if(nl(e))t=na(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=Q("tcp"),a=Q("udp"),c=Q("ip4"),f=Q("ip6"),u=Q("dns6"),l=Q("ip6zone");for(let[b,I]of this.stringTuples())b===l.code&&(i=`%${I??""}`),hp.includes(b)&&(t=s.name,o=443,n=`${I??""}${i}`,e=b===u.code?6:4),(b===s.code||b===a.code)&&(t=Q(b).name,o=parseInt(I??"")),(b===c.code||b===f.code)&&(t=Q(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({},Q(e)))}protoCodes(){return this.#r.map(([e])=>e)}protoNames(){return this.#r.map(([e])=>Q(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(oa(t.slice(0,n)));return this}getPeerId(){try{let e=[];this.stringTuples().forEach(([n,o])=>{n===Ur.p2p.code&&e.push([n,o]),n===Ur["p2p-circuit"].code&&(e=[])});let t=e.pop();if(t?.[1]!=null){let n=t[1];return n[0]==="Q"||n[0]==="1"?oe(te.decode(`z${n}`),"base58btc"):oe(ie.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){return this.#a}equals(e){return ue(this.bytes,e.bytes)}async resolve(e){let t=this.protos().find(i=>i.resolvable);if(t==null)return[this];let n=rl.get(t.name);if(n==null)throw new ia(`no available resolver for ${t.name}`);return(await n(this,e)).map(i=>pn(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)}[fp](){return`Multiaddr(${this.#e})`}};var rl=new Map;function nl(r){return!!r?.[sa]}function pn(r){return new Qo(r)}function mn(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*ei(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 dp="/",pp=new TextEncoder().encode(dp),m1=pp[0];var Zp=Tn(ca(),1);var Qe=class extends Error{static name="SignatureVerificationError";constructor(e="Record signature verification failed"){super(e),this.name="SignatureVerificationError"}},ti=class extends Error{static name="RecordExpiredError";constructor(e="Record has expired"){super(e),this.name="RecordExpiredError"}},Rr=class extends Error{static name="UnsupportedValidityError";constructor(e="The validity type is unsupported"){super(e),this.name="UnsupportedValidityError"}},ri=class extends Error{static name="RecordTooLargeError";constructor(e="The record is too large"){super(e),this.name="RecordTooLargeError"}},ni=class extends Error{static name="InvalidValueError";constructor(e="Value must be a valid content path starting with /"){super(e),this.name="InvalidValueError"}},oi=class extends Error{static name="InvalidRecordDataError";constructor(e="Invalid record data"){super(e),this.name="InvalidRecordDataError"}},gn=class extends Error{static name="InvalidEmbeddedPublicKeyError";constructor(e="Invalid embedded public key"){super(e),this.name="InvalidEmbeddedPublicKeyError"}};var et;(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=()=>en(t)}(e=r.ValidityType||(r.ValidityType={}));let n;r.codec=()=>(n==null&&(n=Er((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=>br(o,r.codec()),r.decode=(o,i)=>xr(o,r.codec(),i)})(et||(et={}));var mp=["string","number","bigint","symbol"],gp=["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 ol(r){if(r===null)return"null";if(r===void 0)return"undefined";if(r===!0||r===!1)return"boolean";let e=typeof r;if(mp.includes(e))return e;if(e==="function")return"Function";if(Array.isArray(r))return"Array";if(yp(r))return"Buffer";let t=wp(r);return t||"Object"}function yp(r){return r&&r.constructor&&r.constructor.isBuffer&&r.constructor.isBuffer.call(null,r)}function wp(r){let e=Object.prototype.toString.call(r).slice(8,-1);if(gp.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 _r=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&typeof globalThis.Buffer.isBuffer=="function",xp=new TextDecoder,bp=new TextEncoder;function ii(r){return _r&&globalThis.Buffer.isBuffer(r)}function cl(r){return r instanceof Uint8Array?ii(r)?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r:Uint8Array.from(r)}var ul=_r?(r,e,t)=>t-e>64?globalThis.Buffer.from(r.subarray(e,t)).toString("utf8"):sl(r,e,t):(r,e,t)=>t-e>64?xp.decode(r.subarray(e,t)):sl(r,e,t),ll=_r?r=>r.length>64?globalThis.Buffer.from(r):il(r):r=>r.length>64?bp.encode(r):il(r);var Lr=_r?(r,e,t)=>ii(r)?new Uint8Array(r.subarray(e,t)):r.slice(e,t):(r,e,t)=>r.slice(e,t),fl=_r?(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},hl=_r?r=>globalThis.Buffer.allocUnsafe(r):r=>new Uint8Array(r);function dl(r,e){if(ii(r)&&ii(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 sl(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 vp(n)}var al=4096;function vp(r){let e=r.length;if(e<=al)return String.fromCharCode.apply(String,r);let t="",n=0;for(;n<e;)t+=String.fromCharCode.apply(String,r.slice(n,n+=al));return t}var Ep=256,si=class{constructor(e=Ep){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=hl(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=Lr(n,0,this.cursor)}else t=fl(this.chunks,this.cursor);return e&&this.reset(),t}};var H="CBOR decode error:",ua="CBOR encode error:",yn=[];yn[23]=1;yn[24]=2;yn[25]=3;yn[26]=5;yn[27]=9;function It(r,e,t){if(r.length-e<t)throw new Error(`${H} not enough data for type`)}var me=[24,256,65536,4294967296,BigInt("18446744073709551616")];function De(r,e,t){It(r,e,1);let n=r[e];if(t.strict===!0&&n<me[0])throw new Error(`${H} integer encoded in more bytes than necessary (strict decode)`);return n}function Oe(r,e,t){It(r,e,2);let n=r[e]<<8|r[e+1];if(t.strict===!0&&n<me[1])throw new Error(`${H} integer encoded in more bytes than necessary (strict decode)`);return n}function Me(r,e,t){It(r,e,4);let n=r[e]*16777216+(r[e+1]<<16)+(r[e+2]<<8)+r[e+3];if(t.strict===!0&&n<me[2])throw new Error(`${H} integer encoded in more bytes than necessary (strict decode)`);return n}function He(r,e,t){It(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<me[3])throw new Error(`${H} 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(`${H} integers outside of the safe integer range are not supported`)}function pl(r,e,t,n){return new L(y.uint,De(r,e+1,n),2)}function ml(r,e,t,n){return new L(y.uint,Oe(r,e+1,n),3)}function gl(r,e,t,n){return new L(y.uint,Me(r,e+1,n),5)}function yl(r,e,t,n){return new L(y.uint,He(r,e+1,n),9)}function Ke(r,e){return be(r,0,e.value)}function be(r,e,t){if(t<me[0]){let n=Number(t);r.push([e|n])}else if(t<me[1]){let n=Number(t);r.push([e|24,n])}else if(t<me[2]){let n=Number(t);r.push([e|25,n>>>8,n&255])}else if(t<me[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<me[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(`${H} encountered BigInt larger than allowable range`)}}Ke.encodedSize=function(e){return be.encodedSize(e.value)};be.encodedSize=function(e){return e<me[0]?1:e<me[1]?2:e<me[2]?3:e<me[3]?5:9};Ke.compareTokens=function(e,t){return e.value<t.value?-1:e.value>t.value?1:0};function wl(r,e,t,n){return new L(y.negint,-1-De(r,e+1,n),2)}function xl(r,e,t,n){return new L(y.negint,-1-Oe(r,e+1,n),3)}function bl(r,e,t,n){return new L(y.negint,-1-Me(r,e+1,n),5)}var la=BigInt(-1),vl=BigInt(1);function El(r,e,t,n){let o=He(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(`${H} integers outside of the safe integer range are not supported`);return new L(y.negint,la-BigInt(o),9)}function ai(r,e){let t=e.value,n=typeof t=="bigint"?t*la-vl:t*-1-1;be(r,e.type.majorEncoded,n)}ai.encodedSize=function(e){let t=e.value,n=typeof t=="bigint"?t*la-vl:t*-1-1;return n<me[0]?1:n<me[1]?2:n<me[2]?3:n<me[3]?5:9};ai.compareTokens=function(e,t){return e.value<t.value?1:e.value>t.value?-1:0};function wn(r,e,t,n){It(r,e,t+n);let o=Lr(r,e+t,e+t+n);return new L(y.bytes,o,t+n)}function Bl(r,e,t,n){return wn(r,e,1,t)}function Al(r,e,t,n){return wn(r,e,2,De(r,e+1,n))}function Sl(r,e,t,n){return wn(r,e,3,Oe(r,e+1,n))}function Il(r,e,t,n){return wn(r,e,5,Me(r,e+1,n))}function kl(r,e,t,n){let o=He(r,e+1,n);if(typeof o=="bigint")throw new Error(`${H} 64-bit integer bytes lengths not supported`);return wn(r,e,9,o)}function ci(r){return r.encodedBytes===void 0&&(r.encodedBytes=r.type===y.string?ll(r.value):r.value),r.encodedBytes}function Vr(r,e){let t=ci(e);be(r,e.type.majorEncoded,t.length),r.push(t)}Vr.encodedSize=function(e){let t=ci(e);return be.encodedSize(t.length)+t.length};Vr.compareTokens=function(e,t){return Ap(ci(e),ci(t))};function Ap(r,e){return r.length<e.length?-1:r.length>e.length?1:dl(r,e)}function xn(r,e,t,n,o){let i=t+n;It(r,e,i);let s=new L(y.string,ul(r,e+t,e+i),i);return o.retainStringBytes===!0&&(s.byteValue=Lr(r,e+t,e+i)),s}function Cl(r,e,t,n){return xn(r,e,1,t,n)}function Tl(r,e,t,n){return xn(r,e,2,De(r,e+1,n),n)}function Nl(r,e,t,n){return xn(r,e,3,Oe(r,e+1,n),n)}function Ul(r,e,t,n){return xn(r,e,5,Me(r,e+1,n),n)}function Rl(r,e,t,n){let o=He(r,e+1,n);if(typeof o=="bigint")throw new Error(`${H} 64-bit integer string lengths not supported`);return xn(r,e,9,o,n)}var _l=Vr;function Pr(r,e,t,n){return new L(y.array,n,t)}function Ll(r,e,t,n){return Pr(r,e,1,t)}function Vl(r,e,t,n){return Pr(r,e,2,De(r,e+1,n))}function Pl(r,e,t,n){return Pr(r,e,3,Oe(r,e+1,n))}function Fl(r,e,t,n){return Pr(r,e,5,Me(r,e+1,n))}function Dl(r,e,t,n){let o=He(r,e+1,n);if(typeof o=="bigint")throw new Error(`${H} 64-bit integer array lengths not supported`);return Pr(r,e,9,o)}function Ol(r,e,t,n){if(n.allowIndefinite===!1)throw new Error(`${H} indefinite length items not allowed`);return Pr(r,e,1,1/0)}function ui(r,e){be(r,y.array.majorEncoded,e.value)}ui.compareTokens=Ke.compareTokens;ui.encodedSize=function(e){return be.encodedSize(e.value)};function Fr(r,e,t,n){return new L(y.map,n,t)}function Ml(r,e,t,n){return Fr(r,e,1,t)}function Hl(r,e,t,n){return Fr(r,e,2,De(r,e+1,n))}function $l(r,e,t,n){return Fr(r,e,3,Oe(r,e+1,n))}function Kl(r,e,t,n){return Fr(r,e,5,Me(r,e+1,n))}function ql(r,e,t,n){let o=He(r,e+1,n);if(typeof o=="bigint")throw new Error(`${H} 64-bit integer map lengths not supported`);return Fr(r,e,9,o)}function zl(r,e,t,n){if(n.allowIndefinite===!1)throw new Error(`${H} indefinite length items not allowed`);return Fr(r,e,1,1/0)}function li(r,e){be(r,y.map.majorEncoded,e.value)}li.compareTokens=Ke.compareTokens;li.encodedSize=function(e){return be.encodedSize(e.value)};function jl(r,e,t,n){return new L(y.tag,t,1)}function Gl(r,e,t,n){return new L(y.tag,De(r,e+1,n),2)}function Zl(r,e,t,n){return new L(y.tag,Oe(r,e+1,n),3)}function Wl(r,e,t,n){return new L(y.tag,Me(r,e+1,n),5)}function Jl(r,e,t,n){return new L(y.tag,He(r,e+1,n),9)}function fi(r,e){be(r,y.tag.majorEncoded,e.value)}fi.compareTokens=Ke.compareTokens;fi.encodedSize=function(e){return be.encodedSize(e.value)};var Np=20,Up=21,Rp=22,_p=23;function Yl(r,e,t,n){if(n.allowUndefined===!1)throw new Error(`${H} undefined values are not supported`);return n.coerceUndefinedToNull===!0?new L(y.null,null,1):new L(y.undefined,void 0,1)}function Xl(r,e,t,n){if(n.allowIndefinite===!1)throw new Error(`${H} indefinite length items not allowed`);return new L(y.break,void 0,1)}function fa(r,e,t){if(t){if(t.allowNaN===!1&&Number.isNaN(r))throw new Error(`${H} NaN values are not supported`);if(t.allowInfinity===!1&&(r===1/0||r===-1/0))throw new Error(`${H} Infinity values are not supported`)}return new L(y.float,r,e)}function Ql(r,e,t,n){return fa(ha(r,e+1),3,n)}function ef(r,e,t,n){return fa(da(r,e+1),5,n)}function tf(r,e,t,n){return fa(sf(r,e+1),9,n)}function hi(r,e,t){let n=e.value;if(n===!1)r.push([y.float.majorEncoded|Np]);else if(n===!0)r.push([y.float.majorEncoded|Up]);else if(n===null)r.push([y.float.majorEncoded|Rp]);else if(n===void 0)r.push([y.float.majorEncoded|_p]);else{let o,i=!1;(!t||t.float64!==!0)&&(nf(n),o=ha(tt,1),n===o||Number.isNaN(n)?(tt[0]=249,r.push(tt.slice(0,3)),i=!0):(of(n),o=da(tt,1),n===o&&(tt[0]=250,r.push(tt.slice(0,5)),i=!0))),i||(Lp(n),o=sf(tt,1),tt[0]=251,r.push(tt.slice(0,9)))}}hi.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){nf(n);let o=ha(tt,1);if(n===o||Number.isNaN(n))return 3;if(of(n),o=da(tt,1),n===o)return 5}return 9};var rf=new ArrayBuffer(9),qe=new DataView(rf,1),tt=new Uint8Array(rf,0);function nf(r){if(r===1/0)qe.setUint16(0,31744,!1);else if(r===-1/0)qe.setUint16(0,64512,!1);else if(Number.isNaN(r))qe.setUint16(0,32256,!1);else{qe.setFloat32(0,r);let e=qe.getUint32(0),t=(e&2139095040)>>23,n=e&8388607;if(t===255)qe.setUint16(0,31744,!1);else if(t===0)qe.setUint16(0,(r&2147483648)>>16|n>>13,!1);else{let o=t-127;o<-24?qe.setUint16(0,0):o<-14?qe.setUint16(0,(e&2147483648)>>16|1<<24+o,!1):qe.setUint16(0,(e&2147483648)>>16|o+15<<10|n>>13,!1)}}}function ha(r,e){if(r.length-e<2)throw new Error(`${H} 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 of(r){qe.setFloat32(0,r,!1)}function da(r,e){if(r.length-e<4)throw new Error(`${H} not enough data for float32`);let t=(r.byteOffset||0)+e;return new DataView(r.buffer,t,4).getFloat32(0,!1)}function Lp(r){qe.setFloat64(0,r,!1)}function sf(r,e){if(r.length-e<8)throw new Error(`${H} not enough data for float64`);let t=(r.byteOffset||0)+e;return new DataView(r.buffer,t,8).getFloat64(0,!1)}hi.compareTokens=Ke.compareTokens;function Z(r,e,t){throw new Error(`${H} encountered invalid minor (${t}) for major ${r[e]>>>5}`)}function di(r){return()=>{throw new Error(`${H} ${r}`)}}var k=[];for(let r=0;r<=23;r++)k[r]=Z;k[24]=pl;k[25]=ml;k[26]=gl;k[27]=yl;k[28]=Z;k[29]=Z;k[30]=Z;k[31]=Z;for(let r=32;r<=55;r++)k[r]=Z;k[56]=wl;k[57]=xl;k[58]=bl;k[59]=El;k[60]=Z;k[61]=Z;k[62]=Z;k[63]=Z;for(let r=64;r<=87;r++)k[r]=Bl;k[88]=Al;k[89]=Sl;k[90]=Il;k[91]=kl;k[92]=Z;k[93]=Z;k[94]=Z;k[95]=di("indefinite length bytes/strings are not supported");for(let r=96;r<=119;r++)k[r]=Cl;k[120]=Tl;k[121]=Nl;k[122]=Ul;k[123]=Rl;k[124]=Z;k[125]=Z;k[126]=Z;k[127]=di("indefinite length bytes/strings are not supported");for(let r=128;r<=151;r++)k[r]=Ll;k[152]=Vl;k[153]=Pl;k[154]=Fl;k[155]=Dl;k[156]=Z;k[157]=Z;k[158]=Z;k[159]=Ol;for(let r=160;r<=183;r++)k[r]=Ml;k[184]=Hl;k[185]=$l;k[186]=Kl;k[187]=ql;k[188]=Z;k[189]=Z;k[190]=Z;k[191]=zl;for(let r=192;r<=215;r++)k[r]=jl;k[216]=Gl;k[217]=Zl;k[218]=Wl;k[219]=Jl;k[220]=Z;k[221]=Z;k[222]=Z;k[223]=Z;for(let r=224;r<=243;r++)k[r]=di("simple values are not supported");k[244]=Z;k[245]=Z;k[246]=Z;k[247]=Yl;k[248]=di("simple values are not supported");k[249]=Ql;k[250]=ef;k[251]=tf;k[252]=Z;k[253]=Z;k[254]=Z;k[255]=Xl;var rt=[];for(let r=0;r<24;r++)rt[r]=new L(y.uint,r,1);for(let r=-1;r>=-24;r--)rt[31-r]=new L(y.negint,r,1);rt[64]=new L(y.bytes,new Uint8Array(0),1);rt[96]=new L(y.string,"",1);rt[128]=new L(y.array,0,1);rt[160]=new L(y.map,0,1);rt[244]=new L(y.false,!1,1);rt[245]=new L(y.true,!0,1);rt[246]=new L(y.null,null,1);function Pp(){let r=[];return r[y.uint.major]=Ke,r[y.negint.major]=ai,r[y.bytes.major]=Vr,r[y.string.major]=_l,r[y.array.major]=ui,r[y.map.major]=li,r[y.tag.major]=fi,r[y.float.major]=hi,r}var d2=Pp(),p2=new si,pi=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(`${ua} object contains circular references`);return new r(t,e)}},$t={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)},Kt={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?$t.true:$t.false},null(r,e,t,n){return $t.null},undefined(r,e,t,n){return $t.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?[$t.emptyArray,new L(y.break)]:$t.emptyArray;n=pi.createCheck(n,r);let o=[],i=0;for(let s of r)o[i++]=pa(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?[$t.emptyMap,new L(y.break)]:$t.emptyMap;n=pi.createCheck(n,r);let a=[],c=0;for(let f of i)a[c++]=[pa(f,t,n),pa(o?r.get(f):r[f],t,n)];return Fp(a,t),t.addBreakTokens?[new L(y.map,s),a,new L(y.break)]:[new L(y.map,s),a]}};Kt.Map=Kt.Object;Kt.Buffer=Kt.Uint8Array;for(let r of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))Kt[`${r}Array`]=Kt.DataView;function pa(r,e={},t){let n=ol(r),o=e&&e.typeEncoders&&e.typeEncoders[n]||Kt[n];if(typeof o=="function"){let s=o(r,n,e,t);if(s!=null)return s}let i=Kt[n];if(!i)throw new Error(`${ua} unsupported type: ${n}`);return i(r,n,e,t)}function Fp(r,e){e.mapSorter&&r.sort(e.mapSorter)}var Dp={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0},mi=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=rt[e];if(t===void 0){let n=k[e];if(!n)throw new Error(`${H} 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}},bn=Symbol.for("DONE"),gi=Symbol.for("BREAK");function Op(r,e,t){let n=[];for(let o=0;o<r.value;o++){let i=Dr(e,t);if(i===gi){if(r.value===1/0)break;throw new Error(`${H} got unexpected break to lengthed array`)}if(i===bn)throw new Error(`${H} found array but not enough entries (got ${o}, expected ${r.value})`);n[o]=i}return n}function Mp(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=Dr(e,t);if(a===gi){if(r.value===1/0)break;throw new Error(`${H} got unexpected break to lengthed map`)}if(a===bn)throw new Error(`${H} found map but not enough entries (got ${s} [no key], expected ${r.value})`);if(n!==!0&&typeof a!="string")throw new Error(`${H} non-string keys not supported (got ${typeof a})`);if(t.rejectDuplicateMapKeys===!0&&(n&&i.has(a)||!n&&a in o))throw new Error(`${H} found repeat map key "${a}"`);let c=Dr(e,t);if(c===bn)throw new Error(`${H} 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 Dr(r,e){if(r.done())return bn;let t=r.next();if(t.type===y.break)return gi;if(t.type.terminal)return t.value;if(t.type===y.array)return Op(t,r,e);if(t.type===y.map)return Mp(t,r,e);if(t.type===y.tag){if(e.tags&&typeof e.tags[t.value]=="function"){let n=Dr(r,e);return e.tags[t.value](n)}throw new Error(`${H} tag not supported (${t.value})`)}throw new Error("unsupported")}function af(r,e){if(!(r instanceof Uint8Array))throw new Error(`${H} data to decode must be a Uint8Array`);e=Object.assign({},Dp,e);let t=e.tokenizer||new mi(r,e),n=Dr(t,e);if(n===bn)throw new Error(`${H} did not find any content to decode`);if(n===gi)throw new Error(`${H} got unexpected break`);return[n,r.subarray(t.pos())]}function ma(r,e){let[t,n]=af(r,e);if(n.length>0)throw new Error(`${H} too many terminals, data makes no sense`);return t}var Kp=Ct("ipns:utils"),cf=J("/ipns/");var qp=0,zp=18;function uf(r){let e;if(r.pubKey!=null)try{e=Mu(r.pubKey)}catch(t){throw Kp.error(t),t}if(e!=null)return e}function lf(r){let e=J("ipns-signature:");return Fe([e,r])}function vn(r){return"signatureV1"in r?et.encode({value:J(r.value),signatureV1:r.signatureV1,validityType:r.validityType,validity:J(r.validity),sequence:r.sequence,ttl:r.ttl,pubKey:r.pubKey,signatureV2:r.signatureV2,data:r.data}):et.encode({pubKey:r.pubKey,signatureV2:r.signatureV2,data:r.data})}function qt(r){let e=et.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 Qe("Missing data or signatureV2");let t=ff(e.data),n=jp(t.Value),o=oe(t.Validity);if(e.value!=null&&e.signatureV1!=null)return Gp(e),{value:n,validityType:et.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:et.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 En(r){return Fe([cf,r.bytes])}function Or(r){let e=ht(r.slice(cf.length));if(!yi(e,qp)&&!yi(e,zp))throw new ir("Multihash in IPNS key was not identity or sha2-256");return e}function ff(r){let e=ma(r);if(e.ValidityType===0)e.ValidityType=et.ValidityType.EOL;else throw new Rr("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 jp(r){let e=oe(r).trim();if(e.startsWith("/"))return e;try{return`/ipfs/${ie.decode(r).toV1().toString()}`}catch{}try{return`/ipfs/${ie.parse(e).toV1().toString()}`}catch{}throw new ni("Value must be a valid content path starting with /")}function Gp(r){if(r.data==null)throw new oi("Record data is missing");let e=ff(r.data);if(!ue(e.Value,r.value??new Uint8Array(0)))throw new Qe('Field "value" did not match between protobuf and CBOR');if(!ue(e.Validity,r.validity??new Uint8Array(0)))throw new Qe('Field "validity" did not match between protobuf and CBOR');if(e.ValidityType!==r.validityType)throw new Qe('Field "validityType" did not match between protobuf and CBOR');if(e.Sequence!==r.sequence)throw new Qe('Field "sequence" did not match between protobuf and CBOR');if(e.TTL!==r.ttl)throw new Qe('Field "ttl" did not match between protobuf and CBOR')}function yi(r,e){return r.code===e}var D2=Ct("ipns"),O2=60*60*1e9,Wp="/ipns/",M2=Wp.length;var hf=Tn(ca(),1);var wi=Ct("ipns:validator"),Jp=1024*10,Yp=async(r,e)=>{let t=qt(e),n;try{let o=lf(t.data);n=await r.verify(o,t.signatureV2)}catch{n=!1}if(!n)throw wi.error("record signature verification failed"),new Qe("Record signature verification failed");if(t.validityType===et.ValidityType.EOL){if(hf.default.fromString(t.validity).toDate().getTime()<Date.now())throw wi.error("record has expired"),new ti("record has expired")}else if(t.validityType!=null)throw wi.error("the validity type is unsupported"),new Rr("The validity type is unsupported");wi("ipns record for %s is valid",t.value)};async function df(r,e){if(e.byteLength>Jp)throw new ri("The record is too large");let t=Or(r),n;yi(t,0)&&(n=zo(t));let o=qt(e),i=uf(o)??n;if(i==null)throw new gn("Could not extract public key from IPNS record or routing key");let s=En(i.toMultihash());if(!ue(r,s))throw new gn("Embedded public key did not match routing key");await Yp(i,e)}async function*Bn(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 ut(){let r={};return r.promise=new Promise((e,t)=>{r.resolve=e,r.reject=t}),r}var ya=Tn(mf(),1);var Sn=class extends Error{constructor(e){super(e),this.name="TimeoutError"}},wa=class extends Error{constructor(e){super(),this.name="AbortError",this.message=e}},gf=r=>globalThis.DOMException===void 0?new wa(r):new DOMException(r),yf=r=>{let e=r.reason===void 0?gf("This operation was aborted."):r.reason;return e instanceof Error?e:gf(e)};function xa(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(yf(h));let b=()=>{u(yf(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 Sn;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 ba(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 In=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=ba(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 kn=class extends ya.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:In,...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=xa(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 Sn&&!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 Mr=class extends Error{static name="InvalidRequestError";constructor(e="Invalid request"){super(e),this.name="InvalidRequestError"}},nr=class extends Error{static name="BadResponseError";constructor(e="Bad response"){super(e),this.name="BadResponseError"}};function em(r){return r[Symbol.asyncIterator]!=null}function tm(r){if(em(r))return(async()=>{for await(let e of r)return e})();for(let e of r)return e}var wf=tm;function rm(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 xf=rm;function nm(r){return r[Symbol.asyncIterator]!=null}function om(r,e){let t=0;if(nm(r))return async function*(){for await(let c of r)yield e(c,t++)}();let n=xf(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 bf=om;var vf=J("/ipns/");function Ef(r){return ue(r.subarray(0,vf.byteLength),vf)}var bi=class{client;constructor(e){this.client=e}async*findProviders(e,t={}){yield*bf(this.client.getProviders(e,t),n=>({id:n.ID,multiaddrs:n.Addrs??[]}))}async provide(){}async cancelReprovide(){}async put(e,t,n){if(!Ef(e))return;let o=Or(e),i=ie.createV1(114,o),s=qt(t);await this.client.putIPNS(i,s,n)}async get(e,t){if(!Ef(e))throw new nt("Not found");let n=Or(e),o=ie.createV1(114,n);try{let i=await this.client.getIPNS(o,t);return vn(i)}catch(i){throw i.name==="BadResponseError"?new nt("Not found"):i}}},vi=class{client;constructor(e){this.client=e}async findPeer(e,t={}){let n=await wf(this.client.getPeers(e,t));if(n!=null)return{id:n.ID,multiaddrs:n.Addrs??[]};throw new nt("Not found")}async*getClosestPeers(e,t={}){}};var ge=Ct("delegated-routing-v1-http-api-client"),va={concurrentRequests:4,timeout:3e4,cacheTTL:5*60*1e3},Ei=class{started;httpQueue;shutDownController;clientUrl;timeout;contentRouting;peerRouting;filterAddrs;filterProtocols;inFlightRequests;cache;cacheTTL;constructor(e,t={}){this.started=!1,this.shutDownController=new AbortController,ar(1/0,this.shutDownController.signal),this.httpQueue=new kn({concurrency:t.concurrentRequests??va.concurrentRequests}),this.inFlightRequests=new Map,this.clientUrl=e instanceof URL?e:new URL(e),this.timeout=t.timeout??va.timeout,this.filterAddrs=t.filterAddrs,this.filterProtocols=t.filterProtocols,this.contentRouting=new bi(this),this.peerRouting=new vi(this),this.cacheTTL=t.cacheTTL??va.cacheTTL,typeof globalThis.caches<"u"&&this.cacheTTL>0&&(ge("cache enabled with ttl %d",this.cacheTTL),globalThis.caches.open("delegated-routing-v1-cache").then(o=>{this.cache=o}).catch(()=>{this.cache=void 0}))}get[Na](){return this.contentRouting}get[Ua](){return this.peerRouting}isStarted(){return this.started}start(){this.started=!0}stop(){this.httpQueue.clear(),this.shutDownController.abort(),this.started=!1,this.cache!=null&&this.cache.delete("delegated-routing-v1-cache")}async*getProviders(e,t={}){ge("getProviders starts: %c",e);let n=AbortSignal.timeout(this.timeout),o=mn([this.shutDownController.signal,n,t.signal]);ar(1/0,n,o);let i=ut(),s=ut();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 nt("No matching records found");if(f.status===422)throw new Mr("Request does not conform to schema or semantic constraints");if(f.body==null)throw new nr("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 Bn(ei(f.body))){let h=this.#e(l);h!=null&&(yield h)}}catch(a){ge.error("getProviders errored:",a)}finally{o.clear(),s.resolve(),ge("getProviders finished: %c",e)}}async*getPeers(e,t={}){ge("getPeers starts: %c",e);let n=AbortSignal.timeout(this.timeout),o=mn([this.shutDownController.signal,n,t.signal]);ar(1/0,n,o);let i=ut(),s=ut();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 nt("No matching records found");if(f.status===422)throw new Mr("Request does not conform to schema or semantic constraints");if(f.body==null)throw new nr("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 Bn(ei(f.body))){let h=this.#e(l);h!=null&&(yield h)}}catch(a){ge.error("getPeers errored:",a)}finally{o.clear(),s.resolve(),ge("getPeers finished: %c",e)}}async getIPNS(e,t={}){ge("getIPNS starts: %s",e);let n=AbortSignal.timeout(this.timeout),o=mn([this.shutDownController.signal,n,t.signal]);ar(1/0,n,o);let i=ut(),s=ut();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(ge("getIPNS GET %s %d",a,f.status),f.status===404)throw new nt("No matching records found");if(f.status===422)throw new Mr("Request does not conform to schema or semantic constraints");if(f.body==null)throw new nr("GET ipns response had no body");let u=await f.arrayBuffer(),l=new Uint8Array(u,0,u.byteLength);return t.validate!==!1&&await df(En(e.multihash),l),qt(l)}catch(c){throw ge.error("getIPNS GET %s error:",a,c),c}finally{o.clear(),s.resolve(),ge("getIPNS finished: %s",e)}}async putIPNS(e,t,n={}){ge("putIPNS starts: %c",e);let o=AbortSignal.timeout(this.timeout),i=mn([this.shutDownController.signal,o,n.signal]);ar(1/0,o,i);let s=ut(),a=ut();this.httpQueue.add(async()=>(s.resolve(),a.promise));let c=`${this.clientUrl}routing/v1/ipns/${e}`;try{await s.promise;let f=vn(t),u={method:"PUT",headers:{"Content-Type":"application/vnd.ipfs.ipns-record"},body:f,signal:i},l=await this.#t(c,u);if(ge("putIPNS PUT %s %d",c,l.status),l.status!==200)throw new nr("PUT ipns response had status other than 200")}catch(f){throw ge.error("putIPNS PUT %s error:",c,f.stack),f}finally{i.clear(),a.resolve(),ge("putIPNS finished: %c",e)}}#e(e){try{let t=[],n=e.Addrs?.map(pn)??[];return e.Protocols!=null&&t.push(...e.Protocols),e.Protocol!=null&&(t.push(e.Protocol),delete e.Protocol),{...e,Schema:"peer",ID:$u(e.ID),Addrs:n,Protocols:t}}catch(t){ge.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 ge("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 ge("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 im(r,e={}){return new Ei(new URL(r),e)}return Pf(sm);})();
|
|
7
|
+
`)}`:`${t} :`}};Hc=Mt;_.Constructed=Hc;Mt.NAME="CONSTRUCTED";var so=class extends Ae{fromBER(e,t,n){return t}toBER(e){return Xe}};so.override="EndOfContentValueBlock";var $c,ao=class extends we{constructor(e={}){super(e,so),this.idBlock.tagClass=1,this.idBlock.tagNumber=0}};$c=ao;_.EndOfContent=$c;ao.NAME=nn;var Kc,Sr=class extends we{constructor(e={}){super(e,Ae),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}`}};Kc=Sr;_.Null=Kc;Sr.NAME="NULL";var co=class extends Bt(Ae){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 Et(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,Vs.call(this),this.blockLength=n,t+n):-1}toBER(){return this.valueHexView.slice()}toJSON(){return{...super.toJSON(),value:this.value}}};co.NAME="BooleanValueBlock";var qc,uo=class extends we{constructor(e={}){super(e,co),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}`}};qc=uo;_.Boolean=qc;uo.NAME="BOOLEAN";var lo=class extends Bt(st){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=st.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===nn){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, OCTET STRING may consists of OCTET STRINGs only",-1}if(s!==Fc)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?st.prototype.toBER.call(this,e,t):e?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),isConstructed:this.isConstructed}}};lo.NAME="OctetStringValueBlock";var zc,fo=class r extends we{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},lo),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=Mo(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?Mt.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)}};zc=fo;_.OctetString=zc;fo.NAME=Fc;var ho=class extends Bt(st){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=st.prototype.fromBER.call(this,e,t,n),o===-1)return o;for(let a of this.value){let c=a.constructor.NAME;if(c===nn){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, BIT STRING may consists of BIT STRINGs only",-1}if(c!==Dc)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(!Et(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=Mo(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 st.prototype.toBER.call(this,e,t);if(e)return new ArrayBuffer(this.valueHexView.byteLength+1);if(!this.valueHexView.byteLength)return Xe;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}}};ho.NAME="BitStringValueBlock";var jc,Ir=class extends we{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},ho),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 Mt.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)}`}}};jc=Ir;_.BitString=jc;Ir.NAME=Dc;var Gc;function T0(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=Qn(new Uint8Array([f%10]),i);break;default:i[s-l]=f%10}}return t[0]>0&&(i=Qn(t,i)),i}function Pc(r){if(r>=tn.length)for(let e=tn.length;e<=r;e++){let t=new Uint8Array([0]),n=tn[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=Qn(t,n)),tn.push(n)}return tn[r]}function N0(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 on=class extends Bt(Ae){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=Vs.call(this)))}set valueDec(e){this._valueDec=e,this.isHexOnly=!1,this.valueHexView=new Uint8Array(_c(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=N0(Pc(n),t),s="-";break;default:t=T0(t,Pc(n))}n++,o>>=1}}for(let c=0;c<t.length;c++)t[c]&&(a=!0),a&&(s+=Vc.charAt(t[c]));return a===!1&&(s+=Vc.charAt(0)),s}};Gc=on;on.NAME="IntegerValueBlock";Object.defineProperty(Gc.prototype,"valueHex",{set:function(r){this.valueHexView=new Uint8Array(r),this.setValueHex()},get:function(){return this.valueHexView.slice().buffer}});var Zc,xe=class r extends we{constructor(e={}){super(e,on),this.idBlock.tagClass=1,this.idBlock.tagNumber=2}toBigInt(){return eo(),BigInt(this.valueBlock.toString())}static fromBigInt(e){eo();let t=BigInt(e),n=new rn,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()}`}};Zc=xe;_.Integer=Zc;xe.NAME="INTEGER";var Wc,po=class extends xe{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=10}};Wc=po;_.Enumerated=Wc;po.NAME="ENUMERATED";var sn=class extends Bt(Ae){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(!Et(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=er(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),t+this.blockLength)}set valueBigInt(e){eo();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=Ot(this.valueDec,7);if(t.byteLength===0)return this.error="Error during encoding SID value",Xe;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}}};sn.NAME="sidBlock";var mo=class extends Ae{constructor({value:e=Cr,...t}={}){super(t),this.value=[],e&&this.fromString(e)}fromBER(e,t,n){let o=t;for(;n>0;){let i=new sn;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,Xe;t.push(o)}return Ps(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 sn;if(o>Number.MAX_SAFE_INTEGER){eo();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}};mo.NAME="ObjectIdentifierValueBlock";var Jc,kr=class extends we{constructor(e={}){super(e,mo),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()}}};Jc=kr;_.ObjectIdentifier=Jc;kr.NAME="OBJECT IDENTIFIER";var an=class extends Bt(xt){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(!Et(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=er(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=Ot(this.valueDec,7);if(t.byteLength===0)return this.error="Error during encoding SID value",Xe;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}}};an.NAME="relativeSidBlock";var go=class extends Ae{constructor({value:e=Cr,...t}={}){super(t),this.value=[],e&&this.fromString(e)}fromBER(e,t,n){let o=t;for(;n>0;){let i=new an;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,Xe;n.push(i)}return Ps(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 an;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}};go.NAME="RelativeObjectIdentifierValueBlock";var Yc,yo=class extends we{constructor(e={}){super(e,go),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()}}};Yc=yo;_.RelativeObjectIdentifier=Yc;yo.NAME="RelativeObjectIdentifier";var Xc,bt=class extends Mt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=16}};Xc=bt;_.Sequence=Xc;bt.NAME="SEQUENCE";var Qc,wo=class extends Mt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=17}};Qc=wo;_.Set=Qc;wo.NAME="SET";var xo=class extends Bt(Ae){constructor({...e}={}){super(e),this.isHexOnly=!0,this.value=Cr}toJSON(){return{...super.toJSON(),value:this.value}}};xo.NAME="StringValueBlock";var bo=class extends xo{};bo.NAME="SimpleStringValueBlock";var Ce=class extends no{constructor({...e}={}){super(e,bo)}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 vo=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}};vo.NAME="Utf8StringValueBlock";var eu,vt=class extends vo{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=12}};eu=vt;_.Utf8String=eu;vt.NAME="UTF8String";var Eo=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))}};Eo.NAME="BmpStringValueBlock";var tu,Bo=class extends Eo{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=30}};tu=Bo;_.BmpString=tu;Bo.NAME="BMPString";var Ao=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=Ot(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}};Ao.NAME="UniversalStringValueBlock";var ru,So=class extends Ao{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=28}};ru=So;_.UniversalString=ru;So.NAME="UniversalString";var nu,Io=class extends Ce{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=18}};nu=Io;_.NumericString=nu;Io.NAME="NumericString";var ou,ko=class extends Ce{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=19}};ou=ko;_.PrintableString=ou;ko.NAME="PrintableString";var iu,Co=class extends Ce{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=20}};iu=Co;_.TeletexString=iu;Co.NAME="TeletexString";var su,To=class extends Ce{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=21}};su=To;_.VideotexString=su;To.NAME="VideotexString";var au,No=class extends Ce{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=22}};au=No;_.IA5String=au;No.NAME="IA5String";var cu,Uo=class extends Ce{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=25}};cu=Uo;_.GraphicString=cu;Uo.NAME="GraphicString";var uu,cn=class extends Ce{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=26}};uu=cn;_.VisibleString=uu;cn.NAME="VisibleString";var lu,Ro=class extends Ce{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=27}};lu=Ro;_.GeneralString=lu;Ro.NAME="GeneralString";var fu,_o=class extends Ce{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=29}};fu=_o;_.CharacterString=fu;_o.NAME="CharacterString";var hu,un=class extends cn{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]=Ve(this.year<2e3?this.year-1900:this.year-2e3,2),t[1]=Ve(this.month,2),t[2]=Ve(this.day,2),t[3]=Ve(this.hour,2),t[4]=Ve(this.minute,2),t[5]=Ve(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}}};hu=un;_.UTCTime=hu;un.NAME="UTCTime";var du,Lo=class extends un{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(Ve(this.year,4)),t.push(Ve(this.month,2)),t.push(Ve(this.day,2)),t.push(Ve(this.hour,2)),t.push(Ve(this.minute,2)),t.push(Ve(this.second,2)),this.millisecond!==0&&(t.push("."),t.push(Ve(this.millisecond,3))),t.push("Z"),t.join("")}return super.toString(e)}toJSON(){return{...super.toJSON(),millisecond:this.millisecond}}};du=Lo;_.GeneralizedTime=du;Lo.NAME="GeneralizedTime";var pu,Vo=class extends vt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=31}};pu=Vo;_.DATE=pu;Vo.NAME="DATE";var mu,Po=class extends vt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=32}};mu=Po;_.TimeOfDay=mu;Po.NAME="TimeOfDay";var gu,Fo=class extends vt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=33}};gu=Fo;_.DateTime=gu;Fo.NAME="DateTime";var yu,Do=class extends vt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=34}};yu=Do;_.Duration=yu;Do.NAME="Duration";var wu,Oo=class extends vt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=14}};wu=Oo;_.TIME=wu;Oo.NAME="TIME";function oe(r,e="utf8"){let t=Zn[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return t.encoder.encode(r).substring(1)}var ln=class extends Error{constructor(e="An error occurred while verifying a message"){super(e),this.name="VerificationError"}},Ho=class extends Error{constructor(e="Missing Web Crypto API"){super(e),this.name="WebCryptoMissingError"}};var xu={get(r=globalThis){let e=r.crypto;if(e?.subtle==null)throw new Ho("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 Ht=xu;async function bu(r){let e=await Ht.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 R0(e);return{privateKey:t[0],publicKey:t[1]}}async function vu(r,e){let t=await Ht.get().subtle.importKey("jwk",r,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["sign"]),n=await Ht.get().subtle.sign({name:"RSASSA-PKCS1-v1_5"},t,e instanceof Uint8Array?e:e.subarray());return new Uint8Array(n,0,n.byteLength)}async function Eu(r,e,t){let n=await Ht.get().subtle.importKey("jwk",r,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["verify"]);return Ht.get().subtle.verify({name:"RSASSA-PKCS1-v1_5"},n,e,t instanceof Uint8Array?t:t.subarray())}async function R0(r){if(r.privateKey==null||r.publicKey==null)throw new ve("Private and public key are required");return Promise.all([Ht.get().subtle.exportKey("jwk",r.privateKey),Ht.get().subtle.exportKey("jwk",r.publicKey)])}function Os(r){if(r.kty!=="RSA")throw new ve("invalid key type");if(r.n==null)throw new ve("invalid key modulus");return J(r.n,"base64url").length*8}var Tr=class{type="RSA";_key;_raw;_multihash;constructor(e,t){this._key=e,this._multihash=t}get raw(){return this._raw==null&&(this._raw=fn.jwkToPkix(this._key)),this._raw}toMultihash(){return this._multihash}toCID(){return ie.createV1(114,this._multihash)}toString(){return te.encode(this.toMultihash().bytes).substring(1)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:ue(this.raw,e.raw)}verify(e,t){return Eu(this._key,t,e)}},hn=class{type="RSA";_key;_raw;publicKey;constructor(e,t){this._key=e,this.publicKey=t}get raw(){return this._raw==null&&(this._raw=fn.jwkToPkcs1(this._key)),this._raw}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:ue(this.raw,e.raw)}sign(e){return vu(this._key,e)}};var $o=8192,Ms=18;function Bu(r){let{result:e}=Ds(r),t=e.valueBlock.value;return{n:at(t[1]),e:at(t[2]),d:at(t[3]),p:at(t[4]),q:at(t[5]),dp:at(t[6]),dq:at(t[7]),qi:at(t[8]),kty:"RSA",alg:"RS256"}}function _0(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 ve("JWK was missing components");let t=new bt({value:[new xe({value:0}),xe.fromBigInt(ct(J(r.n,"base64url"))),xe.fromBigInt(ct(J(r.e,"base64url"))),xe.fromBigInt(ct(J(r.d,"base64url"))),xe.fromBigInt(ct(J(r.p,"base64url"))),xe.fromBigInt(ct(J(r.q,"base64url"))),xe.fromBigInt(ct(J(r.dp,"base64url"))),xe.fromBigInt(ct(J(r.dq,"base64url"))),xe.fromBigInt(ct(J(r.qi,"base64url")))]}).toBER();return new Uint8Array(t,0,t.byteLength)}function Au(r){let{result:e}=Ds(r),t=e.valueBlock.value[1].valueBlock.value[0].valueBlock.value;return{kty:"RSA",n:at(t[0]),e:at(t[1])}}function Hs(r){if(r.n==null||r.e==null)throw new ve("JWK was missing components");let t=new bt({value:[new bt({value:[new kr({value:"1.2.840.113549.1.1.1"}),new Sr]}),new Ir({valueHex:new bt({value:[xe.fromBigInt(ct(J(r.n,"base64url"))),xe.fromBigInt(ct(J(r.e,"base64url")))]}).toBER()})]}).toBER();return new Uint8Array(t,0,t.byteLength)}function at(r){let e=r.valueBlock.valueHexView;for(;e[0]===0;)e=e.subarray(1);return oe(e,"base64url")}function ct(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 Su(r){let e=Bu(r);return Iu(e)}function $s(r){let e=Au(r);if(Os(e)>$o)throw new or("Key size is too large");let t=Br(it.encode({Type:fe.RSA,Data:r})),n=je(Ms,t);return new Tr(e,n)}function Iu(r){if(Os(r)>$o)throw new ve("Key size is too large");let e=Cu(r),t=Br(it.encode({Type:fe.RSA,Data:Hs(e.publicKey)})),n=je(Ms,t);return new hn(e.privateKey,new Tr(e.publicKey,n))}async function ku(r){if(r>$o)throw new ve("Key size is too large");let e=await bu(r),t=Br(it.encode({Type:fe.RSA,Data:Hs(e.publicKey)})),n=je(Ms,t);return new hn(e.privateKey,new Tr(e.publicKey,n))}function Cu(r){if(r==null)throw new ve("Missing key parameter");return{privateKey:r,publicKey:{kty:r.kty,n:r.n,e:r.e}}}var Ko=class extends mr{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,Ja(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 pr(this),this.iHash.update(e),this}digestInto(e){pr(this),dr(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()}},Ks=(r,e,t)=>new Ko(r,e).update(t).digest();Ks.create=(r,e)=>new Ko(r,e);function Tu(r){r.lowS!==void 0&&Ze("lowS",r.lowS),r.prehash!==void 0&&Ze("prehash",r.prehash)}function L0(r){let e=Wr(r);ot(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:V0,hexToBytes:P0}=On,At={Err:class extends Error{constructor(e=""){super(e)}},_tlv:{encode:(r,e)=>{let{Err:t}=At;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=jt(n);if(o.length/2&128)throw new t("tlv.encode: long form length too big");let i=n>127?jt(o.length/2|128):"";return`${jt(r)}${i}${o}${e}`},decode(r,e){let{Err:t}=At,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}=At;if(r<St)throw new e("integer: negative integers are not allowed");let t=jt(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}=At;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 V0(r)}},toSig(r){let{Err:e,_int:t,_tlv:n}=At,o=typeof r=="string"?P0(r):r;yr(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}=At,n=`${e.encode(2,t.encode(r.r))}${e.encode(2,t.encode(r.s))}`;return e.encode(48,n)}},St=BigInt(0),pe=BigInt(1),Cw=BigInt(2),Nu=BigInt(3),Tw=BigInt(4);function F0(r){let e=L0(r),{Fp:t}=e,n=Vt(e.n,e.nBitLength),o=e.toBytes||((w,d,E)=>{let C=d.toAffine();return yt(Uint8Array.from([4]),t.toBytes(C.x),t.toBytes(C.y))}),i=e.fromBytes||(w=>{let d=w.subarray(1),E=t.fromBytes(d.subarray(0,t.BYTES)),C=t.fromBytes(d.subarray(t.BYTES,2*t.BYTES));return{x:E,y:C}});function s(w){let{a:d,b:E}=e,C=t.sqr(w),x=t.mul(C,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 Gr(w,pe,e.n)}function c(w){let{allowedPrivateKeyLengths:d,nByteLength:E,wrapPrivateKey:C,n:x}=e;if(d&&typeof w!="bigint"){if(Rt(w)&&(w=mt(w)),typeof w!="string"||!d.includes(w.length))throw new Error("Invalid key");w=w.padStart(E*2,"0")}let T;try{T=typeof w=="bigint"?w:gt(ae("private key",w,E))}catch{throw new Error(`private key must be ${E} bytes, hex or bigint, not ${typeof w}`)}return C&&(T=X(T,x)),Re("private key",T,pe,x),T}function f(w){if(!(w instanceof h))throw new Error("ProjectivePoint expected")}let u=Wt((w,d)=>{let{px:E,py:C,pz:x}=w;if(t.eql(x,t.ONE))return{x:E,y:C};let T=w.is0();d==null&&(d=T?t.ONE:t.inv(x));let F=t.mul(E,d),V=t.mul(C,d),U=t.mul(x,d);if(T)return{x:t.ZERO,y:t.ZERO};if(!t.eql(U,t.ONE))throw new Error("invZ was invalid");return{x:F,y:V}}),l=Wt(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 C=t.sqr(E),x=s(d);if(!t.eql(C,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,C){if(this.px=d,this.py=E,this.pz=C,d==null||!t.isValid(d))throw new Error("x required");if(E==null||!t.isValid(E))throw new Error("y required");if(C==null||!t.isValid(C))throw new Error("z required");Object.freeze(this)}static fromAffine(d){let{x:E,y:C}=d||{};if(!d||!t.isValid(E)||!t.isValid(C))throw new Error("invalid affine point");if(d instanceof h)throw new Error("projective point not allowed");let x=T=>t.eql(T,t.ZERO);return x(E)&&x(C)?h.ZERO:new h(E,C,t.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(d){let E=t.invertBatch(d.map(C=>C.pz));return d.map((C,x)=>C.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 $n(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:C,pz:x}=this,{px:T,py:F,pz:V}=d,U=t.eql(t.mul(E,V),t.mul(T,x)),g=t.eql(t.mul(C,V),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,C=t.mul(E,Nu),{px:x,py:T,pz:F}=this,V=t.ZERO,U=t.ZERO,g=t.ZERO,v=t.mul(x,x),D=t.mul(T,T),R=t.mul(F,F),N=t.mul(x,T);return N=t.add(N,N),g=t.mul(x,F),g=t.add(g,g),V=t.mul(d,g),U=t.mul(C,R),U=t.add(V,U),V=t.sub(D,U),U=t.add(D,U),U=t.mul(V,U),V=t.mul(N,V),g=t.mul(C,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(T,F),R=t.add(R,R),v=t.mul(R,N),V=t.sub(V,v),g=t.mul(R,D),g=t.add(g,g),g=t.add(g,g),new h(V,U,g)}add(d){f(d);let{px:E,py:C,pz:x}=this,{px:T,py:F,pz:V}=d,U=t.ZERO,g=t.ZERO,v=t.ZERO,D=e.a,R=t.mul(e.b,Nu),N=t.mul(E,T),$=t.mul(C,F),A=t.mul(x,V),S=t.add(E,C),m=t.add(T,F);S=t.mul(S,m),m=t.add(N,$),S=t.sub(S,m),m=t.add(E,x);let p=t.add(T,V);return m=t.mul(m,p),p=t.add(N,A),m=t.sub(m,p),p=t.add(C,x),U=t.add(F,V),p=t.mul(p,U),U=t.add($,A),p=t.sub(p,U),v=t.mul(D,m),U=t.mul(R,A),v=t.add(U,v),U=t.sub($,v),v=t.add($,v),g=t.mul(U,v),$=t.add(N,N),$=t.add($,N),A=t.mul(D,A),m=t.mul(R,m),$=t.add($,A),A=t.sub(N,A),A=t.mul(D,A),m=t.add(m,A),N=t.mul($,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,$),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){Re("scalar",d,St,e.n);let E=h.ZERO;if(d===St)return E;if(d===pe)return this;let{endo:C}=e;if(!C)return I.unsafeLadder(this,d);let{k1neg:x,k1:T,k2neg:F,k2:V}=C.splitScalar(d),U=E,g=E,v=this;for(;T>St||V>St;)T&pe&&(U=U.add(v)),V&pe&&(g=g.add(v)),v=v.double(),T>>=pe,V>>=pe;return x&&(U=U.negate()),F&&(g=g.negate()),g=new h(t.mul(g.px,C.beta),g.py,g.pz),U.add(g)}multiply(d){let{endo:E,n:C}=e;Re("scalar",d,pe,C);let x,T;if(E){let{k1neg:F,k1:V,k2neg:U,k2:g}=E.splitScalar(d),{p:v,f:D}=this.wNAF(V),{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),T=D.add(N)}else{let{p:F,f:V}=this.wNAF(d);x=F,T=V}return h.normalizeZ([x,T])[0]}multiplyAndAddUnsafe(d,E,C){let x=h.BASE,T=(V,U)=>U===St||U===pe||!V.equals(x)?V.multiplyUnsafe(U):V.multiply(U),F=T(this,E).add(T(d,C));return F.is0()?void 0:F}toAffine(d){return u(this,d)}isTorsionFree(){let{h:d,isTorsionFree:E}=e;if(d===pe)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===pe?this:E?E(h,this):this.multiplyUnsafe(e.h)}toRawBytes(d=!0){return Ze("isCompressed",d),this.assertValidity(),o(h,this,d)}toHex(d=!0){return Ze("isCompressed",d),mt(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=Hn(h,e.endo?Math.ceil(b/2):b);return{CURVE:e,ProjectivePoint:h,normPrivateKeyToScalar:c,weierstrassEquation:s,isWithinCurveOrder:a}}function D0(r){let e=Wr(r);return ot(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function Uu(r){let e=D0(r),{Fp:t,n}=e,o=t.BYTES+1,i=2*t.BYTES+1;function s(A){return X(A,n)}function a(A){return Mn(A,n)}let{ProjectivePoint:c,normPrivateKeyToScalar:f,weierstrassEquation:u,isWithinCurveOrder:l}=F0({...e,toBytes(A,S,m){let p=S.toAffine(),B=t.toBytes(p.x),P=yt;return Ze("isCompressed",m),m?P(Uint8Array.from([S.hasEvenY()?2:3]),B):P(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=gt(p);if(!Gr(B,pe,t.ORDER))throw new Error("Point is not on curve");let P=u(B),O;try{O=t.sqrt(P)}catch(G){let z=G instanceof Error?": "+G.message:"";throw new Error("Point is not on curve"+z)}let M=(O&pe)===pe;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)),P=t.fromBytes(p.subarray(t.BYTES,2*t.BYTES));return{x:B,y:P}}else throw new Error(`Point of length ${S} was invalid. Expected ${o} compressed bytes or ${i} uncompressed bytes`)}}),h=A=>mt(Lt(A,e.nByteLength));function b(A){let S=n>>pe;return A>S}function I(A){return b(A)?s(-A):A}let w=(A,S,m)=>gt(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}=At.toSig(ae("DER",S));return new d(m,p)}assertValidity(){Re("r",this.r,pe,n),Re("s",this.s,pe,n)}addRecoveryBit(S){return new d(this.r,this.s,S)}recoverPublicKey(S){let{r:m,s:p,recovery:B}=this,P=V(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(-P*G),Y=s(p*G),ee=c.BASE.multiplyAndAddUnsafe(q,z,Y);if(!ee)throw new Error("point at infinify");return ee.assertValidity(),ee}hasHighS(){return b(this.s)}normalizeS(){return this.hasHighS()?new d(this.r,s(-this.s),this.recovery):this}toDERRawBytes(){return Gt(this.toDERHex())}toDERHex(){return At.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Gt(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=Xi(e.n);return uc(e.randomBytes(A),e.n)},precompute(A=8,S=c.BASE){return S._setWindowSize(A),S.multiply(BigInt(3)),S}};function C(A,S=!0){return c.fromPrivateKey(A).toRawBytes(S)}function x(A){let S=Rt(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 T(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=gt(A),m=A.length*8-e.nBitLength;return m>0?S>>BigInt(m):S},V=e.bits2int_modN||function(A){return s(F(A))},U=Zr(e.nBitLength);function g(A){return Re(`num < 2^${e.nBitLength}`,A,St,U),Lt(A,e.nByteLength)}function v(A,S,m=D){if(["recovered","canonical"].some(de=>de in m))throw new Error("sign() legacy options not supported");let{hash:p,randomBytes:B}=e,{lowS:P,prehash:O,extraEntropy:M}=m;P==null&&(P=!0),A=ae("msgHash",A),Tu(m),O&&(A=ae("prehashed msgHash",p(A)));let q=V(A),G=f(S),z=[g(G),g(q)];if(M!=null&&M!==!1){let de=M===!0?B(t.BYTES):M;z.push(ae("extraEntropy",de))}let Y=yt(...z),ee=q;function he(de){let ye=F(de);if(!l(ye))return;let Ie=a(ye),ce=c.BASE.multiply(ye).toAffine(),Ne=s(ce.x);if(Ne===St)return;let lt=s(Ie*s(ee+Ne*G));if(lt===St)return;let Hr=(ce.x===Ne?0:2)|Number(ce.y&pe),$r=lt;return P&&b(lt)&&($r=I(lt),Hr^=1),new d(Ne,$r,Hr)}return{seed:Y,k2sig:he}}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),P=e;return Zi(P.hash.outputLen,P.nByteLength,P.hmac)(p,B)}c.BASE._setWindowSize(8);function $(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");Tu(p);let{lowS:P,prehash:O}=p,M,q;try{if(typeof B=="string"||Rt(B))try{M=d.fromDER(B)}catch(ce){if(!(ce instanceof At.Err))throw ce;M=d.fromCompact(B)}else if(typeof B=="object"&&typeof B.r=="bigint"&&typeof B.s=="bigint"){let{r:ce,s:Ne}=B;M=new d(ce,Ne)}else throw new Error("PARSE");q=c.fromHex(m)}catch(ce){if(ce.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(P&&M.hasHighS())return!1;O&&(S=e.hash(S));let{r:G,s:z}=M,Y=V(S),ee=a(z),he=s(Y*ee),de=s(G*ee),ye=c.BASE.multiplyAndAddUnsafe(q,he,de)?.toAffine();return ye?s(ye.x)===G:!1}return{CURVE:e,getPublicKey:C,getSharedSecret:T,sign:N,verify:$,ProjectivePoint:c,Signature:d,utils:E}}function O0(r){return{hash:r,hmac:(e,...t)=>Ks(r,e,Mi(...t)),randomBytes:Pn}}function Ru(r,e){let t=n=>Uu({...r,...O0(n)});return Object.freeze({...t(e),create:t})}var Vu=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),_u=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),M0=BigInt(1),qs=BigInt(2),Lu=(r,e)=>(r+e/qs)/e;function H0(r){let e=Vu,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=ne(u,t,e)*u%e,h=ne(l,t,e)*u%e,b=ne(h,qs,e)*f%e,I=ne(b,o,e)*b%e,w=ne(I,i,e)*I%e,d=ne(w,a,e)*w%e,E=ne(d,c,e)*d%e,C=ne(E,a,e)*w%e,x=ne(C,t,e)*u%e,T=ne(x,s,e)*I%e,F=ne(T,n,e)*f%e,V=ne(F,qs,e);if(!zs.eql(zs.sqr(V),r))throw new Error("Cannot find square root");return V}var zs=Vt(Vu,void 0,void 0,{sqrt:H0}),tr=Ru({a:BigInt(0),b:BigInt(7),Fp:zs,n:_u,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:r=>{let e=_u,t=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-M0*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),i=t,s=BigInt("0x100000000000000000000000000000000"),a=Lu(i*r,e),c=Lu(-n*r,e),f=X(r-a*t-c*o,e),u=X(-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}}}},Br),Dw=BigInt(0);var Ow=tr.ProjectivePoint;function Fe(r,e){e==null&&(e=r.reduce((o,i)=>o+i.length,0));let t=Je(e),n=0;for(let o of r)t.set(o,n),n+=o.length;return t}function Pu(r){return r==null?!1:typeof r.then=="function"&&typeof r.catch=="function"&&typeof r.finally=="function"}function Fu(r,e,t){let n=Jr.digest(t instanceof Uint8Array?t:t.subarray());if(Pu(n))return n.then(({digest:o})=>tr.verify(e,o,r)).catch(o=>{throw new ln(String(o))});try{return tr.verify(e,n.digest,r)}catch(o){throw new ln(String(o))}}var qo=class{type="secp256k1";raw;_key;constructor(e){this._key=Ou(e),this.raw=Du(this._key)}toMultihash(){return dt.digest(jn(this))}toCID(){return ie.createV1(114,this.toMultihash())}toString(){return te.encode(this.toMultihash().bytes).substring(1)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:ue(this.raw,e.raw)}verify(e,t){return Fu(this._key,t,e)}};function js(r){return new qo(r)}function Du(r){return tr.ProjectivePoint.fromHex(r).toRawBytes(!0)}function Ou(r){try{return tr.ProjectivePoint.fromHex(r),r}catch(e){throw new or(String(e))}}function Mu(r){let{Type:e,Data:t}=it.decode(r),n=t??new Uint8Array;switch(e){case fe.RSA:return $s(n);case fe.Ed25519:return ns(n);case fe.secp256k1:return js(n);default:throw new sr}}function zo(r){let{Type:e,Data:t}=it.decode(r.digest),n=t??new Uint8Array;switch(e){case fe.Ed25519:return ns(n);case fe.secp256k1:return js(n);default:throw new sr}}function jn(r){return it.encode({Type:fe[r.type],Data:r.raw})}var Hu=Symbol.for("nodejs.util.inspect.custom"),$0=114,dn=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()})`}[Ii]=!0;toString(){return this.string==null&&(this.string=te.encode(this.multihash.bytes).slice(1)),this.string}toMultihash(){return this.multihash}toCID(){return ie.createV1($0,this.multihash)}toJSON(){return this.toString()}equals(e){if(e==null)return!1;if(e instanceof Uint8Array)return ue(this.multihash.bytes,e);if(typeof e=="string")return this.toString()===e;if(e?.toMultihash()?.bytes!=null)return ue(this.multihash.bytes,e.toMultihash().bytes);throw new Error("not valid Id")}[Hu](){return`PeerId(${this.toString()})`}},jo=class extends dn{type="RSA";publicKey;constructor(e){super({...e,type:"RSA"}),this.publicKey=e.publicKey}},Go=class extends dn{type="Ed25519";publicKey;constructor(e){super({...e,type:"Ed25519"}),this.publicKey=e.publicKey}},Zo=class extends dn{type="secp256k1";publicKey;constructor(e){super({...e,type:"secp256k1"}),this.publicKey=e.publicKey}},K0=2336,Wo=class{type="url";multihash;publicKey;url;constructor(e){this.url=e.toString(),this.multihash=dt.digest(J(this.url))}[Hu](){return`PeerId(${this.url})`}[Ii]=!0;toString(){return this.toCID().toString()}toMultihash(){return this.multihash}toCID(){return ie.createV1(K0,this.toMultihash())}toJSON(){return this.toString()}equals(e){return e==null?!1:(e instanceof Uint8Array&&(e=oe(e)),e.toString()===this.toString())}};function $u(r,e){let t;if(r.charAt(0)==="1"||r.charAt(0)==="Q")t=ht(te.decode(`z${r}`));else{if(e==null)throw new ve('Please pass a multibase decoder for strings that do not start with "1" or "Q"');t=ht(e.decode(r))}return q0(t)}function q0(r){if(j0(r))return new jo({multihash:r});if(z0(r))try{let e=zo(r);if(e.type==="Ed25519")return new Go({multihash:r,publicKey:e});if(e.type==="secp256k1")return new Zo({multihash:r,publicKey:e})}catch{let t=oe(r.digest);return new Wo(new URL(t))}throw new ir("Supplied PeerID Multihash is invalid")}function z0(r){return r.code===dt.code}function j0(r){return r.code===Jr.code}var Jo=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 Ku=45,G0=15,Nr=new Jo;function Gs(r){if(!(r.length>G0))return Nr.new(r).parseWith(()=>Nr.readIPv4Addr())}function Zs(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>Ku))return Nr.new(r).parseWith(()=>Nr.readIPv6Addr())}function Yo(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>Ku))return Nr.new(r).parseWith(()=>Nr.readIPAddr())}var tb=parseInt("0xFFFF",16),rb=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);function ju(r){return!!Gs(r)}function Gu(r){return!!Zs(r)}function Xo(r){return!!Yo(r)}var Zu=ju,X0=Gu,Ws=function(r){let e=0;if(r=r.toString().trim(),Zu(r)){let t=new Uint8Array(e+4);return r.split(/\./g).forEach(n=>{t[e++]=parseInt(n,10)&255}),t}if(X0(r)){let t=r.split(":",8),n;for(n=0;n<t.length;n++){let i=Zu(t[n]),s;i&&(s=Ws(t[n]),t[n]=oe(s.slice(0,2),"base16")),s!=null&&++n<8&&t.splice(n,0,oe(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")},Wu=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 Ur={},Js={},ep=[[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"]];ep.forEach(r=>{let e=tp(...r);Js[e.code]=e,Ur[e.name]=e});function tp(r,e,t,n,o){return{code:r,size:e,name:t,resolvable:!!n,path:!!o}}function Q(r){if(typeof r=="number"){if(Js[r]!=null)return Js[r];throw new Error(`no protocol with code: ${r}`)}else if(typeof r=="string"){if(Ur[r]!=null)return Ur[r];throw new Error(`no protocol with name: ${r}`)}throw new Error(`invalid protocol id type: ${typeof r}`)}var Ob=Q("ip4"),Mb=Q("ip6"),Hb=Q("ipcidr");function ea(r,e){switch(Q(r).code){case 4:case 41:return np(e);case 42:return Qs(e);case 6:case 273:case 33:case 132:return Xu(e).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return Qs(e);case 421:return ap(e);case 444:return Yu(e);case 445:return Yu(e);case 466:return sp(e);case 481:return globalThis.encodeURIComponent(Qs(e));default:return oe(e,"base16")}}function ta(r,e){switch(Q(r).code){case 4:return Ju(e);case 41:return Ju(e);case 42:return Xs(e);case 6:case 273:case 33:case 132:return ra(parseInt(e,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return Xs(e);case 421:return op(e);case 444:return cp(e);case 445:return up(e);case 466:return ip(e);case 481:return Xs(globalThis.decodeURIComponent(e));default:return J(e,"base16")}}var Ys=Object.values(Yr).map(r=>r.decoder),rp=function(){let r=Ys[0].or(Ys[1]);return Ys.slice(2).forEach(e=>r=r.or(e)),r}();function Ju(r){if(!Xo(r))throw new Error("invalid ip address");return Ws(r)}function np(r){let e=Wu(r,0,r.length);if(e==null)throw new Error("ipBuff is required");if(!Xo(e))throw new Error("invalid ip address");return e}function ra(r){let e=new ArrayBuffer(2);return new DataView(e).setUint16(0,r),new Uint8Array(e)}function Xu(r){return new DataView(r.buffer).getUint16(r.byteOffset)}function Xs(r){let e=J(r),t=Uint8Array.from(wr(e.length));return Fe([t,e],t.length+e.length)}function Qs(r){let e=Yt(r);if(r=r.slice(Le(e)),r.length!==e)throw new Error("inconsistent lengths");return oe(r)}function op(r){let e;r[0]==="Q"||r[0]==="1"?e=ht(te.decode(`z${r}`)).bytes:e=ie.parse(r).multihash.bytes;let t=Uint8Array.from(wr(e.length));return Fe([t,e],t.length+e.length)}function ip(r){let e=rp.decode(r),t=Uint8Array.from(wr(e.length));return Fe([t,e],t.length+e.length)}function sp(r){let e=Yt(r),t=r.slice(Le(e));if(t.length!==e)throw new Error("inconsistent lengths");return"u"+oe(t,"base64url")}function ap(r){let e=Yt(r),t=r.slice(Le(e));if(t.length!==e)throw new Error("inconsistent lengths");return oe(t,"base58btc")}function cp(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=ze.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=ra(n);return Fe([t,o],t.length+o.length)}function up(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=ze.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=ra(n);return Fe([t,o],t.length+o.length)}function Yu(r){let e=r.slice(0,r.length-2),t=r.slice(r.length-2),n=oe(e,"base32"),o=Xu(t);return`${n}:${o}`}function Qu(r){r=na(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=Q(s);if(a.size===0){e.push([a.code]),t.push([a.code]);continue}if(i++,i>=o.length)throw tl("invalid address: "+r);if(a.path===!0){n=na(o.slice(i).join("/")),e.push([a.code,ta(a.code,n)]),t.push([a.code,n]);break}let c=ta(a.code,o[i]);e.push([a.code,c]),t.push([a.code,ea(a.code,c)])}return{string:el(t),bytes:ia(e),tuples:e,stringTuples:t,path:n}}function oa(r){let e=[],t=[],n=null,o=0;for(;o<r.length;){let i=Yt(r,o),s=Le(i),a=Q(i),c=lp(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 tl("Invalid address Uint8Array: "+oe(r,"base16"));e.push([i,f]);let u=ea(i,f);if(t.push([i,u]),a.path===!0){n=u;break}}return{bytes:Uint8Array.from(r),string:el(t),tuples:e,stringTuples:t,path:n}}function el(r){let e=[];return r.map(t=>{let n=Q(t[0]);return e.push(n.name),t.length>1&&t[1]!=null&&e.push(t[1]),null}),na(e.join("/"))}function ia(r){return Fe(r.map(e=>{let t=Q(e[0]),n=Uint8Array.from(wr(t.code));return e.length>1&&e[1]!=null&&(n=Fe([n,e[1]])),n}))}function lp(r,e){if(r.size>0)return r.size/8;if(r.size===0)return 0;{let t=Yt(e instanceof Uint8Array?e:Uint8Array.from(e));return t+Le(t)}}function na(r){return"/"+r.trim().split("/").filter(e=>e).join("/")}function tl(r){return new Error("Error parsing address: "+r)}var fp=Symbol.for("nodejs.util.inspect.custom"),aa=Symbol.for("@multiformats/js-multiaddr/multiaddr"),hp=[Q("dns").code,Q("dns4").code,Q("dns6").code,Q("dnsaddr").code],sa=class extends Error{constructor(e="No available resolver"){super(e),this.name="NoAvailableResolverError"}},Qo=class r{bytes;#e;#r;#t;#a;[aa]=!0;constructor(e){e==null&&(e="");let t;if(e instanceof Uint8Array)t=oa(e);else if(typeof e=="string"){if(e.length>0&&e.charAt(0)!=="/")throw new Error(`multiaddr "${e}" must start with a "/"`);t=Qu(e)}else if(nl(e))t=oa(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=Q("tcp"),a=Q("udp"),c=Q("ip4"),f=Q("ip6"),u=Q("dns6"),l=Q("ip6zone");for(let[b,I]of this.stringTuples())b===l.code&&(i=`%${I??""}`),hp.includes(b)&&(t=s.name,o=443,n=`${I??""}${i}`,e=b===u.code?6:4),(b===s.code||b===a.code)&&(t=Q(b).name,o=parseInt(I??"")),(b===c.code||b===f.code)&&(t=Q(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({},Q(e)))}protoCodes(){return this.#r.map(([e])=>e)}protoNames(){return this.#r.map(([e])=>Q(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(ia(t.slice(0,n)));return this}getPeerId(){try{let e=[];this.stringTuples().forEach(([n,o])=>{n===Ur.p2p.code&&e.push([n,o]),n===Ur["p2p-circuit"].code&&(e=[])});let t=e.pop();if(t?.[1]!=null){let n=t[1];return n[0]==="Q"||n[0]==="1"?oe(te.decode(`z${n}`),"base58btc"):oe(ie.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){return this.#a}equals(e){return ue(this.bytes,e.bytes)}async resolve(e){let t=this.protos().find(i=>i.resolvable);if(t==null)return[this];let n=rl.get(t.name);if(n==null)throw new sa(`no available resolver for ${t.name}`);return(await n(this,e)).map(i=>pn(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)}[fp](){return`Multiaddr(${this.#e})`}};var rl=new Map;function nl(r){return!!r?.[aa]}function pn(r){return new Qo(r)}function mn(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*ei(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 dp="/",pp=new TextEncoder().encode(dp),m1=pp[0];var Zp=Tn(ua(),1);var Qe=class extends Error{static name="SignatureVerificationError";constructor(e="Record signature verification failed"){super(e),this.name="SignatureVerificationError"}},ti=class extends Error{static name="RecordExpiredError";constructor(e="Record has expired"){super(e),this.name="RecordExpiredError"}},Rr=class extends Error{static name="UnsupportedValidityError";constructor(e="The validity type is unsupported"){super(e),this.name="UnsupportedValidityError"}},ri=class extends Error{static name="RecordTooLargeError";constructor(e="The record is too large"){super(e),this.name="RecordTooLargeError"}},ni=class extends Error{static name="InvalidValueError";constructor(e="Value must be a valid content path starting with /"){super(e),this.name="InvalidValueError"}},oi=class extends Error{static name="InvalidRecordDataError";constructor(e="Invalid record data"){super(e),this.name="InvalidRecordDataError"}},gn=class extends Error{static name="InvalidEmbeddedPublicKeyError";constructor(e="Invalid embedded public key"){super(e),this.name="InvalidEmbeddedPublicKeyError"}};var et;(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=()=>en(t)}(e=r.ValidityType||(r.ValidityType={}));let n;r.codec=()=>(n==null&&(n=Er((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=>br(o,r.codec()),r.decode=(o,i)=>xr(o,r.codec(),i)})(et||(et={}));var mp=["string","number","bigint","symbol"],gp=["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 ol(r){if(r===null)return"null";if(r===void 0)return"undefined";if(r===!0||r===!1)return"boolean";let e=typeof r;if(mp.includes(e))return e;if(e==="function")return"Function";if(Array.isArray(r))return"Array";if(yp(r))return"Buffer";let t=wp(r);return t||"Object"}function yp(r){return r&&r.constructor&&r.constructor.isBuffer&&r.constructor.isBuffer.call(null,r)}function wp(r){let e=Object.prototype.toString.call(r).slice(8,-1);if(gp.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 _r=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&typeof globalThis.Buffer.isBuffer=="function",xp=new TextDecoder,bp=new TextEncoder;function ii(r){return _r&&globalThis.Buffer.isBuffer(r)}function cl(r){return r instanceof Uint8Array?ii(r)?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r:Uint8Array.from(r)}var ul=_r?(r,e,t)=>t-e>64?globalThis.Buffer.from(r.subarray(e,t)).toString("utf8"):sl(r,e,t):(r,e,t)=>t-e>64?xp.decode(r.subarray(e,t)):sl(r,e,t),ll=_r?r=>r.length>64?globalThis.Buffer.from(r):il(r):r=>r.length>64?bp.encode(r):il(r);var Lr=_r?(r,e,t)=>ii(r)?new Uint8Array(r.subarray(e,t)):r.slice(e,t):(r,e,t)=>r.slice(e,t),fl=_r?(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},hl=_r?r=>globalThis.Buffer.allocUnsafe(r):r=>new Uint8Array(r);function dl(r,e){if(ii(r)&&ii(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 sl(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 vp(n)}var al=4096;function vp(r){let e=r.length;if(e<=al)return String.fromCharCode.apply(String,r);let t="",n=0;for(;n<e;)t+=String.fromCharCode.apply(String,r.slice(n,n+=al));return t}var Ep=256,si=class{constructor(e=Ep){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=hl(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=Lr(n,0,this.cursor)}else t=fl(this.chunks,this.cursor);return e&&this.reset(),t}};var H="CBOR decode error:",la="CBOR encode error:",yn=[];yn[23]=1;yn[24]=2;yn[25]=3;yn[26]=5;yn[27]=9;function It(r,e,t){if(r.length-e<t)throw new Error(`${H} not enough data for type`)}var me=[24,256,65536,4294967296,BigInt("18446744073709551616")];function De(r,e,t){It(r,e,1);let n=r[e];if(t.strict===!0&&n<me[0])throw new Error(`${H} integer encoded in more bytes than necessary (strict decode)`);return n}function Oe(r,e,t){It(r,e,2);let n=r[e]<<8|r[e+1];if(t.strict===!0&&n<me[1])throw new Error(`${H} integer encoded in more bytes than necessary (strict decode)`);return n}function Me(r,e,t){It(r,e,4);let n=r[e]*16777216+(r[e+1]<<16)+(r[e+2]<<8)+r[e+3];if(t.strict===!0&&n<me[2])throw new Error(`${H} integer encoded in more bytes than necessary (strict decode)`);return n}function He(r,e,t){It(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<me[3])throw new Error(`${H} 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(`${H} integers outside of the safe integer range are not supported`)}function pl(r,e,t,n){return new L(y.uint,De(r,e+1,n),2)}function ml(r,e,t,n){return new L(y.uint,Oe(r,e+1,n),3)}function gl(r,e,t,n){return new L(y.uint,Me(r,e+1,n),5)}function yl(r,e,t,n){return new L(y.uint,He(r,e+1,n),9)}function Ke(r,e){return be(r,0,e.value)}function be(r,e,t){if(t<me[0]){let n=Number(t);r.push([e|n])}else if(t<me[1]){let n=Number(t);r.push([e|24,n])}else if(t<me[2]){let n=Number(t);r.push([e|25,n>>>8,n&255])}else if(t<me[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<me[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(`${H} encountered BigInt larger than allowable range`)}}Ke.encodedSize=function(e){return be.encodedSize(e.value)};be.encodedSize=function(e){return e<me[0]?1:e<me[1]?2:e<me[2]?3:e<me[3]?5:9};Ke.compareTokens=function(e,t){return e.value<t.value?-1:e.value>t.value?1:0};function wl(r,e,t,n){return new L(y.negint,-1-De(r,e+1,n),2)}function xl(r,e,t,n){return new L(y.negint,-1-Oe(r,e+1,n),3)}function bl(r,e,t,n){return new L(y.negint,-1-Me(r,e+1,n),5)}var fa=BigInt(-1),vl=BigInt(1);function El(r,e,t,n){let o=He(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(`${H} integers outside of the safe integer range are not supported`);return new L(y.negint,fa-BigInt(o),9)}function ai(r,e){let t=e.value,n=typeof t=="bigint"?t*fa-vl:t*-1-1;be(r,e.type.majorEncoded,n)}ai.encodedSize=function(e){let t=e.value,n=typeof t=="bigint"?t*fa-vl:t*-1-1;return n<me[0]?1:n<me[1]?2:n<me[2]?3:n<me[3]?5:9};ai.compareTokens=function(e,t){return e.value<t.value?1:e.value>t.value?-1:0};function wn(r,e,t,n){It(r,e,t+n);let o=Lr(r,e+t,e+t+n);return new L(y.bytes,o,t+n)}function Bl(r,e,t,n){return wn(r,e,1,t)}function Al(r,e,t,n){return wn(r,e,2,De(r,e+1,n))}function Sl(r,e,t,n){return wn(r,e,3,Oe(r,e+1,n))}function Il(r,e,t,n){return wn(r,e,5,Me(r,e+1,n))}function kl(r,e,t,n){let o=He(r,e+1,n);if(typeof o=="bigint")throw new Error(`${H} 64-bit integer bytes lengths not supported`);return wn(r,e,9,o)}function ci(r){return r.encodedBytes===void 0&&(r.encodedBytes=r.type===y.string?ll(r.value):r.value),r.encodedBytes}function Vr(r,e){let t=ci(e);be(r,e.type.majorEncoded,t.length),r.push(t)}Vr.encodedSize=function(e){let t=ci(e);return be.encodedSize(t.length)+t.length};Vr.compareTokens=function(e,t){return Ap(ci(e),ci(t))};function Ap(r,e){return r.length<e.length?-1:r.length>e.length?1:dl(r,e)}function xn(r,e,t,n,o){let i=t+n;It(r,e,i);let s=new L(y.string,ul(r,e+t,e+i),i);return o.retainStringBytes===!0&&(s.byteValue=Lr(r,e+t,e+i)),s}function Cl(r,e,t,n){return xn(r,e,1,t,n)}function Tl(r,e,t,n){return xn(r,e,2,De(r,e+1,n),n)}function Nl(r,e,t,n){return xn(r,e,3,Oe(r,e+1,n),n)}function Ul(r,e,t,n){return xn(r,e,5,Me(r,e+1,n),n)}function Rl(r,e,t,n){let o=He(r,e+1,n);if(typeof o=="bigint")throw new Error(`${H} 64-bit integer string lengths not supported`);return xn(r,e,9,o,n)}var _l=Vr;function Pr(r,e,t,n){return new L(y.array,n,t)}function Ll(r,e,t,n){return Pr(r,e,1,t)}function Vl(r,e,t,n){return Pr(r,e,2,De(r,e+1,n))}function Pl(r,e,t,n){return Pr(r,e,3,Oe(r,e+1,n))}function Fl(r,e,t,n){return Pr(r,e,5,Me(r,e+1,n))}function Dl(r,e,t,n){let o=He(r,e+1,n);if(typeof o=="bigint")throw new Error(`${H} 64-bit integer array lengths not supported`);return Pr(r,e,9,o)}function Ol(r,e,t,n){if(n.allowIndefinite===!1)throw new Error(`${H} indefinite length items not allowed`);return Pr(r,e,1,1/0)}function ui(r,e){be(r,y.array.majorEncoded,e.value)}ui.compareTokens=Ke.compareTokens;ui.encodedSize=function(e){return be.encodedSize(e.value)};function Fr(r,e,t,n){return new L(y.map,n,t)}function Ml(r,e,t,n){return Fr(r,e,1,t)}function Hl(r,e,t,n){return Fr(r,e,2,De(r,e+1,n))}function $l(r,e,t,n){return Fr(r,e,3,Oe(r,e+1,n))}function Kl(r,e,t,n){return Fr(r,e,5,Me(r,e+1,n))}function ql(r,e,t,n){let o=He(r,e+1,n);if(typeof o=="bigint")throw new Error(`${H} 64-bit integer map lengths not supported`);return Fr(r,e,9,o)}function zl(r,e,t,n){if(n.allowIndefinite===!1)throw new Error(`${H} indefinite length items not allowed`);return Fr(r,e,1,1/0)}function li(r,e){be(r,y.map.majorEncoded,e.value)}li.compareTokens=Ke.compareTokens;li.encodedSize=function(e){return be.encodedSize(e.value)};function jl(r,e,t,n){return new L(y.tag,t,1)}function Gl(r,e,t,n){return new L(y.tag,De(r,e+1,n),2)}function Zl(r,e,t,n){return new L(y.tag,Oe(r,e+1,n),3)}function Wl(r,e,t,n){return new L(y.tag,Me(r,e+1,n),5)}function Jl(r,e,t,n){return new L(y.tag,He(r,e+1,n),9)}function fi(r,e){be(r,y.tag.majorEncoded,e.value)}fi.compareTokens=Ke.compareTokens;fi.encodedSize=function(e){return be.encodedSize(e.value)};var Np=20,Up=21,Rp=22,_p=23;function Yl(r,e,t,n){if(n.allowUndefined===!1)throw new Error(`${H} undefined values are not supported`);return n.coerceUndefinedToNull===!0?new L(y.null,null,1):new L(y.undefined,void 0,1)}function Xl(r,e,t,n){if(n.allowIndefinite===!1)throw new Error(`${H} indefinite length items not allowed`);return new L(y.break,void 0,1)}function ha(r,e,t){if(t){if(t.allowNaN===!1&&Number.isNaN(r))throw new Error(`${H} NaN values are not supported`);if(t.allowInfinity===!1&&(r===1/0||r===-1/0))throw new Error(`${H} Infinity values are not supported`)}return new L(y.float,r,e)}function Ql(r,e,t,n){return ha(da(r,e+1),3,n)}function ef(r,e,t,n){return ha(pa(r,e+1),5,n)}function tf(r,e,t,n){return ha(sf(r,e+1),9,n)}function hi(r,e,t){let n=e.value;if(n===!1)r.push([y.float.majorEncoded|Np]);else if(n===!0)r.push([y.float.majorEncoded|Up]);else if(n===null)r.push([y.float.majorEncoded|Rp]);else if(n===void 0)r.push([y.float.majorEncoded|_p]);else{let o,i=!1;(!t||t.float64!==!0)&&(nf(n),o=da(tt,1),n===o||Number.isNaN(n)?(tt[0]=249,r.push(tt.slice(0,3)),i=!0):(of(n),o=pa(tt,1),n===o&&(tt[0]=250,r.push(tt.slice(0,5)),i=!0))),i||(Lp(n),o=sf(tt,1),tt[0]=251,r.push(tt.slice(0,9)))}}hi.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){nf(n);let o=da(tt,1);if(n===o||Number.isNaN(n))return 3;if(of(n),o=pa(tt,1),n===o)return 5}return 9};var rf=new ArrayBuffer(9),qe=new DataView(rf,1),tt=new Uint8Array(rf,0);function nf(r){if(r===1/0)qe.setUint16(0,31744,!1);else if(r===-1/0)qe.setUint16(0,64512,!1);else if(Number.isNaN(r))qe.setUint16(0,32256,!1);else{qe.setFloat32(0,r);let e=qe.getUint32(0),t=(e&2139095040)>>23,n=e&8388607;if(t===255)qe.setUint16(0,31744,!1);else if(t===0)qe.setUint16(0,(r&2147483648)>>16|n>>13,!1);else{let o=t-127;o<-24?qe.setUint16(0,0):o<-14?qe.setUint16(0,(e&2147483648)>>16|1<<24+o,!1):qe.setUint16(0,(e&2147483648)>>16|o+15<<10|n>>13,!1)}}}function da(r,e){if(r.length-e<2)throw new Error(`${H} 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 of(r){qe.setFloat32(0,r,!1)}function pa(r,e){if(r.length-e<4)throw new Error(`${H} not enough data for float32`);let t=(r.byteOffset||0)+e;return new DataView(r.buffer,t,4).getFloat32(0,!1)}function Lp(r){qe.setFloat64(0,r,!1)}function sf(r,e){if(r.length-e<8)throw new Error(`${H} not enough data for float64`);let t=(r.byteOffset||0)+e;return new DataView(r.buffer,t,8).getFloat64(0,!1)}hi.compareTokens=Ke.compareTokens;function Z(r,e,t){throw new Error(`${H} encountered invalid minor (${t}) for major ${r[e]>>>5}`)}function di(r){return()=>{throw new Error(`${H} ${r}`)}}var k=[];for(let r=0;r<=23;r++)k[r]=Z;k[24]=pl;k[25]=ml;k[26]=gl;k[27]=yl;k[28]=Z;k[29]=Z;k[30]=Z;k[31]=Z;for(let r=32;r<=55;r++)k[r]=Z;k[56]=wl;k[57]=xl;k[58]=bl;k[59]=El;k[60]=Z;k[61]=Z;k[62]=Z;k[63]=Z;for(let r=64;r<=87;r++)k[r]=Bl;k[88]=Al;k[89]=Sl;k[90]=Il;k[91]=kl;k[92]=Z;k[93]=Z;k[94]=Z;k[95]=di("indefinite length bytes/strings are not supported");for(let r=96;r<=119;r++)k[r]=Cl;k[120]=Tl;k[121]=Nl;k[122]=Ul;k[123]=Rl;k[124]=Z;k[125]=Z;k[126]=Z;k[127]=di("indefinite length bytes/strings are not supported");for(let r=128;r<=151;r++)k[r]=Ll;k[152]=Vl;k[153]=Pl;k[154]=Fl;k[155]=Dl;k[156]=Z;k[157]=Z;k[158]=Z;k[159]=Ol;for(let r=160;r<=183;r++)k[r]=Ml;k[184]=Hl;k[185]=$l;k[186]=Kl;k[187]=ql;k[188]=Z;k[189]=Z;k[190]=Z;k[191]=zl;for(let r=192;r<=215;r++)k[r]=jl;k[216]=Gl;k[217]=Zl;k[218]=Wl;k[219]=Jl;k[220]=Z;k[221]=Z;k[222]=Z;k[223]=Z;for(let r=224;r<=243;r++)k[r]=di("simple values are not supported");k[244]=Z;k[245]=Z;k[246]=Z;k[247]=Yl;k[248]=di("simple values are not supported");k[249]=Ql;k[250]=ef;k[251]=tf;k[252]=Z;k[253]=Z;k[254]=Z;k[255]=Xl;var rt=[];for(let r=0;r<24;r++)rt[r]=new L(y.uint,r,1);for(let r=-1;r>=-24;r--)rt[31-r]=new L(y.negint,r,1);rt[64]=new L(y.bytes,new Uint8Array(0),1);rt[96]=new L(y.string,"",1);rt[128]=new L(y.array,0,1);rt[160]=new L(y.map,0,1);rt[244]=new L(y.false,!1,1);rt[245]=new L(y.true,!0,1);rt[246]=new L(y.null,null,1);function Pp(){let r=[];return r[y.uint.major]=Ke,r[y.negint.major]=ai,r[y.bytes.major]=Vr,r[y.string.major]=_l,r[y.array.major]=ui,r[y.map.major]=li,r[y.tag.major]=fi,r[y.float.major]=hi,r}var d2=Pp(),p2=new si,pi=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(`${la} object contains circular references`);return new r(t,e)}},$t={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)},Kt={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?$t.true:$t.false},null(r,e,t,n){return $t.null},undefined(r,e,t,n){return $t.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?[$t.emptyArray,new L(y.break)]:$t.emptyArray;n=pi.createCheck(n,r);let o=[],i=0;for(let s of r)o[i++]=ma(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?[$t.emptyMap,new L(y.break)]:$t.emptyMap;n=pi.createCheck(n,r);let a=[],c=0;for(let f of i)a[c++]=[ma(f,t,n),ma(o?r.get(f):r[f],t,n)];return Fp(a,t),t.addBreakTokens?[new L(y.map,s),a,new L(y.break)]:[new L(y.map,s),a]}};Kt.Map=Kt.Object;Kt.Buffer=Kt.Uint8Array;for(let r of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))Kt[`${r}Array`]=Kt.DataView;function ma(r,e={},t){let n=ol(r),o=e&&e.typeEncoders&&e.typeEncoders[n]||Kt[n];if(typeof o=="function"){let s=o(r,n,e,t);if(s!=null)return s}let i=Kt[n];if(!i)throw new Error(`${la} unsupported type: ${n}`);return i(r,n,e,t)}function Fp(r,e){e.mapSorter&&r.sort(e.mapSorter)}var Dp={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0},mi=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=rt[e];if(t===void 0){let n=k[e];if(!n)throw new Error(`${H} 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}},bn=Symbol.for("DONE"),gi=Symbol.for("BREAK");function Op(r,e,t){let n=[];for(let o=0;o<r.value;o++){let i=Dr(e,t);if(i===gi){if(r.value===1/0)break;throw new Error(`${H} got unexpected break to lengthed array`)}if(i===bn)throw new Error(`${H} found array but not enough entries (got ${o}, expected ${r.value})`);n[o]=i}return n}function Mp(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=Dr(e,t);if(a===gi){if(r.value===1/0)break;throw new Error(`${H} got unexpected break to lengthed map`)}if(a===bn)throw new Error(`${H} found map but not enough entries (got ${s} [no key], expected ${r.value})`);if(n!==!0&&typeof a!="string")throw new Error(`${H} non-string keys not supported (got ${typeof a})`);if(t.rejectDuplicateMapKeys===!0&&(n&&i.has(a)||!n&&a in o))throw new Error(`${H} found repeat map key "${a}"`);let c=Dr(e,t);if(c===bn)throw new Error(`${H} 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 Dr(r,e){if(r.done())return bn;let t=r.next();if(t.type===y.break)return gi;if(t.type.terminal)return t.value;if(t.type===y.array)return Op(t,r,e);if(t.type===y.map)return Mp(t,r,e);if(t.type===y.tag){if(e.tags&&typeof e.tags[t.value]=="function"){let n=Dr(r,e);return e.tags[t.value](n)}throw new Error(`${H} tag not supported (${t.value})`)}throw new Error("unsupported")}function af(r,e){if(!(r instanceof Uint8Array))throw new Error(`${H} data to decode must be a Uint8Array`);e=Object.assign({},Dp,e);let t=e.tokenizer||new mi(r,e),n=Dr(t,e);if(n===bn)throw new Error(`${H} did not find any content to decode`);if(n===gi)throw new Error(`${H} got unexpected break`);return[n,r.subarray(t.pos())]}function ga(r,e){let[t,n]=af(r,e);if(n.length>0)throw new Error(`${H} too many terminals, data makes no sense`);return t}var Kp=Ct("ipns:utils"),cf=J("/ipns/");var qp=0,zp=18;function uf(r){let e;if(r.pubKey!=null)try{e=Mu(r.pubKey)}catch(t){throw Kp.error(t),t}if(e!=null)return e}function lf(r){let e=J("ipns-signature:");return Fe([e,r])}function vn(r){return"signatureV1"in r?et.encode({value:J(r.value),signatureV1:r.signatureV1,validityType:r.validityType,validity:J(r.validity),sequence:r.sequence,ttl:r.ttl,pubKey:r.pubKey,signatureV2:r.signatureV2,data:r.data}):et.encode({pubKey:r.pubKey,signatureV2:r.signatureV2,data:r.data})}function qt(r){let e=et.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 Qe("Missing data or signatureV2");let t=ff(e.data),n=jp(t.Value),o=oe(t.Validity);if(e.value!=null&&e.signatureV1!=null)return Gp(e),{value:n,validityType:et.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:et.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 En(r){return Fe([cf,r.bytes])}function Or(r){let e=ht(r.slice(cf.length));if(!yi(e,qp)&&!yi(e,zp))throw new ir("Multihash in IPNS key was not identity or sha2-256");return e}function ff(r){let e=ga(r);if(e.ValidityType===0)e.ValidityType=et.ValidityType.EOL;else throw new Rr("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 jp(r){let e=oe(r).trim();if(e.startsWith("/"))return e;try{return`/ipfs/${ie.decode(r).toV1().toString()}`}catch{}try{return`/ipfs/${ie.parse(e).toV1().toString()}`}catch{}throw new ni("Value must be a valid content path starting with /")}function Gp(r){if(r.data==null)throw new oi("Record data is missing");let e=ff(r.data);if(!ue(e.Value,r.value??new Uint8Array(0)))throw new Qe('Field "value" did not match between protobuf and CBOR');if(!ue(e.Validity,r.validity??new Uint8Array(0)))throw new Qe('Field "validity" did not match between protobuf and CBOR');if(e.ValidityType!==r.validityType)throw new Qe('Field "validityType" did not match between protobuf and CBOR');if(e.Sequence!==r.sequence)throw new Qe('Field "sequence" did not match between protobuf and CBOR');if(e.TTL!==r.ttl)throw new Qe('Field "ttl" did not match between protobuf and CBOR')}function yi(r,e){return r.code===e}var D2=Ct("ipns"),O2=60*60*1e9,Wp="/ipns/",M2=Wp.length;var hf=Tn(ua(),1);var wi=Ct("ipns:validator"),Jp=1024*10,Yp=async(r,e)=>{let t=qt(e),n;try{let o=lf(t.data);n=await r.verify(o,t.signatureV2)}catch{n=!1}if(!n)throw wi.error("record signature verification failed"),new Qe("Record signature verification failed");if(t.validityType===et.ValidityType.EOL){if(hf.default.fromString(t.validity).toDate().getTime()<Date.now())throw wi.error("record has expired"),new ti("record has expired")}else if(t.validityType!=null)throw wi.error("the validity type is unsupported"),new Rr("The validity type is unsupported");wi("ipns record for %s is valid",t.value)};async function df(r,e){if(e.byteLength>Jp)throw new ri("The record is too large");let t=Or(r),n;yi(t,0)&&(n=zo(t));let o=qt(e),i=uf(o)??n;if(i==null)throw new gn("Could not extract public key from IPNS record or routing key");let s=En(i.toMultihash());if(!ue(r,s))throw new gn("Embedded public key did not match routing key");await Yp(i,e)}async function*Bn(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 ut(){let r={};return r.promise=new Promise((e,t)=>{r.resolve=e,r.reject=t}),r}var wa=Tn(mf(),1);var Sn=class extends Error{constructor(e){super(e),this.name="TimeoutError"}},xa=class extends Error{constructor(e){super(),this.name="AbortError",this.message=e}},gf=r=>globalThis.DOMException===void 0?new xa(r):new DOMException(r),yf=r=>{let e=r.reason===void 0?gf("This operation was aborted."):r.reason;return e instanceof Error?e:gf(e)};function ba(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(yf(h));let b=()=>{u(yf(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 Sn;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 va(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 In=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=va(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 kn=class extends wa.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:In,...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=ba(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 Sn&&!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 Mr=class extends Error{static name="InvalidRequestError";constructor(e="Invalid request"){super(e),this.name="InvalidRequestError"}},nr=class extends Error{static name="BadResponseError";constructor(e="Bad response"){super(e),this.name="BadResponseError"}};function em(r){return r[Symbol.asyncIterator]!=null}function tm(r){if(em(r))return(async()=>{for await(let e of r)return e})();for(let e of r)return e}var wf=tm;function rm(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 xf=rm;function nm(r){return r[Symbol.asyncIterator]!=null}function om(r,e){let t=0;if(nm(r))return async function*(){for await(let c of r)yield e(c,t++)}();let n=xf(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 bf=om;var vf=J("/ipns/");function Ef(r){return ue(r.subarray(0,vf.byteLength),vf)}var bi=class{client;constructor(e){this.client=e}async*findProviders(e,t={}){yield*bf(this.client.getProviders(e,t),n=>({id:n.ID,multiaddrs:n.Addrs??[]}))}async provide(){}async cancelReprovide(){}async put(e,t,n){if(!Ef(e))return;let o=Or(e),i=ie.createV1(114,o),s=qt(t);await this.client.putIPNS(i,s,n)}async get(e,t){if(!Ef(e))throw new nt("Not found");let n=Or(e),o=ie.createV1(114,n);try{let i=await this.client.getIPNS(o,t);return vn(i)}catch(i){throw i.name==="BadResponseError"?new nt("Not found"):i}}},vi=class{client;constructor(e){this.client=e}async findPeer(e,t={}){let n=await wf(this.client.getPeers(e,t));if(n!=null)return{id:n.ID,multiaddrs:n.Addrs??[]};throw new nt("Not found")}async*getClosestPeers(e,t={}){}};var ge=Ct("delegated-routing-v1-http-api-client"),Ei={concurrentRequests:4,timeout:3e4,cacheTTL:5*60*1e3,cacheName:"delegated-routing-v1-cache"},Bi=class{started;httpQueue;shutDownController;clientUrl;timeout;contentRouting;peerRouting;filterAddrs;filterProtocols;inFlightRequests;cacheName;cache;cacheTTL;constructor(e,t={}){this.started=!1,this.shutDownController=new AbortController,ar(1/0,this.shutDownController.signal),this.httpQueue=new kn({concurrency:t.concurrentRequests??Ei.concurrentRequests}),this.inFlightRequests=new Map,this.clientUrl=e instanceof URL?e:new URL(e),this.timeout=t.timeout??Ei.timeout,this.filterAddrs=t.filterAddrs,this.filterProtocols=t.filterProtocols,this.contentRouting=new bi(this),this.peerRouting=new vi(this),this.cacheName=t.cacheName??Ei.cacheName,this.cacheTTL=t.cacheTTL??Ei.cacheTTL}get[Na](){return this.contentRouting}get[Ua](){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&&ge("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={}){ge("getProviders starts: %c",e);let n=AbortSignal.timeout(this.timeout),o=mn([this.shutDownController.signal,n,t.signal]);ar(1/0,n,o);let i=ut(),s=ut();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 nt("No matching records found");if(f.status===422)throw new Mr("Request does not conform to schema or semantic constraints");if(f.body==null)throw new nr("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 Bn(ei(f.body))){let h=this.#e(l);h!=null&&(yield h)}}catch(a){ge.error("getProviders errored:",a)}finally{o.clear(),s.resolve(),ge("getProviders finished: %c",e)}}async*getPeers(e,t={}){ge("getPeers starts: %c",e);let n=AbortSignal.timeout(this.timeout),o=mn([this.shutDownController.signal,n,t.signal]);ar(1/0,n,o);let i=ut(),s=ut();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 nt("No matching records found");if(f.status===422)throw new Mr("Request does not conform to schema or semantic constraints");if(f.body==null)throw new nr("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 Bn(ei(f.body))){let h=this.#e(l);h!=null&&(yield h)}}catch(a){ge.error("getPeers errored:",a)}finally{o.clear(),s.resolve(),ge("getPeers finished: %c",e)}}async getIPNS(e,t={}){ge("getIPNS starts: %s",e);let n=AbortSignal.timeout(this.timeout),o=mn([this.shutDownController.signal,n,t.signal]);ar(1/0,n,o);let i=ut(),s=ut();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(ge("getIPNS GET %s %d",a,f.status),f.status===404)throw new nt("No matching records found");if(f.status===422)throw new Mr("Request does not conform to schema or semantic constraints");if(f.body==null)throw new nr("GET ipns response had no body");let u=await f.arrayBuffer(),l=new Uint8Array(u,0,u.byteLength);return t.validate!==!1&&await df(En(e.multihash),l),qt(l)}catch(c){throw ge.error("getIPNS GET %s error:",a,c),c}finally{o.clear(),s.resolve(),ge("getIPNS finished: %s",e)}}async putIPNS(e,t,n={}){ge("putIPNS starts: %c",e);let o=AbortSignal.timeout(this.timeout),i=mn([this.shutDownController.signal,o,n.signal]);ar(1/0,o,i);let s=ut(),a=ut();this.httpQueue.add(async()=>(s.resolve(),a.promise));let c=`${this.clientUrl}routing/v1/ipns/${e}`;try{await s.promise;let f=vn(t),u={method:"PUT",headers:{"Content-Type":"application/vnd.ipfs.ipns-record"},body:f,signal:i},l=await this.#t(c,u);if(ge("putIPNS PUT %s %d",c,l.status),l.status!==200)throw new nr("PUT ipns response had status other than 200")}catch(f){throw ge.error("putIPNS PUT %s error:",c,f.stack),f}finally{i.clear(),a.resolve(),ge("putIPNS finished: %c",e)}}#e(e){try{let t=[],n=e.Addrs?.map(pn)??[];return e.Protocols!=null&&t.push(...e.Protocols),e.Protocol!=null&&(t.push(e.Protocol),delete e.Protocol),{...e,Schema:"peer",ID:$u(e.ID),Addrs:n,Protocols:t}}catch(t){ge.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 ge("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 ge("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 im(r,e={}){return new Bi(new URL(r),e)}return Pf(sm);})();
|
|
8
8
|
/*! Bundled license information:
|
|
9
9
|
|
|
10
10
|
pvtsutils/build/index.js:
|