@helia/delegated-routing-v1-http-api-client 3.0.1 → 3.0.2

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,11 +1,11 @@
1
1
  (function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.HeliaDelegatedRoutingV1HttpApiClient = factory()}(typeof self !== 'undefined' ? self : this, function () {
2
- "use strict";var HeliaDelegatedRoutingV1HttpApiClient=(()=>{var rh=Object.create;var zn=Object.defineProperty;var nh=Object.getOwnPropertyDescriptor;var oh=Object.getOwnPropertyNames;var ih=Object.getPrototypeOf,sh=Object.prototype.hasOwnProperty;var nr=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),me=(r,e)=>{for(var t in e)zn(r,t,{get:e[t],enumerable:!0})},Va=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of oh(e))!sh.call(r,o)&&o!==t&&zn(r,o,{get:()=>e[o],enumerable:!(n=nh(e,o))||n.enumerable});return r};var Lt=(r,e,t)=>(t=r!=null?rh(ih(r)):{},Va(e||!r||!r.__esModule?zn(t,"default",{value:r,enumerable:!0}):t,r)),ah=r=>Va(zn({},"__esModule",{value:!0}),r);var Ma=nr((nm,Fa)=>{var yr=1e3,wr=yr*60,br=wr*60,or=br*24,ch=or*7,uh=or*365.25;Fa.exports=function(r,e){e=e||{};var t=typeof r;if(t==="string"&&r.length>0)return lh(r);if(t==="number"&&isFinite(r))return e.long?hh(r):fh(r);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(r))};function lh(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*uh;case"weeks":case"week":case"w":return t*ch;case"days":case"day":case"d":return t*or;case"hours":case"hour":case"hrs":case"hr":case"h":return t*br;case"minutes":case"minute":case"mins":case"min":case"m":return t*wr;case"seconds":case"second":case"secs":case"sec":case"s":return t*yr;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return t;default:return}}}}function fh(r){var e=Math.abs(r);return e>=or?Math.round(r/or)+"d":e>=br?Math.round(r/br)+"h":e>=wr?Math.round(r/wr)+"m":e>=yr?Math.round(r/yr)+"s":r+"ms"}function hh(r){var e=Math.abs(r);return e>=or?Gn(r,e,or,"day"):e>=br?Gn(r,e,br,"hour"):e>=wr?Gn(r,e,wr,"minute"):e>=yr?Gn(r,e,yr,"second"):r+" ms"}function Gn(r,e,t,n){var o=e>=t*1.5;return Math.round(r/t)+" "+n+(o?"s":"")}});var Ka=nr((om,Ha)=>{function dh(r){t.debug=t,t.default=t,t.coerce=c,t.disable=i,t.enable=o,t.enabled=s,t.humanize=Ma(),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,E,g;function h(...p){if(!h.enabled)return;let b=h,k=Number(new Date),v=k-(l||k);b.diff=v,b.prev=l,b.curr=k,l=k,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,(R,N)=>{if(R==="%%")return"%";L++;let y=t.formatters[N];if(typeof y=="function"){let C=p[L];R=y.call(b,C),p.splice(L,1),L--}return R}),t.formatArgs.call(b,p),(b.log||t.log).apply(b,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:(E!==t.namespaces&&(E=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,]+/),E=d.length;for(l=0;l<E;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}Ha.exports=dh});var $a=nr((Oe,jn)=>{Oe.formatArgs=gh;Oe.save=mh;Oe.load=yh;Oe.useColors=ph;Oe.storage=wh();Oe.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`."))}})();Oe.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 ph(){return typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs)?!0:typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)?!1: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&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function gh(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)}Oe.log=console.debug||console.log||(()=>{});function mh(r){try{r?Oe.storage.setItem("debug",r):Oe.storage.removeItem("debug")}catch{}}function yh(){let r;try{r=Oe.storage.getItem("debug")}catch{}return!r&&typeof process<"u"&&"env"in process&&(r=process.env.DEBUG),r}function wh(){try{return localStorage}catch{}}jn.exports=Ka()(Oe);var{formatters:bh}=jn.exports;bh.j=function(r){try{return JSON.stringify(r)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}});var du=nr(jr=>{"use strict";var yp="[object ArrayBuffer]",St=class r{static isArrayBuffer(e){return Object.prototype.toString.call(e)===yp}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}},Zs="string",wp=/^[0-9a-f]+$/i,bp=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/,xp=/^[a-zA-Z0-9-_]+$/,Eo=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=St.toUint8Array(e),n="";for(let i=0;i<t.length;i++)n+=String.fromCharCode(t[i]);return decodeURIComponent(escape(n))}},je=class{static toString(e,t=!1){let n=St.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}},vo=class r{static isHex(e){return typeof e===Zs&&wp.test(e)}static isBase64(e){return typeof e===Zs&&bp.test(e)}static isBase64Url(e){return typeof e===Zs&&xp.test(e)}static ToString(e,t="utf8"){let n=St.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 je.toString(n,!0);case"utf16":case"utf16be":return je.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 je.fromString(e,!0);case"utf16":case"utf16be":return je.fromString(e);default:throw new Error(`Unknown type of encoding '${t}'`)}}static ToBase64(e){let t=St.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 Eo.fromString(e);case"utf16":case"utf16be":return je.fromString(e);case"utf16le":case"usc2":return je.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 Eo.toString(e);case"utf16":case"utf16be":return je.toString(e);case"utf16le":case"usc2":return je.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=St.toUint8Array(e),n="";for(let o=0;o<t.length;o++)n+=String.fromCharCode(t[o]);return n}static ToHex(e){let t=St.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 je.toString(e,t)}static FromUtf16String(e,t=!1){return je.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,"")||""}};vo.DEFAULT_UTF8_ENCODING="utf8";function Ep(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 vp(...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 Bp(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=St;jr.Convert=vo;jr.assign=Ep;jr.combine=vp;jr.isEqual=Bp});var fi=nr((T1,bl)=>{"use strict";function wl(r,e){for(let t in e)Object.defineProperty(r,t,{value:e[t],enumerable:!0,configurable:!0});return r}function ng(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 wl(r,t)}catch{t.message=r.message,t.stack=r.stack;let o=function(){};return o.prototype=Object.create(Object.getPrototypeOf(r)),wl(new o,t)}}bl.exports=ng});var fa=nr((V1,la)=>{var L1=function(){typeof la<"u"&&(la.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 C=y-y%1;return C==0&&(y<0||y===0&&1/y!=1/0)?-0:C},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 C,D=new h,T=(T+="").replace(/^\s*[+\-]?\d+/,function(H){var H=+H,W=1970+(H-1970)%400;return D.year=H-W,W}).replace(/(?:Z|([+\-]\d{2}):?(\d{2}))$/,function(O,H,W){return H<0&&(W*=-1),C=6e4*(60*+H+ +W),""}).replace(/\.\d+$/,function(O){return D.nano=+(O+c).substr(1,9),""}).split(/\D+/);if(1<T.length?T[1]--:T[1]=0,D.time=C=Date.UTC.apply(Date,T)-(C||0),isNaN(C))throw new TypeError("Invalid Date");return p(D)},h.fromTimeT=function(y){return k(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 C=p(this),y=Math.floor(C.time/1e3),C=C.year;return C&&(y+=C*t*r/e),y},u.getYear=function(){return this.toDate().getUTCFullYear()+this.year},u.toDate=function(){return b(p(this).time)},u.toJSON=function(){return this.toString().replace(/0{1,6}Z$/,"Z")},u.toString=function(y){var C=this,D=C.toDate(),T={H:function(){return R(D.getUTCHours())},L:function(){return N(D.getUTCMilliseconds(),3)},M:function(){return R(D.getUTCMinutes())},N:function(){return N(C.getNano(),9)},S:function(){return R(D.getUTCSeconds())},Y:function(){var O=C.getYear();return 999999<O?"+"+O:9999<O?"+"+N(O,6):0<=O?N(O,4):-999999<=O?"-"+N(-O,6):O},a:function(){return E[D.getUTCDay()]},b:function(){return d[D.getUTCMonth()]},d:function(){return R(D.getUTCDate())},e:function(){return function(O){return(9<O?"":" ")+(0|O)}(D.getUTCDate())},m:function(){return R(D.getUTCMonth()+1)}};return function O(H){return H.replace(/%./g,function(W){var A=W[1],x=g[A],A=T[A];return x?O(x):A?A():W})}(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"],E=["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,C,D){var T=this;if(!(T instanceof h))return new h(y,C,D);T.time=+y||0,T.nano=+C||0,T.year=+D||0,p(T)}function p(y){var C,D,T,O=y.year,H=y.time,W=y.nano,x=((W<0||a<=W)&&(W-=(D=Math.floor(W/a))*a,H+=D,D=1),O%e);return(H<-i||i<H||x)&&((C=f(H/o))&&(O+=C*e,H-=C*o),(T=b(H)).setUTCFullYear(x+T.getUTCFullYear()),T=(H=+T)+(C=f((O-=x)/e))*o,C&&-i<=T&&T<=i&&(O-=C*e,H=T),D=1),D&&(y.year=O,y.time=H,y.nano=W),y}function b(y){var C=new Date(0);return C.setTime(y),C}function k(O,T){O=+O||0;var D=f((T=(T|0)*s)/n)+f(O/n),T=T%n+O%n,O=f(T/n);return O&&(D+=O,T-=O*n),new h(1e3*T,0,D*e)}function v(y,C,D,T,O,H){return function(x,A){var B=p(this);x=x||new Array(8),S(x,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),W(x,A+O,M),W(x,A+H,B),x};function W(x,A,M){x[A+y]=M>>24&255,x[A+C]=M>>16&255,x[A+D]=M>>8&255,x[A+T]=255&M}}function L(y,C,D,T,O,H){return function(x,A){S(x,A|=0);var M=W(x,A+O);return k(W(x,A+H),M)};function W(x,A){return 16777216*x[A+y]+(x[A+C]<<16|x[A+D]<<8|x[A+T])}}function S(y,C){if(y=y&&y.length,y==null)throw new TypeError("Invalid Buffer");if(y<C+8)throw new RangeError("Out of range")}function R(y){return(9<y?"":"0")+(0|y)}function N(y,C){return(c+(0|y)).substr(-C)}}()});var Ff=nr((B2,Ea)=>{"use strict";var Kg=Object.prototype.hasOwnProperty,Ue="~";function Hn(){}Object.create&&(Hn.prototype=Object.create(null),new Hn().__proto__||(Ue=!1));function $g(r,e,t){this.fn=r,this.context=e,this.once=t||!1}function Pf(r,e,t,n,o){if(typeof t!="function")throw new TypeError("The listener must be a function");var i=new $g(t,n||r,o),s=Ue?Ue+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 Ii(r,e){--r._eventsCount===0?r._events=new Hn:delete r._events[e]}function Re(){this._events=new Hn,this._eventsCount=0}Re.prototype.eventNames=function(){var e=[],t,n;if(this._eventsCount===0)return e;for(n in t=this._events)Kg.call(t,n)&&e.push(Ue?n.slice(1):n);return Object.getOwnPropertySymbols?e.concat(Object.getOwnPropertySymbols(t)):e};Re.prototype.listeners=function(e){var t=Ue?Ue+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};Re.prototype.listenerCount=function(e){var t=Ue?Ue+e:e,n=this._events[t];return n?n.fn?1:n.length:0};Re.prototype.emit=function(e,t,n,o,i,s){var a=Ue?Ue+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,E;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(E=1,u=new Array(f-1);E<f;E++)u[E-1]=arguments[E];c[l].fn.apply(c[l].context,u)}}return!0};Re.prototype.on=function(e,t,n){return Pf(this,e,t,n,!1)};Re.prototype.once=function(e,t,n){return Pf(this,e,t,n,!0)};Re.prototype.removeListener=function(e,t,n,o){var i=Ue?Ue+e:e;if(!this._events[i])return this;if(!t)return Ii(this,i),this;var s=this._events[i];if(s.fn)s.fn===t&&(!o||s.once)&&(!n||s.context===n)&&Ii(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:Ii(this,i)}return this};Re.prototype.removeAllListeners=function(e){var t;return e?(t=Ue?Ue+e:e,this._events[t]&&Ii(this,t)):(this._events=new Hn,this._eventsCount=0),this};Re.prototype.off=Re.prototype.removeListener;Re.prototype.addListener=Re.prototype.on;Re.prefixed=Ue;Re.EventEmitter=Re;typeof Ea<"u"&&(Ea.exports=Re)});var Wg={};me(Wg,{createDelegatedRoutingV1HttpApiClient:()=>Zg});var Da=Symbol.for("@libp2p/content-routing");var Ni=Symbol.for("@libp2p/peer-id");function Oa(r){return r!=null&&!!r[Ni]}var Pa=Symbol.for("@libp2p/peer-routing");var P=class extends Error{code;props;constructor(e,t,n){super(e),this.code=t,this.name=n?.name??"CodeError",this.props=n??{}}};var mr=(r,...e)=>{try{[...e]}catch{}};var Pe=Lt($a(),1);var Di={};me(Di,{base32:()=>Je,base32hex:()=>kh,base32hexpad:()=>Th,base32hexpadupper:()=>Ch,base32hexupper:()=>Rh,base32pad:()=>Sh,base32padupper:()=>Ih,base32upper:()=>Wa,base32z:()=>Nh});var im=new Uint8Array(0);function qa(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 yt(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 za(r){return new TextEncoder().encode(r)}function Ga(r){return new TextDecoder().decode(r)}function xh(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,b=0,k=g.length;b!==k&&g[b]===0;)b++,h++;for(var v=(k-b)*u+1>>>0,L=new Uint8Array(v);b!==k;){for(var S=g[b],R=0,N=v-1;(S!==0||R<p)&&N!==-1;N--,R++)S+=256*L[N]>>>0,L[N]=S%a>>>0,S=S/a>>>0;if(S!==0)throw new Error("Non-zero carry");p=R,b++}for(var y=v-p;y!==v&&L[y]===0;)y++;for(var C=c.repeat(h);y<v;++y)C+=r.charAt(L[y]);return C}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,b=0;g[h]===c;)p++,h++;for(var k=(g.length-h)*f+1>>>0,v=new Uint8Array(k);g[h];){var L=t[g.charCodeAt(h)];if(L===255)return;for(var S=0,R=k-1;(L!==0||S<b)&&R!==-1;R--,S++)L+=a*v[R]>>>0,v[R]=L%256>>>0,L=L/256>>>0;if(L!==0)throw new Error("Non-zero carry");b=S,h++}if(g[h]!==" "){for(var N=k-b;N!==k&&v[N]===0;)N++;for(var y=new Uint8Array(p+(k-N)),C=p;N!==k;)y[C++]=v[N++];return y}}}function E(g){var h=d(g);if(h)return h;throw new Error(`Non-${e} character`)}return{encode:l,decodeUnsafe:d,decode:E}}var Eh=xh,vh=Eh,Ya=vh;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")}},Ui=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 Za(this,e)}},Li=class{decoders;constructor(e){this.decoders=e}or(e){return Za(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 Za(r,e){return new Li({...r.decoders??{[r.prefix]:r},...e.decoders??{[e.prefix]:e}})}var Vi=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 Ui(e,t,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};function xr({name:r,prefix:e,encode:t,decode:n}){return new Vi(r,e,t,n)}function Vt({name:r,prefix:e,alphabet:t}){let{encode:n,decode:o}=Ya(t,r);return xr({prefix:e,name:r,encode:n,decode:i=>yt(o(i))})}function Bh(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 Ah(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 xr({prefix:e,name:r,encode(o){return Ah(o,n,t)},decode(o){return Bh(o,n,t,r)}})}var Je=ae({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Wa=ae({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Sh=ae({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Ih=ae({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),kh=ae({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Rh=ae({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Th=ae({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Ch=ae({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Nh=ae({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Oi={};me(Oi,{base58btc:()=>ue,base58flickr:()=>_h});var ue=Vt({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),_h=Vt({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Pi={};me(Pi,{base64:()=>sn,base64pad:()=>Uh,base64url:()=>Lh,base64urlpad:()=>Vh});var sn=ae({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Uh=ae({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Lh=ae({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Vh=ae({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});Pe.default.formatters.b=r=>r==null?"undefined":ue.baseEncode(r);Pe.default.formatters.t=r=>r==null?"undefined":Je.baseEncode(r);Pe.default.formatters.m=r=>r==null?"undefined":sn.baseEncode(r);Pe.default.formatters.p=r=>r==null?"undefined":r.toString();Pe.default.formatters.c=r=>r==null?"undefined":r.toString();Pe.default.formatters.k=r=>r==null?"undefined":r.toString();Pe.default.formatters.a=r=>r==null?"undefined":r.toString();function Dh(r){let e=()=>{};return e.enabled=!1,e.color="",e.diff=0,e.log=()=>{},e.namespace=r,e.destroy=()=>!0,e.extend=()=>e,e}function Dt(r){let e=Dh(`${r}:trace`);return Pe.default.enabled(`${r}:trace`)&&Pe.default.names.map(t=>t.toString()).find(t=>t.includes(":trace"))!=null&&(e=(0,Pe.default)(`${r}:trace`)),Object.assign((0,Pe.default)(r),{error:(0,Pe.default)(`${r}:error`),trace:e})}var Fi={};me(Fi,{base10:()=>Oh});var Oh=Vt({prefix:"9",name:"base10",alphabet:"0123456789"});var Mi={};me(Mi,{base16:()=>Ph,base16upper:()=>Fh});var Ph=ae({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Fh=ae({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Hi={};me(Hi,{base2:()=>Mh});var Mh=ae({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Ki={};me(Ki,{base256emoji:()=>zh});var Ja=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}"),Hh=Ja.reduce((r,e,t)=>(r[t]=e,r),[]),Kh=Ja.reduce((r,e,t)=>(r[e.codePointAt(0)]=t,r),[]);function $h(r){return r.reduce((e,t)=>(e+=Hh[t],e),"")}function qh(r){let e=[];for(let t of r){let n=Kh[t.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${t}`);e.push(n)}return new Uint8Array(e)}var zh=xr({prefix:"\u{1F680}",name:"base256emoji",encode:$h,decode:qh});var $i={};me($i,{base36:()=>Yn,base36upper:()=>Gh});var Yn=Vt({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Gh=Vt({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var qi={};me(qi,{base8:()=>jh});var jh=ae({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var zi={};me(zi,{identity:()=>Yh});var Yh=xr({prefix:"\0",name:"identity",encode:r=>Ga(r),decode:r=>za(r)});var Sm=new TextEncoder,Im=new TextDecoder;var ji={};me(ji,{identity:()=>ut});var Jh=ec,Xa=128,Xh=127,Qh=~Xh,ed=Math.pow(2,31);function ec(r,e,t){e=e||[],t=t||0;for(var n=t;r>=ed;)e[t++]=r&255|Xa,r/=128;for(;r&Qh;)e[t++]=r&255|Xa,r>>>=7;return e[t]=r|0,ec.bytes=t-n+1,e}var td=Gi,rd=128,Qa=127;function Gi(r,n){var t=0,n=n||0,o=0,i=n,s,a=r.length;do{if(i>=a)throw Gi.bytes=0,new RangeError("Could not decode varint");s=r[i++],t+=o<28?(s&Qa)<<o:(s&Qa)*Math.pow(2,o),o+=7}while(s>=rd);return Gi.bytes=i-n,t}var nd=Math.pow(2,7),od=Math.pow(2,14),id=Math.pow(2,21),sd=Math.pow(2,28),ad=Math.pow(2,35),cd=Math.pow(2,42),ud=Math.pow(2,49),ld=Math.pow(2,56),fd=Math.pow(2,63),hd=function(r){return r<nd?1:r<od?2:r<id?3:r<sd?4:r<ad?5:r<cd?6:r<ud?7:r<ld?8:r<fd?9:10},dd={encode:Jh,decode:td,encodingLength:hd},pd=dd,an=pd;function cn(r,e=0){return[an.decode(r,e),an.decode.bytes]}function Er(r,e,t=0){return an.encode(r,e,t),e}function vr(r){return an.encodingLength(r)}function ct(r,e){let t=e.byteLength,n=vr(r),o=n+vr(t),i=new Uint8Array(o+t);return Er(r,i,0),Er(t,i,n),i.set(e,o),new Br(r,t,e,i)}function Ot(r){let e=yt(r),[t,n]=cn(e),[o,i]=cn(e.subarray(n)),s=e.subarray(n+i);if(s.byteLength!==o)throw new Error("Incorrect length");return new Br(t,o,s,e)}function tc(r,e){if(r===e)return!0;{let t=e;return r.code===t.code&&r.size===t.size&&t.bytes instanceof Uint8Array&&qa(r.bytes,t.bytes)}}var Br=class{code;size;digest;bytes;constructor(e,t,n,o){this.code=e,this.size=t,this.digest=n,this.bytes=o}};var rc=0,gd="identity",nc=yt;function md(r){return ct(rc,nc(r))}var ut={code:rc,name:gd,encode:nc,digest:md};var Wi={};me(Wi,{sha256:()=>Ee,sha512:()=>yd});function Zi({name:r,code:e,encode:t}){return new Yi(r,e,t)}var Yi=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?ct(this.code,t):t.then(n=>ct(this.code,n))}else throw Error("Unknown type, must be binary type")}};function ic(r){return async e=>new Uint8Array(await crypto.subtle.digest(r,e))}var Ee=Zi({name:"sha2-256",code:18,encode:ic("SHA-256")}),yd=Zi({name:"sha2-512",code:19,encode:ic("SHA-512")});function sc(r,e){let{bytes:t,version:n}=r;switch(n){case 0:return bd(t,Ji(r),e??ue.encoder);default:return xd(t,Ji(r),e??Je.encoder)}}var ac=new WeakMap;function Ji(r){let e=ac.get(r);if(e==null){let t=new Map;return ac.set(r,t),t}return e}var Te=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!==un)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==Ed)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=ct(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&&tc(e.multihash,n.multihash)}toString(e){return sc(this,e)}toJSON(){return{"/":sc(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??cc(n,o,i.bytes))}else if(t[vd]===!0){let{version:n,multihash:o,code:i}=t,s=Ot(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!==un)throw new Error(`Version 0 CID must use dag-pb (code: ${un}) block encoding`);return new r(e,t,n,n.bytes)}case 1:{let o=cc(e,t,n.bytes);return new r(e,t,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return r.create(0,un,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=yt(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 Br(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]=cn(e.subarray(t));return t+=d,l},o=n(),i=un;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]=wd(e,t),i=r.decode(o);if(i.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Ji(i).set(n,e),i}};function wd(r,e){switch(r[0]){case"Q":{let t=e??ue;return[ue.prefix,t.decode(`${ue.prefix}${r}`)]}case ue.prefix:{let t=e??ue;return[ue.prefix,t.decode(r)]}case Je.prefix:{let t=e??Je;return[Je.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 bd(r,e,t){let{prefix:n}=t;if(n!==ue.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 xd(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 un=112,Ed=18;function cc(r,e,t){let n=vr(r),o=n+vr(e),i=new Uint8Array(o+t.byteLength);return Er(r,i,0),Er(e,i,n),i.set(t,o),i}var vd=Symbol.for("@ipld/js-cid/CID");var Ft={...zi,...Hi,...qi,...Fi,...Mi,...Di,...$i,...Oi,...Pi,...Ki},jm={...Wi,...ji};function he(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}var Bd=Symbol.for("nodejs.util.inspect.custom"),uc=Object.values(Ft).map(r=>r.decoder).reduce((r,e)=>r.or(e),Ft.identity.decoder),lc=114,Xi=36,Qi=37,ln=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()})`}[Ni]=!0;toString(){return this.string==null&&(this.string=ue.encode(this.multihash.bytes).slice(1)),this.string}toCID(){return Te.createV1(lc,this.multihash)}toBytes(){return this.multihash.bytes}toJSON(){return this.toString()}equals(e){if(e==null)return!1;if(e instanceof Uint8Array)return he(this.multihash.bytes,e);if(typeof e=="string")return es(e).equals(this);if(e?.multihash?.bytes!=null)return he(this.multihash.bytes,e.multihash.bytes);throw new Error("not valid Id")}[Bd](){return`PeerId(${this.toString()})`}},Ar=class extends ln{type="RSA";publicKey;constructor(e){super({...e,type:"RSA"}),this.publicKey=e.publicKey}},Sr=class extends ln{type="Ed25519";publicKey;constructor(e){super({...e,type:"Ed25519"}),this.publicKey=e.multihash.digest}},Ir=class extends ln{type="secp256k1";publicKey;constructor(e){super({...e,type:"secp256k1"}),this.publicKey=e.multihash.digest}};function es(r,e){if(e=e??uc,r.charAt(0)==="1"||r.charAt(0)==="Q"){let t=Ot(ue.decode(`z${r}`));return r.startsWith("12D")?new Sr({multihash:t}):r.startsWith("16U")?new Ir({multihash:t}):new Ar({multihash:t})}return fn(uc.decode(r))}function fn(r){try{let e=Ot(r);if(e.code===ut.code){if(e.digest.length===Xi)return new Sr({multihash:e});if(e.digest.length===Qi)return new Ir({multihash:e})}if(e.code===Ee.code)return new Ar({multihash:e})}catch{return Ad(Te.decode(r))}throw new Error("Supplied PeerID CID is invalid")}function Ad(r){if(r==null||r.multihash==null||r.version==null||r.version===1&&r.code!==lc)throw new Error("Supplied PeerID CID is invalid");let e=r.multihash;if(e.code===Ee.code)return new Ar({multihash:r.multihash});if(e.code===ut.code){if(e.digest.length===Xi)return new Sr({multihash:r.multihash});if(e.digest.length===Qi)return new Ir({multihash:r.multihash})}throw new Error("Supplied PeerID CID is invalid")}async function fc(r,e){return r.length===Xi?new Sr({multihash:ct(ut.code,r),privateKey:e}):r.length===Qi?new Ir({multihash:ct(ut.code,r),privateKey:e}):new Ar({multihash:await Ee.digest(r),publicKey:r,privateKey:e})}function Xe(r=0){return new Uint8Array(r)}function dc(r,e,t,n){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:n}}}var hc=dc("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),ts=dc("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=Xe(r.length);for(let t=0;t<r.length;t++)e[t]=r.charCodeAt(t);return e}),Sd={utf8:hc,"utf-8":hc,hex:Ft.base16,latin1:ts,ascii:ts,binary:ts,...Ft},Wn=Sd;function Z(r,e="utf8"){let t=Wn[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return t.encoder.encode(r).substring(1)}var Id=Math.pow(2,7),kd=Math.pow(2,14),Rd=Math.pow(2,21),rs=Math.pow(2,28),ns=Math.pow(2,35),os=Math.pow(2,42),is=Math.pow(2,49),te=128,Se=127;function Le(r){if(r<Id)return 1;if(r<kd)return 2;if(r<Rd)return 3;if(r<rs)return 4;if(r<ns)return 5;if(r<os)return 6;if(r<is)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function ss(r,e,t=0){switch(Le(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 Td(r,e,t=0){switch(Le(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 as(r,e){let t=r[e],n=0;if(n+=t&Se,t<te||(t=r[e+1],n+=(t&Se)<<7,t<te)||(t=r[e+2],n+=(t&Se)<<14,t<te)||(t=r[e+3],n+=(t&Se)<<21,t<te)||(t=r[e+4],n+=(t&Se)*rs,t<te)||(t=r[e+5],n+=(t&Se)*ns,t<te)||(t=r[e+6],n+=(t&Se)*os,t<te)||(t=r[e+7],n+=(t&Se)*is,t<te))return n;throw new RangeError("Could not decode varint")}function Cd(r,e){let t=r.get(e),n=0;if(n+=t&Se,t<te||(t=r.get(e+1),n+=(t&Se)<<7,t<te)||(t=r.get(e+2),n+=(t&Se)<<14,t<te)||(t=r.get(e+3),n+=(t&Se)<<21,t<te)||(t=r.get(e+4),n+=(t&Se)*rs,t<te)||(t=r.get(e+5),n+=(t&Se)*ns,t<te)||(t=r.get(e+6),n+=(t&Se)*os,t<te)||(t=r.get(e+7),n+=(t&Se)*is,t<te))return n;throw new RangeError("Could not decode varint")}function kr(r,e,t=0){return e==null&&(e=Xe(Le(r))),e instanceof Uint8Array?ss(r,e,t):Td(r,e,t)}function ir(r,e=0){return r instanceof Uint8Array?as(r,e):Cd(r,e)}function Ce(r,e){e==null&&(e=r.reduce((o,i)=>o+i.length,0));let t=Xe(e),n=0;for(let o of r)t.set(o,n),n+=o.length;return t}var Jn=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 gc=45,Nd=15,Rr=new Jn;function cs(r){if(!(r.length>Nd))return Rr.new(r).parseWith(()=>Rr.readIPv4Addr())}function us(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>gc))return Rr.new(r).parseWith(()=>Rr.readIPv6Addr())}function Xn(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>gc))return Rr.new(r).parseWith(()=>Rr.readIPAddr())}var Sy=parseInt("0xFFFF",16),Iy=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);function J(r,e="utf8"){let t=Wn[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return t.decoder.decode(`${t.prefix}${r}`)}function wc(r){return!!cs(r)}function bc(r){return!!us(r)}function Qn(r){return!!Xn(r)}var xc=wc,Dd=bc,ls=function(r){let e=0;if(r=r.toString().trim(),xc(r)){let t=new Uint8Array(e+4);return r.split(/\./g).forEach(n=>{t[e++]=parseInt(n,10)&255}),t}if(Dd(r)){let t=r.split(":",8),n;for(n=0;n<t.length;n++){let i=xc(t[n]),s;i&&(s=ls(t[n]),t[n]=Z(s.slice(0,2),"base16")),s!=null&&++n<8&&t.splice(n,0,Z(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")},Ec=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 Tr={},fs={},Pd=[[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"],[777,-1,"memory"]];Pd.forEach(r=>{let e=Fd(...r);fs[e.code]=e,Tr[e.name]=e});function Fd(r,e,t,n,o){return{code:r,size:e,name:t,resolvable:!!n,path:!!o}}function ne(r){if(typeof r=="number"){if(fs[r]!=null)return fs[r];throw new Error(`no protocol with code: ${r}`)}else if(typeof r=="string"){if(Tr[r]!=null)return Tr[r];throw new Error(`no protocol with name: ${r}`)}throw new Error(`invalid protocol id type: ${typeof r}`)}var fw=ne("ip4"),hw=ne("ip6"),dw=ne("ipcidr");function ds(r,e){switch(ne(r).code){case 4:case 41:return Hd(e);case 42:return Ac(e);case 6:case 273:case 33:case 132:return Ic(e).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return Ac(e);case 421:return zd(e);case 444:return Sc(e);case 445:return Sc(e);case 466:return qd(e);default:return Z(e,"base16")}}function ps(r,e){switch(ne(r).code){case 4:return vc(e);case 41:return vc(e);case 42:return Bc(e);case 6:case 273:case 33:case 132:return gs(parseInt(e,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return Bc(e);case 421:return Kd(e);case 444:return Gd(e);case 445:return jd(e);case 466:return $d(e);default:return J(e,"base16")}}var hs=Object.values(Ft).map(r=>r.decoder),Md=function(){let r=hs[0].or(hs[1]);return hs.slice(2).forEach(e=>r=r.or(e)),r}();function vc(r){if(!Qn(r))throw new Error("invalid ip address");return ls(r)}function Hd(r){let e=Ec(r,0,r.length);if(e==null)throw new Error("ipBuff is required");if(!Qn(e))throw new Error("invalid ip address");return e}function gs(r){let e=new ArrayBuffer(2);return new DataView(e).setUint16(0,r),new Uint8Array(e)}function Ic(r){return new DataView(r.buffer).getUint16(r.byteOffset)}function Bc(r){let e=J(r),t=Uint8Array.from(kr(e.length));return Ce([t,e],t.length+e.length)}function Ac(r){let e=ir(r);if(r=r.slice(Le(e)),r.length!==e)throw new Error("inconsistent lengths");return Z(r)}function Kd(r){let e;r[0]==="Q"||r[0]==="1"?e=Ot(ue.decode(`z${r}`)).bytes:e=Te.parse(r).multihash.bytes;let t=Uint8Array.from(kr(e.length));return Ce([t,e],t.length+e.length)}function $d(r){let e=Md.decode(r),t=Uint8Array.from(kr(e.length));return Ce([t,e],t.length+e.length)}function qd(r){let e=ir(r),t=r.slice(Le(e));if(t.length!==e)throw new Error("inconsistent lengths");return"u"+Z(t,"base64url")}function zd(r){let e=ir(r),t=r.slice(Le(e));if(t.length!==e)throw new Error("inconsistent lengths");return Z(t,"base58btc")}function Gd(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=Je.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=gs(n);return Ce([t,o],t.length+o.length)}function jd(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=Je.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=gs(n);return Ce([t,o],t.length+o.length)}function Sc(r){let e=r.slice(0,r.length-2),t=r.slice(r.length-2),n=Z(e,"base32"),o=Ic(t);return`${n}:${o}`}function kc(r){r=ms(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 Tc("invalid address: "+r);if(a.path===!0){n=ms(o.slice(i).join("/")),e.push([a.code,ps(a.code,n)]),t.push([a.code,n]);break}let c=ps(a.code,o[i]);e.push([a.code,c]),t.push([a.code,ds(a.code,c)])}return{string:Rc(t),bytes:ws(e),tuples:e,stringTuples:t,path:n}}function ys(r){let e=[],t=[],n=null,o=0;for(;o<r.length;){let i=ir(r,o),s=Le(i),a=ne(i),c=Yd(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 Tc("Invalid address Uint8Array: "+Z(r,"base16"));e.push([i,f]);let u=ds(i,f);if(t.push([i,u]),a.path===!0){n=u;break}}return{bytes:Uint8Array.from(r),string:Rc(t),tuples:e,stringTuples:t,path:n}}function Rc(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}),ms(e.join("/"))}function ws(r){return Ce(r.map(e=>{let t=ne(e[0]),n=Uint8Array.from(kr(t.code));return e.length>1&&e[1]!=null&&(n=Ce([n,e[1]])),n}))}function Yd(r,e){if(r.size>0)return r.size/8;if(r.size===0)return 0;{let t=ir(e instanceof Uint8Array?e:Uint8Array.from(e));return t+Le(t)}}function ms(r){return"/"+r.trim().split("/").filter(e=>e).join("/")}function Tc(r){return new Error("Error parsing address: "+r)}var Zd=Symbol.for("nodejs.util.inspect.custom"),bs=Symbol.for("@multiformats/js-multiaddr/multiaddr"),Wd=[ne("dns").code,ne("dns4").code,ne("dns6").code,ne("dnsaddr").code],eo=class r{bytes;#e;#r;#i;#a;[bs]=!0;constructor(e){e==null&&(e="");let t;if(e instanceof Uint8Array)t=ys(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(Nc(e))t=ys(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[E,g]of this.stringTuples())E===l.code&&(i=`%${g??""}`),Wd.includes(E)&&(t=s.name,o=443,n=`${g??""}${i}`,e=E===u.code?6:4),(E===s.code||E===a.code)&&(t=ne(E).name,o=parseInt(g??"")),(E===c.code||E===f.code)&&(t=ne(E).name,n=`${g??""}${i}`,e=E===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(ws(t.slice(0,n)));return this}getPeerId(){try{let e=[];this.stringTuples().forEach(([n,o])=>{n===Tr.p2p.code&&e.push([n,o]),n===Tr["p2p-circuit"].code&&(e=[])});let t=e.pop();if(t?.[1]!=null){let n=t[1];return n[0]==="Q"||n[0]==="1"?Z(ue.decode(`z${n}`),"base58btc"):Z(Te.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){return this.#a}equals(e){return he(this.bytes,e.bytes)}async resolve(e){let t=this.protos().find(i=>i.resolvable);if(t==null)return[this];let n=Cc.get(t.name);if(n==null)throw new P(`no available resolver for ${t.name}`,"ERR_NO_AVAILABLE_RESOLVER");return(await n(this,e)).map(i=>hn(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)}[Zd](){return`Multiaddr(${this.#e})`}};var Cc=new Map;function Nc(r){return!!r?.[bs]}function hn(r){return new eo(r)}function dn(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*to(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 js={};me(js,{Ed25519PrivateKey:()=>fr,Ed25519PublicKey:()=>bn,generateKeyPair:()=>pp,generateKeyPairFromSeed:()=>hu,unmarshalEd25519PrivateKey:()=>hp,unmarshalEd25519PublicKey:()=>dp});function Ge(r){return r==null?!1:typeof r.then=="function"&&typeof r.catch=="function"&&typeof r.finally=="function"}function Cr(r){if(!Number.isSafeInteger(r)||r<0)throw new Error(`positive integer expected, not ${r}`)}function Jd(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}function Nr(r,...e){if(!Jd(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 ro(r){if(typeof r!="function"||typeof r.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");Cr(r.outputLen),Cr(r.blockLen)}function _r(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 _c(r,e){Nr(r);let t=e.outputLen;if(r.length<t)throw new Error(`digestInto() expects output buffer of length at least ${t}`)}var no=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;var Lr=r=>new DataView(r.buffer,r.byteOffset,r.byteLength),Qe=(r,e)=>r<<32-e|r>>>e;var jw=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;var Xd=async()=>{};async function Uc(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 Xd(),n+=i)}}function xs(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}function Mt(r){return typeof r=="string"&&(r=xs(r)),Nr(r),r}function oo(...r){let e=0;for(let n=0;n<r.length;n++){let o=r[n];Nr(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 Ur=class{clone(){return this._cloneInto()}},Qd={}.toString;function Lc(r,e){if(e!==void 0&&Qd.call(e)!=="[object Object]")throw new Error("Options should be object or undefined");return Object.assign(r,e)}function io(r){let e=n=>r().update(Mt(n)).digest(),t=r();return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=()=>r(),e}function Vr(r=32){if(no&&typeof no.getRandomValues=="function")return no.getRandomValues(new Uint8Array(r));throw new Error("crypto.getRandomValues must be defined")}function e0(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 Vc=(r,e,t)=>r&e^~r&t,Dc=(r,e,t)=>r&e^r&t^e&t,Dr=class extends Ur{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=Lr(this.buffer)}update(e){_r(this);let{view:t,buffer:n,blockLen:o}=this;e=Mt(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=Lr(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){_r(this),_c(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;e0(n,o-8,BigInt(this.length*8),i),this.process(n,0);let a=Lr(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 so=BigInt(4294967295),Es=BigInt(32);function Oc(r,e=!1){return e?{h:Number(r&so),l:Number(r>>Es&so)}:{h:Number(r>>Es&so)|0,l:Number(r&so)|0}}function t0(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}=Oc(r[o],e);[t[o],n[o]]=[i,s]}return[t,n]}var r0=(r,e)=>BigInt(r>>>0)<<Es|BigInt(e>>>0),n0=(r,e,t)=>r>>>t,o0=(r,e,t)=>r<<32-t|e>>>t,i0=(r,e,t)=>r>>>t|e<<32-t,s0=(r,e,t)=>r<<32-t|e>>>t,a0=(r,e,t)=>r<<64-t|e>>>t-32,c0=(r,e,t)=>r>>>t-32|e<<64-t,u0=(r,e)=>e,l0=(r,e)=>r,f0=(r,e,t)=>r<<t|e>>>32-t,h0=(r,e,t)=>e<<t|r>>>32-t,d0=(r,e,t)=>e<<t-32|r>>>64-t,p0=(r,e,t)=>r<<t-32|e>>>64-t;function g0(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),y0=(r,e,t,n)=>e+t+n+(r/2**32|0)|0,w0=(r,e,t,n)=>(r>>>0)+(e>>>0)+(t>>>0)+(n>>>0),b0=(r,e,t,n,o)=>e+t+n+o+(r/2**32|0)|0,x0=(r,e,t,n,o)=>(r>>>0)+(e>>>0)+(t>>>0)+(n>>>0)+(o>>>0),E0=(r,e,t,n,o,i)=>e+t+n+o+i+(r/2**32|0)|0;var v0={fromBig:Oc,split:t0,toBig:r0,shrSH:n0,shrSL:o0,rotrSH:i0,rotrSL:s0,rotrBH:a0,rotrBL:c0,rotr32H:u0,rotr32L:l0,rotlSH:f0,rotlSL:h0,rotlBH:d0,rotlBL:p0,add:g0,add3L:m0,add3H:y0,add4L:w0,add4H:b0,add5H:E0,add5L:x0},q=v0;var[B0,A0]=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))),Ht=new Uint32Array(80),Kt=new Uint32Array(80),vs=class extends Dr{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:E,Gl:g,Hh:h,Hl:p}=this;return[e,t,n,o,i,s,a,c,f,u,l,d,E,g,h,p]}set(e,t,n,o,i,s,a,c,f,u,l,d,E,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=E|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)Ht[v]=e.getUint32(t),Kt[v]=e.getUint32(t+=4);for(let v=16;v<80;v++){let L=Ht[v-15]|0,S=Kt[v-15]|0,R=q.rotrSH(L,S,1)^q.rotrSH(L,S,8)^q.shrSH(L,S,7),N=q.rotrSL(L,S,1)^q.rotrSL(L,S,8)^q.shrSL(L,S,7),y=Ht[v-2]|0,C=Kt[v-2]|0,D=q.rotrSH(y,C,19)^q.rotrBH(y,C,61)^q.shrSH(y,C,6),T=q.rotrSL(y,C,19)^q.rotrBL(y,C,61)^q.shrSL(y,C,6),O=q.add4L(N,T,Kt[v-7],Kt[v-16]),H=q.add4H(O,R,D,Ht[v-7],Ht[v-16]);Ht[v]=H|0,Kt[v]=O|0}let{Ah:n,Al:o,Bh:i,Bl:s,Ch:a,Cl:c,Dh:f,Dl:u,Eh:l,El:d,Fh:E,Fl:g,Gh:h,Gl:p,Hh:b,Hl:k}=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),R=l&E^~l&h,N=d&g^~d&p,y=q.add5L(k,S,N,A0[v],Kt[v]),C=q.add5H(y,b,L,R,B0[v],Ht[v]),D=y|0,T=q.rotrSH(n,o,28)^q.rotrBH(n,o,34)^q.rotrBH(n,o,39),O=q.rotrSL(n,o,28)^q.rotrBL(n,o,34)^q.rotrBL(n,o,39),H=n&i^n&a^i&a,W=o&s^o&c^s&c;b=h|0,k=p|0,h=E|0,p=g|0,E=l|0,g=d|0,{h:l,l:d}=q.add(f|0,u|0,C|0,D|0),f=a|0,u=c|0,a=i|0,c=s|0,i=n|0,s=o|0;let x=q.add3L(D,O,W);n=q.add3H(x,C,T,H),o=x|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:E,l:g}=q.add(this.Fh|0,this.Fl|0,E|0,g|0),{h,l:p}=q.add(this.Gh|0,this.Gl|0,h|0,p|0),{h:b,l:k}=q.add(this.Hh|0,this.Hl|0,b|0,k|0),this.set(n,o,i,s,a,c,f,u,l,d,E,g,h,p,b,k)}roundClean(){Ht.fill(0),Kt.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 Or=io(()=>new vs);var co={};me(co,{abytes:()=>Pr,bitGet:()=>N0,bitLen:()=>C0,bitMask:()=>pn,bitSet:()=>_0,bytesToHex:()=>bt,bytesToNumberBE:()=>xt,bytesToNumberLE:()=>qt,concatBytes:()=>Et,createHmacDrbg:()=>Ss,ensureBytes:()=>ce,equalBytes:()=>R0,hexToBytes:()=>sr,hexToNumber:()=>As,isBytes:()=>$t,numberToBytesBE:()=>zt,numberToBytesLE:()=>ar,numberToHexUnpadded:()=>Hc,numberToVarBytesBE:()=>k0,utf8ToBytes:()=>T0,validateObject:()=>lt});var Mc=BigInt(0),ao=BigInt(1),S0=BigInt(2);function $t(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}function Pr(r){if(!$t(r))throw new Error("Uint8Array expected")}var I0=Array.from({length:256},(r,e)=>e.toString(16).padStart(2,"0"));function bt(r){Pr(r);let e="";for(let t=0;t<r.length;t++)e+=I0[r[t]];return e}function Hc(r){let e=r.toString(16);return e.length&1?`0${e}`:e}function As(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return BigInt(r===""?"0":`0x${r}`)}var wt={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function Pc(r){if(r>=wt._0&&r<=wt._9)return r-wt._0;if(r>=wt._A&&r<=wt._F)return r-(wt._A-10);if(r>=wt._a&&r<=wt._f)return r-(wt._a-10)}function sr(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=Pc(r.charCodeAt(i)),a=Pc(r.charCodeAt(i+1));if(s===void 0||a===void 0){let c=r[i]+r[i+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+i)}n[o]=s*16+a}return n}function xt(r){return As(bt(r))}function qt(r){return Pr(r),As(bt(Uint8Array.from(r).reverse()))}function zt(r,e){return sr(r.toString(16).padStart(e*2,"0"))}function ar(r,e){return zt(r,e).reverse()}function k0(r){return sr(Hc(r))}function ce(r,e,t){let n;if(typeof e=="string")try{n=sr(e)}catch(i){throw new Error(`${r} must be valid hex string, got "${e}". Cause: ${i}`)}else if($t(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 Et(...r){let e=0;for(let n=0;n<r.length;n++){let o=r[n];Pr(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 R0(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 T0(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}function C0(r){let e;for(e=0;r>Mc;r>>=ao,e+=1);return e}function N0(r,e){return r>>BigInt(e)&ao}function _0(r,e,t){return r|(t?ao:Mc)<<BigInt(e)}var pn=r=>(S0<<BigInt(r-1))-ao,Bs=r=>new Uint8Array(r),Fc=r=>Uint8Array.from(r);function Ss(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=Bs(r),o=Bs(r),i=0,s=()=>{n.fill(1),o.fill(0),i=0},a=(...l)=>t(o,n,...l),c=(l=Bs())=>{o=a(Fc([0]),l),n=a(),l.length!==0&&(o=a(Fc([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 E=n.slice();d.push(E),l+=n.length}return Et(...d)};return(l,d)=>{s(),c(l);let E;for(;!(E=d(f()));)c();return s(),E}}var U0={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"||$t(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 lt(r,e,t={}){let n=(o,i,s)=>{let a=U0[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 ge=BigInt(0),oe=BigInt(1),cr=BigInt(2),L0=BigInt(3),Is=BigInt(4),Kc=BigInt(5),$c=BigInt(8),V0=BigInt(9),D0=BigInt(16);function re(r,e){let t=r%e;return t>=ge?t:e+t}function O0(r,e,t){if(t<=ge||e<ge)throw new Error("Expected power/modulo > 0");if(t===oe)return ge;let n=oe;for(;e>ge;)e&oe&&(n=n*r%t),r=r*r%t,e>>=oe;return n}function ie(r,e,t){let n=r;for(;e-- >ge;)n*=n,n%=t;return n}function uo(r,e){if(r===ge||e<=ge)throw new Error(`invert: expected positive integers, got n=${r} mod=${e}`);let t=re(r,e),n=e,o=ge,i=oe,s=oe,a=ge;for(;t!==ge;){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 P0(r){let e=(r-oe)/cr,t,n,o;for(t=r-oe,n=0;t%cr===ge;t/=cr,n++);for(o=cr;o<r&&O0(o,e,r)!==r-oe;o++);if(n===1){let s=(r+oe)/Is;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)/cr;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 E=1;for(let h=a.sqr(d);E<f&&!a.eql(h,a.ONE);E++)h=a.sqr(h);let g=a.pow(u,oe<<BigInt(f-E-1));u=a.sqr(g),l=a.mul(l,g),d=a.mul(d,u),f=E}return l}}function F0(r){if(r%Is===L0){let e=(r+oe)/Is;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%$c===Kc){let e=(r-Kc)/$c;return function(n,o){let i=n.mul(o,cr),s=n.pow(i,e),a=n.mul(o,s),c=n.mul(n.mul(a,cr),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%D0,P0(r)}var qc=(r,e)=>(re(r,e)&oe)===oe,M0=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function ks(r){let e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},t=M0.reduce((n,o)=>(n[o]="function",n),e);return lt(r,t)}function H0(r,e,t){if(t<ge)throw new Error("Expected power > 0");if(t===ge)return r.ONE;if(t===oe)return e;let n=r.ONE,o=e;for(;t>ge;)t&oe&&(n=r.mul(n,o)),o=r.sqr(o),t>>=oe;return n}function K0(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 Rs(r,e){let t=e!==void 0?e:r.toString(2).length,n=Math.ceil(t/8);return{nBitLength:t,nByteLength:n}}function lo(r,e,t=!1,n={}){if(r<=ge)throw new Error(`Expected Field ORDER > 0, got ${r}`);let{nBitLength:o,nByteLength:i}=Rs(r,e);if(i>2048)throw new Error("Field lengths over 2048 bytes are not supported");let s=F0(r),a=Object.freeze({ORDER:r,BITS:o,BYTES:i,MASK:pn(o),ZERO:ge,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 ge<=c&&c<r},is0:c=>c===ge,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)=>H0(a,c,f),div:(c,f)=>re(c*uo(f,r),r),sqrN:c=>c*c,addN:(c,f)=>c+f,subN:(c,f)=>c-f,mulN:(c,f)=>c*f,inv:c=>uo(c,r),sqrt:n.sqrt||(c=>s(a,c)),invertBatch:c=>K0(a,c),cmov:(c,f,u)=>u?f:c,toBytes:c=>t?ar(c,i):zt(c,i),fromBytes:c=>{if(c.length!==i)throw new Error(`Fp.fromBytes: expected ${i}, got ${c.length}`);return t?qt(c):xt(c)}});return Object.freeze(a)}function zc(r,e){if(!r.isOdd)throw new Error("Field doesn't have isOdd");let t=r.sqrt(e);return r.isOdd(t)?r.neg(t):t}function Gc(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 Ts(r){let e=Gc(r);return e+Math.ceil(e/2)}function jc(r,e,t=!1){let n=r.length,o=Gc(e),i=Ts(e);if(n<16||n<i||n>1024)throw new Error(`expected ${i}-1024 bytes of input, got ${n}`);let s=t?xt(r):qt(r),a=re(s,e-oe)+oe;return t?ar(a,o):zt(a,o)}var q0=BigInt(0),Cs=BigInt(1);function fo(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>q0;)i&Cs&&(s=s.add(a)),a=a.double(),i>>=Cs;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,E=BigInt(o);for(let g=0;g<a;g++){let h=g*c,p=Number(s&l);s>>=E,p>c&&(p-=d,s+=Cs);let b=h,k=h+Math.abs(p)-1,v=g%2!==0,L=p<0;p===0?u=u.add(t(v,i[b])):f=f.add(t(L,i[k]))}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 gn(r){return ks(r.Fp),lt(r,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Rs(r.n,r.nBitLength),...r,p:r.Fp.ORDER})}var et=BigInt(0),Fe=BigInt(1),ho=BigInt(2),z0=BigInt(8),G0={zip215:!0};function j0(r){let e=gn(r);return lt(r,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...e})}function po(r){let e=j0(r),{Fp:t,n,prehash:o,hash:i,randomBytes:s,nByteLength:a,h:c}=e,f=ho<<BigInt(a*8)-Fe,u=t.create,l=e.uvRatio||((B,w)=>{try{return{isValid:!0,value:t.sqrt(B*t.inv(w))}}catch{return{isValid:!1,value:et}}}),d=e.adjustScalarBytes||(B=>B),E=e.domain||((B,w,V)=>{if(w.length||V)throw new Error("Contexts/pre-hash are not supported");return B}),g=B=>typeof B=="bigint"&&et<B,h=(B,w)=>g(B)&&g(w)&&B<w,p=B=>B===et||h(B,f);function b(B,w){if(h(B,w))return B;throw new Error(`Expected valid scalar < ${w}, got ${typeof B} ${B}`)}function k(B){return B===et?B:b(B,n)}let v=new Map;function L(B){if(!(B instanceof S))throw new Error("ExtendedPoint expected")}class S{constructor(w,V,F,K){if(this.ex=w,this.ey=V,this.ez=F,this.et=K,!p(w))throw new Error("x required");if(!p(V))throw new Error("y required");if(!p(F))throw new Error("z required");if(!p(K))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:V,y:F}=w||{};if(!p(V)||!p(F))throw new Error("invalid affine point");return new S(V,F,Fe,u(V*F))}static normalizeZ(w){let V=t.invertBatch(w.map(F=>F.ez));return w.map((F,K)=>F.toAffine(V[K])).map(S.fromAffine)}_setWindowSize(w){this._WINDOW_SIZE=w,v.delete(this)}assertValidity(){let{a:w,d:V}=e;if(this.is0())throw new Error("bad point: ZERO");let{ex:F,ey:K,ez:z,et:G}=this,ee=u(F*F),Y=u(K*K),X=u(z*z),fe=u(X*X),se=u(ee*w),be=u(X*u(se+Y)),xe=u(fe+u(V*u(ee*Y)));if(be!==xe)throw new Error("bad point: equation left != right (1)");let pe=u(F*K),Ae=u(z*G);if(pe!==Ae)throw new Error("bad point: equation left != right (2)")}equals(w){L(w);let{ex:V,ey:F,ez:K}=this,{ex:z,ey:G,ez:ee}=w,Y=u(V*ee),X=u(z*K),fe=u(F*ee),se=u(G*K);return Y===X&&fe===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:V,ey:F,ez:K}=this,z=u(V*V),G=u(F*F),ee=u(ho*u(K*K)),Y=u(w*z),X=V+F,fe=u(u(X*X)-z-G),se=Y+G,be=se-ee,xe=Y-G,pe=u(fe*be),Ae=u(se*xe),mt=u(fe*xe),rr=u(be*se);return new S(pe,Ae,rr,mt)}add(w){L(w);let{a:V,d:F}=e,{ex:K,ey:z,ez:G,et:ee}=this,{ex:Y,ey:X,ez:fe,et:se}=w;if(V===BigInt(-1)){let Ra=u((z-K)*(X+Y)),Ta=u((z+K)*(X-Y)),Ci=u(Ta-Ra);if(Ci===et)return this.double();let Ca=u(G*ho*se),Na=u(ee*ho*fe),_a=Na+Ca,Ua=Ta+Ra,La=Na-Ca,Xf=u(_a*Ci),Qf=u(Ua*La),eh=u(_a*La),th=u(Ci*Ua);return new S(Xf,Qf,th,eh)}let be=u(K*Y),xe=u(z*X),pe=u(ee*F*se),Ae=u(G*fe),mt=u((K+z)*(Y+X)-be-xe),rr=Ae-pe,on=Ae+pe,ka=u(xe-V*be),Yf=u(mt*rr),Zf=u(on*ka),Wf=u(mt*ka),Jf=u(rr*on);return new S(Yf,Zf,Jf,Wf)}subtract(w){return this.add(w.negate())}wNAF(w){return y.wNAFCached(this,v,w,S.normalizeZ)}multiply(w){let{p:V,f:F}=this.wNAF(b(w,n));return S.normalizeZ([V,F])[0]}multiplyUnsafe(w){let V=k(w);return V===et?N:this.equals(N)||V===Fe?this:this.equals(R)?this.wNAF(V).p:y.unsafeLadder(this,V)}isSmallOrder(){return this.multiplyUnsafe(c).is0()}isTorsionFree(){return y.unsafeLadder(this,n).is0()}toAffine(w){let{ex:V,ey:F,ez:K}=this,z=this.is0();w==null&&(w=z?z0:t.inv(K));let G=u(V*w),ee=u(F*w),Y=u(K*w);if(z)return{x:et,y:Fe};if(Y!==Fe)throw new Error("invZ was invalid");return{x:G,y:ee}}clearCofactor(){let{h:w}=e;return w===Fe?this:this.multiplyUnsafe(w)}static fromHex(w,V=!1){let{d:F,a:K}=e,z=t.BYTES;w=ce("pointHex",w,z);let G=w.slice(),ee=w[z-1];G[z-1]=ee&-129;let Y=qt(G);Y===et||(V?b(Y,f):b(Y,t.ORDER));let X=u(Y*Y),fe=u(X-Fe),se=u(F*X-K),{isValid:be,value:xe}=l(fe,se);if(!be)throw new Error("Point.fromHex: invalid y coordinate");let pe=(xe&Fe)===Fe,Ae=(ee&128)!==0;if(!V&&xe===et&&Ae)throw new Error("Point.fromHex: x=0 and x_0=1");return Ae!==pe&&(xe=u(-xe)),S.fromAffine({x:xe,y:Y})}static fromPrivateKey(w){return T(w).point}toRawBytes(){let{x:w,y:V}=this.toAffine(),F=ar(V,t.BYTES);return F[F.length-1]|=w&Fe?128:0,F}toHex(){return bt(this.toRawBytes())}}S.BASE=new S(e.Gx,e.Gy,Fe,u(e.Gx*e.Gy)),S.ZERO=new S(et,Fe,Fe,et);let{BASE:R,ZERO:N}=S,y=fo(S,a*8);function C(B){return re(B,n)}function D(B){return C(qt(B))}function T(B){let w=a;B=ce("private key",B,w);let V=ce("hashed private key",i(B),2*w),F=d(V.slice(0,w)),K=V.slice(w,2*w),z=D(F),G=R.multiply(z),ee=G.toRawBytes();return{head:F,prefix:K,scalar:z,point:G,pointBytes:ee}}function O(B){return T(B).pointBytes}function H(B=new Uint8Array,...w){let V=Et(...w);return D(i(E(V,ce("context",B),!!o)))}function W(B,w,V={}){B=ce("message",B),o&&(B=o(B));let{prefix:F,scalar:K,pointBytes:z}=T(w),G=H(V.context,F,B),ee=R.multiply(G).toRawBytes(),Y=H(V.context,ee,z,B),X=C(G+Y*K);k(X);let fe=Et(ee,ar(X,t.BYTES));return ce("result",fe,a*2)}let x=G0;function A(B,w,V,F=x){let{context:K,zip215:z}=F,G=t.BYTES;B=ce("signature",B,2*G),w=ce("message",w),o&&(w=o(w));let ee=qt(B.slice(G,2*G)),Y,X,fe;try{Y=S.fromHex(V,z),X=S.fromHex(B.slice(0,G),z),fe=R.multiplyUnsafe(ee)}catch{return!1}if(!z&&Y.isSmallOrder())return!1;let se=H(K,X.toRawBytes(),Y.toRawBytes(),w);return X.add(Y.multiplyUnsafe(se)).subtract(fe).clearCofactor().equals(S.ZERO)}return R._setWindowSize(8),{CURVE:e,getPublicKey:O,sign:W,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 _s=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),Yc=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),gb=BigInt(0),Y0=BigInt(1),Ns=BigInt(2),Z0=BigInt(5),Zc=BigInt(10),W0=BigInt(20),J0=BigInt(40),Wc=BigInt(80);function X0(r){let e=_s,n=r*r%e*r%e,o=ie(n,Ns,e)*n%e,i=ie(o,Y0,e)*r%e,s=ie(i,Z0,e)*i%e,a=ie(s,Zc,e)*s%e,c=ie(a,W0,e)*a%e,f=ie(c,J0,e)*c%e,u=ie(f,Wc,e)*f%e,l=ie(u,Wc,e)*f%e,d=ie(l,Zc,e)*s%e;return{pow_p_5_8:ie(d,Ns,e)*r%e,b2:n}}function Q0(r){return r[0]&=248,r[31]&=127,r[31]|=64,r}function ep(r,e){let t=_s,n=re(e*e*e,t),o=re(n*n*e,t),i=X0(r*o).pow_p_5_8,s=re(r*n*i,t),a=re(e*s*s,t),c=s,f=re(s*Yc,t),u=a===r,l=a===re(-r,t),d=a===re(-r*Yc,t);return u&&(s=c),(l||d)&&(s=f),qc(s,t)&&(s=re(-s,t)),{isValid:u||l,value:s}}var vt=lo(_s,void 0,!0),Us={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:vt,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:BigInt(8),Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:Or,randomBytes:Vr,adjustScalarBytes:Q0,uvRatio:ep},Fr=po(Us);function Jc(r,e,t){if(e.length>255)throw new Error("Context is too big");return oo(xs("SigEd25519 no Ed25519 collisions"),new Uint8Array([t?1:0,e.length]),e,r)}var mb=po({...Us,domain:Jc}),yb=po({...Us,domain:Jc,prehash:Or});var tp=(vt.ORDER+BigInt(3))/BigInt(8),wb=vt.pow(Ns,tp),bb=vt.sqrt(vt.neg(vt.ONE)),xb=(vt.ORDER-BigInt(5))/BigInt(8),Eb=BigInt(486662);var vb=zc(vt,vt.neg(BigInt(486664)));var Bb=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),Ab=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),Sb=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),Ib=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952");var kb=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");var Mr=32,Bt=64,go=32;function Xc(){let r=Fr.utils.randomPrivateKey(),e=Fr.getPublicKey(r);return{privateKey:ru(r,e),publicKey:e}}function Qc(r){if(r.length!==go)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=Fr.getPublicKey(e);return{privateKey:ru(e,t),publicKey:t}}function eu(r,e){let t=r.subarray(0,go);return Fr.sign(e instanceof Uint8Array?e:e.subarray(),t)}function tu(r,e,t){return Fr.verify(e,t instanceof Uint8Array?t:t.subarray(),r)}function ru(r,e){let t=new Uint8Array(Bt);for(let n=0;n<go;n++)t[n]=r[n],t[go+n]=e[n];return t}var Ne={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 Ls={alg:"A128GCM",ext:!0,k:"scm9jmO_4BJAgdwWGVulLg",key_ops:["encrypt","decrypt"],kty:"oct"};function nu(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=Ne.get();t*=8;async function c(l,d){let E=a.getRandomValues(new Uint8Array(i)),g=a.getRandomValues(new Uint8Array(n)),h={name:e,iv:g};typeof d=="string"&&(d=J(d));let p;if(d.length===0){p=await a.subtle.importKey("jwk",Ls,{name:"AES-GCM"},!0,["encrypt"]);try{let k={name:"PBKDF2",salt:E,iterations:s,hash:{name:o}},v=await a.subtle.importKey("raw",d,{name:"PBKDF2"},!1,["deriveKey"]);p=await a.subtle.deriveKey(k,v,{name:e,length:t},!0,["encrypt"])}catch{p=await a.subtle.importKey("jwk",Ls,{name:"AES-GCM"},!0,["encrypt"])}}else{let k={name:"PBKDF2",salt:E,iterations:s,hash:{name:o}},v=await a.subtle.importKey("raw",d,{name:"PBKDF2"},!1,["deriveKey"]);p=await a.subtle.deriveKey(k,v,{name:e,length:t},!0,["encrypt"])}let b=await a.subtle.encrypt(h,p,l);return Ce([E,h.iv,new Uint8Array(b)])}async function f(l,d){let E=l.subarray(0,i),g=l.subarray(i,i+n),h=l.subarray(i+n),p={name:e,iv:g};typeof d=="string"&&(d=J(d));let b;if(d.length===0)try{let v={name:"PBKDF2",salt:E,iterations:s,hash:{name:o}},L=await a.subtle.importKey("raw",d,{name:"PBKDF2"},!1,["deriveKey"]);b=await a.subtle.deriveKey(v,L,{name:e,length:t},!0,["decrypt"])}catch{b=await a.subtle.importKey("jwk",Ls,{name:"AES-GCM"},!0,["decrypt"])}else{let v={name:"PBKDF2",salt:E,iterations:s,hash:{name:o}},L=await a.subtle.importKey("raw",d,{name:"PBKDF2"},!1,["deriveKey"]);b=await a.subtle.deriveKey(v,L,{name:e,length:t},!0,["decrypt"])}let k=await a.subtle.decrypt(p,b,h);return new Uint8Array(k)}return{encrypt:c,decrypt:f}}async function Hr(r,e){let n=await nu().encrypt(r,e);return sn.encode(n)}var Vs=new Float32Array([-0]),Gt=new Uint8Array(Vs.buffer);function ou(r,e,t){Vs[0]=r,e[t]=Gt[0],e[t+1]=Gt[1],e[t+2]=Gt[2],e[t+3]=Gt[3]}function iu(r,e){return Gt[0]=r[e],Gt[1]=r[e+1],Gt[2]=r[e+2],Gt[3]=r[e+3],Vs[0]}var Ds=new Float64Array([-0]),Ie=new Uint8Array(Ds.buffer);function su(r,e,t){Ds[0]=r,e[t]=Ie[0],e[t+1]=Ie[1],e[t+2]=Ie[2],e[t+3]=Ie[3],e[t+4]=Ie[4],e[t+5]=Ie[5],e[t+6]=Ie[6],e[t+7]=Ie[7]}function au(r,e){return Ie[0]=r[e],Ie[1]=r[e+1],Ie[2]=r[e+2],Ie[3]=r[e+3],Ie[4]=r[e+4],Ie[5]=r[e+5],Ie[6]=r[e+6],Ie[7]=r[e+7],Ds[0]}var op=BigInt(Number.MAX_SAFE_INTEGER),ip=BigInt(Number.MIN_SAFE_INTEGER),Me=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 ur;if(e<op&&e>ip)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>cu&&(o=0n,++n>cu&&(n=0n))),new r(Number(o),Number(n))}static fromNumber(e){if(e===0)return ur;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):ur}},ur=new Me(0,0);ur.toBigInt=function(){return 0n};ur.zzEncode=ur.zzDecode=function(){return this};ur.length=function(){return 1};var cu=4294967296n;function uu(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 lu(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 Os(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 tt(r,e){return RangeError(`index out of range: ${r.pos} + ${e??1} > ${r.len}`)}function mo(r,e){return(r[e-4]|r[e-3]<<8|r[e-2]<<16|r[e-1]<<24)>>>0}var Ps=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,tt(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 tt(this,4);return mo(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw tt(this,4);return mo(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw tt(this,4);let e=iu(this.buf,this.pos);return this.pos+=4,e}double(){if(this.pos+8>this.len)throw tt(this,4);let e=au(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 tt(this,e);return this.pos+=e,t===n?new Uint8Array(0):this.buf.subarray(t,n)}string(){let e=this.bytes();return lu(e,0,e.length)}skip(e){if(typeof e=="number"){if(this.pos+e>this.len)throw tt(this,e);this.pos+=e}else do if(this.pos>=this.len)throw tt(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 Me(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 tt(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 tt(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 tt(this,8);let e=mo(this.buf,this.pos+=4),t=mo(this.buf,this.pos+=4);return new Me(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=as(this.buf,this.pos);return this.pos+=Le(e),e}uint64String(){return this.readLongVarint().toString(!0)}sint64(){return this.readLongVarint().zzDecode().toBigInt()}sint64Number(){return this.readLongVarint().zzDecode().toNumber()}sint64String(){return this.readLongVarint().zzDecode().toString()}fixed64(){return this.readFixed64().toBigInt()}fixed64Number(){return this.readFixed64().toNumber()}fixed64String(){return this.readFixed64().toString()}sfixed64(){return this.readFixed64().toBigInt()}sfixed64Number(){return this.readFixed64().toNumber()}sfixed64String(){return this.readFixed64().toString()}};function Fs(r){return new Ps(r instanceof Uint8Array?r:r.subarray())}function Kr(r,e,t){let n=Fs(r);return e.decode(n,void 0,t)}function Ms(r){let e=r??8192,t=e>>>1,n,o=e;return function(s){if(s<1||s>t)return Xe(s);o+s>e&&(n=Xe(e),o=0);let a=n.subarray(o,o+=s);return o&7&&(o=(o|7)+1),a}}var lr=class{fn;len;next;val;constructor(e,t,n){this.fn=e,this.len=t,this.next=void 0,this.val=n}};function Hs(){}var $s=class{head;tail;len;next;constructor(e){this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}},sp=Ms();function ap(r){return globalThis.Buffer!=null?Xe(r):sp(r)}var yn=class{len;head;tail;states;constructor(){this.len=0,this.head=new lr(Hs,0,0),this.tail=this.head,this.states=null}_push(e,t,n){return this.tail=this.tail.next=new lr(e,t,n),this.len+=t,this}uint32(e){return this.len+=(this.tail=this.tail.next=new qs((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(yo,10,Me.fromNumber(e)):this.uint32(e)}sint32(e){return this.uint32((e<<1^e>>31)>>>0)}uint64(e){let t=Me.fromBigInt(e);return this._push(yo,t.length(),t)}uint64Number(e){return this._push(ss,Le(e),e)}uint64String(e){return this.uint64(BigInt(e))}int64(e){return this.uint64(e)}int64Number(e){return this.uint64Number(e)}int64String(e){return this.uint64String(e)}sint64(e){let t=Me.fromBigInt(e).zzEncode();return this._push(yo,t.length(),t)}sint64Number(e){let t=Me.fromNumber(e).zzEncode();return this._push(yo,t.length(),t)}sint64String(e){return this.sint64(BigInt(e))}bool(e){return this._push(Ks,1,e?1:0)}fixed32(e){return this._push(mn,4,e>>>0)}sfixed32(e){return this.fixed32(e)}fixed64(e){let t=Me.fromBigInt(e);return this._push(mn,4,t.lo)._push(mn,4,t.hi)}fixed64Number(e){let t=Me.fromNumber(e);return this._push(mn,4,t.lo)._push(mn,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(ou,4,e)}double(e){return this._push(su,8,e)}bytes(e){let t=e.length>>>0;return t===0?this._push(Ks,1,0):this.uint32(t)._push(up,t,e)}string(e){let t=uu(e);return t!==0?this.uint32(t)._push(Os,t,e):this._push(Ks,1,0)}fork(){return this.states=new $s(this),this.head=this.tail=new lr(Hs,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 lr(Hs,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=ap(this.len),n=0;for(;e!=null;)e.fn(e.val,t,n),n+=e.len,e=e.next;return t}};function Ks(r,e,t){e[t]=r&255}function cp(r,e,t){for(;r>127;)e[t++]=r&127|128,r>>>=7;e[t]=r}var qs=class extends lr{next;constructor(e,t){super(cp,e,t),this.next=void 0}};function yo(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 mn(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&&(yn.prototype.bytes=function(r){let e=r.length>>>0;return this.uint32(e),e>0&&this._push(lp,e,r),this},yn.prototype.string=function(r){let e=globalThis.Buffer.byteLength(r);return this.uint32(e),e>0&&this._push(fp,e,r),this});function lp(r,e,t){e.set(r,t)}function fp(r,e,t){r.length<40?Os(r,e,t):e.utf8Write!=null?e.utf8Write(r,t):e.set(J(r),t)}function zs(){return new yn}function $r(r,e){let t=zs();return e.encode(r,t,{lengthDelimited:!1}),t.finish()}var qr;(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"})(qr||(qr={}));function wo(r,e,t,n){return{name:r,type:e,encode:t,decode:n}}function wn(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 wo("enum",qr.VARINT,t,n)}function zr(r,e){return wo("message",qr.LENGTH_DELIMITED,r,e)}var le;(function(r){r.RSA="RSA",r.Ed25519="Ed25519",r.Secp256k1="Secp256k1"})(le||(le={}));var Gs;(function(r){r[r.RSA=0]="RSA",r[r.Ed25519=1]="Ed25519",r[r.Secp256k1=2]="Secp256k1"})(Gs||(Gs={}));(function(r){r.codec=()=>wn(Gs)})(le||(le={}));var ft;(function(r){let e;r.codec=()=>(e==null&&(e=zr((t,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),t.Type!=null&&(n.uint32(8),le.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=le.codec().decode(t);break;case 2:o.Data=t.bytes();break;default:t.skipType(s&7);break}}return o})),e),r.encode=t=>$r(t,r.codec()),r.decode=t=>Kr(t,r.codec())})(ft||(ft={}));var At;(function(r){let e;r.codec=()=>(e==null&&(e=zr((t,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),t.Type!=null&&(n.uint32(8),le.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=le.codec().decode(t);break;case 2:o.Data=t.bytes();break;default:t.skipType(s&7);break}}return o})),e),r.encode=t=>$r(t,r.codec()),r.decode=t=>Kr(t,r.codec())})(At||(At={}));var bn=class{_key;constructor(e){this._key=Gr(e,Mr)}verify(e,t){return tu(this._key,t,e)}marshal(){return this._key}get bytes(){return ft.encode({Type:le.Ed25519,Data:this.marshal()}).subarray()}equals(e){return he(this.bytes,e.bytes)}hash(){let e=Ee.digest(this.bytes);return Ge(e)?e.then(({bytes:t})=>t):e.bytes}},fr=class{_key;_publicKey;constructor(e,t){this._key=Gr(e,Bt),this._publicKey=Gr(t,Mr)}sign(e){return eu(this._key,e)}get public(){return new bn(this._publicKey)}marshal(){return this._key}get bytes(){return At.encode({Type:le.Ed25519,Data:this.marshal()}).subarray()}equals(e){return he(this.bytes,e.bytes)}async hash(){let e=Ee.digest(this.bytes),t;return Ge(e)?{bytes:t}=await e:t=e.bytes,t}async id(){let e=ut.digest(this.public.bytes);return ue.encode(e.bytes).substring(1)}async export(e,t="libp2p-key"){if(t==="libp2p-key")return Hr(this.bytes,e);throw new P(`export format '${t}' is not supported`,"ERR_INVALID_EXPORT_FORMAT")}};function hp(r){if(r.length>Bt){r=Gr(r,Bt+Mr);let n=r.subarray(0,Bt),o=r.subarray(Bt,r.length);return new fr(n,o)}r=Gr(r,Bt);let e=r.subarray(0,Bt),t=r.subarray(Mr);return new fr(e,t)}function dp(r){return r=Gr(r,Mr),new bn(r)}async function pp(){let{privateKey:r,publicKey:e}=Xc();return new fr(r,e)}async function hu(r){let{privateKey:e,publicKey:t}=Qc(r);return new fr(e,t)}function Gr(r,e){if(r=Uint8Array.from(r??[]),r.length!==e)throw new P(`Key must be a Uint8Array of length ${e}, got ${r.length}`,"ERR_INVALID_KEY_TYPE");return r}var na={};me(na,{MAX_RSA_KEY_SIZE:()=>Nn,RsaPrivateKey:()=>Jr,RsaPublicKey:()=>Cn,fromJwk:()=>Hp,generateKeyPair:()=>Kp,unmarshalRsaPrivateKey:()=>ta,unmarshalRsaPublicKey:()=>Mp});function hr(r){if(isNaN(r)||r<=0)throw new P("random bytes length must be a Number bigger than 0","ERR_INVALID_LENGTH");return Vr(r)}var Wt={};me(Wt,{exportToPem:()=>Vp,importFromPem:()=>Dp,jwkToPkcs1:()=>Np,jwkToPkix:()=>Up,pkcs1ToJwk:()=>Cp,pkixToJwk:()=>_p});var xo=class extends Ur{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,ro(e);let n=Mt(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 _r(this),this.iHash.update(e),this}digestInto(e){_r(this),Nr(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()}},xn=(r,e,t)=>new xo(r,e).update(t).digest();xn.create=(r,e)=>new xo(r,e);function gp(r,e,t,n){ro(r);let o=Lc({dkLen:32,asyncTick:10},n),{c:i,dkLen:s,asyncTick:a}=o;if(Cr(i),Cr(s),Cr(a),i<1)throw new Error("PBKDF2: iterations (c) should be >= 1");let c=Mt(e),f=Mt(t),u=new Uint8Array(s),l=xn.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 Ys(r,e,t,n){let{c:o,dkLen:i,asyncTick:s,DK:a,PRF:c,PRFSalt:f}=gp(r,e,t,n),u,l=new Uint8Array(4),d=Lr(l),E=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(E),p.set(E.subarray(0,p.length)),await Uc(o-1,s,()=>{c._cloneInto(u).update(E).digestInto(E);for(let b=0;b<p.length;b++)p[b]^=E[b]})}return mp(c,f,a,u,E)}var j=Lt(du());function dr(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 jt(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 Bo(...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 Ws(){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=dr(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,dr(i,8)-n}function pu(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=jt(s,8,n),c=new Uint8Array(a);return c[0]|=128,a}let o=jt(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 gu(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 _x=Math.log(2);function Ao(){if(typeof BigInt>"u")throw new Error("BigInt is not defined. Your environment doesn't implement BigInt.")}function Js(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 Tt(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 vn=class{constructor(){this.items=[]}write(e){this.items.push(e)}final(){return Js(this.items)}},En=[new Uint8Array([1])],mu="0123456789";var Zr="",nt=new ArrayBuffer(0),Xs=new Uint8Array(0),Bn="EndOfContent",wu="OCTET STRING",bu="BIT STRING";function Ct(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):Xs}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(!Tt(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",nt)}toJSON(){return{...super.toJSON(),isHexOnly:this.isHexOnly,valueHex:j.Convert.ToHex(this.valueHexView)}}},e.NAME="hexBlock",e}var It=class{constructor({blockLength:e=0,error:t=Zr,warnings:n=[],valueBeforeDecode:o=Xs}={}){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)}}};It.NAME="baseBlock";var ke=class extends It{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'")}};ke.NAME="valueBlock";var So=class extends Ct(It){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):Xs,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",nt}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=jt(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(!Tt(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 E=0;E<f.length;E++)d[E]=f[E];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=dr(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 Io=class extends It{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(!Tt(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=dr(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=jt(this.length,8);if(o.byteLength>127)return this.error="Too big length",nt;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}}};Io.NAME="lengthBlock";var _={},ve=class extends It{constructor({name:e=Zr,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 Io(o),this.valueBlock=i?new i(o):new ke(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 vn;t||xu(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?nt: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 gu(t,n)}};ve.NAME="BaseBlock";function xu(r){if(r instanceof _.Constructed)for(let e of r.valueBlock.value)xu(e)&&(r.lenBlock.isIndefiniteForm=!0);return!!r.lenBlock.isIndefiniteForm}var ko=class extends ve{constructor({value:e=Zr,...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}'`}};ko.NAME="BaseStringBlock";var Ro=class extends Ct(ke){constructor({isHexOnly:e=!0,...t}={}){super(t),this.isHexOnly=e}};Ro.NAME="PrimitiveValueBlock";var Eu,To=class extends ve{constructor(e={}){super(e,Ro),this.idBlock.isConstructed=!1}};Eu=To;_.Primitive=Eu;To.NAME="PRIMITIVE";function Sp(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 ci(r,e=0,t=r.length){let n=e,o=new ve({},ke),i=new It;if(!Tt(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=ve;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=Sp(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 Wr(r){if(!r.byteLength){let e=new ve({},ke);return e.error="Input buffer has zero length",{offset:-1,result:e}}return ci(j.BufferSourceConverter.toUint8Array(r).slice(),0,r.byteLength)}function Ip(r,e){return r?1:e}var ht=class extends ke{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(!Tt(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(;Ip(this.isIndefiniteForm,n)>0;){let s=ci(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===Bn)break}return this.isIndefiniteForm&&(this.value[this.value.length-1].constructor.NAME===Bn?this.value.pop():this.warnings.push("No EndOfContent block encoded")),i}toBER(e,t){let n=t||new vn;for(let o=0;o<this.value.length;o++)this.value[o].toBER(e,n);return t?nt:n.final()}toJSON(){let e={...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,value:[]};for(let t of this.value)e.value.push(t.toJSON());return e}};ht.NAME="ConstructedValueBlock";var vu,Yt=class extends ve{constructor(e={}){super(e,ht),this.idBlock.isConstructed=!0}fromBER(e,t,n){this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm;let o=this.valueBlock.fromBER(e,t,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length);return o===-1?(this.error=this.valueBlock.error,o):(this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),o)}onAsciiEncoding(){let e=[];for(let n of this.valueBlock.value)e.push(n.toString("ascii").split(`
2
+ "use strict";var HeliaDelegatedRoutingV1HttpApiClient=(()=>{var th=Object.create;var qn=Object.defineProperty;var rh=Object.getOwnPropertyDescriptor;var nh=Object.getOwnPropertyNames;var oh=Object.getPrototypeOf,ih=Object.prototype.hasOwnProperty;var zn=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),me=(r,e)=>{for(var t in e)qn(r,t,{get:e[t],enumerable:!0})},Ma=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of nh(e))!ih.call(r,o)&&o!==t&&qn(r,o,{get:()=>e[o],enumerable:!(n=rh(e,o))||n.enumerable});return r};var rr=(r,e,t)=>(t=r!=null?th(oh(r)):{},Ma(e||!r||!r.__esModule?qn(t,"default",{value:r,enumerable:!0}):t,r)),sh=r=>Ma(qn({},"__esModule",{value:!0}),r);var fu=zn($r=>{"use strict";var gp="[object ArrayBuffer]",At=class r{static isArrayBuffer(e){return Object.prototype.toString.call(e)===gp}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",yp=/^[0-9a-f]+$/i,wp=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/,bp=/^[a-zA-Z0-9-_]+$/,xo=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=At.toUint8Array(e),n="";for(let i=0;i<t.length;i++)n+=String.fromCharCode(t[i]);return decodeURIComponent(escape(n))}},je=class{static toString(e,t=!1){let n=At.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}},Eo=class r{static isHex(e){return typeof e===ta&&yp.test(e)}static isBase64(e){return typeof e===ta&&wp.test(e)}static isBase64Url(e){return typeof e===ta&&bp.test(e)}static ToString(e,t="utf8"){let n=At.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 je.toString(n,!0);case"utf16":case"utf16be":return je.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 je.fromString(e,!0);case"utf16":case"utf16be":return je.fromString(e);default:throw new Error(`Unknown type of encoding '${t}'`)}}static ToBase64(e){let t=At.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 xo.fromString(e);case"utf16":case"utf16be":return je.fromString(e);case"utf16le":case"usc2":return je.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 xo.toString(e);case"utf16":case"utf16be":return je.toString(e);case"utf16le":case"usc2":return je.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=At.toUint8Array(e),n="";for(let o=0;o<t.length;o++)n+=String.fromCharCode(t[o]);return n}static ToHex(e){let t=At.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 je.toString(e,t)}static FromUtf16String(e,t=!1){return je.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,"")||""}};Eo.DEFAULT_UTF8_ENCODING="utf8";function xp(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 vp(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}$r.BufferSourceConverter=At;$r.Convert=Eo;$r.assign=xp;$r.combine=Ep;$r.isEqual=vp});var li=zn((I1,wl)=>{"use strict";function yl(r,e){for(let t in e)Object.defineProperty(r,t,{value:e[t],enumerable:!0,configurable:!0});return r}function rm(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 yl(r,t)}catch{t.message=r.message,t.stack=r.stack;let o=function(){};return o.prototype=Object.create(Object.getPrototypeOf(r)),yl(new o,t)}}wl.exports=rm});var ya=zn((_1,ga)=>{var N1=function(){typeof ga<"u"&&(ga.exports=m);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(b){var v=b-b%1;return v==0&&(b<0||b===0&&1/b!=1/0)?-0:v},u=m.prototype,l=(m.fromDate=function(b){return new m(+b)},m.fromInt64BE=k(0,1,2,3,0,4),m.fromInt64LE=k(3,2,1,0,4,0),m.fromString=function(_){var v,F=new m,_=(_+="").replace(/^\s*[+\-]?\d+/,function($){var $=+$,S=1970+($-1970)%400;return F.year=$-S,S}).replace(/(?:Z|([+\-]\d{2}):?(\d{2}))$/,function(C,$,S){return $<0&&(S*=-1),v=6e4*(60*+$+ +S),""}).replace(/\.\d+$/,function(C){return F.nano=+(C+c).substr(1,9),""}).split(/\D+/);if(1<_.length?_[1]--:_[1]=0,F.time=v=Date.UTC.apply(Date,_)-(v||0),isNaN(v))throw new TypeError("Invalid Date");return d(F)},m.fromTimeT=function(b){return R(b,0)},u.year=0,u.time=0,u.nano=0,u.addNano=function(b){return this.nano+=+b||0,this},u.getNano=function(){var b=d(this);return(b.time%1e3*a+ +b.nano+1e9)%1e9},u.getTimeT=function(){var v=d(this),b=Math.floor(v.time/1e3),v=v.year;return v&&(b+=v*t*r/e),b},u.getYear=function(){return this.toDate().getUTCFullYear()+this.year},u.toDate=function(){return E(d(this).time)},u.toJSON=function(){return this.toString().replace(/0{1,6}Z$/,"Z")},u.toString=function(b){var v=this,F=v.toDate(),_={H:function(){return V(F.getUTCHours())},L:function(){return N(F.getUTCMilliseconds(),3)},M:function(){return V(F.getUTCMinutes())},N:function(){return N(v.getNano(),9)},S:function(){return V(F.getUTCSeconds())},Y:function(){var C=v.getYear();return 999999<C?"+"+C:9999<C?"+"+N(C,6):0<=C?N(C,4):-999999<=C?"-"+N(-C,6):C},a:function(){return w[F.getUTCDay()]},b:function(){return h[F.getUTCMonth()]},d:function(){return V(F.getUTCDate())},e:function(){return function(C){return(9<C?"":" ")+(0|C)}(F.getUTCDate())},m:function(){return V(F.getUTCMonth()+1)}};return function C($){return $.replace(/%./g,function(S){var g=S[1],I=B[g],g=_[g];return I?C(I):g?g():S})}(b||l)},u.writeInt64BE=y(0,1,2,3,0,4),u.writeInt64LE=y(3,2,1,0,4,0),"%Y-%m-%dT%H:%M:%S.%NZ"),h=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],w=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],B={"%":"%",F:"%Y-%m-%d",n:`
3
+ `,R:"%H:%M",T:"%H:%M:%S",t:" ",X:"%T",Z:"GMT",z:"+0000"};return m;function m(b,v,F){var _=this;if(!(_ instanceof m))return new m(b,v,F);_.time=+b||0,_.nano=+v||0,_.year=+F||0,d(_)}function d(b){var v,F,_,C=b.year,$=b.time,S=b.nano,I=((S<0||a<=S)&&(S-=(F=Math.floor(S/a))*a,$+=F,F=1),C%e);return($<-i||i<$||I)&&((v=f($/o))&&(C+=v*e,$-=v*o),(_=E($)).setUTCFullYear(I+_.getUTCFullYear()),_=($=+_)+(v=f((C-=I)/e))*o,v&&-i<=_&&_<=i&&(C-=v*e,$=_),F=1),F&&(b.year=C,b.time=$,b.nano=S),b}function E(b){var v=new Date(0);return v.setTime(b),v}function R(C,_){C=+C||0;var F=f((_=(_|0)*s)/n)+f(C/n),_=_%n+C%n,C=f(_/n);return C&&(F+=C,_-=C*n),new m(1e3*_,0,F*e)}function y(b,v,F,_,C,$){return function(I,g){var A=d(this);I=I||new Array(8),D(I,g|=0);var O=Math.floor(A.time/1e3),A=A.year*(t*r/e),p=f(A/s)+f(O/s),A=A%s+O%s,O=Math.floor(A/s);return O&&(p+=O,A-=O*s),S(I,g+C,p),S(I,g+$,A),I};function S(I,g,p){I[g+b]=p>>24&255,I[g+v]=p>>16&255,I[g+F]=p>>8&255,I[g+_]=255&p}}function k(b,v,F,_,C,$){return function(I,g){D(I,g|=0);var p=S(I,g+C);return R(S(I,g+$),p)};function S(I,g){return 16777216*I[g+b]+(I[g+v]<<16|I[g+F]<<8|I[g+_])}}function D(b,v){if(b=b&&b.length,b==null)throw new TypeError("Invalid Buffer");if(b<v+8)throw new RangeError("Out of range")}function V(b){return(9<b?"":"0")+(0|b)}function N(b,v){return(c+(0|b)).substr(-v)}}()});var Pf=zn((x2,Ra)=>{"use strict";var Hm=Object.prototype.hasOwnProperty,_e="~";function Mn(){}Object.create&&(Mn.prototype=Object.create(null),new Mn().__proto__||(_e=!1));function Km(r,e,t){this.fn=r,this.context=e,this.once=t||!1}function Df(r,e,t,n,o){if(typeof t!="function")throw new TypeError("The listener must be a function");var i=new Km(t,n||r,o),s=_e?_e+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 Si(r,e){--r._eventsCount===0?r._events=new Mn:delete r._events[e]}function Re(){this._events=new Mn,this._eventsCount=0}Re.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(_e?n.slice(1):n);return Object.getOwnPropertySymbols?e.concat(Object.getOwnPropertySymbols(t)):e};Re.prototype.listeners=function(e){var t=_e?_e+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};Re.prototype.listenerCount=function(e){var t=_e?_e+e:e,n=this._events[t];return n?n.fn?1:n.length:0};Re.prototype.emit=function(e,t,n,o,i,s){var a=_e?_e+e:e;if(!this._events[a])return!1;var c=this._events[a],f=arguments.length,u,l;if(c.fn){switch(c.once&&this.removeListener(e,c.fn,void 0,!0),f){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,t),!0;case 3:return c.fn.call(c.context,t,n),!0;case 4:return c.fn.call(c.context,t,n,o),!0;case 5:return c.fn.call(c.context,t,n,o,i),!0;case 6:return c.fn.call(c.context,t,n,o,i,s),!0}for(l=1,u=new Array(f-1);l<f;l++)u[l-1]=arguments[l];c.fn.apply(c.context,u)}else{var h=c.length,w;for(l=0;l<h;l++)switch(c[l].once&&this.removeListener(e,c[l].fn,void 0,!0),f){case 1:c[l].fn.call(c[l].context);break;case 2:c[l].fn.call(c[l].context,t);break;case 3:c[l].fn.call(c[l].context,t,n);break;case 4:c[l].fn.call(c[l].context,t,n,o);break;default:if(!u)for(w=1,u=new Array(f-1);w<f;w++)u[w-1]=arguments[w];c[l].fn.apply(c[l].context,u)}}return!0};Re.prototype.on=function(e,t,n){return Df(this,e,t,n,!1)};Re.prototype.once=function(e,t,n){return Df(this,e,t,n,!0)};Re.prototype.removeListener=function(e,t,n,o){var i=_e?_e+e:e;if(!this._events[i])return this;if(!t)return Si(this,i),this;var s=this._events[i];if(s.fn)s.fn===t&&(!o||s.once)&&(!n||s.context===n)&&Si(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:Si(this,i)}return this};Re.prototype.removeAllListeners=function(e){var t;return e?(t=_e?_e+e:e,this._events[t]&&Si(this,t)):(this._events=new Mn,this._eventsCount=0),this};Re.prototype.off=Re.prototype.removeListener;Re.prototype.addListener=Re.prototype.on;Re.prefixed=_e;Re.EventEmitter=Re;typeof Ra<"u"&&(Ra.exports=Re)});var Zm={};me(Zm,{createDelegatedRoutingV1HttpApiClient:()=>Ym});var Ha=Symbol.for("@libp2p/content-routing");var Gn=Symbol.for("@libp2p/peer-id");function Ka(r){return r!=null&&!!r[Gn]}var $a=Symbol.for("@libp2p/peer-routing");var P=class extends Error{code;props;constructor(e,t,n){super(e),this.code=t,this.name=n?.name??"CodeError",this.props=n??{}}};var gr=(r,...e)=>{try{[...e]}catch{}};var Li={};me(Li,{base32:()=>We,base32hex:()=>ph,base32hexpad:()=>gh,base32hexpadupper:()=>yh,base32hexupper:()=>mh,base32pad:()=>hh,base32padupper:()=>dh,base32upper:()=>Wa,base32z:()=>wh});var rg=new Uint8Array(0);function qa(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 yt(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 za(r){return new TextEncoder().encode(r)}function Ga(r){return new TextDecoder().decode(r)}function ah(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(B){if(B instanceof Uint8Array||(ArrayBuffer.isView(B)?B=new Uint8Array(B.buffer,B.byteOffset,B.byteLength):Array.isArray(B)&&(B=Uint8Array.from(B))),!(B instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(B.length===0)return"";for(var m=0,d=0,E=0,R=B.length;E!==R&&B[E]===0;)E++,m++;for(var y=(R-E)*u+1>>>0,k=new Uint8Array(y);E!==R;){for(var D=B[E],V=0,N=y-1;(D!==0||V<d)&&N!==-1;N--,V++)D+=256*k[N]>>>0,k[N]=D%a>>>0,D=D/a>>>0;if(D!==0)throw new Error("Non-zero carry");d=V,E++}for(var b=y-d;b!==y&&k[b]===0;)b++;for(var v=c.repeat(m);b<y;++b)v+=r.charAt(k[b]);return v}function h(B){if(typeof B!="string")throw new TypeError("Expected String");if(B.length===0)return new Uint8Array;var m=0;if(B[m]!==" "){for(var d=0,E=0;B[m]===c;)d++,m++;for(var R=(B.length-m)*f+1>>>0,y=new Uint8Array(R);B[m];){var k=t[B.charCodeAt(m)];if(k===255)return;for(var D=0,V=R-1;(k!==0||D<E)&&V!==-1;V--,D++)k+=a*y[V]>>>0,y[V]=k%256>>>0,k=k/256>>>0;if(k!==0)throw new Error("Non-zero carry");E=D,m++}if(B[m]!==" "){for(var N=R-E;N!==R&&y[N]===0;)N++;for(var b=new Uint8Array(d+(R-N)),v=d;N!==R;)b[v++]=y[N++];return b}}}function w(B){var m=h(B);if(m)return m;throw new Error(`Non-${e} character`)}return{encode:l,decodeUnsafe:h,decode:w}}var ch=ah,uh=ch,Ya=uh;var Ci=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")}},Ni=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 Za(this,e)}},_i=class{decoders;constructor(e){this.decoders=e}or(e){return Za(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 Za(r,e){return new _i({...r.decoders??{[r.prefix]:r},...e.decoders??{[e.prefix]:e}})}var Ui=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 Ci(e,t,n),this.decoder=new Ni(e,t,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};function yr({name:r,prefix:e,encode:t,decode:n}){return new Ui(r,e,t,n)}function Lt({name:r,prefix:e,alphabet:t}){let{encode:n,decode:o}=Ya(t,r);return yr({prefix:e,name:r,encode:n,decode:i=>yt(o(i))})}function lh(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 fh(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 ie({name:r,prefix:e,bitsPerChar:t,alphabet:n}){return yr({prefix:e,name:r,encode(o){return fh(o,n,t)},decode(o){return lh(o,n,t,r)}})}var We=ie({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Wa=ie({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),hh=ie({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),dh=ie({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),ph=ie({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),mh=ie({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),gh=ie({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),yh=ie({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),wh=ie({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Vi={};me(Vi,{base58btc:()=>ae,base58flickr:()=>bh});var ae=Lt({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),bh=Lt({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Oi={};me(Oi,{base64:()=>rn,base64pad:()=>xh,base64url:()=>Eh,base64urlpad:()=>vh});var rn=ie({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),xh=ie({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Eh=ie({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),vh=ie({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});function Bh(r,e){try{if(typeof r=="string"&&r.length>0)return Ah(r);if(typeof r=="number"&&isFinite(r))return e?.long?Ih(r):Sh(r);throw new Error("Value is not a string or number.")}catch(t){let n=Rh(t)?`${t.message}. value=${JSON.stringify(r)}`:"An unknown error has occured.";throw new Error(n)}}function Ah(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 Yn=Bh;function Sh(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 Ih(r){let e=Math.abs(r);return e>=864e5?jn(r,e,864e5,"day"):e>=36e5?jn(r,e,36e5,"hour"):e>=6e4?jn(r,e,6e4,"minute"):e>=1e3?jn(r,e,1e3,"second"):`${r} ms`}function jn(r,e,t,n){let o=e>=t*1.5;return`${Math.round(r/t)} ${n}${o?"s":""}`}function Rh(r){return typeof r=="object"&&r!==null&&"message"in r}function Di(r){t.debug=t,t.default=t,t.coerce=c,t.disable=i,t.enable=o,t.enabled=s,t.humanize=Yn,t.destroy=f,Object.keys(r).forEach(u=>{t[u]=r[u]}),t.names=[],t.skips=[],t.formatters={};function e(u){let l=0;for(let h=0;h<u.length;h++)l=(l<<5)-l+u.charCodeAt(h),l|=0;return t.colors[Math.abs(l)%t.colors.length]}t.selectColor=e;function t(u){let l,h=null,w,B;function m(...d){if(!m.enabled)return;let E=m,R=Number(new Date),y=R-(l||R);E.diff=y,E.prev=l,E.curr=R,l=R,d[0]=t.coerce(d[0]),typeof d[0]!="string"&&d.unshift("%O");let k=0;d[0]=d[0].replace(/%([a-zA-Z%])/g,(V,N)=>{if(V==="%%")return"%";k++;let b=t.formatters[N];if(typeof b=="function"){let v=d[k];V=b.call(E,v),d.splice(k,1),k--}return V}),t.formatArgs.call(E,d),(E.log||t.log).apply(E,d)}return m.namespace=u,m.useColors=t.useColors(),m.color=t.selectColor(u),m.extend=n,m.destroy=t.destroy,Object.defineProperty(m,"enabled",{enumerable:!0,configurable:!1,get:()=>h!==null?h:(w!==t.namespaces&&(w=t.namespaces,B=t.enabled(u)),B),set:d=>{h=d}}),typeof t.init=="function"&&t.init(m),m}function n(u,l){let h=t(this.namespace+(typeof l>"u"?":":l)+u);return h.log=this.log,h}function o(u){t.save(u),t.namespaces=u,t.names=[],t.skips=[];let l,h=(typeof u=="string"?u:"").split(/[\s,]+/),w=h.length;for(l=0;l<w;l++)h[l]&&(u=h[l].replace(/\*/g,".*?"),u[0]==="-"?t.skips.push(new RegExp("^"+u.substr(1)+"$")):t.names.push(new RegExp("^"+u+"$")))}function i(){let u=[...t.names.map(a),...t.skips.map(a).map(l=>"-"+l)].join(",");return t.enable(""),u}function s(u){if(u[u.length-1]==="*")return!0;let l,h;for(l=0,h=t.skips.length;l<h;l++)if(t.skips[l].test(u))return!1;for(l=0,h=t.names.length;l<h;l++)if(t.names[l].test(u))return!0;return!1}function a(u){return u.toString().substring(2,u.toString().length-2).replace(/\.\*\?$/,"*")}function c(u){return u instanceof Error?u.stack??u.message:u}function f(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return t.setupFormatters(t.formatters),t.enable(t.load()),t}var Zn=Lh(),kh=["#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 Th(){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 Ch(r){if(r[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+r[0]+(this.useColors?"%c ":" ")+"+"+Yn(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 Nh=console.debug??console.log??(()=>{});function _h(r){try{r?Zn?.setItem("debug",r):Zn?.removeItem("debug")}catch{}}function Uh(){let r;try{r=Zn?.getItem("debug")}catch{}return!r&&typeof process<"u"&&"env"in process&&(r=process.env.DEBUG),r}function Lh(){try{return localStorage}catch{}}function Vh(r){r.j=function(e){try{return JSON.stringify(e)}catch(t){return"[UnexpectedJSONParseError]: "+t.message}}}var Ja=Di({formatArgs:Ch,save:_h,load:Uh,useColors:Th,setupFormatters:Vh,colors:kh,storage:Zn,log:Nh});var Fe=Ja;Fe.formatters.b=r=>r==null?"undefined":ae.baseEncode(r);Fe.formatters.t=r=>r==null?"undefined":We.baseEncode(r);Fe.formatters.m=r=>r==null?"undefined":rn.baseEncode(r);Fe.formatters.p=r=>r==null?"undefined":r.toString();Fe.formatters.c=r=>r==null?"undefined":r.toString();Fe.formatters.k=r=>r==null?"undefined":r.toString();Fe.formatters.a=r=>r==null?"undefined":r.toString();function Oh(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 Vt(r){let e=Oh(`${r}:trace`);return Fe.enabled(`${r}:trace`)&&Fe.names.map(t=>t.toString()).find(t=>t.includes(":trace"))!=null&&(e=Fe(`${r}:trace`)),Object.assign(Fe(r),{error:Fe(`${r}:error`),trace:e})}var Pi={};me(Pi,{base10:()=>Dh});var Dh=Lt({prefix:"9",name:"base10",alphabet:"0123456789"});var Fi={};me(Fi,{base16:()=>Ph,base16upper:()=>Fh});var Ph=ie({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Fh=ie({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Mi={};me(Mi,{base2:()=>Mh});var Mh=ie({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Hi={};me(Hi,{base256emoji:()=>zh});var Xa=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}"),Hh=Xa.reduce((r,e,t)=>(r[t]=e,r),[]),Kh=Xa.reduce((r,e,t)=>(r[e.codePointAt(0)]=t,r),[]);function $h(r){return r.reduce((e,t)=>(e+=Hh[t],e),"")}function qh(r){let e=[];for(let t of r){let n=Kh[t.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${t}`);e.push(n)}return new Uint8Array(e)}var zh=yr({prefix:"\u{1F680}",name:"base256emoji",encode:$h,decode:qh});var Ki={};me(Ki,{base36:()=>Wn,base36upper:()=>Gh});var Wn=Lt({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Gh=Lt({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var $i={};me($i,{base8:()=>jh});var jh=ie({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var qi={};me(qi,{identity:()=>Yh});var Yh=yr({prefix:"\0",name:"identity",encode:r=>Ga(r),decode:r=>za(r)});var Ng=new TextEncoder,_g=new TextDecoder;var Gi={};me(Gi,{identity:()=>Je});var Jh=tc,Qa=128,Xh=127,Qh=~Xh,ed=Math.pow(2,31);function tc(r,e,t){e=e||[],t=t||0;for(var n=t;r>=ed;)e[t++]=r&255|Qa,r/=128;for(;r&Qh;)e[t++]=r&255|Qa,r>>>=7;return e[t]=r|0,tc.bytes=t-n+1,e}var td=zi,rd=128,ec=127;function zi(r,n){var t=0,n=n||0,o=0,i=n,s,a=r.length;do{if(i>=a)throw zi.bytes=0,new RangeError("Could not decode varint");s=r[i++],t+=o<28?(s&ec)<<o:(s&ec)*Math.pow(2,o),o+=7}while(s>=rd);return zi.bytes=i-n,t}var nd=Math.pow(2,7),od=Math.pow(2,14),id=Math.pow(2,21),sd=Math.pow(2,28),ad=Math.pow(2,35),cd=Math.pow(2,42),ud=Math.pow(2,49),ld=Math.pow(2,56),fd=Math.pow(2,63),hd=function(r){return r<nd?1:r<od?2:r<id?3:r<sd?4:r<ad?5:r<cd?6:r<ud?7:r<ld?8:r<fd?9:10},dd={encode:Jh,decode:td,encodingLength:hd},pd=dd,nn=pd;function on(r,e=0){return[nn.decode(r,e),nn.decode.bytes]}function wr(r,e,t=0){return nn.encode(r,e,t),e}function br(r){return nn.encodingLength(r)}function ut(r,e){let t=e.byteLength,n=br(r),o=n+br(t),i=new Uint8Array(o+t);return wr(r,i,0),wr(t,i,n),i.set(e,o),new xr(r,t,e,i)}function Ot(r){let e=yt(r),[t,n]=on(e),[o,i]=on(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 rc(r,e){if(r===e)return!0;{let t=e;return r.code===t.code&&r.size===t.size&&t.bytes instanceof Uint8Array&&qa(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}};var nc=0,md="identity",oc=yt;function gd(r){return ut(nc,oc(r))}var Je={code:nc,name:md,encode:oc,digest:gd};var Zi={};me(Zi,{sha256:()=>xe,sha512:()=>yd});function Yi({name:r,code:e,encode:t}){return new ji(r,e,t)}var ji=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?ut(this.code,t):t.then(n=>ut(this.code,n))}else throw Error("Unknown type, must be binary type")}};function sc(r){return async e=>new Uint8Array(await crypto.subtle.digest(r,e))}var xe=Yi({name:"sha2-256",code:18,encode:sc("SHA-256")}),yd=Yi({name:"sha2-512",code:19,encode:sc("SHA-512")});function ac(r,e){let{bytes:t,version:n}=r;switch(n){case 0:return bd(t,Wi(r),e??ae.encoder);default:return xd(t,Wi(r),e??We.encoder)}}var cc=new WeakMap;function Wi(r){let e=cc.get(r);if(e==null){let t=new Map;return cc.set(r,t),t}return e}var Be=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!==sn)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==Ed)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=ut(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&&rc(e.multihash,n.multihash)}toString(e){return ac(this,e)}toJSON(){return{"/":ac(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??uc(n,o,i.bytes))}else if(t[vd]===!0){let{version:n,multihash:o,code:i}=t,s=Ot(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!==sn)throw new Error(`Version 0 CID must use dag-pb (code: ${sn}) block encoding`);return new r(e,t,n,n.bytes)}case 1:{let o=uc(e,t,n.bytes);return new r(e,t,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return r.create(0,sn,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=yt(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,h]=on(e.subarray(t));return t+=h,l},o=n(),i=sn;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]=wd(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 Wi(i).set(n,e),i}};function wd(r,e){switch(r[0]){case"Q":{let t=e??ae;return[ae.prefix,t.decode(`${ae.prefix}${r}`)]}case ae.prefix:{let t=e??ae;return[ae.prefix,t.decode(r)]}case We.prefix:{let t=e??We;return[We.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 bd(r,e,t){let{prefix:n}=t;if(n!==ae.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 xd(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 sn=112,Ed=18;function uc(r,e,t){let n=br(r),o=n+br(e),i=new Uint8Array(o+t.byteLength);return wr(r,i,0),wr(e,i,n),i.set(t,o),i}var vd=Symbol.for("@ipld/js-cid/CID");var Pt={...qi,...Mi,...$i,...Pi,...Fi,...Li,...Ki,...Vi,...Oi,...Hi},Qg={...Zi,...Gi};function ue(r,e){if(r===e)return!0;if(r.byteLength!==e.byteLength)return!1;for(let t=0;t<r.byteLength;t++)if(r[t]!==e[t])return!1;return!0}function Xe(r=0){return new Uint8Array(r)}function fc(r,e,t,n){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:n}}}var lc=fc("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),Ji=fc("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=Xe(r.length);for(let t=0;t<r.length;t++)e[t]=r.charCodeAt(t);return e}),Bd={utf8:lc,"utf-8":lc,hex:Pt.base16,latin1:Ji,ascii:Ji,binary:Ji,...Pt},Xn=Bd;function Y(r,e="utf8"){let t=Xn[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return t.decoder.decode(`${t.prefix}${r}`)}function z(r,e="utf8"){let t=Xn[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return t.encoder.encode(r).substring(1)}var dc=Symbol.for("nodejs.util.inspect.custom"),hc=Object.values(Pt).map(r=>r.decoder).reduce((r,e)=>r.or(e),Pt.identity.decoder),pc=114,es=36,ts=37,an=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()})`}[Gn]=!0;toString(){return this.string==null&&(this.string=ae.encode(this.multihash.bytes).slice(1)),this.string}toCID(){return Be.createV1(pc,this.multihash)}toBytes(){return this.multihash.bytes}toJSON(){return this.toString()}equals(e){if(e==null)return!1;if(e instanceof Uint8Array)return ue(this.multihash.bytes,e);if(typeof e=="string")return rs(e).equals(this);if(e?.multihash?.bytes!=null)return ue(this.multihash.bytes,e.multihash.bytes);throw new Error("not valid Id")}[dc](){return`PeerId(${this.toString()})`}},Er=class extends an{type="RSA";publicKey;constructor(e){super({...e,type:"RSA"}),this.publicKey=e.publicKey}},vr=class extends an{type="Ed25519";publicKey;constructor(e){super({...e,type:"Ed25519"}),this.publicKey=e.multihash.digest}},Br=class extends an{type="secp256k1";publicKey;constructor(e){super({...e,type:"secp256k1"}),this.publicKey=e.multihash.digest}},Xi=2336,Qi=class{type="url";multihash;privateKey;publicKey;url;constructor(e){this.url=e.toString(),this.multihash=Je.digest(Y(this.url))}[dc](){return`PeerId(${this.url})`}[Gn]=!0;toString(){return this.toCID().toString()}toCID(){return Be.createV1(Xi,this.multihash)}toBytes(){return this.toCID().bytes}equals(e){return e==null?!1:(e instanceof Uint8Array&&(e=z(e)),e.toString()===this.toString())}};function rs(r,e){if(e=e??hc,r.charAt(0)==="1"||r.charAt(0)==="Q"){let t=Ot(ae.decode(`z${r}`));return r.startsWith("12D")?new vr({multihash:t}):r.startsWith("16U")?new Br({multihash:t}):new Er({multihash:t})}return cn(hc.decode(r))}function cn(r){try{let e=Ot(r);if(e.code===Je.code){if(e.digest.length===es)return new vr({multihash:e});if(e.digest.length===ts)return new Br({multihash:e})}if(e.code===xe.code)return new Er({multihash:e})}catch{return Ad(Be.decode(r))}throw new Error("Supplied PeerID CID is invalid")}function Ad(r){if(r?.multihash==null||r.version==null||r.version===1&&r.code!==pc&&r.code!==Xi)throw new Error("Supplied PeerID CID is invalid");if(r.code===Xi){let t=z(r.multihash.digest);return new Qi(new URL(t))}let e=r.multihash;if(e.code===xe.code)return new Er({multihash:r.multihash});if(e.code===Je.code){if(e.digest.length===es)return new vr({multihash:r.multihash});if(e.digest.length===ts)return new Br({multihash:r.multihash})}throw new Error("Supplied PeerID CID is invalid")}async function mc(r,e){return r.length===es?new vr({multihash:ut(Je.code,r),privateKey:e}):r.length===ts?new Br({multihash:ut(Je.code,r),privateKey:e}):new Er({multihash:await xe.digest(r),publicKey:r,privateKey:e})}var Sd=Math.pow(2,7),Id=Math.pow(2,14),Rd=Math.pow(2,21),ns=Math.pow(2,28),os=Math.pow(2,35),is=Math.pow(2,42),ss=Math.pow(2,49),X=128,Ae=127;function Ve(r){if(r<Sd)return 1;if(r<Id)return 2;if(r<Rd)return 3;if(r<ns)return 4;if(r<os)return 5;if(r<is)return 6;if(r<ss)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function as(r,e,t=0){switch(Ve(r)){case 8:e[t++]=r&255|X,r/=128;case 7:e[t++]=r&255|X,r/=128;case 6:e[t++]=r&255|X,r/=128;case 5:e[t++]=r&255|X,r/=128;case 4:e[t++]=r&255|X,r>>>=7;case 3:e[t++]=r&255|X,r>>>=7;case 2:e[t++]=r&255|X,r>>>=7;case 1:{e[t++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return e}function kd(r,e,t=0){switch(Ve(r)){case 8:e.set(t++,r&255|X),r/=128;case 7:e.set(t++,r&255|X),r/=128;case 6:e.set(t++,r&255|X),r/=128;case 5:e.set(t++,r&255|X),r/=128;case 4:e.set(t++,r&255|X),r>>>=7;case 3:e.set(t++,r&255|X),r>>>=7;case 2:e.set(t++,r&255|X),r>>>=7;case 1:{e.set(t++,r&255),r>>>=7;break}default:throw new Error("unreachable")}return e}function cs(r,e){let t=r[e],n=0;if(n+=t&Ae,t<X||(t=r[e+1],n+=(t&Ae)<<7,t<X)||(t=r[e+2],n+=(t&Ae)<<14,t<X)||(t=r[e+3],n+=(t&Ae)<<21,t<X)||(t=r[e+4],n+=(t&Ae)*ns,t<X)||(t=r[e+5],n+=(t&Ae)*os,t<X)||(t=r[e+6],n+=(t&Ae)*is,t<X)||(t=r[e+7],n+=(t&Ae)*ss,t<X))return n;throw new RangeError("Could not decode varint")}function Td(r,e){let t=r.get(e),n=0;if(n+=t&Ae,t<X||(t=r.get(e+1),n+=(t&Ae)<<7,t<X)||(t=r.get(e+2),n+=(t&Ae)<<14,t<X)||(t=r.get(e+3),n+=(t&Ae)<<21,t<X)||(t=r.get(e+4),n+=(t&Ae)*ns,t<X)||(t=r.get(e+5),n+=(t&Ae)*os,t<X)||(t=r.get(e+6),n+=(t&Ae)*is,t<X)||(t=r.get(e+7),n+=(t&Ae)*ss,t<X))return n;throw new RangeError("Could not decode varint")}function Ar(r,e,t=0){return e==null&&(e=Xe(Ve(r))),e instanceof Uint8Array?as(r,e,t):kd(r,e,t)}function nr(r,e=0){return r instanceof Uint8Array?cs(r,e):Td(r,e)}function Te(r,e){e==null&&(e=r.reduce((o,i)=>o+i.length,0));let t=Xe(e),n=0;for(let o of r)t.set(o,n),n+=o.length;return t}var Qn=class{index=0;input="";new(e){return this.index=0,this.input=e,this}readAtomically(e){let t=this.index,n=e();return n===void 0&&(this.index=t),n}parseWith(e){let t=e();if(this.index===this.input.length)return t}peekChar(){if(!(this.index>=this.input.length))return this.input[this.index]}readChar(){if(!(this.index>=this.input.length))return this.input[this.index++]}readGivenChar(e){return this.readAtomically(()=>{let t=this.readChar();if(t===e)return t})}readSeparator(e,t,n){return this.readAtomically(()=>{if(!(t>0&&this.readGivenChar(e)===void 0))return n()})}readNumber(e,t,n,o){return this.readAtomically(()=>{let i=0,s=0,a=this.peekChar();if(a===void 0)return;let c=a==="0",f=2**(8*o)-1;for(;;){let u=this.readAtomically(()=>{let l=this.readChar();if(l===void 0)return;let h=Number.parseInt(l,e);if(!Number.isNaN(h))return h});if(u===void 0)break;if(i*=e,i+=u,i>f||(s+=1,t!==void 0&&s>t))return}if(s!==0)return!n&&c&&s>1?void 0:i})}readIPv4Addr(){return this.readAtomically(()=>{let e=new Uint8Array(4);for(let t=0;t<e.length;t++){let n=this.readSeparator(".",t,()=>this.readNumber(10,3,!1,1));if(n===void 0)return;e[t]=n}return e})}readIPv6Addr(){let e=t=>{for(let n=0;n<t.length/2;n++){let o=n*2;if(n<t.length-3){let s=this.readSeparator(":",n,()=>this.readIPv4Addr());if(s!==void 0)return t[o]=s[0],t[o+1]=s[1],t[o+2]=s[2],t[o+3]=s[3],[o+4,!0]}let i=this.readSeparator(":",n,()=>this.readNumber(16,4,!0,2));if(i===void 0)return[o,!1];t[o]=i>>8,t[o+1]=i&255}return[t.length,!1]};return this.readAtomically(()=>{let t=new Uint8Array(16),[n,o]=e(t);if(n===16)return t;if(o||this.readGivenChar(":")===void 0||this.readGivenChar(":")===void 0)return;let i=new Uint8Array(14),s=16-(n+2),[a]=e(i.subarray(0,s));return t.set(i.subarray(0,a),16-a),t})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var yc=45,Cd=15,Sr=new Qn;function us(r){if(!(r.length>Cd))return Sr.new(r).parseWith(()=>Sr.readIPv4Addr())}function ls(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>yc))return Sr.new(r).parseWith(()=>Sr.readIPv6Addr())}function eo(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>yc))return Sr.new(r).parseWith(()=>Sr.readIPAddr())}var Vy=parseInt("0xFFFF",16),Oy=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);function xc(r){return!!us(r)}function Ec(r){return!!ls(r)}function to(r){return!!eo(r)}var vc=xc,Vd=Ec,fs=function(r){let e=0;if(r=r.toString().trim(),vc(r)){let t=new Uint8Array(e+4);return r.split(/\./g).forEach(n=>{t[e++]=parseInt(n,10)&255}),t}if(Vd(r)){let t=r.split(":",8),n;for(n=0;n<t.length;n++){let i=vc(t[n]),s;i&&(s=fs(t[n]),t[n]=z(s.slice(0,2),"base16")),s!=null&&++n<8&&t.splice(n,0,z(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")},Bc=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 Ir={},hs={},Dd=[[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"]];Dd.forEach(r=>{let e=Pd(...r);hs[e.code]=e,Ir[e.name]=e});function Pd(r,e,t,n,o){return{code:r,size:e,name:t,resolvable:!!n,path:!!o}}function te(r){if(typeof r=="number"){if(hs[r]!=null)return hs[r];throw new Error(`no protocol with code: ${r}`)}else if(typeof r=="string"){if(Ir[r]!=null)return Ir[r];throw new Error(`no protocol with name: ${r}`)}throw new Error(`invalid protocol id type: ${typeof r}`)}var bw=te("ip4"),xw=te("ip6"),Ew=te("ipcidr");function gs(r,e){switch(te(r).code){case 4:case 41:return Md(e);case 42:return ms(e);case 6:case 273:case 33:case 132:return Ic(e).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return ms(e);case 421:return qd(e);case 444:return Sc(e);case 445:return Sc(e);case 466:return $d(e);case 481:return globalThis.encodeURIComponent(ms(e));default:return z(e,"base16")}}function ys(r,e){switch(te(r).code){case 4:return Ac(e);case 41:return Ac(e);case 42:return ps(e);case 6:case 273:case 33:case 132:return ws(parseInt(e,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return ps(e);case 421:return Hd(e);case 444:return zd(e);case 445:return Gd(e);case 466:return Kd(e);case 481:return ps(globalThis.decodeURIComponent(e));default:return Y(e,"base16")}}var ds=Object.values(Pt).map(r=>r.decoder),Fd=function(){let r=ds[0].or(ds[1]);return ds.slice(2).forEach(e=>r=r.or(e)),r}();function Ac(r){if(!to(r))throw new Error("invalid ip address");return fs(r)}function Md(r){let e=Bc(r,0,r.length);if(e==null)throw new Error("ipBuff is required");if(!to(e))throw new Error("invalid ip address");return e}function ws(r){let e=new ArrayBuffer(2);return new DataView(e).setUint16(0,r),new Uint8Array(e)}function Ic(r){return new DataView(r.buffer).getUint16(r.byteOffset)}function ps(r){let e=Y(r),t=Uint8Array.from(Ar(e.length));return Te([t,e],t.length+e.length)}function ms(r){let e=nr(r);if(r=r.slice(Ve(e)),r.length!==e)throw new Error("inconsistent lengths");return z(r)}function Hd(r){let e;r[0]==="Q"||r[0]==="1"?e=Ot(ae.decode(`z${r}`)).bytes:e=Be.parse(r).multihash.bytes;let t=Uint8Array.from(Ar(e.length));return Te([t,e],t.length+e.length)}function Kd(r){let e=Fd.decode(r),t=Uint8Array.from(Ar(e.length));return Te([t,e],t.length+e.length)}function $d(r){let e=nr(r),t=r.slice(Ve(e));if(t.length!==e)throw new Error("inconsistent lengths");return"u"+z(t,"base64url")}function qd(r){let e=nr(r),t=r.slice(Ve(e));if(t.length!==e)throw new Error("inconsistent lengths");return z(t,"base58btc")}function zd(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=We.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=ws(n);return Te([t,o],t.length+o.length)}function Gd(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=We.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=ws(n);return Te([t,o],t.length+o.length)}function Sc(r){let e=r.slice(0,r.length-2),t=r.slice(r.length-2),n=z(e,"base32"),o=Ic(t);return`${n}:${o}`}function Rc(r){r=bs(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 Tc("invalid address: "+r);if(a.path===!0){n=bs(o.slice(i).join("/")),e.push([a.code,ys(a.code,n)]),t.push([a.code,n]);break}let c=ys(a.code,o[i]);e.push([a.code,c]),t.push([a.code,gs(a.code,c)])}return{string:kc(t),bytes:Es(e),tuples:e,stringTuples:t,path:n}}function xs(r){let e=[],t=[],n=null,o=0;for(;o<r.length;){let i=nr(r,o),s=Ve(i),a=te(i),c=jd(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 Tc("Invalid address Uint8Array: "+z(r,"base16"));e.push([i,f]);let u=gs(i,f);if(t.push([i,u]),a.path===!0){n=u;break}}return{bytes:Uint8Array.from(r),string:kc(t),tuples:e,stringTuples:t,path:n}}function kc(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}),bs(e.join("/"))}function Es(r){return Te(r.map(e=>{let t=te(e[0]),n=Uint8Array.from(Ar(t.code));return e.length>1&&e[1]!=null&&(n=Te([n,e[1]])),n}))}function jd(r,e){if(r.size>0)return r.size/8;if(r.size===0)return 0;{let t=nr(e instanceof Uint8Array?e:Uint8Array.from(e));return t+Ve(t)}}function bs(r){return"/"+r.trim().split("/").filter(e=>e).join("/")}function Tc(r){return new Error("Error parsing address: "+r)}var Yd=Symbol.for("nodejs.util.inspect.custom"),Bs=Symbol.for("@multiformats/js-multiaddr/multiaddr"),Zd=[te("dns").code,te("dns4").code,te("dns6").code,te("dnsaddr").code],vs=class extends Error{constructor(e="No available resolver"){super(e),this.name="NoAvailableResolverError"}},ro=class r{bytes;#e;#r;#i;#a;[Bs]=!0;constructor(e){e==null&&(e="");let t;if(e instanceof Uint8Array)t=xs(e);else if(typeof e=="string"){if(e.length>0&&e.charAt(0)!=="/")throw new Error(`multiaddr "${e}" must start with a "/"`);t=Rc(e)}else if(Nc(e))t=xs(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[w,B]of this.stringTuples())w===l.code&&(i=`%${B??""}`),Zd.includes(w)&&(t=s.name,o=443,n=`${B??""}${i}`,e=w===u.code?6:4),(w===s.code||w===a.code)&&(t=te(w).name,o=parseInt(B??"")),(w===c.code||w===f.code)&&(t=te(w).name,n=`${B??""}${i}`,e=w===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(Es(t.slice(0,n)));return this}getPeerId(){try{let e=[];this.stringTuples().forEach(([n,o])=>{n===Ir.p2p.code&&e.push([n,o]),n===Ir["p2p-circuit"].code&&(e=[])});let t=e.pop();if(t?.[1]!=null){let n=t[1];return n[0]==="Q"||n[0]==="1"?z(ae.decode(`z${n}`),"base58btc"):z(Be.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){return this.#a}equals(e){return ue(this.bytes,e.bytes)}async resolve(e){let t=this.protos().find(i=>i.resolvable);if(t==null)return[this];let n=Cc.get(t.name);if(n==null)throw new vs(`no available resolver for ${t.name}`);return(await n(this,e)).map(i=>un(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)}[Yd](){return`Multiaddr(${this.#e})`}};var Cc=new Map;function Nc(r){return!!r?.[Bs]}function un(r){return new ro(r)}function ln(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*no(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={};me(Qs,{Ed25519PrivateKey:()=>hr,Ed25519PublicKey:()=>wn,generateKeyPair:()=>dp,generateKeyPairFromSeed:()=>lu,unmarshalEd25519PrivateKey:()=>fp,unmarshalEd25519PublicKey:()=>hp});function Ge(r){return r==null?!1:typeof r.then=="function"&&typeof r.catch=="function"&&typeof r.finally=="function"}function Rr(r){if(!Number.isSafeInteger(r)||r<0)throw new Error(`positive integer expected, not ${r}`)}function Wd(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}function kr(r,...e){if(!Wd(r))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(r.length))throw new Error(`Uint8Array expected of length ${e}, not of length=${r.length}`)}function oo(r){if(typeof r!="function"||typeof r.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");Rr(r.outputLen),Rr(r.blockLen)}function Tr(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 _c(r,e){kr(r);let t=e.outputLen;if(r.length<t)throw new Error(`digestInto() expects output buffer of length at least ${t}`)}var or=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;var Nr=r=>new DataView(r.buffer,r.byteOffset,r.byteLength),Qe=(r,e)=>r<<32-e|r>>>e;var eb=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;var Jd=async()=>{};async function Uc(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 Jd(),n+=i)}}function Lc(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}function Ft(r){return typeof r=="string"&&(r=Lc(r)),kr(r),r}function As(...r){let e=0;for(let n=0;n<r.length;n++){let o=r[n];kr(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 Cr=class{clone(){return this._cloneInto()}},Xd={}.toString;function Vc(r,e){if(e!==void 0&&Xd.call(e)!=="[object Object]")throw new Error("Options should be object or undefined");return Object.assign(r,e)}function io(r){let e=n=>r().update(Ft(n)).digest(),t=r();return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=()=>r(),e}function _r(r=32){if(or&&typeof or.getRandomValues=="function")return or.getRandomValues(new Uint8Array(r));if(or&&typeof or.randomBytes=="function")return or.randomBytes(r);throw new Error("crypto.getRandomValues must be defined")}function Qd(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 Oc=(r,e,t)=>r&e^~r&t,Dc=(r,e,t)=>r&e^r&t^e&t,Ur=class extends Cr{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=Nr(this.buffer)}update(e){Tr(this);let{view:t,buffer:n,blockLen:o}=this;e=Ft(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=Nr(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){Tr(this),_c(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;Qd(n,o-8,BigInt(this.length*8),i),this.process(n,0);let a=Nr(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 so=BigInt(4294967295),Ss=BigInt(32);function Pc(r,e=!1){return e?{h:Number(r&so),l:Number(r>>Ss&so)}:{h:Number(r>>Ss&so)|0,l:Number(r&so)|0}}function e0(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}=Pc(r[o],e);[t[o],n[o]]=[i,s]}return[t,n]}var t0=(r,e)=>BigInt(r>>>0)<<Ss|BigInt(e>>>0),r0=(r,e,t)=>r>>>t,n0=(r,e,t)=>r<<32-t|e>>>t,o0=(r,e,t)=>r>>>t|e<<32-t,i0=(r,e,t)=>r<<32-t|e>>>t,s0=(r,e,t)=>r<<64-t|e>>>t-32,a0=(r,e,t)=>r>>>t-32|e<<64-t,c0=(r,e)=>e,u0=(r,e)=>r,l0=(r,e,t)=>r<<t|e>>>32-t,f0=(r,e,t)=>e<<t|r>>>32-t,h0=(r,e,t)=>e<<t-32|r>>>64-t,d0=(r,e,t)=>r<<t-32|e>>>64-t;function p0(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),g0=(r,e,t,n)=>e+t+n+(r/2**32|0)|0,y0=(r,e,t,n)=>(r>>>0)+(e>>>0)+(t>>>0)+(n>>>0),w0=(r,e,t,n,o)=>e+t+n+o+(r/2**32|0)|0,b0=(r,e,t,n,o)=>(r>>>0)+(e>>>0)+(t>>>0)+(n>>>0)+(o>>>0),x0=(r,e,t,n,o,i)=>e+t+n+o+i+(r/2**32|0)|0;var E0={fromBig:Pc,split:e0,toBig:t0,shrSH:r0,shrSL:n0,rotrSH:o0,rotrSL:i0,rotrBH:s0,rotrBL:a0,rotr32H:c0,rotr32L:u0,rotlSH:l0,rotlSL:f0,rotlBH:h0,rotlBL:d0,add:p0,add3L:m0,add3H:g0,add4L:y0,add4H:w0,add5H:x0,add5L:b0},q=E0;var[v0,B0]=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))),Mt=new Uint32Array(80),Ht=new Uint32Array(80),Is=class extends Ur{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){let{Ah:e,Al:t,Bh:n,Bl:o,Ch:i,Cl:s,Dh:a,Dl:c,Eh:f,El:u,Fh:l,Fl:h,Gh:w,Gl:B,Hh:m,Hl:d}=this;return[e,t,n,o,i,s,a,c,f,u,l,h,w,B,m,d]}set(e,t,n,o,i,s,a,c,f,u,l,h,w,B,m,d){this.Ah=e|0,this.Al=t|0,this.Bh=n|0,this.Bl=o|0,this.Ch=i|0,this.Cl=s|0,this.Dh=a|0,this.Dl=c|0,this.Eh=f|0,this.El=u|0,this.Fh=l|0,this.Fl=h|0,this.Gh=w|0,this.Gl=B|0,this.Hh=m|0,this.Hl=d|0}process(e,t){for(let y=0;y<16;y++,t+=4)Mt[y]=e.getUint32(t),Ht[y]=e.getUint32(t+=4);for(let y=16;y<80;y++){let k=Mt[y-15]|0,D=Ht[y-15]|0,V=q.rotrSH(k,D,1)^q.rotrSH(k,D,8)^q.shrSH(k,D,7),N=q.rotrSL(k,D,1)^q.rotrSL(k,D,8)^q.shrSL(k,D,7),b=Mt[y-2]|0,v=Ht[y-2]|0,F=q.rotrSH(b,v,19)^q.rotrBH(b,v,61)^q.shrSH(b,v,6),_=q.rotrSL(b,v,19)^q.rotrBL(b,v,61)^q.shrSL(b,v,6),C=q.add4L(N,_,Ht[y-7],Ht[y-16]),$=q.add4H(C,V,F,Mt[y-7],Mt[y-16]);Mt[y]=$|0,Ht[y]=C|0}let{Ah:n,Al:o,Bh:i,Bl:s,Ch:a,Cl:c,Dh:f,Dl:u,Eh:l,El:h,Fh:w,Fl:B,Gh:m,Gl:d,Hh:E,Hl:R}=this;for(let y=0;y<80;y++){let k=q.rotrSH(l,h,14)^q.rotrSH(l,h,18)^q.rotrBH(l,h,41),D=q.rotrSL(l,h,14)^q.rotrSL(l,h,18)^q.rotrBL(l,h,41),V=l&w^~l&m,N=h&B^~h&d,b=q.add5L(R,D,N,B0[y],Ht[y]),v=q.add5H(b,E,k,V,v0[y],Mt[y]),F=b|0,_=q.rotrSH(n,o,28)^q.rotrBH(n,o,34)^q.rotrBH(n,o,39),C=q.rotrSL(n,o,28)^q.rotrBL(n,o,34)^q.rotrBL(n,o,39),$=n&i^n&a^i&a,S=o&s^o&c^s&c;E=m|0,R=d|0,m=w|0,d=B|0,w=l|0,B=h|0,{h:l,l:h}=q.add(f|0,u|0,v|0,F|0),f=a|0,u=c|0,a=i|0,c=s|0,i=n|0,s=o|0;let I=q.add3L(F,C,S);n=q.add3H(I,v,_,$),o=I|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:h}=q.add(this.Eh|0,this.El|0,l|0,h|0),{h:w,l:B}=q.add(this.Fh|0,this.Fl|0,w|0,B|0),{h:m,l:d}=q.add(this.Gh|0,this.Gl|0,m|0,d|0),{h:E,l:R}=q.add(this.Hh|0,this.Hl|0,E|0,R|0),this.set(n,o,i,s,a,c,f,u,l,h,w,B,m,d,E,R)}roundClean(){Mt.fill(0),Ht.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 fn=io(()=>new Is);var co={};me(co,{aInRange:()=>Oe,abool:()=>et,abytes:()=>Lr,bitGet:()=>T0,bitLen:()=>Ns,bitMask:()=>dn,bitSet:()=>C0,bytesToHex:()=>bt,bytesToNumberBE:()=>xt,bytesToNumberLE:()=>$t,concatBytes:()=>Et,createHmacDrbg:()=>_s,ensureBytes:()=>se,equalBytes:()=>R0,hexToBytes:()=>sr,hexToNumber:()=>Cs,inRange:()=>hn,isBytes:()=>Kt,memoized:()=>cr,notImplemented:()=>_0,numberToBytesBE:()=>qt,numberToBytesLE:()=>ar,numberToHexUnpadded:()=>ir,numberToVarBytesBE:()=>I0,utf8ToBytes:()=>k0,validateObject:()=>lt});var Ts=BigInt(0),ao=BigInt(1),A0=BigInt(2);function Kt(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}function Lr(r){if(!Kt(r))throw new Error("Uint8Array expected")}function et(r,e){if(typeof e!="boolean")throw new Error(`${r} must be valid boolean, got "${e}".`)}var S0=Array.from({length:256},(r,e)=>e.toString(16).padStart(2,"0"));function bt(r){Lr(r);let e="";for(let t=0;t<r.length;t++)e+=S0[r[t]];return e}function ir(r){let e=r.toString(16);return e.length&1?`0${e}`:e}function Cs(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return BigInt(r===""?"0":`0x${r}`)}var wt={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function Fc(r){if(r>=wt._0&&r<=wt._9)return r-wt._0;if(r>=wt._A&&r<=wt._F)return r-(wt._A-10);if(r>=wt._a&&r<=wt._f)return r-(wt._a-10)}function sr(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=Fc(r.charCodeAt(i)),a=Fc(r.charCodeAt(i+1));if(s===void 0||a===void 0){let c=r[i]+r[i+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+i)}n[o]=s*16+a}return n}function xt(r){return Cs(bt(r))}function $t(r){return Lr(r),Cs(bt(Uint8Array.from(r).reverse()))}function qt(r,e){return sr(r.toString(16).padStart(e*2,"0"))}function ar(r,e){return qt(r,e).reverse()}function I0(r){return sr(ir(r))}function se(r,e,t){let n;if(typeof e=="string")try{n=sr(e)}catch(i){throw new Error(`${r} must be valid hex string, got "${e}". Cause: ${i}`)}else if(Kt(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 Et(...r){let e=0;for(let n=0;n<r.length;n++){let o=r[n];Lr(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 R0(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 k0(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}var Rs=r=>typeof r=="bigint"&&Ts<=r;function hn(r,e,t){return Rs(r)&&Rs(e)&&Rs(t)&&e<=r&&r<t}function Oe(r,e,t,n){if(!hn(e,t,n))throw new Error(`expected valid ${r}: ${t} <= n < ${n}, got ${typeof e} ${e}`)}function Ns(r){let e;for(e=0;r>Ts;r>>=ao,e+=1);return e}function T0(r,e){return r>>BigInt(e)&ao}function C0(r,e,t){return r|(t?ao:Ts)<<BigInt(e)}var dn=r=>(A0<<BigInt(r-1))-ao,ks=r=>new Uint8Array(r),Mc=r=>Uint8Array.from(r);function _s(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=ks(r),o=ks(r),i=0,s=()=>{n.fill(1),o.fill(0),i=0},a=(...l)=>t(o,n,...l),c=(l=ks())=>{o=a(Mc([0]),l),n=a(),l.length!==0&&(o=a(Mc([1]),l),n=a())},f=()=>{if(i++>=1e3)throw new Error("drbg: tried 1000 values");let l=0,h=[];for(;l<e;){n=a();let w=n.slice();h.push(w),l+=n.length}return Et(...h)};return(l,h)=>{s(),c(l);let w;for(;!(w=h(f()));)c();return s(),w}}var N0={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"||Kt(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 lt(r,e,t={}){let n=(o,i,s)=>{let a=N0[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 _0=()=>{throw new Error("not implemented")};function cr(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 he=BigInt(0),ne=BigInt(1),ur=BigInt(2),U0=BigInt(3),Us=BigInt(4),Hc=BigInt(5),Kc=BigInt(8),L0=BigInt(9),V0=BigInt(16);function ee(r,e){let t=r%e;return t>=he?t:e+t}function O0(r,e,t){if(t<=he||e<he)throw new Error("Expected power/modulo > 0");if(t===ne)return he;let n=ne;for(;e>he;)e&ne&&(n=n*r%t),r=r*r%t,e>>=ne;return n}function oe(r,e,t){let n=r;for(;e-- >he;)n*=n,n%=t;return n}function uo(r,e){if(r===he||e<=he)throw new Error(`invert: expected positive integers, got n=${r} mod=${e}`);let t=ee(r,e),n=e,o=he,i=ne,s=ne,a=he;for(;t!==he;){let f=n/t,u=n%t,l=o-s*f,h=i-a*f;n=t,t=u,o=s,i=a,s=l,a=h}if(n!==ne)throw new Error("invert: does not exist");return ee(o,e)}function D0(r){let e=(r-ne)/ur,t,n,o;for(t=r-ne,n=0;t%ur===he;t/=ur,n++);for(o=ur;o<r&&O0(o,e,r)!==r-ne;o++);if(n===1){let s=(r+ne)/Us;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+ne)/ur;return function(a,c){if(a.pow(c,e)===a.neg(a.ONE))throw new Error("Cannot find square root");let f=n,u=a.pow(a.mul(a.ONE,o),t),l=a.pow(c,i),h=a.pow(c,t);for(;!a.eql(h,a.ONE);){if(a.eql(h,a.ZERO))return a.ZERO;let w=1;for(let m=a.sqr(h);w<f&&!a.eql(m,a.ONE);w++)m=a.sqr(m);let B=a.pow(u,ne<<BigInt(f-w-1));u=a.sqr(B),l=a.mul(l,B),h=a.mul(h,u),f=w}return l}}function P0(r){if(r%Us===U0){let e=(r+ne)/Us;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%Kc===Hc){let e=(r-Hc)/Kc;return function(n,o){let i=n.mul(o,ur),s=n.pow(i,e),a=n.mul(o,s),c=n.mul(n.mul(a,ur),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%V0,D0(r)}var $c=(r,e)=>(ee(r,e)&ne)===ne,F0=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Ls(r){let e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},t=F0.reduce((n,o)=>(n[o]="function",n),e);return lt(r,t)}function M0(r,e,t){if(t<he)throw new Error("Expected power > 0");if(t===he)return r.ONE;if(t===ne)return e;let n=r.ONE,o=e;for(;t>he;)t&ne&&(n=r.mul(n,o)),o=r.sqr(o),t>>=ne;return n}function H0(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 zt(r,e,t=!1,n={}){if(r<=he)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=P0(r),a=Object.freeze({ORDER:r,BITS:o,BYTES:i,MASK:dn(o),ZERO:he,ONE:ne,create:c=>ee(c,r),isValid:c=>{if(typeof c!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof c}`);return he<=c&&c<r},is0:c=>c===he,isOdd:c=>(c&ne)===ne,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)=>M0(a,c,f),div:(c,f)=>ee(c*uo(f,r),r),sqrN:c=>c*c,addN:(c,f)=>c+f,subN:(c,f)=>c-f,mulN:(c,f)=>c*f,inv:c=>uo(c,r),sqrt:n.sqrt||(c=>s(a,c)),invertBatch:c=>H0(a,c),cmov:(c,f,u)=>u?f:c,toBytes:c=>t?ar(c,i):qt(c,i),fromBytes:c=>{if(c.length!==i)throw new Error(`Fp.fromBytes: expected ${i}, got ${c.length}`);return t?$t(c):xt(c)}});return Object.freeze(a)}function qc(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=qc(r);return e+Math.ceil(e/2)}function zc(r,e,t=!1){let n=r.length,o=qc(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?xt(r):$t(r),a=ee(s,e-ne)+ne;return t?ar(a,o):qt(a,o)}var $0=BigInt(0),Ds=BigInt(1),Ps=new WeakMap,Gc=new WeakMap;function lo(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>$0;)s&Ds&&(a=a.add(c)),c=c.double(),s>>=Ds;return a},precomputeWindow(i,s){let{windows:a,windowSize:c}=o(s),f=[],u=i,l=u;for(let h=0;h<a;h++){l=u,f.push(l);for(let w=1;w<c;w++)l=l.add(u),f.push(l);u=l.double()}return f},wNAF(i,s,a){let{windows:c,windowSize:f}=o(i),u=r.ZERO,l=r.BASE,h=BigInt(2**i-1),w=2**i,B=BigInt(i);for(let m=0;m<c;m++){let d=m*f,E=Number(a&h);a>>=B,E>f&&(E-=w,a+=Ds);let R=d,y=d+Math.abs(E)-1,k=m%2!==0,D=E<0;E===0?l=l.add(t(k,s[R])):u=u.add(t(D,s[y]))}return{p:u,f:l}},wNAFCached(i,s,a){let c=Gc.get(i)||1,f=Ps.get(i);return f||(f=this.precomputeWindow(i,c),c!==1&&Ps.set(i,a(f))),this.wNAF(c,f,s)},setWindowSize(i,s){n(s),Gc.set(i,s),Ps.delete(i)}}}function fo(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=Ns(BigInt(t.length)),i=o>12?o-3:o>4?o-2:o?2:1,s=(1<<i)-1,a=new Array(s+1).fill(r.ZERO),c=Math.floor((e.BITS-1)/i)*i,f=r.ZERO;for(let u=c;u>=0;u-=i){a.fill(r.ZERO);for(let h=0;h<n.length;h++){let w=n[h],B=Number(w>>BigInt(u)&BigInt(s));a[B]=a[B].add(t[h])}let l=r.ZERO;for(let h=a.length-1,w=r.ZERO;h>0;h--)w=w.add(a[h]),l=l.add(w);if(f=f.add(l),u!==0)for(let h=0;h<i;h++)f=f.double()}return f}function pn(r){return Ls(r.Fp),lt(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 tt=BigInt(0),De=BigInt(1),ho=BigInt(2),q0=BigInt(8),z0={zip215:!0};function G0(r){let e=pn(r);return lt(r,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...e})}function jc(r){let e=G0(r),{Fp:t,n,prehash:o,hash:i,randomBytes:s,nByteLength:a,h:c}=e,f=ho<<BigInt(a*8)-De,u=t.create,l=zt(e.n,e.nBitLength),h=e.uvRatio||((g,p)=>{try{return{isValid:!0,value:t.sqrt(g*t.inv(p))}}catch{return{isValid:!1,value:tt}}}),w=e.adjustScalarBytes||(g=>g),B=e.domain||((g,p,A)=>{if(et("phflag",A),p.length||A)throw new Error("Contexts/pre-hash are not supported");return g});function m(g,p){Oe("coordinate "+g,p,tt,f)}function d(g){if(!(g instanceof y))throw new Error("ExtendedPoint expected")}let E=cr((g,p)=>{let{ex:A,ey:O,ez:M}=g,H=g.is0();p==null&&(p=H?q0:t.inv(M));let G=u(A*p),W=u(O*p),j=u(M*p);if(H)return{x:tt,y:De};if(j!==De)throw new Error("invZ was invalid");return{x:G,y:W}}),R=cr(g=>{let{a:p,d:A}=e;if(g.is0())throw new Error("bad point: ZERO");let{ex:O,ey:M,ez:H,et:G}=g,W=u(O*O),j=u(M*M),Q=u(H*H),re=u(Q*Q),de=u(W*p),pe=u(Q*u(de+j)),be=u(re+u(A*u(W*j)));if(pe!==be)throw new Error("bad point: equation left != right (1)");let ke=u(O*M),fe=u(H*G);if(ke!==fe)throw new Error("bad point: equation left != right (2)");return!0});class y{constructor(p,A,O,M){this.ex=p,this.ey=A,this.ez=O,this.et=M,m("x",p),m("y",A),m("z",O),m("t",M),Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(p){if(p instanceof y)throw new Error("extended point not allowed");let{x:A,y:O}=p||{};return m("x",A),m("y",O),new y(A,O,De,u(A*O))}static normalizeZ(p){let A=t.invertBatch(p.map(O=>O.ez));return p.map((O,M)=>O.toAffine(A[M])).map(y.fromAffine)}static msm(p,A){return fo(y,l,p,A)}_setWindowSize(p){V.setWindowSize(this,p)}assertValidity(){R(this)}equals(p){d(p);let{ex:A,ey:O,ez:M}=this,{ex:H,ey:G,ez:W}=p,j=u(A*W),Q=u(H*M),re=u(O*W),de=u(G*M);return j===Q&&re===de}is0(){return this.equals(y.ZERO)}negate(){return new y(u(-this.ex),this.ey,this.ez,u(-this.et))}double(){let{a:p}=e,{ex:A,ey:O,ez:M}=this,H=u(A*A),G=u(O*O),W=u(ho*u(M*M)),j=u(p*H),Q=A+O,re=u(u(Q*Q)-H-G),de=j+G,pe=de-W,be=j-G,ke=u(re*pe),fe=u(de*be),Le=u(re*be),gt=u(pe*de);return new y(ke,fe,gt,Le)}add(p){d(p);let{a:A,d:O}=e,{ex:M,ey:H,ez:G,et:W}=this,{ex:j,ey:Q,ez:re,et:de}=p;if(A===BigInt(-1)){let Ua=u((H-M)*(Q+j)),La=u((H+M)*(Q-j)),Ti=u(La-Ua);if(Ti===tt)return this.double();let Va=u(G*ho*de),Oa=u(W*ho*re),Da=Oa+Va,Pa=La+Ua,Fa=Oa-Va,Jf=u(Da*Ti),Xf=u(Pa*Fa),Qf=u(Da*Fa),eh=u(Ti*Pa);return new y(Jf,Xf,eh,Qf)}let pe=u(M*j),be=u(H*Q),ke=u(W*O*de),fe=u(G*re),Le=u((M+H)*(j+Q)-pe-be),gt=fe-ke,en=fe+ke,tn=u(be-A*pe),jf=u(Le*gt),Yf=u(en*tn),Zf=u(Le*tn),Wf=u(gt*en);return new y(jf,Yf,Wf,Zf)}subtract(p){return this.add(p.negate())}wNAF(p){return V.wNAFCached(this,p,y.normalizeZ)}multiply(p){let A=p;Oe("scalar",A,De,n);let{p:O,f:M}=this.wNAF(A);return y.normalizeZ([O,M])[0]}multiplyUnsafe(p){let A=p;return Oe("scalar",A,tt,n),A===tt?D:this.equals(D)||A===De?this:this.equals(k)?this.wNAF(A).p:V.unsafeLadder(this,A)}isSmallOrder(){return this.multiplyUnsafe(c).is0()}isTorsionFree(){return V.unsafeLadder(this,n).is0()}toAffine(p){return E(this,p)}clearCofactor(){let{h:p}=e;return p===De?this:this.multiplyUnsafe(p)}static fromHex(p,A=!1){let{d:O,a:M}=e,H=t.BYTES;p=se("pointHex",p,H),et("zip215",A);let G=p.slice(),W=p[H-1];G[H-1]=W&-129;let j=$t(G),Q=A?f:t.ORDER;Oe("pointHex.y",j,tt,Q);let re=u(j*j),de=u(re-De),pe=u(O*re-M),{isValid:be,value:ke}=h(de,pe);if(!be)throw new Error("Point.fromHex: invalid y coordinate");let fe=(ke&De)===De,Le=(W&128)!==0;if(!A&&ke===tt&&Le)throw new Error("Point.fromHex: x=0 and x_0=1");return Le!==fe&&(ke=u(-ke)),y.fromAffine({x:ke,y:j})}static fromPrivateKey(p){return v(p).point}toRawBytes(){let{x:p,y:A}=this.toAffine(),O=ar(A,t.BYTES);return O[O.length-1]|=p&De?128:0,O}toHex(){return bt(this.toRawBytes())}}y.BASE=new y(e.Gx,e.Gy,De,u(e.Gx*e.Gy)),y.ZERO=new y(tt,De,De,tt);let{BASE:k,ZERO:D}=y,V=lo(y,a*8);function N(g){return ee(g,n)}function b(g){return N($t(g))}function v(g){let p=a;g=se("private key",g,p);let A=se("hashed private key",i(g),2*p),O=w(A.slice(0,p)),M=A.slice(p,2*p),H=b(O),G=k.multiply(H),W=G.toRawBytes();return{head:O,prefix:M,scalar:H,point:G,pointBytes:W}}function F(g){return v(g).pointBytes}function _(g=new Uint8Array,...p){let A=Et(...p);return b(i(B(A,se("context",g),!!o)))}function C(g,p,A={}){g=se("message",g),o&&(g=o(g));let{prefix:O,scalar:M,pointBytes:H}=v(p),G=_(A.context,O,g),W=k.multiply(G).toRawBytes(),j=_(A.context,W,H,g),Q=N(G+j*M);Oe("signature.s",Q,tt,n);let re=Et(W,ar(Q,t.BYTES));return se("result",re,a*2)}let $=z0;function S(g,p,A,O=$){let{context:M,zip215:H}=O,G=t.BYTES;g=se("signature",g,2*G),p=se("message",p),H!==void 0&&et("zip215",H),o&&(p=o(p));let W=$t(g.slice(G,2*G)),j,Q,re;try{j=y.fromHex(A,H),Q=y.fromHex(g.slice(0,G),H),re=k.multiplyUnsafe(W)}catch{return!1}if(!H&&j.isSmallOrder())return!1;let de=_(M,Q.toRawBytes(),j.toRawBytes(),p);return Q.add(j.multiplyUnsafe(de)).subtract(re).clearCofactor().equals(y.ZERO)}return k._setWindowSize(8),{CURVE:e,getPublicKey:F,sign:C,verify:S,ExtendedPoint:y,utils:{getExtendedPublicKey:v,randomPrivateKey:()=>s(t.BYTES),precompute(g=8,p=y.BASE){return p._setWindowSize(g),p.multiply(BigInt(3)),p}}}}var Fs=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),Yc=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),Bb=BigInt(0),j0=BigInt(1),Zc=BigInt(2),Ab=BigInt(3),Y0=BigInt(5),Z0=BigInt(8);function W0(r){let e=BigInt(10),t=BigInt(20),n=BigInt(40),o=BigInt(80),i=Fs,a=r*r%i*r%i,c=oe(a,Zc,i)*a%i,f=oe(c,j0,i)*r%i,u=oe(f,Y0,i)*f%i,l=oe(u,e,i)*u%i,h=oe(l,t,i)*l%i,w=oe(h,n,i)*h%i,B=oe(w,o,i)*w%i,m=oe(B,o,i)*w%i,d=oe(m,e,i)*u%i;return{pow_p_5_8:oe(d,Zc,i)*r%i,b2:a}}function J0(r){return r[0]&=248,r[31]&=127,r[31]|=64,r}function X0(r,e){let t=Fs,n=ee(e*e*e,t),o=ee(n*n*e,t),i=W0(r*o).pow_p_5_8,s=ee(r*n*i,t),a=ee(e*s*s,t),c=s,f=ee(s*Yc,t),u=a===r,l=a===ee(-r,t),h=a===ee(-r*Yc,t);return u&&(s=c),(l||h)&&(s=f),$c(s,t)&&(s=ee(-s,t)),{isValid:u||l,value:s}}var Q0=zt(Fs,void 0,!0),ep={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:Q0,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:Z0,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:fn,randomBytes:_r,adjustScalarBytes:J0,uvRatio:X0},Vr=jc(ep);var Or=32,vt=64,po=32;function Wc(){let r=Vr.utils.randomPrivateKey(),e=Vr.getPublicKey(r);return{privateKey:eu(r,e),publicKey:e}}function Jc(r){if(r.length!==po)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=Vr.getPublicKey(e);return{privateKey:eu(e,t),publicKey:t}}function Xc(r,e){let t=r.subarray(0,po);return Vr.sign(e instanceof Uint8Array?e:e.subarray(),t)}function Qc(r,e,t){return Vr.verify(e,t instanceof Uint8Array?t:t.subarray(),r)}function eu(r,e){let t=new Uint8Array(vt);for(let n=0;n<po;n++)t[n]=r[n],t[po+n]=e[n];return t}var Ce={get(r=globalThis){let e=r.crypto;if(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 tu(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=Ce.get();t*=8;async function c(l,h){let w=a.getRandomValues(new Uint8Array(i)),B=a.getRandomValues(new Uint8Array(n)),m={name:e,iv:B};typeof h=="string"&&(h=Y(h));let d;if(h.length===0){d=await a.subtle.importKey("jwk",Ms,{name:"AES-GCM"},!0,["encrypt"]);try{let R={name:"PBKDF2",salt:w,iterations:s,hash:{name:o}},y=await a.subtle.importKey("raw",h,{name:"PBKDF2"},!1,["deriveKey"]);d=await a.subtle.deriveKey(R,y,{name:e,length:t},!0,["encrypt"])}catch{d=await a.subtle.importKey("jwk",Ms,{name:"AES-GCM"},!0,["encrypt"])}}else{let R={name:"PBKDF2",salt:w,iterations:s,hash:{name:o}},y=await a.subtle.importKey("raw",h,{name:"PBKDF2"},!1,["deriveKey"]);d=await a.subtle.deriveKey(R,y,{name:e,length:t},!0,["encrypt"])}let E=await a.subtle.encrypt(m,d,l);return Te([w,m.iv,new Uint8Array(E)])}async function f(l,h){let w=l.subarray(0,i),B=l.subarray(i,i+n),m=l.subarray(i+n),d={name:e,iv:B};typeof h=="string"&&(h=Y(h));let E;if(h.length===0)try{let y={name:"PBKDF2",salt:w,iterations:s,hash:{name:o}},k=await a.subtle.importKey("raw",h,{name:"PBKDF2"},!1,["deriveKey"]);E=await a.subtle.deriveKey(y,k,{name:e,length:t},!0,["decrypt"])}catch{E=await a.subtle.importKey("jwk",Ms,{name:"AES-GCM"},!0,["decrypt"])}else{let y={name:"PBKDF2",salt:w,iterations:s,hash:{name:o}},k=await a.subtle.importKey("raw",h,{name:"PBKDF2"},!1,["deriveKey"]);E=await a.subtle.deriveKey(y,k,{name:e,length:t},!0,["decrypt"])}let R=await a.subtle.decrypt(d,E,m);return new Uint8Array(R)}return{encrypt:c,decrypt:f}}async function Dr(r,e){let n=await tu().encrypt(r,e);return rn.encode(n)}var Hs=new Float32Array([-0]),Gt=new Uint8Array(Hs.buffer);function ru(r,e,t){Hs[0]=r,e[t]=Gt[0],e[t+1]=Gt[1],e[t+2]=Gt[2],e[t+3]=Gt[3]}function nu(r,e){return Gt[0]=r[e],Gt[1]=r[e+1],Gt[2]=r[e+2],Gt[3]=r[e+3],Hs[0]}var Ks=new Float64Array([-0]),Se=new Uint8Array(Ks.buffer);function ou(r,e,t){Ks[0]=r,e[t]=Se[0],e[t+1]=Se[1],e[t+2]=Se[2],e[t+3]=Se[3],e[t+4]=Se[4],e[t+5]=Se[5],e[t+6]=Se[6],e[t+7]=Se[7]}function iu(r,e){return Se[0]=r[e],Se[1]=r[e+1],Se[2]=r[e+2],Se[3]=r[e+3],Se[4]=r[e+4],Se[5]=r[e+5],Se[6]=r[e+6],Se[7]=r[e+7],Ks[0]}var np=BigInt(Number.MAX_SAFE_INTEGER),op=BigInt(Number.MIN_SAFE_INTEGER),Me=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 lr;if(e<np&&e>op)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>su&&(o=0n,++n>su&&(n=0n))),new r(Number(o),Number(n))}static fromNumber(e){if(e===0)return lr;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):lr}},lr=new Me(0,0);lr.toBigInt=function(){return 0n};lr.zzEncode=lr.zzDecode=function(){return this};lr.length=function(){return 1};var su=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 cu(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 $s(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 rt(r,e){return RangeError(`index out of range: ${r.pos} + ${e??1} > ${r.len}`)}function mo(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,rt(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 rt(this,4);return mo(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw rt(this,4);return mo(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw rt(this,4);let e=nu(this.buf,this.pos);return this.pos+=4,e}double(){if(this.pos+8>this.len)throw rt(this,4);let e=iu(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 rt(this,e);return this.pos+=e,t===n?new Uint8Array(0):this.buf.subarray(t,n)}string(){let e=this.bytes();return cu(e,0,e.length)}skip(e){if(typeof e=="number"){if(this.pos+e>this.len)throw rt(this,e);this.pos+=e}else do if(this.pos>=this.len)throw rt(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 Me(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 rt(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 rt(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 rt(this,8);let e=mo(this.buf,this.pos+=4),t=mo(this.buf,this.pos+=4);return new Me(e,t)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){let e=cs(this.buf,this.pos);return this.pos+=Ve(e),e}uint64String(){return this.readLongVarint().toString(!0)}sint64(){return this.readLongVarint().zzDecode().toBigInt()}sint64Number(){return this.readLongVarint().zzDecode().toNumber()}sint64String(){return this.readLongVarint().zzDecode().toString()}fixed64(){return this.readFixed64().toBigInt()}fixed64Number(){return this.readFixed64().toNumber()}fixed64String(){return this.readFixed64().toString()}sfixed64(){return this.readFixed64().toBigInt()}sfixed64Number(){return this.readFixed64().toNumber()}sfixed64String(){return this.readFixed64().toString()}};function zs(r){return new qs(r instanceof Uint8Array?r:r.subarray())}function Pr(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 Xe(s);o+s>e&&(n=Xe(e),o=0);let a=n.subarray(o,o+=s);return o&7&&(o=(o|7)+1),a}}var fr=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}},ip=Gs();function sp(r){return globalThis.Buffer!=null?Xe(r):ip(r)}var gn=class{len;head;tail;states;constructor(){this.len=0,this.head=new fr(js,0,0),this.tail=this.head,this.states=null}_push(e,t,n){return this.tail=this.tail.next=new fr(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(go,10,Me.fromNumber(e)):this.uint32(e)}sint32(e){return this.uint32((e<<1^e>>31)>>>0)}uint64(e){let t=Me.fromBigInt(e);return this._push(go,t.length(),t)}uint64Number(e){return this._push(as,Ve(e),e)}uint64String(e){return this.uint64(BigInt(e))}int64(e){return this.uint64(e)}int64Number(e){return this.uint64Number(e)}int64String(e){return this.uint64String(e)}sint64(e){let t=Me.fromBigInt(e).zzEncode();return this._push(go,t.length(),t)}sint64Number(e){let t=Me.fromNumber(e).zzEncode();return this._push(go,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(mn,4,e>>>0)}sfixed32(e){return this.fixed32(e)}fixed64(e){let t=Me.fromBigInt(e);return this._push(mn,4,t.lo)._push(mn,4,t.hi)}fixed64Number(e){let t=Me.fromNumber(e);return this._push(mn,4,t.lo)._push(mn,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(ru,4,e)}double(e){return this._push(ou,8,e)}bytes(e){let t=e.length>>>0;return t===0?this._push(Ys,1,0):this.uint32(t)._push(cp,t,e)}string(e){let t=au(e);return t!==0?this.uint32(t)._push($s,t,e):this._push(Ys,1,0)}fork(){return this.states=new Zs(this),this.head=this.tail=new fr(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 fr(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=sp(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 ap(r,e,t){for(;r>127;)e[t++]=r&127|128,r>>>=7;e[t]=r}var Ws=class extends fr{next;constructor(e,t){super(ap,e,t),this.next=void 0}};function go(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 mn(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 cp(r,e,t){e.set(r,t)}globalThis.Buffer!=null&&(gn.prototype.bytes=function(r){let e=r.length>>>0;return this.uint32(e),e>0&&this._push(up,e,r),this},gn.prototype.string=function(r){let e=globalThis.Buffer.byteLength(r);return this.uint32(e),e>0&&this._push(lp,e,r),this});function up(r,e,t){e.set(r,t)}function lp(r,e,t){r.length<40?$s(r,e,t):e.utf8Write!=null?e.utf8Write(r,t):e.set(Y(r),t)}function Js(){return new gn}function Fr(r,e){let t=Js();return e.encode(r,t,{lengthDelimited:!1}),t.finish()}var Mr;(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"})(Mr||(Mr={}));function yo(r,e,t,n){return{name:r,type:e,encode:t,decode:n}}function yn(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 yo("enum",Mr.VARINT,t,n)}function Hr(r,e){return yo("message",Mr.LENGTH_DELIMITED,r,e)}var ce;(function(r){r.RSA="RSA",r.Ed25519="Ed25519",r.Secp256k1="Secp256k1"})(ce||(ce={}));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=()=>yn(Xs)})(ce||(ce={}));var ft;(function(r){let e;r.codec=()=>(e==null&&(e=Hr((t,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),t.Type!=null&&(n.uint32(8),ce.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=ce.codec().decode(t);break;case 2:o.Data=t.bytes();break;default:t.skipType(s&7);break}}return o})),e),r.encode=t=>Fr(t,r.codec()),r.decode=t=>Pr(t,r.codec())})(ft||(ft={}));var Bt;(function(r){let e;r.codec=()=>(e==null&&(e=Hr((t,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),t.Type!=null&&(n.uint32(8),ce.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=ce.codec().decode(t);break;case 2:o.Data=t.bytes();break;default:t.skipType(s&7);break}}return o})),e),r.encode=t=>Fr(t,r.codec()),r.decode=t=>Pr(t,r.codec())})(Bt||(Bt={}));var wn=class{_key;constructor(e){this._key=Kr(e,Or)}verify(e,t){return Qc(this._key,t,e)}marshal(){return this._key}get bytes(){return ft.encode({Type:ce.Ed25519,Data:this.marshal()}).subarray()}equals(e){return ue(this.bytes,e.bytes)}hash(){let e=xe.digest(this.bytes);return Ge(e)?e.then(({bytes:t})=>t):e.bytes}},hr=class{_key;_publicKey;constructor(e,t){this._key=Kr(e,vt),this._publicKey=Kr(t,Or)}sign(e){return Xc(this._key,e)}get public(){return new wn(this._publicKey)}marshal(){return this._key}get bytes(){return Bt.encode({Type:ce.Ed25519,Data:this.marshal()}).subarray()}equals(e){return ue(this.bytes,e.bytes)}async hash(){let e=xe.digest(this.bytes),t;return Ge(e)?{bytes:t}=await e:t=e.bytes,t}async id(){let e=Je.digest(this.public.bytes);return ae.encode(e.bytes).substring(1)}async export(e,t="libp2p-key"){if(t==="libp2p-key")return Dr(this.bytes,e);throw new P(`export format '${t}' is not supported`,"ERR_INVALID_EXPORT_FORMAT")}};function fp(r){if(r.length>vt){r=Kr(r,vt+Or);let n=r.subarray(0,vt),o=r.subarray(vt,r.length);return new hr(n,o)}r=Kr(r,vt);let e=r.subarray(0,vt),t=r.subarray(Or);return new hr(e,t)}function hp(r){return r=Kr(r,Or),new wn(r)}async function dp(){let{privateKey:r,publicKey:e}=Wc();return new hr(r,e)}async function lu(r){let{privateKey:e,publicKey:t}=Jc(r);return new hr(e,t)}function Kr(r,e){if(r=Uint8Array.from(r??[]),r.length!==e)throw new P(`Key must be a Uint8Array of length ${e}, got ${r.length}`,"ERR_INVALID_KEY_TYPE");return r}var ua={};me(ua,{MAX_RSA_KEY_SIZE:()=>Cn,RsaPrivateKey:()=>jr,RsaPublicKey:()=>Tn,fromJwk:()=>Mp,generateKeyPair:()=>Hp,unmarshalRsaPrivateKey:()=>aa,unmarshalRsaPublicKey:()=>Fp});function dr(r){if(isNaN(r)||r<=0)throw new P("random bytes length must be a Number bigger than 0","ERR_INVALID_LENGTH");return _r(r)}var Wt={};me(Wt,{exportToPem:()=>Lp,importFromPem:()=>Vp,jwkToPkcs1:()=>Cp,jwkToPkix:()=>_p,pkcs1ToJwk:()=>Tp,pkixToJwk:()=>Np});var bo=class extends Cr{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,oo(e);let n=Ft(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 Tr(this),this.iHash.update(e),this}digestInto(e){Tr(this),kr(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()}},bn=(r,e,t)=>new bo(r,e).update(t).digest();bn.create=(r,e)=>new bo(r,e);function pp(r,e,t,n){oo(r);let o=Vc({dkLen:32,asyncTick:10},n),{c:i,dkLen:s,asyncTick:a}=o;if(Rr(i),Rr(s),Rr(a),i<1)throw new Error("PBKDF2: iterations (c) should be >= 1");let c=Ft(e),f=Ft(t),u=new Uint8Array(s),l=bn.create(r,c),h=l._cloneInto().update(f);return{c:i,dkLen:s,asyncTick:a,DK:u,PRF:l,PRFSalt:h}}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}=pp(r,e,t,n),u,l=new Uint8Array(4),h=Nr(l),w=new Uint8Array(c.outputLen);for(let B=1,m=0;m<i;B++,m+=c.outputLen){let d=a.subarray(m,m+c.outputLen);h.setInt32(0,B,!1),(u=f._cloneInto(u)).update(l).digestInto(w),d.set(w.subarray(0,d.length)),await Uc(o-1,s,()=>{c._cloneInto(u).update(w).digestInto(w);for(let E=0;E<d.length;E++)d[E]^=w[E]})}return mp(c,f,a,u,w)}var Z=rr(fu());function pr(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 jt(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 vo(...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=pr(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,pr(i,8)-n}function hu(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=jt(s,8,n),c=new Uint8Array(a);return c[0]|=128,a}let o=jt(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 du(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 Pe(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 Tx=Math.log(2);function Bo(){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 kt(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 En=class{constructor(){this.items=[]}write(e){this.items.push(e)}final(){return na(this.items)}},xn=[new Uint8Array([1])],pu="0123456789";var zr="",ot=new ArrayBuffer(0),oa=new Uint8Array(0),vn="EndOfContent",gu="OCTET STRING",yu="BIT STRING";function Tt(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(!kt(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",ot)}toJSON(){return{...super.toJSON(),isHexOnly:this.isHexOnly,valueHex:Z.Convert.ToHex(this.valueHexView)}}},e.NAME="hexBlock",e}var St=class{constructor({blockLength:e=0,error:t=zr,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)}}};St.NAME="baseBlock";var Ie=class extends St{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'")}};Ie.NAME="valueBlock";var Ao=class extends Tt(St){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",ot}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=jt(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(!kt(this,o,t,n))return-1;let i=o.subarray(t,t+n);if(i.length===0)return this.error="Zero buffer length",-1;switch(i[0]&192){case 0:this.tagClass=1;break;case 64:this.tagClass=2;break;case 128:this.tagClass=3;break;case 192:this.tagClass=4;break;default:return this.error="Unknown tag class",-1}this.isConstructed=(i[0]&32)===32,this.isHexOnly=!1;let a=i[0]&31;if(a!==31)this.tagNumber=a,this.blockLength=1;else{let c=1,f=this.valueHexView=new Uint8Array(255),u=255;for(;i[c]&128;){if(f[c-1]=i[c]&127,c++,c>=i.length)return this.error="End of input reached before message was fully decoded",-1;if(c===u){u+=255;let h=new Uint8Array(u);for(let w=0;w<f.length;w++)h[w]=f[w];f=this.valueHexView=new Uint8Array(u)}}this.blockLength=c+1,f[c-1]=i[c]&127;let l=new Uint8Array(c);for(let h=0;h<c;h++)l[h]=f[h];f=this.valueHexView=new Uint8Array(c),f.set(l),this.blockLength<=9?this.tagNumber=pr(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}}};Ao.NAME="identificationBlock";var So=class extends St{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(!kt(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=pr(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=jt(this.length,8);if(o.byteLength>127)return this.error="Too big length",ot;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}}};So.NAME="lengthBlock";var U={},Ee=class extends St{constructor({name:e=zr,optional:t=!1,primitiveSchema:n,...o}={},i){super(o),this.name=e,this.optional=t,n&&(this.primitiveSchema=n),this.idBlock=new Ao(o),this.lenBlock=new So(o),this.valueBlock=i?new i(o):new Ie(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 En;t||wu(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?ot: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 du(t,n)}};Ee.NAME="BaseBlock";function wu(r){if(r instanceof U.Constructed)for(let e of r.valueBlock.value)wu(e)&&(r.lenBlock.isIndefiniteForm=!0);return!!r.lenBlock.isIndefiniteForm}var Io=class extends Ee{constructor({value:e=zr,...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}'`}};Io.NAME="BaseStringBlock";var Ro=class extends Tt(Ie){constructor({isHexOnly:e=!0,...t}={}){super(t),this.isHexOnly=e}};Ro.NAME="PrimitiveValueBlock";var bu,ko=class extends Ee{constructor(e={}){super(e,Ro),this.idBlock.isConstructed=!1}};bu=ko;U.Primitive=bu;ko.NAME="PRIMITIVE";function Ap(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 ai(r,e=0,t=r.length){let n=e,o=new Ee({},Ie),i=new St;if(!kt(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=Ee;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=U.EndOfContent;break;case 1:c=U.Boolean;break;case 2:c=U.Integer;break;case 3:c=U.BitString;break;case 4:c=U.OctetString;break;case 5:c=U.Null;break;case 6:c=U.ObjectIdentifier;break;case 10:c=U.Enumerated;break;case 12:c=U.Utf8String;break;case 13:c=U.RelativeObjectIdentifier;break;case 14:c=U.TIME;break;case 15:return o.error="[UNIVERSAL 15] is reserved by ASN.1 standard",{offset:-1,result:o};case 16:c=U.Sequence;break;case 17:c=U.Set;break;case 18:c=U.NumericString;break;case 19:c=U.PrintableString;break;case 20:c=U.TeletexString;break;case 21:c=U.VideotexString;break;case 22:c=U.IA5String;break;case 23:c=U.UTCTime;break;case 24:c=U.GeneralizedTime;break;case 25:c=U.GraphicString;break;case 26:c=U.VisibleString;break;case 27:c=U.GeneralString;break;case 28:c=U.UniversalString;break;case 29:c=U.CharacterString;break;case 30:c=U.BmpString;break;case 31:c=U.DATE;break;case 32:c=U.TimeOfDay;break;case 33:c=U.DateTime;break;case 34:c=U.Duration;break;default:{let f=o.idBlock.isConstructed?new U.Constructed:new U.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?U.Constructed:U.Primitive}return o=Ap(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 Gr(r){if(!r.byteLength){let e=new Ee({},Ie);return e.error="Input buffer has zero length",{offset:-1,result:e}}return ai(Z.BufferSourceConverter.toUint8Array(r).slice(),0,r.byteLength)}function Sp(r,e){return r?1:e}var ht=class extends Ie{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(!kt(this,o,t,n))return-1;if(this.valueBeforeDecodeView=o.subarray(t,t+n),this.valueBeforeDecodeView.length===0)return this.warnings.push("Zero buffer length"),t;let i=t;for(;Sp(this.isIndefiniteForm,n)>0;){let s=ai(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===vn)break}return this.isIndefiniteForm&&(this.value[this.value.length-1].constructor.NAME===vn?this.value.pop():this.warnings.push("No EndOfContent block encoded")),i}toBER(e,t){let n=t||new En;for(let o=0;o<this.value.length;o++)this.value[o].toBER(e,n);return t?ot:n.final()}toJSON(){let e={...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,value:[]};for(let t of this.value)e.value.push(t.toJSON());return e}};ht.NAME="ConstructedValueBlock";var xu,Yt=class extends Ee{constructor(e={}){super(e,ht),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} :`}};vu=Yt;_.Constructed=vu;Yt.NAME="CONSTRUCTED";var Co=class extends ke{fromBER(e,t,n){return t}toBER(e){return nt}};Co.override="EndOfContentValueBlock";var Bu,No=class extends ve{constructor(e={}){super(e,Co),this.idBlock.tagClass=1,this.idBlock.tagNumber=0}};Bu=No;_.EndOfContent=Bu;No.NAME=Bn;var Au,Zt=class extends ve{constructor(e={}){super(e,ke),this.idBlock.tagClass=1,this.idBlock.tagNumber=5}fromBER(e,t,n){return this.lenBlock.length>0&&this.warnings.push("Non-zero length of value block for Null type"),this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.blockLength+=n,t+n>e.byteLength?(this.error="End of input reached before message was fully decoded (inconsistent offset and length values)",-1):t+n}toBER(e,t){let n=new ArrayBuffer(2);if(!e){let o=new Uint8Array(n);o[0]=5,o[1]=0}return t&&t.write(n),n}onAsciiEncoding(){return`${this.constructor.NAME}`}};Au=Zt;_.Null=Au;Zt.NAME="NULL";var _o=class extends Ct(ke){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 Tt(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,Ws.call(this),this.blockLength=n,t+n):-1}toBER(){return this.valueHexView.slice()}toJSON(){return{...super.toJSON(),value:this.value}}};_o.NAME="BooleanValueBlock";var Su,Uo=class extends ve{constructor(e={}){super(e,_o),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}`}};Su=Uo;_.Boolean=Su;Uo.NAME="BOOLEAN";var Lo=class extends Ct(ht){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=ht.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===Bn){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, OCTET STRING may consists of OCTET STRINGs only",-1}if(s!==wu)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?ht.prototype.toBER.call(this,e,t):e?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),isConstructed:this.isConstructed}}};Lo.NAME="OctetStringValueBlock";var Iu,kt=class r extends ve{constructor({idBlock:e={},lenBlock:t={},...n}={}){var o,i;(o=n.isConstructed)!==null&&o!==void 0||(n.isConstructed=!!(!((i=n.value)===null||i===void 0)&&i.length)),super({idBlock:{isConstructed:n.isConstructed,...e},lenBlock:{...t,isIndefiniteForm:!!n.isIndefiniteForm},...n},Lo),this.idBlock.tagClass=1,this.idBlock.tagNumber=4}fromBER(e,t,n){if(this.valueBlock.isConstructed=this.idBlock.isConstructed,this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm,n===0)return this.idBlock.error.length===0&&(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length===0&&(this.blockLength+=this.lenBlock.blockLength),t;if(!this.valueBlock.isConstructed){let i=(e instanceof ArrayBuffer?new Uint8Array(e):e).subarray(t,t+n);try{if(i.byteLength){let s=ci(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?Yt.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)}};Iu=kt;_.OctetString=Iu;kt.NAME=wu;var Vo=class extends Ct(ht){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=ht.prototype.fromBER.call(this,e,t,n),o===-1)return o;for(let a of this.value){let c=a.constructor.NAME;if(c===Bn){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, BIT STRING may consists of BIT STRINGs only",-1}if(c!==bu)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(!Tt(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=ci(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 ht.prototype.toBER.call(this,e,t);if(e)return new ArrayBuffer(this.valueHexView.byteLength+1);if(!this.valueHexView.byteLength)return nt;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}}};Vo.NAME="BitStringValueBlock";var ku,Yr=class extends ve{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=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 Yt.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)}`}}};ku=Yr;_.BitString=ku;Yr.NAME=bu;var Ru;function kp(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=Bo(new Uint8Array([f%10]),i);break;default:i[s-l]=f%10}}return t[0]>0&&(i=Bo(t,i)),i}function yu(r){if(r>=En.length)for(let e=En.length;e<=r;e++){let t=new Uint8Array([0]),n=En[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=Bo(t,n)),En.push(n)}return En[r]}function Rp(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 An=class extends Ct(ke){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=Ws.call(this)))}set valueDec(e){this._valueDec=e,this.isHexOnly=!1,this.valueHexView=new Uint8Array(pu(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=Rp(yu(n),t),s="-";break;default:t=kp(t,yu(n))}n++,o>>=1}}for(let c=0;c<t.length;c++)t[c]&&(a=!0),a&&(s+=mu.charAt(t[c]));return a===!1&&(s+=mu.charAt(0)),s}};Ru=An;An.NAME="IntegerValueBlock";Object.defineProperty(Ru.prototype,"valueHex",{set:function(r){this.valueHexView=new Uint8Array(r),this.setValueHex()},get:function(){return this.valueHexView.slice().buffer}});var Tu,de=class r extends ve{constructor(e={}){super(e,An),this.idBlock.tagClass=1,this.idBlock.tagNumber=2}toBigInt(){return Ao(),BigInt(this.valueBlock.toString())}static fromBigInt(e){Ao();let t=BigInt(e),n=new vn,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()}`}};Tu=de;_.Integer=Tu;de.NAME="INTEGER";var Cu,Do=class extends de{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=10}};Cu=Do;_.Enumerated=Cu;Do.NAME="ENUMERATED";var Sn=class extends Ct(ke){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(!Tt(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=dr(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),t+this.blockLength)}set valueBigInt(e){Ao();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=jt(this.valueDec,7);if(t.byteLength===0)return this.error="Error during encoding SID value",nt;let n=new Uint8Array(t.byteLength);if(!e){let o=new Uint8Array(t),i=t.byteLength-1;for(let s=0;s<i;s++)n[s]=o[s]|128;n[i]=o[i]}return n}toString(){let e="";if(this.isHexOnly)e=j.Convert.ToHex(this.valueHexView);else if(this.isFirstSid){let t=this.valueDec;this.valueDec<=39?e="0.":this.valueDec<=79?(e="1.",t-=40):(e="2.",t-=80),e+=t.toString()}else e=this.valueDec.toString();return e}toJSON(){return{...super.toJSON(),valueDec:this.valueDec,isFirstSid:this.isFirstSid}}};Sn.NAME="sidBlock";var Oo=class extends ke{constructor({value:e=Zr,...t}={}){super(t),this.value=[],e&&this.fromString(e)}fromBER(e,t,n){let o=t;for(;n>0;){let i=new Sn;if(o=i.fromBER(e,o,n),o===-1)return this.blockLength=0,this.error=i.error,o;this.value.length===0&&(i.isFirstSid=!0),this.blockLength+=i.blockLength,n-=i.blockLength,this.value.push(i)}return o}toBER(e){let t=[];for(let n=0;n<this.value.length;n++){let o=this.value[n].toBER(e);if(o.byteLength===0)return this.error=this.value[n].error,nt;t.push(o)}return Js(t)}fromString(e){this.value=[];let t=0,n=0,o="",i=!1;do if(n=e.indexOf(".",t),n===-1?o=e.substring(t):o=e.substring(t,n),t=n+1,i){let s=this.value[0],a=0;switch(s.valueDec){case 0:break;case 1:a=40;break;case 2:a=80;break;default:this.value=[];return}let c=parseInt(o,10);if(isNaN(c))return;s.valueDec=c+a,i=!1}else{let s=new Sn;if(o>Number.MAX_SAFE_INTEGER){Ao();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}};Oo.NAME="ObjectIdentifierValueBlock";var Nu,rt=class extends ve{constructor(e={}){super(e,Oo),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()}}};Nu=rt;_.ObjectIdentifier=Nu;rt.NAME="OBJECT IDENTIFIER";var In=class extends Ct(It){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(!Tt(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=dr(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=jt(this.valueDec,7);if(t.byteLength===0)return this.error="Error during encoding SID value",nt;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}}};In.NAME="relativeSidBlock";var Po=class extends ke{constructor({value:e=Zr,...t}={}){super(t),this.value=[],e&&this.fromString(e)}fromBER(e,t,n){let o=t;for(;n>0;){let i=new In;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,nt;n.push(i)}return Js(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 In;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}};Po.NAME="RelativeObjectIdentifierValueBlock";var _u,Fo=class extends ve{constructor(e={}){super(e,Po),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()}}};_u=Fo;_.RelativeObjectIdentifier=_u;Fo.NAME="RelativeObjectIdentifier";var Uu,ye=class extends Yt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=16}};Uu=ye;_.Sequence=Uu;ye.NAME="SEQUENCE";var Lu,Mo=class extends Yt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=17}};Lu=Mo;_.Set=Lu;Mo.NAME="SET";var Ho=class extends Ct(ke){constructor({...e}={}){super(e),this.isHexOnly=!0,this.value=Zr}toJSON(){return{...super.toJSON(),value:this.value}}};Ho.NAME="StringValueBlock";var Ko=class extends Ho{};Ko.NAME="SimpleStringValueBlock";var _e=class extends ko{constructor({...e}={}){super(e,Ko)}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}};_e.NAME="SIMPLE STRING";var $o=class extends _e{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}};$o.NAME="Utf8StringValueBlock";var Vu,Rt=class extends $o{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=12}};Vu=Rt;_.Utf8String=Vu;Rt.NAME="UTF8String";var qo=class extends _e{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))}};qo.NAME="BmpStringValueBlock";var Du,zo=class extends qo{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=30}};Du=zo;_.BmpString=Du;zo.NAME="BMPString";var Go=class extends _e{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=jt(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}};Go.NAME="UniversalStringValueBlock";var Ou,jo=class extends Go{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=28}};Ou=jo;_.UniversalString=Ou;jo.NAME="UniversalString";var Pu,Yo=class extends _e{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=18}};Pu=Yo;_.NumericString=Pu;Yo.NAME="NumericString";var Fu,Zo=class extends _e{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=19}};Fu=Zo;_.PrintableString=Fu;Zo.NAME="PrintableString";var Mu,Wo=class extends _e{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=20}};Mu=Wo;_.TeletexString=Mu;Wo.NAME="TeletexString";var Hu,Jo=class extends _e{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=21}};Hu=Jo;_.VideotexString=Hu;Jo.NAME="VideotexString";var Ku,Xo=class extends _e{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=22}};Ku=Xo;_.IA5String=Ku;Xo.NAME="IA5String";var $u,Qo=class extends _e{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=25}};$u=Qo;_.GraphicString=$u;Qo.NAME="GraphicString";var qu,kn=class extends _e{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=26}};qu=kn;_.VisibleString=qu;kn.NAME="VisibleString";var zu,ei=class extends _e{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=27}};zu=ei;_.GeneralString=zu;ei.NAME="GeneralString";var Gu,ti=class extends _e{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=29}};Gu=ti;_.CharacterString=Gu;ti.NAME="CharacterString";var ju,Rn=class extends kn{constructor({value:e,valueDate:t,...n}={}){if(super(n),this.year=0,this.month=0,this.day=0,this.hour=0,this.minute=0,this.second=0,e){this.fromString(e),this.valueBlock.valueHexView=new Uint8Array(e.length);for(let o=0;o<e.length;o++)this.valueBlock.valueHexView[o]=e.charCodeAt(o)}t&&(this.fromDate(t),this.valueBlock.valueHexView=new Uint8Array(this.toBuffer())),this.idBlock.tagClass=1,this.idBlock.tagNumber=23}fromBuffer(e){this.fromString(String.fromCharCode.apply(null,j.BufferSourceConverter.toUint8Array(e)))}toBuffer(){let e=this.toString(),t=new ArrayBuffer(e.length),n=new Uint8Array(t);for(let o=0;o<e.length;o++)n[o]=e.charCodeAt(o);return t}fromDate(e){this.year=e.getUTCFullYear(),this.month=e.getUTCMonth()+1,this.day=e.getUTCDate(),this.hour=e.getUTCHours(),this.minute=e.getUTCMinutes(),this.second=e.getUTCSeconds()}toDate(){return new Date(Date.UTC(this.year,this.month-1,this.day,this.hour,this.minute,this.second))}fromString(e){let n=/(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})Z/ig.exec(e);if(n===null){this.error="Wrong input string for conversion";return}let o=parseInt(n[1],10);o>=50?this.year=1900+o:this.year=2e3+o,this.month=parseInt(n[2],10),this.day=parseInt(n[3],10),this.hour=parseInt(n[4],10),this.minute=parseInt(n[5],10),this.second=parseInt(n[6],10)}toString(e="iso"){if(e==="iso"){let t=new Array(7);return t[0]=Ve(this.year<2e3?this.year-1900:this.year-2e3,2),t[1]=Ve(this.month,2),t[2]=Ve(this.day,2),t[3]=Ve(this.hour,2),t[4]=Ve(this.minute,2),t[5]=Ve(this.second,2),t[6]="Z",t.join("")}return super.toString(e)}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.toDate().toISOString()}`}toJSON(){return{...super.toJSON(),year:this.year,month:this.month,day:this.day,hour:this.hour,minute:this.minute,second:this.second}}};ju=Rn;_.UTCTime=ju;Rn.NAME="UTCTime";var Yu,ri=class extends Rn{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("+"),E="";if(d===-1&&(d=n.indexOf("-"),l=-1),d!==-1){if(E=n.substring(d+1),n=n.substring(0,d),E.length!==2&&E.length!==4)throw new Error("Wrong input string for conversion");let g=parseInt(E.substring(0,2),10);if(isNaN(g.valueOf()))throw new Error("Wrong input string for conversion");if(a=l*g,E.length===4){if(g=parseInt(E.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}}};Yu=ri;_.GeneralizedTime=Yu;ri.NAME="GeneralizedTime";var Zu,ni=class extends Rt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=31}};Zu=ni;_.DATE=Zu;ni.NAME="DATE";var Wu,oi=class extends Rt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=32}};Wu=oi;_.TimeOfDay=Wu;oi.NAME="TimeOfDay";var Ju,ii=class extends Rt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=33}};Ju=ii;_.DateTime=Ju;ii.NAME="DateTime";var Xu,si=class extends Rt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=34}};Xu=si;_.Duration=Xu;si.NAME="Duration";var Qu,ai=class extends Rt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=14}};Qu=ai;_.TIME=Qu;ai.NAME="TIME";function Cp(r){let{result:e}=Wr(r),t=e.valueBlock.value;return{n:Z(dt(t[1].toBigInt()),"base64url"),e:Z(dt(t[2].toBigInt()),"base64url"),d:Z(dt(t[3].toBigInt()),"base64url"),p:Z(dt(t[4].toBigInt()),"base64url"),q:Z(dt(t[5].toBigInt()),"base64url"),dp:Z(dt(t[6].toBigInt()),"base64url"),dq:Z(dt(t[7].toBigInt()),"base64url"),qi:Z(dt(t[8].toBigInt()),"base64url"),kty:"RSA",alg:"RS256"}}function Np(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 P("JWK was missing components","ERR_INVALID_PARAMETERS");let t=new ye({value:[new de({value:0}),de.fromBigInt(pt(J(r.n,"base64url"))),de.fromBigInt(pt(J(r.e,"base64url"))),de.fromBigInt(pt(J(r.d,"base64url"))),de.fromBigInt(pt(J(r.p,"base64url"))),de.fromBigInt(pt(J(r.q,"base64url"))),de.fromBigInt(pt(J(r.dp,"base64url"))),de.fromBigInt(pt(J(r.dq,"base64url"))),de.fromBigInt(pt(J(r.qi,"base64url")))]}).toBER();return new Uint8Array(t,0,t.byteLength)}function _p(r){let{result:e}=Wr(r),t=e.valueBlock.value[1].valueBlock.value[0].valueBlock.value;return{kty:"RSA",n:Z(dt(t[0].toBigInt()),"base64url"),e:Z(dt(t[1].toBigInt()),"base64url")}}function Up(r){if(r.n==null||r.e==null)throw new P("JWK was missing components","ERR_INVALID_PARAMETERS");let t=new ye({value:[new ye({value:[new rt({value:"1.2.840.113549.1.1.1"}),new Zt]}),new Yr({valueHex:new ye({value:[de.fromBigInt(pt(J(r.n,"base64url"))),de.fromBigInt(pt(J(r.e,"base64url")))]}).toBER()})]}).toBER();return new Uint8Array(t,0,t.byteLength)}function dt(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 pt(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 Lp=16,Qs=32,ea=1e4;async function Vp(r,e){let t=Ne.get(),o=new ye({value:[new de({value:0}),new ye({value:[new rt({value:"1.2.840.113549.1.1.1"}),new Zt]}),new kt({valueHex:r.marshal()})]}).toBER(),i=new Uint8Array(o,0,o.byteLength),s=hr(Lp),a=await Ys(Or,e,s,{c:ea,dkLen:Qs}),c=hr(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 ye({value:[new kt({valueHex:s}),new de({value:ea}),new de({value:Qs}),new ye({value:[new rt({value:"1.2.840.113549.2.11"}),new Zt]})]}),d=new ye({value:[new rt({value:"1.2.840.113549.1.5.13"}),new ye({value:[new ye({value:[new rt({value:"1.2.840.113549.1.5.12"}),l]}),new ye({value:[new rt({value:"2.16.840.1.101.3.4.1.42"}),new kt({valueHex:c})]})]})]}),g=new ye({value:[d,new kt({valueHex:u})]}).toBER(),h=new Uint8Array(g,0,g.byteLength);return["-----BEGIN ENCRYPTED PRIVATE KEY-----",...Z(h,"base64pad").split(/(.{64})/).filter(Boolean),"-----END ENCRYPTED PRIVATE KEY-----"].join(`
8
- `)}async function Dp(r,e){let t=Ne.get(),n;if(r.includes("-----BEGIN ENCRYPTED PRIVATE KEY-----")){let o=J(r.replace("-----BEGIN ENCRYPTED PRIVATE KEY-----","").replace("-----END ENCRYPTED PRIVATE KEY-----","").replace(/\n/g,"").trim(),"base64pad"),{result:i}=Wr(o),{iv:s,salt:a,iterations:c,keySize:f,cipherText:u}=Op(i),l=await Ys(Or,e,a,{c,dkLen:f}),d=await t.subtle.importKey("raw",l,"AES-CBC",!1,["decrypt"]),E=Tn(await t.subtle.decrypt({name:"AES-CBC",iv:s},d,u)),{result:g}=Wr(E);n=el(g)}else if(r.includes("-----BEGIN PRIVATE KEY-----")){let o=J(r.replace("-----BEGIN PRIVATE KEY-----","").replace("-----END PRIVATE KEY-----","").replace(/\n/g,"").trim(),"base64pad"),{result:i}=Wr(o);n=el(i)}else throw new P("Could not parse private key from PEM data","ERR_INVALID_PARAMETERS");return ta(n)}function Op(r){let e=r.valueBlock.value[0];if(e.valueBlock.value[0].toString()!=="OBJECT IDENTIFIER : 1.2.840.113549.1.5.13")throw new P("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 P("Only pkcs5PBKDF2 key derivation functions are supported","ERR_INVALID_PARAMS");let i=n.valueBlock.value[1],s=Tn(i.valueBlock.value[0].getValue()),a=ea,c=Qs;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 P("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 P("Only AES-CBC encryption schemes are supported","ERR_INVALID_PARAMS")}}}}let l=Tn(f.valueBlock.value[1].getValue());return{cipherText:Tn(r.valueBlock.value[1].getValue()),salt:s,iterations:a,keySize:c,iv:l}}function el(r){return Tn(r.valueBlock.value[2].getValue())}function Tn(r){return new Uint8Array(r,0,r.byteLength)}async function tl(r){let e=await Ne.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 ol(e);return{privateKey:t[0],publicKey:t[1]}}async function ra(r){let t=[await Ne.get().subtle.importKey("jwk",r,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["sign"]),await Pp(r)],n=await ol({privateKey:t[0],publicKey:t[1]});return{privateKey:n[0],publicKey:n[1]}}async function rl(r,e){let t=await Ne.get().subtle.importKey("jwk",r,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["sign"]),n=await Ne.get().subtle.sign({name:"RSASSA-PKCS1-v1_5"},t,e instanceof Uint8Array?e:e.subarray());return new Uint8Array(n,0,n.byteLength)}async function nl(r,e,t){let n=await Ne.get().subtle.importKey("jwk",r,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["verify"]);return Ne.get().subtle.verify({name:"RSASSA-PKCS1-v1_5"},n,e,t instanceof Uint8Array?t:t.subarray())}async function ol(r){if(r.privateKey==null||r.publicKey==null)throw new P("Private and public key are required","ERR_INVALID_PARAMETERS");return Promise.all([Ne.get().subtle.exportKey("jwk",r.privateKey),Ne.get().subtle.exportKey("jwk",r.publicKey)])}async function Pp(r){return Ne.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 ui(r){if(r.kty!=="RSA")throw new P("invalid key type","ERR_INVALID_KEY_TYPE");if(r.n==null)throw new P("invalid key modulus","ERR_INVALID_KEY_MODULUS");return J(r.n,"base64url").length*8}var Nn=8192,Cn=class{_key;constructor(e){this._key=e}verify(e,t){return nl(this._key,t,e)}marshal(){return Wt.jwkToPkix(this._key)}get bytes(){return ft.encode({Type:le.RSA,Data:this.marshal()}).subarray()}equals(e){return he(this.bytes,e.bytes)}hash(){let e=Ee.digest(this.bytes);return Ge(e)?e.then(({bytes:t})=>t):e.bytes}},Jr=class{_key;_publicKey;constructor(e,t){this._key=e,this._publicKey=t}genSecret(){return hr(16)}sign(e){return rl(this._key,e)}get public(){if(this._publicKey==null)throw new P("public key not provided","ERR_PUBKEY_NOT_PROVIDED");return new Cn(this._publicKey)}marshal(){return Wt.jwkToPkcs1(this._key)}get bytes(){return At.encode({Type:le.RSA,Data:this.marshal()}).subarray()}equals(e){return he(this.bytes,e.bytes)}hash(){let e=Ee.digest(this.bytes);return Ge(e)?e.then(({bytes:t})=>t):e.bytes}async id(){let e=await this.public.hash();return Z(e,"base58btc")}async export(e,t="pkcs-8"){if(t==="pkcs-8")return Wt.exportToPem(this,e);if(t==="libp2p-key")return Hr(this.bytes,e);throw new P(`export format '${t}' is not supported`,"ERR_INVALID_EXPORT_FORMAT")}};async function ta(r){let e=Wt.pkcs1ToJwk(r);if(ui(e)>Nn)throw new P("key size is too large","ERR_KEY_SIZE_TOO_LARGE");let t=await ra(e);return new Jr(t.privateKey,t.publicKey)}function Mp(r){let e=Wt.pkixToJwk(r);if(ui(e)>Nn)throw new P("key size is too large","ERR_KEY_SIZE_TOO_LARGE");return new Cn(e)}async function Hp(r){if(ui(r)>Nn)throw new P("key size is too large","ERR_KEY_SIZE_TOO_LARGE");let e=await ra(r);return new Jr(e.privateKey,e.publicKey)}async function Kp(r){if(r>Nn)throw new P("key size is too large","ERR_KEY_SIZE_TOO_LARGE");let e=await tl(r);return new Jr(e.privateKey,e.publicKey)}var ca={};me(ca,{Secp256k1PrivateKey:()=>Un,Secp256k1PublicKey:()=>_n,generateKeyPair:()=>tg,unmarshalSecp256k1PrivateKey:()=>Qp,unmarshalSecp256k1PublicKey:()=>eg});var $p=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]),Jt=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Xt=new Uint32Array(64),oa=class extends Dr{constructor(){super(64,32,8,!1),this.A=Jt[0]|0,this.B=Jt[1]|0,this.C=Jt[2]|0,this.D=Jt[3]|0,this.E=Jt[4]|0,this.F=Jt[5]|0,this.G=Jt[6]|0,this.H=Jt[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)Xt[l]=e.getUint32(t,!1);for(let l=16;l<64;l++){let d=Xt[l-15],E=Xt[l-2],g=Qe(d,7)^Qe(d,18)^d>>>3,h=Qe(E,17)^Qe(E,19)^E>>>10;Xt[l]=h+Xt[l-7]+g+Xt[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=Qe(a,6)^Qe(a,11)^Qe(a,25),E=u+d+Vc(a,c,f)+$p[l]+Xt[l]|0,h=(Qe(n,2)^Qe(n,13)^Qe(n,22))+Dc(n,o,i)|0;u=f,f=c,c=a,a=s+E|0,s=i,i=o,o=n,n=E+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(){Xt.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var il=io(()=>new oa);function qp(r){let e=gn(r);lt(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:zp,hexToBytes:Gp}=co,pr={Err:class extends Error{constructor(e=""){super(e)}},_parseInt(r){let{Err:e}=pr;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:zp(n),l:r.subarray(t+2)}},toSig(r){let{Err:e}=pr,t=typeof r=="string"?Gp(r):r;Pr(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}=pr._parseInt(t.subarray(2)),{d:s,l:a}=pr._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}`}},Nt=BigInt(0),Ye=BigInt(1),o1=BigInt(2),sl=BigInt(3),i1=BigInt(4);function jp(r){let e=qp(r),{Fp:t}=e,n=e.toBytes||((g,h,p)=>{let b=h.toAffine();return Et(Uint8Array.from([4]),t.toBytes(b.x),t.toBytes(b.y))}),o=e.fromBytes||(g=>{let h=g.subarray(1),p=t.fromBytes(h.subarray(0,t.BYTES)),b=t.fromBytes(h.subarray(t.BYTES,2*t.BYTES));return{x:p,y:b}});function i(g){let{a:h,b:p}=e,b=t.sqr(g),k=t.mul(b,g);return t.add(t.add(k,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"&&Nt<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:b,n:k}=e;if(h&&typeof g!="bigint"){if($t(g)&&(g=bt(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:xt(ce("private key",g,p))}catch{throw new Error(`private key must be ${p} bytes, hex or bigint, not ${typeof g}`)}return b&&(v=re(v,k)),a(v),v}let f=new Map;function u(g){if(!(g instanceof l))throw new Error("ProjectivePoint expected")}class l{constructor(h,p,b){if(this.px=h,this.py=p,this.pz=b,h==null||!t.isValid(h))throw new Error("x required");if(p==null||!t.isValid(p))throw new Error("y required");if(b==null||!t.isValid(b))throw new Error("z required")}static fromAffine(h){let{x:p,y:b}=h||{};if(!h||!t.isValid(p)||!t.isValid(b))throw new Error("invalid affine point");if(h instanceof l)throw new Error("projective point not allowed");let k=v=>t.eql(v,t.ZERO);return k(p)&&k(b)?l.ZERO:new l(p,b,t.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(h){let p=t.invertBatch(h.map(b=>b.pz));return h.map((b,k)=>b.toAffine(p[k])).map(l.fromAffine)}static fromHex(h){let p=l.fromAffine(o(ce("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 b=t.sqr(p),k=i(h);if(!t.eql(b,k))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:b,pz:k}=this,{px:v,py:L,pz:S}=h,R=t.eql(t.mul(p,S),t.mul(v,k)),N=t.eql(t.mul(b,S),t.mul(L,k));return R&&N}negate(){return new l(this.px,t.neg(this.py),this.pz)}double(){let{a:h,b:p}=e,b=t.mul(p,sl),{px:k,py:v,pz:L}=this,S=t.ZERO,R=t.ZERO,N=t.ZERO,y=t.mul(k,k),C=t.mul(v,v),D=t.mul(L,L),T=t.mul(k,v);return T=t.add(T,T),N=t.mul(k,L),N=t.add(N,N),S=t.mul(h,N),R=t.mul(b,D),R=t.add(S,R),S=t.sub(C,R),R=t.add(C,R),R=t.mul(S,R),S=t.mul(T,S),N=t.mul(b,N),D=t.mul(h,D),T=t.sub(y,D),T=t.mul(h,T),T=t.add(T,N),N=t.add(y,y),y=t.add(N,y),y=t.add(y,D),y=t.mul(y,T),R=t.add(R,y),D=t.mul(v,L),D=t.add(D,D),y=t.mul(D,T),S=t.sub(S,y),N=t.mul(D,C),N=t.add(N,N),N=t.add(N,N),new l(S,R,N)}add(h){u(h);let{px:p,py:b,pz:k}=this,{px:v,py:L,pz:S}=h,R=t.ZERO,N=t.ZERO,y=t.ZERO,C=e.a,D=t.mul(e.b,sl),T=t.mul(p,v),O=t.mul(b,L),H=t.mul(k,S),W=t.add(p,b),x=t.add(v,L);W=t.mul(W,x),x=t.add(T,O),W=t.sub(W,x),x=t.add(p,k);let A=t.add(v,S);return x=t.mul(x,A),A=t.add(T,H),x=t.sub(x,A),A=t.add(b,k),R=t.add(L,S),A=t.mul(A,R),R=t.add(O,H),A=t.sub(A,R),y=t.mul(C,x),R=t.mul(D,H),y=t.add(R,y),R=t.sub(O,y),y=t.add(O,y),N=t.mul(R,y),O=t.add(T,T),O=t.add(O,T),H=t.mul(C,H),x=t.mul(D,x),O=t.add(O,H),H=t.sub(T,H),H=t.mul(C,H),x=t.add(x,H),T=t.mul(O,x),N=t.add(N,T),T=t.mul(A,x),R=t.mul(W,R),R=t.sub(R,T),T=t.mul(W,O),y=t.mul(A,y),y=t.add(y,T),new l(R,N,y)}subtract(h){return this.add(h.negate())}is0(){return this.equals(l.ZERO)}wNAF(h){return E.wNAFCached(this,f,h,p=>{let b=t.invertBatch(p.map(k=>k.pz));return p.map((k,v)=>k.toAffine(b[v])).map(l.fromAffine)})}multiplyUnsafe(h){let p=l.ZERO;if(h===Nt)return p;if(a(h),h===Ye)return this;let{endo:b}=e;if(!b)return E.unsafeLadder(this,h);let{k1neg:k,k1:v,k2neg:L,k2:S}=b.splitScalar(h),R=p,N=p,y=this;for(;v>Nt||S>Nt;)v&Ye&&(R=R.add(y)),S&Ye&&(N=N.add(y)),y=y.double(),v>>=Ye,S>>=Ye;return k&&(R=R.negate()),L&&(N=N.negate()),N=new l(t.mul(N.px,b.beta),N.py,N.pz),R.add(N)}multiply(h){a(h);let p=h,b,k,{endo:v}=e;if(v){let{k1neg:L,k1:S,k2neg:R,k2:N}=v.splitScalar(p),{p:y,f:C}=this.wNAF(S),{p:D,f:T}=this.wNAF(N);y=E.constTimeNegate(L,y),D=E.constTimeNegate(R,D),D=new l(t.mul(D.px,v.beta),D.py,D.pz),b=y.add(D),k=C.add(T)}else{let{p:L,f:S}=this.wNAF(p);b=L,k=S}return l.normalizeZ([b,k])[0]}multiplyAndAddUnsafe(h,p,b){let k=l.BASE,v=(S,R)=>R===Nt||R===Ye||!S.equals(k)?S.multiplyUnsafe(R):S.multiply(R),L=v(this,p).add(v(h,b));return L.is0()?void 0:L}toAffine(h){let{px:p,py:b,pz:k}=this,v=this.is0();h==null&&(h=v?t.ONE:t.inv(k));let L=t.mul(p,h),S=t.mul(b,h),R=t.mul(k,h);if(v)return{x:t.ZERO,y:t.ZERO};if(!t.eql(R,t.ONE))throw new Error("invZ was invalid");return{x:L,y:S}}isTorsionFree(){let{h,isTorsionFree:p}=e;if(h===Ye)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===Ye?this:p?p(l,this):this.multiplyUnsafe(e.h)}toRawBytes(h=!0){return this.assertValidity(),n(l,this,h)}toHex(h=!0){return bt(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,E=fo(l,e.endo?Math.ceil(d/2):d);return{CURVE:e,ProjectivePoint:l,normPrivateKeyToScalar:c,weierstrassEquation:i,isWithinCurveOrder:s}}function Yp(r){let e=gn(r);return lt(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function al(r){let e=Yp(r),{Fp:t,n}=e,o=t.BYTES+1,i=2*t.BYTES+1;function s(x){return Nt<x&&x<t.ORDER}function a(x){return re(x,n)}function c(x){return uo(x,n)}let{ProjectivePoint:f,normPrivateKeyToScalar:u,weierstrassEquation:l,isWithinCurveOrder:d}=jp({...e,toBytes(x,A,M){let B=A.toAffine(),w=t.toBytes(B.x),V=Et;return M?V(Uint8Array.from([A.hasEvenY()?2:3]),w):V(Uint8Array.from([4]),w,t.toBytes(B.y))},fromBytes(x){let A=x.length,M=x[0],B=x.subarray(1);if(A===o&&(M===2||M===3)){let w=xt(B);if(!s(w))throw new Error("Point is not on curve");let V=l(w),F;try{F=t.sqrt(V)}catch(G){let ee=G instanceof Error?": "+G.message:"";throw new Error("Point is not on curve"+ee)}let K=(F&Ye)===Ye;return(M&1)===1!==K&&(F=t.neg(F)),{x:w,y:F}}else if(A===i&&M===4){let w=t.fromBytes(B.subarray(0,t.BYTES)),V=t.fromBytes(B.subarray(t.BYTES,2*t.BYTES));return{x:w,y:V}}else throw new Error(`Point of length ${A} was invalid. Expected ${o} compressed bytes or ${i} uncompressed bytes`)}}),E=x=>bt(zt(x,e.nByteLength));function g(x){let A=n>>Ye;return x>A}function h(x){return g(x)?a(-x):x}let p=(x,A,M)=>xt(x.slice(A,M));class b{constructor(A,M,B){this.r=A,this.s=M,this.recovery=B,this.assertValidity()}static fromCompact(A){let M=e.nByteLength;return A=ce("compactSignature",A,M*2),new b(p(A,0,M),p(A,M,2*M))}static fromDER(A){let{r:M,s:B}=pr.toSig(ce("DER",A));return new b(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 b(this.r,this.s,A)}recoverPublicKey(A){let{r:M,s:B,recovery:w}=this,V=N(ce("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 K=w&1?"03":"02",z=f.fromHex(K+E(F)),G=c(F),ee=a(-V*G),Y=a(B*G),X=f.BASE.multiplyAndAddUnsafe(z,ee,Y);if(!X)throw new Error("point at infinify");return X.assertValidity(),X}hasHighS(){return g(this.s)}normalizeS(){return this.hasHighS()?new b(this.r,a(-this.s),this.recovery):this}toDERRawBytes(){return sr(this.toDERHex())}toDERHex(){return pr.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return sr(this.toCompactHex())}toCompactHex(){return E(this.r)+E(this.s)}}let k={isValidPrivateKey(x){try{return u(x),!0}catch{return!1}},normPrivateKeyToScalar:u,randomPrivateKey:()=>{let x=Ts(e.n);return jc(e.randomBytes(x),e.n)},precompute(x=8,A=f.BASE){return A._setWindowSize(x),A.multiply(BigInt(3)),A}};function v(x,A=!0){return f.fromPrivateKey(x).toRawBytes(A)}function L(x){let A=$t(x),M=typeof x=="string",B=(A||M)&&x.length;return A?B===o||B===i:M?B===2*o||B===2*i:x instanceof f}function S(x,A,M=!0){if(L(x))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(x)).toRawBytes(M)}let R=e.bits2int||function(x){let A=xt(x),M=x.length*8-e.nBitLength;return M>0?A>>BigInt(M):A},N=e.bits2int_modN||function(x){return a(R(x))},y=pn(e.nBitLength);function C(x){if(typeof x!="bigint")throw new Error("bigint expected");if(!(Nt<=x&&x<y))throw new Error(`bigint expected < 2^${e.nBitLength}`);return zt(x,e.nByteLength)}function D(x,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:V,prehash:F,extraEntropy:K}=M;V==null&&(V=!0),x=ce("msgHash",x),F&&(x=ce("prehashed msgHash",B(x)));let z=N(x),G=u(A),ee=[C(G),C(z)];if(K!=null&&K!==!1){let se=K===!0?w(t.BYTES):K;ee.push(ce("extraEntropy",se))}let Y=Et(...ee),X=z;function fe(se){let be=R(se);if(!d(be))return;let xe=c(be),pe=f.BASE.multiply(be).toAffine(),Ae=a(pe.x);if(Ae===Nt)return;let mt=a(xe*a(X+Ae*G));if(mt===Nt)return;let rr=(pe.x===Ae?0:2)|Number(pe.y&Ye),on=mt;return V&&g(mt)&&(on=h(mt),rr^=1),new b(Ae,on,rr)}return{seed:Y,k2sig:fe}}let T={lowS:e.lowS,prehash:!1},O={lowS:e.lowS,prehash:!1};function H(x,A,M=T){let{seed:B,k2sig:w}=D(x,A,M),V=e;return Ss(V.hash.outputLen,V.nByteLength,V.hmac)(B,w)}f.BASE._setWindowSize(8);function W(x,A,M,B=O){let w=x;if(A=ce("msgHash",A),M=ce("publicKey",M),"strict"in B)throw new Error("options.strict was renamed to lowS");let{lowS:V,prehash:F}=B,K,z;try{if(typeof w=="string"||$t(w))try{K=b.fromDER(w)}catch(pe){if(!(pe instanceof pr.Err))throw pe;K=b.fromCompact(w)}else if(typeof w=="object"&&typeof w.r=="bigint"&&typeof w.s=="bigint"){let{r:pe,s:Ae}=w;K=new b(pe,Ae)}else throw new Error("PARSE");z=f.fromHex(M)}catch(pe){if(pe.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(V&&K.hasHighS())return!1;F&&(A=e.hash(A));let{r:G,s:ee}=K,Y=N(A),X=c(ee),fe=a(Y*X),se=a(G*X),be=f.BASE.multiplyAndAddUnsafe(z,fe,se)?.toAffine();return be?a(be.x)===G:!1}return{CURVE:e,getPublicKey:v,getSharedSecret:S,sign:H,verify:W,ProjectivePoint:f,Signature:b,utils:k}}function Zp(r){return{hash:r,hmac:(e,...t)=>xn(r,e,oo(...t)),randomBytes:Vr}}function cl(r,e){let t=n=>al({...r,...Zp(n)});return Object.freeze({...t(e),create:t})}var fl=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),ul=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),Wp=BigInt(1),ia=BigInt(2),ll=(r,e)=>(r+e/ia)/e;function Jp(r){let e=fl,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,E=ie(d,ia,e)*f%e,g=ie(E,o,e)*E%e,h=ie(g,i,e)*g%e,p=ie(h,a,e)*h%e,b=ie(p,c,e)*p%e,k=ie(b,a,e)*h%e,v=ie(k,t,e)*u%e,L=ie(v,s,e)*g%e,S=ie(L,n,e)*f%e,R=ie(S,ia,e);if(!sa.eql(sa.sqr(R),r))throw new Error("Cannot find square root");return R}var sa=lo(fl,void 0,void 0,{sqrt:Jp}),ot=cl({a:BigInt(0),b:BigInt(7),Fp:sa,n:ul,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:r=>{let e=ul,t=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-Wp*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),i=t,s=BigInt("0x100000000000000000000000000000000"),a=ll(i*r,e),c=ll(-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}}}},il),p1=BigInt(0);var g1=ot.ProjectivePoint;function hl(){return ot.utils.randomPrivateKey()}function dl(r,e){let t=Ee.digest(e instanceof Uint8Array?e:e.subarray());if(Ge(t))return t.then(({digest:n})=>ot.sign(n,r).toDERRawBytes()).catch(n=>{throw new P(String(n),"ERR_INVALID_INPUT")});try{return ot.sign(t.digest,r).toDERRawBytes()}catch(n){throw new P(String(n),"ERR_INVALID_INPUT")}}function pl(r,e,t){let n=Ee.digest(t instanceof Uint8Array?t:t.subarray());if(Ge(n))return n.then(({digest:o})=>ot.verify(e,o,r)).catch(o=>{throw new P(String(o),"ERR_INVALID_INPUT")});try{return ot.verify(e,n.digest,r)}catch(o){throw new P(String(o),"ERR_INVALID_INPUT")}}function gl(r){return ot.ProjectivePoint.fromHex(r).toRawBytes(!0)}function ml(r){try{ot.getPublicKey(r,!0)}catch(e){throw new P(String(e),"ERR_INVALID_PRIVATE_KEY")}}function aa(r){try{ot.ProjectivePoint.fromHex(r)}catch(e){throw new P(String(e),"ERR_INVALID_PUBLIC_KEY")}}function yl(r){try{return ot.getPublicKey(r,!0)}catch(e){throw new P(String(e),"ERR_INVALID_PRIVATE_KEY")}}var _n=class{_key;constructor(e){aa(e),this._key=e}verify(e,t){return pl(this._key,t,e)}marshal(){return gl(this._key)}get bytes(){return ft.encode({Type:le.Secp256k1,Data:this.marshal()}).subarray()}equals(e){return he(this.bytes,e.bytes)}async hash(){let e=Ee.digest(this.bytes),t;return Ge(e)?{bytes:t}=await e:t=e.bytes,t}},Un=class{_key;_publicKey;constructor(e,t){this._key=e,this._publicKey=t??yl(e),ml(this._key),aa(this._publicKey)}sign(e){return dl(this._key,e)}get public(){return new _n(this._publicKey)}marshal(){return this._key}get bytes(){return At.encode({Type:le.Secp256k1,Data:this.marshal()}).subarray()}equals(e){return he(this.bytes,e.bytes)}hash(){let e=Ee.digest(this.bytes);return Ge(e)?e.then(({bytes:t})=>t):e.bytes}async id(){let e=await this.public.hash();return Z(e,"base58btc")}async export(e,t="libp2p-key"){if(t==="libp2p-key")return Hr(this.bytes,e);throw new P(`export format '${t}' is not supported`,"ERR_INVALID_EXPORT_FORMAT")}};function Qp(r){return new Un(r)}function eg(r){return new _n(r)}async function tg(){let r=hl();return new Un(r)}var li={rsa:na,ed25519:js,secp256k1:ca};function rg(r){let e=Object.keys(li).join(" / ");return new P(`invalid or unsupported key type ${r}. Must be ${e}`,"ERR_UNSUPPORTED_KEY_TYPE")}function ua(r){let e=ft.decode(r),t=e.Data??new Uint8Array;switch(e.Type){case le.RSA:return li.rsa.unmarshalRsaPublicKey(t);case le.Ed25519:return li.ed25519.unmarshalEd25519PublicKey(t);case le.Secp256k1:return li.secp256k1.unmarshalSecp256k1PublicKey(t);default:throw rg(e.Type??"unknown")}}var Og=Lt(fi(),1);var og="/",ig=new TextEncoder().encode(og),_1=ig[0];var Pg=Lt(fa(),1);var xl="ERR_IPNS_EXPIRED_RECORD",hi="ERR_UNRECOGNIZED_VALIDITY";var _t="ERR_SIGNATURE_VERIFICATION";var ha="ERR_UNDEFINED_PARAMETER",El="ERR_INVALID_RECORD_DATA",vl="ERR_INVALID_VALUE",Bl="ERR_INVALID_EMBEDDED_KEY";var Al="ERR_RECORD_TOO_LARGE";var it;(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=()=>wn(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=>$r(o,r.codec()),r.decode=o=>Kr(o,r.codec())})(it||(it={}));var sg=["string","number","bigint","symbol"],ag=["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 Il(r){if(r===null)return"null";if(r===void 0)return"undefined";if(r===!0||r===!1)return"boolean";let e=typeof r;if(sg.includes(e))return e;if(e==="function")return"Function";if(Array.isArray(r))return"Array";if(cg(r))return"Buffer";let t=ug(r);return t||"Object"}function cg(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(ag.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 Xr=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&typeof globalThis.Buffer.isBuffer=="function",lg=new TextDecoder,fg=new TextEncoder;function di(r){return Xr&&globalThis.Buffer.isBuffer(r)}function Cl(r){return r instanceof Uint8Array?di(r)?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r:Uint8Array.from(r)}var Nl=Xr?(r,e,t)=>t-e>64?globalThis.Buffer.from(r.subarray(e,t)).toString("utf8"):Rl(r,e,t):(r,e,t)=>t-e>64?lg.decode(r.subarray(e,t)):Rl(r,e,t),_l=Xr?r=>r.length>64?globalThis.Buffer.from(r):kl(r):r=>r.length>64?fg.encode(r):kl(r);var Qr=Xr?(r,e,t)=>di(r)?new Uint8Array(r.subarray(e,t)):r.slice(e,t):(r,e,t)=>r.slice(e,t),Ul=Xr?(r,e)=>(r=r.map(t=>t instanceof Uint8Array?t:globalThis.Buffer.from(t)),Cl(globalThis.Buffer.concat(r,e))):(r,e)=>{let t=new Uint8Array(e),n=0;for(let o of r)n+o.length>t.length&&(o=o.subarray(0,t.length-n)),t.set(o,n),n+=o.length;return t},Ll=Xr?r=>globalThis.Buffer.allocUnsafe(r):r=>new Uint8Array(r);function Vl(r,e){if(di(r)&&di(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 kl(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 Rl(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 hg(n)}var Tl=4096;function hg(r){let e=r.length;if(e<=Tl)return String.fromCharCode.apply(String,r);let t="",n=0;for(;n<e;)t+=String.fromCharCode.apply(String,r.slice(n,n+=Tl));return t}var dg=256,pi=class{constructor(e=dg){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=Ll(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=Qr(n,0,this.cursor)}else t=Ul(this.chunks,this.cursor);return e&&this.reset(),t}};var $="CBOR decode error:",da="CBOR encode error:",Ln=[];Ln[23]=1;Ln[24]=2;Ln[25]=3;Ln[26]=5;Ln[27]=9;function Ut(r,e,t){if(r.length-e<t)throw new Error(`${$} not enough data for type`)}var we=[24,256,65536,4294967296,BigInt("18446744073709551616")];function He(r,e,t){Ut(r,e,1);let n=r[e];if(t.strict===!0&&n<we[0])throw new Error(`${$} integer encoded in more bytes than necessary (strict decode)`);return n}function Ke(r,e,t){Ut(r,e,2);let n=r[e]<<8|r[e+1];if(t.strict===!0&&n<we[1])throw new Error(`${$} integer encoded in more bytes than necessary (strict decode)`);return n}function $e(r,e,t){Ut(r,e,4);let n=r[e]*16777216+(r[e+1]<<16)+(r[e+2]<<8)+r[e+3];if(t.strict===!0&&n<we[2])throw new Error(`${$} integer encoded in more bytes than necessary (strict decode)`);return n}function qe(r,e,t){Ut(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<we[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 Dl(r,e,t,n){return new U(m.uint,He(r,e+1,n),2)}function Ol(r,e,t,n){return new U(m.uint,Ke(r,e+1,n),3)}function Pl(r,e,t,n){return new U(m.uint,$e(r,e+1,n),5)}function Fl(r,e,t,n){return new U(m.uint,qe(r,e+1,n),9)}function Ze(r,e){return Be(r,0,e.value)}function Be(r,e,t){if(t<we[0]){let n=Number(t);r.push([e|n])}else if(t<we[1]){let n=Number(t);r.push([e|24,n])}else if(t<we[2]){let n=Number(t);r.push([e|25,n>>>8,n&255])}else if(t<we[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<we[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<we[0]?1:e<we[1]?2:e<we[2]?3:e<we[3]?5:9};Ze.compareTokens=function(e,t){return e.value<t.value?-1:e.value>t.value?1:0};function Ml(r,e,t,n){return new U(m.negint,-1-He(r,e+1,n),2)}function Hl(r,e,t,n){return new U(m.negint,-1-Ke(r,e+1,n),3)}function Kl(r,e,t,n){return new U(m.negint,-1-$e(r,e+1,n),5)}var pa=BigInt(-1),$l=BigInt(1);function ql(r,e,t,n){let o=qe(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(`${$} integers outside of the safe integer range are not supported`);return new U(m.negint,pa-BigInt(o),9)}function gi(r,e){let t=e.value,n=typeof t=="bigint"?t*pa-$l:t*-1-1;Be(r,e.type.majorEncoded,n)}gi.encodedSize=function(e){let t=e.value,n=typeof t=="bigint"?t*pa-$l:t*-1-1;return n<we[0]?1:n<we[1]?2:n<we[2]?3:n<we[3]?5:9};gi.compareTokens=function(e,t){return e.value<t.value?1:e.value>t.value?-1:0};function Vn(r,e,t,n){Ut(r,e,t+n);let o=Qr(r,e+t,e+t+n);return new U(m.bytes,o,t+n)}function zl(r,e,t,n){return Vn(r,e,1,t)}function Gl(r,e,t,n){return Vn(r,e,2,He(r,e+1,n))}function jl(r,e,t,n){return Vn(r,e,3,Ke(r,e+1,n))}function Yl(r,e,t,n){return Vn(r,e,5,$e(r,e+1,n))}function Zl(r,e,t,n){let o=qe(r,e+1,n);if(typeof o=="bigint")throw new Error(`${$} 64-bit integer bytes lengths not supported`);return Vn(r,e,9,o)}function mi(r){return r.encodedBytes===void 0&&(r.encodedBytes=r.type===m.string?_l(r.value):r.value),r.encodedBytes}function en(r,e){let t=mi(e);Be(r,e.type.majorEncoded,t.length),r.push(t)}en.encodedSize=function(e){let t=mi(e);return Be.encodedSize(t.length)+t.length};en.compareTokens=function(e,t){return gg(mi(e),mi(t))};function gg(r,e){return r.length<e.length?-1:r.length>e.length?1:Vl(r,e)}function Dn(r,e,t,n,o){let i=t+n;Ut(r,e,i);let s=new U(m.string,Nl(r,e+t,e+i),i);return o.retainStringBytes===!0&&(s.byteValue=Qr(r,e+t,e+i)),s}function Wl(r,e,t,n){return Dn(r,e,1,t,n)}function Jl(r,e,t,n){return Dn(r,e,2,He(r,e+1,n),n)}function Xl(r,e,t,n){return Dn(r,e,3,Ke(r,e+1,n),n)}function Ql(r,e,t,n){return Dn(r,e,5,$e(r,e+1,n),n)}function ef(r,e,t,n){let o=qe(r,e+1,n);if(typeof o=="bigint")throw new Error(`${$} 64-bit integer string lengths not supported`);return Dn(r,e,9,o,n)}var tf=en;function tn(r,e,t,n){return new U(m.array,n,t)}function rf(r,e,t,n){return tn(r,e,1,t)}function nf(r,e,t,n){return tn(r,e,2,He(r,e+1,n))}function of(r,e,t,n){return tn(r,e,3,Ke(r,e+1,n))}function sf(r,e,t,n){return tn(r,e,5,$e(r,e+1,n))}function af(r,e,t,n){let o=qe(r,e+1,n);if(typeof o=="bigint")throw new Error(`${$} 64-bit integer array lengths not supported`);return tn(r,e,9,o)}function cf(r,e,t,n){if(n.allowIndefinite===!1)throw new Error(`${$} indefinite length items not allowed`);return tn(r,e,1,1/0)}function yi(r,e){Be(r,m.array.majorEncoded,e.value)}yi.compareTokens=Ze.compareTokens;yi.encodedSize=function(e){return Be.encodedSize(e.value)};function rn(r,e,t,n){return new U(m.map,n,t)}function uf(r,e,t,n){return rn(r,e,1,t)}function lf(r,e,t,n){return rn(r,e,2,He(r,e+1,n))}function ff(r,e,t,n){return rn(r,e,3,Ke(r,e+1,n))}function hf(r,e,t,n){return rn(r,e,5,$e(r,e+1,n))}function df(r,e,t,n){let o=qe(r,e+1,n);if(typeof o=="bigint")throw new Error(`${$} 64-bit integer map lengths not supported`);return rn(r,e,9,o)}function pf(r,e,t,n){if(n.allowIndefinite===!1)throw new Error(`${$} indefinite length items not allowed`);return rn(r,e,1,1/0)}function wi(r,e){Be(r,m.map.majorEncoded,e.value)}wi.compareTokens=Ze.compareTokens;wi.encodedSize=function(e){return Be.encodedSize(e.value)};function gf(r,e,t,n){return new U(m.tag,t,1)}function mf(r,e,t,n){return new U(m.tag,He(r,e+1,n),2)}function yf(r,e,t,n){return new U(m.tag,Ke(r,e+1,n),3)}function wf(r,e,t,n){return new U(m.tag,$e(r,e+1,n),5)}function bf(r,e,t,n){return new U(m.tag,qe(r,e+1,n),9)}function bi(r,e){Be(r,m.tag.majorEncoded,e.value)}bi.compareTokens=Ze.compareTokens;bi.encodedSize=function(e){return Be.encodedSize(e.value)};var Eg=20,vg=21,Bg=22,Ag=23;function xf(r,e,t,n){if(n.allowUndefined===!1)throw new Error(`${$} undefined values are not supported`);return n.coerceUndefinedToNull===!0?new U(m.null,null,1):new U(m.undefined,void 0,1)}function Ef(r,e,t,n){if(n.allowIndefinite===!1)throw new Error(`${$} indefinite length items not allowed`);return new U(m.break,void 0,1)}function ga(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 U(m.float,r,e)}function vf(r,e,t,n){return ga(ma(r,e+1),3,n)}function Bf(r,e,t,n){return ga(ya(r,e+1),5,n)}function Af(r,e,t,n){return ga(Rf(r,e+1),9,n)}function xi(r,e,t){let n=e.value;if(n===!1)r.push([m.float.majorEncoded|Eg]);else if(n===!0)r.push([m.float.majorEncoded|vg]);else if(n===null)r.push([m.float.majorEncoded|Bg]);else if(n===void 0)r.push([m.float.majorEncoded|Ag]);else{let o,i=!1;(!t||t.float64!==!0)&&(If(n),o=ma(st,1),n===o||Number.isNaN(n)?(st[0]=249,r.push(st.slice(0,3)),i=!0):(kf(n),o=ya(st,1),n===o&&(st[0]=250,r.push(st.slice(0,5)),i=!0))),i||(Sg(n),o=Rf(st,1),st[0]=251,r.push(st.slice(0,9)))}}xi.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){If(n);let o=ma(st,1);if(n===o||Number.isNaN(n))return 3;if(kf(n),o=ya(st,1),n===o)return 5}return 9};var Sf=new ArrayBuffer(9),We=new DataView(Sf,1),st=new Uint8Array(Sf,0);function If(r){if(r===1/0)We.setUint16(0,31744,!1);else if(r===-1/0)We.setUint16(0,64512,!1);else if(Number.isNaN(r))We.setUint16(0,32256,!1);else{We.setFloat32(0,r);let e=We.getUint32(0),t=(e&2139095040)>>23,n=e&8388607;if(t===255)We.setUint16(0,31744,!1);else if(t===0)We.setUint16(0,(r&2147483648)>>16|n>>13,!1);else{let o=t-127;o<-24?We.setUint16(0,0):o<-14?We.setUint16(0,(e&2147483648)>>16|1<<24+o,!1):We.setUint16(0,(e&2147483648)>>16|o+15<<10|n>>13,!1)}}}function ma(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 kf(r){We.setFloat32(0,r,!1)}function ya(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 Sg(r){We.setFloat64(0,r,!1)}function Rf(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)}xi.compareTokens=Ze.compareTokens;function Q(r,e,t){throw new Error(`${$} encountered invalid minor (${t}) for major ${r[e]>>>5}`)}function Ei(r){return()=>{throw new Error(`${$} ${r}`)}}var I=[];for(let r=0;r<=23;r++)I[r]=Q;I[24]=Dl;I[25]=Ol;I[26]=Pl;I[27]=Fl;I[28]=Q;I[29]=Q;I[30]=Q;I[31]=Q;for(let r=32;r<=55;r++)I[r]=Q;I[56]=Ml;I[57]=Hl;I[58]=Kl;I[59]=ql;I[60]=Q;I[61]=Q;I[62]=Q;I[63]=Q;for(let r=64;r<=87;r++)I[r]=zl;I[88]=Gl;I[89]=jl;I[90]=Yl;I[91]=Zl;I[92]=Q;I[93]=Q;I[94]=Q;I[95]=Ei("indefinite length bytes/strings are not supported");for(let r=96;r<=119;r++)I[r]=Wl;I[120]=Jl;I[121]=Xl;I[122]=Ql;I[123]=ef;I[124]=Q;I[125]=Q;I[126]=Q;I[127]=Ei("indefinite length bytes/strings are not supported");for(let r=128;r<=151;r++)I[r]=rf;I[152]=nf;I[153]=of;I[154]=sf;I[155]=af;I[156]=Q;I[157]=Q;I[158]=Q;I[159]=cf;for(let r=160;r<=183;r++)I[r]=uf;I[184]=lf;I[185]=ff;I[186]=hf;I[187]=df;I[188]=Q;I[189]=Q;I[190]=Q;I[191]=pf;for(let r=192;r<=215;r++)I[r]=gf;I[216]=mf;I[217]=yf;I[218]=wf;I[219]=bf;I[220]=Q;I[221]=Q;I[222]=Q;I[223]=Q;for(let r=224;r<=243;r++)I[r]=Ei("simple values are not supported");I[244]=Q;I[245]=Q;I[246]=Q;I[247]=xf;I[248]=Ei("simple values are not supported");I[249]=vf;I[250]=Bf;I[251]=Af;I[252]=Q;I[253]=Q;I[254]=Q;I[255]=Ef;var at=[];for(let r=0;r<24;r++)at[r]=new U(m.uint,r,1);for(let r=-1;r>=-24;r--)at[31-r]=new U(m.negint,r,1);at[64]=new U(m.bytes,new Uint8Array(0),1);at[96]=new U(m.string,"",1);at[128]=new U(m.array,0,1);at[160]=new U(m.map,0,1);at[244]=new U(m.false,!1,1);at[245]=new U(m.true,!0,1);at[246]=new U(m.null,null,1);function kg(){let r=[];return r[m.uint.major]=Ze,r[m.negint.major]=gi,r[m.bytes.major]=en,r[m.string.major]=tf,r[m.array.major]=yi,r[m.map.major]=wi,r[m.tag.major]=bi,r[m.float.major]=xi,r}var TE=kg(),CE=new pi,vi=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(`${da} object contains circular references`);return new r(t,e)}},Qt={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)},er={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?Qt.true:Qt.false},null(r,e,t,n){return Qt.null},undefined(r,e,t,n){return Qt.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?[Qt.emptyArray,new U(m.break)]:Qt.emptyArray;n=vi.createCheck(n,r);let o=[],i=0;for(let s of r)o[i++]=wa(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?[Qt.emptyMap,new U(m.break)]:Qt.emptyMap;n=vi.createCheck(n,r);let a=[],c=0;for(let f of i)a[c++]=[wa(f,t,n),wa(o?r.get(f):r[f],t,n)];return Rg(a,t),t.addBreakTokens?[new U(m.map,s),a,new U(m.break)]:[new U(m.map,s),a]}};er.Map=er.Object;er.Buffer=er.Uint8Array;for(let r of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))er[`${r}Array`]=er.DataView;function wa(r,e={},t){let n=Il(r),o=e&&e.typeEncoders&&e.typeEncoders[n]||er[n];if(typeof o=="function"){let s=o(r,n,e,t);if(s!=null)return s}let i=er[n];if(!i)throw new Error(`${da} unsupported type: ${n}`);return i(r,n,e,t)}function Rg(r,e){e.mapSorter&&r.sort(e.mapSorter)}var Tg={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0},Bi=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=at[e];if(t===void 0){let n=I[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}},On=Symbol.for("DONE"),Ai=Symbol.for("BREAK");function Cg(r,e,t){let n=[];for(let o=0;o<r.value;o++){let i=nn(e,t);if(i===Ai){if(r.value===1/0)break;throw new Error(`${$} got unexpected break to lengthed array`)}if(i===On)throw new Error(`${$} found array but not enough entries (got ${o}, expected ${r.value})`);n[o]=i}return n}function Ng(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=nn(e,t);if(a===Ai){if(r.value===1/0)break;throw new Error(`${$} got unexpected break to lengthed map`)}if(a===On)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=nn(e,t);if(c===On)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 nn(r,e){if(r.done())return On;let t=r.next();if(t.type===m.break)return Ai;if(t.type.terminal)return t.value;if(t.type===m.array)return Cg(t,r,e);if(t.type===m.map)return Ng(t,r,e);if(t.type===m.tag){if(e.tags&&typeof e.tags[t.value]=="function"){let n=nn(r,e);return e.tags[t.value](n)}throw new Error(`${$} tag not supported (${t.value})`)}throw new Error("unsupported")}function Tf(r,e){if(!(r instanceof Uint8Array))throw new Error(`${$} data to decode must be a Uint8Array`);e=Object.assign({},Tg,e);let t=e.tokenizer||new Bi(r,e),n=nn(t,e);if(n===On)throw new Error(`${$} did not find any content to decode`);if(n===Ai)throw new Error(`${$} got unexpected break`);return[n,r.subarray(t.pos())]}function ba(r,e){let[t,n]=Tf(r,e);if(n.length>0)throw new Error(`${$} too many terminals, data makes no sense`);return t}var ze=Lt(fi(),1);var Cf=Dt("ipns:utils"),Nf=J("/ipns/"),Lg=114,_f=async(r,e)=>{if(e==null||r==null){let n=new Error("one or more of the provided parameters are not defined");throw Cf.error(n),(0,ze.default)(n,ha)}let t;if(e.pubKey!=null){try{t=ua(e.pubKey)}catch(o){throw Cf.error(o),o}if(!(await fc(e.pubKey)).equals(r))throw(0,ze.default)(new Error("Embedded public key did not match PeerID"),Bl)}else r.publicKey!=null&&(t=ua(r.publicKey));if(t!=null)return t;throw(0,ze.default)(new Error("no public key is available"),ha)};var Uf=r=>{let e=J("ipns-signature:");return Ce([e,r])},Pn=r=>"signatureV1"in r?it.encode({value:J(r.value),signatureV1:r.signatureV1,validityType:r.validityType,validity:J(r.validity),sequence:r.sequence,ttl:r.ttl,pubKey:r.pubKey,signatureV2:r.signatureV2,data:r.data}):it.encode({pubKey:r.pubKey,signatureV2:r.signatureV2,data:r.data});function tr(r){let e=it.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,ze.default)(new Error("missing data or signatureV2"),_t);let t=Vf(e.data),n=Vg(t.Value),o=Z(t.Validity);if(e.value!=null&&e.signatureV1!=null)return Dg(e),{value:n,validityType:it.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:it.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 xa=r=>Ce([Nf,r.toBytes()]),Lf=r=>fn(r.slice(Nf.length));var Vf=r=>{let e=ba(r);if(e.ValidityType===0)e.ValidityType=it.ValidityType.EOL;else throw(0,ze.default)(new Error("Unknown validity type"),hi);return Number.isInteger(e.Sequence)&&(e.Sequence=BigInt(e.Sequence)),Number.isInteger(e.TTL)&&(e.TTL=BigInt(e.TTL)),e},Vg=r=>{if(r!=null){if(Oa(r))return`/ipns/${r.toCID().toString(Yn)}`;if(r instanceof Uint8Array){let n=Z(r);n.startsWith("/")&&(r=n)}let e=r.toString().trim();if(e.startsWith("/")&&e.length>1)return e;let t=Te.asCID(r);if(t!=null)return t.code===Lg?`/ipns/${t.toString(Yn)}`:`/ipfs/${t.toV1().toString()}`;try{return r instanceof Uint8Array?`/ipfs/${Te.decode(r).toV1().toString()}`:`/ipfs/${Te.parse(e).toV1().toString()}`}catch{}}throw(0,ze.default)(new Error("Value must be a valid content path starting with /"),vl)},Dg=r=>{if(r.data==null)throw(0,ze.default)(new Error("Record data is missing"),El);let e=Vf(r.data);if(!he(e.Value,r.value??new Uint8Array(0)))throw(0,ze.default)(new Error('Field "value" did not match between protobuf and CBOR'),_t);if(!he(e.Validity,r.validity??new Uint8Array(0)))throw(0,ze.default)(new Error('Field "validity" did not match between protobuf and CBOR'),_t);if(e.ValidityType!==r.validityType)throw(0,ze.default)(new Error('Field "validityType" did not match between protobuf and CBOR'),_t);if(e.Sequence!==r.sequence)throw(0,ze.default)(new Error('Field "sequence" did not match between protobuf and CBOR'),_t);if(e.TTL!==r.ttl)throw(0,ze.default)(new Error('Field "ttl" did not match between protobuf and CBOR'),_t)};var o2=Dt("ipns"),i2=ut.code,s2=60*60*1e9,Fg="/ipns/",a2=Fg.length;var Fn=Lt(fi(),1),Df=Lt(fa(),1);var Si=Dt("ipns:validator"),Mg=1024*10,Hg=async(r,e)=>{let t=tr(e),n;try{let o=Uf(t.data);n=await r.verify(o,t.signatureV2)}catch{n=!1}if(!n)throw Si.error("record signature verification failed"),(0,Fn.default)(new Error("record signature verification failed"),_t);if(t.validityType===it.ValidityType.EOL){if(Df.default.fromString(t.validity).toDate().getTime()<Date.now())throw Si.error("record has expired"),(0,Fn.default)(new Error("record has expired"),xl)}else if(t.validityType!=null)throw Si.error("unrecognized validity type"),(0,Fn.default)(new Error("unrecognized validity type"),hi);Si("ipns record for %s is valid",t.value)};async function Of(r,e){if(e.byteLength>Mg)throw(0,Fn.default)(new Error("record too large"),Al);let t=Lf(r),n=tr(e),o=await _f(t,n);await Hg(o,e)}async function*Mn(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 gt(){let r={};return r.promise=new Promise((e,t)=>{r.resolve=e,r.reject=t}),r}var va=Lt(Ff(),1);var Kn=class extends Error{constructor(e){super(e),this.name="TimeoutError"}},Ba=class extends Error{constructor(e){super(),this.name="AbortError",this.message=e}},Mf=r=>globalThis.DOMException===void 0?new Ba(r):new DOMException(r),Hf=r=>{let e=r.reason===void 0?Mf("This operation was aborted."):r.reason;return e instanceof Error?e:Mf(e)};function Aa(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(Hf(d)),d.addEventListener("abort",()=>{u(Hf(d))})}if(t===Number.POSITIVE_INFINITY){r.then(f,u);return}let l=new Kn;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 Sa(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 $n=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=Sa(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 qn=class extends va.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:$n,...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=Aa(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 Kn&&!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 qg(r){return r[Symbol.asyncIterator]!=null}function zg(r){if(qg(r))return(async()=>{for await(let e of r)return e})();for(let e of r)return e}var Kf=zg;function Gg(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 $f=Gg;function jg(r){return r[Symbol.asyncIterator]!=null}function Yg(r,e){if(jg(r))return async function*(){for await(let a of r)yield e(a)}();let t=$f(r),{value:n,done:o}=t.next();if(o===!0)return function*(){}();let i=e(n);if(typeof i.then=="function")return async function*(){yield await i;for await(let a of t)yield e(a)}();let s=e;return function*(){yield i;for(let a of t)yield s(a)}()}var qf=Yg;var Ia=J("/ipns/");function zf(r){return he(r.subarray(0,Ia.byteLength),Ia)}var Gf=r=>fn(r.slice(Ia.length)),ki=class{client;constructor(e){this.client=e}async*findProviders(e,t={}){yield*qf(this.client.getProviders(e,t),n=>({id:n.ID,multiaddrs:n.Addrs??[]}))}async provide(){}async put(e,t,n){if(!zf(e))return;let o=Gf(e),i=tr(t);await this.client.putIPNS(o,i,n)}async get(e,t){if(!zf(e))throw new P("Not found","ERR_NOT_FOUND");let n=Gf(e);try{let o=await this.client.getIPNS(n,t);return Pn(o)}catch(o){throw o.code==="ERR_BAD_RESPONSE"?new P("Not found","ERR_NOT_FOUND"):o}}},Ri=class{client;constructor(e){this.client=e}async findPeer(e,t={}){let n=await Kf(this.client.getPeers(e,t));if(n!=null)return{id:n.ID,multiaddrs:n.Addrs??[]};throw new P("Not found","ERR_NOT_FOUND")}async*getClosestPeers(e,t={}){}};var De=Dt("delegated-routing-v1-http-api-client"),jf={concurrentRequests:4,timeout:3e4},Ti=class{started;httpQueue;shutDownController;clientUrl;timeout;contentRouting;peerRouting;constructor(e,t={}){this.started=!1,this.shutDownController=new AbortController,mr(1/0,this.shutDownController.signal),this.httpQueue=new qn({concurrency:t.concurrentRequests??jf.concurrentRequests}),this.clientUrl=e instanceof URL?e:new URL(e),this.timeout=t.timeout??jf.timeout,this.contentRouting=new ki(this),this.peerRouting=new Ri(this)}get[Da](){return this.contentRouting}get[Pa](){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={}){De("getProviders starts: %c",e);let n=AbortSignal.timeout(this.timeout),o=dn([this.shutDownController.signal,n,t.signal]);mr(1/0,n,o);let i=gt(),s=gt();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 P("No matching records found.","ERR_NOT_FOUND");if(f.status===422)throw new P("Request does not conform to schema or semantic constraints.","ERR_INVALID_REQUEST");if(f.body==null)throw new P("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 E=this.#e(d);E!=null&&(yield E)}}else for await(let l of Mn(to(f.body))){let d=this.#e(l);d!=null&&(yield d)}}catch(a){De.error("getProviders errored:",a)}finally{o.clear(),s.resolve(),De("getProviders finished: %c",e)}}async*getPeers(e,t={}){De("getPeers starts: %c",e);let n=AbortSignal.timeout(this.timeout),o=dn([this.shutDownController.signal,n,t.signal]);mr(1/0,n,o);let i=gt(),s=gt();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 P("No matching records found.","ERR_NOT_FOUND");if(f.status===422)throw new P("Request does not conform to schema or semantic constraints.","ERR_INVALID_REQUEST");if(f.body==null)throw new P("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 E=this.#e(d);E!=null&&(yield E)}}else for await(let l of Mn(to(f.body))){let d=this.#e(l);d!=null&&(yield d)}}catch(a){De.error("getPeers errored:",a)}finally{o.clear(),s.resolve(),De("getPeers finished: %c",e)}}async getIPNS(e,t={}){De("getIPNS starts: %c",e);let n=AbortSignal.timeout(this.timeout),o=dn([this.shutDownController.signal,n,t.signal]);mr(1/0,n,o);let i=gt(),s=gt();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(De("getIPNS GET %s %d",a,f.status),f.status===404)throw new P("No matching records found.","ERR_NOT_FOUND");if(f.status===422)throw new P("Request does not conform to schema or semantic constraints.","ERR_INVALID_REQUEST");if(f.body==null)throw new P("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 Of(xa(e),l),tr(l)}catch(c){throw De.error("getIPNS GET %s error:",a,c),c}finally{o.clear(),s.resolve(),De("getIPNS finished: %c",e)}}async putIPNS(e,t,n={}){De("putIPNS starts: %c",e);let o=AbortSignal.timeout(this.timeout),i=dn([this.shutDownController.signal,o,n.signal]);mr(1/0,o,i);let s=gt(),a=gt();this.httpQueue.add(async()=>(s.resolve(),a.promise));let c=`${this.clientUrl}routing/v1/ipns/${e.toCID().toString()}`;try{await s.promise;let f=Pn(t),l=await fetch(c,{method:"PUT",headers:{"Content-Type":"application/vnd.ipfs.ipns-record"},body:f,signal:i});if(De("putIPNS PUT %s %d",c,l.status),l.status!==200)throw new P("PUT ipns response had status other than 200","ERR_BAD_RESPONSE")}catch(f){throw De.error("putIPNS PUT %s error:",c,f.stack),f}finally{i.clear(),a.resolve(),De("putIPNS finished: %c",e)}}#e(e){let t=[],n=e.Addrs?.map(hn)??[];return e.Protocols!=null&&t.push(...e.Protocols),e.Protocol!=null&&(t.push(e.Protocol),delete e.Protocol),{...e,Schema:"peer",ID:es(e.ID),Addrs:n,Protocols:t}}};function Zg(r,e={}){return new Ti(new URL(r),e)}return ah(Wg);})();
7
+ `)}`:`${t} :`}};xu=Yt;U.Constructed=xu;Yt.NAME="CONSTRUCTED";var To=class extends Ie{fromBER(e,t,n){return t}toBER(e){return ot}};To.override="EndOfContentValueBlock";var Eu,Co=class extends Ee{constructor(e={}){super(e,To),this.idBlock.tagClass=1,this.idBlock.tagNumber=0}};Eu=Co;U.EndOfContent=Eu;Co.NAME=vn;var vu,Zt=class extends Ee{constructor(e={}){super(e,Ie),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}`}};vu=Zt;U.Null=vu;Zt.NAME="NULL";var No=class extends Tt(Ie){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 kt(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}}};No.NAME="BooleanValueBlock";var Bu,_o=class extends Ee{constructor(e={}){super(e,No),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}`}};Bu=_o;U.Boolean=Bu;_o.NAME="BOOLEAN";var Uo=class extends Tt(ht){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=ht.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===vn){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, OCTET STRING may consists of OCTET STRINGs only",-1}if(s!==gu)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?ht.prototype.toBER.call(this,e,t):e?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),isConstructed:this.isConstructed}}};Uo.NAME="OctetStringValueBlock";var Au,It=class r extends Ee{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},Uo),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=ai(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?Yt.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)}};Au=It;U.OctetString=Au;It.NAME=gu;var Lo=class extends Tt(ht){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=ht.prototype.fromBER.call(this,e,t,n),o===-1)return o;for(let a of this.value){let c=a.constructor.NAME;if(c===vn){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, BIT STRING may consists of BIT STRINGs only",-1}if(c!==yu)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(!kt(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=ai(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 ht.prototype.toBER.call(this,e,t);if(e)return new ArrayBuffer(this.valueHexView.byteLength+1);if(!this.valueHexView.byteLength)return ot;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}}};Lo.NAME="BitStringValueBlock";var Su,qr=class extends Ee{constructor({idBlock:e={},lenBlock:t={},...n}={}){var o,i;(o=n.isConstructed)!==null&&o!==void 0||(n.isConstructed=!!(!((i=n.value)===null||i===void 0)&&i.length)),super({idBlock:{isConstructed:n.isConstructed,...e},lenBlock:{...t,isIndefiniteForm:!!n.isIndefiniteForm},...n},Lo),this.idBlock.tagClass=1,this.idBlock.tagNumber=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 Yt.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)}`}}};Su=qr;U.BitString=Su;qr.NAME=yu;var Iu;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 h=u;h>=0;h--,l++){switch(!0){case l<a.length:f=i[s-l]+a[c-l]+t[0];break;default:f=i[s-l]+t[0]}switch(t[0]=f/10,!0){case l>=i.length:i=vo(new Uint8Array([f%10]),i);break;default:i[s-l]=f%10}}return t[0]>0&&(i=vo(t,i)),i}function mu(r){if(r>=xn.length)for(let e=xn.length;e<=r;e++){let t=new Uint8Array([0]),n=xn[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=vo(t,n)),xn.push(n)}return xn[r]}function Rp(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 Bn=class extends Tt(Ie){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(hu(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=Rp(mu(n),t),s="-";break;default:t=Ip(t,mu(n))}n++,o>>=1}}for(let c=0;c<t.length;c++)t[c]&&(a=!0),a&&(s+=pu.charAt(t[c]));return a===!1&&(s+=pu.charAt(0)),s}};Iu=Bn;Bn.NAME="IntegerValueBlock";Object.defineProperty(Iu.prototype,"valueHex",{set:function(r){this.valueHexView=new Uint8Array(r),this.setValueHex()},get:function(){return this.valueHexView.slice().buffer}});var Ru,le=class r extends Ee{constructor(e={}){super(e,Bn),this.idBlock.tagClass=1,this.idBlock.tagNumber=2}toBigInt(){return Bo(),BigInt(this.valueBlock.toString())}static fromBigInt(e){Bo();let t=BigInt(e),n=new En,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()}`}};Ru=le;U.Integer=Ru;le.NAME="INTEGER";var ku,Vo=class extends le{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=10}};ku=Vo;U.Enumerated=ku;Vo.NAME="ENUMERATED";var An=class extends Tt(Ie){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(!kt(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=pr(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),t+this.blockLength)}set valueBigInt(e){Bo();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=jt(this.valueDec,7);if(t.byteLength===0)return this.error="Error during encoding SID value",ot;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}}};An.NAME="sidBlock";var Oo=class extends Ie{constructor({value:e=zr,...t}={}){super(t),this.value=[],e&&this.fromString(e)}fromBER(e,t,n){let o=t;for(;n>0;){let i=new An;if(o=i.fromBER(e,o,n),o===-1)return this.blockLength=0,this.error=i.error,o;this.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,ot;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 An;if(o>Number.MAX_SAFE_INTEGER){Bo();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}};Oo.NAME="ObjectIdentifierValueBlock";var Tu,nt=class extends Ee{constructor(e={}){super(e,Oo),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()}}};Tu=nt;U.ObjectIdentifier=Tu;nt.NAME="OBJECT IDENTIFIER";var Sn=class extends Tt(St){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(!kt(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=pr(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=jt(this.valueDec,7);if(t.byteLength===0)return this.error="Error during encoding SID value",ot;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}}};Sn.NAME="relativeSidBlock";var Do=class extends Ie{constructor({value:e=zr,...t}={}){super(t),this.value=[],e&&this.fromString(e)}fromBER(e,t,n){let o=t;for(;n>0;){let i=new Sn;if(o=i.fromBER(e,o,n),o===-1)return this.blockLength=0,this.error=i.error,o;this.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,ot;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 Sn;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}};Do.NAME="RelativeObjectIdentifierValueBlock";var Cu,Po=class extends Ee{constructor(e={}){super(e,Do),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()}}};Cu=Po;U.RelativeObjectIdentifier=Cu;Po.NAME="RelativeObjectIdentifier";var Nu,ge=class extends Yt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=16}};Nu=ge;U.Sequence=Nu;ge.NAME="SEQUENCE";var _u,Fo=class extends Yt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=17}};_u=Fo;U.Set=_u;Fo.NAME="SET";var Mo=class extends Tt(Ie){constructor({...e}={}){super(e),this.isHexOnly=!0,this.value=zr}toJSON(){return{...super.toJSON(),value:this.value}}};Mo.NAME="StringValueBlock";var Ho=class extends Mo{};Ho.NAME="SimpleStringValueBlock";var Ne=class extends Io{constructor({...e}={}){super(e,Ho)}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}};Ne.NAME="SIMPLE STRING";var Ko=class extends Ne{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}};Ko.NAME="Utf8StringValueBlock";var Uu,Rt=class extends Ko{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=12}};Uu=Rt;U.Utf8String=Uu;Rt.NAME="UTF8String";var $o=class extends Ne{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))}};$o.NAME="BmpStringValueBlock";var Lu,qo=class extends $o{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=30}};Lu=qo;U.BmpString=Lu;qo.NAME="BMPString";var zo=class extends Ne{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=jt(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}};zo.NAME="UniversalStringValueBlock";var Vu,Go=class extends zo{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=28}};Vu=Go;U.UniversalString=Vu;Go.NAME="UniversalString";var Ou,jo=class extends Ne{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=18}};Ou=jo;U.NumericString=Ou;jo.NAME="NumericString";var Du,Yo=class extends Ne{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=19}};Du=Yo;U.PrintableString=Du;Yo.NAME="PrintableString";var Pu,Zo=class extends Ne{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=20}};Pu=Zo;U.TeletexString=Pu;Zo.NAME="TeletexString";var Fu,Wo=class extends Ne{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=21}};Fu=Wo;U.VideotexString=Fu;Wo.NAME="VideotexString";var Mu,Jo=class extends Ne{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=22}};Mu=Jo;U.IA5String=Mu;Jo.NAME="IA5String";var Hu,Xo=class extends Ne{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=25}};Hu=Xo;U.GraphicString=Hu;Xo.NAME="GraphicString";var Ku,In=class extends Ne{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=26}};Ku=In;U.VisibleString=Ku;In.NAME="VisibleString";var $u,Qo=class extends Ne{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=27}};$u=Qo;U.GeneralString=$u;Qo.NAME="GeneralString";var qu,ei=class extends Ne{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=29}};qu=ei;U.CharacterString=qu;ei.NAME="CharacterString";var zu,Rn=class extends In{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]=Pe(this.year<2e3?this.year-1900:this.year-2e3,2),t[1]=Pe(this.month,2),t[2]=Pe(this.day,2),t[3]=Pe(this.hour,2),t[4]=Pe(this.minute,2),t[5]=Pe(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}}};zu=Rn;U.UTCTime=zu;Rn.NAME="UTCTime";var Gu,ti=class extends Rn{constructor(e={}){var t;super(e),(t=this.millisecond)!==null&&t!==void 0||(this.millisecond=0),this.idBlock.tagClass=1,this.idBlock.tagNumber=24}fromDate(e){super.fromDate(e),this.millisecond=e.getUTCMilliseconds()}toDate(){return new Date(Date.UTC(this.year,this.month-1,this.day,this.hour,this.minute,this.second,this.millisecond))}fromString(e){let t=!1,n="",o="",i=0,s,a=0,c=0;if(e[e.length-1]==="Z")n=e.substring(0,e.length-1),t=!0;else{let l=new Number(e[e.length-1]);if(isNaN(l.valueOf()))throw new Error("Wrong input string for conversion");n=e}if(t){if(n.indexOf("+")!==-1)throw new Error("Wrong input string for conversion");if(n.indexOf("-")!==-1)throw new Error("Wrong input string for conversion")}else{let l=1,h=n.indexOf("+"),w="";if(h===-1&&(h=n.indexOf("-"),l=-1),h!==-1){if(w=n.substring(h+1),n=n.substring(0,h),w.length!==2&&w.length!==4)throw new Error("Wrong input string for conversion");let B=parseInt(w.substring(0,2),10);if(isNaN(B.valueOf()))throw new Error("Wrong input string for conversion");if(a=l*B,w.length===4){if(B=parseInt(w.substring(2,4),10),isNaN(B.valueOf()))throw new Error("Wrong input string for conversion");c=l*B}}}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(Pe(this.year,4)),t.push(Pe(this.month,2)),t.push(Pe(this.day,2)),t.push(Pe(this.hour,2)),t.push(Pe(this.minute,2)),t.push(Pe(this.second,2)),this.millisecond!==0&&(t.push("."),t.push(Pe(this.millisecond,3))),t.push("Z"),t.join("")}return super.toString(e)}toJSON(){return{...super.toJSON(),millisecond:this.millisecond}}};Gu=ti;U.GeneralizedTime=Gu;ti.NAME="GeneralizedTime";var ju,ri=class extends Rt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=31}};ju=ri;U.DATE=ju;ri.NAME="DATE";var Yu,ni=class extends Rt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=32}};Yu=ni;U.TimeOfDay=Yu;ni.NAME="TimeOfDay";var Zu,oi=class extends Rt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=33}};Zu=oi;U.DateTime=Zu;oi.NAME="DateTime";var Wu,ii=class extends Rt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=34}};Wu=ii;U.Duration=Wu;ii.NAME="Duration";var Ju,si=class extends Rt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=14}};Ju=si;U.TIME=Ju;si.NAME="TIME";function Tp(r){let{result:e}=Gr(r),t=e.valueBlock.value;return{n:z(dt(t[1].toBigInt()),"base64url"),e:z(dt(t[2].toBigInt()),"base64url"),d:z(dt(t[3].toBigInt()),"base64url"),p:z(dt(t[4].toBigInt()),"base64url"),q:z(dt(t[5].toBigInt()),"base64url"),dp:z(dt(t[6].toBigInt()),"base64url"),dq:z(dt(t[7].toBigInt()),"base64url"),qi:z(dt(t[8].toBigInt()),"base64url"),kty:"RSA",alg:"RS256"}}function Cp(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 P("JWK was missing components","ERR_INVALID_PARAMETERS");let t=new ge({value:[new le({value:0}),le.fromBigInt(pt(Y(r.n,"base64url"))),le.fromBigInt(pt(Y(r.e,"base64url"))),le.fromBigInt(pt(Y(r.d,"base64url"))),le.fromBigInt(pt(Y(r.p,"base64url"))),le.fromBigInt(pt(Y(r.q,"base64url"))),le.fromBigInt(pt(Y(r.dp,"base64url"))),le.fromBigInt(pt(Y(r.dq,"base64url"))),le.fromBigInt(pt(Y(r.qi,"base64url")))]}).toBER();return new Uint8Array(t,0,t.byteLength)}function Np(r){let{result:e}=Gr(r),t=e.valueBlock.value[1].valueBlock.value[0].valueBlock.value;return{kty:"RSA",n:z(dt(t[0].toBigInt()),"base64url"),e:z(dt(t[1].toBigInt()),"base64url")}}function _p(r){if(r.n==null||r.e==null)throw new P("JWK was missing components","ERR_INVALID_PARAMETERS");let t=new ge({value:[new ge({value:[new nt({value:"1.2.840.113549.1.1.1"}),new Zt]}),new qr({valueHex:new ge({value:[le.fromBigInt(pt(Y(r.n,"base64url"))),le.fromBigInt(pt(Y(r.e,"base64url")))]}).toBER()})]}).toBER();return new Uint8Array(t,0,t.byteLength)}function dt(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 pt(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 Up=16,ia=32,sa=1e4;async function Lp(r,e){let t=Ce.get(),o=new ge({value:[new le({value:0}),new ge({value:[new nt({value:"1.2.840.113549.1.1.1"}),new Zt]}),new It({valueHex:r.marshal()})]}).toBER(),i=new Uint8Array(o,0,o.byteLength),s=dr(Up),a=await ea(fn,e,s,{c:sa,dkLen:ia}),c=dr(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 ge({value:[new It({valueHex:s}),new le({value:sa}),new le({value:ia}),new ge({value:[new nt({value:"1.2.840.113549.2.11"}),new Zt]})]}),h=new ge({value:[new nt({value:"1.2.840.113549.1.5.13"}),new ge({value:[new ge({value:[new nt({value:"1.2.840.113549.1.5.12"}),l]}),new ge({value:[new nt({value:"2.16.840.1.101.3.4.1.42"}),new It({valueHex:c})]})]})]}),B=new ge({value:[h,new It({valueHex:u})]}).toBER(),m=new Uint8Array(B,0,B.byteLength);return["-----BEGIN ENCRYPTED PRIVATE KEY-----",...z(m,"base64pad").split(/(.{64})/).filter(Boolean),"-----END ENCRYPTED PRIVATE KEY-----"].join(`
8
+ `)}async function Vp(r,e){let t=Ce.get(),n;if(r.includes("-----BEGIN ENCRYPTED PRIVATE KEY-----")){let o=Y(r.replace("-----BEGIN ENCRYPTED PRIVATE KEY-----","").replace("-----END ENCRYPTED PRIVATE KEY-----","").replace(/\n/g,"").trim(),"base64pad"),{result:i}=Gr(o),{iv:s,salt:a,iterations:c,keySize:f,cipherText:u}=Op(i),l=await ea(fn,e,a,{c,dkLen:f}),h=await t.subtle.importKey("raw",l,"AES-CBC",!1,["decrypt"]),w=kn(await t.subtle.decrypt({name:"AES-CBC",iv:s},h,u)),{result:B}=Gr(w);n=Xu(B)}else if(r.includes("-----BEGIN PRIVATE KEY-----")){let o=Y(r.replace("-----BEGIN PRIVATE KEY-----","").replace("-----END PRIVATE KEY-----","").replace(/\n/g,"").trim(),"base64pad"),{result:i}=Gr(o);n=Xu(i)}else throw new P("Could not parse private key from PEM data","ERR_INVALID_PARAMETERS");return aa(n)}function Op(r){let e=r.valueBlock.value[0];if(e.valueBlock.value[0].toString()!=="OBJECT IDENTIFIER : 1.2.840.113549.1.5.13")throw new P("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 P("Only pkcs5PBKDF2 key derivation functions are supported","ERR_INVALID_PARAMS");let i=n.valueBlock.value[1],s=kn(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 P("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 P("Only AES-CBC encryption schemes are supported","ERR_INVALID_PARAMS")}}}}let l=kn(f.valueBlock.value[1].getValue());return{cipherText:kn(r.valueBlock.value[1].getValue()),salt:s,iterations:a,keySize:c,iv:l}}function Xu(r){return kn(r.valueBlock.value[2].getValue())}function kn(r){return new Uint8Array(r,0,r.byteLength)}async function Qu(r){let e=await Ce.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 rl(e);return{privateKey:t[0],publicKey:t[1]}}async function ca(r){let t=[await Ce.get().subtle.importKey("jwk",r,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["sign"]),await Dp(r)],n=await rl({privateKey:t[0],publicKey:t[1]});return{privateKey:n[0],publicKey:n[1]}}async function el(r,e){let t=await Ce.get().subtle.importKey("jwk",r,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["sign"]),n=await Ce.get().subtle.sign({name:"RSASSA-PKCS1-v1_5"},t,e instanceof Uint8Array?e:e.subarray());return new Uint8Array(n,0,n.byteLength)}async function tl(r,e,t){let n=await Ce.get().subtle.importKey("jwk",r,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["verify"]);return Ce.get().subtle.verify({name:"RSASSA-PKCS1-v1_5"},n,e,t instanceof Uint8Array?t:t.subarray())}async function rl(r){if(r.privateKey==null||r.publicKey==null)throw new P("Private and public key are required","ERR_INVALID_PARAMETERS");return Promise.all([Ce.get().subtle.exportKey("jwk",r.privateKey),Ce.get().subtle.exportKey("jwk",r.publicKey)])}async function Dp(r){return Ce.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 ci(r){if(r.kty!=="RSA")throw new P("invalid key type","ERR_INVALID_KEY_TYPE");if(r.n==null)throw new P("invalid key modulus","ERR_INVALID_KEY_MODULUS");return Y(r.n,"base64url").length*8}var Cn=8192,Tn=class{_key;constructor(e){this._key=e}verify(e,t){return tl(this._key,t,e)}marshal(){return Wt.jwkToPkix(this._key)}get bytes(){return ft.encode({Type:ce.RSA,Data:this.marshal()}).subarray()}equals(e){return ue(this.bytes,e.bytes)}hash(){let e=xe.digest(this.bytes);return Ge(e)?e.then(({bytes:t})=>t):e.bytes}},jr=class{_key;_publicKey;constructor(e,t){this._key=e,this._publicKey=t}genSecret(){return dr(16)}sign(e){return el(this._key,e)}get public(){if(this._publicKey==null)throw new P("public key not provided","ERR_PUBKEY_NOT_PROVIDED");return new Tn(this._publicKey)}marshal(){return Wt.jwkToPkcs1(this._key)}get bytes(){return Bt.encode({Type:ce.RSA,Data:this.marshal()}).subarray()}equals(e){return ue(this.bytes,e.bytes)}hash(){let e=xe.digest(this.bytes);return Ge(e)?e.then(({bytes:t})=>t):e.bytes}async id(){let e=await this.public.hash();return z(e,"base58btc")}async export(e,t="pkcs-8"){if(t==="pkcs-8")return Wt.exportToPem(this,e);if(t==="libp2p-key")return Dr(this.bytes,e);throw new P(`export format '${t}' is not supported`,"ERR_INVALID_EXPORT_FORMAT")}};async function aa(r){let e=Wt.pkcs1ToJwk(r);if(ci(e)>Cn)throw new P("key size is too large","ERR_KEY_SIZE_TOO_LARGE");let t=await ca(e);return new jr(t.privateKey,t.publicKey)}function Fp(r){let e=Wt.pkixToJwk(r);if(ci(e)>Cn)throw new P("key size is too large","ERR_KEY_SIZE_TOO_LARGE");return new Tn(e)}async function Mp(r){if(ci(r)>Cn)throw new P("key size is too large","ERR_KEY_SIZE_TOO_LARGE");let e=await ca(r);return new jr(e.privateKey,e.publicKey)}async function Hp(r){if(r>Cn)throw new P("key size is too large","ERR_KEY_SIZE_TOO_LARGE");let e=await Qu(r);return new jr(e.privateKey,e.publicKey)}var pa={};me(pa,{Secp256k1PrivateKey:()=>_n,Secp256k1PublicKey:()=>Nn,generateKeyPair:()=>em,unmarshalSecp256k1PrivateKey:()=>Xp,unmarshalSecp256k1PublicKey:()=>Qp});var Kp=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]),Jt=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Xt=new Uint32Array(64),la=class extends Ur{constructor(){super(64,32,8,!1),this.A=Jt[0]|0,this.B=Jt[1]|0,this.C=Jt[2]|0,this.D=Jt[3]|0,this.E=Jt[4]|0,this.F=Jt[5]|0,this.G=Jt[6]|0,this.H=Jt[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)Xt[l]=e.getUint32(t,!1);for(let l=16;l<64;l++){let h=Xt[l-15],w=Xt[l-2],B=Qe(h,7)^Qe(h,18)^h>>>3,m=Qe(w,17)^Qe(w,19)^w>>>10;Xt[l]=m+Xt[l-7]+B+Xt[l-16]|0}let{A:n,B:o,C:i,D:s,E:a,F:c,G:f,H:u}=this;for(let l=0;l<64;l++){let h=Qe(a,6)^Qe(a,11)^Qe(a,25),w=u+h+Oc(a,c,f)+Kp[l]+Xt[l]|0,m=(Qe(n,2)^Qe(n,13)^Qe(n,22))+Dc(n,o,i)|0;u=f,f=c,c=a,a=s+w|0,s=i,i=o,o=n,n=w+m|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(){Xt.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var nl=io(()=>new la);function ol(r){r.lowS!==void 0&&et("lowS",r.lowS),r.prehash!==void 0&&et("prehash",r.prehash)}function $p(r){let e=pn(r);lt(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:qp,hexToBytes:zp}=co,Ct={Err:class extends Error{constructor(e=""){super(e)}},_tlv:{encode:(r,e)=>{let{Err:t}=Ct;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=ir(n);if(o.length/2&128)throw new t("tlv.encode: long form length too big");let i=n>127?ir(o.length/2|128):"";return`${ir(r)}${i}${o}${e}`},decode(r,e){let{Err:t}=Ct,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}=Ct;if(r<Nt)throw new e("integer: negative integers are not allowed");let t=ir(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}=Ct;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 qp(r)}},toSig(r){let{Err:e,_int:t,_tlv:n}=Ct,o=typeof r=="string"?zp(r):r;Lr(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}=Ct,n=`${e.encode(2,t.encode(r.r))}${e.encode(2,t.encode(r.s))}`;return e.encode(48,n)}},Nt=BigInt(0),ye=BigInt(1),t1=BigInt(2),il=BigInt(3),r1=BigInt(4);function Gp(r){let e=$p(r),{Fp:t}=e,n=zt(e.n,e.nBitLength),o=e.toBytes||((m,d,E)=>{let R=d.toAffine();return Et(Uint8Array.from([4]),t.toBytes(R.x),t.toBytes(R.y))}),i=e.fromBytes||(m=>{let d=m.subarray(1),E=t.fromBytes(d.subarray(0,t.BYTES)),R=t.fromBytes(d.subarray(t.BYTES,2*t.BYTES));return{x:E,y:R}});function s(m){let{a:d,b:E}=e,R=t.sqr(m),y=t.mul(R,m);return t.add(t.add(y,t.mul(m,d)),E)}if(!t.eql(t.sqr(e.Gy),s(e.Gx)))throw new Error("bad generator point: equation left != right");function a(m){return hn(m,ye,e.n)}function c(m){let{allowedPrivateKeyLengths:d,nByteLength:E,wrapPrivateKey:R,n:y}=e;if(d&&typeof m!="bigint"){if(Kt(m)&&(m=bt(m)),typeof m!="string"||!d.includes(m.length))throw new Error("Invalid key");m=m.padStart(E*2,"0")}let k;try{k=typeof m=="bigint"?m:xt(se("private key",m,E))}catch{throw new Error(`private key must be ${E} bytes, hex or bigint, not ${typeof m}`)}return R&&(k=ee(k,y)),Oe("private key",k,ye,y),k}function f(m){if(!(m instanceof h))throw new Error("ProjectivePoint expected")}let u=cr((m,d)=>{let{px:E,py:R,pz:y}=m;if(t.eql(y,t.ONE))return{x:E,y:R};let k=m.is0();d==null&&(d=k?t.ONE:t.inv(y));let D=t.mul(E,d),V=t.mul(R,d),N=t.mul(y,d);if(k)return{x:t.ZERO,y:t.ZERO};if(!t.eql(N,t.ONE))throw new Error("invZ was invalid");return{x:D,y:V}}),l=cr(m=>{if(m.is0()){if(e.allowInfinityPoint&&!t.is0(m.py))return;throw new Error("bad point: ZERO")}let{x:d,y:E}=m.toAffine();if(!t.isValid(d)||!t.isValid(E))throw new Error("bad point: x or y not FE");let R=t.sqr(E),y=s(d);if(!t.eql(R,y))throw new Error("bad point: equation left != right");if(!m.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class h{constructor(d,E,R){if(this.px=d,this.py=E,this.pz=R,d==null||!t.isValid(d))throw new Error("x required");if(E==null||!t.isValid(E))throw new Error("y required");if(R==null||!t.isValid(R))throw new Error("z required");Object.freeze(this)}static fromAffine(d){let{x:E,y:R}=d||{};if(!d||!t.isValid(E)||!t.isValid(R))throw new Error("invalid affine point");if(d instanceof h)throw new Error("projective point not allowed");let y=k=>t.eql(k,t.ZERO);return y(E)&&y(R)?h.ZERO:new h(E,R,t.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(d){let E=t.invertBatch(d.map(R=>R.pz));return d.map((R,y)=>R.toAffine(E[y])).map(h.fromAffine)}static fromHex(d){let E=h.fromAffine(i(se("pointHex",d)));return E.assertValidity(),E}static fromPrivateKey(d){return h.BASE.multiply(c(d))}static msm(d,E){return fo(h,n,d,E)}_setWindowSize(d){B.setWindowSize(this,d)}assertValidity(){l(this)}hasEvenY(){let{y:d}=this.toAffine();if(t.isOdd)return!t.isOdd(d);throw new Error("Field doesn't support isOdd")}equals(d){f(d);let{px:E,py:R,pz:y}=this,{px:k,py:D,pz:V}=d,N=t.eql(t.mul(E,V),t.mul(k,y)),b=t.eql(t.mul(R,V),t.mul(D,y));return N&&b}negate(){return new h(this.px,t.neg(this.py),this.pz)}double(){let{a:d,b:E}=e,R=t.mul(E,il),{px:y,py:k,pz:D}=this,V=t.ZERO,N=t.ZERO,b=t.ZERO,v=t.mul(y,y),F=t.mul(k,k),_=t.mul(D,D),C=t.mul(y,k);return C=t.add(C,C),b=t.mul(y,D),b=t.add(b,b),V=t.mul(d,b),N=t.mul(R,_),N=t.add(V,N),V=t.sub(F,N),N=t.add(F,N),N=t.mul(V,N),V=t.mul(C,V),b=t.mul(R,b),_=t.mul(d,_),C=t.sub(v,_),C=t.mul(d,C),C=t.add(C,b),b=t.add(v,v),v=t.add(b,v),v=t.add(v,_),v=t.mul(v,C),N=t.add(N,v),_=t.mul(k,D),_=t.add(_,_),v=t.mul(_,C),V=t.sub(V,v),b=t.mul(_,F),b=t.add(b,b),b=t.add(b,b),new h(V,N,b)}add(d){f(d);let{px:E,py:R,pz:y}=this,{px:k,py:D,pz:V}=d,N=t.ZERO,b=t.ZERO,v=t.ZERO,F=e.a,_=t.mul(e.b,il),C=t.mul(E,k),$=t.mul(R,D),S=t.mul(y,V),I=t.add(E,R),g=t.add(k,D);I=t.mul(I,g),g=t.add(C,$),I=t.sub(I,g),g=t.add(E,y);let p=t.add(k,V);return g=t.mul(g,p),p=t.add(C,S),g=t.sub(g,p),p=t.add(R,y),N=t.add(D,V),p=t.mul(p,N),N=t.add($,S),p=t.sub(p,N),v=t.mul(F,g),N=t.mul(_,S),v=t.add(N,v),N=t.sub($,v),v=t.add($,v),b=t.mul(N,v),$=t.add(C,C),$=t.add($,C),S=t.mul(F,S),g=t.mul(_,g),$=t.add($,S),S=t.sub(C,S),S=t.mul(F,S),g=t.add(g,S),C=t.mul($,g),b=t.add(b,C),C=t.mul(p,g),N=t.mul(I,N),N=t.sub(N,C),C=t.mul(I,$),v=t.mul(p,v),v=t.add(v,C),new h(N,b,v)}subtract(d){return this.add(d.negate())}is0(){return this.equals(h.ZERO)}wNAF(d){return B.wNAFCached(this,d,h.normalizeZ)}multiplyUnsafe(d){Oe("scalar",d,Nt,e.n);let E=h.ZERO;if(d===Nt)return E;if(d===ye)return this;let{endo:R}=e;if(!R)return B.unsafeLadder(this,d);let{k1neg:y,k1:k,k2neg:D,k2:V}=R.splitScalar(d),N=E,b=E,v=this;for(;k>Nt||V>Nt;)k&ye&&(N=N.add(v)),V&ye&&(b=b.add(v)),v=v.double(),k>>=ye,V>>=ye;return y&&(N=N.negate()),D&&(b=b.negate()),b=new h(t.mul(b.px,R.beta),b.py,b.pz),N.add(b)}multiply(d){let{endo:E,n:R}=e;Oe("scalar",d,ye,R);let y,k;if(E){let{k1neg:D,k1:V,k2neg:N,k2:b}=E.splitScalar(d),{p:v,f:F}=this.wNAF(V),{p:_,f:C}=this.wNAF(b);v=B.constTimeNegate(D,v),_=B.constTimeNegate(N,_),_=new h(t.mul(_.px,E.beta),_.py,_.pz),y=v.add(_),k=F.add(C)}else{let{p:D,f:V}=this.wNAF(d);y=D,k=V}return h.normalizeZ([y,k])[0]}multiplyAndAddUnsafe(d,E,R){let y=h.BASE,k=(V,N)=>N===Nt||N===ye||!V.equals(y)?V.multiplyUnsafe(N):V.multiply(N),D=k(this,E).add(k(d,R));return D.is0()?void 0:D}toAffine(d){return u(this,d)}isTorsionFree(){let{h:d,isTorsionFree:E}=e;if(d===ye)return!0;if(E)return E(h,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h:d,clearCofactor:E}=e;return d===ye?this:E?E(h,this):this.multiplyUnsafe(e.h)}toRawBytes(d=!0){return et("isCompressed",d),this.assertValidity(),o(h,this,d)}toHex(d=!0){return et("isCompressed",d),bt(this.toRawBytes(d))}}h.BASE=new h(e.Gx,e.Gy,t.ONE),h.ZERO=new h(t.ZERO,t.ONE,t.ZERO);let w=e.nBitLength,B=lo(h,e.endo?Math.ceil(w/2):w);return{CURVE:e,ProjectivePoint:h,normPrivateKeyToScalar:c,weierstrassEquation:s,isWithinCurveOrder:a}}function jp(r){let e=pn(r);return lt(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function sl(r){let e=jp(r),{Fp:t,n}=e,o=t.BYTES+1,i=2*t.BYTES+1;function s(S){return ee(S,n)}function a(S){return uo(S,n)}let{ProjectivePoint:c,normPrivateKeyToScalar:f,weierstrassEquation:u,isWithinCurveOrder:l}=Gp({...e,toBytes(S,I,g){let p=I.toAffine(),A=t.toBytes(p.x),O=Et;return et("isCompressed",g),g?O(Uint8Array.from([I.hasEvenY()?2:3]),A):O(Uint8Array.from([4]),A,t.toBytes(p.y))},fromBytes(S){let I=S.length,g=S[0],p=S.subarray(1);if(I===o&&(g===2||g===3)){let A=xt(p);if(!hn(A,ye,t.ORDER))throw new Error("Point is not on curve");let O=u(A),M;try{M=t.sqrt(O)}catch(W){let j=W instanceof Error?": "+W.message:"";throw new Error("Point is not on curve"+j)}let H=(M&ye)===ye;return(g&1)===1!==H&&(M=t.neg(M)),{x:A,y:M}}else if(I===i&&g===4){let A=t.fromBytes(p.subarray(0,t.BYTES)),O=t.fromBytes(p.subarray(t.BYTES,2*t.BYTES));return{x:A,y:O}}else throw new Error(`Point of length ${I} was invalid. Expected ${o} compressed bytes or ${i} uncompressed bytes`)}}),h=S=>bt(qt(S,e.nByteLength));function w(S){let I=n>>ye;return S>I}function B(S){return w(S)?s(-S):S}let m=(S,I,g)=>xt(S.slice(I,g));class d{constructor(I,g,p){this.r=I,this.s=g,this.recovery=p,this.assertValidity()}static fromCompact(I){let g=e.nByteLength;return I=se("compactSignature",I,g*2),new d(m(I,0,g),m(I,g,2*g))}static fromDER(I){let{r:g,s:p}=Ct.toSig(se("DER",I));return new d(g,p)}assertValidity(){Oe("r",this.r,ye,n),Oe("s",this.s,ye,n)}addRecoveryBit(I){return new d(this.r,this.s,I)}recoverPublicKey(I){let{r:g,s:p,recovery:A}=this,O=V(se("msgHash",I));if(A==null||![0,1,2,3].includes(A))throw new Error("recovery id invalid");let M=A===2||A===3?g+e.n:g;if(M>=t.ORDER)throw new Error("recovery id 2 or 3 invalid");let H=A&1?"03":"02",G=c.fromHex(H+h(M)),W=a(M),j=s(-O*W),Q=s(p*W),re=c.BASE.multiplyAndAddUnsafe(G,j,Q);if(!re)throw new Error("point at infinify");return re.assertValidity(),re}hasHighS(){return w(this.s)}normalizeS(){return this.hasHighS()?new d(this.r,s(-this.s),this.recovery):this}toDERRawBytes(){return sr(this.toDERHex())}toDERHex(){return Ct.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return sr(this.toCompactHex())}toCompactHex(){return h(this.r)+h(this.s)}}let E={isValidPrivateKey(S){try{return f(S),!0}catch{return!1}},normPrivateKeyToScalar:f,randomPrivateKey:()=>{let S=Os(e.n);return zc(e.randomBytes(S),e.n)},precompute(S=8,I=c.BASE){return I._setWindowSize(S),I.multiply(BigInt(3)),I}};function R(S,I=!0){return c.fromPrivateKey(S).toRawBytes(I)}function y(S){let I=Kt(S),g=typeof S=="string",p=(I||g)&&S.length;return I?p===o||p===i:g?p===2*o||p===2*i:S instanceof c}function k(S,I,g=!0){if(y(S))throw new Error("first arg must be private key");if(!y(I))throw new Error("second arg must be public key");return c.fromHex(I).multiply(f(S)).toRawBytes(g)}let D=e.bits2int||function(S){let I=xt(S),g=S.length*8-e.nBitLength;return g>0?I>>BigInt(g):I},V=e.bits2int_modN||function(S){return s(D(S))},N=dn(e.nBitLength);function b(S){return Oe(`num < 2^${e.nBitLength}`,S,Nt,N),qt(S,e.nByteLength)}function v(S,I,g=F){if(["recovered","canonical"].some(pe=>pe in g))throw new Error("sign() legacy options not supported");let{hash:p,randomBytes:A}=e,{lowS:O,prehash:M,extraEntropy:H}=g;O==null&&(O=!0),S=se("msgHash",S),ol(g),M&&(S=se("prehashed msgHash",p(S)));let G=V(S),W=f(I),j=[b(W),b(G)];if(H!=null&&H!==!1){let pe=H===!0?A(t.BYTES):H;j.push(se("extraEntropy",pe))}let Q=Et(...j),re=G;function de(pe){let be=D(pe);if(!l(be))return;let ke=a(be),fe=c.BASE.multiply(be).toAffine(),Le=s(fe.x);if(Le===Nt)return;let gt=s(ke*s(re+Le*W));if(gt===Nt)return;let en=(fe.x===Le?0:2)|Number(fe.y&ye),tn=gt;return O&&w(gt)&&(tn=B(gt),en^=1),new d(Le,tn,en)}return{seed:Q,k2sig:de}}let F={lowS:e.lowS,prehash:!1},_={lowS:e.lowS,prehash:!1};function C(S,I,g=F){let{seed:p,k2sig:A}=v(S,I,g),O=e;return _s(O.hash.outputLen,O.nByteLength,O.hmac)(p,A)}c.BASE._setWindowSize(8);function $(S,I,g,p=_){let A=S;if(I=se("msgHash",I),g=se("publicKey",g),"strict"in p)throw new Error("options.strict was renamed to lowS");ol(p);let{lowS:O,prehash:M}=p,H,G;try{if(typeof A=="string"||Kt(A))try{H=d.fromDER(A)}catch(fe){if(!(fe instanceof Ct.Err))throw fe;H=d.fromCompact(A)}else if(typeof A=="object"&&typeof A.r=="bigint"&&typeof A.s=="bigint"){let{r:fe,s:Le}=A;H=new d(fe,Le)}else throw new Error("PARSE");G=c.fromHex(g)}catch(fe){if(fe.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(O&&H.hasHighS())return!1;M&&(I=e.hash(I));let{r:W,s:j}=H,Q=V(I),re=a(j),de=s(Q*re),pe=s(W*re),be=c.BASE.multiplyAndAddUnsafe(G,de,pe)?.toAffine();return be?s(be.x)===W:!1}return{CURVE:e,getPublicKey:R,getSharedSecret:k,sign:C,verify:$,ProjectivePoint:c,Signature:d,utils:E}}function Yp(r){return{hash:r,hmac:(e,...t)=>bn(r,e,As(...t)),randomBytes:_r}}function al(r,e){let t=n=>sl({...r,...Yp(n)});return Object.freeze({...t(e),create:t})}var ll=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),cl=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),Zp=BigInt(1),fa=BigInt(2),ul=(r,e)=>(r+e/fa)/e;function Wp(r){let e=ll,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=oe(u,t,e)*u%e,h=oe(l,t,e)*u%e,w=oe(h,fa,e)*f%e,B=oe(w,o,e)*w%e,m=oe(B,i,e)*B%e,d=oe(m,a,e)*m%e,E=oe(d,c,e)*d%e,R=oe(E,a,e)*m%e,y=oe(R,t,e)*u%e,k=oe(y,s,e)*B%e,D=oe(k,n,e)*f%e,V=oe(D,fa,e);if(!ha.eql(ha.sqr(V),r))throw new Error("Cannot find square root");return V}var ha=zt(ll,void 0,void 0,{sqrt:Wp}),it=al({a:BigInt(0),b:BigInt(7),Fp:ha,n:cl,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:r=>{let e=cl,t=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-Zp*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),i=t,s=BigInt("0x100000000000000000000000000000000"),a=ul(i*r,e),c=ul(-n*r,e),f=ee(r-a*t-c*o,e),u=ee(-a*n-c*i,e),l=f>s,h=u>s;if(l&&(f=e-f),h&&(u=e-u),f>s||u>s)throw new Error("splitScalar: Endomorphism failed, k="+r);return{k1neg:l,k1:f,k2neg:h,k2:u}}}},nl),f1=BigInt(0);var h1=it.ProjectivePoint;function fl(){return it.utils.randomPrivateKey()}function hl(r,e){let t=xe.digest(e instanceof Uint8Array?e:e.subarray());if(Ge(t))return t.then(({digest:n})=>it.sign(n,r).toDERRawBytes()).catch(n=>{throw new P(String(n),"ERR_INVALID_INPUT")});try{return it.sign(t.digest,r).toDERRawBytes()}catch(n){throw new P(String(n),"ERR_INVALID_INPUT")}}function dl(r,e,t){let n=xe.digest(t instanceof Uint8Array?t:t.subarray());if(Ge(n))return n.then(({digest:o})=>it.verify(e,o,r)).catch(o=>{throw new P(String(o),"ERR_INVALID_INPUT")});try{return it.verify(e,n.digest,r)}catch(o){throw new P(String(o),"ERR_INVALID_INPUT")}}function pl(r){return it.ProjectivePoint.fromHex(r).toRawBytes(!0)}function ml(r){try{it.getPublicKey(r,!0)}catch(e){throw new P(String(e),"ERR_INVALID_PRIVATE_KEY")}}function da(r){try{it.ProjectivePoint.fromHex(r)}catch(e){throw new P(String(e),"ERR_INVALID_PUBLIC_KEY")}}function gl(r){try{return it.getPublicKey(r,!0)}catch(e){throw new P(String(e),"ERR_INVALID_PRIVATE_KEY")}}var Nn=class{_key;constructor(e){da(e),this._key=e}verify(e,t){return dl(this._key,t,e)}marshal(){return pl(this._key)}get bytes(){return ft.encode({Type:ce.Secp256k1,Data:this.marshal()}).subarray()}equals(e){return ue(this.bytes,e.bytes)}async hash(){let e=xe.digest(this.bytes),t;return Ge(e)?{bytes:t}=await e:t=e.bytes,t}},_n=class{_key;_publicKey;constructor(e,t){this._key=e,this._publicKey=t??gl(e),ml(this._key),da(this._publicKey)}sign(e){return hl(this._key,e)}get public(){return new Nn(this._publicKey)}marshal(){return this._key}get bytes(){return Bt.encode({Type:ce.Secp256k1,Data:this.marshal()}).subarray()}equals(e){return ue(this.bytes,e.bytes)}hash(){let e=xe.digest(this.bytes);return Ge(e)?e.then(({bytes:t})=>t):e.bytes}async id(){let e=await this.public.hash();return z(e,"base58btc")}async export(e,t="libp2p-key"){if(t==="libp2p-key")return Dr(this.bytes,e);throw new P(`export format '${t}' is not supported`,"ERR_INVALID_EXPORT_FORMAT")}};function Xp(r){return new _n(r)}function Qp(r){return new Nn(r)}async function em(){let r=fl();return new _n(r)}var ui={rsa:ua,ed25519:Qs,secp256k1:pa};function tm(r){let e=Object.keys(ui).join(" / ");return new P(`invalid or unsupported key type ${r}. Must be ${e}`,"ERR_UNSUPPORTED_KEY_TYPE")}function ma(r){let e=ft.decode(r),t=e.Data??new Uint8Array;switch(e.Type){case ce.RSA:return ui.rsa.unmarshalRsaPublicKey(t);case ce.Ed25519:return ui.ed25519.unmarshalEd25519PublicKey(t);case ce.Secp256k1:return ui.secp256k1.unmarshalSecp256k1PublicKey(t);default:throw tm(e.Type??"unknown")}}var Om=rr(li(),1);var nm="/",om=new TextEncoder().encode(nm),T1=om[0];var Dm=rr(ya(),1);var bl="ERR_IPNS_EXPIRED_RECORD",fi="ERR_UNRECOGNIZED_VALIDITY";var _t="ERR_SIGNATURE_VERIFICATION";var wa="ERR_UNDEFINED_PARAMETER",xl="ERR_INVALID_RECORD_DATA",El="ERR_INVALID_VALUE",vl="ERR_INVALID_EMBEDDED_KEY";var Bl="ERR_RECORD_TOO_LARGE";var st;(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=()=>yn(t)}(e=r.ValidityType||(r.ValidityType={}));let n;r.codec=()=>(n==null&&(n=Hr((o,i,s={})=>{s.lengthDelimited!==!1&&i.fork(),o.value!=null&&(i.uint32(10),i.bytes(o.value)),o.signatureV1!=null&&(i.uint32(18),i.bytes(o.signatureV1)),o.validityType!=null&&(i.uint32(24),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=>Fr(o,r.codec()),r.decode=o=>Pr(o,r.codec())})(st||(st={}));var im=["string","number","bigint","symbol"],sm=["Function","Generator","AsyncGenerator","GeneratorFunction","AsyncGeneratorFunction","AsyncFunction","Observable","Array","Buffer","Object","RegExp","Date","Error","Map","Set","WeakMap","WeakSet","ArrayBuffer","SharedArrayBuffer","DataView","Promise","URL","HTMLElement","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","BigInt64Array","BigUint64Array"];function Sl(r){if(r===null)return"null";if(r===void 0)return"undefined";if(r===!0||r===!1)return"boolean";let e=typeof r;if(im.includes(e))return e;if(e==="function")return"Function";if(Array.isArray(r))return"Array";if(am(r))return"Buffer";let t=cm(r);return t||"Object"}function am(r){return r&&r.constructor&&r.constructor.isBuffer&&r.constructor.isBuffer.call(null,r)}function cm(r){let e=Object.prototype.toString.call(r).slice(8,-1);if(sm.includes(e))return e}var x=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}};x.uint=new x(0,"uint",!0);x.negint=new x(1,"negint",!0);x.bytes=new x(2,"bytes",!0);x.string=new x(3,"string",!0);x.array=new x(4,"array",!1);x.map=new x(5,"map",!1);x.tag=new x(6,"tag",!1);x.float=new x(7,"float",!0);x.false=new x(7,"false",!0);x.true=new x(7,"true",!0);x.null=new x(7,"null",!0);x.undefined=new x(7,"undefined",!0);x.break=new x(7,"break",!0);var L=class{constructor(e,t,n){this.type=e,this.value=t,this.encodedLength=n,this.encodedBytes=void 0,this.byteValue=void 0}toString(){return`Token[${this.type}].${this.value}`}};var Yr=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&typeof globalThis.Buffer.isBuffer=="function",um=new TextDecoder,lm=new TextEncoder;function hi(r){return Yr&&globalThis.Buffer.isBuffer(r)}function Tl(r){return r instanceof Uint8Array?hi(r)?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r:Uint8Array.from(r)}var Cl=Yr?(r,e,t)=>t-e>64?globalThis.Buffer.from(r.subarray(e,t)).toString("utf8"):Rl(r,e,t):(r,e,t)=>t-e>64?um.decode(r.subarray(e,t)):Rl(r,e,t),Nl=Yr?r=>r.length>64?globalThis.Buffer.from(r):Il(r):r=>r.length>64?lm.encode(r):Il(r);var Zr=Yr?(r,e,t)=>hi(r)?new Uint8Array(r.subarray(e,t)):r.slice(e,t):(r,e,t)=>r.slice(e,t),_l=Yr?(r,e)=>(r=r.map(t=>t instanceof Uint8Array?t:globalThis.Buffer.from(t)),Tl(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},Ul=Yr?r=>globalThis.Buffer.allocUnsafe(r):r=>new Uint8Array(r);function Ll(r,e){if(hi(r)&&hi(e))return r.compare(e);for(let t=0;t<r.length;t++)if(r[t]!==e[t])return r[t]<e[t]?-1:1;return 0}function Il(r){let e=[],t=0;for(let n=0;n<r.length;n++){let o=r.charCodeAt(n);o<128?e[t++]=o:o<2048?(e[t++]=o>>6|192,e[t++]=o&63|128):(o&64512)===55296&&n+1<r.length&&(r.charCodeAt(n+1)&64512)===56320?(o=65536+((o&1023)<<10)+(r.charCodeAt(++n)&1023),e[t++]=o>>18|240,e[t++]=o>>12&63|128,e[t++]=o>>6&63|128,e[t++]=o&63|128):(e[t++]=o>>12|224,e[t++]=o>>6&63|128,e[t++]=o&63|128)}return e}function Rl(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 fm(n)}var kl=4096;function fm(r){let e=r.length;if(e<=kl)return String.fromCharCode.apply(String,r);let t="",n=0;for(;n<e;)t+=String.fromCharCode.apply(String,r.slice(n,n+=kl));return t}var hm=256,di=class{constructor(e=hm){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=Ul(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=Zr(n,0,this.cursor)}else t=_l(this.chunks,this.cursor);return e&&this.reset(),t}};var K="CBOR decode error:",ba="CBOR encode error:",Un=[];Un[23]=1;Un[24]=2;Un[25]=3;Un[26]=5;Un[27]=9;function Ut(r,e,t){if(r.length-e<t)throw new Error(`${K} not enough data for type`)}var we=[24,256,65536,4294967296,BigInt("18446744073709551616")];function He(r,e,t){Ut(r,e,1);let n=r[e];if(t.strict===!0&&n<we[0])throw new Error(`${K} integer encoded in more bytes than necessary (strict decode)`);return n}function Ke(r,e,t){Ut(r,e,2);let n=r[e]<<8|r[e+1];if(t.strict===!0&&n<we[1])throw new Error(`${K} integer encoded in more bytes than necessary (strict decode)`);return n}function $e(r,e,t){Ut(r,e,4);let n=r[e]*16777216+(r[e+1]<<16)+(r[e+2]<<8)+r[e+3];if(t.strict===!0&&n<we[2])throw new Error(`${K} integer encoded in more bytes than necessary (strict decode)`);return n}function qe(r,e,t){Ut(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<we[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 Vl(r,e,t,n){return new L(x.uint,He(r,e+1,n),2)}function Ol(r,e,t,n){return new L(x.uint,Ke(r,e+1,n),3)}function Dl(r,e,t,n){return new L(x.uint,$e(r,e+1,n),5)}function Pl(r,e,t,n){return new L(x.uint,qe(r,e+1,n),9)}function Ye(r,e){return ve(r,0,e.value)}function ve(r,e,t){if(t<we[0]){let n=Number(t);r.push([e|n])}else if(t<we[1]){let n=Number(t);r.push([e|24,n])}else if(t<we[2]){let n=Number(t);r.push([e|25,n>>>8,n&255])}else if(t<we[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<we[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`)}}Ye.encodedSize=function(e){return ve.encodedSize(e.value)};ve.encodedSize=function(e){return e<we[0]?1:e<we[1]?2:e<we[2]?3:e<we[3]?5:9};Ye.compareTokens=function(e,t){return e.value<t.value?-1:e.value>t.value?1:0};function Fl(r,e,t,n){return new L(x.negint,-1-He(r,e+1,n),2)}function Ml(r,e,t,n){return new L(x.negint,-1-Ke(r,e+1,n),3)}function Hl(r,e,t,n){return new L(x.negint,-1-$e(r,e+1,n),5)}var xa=BigInt(-1),Kl=BigInt(1);function $l(r,e,t,n){let o=qe(r,e+1,n);if(typeof o!="bigint"){let i=-1-o;if(i>=Number.MIN_SAFE_INTEGER)return new L(x.negint,i,9)}if(n.allowBigInt!==!0)throw new Error(`${K} integers outside of the safe integer range are not supported`);return new L(x.negint,xa-BigInt(o),9)}function pi(r,e){let t=e.value,n=typeof t=="bigint"?t*xa-Kl:t*-1-1;ve(r,e.type.majorEncoded,n)}pi.encodedSize=function(e){let t=e.value,n=typeof t=="bigint"?t*xa-Kl:t*-1-1;return n<we[0]?1:n<we[1]?2:n<we[2]?3:n<we[3]?5:9};pi.compareTokens=function(e,t){return e.value<t.value?1:e.value>t.value?-1:0};function Ln(r,e,t,n){Ut(r,e,t+n);let o=Zr(r,e+t,e+t+n);return new L(x.bytes,o,t+n)}function ql(r,e,t,n){return Ln(r,e,1,t)}function zl(r,e,t,n){return Ln(r,e,2,He(r,e+1,n))}function Gl(r,e,t,n){return Ln(r,e,3,Ke(r,e+1,n))}function jl(r,e,t,n){return Ln(r,e,5,$e(r,e+1,n))}function Yl(r,e,t,n){let o=qe(r,e+1,n);if(typeof o=="bigint")throw new Error(`${K} 64-bit integer bytes lengths not supported`);return Ln(r,e,9,o)}function mi(r){return r.encodedBytes===void 0&&(r.encodedBytes=r.type===x.string?Nl(r.value):r.value),r.encodedBytes}function Wr(r,e){let t=mi(e);ve(r,e.type.majorEncoded,t.length),r.push(t)}Wr.encodedSize=function(e){let t=mi(e);return ve.encodedSize(t.length)+t.length};Wr.compareTokens=function(e,t){return pm(mi(e),mi(t))};function pm(r,e){return r.length<e.length?-1:r.length>e.length?1:Ll(r,e)}function Vn(r,e,t,n,o){let i=t+n;Ut(r,e,i);let s=new L(x.string,Cl(r,e+t,e+i),i);return o.retainStringBytes===!0&&(s.byteValue=Zr(r,e+t,e+i)),s}function Zl(r,e,t,n){return Vn(r,e,1,t,n)}function Wl(r,e,t,n){return Vn(r,e,2,He(r,e+1,n),n)}function Jl(r,e,t,n){return Vn(r,e,3,Ke(r,e+1,n),n)}function Xl(r,e,t,n){return Vn(r,e,5,$e(r,e+1,n),n)}function Ql(r,e,t,n){let o=qe(r,e+1,n);if(typeof o=="bigint")throw new Error(`${K} 64-bit integer string lengths not supported`);return Vn(r,e,9,o,n)}var ef=Wr;function Jr(r,e,t,n){return new L(x.array,n,t)}function tf(r,e,t,n){return Jr(r,e,1,t)}function rf(r,e,t,n){return Jr(r,e,2,He(r,e+1,n))}function nf(r,e,t,n){return Jr(r,e,3,Ke(r,e+1,n))}function of(r,e,t,n){return Jr(r,e,5,$e(r,e+1,n))}function sf(r,e,t,n){let o=qe(r,e+1,n);if(typeof o=="bigint")throw new Error(`${K} 64-bit integer array lengths not supported`);return Jr(r,e,9,o)}function af(r,e,t,n){if(n.allowIndefinite===!1)throw new Error(`${K} indefinite length items not allowed`);return Jr(r,e,1,1/0)}function gi(r,e){ve(r,x.array.majorEncoded,e.value)}gi.compareTokens=Ye.compareTokens;gi.encodedSize=function(e){return ve.encodedSize(e.value)};function Xr(r,e,t,n){return new L(x.map,n,t)}function cf(r,e,t,n){return Xr(r,e,1,t)}function uf(r,e,t,n){return Xr(r,e,2,He(r,e+1,n))}function lf(r,e,t,n){return Xr(r,e,3,Ke(r,e+1,n))}function ff(r,e,t,n){return Xr(r,e,5,$e(r,e+1,n))}function hf(r,e,t,n){let o=qe(r,e+1,n);if(typeof o=="bigint")throw new Error(`${K} 64-bit integer map lengths not supported`);return Xr(r,e,9,o)}function df(r,e,t,n){if(n.allowIndefinite===!1)throw new Error(`${K} indefinite length items not allowed`);return Xr(r,e,1,1/0)}function yi(r,e){ve(r,x.map.majorEncoded,e.value)}yi.compareTokens=Ye.compareTokens;yi.encodedSize=function(e){return ve.encodedSize(e.value)};function pf(r,e,t,n){return new L(x.tag,t,1)}function mf(r,e,t,n){return new L(x.tag,He(r,e+1,n),2)}function gf(r,e,t,n){return new L(x.tag,Ke(r,e+1,n),3)}function yf(r,e,t,n){return new L(x.tag,$e(r,e+1,n),5)}function wf(r,e,t,n){return new L(x.tag,qe(r,e+1,n),9)}function wi(r,e){ve(r,x.tag.majorEncoded,e.value)}wi.compareTokens=Ye.compareTokens;wi.encodedSize=function(e){return ve.encodedSize(e.value)};var xm=20,Em=21,vm=22,Bm=23;function bf(r,e,t,n){if(n.allowUndefined===!1)throw new Error(`${K} undefined values are not supported`);return n.coerceUndefinedToNull===!0?new L(x.null,null,1):new L(x.undefined,void 0,1)}function xf(r,e,t,n){if(n.allowIndefinite===!1)throw new Error(`${K} indefinite length items not allowed`);return new L(x.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 L(x.float,r,e)}function Ef(r,e,t,n){return Ea(va(r,e+1),3,n)}function vf(r,e,t,n){return Ea(Ba(r,e+1),5,n)}function Bf(r,e,t,n){return Ea(Rf(r,e+1),9,n)}function bi(r,e,t){let n=e.value;if(n===!1)r.push([x.float.majorEncoded|xm]);else if(n===!0)r.push([x.float.majorEncoded|Em]);else if(n===null)r.push([x.float.majorEncoded|vm]);else if(n===void 0)r.push([x.float.majorEncoded|Bm]);else{let o,i=!1;(!t||t.float64!==!0)&&(Sf(n),o=va(at,1),n===o||Number.isNaN(n)?(at[0]=249,r.push(at.slice(0,3)),i=!0):(If(n),o=Ba(at,1),n===o&&(at[0]=250,r.push(at.slice(0,5)),i=!0))),i||(Am(n),o=Rf(at,1),at[0]=251,r.push(at.slice(0,9)))}}bi.encodedSize=function(e,t){let n=e.value;if(n===!1||n===!0||n===null||n===void 0)return 1;if(!t||t.float64!==!0){Sf(n);let o=va(at,1);if(n===o||Number.isNaN(n))return 3;if(If(n),o=Ba(at,1),n===o)return 5}return 9};var Af=new ArrayBuffer(9),Ze=new DataView(Af,1),at=new Uint8Array(Af,0);function Sf(r){if(r===1/0)Ze.setUint16(0,31744,!1);else if(r===-1/0)Ze.setUint16(0,64512,!1);else if(Number.isNaN(r))Ze.setUint16(0,32256,!1);else{Ze.setFloat32(0,r);let e=Ze.getUint32(0),t=(e&2139095040)>>23,n=e&8388607;if(t===255)Ze.setUint16(0,31744,!1);else if(t===0)Ze.setUint16(0,(r&2147483648)>>16|n>>13,!1);else{let o=t-127;o<-24?Ze.setUint16(0,0):o<-14?Ze.setUint16(0,(e&2147483648)>>16|1<<24+o,!1):Ze.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 If(r){Ze.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 Am(r){Ze.setFloat64(0,r,!1)}function Rf(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)}bi.compareTokens=Ye.compareTokens;function J(r,e,t){throw new Error(`${K} encountered invalid minor (${t}) for major ${r[e]>>>5}`)}function xi(r){return()=>{throw new Error(`${K} ${r}`)}}var T=[];for(let r=0;r<=23;r++)T[r]=J;T[24]=Vl;T[25]=Ol;T[26]=Dl;T[27]=Pl;T[28]=J;T[29]=J;T[30]=J;T[31]=J;for(let r=32;r<=55;r++)T[r]=J;T[56]=Fl;T[57]=Ml;T[58]=Hl;T[59]=$l;T[60]=J;T[61]=J;T[62]=J;T[63]=J;for(let r=64;r<=87;r++)T[r]=ql;T[88]=zl;T[89]=Gl;T[90]=jl;T[91]=Yl;T[92]=J;T[93]=J;T[94]=J;T[95]=xi("indefinite length bytes/strings are not supported");for(let r=96;r<=119;r++)T[r]=Zl;T[120]=Wl;T[121]=Jl;T[122]=Xl;T[123]=Ql;T[124]=J;T[125]=J;T[126]=J;T[127]=xi("indefinite length bytes/strings are not supported");for(let r=128;r<=151;r++)T[r]=tf;T[152]=rf;T[153]=nf;T[154]=of;T[155]=sf;T[156]=J;T[157]=J;T[158]=J;T[159]=af;for(let r=160;r<=183;r++)T[r]=cf;T[184]=uf;T[185]=lf;T[186]=ff;T[187]=hf;T[188]=J;T[189]=J;T[190]=J;T[191]=df;for(let r=192;r<=215;r++)T[r]=pf;T[216]=mf;T[217]=gf;T[218]=yf;T[219]=wf;T[220]=J;T[221]=J;T[222]=J;T[223]=J;for(let r=224;r<=243;r++)T[r]=xi("simple values are not supported");T[244]=J;T[245]=J;T[246]=J;T[247]=bf;T[248]=xi("simple values are not supported");T[249]=Ef;T[250]=vf;T[251]=Bf;T[252]=J;T[253]=J;T[254]=J;T[255]=xf;var ct=[];for(let r=0;r<24;r++)ct[r]=new L(x.uint,r,1);for(let r=-1;r>=-24;r--)ct[31-r]=new L(x.negint,r,1);ct[64]=new L(x.bytes,new Uint8Array(0),1);ct[96]=new L(x.string,"",1);ct[128]=new L(x.array,0,1);ct[160]=new L(x.map,0,1);ct[244]=new L(x.false,!1,1);ct[245]=new L(x.true,!0,1);ct[246]=new L(x.null,null,1);function Im(){let r=[];return r[x.uint.major]=Ye,r[x.negint.major]=pi,r[x.bytes.major]=Wr,r[x.string.major]=ef,r[x.array.major]=gi,r[x.map.major]=yi,r[x.tag.major]=wi,r[x.float.major]=bi,r}var IE=Im(),RE=new di,Ei=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)}},Qt={null:new L(x.null,null),undefined:new L(x.undefined,void 0),true:new L(x.true,!0),false:new L(x.false,!1),emptyArray:new L(x.array,0),emptyMap:new L(x.map,0)},er={number(r,e,t,n){return!Number.isInteger(r)||!Number.isSafeInteger(r)?new L(x.float,r):r>=0?new L(x.uint,r):new L(x.negint,r)},bigint(r,e,t,n){return r>=BigInt(0)?new L(x.uint,r):new L(x.negint,r)},Uint8Array(r,e,t,n){return new L(x.bytes,r)},string(r,e,t,n){return new L(x.string,r)},boolean(r,e,t,n){return r?Qt.true:Qt.false},null(r,e,t,n){return Qt.null},undefined(r,e,t,n){return Qt.undefined},ArrayBuffer(r,e,t,n){return new L(x.bytes,new Uint8Array(r))},DataView(r,e,t,n){return new L(x.bytes,new Uint8Array(r.buffer,r.byteOffset,r.byteLength))},Array(r,e,t,n){if(!r.length)return t.addBreakTokens===!0?[Qt.emptyArray,new L(x.break)]:Qt.emptyArray;n=Ei.createCheck(n,r);let o=[],i=0;for(let s of r)o[i++]=Aa(s,t,n);return t.addBreakTokens?[new L(x.array,r.length),o,new L(x.break)]:[new L(x.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?[Qt.emptyMap,new L(x.break)]:Qt.emptyMap;n=Ei.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 Rm(a,t),t.addBreakTokens?[new L(x.map,s),a,new L(x.break)]:[new L(x.map,s),a]}};er.Map=er.Object;er.Buffer=er.Uint8Array;for(let r of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))er[`${r}Array`]=er.DataView;function Aa(r,e={},t){let n=Sl(r),o=e&&e.typeEncoders&&e.typeEncoders[n]||er[n];if(typeof o=="function"){let s=o(r,n,e,t);if(s!=null)return s}let i=er[n];if(!i)throw new Error(`${ba} unsupported type: ${n}`);return i(r,n,e,t)}function Rm(r,e){e.mapSorter&&r.sort(e.mapSorter)}var km={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0},vi=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=ct[e];if(t===void 0){let n=T[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}},On=Symbol.for("DONE"),Bi=Symbol.for("BREAK");function Tm(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(`${K} got unexpected break to lengthed array`)}if(i===On)throw new Error(`${K} found array but not enough entries (got ${o}, expected ${r.value})`);n[o]=i}return n}function Cm(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(`${K} got unexpected break to lengthed map`)}if(a===On)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=Qr(e,t);if(c===On)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 Qr(r,e){if(r.done())return On;let t=r.next();if(t.type===x.break)return Bi;if(t.type.terminal)return t.value;if(t.type===x.array)return Tm(t,r,e);if(t.type===x.map)return Cm(t,r,e);if(t.type===x.tag){if(e.tags&&typeof e.tags[t.value]=="function"){let n=Qr(r,e);return e.tags[t.value](n)}throw new Error(`${K} tag not supported (${t.value})`)}throw new Error("unsupported")}function kf(r,e){if(!(r instanceof Uint8Array))throw new Error(`${K} data to decode must be a Uint8Array`);e=Object.assign({},km,e);let t=e.tokenizer||new vi(r,e),n=Qr(t,e);if(n===On)throw new Error(`${K} did not find any content to decode`);if(n===Bi)throw new Error(`${K} got unexpected break`);return[n,r.subarray(t.pos())]}function Sa(r,e){let[t,n]=kf(r,e);if(n.length>0)throw new Error(`${K} too many terminals, data makes no sense`);return t}var ze=rr(li(),1);var Tf=Vt("ipns:utils"),Cf=Y("/ipns/"),Um=114,Nf=async(r,e)=>{if(e==null||r==null){let n=new Error("one or more of the provided parameters are not defined");throw Tf.error(n),(0,ze.default)(n,wa)}let t;if(e.pubKey!=null){try{t=ma(e.pubKey)}catch(o){throw Tf.error(o),o}if(!(await mc(e.pubKey)).equals(r))throw(0,ze.default)(new Error("Embedded public key did not match PeerID"),vl)}else r.publicKey!=null&&(t=ma(r.publicKey));if(t!=null)return t;throw(0,ze.default)(new Error("no public key is available"),wa)};var _f=r=>{let e=Y("ipns-signature:");return Te([e,r])},Dn=r=>"signatureV1"in r?st.encode({value:Y(r.value),signatureV1:r.signatureV1,validityType:r.validityType,validity:Y(r.validity),sequence:r.sequence,ttl:r.ttl,pubKey:r.pubKey,signatureV2:r.signatureV2,data:r.data}):st.encode({pubKey:r.pubKey,signatureV2:r.signatureV2,data:r.data});function tr(r){let e=st.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,ze.default)(new Error("missing data or signatureV2"),_t);let t=Lf(e.data),n=Lm(t.Value),o=z(t.Validity);if(e.value!=null&&e.signatureV1!=null)return Vm(e),{value:n,validityType:st.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:st.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=>Te([Cf,r.toBytes()]),Uf=r=>cn(r.slice(Cf.length));var Lf=r=>{let e=Sa(r);if(e.ValidityType===0)e.ValidityType=st.ValidityType.EOL;else throw(0,ze.default)(new Error("Unknown validity type"),fi);return Number.isInteger(e.Sequence)&&(e.Sequence=BigInt(e.Sequence)),Number.isInteger(e.TTL)&&(e.TTL=BigInt(e.TTL)),e},Lm=r=>{if(r!=null){if(Ka(r))return`/ipns/${r.toCID().toString(Wn)}`;if(r instanceof Uint8Array){let n=z(r);n.startsWith("/")&&(r=n)}let e=r.toString().trim();if(e.startsWith("/")&&e.length>1)return e;let t=Be.asCID(r);if(t!=null)return t.code===Um?`/ipns/${t.toString(Wn)}`:`/ipfs/${t.toV1().toString()}`;try{return r instanceof Uint8Array?`/ipfs/${Be.decode(r).toV1().toString()}`:`/ipfs/${Be.parse(e).toV1().toString()}`}catch{}}throw(0,ze.default)(new Error("Value must be a valid content path starting with /"),El)},Vm=r=>{if(r.data==null)throw(0,ze.default)(new Error("Record data is missing"),xl);let e=Lf(r.data);if(!ue(e.Value,r.value??new Uint8Array(0)))throw(0,ze.default)(new Error('Field "value" did not match between protobuf and CBOR'),_t);if(!ue(e.Validity,r.validity??new Uint8Array(0)))throw(0,ze.default)(new Error('Field "validity" did not match between protobuf and CBOR'),_t);if(e.ValidityType!==r.validityType)throw(0,ze.default)(new Error('Field "validityType" did not match between protobuf and CBOR'),_t);if(e.Sequence!==r.sequence)throw(0,ze.default)(new Error('Field "sequence" did not match between protobuf and CBOR'),_t);if(e.TTL!==r.ttl)throw(0,ze.default)(new Error('Field "ttl" did not match between protobuf and CBOR'),_t)};var t2=Vt("ipns"),r2=Je.code,n2=60*60*1e9,Pm="/ipns/",o2=Pm.length;var Pn=rr(li(),1),Vf=rr(ya(),1);var Ai=Vt("ipns:validator"),Fm=1024*10,Mm=async(r,e)=>{let t=tr(e),n;try{let o=_f(t.data);n=await r.verify(o,t.signatureV2)}catch{n=!1}if(!n)throw Ai.error("record signature verification failed"),(0,Pn.default)(new Error("record signature verification failed"),_t);if(t.validityType===st.ValidityType.EOL){if(Vf.default.fromString(t.validity).toDate().getTime()<Date.now())throw Ai.error("record has expired"),(0,Pn.default)(new Error("record has expired"),bl)}else if(t.validityType!=null)throw Ai.error("unrecognized validity type"),(0,Pn.default)(new Error("unrecognized validity type"),fi);Ai("ipns record for %s is valid",t.value)};async function Of(r,e){if(e.byteLength>Fm)throw(0,Pn.default)(new Error("record too large"),Bl);let t=Uf(r),n=tr(e),o=await Nf(t,n);await Mm(o,e)}async function*Fn(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 mt(){let r={};return r.promise=new Promise((e,t)=>{r.resolve=e,r.reject=t}),r}var ka=rr(Pf(),1);var Hn=class extends Error{constructor(e){super(e),this.name="TimeoutError"}},Ta=class extends Error{constructor(e){super(),this.name="AbortError",this.message=e}},Ff=r=>globalThis.DOMException===void 0?new Ta(r):new DOMException(r),Mf=r=>{let e=r.reason===void 0?Ff("This operation was aborted."):r.reason;return e instanceof Error?e:Ff(e)};function Ca(r,e){let{milliseconds:t,fallback:n,message:o,customTimers:i={setTimeout,clearTimeout}}=e,s,c=new Promise((f,u)=>{if(typeof t!="number"||Math.sign(t)!==1)throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${t}\``);if(e.signal){let{signal:h}=e;h.aborted&&u(Mf(h)),h.addEventListener("abort",()=>{u(Mf(h))})}if(t===Number.POSITIVE_INFINITY){r.then(f,u);return}let l=new Hn;s=i.setTimeout.call(void 0,()=>{if(n){try{f(n())}catch(h){u(h)}return}typeof r.cancel=="function"&&r.cancel(),o===!1?f():o instanceof Error?u(o):(l.message=o??`Promise timed out after ${t} milliseconds`,u(l))},t),(async()=>{try{f(await r)}catch(h){u(h)}})()}).finally(()=>{c.clear()});return c.clear=()=>{i.clearTimeout.call(void 0,s),s=void 0},c}function Na(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 Kn=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=Na(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 $n=class extends ka.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:Kn,...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#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.#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=Ca(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 Hn&&!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.#m}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 $m(r){return r[Symbol.asyncIterator]!=null}function qm(r){if($m(r))return(async()=>{for await(let e of r)return e})();for(let e of r)return e}var Hf=qm;function zm(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 Kf=zm;function Gm(r){return r[Symbol.asyncIterator]!=null}function jm(r,e){let t=0;if(Gm(r))return async function*(){for await(let c of r)yield e(c,t++)}();let n=Kf(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 $f=jm;var _a=Y("/ipns/");function qf(r){return ue(r.subarray(0,_a.byteLength),_a)}var zf=r=>cn(r.slice(_a.length)),Ii=class{client;constructor(e){this.client=e}async*findProviders(e,t={}){yield*$f(this.client.getProviders(e,t),n=>({id:n.ID,multiaddrs:n.Addrs??[]}))}async provide(){}async put(e,t,n){if(!qf(e))return;let o=zf(e),i=tr(t);await this.client.putIPNS(o,i,n)}async get(e,t){if(!qf(e))throw new P("Not found","ERR_NOT_FOUND");let n=zf(e);try{let o=await this.client.getIPNS(n,t);return Dn(o)}catch(o){throw o.code==="ERR_BAD_RESPONSE"?new P("Not found","ERR_NOT_FOUND"):o}}},Ri=class{client;constructor(e){this.client=e}async findPeer(e,t={}){let n=await Hf(this.client.getPeers(e,t));if(n!=null)return{id:n.ID,multiaddrs:n.Addrs??[]};throw new P("Not found","ERR_NOT_FOUND")}async*getClosestPeers(e,t={}){}};var Ue=Vt("delegated-routing-v1-http-api-client"),Gf={concurrentRequests:4,timeout:3e4},ki=class{started;httpQueue;shutDownController;clientUrl;timeout;contentRouting;peerRouting;constructor(e,t={}){this.started=!1,this.shutDownController=new AbortController,gr(1/0,this.shutDownController.signal),this.httpQueue=new $n({concurrency:t.concurrentRequests??Gf.concurrentRequests}),this.clientUrl=e instanceof URL?e:new URL(e),this.timeout=t.timeout??Gf.timeout,this.contentRouting=new Ii(this),this.peerRouting=new Ri(this)}get[Ha](){return this.contentRouting}get[$a](){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={}){Ue("getProviders starts: %c",e);let n=AbortSignal.timeout(this.timeout),o=ln([this.shutDownController.signal,n,t.signal]);gr(1/0,n,o);let i=mt(),s=mt();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 P("No matching records found.","ERR_NOT_FOUND");if(f.status===422)throw new P("Request does not conform to schema or semantic constraints.","ERR_INVALID_REQUEST");if(f.body==null)throw new P("Routing response had no body","ERR_BAD_RESPONSE");if(f.headers.get("Content-Type")==="application/json"){let l=await f.json();for(let h of l.Providers){let w=this.#e(h);w!=null&&(yield w)}}else for await(let l of Fn(no(f.body))){let h=this.#e(l);h!=null&&(yield h)}}catch(a){Ue.error("getProviders errored:",a)}finally{o.clear(),s.resolve(),Ue("getProviders finished: %c",e)}}async*getPeers(e,t={}){Ue("getPeers starts: %c",e);let n=AbortSignal.timeout(this.timeout),o=ln([this.shutDownController.signal,n,t.signal]);gr(1/0,n,o);let i=mt(),s=mt();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 P("No matching records found.","ERR_NOT_FOUND");if(f.status===422)throw new P("Request does not conform to schema or semantic constraints.","ERR_INVALID_REQUEST");if(f.body==null)throw new P("Routing response had no body","ERR_BAD_RESPONSE");if(f.headers.get("Content-Type")==="application/json"){let l=await f.json();for(let h of l.Peers){let w=this.#e(h);w!=null&&(yield w)}}else for await(let l of Fn(no(f.body))){let h=this.#e(l);h!=null&&(yield h)}}catch(a){Ue.error("getPeers errored:",a)}finally{o.clear(),s.resolve(),Ue("getPeers finished: %c",e)}}async getIPNS(e,t={}){Ue("getIPNS starts: %c",e);let n=AbortSignal.timeout(this.timeout),o=ln([this.shutDownController.signal,n,t.signal]);gr(1/0,n,o);let i=mt(),s=mt();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(Ue("getIPNS GET %s %d",a,f.status),f.status===404)throw new P("No matching records found.","ERR_NOT_FOUND");if(f.status===422)throw new P("Request does not conform to schema or semantic constraints.","ERR_INVALID_REQUEST");if(f.body==null)throw new P("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 Of(Ia(e),l),tr(l)}catch(c){throw Ue.error("getIPNS GET %s error:",a,c),c}finally{o.clear(),s.resolve(),Ue("getIPNS finished: %c",e)}}async putIPNS(e,t,n={}){Ue("putIPNS starts: %c",e);let o=AbortSignal.timeout(this.timeout),i=ln([this.shutDownController.signal,o,n.signal]);gr(1/0,o,i);let s=mt(),a=mt();this.httpQueue.add(async()=>(s.resolve(),a.promise));let c=`${this.clientUrl}routing/v1/ipns/${e.toCID().toString()}`;try{await s.promise;let f=Dn(t),l=await fetch(c,{method:"PUT",headers:{"Content-Type":"application/vnd.ipfs.ipns-record"},body:f,signal:i});if(Ue("putIPNS PUT %s %d",c,l.status),l.status!==200)throw new P("PUT ipns response had status other than 200","ERR_BAD_RESPONSE")}catch(f){throw Ue.error("putIPNS PUT %s error:",c,f.stack),f}finally{i.clear(),a.resolve(),Ue("putIPNS finished: %c",e)}}#e(e){try{let t=[],n=e.Addrs?.map(un)??[];return e.Protocols!=null&&t.push(...e.Protocols),e.Protocol!=null&&(t.push(e.Protocol),delete e.Protocol),{...e,Schema:"peer",ID:rs(e.ID),Addrs:n,Protocols:t}}catch(t){Ue.error("could not conform record to peer schema",t)}}};function Ym(r,e={}){return new ki(new URL(r),e)}return sh(Zm);})();
9
9
  /*! Bundled license information:
10
10
 
11
11
  pvtsutils/build/index.js: