@libp2p/identify 3.0.11 → 3.0.12-339b7df88
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 +1 -1
- package/dist/index.min.js +6 -3
- package/package.json +16 -16
- package/LICENSE +0 -4
- package/dist/typedoc-urls.json +0 -18
package/README.md
CHANGED
|
@@ -71,7 +71,7 @@ $ npm i @libp2p/identify
|
|
|
71
71
|
|
|
72
72
|
## Browser `<script>` tag
|
|
73
73
|
|
|
74
|
-
Loading this module through a script tag will make
|
|
74
|
+
Loading this module through a script tag will make its exports available as `Libp2pIdentify` in the global namespace.
|
|
75
75
|
|
|
76
76
|
```html
|
|
77
77
|
<script src="https://unpkg.com/@libp2p/identify/dist/index.min.js"></script>
|
package/dist/index.min.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
(function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.Libp2PIdentify = factory()}(typeof self !== 'undefined' ? self : this, function () {
|
|
2
|
-
"use strict";var Libp2PIdentify=(()=>{var uu=Object.create;var cn=Object.defineProperty;var fu=Object.getOwnPropertyDescriptor;var hu=Object.getOwnPropertyNames;var du=Object.getPrototypeOf,pu=Object.prototype.hasOwnProperty;var Ws=(r,t)=>()=>(t||r((t={exports:{}}).exports,t),t.exports),St=(r,t)=>{for(var e in t)cn(r,e,{get:t[e],enumerable:!0})},Ji=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of hu(t))!pu.call(r,s)&&s!==e&&cn(r,s,{get:()=>t[s],enumerable:!(n=fu(t,s))||n.enumerable});return r};var js=(r,t,e)=>(e=r!=null?uu(du(r)):{},Ji(t||!r||!r.__esModule?cn(e,"default",{value:r,enumerable:!0}):e,r)),mu=r=>Ji(cn({},"__esModule",{value:!0}),r);var Za=Ws(ur=>{"use strict";var Mh="[object ArrayBuffer]",de=class r{static isArrayBuffer(t){return Object.prototype.toString.call(t)===Mh}static toArrayBuffer(t){return this.isArrayBuffer(t)?t:t.byteLength===t.buffer.byteLength||t.byteOffset===0&&t.byteLength===t.buffer.byteLength?t.buffer:this.toUint8Array(t.buffer).slice(t.byteOffset,t.byteOffset+t.byteLength).buffer}static toUint8Array(t){return this.toView(t,Uint8Array)}static toView(t,e){if(t.constructor===e)return t;if(this.isArrayBuffer(t))return new e(t);if(this.isArrayBufferView(t))return new e(t.buffer,t.byteOffset,t.byteLength);throw new TypeError("The provided value is not of type '(ArrayBuffer or ArrayBufferView)'")}static isBufferSource(t){return this.isArrayBufferView(t)||this.isArrayBuffer(t)}static isArrayBufferView(t){return ArrayBuffer.isView(t)||t&&this.isArrayBuffer(t.buffer)}static isEqual(t,e){let n=r.toUint8Array(t),s=r.toUint8Array(e);if(n.length!==s.byteLength)return!1;for(let o=0;o<n.length;o++)if(n[o]!==s[o])return!1;return!0}static concat(...t){let e;Array.isArray(t[0])&&!(t[1]instanceof Function)||Array.isArray(t[0])&&t[1]instanceof Function?e=t[0]:t[t.length-1]instanceof Function?e=t.slice(0,t.length-1):e=t;let n=0;for(let i of e)n+=i.byteLength;let s=new Uint8Array(n),o=0;for(let i of e){let a=this.toUint8Array(i);s.set(a,o),o+=a.length}return t[t.length-1]instanceof Function?this.toView(s,t[t.length-1]):s.buffer}},si="string",Fh=/^[0-9a-f]+$/i,Hh=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/,Kh=/^[a-zA-Z0-9-_]+$/,Ln=class{static fromString(t){let e=unescape(encodeURIComponent(t)),n=new Uint8Array(e.length);for(let s=0;s<e.length;s++)n[s]=e.charCodeAt(s);return n.buffer}static toString(t){let e=de.toUint8Array(t),n="";for(let o=0;o<e.length;o++)n+=String.fromCharCode(e[o]);return decodeURIComponent(escape(n))}},Vt=class{static toString(t,e=!1){let n=de.toArrayBuffer(t),s=new DataView(n),o="";for(let i=0;i<n.byteLength;i+=2){let a=s.getUint16(i,e);o+=String.fromCharCode(a)}return o}static fromString(t,e=!1){let n=new ArrayBuffer(t.length*2),s=new DataView(n);for(let o=0;o<t.length;o++)s.setUint16(o*2,t.charCodeAt(o),e);return n}},Un=class r{static isHex(t){return typeof t===si&&Fh.test(t)}static isBase64(t){return typeof t===si&&Hh.test(t)}static isBase64Url(t){return typeof t===si&&Kh.test(t)}static ToString(t,e="utf8"){let n=de.toUint8Array(t);switch(e.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 Vt.toString(n,!0);case"utf16":case"utf16be":return Vt.toString(n);default:throw new Error(`Unknown type of encoding '${e}'`)}}static FromString(t,e="utf8"){if(!t)return new ArrayBuffer(0);switch(e.toLowerCase()){case"utf8":return this.FromUtf8String(t);case"binary":return this.FromBinary(t);case"hex":return this.FromHex(t);case"base64":return this.FromBase64(t);case"base64url":return this.FromBase64Url(t);case"utf16le":return Vt.fromString(t,!0);case"utf16":case"utf16be":return Vt.fromString(t);default:throw new Error(`Unknown type of encoding '${e}'`)}}static ToBase64(t){let e=de.toUint8Array(t);if(typeof btoa<"u"){let n=this.ToString(e,"binary");return btoa(n)}else return Buffer.from(e).toString("base64")}static FromBase64(t){let e=this.formatString(t);if(!e)return new ArrayBuffer(0);if(!r.isBase64(e))throw new TypeError("Argument 'base64Text' is not Base64 encoded");return typeof atob<"u"?this.FromBinary(atob(e)):new Uint8Array(Buffer.from(e,"base64")).buffer}static FromBase64Url(t){let e=this.formatString(t);if(!e)return new ArrayBuffer(0);if(!r.isBase64Url(e))throw new TypeError("Argument 'base64url' is not Base64Url encoded");return this.FromBase64(this.Base64Padding(e.replace(/\-/g,"+").replace(/\_/g,"/")))}static ToBase64Url(t){return this.ToBase64(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/\=/g,"")}static FromUtf8String(t,e=r.DEFAULT_UTF8_ENCODING){switch(e){case"ascii":return this.FromBinary(t);case"utf8":return Ln.fromString(t);case"utf16":case"utf16be":return Vt.fromString(t);case"utf16le":case"usc2":return Vt.fromString(t,!0);default:throw new Error(`Unknown type of encoding '${e}'`)}}static ToUtf8String(t,e=r.DEFAULT_UTF8_ENCODING){switch(e){case"ascii":return this.ToBinary(t);case"utf8":return Ln.toString(t);case"utf16":case"utf16be":return Vt.toString(t);case"utf16le":case"usc2":return Vt.toString(t,!0);default:throw new Error(`Unknown type of encoding '${e}'`)}}static FromBinary(t){let e=t.length,n=new Uint8Array(e);for(let s=0;s<e;s++)n[s]=t.charCodeAt(s);return n.buffer}static ToBinary(t){let e=de.toUint8Array(t),n="";for(let s=0;s<e.length;s++)n+=String.fromCharCode(e[s]);return n}static ToHex(t){let e=de.toUint8Array(t),n="",s=e.length;for(let o=0;o<s;o++){let i=e[o];i<16&&(n+="0"),n+=i.toString(16)}return n}static FromHex(t){let e=this.formatString(t);if(!e)return new ArrayBuffer(0);if(!r.isHex(e))throw new TypeError("Argument 'hexString' is not HEX encoded");e.length%2&&(e=`0${e}`);let n=new Uint8Array(e.length/2);for(let s=0;s<e.length;s=s+2){let o=e.slice(s,s+2);n[s/2]=parseInt(o,16)}return n.buffer}static ToUtf16String(t,e=!1){return Vt.toString(t,e)}static FromUtf16String(t,e=!1){return Vt.fromString(t,e)}static Base64Padding(t){let e=4-t.length%4;if(e<4)for(let n=0;n<e;n++)t+="=";return t}static formatString(t){return t?.replace(/[\n\r\t ]/g,"")||""}};Un.DEFAULT_UTF8_ENCODING="utf8";function $h(r,...t){let e=arguments[0];for(let n=1;n<arguments.length;n++){let s=arguments[n];for(let o in s)e[o]=s[o]}return e}function qh(...r){let t=r.map(s=>s.byteLength).reduce((s,o)=>s+o),e=new Uint8Array(t),n=0;return r.map(s=>new Uint8Array(s)).forEach(s=>{for(let o of s)e[n++]=o}),e.buffer}function zh(r,t){if(!(r&&t)||r.byteLength!==t.byteLength)return!1;let e=new Uint8Array(r),n=new Uint8Array(t);for(let s=0;s<r.byteLength;s++)if(e[s]!==n[s])return!1;return!0}ur.BufferSourceConverter=de;ur.Convert=Un;ur.assign=$h;ur.combine=qh;ur.isEqual=zh});var Vl=Ws((hx,Ol)=>{function Pd(){return!!(typeof window<"u"&&typeof window.process=="object"&&window.process.type==="renderer"||typeof process<"u"&&typeof process.versions=="object"&&process.versions.electron||typeof navigator=="object"&&typeof navigator.userAgent=="string"&&navigator.userAgent.indexOf("Electron")>=0)}Ol.exports=Pd});var Gl=Ws(nn=>{(function(){var r,t,e,n,s,o,i,a;a=function(c){var l,u,f,h;return l=(c&255<<24)>>>24,u=(c&255<<16)>>>16,f=(c&65280)>>>8,h=c&255,[l,u,f,h].join(".")},i=function(c){var l,u,f,h,g,m;for(l=[],f=h=0;h<=3&&c.length!==0;f=++h){if(f>0){if(c[0]!==".")throw new Error("Invalid IP");c=c.substring(1)}m=t(c),g=m[0],u=m[1],c=c.substring(u),l.push(g)}if(c.length!==0)throw new Error("Invalid IP");switch(l.length){case 1:if(l[0]>4294967295)throw new Error("Invalid IP");return l[0]>>>0;case 2:if(l[0]>255||l[1]>16777215)throw new Error("Invalid IP");return(l[0]<<24|l[1])>>>0;case 3:if(l[0]>255||l[1]>255||l[2]>65535)throw new Error("Invalid IP");return(l[0]<<24|l[1]<<16|l[2])>>>0;case 4:if(l[0]>255||l[1]>255||l[2]>255||l[3]>255)throw new Error("Invalid IP");return(l[0]<<24|l[1]<<16|l[2]<<8|l[3])>>>0;default:throw new Error("Invalid IP")}},e=function(c){return c.charCodeAt(0)},n=e("0"),o=e("a"),s=e("A"),t=function(c){var l,u,f,h,g;for(h=0,l=10,u="9",f=0,c.length>1&&c[f]==="0"&&(c[f+1]==="x"||c[f+1]==="X"?(f+=2,l=16):"0"<=c[f+1]&&c[f+1]<="9"&&(f++,l=8,u="7")),g=f;f<c.length;){if("0"<=c[f]&&c[f]<=u)h=h*l+(e(c[f])-n)>>>0;else if(l===16)if("a"<=c[f]&&c[f]<="f")h=h*l+(10+e(c[f])-o)>>>0;else if("A"<=c[f]&&c[f]<="F")h=h*l+(10+e(c[f])-s)>>>0;else break;else break;if(h>4294967295)throw new Error("too large");f++}if(f===g)throw new Error("empty octet");return[h,f]},r=function(){function c(l,u){var f,h,g,m;if(typeof l!="string")throw new Error("Missing `net' parameter");if(u||(m=l.split("/",2),l=m[0],u=m[1]),u||(u=32),typeof u=="string"&&u.indexOf(".")>-1){try{this.maskLong=i(u)}catch(b){throw f=b,new Error("Invalid mask: "+u)}for(h=g=32;g>=0;h=--g)if(this.maskLong===4294967295<<32-h>>>0){this.bitmask=h;break}}else if(u||u===0)this.bitmask=parseInt(u,10),this.maskLong=0,this.bitmask>0&&(this.maskLong=4294967295<<32-this.bitmask>>>0);else throw new Error("Invalid mask: empty");try{this.netLong=(i(l)&this.maskLong)>>>0}catch(b){throw f=b,new Error("Invalid net address: "+l)}if(!(this.bitmask<=32))throw new Error("Invalid mask for ip4: "+u);this.size=Math.pow(2,32-this.bitmask),this.base=a(this.netLong),this.mask=a(this.maskLong),this.hostmask=a(~this.maskLong),this.first=this.bitmask<=30?a(this.netLong+1):this.base,this.last=this.bitmask<=30?a(this.netLong+this.size-2):a(this.netLong+this.size-1),this.broadcast=this.bitmask<=30?a(this.netLong+this.size-1):void 0}return c.prototype.contains=function(l){return typeof l=="string"&&(l.indexOf("/")>0||l.split(".").length!==4)&&(l=new c(l)),l instanceof c?this.contains(l.base)&&this.contains(l.broadcast||l.last):(i(l)&this.maskLong)>>>0===(this.netLong&this.maskLong)>>>0},c.prototype.next=function(l){return l==null&&(l=1),new c(a(this.netLong+this.size*l),this.mask)},c.prototype.forEach=function(l){var u,f,h;for(h=i(this.first),f=i(this.last),u=0;h<=f;)l(a(h),h,u),u++,h++},c.prototype.toString=function(){return this.base+"/"+this.bitmask},c}(),nn.ip2long=i,nn.long2ip=a,nn.Netmask=r}).call(nn)});var e0={};St(e0,{identify:()=>Qd,identifyPush:()=>t0});var Zs=Symbol.for("@libp2p/peer-id");var It=class extends Error{static name="InvalidParametersError";constructor(t="Invalid parameters"){super(t),this.name="InvalidParametersError"}},Xe=class extends Error{static name="InvalidPublicKeyError";constructor(t="Invalid public key"){super(t),this.name="InvalidPublicKeyError"}};var ln=class extends Error{static name="InvalidCIDError";constructor(t="Invalid CID"){super(t),this.name="InvalidCIDError"}},un=class extends Error{static name="InvalidMultihashError";constructor(t="Invalid Multihash"){super(t),this.name="InvalidMultihashError"}},fn=class extends Error{static name="UnsupportedProtocolError";constructor(t="Unsupported protocol error"){super(t),this.name="UnsupportedProtocolError"}},Dt=class extends Error{static name="InvalidMessageError";constructor(t="Invalid message"){super(t),this.name="InvalidMessageError"}};var De=class extends Error{static name="UnsupportedKeyTypeError";constructor(t="Unsupported key type"){super(t),this.name="UnsupportedKeyTypeError"}};var Ir=(r,...t)=>{try{[...t]}catch{}};var hn=Symbol.for("@libp2p/service-capabilities"),i0=Symbol.for("@libp2p/service-dependencies");var to={};St(to,{base58btc:()=>X,base58flickr:()=>vu});var T0=new Uint8Array(0);function Xi(r,t){if(r===t)return!0;if(r.byteLength!==t.byteLength)return!1;for(let e=0;e<r.byteLength;e++)if(r[e]!==t[e])return!1;return!0}function oe(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 Qi(r){return new TextEncoder().encode(r)}function ta(r){return new TextDecoder().decode(r)}function gu(r,t){if(r.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),n=0;n<e.length;n++)e[n]=255;for(var s=0;s<r.length;s++){var o=r.charAt(s),i=o.charCodeAt(0);if(e[i]!==255)throw new TypeError(o+" is ambiguous");e[i]=s}var a=r.length,c=r.charAt(0),l=Math.log(a)/Math.log(256),u=Math.log(256)/Math.log(a);function f(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 b=0,d=0,x=0,B=m.length;x!==B&&m[x]===0;)x++,b++;for(var y=(B-x)*u+1>>>0,S=new Uint8Array(y);x!==B;){for(var U=m[x],L=0,I=y-1;(U!==0||L<d)&&I!==-1;I--,L++)U+=256*S[I]>>>0,S[I]=U%a>>>0,U=U/a>>>0;if(U!==0)throw new Error("Non-zero carry");d=L,x++}for(var k=y-d;k!==y&&S[k]===0;)k++;for(var T=c.repeat(b);k<y;++k)T+=r.charAt(S[k]);return T}function h(m){if(typeof m!="string")throw new TypeError("Expected String");if(m.length===0)return new Uint8Array;var b=0;if(m[b]!==" "){for(var d=0,x=0;m[b]===c;)d++,b++;for(var B=(m.length-b)*l+1>>>0,y=new Uint8Array(B);m[b];){var S=e[m.charCodeAt(b)];if(S===255)return;for(var U=0,L=B-1;(S!==0||U<x)&&L!==-1;L--,U++)S+=a*y[L]>>>0,y[L]=S%256>>>0,S=S/256>>>0;if(S!==0)throw new Error("Non-zero carry");x=U,b++}if(m[b]!==" "){for(var I=B-x;I!==B&&y[I]===0;)I++;for(var k=new Uint8Array(d+(B-I)),T=d;I!==B;)k[T++]=y[I++];return k}}}function g(m){var b=h(m);if(b)return b;throw new Error(`Non-${t} character`)}return{encode:f,decodeUnsafe:h,decode:g}}var yu=gu,bu=yu,ra=bu;var Ys=class{name;prefix;baseEncode;constructor(t,e,n){this.name=t,this.prefix=e,this.baseEncode=n}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}},Js=class{name;prefix;baseDecode;prefixCodePoint;constructor(t,e,n){this.name=t,this.prefix=e;let s=e.codePointAt(0);if(s===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=s,this.baseDecode=n}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return na(this,t)}},Xs=class{decoders;constructor(t){this.decoders=t}or(t){return na(this,t)}decode(t){let e=t[0],n=this.decoders[e];if(n!=null)return n.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function na(r,t){return new Xs({...r.decoders??{[r.prefix]:r},...t.decoders??{[t.prefix]:t}})}var Qs=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(t,e,n,s){this.name=t,this.prefix=e,this.baseEncode=n,this.baseDecode=s,this.encoder=new Ys(t,e,n),this.decoder=new Js(t,e,s)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function Qe({name:r,prefix:t,encode:e,decode:n}){return new Qs(r,t,e,n)}function Ee({name:r,prefix:t,alphabet:e}){let{encode:n,decode:s}=ra(e,r);return Qe({prefix:t,name:r,encode:n,decode:o=>oe(s(o))})}function wu(r,t,e,n){let s={};for(let u=0;u<t.length;++u)s[t[u]]=u;let o=r.length;for(;r[o-1]==="=";)--o;let i=new Uint8Array(o*e/8|0),a=0,c=0,l=0;for(let u=0;u<o;++u){let f=s[r[u]];if(f===void 0)throw new SyntaxError(`Non-${n} character`);c=c<<e|f,a+=e,a>=8&&(a-=8,i[l++]=255&c>>a)}if(a>=e||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return i}function xu(r,t,e){let n=t[t.length-1]==="=",s=(1<<e)-1,o="",i=0,a=0;for(let c=0;c<r.length;++c)for(a=a<<8|r[c],i+=8;i>e;)i-=e,o+=t[s&a>>i];if(i!==0&&(o+=t[s&a<<e-i]),n)for(;o.length*e&7;)o+="=";return o}function nt({name:r,prefix:t,bitsPerChar:e,alphabet:n}){return Qe({prefix:t,name:r,encode(s){return xu(s,n,e)},decode(s){return wu(s,n,e,r)}})}var X=Ee({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),vu=Ee({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var eo={};St(eo,{base32:()=>ie,base32hex:()=>Su,base32hexpad:()=>ku,base32hexpadupper:()=>Nu,base32hexupper:()=>Iu,base32pad:()=>Bu,base32padupper:()=>Au,base32upper:()=>Eu,base32z:()=>Cu});var ie=nt({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Eu=nt({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Bu=nt({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Au=nt({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Su=nt({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Iu=nt({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),ku=nt({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Nu=nt({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Cu=nt({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var ro={};St(ro,{base36:()=>kr,base36upper:()=>Tu});var kr=Ee({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Tu=Ee({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Lu=ia,sa=128,Uu=127,Ru=~Uu,_u=Math.pow(2,31);function ia(r,t,e){t=t||[],e=e||0;for(var n=e;r>=_u;)t[e++]=r&255|sa,r/=128;for(;r&Ru;)t[e++]=r&255|sa,r>>>=7;return t[e]=r|0,ia.bytes=e-n+1,t}var Pu=no,Ou=128,oa=127;function no(r,n){var e=0,n=n||0,s=0,o=n,i,a=r.length;do{if(o>=a)throw no.bytes=0,new RangeError("Could not decode varint");i=r[o++],e+=s<28?(i&oa)<<s:(i&oa)*Math.pow(2,s),s+=7}while(i>=Ou);return no.bytes=o-n,e}var Vu=Math.pow(2,7),Du=Math.pow(2,14),Mu=Math.pow(2,21),Fu=Math.pow(2,28),Hu=Math.pow(2,35),Ku=Math.pow(2,42),$u=Math.pow(2,49),qu=Math.pow(2,56),zu=Math.pow(2,63),Gu=function(r){return r<Vu?1:r<Du?2:r<Mu?3:r<Fu?4:r<Hu?5:r<Ku?6:r<$u?7:r<qu?8:r<zu?9:10},Wu={encode:Lu,decode:Pu,encodingLength:Gu},ju=Wu,Nr=ju;function Cr(r,t=0){return[Nr.decode(r,t),Nr.decode.bytes]}function tr(r,t,e=0){return Nr.encode(r,t,e),t}function er(r){return Nr.encodingLength(r)}function Mt(r,t){let e=t.byteLength,n=er(r),s=n+er(e),o=new Uint8Array(s+e);return tr(r,o,0),tr(e,o,n),o.set(t,s),new rr(r,e,t,o)}function Me(r){let t=oe(r),[e,n]=Cr(t),[s,o]=Cr(t.subarray(n)),i=t.subarray(n+o);if(i.byteLength!==s)throw new Error("Incorrect length");return new rr(e,s,i,t)}function aa(r,t){if(r===t)return!0;{let e=t;return r.code===e.code&&r.size===e.size&&e.bytes instanceof Uint8Array&&Xi(r.bytes,e.bytes)}}var rr=class{code;size;digest;bytes;constructor(t,e,n,s){this.code=t,this.size=e,this.digest=n,this.bytes=s}};function ca(r,t){let{bytes:e,version:n}=r;switch(n){case 0:return Yu(e,so(r),t??X.encoder);default:return Ju(e,so(r),t??ie.encoder)}}var la=new WeakMap;function so(r){let t=la.get(r);if(t==null){let e=new Map;return la.set(r,e),e}return t}var pt=class r{code;version;multihash;bytes;"/";constructor(t,e,n,s){this.code=e,this.version=t,this.multihash=n,this.bytes=s,this["/"]=s}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:t,multihash:e}=this;if(t!==Tr)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(e.code!==Xu)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return r.createV0(e)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:t,digest:e}=this.multihash,n=Mt(t,e);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(t){return r.equals(this,t)}static equals(t,e){let n=e;return n!=null&&t.code===n.code&&t.version===n.version&&aa(t.multihash,n.multihash)}toString(t){return ca(this,t)}toJSON(){return{"/":ca(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(t){if(t==null)return null;let e=t;if(e instanceof r)return e;if(e["/"]!=null&&e["/"]===e.bytes||e.asCID===e){let{version:n,code:s,multihash:o,bytes:i}=e;return new r(n,s,o,i??ua(n,s,o.bytes))}else if(e[Qu]===!0){let{version:n,multihash:s,code:o}=e,i=Me(s);return r.create(n,o,i)}else return null}static create(t,e,n){if(typeof e!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(t){case 0:{if(e!==Tr)throw new Error(`Version 0 CID must use dag-pb (code: ${Tr}) block encoding`);return new r(t,e,n,n.bytes)}case 1:{let s=ua(t,e,n.bytes);return new r(t,e,n,s)}default:throw new Error("Invalid version")}}static createV0(t){return r.create(0,Tr,t)}static createV1(t,e){return r.create(1,t,e)}static decode(t){let[e,n]=r.decodeFirst(t);if(n.length!==0)throw new Error("Incorrect length");return e}static decodeFirst(t){let e=r.inspectBytes(t),n=e.size-e.multihashSize,s=oe(t.subarray(n,n+e.multihashSize));if(s.byteLength!==e.multihashSize)throw new Error("Incorrect length");let o=s.subarray(e.multihashSize-e.digestSize),i=new rr(e.multihashCode,e.digestSize,o,s);return[e.version===0?r.createV0(i):r.createV1(e.codec,i),t.subarray(e.size)]}static inspectBytes(t){let e=0,n=()=>{let[f,h]=Cr(t.subarray(e));return e+=h,f},s=n(),o=Tr;if(s===18?(s=0,e=0):o=n(),s!==0&&s!==1)throw new RangeError(`Invalid CID version ${s}`);let i=e,a=n(),c=n(),l=e+c,u=l-i;return{version:s,codec:o,multihashCode:a,digestSize:c,multihashSize:u,size:l}}static parse(t,e){let[n,s]=Zu(t,e),o=r.decode(s);if(o.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return so(o).set(n,t),o}};function Zu(r,t){switch(r[0]){case"Q":{let e=t??X;return[X.prefix,e.decode(`${X.prefix}${r}`)]}case X.prefix:{let e=t??X;return[X.prefix,e.decode(r)]}case ie.prefix:{let e=t??ie;return[ie.prefix,e.decode(r)]}case kr.prefix:{let e=t??kr;return[kr.prefix,e.decode(r)]}default:{if(t==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[r[0],t.decode(r)]}}}function Yu(r,t,e){let{prefix:n}=e;if(n!==X.prefix)throw Error(`Cannot string encode V0 in ${e.name} encoding`);let s=t.get(n);if(s==null){let o=e.encode(r).slice(1);return t.set(n,o),o}else return s}function Ju(r,t,e){let{prefix:n}=e,s=t.get(n);if(s==null){let o=e.encode(r);return t.set(n,o),o}else return s}var Tr=112,Xu=18;function ua(r,t,e){let n=er(r),s=n+er(t),o=new Uint8Array(s+e.byteLength);return tr(r,o,0),tr(t,o,n),o.set(e,s),o}var Qu=Symbol.for("@ipld/js-cid/CID");var oo={};St(oo,{identity:()=>ae});var fa=0,tf="identity",ha=oe;function ef(r){return Mt(fa,ha(r))}var ae={code:fa,name:tf,encode:ha,digest:ef};function bt(r,t){if(r===t)return!0;if(r.byteLength!==t.byteLength)return!1;for(let e=0;e<r.byteLength;e++)if(r[e]!==t[e])return!1;return!0}function da(r){if(!Number.isSafeInteger(r)||r<0)throw new Error(`positive integer expected, not ${r}`)}function rf(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}function nr(r,...t){if(!rf(r))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(r.length))throw new Error(`Uint8Array expected of length ${t}, not of length=${r.length}`)}function pa(r){if(typeof r!="function"||typeof r.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");da(r.outputLen),da(r.blockLen)}function sr(r,t=!0){if(r.destroyed)throw new Error("Hash instance has been destroyed");if(t&&r.finished)throw new Error("Hash#digest() has already been called")}function ma(r,t){nr(r);let e=t.outputLen;if(r.length<e)throw new Error(`digestInto() expects output buffer of length at least ${e}`)}var Fe=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;var pn=r=>new DataView(r.buffer,r.byteOffset,r.byteLength),Ft=(r,t)=>r<<32-t|r>>>t;var Q0=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function ga(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}function Lr(r){return typeof r=="string"&&(r=ga(r)),nr(r),r}function io(...r){let t=0;for(let n=0;n<r.length;n++){let s=r[n];nr(s),t+=s.length}let e=new Uint8Array(t);for(let n=0,s=0;n<r.length;n++){let o=r[n];e.set(o,s),s+=o.length}return e}var or=class{clone(){return this._cloneInto()}},tp={}.toString;function mn(r){let t=n=>r().update(Lr(n)).digest(),e=r();return t.outputLen=e.outputLen,t.blockLen=e.blockLen,t.create=()=>r(),t}function gn(r=32){if(Fe&&typeof Fe.getRandomValues=="function")return Fe.getRandomValues(new Uint8Array(r));if(Fe&&typeof Fe.randomBytes=="function")return Fe.randomBytes(r);throw new Error("crypto.getRandomValues must be defined")}function nf(r,t,e,n){if(typeof r.setBigUint64=="function")return r.setBigUint64(t,e,n);let s=BigInt(32),o=BigInt(4294967295),i=Number(e>>s&o),a=Number(e&o),c=n?4:0,l=n?0:4;r.setUint32(t+c,i,n),r.setUint32(t+l,a,n)}var ya=(r,t,e)=>r&t^~r&e,ba=(r,t,e)=>r&t^r&e^t&e,ir=class extends or{constructor(t,e,n,s){super(),this.blockLen=t,this.outputLen=e,this.padOffset=n,this.isLE=s,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=pn(this.buffer)}update(t){sr(this);let{view:e,buffer:n,blockLen:s}=this;t=Lr(t);let o=t.length;for(let i=0;i<o;){let a=Math.min(s-this.pos,o-i);if(a===s){let c=pn(t);for(;s<=o-i;i+=s)this.process(c,i);continue}n.set(t.subarray(i,i+a),this.pos),this.pos+=a,i+=a,this.pos===s&&(this.process(e,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){sr(this),ma(t,this),this.finished=!0;let{buffer:e,view:n,blockLen:s,isLE:o}=this,{pos:i}=this;e[i++]=128,this.buffer.subarray(i).fill(0),this.padOffset>s-i&&(this.process(n,0),i=0);for(let f=i;f<s;f++)e[f]=0;nf(n,s-8,BigInt(this.length*8),o),this.process(n,0);let a=pn(t),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let l=c/4,u=this.get();if(l>u.length)throw new Error("_sha2: outputLen bigger than state");for(let f=0;f<l;f++)a.setUint32(4*f,u[f],o)}digest(){let{buffer:t,outputLen:e}=this;this.digestInto(t);let n=t.slice(0,e);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());let{blockLen:e,buffer:n,length:s,finished:o,destroyed:i,pos:a}=this;return t.length=s,t.pos=a,t.finished=o,t.destroyed=i,s%e&&t.buffer.set(n),t}};var yn=BigInt(4294967295),ao=BigInt(32);function wa(r,t=!1){return t?{h:Number(r&yn),l:Number(r>>ao&yn)}:{h:Number(r>>ao&yn)|0,l:Number(r&yn)|0}}function sf(r,t=!1){let e=new Uint32Array(r.length),n=new Uint32Array(r.length);for(let s=0;s<r.length;s++){let{h:o,l:i}=wa(r[s],t);[e[s],n[s]]=[o,i]}return[e,n]}var of=(r,t)=>BigInt(r>>>0)<<ao|BigInt(t>>>0),af=(r,t,e)=>r>>>e,cf=(r,t,e)=>r<<32-e|t>>>e,lf=(r,t,e)=>r>>>e|t<<32-e,uf=(r,t,e)=>r<<32-e|t>>>e,ff=(r,t,e)=>r<<64-e|t>>>e-32,hf=(r,t,e)=>r>>>e-32|t<<64-e,df=(r,t)=>t,pf=(r,t)=>r,mf=(r,t,e)=>r<<e|t>>>32-e,gf=(r,t,e)=>t<<e|r>>>32-e,yf=(r,t,e)=>t<<e-32|r>>>64-e,bf=(r,t,e)=>r<<e-32|t>>>64-e;function wf(r,t,e,n){let s=(t>>>0)+(n>>>0);return{h:r+e+(s/2**32|0)|0,l:s|0}}var xf=(r,t,e)=>(r>>>0)+(t>>>0)+(e>>>0),vf=(r,t,e,n)=>t+e+n+(r/2**32|0)|0,Ef=(r,t,e,n)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0),Bf=(r,t,e,n,s)=>t+e+n+s+(r/2**32|0)|0,Af=(r,t,e,n,s)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0)+(s>>>0),Sf=(r,t,e,n,s,o)=>t+e+n+s+o+(r/2**32|0)|0;var If={fromBig:wa,split:sf,toBig:of,shrSH:af,shrSL:cf,rotrSH:lf,rotrSL:uf,rotrBH:ff,rotrBL:hf,rotr32H:df,rotr32L:pf,rotlSH:mf,rotlSL:gf,rotlBH:yf,rotlBL:bf,add:wf,add3L:xf,add3H:vf,add4L:Ef,add4H:Bf,add5H:Sf,add5L:Af},P=If;var[kf,Nf]=P.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))),Ae=new Uint32Array(80),Se=new Uint32Array(80),co=class extends ir{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){let{Ah:t,Al:e,Bh:n,Bl:s,Ch:o,Cl:i,Dh:a,Dl:c,Eh:l,El:u,Fh:f,Fl:h,Gh:g,Gl:m,Hh:b,Hl:d}=this;return[t,e,n,s,o,i,a,c,l,u,f,h,g,m,b,d]}set(t,e,n,s,o,i,a,c,l,u,f,h,g,m,b,d){this.Ah=t|0,this.Al=e|0,this.Bh=n|0,this.Bl=s|0,this.Ch=o|0,this.Cl=i|0,this.Dh=a|0,this.Dl=c|0,this.Eh=l|0,this.El=u|0,this.Fh=f|0,this.Fl=h|0,this.Gh=g|0,this.Gl=m|0,this.Hh=b|0,this.Hl=d|0}process(t,e){for(let y=0;y<16;y++,e+=4)Ae[y]=t.getUint32(e),Se[y]=t.getUint32(e+=4);for(let y=16;y<80;y++){let S=Ae[y-15]|0,U=Se[y-15]|0,L=P.rotrSH(S,U,1)^P.rotrSH(S,U,8)^P.shrSH(S,U,7),I=P.rotrSL(S,U,1)^P.rotrSL(S,U,8)^P.shrSL(S,U,7),k=Ae[y-2]|0,T=Se[y-2]|0,ot=P.rotrSH(k,T,19)^P.rotrBH(k,T,61)^P.shrSH(k,T,6),$=P.rotrSL(k,T,19)^P.rotrBL(k,T,61)^P.shrSL(k,T,6),O=P.add4L(I,$,Se[y-7],Se[y-16]),it=P.add4H(O,L,ot,Ae[y-7],Ae[y-16]);Ae[y]=it|0,Se[y]=O|0}let{Ah:n,Al:s,Bh:o,Bl:i,Ch:a,Cl:c,Dh:l,Dl:u,Eh:f,El:h,Fh:g,Fl:m,Gh:b,Gl:d,Hh:x,Hl:B}=this;for(let y=0;y<80;y++){let S=P.rotrSH(f,h,14)^P.rotrSH(f,h,18)^P.rotrBH(f,h,41),U=P.rotrSL(f,h,14)^P.rotrSL(f,h,18)^P.rotrBL(f,h,41),L=f&g^~f&b,I=h&m^~h&d,k=P.add5L(B,U,I,Nf[y],Se[y]),T=P.add5H(k,x,S,L,kf[y],Ae[y]),ot=k|0,$=P.rotrSH(n,s,28)^P.rotrBH(n,s,34)^P.rotrBH(n,s,39),O=P.rotrSL(n,s,28)^P.rotrBL(n,s,34)^P.rotrBL(n,s,39),it=n&o^n&a^o&a,E=s&i^s&c^i&c;x=b|0,B=d|0,b=g|0,d=m|0,g=f|0,m=h|0,{h:f,l:h}=P.add(l|0,u|0,T|0,ot|0),l=a|0,u=c|0,a=o|0,c=i|0,o=n|0,i=s|0;let N=P.add3L(ot,O,E);n=P.add3H(N,T,$,it),s=N|0}({h:n,l:s}=P.add(this.Ah|0,this.Al|0,n|0,s|0)),{h:o,l:i}=P.add(this.Bh|0,this.Bl|0,o|0,i|0),{h:a,l:c}=P.add(this.Ch|0,this.Cl|0,a|0,c|0),{h:l,l:u}=P.add(this.Dh|0,this.Dl|0,l|0,u|0),{h:f,l:h}=P.add(this.Eh|0,this.El|0,f|0,h|0),{h:g,l:m}=P.add(this.Fh|0,this.Fl|0,g|0,m|0),{h:b,l:d}=P.add(this.Gh|0,this.Gl|0,b|0,d|0),{h:x,l:B}=P.add(this.Hh|0,this.Hl|0,x|0,B|0),this.set(n,s,o,i,a,c,l,u,f,h,g,m,b,d,x,B)}roundClean(){Ae.fill(0),Se.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};var xa=mn(()=>new co);var wn={};St(wn,{aInRange:()=>Ct,abool:()=>Ht,abytes:()=>ar,bitGet:()=>_f,bitLen:()=>po,bitMask:()=>Rr,bitSet:()=>Pf,bytesToHex:()=>le,bytesToNumberBE:()=>ue,bytesToNumberLE:()=>ke,concatBytes:()=>fe,createHmacDrbg:()=>mo,ensureBytes:()=>st,equalBytes:()=>Uf,hexToBytes:()=>Ke,hexToNumber:()=>ho,inRange:()=>Ur,isBytes:()=>Ie,memoized:()=>qe,notImplemented:()=>Vf,numberToBytesBE:()=>Ne,numberToBytesLE:()=>$e,numberToHexUnpadded:()=>He,numberToVarBytesBE:()=>Lf,utf8ToBytes:()=>Rf,validateObject:()=>Jt});var fo=BigInt(0),bn=BigInt(1),Cf=BigInt(2);function Ie(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}function ar(r){if(!Ie(r))throw new Error("Uint8Array expected")}function Ht(r,t){if(typeof t!="boolean")throw new Error(`${r} must be valid boolean, got "${t}".`)}var Tf=Array.from({length:256},(r,t)=>t.toString(16).padStart(2,"0"));function le(r){ar(r);let t="";for(let e=0;e<r.length;e++)t+=Tf[r[e]];return t}function He(r){let t=r.toString(16);return t.length&1?`0${t}`:t}function ho(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return BigInt(r===""?"0":`0x${r}`)}var ce={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function va(r){if(r>=ce._0&&r<=ce._9)return r-ce._0;if(r>=ce._A&&r<=ce._F)return r-(ce._A-10);if(r>=ce._a&&r<=ce._f)return r-(ce._a-10)}function Ke(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);let t=r.length,e=t/2;if(t%2)throw new Error("padded hex string expected, got unpadded hex of length "+t);let n=new Uint8Array(e);for(let s=0,o=0;s<e;s++,o+=2){let i=va(r.charCodeAt(o)),a=va(r.charCodeAt(o+1));if(i===void 0||a===void 0){let c=r[o]+r[o+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+o)}n[s]=i*16+a}return n}function ue(r){return ho(le(r))}function ke(r){return ar(r),ho(le(Uint8Array.from(r).reverse()))}function Ne(r,t){return Ke(r.toString(16).padStart(t*2,"0"))}function $e(r,t){return Ne(r,t).reverse()}function Lf(r){return Ke(He(r))}function st(r,t,e){let n;if(typeof t=="string")try{n=Ke(t)}catch(o){throw new Error(`${r} must be valid hex string, got "${t}". Cause: ${o}`)}else if(Ie(t))n=Uint8Array.from(t);else throw new Error(`${r} must be hex string or Uint8Array`);let s=n.length;if(typeof e=="number"&&s!==e)throw new Error(`${r} expected ${e} bytes, got ${s}`);return n}function fe(...r){let t=0;for(let n=0;n<r.length;n++){let s=r[n];ar(s),t+=s.length}let e=new Uint8Array(t);for(let n=0,s=0;n<r.length;n++){let o=r[n];e.set(o,s),s+=o.length}return e}function Uf(r,t){if(r.length!==t.length)return!1;let e=0;for(let n=0;n<r.length;n++)e|=r[n]^t[n];return e===0}function Rf(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}var lo=r=>typeof r=="bigint"&&fo<=r;function Ur(r,t,e){return lo(r)&&lo(t)&&lo(e)&&t<=r&&r<e}function Ct(r,t,e,n){if(!Ur(t,e,n))throw new Error(`expected valid ${r}: ${e} <= n < ${n}, got ${typeof t} ${t}`)}function po(r){let t;for(t=0;r>fo;r>>=bn,t+=1);return t}function _f(r,t){return r>>BigInt(t)&bn}function Pf(r,t,e){return r|(e?bn:fo)<<BigInt(t)}var Rr=r=>(Cf<<BigInt(r-1))-bn,uo=r=>new Uint8Array(r),Ea=r=>Uint8Array.from(r);function mo(r,t,e){if(typeof r!="number"||r<2)throw new Error("hashLen must be a number");if(typeof t!="number"||t<2)throw new Error("qByteLen must be a number");if(typeof e!="function")throw new Error("hmacFn must be a function");let n=uo(r),s=uo(r),o=0,i=()=>{n.fill(1),s.fill(0),o=0},a=(...f)=>e(s,n,...f),c=(f=uo())=>{s=a(Ea([0]),f),n=a(),f.length!==0&&(s=a(Ea([1]),f),n=a())},l=()=>{if(o++>=1e3)throw new Error("drbg: tried 1000 values");let f=0,h=[];for(;f<t;){n=a();let g=n.slice();h.push(g),f+=n.length}return fe(...h)};return(f,h)=>{i(),c(f);let g;for(;!(g=h(l()));)c();return i(),g}}var Of={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"||Ie(r),isSafeInteger:r=>Number.isSafeInteger(r),array:r=>Array.isArray(r),field:(r,t)=>t.Fp.isValid(r),hash:r=>typeof r=="function"&&Number.isSafeInteger(r.outputLen)};function Jt(r,t,e={}){let n=(s,o,i)=>{let a=Of[o];if(typeof a!="function")throw new Error(`Invalid validator "${o}", expected function`);let c=r[s];if(!(i&&c===void 0)&&!a(c,r))throw new Error(`Invalid param ${String(s)}=${c} (${typeof c}), expected ${o}`)};for(let[s,o]of Object.entries(t))n(s,o,!1);for(let[s,o]of Object.entries(e))n(s,o,!0);return r}var Vf=()=>{throw new Error("not implemented")};function qe(r){let t=new WeakMap;return(e,...n)=>{let s=t.get(e);if(s!==void 0)return s;let o=r(e,...n);return t.set(e,o),o}}var ct=BigInt(0),Q=BigInt(1),ze=BigInt(2),Df=BigInt(3),go=BigInt(4),Ba=BigInt(5),Aa=BigInt(8),Mf=BigInt(9),Ff=BigInt(16);function Z(r,t){let e=r%t;return e>=ct?e:t+e}function Hf(r,t,e){if(e<=ct||t<ct)throw new Error("Expected power/modulo > 0");if(e===Q)return ct;let n=Q;for(;t>ct;)t&Q&&(n=n*r%e),r=r*r%e,t>>=Q;return n}function tt(r,t,e){let n=r;for(;t-- >ct;)n*=n,n%=e;return n}function xn(r,t){if(r===ct||t<=ct)throw new Error(`invert: expected positive integers, got n=${r} mod=${t}`);let e=Z(r,t),n=t,s=ct,o=Q,i=Q,a=ct;for(;e!==ct;){let l=n/e,u=n%e,f=s-i*l,h=o-a*l;n=e,e=u,s=i,o=a,i=f,a=h}if(n!==Q)throw new Error("invert: does not exist");return Z(s,t)}function Kf(r){let t=(r-Q)/ze,e,n,s;for(e=r-Q,n=0;e%ze===ct;e/=ze,n++);for(s=ze;s<r&&Hf(s,t,r)!==r-Q;s++);if(n===1){let i=(r+Q)/go;return function(c,l){let u=c.pow(l,i);if(!c.eql(c.sqr(u),l))throw new Error("Cannot find square root");return u}}let o=(e+Q)/ze;return function(a,c){if(a.pow(c,t)===a.neg(a.ONE))throw new Error("Cannot find square root");let l=n,u=a.pow(a.mul(a.ONE,s),e),f=a.pow(c,o),h=a.pow(c,e);for(;!a.eql(h,a.ONE);){if(a.eql(h,a.ZERO))return a.ZERO;let g=1;for(let b=a.sqr(h);g<l&&!a.eql(b,a.ONE);g++)b=a.sqr(b);let m=a.pow(u,Q<<BigInt(l-g-1));u=a.sqr(m),f=a.mul(f,m),h=a.mul(h,u),l=g}return f}}function $f(r){if(r%go===Df){let t=(r+Q)/go;return function(n,s){let o=n.pow(s,t);if(!n.eql(n.sqr(o),s))throw new Error("Cannot find square root");return o}}if(r%Aa===Ba){let t=(r-Ba)/Aa;return function(n,s){let o=n.mul(s,ze),i=n.pow(o,t),a=n.mul(s,i),c=n.mul(n.mul(a,ze),i),l=n.mul(a,n.sub(c,n.ONE));if(!n.eql(n.sqr(l),s))throw new Error("Cannot find square root");return l}}return r%Ff,Kf(r)}var Sa=(r,t)=>(Z(r,t)&Q)===Q,qf=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function yo(r){let t={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},e=qf.reduce((n,s)=>(n[s]="function",n),t);return Jt(r,e)}function zf(r,t,e){if(e<ct)throw new Error("Expected power > 0");if(e===ct)return r.ONE;if(e===Q)return t;let n=r.ONE,s=t;for(;e>ct;)e&Q&&(n=r.mul(n,s)),s=r.sqr(s),e>>=Q;return n}function Gf(r,t){let e=new Array(t.length),n=t.reduce((o,i,a)=>r.is0(i)?o:(e[a]=o,r.mul(o,i)),r.ONE),s=r.inv(n);return t.reduceRight((o,i,a)=>r.is0(i)?o:(e[a]=r.mul(o,e[a]),r.mul(o,i)),s),e}function bo(r,t){let e=t!==void 0?t:r.toString(2).length,n=Math.ceil(e/8);return{nBitLength:e,nByteLength:n}}function Ce(r,t,e=!1,n={}){if(r<=ct)throw new Error(`Expected Field ORDER > 0, got ${r}`);let{nBitLength:s,nByteLength:o}=bo(r,t);if(o>2048)throw new Error("Field lengths over 2048 bytes are not supported");let i=$f(r),a=Object.freeze({ORDER:r,BITS:s,BYTES:o,MASK:Rr(s),ZERO:ct,ONE:Q,create:c=>Z(c,r),isValid:c=>{if(typeof c!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof c}`);return ct<=c&&c<r},is0:c=>c===ct,isOdd:c=>(c&Q)===Q,neg:c=>Z(-c,r),eql:(c,l)=>c===l,sqr:c=>Z(c*c,r),add:(c,l)=>Z(c+l,r),sub:(c,l)=>Z(c-l,r),mul:(c,l)=>Z(c*l,r),pow:(c,l)=>zf(a,c,l),div:(c,l)=>Z(c*xn(l,r),r),sqrN:c=>c*c,addN:(c,l)=>c+l,subN:(c,l)=>c-l,mulN:(c,l)=>c*l,inv:c=>xn(c,r),sqrt:n.sqrt||(c=>i(a,c)),invertBatch:c=>Gf(a,c),cmov:(c,l,u)=>u?l:c,toBytes:c=>e?$e(c,o):Ne(c,o),fromBytes:c=>{if(c.length!==o)throw new Error(`Fp.fromBytes: expected ${o}, got ${c.length}`);return e?ke(c):ue(c)}});return Object.freeze(a)}function Ia(r){if(typeof r!="bigint")throw new Error("field order must be bigint");let t=r.toString(2).length;return Math.ceil(t/8)}function wo(r){let t=Ia(r);return t+Math.ceil(t/2)}function ka(r,t,e=!1){let n=r.length,s=Ia(t),o=wo(t);if(n<16||n<o||n>1024)throw new Error(`expected ${o}-1024 bytes of input, got ${n}`);let i=e?ue(r):ke(r),a=Z(i,t-Q)+Q;return e?$e(a,s):Ne(a,s)}var jf=BigInt(0),xo=BigInt(1),vo=new WeakMap,Na=new WeakMap;function vn(r,t){let e=(o,i)=>{let a=i.negate();return o?a:i},n=o=>{if(!Number.isSafeInteger(o)||o<=0||o>t)throw new Error(`Wrong window size=${o}, should be [1..${t}]`)},s=o=>{n(o);let i=Math.ceil(t/o)+1,a=2**(o-1);return{windows:i,windowSize:a}};return{constTimeNegate:e,unsafeLadder(o,i){let a=r.ZERO,c=o;for(;i>jf;)i&xo&&(a=a.add(c)),c=c.double(),i>>=xo;return a},precomputeWindow(o,i){let{windows:a,windowSize:c}=s(i),l=[],u=o,f=u;for(let h=0;h<a;h++){f=u,l.push(f);for(let g=1;g<c;g++)f=f.add(u),l.push(f);u=f.double()}return l},wNAF(o,i,a){let{windows:c,windowSize:l}=s(o),u=r.ZERO,f=r.BASE,h=BigInt(2**o-1),g=2**o,m=BigInt(o);for(let b=0;b<c;b++){let d=b*l,x=Number(a&h);a>>=m,x>l&&(x-=g,a+=xo);let B=d,y=d+Math.abs(x)-1,S=b%2!==0,U=x<0;x===0?f=f.add(e(S,i[B])):u=u.add(e(U,i[y]))}return{p:u,f}},wNAFCached(o,i,a){let c=Na.get(o)||1,l=vo.get(o);return l||(l=this.precomputeWindow(o,c),c!==1&&vo.set(o,a(l))),this.wNAF(c,l,i)},setWindowSize(o,i){n(i),Na.set(o,i),vo.delete(o)}}}function En(r,t,e,n){if(!Array.isArray(e)||!Array.isArray(n)||n.length!==e.length)throw new Error("arrays of points and scalars must have equal length");n.forEach((u,f)=>{if(!t.isValid(u))throw new Error(`wrong scalar at index ${f}`)}),e.forEach((u,f)=>{if(!(u instanceof r))throw new Error(`wrong point at index ${f}`)});let s=po(BigInt(e.length)),o=s>12?s-3:s>4?s-2:s?2:1,i=(1<<o)-1,a=new Array(i+1).fill(r.ZERO),c=Math.floor((t.BITS-1)/o)*o,l=r.ZERO;for(let u=c;u>=0;u-=o){a.fill(r.ZERO);for(let h=0;h<n.length;h++){let g=n[h],m=Number(g>>BigInt(u)&BigInt(i));a[m]=a[m].add(e[h])}let f=r.ZERO;for(let h=a.length-1,g=r.ZERO;h>0;h--)g=g.add(a[h]),f=f.add(g);if(l=l.add(f),u!==0)for(let h=0;h<o;h++)l=l.double()}return l}function _r(r){return yo(r.Fp),Jt(r,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...bo(r.n,r.nBitLength),...r,p:r.Fp.ORDER})}var Kt=BigInt(0),Tt=BigInt(1),Bn=BigInt(2),Zf=BigInt(8),Yf={zip215:!0};function Jf(r){let t=_r(r);return Jt(r,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...t})}function Ca(r){let t=Jf(r),{Fp:e,n,prehash:s,hash:o,randomBytes:i,nByteLength:a,h:c}=t,l=Bn<<BigInt(a*8)-Tt,u=e.create,f=Ce(t.n,t.nBitLength),h=t.uvRatio||((w,p)=>{try{return{isValid:!0,value:e.sqrt(w*e.inv(p))}}catch{return{isValid:!1,value:Kt}}}),g=t.adjustScalarBytes||(w=>w),m=t.domain||((w,p,v)=>{if(Ht("phflag",v),p.length||v)throw new Error("Contexts/pre-hash are not supported");return w});function b(w,p){Ct("coordinate "+w,p,Kt,l)}function d(w){if(!(w instanceof y))throw new Error("ExtendedPoint expected")}let x=qe((w,p)=>{let{ex:v,ey:C,ez:R}=w,_=w.is0();p==null&&(p=_?Zf:e.inv(R));let V=u(v*p),F=u(C*p),D=u(R*p);if(_)return{x:Kt,y:Tt};if(D!==Tt)throw new Error("invZ was invalid");return{x:V,y:F}}),B=qe(w=>{let{a:p,d:v}=t;if(w.is0())throw new Error("bad point: ZERO");let{ex:C,ey:R,ez:_,et:V}=w,F=u(C*C),D=u(R*R),j=u(_*_),J=u(j*j),ut=u(F*p),ft=u(j*u(ut+D)),dt=u(J+u(v*u(F*D)));if(ft!==dt)throw new Error("bad point: equation left != right (1)");let At=u(C*R),at=u(_*V);if(At!==at)throw new Error("bad point: equation left != right (2)");return!0});class y{constructor(p,v,C,R){this.ex=p,this.ey=v,this.ez=C,this.et=R,b("x",p),b("y",v),b("z",C),b("t",R),Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(p){if(p instanceof y)throw new Error("extended point not allowed");let{x:v,y:C}=p||{};return b("x",v),b("y",C),new y(v,C,Tt,u(v*C))}static normalizeZ(p){let v=e.invertBatch(p.map(C=>C.ez));return p.map((C,R)=>C.toAffine(v[R])).map(y.fromAffine)}static msm(p,v){return En(y,f,p,v)}_setWindowSize(p){L.setWindowSize(this,p)}assertValidity(){B(this)}equals(p){d(p);let{ex:v,ey:C,ez:R}=this,{ex:_,ey:V,ez:F}=p,D=u(v*F),j=u(_*R),J=u(C*F),ut=u(V*R);return D===j&&J===ut}is0(){return this.equals(y.ZERO)}negate(){return new y(u(-this.ex),this.ey,this.ez,u(-this.et))}double(){let{a:p}=t,{ex:v,ey:C,ez:R}=this,_=u(v*v),V=u(C*C),F=u(Bn*u(R*R)),D=u(p*_),j=v+C,J=u(u(j*j)-_-V),ut=D+V,ft=ut-F,dt=D-V,At=u(J*ft),at=u(ut*dt),Nt=u(J*dt),se=u(ft*ut);return new y(At,at,se,Nt)}add(p){d(p);let{a:v,d:C}=t,{ex:R,ey:_,ez:V,et:F}=this,{ex:D,ey:j,ez:J,et:ut}=p;if(v===BigInt(-1)){let qi=u((_-R)*(j+D)),zi=u((_+R)*(j-D)),Gs=u(zi-qi);if(Gs===Kt)return this.double();let Gi=u(V*Bn*ut),Wi=u(F*Bn*J),ji=Wi+Gi,Zi=zi+qi,Yi=Wi-Gi,iu=u(ji*Gs),au=u(Zi*Yi),cu=u(ji*Yi),lu=u(Gs*Zi);return new y(iu,au,lu,cu)}let ft=u(R*D),dt=u(_*j),At=u(F*C*ut),at=u(V*J),Nt=u((R+_)*(D+j)-ft-dt),se=at-At,Ar=at+At,Sr=u(dt-v*ft),ru=u(Nt*se),nu=u(Ar*Sr),su=u(Nt*Sr),ou=u(se*Ar);return new y(ru,nu,ou,su)}subtract(p){return this.add(p.negate())}wNAF(p){return L.wNAFCached(this,p,y.normalizeZ)}multiply(p){let v=p;Ct("scalar",v,Tt,n);let{p:C,f:R}=this.wNAF(v);return y.normalizeZ([C,R])[0]}multiplyUnsafe(p){let v=p;return Ct("scalar",v,Kt,n),v===Kt?U:this.equals(U)||v===Tt?this:this.equals(S)?this.wNAF(v).p:L.unsafeLadder(this,v)}isSmallOrder(){return this.multiplyUnsafe(c).is0()}isTorsionFree(){return L.unsafeLadder(this,n).is0()}toAffine(p){return x(this,p)}clearCofactor(){let{h:p}=t;return p===Tt?this:this.multiplyUnsafe(p)}static fromHex(p,v=!1){let{d:C,a:R}=t,_=e.BYTES;p=st("pointHex",p,_),Ht("zip215",v);let V=p.slice(),F=p[_-1];V[_-1]=F&-129;let D=ke(V),j=v?l:e.ORDER;Ct("pointHex.y",D,Kt,j);let J=u(D*D),ut=u(J-Tt),ft=u(C*J-R),{isValid:dt,value:At}=h(ut,ft);if(!dt)throw new Error("Point.fromHex: invalid y coordinate");let at=(At&Tt)===Tt,Nt=(F&128)!==0;if(!v&&At===Kt&&Nt)throw new Error("Point.fromHex: x=0 and x_0=1");return Nt!==at&&(At=u(-At)),y.fromAffine({x:At,y:D})}static fromPrivateKey(p){return T(p).point}toRawBytes(){let{x:p,y:v}=this.toAffine(),C=$e(v,e.BYTES);return C[C.length-1]|=p&Tt?128:0,C}toHex(){return le(this.toRawBytes())}}y.BASE=new y(t.Gx,t.Gy,Tt,u(t.Gx*t.Gy)),y.ZERO=new y(Kt,Tt,Tt,Kt);let{BASE:S,ZERO:U}=y,L=vn(y,a*8);function I(w){return Z(w,n)}function k(w){return I(ke(w))}function T(w){let p=a;w=st("private key",w,p);let v=st("hashed private key",o(w),2*p),C=g(v.slice(0,p)),R=v.slice(p,2*p),_=k(C),V=S.multiply(_),F=V.toRawBytes();return{head:C,prefix:R,scalar:_,point:V,pointBytes:F}}function ot(w){return T(w).pointBytes}function $(w=new Uint8Array,...p){let v=fe(...p);return k(o(m(v,st("context",w),!!s)))}function O(w,p,v={}){w=st("message",w),s&&(w=s(w));let{prefix:C,scalar:R,pointBytes:_}=T(p),V=$(v.context,C,w),F=S.multiply(V).toRawBytes(),D=$(v.context,F,_,w),j=I(V+D*R);Ct("signature.s",j,Kt,n);let J=fe(F,$e(j,e.BYTES));return st("result",J,a*2)}let it=Yf;function E(w,p,v,C=it){let{context:R,zip215:_}=C,V=e.BYTES;w=st("signature",w,2*V),p=st("message",p),_!==void 0&&Ht("zip215",_),s&&(p=s(p));let F=ke(w.slice(V,2*V)),D,j,J;try{D=y.fromHex(v,_),j=y.fromHex(w.slice(0,V),_),J=S.multiplyUnsafe(F)}catch{return!1}if(!_&&D.isSmallOrder())return!1;let ut=$(R,j.toRawBytes(),D.toRawBytes(),p);return j.add(D.multiplyUnsafe(ut)).subtract(J).clearCofactor().equals(y.ZERO)}return S._setWindowSize(8),{CURVE:t,getPublicKey:ot,sign:O,verify:E,ExtendedPoint:y,utils:{getExtendedPublicKey:T,randomPrivateKey:()=>i(e.BYTES),precompute(w=8,p=y.BASE){return p._setWindowSize(w),p.multiply(BigInt(3)),p}}}}var Eo=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),Ta=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),Bp=BigInt(0),Xf=BigInt(1),La=BigInt(2),Ap=BigInt(3),Qf=BigInt(5),th=BigInt(8);function eh(r){let t=BigInt(10),e=BigInt(20),n=BigInt(40),s=BigInt(80),o=Eo,a=r*r%o*r%o,c=tt(a,La,o)*a%o,l=tt(c,Xf,o)*r%o,u=tt(l,Qf,o)*l%o,f=tt(u,t,o)*u%o,h=tt(f,e,o)*f%o,g=tt(h,n,o)*h%o,m=tt(g,s,o)*g%o,b=tt(m,s,o)*g%o,d=tt(b,t,o)*u%o;return{pow_p_5_8:tt(d,La,o)*r%o,b2:a}}function rh(r){return r[0]&=248,r[31]&=127,r[31]|=64,r}function nh(r,t){let e=Eo,n=Z(t*t*t,e),s=Z(n*n*t,e),o=eh(r*s).pow_p_5_8,i=Z(r*n*o,e),a=Z(t*i*i,e),c=i,l=Z(i*Ta,e),u=a===r,f=a===Z(-r,e),h=a===Z(-r*Ta,e);return u&&(i=c),(f||h)&&(i=l),Sa(i,e)&&(i=Z(-i,e)),{isValid:u||f,value:i}}var sh=Ce(Eo,void 0,!0),oh={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:sh,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:th,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:xa,randomBytes:gn,adjustScalarBytes:rh,uvRatio:nh},Ua=Ca(oh);var An=32;function Ra(r,t,e){return Ua.verify(t,e instanceof Uint8Array?e:e.subarray(),r)}var Sn=class{type="Ed25519";raw;constructor(t){this.raw=Bo(t,An)}toMultihash(){return ae.digest(Te(this))}toCID(){return pt.createV1(114,this.toMultihash())}toString(){return X.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:bt(this.raw,t.raw)}verify(t,e){return Ra(this.raw,e,t)}};function Ao(r){return r=Bo(r,An),new Sn(r)}function Bo(r,t){if(r=Uint8Array.from(r??[]),r.length!==t)throw new It(`Key must be a Uint8Array of length ${t}, got ${r.length}`);return r}function mt(r=0){return new Uint8Array(r)}function Lt(r=0){return new Uint8Array(r)}var ah=Math.pow(2,7),ch=Math.pow(2,14),lh=Math.pow(2,21),So=Math.pow(2,28),Io=Math.pow(2,35),ko=Math.pow(2,42),No=Math.pow(2,49),W=128,wt=127;function xt(r){if(r<ah)return 1;if(r<ch)return 2;if(r<lh)return 3;if(r<So)return 4;if(r<Io)return 5;if(r<ko)return 6;if(r<No)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function Co(r,t,e=0){switch(xt(r)){case 8:t[e++]=r&255|W,r/=128;case 7:t[e++]=r&255|W,r/=128;case 6:t[e++]=r&255|W,r/=128;case 5:t[e++]=r&255|W,r/=128;case 4:t[e++]=r&255|W,r>>>=7;case 3:t[e++]=r&255|W,r>>>=7;case 2:t[e++]=r&255|W,r>>>=7;case 1:{t[e++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return t}function uh(r,t,e=0){switch(xt(r)){case 8:t.set(e++,r&255|W),r/=128;case 7:t.set(e++,r&255|W),r/=128;case 6:t.set(e++,r&255|W),r/=128;case 5:t.set(e++,r&255|W),r/=128;case 4:t.set(e++,r&255|W),r>>>=7;case 3:t.set(e++,r&255|W),r>>>=7;case 2:t.set(e++,r&255|W),r>>>=7;case 1:{t.set(e++,r&255),r>>>=7;break}default:throw new Error("unreachable")}return t}function To(r,t){let e=r[t],n=0;if(n+=e&wt,e<W||(e=r[t+1],n+=(e&wt)<<7,e<W)||(e=r[t+2],n+=(e&wt)<<14,e<W)||(e=r[t+3],n+=(e&wt)<<21,e<W)||(e=r[t+4],n+=(e&wt)*So,e<W)||(e=r[t+5],n+=(e&wt)*Io,e<W)||(e=r[t+6],n+=(e&wt)*ko,e<W)||(e=r[t+7],n+=(e&wt)*No,e<W))return n;throw new RangeError("Could not decode varint")}function fh(r,t){let e=r.get(t),n=0;if(n+=e&wt,e<W||(e=r.get(t+1),n+=(e&wt)<<7,e<W)||(e=r.get(t+2),n+=(e&wt)<<14,e<W)||(e=r.get(t+3),n+=(e&wt)<<21,e<W)||(e=r.get(t+4),n+=(e&wt)*So,e<W)||(e=r.get(t+5),n+=(e&wt)*Io,e<W)||(e=r.get(t+6),n+=(e&wt)*ko,e<W)||(e=r.get(t+7),n+=(e&wt)*No,e<W))return n;throw new RangeError("Could not decode varint")}function Ot(r,t,e=0){return t==null&&(t=Lt(xt(r))),t instanceof Uint8Array?Co(r,t,e):uh(r,t,e)}function he(r,t=0){return r instanceof Uint8Array?To(r,t):fh(r,t)}var Lo=new Float32Array([-0]),Le=new Uint8Array(Lo.buffer);function Pa(r,t,e){Lo[0]=r,t[e]=Le[0],t[e+1]=Le[1],t[e+2]=Le[2],t[e+3]=Le[3]}function Oa(r,t){return Le[0]=r[t],Le[1]=r[t+1],Le[2]=r[t+2],Le[3]=r[t+3],Lo[0]}var Uo=new Float64Array([-0]),vt=new Uint8Array(Uo.buffer);function Va(r,t,e){Uo[0]=r,t[e]=vt[0],t[e+1]=vt[1],t[e+2]=vt[2],t[e+3]=vt[3],t[e+4]=vt[4],t[e+5]=vt[5],t[e+6]=vt[6],t[e+7]=vt[7]}function Da(r,t){return vt[0]=r[t],vt[1]=r[t+1],vt[2]=r[t+2],vt[3]=r[t+3],vt[4]=r[t+4],vt[5]=r[t+5],vt[6]=r[t+6],vt[7]=r[t+7],Uo[0]}var hh=BigInt(Number.MAX_SAFE_INTEGER),dh=BigInt(Number.MIN_SAFE_INTEGER),_t=class r{lo;hi;constructor(t,e){this.lo=t|0,this.hi=e|0}toNumber(t=!1){if(!t&&this.hi>>>31>0){let e=~this.lo+1>>>0,n=~this.hi>>>0;return e===0&&(n=n+1>>>0),-(e+n*4294967296)}return this.lo+this.hi*4294967296}toBigInt(t=!1){if(t)return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31){let e=~this.lo+1>>>0,n=~this.hi>>>0;return e===0&&(n=n+1>>>0),-(BigInt(e)+(BigInt(n)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toString(t=!1){return this.toBigInt(t).toString()}zzEncode(){let t=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^t)>>>0,this.lo=(this.lo<<1^t)>>>0,this}zzDecode(){let t=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^t)>>>0,this.hi=(this.hi>>>1^t)>>>0,this}length(){let t=this.lo,e=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return n===0?e===0?t<16384?t<128?1:2:t<2097152?3:4:e<16384?e<128?5:6:e<2097152?7:8:n<128?9:10}static fromBigInt(t){if(t===0n)return Ge;if(t<hh&&t>dh)return this.fromNumber(Number(t));let e=t<0n;e&&(t=-t);let n=t>>32n,s=t-(n<<32n);return e&&(n=~n|0n,s=~s|0n,++s>Ma&&(s=0n,++n>Ma&&(n=0n))),new r(Number(s),Number(n))}static fromNumber(t){if(t===0)return Ge;let e=t<0;e&&(t=-t);let n=t>>>0,s=(t-n)/4294967296>>>0;return e&&(s=~s>>>0,n=~n>>>0,++n>4294967295&&(n=0,++s>4294967295&&(s=0))),new r(n,s)}static from(t){return typeof t=="number"?r.fromNumber(t):typeof t=="bigint"?r.fromBigInt(t):typeof t=="string"?r.fromBigInt(BigInt(t)):t.low!=null||t.high!=null?new r(t.low>>>0,t.high>>>0):Ge}},Ge=new _t(0,0);Ge.toBigInt=function(){return 0n};Ge.zzEncode=Ge.zzDecode=function(){return this};Ge.length=function(){return 1};var Ma=4294967296n;function Fa(r){let t=0,e=0;for(let n=0;n<r.length;++n)e=r.charCodeAt(n),e<128?t+=1:e<2048?t+=2:(e&64512)===55296&&(r.charCodeAt(n+1)&64512)===56320?(++n,t+=4):t+=3;return t}function Ha(r,t,e){if(e-t<1)return"";let s,o=[],i=0,a;for(;t<e;)a=r[t++],a<128?o[i++]=a:a>191&&a<224?o[i++]=(a&31)<<6|r[t++]&63:a>239&&a<365?(a=((a&7)<<18|(r[t++]&63)<<12|(r[t++]&63)<<6|r[t++]&63)-65536,o[i++]=55296+(a>>10),o[i++]=56320+(a&1023)):o[i++]=(a&15)<<12|(r[t++]&63)<<6|r[t++]&63,i>8191&&((s??(s=[])).push(String.fromCharCode.apply(String,o)),i=0);return s!=null?(i>0&&s.push(String.fromCharCode.apply(String,o.slice(0,i))),s.join("")):String.fromCharCode.apply(String,o.slice(0,i))}function Ro(r,t,e){let n=e,s,o;for(let i=0;i<r.length;++i)s=r.charCodeAt(i),s<128?t[e++]=s:s<2048?(t[e++]=s>>6|192,t[e++]=s&63|128):(s&64512)===55296&&((o=r.charCodeAt(i+1))&64512)===56320?(s=65536+((s&1023)<<10)+(o&1023),++i,t[e++]=s>>18|240,t[e++]=s>>12&63|128,t[e++]=s>>6&63|128,t[e++]=s&63|128):(t[e++]=s>>12|224,t[e++]=s>>6&63|128,t[e++]=s&63|128);return e-n}function $t(r,t){return RangeError(`index out of range: ${r.pos} + ${t??1} > ${r.len}`)}function kn(r,t){return(r[t-4]|r[t-3]<<8|r[t-2]<<16|r[t-1]<<24)>>>0}var _o=class{buf;pos;len;_slice=Uint8Array.prototype.subarray;constructor(t){this.buf=t,this.pos=0,this.len=t.length}uint32(){let t=4294967295;if(t=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(t=(t|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return t;if((this.pos+=5)>this.len)throw this.pos=this.len,$t(this,10);return t}int32(){return this.uint32()|0}sint32(){let t=this.uint32();return t>>>1^-(t&1)|0}bool(){return this.uint32()!==0}fixed32(){if(this.pos+4>this.len)throw $t(this,4);return kn(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw $t(this,4);return kn(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw $t(this,4);let t=Oa(this.buf,this.pos);return this.pos+=4,t}double(){if(this.pos+8>this.len)throw $t(this,4);let t=Da(this.buf,this.pos);return this.pos+=8,t}bytes(){let t=this.uint32(),e=this.pos,n=this.pos+t;if(n>this.len)throw $t(this,t);return this.pos+=t,e===n?new Uint8Array(0):this.buf.subarray(e,n)}string(){let t=this.bytes();return Ha(t,0,t.length)}skip(t){if(typeof t=="number"){if(this.pos+t>this.len)throw $t(this,t);this.pos+=t}else do if(this.pos>=this.len)throw $t(this);while(this.buf[this.pos++]&128);return this}skipType(t){switch(t){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(t=this.uint32()&7)!==4;)this.skipType(t);break;case 5:this.skip(4);break;default:throw Error(`invalid wire type ${t} at offset ${this.pos}`)}return this}readLongVarint(){let t=new _t(0,0),e=0;if(this.len-this.pos>4){for(;e<4;++e)if(t.lo=(t.lo|(this.buf[this.pos]&127)<<e*7)>>>0,this.buf[this.pos++]<128)return t;if(t.lo=(t.lo|(this.buf[this.pos]&127)<<28)>>>0,t.hi=(t.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return t;e=0}else{for(;e<3;++e){if(this.pos>=this.len)throw $t(this);if(t.lo=(t.lo|(this.buf[this.pos]&127)<<e*7)>>>0,this.buf[this.pos++]<128)return t}return t.lo=(t.lo|(this.buf[this.pos++]&127)<<e*7)>>>0,t}if(this.len-this.pos>4){for(;e<5;++e)if(t.hi=(t.hi|(this.buf[this.pos]&127)<<e*7+3)>>>0,this.buf[this.pos++]<128)return t}else for(;e<5;++e){if(this.pos>=this.len)throw $t(this);if(t.hi=(t.hi|(this.buf[this.pos]&127)<<e*7+3)>>>0,this.buf[this.pos++]<128)return t}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw $t(this,8);let t=kn(this.buf,this.pos+=4),e=kn(this.buf,this.pos+=4);return new _t(t,e)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){let t=To(this.buf,this.pos);return this.pos+=xt(t),t}uint64String(){return this.readLongVarint().toString(!0)}sint64(){return this.readLongVarint().zzDecode().toBigInt()}sint64Number(){return this.readLongVarint().zzDecode().toNumber()}sint64String(){return this.readLongVarint().zzDecode().toString()}fixed64(){return this.readFixed64().toBigInt()}fixed64Number(){return this.readFixed64().toNumber()}fixed64String(){return this.readFixed64().toString()}sfixed64(){return this.readFixed64().toBigInt()}sfixed64Number(){return this.readFixed64().toNumber()}sfixed64String(){return this.readFixed64().toString()}};function Po(r){return new _o(r instanceof Uint8Array?r:r.subarray())}function qt(r,t,e){let n=Po(r);return t.decode(n,void 0,e)}var Oo={};St(Oo,{base10:()=>ph});var ph=Ee({prefix:"9",name:"base10",alphabet:"0123456789"});var Vo={};St(Vo,{base16:()=>mh,base16upper:()=>gh});var mh=nt({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),gh=nt({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Do={};St(Do,{base2:()=>yh});var yh=nt({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Mo={};St(Mo,{base256emoji:()=>Eh});var $a=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}"),bh=$a.reduce((r,t,e)=>(r[e]=t,r),[]),wh=$a.reduce((r,t,e)=>{let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);return r[n]=e,r},[]);function xh(r){return r.reduce((t,e)=>(t+=bh[e],t),"")}function vh(r){let t=[];for(let e of r){let n=e.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${e}`);let s=wh[n];if(s==null)throw new Error(`Non-base256emoji character: ${e}`);t.push(s)}return new Uint8Array(t)}var Eh=Qe({prefix:"\u{1F680}",name:"base256emoji",encode:xh,decode:vh});var Ho={};St(Ho,{base64:()=>Bh,base64pad:()=>Ah,base64url:()=>Fo,base64urlpad:()=>Sh});var Bh=nt({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Ah=nt({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Fo=nt({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Sh=nt({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Ko={};St(Ko,{base8:()=>Ih});var Ih=nt({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var $o={};St($o,{identity:()=>kh});var kh=Qe({prefix:"\0",name:"identity",encode:r=>ta(r),decode:r=>Qi(r)});var im=new TextEncoder,am=new TextDecoder;var Go={};St(Go,{sha256:()=>Pr,sha512:()=>Th});function zo({name:r,code:t,encode:e}){return new qo(r,t,e)}var qo=class{name;code;encode;constructor(t,e,n){this.name=t,this.code=e,this.encode=n}digest(t){if(t instanceof Uint8Array){let e=this.encode(t);return e instanceof Uint8Array?Mt(this.code,e):e.then(n=>Mt(this.code,n))}else throw Error("Unknown type, must be binary type")}};function za(r){return async t=>new Uint8Array(await crypto.subtle.digest(r,t))}var Pr=zo({name:"sha2-256",code:18,encode:za("SHA-256")}),Th=zo({name:"sha2-512",code:19,encode:za("SHA-512")});var Or={...$o,...Do,...Ko,...Oo,...Vo,...eo,...ro,...to,...Ho,...Mo},wm={...Go,...oo};function Wa(r,t,e,n){return{name:r,prefix:t,encoder:{name:r,prefix:t,encode:e},decoder:{decode:n}}}var Ga=Wa("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),Wo=Wa("ascii","a",r=>{let t="a";for(let e=0;e<r.length;e++)t+=String.fromCharCode(r[e]);return t},r=>{r=r.substring(1);let t=Lt(r.length);for(let e=0;e<r.length;e++)t[e]=r.charCodeAt(e);return t}),Lh={utf8:Ga,"utf-8":Ga,hex:Or.base16,latin1:Wo,ascii:Wo,binary:Wo,...Or},Nn=Lh;function q(r,t="utf8"){let e=Nn[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.decoder.decode(`${e.prefix}${r}`)}function jo(r){let t=r??8192,e=t>>>1,n,s=t;return function(i){if(i<1||i>e)return Lt(i);s+i>t&&(n=Lt(t),s=0);let a=n.subarray(s,s+=i);return s&7&&(s=(s|7)+1),a}}var We=class{fn;len;next;val;constructor(t,e,n){this.fn=t,this.len=e,this.next=void 0,this.val=n}};function Zo(){}var Jo=class{head;tail;len;next;constructor(t){this.head=t.head,this.tail=t.tail,this.len=t.len,this.next=t.states}},Uh=jo();function Rh(r){return globalThis.Buffer!=null?Lt(r):Uh(r)}var Dr=class{len;head;tail;states;constructor(){this.len=0,this.head=new We(Zo,0,0),this.tail=this.head,this.states=null}_push(t,e,n){return this.tail=this.tail.next=new We(t,e,n),this.len+=e,this}uint32(t){return this.len+=(this.tail=this.tail.next=new Xo((t=t>>>0)<128?1:t<16384?2:t<2097152?3:t<268435456?4:5,t)).len,this}int32(t){return t<0?this._push(Cn,10,_t.fromNumber(t)):this.uint32(t)}sint32(t){return this.uint32((t<<1^t>>31)>>>0)}uint64(t){let e=_t.fromBigInt(t);return this._push(Cn,e.length(),e)}uint64Number(t){return this._push(Co,xt(t),t)}uint64String(t){return this.uint64(BigInt(t))}int64(t){return this.uint64(t)}int64Number(t){return this.uint64Number(t)}int64String(t){return this.uint64String(t)}sint64(t){let e=_t.fromBigInt(t).zzEncode();return this._push(Cn,e.length(),e)}sint64Number(t){let e=_t.fromNumber(t).zzEncode();return this._push(Cn,e.length(),e)}sint64String(t){return this.sint64(BigInt(t))}bool(t){return this._push(Yo,1,t?1:0)}fixed32(t){return this._push(Vr,4,t>>>0)}sfixed32(t){return this.fixed32(t)}fixed64(t){let e=_t.fromBigInt(t);return this._push(Vr,4,e.lo)._push(Vr,4,e.hi)}fixed64Number(t){let e=_t.fromNumber(t);return this._push(Vr,4,e.lo)._push(Vr,4,e.hi)}fixed64String(t){return this.fixed64(BigInt(t))}sfixed64(t){return this.fixed64(t)}sfixed64Number(t){return this.fixed64Number(t)}sfixed64String(t){return this.fixed64String(t)}float(t){return this._push(Pa,4,t)}double(t){return this._push(Va,8,t)}bytes(t){let e=t.length>>>0;return e===0?this._push(Yo,1,0):this.uint32(e)._push(Ph,e,t)}string(t){let e=Fa(t);return e!==0?this.uint32(e)._push(Ro,e,t):this._push(Yo,1,0)}fork(){return this.states=new Jo(this),this.head=this.tail=new We(Zo,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 We(Zo,0,0),this.len=0),this}ldelim(){let t=this.head,e=this.tail,n=this.len;return this.reset().uint32(n),n!==0&&(this.tail.next=t.next,this.tail=e,this.len+=n),this}finish(){let t=this.head.next,e=Rh(this.len),n=0;for(;t!=null;)t.fn(t.val,e,n),n+=t.len,t=t.next;return e}};function Yo(r,t,e){t[e]=r&255}function _h(r,t,e){for(;r>127;)t[e++]=r&127|128,r>>>=7;t[e]=r}var Xo=class extends We{next;constructor(t,e){super(_h,t,e),this.next=void 0}};function Cn(r,t,e){for(;r.hi!==0;)t[e++]=r.lo&127|128,r.lo=(r.lo>>>7|r.hi<<25)>>>0,r.hi>>>=7;for(;r.lo>127;)t[e++]=r.lo&127|128,r.lo=r.lo>>>7;t[e++]=r.lo}function Vr(r,t,e){t[e]=r&255,t[e+1]=r>>>8&255,t[e+2]=r>>>16&255,t[e+3]=r>>>24}function Ph(r,t,e){t.set(r,e)}globalThis.Buffer!=null&&(Dr.prototype.bytes=function(r){let t=r.length>>>0;return this.uint32(t),t>0&&this._push(Oh,t,r),this},Dr.prototype.string=function(r){let t=globalThis.Buffer.byteLength(r);return this.uint32(t),t>0&&this._push(Vh,t,r),this});function Oh(r,t,e){t.set(r,e)}function Vh(r,t,e){r.length<40?Ro(r,t,e):t.utf8Write!=null?t.utf8Write(r,e):t.set(q(r),e)}function Qo(){return new Dr}function zt(r,t){let e=Qo();return t.encode(r,e,{lengthDelimited:!1}),e.finish()}var cr;(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"})(cr||(cr={}));function Tn(r,t,e,n){return{name:r,type:t,encode:e,decode:n}}function ti(r){function t(s){if(r[s.toString()]==null)throw new Error("Invalid enum value");return r[s]}let e=function(o,i){let a=t(o);i.int32(a)},n=function(o){let i=o.int32();return t(i)};return Tn("enum",cr.VARINT,e,n)}function Gt(r,t){return Tn("message",cr.LENGTH_DELIMITED,r,t)}var je=class extends Error{code="ERR_MAX_LENGTH";name="MaxLengthError"};var lt;(function(r){r.RSA="RSA",r.Ed25519="Ed25519",r.secp256k1="secp256k1"})(lt||(lt={}));var ei;(function(r){r[r.RSA=0]="RSA",r[r.Ed25519=1]="Ed25519",r[r.secp256k1=2]="secp256k1"})(ei||(ei={}));(function(r){r.codec=()=>ti(ei)})(lt||(lt={}));var Xt;(function(r){let t;r.codec=()=>(t==null&&(t=Gt((e,n,s={})=>{s.lengthDelimited!==!1&&n.fork(),e.Type!=null&&(n.uint32(8),lt.codec().encode(e.Type,n)),e.Data!=null&&(n.uint32(18),n.bytes(e.Data)),s.lengthDelimited!==!1&&n.ldelim()},(e,n,s={})=>{let o={},i=n==null?e.len:e.pos+n;for(;e.pos<i;){let a=e.uint32();switch(a>>>3){case 1:{o.Type=lt.codec().decode(e);break}case 2:{o.Data=e.bytes();break}default:{e.skipType(a&7);break}}}return o})),t),r.encode=e=>zt(e,r.codec()),r.decode=(e,n)=>qt(e,r.codec(),n)})(Xt||(Xt={}));var ri;(function(r){let t;r.codec=()=>(t==null&&(t=Gt((e,n,s={})=>{s.lengthDelimited!==!1&&n.fork(),e.Type!=null&&(n.uint32(8),lt.codec().encode(e.Type,n)),e.Data!=null&&(n.uint32(18),n.bytes(e.Data)),s.lengthDelimited!==!1&&n.ldelim()},(e,n,s={})=>{let o={},i=n==null?e.len:e.pos+n;for(;e.pos<i;){let a=e.uint32();switch(a>>>3){case 1:{o.Type=lt.codec().decode(e);break}case 2:{o.Data=e.bytes();break}default:{e.skipType(a&7);break}}}return o})),t),r.encode=e=>zt(e,r.codec()),r.decode=(e,n)=>qt(e,r.codec(),n)})(ri||(ri={}));var jr={};St(jr,{MAX_RSA_KEY_SIZE:()=>vs,generateRSAKeyPair:()=>qc,jwkToJWKKeyPair:()=>zc,jwkToPkcs1:()=>Qh,jwkToPkix:()=>fi,jwkToRSAPrivateKey:()=>$c,pkcs1ToJwk:()=>Fc,pkcs1ToRSAPrivateKey:()=>Kc,pkixToJwk:()=>Hc,pkixToRSAPublicKey:()=>hi});var Dh=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]),Ue=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Re=new Uint32Array(64),ni=class extends ir{constructor(){super(64,32,8,!1),this.A=Ue[0]|0,this.B=Ue[1]|0,this.C=Ue[2]|0,this.D=Ue[3]|0,this.E=Ue[4]|0,this.F=Ue[5]|0,this.G=Ue[6]|0,this.H=Ue[7]|0}get(){let{A:t,B:e,C:n,D:s,E:o,F:i,G:a,H:c}=this;return[t,e,n,s,o,i,a,c]}set(t,e,n,s,o,i,a,c){this.A=t|0,this.B=e|0,this.C=n|0,this.D=s|0,this.E=o|0,this.F=i|0,this.G=a|0,this.H=c|0}process(t,e){for(let f=0;f<16;f++,e+=4)Re[f]=t.getUint32(e,!1);for(let f=16;f<64;f++){let h=Re[f-15],g=Re[f-2],m=Ft(h,7)^Ft(h,18)^h>>>3,b=Ft(g,17)^Ft(g,19)^g>>>10;Re[f]=b+Re[f-7]+m+Re[f-16]|0}let{A:n,B:s,C:o,D:i,E:a,F:c,G:l,H:u}=this;for(let f=0;f<64;f++){let h=Ft(a,6)^Ft(a,11)^Ft(a,25),g=u+h+ya(a,c,l)+Dh[f]+Re[f]|0,b=(Ft(n,2)^Ft(n,13)^Ft(n,22))+ba(n,s,o)|0;u=l,l=c,c=a,a=i+g|0,i=o,o=s,s=n,n=g+b|0}n=n+this.A|0,s=s+this.B|0,o=o+this.C|0,i=i+this.D|0,a=a+this.E|0,c=c+this.F|0,l=l+this.G|0,u=u+this.H|0,this.set(n,s,o,i,a,c,l,u)}roundClean(){Re.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var lr=mn(()=>new ni);var M=js(Za());function Ze(r,t){let e=0;if(r.length===1)return r[0];for(let n=r.length-1;n>=0;n--)e+=r[r.length-1-n]*Math.pow(2,t*n);return e}function _e(r,t,e=-1){let n=e,s=r,o=0,i=Math.pow(2,t);for(let a=1;a<8;a++){if(r<i){let c;if(n<0)c=new ArrayBuffer(a),o=a;else{if(n<a)return new ArrayBuffer(0);c=new ArrayBuffer(n),o=n}let l=new Uint8Array(c);for(let u=a-1;u>=0;u--){let f=Math.pow(2,u*t);l[o-u-1]=Math.floor(s/f),s-=l[o-u-1]*f}return c}i*=Math.pow(2,t)}return new ArrayBuffer(0)}function Rn(...r){let t=0,e=0;for(let o of r)t+=o.length;let n=new ArrayBuffer(t),s=new Uint8Array(n);for(let o of r)s.set(o,e),e+=o.length;return s}function oi(){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 t=new ArrayBuffer(this.valueHex.byteLength),e=new Uint8Array(t);for(let a=0;a<this.valueHex.byteLength;a++)e[a]=0;e[0]=r[0]&128;let n=Ze(e,8),s=new ArrayBuffer(this.valueHex.byteLength),o=new Uint8Array(s);for(let a=0;a<this.valueHex.byteLength;a++)o[a]=r[a];return o[0]&=127,Ze(o,8)-n}function Ya(r){let t=r<0?r*-1:r,e=128;for(let n=1;n<8;n++){if(t<=e){if(r<0){let i=e-t,a=_e(i,8,n),c=new Uint8Array(a);return c[0]|=128,a}let s=_e(t,8,n),o=new Uint8Array(s);if(o[0]&128){let i=s.slice(0),a=new Uint8Array(i);s=new ArrayBuffer(s.byteLength+1),o=new Uint8Array(s);for(let c=0;c<i.byteLength;c++)o[c+1]=a[c];o[0]=0}return s}e*=Math.pow(2,8)}return new ArrayBuffer(0)}function Ja(r,t){if(r.byteLength!==t.byteLength)return!1;let e=new Uint8Array(r),n=new Uint8Array(t);for(let s=0;s<e.length;s++)if(e[s]!==n[s])return!1;return!0}function Ut(r,t){let e=r.toString(10);if(t<e.length)return"";let n=t-e.length,s=new Array(n);for(let i=0;i<n;i++)s[i]="0";return s.join("").concat(e)}var tg=Math.log(2);function _n(){if(typeof BigInt>"u")throw new Error("BigInt is not defined. Your environment doesn't implement BigInt.")}function ii(r){let t=0,e=0;for(let s=0;s<r.length;s++){let o=r[s];t+=o.byteLength}let n=new Uint8Array(t);for(let s=0;s<r.length;s++){let o=r[s];n.set(new Uint8Array(o),e),e+=o.byteLength}return n.buffer}function ye(r,t,e,n){return t instanceof Uint8Array?t.byteLength?e<0?(r.error="Wrong parameter: inputOffset less than zero",!1):n<0?(r.error="Wrong parameter: inputLength less than zero",!1):t.byteLength-e-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 Fr=class{constructor(){this.items=[]}write(t){this.items.push(t)}final(){return ii(this.items)}},Mr=[new Uint8Array([1])],Xa="0123456789";var pr="",Wt=new ArrayBuffer(0),ai=new Uint8Array(0),Hr="EndOfContent",tc="OCTET STRING",ec="BIT STRING";function be(r){var t;return t=class extends r{constructor(...n){var s;super(...n);let o=n[0]||{};this.isHexOnly=(s=o.isHexOnly)!==null&&s!==void 0?s:!1,this.valueHexView=o.valueHex?M.BufferSourceConverter.toUint8Array(o.valueHex):ai}get valueHex(){return this.valueHexView.slice().buffer}set valueHex(n){this.valueHexView=new Uint8Array(n)}fromBER(n,s,o){let i=n instanceof ArrayBuffer?new Uint8Array(n):n;if(!ye(this,i,s,o))return-1;let a=s+o;return this.valueHexView=i.subarray(s,a),this.valueHexView.length?(this.blockLength=o,a):(this.warnings.push("Zero buffer length"),s)}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",Wt)}toJSON(){return{...super.toJSON(),isHexOnly:this.isHexOnly,valueHex:M.Convert.ToHex(this.valueHexView)}}},t.NAME="hexBlock",t}var pe=class{constructor({blockLength:t=0,error:e=pr,warnings:n=[],valueBeforeDecode:s=ai}={}){this.blockLength=t,this.error=e,this.warnings=n,this.valueBeforeDecodeView=M.BufferSourceConverter.toUint8Array(s)}static blockName(){return this.NAME}get valueBeforeDecode(){return this.valueBeforeDecodeView.slice().buffer}set valueBeforeDecode(t){this.valueBeforeDecodeView=new Uint8Array(t)}toJSON(){return{blockName:this.constructor.NAME,blockLength:this.blockLength,error:this.error,warnings:this.warnings,valueBeforeDecode:M.Convert.ToHex(this.valueBeforeDecodeView)}}};pe.NAME="baseBlock";var Et=class extends pe{fromBER(t,e,n){throw TypeError("User need to make a specific function in a class which extends 'ValueBlock'")}toBER(t,e){throw TypeError("User need to make a specific function in a class which extends 'ValueBlock'")}};Et.NAME="valueBlock";var Pn=class extends be(pe){constructor({idBlock:t={}}={}){var e,n,s,o;super(),t?(this.isHexOnly=(e=t.isHexOnly)!==null&&e!==void 0?e:!1,this.valueHexView=t.valueHex?M.BufferSourceConverter.toUint8Array(t.valueHex):ai,this.tagClass=(n=t.tagClass)!==null&&n!==void 0?n:-1,this.tagNumber=(s=t.tagNumber)!==null&&s!==void 0?s:-1,this.isConstructed=(o=t.isConstructed)!==null&&o!==void 0?o:!1):(this.tagClass=-1,this.tagNumber=-1,this.isConstructed=!1)}toBER(t=!1){let e=0;switch(this.tagClass){case 1:e|=0;break;case 2:e|=64;break;case 3:e|=128;break;case 4:e|=192;break;default:return this.error="Unknown tag class",Wt}if(this.isConstructed&&(e|=32),this.tagNumber<31&&!this.isHexOnly){let s=new Uint8Array(1);if(!t){let o=this.tagNumber;o&=31,e|=o,s[0]=e}return s.buffer}if(!this.isHexOnly){let s=_e(this.tagNumber,7),o=new Uint8Array(s),i=s.byteLength,a=new Uint8Array(i+1);if(a[0]=e|31,!t){for(let c=0;c<i-1;c++)a[c+1]=o[c]|128;a[i]=o[i-1]}return a.buffer}let n=new Uint8Array(this.valueHexView.byteLength+1);if(n[0]=e|31,!t){let s=this.valueHexView;for(let o=0;o<s.length-1;o++)n[o+1]=s[o]|128;n[this.valueHexView.byteLength]=s[s.length-1]}return n.buffer}fromBER(t,e,n){let s=M.BufferSourceConverter.toUint8Array(t);if(!ye(this,s,e,n))return-1;let o=s.subarray(e,e+n);if(o.length===0)return this.error="Zero buffer length",-1;switch(o[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=(o[0]&32)===32,this.isHexOnly=!1;let a=o[0]&31;if(a!==31)this.tagNumber=a,this.blockLength=1;else{let c=1,l=this.valueHexView=new Uint8Array(255),u=255;for(;o[c]&128;){if(l[c-1]=o[c]&127,c++,c>=o.length)return this.error="End of input reached before message was fully decoded",-1;if(c===u){u+=255;let h=new Uint8Array(u);for(let g=0;g<l.length;g++)h[g]=l[g];l=this.valueHexView=new Uint8Array(u)}}this.blockLength=c+1,l[c-1]=o[c]&127;let f=new Uint8Array(c);for(let h=0;h<c;h++)f[h]=l[h];l=this.valueHexView=new Uint8Array(c),l.set(f),this.blockLength<=9?this.tagNumber=Ze(l,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 e+this.blockLength}toJSON(){return{...super.toJSON(),tagClass:this.tagClass,tagNumber:this.tagNumber,isConstructed:this.isConstructed}}};Pn.NAME="identificationBlock";var On=class extends pe{constructor({lenBlock:t={}}={}){var e,n,s;super(),this.isIndefiniteForm=(e=t.isIndefiniteForm)!==null&&e!==void 0?e:!1,this.longFormUsed=(n=t.longFormUsed)!==null&&n!==void 0?n:!1,this.length=(s=t.length)!==null&&s!==void 0?s:0}fromBER(t,e,n){let s=M.BufferSourceConverter.toUint8Array(t);if(!ye(this,s,e,n))return-1;let o=s.subarray(e,e+n);if(o.length===0)return this.error="Zero buffer length",-1;if(o[0]===255)return this.error="Length block 0xFF is reserved by standard",-1;if(this.isIndefiniteForm=o[0]===128,this.isIndefiniteForm)return this.blockLength=1,e+this.blockLength;if(this.longFormUsed=!!(o[0]&128),this.longFormUsed===!1)return this.length=o[0],this.blockLength=1,e+this.blockLength;let i=o[0]&127;if(i>8)return this.error="Too big integer",-1;if(i+1>o.length)return this.error="End of input reached before message was fully decoded",-1;let a=e+1,c=s.subarray(a,a+i);return c[i-1]===0&&this.warnings.push("Needlessly long encoded length"),this.length=Ze(c,8),this.longFormUsed&&this.length<=127&&this.warnings.push("Unnecessary usage of long length form"),this.blockLength=i+1,e+this.blockLength}toBER(t=!1){let e,n;if(this.length>127&&(this.longFormUsed=!0),this.isIndefiniteForm)return e=new ArrayBuffer(1),t===!1&&(n=new Uint8Array(e),n[0]=128),e;if(this.longFormUsed){let s=_e(this.length,8);if(s.byteLength>127)return this.error="Too big length",Wt;if(e=new ArrayBuffer(s.byteLength+1),t)return e;let o=new Uint8Array(s);n=new Uint8Array(e),n[0]=s.byteLength|128;for(let i=0;i<s.byteLength;i++)n[i+1]=o[i];return e}return e=new ArrayBuffer(1),t===!1&&(n=new Uint8Array(e),n[0]=this.length),e}toJSON(){return{...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,longFormUsed:this.longFormUsed,length:this.length}}};On.NAME="lengthBlock";var A={},gt=class extends pe{constructor({name:t=pr,optional:e=!1,primitiveSchema:n,...s}={},o){super(s),this.name=t,this.optional=e,n&&(this.primitiveSchema=n),this.idBlock=new Pn(s),this.lenBlock=new On(s),this.valueBlock=o?new o(s):new Et(s)}fromBER(t,e,n){let s=this.valueBlock.fromBER(t,e,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length);return s===-1?(this.error=this.valueBlock.error,s):(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),s)}toBER(t,e){let n=e||new Fr;e||rc(this);let s=this.idBlock.toBER(t);if(n.write(s),this.lenBlock.isIndefiniteForm)n.write(new Uint8Array([128]).buffer),this.valueBlock.toBER(t,n),n.write(new ArrayBuffer(2));else{let o=this.valueBlock.toBER(t);this.lenBlock.length=o.byteLength;let i=this.lenBlock.toBER(t);n.write(i),n.write(o)}return e?Wt:n.final()}toJSON(){let t={...super.toJSON(),idBlock:this.idBlock.toJSON(),lenBlock:this.lenBlock.toJSON(),valueBlock:this.valueBlock.toJSON(),name:this.name,optional:this.optional};return this.primitiveSchema&&(t.primitiveSchema=this.primitiveSchema.toJSON()),t}toString(t="ascii"){return t==="ascii"?this.onAsciiEncoding():M.Convert.ToHex(this.toBER())}onAsciiEncoding(){return`${this.constructor.NAME} : ${M.Convert.ToHex(this.valueBlock.valueBeforeDecodeView)}`}isEqual(t){if(this===t)return!0;if(!(t instanceof this.constructor))return!1;let e=this.toBER(),n=t.toBER();return Ja(e,n)}};gt.NAME="BaseBlock";function rc(r){if(r instanceof A.Constructed)for(let t of r.valueBlock.value)rc(t)&&(r.lenBlock.isIndefiniteForm=!0);return!!r.lenBlock.isIndefiniteForm}var Vn=class extends gt{constructor({value:t=pr,...e}={},n){super(e,n),t&&this.fromString(t)}getValue(){return this.valueBlock.value}setValue(t){this.valueBlock.value=t}fromBER(t,e,n){let s=this.valueBlock.fromBER(t,e,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length);return s===-1?(this.error=this.valueBlock.error,s):(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),s)}onAsciiEncoding(){return`${this.constructor.NAME} : '${this.valueBlock.value}'`}};Vn.NAME="BaseStringBlock";var Dn=class extends be(Et){constructor({isHexOnly:t=!0,...e}={}){super(e),this.isHexOnly=t}};Dn.NAME="PrimitiveValueBlock";var nc,Mn=class extends gt{constructor(t={}){super(t,Dn),this.idBlock.isConstructed=!1}};nc=Mn;A.Primitive=nc;Mn.NAME="PRIMITIVE";function Wh(r,t){if(r instanceof t)return r;let e=new t;return e.idBlock=r.idBlock,e.lenBlock=r.lenBlock,e.warnings=r.warnings,e.valueBeforeDecodeView=r.valueBeforeDecodeView,e}function ws(r,t=0,e=r.length){let n=t,s=new gt({},Et),o=new pe;if(!ye(o,r,t,e))return s.error=o.error,{offset:-1,result:s};if(!r.subarray(t,t+e).length)return s.error="Zero buffer length",{offset:-1,result:s};let a=s.idBlock.fromBER(r,t,e);if(s.idBlock.warnings.length&&s.warnings.concat(s.idBlock.warnings),a===-1)return s.error=s.idBlock.error,{offset:-1,result:s};if(t=a,e-=s.idBlock.blockLength,a=s.lenBlock.fromBER(r,t,e),s.lenBlock.warnings.length&&s.warnings.concat(s.lenBlock.warnings),a===-1)return s.error=s.lenBlock.error,{offset:-1,result:s};if(t=a,e-=s.lenBlock.blockLength,!s.idBlock.isConstructed&&s.lenBlock.isIndefiniteForm)return s.error="Indefinite length form used for primitive encoding form",{offset:-1,result:s};let c=gt;switch(s.idBlock.tagClass){case 1:if(s.idBlock.tagNumber>=37&&s.idBlock.isHexOnly===!1)return s.error="UNIVERSAL 37 and upper tags are reserved by ASN.1 standard",{offset:-1,result:s};switch(s.idBlock.tagNumber){case 0:if(s.idBlock.isConstructed&&s.lenBlock.length>0)return s.error="Type [UNIVERSAL 0] is reserved",{offset:-1,result:s};c=A.EndOfContent;break;case 1:c=A.Boolean;break;case 2:c=A.Integer;break;case 3:c=A.BitString;break;case 4:c=A.OctetString;break;case 5:c=A.Null;break;case 6:c=A.ObjectIdentifier;break;case 10:c=A.Enumerated;break;case 12:c=A.Utf8String;break;case 13:c=A.RelativeObjectIdentifier;break;case 14:c=A.TIME;break;case 15:return s.error="[UNIVERSAL 15] is reserved by ASN.1 standard",{offset:-1,result:s};case 16:c=A.Sequence;break;case 17:c=A.Set;break;case 18:c=A.NumericString;break;case 19:c=A.PrintableString;break;case 20:c=A.TeletexString;break;case 21:c=A.VideotexString;break;case 22:c=A.IA5String;break;case 23:c=A.UTCTime;break;case 24:c=A.GeneralizedTime;break;case 25:c=A.GraphicString;break;case 26:c=A.VisibleString;break;case 27:c=A.GeneralString;break;case 28:c=A.UniversalString;break;case 29:c=A.CharacterString;break;case 30:c=A.BmpString;break;case 31:c=A.DATE;break;case 32:c=A.TimeOfDay;break;case 33:c=A.DateTime;break;case 34:c=A.Duration;break;default:{let l=s.idBlock.isConstructed?new A.Constructed:new A.Primitive;l.idBlock=s.idBlock,l.lenBlock=s.lenBlock,l.warnings=s.warnings,s=l}}break;case 2:case 3:case 4:default:c=s.idBlock.isConstructed?A.Constructed:A.Primitive}return s=Wh(s,c),a=s.fromBER(r,t,s.lenBlock.isIndefiniteForm?e:s.lenBlock.length),s.valueBeforeDecodeView=r.subarray(n,n+s.blockLength),{offset:a,result:s}}function ci(r){if(!r.byteLength){let t=new gt({},Et);return t.error="Input buffer has zero length",{offset:-1,result:t}}return ws(M.BufferSourceConverter.toUint8Array(r).slice(),0,r.byteLength)}function jh(r,t){return r?1:t}var Qt=class extends Et{constructor({value:t=[],isIndefiniteForm:e=!1,...n}={}){super(n),this.value=t,this.isIndefiniteForm=e}fromBER(t,e,n){let s=M.BufferSourceConverter.toUint8Array(t);if(!ye(this,s,e,n))return-1;if(this.valueBeforeDecodeView=s.subarray(e,e+n),this.valueBeforeDecodeView.length===0)return this.warnings.push("Zero buffer length"),e;let o=e;for(;jh(this.isIndefiniteForm,n)>0;){let i=ws(s,o,n);if(i.offset===-1)return this.error=i.result.error,this.warnings.concat(i.result.warnings),-1;if(o=i.offset,this.blockLength+=i.result.blockLength,n-=i.result.blockLength,this.value.push(i.result),this.isIndefiniteForm&&i.result.constructor.NAME===Hr)break}return this.isIndefiniteForm&&(this.value[this.value.length-1].constructor.NAME===Hr?this.value.pop():this.warnings.push("No EndOfContent block encoded")),o}toBER(t,e){let n=e||new Fr;for(let s=0;s<this.value.length;s++)this.value[s].toBER(t,n);return e?Wt:n.final()}toJSON(){let t={...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,value:[]};for(let e of this.value)t.value.push(e.toJSON());return t}};Qt.NAME="ConstructedValueBlock";var sc,Pe=class extends gt{constructor(t={}){super(t,Qt),this.idBlock.isConstructed=!0}fromBER(t,e,n){this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm;let s=this.valueBlock.fromBER(t,e,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length);return s===-1?(this.error=this.valueBlock.error,s):(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),s)}onAsciiEncoding(){let t=[];for(let n of this.valueBlock.value)t.push(n.toString("ascii").split(`
|
|
2
|
+
"use strict";var Libp2PIdentify=(()=>{var Tu=Object.create;var un=Object.defineProperty;var Lu=Object.getOwnPropertyDescriptor;var Uu=Object.getOwnPropertyNames;var Ru=Object.getPrototypeOf,_u=Object.prototype.hasOwnProperty;var eo=(r,t)=>()=>(t||r((t={exports:{}}).exports,t),t.exports),St=(r,t)=>{for(var e in t)un(r,e,{get:t[e],enumerable:!0})},ua=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Uu(t))!_u.call(r,s)&&s!==e&&un(r,s,{get:()=>t[s],enumerable:!(n=Lu(t,s))||n.enumerable});return r};var ro=(r,t,e)=>(e=r!=null?Tu(Ru(r)):{},ua(t||!r||!r.__esModule?un(e,"default",{value:r,enumerable:!0}):e,r)),Ou=r=>ua(un({},"__esModule",{value:!0}),r);var pc=eo(dr=>{"use strict";var ld="[object ArrayBuffer]",ge=class r{static isArrayBuffer(t){return Object.prototype.toString.call(t)===ld}static toArrayBuffer(t){return this.isArrayBuffer(t)?t:t.byteLength===t.buffer.byteLength||t.byteOffset===0&&t.byteLength===t.buffer.byteLength?t.buffer:this.toUint8Array(t.buffer).slice(t.byteOffset,t.byteOffset+t.byteLength).buffer}static toUint8Array(t){return this.toView(t,Uint8Array)}static toView(t,e){if(t.constructor===e)return t;if(this.isArrayBuffer(t))return new e(t);if(this.isArrayBufferView(t))return new e(t.buffer,t.byteOffset,t.byteLength);throw new TypeError("The provided value is not of type '(ArrayBuffer or ArrayBufferView)'")}static isBufferSource(t){return this.isArrayBufferView(t)||this.isArrayBuffer(t)}static isArrayBufferView(t){return ArrayBuffer.isView(t)||t&&this.isArrayBuffer(t.buffer)}static isEqual(t,e){let n=r.toUint8Array(t),s=r.toUint8Array(e);if(n.length!==s.byteLength)return!1;for(let o=0;o<n.length;o++)if(n[o]!==s[o])return!1;return!0}static concat(...t){let e;Array.isArray(t[0])&&!(t[1]instanceof Function)||Array.isArray(t[0])&&t[1]instanceof Function?e=t[0]:t[t.length-1]instanceof Function?e=t.slice(0,t.length-1):e=t;let n=0;for(let i of e)n+=i.byteLength;let s=new Uint8Array(n),o=0;for(let i of e){let a=this.toUint8Array(i);s.set(a,o),o+=a.length}return t[t.length-1]instanceof Function?this.toView(s,t[t.length-1]):s.buffer}},mi="string",ud=/^[0-9a-f\s]+$/i,fd=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/,hd=/^[a-zA-Z0-9-_]+$/,Mn=class{static fromString(t){let e=unescape(encodeURIComponent(t)),n=new Uint8Array(e.length);for(let s=0;s<e.length;s++)n[s]=e.charCodeAt(s);return n.buffer}static toString(t){let e=ge.toUint8Array(t),n="";for(let o=0;o<e.length;o++)n+=String.fromCharCode(e[o]);return decodeURIComponent(escape(n))}},Pt=class{static toString(t,e=!1){let n=ge.toArrayBuffer(t),s=new DataView(n),o="";for(let i=0;i<n.byteLength;i+=2){let a=s.getUint16(i,e);o+=String.fromCharCode(a)}return o}static fromString(t,e=!1){let n=new ArrayBuffer(t.length*2),s=new DataView(n);for(let o=0;o<t.length;o++)s.setUint16(o*2,t.charCodeAt(o),e);return n}},Fn=class r{static isHex(t){return typeof t===mi&&ud.test(t)}static isBase64(t){return typeof t===mi&&fd.test(t)}static isBase64Url(t){return typeof t===mi&&hd.test(t)}static ToString(t,e="utf8"){let n=ge.toUint8Array(t);switch(e.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 Pt.toString(n,!0);case"utf16":case"utf16be":return Pt.toString(n);default:throw new Error(`Unknown type of encoding '${e}'`)}}static FromString(t,e="utf8"){if(!t)return new ArrayBuffer(0);switch(e.toLowerCase()){case"utf8":return this.FromUtf8String(t);case"binary":return this.FromBinary(t);case"hex":return this.FromHex(t);case"base64":return this.FromBase64(t);case"base64url":return this.FromBase64Url(t);case"utf16le":return Pt.fromString(t,!0);case"utf16":case"utf16be":return Pt.fromString(t);default:throw new Error(`Unknown type of encoding '${e}'`)}}static ToBase64(t){let e=ge.toUint8Array(t);if(typeof btoa<"u"){let n=this.ToString(e,"binary");return btoa(n)}else return Buffer.from(e).toString("base64")}static FromBase64(t){let e=this.formatString(t);if(!e)return new ArrayBuffer(0);if(!r.isBase64(e))throw new TypeError("Argument 'base64Text' is not Base64 encoded");return typeof atob<"u"?this.FromBinary(atob(e)):new Uint8Array(Buffer.from(e,"base64")).buffer}static FromBase64Url(t){let e=this.formatString(t);if(!e)return new ArrayBuffer(0);if(!r.isBase64Url(e))throw new TypeError("Argument 'base64url' is not Base64Url encoded");return this.FromBase64(this.Base64Padding(e.replace(/\-/g,"+").replace(/\_/g,"/")))}static ToBase64Url(t){return this.ToBase64(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/\=/g,"")}static FromUtf8String(t,e=r.DEFAULT_UTF8_ENCODING){switch(e){case"ascii":return this.FromBinary(t);case"utf8":return Mn.fromString(t);case"utf16":case"utf16be":return Pt.fromString(t);case"utf16le":case"usc2":return Pt.fromString(t,!0);default:throw new Error(`Unknown type of encoding '${e}'`)}}static ToUtf8String(t,e=r.DEFAULT_UTF8_ENCODING){switch(e){case"ascii":return this.ToBinary(t);case"utf8":return Mn.toString(t);case"utf16":case"utf16be":return Pt.toString(t);case"utf16le":case"usc2":return Pt.toString(t,!0);default:throw new Error(`Unknown type of encoding '${e}'`)}}static FromBinary(t){let e=t.length,n=new Uint8Array(e);for(let s=0;s<e;s++)n[s]=t.charCodeAt(s);return n.buffer}static ToBinary(t){let e=ge.toUint8Array(t),n="";for(let s=0;s<e.length;s++)n+=String.fromCharCode(e[s]);return n}static ToHex(t){let e=ge.toUint8Array(t),n="",s=e.length;for(let o=0;o<s;o++){let i=e[o];i<16&&(n+="0"),n+=i.toString(16)}return n}static FromHex(t){let e=this.formatString(t);if(!e)return new ArrayBuffer(0);if(!r.isHex(e))throw new TypeError("Argument 'hexString' is not HEX encoded");e.length%2&&(e=`0${e}`);let n=new Uint8Array(e.length/2);for(let s=0;s<e.length;s=s+2){let o=e.slice(s,s+2);n[s/2]=parseInt(o,16)}return n.buffer}static ToUtf16String(t,e=!1){return Pt.toString(t,e)}static FromUtf16String(t,e=!1){return Pt.fromString(t,e)}static Base64Padding(t){let e=4-t.length%4;if(e<4)for(let n=0;n<e;n++)t+="=";return t}static formatString(t){return t?.replace(/[\n\r\t ]/g,"")||""}};Fn.DEFAULT_UTF8_ENCODING="utf8";function dd(r,...t){let e=arguments[0];for(let n=1;n<arguments.length;n++){let s=arguments[n];for(let o in s)e[o]=s[o]}return e}function pd(...r){let t=r.map(s=>s.byteLength).reduce((s,o)=>s+o),e=new Uint8Array(t),n=0;return r.map(s=>new Uint8Array(s)).forEach(s=>{for(let o of s)e[n++]=o}),e.buffer}function gd(r,t){if(!(r&&t)||r.byteLength!==t.byteLength)return!1;let e=new Uint8Array(r),n=new Uint8Array(t);for(let s=0;s<r.byteLength;s++)if(e[s]!==n[s])return!1;return!0}dr.BufferSourceConverter=ge;dr.Convert=Fn;dr.assign=dd;dr.combine=pd;dr.isEqual=gd});var nu=eo(($x,ru)=>{function i0(){return!!(typeof window<"u"&&typeof window.process=="object"&&window.process.type==="renderer"||typeof process<"u"&&typeof process.versions=="object"&&process.versions.electron||typeof navigator=="object"&&typeof navigator.userAgent=="string"&&navigator.userAgent.indexOf("Electron")>=0)}ru.exports=i0});var hu=eo(on=>{(function(){var r,t,e,n,s,o,i,a;a=function(c){var l,u,f,h;return l=(c&255<<24)>>>24,u=(c&255<<16)>>>16,f=(c&65280)>>>8,h=c&255,[l,u,f,h].join(".")},i=function(c){var l,u,f,h,d,p;for(l=[],f=h=0;h<=3&&c.length!==0;f=++h){if(f>0){if(c[0]!==".")throw new Error("Invalid IP");c=c.substring(1)}p=t(c),d=p[0],u=p[1],c=c.substring(u),l.push(d)}if(c.length!==0)throw new Error("Invalid IP");switch(l.length){case 1:if(l[0]>4294967295)throw new Error("Invalid IP");return l[0]>>>0;case 2:if(l[0]>255||l[1]>16777215)throw new Error("Invalid IP");return(l[0]<<24|l[1])>>>0;case 3:if(l[0]>255||l[1]>255||l[2]>65535)throw new Error("Invalid IP");return(l[0]<<24|l[1]<<16|l[2])>>>0;case 4:if(l[0]>255||l[1]>255||l[2]>255||l[3]>255)throw new Error("Invalid IP");return(l[0]<<24|l[1]<<16|l[2]<<8|l[3])>>>0;default:throw new Error("Invalid IP")}},e=function(c){return c.charCodeAt(0)},n=e("0"),o=e("a"),s=e("A"),t=function(c){var l,u,f,h,d;for(h=0,l=10,u="9",f=0,c.length>1&&c[f]==="0"&&(c[f+1]==="x"||c[f+1]==="X"?(f+=2,l=16):"0"<=c[f+1]&&c[f+1]<="9"&&(f++,l=8,u="7")),d=f;f<c.length;){if("0"<=c[f]&&c[f]<=u)h=h*l+(e(c[f])-n)>>>0;else if(l===16)if("a"<=c[f]&&c[f]<="f")h=h*l+(10+e(c[f])-o)>>>0;else if("A"<=c[f]&&c[f]<="F")h=h*l+(10+e(c[f])-s)>>>0;else break;else break;if(h>4294967295)throw new Error("too large");f++}if(f===d)throw new Error("empty octet");return[h,f]},r=function(){function c(l,u){var f,h,d,p;if(typeof l!="string")throw new Error("Missing `net' parameter");if(u||(p=l.split("/",2),l=p[0],u=p[1]),u||(u=32),typeof u=="string"&&u.indexOf(".")>-1){try{this.maskLong=i(u)}catch(b){throw f=b,new Error("Invalid mask: "+u)}for(h=d=32;d>=0;h=--d)if(this.maskLong===4294967295<<32-h>>>0){this.bitmask=h;break}}else if(u||u===0)this.bitmask=parseInt(u,10),this.maskLong=0,this.bitmask>0&&(this.maskLong=4294967295<<32-this.bitmask>>>0);else throw new Error("Invalid mask: empty");try{this.netLong=(i(l)&this.maskLong)>>>0}catch(b){throw f=b,new Error("Invalid net address: "+l)}if(!(this.bitmask<=32))throw new Error("Invalid mask for ip4: "+u);this.size=Math.pow(2,32-this.bitmask),this.base=a(this.netLong),this.mask=a(this.maskLong),this.hostmask=a(~this.maskLong),this.first=this.bitmask<=30?a(this.netLong+1):this.base,this.last=this.bitmask<=30?a(this.netLong+this.size-2):a(this.netLong+this.size-1),this.broadcast=this.bitmask<=30?a(this.netLong+this.size-1):void 0}return c.prototype.contains=function(l){return typeof l=="string"&&(l.indexOf("/")>0||l.split(".").length!==4)&&(l=new c(l)),l instanceof c?this.contains(l.base)&&this.contains(l.broadcast||l.last):(i(l)&this.maskLong)>>>0===(this.netLong&this.maskLong)>>>0},c.prototype.next=function(l){return l==null&&(l=1),new c(a(this.netLong+this.size*l),this.mask)},c.prototype.forEach=function(l){var u,f,h;for(h=i(this.first),f=i(this.last),u=0;h<=f;)l(a(h),h,u),u++,h++},c.prototype.toString=function(){return this.base+"/"+this.bitmask},c}(),on.ip2long=i,on.long2ip=a,on.Netmask=r}).call(on)});var I0={};St(I0,{identify:()=>A0,identifyPush:()=>S0});var no=Symbol.for("@libp2p/peer-id");var It=class extends Error{static name="InvalidParametersError";constructor(t="Invalid parameters"){super(t),this.name="InvalidParametersError"}},rr=class extends Error{static name="InvalidPublicKeyError";constructor(t="Invalid public key"){super(t),this.name="InvalidPublicKeyError"}};var fn=class extends Error{static name="InvalidCIDError";constructor(t="Invalid CID"){super(t),this.name="InvalidCIDError"}},hn=class extends Error{static name="InvalidMultihashError";constructor(t="Invalid Multihash"){super(t),this.name="InvalidMultihashError"}},dn=class extends Error{static name="UnsupportedProtocolError";constructor(t="Unsupported protocol error"){super(t),this.name="UnsupportedProtocolError"}},Dt=class extends Error{static name="InvalidMessageError";constructor(t="Invalid message"){super(t),this.name="InvalidMessageError"}};var Ke=class extends Error{static name="UnsupportedKeyTypeError";constructor(t="Unsupported key type"){super(t),this.name="UnsupportedKeyTypeError"}};var Nr=(r,...t)=>{try{[...t]}catch{}};var pn=Symbol.for("@libp2p/service-capabilities"),L0=Symbol.for("@libp2p/service-dependencies");var co={};St(co,{base58btc:()=>X,base58flickr:()=>Hu});var ep=new Uint8Array(0);function fa(r,t){if(r===t)return!0;if(r.byteLength!==t.byteLength)return!1;for(let e=0;e<r.byteLength;e++)if(r[e]!==t[e])return!1;return!0}function ae(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 ha(r){return new TextEncoder().encode(r)}function da(r){return new TextDecoder().decode(r)}function Vu(r,t){if(r.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),n=0;n<e.length;n++)e[n]=255;for(var s=0;s<r.length;s++){var o=r.charAt(s),i=o.charCodeAt(0);if(e[i]!==255)throw new TypeError(o+" is ambiguous");e[i]=s}var a=r.length,c=r.charAt(0),l=Math.log(a)/Math.log(256),u=Math.log(256)/Math.log(a);function f(p){if(p instanceof Uint8Array||(ArrayBuffer.isView(p)?p=new Uint8Array(p.buffer,p.byteOffset,p.byteLength):Array.isArray(p)&&(p=Uint8Array.from(p))),!(p instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(p.length===0)return"";for(var b=0,g=0,v=0,A=p.length;v!==A&&p[v]===0;)v++,b++;for(var y=(A-v)*u+1>>>0,I=new Uint8Array(y);v!==A;){for(var U=p[v],L=0,k=y-1;(U!==0||L<g)&&k!==-1;k--,L++)U+=256*I[k]>>>0,I[k]=U%a>>>0,U=U/a>>>0;if(U!==0)throw new Error("Non-zero carry");g=L,v++}for(var T=y-g;T!==y&&I[T]===0;)T++;for(var N=c.repeat(b);T<y;++T)N+=r.charAt(I[T]);return N}function h(p){if(typeof p!="string")throw new TypeError("Expected String");if(p.length===0)return new Uint8Array;var b=0;if(p[b]!==" "){for(var g=0,v=0;p[b]===c;)g++,b++;for(var A=(p.length-b)*l+1>>>0,y=new Uint8Array(A);p[b];){var I=e[p.charCodeAt(b)];if(I===255)return;for(var U=0,L=A-1;(I!==0||U<v)&&L!==-1;L--,U++)I+=a*y[L]>>>0,y[L]=I%256>>>0,I=I/256>>>0;if(I!==0)throw new Error("Non-zero carry");v=U,b++}if(p[b]!==" "){for(var k=A-v;k!==A&&y[k]===0;)k++;for(var T=new Uint8Array(g+(A-k)),N=g;k!==A;)T[N++]=y[k++];return T}}}function d(p){var b=h(p);if(b)return b;throw new Error(`Non-${t} character`)}return{encode:f,decodeUnsafe:h,decode:d}}var Pu=Vu,Du=Pu,ga=Du;var so=class{name;prefix;baseEncode;constructor(t,e,n){this.name=t,this.prefix=e,this.baseEncode=n}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}},oo=class{name;prefix;baseDecode;prefixCodePoint;constructor(t,e,n){this.name=t,this.prefix=e;let s=e.codePointAt(0);if(s===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=s,this.baseDecode=n}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return ma(this,t)}},io=class{decoders;constructor(t){this.decoders=t}or(t){return ma(this,t)}decode(t){let e=t[0],n=this.decoders[e];if(n!=null)return n.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function ma(r,t){return new io({...r.decoders??{[r.prefix]:r},...t.decoders??{[t.prefix]:t}})}var ao=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(t,e,n,s){this.name=t,this.prefix=e,this.baseEncode=n,this.baseDecode=s,this.encoder=new so(t,e,n),this.decoder=new oo(t,e,s)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function nr({name:r,prefix:t,encode:e,decode:n}){return new ao(r,t,e,n)}function Ae({name:r,prefix:t,alphabet:e}){let{encode:n,decode:s}=ga(e,r);return nr({prefix:t,name:r,encode:n,decode:o=>ae(s(o))})}function Mu(r,t,e,n){let s={};for(let u=0;u<t.length;++u)s[t[u]]=u;let o=r.length;for(;r[o-1]==="=";)--o;let i=new Uint8Array(o*e/8|0),a=0,c=0,l=0;for(let u=0;u<o;++u){let f=s[r[u]];if(f===void 0)throw new SyntaxError(`Non-${n} character`);c=c<<e|f,a+=e,a>=8&&(a-=8,i[l++]=255&c>>a)}if(a>=e||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return i}function Fu(r,t,e){let n=t[t.length-1]==="=",s=(1<<e)-1,o="",i=0,a=0;for(let c=0;c<r.length;++c)for(a=a<<8|r[c],i+=8;i>e;)i-=e,o+=t[s&a>>i];if(i!==0&&(o+=t[s&a<<e-i]),n)for(;o.length*e&7;)o+="=";return o}function ot({name:r,prefix:t,bitsPerChar:e,alphabet:n}){return nr({prefix:t,name:r,encode(s){return Fu(s,n,e)},decode(s){return Mu(s,n,e,r)}})}var X=Ae({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Hu=Ae({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var lo={};St(lo,{base32:()=>ce,base32hex:()=>zu,base32hexpad:()=>Wu,base32hexpadupper:()=>ju,base32hexupper:()=>Gu,base32pad:()=>qu,base32padupper:()=>$u,base32upper:()=>Ku,base32z:()=>Zu});var ce=ot({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Ku=ot({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),qu=ot({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),$u=ot({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),zu=ot({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Gu=ot({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Wu=ot({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),ju=ot({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Zu=ot({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var uo={};St(uo,{base36:()=>Cr,base36upper:()=>Yu});var Cr=Ae({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Yu=Ae({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Ju=wa,ba=128,Xu=127,Qu=~Xu,tf=Math.pow(2,31);function wa(r,t,e){t=t||[],e=e||0;for(var n=e;r>=tf;)t[e++]=r&255|ba,r/=128;for(;r&Qu;)t[e++]=r&255|ba,r>>>=7;return t[e]=r|0,wa.bytes=e-n+1,t}var ef=fo,rf=128,ya=127;function fo(r,n){var e=0,n=n||0,s=0,o=n,i,a=r.length;do{if(o>=a)throw fo.bytes=0,new RangeError("Could not decode varint");i=r[o++],e+=s<28?(i&ya)<<s:(i&ya)*Math.pow(2,s),s+=7}while(i>=rf);return fo.bytes=o-n,e}var nf=Math.pow(2,7),sf=Math.pow(2,14),of=Math.pow(2,21),af=Math.pow(2,28),cf=Math.pow(2,35),lf=Math.pow(2,42),uf=Math.pow(2,49),ff=Math.pow(2,56),hf=Math.pow(2,63),df=function(r){return r<nf?1:r<sf?2:r<of?3:r<af?4:r<cf?5:r<lf?6:r<uf?7:r<ff?8:r<hf?9:10},pf={encode:Ju,decode:ef,encodingLength:df},gf=pf,Tr=gf;function Lr(r,t=0){return[Tr.decode(r,t),Tr.decode.bytes]}function sr(r,t,e=0){return Tr.encode(r,t,e),t}function or(r){return Tr.encodingLength(r)}function Mt(r,t){let e=t.byteLength,n=or(r),s=n+or(e),o=new Uint8Array(s+e);return sr(r,o,0),sr(e,o,n),o.set(t,s),new ir(r,e,t,o)}function qe(r){let t=ae(r),[e,n]=Lr(t),[s,o]=Lr(t.subarray(n)),i=t.subarray(n+o);if(i.byteLength!==s)throw new Error("Incorrect length");return new ir(e,s,i,t)}function xa(r,t){if(r===t)return!0;{let e=t;return r.code===e.code&&r.size===e.size&&e.bytes instanceof Uint8Array&&fa(r.bytes,e.bytes)}}var ir=class{code;size;digest;bytes;constructor(t,e,n,s){this.code=t,this.size=e,this.digest=n,this.bytes=s}};function va(r,t){let{bytes:e,version:n}=r;switch(n){case 0:return bf(e,ho(r),t??X.encoder);default:return yf(e,ho(r),t??ce.encoder)}}var Ea=new WeakMap;function ho(r){let t=Ea.get(r);if(t==null){let e=new Map;return Ea.set(r,e),e}return t}var dt=class r{code;version;multihash;bytes;"/";constructor(t,e,n,s){this.code=e,this.version=t,this.multihash=n,this.bytes=s,this["/"]=s}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:t,multihash:e}=this;if(t!==Ur)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(e.code!==wf)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return r.createV0(e)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:t,digest:e}=this.multihash,n=Mt(t,e);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(t){return r.equals(this,t)}static equals(t,e){let n=e;return n!=null&&t.code===n.code&&t.version===n.version&&xa(t.multihash,n.multihash)}toString(t){return va(this,t)}toJSON(){return{"/":va(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(t){if(t==null)return null;let e=t;if(e instanceof r)return e;if(e["/"]!=null&&e["/"]===e.bytes||e.asCID===e){let{version:n,code:s,multihash:o,bytes:i}=e;return new r(n,s,o,i??Ba(n,s,o.bytes))}else if(e[xf]===!0){let{version:n,multihash:s,code:o}=e,i=qe(s);return r.create(n,o,i)}else return null}static create(t,e,n){if(typeof e!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(t){case 0:{if(e!==Ur)throw new Error(`Version 0 CID must use dag-pb (code: ${Ur}) block encoding`);return new r(t,e,n,n.bytes)}case 1:{let s=Ba(t,e,n.bytes);return new r(t,e,n,s)}default:throw new Error("Invalid version")}}static createV0(t){return r.create(0,Ur,t)}static createV1(t,e){return r.create(1,t,e)}static decode(t){let[e,n]=r.decodeFirst(t);if(n.length!==0)throw new Error("Incorrect length");return e}static decodeFirst(t){let e=r.inspectBytes(t),n=e.size-e.multihashSize,s=ae(t.subarray(n,n+e.multihashSize));if(s.byteLength!==e.multihashSize)throw new Error("Incorrect length");let o=s.subarray(e.multihashSize-e.digestSize),i=new ir(e.multihashCode,e.digestSize,o,s);return[e.version===0?r.createV0(i):r.createV1(e.codec,i),t.subarray(e.size)]}static inspectBytes(t){let e=0,n=()=>{let[f,h]=Lr(t.subarray(e));return e+=h,f},s=n(),o=Ur;if(s===18?(s=0,e=0):o=n(),s!==0&&s!==1)throw new RangeError(`Invalid CID version ${s}`);let i=e,a=n(),c=n(),l=e+c,u=l-i;return{version:s,codec:o,multihashCode:a,digestSize:c,multihashSize:u,size:l}}static parse(t,e){let[n,s]=mf(t,e),o=r.decode(s);if(o.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return ho(o).set(n,t),o}};function mf(r,t){switch(r[0]){case"Q":{let e=t??X;return[X.prefix,e.decode(`${X.prefix}${r}`)]}case X.prefix:{let e=t??X;return[X.prefix,e.decode(r)]}case ce.prefix:{let e=t??ce;return[ce.prefix,e.decode(r)]}case Cr.prefix:{let e=t??Cr;return[Cr.prefix,e.decode(r)]}default:{if(t==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[r[0],t.decode(r)]}}}function bf(r,t,e){let{prefix:n}=e;if(n!==X.prefix)throw Error(`Cannot string encode V0 in ${e.name} encoding`);let s=t.get(n);if(s==null){let o=e.encode(r).slice(1);return t.set(n,o),o}else return s}function yf(r,t,e){let{prefix:n}=e,s=t.get(n);if(s==null){let o=e.encode(r);return t.set(n,o),o}else return s}var Ur=112,wf=18;function Ba(r,t,e){let n=or(r),s=n+or(t),o=new Uint8Array(s+e.byteLength);return sr(r,o,0),sr(t,o,n),o.set(e,s),o}var xf=Symbol.for("@ipld/js-cid/CID");var po={};St(po,{identity:()=>le});var Aa=0,vf="identity",Sa=ae;function Ef(r){return Mt(Aa,Sa(r))}var le={code:Aa,name:vf,encode:Sa,digest:Ef};function yt(r,t){if(r===t)return!0;if(r.byteLength!==t.byteLength)return!1;for(let e=0;e<r.byteLength;e++)if(r[e]!==t[e])return!1;return!0}function Ia(r){if(!Number.isSafeInteger(r)||r<0)throw new Error("positive integer expected, got "+r)}function Bf(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function ar(r,...t){if(!Bf(r))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(r.length))throw new Error("Uint8Array expected of length "+t+", got length="+r.length)}function ka(r){if(typeof r!="function"||typeof r.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");Ia(r.outputLen),Ia(r.blockLen)}function cr(r,t=!0){if(r.destroyed)throw new Error("Hash instance has been destroyed");if(t&&r.finished)throw new Error("Hash#digest() has already been called")}function Na(r,t){ar(r);let e=t.outputLen;if(r.length<e)throw new Error("digestInto() expects output buffer of length at least "+e)}var $e=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;var mn=r=>new DataView(r.buffer,r.byteOffset,r.byteLength),Ft=(r,t)=>r<<32-t|r>>>t;function Ca(r){if(typeof r!="string")throw new Error("utf8ToBytes expected string, got "+typeof r);return new Uint8Array(new TextEncoder().encode(r))}function Rr(r){return typeof r=="string"&&(r=Ca(r)),ar(r),r}function go(...r){let t=0;for(let n=0;n<r.length;n++){let s=r[n];ar(s),t+=s.length}let e=new Uint8Array(t);for(let n=0,s=0;n<r.length;n++){let o=r[n];e.set(o,s),s+=o.length}return e}var lr=class{clone(){return this._cloneInto()}};function bn(r){let t=n=>r().update(Rr(n)).digest(),e=r();return t.outputLen=e.outputLen,t.blockLen=e.blockLen,t.create=()=>r(),t}function yn(r=32){if($e&&typeof $e.getRandomValues=="function")return $e.getRandomValues(new Uint8Array(r));if($e&&typeof $e.randomBytes=="function")return $e.randomBytes(r);throw new Error("crypto.getRandomValues must be defined")}function Af(r,t,e,n){if(typeof r.setBigUint64=="function")return r.setBigUint64(t,e,n);let s=BigInt(32),o=BigInt(4294967295),i=Number(e>>s&o),a=Number(e&o),c=n?4:0,l=n?0:4;r.setUint32(t+c,i,n),r.setUint32(t+l,a,n)}var Ta=(r,t,e)=>r&t^~r&e,La=(r,t,e)=>r&t^r&e^t&e,ur=class extends lr{constructor(t,e,n,s){super(),this.blockLen=t,this.outputLen=e,this.padOffset=n,this.isLE=s,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=mn(this.buffer)}update(t){cr(this);let{view:e,buffer:n,blockLen:s}=this;t=Rr(t);let o=t.length;for(let i=0;i<o;){let a=Math.min(s-this.pos,o-i);if(a===s){let c=mn(t);for(;s<=o-i;i+=s)this.process(c,i);continue}n.set(t.subarray(i,i+a),this.pos),this.pos+=a,i+=a,this.pos===s&&(this.process(e,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){cr(this),Na(t,this),this.finished=!0;let{buffer:e,view:n,blockLen:s,isLE:o}=this,{pos:i}=this;e[i++]=128,this.buffer.subarray(i).fill(0),this.padOffset>s-i&&(this.process(n,0),i=0);for(let f=i;f<s;f++)e[f]=0;Af(n,s-8,BigInt(this.length*8),o),this.process(n,0);let a=mn(t),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let l=c/4,u=this.get();if(l>u.length)throw new Error("_sha2: outputLen bigger than state");for(let f=0;f<l;f++)a.setUint32(4*f,u[f],o)}digest(){let{buffer:t,outputLen:e}=this;this.digestInto(t);let n=t.slice(0,e);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());let{blockLen:e,buffer:n,length:s,finished:o,destroyed:i,pos:a}=this;return t.length=s,t.pos=a,t.finished=o,t.destroyed=i,s%e&&t.buffer.set(n),t}};var wn=BigInt(4294967295),mo=BigInt(32);function Ua(r,t=!1){return t?{h:Number(r&wn),l:Number(r>>mo&wn)}:{h:Number(r>>mo&wn)|0,l:Number(r&wn)|0}}function Sf(r,t=!1){let e=new Uint32Array(r.length),n=new Uint32Array(r.length);for(let s=0;s<r.length;s++){let{h:o,l:i}=Ua(r[s],t);[e[s],n[s]]=[o,i]}return[e,n]}var If=(r,t)=>BigInt(r>>>0)<<mo|BigInt(t>>>0),kf=(r,t,e)=>r>>>e,Nf=(r,t,e)=>r<<32-e|t>>>e,Cf=(r,t,e)=>r>>>e|t<<32-e,Tf=(r,t,e)=>r<<32-e|t>>>e,Lf=(r,t,e)=>r<<64-e|t>>>e-32,Uf=(r,t,e)=>r>>>e-32|t<<64-e,Rf=(r,t)=>t,_f=(r,t)=>r,Of=(r,t,e)=>r<<e|t>>>32-e,Vf=(r,t,e)=>t<<e|r>>>32-e,Pf=(r,t,e)=>t<<e-32|r>>>64-e,Df=(r,t,e)=>r<<e-32|t>>>64-e;function Mf(r,t,e,n){let s=(t>>>0)+(n>>>0);return{h:r+e+(s/2**32|0)|0,l:s|0}}var Ff=(r,t,e)=>(r>>>0)+(t>>>0)+(e>>>0),Hf=(r,t,e,n)=>t+e+n+(r/2**32|0)|0,Kf=(r,t,e,n)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0),qf=(r,t,e,n,s)=>t+e+n+s+(r/2**32|0)|0,$f=(r,t,e,n,s)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0)+(s>>>0),zf=(r,t,e,n,s,o)=>t+e+n+s+o+(r/2**32|0)|0;var Gf={fromBig:Ua,split:Sf,toBig:If,shrSH:kf,shrSL:Nf,rotrSH:Cf,rotrSL:Tf,rotrBH:Lf,rotrBL:Uf,rotr32H:Rf,rotr32L:_f,rotlSH:Of,rotlSL:Vf,rotlBH:Pf,rotlBL:Df,add:Mf,add3L:Ff,add3H:Hf,add4L:Kf,add4H:qf,add5H:zf,add5L:$f},V=Gf;var[Wf,jf]=V.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))),Ie=new Uint32Array(80),ke=new Uint32Array(80),bo=class extends ur{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){let{Ah:t,Al:e,Bh:n,Bl:s,Ch:o,Cl:i,Dh:a,Dl:c,Eh:l,El:u,Fh:f,Fl:h,Gh:d,Gl:p,Hh:b,Hl:g}=this;return[t,e,n,s,o,i,a,c,l,u,f,h,d,p,b,g]}set(t,e,n,s,o,i,a,c,l,u,f,h,d,p,b,g){this.Ah=t|0,this.Al=e|0,this.Bh=n|0,this.Bl=s|0,this.Ch=o|0,this.Cl=i|0,this.Dh=a|0,this.Dl=c|0,this.Eh=l|0,this.El=u|0,this.Fh=f|0,this.Fl=h|0,this.Gh=d|0,this.Gl=p|0,this.Hh=b|0,this.Hl=g|0}process(t,e){for(let y=0;y<16;y++,e+=4)Ie[y]=t.getUint32(e),ke[y]=t.getUint32(e+=4);for(let y=16;y<80;y++){let I=Ie[y-15]|0,U=ke[y-15]|0,L=V.rotrSH(I,U,1)^V.rotrSH(I,U,8)^V.shrSH(I,U,7),k=V.rotrSL(I,U,1)^V.rotrSL(I,U,8)^V.shrSL(I,U,7),T=Ie[y-2]|0,N=ke[y-2]|0,Q=V.rotrSH(T,N,19)^V.rotrBH(T,N,61)^V.shrSH(T,N,6),q=V.rotrSL(T,N,19)^V.rotrBL(T,N,61)^V.shrSL(T,N,6),D=V.add4L(k,q,ke[y-7],ke[y-16]),it=V.add4H(D,L,Q,Ie[y-7],Ie[y-16]);Ie[y]=it|0,ke[y]=D|0}let{Ah:n,Al:s,Bh:o,Bl:i,Ch:a,Cl:c,Dh:l,Dl:u,Eh:f,El:h,Fh:d,Fl:p,Gh:b,Gl:g,Hh:v,Hl:A}=this;for(let y=0;y<80;y++){let I=V.rotrSH(f,h,14)^V.rotrSH(f,h,18)^V.rotrBH(f,h,41),U=V.rotrSL(f,h,14)^V.rotrSL(f,h,18)^V.rotrBL(f,h,41),L=f&d^~f&b,k=h&p^~h&g,T=V.add5L(A,U,k,jf[y],ke[y]),N=V.add5H(T,v,I,L,Wf[y],Ie[y]),Q=T|0,q=V.rotrSH(n,s,28)^V.rotrBH(n,s,34)^V.rotrBH(n,s,39),D=V.rotrSL(n,s,28)^V.rotrBL(n,s,34)^V.rotrBL(n,s,39),it=n&o^n&a^o&a,E=s&i^s&c^i&c;v=b|0,A=g|0,b=d|0,g=p|0,d=f|0,p=h|0,{h:f,l:h}=V.add(l|0,u|0,N|0,Q|0),l=a|0,u=c|0,a=o|0,c=i|0,o=n|0,i=s|0;let C=V.add3L(Q,D,E);n=V.add3H(C,N,q,it),s=C|0}({h:n,l:s}=V.add(this.Ah|0,this.Al|0,n|0,s|0)),{h:o,l:i}=V.add(this.Bh|0,this.Bl|0,o|0,i|0),{h:a,l:c}=V.add(this.Ch|0,this.Cl|0,a|0,c|0),{h:l,l:u}=V.add(this.Dh|0,this.Dl|0,l|0,u|0),{h:f,l:h}=V.add(this.Eh|0,this.El|0,f|0,h|0),{h:d,l:p}=V.add(this.Fh|0,this.Fl|0,d|0,p|0),{h:b,l:g}=V.add(this.Gh|0,this.Gl|0,b|0,g|0),{h:v,l:A}=V.add(this.Hh|0,this.Hl|0,v|0,A|0),this.set(n,s,o,i,a,c,l,u,f,h,d,p,b,g,v,A)}roundClean(){Ie.fill(0),ke.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 Ra=bn(()=>new bo);var En={};St(En,{aInRange:()=>Ct,abool:()=>Ht,abytes:()=>fr,bitGet:()=>th,bitLen:()=>vo,bitMask:()=>Or,bitSet:()=>eh,bytesToHex:()=>fe,bytesToNumberBE:()=>he,bytesToNumberLE:()=>Ce,concatBytes:()=>de,createHmacDrbg:()=>Eo,ensureBytes:()=>nt,equalBytes:()=>Xf,hexToBytes:()=>Ge,hexToNumber:()=>xo,inRange:()=>_r,isBytes:()=>Ne,memoized:()=>je,notImplemented:()=>nh,numberToBytesBE:()=>Te,numberToBytesLE:()=>We,numberToHexUnpadded:()=>ze,numberToVarBytesBE:()=>Jf,utf8ToBytes:()=>Qf,validateObject:()=>Qt});var xn=BigInt(0),vn=BigInt(1),Zf=BigInt(2);function Ne(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function fr(r){if(!Ne(r))throw new Error("Uint8Array expected")}function Ht(r,t){if(typeof t!="boolean")throw new Error(r+" boolean expected, got "+t)}var Yf=Array.from({length:256},(r,t)=>t.toString(16).padStart(2,"0"));function fe(r){fr(r);let t="";for(let e=0;e<r.length;e++)t+=Yf[r[e]];return t}function ze(r){let t=r.toString(16);return t.length&1?"0"+t:t}function xo(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return r===""?xn:BigInt("0x"+r)}var ue={_0:48,_9:57,A:65,F:70,a:97,f:102};function _a(r){if(r>=ue._0&&r<=ue._9)return r-ue._0;if(r>=ue.A&&r<=ue.F)return r-(ue.A-10);if(r>=ue.a&&r<=ue.f)return r-(ue.a-10)}function Ge(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);let t=r.length,e=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);let n=new Uint8Array(e);for(let s=0,o=0;s<e;s++,o+=2){let i=_a(r.charCodeAt(o)),a=_a(r.charCodeAt(o+1));if(i===void 0||a===void 0){let c=r[o]+r[o+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+o)}n[s]=i*16+a}return n}function he(r){return xo(fe(r))}function Ce(r){return fr(r),xo(fe(Uint8Array.from(r).reverse()))}function Te(r,t){return Ge(r.toString(16).padStart(t*2,"0"))}function We(r,t){return Te(r,t).reverse()}function Jf(r){return Ge(ze(r))}function nt(r,t,e){let n;if(typeof t=="string")try{n=Ge(t)}catch(o){throw new Error(r+" must be hex string or Uint8Array, cause: "+o)}else if(Ne(t))n=Uint8Array.from(t);else throw new Error(r+" must be hex string or Uint8Array");let s=n.length;if(typeof e=="number"&&s!==e)throw new Error(r+" of length "+e+" expected, got "+s);return n}function de(...r){let t=0;for(let n=0;n<r.length;n++){let s=r[n];fr(s),t+=s.length}let e=new Uint8Array(t);for(let n=0,s=0;n<r.length;n++){let o=r[n];e.set(o,s),s+=o.length}return e}function Xf(r,t){if(r.length!==t.length)return!1;let e=0;for(let n=0;n<r.length;n++)e|=r[n]^t[n];return e===0}function Qf(r){if(typeof r!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(r))}var yo=r=>typeof r=="bigint"&&xn<=r;function _r(r,t,e){return yo(r)&&yo(t)&&yo(e)&&t<=r&&r<e}function Ct(r,t,e,n){if(!_r(t,e,n))throw new Error("expected valid "+r+": "+e+" <= n < "+n+", got "+t)}function vo(r){let t;for(t=0;r>xn;r>>=vn,t+=1);return t}function th(r,t){return r>>BigInt(t)&vn}function eh(r,t,e){return r|(e?vn:xn)<<BigInt(t)}var Or=r=>(Zf<<BigInt(r-1))-vn,wo=r=>new Uint8Array(r),Oa=r=>Uint8Array.from(r);function Eo(r,t,e){if(typeof r!="number"||r<2)throw new Error("hashLen must be a number");if(typeof t!="number"||t<2)throw new Error("qByteLen must be a number");if(typeof e!="function")throw new Error("hmacFn must be a function");let n=wo(r),s=wo(r),o=0,i=()=>{n.fill(1),s.fill(0),o=0},a=(...f)=>e(s,n,...f),c=(f=wo())=>{s=a(Oa([0]),f),n=a(),f.length!==0&&(s=a(Oa([1]),f),n=a())},l=()=>{if(o++>=1e3)throw new Error("drbg: tried 1000 values");let f=0,h=[];for(;f<t;){n=a();let d=n.slice();h.push(d),f+=n.length}return de(...h)};return(f,h)=>{i(),c(f);let d;for(;!(d=h(l()));)c();return i(),d}}var rh={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"||Ne(r),isSafeInteger:r=>Number.isSafeInteger(r),array:r=>Array.isArray(r),field:(r,t)=>t.Fp.isValid(r),hash:r=>typeof r=="function"&&Number.isSafeInteger(r.outputLen)};function Qt(r,t,e={}){let n=(s,o,i)=>{let a=rh[o];if(typeof a!="function")throw new Error("invalid validator function");let c=r[s];if(!(i&&c===void 0)&&!a(c,r))throw new Error("param "+String(s)+" is invalid. Expected "+o+", got "+c)};for(let[s,o]of Object.entries(t))n(s,o,!1);for(let[s,o]of Object.entries(e))n(s,o,!0);return r}var nh=()=>{throw new Error("not implemented")};function je(r){let t=new WeakMap;return(e,...n)=>{let s=t.get(e);if(s!==void 0)return s;let o=r(e,...n);return t.set(e,o),o}}var at=BigInt(0),tt=BigInt(1),Ze=BigInt(2),sh=BigInt(3),Bo=BigInt(4),Va=BigInt(5),Pa=BigInt(8),oh=BigInt(9),ih=BigInt(16);function Z(r,t){let e=r%t;return e>=at?e:t+e}function ah(r,t,e){if(t<at)throw new Error("invalid exponent, negatives unsupported");if(e<=at)throw new Error("invalid modulus");if(e===tt)return at;let n=tt;for(;t>at;)t&tt&&(n=n*r%e),r=r*r%e,t>>=tt;return n}function et(r,t,e){let n=r;for(;t-- >at;)n*=n,n%=e;return n}function Bn(r,t){if(r===at)throw new Error("invert: expected non-zero number");if(t<=at)throw new Error("invert: expected positive modulus, got "+t);let e=Z(r,t),n=t,s=at,o=tt,i=tt,a=at;for(;e!==at;){let l=n/e,u=n%e,f=s-i*l,h=o-a*l;n=e,e=u,s=i,o=a,i=f,a=h}if(n!==tt)throw new Error("invert: does not exist");return Z(s,t)}function ch(r){let t=(r-tt)/Ze,e,n,s;for(e=r-tt,n=0;e%Ze===at;e/=Ze,n++);for(s=Ze;s<r&&ah(s,t,r)!==r-tt;s++)if(s>1e3)throw new Error("Cannot find square root: likely non-prime P");if(n===1){let i=(r+tt)/Bo;return function(c,l){let u=c.pow(l,i);if(!c.eql(c.sqr(u),l))throw new Error("Cannot find square root");return u}}let o=(e+tt)/Ze;return function(a,c){if(a.pow(c,t)===a.neg(a.ONE))throw new Error("Cannot find square root");let l=n,u=a.pow(a.mul(a.ONE,s),e),f=a.pow(c,o),h=a.pow(c,e);for(;!a.eql(h,a.ONE);){if(a.eql(h,a.ZERO))return a.ZERO;let d=1;for(let b=a.sqr(h);d<l&&!a.eql(b,a.ONE);d++)b=a.sqr(b);let p=a.pow(u,tt<<BigInt(l-d-1));u=a.sqr(p),f=a.mul(f,p),h=a.mul(h,u),l=d}return f}}function lh(r){if(r%Bo===sh){let t=(r+tt)/Bo;return function(n,s){let o=n.pow(s,t);if(!n.eql(n.sqr(o),s))throw new Error("Cannot find square root");return o}}if(r%Pa===Va){let t=(r-Va)/Pa;return function(n,s){let o=n.mul(s,Ze),i=n.pow(o,t),a=n.mul(s,i),c=n.mul(n.mul(a,Ze),i),l=n.mul(a,n.sub(c,n.ONE));if(!n.eql(n.sqr(l),s))throw new Error("Cannot find square root");return l}}return r%ih,ch(r)}var Da=(r,t)=>(Z(r,t)&tt)===tt,uh=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Ao(r){let t={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},e=uh.reduce((n,s)=>(n[s]="function",n),t);return Qt(r,e)}function fh(r,t,e){if(e<at)throw new Error("invalid exponent, negatives unsupported");if(e===at)return r.ONE;if(e===tt)return t;let n=r.ONE,s=t;for(;e>at;)e&tt&&(n=r.mul(n,s)),s=r.sqr(s),e>>=tt;return n}function hh(r,t){let e=new Array(t.length),n=t.reduce((o,i,a)=>r.is0(i)?o:(e[a]=o,r.mul(o,i)),r.ONE),s=r.inv(n);return t.reduceRight((o,i,a)=>r.is0(i)?o:(e[a]=r.mul(o,e[a]),r.mul(o,i)),s),e}function So(r,t){let e=t!==void 0?t:r.toString(2).length,n=Math.ceil(e/8);return{nBitLength:e,nByteLength:n}}function Le(r,t,e=!1,n={}){if(r<=at)throw new Error("invalid field: expected ORDER > 0, got "+r);let{nBitLength:s,nByteLength:o}=So(r,t);if(o>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let i,a=Object.freeze({ORDER:r,BITS:s,BYTES:o,MASK:Or(s),ZERO:at,ONE:tt,create:c=>Z(c,r),isValid:c=>{if(typeof c!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof c);return at<=c&&c<r},is0:c=>c===at,isOdd:c=>(c&tt)===tt,neg:c=>Z(-c,r),eql:(c,l)=>c===l,sqr:c=>Z(c*c,r),add:(c,l)=>Z(c+l,r),sub:(c,l)=>Z(c-l,r),mul:(c,l)=>Z(c*l,r),pow:(c,l)=>fh(a,c,l),div:(c,l)=>Z(c*Bn(l,r),r),sqrN:c=>c*c,addN:(c,l)=>c+l,subN:(c,l)=>c-l,mulN:(c,l)=>c*l,inv:c=>Bn(c,r),sqrt:n.sqrt||(c=>(i||(i=lh(r)),i(a,c))),invertBatch:c=>hh(a,c),cmov:(c,l,u)=>u?l:c,toBytes:c=>e?We(c,o):Te(c,o),fromBytes:c=>{if(c.length!==o)throw new Error("Field.fromBytes: expected "+o+" bytes, got "+c.length);return e?Ce(c):he(c)}});return Object.freeze(a)}function Ma(r){if(typeof r!="bigint")throw new Error("field order must be bigint");let t=r.toString(2).length;return Math.ceil(t/8)}function Io(r){let t=Ma(r);return t+Math.ceil(t/2)}function Fa(r,t,e=!1){let n=r.length,s=Ma(t),o=Io(t);if(n<16||n<o||n>1024)throw new Error("expected "+o+"-1024 bytes of input, got "+n);let i=e?he(r):Ce(r),a=Z(i,t-tt)+tt;return e?We(a,s):Te(a,s)}var Ha=BigInt(0),An=BigInt(1);function ko(r,t){let e=t.negate();return r?e:t}function Ka(r,t){if(!Number.isSafeInteger(r)||r<=0||r>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+r)}function No(r,t){Ka(r,t);let e=Math.ceil(t/r)+1,n=2**(r-1);return{windows:e,windowSize:n}}function ph(r,t){if(!Array.isArray(r))throw new Error("array expected");r.forEach((e,n)=>{if(!(e instanceof t))throw new Error("invalid point at index "+n)})}function gh(r,t){if(!Array.isArray(r))throw new Error("array of scalars expected");r.forEach((e,n)=>{if(!t.isValid(e))throw new Error("invalid scalar at index "+n)})}var Co=new WeakMap,qa=new WeakMap;function To(r){return qa.get(r)||1}function Sn(r,t){return{constTimeNegate:ko,hasPrecomputes(e){return To(e)!==1},unsafeLadder(e,n,s=r.ZERO){let o=e;for(;n>Ha;)n&An&&(s=s.add(o)),o=o.double(),n>>=An;return s},precomputeWindow(e,n){let{windows:s,windowSize:o}=No(n,t),i=[],a=e,c=a;for(let l=0;l<s;l++){c=a,i.push(c);for(let u=1;u<o;u++)c=c.add(a),i.push(c);a=c.double()}return i},wNAF(e,n,s){let{windows:o,windowSize:i}=No(e,t),a=r.ZERO,c=r.BASE,l=BigInt(2**e-1),u=2**e,f=BigInt(e);for(let h=0;h<o;h++){let d=h*i,p=Number(s&l);s>>=f,p>i&&(p-=u,s+=An);let b=d,g=d+Math.abs(p)-1,v=h%2!==0,A=p<0;p===0?c=c.add(ko(v,n[b])):a=a.add(ko(A,n[g]))}return{p:a,f:c}},wNAFUnsafe(e,n,s,o=r.ZERO){let{windows:i,windowSize:a}=No(e,t),c=BigInt(2**e-1),l=2**e,u=BigInt(e);for(let f=0;f<i;f++){let h=f*a;if(s===Ha)break;let d=Number(s&c);if(s>>=u,d>a&&(d-=l,s+=An),d===0)continue;let p=n[h+Math.abs(d)-1];d<0&&(p=p.negate()),o=o.add(p)}return o},getPrecomputes(e,n,s){let o=Co.get(n);return o||(o=this.precomputeWindow(n,e),e!==1&&Co.set(n,s(o))),o},wNAFCached(e,n,s){let o=To(e);return this.wNAF(o,this.getPrecomputes(o,e,s),n)},wNAFCachedUnsafe(e,n,s,o){let i=To(e);return i===1?this.unsafeLadder(e,n,o):this.wNAFUnsafe(i,this.getPrecomputes(i,e,s),n,o)},setWindowSize(e,n){Ka(n,t),qa.set(e,n),Co.delete(e)}}}function In(r,t,e,n){if(ph(e,r),gh(n,t),e.length!==n.length)throw new Error("arrays of points and scalars must have equal length");let s=r.ZERO,o=vo(BigInt(e.length)),i=o>12?o-3:o>4?o-2:o?2:1,a=(1<<i)-1,c=new Array(a+1).fill(s),l=Math.floor((t.BITS-1)/i)*i,u=s;for(let f=l;f>=0;f-=i){c.fill(s);for(let d=0;d<n.length;d++){let p=n[d],b=Number(p>>BigInt(f)&BigInt(a));c[b]=c[b].add(e[d])}let h=s;for(let d=c.length-1,p=s;d>0;d--)p=p.add(c[d]),h=h.add(p);if(u=u.add(h),f!==0)for(let d=0;d<i;d++)u=u.double()}return u}function Vr(r){return Ao(r.Fp),Qt(r,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...So(r.n,r.nBitLength),...r,p:r.Fp.ORDER})}var Kt=BigInt(0),Tt=BigInt(1),kn=BigInt(2),mh=BigInt(8),bh={zip215:!0};function yh(r){let t=Vr(r);return Qt(r,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...t})}function $a(r){let t=yh(r),{Fp:e,n,prehash:s,hash:o,randomBytes:i,nByteLength:a,h:c}=t,l=kn<<BigInt(a*8)-Tt,u=e.create,f=Le(t.n,t.nBitLength),h=t.uvRatio||((w,m)=>{try{return{isValid:!0,value:e.sqrt(w*e.inv(m))}}catch{return{isValid:!1,value:Kt}}}),d=t.adjustScalarBytes||(w=>w),p=t.domain||((w,m,x)=>{if(Ht("phflag",x),m.length||x)throw new Error("Contexts/pre-hash are not supported");return w});function b(w,m){Ct("coordinate "+w,m,Kt,l)}function g(w){if(!(w instanceof y))throw new Error("ExtendedPoint expected")}let v=je((w,m)=>{let{ex:x,ey:S,ez:R}=w,_=w.is0();m==null&&(m=_?mh:e.inv(R));let P=u(x*m),F=u(S*m),O=u(R*m);if(_)return{x:Kt,y:Tt};if(O!==Tt)throw new Error("invZ was invalid");return{x:P,y:F}}),A=je(w=>{let{a:m,d:x}=t;if(w.is0())throw new Error("bad point: ZERO");let{ex:S,ey:R,ez:_,et:P}=w,F=u(S*S),O=u(R*R),j=u(_*_),J=u(j*j),lt=u(F*m),ut=u(j*u(lt+O)),ht=u(J+u(x*u(F*O)));if(ut!==ht)throw new Error("bad point: equation left != right (1)");let bt=u(S*R),Nt=u(_*P);if(bt!==Nt)throw new Error("bad point: equation left != right (2)");return!0});class y{constructor(m,x,S,R){this.ex=m,this.ey=x,this.ez=S,this.et=R,b("x",m),b("y",x),b("z",S),b("t",R),Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(m){if(m instanceof y)throw new Error("extended point not allowed");let{x,y:S}=m||{};return b("x",x),b("y",S),new y(x,S,Tt,u(x*S))}static normalizeZ(m){let x=e.invertBatch(m.map(S=>S.ez));return m.map((S,R)=>S.toAffine(x[R])).map(y.fromAffine)}static msm(m,x){return In(y,f,m,x)}_setWindowSize(m){L.setWindowSize(this,m)}assertValidity(){A(this)}equals(m){g(m);let{ex:x,ey:S,ez:R}=this,{ex:_,ey:P,ez:F}=m,O=u(x*F),j=u(_*R),J=u(S*F),lt=u(P*R);return O===j&&J===lt}is0(){return this.equals(y.ZERO)}negate(){return new y(u(-this.ex),this.ey,this.ez,u(-this.et))}double(){let{a:m}=t,{ex:x,ey:S,ez:R}=this,_=u(x*x),P=u(S*S),F=u(kn*u(R*R)),O=u(m*_),j=x+S,J=u(u(j*j)-_-P),lt=O+P,ut=lt-F,ht=O-P,bt=u(J*ut),Nt=u(lt*ht),At=u(J*ht),Xt=u(ut*lt);return new y(bt,Nt,Xt,At)}add(m){g(m);let{a:x,d:S}=t,{ex:R,ey:_,ez:P,et:F}=this,{ex:O,ey:j,ez:J,et:lt}=m;if(x===BigInt(-1)){let na=u((_-R)*(j+O)),sa=u((_+R)*(j-O)),to=u(sa-na);if(to===Kt)return this.double();let oa=u(P*kn*lt),ia=u(F*kn*J),aa=ia+oa,ca=sa+na,la=ia-oa,Iu=u(aa*to),ku=u(ca*la),Nu=u(aa*la),Cu=u(to*ca);return new y(Iu,ku,Cu,Nu)}let ut=u(R*O),ht=u(_*j),bt=u(F*S*lt),Nt=u(P*J),At=u((R+_)*(O+j)-ut-ht),Xt=Nt-bt,ie=Nt+bt,kr=u(ht-x*ut),Eu=u(At*Xt),Bu=u(ie*kr),Au=u(At*kr),Su=u(Xt*ie);return new y(Eu,Bu,Su,Au)}subtract(m){return this.add(m.negate())}wNAF(m){return L.wNAFCached(this,m,y.normalizeZ)}multiply(m){let x=m;Ct("scalar",x,Tt,n);let{p:S,f:R}=this.wNAF(x);return y.normalizeZ([S,R])[0]}multiplyUnsafe(m,x=y.ZERO){let S=m;return Ct("scalar",S,Kt,n),S===Kt?U:this.is0()||S===Tt?this:L.wNAFCachedUnsafe(this,S,y.normalizeZ,x)}isSmallOrder(){return this.multiplyUnsafe(c).is0()}isTorsionFree(){return L.unsafeLadder(this,n).is0()}toAffine(m){return v(this,m)}clearCofactor(){let{h:m}=t;return m===Tt?this:this.multiplyUnsafe(m)}static fromHex(m,x=!1){let{d:S,a:R}=t,_=e.BYTES;m=nt("pointHex",m,_),Ht("zip215",x);let P=m.slice(),F=m[_-1];P[_-1]=F&-129;let O=Ce(P),j=x?l:e.ORDER;Ct("pointHex.y",O,Kt,j);let J=u(O*O),lt=u(J-Tt),ut=u(S*J-R),{isValid:ht,value:bt}=h(lt,ut);if(!ht)throw new Error("Point.fromHex: invalid y coordinate");let Nt=(bt&Tt)===Tt,At=(F&128)!==0;if(!x&&bt===Kt&&At)throw new Error("Point.fromHex: x=0 and x_0=1");return At!==Nt&&(bt=u(-bt)),y.fromAffine({x:bt,y:O})}static fromPrivateKey(m){return N(m).point}toRawBytes(){let{x:m,y:x}=this.toAffine(),S=We(x,e.BYTES);return S[S.length-1]|=m&Tt?128:0,S}toHex(){return fe(this.toRawBytes())}}y.BASE=new y(t.Gx,t.Gy,Tt,u(t.Gx*t.Gy)),y.ZERO=new y(Kt,Tt,Tt,Kt);let{BASE:I,ZERO:U}=y,L=Sn(y,a*8);function k(w){return Z(w,n)}function T(w){return k(Ce(w))}function N(w){let m=e.BYTES;w=nt("private key",w,m);let x=nt("hashed private key",o(w),2*m),S=d(x.slice(0,m)),R=x.slice(m,2*m),_=T(S),P=I.multiply(_),F=P.toRawBytes();return{head:S,prefix:R,scalar:_,point:P,pointBytes:F}}function Q(w){return N(w).pointBytes}function q(w=new Uint8Array,...m){let x=de(...m);return T(o(p(x,nt("context",w),!!s)))}function D(w,m,x={}){w=nt("message",w),s&&(w=s(w));let{prefix:S,scalar:R,pointBytes:_}=N(m),P=q(x.context,S,w),F=I.multiply(P).toRawBytes(),O=q(x.context,F,_,w),j=k(P+O*R);Ct("signature.s",j,Kt,n);let J=de(F,We(j,e.BYTES));return nt("result",J,e.BYTES*2)}let it=bh;function E(w,m,x,S=it){let{context:R,zip215:_}=S,P=e.BYTES;w=nt("signature",w,2*P),m=nt("message",m),x=nt("publicKey",x,P),_!==void 0&&Ht("zip215",_),s&&(m=s(m));let F=Ce(w.slice(P,2*P)),O,j,J;try{O=y.fromHex(x,_),j=y.fromHex(w.slice(0,P),_),J=I.multiplyUnsafe(F)}catch{return!1}if(!_&&O.isSmallOrder())return!1;let lt=q(R,j.toRawBytes(),O.toRawBytes(),m);return j.add(O.multiplyUnsafe(lt)).subtract(J).clearCofactor().equals(y.ZERO)}return I._setWindowSize(8),{CURVE:t,getPublicKey:Q,sign:D,verify:E,ExtendedPoint:y,utils:{getExtendedPublicKey:N,randomPrivateKey:()=>i(e.BYTES),precompute(w=8,m=y.BASE){return m._setWindowSize(w),m.multiply(BigInt(3)),m}}}}var Lo=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),za=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),Gp=BigInt(0),wh=BigInt(1),Ga=BigInt(2),Wp=BigInt(3),xh=BigInt(5),vh=BigInt(8);function Eh(r){let t=BigInt(10),e=BigInt(20),n=BigInt(40),s=BigInt(80),o=Lo,a=r*r%o*r%o,c=et(a,Ga,o)*a%o,l=et(c,wh,o)*r%o,u=et(l,xh,o)*l%o,f=et(u,t,o)*u%o,h=et(f,e,o)*f%o,d=et(h,n,o)*h%o,p=et(d,s,o)*d%o,b=et(p,s,o)*d%o,g=et(b,t,o)*u%o;return{pow_p_5_8:et(g,Ga,o)*r%o,b2:a}}function Bh(r){return r[0]&=248,r[31]&=127,r[31]|=64,r}function Ah(r,t){let e=Lo,n=Z(t*t*t,e),s=Z(n*n*t,e),o=Eh(r*s).pow_p_5_8,i=Z(r*n*o,e),a=Z(t*i*i,e),c=i,l=Z(i*za,e),u=a===r,f=a===Z(-r,e),h=a===Z(-r*za,e);return u&&(i=c),(f||h)&&(i=l),Da(i,e)&&(i=Z(-i,e)),{isValid:u||f,value:i}}var Sh=Le(Lo,void 0,!0),Ih={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:Sh,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:vh,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:Ra,randomBytes:yn,adjustScalarBytes:Bh,uvRatio:Ah},Wa=$a(Ih);var Nn=32;function ja(r,t,e){return Wa.verify(t,e instanceof Uint8Array?e:e.subarray(),r)}var Cn=class{type="Ed25519";raw;constructor(t){this.raw=Uo(t,Nn)}toMultihash(){return le.digest(Ue(this))}toCID(){return dt.createV1(114,this.toMultihash())}toString(){return X.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:yt(this.raw,t.raw)}verify(t,e){return ja(this.raw,e,t)}};function Ro(r){return r=Uo(r,Nn),new Cn(r)}function Uo(r,t){if(r=Uint8Array.from(r??[]),r.length!==t)throw new It(`Key must be a Uint8Array of length ${t}, got ${r.length}`);return r}function pt(r=0){return new Uint8Array(r)}function Lt(r=0){return new Uint8Array(r)}var Nh=Math.pow(2,7),Ch=Math.pow(2,14),Th=Math.pow(2,21),_o=Math.pow(2,28),Oo=Math.pow(2,35),Vo=Math.pow(2,42),Po=Math.pow(2,49),W=128,wt=127;function xt(r){if(r<Nh)return 1;if(r<Ch)return 2;if(r<Th)return 3;if(r<_o)return 4;if(r<Oo)return 5;if(r<Vo)return 6;if(r<Po)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function Do(r,t,e=0){switch(xt(r)){case 8:t[e++]=r&255|W,r/=128;case 7:t[e++]=r&255|W,r/=128;case 6:t[e++]=r&255|W,r/=128;case 5:t[e++]=r&255|W,r/=128;case 4:t[e++]=r&255|W,r>>>=7;case 3:t[e++]=r&255|W,r>>>=7;case 2:t[e++]=r&255|W,r>>>=7;case 1:{t[e++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return t}function Lh(r,t,e=0){switch(xt(r)){case 8:t.set(e++,r&255|W),r/=128;case 7:t.set(e++,r&255|W),r/=128;case 6:t.set(e++,r&255|W),r/=128;case 5:t.set(e++,r&255|W),r/=128;case 4:t.set(e++,r&255|W),r>>>=7;case 3:t.set(e++,r&255|W),r>>>=7;case 2:t.set(e++,r&255|W),r>>>=7;case 1:{t.set(e++,r&255),r>>>=7;break}default:throw new Error("unreachable")}return t}function Mo(r,t){let e=r[t],n=0;if(n+=e&wt,e<W||(e=r[t+1],n+=(e&wt)<<7,e<W)||(e=r[t+2],n+=(e&wt)<<14,e<W)||(e=r[t+3],n+=(e&wt)<<21,e<W)||(e=r[t+4],n+=(e&wt)*_o,e<W)||(e=r[t+5],n+=(e&wt)*Oo,e<W)||(e=r[t+6],n+=(e&wt)*Vo,e<W)||(e=r[t+7],n+=(e&wt)*Po,e<W))return n;throw new RangeError("Could not decode varint")}function Uh(r,t){let e=r.get(t),n=0;if(n+=e&wt,e<W||(e=r.get(t+1),n+=(e&wt)<<7,e<W)||(e=r.get(t+2),n+=(e&wt)<<14,e<W)||(e=r.get(t+3),n+=(e&wt)<<21,e<W)||(e=r.get(t+4),n+=(e&wt)*_o,e<W)||(e=r.get(t+5),n+=(e&wt)*Oo,e<W)||(e=r.get(t+6),n+=(e&wt)*Vo,e<W)||(e=r.get(t+7),n+=(e&wt)*Po,e<W))return n;throw new RangeError("Could not decode varint")}function Vt(r,t,e=0){return t==null&&(t=Lt(xt(r))),t instanceof Uint8Array?Do(r,t,e):Lh(r,t,e)}function pe(r,t=0){return r instanceof Uint8Array?Mo(r,t):Uh(r,t)}var Fo=new Float32Array([-0]),Re=new Uint8Array(Fo.buffer);function Ya(r,t,e){Fo[0]=r,t[e]=Re[0],t[e+1]=Re[1],t[e+2]=Re[2],t[e+3]=Re[3]}function Ja(r,t){return Re[0]=r[t],Re[1]=r[t+1],Re[2]=r[t+2],Re[3]=r[t+3],Fo[0]}var Ho=new Float64Array([-0]),vt=new Uint8Array(Ho.buffer);function Xa(r,t,e){Ho[0]=r,t[e]=vt[0],t[e+1]=vt[1],t[e+2]=vt[2],t[e+3]=vt[3],t[e+4]=vt[4],t[e+5]=vt[5],t[e+6]=vt[6],t[e+7]=vt[7]}function Qa(r,t){return vt[0]=r[t],vt[1]=r[t+1],vt[2]=r[t+2],vt[3]=r[t+3],vt[4]=r[t+4],vt[5]=r[t+5],vt[6]=r[t+6],vt[7]=r[t+7],Ho[0]}var Rh=BigInt(Number.MAX_SAFE_INTEGER),_h=BigInt(Number.MIN_SAFE_INTEGER),_t=class r{lo;hi;constructor(t,e){this.lo=t|0,this.hi=e|0}toNumber(t=!1){if(!t&&this.hi>>>31>0){let e=~this.lo+1>>>0,n=~this.hi>>>0;return e===0&&(n=n+1>>>0),-(e+n*4294967296)}return this.lo+this.hi*4294967296}toBigInt(t=!1){if(t)return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31){let e=~this.lo+1>>>0,n=~this.hi>>>0;return e===0&&(n=n+1>>>0),-(BigInt(e)+(BigInt(n)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toString(t=!1){return this.toBigInt(t).toString()}zzEncode(){let t=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^t)>>>0,this.lo=(this.lo<<1^t)>>>0,this}zzDecode(){let t=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^t)>>>0,this.hi=(this.hi>>>1^t)>>>0,this}length(){let t=this.lo,e=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return n===0?e===0?t<16384?t<128?1:2:t<2097152?3:4:e<16384?e<128?5:6:e<2097152?7:8:n<128?9:10}static fromBigInt(t){if(t===0n)return Ye;if(t<Rh&&t>_h)return this.fromNumber(Number(t));let e=t<0n;e&&(t=-t);let n=t>>32n,s=t-(n<<32n);return e&&(n=~n|0n,s=~s|0n,++s>tc&&(s=0n,++n>tc&&(n=0n))),new r(Number(s),Number(n))}static fromNumber(t){if(t===0)return Ye;let e=t<0;e&&(t=-t);let n=t>>>0,s=(t-n)/4294967296>>>0;return e&&(s=~s>>>0,n=~n>>>0,++n>4294967295&&(n=0,++s>4294967295&&(s=0))),new r(n,s)}static from(t){return typeof t=="number"?r.fromNumber(t):typeof t=="bigint"?r.fromBigInt(t):typeof t=="string"?r.fromBigInt(BigInt(t)):t.low!=null||t.high!=null?new r(t.low>>>0,t.high>>>0):Ye}},Ye=new _t(0,0);Ye.toBigInt=function(){return 0n};Ye.zzEncode=Ye.zzDecode=function(){return this};Ye.length=function(){return 1};var tc=4294967296n;function ec(r){let t=0,e=0;for(let n=0;n<r.length;++n)e=r.charCodeAt(n),e<128?t+=1:e<2048?t+=2:(e&64512)===55296&&(r.charCodeAt(n+1)&64512)===56320?(++n,t+=4):t+=3;return t}function rc(r,t,e){if(e-t<1)return"";let s,o=[],i=0,a;for(;t<e;)a=r[t++],a<128?o[i++]=a:a>191&&a<224?o[i++]=(a&31)<<6|r[t++]&63:a>239&&a<365?(a=((a&7)<<18|(r[t++]&63)<<12|(r[t++]&63)<<6|r[t++]&63)-65536,o[i++]=55296+(a>>10),o[i++]=56320+(a&1023)):o[i++]=(a&15)<<12|(r[t++]&63)<<6|r[t++]&63,i>8191&&((s??(s=[])).push(String.fromCharCode.apply(String,o)),i=0);return s!=null?(i>0&&s.push(String.fromCharCode.apply(String,o.slice(0,i))),s.join("")):String.fromCharCode.apply(String,o.slice(0,i))}function Ko(r,t,e){let n=e,s,o;for(let i=0;i<r.length;++i)s=r.charCodeAt(i),s<128?t[e++]=s:s<2048?(t[e++]=s>>6|192,t[e++]=s&63|128):(s&64512)===55296&&((o=r.charCodeAt(i+1))&64512)===56320?(s=65536+((s&1023)<<10)+(o&1023),++i,t[e++]=s>>18|240,t[e++]=s>>12&63|128,t[e++]=s>>6&63|128,t[e++]=s&63|128):(t[e++]=s>>12|224,t[e++]=s>>6&63|128,t[e++]=s&63|128);return e-n}function qt(r,t){return RangeError(`index out of range: ${r.pos} + ${t??1} > ${r.len}`)}function Ln(r,t){return(r[t-4]|r[t-3]<<8|r[t-2]<<16|r[t-1]<<24)>>>0}var qo=class{buf;pos;len;_slice=Uint8Array.prototype.subarray;constructor(t){this.buf=t,this.pos=0,this.len=t.length}uint32(){let t=4294967295;if(t=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(t=(t|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return t;if((this.pos+=5)>this.len)throw this.pos=this.len,qt(this,10);return t}int32(){return this.uint32()|0}sint32(){let t=this.uint32();return t>>>1^-(t&1)|0}bool(){return this.uint32()!==0}fixed32(){if(this.pos+4>this.len)throw qt(this,4);return Ln(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw qt(this,4);return Ln(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw qt(this,4);let t=Ja(this.buf,this.pos);return this.pos+=4,t}double(){if(this.pos+8>this.len)throw qt(this,4);let t=Qa(this.buf,this.pos);return this.pos+=8,t}bytes(){let t=this.uint32(),e=this.pos,n=this.pos+t;if(n>this.len)throw qt(this,t);return this.pos+=t,e===n?new Uint8Array(0):this.buf.subarray(e,n)}string(){let t=this.bytes();return rc(t,0,t.length)}skip(t){if(typeof t=="number"){if(this.pos+t>this.len)throw qt(this,t);this.pos+=t}else do if(this.pos>=this.len)throw qt(this);while(this.buf[this.pos++]&128);return this}skipType(t){switch(t){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(t=this.uint32()&7)!==4;)this.skipType(t);break;case 5:this.skip(4);break;default:throw Error(`invalid wire type ${t} at offset ${this.pos}`)}return this}readLongVarint(){let t=new _t(0,0),e=0;if(this.len-this.pos>4){for(;e<4;++e)if(t.lo=(t.lo|(this.buf[this.pos]&127)<<e*7)>>>0,this.buf[this.pos++]<128)return t;if(t.lo=(t.lo|(this.buf[this.pos]&127)<<28)>>>0,t.hi=(t.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return t;e=0}else{for(;e<3;++e){if(this.pos>=this.len)throw qt(this);if(t.lo=(t.lo|(this.buf[this.pos]&127)<<e*7)>>>0,this.buf[this.pos++]<128)return t}return t.lo=(t.lo|(this.buf[this.pos++]&127)<<e*7)>>>0,t}if(this.len-this.pos>4){for(;e<5;++e)if(t.hi=(t.hi|(this.buf[this.pos]&127)<<e*7+3)>>>0,this.buf[this.pos++]<128)return t}else for(;e<5;++e){if(this.pos>=this.len)throw qt(this);if(t.hi=(t.hi|(this.buf[this.pos]&127)<<e*7+3)>>>0,this.buf[this.pos++]<128)return t}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw qt(this,8);let t=Ln(this.buf,this.pos+=4),e=Ln(this.buf,this.pos+=4);return new _t(t,e)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){let t=Mo(this.buf,this.pos);return this.pos+=xt(t),t}uint64String(){return this.readLongVarint().toString(!0)}sint64(){return this.readLongVarint().zzDecode().toBigInt()}sint64Number(){return this.readLongVarint().zzDecode().toNumber()}sint64String(){return this.readLongVarint().zzDecode().toString()}fixed64(){return this.readFixed64().toBigInt()}fixed64Number(){return this.readFixed64().toNumber()}fixed64String(){return this.readFixed64().toString()}sfixed64(){return this.readFixed64().toBigInt()}sfixed64Number(){return this.readFixed64().toNumber()}sfixed64String(){return this.readFixed64().toString()}};function $o(r){return new qo(r instanceof Uint8Array?r:r.subarray())}function $t(r,t,e){let n=$o(r);return t.decode(n,void 0,e)}var zo={};St(zo,{base10:()=>Oh});var Oh=Ae({prefix:"9",name:"base10",alphabet:"0123456789"});var Go={};St(Go,{base16:()=>Vh,base16upper:()=>Ph});var Vh=ot({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Ph=ot({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Wo={};St(Wo,{base2:()=>Dh});var Dh=ot({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var jo={};St(jo,{base256emoji:()=>qh});var sc=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}"),Mh=sc.reduce((r,t,e)=>(r[e]=t,r),[]),Fh=sc.reduce((r,t,e)=>{let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);return r[n]=e,r},[]);function Hh(r){return r.reduce((t,e)=>(t+=Mh[e],t),"")}function Kh(r){let t=[];for(let e of r){let n=e.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${e}`);let s=Fh[n];if(s==null)throw new Error(`Non-base256emoji character: ${e}`);t.push(s)}return new Uint8Array(t)}var qh=nr({prefix:"\u{1F680}",name:"base256emoji",encode:Hh,decode:Kh});var Yo={};St(Yo,{base64:()=>$h,base64pad:()=>zh,base64url:()=>Zo,base64urlpad:()=>Gh});var $h=ot({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),zh=ot({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Zo=ot({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Gh=ot({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Jo={};St(Jo,{base8:()=>Wh});var Wh=ot({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Xo={};St(Xo,{identity:()=>jh});var jh=nr({prefix:"\0",name:"identity",encode:r=>da(r),decode:r=>ha(r)});var Cg=new TextEncoder,Tg=new TextDecoder;var ei={};St(ei,{sha256:()=>Pr,sha512:()=>Jh});function ti({name:r,code:t,encode:e}){return new Qo(r,t,e)}var Qo=class{name;code;encode;constructor(t,e,n){this.name=t,this.code=e,this.encode=n}digest(t){if(t instanceof Uint8Array){let e=this.encode(t);return e instanceof Uint8Array?Mt(this.code,e):e.then(n=>Mt(this.code,n))}else throw Error("Unknown type, must be binary type")}};function ic(r){return async t=>new Uint8Array(await crypto.subtle.digest(r,t))}var Pr=ti({name:"sha2-256",code:18,encode:ic("SHA-256")}),Jh=ti({name:"sha2-512",code:19,encode:ic("SHA-512")});var Dr={...Xo,...Wo,...Jo,...zo,...Go,...lo,...uo,...co,...Yo,...jo},Kg={...ei,...po};function cc(r,t,e,n){return{name:r,prefix:t,encoder:{name:r,prefix:t,encode:e},decoder:{decode:n}}}var ac=cc("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),ri=cc("ascii","a",r=>{let t="a";for(let e=0;e<r.length;e++)t+=String.fromCharCode(r[e]);return t},r=>{r=r.substring(1);let t=Lt(r.length);for(let e=0;e<r.length;e++)t[e]=r.charCodeAt(e);return t}),Xh={utf8:ac,"utf-8":ac,hex:Dr.base16,latin1:ri,ascii:ri,binary:ri,...Dr},Un=Xh;function $(r,t="utf8"){let e=Un[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.decoder.decode(`${e.prefix}${r}`)}function ni(r){let t=r??8192,e=t>>>1,n,s=t;return function(i){if(i<1||i>e)return Lt(i);s+i>t&&(n=Lt(t),s=0);let a=n.subarray(s,s+=i);return s&7&&(s=(s|7)+1),a}}var Je=class{fn;len;next;val;constructor(t,e,n){this.fn=t,this.len=e,this.next=void 0,this.val=n}};function si(){}var ii=class{head;tail;len;next;constructor(t){this.head=t.head,this.tail=t.tail,this.len=t.len,this.next=t.states}},Qh=ni();function td(r){return globalThis.Buffer!=null?Lt(r):Qh(r)}var Fr=class{len;head;tail;states;constructor(){this.len=0,this.head=new Je(si,0,0),this.tail=this.head,this.states=null}_push(t,e,n){return this.tail=this.tail.next=new Je(t,e,n),this.len+=e,this}uint32(t){return this.len+=(this.tail=this.tail.next=new ai((t=t>>>0)<128?1:t<16384?2:t<2097152?3:t<268435456?4:5,t)).len,this}int32(t){return t<0?this._push(Rn,10,_t.fromNumber(t)):this.uint32(t)}sint32(t){return this.uint32((t<<1^t>>31)>>>0)}uint64(t){let e=_t.fromBigInt(t);return this._push(Rn,e.length(),e)}uint64Number(t){return this._push(Do,xt(t),t)}uint64String(t){return this.uint64(BigInt(t))}int64(t){return this.uint64(t)}int64Number(t){return this.uint64Number(t)}int64String(t){return this.uint64String(t)}sint64(t){let e=_t.fromBigInt(t).zzEncode();return this._push(Rn,e.length(),e)}sint64Number(t){let e=_t.fromNumber(t).zzEncode();return this._push(Rn,e.length(),e)}sint64String(t){return this.sint64(BigInt(t))}bool(t){return this._push(oi,1,t?1:0)}fixed32(t){return this._push(Mr,4,t>>>0)}sfixed32(t){return this.fixed32(t)}fixed64(t){let e=_t.fromBigInt(t);return this._push(Mr,4,e.lo)._push(Mr,4,e.hi)}fixed64Number(t){let e=_t.fromNumber(t);return this._push(Mr,4,e.lo)._push(Mr,4,e.hi)}fixed64String(t){return this.fixed64(BigInt(t))}sfixed64(t){return this.fixed64(t)}sfixed64Number(t){return this.fixed64Number(t)}sfixed64String(t){return this.fixed64String(t)}float(t){return this._push(Ya,4,t)}double(t){return this._push(Xa,8,t)}bytes(t){let e=t.length>>>0;return e===0?this._push(oi,1,0):this.uint32(e)._push(rd,e,t)}string(t){let e=ec(t);return e!==0?this.uint32(e)._push(Ko,e,t):this._push(oi,1,0)}fork(){return this.states=new ii(this),this.head=this.tail=new Je(si,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 Je(si,0,0),this.len=0),this}ldelim(){let t=this.head,e=this.tail,n=this.len;return this.reset().uint32(n),n!==0&&(this.tail.next=t.next,this.tail=e,this.len+=n),this}finish(){let t=this.head.next,e=td(this.len),n=0;for(;t!=null;)t.fn(t.val,e,n),n+=t.len,t=t.next;return e}};function oi(r,t,e){t[e]=r&255}function ed(r,t,e){for(;r>127;)t[e++]=r&127|128,r>>>=7;t[e]=r}var ai=class extends Je{next;constructor(t,e){super(ed,t,e),this.next=void 0}};function Rn(r,t,e){for(;r.hi!==0;)t[e++]=r.lo&127|128,r.lo=(r.lo>>>7|r.hi<<25)>>>0,r.hi>>>=7;for(;r.lo>127;)t[e++]=r.lo&127|128,r.lo=r.lo>>>7;t[e++]=r.lo}function Mr(r,t,e){t[e]=r&255,t[e+1]=r>>>8&255,t[e+2]=r>>>16&255,t[e+3]=r>>>24}function rd(r,t,e){t.set(r,e)}globalThis.Buffer!=null&&(Fr.prototype.bytes=function(r){let t=r.length>>>0;return this.uint32(t),t>0&&this._push(nd,t,r),this},Fr.prototype.string=function(r){let t=globalThis.Buffer.byteLength(r);return this.uint32(t),t>0&&this._push(sd,t,r),this});function nd(r,t,e){t.set(r,e)}function sd(r,t,e){r.length<40?Ko(r,t,e):t.utf8Write!=null?t.utf8Write(r,e):t.set($(r),e)}function ci(){return new Fr}function zt(r,t){let e=ci();return t.encode(r,e,{lengthDelimited:!1}),e.finish()}var hr;(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"})(hr||(hr={}));function _n(r,t,e,n){return{name:r,type:t,encode:e,decode:n}}function li(r){function t(s){if(r[s.toString()]==null)throw new Error("Invalid enum value");return r[s]}let e=function(o,i){let a=t(o);i.int32(a)},n=function(o){let i=o.int32();return t(i)};return _n("enum",hr.VARINT,e,n)}function Gt(r,t){return _n("message",hr.LENGTH_DELIMITED,r,t)}var Xe=class extends Error{code="ERR_MAX_LENGTH";name="MaxLengthError"};var ct;(function(r){r.RSA="RSA",r.Ed25519="Ed25519",r.secp256k1="secp256k1"})(ct||(ct={}));var ui;(function(r){r[r.RSA=0]="RSA",r[r.Ed25519=1]="Ed25519",r[r.secp256k1=2]="secp256k1"})(ui||(ui={}));(function(r){r.codec=()=>li(ui)})(ct||(ct={}));var te;(function(r){let t;r.codec=()=>(t==null&&(t=Gt((e,n,s={})=>{s.lengthDelimited!==!1&&n.fork(),e.Type!=null&&(n.uint32(8),ct.codec().encode(e.Type,n)),e.Data!=null&&(n.uint32(18),n.bytes(e.Data)),s.lengthDelimited!==!1&&n.ldelim()},(e,n,s={})=>{let o={},i=n==null?e.len:e.pos+n;for(;e.pos<i;){let a=e.uint32();switch(a>>>3){case 1:{o.Type=ct.codec().decode(e);break}case 2:{o.Data=e.bytes();break}default:{e.skipType(a&7);break}}}return o})),t),r.encode=e=>zt(e,r.codec()),r.decode=(e,n)=>$t(e,r.codec(),n)})(te||(te={}));var fi;(function(r){let t;r.codec=()=>(t==null&&(t=Gt((e,n,s={})=>{s.lengthDelimited!==!1&&n.fork(),e.Type!=null&&(n.uint32(8),ct.codec().encode(e.Type,n)),e.Data!=null&&(n.uint32(18),n.bytes(e.Data)),s.lengthDelimited!==!1&&n.ldelim()},(e,n,s={})=>{let o={},i=n==null?e.len:e.pos+n;for(;e.pos<i;){let a=e.uint32();switch(a>>>3){case 1:{o.Type=ct.codec().decode(e);break}case 2:{o.Data=e.bytes();break}default:{e.skipType(a&7);break}}}return o})),t),r.encode=e=>zt(e,r.codec()),r.decode=(e,n)=>$t(e,r.codec(),n)})(fi||(fi={}));var Yr={};St(Yr,{MAX_RSA_KEY_SIZE:()=>Cs,generateRSAKeyPair:()=>ll,jwkToJWKKeyPair:()=>ul,jwkToPkcs1:()=>Bd,jwkToPkix:()=>Bi,jwkToRSAPrivateKey:()=>cl,pkcs1ToJwk:()=>ol,pkcs1ToRSAPrivateKey:()=>al,pkixToJwk:()=>il,pkixToRSAPublicKey:()=>Ai});function od(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function hi(r,...t){if(!od(r))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(r.length))throw new Error("Uint8Array expected of length "+t+", got length="+r.length)}function di(r,t=!0){if(r.destroyed)throw new Error("Hash instance has been destroyed");if(t&&r.finished)throw new Error("Hash#digest() has already been called")}function uc(r,t){hi(r);let e=t.outputLen;if(r.length<e)throw new Error("digestInto() expects output buffer of length at least "+e)}var Vn=r=>new DataView(r.buffer,r.byteOffset,r.byteLength),Wt=(r,t)=>r<<32-t|r>>>t;function id(r){if(typeof r!="string")throw new Error("utf8ToBytes expected string, got "+typeof r);return new Uint8Array(new TextEncoder().encode(r))}function pi(r){return typeof r=="string"&&(r=id(r)),hi(r),r}var On=class{clone(){return this._cloneInto()}};function fc(r){let t=n=>r().update(pi(n)).digest(),e=r();return t.outputLen=e.outputLen,t.blockLen=e.blockLen,t.create=()=>r(),t}function ad(r,t,e,n){if(typeof r.setBigUint64=="function")return r.setBigUint64(t,e,n);let s=BigInt(32),o=BigInt(4294967295),i=Number(e>>s&o),a=Number(e&o),c=n?4:0,l=n?0:4;r.setUint32(t+c,i,n),r.setUint32(t+l,a,n)}var hc=(r,t,e)=>r&t^~r&e,dc=(r,t,e)=>r&t^r&e^t&e,Pn=class extends On{constructor(t,e,n,s){super(),this.blockLen=t,this.outputLen=e,this.padOffset=n,this.isLE=s,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=Vn(this.buffer)}update(t){di(this);let{view:e,buffer:n,blockLen:s}=this;t=pi(t);let o=t.length;for(let i=0;i<o;){let a=Math.min(s-this.pos,o-i);if(a===s){let c=Vn(t);for(;s<=o-i;i+=s)this.process(c,i);continue}n.set(t.subarray(i,i+a),this.pos),this.pos+=a,i+=a,this.pos===s&&(this.process(e,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){di(this),uc(t,this),this.finished=!0;let{buffer:e,view:n,blockLen:s,isLE:o}=this,{pos:i}=this;e[i++]=128,this.buffer.subarray(i).fill(0),this.padOffset>s-i&&(this.process(n,0),i=0);for(let f=i;f<s;f++)e[f]=0;ad(n,s-8,BigInt(this.length*8),o),this.process(n,0);let a=Vn(t),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let l=c/4,u=this.get();if(l>u.length)throw new Error("_sha2: outputLen bigger than state");for(let f=0;f<l;f++)a.setUint32(4*f,u[f],o)}digest(){let{buffer:t,outputLen:e}=this;this.digestInto(t);let n=t.slice(0,e);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());let{blockLen:e,buffer:n,length:s,finished:o,destroyed:i,pos:a}=this;return t.length=s,t.pos=a,t.finished=o,t.destroyed=i,s%e&&t.buffer.set(n),t}};var cd=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]),_e=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Oe=new Uint32Array(64),gi=class extends Pn{constructor(){super(64,32,8,!1),this.A=_e[0]|0,this.B=_e[1]|0,this.C=_e[2]|0,this.D=_e[3]|0,this.E=_e[4]|0,this.F=_e[5]|0,this.G=_e[6]|0,this.H=_e[7]|0}get(){let{A:t,B:e,C:n,D:s,E:o,F:i,G:a,H:c}=this;return[t,e,n,s,o,i,a,c]}set(t,e,n,s,o,i,a,c){this.A=t|0,this.B=e|0,this.C=n|0,this.D=s|0,this.E=o|0,this.F=i|0,this.G=a|0,this.H=c|0}process(t,e){for(let f=0;f<16;f++,e+=4)Oe[f]=t.getUint32(e,!1);for(let f=16;f<64;f++){let h=Oe[f-15],d=Oe[f-2],p=Wt(h,7)^Wt(h,18)^h>>>3,b=Wt(d,17)^Wt(d,19)^d>>>10;Oe[f]=b+Oe[f-7]+p+Oe[f-16]|0}let{A:n,B:s,C:o,D:i,E:a,F:c,G:l,H:u}=this;for(let f=0;f<64;f++){let h=Wt(a,6)^Wt(a,11)^Wt(a,25),d=u+h+hc(a,c,l)+cd[f]+Oe[f]|0,b=(Wt(n,2)^Wt(n,13)^Wt(n,22))+dc(n,s,o)|0;u=l,l=c,c=a,a=i+d|0,i=o,o=s,s=n,n=d+b|0}n=n+this.A|0,s=s+this.B|0,o=o+this.C|0,i=i+this.D|0,a=a+this.E|0,c=c+this.F|0,l=l+this.G|0,u=u+this.H|0,this.set(n,s,o,i,a,c,l,u)}roundClean(){Oe.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var Dn=fc(()=>new gi);var M=ro(pc());function Qe(r,t){let e=0;if(r.length===1)return r[0];for(let n=r.length-1;n>=0;n--)e+=r[r.length-1-n]*Math.pow(2,t*n);return e}function Ve(r,t,e=-1){let n=e,s=r,o=0,i=Math.pow(2,t);for(let a=1;a<8;a++){if(r<i){let c;if(n<0)c=new ArrayBuffer(a),o=a;else{if(n<a)return new ArrayBuffer(0);c=new ArrayBuffer(n),o=n}let l=new Uint8Array(c);for(let u=a-1;u>=0;u--){let f=Math.pow(2,u*t);l[o-u-1]=Math.floor(s/f),s-=l[o-u-1]*f}return c}i*=Math.pow(2,t)}return new ArrayBuffer(0)}function Hn(...r){let t=0,e=0;for(let o of r)t+=o.length;let n=new ArrayBuffer(t),s=new Uint8Array(n);for(let o of r)s.set(o,e),e+=o.length;return s}function bi(){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 t=new ArrayBuffer(this.valueHex.byteLength),e=new Uint8Array(t);for(let a=0;a<this.valueHex.byteLength;a++)e[a]=0;e[0]=r[0]&128;let n=Qe(e,8),s=new ArrayBuffer(this.valueHex.byteLength),o=new Uint8Array(s);for(let a=0;a<this.valueHex.byteLength;a++)o[a]=r[a];return o[0]&=127,Qe(o,8)-n}function gc(r){let t=r<0?r*-1:r,e=128;for(let n=1;n<8;n++){if(t<=e){if(r<0){let i=e-t,a=Ve(i,8,n),c=new Uint8Array(a);return c[0]|=128,a}let s=Ve(t,8,n),o=new Uint8Array(s);if(o[0]&128){let i=s.slice(0),a=new Uint8Array(i);s=new ArrayBuffer(s.byteLength+1),o=new Uint8Array(s);for(let c=0;c<i.byteLength;c++)o[c+1]=a[c];o[0]=0}return s}e*=Math.pow(2,8)}return new ArrayBuffer(0)}function mc(r,t){if(r.byteLength!==t.byteLength)return!1;let e=new Uint8Array(r),n=new Uint8Array(t);for(let s=0;s<e.length;s++)if(e[s]!==n[s])return!1;return!0}function Ut(r,t){let e=r.toString(10);if(t<e.length)return"";let n=t-e.length,s=new Array(n);for(let i=0;i<n;i++)s[i]="0";return s.join("").concat(e)}var Cm=Math.log(2);function Kn(){if(typeof BigInt>"u")throw new Error("BigInt is not defined. Your environment doesn't implement BigInt.")}function yi(r){let t=0,e=0;for(let s=0;s<r.length;s++){let o=r[s];t+=o.byteLength}let n=new Uint8Array(t);for(let s=0;s<r.length;s++){let o=r[s];n.set(new Uint8Array(o),e),e+=o.byteLength}return n.buffer}function we(r,t,e,n){return t instanceof Uint8Array?t.byteLength?e<0?(r.error="Wrong parameter: inputOffset less than zero",!1):n<0?(r.error="Wrong parameter: inputLength less than zero",!1):t.byteLength-e-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 Kr=class{constructor(){this.items=[]}write(t){this.items.push(t)}final(){return yi(this.items)}},Hr=[new Uint8Array([1])],bc="0123456789";var br="",jt=new ArrayBuffer(0),wi=new Uint8Array(0),qr="EndOfContent",wc="OCTET STRING",xc="BIT STRING";function xe(r){var t;return t=class extends r{constructor(...n){var s;super(...n);let o=n[0]||{};this.isHexOnly=(s=o.isHexOnly)!==null&&s!==void 0?s:!1,this.valueHexView=o.valueHex?M.BufferSourceConverter.toUint8Array(o.valueHex):wi}get valueHex(){return this.valueHexView.slice().buffer}set valueHex(n){this.valueHexView=new Uint8Array(n)}fromBER(n,s,o){let i=n instanceof ArrayBuffer?new Uint8Array(n):n;if(!we(this,i,s,o))return-1;let a=s+o;return this.valueHexView=i.subarray(s,a),this.valueHexView.length?(this.blockLength=o,a):(this.warnings.push("Zero buffer length"),s)}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",jt)}toJSON(){return{...super.toJSON(),isHexOnly:this.isHexOnly,valueHex:M.Convert.ToHex(this.valueHexView)}}},t.NAME="hexBlock",t}var me=class{constructor({blockLength:t=0,error:e=br,warnings:n=[],valueBeforeDecode:s=wi}={}){this.blockLength=t,this.error=e,this.warnings=n,this.valueBeforeDecodeView=M.BufferSourceConverter.toUint8Array(s)}static blockName(){return this.NAME}get valueBeforeDecode(){return this.valueBeforeDecodeView.slice().buffer}set valueBeforeDecode(t){this.valueBeforeDecodeView=new Uint8Array(t)}toJSON(){return{blockName:this.constructor.NAME,blockLength:this.blockLength,error:this.error,warnings:this.warnings,valueBeforeDecode:M.Convert.ToHex(this.valueBeforeDecodeView)}}};me.NAME="baseBlock";var Et=class extends me{fromBER(t,e,n){throw TypeError("User need to make a specific function in a class which extends 'ValueBlock'")}toBER(t,e){throw TypeError("User need to make a specific function in a class which extends 'ValueBlock'")}};Et.NAME="valueBlock";var qn=class extends xe(me){constructor({idBlock:t={}}={}){var e,n,s,o;super(),t?(this.isHexOnly=(e=t.isHexOnly)!==null&&e!==void 0?e:!1,this.valueHexView=t.valueHex?M.BufferSourceConverter.toUint8Array(t.valueHex):wi,this.tagClass=(n=t.tagClass)!==null&&n!==void 0?n:-1,this.tagNumber=(s=t.tagNumber)!==null&&s!==void 0?s:-1,this.isConstructed=(o=t.isConstructed)!==null&&o!==void 0?o:!1):(this.tagClass=-1,this.tagNumber=-1,this.isConstructed=!1)}toBER(t=!1){let e=0;switch(this.tagClass){case 1:e|=0;break;case 2:e|=64;break;case 3:e|=128;break;case 4:e|=192;break;default:return this.error="Unknown tag class",jt}if(this.isConstructed&&(e|=32),this.tagNumber<31&&!this.isHexOnly){let s=new Uint8Array(1);if(!t){let o=this.tagNumber;o&=31,e|=o,s[0]=e}return s.buffer}if(!this.isHexOnly){let s=Ve(this.tagNumber,7),o=new Uint8Array(s),i=s.byteLength,a=new Uint8Array(i+1);if(a[0]=e|31,!t){for(let c=0;c<i-1;c++)a[c+1]=o[c]|128;a[i]=o[i-1]}return a.buffer}let n=new Uint8Array(this.valueHexView.byteLength+1);if(n[0]=e|31,!t){let s=this.valueHexView;for(let o=0;o<s.length-1;o++)n[o+1]=s[o]|128;n[this.valueHexView.byteLength]=s[s.length-1]}return n.buffer}fromBER(t,e,n){let s=M.BufferSourceConverter.toUint8Array(t);if(!we(this,s,e,n))return-1;let o=s.subarray(e,e+n);if(o.length===0)return this.error="Zero buffer length",-1;switch(o[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=(o[0]&32)===32,this.isHexOnly=!1;let a=o[0]&31;if(a!==31)this.tagNumber=a,this.blockLength=1;else{let c=1,l=this.valueHexView=new Uint8Array(255),u=255;for(;o[c]&128;){if(l[c-1]=o[c]&127,c++,c>=o.length)return this.error="End of input reached before message was fully decoded",-1;if(c===u){u+=255;let h=new Uint8Array(u);for(let d=0;d<l.length;d++)h[d]=l[d];l=this.valueHexView=new Uint8Array(u)}}this.blockLength=c+1,l[c-1]=o[c]&127;let f=new Uint8Array(c);for(let h=0;h<c;h++)f[h]=l[h];l=this.valueHexView=new Uint8Array(c),l.set(f),this.blockLength<=9?this.tagNumber=Qe(l,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 e+this.blockLength}toJSON(){return{...super.toJSON(),tagClass:this.tagClass,tagNumber:this.tagNumber,isConstructed:this.isConstructed}}};qn.NAME="identificationBlock";var $n=class extends me{constructor({lenBlock:t={}}={}){var e,n,s;super(),this.isIndefiniteForm=(e=t.isIndefiniteForm)!==null&&e!==void 0?e:!1,this.longFormUsed=(n=t.longFormUsed)!==null&&n!==void 0?n:!1,this.length=(s=t.length)!==null&&s!==void 0?s:0}fromBER(t,e,n){let s=M.BufferSourceConverter.toUint8Array(t);if(!we(this,s,e,n))return-1;let o=s.subarray(e,e+n);if(o.length===0)return this.error="Zero buffer length",-1;if(o[0]===255)return this.error="Length block 0xFF is reserved by standard",-1;if(this.isIndefiniteForm=o[0]===128,this.isIndefiniteForm)return this.blockLength=1,e+this.blockLength;if(this.longFormUsed=!!(o[0]&128),this.longFormUsed===!1)return this.length=o[0],this.blockLength=1,e+this.blockLength;let i=o[0]&127;if(i>8)return this.error="Too big integer",-1;if(i+1>o.length)return this.error="End of input reached before message was fully decoded",-1;let a=e+1,c=s.subarray(a,a+i);return c[i-1]===0&&this.warnings.push("Needlessly long encoded length"),this.length=Qe(c,8),this.longFormUsed&&this.length<=127&&this.warnings.push("Unnecessary usage of long length form"),this.blockLength=i+1,e+this.blockLength}toBER(t=!1){let e,n;if(this.length>127&&(this.longFormUsed=!0),this.isIndefiniteForm)return e=new ArrayBuffer(1),t===!1&&(n=new Uint8Array(e),n[0]=128),e;if(this.longFormUsed){let s=Ve(this.length,8);if(s.byteLength>127)return this.error="Too big length",jt;if(e=new ArrayBuffer(s.byteLength+1),t)return e;let o=new Uint8Array(s);n=new Uint8Array(e),n[0]=s.byteLength|128;for(let i=0;i<s.byteLength;i++)n[i+1]=o[i];return e}return e=new ArrayBuffer(1),t===!1&&(n=new Uint8Array(e),n[0]=this.length),e}toJSON(){return{...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,longFormUsed:this.longFormUsed,length:this.length}}};$n.NAME="lengthBlock";var B={},gt=class extends me{constructor({name:t=br,optional:e=!1,primitiveSchema:n,...s}={},o){super(s),this.name=t,this.optional=e,n&&(this.primitiveSchema=n),this.idBlock=new qn(s),this.lenBlock=new $n(s),this.valueBlock=o?new o(s):new Et(s)}fromBER(t,e,n){let s=this.valueBlock.fromBER(t,e,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length);return s===-1?(this.error=this.valueBlock.error,s):(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),s)}toBER(t,e){let n=e||new Kr;e||vc(this);let s=this.idBlock.toBER(t);if(n.write(s),this.lenBlock.isIndefiniteForm)n.write(new Uint8Array([128]).buffer),this.valueBlock.toBER(t,n),n.write(new ArrayBuffer(2));else{let o=this.valueBlock.toBER(t);this.lenBlock.length=o.byteLength;let i=this.lenBlock.toBER(t);n.write(i),n.write(o)}return e?jt:n.final()}toJSON(){let t={...super.toJSON(),idBlock:this.idBlock.toJSON(),lenBlock:this.lenBlock.toJSON(),valueBlock:this.valueBlock.toJSON(),name:this.name,optional:this.optional};return this.primitiveSchema&&(t.primitiveSchema=this.primitiveSchema.toJSON()),t}toString(t="ascii"){return t==="ascii"?this.onAsciiEncoding():M.Convert.ToHex(this.toBER())}onAsciiEncoding(){return`${this.constructor.NAME} : ${M.Convert.ToHex(this.valueBlock.valueBeforeDecodeView)}`}isEqual(t){if(this===t)return!0;if(!(t instanceof this.constructor))return!1;let e=this.toBER(),n=t.toBER();return mc(e,n)}};gt.NAME="BaseBlock";function vc(r){if(r instanceof B.Constructed)for(let t of r.valueBlock.value)vc(t)&&(r.lenBlock.isIndefiniteForm=!0);return!!r.lenBlock.isIndefiniteForm}var zn=class extends gt{constructor({value:t=br,...e}={},n){super(e,n),t&&this.fromString(t)}getValue(){return this.valueBlock.value}setValue(t){this.valueBlock.value=t}fromBER(t,e,n){let s=this.valueBlock.fromBER(t,e,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length);return s===-1?(this.error=this.valueBlock.error,s):(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),s)}onAsciiEncoding(){return`${this.constructor.NAME} : '${this.valueBlock.value}'`}};zn.NAME="BaseStringBlock";var Gn=class extends xe(Et){constructor({isHexOnly:t=!0,...e}={}){super(e),this.isHexOnly=t}};Gn.NAME="PrimitiveValueBlock";var Ec,Wn=class extends gt{constructor(t={}){super(t,Gn),this.idBlock.isConstructed=!1}};Ec=Wn;B.Primitive=Ec;Wn.NAME="PRIMITIVE";function bd(r,t){if(r instanceof t)return r;let e=new t;return e.idBlock=r.idBlock,e.lenBlock=r.lenBlock,e.warnings=r.warnings,e.valueBeforeDecodeView=r.valueBeforeDecodeView,e}function ks(r,t=0,e=r.length){let n=t,s=new gt({},Et),o=new me;if(!we(o,r,t,e))return s.error=o.error,{offset:-1,result:s};if(!r.subarray(t,t+e).length)return s.error="Zero buffer length",{offset:-1,result:s};let a=s.idBlock.fromBER(r,t,e);if(s.idBlock.warnings.length&&s.warnings.concat(s.idBlock.warnings),a===-1)return s.error=s.idBlock.error,{offset:-1,result:s};if(t=a,e-=s.idBlock.blockLength,a=s.lenBlock.fromBER(r,t,e),s.lenBlock.warnings.length&&s.warnings.concat(s.lenBlock.warnings),a===-1)return s.error=s.lenBlock.error,{offset:-1,result:s};if(t=a,e-=s.lenBlock.blockLength,!s.idBlock.isConstructed&&s.lenBlock.isIndefiniteForm)return s.error="Indefinite length form used for primitive encoding form",{offset:-1,result:s};let c=gt;switch(s.idBlock.tagClass){case 1:if(s.idBlock.tagNumber>=37&&s.idBlock.isHexOnly===!1)return s.error="UNIVERSAL 37 and upper tags are reserved by ASN.1 standard",{offset:-1,result:s};switch(s.idBlock.tagNumber){case 0:if(s.idBlock.isConstructed&&s.lenBlock.length>0)return s.error="Type [UNIVERSAL 0] is reserved",{offset:-1,result:s};c=B.EndOfContent;break;case 1:c=B.Boolean;break;case 2:c=B.Integer;break;case 3:c=B.BitString;break;case 4:c=B.OctetString;break;case 5:c=B.Null;break;case 6:c=B.ObjectIdentifier;break;case 10:c=B.Enumerated;break;case 12:c=B.Utf8String;break;case 13:c=B.RelativeObjectIdentifier;break;case 14:c=B.TIME;break;case 15:return s.error="[UNIVERSAL 15] is reserved by ASN.1 standard",{offset:-1,result:s};case 16:c=B.Sequence;break;case 17:c=B.Set;break;case 18:c=B.NumericString;break;case 19:c=B.PrintableString;break;case 20:c=B.TeletexString;break;case 21:c=B.VideotexString;break;case 22:c=B.IA5String;break;case 23:c=B.UTCTime;break;case 24:c=B.GeneralizedTime;break;case 25:c=B.GraphicString;break;case 26:c=B.VisibleString;break;case 27:c=B.GeneralString;break;case 28:c=B.UniversalString;break;case 29:c=B.CharacterString;break;case 30:c=B.BmpString;break;case 31:c=B.DATE;break;case 32:c=B.TimeOfDay;break;case 33:c=B.DateTime;break;case 34:c=B.Duration;break;default:{let l=s.idBlock.isConstructed?new B.Constructed:new B.Primitive;l.idBlock=s.idBlock,l.lenBlock=s.lenBlock,l.warnings=s.warnings,s=l}}break;case 2:case 3:case 4:default:c=s.idBlock.isConstructed?B.Constructed:B.Primitive}return s=bd(s,c),a=s.fromBER(r,t,s.lenBlock.isIndefiniteForm?e:s.lenBlock.length),s.valueBeforeDecodeView=r.subarray(n,n+s.blockLength),{offset:a,result:s}}function xi(r){if(!r.byteLength){let t=new gt({},Et);return t.error="Input buffer has zero length",{offset:-1,result:t}}return ks(M.BufferSourceConverter.toUint8Array(r).slice(),0,r.byteLength)}function yd(r,t){return r?1:t}var ee=class extends Et{constructor({value:t=[],isIndefiniteForm:e=!1,...n}={}){super(n),this.value=t,this.isIndefiniteForm=e}fromBER(t,e,n){let s=M.BufferSourceConverter.toUint8Array(t);if(!we(this,s,e,n))return-1;if(this.valueBeforeDecodeView=s.subarray(e,e+n),this.valueBeforeDecodeView.length===0)return this.warnings.push("Zero buffer length"),e;let o=e;for(;yd(this.isIndefiniteForm,n)>0;){let i=ks(s,o,n);if(i.offset===-1)return this.error=i.result.error,this.warnings.concat(i.result.warnings),-1;if(o=i.offset,this.blockLength+=i.result.blockLength,n-=i.result.blockLength,this.value.push(i.result),this.isIndefiniteForm&&i.result.constructor.NAME===qr)break}return this.isIndefiniteForm&&(this.value[this.value.length-1].constructor.NAME===qr?this.value.pop():this.warnings.push("No EndOfContent block encoded")),o}toBER(t,e){let n=e||new Kr;for(let s=0;s<this.value.length;s++)this.value[s].toBER(t,n);return e?jt:n.final()}toJSON(){let t={...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,value:[]};for(let e of this.value)t.value.push(e.toJSON());return t}};ee.NAME="ConstructedValueBlock";var Bc,Pe=class extends gt{constructor(t={}){super(t,ee),this.idBlock.isConstructed=!0}fromBER(t,e,n){this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm;let s=this.valueBlock.fromBER(t,e,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length);return s===-1?(this.error=this.valueBlock.error,s):(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),s)}onAsciiEncoding(){let t=[];for(let n of this.valueBlock.value)t.push(n.toString("ascii").split(`
|
|
3
3
|
`).map(s=>` ${s}`).join(`
|
|
4
4
|
`));let e=this.idBlock.tagClass===3?`[${this.idBlock.tagNumber}]`:this.constructor.NAME;return t.length?`${e} :
|
|
5
5
|
${t.join(`
|
|
6
|
-
`)}`:`${e} :`}};sc=Pe;A.Constructed=sc;Pe.NAME="CONSTRUCTED";var Fn=class extends Et{fromBER(t,e,n){return e}toBER(t){return Wt}};Fn.override="EndOfContentValueBlock";var oc,Hn=class extends gt{constructor(t={}){super(t,Fn),this.idBlock.tagClass=1,this.idBlock.tagNumber=0}};oc=Hn;A.EndOfContent=oc;Hn.NAME=Hr;var ic,fr=class extends gt{constructor(t={}){super(t,Et),this.idBlock.tagClass=1,this.idBlock.tagNumber=5}fromBER(t,e,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,e+n>t.byteLength?(this.error="End of input reached before message was fully decoded (inconsistent offset and length values)",-1):e+n}toBER(t,e){let n=new ArrayBuffer(2);if(!t){let s=new Uint8Array(n);s[0]=5,s[1]=0}return e&&e.write(n),n}onAsciiEncoding(){return`${this.constructor.NAME}`}};ic=fr;A.Null=ic;fr.NAME="NULL";var Kn=class extends be(Et){constructor({value:t,...e}={}){super(e),e.valueHex?this.valueHexView=M.BufferSourceConverter.toUint8Array(e.valueHex):this.valueHexView=new Uint8Array(1),t&&(this.value=t)}get value(){for(let t of this.valueHexView)if(t>0)return!0;return!1}set value(t){this.valueHexView[0]=t?255:0}fromBER(t,e,n){let s=M.BufferSourceConverter.toUint8Array(t);return ye(this,s,e,n)?(this.valueHexView=s.subarray(e,e+n),n>1&&this.warnings.push("Boolean value encoded in more then 1 octet"),this.isHexOnly=!0,oi.call(this),this.blockLength=n,e+n):-1}toBER(){return this.valueHexView.slice()}toJSON(){return{...super.toJSON(),value:this.value}}};Kn.NAME="BooleanValueBlock";var ac,$n=class extends gt{constructor(t={}){super(t,Kn),this.idBlock.tagClass=1,this.idBlock.tagNumber=1}getValue(){return this.valueBlock.value}setValue(t){this.valueBlock.value=t}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.getValue}`}};ac=$n;A.Boolean=ac;$n.NAME="BOOLEAN";var qn=class extends be(Qt){constructor({isConstructed:t=!1,...e}={}){super(e),this.isConstructed=t}fromBER(t,e,n){let s=0;if(this.isConstructed){if(this.isHexOnly=!1,s=Qt.prototype.fromBER.call(this,t,e,n),s===-1)return s;for(let o=0;o<this.value.length;o++){let i=this.value[o].constructor.NAME;if(i===Hr){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, OCTET STRING may consists of OCTET STRINGs only",-1}if(i!==tc)return this.error="OCTET STRING may consists of OCTET STRINGs only",-1}}else this.isHexOnly=!0,s=super.fromBER(t,e,n),this.blockLength=n;return s}toBER(t,e){return this.isConstructed?Qt.prototype.toBER.call(this,t,e):t?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),isConstructed:this.isConstructed}}};qn.NAME="OctetStringValueBlock";var cc,zn=class r extends gt{constructor({idBlock:t={},lenBlock:e={},...n}={}){var s,o;(s=n.isConstructed)!==null&&s!==void 0||(n.isConstructed=!!(!((o=n.value)===null||o===void 0)&&o.length)),super({idBlock:{isConstructed:n.isConstructed,...t},lenBlock:{...e,isIndefiniteForm:!!n.isIndefiniteForm},...n},qn),this.idBlock.tagClass=1,this.idBlock.tagNumber=4}fromBER(t,e,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),e;if(!this.valueBlock.isConstructed){let o=(t instanceof ArrayBuffer?new Uint8Array(t):t).subarray(e,e+n);try{if(o.byteLength){let i=ws(o,0,o.byteLength);i.offset!==-1&&i.offset===n&&(this.valueBlock.value=[i.result])}}catch{}}return super.fromBER(t,e,n)}onAsciiEncoding(){return this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length?Pe.prototype.onAsciiEncoding.call(this):`${this.constructor.NAME} : ${M.Convert.ToHex(this.valueBlock.valueHexView)}`}getValue(){if(!this.idBlock.isConstructed)return this.valueBlock.valueHexView.slice().buffer;let t=[];for(let e of this.valueBlock.value)e instanceof r&&t.push(e.valueBlock.valueHexView);return M.BufferSourceConverter.concat(t)}};cc=zn;A.OctetString=cc;zn.NAME=tc;var Gn=class extends be(Qt){constructor({unusedBits:t=0,isConstructed:e=!1,...n}={}){super(n),this.unusedBits=t,this.isConstructed=e,this.blockLength=this.valueHexView.byteLength}fromBER(t,e,n){if(!n)return e;let s=-1;if(this.isConstructed){if(s=Qt.prototype.fromBER.call(this,t,e,n),s===-1)return s;for(let a of this.value){let c=a.constructor.NAME;if(c===Hr){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, BIT STRING may consists of BIT STRINGs only",-1}if(c!==ec)return this.error="BIT STRING may consists of BIT STRINGs only",-1;let l=a.valueBlock;if(this.unusedBits>0&&l.unusedBits>0)return this.error='Using of "unused bits" inside constructive BIT STRING allowed for least one only',-1;this.unusedBits=l.unusedBits}return s}let o=M.BufferSourceConverter.toUint8Array(t);if(!ye(this,o,e,n))return-1;let i=o.subarray(e,e+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=ws(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,e+n}toBER(t,e){if(this.isConstructed)return Qt.prototype.toBER.call(this,t,e);if(t)return new ArrayBuffer(this.valueHexView.byteLength+1);if(!this.valueHexView.byteLength)return Wt;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}}};Gn.NAME="BitStringValueBlock";var lc,hr=class extends gt{constructor({idBlock:t={},lenBlock:e={},...n}={}){var s,o;(s=n.isConstructed)!==null&&s!==void 0||(n.isConstructed=!!(!((o=n.value)===null||o===void 0)&&o.length)),super({idBlock:{isConstructed:n.isConstructed,...t},lenBlock:{...e,isIndefiniteForm:!!n.isIndefiniteForm},...n},Gn),this.idBlock.tagClass=1,this.idBlock.tagNumber=3}fromBER(t,e,n){return this.valueBlock.isConstructed=this.idBlock.isConstructed,this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm,super.fromBER(t,e,n)}onAsciiEncoding(){if(this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length)return Pe.prototype.onAsciiEncoding.call(this);{let t=[],e=this.valueBlock.valueHexView;for(let s of e)t.push(s.toString(2).padStart(8,"0"));let n=t.join("");return`${this.constructor.NAME} : ${n.substring(0,n.length-this.valueBlock.unusedBits)}`}}};lc=hr;A.BitString=lc;hr.NAME=ec;var uc;function Zh(r,t){let e=new Uint8Array([0]),n=new Uint8Array(r),s=new Uint8Array(t),o=n.slice(0),i=o.length-1,a=s.slice(0),c=a.length-1,l=0,u=c<i?i:c,f=0;for(let h=u;h>=0;h--,f++){switch(!0){case f<a.length:l=o[i-f]+a[c-f]+e[0];break;default:l=o[i-f]+e[0]}switch(e[0]=l/10,!0){case f>=o.length:o=Rn(new Uint8Array([l%10]),o);break;default:o[i-f]=l%10}}return e[0]>0&&(o=Rn(e,o)),o}function Qa(r){if(r>=Mr.length)for(let t=Mr.length;t<=r;t++){let e=new Uint8Array([0]),n=Mr[t-1].slice(0);for(let s=n.length-1;s>=0;s--){let o=new Uint8Array([(n[s]<<1)+e[0]]);e[0]=o[0]/10,n[s]=o[0]%10}e[0]>0&&(n=Rn(e,n)),Mr.push(n)}return Mr[r]}function Yh(r,t){let e=0,n=new Uint8Array(r),s=new Uint8Array(t),o=n.slice(0),i=o.length-1,a=s.slice(0),c=a.length-1,l,u=0;for(let f=c;f>=0;f--,u++)switch(l=o[i-u]-a[c-u]-e,!0){case l<0:e=1,o[i-u]=l+10;break;default:e=0,o[i-u]=l}if(e>0)for(let f=i-c+1;f>=0;f--,u++)if(l=o[i-u]-e,l<0)e=1,o[i-u]=l+10;else{e=0,o[i-u]=l;break}return o.slice()}var Kr=class extends be(Et){constructor({value:t,...e}={}){super(e),this._valueDec=0,e.valueHex&&this.setValueHex(),t!==void 0&&(this.valueDec=t)}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=oi.call(this)))}set valueDec(t){this._valueDec=t,this.isHexOnly=!1,this.valueHexView=new Uint8Array(Ya(t))}get valueDec(){return this._valueDec}fromDER(t,e,n,s=0){let o=this.fromBER(t,e,n);if(o===-1)return o;let i=this.valueHexView;return i[0]===0&&i[1]&128?this.valueHexView=i.subarray(1):s!==0&&i.length<s&&(s-i.length>1&&(s=i.length+1),this.valueHexView=i.subarray(s-i.length)),o}toDER(t=!1){let e=this.valueHexView;switch(!0){case(e[0]&128)!==0:{let n=new Uint8Array(this.valueHexView.length+1);n[0]=0,n.set(e,1),this.valueHexView=n}break;case(e[0]===0&&(e[1]&128)===0):this.valueHexView=this.valueHexView.subarray(1);break}return this.toBER(t)}fromBER(t,e,n){let s=super.fromBER(t,e,n);return s===-1||this.setValueHex(),s}toBER(t){return t?new ArrayBuffer(this.valueHexView.length):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}toString(){let t=this.valueHexView.length*8-1,e=new Uint8Array(this.valueHexView.length*8/3),n=0,s,o=this.valueHexView,i="",a=!1;for(let c=o.byteLength-1;c>=0;c--){s=o[c];for(let l=0;l<8;l++){if((s&1)===1)switch(n){case t:e=Yh(Qa(n),e),i="-";break;default:e=Zh(e,Qa(n))}n++,s>>=1}}for(let c=0;c<e.length;c++)e[c]&&(a=!0),a&&(i+=Xa.charAt(e[c]));return a===!1&&(i+=Xa.charAt(0)),i}};uc=Kr;Kr.NAME="IntegerValueBlock";Object.defineProperty(uc.prototype,"valueHex",{set:function(r){this.valueHexView=new Uint8Array(r),this.setValueHex()},get:function(){return this.valueHexView.slice().buffer}});var fc,yt=class r extends gt{constructor(t={}){super(t,Kr),this.idBlock.tagClass=1,this.idBlock.tagNumber=2}toBigInt(){return _n(),BigInt(this.valueBlock.toString())}static fromBigInt(t){_n();let e=BigInt(t),n=new Fr,s=e.toString(16).replace(/^-/,""),o=new Uint8Array(M.Convert.FromHex(s));if(e<0){let a=new Uint8Array(o.length+(o[0]&128?1:0));a[0]|=128;let l=BigInt(`0x${M.Convert.ToHex(a)}`)+e,u=M.BufferSourceConverter.toUint8Array(M.Convert.FromHex(l.toString(16)));u[0]|=128,n.write(u)}else o[0]&128&&n.write(new Uint8Array([0])),n.write(o);return new r({valueHex:n.final()})}convertToDER(){let t=new r({valueHex:this.valueBlock.valueHexView});return t.valueBlock.toDER(),t}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()}`}};fc=yt;A.Integer=fc;yt.NAME="INTEGER";var hc,Wn=class extends yt{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=10}};hc=Wn;A.Enumerated=hc;Wn.NAME="ENUMERATED";var $r=class extends be(Et){constructor({valueDec:t=-1,isFirstSid:e=!1,...n}={}){super(n),this.valueDec=t,this.isFirstSid=e}fromBER(t,e,n){if(!n)return e;let s=M.BufferSourceConverter.toUint8Array(t);if(!ye(this,s,e,n))return-1;let o=s.subarray(e,e+n);this.valueHexView=new Uint8Array(n);for(let a=0;a<n&&(this.valueHexView[a]=o[a]&127,this.blockLength++,!!(o[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,o[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=Ze(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),e+this.blockLength)}set valueBigInt(t){_n();let e=BigInt(t).toString(2);for(;e.length%7;)e="0"+e;let n=new Uint8Array(e.length/7);for(let s=0;s<n.length;s++)n[s]=parseInt(e.slice(s*7,s*7+7),2)+(s+1<n.length?128:0);this.fromBER(n.buffer,0,n.length)}toBER(t){if(this.isHexOnly){if(t)return new ArrayBuffer(this.valueHexView.byteLength);let s=this.valueHexView,o=new Uint8Array(this.blockLength);for(let i=0;i<this.blockLength-1;i++)o[i]=s[i]|128;return o[this.blockLength-1]=s[this.blockLength-1],o.buffer}let e=_e(this.valueDec,7);if(e.byteLength===0)return this.error="Error during encoding SID value",Wt;let n=new Uint8Array(e.byteLength);if(!t){let s=new Uint8Array(e),o=e.byteLength-1;for(let i=0;i<o;i++)n[i]=s[i]|128;n[o]=s[o]}return n}toString(){let t="";if(this.isHexOnly)t=M.Convert.ToHex(this.valueHexView);else if(this.isFirstSid){let e=this.valueDec;this.valueDec<=39?t="0.":this.valueDec<=79?(t="1.",e-=40):(t="2.",e-=80),t+=e.toString()}else t=this.valueDec.toString();return t}toJSON(){return{...super.toJSON(),valueDec:this.valueDec,isFirstSid:this.isFirstSid}}};$r.NAME="sidBlock";var jn=class extends Et{constructor({value:t=pr,...e}={}){super(e),this.value=[],t&&this.fromString(t)}fromBER(t,e,n){let s=e;for(;n>0;){let o=new $r;if(s=o.fromBER(t,s,n),s===-1)return this.blockLength=0,this.error=o.error,s;this.value.length===0&&(o.isFirstSid=!0),this.blockLength+=o.blockLength,n-=o.blockLength,this.value.push(o)}return s}toBER(t){let e=[];for(let n=0;n<this.value.length;n++){let s=this.value[n].toBER(t);if(s.byteLength===0)return this.error=this.value[n].error,Wt;e.push(s)}return ii(e)}fromString(t){this.value=[];let e=0,n=0,s="",o=!1;do if(n=t.indexOf(".",e),n===-1?s=t.substring(e):s=t.substring(e,n),e=n+1,o){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(s,10);if(isNaN(c))return;i.valueDec=c+a,o=!1}else{let i=new $r;if(s>Number.MAX_SAFE_INTEGER){_n();let a=BigInt(s);i.valueBigInt=a}else if(i.valueDec=parseInt(s,10),isNaN(i.valueDec))return;this.value.length||(i.isFirstSid=!0,o=!0),this.value.push(i)}while(n!==-1)}toString(){let t="",e=!1;for(let n=0;n<this.value.length;n++){e=this.value[n].isHexOnly;let s=this.value[n].toString();n!==0&&(t=`${t}.`),e?(s=`{${s}}`,this.value[n].isFirstSid?t=`2.{${s} - 80}`:t+=s):t+=s}return t}toJSON(){let t={...super.toJSON(),value:this.toString(),sidArray:[]};for(let e=0;e<this.value.length;e++)t.sidArray.push(this.value[e].toJSON());return t}};jn.NAME="ObjectIdentifierValueBlock";var dc,dr=class extends gt{constructor(t={}){super(t,jn),this.idBlock.tagClass=1,this.idBlock.tagNumber=6}getValue(){return this.valueBlock.toString()}setValue(t){this.valueBlock.fromString(t)}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()||"empty"}`}toJSON(){return{...super.toJSON(),value:this.getValue()}}};dc=dr;A.ObjectIdentifier=dc;dr.NAME="OBJECT IDENTIFIER";var qr=class extends be(pe){constructor({valueDec:t=0,...e}={}){super(e),this.valueDec=t}fromBER(t,e,n){if(n===0)return e;let s=M.BufferSourceConverter.toUint8Array(t);if(!ye(this,s,e,n))return-1;let o=s.subarray(e,e+n);this.valueHexView=new Uint8Array(n);for(let a=0;a<n&&(this.valueHexView[a]=o[a]&127,this.blockLength++,!!(o[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,o[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=Ze(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),e+this.blockLength)}toBER(t){if(this.isHexOnly){if(t)return new ArrayBuffer(this.valueHexView.byteLength);let s=this.valueHexView,o=new Uint8Array(this.blockLength);for(let i=0;i<this.blockLength-1;i++)o[i]=s[i]|128;return o[this.blockLength-1]=s[this.blockLength-1],o.buffer}let e=_e(this.valueDec,7);if(e.byteLength===0)return this.error="Error during encoding SID value",Wt;let n=new Uint8Array(e.byteLength);if(!t){let s=new Uint8Array(e),o=e.byteLength-1;for(let i=0;i<o;i++)n[i]=s[i]|128;n[o]=s[o]}return n.buffer}toString(){let t="";return this.isHexOnly?t=M.Convert.ToHex(this.valueHexView):t=this.valueDec.toString(),t}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}};qr.NAME="relativeSidBlock";var Zn=class extends Et{constructor({value:t=pr,...e}={}){super(e),this.value=[],t&&this.fromString(t)}fromBER(t,e,n){let s=e;for(;n>0;){let o=new qr;if(s=o.fromBER(t,s,n),s===-1)return this.blockLength=0,this.error=o.error,s;this.blockLength+=o.blockLength,n-=o.blockLength,this.value.push(o)}return s}toBER(t,e){let n=[];for(let s=0;s<this.value.length;s++){let o=this.value[s].toBER(t);if(o.byteLength===0)return this.error=this.value[s].error,Wt;n.push(o)}return ii(n)}fromString(t){this.value=[];let e=0,n=0,s="";do{n=t.indexOf(".",e),n===-1?s=t.substring(e):s=t.substring(e,n),e=n+1;let o=new qr;if(o.valueDec=parseInt(s,10),isNaN(o.valueDec))return!0;this.value.push(o)}while(n!==-1);return!0}toString(){let t="",e=!1;for(let n=0;n<this.value.length;n++){e=this.value[n].isHexOnly;let s=this.value[n].toString();n!==0&&(t=`${t}.`),e&&(s=`{${s}}`),t+=s}return t}toJSON(){let t={...super.toJSON(),value:this.toString(),sidArray:[]};for(let e=0;e<this.value.length;e++)t.sidArray.push(this.value[e].toJSON());return t}};Zn.NAME="RelativeObjectIdentifierValueBlock";var pc,Yn=class extends gt{constructor(t={}){super(t,Zn),this.idBlock.tagClass=1,this.idBlock.tagNumber=13}getValue(){return this.valueBlock.toString()}setValue(t){this.valueBlock.fromString(t)}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()||"empty"}`}toJSON(){return{...super.toJSON(),value:this.getValue()}}};pc=Yn;A.RelativeObjectIdentifier=pc;Yn.NAME="RelativeObjectIdentifier";var mc,me=class extends Pe{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=16}};mc=me;A.Sequence=mc;me.NAME="SEQUENCE";var gc,Jn=class extends Pe{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=17}};gc=Jn;A.Set=gc;Jn.NAME="SET";var Xn=class extends be(Et){constructor({...t}={}){super(t),this.isHexOnly=!0,this.value=pr}toJSON(){return{...super.toJSON(),value:this.value}}};Xn.NAME="StringValueBlock";var Qn=class extends Xn{};Qn.NAME="SimpleStringValueBlock";var kt=class extends Vn{constructor({...t}={}){super(t,Qn)}fromBuffer(t){this.valueBlock.value=String.fromCharCode.apply(null,M.BufferSourceConverter.toUint8Array(t))}fromString(t){let e=t.length,n=this.valueBlock.valueHexView=new Uint8Array(e);for(let s=0;s<e;s++)n[s]=t.charCodeAt(s);this.valueBlock.value=t}};kt.NAME="SIMPLE STRING";var ts=class extends kt{fromBuffer(t){this.valueBlock.valueHexView=M.BufferSourceConverter.toUint8Array(t);try{this.valueBlock.value=M.Convert.ToUtf8String(t)}catch(e){this.warnings.push(`Error during "decodeURIComponent": ${e}, using raw string`),this.valueBlock.value=M.Convert.ToBinary(t)}}fromString(t){this.valueBlock.valueHexView=new Uint8Array(M.Convert.FromUtf8String(t)),this.valueBlock.value=t}};ts.NAME="Utf8StringValueBlock";var yc,ge=class extends ts{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=12}};yc=ge;A.Utf8String=yc;ge.NAME="UTF8String";var es=class extends kt{fromBuffer(t){this.valueBlock.value=M.Convert.ToUtf16String(t),this.valueBlock.valueHexView=M.BufferSourceConverter.toUint8Array(t)}fromString(t){this.valueBlock.value=t,this.valueBlock.valueHexView=new Uint8Array(M.Convert.FromUtf16String(t))}};es.NAME="BmpStringValueBlock";var bc,rs=class extends es{constructor({...t}={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=30}};bc=rs;A.BmpString=bc;rs.NAME="BMPString";var ns=class extends kt{fromBuffer(t){let e=ArrayBuffer.isView(t)?t.slice().buffer:t.slice(0),n=new Uint8Array(e);for(let s=0;s<n.length;s+=4)n[s]=n[s+3],n[s+1]=n[s+2],n[s+2]=0,n[s+3]=0;this.valueBlock.value=String.fromCharCode.apply(null,new Uint32Array(e))}fromString(t){let e=t.length,n=this.valueBlock.valueHexView=new Uint8Array(e*4);for(let s=0;s<e;s++){let o=_e(t.charCodeAt(s),8),i=new Uint8Array(o);if(i.length>4)continue;let a=4-i.length;for(let c=i.length-1;c>=0;c--)n[s*4+c+a]=i[c]}this.valueBlock.value=t}};ns.NAME="UniversalStringValueBlock";var wc,ss=class extends ns{constructor({...t}={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=28}};wc=ss;A.UniversalString=wc;ss.NAME="UniversalString";var xc,os=class extends kt{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=18}};xc=os;A.NumericString=xc;os.NAME="NumericString";var vc,is=class extends kt{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=19}};vc=is;A.PrintableString=vc;is.NAME="PrintableString";var Ec,as=class extends kt{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=20}};Ec=as;A.TeletexString=Ec;as.NAME="TeletexString";var Bc,cs=class extends kt{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=21}};Bc=cs;A.VideotexString=Bc;cs.NAME="VideotexString";var Ac,ls=class extends kt{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=22}};Ac=ls;A.IA5String=Ac;ls.NAME="IA5String";var Sc,us=class extends kt{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=25}};Sc=us;A.GraphicString=Sc;us.NAME="GraphicString";var Ic,zr=class extends kt{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=26}};Ic=zr;A.VisibleString=Ic;zr.NAME="VisibleString";var kc,fs=class extends kt{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=27}};kc=fs;A.GeneralString=kc;fs.NAME="GeneralString";var Nc,hs=class extends kt{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=29}};Nc=hs;A.CharacterString=Nc;hs.NAME="CharacterString";var Cc,Gr=class extends zr{constructor({value:t,valueDate:e,...n}={}){if(super(n),this.year=0,this.month=0,this.day=0,this.hour=0,this.minute=0,this.second=0,t){this.fromString(t),this.valueBlock.valueHexView=new Uint8Array(t.length);for(let s=0;s<t.length;s++)this.valueBlock.valueHexView[s]=t.charCodeAt(s)}e&&(this.fromDate(e),this.valueBlock.valueHexView=new Uint8Array(this.toBuffer())),this.idBlock.tagClass=1,this.idBlock.tagNumber=23}fromBuffer(t){this.fromString(String.fromCharCode.apply(null,M.BufferSourceConverter.toUint8Array(t)))}toBuffer(){let t=this.toString(),e=new ArrayBuffer(t.length),n=new Uint8Array(e);for(let s=0;s<t.length;s++)n[s]=t.charCodeAt(s);return e}fromDate(t){this.year=t.getUTCFullYear(),this.month=t.getUTCMonth()+1,this.day=t.getUTCDate(),this.hour=t.getUTCHours(),this.minute=t.getUTCMinutes(),this.second=t.getUTCSeconds()}toDate(){return new Date(Date.UTC(this.year,this.month-1,this.day,this.hour,this.minute,this.second))}fromString(t){let n=/(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})Z/ig.exec(t);if(n===null){this.error="Wrong input string for conversion";return}let s=parseInt(n[1],10);s>=50?this.year=1900+s:this.year=2e3+s,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(t="iso"){if(t==="iso"){let e=new Array(7);return e[0]=Ut(this.year<2e3?this.year-1900:this.year-2e3,2),e[1]=Ut(this.month,2),e[2]=Ut(this.day,2),e[3]=Ut(this.hour,2),e[4]=Ut(this.minute,2),e[5]=Ut(this.second,2),e[6]="Z",e.join("")}return super.toString(t)}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}}};Cc=Gr;A.UTCTime=Cc;Gr.NAME="UTCTime";var Tc,ds=class extends Gr{constructor(t={}){var e;super(t),(e=this.millisecond)!==null&&e!==void 0||(this.millisecond=0),this.idBlock.tagClass=1,this.idBlock.tagNumber=24}fromDate(t){super.fromDate(t),this.millisecond=t.getUTCMilliseconds()}toDate(){return new Date(Date.UTC(this.year,this.month-1,this.day,this.hour,this.minute,this.second,this.millisecond))}fromString(t){let e=!1,n="",s="",o=0,i,a=0,c=0;if(t[t.length-1]==="Z")n=t.substring(0,t.length-1),e=!0;else{let f=new Number(t[t.length-1]);if(isNaN(f.valueOf()))throw new Error("Wrong input string for conversion");n=t}if(e){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 f=1,h=n.indexOf("+"),g="";if(h===-1&&(h=n.indexOf("-"),f=-1),h!==-1){if(g=n.substring(h+1),n=n.substring(0,h),g.length!==2&&g.length!==4)throw new Error("Wrong input string for conversion");let m=parseInt(g.substring(0,2),10);if(isNaN(m.valueOf()))throw new Error("Wrong input string for conversion");if(a=f*m,g.length===4){if(m=parseInt(g.substring(2,4),10),isNaN(m.valueOf()))throw new Error("Wrong input string for conversion");c=f*m}}}let l=n.indexOf(".");if(l===-1&&(l=n.indexOf(",")),l!==-1){let f=new Number(`0${n.substring(l)}`);if(isNaN(f.valueOf()))throw new Error("Wrong input string for conversion");o=f.valueOf(),s=n.substring(0,l)}else s=n;switch(!0){case s.length===8:if(i=/(\d{4})(\d{2})(\d{2})/ig,l!==-1)throw new Error("Wrong input string for conversion");break;case s.length===10:if(i=/(\d{4})(\d{2})(\d{2})(\d{2})/ig,l!==-1){let f=60*o;this.minute=Math.floor(f),f=60*(f-this.minute),this.second=Math.floor(f),f=1e3*(f-this.second),this.millisecond=Math.floor(f)}break;case s.length===12:if(i=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})/ig,l!==-1){let f=60*o;this.second=Math.floor(f),f=1e3*(f-this.second),this.millisecond=Math.floor(f)}break;case s.length===14:if(i=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/ig,l!==-1){let f=1e3*o;this.millisecond=Math.floor(f)}break;default:throw new Error("Wrong input string for conversion")}let u=i.exec(s);if(u===null)throw new Error("Wrong input string for conversion");for(let f=1;f<u.length;f++)switch(f){case 1:this.year=parseInt(u[f],10);break;case 2:this.month=parseInt(u[f],10);break;case 3:this.day=parseInt(u[f],10);break;case 4:this.hour=parseInt(u[f],10)+a;break;case 5:this.minute=parseInt(u[f],10)+c;break;case 6:this.second=parseInt(u[f],10);break;default:throw new Error("Wrong input string for conversion")}if(e===!1){let f=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);this.year=f.getUTCFullYear(),this.month=f.getUTCMonth(),this.day=f.getUTCDay(),this.hour=f.getUTCHours(),this.minute=f.getUTCMinutes(),this.second=f.getUTCSeconds(),this.millisecond=f.getUTCMilliseconds()}}toString(t="iso"){if(t==="iso"){let e=[];return e.push(Ut(this.year,4)),e.push(Ut(this.month,2)),e.push(Ut(this.day,2)),e.push(Ut(this.hour,2)),e.push(Ut(this.minute,2)),e.push(Ut(this.second,2)),this.millisecond!==0&&(e.push("."),e.push(Ut(this.millisecond,3))),e.push("Z"),e.join("")}return super.toString(t)}toJSON(){return{...super.toJSON(),millisecond:this.millisecond}}};Tc=ds;A.GeneralizedTime=Tc;ds.NAME="GeneralizedTime";var Lc,ps=class extends ge{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=31}};Lc=ps;A.DATE=Lc;ps.NAME="DATE";var Uc,ms=class extends ge{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=32}};Uc=ms;A.TimeOfDay=Uc;ms.NAME="TimeOfDay";var Rc,gs=class extends ge{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=33}};Rc=gs;A.DateTime=Rc;gs.NAME="DateTime";var _c,ys=class extends ge{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=34}};_c=ys;A.Duration=_c;ys.NAME="Duration";var Pc,bs=class extends ge{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=14}};Pc=bs;A.TIME=Pc;bs.NAME="TIME";function et(r,t="utf8"){let e=Nn[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.encoder.encode(r).substring(1)}var Wr=class extends Error{constructor(t="An error occurred while verifying a message"){super(t),this.name="VerificationError"}},xs=class extends Error{constructor(t="Missing Web Crypto API"){super(t),this.name="WebCryptoMissingError"}};var Oc={get(r=globalThis){let t=r.crypto;if(t?.subtle==null)throw new xs("Missing Web Crypto API. The most likely cause of this error is that this page is being accessed from an insecure context (i.e. not HTTPS). For more information and possible resolutions see https://github.com/libp2p/js-libp2p/blob/main/packages/crypto/README.md#web-crypto-api");return t}};var Oe=Oc;async function Vc(r){let t=await Oe.get().subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:r,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-256"}},!0,["sign","verify"]),e=await Xh(t);return{privateKey:e[0],publicKey:e[1]}}async function Dc(r,t){let e=await Oe.get().subtle.importKey("jwk",r,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["sign"]),n=await Oe.get().subtle.sign({name:"RSASSA-PKCS1-v1_5"},e,t instanceof Uint8Array?t:t.subarray());return new Uint8Array(n,0,n.byteLength)}async function Mc(r,t,e){let n=await Oe.get().subtle.importKey("jwk",r,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["verify"]);return Oe.get().subtle.verify({name:"RSASSA-PKCS1-v1_5"},n,t,e instanceof Uint8Array?e:e.subarray())}async function Xh(r){if(r.privateKey==null||r.publicKey==null)throw new It("Private and public key are required");return Promise.all([Oe.get().subtle.exportKey("jwk",r.privateKey),Oe.get().subtle.exportKey("jwk",r.publicKey)])}function li(r){if(r.kty!=="RSA")throw new It("invalid key type");if(r.n==null)throw new It("invalid key modulus");return q(r.n,"base64url").length*8}var mr=class{type="RSA";_key;_raw;_multihash;constructor(t,e){this._key=t,this._multihash=e}get raw(){return this._raw==null&&(this._raw=jr.jwkToPkix(this._key)),this._raw}toMultihash(){return this._multihash}toCID(){return pt.createV1(114,this._multihash)}toString(){return X.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:bt(this.raw,t.raw)}verify(t,e){return Mc(this._key,e,t)}},Zr=class{type="RSA";_key;_raw;publicKey;constructor(t,e){this._key=t,this.publicKey=e}get raw(){return this._raw==null&&(this._raw=jr.jwkToPkcs1(this._key)),this._raw}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:bt(this.raw,t.raw)}sign(t){return Dc(this._key,t)}};var vs=8192,ui=18;function Fc(r){let{result:t}=ci(r),e=t.valueBlock.value;return{n:te(e[1]),e:te(e[2]),d:te(e[3]),p:te(e[4]),q:te(e[5]),dp:te(e[6]),dq:te(e[7]),qi:te(e[8]),kty:"RSA",alg:"RS256"}}function Qh(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 It("JWK was missing components");let e=new me({value:[new yt({value:0}),yt.fromBigInt(ee(q(r.n,"base64url"))),yt.fromBigInt(ee(q(r.e,"base64url"))),yt.fromBigInt(ee(q(r.d,"base64url"))),yt.fromBigInt(ee(q(r.p,"base64url"))),yt.fromBigInt(ee(q(r.q,"base64url"))),yt.fromBigInt(ee(q(r.dp,"base64url"))),yt.fromBigInt(ee(q(r.dq,"base64url"))),yt.fromBigInt(ee(q(r.qi,"base64url")))]}).toBER();return new Uint8Array(e,0,e.byteLength)}function Hc(r){let{result:t}=ci(r),e=t.valueBlock.value[1].valueBlock.value[0].valueBlock.value;return{kty:"RSA",n:te(e[0]),e:te(e[1])}}function fi(r){if(r.n==null||r.e==null)throw new It("JWK was missing components");let e=new me({value:[new me({value:[new dr({value:"1.2.840.113549.1.1.1"}),new fr]}),new hr({valueHex:new me({value:[yt.fromBigInt(ee(q(r.n,"base64url"))),yt.fromBigInt(ee(q(r.e,"base64url")))]}).toBER()})]}).toBER();return new Uint8Array(e,0,e.byteLength)}function te(r){let t=r.valueBlock.valueHexView;for(;t[0]===0;)t=t.subarray(1);return et(t,"base64url")}function ee(r){let t=[];return r.forEach(function(e){let n=e.toString(16);n.length%2>0&&(n=`0${n}`),t.push(n)}),BigInt("0x"+t.join(""))}function Kc(r){let t=Fc(r);return $c(t)}function hi(r){let t=Hc(r);if(li(t)>vs)throw new Xe("Key size is too large");let e=lr(Xt.encode({Type:lt.RSA,Data:r})),n=Mt(ui,e);return new mr(t,n)}function $c(r){if(li(r)>vs)throw new It("Key size is too large");let t=zc(r),e=lr(Xt.encode({Type:lt.RSA,Data:fi(t.publicKey)})),n=Mt(ui,e);return new Zr(t.privateKey,new mr(t.publicKey,n))}async function qc(r){if(r>vs)throw new It("Key size is too large");let t=await Vc(r),e=lr(Xt.encode({Type:lt.RSA,Data:fi(t.publicKey)})),n=Mt(ui,e);return new Zr(t.privateKey,new mr(t.publicKey,n))}function zc(r){if(r==null)throw new It("Missing key parameter");return{privateKey:r,publicKey:{kty:r.kty,n:r.n,e:r.e}}}var Es=class extends or{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,pa(t);let n=Lr(e);if(this.iHash=t.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let s=this.blockLen,o=new Uint8Array(s);o.set(n.length>s?t.create().update(n).digest():n);for(let i=0;i<o.length;i++)o[i]^=54;this.iHash.update(o),this.oHash=t.create();for(let i=0;i<o.length;i++)o[i]^=106;this.oHash.update(o),o.fill(0)}update(t){return sr(this),this.iHash.update(t),this}digestInto(t){sr(this),nr(t,this.outputLen),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){let t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));let{oHash:e,iHash:n,finished:s,destroyed:o,blockLen:i,outputLen:a}=this;return t=t,t.finished=s,t.destroyed=o,t.blockLen=i,t.outputLen=a,t.oHash=e._cloneInto(t.oHash),t.iHash=n._cloneInto(t.iHash),t}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},di=(r,t,e)=>new Es(r,t).update(e).digest();di.create=(r,t)=>new Es(r,t);function Gc(r){r.lowS!==void 0&&Ht("lowS",r.lowS),r.prehash!==void 0&&Ht("prehash",r.prehash)}function td(r){let t=_r(r);Jt(t,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});let{endo:e,Fp:n,a:s}=t;if(e){if(!n.eql(s,n.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if(typeof e!="object"||typeof e.beta!="bigint"||typeof e.splitScalar!="function")throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...t})}var{bytesToNumberBE:ed,hexToBytes:rd}=wn,we={Err:class extends Error{constructor(t=""){super(t)}},_tlv:{encode:(r,t)=>{let{Err:e}=we;if(r<0||r>256)throw new e("tlv.encode: wrong tag");if(t.length&1)throw new e("tlv.encode: unpadded data");let n=t.length/2,s=He(n);if(s.length/2&128)throw new e("tlv.encode: long form length too big");let o=n>127?He(s.length/2|128):"";return`${He(r)}${o}${s}${t}`},decode(r,t){let{Err:e}=we,n=0;if(r<0||r>256)throw new e("tlv.encode: wrong tag");if(t.length<2||t[n++]!==r)throw new e("tlv.decode: wrong tlv");let s=t[n++],o=!!(s&128),i=0;if(!o)i=s;else{let c=s&127;if(!c)throw new e("tlv.decode(long): indefinite length not supported");if(c>4)throw new e("tlv.decode(long): byte length is too big");let l=t.subarray(n,n+c);if(l.length!==c)throw new e("tlv.decode: length bytes not complete");if(l[0]===0)throw new e("tlv.decode(long): zero leftmost byte");for(let u of l)i=i<<8|u;if(n+=c,i<128)throw new e("tlv.decode(long): not minimal encoding")}let a=t.subarray(n,n+i);if(a.length!==i)throw new e("tlv.decode: wrong value length");return{v:a,l:t.subarray(n+i)}}},_int:{encode(r){let{Err:t}=we;if(r<xe)throw new t("integer: negative integers are not allowed");let e=He(r);if(Number.parseInt(e[0],16)&8&&(e="00"+e),e.length&1)throw new t("unexpected assertion");return e},decode(r){let{Err:t}=we;if(r[0]&128)throw new t("Invalid signature integer: negative");if(r[0]===0&&!(r[1]&128))throw new t("Invalid signature integer: unnecessary leading zero");return ed(r)}},toSig(r){let{Err:t,_int:e,_tlv:n}=we,s=typeof r=="string"?rd(r):r;ar(s);let{v:o,l:i}=n.decode(48,s);if(i.length)throw new t("Invalid signature: left bytes after parsing");let{v:a,l:c}=n.decode(2,o),{v:l,l:u}=n.decode(2,c);if(u.length)throw new t("Invalid signature: left bytes after parsing");return{r:e.decode(a),s:e.decode(l)}},hexFromSig(r){let{_tlv:t,_int:e}=we,n=`${t.encode(2,e.encode(r.r))}${t.encode(2,e.encode(r.s))}`;return t.encode(48,n)}},xe=BigInt(0),ht=BigInt(1),Ug=BigInt(2),Wc=BigInt(3),Rg=BigInt(4);function nd(r){let t=td(r),{Fp:e}=t,n=Ce(t.n,t.nBitLength),s=t.toBytes||((b,d,x)=>{let B=d.toAffine();return fe(Uint8Array.from([4]),e.toBytes(B.x),e.toBytes(B.y))}),o=t.fromBytes||(b=>{let d=b.subarray(1),x=e.fromBytes(d.subarray(0,e.BYTES)),B=e.fromBytes(d.subarray(e.BYTES,2*e.BYTES));return{x,y:B}});function i(b){let{a:d,b:x}=t,B=e.sqr(b),y=e.mul(B,b);return e.add(e.add(y,e.mul(b,d)),x)}if(!e.eql(e.sqr(t.Gy),i(t.Gx)))throw new Error("bad generator point: equation left != right");function a(b){return Ur(b,ht,t.n)}function c(b){let{allowedPrivateKeyLengths:d,nByteLength:x,wrapPrivateKey:B,n:y}=t;if(d&&typeof b!="bigint"){if(Ie(b)&&(b=le(b)),typeof b!="string"||!d.includes(b.length))throw new Error("Invalid key");b=b.padStart(x*2,"0")}let S;try{S=typeof b=="bigint"?b:ue(st("private key",b,x))}catch{throw new Error(`private key must be ${x} bytes, hex or bigint, not ${typeof b}`)}return B&&(S=Z(S,y)),Ct("private key",S,ht,y),S}function l(b){if(!(b instanceof h))throw new Error("ProjectivePoint expected")}let u=qe((b,d)=>{let{px:x,py:B,pz:y}=b;if(e.eql(y,e.ONE))return{x,y:B};let S=b.is0();d==null&&(d=S?e.ONE:e.inv(y));let U=e.mul(x,d),L=e.mul(B,d),I=e.mul(y,d);if(S)return{x:e.ZERO,y:e.ZERO};if(!e.eql(I,e.ONE))throw new Error("invZ was invalid");return{x:U,y:L}}),f=qe(b=>{if(b.is0()){if(t.allowInfinityPoint&&!e.is0(b.py))return;throw new Error("bad point: ZERO")}let{x:d,y:x}=b.toAffine();if(!e.isValid(d)||!e.isValid(x))throw new Error("bad point: x or y not FE");let B=e.sqr(x),y=i(d);if(!e.eql(B,y))throw new Error("bad point: equation left != right");if(!b.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class h{constructor(d,x,B){if(this.px=d,this.py=x,this.pz=B,d==null||!e.isValid(d))throw new Error("x required");if(x==null||!e.isValid(x))throw new Error("y required");if(B==null||!e.isValid(B))throw new Error("z required");Object.freeze(this)}static fromAffine(d){let{x,y:B}=d||{};if(!d||!e.isValid(x)||!e.isValid(B))throw new Error("invalid affine point");if(d instanceof h)throw new Error("projective point not allowed");let y=S=>e.eql(S,e.ZERO);return y(x)&&y(B)?h.ZERO:new h(x,B,e.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(d){let x=e.invertBatch(d.map(B=>B.pz));return d.map((B,y)=>B.toAffine(x[y])).map(h.fromAffine)}static fromHex(d){let x=h.fromAffine(o(st("pointHex",d)));return x.assertValidity(),x}static fromPrivateKey(d){return h.BASE.multiply(c(d))}static msm(d,x){return En(h,n,d,x)}_setWindowSize(d){m.setWindowSize(this,d)}assertValidity(){f(this)}hasEvenY(){let{y:d}=this.toAffine();if(e.isOdd)return!e.isOdd(d);throw new Error("Field doesn't support isOdd")}equals(d){l(d);let{px:x,py:B,pz:y}=this,{px:S,py:U,pz:L}=d,I=e.eql(e.mul(x,L),e.mul(S,y)),k=e.eql(e.mul(B,L),e.mul(U,y));return I&&k}negate(){return new h(this.px,e.neg(this.py),this.pz)}double(){let{a:d,b:x}=t,B=e.mul(x,Wc),{px:y,py:S,pz:U}=this,L=e.ZERO,I=e.ZERO,k=e.ZERO,T=e.mul(y,y),ot=e.mul(S,S),$=e.mul(U,U),O=e.mul(y,S);return O=e.add(O,O),k=e.mul(y,U),k=e.add(k,k),L=e.mul(d,k),I=e.mul(B,$),I=e.add(L,I),L=e.sub(ot,I),I=e.add(ot,I),I=e.mul(L,I),L=e.mul(O,L),k=e.mul(B,k),$=e.mul(d,$),O=e.sub(T,$),O=e.mul(d,O),O=e.add(O,k),k=e.add(T,T),T=e.add(k,T),T=e.add(T,$),T=e.mul(T,O),I=e.add(I,T),$=e.mul(S,U),$=e.add($,$),T=e.mul($,O),L=e.sub(L,T),k=e.mul($,ot),k=e.add(k,k),k=e.add(k,k),new h(L,I,k)}add(d){l(d);let{px:x,py:B,pz:y}=this,{px:S,py:U,pz:L}=d,I=e.ZERO,k=e.ZERO,T=e.ZERO,ot=t.a,$=e.mul(t.b,Wc),O=e.mul(x,S),it=e.mul(B,U),E=e.mul(y,L),N=e.add(x,B),w=e.add(S,U);N=e.mul(N,w),w=e.add(O,it),N=e.sub(N,w),w=e.add(x,y);let p=e.add(S,L);return w=e.mul(w,p),p=e.add(O,E),w=e.sub(w,p),p=e.add(B,y),I=e.add(U,L),p=e.mul(p,I),I=e.add(it,E),p=e.sub(p,I),T=e.mul(ot,w),I=e.mul($,E),T=e.add(I,T),I=e.sub(it,T),T=e.add(it,T),k=e.mul(I,T),it=e.add(O,O),it=e.add(it,O),E=e.mul(ot,E),w=e.mul($,w),it=e.add(it,E),E=e.sub(O,E),E=e.mul(ot,E),w=e.add(w,E),O=e.mul(it,w),k=e.add(k,O),O=e.mul(p,w),I=e.mul(N,I),I=e.sub(I,O),O=e.mul(N,it),T=e.mul(p,T),T=e.add(T,O),new h(I,k,T)}subtract(d){return this.add(d.negate())}is0(){return this.equals(h.ZERO)}wNAF(d){return m.wNAFCached(this,d,h.normalizeZ)}multiplyUnsafe(d){Ct("scalar",d,xe,t.n);let x=h.ZERO;if(d===xe)return x;if(d===ht)return this;let{endo:B}=t;if(!B)return m.unsafeLadder(this,d);let{k1neg:y,k1:S,k2neg:U,k2:L}=B.splitScalar(d),I=x,k=x,T=this;for(;S>xe||L>xe;)S&ht&&(I=I.add(T)),L&ht&&(k=k.add(T)),T=T.double(),S>>=ht,L>>=ht;return y&&(I=I.negate()),U&&(k=k.negate()),k=new h(e.mul(k.px,B.beta),k.py,k.pz),I.add(k)}multiply(d){let{endo:x,n:B}=t;Ct("scalar",d,ht,B);let y,S;if(x){let{k1neg:U,k1:L,k2neg:I,k2:k}=x.splitScalar(d),{p:T,f:ot}=this.wNAF(L),{p:$,f:O}=this.wNAF(k);T=m.constTimeNegate(U,T),$=m.constTimeNegate(I,$),$=new h(e.mul($.px,x.beta),$.py,$.pz),y=T.add($),S=ot.add(O)}else{let{p:U,f:L}=this.wNAF(d);y=U,S=L}return h.normalizeZ([y,S])[0]}multiplyAndAddUnsafe(d,x,B){let y=h.BASE,S=(L,I)=>I===xe||I===ht||!L.equals(y)?L.multiplyUnsafe(I):L.multiply(I),U=S(this,x).add(S(d,B));return U.is0()?void 0:U}toAffine(d){return u(this,d)}isTorsionFree(){let{h:d,isTorsionFree:x}=t;if(d===ht)return!0;if(x)return x(h,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h:d,clearCofactor:x}=t;return d===ht?this:x?x(h,this):this.multiplyUnsafe(t.h)}toRawBytes(d=!0){return Ht("isCompressed",d),this.assertValidity(),s(h,this,d)}toHex(d=!0){return Ht("isCompressed",d),le(this.toRawBytes(d))}}h.BASE=new h(t.Gx,t.Gy,e.ONE),h.ZERO=new h(e.ZERO,e.ONE,e.ZERO);let g=t.nBitLength,m=vn(h,t.endo?Math.ceil(g/2):g);return{CURVE:t,ProjectivePoint:h,normPrivateKeyToScalar:c,weierstrassEquation:i,isWithinCurveOrder:a}}function sd(r){let t=_r(r);return Jt(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}function jc(r){let t=sd(r),{Fp:e,n}=t,s=e.BYTES+1,o=2*e.BYTES+1;function i(E){return Z(E,n)}function a(E){return xn(E,n)}let{ProjectivePoint:c,normPrivateKeyToScalar:l,weierstrassEquation:u,isWithinCurveOrder:f}=nd({...t,toBytes(E,N,w){let p=N.toAffine(),v=e.toBytes(p.x),C=fe;return Ht("isCompressed",w),w?C(Uint8Array.from([N.hasEvenY()?2:3]),v):C(Uint8Array.from([4]),v,e.toBytes(p.y))},fromBytes(E){let N=E.length,w=E[0],p=E.subarray(1);if(N===s&&(w===2||w===3)){let v=ue(p);if(!Ur(v,ht,e.ORDER))throw new Error("Point is not on curve");let C=u(v),R;try{R=e.sqrt(C)}catch(F){let D=F instanceof Error?": "+F.message:"";throw new Error("Point is not on curve"+D)}let _=(R&ht)===ht;return(w&1)===1!==_&&(R=e.neg(R)),{x:v,y:R}}else if(N===o&&w===4){let v=e.fromBytes(p.subarray(0,e.BYTES)),C=e.fromBytes(p.subarray(e.BYTES,2*e.BYTES));return{x:v,y:C}}else throw new Error(`Point of length ${N} was invalid. Expected ${s} compressed bytes or ${o} uncompressed bytes`)}}),h=E=>le(Ne(E,t.nByteLength));function g(E){let N=n>>ht;return E>N}function m(E){return g(E)?i(-E):E}let b=(E,N,w)=>ue(E.slice(N,w));class d{constructor(N,w,p){this.r=N,this.s=w,this.recovery=p,this.assertValidity()}static fromCompact(N){let w=t.nByteLength;return N=st("compactSignature",N,w*2),new d(b(N,0,w),b(N,w,2*w))}static fromDER(N){let{r:w,s:p}=we.toSig(st("DER",N));return new d(w,p)}assertValidity(){Ct("r",this.r,ht,n),Ct("s",this.s,ht,n)}addRecoveryBit(N){return new d(this.r,this.s,N)}recoverPublicKey(N){let{r:w,s:p,recovery:v}=this,C=L(st("msgHash",N));if(v==null||![0,1,2,3].includes(v))throw new Error("recovery id invalid");let R=v===2||v===3?w+t.n:w;if(R>=e.ORDER)throw new Error("recovery id 2 or 3 invalid");let _=v&1?"03":"02",V=c.fromHex(_+h(R)),F=a(R),D=i(-C*F),j=i(p*F),J=c.BASE.multiplyAndAddUnsafe(V,D,j);if(!J)throw new Error("point at infinify");return J.assertValidity(),J}hasHighS(){return g(this.s)}normalizeS(){return this.hasHighS()?new d(this.r,i(-this.s),this.recovery):this}toDERRawBytes(){return Ke(this.toDERHex())}toDERHex(){return we.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Ke(this.toCompactHex())}toCompactHex(){return h(this.r)+h(this.s)}}let x={isValidPrivateKey(E){try{return l(E),!0}catch{return!1}},normPrivateKeyToScalar:l,randomPrivateKey:()=>{let E=wo(t.n);return ka(t.randomBytes(E),t.n)},precompute(E=8,N=c.BASE){return N._setWindowSize(E),N.multiply(BigInt(3)),N}};function B(E,N=!0){return c.fromPrivateKey(E).toRawBytes(N)}function y(E){let N=Ie(E),w=typeof E=="string",p=(N||w)&&E.length;return N?p===s||p===o:w?p===2*s||p===2*o:E instanceof c}function S(E,N,w=!0){if(y(E))throw new Error("first arg must be private key");if(!y(N))throw new Error("second arg must be public key");return c.fromHex(N).multiply(l(E)).toRawBytes(w)}let U=t.bits2int||function(E){let N=ue(E),w=E.length*8-t.nBitLength;return w>0?N>>BigInt(w):N},L=t.bits2int_modN||function(E){return i(U(E))},I=Rr(t.nBitLength);function k(E){return Ct(`num < 2^${t.nBitLength}`,E,xe,I),Ne(E,t.nByteLength)}function T(E,N,w=ot){if(["recovered","canonical"].some(ft=>ft in w))throw new Error("sign() legacy options not supported");let{hash:p,randomBytes:v}=t,{lowS:C,prehash:R,extraEntropy:_}=w;C==null&&(C=!0),E=st("msgHash",E),Gc(w),R&&(E=st("prehashed msgHash",p(E)));let V=L(E),F=l(N),D=[k(F),k(V)];if(_!=null&&_!==!1){let ft=_===!0?v(e.BYTES):_;D.push(st("extraEntropy",ft))}let j=fe(...D),J=V;function ut(ft){let dt=U(ft);if(!f(dt))return;let At=a(dt),at=c.BASE.multiply(dt).toAffine(),Nt=i(at.x);if(Nt===xe)return;let se=i(At*i(J+Nt*F));if(se===xe)return;let Ar=(at.x===Nt?0:2)|Number(at.y&ht),Sr=se;return C&&g(se)&&(Sr=m(se),Ar^=1),new d(Nt,Sr,Ar)}return{seed:j,k2sig:ut}}let ot={lowS:t.lowS,prehash:!1},$={lowS:t.lowS,prehash:!1};function O(E,N,w=ot){let{seed:p,k2sig:v}=T(E,N,w),C=t;return mo(C.hash.outputLen,C.nByteLength,C.hmac)(p,v)}c.BASE._setWindowSize(8);function it(E,N,w,p=$){let v=E;if(N=st("msgHash",N),w=st("publicKey",w),"strict"in p)throw new Error("options.strict was renamed to lowS");Gc(p);let{lowS:C,prehash:R}=p,_,V;try{if(typeof v=="string"||Ie(v))try{_=d.fromDER(v)}catch(at){if(!(at instanceof we.Err))throw at;_=d.fromCompact(v)}else if(typeof v=="object"&&typeof v.r=="bigint"&&typeof v.s=="bigint"){let{r:at,s:Nt}=v;_=new d(at,Nt)}else throw new Error("PARSE");V=c.fromHex(w)}catch(at){if(at.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(C&&_.hasHighS())return!1;R&&(N=t.hash(N));let{r:F,s:D}=_,j=L(N),J=a(D),ut=i(j*J),ft=i(F*J),dt=c.BASE.multiplyAndAddUnsafe(V,ut,ft)?.toAffine();return dt?i(dt.x)===F:!1}return{CURVE:t,getPublicKey:B,getSharedSecret:S,sign:O,verify:it,ProjectivePoint:c,Signature:d,utils:x}}function od(r){return{hash:r,hmac:(t,...e)=>di(r,t,io(...e)),randomBytes:gn}}function Zc(r,t){let e=n=>jc({...r,...od(n)});return Object.freeze({...e(t),create:e})}var Xc=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),Yc=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),id=BigInt(1),pi=BigInt(2),Jc=(r,t)=>(r+t/pi)/t;function ad(r){let t=Xc,e=BigInt(3),n=BigInt(6),s=BigInt(11),o=BigInt(22),i=BigInt(23),a=BigInt(44),c=BigInt(88),l=r*r*r%t,u=l*l*r%t,f=tt(u,e,t)*u%t,h=tt(f,e,t)*u%t,g=tt(h,pi,t)*l%t,m=tt(g,s,t)*g%t,b=tt(m,o,t)*m%t,d=tt(b,a,t)*b%t,x=tt(d,c,t)*d%t,B=tt(x,a,t)*b%t,y=tt(B,e,t)*u%t,S=tt(y,i,t)*m%t,U=tt(S,n,t)*l%t,L=tt(U,pi,t);if(!mi.eql(mi.sqr(L),r))throw new Error("Cannot find square root");return L}var mi=Ce(Xc,void 0,void 0,{sqrt:ad}),Ye=Zc({a:BigInt(0),b:BigInt(7),Fp:mi,n:Yc,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:r=>{let t=Yc,e=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-id*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),s=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),o=e,i=BigInt("0x100000000000000000000000000000000"),a=Jc(o*r,t),c=Jc(-n*r,t),l=Z(r-a*e-c*s,t),u=Z(-a*n-c*o,t),f=l>i,h=u>i;if(f&&(l=t-l),h&&(u=t-u),l>i||u>i)throw new Error("splitScalar: Endomorphism failed, k="+r);return{k1neg:f,k1:l,k2neg:h,k2:u}}}},lr),Kg=BigInt(0);var $g=Ye.ProjectivePoint;function Pt(r,t){t==null&&(t=r.reduce((s,o)=>s+o.length,0));let e=Lt(t),n=0;for(let s of r)e.set(s,n),n+=s.length;return e}function Qc(r){return r==null?!1:typeof r.then=="function"&&typeof r.catch=="function"&&typeof r.finally=="function"}function tl(r,t,e){let n=Pr.digest(e instanceof Uint8Array?e:e.subarray());if(Qc(n))return n.then(({digest:s})=>Ye.verify(t,s,r)).catch(s=>{throw new Wr(String(s))});try{return Ye.verify(t,n.digest,r)}catch(s){throw new Wr(String(s))}}var Bs=class{type="secp256k1";raw;_key;constructor(t){this._key=rl(t),this.raw=el(this._key)}toMultihash(){return ae.digest(Te(this))}toCID(){return pt.createV1(114,this.toMultihash())}toString(){return X.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:bt(this.raw,t.raw)}verify(t,e){return tl(this._key,e,t)}};function gi(r){return new Bs(r)}function el(r){return Ye.ProjectivePoint.fromHex(r).toRawBytes(!0)}function rl(r){try{return Ye.ProjectivePoint.fromHex(r),r}catch(t){throw new Xe(String(t))}}function gr(r){let{Type:t,Data:e}=Xt.decode(r),n=e??new Uint8Array;switch(t){case lt.RSA:return hi(n);case lt.Ed25519:return Ao(n);case lt.secp256k1:return gi(n);default:throw new De}}function nl(r){let{Type:t,Data:e}=Xt.decode(r.digest),n=e??new Uint8Array;switch(t){case lt.Ed25519:return Ao(n);case lt.secp256k1:return gi(n);default:throw new De}}function Te(r){return Xt.encode({Type:lt[r.type],Data:r.raw})}var ol=Symbol.for("@achingbrain/uint8arraylist");function sl(r,t){if(t==null||t<0)throw new RangeError("index is out of bounds");let e=0;for(let n of r){let s=e+n.byteLength;if(t<s)return{buf:n,index:t-e};e=s}throw new RangeError("index is out of bounds")}function As(r){return!!r?.[ol]}var jt=class r{bufs;length;[ol]=!0;constructor(...t){this.bufs=[],this.length=0,t.length>0&&this.appendAll(t)}*[Symbol.iterator](){yield*this.bufs}get byteLength(){return this.length}append(...t){this.appendAll(t)}appendAll(t){let e=0;for(let n of t)if(n instanceof Uint8Array)e+=n.byteLength,this.bufs.push(n);else if(As(n))e+=n.byteLength,this.bufs.push(...n.bufs);else throw new Error("Could not append value, must be an Uint8Array or a Uint8ArrayList");this.length+=e}prepend(...t){this.prependAll(t)}prependAll(t){let e=0;for(let n of t.reverse())if(n instanceof Uint8Array)e+=n.byteLength,this.bufs.unshift(n);else if(As(n))e+=n.byteLength,this.bufs.unshift(...n.bufs);else throw new Error("Could not prepend value, must be an Uint8Array or a Uint8ArrayList");this.length+=e}get(t){let e=sl(this.bufs,t);return e.buf[e.index]}set(t,e){let n=sl(this.bufs,t);n.buf[n.index]=e}write(t,e=0){if(t instanceof Uint8Array)for(let n=0;n<t.length;n++)this.set(e+n,t[n]);else if(As(t))for(let n=0;n<t.length;n++)this.set(e+n,t.get(n));else throw new Error("Could not write value, must be an Uint8Array or a Uint8ArrayList")}consume(t){if(t=Math.trunc(t),!(Number.isNaN(t)||t<=0)){if(t===this.byteLength){this.bufs=[],this.length=0;return}for(;this.bufs.length>0;)if(t>=this.bufs[0].byteLength)t-=this.bufs[0].byteLength,this.length-=this.bufs[0].byteLength,this.bufs.shift();else{this.bufs[0]=this.bufs[0].subarray(t),this.length-=t;break}}}slice(t,e){let{bufs:n,length:s}=this._subList(t,e);return Pt(n,s)}subarray(t,e){let{bufs:n,length:s}=this._subList(t,e);return n.length===1?n[0]:Pt(n,s)}sublist(t,e){let{bufs:n,length:s}=this._subList(t,e),o=new r;return o.length=s,o.bufs=[...n],o}_subList(t,e){if(t=t??0,e=e??this.length,t<0&&(t=this.length+t),e<0&&(e=this.length+e),t<0||e>this.length)throw new RangeError("index is out of bounds");if(t===e)return{bufs:[],length:0};if(t===0&&e===this.length)return{bufs:this.bufs,length:this.length};let n=[],s=0;for(let o=0;o<this.bufs.length;o++){let i=this.bufs[o],a=s,c=a+i.byteLength;if(s=c,t>=c)continue;let l=t>=a&&t<c,u=e>a&&e<=c;if(l&&u){if(t===a&&e===c){n.push(i);break}let f=t-a;n.push(i.subarray(f,f+(e-t)));break}if(l){if(t===0){n.push(i);continue}n.push(i.subarray(t-a));continue}if(u){if(e===c){n.push(i);break}n.push(i.subarray(0,e-a));break}n.push(i)}return{bufs:n,length:e-t}}indexOf(t,e=0){if(!As(t)&&!(t instanceof Uint8Array))throw new TypeError('The "value" argument must be a Uint8ArrayList or Uint8Array');let n=t instanceof Uint8Array?t:t.subarray();if(e=Number(e??0),isNaN(e)&&(e=0),e<0&&(e=this.length+e),e<0&&(e=0),t.length===0)return e>this.length?this.length:e;let s=n.byteLength;if(s===0)throw new TypeError("search must be at least 1 byte long");let o=256,i=new Int32Array(o);for(let f=0;f<o;f++)i[f]=-1;for(let f=0;f<s;f++)i[n[f]]=f;let a=i,c=this.byteLength-n.byteLength,l=n.byteLength-1,u;for(let f=e;f<=c;f+=u){u=0;for(let h=l;h>=0;h--){let g=this.get(f+h);if(n[h]!==g){u=Math.max(1,h-a[g]);break}}if(u===0)return f}return-1}getInt8(t){let e=this.subarray(t,t+1);return new DataView(e.buffer,e.byteOffset,e.byteLength).getInt8(0)}setInt8(t,e){let n=Lt(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setInt8(0,e),this.write(n,t)}getInt16(t,e){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt16(0,e)}setInt16(t,e,n){let s=mt(2);new DataView(s.buffer,s.byteOffset,s.byteLength).setInt16(0,e,n),this.write(s,t)}getInt32(t,e){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt32(0,e)}setInt32(t,e,n){let s=mt(4);new DataView(s.buffer,s.byteOffset,s.byteLength).setInt32(0,e,n),this.write(s,t)}getBigInt64(t,e){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigInt64(0,e)}setBigInt64(t,e,n){let s=mt(8);new DataView(s.buffer,s.byteOffset,s.byteLength).setBigInt64(0,e,n),this.write(s,t)}getUint8(t){let e=this.subarray(t,t+1);return new DataView(e.buffer,e.byteOffset,e.byteLength).getUint8(0)}setUint8(t,e){let n=Lt(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setUint8(0,e),this.write(n,t)}getUint16(t,e){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint16(0,e)}setUint16(t,e,n){let s=mt(2);new DataView(s.buffer,s.byteOffset,s.byteLength).setUint16(0,e,n),this.write(s,t)}getUint32(t,e){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint32(0,e)}setUint32(t,e,n){let s=mt(4);new DataView(s.buffer,s.byteOffset,s.byteLength).setUint32(0,e,n),this.write(s,t)}getBigUint64(t,e){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigUint64(0,e)}setBigUint64(t,e,n){let s=mt(8);new DataView(s.buffer,s.byteOffset,s.byteLength).setBigUint64(0,e,n),this.write(s,t)}getFloat32(t,e){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat32(0,e)}setFloat32(t,e,n){let s=mt(4);new DataView(s.buffer,s.byteOffset,s.byteLength).setFloat32(0,e,n),this.write(s,t)}getFloat64(t,e){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat64(0,e)}setFloat64(t,e,n){let s=mt(8);new DataView(s.buffer,s.byteOffset,s.byteLength).setFloat64(0,e,n),this.write(s,t)}equals(t){if(t==null||!(t instanceof r)||t.bufs.length!==this.bufs.length)return!1;for(let e=0;e<this.bufs.length;e++)if(!bt(this.bufs[e],t.bufs[e]))return!1;return!0}static fromUint8Arrays(t,e){let n=new r;return n.bufs=t,e==null&&(e=t.reduce((s,o)=>s+o.byteLength,0)),n.length=e,n}};var Yr;(function(r){let t;r.codec=()=>(t==null&&(t=Gt((e,n,s={})=>{s.lengthDelimited!==!1&&n.fork(),e.publicKey!=null&&e.publicKey.byteLength>0&&(n.uint32(10),n.bytes(e.publicKey)),e.payloadType!=null&&e.payloadType.byteLength>0&&(n.uint32(18),n.bytes(e.payloadType)),e.payload!=null&&e.payload.byteLength>0&&(n.uint32(26),n.bytes(e.payload)),e.signature!=null&&e.signature.byteLength>0&&(n.uint32(42),n.bytes(e.signature)),s.lengthDelimited!==!1&&n.ldelim()},(e,n,s={})=>{let o={publicKey:mt(0),payloadType:mt(0),payload:mt(0),signature:mt(0)},i=n==null?e.len:e.pos+n;for(;e.pos<i;){let a=e.uint32();switch(a>>>3){case 1:{o.publicKey=e.bytes();break}case 2:{o.payloadType=e.bytes();break}case 3:{o.payload=e.bytes();break}case 5:{o.signature=e.bytes();break}default:{e.skipType(a&7);break}}}return o})),t),r.encode=e=>zt(e,r.codec()),r.decode=(e,n)=>qt(e,r.codec(),n)})(Yr||(Yr={}));var Ss=class extends Error{constructor(t="Invalid signature"){super(t),this.name="InvalidSignatureError"}};var re=class r{static createFromProtobuf=async t=>{let e=Yr.decode(t),n=gr(e.publicKey);return new r({publicKey:n,payloadType:e.payloadType,payload:e.payload,signature:e.signature})};static seal=async(t,e)=>{if(e==null)throw new Error("Missing private key");let n=t.domain,s=t.codec,o=t.marshal(),i=il(n,s,o),a=await e.sign(i.subarray());return new r({publicKey:e.publicKey,payloadType:s,payload:o,signature:a})};static openAndCertify=async(t,e)=>{let n=await r.createFromProtobuf(t);if(!await n.validate(e))throw new Ss("Envelope signature is not valid for the given domain");return n};publicKey;payloadType;payload;signature;marshaled;constructor(t){let{publicKey:e,payloadType:n,payload:s,signature:o}=t;this.publicKey=e,this.payloadType=n,this.payload=s,this.signature=o}marshal(){return this.marshaled==null&&(this.marshaled=Yr.encode({publicKey:Te(this.publicKey),payloadType:this.payloadType,payload:this.payload.subarray(),signature:this.signature})),this.marshaled}equals(t){return bt(this.marshal(),t.marshal())}async validate(t){let e=il(t,this.payloadType,this.payload);return this.publicKey.verify(e.subarray(),this.signature)}},il=(r,t,e)=>{let n=q(r),s=Ot(n.byteLength),o=Ot(t.length),i=Ot(e.length);return new jt(s,n,o,t,i,e)};var al=Symbol.for("nodejs.util.inspect.custom"),cd=114,Jr=class{type;multihash;publicKey;string;constructor(t){this.type=t.type,this.multihash=t.multihash,Object.defineProperty(this,"string",{enumerable:!1,writable:!0})}get[Symbol.toStringTag](){return`PeerId(${this.toString()})`}[Zs]=!0;toString(){return this.string==null&&(this.string=X.encode(this.multihash.bytes).slice(1)),this.string}toMultihash(){return this.multihash}toCID(){return pt.createV1(cd,this.multihash)}toJSON(){return this.toString()}equals(t){if(t==null)return!1;if(t instanceof Uint8Array)return bt(this.multihash.bytes,t);if(typeof t=="string")return this.toString()===t;if(t?.toMultihash()?.bytes!=null)return bt(this.multihash.bytes,t.toMultihash().bytes);throw new Error("not valid Id")}[al](){return`PeerId(${this.toString()})`}},Xr=class extends Jr{type="RSA";publicKey;constructor(t){super({...t,type:"RSA"}),this.publicKey=t.publicKey}},Qr=class extends Jr{type="Ed25519";publicKey;constructor(t){super({...t,type:"Ed25519"}),this.publicKey=t.publicKey}},tn=class extends Jr{type="secp256k1";publicKey;constructor(t){super({...t,type:"secp256k1"}),this.publicKey=t.publicKey}},ld=2336,en=class{type="url";multihash;publicKey;url;constructor(t){this.url=t.toString(),this.multihash=ae.digest(q(this.url))}[al](){return`PeerId(${this.url})`}[Zs]=!0;toString(){return this.toCID().toString()}toMultihash(){return this.multihash}toCID(){return pt.createV1(ld,this.toMultihash())}toJSON(){return this.toString()}equals(t){return t==null?!1:(t instanceof Uint8Array&&(t=et(t)),t.toString()===this.toString())}};var ud=114,cl=2336;function ll(r){if(r.type==="Ed25519")return new Qr({multihash:r.toCID().multihash,publicKey:r});if(r.type==="secp256k1")return new tn({multihash:r.toCID().multihash,publicKey:r});if(r.type==="RSA")return new Xr({multihash:r.toCID().multihash,publicKey:r});throw new De}function yi(r){if(hd(r))return new Xr({multihash:r});if(fd(r))try{let t=nl(r);if(t.type==="Ed25519")return new Qr({multihash:r,publicKey:t});if(t.type==="secp256k1")return new tn({multihash:r,publicKey:t})}catch{let e=et(r.digest);return new en(new URL(e))}throw new un("Supplied PeerID Multihash is invalid")}function Is(r){if(r?.multihash==null||r.version==null||r.version===1&&r.code!==ud&&r.code!==cl)throw new ln("Supplied PeerID CID is invalid");if(r.code===cl){let t=et(r.multihash.digest);return new en(new URL(t))}return yi(r.multihash)}function fd(r){return r.code===ae.code}function hd(r){return r.code===Pr.code}function ul(r,t){let e=(n,s)=>n.toString().localeCompare(s.toString());return r.length!==t.length?!1:(t.sort(e),r.sort(e).every((n,s)=>t[s].equals(n)))}var ks=class{index=0;input="";new(t){return this.index=0,this.input=t,this}readAtomically(t){let e=this.index,n=t();return n===void 0&&(this.index=e),n}parseWith(t){let e=t();if(this.index===this.input.length)return e}peekChar(){if(!(this.index>=this.input.length))return this.input[this.index]}readChar(){if(!(this.index>=this.input.length))return this.input[this.index++]}readGivenChar(t){return this.readAtomically(()=>{let e=this.readChar();if(e===t)return e})}readSeparator(t,e,n){return this.readAtomically(()=>{if(!(e>0&&this.readGivenChar(t)===void 0))return n()})}readNumber(t,e,n,s){return this.readAtomically(()=>{let o=0,i=0,a=this.peekChar();if(a===void 0)return;let c=a==="0",l=2**(8*s)-1;for(;;){let u=this.readAtomically(()=>{let f=this.readChar();if(f===void 0)return;let h=Number.parseInt(f,t);if(!Number.isNaN(h))return h});if(u===void 0)break;if(o*=t,o+=u,o>l||(i+=1,e!==void 0&&i>e))return}if(i!==0)return!n&&c&&i>1?void 0:o})}readIPv4Addr(){return this.readAtomically(()=>{let t=new Uint8Array(4);for(let e=0;e<t.length;e++){let n=this.readSeparator(".",e,()=>this.readNumber(10,3,!1,1));if(n===void 0)return;t[e]=n}return t})}readIPv6Addr(){let t=e=>{for(let n=0;n<e.length/2;n++){let s=n*2;if(n<e.length-3){let i=this.readSeparator(":",n,()=>this.readIPv4Addr());if(i!==void 0)return e[s]=i[0],e[s+1]=i[1],e[s+2]=i[2],e[s+3]=i[3],[s+4,!0]}let o=this.readSeparator(":",n,()=>this.readNumber(16,4,!0,2));if(o===void 0)return[s,!1];e[s]=o>>8,e[s+1]=o&255}return[e.length,!1]};return this.readAtomically(()=>{let e=new Uint8Array(16),[n,s]=t(e);if(n===16)return e;if(s||this.readGivenChar(":")===void 0||this.readGivenChar(":")===void 0)return;let o=new Uint8Array(14),i=16-(n+2),[a]=t(o.subarray(0,i));return e.set(o.subarray(0,a),16-a),e})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var fl=45,dd=15,yr=new ks;function bi(r){if(!(r.length>dd))return yr.new(r).parseWith(()=>yr.readIPv4Addr())}function wi(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>fl))return yr.new(r).parseWith(()=>yr.readIPv6Addr())}function Ns(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>fl))return yr.new(r).parseWith(()=>yr.readIPAddr())}var xb=parseInt("0xFFFF",16),vb=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);function br(r){return!!bi(r)}function wr(r){return!!wi(r)}function Cs(r){return!!Ns(r)}var pl=br,bd=wr,xi=function(r){let t=0;if(r=r.toString().trim(),pl(r)){let e=new Uint8Array(t+4);return r.split(/\./g).forEach(n=>{e[t++]=parseInt(n,10)&255}),e}if(bd(r)){let e=r.split(":",8),n;for(n=0;n<e.length;n++){let o=pl(e[n]),i;o&&(i=xi(e[n]),e[n]=et(i.slice(0,2),"base16")),i!=null&&++n<8&&e.splice(n,0,et(i.slice(2,4),"base16"))}if(e[0]==="")for(;e.length<8;)e.unshift("0");else if(e[e.length-1]==="")for(;e.length<8;)e.push("0");else if(e.length<8){for(n=0;n<e.length&&e[n]!=="";n++);let o=[n,1];for(n=9-e.length;n>0;n--)o.push("0");e.splice.apply(e,o)}let s=new Uint8Array(t+16);for(n=0;n<e.length;n++){let o=parseInt(e[n],16);s[t++]=o>>8&255,s[t++]=o&255}return s}throw new Error("invalid ip address")},ml=function(r,t=0,e){t=~~t,e=e??r.length-t;let n=new DataView(r.buffer);if(e===4){let s=[];for(let o=0;o<e;o++)s.push(r[t+o]);return s.join(".")}if(e===16){let s=[];for(let o=0;o<e;o+=2)s.push(n.getUint16(t+o).toString(16));return s.join(":").replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}return""};var xr={},vi={},xd=[[4,32,"ip4"],[6,16,"tcp"],[33,16,"dccp"],[41,128,"ip6"],[42,-1,"ip6zone"],[43,8,"ipcidr"],[53,-1,"dns",!0],[54,-1,"dns4",!0],[55,-1,"dns6",!0],[56,-1,"dnsaddr",!0],[132,16,"sctp"],[273,16,"udp"],[275,0,"p2p-webrtc-star"],[276,0,"p2p-webrtc-direct"],[277,0,"p2p-stardust"],[280,0,"webrtc-direct"],[281,0,"webrtc"],[290,0,"p2p-circuit"],[301,0,"udt"],[302,0,"utp"],[400,-1,"unix",!1,!0],[421,-1,"ipfs"],[421,-1,"p2p"],[443,0,"https"],[444,96,"onion"],[445,296,"onion3"],[446,-1,"garlic64"],[448,0,"tls"],[449,-1,"sni"],[460,0,"quic"],[461,0,"quic-v1"],[465,0,"webtransport"],[466,-1,"certhash"],[477,0,"ws"],[478,0,"wss"],[479,0,"p2p-websocket-star"],[480,0,"http"],[481,-1,"http-path"],[777,-1,"memory"]];xd.forEach(r=>{let t=vd(...r);vi[t.code]=t,xr[t.name]=t});function vd(r,t,e,n,s){return{code:r,size:t,name:e,resolvable:!!n,path:!!s}}function z(r){if(typeof r=="number"){if(vi[r]!=null)return vi[r];throw new Error(`no protocol with code: ${r}`)}else if(typeof r=="string"){if(xr[r]!=null)return xr[r];throw new Error(`no protocol with name: ${r}`)}throw new Error(`invalid protocol id type: ${typeof r}`)}var sw=z("ip4"),ow=z("ip6"),iw=z("ipcidr");function Si(r,t){switch(z(r).code){case 4:case 41:return Bd(t);case 42:return Ai(t);case 6:case 273:case 33:case 132:return bl(t).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return Ai(t);case 421:return kd(t);case 444:return yl(t);case 445:return yl(t);case 466:return Id(t);case 481:return globalThis.encodeURIComponent(Ai(t));default:return et(t,"base16")}}function Ii(r,t){switch(z(r).code){case 4:return gl(t);case 41:return gl(t);case 42:return Bi(t);case 6:case 273:case 33:case 132:return ki(parseInt(t,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return Bi(t);case 421:return Ad(t);case 444:return Nd(t);case 445:return Cd(t);case 466:return Sd(t);case 481:return Bi(globalThis.decodeURIComponent(t));default:return q(t,"base16")}}var Ei=Object.values(Or).map(r=>r.decoder),Ed=function(){let r=Ei[0].or(Ei[1]);return Ei.slice(2).forEach(t=>r=r.or(t)),r}();function gl(r){if(!Cs(r))throw new Error("invalid ip address");return xi(r)}function Bd(r){let t=ml(r,0,r.length);if(t==null)throw new Error("ipBuff is required");if(!Cs(t))throw new Error("invalid ip address");return t}function ki(r){let t=new ArrayBuffer(2);return new DataView(t).setUint16(0,r),new Uint8Array(t)}function bl(r){return new DataView(r.buffer).getUint16(r.byteOffset)}function Bi(r){let t=q(r),e=Uint8Array.from(Ot(t.length));return Pt([e,t],e.length+t.length)}function Ai(r){let t=he(r);if(r=r.slice(xt(t)),r.length!==t)throw new Error("inconsistent lengths");return et(r)}function Ad(r){let t;r[0]==="Q"||r[0]==="1"?t=Me(X.decode(`z${r}`)).bytes:t=pt.parse(r).multihash.bytes;let e=Uint8Array.from(Ot(t.length));return Pt([e,t],e.length+t.length)}function Sd(r){let t=Ed.decode(r),e=Uint8Array.from(Ot(t.length));return Pt([e,t],e.length+t.length)}function Id(r){let t=he(r),e=r.slice(xt(t));if(e.length!==t)throw new Error("inconsistent lengths");return"u"+et(e,"base64url")}function kd(r){let t=he(r),e=r.slice(xt(t));if(e.length!==t)throw new Error("inconsistent lengths");return et(e,"base58btc")}function Nd(r){let t=r.split(":");if(t.length!==2)throw new Error(`failed to parse onion addr: ["'${t.join('", "')}'"]' does not contain a port number`);if(t[0].length!==16)throw new Error(`failed to parse onion addr: ${t[0]} not a Tor onion address.`);let e=ie.decode("b"+t[0]),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let s=ki(n);return Pt([e,s],e.length+s.length)}function Cd(r){let t=r.split(":");if(t.length!==2)throw new Error(`failed to parse onion addr: ["'${t.join('", "')}'"]' does not contain a port number`);if(t[0].length!==56)throw new Error(`failed to parse onion addr: ${t[0]} not a Tor onion3 address.`);let e=ie.decode(`b${t[0]}`),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let s=ki(n);return Pt([e,s],e.length+s.length)}function yl(r){let t=r.slice(0,r.length-2),e=r.slice(r.length-2),n=et(t,"base32"),s=bl(e);return`${n}:${s}`}function wl(r){r=Ni(r);let t=[],e=[],n=null,s=r.split("/").slice(1);if(s.length===1&&s[0]==="")return{bytes:new Uint8Array,string:"/",tuples:[],stringTuples:[],path:null};for(let o=0;o<s.length;o++){let i=s[o],a=z(i);if(a.size===0){t.push([a.code]),e.push([a.code]);continue}if(o++,o>=s.length)throw vl("invalid address: "+r);if(a.path===!0){n=Ni(s.slice(o).join("/")),t.push([a.code,Ii(a.code,n)]),e.push([a.code,n]);break}let c=Ii(a.code,s[o]);t.push([a.code,c]),e.push([a.code,Si(a.code,c)])}return{string:xl(e),bytes:Ti(t),tuples:t,stringTuples:e,path:n}}function Ci(r){let t=[],e=[],n=null,s=0;for(;s<r.length;){let o=he(r,s),i=xt(o),a=z(o),c=Td(a,r.slice(s+i));if(c===0){t.push([o]),e.push([o]),s+=i;continue}let l=r.slice(s+i,s+i+c);if(s+=c+i,s>r.length)throw vl("Invalid address Uint8Array: "+et(r,"base16"));t.push([o,l]);let u=Si(o,l);if(e.push([o,u]),a.path===!0){n=u;break}}return{bytes:Uint8Array.from(r),string:xl(e),tuples:t,stringTuples:e,path:n}}function xl(r){let t=[];return r.map(e=>{let n=z(e[0]);return t.push(n.name),e.length>1&&e[1]!=null&&t.push(e[1]),null}),Ni(t.join("/"))}function Ti(r){return Pt(r.map(t=>{let e=z(t[0]),n=Uint8Array.from(Ot(e.code));return t.length>1&&t[1]!=null&&(n=Pt([n,t[1]])),n}))}function Td(r,t){if(r.size>0)return r.size/8;if(r.size===0)return 0;{let e=he(t instanceof Uint8Array?t:Uint8Array.from(t));return e+xt(e)}}function Ni(r){return"/"+r.trim().split("/").filter(t=>t).join("/")}function vl(r){return new Error("Error parsing address: "+r)}var Ld=Symbol.for("nodejs.util.inspect.custom"),Ui=Symbol.for("@multiformats/js-multiaddr/multiaddr"),Ud=[z("dns").code,z("dns4").code,z("dns6").code,z("dnsaddr").code],Li=class extends Error{constructor(t="No available resolver"){super(t),this.name="NoAvailableResolverError"}},Ts=class r{bytes;#e;#t;#r;#n;[Ui]=!0;constructor(t){t==null&&(t="");let e;if(t instanceof Uint8Array)e=Ci(t);else if(typeof t=="string"){if(t.length>0&&t.charAt(0)!=="/")throw new Error(`multiaddr "${t}" must start with a "/"`);e=wl(t)}else if(Bl(t))e=Ci(t.bytes);else throw new Error("addr must be a string, Buffer, or another Multiaddr");this.bytes=e.bytes,this.#e=e.string,this.#t=e.tuples,this.#r=e.stringTuples,this.#n=e.path}toString(){return this.#e}toJSON(){return this.toString()}toOptions(){let t,e,n,s,o="",i=z("tcp"),a=z("udp"),c=z("ip4"),l=z("ip6"),u=z("dns6"),f=z("ip6zone");for(let[g,m]of this.stringTuples())g===f.code&&(o=`%${m??""}`),Ud.includes(g)&&(e=i.name,s=443,n=`${m??""}${o}`,t=g===u.code?6:4),(g===i.code||g===a.code)&&(e=z(g).name,s=parseInt(m??"")),(g===c.code||g===l.code)&&(e=z(g).name,n=`${m??""}${o}`,t=g===l.code?6:4);if(t==null||e==null||n==null||s==null)throw new Error('multiaddr must have a valid format: "/{ip4, ip6, dns4, dns6, dnsaddr}/{address}/{tcp, udp}/{port}".');return{family:t,host:n,transport:e,port:s}}protos(){return this.#t.map(([t])=>Object.assign({},z(t)))}protoCodes(){return this.#t.map(([t])=>t)}protoNames(){return this.#t.map(([t])=>z(t).name)}tuples(){return this.#t}stringTuples(){return this.#r}encapsulate(t){return t=new r(t),new r(this.toString()+t.toString())}decapsulate(t){let e=t.toString(),n=this.toString(),s=n.lastIndexOf(e);if(s<0)throw new Error(`Address ${this.toString()} does not contain subaddress: ${t.toString()}`);return new r(n.slice(0,s))}decapsulateCode(t){let e=this.tuples();for(let n=e.length-1;n>=0;n--)if(e[n][0]===t)return new r(Ti(e.slice(0,n)));return this}getPeerId(){try{let t=[];this.stringTuples().forEach(([n,s])=>{n===xr.p2p.code&&t.push([n,s]),n===xr["p2p-circuit"].code&&(t=[])});let e=t.pop();if(e?.[1]!=null){let n=e[1];return n[0]==="Q"||n[0]==="1"?et(X.decode(`z${n}`),"base58btc"):et(pt.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){return this.#n}equals(t){return bt(this.bytes,t.bytes)}async resolve(t){let e=this.protos().find(o=>o.resolvable);if(e==null)return[this];let n=El.get(e.name);if(n==null)throw new Li(`no available resolver for ${e.name}`);return(await n(this,t)).map(o=>ne(o))}nodeAddress(){let t=this.toOptions();if(t.transport!=="tcp"&&t.transport!=="udp")throw new Error(`multiaddr must have a valid format - no protocol with name: "${t.transport}". Must have a valid transport protocol: "{tcp, udp}"`);return{family:t.family,address:t.host,port:t.port}}isThinWaistAddress(t){let e=(t??this).protos();return!(e.length!==2||e[0].code!==4&&e[0].code!==41||e[1].code!==6&&e[1].code!==273)}[Ld](){return`Multiaddr(${this.#e})`}};var El=new Map;function Bl(r){return!!r?.[Ui]}function ne(r){return new Ts(r)}var Al="libp2p-peer-record",Sl=Uint8Array.from([3,1]);var rn;(function(r){let t;(function(n){let s;n.codec=()=>(s==null&&(s=Gt((o,i,a={})=>{a.lengthDelimited!==!1&&i.fork(),o.multiaddr!=null&&o.multiaddr.byteLength>0&&(i.uint32(10),i.bytes(o.multiaddr)),a.lengthDelimited!==!1&&i.ldelim()},(o,i,a={})=>{let c={multiaddr:mt(0)},l=i==null?o.len:o.pos+i;for(;o.pos<l;){let u=o.uint32();switch(u>>>3){case 1:{c.multiaddr=o.bytes();break}default:{o.skipType(u&7);break}}}return c})),s),n.encode=o=>zt(o,n.codec()),n.decode=(o,i)=>qt(o,n.codec(),i)})(t=r.AddressInfo||(r.AddressInfo={}));let e;r.codec=()=>(e==null&&(e=Gt((n,s,o={})=>{if(o.lengthDelimited!==!1&&s.fork(),n.peerId!=null&&n.peerId.byteLength>0&&(s.uint32(10),s.bytes(n.peerId)),n.seq!=null&&n.seq!==0n&&(s.uint32(16),s.uint64(n.seq)),n.addresses!=null)for(let i of n.addresses)s.uint32(26),r.AddressInfo.codec().encode(i,s);o.lengthDelimited!==!1&&s.ldelim()},(n,s,o={})=>{let i={peerId:mt(0),seq:0n,addresses:[]},a=s==null?n.len:n.pos+s;for(;n.pos<a;){let c=n.uint32();switch(c>>>3){case 1:{i.peerId=n.bytes();break}case 2:{i.seq=n.uint64();break}case 3:{if(o.limits?.addresses!=null&&i.addresses.length===o.limits.addresses)throw new je('Decode error - map field "addresses" had too many elements');i.addresses.push(r.AddressInfo.codec().decode(n,n.uint32(),{limits:o.limits?.addresses$}));break}default:{n.skipType(c&7);break}}}return i})),e),r.encode=n=>zt(n,r.codec()),r.decode=(n,s)=>qt(n,r.codec(),s)})(rn||(rn={}));var Zt=class r{static createFromProtobuf=t=>{let e=rn.decode(t),n=yi(Me(e.peerId)),s=(e.addresses??[]).map(i=>ne(i.multiaddr)),o=e.seq;return new r({peerId:n,multiaddrs:s,seqNumber:o})};static DOMAIN=Al;static CODEC=Sl;peerId;multiaddrs;seqNumber;domain=r.DOMAIN;codec=r.CODEC;marshaled;constructor(t){let{peerId:e,multiaddrs:n,seqNumber:s}=t;this.peerId=e,this.multiaddrs=n??[],this.seqNumber=s??BigInt(Date.now())}marshal(){return this.marshaled==null&&(this.marshaled=rn.encode({peerId:this.peerId.toMultihash().bytes,seq:BigInt(this.seqNumber),addresses:this.multiaddrs.map(t=>({multiaddr:t.bytes}))})),this.marshaled}equals(t){return!(!(t instanceof r)||!this.peerId.equals(t.peerId)||this.seqNumber!==t.seqNumber||!ul(this.multiaddrs,t.multiaddrs))}};function Rd(r){return r[Symbol.asyncIterator]!=null}function _d(r){if(Rd(r))return(async()=>{for await(let t of r);})();for(let t of r);}var Il=_d;function Yt(){let r={};return r.promise=new Promise((t,e)=>{r.resolve=t,r.reject=e}),r}var Ls=globalThis.CustomEvent??Event;async function*Ri(r,t={}){let e=t.concurrency??1/0;e<1&&(e=1/0);let n=t.ordered==null?!1:t.ordered,s=new EventTarget,o=[],i=Yt(),a=Yt(),c=!1,l,u=!1;s.addEventListener("task-complete",()=>{a.resolve()}),Promise.resolve().then(async()=>{try{for await(let m of r){if(o.length===e&&(i=Yt(),await i.promise),u)break;let b={done:!1};o.push(b),m().then(d=>{b.done=!0,b.ok=!0,b.value=d,s.dispatchEvent(new Ls("task-complete"))},d=>{b.done=!0,b.err=d,s.dispatchEvent(new Ls("task-complete"))})}c=!0,s.dispatchEvent(new Ls("task-complete"))}catch(m){l=m,s.dispatchEvent(new Ls("task-complete"))}});function f(){return n?o[0]?.done:!!o.find(m=>m.done)}function*h(){for(;o.length>0&&o[0].done;){let m=o[0];if(o.shift(),m.ok)yield m.value;else throw u=!0,i.resolve(),m.err;i.resolve()}}function*g(){for(;f();)for(let m=0;m<o.length;m++)if(o[m].done){let b=o[m];if(o.splice(m,1),m--,b.ok)yield b.value;else throw u=!0,i.resolve(),b.err;i.resolve()}}for(;;){if(f()||(a=Yt(),await a.promise),l!=null)throw l;if(n?yield*h():yield*g(),c&&o.length===0)break}}var Us=class extends Error{type;code;constructor(t,e,n){super(t??"The operation was aborted"),this.type="aborted",this.name=n??"AbortError",this.code=e??"ABORT_ERR"}};async function kl(r,t,e){if(t==null)return r;if(t.aborted)return Promise.reject(new Us(e?.errorMessage,e?.errorCode,e?.errorName));let n,s=new Us(e?.errorMessage,e?.errorCode,e?.errorName);try{return await Promise.race([r,new Promise((o,i)=>{n=()=>{i(s)},t.addEventListener("abort",n)})])}finally{n!=null&&t.removeEventListener("abort",n)}}var _i=class{readNext;haveNext;ended;nextResult;constructor(){this.ended=!1,this.readNext=Yt(),this.haveNext=Yt()}[Symbol.asyncIterator](){return this}async next(){if(this.nextResult==null&&await this.haveNext.promise,this.nextResult==null)throw new Error("HaveNext promise resolved but nextResult was undefined");let t=this.nextResult;return this.nextResult=void 0,this.readNext.resolve(),this.readNext=Yt(),t}async throw(t){return this.ended=!0,t!=null&&(this.haveNext.promise.catch(()=>{}),this.haveNext.reject(t)),{done:!0,value:void 0}}async return(){let t={done:!0,value:void 0};return await this._push(void 0),t}async push(t,e){await this._push(t,e)}async end(t,e){t!=null?await this.throw(t):await this._push(void 0,e)}async _push(t,e){if(t!=null&&this.ended)throw new Error("Cannot push value onto an ended pushable");for(;this.nextResult!=null;)await this.readNext.promise;t!=null?this.nextResult={done:!1,value:t}:(this.ended=!0,this.nextResult={done:!0,value:void 0}),this.haveNext.resolve(),this.haveNext=Yt(),await kl(this.readNext.promise,e?.signal,e)}};function Nl(){return new _i}var Rs=class extends Error{name="UnexpectedEOFError";code="ERR_UNEXPECTED_EOF"};var Pi=class extends Error{code;constructor(t,e){super(t),this.code=e}},Oi=class extends Pi{type;constructor(t){super(t,"ABORT_ERR"),this.type="aborted",this.name="AbortError"}};function Cl(r,t){let e=Nl();r.sink(e).catch(async i=>{await e.end(i)}),r.sink=async i=>{for await(let a of i)await e.push(a);await e.end()};let n=r.source;r.source[Symbol.iterator]!=null?n=r.source[Symbol.iterator]():r.source[Symbol.asyncIterator]!=null&&(n=r.source[Symbol.asyncIterator]());let s=new jt;return{read:async(i,a)=>{a?.signal?.throwIfAborted();let c,l=new Promise((u,f)=>{c=()=>{f(new Oi("Read aborted"))},a?.signal?.addEventListener("abort",c)});try{if(i==null){let{done:f,value:h}=await Promise.race([n.next(),l]);return f===!0?new jt:h}for(;s.byteLength<i;){let{value:f,done:h}=await Promise.race([n.next(),l]);if(h===!0)throw new Rs("unexpected end of input");s.append(f)}let u=s.sublist(0,i);return s.consume(i),u}finally{c!=null&&a?.signal?.removeEventListener("abort",c)}},write:async(i,a)=>{a?.signal?.throwIfAborted(),i instanceof Uint8Array?await e.push(i,a):await e.push(i.subarray(),a)},unwrap:()=>{if(s.byteLength>0){let i=r.source;r.source=async function*(){t?.yieldBytes===!1?yield s:yield*s,yield*i}()}return r}}}var _s=class extends Error{name="InvalidMessageLengthError";code="ERR_INVALID_MSG_LENGTH"},Ps=class extends Error{name="InvalidDataLengthError";code="ERR_MSG_DATA_TOO_LONG"},Os=class extends Error{name="InvalidDataLengthLengthError";code="ERR_MSG_LENGTH_TOO_LONG"};function Tl(r,t={}){let e=Cl(r,t);t.maxDataLength!=null&&t.maxLengthLength==null&&(t.maxLengthLength=xt(t.maxDataLength));let n=t?.lengthDecoder??he,s=t?.lengthEncoder??Ot;return{read:async i=>{let a=-1,c=new jt;for(;;){c.append(await e.read(1,i));try{a=n(c)}catch(l){if(l instanceof RangeError)continue;throw l}if(a<0)throw new _s("Invalid message length");if(t?.maxLengthLength!=null&&c.byteLength>t.maxLengthLength)throw new Os("message length length too long");if(a>-1)break}if(t?.maxDataLength!=null&&a>t.maxDataLength)throw new Ps("message length too long");return e.read(a,i)},write:async(i,a)=>{await e.write(new jt(s(i.byteLength),i),a)},writeV:async(i,a)=>{let c=new jt(...i.flatMap(l=>[s(l.byteLength),l]));await e.write(c,a)},unwrap:()=>e.unwrap()}}function vr(r,t){let e=Tl(r,t),n={read:async(s,o)=>{let i=await e.read(o);return s.decode(i)},write:async(s,o,i)=>{await e.write(o.encode(s),i)},writeV:async(s,o,i)=>{await e.writeV(s.map(a=>o.encode(a)),i)},pb:s=>({read:async o=>n.read(s,o),write:async(o,i)=>n.write(o,s,i),writeV:async(o,i)=>n.writeV(o,s,i),unwrap:()=>n}),unwrap:()=>e.unwrap()};return n}var Ll="0.1.0",Ul="id",Rl="id/push",_l="1.0.0",Pl="1.0.0";var Ve;(function(r){let t;r.codec=()=>(t==null&&(t=Gt((e,n,s={})=>{if(s.lengthDelimited!==!1&&n.fork(),e.protocolVersion!=null&&(n.uint32(42),n.string(e.protocolVersion)),e.agentVersion!=null&&(n.uint32(50),n.string(e.agentVersion)),e.publicKey!=null&&(n.uint32(10),n.bytes(e.publicKey)),e.listenAddrs!=null)for(let o of e.listenAddrs)n.uint32(18),n.bytes(o);if(e.observedAddr!=null&&(n.uint32(34),n.bytes(e.observedAddr)),e.protocols!=null)for(let o of e.protocols)n.uint32(26),n.string(o);e.signedPeerRecord!=null&&(n.uint32(66),n.bytes(e.signedPeerRecord)),s.lengthDelimited!==!1&&n.ldelim()},(e,n,s={})=>{let o={listenAddrs:[],protocols:[]},i=n==null?e.len:e.pos+n;for(;e.pos<i;){let a=e.uint32();switch(a>>>3){case 5:{o.protocolVersion=e.string();break}case 6:{o.agentVersion=e.string();break}case 1:{o.publicKey=e.bytes();break}case 2:{if(s.limits?.listenAddrs!=null&&o.listenAddrs.length===s.limits.listenAddrs)throw new je('Decode error - map field "listenAddrs" had too many elements');o.listenAddrs.push(e.bytes());break}case 4:{o.observedAddr=e.bytes();break}case 3:{if(s.limits?.protocols!=null&&o.protocols.length===s.limits.protocols)throw new je('Decode error - map field "protocols" had too many elements');o.protocols.push(e.string());break}case 8:{o.signedPeerRecord=e.bytes();break}default:{e.skipType(a&7);break}}}return o})),t),r.encode=e=>zt(e,r.codec()),r.decode=(e,n)=>qt(e,r.codec(),n)})(Ve||(Ve={}));var Dl=js(Vl(),1),Vi=typeof window=="object"&&typeof document=="object"&&document.nodeType===9,Vs=(0,Dl.default)(),Ml=Vi&&!Vs,Fl=Vs&&!Vi,Hl=Vs&&Vi,Kl=typeof globalThis.process<"u"&&typeof globalThis.process.release<"u"&&globalThis.process.release.name==="node"&&!Vs,$l=typeof importScripts=="function"&&typeof self<"u"&&typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope,dx=typeof globalThis.process<"u"&&typeof globalThis.process.env<"u"&&globalThis.process.env["NODE"+"_"+"ENV"]==="test",ql=typeof navigator<"u"&&navigator.product==="ReactNative";var Rt={protocolPrefix:"ipfs",timeout:5e3,maxInboundStreams:1,maxOutboundStreams:1,maxObservedAddresses:10,maxMessageSize:8192,runOnConnectionOpen:!0,runOnSelfUpdate:!0,runOnLimitedConnection:!0,concurrency:32};function zl(r){if(r!=null&&r.length>0)try{return ne(r)}catch{}}function Dd(r,t){return t!=null||(t=`${r.name}/${r.version}`,Kl||Fl?t+=` UserAgent=${globalThis.process.version}`:(Ml||$l||Hl||ql)&&(t+=` UserAgent=${globalThis.navigator.userAgent}`)),t}async function Ds(r,t,e,n,s){if(e("received identify from %p",n.remotePeer),s==null)throw new Dt("message was null or undefined");let o={};if(s.listenAddrs.length>0&&(o.addresses=s.listenAddrs.map(c=>({isCertified:!1,multiaddr:ne(c)}))),s.protocols.length>0&&(o.protocols=s.protocols),s.publicKey!=null){let c=gr(s.publicKey);if(!ll(c).equals(n.remotePeer))throw new Dt("public key did not match remote PeerId");o.publicKey=c}let i;if(s.signedPeerRecord!=null){e.trace("received signedPeerRecord from %p",n.remotePeer);let c=s.signedPeerRecord,l=await re.openAndCertify(c,Zt.DOMAIN),u=Zt.createFromProtobuf(l.payload),f=Is(l.publicKey.toCID());if(!u.peerId.equals(f))throw new Dt("signing key does not match PeerId in the PeerRecord");if(!n.remotePeer.equals(u.peerId))throw new Dt("signing key does not match remote PeerId");let h;try{h=await r.get(u.peerId)}catch(g){if(g.name!=="NotFoundError")throw g}if(h!=null&&(o.metadata=h.metadata,h.peerRecordEnvelope!=null)){let g=await re.createFromProtobuf(h.peerRecordEnvelope),m=Zt.createFromProtobuf(g.payload);m.seqNumber>=u.seqNumber&&(e("sequence number was lower or equal to existing sequence number - stored: %d received: %d",m.seqNumber,u.seqNumber),u=m,c=h.peerRecordEnvelope)}o.peerRecordEnvelope=c,o.addresses=u.multiaddrs.map(g=>({isCertified:!0,multiaddr:g})),i={seq:u.seqNumber,addresses:u.multiaddrs}}else e("%p did not send a signed peer record",n.remotePeer);if(e.trace("patching %p with",n.remotePeer,o),await r.patch(n.remotePeer,o),s.agentVersion!=null||s.protocolVersion!=null){let c={};s.agentVersion!=null&&(c.AgentVersion=q(s.agentVersion)),s.protocolVersion!=null&&(c.ProtocolVersion=q(s.protocolVersion)),e.trace("merging %p metadata",n.remotePeer,c),await r.merge(n.remotePeer,{metadata:c})}let a={peerId:n.remotePeer,protocolVersion:s.protocolVersion,agentVersion:s.agentVersion,publicKey:s.publicKey,listenAddrs:s.listenAddrs.map(c=>ne(c)),observedAddr:s.observedAddr==null?void 0:ne(s.observedAddr),protocols:s.protocols,signedPeerRecord:i,connection:n};return t.safeDispatchEvent("peer:identify",{detail:a}),a}var Er=class{host;protocol;started;timeout;peerId;privateKey;peerStore;registrar;addressManager;maxInboundStreams;maxOutboundStreams;maxMessageSize;maxObservedAddresses;events;runOnLimitedConnection;log;constructor(t,e){this.protocol=e.protocol,this.started=!1,this.peerId=t.peerId,this.privateKey=t.privateKey,this.peerStore=t.peerStore,this.registrar=t.registrar,this.addressManager=t.addressManager,this.events=t.events,this.log=e.log,this.timeout=e.timeout??Rt.timeout,this.maxInboundStreams=e.maxInboundStreams??Rt.maxInboundStreams,this.maxOutboundStreams=e.maxOutboundStreams??Rt.maxOutboundStreams,this.maxMessageSize=e.maxMessageSize??Rt.maxMessageSize,this.maxObservedAddresses=e.maxObservedAddresses??Rt.maxObservedAddresses,this.runOnLimitedConnection=e.runOnLimitedConnection??Rt.runOnLimitedConnection,this.host={protocolVersion:`${e.protocolPrefix??Rt.protocolPrefix}/${Ll}`,agentVersion:Dd(t.nodeInfo,e.agentVersion)}}isStarted(){return this.started}async start(){this.started||(await this.peerStore.merge(this.peerId,{metadata:{AgentVersion:q(this.host.agentVersion),ProtocolVersion:q(this.host.protocolVersion)}}),await this.registrar.handle(this.protocol,t=>{this.handleProtocol(t).catch(e=>{this.log.error(e)})},{maxInboundStreams:this.maxInboundStreams,maxOutboundStreams:this.maxOutboundStreams,runOnLimitedConnection:this.runOnLimitedConnection}),this.started=!0)}async stop(){await this.registrar.unhandle(this.protocol),this.started=!1}};var Ms=class extends Er{connectionManager;concurrency;constructor(t,e={}){super(t,{...e,protocol:`/${e.protocolPrefix??Rt.protocolPrefix}/${Rl}/${Pl}`,log:t.logger.forComponent("libp2p:identify-push")}),this.connectionManager=t.connectionManager,this.concurrency=e.concurrency??Rt.concurrency,(e.runOnSelfUpdate??Rt.runOnSelfUpdate)&&t.events.addEventListener("self:peer:update",n=>{this.push().catch(s=>{this.log.error(s)})})}[hn]=["@libp2p/identify-push"];async push(){if(!this.isStarted())return;let t=this.addressManager.getAddresses().map(u=>u.decapsulateCode(z("p2p").code)),e=new Zt({peerId:this.peerId,multiaddrs:t}),n=await re.seal(e,this.privateKey),s=this.registrar.getProtocols(),o=await this.peerStore.get(this.peerId),i=et(o.metadata.get("AgentVersion")??q(this.host.agentVersion)),a=et(o.metadata.get("ProtocolVersion")??q(this.host.protocolVersion)),c=this;async function*l(){for(let u of c.connectionManager.getConnections())(await c.peerStore.get(u.remotePeer)).protocols.includes(c.protocol)&&(yield async()=>{let h,g=AbortSignal.timeout(c.timeout);Ir(1/0,g);try{h=await u.newStream(c.protocol,{signal:g,runOnLimitedConnection:c.runOnLimitedConnection}),await vr(h,{maxDataLength:c.maxMessageSize}).pb(Ve).write({listenAddrs:t.map(b=>b.bytes),signedPeerRecord:n.marshal(),protocols:s,agentVersion:i,protocolVersion:a},{signal:g}),await h.close({signal:g})}catch(m){c.log.error("could not push identify update to peer",m),h?.abort(m)}})}await Il(Ri(l(),{concurrency:this.concurrency}))}async handleProtocol(t){let{connection:e,stream:n}=t;try{if(this.peerId.equals(e.remotePeer))throw new Error("received push from ourselves?");let s={signal:AbortSignal.timeout(this.timeout)},i=await vr(n,{maxDataLength:this.maxMessageSize}).pb(Ve).read(s);await n.close(s),await Ds(this.peerStore,this.events,this.log,e,i)}catch(s){this.log.error("received invalid message",s),n.abort(s);return}this.log.trace("handled push from %p",e.remotePeer)}};var Wl=js(Gl(),1),Md=["0.0.0.0/8","10.0.0.0/8","100.64.0.0/10","127.0.0.0/8","169.254.0.0/16","172.16.0.0/12","192.0.0.0/24","192.0.0.0/29","192.0.0.8/32","192.0.0.9/32","192.0.0.10/32","192.0.0.170/32","192.0.0.171/32","192.0.2.0/24","192.31.196.0/24","192.52.193.0/24","192.88.99.0/24","192.168.0.0/16","192.175.48.0/24","198.18.0.0/15","198.51.100.0/24","203.0.113.0/24","240.0.0.0/4","255.255.255.255/32"],Fd=Md.map(r=>new Wl.Netmask(r));function Di(r){for(let t of Fd)if(t.contains(r))return!0;return!1}function Hd(r){return/^::ffff:([0-9a-fA-F]{1,4}):([0-9a-fA-F]{1,4})$/.test(r)}function Kd(r){let t=r.split(":");if(t.length<2)return!1;let e=t[t.length-1].padStart(4,"0"),n=t[t.length-2].padStart(4,"0"),s=`${parseInt(n.substring(0,2),16)}.${parseInt(n.substring(2),16)}.${parseInt(e.substring(0,2),16)}.${parseInt(e.substring(2),16)}`;return Di(s)}function $d(r){return/^::ffff:([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(r)}function qd(r){let t=r.split(":"),e=t[t.length-1];return Di(e)}function zd(r){return/^::$/.test(r)||/^::1$/.test(r)||/^64:ff9b::([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(r)||/^100::([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^2001::([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^2001:2[0-9a-fA-F]:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^2001:db8:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^2002:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^f[c-d]([0-9a-fA-F]{2,2}):/i.test(r)||/^fe[8-9a-bA-B][0-9a-fA-F]:/i.test(r)||/^ff([0-9a-fA-F]{2,2}):/i.test(r)}function jl(r){return br(r)?Di(r):Hd(r)?Kd(r):$d(r)?qd(r):wr(r)?zd(r):void 0}var Gd=r=>r.toString().split("/").slice(1),Br=r=>({match:t=>t.length<1?!1:r(t[0])?t.slice(1):!1,pattern:"fn"}),H=r=>({match:t=>Br(e=>e===r).match(t),pattern:r}),Je=()=>({match:r=>Br(t=>typeof t=="string").match(r),pattern:"{string}"}),sn=()=>({match:r=>Br(t=>!isNaN(parseInt(t))).match(r),pattern:"{number}"}),Y=()=>({match:r=>{if(r.length<2||r[0]!=="p2p"&&r[0]!=="ipfs")return!1;if(r[1].startsWith("Q")||r[1].startsWith("1"))try{X.decode(`z${r[1]}`)}catch{return!1}else return!1;return r.slice(2)},pattern:"/p2p/{peerid}"}),on=()=>({match:r=>{if(r.length<2||r[0]!=="certhash")return!1;try{Fo.decode(r[1])}catch{return!1}return r.slice(2)},pattern:"/certhash/{certhash}"}),G=r=>({match:t=>{let e=r.match(t);return e===!1?t:e},pattern:`optional(${r.pattern})`}),Bt=(...r)=>({match:t=>{let e;for(let n of r){let s=n.match(t);s!==!1&&(e==null||s.length<e.length)&&(e=s)}return e??!1},pattern:`or(${r.map(t=>t.pattern).join(", ")})`}),K=(...r)=>({match:t=>{for(let e of r){let n=e.match(t);if(n===!1)return!1;t=n}return t},pattern:`and(${r.map(t=>t.pattern).join(", ")})`});function rt(...r){function t(s){let o=Gd(s);for(let i of r){let a=i.match(o);if(a===!1)return!1;o=a}return o}function e(s){return t(s)!==!1}function n(s){let o=t(s);return o===!1?!1:o.length===0}return{matchers:r,matches:e,exactMatch:n}}var Hs=K(H("dns4"),Je()),Ks=K(H("dns6"),Je()),$s=K(H("dnsaddr"),Je()),Fi=K(H("dns"),Je()),qx=rt(Hs,G(Y())),zx=rt(Ks,G(Y())),Gx=rt($s,G(Y())),Wx=rt(Bt(Fi,$s,Hs,Ks),G(Y())),Zl=K(H("ip4"),Br(br)),Yl=K(H("ip6"),Br(wr)),Hi=Bt(Zl,Yl),ve=Bt(Hi,Fi,Hs,Ks,$s),Jl=rt(Bt(Hi,K(Bt(Fi,$s,Hs,Ks),G(Y())))),jx=rt(Zl),Zx=rt(Yl),Yx=rt(Hi),Ki=K(ve,H("tcp"),sn()),an=K(ve,H("udp"),sn()),Jx=rt(K(Ki,G(Y()))),Xx=rt(an),$i=K(an,H("quic"),G(Y())),qs=K(an,H("quic-v1"),G(Y())),Wd=Bt($i,qs),Qx=rt($i),t1=rt(qs),Mi=Bt(ve,Ki,an,$i,qs),Xl=Bt(K(Mi,H("ws"),G(Y()))),e1=rt(Xl),Ql=Bt(K(Mi,H("wss"),G(Y())),K(Mi,H("tls"),G(K(H("sni"),Je())),H("ws"),G(Y()))),r1=rt(Ql),tu=K(an,H("webrtc-direct"),G(on()),G(on()),G(Y())),n1=rt(tu),eu=K(qs,H("webtransport"),G(on()),G(on()),G(Y())),s1=rt(eu),Fs=Bt(Xl,Ql,K(Ki,G(Y())),K(Wd,G(Y())),K(ve,G(Y())),tu,eu,Y()),o1=rt(Fs),jd=K(Fs,H("p2p-circuit"),Y()),i1=rt(jd),Zd=Bt(K(Fs,H("p2p-circuit"),H("webrtc"),G(Y())),K(Fs,H("webrtc"),G(Y())),K(H("webrtc"),G(Y()))),a1=rt(Zd),Yd=Bt(K(ve,H("tcp"),sn(),H("http"),G(Y())),K(ve,H("http"),G(Y()))),c1=rt(Yd),Jd=Bt(K(ve,H("tcp"),Bt(K(H("443"),H("http")),K(sn(),H("https"))),G(Y())),K(ve,H("tls"),H("http"),G(Y())),K(ve,H("https"),G(Y()))),l1=rt(Jd),Xd=Bt(K(H("memory"),Je(),G(Y()))),u1=rt(Xd);var zs=class extends Er{constructor(t,e={}){super(t,{...e,protocol:`/${e.protocolPrefix??Rt.protocolPrefix}/${Ul}/${_l}`,log:t.logger.forComponent("libp2p:identify")}),(e.runOnConnectionOpen??Rt.runOnConnectionOpen)&&t.events.addEventListener("connection:open",n=>{let s=n.detail;this.identify(s).catch(o=>{o.name!==fn.name&&this.log.error("error during identify trigged by connection:open",o)})})}[hn]=["@libp2p/identify"];async _identify(t,e={}){let n;if(e.signal==null){let s=AbortSignal.timeout(this.timeout);Ir(1/0,s),e={...e,signal:s}}try{n=await t.newStream(this.protocol,{...e,runOnLimitedConnection:this.runOnLimitedConnection});let o=await vr(n,{maxDataLength:this.maxMessageSize}).pb(Ve).read(e);return await n.close(e),o}catch(s){throw n?.abort(s),s}}async identify(t,e={}){let n=await this._identify(t,e),{publicKey:s,protocols:o,observedAddr:i}=n;if(s==null)throw new Dt("public key was missing from identify message");let a=gr(s),c=Is(a.toCID());if(!t.remotePeer.equals(c))throw new Dt("identified peer does not match the expected peer");if(this.peerId.equals(c))throw new Dt("identified peer is our own peer id?");let l=zl(i);return this.log("identify completed for peer %p and protocols %o",c,o),l!=null&&(this.log("our observed address was %a",l),jl(l?.nodeAddress().address)===!0?this.log("our observed address was private"):this.addressManager.getObservedAddrs().length<(this.maxObservedAddresses??1/0)&&(this.log("storing our observed address"),this.addressManager.addObservedAddr(l))),Ds(this.peerStore,this.events,this.log,t,n)}async handleProtocol(t){let{connection:e,stream:n}=t,s=AbortSignal.timeout(this.timeout);Ir(1/0,s);try{let o=await this.peerStore.get(this.peerId),i=this.addressManager.getAddresses().map(u=>u.decapsulateCode(z("p2p").code)),a=o.peerRecordEnvelope;if(i.length>0&&a==null){let u=new Zt({peerId:this.peerId,multiaddrs:i});a=(await re.seal(u,this.privateKey)).marshal().subarray()}let c=e.remoteAddr.bytes;Jl.matches(e.remoteAddr)||(c=void 0),await vr(n).pb(Ve).write({protocolVersion:this.host.protocolVersion,agentVersion:this.host.agentVersion,publicKey:Te(this.privateKey.publicKey),listenAddrs:i.map(u=>u.bytes),signedPeerRecord:a,observedAddr:c,protocols:o.protocols},{signal:s}),await n.close({signal:s})}catch(o){this.log.error("could not respond to identify request",o),n.abort(o)}}};function Qd(r={}){return t=>new zs(t,r)}function t0(r={}){return t=>new Ms(t,r)}return mu(e0);})();
|
|
6
|
+
`)}`:`${e} :`}};Bc=Pe;B.Constructed=Bc;Pe.NAME="CONSTRUCTED";var jn=class extends Et{fromBER(t,e,n){return e}toBER(t){return jt}};jn.override="EndOfContentValueBlock";var Ac,Zn=class extends gt{constructor(t={}){super(t,jn),this.idBlock.tagClass=1,this.idBlock.tagNumber=0}};Ac=Zn;B.EndOfContent=Ac;Zn.NAME=qr;var Sc,pr=class extends gt{constructor(t={}){super(t,Et),this.idBlock.tagClass=1,this.idBlock.tagNumber=5}fromBER(t,e,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,e+n>t.byteLength?(this.error="End of input reached before message was fully decoded (inconsistent offset and length values)",-1):e+n}toBER(t,e){let n=new ArrayBuffer(2);if(!t){let s=new Uint8Array(n);s[0]=5,s[1]=0}return e&&e.write(n),n}onAsciiEncoding(){return`${this.constructor.NAME}`}};Sc=pr;B.Null=Sc;pr.NAME="NULL";var Yn=class extends xe(Et){constructor({value:t,...e}={}){super(e),e.valueHex?this.valueHexView=M.BufferSourceConverter.toUint8Array(e.valueHex):this.valueHexView=new Uint8Array(1),t&&(this.value=t)}get value(){for(let t of this.valueHexView)if(t>0)return!0;return!1}set value(t){this.valueHexView[0]=t?255:0}fromBER(t,e,n){let s=M.BufferSourceConverter.toUint8Array(t);return we(this,s,e,n)?(this.valueHexView=s.subarray(e,e+n),n>1&&this.warnings.push("Boolean value encoded in more then 1 octet"),this.isHexOnly=!0,bi.call(this),this.blockLength=n,e+n):-1}toBER(){return this.valueHexView.slice()}toJSON(){return{...super.toJSON(),value:this.value}}};Yn.NAME="BooleanValueBlock";var Ic,Jn=class extends gt{constructor(t={}){super(t,Yn),this.idBlock.tagClass=1,this.idBlock.tagNumber=1}getValue(){return this.valueBlock.value}setValue(t){this.valueBlock.value=t}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.getValue}`}};Ic=Jn;B.Boolean=Ic;Jn.NAME="BOOLEAN";var Xn=class extends xe(ee){constructor({isConstructed:t=!1,...e}={}){super(e),this.isConstructed=t}fromBER(t,e,n){let s=0;if(this.isConstructed){if(this.isHexOnly=!1,s=ee.prototype.fromBER.call(this,t,e,n),s===-1)return s;for(let o=0;o<this.value.length;o++){let i=this.value[o].constructor.NAME;if(i===qr){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, OCTET STRING may consists of OCTET STRINGs only",-1}if(i!==wc)return this.error="OCTET STRING may consists of OCTET STRINGs only",-1}}else this.isHexOnly=!0,s=super.fromBER(t,e,n),this.blockLength=n;return s}toBER(t,e){return this.isConstructed?ee.prototype.toBER.call(this,t,e):t?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),isConstructed:this.isConstructed}}};Xn.NAME="OctetStringValueBlock";var kc,Qn=class r extends gt{constructor({idBlock:t={},lenBlock:e={},...n}={}){var s,o;(s=n.isConstructed)!==null&&s!==void 0||(n.isConstructed=!!(!((o=n.value)===null||o===void 0)&&o.length)),super({idBlock:{isConstructed:n.isConstructed,...t},lenBlock:{...e,isIndefiniteForm:!!n.isIndefiniteForm},...n},Xn),this.idBlock.tagClass=1,this.idBlock.tagNumber=4}fromBER(t,e,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),e;if(!this.valueBlock.isConstructed){let o=(t instanceof ArrayBuffer?new Uint8Array(t):t).subarray(e,e+n);try{if(o.byteLength){let i=ks(o,0,o.byteLength);i.offset!==-1&&i.offset===n&&(this.valueBlock.value=[i.result])}}catch{}}return super.fromBER(t,e,n)}onAsciiEncoding(){return this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length?Pe.prototype.onAsciiEncoding.call(this):`${this.constructor.NAME} : ${M.Convert.ToHex(this.valueBlock.valueHexView)}`}getValue(){if(!this.idBlock.isConstructed)return this.valueBlock.valueHexView.slice().buffer;let t=[];for(let e of this.valueBlock.value)e instanceof r&&t.push(e.valueBlock.valueHexView);return M.BufferSourceConverter.concat(t)}};kc=Qn;B.OctetString=kc;Qn.NAME=wc;var ts=class extends xe(ee){constructor({unusedBits:t=0,isConstructed:e=!1,...n}={}){super(n),this.unusedBits=t,this.isConstructed=e,this.blockLength=this.valueHexView.byteLength}fromBER(t,e,n){if(!n)return e;let s=-1;if(this.isConstructed){if(s=ee.prototype.fromBER.call(this,t,e,n),s===-1)return s;for(let a of this.value){let c=a.constructor.NAME;if(c===qr){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, BIT STRING may consists of BIT STRINGs only",-1}if(c!==xc)return this.error="BIT STRING may consists of BIT STRINGs only",-1;let l=a.valueBlock;if(this.unusedBits>0&&l.unusedBits>0)return this.error='Using of "unused bits" inside constructive BIT STRING allowed for least one only',-1;this.unusedBits=l.unusedBits}return s}let o=M.BufferSourceConverter.toUint8Array(t);if(!we(this,o,e,n))return-1;let i=o.subarray(e,e+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=ks(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,e+n}toBER(t,e){if(this.isConstructed)return ee.prototype.toBER.call(this,t,e);if(t)return new ArrayBuffer(this.valueHexView.byteLength+1);if(!this.valueHexView.byteLength)return jt;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}}};ts.NAME="BitStringValueBlock";var Nc,gr=class extends gt{constructor({idBlock:t={},lenBlock:e={},...n}={}){var s,o;(s=n.isConstructed)!==null&&s!==void 0||(n.isConstructed=!!(!((o=n.value)===null||o===void 0)&&o.length)),super({idBlock:{isConstructed:n.isConstructed,...t},lenBlock:{...e,isIndefiniteForm:!!n.isIndefiniteForm},...n},ts),this.idBlock.tagClass=1,this.idBlock.tagNumber=3}fromBER(t,e,n){return this.valueBlock.isConstructed=this.idBlock.isConstructed,this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm,super.fromBER(t,e,n)}onAsciiEncoding(){if(this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length)return Pe.prototype.onAsciiEncoding.call(this);{let t=[],e=this.valueBlock.valueHexView;for(let s of e)t.push(s.toString(2).padStart(8,"0"));let n=t.join("");return`${this.constructor.NAME} : ${n.substring(0,n.length-this.valueBlock.unusedBits)}`}}};Nc=gr;B.BitString=Nc;gr.NAME=xc;var Cc;function wd(r,t){let e=new Uint8Array([0]),n=new Uint8Array(r),s=new Uint8Array(t),o=n.slice(0),i=o.length-1,a=s.slice(0),c=a.length-1,l=0,u=c<i?i:c,f=0;for(let h=u;h>=0;h--,f++){switch(!0){case f<a.length:l=o[i-f]+a[c-f]+e[0];break;default:l=o[i-f]+e[0]}switch(e[0]=l/10,!0){case f>=o.length:o=Hn(new Uint8Array([l%10]),o);break;default:o[i-f]=l%10}}return e[0]>0&&(o=Hn(e,o)),o}function yc(r){if(r>=Hr.length)for(let t=Hr.length;t<=r;t++){let e=new Uint8Array([0]),n=Hr[t-1].slice(0);for(let s=n.length-1;s>=0;s--){let o=new Uint8Array([(n[s]<<1)+e[0]]);e[0]=o[0]/10,n[s]=o[0]%10}e[0]>0&&(n=Hn(e,n)),Hr.push(n)}return Hr[r]}function xd(r,t){let e=0,n=new Uint8Array(r),s=new Uint8Array(t),o=n.slice(0),i=o.length-1,a=s.slice(0),c=a.length-1,l,u=0;for(let f=c;f>=0;f--,u++)switch(l=o[i-u]-a[c-u]-e,!0){case l<0:e=1,o[i-u]=l+10;break;default:e=0,o[i-u]=l}if(e>0)for(let f=i-c+1;f>=0;f--,u++)if(l=o[i-u]-e,l<0)e=1,o[i-u]=l+10;else{e=0,o[i-u]=l;break}return o.slice()}var $r=class extends xe(Et){constructor({value:t,...e}={}){super(e),this._valueDec=0,e.valueHex&&this.setValueHex(),t!==void 0&&(this.valueDec=t)}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=bi.call(this)))}set valueDec(t){this._valueDec=t,this.isHexOnly=!1,this.valueHexView=new Uint8Array(gc(t))}get valueDec(){return this._valueDec}fromDER(t,e,n,s=0){let o=this.fromBER(t,e,n);if(o===-1)return o;let i=this.valueHexView;return i[0]===0&&i[1]&128?this.valueHexView=i.subarray(1):s!==0&&i.length<s&&(s-i.length>1&&(s=i.length+1),this.valueHexView=i.subarray(s-i.length)),o}toDER(t=!1){let e=this.valueHexView;switch(!0){case(e[0]&128)!==0:{let n=new Uint8Array(this.valueHexView.length+1);n[0]=0,n.set(e,1),this.valueHexView=n}break;case(e[0]===0&&(e[1]&128)===0):this.valueHexView=this.valueHexView.subarray(1);break}return this.toBER(t)}fromBER(t,e,n){let s=super.fromBER(t,e,n);return s===-1||this.setValueHex(),s}toBER(t){return t?new ArrayBuffer(this.valueHexView.length):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}toString(){let t=this.valueHexView.length*8-1,e=new Uint8Array(this.valueHexView.length*8/3),n=0,s,o=this.valueHexView,i="",a=!1;for(let c=o.byteLength-1;c>=0;c--){s=o[c];for(let l=0;l<8;l++){if((s&1)===1)switch(n){case t:e=xd(yc(n),e),i="-";break;default:e=wd(e,yc(n))}n++,s>>=1}}for(let c=0;c<e.length;c++)e[c]&&(a=!0),a&&(i+=bc.charAt(e[c]));return a===!1&&(i+=bc.charAt(0)),i}};Cc=$r;$r.NAME="IntegerValueBlock";Object.defineProperty(Cc.prototype,"valueHex",{set:function(r){this.valueHexView=new Uint8Array(r),this.setValueHex()},get:function(){return this.valueHexView.slice().buffer}});var Tc,mt=class r extends gt{constructor(t={}){super(t,$r),this.idBlock.tagClass=1,this.idBlock.tagNumber=2}toBigInt(){return Kn(),BigInt(this.valueBlock.toString())}static fromBigInt(t){Kn();let e=BigInt(t),n=new Kr,s=e.toString(16).replace(/^-/,""),o=new Uint8Array(M.Convert.FromHex(s));if(e<0){let a=new Uint8Array(o.length+(o[0]&128?1:0));a[0]|=128;let l=BigInt(`0x${M.Convert.ToHex(a)}`)+e,u=M.BufferSourceConverter.toUint8Array(M.Convert.FromHex(l.toString(16)));u[0]|=128,n.write(u)}else o[0]&128&&n.write(new Uint8Array([0])),n.write(o);return new r({valueHex:n.final()})}convertToDER(){let t=new r({valueHex:this.valueBlock.valueHexView});return t.valueBlock.toDER(),t}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()}`}};Tc=mt;B.Integer=Tc;mt.NAME="INTEGER";var Lc,es=class extends mt{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=10}};Lc=es;B.Enumerated=Lc;es.NAME="ENUMERATED";var zr=class extends xe(Et){constructor({valueDec:t=-1,isFirstSid:e=!1,...n}={}){super(n),this.valueDec=t,this.isFirstSid=e}fromBER(t,e,n){if(!n)return e;let s=M.BufferSourceConverter.toUint8Array(t);if(!we(this,s,e,n))return-1;let o=s.subarray(e,e+n);this.valueHexView=new Uint8Array(n);for(let a=0;a<n&&(this.valueHexView[a]=o[a]&127,this.blockLength++,!!(o[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,o[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=Qe(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),e+this.blockLength)}set valueBigInt(t){Kn();let e=BigInt(t).toString(2);for(;e.length%7;)e="0"+e;let n=new Uint8Array(e.length/7);for(let s=0;s<n.length;s++)n[s]=parseInt(e.slice(s*7,s*7+7),2)+(s+1<n.length?128:0);this.fromBER(n.buffer,0,n.length)}toBER(t){if(this.isHexOnly){if(t)return new ArrayBuffer(this.valueHexView.byteLength);let s=this.valueHexView,o=new Uint8Array(this.blockLength);for(let i=0;i<this.blockLength-1;i++)o[i]=s[i]|128;return o[this.blockLength-1]=s[this.blockLength-1],o.buffer}let e=Ve(this.valueDec,7);if(e.byteLength===0)return this.error="Error during encoding SID value",jt;let n=new Uint8Array(e.byteLength);if(!t){let s=new Uint8Array(e),o=e.byteLength-1;for(let i=0;i<o;i++)n[i]=s[i]|128;n[o]=s[o]}return n}toString(){let t="";if(this.isHexOnly)t=M.Convert.ToHex(this.valueHexView);else if(this.isFirstSid){let e=this.valueDec;this.valueDec<=39?t="0.":this.valueDec<=79?(t="1.",e-=40):(t="2.",e-=80),t+=e.toString()}else t=this.valueDec.toString();return t}toJSON(){return{...super.toJSON(),valueDec:this.valueDec,isFirstSid:this.isFirstSid}}};zr.NAME="sidBlock";var rs=class extends Et{constructor({value:t=br,...e}={}){super(e),this.value=[],t&&this.fromString(t)}fromBER(t,e,n){let s=e;for(;n>0;){let o=new zr;if(s=o.fromBER(t,s,n),s===-1)return this.blockLength=0,this.error=o.error,s;this.value.length===0&&(o.isFirstSid=!0),this.blockLength+=o.blockLength,n-=o.blockLength,this.value.push(o)}return s}toBER(t){let e=[];for(let n=0;n<this.value.length;n++){let s=this.value[n].toBER(t);if(s.byteLength===0)return this.error=this.value[n].error,jt;e.push(s)}return yi(e)}fromString(t){this.value=[];let e=0,n=0,s="",o=!1;do if(n=t.indexOf(".",e),n===-1?s=t.substring(e):s=t.substring(e,n),e=n+1,o){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(s,10);if(isNaN(c))return;i.valueDec=c+a,o=!1}else{let i=new zr;if(s>Number.MAX_SAFE_INTEGER){Kn();let a=BigInt(s);i.valueBigInt=a}else if(i.valueDec=parseInt(s,10),isNaN(i.valueDec))return;this.value.length||(i.isFirstSid=!0,o=!0),this.value.push(i)}while(n!==-1)}toString(){let t="",e=!1;for(let n=0;n<this.value.length;n++){e=this.value[n].isHexOnly;let s=this.value[n].toString();n!==0&&(t=`${t}.`),e?(s=`{${s}}`,this.value[n].isFirstSid?t=`2.{${s} - 80}`:t+=s):t+=s}return t}toJSON(){let t={...super.toJSON(),value:this.toString(),sidArray:[]};for(let e=0;e<this.value.length;e++)t.sidArray.push(this.value[e].toJSON());return t}};rs.NAME="ObjectIdentifierValueBlock";var Uc,mr=class extends gt{constructor(t={}){super(t,rs),this.idBlock.tagClass=1,this.idBlock.tagNumber=6}getValue(){return this.valueBlock.toString()}setValue(t){this.valueBlock.fromString(t)}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()||"empty"}`}toJSON(){return{...super.toJSON(),value:this.getValue()}}};Uc=mr;B.ObjectIdentifier=Uc;mr.NAME="OBJECT IDENTIFIER";var Gr=class extends xe(me){constructor({valueDec:t=0,...e}={}){super(e),this.valueDec=t}fromBER(t,e,n){if(n===0)return e;let s=M.BufferSourceConverter.toUint8Array(t);if(!we(this,s,e,n))return-1;let o=s.subarray(e,e+n);this.valueHexView=new Uint8Array(n);for(let a=0;a<n&&(this.valueHexView[a]=o[a]&127,this.blockLength++,!!(o[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,o[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=Qe(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),e+this.blockLength)}toBER(t){if(this.isHexOnly){if(t)return new ArrayBuffer(this.valueHexView.byteLength);let s=this.valueHexView,o=new Uint8Array(this.blockLength);for(let i=0;i<this.blockLength-1;i++)o[i]=s[i]|128;return o[this.blockLength-1]=s[this.blockLength-1],o.buffer}let e=Ve(this.valueDec,7);if(e.byteLength===0)return this.error="Error during encoding SID value",jt;let n=new Uint8Array(e.byteLength);if(!t){let s=new Uint8Array(e),o=e.byteLength-1;for(let i=0;i<o;i++)n[i]=s[i]|128;n[o]=s[o]}return n.buffer}toString(){let t="";return this.isHexOnly?t=M.Convert.ToHex(this.valueHexView):t=this.valueDec.toString(),t}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}};Gr.NAME="relativeSidBlock";var ns=class extends Et{constructor({value:t=br,...e}={}){super(e),this.value=[],t&&this.fromString(t)}fromBER(t,e,n){let s=e;for(;n>0;){let o=new Gr;if(s=o.fromBER(t,s,n),s===-1)return this.blockLength=0,this.error=o.error,s;this.blockLength+=o.blockLength,n-=o.blockLength,this.value.push(o)}return s}toBER(t,e){let n=[];for(let s=0;s<this.value.length;s++){let o=this.value[s].toBER(t);if(o.byteLength===0)return this.error=this.value[s].error,jt;n.push(o)}return yi(n)}fromString(t){this.value=[];let e=0,n=0,s="";do{n=t.indexOf(".",e),n===-1?s=t.substring(e):s=t.substring(e,n),e=n+1;let o=new Gr;if(o.valueDec=parseInt(s,10),isNaN(o.valueDec))return!0;this.value.push(o)}while(n!==-1);return!0}toString(){let t="",e=!1;for(let n=0;n<this.value.length;n++){e=this.value[n].isHexOnly;let s=this.value[n].toString();n!==0&&(t=`${t}.`),e&&(s=`{${s}}`),t+=s}return t}toJSON(){let t={...super.toJSON(),value:this.toString(),sidArray:[]};for(let e=0;e<this.value.length;e++)t.sidArray.push(this.value[e].toJSON());return t}};ns.NAME="RelativeObjectIdentifierValueBlock";var Rc,ss=class extends gt{constructor(t={}){super(t,ns),this.idBlock.tagClass=1,this.idBlock.tagNumber=13}getValue(){return this.valueBlock.toString()}setValue(t){this.valueBlock.fromString(t)}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()||"empty"}`}toJSON(){return{...super.toJSON(),value:this.getValue()}}};Rc=ss;B.RelativeObjectIdentifier=Rc;ss.NAME="RelativeObjectIdentifier";var _c,be=class extends Pe{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=16}};_c=be;B.Sequence=_c;be.NAME="SEQUENCE";var Oc,os=class extends Pe{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=17}};Oc=os;B.Set=Oc;os.NAME="SET";var is=class extends xe(Et){constructor({...t}={}){super(t),this.isHexOnly=!0,this.value=br}toJSON(){return{...super.toJSON(),value:this.value}}};is.NAME="StringValueBlock";var as=class extends is{};as.NAME="SimpleStringValueBlock";var kt=class extends zn{constructor({...t}={}){super(t,as)}fromBuffer(t){this.valueBlock.value=String.fromCharCode.apply(null,M.BufferSourceConverter.toUint8Array(t))}fromString(t){let e=t.length,n=this.valueBlock.valueHexView=new Uint8Array(e);for(let s=0;s<e;s++)n[s]=t.charCodeAt(s);this.valueBlock.value=t}};kt.NAME="SIMPLE STRING";var cs=class extends kt{fromBuffer(t){this.valueBlock.valueHexView=M.BufferSourceConverter.toUint8Array(t);try{this.valueBlock.value=M.Convert.ToUtf8String(t)}catch(e){this.warnings.push(`Error during "decodeURIComponent": ${e}, using raw string`),this.valueBlock.value=M.Convert.ToBinary(t)}}fromString(t){this.valueBlock.valueHexView=new Uint8Array(M.Convert.FromUtf8String(t)),this.valueBlock.value=t}};cs.NAME="Utf8StringValueBlock";var Vc,ye=class extends cs{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=12}};Vc=ye;B.Utf8String=Vc;ye.NAME="UTF8String";var ls=class extends kt{fromBuffer(t){this.valueBlock.value=M.Convert.ToUtf16String(t),this.valueBlock.valueHexView=M.BufferSourceConverter.toUint8Array(t)}fromString(t){this.valueBlock.value=t,this.valueBlock.valueHexView=new Uint8Array(M.Convert.FromUtf16String(t))}};ls.NAME="BmpStringValueBlock";var Pc,us=class extends ls{constructor({...t}={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=30}};Pc=us;B.BmpString=Pc;us.NAME="BMPString";var fs=class extends kt{fromBuffer(t){let e=ArrayBuffer.isView(t)?t.slice().buffer:t.slice(0),n=new Uint8Array(e);for(let s=0;s<n.length;s+=4)n[s]=n[s+3],n[s+1]=n[s+2],n[s+2]=0,n[s+3]=0;this.valueBlock.value=String.fromCharCode.apply(null,new Uint32Array(e))}fromString(t){let e=t.length,n=this.valueBlock.valueHexView=new Uint8Array(e*4);for(let s=0;s<e;s++){let o=Ve(t.charCodeAt(s),8),i=new Uint8Array(o);if(i.length>4)continue;let a=4-i.length;for(let c=i.length-1;c>=0;c--)n[s*4+c+a]=i[c]}this.valueBlock.value=t}};fs.NAME="UniversalStringValueBlock";var Dc,hs=class extends fs{constructor({...t}={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=28}};Dc=hs;B.UniversalString=Dc;hs.NAME="UniversalString";var Mc,ds=class extends kt{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=18}};Mc=ds;B.NumericString=Mc;ds.NAME="NumericString";var Fc,ps=class extends kt{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=19}};Fc=ps;B.PrintableString=Fc;ps.NAME="PrintableString";var Hc,gs=class extends kt{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=20}};Hc=gs;B.TeletexString=Hc;gs.NAME="TeletexString";var Kc,ms=class extends kt{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=21}};Kc=ms;B.VideotexString=Kc;ms.NAME="VideotexString";var qc,bs=class extends kt{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=22}};qc=bs;B.IA5String=qc;bs.NAME="IA5String";var $c,ys=class extends kt{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=25}};$c=ys;B.GraphicString=$c;ys.NAME="GraphicString";var zc,Wr=class extends kt{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=26}};zc=Wr;B.VisibleString=zc;Wr.NAME="VisibleString";var Gc,ws=class extends kt{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=27}};Gc=ws;B.GeneralString=Gc;ws.NAME="GeneralString";var Wc,xs=class extends kt{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=29}};Wc=xs;B.CharacterString=Wc;xs.NAME="CharacterString";var jc,jr=class extends Wr{constructor({value:t,valueDate:e,...n}={}){if(super(n),this.year=0,this.month=0,this.day=0,this.hour=0,this.minute=0,this.second=0,t){this.fromString(t),this.valueBlock.valueHexView=new Uint8Array(t.length);for(let s=0;s<t.length;s++)this.valueBlock.valueHexView[s]=t.charCodeAt(s)}e&&(this.fromDate(e),this.valueBlock.valueHexView=new Uint8Array(this.toBuffer())),this.idBlock.tagClass=1,this.idBlock.tagNumber=23}fromBuffer(t){this.fromString(String.fromCharCode.apply(null,M.BufferSourceConverter.toUint8Array(t)))}toBuffer(){let t=this.toString(),e=new ArrayBuffer(t.length),n=new Uint8Array(e);for(let s=0;s<t.length;s++)n[s]=t.charCodeAt(s);return e}fromDate(t){this.year=t.getUTCFullYear(),this.month=t.getUTCMonth()+1,this.day=t.getUTCDate(),this.hour=t.getUTCHours(),this.minute=t.getUTCMinutes(),this.second=t.getUTCSeconds()}toDate(){return new Date(Date.UTC(this.year,this.month-1,this.day,this.hour,this.minute,this.second))}fromString(t){let n=/(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})Z/ig.exec(t);if(n===null){this.error="Wrong input string for conversion";return}let s=parseInt(n[1],10);s>=50?this.year=1900+s:this.year=2e3+s,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(t="iso"){if(t==="iso"){let e=new Array(7);return e[0]=Ut(this.year<2e3?this.year-1900:this.year-2e3,2),e[1]=Ut(this.month,2),e[2]=Ut(this.day,2),e[3]=Ut(this.hour,2),e[4]=Ut(this.minute,2),e[5]=Ut(this.second,2),e[6]="Z",e.join("")}return super.toString(t)}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}}};jc=jr;B.UTCTime=jc;jr.NAME="UTCTime";var Zc,vs=class extends jr{constructor(t={}){var e;super(t),(e=this.millisecond)!==null&&e!==void 0||(this.millisecond=0),this.idBlock.tagClass=1,this.idBlock.tagNumber=24}fromDate(t){super.fromDate(t),this.millisecond=t.getUTCMilliseconds()}toDate(){return new Date(Date.UTC(this.year,this.month-1,this.day,this.hour,this.minute,this.second,this.millisecond))}fromString(t){let e=!1,n="",s="",o=0,i,a=0,c=0;if(t[t.length-1]==="Z")n=t.substring(0,t.length-1),e=!0;else{let f=new Number(t[t.length-1]);if(isNaN(f.valueOf()))throw new Error("Wrong input string for conversion");n=t}if(e){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 f=1,h=n.indexOf("+"),d="";if(h===-1&&(h=n.indexOf("-"),f=-1),h!==-1){if(d=n.substring(h+1),n=n.substring(0,h),d.length!==2&&d.length!==4)throw new Error("Wrong input string for conversion");let p=parseInt(d.substring(0,2),10);if(isNaN(p.valueOf()))throw new Error("Wrong input string for conversion");if(a=f*p,d.length===4){if(p=parseInt(d.substring(2,4),10),isNaN(p.valueOf()))throw new Error("Wrong input string for conversion");c=f*p}}}let l=n.indexOf(".");if(l===-1&&(l=n.indexOf(",")),l!==-1){let f=new Number(`0${n.substring(l)}`);if(isNaN(f.valueOf()))throw new Error("Wrong input string for conversion");o=f.valueOf(),s=n.substring(0,l)}else s=n;switch(!0){case s.length===8:if(i=/(\d{4})(\d{2})(\d{2})/ig,l!==-1)throw new Error("Wrong input string for conversion");break;case s.length===10:if(i=/(\d{4})(\d{2})(\d{2})(\d{2})/ig,l!==-1){let f=60*o;this.minute=Math.floor(f),f=60*(f-this.minute),this.second=Math.floor(f),f=1e3*(f-this.second),this.millisecond=Math.floor(f)}break;case s.length===12:if(i=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})/ig,l!==-1){let f=60*o;this.second=Math.floor(f),f=1e3*(f-this.second),this.millisecond=Math.floor(f)}break;case s.length===14:if(i=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/ig,l!==-1){let f=1e3*o;this.millisecond=Math.floor(f)}break;default:throw new Error("Wrong input string for conversion")}let u=i.exec(s);if(u===null)throw new Error("Wrong input string for conversion");for(let f=1;f<u.length;f++)switch(f){case 1:this.year=parseInt(u[f],10);break;case 2:this.month=parseInt(u[f],10);break;case 3:this.day=parseInt(u[f],10);break;case 4:this.hour=parseInt(u[f],10)+a;break;case 5:this.minute=parseInt(u[f],10)+c;break;case 6:this.second=parseInt(u[f],10);break;default:throw new Error("Wrong input string for conversion")}if(e===!1){let f=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);this.year=f.getUTCFullYear(),this.month=f.getUTCMonth(),this.day=f.getUTCDay(),this.hour=f.getUTCHours(),this.minute=f.getUTCMinutes(),this.second=f.getUTCSeconds(),this.millisecond=f.getUTCMilliseconds()}}toString(t="iso"){if(t==="iso"){let e=[];return e.push(Ut(this.year,4)),e.push(Ut(this.month,2)),e.push(Ut(this.day,2)),e.push(Ut(this.hour,2)),e.push(Ut(this.minute,2)),e.push(Ut(this.second,2)),this.millisecond!==0&&(e.push("."),e.push(Ut(this.millisecond,3))),e.push("Z"),e.join("")}return super.toString(t)}toJSON(){return{...super.toJSON(),millisecond:this.millisecond}}};Zc=vs;B.GeneralizedTime=Zc;vs.NAME="GeneralizedTime";var Yc,Es=class extends ye{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=31}};Yc=Es;B.DATE=Yc;Es.NAME="DATE";var Jc,Bs=class extends ye{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=32}};Jc=Bs;B.TimeOfDay=Jc;Bs.NAME="TimeOfDay";var Xc,As=class extends ye{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=33}};Xc=As;B.DateTime=Xc;As.NAME="DateTime";var Qc,Ss=class extends ye{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=34}};Qc=Ss;B.Duration=Qc;Ss.NAME="Duration";var tl,Is=class extends ye{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=14}};tl=Is;B.TIME=tl;Is.NAME="TIME";function rt(r,t="utf8"){let e=Un[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.encoder.encode(r).substring(1)}var Zr=class extends Error{constructor(t="An error occurred while verifying a message"){super(t),this.name="VerificationError"}},Ns=class extends Error{constructor(t="Missing Web Crypto API"){super(t),this.name="WebCryptoMissingError"}};var el={get(r=globalThis){let t=r.crypto;if(t?.subtle==null)throw new Ns("Missing Web Crypto API. The most likely cause of this error is that this page is being accessed from an insecure context (i.e. not HTTPS). For more information and possible resolutions see https://github.com/libp2p/js-libp2p/blob/main/packages/crypto/README.md#web-crypto-api");return t}};var De=el;async function rl(r){let t=await De.get().subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:r,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-256"}},!0,["sign","verify"]),e=await Ed(t);return{privateKey:e[0],publicKey:e[1]}}async function nl(r,t){let e=await De.get().subtle.importKey("jwk",r,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["sign"]),n=await De.get().subtle.sign({name:"RSASSA-PKCS1-v1_5"},e,t instanceof Uint8Array?t:t.subarray());return new Uint8Array(n,0,n.byteLength)}async function sl(r,t,e){let n=await De.get().subtle.importKey("jwk",r,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["verify"]);return De.get().subtle.verify({name:"RSASSA-PKCS1-v1_5"},n,t,e instanceof Uint8Array?e:e.subarray())}async function Ed(r){if(r.privateKey==null||r.publicKey==null)throw new It("Private and public key are required");return Promise.all([De.get().subtle.exportKey("jwk",r.privateKey),De.get().subtle.exportKey("jwk",r.publicKey)])}function vi(r){if(r.kty!=="RSA")throw new It("invalid key type");if(r.n==null)throw new It("invalid key modulus");return $(r.n,"base64url").length*8}var yr=class{type="RSA";_key;_raw;_multihash;constructor(t,e){this._key=t,this._multihash=e}get raw(){return this._raw==null&&(this._raw=Yr.jwkToPkix(this._key)),this._raw}toMultihash(){return this._multihash}toCID(){return dt.createV1(114,this._multihash)}toString(){return X.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:yt(this.raw,t.raw)}verify(t,e){return sl(this._key,e,t)}},Jr=class{type="RSA";_key;_raw;publicKey;constructor(t,e){this._key=t,this.publicKey=e}get raw(){return this._raw==null&&(this._raw=Yr.jwkToPkcs1(this._key)),this._raw}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:yt(this.raw,t.raw)}sign(t){return nl(this._key,t)}};var Cs=8192,Ei=18;function ol(r){let{result:t}=xi(r),e=t.valueBlock.value;return{n:re(e[1]),e:re(e[2]),d:re(e[3]),p:re(e[4]),q:re(e[5]),dp:re(e[6]),dq:re(e[7]),qi:re(e[8]),kty:"RSA",alg:"RS256"}}function Bd(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 It("JWK was missing components");let e=new be({value:[new mt({value:0}),mt.fromBigInt(ne($(r.n,"base64url"))),mt.fromBigInt(ne($(r.e,"base64url"))),mt.fromBigInt(ne($(r.d,"base64url"))),mt.fromBigInt(ne($(r.p,"base64url"))),mt.fromBigInt(ne($(r.q,"base64url"))),mt.fromBigInt(ne($(r.dp,"base64url"))),mt.fromBigInt(ne($(r.dq,"base64url"))),mt.fromBigInt(ne($(r.qi,"base64url")))]}).toBER();return new Uint8Array(e,0,e.byteLength)}function il(r){let{result:t}=xi(r),e=t.valueBlock.value[1].valueBlock.value[0].valueBlock.value;return{kty:"RSA",n:re(e[0]),e:re(e[1])}}function Bi(r){if(r.n==null||r.e==null)throw new It("JWK was missing components");let e=new be({value:[new be({value:[new mr({value:"1.2.840.113549.1.1.1"}),new pr]}),new gr({valueHex:new be({value:[mt.fromBigInt(ne($(r.n,"base64url"))),mt.fromBigInt(ne($(r.e,"base64url")))]}).toBER()})]}).toBER();return new Uint8Array(e,0,e.byteLength)}function re(r){let t=r.valueBlock.valueHexView;for(;t[0]===0;)t=t.subarray(1);return rt(t,"base64url")}function ne(r){let t=[];return r.forEach(function(e){let n=e.toString(16);n.length%2>0&&(n=`0${n}`),t.push(n)}),BigInt("0x"+t.join(""))}function al(r){let t=ol(r);return cl(t)}function Ai(r){let t=il(r);if(vi(t)>Cs)throw new rr("Key size is too large");let e=Dn(te.encode({Type:ct.RSA,Data:r})),n=Mt(Ei,e);return new yr(t,n)}function cl(r){if(vi(r)>Cs)throw new It("Key size is too large");let t=ul(r),e=Dn(te.encode({Type:ct.RSA,Data:Bi(t.publicKey)})),n=Mt(Ei,e);return new Jr(t.privateKey,new yr(t.publicKey,n))}async function ll(r){if(r>Cs)throw new It("Key size is too large");let t=await rl(r),e=Dn(te.encode({Type:ct.RSA,Data:Bi(t.publicKey)})),n=Mt(Ei,e);return new Jr(t.privateKey,new yr(t.publicKey,n))}function ul(r){if(r==null)throw new It("Missing key parameter");return{privateKey:r,publicKey:{kty:r.kty,n:r.n,e:r.e}}}var Ad=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]),Me=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Fe=new Uint32Array(64),Si=class extends ur{constructor(){super(64,32,8,!1),this.A=Me[0]|0,this.B=Me[1]|0,this.C=Me[2]|0,this.D=Me[3]|0,this.E=Me[4]|0,this.F=Me[5]|0,this.G=Me[6]|0,this.H=Me[7]|0}get(){let{A:t,B:e,C:n,D:s,E:o,F:i,G:a,H:c}=this;return[t,e,n,s,o,i,a,c]}set(t,e,n,s,o,i,a,c){this.A=t|0,this.B=e|0,this.C=n|0,this.D=s|0,this.E=o|0,this.F=i|0,this.G=a|0,this.H=c|0}process(t,e){for(let f=0;f<16;f++,e+=4)Fe[f]=t.getUint32(e,!1);for(let f=16;f<64;f++){let h=Fe[f-15],d=Fe[f-2],p=Ft(h,7)^Ft(h,18)^h>>>3,b=Ft(d,17)^Ft(d,19)^d>>>10;Fe[f]=b+Fe[f-7]+p+Fe[f-16]|0}let{A:n,B:s,C:o,D:i,E:a,F:c,G:l,H:u}=this;for(let f=0;f<64;f++){let h=Ft(a,6)^Ft(a,11)^Ft(a,25),d=u+h+Ta(a,c,l)+Ad[f]+Fe[f]|0,b=(Ft(n,2)^Ft(n,13)^Ft(n,22))+La(n,s,o)|0;u=l,l=c,c=a,a=i+d|0,i=o,o=s,s=n,n=d+b|0}n=n+this.A|0,s=s+this.B|0,o=o+this.C|0,i=i+this.D|0,a=a+this.E|0,c=c+this.F|0,l=l+this.G|0,u=u+this.H|0,this.set(n,s,o,i,a,c,l,u)}roundClean(){Fe.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var fl=bn(()=>new Si);var Ts=class extends lr{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,ka(t);let n=Rr(e);if(this.iHash=t.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let s=this.blockLen,o=new Uint8Array(s);o.set(n.length>s?t.create().update(n).digest():n);for(let i=0;i<o.length;i++)o[i]^=54;this.iHash.update(o),this.oHash=t.create();for(let i=0;i<o.length;i++)o[i]^=106;this.oHash.update(o),o.fill(0)}update(t){return cr(this),this.iHash.update(t),this}digestInto(t){cr(this),ar(t,this.outputLen),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){let t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));let{oHash:e,iHash:n,finished:s,destroyed:o,blockLen:i,outputLen:a}=this;return t=t,t.finished=s,t.destroyed=o,t.blockLen=i,t.outputLen=a,t.oHash=e._cloneInto(t.oHash),t.iHash=n._cloneInto(t.iHash),t}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},Ii=(r,t,e)=>new Ts(r,t).update(e).digest();Ii.create=(r,t)=>new Ts(r,t);function hl(r){r.lowS!==void 0&&Ht("lowS",r.lowS),r.prehash!==void 0&&Ht("prehash",r.prehash)}function Sd(r){let t=Vr(r);Qt(t,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});let{endo:e,Fp:n,a:s}=t;if(e){if(!n.eql(s,n.ZERO))throw new Error("invalid endomorphism, can only be defined for Koblitz curves that have a=0");if(typeof e!="object"||typeof e.beta!="bigint"||typeof e.splitScalar!="function")throw new Error("invalid endomorphism, expected beta: bigint and splitScalar: function")}return Object.freeze({...t})}var{bytesToNumberBE:Id,hexToBytes:kd}=En,ve={Err:class extends Error{constructor(t=""){super(t)}},_tlv:{encode:(r,t)=>{let{Err:e}=ve;if(r<0||r>256)throw new e("tlv.encode: wrong tag");if(t.length&1)throw new e("tlv.encode: unpadded data");let n=t.length/2,s=ze(n);if(s.length/2&128)throw new e("tlv.encode: long form length too big");let o=n>127?ze(s.length/2|128):"";return ze(r)+o+s+t},decode(r,t){let{Err:e}=ve,n=0;if(r<0||r>256)throw new e("tlv.encode: wrong tag");if(t.length<2||t[n++]!==r)throw new e("tlv.decode: wrong tlv");let s=t[n++],o=!!(s&128),i=0;if(!o)i=s;else{let c=s&127;if(!c)throw new e("tlv.decode(long): indefinite length not supported");if(c>4)throw new e("tlv.decode(long): byte length is too big");let l=t.subarray(n,n+c);if(l.length!==c)throw new e("tlv.decode: length bytes not complete");if(l[0]===0)throw new e("tlv.decode(long): zero leftmost byte");for(let u of l)i=i<<8|u;if(n+=c,i<128)throw new e("tlv.decode(long): not minimal encoding")}let a=t.subarray(n,n+i);if(a.length!==i)throw new e("tlv.decode: wrong value length");return{v:a,l:t.subarray(n+i)}}},_int:{encode(r){let{Err:t}=ve;if(r<Ee)throw new t("integer: negative integers are not allowed");let e=ze(r);if(Number.parseInt(e[0],16)&8&&(e="00"+e),e.length&1)throw new t("unexpected DER parsing assertion: unpadded hex");return e},decode(r){let{Err:t}=ve;if(r[0]&128)throw new t("invalid signature integer: negative");if(r[0]===0&&!(r[1]&128))throw new t("invalid signature integer: unnecessary leading zero");return Id(r)}},toSig(r){let{Err:t,_int:e,_tlv:n}=ve,s=typeof r=="string"?kd(r):r;fr(s);let{v:o,l:i}=n.decode(48,s);if(i.length)throw new t("invalid signature: left bytes after parsing");let{v:a,l:c}=n.decode(2,o),{v:l,l:u}=n.decode(2,c);if(u.length)throw new t("invalid signature: left bytes after parsing");return{r:e.decode(a),s:e.decode(l)}},hexFromSig(r){let{_tlv:t,_int:e}=ve,n=t.encode(2,e.encode(r.r)),s=t.encode(2,e.encode(r.s)),o=n+s;return t.encode(48,o)}},Ee=BigInt(0),ft=BigInt(1),ub=BigInt(2),dl=BigInt(3),fb=BigInt(4);function Nd(r){let t=Sd(r),{Fp:e}=t,n=Le(t.n,t.nBitLength),s=t.toBytes||((b,g,v)=>{let A=g.toAffine();return de(Uint8Array.from([4]),e.toBytes(A.x),e.toBytes(A.y))}),o=t.fromBytes||(b=>{let g=b.subarray(1),v=e.fromBytes(g.subarray(0,e.BYTES)),A=e.fromBytes(g.subarray(e.BYTES,2*e.BYTES));return{x:v,y:A}});function i(b){let{a:g,b:v}=t,A=e.sqr(b),y=e.mul(A,b);return e.add(e.add(y,e.mul(b,g)),v)}if(!e.eql(e.sqr(t.Gy),i(t.Gx)))throw new Error("bad generator point: equation left != right");function a(b){return _r(b,ft,t.n)}function c(b){let{allowedPrivateKeyLengths:g,nByteLength:v,wrapPrivateKey:A,n:y}=t;if(g&&typeof b!="bigint"){if(Ne(b)&&(b=fe(b)),typeof b!="string"||!g.includes(b.length))throw new Error("invalid private key");b=b.padStart(v*2,"0")}let I;try{I=typeof b=="bigint"?b:he(nt("private key",b,v))}catch{throw new Error("invalid private key, expected hex or "+v+" bytes, got "+typeof b)}return A&&(I=Z(I,y)),Ct("private key",I,ft,y),I}function l(b){if(!(b instanceof h))throw new Error("ProjectivePoint expected")}let u=je((b,g)=>{let{px:v,py:A,pz:y}=b;if(e.eql(y,e.ONE))return{x:v,y:A};let I=b.is0();g==null&&(g=I?e.ONE:e.inv(y));let U=e.mul(v,g),L=e.mul(A,g),k=e.mul(y,g);if(I)return{x:e.ZERO,y:e.ZERO};if(!e.eql(k,e.ONE))throw new Error("invZ was invalid");return{x:U,y:L}}),f=je(b=>{if(b.is0()){if(t.allowInfinityPoint&&!e.is0(b.py))return;throw new Error("bad point: ZERO")}let{x:g,y:v}=b.toAffine();if(!e.isValid(g)||!e.isValid(v))throw new Error("bad point: x or y not FE");let A=e.sqr(v),y=i(g);if(!e.eql(A,y))throw new Error("bad point: equation left != right");if(!b.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class h{constructor(g,v,A){if(this.px=g,this.py=v,this.pz=A,g==null||!e.isValid(g))throw new Error("x required");if(v==null||!e.isValid(v))throw new Error("y required");if(A==null||!e.isValid(A))throw new Error("z required");Object.freeze(this)}static fromAffine(g){let{x:v,y:A}=g||{};if(!g||!e.isValid(v)||!e.isValid(A))throw new Error("invalid affine point");if(g instanceof h)throw new Error("projective point not allowed");let y=I=>e.eql(I,e.ZERO);return y(v)&&y(A)?h.ZERO:new h(v,A,e.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(g){let v=e.invertBatch(g.map(A=>A.pz));return g.map((A,y)=>A.toAffine(v[y])).map(h.fromAffine)}static fromHex(g){let v=h.fromAffine(o(nt("pointHex",g)));return v.assertValidity(),v}static fromPrivateKey(g){return h.BASE.multiply(c(g))}static msm(g,v){return In(h,n,g,v)}_setWindowSize(g){p.setWindowSize(this,g)}assertValidity(){f(this)}hasEvenY(){let{y:g}=this.toAffine();if(e.isOdd)return!e.isOdd(g);throw new Error("Field doesn't support isOdd")}equals(g){l(g);let{px:v,py:A,pz:y}=this,{px:I,py:U,pz:L}=g,k=e.eql(e.mul(v,L),e.mul(I,y)),T=e.eql(e.mul(A,L),e.mul(U,y));return k&&T}negate(){return new h(this.px,e.neg(this.py),this.pz)}double(){let{a:g,b:v}=t,A=e.mul(v,dl),{px:y,py:I,pz:U}=this,L=e.ZERO,k=e.ZERO,T=e.ZERO,N=e.mul(y,y),Q=e.mul(I,I),q=e.mul(U,U),D=e.mul(y,I);return D=e.add(D,D),T=e.mul(y,U),T=e.add(T,T),L=e.mul(g,T),k=e.mul(A,q),k=e.add(L,k),L=e.sub(Q,k),k=e.add(Q,k),k=e.mul(L,k),L=e.mul(D,L),T=e.mul(A,T),q=e.mul(g,q),D=e.sub(N,q),D=e.mul(g,D),D=e.add(D,T),T=e.add(N,N),N=e.add(T,N),N=e.add(N,q),N=e.mul(N,D),k=e.add(k,N),q=e.mul(I,U),q=e.add(q,q),N=e.mul(q,D),L=e.sub(L,N),T=e.mul(q,Q),T=e.add(T,T),T=e.add(T,T),new h(L,k,T)}add(g){l(g);let{px:v,py:A,pz:y}=this,{px:I,py:U,pz:L}=g,k=e.ZERO,T=e.ZERO,N=e.ZERO,Q=t.a,q=e.mul(t.b,dl),D=e.mul(v,I),it=e.mul(A,U),E=e.mul(y,L),C=e.add(v,A),w=e.add(I,U);C=e.mul(C,w),w=e.add(D,it),C=e.sub(C,w),w=e.add(v,y);let m=e.add(I,L);return w=e.mul(w,m),m=e.add(D,E),w=e.sub(w,m),m=e.add(A,y),k=e.add(U,L),m=e.mul(m,k),k=e.add(it,E),m=e.sub(m,k),N=e.mul(Q,w),k=e.mul(q,E),N=e.add(k,N),k=e.sub(it,N),N=e.add(it,N),T=e.mul(k,N),it=e.add(D,D),it=e.add(it,D),E=e.mul(Q,E),w=e.mul(q,w),it=e.add(it,E),E=e.sub(D,E),E=e.mul(Q,E),w=e.add(w,E),D=e.mul(it,w),T=e.add(T,D),D=e.mul(m,w),k=e.mul(C,k),k=e.sub(k,D),D=e.mul(C,it),N=e.mul(m,N),N=e.add(N,D),new h(k,T,N)}subtract(g){return this.add(g.negate())}is0(){return this.equals(h.ZERO)}wNAF(g){return p.wNAFCached(this,g,h.normalizeZ)}multiplyUnsafe(g){let{endo:v,n:A}=t;Ct("scalar",g,Ee,A);let y=h.ZERO;if(g===Ee)return y;if(this.is0()||g===ft)return this;if(!v||p.hasPrecomputes(this))return p.wNAFCachedUnsafe(this,g,h.normalizeZ);let{k1neg:I,k1:U,k2neg:L,k2:k}=v.splitScalar(g),T=y,N=y,Q=this;for(;U>Ee||k>Ee;)U&ft&&(T=T.add(Q)),k&ft&&(N=N.add(Q)),Q=Q.double(),U>>=ft,k>>=ft;return I&&(T=T.negate()),L&&(N=N.negate()),N=new h(e.mul(N.px,v.beta),N.py,N.pz),T.add(N)}multiply(g){let{endo:v,n:A}=t;Ct("scalar",g,ft,A);let y,I;if(v){let{k1neg:U,k1:L,k2neg:k,k2:T}=v.splitScalar(g),{p:N,f:Q}=this.wNAF(L),{p:q,f:D}=this.wNAF(T);N=p.constTimeNegate(U,N),q=p.constTimeNegate(k,q),q=new h(e.mul(q.px,v.beta),q.py,q.pz),y=N.add(q),I=Q.add(D)}else{let{p:U,f:L}=this.wNAF(g);y=U,I=L}return h.normalizeZ([y,I])[0]}multiplyAndAddUnsafe(g,v,A){let y=h.BASE,I=(L,k)=>k===Ee||k===ft||!L.equals(y)?L.multiplyUnsafe(k):L.multiply(k),U=I(this,v).add(I(g,A));return U.is0()?void 0:U}toAffine(g){return u(this,g)}isTorsionFree(){let{h:g,isTorsionFree:v}=t;if(g===ft)return!0;if(v)return v(h,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h:g,clearCofactor:v}=t;return g===ft?this:v?v(h,this):this.multiplyUnsafe(t.h)}toRawBytes(g=!0){return Ht("isCompressed",g),this.assertValidity(),s(h,this,g)}toHex(g=!0){return Ht("isCompressed",g),fe(this.toRawBytes(g))}}h.BASE=new h(t.Gx,t.Gy,e.ONE),h.ZERO=new h(e.ZERO,e.ONE,e.ZERO);let d=t.nBitLength,p=Sn(h,t.endo?Math.ceil(d/2):d);return{CURVE:t,ProjectivePoint:h,normPrivateKeyToScalar:c,weierstrassEquation:i,isWithinCurveOrder:a}}function Cd(r){let t=Vr(r);return Qt(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}function pl(r){let t=Cd(r),{Fp:e,n}=t,s=e.BYTES+1,o=2*e.BYTES+1;function i(E){return Z(E,n)}function a(E){return Bn(E,n)}let{ProjectivePoint:c,normPrivateKeyToScalar:l,weierstrassEquation:u,isWithinCurveOrder:f}=Nd({...t,toBytes(E,C,w){let m=C.toAffine(),x=e.toBytes(m.x),S=de;return Ht("isCompressed",w),w?S(Uint8Array.from([C.hasEvenY()?2:3]),x):S(Uint8Array.from([4]),x,e.toBytes(m.y))},fromBytes(E){let C=E.length,w=E[0],m=E.subarray(1);if(C===s&&(w===2||w===3)){let x=he(m);if(!_r(x,ft,e.ORDER))throw new Error("Point is not on curve");let S=u(x),R;try{R=e.sqrt(S)}catch(F){let O=F instanceof Error?": "+F.message:"";throw new Error("Point is not on curve"+O)}let _=(R&ft)===ft;return(w&1)===1!==_&&(R=e.neg(R)),{x,y:R}}else if(C===o&&w===4){let x=e.fromBytes(m.subarray(0,e.BYTES)),S=e.fromBytes(m.subarray(e.BYTES,2*e.BYTES));return{x,y:S}}else{let x=s,S=o;throw new Error("invalid Point, expected length of "+x+", or uncompressed "+S+", got "+C)}}}),h=E=>fe(Te(E,t.nByteLength));function d(E){let C=n>>ft;return E>C}function p(E){return d(E)?i(-E):E}let b=(E,C,w)=>he(E.slice(C,w));class g{constructor(C,w,m){this.r=C,this.s=w,this.recovery=m,this.assertValidity()}static fromCompact(C){let w=t.nByteLength;return C=nt("compactSignature",C,w*2),new g(b(C,0,w),b(C,w,2*w))}static fromDER(C){let{r:w,s:m}=ve.toSig(nt("DER",C));return new g(w,m)}assertValidity(){Ct("r",this.r,ft,n),Ct("s",this.s,ft,n)}addRecoveryBit(C){return new g(this.r,this.s,C)}recoverPublicKey(C){let{r:w,s:m,recovery:x}=this,S=L(nt("msgHash",C));if(x==null||![0,1,2,3].includes(x))throw new Error("recovery id invalid");let R=x===2||x===3?w+t.n:w;if(R>=e.ORDER)throw new Error("recovery id 2 or 3 invalid");let _=x&1?"03":"02",P=c.fromHex(_+h(R)),F=a(R),O=i(-S*F),j=i(m*F),J=c.BASE.multiplyAndAddUnsafe(P,O,j);if(!J)throw new Error("point at infinify");return J.assertValidity(),J}hasHighS(){return d(this.s)}normalizeS(){return this.hasHighS()?new g(this.r,i(-this.s),this.recovery):this}toDERRawBytes(){return Ge(this.toDERHex())}toDERHex(){return ve.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Ge(this.toCompactHex())}toCompactHex(){return h(this.r)+h(this.s)}}let v={isValidPrivateKey(E){try{return l(E),!0}catch{return!1}},normPrivateKeyToScalar:l,randomPrivateKey:()=>{let E=Io(t.n);return Fa(t.randomBytes(E),t.n)},precompute(E=8,C=c.BASE){return C._setWindowSize(E),C.multiply(BigInt(3)),C}};function A(E,C=!0){return c.fromPrivateKey(E).toRawBytes(C)}function y(E){let C=Ne(E),w=typeof E=="string",m=(C||w)&&E.length;return C?m===s||m===o:w?m===2*s||m===2*o:E instanceof c}function I(E,C,w=!0){if(y(E))throw new Error("first arg must be private key");if(!y(C))throw new Error("second arg must be public key");return c.fromHex(C).multiply(l(E)).toRawBytes(w)}let U=t.bits2int||function(E){if(E.length>8192)throw new Error("input is too large");let C=he(E),w=E.length*8-t.nBitLength;return w>0?C>>BigInt(w):C},L=t.bits2int_modN||function(E){return i(U(E))},k=Or(t.nBitLength);function T(E){return Ct("num < 2^"+t.nBitLength,E,Ee,k),Te(E,t.nByteLength)}function N(E,C,w=Q){if(["recovered","canonical"].some(ut=>ut in w))throw new Error("sign() legacy options not supported");let{hash:m,randomBytes:x}=t,{lowS:S,prehash:R,extraEntropy:_}=w;S==null&&(S=!0),E=nt("msgHash",E),hl(w),R&&(E=nt("prehashed msgHash",m(E)));let P=L(E),F=l(C),O=[T(F),T(P)];if(_!=null&&_!==!1){let ut=_===!0?x(e.BYTES):_;O.push(nt("extraEntropy",ut))}let j=de(...O),J=P;function lt(ut){let ht=U(ut);if(!f(ht))return;let bt=a(ht),Nt=c.BASE.multiply(ht).toAffine(),At=i(Nt.x);if(At===Ee)return;let Xt=i(bt*i(J+At*F));if(Xt===Ee)return;let ie=(Nt.x===At?0:2)|Number(Nt.y&ft),kr=Xt;return S&&d(Xt)&&(kr=p(Xt),ie^=1),new g(At,kr,ie)}return{seed:j,k2sig:lt}}let Q={lowS:t.lowS,prehash:!1},q={lowS:t.lowS,prehash:!1};function D(E,C,w=Q){let{seed:m,k2sig:x}=N(E,C,w),S=t;return Eo(S.hash.outputLen,S.nByteLength,S.hmac)(m,x)}c.BASE._setWindowSize(8);function it(E,C,w,m=q){let x=E;C=nt("msgHash",C),w=nt("publicKey",w);let{lowS:S,prehash:R,format:_}=m;if(hl(m),"strict"in m)throw new Error("options.strict was renamed to lowS");if(_!==void 0&&_!=="compact"&&_!=="der")throw new Error("format must be compact or der");let P=typeof x=="string"||Ne(x),F=!P&&!_&&typeof x=="object"&&x!==null&&typeof x.r=="bigint"&&typeof x.s=="bigint";if(!P&&!F)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let O,j;try{if(F&&(O=new g(x.r,x.s)),P){try{_!=="compact"&&(O=g.fromDER(x))}catch(ie){if(!(ie instanceof ve.Err))throw ie}!O&&_!=="der"&&(O=g.fromCompact(x))}j=c.fromHex(w)}catch{return!1}if(!O||S&&O.hasHighS())return!1;R&&(C=t.hash(C));let{r:J,s:lt}=O,ut=L(C),ht=a(lt),bt=i(ut*ht),Nt=i(J*ht),At=c.BASE.multiplyAndAddUnsafe(j,bt,Nt)?.toAffine();return At?i(At.x)===J:!1}return{CURVE:t,getPublicKey:A,getSharedSecret:I,sign:D,verify:it,ProjectivePoint:c,Signature:g,utils:v}}function Td(r){return{hash:r,hmac:(t,...e)=>Ii(r,t,go(...e)),randomBytes:yn}}function gl(r,t){let e=n=>pl({...r,...Td(n)});return Object.freeze({...e(t),create:e})}var yl=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),ml=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),Ld=BigInt(1),ki=BigInt(2),bl=(r,t)=>(r+t/ki)/t;function Ud(r){let t=yl,e=BigInt(3),n=BigInt(6),s=BigInt(11),o=BigInt(22),i=BigInt(23),a=BigInt(44),c=BigInt(88),l=r*r*r%t,u=l*l*r%t,f=et(u,e,t)*u%t,h=et(f,e,t)*u%t,d=et(h,ki,t)*l%t,p=et(d,s,t)*d%t,b=et(p,o,t)*p%t,g=et(b,a,t)*b%t,v=et(g,c,t)*g%t,A=et(v,a,t)*b%t,y=et(A,e,t)*u%t,I=et(y,i,t)*p%t,U=et(I,n,t)*l%t,L=et(U,ki,t);if(!Ni.eql(Ni.sqr(L),r))throw new Error("Cannot find square root");return L}var Ni=Le(yl,void 0,void 0,{sqrt:Ud}),tr=gl({a:BigInt(0),b:BigInt(7),Fp:Ni,n:ml,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:r=>{let t=ml,e=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-Ld*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),s=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),o=e,i=BigInt("0x100000000000000000000000000000000"),a=bl(o*r,t),c=bl(-n*r,t),l=Z(r-a*e-c*s,t),u=Z(-a*n-c*o,t),f=l>i,h=u>i;if(f&&(l=t-l),h&&(u=t-u),l>i||u>i)throw new Error("splitScalar: Endomorphism failed, k="+r);return{k1neg:f,k1:l,k2neg:h,k2:u}}}},fl),xb=BigInt(0);var vb=tr.ProjectivePoint;function Ot(r,t){t==null&&(t=r.reduce((s,o)=>s+o.length,0));let e=Lt(t),n=0;for(let s of r)e.set(s,n),n+=s.length;return e}function wl(r){return r==null?!1:typeof r.then=="function"&&typeof r.catch=="function"&&typeof r.finally=="function"}function xl(r,t,e){let n=Pr.digest(e instanceof Uint8Array?e:e.subarray());if(wl(n))return n.then(({digest:s})=>tr.verify(t,s,r)).catch(s=>{throw new Zr(String(s))});try{return tr.verify(t,n.digest,r)}catch(s){throw new Zr(String(s))}}var Ls=class{type="secp256k1";raw;_key;constructor(t){this._key=El(t),this.raw=vl(this._key)}toMultihash(){return le.digest(Ue(this))}toCID(){return dt.createV1(114,this.toMultihash())}toString(){return X.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:yt(this.raw,t.raw)}verify(t,e){return xl(this._key,e,t)}};function Ci(r){return new Ls(r)}function vl(r){return tr.ProjectivePoint.fromHex(r).toRawBytes(!0)}function El(r){try{return tr.ProjectivePoint.fromHex(r),r}catch(t){throw new rr(String(t))}}function wr(r){let{Type:t,Data:e}=te.decode(r),n=e??new Uint8Array;switch(t){case ct.RSA:return Ai(n);case ct.Ed25519:return Ro(n);case ct.secp256k1:return Ci(n);default:throw new Ke}}function Bl(r){let{Type:t,Data:e}=te.decode(r.digest),n=e??new Uint8Array;switch(t){case ct.Ed25519:return Ro(n);case ct.secp256k1:return Ci(n);default:throw new Ke}}function Ue(r){return te.encode({Type:ct[r.type],Data:r.raw})}var Sl=Symbol.for("@achingbrain/uint8arraylist");function Al(r,t){if(t==null||t<0)throw new RangeError("index is out of bounds");let e=0;for(let n of r){let s=e+n.byteLength;if(t<s)return{buf:n,index:t-e};e=s}throw new RangeError("index is out of bounds")}function Us(r){return!!r?.[Sl]}var Zt=class r{bufs;length;[Sl]=!0;constructor(...t){this.bufs=[],this.length=0,t.length>0&&this.appendAll(t)}*[Symbol.iterator](){yield*this.bufs}get byteLength(){return this.length}append(...t){this.appendAll(t)}appendAll(t){let e=0;for(let n of t)if(n instanceof Uint8Array)e+=n.byteLength,this.bufs.push(n);else if(Us(n))e+=n.byteLength,this.bufs.push(...n.bufs);else throw new Error("Could not append value, must be an Uint8Array or a Uint8ArrayList");this.length+=e}prepend(...t){this.prependAll(t)}prependAll(t){let e=0;for(let n of t.reverse())if(n instanceof Uint8Array)e+=n.byteLength,this.bufs.unshift(n);else if(Us(n))e+=n.byteLength,this.bufs.unshift(...n.bufs);else throw new Error("Could not prepend value, must be an Uint8Array or a Uint8ArrayList");this.length+=e}get(t){let e=Al(this.bufs,t);return e.buf[e.index]}set(t,e){let n=Al(this.bufs,t);n.buf[n.index]=e}write(t,e=0){if(t instanceof Uint8Array)for(let n=0;n<t.length;n++)this.set(e+n,t[n]);else if(Us(t))for(let n=0;n<t.length;n++)this.set(e+n,t.get(n));else throw new Error("Could not write value, must be an Uint8Array or a Uint8ArrayList")}consume(t){if(t=Math.trunc(t),!(Number.isNaN(t)||t<=0)){if(t===this.byteLength){this.bufs=[],this.length=0;return}for(;this.bufs.length>0;)if(t>=this.bufs[0].byteLength)t-=this.bufs[0].byteLength,this.length-=this.bufs[0].byteLength,this.bufs.shift();else{this.bufs[0]=this.bufs[0].subarray(t),this.length-=t;break}}}slice(t,e){let{bufs:n,length:s}=this._subList(t,e);return Ot(n,s)}subarray(t,e){let{bufs:n,length:s}=this._subList(t,e);return n.length===1?n[0]:Ot(n,s)}sublist(t,e){let{bufs:n,length:s}=this._subList(t,e),o=new r;return o.length=s,o.bufs=[...n],o}_subList(t,e){if(t=t??0,e=e??this.length,t<0&&(t=this.length+t),e<0&&(e=this.length+e),t<0||e>this.length)throw new RangeError("index is out of bounds");if(t===e)return{bufs:[],length:0};if(t===0&&e===this.length)return{bufs:this.bufs,length:this.length};let n=[],s=0;for(let o=0;o<this.bufs.length;o++){let i=this.bufs[o],a=s,c=a+i.byteLength;if(s=c,t>=c)continue;let l=t>=a&&t<c,u=e>a&&e<=c;if(l&&u){if(t===a&&e===c){n.push(i);break}let f=t-a;n.push(i.subarray(f,f+(e-t)));break}if(l){if(t===0){n.push(i);continue}n.push(i.subarray(t-a));continue}if(u){if(e===c){n.push(i);break}n.push(i.subarray(0,e-a));break}n.push(i)}return{bufs:n,length:e-t}}indexOf(t,e=0){if(!Us(t)&&!(t instanceof Uint8Array))throw new TypeError('The "value" argument must be a Uint8ArrayList or Uint8Array');let n=t instanceof Uint8Array?t:t.subarray();if(e=Number(e??0),isNaN(e)&&(e=0),e<0&&(e=this.length+e),e<0&&(e=0),t.length===0)return e>this.length?this.length:e;let s=n.byteLength;if(s===0)throw new TypeError("search must be at least 1 byte long");let o=256,i=new Int32Array(o);for(let f=0;f<o;f++)i[f]=-1;for(let f=0;f<s;f++)i[n[f]]=f;let a=i,c=this.byteLength-n.byteLength,l=n.byteLength-1,u;for(let f=e;f<=c;f+=u){u=0;for(let h=l;h>=0;h--){let d=this.get(f+h);if(n[h]!==d){u=Math.max(1,h-a[d]);break}}if(u===0)return f}return-1}getInt8(t){let e=this.subarray(t,t+1);return new DataView(e.buffer,e.byteOffset,e.byteLength).getInt8(0)}setInt8(t,e){let n=Lt(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setInt8(0,e),this.write(n,t)}getInt16(t,e){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt16(0,e)}setInt16(t,e,n){let s=pt(2);new DataView(s.buffer,s.byteOffset,s.byteLength).setInt16(0,e,n),this.write(s,t)}getInt32(t,e){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt32(0,e)}setInt32(t,e,n){let s=pt(4);new DataView(s.buffer,s.byteOffset,s.byteLength).setInt32(0,e,n),this.write(s,t)}getBigInt64(t,e){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigInt64(0,e)}setBigInt64(t,e,n){let s=pt(8);new DataView(s.buffer,s.byteOffset,s.byteLength).setBigInt64(0,e,n),this.write(s,t)}getUint8(t){let e=this.subarray(t,t+1);return new DataView(e.buffer,e.byteOffset,e.byteLength).getUint8(0)}setUint8(t,e){let n=Lt(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setUint8(0,e),this.write(n,t)}getUint16(t,e){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint16(0,e)}setUint16(t,e,n){let s=pt(2);new DataView(s.buffer,s.byteOffset,s.byteLength).setUint16(0,e,n),this.write(s,t)}getUint32(t,e){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint32(0,e)}setUint32(t,e,n){let s=pt(4);new DataView(s.buffer,s.byteOffset,s.byteLength).setUint32(0,e,n),this.write(s,t)}getBigUint64(t,e){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigUint64(0,e)}setBigUint64(t,e,n){let s=pt(8);new DataView(s.buffer,s.byteOffset,s.byteLength).setBigUint64(0,e,n),this.write(s,t)}getFloat32(t,e){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat32(0,e)}setFloat32(t,e,n){let s=pt(4);new DataView(s.buffer,s.byteOffset,s.byteLength).setFloat32(0,e,n),this.write(s,t)}getFloat64(t,e){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat64(0,e)}setFloat64(t,e,n){let s=pt(8);new DataView(s.buffer,s.byteOffset,s.byteLength).setFloat64(0,e,n),this.write(s,t)}equals(t){if(t==null||!(t instanceof r)||t.bufs.length!==this.bufs.length)return!1;for(let e=0;e<this.bufs.length;e++)if(!yt(this.bufs[e],t.bufs[e]))return!1;return!0}static fromUint8Arrays(t,e){let n=new r;return n.bufs=t,e==null&&(e=t.reduce((s,o)=>s+o.byteLength,0)),n.length=e,n}};var Xr;(function(r){let t;r.codec=()=>(t==null&&(t=Gt((e,n,s={})=>{s.lengthDelimited!==!1&&n.fork(),e.publicKey!=null&&e.publicKey.byteLength>0&&(n.uint32(10),n.bytes(e.publicKey)),e.payloadType!=null&&e.payloadType.byteLength>0&&(n.uint32(18),n.bytes(e.payloadType)),e.payload!=null&&e.payload.byteLength>0&&(n.uint32(26),n.bytes(e.payload)),e.signature!=null&&e.signature.byteLength>0&&(n.uint32(42),n.bytes(e.signature)),s.lengthDelimited!==!1&&n.ldelim()},(e,n,s={})=>{let o={publicKey:pt(0),payloadType:pt(0),payload:pt(0),signature:pt(0)},i=n==null?e.len:e.pos+n;for(;e.pos<i;){let a=e.uint32();switch(a>>>3){case 1:{o.publicKey=e.bytes();break}case 2:{o.payloadType=e.bytes();break}case 3:{o.payload=e.bytes();break}case 5:{o.signature=e.bytes();break}default:{e.skipType(a&7);break}}}return o})),t),r.encode=e=>zt(e,r.codec()),r.decode=(e,n)=>$t(e,r.codec(),n)})(Xr||(Xr={}));var Rs=class extends Error{constructor(t="Invalid signature"){super(t),this.name="InvalidSignatureError"}};var se=class r{static createFromProtobuf=async t=>{let e=Xr.decode(t),n=wr(e.publicKey);return new r({publicKey:n,payloadType:e.payloadType,payload:e.payload,signature:e.signature})};static seal=async(t,e)=>{if(e==null)throw new Error("Missing private key");let n=t.domain,s=t.codec,o=t.marshal(),i=Il(n,s,o),a=await e.sign(i.subarray());return new r({publicKey:e.publicKey,payloadType:s,payload:o,signature:a})};static openAndCertify=async(t,e)=>{let n=await r.createFromProtobuf(t);if(!await n.validate(e))throw new Rs("Envelope signature is not valid for the given domain");return n};publicKey;payloadType;payload;signature;marshaled;constructor(t){let{publicKey:e,payloadType:n,payload:s,signature:o}=t;this.publicKey=e,this.payloadType=n,this.payload=s,this.signature=o}marshal(){return this.marshaled==null&&(this.marshaled=Xr.encode({publicKey:Ue(this.publicKey),payloadType:this.payloadType,payload:this.payload.subarray(),signature:this.signature})),this.marshaled}equals(t){return yt(this.marshal(),t.marshal())}async validate(t){let e=Il(t,this.payloadType,this.payload);return this.publicKey.verify(e.subarray(),this.signature)}},Il=(r,t,e)=>{let n=$(r),s=Vt(n.byteLength),o=Vt(t.length),i=Vt(e.length);return new Zt(s,n,o,t,i,e)};var kl=Symbol.for("nodejs.util.inspect.custom"),Rd=114,Qr=class{type;multihash;publicKey;string;constructor(t){this.type=t.type,this.multihash=t.multihash,Object.defineProperty(this,"string",{enumerable:!1,writable:!0})}get[Symbol.toStringTag](){return`PeerId(${this.toString()})`}[no]=!0;toString(){return this.string==null&&(this.string=X.encode(this.multihash.bytes).slice(1)),this.string}toMultihash(){return this.multihash}toCID(){return dt.createV1(Rd,this.multihash)}toJSON(){return this.toString()}equals(t){if(t==null)return!1;if(t instanceof Uint8Array)return yt(this.multihash.bytes,t);if(typeof t=="string")return this.toString()===t;if(t?.toMultihash()?.bytes!=null)return yt(this.multihash.bytes,t.toMultihash().bytes);throw new Error("not valid Id")}[kl](){return`PeerId(${this.toString()})`}},tn=class extends Qr{type="RSA";publicKey;constructor(t){super({...t,type:"RSA"}),this.publicKey=t.publicKey}},en=class extends Qr{type="Ed25519";publicKey;constructor(t){super({...t,type:"Ed25519"}),this.publicKey=t.publicKey}},rn=class extends Qr{type="secp256k1";publicKey;constructor(t){super({...t,type:"secp256k1"}),this.publicKey=t.publicKey}},_d=2336,nn=class{type="url";multihash;publicKey;url;constructor(t){this.url=t.toString(),this.multihash=le.digest($(this.url))}[kl](){return`PeerId(${this.url})`}[no]=!0;toString(){return this.toCID().toString()}toMultihash(){return this.multihash}toCID(){return dt.createV1(_d,this.toMultihash())}toJSON(){return this.toString()}equals(t){return t==null?!1:(t instanceof Uint8Array&&(t=rt(t)),t.toString()===this.toString())}};var Od=114,Nl=2336;function Cl(r){if(r.type==="Ed25519")return new en({multihash:r.toCID().multihash,publicKey:r});if(r.type==="secp256k1")return new rn({multihash:r.toCID().multihash,publicKey:r});if(r.type==="RSA")return new tn({multihash:r.toCID().multihash,publicKey:r});throw new Ke}function Ti(r){if(Pd(r))return new tn({multihash:r});if(Vd(r))try{let t=Bl(r);if(t.type==="Ed25519")return new en({multihash:r,publicKey:t});if(t.type==="secp256k1")return new rn({multihash:r,publicKey:t})}catch{let e=rt(r.digest);return new nn(new URL(e))}throw new hn("Supplied PeerID Multihash is invalid")}function _s(r){if(r?.multihash==null||r.version==null||r.version===1&&r.code!==Od&&r.code!==Nl)throw new fn("Supplied PeerID CID is invalid");if(r.code===Nl){let t=rt(r.multihash.digest);return new nn(new URL(t))}return Ti(r.multihash)}function Vd(r){return r.code===le.code}function Pd(r){return r.code===Pr.code}function Tl(r,t){let e=(n,s)=>n.toString().localeCompare(s.toString());return r.length!==t.length?!1:(t.sort(e),r.sort(e).every((n,s)=>t[s].equals(n)))}var Os=class{index=0;input="";new(t){return this.index=0,this.input=t,this}readAtomically(t){let e=this.index,n=t();return n===void 0&&(this.index=e),n}parseWith(t){let e=t();if(this.index===this.input.length)return e}peekChar(){if(!(this.index>=this.input.length))return this.input[this.index]}readChar(){if(!(this.index>=this.input.length))return this.input[this.index++]}readGivenChar(t){return this.readAtomically(()=>{let e=this.readChar();if(e===t)return e})}readSeparator(t,e,n){return this.readAtomically(()=>{if(!(e>0&&this.readGivenChar(t)===void 0))return n()})}readNumber(t,e,n,s){return this.readAtomically(()=>{let o=0,i=0,a=this.peekChar();if(a===void 0)return;let c=a==="0",l=2**(8*s)-1;for(;;){let u=this.readAtomically(()=>{let f=this.readChar();if(f===void 0)return;let h=Number.parseInt(f,t);if(!Number.isNaN(h))return h});if(u===void 0)break;if(o*=t,o+=u,o>l||(i+=1,e!==void 0&&i>e))return}if(i!==0)return!n&&c&&i>1?void 0:o})}readIPv4Addr(){return this.readAtomically(()=>{let t=new Uint8Array(4);for(let e=0;e<t.length;e++){let n=this.readSeparator(".",e,()=>this.readNumber(10,3,!1,1));if(n===void 0)return;t[e]=n}return t})}readIPv6Addr(){let t=e=>{for(let n=0;n<e.length/2;n++){let s=n*2;if(n<e.length-3){let i=this.readSeparator(":",n,()=>this.readIPv4Addr());if(i!==void 0)return e[s]=i[0],e[s+1]=i[1],e[s+2]=i[2],e[s+3]=i[3],[s+4,!0]}let o=this.readSeparator(":",n,()=>this.readNumber(16,4,!0,2));if(o===void 0)return[s,!1];e[s]=o>>8,e[s+1]=o&255}return[e.length,!1]};return this.readAtomically(()=>{let e=new Uint8Array(16),[n,s]=t(e);if(n===16)return e;if(s||this.readGivenChar(":")===void 0||this.readGivenChar(":")===void 0)return;let o=new Uint8Array(14),i=16-(n+2),[a]=t(o.subarray(0,i));return e.set(o.subarray(0,a),16-a),e})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var Ll=45,Dd=15,xr=new Os;function Li(r){if(!(r.length>Dd))return xr.new(r).parseWith(()=>xr.readIPv4Addr())}function Ui(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>Ll))return xr.new(r).parseWith(()=>xr.readIPv6Addr())}function Vs(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>Ll))return xr.new(r).parseWith(()=>xr.readIPAddr())}var Xy=parseInt("0xFFFF",16),Qy=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);function vr(r){return!!Li(r)}function Er(r){return!!Ui(r)}function Ps(r){return!!Vs(r)}var _l=vr,qd=Er,Ri=function(r){let t=0;if(r=r.toString().trim(),_l(r)){let e=new Uint8Array(t+4);return r.split(/\./g).forEach(n=>{e[t++]=parseInt(n,10)&255}),e}if(qd(r)){let e=r.split(":",8),n;for(n=0;n<e.length;n++){let o=_l(e[n]),i;o&&(i=Ri(e[n]),e[n]=rt(i.slice(0,2),"base16")),i!=null&&++n<8&&e.splice(n,0,rt(i.slice(2,4),"base16"))}if(e[0]==="")for(;e.length<8;)e.unshift("0");else if(e[e.length-1]==="")for(;e.length<8;)e.push("0");else if(e.length<8){for(n=0;n<e.length&&e[n]!=="";n++);let o=[n,1];for(n=9-e.length;n>0;n--)o.push("0");e.splice.apply(e,o)}let s=new Uint8Array(t+16);for(n=0;n<e.length;n++){let o=parseInt(e[n],16);s[t++]=o>>8&255,s[t++]=o&255}return s}throw new Error("invalid ip address")},Ol=function(r,t=0,e){t=~~t,e=e??r.length-t;let n=new DataView(r.buffer);if(e===4){let s=[];for(let o=0;o<e;o++)s.push(r[t+o]);return s.join(".")}if(e===16){let s=[];for(let o=0;o<e;o+=2)s.push(n.getUint16(t+o).toString(16));return s.join(":").replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}return""};var Br={},_i={},zd=[[4,32,"ip4"],[6,16,"tcp"],[33,16,"dccp"],[41,128,"ip6"],[42,-1,"ip6zone"],[43,8,"ipcidr"],[53,-1,"dns",!0],[54,-1,"dns4",!0],[55,-1,"dns6",!0],[56,-1,"dnsaddr",!0],[132,16,"sctp"],[273,16,"udp"],[275,0,"p2p-webrtc-star"],[276,0,"p2p-webrtc-direct"],[277,0,"p2p-stardust"],[280,0,"webrtc-direct"],[281,0,"webrtc"],[290,0,"p2p-circuit"],[301,0,"udt"],[302,0,"utp"],[400,-1,"unix",!1,!0],[421,-1,"ipfs"],[421,-1,"p2p"],[443,0,"https"],[444,96,"onion"],[445,296,"onion3"],[446,-1,"garlic64"],[448,0,"tls"],[449,-1,"sni"],[460,0,"quic"],[461,0,"quic-v1"],[465,0,"webtransport"],[466,-1,"certhash"],[477,0,"ws"],[478,0,"wss"],[479,0,"p2p-websocket-star"],[480,0,"http"],[481,-1,"http-path"],[777,-1,"memory"]];zd.forEach(r=>{let t=Gd(...r);_i[t.code]=t,Br[t.name]=t});function Gd(r,t,e,n,s){return{code:r,size:t,name:e,resolvable:!!n,path:!!s}}function z(r){if(typeof r=="number"){if(_i[r]!=null)return _i[r];throw new Error(`no protocol with code: ${r}`)}else if(typeof r=="string"){if(Br[r]!=null)return Br[r];throw new Error(`no protocol with name: ${r}`)}throw new Error(`invalid protocol id type: ${typeof r}`)}var Vw=z("ip4"),Pw=z("ip6"),Dw=z("ipcidr");function Di(r,t){switch(z(r).code){case 4:case 41:return jd(t);case 42:return Pi(t);case 6:case 273:case 33:case 132:return Dl(t).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return Pi(t);case 421:return Xd(t);case 444:return Pl(t);case 445:return Pl(t);case 466:return Jd(t);case 481:return globalThis.encodeURIComponent(Pi(t));default:return rt(t,"base16")}}function Mi(r,t){switch(z(r).code){case 4:return Vl(t);case 41:return Vl(t);case 42:return Vi(t);case 6:case 273:case 33:case 132:return Fi(parseInt(t,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return Vi(t);case 421:return Zd(t);case 444:return Qd(t);case 445:return t0(t);case 466:return Yd(t);case 481:return Vi(globalThis.decodeURIComponent(t));default:return $(t,"base16")}}var Oi=Object.values(Dr).map(r=>r.decoder),Wd=function(){let r=Oi[0].or(Oi[1]);return Oi.slice(2).forEach(t=>r=r.or(t)),r}();function Vl(r){if(!Ps(r))throw new Error("invalid ip address");return Ri(r)}function jd(r){let t=Ol(r,0,r.length);if(t==null)throw new Error("ipBuff is required");if(!Ps(t))throw new Error("invalid ip address");return t}function Fi(r){let t=new ArrayBuffer(2);return new DataView(t).setUint16(0,r),new Uint8Array(t)}function Dl(r){return new DataView(r.buffer).getUint16(r.byteOffset)}function Vi(r){let t=$(r),e=Uint8Array.from(Vt(t.length));return Ot([e,t],e.length+t.length)}function Pi(r){let t=pe(r);if(r=r.slice(xt(t)),r.length!==t)throw new Error("inconsistent lengths");return rt(r)}function Zd(r){let t;r[0]==="Q"||r[0]==="1"?t=qe(X.decode(`z${r}`)).bytes:t=dt.parse(r).multihash.bytes;let e=Uint8Array.from(Vt(t.length));return Ot([e,t],e.length+t.length)}function Yd(r){let t=Wd.decode(r),e=Uint8Array.from(Vt(t.length));return Ot([e,t],e.length+t.length)}function Jd(r){let t=pe(r),e=r.slice(xt(t));if(e.length!==t)throw new Error("inconsistent lengths");return"u"+rt(e,"base64url")}function Xd(r){let t=pe(r),e=r.slice(xt(t));if(e.length!==t)throw new Error("inconsistent lengths");return rt(e,"base58btc")}function Qd(r){let t=r.split(":");if(t.length!==2)throw new Error(`failed to parse onion addr: ["'${t.join('", "')}'"]' does not contain a port number`);if(t[0].length!==16)throw new Error(`failed to parse onion addr: ${t[0]} not a Tor onion address.`);let e=ce.decode("b"+t[0]),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let s=Fi(n);return Ot([e,s],e.length+s.length)}function t0(r){let t=r.split(":");if(t.length!==2)throw new Error(`failed to parse onion addr: ["'${t.join('", "')}'"]' does not contain a port number`);if(t[0].length!==56)throw new Error(`failed to parse onion addr: ${t[0]} not a Tor onion3 address.`);let e=ce.decode(`b${t[0]}`),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let s=Fi(n);return Ot([e,s],e.length+s.length)}function Pl(r){let t=r.slice(0,r.length-2),e=r.slice(r.length-2),n=rt(t,"base32"),s=Dl(e);return`${n}:${s}`}function Ml(r){r=Hi(r);let t=[],e=[],n=null,s=r.split("/").slice(1);if(s.length===1&&s[0]==="")return{bytes:new Uint8Array,string:"/",tuples:[],stringTuples:[],path:null};for(let o=0;o<s.length;o++){let i=s[o],a=z(i);if(a.size===0){t.push([a.code]),e.push([a.code]);continue}if(o++,o>=s.length)throw Hl("invalid address: "+r);if(a.path===!0){n=Hi(s.slice(o).join("/")),t.push([a.code,Mi(a.code,n)]),e.push([a.code,n]);break}let c=Mi(a.code,s[o]);t.push([a.code,c]),e.push([a.code,Di(a.code,c)])}return{string:Fl(e),bytes:qi(t),tuples:t,stringTuples:e,path:n}}function Ki(r){let t=[],e=[],n=null,s=0;for(;s<r.length;){let o=pe(r,s),i=xt(o),a=z(o),c=e0(a,r.slice(s+i));if(c===0){t.push([o]),e.push([o]),s+=i;continue}let l=r.slice(s+i,s+i+c);if(s+=c+i,s>r.length)throw Hl("Invalid address Uint8Array: "+rt(r,"base16"));t.push([o,l]);let u=Di(o,l);if(e.push([o,u]),a.path===!0){n=u;break}}return{bytes:Uint8Array.from(r),string:Fl(e),tuples:t,stringTuples:e,path:n}}function Fl(r){let t=[];return r.map(e=>{let n=z(e[0]);return t.push(n.name),e.length>1&&e[1]!=null&&t.push(e[1]),null}),Hi(t.join("/"))}function qi(r){return Ot(r.map(t=>{let e=z(t[0]),n=Uint8Array.from(Vt(e.code));return t.length>1&&t[1]!=null&&(n=Ot([n,t[1]])),n}))}function e0(r,t){if(r.size>0)return r.size/8;if(r.size===0)return 0;{let e=pe(t instanceof Uint8Array?t:Uint8Array.from(t));return e+xt(e)}}function Hi(r){return"/"+r.trim().split("/").filter(t=>t).join("/")}function Hl(r){return new Error("Error parsing address: "+r)}var r0=Symbol.for("nodejs.util.inspect.custom"),zi=Symbol.for("@multiformats/js-multiaddr/multiaddr"),n0=[z("dns").code,z("dns4").code,z("dns6").code,z("dnsaddr").code],$i=class extends Error{constructor(t="No available resolver"){super(t),this.name="NoAvailableResolverError"}},Ds=class r{bytes;#e;#t;#r;#n;[zi]=!0;constructor(t){t==null&&(t="");let e;if(t instanceof Uint8Array)e=Ki(t);else if(typeof t=="string"){if(t.length>0&&t.charAt(0)!=="/")throw new Error(`multiaddr "${t}" must start with a "/"`);e=Ml(t)}else if(ql(t))e=Ki(t.bytes);else throw new Error("addr must be a string, Buffer, or another Multiaddr");this.bytes=e.bytes,this.#e=e.string,this.#t=e.tuples,this.#r=e.stringTuples,this.#n=e.path}toString(){return this.#e}toJSON(){return this.toString()}toOptions(){let t,e,n,s,o="",i=z("tcp"),a=z("udp"),c=z("ip4"),l=z("ip6"),u=z("dns6"),f=z("ip6zone");for(let[d,p]of this.stringTuples())d===f.code&&(o=`%${p??""}`),n0.includes(d)&&(e=i.name,s=443,n=`${p??""}${o}`,t=d===u.code?6:4),(d===i.code||d===a.code)&&(e=z(d).name,s=parseInt(p??"")),(d===c.code||d===l.code)&&(e=z(d).name,n=`${p??""}${o}`,t=d===l.code?6:4);if(t==null||e==null||n==null||s==null)throw new Error('multiaddr must have a valid format: "/{ip4, ip6, dns4, dns6, dnsaddr}/{address}/{tcp, udp}/{port}".');return{family:t,host:n,transport:e,port:s}}protos(){return this.#t.map(([t])=>Object.assign({},z(t)))}protoCodes(){return this.#t.map(([t])=>t)}protoNames(){return this.#t.map(([t])=>z(t).name)}tuples(){return this.#t.map(([t,e])=>e==null?[t]:[t,e])}stringTuples(){return this.#r.map(([t,e])=>e==null?[t]:[t,e])}encapsulate(t){return t=new r(t),new r(this.toString()+t.toString())}decapsulate(t){let e=t.toString(),n=this.toString(),s=n.lastIndexOf(e);if(s<0)throw new Error(`Address ${this.toString()} does not contain subaddress: ${t.toString()}`);return new r(n.slice(0,s))}decapsulateCode(t){let e=this.tuples();for(let n=e.length-1;n>=0;n--)if(e[n][0]===t)return new r(qi(e.slice(0,n)));return this}getPeerId(){try{let t=[];this.stringTuples().forEach(([n,s])=>{n===Br.p2p.code&&t.push([n,s]),n===Br["p2p-circuit"].code&&(t=[])});let e=t.pop();if(e?.[1]!=null){let n=e[1];return n[0]==="Q"||n[0]==="1"?rt(X.decode(`z${n}`),"base58btc"):rt(dt.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){return this.#n}equals(t){return yt(this.bytes,t.bytes)}async resolve(t){let e=this.protos().find(o=>o.resolvable);if(e==null)return[this];let n=Kl.get(e.name);if(n==null)throw new $i(`no available resolver for ${e.name}`);return(await n(this,t)).map(o=>oe(o))}nodeAddress(){let t=this.toOptions();if(t.transport!=="tcp"&&t.transport!=="udp")throw new Error(`multiaddr must have a valid format - no protocol with name: "${t.transport}". Must have a valid transport protocol: "{tcp, udp}"`);return{family:t.family,address:t.host,port:t.port}}isThinWaistAddress(t){let e=(t??this).protos();return!(e.length!==2||e[0].code!==4&&e[0].code!==41||e[1].code!==6&&e[1].code!==273)}[r0](){return`Multiaddr(${this.#e})`}};var Kl=new Map;function ql(r){return!!r?.[zi]}function oe(r){return new Ds(r)}var $l="libp2p-peer-record",zl=Uint8Array.from([3,1]);var sn;(function(r){let t;(function(n){let s;n.codec=()=>(s==null&&(s=Gt((o,i,a={})=>{a.lengthDelimited!==!1&&i.fork(),o.multiaddr!=null&&o.multiaddr.byteLength>0&&(i.uint32(10),i.bytes(o.multiaddr)),a.lengthDelimited!==!1&&i.ldelim()},(o,i,a={})=>{let c={multiaddr:pt(0)},l=i==null?o.len:o.pos+i;for(;o.pos<l;){let u=o.uint32();switch(u>>>3){case 1:{c.multiaddr=o.bytes();break}default:{o.skipType(u&7);break}}}return c})),s),n.encode=o=>zt(o,n.codec()),n.decode=(o,i)=>$t(o,n.codec(),i)})(t=r.AddressInfo||(r.AddressInfo={}));let e;r.codec=()=>(e==null&&(e=Gt((n,s,o={})=>{if(o.lengthDelimited!==!1&&s.fork(),n.peerId!=null&&n.peerId.byteLength>0&&(s.uint32(10),s.bytes(n.peerId)),n.seq!=null&&n.seq!==0n&&(s.uint32(16),s.uint64(n.seq)),n.addresses!=null)for(let i of n.addresses)s.uint32(26),r.AddressInfo.codec().encode(i,s);o.lengthDelimited!==!1&&s.ldelim()},(n,s,o={})=>{let i={peerId:pt(0),seq:0n,addresses:[]},a=s==null?n.len:n.pos+s;for(;n.pos<a;){let c=n.uint32();switch(c>>>3){case 1:{i.peerId=n.bytes();break}case 2:{i.seq=n.uint64();break}case 3:{if(o.limits?.addresses!=null&&i.addresses.length===o.limits.addresses)throw new Xe('Decode error - map field "addresses" had too many elements');i.addresses.push(r.AddressInfo.codec().decode(n,n.uint32(),{limits:o.limits?.addresses$}));break}default:{n.skipType(c&7);break}}}return i})),e),r.encode=n=>zt(n,r.codec()),r.decode=(n,s)=>$t(n,r.codec(),s)})(sn||(sn={}));var Yt=class r{static createFromProtobuf=t=>{let e=sn.decode(t),n=Ti(qe(e.peerId)),s=(e.addresses??[]).map(i=>oe(i.multiaddr)),o=e.seq;return new r({peerId:n,multiaddrs:s,seqNumber:o})};static DOMAIN=$l;static CODEC=zl;peerId;multiaddrs;seqNumber;domain=r.DOMAIN;codec=r.CODEC;marshaled;constructor(t){let{peerId:e,multiaddrs:n,seqNumber:s}=t;this.peerId=e,this.multiaddrs=n??[],this.seqNumber=s??BigInt(Date.now())}marshal(){return this.marshaled==null&&(this.marshaled=sn.encode({peerId:this.peerId.toMultihash().bytes,seq:BigInt(this.seqNumber),addresses:this.multiaddrs.map(t=>({multiaddr:t.bytes}))})),this.marshaled}equals(t){return!(!(t instanceof r)||!this.peerId.equals(t.peerId)||this.seqNumber!==t.seqNumber||!Tl(this.multiaddrs,t.multiaddrs))}};function s0(r){return r[Symbol.asyncIterator]!=null}function o0(r){if(s0(r))return(async()=>{for await(let t of r);})();for(let t of r);}var Gl=o0;function Jt(){let r={};return r.promise=new Promise((t,e)=>{r.resolve=t,r.reject=e}),r}var Ms=globalThis.CustomEvent??Event;async function*Gi(r,t={}){let e=t.concurrency??1/0;e<1&&(e=1/0);let n=t.ordered==null?!1:t.ordered,s=new EventTarget,o=[],i=Jt(),a=Jt(),c=!1,l,u=!1;s.addEventListener("task-complete",()=>{a.resolve()}),Promise.resolve().then(async()=>{try{for await(let p of r){if(o.length===e&&(i=Jt(),await i.promise),u)break;let b={done:!1};o.push(b),p().then(g=>{b.done=!0,b.ok=!0,b.value=g,s.dispatchEvent(new Ms("task-complete"))},g=>{b.done=!0,b.err=g,s.dispatchEvent(new Ms("task-complete"))})}c=!0,s.dispatchEvent(new Ms("task-complete"))}catch(p){l=p,s.dispatchEvent(new Ms("task-complete"))}});function f(){return n?o[0]?.done:!!o.find(p=>p.done)}function*h(){for(;o.length>0&&o[0].done;){let p=o[0];if(o.shift(),p.ok)yield p.value;else throw u=!0,i.resolve(),p.err;i.resolve()}}function*d(){for(;f();)for(let p=0;p<o.length;p++)if(o[p].done){let b=o[p];if(o.splice(p,1),p--,b.ok)yield b.value;else throw u=!0,i.resolve(),b.err;i.resolve()}}for(;;){if(f()||(a=Jt(),await a.promise),l!=null)throw l;if(n?yield*h():yield*d(),c&&o.length===0)break}}var Fs=class extends Error{type;code;constructor(t,e,n){super(t??"The operation was aborted"),this.type="aborted",this.name=n??"AbortError",this.code=e??"ABORT_ERR"}};async function Wl(r,t,e){if(t==null)return r;if(t.aborted)return Promise.reject(new Fs(e?.errorMessage,e?.errorCode,e?.errorName));let n,s=new Fs(e?.errorMessage,e?.errorCode,e?.errorName);try{return await Promise.race([r,new Promise((o,i)=>{n=()=>{i(s)},t.addEventListener("abort",n)})])}finally{n!=null&&t.removeEventListener("abort",n)}}var Wi=class{readNext;haveNext;ended;nextResult;constructor(){this.ended=!1,this.readNext=Jt(),this.haveNext=Jt()}[Symbol.asyncIterator](){return this}async next(){if(this.nextResult==null&&await this.haveNext.promise,this.nextResult==null)throw new Error("HaveNext promise resolved but nextResult was undefined");let t=this.nextResult;return this.nextResult=void 0,this.readNext.resolve(),this.readNext=Jt(),t}async throw(t){return this.ended=!0,t!=null&&(this.haveNext.promise.catch(()=>{}),this.haveNext.reject(t)),{done:!0,value:void 0}}async return(){let t={done:!0,value:void 0};return await this._push(void 0),t}async push(t,e){await this._push(t,e)}async end(t,e){t!=null?await this.throw(t):await this._push(void 0,e)}async _push(t,e){if(t!=null&&this.ended)throw new Error("Cannot push value onto an ended pushable");for(;this.nextResult!=null;)await this.readNext.promise;t!=null?this.nextResult={done:!1,value:t}:(this.ended=!0,this.nextResult={done:!0,value:void 0}),this.haveNext.resolve(),this.haveNext=Jt(),await Wl(this.readNext.promise,e?.signal,e)}};function jl(){return new Wi}var Hs=class extends Error{name="UnexpectedEOFError";code="ERR_UNEXPECTED_EOF"};var ji=class extends Error{code;constructor(t,e){super(t),this.code=e}},Zi=class extends ji{type;constructor(t){super(t,"ABORT_ERR"),this.type="aborted",this.name="AbortError"}};function Zl(r,t){let e=jl();r.sink(e).catch(async i=>{await e.end(i)}),r.sink=async i=>{for await(let a of i)await e.push(a);await e.end()};let n=r.source;r.source[Symbol.iterator]!=null?n=r.source[Symbol.iterator]():r.source[Symbol.asyncIterator]!=null&&(n=r.source[Symbol.asyncIterator]());let s=new Zt;return{read:async(i,a)=>{a?.signal?.throwIfAborted();let c,l=new Promise((u,f)=>{c=()=>{f(new Zi("Read aborted"))},a?.signal?.addEventListener("abort",c)});try{if(i==null){let{done:f,value:h}=await Promise.race([n.next(),l]);return f===!0?new Zt:h}for(;s.byteLength<i;){let{value:f,done:h}=await Promise.race([n.next(),l]);if(h===!0)throw new Hs("unexpected end of input");s.append(f)}let u=s.sublist(0,i);return s.consume(i),u}finally{c!=null&&a?.signal?.removeEventListener("abort",c)}},write:async(i,a)=>{a?.signal?.throwIfAborted(),i instanceof Uint8Array?await e.push(i,a):await e.push(i.subarray(),a)},unwrap:()=>{if(s.byteLength>0){let i=r.source;r.source=async function*(){t?.yieldBytes===!1?yield s:yield*s,yield*i}()}return r}}}var Ks=class extends Error{name="InvalidMessageLengthError";code="ERR_INVALID_MSG_LENGTH"},qs=class extends Error{name="InvalidDataLengthError";code="ERR_MSG_DATA_TOO_LONG"},$s=class extends Error{name="InvalidDataLengthLengthError";code="ERR_MSG_LENGTH_TOO_LONG"};function Yl(r,t={}){let e=Zl(r,t);t.maxDataLength!=null&&t.maxLengthLength==null&&(t.maxLengthLength=xt(t.maxDataLength));let n=t?.lengthDecoder??pe,s=t?.lengthEncoder??Vt;return{read:async i=>{let a=-1,c=new Zt;for(;;){c.append(await e.read(1,i));try{a=n(c)}catch(l){if(l instanceof RangeError)continue;throw l}if(a<0)throw new Ks("Invalid message length");if(t?.maxLengthLength!=null&&c.byteLength>t.maxLengthLength)throw new $s("message length length too long");if(a>-1)break}if(t?.maxDataLength!=null&&a>t.maxDataLength)throw new qs("message length too long");return e.read(a,i)},write:async(i,a)=>{await e.write(new Zt(s(i.byteLength),i),a)},writeV:async(i,a)=>{let c=new Zt(...i.flatMap(l=>[s(l.byteLength),l]));await e.write(c,a)},unwrap:()=>e.unwrap()}}function Ar(r,t){let e=Yl(r,t),n={read:async(s,o)=>{let i=await e.read(o);return s.decode(i)},write:async(s,o,i)=>{await e.write(o.encode(s),i)},writeV:async(s,o,i)=>{await e.writeV(s.map(a=>o.encode(a)),i)},pb:s=>({read:async o=>n.read(s,o),write:async(o,i)=>n.write(o,s,i),writeV:async(o,i)=>n.writeV(o,s,i),unwrap:()=>n}),unwrap:()=>e.unwrap()};return n}var Jl="0.1.0",Xl="id",Ql="id/push",tu="1.0.0",eu="1.0.0";var He;(function(r){let t;r.codec=()=>(t==null&&(t=Gt((e,n,s={})=>{if(s.lengthDelimited!==!1&&n.fork(),e.protocolVersion!=null&&(n.uint32(42),n.string(e.protocolVersion)),e.agentVersion!=null&&(n.uint32(50),n.string(e.agentVersion)),e.publicKey!=null&&(n.uint32(10),n.bytes(e.publicKey)),e.listenAddrs!=null)for(let o of e.listenAddrs)n.uint32(18),n.bytes(o);if(e.observedAddr!=null&&(n.uint32(34),n.bytes(e.observedAddr)),e.protocols!=null)for(let o of e.protocols)n.uint32(26),n.string(o);e.signedPeerRecord!=null&&(n.uint32(66),n.bytes(e.signedPeerRecord)),s.lengthDelimited!==!1&&n.ldelim()},(e,n,s={})=>{let o={listenAddrs:[],protocols:[]},i=n==null?e.len:e.pos+n;for(;e.pos<i;){let a=e.uint32();switch(a>>>3){case 5:{o.protocolVersion=e.string();break}case 6:{o.agentVersion=e.string();break}case 1:{o.publicKey=e.bytes();break}case 2:{if(s.limits?.listenAddrs!=null&&o.listenAddrs.length===s.limits.listenAddrs)throw new Xe('Decode error - map field "listenAddrs" had too many elements');o.listenAddrs.push(e.bytes());break}case 4:{o.observedAddr=e.bytes();break}case 3:{if(s.limits?.protocols!=null&&o.protocols.length===s.limits.protocols)throw new Xe('Decode error - map field "protocols" had too many elements');o.protocols.push(e.string());break}case 8:{o.signedPeerRecord=e.bytes();break}default:{e.skipType(a&7);break}}}return o})),t),r.encode=e=>zt(e,r.codec()),r.decode=(e,n)=>$t(e,r.codec(),n)})(He||(He={}));var su=ro(nu(),1),Yi=typeof window=="object"&&typeof document=="object"&&document.nodeType===9,zs=(0,su.default)(),ou=Yi&&!zs,iu=zs&&!Yi,au=zs&&Yi,cu=typeof globalThis.process<"u"&&typeof globalThis.process.release<"u"&&globalThis.process.release.name==="node"&&!zs,lu=typeof importScripts=="function"&&typeof self<"u"&&typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope,zx=typeof globalThis.process<"u"&&typeof globalThis.process.env<"u"&&globalThis.process.env["NODE"+"_"+"ENV"]==="test",uu=typeof navigator<"u"&&navigator.product==="ReactNative";var Rt={protocolPrefix:"ipfs",timeout:5e3,maxInboundStreams:1,maxOutboundStreams:1,maxObservedAddresses:10,maxMessageSize:8192,runOnConnectionOpen:!0,runOnSelfUpdate:!0,runOnLimitedConnection:!0,concurrency:32};function fu(r){if(r!=null&&r.length>0)try{return oe(r)}catch{}}function l0(r,t){return t!=null||(t=`${r.name}/${r.version}`,cu||iu?t+=` UserAgent=${globalThis.process.version}`:(ou||lu||au||uu)&&(t+=` UserAgent=${globalThis.navigator.userAgent}`)),t}async function Gs(r,t,e,n,s){if(e("received identify from %p",n.remotePeer),s==null)throw new Dt("message was null or undefined");let o={};if(s.listenAddrs.length>0&&(o.addresses=s.listenAddrs.map(c=>({isCertified:!1,multiaddr:oe(c)}))),s.protocols.length>0&&(o.protocols=s.protocols),s.publicKey!=null){let c=wr(s.publicKey);if(!Cl(c).equals(n.remotePeer))throw new Dt("public key did not match remote PeerId");o.publicKey=c}let i;if(s.signedPeerRecord!=null){e.trace("received signedPeerRecord from %p",n.remotePeer);let c=s.signedPeerRecord,l=await se.openAndCertify(c,Yt.DOMAIN),u=Yt.createFromProtobuf(l.payload),f=_s(l.publicKey.toCID());if(!u.peerId.equals(f))throw new Dt("signing key does not match PeerId in the PeerRecord");if(!n.remotePeer.equals(u.peerId))throw new Dt("signing key does not match remote PeerId");let h;try{h=await r.get(u.peerId)}catch(d){if(d.name!=="NotFoundError")throw d}if(h!=null&&(o.metadata=h.metadata,h.peerRecordEnvelope!=null)){let d=await se.createFromProtobuf(h.peerRecordEnvelope),p=Yt.createFromProtobuf(d.payload);p.seqNumber>=u.seqNumber&&(e("sequence number was lower or equal to existing sequence number - stored: %d received: %d",p.seqNumber,u.seqNumber),u=p,c=h.peerRecordEnvelope)}o.peerRecordEnvelope=c,o.addresses=u.multiaddrs.map(d=>({isCertified:!0,multiaddr:d})),i={seq:u.seqNumber,addresses:u.multiaddrs}}else e("%p did not send a signed peer record",n.remotePeer);if(e.trace("patching %p with",n.remotePeer,o),await r.patch(n.remotePeer,o),s.agentVersion!=null||s.protocolVersion!=null){let c={};s.agentVersion!=null&&(c.AgentVersion=$(s.agentVersion)),s.protocolVersion!=null&&(c.ProtocolVersion=$(s.protocolVersion)),e.trace("merging %p metadata",n.remotePeer,c),await r.merge(n.remotePeer,{metadata:c})}let a={peerId:n.remotePeer,protocolVersion:s.protocolVersion,agentVersion:s.agentVersion,publicKey:s.publicKey,listenAddrs:s.listenAddrs.map(c=>oe(c)),observedAddr:s.observedAddr==null?void 0:oe(s.observedAddr),protocols:s.protocols,signedPeerRecord:i,connection:n};return t.safeDispatchEvent("peer:identify",{detail:a}),a}var Sr=class{host;protocol;started;timeout;peerId;privateKey;peerStore;registrar;addressManager;maxInboundStreams;maxOutboundStreams;maxMessageSize;maxObservedAddresses;events;runOnLimitedConnection;log;constructor(t,e){this.protocol=e.protocol,this.started=!1,this.peerId=t.peerId,this.privateKey=t.privateKey,this.peerStore=t.peerStore,this.registrar=t.registrar,this.addressManager=t.addressManager,this.events=t.events,this.log=e.log,this.timeout=e.timeout??Rt.timeout,this.maxInboundStreams=e.maxInboundStreams??Rt.maxInboundStreams,this.maxOutboundStreams=e.maxOutboundStreams??Rt.maxOutboundStreams,this.maxMessageSize=e.maxMessageSize??Rt.maxMessageSize,this.maxObservedAddresses=e.maxObservedAddresses??Rt.maxObservedAddresses,this.runOnLimitedConnection=e.runOnLimitedConnection??Rt.runOnLimitedConnection,this.host={protocolVersion:`${e.protocolPrefix??Rt.protocolPrefix}/${Jl}`,agentVersion:l0(t.nodeInfo,e.agentVersion)}}isStarted(){return this.started}async start(){this.started||(await this.peerStore.merge(this.peerId,{metadata:{AgentVersion:$(this.host.agentVersion),ProtocolVersion:$(this.host.protocolVersion)}}),await this.registrar.handle(this.protocol,t=>{this.handleProtocol(t).catch(e=>{this.log.error(e)})},{maxInboundStreams:this.maxInboundStreams,maxOutboundStreams:this.maxOutboundStreams,runOnLimitedConnection:this.runOnLimitedConnection}),this.started=!0)}async stop(){await this.registrar.unhandle(this.protocol),this.started=!1}};var Ws=class extends Sr{connectionManager;concurrency;constructor(t,e={}){super(t,{...e,protocol:`/${e.protocolPrefix??Rt.protocolPrefix}/${Ql}/${eu}`,log:t.logger.forComponent("libp2p:identify-push")}),this.connectionManager=t.connectionManager,this.concurrency=e.concurrency??Rt.concurrency,(e.runOnSelfUpdate??Rt.runOnSelfUpdate)&&t.events.addEventListener("self:peer:update",n=>{this.push().catch(s=>{this.log.error(s)})})}[pn]=["@libp2p/identify-push"];async push(){if(!this.isStarted())return;let t=this.addressManager.getAddresses().map(u=>u.decapsulateCode(z("p2p").code)),e=new Yt({peerId:this.peerId,multiaddrs:t}),n=await se.seal(e,this.privateKey),s=this.registrar.getProtocols(),o=await this.peerStore.get(this.peerId),i=rt(o.metadata.get("AgentVersion")??$(this.host.agentVersion)),a=rt(o.metadata.get("ProtocolVersion")??$(this.host.protocolVersion)),c=this;async function*l(){for(let u of c.connectionManager.getConnections())(await c.peerStore.get(u.remotePeer)).protocols.includes(c.protocol)&&(yield async()=>{let h,d=AbortSignal.timeout(c.timeout);Nr(1/0,d);try{h=await u.newStream(c.protocol,{signal:d,runOnLimitedConnection:c.runOnLimitedConnection}),await Ar(h,{maxDataLength:c.maxMessageSize}).pb(He).write({listenAddrs:t.map(b=>b.bytes),signedPeerRecord:n.marshal(),protocols:s,agentVersion:i,protocolVersion:a},{signal:d}),await h.close({signal:d})}catch(p){c.log.error("could not push identify update to peer",p),h?.abort(p)}})}await Gl(Gi(l(),{concurrency:this.concurrency}))}async handleProtocol(t){let{connection:e,stream:n}=t;try{if(this.peerId.equals(e.remotePeer))throw new Error("received push from ourselves?");let s={signal:AbortSignal.timeout(this.timeout)},i=await Ar(n,{maxDataLength:this.maxMessageSize}).pb(He).read(s);await n.close(s),await Gs(this.peerStore,this.events,this.log,e,i)}catch(s){this.log.error("received invalid message",s),n.abort(s);return}this.log.trace("handled push from %p",e.remotePeer)}};var du=ro(hu(),1),u0=["0.0.0.0/8","10.0.0.0/8","100.64.0.0/10","127.0.0.0/8","169.254.0.0/16","172.16.0.0/12","192.0.0.0/24","192.0.0.0/29","192.0.0.8/32","192.0.0.9/32","192.0.0.10/32","192.0.0.170/32","192.0.0.171/32","192.0.2.0/24","192.31.196.0/24","192.52.193.0/24","192.88.99.0/24","192.168.0.0/16","192.175.48.0/24","198.18.0.0/15","198.51.100.0/24","203.0.113.0/24","240.0.0.0/4","255.255.255.255/32"],f0=u0.map(r=>new du.Netmask(r));function Ji(r){for(let t of f0)if(t.contains(r))return!0;return!1}function h0(r){return/^::ffff:([0-9a-fA-F]{1,4}):([0-9a-fA-F]{1,4})$/.test(r)}function d0(r){let t=r.split(":");if(t.length<2)return!1;let e=t[t.length-1].padStart(4,"0"),n=t[t.length-2].padStart(4,"0"),s=`${parseInt(n.substring(0,2),16)}.${parseInt(n.substring(2),16)}.${parseInt(e.substring(0,2),16)}.${parseInt(e.substring(2),16)}`;return Ji(s)}function p0(r){return/^::ffff:([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(r)}function g0(r){let t=r.split(":"),e=t[t.length-1];return Ji(e)}function m0(r){return/^::$/.test(r)||/^::1$/.test(r)||/^64:ff9b::([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(r)||/^100::([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^2001::([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^2001:2[0-9a-fA-F]:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^2001:db8:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^2002:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^f[c-d]([0-9a-fA-F]{2,2}):/i.test(r)||/^fe[8-9a-bA-B][0-9a-fA-F]:/i.test(r)||/^ff([0-9a-fA-F]{2,2}):/i.test(r)}function pu(r){return vr(r)?Ji(r):h0(r)?d0(r):p0(r)?g0(r):Er(r)?m0(r):void 0}var b0=r=>r.toString().split("/").slice(1),Ir=r=>({match:t=>t.length<1?!1:r(t[0])?t.slice(1):!1,pattern:"fn"}),H=r=>({match:t=>Ir(e=>e===r).match(t),pattern:r}),er=()=>({match:r=>Ir(t=>typeof t=="string").match(r),pattern:"{string}"}),an=()=>({match:r=>Ir(t=>!isNaN(parseInt(t))).match(r),pattern:"{number}"}),Y=()=>({match:r=>{if(r.length<2||r[0]!=="p2p"&&r[0]!=="ipfs")return!1;if(r[1].startsWith("Q")||r[1].startsWith("1"))try{X.decode(`z${r[1]}`)}catch{return!1}else return!1;return r.slice(2)},pattern:"/p2p/{peerid}"}),cn=()=>({match:r=>{if(r.length<2||r[0]!=="certhash")return!1;try{Zo.decode(r[1])}catch{return!1}return r.slice(2)},pattern:"/certhash/{certhash}"}),G=r=>({match:t=>{let e=r.match(t);return e===!1?t:e},pattern:`optional(${r.pattern})`}),Bt=(...r)=>({match:t=>{let e;for(let n of r){let s=n.match(t);s!==!1&&(e==null||s.length<e.length)&&(e=s)}return e??!1},pattern:`or(${r.map(t=>t.pattern).join(", ")})`}),K=(...r)=>({match:t=>{for(let e of r){let n=e.match(t);if(n===!1)return!1;t=n}return t},pattern:`and(${r.map(t=>t.pattern).join(", ")})`});function st(...r){function t(s){let o=b0(s);for(let i of r){let a=i.match(o);if(a===!1)return!1;o=a}return o}function e(s){return t(s)!==!1}function n(s){let o=t(s);return o===!1?!1:o.length===0}return{matchers:r,matches:e,exactMatch:n}}var Zs=K(H("dns4"),er()),Ys=K(H("dns6"),er()),Js=K(H("dnsaddr"),er()),Qi=K(H("dns"),er()),E1=st(Zs,G(Y())),B1=st(Ys,G(Y())),A1=st(Js,G(Y())),S1=st(Bt(Qi,Js,Zs,Ys),G(Y())),gu=K(H("ip4"),Ir(vr)),mu=K(H("ip6"),Ir(Er)),ta=Bt(gu,mu),Be=Bt(ta,Qi,Zs,Ys,Js),bu=st(Bt(ta,K(Bt(Qi,Js,Zs,Ys),G(Y())))),I1=st(gu),k1=st(mu),N1=st(ta),ea=K(Be,H("tcp"),an()),ln=K(Be,H("udp"),an()),C1=st(K(ea,G(Y()))),T1=st(ln),ra=K(ln,H("quic"),G(Y())),Xs=K(ln,H("quic-v1"),G(Y())),y0=Bt(ra,Xs),L1=st(ra),U1=st(Xs),Xi=Bt(Be,ea,ln,ra,Xs),yu=Bt(K(Xi,H("ws"),G(Y()))),R1=st(yu),wu=Bt(K(Xi,H("wss"),G(Y())),K(Xi,H("tls"),G(K(H("sni"),er())),H("ws"),G(Y()))),_1=st(wu),xu=K(ln,H("webrtc-direct"),G(cn()),G(cn()),G(Y())),O1=st(xu),vu=K(Xs,H("webtransport"),G(cn()),G(cn()),G(Y())),V1=st(vu),js=Bt(yu,wu,K(ea,G(Y())),K(y0,G(Y())),K(Be,G(Y())),xu,vu,Y()),P1=st(js),w0=K(js,H("p2p-circuit"),Y()),D1=st(w0),x0=Bt(K(js,H("p2p-circuit"),H("webrtc"),G(Y())),K(js,H("webrtc"),G(Y())),K(H("webrtc"),G(Y()))),M1=st(x0),v0=Bt(K(Be,H("tcp"),an(),H("http"),G(Y())),K(Be,H("http"),G(Y()))),F1=st(v0),E0=Bt(K(Be,H("tcp"),Bt(K(H("443"),H("http")),K(an(),H("https"))),G(Y())),K(Be,H("tls"),H("http"),G(Y())),K(Be,H("https"),G(Y()))),H1=st(E0),B0=Bt(K(H("memory"),er(),G(Y()))),K1=st(B0);var Qs=class extends Sr{constructor(t,e={}){super(t,{...e,protocol:`/${e.protocolPrefix??Rt.protocolPrefix}/${Xl}/${tu}`,log:t.logger.forComponent("libp2p:identify")}),(e.runOnConnectionOpen??Rt.runOnConnectionOpen)&&t.events.addEventListener("connection:open",n=>{let s=n.detail;this.identify(s).catch(o=>{o.name!==dn.name&&this.log.error("error during identify trigged by connection:open",o)})})}[pn]=["@libp2p/identify"];async _identify(t,e={}){let n;if(e.signal==null){let s=AbortSignal.timeout(this.timeout);Nr(1/0,s),e={...e,signal:s}}try{n=await t.newStream(this.protocol,{...e,runOnLimitedConnection:this.runOnLimitedConnection});let o=await Ar(n,{maxDataLength:this.maxMessageSize}).pb(He).read(e);return await n.close(e),o}catch(s){throw n?.abort(s),s}}async identify(t,e={}){let n=await this._identify(t,e),{publicKey:s,protocols:o,observedAddr:i}=n;if(s==null)throw new Dt("public key was missing from identify message");let a=wr(s),c=_s(a.toCID());if(!t.remotePeer.equals(c))throw new Dt("identified peer does not match the expected peer");if(this.peerId.equals(c))throw new Dt("identified peer is our own peer id?");let l=fu(i);return this.log("identify completed for peer %p and protocols %o",c,o),l!=null&&(this.log("our observed address was %a",l),pu(l?.nodeAddress().address)===!0?this.log("our observed address was private"):this.addressManager.getObservedAddrs().length<(this.maxObservedAddresses??1/0)&&(this.log("storing our observed address"),this.addressManager.addObservedAddr(l))),Gs(this.peerStore,this.events,this.log,t,n)}async handleProtocol(t){let{connection:e,stream:n}=t,s=AbortSignal.timeout(this.timeout);Nr(1/0,s);try{let o=await this.peerStore.get(this.peerId),i=this.addressManager.getAddresses().map(u=>u.decapsulateCode(z("p2p").code)),a=o.peerRecordEnvelope;if(i.length>0&&a==null){let u=new Yt({peerId:this.peerId,multiaddrs:i});a=(await se.seal(u,this.privateKey)).marshal().subarray()}let c=e.remoteAddr.bytes;bu.matches(e.remoteAddr)||(c=void 0),await Ar(n).pb(He).write({protocolVersion:this.host.protocolVersion,agentVersion:this.host.agentVersion,publicKey:Ue(this.privateKey.publicKey),listenAddrs:i.map(u=>u.bytes),signedPeerRecord:a,observedAddr:c,protocols:o.protocols},{signal:s}),await n.close({signal:s})}catch(o){this.log.error("could not respond to identify request",o),n.abort(o)}}};function A0(r={}){return t=>new Qs(t,r)}function S0(r={}){return t=>new Ws(t,r)}return Ou(I0);})();
|
|
7
7
|
/*! Bundled license information:
|
|
8
8
|
|
|
9
9
|
pvtsutils/build/index.js:
|
|
10
10
|
(*!
|
|
11
11
|
* MIT License
|
|
12
12
|
*
|
|
13
|
-
* Copyright (c) 2017-
|
|
13
|
+
* Copyright (c) 2017-2024 Peculiar Ventures, LLC
|
|
14
14
|
*
|
|
15
15
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
16
16
|
* of this software and associated documentation files (the "Software"), to deal
|
|
@@ -50,6 +50,9 @@ pvtsutils/build/index.js:
|
|
|
50
50
|
@noble/curves/esm/ed25519.js:
|
|
51
51
|
(*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
52
52
|
|
|
53
|
+
@noble/hashes/esm/utils.js:
|
|
54
|
+
(*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
55
|
+
|
|
53
56
|
pvutils/build/utils.es.js:
|
|
54
57
|
(*!
|
|
55
58
|
Copyright (c) Peculiar Ventures, LLC
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@libp2p/identify",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.12-339b7df88",
|
|
4
4
|
"description": "Implementation of the Identify Protocol",
|
|
5
5
|
"license": "Apache-2.0 OR MIT",
|
|
6
6
|
"homepage": "https://github.com/libp2p/js-libp2p/tree/main/packages/protocol-identify#readme",
|
|
@@ -52,30 +52,30 @@
|
|
|
52
52
|
"doc-check": "aegir doc-check"
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
|
-
"@libp2p/crypto": "
|
|
56
|
-
"@libp2p/interface": "
|
|
57
|
-
"@libp2p/interface-internal": "
|
|
58
|
-
"@libp2p/peer-id": "
|
|
59
|
-
"@libp2p/peer-record": "
|
|
60
|
-
"@libp2p/utils": "
|
|
61
|
-
"@multiformats/multiaddr": "^12.
|
|
62
|
-
"@multiformats/multiaddr-matcher": "^1.
|
|
55
|
+
"@libp2p/crypto": "5.0.7-339b7df88",
|
|
56
|
+
"@libp2p/interface": "2.2.1-339b7df88",
|
|
57
|
+
"@libp2p/interface-internal": "2.1.1-339b7df88",
|
|
58
|
+
"@libp2p/peer-id": "5.0.8-339b7df88",
|
|
59
|
+
"@libp2p/peer-record": "8.0.12-339b7df88",
|
|
60
|
+
"@libp2p/utils": "6.2.1-339b7df88",
|
|
61
|
+
"@multiformats/multiaddr": "^12.3.3",
|
|
62
|
+
"@multiformats/multiaddr-matcher": "^1.6.0",
|
|
63
63
|
"it-drain": "^3.0.7",
|
|
64
|
-
"it-parallel": "^3.0.
|
|
65
|
-
"it-protobuf-stream": "^1.1.
|
|
66
|
-
"protons-runtime": "^5.
|
|
64
|
+
"it-parallel": "^3.0.8",
|
|
65
|
+
"it-protobuf-stream": "^1.1.5",
|
|
66
|
+
"protons-runtime": "^5.5.0",
|
|
67
67
|
"uint8arraylist": "^2.4.8",
|
|
68
68
|
"uint8arrays": "^5.1.0",
|
|
69
69
|
"wherearewe": "^2.0.1"
|
|
70
70
|
},
|
|
71
71
|
"devDependencies": {
|
|
72
|
-
"@libp2p/logger": "
|
|
73
|
-
"aegir": "^
|
|
72
|
+
"@libp2p/logger": "5.1.4-339b7df88",
|
|
73
|
+
"aegir": "^45.0.5",
|
|
74
74
|
"delay": "^6.0.0",
|
|
75
|
-
"it-length-prefixed": "^9.0
|
|
75
|
+
"it-length-prefixed": "^9.1.0",
|
|
76
76
|
"it-pair": "^2.0.6",
|
|
77
77
|
"it-pushable": "^3.2.3",
|
|
78
|
-
"protons": "^7.
|
|
78
|
+
"protons": "^7.6.0",
|
|
79
79
|
"sinon-ts": "^2.0.0"
|
|
80
80
|
},
|
|
81
81
|
"sideEffects": false
|
package/LICENSE
DELETED
package/dist/typedoc-urls.json
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"Identify": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_identify.Identify.html",
|
|
3
|
-
".:Identify": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_identify.Identify.html",
|
|
4
|
-
"IdentifyComponents": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_identify.IdentifyComponents.html",
|
|
5
|
-
".:IdentifyComponents": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_identify.IdentifyComponents.html",
|
|
6
|
-
"IdentifyInit": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_identify.IdentifyInit.html",
|
|
7
|
-
".:IdentifyInit": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_identify.IdentifyInit.html",
|
|
8
|
-
"IdentifyPush": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_identify.IdentifyPush.html",
|
|
9
|
-
".:IdentifyPush": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_identify.IdentifyPush.html",
|
|
10
|
-
"IdentifyPushComponents": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_identify.IdentifyPushComponents.html",
|
|
11
|
-
".:IdentifyPushComponents": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_identify.IdentifyPushComponents.html",
|
|
12
|
-
"IdentifyPushInit": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_identify.IdentifyPushInit.html",
|
|
13
|
-
".:IdentifyPushInit": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_identify.IdentifyPushInit.html",
|
|
14
|
-
"identify": "https://libp2p.github.io/js-libp2p/functions/_libp2p_identify.identify-1.html",
|
|
15
|
-
".:identify": "https://libp2p.github.io/js-libp2p/functions/_libp2p_identify.identify-1.html",
|
|
16
|
-
"identifyPush": "https://libp2p.github.io/js-libp2p/functions/_libp2p_identify.identifyPush-1.html",
|
|
17
|
-
".:identifyPush": "https://libp2p.github.io/js-libp2p/functions/_libp2p_identify.identifyPush-1.html"
|
|
18
|
-
}
|