@helia/ipns 6.0.0 → 6.0.1-2c71b6e
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -1
- package/dist/index.min.js +5 -5
- package/dist/src/dnslink.d.ts +5 -0
- package/dist/src/dnslink.d.ts.map +1 -0
- package/dist/src/dnslink.js +123 -0
- package/dist/src/dnslink.js.map +1 -0
- package/dist/src/index.d.ts +18 -22
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +10 -9
- package/dist/src/index.js.map +1 -1
- package/package.json +14 -18
- package/src/dnslink.ts +142 -0
- package/src/index.ts +30 -38
- package/dist/src/dns-resolvers/default.d.ts +0 -3
- package/dist/src/dns-resolvers/default.d.ts.map +0 -1
- package/dist/src/dns-resolvers/default.js +0 -8
- package/dist/src/dns-resolvers/default.js.map +0 -1
- package/dist/src/dns-resolvers/dns-json-over-https.d.ts +0 -18
- package/dist/src/dns-resolvers/dns-json-over-https.d.ts.map +0 -1
- package/dist/src/dns-resolvers/dns-json-over-https.js +0 -72
- package/dist/src/dns-resolvers/dns-json-over-https.js.map +0 -1
- package/dist/src/dns-resolvers/dns-over-https.d.ts +0 -16
- package/dist/src/dns-resolvers/dns-over-https.d.ts.map +0 -1
- package/dist/src/dns-resolvers/dns-over-https.js +0 -123
- package/dist/src/dns-resolvers/dns-over-https.js.map +0 -1
- package/dist/src/dns-resolvers/index.d.ts +0 -3
- package/dist/src/dns-resolvers/index.d.ts.map +0 -1
- package/dist/src/dns-resolvers/index.js +0 -3
- package/dist/src/dns-resolvers/index.js.map +0 -1
- package/dist/src/dns-resolvers/resolver.browser.d.ts +0 -4
- package/dist/src/dns-resolvers/resolver.browser.d.ts.map +0 -1
- package/dist/src/dns-resolvers/resolver.browser.js +0 -39
- package/dist/src/dns-resolvers/resolver.browser.js.map +0 -1
- package/dist/src/dns-resolvers/resolver.d.ts +0 -4
- package/dist/src/dns-resolvers/resolver.d.ts.map +0 -1
- package/dist/src/dns-resolvers/resolver.js +0 -21
- package/dist/src/dns-resolvers/resolver.js.map +0 -1
- package/dist/src/utils/dns.d.ts +0 -35
- package/dist/src/utils/dns.d.ts.map +0 -1
- package/dist/src/utils/dns.js +0 -79
- package/dist/src/utils/dns.js.map +0 -1
- package/dist/src/utils/tlru.d.ts +0 -15
- package/dist/src/utils/tlru.d.ts.map +0 -1
- package/dist/src/utils/tlru.js +0 -40
- package/dist/src/utils/tlru.js.map +0 -1
- package/dist/typedoc-urls.json +0 -44
- package/src/dns-resolvers/default.ts +0 -9
- package/src/dns-resolvers/dns-json-over-https.ts +0 -90
- package/src/dns-resolvers/dns-over-https.ts +0 -146
- package/src/dns-resolvers/index.ts +0 -2
- package/src/dns-resolvers/resolver.browser.ts +0 -50
- package/src/dns-resolvers/resolver.ts +0 -25
- package/src/utils/dns.ts +0 -126
- package/src/utils/tlru.ts +0 -52
package/dist/index.min.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
(function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.HeliaIpns = factory()}(typeof self !== 'undefined' ? self : this, function () {
|
|
2
|
-
"use strict";var HeliaIpns=(()=>{var Hg=Object.create;var ps=Object.defineProperty;var Kg=Object.getOwnPropertyDescriptor;var zg=Object.getOwnPropertyNames;var qg=Object.getPrototypeOf,jg=Object.prototype.hasOwnProperty;var Le=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),M=(r,e)=>{for(var t in e)ps(r,t,{get:e[t],enumerable:!0})},pf=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of zg(e))!jg.call(r,o)&&o!==t&&ps(r,o,{get:()=>e[o],enumerable:!(n=Kg(e,o))||n.enumerable});return r};var Se=(r,e,t)=>(t=r!=null?Hg(qg(r)):{},pf(e||!r||!r.__esModule?ps(t,"default",{value:r,enumerable:!0}):t,r)),Gg=r=>pf(ps({},"__esModule",{value:!0}),r);var ma=Le((vA,gf)=>{var nn=1e3,on=nn*60,sn=on*60,Ur=sn*24,Wg=Ur*7,Yg=Ur*365.25;gf.exports=function(r,e){e=e||{};var t=typeof r;if(t==="string"&&r.length>0)return Zg(r);if(t==="number"&&isFinite(r))return e.long?Xg(r):Jg(r);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(r))};function Zg(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*Yg;case"weeks":case"week":case"w":return t*Wg;case"days":case"day":case"d":return t*Ur;case"hours":case"hour":case"hrs":case"hr":case"h":return t*sn;case"minutes":case"minute":case"mins":case"min":case"m":return t*on;case"seconds":case"second":case"secs":case"sec":case"s":return t*nn;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return t;default:return}}}}function Jg(r){var e=Math.abs(r);return e>=Ur?Math.round(r/Ur)+"d":e>=sn?Math.round(r/sn)+"h":e>=on?Math.round(r/on)+"m":e>=nn?Math.round(r/nn)+"s":r+"ms"}function Xg(r){var e=Math.abs(r);return e>=Ur?ms(r,e,Ur,"day"):e>=sn?ms(r,e,sn,"hour"):e>=on?ms(r,e,on,"minute"):e>=nn?ms(r,e,nn,"second"):r+" ms"}function ms(r,e,t,n){var o=e>=t*1.5;return Math.round(r/t)+" "+n+(o?"s":"")}});var wf=Le((EA,yf)=>{function Qg(r){t.debug=t,t.default=t,t.coerce=c,t.disable=s,t.enable=o,t.enabled=i,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 p=0;p<u.length;p++)l=(l<<5)-l+u.charCodeAt(p),l|=0;return t.colors[Math.abs(l)%t.colors.length]}t.selectColor=e;function t(u){let l,p=null,x,d;function h(...m){if(!h.enabled)return;let g=h,A=Number(new Date),w=A-(l||A);g.diff=w,g.prev=l,g.curr=A,l=A,m[0]=t.coerce(m[0]),typeof m[0]!="string"&&m.unshift("%O");let S=0;m[0]=m[0].replace(/%([a-zA-Z%])/g,(I,C)=>{if(I==="%%")return"%";S++;let y=t.formatters[C];if(typeof y=="function"){let k=m[S];I=y.call(g,k),m.splice(S,1),S--}return I}),t.formatArgs.call(g,m),(g.log||t.log).apply(g,m)}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:()=>p!==null?p:(x!==t.namespaces&&(x=t.namespaces,d=t.enabled(u)),d),set:m=>{p=m}}),typeof t.init=="function"&&t.init(h),h}function n(u,l){let p=t(this.namespace+(typeof l>"u"?":":l)+u);return p.log=this.log,p}function o(u){t.save(u),t.namespaces=u,t.names=[],t.skips=[];let l,p=(typeof u=="string"?u:"").split(/[\s,]+/),x=p.length;for(l=0;l<x;l++)p[l]&&(u=p[l].replace(/\*/g,".*?"),u[0]==="-"?t.skips.push(new RegExp("^"+u.slice(1)+"$")):t.names.push(new RegExp("^"+u+"$")))}function s(){let u=[...t.names.map(a),...t.skips.map(a).map(l=>"-"+l)].join(",");return t.enable(""),u}function i(u){if(u[u.length-1]==="*")return!0;let l,p;for(l=0,p=t.skips.length;l<p;l++)if(t.skips[l].test(u))return!1;for(l=0,p=t.names.length;l<p;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}yf.exports=Qg});var ga=Le((Ze,gs)=>{Ze.formatArgs=ty;Ze.save=ry;Ze.load=ny;Ze.useColors=ey;Ze.storage=oy();Ze.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`."))}})();Ze.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 ey(){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 ty(r){if(r[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+r[0]+(this.useColors?"%c ":" ")+"+"+gs.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)}Ze.log=console.debug||console.log||(()=>{});function ry(r){try{r?Ze.storage.setItem("debug",r):Ze.storage.removeItem("debug")}catch{}}function ny(){let r;try{r=Ze.storage.getItem("debug")}catch{}return!r&&typeof process<"u"&&"env"in process&&(r=process.env.DEBUG),r}function oy(){try{return localStorage}catch{}}gs.exports=wf()(Ze);var{formatters:sy}=gs.exports;sy.j=function(r){try{return JSON.stringify(r)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}});var Bh=Le(Tn=>{"use strict";var Pb="[object ArrayBuffer]",$t=class r{static isArrayBuffer(e){return Object.prototype.toString.call(e)===Pb}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 s=0;s<n.length;s++)if(n[s]!==o[s])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 i of t)n+=i.byteLength;let o=new Uint8Array(n),s=0;for(let i of t){let a=this.toUint8Array(i);o.set(a,s),s+=a.length}return e[e.length-1]instanceof Function?this.toView(o,e[e.length-1]):o.buffer}},Bc="string",Mb=/^[0-9a-f]+$/i,Fb=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/,$b=/^[a-zA-Z0-9-_]+$/,Ps=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=$t.toUint8Array(e),n="";for(let s=0;s<t.length;s++)n+=String.fromCharCode(t[s]);return decodeURIComponent(escape(n))}},it=class{static toString(e,t=!1){let n=$t.toArrayBuffer(e),o=new DataView(n),s="";for(let i=0;i<n.byteLength;i+=2){let a=o.getUint16(i,t);s+=String.fromCharCode(a)}return s}static fromString(e,t=!1){let n=new ArrayBuffer(e.length*2),o=new DataView(n);for(let s=0;s<e.length;s++)o.setUint16(s*2,e.charCodeAt(s),t);return n}},Ms=class r{static isHex(e){return typeof e===Bc&&Mb.test(e)}static isBase64(e){return typeof e===Bc&&Fb.test(e)}static isBase64Url(e){return typeof e===Bc&&$b.test(e)}static ToString(e,t="utf8"){let n=$t.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 it.toString(n,!0);case"utf16":case"utf16be":return it.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 it.fromString(e,!0);case"utf16":case"utf16be":return it.fromString(e);default:throw new Error(`Unknown type of encoding '${t}'`)}}static ToBase64(e){let t=$t.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 Ps.fromString(e);case"utf16":case"utf16be":return it.fromString(e);case"utf16le":case"usc2":return it.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 Ps.toString(e);case"utf16":case"utf16be":return it.toString(e);case"utf16le":case"usc2":return it.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=$t.toUint8Array(e),n="";for(let o=0;o<t.length;o++)n+=String.fromCharCode(t[o]);return n}static ToHex(e){let t=$t.toUint8Array(e),n="",o=t.length;for(let s=0;s<o;s++){let i=t[s];i<16&&(n+="0"),n+=i.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 s=t.slice(o,o+2);n[o/2]=parseInt(s,16)}return n.buffer}static ToUtf16String(e,t=!1){return it.toString(e,t)}static FromUtf16String(e,t=!1){return it.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,"")||""}};Ms.DEFAULT_UTF8_ENCODING="utf8";function Hb(r,...e){let t=arguments[0];for(let n=1;n<arguments.length;n++){let o=arguments[n];for(let s in o)t[s]=o[s]}return t}function Kb(...r){let e=r.map(o=>o.byteLength).reduce((o,s)=>o+s),t=new Uint8Array(e),n=0;return r.map(o=>new Uint8Array(o)).forEach(o=>{for(let s of o)t[n++]=s}),t.buffer}function zb(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}Tn.BufferSourceConverter=$t;Tn.Convert=Ms;Tn.assign=Hb;Tn.combine=Kb;Tn.isEqual=zb});var _o=Le((B3,Ud)=>{"use strict";function Nd(r,e){for(let t in e)Object.defineProperty(r,t,{value:e[t],enumerable:!0,configurable:!0});return r}function Sx(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 Nd(r,t)}catch{t.message=r.message,t.stack=r.stack;let o=function(){};return o.prototype=Object.create(Object.getPrototypeOf(r)),Nd(new o,t)}}Ud.exports=Sx});var Ti=Le((k3,Mc)=>{var T3=function(){typeof Mc<"u"&&(Mc.exports=h);var r=86400,e=3200,t=146097*e/400,n=r*t,o=1e3*n,s=864e13,i=4294967296,a=1e6,c="000000000",f=Math.trunc||function(y){var k=y-y%1;return k==0&&(y<0||y===0&&1/y!=1/0)?-0:k},u=h.prototype,l=(h.fromDate=function(y){return new h(+y)},h.fromInt64BE=S(0,1,2,3,0,4),h.fromInt64LE=S(3,2,1,0,4,0),h.fromString=function(U){var k,O=new h,U=(U+="").replace(/^\s*[+\-]?\d+/,function(H){var H=+H,X=1970+(H-1970)%400;return O.year=H-X,X}).replace(/(?:Z|([+\-]\d{2}):?(\d{2}))$/,function(V,H,X){return H<0&&(X*=-1),k=6e4*(60*+H+ +X),""}).replace(/\.\d+$/,function(V){return O.nano=+(V+c).substr(1,9),""}).split(/\D+/);if(1<U.length?U[1]--:U[1]=0,O.time=k=Date.UTC.apply(Date,U)-(k||0),isNaN(k))throw new TypeError("Invalid Date");return m(O)},h.fromTimeT=function(y){return A(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=m(this);return(y.time%1e3*a+ +y.nano+1e9)%1e9},u.getTimeT=function(){var k=m(this),y=Math.floor(k.time/1e3),k=k.year;return k&&(y+=k*t*r/e),y},u.getYear=function(){return this.toDate().getUTCFullYear()+this.year},u.toDate=function(){return g(m(this).time)},u.toJSON=function(){return this.toString().replace(/0{1,6}Z$/,"Z")},u.toString=function(y){var k=this,O=k.toDate(),U={H:function(){return I(O.getUTCHours())},L:function(){return C(O.getUTCMilliseconds(),3)},M:function(){return I(O.getUTCMinutes())},N:function(){return C(k.getNano(),9)},S:function(){return I(O.getUTCSeconds())},Y:function(){var V=k.getYear();return 999999<V?"+"+V:9999<V?"+"+C(V,6):0<=V?C(V,4):-999999<=V?"-"+C(-V,6):V},a:function(){return x[O.getUTCDay()]},b:function(){return p[O.getUTCMonth()]},d:function(){return I(O.getUTCDate())},e:function(){return function(V){return(9<V?"":" ")+(0|V)}(O.getUTCDate())},m:function(){return I(O.getUTCMonth()+1)}};return function V(H){return H.replace(/%./g,function(X){var R=X[1],B=d[R],R=U[R];return B?V(B):R?R():X})}(y||l)},u.writeInt64BE=w(0,1,2,3,0,4),u.writeInt64LE=w(3,2,1,0,4,0),"%Y-%m-%dT%H:%M:%S.%NZ"),p=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],x=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],d={"%":"%",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,k,O){var U=this;if(!(U instanceof h))return new h(y,k,O);U.time=+y||0,U.nano=+k||0,U.year=+O||0,m(U)}function m(y){var k,O,U,V=y.year,H=y.time,X=y.nano,B=((X<0||a<=X)&&(X-=(O=Math.floor(X/a))*a,H+=O,O=1),V%e);return(H<-s||s<H||B)&&((k=f(H/o))&&(V+=k*e,H-=k*o),(U=g(H)).setUTCFullYear(B+U.getUTCFullYear()),U=(H=+U)+(k=f((V-=B)/e))*o,k&&-s<=U&&U<=s&&(V-=k*e,H=U),O=1),O&&(y.year=V,y.time=H,y.nano=X),y}function g(y){var k=new Date(0);return k.setTime(y),k}function A(V,U){V=+V||0;var O=f((U=(U|0)*i)/n)+f(V/n),U=U%n+V%n,V=f(U/n);return V&&(O+=V,U-=V*n),new h(1e3*U,0,O*e)}function w(y,k,O,U,V,H){return function(B,R){var T=m(this);B=B||new Array(8),v(B,R|=0);var E=Math.floor(T.time/1e3),T=T.year*(t*r/e),$=f(T/i)+f(E/i),T=T%i+E%i,E=Math.floor(T/i);return E&&($+=E,T-=E*i),X(B,R+V,$),X(B,R+H,T),B};function X(B,R,$){B[R+y]=$>>24&255,B[R+k]=$>>16&255,B[R+O]=$>>8&255,B[R+U]=255&$}}function S(y,k,O,U,V,H){return function(B,R){v(B,R|=0);var $=X(B,R+V);return A(X(B,R+H),$)};function X(B,R){return 16777216*B[R+y]+(B[R+k]<<16|B[R+O]<<8|B[R+U])}}function v(y,k){if(y=y&&y.length,y==null)throw new TypeError("Invalid Buffer");if(y<k+8)throw new RangeError("Out of range")}function I(y){return(9<y?"":"0")+(0|y)}function C(y,k){return(c+(0|y)).substr(-k)}}()});var W0=Le((HC,G0)=>{G0.exports=Yu;var j0=128,D2=127,L2=~D2,O2=Math.pow(2,31);function Yu(r,e,t){if(Number.MAX_SAFE_INTEGER&&r>Number.MAX_SAFE_INTEGER)throw Yu.bytes=0,new RangeError("Could not encode varint");e=e||[],t=t||0;for(var n=t;r>=O2;)e[t++]=r&255|j0,r/=128;for(;r&L2;)e[t++]=r&255|j0,r>>>=7;return e[t]=r|0,Yu.bytes=t-n+1,e}});var J0=Le((KC,Z0)=>{Z0.exports=Zu;var V2=128,Y0=127;function Zu(r,n){var t=0,n=n||0,o=0,s=n,i,a=r.length;do{if(s>=a||o>49)throw Zu.bytes=0,new RangeError("Could not decode varint");i=r[s++],t+=o<28?(i&Y0)<<o:(i&Y0)*Math.pow(2,o),o+=7}while(i>=V2);return Zu.bytes=s-n,t}});var Q0=Le((zC,X0)=>{var P2=Math.pow(2,7),M2=Math.pow(2,14),F2=Math.pow(2,21),$2=Math.pow(2,28),H2=Math.pow(2,35),K2=Math.pow(2,42),z2=Math.pow(2,49),q2=Math.pow(2,56),j2=Math.pow(2,63);X0.exports=function(r){return r<P2?1:r<M2?2:r<F2?3:r<$2?4:r<H2?5:r<K2?6:r<z2?7:r<q2?8:r<j2?9:10}});var Qi=Le((qC,em)=>{em.exports={encode:W0(),decode:J0(),encodingLength:Q0()}});var Kl=Le((Vk,og)=>{"use strict";var q8=typeof navigator<"u"&&navigator.product==="ReactNative";function j8(){return q8?"http://localhost":self.location?self.location.protocol+"//"+self.location.host:""}var cs=self.URL,ng=j8(),Hl=class{constructor(e="",t=ng){this.super=new cs(e,t),this.path=this.pathname+this.search,this.auth=this.username&&this.password?this.username+":"+this.password:null,this.query=this.search&&this.search.startsWith("?")?this.search.slice(1):null}get hash(){return this.super.hash}get host(){return this.super.host}get hostname(){return this.super.hostname}get href(){return this.super.href}get origin(){return this.super.origin}get password(){return this.super.password}get pathname(){return this.super.pathname}get port(){return this.super.port}get protocol(){return this.super.protocol}get search(){return this.super.search}get searchParams(){return this.super.searchParams}get username(){return this.super.username}set hash(e){this.super.hash=e}set host(e){this.super.host=e}set hostname(e){this.super.hostname=e}set href(e){this.super.href=e}set password(e){this.super.password=e}set pathname(e){this.super.pathname=e}set port(e){this.super.port=e}set protocol(e){this.super.protocol=e}set search(e){this.super.search=e}set username(e){this.super.username=e}static createObjectURL(e){return cs.createObjectURL(e)}static revokeObjectURL(e){cs.revokeObjectURL(e)}toJSON(){return this.super.toJSON()}toString(){return this.super.toString()}format(){return this.toString()}};function G8(r){if(typeof r=="string")return new cs(r).toString();if(!(r instanceof cs)){let e=r.username&&r.password?`${r.username}:${r.password}@`:"",t=r.auth?r.auth+"@":"",n=r.port?":"+r.port:"",o=r.protocol?r.protocol+"//":"",s=r.host||"",i=r.hostname||"",a=r.search||(r.query?"?"+r.query:""),c=r.hash||"",f=r.pathname||"",u=r.path||f+a;return`${o}${e||t}${s||i+n}${u}${c}`}}og.exports={URLWithLegacySupport:Hl,URLSearchParams:self.URLSearchParams,defaultBase:ng,format:G8}});var ag=Le((Pk,ig)=>{"use strict";var{URLWithLegacySupport:sg,format:W8}=Kl();ig.exports=(r,e={},t={},n)=>{let o=e.protocol?e.protocol.replace(":",""):"http";o=(t[o]||n||o)+":";let s;try{s=new sg(r)}catch{s={}}let i=Object.assign({},e,{protocol:o||s.protocol,host:e.host||s.host});return new sg(r,W8(i)).toString()}});var ug=Le((Mk,cg)=>{"use strict";var{URLWithLegacySupport:Y8,format:Z8,URLSearchParams:J8,defaultBase:X8}=Kl(),Q8=ag();cg.exports={URL:Y8,URLSearchParams:J8,format:Z8,relative:Q8,defaultBase:X8}});var mg=Le((Wk,pg)=>{"use strict";pg.exports=dg;var oA=ma(),Rr=dg.prototype,sA=new Date%1e9;function iA(){return(Math.random()*1e9>>>0)+sA++}function dg(r){r=r||{},this.id=r.id||iA(),this.max=r.max||1/0,this.items=r.items||[],this._lookup={},this.size=this.items.length,this.lastModified=new Date(r.lastModified||new Date);for(var e,t,n=this.items.length;n--;)e=this.items[n],t=new Date(e.expires)-new Date,this._lookup[e.key]=e,t>0?this.expire(e.key,t):t<=0&&this.delete(e.key)}Rr.has=function(r){return r in this._lookup};Rr.get=function(r){if(!this.has(r))return null;var e=this._lookup[r];return e.refresh&&this.expire(r,e.refresh),this.items.splice(this.items.indexOf(e),1),this.items.push(e),e.value};Rr.meta=function(r){if(!this.has(r))return null;var e=this._lookup[r];return"meta"in e?e.meta:null};Rr.set=function(r,e,t){var n=this._lookup[r],o=this._lookup[r]={key:r,value:e};return this.lastModified=new Date,n?(clearTimeout(n.timeout),this.items.splice(this.items.indexOf(n),1,o)):(this.size>=this.max&&this.delete(this.items[0].key),this.items.push(o),this.size++),t&&("ttl"in t&&this.expire(r,t.ttl),"meta"in t&&(o.meta=t.meta),t.refresh&&(o.refresh=t.ttl)),this};Rr.delete=function(r){var e=this._lookup[r];return e?(this.lastModified=new Date,this.items.splice(this.items.indexOf(e),1),clearTimeout(e.timeout),delete this._lookup[r],this.size--,this):!1};Rr.expire=function(r,e){var t=e||0,n=this._lookup[r];if(!n)return this;if(typeof t=="string"&&(t=oA(e)),typeof t!="number")throw new TypeError("Expiration time must be a string or number.");return clearTimeout(n.timeout),n.timeout=setTimeout(this.delete.bind(this,n.key),t),n.expires=Number(new Date)+t,this};Rr.clear=function(){for(var r=this.items.length;r--;)this.delete(this.items[r].key);return this};Rr.toJSON=function(){for(var r=new Array(this.items.length),e,t=r.length;t--;)e=this.items[t],r[t]={key:e.key,meta:e.meta,value:e.value,expires:e.expires,refresh:e.refresh};return{id:this.id,max:isFinite(this.max)?this.max:void 0,lastModified:this.lastModified,items:r}}});var bg=Le((Zk,Yl)=>{"use strict";var cA=Object.prototype.hasOwnProperty,ze="~";function us(){}Object.create&&(us.prototype=Object.create(null),new us().__proto__||(ze=!1));function uA(r,e,t){this.fn=r,this.context=e,this.once=t||!1}function wg(r,e,t,n,o){if(typeof t!="function")throw new TypeError("The listener must be a function");var s=new uA(t,n||r,o),i=ze?ze+e:e;return r._events[i]?r._events[i].fn?r._events[i]=[r._events[i],s]:r._events[i].push(s):(r._events[i]=s,r._eventsCount++),r}function fa(r,e){--r._eventsCount===0?r._events=new us:delete r._events[e]}function Me(){this._events=new us,this._eventsCount=0}Me.prototype.eventNames=function(){var e=[],t,n;if(this._eventsCount===0)return e;for(n in t=this._events)cA.call(t,n)&&e.push(ze?n.slice(1):n);return Object.getOwnPropertySymbols?e.concat(Object.getOwnPropertySymbols(t)):e};Me.prototype.listeners=function(e){var t=ze?ze+e:e,n=this._events[t];if(!n)return[];if(n.fn)return[n.fn];for(var o=0,s=n.length,i=new Array(s);o<s;o++)i[o]=n[o].fn;return i};Me.prototype.listenerCount=function(e){var t=ze?ze+e:e,n=this._events[t];return n?n.fn?1:n.length:0};Me.prototype.emit=function(e,t,n,o,s,i){var a=ze?ze+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,s),!0;case 6:return c.fn.call(c.context,t,n,o,s,i),!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 p=c.length,x;for(l=0;l<p;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(x=1,u=new Array(f-1);x<f;x++)u[x-1]=arguments[x];c[l].fn.apply(c[l].context,u)}}return!0};Me.prototype.on=function(e,t,n){return wg(this,e,t,n,!1)};Me.prototype.once=function(e,t,n){return wg(this,e,t,n,!0)};Me.prototype.removeListener=function(e,t,n,o){var s=ze?ze+e:e;if(!this._events[s])return this;if(!t)return fa(this,s),this;var i=this._events[s];if(i.fn)i.fn===t&&(!o||i.once)&&(!n||i.context===n)&&fa(this,s);else{for(var a=0,c=[],f=i.length;a<f;a++)(i[a].fn!==t||o&&!i[a].once||n&&i[a].context!==n)&&c.push(i[a]);c.length?this._events[s]=c.length===1?c[0]:c:fa(this,s)}return this};Me.prototype.removeAllListeners=function(e){var t;return e?(t=ze?ze+e:e,this._events[t]&&fa(this,t)):(this._events=new us,this._eventsCount=0),this};Me.prototype.off=Me.prototype.removeListener;Me.prototype.addListener=Me.prototype.on;Me.prefixed=ze;Me.EventEmitter=Me;typeof Yl<"u"&&(Yl.exports=Me)});var Ag=Le((iR,Eg)=>{Eg.exports=function(r){if(!r)throw Error("hashlru must have a max value, of type number, greater than 0");var e=0,t=Object.create(null),n=Object.create(null);function o(s,i){t[s]=i,e++,e>=r&&(e=0,n=t,t=Object.create(null))}return{has:function(s){return t[s]!==void 0||n[s]!==void 0},remove:function(s){t[s]!==void 0&&(t[s]=void 0),n[s]!==void 0&&(n[s]=void 0)},get:function(s){var i=t[s];if(i!==void 0)return i;if((i=n[s])!==void 0)return o(s,i),i},set:function(s,i){t[s]!==void 0?t[s]=i:o(s,i)},clear:function(){t=Object.create(null),n=Object.create(null)}}}});var yA={};M(yA,{ipns:()=>gA,ipnsSelector:()=>Hi,ipnsValidator:()=>ru});var pa=Symbol.for("@libp2p/peer-id");function mf(r){return r!=null&&!!r[pa]}var K=class extends Error{code;props;constructor(e,t,n){super(e),this.code=t,this.name=n?.name??"CodeError",this.props=n??{}}};var Je=Se(ga(),1);var va={};M(va,{base32:()=>sr,base32hex:()=>dy,base32hexpad:()=>my,base32hexpadupper:()=>gy,base32hexupper:()=>py,base32pad:()=>fy,base32padupper:()=>hy,base32upper:()=>Sf,base32z:()=>yy});var AA=new Uint8Array(0);function bf(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 Dt(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 xf(r){return new TextEncoder().encode(r)}function vf(r){return new TextDecoder().decode(r)}function iy(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 s=r.charAt(o),i=s.charCodeAt(0);if(t[i]!==255)throw new TypeError(s+" is ambiguous");t[i]=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(d){if(d instanceof Uint8Array||(ArrayBuffer.isView(d)?d=new Uint8Array(d.buffer,d.byteOffset,d.byteLength):Array.isArray(d)&&(d=Uint8Array.from(d))),!(d instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(d.length===0)return"";for(var h=0,m=0,g=0,A=d.length;g!==A&&d[g]===0;)g++,h++;for(var w=(A-g)*u+1>>>0,S=new Uint8Array(w);g!==A;){for(var v=d[g],I=0,C=w-1;(v!==0||I<m)&&C!==-1;C--,I++)v+=256*S[C]>>>0,S[C]=v%a>>>0,v=v/a>>>0;if(v!==0)throw new Error("Non-zero carry");m=I,g++}for(var y=w-m;y!==w&&S[y]===0;)y++;for(var k=c.repeat(h);y<w;++y)k+=r.charAt(S[y]);return k}function p(d){if(typeof d!="string")throw new TypeError("Expected String");if(d.length===0)return new Uint8Array;var h=0;if(d[h]!==" "){for(var m=0,g=0;d[h]===c;)m++,h++;for(var A=(d.length-h)*f+1>>>0,w=new Uint8Array(A);d[h];){var S=t[d.charCodeAt(h)];if(S===255)return;for(var v=0,I=A-1;(S!==0||v<g)&&I!==-1;I--,v++)S+=a*w[I]>>>0,w[I]=S%256>>>0,S=S/256>>>0;if(S!==0)throw new Error("Non-zero carry");g=v,h++}if(d[h]!==" "){for(var C=A-g;C!==A&&w[C]===0;)C++;for(var y=new Uint8Array(m+(A-C)),k=m;C!==A;)y[k++]=w[C++];return y}}}function x(d){var h=p(d);if(h)return h;throw new Error(`Non-${e} character`)}return{encode:l,decodeUnsafe:p,decode:x}}var ay=iy,cy=ay,Af=cy;var ya=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")}},wa=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 Bf(this,e)}},ba=class{decoders;constructor(e){this.decoders=e}or(e){return Bf(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 Bf(r,e){return new ba({...r.decoders??{[r.prefix]:r},...e.decoders??{[e.prefix]:e}})}var xa=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 ya(e,t,n),this.decoder=new wa(e,t,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};function an({name:r,prefix:e,encode:t,decode:n}){return new xa(r,e,t,n)}function or({name:r,prefix:e,alphabet:t}){let{encode:n,decode:o}=Af(t,r);return an({prefix:e,name:r,encode:n,decode:s=>Dt(o(s))})}function uy(r,e,t,n){let o={};for(let u=0;u<e.length;++u)o[e[u]]=u;let s=r.length;for(;r[s-1]==="=";)--s;let i=new Uint8Array(s*t/8|0),a=0,c=0,f=0;for(let u=0;u<s;++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,i[f++]=255&c>>a)}if(a>=t||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return i}function ly(r,e,t){let n=e[e.length-1]==="=",o=(1<<t)-1,s="",i=0,a=0;for(let c=0;c<r.length;++c)for(a=a<<8|r[c],i+=8;i>t;)i-=t,s+=e[o&a>>i];if(i!==0&&(s+=e[o&a<<t-i]),n)for(;s.length*t&7;)s+="=";return s}function he({name:r,prefix:e,bitsPerChar:t,alphabet:n}){return an({prefix:e,name:r,encode(o){return ly(o,n,t)},decode(o){return uy(o,n,t,r)}})}var sr=he({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Sf=he({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),fy=he({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),hy=he({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),dy=he({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),py=he({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),my=he({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),gy=he({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),yy=he({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Ea={};M(Ea,{base58btc:()=>Ie,base58flickr:()=>wy});var Ie=or({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),wy=or({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Aa={};M(Aa,{base64:()=>ao,base64pad:()=>by,base64url:()=>xy,base64urlpad:()=>vy});var ao=he({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),by=he({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),xy=he({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),vy=he({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});Je.default.formatters.b=r=>r==null?"undefined":Ie.baseEncode(r);Je.default.formatters.t=r=>r==null?"undefined":sr.baseEncode(r);Je.default.formatters.m=r=>r==null?"undefined":ao.baseEncode(r);Je.default.formatters.p=r=>r==null?"undefined":r.toString();Je.default.formatters.c=r=>r==null?"undefined":r.toString();Je.default.formatters.k=r=>r==null?"undefined":r.toString();Je.default.formatters.a=r=>r==null?"undefined":r.toString();function Ey(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 ir(r){let e=Ey(`${r}:trace`);return Je.default.enabled(`${r}:trace`)&&Je.default.names.map(t=>t.toString()).find(t=>t.includes(":trace"))!=null&&(e=(0,Je.default)(`${r}:trace`)),Object.assign((0,Je.default)(r),{error:(0,Je.default)(`${r}:error`),trace:e})}var Ba={};M(Ba,{base10:()=>Ay});var Ay=or({prefix:"9",name:"base10",alphabet:"0123456789"});var Sa={};M(Sa,{base16:()=>By,base16upper:()=>Sy});var By=he({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Sy=he({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Ia={};M(Ia,{base2:()=>Iy});var Iy=he({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Ca={};M(Ca,{base256emoji:()=>Ny});var If=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}"),Cy=If.reduce((r,e,t)=>(r[t]=e,r),[]),Ty=If.reduce((r,e,t)=>(r[e.codePointAt(0)]=t,r),[]);function ky(r){return r.reduce((e,t)=>(e+=Cy[t],e),"")}function Ry(r){let e=[];for(let t of r){let n=Ty[t.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${t}`);e.push(n)}return new Uint8Array(e)}var Ny=an({prefix:"\u{1F680}",name:"base256emoji",encode:ky,decode:Ry});var Ta={};M(Ta,{base36:()=>ys,base36upper:()=>Uy});var ys=or({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Uy=or({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var ka={};M(ka,{base8:()=>_y});var _y=he({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Ra={};M(Ra,{identity:()=>Dy});var Dy=an({prefix:"\0",name:"identity",encode:r=>vf(r),decode:r=>xf(r)});var KA=new TextEncoder,zA=new TextDecoder;var Ua={};M(Ua,{identity:()=>Et});var Vy=kf,Cf=128,Py=127,My=~Py,Fy=Math.pow(2,31);function kf(r,e,t){e=e||[],t=t||0;for(var n=t;r>=Fy;)e[t++]=r&255|Cf,r/=128;for(;r&My;)e[t++]=r&255|Cf,r>>>=7;return e[t]=r|0,kf.bytes=t-n+1,e}var $y=Na,Hy=128,Tf=127;function Na(r,n){var t=0,n=n||0,o=0,s=n,i,a=r.length;do{if(s>=a)throw Na.bytes=0,new RangeError("Could not decode varint");i=r[s++],t+=o<28?(i&Tf)<<o:(i&Tf)*Math.pow(2,o),o+=7}while(i>=Hy);return Na.bytes=s-n,t}var Ky=Math.pow(2,7),zy=Math.pow(2,14),qy=Math.pow(2,21),jy=Math.pow(2,28),Gy=Math.pow(2,35),Wy=Math.pow(2,42),Yy=Math.pow(2,49),Zy=Math.pow(2,56),Jy=Math.pow(2,63),Xy=function(r){return r<Ky?1:r<zy?2:r<qy?3:r<jy?4:r<Gy?5:r<Wy?6:r<Yy?7:r<Zy?8:r<Jy?9:10},Qy={encode:Vy,decode:$y,encodingLength:Xy},ew=Qy,co=ew;function uo(r,e=0){return[co.decode(r,e),co.decode.bytes]}function cn(r,e,t=0){return co.encode(r,e,t),e}function un(r){return co.encodingLength(r)}function vt(r,e){let t=e.byteLength,n=un(r),o=n+un(t),s=new Uint8Array(o+t);return cn(r,s,0),cn(t,s,n),s.set(e,o),new ln(r,t,e,s)}function _r(r){let e=Dt(r),[t,n]=uo(e),[o,s]=uo(e.subarray(n)),i=e.subarray(n+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new ln(t,o,i,e)}function Rf(r,e){if(r===e)return!0;{let t=e;return r.code===t.code&&r.size===t.size&&t.bytes instanceof Uint8Array&&bf(r.bytes,t.bytes)}}var ln=class{code;size;digest;bytes;constructor(e,t,n,o){this.code=e,this.size=t,this.digest=n,this.bytes=o}};var Nf=0,tw="identity",Uf=Dt;function rw(r){return vt(Nf,Uf(r))}var Et={code:Nf,name:tw,encode:Uf,digest:rw};var La={};M(La,{sha256:()=>Ce,sha512:()=>nw});function Da({name:r,code:e,encode:t}){return new _a(r,e,t)}var _a=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?vt(this.code,t):t.then(n=>vt(this.code,n))}else throw Error("Unknown type, must be binary type")}};function Df(r){return async e=>new Uint8Array(await crypto.subtle.digest(r,e))}var Ce=Da({name:"sha2-256",code:18,encode:Df("SHA-256")}),nw=Da({name:"sha2-512",code:19,encode:Df("SHA-512")});function Lf(r,e){let{bytes:t,version:n}=r;switch(n){case 0:return sw(t,Oa(r),e??Ie.encoder);default:return iw(t,Oa(r),e??sr.encoder)}}var Of=new WeakMap;function Oa(r){let e=Of.get(r);if(e==null){let t=new Map;return Of.set(r,t),t}return e}var Xe=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!==lo)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==aw)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=vt(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&&Rf(e.multihash,n.multihash)}toString(e){return Lf(this,e)}toJSON(){return{"/":Lf(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:s,bytes:i}=t;return new r(n,o,s,i??Vf(n,o,s.bytes))}else if(t[cw]===!0){let{version:n,multihash:o,code:s}=t,i=_r(o);return r.create(n,s,i)}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!==lo)throw new Error(`Version 0 CID must use dag-pb (code: ${lo}) block encoding`);return new r(e,t,n,n.bytes)}case 1:{let o=Vf(e,t,n.bytes);return new r(e,t,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return r.create(0,lo,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=Dt(e.subarray(n,n+t.multihashSize));if(o.byteLength!==t.multihashSize)throw new Error("Incorrect length");let s=o.subarray(t.multihashSize-t.digestSize),i=new ln(t.multihashCode,t.digestSize,s,o);return[t.version===0?r.createV0(i):r.createV1(t.codec,i),e.subarray(t.size)]}static inspectBytes(e){let t=0,n=()=>{let[l,p]=uo(e.subarray(t));return t+=p,l},o=n(),s=lo;if(o===18?(o=0,t=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let i=t,a=n(),c=n(),f=t+c,u=f-i;return{version:o,codec:s,multihashCode:a,digestSize:c,multihashSize:u,size:f}}static parse(e,t){let[n,o]=ow(e,t),s=r.decode(o);if(s.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Oa(s).set(n,e),s}};function ow(r,e){switch(r[0]){case"Q":{let t=e??Ie;return[Ie.prefix,t.decode(`${Ie.prefix}${r}`)]}case Ie.prefix:{let t=e??Ie;return[Ie.prefix,t.decode(r)]}case sr.prefix:{let t=e??sr;return[sr.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 sw(r,e,t){let{prefix:n}=t;if(n!==Ie.prefix)throw Error(`Cannot string encode V0 in ${t.name} encoding`);let o=e.get(n);if(o==null){let s=t.encode(r).slice(1);return e.set(n,s),s}else return o}function iw(r,e,t){let{prefix:n}=t,o=e.get(n);if(o==null){let s=t.encode(r);return e.set(n,s),s}else return o}var lo=112,aw=18;function Vf(r,e,t){let n=un(r),o=n+un(e),s=new Uint8Array(o+t.byteLength);return cn(r,s,0),cn(e,s,n),s.set(t,o),s}var cw=Symbol.for("@ipld/js-cid/CID");var fn={...Ra,...Ia,...ka,...Ba,...Sa,...va,...Ta,...Ea,...Aa,...Ca},fB={...La,...Ua};function Te(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 uw=Symbol.for("nodejs.util.inspect.custom"),Pf=Object.values(fn).map(r=>r.decoder).reduce((r,e)=>r.or(e),fn.identity.decoder),Mf=114,Va=36,Pa=37,fo=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()})`}[pa]=!0;toString(){return this.string==null&&(this.string=Ie.encode(this.multihash.bytes).slice(1)),this.string}toCID(){return Xe.createV1(Mf,this.multihash)}toBytes(){return this.multihash.bytes}toJSON(){return this.toString()}equals(e){if(e==null)return!1;if(e instanceof Uint8Array)return Te(this.multihash.bytes,e);if(typeof e=="string")return Ma(e).equals(this);if(e?.multihash?.bytes!=null)return Te(this.multihash.bytes,e.multihash.bytes);throw new Error("not valid Id")}[uw](){return`PeerId(${this.toString()})`}},hn=class extends fo{type="RSA";publicKey;constructor(e){super({...e,type:"RSA"}),this.publicKey=e.publicKey}},dn=class extends fo{type="Ed25519";publicKey;constructor(e){super({...e,type:"Ed25519"}),this.publicKey=e.multihash.digest}},pn=class extends fo{type="secp256k1";publicKey;constructor(e){super({...e,type:"secp256k1"}),this.publicKey=e.multihash.digest}};function Ma(r,e){if(e=e??Pf,r.charAt(0)==="1"||r.charAt(0)==="Q"){let t=_r(Ie.decode(`z${r}`));return r.startsWith("12D")?new dn({multihash:t}):r.startsWith("16U")?new pn({multihash:t}):new hn({multihash:t})}return Fa(Pf.decode(r))}function Fa(r){try{let e=_r(r);if(e.code===Et.code){if(e.digest.length===Va)return new dn({multihash:e});if(e.digest.length===Pa)return new pn({multihash:e})}if(e.code===Ce.code)return new hn({multihash:e})}catch{return lw(Xe.decode(r))}throw new Error("Supplied PeerID CID is invalid")}function lw(r){if(r==null||r.multihash==null||r.version==null||r.version===1&&r.code!==Mf)throw new Error("Supplied PeerID CID is invalid");let e=r.multihash;if(e.code===Ce.code)return new hn({multihash:r.multihash});if(e.code===Et.code){if(e.digest.length===Va)return new dn({multihash:r.multihash});if(e.digest.length===Pa)return new pn({multihash:r.multihash})}throw new Error("Supplied PeerID CID is invalid")}async function Ff(r,e){return r.length===Va?new dn({multihash:vt(Et.code,r),privateKey:e}):r.length===Pa?new pn({multihash:vt(Et.code,r),privateKey:e}):new hn({multihash:await Ce.digest(r),publicKey:r,privateKey:e})}var Ec={};M(Ec,{Ed25519PrivateKey:()=>Kr,Ed25519PublicKey:()=>wo,generateKeyPair:()=>Lb,generateKeyPairFromSeed:()=>Ah,unmarshalEd25519PrivateKey:()=>_b,unmarshalEd25519PublicKey:()=>Db});function Lr(r){return globalThis.Buffer!=null?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r}function ft(r=0){return globalThis.Buffer?.allocUnsafe!=null?Lr(globalThis.Buffer.allocUnsafe(r)):new Uint8Array(r)}function Or(r,e){if(globalThis.Buffer!=null)return Lr(globalThis.Buffer.concat(r,e));e==null&&(e=r.reduce((o,s)=>o+s.length,0));let t=ft(e),n=0;for(let o of r)t.set(o,n),n+=o.length;return Lr(t)}function Hf(r,e,t,n){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:n}}}var $f=Hf("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),$a=Hf("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=ft(r.length);for(let t=0;t<r.length;t++)e[t]=r.charCodeAt(t);return e}),fw={utf8:$f,"utf-8":$f,hex:fn.base16,latin1:$a,ascii:$a,binary:$a,...fn},bs=fw;function ee(r,e="utf8"){let t=bs[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?Lr(globalThis.Buffer.from(r,"utf-8")):t.decoder.decode(`${t.prefix}${r}`)}function st(r){return r==null?!1:typeof r.then=="function"&&typeof r.catch=="function"&&typeof r.finally=="function"}function mn(r){if(!Number.isSafeInteger(r)||r<0)throw new Error(`Wrong positive integer: ${r}`)}function hw(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}function Ha(r,...e){if(!hw(r))throw new Error("Expected Uint8Array");if(e.length>0&&!e.includes(r.length))throw new Error(`Expected Uint8Array of length ${e}, not of length=${r.length}`)}function xs(r){if(typeof r!="function"||typeof r.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");mn(r.outputLen),mn(r.blockLen)}function gn(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 Kf(r,e){Ha(r);let t=e.outputLen;if(r.length<t)throw new Error(`digestInto() expects output buffer of length at least ${t}`)}var vs=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function zf(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}var wn=r=>new DataView(r.buffer,r.byteOffset,r.byteLength),ht=(r,e)=>r<<32-e|r>>>e,dw=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!dw)throw new Error("Non little-endian hardware is not supported");var pw=async()=>{};async function qf(r,e,t){let n=Date.now();for(let o=0;o<r;o++){t(o);let s=Date.now()-n;s>=0&&s<e||(await pw(),n+=s)}}function Ka(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}function ar(r){if(typeof r=="string"&&(r=Ka(r)),!zf(r))throw new Error(`expected Uint8Array, got ${typeof r}`);return r}function Es(...r){let e=0;for(let n=0;n<r.length;n++){let o=r[n];if(!zf(o))throw new Error("Uint8Array expected");e+=o.length}let t=new Uint8Array(e);for(let n=0,o=0;n<r.length;n++){let s=r[n];t.set(s,o),o+=s.length}return t}var yn=class{clone(){return this._cloneInto()}},mw={}.toString;function jf(r,e){if(e!==void 0&&mw.call(e)!=="[object Object]")throw new Error("Options should be object or undefined");return Object.assign(r,e)}function As(r){let e=n=>r().update(ar(n)).digest(),t=r();return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=()=>r(),e}function bn(r=32){if(vs&&typeof vs.getRandomValues=="function")return vs.getRandomValues(new Uint8Array(r));throw new Error("crypto.getRandomValues must be defined")}function gw(r,e,t,n){if(typeof r.setBigUint64=="function")return r.setBigUint64(e,t,n);let o=BigInt(32),s=BigInt(4294967295),i=Number(t>>o&s),a=Number(t&s),c=n?4:0,f=n?0:4;r.setUint32(e+c,i,n),r.setUint32(e+f,a,n)}var xn=class extends yn{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=wn(this.buffer)}update(e){gn(this);let{view:t,buffer:n,blockLen:o}=this;e=ar(e);let s=e.length;for(let i=0;i<s;){let a=Math.min(o-this.pos,s-i);if(a===o){let c=wn(e);for(;o<=s-i;i+=o)this.process(c,i);continue}n.set(e.subarray(i,i+a),this.pos),this.pos+=a,i+=a,this.pos===o&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){gn(this),Kf(e,this),this.finished=!0;let{buffer:t,view:n,blockLen:o,isLE:s}=this,{pos:i}=this;t[i++]=128,this.buffer.subarray(i).fill(0),this.padOffset>o-i&&(this.process(n,0),i=0);for(let l=i;l<o;l++)t[l]=0;gw(n,o-8,BigInt(this.length*8),s),this.process(n,0);let a=wn(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],s)}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:s,destroyed:i,pos:a}=this;return e.length=o,e.pos=a,e.finished=s,e.destroyed=i,o%t&&e.buffer.set(n),e}};var Bs=BigInt(4294967295),za=BigInt(32);function Gf(r,e=!1){return e?{h:Number(r&Bs),l:Number(r>>za&Bs)}:{h:Number(r>>za&Bs)|0,l:Number(r&Bs)|0}}function yw(r,e=!1){let t=new Uint32Array(r.length),n=new Uint32Array(r.length);for(let o=0;o<r.length;o++){let{h:s,l:i}=Gf(r[o],e);[t[o],n[o]]=[s,i]}return[t,n]}var ww=(r,e)=>BigInt(r>>>0)<<za|BigInt(e>>>0),bw=(r,e,t)=>r>>>t,xw=(r,e,t)=>r<<32-t|e>>>t,vw=(r,e,t)=>r>>>t|e<<32-t,Ew=(r,e,t)=>r<<32-t|e>>>t,Aw=(r,e,t)=>r<<64-t|e>>>t-32,Bw=(r,e,t)=>r>>>t-32|e<<64-t,Sw=(r,e)=>e,Iw=(r,e)=>r,Cw=(r,e,t)=>r<<t|e>>>32-t,Tw=(r,e,t)=>e<<t|r>>>32-t,kw=(r,e,t)=>e<<t-32|r>>>64-t,Rw=(r,e,t)=>r<<t-32|e>>>64-t;function Nw(r,e,t,n){let o=(e>>>0)+(n>>>0);return{h:r+t+(o/2**32|0)|0,l:o|0}}var Uw=(r,e,t)=>(r>>>0)+(e>>>0)+(t>>>0),_w=(r,e,t,n)=>e+t+n+(r/2**32|0)|0,Dw=(r,e,t,n)=>(r>>>0)+(e>>>0)+(t>>>0)+(n>>>0),Lw=(r,e,t,n,o)=>e+t+n+o+(r/2**32|0)|0,Ow=(r,e,t,n,o)=>(r>>>0)+(e>>>0)+(t>>>0)+(n>>>0)+(o>>>0),Vw=(r,e,t,n,o,s)=>e+t+n+o+s+(r/2**32|0)|0;var Pw={fromBig:Gf,split:yw,toBig:ww,shrSH:bw,shrSL:xw,rotrSH:vw,rotrSL:Ew,rotrBH:Aw,rotrBL:Bw,rotr32H:Sw,rotr32L:Iw,rotlSH:Cw,rotlSL:Tw,rotlBH:kw,rotlBL:Rw,add:Nw,add3L:Uw,add3H:_w,add4L:Dw,add4H:Lw,add5H:Vw,add5L:Ow},G=Pw;var[Mw,Fw]=G.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))),cr=new Uint32Array(80),ur=new Uint32Array(80),qa=class extends xn{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:s,Cl:i,Dh:a,Dl:c,Eh:f,El:u,Fh:l,Fl:p,Gh:x,Gl:d,Hh:h,Hl:m}=this;return[e,t,n,o,s,i,a,c,f,u,l,p,x,d,h,m]}set(e,t,n,o,s,i,a,c,f,u,l,p,x,d,h,m){this.Ah=e|0,this.Al=t|0,this.Bh=n|0,this.Bl=o|0,this.Ch=s|0,this.Cl=i|0,this.Dh=a|0,this.Dl=c|0,this.Eh=f|0,this.El=u|0,this.Fh=l|0,this.Fl=p|0,this.Gh=x|0,this.Gl=d|0,this.Hh=h|0,this.Hl=m|0}process(e,t){for(let w=0;w<16;w++,t+=4)cr[w]=e.getUint32(t),ur[w]=e.getUint32(t+=4);for(let w=16;w<80;w++){let S=cr[w-15]|0,v=ur[w-15]|0,I=G.rotrSH(S,v,1)^G.rotrSH(S,v,8)^G.shrSH(S,v,7),C=G.rotrSL(S,v,1)^G.rotrSL(S,v,8)^G.shrSL(S,v,7),y=cr[w-2]|0,k=ur[w-2]|0,O=G.rotrSH(y,k,19)^G.rotrBH(y,k,61)^G.shrSH(y,k,6),U=G.rotrSL(y,k,19)^G.rotrBL(y,k,61)^G.shrSL(y,k,6),V=G.add4L(C,U,ur[w-7],ur[w-16]),H=G.add4H(V,I,O,cr[w-7],cr[w-16]);cr[w]=H|0,ur[w]=V|0}let{Ah:n,Al:o,Bh:s,Bl:i,Ch:a,Cl:c,Dh:f,Dl:u,Eh:l,El:p,Fh:x,Fl:d,Gh:h,Gl:m,Hh:g,Hl:A}=this;for(let w=0;w<80;w++){let S=G.rotrSH(l,p,14)^G.rotrSH(l,p,18)^G.rotrBH(l,p,41),v=G.rotrSL(l,p,14)^G.rotrSL(l,p,18)^G.rotrBL(l,p,41),I=l&x^~l&h,C=p&d^~p&m,y=G.add5L(A,v,C,Fw[w],ur[w]),k=G.add5H(y,g,S,I,Mw[w],cr[w]),O=y|0,U=G.rotrSH(n,o,28)^G.rotrBH(n,o,34)^G.rotrBH(n,o,39),V=G.rotrSL(n,o,28)^G.rotrBL(n,o,34)^G.rotrBL(n,o,39),H=n&s^n&a^s&a,X=o&i^o&c^i&c;g=h|0,A=m|0,h=x|0,m=d|0,x=l|0,d=p|0,{h:l,l:p}=G.add(f|0,u|0,k|0,O|0),f=a|0,u=c|0,a=s|0,c=i|0,s=n|0,i=o|0;let B=G.add3L(O,V,X);n=G.add3H(B,k,U,H),o=B|0}({h:n,l:o}=G.add(this.Ah|0,this.Al|0,n|0,o|0)),{h:s,l:i}=G.add(this.Bh|0,this.Bl|0,s|0,i|0),{h:a,l:c}=G.add(this.Ch|0,this.Cl|0,a|0,c|0),{h:f,l:u}=G.add(this.Dh|0,this.Dl|0,f|0,u|0),{h:l,l:p}=G.add(this.Eh|0,this.El|0,l|0,p|0),{h:x,l:d}=G.add(this.Fh|0,this.Fl|0,x|0,d|0),{h,l:m}=G.add(this.Gh|0,this.Gl|0,h|0,m|0),{h:g,l:A}=G.add(this.Hh|0,this.Hl|0,g|0,A|0),this.set(n,o,s,i,a,c,f,u,l,p,x,d,h,m,g,A)}roundClean(){cr.fill(0),ur.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 vn=As(()=>new qa);var Is={};M(Is,{bitGet:()=>Gw,bitLen:()=>jw,bitMask:()=>ho,bitSet:()=>Ww,bytesToHex:()=>Ot,bytesToNumberBE:()=>Vt,bytesToNumberLE:()=>lr,concatBytes:()=>Pt,createHmacDrbg:()=>Wa,ensureBytes:()=>de,equalBytes:()=>zw,hexToBytes:()=>Vr,hexToNumber:()=>Ga,isBytes:()=>dt,numberToBytesBE:()=>fr,numberToBytesLE:()=>Pr,numberToHexUnpadded:()=>Jf,numberToVarBytesBE:()=>Kw,utf8ToBytes:()=>qw,validateObject:()=>At});var Zf=BigInt(0),Ss=BigInt(1),$w=BigInt(2);function dt(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}var Hw=Array.from({length:256},(r,e)=>e.toString(16).padStart(2,"0"));function Ot(r){if(!dt(r))throw new Error("Uint8Array expected");let e="";for(let t=0;t<r.length;t++)e+=Hw[r[t]];return e}function Jf(r){let e=r.toString(16);return e.length&1?`0${e}`:e}function Ga(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return BigInt(r===""?"0":`0x${r}`)}var Lt={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function Wf(r){if(r>=Lt._0&&r<=Lt._9)return r-Lt._0;if(r>=Lt._A&&r<=Lt._F)return r-(Lt._A-10);if(r>=Lt._a&&r<=Lt._f)return r-(Lt._a-10)}function Vr(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,s=0;o<t;o++,s+=2){let i=Wf(r.charCodeAt(s)),a=Wf(r.charCodeAt(s+1));if(i===void 0||a===void 0){let c=r[s]+r[s+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+s)}n[o]=i*16+a}return n}function Vt(r){return Ga(Ot(r))}function lr(r){if(!dt(r))throw new Error("Uint8Array expected");return Ga(Ot(Uint8Array.from(r).reverse()))}function fr(r,e){return Vr(r.toString(16).padStart(e*2,"0"))}function Pr(r,e){return fr(r,e).reverse()}function Kw(r){return Vr(Jf(r))}function de(r,e,t){let n;if(typeof e=="string")try{n=Vr(e)}catch(s){throw new Error(`${r} must be valid hex string, got "${e}". Cause: ${s}`)}else if(dt(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 Pt(...r){let e=0;for(let o=0;o<r.length;o++){let s=r[o];if(!dt(s))throw new Error("Uint8Array expected");e+=s.length}let t=new Uint8Array(e),n=0;for(let o=0;o<r.length;o++){let s=r[o];t.set(s,n),n+=s.length}return t}function zw(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 qw(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}function jw(r){let e;for(e=0;r>Zf;r>>=Ss,e+=1);return e}function Gw(r,e){return r>>BigInt(e)&Ss}var Ww=(r,e,t)=>r|(t?Ss:Zf)<<BigInt(e),ho=r=>($w<<BigInt(r-1))-Ss,ja=r=>new Uint8Array(r),Yf=r=>Uint8Array.from(r);function Wa(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=ja(r),o=ja(r),s=0,i=()=>{n.fill(1),o.fill(0),s=0},a=(...l)=>t(o,n,...l),c=(l=ja())=>{o=a(Yf([0]),l),n=a(),l.length!==0&&(o=a(Yf([1]),l),n=a())},f=()=>{if(s++>=1e3)throw new Error("drbg: tried 1000 values");let l=0,p=[];for(;l<e;){n=a();let x=n.slice();p.push(x),l+=n.length}return Pt(...p)};return(l,p)=>{i(),c(l);let x;for(;!(x=p(f()));)c();return i(),x}}var Yw={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"||dt(r),isSafeInteger:r=>Number.isSafeInteger(r),array:r=>Array.isArray(r),field:(r,e)=>e.Fp.isValid(r),hash:r=>typeof r=="function"&&Number.isSafeInteger(r.outputLen)};function At(r,e,t={}){let n=(o,s,i)=>{let a=Yw[s];if(typeof a!="function")throw new Error(`Invalid validator "${s}", expected function`);let c=r[o];if(!(i&&c===void 0)&&!a(c,r))throw new Error(`Invalid param ${String(o)}=${c} (${typeof c}), expected ${s}`)};for(let[o,s]of Object.entries(e))n(o,s,!1);for(let[o,s]of Object.entries(t))n(o,s,!0);return r}var xe=BigInt(0),ie=BigInt(1),Mr=BigInt(2),Zw=BigInt(3),Ya=BigInt(4),Xf=BigInt(5),Qf=BigInt(8),Jw=BigInt(9),Xw=BigInt(16);function oe(r,e){let t=r%e;return t>=xe?t:e+t}function Qw(r,e,t){if(t<=xe||e<xe)throw new Error("Expected power/modulo > 0");if(t===ie)return xe;let n=ie;for(;e>xe;)e&ie&&(n=n*r%t),r=r*r%t,e>>=ie;return n}function ae(r,e,t){let n=r;for(;e-- >xe;)n*=n,n%=t;return n}function Cs(r,e){if(r===xe||e<=xe)throw new Error(`invert: expected positive integers, got n=${r} mod=${e}`);let t=oe(r,e),n=e,o=xe,s=ie,i=ie,a=xe;for(;t!==xe;){let f=n/t,u=n%t,l=o-i*f,p=s-a*f;n=t,t=u,o=i,s=a,i=l,a=p}if(n!==ie)throw new Error("invert: does not exist");return oe(o,e)}function eb(r){let e=(r-ie)/Mr,t,n,o;for(t=r-ie,n=0;t%Mr===xe;t/=Mr,n++);for(o=Mr;o<r&&Qw(o,e,r)!==r-ie;o++);if(n===1){let i=(r+ie)/Ya;return function(c,f){let u=c.pow(f,i);if(!c.eql(c.sqr(u),f))throw new Error("Cannot find square root");return u}}let s=(t+ie)/Mr;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,s),p=a.pow(c,t);for(;!a.eql(p,a.ONE);){if(a.eql(p,a.ZERO))return a.ZERO;let x=1;for(let h=a.sqr(p);x<f&&!a.eql(h,a.ONE);x++)h=a.sqr(h);let d=a.pow(u,ie<<BigInt(f-x-1));u=a.sqr(d),l=a.mul(l,d),p=a.mul(p,u),f=x}return l}}function tb(r){if(r%Ya===Zw){let e=(r+ie)/Ya;return function(n,o){let s=n.pow(o,e);if(!n.eql(n.sqr(s),o))throw new Error("Cannot find square root");return s}}if(r%Qf===Xf){let e=(r-Xf)/Qf;return function(n,o){let s=n.mul(o,Mr),i=n.pow(s,e),a=n.mul(o,i),c=n.mul(n.mul(a,Mr),i),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%Xw,eb(r)}var eh=(r,e)=>(oe(r,e)&ie)===ie,rb=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Za(r){let e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},t=rb.reduce((n,o)=>(n[o]="function",n),e);return At(r,t)}function nb(r,e,t){if(t<xe)throw new Error("Expected power > 0");if(t===xe)return r.ONE;if(t===ie)return e;let n=r.ONE,o=e;for(;t>xe;)t&ie&&(n=r.mul(n,o)),o=r.sqr(o),t>>=ie;return n}function ob(r,e){let t=new Array(e.length),n=e.reduce((s,i,a)=>r.is0(i)?s:(t[a]=s,r.mul(s,i)),r.ONE),o=r.inv(n);return e.reduceRight((s,i,a)=>r.is0(i)?s:(t[a]=r.mul(s,t[a]),r.mul(s,i)),o),t}function Ja(r,e){let t=e!==void 0?e:r.toString(2).length,n=Math.ceil(t/8);return{nBitLength:t,nByteLength:n}}function Ts(r,e,t=!1,n={}){if(r<=xe)throw new Error(`Expected Field ORDER > 0, got ${r}`);let{nBitLength:o,nByteLength:s}=Ja(r,e);if(s>2048)throw new Error("Field lengths over 2048 bytes are not supported");let i=tb(r),a=Object.freeze({ORDER:r,BITS:o,BYTES:s,MASK:ho(o),ZERO:xe,ONE:ie,create:c=>oe(c,r),isValid:c=>{if(typeof c!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof c}`);return xe<=c&&c<r},is0:c=>c===xe,isOdd:c=>(c&ie)===ie,neg:c=>oe(-c,r),eql:(c,f)=>c===f,sqr:c=>oe(c*c,r),add:(c,f)=>oe(c+f,r),sub:(c,f)=>oe(c-f,r),mul:(c,f)=>oe(c*f,r),pow:(c,f)=>nb(a,c,f),div:(c,f)=>oe(c*Cs(f,r),r),sqrN:c=>c*c,addN:(c,f)=>c+f,subN:(c,f)=>c-f,mulN:(c,f)=>c*f,inv:c=>Cs(c,r),sqrt:n.sqrt||(c=>i(a,c)),invertBatch:c=>ob(a,c),cmov:(c,f,u)=>u?f:c,toBytes:c=>t?Pr(c,s):fr(c,s),fromBytes:c=>{if(c.length!==s)throw new Error(`Fp.fromBytes: expected ${s}, got ${c.length}`);return t?lr(c):Vt(c)}});return Object.freeze(a)}function th(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 rh(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 Xa(r){let e=rh(r);return e+Math.ceil(e/2)}function nh(r,e,t=!1){let n=r.length,o=rh(e),s=Xa(e);if(n<16||n<s||n>1024)throw new Error(`expected ${s}-1024 bytes of input, got ${n}`);let i=t?Vt(r):lr(r),a=oe(i,e-ie)+ie;return t?Pr(a,o):fr(a,o)}var ib=BigInt(0),Qa=BigInt(1);function ks(r,e){let t=(o,s)=>{let i=s.negate();return o?i:s},n=o=>{let s=Math.ceil(e/o)+1,i=2**(o-1);return{windows:s,windowSize:i}};return{constTimeNegate:t,unsafeLadder(o,s){let i=r.ZERO,a=o;for(;s>ib;)s&Qa&&(i=i.add(a)),a=a.double(),s>>=Qa;return i},precomputeWindow(o,s){let{windows:i,windowSize:a}=n(s),c=[],f=o,u=f;for(let l=0;l<i;l++){u=f,c.push(u);for(let p=1;p<a;p++)u=u.add(f),c.push(u);f=u.double()}return c},wNAF(o,s,i){let{windows:a,windowSize:c}=n(o),f=r.ZERO,u=r.BASE,l=BigInt(2**o-1),p=2**o,x=BigInt(o);for(let d=0;d<a;d++){let h=d*c,m=Number(i&l);i>>=x,m>c&&(m-=p,i+=Qa);let g=h,A=h+Math.abs(m)-1,w=d%2!==0,S=m<0;m===0?u=u.add(t(w,s[g])):f=f.add(t(S,s[A]))}return{p:f,f:u}},wNAFCached(o,s,i,a){let c=o._WINDOW_SIZE||1,f=s.get(o);return f||(f=this.precomputeWindow(o,c),c!==1&&s.set(o,a(f))),this.wNAF(c,f,i)}}}function po(r){return Za(r.Fp),At(r,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Ja(r.n,r.nBitLength),...r,p:r.Fp.ORDER})}var pt=BigInt(0),Qe=BigInt(1),Rs=BigInt(2),ab=BigInt(8),cb={zip215:!0};function ub(r){let e=po(r);return At(r,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...e})}function Ns(r){let e=ub(r),{Fp:t,n,prehash:o,hash:s,randomBytes:i,nByteLength:a,h:c}=e,f=Rs<<BigInt(a*8)-Qe,u=t.create,l=e.uvRatio||((T,E)=>{try{return{isValid:!0,value:t.sqrt(T*t.inv(E))}}catch{return{isValid:!1,value:pt}}}),p=e.adjustScalarBytes||(T=>T),x=e.domain||((T,E,L)=>{if(E.length||L)throw new Error("Contexts/pre-hash are not supported");return T}),d=T=>typeof T=="bigint"&&pt<T,h=(T,E)=>d(T)&&d(E)&&T<E,m=T=>T===pt||h(T,f);function g(T,E){if(h(T,E))return T;throw new Error(`Expected valid scalar < ${E}, got ${typeof T} ${T}`)}function A(T){return T===pt?T:g(T,n)}let w=new Map;function S(T){if(!(T instanceof v))throw new Error("ExtendedPoint expected")}class v{constructor(E,L,F,q){if(this.ex=E,this.ey=L,this.ez=F,this.et=q,!m(E))throw new Error("x required");if(!m(L))throw new Error("y required");if(!m(F))throw new Error("z required");if(!m(q))throw new Error("t required")}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(E){if(E instanceof v)throw new Error("extended point not allowed");let{x:L,y:F}=E||{};if(!m(L)||!m(F))throw new Error("invalid affine point");return new v(L,F,Qe,u(L*F))}static normalizeZ(E){let L=t.invertBatch(E.map(F=>F.ez));return E.map((F,q)=>F.toAffine(L[q])).map(v.fromAffine)}_setWindowSize(E){this._WINDOW_SIZE=E,w.delete(this)}assertValidity(){let{a:E,d:L}=e;if(this.is0())throw new Error("bad point: ZERO");let{ex:F,ey:q,ez:W,et:Y}=this,ne=u(F*F),J=u(q*q),Q=u(W*W),ye=u(Q*Q),fe=u(ne*E),Ae=u(Q*u(fe+J)),Be=u(ye+u(L*u(ne*J)));if(Ae!==Be)throw new Error("bad point: equation left != right (1)");let be=u(F*q),De=u(W*Y);if(be!==De)throw new Error("bad point: equation left != right (2)")}equals(E){S(E);let{ex:L,ey:F,ez:q}=this,{ex:W,ey:Y,ez:ne}=E,J=u(L*ne),Q=u(W*q),ye=u(F*ne),fe=u(Y*q);return J===Q&&ye===fe}is0(){return this.equals(v.ZERO)}negate(){return new v(u(-this.ex),this.ey,this.ez,u(-this.et))}double(){let{a:E}=e,{ex:L,ey:F,ez:q}=this,W=u(L*L),Y=u(F*F),ne=u(Rs*u(q*q)),J=u(E*W),Q=L+F,ye=u(u(Q*Q)-W-Y),fe=J+Y,Ae=fe-ne,Be=J-Y,be=u(ye*Ae),De=u(fe*Be),_t=u(ye*Be),Nr=u(Ae*fe);return new v(be,De,Nr,_t)}add(E){S(E);let{a:L,d:F}=e,{ex:q,ey:W,ez:Y,et:ne}=this,{ex:J,ey:Q,ez:ye,et:fe}=E;if(L===BigInt(-1)){let af=u((W-q)*(Q+J)),cf=u((W+q)*(Q-J)),da=u(cf-af);if(da===pt)return this.double();let uf=u(Y*Rs*fe),lf=u(ne*Rs*ye),ff=lf+uf,hf=cf+af,df=lf-uf,Pg=u(ff*da),Mg=u(hf*df),Fg=u(ff*df),$g=u(da*hf);return new v(Pg,Mg,$g,Fg)}let Ae=u(q*J),Be=u(W*Q),be=u(ne*F*fe),De=u(Y*ye),_t=u((q+W)*(J+Q)-Ae-Be),Nr=De-be,io=De+be,sf=u(Be-L*Ae),Dg=u(_t*Nr),Lg=u(io*sf),Og=u(_t*sf),Vg=u(Nr*io);return new v(Dg,Lg,Vg,Og)}subtract(E){return this.add(E.negate())}wNAF(E){return y.wNAFCached(this,w,E,v.normalizeZ)}multiply(E){let{p:L,f:F}=this.wNAF(g(E,n));return v.normalizeZ([L,F])[0]}multiplyUnsafe(E){let L=A(E);return L===pt?C:this.equals(C)||L===Qe?this:this.equals(I)?this.wNAF(L).p:y.unsafeLadder(this,L)}isSmallOrder(){return this.multiplyUnsafe(c).is0()}isTorsionFree(){return y.unsafeLadder(this,n).is0()}toAffine(E){let{ex:L,ey:F,ez:q}=this,W=this.is0();E==null&&(E=W?ab:t.inv(q));let Y=u(L*E),ne=u(F*E),J=u(q*E);if(W)return{x:pt,y:Qe};if(J!==Qe)throw new Error("invZ was invalid");return{x:Y,y:ne}}clearCofactor(){let{h:E}=e;return E===Qe?this:this.multiplyUnsafe(E)}static fromHex(E,L=!1){let{d:F,a:q}=e,W=t.BYTES;E=de("pointHex",E,W);let Y=E.slice(),ne=E[W-1];Y[W-1]=ne&-129;let J=lr(Y);J===pt||(L?g(J,f):g(J,t.ORDER));let Q=u(J*J),ye=u(Q-Qe),fe=u(F*Q-q),{isValid:Ae,value:Be}=l(ye,fe);if(!Ae)throw new Error("Point.fromHex: invalid y coordinate");let be=(Be&Qe)===Qe,De=(ne&128)!==0;if(!L&&Be===pt&&De)throw new Error("Point.fromHex: x=0 and x_0=1");return De!==be&&(Be=u(-Be)),v.fromAffine({x:Be,y:J})}static fromPrivateKey(E){return U(E).point}toRawBytes(){let{x:E,y:L}=this.toAffine(),F=Pr(L,t.BYTES);return F[F.length-1]|=E&Qe?128:0,F}toHex(){return Ot(this.toRawBytes())}}v.BASE=new v(e.Gx,e.Gy,Qe,u(e.Gx*e.Gy)),v.ZERO=new v(pt,Qe,Qe,pt);let{BASE:I,ZERO:C}=v,y=ks(v,a*8);function k(T){return oe(T,n)}function O(T){return k(lr(T))}function U(T){let E=a;T=de("private key",T,E);let L=de("hashed private key",s(T),2*E),F=p(L.slice(0,E)),q=L.slice(E,2*E),W=O(F),Y=I.multiply(W),ne=Y.toRawBytes();return{head:F,prefix:q,scalar:W,point:Y,pointBytes:ne}}function V(T){return U(T).pointBytes}function H(T=new Uint8Array,...E){let L=Pt(...E);return O(s(x(L,de("context",T),!!o)))}function X(T,E,L={}){T=de("message",T),o&&(T=o(T));let{prefix:F,scalar:q,pointBytes:W}=U(E),Y=H(L.context,F,T),ne=I.multiply(Y).toRawBytes(),J=H(L.context,ne,W,T),Q=k(Y+J*q);A(Q);let ye=Pt(ne,Pr(Q,t.BYTES));return de("result",ye,a*2)}let B=cb;function R(T,E,L,F=B){let{context:q,zip215:W}=F,Y=t.BYTES;T=de("signature",T,2*Y),E=de("message",E),o&&(E=o(E));let ne=lr(T.slice(Y,2*Y)),J,Q,ye;try{J=v.fromHex(L,W),Q=v.fromHex(T.slice(0,Y),W),ye=I.multiplyUnsafe(ne)}catch{return!1}if(!W&&J.isSmallOrder())return!1;let fe=H(q,Q.toRawBytes(),J.toRawBytes(),E);return Q.add(J.multiplyUnsafe(fe)).subtract(ye).clearCofactor().equals(v.ZERO)}return I._setWindowSize(8),{CURVE:e,getPublicKey:V,sign:X,verify:R,ExtendedPoint:v,utils:{getExtendedPublicKey:U,randomPrivateKey:()=>i(t.BYTES),precompute(T=8,E=v.BASE){return E._setWindowSize(T),E.multiply(BigInt(3)),E}}}}var tc=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),oh=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),a6=BigInt(0),lb=BigInt(1),ec=BigInt(2),fb=BigInt(5),sh=BigInt(10),hb=BigInt(20),db=BigInt(40),ih=BigInt(80);function pb(r){let e=tc,n=r*r%e*r%e,o=ae(n,ec,e)*n%e,s=ae(o,lb,e)*r%e,i=ae(s,fb,e)*s%e,a=ae(i,sh,e)*i%e,c=ae(a,hb,e)*a%e,f=ae(c,db,e)*c%e,u=ae(f,ih,e)*f%e,l=ae(u,ih,e)*f%e,p=ae(l,sh,e)*i%e;return{pow_p_5_8:ae(p,ec,e)*r%e,b2:n}}function mb(r){return r[0]&=248,r[31]&=127,r[31]|=64,r}function gb(r,e){let t=tc,n=oe(e*e*e,t),o=oe(n*n*e,t),s=pb(r*o).pow_p_5_8,i=oe(r*n*s,t),a=oe(e*i*i,t),c=i,f=oe(i*oh,t),u=a===r,l=a===oe(-r,t),p=a===oe(-r*oh,t);return u&&(i=c),(l||p)&&(i=f),eh(i,t)&&(i=oe(-i,t)),{isValid:u||l,value:i}}var Mt=Ts(tc,void 0,!0),rc={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:Mt,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:BigInt(8),Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:vn,randomBytes:bn,adjustScalarBytes:mb,uvRatio:gb},En=Ns(rc);function ah(r,e,t){if(e.length>255)throw new Error("Context is too big");return Es(Ka("SigEd25519 no Ed25519 collisions"),new Uint8Array([t?1:0,e.length]),e,r)}var c6=Ns({...rc,domain:ah}),u6=Ns({...rc,domain:ah,prehash:vn});var yb=(Mt.ORDER+BigInt(3))/BigInt(8),l6=Mt.pow(ec,yb),f6=Mt.sqrt(Mt.neg(Mt.ONE)),h6=(Mt.ORDER-BigInt(5))/BigInt(8),d6=BigInt(486662);var p6=th(Mt,Mt.neg(BigInt(486664)));var m6=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),g6=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),y6=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),w6=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952");var b6=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");var An=32,Ft=64,Us=32;function ch(){let r=En.utils.randomPrivateKey(),e=En.getPublicKey(r);return{privateKey:hh(r,e),publicKey:e}}function uh(r){if(r.length!==Us)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=En.getPublicKey(e);return{privateKey:hh(e,t),publicKey:t}}function lh(r,e){let t=r.subarray(0,Us);return En.sign(e instanceof Uint8Array?e:e.subarray(),t)}function fh(r,e,t){return En.verify(e,t instanceof Uint8Array?t:t.subarray(),r)}function hh(r,e){let t=new Uint8Array(Ft);for(let n=0;n<Us;n++)t[n]=r[n],t[Us+n]=e[n];return t}var Fe={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 nc={alg:"A128GCM",ext:!0,k:"scm9jmO_4BJAgdwWGVulLg",key_ops:["encrypt","decrypt"],kty:"oct"};function dh(r){let e=r?.algorithm??"AES-GCM",t=r?.keyLength??16,n=r?.nonceLength??12,o=r?.digest??"SHA-256",s=r?.saltLength??16,i=r?.iterations??32767,a=Fe.get();t*=8;async function c(l,p){let x=a.getRandomValues(new Uint8Array(s)),d=a.getRandomValues(new Uint8Array(n)),h={name:e,iv:d};typeof p=="string"&&(p=ee(p));let m;if(p.length===0){m=await a.subtle.importKey("jwk",nc,{name:"AES-GCM"},!0,["encrypt"]);try{let A={name:"PBKDF2",salt:x,iterations:i,hash:{name:o}},w=await a.subtle.importKey("raw",p,{name:"PBKDF2"},!1,["deriveKey"]);m=await a.subtle.deriveKey(A,w,{name:e,length:t},!0,["encrypt"])}catch{m=await a.subtle.importKey("jwk",nc,{name:"AES-GCM"},!0,["encrypt"])}}else{let A={name:"PBKDF2",salt:x,iterations:i,hash:{name:o}},w=await a.subtle.importKey("raw",p,{name:"PBKDF2"},!1,["deriveKey"]);m=await a.subtle.deriveKey(A,w,{name:e,length:t},!0,["encrypt"])}let g=await a.subtle.encrypt(h,m,l);return Or([x,h.iv,new Uint8Array(g)])}async function f(l,p){let x=l.subarray(0,s),d=l.subarray(s,s+n),h=l.subarray(s+n),m={name:e,iv:d};typeof p=="string"&&(p=ee(p));let g;if(p.length===0)try{let w={name:"PBKDF2",salt:x,iterations:i,hash:{name:o}},S=await a.subtle.importKey("raw",p,{name:"PBKDF2"},!1,["deriveKey"]);g=await a.subtle.deriveKey(w,S,{name:e,length:t},!0,["decrypt"])}catch{g=await a.subtle.importKey("jwk",nc,{name:"AES-GCM"},!0,["decrypt"])}else{let w={name:"PBKDF2",salt:x,iterations:i,hash:{name:o}},S=await a.subtle.importKey("raw",p,{name:"PBKDF2"},!1,["deriveKey"]);g=await a.subtle.deriveKey(w,S,{name:e,length:t},!0,["decrypt"])}let A=await a.subtle.decrypt(m,g,h);return new Uint8Array(A)}return{encrypt:c,decrypt:f}}async function Bn(r,e){let n=await dh().encrypt(r,e);return ao.encode(n)}var xb=Math.pow(2,7),vb=Math.pow(2,14),Eb=Math.pow(2,21),oc=Math.pow(2,28),sc=Math.pow(2,35),ic=Math.pow(2,42),ac=Math.pow(2,49),re=128,Oe=127;function qe(r){if(r<xb)return 1;if(r<vb)return 2;if(r<Eb)return 3;if(r<oc)return 4;if(r<sc)return 5;if(r<ic)return 6;if(r<ac)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function cc(r,e,t=0){switch(qe(r)){case 8:e[t++]=r&255|re,r/=128;case 7:e[t++]=r&255|re,r/=128;case 6:e[t++]=r&255|re,r/=128;case 5:e[t++]=r&255|re,r/=128;case 4:e[t++]=r&255|re,r>>>=7;case 3:e[t++]=r&255|re,r>>>=7;case 2:e[t++]=r&255|re,r>>>=7;case 1:{e[t++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return e}function Ab(r,e,t=0){switch(qe(r)){case 8:e.set(t++,r&255|re),r/=128;case 7:e.set(t++,r&255|re),r/=128;case 6:e.set(t++,r&255|re),r/=128;case 5:e.set(t++,r&255|re),r/=128;case 4:e.set(t++,r&255|re),r>>>=7;case 3:e.set(t++,r&255|re),r>>>=7;case 2:e.set(t++,r&255|re),r>>>=7;case 1:{e.set(t++,r&255),r>>>=7;break}default:throw new Error("unreachable")}return e}function uc(r,e){let t=r[e],n=0;if(n+=t&Oe,t<re||(t=r[e+1],n+=(t&Oe)<<7,t<re)||(t=r[e+2],n+=(t&Oe)<<14,t<re)||(t=r[e+3],n+=(t&Oe)<<21,t<re)||(t=r[e+4],n+=(t&Oe)*oc,t<re)||(t=r[e+5],n+=(t&Oe)*sc,t<re)||(t=r[e+6],n+=(t&Oe)*ic,t<re)||(t=r[e+7],n+=(t&Oe)*ac,t<re))return n;throw new RangeError("Could not decode varint")}function Bb(r,e){let t=r.get(e),n=0;if(n+=t&Oe,t<re||(t=r.get(e+1),n+=(t&Oe)<<7,t<re)||(t=r.get(e+2),n+=(t&Oe)<<14,t<re)||(t=r.get(e+3),n+=(t&Oe)<<21,t<re)||(t=r.get(e+4),n+=(t&Oe)*oc,t<re)||(t=r.get(e+5),n+=(t&Oe)*sc,t<re)||(t=r.get(e+6),n+=(t&Oe)*ic,t<re)||(t=r.get(e+7),n+=(t&Oe)*ac,t<re))return n;throw new RangeError("Could not decode varint")}function Sn(r,e,t=0){return e==null&&(e=ft(qe(r))),e instanceof Uint8Array?cc(r,e,t):Ab(r,e,t)}function Fr(r,e=0){return r instanceof Uint8Array?uc(r,e):Bb(r,e)}var lc=new Float32Array([-0]),hr=new Uint8Array(lc.buffer);function mh(r,e,t){lc[0]=r,e[t]=hr[0],e[t+1]=hr[1],e[t+2]=hr[2],e[t+3]=hr[3]}function gh(r,e){return hr[0]=r[e],hr[1]=r[e+1],hr[2]=r[e+2],hr[3]=r[e+3],lc[0]}var fc=new Float64Array([-0]),Ve=new Uint8Array(fc.buffer);function yh(r,e,t){fc[0]=r,e[t]=Ve[0],e[t+1]=Ve[1],e[t+2]=Ve[2],e[t+3]=Ve[3],e[t+4]=Ve[4],e[t+5]=Ve[5],e[t+6]=Ve[6],e[t+7]=Ve[7]}function wh(r,e){return Ve[0]=r[e],Ve[1]=r[e+1],Ve[2]=r[e+2],Ve[3]=r[e+3],Ve[4]=r[e+4],Ve[5]=r[e+5],Ve[6]=r[e+6],Ve[7]=r[e+7],fc[0]}var Sb=BigInt(Number.MAX_SAFE_INTEGER),Ib=BigInt(Number.MIN_SAFE_INTEGER),et=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 $r;if(e<Sb&&e>Ib)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>bh&&(o=0n,++n>bh&&(n=0n))),new r(Number(o),Number(n))}static fromNumber(e){if(e===0)return $r;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):$r}},$r=new et(0,0);$r.toBigInt=function(){return 0n};$r.zzEncode=$r.zzDecode=function(){return this};$r.length=function(){return 1};var bh=4294967296n;function xh(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 vh(r,e,t){if(t-e<1)return"";let o,s=[],i=0,a;for(;e<t;)a=r[e++],a<128?s[i++]=a:a>191&&a<224?s[i++]=(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,s[i++]=55296+(a>>10),s[i++]=56320+(a&1023)):s[i++]=(a&15)<<12|(r[e++]&63)<<6|r[e++]&63,i>8191&&((o??(o=[])).push(String.fromCharCode.apply(String,s)),i=0);return o!=null?(i>0&&o.push(String.fromCharCode.apply(String,s.slice(0,i))),o.join("")):String.fromCharCode.apply(String,s.slice(0,i))}function hc(r,e,t){let n=t,o,s;for(let i=0;i<r.length;++i)o=r.charCodeAt(i),o<128?e[t++]=o:o<2048?(e[t++]=o>>6|192,e[t++]=o&63|128):(o&64512)===55296&&((s=r.charCodeAt(i+1))&64512)===56320?(o=65536+((o&1023)<<10)+(s&1023),++i,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 mt(r,e){return RangeError(`index out of range: ${r.pos} + ${e??1} > ${r.len}`)}function _s(r,e){return(r[e-4]|r[e-3]<<8|r[e-2]<<16|r[e-1]<<24)>>>0}var dc=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,mt(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 mt(this,4);return _s(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw mt(this,4);return _s(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw mt(this,4);let e=gh(this.buf,this.pos);return this.pos+=4,e}double(){if(this.pos+8>this.len)throw mt(this,4);let e=wh(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 mt(this,e);return this.pos+=e,t===n?new Uint8Array(0):this.buf.subarray(t,n)}string(){let e=this.bytes();return vh(e,0,e.length)}skip(e){if(typeof e=="number"){if(this.pos+e>this.len)throw mt(this,e);this.pos+=e}else do if(this.pos>=this.len)throw mt(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 et(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 mt(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 mt(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 mt(this,8);let e=_s(this.buf,this.pos+=4),t=_s(this.buf,this.pos+=4);return new et(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=uc(this.buf,this.pos);return this.pos+=qe(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 pc(r){return new dc(r instanceof Uint8Array?r:r.subarray())}function dr(r,e,t){let n=pc(r);return e.decode(n,void 0,t)}function mc(r){let e=r??8192,t=e>>>1,n,o=e;return function(i){if(i<1||i>t)return ft(i);o+i>e&&(n=ft(e),o=0);let a=n.subarray(o,o+=i);return o&7&&(o=(o|7)+1),a}}var Hr=class{fn;len;next;val;constructor(e,t,n){this.fn=e,this.len=t,this.next=void 0,this.val=n}};function gc(){}var wc=class{head;tail;len;next;constructor(e){this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}},Cb=mc();function Tb(r){return globalThis.Buffer!=null?ft(r):Cb(r)}var go=class{len;head;tail;states;constructor(){this.len=0,this.head=new Hr(gc,0,0),this.tail=this.head,this.states=null}_push(e,t,n){return this.tail=this.tail.next=new Hr(e,t,n),this.len+=t,this}uint32(e){return this.len+=(this.tail=this.tail.next=new bc((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(Ds,10,et.fromNumber(e)):this.uint32(e)}sint32(e){return this.uint32((e<<1^e>>31)>>>0)}uint64(e){let t=et.fromBigInt(e);return this._push(Ds,t.length(),t)}uint64Number(e){return this._push(cc,qe(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=et.fromBigInt(e).zzEncode();return this._push(Ds,t.length(),t)}sint64Number(e){let t=et.fromNumber(e).zzEncode();return this._push(Ds,t.length(),t)}sint64String(e){return this.sint64(BigInt(e))}bool(e){return this._push(yc,1,e?1:0)}fixed32(e){return this._push(mo,4,e>>>0)}sfixed32(e){return this.fixed32(e)}fixed64(e){let t=et.fromBigInt(e);return this._push(mo,4,t.lo)._push(mo,4,t.hi)}fixed64Number(e){let t=et.fromNumber(e);return this._push(mo,4,t.lo)._push(mo,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(mh,4,e)}double(e){return this._push(yh,8,e)}bytes(e){let t=e.length>>>0;return t===0?this._push(yc,1,0):this.uint32(t)._push(Rb,t,e)}string(e){let t=xh(e);return t!==0?this.uint32(t)._push(hc,t,e):this._push(yc,1,0)}fork(){return this.states=new wc(this),this.head=this.tail=new Hr(gc,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 Hr(gc,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=Tb(this.len),n=0;for(;e!=null;)e.fn(e.val,t,n),n+=e.len,e=e.next;return t}};function yc(r,e,t){e[t]=r&255}function kb(r,e,t){for(;r>127;)e[t++]=r&127|128,r>>>=7;e[t]=r}var bc=class extends Hr{next;constructor(e,t){super(kb,e,t),this.next=void 0}};function Ds(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 mo(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 Rb(r,e,t){e.set(r,t)}globalThis.Buffer!=null&&(go.prototype.bytes=function(r){let e=r.length>>>0;return this.uint32(e),e>0&&this._push(Nb,e,r),this},go.prototype.string=function(r){let e=globalThis.Buffer.byteLength(r);return this.uint32(e),e>0&&this._push(Ub,e,r),this});function Nb(r,e,t){e.set(r,t)}function Ub(r,e,t){r.length<40?hc(r,e,t):e.utf8Write!=null?e.utf8Write(r,t):e.set(ee(r),t)}function xc(){return new go}function pr(r,e){let t=xc();return e.encode(r,t,{lengthDelimited:!1}),t.finish()}var In;(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"})(In||(In={}));function Ls(r,e,t,n){return{name:r,type:e,encode:t,decode:n}}function yo(r){function e(o){if(r[o.toString()]==null)throw new Error("Invalid enum value");return r[o]}let t=function(s,i){let a=e(s);i.int32(a)},n=function(s){let i=s.int32();return e(i)};return Ls("enum",In.VARINT,t,n)}function mr(r,e){return Ls("message",In.LENGTH_DELIMITED,r,e)}var ce;(function(r){r.RSA="RSA",r.Ed25519="Ed25519",r.Secp256k1="Secp256k1"})(ce||(ce={}));var vc;(function(r){r[r.RSA=0]="RSA",r[r.Ed25519=1]="Ed25519",r[r.Secp256k1=2]="Secp256k1"})(vc||(vc={}));(function(r){r.codec=()=>yo(vc)})(ce||(ce={}));var Bt;(function(r){let e;r.codec=()=>(e==null&&(e=mr((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={},s=n==null?t.len:t.pos+n;for(;t.pos<s;){let i=t.uint32();switch(i>>>3){case 1:o.Type=ce.codec().decode(t);break;case 2:o.Data=t.bytes();break;default:t.skipType(i&7);break}}return o})),e),r.encode=t=>pr(t,r.codec()),r.decode=t=>dr(t,r.codec())})(Bt||(Bt={}));var St;(function(r){let e;r.codec=()=>(e==null&&(e=mr((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={},s=n==null?t.len:t.pos+n;for(;t.pos<s;){let i=t.uint32();switch(i>>>3){case 1:o.Type=ce.codec().decode(t);break;case 2:o.Data=t.bytes();break;default:t.skipType(i&7);break}}return o})),e),r.encode=t=>pr(t,r.codec()),r.decode=t=>dr(t,r.codec())})(St||(St={}));var wo=class{_key;constructor(e){this._key=Cn(e,An)}verify(e,t){return fh(this._key,t,e)}marshal(){return this._key}get bytes(){return Bt.encode({Type:ce.Ed25519,Data:this.marshal()}).subarray()}equals(e){return Te(this.bytes,e.bytes)}hash(){let e=Ce.digest(this.bytes);return st(e)?e.then(({bytes:t})=>t):e.bytes}},Kr=class{_key;_publicKey;constructor(e,t){this._key=Cn(e,Ft),this._publicKey=Cn(t,An)}sign(e){return lh(this._key,e)}get public(){return new wo(this._publicKey)}marshal(){return this._key}get bytes(){return St.encode({Type:ce.Ed25519,Data:this.marshal()}).subarray()}equals(e){return Te(this.bytes,e.bytes)}async hash(){let e=Ce.digest(this.bytes),t;return st(e)?{bytes:t}=await e:t=e.bytes,t}async id(){let e=Et.digest(this.public.bytes);return Ie.encode(e.bytes).substring(1)}async export(e,t="libp2p-key"){if(t==="libp2p-key")return Bn(this.bytes,e);throw new K(`export format '${t}' is not supported`,"ERR_INVALID_EXPORT_FORMAT")}};function _b(r){if(r.length>Ft){r=Cn(r,Ft+An);let n=r.subarray(0,Ft),o=r.subarray(Ft,r.length);return new Kr(n,o)}r=Cn(r,Ft);let e=r.subarray(0,Ft),t=r.subarray(An);return new Kr(e,t)}function Db(r){return r=Cn(r,An),new wo(r)}async function Lb(){let{privateKey:r,publicKey:e}=ch();return new Kr(r,e)}async function Ah(r){let{privateKey:e,publicKey:t}=uh(r);return new Kr(e,t)}function Cn(r,e){if(r=Uint8Array.from(r??[]),r.length!==e)throw new K(`Key must be a Uint8Array of length ${e}, got ${r.length}`,"ERR_INVALID_KEY_TYPE");return r}function ue(r,e="utf8"){let t=bs[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(r.buffer,r.byteOffset,r.byteLength).toString("utf8"):t.encoder.encode(r).substring(1)}var Uc={};M(Uc,{MAX_RSA_KEY_SIZE:()=>Ro,RsaPrivateKey:()=>Un,RsaPublicKey:()=>ko,fromJwk:()=>cx,generateKeyPair:()=>ux,unmarshalRsaPrivateKey:()=>Rc,unmarshalRsaPublicKey:()=>ax});function zr(r){if(isNaN(r)||r<=0)throw new K("random bytes length must be a Number bigger than 0","ERR_INVALID_LENGTH");return bn(r)}var br={};M(br,{exportToPem:()=>rx,importFromPem:()=>nx,jwkToPkcs1:()=>Xb,jwkToPkix:()=>ex,pkcs1ToJwk:()=>Jb,pkixToJwk:()=>Qb});var Vs=class extends yn{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,xs(e);let n=ar(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,s=new Uint8Array(o);s.set(n.length>o?e.create().update(n).digest():n);for(let i=0;i<s.length;i++)s[i]^=54;this.iHash.update(s),this.oHash=e.create();for(let i=0;i<s.length;i++)s[i]^=106;this.oHash.update(s),s.fill(0)}update(e){return gn(this),this.iHash.update(e),this}digestInto(e){gn(this),Ha(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:s,blockLen:i,outputLen:a}=this;return e=e,e.finished=o,e.destroyed=s,e.blockLen=i,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()}},bo=(r,e,t)=>new Vs(r,e).update(t).digest();bo.create=(r,e)=>new Vs(r,e);function Ob(r,e,t,n){xs(r);let o=jf({dkLen:32,asyncTick:10},n),{c:s,dkLen:i,asyncTick:a}=o;if(mn(s),mn(i),mn(a),s<1)throw new Error("PBKDF2: iterations (c) should be >= 1");let c=ar(e),f=ar(t),u=new Uint8Array(i),l=bo.create(r,c),p=l._cloneInto().update(f);return{c:s,dkLen:i,asyncTick:a,DK:u,PRF:l,PRFSalt:p}}function Vb(r,e,t,n,o){return r.destroy(),e.destroy(),n&&n.destroy(),o.fill(0),t}async function Ac(r,e,t,n){let{c:o,dkLen:s,asyncTick:i,DK:a,PRF:c,PRFSalt:f}=Ob(r,e,t,n),u,l=new Uint8Array(4),p=wn(l),x=new Uint8Array(c.outputLen);for(let d=1,h=0;h<s;d++,h+=c.outputLen){let m=a.subarray(h,h+c.outputLen);p.setInt32(0,d,!1),(u=f._cloneInto(u)).update(l).digestInto(x),m.set(x.subarray(0,m.length)),await qf(o-1,i,()=>{c._cloneInto(u).update(x).digestInto(x);for(let g=0;g<m.length;g++)m[g]^=x[g]})}return Vb(c,f,a,u,x)}var Z=Se(Bh());function qr(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 gr(r,e,t=-1){let n=t,o=r,s=0,i=Math.pow(2,e);for(let a=1;a<8;a++){if(r<i){let c;if(n<0)c=new ArrayBuffer(a),s=a;else{if(n<a)return new ArrayBuffer(0);c=new ArrayBuffer(n),s=n}let f=new Uint8Array(c);for(let u=a-1;u>=0;u--){let l=Math.pow(2,u*e);f[s-u-1]=Math.floor(o/l),o-=f[s-u-1]*l}return c}i*=Math.pow(2,e)}return new ArrayBuffer(0)}function Fs(...r){let e=0,t=0;for(let s of r)e+=s.length;let n=new ArrayBuffer(e),o=new Uint8Array(n);for(let s of r)o.set(s,t),t+=s.length;return o}function Sc(){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=qr(t,8),o=new ArrayBuffer(this.valueHex.byteLength),s=new Uint8Array(o);for(let a=0;a<this.valueHex.byteLength;a++)s[a]=r[a];return s[0]&=127,qr(s,8)-n}function Sh(r){let e=r<0?r*-1:r,t=128;for(let n=1;n<8;n++){if(e<=t){if(r<0){let i=t-e,a=gr(i,8,n),c=new Uint8Array(a);return c[0]|=128,a}let o=gr(e,8,n),s=new Uint8Array(o);if(s[0]&128){let i=o.slice(0),a=new Uint8Array(i);o=new ArrayBuffer(o.byteLength+1),s=new Uint8Array(o);for(let c=0;c<i.byteLength;c++)s[c+1]=a[c];s[0]=0}return o}t*=Math.pow(2,8)}return new ArrayBuffer(0)}function Ih(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 je(r,e){let t=r.toString(10);if(e<t.length)return"";let n=e-t.length,o=new Array(n);for(let i=0;i<n;i++)o[i]="0";return o.join("").concat(t)}var CS=Math.log(2);function $s(){if(typeof BigInt>"u")throw new Error("BigInt is not defined. Your environment doesn't implement BigInt.")}function Ic(r){let e=0,t=0;for(let o=0;o<r.length;o++){let s=r[o];e+=s.byteLength}let n=new Uint8Array(e);for(let o=0;o<r.length;o++){let s=r[o];n.set(new Uint8Array(s),t),t+=s.byteLength}return n.buffer}function qt(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 vo=class{constructor(){this.items=[]}write(e){this.items.push(e)}final(){return Ic(this.items)}},xo=[new Uint8Array([1])],Ch="0123456789";var Rn="",yt=new ArrayBuffer(0),Cc=new Uint8Array(0),Eo="EndOfContent",kh="OCTET STRING",Rh="BIT STRING";function jt(r){var e;return e=class extends r{constructor(...n){var o;super(...n);let s=n[0]||{};this.isHexOnly=(o=s.isHexOnly)!==null&&o!==void 0?o:!1,this.valueHexView=s.valueHex?Z.BufferSourceConverter.toUint8Array(s.valueHex):Cc}get valueHex(){return this.valueHexView.slice().buffer}set valueHex(n){this.valueHexView=new Uint8Array(n)}fromBER(n,o,s){let i=n instanceof ArrayBuffer?new Uint8Array(n):n;if(!qt(this,i,o,s))return-1;let a=o+s;return this.valueHexView=i.subarray(o,a),this.valueHexView.length?(this.blockLength=s,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",yt)}toJSON(){return{...super.toJSON(),isHexOnly:this.isHexOnly,valueHex:Z.Convert.ToHex(this.valueHexView)}}},e.NAME="hexBlock",e}var Ht=class{constructor({blockLength:e=0,error:t=Rn,warnings:n=[],valueBeforeDecode:o=Cc}={}){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)}}};Ht.NAME="baseBlock";var Pe=class extends Ht{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'")}};Pe.NAME="valueBlock";var Hs=class extends jt(Ht){constructor({idBlock:e={}}={}){var t,n,o,s;super(),e?(this.isHexOnly=(t=e.isHexOnly)!==null&&t!==void 0?t:!1,this.valueHexView=e.valueHex?Z.BufferSourceConverter.toUint8Array(e.valueHex):Cc,this.tagClass=(n=e.tagClass)!==null&&n!==void 0?n:-1,this.tagNumber=(o=e.tagNumber)!==null&&o!==void 0?o:-1,this.isConstructed=(s=e.isConstructed)!==null&&s!==void 0?s:!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",yt}if(this.isConstructed&&(t|=32),this.tagNumber<31&&!this.isHexOnly){let o=new Uint8Array(1);if(!e){let s=this.tagNumber;s&=31,t|=s,o[0]=t}return o.buffer}if(!this.isHexOnly){let o=gr(this.tagNumber,7),s=new Uint8Array(o),i=o.byteLength,a=new Uint8Array(i+1);if(a[0]=t|31,!e){for(let c=0;c<i-1;c++)a[c+1]=s[c]|128;a[i]=s[i-1]}return a.buffer}let n=new Uint8Array(this.valueHexView.byteLength+1);if(n[0]=t|31,!e){let o=this.valueHexView;for(let s=0;s<o.length-1;s++)n[s+1]=o[s]|128;n[this.valueHexView.byteLength]=o[o.length-1]}return n.buffer}fromBER(e,t,n){let o=Z.BufferSourceConverter.toUint8Array(e);if(!qt(this,o,t,n))return-1;let s=o.subarray(t,t+n);if(s.length===0)return this.error="Zero buffer length",-1;switch(s[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=(s[0]&32)===32,this.isHexOnly=!1;let a=s[0]&31;if(a!==31)this.tagNumber=a,this.blockLength=1;else{let c=1,f=this.valueHexView=new Uint8Array(255),u=255;for(;s[c]&128;){if(f[c-1]=s[c]&127,c++,c>=s.length)return this.error="End of input reached before message was fully decoded",-1;if(c===u){u+=255;let p=new Uint8Array(u);for(let x=0;x<f.length;x++)p[x]=f[x];f=this.valueHexView=new Uint8Array(u)}}this.blockLength=c+1,f[c-1]=s[c]&127;let l=new Uint8Array(c);for(let p=0;p<c;p++)l[p]=f[p];f=this.valueHexView=new Uint8Array(c),f.set(l),this.blockLength<=9?this.tagNumber=qr(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}}};Hs.NAME="identificationBlock";var Ks=class extends Ht{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(!qt(this,o,t,n))return-1;let s=o.subarray(t,t+n);if(s.length===0)return this.error="Zero buffer length",-1;if(s[0]===255)return this.error="Length block 0xFF is reserved by standard",-1;if(this.isIndefiniteForm=s[0]===128,this.isIndefiniteForm)return this.blockLength=1,t+this.blockLength;if(this.longFormUsed=!!(s[0]&128),this.longFormUsed===!1)return this.length=s[0],this.blockLength=1,t+this.blockLength;let i=s[0]&127;if(i>8)return this.error="Too big integer",-1;if(i+1>s.length)return this.error="End of input reached before message was fully decoded",-1;let a=t+1,c=o.subarray(a,a+i);return c[i-1]===0&&this.warnings.push("Needlessly long encoded length"),this.length=qr(c,8),this.longFormUsed&&this.length<=127&&this.warnings.push("Unnecessary usage of long length form"),this.blockLength=i+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=gr(this.length,8);if(o.byteLength>127)return this.error="Too big length",yt;if(t=new ArrayBuffer(o.byteLength+1),e)return t;let s=new Uint8Array(o);n=new Uint8Array(t),n[0]=o.byteLength|128;for(let i=0;i<o.byteLength;i++)n[i+1]=s[i];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}}};Ks.NAME="lengthBlock";var _={},ke=class extends Ht{constructor({name:e=Rn,optional:t=!1,primitiveSchema:n,...o}={},s){super(o),this.name=e,this.optional=t,n&&(this.primitiveSchema=n),this.idBlock=new Hs(o),this.lenBlock=new Ks(o),this.valueBlock=s?new s(o):new Pe(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 vo;t||Nh(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 s=this.valueBlock.toBER(e);this.lenBlock.length=s.byteLength;let i=this.lenBlock.toBER(e);n.write(i),n.write(s)}return t?yt: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 Ih(t,n)}};ke.NAME="BaseBlock";function Nh(r){if(r instanceof _.Constructed)for(let e of r.valueBlock.value)Nh(e)&&(r.lenBlock.isIndefiniteForm=!0);return!!r.lenBlock.isIndefiniteForm}var zs=class extends ke{constructor({value:e=Rn,...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}'`}};zs.NAME="BaseStringBlock";var qs=class extends jt(Pe){constructor({isHexOnly:e=!0,...t}={}){super(t),this.isHexOnly=e}};qs.NAME="PrimitiveValueBlock";var Uh,js=class extends ke{constructor(e={}){super(e,qs),this.idBlock.isConstructed=!1}};Uh=js;_.Primitive=Uh;js.NAME="PRIMITIVE";function jb(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 Si(r,e=0,t=r.length){let n=e,o=new ke({},Pe),s=new Ht;if(!qt(s,r,e,t))return o.error=s.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=ke;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=jb(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 Nn(r){if(!r.byteLength){let e=new ke({},Pe);return e.error="Input buffer has zero length",{offset:-1,result:e}}return Si(Z.BufferSourceConverter.toUint8Array(r).slice(),0,r.byteLength)}function Gb(r,e){return r?1:e}var It=class extends Pe{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(!qt(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 s=t;for(;Gb(this.isIndefiniteForm,n)>0;){let i=Si(o,s,n);if(i.offset===-1)return this.error=i.result.error,this.warnings.concat(i.result.warnings),-1;if(s=i.offset,this.blockLength+=i.result.blockLength,n-=i.result.blockLength,this.value.push(i.result),this.isIndefiniteForm&&i.result.constructor.NAME===Eo)break}return this.isIndefiniteForm&&(this.value[this.value.length-1].constructor.NAME===Eo?this.value.pop():this.warnings.push("No EndOfContent block encoded")),s}toBER(e,t){let n=t||new vo;for(let o=0;o<this.value.length;o++)this.value[o].toBER(e,n);return t?yt:n.final()}toJSON(){let e={...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,value:[]};for(let t of this.value)e.value.push(t.toJSON());return e}};It.NAME="ConstructedValueBlock";var _h,yr=class extends ke{constructor(e={}){super(e,It),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 HeliaIpns=(()=>{var Tf=Object.create;var Fn=Object.defineProperty;var Cf=Object.getOwnPropertyDescriptor;var Nf=Object.getOwnPropertyNames;var _f=Object.getPrototypeOf,Uf=Object.prototype.hasOwnProperty;var er=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),he=(t,e)=>{for(var r in e)Fn(t,r,{get:e[r],enumerable:!0})},ha=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Nf(e))!Uf.call(t,o)&&o!==r&&Fn(t,o,{get:()=>e[o],enumerable:!(n=Cf(e,o))||n.enumerable});return t};var ht=(t,e,r)=>(r=t!=null?Tf(_f(t)):{},ha(e||!t||!t.__esModule?Fn(r,"default",{value:t,enumerable:!0}):r,t)),Df=t=>ha(Fn({},"__esModule",{value:!0}),t);var ga=er((ag,pa)=>{var yr=1e3,wr=yr*60,br=wr*60,tr=br*24,Lf=tr*7,Vf=tr*365.25;pa.exports=function(t,e){e=e||{};var r=typeof t;if(r==="string"&&t.length>0)return Of(t);if(r==="number"&&isFinite(t))return e.long?Pf(t):Ff(t);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(t))};function Of(t){if(t=String(t),!(t.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(t);if(e){var r=parseFloat(e[1]),n=(e[2]||"ms").toLowerCase();switch(n){case"years":case"year":case"yrs":case"yr":case"y":return r*Vf;case"weeks":case"week":case"w":return r*Lf;case"days":case"day":case"d":return r*tr;case"hours":case"hour":case"hrs":case"hr":case"h":return r*br;case"minutes":case"minute":case"mins":case"min":case"m":return r*wr;case"seconds":case"second":case"secs":case"sec":case"s":return r*yr;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:return}}}}function Ff(t){var e=Math.abs(t);return e>=tr?Math.round(t/tr)+"d":e>=br?Math.round(t/br)+"h":e>=wr?Math.round(t/wr)+"m":e>=yr?Math.round(t/yr)+"s":t+"ms"}function Pf(t){var e=Math.abs(t);return e>=tr?Pn(t,e,tr,"day"):e>=br?Pn(t,e,br,"hour"):e>=wr?Pn(t,e,wr,"minute"):e>=yr?Pn(t,e,yr,"second"):t+" ms"}function Pn(t,e,r,n){var o=e>=r*1.5;return Math.round(t/r)+" "+n+(o?"s":"")}});var ya=er((cg,ma)=>{function Mf(t){r.debug=r,r.default=r,r.coerce=c,r.disable=i,r.enable=o,r.enabled=s,r.humanize=ga(),r.destroy=f,Object.keys(t).forEach(u=>{r[u]=t[u]}),r.names=[],r.skips=[],r.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 r.colors[Math.abs(l)%r.colors.length]}r.selectColor=e;function r(u){let l,d=null,v,m;function h(...p){if(!h.enabled)return;let b=h,k=Number(new Date),E=k-(l||k);b.diff=E,b.prev=l,b.curr=k,l=k,p[0]=r.coerce(p[0]),typeof p[0]!="string"&&p.unshift("%O");let D=0;p[0]=p[0].replace(/%([a-zA-Z%])/g,(I,N)=>{if(I==="%%")return"%";D++;let y=r.formatters[N];if(typeof y=="function"){let C=p[D];I=y.call(b,C),p.splice(D,1),D--}return I}),r.formatArgs.call(b,p),(b.log||r.log).apply(b,p)}return h.namespace=u,h.useColors=r.useColors(),h.color=r.selectColor(u),h.extend=n,h.destroy=r.destroy,Object.defineProperty(h,"enabled",{enumerable:!0,configurable:!1,get:()=>d!==null?d:(v!==r.namespaces&&(v=r.namespaces,m=r.enabled(u)),m),set:p=>{d=p}}),typeof r.init=="function"&&r.init(h),h}function n(u,l){let d=r(this.namespace+(typeof l>"u"?":":l)+u);return d.log=this.log,d}function o(u){r.save(u),r.namespaces=u,r.names=[],r.skips=[];let l,d=(typeof u=="string"?u:"").split(/[\s,]+/),v=d.length;for(l=0;l<v;l++)d[l]&&(u=d[l].replace(/\*/g,".*?"),u[0]==="-"?r.skips.push(new RegExp("^"+u.slice(1)+"$")):r.names.push(new RegExp("^"+u+"$")))}function i(){let u=[...r.names.map(a),...r.skips.map(a).map(l=>"-"+l)].join(",");return r.enable(""),u}function s(u){if(u[u.length-1]==="*")return!0;let l,d;for(l=0,d=r.skips.length;l<d;l++)if(r.skips[l].test(u))return!1;for(l=0,d=r.names.length;l<d;l++)if(r.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 r.enable(r.load()),r}ma.exports=Mf});var wa=er((Ue,Mn)=>{Ue.formatArgs=Kf;Ue.save=$f;Ue.load=qf;Ue.useColors=Hf;Ue.storage=zf();Ue.destroy=(()=>{let t=!1;return()=>{t||(t=!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`."))}})();Ue.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 Hf(){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 Kf(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+Mn.exports.humanize(this.diff),!this.useColors)return;let e="color: "+this.color;t.splice(1,0,e,"color: inherit");let r=0,n=0;t[0].replace(/%[a-zA-Z%]/g,o=>{o!=="%%"&&(r++,o==="%c"&&(n=r))}),t.splice(n,0,e)}Ue.log=console.debug||console.log||(()=>{});function $f(t){try{t?Ue.storage.setItem("debug",t):Ue.storage.removeItem("debug")}catch{}}function qf(){let t;try{t=Ue.storage.getItem("debug")}catch{}return!t&&typeof process<"u"&&"env"in process&&(t=process.env.DEBUG),t}function zf(){try{return localStorage}catch{}}Mn.exports=ya()(Ue);var{formatters:Gf}=Mn.exports;Gf.j=function(t){try{return JSON.stringify(t)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}});var Cc=er(Kr=>{"use strict";var v0="[object ArrayBuffer]",xt=class t{static isArrayBuffer(e){return Object.prototype.toString.call(e)===v0}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,r){if(e.constructor===r)return e;if(this.isArrayBuffer(e))return new r(e);if(this.isArrayBufferView(e))return new r(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,r){let n=t.toUint8Array(e),o=t.toUint8Array(r);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 r;Array.isArray(e[0])&&!(e[1]instanceof Function)||Array.isArray(e[0])&&e[1]instanceof Function?r=e[0]:e[e.length-1]instanceof Function?r=e.slice(0,e.length-1):r=e;let n=0;for(let s of r)n+=s.byteLength;let o=new Uint8Array(n),i=0;for(let s of r){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}},bs="string",B0=/^[0-9a-f]+$/i,A0=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/,S0=/^[a-zA-Z0-9-_]+$/,co=class{static fromString(e){let r=unescape(encodeURIComponent(e)),n=new Uint8Array(r.length);for(let o=0;o<r.length;o++)n[o]=r.charCodeAt(o);return n.buffer}static toString(e){let r=xt.toUint8Array(e),n="";for(let i=0;i<r.length;i++)n+=String.fromCharCode(r[i]);return decodeURIComponent(escape(n))}},Ke=class{static toString(e,r=!1){let n=xt.toArrayBuffer(e),o=new DataView(n),i="";for(let s=0;s<n.byteLength;s+=2){let a=o.getUint16(s,r);i+=String.fromCharCode(a)}return i}static fromString(e,r=!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),r);return n}},uo=class t{static isHex(e){return typeof e===bs&&B0.test(e)}static isBase64(e){return typeof e===bs&&A0.test(e)}static isBase64Url(e){return typeof e===bs&&S0.test(e)}static ToString(e,r="utf8"){let n=xt.toUint8Array(e);switch(r.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 Ke.toString(n,!0);case"utf16":case"utf16be":return Ke.toString(n);default:throw new Error(`Unknown type of encoding '${r}'`)}}static FromString(e,r="utf8"){if(!e)return new ArrayBuffer(0);switch(r.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 Ke.fromString(e,!0);case"utf16":case"utf16be":return Ke.fromString(e);default:throw new Error(`Unknown type of encoding '${r}'`)}}static ToBase64(e){let r=xt.toUint8Array(e);if(typeof btoa<"u"){let n=this.ToString(r,"binary");return btoa(n)}else return Buffer.from(r).toString("base64")}static FromBase64(e){let r=this.formatString(e);if(!r)return new ArrayBuffer(0);if(!t.isBase64(r))throw new TypeError("Argument 'base64Text' is not Base64 encoded");return typeof atob<"u"?this.FromBinary(atob(r)):new Uint8Array(Buffer.from(r,"base64")).buffer}static FromBase64Url(e){let r=this.formatString(e);if(!r)return new ArrayBuffer(0);if(!t.isBase64Url(r))throw new TypeError("Argument 'base64url' is not Base64Url encoded");return this.FromBase64(this.Base64Padding(r.replace(/\-/g,"+").replace(/\_/g,"/")))}static ToBase64Url(e){return this.ToBase64(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/\=/g,"")}static FromUtf8String(e,r=t.DEFAULT_UTF8_ENCODING){switch(r){case"ascii":return this.FromBinary(e);case"utf8":return co.fromString(e);case"utf16":case"utf16be":return Ke.fromString(e);case"utf16le":case"usc2":return Ke.fromString(e,!0);default:throw new Error(`Unknown type of encoding '${r}'`)}}static ToUtf8String(e,r=t.DEFAULT_UTF8_ENCODING){switch(r){case"ascii":return this.ToBinary(e);case"utf8":return co.toString(e);case"utf16":case"utf16be":return Ke.toString(e);case"utf16le":case"usc2":return Ke.toString(e,!0);default:throw new Error(`Unknown type of encoding '${r}'`)}}static FromBinary(e){let r=e.length,n=new Uint8Array(r);for(let o=0;o<r;o++)n[o]=e.charCodeAt(o);return n.buffer}static ToBinary(e){let r=xt.toUint8Array(e),n="";for(let o=0;o<r.length;o++)n+=String.fromCharCode(r[o]);return n}static ToHex(e){let r=xt.toUint8Array(e),n="",o=r.length;for(let i=0;i<o;i++){let s=r[i];s<16&&(n+="0"),n+=s.toString(16)}return n}static FromHex(e){let r=this.formatString(e);if(!r)return new ArrayBuffer(0);if(!t.isHex(r))throw new TypeError("Argument 'hexString' is not HEX encoded");r.length%2&&(r=`0${r}`);let n=new Uint8Array(r.length/2);for(let o=0;o<r.length;o=o+2){let i=r.slice(o,o+2);n[o/2]=parseInt(i,16)}return n.buffer}static ToUtf16String(e,r=!1){return Ke.toString(e,r)}static FromUtf16String(e,r=!1){return Ke.fromString(e,r)}static Base64Padding(e){let r=4-e.length%4;if(r<4)for(let n=0;n<r;n++)e+="=";return e}static formatString(e){return e?.replace(/[\n\r\t ]/g,"")||""}};uo.DEFAULT_UTF8_ENCODING="utf8";function R0(t,...e){let r=arguments[0];for(let n=1;n<arguments.length;n++){let o=arguments[n];for(let i in o)r[i]=o[i]}return r}function k0(...t){let e=t.map(o=>o.byteLength).reduce((o,i)=>o+i),r=new Uint8Array(e),n=0;return t.map(o=>new Uint8Array(o)).forEach(o=>{for(let i of o)r[n++]=i}),r.buffer}function I0(t,e){if(!(t&&e)||t.byteLength!==e.byteLength)return!1;let r=new Uint8Array(t),n=new Uint8Array(e);for(let o=0;o<t.byteLength;o++)if(r[o]!==n[o])return!1;return!0}Kr.BufferSourceConverter=xt;Kr.Convert=uo;Kr.assign=R0;Kr.combine=k0;Kr.isEqual=I0});var Xo=er((hb,Fu)=>{"use strict";function Ou(t,e){for(let r in e)Object.defineProperty(t,r,{value:e[r],enumerable:!0,configurable:!0});return t}function ap(t,e,r){if(!t||typeof t=="string")throw new TypeError("Please pass an Error to err-code");r||(r={}),typeof e=="object"&&(r=e,e=""),e&&(r.code=e);try{return Ou(t,r)}catch{r.message=t.message,r.stack=t.stack;let o=function(){};return o.prototype=Object.create(Object.getPrototypeOf(t)),Ou(new o,r)}}Fu.exports=ap});var ei=er((yb,Ds)=>{var mb=function(){typeof Ds<"u"&&(Ds.exports=h);var t=86400,e=3200,r=146097*e/400,n=t*r,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=D(0,1,2,3,0,4),h.fromInt64LE=D(3,2,1,0,4,0),h.fromString=function(T){var C,V=new h,T=(T+="").replace(/^\s*[+\-]?\d+/,function(M){var M=+M,Z=1970+(M-1970)%400;return V.year=M-Z,Z}).replace(/(?:Z|([+\-]\d{2}):?(\d{2}))$/,function(O,M,Z){return M<0&&(Z*=-1),C=6e4*(60*+M+ +Z),""}).replace(/\.\d+$/,function(O){return V.nano=+(O+c).substr(1,9),""}).split(/\D+/);if(1<T.length?T[1]--:T[1]=0,V.time=C=Date.UTC.apply(Date,T)-(C||0),isNaN(C))throw new TypeError("Invalid Date");return p(V)},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*r*t/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,V=C.toDate(),T={H:function(){return I(V.getUTCHours())},L:function(){return N(V.getUTCMilliseconds(),3)},M:function(){return I(V.getUTCMinutes())},N:function(){return N(C.getNano(),9)},S:function(){return I(V.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 v[V.getUTCDay()]},b:function(){return d[V.getUTCMonth()]},d:function(){return I(V.getUTCDate())},e:function(){return function(O){return(9<O?"":" ")+(0|O)}(V.getUTCDate())},m:function(){return I(V.getUTCMonth()+1)}};return function O(M){return M.replace(/%./g,function(Z){var A=Z[1],x=m[A],A=T[A];return x?O(x):A?A():Z})}(y||l)},u.writeInt64BE=E(0,1,2,3,0,4),u.writeInt64LE=E(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"],v=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],m={"%":"%",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,V){var T=this;if(!(T instanceof h))return new h(y,C,V);T.time=+y||0,T.nano=+C||0,T.year=+V||0,p(T)}function p(y){var C,V,T,O=y.year,M=y.time,Z=y.nano,x=((Z<0||a<=Z)&&(Z-=(V=Math.floor(Z/a))*a,M+=V,V=1),O%e);return(M<-i||i<M||x)&&((C=f(M/o))&&(O+=C*e,M-=C*o),(T=b(M)).setUTCFullYear(x+T.getUTCFullYear()),T=(M=+T)+(C=f((O-=x)/e))*o,C&&-i<=T&&T<=i&&(O-=C*e,M=T),V=1),V&&(y.year=O,y.time=M,y.nano=Z),y}function b(y){var C=new Date(0);return C.setTime(y),C}function k(O,T){O=+O||0;var V=f((T=(T|0)*s)/n)+f(O/n),T=T%n+O%n,O=f(T/n);return O&&(V+=O,T-=O*n),new h(1e3*T,0,V*e)}function E(y,C,V,T,O,M){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*(r*t/e),P=f(B/s)+f(w/s),B=B%s+w%s,w=Math.floor(B/s);return w&&(P+=w,B-=w*s),Z(x,A+O,P),Z(x,A+M,B),x};function Z(x,A,P){x[A+y]=P>>24&255,x[A+C]=P>>16&255,x[A+V]=P>>8&255,x[A+T]=255&P}}function D(y,C,V,T,O,M){return function(x,A){S(x,A|=0);var P=Z(x,A+O);return k(Z(x,A+M),P)};function Z(x,A){return 16777216*x[A+y]+(x[A+C]<<16|x[A+V]<<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 I(y){return(9<y?"":"0")+(0|y)}function N(y,C){return(c+(0|y)).substr(-C)}}()});var ff=er((u1,lf)=>{lf.exports=function(t){if(!t)throw Error("hashlru must have a max value, of type number, greater than 0");var e=0,r=Object.create(null),n=Object.create(null);function o(i,s){r[i]=s,e++,e>=t&&(e=0,n=r,r=Object.create(null))}return{has:function(i){return r[i]!==void 0||n[i]!==void 0},remove:function(i){r[i]!==void 0&&(r[i]=void 0),n[i]!==void 0&&(n[i]=void 0)},get:function(i){var s=r[i];if(s!==void 0)return s;if((s=n[i])!==void 0)return o(i,s),s},set:function(i,s){r[i]!==void 0?r[i]=s:o(i,s)},clear:function(){r=Object.create(null),n=Object.create(null)}}}});var ng={};he(ng,{ipns:()=>rg,ipnsSelector:()=>gi,ipnsValidator:()=>Ws});var bi=Symbol.for("@libp2p/peer-id");function da(t){return t!=null&&!!t[bi]}var $=class extends Error{code;props;constructor(e,r,n){super(e),this.code=r,this.name=n?.name??"CodeError",this.props=n??{}}};var De=ht(wa(),1);var Ai={};he(Ai,{base32:()=>_t,base32hex:()=>eh,base32hexpad:()=>rh,base32hexpadupper:()=>nh,base32hexupper:()=>th,base32pad:()=>Xf,base32padupper:()=>Qf,base32upper:()=>Sa,base32z:()=>oh});var ug=new Uint8Array(0);function ba(t,e){if(t===e)return!0;if(t.byteLength!==e.byteLength)return!1;for(let r=0;r<t.byteLength;r++)if(t[r]!==e[r])return!1;return!0}function dt(t){if(t instanceof Uint8Array&&t.constructor.name==="Uint8Array")return t;if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);throw new Error("Unknown type, must be binary type")}function xa(t){return new TextEncoder().encode(t)}function Ea(t){return new TextDecoder().decode(t)}function jf(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var o=0;o<t.length;o++){var i=t.charAt(o),s=i.charCodeAt(0);if(r[s]!==255)throw new TypeError(i+" is ambiguous");r[s]=o}var a=t.length,c=t.charAt(0),f=Math.log(a)/Math.log(256),u=Math.log(256)/Math.log(a);function l(m){if(m instanceof Uint8Array||(ArrayBuffer.isView(m)?m=new Uint8Array(m.buffer,m.byteOffset,m.byteLength):Array.isArray(m)&&(m=Uint8Array.from(m))),!(m instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(m.length===0)return"";for(var h=0,p=0,b=0,k=m.length;b!==k&&m[b]===0;)b++,h++;for(var E=(k-b)*u+1>>>0,D=new Uint8Array(E);b!==k;){for(var S=m[b],I=0,N=E-1;(S!==0||I<p)&&N!==-1;N--,I++)S+=256*D[N]>>>0,D[N]=S%a>>>0,S=S/a>>>0;if(S!==0)throw new Error("Non-zero carry");p=I,b++}for(var y=E-p;y!==E&&D[y]===0;)y++;for(var C=c.repeat(h);y<E;++y)C+=t.charAt(D[y]);return C}function d(m){if(typeof m!="string")throw new TypeError("Expected String");if(m.length===0)return new Uint8Array;var h=0;if(m[h]!==" "){for(var p=0,b=0;m[h]===c;)p++,h++;for(var k=(m.length-h)*f+1>>>0,E=new Uint8Array(k);m[h];){var D=r[m.charCodeAt(h)];if(D===255)return;for(var S=0,I=k-1;(D!==0||S<b)&&I!==-1;I--,S++)D+=a*E[I]>>>0,E[I]=D%256>>>0,D=D/256>>>0;if(D!==0)throw new Error("Non-zero carry");b=S,h++}if(m[h]!==" "){for(var N=k-b;N!==k&&E[N]===0;)N++;for(var y=new Uint8Array(p+(k-N)),C=p;N!==k;)y[C++]=E[N++];return y}}}function v(m){var h=d(m);if(h)return h;throw new Error(`Non-${e} character`)}return{encode:l,decodeUnsafe:d,decode:v}}var Yf=jf,Zf=Yf,Ba=Zf;var xi=class{name;prefix;baseEncode;constructor(e,r,n){this.name=e,this.prefix=r,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},Ei=class{name;prefix;baseDecode;prefixCodePoint;constructor(e,r,n){if(this.name=e,this.prefix=r,r.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=r.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 Aa(this,e)}},vi=class{decoders;constructor(e){this.decoders=e}or(e){return Aa(this,e)}decode(e){let r=e[0],n=this.decoders[r];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 Aa(t,e){return new vi({...t.decoders??{[t.prefix]:t},...e.decoders??{[e.prefix]:e}})}var Bi=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(e,r,n,o){this.name=e,this.prefix=r,this.baseEncode=n,this.baseDecode=o,this.encoder=new xi(e,r,n),this.decoder=new Ei(e,r,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};function xr({name:t,prefix:e,encode:r,decode:n}){return new Bi(t,e,r,n)}function Nt({name:t,prefix:e,alphabet:r}){let{encode:n,decode:o}=Ba(r,t);return xr({prefix:e,name:t,encode:n,decode:i=>dt(o(i))})}function Wf(t,e,r,n){let o={};for(let u=0;u<e.length;++u)o[e[u]]=u;let i=t.length;for(;t[i-1]==="=";)--i;let s=new Uint8Array(i*r/8|0),a=0,c=0,f=0;for(let u=0;u<i;++u){let l=o[t[u]];if(l===void 0)throw new SyntaxError(`Non-${n} character`);c=c<<r|l,a+=r,a>=8&&(a-=8,s[f++]=255&c>>a)}if(a>=r||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return s}function Jf(t,e,r){let n=e[e.length-1]==="=",o=(1<<r)-1,i="",s=0,a=0;for(let c=0;c<t.length;++c)for(a=a<<8|t[c],s+=8;s>r;)s-=r,i+=e[o&a>>s];if(s!==0&&(i+=e[o&a<<r-s]),n)for(;i.length*r&7;)i+="=";return i}function se({name:t,prefix:e,bitsPerChar:r,alphabet:n}){return xr({prefix:e,name:t,encode(o){return Jf(o,n,r)},decode(o){return Wf(o,n,r,t)}})}var _t=se({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Sa=se({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Xf=se({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Qf=se({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),eh=se({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),th=se({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),rh=se({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),nh=se({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),oh=se({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Si={};he(Si,{base58btc:()=>ye,base58flickr:()=>ih});var ye=Nt({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),ih=Nt({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Ri={};he(Ri,{base64:()=>rn,base64pad:()=>sh,base64url:()=>ah,base64urlpad:()=>ch});var rn=se({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),sh=se({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),ah=se({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),ch=se({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});De.default.formatters.b=t=>t==null?"undefined":ye.baseEncode(t);De.default.formatters.t=t=>t==null?"undefined":_t.baseEncode(t);De.default.formatters.m=t=>t==null?"undefined":rn.baseEncode(t);De.default.formatters.p=t=>t==null?"undefined":t.toString();De.default.formatters.c=t=>t==null?"undefined":t.toString();De.default.formatters.k=t=>t==null?"undefined":t.toString();De.default.formatters.a=t=>t==null?"undefined":t.toString();function uh(t){let e=()=>{};return e.enabled=!1,e.color="",e.diff=0,e.log=()=>{},e.namespace=t,e.destroy=()=>!0,e.extend=()=>e,e}function Ut(t){let e=uh(`${t}:trace`);return De.default.enabled(`${t}:trace`)&&De.default.names.map(r=>r.toString()).find(r=>r.includes(":trace"))!=null&&(e=(0,De.default)(`${t}:trace`)),Object.assign((0,De.default)(t),{error:(0,De.default)(`${t}:error`),trace:e})}var ki={};he(ki,{base10:()=>lh});var lh=Nt({prefix:"9",name:"base10",alphabet:"0123456789"});var Ii={};he(Ii,{base16:()=>fh,base16upper:()=>hh});var fh=se({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),hh=se({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Ti={};he(Ti,{base2:()=>dh});var dh=se({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Ci={};he(Ci,{base256emoji:()=>wh});var Ra=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),ph=Ra.reduce((t,e,r)=>(t[r]=e,t),[]),gh=Ra.reduce((t,e,r)=>(t[e.codePointAt(0)]=r,t),[]);function mh(t){return t.reduce((e,r)=>(e+=ph[r],e),"")}function yh(t){let e=[];for(let r of t){let n=gh[r.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${r}`);e.push(n)}return new Uint8Array(e)}var wh=xr({prefix:"\u{1F680}",name:"base256emoji",encode:mh,decode:yh});var Ni={};he(Ni,{base36:()=>Hn,base36upper:()=>bh});var Hn=Nt({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),bh=Nt({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var _i={};he(_i,{base8:()=>xh});var xh=se({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Ui={};he(Ui,{identity:()=>Eh});var Eh=xr({prefix:"\0",name:"identity",encode:t=>Ea(t),decode:t=>xa(t)});var Tg=new TextEncoder,Cg=new TextDecoder;var Li={};he(Li,{identity:()=>rt});var Ah=Ta,ka=128,Sh=127,Rh=~Sh,kh=Math.pow(2,31);function Ta(t,e,r){e=e||[],r=r||0;for(var n=r;t>=kh;)e[r++]=t&255|ka,t/=128;for(;t&Rh;)e[r++]=t&255|ka,t>>>=7;return e[r]=t|0,Ta.bytes=r-n+1,e}var Ih=Di,Th=128,Ia=127;function Di(t,n){var r=0,n=n||0,o=0,i=n,s,a=t.length;do{if(i>=a)throw Di.bytes=0,new RangeError("Could not decode varint");s=t[i++],r+=o<28?(s&Ia)<<o:(s&Ia)*Math.pow(2,o),o+=7}while(s>=Th);return Di.bytes=i-n,r}var Ch=Math.pow(2,7),Nh=Math.pow(2,14),_h=Math.pow(2,21),Uh=Math.pow(2,28),Dh=Math.pow(2,35),Lh=Math.pow(2,42),Vh=Math.pow(2,49),Oh=Math.pow(2,56),Fh=Math.pow(2,63),Ph=function(t){return t<Ch?1:t<Nh?2:t<_h?3:t<Uh?4:t<Dh?5:t<Lh?6:t<Vh?7:t<Oh?8:t<Fh?9:10},Mh={encode:Ah,decode:Ih,encodingLength:Ph},Hh=Mh,nn=Hh;function on(t,e=0){return[nn.decode(t,e),nn.decode.bytes]}function Er(t,e,r=0){return nn.encode(t,e,r),e}function vr(t){return nn.encodingLength(t)}function tt(t,e){let r=e.byteLength,n=vr(t),o=n+vr(r),i=new Uint8Array(o+r);return Er(t,i,0),Er(r,i,n),i.set(e,o),new Br(t,r,e,i)}function rr(t){let e=dt(t),[r,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 Br(r,o,s,e)}function Ca(t,e){if(t===e)return!0;{let r=e;return t.code===r.code&&t.size===r.size&&r.bytes instanceof Uint8Array&&ba(t.bytes,r.bytes)}}var Br=class{code;size;digest;bytes;constructor(e,r,n,o){this.code=e,this.size=r,this.digest=n,this.bytes=o}};var Na=0,Kh="identity",_a=dt;function $h(t){return tt(Na,_a(t))}var rt={code:Na,name:Kh,encode:_a,digest:$h};var Fi={};he(Fi,{sha256:()=>we,sha512:()=>qh});function Oi({name:t,code:e,encode:r}){return new Vi(t,e,r)}var Vi=class{name;code;encode;constructor(e,r,n){this.name=e,this.code=r,this.encode=n}digest(e){if(e instanceof Uint8Array){let r=this.encode(e);return r instanceof Uint8Array?tt(this.code,r):r.then(n=>tt(this.code,n))}else throw Error("Unknown type, must be binary type")}};function Da(t){return async e=>new Uint8Array(await crypto.subtle.digest(t,e))}var we=Oi({name:"sha2-256",code:18,encode:Da("SHA-256")}),qh=Oi({name:"sha2-512",code:19,encode:Da("SHA-512")});function La(t,e){let{bytes:r,version:n}=t;switch(n){case 0:return Gh(r,Pi(t),e??ye.encoder);default:return jh(r,Pi(t),e??_t.encoder)}}var Va=new WeakMap;function Pi(t){let e=Va.get(t);if(e==null){let r=new Map;return Va.set(t,r),r}return e}var Re=class t{code;version;multihash;bytes;"/";constructor(e,r,n,o){this.code=r,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:r}=this;if(e!==sn)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==Yh)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return t.createV0(r)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:e,digest:r}=this.multihash,n=tt(e,r);return t.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 t.equals(this,e)}static equals(e,r){let n=r;return n!=null&&e.code===n.code&&e.version===n.version&&Ca(e.multihash,n.multihash)}toString(e){return La(this,e)}toJSON(){return{"/":La(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 r=e;if(r instanceof t)return r;if(r["/"]!=null&&r["/"]===r.bytes||r.asCID===r){let{version:n,code:o,multihash:i,bytes:s}=r;return new t(n,o,i,s??Oa(n,o,i.bytes))}else if(r[Zh]===!0){let{version:n,multihash:o,code:i}=r,s=rr(o);return t.create(n,i,s)}else return null}static create(e,r,n){if(typeof r!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(e){case 0:{if(r!==sn)throw new Error(`Version 0 CID must use dag-pb (code: ${sn}) block encoding`);return new t(e,r,n,n.bytes)}case 1:{let o=Oa(e,r,n.bytes);return new t(e,r,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return t.create(0,sn,e)}static createV1(e,r){return t.create(1,e,r)}static decode(e){let[r,n]=t.decodeFirst(e);if(n.length!==0)throw new Error("Incorrect length");return r}static decodeFirst(e){let r=t.inspectBytes(e),n=r.size-r.multihashSize,o=dt(e.subarray(n,n+r.multihashSize));if(o.byteLength!==r.multihashSize)throw new Error("Incorrect length");let i=o.subarray(r.multihashSize-r.digestSize),s=new Br(r.multihashCode,r.digestSize,i,o);return[r.version===0?t.createV0(s):t.createV1(r.codec,s),e.subarray(r.size)]}static inspectBytes(e){let r=0,n=()=>{let[l,d]=on(e.subarray(r));return r+=d,l},o=n(),i=sn;if(o===18?(o=0,r=0):i=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let s=r,a=n(),c=n(),f=r+c,u=f-s;return{version:o,codec:i,multihashCode:a,digestSize:c,multihashSize:u,size:f}}static parse(e,r){let[n,o]=zh(e,r),i=t.decode(o);if(i.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Pi(i).set(n,e),i}};function zh(t,e){switch(t[0]){case"Q":{let r=e??ye;return[ye.prefix,r.decode(`${ye.prefix}${t}`)]}case ye.prefix:{let r=e??ye;return[ye.prefix,r.decode(t)]}case _t.prefix:{let r=e??_t;return[_t.prefix,r.decode(t)]}default:{if(e==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[t[0],e.decode(t)]}}}function Gh(t,e,r){let{prefix:n}=r;if(n!==ye.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);let o=e.get(n);if(o==null){let i=r.encode(t).slice(1);return e.set(n,i),i}else return o}function jh(t,e,r){let{prefix:n}=r,o=e.get(n);if(o==null){let i=r.encode(t);return e.set(n,i),i}else return o}var sn=112,Yh=18;function Oa(t,e,r){let n=vr(t),o=n+vr(e),i=new Uint8Array(o+r.byteLength);return Er(t,i,0),Er(e,i,n),i.set(r,o),i}var Zh=Symbol.for("@ipld/js-cid/CID");var Ar={...Ui,...Ti,..._i,...ki,...Ii,...Ai,...Ni,...Si,...Ri,...Ci},Jg={...Fi,...Li};function be(t,e){if(t===e)return!0;if(t.byteLength!==e.byteLength)return!1;for(let r=0;r<t.byteLength;r++)if(t[r]!==e[r])return!1;return!0}var Wh=Symbol.for("nodejs.util.inspect.custom"),Fa=Object.values(Ar).map(t=>t.decoder).reduce((t,e)=>t.or(e),Ar.identity.decoder),Pa=114,Mi=36,Hi=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()})`}[bi]=!0;toString(){return this.string==null&&(this.string=ye.encode(this.multihash.bytes).slice(1)),this.string}toCID(){return Re.createV1(Pa,this.multihash)}toBytes(){return this.multihash.bytes}toJSON(){return this.toString()}equals(e){if(e==null)return!1;if(e instanceof Uint8Array)return be(this.multihash.bytes,e);if(typeof e=="string")return cn(e).equals(this);if(e?.multihash?.bytes!=null)return be(this.multihash.bytes,e.multihash.bytes);throw new Error("not valid Id")}[Wh](){return`PeerId(${this.toString()})`}},Sr=class extends an{type="RSA";publicKey;constructor(e){super({...e,type:"RSA"}),this.publicKey=e.publicKey}},Rr=class extends an{type="Ed25519";publicKey;constructor(e){super({...e,type:"Ed25519"}),this.publicKey=e.multihash.digest}},kr=class extends an{type="secp256k1";publicKey;constructor(e){super({...e,type:"secp256k1"}),this.publicKey=e.multihash.digest}};function cn(t,e){if(e=e??Fa,t.charAt(0)==="1"||t.charAt(0)==="Q"){let r=rr(ye.decode(`z${t}`));return t.startsWith("12D")?new Rr({multihash:r}):t.startsWith("16U")?new kr({multihash:r}):new Sr({multihash:r})}return Ki(Fa.decode(t))}function Ki(t){try{let e=rr(t);if(e.code===rt.code){if(e.digest.length===Mi)return new Rr({multihash:e});if(e.digest.length===Hi)return new kr({multihash:e})}if(e.code===we.code)return new Sr({multihash:e})}catch{return Jh(Re.decode(t))}throw new Error("Supplied PeerID CID is invalid")}function Jh(t){if(t==null||t.multihash==null||t.version==null||t.version===1&&t.code!==Pa)throw new Error("Supplied PeerID CID is invalid");let e=t.multihash;if(e.code===we.code)return new Sr({multihash:t.multihash});if(e.code===rt.code){if(e.digest.length===Mi)return new Rr({multihash:t.multihash});if(e.digest.length===Hi)return new kr({multihash:t.multihash})}throw new Error("Supplied PeerID CID is invalid")}async function Ma(t,e){return t.length===Mi?new Rr({multihash:tt(rt.code,t),privateKey:e}):t.length===Hi?new kr({multihash:tt(rt.code,t),privateKey:e}):new Sr({multihash:await we.digest(t),publicKey:t,privateKey:e})}var ys={};he(ys,{Ed25519PrivateKey:()=>lr,Ed25519PublicKey:()=>gn,generateKeyPair:()=>b0,generateKeyPairFromSeed:()=>Tc,unmarshalEd25519PrivateKey:()=>y0,unmarshalEd25519PublicKey:()=>w0});function nt(t=0){return new Uint8Array(t)}function or(t,e){e==null&&(e=t.reduce((o,i)=>o+i.length,0));let r=nt(e),n=0;for(let o of t)r.set(o,n),n+=o.length;return r}function Ka(t,e,r,n){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:n}}}var Ha=Ka("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),$i=Ka("ascii","a",t=>{let e="a";for(let r=0;r<t.length;r++)e+=String.fromCharCode(t[r]);return e},t=>{t=t.substring(1);let e=nt(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}),Xh={utf8:Ha,"utf-8":Ha,hex:Ar.base16,latin1:$i,ascii:$i,binary:$i,...Ar},$n=Xh;function J(t,e="utf8"){let r=$n[e];if(r==null)throw new Error(`Unsupported encoding "${e}"`);return r.decoder.decode(`${r.prefix}${t}`)}function He(t){return t==null?!1:typeof t.then=="function"&&typeof t.catch=="function"&&typeof t.finally=="function"}function Ir(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`positive integer expected, not ${t}`)}function Qh(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}function Tr(t,...e){if(!Qh(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error(`Uint8Array expected of length ${e}, not of length=${t.length}`)}function qn(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");Ir(t.outputLen),Ir(t.blockLen)}function Cr(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function $a(t,e){Tr(t);let r=e.outputLen;if(t.length<r)throw new Error(`digestInto() expects output buffer of length at least ${r}`)}var zn=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;var _r=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),Ge=(t,e)=>t<<32-e|t>>>e;var Rm=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;var ed=async()=>{};async function qa(t,e,r){let n=Date.now();for(let o=0;o<t;o++){r(o);let i=Date.now()-n;i>=0&&i<e||(await ed(),n+=i)}}function qi(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}function Dt(t){return typeof t=="string"&&(t=qi(t)),Tr(t),t}function Gn(...t){let e=0;for(let n=0;n<t.length;n++){let o=t[n];Tr(o),e+=o.length}let r=new Uint8Array(e);for(let n=0,o=0;n<t.length;n++){let i=t[n];r.set(i,o),o+=i.length}return r}var Nr=class{clone(){return this._cloneInto()}},td={}.toString;function za(t,e){if(e!==void 0&&td.call(e)!=="[object Object]")throw new Error("Options should be object or undefined");return Object.assign(t,e)}function jn(t){let e=n=>t().update(Dt(n)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}function Ur(t=32){if(zn&&typeof zn.getRandomValues=="function")return zn.getRandomValues(new Uint8Array(t));throw new Error("crypto.getRandomValues must be defined")}function rd(t,e,r,n){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,r,n);let o=BigInt(32),i=BigInt(4294967295),s=Number(r>>o&i),a=Number(r&i),c=n?4:0,f=n?0:4;t.setUint32(e+c,s,n),t.setUint32(e+f,a,n)}var Ga=(t,e,r)=>t&e^~t&r,ja=(t,e,r)=>t&e^t&r^e&r,Dr=class extends Nr{constructor(e,r,n,o){super(),this.blockLen=e,this.outputLen=r,this.padOffset=n,this.isLE=o,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=_r(this.buffer)}update(e){Cr(this);let{view:r,buffer:n,blockLen:o}=this;e=Dt(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=_r(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(r,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){Cr(this),$a(e,this),this.finished=!0;let{buffer:r,view:n,blockLen:o,isLE:i}=this,{pos:s}=this;r[s++]=128,this.buffer.subarray(s).fill(0),this.padOffset>o-s&&(this.process(n,0),s=0);for(let l=s;l<o;l++)r[l]=0;rd(n,o-8,BigInt(this.length*8),i),this.process(n,0);let a=_r(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:r}=this;this.digestInto(e);let n=e.slice(0,r);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());let{blockLen:r,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%r&&e.buffer.set(n),e}};var Yn=BigInt(4294967295),zi=BigInt(32);function Ya(t,e=!1){return e?{h:Number(t&Yn),l:Number(t>>zi&Yn)}:{h:Number(t>>zi&Yn)|0,l:Number(t&Yn)|0}}function nd(t,e=!1){let r=new Uint32Array(t.length),n=new Uint32Array(t.length);for(let o=0;o<t.length;o++){let{h:i,l:s}=Ya(t[o],e);[r[o],n[o]]=[i,s]}return[r,n]}var od=(t,e)=>BigInt(t>>>0)<<zi|BigInt(e>>>0),id=(t,e,r)=>t>>>r,sd=(t,e,r)=>t<<32-r|e>>>r,ad=(t,e,r)=>t>>>r|e<<32-r,cd=(t,e,r)=>t<<32-r|e>>>r,ud=(t,e,r)=>t<<64-r|e>>>r-32,ld=(t,e,r)=>t>>>r-32|e<<64-r,fd=(t,e)=>e,hd=(t,e)=>t,dd=(t,e,r)=>t<<r|e>>>32-r,pd=(t,e,r)=>e<<r|t>>>32-r,gd=(t,e,r)=>e<<r-32|t>>>64-r,md=(t,e,r)=>t<<r-32|e>>>64-r;function yd(t,e,r,n){let o=(e>>>0)+(n>>>0);return{h:t+r+(o/2**32|0)|0,l:o|0}}var wd=(t,e,r)=>(t>>>0)+(e>>>0)+(r>>>0),bd=(t,e,r,n)=>e+r+n+(t/2**32|0)|0,xd=(t,e,r,n)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0),Ed=(t,e,r,n,o)=>e+r+n+o+(t/2**32|0)|0,vd=(t,e,r,n,o)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0)+(o>>>0),Bd=(t,e,r,n,o,i)=>e+r+n+o+i+(t/2**32|0)|0;var Ad={fromBig:Ya,split:nd,toBig:od,shrSH:id,shrSL:sd,rotrSH:ad,rotrSL:cd,rotrBH:ud,rotrBL:ld,rotr32H:fd,rotr32L:hd,rotlSH:dd,rotlSL:pd,rotlBH:gd,rotlBL:md,add:yd,add3L:wd,add3H:bd,add4L:xd,add4H:Ed,add5H:Bd,add5L:vd},q=Ad;var[Sd,Rd]=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(t=>BigInt(t))),Lt=new Uint32Array(80),Vt=new Uint32Array(80),Gi=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:r,Bh:n,Bl:o,Ch:i,Cl:s,Dh:a,Dl:c,Eh:f,El:u,Fh:l,Fl:d,Gh:v,Gl:m,Hh:h,Hl:p}=this;return[e,r,n,o,i,s,a,c,f,u,l,d,v,m,h,p]}set(e,r,n,o,i,s,a,c,f,u,l,d,v,m,h,p){this.Ah=e|0,this.Al=r|0,this.Bh=n|0,this.Bl=o|0,this.Ch=i|0,this.Cl=s|0,this.Dh=a|0,this.Dl=c|0,this.Eh=f|0,this.El=u|0,this.Fh=l|0,this.Fl=d|0,this.Gh=v|0,this.Gl=m|0,this.Hh=h|0,this.Hl=p|0}process(e,r){for(let E=0;E<16;E++,r+=4)Lt[E]=e.getUint32(r),Vt[E]=e.getUint32(r+=4);for(let E=16;E<80;E++){let D=Lt[E-15]|0,S=Vt[E-15]|0,I=q.rotrSH(D,S,1)^q.rotrSH(D,S,8)^q.shrSH(D,S,7),N=q.rotrSL(D,S,1)^q.rotrSL(D,S,8)^q.shrSL(D,S,7),y=Lt[E-2]|0,C=Vt[E-2]|0,V=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,Vt[E-7],Vt[E-16]),M=q.add4H(O,I,V,Lt[E-7],Lt[E-16]);Lt[E]=M|0,Vt[E]=O|0}let{Ah:n,Al:o,Bh:i,Bl:s,Ch:a,Cl:c,Dh:f,Dl:u,Eh:l,El:d,Fh:v,Fl:m,Gh:h,Gl:p,Hh:b,Hl:k}=this;for(let E=0;E<80;E++){let D=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),I=l&v^~l&h,N=d&m^~d&p,y=q.add5L(k,S,N,Rd[E],Vt[E]),C=q.add5H(y,b,D,I,Sd[E],Lt[E]),V=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),M=n&i^n&a^i&a,Z=o&s^o&c^s&c;b=h|0,k=p|0,h=v|0,p=m|0,v=l|0,m=d|0,{h:l,l:d}=q.add(f|0,u|0,C|0,V|0),f=a|0,u=c|0,a=i|0,c=s|0,i=n|0,s=o|0;let x=q.add3L(V,O,Z);n=q.add3H(x,C,T,M),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:v,l:m}=q.add(this.Fh|0,this.Fl|0,v|0,m|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,v,m,h,p,b,k)}roundClean(){Lt.fill(0),Vt.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 Lr=jn(()=>new Gi);var Wn={};he(Wn,{abytes:()=>Vr,bitGet:()=>Ud,bitLen:()=>_d,bitMask:()=>un,bitSet:()=>Dd,bytesToHex:()=>gt,bytesToNumberBE:()=>mt,bytesToNumberLE:()=>Ft,concatBytes:()=>yt,createHmacDrbg:()=>Zi,ensureBytes:()=>ae,equalBytes:()=>Cd,hexToBytes:()=>ir,hexToNumber:()=>Yi,isBytes:()=>Ot,numberToBytesBE:()=>Pt,numberToBytesLE:()=>sr,numberToHexUnpadded:()=>Xa,numberToVarBytesBE:()=>Td,utf8ToBytes:()=>Nd,validateObject:()=>ot});var Ja=BigInt(0),Zn=BigInt(1),kd=BigInt(2);function Ot(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}function Vr(t){if(!Ot(t))throw new Error("Uint8Array expected")}var Id=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function gt(t){Vr(t);let e="";for(let r=0;r<t.length;r++)e+=Id[t[r]];return e}function Xa(t){let e=t.toString(16);return e.length&1?`0${e}`:e}function Yi(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return BigInt(t===""?"0":`0x${t}`)}var pt={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function Za(t){if(t>=pt._0&&t<=pt._9)return t-pt._0;if(t>=pt._A&&t<=pt._F)return t-(pt._A-10);if(t>=pt._a&&t<=pt._f)return t-(pt._a-10)}function ir(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);let e=t.length,r=e/2;if(e%2)throw new Error("padded hex string expected, got unpadded hex of length "+e);let n=new Uint8Array(r);for(let o=0,i=0;o<r;o++,i+=2){let s=Za(t.charCodeAt(i)),a=Za(t.charCodeAt(i+1));if(s===void 0||a===void 0){let c=t[i]+t[i+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+i)}n[o]=s*16+a}return n}function mt(t){return Yi(gt(t))}function Ft(t){return Vr(t),Yi(gt(Uint8Array.from(t).reverse()))}function Pt(t,e){return ir(t.toString(16).padStart(e*2,"0"))}function sr(t,e){return Pt(t,e).reverse()}function Td(t){return ir(Xa(t))}function ae(t,e,r){let n;if(typeof e=="string")try{n=ir(e)}catch(i){throw new Error(`${t} must be valid hex string, got "${e}". Cause: ${i}`)}else if(Ot(e))n=Uint8Array.from(e);else throw new Error(`${t} must be hex string or Uint8Array`);let o=n.length;if(typeof r=="number"&&o!==r)throw new Error(`${t} expected ${r} bytes, got ${o}`);return n}function yt(...t){let e=0;for(let n=0;n<t.length;n++){let o=t[n];Vr(o),e+=o.length}let r=new Uint8Array(e);for(let n=0,o=0;n<t.length;n++){let i=t[n];r.set(i,o),o+=i.length}return r}function Cd(t,e){if(t.length!==e.length)return!1;let r=0;for(let n=0;n<t.length;n++)r|=t[n]^e[n];return r===0}function Nd(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}function _d(t){let e;for(e=0;t>Ja;t>>=Zn,e+=1);return e}function Ud(t,e){return t>>BigInt(e)&Zn}function Dd(t,e,r){return t|(r?Zn:Ja)<<BigInt(e)}var un=t=>(kd<<BigInt(t-1))-Zn,ji=t=>new Uint8Array(t),Wa=t=>Uint8Array.from(t);function Zi(t,e,r){if(typeof t!="number"||t<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 r!="function")throw new Error("hmacFn must be a function");let n=ji(t),o=ji(t),i=0,s=()=>{n.fill(1),o.fill(0),i=0},a=(...l)=>r(o,n,...l),c=(l=ji())=>{o=a(Wa([0]),l),n=a(),l.length!==0&&(o=a(Wa([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 v=n.slice();d.push(v),l+=n.length}return yt(...d)};return(l,d)=>{s(),c(l);let v;for(;!(v=d(f()));)c();return s(),v}}var Ld={bigint:t=>typeof t=="bigint",function:t=>typeof t=="function",boolean:t=>typeof t=="boolean",string:t=>typeof t=="string",stringOrUint8Array:t=>typeof t=="string"||Ot(t),isSafeInteger:t=>Number.isSafeInteger(t),array:t=>Array.isArray(t),field:(t,e)=>e.Fp.isValid(t),hash:t=>typeof t=="function"&&Number.isSafeInteger(t.outputLen)};function ot(t,e,r={}){let n=(o,i,s)=>{let a=Ld[i];if(typeof a!="function")throw new Error(`Invalid validator "${i}", expected function`);let c=t[o];if(!(s&&c===void 0)&&!a(c,t))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(r))n(o,i,!0);return t}var fe=BigInt(0),re=BigInt(1),ar=BigInt(2),Vd=BigInt(3),Wi=BigInt(4),Qa=BigInt(5),ec=BigInt(8),Od=BigInt(9),Fd=BigInt(16);function ee(t,e){let r=t%e;return r>=fe?r:e+r}function Pd(t,e,r){if(r<=fe||e<fe)throw new Error("Expected power/modulo > 0");if(r===re)return fe;let n=re;for(;e>fe;)e&re&&(n=n*t%r),t=t*t%r,e>>=re;return n}function ne(t,e,r){let n=t;for(;e-- >fe;)n*=n,n%=r;return n}function Jn(t,e){if(t===fe||e<=fe)throw new Error(`invert: expected positive integers, got n=${t} mod=${e}`);let r=ee(t,e),n=e,o=fe,i=re,s=re,a=fe;for(;r!==fe;){let f=n/r,u=n%r,l=o-s*f,d=i-a*f;n=r,r=u,o=s,i=a,s=l,a=d}if(n!==re)throw new Error("invert: does not exist");return ee(o,e)}function Md(t){let e=(t-re)/ar,r,n,o;for(r=t-re,n=0;r%ar===fe;r/=ar,n++);for(o=ar;o<t&&Pd(o,e,t)!==t-re;o++);if(n===1){let s=(t+re)/Wi;return function(c,f){let u=c.pow(f,s);if(!c.eql(c.sqr(u),f))throw new Error("Cannot find square root");return u}}let i=(r+re)/ar;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),r),l=a.pow(c,i),d=a.pow(c,r);for(;!a.eql(d,a.ONE);){if(a.eql(d,a.ZERO))return a.ZERO;let v=1;for(let h=a.sqr(d);v<f&&!a.eql(h,a.ONE);v++)h=a.sqr(h);let m=a.pow(u,re<<BigInt(f-v-1));u=a.sqr(m),l=a.mul(l,m),d=a.mul(d,u),f=v}return l}}function Hd(t){if(t%Wi===Vd){let e=(t+re)/Wi;return function(n,o){let i=n.pow(o,e);if(!n.eql(n.sqr(i),o))throw new Error("Cannot find square root");return i}}if(t%ec===Qa){let e=(t-Qa)/ec;return function(n,o){let i=n.mul(o,ar),s=n.pow(i,e),a=n.mul(o,s),c=n.mul(n.mul(a,ar),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 t%Fd,Md(t)}var tc=(t,e)=>(ee(t,e)&re)===re,Kd=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Ji(t){let e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},r=Kd.reduce((n,o)=>(n[o]="function",n),e);return ot(t,r)}function $d(t,e,r){if(r<fe)throw new Error("Expected power > 0");if(r===fe)return t.ONE;if(r===re)return e;let n=t.ONE,o=e;for(;r>fe;)r&re&&(n=t.mul(n,o)),o=t.sqr(o),r>>=re;return n}function qd(t,e){let r=new Array(e.length),n=e.reduce((i,s,a)=>t.is0(s)?i:(r[a]=i,t.mul(i,s)),t.ONE),o=t.inv(n);return e.reduceRight((i,s,a)=>t.is0(s)?i:(r[a]=t.mul(i,r[a]),t.mul(i,s)),o),r}function Xi(t,e){let r=e!==void 0?e:t.toString(2).length,n=Math.ceil(r/8);return{nBitLength:r,nByteLength:n}}function Xn(t,e,r=!1,n={}){if(t<=fe)throw new Error(`Expected Field ORDER > 0, got ${t}`);let{nBitLength:o,nByteLength:i}=Xi(t,e);if(i>2048)throw new Error("Field lengths over 2048 bytes are not supported");let s=Hd(t),a=Object.freeze({ORDER:t,BITS:o,BYTES:i,MASK:un(o),ZERO:fe,ONE:re,create:c=>ee(c,t),isValid:c=>{if(typeof c!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof c}`);return fe<=c&&c<t},is0:c=>c===fe,isOdd:c=>(c&re)===re,neg:c=>ee(-c,t),eql:(c,f)=>c===f,sqr:c=>ee(c*c,t),add:(c,f)=>ee(c+f,t),sub:(c,f)=>ee(c-f,t),mul:(c,f)=>ee(c*f,t),pow:(c,f)=>$d(a,c,f),div:(c,f)=>ee(c*Jn(f,t),t),sqrN:c=>c*c,addN:(c,f)=>c+f,subN:(c,f)=>c-f,mulN:(c,f)=>c*f,inv:c=>Jn(c,t),sqrt:n.sqrt||(c=>s(a,c)),invertBatch:c=>qd(a,c),cmov:(c,f,u)=>u?f:c,toBytes:c=>r?sr(c,i):Pt(c,i),fromBytes:c=>{if(c.length!==i)throw new Error(`Fp.fromBytes: expected ${i}, got ${c.length}`);return r?Ft(c):mt(c)}});return Object.freeze(a)}function rc(t,e){if(!t.isOdd)throw new Error("Field doesn't have isOdd");let r=t.sqrt(e);return t.isOdd(r)?t.neg(r):r}function nc(t){if(typeof t!="bigint")throw new Error("field order must be bigint");let e=t.toString(2).length;return Math.ceil(e/8)}function Qi(t){let e=nc(t);return e+Math.ceil(e/2)}function oc(t,e,r=!1){let n=t.length,o=nc(e),i=Qi(e);if(n<16||n<i||n>1024)throw new Error(`expected ${i}-1024 bytes of input, got ${n}`);let s=r?mt(t):Ft(t),a=ee(s,e-re)+re;return r?sr(a,o):Pt(a,o)}var Gd=BigInt(0),es=BigInt(1);function Qn(t,e){let r=(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:r,unsafeLadder(o,i){let s=t.ZERO,a=o;for(;i>Gd;)i&es&&(s=s.add(a)),a=a.double(),i>>=es;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=t.ZERO,u=t.BASE,l=BigInt(2**o-1),d=2**o,v=BigInt(o);for(let m=0;m<a;m++){let h=m*c,p=Number(s&l);s>>=v,p>c&&(p-=d,s+=es);let b=h,k=h+Math.abs(p)-1,E=m%2!==0,D=p<0;p===0?u=u.add(r(E,i[b])):f=f.add(r(D,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 ln(t){return Ji(t.Fp),ot(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Xi(t.n,t.nBitLength),...t,p:t.Fp.ORDER})}var je=BigInt(0),Le=BigInt(1),eo=BigInt(2),jd=BigInt(8),Yd={zip215:!0};function Zd(t){let e=ln(t);return ot(t,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...e})}function to(t){let e=Zd(t),{Fp:r,n,prehash:o,hash:i,randomBytes:s,nByteLength:a,h:c}=e,f=eo<<BigInt(a*8)-Le,u=r.create,l=e.uvRatio||((B,w)=>{try{return{isValid:!0,value:r.sqrt(B*r.inv(w))}}catch{return{isValid:!1,value:je}}}),d=e.adjustScalarBytes||(B=>B),v=e.domain||((B,w,L)=>{if(w.length||L)throw new Error("Contexts/pre-hash are not supported");return B}),m=B=>typeof B=="bigint"&&je<B,h=(B,w)=>m(B)&&m(w)&&B<w,p=B=>B===je||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===je?B:b(B,n)}let E=new Map;function D(B){if(!(B instanceof S))throw new Error("ExtendedPoint expected")}class S{constructor(w,L,F,H){if(this.ex=w,this.ey=L,this.ez=F,this.et=H,!p(w))throw new Error("x required");if(!p(L))throw new Error("y required");if(!p(F))throw new Error("z required");if(!p(H))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:L,y:F}=w||{};if(!p(L)||!p(F))throw new Error("invalid affine point");return new S(L,F,Le,u(L*F))}static normalizeZ(w){let L=r.invertBatch(w.map(F=>F.ez));return w.map((F,H)=>F.toAffine(L[H])).map(S.fromAffine)}_setWindowSize(w){this._WINDOW_SIZE=w,E.delete(this)}assertValidity(){let{a:w,d:L}=e;if(this.is0())throw new Error("bad point: ZERO");let{ex:F,ey:H,ez:z,et:G}=this,Q=u(F*F),Y=u(H*H),W=u(z*z),ce=u(W*W),ie=u(Q*w),ge=u(W*u(ie+Y)),me=u(ce+u(L*u(Q*Y)));if(ge!==me)throw new Error("bad point: equation left != right (1)");let le=u(F*H),Be=u(z*G);if(le!==Be)throw new Error("bad point: equation left != right (2)")}equals(w){D(w);let{ex:L,ey:F,ez:H}=this,{ex:z,ey:G,ez:Q}=w,Y=u(L*Q),W=u(z*H),ce=u(F*Q),ie=u(G*H);return Y===W&&ce===ie}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:L,ey:F,ez:H}=this,z=u(L*L),G=u(F*F),Q=u(eo*u(H*H)),Y=u(w*z),W=L+F,ce=u(u(W*W)-z-G),ie=Y+G,ge=ie-Q,me=Y-G,le=u(ce*ge),Be=u(ie*me),ft=u(ce*me),Qt=u(ge*ie);return new S(le,Be,Qt,ft)}add(w){D(w);let{a:L,d:F}=e,{ex:H,ey:z,ez:G,et:Q}=this,{ex:Y,ey:W,ez:ce,et:ie}=w;if(L===BigInt(-1)){let ia=u((z-H)*(W+Y)),sa=u((z+H)*(W-Y)),wi=u(sa-ia);if(wi===je)return this.double();let aa=u(G*eo*ie),ca=u(Q*eo*ce),ua=ca+aa,la=sa+ia,fa=ca-aa,Sf=u(ua*wi),Rf=u(la*fa),kf=u(ua*fa),If=u(wi*la);return new S(Sf,Rf,If,kf)}let ge=u(H*Y),me=u(z*W),le=u(Q*F*ie),Be=u(G*ce),ft=u((H+z)*(Y+W)-ge-me),Qt=Be-le,tn=Be+le,oa=u(me-L*ge),Ef=u(ft*Qt),vf=u(tn*oa),Bf=u(ft*oa),Af=u(Qt*tn);return new S(Ef,vf,Af,Bf)}subtract(w){return this.add(w.negate())}wNAF(w){return y.wNAFCached(this,E,w,S.normalizeZ)}multiply(w){let{p:L,f:F}=this.wNAF(b(w,n));return S.normalizeZ([L,F])[0]}multiplyUnsafe(w){let L=k(w);return L===je?N:this.equals(N)||L===Le?this:this.equals(I)?this.wNAF(L).p:y.unsafeLadder(this,L)}isSmallOrder(){return this.multiplyUnsafe(c).is0()}isTorsionFree(){return y.unsafeLadder(this,n).is0()}toAffine(w){let{ex:L,ey:F,ez:H}=this,z=this.is0();w==null&&(w=z?jd:r.inv(H));let G=u(L*w),Q=u(F*w),Y=u(H*w);if(z)return{x:je,y:Le};if(Y!==Le)throw new Error("invZ was invalid");return{x:G,y:Q}}clearCofactor(){let{h:w}=e;return w===Le?this:this.multiplyUnsafe(w)}static fromHex(w,L=!1){let{d:F,a:H}=e,z=r.BYTES;w=ae("pointHex",w,z);let G=w.slice(),Q=w[z-1];G[z-1]=Q&-129;let Y=Ft(G);Y===je||(L?b(Y,f):b(Y,r.ORDER));let W=u(Y*Y),ce=u(W-Le),ie=u(F*W-H),{isValid:ge,value:me}=l(ce,ie);if(!ge)throw new Error("Point.fromHex: invalid y coordinate");let le=(me&Le)===Le,Be=(Q&128)!==0;if(!L&&me===je&&Be)throw new Error("Point.fromHex: x=0 and x_0=1");return Be!==le&&(me=u(-me)),S.fromAffine({x:me,y:Y})}static fromPrivateKey(w){return T(w).point}toRawBytes(){let{x:w,y:L}=this.toAffine(),F=sr(L,r.BYTES);return F[F.length-1]|=w&Le?128:0,F}toHex(){return gt(this.toRawBytes())}}S.BASE=new S(e.Gx,e.Gy,Le,u(e.Gx*e.Gy)),S.ZERO=new S(je,Le,Le,je);let{BASE:I,ZERO:N}=S,y=Qn(S,a*8);function C(B){return ee(B,n)}function V(B){return C(Ft(B))}function T(B){let w=a;B=ae("private key",B,w);let L=ae("hashed private key",i(B),2*w),F=d(L.slice(0,w)),H=L.slice(w,2*w),z=V(F),G=I.multiply(z),Q=G.toRawBytes();return{head:F,prefix:H,scalar:z,point:G,pointBytes:Q}}function O(B){return T(B).pointBytes}function M(B=new Uint8Array,...w){let L=yt(...w);return V(i(v(L,ae("context",B),!!o)))}function Z(B,w,L={}){B=ae("message",B),o&&(B=o(B));let{prefix:F,scalar:H,pointBytes:z}=T(w),G=M(L.context,F,B),Q=I.multiply(G).toRawBytes(),Y=M(L.context,Q,z,B),W=C(G+Y*H);k(W);let ce=yt(Q,sr(W,r.BYTES));return ae("result",ce,a*2)}let x=Yd;function A(B,w,L,F=x){let{context:H,zip215:z}=F,G=r.BYTES;B=ae("signature",B,2*G),w=ae("message",w),o&&(w=o(w));let Q=Ft(B.slice(G,2*G)),Y,W,ce;try{Y=S.fromHex(L,z),W=S.fromHex(B.slice(0,G),z),ce=I.multiplyUnsafe(Q)}catch{return!1}if(!z&&Y.isSmallOrder())return!1;let ie=M(H,W.toRawBytes(),Y.toRawBytes(),w);return W.add(Y.multiplyUnsafe(ie)).subtract(ce).clearCofactor().equals(S.ZERO)}return I._setWindowSize(8),{CURVE:e,getPublicKey:O,sign:Z,verify:A,ExtendedPoint:S,utils:{getExtendedPublicKey:T,randomPrivateKey:()=>s(r.BYTES),precompute(B=8,w=S.BASE){return w._setWindowSize(B),w.multiply(BigInt(3)),w}}}}var rs=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),ic=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),Ym=BigInt(0),Wd=BigInt(1),ts=BigInt(2),Jd=BigInt(5),sc=BigInt(10),Xd=BigInt(20),Qd=BigInt(40),ac=BigInt(80);function e0(t){let e=rs,n=t*t%e*t%e,o=ne(n,ts,e)*n%e,i=ne(o,Wd,e)*t%e,s=ne(i,Jd,e)*i%e,a=ne(s,sc,e)*s%e,c=ne(a,Xd,e)*a%e,f=ne(c,Qd,e)*c%e,u=ne(f,ac,e)*f%e,l=ne(u,ac,e)*f%e,d=ne(l,sc,e)*s%e;return{pow_p_5_8:ne(d,ts,e)*t%e,b2:n}}function t0(t){return t[0]&=248,t[31]&=127,t[31]|=64,t}function r0(t,e){let r=rs,n=ee(e*e*e,r),o=ee(n*n*e,r),i=e0(t*o).pow_p_5_8,s=ee(t*n*i,r),a=ee(e*s*s,r),c=s,f=ee(s*ic,r),u=a===t,l=a===ee(-t,r),d=a===ee(-t*ic,r);return u&&(s=c),(l||d)&&(s=f),tc(s,r)&&(s=ee(-s,r)),{isValid:u||l,value:s}}var wt=Xn(rs,void 0,!0),ns={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:wt,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:BigInt(8),Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:Lr,randomBytes:Ur,adjustScalarBytes:t0,uvRatio:r0},Or=to(ns);function cc(t,e,r){if(e.length>255)throw new Error("Context is too big");return Gn(qi("SigEd25519 no Ed25519 collisions"),new Uint8Array([r?1:0,e.length]),e,t)}var Zm=to({...ns,domain:cc}),Wm=to({...ns,domain:cc,prehash:Lr});var n0=(wt.ORDER+BigInt(3))/BigInt(8),Jm=wt.pow(ts,n0),Xm=wt.sqrt(wt.neg(wt.ONE)),Qm=(wt.ORDER-BigInt(5))/BigInt(8),ey=BigInt(486662);var ty=rc(wt,wt.neg(BigInt(486664)));var ry=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),ny=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),oy=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),iy=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952");var sy=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");var Fr=32,bt=64,ro=32;function uc(){let t=Or.utils.randomPrivateKey(),e=Or.getPublicKey(t);return{privateKey:dc(t,e),publicKey:e}}function lc(t){if(t.length!==ro)throw new TypeError('"seed" must be 32 bytes in length.');if(!(t instanceof Uint8Array))throw new TypeError('"seed" must be a node.js Buffer, or Uint8Array.');let e=t,r=Or.getPublicKey(e);return{privateKey:dc(e,r),publicKey:r}}function fc(t,e){let r=t.subarray(0,ro);return Or.sign(e instanceof Uint8Array?e:e.subarray(),r)}function hc(t,e,r){return Or.verify(e,r instanceof Uint8Array?r:r.subarray(),t)}function dc(t,e){let r=new Uint8Array(bt);for(let n=0;n<ro;n++)r[n]=t[n],r[ro+n]=e[n];return r}var ke={get(t=globalThis){let e=t.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 os={alg:"A128GCM",ext:!0,k:"scm9jmO_4BJAgdwWGVulLg",key_ops:["encrypt","decrypt"],kty:"oct"};function pc(t){let e=t?.algorithm??"AES-GCM",r=t?.keyLength??16,n=t?.nonceLength??12,o=t?.digest??"SHA-256",i=t?.saltLength??16,s=t?.iterations??32767,a=ke.get();r*=8;async function c(l,d){let v=a.getRandomValues(new Uint8Array(i)),m=a.getRandomValues(new Uint8Array(n)),h={name:e,iv:m};typeof d=="string"&&(d=J(d));let p;if(d.length===0){p=await a.subtle.importKey("jwk",os,{name:"AES-GCM"},!0,["encrypt"]);try{let k={name:"PBKDF2",salt:v,iterations:s,hash:{name:o}},E=await a.subtle.importKey("raw",d,{name:"PBKDF2"},!1,["deriveKey"]);p=await a.subtle.deriveKey(k,E,{name:e,length:r},!0,["encrypt"])}catch{p=await a.subtle.importKey("jwk",os,{name:"AES-GCM"},!0,["encrypt"])}}else{let k={name:"PBKDF2",salt:v,iterations:s,hash:{name:o}},E=await a.subtle.importKey("raw",d,{name:"PBKDF2"},!1,["deriveKey"]);p=await a.subtle.deriveKey(k,E,{name:e,length:r},!0,["encrypt"])}let b=await a.subtle.encrypt(h,p,l);return or([v,h.iv,new Uint8Array(b)])}async function f(l,d){let v=l.subarray(0,i),m=l.subarray(i,i+n),h=l.subarray(i+n),p={name:e,iv:m};typeof d=="string"&&(d=J(d));let b;if(d.length===0)try{let E={name:"PBKDF2",salt:v,iterations:s,hash:{name:o}},D=await a.subtle.importKey("raw",d,{name:"PBKDF2"},!1,["deriveKey"]);b=await a.subtle.deriveKey(E,D,{name:e,length:r},!0,["decrypt"])}catch{b=await a.subtle.importKey("jwk",os,{name:"AES-GCM"},!0,["decrypt"])}else{let E={name:"PBKDF2",salt:v,iterations:s,hash:{name:o}},D=await a.subtle.importKey("raw",d,{name:"PBKDF2"},!1,["deriveKey"]);b=await a.subtle.deriveKey(E,D,{name:e,length:r},!0,["decrypt"])}let k=await a.subtle.decrypt(p,b,h);return new Uint8Array(k)}return{encrypt:c,decrypt:f}}async function Pr(t,e){let n=await pc().encrypt(t,e);return rn.encode(n)}var s0=Math.pow(2,7),a0=Math.pow(2,14),c0=Math.pow(2,21),gc=Math.pow(2,28),mc=Math.pow(2,35),yc=Math.pow(2,42),wc=Math.pow(2,49),Ie=128,Mt=127;function fn(t){if(t<s0)return 1;if(t<a0)return 2;if(t<c0)return 3;if(t<gc)return 4;if(t<mc)return 5;if(t<yc)return 6;if(t<wc)return 7;if(Number.MAX_SAFE_INTEGER!=null&&t>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function bc(t,e,r=0){switch(fn(t)){case 8:e[r++]=t&255|Ie,t/=128;case 7:e[r++]=t&255|Ie,t/=128;case 6:e[r++]=t&255|Ie,t/=128;case 5:e[r++]=t&255|Ie,t/=128;case 4:e[r++]=t&255|Ie,t>>>=7;case 3:e[r++]=t&255|Ie,t>>>=7;case 2:e[r++]=t&255|Ie,t>>>=7;case 1:{e[r++]=t&255,t>>>=7;break}default:throw new Error("unreachable")}return e}function xc(t,e){let r=t[e],n=0;if(n+=r&Mt,r<Ie||(r=t[e+1],n+=(r&Mt)<<7,r<Ie)||(r=t[e+2],n+=(r&Mt)<<14,r<Ie)||(r=t[e+3],n+=(r&Mt)<<21,r<Ie)||(r=t[e+4],n+=(r&Mt)*gc,r<Ie)||(r=t[e+5],n+=(r&Mt)*mc,r<Ie)||(r=t[e+6],n+=(r&Mt)*yc,r<Ie)||(r=t[e+7],n+=(r&Mt)*wc,r<Ie))return n;throw new RangeError("Could not decode varint")}var is=new Float32Array([-0]),Ht=new Uint8Array(is.buffer);function Ec(t,e,r){is[0]=t,e[r]=Ht[0],e[r+1]=Ht[1],e[r+2]=Ht[2],e[r+3]=Ht[3]}function vc(t,e){return Ht[0]=t[e],Ht[1]=t[e+1],Ht[2]=t[e+2],Ht[3]=t[e+3],is[0]}var ss=new Float64Array([-0]),Ae=new Uint8Array(ss.buffer);function Bc(t,e,r){ss[0]=t,e[r]=Ae[0],e[r+1]=Ae[1],e[r+2]=Ae[2],e[r+3]=Ae[3],e[r+4]=Ae[4],e[r+5]=Ae[5],e[r+6]=Ae[6],e[r+7]=Ae[7]}function Ac(t,e){return Ae[0]=t[e],Ae[1]=t[e+1],Ae[2]=t[e+2],Ae[3]=t[e+3],Ae[4]=t[e+4],Ae[5]=t[e+5],Ae[6]=t[e+6],Ae[7]=t[e+7],ss[0]}var u0=BigInt(Number.MAX_SAFE_INTEGER),l0=BigInt(Number.MIN_SAFE_INTEGER),Ve=class t{lo;hi;constructor(e,r){this.lo=e|0,this.hi=r|0}toNumber(e=!1){if(!e&&this.hi>>>31>0){let r=~this.lo+1>>>0,n=~this.hi>>>0;return r===0&&(n=n+1>>>0),-(r+n*4294967296)}return this.lo+this.hi*4294967296}toBigInt(e=!1){if(e)return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31){let r=~this.lo+1>>>0,n=~this.hi>>>0;return r===0&&(n=n+1>>>0),-(BigInt(r)+(BigInt(n)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toString(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,r=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return n===0?r===0?e<16384?e<128?1:2:e<2097152?3:4:r<16384?r<128?5:6:r<2097152?7:8:n<128?9:10}static fromBigInt(e){if(e===0n)return cr;if(e<u0&&e>l0)return this.fromNumber(Number(e));let r=e<0n;r&&(e=-e);let n=e>>32n,o=e-(n<<32n);return r&&(n=~n|0n,o=~o|0n,++o>Sc&&(o=0n,++n>Sc&&(n=0n))),new t(Number(o),Number(n))}static fromNumber(e){if(e===0)return cr;let r=e<0;r&&(e=-e);let n=e>>>0,o=(e-n)/4294967296>>>0;return r&&(o=~o>>>0,n=~n>>>0,++n>4294967295&&(n=0,++o>4294967295&&(o=0))),new t(n,o)}static from(e){return typeof e=="number"?t.fromNumber(e):typeof e=="bigint"?t.fromBigInt(e):typeof e=="string"?t.fromBigInt(BigInt(e)):e.low!=null||e.high!=null?new t(e.low>>>0,e.high>>>0):cr}},cr=new Ve(0,0);cr.toBigInt=function(){return 0n};cr.zzEncode=cr.zzDecode=function(){return this};cr.length=function(){return 1};var Sc=4294967296n;function Rc(t){let e=0,r=0;for(let n=0;n<t.length;++n)r=t.charCodeAt(n),r<128?e+=1:r<2048?e+=2:(r&64512)===55296&&(t.charCodeAt(n+1)&64512)===56320?(++n,e+=4):e+=3;return e}function kc(t,e,r){if(r-e<1)return"";let o,i=[],s=0,a;for(;e<r;)a=t[e++],a<128?i[s++]=a:a>191&&a<224?i[s++]=(a&31)<<6|t[e++]&63:a>239&&a<365?(a=((a&7)<<18|(t[e++]&63)<<12|(t[e++]&63)<<6|t[e++]&63)-65536,i[s++]=55296+(a>>10),i[s++]=56320+(a&1023)):i[s++]=(a&15)<<12|(t[e++]&63)<<6|t[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 as(t,e,r){let n=r,o,i;for(let s=0;s<t.length;++s)o=t.charCodeAt(s),o<128?e[r++]=o:o<2048?(e[r++]=o>>6|192,e[r++]=o&63|128):(o&64512)===55296&&((i=t.charCodeAt(s+1))&64512)===56320?(o=65536+((o&1023)<<10)+(i&1023),++s,e[r++]=o>>18|240,e[r++]=o>>12&63|128,e[r++]=o>>6&63|128,e[r++]=o&63|128):(e[r++]=o>>12|224,e[r++]=o>>6&63|128,e[r++]=o&63|128);return r-n}function Ye(t,e){return RangeError(`index out of range: ${t.pos} + ${e??1} > ${t.len}`)}function no(t,e){return(t[e-4]|t[e-3]<<8|t[e-2]<<16|t[e-1]<<24)>>>0}var cs=class{buf;pos;len;_slice=Uint8Array.prototype.subarray;constructor(e){this.buf=e,this.pos=0,this.len=e.length}uint32(){let e=4294967295;if(e=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(e=(e|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return e;if((this.pos+=5)>this.len)throw this.pos=this.len,Ye(this,10);return e}int32(){return this.uint32()|0}sint32(){let e=this.uint32();return e>>>1^-(e&1)|0}bool(){return this.uint32()!==0}fixed32(){if(this.pos+4>this.len)throw Ye(this,4);return no(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw Ye(this,4);return no(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw Ye(this,4);let e=vc(this.buf,this.pos);return this.pos+=4,e}double(){if(this.pos+8>this.len)throw Ye(this,4);let e=Ac(this.buf,this.pos);return this.pos+=8,e}bytes(){let e=this.uint32(),r=this.pos,n=this.pos+e;if(n>this.len)throw Ye(this,e);return this.pos+=e,r===n?new Uint8Array(0):this.buf.subarray(r,n)}string(){let e=this.bytes();return kc(e,0,e.length)}skip(e){if(typeof e=="number"){if(this.pos+e>this.len)throw Ye(this,e);this.pos+=e}else do if(this.pos>=this.len)throw Ye(this);while(this.buf[this.pos++]&128);return this}skipType(e){switch(e){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(e=this.uint32()&7)!==4;)this.skipType(e);break;case 5:this.skip(4);break;default:throw Error(`invalid wire type ${e} at offset ${this.pos}`)}return this}readLongVarint(){let e=new Ve(0,0),r=0;if(this.len-this.pos>4){for(;r<4;++r)if(e.lo=(e.lo|(this.buf[this.pos]&127)<<r*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;r=0}else{for(;r<3;++r){if(this.pos>=this.len)throw Ye(this);if(e.lo=(e.lo|(this.buf[this.pos]&127)<<r*7)>>>0,this.buf[this.pos++]<128)return e}return e.lo=(e.lo|(this.buf[this.pos++]&127)<<r*7)>>>0,e}if(this.len-this.pos>4){for(;r<5;++r)if(e.hi=(e.hi|(this.buf[this.pos]&127)<<r*7+3)>>>0,this.buf[this.pos++]<128)return e}else for(;r<5;++r){if(this.pos>=this.len)throw Ye(this);if(e.hi=(e.hi|(this.buf[this.pos]&127)<<r*7+3)>>>0,this.buf[this.pos++]<128)return e}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw Ye(this,8);let e=no(this.buf,this.pos+=4),r=no(this.buf,this.pos+=4);return new Ve(e,r)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){let e=xc(this.buf,this.pos);return this.pos+=fn(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 us(t){return new cs(t instanceof Uint8Array?t:t.subarray())}function Kt(t,e,r){let n=us(t);return e.decode(n,void 0,r)}function ls(t){let e=t??8192,r=e>>>1,n,o=e;return function(s){if(s<1||s>r)return nt(s);o+s>e&&(n=nt(e),o=0);let a=n.subarray(o,o+=s);return o&7&&(o=(o|7)+1),a}}var ur=class{fn;len;next;val;constructor(e,r,n){this.fn=e,this.len=r,this.next=void 0,this.val=n}};function fs(){}var ds=class{head;tail;len;next;constructor(e){this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}},f0=ls();function h0(t){return globalThis.Buffer!=null?nt(t):f0(t)}var dn=class{len;head;tail;states;constructor(){this.len=0,this.head=new ur(fs,0,0),this.tail=this.head,this.states=null}_push(e,r,n){return this.tail=this.tail.next=new ur(e,r,n),this.len+=r,this}uint32(e){return this.len+=(this.tail=this.tail.next=new ps((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(oo,10,Ve.fromNumber(e)):this.uint32(e)}sint32(e){return this.uint32((e<<1^e>>31)>>>0)}uint64(e){let r=Ve.fromBigInt(e);return this._push(oo,r.length(),r)}uint64Number(e){return this._push(bc,fn(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 r=Ve.fromBigInt(e).zzEncode();return this._push(oo,r.length(),r)}sint64Number(e){let r=Ve.fromNumber(e).zzEncode();return this._push(oo,r.length(),r)}sint64String(e){return this.sint64(BigInt(e))}bool(e){return this._push(hs,1,e?1:0)}fixed32(e){return this._push(hn,4,e>>>0)}sfixed32(e){return this.fixed32(e)}fixed64(e){let r=Ve.fromBigInt(e);return this._push(hn,4,r.lo)._push(hn,4,r.hi)}fixed64Number(e){let r=Ve.fromNumber(e);return this._push(hn,4,r.lo)._push(hn,4,r.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(Ec,4,e)}double(e){return this._push(Bc,8,e)}bytes(e){let r=e.length>>>0;return r===0?this._push(hs,1,0):this.uint32(r)._push(p0,r,e)}string(e){let r=Rc(e);return r!==0?this.uint32(r)._push(as,r,e):this._push(hs,1,0)}fork(){return this.states=new ds(this),this.head=this.tail=new ur(fs,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 ur(fs,0,0),this.len=0),this}ldelim(){let e=this.head,r=this.tail,n=this.len;return this.reset().uint32(n),n!==0&&(this.tail.next=e.next,this.tail=r,this.len+=n),this}finish(){let e=this.head.next,r=h0(this.len),n=0;for(;e!=null;)e.fn(e.val,r,n),n+=e.len,e=e.next;return r}};function hs(t,e,r){e[r]=t&255}function d0(t,e,r){for(;t>127;)e[r++]=t&127|128,t>>>=7;e[r]=t}var ps=class extends ur{next;constructor(e,r){super(d0,e,r),this.next=void 0}};function oo(t,e,r){for(;t.hi!==0;)e[r++]=t.lo&127|128,t.lo=(t.lo>>>7|t.hi<<25)>>>0,t.hi>>>=7;for(;t.lo>127;)e[r++]=t.lo&127|128,t.lo=t.lo>>>7;e[r++]=t.lo}function hn(t,e,r){e[r]=t&255,e[r+1]=t>>>8&255,e[r+2]=t>>>16&255,e[r+3]=t>>>24}function p0(t,e,r){e.set(t,r)}globalThis.Buffer!=null&&(dn.prototype.bytes=function(t){let e=t.length>>>0;return this.uint32(e),e>0&&this._push(g0,e,t),this},dn.prototype.string=function(t){let e=globalThis.Buffer.byteLength(t);return this.uint32(e),e>0&&this._push(m0,e,t),this});function g0(t,e,r){e.set(t,r)}function m0(t,e,r){t.length<40?as(t,e,r):e.utf8Write!=null?e.utf8Write(t,r):e.set(J(t),r)}function gs(){return new dn}function $t(t,e){let r=gs();return e.encode(t,r,{lengthDelimited:!1}),r.finish()}var Mr;(function(t){t[t.VARINT=0]="VARINT",t[t.BIT64=1]="BIT64",t[t.LENGTH_DELIMITED=2]="LENGTH_DELIMITED",t[t.START_GROUP=3]="START_GROUP",t[t.END_GROUP=4]="END_GROUP",t[t.BIT32=5]="BIT32"})(Mr||(Mr={}));function io(t,e,r,n){return{name:t,type:e,encode:r,decode:n}}function pn(t){function e(o){if(t[o.toString()]==null)throw new Error("Invalid enum value");return t[o]}let r=function(i,s){let a=e(i);s.int32(a)},n=function(i){let s=i.int32();return e(s)};return io("enum",Mr.VARINT,r,n)}function qt(t,e){return io("message",Mr.LENGTH_DELIMITED,t,e)}var oe;(function(t){t.RSA="RSA",t.Ed25519="Ed25519",t.Secp256k1="Secp256k1"})(oe||(oe={}));var ms;(function(t){t[t.RSA=0]="RSA",t[t.Ed25519=1]="Ed25519",t[t.Secp256k1=2]="Secp256k1"})(ms||(ms={}));(function(t){t.codec=()=>pn(ms)})(oe||(oe={}));var it;(function(t){let e;t.codec=()=>(e==null&&(e=qt((r,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),r.Type!=null&&(n.uint32(8),oe.codec().encode(r.Type,n)),r.Data!=null&&(n.uint32(18),n.bytes(r.Data)),o.lengthDelimited!==!1&&n.ldelim()},(r,n)=>{let o={},i=n==null?r.len:r.pos+n;for(;r.pos<i;){let s=r.uint32();switch(s>>>3){case 1:o.Type=oe.codec().decode(r);break;case 2:o.Data=r.bytes();break;default:r.skipType(s&7);break}}return o})),e),t.encode=r=>$t(r,t.codec()),t.decode=r=>Kt(r,t.codec())})(it||(it={}));var st;(function(t){let e;t.codec=()=>(e==null&&(e=qt((r,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),r.Type!=null&&(n.uint32(8),oe.codec().encode(r.Type,n)),r.Data!=null&&(n.uint32(18),n.bytes(r.Data)),o.lengthDelimited!==!1&&n.ldelim()},(r,n)=>{let o={},i=n==null?r.len:r.pos+n;for(;r.pos<i;){let s=r.uint32();switch(s>>>3){case 1:o.Type=oe.codec().decode(r);break;case 2:o.Data=r.bytes();break;default:r.skipType(s&7);break}}return o})),e),t.encode=r=>$t(r,t.codec()),t.decode=r=>Kt(r,t.codec())})(st||(st={}));var gn=class{_key;constructor(e){this._key=Hr(e,Fr)}verify(e,r){return hc(this._key,r,e)}marshal(){return this._key}get bytes(){return it.encode({Type:oe.Ed25519,Data:this.marshal()}).subarray()}equals(e){return be(this.bytes,e.bytes)}hash(){let e=we.digest(this.bytes);return He(e)?e.then(({bytes:r})=>r):e.bytes}},lr=class{_key;_publicKey;constructor(e,r){this._key=Hr(e,bt),this._publicKey=Hr(r,Fr)}sign(e){return fc(this._key,e)}get public(){return new gn(this._publicKey)}marshal(){return this._key}get bytes(){return st.encode({Type:oe.Ed25519,Data:this.marshal()}).subarray()}equals(e){return be(this.bytes,e.bytes)}async hash(){let e=we.digest(this.bytes),r;return He(e)?{bytes:r}=await e:r=e.bytes,r}async id(){let e=rt.digest(this.public.bytes);return ye.encode(e.bytes).substring(1)}async export(e,r="libp2p-key"){if(r==="libp2p-key")return Pr(this.bytes,e);throw new $(`export format '${r}' is not supported`,"ERR_INVALID_EXPORT_FORMAT")}};function y0(t){if(t.length>bt){t=Hr(t,bt+Fr);let n=t.subarray(0,bt),o=t.subarray(bt,t.length);return new lr(n,o)}t=Hr(t,bt);let e=t.subarray(0,bt),r=t.subarray(Fr);return new lr(e,r)}function w0(t){return t=Hr(t,Fr),new gn(t)}async function b0(){let{privateKey:t,publicKey:e}=uc();return new lr(t,e)}async function Tc(t){let{privateKey:e,publicKey:r}=lc(t);return new lr(e,r)}function Hr(t,e){if(t=Uint8Array.from(t??[]),t.length!==e)throw new $(`Key must be a Uint8Array of length ${e}, got ${t.length}`,"ERR_INVALID_KEY_TYPE");return t}function te(t,e="utf8"){let r=$n[e];if(r==null)throw new Error(`Unsupported encoding "${e}"`);return r.encoder.encode(t).substring(1)}var ks={};he(ks,{MAX_RSA_KEY_SIZE:()=>kn,RsaPrivateKey:()=>Gr,RsaPublicKey:()=>Rn,fromJwk:()=>G0,generateKeyPair:()=>j0,unmarshalRsaPrivateKey:()=>Ss,unmarshalRsaPublicKey:()=>z0});function fr(t){if(isNaN(t)||t<=0)throw new $("random bytes length must be a Number bigger than 0","ERR_INVALID_LENGTH");return Ur(t)}var Yt={};he(Yt,{exportToPem:()=>M0,importFromPem:()=>H0,jwkToPkcs1:()=>V0,jwkToPkix:()=>F0,pkcs1ToJwk:()=>L0,pkixToJwk:()=>O0});var ao=class extends Nr{constructor(e,r){super(),this.finished=!1,this.destroyed=!1,qn(e);let n=Dt(r);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 Cr(this),this.iHash.update(e),this}digestInto(e){Cr(this),Tr(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:r,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=r._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},mn=(t,e,r)=>new ao(t,e).update(r).digest();mn.create=(t,e)=>new ao(t,e);function x0(t,e,r,n){qn(t);let o=za({dkLen:32,asyncTick:10},n),{c:i,dkLen:s,asyncTick:a}=o;if(Ir(i),Ir(s),Ir(a),i<1)throw new Error("PBKDF2: iterations (c) should be >= 1");let c=Dt(e),f=Dt(r),u=new Uint8Array(s),l=mn.create(t,c),d=l._cloneInto().update(f);return{c:i,dkLen:s,asyncTick:a,DK:u,PRF:l,PRFSalt:d}}function E0(t,e,r,n,o){return t.destroy(),e.destroy(),n&&n.destroy(),o.fill(0),r}async function ws(t,e,r,n){let{c:o,dkLen:i,asyncTick:s,DK:a,PRF:c,PRFSalt:f}=x0(t,e,r,n),u,l=new Uint8Array(4),d=_r(l),v=new Uint8Array(c.outputLen);for(let m=1,h=0;h<i;m++,h+=c.outputLen){let p=a.subarray(h,h+c.outputLen);d.setInt32(0,m,!1),(u=f._cloneInto(u)).update(l).digestInto(v),p.set(v.subarray(0,p.length)),await qa(o-1,s,()=>{c._cloneInto(u).update(v).digestInto(v);for(let b=0;b<p.length;b++)p[b]^=v[b]})}return E0(c,f,a,u,v)}var j=ht(Cc());function hr(t,e){let r=0;if(t.length===1)return t[0];for(let n=t.length-1;n>=0;n--)r+=t[t.length-1-n]*Math.pow(2,e*n);return r}function zt(t,e,r=-1){let n=r,o=t,i=0,s=Math.pow(2,e);for(let a=1;a<8;a++){if(t<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 lo(...t){let e=0,r=0;for(let i of t)e+=i.length;let n=new ArrayBuffer(e),o=new Uint8Array(n);for(let i of t)o.set(i,r),r+=i.length;return o}function xs(){let t=new Uint8Array(this.valueHex);if(this.valueHex.byteLength>=2){let a=t[0]===255&&t[1]&128,c=t[0]===0&&(t[1]&128)===0;(a||c)&&this.warnings.push("Needlessly long format")}let e=new ArrayBuffer(this.valueHex.byteLength),r=new Uint8Array(e);for(let a=0;a<this.valueHex.byteLength;a++)r[a]=0;r[0]=t[0]&128;let n=hr(r,8),o=new ArrayBuffer(this.valueHex.byteLength),i=new Uint8Array(o);for(let a=0;a<this.valueHex.byteLength;a++)i[a]=t[a];return i[0]&=127,hr(i,8)-n}function Nc(t){let e=t<0?t*-1:t,r=128;for(let n=1;n<8;n++){if(e<=r){if(t<0){let s=r-e,a=zt(s,8,n),c=new Uint8Array(a);return c[0]|=128,a}let o=zt(e,8,n),i=new Uint8Array(o);if(i[0]&128){let s=o.slice(0),a=new Uint8Array(s);o=new ArrayBuffer(o.byteLength+1),i=new Uint8Array(o);for(let c=0;c<s.byteLength;c++)i[c+1]=a[c];i[0]=0}return o}r*=Math.pow(2,8)}return new ArrayBuffer(0)}function _c(t,e){if(t.byteLength!==e.byteLength)return!1;let r=new Uint8Array(t),n=new Uint8Array(e);for(let o=0;o<r.length;o++)if(r[o]!==n[o])return!1;return!0}function Ne(t,e){let r=t.toString(10);if(e<r.length)return"";let n=e-r.length,o=new Array(n);for(let s=0;s<n;s++)o[s]="0";return o.join("").concat(r)}var gw=Math.log(2);function fo(){if(typeof BigInt>"u")throw new Error("BigInt is not defined. Your environment doesn't implement BigInt.")}function Es(t){let e=0,r=0;for(let o=0;o<t.length;o++){let i=t[o];e+=i.byteLength}let n=new Uint8Array(e);for(let o=0;o<t.length;o++){let i=t[o];n.set(new Uint8Array(i),r),r+=i.byteLength}return n.buffer}function At(t,e,r,n){return e instanceof Uint8Array?e.byteLength?r<0?(t.error="Wrong parameter: inputOffset less than zero",!1):n<0?(t.error="Wrong parameter: inputLength less than zero",!1):e.byteLength-r-n<0?(t.error="End of input reached before message was fully decoded (inconsistent offset and length values)",!1):!0:(t.error="Wrong parameter: inputBuffer has zero length",!1):(t.error="Wrong parameter: inputBuffer must be 'Uint8Array'",!1)}var wn=class{constructor(){this.items=[]}write(e){this.items.push(e)}final(){return Es(this.items)}},yn=[new Uint8Array([1])],Uc="0123456789";var qr="",We=new ArrayBuffer(0),vs=new Uint8Array(0),bn="EndOfContent",Lc="OCTET STRING",Vc="BIT STRING";function St(t){var e;return e=class extends t{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):vs}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(!At(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",We)}toJSON(){return{...super.toJSON(),isHexOnly:this.isHexOnly,valueHex:j.Convert.ToHex(this.valueHexView)}}},e.NAME="hexBlock",e}var Et=class{constructor({blockLength:e=0,error:r=qr,warnings:n=[],valueBeforeDecode:o=vs}={}){this.blockLength=e,this.error=r,this.warnings=n,this.valueBeforeDecodeView=j.BufferSourceConverter.toUint8Array(o)}static blockName(){return this.NAME}get valueBeforeDecode(){return this.valueBeforeDecodeView.slice().buffer}set valueBeforeDecode(e){this.valueBeforeDecodeView=new Uint8Array(e)}toJSON(){return{blockName:this.constructor.NAME,blockLength:this.blockLength,error:this.error,warnings:this.warnings,valueBeforeDecode:j.Convert.ToHex(this.valueBeforeDecodeView)}}};Et.NAME="baseBlock";var Se=class extends Et{fromBER(e,r,n){throw TypeError("User need to make a specific function in a class which extends 'ValueBlock'")}toBER(e,r){throw TypeError("User need to make a specific function in a class which extends 'ValueBlock'")}};Se.NAME="valueBlock";var ho=class extends St(Et){constructor({idBlock:e={}}={}){var r,n,o,i;super(),e?(this.isHexOnly=(r=e.isHexOnly)!==null&&r!==void 0?r:!1,this.valueHexView=e.valueHex?j.BufferSourceConverter.toUint8Array(e.valueHex):vs,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 r=0;switch(this.tagClass){case 1:r|=0;break;case 2:r|=64;break;case 3:r|=128;break;case 4:r|=192;break;default:return this.error="Unknown tag class",We}if(this.isConstructed&&(r|=32),this.tagNumber<31&&!this.isHexOnly){let o=new Uint8Array(1);if(!e){let i=this.tagNumber;i&=31,r|=i,o[0]=r}return o.buffer}if(!this.isHexOnly){let o=zt(this.tagNumber,7),i=new Uint8Array(o),s=o.byteLength,a=new Uint8Array(s+1);if(a[0]=r|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]=r|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,r,n){let o=j.BufferSourceConverter.toUint8Array(e);if(!At(this,o,r,n))return-1;let i=o.subarray(r,r+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 v=0;v<f.length;v++)d[v]=f[v];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=hr(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 r+this.blockLength}toJSON(){return{...super.toJSON(),tagClass:this.tagClass,tagNumber:this.tagNumber,isConstructed:this.isConstructed}}};ho.NAME="identificationBlock";var po=class extends Et{constructor({lenBlock:e={}}={}){var r,n,o;super(),this.isIndefiniteForm=(r=e.isIndefiniteForm)!==null&&r!==void 0?r:!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,r,n){let o=j.BufferSourceConverter.toUint8Array(e);if(!At(this,o,r,n))return-1;let i=o.subarray(r,r+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,r+this.blockLength;if(this.longFormUsed=!!(i[0]&128),this.longFormUsed===!1)return this.length=i[0],this.blockLength=1,r+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=r+1,c=o.subarray(a,a+s);return c[s-1]===0&&this.warnings.push("Needlessly long encoded length"),this.length=hr(c,8),this.longFormUsed&&this.length<=127&&this.warnings.push("Unnecessary usage of long length form"),this.blockLength=s+1,r+this.blockLength}toBER(e=!1){let r,n;if(this.length>127&&(this.longFormUsed=!0),this.isIndefiniteForm)return r=new ArrayBuffer(1),e===!1&&(n=new Uint8Array(r),n[0]=128),r;if(this.longFormUsed){let o=zt(this.length,8);if(o.byteLength>127)return this.error="Too big length",We;if(r=new ArrayBuffer(o.byteLength+1),e)return r;let i=new Uint8Array(o);n=new Uint8Array(r),n[0]=o.byteLength|128;for(let s=0;s<o.byteLength;s++)n[s+1]=i[s];return r}return r=new ArrayBuffer(1),e===!1&&(n=new Uint8Array(r),n[0]=this.length),r}toJSON(){return{...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,longFormUsed:this.longFormUsed,length:this.length}}};po.NAME="lengthBlock";var _={},xe=class extends Et{constructor({name:e=qr,optional:r=!1,primitiveSchema:n,...o}={},i){super(o),this.name=e,this.optional=r,n&&(this.primitiveSchema=n),this.idBlock=new ho(o),this.lenBlock=new po(o),this.valueBlock=i?new i(o):new Se(o)}fromBER(e,r,n){let o=this.valueBlock.fromBER(e,r,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,r){let n=r||new wn;r||Oc(this);let o=this.idBlock.toBER(e);if(n.write(o),this.lenBlock.isIndefiniteForm)n.write(new Uint8Array([128]).buffer),this.valueBlock.toBER(e,n),n.write(new ArrayBuffer(2));else{let i=this.valueBlock.toBER(e);this.lenBlock.length=i.byteLength;let s=this.lenBlock.toBER(e);n.write(s),n.write(i)}return r?We: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 r=this.toBER(),n=e.toBER();return _c(r,n)}};xe.NAME="BaseBlock";function Oc(t){if(t instanceof _.Constructed)for(let e of t.valueBlock.value)Oc(e)&&(t.lenBlock.isIndefiniteForm=!0);return!!t.lenBlock.isIndefiniteForm}var go=class extends xe{constructor({value:e=qr,...r}={},n){super(r,n),e&&this.fromString(e)}getValue(){return this.valueBlock.value}setValue(e){this.valueBlock.value=e}fromBER(e,r,n){let o=this.valueBlock.fromBER(e,r,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}'`}};go.NAME="BaseStringBlock";var mo=class extends St(Se){constructor({isHexOnly:e=!0,...r}={}){super(r),this.isHexOnly=e}};mo.NAME="PrimitiveValueBlock";var Fc,yo=class extends xe{constructor(e={}){super(e,mo),this.idBlock.isConstructed=!1}};Fc=yo;_.Primitive=Fc;yo.NAME="PRIMITIVE";function C0(t,e){if(t instanceof e)return t;let r=new e;return r.idBlock=t.idBlock,r.lenBlock=t.lenBlock,r.warnings=t.warnings,r.valueBeforeDecodeView=t.valueBeforeDecodeView,r}function Wo(t,e=0,r=t.length){let n=e,o=new xe({},Se),i=new Et;if(!At(i,t,e,r))return o.error=i.error,{offset:-1,result:o};if(!t.subarray(e,e+r).length)return o.error="Zero buffer length",{offset:-1,result:o};let a=o.idBlock.fromBER(t,e,r);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,r-=o.idBlock.blockLength,a=o.lenBlock.fromBER(t,e,r),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,r-=o.lenBlock.blockLength,!o.idBlock.isConstructed&&o.lenBlock.isIndefiniteForm)return o.error="Indefinite length form used for primitive encoding form",{offset:-1,result:o};let c=xe;switch(o.idBlock.tagClass){case 1:if(o.idBlock.tagNumber>=37&&o.idBlock.isHexOnly===!1)return o.error="UNIVERSAL 37 and upper tags are reserved by ASN.1 standard",{offset:-1,result:o};switch(o.idBlock.tagNumber){case 0:if(o.idBlock.isConstructed&&o.lenBlock.length>0)return o.error="Type [UNIVERSAL 0] is reserved",{offset:-1,result:o};c=_.EndOfContent;break;case 1:c=_.Boolean;break;case 2:c=_.Integer;break;case 3:c=_.BitString;break;case 4:c=_.OctetString;break;case 5:c=_.Null;break;case 6:c=_.ObjectIdentifier;break;case 10:c=_.Enumerated;break;case 12:c=_.Utf8String;break;case 13:c=_.RelativeObjectIdentifier;break;case 14:c=_.TIME;break;case 15:return o.error="[UNIVERSAL 15] is reserved by ASN.1 standard",{offset:-1,result:o};case 16:c=_.Sequence;break;case 17:c=_.Set;break;case 18:c=_.NumericString;break;case 19:c=_.PrintableString;break;case 20:c=_.TeletexString;break;case 21:c=_.VideotexString;break;case 22:c=_.IA5String;break;case 23:c=_.UTCTime;break;case 24:c=_.GeneralizedTime;break;case 25:c=_.GraphicString;break;case 26:c=_.VisibleString;break;case 27:c=_.GeneralString;break;case 28:c=_.UniversalString;break;case 29:c=_.CharacterString;break;case 30:c=_.BmpString;break;case 31:c=_.DATE;break;case 32:c=_.TimeOfDay;break;case 33:c=_.DateTime;break;case 34:c=_.Duration;break;default:{let f=o.idBlock.isConstructed?new _.Constructed:new _.Primitive;f.idBlock=o.idBlock,f.lenBlock=o.lenBlock,f.warnings=o.warnings,o=f}}break;case 2:case 3:case 4:default:c=o.idBlock.isConstructed?_.Constructed:_.Primitive}return o=C0(o,c),a=o.fromBER(t,e,o.lenBlock.isIndefiniteForm?r:o.lenBlock.length),o.valueBeforeDecodeView=t.subarray(n,n+o.blockLength),{offset:a,result:o}}function zr(t){if(!t.byteLength){let e=new xe({},Se);return e.error="Input buffer has zero length",{offset:-1,result:e}}return Wo(j.BufferSourceConverter.toUint8Array(t).slice(),0,t.byteLength)}function N0(t,e){return t?1:e}var at=class extends Se{constructor({value:e=[],isIndefiniteForm:r=!1,...n}={}){super(n),this.value=e,this.isIndefiniteForm=r}fromBER(e,r,n){let o=j.BufferSourceConverter.toUint8Array(e);if(!At(this,o,r,n))return-1;if(this.valueBeforeDecodeView=o.subarray(r,r+n),this.valueBeforeDecodeView.length===0)return this.warnings.push("Zero buffer length"),r;let i=r;for(;N0(this.isIndefiniteForm,n)>0;){let s=Wo(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,r){let n=r||new wn;for(let o=0;o<this.value.length;o++)this.value[o].toBER(e,n);return r?We:n.final()}toJSON(){let e={...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,value:[]};for(let r of this.value)e.value.push(r.toJSON());return e}};at.NAME="ConstructedValueBlock";var Pc,Gt=class extends xe{constructor(e={}){super(e,at),this.idBlock.isConstructed=!0}fromBER(e,r,n){this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm;let o=this.valueBlock.fromBER(e,r,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
|
-
`));let
|
|
5
|
+
`));let r=this.idBlock.tagClass===3?`[${this.idBlock.tagNumber}]`:this.constructor.NAME;return e.length?`${r} :
|
|
6
6
|
${e.join(`
|
|
7
|
-
`)}`:`${t} :`}};_h=yr;_.Constructed=_h;yr.NAME="CONSTRUCTED";var Gs=class extends Pe{fromBER(e,t,n){return t}toBER(e){return yt}};Gs.override="EndOfContentValueBlock";var Dh,Ws=class extends ke{constructor(e={}){super(e,Gs),this.idBlock.tagClass=1,this.idBlock.tagNumber=0}};Dh=Ws;_.EndOfContent=Dh;Ws.NAME=Eo;var Lh,wr=class extends ke{constructor(e={}){super(e,Pe),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}`}};Lh=wr;_.Null=Lh;wr.NAME="NULL";var Ys=class extends jt(Pe){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 qt(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,Sc.call(this),this.blockLength=n,t+n):-1}toBER(){return this.valueHexView.slice()}toJSON(){return{...super.toJSON(),value:this.value}}};Ys.NAME="BooleanValueBlock";var Oh,Zs=class extends ke{constructor(e={}){super(e,Ys),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}`}};Oh=Zs;_.Boolean=Oh;Zs.NAME="BOOLEAN";var Js=class extends jt(It){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=It.prototype.fromBER.call(this,e,t,n),o===-1)return o;for(let s=0;s<this.value.length;s++){let i=this.value[s].constructor.NAME;if(i===Eo){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, OCTET STRING may consists of OCTET STRINGs only",-1}if(i!==kh)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?It.prototype.toBER.call(this,e,t):e?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),isConstructed:this.isConstructed}}};Js.NAME="OctetStringValueBlock";var Vh,Kt=class r extends ke{constructor({idBlock:e={},lenBlock:t={},...n}={}){var o,s;(o=n.isConstructed)!==null&&o!==void 0||(n.isConstructed=!!(!((s=n.value)===null||s===void 0)&&s.length)),super({idBlock:{isConstructed:n.isConstructed,...e},lenBlock:{...t,isIndefiniteForm:!!n.isIndefiniteForm},...n},Js),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 s=(e instanceof ArrayBuffer?new Uint8Array(e):e).subarray(t,t+n);try{if(s.byteLength){let i=Si(s,0,s.byteLength);i.offset!==-1&&i.offset===n&&(this.valueBlock.value=[i.result])}}catch{}}return super.fromBER(e,t,n)}onAsciiEncoding(){return this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length?yr.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)}};Vh=Kt;_.OctetString=Vh;Kt.NAME=kh;var Xs=class extends jt(It){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=It.prototype.fromBER.call(this,e,t,n),o===-1)return o;for(let a of this.value){let c=a.constructor.NAME;if(c===Eo){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, BIT STRING may consists of BIT STRINGs only",-1}if(c!==Rh)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 s=Z.BufferSourceConverter.toUint8Array(e);if(!qt(this,s,t,n))return-1;let i=s.subarray(t,t+n);if(this.unusedBits=i[0],this.unusedBits>7)return this.error="Unused bits for BitString must be in range 0-7",-1;if(!this.unusedBits){let a=i.subarray(1);try{if(a.byteLength){let c=Si(a,0,a.byteLength);c.offset!==-1&&c.offset===n-1&&(this.value=[c.result])}}catch{}}return this.valueHexView=i.subarray(1),this.blockLength=i.length,t+n}toBER(e,t){if(this.isConstructed)return It.prototype.toBER.call(this,e,t);if(e)return new ArrayBuffer(this.valueHexView.byteLength+1);if(!this.valueHexView.byteLength)return yt;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}}};Xs.NAME="BitStringValueBlock";var Ph,kn=class extends ke{constructor({idBlock:e={},lenBlock:t={},...n}={}){var o,s;(o=n.isConstructed)!==null&&o!==void 0||(n.isConstructed=!!(!((s=n.value)===null||s===void 0)&&s.length)),super({idBlock:{isConstructed:n.isConstructed,...e},lenBlock:{...t,isIndefiniteForm:!!n.isIndefiniteForm},...n},Xs),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 yr.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)}`}}};Ph=kn;_.BitString=Ph;kn.NAME=Rh;var Mh;function Wb(r,e){let t=new Uint8Array([0]),n=new Uint8Array(r),o=new Uint8Array(e),s=n.slice(0),i=s.length-1,a=o.slice(0),c=a.length-1,f=0,u=c<i?i:c,l=0;for(let p=u;p>=0;p--,l++){switch(!0){case l<a.length:f=s[i-l]+a[c-l]+t[0];break;default:f=s[i-l]+t[0]}switch(t[0]=f/10,!0){case l>=s.length:s=Fs(new Uint8Array([f%10]),s);break;default:s[i-l]=f%10}}return t[0]>0&&(s=Fs(t,s)),s}function Th(r){if(r>=xo.length)for(let e=xo.length;e<=r;e++){let t=new Uint8Array([0]),n=xo[e-1].slice(0);for(let o=n.length-1;o>=0;o--){let s=new Uint8Array([(n[o]<<1)+t[0]]);t[0]=s[0]/10,n[o]=s[0]%10}t[0]>0&&(n=Fs(t,n)),xo.push(n)}return xo[r]}function Yb(r,e){let t=0,n=new Uint8Array(r),o=new Uint8Array(e),s=n.slice(0),i=s.length-1,a=o.slice(0),c=a.length-1,f,u=0;for(let l=c;l>=0;l--,u++)switch(f=s[i-u]-a[c-u]-t,!0){case f<0:t=1,s[i-u]=f+10;break;default:t=0,s[i-u]=f}if(t>0)for(let l=i-c+1;l>=0;l--,u++)if(f=s[i-u]-t,f<0)t=1,s[i-u]=f+10;else{t=0,s[i-u]=f;break}return s.slice()}var Ao=class extends jt(Pe){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=Sc.call(this)))}set valueDec(e){this._valueDec=e,this.isHexOnly=!1,this.valueHexView=new Uint8Array(Sh(e))}get valueDec(){return this._valueDec}fromDER(e,t,n,o=0){let s=this.fromBER(e,t,n);if(s===-1)return s;let i=this.valueHexView;return i[0]===0&&i[1]&128?this.valueHexView=i.subarray(1):o!==0&&i.length<o&&(o-i.length>1&&(o=i.length+1),this.valueHexView=i.subarray(o-i.length)),s}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,s=this.valueHexView,i="",a=!1;for(let c=s.byteLength-1;c>=0;c--){o=s[c];for(let f=0;f<8;f++){if((o&1)===1)switch(n){case e:t=Yb(Th(n),t),i="-";break;default:t=Wb(t,Th(n))}n++,o>>=1}}for(let c=0;c<t.length;c++)t[c]&&(a=!0),a&&(i+=Ch.charAt(t[c]));return a===!1&&(i+=Ch.charAt(0)),i}};Mh=Ao;Ao.NAME="IntegerValueBlock";Object.defineProperty(Mh.prototype,"valueHex",{set:function(r){this.valueHexView=new Uint8Array(r),this.setValueHex()},get:function(){return this.valueHexView.slice().buffer}});var Fh,we=class r extends ke{constructor(e={}){super(e,Ao),this.idBlock.tagClass=1,this.idBlock.tagNumber=2}toBigInt(){return $s(),BigInt(this.valueBlock.toString())}static fromBigInt(e){$s();let t=BigInt(e),n=new vo,o=t.toString(16).replace(/^-/,""),s=new Uint8Array(Z.Convert.FromHex(o));if(t<0){let a=new Uint8Array(s.length+(s[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 s[0]&128&&n.write(new Uint8Array([0])),n.write(s);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()}`}};Fh=we;_.Integer=Fh;we.NAME="INTEGER";var $h,Qs=class extends we{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=10}};$h=Qs;_.Enumerated=$h;Qs.NAME="ENUMERATED";var Bo=class extends jt(Pe){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(!qt(this,o,t,n))return-1;let s=o.subarray(t,t+n);this.valueHexView=new Uint8Array(n);for(let a=0;a<n&&(this.valueHexView[a]=s[a]&127,this.blockLength++,!!(s[a]&128));a++);let i=new Uint8Array(this.blockLength);for(let a=0;a<this.blockLength;a++)i[a]=this.valueHexView[a];return this.valueHexView=i,s[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=qr(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),t+this.blockLength)}set valueBigInt(e){$s();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,s=new Uint8Array(this.blockLength);for(let i=0;i<this.blockLength-1;i++)s[i]=o[i]|128;return s[this.blockLength-1]=o[this.blockLength-1],s.buffer}let t=gr(this.valueDec,7);if(t.byteLength===0)return this.error="Error during encoding SID value",yt;let n=new Uint8Array(t.byteLength);if(!e){let o=new Uint8Array(t),s=t.byteLength-1;for(let i=0;i<s;i++)n[i]=o[i]|128;n[s]=o[s]}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}}};Bo.NAME="sidBlock";var ei=class extends Pe{constructor({value:e=Rn,...t}={}){super(t),this.value=[],e&&this.fromString(e)}fromBER(e,t,n){let o=t;for(;n>0;){let s=new Bo;if(o=s.fromBER(e,o,n),o===-1)return this.blockLength=0,this.error=s.error,o;this.value.length===0&&(s.isFirstSid=!0),this.blockLength+=s.blockLength,n-=s.blockLength,this.value.push(s)}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,yt;t.push(o)}return Ic(t)}fromString(e){this.value=[];let t=0,n=0,o="",s=!1;do if(n=e.indexOf(".",t),n===-1?o=e.substring(t):o=e.substring(t,n),t=n+1,s){let i=this.value[0],a=0;switch(i.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;i.valueDec=c+a,s=!1}else{let i=new Bo;if(o>Number.MAX_SAFE_INTEGER){$s();let a=BigInt(o);i.valueBigInt=a}else if(i.valueDec=parseInt(o,10),isNaN(i.valueDec))return;this.value.length||(i.isFirstSid=!0,s=!0),this.value.push(i)}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}};ei.NAME="ObjectIdentifierValueBlock";var Hh,gt=class extends ke{constructor(e={}){super(e,ei),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()}}};Hh=gt;_.ObjectIdentifier=Hh;gt.NAME="OBJECT IDENTIFIER";var So=class extends jt(Ht){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(!qt(this,o,t,n))return-1;let s=o.subarray(t,t+n);this.valueHexView=new Uint8Array(n);for(let a=0;a<n&&(this.valueHexView[a]=s[a]&127,this.blockLength++,!!(s[a]&128));a++);let i=new Uint8Array(this.blockLength);for(let a=0;a<this.blockLength;a++)i[a]=this.valueHexView[a];return this.valueHexView=i,s[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=qr(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,s=new Uint8Array(this.blockLength);for(let i=0;i<this.blockLength-1;i++)s[i]=o[i]|128;return s[this.blockLength-1]=o[this.blockLength-1],s.buffer}let t=gr(this.valueDec,7);if(t.byteLength===0)return this.error="Error during encoding SID value",yt;let n=new Uint8Array(t.byteLength);if(!e){let o=new Uint8Array(t),s=t.byteLength-1;for(let i=0;i<s;i++)n[i]=o[i]|128;n[s]=o[s]}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}}};So.NAME="relativeSidBlock";var ti=class extends Pe{constructor({value:e=Rn,...t}={}){super(t),this.value=[],e&&this.fromString(e)}fromBER(e,t,n){let o=t;for(;n>0;){let s=new So;if(o=s.fromBER(e,o,n),o===-1)return this.blockLength=0,this.error=s.error,o;this.blockLength+=s.blockLength,n-=s.blockLength,this.value.push(s)}return o}toBER(e,t){let n=[];for(let o=0;o<this.value.length;o++){let s=this.value[o].toBER(e);if(s.byteLength===0)return this.error=this.value[o].error,yt;n.push(s)}return Ic(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 s=new So;if(s.valueDec=parseInt(o,10),isNaN(s.valueDec))return!0;this.value.push(s)}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}};ti.NAME="RelativeObjectIdentifierValueBlock";var Kh,ri=class extends ke{constructor(e={}){super(e,ti),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()}}};Kh=ri;_.RelativeObjectIdentifier=Kh;ri.NAME="RelativeObjectIdentifier";var zh,ve=class extends yr{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=16}};zh=ve;_.Sequence=zh;ve.NAME="SEQUENCE";var qh,ni=class extends yr{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=17}};qh=ni;_.Set=qh;ni.NAME="SET";var oi=class extends jt(Pe){constructor({...e}={}){super(e),this.isHexOnly=!0,this.value=Rn}toJSON(){return{...super.toJSON(),value:this.value}}};oi.NAME="StringValueBlock";var si=class extends oi{};si.NAME="SimpleStringValueBlock";var $e=class extends zs{constructor({...e}={}){super(e,si)}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}};$e.NAME="SIMPLE STRING";var ii=class extends $e{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}};ii.NAME="Utf8StringValueBlock";var jh,zt=class extends ii{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=12}};jh=zt;_.Utf8String=jh;zt.NAME="UTF8String";var ai=class extends $e{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))}};ai.NAME="BmpStringValueBlock";var Gh,ci=class extends ai{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=30}};Gh=ci;_.BmpString=Gh;ci.NAME="BMPString";var ui=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 s=gr(e.charCodeAt(o),8),i=new Uint8Array(s);if(i.length>4)continue;let a=4-i.length;for(let c=i.length-1;c>=0;c--)n[o*4+c+a]=i[c]}this.valueBlock.value=e}};ui.NAME="UniversalStringValueBlock";var Wh,li=class extends ui{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=28}};Wh=li;_.UniversalString=Wh;li.NAME="UniversalString";var Yh,fi=class extends $e{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=18}};Yh=fi;_.NumericString=Yh;fi.NAME="NumericString";var Zh,hi=class extends $e{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=19}};Zh=hi;_.PrintableString=Zh;hi.NAME="PrintableString";var Jh,di=class extends $e{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=20}};Jh=di;_.TeletexString=Jh;di.NAME="TeletexString";var Xh,pi=class extends $e{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=21}};Xh=pi;_.VideotexString=Xh;pi.NAME="VideotexString";var Qh,mi=class extends $e{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=22}};Qh=mi;_.IA5String=Qh;mi.NAME="IA5String";var ed,gi=class extends $e{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=25}};ed=gi;_.GraphicString=ed;gi.NAME="GraphicString";var td,Io=class extends $e{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=26}};td=Io;_.VisibleString=td;Io.NAME="VisibleString";var rd,yi=class extends $e{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=27}};rd=yi;_.GeneralString=rd;yi.NAME="GeneralString";var nd,wi=class extends $e{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=29}};nd=wi;_.CharacterString=nd;wi.NAME="CharacterString";var od,Co=class extends Io{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]=je(this.year<2e3?this.year-1900:this.year-2e3,2),t[1]=je(this.month,2),t[2]=je(this.day,2),t[3]=je(this.hour,2),t[4]=je(this.minute,2),t[5]=je(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}}};od=Co;_.UTCTime=od;Co.NAME="UTCTime";var sd,bi=class extends Co{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="",s=0,i,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,p=n.indexOf("+"),x="";if(p===-1&&(p=n.indexOf("-"),l=-1),p!==-1){if(x=n.substring(p+1),n=n.substring(0,p),x.length!==2&&x.length!==4)throw new Error("Wrong input string for conversion");let d=parseInt(x.substring(0,2),10);if(isNaN(d.valueOf()))throw new Error("Wrong input string for conversion");if(a=l*d,x.length===4){if(d=parseInt(x.substring(2,4),10),isNaN(d.valueOf()))throw new Error("Wrong input string for conversion");c=l*d}}}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");s=l.valueOf(),o=n.substring(0,f)}else o=n;switch(!0){case o.length===8:if(i=/(\d{4})(\d{2})(\d{2})/ig,f!==-1)throw new Error("Wrong input string for conversion");break;case o.length===10:if(i=/(\d{4})(\d{2})(\d{2})(\d{2})/ig,f!==-1){let l=60*s;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(i=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})/ig,f!==-1){let l=60*s;this.second=Math.floor(l),l=1e3*(l-this.second),this.millisecond=Math.floor(l)}break;case o.length===14:if(i=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/ig,f!==-1){let l=1e3*s;this.millisecond=Math.floor(l)}break;default:throw new Error("Wrong input string for conversion")}let u=i.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(je(this.year,4)),t.push(je(this.month,2)),t.push(je(this.day,2)),t.push(je(this.hour,2)),t.push(je(this.minute,2)),t.push(je(this.second,2)),this.millisecond!==0&&(t.push("."),t.push(je(this.millisecond,3))),t.push("Z"),t.join("")}return super.toString(e)}toJSON(){return{...super.toJSON(),millisecond:this.millisecond}}};sd=bi;_.GeneralizedTime=sd;bi.NAME="GeneralizedTime";var id,xi=class extends zt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=31}};id=xi;_.DATE=id;xi.NAME="DATE";var ad,vi=class extends zt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=32}};ad=vi;_.TimeOfDay=ad;vi.NAME="TimeOfDay";var cd,Ei=class extends zt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=33}};cd=Ei;_.DateTime=cd;Ei.NAME="DateTime";var ud,Ai=class extends zt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=34}};ud=Ai;_.Duration=ud;Ai.NAME="Duration";var ld,Bi=class extends zt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=14}};ld=Bi;_.TIME=ld;Bi.NAME="TIME";function Jb(r){let{result:e}=Nn(r),t=e.valueBlock.value;return{n:ue(Ct(t[1].toBigInt()),"base64url"),e:ue(Ct(t[2].toBigInt()),"base64url"),d:ue(Ct(t[3].toBigInt()),"base64url"),p:ue(Ct(t[4].toBigInt()),"base64url"),q:ue(Ct(t[5].toBigInt()),"base64url"),dp:ue(Ct(t[6].toBigInt()),"base64url"),dq:ue(Ct(t[7].toBigInt()),"base64url"),qi:ue(Ct(t[8].toBigInt()),"base64url"),kty:"RSA",alg:"RS256"}}function Xb(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 K("JWK was missing components","ERR_INVALID_PARAMETERS");let t=new ve({value:[new we({value:0}),we.fromBigInt(Tt(ee(r.n,"base64url"))),we.fromBigInt(Tt(ee(r.e,"base64url"))),we.fromBigInt(Tt(ee(r.d,"base64url"))),we.fromBigInt(Tt(ee(r.p,"base64url"))),we.fromBigInt(Tt(ee(r.q,"base64url"))),we.fromBigInt(Tt(ee(r.dp,"base64url"))),we.fromBigInt(Tt(ee(r.dq,"base64url"))),we.fromBigInt(Tt(ee(r.qi,"base64url")))]}).toBER();return new Uint8Array(t,0,t.byteLength)}function Qb(r){let{result:e}=Nn(r),t=e.valueBlock.value[1].valueBlock.value[0].valueBlock.value;return{kty:"RSA",n:ue(Ct(t[0].toBigInt()),"base64url"),e:ue(Ct(t[1].toBigInt()),"base64url")}}function ex(r){if(r.n==null||r.e==null)throw new K("JWK was missing components","ERR_INVALID_PARAMETERS");let t=new ve({value:[new ve({value:[new gt({value:"1.2.840.113549.1.1.1"}),new wr]}),new kn({valueHex:new ve({value:[we.fromBigInt(Tt(ee(r.n,"base64url"))),we.fromBigInt(Tt(ee(r.e,"base64url")))]}).toBER()})]}).toBER();return new Uint8Array(t,0,t.byteLength)}function Ct(r){let e=r.toString(16);e.length%2>0&&(e=`0${e}`);let t=e.length/2,n=new Uint8Array(t),o=0,s=0;for(;o<t;)n[o]=parseInt(e.slice(s,s+2),16),o+=1,s+=2;return n}function Tt(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 tx=16,Tc=32,kc=1e4;async function rx(r,e){let t=Fe.get(),o=new ve({value:[new we({value:0}),new ve({value:[new gt({value:"1.2.840.113549.1.1.1"}),new wr]}),new Kt({valueHex:r.marshal()})]}).toBER(),s=new Uint8Array(o,0,o.byteLength),i=zr(tx),a=await Ac(vn,e,i,{c:kc,dkLen:Tc}),c=zr(16),f=await t.subtle.importKey("raw",a,"AES-CBC",!1,["encrypt"]),u=await t.subtle.encrypt({name:"AES-CBC",iv:c},f,s),l=new ve({value:[new Kt({valueHex:i}),new we({value:kc}),new we({value:Tc}),new ve({value:[new gt({value:"1.2.840.113549.2.11"}),new wr]})]}),p=new ve({value:[new gt({value:"1.2.840.113549.1.5.13"}),new ve({value:[new ve({value:[new gt({value:"1.2.840.113549.1.5.12"}),l]}),new ve({value:[new gt({value:"2.16.840.1.101.3.4.1.42"}),new Kt({valueHex:c})]})]})]}),d=new ve({value:[p,new Kt({valueHex:u})]}).toBER(),h=new Uint8Array(d,0,d.byteLength);return["-----BEGIN ENCRYPTED PRIVATE KEY-----",...ue(h,"base64pad").split(/(.{64})/).filter(Boolean),"-----END ENCRYPTED PRIVATE KEY-----"].join(`
|
|
8
|
-
`)}async function nx(r,e){let t=Fe.get(),n;if(r.includes("-----BEGIN ENCRYPTED PRIVATE KEY-----")){let o=ee(r.replace("-----BEGIN ENCRYPTED PRIVATE KEY-----","").replace("-----END ENCRYPTED PRIVATE KEY-----","").replace(/\n/g,"").trim(),"base64pad"),{result:s}=Nn(o),{iv:i,salt:a,iterations:c,keySize:f,cipherText:u}=ox(s),l=await Ac(vn,e,a,{c,dkLen:f}),p=await t.subtle.importKey("raw",l,"AES-CBC",!1,["decrypt"]),x=To(await t.subtle.decrypt({name:"AES-CBC",iv:i},p,u)),{result:d}=Nn(x);n=fd(d)}else if(r.includes("-----BEGIN PRIVATE KEY-----")){let o=ee(r.replace("-----BEGIN PRIVATE KEY-----","").replace("-----END PRIVATE KEY-----","").replace(/\n/g,"").trim(),"base64pad"),{result:s}=Nn(o);n=fd(s)}else throw new K("Could not parse private key from PEM data","ERR_INVALID_PARAMETERS");return Rc(n)}function ox(r){let e=r.valueBlock.value[0];if(e.valueBlock.value[0].toString()!=="OBJECT IDENTIFIER : 1.2.840.113549.1.5.13")throw new K("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 K("Only pkcs5PBKDF2 key derivation functions are supported","ERR_INVALID_PARAMS");let s=n.valueBlock.value[1],i=To(s.valueBlock.value[0].getValue()),a=kc,c=Tc;if(s.valueBlock.value.length===3)a=Number(s.valueBlock.value[1].toBigInt()),c=Number(s.valueBlock.value[2].toBigInt());else if(s.valueBlock.value.length===2)throw new K("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 K("Only AES-CBC encryption schemes are supported","ERR_INVALID_PARAMS")}}}}let l=To(f.valueBlock.value[1].getValue());return{cipherText:To(r.valueBlock.value[1].getValue()),salt:i,iterations:a,keySize:c,iv:l}}function fd(r){return To(r.valueBlock.value[2].getValue())}function To(r){return new Uint8Array(r,0,r.byteLength)}async function hd(r){let e=await Fe.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 md(e);return{privateKey:t[0],publicKey:t[1]}}async function Nc(r){let t=[await Fe.get().subtle.importKey("jwk",r,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["sign"]),await sx(r)],n=await md({privateKey:t[0],publicKey:t[1]});return{privateKey:n[0],publicKey:n[1]}}async function dd(r,e){let t=await Fe.get().subtle.importKey("jwk",r,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["sign"]),n=await Fe.get().subtle.sign({name:"RSASSA-PKCS1-v1_5"},t,e instanceof Uint8Array?e:e.subarray());return new Uint8Array(n,0,n.byteLength)}async function pd(r,e,t){let n=await Fe.get().subtle.importKey("jwk",r,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["verify"]);return Fe.get().subtle.verify({name:"RSASSA-PKCS1-v1_5"},n,e,t instanceof Uint8Array?t:t.subarray())}async function md(r){if(r.privateKey==null||r.publicKey==null)throw new K("Private and public key are required","ERR_INVALID_PARAMETERS");return Promise.all([Fe.get().subtle.exportKey("jwk",r.privateKey),Fe.get().subtle.exportKey("jwk",r.publicKey)])}async function sx(r){return Fe.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 Ii(r){if(r.kty!=="RSA")throw new K("invalid key type","ERR_INVALID_KEY_TYPE");if(r.n==null)throw new K("invalid key modulus","ERR_INVALID_KEY_MODULUS");return ee(r.n,"base64url").length*8}var Ro=8192,ko=class{_key;constructor(e){this._key=e}verify(e,t){return pd(this._key,t,e)}marshal(){return br.jwkToPkix(this._key)}get bytes(){return Bt.encode({Type:ce.RSA,Data:this.marshal()}).subarray()}equals(e){return Te(this.bytes,e.bytes)}hash(){let e=Ce.digest(this.bytes);return st(e)?e.then(({bytes:t})=>t):e.bytes}},Un=class{_key;_publicKey;constructor(e,t){this._key=e,this._publicKey=t}genSecret(){return zr(16)}sign(e){return dd(this._key,e)}get public(){if(this._publicKey==null)throw new K("public key not provided","ERR_PUBKEY_NOT_PROVIDED");return new ko(this._publicKey)}marshal(){return br.jwkToPkcs1(this._key)}get bytes(){return St.encode({Type:ce.RSA,Data:this.marshal()}).subarray()}equals(e){return Te(this.bytes,e.bytes)}hash(){let e=Ce.digest(this.bytes);return st(e)?e.then(({bytes:t})=>t):e.bytes}async id(){let e=await this.public.hash();return ue(e,"base58btc")}async export(e,t="pkcs-8"){if(t==="pkcs-8")return br.exportToPem(this,e);if(t==="libp2p-key")return Bn(this.bytes,e);throw new K(`export format '${t}' is not supported`,"ERR_INVALID_EXPORT_FORMAT")}};async function Rc(r){let e=br.pkcs1ToJwk(r);if(Ii(e)>Ro)throw new K("key size is too large","ERR_KEY_SIZE_TOO_LARGE");let t=await Nc(e);return new Un(t.privateKey,t.publicKey)}function ax(r){let e=br.pkixToJwk(r);if(Ii(e)>Ro)throw new K("key size is too large","ERR_KEY_SIZE_TOO_LARGE");return new ko(e)}async function cx(r){if(Ii(r)>Ro)throw new K("key size is too large","ERR_KEY_SIZE_TOO_LARGE");let e=await Nc(r);return new Un(e.privateKey,e.publicKey)}async function ux(r){if(r>Ro)throw new K("key size is too large","ERR_KEY_SIZE_TOO_LARGE");let e=await hd(r);return new Un(e.privateKey,e.publicKey)}var Vc={};M(Vc,{Secp256k1PrivateKey:()=>Uo,Secp256k1PublicKey:()=>No,generateKeyPair:()=>Bx,unmarshalSecp256k1PrivateKey:()=>Ex,unmarshalSecp256k1PublicKey:()=>Ax});var lx=(r,e,t)=>r&e^~r&t,fx=(r,e,t)=>r&e^r&t^e&t,hx=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]),xr=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),vr=new Uint32Array(64),_c=class extends xn{constructor(){super(64,32,8,!1),this.A=xr[0]|0,this.B=xr[1]|0,this.C=xr[2]|0,this.D=xr[3]|0,this.E=xr[4]|0,this.F=xr[5]|0,this.G=xr[6]|0,this.H=xr[7]|0}get(){let{A:e,B:t,C:n,D:o,E:s,F:i,G:a,H:c}=this;return[e,t,n,o,s,i,a,c]}set(e,t,n,o,s,i,a,c){this.A=e|0,this.B=t|0,this.C=n|0,this.D=o|0,this.E=s|0,this.F=i|0,this.G=a|0,this.H=c|0}process(e,t){for(let l=0;l<16;l++,t+=4)vr[l]=e.getUint32(t,!1);for(let l=16;l<64;l++){let p=vr[l-15],x=vr[l-2],d=ht(p,7)^ht(p,18)^p>>>3,h=ht(x,17)^ht(x,19)^x>>>10;vr[l]=h+vr[l-7]+d+vr[l-16]|0}let{A:n,B:o,C:s,D:i,E:a,F:c,G:f,H:u}=this;for(let l=0;l<64;l++){let p=ht(a,6)^ht(a,11)^ht(a,25),x=u+p+lx(a,c,f)+hx[l]+vr[l]|0,h=(ht(n,2)^ht(n,13)^ht(n,22))+fx(n,o,s)|0;u=f,f=c,c=a,a=i+x|0,i=s,s=o,o=n,n=x+h|0}n=n+this.A|0,o=o+this.B|0,s=s+this.C|0,i=i+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,s,i,a,c,f,u)}roundClean(){vr.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var gd=As(()=>new _c);function dx(r){let e=po(r);At(e,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});let{endo:t,Fp:n,a:o}=e;if(t){if(!n.eql(o,n.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if(typeof t!="object"||typeof t.beta!="bigint"||typeof t.splitScalar!="function")throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...e})}var{bytesToNumberBE:px,hexToBytes:mx}=Is,jr={Err:class extends Error{constructor(e=""){super(e)}},_parseInt(r){let{Err:e}=jr;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:px(n),l:r.subarray(t+2)}},toSig(r){let{Err:e}=jr,t=typeof r=="string"?mx(r):r;if(!dt(t))throw new Error("ui8a expected");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:s}=jr._parseInt(t.subarray(2)),{d:i,l:a}=jr._parseInt(s);if(a.length)throw new e("Invalid signature: left bytes after parsing");return{r:o,s:i}},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)),s=n.length/2,i=o.length/2,a=t(s),c=t(i);return`30${t(i+s+4)}02${c}${o}02${a}${n}`}},Gt=BigInt(0),at=BigInt(1),QS=BigInt(2),yd=BigInt(3),e3=BigInt(4);function gx(r){let e=dx(r),{Fp:t}=e,n=e.toBytes||((d,h,m)=>{let g=h.toAffine();return Pt(Uint8Array.from([4]),t.toBytes(g.x),t.toBytes(g.y))}),o=e.fromBytes||(d=>{let h=d.subarray(1),m=t.fromBytes(h.subarray(0,t.BYTES)),g=t.fromBytes(h.subarray(t.BYTES,2*t.BYTES));return{x:m,y:g}});function s(d){let{a:h,b:m}=e,g=t.sqr(d),A=t.mul(g,d);return t.add(t.add(A,t.mul(d,h)),m)}if(!t.eql(t.sqr(e.Gy),s(e.Gx)))throw new Error("bad generator point: equation left != right");function i(d){return typeof d=="bigint"&&Gt<d&&d<e.n}function a(d){if(!i(d))throw new Error("Expected valid bigint: 0 < bigint < curve.n")}function c(d){let{allowedPrivateKeyLengths:h,nByteLength:m,wrapPrivateKey:g,n:A}=e;if(h&&typeof d!="bigint"){if(dt(d)&&(d=Ot(d)),typeof d!="string"||!h.includes(d.length))throw new Error("Invalid key");d=d.padStart(m*2,"0")}let w;try{w=typeof d=="bigint"?d:Vt(de("private key",d,m))}catch{throw new Error(`private key must be ${m} bytes, hex or bigint, not ${typeof d}`)}return g&&(w=oe(w,A)),a(w),w}let f=new Map;function u(d){if(!(d instanceof l))throw new Error("ProjectivePoint expected")}class l{constructor(h,m,g){if(this.px=h,this.py=m,this.pz=g,h==null||!t.isValid(h))throw new Error("x required");if(m==null||!t.isValid(m))throw new Error("y required");if(g==null||!t.isValid(g))throw new Error("z required")}static fromAffine(h){let{x:m,y:g}=h||{};if(!h||!t.isValid(m)||!t.isValid(g))throw new Error("invalid affine point");if(h instanceof l)throw new Error("projective point not allowed");let A=w=>t.eql(w,t.ZERO);return A(m)&&A(g)?l.ZERO:new l(m,g,t.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(h){let m=t.invertBatch(h.map(g=>g.pz));return h.map((g,A)=>g.toAffine(m[A])).map(l.fromAffine)}static fromHex(h){let m=l.fromAffine(o(de("pointHex",h)));return m.assertValidity(),m}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:m}=this.toAffine();if(!t.isValid(h)||!t.isValid(m))throw new Error("bad point: x or y not FE");let g=t.sqr(m),A=s(h);if(!t.eql(g,A))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:m,py:g,pz:A}=this,{px:w,py:S,pz:v}=h,I=t.eql(t.mul(m,v),t.mul(w,A)),C=t.eql(t.mul(g,v),t.mul(S,A));return I&&C}negate(){return new l(this.px,t.neg(this.py),this.pz)}double(){let{a:h,b:m}=e,g=t.mul(m,yd),{px:A,py:w,pz:S}=this,v=t.ZERO,I=t.ZERO,C=t.ZERO,y=t.mul(A,A),k=t.mul(w,w),O=t.mul(S,S),U=t.mul(A,w);return U=t.add(U,U),C=t.mul(A,S),C=t.add(C,C),v=t.mul(h,C),I=t.mul(g,O),I=t.add(v,I),v=t.sub(k,I),I=t.add(k,I),I=t.mul(v,I),v=t.mul(U,v),C=t.mul(g,C),O=t.mul(h,O),U=t.sub(y,O),U=t.mul(h,U),U=t.add(U,C),C=t.add(y,y),y=t.add(C,y),y=t.add(y,O),y=t.mul(y,U),I=t.add(I,y),O=t.mul(w,S),O=t.add(O,O),y=t.mul(O,U),v=t.sub(v,y),C=t.mul(O,k),C=t.add(C,C),C=t.add(C,C),new l(v,I,C)}add(h){u(h);let{px:m,py:g,pz:A}=this,{px:w,py:S,pz:v}=h,I=t.ZERO,C=t.ZERO,y=t.ZERO,k=e.a,O=t.mul(e.b,yd),U=t.mul(m,w),V=t.mul(g,S),H=t.mul(A,v),X=t.add(m,g),B=t.add(w,S);X=t.mul(X,B),B=t.add(U,V),X=t.sub(X,B),B=t.add(m,A);let R=t.add(w,v);return B=t.mul(B,R),R=t.add(U,H),B=t.sub(B,R),R=t.add(g,A),I=t.add(S,v),R=t.mul(R,I),I=t.add(V,H),R=t.sub(R,I),y=t.mul(k,B),I=t.mul(O,H),y=t.add(I,y),I=t.sub(V,y),y=t.add(V,y),C=t.mul(I,y),V=t.add(U,U),V=t.add(V,U),H=t.mul(k,H),B=t.mul(O,B),V=t.add(V,H),H=t.sub(U,H),H=t.mul(k,H),B=t.add(B,H),U=t.mul(V,B),C=t.add(C,U),U=t.mul(R,B),I=t.mul(X,I),I=t.sub(I,U),U=t.mul(X,V),y=t.mul(R,y),y=t.add(y,U),new l(I,C,y)}subtract(h){return this.add(h.negate())}is0(){return this.equals(l.ZERO)}wNAF(h){return x.wNAFCached(this,f,h,m=>{let g=t.invertBatch(m.map(A=>A.pz));return m.map((A,w)=>A.toAffine(g[w])).map(l.fromAffine)})}multiplyUnsafe(h){let m=l.ZERO;if(h===Gt)return m;if(a(h),h===at)return this;let{endo:g}=e;if(!g)return x.unsafeLadder(this,h);let{k1neg:A,k1:w,k2neg:S,k2:v}=g.splitScalar(h),I=m,C=m,y=this;for(;w>Gt||v>Gt;)w&at&&(I=I.add(y)),v&at&&(C=C.add(y)),y=y.double(),w>>=at,v>>=at;return A&&(I=I.negate()),S&&(C=C.negate()),C=new l(t.mul(C.px,g.beta),C.py,C.pz),I.add(C)}multiply(h){a(h);let m=h,g,A,{endo:w}=e;if(w){let{k1neg:S,k1:v,k2neg:I,k2:C}=w.splitScalar(m),{p:y,f:k}=this.wNAF(v),{p:O,f:U}=this.wNAF(C);y=x.constTimeNegate(S,y),O=x.constTimeNegate(I,O),O=new l(t.mul(O.px,w.beta),O.py,O.pz),g=y.add(O),A=k.add(U)}else{let{p:S,f:v}=this.wNAF(m);g=S,A=v}return l.normalizeZ([g,A])[0]}multiplyAndAddUnsafe(h,m,g){let A=l.BASE,w=(v,I)=>I===Gt||I===at||!v.equals(A)?v.multiplyUnsafe(I):v.multiply(I),S=w(this,m).add(w(h,g));return S.is0()?void 0:S}toAffine(h){let{px:m,py:g,pz:A}=this,w=this.is0();h==null&&(h=w?t.ONE:t.inv(A));let S=t.mul(m,h),v=t.mul(g,h),I=t.mul(A,h);if(w)return{x:t.ZERO,y:t.ZERO};if(!t.eql(I,t.ONE))throw new Error("invZ was invalid");return{x:S,y:v}}isTorsionFree(){let{h,isTorsionFree:m}=e;if(h===at)return!0;if(m)return m(l,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h,clearCofactor:m}=e;return h===at?this:m?m(l,this):this.multiplyUnsafe(e.h)}toRawBytes(h=!0){return this.assertValidity(),n(l,this,h)}toHex(h=!0){return Ot(this.toRawBytes(h))}}l.BASE=new l(e.Gx,e.Gy,t.ONE),l.ZERO=new l(t.ZERO,t.ONE,t.ZERO);let p=e.nBitLength,x=ks(l,e.endo?Math.ceil(p/2):p);return{CURVE:e,ProjectivePoint:l,normPrivateKeyToScalar:c,weierstrassEquation:s,isWithinCurveOrder:i}}function yx(r){let e=po(r);return At(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function wd(r){let e=yx(r),{Fp:t,n}=e,o=t.BYTES+1,s=2*t.BYTES+1;function i(B){return Gt<B&&B<t.ORDER}function a(B){return oe(B,n)}function c(B){return Cs(B,n)}let{ProjectivePoint:f,normPrivateKeyToScalar:u,weierstrassEquation:l,isWithinCurveOrder:p}=gx({...e,toBytes(B,R,$){let T=R.toAffine(),E=t.toBytes(T.x),L=Pt;return $?L(Uint8Array.from([R.hasEvenY()?2:3]),E):L(Uint8Array.from([4]),E,t.toBytes(T.y))},fromBytes(B){let R=B.length,$=B[0],T=B.subarray(1);if(R===o&&($===2||$===3)){let E=Vt(T);if(!i(E))throw new Error("Point is not on curve");let L=l(E),F=t.sqrt(L),q=(F&at)===at;return($&1)===1!==q&&(F=t.neg(F)),{x:E,y:F}}else if(R===s&&$===4){let E=t.fromBytes(T.subarray(0,t.BYTES)),L=t.fromBytes(T.subarray(t.BYTES,2*t.BYTES));return{x:E,y:L}}else throw new Error(`Point of length ${R} was invalid. Expected ${o} compressed bytes or ${s} uncompressed bytes`)}}),x=B=>Ot(fr(B,e.nByteLength));function d(B){let R=n>>at;return B>R}function h(B){return d(B)?a(-B):B}let m=(B,R,$)=>Vt(B.slice(R,$));class g{constructor(R,$,T){this.r=R,this.s=$,this.recovery=T,this.assertValidity()}static fromCompact(R){let $=e.nByteLength;return R=de("compactSignature",R,$*2),new g(m(R,0,$),m(R,$,2*$))}static fromDER(R){let{r:$,s:T}=jr.toSig(de("DER",R));return new g($,T)}assertValidity(){if(!p(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!p(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(R){return new g(this.r,this.s,R)}recoverPublicKey(R){let{r:$,s:T,recovery:E}=this,L=C(de("msgHash",R));if(E==null||![0,1,2,3].includes(E))throw new Error("recovery id invalid");let F=E===2||E===3?$+e.n:$;if(F>=t.ORDER)throw new Error("recovery id 2 or 3 invalid");let q=E&1?"03":"02",W=f.fromHex(q+x(F)),Y=c(F),ne=a(-L*Y),J=a(T*Y),Q=f.BASE.multiplyAndAddUnsafe(W,ne,J);if(!Q)throw new Error("point at infinify");return Q.assertValidity(),Q}hasHighS(){return d(this.s)}normalizeS(){return this.hasHighS()?new g(this.r,a(-this.s),this.recovery):this}toDERRawBytes(){return Vr(this.toDERHex())}toDERHex(){return jr.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Vr(this.toCompactHex())}toCompactHex(){return x(this.r)+x(this.s)}}let A={isValidPrivateKey(B){try{return u(B),!0}catch{return!1}},normPrivateKeyToScalar:u,randomPrivateKey:()=>{let B=Xa(e.n);return nh(e.randomBytes(B),e.n)},precompute(B=8,R=f.BASE){return R._setWindowSize(B),R.multiply(BigInt(3)),R}};function w(B,R=!0){return f.fromPrivateKey(B).toRawBytes(R)}function S(B){let R=dt(B),$=typeof B=="string",T=(R||$)&&B.length;return R?T===o||T===s:$?T===2*o||T===2*s:B instanceof f}function v(B,R,$=!0){if(S(B))throw new Error("first arg must be private key");if(!S(R))throw new Error("second arg must be public key");return f.fromHex(R).multiply(u(B)).toRawBytes($)}let I=e.bits2int||function(B){let R=Vt(B),$=B.length*8-e.nBitLength;return $>0?R>>BigInt($):R},C=e.bits2int_modN||function(B){return a(I(B))},y=ho(e.nBitLength);function k(B){if(typeof B!="bigint")throw new Error("bigint expected");if(!(Gt<=B&&B<y))throw new Error(`bigint expected < 2^${e.nBitLength}`);return fr(B,e.nByteLength)}function O(B,R,$=U){if(["recovered","canonical"].some(fe=>fe in $))throw new Error("sign() legacy options not supported");let{hash:T,randomBytes:E}=e,{lowS:L,prehash:F,extraEntropy:q}=$;L==null&&(L=!0),B=de("msgHash",B),F&&(B=de("prehashed msgHash",T(B)));let W=C(B),Y=u(R),ne=[k(Y),k(W)];if(q!=null){let fe=q===!0?E(t.BYTES):q;ne.push(de("extraEntropy",fe))}let J=Pt(...ne),Q=W;function ye(fe){let Ae=I(fe);if(!p(Ae))return;let Be=c(Ae),be=f.BASE.multiply(Ae).toAffine(),De=a(be.x);if(De===Gt)return;let _t=a(Be*a(Q+De*Y));if(_t===Gt)return;let Nr=(be.x===De?0:2)|Number(be.y&at),io=_t;return L&&d(_t)&&(io=h(_t),Nr^=1),new g(De,io,Nr)}return{seed:J,k2sig:ye}}let U={lowS:e.lowS,prehash:!1},V={lowS:e.lowS,prehash:!1};function H(B,R,$=U){let{seed:T,k2sig:E}=O(B,R,$),L=e;return Wa(L.hash.outputLen,L.nByteLength,L.hmac)(T,E)}f.BASE._setWindowSize(8);function X(B,R,$,T=V){let E=B;if(R=de("msgHash",R),$=de("publicKey",$),"strict"in T)throw new Error("options.strict was renamed to lowS");let{lowS:L,prehash:F}=T,q,W;try{if(typeof E=="string"||dt(E))try{q=g.fromDER(E)}catch(be){if(!(be instanceof jr.Err))throw be;q=g.fromCompact(E)}else if(typeof E=="object"&&typeof E.r=="bigint"&&typeof E.s=="bigint"){let{r:be,s:De}=E;q=new g(be,De)}else throw new Error("PARSE");W=f.fromHex($)}catch(be){if(be.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(L&&q.hasHighS())return!1;F&&(R=e.hash(R));let{r:Y,s:ne}=q,J=C(R),Q=c(ne),ye=a(J*Q),fe=a(Y*Q),Ae=f.BASE.multiplyAndAddUnsafe(W,ye,fe)?.toAffine();return Ae?a(Ae.x)===Y:!1}return{CURVE:e,getPublicKey:w,getSharedSecret:v,sign:H,verify:X,ProjectivePoint:f,Signature:g,utils:A}}function wx(r){return{hash:r,hmac:(e,...t)=>bo(r,e,Es(...t)),randomBytes:bn}}function bd(r,e){let t=n=>wd({...r,...wx(n)});return Object.freeze({...t(e),create:t})}var Ed=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),xd=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),bx=BigInt(1),Dc=BigInt(2),vd=(r,e)=>(r+e/Dc)/e;function xx(r){let e=Ed,t=BigInt(3),n=BigInt(6),o=BigInt(11),s=BigInt(22),i=BigInt(23),a=BigInt(44),c=BigInt(88),f=r*r*r%e,u=f*f*r%e,l=ae(u,t,e)*u%e,p=ae(l,t,e)*u%e,x=ae(p,Dc,e)*f%e,d=ae(x,o,e)*x%e,h=ae(d,s,e)*d%e,m=ae(h,a,e)*h%e,g=ae(m,c,e)*m%e,A=ae(g,a,e)*h%e,w=ae(A,t,e)*u%e,S=ae(w,i,e)*d%e,v=ae(S,n,e)*f%e,I=ae(v,Dc,e);if(!Lc.eql(Lc.sqr(I),r))throw new Error("Cannot find square root");return I}var Lc=Ts(Ed,void 0,void 0,{sqrt:xx}),wt=bd({a:BigInt(0),b:BigInt(7),Fp:Lc,n:xd,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:r=>{let e=xd,t=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-bx*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),s=t,i=BigInt("0x100000000000000000000000000000000"),a=vd(s*r,e),c=vd(-n*r,e),f=oe(r-a*t-c*o,e),u=oe(-a*n-c*s,e),l=f>i,p=u>i;if(l&&(f=e-f),p&&(u=e-u),f>i||u>i)throw new Error("splitScalar: Endomorphism failed, k="+r);return{k1neg:l,k1:f,k2neg:p,k2:u}}}},gd),u3=BigInt(0);var l3=wt.ProjectivePoint;function Ad(){return wt.utils.randomPrivateKey()}function Bd(r,e){let t=Ce.digest(e instanceof Uint8Array?e:e.subarray());if(st(t))return t.then(({digest:n})=>wt.sign(n,r).toDERRawBytes()).catch(n=>{throw new K(String(n),"ERR_INVALID_INPUT")});try{return wt.sign(t.digest,r).toDERRawBytes()}catch(n){throw new K(String(n),"ERR_INVALID_INPUT")}}function Sd(r,e,t){let n=Ce.digest(t instanceof Uint8Array?t:t.subarray());if(st(n))return n.then(({digest:o})=>wt.verify(e,o,r)).catch(o=>{throw new K(String(o),"ERR_INVALID_INPUT")});try{return wt.verify(e,n.digest,r)}catch(o){throw new K(String(o),"ERR_INVALID_INPUT")}}function Id(r){return wt.ProjectivePoint.fromHex(r).toRawBytes(!0)}function Cd(r){try{wt.getPublicKey(r,!0)}catch(e){throw new K(String(e),"ERR_INVALID_PRIVATE_KEY")}}function Oc(r){try{wt.ProjectivePoint.fromHex(r)}catch(e){throw new K(String(e),"ERR_INVALID_PUBLIC_KEY")}}function Td(r){try{return wt.getPublicKey(r,!0)}catch(e){throw new K(String(e),"ERR_INVALID_PRIVATE_KEY")}}var No=class{_key;constructor(e){Oc(e),this._key=e}verify(e,t){return Sd(this._key,t,e)}marshal(){return Id(this._key)}get bytes(){return Bt.encode({Type:ce.Secp256k1,Data:this.marshal()}).subarray()}equals(e){return Te(this.bytes,e.bytes)}async hash(){let e=Ce.digest(this.bytes),t;return st(e)?{bytes:t}=await e:t=e.bytes,t}},Uo=class{_key;_publicKey;constructor(e,t){this._key=e,this._publicKey=t??Td(e),Cd(this._key),Oc(this._publicKey)}sign(e){return Bd(this._key,e)}get public(){return new No(this._publicKey)}marshal(){return this._key}get bytes(){return St.encode({Type:ce.Secp256k1,Data:this.marshal()}).subarray()}equals(e){return Te(this.bytes,e.bytes)}hash(){let e=Ce.digest(this.bytes);return st(e)?e.then(({bytes:t})=>t):e.bytes}async id(){let e=await this.public.hash();return ue(e,"base58btc")}async export(e,t="libp2p-key"){if(t==="libp2p-key")return Bn(this.bytes,e);throw new K(`export format '${t}' is not supported`,"ERR_INVALID_EXPORT_FORMAT")}};function Ex(r){return new Uo(r)}function Ax(r){return new No(r)}async function Bx(){let r=Ad();return new Uo(r)}var Gr={rsa:Uc,ed25519:Ec,secp256k1:Vc};function kd(r){let e=Object.keys(Gr).join(" / ");return new K(`invalid or unsupported key type ${r}. Must be ${e}`,"ERR_UNSUPPORTED_KEY_TYPE")}function Pc(r){let e=Bt.decode(r),t=e.Data??new Uint8Array;switch(e.Type){case ce.RSA:return Gr.rsa.unmarshalRsaPublicKey(t);case ce.Ed25519:return Gr.ed25519.unmarshalEd25519PublicKey(t);case ce.Secp256k1:return Gr.secp256k1.unmarshalSecp256k1PublicKey(t);default:throw kd(e.Type??"unknown")}}async function Rd(r){let e=St.decode(r),t=e.Data??new Uint8Array;switch(e.Type){case ce.RSA:return Gr.rsa.unmarshalRsaPrivateKey(t);case ce.Ed25519:return Gr.ed25519.unmarshalEd25519PrivateKey(t);case ce.Secp256k1:return Gr.secp256k1.unmarshalSecp256k1PrivateKey(t);default:throw kd(e.Type??"RSA")}}var eu=Se(_o(),1);var Wt="/",_d=new TextEncoder().encode(Wt),Ci=_d[0],_n=class r{_buf;constructor(e,t){if(typeof e=="string")this._buf=ee(e);else if(e instanceof Uint8Array)this._buf=e;else throw new Error("Invalid key, should be String of Uint8Array");if(t==null&&(t=!0),t&&this.clean(),this._buf.byteLength===0||this._buf[0]!==Ci)throw new Error("Invalid key")}toString(e="utf8"){return ue(this._buf,e)}uint8Array(){return this._buf}get[Symbol.toStringTag](){return`Key(${this.toString()})`}static withNamespaces(e){return new r(e.join(Wt))}static random(){return new r(Math.random().toString().substring(2))}static asKey(e){return e instanceof Uint8Array||typeof e=="string"?new r(e):typeof e.uint8Array=="function"?new r(e.uint8Array()):null}clean(){if((this._buf==null||this._buf.byteLength===0)&&(this._buf=_d),this._buf[0]!==Ci){let e=new Uint8Array(this._buf.byteLength+1);e.fill(Ci,0,1),e.set(this._buf,1),this._buf=e}for(;this._buf.byteLength>1&&this._buf[this._buf.byteLength-1]===Ci;)this._buf=this._buf.subarray(0,-1)}less(e){let t=this.list(),n=e.list();for(let o=0;o<t.length;o++){if(n.length<o+1)return!1;let s=t[o],i=n[o];if(s<i)return!0;if(s>i)return!1}return t.length<n.length}reverse(){return r.withNamespaces(this.list().slice().reverse())}namespaces(){return this.list()}baseNamespace(){let e=this.namespaces();return e[e.length-1]}list(){return this.toString().split(Wt).slice(1)}type(){return Ix(this.baseNamespace())}name(){return Cx(this.baseNamespace())}instance(e){return new r(this.toString()+":"+e)}path(){let e=this.parent().toString();return e.endsWith(Wt)||(e+=Wt),e+=this.type(),new r(e)}parent(){let e=this.list();return e.length===1?new r(Wt):new r(e.slice(0,-1).join(Wt))}child(e){return this.toString()===Wt?e:e.toString()===Wt?this:new r(this.toString()+e.toString(),!1)}isAncestorOf(e){return e.toString()===this.toString()?!1:e.toString().startsWith(this.toString())}isDecendantOf(e){return e.toString()===this.toString()?!1:this.toString().startsWith(e.toString())}isTopLevel(){return this.list().length===1}concat(...e){return r.withNamespaces([...this.namespaces(),...Tx(e.map(t=>t.namespaces()))])}};function Ix(r){let e=r.split(":");return e.length<2?"":e.slice(0,-1).join(":")}function Cx(r){let e=r.split(":");return e[e.length-1]}function Tx(r){return[].concat(...r)}var Qp=Se(Ti(),1);var Dd="ERR_IPNS_EXPIRED_RECORD",Do="ERR_UNRECOGNIZED_VALIDITY",Ld="ERR_SIGNATURE_CREATION",Yt="ERR_SIGNATURE_VERIFICATION";var Fc="ERR_UNDEFINED_PARAMETER",Od="ERR_INVALID_RECORD_DATA",Vd="ERR_INVALID_VALUE",Pd="ERR_INVALID_EMBEDDED_KEY",Md="ERR_MISSING_PRIVATE_KEY",Fd="ERR_RECORD_TOO_LARGE";var Re;(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=()=>yo(t)}(e=r.ValidityType||(r.ValidityType={}));let n;r.codec=()=>(n==null&&(n=mr((o,s,i={})=>{i.lengthDelimited!==!1&&s.fork(),o.value!=null&&(s.uint32(10),s.bytes(o.value)),o.signatureV1!=null&&(s.uint32(18),s.bytes(o.signatureV1)),o.validityType!=null&&(s.uint32(24),r.ValidityType.codec().encode(o.validityType,s)),o.validity!=null&&(s.uint32(34),s.bytes(o.validity)),o.sequence!=null&&(s.uint32(40),s.uint64(o.sequence)),o.ttl!=null&&(s.uint32(48),s.uint64(o.ttl)),o.pubKey!=null&&(s.uint32(58),s.bytes(o.pubKey)),o.signatureV2!=null&&(s.uint32(66),s.bytes(o.signatureV2)),o.data!=null&&(s.uint32(74),s.bytes(o.data)),i.lengthDelimited!==!1&&s.ldelim()},(o,s)=>{let i={},a=s==null?o.len:o.pos+s;for(;o.pos<a;){let c=o.uint32();switch(c>>>3){case 1:i.value=o.bytes();break;case 2:i.signatureV1=o.bytes();break;case 3:i.validityType=r.ValidityType.codec().decode(o);break;case 4:i.validity=o.bytes();break;case 5:i.sequence=o.uint64();break;case 6:i.ttl=o.uint64();break;case 7:i.pubKey=o.bytes();break;case 8:i.signatureV2=o.bytes();break;case 9:i.data=o.bytes();break;default:o.skipType(c&7);break}}return i})),n),r.encode=o=>pr(o,r.codec()),r.decode=o=>dr(o,r.codec())})(Re||(Re={}));var kx=["string","number","bigint","symbol"],Rx=["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 $d(r){if(r===null)return"null";if(r===void 0)return"undefined";if(r===!0||r===!1)return"boolean";let e=typeof r;if(kx.includes(e))return e;if(e==="function")return"Function";if(Array.isArray(r))return"Array";if(Nx(r))return"Buffer";let t=Ux(r);return t||"Object"}function Nx(r){return r&&r.constructor&&r.constructor.isBuffer&&r.constructor.isBuffer.call(null,r)}function Ux(r){let e=Object.prototype.toString.call(r).slice(8,-1);if(Rx.includes(e))return e}var b=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}};b.uint=new b(0,"uint",!0);b.negint=new b(1,"negint",!0);b.bytes=new b(2,"bytes",!0);b.string=new b(3,"string",!0);b.array=new b(4,"array",!1);b.map=new b(5,"map",!1);b.tag=new b(6,"tag",!1);b.float=new b(7,"float",!0);b.false=new b(7,"false",!0);b.true=new b(7,"true",!0);b.null=new b(7,"null",!0);b.undefined=new b(7,"undefined",!0);b.break=new b(7,"break",!0);var D=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 Dn=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&typeof globalThis.Buffer.isBuffer=="function",_x=new TextDecoder,Dx=new TextEncoder;function ki(r){return Dn&&globalThis.Buffer.isBuffer(r)}function Hc(r){return r instanceof Uint8Array?ki(r)?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r:Uint8Array.from(r)}var qd=Dn?(r,e,t)=>t-e>64?globalThis.Buffer.from(r.subarray(e,t)).toString("utf8"):Kd(r,e,t):(r,e,t)=>t-e>64?_x.decode(r.subarray(e,t)):Kd(r,e,t),jd=Dn?r=>r.length>64?globalThis.Buffer.from(r):Hd(r):r=>r.length>64?Dx.encode(r):Hd(r),kt=r=>Uint8Array.from(r),Ln=Dn?(r,e,t)=>ki(r)?new Uint8Array(r.subarray(e,t)):r.slice(e,t):(r,e,t)=>r.slice(e,t),Gd=Dn?(r,e)=>(r=r.map(t=>t instanceof Uint8Array?t:globalThis.Buffer.from(t)),Hc(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},Wd=Dn?r=>globalThis.Buffer.allocUnsafe(r):r=>new Uint8Array(r);function Yd(r,e){if(ki(r)&&ki(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 Hd(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 Kd(r,e,t){let n=[];for(;e<t;){let o=r[e],s=null,i=o>239?4:o>223?3:o>191?2:1;if(e+i<=t){let a,c,f,u;switch(i){case 1:o<128&&(s=o);break;case 2:a=r[e+1],(a&192)===128&&(u=(o&31)<<6|a&63,u>127&&(s=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)&&(s=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&&(s=u))}}s===null?(s=65533,i=1):s>65535&&(s-=65536,n.push(s>>>10&1023|55296),s=56320|s&1023),n.push(s),e+=i}return Lx(n)}var zd=4096;function Lx(r){let e=r.length;if(e<=zd)return String.fromCharCode.apply(String,r);let t="",n=0;for(;n<e;)t+=String.fromCharCode.apply(String,r.slice(n,n+=zd));return t}var Ox=256,Lo=class{constructor(e=Ox){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=Wd(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=Ln(n,0,this.cursor)}else t=Gd(this.chunks,this.cursor);return e&&this.reset(),t}};var z="CBOR decode error:",Kc="CBOR encode error:",Oo=[];Oo[23]=1;Oo[24]=2;Oo[25]=3;Oo[26]=5;Oo[27]=9;function Zt(r,e,t){if(r.length-e<t)throw new Error(`${z} not enough data for type`)}var Ee=[24,256,65536,4294967296,BigInt("18446744073709551616")];function tt(r,e,t){Zt(r,e,1);let n=r[e];if(t.strict===!0&&n<Ee[0])throw new Error(`${z} integer encoded in more bytes than necessary (strict decode)`);return n}function rt(r,e,t){Zt(r,e,2);let n=r[e]<<8|r[e+1];if(t.strict===!0&&n<Ee[1])throw new Error(`${z} integer encoded in more bytes than necessary (strict decode)`);return n}function nt(r,e,t){Zt(r,e,4);let n=r[e]*16777216+(r[e+1]<<16)+(r[e+2]<<8)+r[e+3];if(t.strict===!0&&n<Ee[2])throw new Error(`${z} integer encoded in more bytes than necessary (strict decode)`);return n}function ot(r,e,t){Zt(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],s=(BigInt(n)<<BigInt(32))+BigInt(o);if(t.strict===!0&&s<Ee[3])throw new Error(`${z} integer encoded in more bytes than necessary (strict decode)`);if(s<=Number.MAX_SAFE_INTEGER)return Number(s);if(t.allowBigInt===!0)return s;throw new Error(`${z} integers outside of the safe integer range are not supported`)}function Zd(r,e,t,n){return new D(b.uint,tt(r,e+1,n),2)}function Jd(r,e,t,n){return new D(b.uint,rt(r,e+1,n),3)}function Xd(r,e,t,n){return new D(b.uint,nt(r,e+1,n),5)}function Qd(r,e,t,n){return new D(b.uint,ot(r,e+1,n),9)}function ct(r,e){return Ne(r,0,e.value)}function Ne(r,e,t){if(t<Ee[0]){let n=Number(t);r.push([e|n])}else if(t<Ee[1]){let n=Number(t);r.push([e|24,n])}else if(t<Ee[2]){let n=Number(t);r.push([e|25,n>>>8,n&255])}else if(t<Ee[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<Ee[4]){let o=[e|27,0,0,0,0,0,0,0],s=Number(n&BigInt(4294967295)),i=Number(n>>BigInt(32)&BigInt(4294967295));o[8]=s&255,s=s>>8,o[7]=s&255,s=s>>8,o[6]=s&255,s=s>>8,o[5]=s&255,o[4]=i&255,i=i>>8,o[3]=i&255,i=i>>8,o[2]=i&255,i=i>>8,o[1]=i&255,r.push(o)}else throw new Error(`${z} encountered BigInt larger than allowable range`)}}ct.encodedSize=function(e){return Ne.encodedSize(e.value)};Ne.encodedSize=function(e){return e<Ee[0]?1:e<Ee[1]?2:e<Ee[2]?3:e<Ee[3]?5:9};ct.compareTokens=function(e,t){return e.value<t.value?-1:e.value>t.value?1:0};function ep(r,e,t,n){return new D(b.negint,-1-tt(r,e+1,n),2)}function tp(r,e,t,n){return new D(b.negint,-1-rt(r,e+1,n),3)}function rp(r,e,t,n){return new D(b.negint,-1-nt(r,e+1,n),5)}var zc=BigInt(-1),np=BigInt(1);function op(r,e,t,n){let o=ot(r,e+1,n);if(typeof o!="bigint"){let s=-1-o;if(s>=Number.MIN_SAFE_INTEGER)return new D(b.negint,s,9)}if(n.allowBigInt!==!0)throw new Error(`${z} integers outside of the safe integer range are not supported`);return new D(b.negint,zc-BigInt(o),9)}function Ri(r,e){let t=e.value,n=typeof t=="bigint"?t*zc-np:t*-1-1;Ne(r,e.type.majorEncoded,n)}Ri.encodedSize=function(e){let t=e.value,n=typeof t=="bigint"?t*zc-np:t*-1-1;return n<Ee[0]?1:n<Ee[1]?2:n<Ee[2]?3:n<Ee[3]?5:9};Ri.compareTokens=function(e,t){return e.value<t.value?1:e.value>t.value?-1:0};function Vo(r,e,t,n){Zt(r,e,t+n);let o=Ln(r,e+t,e+t+n);return new D(b.bytes,o,t+n)}function sp(r,e,t,n){return Vo(r,e,1,t)}function ip(r,e,t,n){return Vo(r,e,2,tt(r,e+1,n))}function ap(r,e,t,n){return Vo(r,e,3,rt(r,e+1,n))}function cp(r,e,t,n){return Vo(r,e,5,nt(r,e+1,n))}function up(r,e,t,n){let o=ot(r,e+1,n);if(typeof o=="bigint")throw new Error(`${z} 64-bit integer bytes lengths not supported`);return Vo(r,e,9,o)}function Ni(r){return r.encodedBytes===void 0&&(r.encodedBytes=r.type===b.string?jd(r.value):r.value),r.encodedBytes}function On(r,e){let t=Ni(e);Ne(r,e.type.majorEncoded,t.length),r.push(t)}On.encodedSize=function(e){let t=Ni(e);return Ne.encodedSize(t.length)+t.length};On.compareTokens=function(e,t){return Px(Ni(e),Ni(t))};function Px(r,e){return r.length<e.length?-1:r.length>e.length?1:Yd(r,e)}function Po(r,e,t,n,o){let s=t+n;Zt(r,e,s);let i=new D(b.string,qd(r,e+t,e+s),s);return o.retainStringBytes===!0&&(i.byteValue=Ln(r,e+t,e+s)),i}function lp(r,e,t,n){return Po(r,e,1,t,n)}function fp(r,e,t,n){return Po(r,e,2,tt(r,e+1,n),n)}function hp(r,e,t,n){return Po(r,e,3,rt(r,e+1,n),n)}function dp(r,e,t,n){return Po(r,e,5,nt(r,e+1,n),n)}function pp(r,e,t,n){let o=ot(r,e+1,n);if(typeof o=="bigint")throw new Error(`${z} 64-bit integer string lengths not supported`);return Po(r,e,9,o,n)}var mp=On;function Vn(r,e,t,n){return new D(b.array,n,t)}function gp(r,e,t,n){return Vn(r,e,1,t)}function yp(r,e,t,n){return Vn(r,e,2,tt(r,e+1,n))}function wp(r,e,t,n){return Vn(r,e,3,rt(r,e+1,n))}function bp(r,e,t,n){return Vn(r,e,5,nt(r,e+1,n))}function xp(r,e,t,n){let o=ot(r,e+1,n);if(typeof o=="bigint")throw new Error(`${z} 64-bit integer array lengths not supported`);return Vn(r,e,9,o)}function vp(r,e,t,n){if(n.allowIndefinite===!1)throw new Error(`${z} indefinite length items not allowed`);return Vn(r,e,1,1/0)}function Ui(r,e){Ne(r,b.array.majorEncoded,e.value)}Ui.compareTokens=ct.compareTokens;Ui.encodedSize=function(e){return Ne.encodedSize(e.value)};function Pn(r,e,t,n){return new D(b.map,n,t)}function Ep(r,e,t,n){return Pn(r,e,1,t)}function Ap(r,e,t,n){return Pn(r,e,2,tt(r,e+1,n))}function Bp(r,e,t,n){return Pn(r,e,3,rt(r,e+1,n))}function Sp(r,e,t,n){return Pn(r,e,5,nt(r,e+1,n))}function Ip(r,e,t,n){let o=ot(r,e+1,n);if(typeof o=="bigint")throw new Error(`${z} 64-bit integer map lengths not supported`);return Pn(r,e,9,o)}function Cp(r,e,t,n){if(n.allowIndefinite===!1)throw new Error(`${z} indefinite length items not allowed`);return Pn(r,e,1,1/0)}function _i(r,e){Ne(r,b.map.majorEncoded,e.value)}_i.compareTokens=ct.compareTokens;_i.encodedSize=function(e){return Ne.encodedSize(e.value)};function Tp(r,e,t,n){return new D(b.tag,t,1)}function kp(r,e,t,n){return new D(b.tag,tt(r,e+1,n),2)}function Rp(r,e,t,n){return new D(b.tag,rt(r,e+1,n),3)}function Np(r,e,t,n){return new D(b.tag,nt(r,e+1,n),5)}function Up(r,e,t,n){return new D(b.tag,ot(r,e+1,n),9)}function Di(r,e){Ne(r,b.tag.majorEncoded,e.value)}Di.compareTokens=ct.compareTokens;Di.encodedSize=function(e){return Ne.encodedSize(e.value)};var zx=20,qx=21,jx=22,Gx=23;function _p(r,e,t,n){if(n.allowUndefined===!1)throw new Error(`${z} undefined values are not supported`);return n.coerceUndefinedToNull===!0?new D(b.null,null,1):new D(b.undefined,void 0,1)}function Dp(r,e,t,n){if(n.allowIndefinite===!1)throw new Error(`${z} indefinite length items not allowed`);return new D(b.break,void 0,1)}function qc(r,e,t){if(t){if(t.allowNaN===!1&&Number.isNaN(r))throw new Error(`${z} NaN values are not supported`);if(t.allowInfinity===!1&&(r===1/0||r===-1/0))throw new Error(`${z} Infinity values are not supported`)}return new D(b.float,r,e)}function Lp(r,e,t,n){return qc(jc(r,e+1),3,n)}function Op(r,e,t,n){return qc(Gc(r,e+1),5,n)}function Vp(r,e,t,n){return qc($p(r,e+1),9,n)}function Li(r,e,t){let n=e.value;if(n===!1)r.push([b.float.majorEncoded|zx]);else if(n===!0)r.push([b.float.majorEncoded|qx]);else if(n===null)r.push([b.float.majorEncoded|jx]);else if(n===void 0)r.push([b.float.majorEncoded|Gx]);else{let o,s=!1;(!t||t.float64!==!0)&&(Mp(n),o=jc(bt,1),n===o||Number.isNaN(n)?(bt[0]=249,r.push(bt.slice(0,3)),s=!0):(Fp(n),o=Gc(bt,1),n===o&&(bt[0]=250,r.push(bt.slice(0,5)),s=!0))),s||(Wx(n),o=$p(bt,1),bt[0]=251,r.push(bt.slice(0,9)))}}Li.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){Mp(n);let o=jc(bt,1);if(n===o||Number.isNaN(n))return 3;if(Fp(n),o=Gc(bt,1),n===o)return 5}return 9};var Pp=new ArrayBuffer(9),ut=new DataView(Pp,1),bt=new Uint8Array(Pp,0);function Mp(r){if(r===1/0)ut.setUint16(0,31744,!1);else if(r===-1/0)ut.setUint16(0,64512,!1);else if(Number.isNaN(r))ut.setUint16(0,32256,!1);else{ut.setFloat32(0,r);let e=ut.getUint32(0),t=(e&2139095040)>>23,n=e&8388607;if(t===255)ut.setUint16(0,31744,!1);else if(t===0)ut.setUint16(0,(r&2147483648)>>16|n>>13,!1);else{let o=t-127;o<-24?ut.setUint16(0,0):o<-14?ut.setUint16(0,(e&2147483648)>>16|1<<24+o,!1):ut.setUint16(0,(e&2147483648)>>16|o+15<<10|n>>13,!1)}}}function jc(r,e){if(r.length-e<2)throw new Error(`${z} 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,s;return n===0?s=o*2**-24:n!==31?s=(o+1024)*2**(n-25):s=o===0?1/0:NaN,t&32768?-s:s}function Fp(r){ut.setFloat32(0,r,!1)}function Gc(r,e){if(r.length-e<4)throw new Error(`${z} not enough data for float32`);let t=(r.byteOffset||0)+e;return new DataView(r.buffer,t,4).getFloat32(0,!1)}function Wx(r){ut.setFloat64(0,r,!1)}function $p(r,e){if(r.length-e<8)throw new Error(`${z} not enough data for float64`);let t=(r.byteOffset||0)+e;return new DataView(r.buffer,t,8).getFloat64(0,!1)}Li.compareTokens=ct.compareTokens;function te(r,e,t){throw new Error(`${z} encountered invalid minor (${t}) for major ${r[e]>>>5}`)}function Oi(r){return()=>{throw new Error(`${z} ${r}`)}}var N=[];for(let r=0;r<=23;r++)N[r]=te;N[24]=Zd;N[25]=Jd;N[26]=Xd;N[27]=Qd;N[28]=te;N[29]=te;N[30]=te;N[31]=te;for(let r=32;r<=55;r++)N[r]=te;N[56]=ep;N[57]=tp;N[58]=rp;N[59]=op;N[60]=te;N[61]=te;N[62]=te;N[63]=te;for(let r=64;r<=87;r++)N[r]=sp;N[88]=ip;N[89]=ap;N[90]=cp;N[91]=up;N[92]=te;N[93]=te;N[94]=te;N[95]=Oi("indefinite length bytes/strings are not supported");for(let r=96;r<=119;r++)N[r]=lp;N[120]=fp;N[121]=hp;N[122]=dp;N[123]=pp;N[124]=te;N[125]=te;N[126]=te;N[127]=Oi("indefinite length bytes/strings are not supported");for(let r=128;r<=151;r++)N[r]=gp;N[152]=yp;N[153]=wp;N[154]=bp;N[155]=xp;N[156]=te;N[157]=te;N[158]=te;N[159]=vp;for(let r=160;r<=183;r++)N[r]=Ep;N[184]=Ap;N[185]=Bp;N[186]=Sp;N[187]=Ip;N[188]=te;N[189]=te;N[190]=te;N[191]=Cp;for(let r=192;r<=215;r++)N[r]=Tp;N[216]=kp;N[217]=Rp;N[218]=Np;N[219]=Up;N[220]=te;N[221]=te;N[222]=te;N[223]=te;for(let r=224;r<=243;r++)N[r]=Oi("simple values are not supported");N[244]=te;N[245]=te;N[246]=te;N[247]=_p;N[248]=Oi("simple values are not supported");N[249]=Lp;N[250]=Op;N[251]=Vp;N[252]=te;N[253]=te;N[254]=te;N[255]=Dp;var xt=[];for(let r=0;r<24;r++)xt[r]=new D(b.uint,r,1);for(let r=-1;r>=-24;r--)xt[31-r]=new D(b.negint,r,1);xt[64]=new D(b.bytes,new Uint8Array(0),1);xt[96]=new D(b.string,"",1);xt[128]=new D(b.array,0,1);xt[160]=new D(b.map,0,1);xt[244]=new D(b.false,!1,1);xt[245]=new D(b.true,!0,1);xt[246]=new D(b.null,null,1);function Hp(r){switch(r.type){case b.false:return kt([244]);case b.true:return kt([245]);case b.null:return kt([246]);case b.bytes:return r.value.length?void 0:kt([64]);case b.string:return r.value===""?kt([96]):void 0;case b.array:return r.value===0?kt([128]):void 0;case b.map:return r.value===0?kt([160]):void 0;case b.uint:return r.value<24?kt([Number(r.value)]):void 0;case b.negint:if(r.value>=-24)return kt([31-Number(r.value)])}}var Zx={float64:!1,mapSorter:Qx,quickEncodeToken:Hp};function Jx(){let r=[];return r[b.uint.major]=ct,r[b.negint.major]=Ri,r[b.bytes.major]=On,r[b.string.major]=mp,r[b.array.major]=Ui,r[b.map.major]=_i,r[b.tag.major]=Di,r[b.float.major]=Li,r}var Kp=Jx(),Wc=new Lo,Pi=class r{constructor(e,t){this.obj=e,this.parent=t}includes(e){let t=this;do if(t.obj===e)return!0;while(t=t.parent);return!1}static createCheck(e,t){if(e&&e.includes(t))throw new Error(`${Kc} object contains circular references`);return new r(t,e)}},Er={null:new D(b.null,null),undefined:new D(b.undefined,void 0),true:new D(b.true,!0),false:new D(b.false,!1),emptyArray:new D(b.array,0),emptyMap:new D(b.map,0)},Ar={number(r,e,t,n){return!Number.isInteger(r)||!Number.isSafeInteger(r)?new D(b.float,r):r>=0?new D(b.uint,r):new D(b.negint,r)},bigint(r,e,t,n){return r>=BigInt(0)?new D(b.uint,r):new D(b.negint,r)},Uint8Array(r,e,t,n){return new D(b.bytes,r)},string(r,e,t,n){return new D(b.string,r)},boolean(r,e,t,n){return r?Er.true:Er.false},null(r,e,t,n){return Er.null},undefined(r,e,t,n){return Er.undefined},ArrayBuffer(r,e,t,n){return new D(b.bytes,new Uint8Array(r))},DataView(r,e,t,n){return new D(b.bytes,new Uint8Array(r.buffer,r.byteOffset,r.byteLength))},Array(r,e,t,n){if(!r.length)return t.addBreakTokens===!0?[Er.emptyArray,new D(b.break)]:Er.emptyArray;n=Pi.createCheck(n,r);let o=[],s=0;for(let i of r)o[s++]=Vi(i,t,n);return t.addBreakTokens?[new D(b.array,r.length),o,new D(b.break)]:[new D(b.array,r.length),o]},Object(r,e,t,n){let o=e!=="Object",s=o?r.keys():Object.keys(r),i=o?r.size:s.length;if(!i)return t.addBreakTokens===!0?[Er.emptyMap,new D(b.break)]:Er.emptyMap;n=Pi.createCheck(n,r);let a=[],c=0;for(let f of s)a[c++]=[Vi(f,t,n),Vi(o?r.get(f):r[f],t,n)];return Xx(a,t),t.addBreakTokens?[new D(b.map,i),a,new D(b.break)]:[new D(b.map,i),a]}};Ar.Map=Ar.Object;Ar.Buffer=Ar.Uint8Array;for(let r of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))Ar[`${r}Array`]=Ar.DataView;function Vi(r,e={},t){let n=$d(r),o=e&&e.typeEncoders&&e.typeEncoders[n]||Ar[n];if(typeof o=="function"){let i=o(r,n,e,t);if(i!=null)return i}let s=Ar[n];if(!s)throw new Error(`${Kc} unsupported type: ${n}`);return s(r,n,e,t)}function Xx(r,e){e.mapSorter&&r.sort(e.mapSorter)}function Qx(r,e){let t=Array.isArray(r[0])?r[0][0]:r[0],n=Array.isArray(e[0])?e[0][0]:e[0];if(t.type!==n.type)return t.type.compare(n.type);let o=t.type.major,s=Kp[o].compareTokens(t,n);return s===0&&console.warn("WARNING: complex key types used, CBOR key sorting guarantees are gone"),s}function zp(r,e,t,n){if(Array.isArray(e))for(let o of e)zp(r,o,t,n);else t[e.type.major](r,e,n)}function e1(r,e,t){let n=Vi(r,t);if(!Array.isArray(n)&&t.quickEncodeToken){let o=t.quickEncodeToken(n);if(o)return o;let s=e[n.type.major];if(s.encodedSize){let i=s.encodedSize(n,t),a=new Lo(i);if(s(a,n,t),a.chunks.length!==1)throw new Error(`Unexpected error: pre-calculated length for ${n} was wrong`);return Hc(a.chunks[0])}}return Wc.reset(),zp(Wc,n,e,t),Wc.toBytes(!0)}function Yc(r,e){return e=Object.assign({},Zx,e),e1(r,Kp,e)}var t1={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0},Zc=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=xt[e];if(t===void 0){let n=N[e];if(!n)throw new Error(`${z} 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}},Mo=Symbol.for("DONE"),Mi=Symbol.for("BREAK");function r1(r,e,t){let n=[];for(let o=0;o<r.value;o++){let s=Fo(e,t);if(s===Mi){if(r.value===1/0)break;throw new Error(`${z} got unexpected break to lengthed array`)}if(s===Mo)throw new Error(`${z} found array but not enough entries (got ${o}, expected ${r.value})`);n[o]=s}return n}function n1(r,e,t){let n=t.useMaps===!0,o=n?void 0:{},s=n?new Map:void 0;for(let i=0;i<r.value;i++){let a=Fo(e,t);if(a===Mi){if(r.value===1/0)break;throw new Error(`${z} got unexpected break to lengthed map`)}if(a===Mo)throw new Error(`${z} found map but not enough entries (got ${i} [no key], expected ${r.value})`);if(n!==!0&&typeof a!="string")throw new Error(`${z} non-string keys not supported (got ${typeof a})`);if(t.rejectDuplicateMapKeys===!0&&(n&&s.has(a)||!n&&a in o))throw new Error(`${z} found repeat map key "${a}"`);let c=Fo(e,t);if(c===Mo)throw new Error(`${z} found map but not enough entries (got ${i} [no value], expected ${r.value})`);n?s.set(a,c):o[a]=c}return n?s:o}function Fo(r,e){if(r.done())return Mo;let t=r.next();if(t.type===b.break)return Mi;if(t.type.terminal)return t.value;if(t.type===b.array)return r1(t,r,e);if(t.type===b.map)return n1(t,r,e);if(t.type===b.tag){if(e.tags&&typeof e.tags[t.value]=="function"){let n=Fo(r,e);return e.tags[t.value](n)}throw new Error(`${z} tag not supported (${t.value})`)}throw new Error("unsupported")}function qp(r,e){if(!(r instanceof Uint8Array))throw new Error(`${z} data to decode must be a Uint8Array`);e=Object.assign({},t1,e);let t=e.tokenizer||new Zc(r,e),n=Fo(t,e);if(n===Mo)throw new Error(`${z} did not find any content to decode`);if(n===Mi)throw new Error(`${z} got unexpected break`);return[n,r.subarray(t.pos())]}function Jc(r,e){let[t,n]=qp(r,e);if(n.length>0)throw new Error(`${z} too many terminals, data makes no sense`);return t}var Ge=Se(_o(),1);var jp=ir("ipns:utils"),Gp=ee("/ipns/"),s1=114,Wp=async(r,e)=>{if(e==null||r==null){let n=new Error("one or more of the provided parameters are not defined");throw jp.error(n),(0,Ge.default)(n,Fc)}let t;if(e.pubKey!=null){try{t=Pc(e.pubKey)}catch(o){throw jp.error(o),o}if(!(await Ff(e.pubKey)).equals(r))throw(0,Ge.default)(new Error("Embedded public key did not match PeerID"),Pd)}else r.publicKey!=null&&(t=Pc(r.publicKey));if(t!=null)return t;throw(0,Ge.default)(new Error("no public key is available"),Fc)},Yp=(r,e,t)=>{let n=ee(e);return Or([r,t,n])},Fi=r=>{let e=ee("ipns-signature:");return Or([e,r])},Xc=r=>"signatureV1"in r?Re.encode({value:ee(r.value),signatureV1:r.signatureV1,validityType:r.validityType,validity:ee(r.validity),sequence:r.sequence,ttl:r.ttl,pubKey:r.pubKey,signatureV2:r.signatureV2,data:r.data}):Re.encode({pubKey:r.pubKey,signatureV2:r.signatureV2,data:r.data});function Jt(r){let e=Re.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,Ge.default)(new Error("missing data or signatureV2"),Yt);let t=Xp(e.data),n=Qc(t.Value),o=ue(t.Validity);if(e.value!=null&&e.signatureV1!=null)return i1(e),{value:n,validityType:Re.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:Re.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 $i=r=>Or([Gp,r.toBytes()]),Zp=r=>Fa(r.slice(Gp.length)),Jp=(r,e,t,n,o)=>{let s;if(e===Re.ValidityType.EOL)s=0;else throw(0,Ge.default)(new Error("Unknown validity type"),Do);return Yc({Value:r,Validity:t,ValidityType:s,Sequence:n,TTL:o})},Xp=r=>{let e=Jc(r);if(e.ValidityType===0)e.ValidityType=Re.ValidityType.EOL;else throw(0,Ge.default)(new Error("Unknown validity type"),Do);return Number.isInteger(e.Sequence)&&(e.Sequence=BigInt(e.Sequence)),Number.isInteger(e.TTL)&&(e.TTL=BigInt(e.TTL)),e},Qc=r=>{if(r!=null){if(mf(r))return`/ipns/${r.toCID().toString(ys)}`;if(r instanceof Uint8Array){let n=ue(r);n.startsWith("/")&&(r=n)}let e=r.toString().trim();if(e.startsWith("/")&&e.length>1)return e;let t=Xe.asCID(r);if(t!=null)return t.code===s1?`/ipns/${t.toString(ys)}`:`/ipfs/${t.toV1().toString()}`;try{return r instanceof Uint8Array?`/ipfs/${Xe.decode(r).toV1().toString()}`:`/ipfs/${Xe.parse(e).toV1().toString()}`}catch{}}throw(0,Ge.default)(new Error("Value must be a valid content path starting with /"),Vd)},i1=r=>{if(r.data==null)throw(0,Ge.default)(new Error("Record data is missing"),Od);let e=Xp(r.data);if(!Te(e.Value,r.value??new Uint8Array(0)))throw(0,Ge.default)(new Error('Field "value" did not match between protobuf and CBOR'),Yt);if(!Te(e.Validity,r.validity??new Uint8Array(0)))throw(0,Ge.default)(new Error('Field "validity" did not match between protobuf and CBOR'),Yt);if(e.ValidityType!==r.validityType)throw(0,Ge.default)(new Error('Field "validityType" did not match between protobuf and CBOR'),Yt);if(e.Sequence!==r.sequence)throw(0,Ge.default)(new Error('Field "sequence" did not match between protobuf and CBOR'),Yt);if(e.TTL!==r.ttl)throw(0,Ge.default)(new Error('Field "ttl" did not match between protobuf and CBOR'),Yt)};var a1=ir("ipns"),c1=Et.code,u1="/ipns/",Z4=u1.length,e0={v1Compatible:!0};async function t0(r,e,t,n,o=e0){let s=new Qp.default(Date.now()+Number(n)),i=Re.ValidityType.EOL,[a,c]=n.toString().split("."),f=BigInt(a)*BigInt(1e5)+BigInt(c??"0");return l1(r,e,t,i,s.toString(),f,o)}var l1=async(r,e,t,n,o,s,i=e0)=>{t=BigInt(t);let a=ee(o),c=Qc(e),f=ee(c);if(r.privateKey==null)throw(0,eu.default)(new Error("Missing private key"),Md);let u=await Rd(r.privateKey),l=Jp(f,n,a,t,s),p=Fi(l),x=await u.sign(p),d;if(r.publicKey!=null){let h=_r(r.toBytes());(h.code!==c1||!Te(r.publicKey,h.digest))&&(d=r.publicKey)}if(i.v1Compatible===!0){let h=await f1(u,f,n,a),m={value:c,signatureV1:h,validity:o,validityType:n,sequence:t,ttl:s,signatureV2:x,data:l};return d!=null&&(m.pubKey=d),m}else{let h={value:c,validity:o,validityType:n,sequence:t,ttl:s,signatureV2:x,data:l};return d!=null&&(h.pubKey=d),h}};var f1=async(r,e,t,n)=>{try{let o=Yp(e,t,n);return await r.sign(o)}catch(o){throw a1.error("record signature creation failed",o),(0,eu.default)(new Error("record signature creation failed"),Ld)}};var tu=Se(Ti(),1);function Hi(r,e){let t=e.map((n,o)=>({record:Jt(n),index:o}));return t.sort((n,o)=>{let s=n.record.sequence,i=o.record.sequence;if(s>i)return-1;if(s<i)return 1;if(n.record.validityType===Re.ValidityType.EOL&&o.record.validityType===Re.ValidityType.EOL){let a=tu.default.fromString(n.record.validity).toDate(),c=tu.default.fromString(o.record.validity).toDate();if(a.getTime()>c.getTime())return-1;if(a.getTime()<c.getTime())return 1}return 0}),t[0].index}var $o=Se(_o(),1),r0=Se(Ti(),1);var Ki=ir("ipns:validator"),h1=1024*10,d1=async(r,e)=>{let t=Jt(e),n;try{let o=Fi(t.data);n=await r.verify(o,t.signatureV2)}catch{n=!1}if(!n)throw Ki.error("record signature verification failed"),(0,$o.default)(new Error("record signature verification failed"),Yt);if(t.validityType===Re.ValidityType.EOL){if(r0.default.fromString(t.validity).toDate().getTime()<Date.now())throw Ki.error("record has expired"),(0,$o.default)(new Error("record has expired"),Dd)}else if(t.validityType!=null)throw Ki.error("unrecognized validity type"),(0,$o.default)(new Error("unrecognized validity type"),Do);Ki("ipns record for %s is valid",t.value)};async function ru(r,e){if(e.byteLength>h1)throw(0,$o.default)(new Error("record too large"),Fd);let t=Zp(r),n=Jt(e),o=await Wp(t,n);await d1(o,e)}var Ue=class extends Event{constructor(e,t){super(e),this.detail=t}};var au={};M(au,{base58btc:()=>He,base58flickr:()=>b1});function p1(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 s=r.charAt(o),i=s.charCodeAt(0);if(t[i]!==255)throw new TypeError(s+" is ambiguous");t[i]=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(d){if(d instanceof Uint8Array||(ArrayBuffer.isView(d)?d=new Uint8Array(d.buffer,d.byteOffset,d.byteLength):Array.isArray(d)&&(d=Uint8Array.from(d))),!(d instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(d.length===0)return"";for(var h=0,m=0,g=0,A=d.length;g!==A&&d[g]===0;)g++,h++;for(var w=(A-g)*u+1>>>0,S=new Uint8Array(w);g!==A;){for(var v=d[g],I=0,C=w-1;(v!==0||I<m)&&C!==-1;C--,I++)v+=256*S[C]>>>0,S[C]=v%a>>>0,v=v/a>>>0;if(v!==0)throw new Error("Non-zero carry");m=I,g++}for(var y=w-m;y!==w&&S[y]===0;)y++;for(var k=c.repeat(h);y<w;++y)k+=r.charAt(S[y]);return k}function p(d){if(typeof d!="string")throw new TypeError("Expected String");if(d.length===0)return new Uint8Array;var h=0;if(d[h]!==" "){for(var m=0,g=0;d[h]===c;)m++,h++;for(var A=(d.length-h)*f+1>>>0,w=new Uint8Array(A);d[h];){var S=t[d.charCodeAt(h)];if(S===255)return;for(var v=0,I=A-1;(S!==0||v<g)&&I!==-1;I--,v++)S+=a*w[I]>>>0,w[I]=S%256>>>0,S=S/256>>>0;if(S!==0)throw new Error("Non-zero carry");g=v,h++}if(d[h]!==" "){for(var C=A-g;C!==A&&w[C]===0;)C++;for(var y=new Uint8Array(m+(A-C)),k=m;C!==A;)y[k++]=w[C++];return y}}}function x(d){var h=p(d);if(h)return h;throw new Error(`Non-${e} character`)}return{encode:l,decodeUnsafe:p,decode:x}}var m1=p1,g1=m1,n0=g1;var lI=new Uint8Array(0);var o0=(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},Xt=r=>{if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")};var s0=r=>new TextEncoder().encode(r),i0=r=>new TextDecoder().decode(r);var nu=class{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")}},ou=class{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 c0(this,e)}},su=class{constructor(e){this.decoders=e}or(e){return c0(this,e)}decode(e){let t=e[0],n=this.decoders[t];if(n)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},c0=(r,e)=>new su({...r.decoders||{[r.prefix]:r},...e.decoders||{[e.prefix]:e}}),iu=class{constructor(e,t,n,o){this.name=e,this.prefix=t,this.baseEncode=n,this.baseDecode=o,this.encoder=new nu(e,t,n),this.decoder=new ou(e,t,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}},Mn=({name:r,prefix:e,encode:t,decode:n})=>new iu(r,e,t,n),Br=({prefix:r,name:e,alphabet:t})=>{let{encode:n,decode:o}=n0(t,e);return Mn({prefix:r,name:e,encode:n,decode:s=>Xt(o(s))})},y1=(r,e,t,n)=>{let o={};for(let u=0;u<e.length;++u)o[e[u]]=u;let s=r.length;for(;r[s-1]==="=";)--s;let i=new Uint8Array(s*t/8|0),a=0,c=0,f=0;for(let u=0;u<s;++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,i[f++]=255&c>>a)}if(a>=t||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return i},w1=(r,e,t)=>{let n=e[e.length-1]==="=",o=(1<<t)-1,s="",i=0,a=0;for(let c=0;c<r.length;++c)for(a=a<<8|r[c],i+=8;i>t;)i-=t,s+=e[o&a>>i];if(i&&(s+=e[o&a<<t-i]),n)for(;s.length*t&7;)s+="=";return s},pe=({name:r,prefix:e,bitsPerChar:t,alphabet:n})=>Mn({prefix:e,name:r,encode(o){return w1(o,n,t)},decode(o){return y1(o,n,t,r)}});var He=Br({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),b1=Br({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var cu={};M(cu,{base32:()=>Rt,base32hex:()=>A1,base32hexpad:()=>S1,base32hexpadupper:()=>I1,base32hexupper:()=>B1,base32pad:()=>v1,base32padupper:()=>E1,base32upper:()=>x1,base32z:()=>C1});var Rt=pe({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),x1=pe({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),v1=pe({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),E1=pe({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),A1=pe({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),B1=pe({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),S1=pe({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),I1=pe({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),C1=pe({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var T1=f0,u0=128,k1=127,R1=~k1,N1=Math.pow(2,31);function f0(r,e,t){e=e||[],t=t||0;for(var n=t;r>=N1;)e[t++]=r&255|u0,r/=128;for(;r&R1;)e[t++]=r&255|u0,r>>>=7;return e[t]=r|0,f0.bytes=t-n+1,e}var U1=uu,_1=128,l0=127;function uu(r,n){var t=0,n=n||0,o=0,s=n,i,a=r.length;do{if(s>=a)throw uu.bytes=0,new RangeError("Could not decode varint");i=r[s++],t+=o<28?(i&l0)<<o:(i&l0)*Math.pow(2,o),o+=7}while(i>=_1);return uu.bytes=s-n,t}var D1=Math.pow(2,7),L1=Math.pow(2,14),O1=Math.pow(2,21),V1=Math.pow(2,28),P1=Math.pow(2,35),M1=Math.pow(2,42),F1=Math.pow(2,49),$1=Math.pow(2,56),H1=Math.pow(2,63),K1=function(r){return r<D1?1:r<L1?2:r<O1?3:r<V1?4:r<P1?5:r<M1?6:r<F1?7:r<$1?8:r<H1?9:10},z1={encode:T1,decode:U1,encodingLength:K1},q1=z1,Ho=q1;var Ko=(r,e=0)=>[Ho.decode(r,e),Ho.decode.bytes],Fn=(r,e,t=0)=>(Ho.encode(r,e,t),e),$n=r=>Ho.encodingLength(r);var Yr=(r,e)=>{let t=e.byteLength,n=$n(r),o=n+$n(t),s=new Uint8Array(o+t);return Fn(r,s,0),Fn(t,s,n),s.set(e,o),new Hn(r,t,e,s)},zo=r=>{let e=Xt(r),[t,n]=Ko(e),[o,s]=Ko(e.subarray(n)),i=e.subarray(n+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new Hn(t,o,i,e)},h0=(r,e)=>{if(r===e)return!0;{let t=e;return r.code===t.code&&r.size===t.size&&t.bytes instanceof Uint8Array&&o0(r.bytes,t.bytes)}},Hn=class{constructor(e,t,n,o){this.code=e,this.size=t,this.digest=n,this.bytes=o}};var qi=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 s=0,i=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 p=Number.parseInt(l,e);if(!Number.isNaN(p))return p});if(u===void 0)break;if(s*=e,s+=u,s>f||(i+=1,t!==void 0&&i>t))return}if(i!==0)return!n&&c&&i>1?void 0:s})}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 i=this.readSeparator(":",n,()=>this.readIPv4Addr());if(i!==void 0)return t[o]=i[0],t[o+1]=i[1],t[o+2]=i[2],t[o+3]=i[3],[o+4,!0]}let s=this.readSeparator(":",n,()=>this.readNumber(16,4,!0,2));if(s===void 0)return[o,!1];t[o]=s>>8,t[o+1]=s&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 s=new Uint8Array(14),i=16-(n+2),[a]=e(s.subarray(0,i));return t.set(s.subarray(0,a),16-a),t})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var d0=45,j1=15,Kn=new qi;function lu(r){if(!(r.length>j1))return Kn.new(r).parseWith(()=>Kn.readIPv4Addr())}function fu(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>d0))return Kn.new(r).parseWith(()=>Kn.readIPv6Addr())}function ji(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>d0))return Kn.new(r).parseWith(()=>Kn.readIPAddr())}function Gi(r){return!!lu(r)}function Wi(r){return!!fu(r)}function Sr(r){return!!ji(r)}var gu={};M(gu,{base10:()=>X1});function G1(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 s=r.charAt(o),i=s.charCodeAt(0);if(t[i]!==255)throw new TypeError(s+" is ambiguous");t[i]=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(d){if(d instanceof Uint8Array||(ArrayBuffer.isView(d)?d=new Uint8Array(d.buffer,d.byteOffset,d.byteLength):Array.isArray(d)&&(d=Uint8Array.from(d))),!(d instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(d.length===0)return"";for(var h=0,m=0,g=0,A=d.length;g!==A&&d[g]===0;)g++,h++;for(var w=(A-g)*u+1>>>0,S=new Uint8Array(w);g!==A;){for(var v=d[g],I=0,C=w-1;(v!==0||I<m)&&C!==-1;C--,I++)v+=256*S[C]>>>0,S[C]=v%a>>>0,v=v/a>>>0;if(v!==0)throw new Error("Non-zero carry");m=I,g++}for(var y=w-m;y!==w&&S[y]===0;)y++;for(var k=c.repeat(h);y<w;++y)k+=r.charAt(S[y]);return k}function p(d){if(typeof d!="string")throw new TypeError("Expected String");if(d.length===0)return new Uint8Array;var h=0;if(d[h]!==" "){for(var m=0,g=0;d[h]===c;)m++,h++;for(var A=(d.length-h)*f+1>>>0,w=new Uint8Array(A);d[h];){var S=t[d.charCodeAt(h)];if(S===255)return;for(var v=0,I=A-1;(S!==0||v<g)&&I!==-1;I--,v++)S+=a*w[I]>>>0,w[I]=S%256>>>0,S=S/256>>>0;if(S!==0)throw new Error("Non-zero carry");g=v,h++}if(d[h]!==" "){for(var C=A-g;C!==A&&w[C]===0;)C++;for(var y=new Uint8Array(m+(A-C)),k=m;C!==A;)y[k++]=w[C++];return y}}}function x(d){var h=p(d);if(h)return h;throw new Error(`Non-${e} character`)}return{encode:l,decodeUnsafe:p,decode:x}}var W1=G1,Y1=W1,p0=Y1;var SI=new Uint8Array(0);var m0=(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},Qt=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")};var g0=r=>new TextEncoder().encode(r),y0=r=>new TextDecoder().decode(r);var hu=class{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")}},du=class{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 b0(this,e)}},pu=class{constructor(e){this.decoders=e}or(e){return b0(this,e)}decode(e){let t=e[0],n=this.decoders[t];if(n)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},b0=(r,e)=>new pu({...r.decoders||{[r.prefix]:r},...e.decoders||{[e.prefix]:e}}),mu=class{constructor(e,t,n,o){this.name=e,this.prefix=t,this.baseEncode=n,this.baseDecode=o,this.encoder=new hu(e,t,n),this.decoder=new du(e,t,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}},zn=({name:r,prefix:e,encode:t,decode:n})=>new mu(r,e,t,n),Ir=({prefix:r,name:e,alphabet:t})=>{let{encode:n,decode:o}=p0(t,e);return zn({prefix:r,name:e,encode:n,decode:s=>Qt(o(s))})},Z1=(r,e,t,n)=>{let o={};for(let u=0;u<e.length;++u)o[e[u]]=u;let s=r.length;for(;r[s-1]==="=";)--s;let i=new Uint8Array(s*t/8|0),a=0,c=0,f=0;for(let u=0;u<s;++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,i[f++]=255&c>>a)}if(a>=t||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return i},J1=(r,e,t)=>{let n=e[e.length-1]==="=",o=(1<<t)-1,s="",i=0,a=0;for(let c=0;c<r.length;++c)for(a=a<<8|r[c],i+=8;i>t;)i-=t,s+=e[o&a>>i];if(i&&(s+=e[o&a<<t-i]),n)for(;s.length*t&7;)s+="=";return s},me=({name:r,prefix:e,bitsPerChar:t,alphabet:n})=>zn({prefix:e,name:r,encode(o){return J1(o,n,t)},decode(o){return Z1(o,n,t,r)}});var X1=Ir({prefix:"9",name:"base10",alphabet:"0123456789"});var yu={};M(yu,{base16:()=>Q1,base16upper:()=>ev});var Q1=me({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),ev=me({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var wu={};M(wu,{base2:()=>tv});var tv=me({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var bu={};M(bu,{base256emoji:()=>iv});var x0=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}"),rv=x0.reduce((r,e,t)=>(r[t]=e,r),[]),nv=x0.reduce((r,e,t)=>(r[e.codePointAt(0)]=t,r),[]);function ov(r){return r.reduce((e,t)=>(e+=rv[t],e),"")}function sv(r){let e=[];for(let t of r){let n=nv[t.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${t}`);e.push(n)}return new Uint8Array(e)}var iv=zn({prefix:"\u{1F680}",name:"base256emoji",encode:ov,decode:sv});var xu={};M(xu,{base32:()=>qn,base32hex:()=>lv,base32hexpad:()=>hv,base32hexpadupper:()=>dv,base32hexupper:()=>fv,base32pad:()=>cv,base32padupper:()=>uv,base32upper:()=>av,base32z:()=>pv});var qn=me({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),av=me({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),cv=me({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),uv=me({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),lv=me({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),fv=me({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),hv=me({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),dv=me({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),pv=me({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var vu={};M(vu,{base36:()=>mv,base36upper:()=>gv});var mv=Ir({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),gv=Ir({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Eu={};M(Eu,{base58btc:()=>Nt,base58flickr:()=>yv});var Nt=Ir({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),yv=Ir({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Au={};M(Au,{base64:()=>wv,base64pad:()=>bv,base64url:()=>xv,base64urlpad:()=>vv});var wv=me({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),bv=me({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),xv=me({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),vv=me({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Bu={};M(Bu,{base8:()=>Ev});var Ev=me({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Su={};M(Su,{identity:()=>Av});var Av=zn({prefix:"\0",name:"identity",encode:r=>y0(r),decode:r=>g0(r)});var FI=new TextEncoder,$I=new TextDecoder;var Cu={};M(Cu,{identity:()=>jv});var Iv=A0,v0=128,Cv=127,Tv=~Cv,kv=Math.pow(2,31);function A0(r,e,t){e=e||[],t=t||0;for(var n=t;r>=kv;)e[t++]=r&255|v0,r/=128;for(;r&Tv;)e[t++]=r&255|v0,r>>>=7;return e[t]=r|0,A0.bytes=t-n+1,e}var Rv=Iu,Nv=128,E0=127;function Iu(r,n){var t=0,n=n||0,o=0,s=n,i,a=r.length;do{if(s>=a)throw Iu.bytes=0,new RangeError("Could not decode varint");i=r[s++],t+=o<28?(i&E0)<<o:(i&E0)*Math.pow(2,o),o+=7}while(i>=Nv);return Iu.bytes=s-n,t}var Uv=Math.pow(2,7),_v=Math.pow(2,14),Dv=Math.pow(2,21),Lv=Math.pow(2,28),Ov=Math.pow(2,35),Vv=Math.pow(2,42),Pv=Math.pow(2,49),Mv=Math.pow(2,56),Fv=Math.pow(2,63),$v=function(r){return r<Uv?1:r<_v?2:r<Dv?3:r<Lv?4:r<Ov?5:r<Vv?6:r<Pv?7:r<Mv?8:r<Fv?9:10},Hv={encode:Iv,decode:Rv,encodingLength:$v},Kv=Hv,qo=Kv;var jo=(r,e=0)=>[qo.decode(r,e),qo.decode.bytes],jn=(r,e,t=0)=>(qo.encode(r,e,t),e),Gn=r=>qo.encodingLength(r);var Jr=(r,e)=>{let t=e.byteLength,n=Gn(r),o=n+Gn(t),s=new Uint8Array(o+t);return jn(r,s,0),jn(t,s,n),s.set(e,o),new Wn(r,t,e,s)},B0=r=>{let e=Qt(r),[t,n]=jo(e),[o,s]=jo(e.subarray(n)),i=e.subarray(n+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new Wn(t,o,i,e)},S0=(r,e)=>{if(r===e)return!0;{let t=e;return r.code===t.code&&r.size===t.size&&t.bytes instanceof Uint8Array&&m0(r.bytes,t.bytes)}},Wn=class{constructor(e,t,n,o){this.code=e,this.size=t,this.digest=n,this.bytes=o}};var I0=0,zv="identity",C0=Qt,qv=r=>Jr(I0,C0(r)),jv={code:I0,name:zv,encode:C0,digest:qv};var Ru={};M(Ru,{sha256:()=>Gv,sha512:()=>Wv});var ku=({name:r,code:e,encode:t})=>new Tu(r,e,t),Tu=class{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?Jr(this.code,t):t.then(n=>Jr(this.code,n))}else throw Error("Unknown type, must be binary type")}};var k0=r=>async e=>new Uint8Array(await crypto.subtle.digest(r,e)),Gv=ku({name:"sha2-256",code:18,encode:k0("SHA-256")}),Wv=ku({name:"sha2-512",code:19,encode:k0("SHA-512")});var R0=(r,e)=>{let{bytes:t,version:n}=r;switch(n){case 0:return Zv(t,Nu(r),e||Nt.encoder);default:return Jv(t,Nu(r),e||qn.encoder)}};var N0=new WeakMap,Nu=r=>{let e=N0.get(r);if(e==null){let t=new Map;return N0.set(r,t),t}return e},Zi=class r{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!==Wo)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==Xv)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=Jr(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&&e.code===n.code&&e.version===n.version&&S0(e.multihash,n.multihash)}toString(e){return R0(this,e)}toJSON(){return{"/":R0(this)}}link(){return this}get[Symbol.toStringTag](){return"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:s,bytes:i}=t;return new r(n,o,s,i||U0(n,o,s.bytes))}else if(t[Qv]===!0){let{version:n,multihash:o,code:s}=t,i=B0(o);return r.create(n,s,i)}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!==Wo)throw new Error(`Version 0 CID must use dag-pb (code: ${Wo}) block encoding`);return new r(e,t,n,n.bytes)}case 1:{let o=U0(e,t,n.bytes);return new r(e,t,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return r.create(0,Wo,e)}static createV1(e,t){return r.create(1,e,t)}static decode(e){let[t,n]=r.decodeFirst(e);if(n.length)throw new Error("Incorrect length");return t}static decodeFirst(e){let t=r.inspectBytes(e),n=t.size-t.multihashSize,o=Qt(e.subarray(n,n+t.multihashSize));if(o.byteLength!==t.multihashSize)throw new Error("Incorrect length");let s=o.subarray(t.multihashSize-t.digestSize),i=new Wn(t.multihashCode,t.digestSize,s,o);return[t.version===0?r.createV0(i):r.createV1(t.codec,i),e.subarray(t.size)]}static inspectBytes(e){let t=0,n=()=>{let[l,p]=jo(e.subarray(t));return t+=p,l},o=n(),s=Wo;if(o===18?(o=0,t=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let i=t,a=n(),c=n(),f=t+c,u=f-i;return{version:o,codec:s,multihashCode:a,digestSize:c,multihashSize:u,size:f}}static parse(e,t){let[n,o]=Yv(e,t),s=r.decode(o);if(s.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Nu(s).set(n,e),s}},Yv=(r,e)=>{switch(r[0]){case"Q":{let t=e||Nt;return[Nt.prefix,t.decode(`${Nt.prefix}${r}`)]}case Nt.prefix:{let t=e||Nt;return[Nt.prefix,t.decode(r)]}case qn.prefix:{let t=e||qn;return[qn.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)]}}},Zv=(r,e,t)=>{let{prefix:n}=t;if(n!==Nt.prefix)throw Error(`Cannot string encode V0 in ${t.name} encoding`);let o=e.get(n);if(o==null){let s=t.encode(r).slice(1);return e.set(n,s),s}else return o},Jv=(r,e,t)=>{let{prefix:n}=t,o=e.get(n);if(o==null){let s=t.encode(r);return e.set(n,s),s}else return o},Wo=112,Xv=18,U0=(r,e,t)=>{let n=Gn(r),o=n+Gn(e),s=new Uint8Array(o+t.byteLength);return jn(r,s,0),jn(e,s,n),s.set(t,o),s},Qv=Symbol.for("@ipld/js-cid/CID");var Uu={...Su,...wu,...Bu,...gu,...yu,...xu,...vu,...Eu,...Au,...bu},nC={...Ru,...Cu};function Yn(r){return globalThis.Buffer!=null?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r}function Ji(r=0){return globalThis.Buffer?.allocUnsafe!=null?Yn(globalThis.Buffer.allocUnsafe(r)):new Uint8Array(r)}function D0(r,e,t,n){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:n}}}var _0=D0("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),_u=D0("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=Ji(r.length);for(let t=0;t<r.length;t++)e[t]=r.charCodeAt(t);return e}),e2={utf8:_0,"utf-8":_0,hex:Uu.base16,latin1:_u,ascii:_u,binary:_u,...Uu},Xi=e2;function Ke(r,e="utf8"){let t=Xi[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(r.buffer,r.byteOffset,r.byteLength).toString("utf8"):t.encoder.encode(r).substring(1)}var L0=Gi,t2=Wi,Du=function(r){let e=0;if(r=r.toString().trim(),L0(r)){let t=new Uint8Array(e+4);return r.split(/\./g).forEach(n=>{t[e++]=parseInt(n,10)&255}),t}if(t2(r)){let t=r.split(":",8),n;for(n=0;n<t.length;n++){let s=L0(t[n]),i;s&&(i=Du(t[n]),t[n]=Ke(i.slice(0,2),"base16")),i!=null&&++n<8&&t.splice(n,0,Ke(i.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 s=[n,1];for(n=9-t.length;n>0;n--)s.push("0");t.splice.apply(t,s)}let o=new Uint8Array(e+16);for(n=0;n<t.length;n++){let s=parseInt(t[n],16);o[e++]=s>>8&255,o[e++]=s&255}return o}throw new Error("invalid ip address")},O0=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 s=0;s<t;s++)o.push(r[e+s]);return o.join(".")}if(t===16){let o=[];for(let s=0;s<t;s+=2)o.push(n.getUint16(e+s).toString(16));return o.join(":").replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}return""};var Yo={},Lu={},n2=[[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"],[281,0,"webrtc-w3c"],[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"]];n2.forEach(r=>{let e=o2(...r);Lu[e.code]=e,Yo[e.name]=e});function o2(r,e,t,n,o){return{code:r,size:e,name:t,resolvable:!!n,path:!!o}}function le(r){if(typeof r=="number"){if(Lu[r]!=null)return Lu[r];throw new Error(`no protocol with code: ${r}`)}else if(typeof r=="string"){if(Yo[r]!=null)return Yo[r];throw new Error(`no protocol with name: ${r}`)}throw new Error(`invalid protocol id type: ${typeof r}`)}var V0=(r,e)=>{let{bytes:t,version:n}=r;switch(n){case 0:return i2(t,Ou(r),e||He.encoder);default:return a2(t,Ou(r),e||Rt.encoder)}};var P0=new WeakMap,Ou=r=>{let e=P0.get(r);if(e==null){let t=new Map;return P0.set(r,t),t}return e},lt=class r{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!==Zo)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==c2)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=Yr(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&&e.code===n.code&&e.version===n.version&&h0(e.multihash,n.multihash)}toString(e){return V0(this,e)}toJSON(){return{"/":V0(this)}}link(){return this}get[Symbol.toStringTag](){return"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:s,bytes:i}=t;return new r(n,o,s,i||M0(n,o,s.bytes))}else if(t[u2]===!0){let{version:n,multihash:o,code:s}=t,i=zo(o);return r.create(n,s,i)}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!==Zo)throw new Error(`Version 0 CID must use dag-pb (code: ${Zo}) block encoding`);return new r(e,t,n,n.bytes)}case 1:{let o=M0(e,t,n.bytes);return new r(e,t,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return r.create(0,Zo,e)}static createV1(e,t){return r.create(1,e,t)}static decode(e){let[t,n]=r.decodeFirst(e);if(n.length)throw new Error("Incorrect length");return t}static decodeFirst(e){let t=r.inspectBytes(e),n=t.size-t.multihashSize,o=Xt(e.subarray(n,n+t.multihashSize));if(o.byteLength!==t.multihashSize)throw new Error("Incorrect length");let s=o.subarray(t.multihashSize-t.digestSize),i=new Hn(t.multihashCode,t.digestSize,s,o);return[t.version===0?r.createV0(i):r.createV1(t.codec,i),e.subarray(t.size)]}static inspectBytes(e){let t=0,n=()=>{let[l,p]=Ko(e.subarray(t));return t+=p,l},o=n(),s=Zo;if(o===18?(o=0,t=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let i=t,a=n(),c=n(),f=t+c,u=f-i;return{version:o,codec:s,multihashCode:a,digestSize:c,multihashSize:u,size:f}}static parse(e,t){let[n,o]=s2(e,t),s=r.decode(o);if(s.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Ou(s).set(n,e),s}},s2=(r,e)=>{switch(r[0]){case"Q":{let t=e||He;return[He.prefix,t.decode(`${He.prefix}${r}`)]}case He.prefix:{let t=e||He;return[He.prefix,t.decode(r)]}case Rt.prefix:{let t=e||Rt;return[Rt.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)]}}},i2=(r,e,t)=>{let{prefix:n}=t;if(n!==He.prefix)throw Error(`Cannot string encode V0 in ${t.name} encoding`);let o=e.get(n);if(o==null){let s=t.encode(r).slice(1);return e.set(n,s),s}else return o},a2=(r,e,t)=>{let{prefix:n}=t,o=e.get(n);if(o==null){let s=t.encode(r);return e.set(n,s),s}else return o},Zo=112,c2=18,M0=(r,e,t)=>{let n=$n(r),o=n+$n(e),s=new Uint8Array(o+t.byteLength);return Fn(r,s,0),Fn(e,s,n),s.set(t,o),s},u2=Symbol.for("@ipld/js-cid/CID");var Vu={};M(Vu,{identity:()=>l2});var l2=Mn({prefix:"\0",name:"identity",encode:r=>i0(r),decode:r=>s0(r)});var Pu={};M(Pu,{base2:()=>f2});var f2=pe({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Mu={};M(Mu,{base8:()=>h2});var h2=pe({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Fu={};M(Fu,{base10:()=>d2});var d2=Br({prefix:"9",name:"base10",alphabet:"0123456789"});var $u={};M($u,{base16:()=>p2,base16upper:()=>m2});var p2=pe({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),m2=pe({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Hu={};M(Hu,{base36:()=>g2,base36upper:()=>y2});var g2=Br({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),y2=Br({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Ku={};M(Ku,{base64:()=>w2,base64pad:()=>b2,base64url:()=>x2,base64urlpad:()=>v2});var w2=pe({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),b2=pe({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),x2=pe({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),v2=pe({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var zu={};M(zu,{base256emoji:()=>I2});var F0=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}"),E2=F0.reduce((r,e,t)=>(r[t]=e,r),[]),A2=F0.reduce((r,e,t)=>(r[e.codePointAt(0)]=t,r),[]);function B2(r){return r.reduce((e,t)=>(e+=E2[t],e),"")}function S2(r){let e=[];for(let t of r){let n=A2[t.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${t}`);e.push(n)}return new Uint8Array(e)}var I2=Mn({prefix:"\u{1F680}",name:"base256emoji",encode:B2,decode:S2});var Gu={};M(Gu,{sha256:()=>C2,sha512:()=>T2});var ju=({name:r,code:e,encode:t})=>new qu(r,e,t),qu=class{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?Yr(this.code,t):t.then(n=>Yr(this.code,n))}else throw Error("Unknown type, must be binary type")}};var H0=r=>async e=>new Uint8Array(await crypto.subtle.digest(r,e)),C2=ju({name:"sha2-256",code:18,encode:H0("SHA-256")}),T2=ju({name:"sha2-512",code:19,encode:H0("SHA-512")});var Wu={};M(Wu,{identity:()=>N2});var K0=0,k2="identity",z0=Xt,R2=r=>Yr(K0,z0(r)),N2={code:K0,name:k2,encode:z0,digest:R2};var DC=new TextEncoder,LC=new TextDecoder;var q0={...Vu,...Pu,...Mu,...Fu,...$u,...cu,...Hu,...au,...Ku,...zu},FC={...Gu,...Wu};var Ut=Se(Qi(),1);function Ju(r,e="utf8"){let t=Xi[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?Yn(globalThis.Buffer.from(r,"utf-8")):t.decoder.decode(`${t.prefix}${r}`)}function er(r,e){e==null&&(e=r.reduce((o,s)=>o+s.length,0));let t=Ji(e),n=0;for(let o of r)t.set(o,n),n+=o.length;return Yn(t)}function sm(r,e){switch(le(r).code){case 4:case 41:return W2(e);case 42:return nm(e);case 6:case 273:case 33:case 132:return am(e).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return nm(e);case 421:return X2(e);case 444:return om(e);case 445:return om(e);case 466:return J2(e);default:return Ke(e,"base16")}}function im(r,e){switch(le(r).code){case 4:return tm(e);case 41:return tm(e);case 42:return rm(e);case 6:case 273:case 33:case 132:return Qu(parseInt(e,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return rm(e);case 421:return Y2(e);case 444:return Q2(e);case 445:return eE(e);case 466:return Z2(e);default:return Ju(e,"base16")}}var Xu=Object.values(q0).map(r=>r.decoder),G2=function(){let r=Xu[0].or(Xu[1]);return Xu.slice(2).forEach(e=>r=r.or(e)),r}();function tm(r){if(!Sr(r))throw new Error("invalid ip address");return Du(r)}function W2(r){let e=O0(r,0,r.length);if(e==null)throw new Error("ipBuff is required");if(!Sr(e))throw new Error("invalid ip address");return e}function Qu(r){let e=new ArrayBuffer(2);return new DataView(e).setUint16(0,r),new Uint8Array(e)}function am(r){return new DataView(r.buffer).getUint16(r.byteOffset)}function rm(r){let e=Ju(r),t=Uint8Array.from(Ut.default.encode(e.length));return er([t,e],t.length+e.length)}function nm(r){let e=Ut.default.decode(r);if(r=r.slice(Ut.default.decode.bytes),r.length!==e)throw new Error("inconsistent lengths");return Ke(r)}function Y2(r){let e;r[0]==="Q"||r[0]==="1"?e=zo(He.decode(`z${r}`)).bytes:e=lt.parse(r).multihash.bytes;let t=Uint8Array.from(Ut.default.encode(e.length));return er([t,e],t.length+e.length)}function Z2(r){let e=G2.decode(r),t=Uint8Array.from(Ut.default.encode(e.length));return er([t,e],t.length+e.length)}function J2(r){let e=Ut.default.decode(r),t=r.slice(Ut.default.decode.bytes);if(t.length!==e)throw new Error("inconsistent lengths");return"u"+Ke(t,"base64url")}function X2(r){let e=Ut.default.decode(r),t=r.slice(Ut.default.decode.bytes);if(t.length!==e)throw new Error("inconsistent lengths");return Ke(t,"base58btc")}function Q2(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=Rt.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=Qu(n);return er([t,o],t.length+o.length)}function eE(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=Rt.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=Qu(n);return er([t,o],t.length+o.length)}function om(r){let e=r.slice(0,r.length-2),t=r.slice(r.length-2),n=Ke(e,"base32"),o=am(t);return`${n}:${o}`}var Zn=Se(Qi(),1);function tE(r){let e=[],t=r.split("/").slice(1);if(t.length===1&&t[0]==="")return[];for(let n=0;n<t.length;n++){let o=t[n],s=le(o);if(s.size===0){e.push([o]);continue}if(n++,n>=t.length)throw um("invalid address: "+r);if(s.path===!0){e.push([o,ol(t.slice(n).join("/"))]);break}e.push([o,t[n]])}return e}function rE(r){let e=[];return r.map(t=>{let n=ra(t);return e.push(n.name),t.length>1&&t[1]!=null&&e.push(t[1]),null}),ol(e.join("/"))}function nE(r){return r.map(e=>{Array.isArray(e)||(e=[e]);let t=ra(e);return e.length>1?[t.code,im(t.code,e[1])]:[t.code]})}function el(r){return r.map(e=>{let t=ra(e);return e[1]!=null?[t.code,sm(t.code,e[1])]:[t.code]})}function tl(r){return ta(er(r.map(e=>{let t=ra(e),n=Uint8Array.from(Zn.default.encode(t.code));return e.length>1&&e[1]!=null&&(n=er([n,e[1]])),n})))}function rl(r,e){return r.size>0?r.size/8:r.size===0?0:Zn.default.decode(e)+(Zn.default.decode.bytes??0)}function ea(r){let e=[],t=0;for(;t<r.length;){let n=Zn.default.decode(r,t),o=Zn.default.decode.bytes??0,s=le(n),i=rl(s,r.slice(t+o));if(i===0){e.push([n]),t+=o;continue}let a=r.slice(t+o,t+o+i);if(t+=i+o,t>r.length)throw um("Invalid address Uint8Array: "+Ke(r,"base16"));e.push([n,a])}return e}function nl(r){let e=ea(r),t=el(e);return rE(t)}function oE(r){r=ol(r);let e=tE(r),t=nE(e);return tl(t)}function cm(r){return oE(r)}function ta(r){let e=sE(r);if(e!=null)throw e;return Uint8Array.from(r)}function sE(r){try{ea(r)}catch(e){return e}}function ol(r){return"/"+r.trim().split("/").filter(e=>e).join("/")}function um(r){return new Error("Error parsing address: "+r)}function ra(r){return le(r[0])}var il=Se(Qi(),1);var dm=Se(_o(),1);function lm(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 Jn=function(r,e,t,n){if(t==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?n:t==="a"?n.call(r):n?n.value:e.get(r)},sl=function(r,e,t,n,o){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!o)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?r!==e||!o:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?o.call(r,t):o?o.value=t:e.set(r,t),t},Jo,Xo,Qo,fm,aE=Symbol.for("nodejs.util.inspect.custom"),cE=[le("dns").code,le("dns4").code,le("dns6").code,le("dnsaddr").code],uE=new Map,pm=Symbol.for("@multiformats/js-multiaddr/multiaddr");function lE(r){return!!r?.[pm]}var hm=class r{constructor(e){if(Jo.set(this,void 0),Xo.set(this,void 0),Qo.set(this,void 0),this[fm]=!0,e==null&&(e=""),e instanceof Uint8Array)this.bytes=ta(e);else if(typeof e=="string"){if(e.length>0&&e.charAt(0)!=="/")throw new Error(`multiaddr "${e}" must start with a "/"`);this.bytes=cm(e)}else if(lE(e))this.bytes=ta(e.bytes);else throw new Error("addr must be a string, Buffer, or another Multiaddr")}toString(){return Jn(this,Jo,"f")==null&&sl(this,Jo,nl(this.bytes),"f"),Jn(this,Jo,"f")}toJSON(){return this.toString()}toOptions(){let e,t,n,o,s="",i=le("tcp"),a=le("udp"),c=le("ip4"),f=le("ip6"),u=le("dns6"),l=le("ip6zone");for(let[x,d]of this.stringTuples())x===l.code&&(s=`%${d??""}`),cE.includes(x)&&(t=i.name,o=443,n=`${d??""}${s}`,e=x===u.code?6:4),(x===i.code||x===a.code)&&(t=le(x).name,o=parseInt(d??"")),(x===c.code||x===f.code)&&(t=le(x).name,n=`${d??""}${s}`,e=x===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.protoCodes().map(e=>Object.assign({},le(e)))}protoCodes(){let e=[],t=this.bytes,n=0;for(;n<t.length;){let o=il.default.decode(t,n),s=il.default.decode.bytes??0,i=le(o),a=rl(i,t.slice(n+s));n+=a+s,e.push(o)}return e}protoNames(){return this.protos().map(e=>e.name)}tuples(){return Jn(this,Xo,"f")==null&&sl(this,Xo,ea(this.bytes),"f"),Jn(this,Xo,"f")}stringTuples(){return Jn(this,Qo,"f")==null&&sl(this,Qo,el(this.tuples()),"f"),Jn(this,Qo,"f")}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(tl(t.slice(0,n)));return this}getPeerId(){try{let t=this.stringTuples().filter(n=>n[0]===Yo.ipfs.code).pop();if(t?.[1]!=null){let n=t[1];return n[0]==="Q"||n[0]==="1"?Ke(He.decode(`z${n}`),"base58btc"):Ke(lt.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){let e=null;try{e=this.stringTuples().filter(t=>le(t[0]).path===!0)[0][1],e==null&&(e=null)}catch{e=null}return e}equals(e){return lm(this.bytes,e.bytes)}async resolve(e){let t=this.protos().find(s=>s.resolvable);if(t==null)return[this];let n=uE.get(t.name);if(n==null)throw(0,dm.default)(new Error(`no available resolver for ${t.name}`),"ERR_NO_AVAILABLE_RESOLVER");return(await n(this,e)).map(s=>new r(s))}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)}[(Jo=new WeakMap,Xo=new WeakMap,Qo=new WeakMap,fm=pm,aE)](){return`Multiaddr(${nl(this.bytes)})`}};var fl={};M(fl,{base58btc:()=>We,base58flickr:()=>gE});var wT=new Uint8Array(0);function mm(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 tr(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 gm(r){return new TextEncoder().encode(r)}function ym(r){return new TextDecoder().decode(r)}function fE(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 s=r.charAt(o),i=s.charCodeAt(0);if(t[i]!==255)throw new TypeError(s+" is ambiguous");t[i]=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(d){if(d instanceof Uint8Array||(ArrayBuffer.isView(d)?d=new Uint8Array(d.buffer,d.byteOffset,d.byteLength):Array.isArray(d)&&(d=Uint8Array.from(d))),!(d instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(d.length===0)return"";for(var h=0,m=0,g=0,A=d.length;g!==A&&d[g]===0;)g++,h++;for(var w=(A-g)*u+1>>>0,S=new Uint8Array(w);g!==A;){for(var v=d[g],I=0,C=w-1;(v!==0||I<m)&&C!==-1;C--,I++)v+=256*S[C]>>>0,S[C]=v%a>>>0,v=v/a>>>0;if(v!==0)throw new Error("Non-zero carry");m=I,g++}for(var y=w-m;y!==w&&S[y]===0;)y++;for(var k=c.repeat(h);y<w;++y)k+=r.charAt(S[y]);return k}function p(d){if(typeof d!="string")throw new TypeError("Expected String");if(d.length===0)return new Uint8Array;var h=0;if(d[h]!==" "){for(var m=0,g=0;d[h]===c;)m++,h++;for(var A=(d.length-h)*f+1>>>0,w=new Uint8Array(A);d[h];){var S=t[d.charCodeAt(h)];if(S===255)return;for(var v=0,I=A-1;(S!==0||v<g)&&I!==-1;I--,v++)S+=a*w[I]>>>0,w[I]=S%256>>>0,S=S/256>>>0;if(S!==0)throw new Error("Non-zero carry");g=v,h++}if(d[h]!==" "){for(var C=A-g;C!==A&&w[C]===0;)C++;for(var y=new Uint8Array(m+(A-C)),k=m;C!==A;)y[k++]=w[C++];return y}}}function x(d){var h=p(d);if(h)return h;throw new Error(`Non-${e} character`)}return{encode:l,decodeUnsafe:p,decode:x}}var hE=fE,dE=hE,bm=dE;var al=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")}},cl=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 xm(this,e)}},ul=class{decoders;constructor(e){this.decoders=e}or(e){return xm(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 xm(r,e){return new ul({...r.decoders??{[r.prefix]:r},...e.decoders??{[e.prefix]:e}})}var ll=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 al(e,t,n),this.decoder=new cl(e,t,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};function Xn({name:r,prefix:e,encode:t,decode:n}){return new ll(r,e,t,n)}function Cr({name:r,prefix:e,alphabet:t}){let{encode:n,decode:o}=bm(t,r);return Xn({prefix:e,name:r,encode:n,decode:s=>tr(o(s))})}function pE(r,e,t,n){let o={};for(let u=0;u<e.length;++u)o[e[u]]=u;let s=r.length;for(;r[s-1]==="=";)--s;let i=new Uint8Array(s*t/8|0),a=0,c=0,f=0;for(let u=0;u<s;++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,i[f++]=255&c>>a)}if(a>=t||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return i}function mE(r,e,t){let n=e[e.length-1]==="=",o=(1<<t)-1,s="",i=0,a=0;for(let c=0;c<r.length;++c)for(a=a<<8|r[c],i+=8;i>t;)i-=t,s+=e[o&a>>i];if(i!==0&&(s+=e[o&a<<t-i]),n)for(;s.length*t&7;)s+="=";return s}function ge({name:r,prefix:e,bitsPerChar:t,alphabet:n}){return Xn({prefix:e,name:r,encode(o){return mE(o,n,t)},decode(o){return pE(o,n,t,r)}})}var We=Cr({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),gE=Cr({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var hl={};M(hl,{base32:()=>rr,base32hex:()=>xE,base32hexpad:()=>EE,base32hexpadupper:()=>AE,base32hexupper:()=>vE,base32pad:()=>wE,base32padupper:()=>bE,base32upper:()=>yE,base32z:()=>BE});var rr=ge({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),yE=ge({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),wE=ge({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),bE=ge({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),xE=ge({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),vE=ge({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),EE=ge({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),AE=ge({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),BE=ge({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var SE=Am,vm=128,IE=127,CE=~IE,TE=Math.pow(2,31);function Am(r,e,t){e=e||[],t=t||0;for(var n=t;r>=TE;)e[t++]=r&255|vm,r/=128;for(;r&CE;)e[t++]=r&255|vm,r>>>=7;return e[t]=r|0,Am.bytes=t-n+1,e}var kE=dl,RE=128,Em=127;function dl(r,n){var t=0,n=n||0,o=0,s=n,i,a=r.length;do{if(s>=a)throw dl.bytes=0,new RangeError("Could not decode varint");i=r[s++],t+=o<28?(i&Em)<<o:(i&Em)*Math.pow(2,o),o+=7}while(i>=RE);return dl.bytes=s-n,t}var NE=Math.pow(2,7),UE=Math.pow(2,14),_E=Math.pow(2,21),DE=Math.pow(2,28),LE=Math.pow(2,35),OE=Math.pow(2,42),VE=Math.pow(2,49),PE=Math.pow(2,56),ME=Math.pow(2,63),FE=function(r){return r<NE?1:r<UE?2:r<_E?3:r<DE?4:r<LE?5:r<OE?6:r<VE?7:r<PE?8:r<ME?9:10},$E={encode:SE,decode:kE,encodingLength:FE},HE=$E,es=HE;function ts(r,e=0){return[es.decode(r,e),es.decode.bytes]}function Qn(r,e,t=0){return es.encode(r,e,t),e}function eo(r){return es.encodingLength(r)}function Xr(r,e){let t=e.byteLength,n=eo(r),o=n+eo(t),s=new Uint8Array(o+t);return Qn(r,s,0),Qn(t,s,n),s.set(e,o),new to(r,t,e,s)}function oa(r){let e=tr(r),[t,n]=ts(e),[o,s]=ts(e.subarray(n)),i=e.subarray(n+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new to(t,o,i,e)}function Bm(r,e){if(r===e)return!0;{let t=e;return r.code===t.code&&r.size===t.size&&t.bytes instanceof Uint8Array&&mm(r.bytes,t.bytes)}}var to=class{code;size;digest;bytes;constructor(e,t,n,o){this.code=e,this.size=t,this.digest=n,this.bytes=o}};function Sm(r,e){let{bytes:t,version:n}=r;switch(n){case 0:return zE(t,pl(r),e??We.encoder);default:return qE(t,pl(r),e??rr.encoder)}}var Im=new WeakMap;function pl(r){let e=Im.get(r);if(e==null){let t=new Map;return Im.set(r,t),t}return e}var Tr=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!==rs)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==jE)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=Xr(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&&Bm(e.multihash,n.multihash)}toString(e){return Sm(this,e)}toJSON(){return{"/":Sm(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:s,bytes:i}=t;return new r(n,o,s,i??Cm(n,o,s.bytes))}else if(t[GE]===!0){let{version:n,multihash:o,code:s}=t,i=oa(o);return r.create(n,s,i)}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!==rs)throw new Error(`Version 0 CID must use dag-pb (code: ${rs}) block encoding`);return new r(e,t,n,n.bytes)}case 1:{let o=Cm(e,t,n.bytes);return new r(e,t,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return r.create(0,rs,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=tr(e.subarray(n,n+t.multihashSize));if(o.byteLength!==t.multihashSize)throw new Error("Incorrect length");let s=o.subarray(t.multihashSize-t.digestSize),i=new to(t.multihashCode,t.digestSize,s,o);return[t.version===0?r.createV0(i):r.createV1(t.codec,i),e.subarray(t.size)]}static inspectBytes(e){let t=0,n=()=>{let[l,p]=ts(e.subarray(t));return t+=p,l},o=n(),s=rs;if(o===18?(o=0,t=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let i=t,a=n(),c=n(),f=t+c,u=f-i;return{version:o,codec:s,multihashCode:a,digestSize:c,multihashSize:u,size:f}}static parse(e,t){let[n,o]=KE(e,t),s=r.decode(o);if(s.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return pl(s).set(n,e),s}};function KE(r,e){switch(r[0]){case"Q":{let t=e??We;return[We.prefix,t.decode(`${We.prefix}${r}`)]}case We.prefix:{let t=e??We;return[We.prefix,t.decode(r)]}case rr.prefix:{let t=e??rr;return[rr.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 zE(r,e,t){let{prefix:n}=t;if(n!==We.prefix)throw Error(`Cannot string encode V0 in ${t.name} encoding`);let o=e.get(n);if(o==null){let s=t.encode(r).slice(1);return e.set(n,s),s}else return o}function qE(r,e,t){let{prefix:n}=t,o=e.get(n);if(o==null){let s=t.encode(r);return e.set(n,s),s}else return o}var rs=112,jE=18;function Cm(r,e,t){let n=eo(r),o=n+eo(e),s=new Uint8Array(o+t.byteLength);return Qn(r,s,0),Qn(e,s,n),s.set(t,o),s}var GE=Symbol.for("@ipld/js-cid/CID");function Tm(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 ml={};M(ml,{base10:()=>WE});var WE=Cr({prefix:"9",name:"base10",alphabet:"0123456789"});var gl={};M(gl,{base16:()=>YE,base16upper:()=>ZE});var YE=ge({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),ZE=ge({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var yl={};M(yl,{base2:()=>JE});var JE=ge({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var wl={};M(wl,{base256emoji:()=>r8});var km=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}"),XE=km.reduce((r,e,t)=>(r[t]=e,r),[]),QE=km.reduce((r,e,t)=>(r[e.codePointAt(0)]=t,r),[]);function e8(r){return r.reduce((e,t)=>(e+=XE[t],e),"")}function t8(r){let e=[];for(let t of r){let n=QE[t.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${t}`);e.push(n)}return new Uint8Array(e)}var r8=Xn({prefix:"\u{1F680}",name:"base256emoji",encode:e8,decode:t8});var bl={};M(bl,{base36:()=>n8,base36upper:()=>o8});var n8=Cr({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),o8=Cr({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var xl={};M(xl,{base64:()=>s8,base64pad:()=>i8,base64url:()=>a8,base64urlpad:()=>c8});var s8=ge({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),i8=ge({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),a8=ge({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),c8=ge({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var vl={};M(vl,{base8:()=>u8});var u8=ge({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var El={};M(El,{identity:()=>l8});var l8=Xn({prefix:"\0",name:"identity",encode:r=>ym(r),decode:r=>gm(r)});var KT=new TextEncoder,zT=new TextDecoder;var Al={};M(Al,{identity:()=>m8});var Rm=0,d8="identity",Nm=tr;function p8(r){return Xr(Rm,Nm(r))}var m8={code:Rm,name:d8,encode:Nm,digest:p8};var Il={};M(Il,{sha256:()=>g8,sha512:()=>y8});function Sl({name:r,code:e,encode:t}){return new Bl(r,e,t)}var Bl=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?Xr(this.code,t):t.then(n=>Xr(this.code,n))}else throw Error("Unknown type, must be binary type")}};function _m(r){return async e=>new Uint8Array(await crypto.subtle.digest(r,e))}var g8=Sl({name:"sha2-256",code:18,encode:_m("SHA-256")}),y8=Sl({name:"sha2-512",code:19,encode:_m("SHA-512")});var ns={...El,...yl,...vl,...ml,...gl,...hl,...bl,...fl,...xl,...wl},n5={...Il,...Al};function Qr(r){return globalThis.Buffer!=null?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r}function sa(r=0){return globalThis.Buffer?.allocUnsafe!=null?Qr(globalThis.Buffer.allocUnsafe(r)):new Uint8Array(r)}function Lm(r,e,t,n){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:n}}}var Dm=Lm("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),Cl=Lm("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=sa(r.length);for(let t=0;t<r.length;t++)e[t]=r.charCodeAt(t);return e}),w8={utf8:Dm,"utf-8":Dm,hex:ns.base16,latin1:Cl,ascii:Cl,binary:Cl,...ns},ia=w8;function Ye(r,e="utf8"){let t=ia[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(r.buffer,r.byteOffset,r.byteLength).toString("utf8"):t.encoder.encode(r).substring(1)}function nr(r,e){if(globalThis.Buffer!=null)return Qr(globalThis.Buffer.concat(r,e));e==null&&(e=r.reduce((o,s)=>o+s.length,0));let t=sa(e),n=0;for(let o of r)t.set(o,n),n+=o.length;return Qr(t)}var E5=parseInt("0xFFFF",16),A5=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);function Tl(r,e="utf8"){let t=ia[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?Qr(globalThis.Buffer.from(r,"utf-8")):t.decoder.decode(`${t.prefix}${r}`)}var Pm=Gi,A8=Wi,kl=function(r){let e=0;if(r=r.toString().trim(),Pm(r)){let t=new Uint8Array(e+4);return r.split(/\./g).forEach(n=>{t[e++]=parseInt(n,10)&255}),t}if(A8(r)){let t=r.split(":",8),n;for(n=0;n<t.length;n++){let s=Pm(t[n]),i;s&&(i=kl(t[n]),t[n]=Ye(i.slice(0,2),"base16")),i!=null&&++n<8&&t.splice(n,0,Ye(i.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 s=[n,1];for(n=9-t.length;n>0;n--)s.push("0");t.splice.apply(t,s)}let o=new Uint8Array(e+16);for(n=0;n<t.length;n++){let s=parseInt(t[n],16);o[e++]=s>>8&255,o[e++]=s&255}return o}throw new Error("invalid ip address")},Mm=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 s=0;s<t;s++)o.push(r[e+s]);return o.join(".")}if(t===16){let o=[];for(let s=0;s<t;s+=2)o.push(n.getUint16(e+s).toString(16));return o.join(":").replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}return""};var no={},Rl={},S8=[[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"]];S8.forEach(r=>{let e=I8(...r);Rl[e.code]=e,no[e.name]=e});function I8(r,e,t,n,o){return{code:r,size:e,name:t,resolvable:!!n,path:!!o}}function se(r){if(typeof r=="number"){if(Rl[r]!=null)return Rl[r];throw new Error(`no protocol with code: ${r}`)}else if(typeof r=="string"){if(no[r]!=null)return no[r];throw new Error(`no protocol with name: ${r}`)}throw new Error(`invalid protocol id type: ${typeof r}`)}var ak=se("ip4"),ck=se("ip6"),uk=se("ipcidr");function Ul(r,e){switch(se(r).code){case 4:case 41:return T8(e);case 42:return Hm(e);case 6:case 273:case 33:case 132:return zm(e).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return Hm(e);case 421:return U8(e);case 444:return Km(e);case 445:return Km(e);case 466:return N8(e);default:return Ye(e,"base16")}}function _l(r,e){switch(se(r).code){case 4:return Fm(e);case 41:return Fm(e);case 42:return $m(e);case 6:case 273:case 33:case 132:return Dl(parseInt(e,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return $m(e);case 421:return k8(e);case 444:return _8(e);case 445:return D8(e);case 466:return R8(e);default:return Tl(e,"base16")}}var Nl=Object.values(ns).map(r=>r.decoder),C8=function(){let r=Nl[0].or(Nl[1]);return Nl.slice(2).forEach(e=>r=r.or(e)),r}();function Fm(r){if(!Sr(r))throw new Error("invalid ip address");return kl(r)}function T8(r){let e=Mm(r,0,r.length);if(e==null)throw new Error("ipBuff is required");if(!Sr(e))throw new Error("invalid ip address");return e}function Dl(r){let e=new ArrayBuffer(2);return new DataView(e).setUint16(0,r),new Uint8Array(e)}function zm(r){return new DataView(r.buffer).getUint16(r.byteOffset)}function $m(r){let e=Tl(r),t=Uint8Array.from(Sn(e.length));return nr([t,e],t.length+e.length)}function Hm(r){let e=Fr(r);if(r=r.slice(qe(e)),r.length!==e)throw new Error("inconsistent lengths");return Ye(r)}function k8(r){let e;r[0]==="Q"||r[0]==="1"?e=oa(We.decode(`z${r}`)).bytes:e=Tr.parse(r).multihash.bytes;let t=Uint8Array.from(Sn(e.length));return nr([t,e],t.length+e.length)}function R8(r){let e=C8.decode(r),t=Uint8Array.from(Sn(e.length));return nr([t,e],t.length+e.length)}function N8(r){let e=Fr(r),t=r.slice(qe(e));if(t.length!==e)throw new Error("inconsistent lengths");return"u"+Ye(t,"base64url")}function U8(r){let e=Fr(r),t=r.slice(qe(e));if(t.length!==e)throw new Error("inconsistent lengths");return Ye(t,"base58btc")}function _8(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=rr.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=Dl(n);return nr([t,o],t.length+o.length)}function D8(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=rr.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=Dl(n);return nr([t,o],t.length+o.length)}function Km(r){let e=r.slice(0,r.length-2),t=r.slice(r.length-2),n=Ye(e,"base32"),o=zm(t);return`${n}:${o}`}function qm(r){r=Ll(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 s=0;s<o.length;s++){let i=o[s],a=se(i);if(a.size===0){e.push([a.code]),t.push([a.code]);continue}if(s++,s>=o.length)throw Gm("invalid address: "+r);if(a.path===!0){n=Ll(o.slice(s).join("/")),e.push([a.code,_l(a.code,n)]),t.push([a.code,n]);break}let c=_l(a.code,o[s]);e.push([a.code,c]),t.push([a.code,Ul(a.code,c)])}return{string:jm(t),bytes:Vl(e),tuples:e,stringTuples:t,path:n}}function Ol(r){let e=[],t=[],n=null,o=0;for(;o<r.length;){let s=Fr(r,o),i=qe(s),a=se(s),c=L8(a,r.slice(o+i));if(c===0){e.push([s]),t.push([s]),o+=i;continue}let f=r.slice(o+i,o+i+c);if(o+=c+i,o>r.length)throw Gm("Invalid address Uint8Array: "+Ye(r,"base16"));e.push([s,f]);let u=Ul(s,f);if(t.push([s,u]),a.path===!0){n=u;break}}return{bytes:Uint8Array.from(r),string:jm(t),tuples:e,stringTuples:t,path:n}}function jm(r){let e=[];return r.map(t=>{let n=se(t[0]);return e.push(n.name),t.length>1&&t[1]!=null&&e.push(t[1]),null}),Ll(e.join("/"))}function Vl(r){return nr(r.map(e=>{let t=se(e[0]),n=Uint8Array.from(Sn(t.code));return e.length>1&&e[1]!=null&&(n=nr([n,e[1]])),n}))}function L8(r,e){if(r.size>0)return r.size/8;if(r.size===0)return 0;{let t=Fr(e instanceof Uint8Array?e:Uint8Array.from(e));return t+qe(t)}}function Ll(r){return"/"+r.trim().split("/").filter(e=>e).join("/")}function Gm(r){return new Error("Error parsing address: "+r)}var O8=Symbol.for("nodejs.util.inspect.custom"),Pl=Symbol.for("@multiformats/js-multiaddr/multiaddr"),V8=[se("dns").code,se("dns4").code,se("dns6").code,se("dnsaddr").code],aa=class r{bytes;#e;#t;#s;#a;[Pl]=!0;constructor(e){e==null&&(e="");let t;if(e instanceof Uint8Array)t=Ol(e);else if(typeof e=="string"){if(e.length>0&&e.charAt(0)!=="/")throw new Error(`multiaddr "${e}" must start with a "/"`);t=qm(e)}else if(Ym(e))t=Ol(e.bytes);else throw new Error("addr must be a string, Buffer, or another Multiaddr");this.bytes=t.bytes,this.#e=t.string,this.#t=t.tuples,this.#s=t.stringTuples,this.#a=t.path}toString(){return this.#e}toJSON(){return this.toString()}toOptions(){let e,t,n,o,s="",i=se("tcp"),a=se("udp"),c=se("ip4"),f=se("ip6"),u=se("dns6"),l=se("ip6zone");for(let[x,d]of this.stringTuples())x===l.code&&(s=`%${d??""}`),V8.includes(x)&&(t=i.name,o=443,n=`${d??""}${s}`,e=x===u.code?6:4),(x===i.code||x===a.code)&&(t=se(x).name,o=parseInt(d??"")),(x===c.code||x===f.code)&&(t=se(x).name,n=`${d??""}${s}`,e=x===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.#t.map(([e])=>Object.assign({},se(e)))}protoCodes(){return this.#t.map(([e])=>e)}protoNames(){return this.#t.map(([e])=>se(e).name)}tuples(){return this.#t}stringTuples(){return this.#s}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(Vl(t.slice(0,n)));return this}getPeerId(){try{let e=[];this.stringTuples().forEach(([n,o])=>{n===no.p2p.code&&e.push([n,o]),n===no["p2p-circuit"].code&&(e=[])});let t=e.pop();if(t?.[1]!=null){let n=t[1];return n[0]==="Q"||n[0]==="1"?Ye(We.decode(`z${n}`),"base58btc"):Ye(Tr.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){return this.#a}equals(e){return Tm(this.bytes,e.bytes)}async resolve(e){let t=this.protos().find(s=>s.resolvable);if(t==null)return[this];let n=Wm.get(t.name);if(n==null)throw new K(`no available resolver for ${t.name}`,"ERR_NO_AVAILABLE_RESOLVER");return(await n(this,e)).map(s=>new r(s))}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)}[O8](){return`Multiaddr(${this.#e})`}};var Wm=new Map;function Ym(r){return!!r?.[Pl]}function ca(r){return new aa(r)}var P8=P("dns4"),M8=P("dns6"),F8=P("dnsaddr"),en=_e(P("dns"),F8,P8,M8),ua=_e(P("ip4"),P("ip6")),oo=_e(j(ua,P("tcp")),j(en,P("tcp"))),$l=j(ua,P("udp")),$8=j($l,P("utp")),H8=j($l,P("quic")),ss=_e(j(oo,P("ws")),j(en,P("ws"))),is=_e(j(oo,P("wss")),j(en,P("wss")),j(oo,P("tls"),P("ws")),j(en,P("tls"),P("ws"))),Ml=_e(j(oo,P("http")),j(ua,P("http")),j(en,P("http"))),Fl=_e(j(oo,P("https")),j(ua,P("https")),j(en,P("https"))),Zm=j($l,P("webrtc"),P("certhash")),Xm=_e(j(Zm,P("p2p")),Zm),Qm=_e(j(ss,P("p2p-webrtc-star"),P("p2p")),j(is,P("p2p-webrtc-star"),P("p2p")),j(ss,P("p2p-webrtc-star")),j(is,P("p2p-webrtc-star"))),Lk=_e(j(ss,P("p2p-websocket-star"),P("p2p")),j(is,P("p2p-websocket-star"),P("p2p")),j(ss,P("p2p-websocket-star")),j(is,P("p2p-websocket-star"))),eg=_e(j(Ml,P("p2p-webrtc-direct"),P("p2p")),j(Fl,P("p2p-webrtc-direct"),P("p2p")),j(Ml,P("p2p-webrtc-direct")),j(Fl,P("p2p-webrtc-direct"))),as=_e(ss,is,Ml,Fl,Qm,eg,oo,$8,H8,en,Xm),Ok=_e(j(as,P("p2p-stardust"),P("p2p")),j(as,P("p2p-stardust"))),kr=_e(j(as,P("p2p")),Qm,eg,Xm,P("p2p")),Jm=_e(j(kr,P("p2p-circuit"),kr),j(kr,P("p2p-circuit")),j(P("p2p-circuit"),kr),j(as,P("p2p-circuit")),j(P("p2p-circuit"),as),P("p2p-circuit")),tg=()=>_e(j(Jm,tg),Jm),os=tg(),K8=_e(j(os,kr,os),j(kr,os),j(os,kr),os,kr);function rg(r){function e(t){let n;try{n=ca(t)}catch{return!1}let o=r(n.protoNames());return o===null?!1:o===!0||o===!1?o:o.length===0}return e}function j(...r){function e(t){if(t.length<r.length)return null;let n=t;return r.some(o=>(n=typeof o=="function"?o().partialMatch(t):o.partialMatch(t),Array.isArray(n)&&(t=n),n===null)),n}return{toString:function(){return"{ "+r.join(" ")+" }"},input:r,matches:rg(e),partialMatch:e}}function _e(...r){function e(n){let o=null;return r.some(s=>{let i=typeof s=="function"?s().partialMatch(n):s.partialMatch(n);return i!=null?(o=i,!0):!1}),o}return{toString:function(){return"{ "+r.join(" ")+" }"},input:r,matches:rg(e),partialMatch:e}}function P(r){let e=r;function t(o){let s;try{s=ca(o)}catch{return!1}let i=s.protoNames();return i.length===1&&i[0]===e}function n(o){return o.length===0?null:o[0]===e?o.slice(1):null}return{toString:function(){return e},matches:t,partialMatch:n}}var eA=Se(ug(),1);function lg(r){try{return tA(r)?!!lt.parse(r):r instanceof Uint8Array?!!lt.decode(r):!!lt.asCID(r)}catch{return!1}}function tA(r){return typeof r=="string"}var fg=32,zl=async(r,e,t,n={})=>{if(e===0)throw new Error("recursion limit exceeded");let o;try{o=await t(r,n)}catch(c){if(c.code!=="ENOTFOUND"&&c.code!=="ERR_DNSLINK_NOT_FOUND"&&c.code!=="ENODATA")throw c;r.startsWith("_dnslink.")?r=r.replace("_dnslink.",""):r=`_dnslink.${r}`,o=await t(r,n)}let s=o.replace("dnslink=",""),i=s.split("/")[2];return lg(i)?s:zl(i,e-1,t,n)},nA=/^dnslink=.+$/,hg=async(r,e)=>{let o=(await r.resolveTxt(e)).flat().filter(s=>nA.test(s))[0];if(o==null)throw new K(`No dnslink records found for domain: ${e}`,"ERR_DNSLINK_NOT_FOUND");return o};var jl=Se(ga(),1),Gl=Se(mg(),1);function la(r,e,t){return`${r}?name=${e}&type=${t}`}async function gg(r,e){return await(await fetch(r,{headers:new Headers({accept:"application/dns-json"}),signal:e})).json()}function tn(r,e){return`${e}_${r}`}var ql=Object.assign((0,jl.default)("dns-over-http-resolver"),{error:(0,jl.default)("dns-over-http-resolver:error")}),Wl=class{_cache;_TXTcache;_servers;_request;_abortControllers;constructor(e={}){this._cache=new Gl.default({max:e?.maxCache??100}),this._TXTcache=new Gl.default({max:e?.maxCache??100}),this._servers=["https://cloudflare-dns.com/dns-query","https://dns.google/resolve"],this._request=e.request??gg,this._abortControllers=[]}cancel(){this._abortControllers.forEach(e=>{e.abort()})}getServers(){return this._servers}_getShuffledServers(){let e=[...this._servers];for(let t=e.length-1;t>0;t--){let n=Math.floor(Math.random()*t),o=e[t];e[t]=e[n],e[n]=o}return e}setServers(e){this._servers=e}async resolve(e,t="A"){switch(t){case"A":return this.resolve4(e);case"AAAA":return this.resolve6(e);case"TXT":return this.resolveTxt(e);default:throw new Error(`${t} is not supported`)}}async resolve4(e){let t="A",n=this._cache.get(tn(e,t));if(n!=null)return n;let o=!1;for(let s of this._getShuffledServers()){let i=new AbortController;this._abortControllers.push(i);try{let a=await this._request(la(s,e,t),i.signal),c=a.Answer.map(u=>u.data),f=Math.min(...a.Answer.map(u=>u.TTL));return this._cache.set(tn(e,t),c,{ttl:f}),c}catch{i.signal.aborted&&(o=!0),ql.error(`${s} could not resolve ${e} record ${t}`)}finally{this._abortControllers=this._abortControllers.filter(a=>a!==i)}}throw o?Object.assign(new Error("queryA ECANCELLED"),{code:"ECANCELLED"}):new Error(`Could not resolve ${e} record ${t}`)}async resolve6(e){let t="AAAA",n=this._cache.get(tn(e,t));if(n!=null)return n;let o=!1;for(let s of this._getShuffledServers()){let i=new AbortController;this._abortControllers.push(i);try{let a=await this._request(la(s,e,t),i.signal),c=a.Answer.map(u=>u.data),f=Math.min(...a.Answer.map(u=>u.TTL));return this._cache.set(tn(e,t),c,{ttl:f}),c}catch{i.signal.aborted&&(o=!0),ql.error(`${s} could not resolve ${e} record ${t}`)}finally{this._abortControllers=this._abortControllers.filter(a=>a!==i)}}throw o?Object.assign(new Error("queryAaaa ECANCELLED"),{code:"ECANCELLED"}):new Error(`Could not resolve ${e} record ${t}`)}async resolveTxt(e){let t="TXT",n=this._TXTcache.get(tn(e,t));if(n!=null)return n;let o=!1;for(let s of this._getShuffledServers()){let i=new AbortController;this._abortControllers.push(i);try{let a=await this._request(la(s,e,t),i.signal),c=a.Answer.map(u=>[u.data.replace(/['"]+/g,"")]),f=Math.min(...a.Answer.map(u=>u.TTL));return this._TXTcache.set(tn(e,t),c,{ttl:f}),c}catch{i.signal.aborted&&(o=!0),ql.error(`${s} could not resolve ${e} record ${t}`)}finally{this._abortControllers=this._abortControllers.filter(a=>a!==i)}}throw o?Object.assign(new Error("queryTxt ECANCELLED"),{code:"ECANCELLED"}):new Error(`Could not resolve ${e} record ${t}`)}clearCache(){this._cache.clear(),this._TXTcache.clear()}},yg=Wl;var Zl=Se(bg(),1);var ls=class extends Error{constructor(e){super(e),this.name="TimeoutError"}},Jl=class extends Error{constructor(e){super(),this.name="AbortError",this.message=e}},xg=r=>globalThis.DOMException===void 0?new Jl(r):new DOMException(r),vg=r=>{let e=r.reason===void 0?xg("This operation was aborted."):r.reason;return e instanceof Error?e:xg(e)};function Xl(r,e){let{milliseconds:t,fallback:n,message:o,customTimers:s={setTimeout,clearTimeout}}=e,i,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:p}=e;p.aborted&&u(vg(p)),p.addEventListener("abort",()=>{u(vg(p))})}if(t===Number.POSITIVE_INFINITY){r.then(f,u);return}let l=new ls;i=s.setTimeout.call(void 0,()=>{if(n){try{f(n())}catch(p){u(p)}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(p){u(p)}})()}).finally(()=>{c.clear()});return c.clear=()=>{s.clearTimeout.call(void 0,i),i=void 0},c}function Ql(r,e,t){let n=0,o=r.length;for(;o>0;){let s=Math.trunc(o/2),i=n+s;t(r[i],e)<=0?(n=++i,o-=s+1):o=s}return n}var fs=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=Ql(this.#e,n,(s,i)=>i.priority-s.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 hs=class extends Zl.default{#e;#t;#s=0;#a;#c;#p=0;#n;#u;#r;#m;#o=0;#l;#i;#g;timeout;constructor(e){if(super(),e={carryoverConcurrencyCount:!1,intervalCap:Number.POSITIVE_INFINITY,interval:0,concurrency:Number.POSITIVE_INFINITY,autoStart:!0,queueClass:fs,...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.#t=e.intervalCap===Number.POSITIVE_INFINITY||e.interval===0,this.#a=e.intervalCap,this.#c=e.interval,this.#r=new e.queueClass,this.#m=e.queueClass,this.concurrency=e.concurrency,this.timeout=e.timeout,this.#g=e.throwOnTimeout===!0,this.#i=e.autoStart===!1}get#b(){return this.#t||this.#s<this.#a}get#x(){return this.#o<this.#l}#v(){this.#o--,this.#f(),this.emit("next")}#E(){this.#w(),this.#y(),this.#u=void 0}get#A(){let e=Date.now();if(this.#n===void 0){let t=this.#p-e;if(t<0)this.#s=this.#e?this.#o:0;else return this.#u===void 0&&(this.#u=setTimeout(()=>{this.#E()},t)),!0}return!1}#f(){if(this.#r.size===0)return this.#n&&clearInterval(this.#n),this.#n=void 0,this.emit("empty"),this.#o===0&&this.emit("idle"),!1;if(!this.#i){let e=!this.#A;if(this.#b&&this.#x){let t=this.#r.dequeue();return t?(this.emit("active"),t(),e&&this.#y(),!0):!1}}return!1}#y(){this.#t||this.#n!==void 0||(this.#n=setInterval(()=>{this.#w()},this.#c),this.#p=Date.now()+this.#c)}#w(){this.#s===0&&this.#o===0&&this.#n&&(clearInterval(this.#n),this.#n=void 0),this.#s=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#B(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.#r.enqueue(async()=>{this.#o++,this.#s++;try{t.signal?.throwIfAborted();let s=e({signal:t.signal});t.timeout&&(s=Xl(Promise.resolve(s),{milliseconds:t.timeout})),t.signal&&(s=Promise.race([s,this.#B(t.signal)]));let i=await s;n(i),this.emit("completed",i)}catch(s){if(s instanceof ls&&!t.throwOnTimeout){n();return}o(s),this.emit("error",s)}finally{this.#v()}},t),this.emit("add"),this.#f()})}async addAll(e,t){return Promise.all(e.map(async n=>this.add(n,t)))}start(){return this.#i?(this.#i=!1,this.#h(),this):this}pause(){this.#i=!0}clear(){this.#r=new this.#m}async onEmpty(){this.#r.size!==0&&await this.#d("empty")}async onSizeLessThan(e){this.#r.size<e||await this.#d("next",()=>this.#r.size<e)}async onIdle(){this.#o===0&&this.#r.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.#r.size}sizeBy(e){return this.#r.filter(e).length}get pending(){return this.#o}get isPaused(){return this.#i}};var Bg=Se(Ag(),1),ha=class{lru;constructor(e){this.lru=(0,Bg.default)(e)}get(e){let t=this.lru.get(e);if(t!=null){if(t.expire!=null&&t.expire<Date.now()){this.lru.remove(e);return}return t.value}}set(e,t,n){this.lru.set(e,{value:t,expire:Date.now()+n})}has(e){return this.get(e)!=null}remove(e){this.lru.remove(e)}clear(){this.lru.clear()}};var ef=new ha(1e3),lA=60*1e3,fA=new hs({concurrency:4}),hA=async function(e,t={}){let n=new yg({maxCache:0});if(t.nocache!==!0&&ef.has(e)){let s=ef.get(e);if(s!=null)return t?.onProgress?.(new Ue("dnslink:cache",{detail:s})),s}t.onProgress?.(new Ue("dnslink:query",{detail:e}));let o=await fA.add(async()=>{let s=await hg(n,e);return t.onProgress?.(new Ue("dnslink:answer",{detail:s})),ef.set(e,s,lA),s},{signal:t?.signal});if(o==null)throw new Error("No DNS response received");return o},Sg=hA;function Ig(){return async(r,e={})=>zl(r,fg,Sg,e)}var tf=class{routing;constructor(e){this.routing=e}async put(e,t,n={}){try{await this.routing.put(e,t,n)}catch(o){n.onProgress?.(new Ue("ipns:routing:helia:error",o))}}async get(e,t={}){try{return await this.routing.get(e,t)}catch(n){t.onProgress?.(new Ue("ipns:routing:helia:error",n))}throw new Error("Not found")}};function Cg(r){return new tf(r)}var ds;(function(r){let e;r.codec=()=>(e==null&&(e=mr((t,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),t.key!=null&&t.key.byteLength>0&&(n.uint32(10),n.bytes(t.key)),t.value!=null&&t.value.byteLength>0&&(n.uint32(18),n.bytes(t.value)),t.timeReceived!=null&&t.timeReceived!==""&&(n.uint32(42),n.string(t.timeReceived)),o.lengthDelimited!==!1&&n.ldelim()},(t,n)=>{let o={key:new Uint8Array(0),value:new Uint8Array(0),timeReceived:""},s=n==null?t.len:t.pos+n;for(;t.pos<s;){let i=t.uint32();switch(i>>>3){case 1:o.key=t.bytes();break;case 2:o.value=t.bytes();break;case 5:o.timeReceived=t.string();break;default:t.skipType(i&7);break}}return o})),e),r.encode=t=>pr(t,r.codec()),r.decode=t=>dr(t,r.codec())})(ds||(ds={}));function Tg(r){let e=r.getUTCFullYear(),t=String(r.getUTCMonth()+1).padStart(2,"0"),n=String(r.getUTCDate()).padStart(2,"0"),o=String(r.getUTCHours()).padStart(2,"0"),s=String(r.getUTCMinutes()).padStart(2,"0"),i=String(r.getUTCSeconds()).padStart(2,"0"),a=r.getUTCMilliseconds(),c=String(a*1e3*1e3).padStart(9,"0");return`${e}-${t}-${n}T${o}:${s}:${i}.${c}Z`}function kg(r){let e=new RegExp("(\\d{4})-(\\d{2})-(\\d{2})T(\\d{2}):(\\d{2}):(\\d{2})\\.(\\d+)Z"),t=String(r).trim().match(e);if(t==null)throw new Error("Invalid format");let n=parseInt(t[1],10),o=parseInt(t[2],10)-1,s=parseInt(t[3],10),i=parseInt(t[4],10),a=parseInt(t[5],10),c=parseInt(t[6],10),f=parseInt(t[7].slice(0,-6),10);return new Date(Date.UTC(n,o,s,i,a,c,f))}var so=class r{key;value;timeReceived;constructor(e,t,n){if(!(e instanceof Uint8Array))throw new Error("key must be a Uint8Array");if(!(t instanceof Uint8Array))throw new Error("value must be a Uint8Array");this.key=e,this.value=t,this.timeReceived=n}serialize(){return ds.encode(this.prepareSerialize())}prepareSerialize(){return{key:this.key,value:this.value,timeReceived:Tg(this.timeReceived)}}static deserialize(e){let t=ds.decode(e);return new r(t.key,t.value,new Date(t.timeReceived))}static fromDeserialized(e){let t=kg(e.timeReceived);if(e.key==null)throw new Error("key missing from deserialized object");if(e.value==null)throw new Error("value missing from deserialized object");return new r(e.key,e.value,t)}};var Rg;(function(r){r[r.SEND_QUERY=0]="SEND_QUERY",r[r.PEER_RESPONSE=1]="PEER_RESPONSE",r[r.FINAL_PEER=2]="FINAL_PEER",r[r.QUERY_ERROR=3]="QUERY_ERROR",r[r.PROVIDER=4]="PROVIDER",r[r.VALUE=5]="VALUE",r[r.ADD_PEER=6]="ADD_PEER",r[r.DIAL_PEER=7]="DIAL_PEER"})(Rg||(Rg={}));var Ng;(function(r){r[r.PUT_VALUE=0]="PUT_VALUE",r[r.GET_VALUE=1]="GET_VALUE",r[r.ADD_PROVIDER=2]="ADD_PROVIDER",r[r.GET_PROVIDERS=3]="GET_PROVIDERS",r[r.FIND_NODE=4]="FIND_NODE",r[r.PING=5]="PING"})(Ng||(Ng={}));function rf(r){return new _n("/dht/record/"+ue(r,"base32"),!1)}function Ug(r){return{async put(e,t,n={}){try{let o=rf(e),s=new so(e,t,new Date);n.onProgress?.(new Ue("ipns:routing:datastore:put")),await r.put(o,s.serialize(),n)}catch(o){throw n.onProgress?.(new Ue("ipns:routing:datastore:error",o)),o}},async get(e,t={}){try{let n=rf(e);t.onProgress?.(new Ue("ipns:routing:datastore:get"));let o=await r.get(n,t);return so.deserialize(o).value}catch(n){throw t.onProgress?.(new Ue("ipns:routing:datastore:error",n)),n}},async has(e,t={}){let n=rf(e);return r.has(n,t)}}}var rn=ir("helia:ipns"),pA=60*1e3,_g=60*pA,mA=24*_g,nf=23*_g,of=class{routers;localStore;timeout;defaultResolvers;constructor(e,t=[],n=[]){this.routers=[Cg(e.routing),...t],this.localStore=Ug(e.datastore),this.defaultResolvers=n.length>0?n:[Ig()]}async publish(e,t,n={}){try{let o=1n,s=$i(e);if(await this.localStore.has(s,n)){let c=await this.localStore.get(s,n);o=Jt(c).sequence+1n}let i=await t0(e,t,o,n.lifetime??mA,n),a=Xc(i);return await this.localStore.put(s,a,n),n.offline!==!0&&await Promise.all(this.routers.map(async c=>{await c.put(s,a,n)})),i}catch(o){throw n.onProgress?.(new Ue("ipns:publish:error",o)),o}}async resolve(e,t={}){let n=$i(e),o=await this.#t(n,t);return this.#e(o.value,t)}async resolveDns(e,t={}){let n=t.resolvers??this.defaultResolvers,o=await Promise.any(n.map(async s=>s(e,t)));return this.#e(o,t)}republish(e={}){if(this.timeout!=null)throw new Error("Republish is already running");e.signal?.addEventListener("abort",()=>{clearTimeout(this.timeout)});async function t(){let n=Date.now();e.onProgress?.(new Ue("ipns:republish:start"));let s=Date.now()-n,i=nf-s;i<0&&(i=e.interval??nf),setTimeout(()=>{t().catch(a=>{rn.error("error republishing",a)})},i)}this.timeout=setTimeout(()=>{t().catch(n=>{rn.error("error republishing",n)})},e.interval??nf)}async#e(e,t={}){let n=e.split("/");try{let o=n[1];if(o==="ipns"){let{cid:s}=await this.resolve(Ma(n[2]),t),i=n.slice(3).join("/");return{cid:s,path:i}}else if(o==="ipfs"){let s=Xe.parse(n[2]),i=n.slice(3).join("/");return{cid:s,path:i}}}catch(o){rn.error("error parsing ipfs path",o)}throw rn.error("invalid ipfs path %s",e),new Error("Invalid value")}async#t(e,t={}){let n=[this.localStore,...this.routers];t.offline===!0&&(n=[this.localStore]);let o=[],s=0;if(await Promise.all(n.map(async a=>{let c;try{c=await a.get(e,{...t,validate:!1})}catch(f){a===this.localStore&&f.code==="ERR_NOT_FOUND"?rn("did not have record locally"):rn.error("error finding IPNS record",f);return}try{await ru(e,c),o.push(c)}catch(f){s++,rn.error("error finding IPNS record",f)}})),o.length===0)throw s>0?new K(`${s>1?`${s} records`:"Record"} found for routing key ${s>1?"were":"was"} invalid`,"ERR_RECORDS_FAILED_VALIDATION"):new K("Could not find record for routing key","ERR_NOT_FOUND");let i=o[Hi(e,o)];return await this.localStore.put(e,i,t),Jt(i)}};function gA(r,{routers:e=[],resolvers:t=[]}={}){return new of(r,e,t)}return Gg(yA);})();
|
|
7
|
+
`)}`:`${r} :`}};Pc=Gt;_.Constructed=Pc;Gt.NAME="CONSTRUCTED";var wo=class extends Se{fromBER(e,r,n){return r}toBER(e){return We}};wo.override="EndOfContentValueBlock";var Mc,bo=class extends xe{constructor(e={}){super(e,wo),this.idBlock.tagClass=1,this.idBlock.tagNumber=0}};Mc=bo;_.EndOfContent=Mc;bo.NAME=bn;var Hc,jt=class extends xe{constructor(e={}){super(e,Se),this.idBlock.tagClass=1,this.idBlock.tagNumber=5}fromBER(e,r,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,r+n>e.byteLength?(this.error="End of input reached before message was fully decoded (inconsistent offset and length values)",-1):r+n}toBER(e,r){let n=new ArrayBuffer(2);if(!e){let o=new Uint8Array(n);o[0]=5,o[1]=0}return r&&r.write(n),n}onAsciiEncoding(){return`${this.constructor.NAME}`}};Hc=jt;_.Null=Hc;jt.NAME="NULL";var xo=class extends St(Se){constructor({value:e,...r}={}){super(r),r.valueHex?this.valueHexView=j.BufferSourceConverter.toUint8Array(r.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,r,n){let o=j.BufferSourceConverter.toUint8Array(e);return At(this,o,r,n)?(this.valueHexView=o.subarray(r,r+n),n>1&&this.warnings.push("Boolean value encoded in more then 1 octet"),this.isHexOnly=!0,xs.call(this),this.blockLength=n,r+n):-1}toBER(){return this.valueHexView.slice()}toJSON(){return{...super.toJSON(),value:this.value}}};xo.NAME="BooleanValueBlock";var Kc,Eo=class extends xe{constructor(e={}){super(e,xo),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}`}};Kc=Eo;_.Boolean=Kc;Eo.NAME="BOOLEAN";var vo=class extends St(at){constructor({isConstructed:e=!1,...r}={}){super(r),this.isConstructed=e}fromBER(e,r,n){let o=0;if(this.isConstructed){if(this.isHexOnly=!1,o=at.prototype.fromBER.call(this,e,r,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!==Lc)return this.error="OCTET STRING may consists of OCTET STRINGs only",-1}}else this.isHexOnly=!0,o=super.fromBER(e,r,n),this.blockLength=n;return o}toBER(e,r){return this.isConstructed?at.prototype.toBER.call(this,e,r):e?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),isConstructed:this.isConstructed}}};vo.NAME="OctetStringValueBlock";var $c,vt=class t extends xe{constructor({idBlock:e={},lenBlock:r={},...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:{...r,isIndefiniteForm:!!n.isIndefiniteForm},...n},vo),this.idBlock.tagClass=1,this.idBlock.tagNumber=4}fromBER(e,r,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),r;if(!this.valueBlock.isConstructed){let i=(e instanceof ArrayBuffer?new Uint8Array(e):e).subarray(r,r+n);try{if(i.byteLength){let s=Wo(i,0,i.byteLength);s.offset!==-1&&s.offset===n&&(this.valueBlock.value=[s.result])}}catch{}}return super.fromBER(e,r,n)}onAsciiEncoding(){return this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length?Gt.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 r of this.valueBlock.value)r instanceof t&&e.push(r.valueBlock.valueHexView);return j.BufferSourceConverter.concat(e)}};$c=vt;_.OctetString=$c;vt.NAME=Lc;var Bo=class extends St(at){constructor({unusedBits:e=0,isConstructed:r=!1,...n}={}){super(n),this.unusedBits=e,this.isConstructed=r,this.blockLength=this.valueHexView.byteLength}fromBER(e,r,n){if(!n)return r;let o=-1;if(this.isConstructed){if(o=at.prototype.fromBER.call(this,e,r,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!==Vc)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(!At(this,i,r,n))return-1;let s=i.subarray(r,r+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=Wo(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,r+n}toBER(e,r){if(this.isConstructed)return at.prototype.toBER.call(this,e,r);if(e)return new ArrayBuffer(this.valueHexView.byteLength+1);if(!this.valueHexView.byteLength)return We;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}}};Bo.NAME="BitStringValueBlock";var qc,$r=class extends xe{constructor({idBlock:e={},lenBlock:r={},...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:{...r,isIndefiniteForm:!!n.isIndefiniteForm},...n},Bo),this.idBlock.tagClass=1,this.idBlock.tagNumber=3}fromBER(e,r,n){return this.valueBlock.isConstructed=this.idBlock.isConstructed,this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm,super.fromBER(e,r,n)}onAsciiEncoding(){if(this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length)return Gt.prototype.onAsciiEncoding.call(this);{let e=[],r=this.valueBlock.valueHexView;for(let o of r)e.push(o.toString(2).padStart(8,"0"));let n=e.join("");return`${this.constructor.NAME} : ${n.substring(0,n.length-this.valueBlock.unusedBits)}`}}};qc=$r;_.BitString=qc;$r.NAME=Vc;var zc;function _0(t,e){let r=new Uint8Array([0]),n=new Uint8Array(t),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]+r[0];break;default:f=i[s-l]+r[0]}switch(r[0]=f/10,!0){case l>=i.length:i=lo(new Uint8Array([f%10]),i);break;default:i[s-l]=f%10}}return r[0]>0&&(i=lo(r,i)),i}function Dc(t){if(t>=yn.length)for(let e=yn.length;e<=t;e++){let r=new Uint8Array([0]),n=yn[e-1].slice(0);for(let o=n.length-1;o>=0;o--){let i=new Uint8Array([(n[o]<<1)+r[0]]);r[0]=i[0]/10,n[o]=i[0]%10}r[0]>0&&(n=lo(r,n)),yn.push(n)}return yn[t]}function U0(t,e){let r=0,n=new Uint8Array(t),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]-r,!0){case f<0:r=1,i[s-u]=f+10;break;default:r=0,i[s-u]=f}if(r>0)for(let l=s-c+1;l>=0;l--,u++)if(f=i[s-u]-r,f<0)r=1,i[s-u]=f+10;else{r=0,i[s-u]=f;break}return i.slice()}var xn=class extends St(Se){constructor({value:e,...r}={}){super(r),this._valueDec=0,r.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=xs.call(this)))}set valueDec(e){this._valueDec=e,this.isHexOnly=!1,this.valueHexView=new Uint8Array(Nc(e))}get valueDec(){return this._valueDec}fromDER(e,r,n,o=0){let i=this.fromBER(e,r,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 r=this.valueHexView;switch(!0){case(r[0]&128)!==0:{let n=new Uint8Array(this.valueHexView.length+1);n[0]=0,n.set(r,1),this.valueHexView=n}break;case(r[0]===0&&(r[1]&128)===0):this.valueHexView=this.valueHexView.subarray(1);break}return this.toBER(e)}fromBER(e,r,n){let o=super.fromBER(e,r,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,r=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:r=U0(Dc(n),r),s="-";break;default:r=_0(r,Dc(n))}n++,o>>=1}}for(let c=0;c<r.length;c++)r[c]&&(a=!0),a&&(s+=Uc.charAt(r[c]));return a===!1&&(s+=Uc.charAt(0)),s}};zc=xn;xn.NAME="IntegerValueBlock";Object.defineProperty(zc.prototype,"valueHex",{set:function(t){this.valueHexView=new Uint8Array(t),this.setValueHex()},get:function(){return this.valueHexView.slice().buffer}});var Gc,ue=class t extends xe{constructor(e={}){super(e,xn),this.idBlock.tagClass=1,this.idBlock.tagNumber=2}toBigInt(){return fo(),BigInt(this.valueBlock.toString())}static fromBigInt(e){fo();let r=BigInt(e),n=new wn,o=r.toString(16).replace(/^-/,""),i=new Uint8Array(j.Convert.FromHex(o));if(r<0){let a=new Uint8Array(i.length+(i[0]&128?1:0));a[0]|=128;let f=BigInt(`0x${j.Convert.ToHex(a)}`)+r,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 t({valueHex:n.final()})}convertToDER(){let e=new t({valueHex:this.valueBlock.valueHexView});return e.valueBlock.toDER(),e}convertFromDER(){return new t({valueHex:this.valueBlock.valueHexView[0]===0?this.valueBlock.valueHexView.subarray(1):this.valueBlock.valueHexView})}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()}`}};Gc=ue;_.Integer=Gc;ue.NAME="INTEGER";var jc,Ao=class extends ue{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=10}};jc=Ao;_.Enumerated=jc;Ao.NAME="ENUMERATED";var En=class extends St(Se){constructor({valueDec:e=-1,isFirstSid:r=!1,...n}={}){super(n),this.valueDec=e,this.isFirstSid=r}fromBER(e,r,n){if(!n)return r;let o=j.BufferSourceConverter.toUint8Array(e);if(!At(this,o,r,n))return-1;let i=o.subarray(r,r+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=hr(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),r+this.blockLength)}set valueBigInt(e){fo();let r=BigInt(e).toString(2);for(;r.length%7;)r="0"+r;let n=new Uint8Array(r.length/7);for(let o=0;o<n.length;o++)n[o]=parseInt(r.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 r=zt(this.valueDec,7);if(r.byteLength===0)return this.error="Error during encoding SID value",We;let n=new Uint8Array(r.byteLength);if(!e){let o=new Uint8Array(r),i=r.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 r=this.valueDec;this.valueDec<=39?e="0.":this.valueDec<=79?(e="1.",r-=40):(e="2.",r-=80),e+=r.toString()}else e=this.valueDec.toString();return e}toJSON(){return{...super.toJSON(),valueDec:this.valueDec,isFirstSid:this.isFirstSid}}};En.NAME="sidBlock";var So=class extends Se{constructor({value:e=qr,...r}={}){super(r),this.value=[],e&&this.fromString(e)}fromBER(e,r,n){let o=r;for(;n>0;){let i=new En;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 r=[];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,We;r.push(o)}return Es(r)}fromString(e){this.value=[];let r=0,n=0,o="",i=!1;do if(n=e.indexOf(".",r),n===-1?o=e.substring(r):o=e.substring(r,n),r=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 En;if(o>Number.MAX_SAFE_INTEGER){fo();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="",r=!1;for(let n=0;n<this.value.length;n++){r=this.value[n].isHexOnly;let o=this.value[n].toString();n!==0&&(e=`${e}.`),r?(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 r=0;r<this.value.length;r++)e.sidArray.push(this.value[r].toJSON());return e}};So.NAME="ObjectIdentifierValueBlock";var Yc,Ze=class extends xe{constructor(e={}){super(e,So),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()}}};Yc=Ze;_.ObjectIdentifier=Yc;Ze.NAME="OBJECT IDENTIFIER";var vn=class extends St(Et){constructor({valueDec:e=0,...r}={}){super(r),this.valueDec=e}fromBER(e,r,n){if(n===0)return r;let o=j.BufferSourceConverter.toUint8Array(e);if(!At(this,o,r,n))return-1;let i=o.subarray(r,r+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=hr(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),r+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 r=zt(this.valueDec,7);if(r.byteLength===0)return this.error="Error during encoding SID value",We;let n=new Uint8Array(r.byteLength);if(!e){let o=new Uint8Array(r),i=r.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}}};vn.NAME="relativeSidBlock";var Ro=class extends Se{constructor({value:e=qr,...r}={}){super(r),this.value=[],e&&this.fromString(e)}fromBER(e,r,n){let o=r;for(;n>0;){let i=new vn;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,r){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,We;n.push(i)}return Es(n)}fromString(e){this.value=[];let r=0,n=0,o="";do{n=e.indexOf(".",r),n===-1?o=e.substring(r):o=e.substring(r,n),r=n+1;let i=new vn;if(i.valueDec=parseInt(o,10),isNaN(i.valueDec))return!0;this.value.push(i)}while(n!==-1);return!0}toString(){let e="",r=!1;for(let n=0;n<this.value.length;n++){r=this.value[n].isHexOnly;let o=this.value[n].toString();n!==0&&(e=`${e}.`),r&&(o=`{${o}}`),e+=o}return e}toJSON(){let e={...super.toJSON(),value:this.toString(),sidArray:[]};for(let r=0;r<this.value.length;r++)e.sidArray.push(this.value[r].toJSON());return e}};Ro.NAME="RelativeObjectIdentifierValueBlock";var Zc,ko=class extends xe{constructor(e={}){super(e,Ro),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()}}};Zc=ko;_.RelativeObjectIdentifier=Zc;ko.NAME="RelativeObjectIdentifier";var Wc,de=class extends Gt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=16}};Wc=de;_.Sequence=Wc;de.NAME="SEQUENCE";var Jc,Io=class extends Gt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=17}};Jc=Io;_.Set=Jc;Io.NAME="SET";var To=class extends St(Se){constructor({...e}={}){super(e),this.isHexOnly=!0,this.value=qr}toJSON(){return{...super.toJSON(),value:this.value}}};To.NAME="StringValueBlock";var Co=class extends To{};Co.NAME="SimpleStringValueBlock";var Te=class extends go{constructor({...e}={}){super(e,Co)}fromBuffer(e){this.valueBlock.value=String.fromCharCode.apply(null,j.BufferSourceConverter.toUint8Array(e))}fromString(e){let r=e.length,n=this.valueBlock.valueHexView=new Uint8Array(r);for(let o=0;o<r;o++)n[o]=e.charCodeAt(o);this.valueBlock.value=e}};Te.NAME="SIMPLE STRING";var No=class extends Te{fromBuffer(e){this.valueBlock.valueHexView=j.BufferSourceConverter.toUint8Array(e);try{this.valueBlock.value=j.Convert.ToUtf8String(e)}catch(r){this.warnings.push(`Error during "decodeURIComponent": ${r}, 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}};No.NAME="Utf8StringValueBlock";var Xc,Bt=class extends No{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=12}};Xc=Bt;_.Utf8String=Xc;Bt.NAME="UTF8String";var _o=class extends Te{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))}};_o.NAME="BmpStringValueBlock";var Qc,Uo=class extends _o{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=30}};Qc=Uo;_.BmpString=Qc;Uo.NAME="BMPString";var Do=class extends Te{fromBuffer(e){let r=ArrayBuffer.isView(e)?e.slice().buffer:e.slice(0),n=new Uint8Array(r);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(r))}fromString(e){let r=e.length,n=this.valueBlock.valueHexView=new Uint8Array(r*4);for(let o=0;o<r;o++){let i=zt(e.charCodeAt(o),8),s=new Uint8Array(i);if(s.length>4)continue;let a=4-s.length;for(let c=s.length-1;c>=0;c--)n[o*4+c+a]=s[c]}this.valueBlock.value=e}};Do.NAME="UniversalStringValueBlock";var eu,Lo=class extends Do{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=28}};eu=Lo;_.UniversalString=eu;Lo.NAME="UniversalString";var tu,Vo=class extends Te{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=18}};tu=Vo;_.NumericString=tu;Vo.NAME="NumericString";var ru,Oo=class extends Te{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=19}};ru=Oo;_.PrintableString=ru;Oo.NAME="PrintableString";var nu,Fo=class extends Te{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=20}};nu=Fo;_.TeletexString=nu;Fo.NAME="TeletexString";var ou,Po=class extends Te{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=21}};ou=Po;_.VideotexString=ou;Po.NAME="VideotexString";var iu,Mo=class extends Te{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=22}};iu=Mo;_.IA5String=iu;Mo.NAME="IA5String";var su,Ho=class extends Te{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=25}};su=Ho;_.GraphicString=su;Ho.NAME="GraphicString";var au,Bn=class extends Te{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=26}};au=Bn;_.VisibleString=au;Bn.NAME="VisibleString";var cu,Ko=class extends Te{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=27}};cu=Ko;_.GeneralString=cu;Ko.NAME="GeneralString";var uu,$o=class extends Te{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=29}};uu=$o;_.CharacterString=uu;$o.NAME="CharacterString";var lu,An=class extends Bn{constructor({value:e,valueDate:r,...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)}r&&(this.fromDate(r),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(),r=new ArrayBuffer(e.length),n=new Uint8Array(r);for(let o=0;o<e.length;o++)n[o]=e.charCodeAt(o);return r}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 r=new Array(7);return r[0]=Ne(this.year<2e3?this.year-1900:this.year-2e3,2),r[1]=Ne(this.month,2),r[2]=Ne(this.day,2),r[3]=Ne(this.hour,2),r[4]=Ne(this.minute,2),r[5]=Ne(this.second,2),r[6]="Z",r.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}}};lu=An;_.UTCTime=lu;An.NAME="UTCTime";var fu,qo=class extends An{constructor(e={}){var r;super(e),(r=this.millisecond)!==null&&r!==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 r=!1,n="",o="",i=0,s,a=0,c=0;if(e[e.length-1]==="Z")n=e.substring(0,e.length-1),r=!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(r){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("+"),v="";if(d===-1&&(d=n.indexOf("-"),l=-1),d!==-1){if(v=n.substring(d+1),n=n.substring(0,d),v.length!==2&&v.length!==4)throw new Error("Wrong input string for conversion");let m=parseInt(v.substring(0,2),10);if(isNaN(m.valueOf()))throw new Error("Wrong input string for conversion");if(a=l*m,v.length===4){if(m=parseInt(v.substring(2,4),10),isNaN(m.valueOf()))throw new Error("Wrong input string for conversion");c=l*m}}}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(r===!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 r=[];return r.push(Ne(this.year,4)),r.push(Ne(this.month,2)),r.push(Ne(this.day,2)),r.push(Ne(this.hour,2)),r.push(Ne(this.minute,2)),r.push(Ne(this.second,2)),this.millisecond!==0&&(r.push("."),r.push(Ne(this.millisecond,3))),r.push("Z"),r.join("")}return super.toString(e)}toJSON(){return{...super.toJSON(),millisecond:this.millisecond}}};fu=qo;_.GeneralizedTime=fu;qo.NAME="GeneralizedTime";var hu,zo=class extends Bt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=31}};hu=zo;_.DATE=hu;zo.NAME="DATE";var du,Go=class extends Bt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=32}};du=Go;_.TimeOfDay=du;Go.NAME="TimeOfDay";var pu,jo=class extends Bt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=33}};pu=jo;_.DateTime=pu;jo.NAME="DateTime";var gu,Yo=class extends Bt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=34}};gu=Yo;_.Duration=gu;Yo.NAME="Duration";var mu,Zo=class extends Bt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=14}};mu=Zo;_.TIME=mu;Zo.NAME="TIME";function L0(t){let{result:e}=zr(t),r=e.valueBlock.value;return{n:te(ct(r[1].toBigInt()),"base64url"),e:te(ct(r[2].toBigInt()),"base64url"),d:te(ct(r[3].toBigInt()),"base64url"),p:te(ct(r[4].toBigInt()),"base64url"),q:te(ct(r[5].toBigInt()),"base64url"),dp:te(ct(r[6].toBigInt()),"base64url"),dq:te(ct(r[7].toBigInt()),"base64url"),qi:te(ct(r[8].toBigInt()),"base64url"),kty:"RSA",alg:"RS256"}}function V0(t){if(t.n==null||t.e==null||t.d==null||t.p==null||t.q==null||t.dp==null||t.dq==null||t.qi==null)throw new $("JWK was missing components","ERR_INVALID_PARAMETERS");let r=new de({value:[new ue({value:0}),ue.fromBigInt(ut(J(t.n,"base64url"))),ue.fromBigInt(ut(J(t.e,"base64url"))),ue.fromBigInt(ut(J(t.d,"base64url"))),ue.fromBigInt(ut(J(t.p,"base64url"))),ue.fromBigInt(ut(J(t.q,"base64url"))),ue.fromBigInt(ut(J(t.dp,"base64url"))),ue.fromBigInt(ut(J(t.dq,"base64url"))),ue.fromBigInt(ut(J(t.qi,"base64url")))]}).toBER();return new Uint8Array(r,0,r.byteLength)}function O0(t){let{result:e}=zr(t),r=e.valueBlock.value[1].valueBlock.value[0].valueBlock.value;return{kty:"RSA",n:te(ct(r[0].toBigInt()),"base64url"),e:te(ct(r[1].toBigInt()),"base64url")}}function F0(t){if(t.n==null||t.e==null)throw new $("JWK was missing components","ERR_INVALID_PARAMETERS");let r=new de({value:[new de({value:[new Ze({value:"1.2.840.113549.1.1.1"}),new jt]}),new $r({valueHex:new de({value:[ue.fromBigInt(ut(J(t.n,"base64url"))),ue.fromBigInt(ut(J(t.e,"base64url")))]}).toBER()})]}).toBER();return new Uint8Array(r,0,r.byteLength)}function ct(t){let e=t.toString(16);e.length%2>0&&(e=`0${e}`);let r=e.length/2,n=new Uint8Array(r),o=0,i=0;for(;o<r;)n[o]=parseInt(e.slice(i,i+2),16),o+=1,i+=2;return n}function ut(t){let e=[];return t.forEach(function(r){let n=r.toString(16);n.length%2>0&&(n=`0${n}`),e.push(n)}),BigInt("0x"+e.join(""))}var P0=16,Bs=32,As=1e4;async function M0(t,e){let r=ke.get(),o=new de({value:[new ue({value:0}),new de({value:[new Ze({value:"1.2.840.113549.1.1.1"}),new jt]}),new vt({valueHex:t.marshal()})]}).toBER(),i=new Uint8Array(o,0,o.byteLength),s=fr(P0),a=await ws(Lr,e,s,{c:As,dkLen:Bs}),c=fr(16),f=await r.subtle.importKey("raw",a,"AES-CBC",!1,["encrypt"]),u=await r.subtle.encrypt({name:"AES-CBC",iv:c},f,i),l=new de({value:[new vt({valueHex:s}),new ue({value:As}),new ue({value:Bs}),new de({value:[new Ze({value:"1.2.840.113549.2.11"}),new jt]})]}),d=new de({value:[new Ze({value:"1.2.840.113549.1.5.13"}),new de({value:[new de({value:[new Ze({value:"1.2.840.113549.1.5.12"}),l]}),new de({value:[new Ze({value:"2.16.840.1.101.3.4.1.42"}),new vt({valueHex:c})]})]})]}),m=new de({value:[d,new vt({valueHex:u})]}).toBER(),h=new Uint8Array(m,0,m.byteLength);return["-----BEGIN ENCRYPTED PRIVATE KEY-----",...te(h,"base64pad").split(/(.{64})/).filter(Boolean),"-----END ENCRYPTED PRIVATE KEY-----"].join(`
|
|
8
|
+
`)}async function H0(t,e){let r=ke.get(),n;if(t.includes("-----BEGIN ENCRYPTED PRIVATE KEY-----")){let o=J(t.replace("-----BEGIN ENCRYPTED PRIVATE KEY-----","").replace("-----END ENCRYPTED PRIVATE KEY-----","").replace(/\n/g,"").trim(),"base64pad"),{result:i}=zr(o),{iv:s,salt:a,iterations:c,keySize:f,cipherText:u}=K0(i),l=await ws(Lr,e,a,{c,dkLen:f}),d=await r.subtle.importKey("raw",l,"AES-CBC",!1,["decrypt"]),v=Sn(await r.subtle.decrypt({name:"AES-CBC",iv:s},d,u)),{result:m}=zr(v);n=yu(m)}else if(t.includes("-----BEGIN PRIVATE KEY-----")){let o=J(t.replace("-----BEGIN PRIVATE KEY-----","").replace("-----END PRIVATE KEY-----","").replace(/\n/g,"").trim(),"base64pad"),{result:i}=zr(o);n=yu(i)}else throw new $("Could not parse private key from PEM data","ERR_INVALID_PARAMETERS");return Ss(n)}function K0(t){let e=t.valueBlock.value[0];if(e.valueBlock.value[0].toString()!=="OBJECT IDENTIFIER : 1.2.840.113549.1.5.13")throw new $("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 $("Only pkcs5PBKDF2 key derivation functions are supported","ERR_INVALID_PARAMS");let i=n.valueBlock.value[1],s=Sn(i.valueBlock.value[0].getValue()),a=As,c=Bs;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 $("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 $("Only AES-CBC encryption schemes are supported","ERR_INVALID_PARAMS")}}}}let l=Sn(f.valueBlock.value[1].getValue());return{cipherText:Sn(t.valueBlock.value[1].getValue()),salt:s,iterations:a,keySize:c,iv:l}}function yu(t){return Sn(t.valueBlock.value[2].getValue())}function Sn(t){return new Uint8Array(t,0,t.byteLength)}async function wu(t){let e=await ke.get().subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:t,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-256"}},!0,["sign","verify"]),r=await Eu(e);return{privateKey:r[0],publicKey:r[1]}}async function Rs(t){let r=[await ke.get().subtle.importKey("jwk",t,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["sign"]),await $0(t)],n=await Eu({privateKey:r[0],publicKey:r[1]});return{privateKey:n[0],publicKey:n[1]}}async function bu(t,e){let r=await ke.get().subtle.importKey("jwk",t,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["sign"]),n=await ke.get().subtle.sign({name:"RSASSA-PKCS1-v1_5"},r,e instanceof Uint8Array?e:e.subarray());return new Uint8Array(n,0,n.byteLength)}async function xu(t,e,r){let n=await ke.get().subtle.importKey("jwk",t,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["verify"]);return ke.get().subtle.verify({name:"RSASSA-PKCS1-v1_5"},n,e,r instanceof Uint8Array?r:r.subarray())}async function Eu(t){if(t.privateKey==null||t.publicKey==null)throw new $("Private and public key are required","ERR_INVALID_PARAMETERS");return Promise.all([ke.get().subtle.exportKey("jwk",t.privateKey),ke.get().subtle.exportKey("jwk",t.publicKey)])}async function $0(t){return ke.get().subtle.importKey("jwk",{kty:t.kty,n:t.n,e:t.e},{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["verify"])}function Jo(t){if(t.kty!=="RSA")throw new $("invalid key type","ERR_INVALID_KEY_TYPE");if(t.n==null)throw new $("invalid key modulus","ERR_INVALID_KEY_MODULUS");return J(t.n,"base64url").length*8}var kn=8192,Rn=class{_key;constructor(e){this._key=e}verify(e,r){return xu(this._key,r,e)}marshal(){return Yt.jwkToPkix(this._key)}get bytes(){return it.encode({Type:oe.RSA,Data:this.marshal()}).subarray()}equals(e){return be(this.bytes,e.bytes)}hash(){let e=we.digest(this.bytes);return He(e)?e.then(({bytes:r})=>r):e.bytes}},Gr=class{_key;_publicKey;constructor(e,r){this._key=e,this._publicKey=r}genSecret(){return fr(16)}sign(e){return bu(this._key,e)}get public(){if(this._publicKey==null)throw new $("public key not provided","ERR_PUBKEY_NOT_PROVIDED");return new Rn(this._publicKey)}marshal(){return Yt.jwkToPkcs1(this._key)}get bytes(){return st.encode({Type:oe.RSA,Data:this.marshal()}).subarray()}equals(e){return be(this.bytes,e.bytes)}hash(){let e=we.digest(this.bytes);return He(e)?e.then(({bytes:r})=>r):e.bytes}async id(){let e=await this.public.hash();return te(e,"base58btc")}async export(e,r="pkcs-8"){if(r==="pkcs-8")return Yt.exportToPem(this,e);if(r==="libp2p-key")return Pr(this.bytes,e);throw new $(`export format '${r}' is not supported`,"ERR_INVALID_EXPORT_FORMAT")}};async function Ss(t){let e=Yt.pkcs1ToJwk(t);if(Jo(e)>kn)throw new $("key size is too large","ERR_KEY_SIZE_TOO_LARGE");let r=await Rs(e);return new Gr(r.privateKey,r.publicKey)}function z0(t){let e=Yt.pkixToJwk(t);if(Jo(e)>kn)throw new $("key size is too large","ERR_KEY_SIZE_TOO_LARGE");return new Rn(e)}async function G0(t){if(Jo(t)>kn)throw new $("key size is too large","ERR_KEY_SIZE_TOO_LARGE");let e=await Rs(t);return new Gr(e.privateKey,e.publicKey)}async function j0(t){if(t>kn)throw new $("key size is too large","ERR_KEY_SIZE_TOO_LARGE");let e=await wu(t);return new Gr(e.privateKey,e.publicKey)}var _s={};he(_s,{Secp256k1PrivateKey:()=>Tn,Secp256k1PublicKey:()=>In,generateKeyPair:()=>sp,unmarshalSecp256k1PrivateKey:()=>op,unmarshalSecp256k1PublicKey:()=>ip});var Y0=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Zt=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Wt=new Uint32Array(64),Is=class extends Dr{constructor(){super(64,32,8,!1),this.A=Zt[0]|0,this.B=Zt[1]|0,this.C=Zt[2]|0,this.D=Zt[3]|0,this.E=Zt[4]|0,this.F=Zt[5]|0,this.G=Zt[6]|0,this.H=Zt[7]|0}get(){let{A:e,B:r,C:n,D:o,E:i,F:s,G:a,H:c}=this;return[e,r,n,o,i,s,a,c]}set(e,r,n,o,i,s,a,c){this.A=e|0,this.B=r|0,this.C=n|0,this.D=o|0,this.E=i|0,this.F=s|0,this.G=a|0,this.H=c|0}process(e,r){for(let l=0;l<16;l++,r+=4)Wt[l]=e.getUint32(r,!1);for(let l=16;l<64;l++){let d=Wt[l-15],v=Wt[l-2],m=Ge(d,7)^Ge(d,18)^d>>>3,h=Ge(v,17)^Ge(v,19)^v>>>10;Wt[l]=h+Wt[l-7]+m+Wt[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=Ge(a,6)^Ge(a,11)^Ge(a,25),v=u+d+Ga(a,c,f)+Y0[l]+Wt[l]|0,h=(Ge(n,2)^Ge(n,13)^Ge(n,22))+ja(n,o,i)|0;u=f,f=c,c=a,a=s+v|0,s=i,i=o,o=n,n=v+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(){Wt.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var vu=jn(()=>new Is);function Z0(t){let e=ln(t);ot(e,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});let{endo:r,Fp:n,a:o}=e;if(r){if(!n.eql(o,n.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if(typeof r!="object"||typeof r.beta!="bigint"||typeof r.splitScalar!="function")throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...e})}var{bytesToNumberBE:W0,hexToBytes:J0}=Wn,dr={Err:class extends Error{constructor(e=""){super(e)}},_parseInt(t){let{Err:e}=dr;if(t.length<2||t[0]!==2)throw new e("Invalid signature integer tag");let r=t[1],n=t.subarray(2,r+2);if(!r||n.length!==r)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:W0(n),l:t.subarray(r+2)}},toSig(t){let{Err:e}=dr,r=typeof t=="string"?J0(t):t;Vr(r);let n=r.length;if(n<2||r[0]!=48)throw new e("Invalid signature tag");if(r[1]!==n-2)throw new e("Invalid signature: incorrect length");let{d:o,l:i}=dr._parseInt(r.subarray(2)),{d:s,l:a}=dr._parseInt(i);if(a.length)throw new e("Invalid signature: left bytes after parsing");return{r:o,s}},hexFromSig(t){let e=f=>Number.parseInt(f[0],16)&8?"00"+f:f,r=f=>{let u=f.toString(16);return u.length&1?`0${u}`:u},n=e(r(t.s)),o=e(r(t.r)),i=n.length/2,s=o.length/2,a=r(i),c=r(s);return`30${r(s+i+4)}02${c}${o}02${a}${n}`}},Rt=BigInt(0),$e=BigInt(1),Hw=BigInt(2),Bu=BigInt(3),Kw=BigInt(4);function X0(t){let e=Z0(t),{Fp:r}=e,n=e.toBytes||((m,h,p)=>{let b=h.toAffine();return yt(Uint8Array.from([4]),r.toBytes(b.x),r.toBytes(b.y))}),o=e.fromBytes||(m=>{let h=m.subarray(1),p=r.fromBytes(h.subarray(0,r.BYTES)),b=r.fromBytes(h.subarray(r.BYTES,2*r.BYTES));return{x:p,y:b}});function i(m){let{a:h,b:p}=e,b=r.sqr(m),k=r.mul(b,m);return r.add(r.add(k,r.mul(m,h)),p)}if(!r.eql(r.sqr(e.Gy),i(e.Gx)))throw new Error("bad generator point: equation left != right");function s(m){return typeof m=="bigint"&&Rt<m&&m<e.n}function a(m){if(!s(m))throw new Error("Expected valid bigint: 0 < bigint < curve.n")}function c(m){let{allowedPrivateKeyLengths:h,nByteLength:p,wrapPrivateKey:b,n:k}=e;if(h&&typeof m!="bigint"){if(Ot(m)&&(m=gt(m)),typeof m!="string"||!h.includes(m.length))throw new Error("Invalid key");m=m.padStart(p*2,"0")}let E;try{E=typeof m=="bigint"?m:mt(ae("private key",m,p))}catch{throw new Error(`private key must be ${p} bytes, hex or bigint, not ${typeof m}`)}return b&&(E=ee(E,k)),a(E),E}let f=new Map;function u(m){if(!(m 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||!r.isValid(h))throw new Error("x required");if(p==null||!r.isValid(p))throw new Error("y required");if(b==null||!r.isValid(b))throw new Error("z required")}static fromAffine(h){let{x:p,y:b}=h||{};if(!h||!r.isValid(p)||!r.isValid(b))throw new Error("invalid affine point");if(h instanceof l)throw new Error("projective point not allowed");let k=E=>r.eql(E,r.ZERO);return k(p)&&k(b)?l.ZERO:new l(p,b,r.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(h){let p=r.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(ae("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&&!r.is0(this.py))return;throw new Error("bad point: ZERO")}let{x:h,y:p}=this.toAffine();if(!r.isValid(h)||!r.isValid(p))throw new Error("bad point: x or y not FE");let b=r.sqr(p),k=i(h);if(!r.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(r.isOdd)return!r.isOdd(h);throw new Error("Field doesn't support isOdd")}equals(h){u(h);let{px:p,py:b,pz:k}=this,{px:E,py:D,pz:S}=h,I=r.eql(r.mul(p,S),r.mul(E,k)),N=r.eql(r.mul(b,S),r.mul(D,k));return I&&N}negate(){return new l(this.px,r.neg(this.py),this.pz)}double(){let{a:h,b:p}=e,b=r.mul(p,Bu),{px:k,py:E,pz:D}=this,S=r.ZERO,I=r.ZERO,N=r.ZERO,y=r.mul(k,k),C=r.mul(E,E),V=r.mul(D,D),T=r.mul(k,E);return T=r.add(T,T),N=r.mul(k,D),N=r.add(N,N),S=r.mul(h,N),I=r.mul(b,V),I=r.add(S,I),S=r.sub(C,I),I=r.add(C,I),I=r.mul(S,I),S=r.mul(T,S),N=r.mul(b,N),V=r.mul(h,V),T=r.sub(y,V),T=r.mul(h,T),T=r.add(T,N),N=r.add(y,y),y=r.add(N,y),y=r.add(y,V),y=r.mul(y,T),I=r.add(I,y),V=r.mul(E,D),V=r.add(V,V),y=r.mul(V,T),S=r.sub(S,y),N=r.mul(V,C),N=r.add(N,N),N=r.add(N,N),new l(S,I,N)}add(h){u(h);let{px:p,py:b,pz:k}=this,{px:E,py:D,pz:S}=h,I=r.ZERO,N=r.ZERO,y=r.ZERO,C=e.a,V=r.mul(e.b,Bu),T=r.mul(p,E),O=r.mul(b,D),M=r.mul(k,S),Z=r.add(p,b),x=r.add(E,D);Z=r.mul(Z,x),x=r.add(T,O),Z=r.sub(Z,x),x=r.add(p,k);let A=r.add(E,S);return x=r.mul(x,A),A=r.add(T,M),x=r.sub(x,A),A=r.add(b,k),I=r.add(D,S),A=r.mul(A,I),I=r.add(O,M),A=r.sub(A,I),y=r.mul(C,x),I=r.mul(V,M),y=r.add(I,y),I=r.sub(O,y),y=r.add(O,y),N=r.mul(I,y),O=r.add(T,T),O=r.add(O,T),M=r.mul(C,M),x=r.mul(V,x),O=r.add(O,M),M=r.sub(T,M),M=r.mul(C,M),x=r.add(x,M),T=r.mul(O,x),N=r.add(N,T),T=r.mul(A,x),I=r.mul(Z,I),I=r.sub(I,T),T=r.mul(Z,O),y=r.mul(A,y),y=r.add(y,T),new l(I,N,y)}subtract(h){return this.add(h.negate())}is0(){return this.equals(l.ZERO)}wNAF(h){return v.wNAFCached(this,f,h,p=>{let b=r.invertBatch(p.map(k=>k.pz));return p.map((k,E)=>k.toAffine(b[E])).map(l.fromAffine)})}multiplyUnsafe(h){let p=l.ZERO;if(h===Rt)return p;if(a(h),h===$e)return this;let{endo:b}=e;if(!b)return v.unsafeLadder(this,h);let{k1neg:k,k1:E,k2neg:D,k2:S}=b.splitScalar(h),I=p,N=p,y=this;for(;E>Rt||S>Rt;)E&$e&&(I=I.add(y)),S&$e&&(N=N.add(y)),y=y.double(),E>>=$e,S>>=$e;return k&&(I=I.negate()),D&&(N=N.negate()),N=new l(r.mul(N.px,b.beta),N.py,N.pz),I.add(N)}multiply(h){a(h);let p=h,b,k,{endo:E}=e;if(E){let{k1neg:D,k1:S,k2neg:I,k2:N}=E.splitScalar(p),{p:y,f:C}=this.wNAF(S),{p:V,f:T}=this.wNAF(N);y=v.constTimeNegate(D,y),V=v.constTimeNegate(I,V),V=new l(r.mul(V.px,E.beta),V.py,V.pz),b=y.add(V),k=C.add(T)}else{let{p:D,f:S}=this.wNAF(p);b=D,k=S}return l.normalizeZ([b,k])[0]}multiplyAndAddUnsafe(h,p,b){let k=l.BASE,E=(S,I)=>I===Rt||I===$e||!S.equals(k)?S.multiplyUnsafe(I):S.multiply(I),D=E(this,p).add(E(h,b));return D.is0()?void 0:D}toAffine(h){let{px:p,py:b,pz:k}=this,E=this.is0();h==null&&(h=E?r.ONE:r.inv(k));let D=r.mul(p,h),S=r.mul(b,h),I=r.mul(k,h);if(E)return{x:r.ZERO,y:r.ZERO};if(!r.eql(I,r.ONE))throw new Error("invZ was invalid");return{x:D,y:S}}isTorsionFree(){let{h,isTorsionFree:p}=e;if(h===$e)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===$e?this:p?p(l,this):this.multiplyUnsafe(e.h)}toRawBytes(h=!0){return this.assertValidity(),n(l,this,h)}toHex(h=!0){return gt(this.toRawBytes(h))}}l.BASE=new l(e.Gx,e.Gy,r.ONE),l.ZERO=new l(r.ZERO,r.ONE,r.ZERO);let d=e.nBitLength,v=Qn(l,e.endo?Math.ceil(d/2):d);return{CURVE:e,ProjectivePoint:l,normPrivateKeyToScalar:c,weierstrassEquation:i,isWithinCurveOrder:s}}function Q0(t){let e=ln(t);return ot(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function Au(t){let e=Q0(t),{Fp:r,n}=e,o=r.BYTES+1,i=2*r.BYTES+1;function s(x){return Rt<x&&x<r.ORDER}function a(x){return ee(x,n)}function c(x){return Jn(x,n)}let{ProjectivePoint:f,normPrivateKeyToScalar:u,weierstrassEquation:l,isWithinCurveOrder:d}=X0({...e,toBytes(x,A,P){let B=A.toAffine(),w=r.toBytes(B.x),L=yt;return P?L(Uint8Array.from([A.hasEvenY()?2:3]),w):L(Uint8Array.from([4]),w,r.toBytes(B.y))},fromBytes(x){let A=x.length,P=x[0],B=x.subarray(1);if(A===o&&(P===2||P===3)){let w=mt(B);if(!s(w))throw new Error("Point is not on curve");let L=l(w),F;try{F=r.sqrt(L)}catch(G){let Q=G instanceof Error?": "+G.message:"";throw new Error("Point is not on curve"+Q)}let H=(F&$e)===$e;return(P&1)===1!==H&&(F=r.neg(F)),{x:w,y:F}}else if(A===i&&P===4){let w=r.fromBytes(B.subarray(0,r.BYTES)),L=r.fromBytes(B.subarray(r.BYTES,2*r.BYTES));return{x:w,y:L}}else throw new Error(`Point of length ${A} was invalid. Expected ${o} compressed bytes or ${i} uncompressed bytes`)}}),v=x=>gt(Pt(x,e.nByteLength));function m(x){let A=n>>$e;return x>A}function h(x){return m(x)?a(-x):x}let p=(x,A,P)=>mt(x.slice(A,P));class b{constructor(A,P,B){this.r=A,this.s=P,this.recovery=B,this.assertValidity()}static fromCompact(A){let P=e.nByteLength;return A=ae("compactSignature",A,P*2),new b(p(A,0,P),p(A,P,2*P))}static fromDER(A){let{r:P,s:B}=dr.toSig(ae("DER",A));return new b(P,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:P,s:B,recovery:w}=this,L=N(ae("msgHash",A));if(w==null||![0,1,2,3].includes(w))throw new Error("recovery id invalid");let F=w===2||w===3?P+e.n:P;if(F>=r.ORDER)throw new Error("recovery id 2 or 3 invalid");let H=w&1?"03":"02",z=f.fromHex(H+v(F)),G=c(F),Q=a(-L*G),Y=a(B*G),W=f.BASE.multiplyAndAddUnsafe(z,Q,Y);if(!W)throw new Error("point at infinify");return W.assertValidity(),W}hasHighS(){return m(this.s)}normalizeS(){return this.hasHighS()?new b(this.r,a(-this.s),this.recovery):this}toDERRawBytes(){return ir(this.toDERHex())}toDERHex(){return dr.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return ir(this.toCompactHex())}toCompactHex(){return v(this.r)+v(this.s)}}let k={isValidPrivateKey(x){try{return u(x),!0}catch{return!1}},normPrivateKeyToScalar:u,randomPrivateKey:()=>{let x=Qi(e.n);return oc(e.randomBytes(x),e.n)},precompute(x=8,A=f.BASE){return A._setWindowSize(x),A.multiply(BigInt(3)),A}};function E(x,A=!0){return f.fromPrivateKey(x).toRawBytes(A)}function D(x){let A=Ot(x),P=typeof x=="string",B=(A||P)&&x.length;return A?B===o||B===i:P?B===2*o||B===2*i:x instanceof f}function S(x,A,P=!0){if(D(x))throw new Error("first arg must be private key");if(!D(A))throw new Error("second arg must be public key");return f.fromHex(A).multiply(u(x)).toRawBytes(P)}let I=e.bits2int||function(x){let A=mt(x),P=x.length*8-e.nBitLength;return P>0?A>>BigInt(P):A},N=e.bits2int_modN||function(x){return a(I(x))},y=un(e.nBitLength);function C(x){if(typeof x!="bigint")throw new Error("bigint expected");if(!(Rt<=x&&x<y))throw new Error(`bigint expected < 2^${e.nBitLength}`);return Pt(x,e.nByteLength)}function V(x,A,P=T){if(["recovered","canonical"].some(ie=>ie in P))throw new Error("sign() legacy options not supported");let{hash:B,randomBytes:w}=e,{lowS:L,prehash:F,extraEntropy:H}=P;L==null&&(L=!0),x=ae("msgHash",x),F&&(x=ae("prehashed msgHash",B(x)));let z=N(x),G=u(A),Q=[C(G),C(z)];if(H!=null&&H!==!1){let ie=H===!0?w(r.BYTES):H;Q.push(ae("extraEntropy",ie))}let Y=yt(...Q),W=z;function ce(ie){let ge=I(ie);if(!d(ge))return;let me=c(ge),le=f.BASE.multiply(ge).toAffine(),Be=a(le.x);if(Be===Rt)return;let ft=a(me*a(W+Be*G));if(ft===Rt)return;let Qt=(le.x===Be?0:2)|Number(le.y&$e),tn=ft;return L&&m(ft)&&(tn=h(ft),Qt^=1),new b(Be,tn,Qt)}return{seed:Y,k2sig:ce}}let T={lowS:e.lowS,prehash:!1},O={lowS:e.lowS,prehash:!1};function M(x,A,P=T){let{seed:B,k2sig:w}=V(x,A,P),L=e;return Zi(L.hash.outputLen,L.nByteLength,L.hmac)(B,w)}f.BASE._setWindowSize(8);function Z(x,A,P,B=O){let w=x;if(A=ae("msgHash",A),P=ae("publicKey",P),"strict"in B)throw new Error("options.strict was renamed to lowS");let{lowS:L,prehash:F}=B,H,z;try{if(typeof w=="string"||Ot(w))try{H=b.fromDER(w)}catch(le){if(!(le instanceof dr.Err))throw le;H=b.fromCompact(w)}else if(typeof w=="object"&&typeof w.r=="bigint"&&typeof w.s=="bigint"){let{r:le,s:Be}=w;H=new b(le,Be)}else throw new Error("PARSE");z=f.fromHex(P)}catch(le){if(le.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(L&&H.hasHighS())return!1;F&&(A=e.hash(A));let{r:G,s:Q}=H,Y=N(A),W=c(Q),ce=a(Y*W),ie=a(G*W),ge=f.BASE.multiplyAndAddUnsafe(z,ce,ie)?.toAffine();return ge?a(ge.x)===G:!1}return{CURVE:e,getPublicKey:E,getSharedSecret:S,sign:M,verify:Z,ProjectivePoint:f,Signature:b,utils:k}}function ep(t){return{hash:t,hmac:(e,...r)=>mn(t,e,Gn(...r)),randomBytes:Ur}}function Su(t,e){let r=n=>Au({...t,...ep(n)});return Object.freeze({...r(e),create:r})}var Iu=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),Ru=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),tp=BigInt(1),Ts=BigInt(2),ku=(t,e)=>(t+e/Ts)/e;function rp(t){let e=Iu,r=BigInt(3),n=BigInt(6),o=BigInt(11),i=BigInt(22),s=BigInt(23),a=BigInt(44),c=BigInt(88),f=t*t*t%e,u=f*f*t%e,l=ne(u,r,e)*u%e,d=ne(l,r,e)*u%e,v=ne(d,Ts,e)*f%e,m=ne(v,o,e)*v%e,h=ne(m,i,e)*m%e,p=ne(h,a,e)*h%e,b=ne(p,c,e)*p%e,k=ne(b,a,e)*h%e,E=ne(k,r,e)*u%e,D=ne(E,s,e)*m%e,S=ne(D,n,e)*f%e,I=ne(S,Ts,e);if(!Cs.eql(Cs.sqr(I),t))throw new Error("Cannot find square root");return I}var Cs=Xn(Iu,void 0,void 0,{sqrt:rp}),Je=Su({a:BigInt(0),b:BigInt(7),Fp:Cs,n:Ru,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:t=>{let e=Ru,r=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-tp*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),i=r,s=BigInt("0x100000000000000000000000000000000"),a=ku(i*t,e),c=ku(-n*t,e),f=ee(t-a*r-c*o,e),u=ee(-a*n-c*i,e),l=f>s,d=u>s;if(l&&(f=e-f),d&&(u=e-u),f>s||u>s)throw new Error("splitScalar: Endomorphism failed, k="+t);return{k1neg:l,k1:f,k2neg:d,k2:u}}}},vu),Jw=BigInt(0);var Xw=Je.ProjectivePoint;function Tu(){return Je.utils.randomPrivateKey()}function Cu(t,e){let r=we.digest(e instanceof Uint8Array?e:e.subarray());if(He(r))return r.then(({digest:n})=>Je.sign(n,t).toDERRawBytes()).catch(n=>{throw new $(String(n),"ERR_INVALID_INPUT")});try{return Je.sign(r.digest,t).toDERRawBytes()}catch(n){throw new $(String(n),"ERR_INVALID_INPUT")}}function Nu(t,e,r){let n=we.digest(r instanceof Uint8Array?r:r.subarray());if(He(n))return n.then(({digest:o})=>Je.verify(e,o,t)).catch(o=>{throw new $(String(o),"ERR_INVALID_INPUT")});try{return Je.verify(e,n.digest,t)}catch(o){throw new $(String(o),"ERR_INVALID_INPUT")}}function _u(t){return Je.ProjectivePoint.fromHex(t).toRawBytes(!0)}function Uu(t){try{Je.getPublicKey(t,!0)}catch(e){throw new $(String(e),"ERR_INVALID_PRIVATE_KEY")}}function Ns(t){try{Je.ProjectivePoint.fromHex(t)}catch(e){throw new $(String(e),"ERR_INVALID_PUBLIC_KEY")}}function Du(t){try{return Je.getPublicKey(t,!0)}catch(e){throw new $(String(e),"ERR_INVALID_PRIVATE_KEY")}}var In=class{_key;constructor(e){Ns(e),this._key=e}verify(e,r){return Nu(this._key,r,e)}marshal(){return _u(this._key)}get bytes(){return it.encode({Type:oe.Secp256k1,Data:this.marshal()}).subarray()}equals(e){return be(this.bytes,e.bytes)}async hash(){let e=we.digest(this.bytes),r;return He(e)?{bytes:r}=await e:r=e.bytes,r}},Tn=class{_key;_publicKey;constructor(e,r){this._key=e,this._publicKey=r??Du(e),Uu(this._key),Ns(this._publicKey)}sign(e){return Cu(this._key,e)}get public(){return new In(this._publicKey)}marshal(){return this._key}get bytes(){return st.encode({Type:oe.Secp256k1,Data:this.marshal()}).subarray()}equals(e){return be(this.bytes,e.bytes)}hash(){let e=we.digest(this.bytes);return He(e)?e.then(({bytes:r})=>r):e.bytes}async id(){let e=await this.public.hash();return te(e,"base58btc")}async export(e,r="libp2p-key"){if(r==="libp2p-key")return Pr(this.bytes,e);throw new $(`export format '${r}' is not supported`,"ERR_INVALID_EXPORT_FORMAT")}};function op(t){return new Tn(t)}function ip(t){return new In(t)}async function sp(){let t=Tu();return new Tn(t)}var pr={rsa:ks,ed25519:ys,secp256k1:_s};function Lu(t){let e=Object.keys(pr).join(" / ");return new $(`invalid or unsupported key type ${t}. Must be ${e}`,"ERR_UNSUPPORTED_KEY_TYPE")}function Us(t){let e=it.decode(t),r=e.Data??new Uint8Array;switch(e.Type){case oe.RSA:return pr.rsa.unmarshalRsaPublicKey(r);case oe.Ed25519:return pr.ed25519.unmarshalEd25519PublicKey(r);case oe.Secp256k1:return pr.secp256k1.unmarshalSecp256k1PublicKey(r);default:throw Lu(e.Type??"unknown")}}async function Vu(t){let e=st.decode(t),r=e.Data??new Uint8Array;switch(e.Type){case oe.RSA:return pr.rsa.unmarshalRsaPrivateKey(r);case oe.Ed25519:return pr.ed25519.unmarshalEd25519PrivateKey(r);case oe.Secp256k1:return pr.secp256k1.unmarshalSecp256k1PrivateKey(r);default:throw Lu(e.Type??"RSA")}}var Ys=ht(Xo(),1);var kt="/",Pu=new TextEncoder().encode(kt),Qo=Pu[0],jr=class t{_buf;constructor(e,r){if(typeof e=="string")this._buf=J(e);else if(e instanceof Uint8Array)this._buf=e;else throw new Error("Invalid key, should be String of Uint8Array");if(r==null&&(r=!0),r&&this.clean(),this._buf.byteLength===0||this._buf[0]!==Qo)throw new Error("Invalid key")}toString(e="utf8"){return te(this._buf,e)}uint8Array(){return this._buf}get[Symbol.toStringTag](){return`Key(${this.toString()})`}static withNamespaces(e){return new t(e.join(kt))}static random(){return new t(Math.random().toString().substring(2))}static asKey(e){return e instanceof Uint8Array||typeof e=="string"?new t(e):typeof e.uint8Array=="function"?new t(e.uint8Array()):null}clean(){if((this._buf==null||this._buf.byteLength===0)&&(this._buf=Pu),this._buf[0]!==Qo){let e=new Uint8Array(this._buf.byteLength+1);e.fill(Qo,0,1),e.set(this._buf,1),this._buf=e}for(;this._buf.byteLength>1&&this._buf[this._buf.byteLength-1]===Qo;)this._buf=this._buf.subarray(0,-1)}less(e){let r=this.list(),n=e.list();for(let o=0;o<r.length;o++){if(n.length<o+1)return!1;let i=r[o],s=n[o];if(i<s)return!0;if(i>s)return!1}return r.length<n.length}reverse(){return t.withNamespaces(this.list().slice().reverse())}namespaces(){return this.list()}baseNamespace(){let e=this.namespaces();return e[e.length-1]}list(){return this.toString().split(kt).slice(1)}type(){return cp(this.baseNamespace())}name(){return up(this.baseNamespace())}instance(e){return new t(this.toString()+":"+e)}path(){let e=this.parent().toString();return e.endsWith(kt)||(e+=kt),e+=this.type(),new t(e)}parent(){let e=this.list();return e.length===1?new t(kt):new t(e.slice(0,-1).join(kt))}child(e){return this.toString()===kt?e:e.toString()===kt?this:new t(this.toString()+e.toString(),!1)}isAncestorOf(e){return e.toString()===this.toString()?!1:e.toString().startsWith(this.toString())}isDecendantOf(e){return e.toString()===this.toString()?!1:this.toString().startsWith(e.toString())}isTopLevel(){return this.list().length===1}concat(...e){return t.withNamespaces([...this.namespaces(),...lp(e.map(r=>r.namespaces()))])}};function cp(t){let e=t.split(":");return e.length<2?"":e.slice(0,-1).join(":")}function up(t){let e=t.split(":");return e[e.length-1]}function lp(t){return[].concat(...t)}var sf=ht(ei(),1);var Mu="ERR_IPNS_EXPIRED_RECORD",Cn="ERR_UNRECOGNIZED_VALIDITY",Hu="ERR_SIGNATURE_CREATION",It="ERR_SIGNATURE_VERIFICATION";var Ls="ERR_UNDEFINED_PARAMETER",Ku="ERR_INVALID_RECORD_DATA",$u="ERR_INVALID_VALUE",qu="ERR_INVALID_EMBEDDED_KEY",zu="ERR_MISSING_PRIVATE_KEY",Gu="ERR_RECORD_TOO_LARGE";var Ee;(function(t){let e;(function(o){o.EOL="EOL"})(e=t.ValidityType||(t.ValidityType={}));let r;(function(o){o[o.EOL=0]="EOL"})(r||(r={})),function(o){o.codec=()=>pn(r)}(e=t.ValidityType||(t.ValidityType={}));let n;t.codec=()=>(n==null&&(n=qt((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),t.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=t.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),t.encode=o=>$t(o,t.codec()),t.decode=o=>Kt(o,t.codec())})(Ee||(Ee={}));var fp=["string","number","bigint","symbol"],hp=["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 ju(t){if(t===null)return"null";if(t===void 0)return"undefined";if(t===!0||t===!1)return"boolean";let e=typeof t;if(fp.includes(e))return e;if(e==="function")return"Function";if(Array.isArray(t))return"Array";if(dp(t))return"Buffer";let r=pp(t);return r||"Object"}function dp(t){return t&&t.constructor&&t.constructor.isBuffer&&t.constructor.isBuffer.call(null,t)}function pp(t){let e=Object.prototype.toString.call(t).slice(8,-1);if(hp.includes(e))return e}var g=class{constructor(e,r,n){this.major=e,this.majorEncoded=e<<5,this.name=r,this.terminal=n}toString(){return`Type[${this.major}].${this.name}`}compare(e){return this.major<e.major?-1:this.major>e.major?1:0}};g.uint=new g(0,"uint",!0);g.negint=new g(1,"negint",!0);g.bytes=new g(2,"bytes",!0);g.string=new g(3,"string",!0);g.array=new g(4,"array",!1);g.map=new g(5,"map",!1);g.tag=new g(6,"tag",!1);g.float=new g(7,"float",!0);g.false=new g(7,"false",!0);g.true=new g(7,"true",!0);g.null=new g(7,"null",!0);g.undefined=new g(7,"undefined",!0);g.break=new g(7,"break",!0);var U=class{constructor(e,r,n){this.type=e,this.value=r,this.encodedLength=n,this.encodedBytes=void 0,this.byteValue=void 0}toString(){return`Token[${this.type}].${this.value}`}};var Yr=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&typeof globalThis.Buffer.isBuffer=="function",gp=new TextDecoder,mp=new TextEncoder;function ti(t){return Yr&&globalThis.Buffer.isBuffer(t)}function Os(t){return t instanceof Uint8Array?ti(t)?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):t:Uint8Array.from(t)}var Ju=Yr?(t,e,r)=>r-e>64?globalThis.Buffer.from(t.subarray(e,r)).toString("utf8"):Zu(t,e,r):(t,e,r)=>r-e>64?gp.decode(t.subarray(e,r)):Zu(t,e,r),Xu=Yr?t=>t.length>64?globalThis.Buffer.from(t):Yu(t):t=>t.length>64?mp.encode(t):Yu(t),lt=t=>Uint8Array.from(t),Zr=Yr?(t,e,r)=>ti(t)?new Uint8Array(t.subarray(e,r)):t.slice(e,r):(t,e,r)=>t.slice(e,r),Qu=Yr?(t,e)=>(t=t.map(r=>r instanceof Uint8Array?r:globalThis.Buffer.from(r)),Os(globalThis.Buffer.concat(t,e))):(t,e)=>{let r=new Uint8Array(e),n=0;for(let o of t)n+o.length>r.length&&(o=o.subarray(0,r.length-n)),r.set(o,n),n+=o.length;return r},el=Yr?t=>globalThis.Buffer.allocUnsafe(t):t=>new Uint8Array(t);function tl(t,e){if(ti(t)&&ti(e))return t.compare(e);for(let r=0;r<t.length;r++)if(t[r]!==e[r])return t[r]<e[r]?-1:1;return 0}function Yu(t){let e=[],r=0;for(let n=0;n<t.length;n++){let o=t.charCodeAt(n);o<128?e[r++]=o:o<2048?(e[r++]=o>>6|192,e[r++]=o&63|128):(o&64512)===55296&&n+1<t.length&&(t.charCodeAt(n+1)&64512)===56320?(o=65536+((o&1023)<<10)+(t.charCodeAt(++n)&1023),e[r++]=o>>18|240,e[r++]=o>>12&63|128,e[r++]=o>>6&63|128,e[r++]=o&63|128):(e[r++]=o>>12|224,e[r++]=o>>6&63|128,e[r++]=o&63|128)}return e}function Zu(t,e,r){let n=[];for(;e<r;){let o=t[e],i=null,s=o>239?4:o>223?3:o>191?2:1;if(e+s<=r){let a,c,f,u;switch(s){case 1:o<128&&(i=o);break;case 2:a=t[e+1],(a&192)===128&&(u=(o&31)<<6|a&63,u>127&&(i=u));break;case 3:a=t[e+1],c=t[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=t[e+1],c=t[e+2],f=t[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 yp(n)}var Wu=4096;function yp(t){let e=t.length;if(e<=Wu)return String.fromCharCode.apply(String,t);let r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=Wu));return r}var wp=256,Nn=class{constructor(e=wp){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 r=this.chunks[this.chunks.length-1];if(this.cursor+e.length<=this.maxCursor+1){let o=r.length-(this.maxCursor-this.cursor)-1;r.set(e,o)}else{if(r){let o=r.length-(this.maxCursor-this.cursor)-1;o<r.length&&(this.chunks[this.chunks.length-1]=r.subarray(0,o),this.maxCursor=this.cursor-1)}e.length<64&&e.length<this.chunkSize?(r=el(this.chunkSize),this.chunks.push(r),this.maxCursor+=r.length,this._initReuseChunk===null&&(this._initReuseChunk=r),r.set(e,0)):(this.chunks.push(e),this.maxCursor+=e.length)}this.cursor+=e.length}toBytes(e=!1){let r;if(this.chunks.length===1){let n=this.chunks[0];e&&this.cursor>n.length/2?(r=this.cursor===n.length?n:n.subarray(0,this.cursor),this._initReuseChunk=null,this.chunks=[]):r=Zr(n,0,this.cursor)}else r=Qu(this.chunks,this.cursor);return e&&this.reset(),r}};var K="CBOR decode error:",Fs="CBOR encode error:",_n=[];_n[23]=1;_n[24]=2;_n[25]=3;_n[26]=5;_n[27]=9;function Tt(t,e,r){if(t.length-e<r)throw new Error(`${K} not enough data for type`)}var pe=[24,256,65536,4294967296,BigInt("18446744073709551616")];function Oe(t,e,r){Tt(t,e,1);let n=t[e];if(r.strict===!0&&n<pe[0])throw new Error(`${K} integer encoded in more bytes than necessary (strict decode)`);return n}function Fe(t,e,r){Tt(t,e,2);let n=t[e]<<8|t[e+1];if(r.strict===!0&&n<pe[1])throw new Error(`${K} integer encoded in more bytes than necessary (strict decode)`);return n}function Pe(t,e,r){Tt(t,e,4);let n=t[e]*16777216+(t[e+1]<<16)+(t[e+2]<<8)+t[e+3];if(r.strict===!0&&n<pe[2])throw new Error(`${K} integer encoded in more bytes than necessary (strict decode)`);return n}function Me(t,e,r){Tt(t,e,8);let n=t[e]*16777216+(t[e+1]<<16)+(t[e+2]<<8)+t[e+3],o=t[e+4]*16777216+(t[e+5]<<16)+(t[e+6]<<8)+t[e+7],i=(BigInt(n)<<BigInt(32))+BigInt(o);if(r.strict===!0&&i<pe[3])throw new Error(`${K} integer encoded in more bytes than necessary (strict decode)`);if(i<=Number.MAX_SAFE_INTEGER)return Number(i);if(r.allowBigInt===!0)return i;throw new Error(`${K} integers outside of the safe integer range are not supported`)}function rl(t,e,r,n){return new U(g.uint,Oe(t,e+1,n),2)}function nl(t,e,r,n){return new U(g.uint,Fe(t,e+1,n),3)}function ol(t,e,r,n){return new U(g.uint,Pe(t,e+1,n),5)}function il(t,e,r,n){return new U(g.uint,Me(t,e+1,n),9)}function qe(t,e){return ve(t,0,e.value)}function ve(t,e,r){if(r<pe[0]){let n=Number(r);t.push([e|n])}else if(r<pe[1]){let n=Number(r);t.push([e|24,n])}else if(r<pe[2]){let n=Number(r);t.push([e|25,n>>>8,n&255])}else if(r<pe[3]){let n=Number(r);t.push([e|26,n>>>24&255,n>>>16&255,n>>>8&255,n&255])}else{let n=BigInt(r);if(n<pe[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,t.push(o)}else throw new Error(`${K} encountered BigInt larger than allowable range`)}}qe.encodedSize=function(e){return ve.encodedSize(e.value)};ve.encodedSize=function(e){return e<pe[0]?1:e<pe[1]?2:e<pe[2]?3:e<pe[3]?5:9};qe.compareTokens=function(e,r){return e.value<r.value?-1:e.value>r.value?1:0};function sl(t,e,r,n){return new U(g.negint,-1-Oe(t,e+1,n),2)}function al(t,e,r,n){return new U(g.negint,-1-Fe(t,e+1,n),3)}function cl(t,e,r,n){return new U(g.negint,-1-Pe(t,e+1,n),5)}var Ps=BigInt(-1),ul=BigInt(1);function ll(t,e,r,n){let o=Me(t,e+1,n);if(typeof o!="bigint"){let i=-1-o;if(i>=Number.MIN_SAFE_INTEGER)return new U(g.negint,i,9)}if(n.allowBigInt!==!0)throw new Error(`${K} integers outside of the safe integer range are not supported`);return new U(g.negint,Ps-BigInt(o),9)}function ri(t,e){let r=e.value,n=typeof r=="bigint"?r*Ps-ul:r*-1-1;ve(t,e.type.majorEncoded,n)}ri.encodedSize=function(e){let r=e.value,n=typeof r=="bigint"?r*Ps-ul:r*-1-1;return n<pe[0]?1:n<pe[1]?2:n<pe[2]?3:n<pe[3]?5:9};ri.compareTokens=function(e,r){return e.value<r.value?1:e.value>r.value?-1:0};function Un(t,e,r,n){Tt(t,e,r+n);let o=Zr(t,e+r,e+r+n);return new U(g.bytes,o,r+n)}function fl(t,e,r,n){return Un(t,e,1,r)}function hl(t,e,r,n){return Un(t,e,2,Oe(t,e+1,n))}function dl(t,e,r,n){return Un(t,e,3,Fe(t,e+1,n))}function pl(t,e,r,n){return Un(t,e,5,Pe(t,e+1,n))}function gl(t,e,r,n){let o=Me(t,e+1,n);if(typeof o=="bigint")throw new Error(`${K} 64-bit integer bytes lengths not supported`);return Un(t,e,9,o)}function ni(t){return t.encodedBytes===void 0&&(t.encodedBytes=t.type===g.string?Xu(t.value):t.value),t.encodedBytes}function Wr(t,e){let r=ni(e);ve(t,e.type.majorEncoded,r.length),t.push(r)}Wr.encodedSize=function(e){let r=ni(e);return ve.encodedSize(r.length)+r.length};Wr.compareTokens=function(e,r){return xp(ni(e),ni(r))};function xp(t,e){return t.length<e.length?-1:t.length>e.length?1:tl(t,e)}function Dn(t,e,r,n,o){let i=r+n;Tt(t,e,i);let s=new U(g.string,Ju(t,e+r,e+i),i);return o.retainStringBytes===!0&&(s.byteValue=Zr(t,e+r,e+i)),s}function ml(t,e,r,n){return Dn(t,e,1,r,n)}function yl(t,e,r,n){return Dn(t,e,2,Oe(t,e+1,n),n)}function wl(t,e,r,n){return Dn(t,e,3,Fe(t,e+1,n),n)}function bl(t,e,r,n){return Dn(t,e,5,Pe(t,e+1,n),n)}function xl(t,e,r,n){let o=Me(t,e+1,n);if(typeof o=="bigint")throw new Error(`${K} 64-bit integer string lengths not supported`);return Dn(t,e,9,o,n)}var El=Wr;function Jr(t,e,r,n){return new U(g.array,n,r)}function vl(t,e,r,n){return Jr(t,e,1,r)}function Bl(t,e,r,n){return Jr(t,e,2,Oe(t,e+1,n))}function Al(t,e,r,n){return Jr(t,e,3,Fe(t,e+1,n))}function Sl(t,e,r,n){return Jr(t,e,5,Pe(t,e+1,n))}function Rl(t,e,r,n){let o=Me(t,e+1,n);if(typeof o=="bigint")throw new Error(`${K} 64-bit integer array lengths not supported`);return Jr(t,e,9,o)}function kl(t,e,r,n){if(n.allowIndefinite===!1)throw new Error(`${K} indefinite length items not allowed`);return Jr(t,e,1,1/0)}function oi(t,e){ve(t,g.array.majorEncoded,e.value)}oi.compareTokens=qe.compareTokens;oi.encodedSize=function(e){return ve.encodedSize(e.value)};function Xr(t,e,r,n){return new U(g.map,n,r)}function Il(t,e,r,n){return Xr(t,e,1,r)}function Tl(t,e,r,n){return Xr(t,e,2,Oe(t,e+1,n))}function Cl(t,e,r,n){return Xr(t,e,3,Fe(t,e+1,n))}function Nl(t,e,r,n){return Xr(t,e,5,Pe(t,e+1,n))}function _l(t,e,r,n){let o=Me(t,e+1,n);if(typeof o=="bigint")throw new Error(`${K} 64-bit integer map lengths not supported`);return Xr(t,e,9,o)}function Ul(t,e,r,n){if(n.allowIndefinite===!1)throw new Error(`${K} indefinite length items not allowed`);return Xr(t,e,1,1/0)}function ii(t,e){ve(t,g.map.majorEncoded,e.value)}ii.compareTokens=qe.compareTokens;ii.encodedSize=function(e){return ve.encodedSize(e.value)};function Dl(t,e,r,n){return new U(g.tag,r,1)}function Ll(t,e,r,n){return new U(g.tag,Oe(t,e+1,n),2)}function Vl(t,e,r,n){return new U(g.tag,Fe(t,e+1,n),3)}function Ol(t,e,r,n){return new U(g.tag,Pe(t,e+1,n),5)}function Fl(t,e,r,n){return new U(g.tag,Me(t,e+1,n),9)}function si(t,e){ve(t,g.tag.majorEncoded,e.value)}si.compareTokens=qe.compareTokens;si.encodedSize=function(e){return ve.encodedSize(e.value)};var Rp=20,kp=21,Ip=22,Tp=23;function Pl(t,e,r,n){if(n.allowUndefined===!1)throw new Error(`${K} undefined values are not supported`);return n.coerceUndefinedToNull===!0?new U(g.null,null,1):new U(g.undefined,void 0,1)}function Ml(t,e,r,n){if(n.allowIndefinite===!1)throw new Error(`${K} indefinite length items not allowed`);return new U(g.break,void 0,1)}function Ms(t,e,r){if(r){if(r.allowNaN===!1&&Number.isNaN(t))throw new Error(`${K} NaN values are not supported`);if(r.allowInfinity===!1&&(t===1/0||t===-1/0))throw new Error(`${K} Infinity values are not supported`)}return new U(g.float,t,e)}function Hl(t,e,r,n){return Ms(Hs(t,e+1),3,n)}function Kl(t,e,r,n){return Ms(Ks(t,e+1),5,n)}function $l(t,e,r,n){return Ms(jl(t,e+1),9,n)}function ai(t,e,r){let n=e.value;if(n===!1)t.push([g.float.majorEncoded|Rp]);else if(n===!0)t.push([g.float.majorEncoded|kp]);else if(n===null)t.push([g.float.majorEncoded|Ip]);else if(n===void 0)t.push([g.float.majorEncoded|Tp]);else{let o,i=!1;(!r||r.float64!==!0)&&(zl(n),o=Hs(Xe,1),n===o||Number.isNaN(n)?(Xe[0]=249,t.push(Xe.slice(0,3)),i=!0):(Gl(n),o=Ks(Xe,1),n===o&&(Xe[0]=250,t.push(Xe.slice(0,5)),i=!0))),i||(Cp(n),o=jl(Xe,1),Xe[0]=251,t.push(Xe.slice(0,9)))}}ai.encodedSize=function(e,r){let n=e.value;if(n===!1||n===!0||n===null||n===void 0)return 1;if(!r||r.float64!==!0){zl(n);let o=Hs(Xe,1);if(n===o||Number.isNaN(n))return 3;if(Gl(n),o=Ks(Xe,1),n===o)return 5}return 9};var ql=new ArrayBuffer(9),ze=new DataView(ql,1),Xe=new Uint8Array(ql,0);function zl(t){if(t===1/0)ze.setUint16(0,31744,!1);else if(t===-1/0)ze.setUint16(0,64512,!1);else if(Number.isNaN(t))ze.setUint16(0,32256,!1);else{ze.setFloat32(0,t);let e=ze.getUint32(0),r=(e&2139095040)>>23,n=e&8388607;if(r===255)ze.setUint16(0,31744,!1);else if(r===0)ze.setUint16(0,(t&2147483648)>>16|n>>13,!1);else{let o=r-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 Hs(t,e){if(t.length-e<2)throw new Error(`${K} not enough data for float16`);let r=(t[e]<<8)+t[e+1];if(r===31744)return 1/0;if(r===64512)return-1/0;if(r===32256)return NaN;let n=r>>10&31,o=r&1023,i;return n===0?i=o*2**-24:n!==31?i=(o+1024)*2**(n-25):i=o===0?1/0:NaN,r&32768?-i:i}function Gl(t){ze.setFloat32(0,t,!1)}function Ks(t,e){if(t.length-e<4)throw new Error(`${K} not enough data for float32`);let r=(t.byteOffset||0)+e;return new DataView(t.buffer,r,4).getFloat32(0,!1)}function Cp(t){ze.setFloat64(0,t,!1)}function jl(t,e){if(t.length-e<8)throw new Error(`${K} not enough data for float64`);let r=(t.byteOffset||0)+e;return new DataView(t.buffer,r,8).getFloat64(0,!1)}ai.compareTokens=qe.compareTokens;function X(t,e,r){throw new Error(`${K} encountered invalid minor (${r}) for major ${t[e]>>>5}`)}function ci(t){return()=>{throw new Error(`${K} ${t}`)}}var R=[];for(let t=0;t<=23;t++)R[t]=X;R[24]=rl;R[25]=nl;R[26]=ol;R[27]=il;R[28]=X;R[29]=X;R[30]=X;R[31]=X;for(let t=32;t<=55;t++)R[t]=X;R[56]=sl;R[57]=al;R[58]=cl;R[59]=ll;R[60]=X;R[61]=X;R[62]=X;R[63]=X;for(let t=64;t<=87;t++)R[t]=fl;R[88]=hl;R[89]=dl;R[90]=pl;R[91]=gl;R[92]=X;R[93]=X;R[94]=X;R[95]=ci("indefinite length bytes/strings are not supported");for(let t=96;t<=119;t++)R[t]=ml;R[120]=yl;R[121]=wl;R[122]=bl;R[123]=xl;R[124]=X;R[125]=X;R[126]=X;R[127]=ci("indefinite length bytes/strings are not supported");for(let t=128;t<=151;t++)R[t]=vl;R[152]=Bl;R[153]=Al;R[154]=Sl;R[155]=Rl;R[156]=X;R[157]=X;R[158]=X;R[159]=kl;for(let t=160;t<=183;t++)R[t]=Il;R[184]=Tl;R[185]=Cl;R[186]=Nl;R[187]=_l;R[188]=X;R[189]=X;R[190]=X;R[191]=Ul;for(let t=192;t<=215;t++)R[t]=Dl;R[216]=Ll;R[217]=Vl;R[218]=Ol;R[219]=Fl;R[220]=X;R[221]=X;R[222]=X;R[223]=X;for(let t=224;t<=243;t++)R[t]=ci("simple values are not supported");R[244]=X;R[245]=X;R[246]=X;R[247]=Pl;R[248]=ci("simple values are not supported");R[249]=Hl;R[250]=Kl;R[251]=$l;R[252]=X;R[253]=X;R[254]=X;R[255]=Ml;var Qe=[];for(let t=0;t<24;t++)Qe[t]=new U(g.uint,t,1);for(let t=-1;t>=-24;t--)Qe[31-t]=new U(g.negint,t,1);Qe[64]=new U(g.bytes,new Uint8Array(0),1);Qe[96]=new U(g.string,"",1);Qe[128]=new U(g.array,0,1);Qe[160]=new U(g.map,0,1);Qe[244]=new U(g.false,!1,1);Qe[245]=new U(g.true,!0,1);Qe[246]=new U(g.null,null,1);function Yl(t){switch(t.type){case g.false:return lt([244]);case g.true:return lt([245]);case g.null:return lt([246]);case g.bytes:return t.value.length?void 0:lt([64]);case g.string:return t.value===""?lt([96]):void 0;case g.array:return t.value===0?lt([128]):void 0;case g.map:return t.value===0?lt([160]):void 0;case g.uint:return t.value<24?lt([Number(t.value)]):void 0;case g.negint:if(t.value>=-24)return lt([31-Number(t.value)])}}var _p={float64:!1,mapSorter:Lp,quickEncodeToken:Yl};function Up(){let t=[];return t[g.uint.major]=qe,t[g.negint.major]=ri,t[g.bytes.major]=Wr,t[g.string.major]=El,t[g.array.major]=oi,t[g.map.major]=ii,t[g.tag.major]=si,t[g.float.major]=ai,t}var Zl=Up(),$s=new Nn,li=class t{constructor(e,r){this.obj=e,this.parent=r}includes(e){let r=this;do if(r.obj===e)return!0;while(r=r.parent);return!1}static createCheck(e,r){if(e&&e.includes(r))throw new Error(`${Fs} object contains circular references`);return new t(r,e)}},Jt={null:new U(g.null,null),undefined:new U(g.undefined,void 0),true:new U(g.true,!0),false:new U(g.false,!1),emptyArray:new U(g.array,0),emptyMap:new U(g.map,0)},Xt={number(t,e,r,n){return!Number.isInteger(t)||!Number.isSafeInteger(t)?new U(g.float,t):t>=0?new U(g.uint,t):new U(g.negint,t)},bigint(t,e,r,n){return t>=BigInt(0)?new U(g.uint,t):new U(g.negint,t)},Uint8Array(t,e,r,n){return new U(g.bytes,t)},string(t,e,r,n){return new U(g.string,t)},boolean(t,e,r,n){return t?Jt.true:Jt.false},null(t,e,r,n){return Jt.null},undefined(t,e,r,n){return Jt.undefined},ArrayBuffer(t,e,r,n){return new U(g.bytes,new Uint8Array(t))},DataView(t,e,r,n){return new U(g.bytes,new Uint8Array(t.buffer,t.byteOffset,t.byteLength))},Array(t,e,r,n){if(!t.length)return r.addBreakTokens===!0?[Jt.emptyArray,new U(g.break)]:Jt.emptyArray;n=li.createCheck(n,t);let o=[],i=0;for(let s of t)o[i++]=ui(s,r,n);return r.addBreakTokens?[new U(g.array,t.length),o,new U(g.break)]:[new U(g.array,t.length),o]},Object(t,e,r,n){let o=e!=="Object",i=o?t.keys():Object.keys(t),s=o?t.size:i.length;if(!s)return r.addBreakTokens===!0?[Jt.emptyMap,new U(g.break)]:Jt.emptyMap;n=li.createCheck(n,t);let a=[],c=0;for(let f of i)a[c++]=[ui(f,r,n),ui(o?t.get(f):t[f],r,n)];return Dp(a,r),r.addBreakTokens?[new U(g.map,s),a,new U(g.break)]:[new U(g.map,s),a]}};Xt.Map=Xt.Object;Xt.Buffer=Xt.Uint8Array;for(let t of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))Xt[`${t}Array`]=Xt.DataView;function ui(t,e={},r){let n=ju(t),o=e&&e.typeEncoders&&e.typeEncoders[n]||Xt[n];if(typeof o=="function"){let s=o(t,n,e,r);if(s!=null)return s}let i=Xt[n];if(!i)throw new Error(`${Fs} unsupported type: ${n}`);return i(t,n,e,r)}function Dp(t,e){e.mapSorter&&t.sort(e.mapSorter)}function Lp(t,e){let r=Array.isArray(t[0])?t[0][0]:t[0],n=Array.isArray(e[0])?e[0][0]:e[0];if(r.type!==n.type)return r.type.compare(n.type);let o=r.type.major,i=Zl[o].compareTokens(r,n);return i===0&&console.warn("WARNING: complex key types used, CBOR key sorting guarantees are gone"),i}function Wl(t,e,r,n){if(Array.isArray(e))for(let o of e)Wl(t,o,r,n);else r[e.type.major](t,e,n)}function Vp(t,e,r){let n=ui(t,r);if(!Array.isArray(n)&&r.quickEncodeToken){let o=r.quickEncodeToken(n);if(o)return o;let i=e[n.type.major];if(i.encodedSize){let s=i.encodedSize(n,r),a=new Nn(s);if(i(a,n,r),a.chunks.length!==1)throw new Error(`Unexpected error: pre-calculated length for ${n} was wrong`);return Os(a.chunks[0])}}return $s.reset(),Wl($s,n,e,r),$s.toBytes(!0)}function qs(t,e){return e=Object.assign({},_p,e),Vp(t,Zl,e)}var Op={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0},fi=class{constructor(e,r={}){this._pos=0,this.data=e,this.options=r}pos(){return this._pos}done(){return this._pos>=this.data.length}next(){let e=this.data[this._pos],r=Qe[e];if(r===void 0){let n=R[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;r=n(this.data,this._pos,o,this.options)}return this._pos+=r.encodedLength,r}},Ln=Symbol.for("DONE"),hi=Symbol.for("BREAK");function Fp(t,e,r){let n=[];for(let o=0;o<t.value;o++){let i=Qr(e,r);if(i===hi){if(t.value===1/0)break;throw new Error(`${K} got unexpected break to lengthed array`)}if(i===Ln)throw new Error(`${K} found array but not enough entries (got ${o}, expected ${t.value})`);n[o]=i}return n}function Pp(t,e,r){let n=r.useMaps===!0,o=n?void 0:{},i=n?new Map:void 0;for(let s=0;s<t.value;s++){let a=Qr(e,r);if(a===hi){if(t.value===1/0)break;throw new Error(`${K} got unexpected break to lengthed map`)}if(a===Ln)throw new Error(`${K} found map but not enough entries (got ${s} [no key], expected ${t.value})`);if(n!==!0&&typeof a!="string")throw new Error(`${K} non-string keys not supported (got ${typeof a})`);if(r.rejectDuplicateMapKeys===!0&&(n&&i.has(a)||!n&&a in o))throw new Error(`${K} found repeat map key "${a}"`);let c=Qr(e,r);if(c===Ln)throw new Error(`${K} found map but not enough entries (got ${s} [no value], expected ${t.value})`);n?i.set(a,c):o[a]=c}return n?i:o}function Qr(t,e){if(t.done())return Ln;let r=t.next();if(r.type===g.break)return hi;if(r.type.terminal)return r.value;if(r.type===g.array)return Fp(r,t,e);if(r.type===g.map)return Pp(r,t,e);if(r.type===g.tag){if(e.tags&&typeof e.tags[r.value]=="function"){let n=Qr(t,e);return e.tags[r.value](n)}throw new Error(`${K} tag not supported (${r.value})`)}throw new Error("unsupported")}function Jl(t,e){if(!(t instanceof Uint8Array))throw new Error(`${K} data to decode must be a Uint8Array`);e=Object.assign({},Op,e);let r=e.tokenizer||new fi(t,e),n=Qr(r,e);if(n===Ln)throw new Error(`${K} did not find any content to decode`);if(n===hi)throw new Error(`${K} got unexpected break`);return[n,t.subarray(r.pos())]}function zs(t,e){let[r,n]=Jl(t,e);if(n.length>0)throw new Error(`${K} too many terminals, data makes no sense`);return r}var _e=ht(Xo(),1);var Xl=Ut("ipns:utils"),Ql=J("/ipns/"),Hp=114,ef=async(t,e)=>{if(e==null||t==null){let n=new Error("one or more of the provided parameters are not defined");throw Xl.error(n),(0,_e.default)(n,Ls)}let r;if(e.pubKey!=null){try{r=Us(e.pubKey)}catch(o){throw Xl.error(o),o}if(!(await Ma(e.pubKey)).equals(t))throw(0,_e.default)(new Error("Embedded public key did not match PeerID"),qu)}else t.publicKey!=null&&(r=Us(t.publicKey));if(r!=null)return r;throw(0,_e.default)(new Error("no public key is available"),Ls)},tf=(t,e,r)=>{let n=J(e);return or([t,r,n])},di=t=>{let e=J("ipns-signature:");return or([e,t])},Gs=t=>"signatureV1"in t?Ee.encode({value:J(t.value),signatureV1:t.signatureV1,validityType:t.validityType,validity:J(t.validity),sequence:t.sequence,ttl:t.ttl,pubKey:t.pubKey,signatureV2:t.signatureV2,data:t.data}):Ee.encode({pubKey:t.pubKey,signatureV2:t.signatureV2,data:t.data});function Ct(t){let e=Ee.decode(t);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,_e.default)(new Error("missing data or signatureV2"),It);let r=of(e.data),n=js(r.Value),o=te(r.Validity);if(e.value!=null&&e.signatureV1!=null)return Kp(e),{value:n,validityType:Ee.ValidityType.EOL,validity:o,sequence:r.Sequence,ttl:r.TTL,pubKey:e.pubKey,signatureV1:e.signatureV1,signatureV2:e.signatureV2,data:e.data};if(e.signatureV2!=null)return{value:n,validityType:Ee.ValidityType.EOL,validity:o,sequence:r.Sequence,ttl:r.TTL,pubKey:e.pubKey,signatureV2:e.signatureV2,data:e.data};throw new Error("invalid record: does not include signatureV1 or signatureV2")}var pi=t=>or([Ql,t.toBytes()]),rf=t=>Ki(t.slice(Ql.length)),nf=(t,e,r,n,o)=>{let i;if(e===Ee.ValidityType.EOL)i=0;else throw(0,_e.default)(new Error("Unknown validity type"),Cn);return qs({Value:t,Validity:r,ValidityType:i,Sequence:n,TTL:o})},of=t=>{let e=zs(t);if(e.ValidityType===0)e.ValidityType=Ee.ValidityType.EOL;else throw(0,_e.default)(new Error("Unknown validity type"),Cn);return Number.isInteger(e.Sequence)&&(e.Sequence=BigInt(e.Sequence)),Number.isInteger(e.TTL)&&(e.TTL=BigInt(e.TTL)),e},js=t=>{if(t!=null){if(da(t))return`/ipns/${t.toCID().toString(Hn)}`;if(t instanceof Uint8Array){let n=te(t);n.startsWith("/")&&(t=n)}let e=t.toString().trim();if(e.startsWith("/")&&e.length>1)return e;let r=Re.asCID(t);if(r!=null)return r.code===Hp?`/ipns/${r.toString(Hn)}`:`/ipfs/${r.toV1().toString()}`;try{return t instanceof Uint8Array?`/ipfs/${Re.decode(t).toV1().toString()}`:`/ipfs/${Re.parse(e).toV1().toString()}`}catch{}}throw(0,_e.default)(new Error("Value must be a valid content path starting with /"),$u)},Kp=t=>{if(t.data==null)throw(0,_e.default)(new Error("Record data is missing"),Ku);let e=of(t.data);if(!be(e.Value,t.value??new Uint8Array(0)))throw(0,_e.default)(new Error('Field "value" did not match between protobuf and CBOR'),It);if(!be(e.Validity,t.validity??new Uint8Array(0)))throw(0,_e.default)(new Error('Field "validity" did not match between protobuf and CBOR'),It);if(e.ValidityType!==t.validityType)throw(0,_e.default)(new Error('Field "validityType" did not match between protobuf and CBOR'),It);if(e.Sequence!==t.sequence)throw(0,_e.default)(new Error('Field "sequence" did not match between protobuf and CBOR'),It);if(e.TTL!==t.ttl)throw(0,_e.default)(new Error('Field "ttl" did not match between protobuf and CBOR'),It)};var $p=Ut("ipns"),qp=rt.code,zp="/ipns/",Fx=zp.length,af={v1Compatible:!0};async function cf(t,e,r,n,o=af){let i=new sf.default(Date.now()+Number(n)),s=Ee.ValidityType.EOL,[a,c]=n.toString().split("."),f=BigInt(a)*BigInt(1e5)+BigInt(c??"0");return Gp(t,e,r,s,i.toString(),f,o)}var Gp=async(t,e,r,n,o,i,s=af)=>{r=BigInt(r);let a=J(o),c=js(e),f=J(c);if(t.privateKey==null)throw(0,Ys.default)(new Error("Missing private key"),zu);let u=await Vu(t.privateKey),l=nf(f,n,a,r,i),d=di(l),v=await u.sign(d),m;if(t.publicKey!=null){let h=rr(t.toBytes());(h.code!==qp||!be(t.publicKey,h.digest))&&(m=t.publicKey)}if(s.v1Compatible===!0){let h=await jp(u,f,n,a),p={value:c,signatureV1:h,validity:o,validityType:n,sequence:r,ttl:i,signatureV2:v,data:l};return m!=null&&(p.pubKey=m),p}else{let h={value:c,validity:o,validityType:n,sequence:r,ttl:i,signatureV2:v,data:l};return m!=null&&(h.pubKey=m),h}};var jp=async(t,e,r,n)=>{try{let o=tf(e,r,n);return await t.sign(o)}catch(o){throw $p.error("record signature creation failed",o),(0,Ys.default)(new Error("record signature creation failed"),Hu)}};var Zs=ht(ei(),1);function gi(t,e){let r=e.map((n,o)=>({record:Ct(n),index:o}));return r.sort((n,o)=>{let i=n.record.sequence,s=o.record.sequence;if(i>s)return-1;if(i<s)return 1;if(n.record.validityType===Ee.ValidityType.EOL&&o.record.validityType===Ee.ValidityType.EOL){let a=Zs.default.fromString(n.record.validity).toDate(),c=Zs.default.fromString(o.record.validity).toDate();if(a.getTime()>c.getTime())return-1;if(a.getTime()<c.getTime())return 1}return 0}),r[0].index}var Vn=ht(Xo(),1),uf=ht(ei(),1);var mi=Ut("ipns:validator"),Yp=1024*10,Zp=async(t,e)=>{let r=Ct(e),n;try{let o=di(r.data);n=await t.verify(o,r.signatureV2)}catch{n=!1}if(!n)throw mi.error("record signature verification failed"),(0,Vn.default)(new Error("record signature verification failed"),It);if(r.validityType===Ee.ValidityType.EOL){if(uf.default.fromString(r.validity).toDate().getTime()<Date.now())throw mi.error("record has expired"),(0,Vn.default)(new Error("record has expired"),Mu)}else if(r.validityType!=null)throw mi.error("unrecognized validity type"),(0,Vn.default)(new Error("unrecognized validity type"),Cn);mi("ipns record for %s is valid",r.value)};async function Ws(t,e){if(e.byteLength>Yp)throw(0,Vn.default)(new Error("record too large"),Gu);let r=rf(t),n=Ct(e),o=await ef(r,n);await Zp(o,e)}var Ce=class extends Event{constructor(e,r){super(e),this.detail=r}};var Js=60;function Xs(t){return{Status:t.Status??0,TC:t.TC??t.flag_tc??!1,RD:t.RD??t.flag_rd??!1,RA:t.RA??t.flag_ra??!1,AD:t.AD??t.flag_ad??!1,CD:t.CD??t.flag_cd??!1,Question:(t.Question??t.questions??[]).map(e=>({name:e.name,type:et[e.type]})),Answer:(t.Answer??t.answers??[]).map(e=>({name:e.name,type:et[e.type],TTL:e.TTL??e.ttl??Js,data:e.data instanceof Uint8Array?te(e.data):e.data}))}}var hf=ht(ff(),1);var Qs=class{lru;constructor(e){this.lru=(0,hf.default)(e)}get(e,r){let n=!0,o=[];for(let i of r){let s=this.getAnswers(e,i);if(s.length===0){n=!1;break}o.push(...s)}if(n)return Xs({answers:o})}getAnswers(e,r){let n=`${e.toLowerCase()}-${r}`,o=this.lru.get(n);if(o!=null){let i=o.filter(s=>s.expires>Date.now()).map(({value:s})=>({...s,type:et[s.type]}));return i.length===0&&this.lru.remove(n),i}return[]}add(e,r){let n=`${e.toLowerCase()}-${r.type}`,o=this.lru.get(n)??[];o.push({expires:Date.now()+(r.TTL??Js)*1e3,value:r}),this.lru.set(n,o)}remove(e,r){let n=`${e.toLowerCase()}-${r}`;this.lru.remove(n)}clear(){this.lru.clear()}},Jp=new Qs(1e3);var et;(function(t){t[t.A=1]="A",t[t.CNAME=5]="CNAME",t[t.TXT=16]="TXT",t[t.AAAA=28]="AAAA"})(et||(et={}));var Xp=32;async function df(t,e,r,n,o={}){if(e===0)throw new Error("recursion limit exceeded");n("query %s for TXT and CNAME records",t);let s=(await r.query(t,{...o,types:[et.TXT]})).Answer.sort((f,u)=>f.data.localeCompare(u.data));n("found %d TXT records for %s",s.length,t);for(let f of s)try{let u=f.data;if(u.startsWith('"')&&u.endsWith('"')&&(u=u.substring(1,u.length-1)),!u.startsWith("dnslink="))continue;n("%s TXT %s",f.name,u),u=u.replace("dnslink=","");let[,l,d,...v]=u.split("/");if(l==="ipfs")try{return`/ipfs/${Re.parse(d)}${v.length>0?`/${v.join("/")}`:""}`}catch{}else if(l==="ipns"){try{return`/ipns/${cn(d)}${v.length>0?`/${v.join("/")}`:""}`}catch{}return await yi(d,e-1,r,n,o)}else{if(l==="dnslink")return await yi(d,e-1,r,n,o);n('unknown protocol "%s" in DNSLink record for domain: %s',l,t);continue}}catch(u){n.error("could not parse DNS link record for domain %s, %s",t,f.data,u)}n("no DNSLink records found for %s, falling back to CNAME",t);let c=(await r.query(t,{...o,types:[et.CNAME]})).Answer.sort((f,u)=>f.data.localeCompare(u.data));n("found %d CNAME records for %s",c.length,t);for(let f of c)try{return await yi(f.data,e-1,r,n,o)}catch(u){n.error("domain %s cname %s had no DNSLink records",t,f.data,u)}throw new $(`No DNSLink records found for domain: ${t}`,"ERR_DNSLINK_NOT_FOUND")}async function yi(t,e,r,n,o={}){if(e===0)throw new Error("recursion limit exceeded");t.startsWith("_dnslink.")||(t=`_dnslink.${t}`);try{return await df(t,e,r,n,o)}catch(i){if(i.code!=="ENOTFOUND"&&i.code!=="ERR_DNSLINK_NOT_FOUND"&&i.code!=="ENODATA")throw i;return t.startsWith("_dnslink.")?t=t.replace("_dnslink.",""):t=`_dnslink.${t}`,await df(t,e,r,n,o)}}async function pf(t,e,r,n={}){return yi(t,n.maxRecursiveDepth??Xp,e,r,n)}var ea=class{routing;constructor(e){this.routing=e}async put(e,r,n={}){try{await this.routing.put(e,r,n)}catch(o){n.onProgress?.(new Ce("ipns:routing:helia:error",o))}}async get(e,r={}){try{return await this.routing.get(e,r)}catch(n){r.onProgress?.(new Ce("ipns:routing:helia:error",n))}throw new Error("Not found")}};function gf(t){return new ea(t)}var On;(function(t){let e;t.codec=()=>(e==null&&(e=qt((r,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),r.key!=null&&r.key.byteLength>0&&(n.uint32(10),n.bytes(r.key)),r.value!=null&&r.value.byteLength>0&&(n.uint32(18),n.bytes(r.value)),r.timeReceived!=null&&r.timeReceived!==""&&(n.uint32(42),n.string(r.timeReceived)),o.lengthDelimited!==!1&&n.ldelim()},(r,n)=>{let o={key:new Uint8Array(0),value:new Uint8Array(0),timeReceived:""},i=n==null?r.len:r.pos+n;for(;r.pos<i;){let s=r.uint32();switch(s>>>3){case 1:o.key=r.bytes();break;case 2:o.value=r.bytes();break;case 5:o.timeReceived=r.string();break;default:r.skipType(s&7);break}}return o})),e),t.encode=r=>$t(r,t.codec()),t.decode=r=>Kt(r,t.codec())})(On||(On={}));function mf(t){let e=t.getUTCFullYear(),r=String(t.getUTCMonth()+1).padStart(2,"0"),n=String(t.getUTCDate()).padStart(2,"0"),o=String(t.getUTCHours()).padStart(2,"0"),i=String(t.getUTCMinutes()).padStart(2,"0"),s=String(t.getUTCSeconds()).padStart(2,"0"),a=t.getUTCMilliseconds(),c=String(a*1e3*1e3).padStart(9,"0");return`${e}-${r}-${n}T${o}:${i}:${s}.${c}Z`}function yf(t){let e=new RegExp("(\\d{4})-(\\d{2})-(\\d{2})T(\\d{2}):(\\d{2}):(\\d{2})\\.(\\d+)Z"),r=String(t).trim().match(e);if(r==null)throw new Error("Invalid format");let n=parseInt(r[1],10),o=parseInt(r[2],10)-1,i=parseInt(r[3],10),s=parseInt(r[4],10),a=parseInt(r[5],10),c=parseInt(r[6],10),f=parseInt(r[7].slice(0,-6),10);return new Date(Date.UTC(n,o,i,s,a,c,f))}var en=class t{key;value;timeReceived;constructor(e,r,n){if(!(e instanceof Uint8Array))throw new Error("key must be a Uint8Array");if(!(r instanceof Uint8Array))throw new Error("value must be a Uint8Array");this.key=e,this.value=r,this.timeReceived=n}serialize(){return On.encode(this.prepareSerialize())}prepareSerialize(){return{key:this.key,value:this.value,timeReceived:mf(this.timeReceived)}}static deserialize(e){let r=On.decode(e);return new t(r.key,r.value,new Date(r.timeReceived))}static fromDeserialized(e){let r=yf(e.timeReceived);if(e.key==null)throw new Error("key missing from deserialized object");if(e.value==null)throw new Error("value missing from deserialized object");return new t(e.key,e.value,r)}};var wf;(function(t){t[t.SEND_QUERY=0]="SEND_QUERY",t[t.PEER_RESPONSE=1]="PEER_RESPONSE",t[t.FINAL_PEER=2]="FINAL_PEER",t[t.QUERY_ERROR=3]="QUERY_ERROR",t[t.PROVIDER=4]="PROVIDER",t[t.VALUE=5]="VALUE",t[t.ADD_PEER=6]="ADD_PEER",t[t.DIAL_PEER=7]="DIAL_PEER"})(wf||(wf={}));function ta(t){return new jr("/dht/record/"+te(t,"base32"),!1)}function bf(t){return{async put(e,r,n={}){try{let o=ta(e),i=new en(e,r,new Date);n.onProgress?.(new Ce("ipns:routing:datastore:put")),await t.put(o,i.serialize(),n)}catch(o){throw n.onProgress?.(new Ce("ipns:routing:datastore:error",o)),o}},async get(e,r={}){try{let n=ta(e);r.onProgress?.(new Ce("ipns:routing:datastore:get"));let o=await t.get(n,r);return en.deserialize(o).value}catch(n){throw r.onProgress?.(new Ce("ipns:routing:datastore:error",n)),n}},async has(e,r={}){let n=ta(e);return t.has(n,r)}}}var mr=Ut("helia:ipns"),eg=60*1e3,xf=60*eg,tg=24*xf,ra=23*xf,na=class{routers;localStore;timeout;dns;log;constructor(e,r=[]){this.routers=[gf(e.routing),...r],this.localStore=bf(e.datastore),this.dns=e.dns,this.log=e.logger.forComponent("helia:ipns")}async publish(e,r,n={}){try{let o=1n,i=pi(e);if(await this.localStore.has(i,n)){let c=await this.localStore.get(i,n);o=Ct(c).sequence+1n}let s=await cf(e,r,o,n.lifetime??tg,n),a=Gs(s);return await this.localStore.put(i,a,n),n.offline!==!0&&await Promise.all(this.routers.map(async c=>{await c.put(i,a,n)})),s}catch(o){throw n.onProgress?.(new Ce("ipns:publish:error",o)),o}}async resolve(e,r={}){let n=pi(e),o=await this.#t(n,r);return this.#e(o.value,r)}async resolveDNSLink(e,r={}){let n=await pf(e,this.dns,this.log,r);return this.#e(n,r)}republish(e={}){if(this.timeout!=null)throw new Error("Republish is already running");e.signal?.addEventListener("abort",()=>{clearTimeout(this.timeout)});async function r(){let n=Date.now();e.onProgress?.(new Ce("ipns:republish:start"));let i=Date.now()-n,s=ra-i;s<0&&(s=e.interval??ra),setTimeout(()=>{r().catch(a=>{mr.error("error republishing",a)})},s)}this.timeout=setTimeout(()=>{r().catch(n=>{mr.error("error republishing",n)})},e.interval??ra)}async#e(e,r={}){let n=e.split("/");try{let o=n[1];if(o==="ipns"){let{cid:i}=await this.resolve(cn(n[2]),r),s=n.slice(3).join("/");return{cid:i,path:s}}else if(o==="ipfs"){let i=Re.parse(n[2]),s=n.slice(3).join("/");return{cid:i,path:s}}}catch(o){mr.error("error parsing ipfs path",o)}throw mr.error("invalid ipfs path %s",e),new Error("Invalid value")}async#t(e,r={}){let n=[this.localStore,...this.routers];r.offline===!0&&(n=[this.localStore]);let o=[],i=0;if(await Promise.all(n.map(async a=>{let c;try{c=await a.get(e,{...r,validate:!1})}catch(f){a===this.localStore&&f.code==="ERR_NOT_FOUND"?mr("did not have record locally"):mr.error("error finding IPNS record",f);return}try{await Ws(e,c),o.push(c)}catch(f){i++,mr.error("error finding IPNS record",f)}})),o.length===0)throw i>0?new $(`${i>1?`${i} records`:"Record"} found for routing key ${i>1?"were":"was"} invalid`,"ERR_RECORDS_FAILED_VALIDATION"):new $("Could not find record for routing key","ERR_NOT_FOUND");let s=o[gi(e,o)];return await this.localStore.put(e,s,r),Ct(s)}};function rg(t,{routers:e=[]}={}){return new na(t,e)}return Df(ng);})();
|
|
9
9
|
/*! Bundled license information:
|
|
10
10
|
|
|
11
11
|
pvtsutils/build/index.js:
|