@helia/routers 1.1.1 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.min.js CHANGED
@@ -1,22 +1,21 @@
1
1
  (function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.HeliaRouters = factory()}(typeof self !== 'undefined' ? self : this, function () {
2
- "use strict";var HeliaRouters=(()=>{var Rh=Object.create;var Zn=Object.defineProperty;var kh=Object.getOwnPropertyDescriptor;var Th=Object.getOwnPropertyNames;var Nh=Object.getPrototypeOf,Ch=Object.prototype.hasOwnProperty;var ir=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),ye=(r,e)=>{for(var t in e)Zn(r,t,{get:e[t],enumerable:!0})},Xa=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Th(e))!Ch.call(r,o)&&o!==t&&Zn(r,o,{get:()=>e[o],enumerable:!(n=kh(e,o))||n.enumerable});return r};var Vt=(r,e,t)=>(t=r!=null?Rh(Nh(r)):{},Xa(e||!r||!r.__esModule?Zn(t,"default",{value:r,enumerable:!0}):t,r)),_h=r=>Xa(Zn({},"__esModule",{value:!0}),r);var nc=ir(($m,rc)=>{var vr=1e3,Br=vr*60,Ar=Br*60,sr=Ar*24,Uh=sr*7,Lh=sr*365.25;rc.exports=function(r,e){e=e||{};var t=typeof r;if(t==="string"&&r.length>0)return Dh(r);if(t==="number"&&isFinite(r))return e.long?Oh(r):Vh(r);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(r))};function Dh(r){if(r=String(r),!(r.length>100)){var 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){var t=parseFloat(e[1]),n=(e[2]||"ms").toLowerCase();switch(n){case"years":case"year":case"yrs":case"yr":case"y":return t*Lh;case"weeks":case"week":case"w":return t*Uh;case"days":case"day":case"d":return t*sr;case"hours":case"hour":case"hrs":case"hr":case"h":return t*Ar;case"minutes":case"minute":case"mins":case"min":case"m":return t*Br;case"seconds":case"second":case"secs":case"sec":case"s":return t*vr;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return t;default:return}}}}function Vh(r){var e=Math.abs(r);return e>=sr?Math.round(r/sr)+"d":e>=Ar?Math.round(r/Ar)+"h":e>=Br?Math.round(r/Br)+"m":e>=vr?Math.round(r/vr)+"s":r+"ms"}function Oh(r){var e=Math.abs(r);return e>=sr?Wn(r,e,sr,"day"):e>=Ar?Wn(r,e,Ar,"hour"):e>=Br?Wn(r,e,Br,"minute"):e>=vr?Wn(r,e,vr,"second"):r+" ms"}function Wn(r,e,t,n){var o=e>=t*1.5;return Math.round(r/t)+" "+n+(o?"s":"")}});var ic=ir((Km,oc)=>{function Ph(r){t.debug=t,t.default=t,t.coerce=c,t.disable=i,t.enable=o,t.enabled=s,t.humanize=nc(),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 d=0;d<u.length;d++)l=(l<<5)-l+u.charCodeAt(d),l|=0;return t.colors[Math.abs(l)%t.colors.length]}t.selectColor=e;function t(u){let l,d=null,b,g;function h(...p){if(!h.enabled)return;let x=h,R=Number(new Date),v=R-(l||R);x.diff=v,x.prev=l,x.curr=R,l=R,p[0]=t.coerce(p[0]),typeof p[0]!="string"&&p.unshift("%O");let L=0;p[0]=p[0].replace(/%([a-zA-Z%])/g,(k,C)=>{if(k==="%%")return"%";L++;let y=t.formatters[C];if(typeof y=="function"){let N=p[L];k=y.call(x,N),p.splice(L,1),L--}return k}),t.formatArgs.call(x,p),(x.log||t.log).apply(x,p)}return h.namespace=u,h.useColors=t.useColors(),h.color=t.selectColor(u),h.extend=n,h.destroy=t.destroy,Object.defineProperty(h,"enabled",{enumerable:!0,configurable:!1,get:()=>d!==null?d:(b!==t.namespaces&&(b=t.namespaces,g=t.enabled(u)),g),set:p=>{d=p}}),typeof t.init=="function"&&t.init(h),h}function n(u,l){let d=t(this.namespace+(typeof l>"u"?":":l)+u);return d.log=this.log,d}function o(u){t.save(u),t.namespaces=u,t.names=[],t.skips=[];let l,d=(typeof u=="string"?u:"").split(/[\s,]+/),b=d.length;for(l=0;l<b;l++)d[l]&&(u=d[l].replace(/\*/g,".*?"),u[0]==="-"?t.skips.push(new RegExp("^"+u.slice(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,d;for(l=0,d=t.skips.length;l<d;l++)if(t.skips[l].test(u))return!1;for(l=0,d=t.names.length;l<d;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.enable(t.load()),t}oc.exports=Ph});var sc=ir((Pe,Jn)=>{Pe.formatArgs=Mh;Pe.save=Hh;Pe.load=$h;Pe.useColors=Fh;Pe.storage=Kh();Pe.destroy=(()=>{let r=!1;return()=>{r||(r=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})();Pe.colors=["#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 Fh(){if(typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs))return!0;if(typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let r;return typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&(r=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(r[1],10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function Mh(r){if(r[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+r[0]+(this.useColors?"%c ":" ")+"+"+Jn.exports.humanize(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)}Pe.log=console.debug||console.log||(()=>{});function Hh(r){try{r?Pe.storage.setItem("debug",r):Pe.storage.removeItem("debug")}catch{}}function $h(){let r;try{r=Pe.storage.getItem("debug")}catch{}return!r&&typeof process<"u"&&"env"in process&&(r=process.env.DEBUG),r}function Kh(){try{return localStorage}catch{}}Jn.exports=ic()(Pe);var{formatters:qh}=Jn.exports;qh.j=function(r){try{return JSON.stringify(r)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}});var ku=ir(Jr=>{"use strict";var Hp="[object ArrayBuffer]",Rt=class r{static isArrayBuffer(e){return Object.prototype.toString.call(e)===Hp}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}},ta="string",$p=/^[0-9a-f]+$/i,Kp=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/,qp=/^[a-zA-Z0-9-_]+$/,Bo=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=Rt.toUint8Array(e),n="";for(let i=0;i<t.length;i++)n+=String.fromCharCode(t[i]);return decodeURIComponent(escape(n))}},Ze=class{static toString(e,t=!1){let n=Rt.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}},Ao=class r{static isHex(e){return typeof e===ta&&$p.test(e)}static isBase64(e){return typeof e===ta&&Kp.test(e)}static isBase64Url(e){return typeof e===ta&&qp.test(e)}static ToString(e,t="utf8"){let n=Rt.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 Ze.toString(n,!0);case"utf16":case"utf16be":return Ze.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 Ze.fromString(e,!0);case"utf16":case"utf16be":return Ze.fromString(e);default:throw new Error(`Unknown type of encoding '${t}'`)}}static ToBase64(e){let t=Rt.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 Bo.fromString(e);case"utf16":case"utf16be":return Ze.fromString(e);case"utf16le":case"usc2":return Ze.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 Bo.toString(e);case"utf16":case"utf16be":return Ze.toString(e);case"utf16le":case"usc2":return Ze.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=Rt.toUint8Array(e),n="";for(let o=0;o<t.length;o++)n+=String.fromCharCode(t[o]);return n}static ToHex(e){let t=Rt.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 Ze.toString(e,t)}static FromUtf16String(e,t=!1){return Ze.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,"")||""}};Ao.DEFAULT_UTF8_ENCODING="utf8";function zp(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 Gp(...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 jp(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}Jr.BufferSourceConverter=Rt;Jr.Convert=Ao;Jr.assign=zp;Jr.combine=Gp;Jr.isEqual=jp});var di=ir((s2,Ll)=>{"use strict";function Ul(r,e){for(let t in e)Object.defineProperty(r,t,{value:e[t],enumerable:!0,configurable:!0});return r}function Rg(r,e,t){if(!r||typeof r=="string")throw new TypeError("Please pass an Error to err-code");t||(t={}),typeof e=="object"&&(t=e,e=""),e&&(t.code=e);try{return Ul(r,t)}catch{t.message=r.message,t.stack=r.stack;let o=function(){};return o.prototype=Object.create(Object.getPrototypeOf(r)),Ul(new o,t)}}Ll.exports=Rg});var ya=ir((h2,ma)=>{var f2=function(){typeof ma<"u"&&(ma.exports=h);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(y){var N=y-y%1;return N==0&&(y<0||y===0&&1/y!=1/0)?-0:N},u=h.prototype,l=(h.fromDate=function(y){return new h(+y)},h.fromInt64BE=L(0,1,2,3,0,4),h.fromInt64LE=L(3,2,1,0,4,0),h.fromString=function(T){var N,V=new h,T=(T+="").replace(/^\s*[+\-]?\d+/,function(H){var H=+H,J=1970+(H-1970)%400;return V.year=H-J,J}).replace(/(?:Z|([+\-]\d{2}):?(\d{2}))$/,function(P,H,J){return H<0&&(J*=-1),N=6e4*(60*+H+ +J),""}).replace(/\.\d+$/,function(P){return V.nano=+(P+c).substr(1,9),""}).split(/\D+/);if(1<T.length?T[1]--:T[1]=0,V.time=N=Date.UTC.apply(Date,T)-(N||0),isNaN(N))throw new TypeError("Invalid Date");return p(V)},h.fromTimeT=function(y){return R(y,0)},u.year=0,u.time=0,u.nano=0,u.addNano=function(y){return this.nano+=+y||0,this},u.getNano=function(){var y=p(this);return(y.time%1e3*a+ +y.nano+1e9)%1e9},u.getTimeT=function(){var N=p(this),y=Math.floor(N.time/1e3),N=N.year;return N&&(y+=N*t*r/e),y},u.getYear=function(){return this.toDate().getUTCFullYear()+this.year},u.toDate=function(){return x(p(this).time)},u.toJSON=function(){return this.toString().replace(/0{1,6}Z$/,"Z")},u.toString=function(y){var N=this,V=N.toDate(),T={H:function(){return k(V.getUTCHours())},L:function(){return C(V.getUTCMilliseconds(),3)},M:function(){return k(V.getUTCMinutes())},N:function(){return C(N.getNano(),9)},S:function(){return k(V.getUTCSeconds())},Y:function(){var P=N.getYear();return 999999<P?"+"+P:9999<P?"+"+C(P,6):0<=P?C(P,4):-999999<=P?"-"+C(-P,6):P},a:function(){return b[V.getUTCDay()]},b:function(){return d[V.getUTCMonth()]},d:function(){return k(V.getUTCDate())},e:function(){return function(P){return(9<P?"":" ")+(0|P)}(V.getUTCDate())},m:function(){return k(V.getUTCMonth()+1)}};return function P(H){return H.replace(/%./g,function(J){var A=J[1],E=g[A],A=T[A];return E?P(E):A?A():J})}(y||l)},u.writeInt64BE=v(0,1,2,3,0,4),u.writeInt64LE=v(3,2,1,0,4,0),"%Y-%m-%dT%H:%M:%S.%NZ"),d=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],b=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],g={"%":"%",F:"%Y-%m-%d",n:`
3
- `,R:"%H:%M",T:"%H:%M:%S",t:" ",X:"%T",Z:"GMT",z:"+0000"};return h;function h(y,N,V){var T=this;if(!(T instanceof h))return new h(y,N,V);T.time=+y||0,T.nano=+N||0,T.year=+V||0,p(T)}function p(y){var N,V,T,P=y.year,H=y.time,J=y.nano,E=((J<0||a<=J)&&(J-=(V=Math.floor(J/a))*a,H+=V,V=1),P%e);return(H<-i||i<H||E)&&((N=f(H/o))&&(P+=N*e,H-=N*o),(T=x(H)).setUTCFullYear(E+T.getUTCFullYear()),T=(H=+T)+(N=f((P-=E)/e))*o,N&&-i<=T&&T<=i&&(P-=N*e,H=T),V=1),V&&(y.year=P,y.time=H,y.nano=J),y}function x(y){var N=new Date(0);return N.setTime(y),N}function R(P,T){P=+P||0;var V=f((T=(T|0)*s)/n)+f(P/n),T=T%n+P%n,P=f(T/n);return P&&(V+=P,T-=P*n),new h(1e3*T,0,V*e)}function v(y,N,V,T,P,H){return function(E,A){var B=p(this);E=E||new Array(8),S(E,A|=0);var w=Math.floor(B.time/1e3),B=B.year*(t*r/e),M=f(B/s)+f(w/s),B=B%s+w%s,w=Math.floor(B/s);return w&&(M+=w,B-=w*s),J(E,A+P,M),J(E,A+H,B),E};function J(E,A,M){E[A+y]=M>>24&255,E[A+N]=M>>16&255,E[A+V]=M>>8&255,E[A+T]=255&M}}function L(y,N,V,T,P,H){return function(E,A){S(E,A|=0);var M=J(E,A+P);return R(J(E,A+H),M)};function J(E,A){return 16777216*E[A+y]+(E[A+N]<<16|E[A+V]<<8|E[A+T])}}function S(y,N){if(y=y&&y.length,y==null)throw new TypeError("Invalid Buffer");if(y<N+8)throw new RangeError("Out of range")}function k(y){return(9<y?"":"0")+(0|y)}function C(y,N){return(c+(0|y)).substr(-N)}}()});var Qf=ir((tv,Ra)=>{"use strict";var hm=Object.prototype.hasOwnProperty,Le="~";function zn(){}Object.create&&(zn.prototype=Object.create(null),new zn().__proto__||(Le=!1));function dm(r,e,t){this.fn=r,this.context=e,this.once=t||!1}function Xf(r,e,t,n,o){if(typeof t!="function")throw new TypeError("The listener must be a function");var i=new dm(t,n||r,o),s=Le?Le+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 ki(r,e){--r._eventsCount===0?r._events=new zn:delete r._events[e]}function Ne(){this._events=new zn,this._eventsCount=0}Ne.prototype.eventNames=function(){var e=[],t,n;if(this._eventsCount===0)return e;for(n in t=this._events)hm.call(t,n)&&e.push(Le?n.slice(1):n);return Object.getOwnPropertySymbols?e.concat(Object.getOwnPropertySymbols(t)):e};Ne.prototype.listeners=function(e){var t=Le?Le+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};Ne.prototype.listenerCount=function(e){var t=Le?Le+e:e,n=this._events[t];return n?n.fn?1:n.length:0};Ne.prototype.emit=function(e,t,n,o,i,s){var a=Le?Le+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 d=c.length,b;for(l=0;l<d;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};Ne.prototype.on=function(e,t,n){return Xf(this,e,t,n,!1)};Ne.prototype.once=function(e,t,n){return Xf(this,e,t,n,!0)};Ne.prototype.removeListener=function(e,t,n,o){var i=Le?Le+e:e;if(!this._events[i])return this;if(!t)return ki(this,i),this;var s=this._events[i];if(s.fn)s.fn===t&&(!o||s.once)&&(!n||s.context===n)&&ki(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:ki(this,i)}return this};Ne.prototype.removeAllListeners=function(e){var t;return e?(t=Le?Le+e:e,this._events[t]&&ki(this,t)):(this._events=new zn,this._eventsCount=0),this};Ne.prototype.off=Ne.prototype.removeListener;Ne.prototype.addListener=Ne.prototype.on;Ne.prefixed=Le;Ne.EventEmitter=Ne;typeof Ra<"u"&&(Ra.exports=Ne)});var Dm={};ye(Dm,{delegatedHTTPRouting:()=>uh,httpGatewayRouting:()=>yh,libp2pRouting:()=>wh});var Qa=Symbol.for("@libp2p/content-routing");var xr=Symbol.for("@libp2p/peer-id");function ec(r){return r!=null&&!!r[xr]}var tc=Symbol.for("@libp2p/peer-routing");var O=class extends Error{code;props;constructor(e,t,n){super(e),this.code=t,this.name=n?.name??"CodeError",this.props=n??{}}};var Er=(r,...e)=>{try{[...e]}catch{}};var Fe=Vt(sc(),1);var Mi={};ye(Mi,{base32:()=>Qe,base32hex:()=>Xh,base32hexpad:()=>ed,base32hexpadupper:()=>td,base32hexupper:()=>Qh,base32pad:()=>Wh,base32padupper:()=>Jh,base32upper:()=>dc,base32z:()=>rd});var qm=new Uint8Array(0);function ac(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 xt(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 cc(r){return new TextEncoder().encode(r)}function uc(r){return new TextDecoder().decode(r)}function zh(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(g){if(g instanceof Uint8Array||(ArrayBuffer.isView(g)?g=new Uint8Array(g.buffer,g.byteOffset,g.byteLength):Array.isArray(g)&&(g=Uint8Array.from(g))),!(g instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(g.length===0)return"";for(var h=0,p=0,x=0,R=g.length;x!==R&&g[x]===0;)x++,h++;for(var v=(R-x)*u+1>>>0,L=new Uint8Array(v);x!==R;){for(var S=g[x],k=0,C=v-1;(S!==0||k<p)&&C!==-1;C--,k++)S+=256*L[C]>>>0,L[C]=S%a>>>0,S=S/a>>>0;if(S!==0)throw new Error("Non-zero carry");p=k,x++}for(var y=v-p;y!==v&&L[y]===0;)y++;for(var N=c.repeat(h);y<v;++y)N+=r.charAt(L[y]);return N}function d(g){if(typeof g!="string")throw new TypeError("Expected String");if(g.length===0)return new Uint8Array;var h=0;if(g[h]!==" "){for(var p=0,x=0;g[h]===c;)p++,h++;for(var R=(g.length-h)*f+1>>>0,v=new Uint8Array(R);g[h];){var L=t[g.charCodeAt(h)];if(L===255)return;for(var S=0,k=R-1;(L!==0||S<x)&&k!==-1;k--,S++)L+=a*v[k]>>>0,v[k]=L%256>>>0,L=L/256>>>0;if(L!==0)throw new Error("Non-zero carry");x=S,h++}if(g[h]!==" "){for(var C=R-x;C!==R&&v[C]===0;)C++;for(var y=new Uint8Array(p+(R-C)),N=p;C!==R;)y[N++]=v[C++];return y}}}function b(g){var h=d(g);if(h)return h;throw new Error(`Non-${e} character`)}return{encode:l,decodeUnsafe:d,decode:b}}var Gh=zh,jh=Gh,fc=jh;var Vi=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")}},Oi=class{name;prefix;baseDecode;prefixCodePoint;constructor(e,t,n){if(this.name=e,this.prefix=t,t.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),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 hc(this,e)}},Pi=class{decoders;constructor(e){this.decoders=e}or(e){return hc(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 hc(r,e){return new Pi({...r.decoders??{[r.prefix]:r},...e.decoders??{[e.prefix]:e}})}var Fi=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 Vi(e,t,n),this.decoder=new Oi(e,t,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};function Sr({name:r,prefix:e,encode:t,decode:n}){return new Fi(r,e,t,n)}function Ot({name:r,prefix:e,alphabet:t}){let{encode:n,decode:o}=fc(t,r);return Sr({prefix:e,name:r,encode:n,decode:i=>xt(o(i))})}function Yh(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 Zh(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 ae({name:r,prefix:e,bitsPerChar:t,alphabet:n}){return Sr({prefix:e,name:r,encode(o){return Zh(o,n,t)},decode(o){return Yh(o,n,t,r)}})}var Qe=ae({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),dc=ae({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Wh=ae({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Jh=ae({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Xh=ae({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Qh=ae({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),ed=ae({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),td=ae({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),rd=ae({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Hi={};ye(Hi,{base58btc:()=>le,base58flickr:()=>nd});var le=Ot({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),nd=Ot({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var $i={};ye($i,{base64:()=>fn,base64pad:()=>od,base64url:()=>id,base64urlpad:()=>sd});var fn=ae({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),od=ae({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),id=ae({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),sd=ae({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});Fe.default.formatters.b=r=>r==null?"undefined":le.baseEncode(r);Fe.default.formatters.t=r=>r==null?"undefined":Qe.baseEncode(r);Fe.default.formatters.m=r=>r==null?"undefined":fn.baseEncode(r);Fe.default.formatters.p=r=>r==null?"undefined":r.toString();Fe.default.formatters.c=r=>r==null?"undefined":r.toString();Fe.default.formatters.k=r=>r==null?"undefined":r.toString();Fe.default.formatters.a=r=>r==null?"undefined":r.toString();function ad(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 Pt(r){let e=ad(`${r}:trace`);return Fe.default.enabled(`${r}:trace`)&&Fe.default.names.map(t=>t.toString()).find(t=>t.includes(":trace"))!=null&&(e=(0,Fe.default)(`${r}:trace`)),Object.assign((0,Fe.default)(r),{error:(0,Fe.default)(`${r}:error`),trace:e})}var Ki={};ye(Ki,{base10:()=>cd});var cd=Ot({prefix:"9",name:"base10",alphabet:"0123456789"});var qi={};ye(qi,{base16:()=>ud,base16upper:()=>ld});var ud=ae({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),ld=ae({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var zi={};ye(zi,{base2:()=>fd});var fd=ae({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Gi={};ye(Gi,{base256emoji:()=>md});var pc=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}"),hd=pc.reduce((r,e,t)=>(r[t]=e,r),[]),dd=pc.reduce((r,e,t)=>(r[e.codePointAt(0)]=t,r),[]);function pd(r){return r.reduce((e,t)=>(e+=hd[t],e),"")}function gd(r){let e=[];for(let t of r){let n=dd[t.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${t}`);e.push(n)}return new Uint8Array(e)}var md=Sr({prefix:"\u{1F680}",name:"base256emoji",encode:pd,decode:gd});var ji={};ye(ji,{base36:()=>Xn,base36upper:()=>yd});var Xn=Ot({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),yd=Ot({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Yi={};ye(Yi,{base8:()=>wd});var wd=ae({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Zi={};ye(Zi,{identity:()=>bd});var bd=Sr({prefix:"\0",name:"identity",encode:r=>uc(r),decode:r=>cc(r)});var ly=new TextEncoder,fy=new TextDecoder;var Ji={};ye(Ji,{identity:()=>Me});var vd=yc,gc=128,Bd=127,Ad=~Bd,Sd=Math.pow(2,31);function yc(r,e,t){e=e||[],t=t||0;for(var n=t;r>=Sd;)e[t++]=r&255|gc,r/=128;for(;r&Ad;)e[t++]=r&255|gc,r>>>=7;return e[t]=r|0,yc.bytes=t-n+1,e}var Id=Wi,Rd=128,mc=127;function Wi(r,n){var t=0,n=n||0,o=0,i=n,s,a=r.length;do{if(i>=a)throw Wi.bytes=0,new RangeError("Could not decode varint");s=r[i++],t+=o<28?(s&mc)<<o:(s&mc)*Math.pow(2,o),o+=7}while(s>=Rd);return Wi.bytes=i-n,t}var kd=Math.pow(2,7),Td=Math.pow(2,14),Nd=Math.pow(2,21),Cd=Math.pow(2,28),_d=Math.pow(2,35),Ud=Math.pow(2,42),Ld=Math.pow(2,49),Dd=Math.pow(2,56),Vd=Math.pow(2,63),Od=function(r){return r<kd?1:r<Td?2:r<Nd?3:r<Cd?4:r<_d?5:r<Ud?6:r<Ld?7:r<Dd?8:r<Vd?9:10},Pd={encode:vd,decode:Id,encodingLength:Od},Fd=Pd,hn=Fd;function dn(r,e=0){return[hn.decode(r,e),hn.decode.bytes]}function Ir(r,e,t=0){return hn.encode(r,e,t),e}function Rr(r){return hn.encodingLength(r)}function ft(r,e){let t=e.byteLength,n=Rr(r),o=n+Rr(t),i=new Uint8Array(o+t);return Ir(r,i,0),Ir(t,i,n),i.set(e,o),new kr(r,t,e,i)}function Ft(r){let e=xt(r),[t,n]=dn(e),[o,i]=dn(e.subarray(n)),s=e.subarray(n+i);if(s.byteLength!==o)throw new Error("Incorrect length");return new kr(t,o,s,e)}function wc(r,e){if(r===e)return!0;{let t=e;return r.code===t.code&&r.size===t.size&&t.bytes instanceof Uint8Array&&ac(r.bytes,t.bytes)}}var kr=class{code;size;digest;bytes;constructor(e,t,n,o){this.code=e,this.size=t,this.digest=n,this.bytes=o}};var bc=0,Md="identity",xc=xt;function Hd(r){return ft(bc,xc(r))}var Me={code:bc,name:Md,encode:xc,digest:Hd};var es={};ye(es,{sha256:()=>Be,sha512:()=>$d});function Qi({name:r,code:e,encode:t}){return new Xi(r,e,t)}var Xi=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?ft(this.code,t):t.then(n=>ft(this.code,n))}else throw Error("Unknown type, must be binary type")}};function vc(r){return async e=>new Uint8Array(await crypto.subtle.digest(r,e))}var Be=Qi({name:"sha2-256",code:18,encode:vc("SHA-256")}),$d=Qi({name:"sha2-512",code:19,encode:vc("SHA-512")});function Bc(r,e){let{bytes:t,version:n}=r;switch(n){case 0:return qd(t,ts(r),e??le.encoder);default:return zd(t,ts(r),e??Qe.encoder)}}var Ac=new WeakMap;function ts(r){let e=Ac.get(r);if(e==null){let t=new Map;return Ac.set(r,t),t}return e}var we=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!==pn)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==Gd)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=ft(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&&wc(e.multihash,n.multihash)}toString(e){return Bc(this,e)}toJSON(){return{"/":Bc(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??Sc(n,o,i.bytes))}else if(t[jd]===!0){let{version:n,multihash:o,code:i}=t,s=Ft(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!==pn)throw new Error(`Version 0 CID must use dag-pb (code: ${pn}) block encoding`);return new r(e,t,n,n.bytes)}case 1:{let o=Sc(e,t,n.bytes);return new r(e,t,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return r.create(0,pn,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=xt(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 kr(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,d]=dn(e.subarray(t));return t+=d,l},o=n(),i=pn;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]=Kd(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 ts(i).set(n,e),i}};function Kd(r,e){switch(r[0]){case"Q":{let t=e??le;return[le.prefix,t.decode(`${le.prefix}${r}`)]}case le.prefix:{let t=e??le;return[le.prefix,t.decode(r)]}case Qe.prefix:{let t=e??Qe;return[Qe.prefix,t.decode(r)]}default:{if(e==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[r[0],e.decode(r)]}}}function qd(r,e,t){let{prefix:n}=t;if(n!==le.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 zd(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 pn=112,Gd=18;function Sc(r,e,t){let n=Rr(r),o=n+Rr(e),i=new Uint8Array(o+t.byteLength);return Ir(r,i,0),Ir(e,i,n),i.set(t,o),i}var jd=Symbol.for("@ipld/js-cid/CID");var Ht={...Zi,...zi,...Yi,...Ki,...qi,...Mi,...ji,...Hi,...$i,...Gi},_y={...es,...Ji};function ce(r,e){if(r===e)return!0;if(r.byteLength!==e.byteLength)return!1;for(let t=0;t<r.byteLength;t++)if(r[t]!==e[t])return!1;return!0}function et(r=0){return new Uint8Array(r)}function Rc(r,e,t,n){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:n}}}var Ic=Rc("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),rs=Rc("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=et(r.length);for(let t=0;t<r.length;t++)e[t]=r.charCodeAt(t);return e}),Yd={utf8:Ic,"utf-8":Ic,hex:Ht.base16,latin1:rs,ascii:rs,binary:rs,...Ht},eo=Yd;function z(r,e="utf8"){let t=eo[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return t.decoder.decode(`${t.prefix}${r}`)}function G(r,e="utf8"){let t=eo[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return t.encoder.encode(r).substring(1)}var Tc=Symbol.for("nodejs.util.inspect.custom"),kc=Object.values(Ht).map(r=>r.decoder).reduce((r,e)=>r.or(e),Ht.identity.decoder),Nc=114,is=36,ss=37,gn=class{type;multihash;privateKey;publicKey;string;constructor(e){this.type=e.type,this.multihash=e.multihash,this.privateKey=e.privateKey,Object.defineProperty(this,"string",{enumerable:!1,writable:!0})}get[Symbol.toStringTag](){return`PeerId(${this.toString()})`}[xr]=!0;toString(){return this.string==null&&(this.string=le.encode(this.multihash.bytes).slice(1)),this.string}toCID(){return we.createV1(Nc,this.multihash)}toBytes(){return this.multihash.bytes}toJSON(){return this.toString()}equals(e){if(e==null)return!1;if(e instanceof Uint8Array)return ce(this.multihash.bytes,e);if(typeof e=="string")return as(e).equals(this);if(e?.multihash?.bytes!=null)return ce(this.multihash.bytes,e.multihash.bytes);throw new Error("not valid Id")}[Tc](){return`PeerId(${this.toString()})`}},Tr=class extends gn{type="RSA";publicKey;constructor(e){super({...e,type:"RSA"}),this.publicKey=e.publicKey}},Nr=class extends gn{type="Ed25519";publicKey;constructor(e){super({...e,type:"Ed25519"}),this.publicKey=e.multihash.digest}},Cr=class extends gn{type="secp256k1";publicKey;constructor(e){super({...e,type:"secp256k1"}),this.publicKey=e.multihash.digest}},ns=2336,os=class{type="url";multihash;privateKey;publicKey;url;constructor(e){this.url=e.toString(),this.multihash=Me.digest(z(this.url))}[Tc](){return`PeerId(${this.url})`}[xr]=!0;toString(){return this.toCID().toString()}toCID(){return we.createV1(ns,this.multihash)}toBytes(){return this.toCID().bytes}equals(e){return e==null?!1:(e instanceof Uint8Array&&(e=G(e)),e.toString()===this.toString())}};function as(r,e){if(e=e??kc,r.charAt(0)==="1"||r.charAt(0)==="Q"){let t=Ft(le.decode(`z${r}`));return r.startsWith("12D")?new Nr({multihash:t}):r.startsWith("16U")?new Cr({multihash:t}):new Tr({multihash:t})}return mn(kc.decode(r))}function mn(r){try{let e=Ft(r);if(e.code===Me.code){if(e.digest.length===is)return new Nr({multihash:e});if(e.digest.length===ss)return new Cr({multihash:e})}if(e.code===Be.code)return new Tr({multihash:e})}catch{return Zd(we.decode(r))}throw new Error("Supplied PeerID CID is invalid")}function Zd(r){if(r==null||r.multihash==null||r.version==null||r.version===1&&r.code!==Nc&&r.code!==ns)throw new Error("Supplied PeerID CID is invalid");if(r.code===ns){let t=G(r.multihash.digest);return new os(new URL(t))}let e=r.multihash;if(e.code===Be.code)return new Tr({multihash:r.multihash});if(e.code===Me.code){if(e.digest.length===is)return new Nr({multihash:r.multihash});if(e.digest.length===ss)return new Cr({multihash:r.multihash})}throw new Error("Supplied PeerID CID is invalid")}async function Cc(r,e){return r.length===is?new Nr({multihash:ft(Me.code,r),privateKey:e}):r.length===ss?new Cr({multihash:ft(Me.code,r),privateKey:e}):new Tr({multihash:await Be.digest(r),publicKey:r,privateKey:e})}var Wd=Math.pow(2,7),Jd=Math.pow(2,14),Xd=Math.pow(2,21),cs=Math.pow(2,28),us=Math.pow(2,35),ls=Math.pow(2,42),fs=Math.pow(2,49),te=128,Re=127;function De(r){if(r<Wd)return 1;if(r<Jd)return 2;if(r<Xd)return 3;if(r<cs)return 4;if(r<us)return 5;if(r<ls)return 6;if(r<fs)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function hs(r,e,t=0){switch(De(r)){case 8:e[t++]=r&255|te,r/=128;case 7:e[t++]=r&255|te,r/=128;case 6:e[t++]=r&255|te,r/=128;case 5:e[t++]=r&255|te,r/=128;case 4:e[t++]=r&255|te,r>>>=7;case 3:e[t++]=r&255|te,r>>>=7;case 2:e[t++]=r&255|te,r>>>=7;case 1:{e[t++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return e}function Qd(r,e,t=0){switch(De(r)){case 8:e.set(t++,r&255|te),r/=128;case 7:e.set(t++,r&255|te),r/=128;case 6:e.set(t++,r&255|te),r/=128;case 5:e.set(t++,r&255|te),r/=128;case 4:e.set(t++,r&255|te),r>>>=7;case 3:e.set(t++,r&255|te),r>>>=7;case 2:e.set(t++,r&255|te),r>>>=7;case 1:{e.set(t++,r&255),r>>>=7;break}default:throw new Error("unreachable")}return e}function ds(r,e){let t=r[e],n=0;if(n+=t&Re,t<te||(t=r[e+1],n+=(t&Re)<<7,t<te)||(t=r[e+2],n+=(t&Re)<<14,t<te)||(t=r[e+3],n+=(t&Re)<<21,t<te)||(t=r[e+4],n+=(t&Re)*cs,t<te)||(t=r[e+5],n+=(t&Re)*us,t<te)||(t=r[e+6],n+=(t&Re)*ls,t<te)||(t=r[e+7],n+=(t&Re)*fs,t<te))return n;throw new RangeError("Could not decode varint")}function e0(r,e){let t=r.get(e),n=0;if(n+=t&Re,t<te||(t=r.get(e+1),n+=(t&Re)<<7,t<te)||(t=r.get(e+2),n+=(t&Re)<<14,t<te)||(t=r.get(e+3),n+=(t&Re)<<21,t<te)||(t=r.get(e+4),n+=(t&Re)*cs,t<te)||(t=r.get(e+5),n+=(t&Re)*us,t<te)||(t=r.get(e+6),n+=(t&Re)*ls,t<te)||(t=r.get(e+7),n+=(t&Re)*fs,t<te))return n;throw new RangeError("Could not decode varint")}function _r(r,e,t=0){return e==null&&(e=et(De(r))),e instanceof Uint8Array?hs(r,e,t):Qd(r,e,t)}function ar(r,e=0){return r instanceof Uint8Array?ds(r,e):e0(r,e)}function Ce(r,e){e==null&&(e=r.reduce((o,i)=>o+i.length,0));let t=et(e),n=0;for(let o of r)t.set(o,n),n+=o.length;return t}var to=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 d=Number.parseInt(l,e);if(!Number.isNaN(d))return d});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 Uc=45,t0=15,Ur=new to;function ps(r){if(!(r.length>t0))return Ur.new(r).parseWith(()=>Ur.readIPv4Addr())}function gs(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>Uc))return Ur.new(r).parseWith(()=>Ur.readIPv6Addr())}function ro(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>Uc))return Ur.new(r).parseWith(()=>Ur.readIPAddr())}var pw=parseInt("0xFFFF",16),gw=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);function Vc(r){return!!ps(r)}function Oc(r){return!!gs(r)}function no(r){return!!ro(r)}var Pc=Vc,s0=Oc,ms=function(r){let e=0;if(r=r.toString().trim(),Pc(r)){let t=new Uint8Array(e+4);return r.split(/\./g).forEach(n=>{t[e++]=parseInt(n,10)&255}),t}if(s0(r)){let t=r.split(":",8),n;for(n=0;n<t.length;n++){let i=Pc(t[n]),s;i&&(s=ms(t[n]),t[n]=G(s.slice(0,2),"base16")),s!=null&&++n<8&&t.splice(n,0,G(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")},Fc=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 Lr={},ys={},c0=[[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"]];c0.forEach(r=>{let e=u0(...r);ys[e.code]=e,Lr[e.name]=e});function u0(r,e,t,n,o){return{code:r,size:e,name:t,resolvable:!!n,path:!!o}}function ne(r){if(typeof r=="number"){if(ys[r]!=null)return ys[r];throw new Error(`no protocol with code: ${r}`)}else if(typeof r=="string"){if(Lr[r]!=null)return Lr[r];throw new Error(`no protocol with name: ${r}`)}throw new Error(`invalid protocol id type: ${typeof r}`)}var Xw=ne("ip4"),Qw=ne("ip6"),eb=ne("ipcidr");function Es(r,e){switch(ne(r).code){case 4:case 41:return f0(e);case 42:return xs(e);case 6:case 273:case 33:case 132:return $c(e).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return xs(e);case 421:return g0(e);case 444:return Hc(e);case 445:return Hc(e);case 466:return p0(e);case 481:return globalThis.encodeURIComponent(xs(e));default:return G(e,"base16")}}function vs(r,e){switch(ne(r).code){case 4:return Mc(e);case 41:return Mc(e);case 42:return bs(e);case 6:case 273:case 33:case 132:return Bs(parseInt(e,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return bs(e);case 421:return h0(e);case 444:return m0(e);case 445:return y0(e);case 466:return d0(e);case 481:return bs(globalThis.decodeURIComponent(e));default:return z(e,"base16")}}var ws=Object.values(Ht).map(r=>r.decoder),l0=function(){let r=ws[0].or(ws[1]);return ws.slice(2).forEach(e=>r=r.or(e)),r}();function Mc(r){if(!no(r))throw new Error("invalid ip address");return ms(r)}function f0(r){let e=Fc(r,0,r.length);if(e==null)throw new Error("ipBuff is required");if(!no(e))throw new Error("invalid ip address");return e}function Bs(r){let e=new ArrayBuffer(2);return new DataView(e).setUint16(0,r),new Uint8Array(e)}function $c(r){return new DataView(r.buffer).getUint16(r.byteOffset)}function bs(r){let e=z(r),t=Uint8Array.from(_r(e.length));return Ce([t,e],t.length+e.length)}function xs(r){let e=ar(r);if(r=r.slice(De(e)),r.length!==e)throw new Error("inconsistent lengths");return G(r)}function h0(r){let e;r[0]==="Q"||r[0]==="1"?e=Ft(le.decode(`z${r}`)).bytes:e=we.parse(r).multihash.bytes;let t=Uint8Array.from(_r(e.length));return Ce([t,e],t.length+e.length)}function d0(r){let e=l0.decode(r),t=Uint8Array.from(_r(e.length));return Ce([t,e],t.length+e.length)}function p0(r){let e=ar(r),t=r.slice(De(e));if(t.length!==e)throw new Error("inconsistent lengths");return"u"+G(t,"base64url")}function g0(r){let e=ar(r),t=r.slice(De(e));if(t.length!==e)throw new Error("inconsistent lengths");return G(t,"base58btc")}function m0(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=Qe.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=Bs(n);return Ce([t,o],t.length+o.length)}function y0(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=Qe.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=Bs(n);return Ce([t,o],t.length+o.length)}function Hc(r){let e=r.slice(0,r.length-2),t=r.slice(r.length-2),n=G(e,"base32"),o=$c(t);return`${n}:${o}`}function Kc(r){r=As(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=ne(s);if(a.size===0){e.push([a.code]),t.push([a.code]);continue}if(i++,i>=o.length)throw zc("invalid address: "+r);if(a.path===!0){n=As(o.slice(i).join("/")),e.push([a.code,vs(a.code,n)]),t.push([a.code,n]);break}let c=vs(a.code,o[i]);e.push([a.code,c]),t.push([a.code,Es(a.code,c)])}return{string:qc(t),bytes:Is(e),tuples:e,stringTuples:t,path:n}}function Ss(r){let e=[],t=[],n=null,o=0;for(;o<r.length;){let i=ar(r,o),s=De(i),a=ne(i),c=w0(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 zc("Invalid address Uint8Array: "+G(r,"base16"));e.push([i,f]);let u=Es(i,f);if(t.push([i,u]),a.path===!0){n=u;break}}return{bytes:Uint8Array.from(r),string:qc(t),tuples:e,stringTuples:t,path:n}}function qc(r){let e=[];return r.map(t=>{let n=ne(t[0]);return e.push(n.name),t.length>1&&t[1]!=null&&e.push(t[1]),null}),As(e.join("/"))}function Is(r){return Ce(r.map(e=>{let t=ne(e[0]),n=Uint8Array.from(_r(t.code));return e.length>1&&e[1]!=null&&(n=Ce([n,e[1]])),n}))}function w0(r,e){if(r.size>0)return r.size/8;if(r.size===0)return 0;{let t=ar(e instanceof Uint8Array?e:Uint8Array.from(e));return t+De(t)}}function As(r){return"/"+r.trim().split("/").filter(e=>e).join("/")}function zc(r){return new Error("Error parsing address: "+r)}var b0=Symbol.for("nodejs.util.inspect.custom"),Rs=Symbol.for("@multiformats/js-multiaddr/multiaddr"),x0=[ne("dns").code,ne("dns4").code,ne("dns6").code,ne("dnsaddr").code],oo=class r{bytes;#e;#r;#i;#a;[Rs]=!0;constructor(e){e==null&&(e="");let t;if(e instanceof Uint8Array)t=Ss(e);else if(typeof e=="string"){if(e.length>0&&e.charAt(0)!=="/")throw new Error(`multiaddr "${e}" must start with a "/"`);t=Kc(e)}else if(jc(e))t=Ss(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.#i=t.stringTuples,this.#a=t.path}toString(){return this.#e}toJSON(){return this.toString()}toOptions(){let e,t,n,o,i="",s=ne("tcp"),a=ne("udp"),c=ne("ip4"),f=ne("ip6"),u=ne("dns6"),l=ne("ip6zone");for(let[b,g]of this.stringTuples())b===l.code&&(i=`%${g??""}`),x0.includes(b)&&(t=s.name,o=443,n=`${g??""}${i}`,e=b===u.code?6:4),(b===s.code||b===a.code)&&(t=ne(b).name,o=parseInt(g??"")),(b===c.code||b===f.code)&&(t=ne(b).name,n=`${g??""}${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({},ne(e)))}protoCodes(){return this.#r.map(([e])=>e)}protoNames(){return this.#r.map(([e])=>ne(e).name)}tuples(){return this.#r}stringTuples(){return this.#i}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(Is(t.slice(0,n)));return this}getPeerId(){try{let e=[];this.stringTuples().forEach(([n,o])=>{n===Lr.p2p.code&&e.push([n,o]),n===Lr["p2p-circuit"].code&&(e=[])});let t=e.pop();if(t?.[1]!=null){let n=t[1];return n[0]==="Q"||n[0]==="1"?G(le.decode(`z${n}`),"base58btc"):G(we.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){return this.#a}equals(e){return ce(this.bytes,e.bytes)}async resolve(e){let t=this.protos().find(i=>i.resolvable);if(t==null)return[this];let n=Gc.get(t.name);if(n==null)throw new O(`no available resolver for ${t.name}`,"ERR_NO_AVAILABLE_RESOLVER");return(await n(this,e)).map(i=>cr(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)}[b0](){return`Multiaddr(${this.#e})`}};var Gc=new Map;function jc(r){return!!r?.[Rs]}function cr(r){return new oo(r)}function yn(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*io(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 Qs={};ye(Qs,{Ed25519PrivateKey:()=>pr,Ed25519PublicKey:()=>An,generateKeyPair:()=>Pp,generateKeyPairFromSeed:()=>Ru,unmarshalEd25519PrivateKey:()=>Vp,unmarshalEd25519PublicKey:()=>Op});function Ye(r){return r==null?!1:typeof r.then=="function"&&typeof r.catch=="function"&&typeof r.finally=="function"}function Dr(r){if(!Number.isSafeInteger(r)||r<0)throw new Error(`positive integer expected, not ${r}`)}function E0(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}function Vr(r,...e){if(!E0(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 so(r){if(typeof r!="function"||typeof r.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");Dr(r.outputLen),Dr(r.blockLen)}function Or(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 Yc(r,e){Vr(r);let t=e.outputLen;if(r.length<t)throw new Error(`digestInto() expects output buffer of length at least ${t}`)}var ao=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;var Fr=r=>new DataView(r.buffer,r.byteOffset,r.byteLength),tt=(r,e)=>r<<32-e|r>>>e;var Lb=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;var v0=async()=>{};async function Zc(r,e,t){let n=Date.now();for(let o=0;o<r;o++){t(o);let i=Date.now()-n;i>=0&&i<e||(await v0(),n+=i)}}function Wc(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}function $t(r){return typeof r=="string"&&(r=Wc(r)),Vr(r),r}function ks(...r){let e=0;for(let n=0;n<r.length;n++){let o=r[n];Vr(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 Pr=class{clone(){return this._cloneInto()}},B0={}.toString;function Jc(r,e){if(e!==void 0&&B0.call(e)!=="[object Object]")throw new Error("Options should be object or undefined");return Object.assign(r,e)}function co(r){let e=n=>r().update($t(n)).digest(),t=r();return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=()=>r(),e}function Mr(r=32){if(ao&&typeof ao.getRandomValues=="function")return ao.getRandomValues(new Uint8Array(r));throw new Error("crypto.getRandomValues must be defined")}function A0(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 Xc=(r,e,t)=>r&e^~r&t,Qc=(r,e,t)=>r&e^r&t^e&t,Hr=class extends Pr{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=Fr(this.buffer)}update(e){Or(this);let{view:t,buffer:n,blockLen:o}=this;e=$t(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=Fr(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){Or(this),Yc(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;A0(n,o-8,BigInt(this.length*8),i),this.process(n,0);let a=Fr(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 uo=BigInt(4294967295),Ts=BigInt(32);function eu(r,e=!1){return e?{h:Number(r&uo),l:Number(r>>Ts&uo)}:{h:Number(r>>Ts&uo)|0,l:Number(r&uo)|0}}function S0(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}=eu(r[o],e);[t[o],n[o]]=[i,s]}return[t,n]}var I0=(r,e)=>BigInt(r>>>0)<<Ts|BigInt(e>>>0),R0=(r,e,t)=>r>>>t,k0=(r,e,t)=>r<<32-t|e>>>t,T0=(r,e,t)=>r>>>t|e<<32-t,N0=(r,e,t)=>r<<32-t|e>>>t,C0=(r,e,t)=>r<<64-t|e>>>t-32,_0=(r,e,t)=>r>>>t-32|e<<64-t,U0=(r,e)=>e,L0=(r,e)=>r,D0=(r,e,t)=>r<<t|e>>>32-t,V0=(r,e,t)=>e<<t|r>>>32-t,O0=(r,e,t)=>e<<t-32|r>>>64-t,P0=(r,e,t)=>r<<t-32|e>>>64-t;function F0(r,e,t,n){let o=(e>>>0)+(n>>>0);return{h:r+t+(o/2**32|0)|0,l:o|0}}var M0=(r,e,t)=>(r>>>0)+(e>>>0)+(t>>>0),H0=(r,e,t,n)=>e+t+n+(r/2**32|0)|0,$0=(r,e,t,n)=>(r>>>0)+(e>>>0)+(t>>>0)+(n>>>0),K0=(r,e,t,n,o)=>e+t+n+o+(r/2**32|0)|0,q0=(r,e,t,n,o)=>(r>>>0)+(e>>>0)+(t>>>0)+(n>>>0)+(o>>>0),z0=(r,e,t,n,o,i)=>e+t+n+o+i+(r/2**32|0)|0;var G0={fromBig:eu,split:S0,toBig:I0,shrSH:R0,shrSL:k0,rotrSH:T0,rotrSL:N0,rotrBH:C0,rotrBL:_0,rotr32H:U0,rotr32L:L0,rotlSH:D0,rotlSL:V0,rotlBH:O0,rotlBL:P0,add:F0,add3L:M0,add3H:H0,add4L:$0,add4H:K0,add5H:z0,add5L:q0},q=G0;var[j0,Y0]=q.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))),Kt=new Uint32Array(80),qt=new Uint32Array(80),Ns=class extends Hr{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:d,Gh:b,Gl:g,Hh:h,Hl:p}=this;return[e,t,n,o,i,s,a,c,f,u,l,d,b,g,h,p]}set(e,t,n,o,i,s,a,c,f,u,l,d,b,g,h,p){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=d|0,this.Gh=b|0,this.Gl=g|0,this.Hh=h|0,this.Hl=p|0}process(e,t){for(let v=0;v<16;v++,t+=4)Kt[v]=e.getUint32(t),qt[v]=e.getUint32(t+=4);for(let v=16;v<80;v++){let L=Kt[v-15]|0,S=qt[v-15]|0,k=q.rotrSH(L,S,1)^q.rotrSH(L,S,8)^q.shrSH(L,S,7),C=q.rotrSL(L,S,1)^q.rotrSL(L,S,8)^q.shrSL(L,S,7),y=Kt[v-2]|0,N=qt[v-2]|0,V=q.rotrSH(y,N,19)^q.rotrBH(y,N,61)^q.shrSH(y,N,6),T=q.rotrSL(y,N,19)^q.rotrBL(y,N,61)^q.shrSL(y,N,6),P=q.add4L(C,T,qt[v-7],qt[v-16]),H=q.add4H(P,k,V,Kt[v-7],Kt[v-16]);Kt[v]=H|0,qt[v]=P|0}let{Ah:n,Al:o,Bh:i,Bl:s,Ch:a,Cl:c,Dh:f,Dl:u,Eh:l,El:d,Fh:b,Fl:g,Gh:h,Gl:p,Hh:x,Hl:R}=this;for(let v=0;v<80;v++){let L=q.rotrSH(l,d,14)^q.rotrSH(l,d,18)^q.rotrBH(l,d,41),S=q.rotrSL(l,d,14)^q.rotrSL(l,d,18)^q.rotrBL(l,d,41),k=l&b^~l&h,C=d&g^~d&p,y=q.add5L(R,S,C,Y0[v],qt[v]),N=q.add5H(y,x,L,k,j0[v],Kt[v]),V=y|0,T=q.rotrSH(n,o,28)^q.rotrBH(n,o,34)^q.rotrBH(n,o,39),P=q.rotrSL(n,o,28)^q.rotrBL(n,o,34)^q.rotrBL(n,o,39),H=n&i^n&a^i&a,J=o&s^o&c^s&c;x=h|0,R=p|0,h=b|0,p=g|0,b=l|0,g=d|0,{h:l,l:d}=q.add(f|0,u|0,N|0,V|0),f=a|0,u=c|0,a=i|0,c=s|0,i=n|0,s=o|0;let E=q.add3L(V,P,J);n=q.add3H(E,N,T,H),o=E|0}({h:n,l:o}=q.add(this.Ah|0,this.Al|0,n|0,o|0)),{h:i,l:s}=q.add(this.Bh|0,this.Bl|0,i|0,s|0),{h:a,l:c}=q.add(this.Ch|0,this.Cl|0,a|0,c|0),{h:f,l:u}=q.add(this.Dh|0,this.Dl|0,f|0,u|0),{h:l,l:d}=q.add(this.Eh|0,this.El|0,l|0,d|0),{h:b,l:g}=q.add(this.Fh|0,this.Fl|0,b|0,g|0),{h,l:p}=q.add(this.Gh|0,this.Gl|0,h|0,p|0),{h:x,l:R}=q.add(this.Hh|0,this.Hl|0,x|0,R|0),this.set(n,o,i,s,a,c,f,u,l,d,b,g,h,p,x,R)}roundClean(){Kt.fill(0),qt.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 wn=co(()=>new Ns);var fo={};ye(fo,{abytes:()=>$r,bitGet:()=>tp,bitLen:()=>ep,bitMask:()=>bn,bitSet:()=>rp,bytesToHex:()=>vt,bytesToNumberBE:()=>Bt,bytesToNumberLE:()=>Gt,concatBytes:()=>At,createHmacDrbg:()=>Us,ensureBytes:()=>ue,equalBytes:()=>X0,hexToBytes:()=>ur,hexToNumber:()=>_s,isBytes:()=>zt,numberToBytesBE:()=>jt,numberToBytesLE:()=>lr,numberToHexUnpadded:()=>ou,numberToVarBytesBE:()=>J0,utf8ToBytes:()=>Q0,validateObject:()=>ht});var nu=BigInt(0),lo=BigInt(1),Z0=BigInt(2);function zt(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}function $r(r){if(!zt(r))throw new Error("Uint8Array expected")}var W0=Array.from({length:256},(r,e)=>e.toString(16).padStart(2,"0"));function vt(r){$r(r);let e="";for(let t=0;t<r.length;t++)e+=W0[r[t]];return e}function ou(r){let e=r.toString(16);return e.length&1?`0${e}`:e}function _s(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return BigInt(r===""?"0":`0x${r}`)}var Et={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function tu(r){if(r>=Et._0&&r<=Et._9)return r-Et._0;if(r>=Et._A&&r<=Et._F)return r-(Et._A-10);if(r>=Et._a&&r<=Et._f)return r-(Et._a-10)}function ur(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=tu(r.charCodeAt(i)),a=tu(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 Bt(r){return _s(vt(r))}function Gt(r){return $r(r),_s(vt(Uint8Array.from(r).reverse()))}function jt(r,e){return ur(r.toString(16).padStart(e*2,"0"))}function lr(r,e){return jt(r,e).reverse()}function J0(r){return ur(ou(r))}function ue(r,e,t){let n;if(typeof e=="string")try{n=ur(e)}catch(i){throw new Error(`${r} must be valid hex string, got "${e}". Cause: ${i}`)}else if(zt(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 At(...r){let e=0;for(let n=0;n<r.length;n++){let o=r[n];$r(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 X0(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 Q0(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}function ep(r){let e;for(e=0;r>nu;r>>=lo,e+=1);return e}function tp(r,e){return r>>BigInt(e)&lo}function rp(r,e,t){return r|(t?lo:nu)<<BigInt(e)}var bn=r=>(Z0<<BigInt(r-1))-lo,Cs=r=>new Uint8Array(r),ru=r=>Uint8Array.from(r);function Us(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=Cs(r),o=Cs(r),i=0,s=()=>{n.fill(1),o.fill(0),i=0},a=(...l)=>t(o,n,...l),c=(l=Cs())=>{o=a(ru([0]),l),n=a(),l.length!==0&&(o=a(ru([1]),l),n=a())},f=()=>{if(i++>=1e3)throw new Error("drbg: tried 1000 values");let l=0,d=[];for(;l<e;){n=a();let b=n.slice();d.push(b),l+=n.length}return At(...d)};return(l,d)=>{s(),c(l);let b;for(;!(b=d(f()));)c();return s(),b}}var np={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"||zt(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 ht(r,e,t={}){let n=(o,i,s)=>{let a=np[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 me=BigInt(0),oe=BigInt(1),fr=BigInt(2),op=BigInt(3),Ls=BigInt(4),iu=BigInt(5),su=BigInt(8),ip=BigInt(9),sp=BigInt(16);function re(r,e){let t=r%e;return t>=me?t:e+t}function ap(r,e,t){if(t<=me||e<me)throw new Error("Expected power/modulo > 0");if(t===oe)return me;let n=oe;for(;e>me;)e&oe&&(n=n*r%t),r=r*r%t,e>>=oe;return n}function ie(r,e,t){let n=r;for(;e-- >me;)n*=n,n%=t;return n}function ho(r,e){if(r===me||e<=me)throw new Error(`invert: expected positive integers, got n=${r} mod=${e}`);let t=re(r,e),n=e,o=me,i=oe,s=oe,a=me;for(;t!==me;){let f=n/t,u=n%t,l=o-s*f,d=i-a*f;n=t,t=u,o=s,i=a,s=l,a=d}if(n!==oe)throw new Error("invert: does not exist");return re(o,e)}function cp(r){let e=(r-oe)/fr,t,n,o;for(t=r-oe,n=0;t%fr===me;t/=fr,n++);for(o=fr;o<r&&ap(o,e,r)!==r-oe;o++);if(n===1){let s=(r+oe)/Ls;return function(c,f){let u=c.pow(f,s);if(!c.eql(c.sqr(u),f))throw new Error("Cannot find square root");return u}}let i=(t+oe)/fr;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),d=a.pow(c,t);for(;!a.eql(d,a.ONE);){if(a.eql(d,a.ZERO))return a.ZERO;let b=1;for(let h=a.sqr(d);b<f&&!a.eql(h,a.ONE);b++)h=a.sqr(h);let g=a.pow(u,oe<<BigInt(f-b-1));u=a.sqr(g),l=a.mul(l,g),d=a.mul(d,u),f=b}return l}}function up(r){if(r%Ls===op){let e=(r+oe)/Ls;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%su===iu){let e=(r-iu)/su;return function(n,o){let i=n.mul(o,fr),s=n.pow(i,e),a=n.mul(o,s),c=n.mul(n.mul(a,fr),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%sp,cp(r)}var au=(r,e)=>(re(r,e)&oe)===oe,lp=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Ds(r){let e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},t=lp.reduce((n,o)=>(n[o]="function",n),e);return ht(r,t)}function fp(r,e,t){if(t<me)throw new Error("Expected power > 0");if(t===me)return r.ONE;if(t===oe)return e;let n=r.ONE,o=e;for(;t>me;)t&oe&&(n=r.mul(n,o)),o=r.sqr(o),t>>=oe;return n}function hp(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 Vs(r,e){let t=e!==void 0?e:r.toString(2).length,n=Math.ceil(t/8);return{nBitLength:t,nByteLength:n}}function po(r,e,t=!1,n={}){if(r<=me)throw new Error(`Expected Field ORDER > 0, got ${r}`);let{nBitLength:o,nByteLength:i}=Vs(r,e);if(i>2048)throw new Error("Field lengths over 2048 bytes are not supported");let s=up(r),a=Object.freeze({ORDER:r,BITS:o,BYTES:i,MASK:bn(o),ZERO:me,ONE:oe,create:c=>re(c,r),isValid:c=>{if(typeof c!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof c}`);return me<=c&&c<r},is0:c=>c===me,isOdd:c=>(c&oe)===oe,neg:c=>re(-c,r),eql:(c,f)=>c===f,sqr:c=>re(c*c,r),add:(c,f)=>re(c+f,r),sub:(c,f)=>re(c-f,r),mul:(c,f)=>re(c*f,r),pow:(c,f)=>fp(a,c,f),div:(c,f)=>re(c*ho(f,r),r),sqrN:c=>c*c,addN:(c,f)=>c+f,subN:(c,f)=>c-f,mulN:(c,f)=>c*f,inv:c=>ho(c,r),sqrt:n.sqrt||(c=>s(a,c)),invertBatch:c=>hp(a,c),cmov:(c,f,u)=>u?f:c,toBytes:c=>t?lr(c,i):jt(c,i),fromBytes:c=>{if(c.length!==i)throw new Error(`Fp.fromBytes: expected ${i}, got ${c.length}`);return t?Gt(c):Bt(c)}});return Object.freeze(a)}function cu(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 Os(r){let e=cu(r);return e+Math.ceil(e/2)}function uu(r,e,t=!1){let n=r.length,o=cu(e),i=Os(e);if(n<16||n<i||n>1024)throw new Error(`expected ${i}-1024 bytes of input, got ${n}`);let s=t?Bt(r):Gt(r),a=re(s,e-oe)+oe;return t?lr(a,o):jt(a,o)}var pp=BigInt(0),Ps=BigInt(1);function go(r,e){let t=(o,i)=>{let s=i.negate();return o?s:i},n=o=>{let i=Math.ceil(e/o)+1,s=2**(o-1);return{windows:i,windowSize:s}};return{constTimeNegate:t,unsafeLadder(o,i){let s=r.ZERO,a=o;for(;i>pp;)i&Ps&&(s=s.add(a)),a=a.double(),i>>=Ps;return s},precomputeWindow(o,i){let{windows:s,windowSize:a}=n(i),c=[],f=o,u=f;for(let l=0;l<s;l++){u=f,c.push(u);for(let d=1;d<a;d++)u=u.add(f),c.push(u);f=u.double()}return c},wNAF(o,i,s){let{windows:a,windowSize:c}=n(o),f=r.ZERO,u=r.BASE,l=BigInt(2**o-1),d=2**o,b=BigInt(o);for(let g=0;g<a;g++){let h=g*c,p=Number(s&l);s>>=b,p>c&&(p-=d,s+=Ps);let x=h,R=h+Math.abs(p)-1,v=g%2!==0,L=p<0;p===0?u=u.add(t(v,i[x])):f=f.add(t(L,i[R]))}return{p:f,f:u}},wNAFCached(o,i,s,a){let c=o._WINDOW_SIZE||1,f=i.get(o);return f||(f=this.precomputeWindow(o,c),c!==1&&i.set(o,a(f))),this.wNAF(c,f,s)}}}function xn(r){return Ds(r.Fp),ht(r,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Vs(r.n,r.nBitLength),...r,p:r.Fp.ORDER})}var rt=BigInt(0),He=BigInt(1),mo=BigInt(2),gp=BigInt(8),mp={zip215:!0};function yp(r){let e=xn(r);return ht(r,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...e})}function lu(r){let e=yp(r),{Fp:t,n,prehash:o,hash:i,randomBytes:s,nByteLength:a,h:c}=e,f=mo<<BigInt(a*8)-He,u=t.create,l=e.uvRatio||((B,w)=>{try{return{isValid:!0,value:t.sqrt(B*t.inv(w))}}catch{return{isValid:!1,value:rt}}}),d=e.adjustScalarBytes||(B=>B),b=e.domain||((B,w,D)=>{if(w.length||D)throw new Error("Contexts/pre-hash are not supported");return B}),g=B=>typeof B=="bigint"&&rt<B,h=(B,w)=>g(B)&&g(w)&&B<w,p=B=>B===rt||h(B,f);function x(B,w){if(h(B,w))return B;throw new Error(`Expected valid scalar < ${w}, got ${typeof B} ${B}`)}function R(B){return B===rt?B:x(B,n)}let v=new Map;function L(B){if(!(B instanceof S))throw new Error("ExtendedPoint expected")}class S{constructor(w,D,F,$){if(this.ex=w,this.ey=D,this.ez=F,this.et=$,!p(w))throw new Error("x required");if(!p(D))throw new Error("y required");if(!p(F))throw new Error("z required");if(!p($))throw new Error("t required")}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(w){if(w instanceof S)throw new Error("extended point not allowed");let{x:D,y:F}=w||{};if(!p(D)||!p(F))throw new Error("invalid affine point");return new S(D,F,He,u(D*F))}static normalizeZ(w){let D=t.invertBatch(w.map(F=>F.ez));return w.map((F,$)=>F.toAffine(D[$])).map(S.fromAffine)}_setWindowSize(w){this._WINDOW_SIZE=w,v.delete(this)}assertValidity(){let{a:w,d:D}=e;if(this.is0())throw new Error("bad point: ZERO");let{ex:F,ey:$,ez:j,et:Y}=this,ee=u(F*F),W=u($*$),X=u(j*j),he=u(X*X),se=u(ee*w),Ee=u(X*u(se+W)),ve=u(he+u(D*u(ee*W)));if(Ee!==ve)throw new Error("bad point: equation left != right (1)");let ge=u(F*$),Ie=u(j*Y);if(ge!==Ie)throw new Error("bad point: equation left != right (2)")}equals(w){L(w);let{ex:D,ey:F,ez:$}=this,{ex:j,ey:Y,ez:ee}=w,W=u(D*ee),X=u(j*$),he=u(F*ee),se=u(Y*$);return W===X&&he===se}is0(){return this.equals(S.ZERO)}negate(){return new S(u(-this.ex),this.ey,this.ez,u(-this.et))}double(){let{a:w}=e,{ex:D,ey:F,ez:$}=this,j=u(D*D),Y=u(F*F),ee=u(mo*u($*$)),W=u(w*j),X=D+F,he=u(u(X*X)-j-Y),se=W+Y,Ee=se-ee,ve=W-Y,ge=u(he*Ee),Ie=u(se*ve),bt=u(he*ve),or=u(Ee*se);return new S(ge,Ie,or,bt)}add(w){L(w);let{a:D,d:F}=e,{ex:$,ey:j,ez:Y,et:ee}=this,{ex:W,ey:X,ez:he,et:se}=w;if(D===BigInt(-1)){let za=u((j-$)*(X+W)),Ga=u((j+$)*(X-W)),Di=u(Ga-za);if(Di===rt)return this.double();let ja=u(Y*mo*se),Ya=u(ee*mo*he),Za=Ya+ja,Wa=Ga+za,Ja=Ya-ja,Bh=u(Za*Di),Ah=u(Wa*Ja),Sh=u(Za*Ja),Ih=u(Di*Wa);return new S(Bh,Ah,Ih,Sh)}let Ee=u($*W),ve=u(j*X),ge=u(ee*F*se),Ie=u(Y*he),bt=u(($+j)*(W+X)-Ee-ve),or=Ie-ge,ln=Ie+ge,qa=u(ve-D*Ee),bh=u(bt*or),xh=u(ln*qa),Eh=u(bt*qa),vh=u(or*ln);return new S(bh,xh,vh,Eh)}subtract(w){return this.add(w.negate())}wNAF(w){return y.wNAFCached(this,v,w,S.normalizeZ)}multiply(w){let{p:D,f:F}=this.wNAF(x(w,n));return S.normalizeZ([D,F])[0]}multiplyUnsafe(w){let D=R(w);return D===rt?C:this.equals(C)||D===He?this:this.equals(k)?this.wNAF(D).p:y.unsafeLadder(this,D)}isSmallOrder(){return this.multiplyUnsafe(c).is0()}isTorsionFree(){return y.unsafeLadder(this,n).is0()}toAffine(w){let{ex:D,ey:F,ez:$}=this,j=this.is0();w==null&&(w=j?gp:t.inv($));let Y=u(D*w),ee=u(F*w),W=u($*w);if(j)return{x:rt,y:He};if(W!==He)throw new Error("invZ was invalid");return{x:Y,y:ee}}clearCofactor(){let{h:w}=e;return w===He?this:this.multiplyUnsafe(w)}static fromHex(w,D=!1){let{d:F,a:$}=e,j=t.BYTES;w=ue("pointHex",w,j);let Y=w.slice(),ee=w[j-1];Y[j-1]=ee&-129;let W=Gt(Y);W===rt||(D?x(W,f):x(W,t.ORDER));let X=u(W*W),he=u(X-He),se=u(F*X-$),{isValid:Ee,value:ve}=l(he,se);if(!Ee)throw new Error("Point.fromHex: invalid y coordinate");let ge=(ve&He)===He,Ie=(ee&128)!==0;if(!D&&ve===rt&&Ie)throw new Error("Point.fromHex: x=0 and x_0=1");return Ie!==ge&&(ve=u(-ve)),S.fromAffine({x:ve,y:W})}static fromPrivateKey(w){return T(w).point}toRawBytes(){let{x:w,y:D}=this.toAffine(),F=lr(D,t.BYTES);return F[F.length-1]|=w&He?128:0,F}toHex(){return vt(this.toRawBytes())}}S.BASE=new S(e.Gx,e.Gy,He,u(e.Gx*e.Gy)),S.ZERO=new S(rt,He,He,rt);let{BASE:k,ZERO:C}=S,y=go(S,a*8);function N(B){return re(B,n)}function V(B){return N(Gt(B))}function T(B){let w=a;B=ue("private key",B,w);let D=ue("hashed private key",i(B),2*w),F=d(D.slice(0,w)),$=D.slice(w,2*w),j=V(F),Y=k.multiply(j),ee=Y.toRawBytes();return{head:F,prefix:$,scalar:j,point:Y,pointBytes:ee}}function P(B){return T(B).pointBytes}function H(B=new Uint8Array,...w){let D=At(...w);return V(i(b(D,ue("context",B),!!o)))}function J(B,w,D={}){B=ue("message",B),o&&(B=o(B));let{prefix:F,scalar:$,pointBytes:j}=T(w),Y=H(D.context,F,B),ee=k.multiply(Y).toRawBytes(),W=H(D.context,ee,j,B),X=N(Y+W*$);R(X);let he=At(ee,lr(X,t.BYTES));return ue("result",he,a*2)}let E=mp;function A(B,w,D,F=E){let{context:$,zip215:j}=F,Y=t.BYTES;B=ue("signature",B,2*Y),w=ue("message",w),o&&(w=o(w));let ee=Gt(B.slice(Y,2*Y)),W,X,he;try{W=S.fromHex(D,j),X=S.fromHex(B.slice(0,Y),j),he=k.multiplyUnsafe(ee)}catch{return!1}if(!j&&W.isSmallOrder())return!1;let se=H($,X.toRawBytes(),W.toRawBytes(),w);return X.add(W.multiplyUnsafe(se)).subtract(he).clearCofactor().equals(S.ZERO)}return k._setWindowSize(8),{CURVE:e,getPublicKey:P,sign:J,verify:A,ExtendedPoint:S,utils:{getExtendedPublicKey:T,randomPrivateKey:()=>s(t.BYTES),precompute(B=8,w=S.BASE){return w._setWindowSize(B),w.multiply(BigInt(3)),w}}}}var Fs=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),fu=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),nx=BigInt(0),wp=BigInt(1),hu=BigInt(2),ox=BigInt(3),bp=BigInt(5),xp=BigInt(8);function Ep(r){let e=BigInt(10),t=BigInt(20),n=BigInt(40),o=BigInt(80),i=Fs,a=r*r%i*r%i,c=ie(a,hu,i)*a%i,f=ie(c,wp,i)*r%i,u=ie(f,bp,i)*f%i,l=ie(u,e,i)*u%i,d=ie(l,t,i)*l%i,b=ie(d,n,i)*d%i,g=ie(b,o,i)*b%i,h=ie(g,o,i)*b%i,p=ie(h,e,i)*u%i;return{pow_p_5_8:ie(p,hu,i)*r%i,b2:a}}function vp(r){return r[0]&=248,r[31]&=127,r[31]|=64,r}function Bp(r,e){let t=Fs,n=re(e*e*e,t),o=re(n*n*e,t),i=Ep(r*o).pow_p_5_8,s=re(r*n*i,t),a=re(e*s*s,t),c=s,f=re(s*fu,t),u=a===r,l=a===re(-r,t),d=a===re(-r*fu,t);return u&&(s=c),(l||d)&&(s=f),au(s,t)&&(s=re(-s,t)),{isValid:u||l,value:s}}var Ap=po(Fs,void 0,!0),Sp={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:Ap,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:xp,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:wn,randomBytes:Mr,adjustScalarBytes:vp,uvRatio:Bp},Kr=lu(Sp);var qr=32,St=64,yo=32;function du(){let r=Kr.utils.randomPrivateKey(),e=Kr.getPublicKey(r);return{privateKey:yu(r,e),publicKey:e}}function pu(r){if(r.length!==yo)throw new TypeError('"seed" must be 32 bytes in length.');if(!(r instanceof Uint8Array))throw new TypeError('"seed" must be a node.js Buffer, or Uint8Array.');let e=r,t=Kr.getPublicKey(e);return{privateKey:yu(e,t),publicKey:t}}function gu(r,e){let t=r.subarray(0,yo);return Kr.sign(e instanceof Uint8Array?e:e.subarray(),t)}function mu(r,e,t){return Kr.verify(e,t instanceof Uint8Array?t:t.subarray(),r)}function yu(r,e){let t=new Uint8Array(St);for(let n=0;n<yo;n++)t[n]=r[n],t[yo+n]=e[n];return t}var _e={get(r=globalThis){let e=r.crypto;if(e==null||e.subtle==null)throw Object.assign(new Error("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"),{code:"ERR_MISSING_WEB_CRYPTO"});return e}};var Ms={alg:"A128GCM",ext:!0,k:"scm9jmO_4BJAgdwWGVulLg",key_ops:["encrypt","decrypt"],kty:"oct"};function wu(r){let e=r?.algorithm??"AES-GCM",t=r?.keyLength??16,n=r?.nonceLength??12,o=r?.digest??"SHA-256",i=r?.saltLength??16,s=r?.iterations??32767,a=_e.get();t*=8;async function c(l,d){let b=a.getRandomValues(new Uint8Array(i)),g=a.getRandomValues(new Uint8Array(n)),h={name:e,iv:g};typeof d=="string"&&(d=z(d));let p;if(d.length===0){p=await a.subtle.importKey("jwk",Ms,{name:"AES-GCM"},!0,["encrypt"]);try{let R={name:"PBKDF2",salt:b,iterations:s,hash:{name:o}},v=await a.subtle.importKey("raw",d,{name:"PBKDF2"},!1,["deriveKey"]);p=await a.subtle.deriveKey(R,v,{name:e,length:t},!0,["encrypt"])}catch{p=await a.subtle.importKey("jwk",Ms,{name:"AES-GCM"},!0,["encrypt"])}}else{let R={name:"PBKDF2",salt:b,iterations:s,hash:{name:o}},v=await a.subtle.importKey("raw",d,{name:"PBKDF2"},!1,["deriveKey"]);p=await a.subtle.deriveKey(R,v,{name:e,length:t},!0,["encrypt"])}let x=await a.subtle.encrypt(h,p,l);return Ce([b,h.iv,new Uint8Array(x)])}async function f(l,d){let b=l.subarray(0,i),g=l.subarray(i,i+n),h=l.subarray(i+n),p={name:e,iv:g};typeof d=="string"&&(d=z(d));let x;if(d.length===0)try{let v={name:"PBKDF2",salt:b,iterations:s,hash:{name:o}},L=await a.subtle.importKey("raw",d,{name:"PBKDF2"},!1,["deriveKey"]);x=await a.subtle.deriveKey(v,L,{name:e,length:t},!0,["decrypt"])}catch{x=await a.subtle.importKey("jwk",Ms,{name:"AES-GCM"},!0,["decrypt"])}else{let v={name:"PBKDF2",salt:b,iterations:s,hash:{name:o}},L=await a.subtle.importKey("raw",d,{name:"PBKDF2"},!1,["deriveKey"]);x=await a.subtle.deriveKey(v,L,{name:e,length:t},!0,["decrypt"])}let R=await a.subtle.decrypt(p,x,h);return new Uint8Array(R)}return{encrypt:c,decrypt:f}}async function zr(r,e){let n=await wu().encrypt(r,e);return fn.encode(n)}var Hs=new Float32Array([-0]),Yt=new Uint8Array(Hs.buffer);function bu(r,e,t){Hs[0]=r,e[t]=Yt[0],e[t+1]=Yt[1],e[t+2]=Yt[2],e[t+3]=Yt[3]}function xu(r,e){return Yt[0]=r[e],Yt[1]=r[e+1],Yt[2]=r[e+2],Yt[3]=r[e+3],Hs[0]}var $s=new Float64Array([-0]),ke=new Uint8Array($s.buffer);function Eu(r,e,t){$s[0]=r,e[t]=ke[0],e[t+1]=ke[1],e[t+2]=ke[2],e[t+3]=ke[3],e[t+4]=ke[4],e[t+5]=ke[5],e[t+6]=ke[6],e[t+7]=ke[7]}function vu(r,e){return ke[0]=r[e],ke[1]=r[e+1],ke[2]=r[e+2],ke[3]=r[e+3],ke[4]=r[e+4],ke[5]=r[e+5],ke[6]=r[e+6],ke[7]=r[e+7],$s[0]}var kp=BigInt(Number.MAX_SAFE_INTEGER),Tp=BigInt(Number.MIN_SAFE_INTEGER),$e=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 hr;if(e<kp&&e>Tp)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>Bu&&(o=0n,++n>Bu&&(n=0n))),new r(Number(o),Number(n))}static fromNumber(e){if(e===0)return hr;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):hr}},hr=new $e(0,0);hr.toBigInt=function(){return 0n};hr.zzEncode=hr.zzDecode=function(){return this};hr.length=function(){return 1};var Bu=4294967296n;function Au(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 Su(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 Ks(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 nt(r,e){return RangeError(`index out of range: ${r.pos} + ${e??1} > ${r.len}`)}function wo(r,e){return(r[e-4]|r[e-3]<<8|r[e-2]<<16|r[e-1]<<24)>>>0}var qs=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,nt(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 nt(this,4);return wo(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw nt(this,4);return wo(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw nt(this,4);let e=xu(this.buf,this.pos);return this.pos+=4,e}double(){if(this.pos+8>this.len)throw nt(this,4);let e=vu(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 nt(this,e);return this.pos+=e,t===n?new Uint8Array(0):this.buf.subarray(t,n)}string(){let e=this.bytes();return Su(e,0,e.length)}skip(e){if(typeof e=="number"){if(this.pos+e>this.len)throw nt(this,e);this.pos+=e}else do if(this.pos>=this.len)throw nt(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 $e(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 nt(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 nt(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 nt(this,8);let e=wo(this.buf,this.pos+=4),t=wo(this.buf,this.pos+=4);return new $e(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=ds(this.buf,this.pos);return this.pos+=De(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 zs(r){return new qs(r instanceof Uint8Array?r:r.subarray())}function Gr(r,e,t){let n=zs(r);return e.decode(n,void 0,t)}function Gs(r){let e=r??8192,t=e>>>1,n,o=e;return function(s){if(s<1||s>t)return et(s);o+s>e&&(n=et(e),o=0);let a=n.subarray(o,o+=s);return o&7&&(o=(o|7)+1),a}}var dr=class{fn;len;next;val;constructor(e,t,n){this.fn=e,this.len=t,this.next=void 0,this.val=n}};function js(){}var Zs=class{head;tail;len;next;constructor(e){this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}},Np=Gs();function Cp(r){return globalThis.Buffer!=null?et(r):Np(r)}var vn=class{len;head;tail;states;constructor(){this.len=0,this.head=new dr(js,0,0),this.tail=this.head,this.states=null}_push(e,t,n){return this.tail=this.tail.next=new dr(e,t,n),this.len+=t,this}uint32(e){return this.len+=(this.tail=this.tail.next=new Ws((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(bo,10,$e.fromNumber(e)):this.uint32(e)}sint32(e){return this.uint32((e<<1^e>>31)>>>0)}uint64(e){let t=$e.fromBigInt(e);return this._push(bo,t.length(),t)}uint64Number(e){return this._push(hs,De(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=$e.fromBigInt(e).zzEncode();return this._push(bo,t.length(),t)}sint64Number(e){let t=$e.fromNumber(e).zzEncode();return this._push(bo,t.length(),t)}sint64String(e){return this.sint64(BigInt(e))}bool(e){return this._push(Ys,1,e?1:0)}fixed32(e){return this._push(En,4,e>>>0)}sfixed32(e){return this.fixed32(e)}fixed64(e){let t=$e.fromBigInt(e);return this._push(En,4,t.lo)._push(En,4,t.hi)}fixed64Number(e){let t=$e.fromNumber(e);return this._push(En,4,t.lo)._push(En,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(bu,4,e)}double(e){return this._push(Eu,8,e)}bytes(e){let t=e.length>>>0;return t===0?this._push(Ys,1,0):this.uint32(t)._push(Up,t,e)}string(e){let t=Au(e);return t!==0?this.uint32(t)._push(Ks,t,e):this._push(Ys,1,0)}fork(){return this.states=new Zs(this),this.head=this.tail=new dr(js,0,0),this.len=0,this}reset(){return this.states!=null?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new dr(js,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=Cp(this.len),n=0;for(;e!=null;)e.fn(e.val,t,n),n+=e.len,e=e.next;return t}};function Ys(r,e,t){e[t]=r&255}function _p(r,e,t){for(;r>127;)e[t++]=r&127|128,r>>>=7;e[t]=r}var Ws=class extends dr{next;constructor(e,t){super(_p,e,t),this.next=void 0}};function bo(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 En(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 Up(r,e,t){e.set(r,t)}globalThis.Buffer!=null&&(vn.prototype.bytes=function(r){let e=r.length>>>0;return this.uint32(e),e>0&&this._push(Lp,e,r),this},vn.prototype.string=function(r){let e=globalThis.Buffer.byteLength(r);return this.uint32(e),e>0&&this._push(Dp,e,r),this});function Lp(r,e,t){e.set(r,t)}function Dp(r,e,t){r.length<40?Ks(r,e,t):e.utf8Write!=null?e.utf8Write(r,t):e.set(z(r),t)}function Js(){return new vn}function jr(r,e){let t=Js();return e.encode(r,t,{lengthDelimited:!1}),t.finish()}var Yr;(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"})(Yr||(Yr={}));function xo(r,e,t,n){return{name:r,type:e,encode:t,decode:n}}function Bn(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 xo("enum",Yr.VARINT,t,n)}function Zr(r,e){return xo("message",Yr.LENGTH_DELIMITED,r,e)}var fe;(function(r){r.RSA="RSA",r.Ed25519="Ed25519",r.Secp256k1="Secp256k1"})(fe||(fe={}));var Xs;(function(r){r[r.RSA=0]="RSA",r[r.Ed25519=1]="Ed25519",r[r.Secp256k1=2]="Secp256k1"})(Xs||(Xs={}));(function(r){r.codec=()=>Bn(Xs)})(fe||(fe={}));var dt;(function(r){let e;r.codec=()=>(e==null&&(e=Zr((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)=>{let o={},i=n==null?t.len:t.pos+n;for(;t.pos<i;){let s=t.uint32();switch(s>>>3){case 1:o.Type=fe.codec().decode(t);break;case 2:o.Data=t.bytes();break;default:t.skipType(s&7);break}}return o})),e),r.encode=t=>jr(t,r.codec()),r.decode=t=>Gr(t,r.codec())})(dt||(dt={}));var It;(function(r){let e;r.codec=()=>(e==null&&(e=Zr((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)=>{let o={},i=n==null?t.len:t.pos+n;for(;t.pos<i;){let s=t.uint32();switch(s>>>3){case 1:o.Type=fe.codec().decode(t);break;case 2:o.Data=t.bytes();break;default:t.skipType(s&7);break}}return o})),e),r.encode=t=>jr(t,r.codec()),r.decode=t=>Gr(t,r.codec())})(It||(It={}));var An=class{_key;constructor(e){this._key=Wr(e,qr)}verify(e,t){return mu(this._key,t,e)}marshal(){return this._key}get bytes(){return dt.encode({Type:fe.Ed25519,Data:this.marshal()}).subarray()}equals(e){return ce(this.bytes,e.bytes)}hash(){let e=Be.digest(this.bytes);return Ye(e)?e.then(({bytes:t})=>t):e.bytes}},pr=class{_key;_publicKey;constructor(e,t){this._key=Wr(e,St),this._publicKey=Wr(t,qr)}sign(e){return gu(this._key,e)}get public(){return new An(this._publicKey)}marshal(){return this._key}get bytes(){return It.encode({Type:fe.Ed25519,Data:this.marshal()}).subarray()}equals(e){return ce(this.bytes,e.bytes)}async hash(){let e=Be.digest(this.bytes),t;return Ye(e)?{bytes:t}=await e:t=e.bytes,t}async id(){let e=Me.digest(this.public.bytes);return le.encode(e.bytes).substring(1)}async export(e,t="libp2p-key"){if(t==="libp2p-key")return zr(this.bytes,e);throw new O(`export format '${t}' is not supported`,"ERR_INVALID_EXPORT_FORMAT")}};function Vp(r){if(r.length>St){r=Wr(r,St+qr);let n=r.subarray(0,St),o=r.subarray(St,r.length);return new pr(n,o)}r=Wr(r,St);let e=r.subarray(0,St),t=r.subarray(qr);return new pr(e,t)}function Op(r){return r=Wr(r,qr),new An(r)}async function Pp(){let{privateKey:r,publicKey:e}=du();return new pr(r,e)}async function Ru(r){let{privateKey:e,publicKey:t}=pu(r);return new pr(e,t)}function Wr(r,e){if(r=Uint8Array.from(r??[]),r.length!==e)throw new O(`Key must be a Uint8Array of length ${e}, got ${r.length}`,"ERR_INVALID_KEY_TYPE");return r}var ua={};ye(ua,{MAX_RSA_KEY_SIZE:()=>Vn,RsaPrivateKey:()=>tn,RsaPublicKey:()=>Dn,fromJwk:()=>fg,generateKeyPair:()=>hg,unmarshalRsaPrivateKey:()=>aa,unmarshalRsaPublicKey:()=>lg});function gr(r){if(isNaN(r)||r<=0)throw new O("random bytes length must be a Number bigger than 0","ERR_INVALID_LENGTH");return Mr(r)}var Xt={};ye(Xt,{exportToPem:()=>ig,importFromPem:()=>sg,jwkToPkcs1:()=>tg,jwkToPkix:()=>ng,pkcs1ToJwk:()=>eg,pkixToJwk:()=>rg});var vo=class extends Pr{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,so(e);let n=$t(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 Or(this),this.iHash.update(e),this}digestInto(e){Or(this),Vr(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()}},Sn=(r,e,t)=>new vo(r,e).update(t).digest();Sn.create=(r,e)=>new vo(r,e);function Fp(r,e,t,n){so(r);let o=Jc({dkLen:32,asyncTick:10},n),{c:i,dkLen:s,asyncTick:a}=o;if(Dr(i),Dr(s),Dr(a),i<1)throw new Error("PBKDF2: iterations (c) should be >= 1");let c=$t(e),f=$t(t),u=new Uint8Array(s),l=Sn.create(r,c),d=l._cloneInto().update(f);return{c:i,dkLen:s,asyncTick:a,DK:u,PRF:l,PRFSalt:d}}function Mp(r,e,t,n,o){return r.destroy(),e.destroy(),n&&n.destroy(),o.fill(0),t}async function ea(r,e,t,n){let{c:o,dkLen:i,asyncTick:s,DK:a,PRF:c,PRFSalt:f}=Fp(r,e,t,n),u,l=new Uint8Array(4),d=Fr(l),b=new Uint8Array(c.outputLen);for(let g=1,h=0;h<i;g++,h+=c.outputLen){let p=a.subarray(h,h+c.outputLen);d.setInt32(0,g,!1),(u=f._cloneInto(u)).update(l).digestInto(b),p.set(b.subarray(0,p.length)),await Zc(o-1,s,()=>{c._cloneInto(u).update(b).digestInto(b);for(let x=0;x<p.length;x++)p[x]^=b[x]})}return Mp(c,f,a,u,b)}var Z=Vt(ku());function mr(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 Zt(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 So(...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 ra(){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=mr(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,mr(i,8)-n}function Tu(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=Zt(s,8,n),c=new Uint8Array(a);return c[0]|=128,a}let o=Zt(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 Nu(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 u1=Math.log(2);function Io(){if(typeof BigInt>"u")throw new Error("BigInt is not defined. Your environment doesn't implement BigInt.")}function na(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 Ct(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 na(this.items)}},In=[new Uint8Array([1])],Cu="0123456789";var Qr="",it=new ArrayBuffer(0),oa=new Uint8Array(0),kn="EndOfContent",Uu="OCTET STRING",Lu="BIT STRING";function _t(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?Z.BufferSourceConverter.toUint8Array(i.valueHex):oa}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(!Ct(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",it)}toJSON(){return{...super.toJSON(),isHexOnly:this.isHexOnly,valueHex:Z.Convert.ToHex(this.valueHexView)}}},e.NAME="hexBlock",e}var kt=class{constructor({blockLength:e=0,error:t=Qr,warnings:n=[],valueBeforeDecode:o=oa}={}){this.blockLength=e,this.error=t,this.warnings=n,this.valueBeforeDecodeView=Z.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:Z.Convert.ToHex(this.valueBeforeDecodeView)}}};kt.NAME="baseBlock";var Te=class extends kt{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'")}};Te.NAME="valueBlock";var Ro=class extends _t(kt){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?Z.BufferSourceConverter.toUint8Array(e.valueHex):oa,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",it}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=Zt(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=Z.BufferSourceConverter.toUint8Array(e);if(!Ct(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 d=new Uint8Array(u);for(let b=0;b<f.length;b++)d[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 d=0;d<c;d++)l[d]=f[d];f=this.valueHexView=new Uint8Array(c),f.set(l),this.blockLength<=9?this.tagNumber=mr(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}}};Ro.NAME="identificationBlock";var ko=class extends kt{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=Z.BufferSourceConverter.toUint8Array(e);if(!Ct(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=mr(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=Zt(this.length,8);if(o.byteLength>127)return this.error="Too big length",it;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}}};ko.NAME="lengthBlock";var _={},Ae=class extends kt{constructor({name:e=Qr,optional:t=!1,primitiveSchema:n,...o}={},i){super(o),this.name=e,this.optional=t,n&&(this.primitiveSchema=n),this.idBlock=new Ro(o),this.lenBlock=new ko(o),this.valueBlock=i?new i(o):new Te(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||Du(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?it: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():Z.Convert.ToHex(this.toBER())}onAsciiEncoding(){return`${this.constructor.NAME} : ${Z.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 Nu(t,n)}};Ae.NAME="BaseBlock";function Du(r){if(r instanceof _.Constructed)for(let e of r.valueBlock.value)Du(e)&&(r.lenBlock.isIndefiniteForm=!0);return!!r.lenBlock.isIndefiniteForm}var To=class extends Ae{constructor({value:e=Qr,...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}'`}};To.NAME="BaseStringBlock";var No=class extends _t(Te){constructor({isHexOnly:e=!0,...t}={}){super(t),this.isHexOnly=e}};No.NAME="PrimitiveValueBlock";var Vu,Co=class extends Ae{constructor(e={}){super(e,No),this.idBlock.isConstructed=!1}};Vu=Co;_.Primitive=Vu;Co.NAME="PRIMITIVE";function Zp(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 li(r,e=0,t=r.length){let n=e,o=new Ae({},Te),i=new kt;if(!Ct(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=Ae;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=Zp(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 en(r){if(!r.byteLength){let e=new Ae({},Te);return e.error="Input buffer has zero length",{offset:-1,result:e}}return li(Z.BufferSourceConverter.toUint8Array(r).slice(),0,r.byteLength)}function Wp(r,e){return r?1:e}var pt=class extends Te{constructor({value:e=[],isIndefiniteForm:t=!1,...n}={}){super(n),this.value=e,this.isIndefiniteForm=t}fromBER(e,t,n){let o=Z.BufferSourceConverter.toUint8Array(e);if(!Ct(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(;Wp(this.isIndefiniteForm,n)>0;){let s=li(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===kn)break}return this.isIndefiniteForm&&(this.value[this.value.length-1].constructor.NAME===kn?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?it:n.final()}toJSON(){let e={...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,value:[]};for(let t of this.value)e.value.push(t.toJSON());return e}};pt.NAME="ConstructedValueBlock";var Ou,Wt=class extends Ae{constructor(e={}){super(e,pt),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 HeliaRouters=(()=>{var ad=Object.create;var Rn=Object.defineProperty;var cd=Object.getOwnPropertyDescriptor;var ud=Object.getOwnPropertyNames;var ld=Object.getPrototypeOf,fd=Object.prototype.hasOwnProperty;var Ui=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),ke=(r,e)=>{for(var t in e)Rn(r,t,{get:e[t],enumerable:!0})},za=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of ud(e))!fd.call(r,o)&&o!==t&&Rn(r,o,{get:()=>e[o],enumerable:!(n=cd(e,o))||n.enumerable});return r};var _n=(r,e,t)=>(t=r!=null?ad(ld(r)):{},za(e||!r||!r.__esModule?Rn(t,"default",{value:r,enumerable:!0}):t,r)),dd=r=>za(Rn({},"__esModule",{value:!0}),r);var Gc=Ui(Nr=>{"use strict";var W0="[object ArrayBuffer]",vt=class r{static isArrayBuffer(e){return Object.prototype.toString.call(e)===W0}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}},Ms="string",Y0=/^[0-9a-f]+$/i,J0=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/,X0=/^[a-zA-Z0-9-_]+$/,ro=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=vt.toUint8Array(e),n="";for(let i=0;i<t.length;i++)n+=String.fromCharCode(t[i]);return decodeURIComponent(escape(n))}},qe=class{static toString(e,t=!1){let n=vt.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}},no=class r{static isHex(e){return typeof e===Ms&&Y0.test(e)}static isBase64(e){return typeof e===Ms&&J0.test(e)}static isBase64Url(e){return typeof e===Ms&&X0.test(e)}static ToString(e,t="utf8"){let n=vt.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 qe.toString(n,!0);case"utf16":case"utf16be":return qe.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 qe.fromString(e,!0);case"utf16":case"utf16be":return qe.fromString(e);default:throw new Error(`Unknown type of encoding '${t}'`)}}static ToBase64(e){let t=vt.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 ro.fromString(e);case"utf16":case"utf16be":return qe.fromString(e);case"utf16le":case"usc2":return qe.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 ro.toString(e);case"utf16":case"utf16be":return qe.toString(e);case"utf16le":case"usc2":return qe.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=vt.toUint8Array(e),n="";for(let o=0;o<t.length;o++)n+=String.fromCharCode(t[o]);return n}static ToHex(e){let t=vt.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 qe.toString(e,t)}static FromUtf16String(e,t=!1){return qe.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,"")||""}};no.DEFAULT_UTF8_ENCODING="utf8";function Q0(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 ep(...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 tp(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}Nr.BufferSourceConverter=vt;Nr.Convert=no;Nr.assign=Q0;Nr.combine=ep;Nr.isEqual=tp});var ma=Ui((a2,pa)=>{var s2=function(){typeof pa<"u"&&(pa.exports=x);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=x.prototype,l=(x.fromDate=function(g){return new x(+g)},x.fromInt64BE=T(0,1,2,3,0,4),x.fromInt64LE=T(3,2,1,0,4,0),x.fromString=function(R){var v,O=new x,R=(R+="").replace(/^\s*[+\-]?\d+/,function(H){var H=+H,A=1970+(H-1970)%400;return O.year=H-A,A}).replace(/(?:Z|([+\-]\d{2}):?(\d{2}))$/,function(N,H,A){return H<0&&(A*=-1),v=6e4*(60*+H+ +A),""}).replace(/\.\d+$/,function(N){return O.nano=+(N+c).substr(1,9),""}).split(/\D+/);if(1<R.length?R[1]--:R[1]=0,O.time=v=Date.UTC.apply(Date,R)-(v||0),isNaN(v))throw new TypeError("Invalid Date");return h(O)},x.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=h(this);return(g.time%1e3*a+ +g.nano+1e9)%1e9},u.getTimeT=function(){var v=h(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(h(this).time)},u.toJSON=function(){return this.toString().replace(/0{1,6}Z$/,"Z")},u.toString=function(g){var v=this,O=v.toDate(),R={H:function(){return L(O.getUTCHours())},L:function(){return U(O.getUTCMilliseconds(),3)},M:function(){return L(O.getUTCMinutes())},N:function(){return U(v.getNano(),9)},S:function(){return L(O.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[O.getUTCDay()]},b:function(){return d[O.getUTCMonth()]},d:function(){return L(O.getUTCDate())},e:function(){return function(N){return(9<N?"":" ")+(0|N)}(O.getUTCDate())},m:function(){return L(O.getUTCMonth()+1)}};return function N(H){return H.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=w(0,1,2,3,0,4),u.writeInt64LE=w(3,2,1,0,4,0),"%Y-%m-%dT%H:%M:%S.%NZ"),d=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],b=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],I={"%":"%",F:"%Y-%m-%d",n:`
3
+ `,R:"%H:%M",T:"%H:%M:%S",t:" ",X:"%T",Z:"GMT",z:"+0000"};return x;function x(g,v,O){var R=this;if(!(R instanceof x))return new x(g,v,O);R.time=+g||0,R.nano=+v||0,R.year=+O||0,h(R)}function h(g){var v,O,R,N=g.year,H=g.time,A=g.nano,S=((A<0||a<=A)&&(A-=(O=Math.floor(A/a))*a,H+=O,O=1),N%e);return(H<-i||i<H||S)&&((v=f(H/o))&&(N+=v*e,H-=v*o),(R=E(H)).setUTCFullYear(S+R.getUTCFullYear()),R=(H=+R)+(v=f((N-=S)/e))*o,v&&-i<=R&&R<=i&&(N-=v*e,H=R),O=1),O&&(g.year=N,g.time=H,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 O=f((R=(R|0)*s)/n)+f(N/n),R=R%n+N%n,N=f(R/n);return N&&(O+=N,R-=N*n),new x(1e3*R,0,O*e)}function w(g,v,O,R,N,H){return function(S,m){var B=h(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+H,B),S};function A(S,m,p){S[m+g]=p>>24&255,S[m+v]=p>>16&255,S[m+O]=p>>8&255,S[m+R]=255&p}}function T(g,v,O,R,N,H){return function(S,m){F(S,m|=0);var p=A(S,m+N);return C(A(S,m+H),p)};function A(S,m){return 16777216*S[m+g]+(S[m+v]<<16|S[m+O]<<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 L(g){return(9<g?"":"0")+(0|g)}function U(g,v){return(c+(0|g)).substr(-v)}}()});var _f=Ui((Wv,Ba)=>{"use strict";var Cm=Object.prototype.hasOwnProperty,Te="~";function Cn(){}Object.create&&(Cn.prototype=Object.create(null),new Cn().__proto__||(Te=!1));function Tm(r,e,t){this.fn=r,this.context=e,this.once=t||!1}function Rf(r,e,t,n,o){if(typeof t!="function")throw new TypeError("The listener must be a function");var i=new Tm(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 Bi(r,e){--r._eventsCount===0?r._events=new Cn:delete r._events[e]}function Se(){this._events=new Cn,this._eventsCount=0}Se.prototype.eventNames=function(){var e=[],t,n;if(this._eventsCount===0)return e;for(n in t=this._events)Cm.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 d=c.length,b;for(l=0;l<d;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 Rf(this,e,t,n,!1)};Se.prototype.once=function(e,t,n){return Rf(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 Bi(this,i),this;var s=this._events[i];if(s.fn)s.fn===t&&(!o||s.once)&&(!n||s.context===n)&&Bi(this,i);else{for(var a=0,c=[],f=s.length;a<f;a++)(s[a].fn!==t||o&&!s[a].once||n&&s[a].context!==n)&&c.push(s[a]);c.length?this._events[i]=c.length===1?c[0]:c:Bi(this,i)}return this};Se.prototype.removeAllListeners=function(e){var t;return e?(t=Te?Te+e:e,this._events[t]&&Bi(this,t)):(this._events=new Cn,this._eventsCount=0),this};Se.prototype.off=Se.prototype.removeListener;Se.prototype.addListener=Se.prototype.on;Se.prefixed=Te;Se.EventEmitter=Se;typeof Ba<"u"&&(Ba.exports=Se)});var Ym={};ke(Ym,{delegatedHTTPRouting:()=>Kf,httpGatewayRouting:()=>Jf,libp2pRouting:()=>Xf});var ja=Symbol.for("@libp2p/content-routing");var Ri=Symbol.for("@libp2p/peer-id");var Ga=Symbol.for("@libp2p/peer-routing");var ve=class extends Error{static name="InvalidParametersError";constructor(e="Invalid parameters"){super(e),this.name="InvalidParametersError"}},lr=class extends Error{static name="InvalidPublicKeyError";constructor(e="Invalid public key"){super(e),this.name="InvalidPublicKeyError"}};var Re=class extends Error{static name="NotFoundError";constructor(e="Not found"){super(e),this.name="NotFoundError"}};var Vn=class extends Error{static name="InvalidCIDError";constructor(e="Invalid CID"){super(e),this.name="InvalidCIDError"}},fr=class extends Error{static name="InvalidMultihashError";constructor(e="Invalid Multihash"){super(e),this.name="InvalidMultihashError"}};var dr=class extends Error{static name="UnsupportedKeyTypeError";constructor(e="Unsupported key type"){super(e),this.name="UnsupportedKeyTypeError"}};var hr=(r,...e)=>{try{[...e]}catch{}};var Fi={};ke(Fi,{base32:()=>Ge,base32hex:()=>vd,base32hexpad:()=>Bd,base32hexpadupper:()=>Ad,base32hexupper:()=>Ed,base32pad:()=>wd,base32padupper:()=>bd,base32upper:()=>xd,base32z:()=>Sd});var ng=new Uint8Array(0);function Za(r,e){if(r===e)return!0;if(r.byteLength!==e.byteLength)return!1;for(let t=0;t<r.byteLength;t++)if(r[t]!==e[t])return!1;return!0}function mt(r){if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")}function Wa(r){return new TextEncoder().encode(r)}function Ya(r){return new TextDecoder().decode(r)}function hd(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 x=0,h=0,E=0,C=I.length;E!==C&&I[E]===0;)E++,x++;for(var w=(C-E)*u+1>>>0,T=new Uint8Array(w);E!==C;){for(var F=I[E],L=0,U=w-1;(F!==0||L<h)&&U!==-1;U--,L++)F+=256*T[U]>>>0,T[U]=F%a>>>0,F=F/a>>>0;if(F!==0)throw new Error("Non-zero carry");h=L,E++}for(var g=w-h;g!==w&&T[g]===0;)g++;for(var v=c.repeat(x);g<w;++g)v+=r.charAt(T[g]);return v}function d(I){if(typeof I!="string")throw new TypeError("Expected String");if(I.length===0)return new Uint8Array;var x=0;if(I[x]!==" "){for(var h=0,E=0;I[x]===c;)h++,x++;for(var C=(I.length-x)*f+1>>>0,w=new Uint8Array(C);I[x];){var T=t[I.charCodeAt(x)];if(T===255)return;for(var F=0,L=C-1;(T!==0||F<E)&&L!==-1;L--,F++)T+=a*w[L]>>>0,w[L]=T%256>>>0,T=T/256>>>0;if(T!==0)throw new Error("Non-zero carry");E=F,x++}if(I[x]!==" "){for(var U=C-E;U!==C&&w[U]===0;)U++;for(var g=new Uint8Array(h+(C-U)),v=h;U!==C;)g[v++]=w[U++];return g}}}function b(I){var x=d(I);if(x)return x;throw new Error(`Non-${e} character`)}return{encode:l,decodeUnsafe:d,decode:b}}var pd=hd,md=pd,Xa=md;var _i=class{name;prefix;baseEncode;constructor(e,t,n){this.name=e,this.prefix=t,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},Vi=class{name;prefix;baseDecode;prefixCodePoint;constructor(e,t,n){this.name=e,this.prefix=t;let o=t.codePointAt(0);if(o===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=o,this.baseDecode=n}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return Qa(this,e)}},Li=class{decoders;constructor(e){this.decoders=e}or(e){return Qa(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 Qa(r,e){return new Li({...r.decoders??{[r.prefix]:r},...e.decoders??{[e.prefix]:e}})}var Pi=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 _i(e,t,n),this.decoder=new Vi(e,t,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};function pr({name:r,prefix:e,encode:t,decode:n}){return new Pi(r,e,t,n)}function Ut({name:r,prefix:e,alphabet:t}){let{encode:n,decode:o}=Xa(t,r);return pr({prefix:e,name:r,encode:n,decode:i=>mt(o(i))})}function gd(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 yd(r,e,t){let n=e[e.length-1]==="=",o=(1<<t)-1,i="",s=0,a=0;for(let c=0;c<r.length;++c)for(a=a<<8|r[c],s+=8;s>t;)s-=t,i+=e[o&a>>s];if(s!==0&&(i+=e[o&a<<t-s]),n)for(;i.length*t&7;)i+="=";return i}function se({name:r,prefix:e,bitsPerChar:t,alphabet:n}){return pr({prefix:e,name:r,encode(o){return yd(o,n,t)},decode(o){return gd(o,n,t,r)}})}var Ge=se({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),xd=se({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),wd=se({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),bd=se({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),vd=se({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Ed=se({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Bd=se({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Ad=se({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Sd=se({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Oi={};ke(Oi,{base58btc:()=>ne,base58flickr:()=>Id});var ne=Ut({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Id=Ut({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Mi={};ke(Mi,{base64:()=>Di,base64pad:()=>kd,base64url:()=>Cd,base64urlpad:()=>Td});var Di=se({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),kd=se({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Cd=se({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Td=se({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});function Nd(r,e){try{if(typeof r=="string"&&r.length>0)return Ud(r);if(typeof r=="number"&&isFinite(r))return e?.long?_d(r):Rd(r);throw new Error("Value is not a string or number.")}catch(t){let n=Vd(t)?`${t.message}. value=${JSON.stringify(r)}`:"An unknown error has occured.";throw new Error(n)}}function Ud(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 Pn=Nd;function Rd(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 _d(r){let e=Math.abs(r);return e>=864e5?Ln(r,e,864e5,"day"):e>=36e5?Ln(r,e,36e5,"hour"):e>=6e4?Ln(r,e,6e4,"minute"):e>=1e3?Ln(r,e,1e3,"second"):`${r} ms`}function Ln(r,e,t,n){let o=e>=t*1.5;return`${Math.round(r/t)} ${n}${o?"s":""}`}function Vd(r){return typeof r=="object"&&r!==null&&"message"in r}function $i(r){t.debug=t,t.default=t,t.coerce=c,t.disable=i,t.enable=o,t.enabled=s,t.humanize=Pn,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 d=0;d<u.length;d++)l=(l<<5)-l+u.charCodeAt(d),l|=0;return t.colors[Math.abs(l)%t.colors.length]}t.selectColor=e;function t(u){let l,d=null,b,I;function x(...h){if(!x.enabled)return;let E=x,C=Number(new Date),w=C-(l||C);E.diff=w,E.prev=l,E.curr=C,l=C,h[0]=t.coerce(h[0]),typeof h[0]!="string"&&h.unshift("%O");let T=0;h[0]=h[0].replace(/%([a-zA-Z%])/g,(L,U)=>{if(L==="%%")return"%";T++;let g=t.formatters[U];if(typeof g=="function"){let v=h[T];L=g.call(E,v),h.splice(T,1),T--}return L}),t.formatArgs.call(E,h),(E.log||t.log).apply(E,h)}return x.namespace=u,x.useColors=t.useColors(),x.color=t.selectColor(u),x.extend=n,x.destroy=t.destroy,Object.defineProperty(x,"enabled",{enumerable:!0,configurable:!1,get:()=>d!==null?d:(b!==t.namespaces&&(b=t.namespaces,I=t.enabled(u)),I),set:h=>{d=h}}),typeof t.init=="function"&&t.init(x),x}function n(u,l){let d=t(this.namespace+(typeof l>"u"?":":l)+u);return d.log=this.log,d}function o(u){t.save(u),t.namespaces=u,t.names=[],t.skips=[];let l,d=(typeof u=="string"?u:"").split(/[\s,]+/),b=d.length;for(l=0;l<b;l++)d[l]&&(u=d[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,d;for(l=0,d=t.skips.length;l<d;l++)if(t.skips[l].test(u))return!1;for(l=0,d=t.names.length;l<d;l++)if(t.names[l].test(u))return!0;return!1}function a(u){return u.toString().substring(2,u.toString().length-2).replace(/\.\*\?$/,"*")}function c(u){return u instanceof Error?u.stack??u.message:u}function f(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return t.setupFormatters(t.formatters),t.enable(t.load()),t}var Fn=$d(),Ld=["#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 Pd(){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 Fd(r){if(r[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+r[0]+(this.useColors?"%c ":" ")+"+"+Pn(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 Od=console.debug??console.log??(()=>{});function Dd(r){try{r?Fn?.setItem("debug",r):Fn?.removeItem("debug")}catch{}}function Md(){let r;try{r=Fn?.getItem("debug")}catch{}return!r&&typeof process<"u"&&"env"in process&&(r=process.env.DEBUG),r}function $d(){try{return localStorage}catch{}}function Hd(r){r.j=function(e){try{return JSON.stringify(e)}catch(t){return"[UnexpectedJSONParseError]: "+t.message}}}var ec=$i({formatArgs:Fd,save:Dd,load:Md,useColors:Pd,setupFormatters:Hd,colors:Ld,storage:Fn,log:Od});var _e=ec;_e.formatters.b=r=>r==null?"undefined":ne.baseEncode(r);_e.formatters.t=r=>r==null?"undefined":Ge.baseEncode(r);_e.formatters.m=r=>r==null?"undefined":Di.baseEncode(r);_e.formatters.p=r=>r==null?"undefined":r.toString();_e.formatters.c=r=>r==null?"undefined":r.toString();_e.formatters.k=r=>r==null?"undefined":r.toString();_e.formatters.a=r=>r==null?"undefined":r.toString();_e.formatters.e=r=>r==null?"undefined":r.stack??r.message;function Kd(r){let e=()=>{};return e.enabled=!1,e.color="",e.diff=0,e.log=()=>{},e.namespace=r,e.destroy=()=>!0,e.extend=()=>e,e}function Rt(r){let e=Kd(`${r}:trace`);return _e.enabled(`${r}:trace`)&&_e.names.map(t=>t.toString()).find(t=>t.includes(":trace"))!=null&&(e=_e(`${r}:trace`)),Object.assign(_e(r),{error:_e(`${r}:error`),trace:e})}var Hi={};ke(Hi,{base36:()=>mr,base36upper:()=>qd});var mr=Ut({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),qd=Ut({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var zd=nc,tc=128,jd=127,Gd=~jd,Zd=Math.pow(2,31);function nc(r,e,t){e=e||[],t=t||0;for(var n=t;r>=Zd;)e[t++]=r&255|tc,r/=128;for(;r&Gd;)e[t++]=r&255|tc,r>>>=7;return e[t]=r|0,nc.bytes=t-n+1,e}var Wd=Ki,Yd=128,rc=127;function Ki(r,n){var t=0,n=n||0,o=0,i=n,s,a=r.length;do{if(i>=a)throw Ki.bytes=0,new RangeError("Could not decode varint");s=r[i++],t+=o<28?(s&rc)<<o:(s&rc)*Math.pow(2,o),o+=7}while(s>=Yd);return Ki.bytes=i-n,t}var Jd=Math.pow(2,7),Xd=Math.pow(2,14),Qd=Math.pow(2,21),eh=Math.pow(2,28),th=Math.pow(2,35),rh=Math.pow(2,42),nh=Math.pow(2,49),oh=Math.pow(2,56),ih=Math.pow(2,63),sh=function(r){return r<Jd?1:r<Xd?2:r<Qd?3:r<eh?4:r<th?5:r<rh?6:r<nh?7:r<oh?8:r<ih?9:10},ah={encode:zd,decode:Wd,encodingLength:sh},ch=ah,Zr=ch;function Wr(r,e=0){return[Zr.decode(r,e),Zr.decode.bytes]}function gr(r,e,t=0){return Zr.encode(r,e,t),e}function yr(r){return Zr.encodingLength(r)}function Ze(r,e){let t=e.byteLength,n=yr(r),o=n+yr(t),i=new Uint8Array(o+t);return gr(r,i,0),gr(t,i,n),i.set(e,o),new xr(r,t,e,i)}function gt(r){let e=mt(r),[t,n]=Wr(e),[o,i]=Wr(e.subarray(n)),s=e.subarray(n+i);if(s.byteLength!==o)throw new Error("Incorrect length");return new xr(t,o,s,e)}function oc(r,e){if(r===e)return!0;{let t=e;return r.code===t.code&&r.size===t.size&&t.bytes instanceof Uint8Array&&Za(r.bytes,t.bytes)}}var xr=class{code;size;digest;bytes;constructor(e,t,n,o){this.code=e,this.size=t,this.digest=n,this.bytes=o}};function ic(r,e){let{bytes:t,version:n}=r;switch(n){case 0:return lh(t,qi(r),e??ne.encoder);default:return fh(t,qi(r),e??Ge.encoder)}}var sc=new WeakMap;function qi(r){let e=sc.get(r);if(e==null){let t=new Map;return sc.set(r,t),t}return e}var Q=class r{code;version;multihash;bytes;"/";constructor(e,t,n,o){this.code=t,this.version=e,this.multihash=n,this.bytes=o,this["/"]=o}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:e,multihash:t}=this;if(e!==Yr)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==dh)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return r.createV0(t)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:e,digest:t}=this.multihash,n=Ze(e,t);return r.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(e){return r.equals(this,e)}static equals(e,t){let n=t;return n!=null&&e.code===n.code&&e.version===n.version&&oc(e.multihash,n.multihash)}toString(e){return ic(this,e)}toJSON(){return{"/":ic(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??ac(n,o,i.bytes))}else if(t[hh]===!0){let{version:n,multihash:o,code:i}=t,s=gt(o);return r.create(n,i,s)}else return null}static create(e,t,n){if(typeof t!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(e){case 0:{if(t!==Yr)throw new Error(`Version 0 CID must use dag-pb (code: ${Yr}) block encoding`);return new r(e,t,n,n.bytes)}case 1:{let o=ac(e,t,n.bytes);return new r(e,t,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return r.create(0,Yr,e)}static createV1(e,t){return r.create(1,e,t)}static decode(e){let[t,n]=r.decodeFirst(e);if(n.length!==0)throw new Error("Incorrect length");return t}static decodeFirst(e){let t=r.inspectBytes(e),n=t.size-t.multihashSize,o=mt(e.subarray(n,n+t.multihashSize));if(o.byteLength!==t.multihashSize)throw new Error("Incorrect length");let i=o.subarray(t.multihashSize-t.digestSize),s=new xr(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,d]=Wr(e.subarray(t));return t+=d,l},o=n(),i=Yr;if(o===18?(o=0,t=0):i=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let s=t,a=n(),c=n(),f=t+c,u=f-s;return{version:o,codec:i,multihashCode:a,digestSize:c,multihashSize:u,size:f}}static parse(e,t){let[n,o]=uh(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 qi(i).set(n,e),i}};function uh(r,e){switch(r[0]){case"Q":{let t=e??ne;return[ne.prefix,t.decode(`${ne.prefix}${r}`)]}case ne.prefix:{let t=e??ne;return[ne.prefix,t.decode(r)]}case Ge.prefix:{let t=e??Ge;return[Ge.prefix,t.decode(r)]}case mr.prefix:{let t=e??mr;return[mr.prefix,t.decode(r)]}default:{if(e==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[r[0],e.decode(r)]}}}function lh(r,e,t){let{prefix:n}=t;if(n!==ne.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 fh(r,e,t){let{prefix:n}=t,o=e.get(n);if(o==null){let i=t.encode(r);return e.set(n,i),i}else return o}var Yr=112,dh=18;function ac(r,e,t){let n=yr(r),o=n+yr(e),i=new Uint8Array(o+t.byteLength);return gr(r,i,0),gr(e,i,n),i.set(t,o),i}var hh=Symbol.for("@ipld/js-cid/CID");var zi={};ke(zi,{identity:()=>We});var cc=0,ph="identity",uc=mt;function mh(r){return Ze(cc,uc(r))}var We={code:cc,name:ph,encode:uc,digest:mh};function ce(r,e){if(r===e)return!0;if(r.byteLength!==e.byteLength)return!1;for(let t=0;t<r.byteLength;t++)if(r[t]!==e[t])return!1;return!0}function lc(r){if(!Number.isSafeInteger(r)||r<0)throw new Error(`positive integer expected, not ${r}`)}function gh(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}function wr(r,...e){if(!gh(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 fc(r){if(typeof r!="function"||typeof r.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");lc(r.outputLen),lc(r.blockLen)}function br(r,e=!0){if(r.destroyed)throw new Error("Hash instance has been destroyed");if(e&&r.finished)throw new Error("Hash#digest() has already been called")}function dc(r,e){wr(r);let t=e.outputLen;if(r.length<t)throw new Error(`digestInto() expects output buffer of length at least ${t}`)}var Wt=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;var Dn=r=>new DataView(r.buffer,r.byteOffset,r.byteLength),Ye=(r,e)=>r<<32-e|r>>>e;var Mg=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function hc(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=hc(r)),wr(r),r}function ji(...r){let e=0;for(let n=0;n<r.length;n++){let o=r[n];wr(o),e+=o.length}let t=new Uint8Array(e);for(let n=0,o=0;n<r.length;n++){let i=r[n];t.set(i,o),o+=i.length}return t}var vr=class{clone(){return this._cloneInto()}},$g={}.toString;function Mn(r){let e=n=>r().update(Jr(n)).digest(),t=r();return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=()=>r(),e}function $n(r=32){if(Wt&&typeof Wt.getRandomValues=="function")return Wt.getRandomValues(new Uint8Array(r));if(Wt&&typeof Wt.randomBytes=="function")return Wt.randomBytes(r);throw new Error("crypto.getRandomValues must be defined")}function yh(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 pc=(r,e,t)=>r&e^~r&t,mc=(r,e,t)=>r&e^r&t^e&t,Er=class extends vr{constructor(e,t,n,o){super(),this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=o,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=Dn(this.buffer)}update(e){br(this);let{view:t,buffer:n,blockLen:o}=this;e=Jr(e);let i=e.length;for(let s=0;s<i;){let a=Math.min(o-this.pos,i-s);if(a===o){let c=Dn(e);for(;o<=i-s;s+=o)this.process(c,s);continue}n.set(e.subarray(s,s+a),this.pos),this.pos+=a,s+=a,this.pos===o&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){br(this),dc(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;yh(n,o-8,BigInt(this.length*8),i),this.process(n,0);let a=Dn(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let f=c/4,u=this.get();if(f>u.length)throw new Error("_sha2: outputLen bigger than state");for(let l=0;l<f;l++)a.setUint32(4*l,u[l],i)}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let n=e.slice(0,t);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());let{blockLen:t,buffer:n,length:o,finished:i,destroyed:s,pos:a}=this;return e.length=o,e.pos=a,e.finished=i,e.destroyed=s,o%t&&e.buffer.set(n),e}};var Hn=BigInt(4294967295),Gi=BigInt(32);function gc(r,e=!1){return e?{h:Number(r&Hn),l:Number(r>>Gi&Hn)}:{h:Number(r>>Gi&Hn)|0,l:Number(r&Hn)|0}}function xh(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}=gc(r[o],e);[t[o],n[o]]=[i,s]}return[t,n]}var wh=(r,e)=>BigInt(r>>>0)<<Gi|BigInt(e>>>0),bh=(r,e,t)=>r>>>t,vh=(r,e,t)=>r<<32-t|e>>>t,Eh=(r,e,t)=>r>>>t|e<<32-t,Bh=(r,e,t)=>r<<32-t|e>>>t,Ah=(r,e,t)=>r<<64-t|e>>>t-32,Sh=(r,e,t)=>r>>>t-32|e<<64-t,Ih=(r,e)=>e,kh=(r,e)=>r,Ch=(r,e,t)=>r<<t|e>>>32-t,Th=(r,e,t)=>e<<t|r>>>32-t,Nh=(r,e,t)=>e<<t-32|r>>>64-t,Uh=(r,e,t)=>r<<t-32|e>>>64-t;function Rh(r,e,t,n){let o=(e>>>0)+(n>>>0);return{h:r+t+(o/2**32|0)|0,l:o|0}}var _h=(r,e,t)=>(r>>>0)+(e>>>0)+(t>>>0),Vh=(r,e,t,n)=>e+t+n+(r/2**32|0)|0,Lh=(r,e,t,n)=>(r>>>0)+(e>>>0)+(t>>>0)+(n>>>0),Ph=(r,e,t,n,o)=>e+t+n+o+(r/2**32|0)|0,Fh=(r,e,t,n,o)=>(r>>>0)+(e>>>0)+(t>>>0)+(n>>>0)+(o>>>0),Oh=(r,e,t,n,o,i)=>e+t+n+o+i+(r/2**32|0)|0;var Dh={fromBig:gc,split:xh,toBig:wh,shrSH:bh,shrSL:vh,rotrSH:Eh,rotrSL:Bh,rotrBH:Ah,rotrBL:Sh,rotr32H:Ih,rotr32L:kh,rotlSH:Ch,rotlSL:Th,rotlBH:Nh,rotlBL:Uh,add:Rh,add3L:_h,add3H:Vh,add4L:Lh,add4H:Ph,add5H:Oh,add5L:Fh},K=Dh;var[Mh,$h]=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))),Vt=new Uint32Array(80),Lt=new Uint32Array(80),Zi=class extends Er{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){let{Ah:e,Al:t,Bh:n,Bl:o,Ch:i,Cl:s,Dh:a,Dl:c,Eh:f,El:u,Fh:l,Fl:d,Gh:b,Gl:I,Hh:x,Hl:h}=this;return[e,t,n,o,i,s,a,c,f,u,l,d,b,I,x,h]}set(e,t,n,o,i,s,a,c,f,u,l,d,b,I,x,h){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=d|0,this.Gh=b|0,this.Gl=I|0,this.Hh=x|0,this.Hl=h|0}process(e,t){for(let w=0;w<16;w++,t+=4)Vt[w]=e.getUint32(t),Lt[w]=e.getUint32(t+=4);for(let w=16;w<80;w++){let T=Vt[w-15]|0,F=Lt[w-15]|0,L=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=Vt[w-2]|0,v=Lt[w-2]|0,O=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,Lt[w-7],Lt[w-16]),H=K.add4H(N,L,O,Vt[w-7],Vt[w-16]);Vt[w]=H|0,Lt[w]=N|0}let{Ah:n,Al:o,Bh:i,Bl:s,Ch:a,Cl:c,Dh:f,Dl:u,Eh:l,El:d,Fh:b,Fl:I,Gh:x,Gl:h,Hh:E,Hl:C}=this;for(let w=0;w<80;w++){let T=K.rotrSH(l,d,14)^K.rotrSH(l,d,18)^K.rotrBH(l,d,41),F=K.rotrSL(l,d,14)^K.rotrSL(l,d,18)^K.rotrBL(l,d,41),L=l&b^~l&x,U=d&I^~d&h,g=K.add5L(C,F,U,$h[w],Lt[w]),v=K.add5H(g,E,T,L,Mh[w],Vt[w]),O=g|0,R=K.rotrSH(n,o,28)^K.rotrBH(n,o,34)^K.rotrBH(n,o,39),N=K.rotrSL(n,o,28)^K.rotrBL(n,o,34)^K.rotrBL(n,o,39),H=n&i^n&a^i&a,A=o&s^o&c^s&c;E=x|0,C=h|0,x=b|0,h=I|0,b=l|0,I=d|0,{h:l,l:d}=K.add(f|0,u|0,v|0,O|0),f=a|0,u=c|0,a=i|0,c=s|0,i=n|0,s=o|0;let S=K.add3L(O,N,A);n=K.add3H(S,v,R,H),o=S|0}({h:n,l:o}=K.add(this.Ah|0,this.Al|0,n|0,o|0)),{h:i,l:s}=K.add(this.Bh|0,this.Bl|0,i|0,s|0),{h:a,l:c}=K.add(this.Ch|0,this.Cl|0,a|0,c|0),{h:f,l:u}=K.add(this.Dh|0,this.Dl|0,f|0,u|0),{h:l,l:d}=K.add(this.Eh|0,this.El|0,l|0,d|0),{h:b,l:I}=K.add(this.Fh|0,this.Fl|0,b|0,I|0),{h:x,l:h}=K.add(this.Gh|0,this.Gl|0,x|0,h|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,d,b,I,x,h,E,C)}roundClean(){Vt.fill(0),Lt.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 yc=Mn(()=>new Zi);var qn={};ke(qn,{aInRange:()=>Ve,abool:()=>Je,abytes:()=>Br,bitGet:()=>Gh,bitLen:()=>Qi,bitMask:()=>Qr,bitSet:()=>Zh,bytesToHex:()=>xt,bytesToNumberBE:()=>wt,bytesToNumberLE:()=>Ft,concatBytes:()=>bt,createHmacDrbg:()=>es,ensureBytes:()=>ae,equalBytes:()=>zh,hexToBytes:()=>Jt,hexToNumber:()=>Xi,inRange:()=>Xr,isBytes:()=>Pt,memoized:()=>Qt,notImplemented:()=>Yh,numberToBytesBE:()=>Ot,numberToBytesLE:()=>Xt,numberToHexUnpadded:()=>Yt,numberToVarBytesBE:()=>qh,utf8ToBytes:()=>jh,validateObject:()=>at});var Ji=BigInt(0),Kn=BigInt(1),Hh=BigInt(2);function Pt(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}function Br(r){if(!Pt(r))throw new Error("Uint8Array expected")}function Je(r,e){if(typeof e!="boolean")throw new Error(`${r} must be valid boolean, got "${e}".`)}var Kh=Array.from({length:256},(r,e)=>e.toString(16).padStart(2,"0"));function xt(r){Br(r);let e="";for(let t=0;t<r.length;t++)e+=Kh[r[t]];return e}function Yt(r){let e=r.toString(16);return e.length&1?`0${e}`:e}function Xi(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return BigInt(r===""?"0":`0x${r}`)}var yt={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function xc(r){if(r>=yt._0&&r<=yt._9)return r-yt._0;if(r>=yt._A&&r<=yt._F)return r-(yt._A-10);if(r>=yt._a&&r<=yt._f)return r-(yt._a-10)}function Jt(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);let e=r.length,t=e/2;if(e%2)throw new Error("padded hex string expected, got unpadded hex of length "+e);let n=new Uint8Array(t);for(let o=0,i=0;o<t;o++,i+=2){let s=xc(r.charCodeAt(i)),a=xc(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 wt(r){return Xi(xt(r))}function Ft(r){return Br(r),Xi(xt(Uint8Array.from(r).reverse()))}function Ot(r,e){return Jt(r.toString(16).padStart(e*2,"0"))}function Xt(r,e){return Ot(r,e).reverse()}function qh(r){return Jt(Yt(r))}function ae(r,e,t){let n;if(typeof e=="string")try{n=Jt(e)}catch(i){throw new Error(`${r} must be valid hex string, got "${e}". Cause: ${i}`)}else if(Pt(e))n=Uint8Array.from(e);else throw new Error(`${r} must be hex string or Uint8Array`);let o=n.length;if(typeof t=="number"&&o!==t)throw new Error(`${r} expected ${t} bytes, got ${o}`);return n}function bt(...r){let e=0;for(let n=0;n<r.length;n++){let o=r[n];Br(o),e+=o.length}let t=new Uint8Array(e);for(let n=0,o=0;n<r.length;n++){let i=r[n];t.set(i,o),o+=i.length}return t}function zh(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 jh(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}var Wi=r=>typeof r=="bigint"&&Ji<=r;function Xr(r,e,t){return Wi(r)&&Wi(e)&&Wi(t)&&e<=r&&r<t}function Ve(r,e,t,n){if(!Xr(e,t,n))throw new Error(`expected valid ${r}: ${t} <= n < ${n}, got ${typeof e} ${e}`)}function Qi(r){let e;for(e=0;r>Ji;r>>=Kn,e+=1);return e}function Gh(r,e){return r>>BigInt(e)&Kn}function Zh(r,e,t){return r|(t?Kn:Ji)<<BigInt(e)}var Qr=r=>(Hh<<BigInt(r-1))-Kn,Yi=r=>new Uint8Array(r),wc=r=>Uint8Array.from(r);function es(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=Yi(r),o=Yi(r),i=0,s=()=>{n.fill(1),o.fill(0),i=0},a=(...l)=>t(o,n,...l),c=(l=Yi())=>{o=a(wc([0]),l),n=a(),l.length!==0&&(o=a(wc([1]),l),n=a())},f=()=>{if(i++>=1e3)throw new Error("drbg: tried 1000 values");let l=0,d=[];for(;l<e;){n=a();let b=n.slice();d.push(b),l+=n.length}return bt(...d)};return(l,d)=>{s(),c(l);let b;for(;!(b=d(f()));)c();return s(),b}}var Wh={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"||Pt(r),isSafeInteger:r=>Number.isSafeInteger(r),array:r=>Array.isArray(r),field:(r,e)=>e.Fp.isValid(r),hash:r=>typeof r=="function"&&Number.isSafeInteger(r.outputLen)};function at(r,e,t={}){let n=(o,i,s)=>{let a=Wh[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 Yh=()=>{throw new Error("not implemented")};function Qt(r){let e=new WeakMap;return(t,...n)=>{let o=e.get(t);if(o!==void 0)return o;let i=r(t,...n);return e.set(t,i),i}}var fe=BigInt(0),oe=BigInt(1),er=BigInt(2),Jh=BigInt(3),ts=BigInt(4),bc=BigInt(5),vc=BigInt(8),Xh=BigInt(9),Qh=BigInt(16);function ee(r,e){let t=r%e;return t>=fe?t:e+t}function e0(r,e,t){if(t<=fe||e<fe)throw new Error("Expected power/modulo > 0");if(t===oe)return fe;let n=oe;for(;e>fe;)e&oe&&(n=n*r%t),r=r*r%t,e>>=oe;return n}function ie(r,e,t){let n=r;for(;e-- >fe;)n*=n,n%=t;return n}function zn(r,e){if(r===fe||e<=fe)throw new Error(`invert: expected positive integers, got n=${r} mod=${e}`);let t=ee(r,e),n=e,o=fe,i=oe,s=oe,a=fe;for(;t!==fe;){let f=n/t,u=n%t,l=o-s*f,d=i-a*f;n=t,t=u,o=s,i=a,s=l,a=d}if(n!==oe)throw new Error("invert: does not exist");return ee(o,e)}function t0(r){let e=(r-oe)/er,t,n,o;for(t=r-oe,n=0;t%er===fe;t/=er,n++);for(o=er;o<r&&e0(o,e,r)!==r-oe;o++);if(n===1){let s=(r+oe)/ts;return function(c,f){let u=c.pow(f,s);if(!c.eql(c.sqr(u),f))throw new Error("Cannot find square root");return u}}let i=(t+oe)/er;return function(a,c){if(a.pow(c,e)===a.neg(a.ONE))throw new Error("Cannot find square root");let f=n,u=a.pow(a.mul(a.ONE,o),t),l=a.pow(c,i),d=a.pow(c,t);for(;!a.eql(d,a.ONE);){if(a.eql(d,a.ZERO))return a.ZERO;let b=1;for(let x=a.sqr(d);b<f&&!a.eql(x,a.ONE);b++)x=a.sqr(x);let I=a.pow(u,oe<<BigInt(f-b-1));u=a.sqr(I),l=a.mul(l,I),d=a.mul(d,u),f=b}return l}}function r0(r){if(r%ts===Jh){let e=(r+oe)/ts;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%vc===bc){let e=(r-bc)/vc;return function(n,o){let i=n.mul(o,er),s=n.pow(i,e),a=n.mul(o,s),c=n.mul(n.mul(a,er),s),f=n.mul(a,n.sub(c,n.ONE));if(!n.eql(n.sqr(f),o))throw new Error("Cannot find square root");return f}}return r%Qh,t0(r)}var Ec=(r,e)=>(ee(r,e)&oe)===oe,n0=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function rs(r){let e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},t=n0.reduce((n,o)=>(n[o]="function",n),e);return at(r,t)}function o0(r,e,t){if(t<fe)throw new Error("Expected power > 0");if(t===fe)return r.ONE;if(t===oe)return e;let n=r.ONE,o=e;for(;t>fe;)t&oe&&(n=r.mul(n,o)),o=r.sqr(o),t>>=oe;return n}function i0(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 ns(r,e){let t=e!==void 0?e:r.toString(2).length,n=Math.ceil(t/8);return{nBitLength:t,nByteLength:n}}function Dt(r,e,t=!1,n={}){if(r<=fe)throw new Error(`Expected Field ORDER > 0, got ${r}`);let{nBitLength:o,nByteLength:i}=ns(r,e);if(i>2048)throw new Error("Field lengths over 2048 bytes are not supported");let s=r0(r),a=Object.freeze({ORDER:r,BITS:o,BYTES:i,MASK:Qr(o),ZERO:fe,ONE:oe,create:c=>ee(c,r),isValid:c=>{if(typeof c!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof c}`);return fe<=c&&c<r},is0:c=>c===fe,isOdd:c=>(c&oe)===oe,neg:c=>ee(-c,r),eql:(c,f)=>c===f,sqr:c=>ee(c*c,r),add:(c,f)=>ee(c+f,r),sub:(c,f)=>ee(c-f,r),mul:(c,f)=>ee(c*f,r),pow:(c,f)=>o0(a,c,f),div:(c,f)=>ee(c*zn(f,r),r),sqrN:c=>c*c,addN:(c,f)=>c+f,subN:(c,f)=>c-f,mulN:(c,f)=>c*f,inv:c=>zn(c,r),sqrt:n.sqrt||(c=>s(a,c)),invertBatch:c=>i0(a,c),cmov:(c,f,u)=>u?f:c,toBytes:c=>t?Xt(c,i):Ot(c,i),fromBytes:c=>{if(c.length!==i)throw new Error(`Fp.fromBytes: expected ${i}, got ${c.length}`);return t?Ft(c):wt(c)}});return Object.freeze(a)}function Bc(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 os(r){let e=Bc(r);return e+Math.ceil(e/2)}function Ac(r,e,t=!1){let n=r.length,o=Bc(e),i=os(e);if(n<16||n<i||n>1024)throw new Error(`expected ${i}-1024 bytes of input, got ${n}`);let s=t?wt(r):Ft(r),a=ee(s,e-oe)+oe;return t?Xt(a,o):Ot(a,o)}var a0=BigInt(0),is=BigInt(1),ss=new WeakMap,Sc=new WeakMap;function jn(r,e){let t=(i,s)=>{let a=s.negate();return i?a:s},n=i=>{if(!Number.isSafeInteger(i)||i<=0||i>e)throw new Error(`Wrong window size=${i}, should be [1..${e}]`)},o=i=>{n(i);let s=Math.ceil(e/i)+1,a=2**(i-1);return{windows:s,windowSize:a}};return{constTimeNegate:t,unsafeLadder(i,s){let a=r.ZERO,c=i;for(;s>a0;)s&is&&(a=a.add(c)),c=c.double(),s>>=is;return a},precomputeWindow(i,s){let{windows:a,windowSize:c}=o(s),f=[],u=i,l=u;for(let d=0;d<a;d++){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,d=BigInt(2**i-1),b=2**i,I=BigInt(i);for(let x=0;x<c;x++){let h=x*f,E=Number(a&d);a>>=I,E>f&&(E-=b,a+=is);let C=h,w=h+Math.abs(E)-1,T=x%2!==0,F=E<0;E===0?l=l.add(t(T,s[C])):u=u.add(t(F,s[w]))}return{p:u,f:l}},wNAFCached(i,s,a){let c=Sc.get(i)||1,f=ss.get(i);return f||(f=this.precomputeWindow(i,c),c!==1&&ss.set(i,a(f))),this.wNAF(c,f,s)},setWindowSize(i,s){n(s),Sc.set(i,s),ss.delete(i)}}}function Gn(r,e,t,n){if(!Array.isArray(t)||!Array.isArray(n)||n.length!==t.length)throw new Error("arrays of points and scalars must have equal length");n.forEach((u,l)=>{if(!e.isValid(u))throw new Error(`wrong scalar at index ${l}`)}),t.forEach((u,l)=>{if(!(u instanceof r))throw new Error(`wrong point at index ${l}`)});let o=Qi(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 d=0;d<n.length;d++){let b=n[d],I=Number(b>>BigInt(u)&BigInt(s));a[I]=a[I].add(t[d])}let l=r.ZERO;for(let d=a.length-1,b=r.ZERO;d>0;d--)b=b.add(a[d]),l=l.add(b);if(f=f.add(l),u!==0)for(let d=0;d<i;d++)f=f.double()}return f}function en(r){return rs(r.Fp),at(r,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...ns(r.n,r.nBitLength),...r,p:r.Fp.ORDER})}var Xe=BigInt(0),Le=BigInt(1),Zn=BigInt(2),c0=BigInt(8),u0={zip215:!0};function l0(r){let e=en(r);return at(r,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...e})}function Ic(r){let e=l0(r),{Fp:t,n,prehash:o,hash:i,randomBytes:s,nByteLength:a,h:c}=e,f=Zn<<BigInt(a*8)-Le,u=t.create,l=Dt(e.n,e.nBitLength),d=e.uvRatio||((m,p)=>{try{return{isValid:!0,value:t.sqrt(m*t.inv(p))}}catch{return{isValid:!1,value:Xe}}}),b=e.adjustScalarBytes||(m=>m),I=e.domain||((m,p,B)=>{if(Je("phflag",B),p.length||B)throw new Error("Contexts/pre-hash are not supported");return m});function x(m,p){Ve("coordinate "+m,p,Xe,f)}function h(m){if(!(m instanceof w))throw new Error("ExtendedPoint expected")}let E=Qt((m,p)=>{let{ex:B,ey:P,ez:D}=m,M=m.is0();p==null&&(p=M?c0:t.inv(D));let q=u(B*p),G=u(P*p),z=u(D*p);if(M)return{x:Xe,y:Le};if(z!==Le)throw new Error("invZ was invalid");return{x:q,y:G}}),C=Qt(m=>{let{a:p,d:B}=e;if(m.is0())throw new Error("bad point: ZERO");let{ex:P,ey:D,ez:M,et:q}=m,G=u(P*P),z=u(D*D),X=u(M*M),re=u(X*X),he=u(G*p),pe=u(X*u(he+z)),ye=u(re+u(B*u(G*z)));if(pe!==ye)throw new Error("bad point: equation left != right (1)");let Ie=u(P*D),le=u(M*q);if(Ie!==le)throw new Error("bad point: equation left != right (2)");return!0});class w{constructor(p,B,P,D){this.ex=p,this.ey=B,this.ez=P,this.et=D,x("x",p),x("y",B),x("z",P),x("t",D),Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(p){if(p instanceof w)throw new Error("extended point not allowed");let{x:B,y:P}=p||{};return x("x",B),x("y",P),new w(B,P,Le,u(B*P))}static normalizeZ(p){let B=t.invertBatch(p.map(P=>P.ez));return p.map((P,D)=>P.toAffine(B[D])).map(w.fromAffine)}static msm(p,B){return Gn(w,l,p,B)}_setWindowSize(p){L.setWindowSize(this,p)}assertValidity(){C(this)}equals(p){h(p);let{ex:B,ey:P,ez:D}=this,{ex:M,ey:q,ez:G}=p,z=u(B*G),X=u(M*D),re=u(P*G),he=u(q*D);return z===X&&re===he}is0(){return this.equals(w.ZERO)}negate(){return new w(u(-this.ex),this.ey,this.ez,u(-this.et))}double(){let{a:p}=e,{ex:B,ey:P,ez:D}=this,M=u(B*B),q=u(P*P),G=u(Zn*u(D*D)),z=u(p*M),X=B+P,re=u(u(X*X)-M-q),he=z+q,pe=he-G,ye=z-q,Ie=u(re*pe),le=u(he*ye),Ue=u(re*ye),pt=u(pe*he);return new w(Ie,le,pt,Ue)}add(p){h(p);let{a:B,d:P}=e,{ex:D,ey:M,ez:q,et:G}=this,{ex:z,ey:X,ez:re,et:he}=p;if(B===BigInt(-1)){let Oa=u((M-D)*(X+z)),Da=u((M+D)*(X-z)),Ni=u(Da-Oa);if(Ni===Xe)return this.double();let Ma=u(q*Zn*he),$a=u(G*Zn*re),Ha=$a+Ma,Ka=Da+Oa,qa=$a-Ma,nd=u(Ha*Ni),od=u(Ka*qa),id=u(Ha*qa),sd=u(Ni*Ka);return new w(nd,od,sd,id)}let pe=u(D*z),ye=u(M*X),Ie=u(G*P*he),le=u(q*re),Ue=u((D+M)*(z+X)-pe-ye),pt=le-Ie,jr=le+Ie,Gr=u(ye-B*pe),Qf=u(Ue*pt),ed=u(jr*Gr),td=u(Ue*Gr),rd=u(pt*jr);return new w(Qf,ed,rd,td)}subtract(p){return this.add(p.negate())}wNAF(p){return L.wNAFCached(this,p,w.normalizeZ)}multiply(p){let B=p;Ve("scalar",B,Le,n);let{p:P,f:D}=this.wNAF(B);return w.normalizeZ([P,D])[0]}multiplyUnsafe(p){let B=p;return Ve("scalar",B,Xe,n),B===Xe?F:this.equals(F)||B===Le?this:this.equals(T)?this.wNAF(B).p:L.unsafeLadder(this,B)}isSmallOrder(){return this.multiplyUnsafe(c).is0()}isTorsionFree(){return L.unsafeLadder(this,n).is0()}toAffine(p){return E(this,p)}clearCofactor(){let{h:p}=e;return p===Le?this:this.multiplyUnsafe(p)}static fromHex(p,B=!1){let{d:P,a:D}=e,M=t.BYTES;p=ae("pointHex",p,M),Je("zip215",B);let q=p.slice(),G=p[M-1];q[M-1]=G&-129;let z=Ft(q),X=B?f:t.ORDER;Ve("pointHex.y",z,Xe,X);let re=u(z*z),he=u(re-Le),pe=u(P*re-D),{isValid:ye,value:Ie}=d(he,pe);if(!ye)throw new Error("Point.fromHex: invalid y coordinate");let le=(Ie&Le)===Le,Ue=(G&128)!==0;if(!B&&Ie===Xe&&Ue)throw new Error("Point.fromHex: x=0 and x_0=1");return Ue!==le&&(Ie=u(-Ie)),w.fromAffine({x:Ie,y:z})}static fromPrivateKey(p){return v(p).point}toRawBytes(){let{x:p,y:B}=this.toAffine(),P=Xt(B,t.BYTES);return P[P.length-1]|=p&Le?128:0,P}toHex(){return xt(this.toRawBytes())}}w.BASE=new w(e.Gx,e.Gy,Le,u(e.Gx*e.Gy)),w.ZERO=new w(Xe,Le,Le,Xe);let{BASE:T,ZERO:F}=w,L=jn(w,a*8);function U(m){return ee(m,n)}function g(m){return U(Ft(m))}function v(m){let p=a;m=ae("private key",m,p);let B=ae("hashed private key",i(m),2*p),P=b(B.slice(0,p)),D=B.slice(p,2*p),M=g(P),q=T.multiply(M),G=q.toRawBytes();return{head:P,prefix:D,scalar:M,point:q,pointBytes:G}}function O(m){return v(m).pointBytes}function R(m=new Uint8Array,...p){let B=bt(...p);return g(i(I(B,ae("context",m),!!o)))}function N(m,p,B={}){m=ae("message",m),o&&(m=o(m));let{prefix:P,scalar:D,pointBytes:M}=v(p),q=R(B.context,P,m),G=T.multiply(q).toRawBytes(),z=R(B.context,G,M,m),X=U(q+z*D);Ve("signature.s",X,Xe,n);let re=bt(G,Xt(X,t.BYTES));return ae("result",re,a*2)}let H=u0;function A(m,p,B,P=H){let{context:D,zip215:M}=P,q=t.BYTES;m=ae("signature",m,2*q),p=ae("message",p),M!==void 0&&Je("zip215",M),o&&(p=o(p));let G=Ft(m.slice(q,2*q)),z,X,re;try{z=w.fromHex(B,M),X=w.fromHex(m.slice(0,q),M),re=T.multiplyUnsafe(G)}catch{return!1}if(!M&&z.isSmallOrder())return!1;let he=R(D,X.toRawBytes(),z.toRawBytes(),p);return X.add(z.multiplyUnsafe(he)).subtract(re).clearCofactor().equals(w.ZERO)}return T._setWindowSize(8),{CURVE:e,getPublicKey:O,sign:N,verify:A,ExtendedPoint:w,utils:{getExtendedPublicKey:v,randomPrivateKey:()=>s(t.BYTES),precompute(m=8,p=w.BASE){return p._setWindowSize(m),p.multiply(BigInt(3)),p}}}}var as=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),kc=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),ly=BigInt(0),f0=BigInt(1),Cc=BigInt(2),fy=BigInt(3),d0=BigInt(5),h0=BigInt(8);function p0(r){let e=BigInt(10),t=BigInt(20),n=BigInt(40),o=BigInt(80),i=as,a=r*r%i*r%i,c=ie(a,Cc,i)*a%i,f=ie(c,f0,i)*r%i,u=ie(f,d0,i)*f%i,l=ie(u,e,i)*u%i,d=ie(l,t,i)*l%i,b=ie(d,n,i)*d%i,I=ie(b,o,i)*b%i,x=ie(I,o,i)*b%i,h=ie(x,e,i)*u%i;return{pow_p_5_8:ie(h,Cc,i)*r%i,b2:a}}function m0(r){return r[0]&=248,r[31]&=127,r[31]|=64,r}function g0(r,e){let t=as,n=ee(e*e*e,t),o=ee(n*n*e,t),i=p0(r*o).pow_p_5_8,s=ee(r*n*i,t),a=ee(e*s*s,t),c=s,f=ee(s*kc,t),u=a===r,l=a===ee(-r,t),d=a===ee(-r*kc,t);return u&&(s=c),(l||d)&&(s=f),Ec(s,t)&&(s=ee(-s,t)),{isValid:u||l,value:s}}var y0=Dt(as,void 0,!0),x0={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:y0,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:h0,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:yc,randomBytes:$n,adjustScalarBytes:m0,uvRatio:g0},Tc=Ic(x0);var Wn=32;function Nc(r,e,t){return Tc.verify(e,t instanceof Uint8Array?t:t.subarray(),r)}var Yn=class{type="Ed25519";raw;constructor(e){this.raw=cs(e,Wn)}toMultihash(){return We.digest(Jn(this))}toCID(){return Q.createV1(114,this.toMultihash())}toString(){return ne.encode(this.toMultihash().bytes).substring(1)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:ce(this.raw,e.raw)}verify(e,t){return Nc(this.raw,t,e)}};function us(r){return r=cs(r,Wn),new Yn(r)}function cs(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 Qe(r=0){return new Uint8Array(r)}var b0=Math.pow(2,7),v0=Math.pow(2,14),E0=Math.pow(2,21),ls=Math.pow(2,28),fs=Math.pow(2,35),ds=Math.pow(2,42),hs=Math.pow(2,49),J=128,Ee=127;function Pe(r){if(r<b0)return 1;if(r<v0)return 2;if(r<E0)return 3;if(r<ls)return 4;if(r<fs)return 5;if(r<ds)return 6;if(r<hs)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function ps(r,e,t=0){switch(Pe(r)){case 8:e[t++]=r&255|J,r/=128;case 7:e[t++]=r&255|J,r/=128;case 6:e[t++]=r&255|J,r/=128;case 5:e[t++]=r&255|J,r/=128;case 4:e[t++]=r&255|J,r>>>=7;case 3:e[t++]=r&255|J,r>>>=7;case 2:e[t++]=r&255|J,r>>>=7;case 1:{e[t++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return e}function B0(r,e,t=0){switch(Pe(r)){case 8:e.set(t++,r&255|J),r/=128;case 7:e.set(t++,r&255|J),r/=128;case 6:e.set(t++,r&255|J),r/=128;case 5:e.set(t++,r&255|J),r/=128;case 4:e.set(t++,r&255|J),r>>>=7;case 3:e.set(t++,r&255|J),r>>>=7;case 2:e.set(t++,r&255|J),r>>>=7;case 1:{e.set(t++,r&255),r>>>=7;break}default:throw new Error("unreachable")}return e}function ms(r,e){let t=r[e],n=0;if(n+=t&Ee,t<J||(t=r[e+1],n+=(t&Ee)<<7,t<J)||(t=r[e+2],n+=(t&Ee)<<14,t<J)||(t=r[e+3],n+=(t&Ee)<<21,t<J)||(t=r[e+4],n+=(t&Ee)*ls,t<J)||(t=r[e+5],n+=(t&Ee)*fs,t<J)||(t=r[e+6],n+=(t&Ee)*ds,t<J)||(t=r[e+7],n+=(t&Ee)*hs,t<J))return n;throw new RangeError("Could not decode varint")}function A0(r,e){let t=r.get(e),n=0;if(n+=t&Ee,t<J||(t=r.get(e+1),n+=(t&Ee)<<7,t<J)||(t=r.get(e+2),n+=(t&Ee)<<14,t<J)||(t=r.get(e+3),n+=(t&Ee)<<21,t<J)||(t=r.get(e+4),n+=(t&Ee)*ls,t<J)||(t=r.get(e+5),n+=(t&Ee)*fs,t<J)||(t=r.get(e+6),n+=(t&Ee)*ds,t<J)||(t=r.get(e+7),n+=(t&Ee)*hs,t<J))return n;throw new RangeError("Could not decode varint")}function Ar(r,e,t=0){return e==null&&(e=Qe(Pe(r))),e instanceof Uint8Array?ps(r,e,t):B0(r,e,t)}function tr(r,e=0){return r instanceof Uint8Array?ms(r,e):A0(r,e)}var gs=new Float32Array([-0]),Mt=new Uint8Array(gs.buffer);function _c(r,e,t){gs[0]=r,e[t]=Mt[0],e[t+1]=Mt[1],e[t+2]=Mt[2],e[t+3]=Mt[3]}function Vc(r,e){return Mt[0]=r[e],Mt[1]=r[e+1],Mt[2]=r[e+2],Mt[3]=r[e+3],gs[0]}var ys=new Float64Array([-0]),Be=new Uint8Array(ys.buffer);function Lc(r,e,t){ys[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 Pc(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],ys[0]}var S0=BigInt(Number.MAX_SAFE_INTEGER),I0=BigInt(Number.MIN_SAFE_INTEGER),Oe=class r{lo;hi;constructor(e,t){this.lo=e|0,this.hi=t|0}toNumber(e=!1){if(!e&&this.hi>>>31>0){let t=~this.lo+1>>>0,n=~this.hi>>>0;return t===0&&(n=n+1>>>0),-(t+n*4294967296)}return this.lo+this.hi*4294967296}toBigInt(e=!1){if(e)return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31){let t=~this.lo+1>>>0,n=~this.hi>>>0;return t===0&&(n=n+1>>>0),-(BigInt(t)+(BigInt(n)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toString(e=!1){return this.toBigInt(e).toString()}zzEncode(){let e=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^e)>>>0,this.lo=(this.lo<<1^e)>>>0,this}zzDecode(){let e=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^e)>>>0,this.hi=(this.hi>>>1^e)>>>0,this}length(){let e=this.lo,t=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return n===0?t===0?e<16384?e<128?1:2:e<2097152?3:4:t<16384?t<128?5:6:t<2097152?7:8:n<128?9:10}static fromBigInt(e){if(e===0n)return rr;if(e<S0&&e>I0)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>Fc&&(o=0n,++n>Fc&&(n=0n))),new r(Number(o),Number(n))}static fromNumber(e){if(e===0)return rr;let t=e<0;t&&(e=-e);let n=e>>>0,o=(e-n)/4294967296>>>0;return t&&(o=~o>>>0,n=~n>>>0,++n>4294967295&&(n=0,++o>4294967295&&(o=0))),new r(n,o)}static from(e){return typeof e=="number"?r.fromNumber(e):typeof e=="bigint"?r.fromBigInt(e):typeof e=="string"?r.fromBigInt(BigInt(e)):e.low!=null||e.high!=null?new r(e.low>>>0,e.high>>>0):rr}},rr=new Oe(0,0);rr.toBigInt=function(){return 0n};rr.zzEncode=rr.zzDecode=function(){return this};rr.length=function(){return 1};var Fc=4294967296n;function Oc(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 Dc(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 xs(r,e,t){let n=t,o,i;for(let s=0;s<r.length;++s)o=r.charCodeAt(s),o<128?e[t++]=o:o<2048?(e[t++]=o>>6|192,e[t++]=o&63|128):(o&64512)===55296&&((i=r.charCodeAt(s+1))&64512)===56320?(o=65536+((o&1023)<<10)+(i&1023),++s,e[t++]=o>>18|240,e[t++]=o>>12&63|128,e[t++]=o>>6&63|128,e[t++]=o&63|128):(e[t++]=o>>12|224,e[t++]=o>>6&63|128,e[t++]=o&63|128);return t-n}function et(r,e){return RangeError(`index out of range: ${r.pos} + ${e??1} > ${r.len}`)}function Xn(r,e){return(r[e-4]|r[e-3]<<8|r[e-2]<<16|r[e-1]<<24)>>>0}var ws=class{buf;pos;len;_slice=Uint8Array.prototype.subarray;constructor(e){this.buf=e,this.pos=0,this.len=e.length}uint32(){let e=4294967295;if(e=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(e=(e|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return e;if((this.pos+=5)>this.len)throw this.pos=this.len,et(this,10);return e}int32(){return this.uint32()|0}sint32(){let e=this.uint32();return e>>>1^-(e&1)|0}bool(){return this.uint32()!==0}fixed32(){if(this.pos+4>this.len)throw et(this,4);return Xn(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw et(this,4);return Xn(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw et(this,4);let e=Vc(this.buf,this.pos);return this.pos+=4,e}double(){if(this.pos+8>this.len)throw et(this,4);let e=Pc(this.buf,this.pos);return this.pos+=8,e}bytes(){let e=this.uint32(),t=this.pos,n=this.pos+e;if(n>this.len)throw et(this,e);return this.pos+=e,t===n?new Uint8Array(0):this.buf.subarray(t,n)}string(){let e=this.bytes();return Dc(e,0,e.length)}skip(e){if(typeof e=="number"){if(this.pos+e>this.len)throw et(this,e);this.pos+=e}else do if(this.pos>=this.len)throw et(this);while(this.buf[this.pos++]&128);return this}skipType(e){switch(e){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(e=this.uint32()&7)!==4;)this.skipType(e);break;case 5:this.skip(4);break;default:throw Error(`invalid wire type ${e} at offset ${this.pos}`)}return this}readLongVarint(){let e=new Oe(0,0),t=0;if(this.len-this.pos>4){for(;t<4;++t)if(e.lo=(e.lo|(this.buf[this.pos]&127)<<t*7)>>>0,this.buf[this.pos++]<128)return e;if(e.lo=(e.lo|(this.buf[this.pos]&127)<<28)>>>0,e.hi=(e.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return e;t=0}else{for(;t<3;++t){if(this.pos>=this.len)throw et(this);if(e.lo=(e.lo|(this.buf[this.pos]&127)<<t*7)>>>0,this.buf[this.pos++]<128)return e}return e.lo=(e.lo|(this.buf[this.pos++]&127)<<t*7)>>>0,e}if(this.len-this.pos>4){for(;t<5;++t)if(e.hi=(e.hi|(this.buf[this.pos]&127)<<t*7+3)>>>0,this.buf[this.pos++]<128)return e}else for(;t<5;++t){if(this.pos>=this.len)throw et(this);if(e.hi=(e.hi|(this.buf[this.pos]&127)<<t*7+3)>>>0,this.buf[this.pos++]<128)return e}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw et(this,8);let e=Xn(this.buf,this.pos+=4),t=Xn(this.buf,this.pos+=4);return new Oe(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=ms(this.buf,this.pos);return this.pos+=Pe(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 bs(r){return new ws(r instanceof Uint8Array?r:r.subarray())}function Sr(r,e,t){let n=bs(r);return e.decode(n,void 0,t)}var vs={};ke(vs,{base10:()=>k0});var k0=Ut({prefix:"9",name:"base10",alphabet:"0123456789"});var Es={};ke(Es,{base16:()=>C0,base16upper:()=>T0});var C0=se({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),T0=se({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Bs={};ke(Bs,{base2:()=>N0});var N0=se({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var As={};ke(As,{base256emoji:()=>L0});var $c=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}"),U0=$c.reduce((r,e,t)=>(r[t]=e,r),[]),R0=$c.reduce((r,e,t)=>{let n=e.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${e}`);return r[n]=t,r},[]);function _0(r){return r.reduce((e,t)=>(e+=U0[t],e),"")}function V0(r){let e=[];for(let t of r){let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);let o=R0[n];if(o==null)throw new Error(`Non-base256emoji character: ${t}`);e.push(o)}return new Uint8Array(e)}var L0=pr({prefix:"\u{1F680}",name:"base256emoji",encode:_0,decode:V0});var Ss={};ke(Ss,{base8:()=>P0});var P0=se({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Is={};ke(Is,{identity:()=>F0});var F0=pr({prefix:"\0",name:"identity",encode:r=>Ya(r),decode:r=>Wa(r)});var jy=new TextEncoder,Gy=new TextDecoder;var Ts={};ke(Ts,{sha256:()=>tn,sha512:()=>M0});function Cs({name:r,code:e,encode:t}){return new ks(r,e,t)}var ks=class{name;code;encode;constructor(e,t,n){this.name=e,this.code=t,this.encode=n}digest(e){if(e instanceof Uint8Array){let t=this.encode(e);return t instanceof Uint8Array?Ze(this.code,t):t.then(n=>Ze(this.code,n))}else throw Error("Unknown type, must be binary type")}};function Kc(r){return async e=>new Uint8Array(await crypto.subtle.digest(r,e))}var tn=Cs({name:"sha2-256",code:18,encode:Kc("SHA-256")}),M0=Cs({name:"sha2-512",code:19,encode:Kc("SHA-512")});var rn={...Is,...Bs,...Ss,...vs,...Es,...Fi,...Hi,...Oi,...Mi,...As},ix={...Ts,...zi};function zc(r,e,t,n){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:n}}}var qc=zc("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),Ns=zc("ascii","a",r=>{let e="a";for(let t=0;t<r.length;t++)e+=String.fromCharCode(r[t]);return e},r=>{r=r.substring(1);let e=Qe(r.length);for(let t=0;t<r.length;t++)e[t]=r.charCodeAt(t);return e}),$0={utf8:qc,"utf-8":qc,hex:rn.base16,latin1:Ns,ascii:Ns,binary:Ns,...rn},Qn=$0;function Z(r,e="utf8"){let t=Qn[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return t.decoder.decode(`${t.prefix}${r}`)}function Us(r){let e=r??8192,t=e>>>1,n,o=e;return function(s){if(s<1||s>t)return Qe(s);o+s>e&&(n=Qe(e),o=0);let a=n.subarray(o,o+=s);return o&7&&(o=(o|7)+1),a}}var nr=class{fn;len;next;val;constructor(e,t,n){this.fn=e,this.len=t,this.next=void 0,this.val=n}};function Rs(){}var Vs=class{head;tail;len;next;constructor(e){this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}},H0=Us();function K0(r){return globalThis.Buffer!=null?Qe(r):H0(r)}var on=class{len;head;tail;states;constructor(){this.len=0,this.head=new nr(Rs,0,0),this.tail=this.head,this.states=null}_push(e,t,n){return this.tail=this.tail.next=new nr(e,t,n),this.len+=t,this}uint32(e){return this.len+=(this.tail=this.tail.next=new Ls((e=e>>>0)<128?1:e<16384?2:e<2097152?3:e<268435456?4:5,e)).len,this}int32(e){return e<0?this._push(eo,10,Oe.fromNumber(e)):this.uint32(e)}sint32(e){return this.uint32((e<<1^e>>31)>>>0)}uint64(e){let t=Oe.fromBigInt(e);return this._push(eo,t.length(),t)}uint64Number(e){return this._push(ps,Pe(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=Oe.fromBigInt(e).zzEncode();return this._push(eo,t.length(),t)}sint64Number(e){let t=Oe.fromNumber(e).zzEncode();return this._push(eo,t.length(),t)}sint64String(e){return this.sint64(BigInt(e))}bool(e){return this._push(_s,1,e?1:0)}fixed32(e){return this._push(nn,4,e>>>0)}sfixed32(e){return this.fixed32(e)}fixed64(e){let t=Oe.fromBigInt(e);return this._push(nn,4,t.lo)._push(nn,4,t.hi)}fixed64Number(e){let t=Oe.fromNumber(e);return this._push(nn,4,t.lo)._push(nn,4,t.hi)}fixed64String(e){return this.fixed64(BigInt(e))}sfixed64(e){return this.fixed64(e)}sfixed64Number(e){return this.fixed64Number(e)}sfixed64String(e){return this.fixed64String(e)}float(e){return this._push(_c,4,e)}double(e){return this._push(Lc,8,e)}bytes(e){let t=e.length>>>0;return t===0?this._push(_s,1,0):this.uint32(t)._push(z0,t,e)}string(e){let t=Oc(e);return t!==0?this.uint32(t)._push(xs,t,e):this._push(_s,1,0)}fork(){return this.states=new Vs(this),this.head=this.tail=new nr(Rs,0,0),this.len=0,this}reset(){return this.states!=null?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new nr(Rs,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=K0(this.len),n=0;for(;e!=null;)e.fn(e.val,t,n),n+=e.len,e=e.next;return t}};function _s(r,e,t){e[t]=r&255}function q0(r,e,t){for(;r>127;)e[t++]=r&127|128,r>>>=7;e[t]=r}var Ls=class extends nr{next;constructor(e,t){super(q0,e,t),this.next=void 0}};function eo(r,e,t){for(;r.hi!==0;)e[t++]=r.lo&127|128,r.lo=(r.lo>>>7|r.hi<<25)>>>0,r.hi>>>=7;for(;r.lo>127;)e[t++]=r.lo&127|128,r.lo=r.lo>>>7;e[t++]=r.lo}function nn(r,e,t){e[t]=r&255,e[t+1]=r>>>8&255,e[t+2]=r>>>16&255,e[t+3]=r>>>24}function z0(r,e,t){e.set(r,t)}globalThis.Buffer!=null&&(on.prototype.bytes=function(r){let e=r.length>>>0;return this.uint32(e),e>0&&this._push(j0,e,r),this},on.prototype.string=function(r){let e=globalThis.Buffer.byteLength(r);return this.uint32(e),e>0&&this._push(G0,e,r),this});function j0(r,e,t){e.set(r,t)}function G0(r,e,t){r.length<40?xs(r,e,t):e.utf8Write!=null?e.utf8Write(r,t):e.set(Z(r),t)}function Ps(){return new on}function Ir(r,e){let t=Ps();return e.encode(r,t,{lengthDelimited:!1}),t.finish()}var kr;(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"})(kr||(kr={}));function to(r,e,t,n){return{name:r,type:e,encode:t,decode:n}}function sn(r){function e(o){if(r[o.toString()]==null)throw new Error("Invalid enum value");return r[o]}let t=function(i,s){let a=e(i);s.int32(a)},n=function(i){let s=i.int32();return e(s)};return to("enum",kr.VARINT,t,n)}function Cr(r,e){return to("message",kr.LENGTH_DELIMITED,r,e)}var de;(function(r){r.RSA="RSA",r.Ed25519="Ed25519",r.secp256k1="secp256k1"})(de||(de={}));var Fs;(function(r){r[r.RSA=0]="RSA",r[r.Ed25519=1]="Ed25519",r[r.secp256k1=2]="secp256k1"})(Fs||(Fs={}));(function(r){r.codec=()=>sn(Fs)})(de||(de={}));var ct;(function(r){let e;r.codec=()=>(e==null&&(e=Cr((t,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),t.Type!=null&&(n.uint32(8),de.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=de.codec().decode(t);break}case 2:{i.Data=t.bytes();break}default:{t.skipType(a&7);break}}}return i})),e),r.encode=t=>Ir(t,r.codec()),r.decode=(t,n)=>Sr(t,r.codec(),n)})(ct||(ct={}));var Os;(function(r){let e;r.codec=()=>(e==null&&(e=Cr((t,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),t.Type!=null&&(n.uint32(8),de.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=de.codec().decode(t);break}case 2:{i.Data=t.bytes();break}default:{t.skipType(a&7);break}}}return i})),e),r.encode=t=>Ir(t,r.codec()),r.decode=(t,n)=>Sr(t,r.codec(),n)})(Os||(Os={}));var gn={};ke(gn,{MAX_RSA_KEY_SIZE:()=>Go,generateRSAKeyPair:()=>Hu,jwkToJWKKeyPair:()=>Ku,jwkToPkcs1:()=>up,jwkToPkix:()=>Gs,jwkToRSAPrivateKey:()=>$u,pkcs1ToJwk:()=>Ou,pkcs1ToRSAPrivateKey:()=>Mu,pkixToJwk:()=>Du,pkixToRSAPublicKey:()=>Zs});var Z0=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),$t=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Ht=new Uint32Array(64),Ds=class extends Er{constructor(){super(64,32,8,!1),this.A=$t[0]|0,this.B=$t[1]|0,this.C=$t[2]|0,this.D=$t[3]|0,this.E=$t[4]|0,this.F=$t[5]|0,this.G=$t[6]|0,this.H=$t[7]|0}get(){let{A:e,B:t,C:n,D:o,E:i,F:s,G:a,H:c}=this;return[e,t,n,o,i,s,a,c]}set(e,t,n,o,i,s,a,c){this.A=e|0,this.B=t|0,this.C=n|0,this.D=o|0,this.E=i|0,this.F=s|0,this.G=a|0,this.H=c|0}process(e,t){for(let l=0;l<16;l++,t+=4)Ht[l]=e.getUint32(t,!1);for(let l=16;l<64;l++){let d=Ht[l-15],b=Ht[l-2],I=Ye(d,7)^Ye(d,18)^d>>>3,x=Ye(b,17)^Ye(b,19)^b>>>10;Ht[l]=x+Ht[l-7]+I+Ht[l-16]|0}let{A:n,B:o,C:i,D:s,E:a,F:c,G:f,H:u}=this;for(let l=0;l<64;l++){let d=Ye(a,6)^Ye(a,11)^Ye(a,25),b=u+d+pc(a,c,f)+Z0[l]+Ht[l]|0,x=(Ye(n,2)^Ye(n,13)^Ye(n,22))+mc(n,o,i)|0;u=f,f=c,c=a,a=s+b|0,s=i,i=o,o=n,n=b+x|0}n=n+this.A|0,o=o+this.B|0,i=i+this.C|0,s=s+this.D|0,a=a+this.E|0,c=c+this.F|0,f=f+this.G|0,u=u+this.H|0,this.set(n,o,i,s,a,c,f,u)}roundClean(){Ht.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var Tr=Mn(()=>new Ds);var j=_n(Gc());function or(r,e){let t=0;if(r.length===1)return r[0];for(let n=r.length-1;n>=0;n--)t+=r[r.length-1-n]*Math.pow(2,e*n);return t}function Kt(r,e,t=-1){let n=t,o=r,i=0,s=Math.pow(2,e);for(let a=1;a<8;a++){if(r<s){let c;if(n<0)c=new ArrayBuffer(a),i=a;else{if(n<a)return new ArrayBuffer(0);c=new ArrayBuffer(n),i=n}let f=new Uint8Array(c);for(let u=a-1;u>=0;u--){let l=Math.pow(2,u*e);f[i-u-1]=Math.floor(o/l),o-=f[i-u-1]*l}return c}s*=Math.pow(2,e)}return new ArrayBuffer(0)}function oo(...r){let e=0,t=0;for(let i of r)e+=i.length;let n=new ArrayBuffer(e),o=new Uint8Array(n);for(let i of r)o.set(i,t),t+=i.length;return o}function $s(){let r=new Uint8Array(this.valueHex);if(this.valueHex.byteLength>=2){let a=r[0]===255&&r[1]&128,c=r[0]===0&&(r[1]&128)===0;(a||c)&&this.warnings.push("Needlessly long format")}let e=new ArrayBuffer(this.valueHex.byteLength),t=new Uint8Array(e);for(let a=0;a<this.valueHex.byteLength;a++)t[a]=0;t[0]=r[0]&128;let n=or(t,8),o=new ArrayBuffer(this.valueHex.byteLength),i=new Uint8Array(o);for(let a=0;a<this.valueHex.byteLength;a++)i[a]=r[a];return i[0]&=127,or(i,8)-n}function Zc(r){let e=r<0?r*-1:r,t=128;for(let n=1;n<8;n++){if(e<=t){if(r<0){let s=t-e,a=Kt(s,8,n),c=new Uint8Array(a);return c[0]|=128,a}let o=Kt(e,8,n),i=new Uint8Array(o);if(i[0]&128){let s=o.slice(0),a=new Uint8Array(s);o=new ArrayBuffer(o.byteLength+1),i=new Uint8Array(o);for(let c=0;c<s.byteLength;c++)i[c+1]=a[c];i[0]=0}return o}t*=Math.pow(2,8)}return new ArrayBuffer(0)}function Wc(r,e){if(r.byteLength!==e.byteLength)return!1;let t=new Uint8Array(r),n=new Uint8Array(e);for(let o=0;o<t.length;o++)if(t[o]!==n[o])return!1;return!0}function Fe(r,e){let t=r.toString(10);if(e<t.length)return"";let n=e-t.length,o=new Array(n);for(let s=0;s<n;s++)o[s]="0";return o.join("").concat(t)}var Mx=Math.log(2);function io(){if(typeof BigInt>"u")throw new Error("BigInt is not defined. Your environment doesn't implement BigInt.")}function Hs(r){let e=0,t=0;for(let o=0;o<r.length;o++){let i=r[o];e+=i.byteLength}let n=new Uint8Array(e);for(let o=0;o<r.length;o++){let i=r[o];n.set(new Uint8Array(i),t),t+=i.byteLength}return n.buffer}function St(r,e,t,n){return e instanceof Uint8Array?e.byteLength?t<0?(r.error="Wrong parameter: inputOffset less than zero",!1):n<0?(r.error="Wrong parameter: inputLength less than zero",!1):e.byteLength-t-n<0?(r.error="End of input reached before message was fully decoded (inconsistent offset and length values)",!1):!0:(r.error="Wrong parameter: inputBuffer has zero length",!1):(r.error="Wrong parameter: inputBuffer must be 'Uint8Array'",!1)}var cn=class{constructor(){this.items=[]}write(e){this.items.push(e)}final(){return Hs(this.items)}},an=[new Uint8Array([1])],Yc="0123456789";var Vr="",tt=new ArrayBuffer(0),Ks=new Uint8Array(0),un="EndOfContent",Xc="OCTET STRING",Qc="BIT STRING";function It(r){var e;return e=class extends r{constructor(...n){var o;super(...n);let i=n[0]||{};this.isHexOnly=(o=i.isHexOnly)!==null&&o!==void 0?o:!1,this.valueHexView=i.valueHex?j.BufferSourceConverter.toUint8Array(i.valueHex):Ks}get valueHex(){return this.valueHexView.slice().buffer}set valueHex(n){this.valueHexView=new Uint8Array(n)}fromBER(n,o,i){let s=n instanceof ArrayBuffer?new Uint8Array(n):n;if(!St(this,s,o,i))return-1;let a=o+i;return this.valueHexView=s.subarray(o,a),this.valueHexView.length?(this.blockLength=i,a):(this.warnings.push("Zero buffer length"),o)}toBER(n=!1){return this.isHexOnly?n?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.byteLength===this.valueHexView.buffer.byteLength?this.valueHexView.buffer:this.valueHexView.slice().buffer:(this.error="Flag 'isHexOnly' is not set, abort",tt)}toJSON(){return{...super.toJSON(),isHexOnly:this.isHexOnly,valueHex:j.Convert.ToHex(this.valueHexView)}}},e.NAME="hexBlock",e}var Et=class{constructor({blockLength:e=0,error:t=Vr,warnings:n=[],valueBeforeDecode:o=Ks}={}){this.blockLength=e,this.error=t,this.warnings=n,this.valueBeforeDecodeView=j.BufferSourceConverter.toUint8Array(o)}static blockName(){return this.NAME}get valueBeforeDecode(){return this.valueBeforeDecodeView.slice().buffer}set valueBeforeDecode(e){this.valueBeforeDecodeView=new Uint8Array(e)}toJSON(){return{blockName:this.constructor.NAME,blockLength:this.blockLength,error:this.error,warnings:this.warnings,valueBeforeDecode:j.Convert.ToHex(this.valueBeforeDecodeView)}}};Et.NAME="baseBlock";var Ae=class extends Et{fromBER(e,t,n){throw TypeError("User need to make a specific function in a class which extends 'ValueBlock'")}toBER(e,t){throw TypeError("User need to make a specific function in a class which extends 'ValueBlock'")}};Ae.NAME="valueBlock";var so=class extends It(Et){constructor({idBlock:e={}}={}){var t,n,o,i;super(),e?(this.isHexOnly=(t=e.isHexOnly)!==null&&t!==void 0?t:!1,this.valueHexView=e.valueHex?j.BufferSourceConverter.toUint8Array(e.valueHex):Ks,this.tagClass=(n=e.tagClass)!==null&&n!==void 0?n:-1,this.tagNumber=(o=e.tagNumber)!==null&&o!==void 0?o:-1,this.isConstructed=(i=e.isConstructed)!==null&&i!==void 0?i:!1):(this.tagClass=-1,this.tagNumber=-1,this.isConstructed=!1)}toBER(e=!1){let t=0;switch(this.tagClass){case 1:t|=0;break;case 2:t|=64;break;case 3:t|=128;break;case 4:t|=192;break;default:return this.error="Unknown tag class",tt}if(this.isConstructed&&(t|=32),this.tagNumber<31&&!this.isHexOnly){let o=new Uint8Array(1);if(!e){let i=this.tagNumber;i&=31,t|=i,o[0]=t}return o.buffer}if(!this.isHexOnly){let o=Kt(this.tagNumber,7),i=new Uint8Array(o),s=o.byteLength,a=new Uint8Array(s+1);if(a[0]=t|31,!e){for(let c=0;c<s-1;c++)a[c+1]=i[c]|128;a[s]=i[s-1]}return a.buffer}let n=new Uint8Array(this.valueHexView.byteLength+1);if(n[0]=t|31,!e){let o=this.valueHexView;for(let i=0;i<o.length-1;i++)n[i+1]=o[i]|128;n[this.valueHexView.byteLength]=o[o.length-1]}return n.buffer}fromBER(e,t,n){let o=j.BufferSourceConverter.toUint8Array(e);if(!St(this,o,t,n))return-1;let i=o.subarray(t,t+n);if(i.length===0)return this.error="Zero buffer length",-1;switch(i[0]&192){case 0:this.tagClass=1;break;case 64:this.tagClass=2;break;case 128:this.tagClass=3;break;case 192:this.tagClass=4;break;default:return this.error="Unknown tag class",-1}this.isConstructed=(i[0]&32)===32,this.isHexOnly=!1;let a=i[0]&31;if(a!==31)this.tagNumber=a,this.blockLength=1;else{let c=1,f=this.valueHexView=new Uint8Array(255),u=255;for(;i[c]&128;){if(f[c-1]=i[c]&127,c++,c>=i.length)return this.error="End of input reached before message was fully decoded",-1;if(c===u){u+=255;let d=new Uint8Array(u);for(let b=0;b<f.length;b++)d[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 d=0;d<c;d++)l[d]=f[d];f=this.valueHexView=new Uint8Array(c),f.set(l),this.blockLength<=9?this.tagNumber=or(f,7):(this.isHexOnly=!0,this.warnings.push("Tag too long, represented as hex-coded"))}if(this.tagClass===1&&this.isConstructed)switch(this.tagNumber){case 1:case 2:case 5:case 6:case 9:case 13:case 14:case 23:case 24:case 31:case 32:case 33:case 34:return this.error="Constructed encoding used for primitive type",-1}return t+this.blockLength}toJSON(){return{...super.toJSON(),tagClass:this.tagClass,tagNumber:this.tagNumber,isConstructed:this.isConstructed}}};so.NAME="identificationBlock";var ao=class extends Et{constructor({lenBlock:e={}}={}){var t,n,o;super(),this.isIndefiniteForm=(t=e.isIndefiniteForm)!==null&&t!==void 0?t:!1,this.longFormUsed=(n=e.longFormUsed)!==null&&n!==void 0?n:!1,this.length=(o=e.length)!==null&&o!==void 0?o:0}fromBER(e,t,n){let o=j.BufferSourceConverter.toUint8Array(e);if(!St(this,o,t,n))return-1;let i=o.subarray(t,t+n);if(i.length===0)return this.error="Zero buffer length",-1;if(i[0]===255)return this.error="Length block 0xFF is reserved by standard",-1;if(this.isIndefiniteForm=i[0]===128,this.isIndefiniteForm)return this.blockLength=1,t+this.blockLength;if(this.longFormUsed=!!(i[0]&128),this.longFormUsed===!1)return this.length=i[0],this.blockLength=1,t+this.blockLength;let s=i[0]&127;if(s>8)return this.error="Too big integer",-1;if(s+1>i.length)return this.error="End of input reached before message was fully decoded",-1;let a=t+1,c=o.subarray(a,a+s);return c[s-1]===0&&this.warnings.push("Needlessly long encoded length"),this.length=or(c,8),this.longFormUsed&&this.length<=127&&this.warnings.push("Unnecessary usage of long length form"),this.blockLength=s+1,t+this.blockLength}toBER(e=!1){let t,n;if(this.length>127&&(this.longFormUsed=!0),this.isIndefiniteForm)return t=new ArrayBuffer(1),e===!1&&(n=new Uint8Array(t),n[0]=128),t;if(this.longFormUsed){let o=Kt(this.length,8);if(o.byteLength>127)return this.error="Too big length",tt;if(t=new ArrayBuffer(o.byteLength+1),e)return t;let i=new Uint8Array(o);n=new Uint8Array(t),n[0]=o.byteLength|128;for(let s=0;s<o.byteLength;s++)n[s+1]=i[s];return t}return t=new ArrayBuffer(1),e===!1&&(n=new Uint8Array(t),n[0]=this.length),t}toJSON(){return{...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,longFormUsed:this.longFormUsed,length:this.length}}};ao.NAME="lengthBlock";var _={},xe=class extends Et{constructor({name:e=Vr,optional:t=!1,primitiveSchema:n,...o}={},i){super(o),this.name=e,this.optional=t,n&&(this.primitiveSchema=n),this.idBlock=new so(o),this.lenBlock=new ao(o),this.valueBlock=i?new i(o):new 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 cn;t||eu(this);let o=this.idBlock.toBER(e);if(n.write(o),this.lenBlock.isIndefiniteForm)n.write(new Uint8Array([128]).buffer),this.valueBlock.toBER(e,n),n.write(new ArrayBuffer(2));else{let i=this.valueBlock.toBER(e);this.lenBlock.length=i.byteLength;let s=this.lenBlock.toBER(e);n.write(s),n.write(i)}return t?tt:n.final()}toJSON(){let e={...super.toJSON(),idBlock:this.idBlock.toJSON(),lenBlock:this.lenBlock.toJSON(),valueBlock:this.valueBlock.toJSON(),name:this.name,optional:this.optional};return this.primitiveSchema&&(e.primitiveSchema=this.primitiveSchema.toJSON()),e}toString(e="ascii"){return e==="ascii"?this.onAsciiEncoding():j.Convert.ToHex(this.toBER())}onAsciiEncoding(){return`${this.constructor.NAME} : ${j.Convert.ToHex(this.valueBlock.valueBeforeDecodeView)}`}isEqual(e){if(this===e)return!0;if(!(e instanceof this.constructor))return!1;let t=this.toBER(),n=e.toBER();return Wc(t,n)}};xe.NAME="BaseBlock";function eu(r){if(r instanceof _.Constructed)for(let e of r.valueBlock.value)eu(e)&&(r.lenBlock.isIndefiniteForm=!0);return!!r.lenBlock.isIndefiniteForm}var co=class extends xe{constructor({value:e=Vr,...t}={},n){super(t,n),e&&this.fromString(e)}getValue(){return this.valueBlock.value}setValue(e){this.valueBlock.value=e}fromBER(e,t,n){let o=this.valueBlock.fromBER(e,t,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length);return o===-1?(this.error=this.valueBlock.error,o):(this.fromBuffer(this.valueBlock.valueHexView),this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),o)}onAsciiEncoding(){return`${this.constructor.NAME} : '${this.valueBlock.value}'`}};co.NAME="BaseStringBlock";var uo=class extends It(Ae){constructor({isHexOnly:e=!0,...t}={}){super(t),this.isHexOnly=e}};uo.NAME="PrimitiveValueBlock";var tu,lo=class extends xe{constructor(e={}){super(e,uo),this.idBlock.isConstructed=!1}};tu=lo;_.Primitive=tu;lo.NAME="PRIMITIVE";function np(r,e){if(r instanceof e)return r;let t=new e;return t.idBlock=r.idBlock,t.lenBlock=r.lenBlock,t.warnings=r.warnings,t.valueBeforeDecodeView=r.valueBeforeDecodeView,t}function zo(r,e=0,t=r.length){let n=e,o=new xe({},Ae),i=new Et;if(!St(i,r,e,t))return o.error=i.error,{offset:-1,result:o};if(!r.subarray(e,e+t).length)return o.error="Zero buffer length",{offset:-1,result:o};let a=o.idBlock.fromBER(r,e,t);if(o.idBlock.warnings.length&&o.warnings.concat(o.idBlock.warnings),a===-1)return o.error=o.idBlock.error,{offset:-1,result:o};if(e=a,t-=o.idBlock.blockLength,a=o.lenBlock.fromBER(r,e,t),o.lenBlock.warnings.length&&o.warnings.concat(o.lenBlock.warnings),a===-1)return o.error=o.lenBlock.error,{offset:-1,result:o};if(e=a,t-=o.lenBlock.blockLength,!o.idBlock.isConstructed&&o.lenBlock.isIndefiniteForm)return o.error="Indefinite length form used for primitive encoding form",{offset:-1,result:o};let c=xe;switch(o.idBlock.tagClass){case 1:if(o.idBlock.tagNumber>=37&&o.idBlock.isHexOnly===!1)return o.error="UNIVERSAL 37 and upper tags are reserved by ASN.1 standard",{offset:-1,result:o};switch(o.idBlock.tagNumber){case 0:if(o.idBlock.isConstructed&&o.lenBlock.length>0)return o.error="Type [UNIVERSAL 0] is reserved",{offset:-1,result:o};c=_.EndOfContent;break;case 1:c=_.Boolean;break;case 2:c=_.Integer;break;case 3:c=_.BitString;break;case 4:c=_.OctetString;break;case 5:c=_.Null;break;case 6:c=_.ObjectIdentifier;break;case 10:c=_.Enumerated;break;case 12:c=_.Utf8String;break;case 13:c=_.RelativeObjectIdentifier;break;case 14:c=_.TIME;break;case 15:return o.error="[UNIVERSAL 15] is reserved by ASN.1 standard",{offset:-1,result:o};case 16:c=_.Sequence;break;case 17:c=_.Set;break;case 18:c=_.NumericString;break;case 19:c=_.PrintableString;break;case 20:c=_.TeletexString;break;case 21:c=_.VideotexString;break;case 22:c=_.IA5String;break;case 23:c=_.UTCTime;break;case 24:c=_.GeneralizedTime;break;case 25:c=_.GraphicString;break;case 26:c=_.VisibleString;break;case 27:c=_.GeneralString;break;case 28:c=_.UniversalString;break;case 29:c=_.CharacterString;break;case 30:c=_.BmpString;break;case 31:c=_.DATE;break;case 32:c=_.TimeOfDay;break;case 33:c=_.DateTime;break;case 34:c=_.Duration;break;default:{let f=o.idBlock.isConstructed?new _.Constructed:new _.Primitive;f.idBlock=o.idBlock,f.lenBlock=o.lenBlock,f.warnings=o.warnings,o=f}}break;case 2:case 3:case 4:default:c=o.idBlock.isConstructed?_.Constructed:_.Primitive}return o=np(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 qs(r){if(!r.byteLength){let e=new xe({},Ae);return e.error="Input buffer has zero length",{offset:-1,result:e}}return zo(j.BufferSourceConverter.toUint8Array(r).slice(),0,r.byteLength)}function op(r,e){return r?1:e}var ut=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(!St(this,o,t,n))return-1;if(this.valueBeforeDecodeView=o.subarray(t,t+n),this.valueBeforeDecodeView.length===0)return this.warnings.push("Zero buffer length"),t;let i=t;for(;op(this.isIndefiniteForm,n)>0;){let s=zo(o,i,n);if(s.offset===-1)return this.error=s.result.error,this.warnings.concat(s.result.warnings),-1;if(i=s.offset,this.blockLength+=s.result.blockLength,n-=s.result.blockLength,this.value.push(s.result),this.isIndefiniteForm&&s.result.constructor.NAME===un)break}return this.isIndefiniteForm&&(this.value[this.value.length-1].constructor.NAME===un?this.value.pop():this.warnings.push("No EndOfContent block encoded")),i}toBER(e,t){let n=t||new cn;for(let o=0;o<this.value.length;o++)this.value[o].toBER(e,n);return t?tt:n.final()}toJSON(){let e={...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,value:[]};for(let t of this.value)e.value.push(t.toJSON());return e}};ut.NAME="ConstructedValueBlock";var ru,qt=class extends xe{constructor(e={}){super(e,ut),this.idBlock.isConstructed=!0}fromBER(e,t,n){this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm;let o=this.valueBlock.fromBER(e,t,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length);return o===-1?(this.error=this.valueBlock.error,o):(this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),o)}onAsciiEncoding(){let e=[];for(let n of this.valueBlock.value)e.push(n.toString("ascii").split(`
4
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} :`}};Ou=Wt;_.Constructed=Ou;Wt.NAME="CONSTRUCTED";var _o=class extends Te{fromBER(e,t,n){return t}toBER(e){return it}};_o.override="EndOfContentValueBlock";var Pu,Uo=class extends Ae{constructor(e={}){super(e,_o),this.idBlock.tagClass=1,this.idBlock.tagNumber=0}};Pu=Uo;_.EndOfContent=Pu;Uo.NAME=kn;var Fu,Jt=class extends Ae{constructor(e={}){super(e,Te),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}`}};Fu=Jt;_.Null=Fu;Jt.NAME="NULL";var Lo=class extends _t(Te){constructor({value:e,...t}={}){super(t),t.valueHex?this.valueHexView=Z.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=Z.BufferSourceConverter.toUint8Array(e);return Ct(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,ra.call(this),this.blockLength=n,t+n):-1}toBER(){return this.valueHexView.slice()}toJSON(){return{...super.toJSON(),value:this.value}}};Lo.NAME="BooleanValueBlock";var Mu,Do=class extends Ae{constructor(e={}){super(e,Lo),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}`}};Mu=Do;_.Boolean=Mu;Do.NAME="BOOLEAN";var Vo=class extends _t(pt){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=pt.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===kn){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, OCTET STRING may consists of OCTET STRINGs only",-1}if(s!==Uu)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?pt.prototype.toBER.call(this,e,t):e?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),isConstructed:this.isConstructed}}};Vo.NAME="OctetStringValueBlock";var Hu,Tt=class r extends Ae{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},Vo),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=li(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?Wt.prototype.onAsciiEncoding.call(this):`${this.constructor.NAME} : ${Z.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 Z.BufferSourceConverter.concat(e)}};Hu=Tt;_.OctetString=Hu;Tt.NAME=Uu;var Oo=class extends _t(pt){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=pt.prototype.fromBER.call(this,e,t,n),o===-1)return o;for(let a of this.value){let c=a.constructor.NAME;if(c===kn){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, BIT STRING may consists of BIT STRINGs only",-1}if(c!==Lu)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=Z.BufferSourceConverter.toUint8Array(e);if(!Ct(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=li(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 pt.prototype.toBER.call(this,e,t);if(e)return new ArrayBuffer(this.valueHexView.byteLength+1);if(!this.valueHexView.byteLength)return it;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}}};Oo.NAME="BitStringValueBlock";var $u,Xr=class extends Ae{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},Oo),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 Wt.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)}`}}};$u=Xr;_.BitString=$u;Xr.NAME=Lu;var Ku;function Jp(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 d=u;d>=0;d--,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=So(new Uint8Array([f%10]),i);break;default:i[s-l]=f%10}}return t[0]>0&&(i=So(t,i)),i}function _u(r){if(r>=In.length)for(let e=In.length;e<=r;e++){let t=new Uint8Array([0]),n=In[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=So(t,n)),In.push(n)}return In[r]}function Xp(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 Tn=class extends _t(Te){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=ra.call(this)))}set valueDec(e){this._valueDec=e,this.isHexOnly=!1,this.valueHexView=new Uint8Array(Tu(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=Xp(_u(n),t),s="-";break;default:t=Jp(t,_u(n))}n++,o>>=1}}for(let c=0;c<t.length;c++)t[c]&&(a=!0),a&&(s+=Cu.charAt(t[c]));return a===!1&&(s+=Cu.charAt(0)),s}};Ku=Tn;Tn.NAME="IntegerValueBlock";Object.defineProperty(Ku.prototype,"valueHex",{set:function(r){this.valueHexView=new Uint8Array(r),this.setValueHex()},get:function(){return this.valueHexView.slice().buffer}});var qu,de=class r extends Ae{constructor(e={}){super(e,Tn),this.idBlock.tagClass=1,this.idBlock.tagNumber=2}toBigInt(){return Io(),BigInt(this.valueBlock.toString())}static fromBigInt(e){Io();let t=BigInt(e),n=new Rn,o=t.toString(16).replace(/^-/,""),i=new Uint8Array(Z.Convert.FromHex(o));if(t<0){let a=new Uint8Array(i.length+(i[0]&128?1:0));a[0]|=128;let f=BigInt(`0x${Z.Convert.ToHex(a)}`)+t,u=Z.BufferSourceConverter.toUint8Array(Z.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()}`}};qu=de;_.Integer=qu;de.NAME="INTEGER";var zu,Po=class extends de{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=10}};zu=Po;_.Enumerated=zu;Po.NAME="ENUMERATED";var Nn=class extends _t(Te){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=Z.BufferSourceConverter.toUint8Array(e);if(!Ct(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=mr(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),t+this.blockLength)}set valueBigInt(e){Io();let t=BigInt(e).toString(2);for(;t.length%7;)t="0"+t;let n=new Uint8Array(t.length/7);for(let o=0;o<n.length;o++)n[o]=parseInt(t.slice(o*7,o*7+7),2)+(o+1<n.length?128:0);this.fromBER(n.buffer,0,n.length)}toBER(e){if(this.isHexOnly){if(e)return new ArrayBuffer(this.valueHexView.byteLength);let o=this.valueHexView,i=new Uint8Array(this.blockLength);for(let s=0;s<this.blockLength-1;s++)i[s]=o[s]|128;return i[this.blockLength-1]=o[this.blockLength-1],i.buffer}let t=Zt(this.valueDec,7);if(t.byteLength===0)return this.error="Error during encoding SID value",it;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=Z.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}}};Nn.NAME="sidBlock";var Fo=class extends Te{constructor({value:e=Qr,...t}={}){super(t),this.value=[],e&&this.fromString(e)}fromBER(e,t,n){let o=t;for(;n>0;){let i=new Nn;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,it;t.push(o)}return na(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 Nn;if(o>Number.MAX_SAFE_INTEGER){Io();let a=BigInt(o);s.valueBigInt=a}else if(s.valueDec=parseInt(o,10),isNaN(s.valueDec))return;this.value.length||(s.isFirstSid=!0,i=!0),this.value.push(s)}while(n!==-1)}toString(){let e="",t=!1;for(let n=0;n<this.value.length;n++){t=this.value[n].isHexOnly;let o=this.value[n].toString();n!==0&&(e=`${e}.`),t?(o=`{${o}}`,this.value[n].isFirstSid?e=`2.{${o} - 80}`:e+=o):e+=o}return e}toJSON(){let e={...super.toJSON(),value:this.toString(),sidArray:[]};for(let t=0;t<this.value.length;t++)e.sidArray.push(this.value[t].toJSON());return e}};Fo.NAME="ObjectIdentifierValueBlock";var Gu,ot=class extends Ae{constructor(e={}){super(e,Fo),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()}}};Gu=ot;_.ObjectIdentifier=Gu;ot.NAME="OBJECT IDENTIFIER";var Cn=class extends _t(kt){constructor({valueDec:e=0,...t}={}){super(t),this.valueDec=e}fromBER(e,t,n){if(n===0)return t;let o=Z.BufferSourceConverter.toUint8Array(e);if(!Ct(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=mr(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=Zt(this.valueDec,7);if(t.byteLength===0)return this.error="Error during encoding SID value",it;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=Z.Convert.ToHex(this.valueHexView):e=this.valueDec.toString(),e}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}};Cn.NAME="relativeSidBlock";var Mo=class extends Te{constructor({value:e=Qr,...t}={}){super(t),this.value=[],e&&this.fromString(e)}fromBER(e,t,n){let o=t;for(;n>0;){let i=new Cn;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,it;n.push(i)}return na(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 Cn;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}};Mo.NAME="RelativeObjectIdentifierValueBlock";var ju,Ho=class extends Ae{constructor(e={}){super(e,Mo),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()}}};ju=Ho;_.RelativeObjectIdentifier=ju;Ho.NAME="RelativeObjectIdentifier";var Yu,be=class extends Wt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=16}};Yu=be;_.Sequence=Yu;be.NAME="SEQUENCE";var Zu,$o=class extends Wt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=17}};Zu=$o;_.Set=Zu;$o.NAME="SET";var Ko=class extends _t(Te){constructor({...e}={}){super(e),this.isHexOnly=!0,this.value=Qr}toJSON(){return{...super.toJSON(),value:this.value}}};Ko.NAME="StringValueBlock";var qo=class extends Ko{};qo.NAME="SimpleStringValueBlock";var Ue=class extends To{constructor({...e}={}){super(e,qo)}fromBuffer(e){this.valueBlock.value=String.fromCharCode.apply(null,Z.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}};Ue.NAME="SIMPLE STRING";var zo=class extends Ue{fromBuffer(e){this.valueBlock.valueHexView=Z.BufferSourceConverter.toUint8Array(e);try{this.valueBlock.value=Z.Convert.ToUtf8String(e)}catch(t){this.warnings.push(`Error during "decodeURIComponent": ${t}, using raw string`),this.valueBlock.value=Z.Convert.ToBinary(e)}}fromString(e){this.valueBlock.valueHexView=new Uint8Array(Z.Convert.FromUtf8String(e)),this.valueBlock.value=e}};zo.NAME="Utf8StringValueBlock";var Wu,Nt=class extends zo{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=12}};Wu=Nt;_.Utf8String=Wu;Nt.NAME="UTF8String";var Go=class extends Ue{fromBuffer(e){this.valueBlock.value=Z.Convert.ToUtf16String(e),this.valueBlock.valueHexView=Z.BufferSourceConverter.toUint8Array(e)}fromString(e){this.valueBlock.value=e,this.valueBlock.valueHexView=new Uint8Array(Z.Convert.FromUtf16String(e))}};Go.NAME="BmpStringValueBlock";var Ju,jo=class extends Go{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=30}};Ju=jo;_.BmpString=Ju;jo.NAME="BMPString";var Yo=class extends Ue{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=Zt(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}};Yo.NAME="UniversalStringValueBlock";var Xu,Zo=class extends Yo{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=28}};Xu=Zo;_.UniversalString=Xu;Zo.NAME="UniversalString";var Qu,Wo=class extends Ue{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=18}};Qu=Wo;_.NumericString=Qu;Wo.NAME="NumericString";var el,Jo=class extends Ue{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=19}};el=Jo;_.PrintableString=el;Jo.NAME="PrintableString";var tl,Xo=class extends Ue{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=20}};tl=Xo;_.TeletexString=tl;Xo.NAME="TeletexString";var rl,Qo=class extends Ue{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=21}};rl=Qo;_.VideotexString=rl;Qo.NAME="VideotexString";var nl,ei=class extends Ue{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=22}};nl=ei;_.IA5String=nl;ei.NAME="IA5String";var ol,ti=class extends Ue{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=25}};ol=ti;_.GraphicString=ol;ti.NAME="GraphicString";var il,_n=class extends Ue{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=26}};il=_n;_.VisibleString=il;_n.NAME="VisibleString";var sl,ri=class extends Ue{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=27}};sl=ri;_.GeneralString=sl;ri.NAME="GeneralString";var al,ni=class extends Ue{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=29}};al=ni;_.CharacterString=al;ni.NAME="CharacterString";var cl,Un=class extends _n{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,Z.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}}};cl=Un;_.UTCTime=cl;Un.NAME="UTCTime";var ul,oi=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,d=n.indexOf("+"),b="";if(d===-1&&(d=n.indexOf("-"),l=-1),d!==-1){if(b=n.substring(d+1),n=n.substring(0,d),b.length!==2&&b.length!==4)throw new Error("Wrong input string for conversion");let g=parseInt(b.substring(0,2),10);if(isNaN(g.valueOf()))throw new Error("Wrong input string for conversion");if(a=l*g,b.length===4){if(g=parseInt(b.substring(2,4),10),isNaN(g.valueOf()))throw new Error("Wrong input string for conversion");c=l*g}}}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}}};ul=oi;_.GeneralizedTime=ul;oi.NAME="GeneralizedTime";var ll,ii=class extends Nt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=31}};ll=ii;_.DATE=ll;ii.NAME="DATE";var fl,si=class extends Nt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=32}};fl=si;_.TimeOfDay=fl;si.NAME="TimeOfDay";var hl,ai=class extends Nt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=33}};hl=ai;_.DateTime=hl;ai.NAME="DateTime";var dl,ci=class extends Nt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=34}};dl=ci;_.Duration=dl;ci.NAME="Duration";var pl,ui=class extends Nt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=14}};pl=ui;_.TIME=pl;ui.NAME="TIME";function eg(r){let{result:e}=en(r),t=e.valueBlock.value;return{n:G(gt(t[1].toBigInt()),"base64url"),e:G(gt(t[2].toBigInt()),"base64url"),d:G(gt(t[3].toBigInt()),"base64url"),p:G(gt(t[4].toBigInt()),"base64url"),q:G(gt(t[5].toBigInt()),"base64url"),dp:G(gt(t[6].toBigInt()),"base64url"),dq:G(gt(t[7].toBigInt()),"base64url"),qi:G(gt(t[8].toBigInt()),"base64url"),kty:"RSA",alg:"RS256"}}function tg(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 O("JWK was missing components","ERR_INVALID_PARAMETERS");let t=new be({value:[new de({value:0}),de.fromBigInt(mt(z(r.n,"base64url"))),de.fromBigInt(mt(z(r.e,"base64url"))),de.fromBigInt(mt(z(r.d,"base64url"))),de.fromBigInt(mt(z(r.p,"base64url"))),de.fromBigInt(mt(z(r.q,"base64url"))),de.fromBigInt(mt(z(r.dp,"base64url"))),de.fromBigInt(mt(z(r.dq,"base64url"))),de.fromBigInt(mt(z(r.qi,"base64url")))]}).toBER();return new Uint8Array(t,0,t.byteLength)}function rg(r){let{result:e}=en(r),t=e.valueBlock.value[1].valueBlock.value[0].valueBlock.value;return{kty:"RSA",n:G(gt(t[0].toBigInt()),"base64url"),e:G(gt(t[1].toBigInt()),"base64url")}}function ng(r){if(r.n==null||r.e==null)throw new O("JWK was missing components","ERR_INVALID_PARAMETERS");let t=new be({value:[new be({value:[new ot({value:"1.2.840.113549.1.1.1"}),new Jt]}),new Xr({valueHex:new be({value:[de.fromBigInt(mt(z(r.n,"base64url"))),de.fromBigInt(mt(z(r.e,"base64url")))]}).toBER()})]}).toBER();return new Uint8Array(t,0,t.byteLength)}function gt(r){let e=r.toString(16);e.length%2>0&&(e=`0${e}`);let t=e.length/2,n=new Uint8Array(t),o=0,i=0;for(;o<t;)n[o]=parseInt(e.slice(i,i+2),16),o+=1,i+=2;return n}function mt(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(""))}var og=16,ia=32,sa=1e4;async function ig(r,e){let t=_e.get(),o=new be({value:[new de({value:0}),new be({value:[new ot({value:"1.2.840.113549.1.1.1"}),new Jt]}),new Tt({valueHex:r.marshal()})]}).toBER(),i=new Uint8Array(o,0,o.byteLength),s=gr(og),a=await ea(wn,e,s,{c:sa,dkLen:ia}),c=gr(16),f=await t.subtle.importKey("raw",a,"AES-CBC",!1,["encrypt"]),u=await t.subtle.encrypt({name:"AES-CBC",iv:c},f,i),l=new be({value:[new Tt({valueHex:s}),new de({value:sa}),new de({value:ia}),new be({value:[new ot({value:"1.2.840.113549.2.11"}),new Jt]})]}),d=new be({value:[new ot({value:"1.2.840.113549.1.5.13"}),new be({value:[new be({value:[new ot({value:"1.2.840.113549.1.5.12"}),l]}),new be({value:[new ot({value:"2.16.840.1.101.3.4.1.42"}),new Tt({valueHex:c})]})]})]}),g=new be({value:[d,new Tt({valueHex:u})]}).toBER(),h=new Uint8Array(g,0,g.byteLength);return["-----BEGIN ENCRYPTED PRIVATE KEY-----",...G(h,"base64pad").split(/(.{64})/).filter(Boolean),"-----END ENCRYPTED PRIVATE KEY-----"].join(`
8
- `)}async function sg(r,e){let t=_e.get(),n;if(r.includes("-----BEGIN ENCRYPTED PRIVATE KEY-----")){let o=z(r.replace("-----BEGIN ENCRYPTED PRIVATE KEY-----","").replace("-----END ENCRYPTED PRIVATE KEY-----","").replace(/\n/g,"").trim(),"base64pad"),{result:i}=en(o),{iv:s,salt:a,iterations:c,keySize:f,cipherText:u}=ag(i),l=await ea(wn,e,a,{c,dkLen:f}),d=await t.subtle.importKey("raw",l,"AES-CBC",!1,["decrypt"]),b=Ln(await t.subtle.decrypt({name:"AES-CBC",iv:s},d,u)),{result:g}=en(b);n=gl(g)}else if(r.includes("-----BEGIN PRIVATE KEY-----")){let o=z(r.replace("-----BEGIN PRIVATE KEY-----","").replace("-----END PRIVATE KEY-----","").replace(/\n/g,"").trim(),"base64pad"),{result:i}=en(o);n=gl(i)}else throw new O("Could not parse private key from PEM data","ERR_INVALID_PARAMETERS");return aa(n)}function ag(r){let e=r.valueBlock.value[0];if(e.valueBlock.value[0].toString()!=="OBJECT IDENTIFIER : 1.2.840.113549.1.5.13")throw new O("Only pkcs5PBES2 encrypted private keys are supported","ERR_INVALID_PARAMS");let n=e.valueBlock.value[1].valueBlock.value[0];if(n.valueBlock.value[0].toString()!=="OBJECT IDENTIFIER : 1.2.840.113549.1.5.12")throw new O("Only pkcs5PBKDF2 key derivation functions are supported","ERR_INVALID_PARAMS");let i=n.valueBlock.value[1],s=Ln(i.valueBlock.value[0].getValue()),a=sa,c=ia;if(i.valueBlock.value.length===3)a=Number(i.valueBlock.value[1].toBigInt()),c=Number(i.valueBlock.value[2].toBigInt());else if(i.valueBlock.value.length===2)throw new O("Could not derive key size and iterations from PEM file - please use @libp2p/rsa to re-import your key","ERR_INVALID_PARAMS");let f=e.valueBlock.value[1].valueBlock.value[1],u=f.valueBlock.value[0].toString();if(u!=="OBJECT IDENTIFIER : 1.2.840.113549.3.7"){if(u!=="OBJECT IDENTIFIER : 1.3.14.3.2.7"){if(u!=="OBJECT IDENTIFIER : 2.16.840.1.101.3.4.1.2"){if(u!=="OBJECT IDENTIFIER : 2.16.840.1.101.3.4.1.22"){if(u!=="OBJECT IDENTIFIER : 2.16.840.1.101.3.4.1.42")throw new O("Only AES-CBC encryption schemes are supported","ERR_INVALID_PARAMS")}}}}let l=Ln(f.valueBlock.value[1].getValue());return{cipherText:Ln(r.valueBlock.value[1].getValue()),salt:s,iterations:a,keySize:c,iv:l}}function gl(r){return Ln(r.valueBlock.value[2].getValue())}function Ln(r){return new Uint8Array(r,0,r.byteLength)}async function ml(r){let e=await _e.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 bl(e);return{privateKey:t[0],publicKey:t[1]}}async function ca(r){let t=[await _e.get().subtle.importKey("jwk",r,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["sign"]),await cg(r)],n=await bl({privateKey:t[0],publicKey:t[1]});return{privateKey:n[0],publicKey:n[1]}}async function yl(r,e){let t=await _e.get().subtle.importKey("jwk",r,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["sign"]),n=await _e.get().subtle.sign({name:"RSASSA-PKCS1-v1_5"},t,e instanceof Uint8Array?e:e.subarray());return new Uint8Array(n,0,n.byteLength)}async function wl(r,e,t){let n=await _e.get().subtle.importKey("jwk",r,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["verify"]);return _e.get().subtle.verify({name:"RSASSA-PKCS1-v1_5"},n,e,t instanceof Uint8Array?t:t.subarray())}async function bl(r){if(r.privateKey==null||r.publicKey==null)throw new O("Private and public key are required","ERR_INVALID_PARAMETERS");return Promise.all([_e.get().subtle.exportKey("jwk",r.privateKey),_e.get().subtle.exportKey("jwk",r.publicKey)])}async function cg(r){return _e.get().subtle.importKey("jwk",{kty:r.kty,n:r.n,e:r.e},{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["verify"])}function fi(r){if(r.kty!=="RSA")throw new O("invalid key type","ERR_INVALID_KEY_TYPE");if(r.n==null)throw new O("invalid key modulus","ERR_INVALID_KEY_MODULUS");return z(r.n,"base64url").length*8}var Vn=8192,Dn=class{_key;constructor(e){this._key=e}verify(e,t){return wl(this._key,t,e)}marshal(){return Xt.jwkToPkix(this._key)}get bytes(){return dt.encode({Type:fe.RSA,Data:this.marshal()}).subarray()}equals(e){return ce(this.bytes,e.bytes)}hash(){let e=Be.digest(this.bytes);return Ye(e)?e.then(({bytes:t})=>t):e.bytes}},tn=class{_key;_publicKey;constructor(e,t){this._key=e,this._publicKey=t}genSecret(){return gr(16)}sign(e){return yl(this._key,e)}get public(){if(this._publicKey==null)throw new O("public key not provided","ERR_PUBKEY_NOT_PROVIDED");return new Dn(this._publicKey)}marshal(){return Xt.jwkToPkcs1(this._key)}get bytes(){return It.encode({Type:fe.RSA,Data:this.marshal()}).subarray()}equals(e){return ce(this.bytes,e.bytes)}hash(){let e=Be.digest(this.bytes);return Ye(e)?e.then(({bytes:t})=>t):e.bytes}async id(){let e=await this.public.hash();return G(e,"base58btc")}async export(e,t="pkcs-8"){if(t==="pkcs-8")return Xt.exportToPem(this,e);if(t==="libp2p-key")return zr(this.bytes,e);throw new O(`export format '${t}' is not supported`,"ERR_INVALID_EXPORT_FORMAT")}};async function aa(r){let e=Xt.pkcs1ToJwk(r);if(fi(e)>Vn)throw new O("key size is too large","ERR_KEY_SIZE_TOO_LARGE");let t=await ca(e);return new tn(t.privateKey,t.publicKey)}function lg(r){let e=Xt.pkixToJwk(r);if(fi(e)>Vn)throw new O("key size is too large","ERR_KEY_SIZE_TOO_LARGE");return new Dn(e)}async function fg(r){if(fi(r)>Vn)throw new O("key size is too large","ERR_KEY_SIZE_TOO_LARGE");let e=await ca(r);return new tn(e.privateKey,e.publicKey)}async function hg(r){if(r>Vn)throw new O("key size is too large","ERR_KEY_SIZE_TOO_LARGE");let e=await ml(r);return new tn(e.privateKey,e.publicKey)}var pa={};ye(pa,{Secp256k1PrivateKey:()=>Pn,Secp256k1PublicKey:()=>On,generateKeyPair:()=>Sg,unmarshalSecp256k1PrivateKey:()=>Bg,unmarshalSecp256k1PublicKey:()=>Ag});var dg=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]),Qt=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),er=new Uint32Array(64),la=class extends Hr{constructor(){super(64,32,8,!1),this.A=Qt[0]|0,this.B=Qt[1]|0,this.C=Qt[2]|0,this.D=Qt[3]|0,this.E=Qt[4]|0,this.F=Qt[5]|0,this.G=Qt[6]|0,this.H=Qt[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)er[l]=e.getUint32(t,!1);for(let l=16;l<64;l++){let d=er[l-15],b=er[l-2],g=tt(d,7)^tt(d,18)^d>>>3,h=tt(b,17)^tt(b,19)^b>>>10;er[l]=h+er[l-7]+g+er[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 d=tt(a,6)^tt(a,11)^tt(a,25),b=u+d+Xc(a,c,f)+dg[l]+er[l]|0,h=(tt(n,2)^tt(n,13)^tt(n,22))+Qc(n,o,i)|0;u=f,f=c,c=a,a=s+b|0,s=i,i=o,o=n,n=b+h|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(){er.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var xl=co(()=>new la);function pg(r){let e=xn(r);ht(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:gg,hexToBytes:mg}=fo,yr={Err:class extends Error{constructor(e=""){super(e)}},_parseInt(r){let{Err:e}=yr;if(r.length<2||r[0]!==2)throw new e("Invalid signature integer tag");let t=r[1],n=r.subarray(2,t+2);if(!t||n.length!==t)throw new e("Invalid signature integer: wrong length");if(n[0]&128)throw new e("Invalid signature integer: negative");if(n[0]===0&&!(n[1]&128))throw new e("Invalid signature integer: unnecessary leading zero");return{d:gg(n),l:r.subarray(t+2)}},toSig(r){let{Err:e}=yr,t=typeof r=="string"?mg(r):r;$r(t);let n=t.length;if(n<2||t[0]!=48)throw new e("Invalid signature tag");if(t[1]!==n-2)throw new e("Invalid signature: incorrect length");let{d:o,l:i}=yr._parseInt(t.subarray(2)),{d:s,l:a}=yr._parseInt(i);if(a.length)throw new e("Invalid signature: left bytes after parsing");return{r:o,s}},hexFromSig(r){let e=f=>Number.parseInt(f[0],16)&8?"00"+f:f,t=f=>{let u=f.toString(16);return u.length&1?`0${u}`:u},n=e(t(r.s)),o=e(t(r.r)),i=n.length/2,s=o.length/2,a=t(i),c=t(s);return`30${t(s+i+4)}02${c}${o}02${a}${n}`}},Ut=BigInt(0),We=BigInt(1),D1=BigInt(2),El=BigInt(3),V1=BigInt(4);function yg(r){let e=pg(r),{Fp:t}=e,n=e.toBytes||((g,h,p)=>{let x=h.toAffine();return At(Uint8Array.from([4]),t.toBytes(x.x),t.toBytes(x.y))}),o=e.fromBytes||(g=>{let h=g.subarray(1),p=t.fromBytes(h.subarray(0,t.BYTES)),x=t.fromBytes(h.subarray(t.BYTES,2*t.BYTES));return{x:p,y:x}});function i(g){let{a:h,b:p}=e,x=t.sqr(g),R=t.mul(x,g);return t.add(t.add(R,t.mul(g,h)),p)}if(!t.eql(t.sqr(e.Gy),i(e.Gx)))throw new Error("bad generator point: equation left != right");function s(g){return typeof g=="bigint"&&Ut<g&&g<e.n}function a(g){if(!s(g))throw new Error("Expected valid bigint: 0 < bigint < curve.n")}function c(g){let{allowedPrivateKeyLengths:h,nByteLength:p,wrapPrivateKey:x,n:R}=e;if(h&&typeof g!="bigint"){if(zt(g)&&(g=vt(g)),typeof g!="string"||!h.includes(g.length))throw new Error("Invalid key");g=g.padStart(p*2,"0")}let v;try{v=typeof g=="bigint"?g:Bt(ue("private key",g,p))}catch{throw new Error(`private key must be ${p} bytes, hex or bigint, not ${typeof g}`)}return x&&(v=re(v,R)),a(v),v}let f=new Map;function u(g){if(!(g instanceof l))throw new Error("ProjectivePoint expected")}class l{constructor(h,p,x){if(this.px=h,this.py=p,this.pz=x,h==null||!t.isValid(h))throw new Error("x required");if(p==null||!t.isValid(p))throw new Error("y required");if(x==null||!t.isValid(x))throw new Error("z required")}static fromAffine(h){let{x:p,y:x}=h||{};if(!h||!t.isValid(p)||!t.isValid(x))throw new Error("invalid affine point");if(h instanceof l)throw new Error("projective point not allowed");let R=v=>t.eql(v,t.ZERO);return R(p)&&R(x)?l.ZERO:new l(p,x,t.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(h){let p=t.invertBatch(h.map(x=>x.pz));return h.map((x,R)=>x.toAffine(p[R])).map(l.fromAffine)}static fromHex(h){let p=l.fromAffine(o(ue("pointHex",h)));return p.assertValidity(),p}static fromPrivateKey(h){return l.BASE.multiply(c(h))}_setWindowSize(h){this._WINDOW_SIZE=h,f.delete(this)}assertValidity(){if(this.is0()){if(e.allowInfinityPoint&&!t.is0(this.py))return;throw new Error("bad point: ZERO")}let{x:h,y:p}=this.toAffine();if(!t.isValid(h)||!t.isValid(p))throw new Error("bad point: x or y not FE");let x=t.sqr(p),R=i(h);if(!t.eql(x,R))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){let{y:h}=this.toAffine();if(t.isOdd)return!t.isOdd(h);throw new Error("Field doesn't support isOdd")}equals(h){u(h);let{px:p,py:x,pz:R}=this,{px:v,py:L,pz:S}=h,k=t.eql(t.mul(p,S),t.mul(v,R)),C=t.eql(t.mul(x,S),t.mul(L,R));return k&&C}negate(){return new l(this.px,t.neg(this.py),this.pz)}double(){let{a:h,b:p}=e,x=t.mul(p,El),{px:R,py:v,pz:L}=this,S=t.ZERO,k=t.ZERO,C=t.ZERO,y=t.mul(R,R),N=t.mul(v,v),V=t.mul(L,L),T=t.mul(R,v);return T=t.add(T,T),C=t.mul(R,L),C=t.add(C,C),S=t.mul(h,C),k=t.mul(x,V),k=t.add(S,k),S=t.sub(N,k),k=t.add(N,k),k=t.mul(S,k),S=t.mul(T,S),C=t.mul(x,C),V=t.mul(h,V),T=t.sub(y,V),T=t.mul(h,T),T=t.add(T,C),C=t.add(y,y),y=t.add(C,y),y=t.add(y,V),y=t.mul(y,T),k=t.add(k,y),V=t.mul(v,L),V=t.add(V,V),y=t.mul(V,T),S=t.sub(S,y),C=t.mul(V,N),C=t.add(C,C),C=t.add(C,C),new l(S,k,C)}add(h){u(h);let{px:p,py:x,pz:R}=this,{px:v,py:L,pz:S}=h,k=t.ZERO,C=t.ZERO,y=t.ZERO,N=e.a,V=t.mul(e.b,El),T=t.mul(p,v),P=t.mul(x,L),H=t.mul(R,S),J=t.add(p,x),E=t.add(v,L);J=t.mul(J,E),E=t.add(T,P),J=t.sub(J,E),E=t.add(p,R);let A=t.add(v,S);return E=t.mul(E,A),A=t.add(T,H),E=t.sub(E,A),A=t.add(x,R),k=t.add(L,S),A=t.mul(A,k),k=t.add(P,H),A=t.sub(A,k),y=t.mul(N,E),k=t.mul(V,H),y=t.add(k,y),k=t.sub(P,y),y=t.add(P,y),C=t.mul(k,y),P=t.add(T,T),P=t.add(P,T),H=t.mul(N,H),E=t.mul(V,E),P=t.add(P,H),H=t.sub(T,H),H=t.mul(N,H),E=t.add(E,H),T=t.mul(P,E),C=t.add(C,T),T=t.mul(A,E),k=t.mul(J,k),k=t.sub(k,T),T=t.mul(J,P),y=t.mul(A,y),y=t.add(y,T),new l(k,C,y)}subtract(h){return this.add(h.negate())}is0(){return this.equals(l.ZERO)}wNAF(h){return b.wNAFCached(this,f,h,p=>{let x=t.invertBatch(p.map(R=>R.pz));return p.map((R,v)=>R.toAffine(x[v])).map(l.fromAffine)})}multiplyUnsafe(h){let p=l.ZERO;if(h===Ut)return p;if(a(h),h===We)return this;let{endo:x}=e;if(!x)return b.unsafeLadder(this,h);let{k1neg:R,k1:v,k2neg:L,k2:S}=x.splitScalar(h),k=p,C=p,y=this;for(;v>Ut||S>Ut;)v&We&&(k=k.add(y)),S&We&&(C=C.add(y)),y=y.double(),v>>=We,S>>=We;return R&&(k=k.negate()),L&&(C=C.negate()),C=new l(t.mul(C.px,x.beta),C.py,C.pz),k.add(C)}multiply(h){a(h);let p=h,x,R,{endo:v}=e;if(v){let{k1neg:L,k1:S,k2neg:k,k2:C}=v.splitScalar(p),{p:y,f:N}=this.wNAF(S),{p:V,f:T}=this.wNAF(C);y=b.constTimeNegate(L,y),V=b.constTimeNegate(k,V),V=new l(t.mul(V.px,v.beta),V.py,V.pz),x=y.add(V),R=N.add(T)}else{let{p:L,f:S}=this.wNAF(p);x=L,R=S}return l.normalizeZ([x,R])[0]}multiplyAndAddUnsafe(h,p,x){let R=l.BASE,v=(S,k)=>k===Ut||k===We||!S.equals(R)?S.multiplyUnsafe(k):S.multiply(k),L=v(this,p).add(v(h,x));return L.is0()?void 0:L}toAffine(h){let{px:p,py:x,pz:R}=this,v=this.is0();h==null&&(h=v?t.ONE:t.inv(R));let L=t.mul(p,h),S=t.mul(x,h),k=t.mul(R,h);if(v)return{x:t.ZERO,y:t.ZERO};if(!t.eql(k,t.ONE))throw new Error("invZ was invalid");return{x:L,y:S}}isTorsionFree(){let{h,isTorsionFree:p}=e;if(h===We)return!0;if(p)return p(l,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h,clearCofactor:p}=e;return h===We?this:p?p(l,this):this.multiplyUnsafe(e.h)}toRawBytes(h=!0){return this.assertValidity(),n(l,this,h)}toHex(h=!0){return vt(this.toRawBytes(h))}}l.BASE=new l(e.Gx,e.Gy,t.ONE),l.ZERO=new l(t.ZERO,t.ONE,t.ZERO);let d=e.nBitLength,b=go(l,e.endo?Math.ceil(d/2):d);return{CURVE:e,ProjectivePoint:l,normPrivateKeyToScalar:c,weierstrassEquation:i,isWithinCurveOrder:s}}function wg(r){let e=xn(r);return ht(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function vl(r){let e=wg(r),{Fp:t,n}=e,o=t.BYTES+1,i=2*t.BYTES+1;function s(E){return Ut<E&&E<t.ORDER}function a(E){return re(E,n)}function c(E){return ho(E,n)}let{ProjectivePoint:f,normPrivateKeyToScalar:u,weierstrassEquation:l,isWithinCurveOrder:d}=yg({...e,toBytes(E,A,M){let B=A.toAffine(),w=t.toBytes(B.x),D=At;return M?D(Uint8Array.from([A.hasEvenY()?2:3]),w):D(Uint8Array.from([4]),w,t.toBytes(B.y))},fromBytes(E){let A=E.length,M=E[0],B=E.subarray(1);if(A===o&&(M===2||M===3)){let w=Bt(B);if(!s(w))throw new Error("Point is not on curve");let D=l(w),F;try{F=t.sqrt(D)}catch(Y){let ee=Y instanceof Error?": "+Y.message:"";throw new Error("Point is not on curve"+ee)}let $=(F&We)===We;return(M&1)===1!==$&&(F=t.neg(F)),{x:w,y:F}}else if(A===i&&M===4){let w=t.fromBytes(B.subarray(0,t.BYTES)),D=t.fromBytes(B.subarray(t.BYTES,2*t.BYTES));return{x:w,y:D}}else throw new Error(`Point of length ${A} was invalid. Expected ${o} compressed bytes or ${i} uncompressed bytes`)}}),b=E=>vt(jt(E,e.nByteLength));function g(E){let A=n>>We;return E>A}function h(E){return g(E)?a(-E):E}let p=(E,A,M)=>Bt(E.slice(A,M));class x{constructor(A,M,B){this.r=A,this.s=M,this.recovery=B,this.assertValidity()}static fromCompact(A){let M=e.nByteLength;return A=ue("compactSignature",A,M*2),new x(p(A,0,M),p(A,M,2*M))}static fromDER(A){let{r:M,s:B}=yr.toSig(ue("DER",A));return new x(M,B)}assertValidity(){if(!d(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!d(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(A){return new x(this.r,this.s,A)}recoverPublicKey(A){let{r:M,s:B,recovery:w}=this,D=C(ue("msgHash",A));if(w==null||![0,1,2,3].includes(w))throw new Error("recovery id invalid");let F=w===2||w===3?M+e.n:M;if(F>=t.ORDER)throw new Error("recovery id 2 or 3 invalid");let $=w&1?"03":"02",j=f.fromHex($+b(F)),Y=c(F),ee=a(-D*Y),W=a(B*Y),X=f.BASE.multiplyAndAddUnsafe(j,ee,W);if(!X)throw new Error("point at infinify");return X.assertValidity(),X}hasHighS(){return g(this.s)}normalizeS(){return this.hasHighS()?new x(this.r,a(-this.s),this.recovery):this}toDERRawBytes(){return ur(this.toDERHex())}toDERHex(){return yr.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return ur(this.toCompactHex())}toCompactHex(){return b(this.r)+b(this.s)}}let R={isValidPrivateKey(E){try{return u(E),!0}catch{return!1}},normPrivateKeyToScalar:u,randomPrivateKey:()=>{let E=Os(e.n);return uu(e.randomBytes(E),e.n)},precompute(E=8,A=f.BASE){return A._setWindowSize(E),A.multiply(BigInt(3)),A}};function v(E,A=!0){return f.fromPrivateKey(E).toRawBytes(A)}function L(E){let A=zt(E),M=typeof E=="string",B=(A||M)&&E.length;return A?B===o||B===i:M?B===2*o||B===2*i:E instanceof f}function S(E,A,M=!0){if(L(E))throw new Error("first arg must be private key");if(!L(A))throw new Error("second arg must be public key");return f.fromHex(A).multiply(u(E)).toRawBytes(M)}let k=e.bits2int||function(E){let A=Bt(E),M=E.length*8-e.nBitLength;return M>0?A>>BigInt(M):A},C=e.bits2int_modN||function(E){return a(k(E))},y=bn(e.nBitLength);function N(E){if(typeof E!="bigint")throw new Error("bigint expected");if(!(Ut<=E&&E<y))throw new Error(`bigint expected < 2^${e.nBitLength}`);return jt(E,e.nByteLength)}function V(E,A,M=T){if(["recovered","canonical"].some(se=>se in M))throw new Error("sign() legacy options not supported");let{hash:B,randomBytes:w}=e,{lowS:D,prehash:F,extraEntropy:$}=M;D==null&&(D=!0),E=ue("msgHash",E),F&&(E=ue("prehashed msgHash",B(E)));let j=C(E),Y=u(A),ee=[N(Y),N(j)];if($!=null&&$!==!1){let se=$===!0?w(t.BYTES):$;ee.push(ue("extraEntropy",se))}let W=At(...ee),X=j;function he(se){let Ee=k(se);if(!d(Ee))return;let ve=c(Ee),ge=f.BASE.multiply(Ee).toAffine(),Ie=a(ge.x);if(Ie===Ut)return;let bt=a(ve*a(X+Ie*Y));if(bt===Ut)return;let or=(ge.x===Ie?0:2)|Number(ge.y&We),ln=bt;return D&&g(bt)&&(ln=h(bt),or^=1),new x(Ie,ln,or)}return{seed:W,k2sig:he}}let T={lowS:e.lowS,prehash:!1},P={lowS:e.lowS,prehash:!1};function H(E,A,M=T){let{seed:B,k2sig:w}=V(E,A,M),D=e;return Us(D.hash.outputLen,D.nByteLength,D.hmac)(B,w)}f.BASE._setWindowSize(8);function J(E,A,M,B=P){let w=E;if(A=ue("msgHash",A),M=ue("publicKey",M),"strict"in B)throw new Error("options.strict was renamed to lowS");let{lowS:D,prehash:F}=B,$,j;try{if(typeof w=="string"||zt(w))try{$=x.fromDER(w)}catch(ge){if(!(ge instanceof yr.Err))throw ge;$=x.fromCompact(w)}else if(typeof w=="object"&&typeof w.r=="bigint"&&typeof w.s=="bigint"){let{r:ge,s:Ie}=w;$=new x(ge,Ie)}else throw new Error("PARSE");j=f.fromHex(M)}catch(ge){if(ge.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(D&&$.hasHighS())return!1;F&&(A=e.hash(A));let{r:Y,s:ee}=$,W=C(A),X=c(ee),he=a(W*X),se=a(Y*X),Ee=f.BASE.multiplyAndAddUnsafe(j,he,se)?.toAffine();return Ee?a(Ee.x)===Y:!1}return{CURVE:e,getPublicKey:v,getSharedSecret:S,sign:H,verify:J,ProjectivePoint:f,Signature:x,utils:R}}function bg(r){return{hash:r,hmac:(e,...t)=>Sn(r,e,ks(...t)),randomBytes:Mr}}function Bl(r,e){let t=n=>vl({...r,...bg(n)});return Object.freeze({...t(e),create:t})}var Il=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),Al=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),xg=BigInt(1),fa=BigInt(2),Sl=(r,e)=>(r+e/fa)/e;function Eg(r){let e=Il,t=BigInt(3),n=BigInt(6),o=BigInt(11),i=BigInt(22),s=BigInt(23),a=BigInt(44),c=BigInt(88),f=r*r*r%e,u=f*f*r%e,l=ie(u,t,e)*u%e,d=ie(l,t,e)*u%e,b=ie(d,fa,e)*f%e,g=ie(b,o,e)*b%e,h=ie(g,i,e)*g%e,p=ie(h,a,e)*h%e,x=ie(p,c,e)*p%e,R=ie(x,a,e)*h%e,v=ie(R,t,e)*u%e,L=ie(v,s,e)*g%e,S=ie(L,n,e)*f%e,k=ie(S,fa,e);if(!ha.eql(ha.sqr(k),r))throw new Error("Cannot find square root");return k}var ha=po(Il,void 0,void 0,{sqrt:Eg}),st=Bl({a:BigInt(0),b:BigInt(7),Fp:ha,n:Al,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:r=>{let e=Al,t=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-xg*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),i=t,s=BigInt("0x100000000000000000000000000000000"),a=Sl(i*r,e),c=Sl(-n*r,e),f=re(r-a*t-c*o,e),u=re(-a*n-c*i,e),l=f>s,d=u>s;if(l&&(f=e-f),d&&(u=e-u),f>s||u>s)throw new Error("splitScalar: Endomorphism failed, k="+r);return{k1neg:l,k1:f,k2neg:d,k2:u}}}},xl),z1=BigInt(0);var G1=st.ProjectivePoint;function Rl(){return st.utils.randomPrivateKey()}function kl(r,e){let t=Be.digest(e instanceof Uint8Array?e:e.subarray());if(Ye(t))return t.then(({digest:n})=>st.sign(n,r).toDERRawBytes()).catch(n=>{throw new O(String(n),"ERR_INVALID_INPUT")});try{return st.sign(t.digest,r).toDERRawBytes()}catch(n){throw new O(String(n),"ERR_INVALID_INPUT")}}function Tl(r,e,t){let n=Be.digest(t instanceof Uint8Array?t:t.subarray());if(Ye(n))return n.then(({digest:o})=>st.verify(e,o,r)).catch(o=>{throw new O(String(o),"ERR_INVALID_INPUT")});try{return st.verify(e,n.digest,r)}catch(o){throw new O(String(o),"ERR_INVALID_INPUT")}}function Nl(r){return st.ProjectivePoint.fromHex(r).toRawBytes(!0)}function Cl(r){try{st.getPublicKey(r,!0)}catch(e){throw new O(String(e),"ERR_INVALID_PRIVATE_KEY")}}function da(r){try{st.ProjectivePoint.fromHex(r)}catch(e){throw new O(String(e),"ERR_INVALID_PUBLIC_KEY")}}function _l(r){try{return st.getPublicKey(r,!0)}catch(e){throw new O(String(e),"ERR_INVALID_PRIVATE_KEY")}}var On=class{_key;constructor(e){da(e),this._key=e}verify(e,t){return Tl(this._key,t,e)}marshal(){return Nl(this._key)}get bytes(){return dt.encode({Type:fe.Secp256k1,Data:this.marshal()}).subarray()}equals(e){return ce(this.bytes,e.bytes)}async hash(){let e=Be.digest(this.bytes),t;return Ye(e)?{bytes:t}=await e:t=e.bytes,t}},Pn=class{_key;_publicKey;constructor(e,t){this._key=e,this._publicKey=t??_l(e),Cl(this._key),da(this._publicKey)}sign(e){return kl(this._key,e)}get public(){return new On(this._publicKey)}marshal(){return this._key}get bytes(){return It.encode({Type:fe.Secp256k1,Data:this.marshal()}).subarray()}equals(e){return ce(this.bytes,e.bytes)}hash(){let e=Be.digest(this.bytes);return Ye(e)?e.then(({bytes:t})=>t):e.bytes}async id(){let e=await this.public.hash();return G(e,"base58btc")}async export(e,t="libp2p-key"){if(t==="libp2p-key")return zr(this.bytes,e);throw new O(`export format '${t}' is not supported`,"ERR_INVALID_EXPORT_FORMAT")}};function Bg(r){return new Pn(r)}function Ag(r){return new On(r)}async function Sg(){let r=Rl();return new Pn(r)}var hi={rsa:ua,ed25519:Qs,secp256k1:pa};function Ig(r){let e=Object.keys(hi).join(" / ");return new O(`invalid or unsupported key type ${r}. Must be ${e}`,"ERR_UNSUPPORTED_KEY_TYPE")}function ga(r){let e=dt.decode(r),t=e.Data??new Uint8Array;switch(e.Type){case fe.RSA:return hi.rsa.unmarshalRsaPublicKey(t);case fe.Ed25519:return hi.ed25519.unmarshalEd25519PublicKey(t);case fe.Secp256k1:return hi.secp256k1.unmarshalSecp256k1PublicKey(t);default:throw Ig(e.Type??"unknown")}}var am=Vt(di(),1);var kg="/",Tg=new TextEncoder().encode(kg),u2=Tg[0];var cm=Vt(ya(),1);var Dl="ERR_IPNS_EXPIRED_RECORD",pi="ERR_UNRECOGNIZED_VALIDITY";var Lt="ERR_SIGNATURE_VERIFICATION";var wa="ERR_UNDEFINED_PARAMETER",Vl="ERR_INVALID_RECORD_DATA",Ol="ERR_INVALID_VALUE",Pl="ERR_INVALID_EMBEDDED_KEY";var Fl="ERR_RECORD_TOO_LARGE";var at;(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=()=>Bn(t)}(e=r.ValidityType||(r.ValidityType={}));let n;r.codec=()=>(n==null&&(n=Zr((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)=>{let s={},a=i==null?o.len:o.pos+i;for(;o.pos<a;){let c=o.uint32();switch(c>>>3){case 1:s.value=o.bytes();break;case 2:s.signatureV1=o.bytes();break;case 3:s.validityType=r.ValidityType.codec().decode(o);break;case 4:s.validity=o.bytes();break;case 5:s.sequence=o.uint64();break;case 6:s.ttl=o.uint64();break;case 7:s.pubKey=o.bytes();break;case 8:s.signatureV2=o.bytes();break;case 9:s.data=o.bytes();break;default:o.skipType(c&7);break}}return s})),n),r.encode=o=>jr(o,r.codec()),r.decode=o=>Gr(o,r.codec())})(at||(at={}));var Ng=["string","number","bigint","symbol"],Cg=["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 Hl(r){if(r===null)return"null";if(r===void 0)return"undefined";if(r===!0||r===!1)return"boolean";let e=typeof r;if(Ng.includes(e))return e;if(e==="function")return"Function";if(Array.isArray(r))return"Array";if(_g(r))return"Buffer";let t=Ug(r);return t||"Object"}function _g(r){return r&&r.constructor&&r.constructor.isBuffer&&r.constructor.isBuffer.call(null,r)}function Ug(r){let e=Object.prototype.toString.call(r).slice(8,-1);if(Cg.includes(e))return e}var m=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}};m.uint=new m(0,"uint",!0);m.negint=new m(1,"negint",!0);m.bytes=new m(2,"bytes",!0);m.string=new m(3,"string",!0);m.array=new m(4,"array",!1);m.map=new m(5,"map",!1);m.tag=new m(6,"tag",!1);m.float=new m(7,"float",!0);m.false=new m(7,"false",!0);m.true=new m(7,"true",!0);m.null=new m(7,"null",!0);m.undefined=new m(7,"undefined",!0);m.break=new m(7,"break",!0);var U=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 rn=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&typeof globalThis.Buffer.isBuffer=="function",Lg=new TextDecoder,Dg=new TextEncoder;function gi(r){return rn&&globalThis.Buffer.isBuffer(r)}function zl(r){return r instanceof Uint8Array?gi(r)?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r:Uint8Array.from(r)}var Gl=rn?(r,e,t)=>t-e>64?globalThis.Buffer.from(r.subarray(e,t)).toString("utf8"):Kl(r,e,t):(r,e,t)=>t-e>64?Lg.decode(r.subarray(e,t)):Kl(r,e,t),jl=rn?r=>r.length>64?globalThis.Buffer.from(r):$l(r):r=>r.length>64?Dg.encode(r):$l(r);var nn=rn?(r,e,t)=>gi(r)?new Uint8Array(r.subarray(e,t)):r.slice(e,t):(r,e,t)=>r.slice(e,t),Yl=rn?(r,e)=>(r=r.map(t=>t instanceof Uint8Array?t:globalThis.Buffer.from(t)),zl(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},Zl=rn?r=>globalThis.Buffer.allocUnsafe(r):r=>new Uint8Array(r);function Wl(r,e){if(gi(r)&&gi(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 $l(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 Kl(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 Vg(n)}var ql=4096;function Vg(r){let e=r.length;if(e<=ql)return String.fromCharCode.apply(String,r);let t="",n=0;for(;n<e;)t+=String.fromCharCode.apply(String,r.slice(n,n+=ql));return t}var Og=256,mi=class{constructor(e=Og){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=Zl(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=nn(n,0,this.cursor)}else t=Yl(this.chunks,this.cursor);return e&&this.reset(),t}};var K="CBOR decode error:",ba="CBOR encode error:",Fn=[];Fn[23]=1;Fn[24]=2;Fn[25]=3;Fn[26]=5;Fn[27]=9;function Dt(r,e,t){if(r.length-e<t)throw new Error(`${K} not enough data for type`)}var xe=[24,256,65536,4294967296,BigInt("18446744073709551616")];function Ke(r,e,t){Dt(r,e,1);let n=r[e];if(t.strict===!0&&n<xe[0])throw new Error(`${K} integer encoded in more bytes than necessary (strict decode)`);return n}function qe(r,e,t){Dt(r,e,2);let n=r[e]<<8|r[e+1];if(t.strict===!0&&n<xe[1])throw new Error(`${K} integer encoded in more bytes than necessary (strict decode)`);return n}function ze(r,e,t){Dt(r,e,4);let n=r[e]*16777216+(r[e+1]<<16)+(r[e+2]<<8)+r[e+3];if(t.strict===!0&&n<xe[2])throw new Error(`${K} integer encoded in more bytes than necessary (strict decode)`);return n}function Ge(r,e,t){Dt(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<xe[3])throw new Error(`${K} 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(`${K} integers outside of the safe integer range are not supported`)}function Jl(r,e,t,n){return new U(m.uint,Ke(r,e+1,n),2)}function Xl(r,e,t,n){return new U(m.uint,qe(r,e+1,n),3)}function Ql(r,e,t,n){return new U(m.uint,ze(r,e+1,n),5)}function ef(r,e,t,n){return new U(m.uint,Ge(r,e+1,n),9)}function Je(r,e){return Se(r,0,e.value)}function Se(r,e,t){if(t<xe[0]){let n=Number(t);r.push([e|n])}else if(t<xe[1]){let n=Number(t);r.push([e|24,n])}else if(t<xe[2]){let n=Number(t);r.push([e|25,n>>>8,n&255])}else if(t<xe[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<xe[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(`${K} encountered BigInt larger than allowable range`)}}Je.encodedSize=function(e){return Se.encodedSize(e.value)};Se.encodedSize=function(e){return e<xe[0]?1:e<xe[1]?2:e<xe[2]?3:e<xe[3]?5:9};Je.compareTokens=function(e,t){return e.value<t.value?-1:e.value>t.value?1:0};function tf(r,e,t,n){return new U(m.negint,-1-Ke(r,e+1,n),2)}function rf(r,e,t,n){return new U(m.negint,-1-qe(r,e+1,n),3)}function nf(r,e,t,n){return new U(m.negint,-1-ze(r,e+1,n),5)}var xa=BigInt(-1),of=BigInt(1);function sf(r,e,t,n){let o=Ge(r,e+1,n);if(typeof o!="bigint"){let i=-1-o;if(i>=Number.MIN_SAFE_INTEGER)return new U(m.negint,i,9)}if(n.allowBigInt!==!0)throw new Error(`${K} integers outside of the safe integer range are not supported`);return new U(m.negint,xa-BigInt(o),9)}function yi(r,e){let t=e.value,n=typeof t=="bigint"?t*xa-of:t*-1-1;Se(r,e.type.majorEncoded,n)}yi.encodedSize=function(e){let t=e.value,n=typeof t=="bigint"?t*xa-of:t*-1-1;return n<xe[0]?1:n<xe[1]?2:n<xe[2]?3:n<xe[3]?5:9};yi.compareTokens=function(e,t){return e.value<t.value?1:e.value>t.value?-1:0};function Mn(r,e,t,n){Dt(r,e,t+n);let o=nn(r,e+t,e+t+n);return new U(m.bytes,o,t+n)}function af(r,e,t,n){return Mn(r,e,1,t)}function cf(r,e,t,n){return Mn(r,e,2,Ke(r,e+1,n))}function uf(r,e,t,n){return Mn(r,e,3,qe(r,e+1,n))}function lf(r,e,t,n){return Mn(r,e,5,ze(r,e+1,n))}function ff(r,e,t,n){let o=Ge(r,e+1,n);if(typeof o=="bigint")throw new Error(`${K} 64-bit integer bytes lengths not supported`);return Mn(r,e,9,o)}function wi(r){return r.encodedBytes===void 0&&(r.encodedBytes=r.type===m.string?jl(r.value):r.value),r.encodedBytes}function on(r,e){let t=wi(e);Se(r,e.type.majorEncoded,t.length),r.push(t)}on.encodedSize=function(e){let t=wi(e);return Se.encodedSize(t.length)+t.length};on.compareTokens=function(e,t){return Fg(wi(e),wi(t))};function Fg(r,e){return r.length<e.length?-1:r.length>e.length?1:Wl(r,e)}function Hn(r,e,t,n,o){let i=t+n;Dt(r,e,i);let s=new U(m.string,Gl(r,e+t,e+i),i);return o.retainStringBytes===!0&&(s.byteValue=nn(r,e+t,e+i)),s}function hf(r,e,t,n){return Hn(r,e,1,t,n)}function df(r,e,t,n){return Hn(r,e,2,Ke(r,e+1,n),n)}function pf(r,e,t,n){return Hn(r,e,3,qe(r,e+1,n),n)}function gf(r,e,t,n){return Hn(r,e,5,ze(r,e+1,n),n)}function mf(r,e,t,n){let o=Ge(r,e+1,n);if(typeof o=="bigint")throw new Error(`${K} 64-bit integer string lengths not supported`);return Hn(r,e,9,o,n)}var yf=on;function sn(r,e,t,n){return new U(m.array,n,t)}function wf(r,e,t,n){return sn(r,e,1,t)}function bf(r,e,t,n){return sn(r,e,2,Ke(r,e+1,n))}function xf(r,e,t,n){return sn(r,e,3,qe(r,e+1,n))}function Ef(r,e,t,n){return sn(r,e,5,ze(r,e+1,n))}function vf(r,e,t,n){let o=Ge(r,e+1,n);if(typeof o=="bigint")throw new Error(`${K} 64-bit integer array lengths not supported`);return sn(r,e,9,o)}function Bf(r,e,t,n){if(n.allowIndefinite===!1)throw new Error(`${K} indefinite length items not allowed`);return sn(r,e,1,1/0)}function bi(r,e){Se(r,m.array.majorEncoded,e.value)}bi.compareTokens=Je.compareTokens;bi.encodedSize=function(e){return Se.encodedSize(e.value)};function an(r,e,t,n){return new U(m.map,n,t)}function Af(r,e,t,n){return an(r,e,1,t)}function Sf(r,e,t,n){return an(r,e,2,Ke(r,e+1,n))}function If(r,e,t,n){return an(r,e,3,qe(r,e+1,n))}function Rf(r,e,t,n){return an(r,e,5,ze(r,e+1,n))}function kf(r,e,t,n){let o=Ge(r,e+1,n);if(typeof o=="bigint")throw new Error(`${K} 64-bit integer map lengths not supported`);return an(r,e,9,o)}function Tf(r,e,t,n){if(n.allowIndefinite===!1)throw new Error(`${K} indefinite length items not allowed`);return an(r,e,1,1/0)}function xi(r,e){Se(r,m.map.majorEncoded,e.value)}xi.compareTokens=Je.compareTokens;xi.encodedSize=function(e){return Se.encodedSize(e.value)};function Nf(r,e,t,n){return new U(m.tag,t,1)}function Cf(r,e,t,n){return new U(m.tag,Ke(r,e+1,n),2)}function _f(r,e,t,n){return new U(m.tag,qe(r,e+1,n),3)}function Uf(r,e,t,n){return new U(m.tag,ze(r,e+1,n),5)}function Lf(r,e,t,n){return new U(m.tag,Ge(r,e+1,n),9)}function Ei(r,e){Se(r,m.tag.majorEncoded,e.value)}Ei.compareTokens=Je.compareTokens;Ei.encodedSize=function(e){return Se.encodedSize(e.value)};var zg=20,Gg=21,jg=22,Yg=23;function Df(r,e,t,n){if(n.allowUndefined===!1)throw new Error(`${K} undefined values are not supported`);return n.coerceUndefinedToNull===!0?new U(m.null,null,1):new U(m.undefined,void 0,1)}function Vf(r,e,t,n){if(n.allowIndefinite===!1)throw new Error(`${K} indefinite length items not allowed`);return new U(m.break,void 0,1)}function Ea(r,e,t){if(t){if(t.allowNaN===!1&&Number.isNaN(r))throw new Error(`${K} NaN values are not supported`);if(t.allowInfinity===!1&&(r===1/0||r===-1/0))throw new Error(`${K} Infinity values are not supported`)}return new U(m.float,r,e)}function Of(r,e,t,n){return Ea(va(r,e+1),3,n)}function Pf(r,e,t,n){return Ea(Ba(r,e+1),5,n)}function Ff(r,e,t,n){return Ea(Kf(r,e+1),9,n)}function vi(r,e,t){let n=e.value;if(n===!1)r.push([m.float.majorEncoded|zg]);else if(n===!0)r.push([m.float.majorEncoded|Gg]);else if(n===null)r.push([m.float.majorEncoded|jg]);else if(n===void 0)r.push([m.float.majorEncoded|Yg]);else{let o,i=!1;(!t||t.float64!==!0)&&(Hf(n),o=va(ct,1),n===o||Number.isNaN(n)?(ct[0]=249,r.push(ct.slice(0,3)),i=!0):($f(n),o=Ba(ct,1),n===o&&(ct[0]=250,r.push(ct.slice(0,5)),i=!0))),i||(Zg(n),o=Kf(ct,1),ct[0]=251,r.push(ct.slice(0,9)))}}vi.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){Hf(n);let o=va(ct,1);if(n===o||Number.isNaN(n))return 3;if($f(n),o=Ba(ct,1),n===o)return 5}return 9};var Mf=new ArrayBuffer(9),Xe=new DataView(Mf,1),ct=new Uint8Array(Mf,0);function Hf(r){if(r===1/0)Xe.setUint16(0,31744,!1);else if(r===-1/0)Xe.setUint16(0,64512,!1);else if(Number.isNaN(r))Xe.setUint16(0,32256,!1);else{Xe.setFloat32(0,r);let e=Xe.getUint32(0),t=(e&2139095040)>>23,n=e&8388607;if(t===255)Xe.setUint16(0,31744,!1);else if(t===0)Xe.setUint16(0,(r&2147483648)>>16|n>>13,!1);else{let o=t-127;o<-24?Xe.setUint16(0,0):o<-14?Xe.setUint16(0,(e&2147483648)>>16|1<<24+o,!1):Xe.setUint16(0,(e&2147483648)>>16|o+15<<10|n>>13,!1)}}}function va(r,e){if(r.length-e<2)throw new Error(`${K} 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 $f(r){Xe.setFloat32(0,r,!1)}function Ba(r,e){if(r.length-e<4)throw new Error(`${K} not enough data for float32`);let t=(r.byteOffset||0)+e;return new DataView(r.buffer,t,4).getFloat32(0,!1)}function Zg(r){Xe.setFloat64(0,r,!1)}function Kf(r,e){if(r.length-e<8)throw new Error(`${K} not enough data for float64`);let t=(r.byteOffset||0)+e;return new DataView(r.buffer,t,8).getFloat64(0,!1)}vi.compareTokens=Je.compareTokens;function Q(r,e,t){throw new Error(`${K} encountered invalid minor (${t}) for major ${r[e]>>>5}`)}function Bi(r){return()=>{throw new Error(`${K} ${r}`)}}var I=[];for(let r=0;r<=23;r++)I[r]=Q;I[24]=Jl;I[25]=Xl;I[26]=Ql;I[27]=ef;I[28]=Q;I[29]=Q;I[30]=Q;I[31]=Q;for(let r=32;r<=55;r++)I[r]=Q;I[56]=tf;I[57]=rf;I[58]=nf;I[59]=sf;I[60]=Q;I[61]=Q;I[62]=Q;I[63]=Q;for(let r=64;r<=87;r++)I[r]=af;I[88]=cf;I[89]=uf;I[90]=lf;I[91]=ff;I[92]=Q;I[93]=Q;I[94]=Q;I[95]=Bi("indefinite length bytes/strings are not supported");for(let r=96;r<=119;r++)I[r]=hf;I[120]=df;I[121]=pf;I[122]=gf;I[123]=mf;I[124]=Q;I[125]=Q;I[126]=Q;I[127]=Bi("indefinite length bytes/strings are not supported");for(let r=128;r<=151;r++)I[r]=wf;I[152]=bf;I[153]=xf;I[154]=Ef;I[155]=vf;I[156]=Q;I[157]=Q;I[158]=Q;I[159]=Bf;for(let r=160;r<=183;r++)I[r]=Af;I[184]=Sf;I[185]=If;I[186]=Rf;I[187]=kf;I[188]=Q;I[189]=Q;I[190]=Q;I[191]=Tf;for(let r=192;r<=215;r++)I[r]=Nf;I[216]=Cf;I[217]=_f;I[218]=Uf;I[219]=Lf;I[220]=Q;I[221]=Q;I[222]=Q;I[223]=Q;for(let r=224;r<=243;r++)I[r]=Bi("simple values are not supported");I[244]=Q;I[245]=Q;I[246]=Q;I[247]=Df;I[248]=Bi("simple values are not supported");I[249]=Of;I[250]=Pf;I[251]=Ff;I[252]=Q;I[253]=Q;I[254]=Q;I[255]=Vf;var ut=[];for(let r=0;r<24;r++)ut[r]=new U(m.uint,r,1);for(let r=-1;r>=-24;r--)ut[31-r]=new U(m.negint,r,1);ut[64]=new U(m.bytes,new Uint8Array(0),1);ut[96]=new U(m.string,"",1);ut[128]=new U(m.array,0,1);ut[160]=new U(m.map,0,1);ut[244]=new U(m.false,!1,1);ut[245]=new U(m.true,!0,1);ut[246]=new U(m.null,null,1);function Jg(){let r=[];return r[m.uint.major]=Je,r[m.negint.major]=yi,r[m.bytes.major]=on,r[m.string.major]=yf,r[m.array.major]=bi,r[m.map.major]=xi,r[m.tag.major]=Ei,r[m.float.major]=vi,r}var sE=Jg(),aE=new mi,Ai=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(`${ba} object contains circular references`);return new r(t,e)}},tr={null:new U(m.null,null),undefined:new U(m.undefined,void 0),true:new U(m.true,!0),false:new U(m.false,!1),emptyArray:new U(m.array,0),emptyMap:new U(m.map,0)},rr={number(r,e,t,n){return!Number.isInteger(r)||!Number.isSafeInteger(r)?new U(m.float,r):r>=0?new U(m.uint,r):new U(m.negint,r)},bigint(r,e,t,n){return r>=BigInt(0)?new U(m.uint,r):new U(m.negint,r)},Uint8Array(r,e,t,n){return new U(m.bytes,r)},string(r,e,t,n){return new U(m.string,r)},boolean(r,e,t,n){return r?tr.true:tr.false},null(r,e,t,n){return tr.null},undefined(r,e,t,n){return tr.undefined},ArrayBuffer(r,e,t,n){return new U(m.bytes,new Uint8Array(r))},DataView(r,e,t,n){return new U(m.bytes,new Uint8Array(r.buffer,r.byteOffset,r.byteLength))},Array(r,e,t,n){if(!r.length)return t.addBreakTokens===!0?[tr.emptyArray,new U(m.break)]:tr.emptyArray;n=Ai.createCheck(n,r);let o=[],i=0;for(let s of r)o[i++]=Aa(s,t,n);return t.addBreakTokens?[new U(m.array,r.length),o,new U(m.break)]:[new U(m.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?[tr.emptyMap,new U(m.break)]:tr.emptyMap;n=Ai.createCheck(n,r);let a=[],c=0;for(let f of i)a[c++]=[Aa(f,t,n),Aa(o?r.get(f):r[f],t,n)];return Xg(a,t),t.addBreakTokens?[new U(m.map,s),a,new U(m.break)]:[new U(m.map,s),a]}};rr.Map=rr.Object;rr.Buffer=rr.Uint8Array;for(let r of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))rr[`${r}Array`]=rr.DataView;function Aa(r,e={},t){let n=Hl(r),o=e&&e.typeEncoders&&e.typeEncoders[n]||rr[n];if(typeof o=="function"){let s=o(r,n,e,t);if(s!=null)return s}let i=rr[n];if(!i)throw new Error(`${ba} unsupported type: ${n}`);return i(r,n,e,t)}function Xg(r,e){e.mapSorter&&r.sort(e.mapSorter)}var Qg={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0},Si=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=ut[e];if(t===void 0){let n=I[e];if(!n)throw new Error(`${K} 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}},$n=Symbol.for("DONE"),Ii=Symbol.for("BREAK");function em(r,e,t){let n=[];for(let o=0;o<r.value;o++){let i=cn(e,t);if(i===Ii){if(r.value===1/0)break;throw new Error(`${K} got unexpected break to lengthed array`)}if(i===$n)throw new Error(`${K} found array but not enough entries (got ${o}, expected ${r.value})`);n[o]=i}return n}function tm(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=cn(e,t);if(a===Ii){if(r.value===1/0)break;throw new Error(`${K} got unexpected break to lengthed map`)}if(a===$n)throw new Error(`${K} found map but not enough entries (got ${s} [no key], expected ${r.value})`);if(n!==!0&&typeof a!="string")throw new Error(`${K} non-string keys not supported (got ${typeof a})`);if(t.rejectDuplicateMapKeys===!0&&(n&&i.has(a)||!n&&a in o))throw new Error(`${K} found repeat map key "${a}"`);let c=cn(e,t);if(c===$n)throw new Error(`${K} 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 cn(r,e){if(r.done())return $n;let t=r.next();if(t.type===m.break)return Ii;if(t.type.terminal)return t.value;if(t.type===m.array)return em(t,r,e);if(t.type===m.map)return tm(t,r,e);if(t.type===m.tag){if(e.tags&&typeof e.tags[t.value]=="function"){let n=cn(r,e);return e.tags[t.value](n)}throw new Error(`${K} tag not supported (${t.value})`)}throw new Error("unsupported")}function qf(r,e){if(!(r instanceof Uint8Array))throw new Error(`${K} data to decode must be a Uint8Array`);e=Object.assign({},Qg,e);let t=e.tokenizer||new Si(r,e),n=cn(t,e);if(n===$n)throw new Error(`${K} did not find any content to decode`);if(n===Ii)throw new Error(`${K} got unexpected break`);return[n,r.subarray(t.pos())]}function Sa(r,e){let[t,n]=qf(r,e);if(n.length>0)throw new Error(`${K} too many terminals, data makes no sense`);return t}var je=Vt(di(),1);var zf=Pt("ipns:utils"),Gf=z("/ipns/"),om=114,jf=async(r,e)=>{if(e==null||r==null){let n=new Error("one or more of the provided parameters are not defined");throw zf.error(n),(0,je.default)(n,wa)}let t;if(e.pubKey!=null){try{t=ga(e.pubKey)}catch(o){throw zf.error(o),o}if(!(await Cc(e.pubKey)).equals(r))throw(0,je.default)(new Error("Embedded public key did not match PeerID"),Pl)}else r.publicKey!=null&&(t=ga(r.publicKey));if(t!=null)return t;throw(0,je.default)(new Error("no public key is available"),wa)};var Yf=r=>{let e=z("ipns-signature:");return Ce([e,r])},br=r=>"signatureV1"in r?at.encode({value:z(r.value),signatureV1:r.signatureV1,validityType:r.validityType,validity:z(r.validity),sequence:r.sequence,ttl:r.ttl,pubKey:r.pubKey,signatureV2:r.signatureV2,data:r.data}):at.encode({pubKey:r.pubKey,signatureV2:r.signatureV2,data:r.data});function yt(r){let e=at.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(0,je.default)(new Error("missing data or signatureV2"),Lt);let t=Zf(e.data),n=im(t.Value),o=G(t.Validity);if(e.value!=null&&e.signatureV1!=null)return sm(e),{value:n,validityType:at.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:at.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")}var Ia=r=>Ce([Gf,r.toBytes()]),un=r=>mn(r.slice(Gf.length));var Zf=r=>{let e=Sa(r);if(e.ValidityType===0)e.ValidityType=at.ValidityType.EOL;else throw(0,je.default)(new Error("Unknown validity type"),pi);return Number.isInteger(e.Sequence)&&(e.Sequence=BigInt(e.Sequence)),Number.isInteger(e.TTL)&&(e.TTL=BigInt(e.TTL)),e},im=r=>{if(r!=null){if(ec(r))return`/ipns/${r.toCID().toString(Xn)}`;if(r instanceof Uint8Array){let n=G(r);n.startsWith("/")&&(r=n)}let e=r.toString().trim();if(e.startsWith("/")&&e.length>1)return e;let t=we.asCID(r);if(t!=null)return t.code===om?`/ipns/${t.toString(Xn)}`:`/ipfs/${t.toV1().toString()}`;try{return r instanceof Uint8Array?`/ipfs/${we.decode(r).toV1().toString()}`:`/ipfs/${we.parse(e).toV1().toString()}`}catch{}}throw(0,je.default)(new Error("Value must be a valid content path starting with /"),Ol)},sm=r=>{if(r.data==null)throw(0,je.default)(new Error("Record data is missing"),Vl);let e=Zf(r.data);if(!ce(e.Value,r.value??new Uint8Array(0)))throw(0,je.default)(new Error('Field "value" did not match between protobuf and CBOR'),Lt);if(!ce(e.Validity,r.validity??new Uint8Array(0)))throw(0,je.default)(new Error('Field "validity" did not match between protobuf and CBOR'),Lt);if(e.ValidityType!==r.validityType)throw(0,je.default)(new Error('Field "validityType" did not match between protobuf and CBOR'),Lt);if(e.Sequence!==r.sequence)throw(0,je.default)(new Error('Field "sequence" did not match between protobuf and CBOR'),Lt);if(e.TTL!==r.ttl)throw(0,je.default)(new Error('Field "ttl" did not match between protobuf and CBOR'),Lt)};var DE=Pt("ipns"),VE=Me.code,OE=60*60*1e9,um="/ipns/",PE=um.length;var Kn=Vt(di(),1),Wf=Vt(ya(),1);var Ri=Pt("ipns:validator"),lm=1024*10,fm=async(r,e)=>{let t=yt(e),n;try{let o=Yf(t.data);n=await r.verify(o,t.signatureV2)}catch{n=!1}if(!n)throw Ri.error("record signature verification failed"),(0,Kn.default)(new Error("record signature verification failed"),Lt);if(t.validityType===at.ValidityType.EOL){if(Wf.default.fromString(t.validity).toDate().getTime()<Date.now())throw Ri.error("record has expired"),(0,Kn.default)(new Error("record has expired"),Dl)}else if(t.validityType!=null)throw Ri.error("unrecognized validity type"),(0,Kn.default)(new Error("unrecognized validity type"),pi);Ri("ipns record for %s is valid",t.value)};async function Jf(r,e){if(e.byteLength>lm)throw(0,Kn.default)(new Error("record too large"),Fl);let t=un(r),n=yt(e),o=await jf(t,n);await fm(o,e)}async function*qn(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 wt(){let r={};return r.promise=new Promise((e,t)=>{r.resolve=e,r.reject=t}),r}var ka=Vt(Qf(),1);var Gn=class extends Error{constructor(e){super(e),this.name="TimeoutError"}},Ta=class extends Error{constructor(e){super(),this.name="AbortError",this.message=e}},eh=r=>globalThis.DOMException===void 0?new Ta(r):new DOMException(r),th=r=>{let e=r.reason===void 0?eh("This operation was aborted."):r.reason;return e instanceof Error?e:eh(e)};function Na(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:d}=e;d.aborted&&u(th(d)),d.addEventListener("abort",()=>{u(th(d))})}if(t===Number.POSITIVE_INFINITY){r.then(f,u);return}let l=new Gn;s=i.setTimeout.call(void 0,()=>{if(n){try{f(n())}catch(d){u(d)}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(d){u(d)}})()}).finally(()=>{c.clear()});return c.clear=()=>{i.clearTimeout.call(void 0,s),s=void 0},c}function Ca(r,e,t){let n=0,o=r.length;for(;o>0;){let i=Math.trunc(o/2),s=n+i;t(r[s],e)<=0?(n=++s,o-=i+1):o=i}return n}var jn=class{#e=[];enqueue(e,t){t={priority:0,...t};let n={priority:t.priority,run:e};if(this.size&&this.#e[this.size-1].priority>=t.priority){this.#e.push(n);return}let o=Ca(this.#e,n,(i,s)=>s.priority-i.priority);this.#e.splice(o,0,n)}dequeue(){return this.#e.shift()?.run}filter(e){return this.#e.filter(t=>t.priority===e.priority).map(t=>t.run)}get size(){return this.#e.length}};var Yn=class extends ka.default{#e;#r;#i=0;#a;#c;#p=0;#n;#u;#t;#g;#o=0;#l;#s;#m;timeout;constructor(e){if(super(),e={carryoverConcurrencyCount:!1,intervalCap:Number.POSITIVE_INFINITY,interval:0,concurrency:Number.POSITIVE_INFINITY,autoStart:!0,queueClass:jn,...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.#t=new e.queueClass,this.#g=e.queueClass,this.concurrency=e.concurrency,this.timeout=e.timeout,this.#m=e.throwOnTimeout===!0,this.#s=e.autoStart===!1}get#b(){return this.#r||this.#i<this.#a}get#x(){return this.#o<this.#l}#E(){this.#o--,this.#f(),this.emit("next")}#v(){this.#w(),this.#y(),this.#u=void 0}get#B(){let e=Date.now();if(this.#n===void 0){let t=this.#p-e;if(t<0)this.#i=this.#e?this.#o:0;else return this.#u===void 0&&(this.#u=setTimeout(()=>{this.#v()},t)),!0}return!1}#f(){if(this.#t.size===0)return this.#n&&clearInterval(this.#n),this.#n=void 0,this.emit("empty"),this.#o===0&&this.emit("idle"),!1;if(!this.#s){let e=!this.#B;if(this.#b&&this.#x){let t=this.#t.dequeue();return t?(this.emit("active"),t(),e&&this.#y(),!0):!1}}return!1}#y(){this.#r||this.#n!==void 0||(this.#n=setInterval(()=>{this.#w()},this.#c),this.#p=Date.now()+this.#c)}#w(){this.#i===0&&this.#o===0&&this.#n&&(clearInterval(this.#n),this.#n=void 0),this.#i=this.#e?this.#o: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.#m,...t},new Promise((n,o)=>{this.#t.enqueue(async()=>{this.#o++,this.#i++;try{t.signal?.throwIfAborted();let i=e({signal:t.signal});t.timeout&&(i=Na(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 Gn&&!t.throwOnTimeout){n();return}o(i),this.emit("error",i)}finally{this.#E()}},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.#t=new this.#g}async onEmpty(){this.#t.size!==0&&await this.#d("empty")}async onSizeLessThan(e){this.#t.size<e||await this.#d("next",()=>this.#t.size<e)}async onIdle(){this.#o===0&&this.#t.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.#t.size}sizeBy(e){return this.#t.filter(e).length}get pending(){return this.#o}get isPaused(){return this.#s}};function pm(r){return r[Symbol.asyncIterator]!=null}function gm(r){if(pm(r))return(async()=>{for await(let e of r)return e})();for(let e of r)return e}var Ti=gm;function mm(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 rh=mm;function ym(r){return r[Symbol.asyncIterator]!=null}function wm(r,e){let t=0;if(ym(r))return async function*(){for await(let c of r)yield e(c,t++)}();let n=rh(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 Ni=wm;var _a=z("/ipns/");function nh(r){return ce(r.subarray(0,_a.byteLength),_a)}var oh=r=>mn(r.slice(_a.length)),Ci=class{client;constructor(e){this.client=e}async*findProviders(e,t={}){yield*Ni(this.client.getProviders(e,t),n=>({id:n.ID,multiaddrs:n.Addrs??[]}))}async provide(){}async put(e,t,n){if(!nh(e))return;let o=oh(e),i=yt(t);await this.client.putIPNS(o,i,n)}async get(e,t){if(!nh(e))throw new O("Not found","ERR_NOT_FOUND");let n=oh(e);try{let o=await this.client.getIPNS(n,t);return br(o)}catch(o){throw o.code==="ERR_BAD_RESPONSE"?new O("Not found","ERR_NOT_FOUND"):o}}},_i=class{client;constructor(e){this.client=e}async findPeer(e,t={}){let n=await Ti(this.client.getPeers(e,t));if(n!=null)return{id:n.ID,multiaddrs:n.Addrs??[]};throw new O("Not found","ERR_NOT_FOUND")}async*getClosestPeers(e,t={}){}};var Oe=Pt("delegated-routing-v1-http-api-client"),ih={concurrentRequests:4,timeout:3e4},Ui=class{started;httpQueue;shutDownController;clientUrl;timeout;contentRouting;peerRouting;constructor(e,t={}){this.started=!1,this.shutDownController=new AbortController,Er(1/0,this.shutDownController.signal),this.httpQueue=new Yn({concurrency:t.concurrentRequests??ih.concurrentRequests}),this.clientUrl=e instanceof URL?e:new URL(e),this.timeout=t.timeout??ih.timeout,this.contentRouting=new Ci(this),this.peerRouting=new _i(this)}get[Qa](){return this.contentRouting}get[tc](){return this.peerRouting}isStarted(){return this.started}start(){this.started=!0}stop(){this.httpQueue.clear(),this.shutDownController.abort(),this.started=!1}async*getProviders(e,t={}){Oe("getProviders starts: %c",e);let n=AbortSignal.timeout(this.timeout),o=yn([this.shutDownController.signal,n,t.signal]);Er(1/0,n,o);let i=wt(),s=wt();this.httpQueue.add(async()=>(i.resolve(),s.promise));try{await i.promise;let a=`${this.clientUrl}routing/v1/providers/${e.toString()}`,f=await fetch(a,{headers:{Accept:"application/x-ndjson"},signal:o});if(f.status===404)throw new O("No matching records found.","ERR_NOT_FOUND");if(f.status===422)throw new O("Request does not conform to schema or semantic constraints.","ERR_INVALID_REQUEST");if(f.body==null)throw new O("Routing response had no body","ERR_BAD_RESPONSE");if(f.headers.get("Content-Type")==="application/json"){let l=await f.json();for(let d of l.Providers){let b=this.#e(d);b!=null&&(yield b)}}else for await(let l of qn(io(f.body))){let d=this.#e(l);d!=null&&(yield d)}}catch(a){Oe.error("getProviders errored:",a)}finally{o.clear(),s.resolve(),Oe("getProviders finished: %c",e)}}async*getPeers(e,t={}){Oe("getPeers starts: %c",e);let n=AbortSignal.timeout(this.timeout),o=yn([this.shutDownController.signal,n,t.signal]);Er(1/0,n,o);let i=wt(),s=wt();this.httpQueue.add(async()=>(i.resolve(),s.promise));try{await i.promise;let a=`${this.clientUrl}routing/v1/peers/${e.toCID().toString()}`,f=await fetch(a,{headers:{Accept:"application/x-ndjson"},signal:o});if(f.status===404)throw new O("No matching records found.","ERR_NOT_FOUND");if(f.status===422)throw new O("Request does not conform to schema or semantic constraints.","ERR_INVALID_REQUEST");if(f.body==null)throw new O("Routing response had no body","ERR_BAD_RESPONSE");if(f.headers.get("Content-Type")==="application/json"){let l=await f.json();for(let d of l.Peers){let b=this.#e(d);b!=null&&(yield b)}}else for await(let l of qn(io(f.body))){let d=this.#e(l);d!=null&&(yield d)}}catch(a){Oe.error("getPeers errored:",a)}finally{o.clear(),s.resolve(),Oe("getPeers finished: %c",e)}}async getIPNS(e,t={}){Oe("getIPNS starts: %c",e);let n=AbortSignal.timeout(this.timeout),o=yn([this.shutDownController.signal,n,t.signal]);Er(1/0,n,o);let i=wt(),s=wt();this.httpQueue.add(async()=>(i.resolve(),s.promise));let a=`${this.clientUrl}routing/v1/ipns/${e.toCID().toString()}`;try{await i.promise;let f=await fetch(a,{headers:{Accept:"application/vnd.ipfs.ipns-record"},signal:o});if(Oe("getIPNS GET %s %d",a,f.status),f.status===404)throw new O("No matching records found.","ERR_NOT_FOUND");if(f.status===422)throw new O("Request does not conform to schema or semantic constraints.","ERR_INVALID_REQUEST");if(f.body==null)throw new O("GET ipns response had no body","ERR_BAD_RESPONSE");let u=await f.arrayBuffer(),l=new Uint8Array(u,0,u.byteLength);return t.validate!==!1&&await Jf(Ia(e),l),yt(l)}catch(c){throw Oe.error("getIPNS GET %s error:",a,c),c}finally{o.clear(),s.resolve(),Oe("getIPNS finished: %c",e)}}async putIPNS(e,t,n={}){Oe("putIPNS starts: %c",e);let o=AbortSignal.timeout(this.timeout),i=yn([this.shutDownController.signal,o,n.signal]);Er(1/0,o,i);let s=wt(),a=wt();this.httpQueue.add(async()=>(s.resolve(),a.promise));let c=`${this.clientUrl}routing/v1/ipns/${e.toCID().toString()}`;try{await s.promise;let f=br(t),l=await fetch(c,{method:"PUT",headers:{"Content-Type":"application/vnd.ipfs.ipns-record"},body:f,signal:i});if(Oe("putIPNS PUT %s %d",c,l.status),l.status!==200)throw new O("PUT ipns response had status other than 200","ERR_BAD_RESPONSE")}catch(f){throw Oe.error("putIPNS PUT %s error:",c,f.stack),f}finally{i.clear(),a.resolve(),Oe("putIPNS finished: %c",e)}}#e(e){let t=[],n=e.Addrs?.map(cr)??[];return e.Protocols!=null&&t.push(...e.Protocols),e.Protocol!=null&&(t.push(e.Protocol),delete e.Protocol),{...e,Schema:"peer",ID:as(e.ID),Addrs:n,Protocols:t}}};function sh(r,e={}){return new Ui(new URL(r),e)}var ah=z("/ipns/");function ch(r){return ce(r.subarray(0,ah.byteLength),ah)}var Ua=class{client;constructor(e){this.client=sh(e)}async provide(e,t){}async*findProviders(e,t){yield*Ni(this.client.getProviders(e,t),n=>({id:n.ID,multiaddrs:n.Addrs,protocols:n.Protocols}))}async put(e,t,n){if(!ch(e))return;let o=un(e),i=yt(t);await this.client.putIPNS(o,i,n)}async get(e,t){if(!ch(e))throw new O("Not found","ERR_NOT_FOUND");let n=un(e);try{let o=await this.client.getIPNS(n,t);return br(o)}catch(o){throw o.code==="ERR_BAD_RESPONSE"?new O("Not found","ERR_NOT_FOUND"):o}}async findPeer(e,t){let n=await Ti(this.client.getPeers(e,t));if(n!=null)return{id:n.ID,multiaddrs:n.Addrs??[]};throw new O("Not found","ERR_NOT_FOUND")}async*getClosestPeers(e,t){}};function uh(r){return new Ua(new URL(r))}var lh="[a-fA-F\\d:]",nr=r=>r&&r.includeBoundaries?`(?:(?<=\\s|^)(?=${lh})|(?<=${lh})(?=\\s|$))`:"",lt="(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}",pe="[a-fA-F\\d]{1,4}",Li=`
7
+ `)}`:`${t} :`}};ru=qt;_.Constructed=ru;qt.NAME="CONSTRUCTED";var fo=class extends Ae{fromBER(e,t,n){return t}toBER(e){return tt}};fo.override="EndOfContentValueBlock";var nu,ho=class extends xe{constructor(e={}){super(e,fo),this.idBlock.tagClass=1,this.idBlock.tagNumber=0}};nu=ho;_.EndOfContent=nu;ho.NAME=un;var ou,Ur=class extends xe{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}`}};ou=Ur;_.Null=ou;Ur.NAME="NULL";var po=class extends It(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 St(this,o,t,n)?(this.valueHexView=o.subarray(t,t+n),n>1&&this.warnings.push("Boolean value encoded in more then 1 octet"),this.isHexOnly=!0,$s.call(this),this.blockLength=n,t+n):-1}toBER(){return this.valueHexView.slice()}toJSON(){return{...super.toJSON(),value:this.value}}};po.NAME="BooleanValueBlock";var iu,mo=class extends xe{constructor(e={}){super(e,po),this.idBlock.tagClass=1,this.idBlock.tagNumber=1}getValue(){return this.valueBlock.value}setValue(e){this.valueBlock.value=e}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.getValue}`}};iu=mo;_.Boolean=iu;mo.NAME="BOOLEAN";var go=class extends It(ut){constructor({isConstructed:e=!1,...t}={}){super(t),this.isConstructed=e}fromBER(e,t,n){let o=0;if(this.isConstructed){if(this.isHexOnly=!1,o=ut.prototype.fromBER.call(this,e,t,n),o===-1)return o;for(let i=0;i<this.value.length;i++){let s=this.value[i].constructor.NAME;if(s===un){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, OCTET STRING may consists of OCTET STRINGs only",-1}if(s!==Xc)return this.error="OCTET STRING may consists of OCTET STRINGs only",-1}}else this.isHexOnly=!0,o=super.fromBER(e,t,n),this.blockLength=n;return o}toBER(e,t){return this.isConstructed?ut.prototype.toBER.call(this,e,t):e?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),isConstructed:this.isConstructed}}};go.NAME="OctetStringValueBlock";var su,yo=class r extends xe{constructor({idBlock:e={},lenBlock:t={},...n}={}){var o,i;(o=n.isConstructed)!==null&&o!==void 0||(n.isConstructed=!!(!((i=n.value)===null||i===void 0)&&i.length)),super({idBlock:{isConstructed:n.isConstructed,...e},lenBlock:{...t,isIndefiniteForm:!!n.isIndefiniteForm},...n},go),this.idBlock.tagClass=1,this.idBlock.tagNumber=4}fromBER(e,t,n){if(this.valueBlock.isConstructed=this.idBlock.isConstructed,this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm,n===0)return this.idBlock.error.length===0&&(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length===0&&(this.blockLength+=this.lenBlock.blockLength),t;if(!this.valueBlock.isConstructed){let i=(e instanceof ArrayBuffer?new Uint8Array(e):e).subarray(t,t+n);try{if(i.byteLength){let s=zo(i,0,i.byteLength);s.offset!==-1&&s.offset===n&&(this.valueBlock.value=[s.result])}}catch{}}return super.fromBER(e,t,n)}onAsciiEncoding(){return this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length?qt.prototype.onAsciiEncoding.call(this):`${this.constructor.NAME} : ${j.Convert.ToHex(this.valueBlock.valueHexView)}`}getValue(){if(!this.idBlock.isConstructed)return this.valueBlock.valueHexView.slice().buffer;let e=[];for(let t of this.valueBlock.value)t instanceof r&&e.push(t.valueBlock.valueHexView);return j.BufferSourceConverter.concat(e)}};su=yo;_.OctetString=su;yo.NAME=Xc;var xo=class extends It(ut){constructor({unusedBits:e=0,isConstructed:t=!1,...n}={}){super(n),this.unusedBits=e,this.isConstructed=t,this.blockLength=this.valueHexView.byteLength}fromBER(e,t,n){if(!n)return t;let o=-1;if(this.isConstructed){if(o=ut.prototype.fromBER.call(this,e,t,n),o===-1)return o;for(let a of this.value){let c=a.constructor.NAME;if(c===un){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, BIT STRING may consists of BIT STRINGs only",-1}if(c!==Qc)return this.error="BIT STRING may consists of BIT STRINGs only",-1;let f=a.valueBlock;if(this.unusedBits>0&&f.unusedBits>0)return this.error='Using of "unused bits" inside constructive BIT STRING allowed for least one only',-1;this.unusedBits=f.unusedBits}return o}let i=j.BufferSourceConverter.toUint8Array(e);if(!St(this,i,t,n))return-1;let s=i.subarray(t,t+n);if(this.unusedBits=s[0],this.unusedBits>7)return this.error="Unused bits for BitString must be in range 0-7",-1;if(!this.unusedBits){let a=s.subarray(1);try{if(a.byteLength){let c=zo(a,0,a.byteLength);c.offset!==-1&&c.offset===n-1&&(this.value=[c.result])}}catch{}}return this.valueHexView=s.subarray(1),this.blockLength=s.length,t+n}toBER(e,t){if(this.isConstructed)return ut.prototype.toBER.call(this,e,t);if(e)return new ArrayBuffer(this.valueHexView.byteLength+1);if(!this.valueHexView.byteLength)return tt;let n=new Uint8Array(this.valueHexView.length+1);return n[0]=this.unusedBits,n.set(this.valueHexView,1),n.buffer}toJSON(){return{...super.toJSON(),unusedBits:this.unusedBits,isConstructed:this.isConstructed}}};xo.NAME="BitStringValueBlock";var au,Rr=class extends xe{constructor({idBlock:e={},lenBlock:t={},...n}={}){var o,i;(o=n.isConstructed)!==null&&o!==void 0||(n.isConstructed=!!(!((i=n.value)===null||i===void 0)&&i.length)),super({idBlock:{isConstructed:n.isConstructed,...e},lenBlock:{...t,isIndefiniteForm:!!n.isIndefiniteForm},...n},xo),this.idBlock.tagClass=1,this.idBlock.tagNumber=3}fromBER(e,t,n){return this.valueBlock.isConstructed=this.idBlock.isConstructed,this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm,super.fromBER(e,t,n)}onAsciiEncoding(){if(this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length)return qt.prototype.onAsciiEncoding.call(this);{let e=[],t=this.valueBlock.valueHexView;for(let o of t)e.push(o.toString(2).padStart(8,"0"));let n=e.join("");return`${this.constructor.NAME} : ${n.substring(0,n.length-this.valueBlock.unusedBits)}`}}};au=Rr;_.BitString=au;Rr.NAME=Qc;var cu;function ip(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 d=u;d>=0;d--,l++){switch(!0){case l<a.length:f=i[s-l]+a[c-l]+t[0];break;default:f=i[s-l]+t[0]}switch(t[0]=f/10,!0){case l>=i.length:i=oo(new Uint8Array([f%10]),i);break;default:i[s-l]=f%10}}return t[0]>0&&(i=oo(t,i)),i}function Jc(r){if(r>=an.length)for(let e=an.length;e<=r;e++){let t=new Uint8Array([0]),n=an[e-1].slice(0);for(let o=n.length-1;o>=0;o--){let i=new Uint8Array([(n[o]<<1)+t[0]]);t[0]=i[0]/10,n[o]=i[0]%10}t[0]>0&&(n=oo(t,n)),an.push(n)}return an[r]}function sp(r,e){let t=0,n=new Uint8Array(r),o=new Uint8Array(e),i=n.slice(0),s=i.length-1,a=o.slice(0),c=a.length-1,f,u=0;for(let l=c;l>=0;l--,u++)switch(f=i[s-u]-a[c-u]-t,!0){case f<0:t=1,i[s-u]=f+10;break;default:t=0,i[s-u]=f}if(t>0)for(let l=s-c+1;l>=0;l--,u++)if(f=i[s-u]-t,f<0)t=1,i[s-u]=f+10;else{t=0,i[s-u]=f;break}return i.slice()}var ln=class extends It(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=$s.call(this)))}set valueDec(e){this._valueDec=e,this.isHexOnly=!1,this.valueHexView=new Uint8Array(Zc(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=sp(Jc(n),t),s="-";break;default:t=ip(t,Jc(n))}n++,o>>=1}}for(let c=0;c<t.length;c++)t[c]&&(a=!0),a&&(s+=Yc.charAt(t[c]));return a===!1&&(s+=Yc.charAt(0)),s}};cu=ln;ln.NAME="IntegerValueBlock";Object.defineProperty(cu.prototype,"valueHex",{set:function(r){this.valueHexView=new Uint8Array(r),this.setValueHex()},get:function(){return this.valueHexView.slice().buffer}});var uu,we=class r extends xe{constructor(e={}){super(e,ln),this.idBlock.tagClass=1,this.idBlock.tagNumber=2}toBigInt(){return io(),BigInt(this.valueBlock.toString())}static fromBigInt(e){io();let t=BigInt(e),n=new cn,o=t.toString(16).replace(/^-/,""),i=new Uint8Array(j.Convert.FromHex(o));if(t<0){let a=new Uint8Array(i.length+(i[0]&128?1:0));a[0]|=128;let f=BigInt(`0x${j.Convert.ToHex(a)}`)+t,u=j.BufferSourceConverter.toUint8Array(j.Convert.FromHex(f.toString(16)));u[0]|=128,n.write(u)}else i[0]&128&&n.write(new Uint8Array([0])),n.write(i);return new r({valueHex:n.final()})}convertToDER(){let e=new r({valueHex:this.valueBlock.valueHexView});return e.valueBlock.toDER(),e}convertFromDER(){return new r({valueHex:this.valueBlock.valueHexView[0]===0?this.valueBlock.valueHexView.subarray(1):this.valueBlock.valueHexView})}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()}`}};uu=we;_.Integer=uu;we.NAME="INTEGER";var lu,wo=class extends we{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=10}};lu=wo;_.Enumerated=lu;wo.NAME="ENUMERATED";var fn=class extends It(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(!St(this,o,t,n))return-1;let i=o.subarray(t,t+n);this.valueHexView=new Uint8Array(n);for(let a=0;a<n&&(this.valueHexView[a]=i[a]&127,this.blockLength++,!!(i[a]&128));a++);let s=new Uint8Array(this.blockLength);for(let a=0;a<this.blockLength;a++)s[a]=this.valueHexView[a];return this.valueHexView=s,i[this.blockLength-1]&128?(this.error="End of input reached before message was fully decoded",-1):(this.valueHexView[0]===0&&this.warnings.push("Needlessly long format of SID encoding"),this.blockLength<=8?this.valueDec=or(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),t+this.blockLength)}set valueBigInt(e){io();let t=BigInt(e).toString(2);for(;t.length%7;)t="0"+t;let n=new Uint8Array(t.length/7);for(let o=0;o<n.length;o++)n[o]=parseInt(t.slice(o*7,o*7+7),2)+(o+1<n.length?128:0);this.fromBER(n.buffer,0,n.length)}toBER(e){if(this.isHexOnly){if(e)return new ArrayBuffer(this.valueHexView.byteLength);let o=this.valueHexView,i=new Uint8Array(this.blockLength);for(let s=0;s<this.blockLength-1;s++)i[s]=o[s]|128;return i[this.blockLength-1]=o[this.blockLength-1],i.buffer}let t=Kt(this.valueDec,7);if(t.byteLength===0)return this.error="Error during encoding SID value",tt;let n=new Uint8Array(t.byteLength);if(!e){let o=new Uint8Array(t),i=t.byteLength-1;for(let s=0;s<i;s++)n[s]=o[s]|128;n[i]=o[i]}return n}toString(){let e="";if(this.isHexOnly)e=j.Convert.ToHex(this.valueHexView);else if(this.isFirstSid){let t=this.valueDec;this.valueDec<=39?e="0.":this.valueDec<=79?(e="1.",t-=40):(e="2.",t-=80),e+=t.toString()}else e=this.valueDec.toString();return e}toJSON(){return{...super.toJSON(),valueDec:this.valueDec,isFirstSid:this.isFirstSid}}};fn.NAME="sidBlock";var bo=class extends Ae{constructor({value:e=Vr,...t}={}){super(t),this.value=[],e&&this.fromString(e)}fromBER(e,t,n){let o=t;for(;n>0;){let i=new fn;if(o=i.fromBER(e,o,n),o===-1)return this.blockLength=0,this.error=i.error,o;this.value.length===0&&(i.isFirstSid=!0),this.blockLength+=i.blockLength,n-=i.blockLength,this.value.push(i)}return o}toBER(e){let t=[];for(let n=0;n<this.value.length;n++){let o=this.value[n].toBER(e);if(o.byteLength===0)return this.error=this.value[n].error,tt;t.push(o)}return Hs(t)}fromString(e){this.value=[];let t=0,n=0,o="",i=!1;do if(n=e.indexOf(".",t),n===-1?o=e.substring(t):o=e.substring(t,n),t=n+1,i){let s=this.value[0],a=0;switch(s.valueDec){case 0:break;case 1:a=40;break;case 2:a=80;break;default:this.value=[];return}let c=parseInt(o,10);if(isNaN(c))return;s.valueDec=c+a,i=!1}else{let s=new fn;if(o>Number.MAX_SAFE_INTEGER){io();let a=BigInt(o);s.valueBigInt=a}else if(s.valueDec=parseInt(o,10),isNaN(s.valueDec))return;this.value.length||(s.isFirstSid=!0,i=!0),this.value.push(s)}while(n!==-1)}toString(){let e="",t=!1;for(let n=0;n<this.value.length;n++){t=this.value[n].isHexOnly;let o=this.value[n].toString();n!==0&&(e=`${e}.`),t?(o=`{${o}}`,this.value[n].isFirstSid?e=`2.{${o} - 80}`:e+=o):e+=o}return e}toJSON(){let e={...super.toJSON(),value:this.toString(),sidArray:[]};for(let t=0;t<this.value.length;t++)e.sidArray.push(this.value[t].toJSON());return e}};bo.NAME="ObjectIdentifierValueBlock";var fu,_r=class extends xe{constructor(e={}){super(e,bo),this.idBlock.tagClass=1,this.idBlock.tagNumber=6}getValue(){return this.valueBlock.toString()}setValue(e){this.valueBlock.fromString(e)}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()||"empty"}`}toJSON(){return{...super.toJSON(),value:this.getValue()}}};fu=_r;_.ObjectIdentifier=fu;_r.NAME="OBJECT IDENTIFIER";var dn=class extends It(Et){constructor({valueDec:e=0,...t}={}){super(t),this.valueDec=e}fromBER(e,t,n){if(n===0)return t;let o=j.BufferSourceConverter.toUint8Array(e);if(!St(this,o,t,n))return-1;let i=o.subarray(t,t+n);this.valueHexView=new Uint8Array(n);for(let a=0;a<n&&(this.valueHexView[a]=i[a]&127,this.blockLength++,!!(i[a]&128));a++);let s=new Uint8Array(this.blockLength);for(let a=0;a<this.blockLength;a++)s[a]=this.valueHexView[a];return this.valueHexView=s,i[this.blockLength-1]&128?(this.error="End of input reached before message was fully decoded",-1):(this.valueHexView[0]===0&&this.warnings.push("Needlessly long format of SID encoding"),this.blockLength<=8?this.valueDec=or(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),t+this.blockLength)}toBER(e){if(this.isHexOnly){if(e)return new ArrayBuffer(this.valueHexView.byteLength);let o=this.valueHexView,i=new Uint8Array(this.blockLength);for(let s=0;s<this.blockLength-1;s++)i[s]=o[s]|128;return i[this.blockLength-1]=o[this.blockLength-1],i.buffer}let t=Kt(this.valueDec,7);if(t.byteLength===0)return this.error="Error during encoding SID value",tt;let n=new Uint8Array(t.byteLength);if(!e){let o=new Uint8Array(t),i=t.byteLength-1;for(let s=0;s<i;s++)n[s]=o[s]|128;n[i]=o[i]}return n.buffer}toString(){let e="";return this.isHexOnly?e=j.Convert.ToHex(this.valueHexView):e=this.valueDec.toString(),e}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}};dn.NAME="relativeSidBlock";var vo=class extends Ae{constructor({value:e=Vr,...t}={}){super(t),this.value=[],e&&this.fromString(e)}fromBER(e,t,n){let o=t;for(;n>0;){let i=new dn;if(o=i.fromBER(e,o,n),o===-1)return this.blockLength=0,this.error=i.error,o;this.blockLength+=i.blockLength,n-=i.blockLength,this.value.push(i)}return o}toBER(e,t){let n=[];for(let o=0;o<this.value.length;o++){let i=this.value[o].toBER(e);if(i.byteLength===0)return this.error=this.value[o].error,tt;n.push(i)}return Hs(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 dn;if(i.valueDec=parseInt(o,10),isNaN(i.valueDec))return!0;this.value.push(i)}while(n!==-1);return!0}toString(){let e="",t=!1;for(let n=0;n<this.value.length;n++){t=this.value[n].isHexOnly;let o=this.value[n].toString();n!==0&&(e=`${e}.`),t&&(o=`{${o}}`),e+=o}return e}toJSON(){let e={...super.toJSON(),value:this.toString(),sidArray:[]};for(let t=0;t<this.value.length;t++)e.sidArray.push(this.value[t].toJSON());return e}};vo.NAME="RelativeObjectIdentifierValueBlock";var du,Eo=class extends xe{constructor(e={}){super(e,vo),this.idBlock.tagClass=1,this.idBlock.tagNumber=13}getValue(){return this.valueBlock.toString()}setValue(e){this.valueBlock.fromString(e)}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()||"empty"}`}toJSON(){return{...super.toJSON(),value:this.getValue()}}};du=Eo;_.RelativeObjectIdentifier=du;Eo.NAME="RelativeObjectIdentifier";var hu,Bt=class extends qt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=16}};hu=Bt;_.Sequence=hu;Bt.NAME="SEQUENCE";var pu,Bo=class extends qt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=17}};pu=Bo;_.Set=pu;Bo.NAME="SET";var Ao=class extends It(Ae){constructor({...e}={}){super(e),this.isHexOnly=!0,this.value=Vr}toJSON(){return{...super.toJSON(),value:this.value}}};Ao.NAME="StringValueBlock";var So=class extends Ao{};So.NAME="SimpleStringValueBlock";var Ce=class extends co{constructor({...e}={}){super(e,So)}fromBuffer(e){this.valueBlock.value=String.fromCharCode.apply(null,j.BufferSourceConverter.toUint8Array(e))}fromString(e){let t=e.length,n=this.valueBlock.valueHexView=new Uint8Array(t);for(let o=0;o<t;o++)n[o]=e.charCodeAt(o);this.valueBlock.value=e}};Ce.NAME="SIMPLE STRING";var Io=class extends Ce{fromBuffer(e){this.valueBlock.valueHexView=j.BufferSourceConverter.toUint8Array(e);try{this.valueBlock.value=j.Convert.ToUtf8String(e)}catch(t){this.warnings.push(`Error during "decodeURIComponent": ${t}, using raw string`),this.valueBlock.value=j.Convert.ToBinary(e)}}fromString(e){this.valueBlock.valueHexView=new Uint8Array(j.Convert.FromUtf8String(e)),this.valueBlock.value=e}};Io.NAME="Utf8StringValueBlock";var mu,At=class extends Io{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=12}};mu=At;_.Utf8String=mu;At.NAME="UTF8String";var ko=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))}};ko.NAME="BmpStringValueBlock";var gu,Co=class extends ko{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=30}};gu=Co;_.BmpString=gu;Co.NAME="BMPString";var To=class extends Ce{fromBuffer(e){let t=ArrayBuffer.isView(e)?e.slice().buffer:e.slice(0),n=new Uint8Array(t);for(let o=0;o<n.length;o+=4)n[o]=n[o+3],n[o+1]=n[o+2],n[o+2]=0,n[o+3]=0;this.valueBlock.value=String.fromCharCode.apply(null,new Uint32Array(t))}fromString(e){let t=e.length,n=this.valueBlock.valueHexView=new Uint8Array(t*4);for(let o=0;o<t;o++){let i=Kt(e.charCodeAt(o),8),s=new Uint8Array(i);if(s.length>4)continue;let a=4-s.length;for(let c=s.length-1;c>=0;c--)n[o*4+c+a]=s[c]}this.valueBlock.value=e}};To.NAME="UniversalStringValueBlock";var yu,No=class extends To{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=28}};yu=No;_.UniversalString=yu;No.NAME="UniversalString";var xu,Uo=class extends Ce{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=18}};xu=Uo;_.NumericString=xu;Uo.NAME="NumericString";var wu,Ro=class extends Ce{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=19}};wu=Ro;_.PrintableString=wu;Ro.NAME="PrintableString";var bu,_o=class extends Ce{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=20}};bu=_o;_.TeletexString=bu;_o.NAME="TeletexString";var vu,Vo=class extends Ce{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=21}};vu=Vo;_.VideotexString=vu;Vo.NAME="VideotexString";var Eu,Lo=class extends Ce{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=22}};Eu=Lo;_.IA5String=Eu;Lo.NAME="IA5String";var Bu,Po=class extends Ce{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=25}};Bu=Po;_.GraphicString=Bu;Po.NAME="GraphicString";var Au,hn=class extends Ce{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=26}};Au=hn;_.VisibleString=Au;hn.NAME="VisibleString";var Su,Fo=class extends Ce{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=27}};Su=Fo;_.GeneralString=Su;Fo.NAME="GeneralString";var Iu,Oo=class extends Ce{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=29}};Iu=Oo;_.CharacterString=Iu;Oo.NAME="CharacterString";var ku,pn=class extends hn{constructor({value:e,valueDate:t,...n}={}){if(super(n),this.year=0,this.month=0,this.day=0,this.hour=0,this.minute=0,this.second=0,e){this.fromString(e),this.valueBlock.valueHexView=new Uint8Array(e.length);for(let o=0;o<e.length;o++)this.valueBlock.valueHexView[o]=e.charCodeAt(o)}t&&(this.fromDate(t),this.valueBlock.valueHexView=new Uint8Array(this.toBuffer())),this.idBlock.tagClass=1,this.idBlock.tagNumber=23}fromBuffer(e){this.fromString(String.fromCharCode.apply(null,j.BufferSourceConverter.toUint8Array(e)))}toBuffer(){let e=this.toString(),t=new ArrayBuffer(e.length),n=new Uint8Array(t);for(let o=0;o<e.length;o++)n[o]=e.charCodeAt(o);return t}fromDate(e){this.year=e.getUTCFullYear(),this.month=e.getUTCMonth()+1,this.day=e.getUTCDate(),this.hour=e.getUTCHours(),this.minute=e.getUTCMinutes(),this.second=e.getUTCSeconds()}toDate(){return new Date(Date.UTC(this.year,this.month-1,this.day,this.hour,this.minute,this.second))}fromString(e){let n=/(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})Z/ig.exec(e);if(n===null){this.error="Wrong input string for conversion";return}let o=parseInt(n[1],10);o>=50?this.year=1900+o:this.year=2e3+o,this.month=parseInt(n[2],10),this.day=parseInt(n[3],10),this.hour=parseInt(n[4],10),this.minute=parseInt(n[5],10),this.second=parseInt(n[6],10)}toString(e="iso"){if(e==="iso"){let t=new Array(7);return t[0]=Fe(this.year<2e3?this.year-1900:this.year-2e3,2),t[1]=Fe(this.month,2),t[2]=Fe(this.day,2),t[3]=Fe(this.hour,2),t[4]=Fe(this.minute,2),t[5]=Fe(this.second,2),t[6]="Z",t.join("")}return super.toString(e)}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.toDate().toISOString()}`}toJSON(){return{...super.toJSON(),year:this.year,month:this.month,day:this.day,hour:this.hour,minute:this.minute,second:this.second}}};ku=pn;_.UTCTime=ku;pn.NAME="UTCTime";var Cu,Do=class extends pn{constructor(e={}){var t;super(e),(t=this.millisecond)!==null&&t!==void 0||(this.millisecond=0),this.idBlock.tagClass=1,this.idBlock.tagNumber=24}fromDate(e){super.fromDate(e),this.millisecond=e.getUTCMilliseconds()}toDate(){return new Date(Date.UTC(this.year,this.month-1,this.day,this.hour,this.minute,this.second,this.millisecond))}fromString(e){let t=!1,n="",o="",i=0,s,a=0,c=0;if(e[e.length-1]==="Z")n=e.substring(0,e.length-1),t=!0;else{let l=new Number(e[e.length-1]);if(isNaN(l.valueOf()))throw new Error("Wrong input string for conversion");n=e}if(t){if(n.indexOf("+")!==-1)throw new Error("Wrong input string for conversion");if(n.indexOf("-")!==-1)throw new Error("Wrong input string for conversion")}else{let l=1,d=n.indexOf("+"),b="";if(d===-1&&(d=n.indexOf("-"),l=-1),d!==-1){if(b=n.substring(d+1),n=n.substring(0,d),b.length!==2&&b.length!==4)throw new Error("Wrong input string for conversion");let I=parseInt(b.substring(0,2),10);if(isNaN(I.valueOf()))throw new Error("Wrong input string for conversion");if(a=l*I,b.length===4){if(I=parseInt(b.substring(2,4),10),isNaN(I.valueOf()))throw new Error("Wrong input string for conversion");c=l*I}}}let f=n.indexOf(".");if(f===-1&&(f=n.indexOf(",")),f!==-1){let l=new Number(`0${n.substring(f)}`);if(isNaN(l.valueOf()))throw new Error("Wrong input string for conversion");i=l.valueOf(),o=n.substring(0,f)}else o=n;switch(!0){case o.length===8:if(s=/(\d{4})(\d{2})(\d{2})/ig,f!==-1)throw new Error("Wrong input string for conversion");break;case o.length===10:if(s=/(\d{4})(\d{2})(\d{2})(\d{2})/ig,f!==-1){let l=60*i;this.minute=Math.floor(l),l=60*(l-this.minute),this.second=Math.floor(l),l=1e3*(l-this.second),this.millisecond=Math.floor(l)}break;case o.length===12:if(s=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})/ig,f!==-1){let l=60*i;this.second=Math.floor(l),l=1e3*(l-this.second),this.millisecond=Math.floor(l)}break;case o.length===14:if(s=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/ig,f!==-1){let l=1e3*i;this.millisecond=Math.floor(l)}break;default:throw new Error("Wrong input string for conversion")}let u=s.exec(o);if(u===null)throw new Error("Wrong input string for conversion");for(let l=1;l<u.length;l++)switch(l){case 1:this.year=parseInt(u[l],10);break;case 2:this.month=parseInt(u[l],10);break;case 3:this.day=parseInt(u[l],10);break;case 4:this.hour=parseInt(u[l],10)+a;break;case 5:this.minute=parseInt(u[l],10)+c;break;case 6:this.second=parseInt(u[l],10);break;default:throw new Error("Wrong input string for conversion")}if(t===!1){let l=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);this.year=l.getUTCFullYear(),this.month=l.getUTCMonth(),this.day=l.getUTCDay(),this.hour=l.getUTCHours(),this.minute=l.getUTCMinutes(),this.second=l.getUTCSeconds(),this.millisecond=l.getUTCMilliseconds()}}toString(e="iso"){if(e==="iso"){let t=[];return t.push(Fe(this.year,4)),t.push(Fe(this.month,2)),t.push(Fe(this.day,2)),t.push(Fe(this.hour,2)),t.push(Fe(this.minute,2)),t.push(Fe(this.second,2)),this.millisecond!==0&&(t.push("."),t.push(Fe(this.millisecond,3))),t.push("Z"),t.join("")}return super.toString(e)}toJSON(){return{...super.toJSON(),millisecond:this.millisecond}}};Cu=Do;_.GeneralizedTime=Cu;Do.NAME="GeneralizedTime";var Tu,Mo=class extends At{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=31}};Tu=Mo;_.DATE=Tu;Mo.NAME="DATE";var Nu,$o=class extends At{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=32}};Nu=$o;_.TimeOfDay=Nu;$o.NAME="TimeOfDay";var Uu,Ho=class extends At{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=33}};Uu=Ho;_.DateTime=Uu;Ho.NAME="DateTime";var Ru,Ko=class extends At{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=34}};Ru=Ko;_.Duration=Ru;Ko.NAME="Duration";var _u,qo=class extends At{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=14}};_u=qo;_.TIME=_u;qo.NAME="TIME";function W(r,e="utf8"){let t=Qn[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return t.encoder.encode(r).substring(1)}var mn=class extends Error{constructor(e="An error occurred while verifying a message"){super(e),this.name="VerificationError"}},jo=class extends Error{constructor(e="Missing Web Crypto API"){super(e),this.name="WebCryptoMissingError"}};var Vu={get(r=globalThis){let e=r.crypto;if(e?.subtle==null)throw new jo("Missing Web Crypto API. The most likely cause of this error is that this page is being accessed from an insecure context (i.e. not HTTPS). For more information and possible resolutions see https://github.com/libp2p/js-libp2p/blob/main/packages/crypto/README.md#web-crypto-api");return e}};var zt=Vu;async function Lu(r){let e=await zt.get().subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:r,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-256"}},!0,["sign","verify"]),t=await cp(e);return{privateKey:t[0],publicKey:t[1]}}async function Pu(r,e){let t=await zt.get().subtle.importKey("jwk",r,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["sign"]),n=await zt.get().subtle.sign({name:"RSASSA-PKCS1-v1_5"},t,e instanceof Uint8Array?e:e.subarray());return new Uint8Array(n,0,n.byteLength)}async function Fu(r,e,t){let n=await zt.get().subtle.importKey("jwk",r,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["verify"]);return zt.get().subtle.verify({name:"RSASSA-PKCS1-v1_5"},n,e,t instanceof Uint8Array?t:t.subarray())}async function cp(r){if(r.privateKey==null||r.publicKey==null)throw new ve("Private and public key are required");return Promise.all([zt.get().subtle.exportKey("jwk",r.privateKey),zt.get().subtle.exportKey("jwk",r.publicKey)])}function zs(r){if(r.kty!=="RSA")throw new ve("invalid key type");if(r.n==null)throw new ve("invalid key modulus");return Z(r.n,"base64url").length*8}var Lr=class{type="RSA";_key;_raw;_multihash;constructor(e,t){this._key=e,this._multihash=t}get raw(){return this._raw==null&&(this._raw=gn.jwkToPkix(this._key)),this._raw}toMultihash(){return this._multihash}toCID(){return Q.createV1(114,this._multihash)}toString(){return ne.encode(this.toMultihash().bytes).substring(1)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:ce(this.raw,e.raw)}verify(e,t){return Fu(this._key,t,e)}},yn=class{type="RSA";_key;_raw;publicKey;constructor(e,t){this._key=e,this.publicKey=t}get raw(){return this._raw==null&&(this._raw=gn.jwkToPkcs1(this._key)),this._raw}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:ce(this.raw,e.raw)}sign(e){return Pu(this._key,e)}};var Go=8192,js=18;function Ou(r){let{result:e}=qs(r),t=e.valueBlock.value;return{n:W(lt(t[1].toBigInt()),"base64url"),e:W(lt(t[2].toBigInt()),"base64url"),d:W(lt(t[3].toBigInt()),"base64url"),p:W(lt(t[4].toBigInt()),"base64url"),q:W(lt(t[5].toBigInt()),"base64url"),dp:W(lt(t[6].toBigInt()),"base64url"),dq:W(lt(t[7].toBigInt()),"base64url"),qi:W(lt(t[8].toBigInt()),"base64url"),kty:"RSA",alg:"RS256"}}function up(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 we({value:0}),we.fromBigInt(ft(Z(r.n,"base64url"))),we.fromBigInt(ft(Z(r.e,"base64url"))),we.fromBigInt(ft(Z(r.d,"base64url"))),we.fromBigInt(ft(Z(r.p,"base64url"))),we.fromBigInt(ft(Z(r.q,"base64url"))),we.fromBigInt(ft(Z(r.dp,"base64url"))),we.fromBigInt(ft(Z(r.dq,"base64url"))),we.fromBigInt(ft(Z(r.qi,"base64url")))]}).toBER();return new Uint8Array(t,0,t.byteLength)}function Du(r){let{result:e}=qs(r),t=e.valueBlock.value[1].valueBlock.value[0].valueBlock.value;return{kty:"RSA",n:W(lt(t[0].toBigInt()),"base64url"),e:W(lt(t[1].toBigInt()),"base64url")}}function Gs(r){if(r.n==null||r.e==null)throw new ve("JWK was missing components");let t=new Bt({value:[new Bt({value:[new _r({value:"1.2.840.113549.1.1.1"}),new Ur]}),new Rr({valueHex:new Bt({value:[we.fromBigInt(ft(Z(r.n,"base64url"))),we.fromBigInt(ft(Z(r.e,"base64url")))]}).toBER()})]}).toBER();return new Uint8Array(t,0,t.byteLength)}function lt(r){let e=r.toString(16);e.length%2>0&&(e=`0${e}`);let t=e.length/2,n=new Uint8Array(t),o=0,i=0;for(;o<t;)n[o]=parseInt(e.slice(i,i+2),16),o+=1,i+=2;return n}function ft(r){let e=[];return r.forEach(function(t){let n=t.toString(16);n.length%2>0&&(n=`0${n}`),e.push(n)}),BigInt("0x"+e.join(""))}function Mu(r){let e=Ou(r);return $u(e)}function Zs(r){let e=Du(r);if(zs(e)>Go)throw new lr("Key size is too large");let t=Tr(ct.encode({Type:de.RSA,Data:r})),n=Ze(js,t);return new Lr(e,n)}function $u(r){if(zs(r)>Go)throw new ve("Key size is too large");let e=Ku(r),t=Tr(ct.encode({Type:de.RSA,Data:Gs(e.publicKey)})),n=Ze(js,t);return new yn(e.privateKey,new Lr(e.publicKey,n))}async function Hu(r){if(r>Go)throw new ve("Key size is too large");let e=await Lu(r),t=Tr(ct.encode({Type:de.RSA,Data:Gs(e.publicKey)})),n=Ze(js,t);return new yn(e.privateKey,new Lr(e.publicKey,n))}function Ku(r){if(r==null)throw new ve("Missing key parameter");return{privateKey:r,publicKey:{kty:r.kty,n:r.n,e:r.e}}}var Zo=class extends vr{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,fc(e);let n=Jr(t);if(this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let o=this.blockLen,i=new Uint8Array(o);i.set(n.length>o?e.create().update(n).digest():n);for(let s=0;s<i.length;s++)i[s]^=54;this.iHash.update(i),this.oHash=e.create();for(let s=0;s<i.length;s++)i[s]^=106;this.oHash.update(i),i.fill(0)}update(e){return br(this),this.iHash.update(e),this}digestInto(e){br(this),wr(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()}},Ws=(r,e,t)=>new Zo(r,e).update(t).digest();Ws.create=(r,e)=>new Zo(r,e);function qu(r){r.lowS!==void 0&&Je("lowS",r.lowS),r.prehash!==void 0&&Je("prehash",r.prehash)}function lp(r){let e=en(r);at(e,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});let{endo:t,Fp:n,a:o}=e;if(t){if(!n.eql(o,n.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if(typeof t!="object"||typeof t.beta!="bigint"||typeof t.splitScalar!="function")throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...e})}var{bytesToNumberBE:fp,hexToBytes:dp}=qn,kt={Err:class extends Error{constructor(e=""){super(e)}},_tlv:{encode:(r,e)=>{let{Err:t}=kt;if(r<0||r>256)throw new t("tlv.encode: wrong tag");if(e.length&1)throw new t("tlv.encode: unpadded data");let n=e.length/2,o=Yt(n);if(o.length/2&128)throw new t("tlv.encode: long form length too big");let i=n>127?Yt(o.length/2|128):"";return`${Yt(r)}${i}${o}${e}`},decode(r,e){let{Err:t}=kt,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}=kt;if(r<Ct)throw new e("integer: negative integers are not allowed");let t=Yt(r);if(Number.parseInt(t[0],16)&8&&(t="00"+t),t.length&1)throw new e("unexpected assertion");return t},decode(r){let{Err:e}=kt;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 fp(r)}},toSig(r){let{Err:e,_int:t,_tlv:n}=kt,o=typeof r=="string"?dp(r):r;Br(o);let{v:i,l:s}=n.decode(48,o);if(s.length)throw new e("Invalid signature: left bytes after parsing");let{v:a,l:c}=n.decode(2,i),{v:f,l:u}=n.decode(2,c);if(u.length)throw new e("Invalid signature: left bytes after parsing");return{r:t.decode(a),s:t.decode(f)}},hexFromSig(r){let{_tlv:e,_int:t}=kt,n=`${e.encode(2,t.encode(r.r))}${e.encode(2,t.encode(r.s))}`;return e.encode(48,n)}},Ct=BigInt(0),me=BigInt(1),xw=BigInt(2),zu=BigInt(3),ww=BigInt(4);function hp(r){let e=lp(r),{Fp:t}=e,n=Dt(e.n,e.nBitLength),o=e.toBytes||((x,h,E)=>{let C=h.toAffine();return bt(Uint8Array.from([4]),t.toBytes(C.x),t.toBytes(C.y))}),i=e.fromBytes||(x=>{let h=x.subarray(1),E=t.fromBytes(h.subarray(0,t.BYTES)),C=t.fromBytes(h.subarray(t.BYTES,2*t.BYTES));return{x:E,y:C}});function s(x){let{a:h,b:E}=e,C=t.sqr(x),w=t.mul(C,x);return t.add(t.add(w,t.mul(x,h)),E)}if(!t.eql(t.sqr(e.Gy),s(e.Gx)))throw new Error("bad generator point: equation left != right");function a(x){return Xr(x,me,e.n)}function c(x){let{allowedPrivateKeyLengths:h,nByteLength:E,wrapPrivateKey:C,n:w}=e;if(h&&typeof x!="bigint"){if(Pt(x)&&(x=xt(x)),typeof x!="string"||!h.includes(x.length))throw new Error("Invalid key");x=x.padStart(E*2,"0")}let T;try{T=typeof x=="bigint"?x:wt(ae("private key",x,E))}catch{throw new Error(`private key must be ${E} bytes, hex or bigint, not ${typeof x}`)}return C&&(T=ee(T,w)),Ve("private key",T,me,w),T}function f(x){if(!(x instanceof d))throw new Error("ProjectivePoint expected")}let u=Qt((x,h)=>{let{px:E,py:C,pz:w}=x;if(t.eql(w,t.ONE))return{x:E,y:C};let T=x.is0();h==null&&(h=T?t.ONE:t.inv(w));let F=t.mul(E,h),L=t.mul(C,h),U=t.mul(w,h);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:L}}),l=Qt(x=>{if(x.is0()){if(e.allowInfinityPoint&&!t.is0(x.py))return;throw new Error("bad point: ZERO")}let{x:h,y:E}=x.toAffine();if(!t.isValid(h)||!t.isValid(E))throw new Error("bad point: x or y not FE");let C=t.sqr(E),w=s(h);if(!t.eql(C,w))throw new Error("bad point: equation left != right");if(!x.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class d{constructor(h,E,C){if(this.px=h,this.py=E,this.pz=C,h==null||!t.isValid(h))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(h){let{x:E,y:C}=h||{};if(!h||!t.isValid(E)||!t.isValid(C))throw new Error("invalid affine point");if(h instanceof d)throw new Error("projective point not allowed");let w=T=>t.eql(T,t.ZERO);return w(E)&&w(C)?d.ZERO:new d(E,C,t.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(h){let E=t.invertBatch(h.map(C=>C.pz));return h.map((C,w)=>C.toAffine(E[w])).map(d.fromAffine)}static fromHex(h){let E=d.fromAffine(i(ae("pointHex",h)));return E.assertValidity(),E}static fromPrivateKey(h){return d.BASE.multiply(c(h))}static msm(h,E){return Gn(d,n,h,E)}_setWindowSize(h){I.setWindowSize(this,h)}assertValidity(){l(this)}hasEvenY(){let{y:h}=this.toAffine();if(t.isOdd)return!t.isOdd(h);throw new Error("Field doesn't support isOdd")}equals(h){f(h);let{px:E,py:C,pz:w}=this,{px:T,py:F,pz:L}=h,U=t.eql(t.mul(E,L),t.mul(T,w)),g=t.eql(t.mul(C,L),t.mul(F,w));return U&&g}negate(){return new d(this.px,t.neg(this.py),this.pz)}double(){let{a:h,b:E}=e,C=t.mul(E,zu),{px:w,py:T,pz:F}=this,L=t.ZERO,U=t.ZERO,g=t.ZERO,v=t.mul(w,w),O=t.mul(T,T),R=t.mul(F,F),N=t.mul(w,T);return N=t.add(N,N),g=t.mul(w,F),g=t.add(g,g),L=t.mul(h,g),U=t.mul(C,R),U=t.add(L,U),L=t.sub(O,U),U=t.add(O,U),U=t.mul(L,U),L=t.mul(N,L),g=t.mul(C,g),R=t.mul(h,R),N=t.sub(v,R),N=t.mul(h,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),L=t.sub(L,v),g=t.mul(R,O),g=t.add(g,g),g=t.add(g,g),new d(L,U,g)}add(h){f(h);let{px:E,py:C,pz:w}=this,{px:T,py:F,pz:L}=h,U=t.ZERO,g=t.ZERO,v=t.ZERO,O=e.a,R=t.mul(e.b,zu),N=t.mul(E,T),H=t.mul(C,F),A=t.mul(w,L),S=t.add(E,C),m=t.add(T,F);S=t.mul(S,m),m=t.add(N,H),S=t.sub(S,m),m=t.add(E,w);let p=t.add(T,L);return m=t.mul(m,p),p=t.add(N,A),m=t.sub(m,p),p=t.add(C,w),U=t.add(F,L),p=t.mul(p,U),U=t.add(H,A),p=t.sub(p,U),v=t.mul(O,m),U=t.mul(R,A),v=t.add(U,v),U=t.sub(H,v),v=t.add(H,v),g=t.mul(U,v),H=t.add(N,N),H=t.add(H,N),A=t.mul(O,A),m=t.mul(R,m),H=t.add(H,A),A=t.sub(N,A),A=t.mul(O,A),m=t.add(m,A),N=t.mul(H,m),g=t.add(g,N),N=t.mul(p,m),U=t.mul(S,U),U=t.sub(U,N),N=t.mul(S,H),v=t.mul(p,v),v=t.add(v,N),new d(U,g,v)}subtract(h){return this.add(h.negate())}is0(){return this.equals(d.ZERO)}wNAF(h){return I.wNAFCached(this,h,d.normalizeZ)}multiplyUnsafe(h){Ve("scalar",h,Ct,e.n);let E=d.ZERO;if(h===Ct)return E;if(h===me)return this;let{endo:C}=e;if(!C)return I.unsafeLadder(this,h);let{k1neg:w,k1:T,k2neg:F,k2:L}=C.splitScalar(h),U=E,g=E,v=this;for(;T>Ct||L>Ct;)T&me&&(U=U.add(v)),L&me&&(g=g.add(v)),v=v.double(),T>>=me,L>>=me;return w&&(U=U.negate()),F&&(g=g.negate()),g=new d(t.mul(g.px,C.beta),g.py,g.pz),U.add(g)}multiply(h){let{endo:E,n:C}=e;Ve("scalar",h,me,C);let w,T;if(E){let{k1neg:F,k1:L,k2neg:U,k2:g}=E.splitScalar(h),{p:v,f:O}=this.wNAF(L),{p:R,f:N}=this.wNAF(g);v=I.constTimeNegate(F,v),R=I.constTimeNegate(U,R),R=new d(t.mul(R.px,E.beta),R.py,R.pz),w=v.add(R),T=O.add(N)}else{let{p:F,f:L}=this.wNAF(h);w=F,T=L}return d.normalizeZ([w,T])[0]}multiplyAndAddUnsafe(h,E,C){let w=d.BASE,T=(L,U)=>U===Ct||U===me||!L.equals(w)?L.multiplyUnsafe(U):L.multiply(U),F=T(this,E).add(T(h,C));return F.is0()?void 0:F}toAffine(h){return u(this,h)}isTorsionFree(){let{h,isTorsionFree:E}=e;if(h===me)return!0;if(E)return E(d,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h,clearCofactor:E}=e;return h===me?this:E?E(d,this):this.multiplyUnsafe(e.h)}toRawBytes(h=!0){return Je("isCompressed",h),this.assertValidity(),o(d,this,h)}toHex(h=!0){return Je("isCompressed",h),xt(this.toRawBytes(h))}}d.BASE=new d(e.Gx,e.Gy,t.ONE),d.ZERO=new d(t.ZERO,t.ONE,t.ZERO);let b=e.nBitLength,I=jn(d,e.endo?Math.ceil(b/2):b);return{CURVE:e,ProjectivePoint:d,normPrivateKeyToScalar:c,weierstrassEquation:s,isWithinCurveOrder:a}}function pp(r){let e=en(r);return at(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function ju(r){let e=pp(r),{Fp:t,n}=e,o=t.BYTES+1,i=2*t.BYTES+1;function s(A){return ee(A,n)}function a(A){return zn(A,n)}let{ProjectivePoint:c,normPrivateKeyToScalar:f,weierstrassEquation:u,isWithinCurveOrder:l}=hp({...e,toBytes(A,S,m){let p=S.toAffine(),B=t.toBytes(p.x),P=bt;return Je("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=wt(p);if(!Xr(B,me,t.ORDER))throw new Error("Point is not on curve");let P=u(B),D;try{D=t.sqrt(P)}catch(G){let z=G instanceof Error?": "+G.message:"";throw new Error("Point is not on curve"+z)}let M=(D&me)===me;return(m&1)===1!==M&&(D=t.neg(D)),{x:B,y:D}}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`)}}),d=A=>xt(Ot(A,e.nByteLength));function b(A){let S=n>>me;return A>S}function I(A){return b(A)?s(-A):A}let x=(A,S,m)=>wt(A.slice(S,m));class h{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 h(x(S,0,m),x(S,m,2*m))}static fromDER(S){let{r:m,s:p}=kt.toSig(ae("DER",S));return new h(m,p)}assertValidity(){Ve("r",this.r,me,n),Ve("s",this.s,me,n)}addRecoveryBit(S){return new h(this.r,this.s,S)}recoverPublicKey(S){let{r:m,s:p,recovery:B}=this,P=L(ae("msgHash",S));if(B==null||![0,1,2,3].includes(B))throw new Error("recovery id invalid");let D=B===2||B===3?m+e.n:m;if(D>=t.ORDER)throw new Error("recovery id 2 or 3 invalid");let M=B&1?"03":"02",q=c.fromHex(M+d(D)),G=a(D),z=s(-P*G),X=s(p*G),re=c.BASE.multiplyAndAddUnsafe(q,z,X);if(!re)throw new Error("point at infinify");return re.assertValidity(),re}hasHighS(){return b(this.s)}normalizeS(){return this.hasHighS()?new h(this.r,s(-this.s),this.recovery):this}toDERRawBytes(){return Jt(this.toDERHex())}toDERHex(){return kt.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Jt(this.toCompactHex())}toCompactHex(){return d(this.r)+d(this.s)}}let E={isValidPrivateKey(A){try{return f(A),!0}catch{return!1}},normPrivateKeyToScalar:f,randomPrivateKey:()=>{let A=os(e.n);return Ac(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 w(A){let S=Pt(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(w(A))throw new Error("first arg must be private key");if(!w(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=wt(A),m=A.length*8-e.nBitLength;return m>0?S>>BigInt(m):S},L=e.bits2int_modN||function(A){return s(F(A))},U=Qr(e.nBitLength);function g(A){return Ve(`num < 2^${e.nBitLength}`,A,Ct,U),Ot(A,e.nByteLength)}function v(A,S,m=O){if(["recovered","canonical"].some(pe=>pe in m))throw new Error("sign() legacy options not supported");let{hash:p,randomBytes:B}=e,{lowS:P,prehash:D,extraEntropy:M}=m;P==null&&(P=!0),A=ae("msgHash",A),qu(m),D&&(A=ae("prehashed msgHash",p(A)));let q=L(A),G=f(S),z=[g(G),g(q)];if(M!=null&&M!==!1){let pe=M===!0?B(t.BYTES):M;z.push(ae("extraEntropy",pe))}let X=bt(...z),re=q;function he(pe){let ye=F(pe);if(!l(ye))return;let Ie=a(ye),le=c.BASE.multiply(ye).toAffine(),Ue=s(le.x);if(Ue===Ct)return;let pt=s(Ie*s(re+Ue*G));if(pt===Ct)return;let jr=(le.x===Ue?0:2)|Number(le.y&me),Gr=pt;return P&&b(pt)&&(Gr=I(pt),jr^=1),new h(Ue,Gr,jr)}return{seed:X,k2sig:he}}let O={lowS:e.lowS,prehash:!1},R={lowS:e.lowS,prehash:!1};function N(A,S,m=O){let{seed:p,k2sig:B}=v(A,S,m),P=e;return es(P.hash.outputLen,P.nByteLength,P.hmac)(p,B)}c.BASE._setWindowSize(8);function H(A,S,m,p=R){let B=A;if(S=ae("msgHash",S),m=ae("publicKey",m),"strict"in p)throw new Error("options.strict was renamed to lowS");qu(p);let{lowS:P,prehash:D}=p,M,q;try{if(typeof B=="string"||Pt(B))try{M=h.fromDER(B)}catch(le){if(!(le instanceof kt.Err))throw le;M=h.fromCompact(B)}else if(typeof B=="object"&&typeof B.r=="bigint"&&typeof B.s=="bigint"){let{r:le,s:Ue}=B;M=new h(le,Ue)}else throw new Error("PARSE");q=c.fromHex(m)}catch(le){if(le.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(P&&M.hasHighS())return!1;D&&(S=e.hash(S));let{r:G,s:z}=M,X=L(S),re=a(z),he=s(X*re),pe=s(G*re),ye=c.BASE.multiplyAndAddUnsafe(q,he,pe)?.toAffine();return ye?s(ye.x)===G:!1}return{CURVE:e,getPublicKey:C,getSharedSecret:T,sign:N,verify:H,ProjectivePoint:c,Signature:h,utils:E}}function mp(r){return{hash:r,hmac:(e,...t)=>Ws(r,e,ji(...t)),randomBytes:$n}}function Gu(r,e){let t=n=>ju({...r,...mp(n)});return Object.freeze({...t(e),create:t})}var Yu=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),Zu=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),gp=BigInt(1),Ys=BigInt(2),Wu=(r,e)=>(r+e/Ys)/e;function yp(r){let e=Yu,t=BigInt(3),n=BigInt(6),o=BigInt(11),i=BigInt(22),s=BigInt(23),a=BigInt(44),c=BigInt(88),f=r*r*r%e,u=f*f*r%e,l=ie(u,t,e)*u%e,d=ie(l,t,e)*u%e,b=ie(d,Ys,e)*f%e,I=ie(b,o,e)*b%e,x=ie(I,i,e)*I%e,h=ie(x,a,e)*x%e,E=ie(h,c,e)*h%e,C=ie(E,a,e)*x%e,w=ie(C,t,e)*u%e,T=ie(w,s,e)*I%e,F=ie(T,n,e)*f%e,L=ie(F,Ys,e);if(!Js.eql(Js.sqr(L),r))throw new Error("Cannot find square root");return L}var Js=Dt(Yu,void 0,void 0,{sqrt:yp}),ir=Gu({a:BigInt(0),b:BigInt(7),Fp:Js,n:Zu,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:r=>{let e=Zu,t=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-gp*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),i=t,s=BigInt("0x100000000000000000000000000000000"),a=Wu(i*r,e),c=Wu(-n*r,e),f=ee(r-a*t-c*o,e),u=ee(-a*n-c*i,e),l=f>s,d=u>s;if(l&&(f=e-f),d&&(u=e-u),f>s||u>s)throw new Error("splitScalar: Endomorphism failed, k="+r);return{k1neg:l,k1:f,k2neg:d,k2:u}}}},Tr),Cw=BigInt(0);var Tw=ir.ProjectivePoint;function De(r,e){e==null&&(e=r.reduce((o,i)=>o+i.length,0));let t=Qe(e),n=0;for(let o of r)t.set(o,n),n+=o.length;return t}function Ju(r){return r==null?!1:typeof r.then=="function"&&typeof r.catch=="function"&&typeof r.finally=="function"}function Xu(r,e,t){let n=tn.digest(t instanceof Uint8Array?t:t.subarray());if(Ju(n))return n.then(({digest:o})=>ir.verify(e,o,r)).catch(o=>{throw new mn(String(o))});try{return ir.verify(e,n.digest,r)}catch(o){throw new mn(String(o))}}var Wo=class{type="secp256k1";raw;_key;constructor(e){this._key=el(e),this.raw=Qu(this._key)}toMultihash(){return We.digest(Jn(this))}toCID(){return Q.createV1(114,this.toMultihash())}toString(){return ne.encode(this.toMultihash().bytes).substring(1)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:ce(this.raw,e.raw)}verify(e,t){return Xu(this._key,t,e)}};function Xs(r){return new Wo(r)}function Qu(r){return ir.ProjectivePoint.fromHex(r).toRawBytes(!0)}function el(r){try{return ir.ProjectivePoint.fromHex(r),r}catch(e){throw new lr(String(e))}}function tl(r){let{Type:e,Data:t}=ct.decode(r),n=t??new Uint8Array;switch(e){case de.RSA:return Zs(n);case de.Ed25519:return us(n);case de.secp256k1:return Xs(n);default:throw new dr}}function Yo(r){let{Type:e,Data:t}=ct.decode(r.digest),n=t??new Uint8Array;switch(e){case de.Ed25519:return us(n);case de.secp256k1:return Xs(n);default:throw new dr}}function Jn(r){return ct.encode({Type:de[r.type],Data:r.raw})}var rl=Symbol.for("nodejs.util.inspect.custom"),xp=114,xn=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()})`}[Ri]=!0;toString(){return this.string==null&&(this.string=ne.encode(this.multihash.bytes).slice(1)),this.string}toMultihash(){return this.multihash}toCID(){return Q.createV1(xp,this.multihash)}toJSON(){return this.toString()}equals(e){if(e==null)return!1;if(e instanceof Uint8Array)return ce(this.multihash.bytes,e);if(typeof e=="string")return this.toString()===e;if(e?.toMultihash()?.bytes!=null)return ce(this.multihash.bytes,e.toMultihash().bytes);throw new Error("not valid Id")}[rl](){return`PeerId(${this.toString()})`}},Jo=class extends xn{type="RSA";publicKey;constructor(e){super({...e,type:"RSA"}),this.publicKey=e.publicKey}},Xo=class extends xn{type="Ed25519";publicKey;constructor(e){super({...e,type:"Ed25519"}),this.publicKey=e.publicKey}},Qo=class extends xn{type="secp256k1";publicKey;constructor(e){super({...e,type:"secp256k1"}),this.publicKey=e.publicKey}},wp=2336,wn=class{type="url";multihash;publicKey;url;constructor(e){this.url=e.toString(),this.multihash=We.digest(Z(this.url))}[rl](){return`PeerId(${this.url})`}[Ri]=!0;toString(){return this.toCID().toString()}toMultihash(){return this.multihash}toCID(){return Q.createV1(wp,this.toMultihash())}toJSON(){return this.toString()}equals(e){return e==null?!1:(e instanceof Uint8Array&&(e=W(e)),e.toString()===this.toString())}};var bp=114,nl=2336;function ol(r,e){let t;if(r.charAt(0)==="1"||r.charAt(0)==="Q")t=gt(ne.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=gt(e.decode(r))}return il(t)}function il(r){if(Ep(r))return new Jo({multihash:r});if(vp(r))try{let e=Yo(r);if(e.type==="Ed25519")return new Xo({multihash:r,publicKey:e});if(e.type==="secp256k1")return new Qo({multihash:r,publicKey:e})}catch{let t=W(r.digest);return new wn(new URL(t))}throw new fr("Supplied PeerID Multihash is invalid")}function sl(r){if(r?.multihash==null||r.version==null||r.version===1&&r.code!==bp&&r.code!==nl)throw new Vn("Supplied PeerID CID is invalid");if(r.code===nl){let e=W(r.multihash.digest);return new wn(new URL(e))}return il(r.multihash)}function vp(r){return r.code===We.code}function Ep(r){return r.code===tn.code}var ei=class{index=0;input="";new(e){return this.index=0,this.input=e,this}readAtomically(e){let t=this.index,n=e();return n===void 0&&(this.index=t),n}parseWith(e){let t=e();if(this.index===this.input.length)return t}peekChar(){if(!(this.index>=this.input.length))return this.input[this.index]}readChar(){if(!(this.index>=this.input.length))return this.input[this.index++]}readGivenChar(e){return this.readAtomically(()=>{let t=this.readChar();if(t===e)return t})}readSeparator(e,t,n){return this.readAtomically(()=>{if(!(t>0&&this.readGivenChar(e)===void 0))return n()})}readNumber(e,t,n,o){return this.readAtomically(()=>{let i=0,s=0,a=this.peekChar();if(a===void 0)return;let c=a==="0",f=2**(8*o)-1;for(;;){let u=this.readAtomically(()=>{let l=this.readChar();if(l===void 0)return;let d=Number.parseInt(l,e);if(!Number.isNaN(d))return d});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 al=45,Bp=15,Pr=new ei;function Qs(r){if(!(r.length>Bp))return Pr.new(r).parseWith(()=>Pr.readIPv4Addr())}function ea(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>al))return Pr.new(r).parseWith(()=>Pr.readIPv6Addr())}function ti(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>al))return Pr.new(r).parseWith(()=>Pr.readIPAddr())}var qb=parseInt("0xFFFF",16),zb=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);function ll(r){return!!Qs(r)}function fl(r){return!!ea(r)}function ri(r){return!!ti(r)}var dl=ll,Cp=fl,ta=function(r){let e=0;if(r=r.toString().trim(),dl(r)){let t=new Uint8Array(e+4);return r.split(/\./g).forEach(n=>{t[e++]=parseInt(n,10)&255}),t}if(Cp(r)){let t=r.split(":",8),n;for(n=0;n<t.length;n++){let i=dl(t[n]),s;i&&(s=ta(t[n]),t[n]=W(s.slice(0,2),"base16")),s!=null&&++n<8&&t.splice(n,0,W(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")},hl=function(r,e=0,t){e=~~e,t=t??r.length-e;let n=new DataView(r.buffer);if(t===4){let o=[];for(let i=0;i<t;i++)o.push(r[e+i]);return o.join(".")}if(t===16){let o=[];for(let i=0;i<t;i+=2)o.push(n.getUint16(e+i).toString(16));return o.join(":").replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}return""};var Fr={},ra={},Np=[[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"]];Np.forEach(r=>{let e=Up(...r);ra[e.code]=e,Fr[e.name]=e});function Up(r,e,t,n,o){return{code:r,size:e,name:t,resolvable:!!n,path:!!o}}function te(r){if(typeof r=="number"){if(ra[r]!=null)return ra[r];throw new Error(`no protocol with code: ${r}`)}else if(typeof r=="string"){if(Fr[r]!=null)return Fr[r];throw new Error(`no protocol with name: ${r}`)}throw new Error(`invalid protocol id type: ${typeof r}`)}var C1=te("ip4"),T1=te("ip6"),N1=te("ipcidr");function sa(r,e){switch(te(r).code){case 4:case 41:return _p(e);case 42:return ia(e);case 6:case 273:case 33:case 132:return gl(e).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return ia(e);case 421:return Fp(e);case 444:return ml(e);case 445:return ml(e);case 466:return Pp(e);case 481:return globalThis.encodeURIComponent(ia(e));default:return W(e,"base16")}}function aa(r,e){switch(te(r).code){case 4:return pl(e);case 41:return pl(e);case 42:return oa(e);case 6:case 273:case 33:case 132:return ca(parseInt(e,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return oa(e);case 421:return Vp(e);case 444:return Op(e);case 445:return Dp(e);case 466:return Lp(e);case 481:return oa(globalThis.decodeURIComponent(e));default:return Z(e,"base16")}}var na=Object.values(rn).map(r=>r.decoder),Rp=function(){let r=na[0].or(na[1]);return na.slice(2).forEach(e=>r=r.or(e)),r}();function pl(r){if(!ri(r))throw new Error("invalid ip address");return ta(r)}function _p(r){let e=hl(r,0,r.length);if(e==null)throw new Error("ipBuff is required");if(!ri(e))throw new Error("invalid ip address");return e}function ca(r){let e=new ArrayBuffer(2);return new DataView(e).setUint16(0,r),new Uint8Array(e)}function gl(r){return new DataView(r.buffer).getUint16(r.byteOffset)}function oa(r){let e=Z(r),t=Uint8Array.from(Ar(e.length));return De([t,e],t.length+e.length)}function ia(r){let e=tr(r);if(r=r.slice(Pe(e)),r.length!==e)throw new Error("inconsistent lengths");return W(r)}function Vp(r){let e;r[0]==="Q"||r[0]==="1"?e=gt(ne.decode(`z${r}`)).bytes:e=Q.parse(r).multihash.bytes;let t=Uint8Array.from(Ar(e.length));return De([t,e],t.length+e.length)}function Lp(r){let e=Rp.decode(r),t=Uint8Array.from(Ar(e.length));return De([t,e],t.length+e.length)}function Pp(r){let e=tr(r),t=r.slice(Pe(e));if(t.length!==e)throw new Error("inconsistent lengths");return"u"+W(t,"base64url")}function Fp(r){let e=tr(r),t=r.slice(Pe(e));if(t.length!==e)throw new Error("inconsistent lengths");return W(t,"base58btc")}function Op(r){let e=r.split(":");if(e.length!==2)throw new Error(`failed to parse onion addr: ["'${e.join('", "')}'"]' does not contain a port number`);if(e[0].length!==16)throw new Error(`failed to parse onion addr: ${e[0]} not a Tor onion address.`);let t=Ge.decode("b"+e[0]),n=parseInt(e[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=ca(n);return De([t,o],t.length+o.length)}function Dp(r){let e=r.split(":");if(e.length!==2)throw new Error(`failed to parse onion addr: ["'${e.join('", "')}'"]' does not contain a port number`);if(e[0].length!==56)throw new Error(`failed to parse onion addr: ${e[0]} not a Tor onion3 address.`);let t=Ge.decode(`b${e[0]}`),n=parseInt(e[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=ca(n);return De([t,o],t.length+o.length)}function ml(r){let e=r.slice(0,r.length-2),t=r.slice(r.length-2),n=W(e,"base32"),o=gl(t);return`${n}:${o}`}function yl(r){r=ua(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=te(s);if(a.size===0){e.push([a.code]),t.push([a.code]);continue}if(i++,i>=o.length)throw wl("invalid address: "+r);if(a.path===!0){n=ua(o.slice(i).join("/")),e.push([a.code,aa(a.code,n)]),t.push([a.code,n]);break}let c=aa(a.code,o[i]);e.push([a.code,c]),t.push([a.code,sa(a.code,c)])}return{string:xl(t),bytes:fa(e),tuples:e,stringTuples:t,path:n}}function la(r){let e=[],t=[],n=null,o=0;for(;o<r.length;){let i=tr(r,o),s=Pe(i),a=te(i),c=Mp(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 wl("Invalid address Uint8Array: "+W(r,"base16"));e.push([i,f]);let u=sa(i,f);if(t.push([i,u]),a.path===!0){n=u;break}}return{bytes:Uint8Array.from(r),string:xl(t),tuples:e,stringTuples:t,path:n}}function xl(r){let e=[];return r.map(t=>{let n=te(t[0]);return e.push(n.name),t.length>1&&t[1]!=null&&e.push(t[1]),null}),ua(e.join("/"))}function fa(r){return De(r.map(e=>{let t=te(e[0]),n=Uint8Array.from(Ar(t.code));return e.length>1&&e[1]!=null&&(n=De([n,e[1]])),n}))}function Mp(r,e){if(r.size>0)return r.size/8;if(r.size===0)return 0;{let t=tr(e instanceof Uint8Array?e:Uint8Array.from(e));return t+Pe(t)}}function ua(r){return"/"+r.trim().split("/").filter(e=>e).join("/")}function wl(r){return new Error("Error parsing address: "+r)}var $p=Symbol.for("nodejs.util.inspect.custom"),ha=Symbol.for("@multiformats/js-multiaddr/multiaddr"),Hp=[te("dns").code,te("dns4").code,te("dns6").code,te("dnsaddr").code],da=class extends Error{constructor(e="No available resolver"){super(e),this.name="NoAvailableResolverError"}},ni=class r{bytes;#e;#r;#i;#a;[ha]=!0;constructor(e){e==null&&(e="");let t;if(e instanceof Uint8Array)t=la(e);else if(typeof e=="string"){if(e.length>0&&e.charAt(0)!=="/")throw new Error(`multiaddr "${e}" must start with a "/"`);t=yl(e)}else if(vl(e))t=la(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.#i=t.stringTuples,this.#a=t.path}toString(){return this.#e}toJSON(){return this.toString()}toOptions(){let e,t,n,o,i="",s=te("tcp"),a=te("udp"),c=te("ip4"),f=te("ip6"),u=te("dns6"),l=te("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=te(b).name,o=parseInt(I??"")),(b===c.code||b===f.code)&&(t=te(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({},te(e)))}protoCodes(){return this.#r.map(([e])=>e)}protoNames(){return this.#r.map(([e])=>te(e).name)}tuples(){return this.#r}stringTuples(){return this.#i}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(fa(t.slice(0,n)));return this}getPeerId(){try{let e=[];this.stringTuples().forEach(([n,o])=>{n===Fr.p2p.code&&e.push([n,o]),n===Fr["p2p-circuit"].code&&(e=[])});let t=e.pop();if(t?.[1]!=null){let n=t[1];return n[0]==="Q"||n[0]==="1"?W(ne.decode(`z${n}`),"base58btc"):W(Q.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){return this.#a}equals(e){return ce(this.bytes,e.bytes)}async resolve(e){let t=this.protos().find(i=>i.resolvable);if(t==null)return[this];let n=bl.get(t.name);if(n==null)throw new da(`no available resolver for ${t.name}`);return(await n(this,e)).map(i=>sr(i))}nodeAddress(){let e=this.toOptions();if(e.transport!=="tcp"&&e.transport!=="udp")throw new Error(`multiaddr must have a valid format - no protocol with name: "${e.transport}". Must have a valid transport protocol: "{tcp, udp}"`);return{family:e.family,address:e.host,port:e.port}}isThinWaistAddress(e){let t=(e??this).protos();return!(t.length!==2||t[0].code!==4&&t[0].code!==41||t[1].code!==6&&t[1].code!==273)}[$p](){return`Multiaddr(${this.#e})`}};var bl=new Map;function vl(r){return!!r?.[ha]}function sr(r){return new ni(r)}function bn(r){let e=new globalThis.AbortController;function t(){e.abort();for(let i of r)i?.removeEventListener!=null&&i.removeEventListener("abort",t)}for(let i of r){if(i?.aborted===!0){t();break}i?.addEventListener!=null&&i.addEventListener("abort",t)}function n(){for(let i of r)i?.removeEventListener!=null&&i.removeEventListener("abort",t)}let o=e.signal;return o.clear=n,o}async function*oi(r,e={}){let t=r.getReader();try{for(;;){let n=await t.read();if(n.done)return;yield n.value}}finally{e.preventCancel!==!0&&await t.cancel(),t.releaseLock()}}var Kp="/",qp=new TextEncoder().encode(Kp),o2=qp[0];var Am=_n(ma(),1);var rt=class extends Error{static name="SignatureVerificationError";constructor(e="Record signature verification failed"){super(e),this.name="SignatureVerificationError"}},ii=class extends Error{static name="RecordExpiredError";constructor(e="Record has expired"){super(e),this.name="RecordExpiredError"}},Or=class extends Error{static name="UnsupportedValidityError";constructor(e="The validity type is unsupported"){super(e),this.name="UnsupportedValidityError"}},si=class extends Error{static name="RecordTooLargeError";constructor(e="The record is too large"){super(e),this.name="RecordTooLargeError"}},ai=class extends Error{static name="InvalidValueError";constructor(e="Value must be a valid content path starting with /"){super(e),this.name="InvalidValueError"}},ci=class extends Error{static name="InvalidRecordDataError";constructor(e="Invalid record data"){super(e),this.name="InvalidRecordDataError"}},vn=class extends Error{static name="InvalidEmbeddedPublicKeyError";constructor(e="Invalid embedded public key"){super(e),this.name="InvalidEmbeddedPublicKeyError"}};var nt;(function(r){let e;(function(o){o.EOL="EOL"})(e=r.ValidityType||(r.ValidityType={}));let t;(function(o){o[o.EOL=0]="EOL"})(t||(t={})),function(o){o.codec=()=>sn(t)}(e=r.ValidityType||(r.ValidityType={}));let n;r.codec=()=>(n==null&&(n=Cr((o,i,s={})=>{s.lengthDelimited!==!1&&i.fork(),o.value!=null&&(i.uint32(10),i.bytes(o.value)),o.signatureV1!=null&&(i.uint32(18),i.bytes(o.signatureV1)),o.validityType!=null&&(i.uint32(24),r.ValidityType.codec().encode(o.validityType,i)),o.validity!=null&&(i.uint32(34),i.bytes(o.validity)),o.sequence!=null&&(i.uint32(40),i.uint64(o.sequence)),o.ttl!=null&&(i.uint32(48),i.uint64(o.ttl)),o.pubKey!=null&&(i.uint32(58),i.bytes(o.pubKey)),o.signatureV2!=null&&(i.uint32(66),i.bytes(o.signatureV2)),o.data!=null&&(i.uint32(74),i.bytes(o.data)),s.lengthDelimited!==!1&&i.ldelim()},(o,i,s={})=>{let a={},c=i==null?o.len:o.pos+i;for(;o.pos<c;){let f=o.uint32();switch(f>>>3){case 1:{a.value=o.bytes();break}case 2:{a.signatureV1=o.bytes();break}case 3:{a.validityType=r.ValidityType.codec().decode(o);break}case 4:{a.validity=o.bytes();break}case 5:{a.sequence=o.uint64();break}case 6:{a.ttl=o.uint64();break}case 7:{a.pubKey=o.bytes();break}case 8:{a.signatureV2=o.bytes();break}case 9:{a.data=o.bytes();break}default:{o.skipType(f&7);break}}}return a})),n),r.encode=o=>Ir(o,r.codec()),r.decode=(o,i)=>Sr(o,r.codec(),i)})(nt||(nt={}));var zp=["string","number","bigint","symbol"],jp=["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 El(r){if(r===null)return"null";if(r===void 0)return"undefined";if(r===!0||r===!1)return"boolean";let e=typeof r;if(zp.includes(e))return e;if(e==="function")return"Function";if(Array.isArray(r))return"Array";if(Gp(r))return"Buffer";let t=Zp(r);return t||"Object"}function Gp(r){return r&&r.constructor&&r.constructor.isBuffer&&r.constructor.isBuffer.call(null,r)}function Zp(r){let e=Object.prototype.toString.call(r).slice(8,-1);if(jp.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 V=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 Dr=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&typeof globalThis.Buffer.isBuffer=="function",Wp=new TextDecoder,Yp=new TextEncoder;function ui(r){return Dr&&globalThis.Buffer.isBuffer(r)}function Il(r){return r instanceof Uint8Array?ui(r)?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r:Uint8Array.from(r)}var kl=Dr?(r,e,t)=>t-e>64?globalThis.Buffer.from(r.subarray(e,t)).toString("utf8"):Al(r,e,t):(r,e,t)=>t-e>64?Wp.decode(r.subarray(e,t)):Al(r,e,t),Cl=Dr?r=>r.length>64?globalThis.Buffer.from(r):Bl(r):r=>r.length>64?Yp.encode(r):Bl(r);var Mr=Dr?(r,e,t)=>ui(r)?new Uint8Array(r.subarray(e,t)):r.slice(e,t):(r,e,t)=>r.slice(e,t),Tl=Dr?(r,e)=>(r=r.map(t=>t instanceof Uint8Array?t:globalThis.Buffer.from(t)),Il(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},Nl=Dr?r=>globalThis.Buffer.allocUnsafe(r):r=>new Uint8Array(r);function Ul(r,e){if(ui(r)&&ui(e))return r.compare(e);for(let t=0;t<r.length;t++)if(r[t]!==e[t])return r[t]<e[t]?-1:1;return 0}function Bl(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 Al(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 Jp(n)}var Sl=4096;function Jp(r){let e=r.length;if(e<=Sl)return String.fromCharCode.apply(String,r);let t="",n=0;for(;n<e;)t+=String.fromCharCode.apply(String,r.slice(n,n+=Sl));return t}var Xp=256,li=class{constructor(e=Xp){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=Nl(this.chunkSize),this.chunks.push(t),this.maxCursor+=t.length,this._initReuseChunk===null&&(this._initReuseChunk=t),t.set(e,0)):(this.chunks.push(e),this.maxCursor+=e.length)}this.cursor+=e.length}toBytes(e=!1){let t;if(this.chunks.length===1){let n=this.chunks[0];e&&this.cursor>n.length/2?(t=this.cursor===n.length?n:n.subarray(0,this.cursor),this._initReuseChunk=null,this.chunks=[]):t=Mr(n,0,this.cursor)}else t=Tl(this.chunks,this.cursor);return e&&this.reset(),t}};var $="CBOR decode error:",ga="CBOR encode error:",En=[];En[23]=1;En[24]=2;En[25]=3;En[26]=5;En[27]=9;function Tt(r,e,t){if(r.length-e<t)throw new Error(`${$} not enough data for type`)}var ge=[24,256,65536,4294967296,BigInt("18446744073709551616")];function Me(r,e,t){Tt(r,e,1);let n=r[e];if(t.strict===!0&&n<ge[0])throw new Error(`${$} integer encoded in more bytes than necessary (strict decode)`);return n}function $e(r,e,t){Tt(r,e,2);let n=r[e]<<8|r[e+1];if(t.strict===!0&&n<ge[1])throw new Error(`${$} integer encoded in more bytes than necessary (strict decode)`);return n}function He(r,e,t){Tt(r,e,4);let n=r[e]*16777216+(r[e+1]<<16)+(r[e+2]<<8)+r[e+3];if(t.strict===!0&&n<ge[2])throw new Error(`${$} integer encoded in more bytes than necessary (strict decode)`);return n}function Ke(r,e,t){Tt(r,e,8);let n=r[e]*16777216+(r[e+1]<<16)+(r[e+2]<<8)+r[e+3],o=r[e+4]*16777216+(r[e+5]<<16)+(r[e+6]<<8)+r[e+7],i=(BigInt(n)<<BigInt(32))+BigInt(o);if(t.strict===!0&&i<ge[3])throw new Error(`${$} integer encoded in more bytes than necessary (strict decode)`);if(i<=Number.MAX_SAFE_INTEGER)return Number(i);if(t.allowBigInt===!0)return i;throw new Error(`${$} integers outside of the safe integer range are not supported`)}function Rl(r,e,t,n){return new V(y.uint,Me(r,e+1,n),2)}function _l(r,e,t,n){return new V(y.uint,$e(r,e+1,n),3)}function Vl(r,e,t,n){return new V(y.uint,He(r,e+1,n),5)}function Ll(r,e,t,n){return new V(y.uint,Ke(r,e+1,n),9)}function ze(r,e){return be(r,0,e.value)}function be(r,e,t){if(t<ge[0]){let n=Number(t);r.push([e|n])}else if(t<ge[1]){let n=Number(t);r.push([e|24,n])}else if(t<ge[2]){let n=Number(t);r.push([e|25,n>>>8,n&255])}else if(t<ge[3]){let n=Number(t);r.push([e|26,n>>>24&255,n>>>16&255,n>>>8&255,n&255])}else{let n=BigInt(t);if(n<ge[4]){let o=[e|27,0,0,0,0,0,0,0],i=Number(n&BigInt(4294967295)),s=Number(n>>BigInt(32)&BigInt(4294967295));o[8]=i&255,i=i>>8,o[7]=i&255,i=i>>8,o[6]=i&255,i=i>>8,o[5]=i&255,o[4]=s&255,s=s>>8,o[3]=s&255,s=s>>8,o[2]=s&255,s=s>>8,o[1]=s&255,r.push(o)}else throw new Error(`${$} encountered BigInt larger than allowable range`)}}ze.encodedSize=function(e){return be.encodedSize(e.value)};be.encodedSize=function(e){return e<ge[0]?1:e<ge[1]?2:e<ge[2]?3:e<ge[3]?5:9};ze.compareTokens=function(e,t){return e.value<t.value?-1:e.value>t.value?1:0};function Pl(r,e,t,n){return new V(y.negint,-1-Me(r,e+1,n),2)}function Fl(r,e,t,n){return new V(y.negint,-1-$e(r,e+1,n),3)}function Ol(r,e,t,n){return new V(y.negint,-1-He(r,e+1,n),5)}var ya=BigInt(-1),Dl=BigInt(1);function Ml(r,e,t,n){let o=Ke(r,e+1,n);if(typeof o!="bigint"){let i=-1-o;if(i>=Number.MIN_SAFE_INTEGER)return new V(y.negint,i,9)}if(n.allowBigInt!==!0)throw new Error(`${$} integers outside of the safe integer range are not supported`);return new V(y.negint,ya-BigInt(o),9)}function fi(r,e){let t=e.value,n=typeof t=="bigint"?t*ya-Dl:t*-1-1;be(r,e.type.majorEncoded,n)}fi.encodedSize=function(e){let t=e.value,n=typeof t=="bigint"?t*ya-Dl:t*-1-1;return n<ge[0]?1:n<ge[1]?2:n<ge[2]?3:n<ge[3]?5:9};fi.compareTokens=function(e,t){return e.value<t.value?1:e.value>t.value?-1:0};function Bn(r,e,t,n){Tt(r,e,t+n);let o=Mr(r,e+t,e+t+n);return new V(y.bytes,o,t+n)}function $l(r,e,t,n){return Bn(r,e,1,t)}function Hl(r,e,t,n){return Bn(r,e,2,Me(r,e+1,n))}function Kl(r,e,t,n){return Bn(r,e,3,$e(r,e+1,n))}function ql(r,e,t,n){return Bn(r,e,5,He(r,e+1,n))}function zl(r,e,t,n){let o=Ke(r,e+1,n);if(typeof o=="bigint")throw new Error(`${$} 64-bit integer bytes lengths not supported`);return Bn(r,e,9,o)}function di(r){return r.encodedBytes===void 0&&(r.encodedBytes=r.type===y.string?Cl(r.value):r.value),r.encodedBytes}function $r(r,e){let t=di(e);be(r,e.type.majorEncoded,t.length),r.push(t)}$r.encodedSize=function(e){let t=di(e);return be.encodedSize(t.length)+t.length};$r.compareTokens=function(e,t){return em(di(e),di(t))};function em(r,e){return r.length<e.length?-1:r.length>e.length?1:Ul(r,e)}function An(r,e,t,n,o){let i=t+n;Tt(r,e,i);let s=new V(y.string,kl(r,e+t,e+i),i);return o.retainStringBytes===!0&&(s.byteValue=Mr(r,e+t,e+i)),s}function jl(r,e,t,n){return An(r,e,1,t,n)}function Gl(r,e,t,n){return An(r,e,2,Me(r,e+1,n),n)}function Zl(r,e,t,n){return An(r,e,3,$e(r,e+1,n),n)}function Wl(r,e,t,n){return An(r,e,5,He(r,e+1,n),n)}function Yl(r,e,t,n){let o=Ke(r,e+1,n);if(typeof o=="bigint")throw new Error(`${$} 64-bit integer string lengths not supported`);return An(r,e,9,o,n)}var Jl=$r;function Hr(r,e,t,n){return new V(y.array,n,t)}function Xl(r,e,t,n){return Hr(r,e,1,t)}function Ql(r,e,t,n){return Hr(r,e,2,Me(r,e+1,n))}function ef(r,e,t,n){return Hr(r,e,3,$e(r,e+1,n))}function tf(r,e,t,n){return Hr(r,e,5,He(r,e+1,n))}function rf(r,e,t,n){let o=Ke(r,e+1,n);if(typeof o=="bigint")throw new Error(`${$} 64-bit integer array lengths not supported`);return Hr(r,e,9,o)}function nf(r,e,t,n){if(n.allowIndefinite===!1)throw new Error(`${$} indefinite length items not allowed`);return Hr(r,e,1,1/0)}function hi(r,e){be(r,y.array.majorEncoded,e.value)}hi.compareTokens=ze.compareTokens;hi.encodedSize=function(e){return be.encodedSize(e.value)};function Kr(r,e,t,n){return new V(y.map,n,t)}function of(r,e,t,n){return Kr(r,e,1,t)}function sf(r,e,t,n){return Kr(r,e,2,Me(r,e+1,n))}function af(r,e,t,n){return Kr(r,e,3,$e(r,e+1,n))}function cf(r,e,t,n){return Kr(r,e,5,He(r,e+1,n))}function uf(r,e,t,n){let o=Ke(r,e+1,n);if(typeof o=="bigint")throw new Error(`${$} 64-bit integer map lengths not supported`);return Kr(r,e,9,o)}function lf(r,e,t,n){if(n.allowIndefinite===!1)throw new Error(`${$} indefinite length items not allowed`);return Kr(r,e,1,1/0)}function pi(r,e){be(r,y.map.majorEncoded,e.value)}pi.compareTokens=ze.compareTokens;pi.encodedSize=function(e){return be.encodedSize(e.value)};function ff(r,e,t,n){return new V(y.tag,t,1)}function df(r,e,t,n){return new V(y.tag,Me(r,e+1,n),2)}function hf(r,e,t,n){return new V(y.tag,$e(r,e+1,n),3)}function pf(r,e,t,n){return new V(y.tag,He(r,e+1,n),5)}function mf(r,e,t,n){return new V(y.tag,Ke(r,e+1,n),9)}function mi(r,e){be(r,y.tag.majorEncoded,e.value)}mi.compareTokens=ze.compareTokens;mi.encodedSize=function(e){return be.encodedSize(e.value)};var sm=20,am=21,cm=22,um=23;function gf(r,e,t,n){if(n.allowUndefined===!1)throw new Error(`${$} undefined values are not supported`);return n.coerceUndefinedToNull===!0?new V(y.null,null,1):new V(y.undefined,void 0,1)}function yf(r,e,t,n){if(n.allowIndefinite===!1)throw new Error(`${$} indefinite length items not allowed`);return new V(y.break,void 0,1)}function xa(r,e,t){if(t){if(t.allowNaN===!1&&Number.isNaN(r))throw new Error(`${$} NaN values are not supported`);if(t.allowInfinity===!1&&(r===1/0||r===-1/0))throw new Error(`${$} Infinity values are not supported`)}return new V(y.float,r,e)}function xf(r,e,t,n){return xa(wa(r,e+1),3,n)}function wf(r,e,t,n){return xa(ba(r,e+1),5,n)}function bf(r,e,t,n){return xa(Af(r,e+1),9,n)}function gi(r,e,t){let n=e.value;if(n===!1)r.push([y.float.majorEncoded|sm]);else if(n===!0)r.push([y.float.majorEncoded|am]);else if(n===null)r.push([y.float.majorEncoded|cm]);else if(n===void 0)r.push([y.float.majorEncoded|um]);else{let o,i=!1;(!t||t.float64!==!0)&&(Ef(n),o=wa(ot,1),n===o||Number.isNaN(n)?(ot[0]=249,r.push(ot.slice(0,3)),i=!0):(Bf(n),o=ba(ot,1),n===o&&(ot[0]=250,r.push(ot.slice(0,5)),i=!0))),i||(lm(n),o=Af(ot,1),ot[0]=251,r.push(ot.slice(0,9)))}}gi.encodedSize=function(e,t){let n=e.value;if(n===!1||n===!0||n===null||n===void 0)return 1;if(!t||t.float64!==!0){Ef(n);let o=wa(ot,1);if(n===o||Number.isNaN(n))return 3;if(Bf(n),o=ba(ot,1),n===o)return 5}return 9};var vf=new ArrayBuffer(9),je=new DataView(vf,1),ot=new Uint8Array(vf,0);function Ef(r){if(r===1/0)je.setUint16(0,31744,!1);else if(r===-1/0)je.setUint16(0,64512,!1);else if(Number.isNaN(r))je.setUint16(0,32256,!1);else{je.setFloat32(0,r);let e=je.getUint32(0),t=(e&2139095040)>>23,n=e&8388607;if(t===255)je.setUint16(0,31744,!1);else if(t===0)je.setUint16(0,(r&2147483648)>>16|n>>13,!1);else{let o=t-127;o<-24?je.setUint16(0,0):o<-14?je.setUint16(0,(e&2147483648)>>16|1<<24+o,!1):je.setUint16(0,(e&2147483648)>>16|o+15<<10|n>>13,!1)}}}function wa(r,e){if(r.length-e<2)throw new Error(`${$} not enough data for float16`);let t=(r[e]<<8)+r[e+1];if(t===31744)return 1/0;if(t===64512)return-1/0;if(t===32256)return NaN;let n=t>>10&31,o=t&1023,i;return n===0?i=o*2**-24:n!==31?i=(o+1024)*2**(n-25):i=o===0?1/0:NaN,t&32768?-i:i}function Bf(r){je.setFloat32(0,r,!1)}function ba(r,e){if(r.length-e<4)throw new Error(`${$} not enough data for float32`);let t=(r.byteOffset||0)+e;return new DataView(r.buffer,t,4).getFloat32(0,!1)}function lm(r){je.setFloat64(0,r,!1)}function Af(r,e){if(r.length-e<8)throw new Error(`${$} not enough data for float64`);let t=(r.byteOffset||0)+e;return new DataView(r.buffer,t,8).getFloat64(0,!1)}gi.compareTokens=ze.compareTokens;function Y(r,e,t){throw new Error(`${$} encountered invalid minor (${t}) for major ${r[e]>>>5}`)}function yi(r){return()=>{throw new Error(`${$} ${r}`)}}var k=[];for(let r=0;r<=23;r++)k[r]=Y;k[24]=Rl;k[25]=_l;k[26]=Vl;k[27]=Ll;k[28]=Y;k[29]=Y;k[30]=Y;k[31]=Y;for(let r=32;r<=55;r++)k[r]=Y;k[56]=Pl;k[57]=Fl;k[58]=Ol;k[59]=Ml;k[60]=Y;k[61]=Y;k[62]=Y;k[63]=Y;for(let r=64;r<=87;r++)k[r]=$l;k[88]=Hl;k[89]=Kl;k[90]=ql;k[91]=zl;k[92]=Y;k[93]=Y;k[94]=Y;k[95]=yi("indefinite length bytes/strings are not supported");for(let r=96;r<=119;r++)k[r]=jl;k[120]=Gl;k[121]=Zl;k[122]=Wl;k[123]=Yl;k[124]=Y;k[125]=Y;k[126]=Y;k[127]=yi("indefinite length bytes/strings are not supported");for(let r=128;r<=151;r++)k[r]=Xl;k[152]=Ql;k[153]=ef;k[154]=tf;k[155]=rf;k[156]=Y;k[157]=Y;k[158]=Y;k[159]=nf;for(let r=160;r<=183;r++)k[r]=of;k[184]=sf;k[185]=af;k[186]=cf;k[187]=uf;k[188]=Y;k[189]=Y;k[190]=Y;k[191]=lf;for(let r=192;r<=215;r++)k[r]=ff;k[216]=df;k[217]=hf;k[218]=pf;k[219]=mf;k[220]=Y;k[221]=Y;k[222]=Y;k[223]=Y;for(let r=224;r<=243;r++)k[r]=yi("simple values are not supported");k[244]=Y;k[245]=Y;k[246]=Y;k[247]=gf;k[248]=yi("simple values are not supported");k[249]=xf;k[250]=wf;k[251]=bf;k[252]=Y;k[253]=Y;k[254]=Y;k[255]=yf;var it=[];for(let r=0;r<24;r++)it[r]=new V(y.uint,r,1);for(let r=-1;r>=-24;r--)it[31-r]=new V(y.negint,r,1);it[64]=new V(y.bytes,new Uint8Array(0),1);it[96]=new V(y.string,"",1);it[128]=new V(y.array,0,1);it[160]=new V(y.map,0,1);it[244]=new V(y.false,!1,1);it[245]=new V(y.true,!0,1);it[246]=new V(y.null,null,1);function dm(){let r=[];return r[y.uint.major]=ze,r[y.negint.major]=fi,r[y.bytes.major]=$r,r[y.string.major]=Jl,r[y.array.major]=hi,r[y.map.major]=pi,r[y.tag.major]=mi,r[y.float.major]=gi,r}var rv=dm(),nv=new li,xi=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(`${ga} object contains circular references`);return new r(t,e)}},jt={null:new V(y.null,null),undefined:new V(y.undefined,void 0),true:new V(y.true,!0),false:new V(y.false,!1),emptyArray:new V(y.array,0),emptyMap:new V(y.map,0)},Gt={number(r,e,t,n){return!Number.isInteger(r)||!Number.isSafeInteger(r)?new V(y.float,r):r>=0?new V(y.uint,r):new V(y.negint,r)},bigint(r,e,t,n){return r>=BigInt(0)?new V(y.uint,r):new V(y.negint,r)},Uint8Array(r,e,t,n){return new V(y.bytes,r)},string(r,e,t,n){return new V(y.string,r)},boolean(r,e,t,n){return r?jt.true:jt.false},null(r,e,t,n){return jt.null},undefined(r,e,t,n){return jt.undefined},ArrayBuffer(r,e,t,n){return new V(y.bytes,new Uint8Array(r))},DataView(r,e,t,n){return new V(y.bytes,new Uint8Array(r.buffer,r.byteOffset,r.byteLength))},Array(r,e,t,n){if(!r.length)return t.addBreakTokens===!0?[jt.emptyArray,new V(y.break)]:jt.emptyArray;n=xi.createCheck(n,r);let o=[],i=0;for(let s of r)o[i++]=va(s,t,n);return t.addBreakTokens?[new V(y.array,r.length),o,new V(y.break)]:[new V(y.array,r.length),o]},Object(r,e,t,n){let o=e!=="Object",i=o?r.keys():Object.keys(r),s=o?r.size:i.length;if(!s)return t.addBreakTokens===!0?[jt.emptyMap,new V(y.break)]:jt.emptyMap;n=xi.createCheck(n,r);let a=[],c=0;for(let f of i)a[c++]=[va(f,t,n),va(o?r.get(f):r[f],t,n)];return hm(a,t),t.addBreakTokens?[new V(y.map,s),a,new V(y.break)]:[new V(y.map,s),a]}};Gt.Map=Gt.Object;Gt.Buffer=Gt.Uint8Array;for(let r of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))Gt[`${r}Array`]=Gt.DataView;function va(r,e={},t){let n=El(r),o=e&&e.typeEncoders&&e.typeEncoders[n]||Gt[n];if(typeof o=="function"){let s=o(r,n,e,t);if(s!=null)return s}let i=Gt[n];if(!i)throw new Error(`${ga} unsupported type: ${n}`);return i(r,n,e,t)}function hm(r,e){e.mapSorter&&r.sort(e.mapSorter)}var pm={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0},wi=class{constructor(e,t={}){this._pos=0,this.data=e,this.options=t}pos(){return this._pos}done(){return this._pos>=this.data.length}next(){let e=this.data[this._pos],t=it[e];if(t===void 0){let n=k[e];if(!n)throw new Error(`${$} no decoder for major type ${e>>>5} (byte 0x${e.toString(16).padStart(2,"0")})`);let o=e&31;t=n(this.data,this._pos,o,this.options)}return this._pos+=t.encodedLength,t}},Sn=Symbol.for("DONE"),bi=Symbol.for("BREAK");function mm(r,e,t){let n=[];for(let o=0;o<r.value;o++){let i=qr(e,t);if(i===bi){if(r.value===1/0)break;throw new Error(`${$} got unexpected break to lengthed array`)}if(i===Sn)throw new Error(`${$} found array but not enough entries (got ${o}, expected ${r.value})`);n[o]=i}return n}function gm(r,e,t){let n=t.useMaps===!0,o=n?void 0:{},i=n?new Map:void 0;for(let s=0;s<r.value;s++){let a=qr(e,t);if(a===bi){if(r.value===1/0)break;throw new Error(`${$} got unexpected break to lengthed map`)}if(a===Sn)throw new Error(`${$} found map but not enough entries (got ${s} [no key], expected ${r.value})`);if(n!==!0&&typeof a!="string")throw new Error(`${$} non-string keys not supported (got ${typeof a})`);if(t.rejectDuplicateMapKeys===!0&&(n&&i.has(a)||!n&&a in o))throw new Error(`${$} found repeat map key "${a}"`);let c=qr(e,t);if(c===Sn)throw new Error(`${$} found map but not enough entries (got ${s} [no value], expected ${r.value})`);n?i.set(a,c):o[a]=c}return n?i:o}function qr(r,e){if(r.done())return Sn;let t=r.next();if(t.type===y.break)return bi;if(t.type.terminal)return t.value;if(t.type===y.array)return mm(t,r,e);if(t.type===y.map)return gm(t,r,e);if(t.type===y.tag){if(e.tags&&typeof e.tags[t.value]=="function"){let n=qr(r,e);return e.tags[t.value](n)}throw new Error(`${$} tag not supported (${t.value})`)}throw new Error("unsupported")}function Sf(r,e){if(!(r instanceof Uint8Array))throw new Error(`${$} data to decode must be a Uint8Array`);e=Object.assign({},pm,e);let t=e.tokenizer||new wi(r,e),n=qr(t,e);if(n===Sn)throw new Error(`${$} did not find any content to decode`);if(n===bi)throw new Error(`${$} got unexpected break`);return[n,r.subarray(t.pos())]}function Ea(r,e){let[t,n]=Sf(r,e);if(n.length>0)throw new Error(`${$} too many terminals, data makes no sense`);return t}var wm=Rt("ipns:utils"),If=Z("/ipns/");var bm=0,vm=18;function kf(r){let e;if(r.pubKey!=null)try{e=tl(r.pubKey)}catch(t){throw wm.error(t),t}if(e!=null)return e}function Cf(r){let e=Z("ipns-signature:");return De([e,r])}function cr(r){return"signatureV1"in r?nt.encode({value:Z(r.value),signatureV1:r.signatureV1,validityType:r.validityType,validity:Z(r.validity),sequence:r.sequence,ttl:r.ttl,pubKey:r.pubKey,signatureV2:r.signatureV2,data:r.data}):nt.encode({pubKey:r.pubKey,signatureV2:r.signatureV2,data:r.data})}function dt(r){let e=nt.decode(r);if(e.sequence!=null&&(e.sequence=BigInt(e.sequence)),e.ttl!=null&&(e.ttl=BigInt(e.ttl)),e.signatureV2==null||e.data==null)throw new rt("Missing data or signatureV2");let t=Tf(e.data),n=Em(t.Value),o=W(t.Validity);if(e.value!=null&&e.signatureV1!=null)return Bm(e),{value:n,validityType:nt.ValidityType.EOL,validity:o,sequence:t.Sequence,ttl:t.TTL,pubKey:e.pubKey,signatureV1:e.signatureV1,signatureV2:e.signatureV2,data:e.data};if(e.signatureV2!=null)return{value:n,validityType:nt.ValidityType.EOL,validity:o,sequence:t.Sequence,ttl:t.TTL,pubKey:e.pubKey,signatureV2:e.signatureV2,data:e.data};throw new Error("invalid record: does not include signatureV1 or signatureV2")}function In(r){return De([If,r.bytes])}function Nt(r){let e=gt(r.slice(If.length));if(!vi(e,bm)&&!vi(e,vm))throw new fr("Multihash in IPNS key was not identity or sha2-256");return e}function Tf(r){let e=Ea(r);if(e.ValidityType===0)e.ValidityType=nt.ValidityType.EOL;else throw new Or("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 Em(r){let e=W(r).trim();if(e.startsWith("/"))return e;try{return`/ipfs/${Q.decode(r).toV1().toString()}`}catch{}try{return`/ipfs/${Q.parse(e).toV1().toString()}`}catch{}throw new ai("Value must be a valid content path starting with /")}function Bm(r){if(r.data==null)throw new ci("Record data is missing");let e=Tf(r.data);if(!ce(e.Value,r.value??new Uint8Array(0)))throw new rt('Field "value" did not match between protobuf and CBOR');if(!ce(e.Validity,r.validity??new Uint8Array(0)))throw new rt('Field "validity" did not match between protobuf and CBOR');if(e.ValidityType!==r.validityType)throw new rt('Field "validityType" did not match between protobuf and CBOR');if(e.Sequence!==r.sequence)throw new rt('Field "sequence" did not match between protobuf and CBOR');if(e.TTL!==r.ttl)throw new rt('Field "ttl" did not match between protobuf and CBOR')}function vi(r,e){return r.code===e}var kv=Rt("ipns"),Cv=60*60*1e9,Sm="/ipns/",Tv=Sm.length;var Nf=_n(ma(),1);var Ei=Rt("ipns:validator"),Im=1024*10,km=async(r,e)=>{let t=dt(e),n;try{let o=Cf(t.data);n=await r.verify(o,t.signatureV2)}catch{n=!1}if(!n)throw Ei.error("record signature verification failed"),new rt("Record signature verification failed");if(t.validityType===nt.ValidityType.EOL){if(Nf.default.fromString(t.validity).toDate().getTime()<Date.now())throw Ei.error("record has expired"),new ii("record has expired")}else if(t.validityType!=null)throw Ei.error("the validity type is unsupported"),new Or("The validity type is unsupported");Ei("ipns record for %s is valid",t.value)};async function Uf(r,e){if(e.byteLength>Im)throw new si("The record is too large");let t=Nt(r),n;vi(t,0)&&(n=Yo(t));let o=dt(e),i=kf(o)??n;if(i==null)throw new vn("Could not extract public key from IPNS record or routing key");let s=In(i.toMultihash());if(!ce(r,s))throw new vn("Embedded public key did not match routing key");await km(i,e)}async function*kn(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 ht(){let r={};return r.promise=new Promise((e,t)=>{r.resolve=e,r.reject=t}),r}var Aa=_n(_f(),1);var Tn=class extends Error{constructor(e){super(e),this.name="TimeoutError"}},Sa=class extends Error{constructor(e){super(),this.name="AbortError",this.message=e}},Vf=r=>globalThis.DOMException===void 0?new Sa(r):new DOMException(r),Lf=r=>{let e=r.reason===void 0?Vf("This operation was aborted."):r.reason;return e instanceof Error?e:Vf(e)};function Ia(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:d}=e;d.aborted&&u(Lf(d)),d.addEventListener("abort",()=>{u(Lf(d))})}if(t===Number.POSITIVE_INFINITY){r.then(f,u);return}let l=new Tn;s=i.setTimeout.call(void 0,()=>{if(n){try{f(n())}catch(d){u(d)}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(d){u(d)}})()}).finally(()=>{c.clear()});return c.clear=()=>{i.clearTimeout.call(void 0,s),s=void 0},c}function ka(r,e,t){let n=0,o=r.length;for(;o>0;){let i=Math.trunc(o/2),s=n+i;t(r[s],e)<=0?(n=++s,o-=i+1):o=i}return n}var Nn=class{#e=[];enqueue(e,t){t={priority:0,...t};let n={priority:t.priority,run:e};if(this.size&&this.#e[this.size-1].priority>=t.priority){this.#e.push(n);return}let o=ka(this.#e,n,(i,s)=>s.priority-i.priority);this.#e.splice(o,0,n)}dequeue(){return this.#e.shift()?.run}filter(e){return this.#e.filter(t=>t.priority===e.priority).map(t=>t.run)}get size(){return this.#e.length}};var Un=class extends Aa.default{#e;#r;#i=0;#a;#c;#p=0;#n;#u;#t;#m;#o=0;#l;#s;#g;timeout;constructor(e){if(super(),e={carryoverConcurrencyCount:!1,intervalCap:Number.POSITIVE_INFINITY,interval:0,concurrency:Number.POSITIVE_INFINITY,autoStart:!0,queueClass:Nn,...e},!(typeof e.intervalCap=="number"&&e.intervalCap>=1))throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${e.intervalCap?.toString()??""}\` (${typeof e.intervalCap})`);if(e.interval===void 0||!(Number.isFinite(e.interval)&&e.interval>=0))throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${e.interval?.toString()??""}\` (${typeof e.interval})`);this.#e=e.carryoverConcurrencyCount,this.#r=e.intervalCap===Number.POSITIVE_INFINITY||e.interval===0,this.#a=e.intervalCap,this.#c=e.interval,this.#t=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#w(){return this.#r||this.#i<this.#a}get#b(){return this.#o<this.#l}#v(){this.#o--,this.#f(),this.emit("next")}#E(){this.#x(),this.#y(),this.#u=void 0}get#B(){let e=Date.now();if(this.#n===void 0){let t=this.#p-e;if(t<0)this.#i=this.#e?this.#o:0;else return this.#u===void 0&&(this.#u=setTimeout(()=>{this.#E()},t)),!0}return!1}#f(){if(this.#t.size===0)return this.#n&&clearInterval(this.#n),this.#n=void 0,this.emit("empty"),this.#o===0&&this.emit("idle"),!1;if(!this.#s){let e=!this.#B;if(this.#w&&this.#b){let t=this.#t.dequeue();return t?(this.emit("active"),t(),e&&this.#y(),!0):!1}}return!1}#y(){this.#r||this.#n!==void 0||(this.#n=setInterval(()=>{this.#x()},this.#c),this.#p=Date.now()+this.#c)}#x(){this.#i===0&&this.#o===0&&this.#n&&(clearInterval(this.#n),this.#n=void 0),this.#i=this.#e?this.#o:0,this.#d()}#d(){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.#d()}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.#t.enqueue(async()=>{this.#o++,this.#i++;try{t.signal?.throwIfAborted();let i=e({signal:t.signal});t.timeout&&(i=Ia(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 Tn&&!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.#d(),this):this}pause(){this.#s=!0}clear(){this.#t=new this.#m}async onEmpty(){this.#t.size!==0&&await this.#h("empty")}async onSizeLessThan(e){this.#t.size<e||await this.#h("next",()=>this.#t.size<e)}async onIdle(){this.#o===0&&this.#t.size===0||await this.#h("idle")}async#h(e,t){return new Promise(n=>{let o=()=>{t&&!t()||(this.off(e,o),n())};this.on(e,o)})}get size(){return this.#t.size}sizeBy(e){return this.#t.filter(e).length}get pending(){return this.#o}get isPaused(){return this.#s}};var zr=class extends Error{static name="InvalidRequestError";constructor(e="Invalid request"){super(e),this.name="InvalidRequestError"}},ur=class extends Error{static name="BadResponseError";constructor(e="Bad response"){super(e),this.name="BadResponseError"}};function Nm(r){return r[Symbol.asyncIterator]!=null}function Um(r){if(Nm(r))return(async()=>{for await(let e of r)return e})();for(let e of r)return e}var Ai=Um;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 Pf=Rm;function _m(r){return r[Symbol.asyncIterator]!=null}function Vm(r,e){let t=0;if(_m(r))return async function*(){for await(let c of r)yield e(c,t++)}();let n=Pf(r),{value:o,done:i}=n.next();if(i===!0)return function*(){}();let s=e(o,t++);if(typeof s.then=="function")return async function*(){yield await s;for await(let c of n)yield e(c,t++)}();let a=e;return function*(){yield s;for(let c of n)yield a(c,t++)}()}var Si=Vm;var Ff=Z("/ipns/");function Of(r){return ce(r.subarray(0,Ff.byteLength),Ff)}var Ii=class{client;constructor(e){this.client=e}async*findProviders(e,t={}){yield*Si(this.client.getProviders(e,t),n=>({id:n.ID,multiaddrs:n.Addrs??[]}))}async provide(){}async put(e,t,n){if(!Of(e))return;let o=Nt(e),i=Q.createV1(114,o),s=dt(t);await this.client.putIPNS(i,s,n)}async get(e,t){if(!Of(e))throw new Re("Not found");let n=Nt(e),o=Q.createV1(114,n);try{let i=await this.client.getIPNS(o,t);return cr(i)}catch(i){throw i.name==="BadResponseError"?new Re("Not found"):i}}},ki=class{client;constructor(e){this.client=e}async findPeer(e,t={}){let n=await Ai(this.client.getPeers(e,t));if(n!=null)return{id:n.ID,multiaddrs:n.Addrs??[]};throw new Re("Not found")}async*getClosestPeers(e,t={}){}};var Ne=Rt("delegated-routing-v1-http-api-client"),Df={concurrentRequests:4,timeout:3e4},Ci=class{started;httpQueue;shutDownController;clientUrl;timeout;contentRouting;peerRouting;constructor(e,t={}){this.started=!1,this.shutDownController=new AbortController,hr(1/0,this.shutDownController.signal),this.httpQueue=new Un({concurrency:t.concurrentRequests??Df.concurrentRequests}),this.clientUrl=e instanceof URL?e:new URL(e),this.timeout=t.timeout??Df.timeout,this.contentRouting=new Ii(this),this.peerRouting=new ki(this)}get[ja](){return this.contentRouting}get[Ga](){return this.peerRouting}isStarted(){return this.started}start(){this.started=!0}stop(){this.httpQueue.clear(),this.shutDownController.abort(),this.started=!1}async*getProviders(e,t={}){Ne("getProviders starts: %c",e);let n=AbortSignal.timeout(this.timeout),o=bn([this.shutDownController.signal,n,t.signal]);hr(1/0,n,o);let i=ht(),s=ht();this.httpQueue.add(async()=>(i.resolve(),s.promise));try{await i.promise;let a=`${this.clientUrl}routing/v1/providers/${e.toString()}`,f=await fetch(a,{headers:{Accept:"application/x-ndjson"},signal:o});if(f.status===404)throw new Re("No matching records found");if(f.status===422)throw new zr("Request does not conform to schema or semantic constraints");if(f.body==null)throw new ur("Routing response had no body");if(f.headers.get("Content-Type")==="application/json"){let l=await f.json();for(let d of l.Providers){let b=this.#e(d);b!=null&&(yield b)}}else for await(let l of kn(oi(f.body))){let d=this.#e(l);d!=null&&(yield d)}}catch(a){Ne.error("getProviders errored:",a)}finally{o.clear(),s.resolve(),Ne("getProviders finished: %c",e)}}async*getPeers(e,t={}){Ne("getPeers starts: %c",e);let n=AbortSignal.timeout(this.timeout),o=bn([this.shutDownController.signal,n,t.signal]);hr(1/0,n,o);let i=ht(),s=ht();this.httpQueue.add(async()=>(i.resolve(),s.promise));try{await i.promise;let a=`${this.clientUrl}routing/v1/peers/${e.toCID().toString()}`,f=await fetch(a,{headers:{Accept:"application/x-ndjson"},signal:o});if(f.status===404)throw new Re("No matching records found");if(f.status===422)throw new zr("Request does not conform to schema or semantic constraints");if(f.body==null)throw new ur("Routing response had no body");if(f.headers.get("Content-Type")==="application/json"){let l=await f.json();for(let d of l.Peers){let b=this.#e(d);b!=null&&(yield b)}}else for await(let l of kn(oi(f.body))){let d=this.#e(l);d!=null&&(yield d)}}catch(a){Ne.error("getPeers errored:",a)}finally{o.clear(),s.resolve(),Ne("getPeers finished: %c",e)}}async getIPNS(e,t={}){Ne("getIPNS starts: %s",e);let n=AbortSignal.timeout(this.timeout),o=bn([this.shutDownController.signal,n,t.signal]);hr(1/0,n,o);let i=ht(),s=ht();this.httpQueue.add(async()=>(i.resolve(),s.promise));let a=`${this.clientUrl}routing/v1/ipns/${e}`;try{await i.promise;let f=await fetch(a,{headers:{Accept:"application/vnd.ipfs.ipns-record"},signal:o});if(Ne("getIPNS GET %s %d",a,f.status),f.status===404)throw new Re("No matching records found");if(f.status===422)throw new zr("Request does not conform to schema or semantic constraints");if(f.body==null)throw new ur("GET ipns response had no body");let u=await f.arrayBuffer(),l=new Uint8Array(u,0,u.byteLength);return t.validate!==!1&&await Uf(In(e.multihash),l),dt(l)}catch(c){throw Ne.error("getIPNS GET %s error:",a,c),c}finally{o.clear(),s.resolve(),Ne("getIPNS finished: %s",e)}}async putIPNS(e,t,n={}){Ne("putIPNS starts: %c",e);let o=AbortSignal.timeout(this.timeout),i=bn([this.shutDownController.signal,o,n.signal]);hr(1/0,o,i);let s=ht(),a=ht();this.httpQueue.add(async()=>(s.resolve(),a.promise));let c=`${this.clientUrl}routing/v1/ipns/${e}`;try{await s.promise;let f=cr(t),l=await fetch(c,{method:"PUT",headers:{"Content-Type":"application/vnd.ipfs.ipns-record"},body:f,signal:i});if(Ne("putIPNS PUT %s %d",c,l.status),l.status!==200)throw new ur("PUT ipns response had status other than 200")}catch(f){throw Ne.error("putIPNS PUT %s error:",c,f.stack),f}finally{i.clear(),a.resolve(),Ne("putIPNS finished: %c",e)}}#e(e){try{let t=[],n=e.Addrs?.map(sr)??[];return e.Protocols!=null&&t.push(...e.Protocols),e.Protocol!=null&&(t.push(e.Protocol),delete e.Protocol),{...e,Schema:"peer",ID:ol(e.ID),Addrs:n,Protocols:t}}catch(t){Ne.error("could not conform record to peer schema",t)}}};function Mf(r,e={}){return new Ci(new URL(r),e)}var $f=Z("/ipns/");function Hf(r){return ce(r.subarray(0,$f.byteLength),$f)}var Ca=class{client;constructor(e){this.client=Mf(e)}async provide(e,t){}async*findProviders(e,t){yield*Si(this.client.getProviders(e,t),n=>({id:n.ID,multiaddrs:n.Addrs,protocols:n.Protocols}))}async put(e,t,n){if(!Hf(e))return;let o=Nt(e),i=Q.createV1(114,o),s=dt(t);await this.client.putIPNS(i,s,n)}async get(e,t){if(!Hf(e))throw new Re("Not found");let n=Nt(e),o=Q.createV1(114,n);try{let i=await this.client.getIPNS(o,t);return cr(i)}catch(i){throw i.name==="BadResponseError"?new Re("Not found"):i}}async findPeer(e,t){let n=await Ai(this.client.getPeers(e,t));if(n!=null)return{id:n.ID,multiaddrs:n.Addrs??[]};throw new Re("Not found")}async*getClosestPeers(e,t){}};function Kf(r){return new Ca(new URL(r))}var qf="[a-fA-F\\d:]",Zt=r=>r&&r.includeBoundaries?`(?:(?<=\\s|^)(?=${qf})|(?<=${qf})(?=\\s|$))`:"",st="(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}",ue="[a-fA-F\\d]{1,4}",Ti=`
9
8
  (?:
10
- (?:${pe}:){7}(?:${pe}|:)| // 1:2:3:4:5:6:7:: 1:2:3:4:5:6:7:8
11
- (?:${pe}:){6}(?:${lt}|:${pe}|:)| // 1:2:3:4:5:6:: 1:2:3:4:5:6::8 1:2:3:4:5:6::8 1:2:3:4:5:6::1.2.3.4
12
- (?:${pe}:){5}(?::${lt}|(?::${pe}){1,2}|:)| // 1:2:3:4:5:: 1:2:3:4:5::7:8 1:2:3:4:5::8 1:2:3:4:5::7:1.2.3.4
13
- (?:${pe}:){4}(?:(?::${pe}){0,1}:${lt}|(?::${pe}){1,3}|:)| // 1:2:3:4:: 1:2:3:4::6:7:8 1:2:3:4::8 1:2:3:4::6:7:1.2.3.4
14
- (?:${pe}:){3}(?:(?::${pe}){0,2}:${lt}|(?::${pe}){1,4}|:)| // 1:2:3:: 1:2:3::5:6:7:8 1:2:3::8 1:2:3::5:6:7:1.2.3.4
15
- (?:${pe}:){2}(?:(?::${pe}){0,3}:${lt}|(?::${pe}){1,5}|:)| // 1:2:: 1:2::4:5:6:7:8 1:2::8 1:2::4:5:6:7:1.2.3.4
16
- (?:${pe}:){1}(?:(?::${pe}){0,4}:${lt}|(?::${pe}){1,6}|:)| // 1:: 1::3:4:5:6:7:8 1::8 1::3:4:5:6:7:1.2.3.4
17
- (?::(?:(?::${pe}){0,5}:${lt}|(?::${pe}){1,7}|:)) // ::2:3:4:5:6:7:8 ::2:3:4:5:6:7:8 ::8 ::1.2.3.4
9
+ (?:${ue}:){7}(?:${ue}|:)| // 1:2:3:4:5:6:7:: 1:2:3:4:5:6:7:8
10
+ (?:${ue}:){6}(?:${st}|:${ue}|:)| // 1:2:3:4:5:6:: 1:2:3:4:5:6::8 1:2:3:4:5:6::8 1:2:3:4:5:6::1.2.3.4
11
+ (?:${ue}:){5}(?::${st}|(?::${ue}){1,2}|:)| // 1:2:3:4:5:: 1:2:3:4:5::7:8 1:2:3:4:5::8 1:2:3:4:5::7:1.2.3.4
12
+ (?:${ue}:){4}(?:(?::${ue}){0,1}:${st}|(?::${ue}){1,3}|:)| // 1:2:3:4:: 1:2:3:4::6:7:8 1:2:3:4::8 1:2:3:4::6:7:1.2.3.4
13
+ (?:${ue}:){3}(?:(?::${ue}){0,2}:${st}|(?::${ue}){1,4}|:)| // 1:2:3:: 1:2:3::5:6:7:8 1:2:3::8 1:2:3::5:6:7:1.2.3.4
14
+ (?:${ue}:){2}(?:(?::${ue}){0,3}:${st}|(?::${ue}){1,5}|:)| // 1:2:: 1:2::4:5:6:7:8 1:2::8 1:2::4:5:6:7:1.2.3.4
15
+ (?:${ue}:){1}(?:(?::${ue}){0,4}:${st}|(?::${ue}){1,6}|:)| // 1:: 1::3:4:5:6:7:8 1::8 1::3:4:5:6:7:1.2.3.4
16
+ (?::(?:(?::${ue}){0,5}:${st}|(?::${ue}){1,7}|:)) // ::2:3:4:5:6:7:8 ::2:3:4:5:6:7:8 ::8 ::1.2.3.4
18
17
  )(?:%[0-9a-zA-Z]{1,})? // %eth0 %1
19
- `.replace(/\s*\/\/.*$/gm,"").replace(/\n/g,"").trim(),bm=new RegExp(`(?:^${lt}$)|(?:^${Li}$)`),xm=new RegExp(`^${lt}$`),Em=new RegExp(`^${Li}$`),La=r=>r&&r.exact?bm:new RegExp(`(?:${nr(r)}${lt}${nr(r)})|(?:${nr(r)}${Li}${nr(r)})`,"g");La.v4=r=>r&&r.exact?xm:new RegExp(`${nr(r)}${lt}${nr(r)}`,"g");La.v6=r=>r&&r.exact?Em:new RegExp(`${nr(r)}${Li}${nr(r)}`,"g");var Da=La;function Va(r){let e=(...t)=>r(...t);return Object.defineProperty(e,"name",{value:`functionTimeout(${r.name||"<anonymous>"})`,configurable:!0}),e}function fh(){return!1}var{toString:vm}=Object.prototype;function Oa(r){return vm.call(r)==="[object RegExp]"}var hh={global:"g",ignoreCase:"i",multiline:"m",dotAll:"s",sticky:"y",unicode:"u"};function Pa(r,e={}){if(!Oa(r))throw new TypeError("Expected a RegExp instance");let t=Object.keys(hh).map(o=>(typeof e[o]=="boolean"?e[o]:r[o])?hh[o]:"").join(""),n=new RegExp(e.source||r.source,t);return n.lastIndex=typeof e.lastIndex=="number"?e.lastIndex:r.lastIndex,n}function Fa(r,e,{timeout:t}={}){try{return Va(()=>Pa(r).test(e),{timeout:t})()}catch(n){if(fh(n))return!1;throw n}}var Bm=15,Am=45,dh={timeout:400};function Ma(r){return r.length>Am?!1:Fa(Da.v6({exact:!0}),r,dh)}function ph(r){return r.length>Bm?!1:Fa(Da.v4({exact:!0}),r,dh)}var gh={http:"80",https:"443",ws:"80",wss:"443"},Sm=["http","https","ws","wss"];function mh(r,e){e=e??{};let t=e.defaultDnsType??"dns4",{scheme:n,hostname:o,port:i}=Im(r),a="/"+[Rm(o,t),km(i,n),Tm(n)].filter(c=>!!c).reduce((c,f)=>c.concat(f),[]).join("/");return cr(a)}function Im(r){let[e]=r.split(":");Sm.includes(e)||(r="http"+r.substring(e.length));let{protocol:t,hostname:n,port:o}=new URL(r);if(o==null||o===""){let i=Nm(e);i!=null&&(o=i),i==null&&t==="http:"&&(o="80")}return{scheme:e,hostname:n,port:o}}function Rm(r,e){if(!(r==null||r==="")){if(ph(r))return["ip4",r];if(Ma(r))return["ip6",r];if(r[0]==="["){let t=r.substring(1,r.length-1);if(Ma(t))return["ip6",t]}return[e,r]}}function km(r,e){if(!(r==null||r===""))return e==="udp"?["udp",r]:["tcp",r]}function Tm(r){if(r.match(/^tcp$|^udp$/)==null)return[r]}function Nm(r){if(!(r==null||r===""||gh[r]==null))return gh[r]}var Cm=["https://trustless-gateway.link","https://4everland.io"],_m=2336,Um=Symbol.for("nodejs.util.inspect.custom"),Ha=class{type="url";multihash;privateKey;publicKey;url;constructor(e){this.url=e.toString(),this.multihash=Me.digest(z(this.url))}[Um](){return`PeerId(${this.url})`}[xr]=!0;toString(){return this.toCID().toString()}toCID(){return we.createV1(_m,this.multihash)}toBytes(){return this.toCID().bytes}equals(e){return e==null?!1:(e instanceof Uint8Array&&(e=G(e)),e.toString()===this.toString())}};function Lm(r){return r=r.toString(),{id:new Ha(new URL(r)),multiaddrs:[mh(r)]}}var $a=class{gateways;constructor(e={}){this.gateways=(e.gateways??Cm).map(t=>Lm(t))}async*findProviders(e,t){yield*this.gateways.toSorted(()=>Math.random()>.5?1:-1).map(n=>({...n,protocols:["transport-ipfs-gateway-http"]}))}};function yh(r={}){return new $a(r)}var Ka=class{libp2p;constructor(e){this.libp2p=e}async provide(e,t){await this.libp2p.contentRouting.provide(e,t)}async*findProviders(e,t){yield*this.libp2p.contentRouting.findProviders(e,t)}async put(e,t,n){await this.libp2p.contentRouting.put(e,t,n)}async get(e,t){return this.libp2p.contentRouting.get(e,t)}async findPeer(e,t){return this.libp2p.peerRouting.findPeer(e,t)}async*getClosestPeers(e,t){yield*this.libp2p.peerRouting.getClosestPeers(e,t)}};function wh(r){return new Ka(r)}return _h(Dm);})();
18
+ `.replace(/\s*\/\/.*$/gm,"").replace(/\n/g,"").trim(),Lm=new RegExp(`(?:^${st}$)|(?:^${Ti}$)`),Pm=new RegExp(`^${st}$`),Fm=new RegExp(`^${Ti}$`),Ta=r=>r&&r.exact?Lm:new RegExp(`(?:${Zt(r)}${st}${Zt(r)})|(?:${Zt(r)}${Ti}${Zt(r)})`,"g");Ta.v4=r=>r&&r.exact?Pm:new RegExp(`${Zt(r)}${st}${Zt(r)}`,"g");Ta.v6=r=>r&&r.exact?Fm:new RegExp(`${Zt(r)}${Ti}${Zt(r)}`,"g");var Na=Ta;function Ua(r){let e=(...t)=>r(...t);return Object.defineProperty(e,"name",{value:`functionTimeout(${r.name||"<anonymous>"})`,configurable:!0}),e}function zf(){return!1}var{toString:Om}=Object.prototype;function Ra(r){return Om.call(r)==="[object RegExp]"}var jf={global:"g",ignoreCase:"i",multiline:"m",dotAll:"s",sticky:"y",unicode:"u"};function _a(r,e={}){if(!Ra(r))throw new TypeError("Expected a RegExp instance");let t=Object.keys(jf).map(o=>(typeof e[o]=="boolean"?e[o]:r[o])?jf[o]:"").join(""),n=new RegExp(e.source||r.source,t);return n.lastIndex=typeof e.lastIndex=="number"?e.lastIndex:r.lastIndex,n}function Va(r,e,{timeout:t}={}){try{return Ua(()=>_a(r).test(e),{timeout:t})()}catch(n){if(zf(n))return!1;throw n}}var Dm=15,Mm=45,Gf={timeout:400};function La(r){return r.length>Mm?!1:Va(Na.v6({exact:!0}),r,Gf)}function Zf(r){return r.length>Dm?!1:Va(Na.v4({exact:!0}),r,Gf)}var Wf={http:"80",https:"443",ws:"80",wss:"443"},$m=["http","https","ws","wss"];function Yf(r,e){e=e??{};let t=e.defaultDnsType??"dns4",{scheme:n,hostname:o,port:i}=Hm(r),a="/"+[Km(o,t),qm(i,n),zm(n)].filter(c=>!!c).reduce((c,f)=>c.concat(f),[]).join("/");return sr(a)}function Hm(r){let[e]=r.split(":");$m.includes(e)||(r="http"+r.substring(e.length));let{protocol:t,hostname:n,port:o}=new URL(r);if(o==null||o===""){let i=jm(e);i!=null&&(o=i),i==null&&t==="http:"&&(o="80")}return{scheme:e,hostname:n,port:o}}function Km(r,e){if(!(r==null||r==="")){if(Zf(r))return["ip4",r];if(La(r))return["ip6",r];if(r[0]==="["){let t=r.substring(1,r.length-1);if(La(t))return["ip6",t]}return[e,r]}}function qm(r,e){if(!(r==null||r===""))return e==="udp"?["udp",r]:["tcp",r]}function zm(r){if(r.match(/^tcp$|^udp$/)==null)return[r]}function jm(r){if(!(r==null||r===""||Wf[r]==null))return Wf[r]}var Gm=["https://trustless-gateway.link","https://4everland.io"],Zm=2336;function Wm(r){return r=r.toString(),{id:sl(Q.createV1(Zm,We.digest(Z(r)))),multiaddrs:[Yf(r)]}}var Pa=class{gateways;constructor(e={}){this.gateways=(e.gateways??Gm).map(t=>Wm(t))}async*findProviders(e,t){yield*this.gateways.toSorted(()=>Math.random()>.5?1:-1).map(n=>({...n,protocols:["transport-ipfs-gateway-http"]}))}};function Jf(r={}){return new Pa(r)}var Fa=class{libp2p;constructor(e){this.libp2p=e}async provide(e,t){await this.libp2p.contentRouting.provide(e,t)}async*findProviders(e,t){yield*this.libp2p.contentRouting.findProviders(e,t)}async put(e,t,n){await this.libp2p.contentRouting.put(e,t,n)}async get(e,t){return this.libp2p.contentRouting.get(e,t)}async findPeer(e,t){return this.libp2p.peerRouting.findPeer(e,t)}async*getClosestPeers(e,t){yield*this.libp2p.peerRouting.getClosestPeers(e,t)}};function Xf(r){return new Fa(r)}return dd(Ym);})();
20
19
  /*! Bundled license information:
21
20
 
22
21
  pvtsutils/build/index.js: