@libp2p/identify 2.1.5-3c8dd5bbf → 2.1.5-737b3ea5b

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.min.js CHANGED
@@ -1,10 +1,10 @@
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 du=Object.create;var hn=Object.defineProperty;var pu=Object.getOwnPropertyDescriptor;var gu=Object.getOwnPropertyNames;var mu=Object.getPrototypeOf,yu=Object.prototype.hasOwnProperty;var Zi=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),de=(r,e)=>{for(var t in e)hn(r,t,{get:e[t],enumerable:!0})},Ji=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of gu(e))!yu.call(r,s)&&s!==t&&hn(r,s,{get:()=>e[s],enumerable:!(n=pu(e,s))||n.enumerable});return r};var Xi=(r,e,t)=>(t=r!=null?du(mu(r)):{},Ji(e||!r||!r.__esModule?hn(t,"default",{value:r,enumerable:!0}):t,r)),bu=r=>Ji(hn({},"__esModule",{value:!0}),r);var Qa=Zi(xr=>{"use strict";var Zh="[object ArrayBuffer]",xt=class r{static isArrayBuffer(e){return Object.prototype.toString.call(e)===Zh}static toArrayBuffer(e){return this.isArrayBuffer(e)?e:e.byteLength===e.buffer.byteLength||e.byteOffset===0&&e.byteLength===e.buffer.byteLength?e.buffer:this.toUint8Array(e.buffer).slice(e.byteOffset,e.byteOffset+e.byteLength).buffer}static toUint8Array(e){return this.toView(e,Uint8Array)}static toView(e,t){if(e.constructor===t)return e;if(this.isArrayBuffer(e))return new t(e);if(this.isArrayBufferView(e))return new t(e.buffer,e.byteOffset,e.byteLength);throw new TypeError("The provided value is not of type '(ArrayBuffer or ArrayBufferView)'")}static isBufferSource(e){return this.isArrayBufferView(e)||this.isArrayBuffer(e)}static isArrayBufferView(e){return ArrayBuffer.isView(e)||e&&this.isArrayBuffer(e.buffer)}static isEqual(e,t){let n=r.toUint8Array(e),s=r.toUint8Array(t);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(...e){let t;Array.isArray(e[0])&&!(e[1]instanceof Function)||Array.isArray(e[0])&&e[1]instanceof Function?t=e[0]:e[e.length-1]instanceof Function?t=e.slice(0,e.length-1):t=e;let n=0;for(let i of t)n+=i.byteLength;let s=new Uint8Array(n),o=0;for(let i of t){let a=this.toUint8Array(i);s.set(a,o),o+=a.length}return e[e.length-1]instanceof Function?this.toView(s,e[e.length-1]):s.buffer}},Qo="string",Jh=/^[0-9a-f]+$/i,Xh=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/,Qh=/^[a-zA-Z0-9-_]+$/,Ln=class{static fromString(e){let t=unescape(encodeURIComponent(e)),n=new Uint8Array(t.length);for(let s=0;s<t.length;s++)n[s]=t.charCodeAt(s);return n.buffer}static toString(e){let t=xt.toUint8Array(e),n="";for(let o=0;o<t.length;o++)n+=String.fromCharCode(t[o]);return decodeURIComponent(escape(n))}},Ve=class{static toString(e,t=!1){let n=xt.toArrayBuffer(e),s=new DataView(n),o="";for(let i=0;i<n.byteLength;i+=2){let a=s.getUint16(i,t);o+=String.fromCharCode(a)}return o}static fromString(e,t=!1){let n=new ArrayBuffer(e.length*2),s=new DataView(n);for(let o=0;o<e.length;o++)s.setUint16(o*2,e.charCodeAt(o),t);return n}},Un=class r{static isHex(e){return typeof e===Qo&&Jh.test(e)}static isBase64(e){return typeof e===Qo&&Xh.test(e)}static isBase64Url(e){return typeof e===Qo&&Qh.test(e)}static ToString(e,t="utf8"){let n=xt.toUint8Array(e);switch(t.toLowerCase()){case"utf8":return this.ToUtf8String(n);case"binary":return this.ToBinary(n);case"hex":return this.ToHex(n);case"base64":return this.ToBase64(n);case"base64url":return this.ToBase64Url(n);case"utf16le":return Ve.toString(n,!0);case"utf16":case"utf16be":return Ve.toString(n);default:throw new Error(`Unknown type of encoding '${t}'`)}}static FromString(e,t="utf8"){if(!e)return new ArrayBuffer(0);switch(t.toLowerCase()){case"utf8":return this.FromUtf8String(e);case"binary":return this.FromBinary(e);case"hex":return this.FromHex(e);case"base64":return this.FromBase64(e);case"base64url":return this.FromBase64Url(e);case"utf16le":return Ve.fromString(e,!0);case"utf16":case"utf16be":return Ve.fromString(e);default:throw new Error(`Unknown type of encoding '${t}'`)}}static ToBase64(e){let t=xt.toUint8Array(e);if(typeof btoa<"u"){let n=this.ToString(t,"binary");return btoa(n)}else return Buffer.from(t).toString("base64")}static FromBase64(e){let t=this.formatString(e);if(!t)return new ArrayBuffer(0);if(!r.isBase64(t))throw new TypeError("Argument 'base64Text' is not Base64 encoded");return typeof atob<"u"?this.FromBinary(atob(t)):new Uint8Array(Buffer.from(t,"base64")).buffer}static FromBase64Url(e){let t=this.formatString(e);if(!t)return new ArrayBuffer(0);if(!r.isBase64Url(t))throw new TypeError("Argument 'base64url' is not Base64Url encoded");return this.FromBase64(this.Base64Padding(t.replace(/\-/g,"+").replace(/\_/g,"/")))}static ToBase64Url(e){return this.ToBase64(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/\=/g,"")}static FromUtf8String(e,t=r.DEFAULT_UTF8_ENCODING){switch(t){case"ascii":return this.FromBinary(e);case"utf8":return Ln.fromString(e);case"utf16":case"utf16be":return Ve.fromString(e);case"utf16le":case"usc2":return Ve.fromString(e,!0);default:throw new Error(`Unknown type of encoding '${t}'`)}}static ToUtf8String(e,t=r.DEFAULT_UTF8_ENCODING){switch(t){case"ascii":return this.ToBinary(e);case"utf8":return Ln.toString(e);case"utf16":case"utf16be":return Ve.toString(e);case"utf16le":case"usc2":return Ve.toString(e,!0);default:throw new Error(`Unknown type of encoding '${t}'`)}}static FromBinary(e){let t=e.length,n=new Uint8Array(t);for(let s=0;s<t;s++)n[s]=e.charCodeAt(s);return n.buffer}static ToBinary(e){let t=xt.toUint8Array(e),n="";for(let s=0;s<t.length;s++)n+=String.fromCharCode(t[s]);return n}static ToHex(e){let t=xt.toUint8Array(e),n="",s=t.length;for(let o=0;o<s;o++){let i=t[o];i<16&&(n+="0"),n+=i.toString(16)}return n}static FromHex(e){let t=this.formatString(e);if(!t)return new ArrayBuffer(0);if(!r.isHex(t))throw new TypeError("Argument 'hexString' is not HEX encoded");t.length%2&&(t=`0${t}`);let n=new Uint8Array(t.length/2);for(let s=0;s<t.length;s=s+2){let o=t.slice(s,s+2);n[s/2]=parseInt(o,16)}return n.buffer}static ToUtf16String(e,t=!1){return Ve.toString(e,t)}static FromUtf16String(e,t=!1){return Ve.fromString(e,t)}static Base64Padding(e){let t=4-e.length%4;if(t<4)for(let n=0;n<t;n++)e+="=";return e}static formatString(e){return e?.replace(/[\n\r\t ]/g,"")||""}};Un.DEFAULT_UTF8_ENCODING="utf8";function ed(r,...e){let t=arguments[0];for(let n=1;n<arguments.length;n++){let s=arguments[n];for(let o in s)t[o]=s[o]}return t}function td(...r){let e=r.map(s=>s.byteLength).reduce((s,o)=>s+o),t=new Uint8Array(e),n=0;return r.map(s=>new Uint8Array(s)).forEach(s=>{for(let o of s)t[n++]=o}),t.buffer}function rd(r,e){if(!(r&&e)||r.byteLength!==e.byteLength)return!1;let t=new Uint8Array(r),n=new Uint8Array(e);for(let s=0;s<r.byteLength;s++)if(t[s]!==n[s])return!1;return!0}xr.BufferSourceConverter=xt;xr.Convert=Un;xr.assign=ed;xr.combine=td;xr.isEqual=rd});var Kl=Zi((ex,Fl)=>{function op(){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)}Fl.exports=op});var yp={};de(yp,{identify:()=>gp,identifyPush:()=>mp});var zs=Symbol.for("@libp2p/peer-id");var C=class extends Error{code;props;constructor(e,t,n){super(e),this.code=t,this.name=n?.name??"CodeError",this.props=n??{}}};var Ur=(r,...e)=>{try{[...e]}catch{}};var dn=Symbol.for("@libp2p/service-capabilities"),Ep=Symbol.for("@libp2p/service-dependencies");var Jo={};de(Jo,{Ed25519PrivateKey:()=>Xt,Ed25519PublicKey:()=>$r,generateKeyPair:()=>jh,generateKeyPairFromSeed:()=>Xa,unmarshalEd25519PrivateKey:()=>zh,unmarshalEd25519PublicKey:()=>Gh});var Zs={};de(Zs,{base58btc:()=>ne,base58flickr:()=>Au});var Gp=new Uint8Array(0);function Qi(r,e){if(r===e)return!0;if(r.byteLength!==e.byteLength)return!1;for(let t=0;t<r.byteLength;t++)if(r[t]!==e[t])return!1;return!0}function ut(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 ea(r){return new TextEncoder().encode(r)}function ta(r){return new TextDecoder().decode(r)}function wu(r,e){if(r.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),n=0;n<t.length;n++)t[n]=255;for(var s=0;s<r.length;s++){var o=r.charAt(s),i=o.charCodeAt(0);if(t[i]!==255)throw new TypeError(o+" is ambiguous");t[i]=s}var a=r.length,c=r.charAt(0),f=Math.log(a)/Math.log(256),u=Math.log(256)/Math.log(a);function l(d){if(d instanceof Uint8Array||(ArrayBuffer.isView(d)?d=new Uint8Array(d.buffer,d.byteOffset,d.byteLength):Array.isArray(d)&&(d=Uint8Array.from(d))),!(d instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(d.length===0)return"";for(var h=0,y=0,v=0,w=d.length;v!==w&&d[v]===0;)v++,h++;for(var x=(w-v)*u+1>>>0,T=new Uint8Array(x);v!==w;){for(var S=d[v],I=0,R=x-1;(S!==0||I<y)&&R!==-1;R--,I++)S+=256*T[R]>>>0,T[R]=S%a>>>0,S=S/a>>>0;if(S!==0)throw new Error("Non-zero carry");y=I,v++}for(var k=x-y;k!==x&&T[k]===0;)k++;for(var j=c.repeat(h);k<x;++k)j+=r.charAt(T[k]);return j}function p(d){if(typeof d!="string")throw new TypeError("Expected String");if(d.length===0)return new Uint8Array;var h=0;if(d[h]!==" "){for(var y=0,v=0;d[h]===c;)y++,h++;for(var w=(d.length-h)*f+1>>>0,x=new Uint8Array(w);d[h];){var T=t[d.charCodeAt(h)];if(T===255)return;for(var S=0,I=w-1;(T!==0||S<v)&&I!==-1;I--,S++)T+=a*x[I]>>>0,x[I]=T%256>>>0,T=T/256>>>0;if(T!==0)throw new Error("Non-zero carry");v=S,h++}if(d[h]!==" "){for(var R=w-v;R!==w&&x[R]===0;)R++;for(var k=new Uint8Array(y+(w-R)),j=y;R!==w;)k[j++]=x[R++];return k}}}function b(d){var h=p(d);if(h)return h;throw new Error(`Non-${e} character`)}return{encode:l,decodeUnsafe:p,decode:b}}var xu=wu,vu=xu,na=vu;var Gs=class{name;prefix;baseEncode;constructor(e,t,n){this.name=e,this.prefix=t,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},js=class{name;prefix;baseDecode;prefixCodePoint;constructor(e,t,n){if(this.name=e,this.prefix=t,t.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=n}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return sa(this,e)}},Ws=class{decoders;constructor(e){this.decoders=e}or(e){return sa(this,e)}decode(e){let t=e[0],n=this.decoders[t];if(n!=null)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function sa(r,e){return new Ws({...r.decoders??{[r.prefix]:r},...e.decoders??{[e.prefix]:e}})}var Ys=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(e,t,n,s){this.name=e,this.prefix=t,this.baseEncode=n,this.baseDecode=s,this.encoder=new Gs(e,t,n),this.decoder=new js(e,t,s)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};function nr({name:r,prefix:e,encode:t,decode:n}){return new Ys(r,e,t,n)}function St({name:r,prefix:e,alphabet:t}){let{encode:n,decode:s}=na(t,r);return nr({prefix:e,name:r,encode:n,decode:o=>ut(s(o))})}function Eu(r,e,t,n){let s={};for(let u=0;u<e.length;++u)s[e[u]]=u;let o=r.length;for(;r[o-1]==="=";)--o;let i=new Uint8Array(o*t/8|0),a=0,c=0,f=0;for(let u=0;u<o;++u){let l=s[r[u]];if(l===void 0)throw new SyntaxError(`Non-${n} character`);c=c<<t|l,a+=t,a>=8&&(a-=8,i[f++]=255&c>>a)}if(a>=t||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return i}function Bu(r,e,t){let n=e[e.length-1]==="=",s=(1<<t)-1,o="",i=0,a=0;for(let c=0;c<r.length;++c)for(a=a<<8|r[c],i+=8;i>t;)i-=t,o+=e[s&a>>i];if(i!==0&&(o+=e[s&a<<t-i]),n)for(;o.length*t&7;)o+="=";return o}function te({name:r,prefix:e,bitsPerChar:t,alphabet:n}){return nr({prefix:e,name:r,encode(s){return Bu(s,n,t)},decode(s){return Eu(s,n,t,r)}})}var ne=St({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Au=St({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Xs={};de(Xs,{identity:()=>ft});var Iu=aa,oa=128,Su=127,ku=~Su,Nu=Math.pow(2,31);function aa(r,e,t){e=e||[],t=t||0;for(var n=t;r>=Nu;)e[t++]=r&255|oa,r/=128;for(;r&ku;)e[t++]=r&255|oa,r>>>=7;return e[t]=r|0,aa.bytes=t-n+1,e}var Ru=Js,Tu=128,ia=127;function Js(r,n){var t=0,n=n||0,s=0,o=n,i,a=r.length;do{if(o>=a)throw Js.bytes=0,new RangeError("Could not decode varint");i=r[o++],t+=s<28?(i&ia)<<s:(i&ia)*Math.pow(2,s),s+=7}while(i>=Tu);return Js.bytes=o-n,t}var _u=Math.pow(2,7),Cu=Math.pow(2,14),Lu=Math.pow(2,21),Uu=Math.pow(2,28),Pu=Math.pow(2,35),Ou=Math.pow(2,42),Vu=Math.pow(2,49),Du=Math.pow(2,56),Mu=Math.pow(2,63),Hu=function(r){return r<_u?1:r<Cu?2:r<Lu?3:r<Uu?4:r<Pu?5:r<Ou?6:r<Vu?7:r<Du?8:r<Mu?9:10},Fu={encode:Iu,decode:Ru,encodingLength:Hu},Ku=Fu,Pr=Ku;function Or(r,e=0){return[Pr.decode(r,e),Pr.decode.bytes]}function sr(r,e,t=0){return Pr.encode(r,e,t),e}function or(r){return Pr.encodingLength(r)}function et(r,e){let t=e.byteLength,n=or(r),s=n+or(t),o=new Uint8Array(s+t);return sr(r,o,0),sr(t,o,n),o.set(e,s),new ir(r,t,e,o)}function $t(r){let e=ut(r),[t,n]=Or(e),[s,o]=Or(e.subarray(n)),i=e.subarray(n+o);if(i.byteLength!==s)throw new Error("Incorrect length");return new ir(t,s,i,e)}function ca(r,e){if(r===e)return!0;{let t=e;return r.code===t.code&&r.size===t.size&&t.bytes instanceof Uint8Array&&Qi(r.bytes,t.bytes)}}var ir=class{code;size;digest;bytes;constructor(e,t,n,s){this.code=e,this.size=t,this.digest=n,this.bytes=s}};var la=0,qu="identity",ua=ut;function $u(r){return et(la,ua(r))}var ft={code:la,name:qu,encode:ua,digest:$u};var to={};de(to,{sha256:()=>ye,sha512:()=>zu});function eo({name:r,code:e,encode:t}){return new Qs(r,e,t)}var Qs=class{name;code;encode;constructor(e,t,n){this.name=e,this.code=t,this.encode=n}digest(e){if(e instanceof Uint8Array){let t=this.encode(e);return t instanceof Uint8Array?et(this.code,t):t.then(n=>et(this.code,n))}else throw Error("Unknown type, must be binary type")}};function ha(r){return async e=>new Uint8Array(await crypto.subtle.digest(r,e))}var ye=eo({name:"sha2-256",code:18,encode:ha("SHA-256")}),zu=eo({name:"sha2-512",code:19,encode:ha("SHA-512")});function pe(r,e){if(r===e)return!0;if(r.byteLength!==e.byteLength)return!1;for(let t=0;t<r.byteLength;t++)if(r[t]!==e[t])return!1;return!0}function ht(r=0){return new Uint8Array(r)}function Ne(r=0){return new Uint8Array(r)}function Ae(r,e){e==null&&(e=r.reduce((s,o)=>s+o.length,0));let t=Ne(e),n=0;for(let s of r)t.set(s,n),n+=s.length;return t}var ro={};de(ro,{base10:()=>Gu});var Gu=St({prefix:"9",name:"base10",alphabet:"0123456789"});var no={};de(no,{base16:()=>ju,base16upper:()=>Wu});var ju=te({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Wu=te({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var so={};de(so,{base2:()=>Yu});var Yu=te({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var oo={};de(oo,{base256emoji:()=>ef});var da=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}"),Zu=da.reduce((r,e,t)=>(r[t]=e,r),[]),Ju=da.reduce((r,e,t)=>(r[e.codePointAt(0)]=t,r),[]);function Xu(r){return r.reduce((e,t)=>(e+=Zu[t],e),"")}function Qu(r){let e=[];for(let t of r){let n=Ju[t.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${t}`);e.push(n)}return new Uint8Array(e)}var ef=nr({prefix:"\u{1F680}",name:"base256emoji",encode:Xu,decode:Qu});var io={};de(io,{base32:()=>dt,base32hex:()=>sf,base32hexpad:()=>af,base32hexpadupper:()=>cf,base32hexupper:()=>of,base32pad:()=>rf,base32padupper:()=>nf,base32upper:()=>tf,base32z:()=>lf});var dt=te({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),tf=te({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),rf=te({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),nf=te({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),sf=te({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),of=te({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),af=te({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),cf=te({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),lf=te({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var ao={};de(ao,{base36:()=>uf,base36upper:()=>ff});var uf=St({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),ff=St({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var uo={};de(uo,{base64:()=>co,base64pad:()=>hf,base64url:()=>lo,base64urlpad:()=>df});var co=te({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),hf=te({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),lo=te({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),df=te({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var fo={};de(fo,{base8:()=>pf});var pf=te({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var ho={};de(ho,{identity:()=>gf});var gf=nr({prefix:"\0",name:"identity",encode:r=>ta(r),decode:r=>ea(r)});var x0=new TextEncoder,v0=new TextDecoder;function pa(r,e){let{bytes:t,version:n}=r;switch(n){case 0:return wf(t,po(r),e??ne.encoder);default:return xf(t,po(r),e??dt.encoder)}}var ga=new WeakMap;function po(r){let e=ga.get(r);if(e==null){let t=new Map;return ga.set(r,t),t}return e}var Ue=class r{code;version;multihash;bytes;"/";constructor(e,t,n,s){this.code=t,this.version=e,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:e,multihash:t}=this;if(e!==Vr)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==vf)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return r.createV0(t)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:e,digest:t}=this.multihash,n=et(e,t);return r.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(e){return r.equals(this,e)}static equals(e,t){let n=t;return n!=null&&e.code===n.code&&e.version===n.version&&ca(e.multihash,n.multihash)}toString(e){return pa(this,e)}toJSON(){return{"/":pa(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(e){if(e==null)return null;let t=e;if(t instanceof r)return t;if(t["/"]!=null&&t["/"]===t.bytes||t.asCID===t){let{version:n,code:s,multihash:o,bytes:i}=t;return new r(n,s,o,i??ma(n,s,o.bytes))}else if(t[Ef]===!0){let{version:n,multihash:s,code:o}=t,i=$t(s);return r.create(n,o,i)}else return null}static create(e,t,n){if(typeof t!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(e){case 0:{if(t!==Vr)throw new Error(`Version 0 CID must use dag-pb (code: ${Vr}) block encoding`);return new r(e,t,n,n.bytes)}case 1:{let s=ma(e,t,n.bytes);return new r(e,t,n,s)}default:throw new Error("Invalid version")}}static createV0(e){return r.create(0,Vr,e)}static createV1(e,t){return r.create(1,e,t)}static decode(e){let[t,n]=r.decodeFirst(e);if(n.length!==0)throw new Error("Incorrect length");return t}static decodeFirst(e){let t=r.inspectBytes(e),n=t.size-t.multihashSize,s=ut(e.subarray(n,n+t.multihashSize));if(s.byteLength!==t.multihashSize)throw new Error("Incorrect length");let o=s.subarray(t.multihashSize-t.digestSize),i=new ir(t.multihashCode,t.digestSize,o,s);return[t.version===0?r.createV0(i):r.createV1(t.codec,i),e.subarray(t.size)]}static inspectBytes(e){let t=0,n=()=>{let[l,p]=Or(e.subarray(t));return t+=p,l},s=n(),o=Vr;if(s===18?(s=0,t=0):o=n(),s!==0&&s!==1)throw new RangeError(`Invalid CID version ${s}`);let i=t,a=n(),c=n(),f=t+c,u=f-i;return{version:s,codec:o,multihashCode:a,digestSize:c,multihashSize:u,size:f}}static parse(e,t){let[n,s]=bf(e,t),o=r.decode(s);if(o.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return po(o).set(n,e),o}};function bf(r,e){switch(r[0]){case"Q":{let t=e??ne;return[ne.prefix,t.decode(`${ne.prefix}${r}`)]}case ne.prefix:{let t=e??ne;return[ne.prefix,t.decode(r)]}case dt.prefix:{let t=e??dt;return[dt.prefix,t.decode(r)]}default:{if(e==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[r[0],e.decode(r)]}}}function wf(r,e,t){let{prefix:n}=t;if(n!==ne.prefix)throw Error(`Cannot string encode V0 in ${t.name} encoding`);let s=e.get(n);if(s==null){let o=t.encode(r).slice(1);return e.set(n,o),o}else return s}function xf(r,e,t){let{prefix:n}=t,s=e.get(n);if(s==null){let o=t.encode(r);return e.set(n,o),o}else return s}var Vr=112,vf=18;function ma(r,e,t){let n=or(r),s=n+or(e),o=new Uint8Array(s+t.byteLength);return sr(r,o,0),sr(e,o,n),o.set(t,s),o}var Ef=Symbol.for("@ipld/js-cid/CID");var kt={...ho,...so,...fo,...ro,...no,...io,...ao,...Zs,...uo,...oo},V0={...to,...Xs};function ba(r,e,t,n){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:n}}}var ya=ba("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),go=ba("ascii","a",r=>{let e="a";for(let t=0;t<r.length;t++)e+=String.fromCharCode(r[t]);return e},r=>{r=r.substring(1);let e=Ne(r.length);for(let t=0;t<r.length;t++)e[t]=r.charCodeAt(t);return e}),Bf={utf8:ya,"utf-8":ya,hex:kt.base16,latin1:go,ascii:go,binary:go,...kt},gn=Bf;function V(r,e="utf8"){let t=gn[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return t.decoder.decode(`${t.prefix}${r}`)}function Pe(r){return r==null?!1:typeof r.then=="function"&&typeof r.catch=="function"&&typeof r.finally=="function"}function ar(r){if(!Number.isSafeInteger(r)||r<0)throw new Error(`positive integer expected, not ${r}`)}function Af(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}function cr(r,...e){if(!Af(r))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(r.length))throw new Error(`Uint8Array expected of length ${e}, not of length=${r.length}`)}function mn(r){if(typeof r!="function"||typeof r.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");ar(r.outputLen),ar(r.blockLen)}function lr(r,e=!0){if(r.destroyed)throw new Error("Hash instance has been destroyed");if(e&&r.finished)throw new Error("Hash#digest() has already been called")}function wa(r,e){cr(r);let t=e.outputLen;if(r.length<t)throw new Error(`digestInto() expects output buffer of length at least ${t}`)}var yn=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;var fr=r=>new DataView(r.buffer,r.byteOffset,r.byteLength),Fe=(r,e)=>r<<32-e|r>>>e;var J0=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;var If=async()=>{};async function xa(r,e,t){let n=Date.now();for(let s=0;s<r;s++){t(s);let o=Date.now()-n;o>=0&&o<e||(await If(),n+=o)}}function va(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}function Nt(r){return typeof r=="string"&&(r=va(r)),cr(r),r}function mo(...r){let e=0;for(let n=0;n<r.length;n++){let s=r[n];cr(s),e+=s.length}let t=new Uint8Array(e);for(let n=0,s=0;n<r.length;n++){let o=r[n];t.set(o,s),s+=o.length}return t}var ur=class{clone(){return this._cloneInto()}},Sf={}.toString;function Ea(r,e){if(e!==void 0&&Sf.call(e)!=="[object Object]")throw new Error("Options should be object or undefined");return Object.assign(r,e)}function bn(r){let e=n=>r().update(Nt(n)).digest(),t=r();return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=()=>r(),e}function hr(r=32){if(yn&&typeof yn.getRandomValues=="function")return yn.getRandomValues(new Uint8Array(r));throw new Error("crypto.getRandomValues must be defined")}function kf(r,e,t,n){if(typeof r.setBigUint64=="function")return r.setBigUint64(e,t,n);let s=BigInt(32),o=BigInt(4294967295),i=Number(t>>s&o),a=Number(t&o),c=n?4:0,f=n?0:4;r.setUint32(e+c,i,n),r.setUint32(e+f,a,n)}var Ba=(r,e,t)=>r&e^~r&t,Aa=(r,e,t)=>r&e^r&t^e&t,dr=class extends ur{constructor(e,t,n,s){super(),this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=s,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=fr(this.buffer)}update(e){lr(this);let{view:t,buffer:n,blockLen:s}=this;e=Nt(e);let o=e.length;for(let i=0;i<o;){let a=Math.min(s-this.pos,o-i);if(a===s){let c=fr(e);for(;s<=o-i;i+=s)this.process(c,i);continue}n.set(e.subarray(i,i+a),this.pos),this.pos+=a,i+=a,this.pos===s&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){lr(this),wa(e,this),this.finished=!0;let{buffer:t,view:n,blockLen:s,isLE:o}=this,{pos:i}=this;t[i++]=128,this.buffer.subarray(i).fill(0),this.padOffset>s-i&&(this.process(n,0),i=0);for(let l=i;l<s;l++)t[l]=0;kf(n,s-8,BigInt(this.length*8),o),this.process(n,0);let a=fr(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let f=c/4,u=this.get();if(f>u.length)throw new Error("_sha2: outputLen bigger than state");for(let l=0;l<f;l++)a.setUint32(4*l,u[l],o)}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let n=e.slice(0,t);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());let{blockLen:t,buffer:n,length:s,finished:o,destroyed:i,pos:a}=this;return e.length=s,e.pos=a,e.finished=o,e.destroyed=i,s%t&&e.buffer.set(n),e}};var wn=BigInt(4294967295),yo=BigInt(32);function Ia(r,e=!1){return e?{h:Number(r&wn),l:Number(r>>yo&wn)}:{h:Number(r>>yo&wn)|0,l:Number(r&wn)|0}}function Nf(r,e=!1){let t=new Uint32Array(r.length),n=new Uint32Array(r.length);for(let s=0;s<r.length;s++){let{h:o,l:i}=Ia(r[s],e);[t[s],n[s]]=[o,i]}return[t,n]}var Rf=(r,e)=>BigInt(r>>>0)<<yo|BigInt(e>>>0),Tf=(r,e,t)=>r>>>t,_f=(r,e,t)=>r<<32-t|e>>>t,Cf=(r,e,t)=>r>>>t|e<<32-t,Lf=(r,e,t)=>r<<32-t|e>>>t,Uf=(r,e,t)=>r<<64-t|e>>>t-32,Pf=(r,e,t)=>r>>>t-32|e<<64-t,Of=(r,e)=>e,Vf=(r,e)=>r,Df=(r,e,t)=>r<<t|e>>>32-t,Mf=(r,e,t)=>e<<t|r>>>32-t,Hf=(r,e,t)=>e<<t-32|r>>>64-t,Ff=(r,e,t)=>r<<t-32|e>>>64-t;function Kf(r,e,t,n){let s=(e>>>0)+(n>>>0);return{h:r+t+(s/2**32|0)|0,l:s|0}}var qf=(r,e,t)=>(r>>>0)+(e>>>0)+(t>>>0),$f=(r,e,t,n)=>e+t+n+(r/2**32|0)|0,zf=(r,e,t,n)=>(r>>>0)+(e>>>0)+(t>>>0)+(n>>>0),Gf=(r,e,t,n,s)=>e+t+n+s+(r/2**32|0)|0,jf=(r,e,t,n,s)=>(r>>>0)+(e>>>0)+(t>>>0)+(n>>>0)+(s>>>0),Wf=(r,e,t,n,s,o)=>e+t+n+s+o+(r/2**32|0)|0;var Yf={fromBig:Ia,split:Nf,toBig:Rf,shrSH:Tf,shrSL:_f,rotrSH:Cf,rotrSL:Lf,rotrBH:Uf,rotrBL:Pf,rotr32H:Of,rotr32L:Vf,rotlSH:Df,rotlSL:Mf,rotlBH:Hf,rotlBL:Ff,add:Kf,add3L:qf,add3H:$f,add4L:zf,add4H:Gf,add5H:Wf,add5L:jf},P=Yf;var[Zf,Jf]=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))),Rt=new Uint32Array(80),Tt=new Uint32Array(80),bo=class extends dr{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){let{Ah:e,Al:t,Bh:n,Bl:s,Ch:o,Cl:i,Dh:a,Dl:c,Eh:f,El:u,Fh:l,Fl:p,Gh:b,Gl:d,Hh:h,Hl:y}=this;return[e,t,n,s,o,i,a,c,f,u,l,p,b,d,h,y]}set(e,t,n,s,o,i,a,c,f,u,l,p,b,d,h,y){this.Ah=e|0,this.Al=t|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=f|0,this.El=u|0,this.Fh=l|0,this.Fl=p|0,this.Gh=b|0,this.Gl=d|0,this.Hh=h|0,this.Hl=y|0}process(e,t){for(let x=0;x<16;x++,t+=4)Rt[x]=e.getUint32(t),Tt[x]=e.getUint32(t+=4);for(let x=16;x<80;x++){let T=Rt[x-15]|0,S=Tt[x-15]|0,I=P.rotrSH(T,S,1)^P.rotrSH(T,S,8)^P.shrSH(T,S,7),R=P.rotrSL(T,S,1)^P.rotrSL(T,S,8)^P.shrSL(T,S,7),k=Rt[x-2]|0,j=Tt[x-2]|0,H=P.rotrSH(k,j,19)^P.rotrBH(k,j,61)^P.shrSH(k,j,6),F=P.rotrSL(k,j,19)^P.rotrBL(k,j,61)^P.shrSL(k,j,6),oe=P.add4L(R,F,Tt[x-7],Tt[x-16]),ae=P.add4H(oe,I,H,Rt[x-7],Rt[x-16]);Rt[x]=ae|0,Tt[x]=oe|0}let{Ah:n,Al:s,Bh:o,Bl:i,Ch:a,Cl:c,Dh:f,Dl:u,Eh:l,El:p,Fh:b,Fl:d,Gh:h,Gl:y,Hh:v,Hl:w}=this;for(let x=0;x<80;x++){let T=P.rotrSH(l,p,14)^P.rotrSH(l,p,18)^P.rotrBH(l,p,41),S=P.rotrSL(l,p,14)^P.rotrSL(l,p,18)^P.rotrBL(l,p,41),I=l&b^~l&h,R=p&d^~p&y,k=P.add5L(w,S,R,Jf[x],Tt[x]),j=P.add5H(k,v,T,I,Zf[x],Rt[x]),H=k|0,F=P.rotrSH(n,s,28)^P.rotrBH(n,s,34)^P.rotrBH(n,s,39),oe=P.rotrSL(n,s,28)^P.rotrBL(n,s,34)^P.rotrBL(n,s,39),ae=n&o^n&a^o&a,N=s&i^s&c^i&c;v=h|0,w=y|0,h=b|0,y=d|0,b=l|0,d=p|0,{h:l,l:p}=P.add(f|0,u|0,j|0,H|0),f=a|0,u=c|0,a=o|0,c=i|0,o=n|0,i=s|0;let m=P.add3L(H,oe,N);n=P.add3H(m,j,F,ae),s=m|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:f,l:u}=P.add(this.Dh|0,this.Dl|0,f|0,u|0),{h:l,l:p}=P.add(this.Eh|0,this.El|0,l|0,p|0),{h:b,l:d}=P.add(this.Fh|0,this.Fl|0,b|0,d|0),{h,l:y}=P.add(this.Gh|0,this.Gl|0,h|0,y|0),{h:v,l:w}=P.add(this.Hh|0,this.Hl|0,v|0,w|0),this.set(n,s,o,i,a,c,f,u,l,p,b,d,h,y,v,w)}roundClean(){Rt.fill(0),Tt.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 Dr=bn(()=>new bo);var vn={};de(vn,{aInRange:()=>Re,abool:()=>Ke,abytes:()=>pr,bitGet:()=>sh,bitLen:()=>nh,bitMask:()=>Hr,bitSet:()=>oh,bytesToHex:()=>gt,bytesToNumberBE:()=>mt,bytesToNumberLE:()=>Ct,concatBytes:()=>yt,createHmacDrbg:()=>Bo,ensureBytes:()=>re,equalBytes:()=>th,hexToBytes:()=>Gt,hexToNumber:()=>Eo,inRange:()=>Mr,isBytes:()=>_t,memoized:()=>Wt,notImplemented:()=>ah,numberToBytesBE:()=>Lt,numberToBytesLE:()=>jt,numberToHexUnpadded:()=>Na,numberToVarBytesBE:()=>eh,utf8ToBytes:()=>rh,validateObject:()=>tt});var vo=BigInt(0),xn=BigInt(1),Xf=BigInt(2);function _t(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}function pr(r){if(!_t(r))throw new Error("Uint8Array expected")}function Ke(r,e){if(typeof e!="boolean")throw new Error(`${r} must be valid boolean, got "${e}".`)}var Qf=Array.from({length:256},(r,e)=>e.toString(16).padStart(2,"0"));function gt(r){pr(r);let e="";for(let t=0;t<r.length;t++)e+=Qf[r[t]];return e}function Na(r){let e=r.toString(16);return e.length&1?`0${e}`:e}function Eo(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return BigInt(r===""?"0":`0x${r}`)}var pt={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function Sa(r){if(r>=pt._0&&r<=pt._9)return r-pt._0;if(r>=pt._A&&r<=pt._F)return r-(pt._A-10);if(r>=pt._a&&r<=pt._f)return r-(pt._a-10)}function Gt(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);let e=r.length,t=e/2;if(e%2)throw new Error("padded hex string expected, got unpadded hex of length "+e);let n=new Uint8Array(t);for(let s=0,o=0;s<t;s++,o+=2){let i=Sa(r.charCodeAt(o)),a=Sa(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 mt(r){return Eo(gt(r))}function Ct(r){return pr(r),Eo(gt(Uint8Array.from(r).reverse()))}function Lt(r,e){return Gt(r.toString(16).padStart(e*2,"0"))}function jt(r,e){return Lt(r,e).reverse()}function eh(r){return Gt(Na(r))}function re(r,e,t){let n;if(typeof e=="string")try{n=Gt(e)}catch(o){throw new Error(`${r} must be valid hex string, got "${e}". Cause: ${o}`)}else if(_t(e))n=Uint8Array.from(e);else throw new Error(`${r} must be hex string or Uint8Array`);let s=n.length;if(typeof t=="number"&&s!==t)throw new Error(`${r} expected ${t} bytes, got ${s}`);return n}function yt(...r){let e=0;for(let n=0;n<r.length;n++){let s=r[n];pr(s),e+=s.length}let t=new Uint8Array(e);for(let n=0,s=0;n<r.length;n++){let o=r[n];t.set(o,s),s+=o.length}return t}function th(r,e){if(r.length!==e.length)return!1;let t=0;for(let n=0;n<r.length;n++)t|=r[n]^e[n];return t===0}function rh(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}var wo=r=>typeof r=="bigint"&&vo<=r;function Mr(r,e,t){return wo(r)&&wo(e)&&wo(t)&&e<=r&&r<t}function Re(r,e,t,n){if(!Mr(e,t,n))throw new Error(`expected valid ${r}: ${t} <= n < ${n}, got ${typeof e} ${e}`)}function nh(r){let e;for(e=0;r>vo;r>>=xn,e+=1);return e}function sh(r,e){return r>>BigInt(e)&xn}function oh(r,e,t){return r|(t?xn:vo)<<BigInt(e)}var Hr=r=>(Xf<<BigInt(r-1))-xn,xo=r=>new Uint8Array(r),ka=r=>Uint8Array.from(r);function Bo(r,e,t){if(typeof r!="number"||r<2)throw new Error("hashLen must be a number");if(typeof e!="number"||e<2)throw new Error("qByteLen must be a number");if(typeof t!="function")throw new Error("hmacFn must be a function");let n=xo(r),s=xo(r),o=0,i=()=>{n.fill(1),s.fill(0),o=0},a=(...l)=>t(s,n,...l),c=(l=xo())=>{s=a(ka([0]),l),n=a(),l.length!==0&&(s=a(ka([1]),l),n=a())},f=()=>{if(o++>=1e3)throw new Error("drbg: tried 1000 values");let l=0,p=[];for(;l<e;){n=a();let b=n.slice();p.push(b),l+=n.length}return yt(...p)};return(l,p)=>{i(),c(l);let b;for(;!(b=p(f()));)c();return i(),b}}var ih={bigint:r=>typeof r=="bigint",function:r=>typeof r=="function",boolean:r=>typeof r=="boolean",string:r=>typeof r=="string",stringOrUint8Array:r=>typeof r=="string"||_t(r),isSafeInteger:r=>Number.isSafeInteger(r),array:r=>Array.isArray(r),field:(r,e)=>e.Fp.isValid(r),hash:r=>typeof r=="function"&&Number.isSafeInteger(r.outputLen)};function tt(r,e,t={}){let n=(s,o,i)=>{let a=ih[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(e))n(s,o,!1);for(let[s,o]of Object.entries(t))n(s,o,!0);return r}var ah=()=>{throw new Error("not implemented")};function Wt(r){let e=new WeakMap;return(t,...n)=>{let s=e.get(t);if(s!==void 0)return s;let o=r(t,...n);return e.set(t,o),o}}var le=BigInt(0),Z=BigInt(1),Yt=BigInt(2),ch=BigInt(3),Ao=BigInt(4),Ra=BigInt(5),Ta=BigInt(8),lh=BigInt(9),uh=BigInt(16);function W(r,e){let t=r%e;return t>=le?t:e+t}function fh(r,e,t){if(t<=le||e<le)throw new Error("Expected power/modulo > 0");if(t===Z)return le;let n=Z;for(;e>le;)e&Z&&(n=n*r%t),r=r*r%t,e>>=Z;return n}function J(r,e,t){let n=r;for(;e-- >le;)n*=n,n%=t;return n}function En(r,e){if(r===le||e<=le)throw new Error(`invert: expected positive integers, got n=${r} mod=${e}`);let t=W(r,e),n=e,s=le,o=Z,i=Z,a=le;for(;t!==le;){let f=n/t,u=n%t,l=s-i*f,p=o-a*f;n=t,t=u,s=i,o=a,i=l,a=p}if(n!==Z)throw new Error("invert: does not exist");return W(s,e)}function hh(r){let e=(r-Z)/Yt,t,n,s;for(t=r-Z,n=0;t%Yt===le;t/=Yt,n++);for(s=Yt;s<r&&fh(s,e,r)!==r-Z;s++);if(n===1){let i=(r+Z)/Ao;return function(c,f){let u=c.pow(f,i);if(!c.eql(c.sqr(u),f))throw new Error("Cannot find square root");return u}}let o=(t+Z)/Yt;return function(a,c){if(a.pow(c,e)===a.neg(a.ONE))throw new Error("Cannot find square root");let f=n,u=a.pow(a.mul(a.ONE,s),t),l=a.pow(c,o),p=a.pow(c,t);for(;!a.eql(p,a.ONE);){if(a.eql(p,a.ZERO))return a.ZERO;let b=1;for(let h=a.sqr(p);b<f&&!a.eql(h,a.ONE);b++)h=a.sqr(h);let d=a.pow(u,Z<<BigInt(f-b-1));u=a.sqr(d),l=a.mul(l,d),p=a.mul(p,u),f=b}return l}}function dh(r){if(r%Ao===ch){let e=(r+Z)/Ao;return function(n,s){let o=n.pow(s,e);if(!n.eql(n.sqr(o),s))throw new Error("Cannot find square root");return o}}if(r%Ta===Ra){let e=(r-Ra)/Ta;return function(n,s){let o=n.mul(s,Yt),i=n.pow(o,e),a=n.mul(s,i),c=n.mul(n.mul(a,Yt),i),f=n.mul(a,n.sub(c,n.ONE));if(!n.eql(n.sqr(f),s))throw new Error("Cannot find square root");return f}}return r%uh,hh(r)}var _a=(r,e)=>(W(r,e)&Z)===Z,ph=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Io(r){let e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},t=ph.reduce((n,s)=>(n[s]="function",n),e);return tt(r,t)}function gh(r,e,t){if(t<le)throw new Error("Expected power > 0");if(t===le)return r.ONE;if(t===Z)return e;let n=r.ONE,s=e;for(;t>le;)t&Z&&(n=r.mul(n,s)),s=r.sqr(s),t>>=Z;return n}function mh(r,e){let t=new Array(e.length),n=e.reduce((o,i,a)=>r.is0(i)?o:(t[a]=o,r.mul(o,i)),r.ONE),s=r.inv(n);return e.reduceRight((o,i,a)=>r.is0(i)?o:(t[a]=r.mul(o,t[a]),r.mul(o,i)),s),t}function So(r,e){let t=e!==void 0?e:r.toString(2).length,n=Math.ceil(t/8);return{nBitLength:t,nByteLength:n}}function Bn(r,e,t=!1,n={}){if(r<=le)throw new Error(`Expected Field ORDER > 0, got ${r}`);let{nBitLength:s,nByteLength:o}=So(r,e);if(o>2048)throw new Error("Field lengths over 2048 bytes are not supported");let i=dh(r),a=Object.freeze({ORDER:r,BITS:s,BYTES:o,MASK:Hr(s),ZERO:le,ONE:Z,create:c=>W(c,r),isValid:c=>{if(typeof c!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof c}`);return le<=c&&c<r},is0:c=>c===le,isOdd:c=>(c&Z)===Z,neg:c=>W(-c,r),eql:(c,f)=>c===f,sqr:c=>W(c*c,r),add:(c,f)=>W(c+f,r),sub:(c,f)=>W(c-f,r),mul:(c,f)=>W(c*f,r),pow:(c,f)=>gh(a,c,f),div:(c,f)=>W(c*En(f,r),r),sqrN:c=>c*c,addN:(c,f)=>c+f,subN:(c,f)=>c-f,mulN:(c,f)=>c*f,inv:c=>En(c,r),sqrt:n.sqrt||(c=>i(a,c)),invertBatch:c=>mh(a,c),cmov:(c,f,u)=>u?f:c,toBytes:c=>t?jt(c,o):Lt(c,o),fromBytes:c=>{if(c.length!==o)throw new Error(`Fp.fromBytes: expected ${o}, got ${c.length}`);return t?Ct(c):mt(c)}});return Object.freeze(a)}function Ca(r){if(typeof r!="bigint")throw new Error("field order must be bigint");let e=r.toString(2).length;return Math.ceil(e/8)}function ko(r){let e=Ca(r);return e+Math.ceil(e/2)}function La(r,e,t=!1){let n=r.length,s=Ca(e),o=ko(e);if(n<16||n<o||n>1024)throw new Error(`expected ${o}-1024 bytes of input, got ${n}`);let i=t?mt(r):Ct(r),a=W(i,e-Z)+Z;return t?jt(a,s):Lt(a,s)}var bh=BigInt(0),No=BigInt(1),Ro=new WeakMap,Ua=new WeakMap;function An(r,e){let t=(o,i)=>{let a=i.negate();return o?a:i},n=o=>{if(!Number.isSafeInteger(o)||o<=0||o>e)throw new Error(`Wrong window size=${o}, should be [1..${e}]`)},s=o=>{n(o);let i=Math.ceil(e/o)+1,a=2**(o-1);return{windows:i,windowSize:a}};return{constTimeNegate:t,unsafeLadder(o,i){let a=r.ZERO,c=o;for(;i>bh;)i&No&&(a=a.add(c)),c=c.double(),i>>=No;return a},precomputeWindow(o,i){let{windows:a,windowSize:c}=s(i),f=[],u=o,l=u;for(let p=0;p<a;p++){l=u,f.push(l);for(let b=1;b<c;b++)l=l.add(u),f.push(l);u=l.double()}return f},wNAF(o,i,a){let{windows:c,windowSize:f}=s(o),u=r.ZERO,l=r.BASE,p=BigInt(2**o-1),b=2**o,d=BigInt(o);for(let h=0;h<c;h++){let y=h*f,v=Number(a&p);a>>=d,v>f&&(v-=b,a+=No);let w=y,x=y+Math.abs(v)-1,T=h%2!==0,S=v<0;v===0?l=l.add(t(T,i[w])):u=u.add(t(S,i[x]))}return{p:u,f:l}},wNAFCached(o,i,a){let c=Ua.get(o)||1,f=Ro.get(o);return f||(f=this.precomputeWindow(o,c),c!==1&&Ro.set(o,a(f))),this.wNAF(c,f,i)},setWindowSize(o,i){n(i),Ua.set(o,i),Ro.delete(o)}}}function Fr(r){return Io(r.Fp),tt(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 qe=BigInt(0),Te=BigInt(1),In=BigInt(2),wh=BigInt(8),xh={zip215:!0};function vh(r){let e=Fr(r);return tt(r,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...e})}function Pa(r){let e=vh(r),{Fp:t,n,prehash:s,hash:o,randomBytes:i,nByteLength:a,h:c}=e,f=In<<BigInt(a*8)-Te,u=t.create,l=e.uvRatio||((m,g)=>{try{return{isValid:!0,value:t.sqrt(m*t.inv(g))}}catch{return{isValid:!1,value:qe}}}),p=e.adjustScalarBytes||(m=>m),b=e.domain||((m,g,E)=>{if(Ke("phflag",E),g.length||E)throw new Error("Contexts/pre-hash are not supported");return m});function d(m,g){Re("coordinate "+m,g,qe,f)}function h(m){if(!(m instanceof w))throw new Error("ExtendedPoint expected")}let y=Wt((m,g)=>{let{ex:E,ey:B,ez:_}=m,L=m.is0();g==null&&(g=L?wh:t.inv(_));let U=u(E*g),K=u(B*g),O=u(_*g);if(L)return{x:qe,y:Te};if(O!==Te)throw new Error("invZ was invalid");return{x:U,y:K}}),v=Wt(m=>{let{a:g,d:E}=e;if(m.is0())throw new Error("bad point: ZERO");let{ex:B,ey:_,ez:L,et:U}=m,K=u(B*B),O=u(_*_),q=u(L*L),Q=u(q*q),ee=u(K*g),ke=u(q*u(ee+O)),fe=u(Q+u(E*u(K*O)));if(ke!==fe)throw new Error("bad point: equation left != right (1)");let ce=u(B*_),Me=u(L*U);if(ce!==Me)throw new Error("bad point: equation left != right (2)");return!0});class w{constructor(g,E,B,_){this.ex=g,this.ey=E,this.ez=B,this.et=_,d("x",g),d("y",E),d("z",B),d("t",_),Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(g){if(g instanceof w)throw new Error("extended point not allowed");let{x:E,y:B}=g||{};return d("x",E),d("y",B),new w(E,B,Te,u(E*B))}static normalizeZ(g){let E=t.invertBatch(g.map(B=>B.ez));return g.map((B,_)=>B.toAffine(E[_])).map(w.fromAffine)}_setWindowSize(g){S.setWindowSize(this,g)}assertValidity(){v(this)}equals(g){h(g);let{ex:E,ey:B,ez:_}=this,{ex:L,ey:U,ez:K}=g,O=u(E*K),q=u(L*_),Q=u(B*K),ee=u(U*_);return O===q&&Q===ee}is0(){return this.equals(w.ZERO)}negate(){return new w(u(-this.ex),this.ey,this.ez,u(-this.et))}double(){let{a:g}=e,{ex:E,ey:B,ez:_}=this,L=u(E*E),U=u(B*B),K=u(In*u(_*_)),O=u(g*L),q=E+B,Q=u(u(q*q)-L-U),ee=O+U,ke=ee-K,fe=O-U,ce=u(Q*ke),Me=u(ee*fe),he=u(Q*fe),He=u(ke*ee);return new w(ce,Me,He,he)}add(g){h(g);let{a:E,d:B}=e,{ex:_,ey:L,ez:U,et:K}=this,{ex:O,ey:q,ez:Q,et:ee}=g;if(E===BigInt(-1)){let qi=u((L-_)*(q+O)),$i=u((L+_)*(q-O)),$s=u($i-qi);if($s===qe)return this.double();let zi=u(U*In*ee),Gi=u(K*In*Q),ji=Gi+zi,Wi=$i+qi,Yi=Gi-zi,lu=u(ji*$s),uu=u(Wi*Yi),fu=u(ji*Yi),hu=u($s*Wi);return new w(lu,uu,hu,fu)}let ke=u(_*O),fe=u(L*q),ce=u(K*B*ee),Me=u(U*Q),he=u((_+L)*(O+q)-ke-fe),He=Me-ce,qt=Me+ce,Lr=u(fe-E*ke),fn=u(he*He),iu=u(qt*Lr),au=u(he*Lr),cu=u(He*qt);return new w(fn,iu,cu,au)}subtract(g){return this.add(g.negate())}wNAF(g){return S.wNAFCached(this,g,w.normalizeZ)}multiply(g){let E=g;Re("scalar",E,Te,n);let{p:B,f:_}=this.wNAF(E);return w.normalizeZ([B,_])[0]}multiplyUnsafe(g){let E=g;return Re("scalar",E,qe,n),E===qe?T:this.equals(T)||E===Te?this:this.equals(x)?this.wNAF(E).p:S.unsafeLadder(this,E)}isSmallOrder(){return this.multiplyUnsafe(c).is0()}isTorsionFree(){return S.unsafeLadder(this,n).is0()}toAffine(g){return y(this,g)}clearCofactor(){let{h:g}=e;return g===Te?this:this.multiplyUnsafe(g)}static fromHex(g,E=!1){let{d:B,a:_}=e,L=t.BYTES;g=re("pointHex",g,L),Ke("zip215",E);let U=g.slice(),K=g[L-1];U[L-1]=K&-129;let O=Ct(U),q=E?f:t.ORDER;Re("pointHex.y",O,qe,q);let Q=u(O*O),ee=u(Q-Te),ke=u(B*Q-_),{isValid:fe,value:ce}=l(ee,ke);if(!fe)throw new Error("Point.fromHex: invalid y coordinate");let Me=(ce&Te)===Te,he=(K&128)!==0;if(!E&&ce===qe&&he)throw new Error("Point.fromHex: x=0 and x_0=1");return he!==Me&&(ce=u(-ce)),w.fromAffine({x:ce,y:O})}static fromPrivateKey(g){return k(g).point}toRawBytes(){let{x:g,y:E}=this.toAffine(),B=jt(E,t.BYTES);return B[B.length-1]|=g&Te?128:0,B}toHex(){return gt(this.toRawBytes())}}w.BASE=new w(e.Gx,e.Gy,Te,u(e.Gx*e.Gy)),w.ZERO=new w(qe,Te,Te,qe);let{BASE:x,ZERO:T}=w,S=An(w,a*8);function I(m){return W(m,n)}function R(m){return I(Ct(m))}function k(m){let g=a;m=re("private key",m,g);let E=re("hashed private key",o(m),2*g),B=p(E.slice(0,g)),_=E.slice(g,2*g),L=R(B),U=x.multiply(L),K=U.toRawBytes();return{head:B,prefix:_,scalar:L,point:U,pointBytes:K}}function j(m){return k(m).pointBytes}function H(m=new Uint8Array,...g){let E=yt(...g);return R(o(b(E,re("context",m),!!s)))}function F(m,g,E={}){m=re("message",m),s&&(m=s(m));let{prefix:B,scalar:_,pointBytes:L}=k(g),U=H(E.context,B,m),K=x.multiply(U).toRawBytes(),O=H(E.context,K,L,m),q=I(U+O*_);Re("signature.s",q,qe,n);let Q=yt(K,jt(q,t.BYTES));return re("result",Q,a*2)}let oe=xh;function ae(m,g,E,B=oe){let{context:_,zip215:L}=B,U=t.BYTES;m=re("signature",m,2*U),g=re("message",g),L!==void 0&&Ke("zip215",L),s&&(g=s(g));let K=Ct(m.slice(U,2*U)),O,q,Q;try{O=w.fromHex(E,L),q=w.fromHex(m.slice(0,U),L),Q=x.multiplyUnsafe(K)}catch{return!1}if(!L&&O.isSmallOrder())return!1;let ee=H(_,q.toRawBytes(),O.toRawBytes(),g);return q.add(O.multiplyUnsafe(ee)).subtract(Q).clearCofactor().equals(w.ZERO)}return x._setWindowSize(8),{CURVE:e,getPublicKey:j,sign:F,verify:ae,ExtendedPoint:w,utils:{getExtendedPublicKey:k,randomPrivateKey:()=>i(t.BYTES),precompute(m=8,g=w.BASE){return g._setWindowSize(m),g.multiply(BigInt(3)),g}}}}var To=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),Oa=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),xg=BigInt(0),Eh=BigInt(1),Va=BigInt(2),vg=BigInt(3),Bh=BigInt(5),Ah=BigInt(8);function Ih(r){let e=BigInt(10),t=BigInt(20),n=BigInt(40),s=BigInt(80),o=To,a=r*r%o*r%o,c=J(a,Va,o)*a%o,f=J(c,Eh,o)*r%o,u=J(f,Bh,o)*f%o,l=J(u,e,o)*u%o,p=J(l,t,o)*l%o,b=J(p,n,o)*p%o,d=J(b,s,o)*b%o,h=J(d,s,o)*b%o,y=J(h,e,o)*u%o;return{pow_p_5_8:J(y,Va,o)*r%o,b2:a}}function Sh(r){return r[0]&=248,r[31]&=127,r[31]|=64,r}function kh(r,e){let t=To,n=W(e*e*e,t),s=W(n*n*e,t),o=Ih(r*s).pow_p_5_8,i=W(r*n*o,t),a=W(e*i*i,t),c=i,f=W(i*Oa,t),u=a===r,l=a===W(-r,t),p=a===W(-r*Oa,t);return u&&(i=c),(l||p)&&(i=f),_a(i,t)&&(i=W(-i,t)),{isValid:u||l,value:i}}var Nh=Bn(To,void 0,!0),Rh={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:Nh,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:Ah,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:Dr,randomBytes:hr,adjustScalarBytes:Sh,uvRatio:kh},gr=Pa(Rh);var mr=32,bt=64,Sn=32;function Da(){let r=gr.utils.randomPrivateKey(),e=gr.getPublicKey(r);return{privateKey:Ka(r,e),publicKey:e}}function Ma(r){if(r.length!==Sn)throw new TypeError('"seed" must be 32 bytes in length.');if(!(r instanceof Uint8Array))throw new TypeError('"seed" must be a node.js Buffer, or Uint8Array.');let e=r,t=gr.getPublicKey(e);return{privateKey:Ka(e,t),publicKey:t}}function Ha(r,e){let t=r.subarray(0,Sn);return gr.sign(e instanceof Uint8Array?e:e.subarray(),t)}function Fa(r,e,t){return gr.verify(e,t instanceof Uint8Array?t:t.subarray(),r)}function Ka(r,e){let t=new Uint8Array(bt);for(let n=0;n<Sn;n++)t[n]=r[n],t[Sn+n]=e[n];return t}var Ie={get(r=globalThis){let e=r.crypto;if(e?.subtle==null)throw Object.assign(new Error("Missing Web Crypto API. The most likely cause of this error is that this page is being accessed from an insecure context (i.e. not HTTPS). For more information and possible resolutions see https://github.com/libp2p/js-libp2p/blob/main/packages/crypto/README.md#web-crypto-api"),{code:"ERR_MISSING_WEB_CRYPTO"});return e}};var _o={alg:"A128GCM",ext:!0,k:"scm9jmO_4BJAgdwWGVulLg",key_ops:["encrypt","decrypt"],kty:"oct"};function qa(r){let e=r?.algorithm??"AES-GCM",t=r?.keyLength??16,n=r?.nonceLength??12,s=r?.digest??"SHA-256",o=r?.saltLength??16,i=r?.iterations??32767,a=Ie.get();t*=8;async function c(l,p){let b=a.getRandomValues(new Uint8Array(o)),d=a.getRandomValues(new Uint8Array(n)),h={name:e,iv:d};typeof p=="string"&&(p=V(p));let y;if(p.length===0){y=await a.subtle.importKey("jwk",_o,{name:"AES-GCM"},!0,["encrypt"]);try{let w={name:"PBKDF2",salt:b,iterations:i,hash:{name:s}},x=await a.subtle.importKey("raw",p,{name:"PBKDF2"},!1,["deriveKey"]);y=await a.subtle.deriveKey(w,x,{name:e,length:t},!0,["encrypt"])}catch{y=await a.subtle.importKey("jwk",_o,{name:"AES-GCM"},!0,["encrypt"])}}else{let w={name:"PBKDF2",salt:b,iterations:i,hash:{name:s}},x=await a.subtle.importKey("raw",p,{name:"PBKDF2"},!1,["deriveKey"]);y=await a.subtle.deriveKey(w,x,{name:e,length:t},!0,["encrypt"])}let v=await a.subtle.encrypt(h,y,l);return Ae([b,h.iv,new Uint8Array(v)])}async function f(l,p){let b=l.subarray(0,o),d=l.subarray(o,o+n),h=l.subarray(o+n),y={name:e,iv:d};typeof p=="string"&&(p=V(p));let v;if(p.length===0)try{let x={name:"PBKDF2",salt:b,iterations:i,hash:{name:s}},T=await a.subtle.importKey("raw",p,{name:"PBKDF2"},!1,["deriveKey"]);v=await a.subtle.deriveKey(x,T,{name:e,length:t},!0,["decrypt"])}catch{v=await a.subtle.importKey("jwk",_o,{name:"AES-GCM"},!0,["decrypt"])}else{let x={name:"PBKDF2",salt:b,iterations:i,hash:{name:s}},T=await a.subtle.importKey("raw",p,{name:"PBKDF2"},!1,["deriveKey"]);v=await a.subtle.deriveKey(x,T,{name:e,length:t},!0,["decrypt"])}let w=await a.subtle.decrypt(y,v,h);return new Uint8Array(w)}return{encrypt:c,decrypt:f}}async function yr(r,e){let n=await qa().encrypt(r,e);return co.encode(n)}var Ch=Math.pow(2,7),Lh=Math.pow(2,14),Uh=Math.pow(2,21),Co=Math.pow(2,28),Lo=Math.pow(2,35),Uo=Math.pow(2,42),Po=Math.pow(2,49),G=128,xe=127;function ve(r){if(r<Ch)return 1;if(r<Lh)return 2;if(r<Uh)return 3;if(r<Co)return 4;if(r<Lo)return 5;if(r<Uo)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 Oo(r,e,t=0){switch(ve(r)){case 8:e[t++]=r&255|G,r/=128;case 7:e[t++]=r&255|G,r/=128;case 6:e[t++]=r&255|G,r/=128;case 5:e[t++]=r&255|G,r/=128;case 4:e[t++]=r&255|G,r>>>=7;case 3:e[t++]=r&255|G,r>>>=7;case 2:e[t++]=r&255|G,r>>>=7;case 1:{e[t++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return e}function Ph(r,e,t=0){switch(ve(r)){case 8:e.set(t++,r&255|G),r/=128;case 7:e.set(t++,r&255|G),r/=128;case 6:e.set(t++,r&255|G),r/=128;case 5:e.set(t++,r&255|G),r/=128;case 4:e.set(t++,r&255|G),r>>>=7;case 3:e.set(t++,r&255|G),r>>>=7;case 2:e.set(t++,r&255|G),r>>>=7;case 1:{e.set(t++,r&255),r>>>=7;break}default:throw new Error("unreachable")}return e}function Vo(r,e){let t=r[e],n=0;if(n+=t&xe,t<G||(t=r[e+1],n+=(t&xe)<<7,t<G)||(t=r[e+2],n+=(t&xe)<<14,t<G)||(t=r[e+3],n+=(t&xe)<<21,t<G)||(t=r[e+4],n+=(t&xe)*Co,t<G)||(t=r[e+5],n+=(t&xe)*Lo,t<G)||(t=r[e+6],n+=(t&xe)*Uo,t<G)||(t=r[e+7],n+=(t&xe)*Po,t<G))return n;throw new RangeError("Could not decode varint")}function Oh(r,e){let t=r.get(e),n=0;if(n+=t&xe,t<G||(t=r.get(e+1),n+=(t&xe)<<7,t<G)||(t=r.get(e+2),n+=(t&xe)<<14,t<G)||(t=r.get(e+3),n+=(t&xe)<<21,t<G)||(t=r.get(e+4),n+=(t&xe)*Co,t<G)||(t=r.get(e+5),n+=(t&xe)*Lo,t<G)||(t=r.get(e+6),n+=(t&xe)*Uo,t<G)||(t=r.get(e+7),n+=(t&xe)*Po,t<G))return n;throw new RangeError("Could not decode varint")}function Oe(r,e,t=0){return e==null&&(e=Ne(ve(r))),e instanceof Uint8Array?Oo(r,e,t):Ph(r,e,t)}function wt(r,e=0){return r instanceof Uint8Array?Vo(r,e):Oh(r,e)}var Do=new Float32Array([-0]),Ut=new Uint8Array(Do.buffer);function $a(r,e,t){Do[0]=r,e[t]=Ut[0],e[t+1]=Ut[1],e[t+2]=Ut[2],e[t+3]=Ut[3]}function za(r,e){return Ut[0]=r[e],Ut[1]=r[e+1],Ut[2]=r[e+2],Ut[3]=r[e+3],Do[0]}var Mo=new Float64Array([-0]),Ee=new Uint8Array(Mo.buffer);function Ga(r,e,t){Mo[0]=r,e[t]=Ee[0],e[t+1]=Ee[1],e[t+2]=Ee[2],e[t+3]=Ee[3],e[t+4]=Ee[4],e[t+5]=Ee[5],e[t+6]=Ee[6],e[t+7]=Ee[7]}function ja(r,e){return Ee[0]=r[e],Ee[1]=r[e+1],Ee[2]=r[e+2],Ee[3]=r[e+3],Ee[4]=r[e+4],Ee[5]=r[e+5],Ee[6]=r[e+6],Ee[7]=r[e+7],Mo[0]}var Vh=BigInt(Number.MAX_SAFE_INTEGER),Dh=BigInt(Number.MIN_SAFE_INTEGER),Le=class r{lo;hi;constructor(e,t){this.lo=e|0,this.hi=t|0}toNumber(e=!1){if(!e&&this.hi>>>31>0){let t=~this.lo+1>>>0,n=~this.hi>>>0;return t===0&&(n=n+1>>>0),-(t+n*4294967296)}return this.lo+this.hi*4294967296}toBigInt(e=!1){if(e)return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31){let t=~this.lo+1>>>0,n=~this.hi>>>0;return t===0&&(n=n+1>>>0),-(BigInt(t)+(BigInt(n)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toString(e=!1){return this.toBigInt(e).toString()}zzEncode(){let e=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^e)>>>0,this.lo=(this.lo<<1^e)>>>0,this}zzDecode(){let e=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^e)>>>0,this.hi=(this.hi>>>1^e)>>>0,this}length(){let e=this.lo,t=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return n===0?t===0?e<16384?e<128?1:2:e<2097152?3:4:t<16384?t<128?5:6:t<2097152?7:8:n<128?9:10}static fromBigInt(e){if(e===0n)return Zt;if(e<Vh&&e>Dh)return this.fromNumber(Number(e));let t=e<0n;t&&(e=-e);let n=e>>32n,s=e-(n<<32n);return t&&(n=~n|0n,s=~s|0n,++s>Wa&&(s=0n,++n>Wa&&(n=0n))),new r(Number(s),Number(n))}static fromNumber(e){if(e===0)return Zt;let t=e<0;t&&(e=-e);let n=e>>>0,s=(e-n)/4294967296>>>0;return t&&(s=~s>>>0,n=~n>>>0,++n>4294967295&&(n=0,++s>4294967295&&(s=0))),new r(n,s)}static from(e){return typeof e=="number"?r.fromNumber(e):typeof e=="bigint"?r.fromBigInt(e):typeof e=="string"?r.fromBigInt(BigInt(e)):e.low!=null||e.high!=null?new r(e.low>>>0,e.high>>>0):Zt}},Zt=new Le(0,0);Zt.toBigInt=function(){return 0n};Zt.zzEncode=Zt.zzDecode=function(){return this};Zt.length=function(){return 1};var Wa=4294967296n;function Ya(r){let e=0,t=0;for(let n=0;n<r.length;++n)t=r.charCodeAt(n),t<128?e+=1:t<2048?e+=2:(t&64512)===55296&&(r.charCodeAt(n+1)&64512)===56320?(++n,e+=4):e+=3;return e}function Za(r,e,t){if(t-e<1)return"";let s,o=[],i=0,a;for(;e<t;)a=r[e++],a<128?o[i++]=a:a>191&&a<224?o[i++]=(a&31)<<6|r[e++]&63:a>239&&a<365?(a=((a&7)<<18|(r[e++]&63)<<12|(r[e++]&63)<<6|r[e++]&63)-65536,o[i++]=55296+(a>>10),o[i++]=56320+(a&1023)):o[i++]=(a&15)<<12|(r[e++]&63)<<6|r[e++]&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 Ho(r,e,t){let n=t,s,o;for(let i=0;i<r.length;++i)s=r.charCodeAt(i),s<128?e[t++]=s:s<2048?(e[t++]=s>>6|192,e[t++]=s&63|128):(s&64512)===55296&&((o=r.charCodeAt(i+1))&64512)===56320?(s=65536+((s&1023)<<10)+(o&1023),++i,e[t++]=s>>18|240,e[t++]=s>>12&63|128,e[t++]=s>>6&63|128,e[t++]=s&63|128):(e[t++]=s>>12|224,e[t++]=s>>6&63|128,e[t++]=s&63|128);return t-n}function $e(r,e){return RangeError(`index out of range: ${r.pos} + ${e??1} > ${r.len}`)}function Nn(r,e){return(r[e-4]|r[e-3]<<8|r[e-2]<<16|r[e-1]<<24)>>>0}var Fo=class{buf;pos;len;_slice=Uint8Array.prototype.subarray;constructor(e){this.buf=e,this.pos=0,this.len=e.length}uint32(){let e=4294967295;if(e=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(e=(e|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return e;if((this.pos+=5)>this.len)throw this.pos=this.len,$e(this,10);return e}int32(){return this.uint32()|0}sint32(){let e=this.uint32();return e>>>1^-(e&1)|0}bool(){return this.uint32()!==0}fixed32(){if(this.pos+4>this.len)throw $e(this,4);return Nn(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw $e(this,4);return Nn(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw $e(this,4);let e=za(this.buf,this.pos);return this.pos+=4,e}double(){if(this.pos+8>this.len)throw $e(this,4);let e=ja(this.buf,this.pos);return this.pos+=8,e}bytes(){let e=this.uint32(),t=this.pos,n=this.pos+e;if(n>this.len)throw $e(this,e);return this.pos+=e,t===n?new Uint8Array(0):this.buf.subarray(t,n)}string(){let e=this.bytes();return Za(e,0,e.length)}skip(e){if(typeof e=="number"){if(this.pos+e>this.len)throw $e(this,e);this.pos+=e}else do if(this.pos>=this.len)throw $e(this);while(this.buf[this.pos++]&128);return this}skipType(e){switch(e){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(e=this.uint32()&7)!==4;)this.skipType(e);break;case 5:this.skip(4);break;default:throw Error(`invalid wire type ${e} at offset ${this.pos}`)}return this}readLongVarint(){let e=new Le(0,0),t=0;if(this.len-this.pos>4){for(;t<4;++t)if(e.lo=(e.lo|(this.buf[this.pos]&127)<<t*7)>>>0,this.buf[this.pos++]<128)return e;if(e.lo=(e.lo|(this.buf[this.pos]&127)<<28)>>>0,e.hi=(e.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return e;t=0}else{for(;t<3;++t){if(this.pos>=this.len)throw $e(this);if(e.lo=(e.lo|(this.buf[this.pos]&127)<<t*7)>>>0,this.buf[this.pos++]<128)return e}return e.lo=(e.lo|(this.buf[this.pos++]&127)<<t*7)>>>0,e}if(this.len-this.pos>4){for(;t<5;++t)if(e.hi=(e.hi|(this.buf[this.pos]&127)<<t*7+3)>>>0,this.buf[this.pos++]<128)return e}else for(;t<5;++t){if(this.pos>=this.len)throw $e(this);if(e.hi=(e.hi|(this.buf[this.pos]&127)<<t*7+3)>>>0,this.buf[this.pos++]<128)return e}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw $e(this,8);let e=Nn(this.buf,this.pos+=4),t=Nn(this.buf,this.pos+=4);return new Le(e,t)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){let e=Vo(this.buf,this.pos);return this.pos+=ve(e),e}uint64String(){return this.readLongVarint().toString(!0)}sint64(){return this.readLongVarint().zzDecode().toBigInt()}sint64Number(){return this.readLongVarint().zzDecode().toNumber()}sint64String(){return this.readLongVarint().zzDecode().toString()}fixed64(){return this.readFixed64().toBigInt()}fixed64Number(){return this.readFixed64().toNumber()}fixed64String(){return this.readFixed64().toString()}sfixed64(){return this.readFixed64().toBigInt()}sfixed64Number(){return this.readFixed64().toNumber()}sfixed64String(){return this.readFixed64().toString()}};function Ko(r){return new Fo(r instanceof Uint8Array?r:r.subarray())}function ze(r,e,t){let n=Ko(r);return e.decode(n,void 0,t)}function qo(r){let e=r??8192,t=e>>>1,n,s=e;return function(i){if(i<1||i>t)return Ne(i);s+i>e&&(n=Ne(e),s=0);let a=n.subarray(s,s+=i);return s&7&&(s=(s|7)+1),a}}var Jt=class{fn;len;next;val;constructor(e,t,n){this.fn=e,this.len=t,this.next=void 0,this.val=n}};function $o(){}var Go=class{head;tail;len;next;constructor(e){this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}},Mh=qo();function Hh(r){return globalThis.Buffer!=null?Ne(r):Mh(r)}var qr=class{len;head;tail;states;constructor(){this.len=0,this.head=new Jt($o,0,0),this.tail=this.head,this.states=null}_push(e,t,n){return this.tail=this.tail.next=new Jt(e,t,n),this.len+=t,this}uint32(e){return this.len+=(this.tail=this.tail.next=new jo((e=e>>>0)<128?1:e<16384?2:e<2097152?3:e<268435456?4:5,e)).len,this}int32(e){return e<0?this._push(Rn,10,Le.fromNumber(e)):this.uint32(e)}sint32(e){return this.uint32((e<<1^e>>31)>>>0)}uint64(e){let t=Le.fromBigInt(e);return this._push(Rn,t.length(),t)}uint64Number(e){return this._push(Oo,ve(e),e)}uint64String(e){return this.uint64(BigInt(e))}int64(e){return this.uint64(e)}int64Number(e){return this.uint64Number(e)}int64String(e){return this.uint64String(e)}sint64(e){let t=Le.fromBigInt(e).zzEncode();return this._push(Rn,t.length(),t)}sint64Number(e){let t=Le.fromNumber(e).zzEncode();return this._push(Rn,t.length(),t)}sint64String(e){return this.sint64(BigInt(e))}bool(e){return this._push(zo,1,e?1:0)}fixed32(e){return this._push(Kr,4,e>>>0)}sfixed32(e){return this.fixed32(e)}fixed64(e){let t=Le.fromBigInt(e);return this._push(Kr,4,t.lo)._push(Kr,4,t.hi)}fixed64Number(e){let t=Le.fromNumber(e);return this._push(Kr,4,t.lo)._push(Kr,4,t.hi)}fixed64String(e){return this.fixed64(BigInt(e))}sfixed64(e){return this.fixed64(e)}sfixed64Number(e){return this.fixed64Number(e)}sfixed64String(e){return this.fixed64String(e)}float(e){return this._push($a,4,e)}double(e){return this._push(Ga,8,e)}bytes(e){let t=e.length>>>0;return t===0?this._push(zo,1,0):this.uint32(t)._push(Kh,t,e)}string(e){let t=Ya(e);return t!==0?this.uint32(t)._push(Ho,t,e):this._push(zo,1,0)}fork(){return this.states=new Go(this),this.head=this.tail=new Jt($o,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 Jt($o,0,0),this.len=0),this}ldelim(){let e=this.head,t=this.tail,n=this.len;return this.reset().uint32(n),n!==0&&(this.tail.next=e.next,this.tail=t,this.len+=n),this}finish(){let e=this.head.next,t=Hh(this.len),n=0;for(;e!=null;)e.fn(e.val,t,n),n+=e.len,e=e.next;return t}};function zo(r,e,t){e[t]=r&255}function Fh(r,e,t){for(;r>127;)e[t++]=r&127|128,r>>>=7;e[t]=r}var jo=class extends Jt{next;constructor(e,t){super(Fh,e,t),this.next=void 0}};function Rn(r,e,t){for(;r.hi!==0;)e[t++]=r.lo&127|128,r.lo=(r.lo>>>7|r.hi<<25)>>>0,r.hi>>>=7;for(;r.lo>127;)e[t++]=r.lo&127|128,r.lo=r.lo>>>7;e[t++]=r.lo}function Kr(r,e,t){e[t]=r&255,e[t+1]=r>>>8&255,e[t+2]=r>>>16&255,e[t+3]=r>>>24}function Kh(r,e,t){e.set(r,t)}globalThis.Buffer!=null&&(qr.prototype.bytes=function(r){let e=r.length>>>0;return this.uint32(e),e>0&&this._push(qh,e,r),this},qr.prototype.string=function(r){let e=globalThis.Buffer.byteLength(r);return this.uint32(e),e>0&&this._push($h,e,r),this});function qh(r,e,t){e.set(r,t)}function $h(r,e,t){r.length<40?Ho(r,e,t):e.utf8Write!=null?e.utf8Write(r,t):e.set(V(r),t)}function Wo(){return new qr}function Ge(r,e){let t=Wo();return e.encode(r,t,{lengthDelimited:!1}),t.finish()}var br;(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"})(br||(br={}));function Tn(r,e,t,n){return{name:r,type:e,encode:t,decode:n}}function Yo(r){function e(s){if(r[s.toString()]==null)throw new Error("Invalid enum value");return r[s]}let t=function(o,i){let a=e(o);i.int32(a)},n=function(o){let i=o.int32();return e(i)};return Tn("enum",br.VARINT,t,n)}function je(r,e){return Tn("message",br.LENGTH_DELIMITED,r,e)}var X;(function(r){r.RSA="RSA",r.Ed25519="Ed25519",r.Secp256k1="Secp256k1"})(X||(X={}));var Zo;(function(r){r[r.RSA=0]="RSA",r[r.Ed25519=1]="Ed25519",r[r.Secp256k1=2]="Secp256k1"})(Zo||(Zo={}));(function(r){r.codec=()=>Yo(Zo)})(X||(X={}));var rt;(function(r){let e;r.codec=()=>(e==null&&(e=je((t,n,s={})=>{s.lengthDelimited!==!1&&n.fork(),t.Type!=null&&(n.uint32(8),X.codec().encode(t.Type,n)),t.Data!=null&&(n.uint32(18),n.bytes(t.Data)),s.lengthDelimited!==!1&&n.ldelim()},(t,n)=>{let s={},o=n==null?t.len:t.pos+n;for(;t.pos<o;){let i=t.uint32();switch(i>>>3){case 1:s.Type=X.codec().decode(t);break;case 2:s.Data=t.bytes();break;default:t.skipType(i&7);break}}return s})),e),r.encode=t=>Ge(t,r.codec()),r.decode=t=>ze(t,r.codec())})(rt||(rt={}));var nt;(function(r){let e;r.codec=()=>(e==null&&(e=je((t,n,s={})=>{s.lengthDelimited!==!1&&n.fork(),t.Type!=null&&(n.uint32(8),X.codec().encode(t.Type,n)),t.Data!=null&&(n.uint32(18),n.bytes(t.Data)),s.lengthDelimited!==!1&&n.ldelim()},(t,n)=>{let s={},o=n==null?t.len:t.pos+n;for(;t.pos<o;){let i=t.uint32();switch(i>>>3){case 1:s.Type=X.codec().decode(t);break;case 2:s.Data=t.bytes();break;default:t.skipType(i&7);break}}return s})),e),r.encode=t=>Ge(t,r.codec()),r.decode=t=>ze(t,r.codec())})(nt||(nt={}));var $r=class{_key;constructor(e){this._key=wr(e,mr)}verify(e,t){return Fa(this._key,t,e)}marshal(){return this._key}get bytes(){return rt.encode({Type:X.Ed25519,Data:this.marshal()}).subarray()}equals(e){return pe(this.bytes,e.bytes)}hash(){let e=ye.digest(this.bytes);return Pe(e)?e.then(({bytes:t})=>t):e.bytes}},Xt=class{_key;_publicKey;constructor(e,t){this._key=wr(e,bt),this._publicKey=wr(t,mr)}sign(e){return Ha(this._key,e)}get public(){return new $r(this._publicKey)}marshal(){return this._key}get bytes(){return nt.encode({Type:X.Ed25519,Data:this.marshal()}).subarray()}equals(e){return pe(this.bytes,e.bytes)}async hash(){let e=ye.digest(this.bytes),t;return Pe(e)?{bytes:t}=await e:t=e.bytes,t}async id(){let e=ft.digest(this.public.bytes);return ne.encode(e.bytes).substring(1)}async export(e,t="libp2p-key"){if(t==="libp2p-key")return yr(this.bytes,e);throw new C(`export format '${t}' is not supported`,"ERR_INVALID_EXPORT_FORMAT")}};function zh(r){if(r.length>bt){r=wr(r,bt+mr);let n=r.subarray(0,bt),s=r.subarray(bt,r.length);return new Xt(n,s)}r=wr(r,bt);let e=r.subarray(0,bt),t=r.subarray(mr);return new Xt(e,t)}function Gh(r){return r=wr(r,mr),new $r(r)}async function jh(){let{privateKey:r,publicKey:e}=Da();return new Xt(r,e)}async function Xa(r){let{privateKey:e,publicKey:t}=Ma(r);return new Xt(e,t)}function wr(r,e){if(r=Uint8Array.from(r??[]),r.length!==e)throw new C(`Key must be a Uint8Array of length ${e}, got ${r.length}`,"ERR_INVALID_KEY_TYPE");return r}function D(r,e="utf8"){let t=gn[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return t.encoder.encode(r).substring(1)}var ai={};de(ai,{MAX_RSA_KEY_SIZE:()=>rn,RsaPrivateKey:()=>Ar,RsaPublicKey:()=>tn,fromJwk:()=>xd,generateKeyPair:()=>vd,unmarshalRsaPrivateKey:()=>oi,unmarshalRsaPublicKey:()=>wd});function Qt(r){if(isNaN(r)||r<=0)throw new C("random bytes length must be a Number bigger than 0","ERR_INVALID_LENGTH");return hr(r)}var Dt={};de(Dt,{exportToPem:()=>pd,importFromPem:()=>gd,jwkToPkcs1:()=>ud,jwkToPkix:()=>hd,pkcs1ToJwk:()=>ld,pkixToJwk:()=>fd});var Cn=class extends ur{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,mn(e);let n=Nt(t);if(this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let s=this.blockLen,o=new Uint8Array(s);o.set(n.length>s?e.create().update(n).digest():n);for(let i=0;i<o.length;i++)o[i]^=54;this.iHash.update(o),this.oHash=e.create();for(let i=0;i<o.length;i++)o[i]^=106;this.oHash.update(o),o.fill(0)}update(e){return lr(this),this.iHash.update(e),this}digestInto(e){lr(this),cr(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){let e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));let{oHash:t,iHash:n,finished:s,destroyed:o,blockLen:i,outputLen:a}=this;return e=e,e.finished=s,e.destroyed=o,e.blockLen=i,e.outputLen=a,e.oHash=t._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},zr=(r,e,t)=>new Cn(r,e).update(t).digest();zr.create=(r,e)=>new Cn(r,e);function Wh(r,e,t,n){mn(r);let s=Ea({dkLen:32,asyncTick:10},n),{c:o,dkLen:i,asyncTick:a}=s;if(ar(o),ar(i),ar(a),o<1)throw new Error("PBKDF2: iterations (c) should be >= 1");let c=Nt(e),f=Nt(t),u=new Uint8Array(i),l=zr.create(r,c),p=l._cloneInto().update(f);return{c:o,dkLen:i,asyncTick:a,DK:u,PRF:l,PRFSalt:p}}function Yh(r,e,t,n,s){return r.destroy(),e.destroy(),n&&n.destroy(),s.fill(0),t}async function Xo(r,e,t,n){let{c:s,dkLen:o,asyncTick:i,DK:a,PRF:c,PRFSalt:f}=Wh(r,e,t,n),u,l=new Uint8Array(4),p=fr(l),b=new Uint8Array(c.outputLen);for(let d=1,h=0;h<o;d++,h+=c.outputLen){let y=a.subarray(h,h+c.outputLen);p.setInt32(0,d,!1),(u=f._cloneInto(u)).update(l).digestInto(b),y.set(b.subarray(0,y.length)),await xa(s-1,i,()=>{c._cloneInto(u).update(b).digestInto(b);for(let v=0;v<y.length;v++)y[v]^=b[v]})}return Yh(c,f,a,u,b)}var M=Xi(Qa());function er(r,e){let t=0;if(r.length===1)return r[0];for(let n=r.length-1;n>=0;n--)t+=r[r.length-1-n]*Math.pow(2,e*n);return t}function Pt(r,e,t=-1){let n=t,s=r,o=0,i=Math.pow(2,e);for(let a=1;a<8;a++){if(r<i){let c;if(n<0)c=new ArrayBuffer(a),o=a;else{if(n<a)return new ArrayBuffer(0);c=new ArrayBuffer(n),o=n}let f=new Uint8Array(c);for(let u=a-1;u>=0;u--){let l=Math.pow(2,u*e);f[o-u-1]=Math.floor(s/l),s-=f[o-u-1]*l}return c}i*=Math.pow(2,e)}return new ArrayBuffer(0)}function Pn(...r){let e=0,t=0;for(let o of r)e+=o.length;let n=new ArrayBuffer(e),s=new Uint8Array(n);for(let o of r)s.set(o,t),t+=o.length;return s}function ei(){let r=new Uint8Array(this.valueHex);if(this.valueHex.byteLength>=2){let a=r[0]===255&&r[1]&128,c=r[0]===0&&(r[1]&128)===0;(a||c)&&this.warnings.push("Needlessly long format")}let e=new ArrayBuffer(this.valueHex.byteLength),t=new Uint8Array(e);for(let a=0;a<this.valueHex.byteLength;a++)t[a]=0;t[0]=r[0]&128;let n=er(t,8),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,er(o,8)-n}function ec(r){let e=r<0?r*-1:r,t=128;for(let n=1;n<8;n++){if(e<=t){if(r<0){let i=t-e,a=Pt(i,8,n),c=new Uint8Array(a);return c[0]|=128,a}let s=Pt(e,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}t*=Math.pow(2,8)}return new ArrayBuffer(0)}function tc(r,e){if(r.byteLength!==e.byteLength)return!1;let t=new Uint8Array(r),n=new Uint8Array(e);for(let s=0;s<t.length;s++)if(t[s]!==n[s])return!1;return!0}function _e(r,e){let t=r.toString(10);if(e<t.length)return"";let n=e-t.length,s=new Array(n);for(let i=0;i<n;i++)s[i]="0";return s.join("").concat(t)}var Rm=Math.log(2);function On(){if(typeof BigInt>"u")throw new Error("BigInt is not defined. Your environment doesn't implement BigInt.")}function ti(r){let e=0,t=0;for(let s=0;s<r.length;s++){let o=r[s];e+=o.byteLength}let n=new Uint8Array(e);for(let s=0;s<r.length;s++){let o=r[s];n.set(new Uint8Array(o),t),t+=o.byteLength}return n.buffer}function At(r,e,t,n){return e instanceof Uint8Array?e.byteLength?t<0?(r.error="Wrong parameter: inputOffset less than zero",!1):n<0?(r.error="Wrong parameter: inputLength less than zero",!1):e.byteLength-t-n<0?(r.error="End of input reached before message was fully decoded (inconsistent offset and length values)",!1):!0:(r.error="Wrong parameter: inputBuffer has zero length",!1):(r.error="Wrong parameter: inputBuffer must be 'Uint8Array'",!1)}var jr=class{constructor(){this.items=[]}write(e){this.items.push(e)}final(){return ti(this.items)}},Gr=[new Uint8Array([1])],rc="0123456789";var Er="",Ye=new ArrayBuffer(0),ri=new Uint8Array(0),Wr="EndOfContent",sc="OCTET STRING",oc="BIT STRING";function It(r){var e;return e=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):ri}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(!At(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",Ye)}toJSON(){return{...super.toJSON(),isHexOnly:this.isHexOnly,valueHex:M.Convert.ToHex(this.valueHexView)}}},e.NAME="hexBlock",e}var vt=class{constructor({blockLength:e=0,error:t=Er,warnings:n=[],valueBeforeDecode:s=ri}={}){this.blockLength=e,this.error=t,this.warnings=n,this.valueBeforeDecodeView=M.BufferSourceConverter.toUint8Array(s)}static blockName(){return this.NAME}get valueBeforeDecode(){return this.valueBeforeDecodeView.slice().buffer}set valueBeforeDecode(e){this.valueBeforeDecodeView=new Uint8Array(e)}toJSON(){return{blockName:this.constructor.NAME,blockLength:this.blockLength,error:this.error,warnings:this.warnings,valueBeforeDecode:M.Convert.ToHex(this.valueBeforeDecodeView)}}};vt.NAME="baseBlock";var Be=class extends vt{fromBER(e,t,n){throw TypeError("User need to make a specific function in a class which extends 'ValueBlock'")}toBER(e,t){throw TypeError("User need to make a specific function in a class which extends 'ValueBlock'")}};Be.NAME="valueBlock";var Vn=class extends It(vt){constructor({idBlock:e={}}={}){var t,n,s,o;super(),e?(this.isHexOnly=(t=e.isHexOnly)!==null&&t!==void 0?t:!1,this.valueHexView=e.valueHex?M.BufferSourceConverter.toUint8Array(e.valueHex):ri,this.tagClass=(n=e.tagClass)!==null&&n!==void 0?n:-1,this.tagNumber=(s=e.tagNumber)!==null&&s!==void 0?s:-1,this.isConstructed=(o=e.isConstructed)!==null&&o!==void 0?o:!1):(this.tagClass=-1,this.tagNumber=-1,this.isConstructed=!1)}toBER(e=!1){let t=0;switch(this.tagClass){case 1:t|=0;break;case 2:t|=64;break;case 3:t|=128;break;case 4:t|=192;break;default:return this.error="Unknown tag class",Ye}if(this.isConstructed&&(t|=32),this.tagNumber<31&&!this.isHexOnly){let s=new Uint8Array(1);if(!e){let o=this.tagNumber;o&=31,t|=o,s[0]=t}return s.buffer}if(!this.isHexOnly){let s=Pt(this.tagNumber,7),o=new Uint8Array(s),i=s.byteLength,a=new Uint8Array(i+1);if(a[0]=t|31,!e){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]=t|31,!e){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(e,t,n){let s=M.BufferSourceConverter.toUint8Array(e);if(!At(this,s,t,n))return-1;let o=s.subarray(t,t+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,f=this.valueHexView=new Uint8Array(255),u=255;for(;o[c]&128;){if(f[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 p=new Uint8Array(u);for(let b=0;b<f.length;b++)p[b]=f[b];f=this.valueHexView=new Uint8Array(u)}}this.blockLength=c+1,f[c-1]=o[c]&127;let l=new Uint8Array(c);for(let p=0;p<c;p++)l[p]=f[p];f=this.valueHexView=new Uint8Array(c),f.set(l),this.blockLength<=9?this.tagNumber=er(f,7):(this.isHexOnly=!0,this.warnings.push("Tag too long, represented as hex-coded"))}if(this.tagClass===1&&this.isConstructed)switch(this.tagNumber){case 1:case 2:case 5:case 6:case 9:case 13:case 14:case 23:case 24:case 31:case 32:case 33:case 34:return this.error="Constructed encoding used for primitive type",-1}return t+this.blockLength}toJSON(){return{...super.toJSON(),tagClass:this.tagClass,tagNumber:this.tagNumber,isConstructed:this.isConstructed}}};Vn.NAME="identificationBlock";var Dn=class extends vt{constructor({lenBlock:e={}}={}){var t,n,s;super(),this.isIndefiniteForm=(t=e.isIndefiniteForm)!==null&&t!==void 0?t:!1,this.longFormUsed=(n=e.longFormUsed)!==null&&n!==void 0?n:!1,this.length=(s=e.length)!==null&&s!==void 0?s:0}fromBER(e,t,n){let s=M.BufferSourceConverter.toUint8Array(e);if(!At(this,s,t,n))return-1;let o=s.subarray(t,t+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,t+this.blockLength;if(this.longFormUsed=!!(o[0]&128),this.longFormUsed===!1)return this.length=o[0],this.blockLength=1,t+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=t+1,c=s.subarray(a,a+i);return c[i-1]===0&&this.warnings.push("Needlessly long encoded length"),this.length=er(c,8),this.longFormUsed&&this.length<=127&&this.warnings.push("Unnecessary usage of long length form"),this.blockLength=i+1,t+this.blockLength}toBER(e=!1){let t,n;if(this.length>127&&(this.longFormUsed=!0),this.isIndefiniteForm)return t=new ArrayBuffer(1),e===!1&&(n=new Uint8Array(t),n[0]=128),t;if(this.longFormUsed){let s=Pt(this.length,8);if(s.byteLength>127)return this.error="Too big length",Ye;if(t=new ArrayBuffer(s.byteLength+1),e)return t;let o=new Uint8Array(s);n=new Uint8Array(t),n[0]=s.byteLength|128;for(let i=0;i<s.byteLength;i++)n[i+1]=o[i];return t}return t=new ArrayBuffer(1),e===!1&&(n=new Uint8Array(t),n[0]=this.length),t}toJSON(){return{...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,longFormUsed:this.longFormUsed,length:this.length}}};Dn.NAME="lengthBlock";var A={},be=class extends vt{constructor({name:e=Er,optional:t=!1,primitiveSchema:n,...s}={},o){super(s),this.name=e,this.optional=t,n&&(this.primitiveSchema=n),this.idBlock=new Vn(s),this.lenBlock=new Dn(s),this.valueBlock=o?new o(s):new Be(s)}fromBER(e,t,n){let s=this.valueBlock.fromBER(e,t,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(e,t){let n=t||new jr;t||ic(this);let s=this.idBlock.toBER(e);if(n.write(s),this.lenBlock.isIndefiniteForm)n.write(new Uint8Array([128]).buffer),this.valueBlock.toBER(e,n),n.write(new ArrayBuffer(2));else{let o=this.valueBlock.toBER(e);this.lenBlock.length=o.byteLength;let i=this.lenBlock.toBER(e);n.write(i),n.write(o)}return t?Ye:n.final()}toJSON(){let e={...super.toJSON(),idBlock:this.idBlock.toJSON(),lenBlock:this.lenBlock.toJSON(),valueBlock:this.valueBlock.toJSON(),name:this.name,optional:this.optional};return this.primitiveSchema&&(e.primitiveSchema=this.primitiveSchema.toJSON()),e}toString(e="ascii"){return e==="ascii"?this.onAsciiEncoding():M.Convert.ToHex(this.toBER())}onAsciiEncoding(){return`${this.constructor.NAME} : ${M.Convert.ToHex(this.valueBlock.valueBeforeDecodeView)}`}isEqual(e){if(this===e)return!0;if(!(e instanceof this.constructor))return!1;let t=this.toBER(),n=e.toBER();return tc(t,n)}};be.NAME="BaseBlock";function ic(r){if(r instanceof A.Constructed)for(let e of r.valueBlock.value)ic(e)&&(r.lenBlock.isIndefiniteForm=!0);return!!r.lenBlock.isIndefiniteForm}var Mn=class extends be{constructor({value:e=Er,...t}={},n){super(t,n),e&&this.fromString(e)}getValue(){return this.valueBlock.value}setValue(e){this.valueBlock.value=e}fromBER(e,t,n){let s=this.valueBlock.fromBER(e,t,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}'`}};Mn.NAME="BaseStringBlock";var Hn=class extends It(Be){constructor({isHexOnly:e=!0,...t}={}){super(t),this.isHexOnly=e}};Hn.NAME="PrimitiveValueBlock";var ac,Fn=class extends be{constructor(e={}){super(e,Hn),this.idBlock.isConstructed=!1}};ac=Fn;A.Primitive=ac;Fn.NAME="PRIMITIVE";function sd(r,e){if(r instanceof e)return r;let t=new e;return t.idBlock=r.idBlock,t.lenBlock=r.lenBlock,t.warnings=r.warnings,t.valueBeforeDecodeView=r.valueBeforeDecodeView,t}function xs(r,e=0,t=r.length){let n=e,s=new be({},Be),o=new vt;if(!At(o,r,e,t))return s.error=o.error,{offset:-1,result:s};if(!r.subarray(e,e+t).length)return s.error="Zero buffer length",{offset:-1,result:s};let a=s.idBlock.fromBER(r,e,t);if(s.idBlock.warnings.length&&s.warnings.concat(s.idBlock.warnings),a===-1)return s.error=s.idBlock.error,{offset:-1,result:s};if(e=a,t-=s.idBlock.blockLength,a=s.lenBlock.fromBER(r,e,t),s.lenBlock.warnings.length&&s.warnings.concat(s.lenBlock.warnings),a===-1)return s.error=s.lenBlock.error,{offset:-1,result:s};if(e=a,t-=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=be;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 f=s.idBlock.isConstructed?new A.Constructed:new A.Primitive;f.idBlock=s.idBlock,f.lenBlock=s.lenBlock,f.warnings=s.warnings,s=f}}break;case 2:case 3:case 4:default:c=s.idBlock.isConstructed?A.Constructed:A.Primitive}return s=sd(s,c),a=s.fromBER(r,e,s.lenBlock.isIndefiniteForm?t:s.lenBlock.length),s.valueBeforeDecodeView=r.subarray(n,n+s.blockLength),{offset:a,result:s}}function Br(r){if(!r.byteLength){let e=new be({},Be);return e.error="Input buffer has zero length",{offset:-1,result:e}}return xs(M.BufferSourceConverter.toUint8Array(r).slice(),0,r.byteLength)}function od(r,e){return r?1:e}var st=class extends Be{constructor({value:e=[],isIndefiniteForm:t=!1,...n}={}){super(n),this.value=e,this.isIndefiniteForm=t}fromBER(e,t,n){let s=M.BufferSourceConverter.toUint8Array(e);if(!At(this,s,t,n))return-1;if(this.valueBeforeDecodeView=s.subarray(t,t+n),this.valueBeforeDecodeView.length===0)return this.warnings.push("Zero buffer length"),t;let o=t;for(;od(this.isIndefiniteForm,n)>0;){let i=xs(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===Wr)break}return this.isIndefiniteForm&&(this.value[this.value.length-1].constructor.NAME===Wr?this.value.pop():this.warnings.push("No EndOfContent block encoded")),o}toBER(e,t){let n=t||new jr;for(let s=0;s<this.value.length;s++)this.value[s].toBER(e,n);return t?Ye:n.final()}toJSON(){let e={...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,value:[]};for(let t of this.value)e.value.push(t.toJSON());return e}};st.NAME="ConstructedValueBlock";var cc,Ot=class extends be{constructor(e={}){super(e,st),this.idBlock.isConstructed=!0}fromBER(e,t,n){this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm;let s=this.valueBlock.fromBER(e,t,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 e=[];for(let n of this.valueBlock.value)e.push(n.toString("ascii").split(`
2
+ "use strict";var Libp2PIdentify=(()=>{var mu=Object.create;var gn=Object.defineProperty;var yu=Object.getOwnPropertyDescriptor;var bu=Object.getOwnPropertyNames;var wu=Object.getPrototypeOf,xu=Object.prototype.hasOwnProperty;var Qi=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),de=(r,e)=>{for(var t in e)gn(r,t,{get:e[t],enumerable:!0})},ea=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of bu(e))!xu.call(r,s)&&s!==t&&gn(r,s,{get:()=>e[s],enumerable:!(n=yu(e,s))||n.enumerable});return r};var ta=(r,e,t)=>(t=r!=null?mu(wu(r)):{},ea(e||!r||!r.__esModule?gn(t,"default",{value:r,enumerable:!0}):t,r)),vu=r=>ea(gn({},"__esModule",{value:!0}),r);var tc=Qi(Br=>{"use strict";var Xh="[object ArrayBuffer]",vt=class r{static isArrayBuffer(e){return Object.prototype.toString.call(e)===Xh}static toArrayBuffer(e){return this.isArrayBuffer(e)?e:e.byteLength===e.buffer.byteLength||e.byteOffset===0&&e.byteLength===e.buffer.byteLength?e.buffer:this.toUint8Array(e.buffer).slice(e.byteOffset,e.byteOffset+e.byteLength).buffer}static toUint8Array(e){return this.toView(e,Uint8Array)}static toView(e,t){if(e.constructor===t)return e;if(this.isArrayBuffer(e))return new t(e);if(this.isArrayBufferView(e))return new t(e.buffer,e.byteOffset,e.byteLength);throw new TypeError("The provided value is not of type '(ArrayBuffer or ArrayBufferView)'")}static isBufferSource(e){return this.isArrayBufferView(e)||this.isArrayBuffer(e)}static isArrayBufferView(e){return ArrayBuffer.isView(e)||e&&this.isArrayBuffer(e.buffer)}static isEqual(e,t){let n=r.toUint8Array(e),s=r.toUint8Array(t);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(...e){let t;Array.isArray(e[0])&&!(e[1]instanceof Function)||Array.isArray(e[0])&&e[1]instanceof Function?t=e[0]:e[e.length-1]instanceof Function?t=e.slice(0,e.length-1):t=e;let n=0;for(let i of t)n+=i.byteLength;let s=new Uint8Array(n),o=0;for(let i of t){let a=this.toUint8Array(i);s.set(a,o),o+=a.length}return e[e.length-1]instanceof Function?this.toView(s,e[e.length-1]):s.buffer}},ri="string",Qh=/^[0-9a-f]+$/i,ed=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/,td=/^[a-zA-Z0-9-_]+$/,On=class{static fromString(e){let t=unescape(encodeURIComponent(e)),n=new Uint8Array(t.length);for(let s=0;s<t.length;s++)n[s]=t.charCodeAt(s);return n.buffer}static toString(e){let t=vt.toUint8Array(e),n="";for(let o=0;o<t.length;o++)n+=String.fromCharCode(t[o]);return decodeURIComponent(escape(n))}},Me=class{static toString(e,t=!1){let n=vt.toArrayBuffer(e),s=new DataView(n),o="";for(let i=0;i<n.byteLength;i+=2){let a=s.getUint16(i,t);o+=String.fromCharCode(a)}return o}static fromString(e,t=!1){let n=new ArrayBuffer(e.length*2),s=new DataView(n);for(let o=0;o<e.length;o++)s.setUint16(o*2,e.charCodeAt(o),t);return n}},Pn=class r{static isHex(e){return typeof e===ri&&Qh.test(e)}static isBase64(e){return typeof e===ri&&ed.test(e)}static isBase64Url(e){return typeof e===ri&&td.test(e)}static ToString(e,t="utf8"){let n=vt.toUint8Array(e);switch(t.toLowerCase()){case"utf8":return this.ToUtf8String(n);case"binary":return this.ToBinary(n);case"hex":return this.ToHex(n);case"base64":return this.ToBase64(n);case"base64url":return this.ToBase64Url(n);case"utf16le":return Me.toString(n,!0);case"utf16":case"utf16be":return Me.toString(n);default:throw new Error(`Unknown type of encoding '${t}'`)}}static FromString(e,t="utf8"){if(!e)return new ArrayBuffer(0);switch(t.toLowerCase()){case"utf8":return this.FromUtf8String(e);case"binary":return this.FromBinary(e);case"hex":return this.FromHex(e);case"base64":return this.FromBase64(e);case"base64url":return this.FromBase64Url(e);case"utf16le":return Me.fromString(e,!0);case"utf16":case"utf16be":return Me.fromString(e);default:throw new Error(`Unknown type of encoding '${t}'`)}}static ToBase64(e){let t=vt.toUint8Array(e);if(typeof btoa<"u"){let n=this.ToString(t,"binary");return btoa(n)}else return Buffer.from(t).toString("base64")}static FromBase64(e){let t=this.formatString(e);if(!t)return new ArrayBuffer(0);if(!r.isBase64(t))throw new TypeError("Argument 'base64Text' is not Base64 encoded");return typeof atob<"u"?this.FromBinary(atob(t)):new Uint8Array(Buffer.from(t,"base64")).buffer}static FromBase64Url(e){let t=this.formatString(e);if(!t)return new ArrayBuffer(0);if(!r.isBase64Url(t))throw new TypeError("Argument 'base64url' is not Base64Url encoded");return this.FromBase64(this.Base64Padding(t.replace(/\-/g,"+").replace(/\_/g,"/")))}static ToBase64Url(e){return this.ToBase64(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/\=/g,"")}static FromUtf8String(e,t=r.DEFAULT_UTF8_ENCODING){switch(t){case"ascii":return this.FromBinary(e);case"utf8":return On.fromString(e);case"utf16":case"utf16be":return Me.fromString(e);case"utf16le":case"usc2":return Me.fromString(e,!0);default:throw new Error(`Unknown type of encoding '${t}'`)}}static ToUtf8String(e,t=r.DEFAULT_UTF8_ENCODING){switch(t){case"ascii":return this.ToBinary(e);case"utf8":return On.toString(e);case"utf16":case"utf16be":return Me.toString(e);case"utf16le":case"usc2":return Me.toString(e,!0);default:throw new Error(`Unknown type of encoding '${t}'`)}}static FromBinary(e){let t=e.length,n=new Uint8Array(t);for(let s=0;s<t;s++)n[s]=e.charCodeAt(s);return n.buffer}static ToBinary(e){let t=vt.toUint8Array(e),n="";for(let s=0;s<t.length;s++)n+=String.fromCharCode(t[s]);return n}static ToHex(e){let t=vt.toUint8Array(e),n="",s=t.length;for(let o=0;o<s;o++){let i=t[o];i<16&&(n+="0"),n+=i.toString(16)}return n}static FromHex(e){let t=this.formatString(e);if(!t)return new ArrayBuffer(0);if(!r.isHex(t))throw new TypeError("Argument 'hexString' is not HEX encoded");t.length%2&&(t=`0${t}`);let n=new Uint8Array(t.length/2);for(let s=0;s<t.length;s=s+2){let o=t.slice(s,s+2);n[s/2]=parseInt(o,16)}return n.buffer}static ToUtf16String(e,t=!1){return Me.toString(e,t)}static FromUtf16String(e,t=!1){return Me.fromString(e,t)}static Base64Padding(e){let t=4-e.length%4;if(t<4)for(let n=0;n<t;n++)e+="=";return e}static formatString(e){return e?.replace(/[\n\r\t ]/g,"")||""}};Pn.DEFAULT_UTF8_ENCODING="utf8";function rd(r,...e){let t=arguments[0];for(let n=1;n<arguments.length;n++){let s=arguments[n];for(let o in s)t[o]=s[o]}return t}function nd(...r){let e=r.map(s=>s.byteLength).reduce((s,o)=>s+o),t=new Uint8Array(e),n=0;return r.map(s=>new Uint8Array(s)).forEach(s=>{for(let o of s)t[n++]=o}),t.buffer}function sd(r,e){if(!(r&&e)||r.byteLength!==e.byteLength)return!1;let t=new Uint8Array(r),n=new Uint8Array(e);for(let s=0;s<r.byteLength;s++)if(t[s]!==n[s])return!1;return!0}Br.BufferSourceConverter=vt;Br.Convert=Pn;Br.assign=rd;Br.combine=nd;Br.isEqual=sd});var $l=Qi((rx,ql)=>{function ap(){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)}ql.exports=ap});var wp={};de(wp,{identify:()=>yp,identifyPush:()=>bp});var js=Symbol.for("@libp2p/peer-id");var L=class extends Error{code;props;constructor(e,t,n){super(e),this.code=t,this.name=n?.name??"CodeError",this.props=n??{}}};var Dr=(r,...e)=>{try{[...e]}catch{}};var mn=Symbol.for("@libp2p/service-capabilities"),Ap=Symbol.for("@libp2p/service-dependencies");var ei={};de(ei,{Ed25519PrivateKey:()=>rr,Ed25519PublicKey:()=>Wr,generateKeyPair:()=>Yh,generateKeyPairFromSeed:()=>ec,unmarshalEd25519PrivateKey:()=>jh,unmarshalEd25519PublicKey:()=>Wh});var Xs={};de(Xs,{base58btc:()=>ne,base58flickr:()=>ku});var Wp=new Uint8Array(0);function ra(r,e){if(r===e)return!0;if(r.byteLength!==e.byteLength)return!1;for(let t=0;t<r.byteLength;t++)if(r[t]!==e[t])return!1;return!0}function ft(r){if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")}function na(r){return new TextEncoder().encode(r)}function sa(r){return new TextDecoder().decode(r)}function Eu(r,e){if(r.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),n=0;n<t.length;n++)t[n]=255;for(var s=0;s<r.length;s++){var o=r.charAt(s),i=o.charCodeAt(0);if(t[i]!==255)throw new TypeError(o+" is ambiguous");t[i]=s}var a=r.length,c=r.charAt(0),f=Math.log(a)/Math.log(256),l=Math.log(256)/Math.log(a);function u(b){if(b instanceof Uint8Array||(ArrayBuffer.isView(b)?b=new Uint8Array(b.buffer,b.byteOffset,b.byteLength):Array.isArray(b)&&(b=Uint8Array.from(b))),!(b instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(b.length===0)return"";for(var m=0,d=0,x=0,E=b.length;x!==E&&b[x]===0;)x++,m++;for(var g=(E-x)*l+1>>>0,B=new Uint8Array(g);x!==E;){for(var C=b[x],_=0,S=g-1;(C!==0||_<d)&&S!==-1;S--,_++)C+=256*B[S]>>>0,B[S]=C%a>>>0,C=C/a>>>0;if(C!==0)throw new Error("Non-zero carry");d=_,x++}for(var k=g-d;k!==g&&B[k]===0;)k++;for(var T=c.repeat(m);k<g;++k)T+=r.charAt(B[k]);return T}function h(b){if(typeof b!="string")throw new TypeError("Expected String");if(b.length===0)return new Uint8Array;var m=0;if(b[m]!==" "){for(var d=0,x=0;b[m]===c;)d++,m++;for(var E=(b.length-m)*f+1>>>0,g=new Uint8Array(E);b[m];){var B=t[b.charCodeAt(m)];if(B===255)return;for(var C=0,_=E-1;(B!==0||C<x)&&_!==-1;_--,C++)B+=a*g[_]>>>0,g[_]=B%256>>>0,B=B/256>>>0;if(B!==0)throw new Error("Non-zero carry");x=C,m++}if(b[m]!==" "){for(var S=E-x;S!==E&&g[S]===0;)S++;for(var k=new Uint8Array(d+(E-S)),T=d;S!==E;)k[T++]=g[S++];return k}}}function y(b){var m=h(b);if(m)return m;throw new Error(`Non-${e} character`)}return{encode:u,decodeUnsafe:h,decode:y}}var Bu=Eu,Au=Bu,ia=Au;var Ws=class{name;prefix;baseEncode;constructor(e,t,n){this.name=e,this.prefix=t,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},Ys=class{name;prefix;baseDecode;prefixCodePoint;constructor(e,t,n){if(this.name=e,this.prefix=t,t.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=n}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return aa(this,e)}},Zs=class{decoders;constructor(e){this.decoders=e}or(e){return aa(this,e)}decode(e){let t=e[0],n=this.decoders[t];if(n!=null)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function aa(r,e){return new Zs({...r.decoders??{[r.prefix]:r},...e.decoders??{[e.prefix]:e}})}var Js=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(e,t,n,s){this.name=e,this.prefix=t,this.baseEncode=n,this.baseDecode=s,this.encoder=new Ws(e,t,n),this.decoder=new Ys(e,t,s)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};function ir({name:r,prefix:e,encode:t,decode:n}){return new Js(r,e,t,n)}function Rt({name:r,prefix:e,alphabet:t}){let{encode:n,decode:s}=ia(t,r);return ir({prefix:e,name:r,encode:n,decode:o=>ft(s(o))})}function Iu(r,e,t,n){let s={};for(let l=0;l<e.length;++l)s[e[l]]=l;let o=r.length;for(;r[o-1]==="=";)--o;let i=new Uint8Array(o*t/8|0),a=0,c=0,f=0;for(let l=0;l<o;++l){let u=s[r[l]];if(u===void 0)throw new SyntaxError(`Non-${n} character`);c=c<<t|u,a+=t,a>=8&&(a-=8,i[f++]=255&c>>a)}if(a>=t||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return i}function Su(r,e,t){let n=e[e.length-1]==="=",s=(1<<t)-1,o="",i=0,a=0;for(let c=0;c<r.length;++c)for(a=a<<8|r[c],i+=8;i>t;)i-=t,o+=e[s&a>>i];if(i!==0&&(o+=e[s&a<<t-i]),n)for(;o.length*t&7;)o+="=";return o}function te({name:r,prefix:e,bitsPerChar:t,alphabet:n}){return ir({prefix:e,name:r,encode(s){return Su(s,n,t)},decode(s){return Iu(s,n,t,r)}})}var ne=Rt({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),ku=Rt({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var eo={};de(eo,{identity:()=>ht});var Nu=ua,ca=128,Ru=127,Tu=~Ru,_u=Math.pow(2,31);function ua(r,e,t){e=e||[],t=t||0;for(var n=t;r>=_u;)e[t++]=r&255|ca,r/=128;for(;r&Tu;)e[t++]=r&255|ca,r>>>=7;return e[t]=r|0,ua.bytes=t-n+1,e}var Cu=Qs,Lu=128,la=127;function Qs(r,n){var t=0,n=n||0,s=0,o=n,i,a=r.length;do{if(o>=a)throw Qs.bytes=0,new RangeError("Could not decode varint");i=r[o++],t+=s<28?(i&la)<<s:(i&la)*Math.pow(2,s),s+=7}while(i>=Lu);return Qs.bytes=o-n,t}var Uu=Math.pow(2,7),Ou=Math.pow(2,14),Pu=Math.pow(2,21),Vu=Math.pow(2,28),Du=Math.pow(2,35),Mu=Math.pow(2,42),Hu=Math.pow(2,49),Fu=Math.pow(2,56),Ku=Math.pow(2,63),qu=function(r){return r<Uu?1:r<Ou?2:r<Pu?3:r<Vu?4:r<Du?5:r<Mu?6:r<Hu?7:r<Fu?8:r<Ku?9:10},$u={encode:Nu,decode:Cu,encodingLength:qu},zu=$u,Mr=zu;function Hr(r,e=0){return[Mr.decode(r,e),Mr.decode.bytes]}function ar(r,e,t=0){return Mr.encode(r,e,t),e}function cr(r){return Mr.encodingLength(r)}function et(r,e){let t=e.byteLength,n=cr(r),s=n+cr(t),o=new Uint8Array(s+t);return ar(r,o,0),ar(t,o,n),o.set(e,s),new lr(r,t,e,o)}function Gt(r){let e=ft(r),[t,n]=Hr(e),[s,o]=Hr(e.subarray(n)),i=e.subarray(n+o);if(i.byteLength!==s)throw new Error("Incorrect length");return new lr(t,s,i,e)}function fa(r,e){if(r===e)return!0;{let t=e;return r.code===t.code&&r.size===t.size&&t.bytes instanceof Uint8Array&&ra(r.bytes,t.bytes)}}var lr=class{code;size;digest;bytes;constructor(e,t,n,s){this.code=e,this.size=t,this.digest=n,this.bytes=s}};var ha=0,Gu="identity",da=ft;function ju(r){return et(ha,da(r))}var ht={code:ha,name:Gu,encode:da,digest:ju};var no={};de(no,{sha256:()=>be,sha512:()=>Wu});function ro({name:r,code:e,encode:t}){return new to(r,e,t)}var to=class{name;code;encode;constructor(e,t,n){this.name=e,this.code=t,this.encode=n}digest(e){if(e instanceof Uint8Array){let t=this.encode(e);return t instanceof Uint8Array?et(this.code,t):t.then(n=>et(this.code,n))}else throw Error("Unknown type, must be binary type")}};function ga(r){return async e=>new Uint8Array(await crypto.subtle.digest(r,e))}var be=ro({name:"sha2-256",code:18,encode:ga("SHA-256")}),Wu=ro({name:"sha2-512",code:19,encode:ga("SHA-512")});function pe(r,e){if(r===e)return!0;if(r.byteLength!==e.byteLength)return!1;for(let t=0;t<r.byteLength;t++)if(r[t]!==e[t])return!1;return!0}function dt(r=0){return new Uint8Array(r)}function Te(r=0){return new Uint8Array(r)}function Se(r,e){e==null&&(e=r.reduce((s,o)=>s+o.length,0));let t=Te(e),n=0;for(let s of r)t.set(s,n),n+=s.length;return t}var so={};de(so,{base10:()=>Yu});var Yu=Rt({prefix:"9",name:"base10",alphabet:"0123456789"});var oo={};de(oo,{base16:()=>Zu,base16upper:()=>Ju});var Zu=te({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Ju=te({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var io={};de(io,{base2:()=>Xu});var Xu=te({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var ao={};de(ao,{base256emoji:()=>nf});var ma=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}"),Qu=ma.reduce((r,e,t)=>(r[t]=e,r),[]),ef=ma.reduce((r,e,t)=>(r[e.codePointAt(0)]=t,r),[]);function tf(r){return r.reduce((e,t)=>(e+=Qu[t],e),"")}function rf(r){let e=[];for(let t of r){let n=ef[t.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${t}`);e.push(n)}return new Uint8Array(e)}var nf=ir({prefix:"\u{1F680}",name:"base256emoji",encode:tf,decode:rf});var co={};de(co,{base32:()=>pt,base32hex:()=>cf,base32hexpad:()=>uf,base32hexpadupper:()=>ff,base32hexupper:()=>lf,base32pad:()=>of,base32padupper:()=>af,base32upper:()=>sf,base32z:()=>hf});var pt=te({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),sf=te({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),of=te({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),af=te({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),cf=te({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),lf=te({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),uf=te({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),ff=te({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),hf=te({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var lo={};de(lo,{base36:()=>df,base36upper:()=>pf});var df=Rt({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),pf=Rt({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var ho={};de(ho,{base64:()=>uo,base64pad:()=>gf,base64url:()=>fo,base64urlpad:()=>mf});var uo=te({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),gf=te({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),fo=te({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),mf=te({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var po={};de(po,{base8:()=>yf});var yf=te({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var go={};de(go,{identity:()=>bf});var bf=ir({prefix:"\0",name:"identity",encode:r=>sa(r),decode:r=>na(r)});var E0=new TextEncoder,B0=new TextDecoder;function ya(r,e){let{bytes:t,version:n}=r;switch(n){case 0:return Ef(t,mo(r),e??ne.encoder);default:return Bf(t,mo(r),e??pt.encoder)}}var ba=new WeakMap;function mo(r){let e=ba.get(r);if(e==null){let t=new Map;return ba.set(r,t),t}return e}var Pe=class r{code;version;multihash;bytes;"/";constructor(e,t,n,s){this.code=t,this.version=e,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:e,multihash:t}=this;if(e!==Fr)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==Af)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return r.createV0(t)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:e,digest:t}=this.multihash,n=et(e,t);return r.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(e){return r.equals(this,e)}static equals(e,t){let n=t;return n!=null&&e.code===n.code&&e.version===n.version&&fa(e.multihash,n.multihash)}toString(e){return ya(this,e)}toJSON(){return{"/":ya(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(e){if(e==null)return null;let t=e;if(t instanceof r)return t;if(t["/"]!=null&&t["/"]===t.bytes||t.asCID===t){let{version:n,code:s,multihash:o,bytes:i}=t;return new r(n,s,o,i??wa(n,s,o.bytes))}else if(t[If]===!0){let{version:n,multihash:s,code:o}=t,i=Gt(s);return r.create(n,o,i)}else return null}static create(e,t,n){if(typeof t!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(e){case 0:{if(t!==Fr)throw new Error(`Version 0 CID must use dag-pb (code: ${Fr}) block encoding`);return new r(e,t,n,n.bytes)}case 1:{let s=wa(e,t,n.bytes);return new r(e,t,n,s)}default:throw new Error("Invalid version")}}static createV0(e){return r.create(0,Fr,e)}static createV1(e,t){return r.create(1,e,t)}static decode(e){let[t,n]=r.decodeFirst(e);if(n.length!==0)throw new Error("Incorrect length");return t}static decodeFirst(e){let t=r.inspectBytes(e),n=t.size-t.multihashSize,s=ft(e.subarray(n,n+t.multihashSize));if(s.byteLength!==t.multihashSize)throw new Error("Incorrect length");let o=s.subarray(t.multihashSize-t.digestSize),i=new lr(t.multihashCode,t.digestSize,o,s);return[t.version===0?r.createV0(i):r.createV1(t.codec,i),e.subarray(t.size)]}static inspectBytes(e){let t=0,n=()=>{let[u,h]=Hr(e.subarray(t));return t+=h,u},s=n(),o=Fr;if(s===18?(s=0,t=0):o=n(),s!==0&&s!==1)throw new RangeError(`Invalid CID version ${s}`);let i=t,a=n(),c=n(),f=t+c,l=f-i;return{version:s,codec:o,multihashCode:a,digestSize:c,multihashSize:l,size:f}}static parse(e,t){let[n,s]=vf(e,t),o=r.decode(s);if(o.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return mo(o).set(n,e),o}};function vf(r,e){switch(r[0]){case"Q":{let t=e??ne;return[ne.prefix,t.decode(`${ne.prefix}${r}`)]}case ne.prefix:{let t=e??ne;return[ne.prefix,t.decode(r)]}case pt.prefix:{let t=e??pt;return[pt.prefix,t.decode(r)]}default:{if(e==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[r[0],e.decode(r)]}}}function Ef(r,e,t){let{prefix:n}=t;if(n!==ne.prefix)throw Error(`Cannot string encode V0 in ${t.name} encoding`);let s=e.get(n);if(s==null){let o=t.encode(r).slice(1);return e.set(n,o),o}else return s}function Bf(r,e,t){let{prefix:n}=t,s=e.get(n);if(s==null){let o=t.encode(r);return e.set(n,o),o}else return s}var Fr=112,Af=18;function wa(r,e,t){let n=cr(r),s=n+cr(e),o=new Uint8Array(s+t.byteLength);return ar(r,o,0),ar(e,o,n),o.set(t,s),o}var If=Symbol.for("@ipld/js-cid/CID");var Tt={...go,...io,...po,...so,...oo,...co,...lo,...Xs,...ho,...ao},M0={...no,...eo};function va(r,e,t,n){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:n}}}var xa=va("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),yo=va("ascii","a",r=>{let e="a";for(let t=0;t<r.length;t++)e+=String.fromCharCode(r[t]);return e},r=>{r=r.substring(1);let e=Te(r.length);for(let t=0;t<r.length;t++)e[t]=r.charCodeAt(t);return e}),Sf={utf8:xa,"utf-8":xa,hex:Tt.base16,latin1:yo,ascii:yo,binary:yo,...Tt},bn=Sf;function V(r,e="utf8"){let t=bn[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return t.decoder.decode(`${t.prefix}${r}`)}function Ve(r){return r==null?!1:typeof r.then=="function"&&typeof r.catch=="function"&&typeof r.finally=="function"}function ur(r){if(!Number.isSafeInteger(r)||r<0)throw new Error(`positive integer expected, not ${r}`)}function kf(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}function fr(r,...e){if(!kf(r))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(r.length))throw new Error(`Uint8Array expected of length ${e}, not of length=${r.length}`)}function wn(r){if(typeof r!="function"||typeof r.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");ur(r.outputLen),ur(r.blockLen)}function hr(r,e=!0){if(r.destroyed)throw new Error("Hash instance has been destroyed");if(e&&r.finished)throw new Error("Hash#digest() has already been called")}function Ea(r,e){fr(r);let t=e.outputLen;if(r.length<t)throw new Error(`digestInto() expects output buffer of length at least ${t}`)}var Wt=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;var pr=r=>new DataView(r.buffer,r.byteOffset,r.byteLength),Fe=(r,e)=>r<<32-e|r>>>e;var Q0=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;var Nf=async()=>{};async function Ba(r,e,t){let n=Date.now();for(let s=0;s<r;s++){t(s);let o=Date.now()-n;o>=0&&o<e||(await Nf(),n+=o)}}function Aa(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}function _t(r){return typeof r=="string"&&(r=Aa(r)),fr(r),r}function bo(...r){let e=0;for(let n=0;n<r.length;n++){let s=r[n];fr(s),e+=s.length}let t=new Uint8Array(e);for(let n=0,s=0;n<r.length;n++){let o=r[n];t.set(o,s),s+=o.length}return t}var dr=class{clone(){return this._cloneInto()}},Rf={}.toString;function Ia(r,e){if(e!==void 0&&Rf.call(e)!=="[object Object]")throw new Error("Options should be object or undefined");return Object.assign(r,e)}function xn(r){let e=n=>r().update(_t(n)).digest(),t=r();return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=()=>r(),e}function gr(r=32){if(Wt&&typeof Wt.getRandomValues=="function")return Wt.getRandomValues(new Uint8Array(r));if(Wt&&typeof Wt.randomBytes=="function")return Wt.randomBytes(r);throw new Error("crypto.getRandomValues must be defined")}function Tf(r,e,t,n){if(typeof r.setBigUint64=="function")return r.setBigUint64(e,t,n);let s=BigInt(32),o=BigInt(4294967295),i=Number(t>>s&o),a=Number(t&o),c=n?4:0,f=n?0:4;r.setUint32(e+c,i,n),r.setUint32(e+f,a,n)}var Sa=(r,e,t)=>r&e^~r&t,ka=(r,e,t)=>r&e^r&t^e&t,mr=class extends dr{constructor(e,t,n,s){super(),this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=s,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=pr(this.buffer)}update(e){hr(this);let{view:t,buffer:n,blockLen:s}=this;e=_t(e);let o=e.length;for(let i=0;i<o;){let a=Math.min(s-this.pos,o-i);if(a===s){let c=pr(e);for(;s<=o-i;i+=s)this.process(c,i);continue}n.set(e.subarray(i,i+a),this.pos),this.pos+=a,i+=a,this.pos===s&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){hr(this),Ea(e,this),this.finished=!0;let{buffer:t,view:n,blockLen:s,isLE:o}=this,{pos:i}=this;t[i++]=128,this.buffer.subarray(i).fill(0),this.padOffset>s-i&&(this.process(n,0),i=0);for(let u=i;u<s;u++)t[u]=0;Tf(n,s-8,BigInt(this.length*8),o),this.process(n,0);let a=pr(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let f=c/4,l=this.get();if(f>l.length)throw new Error("_sha2: outputLen bigger than state");for(let u=0;u<f;u++)a.setUint32(4*u,l[u],o)}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let n=e.slice(0,t);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());let{blockLen:t,buffer:n,length:s,finished:o,destroyed:i,pos:a}=this;return e.length=s,e.pos=a,e.finished=o,e.destroyed=i,s%t&&e.buffer.set(n),e}};var vn=BigInt(4294967295),wo=BigInt(32);function Na(r,e=!1){return e?{h:Number(r&vn),l:Number(r>>wo&vn)}:{h:Number(r>>wo&vn)|0,l:Number(r&vn)|0}}function _f(r,e=!1){let t=new Uint32Array(r.length),n=new Uint32Array(r.length);for(let s=0;s<r.length;s++){let{h:o,l:i}=Na(r[s],e);[t[s],n[s]]=[o,i]}return[t,n]}var Cf=(r,e)=>BigInt(r>>>0)<<wo|BigInt(e>>>0),Lf=(r,e,t)=>r>>>t,Uf=(r,e,t)=>r<<32-t|e>>>t,Of=(r,e,t)=>r>>>t|e<<32-t,Pf=(r,e,t)=>r<<32-t|e>>>t,Vf=(r,e,t)=>r<<64-t|e>>>t-32,Df=(r,e,t)=>r>>>t-32|e<<64-t,Mf=(r,e)=>e,Hf=(r,e)=>r,Ff=(r,e,t)=>r<<t|e>>>32-t,Kf=(r,e,t)=>e<<t|r>>>32-t,qf=(r,e,t)=>e<<t-32|r>>>64-t,$f=(r,e,t)=>r<<t-32|e>>>64-t;function zf(r,e,t,n){let s=(e>>>0)+(n>>>0);return{h:r+t+(s/2**32|0)|0,l:s|0}}var Gf=(r,e,t)=>(r>>>0)+(e>>>0)+(t>>>0),jf=(r,e,t,n)=>e+t+n+(r/2**32|0)|0,Wf=(r,e,t,n)=>(r>>>0)+(e>>>0)+(t>>>0)+(n>>>0),Yf=(r,e,t,n,s)=>e+t+n+s+(r/2**32|0)|0,Zf=(r,e,t,n,s)=>(r>>>0)+(e>>>0)+(t>>>0)+(n>>>0)+(s>>>0),Jf=(r,e,t,n,s,o)=>e+t+n+s+o+(r/2**32|0)|0;var Xf={fromBig:Na,split:_f,toBig:Cf,shrSH:Lf,shrSL:Uf,rotrSH:Of,rotrSL:Pf,rotrBH:Vf,rotrBL:Df,rotr32H:Mf,rotr32L:Hf,rotlSH:Ff,rotlSL:Kf,rotlBH:qf,rotlBL:$f,add:zf,add3L:Gf,add3H:jf,add4L:Wf,add4H:Yf,add5H:Jf,add5L:Zf},P=Xf;var[Qf,eh]=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))),Ct=new Uint32Array(80),Lt=new Uint32Array(80),xo=class extends mr{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){let{Ah:e,Al:t,Bh:n,Bl:s,Ch:o,Cl:i,Dh:a,Dl:c,Eh:f,El:l,Fh:u,Fl:h,Gh:y,Gl:b,Hh:m,Hl:d}=this;return[e,t,n,s,o,i,a,c,f,l,u,h,y,b,m,d]}set(e,t,n,s,o,i,a,c,f,l,u,h,y,b,m,d){this.Ah=e|0,this.Al=t|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=f|0,this.El=l|0,this.Fh=u|0,this.Fl=h|0,this.Gh=y|0,this.Gl=b|0,this.Hh=m|0,this.Hl=d|0}process(e,t){for(let g=0;g<16;g++,t+=4)Ct[g]=e.getUint32(t),Lt[g]=e.getUint32(t+=4);for(let g=16;g<80;g++){let B=Ct[g-15]|0,C=Lt[g-15]|0,_=P.rotrSH(B,C,1)^P.rotrSH(B,C,8)^P.shrSH(B,C,7),S=P.rotrSL(B,C,1)^P.rotrSL(B,C,8)^P.shrSL(B,C,7),k=Ct[g-2]|0,T=Lt[g-2]|0,ie=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),M=P.add4L(S,$,Lt[g-7],Lt[g-16]),ae=P.add4H(M,_,ie,Ct[g-7],Ct[g-16]);Ct[g]=ae|0,Lt[g]=M|0}let{Ah:n,Al:s,Bh:o,Bl:i,Ch:a,Cl:c,Dh:f,Dl:l,Eh:u,El:h,Fh:y,Fl:b,Gh:m,Gl:d,Hh:x,Hl:E}=this;for(let g=0;g<80;g++){let B=P.rotrSH(u,h,14)^P.rotrSH(u,h,18)^P.rotrBH(u,h,41),C=P.rotrSL(u,h,14)^P.rotrSL(u,h,18)^P.rotrBL(u,h,41),_=u&y^~u&m,S=h&b^~h&d,k=P.add5L(E,C,S,eh[g],Lt[g]),T=P.add5H(k,x,B,_,Qf[g],Ct[g]),ie=k|0,$=P.rotrSH(n,s,28)^P.rotrBH(n,s,34)^P.rotrBH(n,s,39),M=P.rotrSL(n,s,28)^P.rotrBL(n,s,34)^P.rotrBL(n,s,39),ae=n&o^n&a^o&a,A=s&i^s&c^i&c;x=m|0,E=d|0,m=y|0,d=b|0,y=u|0,b=h|0,{h:u,l:h}=P.add(f|0,l|0,T|0,ie|0),f=a|0,l=c|0,a=o|0,c=i|0,o=n|0,i=s|0;let N=P.add3L(ie,M,A);n=P.add3H(N,T,$,ae),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:f,l}=P.add(this.Dh|0,this.Dl|0,f|0,l|0),{h:u,l:h}=P.add(this.Eh|0,this.El|0,u|0,h|0),{h:y,l:b}=P.add(this.Fh|0,this.Fl|0,y|0,b|0),{h:m,l:d}=P.add(this.Gh|0,this.Gl|0,m|0,d|0),{h:x,l:E}=P.add(this.Hh|0,this.Hl|0,x|0,E|0),this.set(n,s,o,i,a,c,f,l,u,h,y,b,m,d,x,E)}roundClean(){Ct.fill(0),Lt.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};var Kr=xn(()=>new xo);var Bn={};de(Bn,{aInRange:()=>_e,abool:()=>Ke,abytes:()=>yr,bitGet:()=>ih,bitLen:()=>Io,bitMask:()=>$r,bitSet:()=>ah,bytesToHex:()=>mt,bytesToNumberBE:()=>yt,bytesToNumberLE:()=>Ot,concatBytes:()=>bt,createHmacDrbg:()=>So,ensureBytes:()=>re,equalBytes:()=>sh,hexToBytes:()=>Zt,hexToNumber:()=>Ao,inRange:()=>qr,isBytes:()=>Ut,memoized:()=>Xt,notImplemented:()=>lh,numberToBytesBE:()=>Pt,numberToBytesLE:()=>Jt,numberToHexUnpadded:()=>Yt,numberToVarBytesBE:()=>nh,utf8ToBytes:()=>oh,validateObject:()=>tt});var Bo=BigInt(0),En=BigInt(1),th=BigInt(2);function Ut(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}function yr(r){if(!Ut(r))throw new Error("Uint8Array expected")}function Ke(r,e){if(typeof e!="boolean")throw new Error(`${r} must be valid boolean, got "${e}".`)}var rh=Array.from({length:256},(r,e)=>e.toString(16).padStart(2,"0"));function mt(r){yr(r);let e="";for(let t=0;t<r.length;t++)e+=rh[r[t]];return e}function Yt(r){let e=r.toString(16);return e.length&1?`0${e}`:e}function Ao(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return BigInt(r===""?"0":`0x${r}`)}var gt={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function Ra(r){if(r>=gt._0&&r<=gt._9)return r-gt._0;if(r>=gt._A&&r<=gt._F)return r-(gt._A-10);if(r>=gt._a&&r<=gt._f)return r-(gt._a-10)}function Zt(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);let e=r.length,t=e/2;if(e%2)throw new Error("padded hex string expected, got unpadded hex of length "+e);let n=new Uint8Array(t);for(let s=0,o=0;s<t;s++,o+=2){let i=Ra(r.charCodeAt(o)),a=Ra(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 yt(r){return Ao(mt(r))}function Ot(r){return yr(r),Ao(mt(Uint8Array.from(r).reverse()))}function Pt(r,e){return Zt(r.toString(16).padStart(e*2,"0"))}function Jt(r,e){return Pt(r,e).reverse()}function nh(r){return Zt(Yt(r))}function re(r,e,t){let n;if(typeof e=="string")try{n=Zt(e)}catch(o){throw new Error(`${r} must be valid hex string, got "${e}". Cause: ${o}`)}else if(Ut(e))n=Uint8Array.from(e);else throw new Error(`${r} must be hex string or Uint8Array`);let s=n.length;if(typeof t=="number"&&s!==t)throw new Error(`${r} expected ${t} bytes, got ${s}`);return n}function bt(...r){let e=0;for(let n=0;n<r.length;n++){let s=r[n];yr(s),e+=s.length}let t=new Uint8Array(e);for(let n=0,s=0;n<r.length;n++){let o=r[n];t.set(o,s),s+=o.length}return t}function sh(r,e){if(r.length!==e.length)return!1;let t=0;for(let n=0;n<r.length;n++)t|=r[n]^e[n];return t===0}function oh(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}var vo=r=>typeof r=="bigint"&&Bo<=r;function qr(r,e,t){return vo(r)&&vo(e)&&vo(t)&&e<=r&&r<t}function _e(r,e,t,n){if(!qr(e,t,n))throw new Error(`expected valid ${r}: ${t} <= n < ${n}, got ${typeof e} ${e}`)}function Io(r){let e;for(e=0;r>Bo;r>>=En,e+=1);return e}function ih(r,e){return r>>BigInt(e)&En}function ah(r,e,t){return r|(t?En:Bo)<<BigInt(e)}var $r=r=>(th<<BigInt(r-1))-En,Eo=r=>new Uint8Array(r),Ta=r=>Uint8Array.from(r);function So(r,e,t){if(typeof r!="number"||r<2)throw new Error("hashLen must be a number");if(typeof e!="number"||e<2)throw new Error("qByteLen must be a number");if(typeof t!="function")throw new Error("hmacFn must be a function");let n=Eo(r),s=Eo(r),o=0,i=()=>{n.fill(1),s.fill(0),o=0},a=(...u)=>t(s,n,...u),c=(u=Eo())=>{s=a(Ta([0]),u),n=a(),u.length!==0&&(s=a(Ta([1]),u),n=a())},f=()=>{if(o++>=1e3)throw new Error("drbg: tried 1000 values");let u=0,h=[];for(;u<e;){n=a();let y=n.slice();h.push(y),u+=n.length}return bt(...h)};return(u,h)=>{i(),c(u);let y;for(;!(y=h(f()));)c();return i(),y}}var ch={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"||Ut(r),isSafeInteger:r=>Number.isSafeInteger(r),array:r=>Array.isArray(r),field:(r,e)=>e.Fp.isValid(r),hash:r=>typeof r=="function"&&Number.isSafeInteger(r.outputLen)};function tt(r,e,t={}){let n=(s,o,i)=>{let a=ch[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(e))n(s,o,!1);for(let[s,o]of Object.entries(t))n(s,o,!0);return r}var lh=()=>{throw new Error("not implemented")};function Xt(r){let e=new WeakMap;return(t,...n)=>{let s=e.get(t);if(s!==void 0)return s;let o=r(t,...n);return e.set(t,o),o}}var le=BigInt(0),X=BigInt(1),Qt=BigInt(2),uh=BigInt(3),ko=BigInt(4),_a=BigInt(5),Ca=BigInt(8),fh=BigInt(9),hh=BigInt(16);function Y(r,e){let t=r%e;return t>=le?t:e+t}function dh(r,e,t){if(t<=le||e<le)throw new Error("Expected power/modulo > 0");if(t===X)return le;let n=X;for(;e>le;)e&X&&(n=n*r%t),r=r*r%t,e>>=X;return n}function Q(r,e,t){let n=r;for(;e-- >le;)n*=n,n%=t;return n}function An(r,e){if(r===le||e<=le)throw new Error(`invert: expected positive integers, got n=${r} mod=${e}`);let t=Y(r,e),n=e,s=le,o=X,i=X,a=le;for(;t!==le;){let f=n/t,l=n%t,u=s-i*f,h=o-a*f;n=t,t=l,s=i,o=a,i=u,a=h}if(n!==X)throw new Error("invert: does not exist");return Y(s,e)}function ph(r){let e=(r-X)/Qt,t,n,s;for(t=r-X,n=0;t%Qt===le;t/=Qt,n++);for(s=Qt;s<r&&dh(s,e,r)!==r-X;s++);if(n===1){let i=(r+X)/ko;return function(c,f){let l=c.pow(f,i);if(!c.eql(c.sqr(l),f))throw new Error("Cannot find square root");return l}}let o=(t+X)/Qt;return function(a,c){if(a.pow(c,e)===a.neg(a.ONE))throw new Error("Cannot find square root");let f=n,l=a.pow(a.mul(a.ONE,s),t),u=a.pow(c,o),h=a.pow(c,t);for(;!a.eql(h,a.ONE);){if(a.eql(h,a.ZERO))return a.ZERO;let y=1;for(let m=a.sqr(h);y<f&&!a.eql(m,a.ONE);y++)m=a.sqr(m);let b=a.pow(l,X<<BigInt(f-y-1));l=a.sqr(b),u=a.mul(u,b),h=a.mul(h,l),f=y}return u}}function gh(r){if(r%ko===uh){let e=(r+X)/ko;return function(n,s){let o=n.pow(s,e);if(!n.eql(n.sqr(o),s))throw new Error("Cannot find square root");return o}}if(r%Ca===_a){let e=(r-_a)/Ca;return function(n,s){let o=n.mul(s,Qt),i=n.pow(o,e),a=n.mul(s,i),c=n.mul(n.mul(a,Qt),i),f=n.mul(a,n.sub(c,n.ONE));if(!n.eql(n.sqr(f),s))throw new Error("Cannot find square root");return f}}return r%hh,ph(r)}var La=(r,e)=>(Y(r,e)&X)===X,mh=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function No(r){let e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},t=mh.reduce((n,s)=>(n[s]="function",n),e);return tt(r,t)}function yh(r,e,t){if(t<le)throw new Error("Expected power > 0");if(t===le)return r.ONE;if(t===X)return e;let n=r.ONE,s=e;for(;t>le;)t&X&&(n=r.mul(n,s)),s=r.sqr(s),t>>=X;return n}function bh(r,e){let t=new Array(e.length),n=e.reduce((o,i,a)=>r.is0(i)?o:(t[a]=o,r.mul(o,i)),r.ONE),s=r.inv(n);return e.reduceRight((o,i,a)=>r.is0(i)?o:(t[a]=r.mul(o,t[a]),r.mul(o,i)),s),t}function Ro(r,e){let t=e!==void 0?e:r.toString(2).length,n=Math.ceil(t/8);return{nBitLength:t,nByteLength:n}}function Vt(r,e,t=!1,n={}){if(r<=le)throw new Error(`Expected Field ORDER > 0, got ${r}`);let{nBitLength:s,nByteLength:o}=Ro(r,e);if(o>2048)throw new Error("Field lengths over 2048 bytes are not supported");let i=gh(r),a=Object.freeze({ORDER:r,BITS:s,BYTES:o,MASK:$r(s),ZERO:le,ONE:X,create:c=>Y(c,r),isValid:c=>{if(typeof c!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof c}`);return le<=c&&c<r},is0:c=>c===le,isOdd:c=>(c&X)===X,neg:c=>Y(-c,r),eql:(c,f)=>c===f,sqr:c=>Y(c*c,r),add:(c,f)=>Y(c+f,r),sub:(c,f)=>Y(c-f,r),mul:(c,f)=>Y(c*f,r),pow:(c,f)=>yh(a,c,f),div:(c,f)=>Y(c*An(f,r),r),sqrN:c=>c*c,addN:(c,f)=>c+f,subN:(c,f)=>c-f,mulN:(c,f)=>c*f,inv:c=>An(c,r),sqrt:n.sqrt||(c=>i(a,c)),invertBatch:c=>bh(a,c),cmov:(c,f,l)=>l?f:c,toBytes:c=>t?Jt(c,o):Pt(c,o),fromBytes:c=>{if(c.length!==o)throw new Error(`Fp.fromBytes: expected ${o}, got ${c.length}`);return t?Ot(c):yt(c)}});return Object.freeze(a)}function Ua(r){if(typeof r!="bigint")throw new Error("field order must be bigint");let e=r.toString(2).length;return Math.ceil(e/8)}function To(r){let e=Ua(r);return e+Math.ceil(e/2)}function Oa(r,e,t=!1){let n=r.length,s=Ua(e),o=To(e);if(n<16||n<o||n>1024)throw new Error(`expected ${o}-1024 bytes of input, got ${n}`);let i=t?yt(r):Ot(r),a=Y(i,e-X)+X;return t?Jt(a,s):Pt(a,s)}var xh=BigInt(0),_o=BigInt(1),Co=new WeakMap,Pa=new WeakMap;function In(r,e){let t=(o,i)=>{let a=i.negate();return o?a:i},n=o=>{if(!Number.isSafeInteger(o)||o<=0||o>e)throw new Error(`Wrong window size=${o}, should be [1..${e}]`)},s=o=>{n(o);let i=Math.ceil(e/o)+1,a=2**(o-1);return{windows:i,windowSize:a}};return{constTimeNegate:t,unsafeLadder(o,i){let a=r.ZERO,c=o;for(;i>xh;)i&_o&&(a=a.add(c)),c=c.double(),i>>=_o;return a},precomputeWindow(o,i){let{windows:a,windowSize:c}=s(i),f=[],l=o,u=l;for(let h=0;h<a;h++){u=l,f.push(u);for(let y=1;y<c;y++)u=u.add(l),f.push(u);l=u.double()}return f},wNAF(o,i,a){let{windows:c,windowSize:f}=s(o),l=r.ZERO,u=r.BASE,h=BigInt(2**o-1),y=2**o,b=BigInt(o);for(let m=0;m<c;m++){let d=m*f,x=Number(a&h);a>>=b,x>f&&(x-=y,a+=_o);let E=d,g=d+Math.abs(x)-1,B=m%2!==0,C=x<0;x===0?u=u.add(t(B,i[E])):l=l.add(t(C,i[g]))}return{p:l,f:u}},wNAFCached(o,i,a){let c=Pa.get(o)||1,f=Co.get(o);return f||(f=this.precomputeWindow(o,c),c!==1&&Co.set(o,a(f))),this.wNAF(c,f,i)},setWindowSize(o,i){n(i),Pa.set(o,i),Co.delete(o)}}}function Sn(r,e,t,n){if(!Array.isArray(t)||!Array.isArray(n)||n.length!==t.length)throw new Error("arrays of points and scalars must have equal length");n.forEach((l,u)=>{if(!e.isValid(l))throw new Error(`wrong scalar at index ${u}`)}),t.forEach((l,u)=>{if(!(l instanceof r))throw new Error(`wrong point at index ${u}`)});let s=Io(BigInt(t.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((e.BITS-1)/o)*o,f=r.ZERO;for(let l=c;l>=0;l-=o){a.fill(r.ZERO);for(let h=0;h<n.length;h++){let y=n[h],b=Number(y>>BigInt(l)&BigInt(i));a[b]=a[b].add(t[h])}let u=r.ZERO;for(let h=a.length-1,y=r.ZERO;h>0;h--)y=y.add(a[h]),u=u.add(y);if(f=f.add(u),l!==0)for(let h=0;h<o;h++)f=f.double()}return f}function zr(r){return No(r.Fp),tt(r,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Ro(r.n,r.nBitLength),...r,p:r.Fp.ORDER})}var qe=BigInt(0),Ce=BigInt(1),kn=BigInt(2),vh=BigInt(8),Eh={zip215:!0};function Bh(r){let e=zr(r);return tt(r,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...e})}function Va(r){let e=Bh(r),{Fp:t,n,prehash:s,hash:o,randomBytes:i,nByteLength:a,h:c}=e,f=kn<<BigInt(a*8)-Ce,l=t.create,u=Vt(e.n,e.nBitLength),h=e.uvRatio||((w,p)=>{try{return{isValid:!0,value:t.sqrt(w*t.inv(p))}}catch{return{isValid:!1,value:qe}}}),y=e.adjustScalarBytes||(w=>w),b=e.domain||((w,p,v)=>{if(Ke("phflag",v),p.length||v)throw new Error("Contexts/pre-hash are not supported");return w});function m(w,p){_e("coordinate "+w,p,qe,f)}function d(w){if(!(w instanceof g))throw new Error("ExtendedPoint expected")}let x=Xt((w,p)=>{let{ex:v,ey:R,ez:U}=w,O=w.is0();p==null&&(p=O?vh:t.inv(U));let H=l(v*p),q=l(R*p),F=l(U*p);if(O)return{x:qe,y:Ce};if(F!==Ce)throw new Error("invZ was invalid");return{x:H,y:q}}),E=Xt(w=>{let{a:p,d:v}=e;if(w.is0())throw new Error("bad point: ZERO");let{ex:R,ey:U,ez:O,et:H}=w,q=l(R*R),F=l(U*U),W=l(O*O),J=l(W*W),fe=l(q*p),he=l(W*l(fe+F)),ye=l(J+l(v*l(q*F)));if(he!==ye)throw new Error("bad point: equation left != right (1)");let Ie=l(R*U),ce=l(O*H);if(Ie!==ce)throw new Error("bad point: equation left != right (2)");return!0});class g{constructor(p,v,R,U){this.ex=p,this.ey=v,this.ez=R,this.et=U,m("x",p),m("y",v),m("z",R),m("t",U),Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(p){if(p instanceof g)throw new Error("extended point not allowed");let{x:v,y:R}=p||{};return m("x",v),m("y",R),new g(v,R,Ce,l(v*R))}static normalizeZ(p){let v=t.invertBatch(p.map(R=>R.ez));return p.map((R,U)=>R.toAffine(v[U])).map(g.fromAffine)}static msm(p,v){return Sn(g,u,p,v)}_setWindowSize(p){_.setWindowSize(this,p)}assertValidity(){E(this)}equals(p){d(p);let{ex:v,ey:R,ez:U}=this,{ex:O,ey:H,ez:q}=p,F=l(v*q),W=l(O*U),J=l(R*q),fe=l(H*U);return F===W&&J===fe}is0(){return this.equals(g.ZERO)}negate(){return new g(l(-this.ex),this.ey,this.ez,l(-this.et))}double(){let{a:p}=e,{ex:v,ey:R,ez:U}=this,O=l(v*v),H=l(R*R),q=l(kn*l(U*U)),F=l(p*O),W=v+R,J=l(l(W*W)-O-H),fe=F+H,he=fe-q,ye=F-H,Ie=l(J*he),ce=l(fe*ye),Re=l(J*ye),ut=l(he*fe);return new g(Ie,ce,ut,Re)}add(p){d(p);let{a:v,d:R}=e,{ex:U,ey:O,ez:H,et:q}=this,{ex:F,ey:W,ez:J,et:fe}=p;if(v===BigInt(-1)){let Gi=l((O-U)*(W+F)),ji=l((O+U)*(W-F)),Gs=l(ji-Gi);if(Gs===qe)return this.double();let Wi=l(H*kn*fe),Yi=l(q*kn*J),Zi=Yi+Wi,Ji=ji+Gi,Xi=Yi-Wi,hu=l(Zi*Gs),du=l(Ji*Xi),pu=l(Zi*Xi),gu=l(Gs*Ji);return new g(hu,du,gu,pu)}let he=l(U*F),ye=l(O*W),Ie=l(q*R*fe),ce=l(H*J),Re=l((U+O)*(F+W)-he-ye),ut=ce-Ie,Pr=ce+Ie,Vr=l(ye-v*he),cu=l(Re*ut),lu=l(Pr*Vr),uu=l(Re*Vr),fu=l(ut*Pr);return new g(cu,lu,fu,uu)}subtract(p){return this.add(p.negate())}wNAF(p){return _.wNAFCached(this,p,g.normalizeZ)}multiply(p){let v=p;_e("scalar",v,Ce,n);let{p:R,f:U}=this.wNAF(v);return g.normalizeZ([R,U])[0]}multiplyUnsafe(p){let v=p;return _e("scalar",v,qe,n),v===qe?C:this.equals(C)||v===Ce?this:this.equals(B)?this.wNAF(v).p:_.unsafeLadder(this,v)}isSmallOrder(){return this.multiplyUnsafe(c).is0()}isTorsionFree(){return _.unsafeLadder(this,n).is0()}toAffine(p){return x(this,p)}clearCofactor(){let{h:p}=e;return p===Ce?this:this.multiplyUnsafe(p)}static fromHex(p,v=!1){let{d:R,a:U}=e,O=t.BYTES;p=re("pointHex",p,O),Ke("zip215",v);let H=p.slice(),q=p[O-1];H[O-1]=q&-129;let F=Ot(H),W=v?f:t.ORDER;_e("pointHex.y",F,qe,W);let J=l(F*F),fe=l(J-Ce),he=l(R*J-U),{isValid:ye,value:Ie}=h(fe,he);if(!ye)throw new Error("Point.fromHex: invalid y coordinate");let ce=(Ie&Ce)===Ce,Re=(q&128)!==0;if(!v&&Ie===qe&&Re)throw new Error("Point.fromHex: x=0 and x_0=1");return Re!==ce&&(Ie=l(-Ie)),g.fromAffine({x:Ie,y:F})}static fromPrivateKey(p){return T(p).point}toRawBytes(){let{x:p,y:v}=this.toAffine(),R=Jt(v,t.BYTES);return R[R.length-1]|=p&Ce?128:0,R}toHex(){return mt(this.toRawBytes())}}g.BASE=new g(e.Gx,e.Gy,Ce,l(e.Gx*e.Gy)),g.ZERO=new g(qe,Ce,Ce,qe);let{BASE:B,ZERO:C}=g,_=In(g,a*8);function S(w){return Y(w,n)}function k(w){return S(Ot(w))}function T(w){let p=a;w=re("private key",w,p);let v=re("hashed private key",o(w),2*p),R=y(v.slice(0,p)),U=v.slice(p,2*p),O=k(R),H=B.multiply(O),q=H.toRawBytes();return{head:R,prefix:U,scalar:O,point:H,pointBytes:q}}function ie(w){return T(w).pointBytes}function $(w=new Uint8Array,...p){let v=bt(...p);return k(o(b(v,re("context",w),!!s)))}function M(w,p,v={}){w=re("message",w),s&&(w=s(w));let{prefix:R,scalar:U,pointBytes:O}=T(p),H=$(v.context,R,w),q=B.multiply(H).toRawBytes(),F=$(v.context,q,O,w),W=S(H+F*U);_e("signature.s",W,qe,n);let J=bt(q,Jt(W,t.BYTES));return re("result",J,a*2)}let ae=Eh;function A(w,p,v,R=ae){let{context:U,zip215:O}=R,H=t.BYTES;w=re("signature",w,2*H),p=re("message",p),O!==void 0&&Ke("zip215",O),s&&(p=s(p));let q=Ot(w.slice(H,2*H)),F,W,J;try{F=g.fromHex(v,O),W=g.fromHex(w.slice(0,H),O),J=B.multiplyUnsafe(q)}catch{return!1}if(!O&&F.isSmallOrder())return!1;let fe=$(U,W.toRawBytes(),F.toRawBytes(),p);return W.add(F.multiplyUnsafe(fe)).subtract(J).clearCofactor().equals(g.ZERO)}return B._setWindowSize(8),{CURVE:e,getPublicKey:ie,sign:M,verify:A,ExtendedPoint:g,utils:{getExtendedPublicKey:T,randomPrivateKey:()=>i(t.BYTES),precompute(w=8,p=g.BASE){return p._setWindowSize(w),p.multiply(BigInt(3)),p}}}}var Lo=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),Da=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),Eg=BigInt(0),Ah=BigInt(1),Ma=BigInt(2),Bg=BigInt(3),Ih=BigInt(5),Sh=BigInt(8);function kh(r){let e=BigInt(10),t=BigInt(20),n=BigInt(40),s=BigInt(80),o=Lo,a=r*r%o*r%o,c=Q(a,Ma,o)*a%o,f=Q(c,Ah,o)*r%o,l=Q(f,Ih,o)*f%o,u=Q(l,e,o)*l%o,h=Q(u,t,o)*u%o,y=Q(h,n,o)*h%o,b=Q(y,s,o)*y%o,m=Q(b,s,o)*y%o,d=Q(m,e,o)*l%o;return{pow_p_5_8:Q(d,Ma,o)*r%o,b2:a}}function Nh(r){return r[0]&=248,r[31]&=127,r[31]|=64,r}function Rh(r,e){let t=Lo,n=Y(e*e*e,t),s=Y(n*n*e,t),o=kh(r*s).pow_p_5_8,i=Y(r*n*o,t),a=Y(e*i*i,t),c=i,f=Y(i*Da,t),l=a===r,u=a===Y(-r,t),h=a===Y(-r*Da,t);return l&&(i=c),(u||h)&&(i=f),La(i,t)&&(i=Y(-i,t)),{isValid:l||u,value:i}}var Th=Vt(Lo,void 0,!0),_h={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:Th,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:Sh,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:Kr,randomBytes:gr,adjustScalarBytes:Nh,uvRatio:Rh},br=Va(_h);var wr=32,wt=64,Nn=32;function Ha(){let r=br.utils.randomPrivateKey(),e=br.getPublicKey(r);return{privateKey:$a(r,e),publicKey:e}}function Fa(r){if(r.length!==Nn)throw new TypeError('"seed" must be 32 bytes in length.');if(!(r instanceof Uint8Array))throw new TypeError('"seed" must be a node.js Buffer, or Uint8Array.');let e=r,t=br.getPublicKey(e);return{privateKey:$a(e,t),publicKey:t}}function Ka(r,e){let t=r.subarray(0,Nn);return br.sign(e instanceof Uint8Array?e:e.subarray(),t)}function qa(r,e,t){return br.verify(e,t instanceof Uint8Array?t:t.subarray(),r)}function $a(r,e){let t=new Uint8Array(wt);for(let n=0;n<Nn;n++)t[n]=r[n],t[Nn+n]=e[n];return t}var ke={get(r=globalThis){let e=r.crypto;if(e?.subtle==null)throw Object.assign(new Error("Missing Web Crypto API. The most likely cause of this error is that this page is being accessed from an insecure context (i.e. not HTTPS). For more information and possible resolutions see https://github.com/libp2p/js-libp2p/blob/main/packages/crypto/README.md#web-crypto-api"),{code:"ERR_MISSING_WEB_CRYPTO"});return e}};var Uo={alg:"A128GCM",ext:!0,k:"scm9jmO_4BJAgdwWGVulLg",key_ops:["encrypt","decrypt"],kty:"oct"};function za(r){let e=r?.algorithm??"AES-GCM",t=r?.keyLength??16,n=r?.nonceLength??12,s=r?.digest??"SHA-256",o=r?.saltLength??16,i=r?.iterations??32767,a=ke.get();t*=8;async function c(u,h){let y=a.getRandomValues(new Uint8Array(o)),b=a.getRandomValues(new Uint8Array(n)),m={name:e,iv:b};typeof h=="string"&&(h=V(h));let d;if(h.length===0){d=await a.subtle.importKey("jwk",Uo,{name:"AES-GCM"},!0,["encrypt"]);try{let E={name:"PBKDF2",salt:y,iterations:i,hash:{name:s}},g=await a.subtle.importKey("raw",h,{name:"PBKDF2"},!1,["deriveKey"]);d=await a.subtle.deriveKey(E,g,{name:e,length:t},!0,["encrypt"])}catch{d=await a.subtle.importKey("jwk",Uo,{name:"AES-GCM"},!0,["encrypt"])}}else{let E={name:"PBKDF2",salt:y,iterations:i,hash:{name:s}},g=await a.subtle.importKey("raw",h,{name:"PBKDF2"},!1,["deriveKey"]);d=await a.subtle.deriveKey(E,g,{name:e,length:t},!0,["encrypt"])}let x=await a.subtle.encrypt(m,d,u);return Se([y,m.iv,new Uint8Array(x)])}async function f(u,h){let y=u.subarray(0,o),b=u.subarray(o,o+n),m=u.subarray(o+n),d={name:e,iv:b};typeof h=="string"&&(h=V(h));let x;if(h.length===0)try{let g={name:"PBKDF2",salt:y,iterations:i,hash:{name:s}},B=await a.subtle.importKey("raw",h,{name:"PBKDF2"},!1,["deriveKey"]);x=await a.subtle.deriveKey(g,B,{name:e,length:t},!0,["decrypt"])}catch{x=await a.subtle.importKey("jwk",Uo,{name:"AES-GCM"},!0,["decrypt"])}else{let g={name:"PBKDF2",salt:y,iterations:i,hash:{name:s}},B=await a.subtle.importKey("raw",h,{name:"PBKDF2"},!1,["deriveKey"]);x=await a.subtle.deriveKey(g,B,{name:e,length:t},!0,["decrypt"])}let E=await a.subtle.decrypt(d,x,m);return new Uint8Array(E)}return{encrypt:c,decrypt:f}}async function xr(r,e){let n=await za().encrypt(r,e);return uo.encode(n)}var Uh=Math.pow(2,7),Oh=Math.pow(2,14),Ph=Math.pow(2,21),Oo=Math.pow(2,28),Po=Math.pow(2,35),Vo=Math.pow(2,42),Do=Math.pow(2,49),j=128,ve=127;function Ee(r){if(r<Uh)return 1;if(r<Oh)return 2;if(r<Ph)return 3;if(r<Oo)return 4;if(r<Po)return 5;if(r<Vo)return 6;if(r<Do)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function Mo(r,e,t=0){switch(Ee(r)){case 8:e[t++]=r&255|j,r/=128;case 7:e[t++]=r&255|j,r/=128;case 6:e[t++]=r&255|j,r/=128;case 5:e[t++]=r&255|j,r/=128;case 4:e[t++]=r&255|j,r>>>=7;case 3:e[t++]=r&255|j,r>>>=7;case 2:e[t++]=r&255|j,r>>>=7;case 1:{e[t++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return e}function Vh(r,e,t=0){switch(Ee(r)){case 8:e.set(t++,r&255|j),r/=128;case 7:e.set(t++,r&255|j),r/=128;case 6:e.set(t++,r&255|j),r/=128;case 5:e.set(t++,r&255|j),r/=128;case 4:e.set(t++,r&255|j),r>>>=7;case 3:e.set(t++,r&255|j),r>>>=7;case 2:e.set(t++,r&255|j),r>>>=7;case 1:{e.set(t++,r&255),r>>>=7;break}default:throw new Error("unreachable")}return e}function Ho(r,e){let t=r[e],n=0;if(n+=t&ve,t<j||(t=r[e+1],n+=(t&ve)<<7,t<j)||(t=r[e+2],n+=(t&ve)<<14,t<j)||(t=r[e+3],n+=(t&ve)<<21,t<j)||(t=r[e+4],n+=(t&ve)*Oo,t<j)||(t=r[e+5],n+=(t&ve)*Po,t<j)||(t=r[e+6],n+=(t&ve)*Vo,t<j)||(t=r[e+7],n+=(t&ve)*Do,t<j))return n;throw new RangeError("Could not decode varint")}function Dh(r,e){let t=r.get(e),n=0;if(n+=t&ve,t<j||(t=r.get(e+1),n+=(t&ve)<<7,t<j)||(t=r.get(e+2),n+=(t&ve)<<14,t<j)||(t=r.get(e+3),n+=(t&ve)<<21,t<j)||(t=r.get(e+4),n+=(t&ve)*Oo,t<j)||(t=r.get(e+5),n+=(t&ve)*Po,t<j)||(t=r.get(e+6),n+=(t&ve)*Vo,t<j)||(t=r.get(e+7),n+=(t&ve)*Do,t<j))return n;throw new RangeError("Could not decode varint")}function De(r,e,t=0){return e==null&&(e=Te(Ee(r))),e instanceof Uint8Array?Mo(r,e,t):Vh(r,e,t)}function xt(r,e=0){return r instanceof Uint8Array?Ho(r,e):Dh(r,e)}var Fo=new Float32Array([-0]),Dt=new Uint8Array(Fo.buffer);function Ga(r,e,t){Fo[0]=r,e[t]=Dt[0],e[t+1]=Dt[1],e[t+2]=Dt[2],e[t+3]=Dt[3]}function ja(r,e){return Dt[0]=r[e],Dt[1]=r[e+1],Dt[2]=r[e+2],Dt[3]=r[e+3],Fo[0]}var Ko=new Float64Array([-0]),Be=new Uint8Array(Ko.buffer);function Wa(r,e,t){Ko[0]=r,e[t]=Be[0],e[t+1]=Be[1],e[t+2]=Be[2],e[t+3]=Be[3],e[t+4]=Be[4],e[t+5]=Be[5],e[t+6]=Be[6],e[t+7]=Be[7]}function Ya(r,e){return Be[0]=r[e],Be[1]=r[e+1],Be[2]=r[e+2],Be[3]=r[e+3],Be[4]=r[e+4],Be[5]=r[e+5],Be[6]=r[e+6],Be[7]=r[e+7],Ko[0]}var Mh=BigInt(Number.MAX_SAFE_INTEGER),Hh=BigInt(Number.MIN_SAFE_INTEGER),Oe=class r{lo;hi;constructor(e,t){this.lo=e|0,this.hi=t|0}toNumber(e=!1){if(!e&&this.hi>>>31>0){let t=~this.lo+1>>>0,n=~this.hi>>>0;return t===0&&(n=n+1>>>0),-(t+n*4294967296)}return this.lo+this.hi*4294967296}toBigInt(e=!1){if(e)return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31){let t=~this.lo+1>>>0,n=~this.hi>>>0;return t===0&&(n=n+1>>>0),-(BigInt(t)+(BigInt(n)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toString(e=!1){return this.toBigInt(e).toString()}zzEncode(){let e=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^e)>>>0,this.lo=(this.lo<<1^e)>>>0,this}zzDecode(){let e=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^e)>>>0,this.hi=(this.hi>>>1^e)>>>0,this}length(){let e=this.lo,t=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return n===0?t===0?e<16384?e<128?1:2:e<2097152?3:4:t<16384?t<128?5:6:t<2097152?7:8:n<128?9:10}static fromBigInt(e){if(e===0n)return er;if(e<Mh&&e>Hh)return this.fromNumber(Number(e));let t=e<0n;t&&(e=-e);let n=e>>32n,s=e-(n<<32n);return t&&(n=~n|0n,s=~s|0n,++s>Za&&(s=0n,++n>Za&&(n=0n))),new r(Number(s),Number(n))}static fromNumber(e){if(e===0)return er;let t=e<0;t&&(e=-e);let n=e>>>0,s=(e-n)/4294967296>>>0;return t&&(s=~s>>>0,n=~n>>>0,++n>4294967295&&(n=0,++s>4294967295&&(s=0))),new r(n,s)}static from(e){return typeof e=="number"?r.fromNumber(e):typeof e=="bigint"?r.fromBigInt(e):typeof e=="string"?r.fromBigInt(BigInt(e)):e.low!=null||e.high!=null?new r(e.low>>>0,e.high>>>0):er}},er=new Oe(0,0);er.toBigInt=function(){return 0n};er.zzEncode=er.zzDecode=function(){return this};er.length=function(){return 1};var Za=4294967296n;function Ja(r){let e=0,t=0;for(let n=0;n<r.length;++n)t=r.charCodeAt(n),t<128?e+=1:t<2048?e+=2:(t&64512)===55296&&(r.charCodeAt(n+1)&64512)===56320?(++n,e+=4):e+=3;return e}function Xa(r,e,t){if(t-e<1)return"";let s,o=[],i=0,a;for(;e<t;)a=r[e++],a<128?o[i++]=a:a>191&&a<224?o[i++]=(a&31)<<6|r[e++]&63:a>239&&a<365?(a=((a&7)<<18|(r[e++]&63)<<12|(r[e++]&63)<<6|r[e++]&63)-65536,o[i++]=55296+(a>>10),o[i++]=56320+(a&1023)):o[i++]=(a&15)<<12|(r[e++]&63)<<6|r[e++]&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 qo(r,e,t){let n=t,s,o;for(let i=0;i<r.length;++i)s=r.charCodeAt(i),s<128?e[t++]=s:s<2048?(e[t++]=s>>6|192,e[t++]=s&63|128):(s&64512)===55296&&((o=r.charCodeAt(i+1))&64512)===56320?(s=65536+((s&1023)<<10)+(o&1023),++i,e[t++]=s>>18|240,e[t++]=s>>12&63|128,e[t++]=s>>6&63|128,e[t++]=s&63|128):(e[t++]=s>>12|224,e[t++]=s>>6&63|128,e[t++]=s&63|128);return t-n}function $e(r,e){return RangeError(`index out of range: ${r.pos} + ${e??1} > ${r.len}`)}function Tn(r,e){return(r[e-4]|r[e-3]<<8|r[e-2]<<16|r[e-1]<<24)>>>0}var $o=class{buf;pos;len;_slice=Uint8Array.prototype.subarray;constructor(e){this.buf=e,this.pos=0,this.len=e.length}uint32(){let e=4294967295;if(e=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(e=(e|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return e;if((this.pos+=5)>this.len)throw this.pos=this.len,$e(this,10);return e}int32(){return this.uint32()|0}sint32(){let e=this.uint32();return e>>>1^-(e&1)|0}bool(){return this.uint32()!==0}fixed32(){if(this.pos+4>this.len)throw $e(this,4);return Tn(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw $e(this,4);return Tn(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw $e(this,4);let e=ja(this.buf,this.pos);return this.pos+=4,e}double(){if(this.pos+8>this.len)throw $e(this,4);let e=Ya(this.buf,this.pos);return this.pos+=8,e}bytes(){let e=this.uint32(),t=this.pos,n=this.pos+e;if(n>this.len)throw $e(this,e);return this.pos+=e,t===n?new Uint8Array(0):this.buf.subarray(t,n)}string(){let e=this.bytes();return Xa(e,0,e.length)}skip(e){if(typeof e=="number"){if(this.pos+e>this.len)throw $e(this,e);this.pos+=e}else do if(this.pos>=this.len)throw $e(this);while(this.buf[this.pos++]&128);return this}skipType(e){switch(e){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(e=this.uint32()&7)!==4;)this.skipType(e);break;case 5:this.skip(4);break;default:throw Error(`invalid wire type ${e} at offset ${this.pos}`)}return this}readLongVarint(){let e=new Oe(0,0),t=0;if(this.len-this.pos>4){for(;t<4;++t)if(e.lo=(e.lo|(this.buf[this.pos]&127)<<t*7)>>>0,this.buf[this.pos++]<128)return e;if(e.lo=(e.lo|(this.buf[this.pos]&127)<<28)>>>0,e.hi=(e.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return e;t=0}else{for(;t<3;++t){if(this.pos>=this.len)throw $e(this);if(e.lo=(e.lo|(this.buf[this.pos]&127)<<t*7)>>>0,this.buf[this.pos++]<128)return e}return e.lo=(e.lo|(this.buf[this.pos++]&127)<<t*7)>>>0,e}if(this.len-this.pos>4){for(;t<5;++t)if(e.hi=(e.hi|(this.buf[this.pos]&127)<<t*7+3)>>>0,this.buf[this.pos++]<128)return e}else for(;t<5;++t){if(this.pos>=this.len)throw $e(this);if(e.hi=(e.hi|(this.buf[this.pos]&127)<<t*7+3)>>>0,this.buf[this.pos++]<128)return e}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw $e(this,8);let e=Tn(this.buf,this.pos+=4),t=Tn(this.buf,this.pos+=4);return new Oe(e,t)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){let e=Ho(this.buf,this.pos);return this.pos+=Ee(e),e}uint64String(){return this.readLongVarint().toString(!0)}sint64(){return this.readLongVarint().zzDecode().toBigInt()}sint64Number(){return this.readLongVarint().zzDecode().toNumber()}sint64String(){return this.readLongVarint().zzDecode().toString()}fixed64(){return this.readFixed64().toBigInt()}fixed64Number(){return this.readFixed64().toNumber()}fixed64String(){return this.readFixed64().toString()}sfixed64(){return this.readFixed64().toBigInt()}sfixed64Number(){return this.readFixed64().toNumber()}sfixed64String(){return this.readFixed64().toString()}};function zo(r){return new $o(r instanceof Uint8Array?r:r.subarray())}function ze(r,e,t){let n=zo(r);return e.decode(n,void 0,t)}function Go(r){let e=r??8192,t=e>>>1,n,s=e;return function(i){if(i<1||i>t)return Te(i);s+i>e&&(n=Te(e),s=0);let a=n.subarray(s,s+=i);return s&7&&(s=(s|7)+1),a}}var tr=class{fn;len;next;val;constructor(e,t,n){this.fn=e,this.len=t,this.next=void 0,this.val=n}};function jo(){}var Yo=class{head;tail;len;next;constructor(e){this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}},Fh=Go();function Kh(r){return globalThis.Buffer!=null?Te(r):Fh(r)}var jr=class{len;head;tail;states;constructor(){this.len=0,this.head=new tr(jo,0,0),this.tail=this.head,this.states=null}_push(e,t,n){return this.tail=this.tail.next=new tr(e,t,n),this.len+=t,this}uint32(e){return this.len+=(this.tail=this.tail.next=new Zo((e=e>>>0)<128?1:e<16384?2:e<2097152?3:e<268435456?4:5,e)).len,this}int32(e){return e<0?this._push(_n,10,Oe.fromNumber(e)):this.uint32(e)}sint32(e){return this.uint32((e<<1^e>>31)>>>0)}uint64(e){let t=Oe.fromBigInt(e);return this._push(_n,t.length(),t)}uint64Number(e){return this._push(Mo,Ee(e),e)}uint64String(e){return this.uint64(BigInt(e))}int64(e){return this.uint64(e)}int64Number(e){return this.uint64Number(e)}int64String(e){return this.uint64String(e)}sint64(e){let t=Oe.fromBigInt(e).zzEncode();return this._push(_n,t.length(),t)}sint64Number(e){let t=Oe.fromNumber(e).zzEncode();return this._push(_n,t.length(),t)}sint64String(e){return this.sint64(BigInt(e))}bool(e){return this._push(Wo,1,e?1:0)}fixed32(e){return this._push(Gr,4,e>>>0)}sfixed32(e){return this.fixed32(e)}fixed64(e){let t=Oe.fromBigInt(e);return this._push(Gr,4,t.lo)._push(Gr,4,t.hi)}fixed64Number(e){let t=Oe.fromNumber(e);return this._push(Gr,4,t.lo)._push(Gr,4,t.hi)}fixed64String(e){return this.fixed64(BigInt(e))}sfixed64(e){return this.fixed64(e)}sfixed64Number(e){return this.fixed64Number(e)}sfixed64String(e){return this.fixed64String(e)}float(e){return this._push(Ga,4,e)}double(e){return this._push(Wa,8,e)}bytes(e){let t=e.length>>>0;return t===0?this._push(Wo,1,0):this.uint32(t)._push($h,t,e)}string(e){let t=Ja(e);return t!==0?this.uint32(t)._push(qo,t,e):this._push(Wo,1,0)}fork(){return this.states=new Yo(this),this.head=this.tail=new tr(jo,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 tr(jo,0,0),this.len=0),this}ldelim(){let e=this.head,t=this.tail,n=this.len;return this.reset().uint32(n),n!==0&&(this.tail.next=e.next,this.tail=t,this.len+=n),this}finish(){let e=this.head.next,t=Kh(this.len),n=0;for(;e!=null;)e.fn(e.val,t,n),n+=e.len,e=e.next;return t}};function Wo(r,e,t){e[t]=r&255}function qh(r,e,t){for(;r>127;)e[t++]=r&127|128,r>>>=7;e[t]=r}var Zo=class extends tr{next;constructor(e,t){super(qh,e,t),this.next=void 0}};function _n(r,e,t){for(;r.hi!==0;)e[t++]=r.lo&127|128,r.lo=(r.lo>>>7|r.hi<<25)>>>0,r.hi>>>=7;for(;r.lo>127;)e[t++]=r.lo&127|128,r.lo=r.lo>>>7;e[t++]=r.lo}function Gr(r,e,t){e[t]=r&255,e[t+1]=r>>>8&255,e[t+2]=r>>>16&255,e[t+3]=r>>>24}function $h(r,e,t){e.set(r,t)}globalThis.Buffer!=null&&(jr.prototype.bytes=function(r){let e=r.length>>>0;return this.uint32(e),e>0&&this._push(zh,e,r),this},jr.prototype.string=function(r){let e=globalThis.Buffer.byteLength(r);return this.uint32(e),e>0&&this._push(Gh,e,r),this});function zh(r,e,t){e.set(r,t)}function Gh(r,e,t){r.length<40?qo(r,e,t):e.utf8Write!=null?e.utf8Write(r,t):e.set(V(r),t)}function Jo(){return new jr}function Ge(r,e){let t=Jo();return e.encode(r,t,{lengthDelimited:!1}),t.finish()}var vr;(function(r){r[r.VARINT=0]="VARINT",r[r.BIT64=1]="BIT64",r[r.LENGTH_DELIMITED=2]="LENGTH_DELIMITED",r[r.START_GROUP=3]="START_GROUP",r[r.END_GROUP=4]="END_GROUP",r[r.BIT32=5]="BIT32"})(vr||(vr={}));function Cn(r,e,t,n){return{name:r,type:e,encode:t,decode:n}}function Xo(r){function e(s){if(r[s.toString()]==null)throw new Error("Invalid enum value");return r[s]}let t=function(o,i){let a=e(o);i.int32(a)},n=function(o){let i=o.int32();return e(i)};return Cn("enum",vr.VARINT,t,n)}function je(r,e){return Cn("message",vr.LENGTH_DELIMITED,r,e)}var ee;(function(r){r.RSA="RSA",r.Ed25519="Ed25519",r.Secp256k1="Secp256k1"})(ee||(ee={}));var Qo;(function(r){r[r.RSA=0]="RSA",r[r.Ed25519=1]="Ed25519",r[r.Secp256k1=2]="Secp256k1"})(Qo||(Qo={}));(function(r){r.codec=()=>Xo(Qo)})(ee||(ee={}));var rt;(function(r){let e;r.codec=()=>(e==null&&(e=je((t,n,s={})=>{s.lengthDelimited!==!1&&n.fork(),t.Type!=null&&(n.uint32(8),ee.codec().encode(t.Type,n)),t.Data!=null&&(n.uint32(18),n.bytes(t.Data)),s.lengthDelimited!==!1&&n.ldelim()},(t,n)=>{let s={},o=n==null?t.len:t.pos+n;for(;t.pos<o;){let i=t.uint32();switch(i>>>3){case 1:s.Type=ee.codec().decode(t);break;case 2:s.Data=t.bytes();break;default:t.skipType(i&7);break}}return s})),e),r.encode=t=>Ge(t,r.codec()),r.decode=t=>ze(t,r.codec())})(rt||(rt={}));var nt;(function(r){let e;r.codec=()=>(e==null&&(e=je((t,n,s={})=>{s.lengthDelimited!==!1&&n.fork(),t.Type!=null&&(n.uint32(8),ee.codec().encode(t.Type,n)),t.Data!=null&&(n.uint32(18),n.bytes(t.Data)),s.lengthDelimited!==!1&&n.ldelim()},(t,n)=>{let s={},o=n==null?t.len:t.pos+n;for(;t.pos<o;){let i=t.uint32();switch(i>>>3){case 1:s.Type=ee.codec().decode(t);break;case 2:s.Data=t.bytes();break;default:t.skipType(i&7);break}}return s})),e),r.encode=t=>Ge(t,r.codec()),r.decode=t=>ze(t,r.codec())})(nt||(nt={}));var Wr=class{_key;constructor(e){this._key=Er(e,wr)}verify(e,t){return qa(this._key,t,e)}marshal(){return this._key}get bytes(){return rt.encode({Type:ee.Ed25519,Data:this.marshal()}).subarray()}equals(e){return pe(this.bytes,e.bytes)}hash(){let e=be.digest(this.bytes);return Ve(e)?e.then(({bytes:t})=>t):e.bytes}},rr=class{_key;_publicKey;constructor(e,t){this._key=Er(e,wt),this._publicKey=Er(t,wr)}sign(e){return Ka(this._key,e)}get public(){return new Wr(this._publicKey)}marshal(){return this._key}get bytes(){return nt.encode({Type:ee.Ed25519,Data:this.marshal()}).subarray()}equals(e){return pe(this.bytes,e.bytes)}async hash(){let e=be.digest(this.bytes),t;return Ve(e)?{bytes:t}=await e:t=e.bytes,t}async id(){let e=ht.digest(this.public.bytes);return ne.encode(e.bytes).substring(1)}async export(e,t="libp2p-key"){if(t==="libp2p-key")return xr(this.bytes,e);throw new L(`export format '${t}' is not supported`,"ERR_INVALID_EXPORT_FORMAT")}};function jh(r){if(r.length>wt){r=Er(r,wt+wr);let n=r.subarray(0,wt),s=r.subarray(wt,r.length);return new rr(n,s)}r=Er(r,wt);let e=r.subarray(0,wt),t=r.subarray(wr);return new rr(e,t)}function Wh(r){return r=Er(r,wr),new Wr(r)}async function Yh(){let{privateKey:r,publicKey:e}=Ha();return new rr(r,e)}async function ec(r){let{privateKey:e,publicKey:t}=Fa(r);return new rr(e,t)}function Er(r,e){if(r=Uint8Array.from(r??[]),r.length!==e)throw new L(`Key must be a Uint8Array of length ${e}, got ${r.length}`,"ERR_INVALID_KEY_TYPE");return r}function D(r,e="utf8"){let t=bn[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return t.encoder.encode(r).substring(1)}var ui={};de(ui,{MAX_RSA_KEY_SIZE:()=>an,RsaPrivateKey:()=>kr,RsaPublicKey:()=>on,fromJwk:()=>Ed,generateKeyPair:()=>Bd,unmarshalRsaPrivateKey:()=>ci,unmarshalRsaPublicKey:()=>vd});function nr(r){if(isNaN(r)||r<=0)throw new L("random bytes length must be a Number bigger than 0","ERR_INVALID_LENGTH");return gr(r)}var Kt={};de(Kt,{exportToPem:()=>md,importFromPem:()=>yd,jwkToPkcs1:()=>hd,jwkToPkix:()=>pd,pkcs1ToJwk:()=>fd,pkixToJwk:()=>dd});var Un=class extends dr{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,wn(e);let n=_t(t);if(this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let s=this.blockLen,o=new Uint8Array(s);o.set(n.length>s?e.create().update(n).digest():n);for(let i=0;i<o.length;i++)o[i]^=54;this.iHash.update(o),this.oHash=e.create();for(let i=0;i<o.length;i++)o[i]^=106;this.oHash.update(o),o.fill(0)}update(e){return hr(this),this.iHash.update(e),this}digestInto(e){hr(this),fr(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){let e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));let{oHash:t,iHash:n,finished:s,destroyed:o,blockLen:i,outputLen:a}=this;return e=e,e.finished=s,e.destroyed=o,e.blockLen=i,e.outputLen=a,e.oHash=t._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},Yr=(r,e,t)=>new Un(r,e).update(t).digest();Yr.create=(r,e)=>new Un(r,e);function Zh(r,e,t,n){wn(r);let s=Ia({dkLen:32,asyncTick:10},n),{c:o,dkLen:i,asyncTick:a}=s;if(ur(o),ur(i),ur(a),o<1)throw new Error("PBKDF2: iterations (c) should be >= 1");let c=_t(e),f=_t(t),l=new Uint8Array(i),u=Yr.create(r,c),h=u._cloneInto().update(f);return{c:o,dkLen:i,asyncTick:a,DK:l,PRF:u,PRFSalt:h}}function Jh(r,e,t,n,s){return r.destroy(),e.destroy(),n&&n.destroy(),s.fill(0),t}async function ti(r,e,t,n){let{c:s,dkLen:o,asyncTick:i,DK:a,PRF:c,PRFSalt:f}=Zh(r,e,t,n),l,u=new Uint8Array(4),h=pr(u),y=new Uint8Array(c.outputLen);for(let b=1,m=0;m<o;b++,m+=c.outputLen){let d=a.subarray(m,m+c.outputLen);h.setInt32(0,b,!1),(l=f._cloneInto(l)).update(u).digestInto(y),d.set(y.subarray(0,d.length)),await Ba(s-1,i,()=>{c._cloneInto(l).update(y).digestInto(y);for(let x=0;x<d.length;x++)d[x]^=y[x]})}return Jh(c,f,a,l,y)}var K=ta(tc());function sr(r,e){let t=0;if(r.length===1)return r[0];for(let n=r.length-1;n>=0;n--)t+=r[r.length-1-n]*Math.pow(2,e*n);return t}function Mt(r,e,t=-1){let n=t,s=r,o=0,i=Math.pow(2,e);for(let a=1;a<8;a++){if(r<i){let c;if(n<0)c=new ArrayBuffer(a),o=a;else{if(n<a)return new ArrayBuffer(0);c=new ArrayBuffer(n),o=n}let f=new Uint8Array(c);for(let l=a-1;l>=0;l--){let u=Math.pow(2,l*e);f[o-l-1]=Math.floor(s/u),s-=f[o-l-1]*u}return c}i*=Math.pow(2,e)}return new ArrayBuffer(0)}function Vn(...r){let e=0,t=0;for(let o of r)e+=o.length;let n=new ArrayBuffer(e),s=new Uint8Array(n);for(let o of r)s.set(o,t),t+=o.length;return s}function ni(){let r=new Uint8Array(this.valueHex);if(this.valueHex.byteLength>=2){let a=r[0]===255&&r[1]&128,c=r[0]===0&&(r[1]&128)===0;(a||c)&&this.warnings.push("Needlessly long format")}let e=new ArrayBuffer(this.valueHex.byteLength),t=new Uint8Array(e);for(let a=0;a<this.valueHex.byteLength;a++)t[a]=0;t[0]=r[0]&128;let n=sr(t,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,sr(o,8)-n}function rc(r){let e=r<0?r*-1:r,t=128;for(let n=1;n<8;n++){if(e<=t){if(r<0){let i=t-e,a=Mt(i,8,n),c=new Uint8Array(a);return c[0]|=128,a}let s=Mt(e,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}t*=Math.pow(2,8)}return new ArrayBuffer(0)}function nc(r,e){if(r.byteLength!==e.byteLength)return!1;let t=new Uint8Array(r),n=new Uint8Array(e);for(let s=0;s<t.length;s++)if(t[s]!==n[s])return!1;return!0}function Le(r,e){let t=r.toString(10);if(e<t.length)return"";let n=e-t.length,s=new Array(n);for(let i=0;i<n;i++)s[i]="0";return s.join("").concat(t)}var _m=Math.log(2);function Dn(){if(typeof BigInt>"u")throw new Error("BigInt is not defined. Your environment doesn't implement BigInt.")}function si(r){let e=0,t=0;for(let s=0;s<r.length;s++){let o=r[s];e+=o.byteLength}let n=new Uint8Array(e);for(let s=0;s<r.length;s++){let o=r[s];n.set(new Uint8Array(o),t),t+=o.byteLength}return n.buffer}function It(r,e,t,n){return e instanceof Uint8Array?e.byteLength?t<0?(r.error="Wrong parameter: inputOffset less than zero",!1):n<0?(r.error="Wrong parameter: inputLength less than zero",!1):e.byteLength-t-n<0?(r.error="End of input reached before message was fully decoded (inconsistent offset and length values)",!1):!0:(r.error="Wrong parameter: inputBuffer has zero length",!1):(r.error="Wrong parameter: inputBuffer must be 'Uint8Array'",!1)}var Jr=class{constructor(){this.items=[]}write(e){this.items.push(e)}final(){return si(this.items)}},Zr=[new Uint8Array([1])],sc="0123456789";var Ir="",Ye=new ArrayBuffer(0),oi=new Uint8Array(0),Xr="EndOfContent",ic="OCTET STRING",ac="BIT STRING";function St(r){var e;return e=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?K.BufferSourceConverter.toUint8Array(o.valueHex):oi}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(!It(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",Ye)}toJSON(){return{...super.toJSON(),isHexOnly:this.isHexOnly,valueHex:K.Convert.ToHex(this.valueHexView)}}},e.NAME="hexBlock",e}var Et=class{constructor({blockLength:e=0,error:t=Ir,warnings:n=[],valueBeforeDecode:s=oi}={}){this.blockLength=e,this.error=t,this.warnings=n,this.valueBeforeDecodeView=K.BufferSourceConverter.toUint8Array(s)}static blockName(){return this.NAME}get valueBeforeDecode(){return this.valueBeforeDecodeView.slice().buffer}set valueBeforeDecode(e){this.valueBeforeDecodeView=new Uint8Array(e)}toJSON(){return{blockName:this.constructor.NAME,blockLength:this.blockLength,error:this.error,warnings:this.warnings,valueBeforeDecode:K.Convert.ToHex(this.valueBeforeDecodeView)}}};Et.NAME="baseBlock";var Ae=class extends Et{fromBER(e,t,n){throw TypeError("User need to make a specific function in a class which extends 'ValueBlock'")}toBER(e,t){throw TypeError("User need to make a specific function in a class which extends 'ValueBlock'")}};Ae.NAME="valueBlock";var Mn=class extends St(Et){constructor({idBlock:e={}}={}){var t,n,s,o;super(),e?(this.isHexOnly=(t=e.isHexOnly)!==null&&t!==void 0?t:!1,this.valueHexView=e.valueHex?K.BufferSourceConverter.toUint8Array(e.valueHex):oi,this.tagClass=(n=e.tagClass)!==null&&n!==void 0?n:-1,this.tagNumber=(s=e.tagNumber)!==null&&s!==void 0?s:-1,this.isConstructed=(o=e.isConstructed)!==null&&o!==void 0?o:!1):(this.tagClass=-1,this.tagNumber=-1,this.isConstructed=!1)}toBER(e=!1){let t=0;switch(this.tagClass){case 1:t|=0;break;case 2:t|=64;break;case 3:t|=128;break;case 4:t|=192;break;default:return this.error="Unknown tag class",Ye}if(this.isConstructed&&(t|=32),this.tagNumber<31&&!this.isHexOnly){let s=new Uint8Array(1);if(!e){let o=this.tagNumber;o&=31,t|=o,s[0]=t}return s.buffer}if(!this.isHexOnly){let s=Mt(this.tagNumber,7),o=new Uint8Array(s),i=s.byteLength,a=new Uint8Array(i+1);if(a[0]=t|31,!e){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]=t|31,!e){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(e,t,n){let s=K.BufferSourceConverter.toUint8Array(e);if(!It(this,s,t,n))return-1;let o=s.subarray(t,t+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,f=this.valueHexView=new Uint8Array(255),l=255;for(;o[c]&128;){if(f[c-1]=o[c]&127,c++,c>=o.length)return this.error="End of input reached before message was fully decoded",-1;if(c===l){l+=255;let h=new Uint8Array(l);for(let y=0;y<f.length;y++)h[y]=f[y];f=this.valueHexView=new Uint8Array(l)}}this.blockLength=c+1,f[c-1]=o[c]&127;let u=new Uint8Array(c);for(let h=0;h<c;h++)u[h]=f[h];f=this.valueHexView=new Uint8Array(c),f.set(u),this.blockLength<=9?this.tagNumber=sr(f,7):(this.isHexOnly=!0,this.warnings.push("Tag too long, represented as hex-coded"))}if(this.tagClass===1&&this.isConstructed)switch(this.tagNumber){case 1:case 2:case 5:case 6:case 9:case 13:case 14:case 23:case 24:case 31:case 32:case 33:case 34:return this.error="Constructed encoding used for primitive type",-1}return t+this.blockLength}toJSON(){return{...super.toJSON(),tagClass:this.tagClass,tagNumber:this.tagNumber,isConstructed:this.isConstructed}}};Mn.NAME="identificationBlock";var Hn=class extends Et{constructor({lenBlock:e={}}={}){var t,n,s;super(),this.isIndefiniteForm=(t=e.isIndefiniteForm)!==null&&t!==void 0?t:!1,this.longFormUsed=(n=e.longFormUsed)!==null&&n!==void 0?n:!1,this.length=(s=e.length)!==null&&s!==void 0?s:0}fromBER(e,t,n){let s=K.BufferSourceConverter.toUint8Array(e);if(!It(this,s,t,n))return-1;let o=s.subarray(t,t+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,t+this.blockLength;if(this.longFormUsed=!!(o[0]&128),this.longFormUsed===!1)return this.length=o[0],this.blockLength=1,t+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=t+1,c=s.subarray(a,a+i);return c[i-1]===0&&this.warnings.push("Needlessly long encoded length"),this.length=sr(c,8),this.longFormUsed&&this.length<=127&&this.warnings.push("Unnecessary usage of long length form"),this.blockLength=i+1,t+this.blockLength}toBER(e=!1){let t,n;if(this.length>127&&(this.longFormUsed=!0),this.isIndefiniteForm)return t=new ArrayBuffer(1),e===!1&&(n=new Uint8Array(t),n[0]=128),t;if(this.longFormUsed){let s=Mt(this.length,8);if(s.byteLength>127)return this.error="Too big length",Ye;if(t=new ArrayBuffer(s.byteLength+1),e)return t;let o=new Uint8Array(s);n=new Uint8Array(t),n[0]=s.byteLength|128;for(let i=0;i<s.byteLength;i++)n[i+1]=o[i];return t}return t=new ArrayBuffer(1),e===!1&&(n=new Uint8Array(t),n[0]=this.length),t}toJSON(){return{...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,longFormUsed:this.longFormUsed,length:this.length}}};Hn.NAME="lengthBlock";var I={},we=class extends Et{constructor({name:e=Ir,optional:t=!1,primitiveSchema:n,...s}={},o){super(s),this.name=e,this.optional=t,n&&(this.primitiveSchema=n),this.idBlock=new Mn(s),this.lenBlock=new Hn(s),this.valueBlock=o?new o(s):new Ae(s)}fromBER(e,t,n){let s=this.valueBlock.fromBER(e,t,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(e,t){let n=t||new Jr;t||cc(this);let s=this.idBlock.toBER(e);if(n.write(s),this.lenBlock.isIndefiniteForm)n.write(new Uint8Array([128]).buffer),this.valueBlock.toBER(e,n),n.write(new ArrayBuffer(2));else{let o=this.valueBlock.toBER(e);this.lenBlock.length=o.byteLength;let i=this.lenBlock.toBER(e);n.write(i),n.write(o)}return t?Ye:n.final()}toJSON(){let e={...super.toJSON(),idBlock:this.idBlock.toJSON(),lenBlock:this.lenBlock.toJSON(),valueBlock:this.valueBlock.toJSON(),name:this.name,optional:this.optional};return this.primitiveSchema&&(e.primitiveSchema=this.primitiveSchema.toJSON()),e}toString(e="ascii"){return e==="ascii"?this.onAsciiEncoding():K.Convert.ToHex(this.toBER())}onAsciiEncoding(){return`${this.constructor.NAME} : ${K.Convert.ToHex(this.valueBlock.valueBeforeDecodeView)}`}isEqual(e){if(this===e)return!0;if(!(e instanceof this.constructor))return!1;let t=this.toBER(),n=e.toBER();return nc(t,n)}};we.NAME="BaseBlock";function cc(r){if(r instanceof I.Constructed)for(let e of r.valueBlock.value)cc(e)&&(r.lenBlock.isIndefiniteForm=!0);return!!r.lenBlock.isIndefiniteForm}var Fn=class extends we{constructor({value:e=Ir,...t}={},n){super(t,n),e&&this.fromString(e)}getValue(){return this.valueBlock.value}setValue(e){this.valueBlock.value=e}fromBER(e,t,n){let s=this.valueBlock.fromBER(e,t,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}'`}};Fn.NAME="BaseStringBlock";var Kn=class extends St(Ae){constructor({isHexOnly:e=!0,...t}={}){super(t),this.isHexOnly=e}};Kn.NAME="PrimitiveValueBlock";var lc,qn=class extends we{constructor(e={}){super(e,Kn),this.idBlock.isConstructed=!1}};lc=qn;I.Primitive=lc;qn.NAME="PRIMITIVE";function id(r,e){if(r instanceof e)return r;let t=new e;return t.idBlock=r.idBlock,t.lenBlock=r.lenBlock,t.warnings=r.warnings,t.valueBeforeDecodeView=r.valueBeforeDecodeView,t}function Es(r,e=0,t=r.length){let n=e,s=new we({},Ae),o=new Et;if(!It(o,r,e,t))return s.error=o.error,{offset:-1,result:s};if(!r.subarray(e,e+t).length)return s.error="Zero buffer length",{offset:-1,result:s};let a=s.idBlock.fromBER(r,e,t);if(s.idBlock.warnings.length&&s.warnings.concat(s.idBlock.warnings),a===-1)return s.error=s.idBlock.error,{offset:-1,result:s};if(e=a,t-=s.idBlock.blockLength,a=s.lenBlock.fromBER(r,e,t),s.lenBlock.warnings.length&&s.warnings.concat(s.lenBlock.warnings),a===-1)return s.error=s.lenBlock.error,{offset:-1,result:s};if(e=a,t-=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=we;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=I.EndOfContent;break;case 1:c=I.Boolean;break;case 2:c=I.Integer;break;case 3:c=I.BitString;break;case 4:c=I.OctetString;break;case 5:c=I.Null;break;case 6:c=I.ObjectIdentifier;break;case 10:c=I.Enumerated;break;case 12:c=I.Utf8String;break;case 13:c=I.RelativeObjectIdentifier;break;case 14:c=I.TIME;break;case 15:return s.error="[UNIVERSAL 15] is reserved by ASN.1 standard",{offset:-1,result:s};case 16:c=I.Sequence;break;case 17:c=I.Set;break;case 18:c=I.NumericString;break;case 19:c=I.PrintableString;break;case 20:c=I.TeletexString;break;case 21:c=I.VideotexString;break;case 22:c=I.IA5String;break;case 23:c=I.UTCTime;break;case 24:c=I.GeneralizedTime;break;case 25:c=I.GraphicString;break;case 26:c=I.VisibleString;break;case 27:c=I.GeneralString;break;case 28:c=I.UniversalString;break;case 29:c=I.CharacterString;break;case 30:c=I.BmpString;break;case 31:c=I.DATE;break;case 32:c=I.TimeOfDay;break;case 33:c=I.DateTime;break;case 34:c=I.Duration;break;default:{let f=s.idBlock.isConstructed?new I.Constructed:new I.Primitive;f.idBlock=s.idBlock,f.lenBlock=s.lenBlock,f.warnings=s.warnings,s=f}}break;case 2:case 3:case 4:default:c=s.idBlock.isConstructed?I.Constructed:I.Primitive}return s=id(s,c),a=s.fromBER(r,e,s.lenBlock.isIndefiniteForm?t:s.lenBlock.length),s.valueBeforeDecodeView=r.subarray(n,n+s.blockLength),{offset:a,result:s}}function Sr(r){if(!r.byteLength){let e=new we({},Ae);return e.error="Input buffer has zero length",{offset:-1,result:e}}return Es(K.BufferSourceConverter.toUint8Array(r).slice(),0,r.byteLength)}function ad(r,e){return r?1:e}var st=class extends Ae{constructor({value:e=[],isIndefiniteForm:t=!1,...n}={}){super(n),this.value=e,this.isIndefiniteForm=t}fromBER(e,t,n){let s=K.BufferSourceConverter.toUint8Array(e);if(!It(this,s,t,n))return-1;if(this.valueBeforeDecodeView=s.subarray(t,t+n),this.valueBeforeDecodeView.length===0)return this.warnings.push("Zero buffer length"),t;let o=t;for(;ad(this.isIndefiniteForm,n)>0;){let i=Es(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===Xr)break}return this.isIndefiniteForm&&(this.value[this.value.length-1].constructor.NAME===Xr?this.value.pop():this.warnings.push("No EndOfContent block encoded")),o}toBER(e,t){let n=t||new Jr;for(let s=0;s<this.value.length;s++)this.value[s].toBER(e,n);return t?Ye:n.final()}toJSON(){let e={...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,value:[]};for(let t of this.value)e.value.push(t.toJSON());return e}};st.NAME="ConstructedValueBlock";var uc,Ht=class extends we{constructor(e={}){super(e,st),this.idBlock.isConstructed=!0}fromBER(e,t,n){this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm;let s=this.valueBlock.fromBER(e,t,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 e=[];for(let n of this.valueBlock.value)e.push(n.toString("ascii").split(`
3
3
  `).map(s=>` ${s}`).join(`
4
4
  `));let t=this.idBlock.tagClass===3?`[${this.idBlock.tagNumber}]`:this.constructor.NAME;return e.length?`${t} :
5
5
  ${e.join(`
6
- `)}`:`${t} :`}};cc=Ot;A.Constructed=cc;Ot.NAME="CONSTRUCTED";var Kn=class extends Be{fromBER(e,t,n){return t}toBER(e){return Ye}};Kn.override="EndOfContentValueBlock";var lc,qn=class extends be{constructor(e={}){super(e,Kn),this.idBlock.tagClass=1,this.idBlock.tagNumber=0}};lc=qn;A.EndOfContent=lc;qn.NAME=Wr;var uc,Vt=class extends be{constructor(e={}){super(e,Be),this.idBlock.tagClass=1,this.idBlock.tagNumber=5}fromBER(e,t,n){return this.lenBlock.length>0&&this.warnings.push("Non-zero length of value block for Null type"),this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.blockLength+=n,t+n>e.byteLength?(this.error="End of input reached before message was fully decoded (inconsistent offset and length values)",-1):t+n}toBER(e,t){let n=new ArrayBuffer(2);if(!e){let s=new Uint8Array(n);s[0]=5,s[1]=0}return t&&t.write(n),n}onAsciiEncoding(){return`${this.constructor.NAME}`}};uc=Vt;A.Null=uc;Vt.NAME="NULL";var $n=class extends It(Be){constructor({value:e,...t}={}){super(t),t.valueHex?this.valueHexView=M.BufferSourceConverter.toUint8Array(t.valueHex):this.valueHexView=new Uint8Array(1),e&&(this.value=e)}get value(){for(let e of this.valueHexView)if(e>0)return!0;return!1}set value(e){this.valueHexView[0]=e?255:0}fromBER(e,t,n){let s=M.BufferSourceConverter.toUint8Array(e);return At(this,s,t,n)?(this.valueHexView=s.subarray(t,t+n),n>1&&this.warnings.push("Boolean value encoded in more then 1 octet"),this.isHexOnly=!0,ei.call(this),this.blockLength=n,t+n):-1}toBER(){return this.valueHexView.slice()}toJSON(){return{...super.toJSON(),value:this.value}}};$n.NAME="BooleanValueBlock";var fc,zn=class extends be{constructor(e={}){super(e,$n),this.idBlock.tagClass=1,this.idBlock.tagNumber=1}getValue(){return this.valueBlock.value}setValue(e){this.valueBlock.value=e}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.getValue}`}};fc=zn;A.Boolean=fc;zn.NAME="BOOLEAN";var Gn=class extends It(st){constructor({isConstructed:e=!1,...t}={}){super(t),this.isConstructed=e}fromBER(e,t,n){let s=0;if(this.isConstructed){if(this.isHexOnly=!1,s=st.prototype.fromBER.call(this,e,t,n),s===-1)return s;for(let o=0;o<this.value.length;o++){let i=this.value[o].constructor.NAME;if(i===Wr){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, OCTET STRING may consists of OCTET STRINGs only",-1}if(i!==sc)return this.error="OCTET STRING may consists of OCTET STRINGs only",-1}}else this.isHexOnly=!0,s=super.fromBER(e,t,n),this.blockLength=n;return s}toBER(e,t){return this.isConstructed?st.prototype.toBER.call(this,e,t):e?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),isConstructed:this.isConstructed}}};Gn.NAME="OctetStringValueBlock";var hc,Et=class r extends be{constructor({idBlock:e={},lenBlock:t={},...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,...e},lenBlock:{...t,isIndefiniteForm:!!n.isIndefiniteForm},...n},Gn),this.idBlock.tagClass=1,this.idBlock.tagNumber=4}fromBER(e,t,n){if(this.valueBlock.isConstructed=this.idBlock.isConstructed,this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm,n===0)return this.idBlock.error.length===0&&(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length===0&&(this.blockLength+=this.lenBlock.blockLength),t;if(!this.valueBlock.isConstructed){let o=(e instanceof ArrayBuffer?new Uint8Array(e):e).subarray(t,t+n);try{if(o.byteLength){let i=xs(o,0,o.byteLength);i.offset!==-1&&i.offset===n&&(this.valueBlock.value=[i.result])}}catch{}}return super.fromBER(e,t,n)}onAsciiEncoding(){return this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length?Ot.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 e=[];for(let t of this.valueBlock.value)t instanceof r&&e.push(t.valueBlock.valueHexView);return M.BufferSourceConverter.concat(e)}};hc=Et;A.OctetString=hc;Et.NAME=sc;var jn=class extends It(st){constructor({unusedBits:e=0,isConstructed:t=!1,...n}={}){super(n),this.unusedBits=e,this.isConstructed=t,this.blockLength=this.valueHexView.byteLength}fromBER(e,t,n){if(!n)return t;let s=-1;if(this.isConstructed){if(s=st.prototype.fromBER.call(this,e,t,n),s===-1)return s;for(let a of this.value){let c=a.constructor.NAME;if(c===Wr){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, BIT STRING may consists of BIT STRINGs only",-1}if(c!==oc)return this.error="BIT STRING may consists of BIT STRINGs only",-1;let f=a.valueBlock;if(this.unusedBits>0&&f.unusedBits>0)return this.error='Using of "unused bits" inside constructive BIT STRING allowed for least one only',-1;this.unusedBits=f.unusedBits}return s}let o=M.BufferSourceConverter.toUint8Array(e);if(!At(this,o,t,n))return-1;let i=o.subarray(t,t+n);if(this.unusedBits=i[0],this.unusedBits>7)return this.error="Unused bits for BitString must be in range 0-7",-1;if(!this.unusedBits){let a=i.subarray(1);try{if(a.byteLength){let c=xs(a,0,a.byteLength);c.offset!==-1&&c.offset===n-1&&(this.value=[c.result])}}catch{}}return this.valueHexView=i.subarray(1),this.blockLength=i.length,t+n}toBER(e,t){if(this.isConstructed)return st.prototype.toBER.call(this,e,t);if(e)return new ArrayBuffer(this.valueHexView.byteLength+1);if(!this.valueHexView.byteLength)return Ye;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}}};jn.NAME="BitStringValueBlock";var dc,vr=class extends be{constructor({idBlock:e={},lenBlock:t={},...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,...e},lenBlock:{...t,isIndefiniteForm:!!n.isIndefiniteForm},...n},jn),this.idBlock.tagClass=1,this.idBlock.tagNumber=3}fromBER(e,t,n){return this.valueBlock.isConstructed=this.idBlock.isConstructed,this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm,super.fromBER(e,t,n)}onAsciiEncoding(){if(this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length)return Ot.prototype.onAsciiEncoding.call(this);{let e=[],t=this.valueBlock.valueHexView;for(let s of t)e.push(s.toString(2).padStart(8,"0"));let n=e.join("");return`${this.constructor.NAME} : ${n.substring(0,n.length-this.valueBlock.unusedBits)}`}}};dc=vr;A.BitString=dc;vr.NAME=oc;var pc;function id(r,e){let t=new Uint8Array([0]),n=new Uint8Array(r),s=new Uint8Array(e),o=n.slice(0),i=o.length-1,a=s.slice(0),c=a.length-1,f=0,u=c<i?i:c,l=0;for(let p=u;p>=0;p--,l++){switch(!0){case l<a.length:f=o[i-l]+a[c-l]+t[0];break;default:f=o[i-l]+t[0]}switch(t[0]=f/10,!0){case l>=o.length:o=Pn(new Uint8Array([f%10]),o);break;default:o[i-l]=f%10}}return t[0]>0&&(o=Pn(t,o)),o}function nc(r){if(r>=Gr.length)for(let e=Gr.length;e<=r;e++){let t=new Uint8Array([0]),n=Gr[e-1].slice(0);for(let s=n.length-1;s>=0;s--){let o=new Uint8Array([(n[s]<<1)+t[0]]);t[0]=o[0]/10,n[s]=o[0]%10}t[0]>0&&(n=Pn(t,n)),Gr.push(n)}return Gr[r]}function ad(r,e){let t=0,n=new Uint8Array(r),s=new Uint8Array(e),o=n.slice(0),i=o.length-1,a=s.slice(0),c=a.length-1,f,u=0;for(let l=c;l>=0;l--,u++)switch(f=o[i-u]-a[c-u]-t,!0){case f<0:t=1,o[i-u]=f+10;break;default:t=0,o[i-u]=f}if(t>0)for(let l=i-c+1;l>=0;l--,u++)if(f=o[i-u]-t,f<0)t=1,o[i-u]=f+10;else{t=0,o[i-u]=f;break}return o.slice()}var Yr=class extends It(Be){constructor({value:e,...t}={}){super(t),this._valueDec=0,t.valueHex&&this.setValueHex(),e!==void 0&&(this.valueDec=e)}setValueHex(){this.valueHexView.length>=4?(this.warnings.push("Too big Integer for decoding, hex only"),this.isHexOnly=!0,this._valueDec=0):(this.isHexOnly=!1,this.valueHexView.length>0&&(this._valueDec=ei.call(this)))}set valueDec(e){this._valueDec=e,this.isHexOnly=!1,this.valueHexView=new Uint8Array(ec(e))}get valueDec(){return this._valueDec}fromDER(e,t,n,s=0){let o=this.fromBER(e,t,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(e=!1){let t=this.valueHexView;switch(!0){case(t[0]&128)!==0:{let n=new Uint8Array(this.valueHexView.length+1);n[0]=0,n.set(t,1),this.valueHexView=n}break;case(t[0]===0&&(t[1]&128)===0):this.valueHexView=this.valueHexView.subarray(1);break}return this.toBER(e)}fromBER(e,t,n){let s=super.fromBER(e,t,n);return s===-1||this.setValueHex(),s}toBER(e){return e?new ArrayBuffer(this.valueHexView.length):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}toString(){let e=this.valueHexView.length*8-1,t=new Uint8Array(this.valueHexView.length*8/3),n=0,s,o=this.valueHexView,i="",a=!1;for(let c=o.byteLength-1;c>=0;c--){s=o[c];for(let f=0;f<8;f++){if((s&1)===1)switch(n){case e:t=ad(nc(n),t),i="-";break;default:t=id(t,nc(n))}n++,s>>=1}}for(let c=0;c<t.length;c++)t[c]&&(a=!0),a&&(i+=rc.charAt(t[c]));return a===!1&&(i+=rc.charAt(0)),i}};pc=Yr;Yr.NAME="IntegerValueBlock";Object.defineProperty(pc.prototype,"valueHex",{set:function(r){this.valueHexView=new Uint8Array(r),this.setValueHex()},get:function(){return this.valueHexView.slice().buffer}});var gc,ie=class r extends be{constructor(e={}){super(e,Yr),this.idBlock.tagClass=1,this.idBlock.tagNumber=2}toBigInt(){return On(),BigInt(this.valueBlock.toString())}static fromBigInt(e){On();let t=BigInt(e),n=new jr,s=t.toString(16).replace(/^-/,""),o=new Uint8Array(M.Convert.FromHex(s));if(t<0){let a=new Uint8Array(o.length+(o[0]&128?1:0));a[0]|=128;let f=BigInt(`0x${M.Convert.ToHex(a)}`)+t,u=M.BufferSourceConverter.toUint8Array(M.Convert.FromHex(f.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 e=new r({valueHex:this.valueBlock.valueHexView});return e.valueBlock.toDER(),e}convertFromDER(){return new r({valueHex:this.valueBlock.valueHexView[0]===0?this.valueBlock.valueHexView.subarray(1):this.valueBlock.valueHexView})}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()}`}};gc=ie;A.Integer=gc;ie.NAME="INTEGER";var mc,Wn=class extends ie{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=10}};mc=Wn;A.Enumerated=mc;Wn.NAME="ENUMERATED";var Zr=class extends It(Be){constructor({valueDec:e=-1,isFirstSid:t=!1,...n}={}){super(n),this.valueDec=e,this.isFirstSid=t}fromBER(e,t,n){if(!n)return t;let s=M.BufferSourceConverter.toUint8Array(e);if(!At(this,s,t,n))return-1;let o=s.subarray(t,t+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=er(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),t+this.blockLength)}set valueBigInt(e){On();let t=BigInt(e).toString(2);for(;t.length%7;)t="0"+t;let n=new Uint8Array(t.length/7);for(let s=0;s<n.length;s++)n[s]=parseInt(t.slice(s*7,s*7+7),2)+(s+1<n.length?128:0);this.fromBER(n.buffer,0,n.length)}toBER(e){if(this.isHexOnly){if(e)return new ArrayBuffer(this.valueHexView.byteLength);let 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 t=Pt(this.valueDec,7);if(t.byteLength===0)return this.error="Error during encoding SID value",Ye;let n=new Uint8Array(t.byteLength);if(!e){let s=new Uint8Array(t),o=t.byteLength-1;for(let i=0;i<o;i++)n[i]=s[i]|128;n[o]=s[o]}return n}toString(){let e="";if(this.isHexOnly)e=M.Convert.ToHex(this.valueHexView);else if(this.isFirstSid){let t=this.valueDec;this.valueDec<=39?e="0.":this.valueDec<=79?(e="1.",t-=40):(e="2.",t-=80),e+=t.toString()}else e=this.valueDec.toString();return e}toJSON(){return{...super.toJSON(),valueDec:this.valueDec,isFirstSid:this.isFirstSid}}};Zr.NAME="sidBlock";var Yn=class extends Be{constructor({value:e=Er,...t}={}){super(t),this.value=[],e&&this.fromString(e)}fromBER(e,t,n){let s=t;for(;n>0;){let o=new Zr;if(s=o.fromBER(e,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(e){let t=[];for(let n=0;n<this.value.length;n++){let s=this.value[n].toBER(e);if(s.byteLength===0)return this.error=this.value[n].error,Ye;t.push(s)}return ti(t)}fromString(e){this.value=[];let t=0,n=0,s="",o=!1;do if(n=e.indexOf(".",t),n===-1?s=e.substring(t):s=e.substring(t,n),t=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){On();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 e="",t=!1;for(let n=0;n<this.value.length;n++){t=this.value[n].isHexOnly;let s=this.value[n].toString();n!==0&&(e=`${e}.`),t?(s=`{${s}}`,this.value[n].isFirstSid?e=`2.{${s} - 80}`:e+=s):e+=s}return e}toJSON(){let e={...super.toJSON(),value:this.toString(),sidArray:[]};for(let t=0;t<this.value.length;t++)e.sidArray.push(this.value[t].toJSON());return e}};Yn.NAME="ObjectIdentifierValueBlock";var yc,We=class extends be{constructor(e={}){super(e,Yn),this.idBlock.tagClass=1,this.idBlock.tagNumber=6}getValue(){return this.valueBlock.toString()}setValue(e){this.valueBlock.fromString(e)}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()||"empty"}`}toJSON(){return{...super.toJSON(),value:this.getValue()}}};yc=We;A.ObjectIdentifier=yc;We.NAME="OBJECT IDENTIFIER";var Jr=class extends It(vt){constructor({valueDec:e=0,...t}={}){super(t),this.valueDec=e}fromBER(e,t,n){if(n===0)return t;let s=M.BufferSourceConverter.toUint8Array(e);if(!At(this,s,t,n))return-1;let o=s.subarray(t,t+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=er(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),t+this.blockLength)}toBER(e){if(this.isHexOnly){if(e)return new ArrayBuffer(this.valueHexView.byteLength);let 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 t=Pt(this.valueDec,7);if(t.byteLength===0)return this.error="Error during encoding SID value",Ye;let n=new Uint8Array(t.byteLength);if(!e){let s=new Uint8Array(t),o=t.byteLength-1;for(let i=0;i<o;i++)n[i]=s[i]|128;n[o]=s[o]}return n.buffer}toString(){let e="";return this.isHexOnly?e=M.Convert.ToHex(this.valueHexView):e=this.valueDec.toString(),e}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}};Jr.NAME="relativeSidBlock";var Zn=class extends Be{constructor({value:e=Er,...t}={}){super(t),this.value=[],e&&this.fromString(e)}fromBER(e,t,n){let s=t;for(;n>0;){let o=new Jr;if(s=o.fromBER(e,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(e,t){let n=[];for(let s=0;s<this.value.length;s++){let o=this.value[s].toBER(e);if(o.byteLength===0)return this.error=this.value[s].error,Ye;n.push(o)}return ti(n)}fromString(e){this.value=[];let t=0,n=0,s="";do{n=e.indexOf(".",t),n===-1?s=e.substring(t):s=e.substring(t,n),t=n+1;let o=new Jr;if(o.valueDec=parseInt(s,10),isNaN(o.valueDec))return!0;this.value.push(o)}while(n!==-1);return!0}toString(){let e="",t=!1;for(let n=0;n<this.value.length;n++){t=this.value[n].isHexOnly;let s=this.value[n].toString();n!==0&&(e=`${e}.`),t&&(s=`{${s}}`),e+=s}return e}toJSON(){let e={...super.toJSON(),value:this.toString(),sidArray:[]};for(let t=0;t<this.value.length;t++)e.sidArray.push(this.value[t].toJSON());return e}};Zn.NAME="RelativeObjectIdentifierValueBlock";var bc,Jn=class extends be{constructor(e={}){super(e,Zn),this.idBlock.tagClass=1,this.idBlock.tagNumber=13}getValue(){return this.valueBlock.toString()}setValue(e){this.valueBlock.fromString(e)}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()||"empty"}`}toJSON(){return{...super.toJSON(),value:this.getValue()}}};bc=Jn;A.RelativeObjectIdentifier=bc;Jn.NAME="RelativeObjectIdentifier";var wc,ge=class extends Ot{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=16}};wc=ge;A.Sequence=wc;ge.NAME="SEQUENCE";var xc,Xn=class extends Ot{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=17}};xc=Xn;A.Set=xc;Xn.NAME="SET";var Qn=class extends It(Be){constructor({...e}={}){super(e),this.isHexOnly=!0,this.value=Er}toJSON(){return{...super.toJSON(),value:this.value}}};Qn.NAME="StringValueBlock";var es=class extends Qn{};es.NAME="SimpleStringValueBlock";var Se=class extends Mn{constructor({...e}={}){super(e,es)}fromBuffer(e){this.valueBlock.value=String.fromCharCode.apply(null,M.BufferSourceConverter.toUint8Array(e))}fromString(e){let t=e.length,n=this.valueBlock.valueHexView=new Uint8Array(t);for(let s=0;s<t;s++)n[s]=e.charCodeAt(s);this.valueBlock.value=e}};Se.NAME="SIMPLE STRING";var ts=class extends Se{fromBuffer(e){this.valueBlock.valueHexView=M.BufferSourceConverter.toUint8Array(e);try{this.valueBlock.value=M.Convert.ToUtf8String(e)}catch(t){this.warnings.push(`Error during "decodeURIComponent": ${t}, using raw string`),this.valueBlock.value=M.Convert.ToBinary(e)}}fromString(e){this.valueBlock.valueHexView=new Uint8Array(M.Convert.FromUtf8String(e)),this.valueBlock.value=e}};ts.NAME="Utf8StringValueBlock";var vc,Bt=class extends ts{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=12}};vc=Bt;A.Utf8String=vc;Bt.NAME="UTF8String";var rs=class extends Se{fromBuffer(e){this.valueBlock.value=M.Convert.ToUtf16String(e),this.valueBlock.valueHexView=M.BufferSourceConverter.toUint8Array(e)}fromString(e){this.valueBlock.value=e,this.valueBlock.valueHexView=new Uint8Array(M.Convert.FromUtf16String(e))}};rs.NAME="BmpStringValueBlock";var Ec,ns=class extends rs{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=30}};Ec=ns;A.BmpString=Ec;ns.NAME="BMPString";var ss=class extends Se{fromBuffer(e){let t=ArrayBuffer.isView(e)?e.slice().buffer:e.slice(0),n=new Uint8Array(t);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(t))}fromString(e){let t=e.length,n=this.valueBlock.valueHexView=new Uint8Array(t*4);for(let s=0;s<t;s++){let o=Pt(e.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=e}};ss.NAME="UniversalStringValueBlock";var Bc,os=class extends ss{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=28}};Bc=os;A.UniversalString=Bc;os.NAME="UniversalString";var Ac,is=class extends Se{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=18}};Ac=is;A.NumericString=Ac;is.NAME="NumericString";var Ic,as=class extends Se{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=19}};Ic=as;A.PrintableString=Ic;as.NAME="PrintableString";var Sc,cs=class extends Se{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=20}};Sc=cs;A.TeletexString=Sc;cs.NAME="TeletexString";var kc,ls=class extends Se{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=21}};kc=ls;A.VideotexString=kc;ls.NAME="VideotexString";var Nc,us=class extends Se{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=22}};Nc=us;A.IA5String=Nc;us.NAME="IA5String";var Rc,fs=class extends Se{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=25}};Rc=fs;A.GraphicString=Rc;fs.NAME="GraphicString";var Tc,Xr=class extends Se{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=26}};Tc=Xr;A.VisibleString=Tc;Xr.NAME="VisibleString";var _c,hs=class extends Se{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=27}};_c=hs;A.GeneralString=_c;hs.NAME="GeneralString";var Cc,ds=class extends Se{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=29}};Cc=ds;A.CharacterString=Cc;ds.NAME="CharacterString";var Lc,Qr=class extends Xr{constructor({value:e,valueDate:t,...n}={}){if(super(n),this.year=0,this.month=0,this.day=0,this.hour=0,this.minute=0,this.second=0,e){this.fromString(e),this.valueBlock.valueHexView=new Uint8Array(e.length);for(let s=0;s<e.length;s++)this.valueBlock.valueHexView[s]=e.charCodeAt(s)}t&&(this.fromDate(t),this.valueBlock.valueHexView=new Uint8Array(this.toBuffer())),this.idBlock.tagClass=1,this.idBlock.tagNumber=23}fromBuffer(e){this.fromString(String.fromCharCode.apply(null,M.BufferSourceConverter.toUint8Array(e)))}toBuffer(){let e=this.toString(),t=new ArrayBuffer(e.length),n=new Uint8Array(t);for(let s=0;s<e.length;s++)n[s]=e.charCodeAt(s);return t}fromDate(e){this.year=e.getUTCFullYear(),this.month=e.getUTCMonth()+1,this.day=e.getUTCDate(),this.hour=e.getUTCHours(),this.minute=e.getUTCMinutes(),this.second=e.getUTCSeconds()}toDate(){return new Date(Date.UTC(this.year,this.month-1,this.day,this.hour,this.minute,this.second))}fromString(e){let n=/(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})Z/ig.exec(e);if(n===null){this.error="Wrong input string for conversion";return}let 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(e="iso"){if(e==="iso"){let t=new Array(7);return t[0]=_e(this.year<2e3?this.year-1900:this.year-2e3,2),t[1]=_e(this.month,2),t[2]=_e(this.day,2),t[3]=_e(this.hour,2),t[4]=_e(this.minute,2),t[5]=_e(this.second,2),t[6]="Z",t.join("")}return super.toString(e)}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.toDate().toISOString()}`}toJSON(){return{...super.toJSON(),year:this.year,month:this.month,day:this.day,hour:this.hour,minute:this.minute,second:this.second}}};Lc=Qr;A.UTCTime=Lc;Qr.NAME="UTCTime";var Uc,ps=class extends Qr{constructor(e={}){var t;super(e),(t=this.millisecond)!==null&&t!==void 0||(this.millisecond=0),this.idBlock.tagClass=1,this.idBlock.tagNumber=24}fromDate(e){super.fromDate(e),this.millisecond=e.getUTCMilliseconds()}toDate(){return new Date(Date.UTC(this.year,this.month-1,this.day,this.hour,this.minute,this.second,this.millisecond))}fromString(e){let t=!1,n="",s="",o=0,i,a=0,c=0;if(e[e.length-1]==="Z")n=e.substring(0,e.length-1),t=!0;else{let l=new Number(e[e.length-1]);if(isNaN(l.valueOf()))throw new Error("Wrong input string for conversion");n=e}if(t){if(n.indexOf("+")!==-1)throw new Error("Wrong input string for conversion");if(n.indexOf("-")!==-1)throw new Error("Wrong input string for conversion")}else{let l=1,p=n.indexOf("+"),b="";if(p===-1&&(p=n.indexOf("-"),l=-1),p!==-1){if(b=n.substring(p+1),n=n.substring(0,p),b.length!==2&&b.length!==4)throw new Error("Wrong input string for conversion");let d=parseInt(b.substring(0,2),10);if(isNaN(d.valueOf()))throw new Error("Wrong input string for conversion");if(a=l*d,b.length===4){if(d=parseInt(b.substring(2,4),10),isNaN(d.valueOf()))throw new Error("Wrong input string for conversion");c=l*d}}}let f=n.indexOf(".");if(f===-1&&(f=n.indexOf(",")),f!==-1){let l=new Number(`0${n.substring(f)}`);if(isNaN(l.valueOf()))throw new Error("Wrong input string for conversion");o=l.valueOf(),s=n.substring(0,f)}else s=n;switch(!0){case s.length===8:if(i=/(\d{4})(\d{2})(\d{2})/ig,f!==-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,f!==-1){let l=60*o;this.minute=Math.floor(l),l=60*(l-this.minute),this.second=Math.floor(l),l=1e3*(l-this.second),this.millisecond=Math.floor(l)}break;case s.length===12:if(i=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})/ig,f!==-1){let l=60*o;this.second=Math.floor(l),l=1e3*(l-this.second),this.millisecond=Math.floor(l)}break;case s.length===14:if(i=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/ig,f!==-1){let l=1e3*o;this.millisecond=Math.floor(l)}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 l=1;l<u.length;l++)switch(l){case 1:this.year=parseInt(u[l],10);break;case 2:this.month=parseInt(u[l],10);break;case 3:this.day=parseInt(u[l],10);break;case 4:this.hour=parseInt(u[l],10)+a;break;case 5:this.minute=parseInt(u[l],10)+c;break;case 6:this.second=parseInt(u[l],10);break;default:throw new Error("Wrong input string for conversion")}if(t===!1){let l=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);this.year=l.getUTCFullYear(),this.month=l.getUTCMonth(),this.day=l.getUTCDay(),this.hour=l.getUTCHours(),this.minute=l.getUTCMinutes(),this.second=l.getUTCSeconds(),this.millisecond=l.getUTCMilliseconds()}}toString(e="iso"){if(e==="iso"){let t=[];return t.push(_e(this.year,4)),t.push(_e(this.month,2)),t.push(_e(this.day,2)),t.push(_e(this.hour,2)),t.push(_e(this.minute,2)),t.push(_e(this.second,2)),this.millisecond!==0&&(t.push("."),t.push(_e(this.millisecond,3))),t.push("Z"),t.join("")}return super.toString(e)}toJSON(){return{...super.toJSON(),millisecond:this.millisecond}}};Uc=ps;A.GeneralizedTime=Uc;ps.NAME="GeneralizedTime";var Pc,gs=class extends Bt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=31}};Pc=gs;A.DATE=Pc;gs.NAME="DATE";var Oc,ms=class extends Bt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=32}};Oc=ms;A.TimeOfDay=Oc;ms.NAME="TimeOfDay";var Vc,ys=class extends Bt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=33}};Vc=ys;A.DateTime=Vc;ys.NAME="DateTime";var Dc,bs=class extends Bt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=34}};Dc=bs;A.Duration=Dc;bs.NAME="Duration";var Mc,ws=class extends Bt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=14}};Mc=ws;A.TIME=Mc;ws.NAME="TIME";function ld(r){let{result:e}=Br(r),t=e.valueBlock.value;return{n:D(ot(t[1].toBigInt()),"base64url"),e:D(ot(t[2].toBigInt()),"base64url"),d:D(ot(t[3].toBigInt()),"base64url"),p:D(ot(t[4].toBigInt()),"base64url"),q:D(ot(t[5].toBigInt()),"base64url"),dp:D(ot(t[6].toBigInt()),"base64url"),dq:D(ot(t[7].toBigInt()),"base64url"),qi:D(ot(t[8].toBigInt()),"base64url"),kty:"RSA",alg:"RS256"}}function ud(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 C("JWK was missing components","ERR_INVALID_PARAMETERS");let t=new ge({value:[new ie({value:0}),ie.fromBigInt(it(V(r.n,"base64url"))),ie.fromBigInt(it(V(r.e,"base64url"))),ie.fromBigInt(it(V(r.d,"base64url"))),ie.fromBigInt(it(V(r.p,"base64url"))),ie.fromBigInt(it(V(r.q,"base64url"))),ie.fromBigInt(it(V(r.dp,"base64url"))),ie.fromBigInt(it(V(r.dq,"base64url"))),ie.fromBigInt(it(V(r.qi,"base64url")))]}).toBER();return new Uint8Array(t,0,t.byteLength)}function fd(r){let{result:e}=Br(r),t=e.valueBlock.value[1].valueBlock.value[0].valueBlock.value;return{kty:"RSA",n:D(ot(t[0].toBigInt()),"base64url"),e:D(ot(t[1].toBigInt()),"base64url")}}function hd(r){if(r.n==null||r.e==null)throw new C("JWK was missing components","ERR_INVALID_PARAMETERS");let t=new ge({value:[new ge({value:[new We({value:"1.2.840.113549.1.1.1"}),new Vt]}),new vr({valueHex:new ge({value:[ie.fromBigInt(it(V(r.n,"base64url"))),ie.fromBigInt(it(V(r.e,"base64url")))]}).toBER()})]}).toBER();return new Uint8Array(t,0,t.byteLength)}function ot(r){let e=r.toString(16);e.length%2>0&&(e=`0${e}`);let t=e.length/2,n=new Uint8Array(t),s=0,o=0;for(;s<t;)n[s]=parseInt(e.slice(o,o+2),16),s+=1,o+=2;return n}function it(r){let e=[];return r.forEach(function(t){let n=t.toString(16);n.length%2>0&&(n=`0${n}`),e.push(n)}),BigInt("0x"+e.join(""))}var dd=16,ni=32,si=1e4;async function pd(r,e){let t=Ie.get(),s=new ge({value:[new ie({value:0}),new ge({value:[new We({value:"1.2.840.113549.1.1.1"}),new Vt]}),new Et({valueHex:r.marshal()})]}).toBER(),o=new Uint8Array(s,0,s.byteLength),i=Qt(dd),a=await Xo(Dr,e,i,{c:si,dkLen:ni}),c=Qt(16),f=await t.subtle.importKey("raw",a,"AES-CBC",!1,["encrypt"]),u=await t.subtle.encrypt({name:"AES-CBC",iv:c},f,o),l=new ge({value:[new Et({valueHex:i}),new ie({value:si}),new ie({value:ni}),new ge({value:[new We({value:"1.2.840.113549.2.11"}),new Vt]})]}),p=new ge({value:[new We({value:"1.2.840.113549.1.5.13"}),new ge({value:[new ge({value:[new We({value:"1.2.840.113549.1.5.12"}),l]}),new ge({value:[new We({value:"2.16.840.1.101.3.4.1.42"}),new Et({valueHex:c})]})]})]}),d=new ge({value:[p,new Et({valueHex:u})]}).toBER(),h=new Uint8Array(d,0,d.byteLength);return["-----BEGIN ENCRYPTED PRIVATE KEY-----",...D(h,"base64pad").split(/(.{64})/).filter(Boolean),"-----END ENCRYPTED PRIVATE KEY-----"].join(`
7
- `)}async function gd(r,e){let t=Ie.get(),n;if(r.includes("-----BEGIN ENCRYPTED PRIVATE KEY-----")){let s=V(r.replace("-----BEGIN ENCRYPTED PRIVATE KEY-----","").replace("-----END ENCRYPTED PRIVATE KEY-----","").replace(/\n/g,"").trim(),"base64pad"),{result:o}=Br(s),{iv:i,salt:a,iterations:c,keySize:f,cipherText:u}=md(o),l=await Xo(Dr,e,a,{c,dkLen:f}),p=await t.subtle.importKey("raw",l,"AES-CBC",!1,["decrypt"]),b=en(await t.subtle.decrypt({name:"AES-CBC",iv:i},p,u)),{result:d}=Br(b);n=Hc(d)}else if(r.includes("-----BEGIN PRIVATE KEY-----")){let s=V(r.replace("-----BEGIN PRIVATE KEY-----","").replace("-----END PRIVATE KEY-----","").replace(/\n/g,"").trim(),"base64pad"),{result:o}=Br(s);n=Hc(o)}else throw new C("Could not parse private key from PEM data","ERR_INVALID_PARAMETERS");return oi(n)}function md(r){let e=r.valueBlock.value[0];if(e.valueBlock.value[0].toString()!=="OBJECT IDENTIFIER : 1.2.840.113549.1.5.13")throw new C("Only pkcs5PBES2 encrypted private keys are supported","ERR_INVALID_PARAMS");let n=e.valueBlock.value[1].valueBlock.value[0];if(n.valueBlock.value[0].toString()!=="OBJECT IDENTIFIER : 1.2.840.113549.1.5.12")throw new C("Only pkcs5PBKDF2 key derivation functions are supported","ERR_INVALID_PARAMS");let o=n.valueBlock.value[1],i=en(o.valueBlock.value[0].getValue()),a=si,c=ni;if(o.valueBlock.value.length===3)a=Number(o.valueBlock.value[1].toBigInt()),c=Number(o.valueBlock.value[2].toBigInt());else if(o.valueBlock.value.length===2)throw new C("Could not derive key size and iterations from PEM file - please use @libp2p/rsa to re-import your key","ERR_INVALID_PARAMS");let f=e.valueBlock.value[1].valueBlock.value[1],u=f.valueBlock.value[0].toString();if(u!=="OBJECT IDENTIFIER : 1.2.840.113549.3.7"){if(u!=="OBJECT IDENTIFIER : 1.3.14.3.2.7"){if(u!=="OBJECT IDENTIFIER : 2.16.840.1.101.3.4.1.2"){if(u!=="OBJECT IDENTIFIER : 2.16.840.1.101.3.4.1.22"){if(u!=="OBJECT IDENTIFIER : 2.16.840.1.101.3.4.1.42")throw new C("Only AES-CBC encryption schemes are supported","ERR_INVALID_PARAMS")}}}}let l=en(f.valueBlock.value[1].getValue());return{cipherText:en(r.valueBlock.value[1].getValue()),salt:i,iterations:a,keySize:c,iv:l}}function Hc(r){return en(r.valueBlock.value[2].getValue())}function en(r){return new Uint8Array(r,0,r.byteLength)}async function Fc(r){let e=await Ie.get().subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:r,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-256"}},!0,["sign","verify"]),t=await $c(e);return{privateKey:t[0],publicKey:t[1]}}async function ii(r){let t=[await Ie.get().subtle.importKey("jwk",r,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["sign"]),await yd(r)],n=await $c({privateKey:t[0],publicKey:t[1]});return{privateKey:n[0],publicKey:n[1]}}async function Kc(r,e){let t=await Ie.get().subtle.importKey("jwk",r,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["sign"]),n=await Ie.get().subtle.sign({name:"RSASSA-PKCS1-v1_5"},t,e instanceof Uint8Array?e:e.subarray());return new Uint8Array(n,0,n.byteLength)}async function qc(r,e,t){let n=await Ie.get().subtle.importKey("jwk",r,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["verify"]);return Ie.get().subtle.verify({name:"RSASSA-PKCS1-v1_5"},n,e,t instanceof Uint8Array?t:t.subarray())}async function $c(r){if(r.privateKey==null||r.publicKey==null)throw new C("Private and public key are required","ERR_INVALID_PARAMETERS");return Promise.all([Ie.get().subtle.exportKey("jwk",r.privateKey),Ie.get().subtle.exportKey("jwk",r.publicKey)])}async function yd(r){return Ie.get().subtle.importKey("jwk",{kty:r.kty,n:r.n,e:r.e},{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["verify"])}function vs(r){if(r.kty!=="RSA")throw new C("invalid key type","ERR_INVALID_KEY_TYPE");if(r.n==null)throw new C("invalid key modulus","ERR_INVALID_KEY_MODULUS");return V(r.n,"base64url").length*8}var rn=8192,tn=class{_key;constructor(e){this._key=e}verify(e,t){return qc(this._key,t,e)}marshal(){return Dt.jwkToPkix(this._key)}get bytes(){return rt.encode({Type:X.RSA,Data:this.marshal()}).subarray()}equals(e){return pe(this.bytes,e.bytes)}hash(){let e=ye.digest(this.bytes);return Pe(e)?e.then(({bytes:t})=>t):e.bytes}},Ar=class{_key;_publicKey;constructor(e,t){this._key=e,this._publicKey=t}genSecret(){return Qt(16)}sign(e){return Kc(this._key,e)}get public(){if(this._publicKey==null)throw new C("public key not provided","ERR_PUBKEY_NOT_PROVIDED");return new tn(this._publicKey)}marshal(){return Dt.jwkToPkcs1(this._key)}get bytes(){return nt.encode({Type:X.RSA,Data:this.marshal()}).subarray()}equals(e){return pe(this.bytes,e.bytes)}hash(){let e=ye.digest(this.bytes);return Pe(e)?e.then(({bytes:t})=>t):e.bytes}async id(){let e=await this.public.hash();return D(e,"base58btc")}async export(e,t="pkcs-8"){if(t==="pkcs-8")return Dt.exportToPem(this,e);if(t==="libp2p-key")return yr(this.bytes,e);throw new C(`export format '${t}' is not supported`,"ERR_INVALID_EXPORT_FORMAT")}};async function oi(r){let e=Dt.pkcs1ToJwk(r);if(vs(e)>rn)throw new C("key size is too large","ERR_KEY_SIZE_TOO_LARGE");let t=await ii(e);return new Ar(t.privateKey,t.publicKey)}function wd(r){let e=Dt.pkixToJwk(r);if(vs(e)>rn)throw new C("key size is too large","ERR_KEY_SIZE_TOO_LARGE");return new tn(e)}async function xd(r){if(vs(r)>rn)throw new C("key size is too large","ERR_KEY_SIZE_TOO_LARGE");let e=await ii(r);return new Ar(e.privateKey,e.publicKey)}async function vd(r){if(r>rn)throw new C("key size is too large","ERR_KEY_SIZE_TOO_LARGE");let e=await Fc(r);return new Ar(e.privateKey,e.publicKey)}var hi={};de(hi,{Secp256k1PrivateKey:()=>sn,Secp256k1PublicKey:()=>nn,generateKeyPair:()=>Ud,unmarshalSecp256k1PrivateKey:()=>Cd,unmarshalSecp256k1PublicKey:()=>Ld});var Ed=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]),Mt=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Ht=new Uint32Array(64),ci=class extends dr{constructor(){super(64,32,8,!1),this.A=Mt[0]|0,this.B=Mt[1]|0,this.C=Mt[2]|0,this.D=Mt[3]|0,this.E=Mt[4]|0,this.F=Mt[5]|0,this.G=Mt[6]|0,this.H=Mt[7]|0}get(){let{A:e,B:t,C:n,D:s,E:o,F:i,G:a,H:c}=this;return[e,t,n,s,o,i,a,c]}set(e,t,n,s,o,i,a,c){this.A=e|0,this.B=t|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(e,t){for(let l=0;l<16;l++,t+=4)Ht[l]=e.getUint32(t,!1);for(let l=16;l<64;l++){let p=Ht[l-15],b=Ht[l-2],d=Fe(p,7)^Fe(p,18)^p>>>3,h=Fe(b,17)^Fe(b,19)^b>>>10;Ht[l]=h+Ht[l-7]+d+Ht[l-16]|0}let{A:n,B:s,C:o,D:i,E:a,F:c,G:f,H:u}=this;for(let l=0;l<64;l++){let p=Fe(a,6)^Fe(a,11)^Fe(a,25),b=u+p+Ba(a,c,f)+Ed[l]+Ht[l]|0,h=(Fe(n,2)^Fe(n,13)^Fe(n,22))+Aa(n,s,o)|0;u=f,f=c,c=a,a=i+b|0,i=o,o=s,s=n,n=b+h|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,f=f+this.G|0,u=u+this.H|0,this.set(n,s,o,i,a,c,f,u)}roundClean(){Ht.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var zc=bn(()=>new ci);function Gc(r){r.lowS!==void 0&&Ke("lowS",r.lowS),r.prehash!==void 0&&Ke("prehash",r.prehash)}function Bd(r){let e=Fr(r);tt(e,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});let{endo:t,Fp:n,a:s}=e;if(t){if(!n.eql(s,n.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if(typeof t!="object"||typeof t.beta!="bigint"||typeof t.splitScalar!="function")throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...e})}var{bytesToNumberBE:Ad,hexToBytes:Id}=vn,tr={Err:class extends Error{constructor(e=""){super(e)}},_parseInt(r){let{Err:e}=tr;if(r.length<2||r[0]!==2)throw new e("Invalid signature integer tag");let t=r[1],n=r.subarray(2,t+2);if(!t||n.length!==t)throw new e("Invalid signature integer: wrong length");if(n[0]&128)throw new e("Invalid signature integer: negative");if(n[0]===0&&!(n[1]&128))throw new e("Invalid signature integer: unnecessary leading zero");return{d:Ad(n),l:r.subarray(t+2)}},toSig(r){let{Err:e}=tr,t=typeof r=="string"?Id(r):r;pr(t);let n=t.length;if(n<2||t[0]!=48)throw new e("Invalid signature tag");if(t[1]!==n-2)throw new e("Invalid signature: incorrect length");let{d:s,l:o}=tr._parseInt(t.subarray(2)),{d:i,l:a}=tr._parseInt(o);if(a.length)throw new e("Invalid signature: left bytes after parsing");return{r:s,s:i}},hexFromSig(r){let e=f=>Number.parseInt(f[0],16)&8?"00"+f:f,t=f=>{let u=f.toString(16);return u.length&1?`0${u}`:u},n=e(t(r.s)),s=e(t(r.r)),o=n.length/2,i=s.length/2,a=t(o),c=t(i);return`30${t(i+o+4)}02${c}${s}02${a}${n}`}},Ft=BigInt(0),me=BigInt(1),ty=BigInt(2),jc=BigInt(3),ry=BigInt(4);function Sd(r){let e=Bd(r),{Fp:t}=e,n=e.toBytes||((d,h,y)=>{let v=h.toAffine();return yt(Uint8Array.from([4]),t.toBytes(v.x),t.toBytes(v.y))}),s=e.fromBytes||(d=>{let h=d.subarray(1),y=t.fromBytes(h.subarray(0,t.BYTES)),v=t.fromBytes(h.subarray(t.BYTES,2*t.BYTES));return{x:y,y:v}});function o(d){let{a:h,b:y}=e,v=t.sqr(d),w=t.mul(v,d);return t.add(t.add(w,t.mul(d,h)),y)}if(!t.eql(t.sqr(e.Gy),o(e.Gx)))throw new Error("bad generator point: equation left != right");function i(d){return Mr(d,me,e.n)}function a(d){let{allowedPrivateKeyLengths:h,nByteLength:y,wrapPrivateKey:v,n:w}=e;if(h&&typeof d!="bigint"){if(_t(d)&&(d=gt(d)),typeof d!="string"||!h.includes(d.length))throw new Error("Invalid key");d=d.padStart(y*2,"0")}let x;try{x=typeof d=="bigint"?d:mt(re("private key",d,y))}catch{throw new Error(`private key must be ${y} bytes, hex or bigint, not ${typeof d}`)}return v&&(x=W(x,w)),Re("private key",x,me,w),x}function c(d){if(!(d instanceof l))throw new Error("ProjectivePoint expected")}let f=Wt((d,h)=>{let{px:y,py:v,pz:w}=d;if(t.eql(w,t.ONE))return{x:y,y:v};let x=d.is0();h==null&&(h=x?t.ONE:t.inv(w));let T=t.mul(y,h),S=t.mul(v,h),I=t.mul(w,h);if(x)return{x:t.ZERO,y:t.ZERO};if(!t.eql(I,t.ONE))throw new Error("invZ was invalid");return{x:T,y:S}}),u=Wt(d=>{if(d.is0()){if(e.allowInfinityPoint&&!t.is0(d.py))return;throw new Error("bad point: ZERO")}let{x:h,y}=d.toAffine();if(!t.isValid(h)||!t.isValid(y))throw new Error("bad point: x or y not FE");let v=t.sqr(y),w=o(h);if(!t.eql(v,w))throw new Error("bad point: equation left != right");if(!d.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class l{constructor(h,y,v){if(this.px=h,this.py=y,this.pz=v,h==null||!t.isValid(h))throw new Error("x required");if(y==null||!t.isValid(y))throw new Error("y required");if(v==null||!t.isValid(v))throw new Error("z required");Object.freeze(this)}static fromAffine(h){let{x:y,y:v}=h||{};if(!h||!t.isValid(y)||!t.isValid(v))throw new Error("invalid affine point");if(h instanceof l)throw new Error("projective point not allowed");let w=x=>t.eql(x,t.ZERO);return w(y)&&w(v)?l.ZERO:new l(y,v,t.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(h){let y=t.invertBatch(h.map(v=>v.pz));return h.map((v,w)=>v.toAffine(y[w])).map(l.fromAffine)}static fromHex(h){let y=l.fromAffine(s(re("pointHex",h)));return y.assertValidity(),y}static fromPrivateKey(h){return l.BASE.multiply(a(h))}_setWindowSize(h){b.setWindowSize(this,h)}assertValidity(){u(this)}hasEvenY(){let{y:h}=this.toAffine();if(t.isOdd)return!t.isOdd(h);throw new Error("Field doesn't support isOdd")}equals(h){c(h);let{px:y,py:v,pz:w}=this,{px:x,py:T,pz:S}=h,I=t.eql(t.mul(y,S),t.mul(x,w)),R=t.eql(t.mul(v,S),t.mul(T,w));return I&&R}negate(){return new l(this.px,t.neg(this.py),this.pz)}double(){let{a:h,b:y}=e,v=t.mul(y,jc),{px:w,py:x,pz:T}=this,S=t.ZERO,I=t.ZERO,R=t.ZERO,k=t.mul(w,w),j=t.mul(x,x),H=t.mul(T,T),F=t.mul(w,x);return F=t.add(F,F),R=t.mul(w,T),R=t.add(R,R),S=t.mul(h,R),I=t.mul(v,H),I=t.add(S,I),S=t.sub(j,I),I=t.add(j,I),I=t.mul(S,I),S=t.mul(F,S),R=t.mul(v,R),H=t.mul(h,H),F=t.sub(k,H),F=t.mul(h,F),F=t.add(F,R),R=t.add(k,k),k=t.add(R,k),k=t.add(k,H),k=t.mul(k,F),I=t.add(I,k),H=t.mul(x,T),H=t.add(H,H),k=t.mul(H,F),S=t.sub(S,k),R=t.mul(H,j),R=t.add(R,R),R=t.add(R,R),new l(S,I,R)}add(h){c(h);let{px:y,py:v,pz:w}=this,{px:x,py:T,pz:S}=h,I=t.ZERO,R=t.ZERO,k=t.ZERO,j=e.a,H=t.mul(e.b,jc),F=t.mul(y,x),oe=t.mul(v,T),ae=t.mul(w,S),N=t.add(y,v),m=t.add(x,T);N=t.mul(N,m),m=t.add(F,oe),N=t.sub(N,m),m=t.add(y,w);let g=t.add(x,S);return m=t.mul(m,g),g=t.add(F,ae),m=t.sub(m,g),g=t.add(v,w),I=t.add(T,S),g=t.mul(g,I),I=t.add(oe,ae),g=t.sub(g,I),k=t.mul(j,m),I=t.mul(H,ae),k=t.add(I,k),I=t.sub(oe,k),k=t.add(oe,k),R=t.mul(I,k),oe=t.add(F,F),oe=t.add(oe,F),ae=t.mul(j,ae),m=t.mul(H,m),oe=t.add(oe,ae),ae=t.sub(F,ae),ae=t.mul(j,ae),m=t.add(m,ae),F=t.mul(oe,m),R=t.add(R,F),F=t.mul(g,m),I=t.mul(N,I),I=t.sub(I,F),F=t.mul(N,oe),k=t.mul(g,k),k=t.add(k,F),new l(I,R,k)}subtract(h){return this.add(h.negate())}is0(){return this.equals(l.ZERO)}wNAF(h){return b.wNAFCached(this,h,l.normalizeZ)}multiplyUnsafe(h){Re("scalar",h,Ft,e.n);let y=l.ZERO;if(h===Ft)return y;if(h===me)return this;let{endo:v}=e;if(!v)return b.unsafeLadder(this,h);let{k1neg:w,k1:x,k2neg:T,k2:S}=v.splitScalar(h),I=y,R=y,k=this;for(;x>Ft||S>Ft;)x&me&&(I=I.add(k)),S&me&&(R=R.add(k)),k=k.double(),x>>=me,S>>=me;return w&&(I=I.negate()),T&&(R=R.negate()),R=new l(t.mul(R.px,v.beta),R.py,R.pz),I.add(R)}multiply(h){let{endo:y,n:v}=e;Re("scalar",h,me,v);let w,x;if(y){let{k1neg:T,k1:S,k2neg:I,k2:R}=y.splitScalar(h),{p:k,f:j}=this.wNAF(S),{p:H,f:F}=this.wNAF(R);k=b.constTimeNegate(T,k),H=b.constTimeNegate(I,H),H=new l(t.mul(H.px,y.beta),H.py,H.pz),w=k.add(H),x=j.add(F)}else{let{p:T,f:S}=this.wNAF(h);w=T,x=S}return l.normalizeZ([w,x])[0]}multiplyAndAddUnsafe(h,y,v){let w=l.BASE,x=(S,I)=>I===Ft||I===me||!S.equals(w)?S.multiplyUnsafe(I):S.multiply(I),T=x(this,y).add(x(h,v));return T.is0()?void 0:T}toAffine(h){return f(this,h)}isTorsionFree(){let{h,isTorsionFree:y}=e;if(h===me)return!0;if(y)return y(l,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h,clearCofactor:y}=e;return h===me?this:y?y(l,this):this.multiplyUnsafe(e.h)}toRawBytes(h=!0){return Ke("isCompressed",h),this.assertValidity(),n(l,this,h)}toHex(h=!0){return Ke("isCompressed",h),gt(this.toRawBytes(h))}}l.BASE=new l(e.Gx,e.Gy,t.ONE),l.ZERO=new l(t.ZERO,t.ONE,t.ZERO);let p=e.nBitLength,b=An(l,e.endo?Math.ceil(p/2):p);return{CURVE:e,ProjectivePoint:l,normPrivateKeyToScalar:a,weierstrassEquation:o,isWithinCurveOrder:i}}function kd(r){let e=Fr(r);return tt(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function Wc(r){let e=kd(r),{Fp:t,n}=e,s=t.BYTES+1,o=2*t.BYTES+1;function i(N){return W(N,n)}function a(N){return En(N,n)}let{ProjectivePoint:c,normPrivateKeyToScalar:f,weierstrassEquation:u,isWithinCurveOrder:l}=Sd({...e,toBytes(N,m,g){let E=m.toAffine(),B=t.toBytes(E.x),_=yt;return Ke("isCompressed",g),g?_(Uint8Array.from([m.hasEvenY()?2:3]),B):_(Uint8Array.from([4]),B,t.toBytes(E.y))},fromBytes(N){let m=N.length,g=N[0],E=N.subarray(1);if(m===s&&(g===2||g===3)){let B=mt(E);if(!Mr(B,me,t.ORDER))throw new Error("Point is not on curve");let _=u(B),L;try{L=t.sqrt(_)}catch(O){let q=O instanceof Error?": "+O.message:"";throw new Error("Point is not on curve"+q)}let U=(L&me)===me;return(g&1)===1!==U&&(L=t.neg(L)),{x:B,y:L}}else if(m===o&&g===4){let B=t.fromBytes(E.subarray(0,t.BYTES)),_=t.fromBytes(E.subarray(t.BYTES,2*t.BYTES));return{x:B,y:_}}else throw new Error(`Point of length ${m} was invalid. Expected ${s} compressed bytes or ${o} uncompressed bytes`)}}),p=N=>gt(Lt(N,e.nByteLength));function b(N){let m=n>>me;return N>m}function d(N){return b(N)?i(-N):N}let h=(N,m,g)=>mt(N.slice(m,g));class y{constructor(m,g,E){this.r=m,this.s=g,this.recovery=E,this.assertValidity()}static fromCompact(m){let g=e.nByteLength;return m=re("compactSignature",m,g*2),new y(h(m,0,g),h(m,g,2*g))}static fromDER(m){let{r:g,s:E}=tr.toSig(re("DER",m));return new y(g,E)}assertValidity(){Re("r",this.r,me,n),Re("s",this.s,me,n)}addRecoveryBit(m){return new y(this.r,this.s,m)}recoverPublicKey(m){let{r:g,s:E,recovery:B}=this,_=I(re("msgHash",m));if(B==null||![0,1,2,3].includes(B))throw new Error("recovery id invalid");let L=B===2||B===3?g+e.n:g;if(L>=t.ORDER)throw new Error("recovery id 2 or 3 invalid");let U=B&1?"03":"02",K=c.fromHex(U+p(L)),O=a(L),q=i(-_*O),Q=i(E*O),ee=c.BASE.multiplyAndAddUnsafe(K,q,Q);if(!ee)throw new Error("point at infinify");return ee.assertValidity(),ee}hasHighS(){return b(this.s)}normalizeS(){return this.hasHighS()?new y(this.r,i(-this.s),this.recovery):this}toDERRawBytes(){return Gt(this.toDERHex())}toDERHex(){return tr.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Gt(this.toCompactHex())}toCompactHex(){return p(this.r)+p(this.s)}}let v={isValidPrivateKey(N){try{return f(N),!0}catch{return!1}},normPrivateKeyToScalar:f,randomPrivateKey:()=>{let N=ko(e.n);return La(e.randomBytes(N),e.n)},precompute(N=8,m=c.BASE){return m._setWindowSize(N),m.multiply(BigInt(3)),m}};function w(N,m=!0){return c.fromPrivateKey(N).toRawBytes(m)}function x(N){let m=_t(N),g=typeof N=="string",E=(m||g)&&N.length;return m?E===s||E===o:g?E===2*s||E===2*o:N instanceof c}function T(N,m,g=!0){if(x(N))throw new Error("first arg must be private key");if(!x(m))throw new Error("second arg must be public key");return c.fromHex(m).multiply(f(N)).toRawBytes(g)}let S=e.bits2int||function(N){let m=mt(N),g=N.length*8-e.nBitLength;return g>0?m>>BigInt(g):m},I=e.bits2int_modN||function(N){return i(S(N))},R=Hr(e.nBitLength);function k(N){return Re(`num < 2^${e.nBitLength}`,N,Ft,R),Lt(N,e.nByteLength)}function j(N,m,g=H){if(["recovered","canonical"].some(fe=>fe in g))throw new Error("sign() legacy options not supported");let{hash:E,randomBytes:B}=e,{lowS:_,prehash:L,extraEntropy:U}=g;_==null&&(_=!0),N=re("msgHash",N),Gc(g),L&&(N=re("prehashed msgHash",E(N)));let K=I(N),O=f(m),q=[k(O),k(K)];if(U!=null&&U!==!1){let fe=U===!0?B(t.BYTES):U;q.push(re("extraEntropy",fe))}let Q=yt(...q),ee=K;function ke(fe){let ce=S(fe);if(!l(ce))return;let Me=a(ce),he=c.BASE.multiply(ce).toAffine(),He=i(he.x);if(He===Ft)return;let qt=i(Me*i(ee+He*O));if(qt===Ft)return;let Lr=(he.x===He?0:2)|Number(he.y&me),fn=qt;return _&&b(qt)&&(fn=d(qt),Lr^=1),new y(He,fn,Lr)}return{seed:Q,k2sig:ke}}let H={lowS:e.lowS,prehash:!1},F={lowS:e.lowS,prehash:!1};function oe(N,m,g=H){let{seed:E,k2sig:B}=j(N,m,g),_=e;return Bo(_.hash.outputLen,_.nByteLength,_.hmac)(E,B)}c.BASE._setWindowSize(8);function ae(N,m,g,E=F){let B=N;if(m=re("msgHash",m),g=re("publicKey",g),"strict"in E)throw new Error("options.strict was renamed to lowS");Gc(E);let{lowS:_,prehash:L}=E,U,K;try{if(typeof B=="string"||_t(B))try{U=y.fromDER(B)}catch(he){if(!(he instanceof tr.Err))throw he;U=y.fromCompact(B)}else if(typeof B=="object"&&typeof B.r=="bigint"&&typeof B.s=="bigint"){let{r:he,s:He}=B;U=new y(he,He)}else throw new Error("PARSE");K=c.fromHex(g)}catch(he){if(he.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(_&&U.hasHighS())return!1;L&&(m=e.hash(m));let{r:O,s:q}=U,Q=I(m),ee=a(q),ke=i(Q*ee),fe=i(O*ee),ce=c.BASE.multiplyAndAddUnsafe(K,ke,fe)?.toAffine();return ce?i(ce.x)===O:!1}return{CURVE:e,getPublicKey:w,getSharedSecret:T,sign:oe,verify:ae,ProjectivePoint:c,Signature:y,utils:v}}function Nd(r){return{hash:r,hmac:(e,...t)=>zr(r,e,mo(...t)),randomBytes:hr}}function Yc(r,e){let t=n=>Wc({...r,...Nd(n)});return Object.freeze({...t(e),create:t})}var Xc=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),Zc=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),Rd=BigInt(1),li=BigInt(2),Jc=(r,e)=>(r+e/li)/e;function Td(r){let e=Xc,t=BigInt(3),n=BigInt(6),s=BigInt(11),o=BigInt(22),i=BigInt(23),a=BigInt(44),c=BigInt(88),f=r*r*r%e,u=f*f*r%e,l=J(u,t,e)*u%e,p=J(l,t,e)*u%e,b=J(p,li,e)*f%e,d=J(b,s,e)*b%e,h=J(d,o,e)*d%e,y=J(h,a,e)*h%e,v=J(y,c,e)*y%e,w=J(v,a,e)*h%e,x=J(w,t,e)*u%e,T=J(x,i,e)*d%e,S=J(T,n,e)*f%e,I=J(S,li,e);if(!ui.eql(ui.sqr(I),r))throw new Error("Cannot find square root");return I}var ui=Bn(Xc,void 0,void 0,{sqrt:Td}),Ze=Yc({a:BigInt(0),b:BigInt(7),Fp:ui,n:Zc,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:r=>{let e=Zc,t=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-Rd*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),s=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),o=t,i=BigInt("0x100000000000000000000000000000000"),a=Jc(o*r,e),c=Jc(-n*r,e),f=W(r-a*t-c*s,e),u=W(-a*n-c*o,e),l=f>i,p=u>i;if(l&&(f=e-f),p&&(u=e-u),f>i||u>i)throw new Error("splitScalar: Endomorphism failed, k="+r);return{k1neg:l,k1:f,k2neg:p,k2:u}}}},zc),fy=BigInt(0);var hy=Ze.ProjectivePoint;function Qc(){return Ze.utils.randomPrivateKey()}function el(r,e){let t=ye.digest(e instanceof Uint8Array?e:e.subarray());if(Pe(t))return t.then(({digest:n})=>Ze.sign(n,r).toDERRawBytes()).catch(n=>{throw new C(String(n),"ERR_INVALID_INPUT")});try{return Ze.sign(t.digest,r).toDERRawBytes()}catch(n){throw new C(String(n),"ERR_INVALID_INPUT")}}function tl(r,e,t){let n=ye.digest(t instanceof Uint8Array?t:t.subarray());if(Pe(n))return n.then(({digest:s})=>Ze.verify(e,s,r)).catch(s=>{throw new C(String(s),"ERR_INVALID_INPUT")});try{return Ze.verify(e,n.digest,r)}catch(s){throw new C(String(s),"ERR_INVALID_INPUT")}}function rl(r){return Ze.ProjectivePoint.fromHex(r).toRawBytes(!0)}function nl(r){try{Ze.getPublicKey(r,!0)}catch(e){throw new C(String(e),"ERR_INVALID_PRIVATE_KEY")}}function fi(r){try{Ze.ProjectivePoint.fromHex(r)}catch(e){throw new C(String(e),"ERR_INVALID_PUBLIC_KEY")}}function sl(r){try{return Ze.getPublicKey(r,!0)}catch(e){throw new C(String(e),"ERR_INVALID_PRIVATE_KEY")}}var nn=class{_key;constructor(e){fi(e),this._key=e}verify(e,t){return tl(this._key,t,e)}marshal(){return rl(this._key)}get bytes(){return rt.encode({Type:X.Secp256k1,Data:this.marshal()}).subarray()}equals(e){return pe(this.bytes,e.bytes)}async hash(){let e=ye.digest(this.bytes),t;return Pe(e)?{bytes:t}=await e:t=e.bytes,t}},sn=class{_key;_publicKey;constructor(e,t){this._key=e,this._publicKey=t??sl(e),nl(this._key),fi(this._publicKey)}sign(e){return el(this._key,e)}get public(){return new nn(this._publicKey)}marshal(){return this._key}get bytes(){return nt.encode({Type:X.Secp256k1,Data:this.marshal()}).subarray()}equals(e){return pe(this.bytes,e.bytes)}hash(){let e=ye.digest(this.bytes);return Pe(e)?e.then(({bytes:t})=>t):e.bytes}async id(){let e=await this.public.hash();return D(e,"base58btc")}async export(e,t="libp2p-key"){if(t==="libp2p-key")return yr(this.bytes,e);throw new C(`export format '${t}' is not supported`,"ERR_INVALID_EXPORT_FORMAT")}};function Cd(r){return new sn(r)}function Ld(r){return new nn(r)}async function Ud(){let r=Qc();return new sn(r)}var rr={rsa:ai,ed25519:Jo,secp256k1:hi};function ol(r){let e=Object.keys(rr).join(" / ");return new C(`invalid or unsupported key type ${r}. Must be ${e}`,"ERR_UNSUPPORTED_KEY_TYPE")}function il(r){let e=rt.decode(r),t=e.Data??new Uint8Array;switch(e.Type){case X.RSA:return rr.rsa.unmarshalRsaPublicKey(t);case X.Ed25519:return rr.ed25519.unmarshalEd25519PublicKey(t);case X.Secp256k1:return rr.secp256k1.unmarshalSecp256k1PublicKey(t);default:throw ol(e.Type??"unknown")}}async function al(r){let e=nt.decode(r),t=e.Data??new Uint8Array;switch(e.Type){case X.RSA:return rr.rsa.unmarshalRsaPrivateKey(t);case X.Ed25519:return rr.ed25519.unmarshalEd25519PrivateKey(t);case X.Secp256k1:return rr.secp256k1.unmarshalSecp256k1PrivateKey(t);default:throw ol(e.Type??"RSA")}}var ll=Symbol.for("nodejs.util.inspect.custom"),cl=Object.values(kt).map(r=>r.decoder).reduce((r,e)=>r.or(e),kt.identity.decoder),ul=114,gi=36,mi=37,on=class{type;multihash;privateKey;publicKey;string;constructor(e){this.type=e.type,this.multihash=e.multihash,this.privateKey=e.privateKey,Object.defineProperty(this,"string",{enumerable:!1,writable:!0})}get[Symbol.toStringTag](){return`PeerId(${this.toString()})`}[zs]=!0;toString(){return this.string==null&&(this.string=ne.encode(this.multihash.bytes).slice(1)),this.string}toCID(){return Ue.createV1(ul,this.multihash)}toBytes(){return this.multihash.bytes}toJSON(){return this.toString()}equals(e){if(e==null)return!1;if(e instanceof Uint8Array)return pe(this.multihash.bytes,e);if(typeof e=="string")return Pd(e).equals(this);if(e?.multihash?.bytes!=null)return pe(this.multihash.bytes,e.multihash.bytes);throw new Error("not valid Id")}[ll](){return`PeerId(${this.toString()})`}},Ir=class extends on{type="RSA";publicKey;constructor(e){super({...e,type:"RSA"}),this.publicKey=e.publicKey}},Sr=class extends on{type="Ed25519";publicKey;constructor(e){super({...e,type:"Ed25519"}),this.publicKey=e.multihash.digest}},kr=class extends on{type="secp256k1";publicKey;constructor(e){super({...e,type:"secp256k1"}),this.publicKey=e.multihash.digest}},di=2336,pi=class{type="url";multihash;privateKey;publicKey;url;constructor(e){this.url=e.toString(),this.multihash=ft.digest(V(this.url))}[ll](){return`PeerId(${this.url})`}[zs]=!0;toString(){return this.toCID().toString()}toCID(){return Ue.createV1(di,this.multihash)}toBytes(){return this.toCID().bytes}equals(e){return e==null?!1:(e instanceof Uint8Array&&(e=D(e)),e.toString()===this.toString())}};function Pd(r,e){if(e=e??cl,r.charAt(0)==="1"||r.charAt(0)==="Q"){let t=$t(ne.decode(`z${r}`));return r.startsWith("12D")?new Sr({multihash:t}):r.startsWith("16U")?new kr({multihash:t}):new Ir({multihash:t})}return yi(cl.decode(r))}function yi(r){try{let e=$t(r);if(e.code===ft.code){if(e.digest.length===gi)return new Sr({multihash:e});if(e.digest.length===mi)return new kr({multihash:e})}if(e.code===ye.code)return new Ir({multihash:e})}catch{return Od(Ue.decode(r))}throw new Error("Supplied PeerID CID is invalid")}function Od(r){if(r?.multihash==null||r.version==null||r.version===1&&r.code!==ul&&r.code!==di)throw new Error("Supplied PeerID CID is invalid");if(r.code===di){let t=D(r.multihash.digest);return new pi(new URL(t))}let e=r.multihash;if(e.code===ye.code)return new Ir({multihash:r.multihash});if(e.code===ft.code){if(e.digest.length===gi)return new Sr({multihash:r.multihash});if(e.digest.length===mi)return new kr({multihash:r.multihash})}throw new Error("Supplied PeerID CID is invalid")}async function Nr(r,e){return r.length===gi?new Sr({multihash:et(ft.code,r),privateKey:e}):r.length===mi?new kr({multihash:et(ft.code,r),privateKey:e}):new Ir({multihash:await ye.digest(r),publicKey:r,privateKey:e})}var hl=Symbol.for("@achingbrain/uint8arraylist");function fl(r,e){if(e==null||e<0)throw new RangeError("index is out of bounds");let t=0;for(let n of r){let s=t+n.byteLength;if(e<s)return{buf:n,index:e-t};t=s}throw new RangeError("index is out of bounds")}function Es(r){return!!r?.[hl]}var Je=class r{bufs;length;[hl]=!0;constructor(...e){this.bufs=[],this.length=0,e.length>0&&this.appendAll(e)}*[Symbol.iterator](){yield*this.bufs}get byteLength(){return this.length}append(...e){this.appendAll(e)}appendAll(e){let t=0;for(let n of e)if(n instanceof Uint8Array)t+=n.byteLength,this.bufs.push(n);else if(Es(n))t+=n.byteLength,this.bufs.push(...n.bufs);else throw new Error("Could not append value, must be an Uint8Array or a Uint8ArrayList");this.length+=t}prepend(...e){this.prependAll(e)}prependAll(e){let t=0;for(let n of e.reverse())if(n instanceof Uint8Array)t+=n.byteLength,this.bufs.unshift(n);else if(Es(n))t+=n.byteLength,this.bufs.unshift(...n.bufs);else throw new Error("Could not prepend value, must be an Uint8Array or a Uint8ArrayList");this.length+=t}get(e){let t=fl(this.bufs,e);return t.buf[t.index]}set(e,t){let n=fl(this.bufs,e);n.buf[n.index]=t}write(e,t=0){if(e instanceof Uint8Array)for(let n=0;n<e.length;n++)this.set(t+n,e[n]);else if(Es(e))for(let n=0;n<e.length;n++)this.set(t+n,e.get(n));else throw new Error("Could not write value, must be an Uint8Array or a Uint8ArrayList")}consume(e){if(e=Math.trunc(e),!(Number.isNaN(e)||e<=0)){if(e===this.byteLength){this.bufs=[],this.length=0;return}for(;this.bufs.length>0;)if(e>=this.bufs[0].byteLength)e-=this.bufs[0].byteLength,this.length-=this.bufs[0].byteLength,this.bufs.shift();else{this.bufs[0]=this.bufs[0].subarray(e),this.length-=e;break}}}slice(e,t){let{bufs:n,length:s}=this._subList(e,t);return Ae(n,s)}subarray(e,t){let{bufs:n,length:s}=this._subList(e,t);return n.length===1?n[0]:Ae(n,s)}sublist(e,t){let{bufs:n,length:s}=this._subList(e,t),o=new r;return o.length=s,o.bufs=[...n],o}_subList(e,t){if(e=e??0,t=t??this.length,e<0&&(e=this.length+e),t<0&&(t=this.length+t),e<0||t>this.length)throw new RangeError("index is out of bounds");if(e===t)return{bufs:[],length:0};if(e===0&&t===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,e>=c)continue;let f=e>=a&&e<c,u=t>a&&t<=c;if(f&&u){if(e===a&&t===c){n.push(i);break}let l=e-a;n.push(i.subarray(l,l+(t-e)));break}if(f){if(e===0){n.push(i);continue}n.push(i.subarray(e-a));continue}if(u){if(t===c){n.push(i);break}n.push(i.subarray(0,t-a));break}n.push(i)}return{bufs:n,length:t-e}}indexOf(e,t=0){if(!Es(e)&&!(e instanceof Uint8Array))throw new TypeError('The "value" argument must be a Uint8ArrayList or Uint8Array');let n=e instanceof Uint8Array?e:e.subarray();if(t=Number(t??0),isNaN(t)&&(t=0),t<0&&(t=this.length+t),t<0&&(t=0),e.length===0)return t>this.length?this.length:t;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 l=0;l<o;l++)i[l]=-1;for(let l=0;l<s;l++)i[n[l]]=l;let a=i,c=this.byteLength-n.byteLength,f=n.byteLength-1,u;for(let l=t;l<=c;l+=u){u=0;for(let p=f;p>=0;p--){let b=this.get(l+p);if(n[p]!==b){u=Math.max(1,p-a[b]);break}}if(u===0)return l}return-1}getInt8(e){let t=this.subarray(e,e+1);return new DataView(t.buffer,t.byteOffset,t.byteLength).getInt8(0)}setInt8(e,t){let n=Ne(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setInt8(0,t),this.write(n,e)}getInt16(e,t){let n=this.subarray(e,e+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt16(0,t)}setInt16(e,t,n){let s=ht(2);new DataView(s.buffer,s.byteOffset,s.byteLength).setInt16(0,t,n),this.write(s,e)}getInt32(e,t){let n=this.subarray(e,e+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt32(0,t)}setInt32(e,t,n){let s=ht(4);new DataView(s.buffer,s.byteOffset,s.byteLength).setInt32(0,t,n),this.write(s,e)}getBigInt64(e,t){let n=this.subarray(e,e+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigInt64(0,t)}setBigInt64(e,t,n){let s=ht(8);new DataView(s.buffer,s.byteOffset,s.byteLength).setBigInt64(0,t,n),this.write(s,e)}getUint8(e){let t=this.subarray(e,e+1);return new DataView(t.buffer,t.byteOffset,t.byteLength).getUint8(0)}setUint8(e,t){let n=Ne(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setUint8(0,t),this.write(n,e)}getUint16(e,t){let n=this.subarray(e,e+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint16(0,t)}setUint16(e,t,n){let s=ht(2);new DataView(s.buffer,s.byteOffset,s.byteLength).setUint16(0,t,n),this.write(s,e)}getUint32(e,t){let n=this.subarray(e,e+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint32(0,t)}setUint32(e,t,n){let s=ht(4);new DataView(s.buffer,s.byteOffset,s.byteLength).setUint32(0,t,n),this.write(s,e)}getBigUint64(e,t){let n=this.subarray(e,e+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigUint64(0,t)}setBigUint64(e,t,n){let s=ht(8);new DataView(s.buffer,s.byteOffset,s.byteLength).setBigUint64(0,t,n),this.write(s,e)}getFloat32(e,t){let n=this.subarray(e,e+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat32(0,t)}setFloat32(e,t,n){let s=ht(4);new DataView(s.buffer,s.byteOffset,s.byteLength).setFloat32(0,t,n),this.write(s,e)}getFloat64(e,t){let n=this.subarray(e,e+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat64(0,t)}setFloat64(e,t,n){let s=ht(8);new DataView(s.buffer,s.byteOffset,s.byteLength).setFloat64(0,t,n),this.write(s,e)}equals(e){if(e==null||!(e instanceof r)||e.bufs.length!==this.bufs.length)return!1;for(let t=0;t<this.bufs.length;t++)if(!pe(this.bufs[t],e.bufs[t]))return!1;return!0}static fromUint8Arrays(e,t){let n=new r;return n.bufs=e,t==null&&(t=e.reduce((s,o)=>s+o.byteLength,0)),n.length=t,n}};var dl={ERR_SIGNATURE_NOT_VALID:"ERR_SIGNATURE_NOT_VALID"};var an;(function(r){let e;r.codec=()=>(e==null&&(e=je((t,n,s={})=>{s.lengthDelimited!==!1&&n.fork(),t.publicKey!=null&&t.publicKey.byteLength>0&&(n.uint32(10),n.bytes(t.publicKey)),t.payloadType!=null&&t.payloadType.byteLength>0&&(n.uint32(18),n.bytes(t.payloadType)),t.payload!=null&&t.payload.byteLength>0&&(n.uint32(26),n.bytes(t.payload)),t.signature!=null&&t.signature.byteLength>0&&(n.uint32(42),n.bytes(t.signature)),s.lengthDelimited!==!1&&n.ldelim()},(t,n)=>{let s={publicKey:new Uint8Array(0),payloadType:new Uint8Array(0),payload:new Uint8Array(0),signature:new Uint8Array(0)},o=n==null?t.len:t.pos+n;for(;t.pos<o;){let i=t.uint32();switch(i>>>3){case 1:s.publicKey=t.bytes();break;case 2:s.payloadType=t.bytes();break;case 3:s.payload=t.bytes();break;case 5:s.signature=t.bytes();break;default:t.skipType(i&7);break}}return s})),e),r.encode=t=>Ge(t,r.codec()),r.decode=t=>ze(t,r.codec())})(an||(an={}));var at=class r{static createFromProtobuf=async e=>{let t=an.decode(e),n=await Nr(t.publicKey);return new r({peerId:n,payloadType:t.payloadType,payload:t.payload,signature:t.signature})};static seal=async(e,t)=>{if(t.privateKey==null)throw new Error("Missing private key");let n=e.domain,s=e.codec,o=e.marshal(),i=pl(n,s,o),c=await(await al(t.privateKey)).sign(i.subarray());return new r({peerId:t,payloadType:s,payload:o,signature:c})};static openAndCertify=async(e,t)=>{let n=await r.createFromProtobuf(e);if(!await n.validate(t))throw new C("envelope signature is not valid for the given domain",dl.ERR_SIGNATURE_NOT_VALID);return n};peerId;payloadType;payload;signature;marshaled;constructor(e){let{peerId:t,payloadType:n,payload:s,signature:o}=e;this.peerId=t,this.payloadType=n,this.payload=s,this.signature=o}marshal(){if(this.peerId.publicKey==null)throw new Error("Missing public key");return this.marshaled==null&&(this.marshaled=an.encode({publicKey:this.peerId.publicKey,payloadType:this.payloadType,payload:this.payload.subarray(),signature:this.signature})),this.marshaled}equals(e){return pe(this.marshal(),e.marshal())}async validate(e){let t=pl(e,this.payloadType,this.payload);if(this.peerId.publicKey==null)throw new Error("Missing public key");return il(this.peerId.publicKey).verify(t.subarray(),this.signature)}},pl=(r,e,t)=>{let n=V(r),s=Oe(n.byteLength),o=Oe(e.length),i=Oe(t.length);return new Je(s,n,o,e,i,t)};function gl(r,e){let t=(n,s)=>n.toString().localeCompare(s.toString());return r.length!==e.length?!1:(e.sort(t),r.sort(t).every((n,s)=>e[s].equals(n)))}var Bs=class{index=0;input="";new(e){return this.index=0,this.input=e,this}readAtomically(e){let t=this.index,n=e();return n===void 0&&(this.index=t),n}parseWith(e){let t=e();if(this.index===this.input.length)return t}peekChar(){if(!(this.index>=this.input.length))return this.input[this.index]}readChar(){if(!(this.index>=this.input.length))return this.input[this.index++]}readGivenChar(e){return this.readAtomically(()=>{let t=this.readChar();if(t===e)return t})}readSeparator(e,t,n){return this.readAtomically(()=>{if(!(t>0&&this.readGivenChar(e)===void 0))return n()})}readNumber(e,t,n,s){return this.readAtomically(()=>{let o=0,i=0,a=this.peekChar();if(a===void 0)return;let c=a==="0",f=2**(8*s)-1;for(;;){let u=this.readAtomically(()=>{let l=this.readChar();if(l===void 0)return;let p=Number.parseInt(l,e);if(!Number.isNaN(p))return p});if(u===void 0)break;if(o*=e,o+=u,o>f||(i+=1,t!==void 0&&i>t))return}if(i!==0)return!n&&c&&i>1?void 0:o})}readIPv4Addr(){return this.readAtomically(()=>{let e=new Uint8Array(4);for(let t=0;t<e.length;t++){let n=this.readSeparator(".",t,()=>this.readNumber(10,3,!1,1));if(n===void 0)return;e[t]=n}return e})}readIPv6Addr(){let e=t=>{for(let n=0;n<t.length/2;n++){let s=n*2;if(n<t.length-3){let i=this.readSeparator(":",n,()=>this.readIPv4Addr());if(i!==void 0)return t[s]=i[0],t[s+1]=i[1],t[s+2]=i[2],t[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];t[s]=o>>8,t[s+1]=o&255}return[t.length,!1]};return this.readAtomically(()=>{let t=new Uint8Array(16),[n,s]=e(t);if(n===16)return t;if(s||this.readGivenChar(":")===void 0||this.readGivenChar(":")===void 0)return;let o=new Uint8Array(14),i=16-(n+2),[a]=e(o.subarray(0,i));return t.set(o.subarray(0,a),16-a),t})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var ml=45,Vd=15,Rr=new Bs;function bi(r){if(!(r.length>Vd))return Rr.new(r).parseWith(()=>Rr.readIPv4Addr())}function wi(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>ml))return Rr.new(r).parseWith(()=>Rr.readIPv6Addr())}function As(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>ml))return Rr.new(r).parseWith(()=>Rr.readIPAddr())}var cb=parseInt("0xFFFF",16),lb=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);function Is(r){return!!bi(r)}function Ss(r){return!!wi(r)}function ks(r){return!!As(r)}var wl=Is,Kd=Ss,xi=function(r){let e=0;if(r=r.toString().trim(),wl(r)){let t=new Uint8Array(e+4);return r.split(/\./g).forEach(n=>{t[e++]=parseInt(n,10)&255}),t}if(Kd(r)){let t=r.split(":",8),n;for(n=0;n<t.length;n++){let o=wl(t[n]),i;o&&(i=xi(t[n]),t[n]=D(i.slice(0,2),"base16")),i!=null&&++n<8&&t.splice(n,0,D(i.slice(2,4),"base16"))}if(t[0]==="")for(;t.length<8;)t.unshift("0");else if(t[t.length-1]==="")for(;t.length<8;)t.push("0");else if(t.length<8){for(n=0;n<t.length&&t[n]!=="";n++);let o=[n,1];for(n=9-t.length;n>0;n--)o.push("0");t.splice.apply(t,o)}let s=new Uint8Array(e+16);for(n=0;n<t.length;n++){let o=parseInt(t[n],16);s[e++]=o>>8&255,s[e++]=o&255}return s}throw new Error("invalid ip address")},xl=function(r,e=0,t){e=~~e,t=t??r.length-e;let n=new DataView(r.buffer);if(t===4){let s=[];for(let o=0;o<t;o++)s.push(r[e+o]);return s.join(".")}if(t===16){let s=[];for(let o=0;o<t;o+=2)s.push(n.getUint16(e+o).toString(16));return s.join(":").replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}return""};var Tr={},vi={},$d=[[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"]];$d.forEach(r=>{let e=zd(...r);vi[e.code]=e,Tr[e.name]=e});function zd(r,e,t,n,s){return{code:r,size:e,name:t,resolvable:!!n,path:!!s}}function $(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(Tr[r]!=null)return Tr[r];throw new Error(`no protocol with name: ${r}`)}throw new Error(`invalid protocol id type: ${typeof r}`)}var Gb=$("ip4"),jb=$("ip6"),Wb=$("ipcidr");function Ii(r,e){switch($(r).code){case 4:case 41:return jd(e);case 42:return Ai(e);case 6:case 273:case 33:case 132:return Bl(e).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return Ai(e);case 421:return Jd(e);case 444:return El(e);case 445:return El(e);case 466:return Zd(e);case 481:return globalThis.encodeURIComponent(Ai(e));default:return D(e,"base16")}}function Si(r,e){switch($(r).code){case 4:return vl(e);case 41:return vl(e);case 42:return Bi(e);case 6:case 273:case 33:case 132:return ki(parseInt(e,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return Bi(e);case 421:return Wd(e);case 444:return Xd(e);case 445:return Qd(e);case 466:return Yd(e);case 481:return Bi(globalThis.decodeURIComponent(e));default:return V(e,"base16")}}var Ei=Object.values(kt).map(r=>r.decoder),Gd=function(){let r=Ei[0].or(Ei[1]);return Ei.slice(2).forEach(e=>r=r.or(e)),r}();function vl(r){if(!ks(r))throw new Error("invalid ip address");return xi(r)}function jd(r){let e=xl(r,0,r.length);if(e==null)throw new Error("ipBuff is required");if(!ks(e))throw new Error("invalid ip address");return e}function ki(r){let e=new ArrayBuffer(2);return new DataView(e).setUint16(0,r),new Uint8Array(e)}function Bl(r){return new DataView(r.buffer).getUint16(r.byteOffset)}function Bi(r){let e=V(r),t=Uint8Array.from(Oe(e.length));return Ae([t,e],t.length+e.length)}function Ai(r){let e=wt(r);if(r=r.slice(ve(e)),r.length!==e)throw new Error("inconsistent lengths");return D(r)}function Wd(r){let e;r[0]==="Q"||r[0]==="1"?e=$t(ne.decode(`z${r}`)).bytes:e=Ue.parse(r).multihash.bytes;let t=Uint8Array.from(Oe(e.length));return Ae([t,e],t.length+e.length)}function Yd(r){let e=Gd.decode(r),t=Uint8Array.from(Oe(e.length));return Ae([t,e],t.length+e.length)}function Zd(r){let e=wt(r),t=r.slice(ve(e));if(t.length!==e)throw new Error("inconsistent lengths");return"u"+D(t,"base64url")}function Jd(r){let e=wt(r),t=r.slice(ve(e));if(t.length!==e)throw new Error("inconsistent lengths");return D(t,"base58btc")}function Xd(r){let e=r.split(":");if(e.length!==2)throw new Error(`failed to parse onion addr: ["'${e.join('", "')}'"]' does not contain a port number`);if(e[0].length!==16)throw new Error(`failed to parse onion addr: ${e[0]} not a Tor onion address.`);let t=dt.decode("b"+e[0]),n=parseInt(e[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let s=ki(n);return Ae([t,s],t.length+s.length)}function Qd(r){let e=r.split(":");if(e.length!==2)throw new Error(`failed to parse onion addr: ["'${e.join('", "')}'"]' does not contain a port number`);if(e[0].length!==56)throw new Error(`failed to parse onion addr: ${e[0]} not a Tor onion3 address.`);let t=dt.decode(`b${e[0]}`),n=parseInt(e[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let s=ki(n);return Ae([t,s],t.length+s.length)}function El(r){let e=r.slice(0,r.length-2),t=r.slice(r.length-2),n=D(e,"base32"),s=Bl(t);return`${n}:${s}`}function Al(r){r=Ni(r);let e=[],t=[],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=$(i);if(a.size===0){e.push([a.code]),t.push([a.code]);continue}if(o++,o>=s.length)throw Sl("invalid address: "+r);if(a.path===!0){n=Ni(s.slice(o).join("/")),e.push([a.code,Si(a.code,n)]),t.push([a.code,n]);break}let c=Si(a.code,s[o]);e.push([a.code,c]),t.push([a.code,Ii(a.code,c)])}return{string:Il(t),bytes:Ti(e),tuples:e,stringTuples:t,path:n}}function Ri(r){let e=[],t=[],n=null,s=0;for(;s<r.length;){let o=wt(r,s),i=ve(o),a=$(o),c=ep(a,r.slice(s+i));if(c===0){e.push([o]),t.push([o]),s+=i;continue}let f=r.slice(s+i,s+i+c);if(s+=c+i,s>r.length)throw Sl("Invalid address Uint8Array: "+D(r,"base16"));e.push([o,f]);let u=Ii(o,f);if(t.push([o,u]),a.path===!0){n=u;break}}return{bytes:Uint8Array.from(r),string:Il(t),tuples:e,stringTuples:t,path:n}}function Il(r){let e=[];return r.map(t=>{let n=$(t[0]);return e.push(n.name),t.length>1&&t[1]!=null&&e.push(t[1]),null}),Ni(e.join("/"))}function Ti(r){return Ae(r.map(e=>{let t=$(e[0]),n=Uint8Array.from(Oe(t.code));return e.length>1&&e[1]!=null&&(n=Ae([n,e[1]])),n}))}function ep(r,e){if(r.size>0)return r.size/8;if(r.size===0)return 0;{let t=wt(e instanceof Uint8Array?e:Uint8Array.from(e));return t+ve(t)}}function Ni(r){return"/"+r.trim().split("/").filter(e=>e).join("/")}function Sl(r){return new Error("Error parsing address: "+r)}var tp=Symbol.for("nodejs.util.inspect.custom"),_i=Symbol.for("@multiformats/js-multiaddr/multiaddr"),rp=[$("dns").code,$("dns4").code,$("dns6").code,$("dnsaddr").code],Ns=class r{bytes;#t;#e;#r;#n;[_i]=!0;constructor(e){e==null&&(e="");let t;if(e instanceof Uint8Array)t=Ri(e);else if(typeof e=="string"){if(e.length>0&&e.charAt(0)!=="/")throw new Error(`multiaddr "${e}" must start with a "/"`);t=Al(e)}else if(Nl(e))t=Ri(e.bytes);else throw new Error("addr must be a string, Buffer, or another Multiaddr");this.bytes=t.bytes,this.#t=t.string,this.#e=t.tuples,this.#r=t.stringTuples,this.#n=t.path}toString(){return this.#t}toJSON(){return this.toString()}toOptions(){let e,t,n,s,o="",i=$("tcp"),a=$("udp"),c=$("ip4"),f=$("ip6"),u=$("dns6"),l=$("ip6zone");for(let[b,d]of this.stringTuples())b===l.code&&(o=`%${d??""}`),rp.includes(b)&&(t=i.name,s=443,n=`${d??""}${o}`,e=b===u.code?6:4),(b===i.code||b===a.code)&&(t=$(b).name,s=parseInt(d??"")),(b===c.code||b===f.code)&&(t=$(b).name,n=`${d??""}${o}`,e=b===f.code?6:4);if(e==null||t==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:e,host:n,transport:t,port:s}}protos(){return this.#e.map(([e])=>Object.assign({},$(e)))}protoCodes(){return this.#e.map(([e])=>e)}protoNames(){return this.#e.map(([e])=>$(e).name)}tuples(){return this.#e}stringTuples(){return this.#r}encapsulate(e){return e=new r(e),new r(this.toString()+e.toString())}decapsulate(e){let t=e.toString(),n=this.toString(),s=n.lastIndexOf(t);if(s<0)throw new Error(`Address ${this.toString()} does not contain subaddress: ${e.toString()}`);return new r(n.slice(0,s))}decapsulateCode(e){let t=this.tuples();for(let n=t.length-1;n>=0;n--)if(t[n][0]===e)return new r(Ti(t.slice(0,n)));return this}getPeerId(){try{let e=[];this.stringTuples().forEach(([n,s])=>{n===Tr.p2p.code&&e.push([n,s]),n===Tr["p2p-circuit"].code&&(e=[])});let t=e.pop();if(t?.[1]!=null){let n=t[1];return n[0]==="Q"||n[0]==="1"?D(ne.decode(`z${n}`),"base58btc"):D(Ue.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){return this.#n}equals(e){return pe(this.bytes,e.bytes)}async resolve(e){let t=this.protos().find(o=>o.resolvable);if(t==null)return[this];let n=kl.get(t.name);if(n==null)throw new C(`no available resolver for ${t.name}`,"ERR_NO_AVAILABLE_RESOLVER");return(await n(this,e)).map(o=>ct(o))}nodeAddress(){let e=this.toOptions();if(e.transport!=="tcp"&&e.transport!=="udp")throw new Error(`multiaddr must have a valid format - no protocol with name: "${e.transport}". Must have a valid transport protocol: "{tcp, udp}"`);return{family:e.family,address:e.host,port:e.port}}isThinWaistAddress(e){let t=(e??this).protos();return!(t.length!==2||t[0].code!==4&&t[0].code!==41||t[1].code!==6&&t[1].code!==273)}[tp](){return`Multiaddr(${this.#t})`}};var kl=new Map;function Nl(r){return!!r?.[_i]}function ct(r){return new Ns(r)}var Rl="libp2p-peer-record",Tl=Uint8Array.from([3,1]);var cn;(function(r){let e;(function(n){let s;n.codec=()=>(s==null&&(s=je((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)=>{let a={multiaddr:new Uint8Array(0)},c=i==null?o.len:o.pos+i;for(;o.pos<c;){let f=o.uint32();switch(f>>>3){case 1:a.multiaddr=o.bytes();break;default:o.skipType(f&7);break}}return a})),s),n.encode=o=>Ge(o,n.codec()),n.decode=o=>ze(o,n.codec())})(e=r.AddressInfo||(r.AddressInfo={}));let t;r.codec=()=>(t==null&&(t=je((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)=>{let o={peerId:new Uint8Array(0),seq:0n,addresses:[]},i=s==null?n.len:n.pos+s;for(;n.pos<i;){let a=n.uint32();switch(a>>>3){case 1:o.peerId=n.bytes();break;case 2:o.seq=n.uint64();break;case 3:o.addresses.push(r.AddressInfo.codec().decode(n,n.uint32()));break;default:n.skipType(a&7);break}}return o})),t),r.encode=n=>Ge(n,r.codec()),r.decode=n=>ze(n,r.codec())})(cn||(cn={}));var Xe=class r{static createFromProtobuf=e=>{let t=cn.decode(e),n=yi(t.peerId),s=(t.addresses??[]).map(i=>ct(i.multiaddr)),o=t.seq;return new r({peerId:n,multiaddrs:s,seqNumber:o})};static DOMAIN=Rl;static CODEC=Tl;peerId;multiaddrs;seqNumber;domain=r.DOMAIN;codec=r.CODEC;marshaled;constructor(e){let{peerId:t,multiaddrs:n,seqNumber:s}=e;this.peerId=t,this.multiaddrs=n??[],this.seqNumber=s??BigInt(Date.now())}marshal(){return this.marshaled==null&&(this.marshaled=cn.encode({peerId:this.peerId.toBytes(),seq:BigInt(this.seqNumber),addresses:this.multiaddrs.map(e=>({multiaddr:e.bytes}))})),this.marshaled}equals(e){return!(!(e instanceof r)||!this.peerId.equals(e.peerId)||this.seqNumber!==e.seqNumber||!gl(this.multiaddrs,e.multiaddrs))}};function np(r){return r[Symbol.asyncIterator]!=null}function sp(r){if(np(r))return(async()=>{for await(let e of r);})();for(let e of r);}var _l=sp;function Qe(){let r={};return r.promise=new Promise((e,t)=>{r.resolve=e,r.reject=t}),r}var Rs=globalThis.CustomEvent??Event;async function*Ci(r,e={}){let t=e.concurrency??1/0;t<1&&(t=1/0);let n=e.ordered==null?!1:e.ordered,s=new EventTarget,o=[],i=Qe(),a=Qe(),c=!1,f,u=!1;s.addEventListener("task-complete",()=>{a.resolve()}),Promise.resolve().then(async()=>{try{for await(let d of r){if(o.length===t&&(i=Qe(),await i.promise),u)break;let h={done:!1};o.push(h),d().then(y=>{h.done=!0,h.ok=!0,h.value=y,s.dispatchEvent(new Rs("task-complete"))},y=>{h.done=!0,h.err=y,s.dispatchEvent(new Rs("task-complete"))})}c=!0,s.dispatchEvent(new Rs("task-complete"))}catch(d){f=d,s.dispatchEvent(new Rs("task-complete"))}});function l(){return n?o[0]?.done:!!o.find(d=>d.done)}function*p(){for(;o.length>0&&o[0].done;){let d=o[0];if(o.shift(),d.ok)yield d.value;else throw u=!0,i.resolve(),d.err;i.resolve()}}function*b(){for(;l();)for(let d=0;d<o.length;d++)if(o[d].done){let h=o[d];if(o.splice(d,1),d--,h.ok)yield h.value;else throw u=!0,i.resolve(),h.err;i.resolve()}}for(;;){if(l()||(a=Qe(),await a.promise),f!=null)throw f;if(n?yield*p():yield*b(),c&&o.length===0)break}}var Ts=class extends Error{type;code;constructor(e,t,n){super(e??"The operation was aborted"),this.type="aborted",this.name=n??"AbortError",this.code=t??"ABORT_ERR"}};async function Cl(r,e,t){if(e==null)return r;if(e.aborted)return Promise.reject(new Ts(t?.errorMessage,t?.errorCode,t?.errorName));let n,s=new Ts(t?.errorMessage,t?.errorCode,t?.errorName);try{return await Promise.race([r,new Promise((o,i)=>{n=()=>{i(s)},e.addEventListener("abort",n)})])}finally{n!=null&&e.removeEventListener("abort",n)}}var Li=class{readNext;haveNext;ended;nextResult;constructor(){this.ended=!1,this.readNext=Qe(),this.haveNext=Qe()}[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 e=this.nextResult;return this.nextResult=void 0,this.readNext.resolve(),this.readNext=Qe(),e}async throw(e){return this.ended=!0,e!=null&&(this.haveNext.promise.catch(()=>{}),this.haveNext.reject(e)),{done:!0,value:void 0}}async return(){let e={done:!0,value:void 0};return await this._push(void 0),e}async push(e,t){await this._push(e,t)}async end(e,t){e!=null?await this.throw(e):await this._push(void 0,t)}async _push(e,t){if(e!=null&&this.ended)throw new Error("Cannot push value onto an ended pushable");for(;this.nextResult!=null;)await this.readNext.promise;e!=null?this.nextResult={done:!1,value:e}:(this.ended=!0,this.nextResult={done:!0,value:void 0}),this.haveNext.resolve(),this.haveNext=Qe(),await Cl(this.readNext.promise,t?.signal,t)}};function Ll(){return new Li}var _s=class extends Error{name="UnexpectedEOFError";code="ERR_UNEXPECTED_EOF"};var Ui=class extends Error{code;constructor(e,t){super(e),this.code=t}},Pi=class extends Ui{type;constructor(e){super(e,"ABORT_ERR"),this.type="aborted",this.name="AbortError"}};function Ul(r,e){let t=Ll();r.sink(t).catch(async i=>{await t.end(i)}),r.sink=async i=>{for await(let a of i)await t.push(a);await t.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 Je;return{read:async(i,a)=>{a?.signal?.throwIfAborted();let c,f=new Promise((u,l)=>{c=()=>{l(new Pi("Read aborted"))},a?.signal?.addEventListener("abort",c)});try{if(i==null){let{done:l,value:p}=await Promise.race([n.next(),f]);return l===!0?new Je:p}for(;s.byteLength<i;){let{value:l,done:p}=await Promise.race([n.next(),f]);if(p===!0)throw new _s("unexpected end of input");s.append(l)}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 t.push(i,a):await t.push(i.subarray(),a)},unwrap:()=>{if(s.byteLength>0){let i=r.source;r.source=async function*(){e?.yieldBytes===!1?yield s:yield*s,yield*i}()}return r}}}var Cs=class extends Error{name="InvalidMessageLengthError";code="ERR_INVALID_MSG_LENGTH"},Ls=class extends Error{name="InvalidDataLengthError";code="ERR_MSG_DATA_TOO_LONG"},Us=class extends Error{name="InvalidDataLengthLengthError";code="ERR_MSG_LENGTH_TOO_LONG"};function Pl(r,e={}){let t=Ul(r,e);e.maxDataLength!=null&&e.maxLengthLength==null&&(e.maxLengthLength=ve(e.maxDataLength));let n=e?.lengthDecoder??wt,s=e?.lengthEncoder??Oe;return{read:async i=>{let a=-1,c=new Je;for(;;){c.append(await t.read(1,i));try{a=n(c)}catch(f){if(f instanceof RangeError)continue;throw f}if(a<0)throw new Cs("Invalid message length");if(e?.maxLengthLength!=null&&c.byteLength>e.maxLengthLength)throw new Us("message length length too long");if(a>-1)break}if(e?.maxDataLength!=null&&a>e.maxDataLength)throw new Ls("message length too long");return t.read(a,i)},write:async(i,a)=>{await t.write(new Je(s(i.byteLength),i),a)},writeV:async(i,a)=>{let c=new Je(...i.flatMap(f=>[s(f.byteLength),f]));await t.write(c,a)},unwrap:()=>t.unwrap()}}function _r(r,e){let t=Pl(r,e),n={read:async(s,o)=>{let i=await t.read(o);return s.decode(i)},write:async(s,o,i)=>{await t.write(o.encode(s),i)},writeV:async(s,o,i)=>{await t.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:()=>t.unwrap()};return n}var Ol="0.1.0",Vl="id",Dl="id/push",Ml="1.0.0",Hl="1.0.0";var Kt;(function(r){let e;r.codec=()=>(e==null&&(e=je((t,n,s={})=>{if(s.lengthDelimited!==!1&&n.fork(),t.protocolVersion!=null&&(n.uint32(42),n.string(t.protocolVersion)),t.agentVersion!=null&&(n.uint32(50),n.string(t.agentVersion)),t.publicKey!=null&&(n.uint32(10),n.bytes(t.publicKey)),t.listenAddrs!=null)for(let o of t.listenAddrs)n.uint32(18),n.bytes(o);if(t.observedAddr!=null&&(n.uint32(34),n.bytes(t.observedAddr)),t.protocols!=null)for(let o of t.protocols)n.uint32(26),n.string(o);t.signedPeerRecord!=null&&(n.uint32(66),n.bytes(t.signedPeerRecord)),s.lengthDelimited!==!1&&n.ldelim()},(t,n)=>{let s={listenAddrs:[],protocols:[]},o=n==null?t.len:t.pos+n;for(;t.pos<o;){let i=t.uint32();switch(i>>>3){case 5:s.protocolVersion=t.string();break;case 6:s.agentVersion=t.string();break;case 1:s.publicKey=t.bytes();break;case 2:s.listenAddrs.push(t.bytes());break;case 4:s.observedAddr=t.bytes();break;case 3:s.protocols.push(t.string());break;case 8:s.signedPeerRecord=t.bytes();break;default:t.skipType(i&7);break}}return s})),e),r.encode=t=>Ge(t,r.codec()),r.decode=t=>ze(t,r.codec())})(Kt||(Kt={}));var ql=Xi(Kl(),1),Oi=typeof window=="object"&&typeof document=="object"&&document.nodeType===9,Ps=(0,ql.default)(),$l=Oi&&!Ps,zl=Ps&&!Oi,Gl=Ps&&Oi,jl=typeof globalThis.process<"u"&&typeof globalThis.process.release<"u"&&globalThis.process.release.name==="node"&&!Ps,Wl=typeof importScripts=="function"&&typeof self<"u"&&typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope,tx=typeof globalThis.process<"u"&&typeof globalThis.process.env<"u"&&globalThis.process.env["NODE"+"_"+"ENV"]==="test",Yl=typeof navigator<"u"&&navigator.product==="ReactNative";var Ce={protocolPrefix:"ipfs",timeout:5e3,maxInboundStreams:1,maxOutboundStreams:1,maxObservedAddresses:10,maxMessageSize:8192,runOnConnectionOpen:!0,runOnSelfUpdate:!0,runOnTransientConnection:!0,concurrency:32};function Zl(r){if(r!=null&&r.length>0)try{return ct(r)}catch{}}function cp(r,e){return e!=null||(e=`${r.name}/${r.version}`,jl||zl?e+=` UserAgent=${globalThis.process.version}`:($l||Wl||Gl||Yl)&&(e+=` UserAgent=${globalThis.navigator.userAgent}`)),e}async function Os(r,e,t,n,s){if(t("received identify from %p",n.remotePeer),s==null)throw new C("message was null or undefined","ERR_INVALID_MESSAGE");let o={};if(s.listenAddrs.length>0&&(o.addresses=s.listenAddrs.map(c=>({isCertified:!1,multiaddr:ct(c)}))),s.protocols.length>0&&(o.protocols=s.protocols),s.publicKey!=null&&(o.publicKey=s.publicKey,!(await Nr(s.publicKey)).equals(n.remotePeer)))throw new C("public key did not match remote PeerId","ERR_INVALID_PUBLIC_KEY");let i;if(s.signedPeerRecord!=null){t("received signedPeerRecord from %p",n.remotePeer);let c=s.signedPeerRecord,f=await at.openAndCertify(c,Xe.DOMAIN),u=Xe.createFromProtobuf(f.payload);if(!u.peerId.equals(f.peerId))throw new C("signing key does not match PeerId in the PeerRecord","ERR_INVALID_SIGNING_KEY");if(!n.remotePeer.equals(u.peerId))throw new C("signing key does not match remote PeerId","ERR_INVALID_PEER_RECORD_KEY");let l;try{l=await r.get(u.peerId)}catch(p){if(p.code!=="ERR_NOT_FOUND")throw p}if(l!=null&&(o.metadata=l.metadata,l.peerRecordEnvelope!=null)){let p=await at.createFromProtobuf(l.peerRecordEnvelope),b=Xe.createFromProtobuf(p.payload);b.seqNumber>=u.seqNumber&&(t("sequence number was lower or equal to existing sequence number - stored: %d received: %d",b.seqNumber,u.seqNumber),u=b,c=l.peerRecordEnvelope)}o.peerRecordEnvelope=c,o.addresses=u.multiaddrs.map(p=>({isCertified:!0,multiaddr:p})),i={seq:u.seqNumber,addresses:u.multiaddrs}}else t("%p did not send a signed peer record",n.remotePeer);if(t("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=V(s.agentVersion)),s.protocolVersion!=null&&(c.ProtocolVersion=V(s.protocolVersion)),t("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=>ct(c)),observedAddr:s.observedAddr==null?void 0:ct(s.observedAddr),protocols:s.protocols,signedPeerRecord:i,connection:n};return e.safeDispatchEvent("peer:identify",{detail:a}),a}var Cr=class{host;protocol;started;timeout;peerId;peerStore;registrar;addressManager;maxInboundStreams;maxOutboundStreams;maxMessageSize;maxObservedAddresses;events;runOnTransientConnection;log;constructor(e,t){this.protocol=t.protocol,this.started=!1,this.peerId=e.peerId,this.peerStore=e.peerStore,this.registrar=e.registrar,this.addressManager=e.addressManager,this.events=e.events,this.log=t.log,this.timeout=t.timeout??Ce.timeout,this.maxInboundStreams=t.maxInboundStreams??Ce.maxInboundStreams,this.maxOutboundStreams=t.maxOutboundStreams??Ce.maxOutboundStreams,this.maxMessageSize=t.maxMessageSize??Ce.maxMessageSize,this.maxObservedAddresses=t.maxObservedAddresses??Ce.maxObservedAddresses,this.runOnTransientConnection=t.runOnTransientConnection??Ce.runOnTransientConnection,this.host={protocolVersion:`${t.protocolPrefix??Ce.protocolPrefix}/${Ol}`,agentVersion:cp(e.nodeInfo,t.agentVersion)}}isStarted(){return this.started}async start(){this.started||(await this.peerStore.merge(this.peerId,{metadata:{AgentVersion:V(this.host.agentVersion),ProtocolVersion:V(this.host.protocolVersion)}}),await this.registrar.handle(this.protocol,e=>{this.handleProtocol(e).catch(t=>{this.log.error(t)})},{maxInboundStreams:this.maxInboundStreams,maxOutboundStreams:this.maxOutboundStreams,runOnTransientConnection:this.runOnTransientConnection}),this.started=!0)}async stop(){await this.registrar.unhandle(this.protocol),this.started=!1}};var Vs=class extends Cr{connectionManager;concurrency;constructor(e,t={}){super(e,{...t,protocol:`/${t.protocolPrefix??Ce.protocolPrefix}/${Dl}/${Hl}`,log:e.logger.forComponent("libp2p:identify-push")}),this.connectionManager=e.connectionManager,this.concurrency=t.concurrency??Ce.concurrency,(t.runOnSelfUpdate??Ce.runOnSelfUpdate)&&e.events.addEventListener("self:peer:update",n=>{this.push().catch(s=>{this.log.error(s)})})}[dn]=["@libp2p/identify-push"];async push(){if(!this.isStarted())return;let e=this.addressManager.getAddresses().map(u=>u.decapsulateCode($("p2p").code)),t=new Xe({peerId:this.peerId,multiaddrs:e}),n=await at.seal(t,this.peerId),s=this.registrar.getProtocols(),o=await this.peerStore.get(this.peerId),i=D(o.metadata.get("AgentVersion")??V(this.host.agentVersion)),a=D(o.metadata.get("ProtocolVersion")??V(this.host.protocolVersion)),c=this;async function*f(){for(let u of c.connectionManager.getConnections())(await c.peerStore.get(u.remotePeer)).protocols.includes(c.protocol)&&(yield async()=>{let p,b=AbortSignal.timeout(c.timeout);Ur(1/0,b);try{p=await u.newStream(c.protocol,{signal:b,runOnTransientConnection:c.runOnTransientConnection}),await _r(p,{maxDataLength:c.maxMessageSize}).pb(Kt).write({listenAddrs:e.map(h=>h.bytes),signedPeerRecord:n.marshal(),protocols:s,agentVersion:i,protocolVersion:a},{signal:b}),await p.close({signal:b})}catch(d){c.log.error("could not push identify update to peer",d),p?.abort(d)}})}await _l(Ci(f(),{concurrency:this.concurrency}))}async handleProtocol(e){let{connection:t,stream:n}=e;try{if(this.peerId.equals(t.remotePeer))throw new Error("received push from ourselves?");let s={signal:AbortSignal.timeout(this.timeout)},i=await _r(n,{maxDataLength:this.maxMessageSize}).pb(Kt).read(s);await n.close(s),await Os(this.peerStore,this.events,this.log,t,i)}catch(s){this.log.error("received invalid message",s),n.abort(s);return}this.log("handled push from %p",t.remotePeer)}};var lp=r=>r.toString().split("/").slice(1),ln=r=>({match:e=>e.length<1?!1:r(e[0])?e.slice(1):!1,pattern:"fn"}),z=r=>({match:e=>ln(t=>t===r).match(e),pattern:r}),Hs=()=>({match:r=>ln(e=>typeof e=="string").match(r),pattern:"{string}"}),Fs=()=>({match:r=>ln(e=>!isNaN(parseInt(e))).match(r),pattern:"{number}"}),we=()=>({match:r=>{if(r.length<2||r[0]!=="p2p"&&r[0]!=="ipfs")return!1;if(r[1].startsWith("Q")||r[1].startsWith("1"))try{ne.decode(`z${r[1]}`)}catch{return!1}else return!1;return r.slice(2)},pattern:"/p2p/{peerid}"}),Ds=()=>({match:r=>{if(r.length<2||r[0]!=="certhash")return!1;try{lo.decode(r[1])}catch{return!1}return r.slice(2)},pattern:"/certhash/{certhash}"}),ue=r=>({match:e=>{let t=r.match(e);return t===!1?e:t},pattern:`optional(${r.pattern})`}),De=(...r)=>({match:e=>{let t;for(let n of r){let s=n.match(e);s!==!1&&(t==null||s.length<t.length)&&(t=s)}return t??!1},pattern:`or(${r.map(e=>e.pattern).join(", ")})`}),Y=(...r)=>({match:e=>{for(let t of r){let n=t.match(e);if(n===!1)return!1;e=n}return e},pattern:`and(${r.map(e=>e.pattern).join(", ")})`});function se(...r){function e(s){let o=lp(s);for(let i of r){let a=i.match(o);if(a===!1)return!1;o=a}return o}function t(s){return e(s)!==!1}function n(s){let o=e(s);return o===!1?!1:o.length===0}return{matches:t,exactMatch:n}}var Di=Y(z("dns4"),Hs()),Mi=Y(z("dns6"),Hs()),Hi=Y(z("dnsaddr"),Hs()),Jl=Y(z("dns"),Hs()),kx=se(Di),Nx=se(Mi),Rx=se(Hi),Tx=se(De(Jl,Hi,Di,Mi)),Xl=Y(z("ip4"),ln(Is)),Ql=Y(z("ip6"),ln(Ss)),eu=De(Xl,Ql),lt=De(eu,Jl,Di,Mi,Hi),tu=se(lt),_x=se(Xl),Cx=se(Ql),Lx=se(eu),Fi=Y(lt,z("tcp"),Fs()),un=Y(lt,z("udp"),Fs()),Ux=se(Fi),Px=se(un),Ki=Y(un,z("quic")),Ks=Y(un,z("quic-v1")),up=De(Ki,Ks),Ox=se(Ki),Vx=se(Ks),Vi=De(lt,Fi,un,Ki,Ks),ru=De(Y(Vi,z("ws"),ue(we()))),Dx=se(ru),nu=De(Y(Vi,z("wss"),ue(we())),Y(Vi,z("tls"),z("ws"),ue(we()))),Mx=se(nu),su=Y(un,z("webrtc-direct"),ue(Ds()),ue(Ds()),ue(we())),Hx=se(su),ou=Y(Ks,z("webtransport"),ue(Ds()),ue(Ds()),ue(we())),Fx=se(ou),Ms=De(ru,nu,Y(Fi,ue(we())),Y(up,ue(we())),Y(lt,ue(we())),su,ou,we()),Kx=se(Ms),fp=Y(Ms,z("p2p-circuit"),we()),qx=se(fp),hp=De(Y(Ms,z("p2p-circuit"),z("webrtc"),ue(we())),Y(Ms,z("webrtc"),ue(we())),z("webrtc")),$x=se(hp),dp=De(Y(lt,z("tcp"),Fs(),z("http"),ue(we())),Y(lt,z("http"),ue(we()))),zx=se(dp),pp=De(Y(lt,z("tcp"),De(Y(z("443"),z("http")),Y(Fs(),z("https"))),ue(we())),Y(lt,z("tls"),z("http"),ue(we())),Y(lt,z("https"),ue(we()))),Gx=se(pp);var qs=class extends Cr{constructor(e,t={}){super(e,{...t,protocol:`/${t.protocolPrefix??Ce.protocolPrefix}/${Vl}/${Ml}`,log:e.logger.forComponent("libp2p:identify")}),(t.runOnConnectionOpen??Ce.runOnConnectionOpen)&&e.events.addEventListener("connection:open",n=>{let s=n.detail;this.identify(s).catch(o=>{this.log.error("error during identify trigged by connection:open",o)})})}[dn]=["@libp2p/identify"];async _identify(e,t={}){let n;if(t.signal==null){let s=AbortSignal.timeout(this.timeout);Ur(1/0,s),t={...t,signal:s}}try{n=await e.newStream(this.protocol,{...t,runOnTransientConnection:this.runOnTransientConnection});let o=await _r(n,{maxDataLength:this.maxMessageSize}).pb(Kt).read(t);return await n.close(t),o}catch(s){throw this.log.error("error while reading identify message",s),n?.abort(s),s}}async identify(e,t={}){let n=await this._identify(e,t),{publicKey:s,protocols:o,observedAddr:i}=n;if(s==null)throw new C("public key was missing from identify message","ERR_MISSING_PUBLIC_KEY");let a=await Nr(s);if(!e.remotePeer.equals(a))throw new C("identified peer does not match the expected peer","ERR_INVALID_PEER");if(this.peerId.equals(a))throw new C("identified peer is our own peer id?","ERR_INVALID_PEER");let c=Zl(i);return this.log("identify completed for peer %p and protocols %o",a,o),this.log("our observed address is %a",c),c!=null&&this.addressManager.getObservedAddrs().length<(this.maxObservedAddresses??1/0)&&(this.log("storing our observed address %a",c),this.addressManager.addObservedAddr(c)),Os(this.peerStore,this.events,this.log,e,n)}async handleProtocol(e){let{connection:t,stream:n}=e,s=AbortSignal.timeout(this.timeout);Ur(1/0,s);try{let o=this.peerId.publicKey??new Uint8Array(0),i=await this.peerStore.get(this.peerId),a=this.addressManager.getAddresses().map(l=>l.decapsulateCode($("p2p").code)),c=i.peerRecordEnvelope;if(a.length>0&&c==null){let l=new Xe({peerId:this.peerId,multiaddrs:a});c=(await at.seal(l,this.peerId)).marshal().subarray()}let f=t.remoteAddr.bytes;tu.matches(t.remoteAddr)||(f=void 0),await _r(n).pb(Kt).write({protocolVersion:this.host.protocolVersion,agentVersion:this.host.agentVersion,publicKey:o,listenAddrs:a.map(l=>l.bytes),signedPeerRecord:c,observedAddr:f,protocols:i.protocols},{signal:s}),await n.close({signal:s})}catch(o){this.log.error("could not respond to identify request",o),n.abort(o)}}};function gp(r={}){return e=>new qs(e,r)}function mp(r={}){return e=>new Vs(e,r)}return bu(yp);})();
6
+ `)}`:`${t} :`}};uc=Ht;I.Constructed=uc;Ht.NAME="CONSTRUCTED";var $n=class extends Ae{fromBER(e,t,n){return t}toBER(e){return Ye}};$n.override="EndOfContentValueBlock";var fc,zn=class extends we{constructor(e={}){super(e,$n),this.idBlock.tagClass=1,this.idBlock.tagNumber=0}};fc=zn;I.EndOfContent=fc;zn.NAME=Xr;var hc,Ft=class extends we{constructor(e={}){super(e,Ae),this.idBlock.tagClass=1,this.idBlock.tagNumber=5}fromBER(e,t,n){return this.lenBlock.length>0&&this.warnings.push("Non-zero length of value block for Null type"),this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.blockLength+=n,t+n>e.byteLength?(this.error="End of input reached before message was fully decoded (inconsistent offset and length values)",-1):t+n}toBER(e,t){let n=new ArrayBuffer(2);if(!e){let s=new Uint8Array(n);s[0]=5,s[1]=0}return t&&t.write(n),n}onAsciiEncoding(){return`${this.constructor.NAME}`}};hc=Ft;I.Null=hc;Ft.NAME="NULL";var Gn=class extends St(Ae){constructor({value:e,...t}={}){super(t),t.valueHex?this.valueHexView=K.BufferSourceConverter.toUint8Array(t.valueHex):this.valueHexView=new Uint8Array(1),e&&(this.value=e)}get value(){for(let e of this.valueHexView)if(e>0)return!0;return!1}set value(e){this.valueHexView[0]=e?255:0}fromBER(e,t,n){let s=K.BufferSourceConverter.toUint8Array(e);return It(this,s,t,n)?(this.valueHexView=s.subarray(t,t+n),n>1&&this.warnings.push("Boolean value encoded in more then 1 octet"),this.isHexOnly=!0,ni.call(this),this.blockLength=n,t+n):-1}toBER(){return this.valueHexView.slice()}toJSON(){return{...super.toJSON(),value:this.value}}};Gn.NAME="BooleanValueBlock";var dc,jn=class extends we{constructor(e={}){super(e,Gn),this.idBlock.tagClass=1,this.idBlock.tagNumber=1}getValue(){return this.valueBlock.value}setValue(e){this.valueBlock.value=e}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.getValue}`}};dc=jn;I.Boolean=dc;jn.NAME="BOOLEAN";var Wn=class extends St(st){constructor({isConstructed:e=!1,...t}={}){super(t),this.isConstructed=e}fromBER(e,t,n){let s=0;if(this.isConstructed){if(this.isHexOnly=!1,s=st.prototype.fromBER.call(this,e,t,n),s===-1)return s;for(let o=0;o<this.value.length;o++){let i=this.value[o].constructor.NAME;if(i===Xr){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, OCTET STRING may consists of OCTET STRINGs only",-1}if(i!==ic)return this.error="OCTET STRING may consists of OCTET STRINGs only",-1}}else this.isHexOnly=!0,s=super.fromBER(e,t,n),this.blockLength=n;return s}toBER(e,t){return this.isConstructed?st.prototype.toBER.call(this,e,t):e?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),isConstructed:this.isConstructed}}};Wn.NAME="OctetStringValueBlock";var pc,Bt=class r extends we{constructor({idBlock:e={},lenBlock:t={},...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,...e},lenBlock:{...t,isIndefiniteForm:!!n.isIndefiniteForm},...n},Wn),this.idBlock.tagClass=1,this.idBlock.tagNumber=4}fromBER(e,t,n){if(this.valueBlock.isConstructed=this.idBlock.isConstructed,this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm,n===0)return this.idBlock.error.length===0&&(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length===0&&(this.blockLength+=this.lenBlock.blockLength),t;if(!this.valueBlock.isConstructed){let o=(e instanceof ArrayBuffer?new Uint8Array(e):e).subarray(t,t+n);try{if(o.byteLength){let i=Es(o,0,o.byteLength);i.offset!==-1&&i.offset===n&&(this.valueBlock.value=[i.result])}}catch{}}return super.fromBER(e,t,n)}onAsciiEncoding(){return this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length?Ht.prototype.onAsciiEncoding.call(this):`${this.constructor.NAME} : ${K.Convert.ToHex(this.valueBlock.valueHexView)}`}getValue(){if(!this.idBlock.isConstructed)return this.valueBlock.valueHexView.slice().buffer;let e=[];for(let t of this.valueBlock.value)t instanceof r&&e.push(t.valueBlock.valueHexView);return K.BufferSourceConverter.concat(e)}};pc=Bt;I.OctetString=pc;Bt.NAME=ic;var Yn=class extends St(st){constructor({unusedBits:e=0,isConstructed:t=!1,...n}={}){super(n),this.unusedBits=e,this.isConstructed=t,this.blockLength=this.valueHexView.byteLength}fromBER(e,t,n){if(!n)return t;let s=-1;if(this.isConstructed){if(s=st.prototype.fromBER.call(this,e,t,n),s===-1)return s;for(let a of this.value){let c=a.constructor.NAME;if(c===Xr){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, BIT STRING may consists of BIT STRINGs only",-1}if(c!==ac)return this.error="BIT STRING may consists of BIT STRINGs only",-1;let f=a.valueBlock;if(this.unusedBits>0&&f.unusedBits>0)return this.error='Using of "unused bits" inside constructive BIT STRING allowed for least one only',-1;this.unusedBits=f.unusedBits}return s}let o=K.BufferSourceConverter.toUint8Array(e);if(!It(this,o,t,n))return-1;let i=o.subarray(t,t+n);if(this.unusedBits=i[0],this.unusedBits>7)return this.error="Unused bits for BitString must be in range 0-7",-1;if(!this.unusedBits){let a=i.subarray(1);try{if(a.byteLength){let c=Es(a,0,a.byteLength);c.offset!==-1&&c.offset===n-1&&(this.value=[c.result])}}catch{}}return this.valueHexView=i.subarray(1),this.blockLength=i.length,t+n}toBER(e,t){if(this.isConstructed)return st.prototype.toBER.call(this,e,t);if(e)return new ArrayBuffer(this.valueHexView.byteLength+1);if(!this.valueHexView.byteLength)return Ye;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}}};Yn.NAME="BitStringValueBlock";var gc,Ar=class extends we{constructor({idBlock:e={},lenBlock:t={},...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,...e},lenBlock:{...t,isIndefiniteForm:!!n.isIndefiniteForm},...n},Yn),this.idBlock.tagClass=1,this.idBlock.tagNumber=3}fromBER(e,t,n){return this.valueBlock.isConstructed=this.idBlock.isConstructed,this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm,super.fromBER(e,t,n)}onAsciiEncoding(){if(this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length)return Ht.prototype.onAsciiEncoding.call(this);{let e=[],t=this.valueBlock.valueHexView;for(let s of t)e.push(s.toString(2).padStart(8,"0"));let n=e.join("");return`${this.constructor.NAME} : ${n.substring(0,n.length-this.valueBlock.unusedBits)}`}}};gc=Ar;I.BitString=gc;Ar.NAME=ac;var mc;function cd(r,e){let t=new Uint8Array([0]),n=new Uint8Array(r),s=new Uint8Array(e),o=n.slice(0),i=o.length-1,a=s.slice(0),c=a.length-1,f=0,l=c<i?i:c,u=0;for(let h=l;h>=0;h--,u++){switch(!0){case u<a.length:f=o[i-u]+a[c-u]+t[0];break;default:f=o[i-u]+t[0]}switch(t[0]=f/10,!0){case u>=o.length:o=Vn(new Uint8Array([f%10]),o);break;default:o[i-u]=f%10}}return t[0]>0&&(o=Vn(t,o)),o}function oc(r){if(r>=Zr.length)for(let e=Zr.length;e<=r;e++){let t=new Uint8Array([0]),n=Zr[e-1].slice(0);for(let s=n.length-1;s>=0;s--){let o=new Uint8Array([(n[s]<<1)+t[0]]);t[0]=o[0]/10,n[s]=o[0]%10}t[0]>0&&(n=Vn(t,n)),Zr.push(n)}return Zr[r]}function ld(r,e){let t=0,n=new Uint8Array(r),s=new Uint8Array(e),o=n.slice(0),i=o.length-1,a=s.slice(0),c=a.length-1,f,l=0;for(let u=c;u>=0;u--,l++)switch(f=o[i-l]-a[c-l]-t,!0){case f<0:t=1,o[i-l]=f+10;break;default:t=0,o[i-l]=f}if(t>0)for(let u=i-c+1;u>=0;u--,l++)if(f=o[i-l]-t,f<0)t=1,o[i-l]=f+10;else{t=0,o[i-l]=f;break}return o.slice()}var Qr=class extends St(Ae){constructor({value:e,...t}={}){super(t),this._valueDec=0,t.valueHex&&this.setValueHex(),e!==void 0&&(this.valueDec=e)}setValueHex(){this.valueHexView.length>=4?(this.warnings.push("Too big Integer for decoding, hex only"),this.isHexOnly=!0,this._valueDec=0):(this.isHexOnly=!1,this.valueHexView.length>0&&(this._valueDec=ni.call(this)))}set valueDec(e){this._valueDec=e,this.isHexOnly=!1,this.valueHexView=new Uint8Array(rc(e))}get valueDec(){return this._valueDec}fromDER(e,t,n,s=0){let o=this.fromBER(e,t,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(e=!1){let t=this.valueHexView;switch(!0){case(t[0]&128)!==0:{let n=new Uint8Array(this.valueHexView.length+1);n[0]=0,n.set(t,1),this.valueHexView=n}break;case(t[0]===0&&(t[1]&128)===0):this.valueHexView=this.valueHexView.subarray(1);break}return this.toBER(e)}fromBER(e,t,n){let s=super.fromBER(e,t,n);return s===-1||this.setValueHex(),s}toBER(e){return e?new ArrayBuffer(this.valueHexView.length):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}toString(){let e=this.valueHexView.length*8-1,t=new Uint8Array(this.valueHexView.length*8/3),n=0,s,o=this.valueHexView,i="",a=!1;for(let c=o.byteLength-1;c>=0;c--){s=o[c];for(let f=0;f<8;f++){if((s&1)===1)switch(n){case e:t=ld(oc(n),t),i="-";break;default:t=cd(t,oc(n))}n++,s>>=1}}for(let c=0;c<t.length;c++)t[c]&&(a=!0),a&&(i+=sc.charAt(t[c]));return a===!1&&(i+=sc.charAt(0)),i}};mc=Qr;Qr.NAME="IntegerValueBlock";Object.defineProperty(mc.prototype,"valueHex",{set:function(r){this.valueHexView=new Uint8Array(r),this.setValueHex()},get:function(){return this.valueHexView.slice().buffer}});var yc,oe=class r extends we{constructor(e={}){super(e,Qr),this.idBlock.tagClass=1,this.idBlock.tagNumber=2}toBigInt(){return Dn(),BigInt(this.valueBlock.toString())}static fromBigInt(e){Dn();let t=BigInt(e),n=new Jr,s=t.toString(16).replace(/^-/,""),o=new Uint8Array(K.Convert.FromHex(s));if(t<0){let a=new Uint8Array(o.length+(o[0]&128?1:0));a[0]|=128;let f=BigInt(`0x${K.Convert.ToHex(a)}`)+t,l=K.BufferSourceConverter.toUint8Array(K.Convert.FromHex(f.toString(16)));l[0]|=128,n.write(l)}else o[0]&128&&n.write(new Uint8Array([0])),n.write(o);return new r({valueHex:n.final()})}convertToDER(){let e=new r({valueHex:this.valueBlock.valueHexView});return e.valueBlock.toDER(),e}convertFromDER(){return new r({valueHex:this.valueBlock.valueHexView[0]===0?this.valueBlock.valueHexView.subarray(1):this.valueBlock.valueHexView})}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()}`}};yc=oe;I.Integer=yc;oe.NAME="INTEGER";var bc,Zn=class extends oe{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=10}};bc=Zn;I.Enumerated=bc;Zn.NAME="ENUMERATED";var en=class extends St(Ae){constructor({valueDec:e=-1,isFirstSid:t=!1,...n}={}){super(n),this.valueDec=e,this.isFirstSid=t}fromBER(e,t,n){if(!n)return t;let s=K.BufferSourceConverter.toUint8Array(e);if(!It(this,s,t,n))return-1;let o=s.subarray(t,t+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=sr(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),t+this.blockLength)}set valueBigInt(e){Dn();let t=BigInt(e).toString(2);for(;t.length%7;)t="0"+t;let n=new Uint8Array(t.length/7);for(let s=0;s<n.length;s++)n[s]=parseInt(t.slice(s*7,s*7+7),2)+(s+1<n.length?128:0);this.fromBER(n.buffer,0,n.length)}toBER(e){if(this.isHexOnly){if(e)return new ArrayBuffer(this.valueHexView.byteLength);let 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 t=Mt(this.valueDec,7);if(t.byteLength===0)return this.error="Error during encoding SID value",Ye;let n=new Uint8Array(t.byteLength);if(!e){let s=new Uint8Array(t),o=t.byteLength-1;for(let i=0;i<o;i++)n[i]=s[i]|128;n[o]=s[o]}return n}toString(){let e="";if(this.isHexOnly)e=K.Convert.ToHex(this.valueHexView);else if(this.isFirstSid){let t=this.valueDec;this.valueDec<=39?e="0.":this.valueDec<=79?(e="1.",t-=40):(e="2.",t-=80),e+=t.toString()}else e=this.valueDec.toString();return e}toJSON(){return{...super.toJSON(),valueDec:this.valueDec,isFirstSid:this.isFirstSid}}};en.NAME="sidBlock";var Jn=class extends Ae{constructor({value:e=Ir,...t}={}){super(t),this.value=[],e&&this.fromString(e)}fromBER(e,t,n){let s=t;for(;n>0;){let o=new en;if(s=o.fromBER(e,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(e){let t=[];for(let n=0;n<this.value.length;n++){let s=this.value[n].toBER(e);if(s.byteLength===0)return this.error=this.value[n].error,Ye;t.push(s)}return si(t)}fromString(e){this.value=[];let t=0,n=0,s="",o=!1;do if(n=e.indexOf(".",t),n===-1?s=e.substring(t):s=e.substring(t,n),t=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 en;if(s>Number.MAX_SAFE_INTEGER){Dn();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 e="",t=!1;for(let n=0;n<this.value.length;n++){t=this.value[n].isHexOnly;let s=this.value[n].toString();n!==0&&(e=`${e}.`),t?(s=`{${s}}`,this.value[n].isFirstSid?e=`2.{${s} - 80}`:e+=s):e+=s}return e}toJSON(){let e={...super.toJSON(),value:this.toString(),sidArray:[]};for(let t=0;t<this.value.length;t++)e.sidArray.push(this.value[t].toJSON());return e}};Jn.NAME="ObjectIdentifierValueBlock";var wc,We=class extends we{constructor(e={}){super(e,Jn),this.idBlock.tagClass=1,this.idBlock.tagNumber=6}getValue(){return this.valueBlock.toString()}setValue(e){this.valueBlock.fromString(e)}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()||"empty"}`}toJSON(){return{...super.toJSON(),value:this.getValue()}}};wc=We;I.ObjectIdentifier=wc;We.NAME="OBJECT IDENTIFIER";var tn=class extends St(Et){constructor({valueDec:e=0,...t}={}){super(t),this.valueDec=e}fromBER(e,t,n){if(n===0)return t;let s=K.BufferSourceConverter.toUint8Array(e);if(!It(this,s,t,n))return-1;let o=s.subarray(t,t+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=sr(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),t+this.blockLength)}toBER(e){if(this.isHexOnly){if(e)return new ArrayBuffer(this.valueHexView.byteLength);let 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 t=Mt(this.valueDec,7);if(t.byteLength===0)return this.error="Error during encoding SID value",Ye;let n=new Uint8Array(t.byteLength);if(!e){let s=new Uint8Array(t),o=t.byteLength-1;for(let i=0;i<o;i++)n[i]=s[i]|128;n[o]=s[o]}return n.buffer}toString(){let e="";return this.isHexOnly?e=K.Convert.ToHex(this.valueHexView):e=this.valueDec.toString(),e}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}};tn.NAME="relativeSidBlock";var Xn=class extends Ae{constructor({value:e=Ir,...t}={}){super(t),this.value=[],e&&this.fromString(e)}fromBER(e,t,n){let s=t;for(;n>0;){let o=new tn;if(s=o.fromBER(e,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(e,t){let n=[];for(let s=0;s<this.value.length;s++){let o=this.value[s].toBER(e);if(o.byteLength===0)return this.error=this.value[s].error,Ye;n.push(o)}return si(n)}fromString(e){this.value=[];let t=0,n=0,s="";do{n=e.indexOf(".",t),n===-1?s=e.substring(t):s=e.substring(t,n),t=n+1;let o=new tn;if(o.valueDec=parseInt(s,10),isNaN(o.valueDec))return!0;this.value.push(o)}while(n!==-1);return!0}toString(){let e="",t=!1;for(let n=0;n<this.value.length;n++){t=this.value[n].isHexOnly;let s=this.value[n].toString();n!==0&&(e=`${e}.`),t&&(s=`{${s}}`),e+=s}return e}toJSON(){let e={...super.toJSON(),value:this.toString(),sidArray:[]};for(let t=0;t<this.value.length;t++)e.sidArray.push(this.value[t].toJSON());return e}};Xn.NAME="RelativeObjectIdentifierValueBlock";var xc,Qn=class extends we{constructor(e={}){super(e,Xn),this.idBlock.tagClass=1,this.idBlock.tagNumber=13}getValue(){return this.valueBlock.toString()}setValue(e){this.valueBlock.fromString(e)}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()||"empty"}`}toJSON(){return{...super.toJSON(),value:this.getValue()}}};xc=Qn;I.RelativeObjectIdentifier=xc;Qn.NAME="RelativeObjectIdentifier";var vc,ge=class extends Ht{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=16}};vc=ge;I.Sequence=vc;ge.NAME="SEQUENCE";var Ec,es=class extends Ht{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=17}};Ec=es;I.Set=Ec;es.NAME="SET";var ts=class extends St(Ae){constructor({...e}={}){super(e),this.isHexOnly=!0,this.value=Ir}toJSON(){return{...super.toJSON(),value:this.value}}};ts.NAME="StringValueBlock";var rs=class extends ts{};rs.NAME="SimpleStringValueBlock";var Ne=class extends Fn{constructor({...e}={}){super(e,rs)}fromBuffer(e){this.valueBlock.value=String.fromCharCode.apply(null,K.BufferSourceConverter.toUint8Array(e))}fromString(e){let t=e.length,n=this.valueBlock.valueHexView=new Uint8Array(t);for(let s=0;s<t;s++)n[s]=e.charCodeAt(s);this.valueBlock.value=e}};Ne.NAME="SIMPLE STRING";var ns=class extends Ne{fromBuffer(e){this.valueBlock.valueHexView=K.BufferSourceConverter.toUint8Array(e);try{this.valueBlock.value=K.Convert.ToUtf8String(e)}catch(t){this.warnings.push(`Error during "decodeURIComponent": ${t}, using raw string`),this.valueBlock.value=K.Convert.ToBinary(e)}}fromString(e){this.valueBlock.valueHexView=new Uint8Array(K.Convert.FromUtf8String(e)),this.valueBlock.value=e}};ns.NAME="Utf8StringValueBlock";var Bc,At=class extends ns{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=12}};Bc=At;I.Utf8String=Bc;At.NAME="UTF8String";var ss=class extends Ne{fromBuffer(e){this.valueBlock.value=K.Convert.ToUtf16String(e),this.valueBlock.valueHexView=K.BufferSourceConverter.toUint8Array(e)}fromString(e){this.valueBlock.value=e,this.valueBlock.valueHexView=new Uint8Array(K.Convert.FromUtf16String(e))}};ss.NAME="BmpStringValueBlock";var Ac,os=class extends ss{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=30}};Ac=os;I.BmpString=Ac;os.NAME="BMPString";var is=class extends Ne{fromBuffer(e){let t=ArrayBuffer.isView(e)?e.slice().buffer:e.slice(0),n=new Uint8Array(t);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(t))}fromString(e){let t=e.length,n=this.valueBlock.valueHexView=new Uint8Array(t*4);for(let s=0;s<t;s++){let o=Mt(e.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=e}};is.NAME="UniversalStringValueBlock";var Ic,as=class extends is{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=28}};Ic=as;I.UniversalString=Ic;as.NAME="UniversalString";var Sc,cs=class extends Ne{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=18}};Sc=cs;I.NumericString=Sc;cs.NAME="NumericString";var kc,ls=class extends Ne{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=19}};kc=ls;I.PrintableString=kc;ls.NAME="PrintableString";var Nc,us=class extends Ne{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=20}};Nc=us;I.TeletexString=Nc;us.NAME="TeletexString";var Rc,fs=class extends Ne{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=21}};Rc=fs;I.VideotexString=Rc;fs.NAME="VideotexString";var Tc,hs=class extends Ne{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=22}};Tc=hs;I.IA5String=Tc;hs.NAME="IA5String";var _c,ds=class extends Ne{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=25}};_c=ds;I.GraphicString=_c;ds.NAME="GraphicString";var Cc,rn=class extends Ne{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=26}};Cc=rn;I.VisibleString=Cc;rn.NAME="VisibleString";var Lc,ps=class extends Ne{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=27}};Lc=ps;I.GeneralString=Lc;ps.NAME="GeneralString";var Uc,gs=class extends Ne{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=29}};Uc=gs;I.CharacterString=Uc;gs.NAME="CharacterString";var Oc,nn=class extends rn{constructor({value:e,valueDate:t,...n}={}){if(super(n),this.year=0,this.month=0,this.day=0,this.hour=0,this.minute=0,this.second=0,e){this.fromString(e),this.valueBlock.valueHexView=new Uint8Array(e.length);for(let s=0;s<e.length;s++)this.valueBlock.valueHexView[s]=e.charCodeAt(s)}t&&(this.fromDate(t),this.valueBlock.valueHexView=new Uint8Array(this.toBuffer())),this.idBlock.tagClass=1,this.idBlock.tagNumber=23}fromBuffer(e){this.fromString(String.fromCharCode.apply(null,K.BufferSourceConverter.toUint8Array(e)))}toBuffer(){let e=this.toString(),t=new ArrayBuffer(e.length),n=new Uint8Array(t);for(let s=0;s<e.length;s++)n[s]=e.charCodeAt(s);return t}fromDate(e){this.year=e.getUTCFullYear(),this.month=e.getUTCMonth()+1,this.day=e.getUTCDate(),this.hour=e.getUTCHours(),this.minute=e.getUTCMinutes(),this.second=e.getUTCSeconds()}toDate(){return new Date(Date.UTC(this.year,this.month-1,this.day,this.hour,this.minute,this.second))}fromString(e){let n=/(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})Z/ig.exec(e);if(n===null){this.error="Wrong input string for conversion";return}let 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(e="iso"){if(e==="iso"){let t=new Array(7);return t[0]=Le(this.year<2e3?this.year-1900:this.year-2e3,2),t[1]=Le(this.month,2),t[2]=Le(this.day,2),t[3]=Le(this.hour,2),t[4]=Le(this.minute,2),t[5]=Le(this.second,2),t[6]="Z",t.join("")}return super.toString(e)}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.toDate().toISOString()}`}toJSON(){return{...super.toJSON(),year:this.year,month:this.month,day:this.day,hour:this.hour,minute:this.minute,second:this.second}}};Oc=nn;I.UTCTime=Oc;nn.NAME="UTCTime";var Pc,ms=class extends nn{constructor(e={}){var t;super(e),(t=this.millisecond)!==null&&t!==void 0||(this.millisecond=0),this.idBlock.tagClass=1,this.idBlock.tagNumber=24}fromDate(e){super.fromDate(e),this.millisecond=e.getUTCMilliseconds()}toDate(){return new Date(Date.UTC(this.year,this.month-1,this.day,this.hour,this.minute,this.second,this.millisecond))}fromString(e){let t=!1,n="",s="",o=0,i,a=0,c=0;if(e[e.length-1]==="Z")n=e.substring(0,e.length-1),t=!0;else{let u=new Number(e[e.length-1]);if(isNaN(u.valueOf()))throw new Error("Wrong input string for conversion");n=e}if(t){if(n.indexOf("+")!==-1)throw new Error("Wrong input string for conversion");if(n.indexOf("-")!==-1)throw new Error("Wrong input string for conversion")}else{let u=1,h=n.indexOf("+"),y="";if(h===-1&&(h=n.indexOf("-"),u=-1),h!==-1){if(y=n.substring(h+1),n=n.substring(0,h),y.length!==2&&y.length!==4)throw new Error("Wrong input string for conversion");let b=parseInt(y.substring(0,2),10);if(isNaN(b.valueOf()))throw new Error("Wrong input string for conversion");if(a=u*b,y.length===4){if(b=parseInt(y.substring(2,4),10),isNaN(b.valueOf()))throw new Error("Wrong input string for conversion");c=u*b}}}let f=n.indexOf(".");if(f===-1&&(f=n.indexOf(",")),f!==-1){let u=new Number(`0${n.substring(f)}`);if(isNaN(u.valueOf()))throw new Error("Wrong input string for conversion");o=u.valueOf(),s=n.substring(0,f)}else s=n;switch(!0){case s.length===8:if(i=/(\d{4})(\d{2})(\d{2})/ig,f!==-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,f!==-1){let u=60*o;this.minute=Math.floor(u),u=60*(u-this.minute),this.second=Math.floor(u),u=1e3*(u-this.second),this.millisecond=Math.floor(u)}break;case s.length===12:if(i=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})/ig,f!==-1){let u=60*o;this.second=Math.floor(u),u=1e3*(u-this.second),this.millisecond=Math.floor(u)}break;case s.length===14:if(i=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/ig,f!==-1){let u=1e3*o;this.millisecond=Math.floor(u)}break;default:throw new Error("Wrong input string for conversion")}let l=i.exec(s);if(l===null)throw new Error("Wrong input string for conversion");for(let u=1;u<l.length;u++)switch(u){case 1:this.year=parseInt(l[u],10);break;case 2:this.month=parseInt(l[u],10);break;case 3:this.day=parseInt(l[u],10);break;case 4:this.hour=parseInt(l[u],10)+a;break;case 5:this.minute=parseInt(l[u],10)+c;break;case 6:this.second=parseInt(l[u],10);break;default:throw new Error("Wrong input string for conversion")}if(t===!1){let u=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);this.year=u.getUTCFullYear(),this.month=u.getUTCMonth(),this.day=u.getUTCDay(),this.hour=u.getUTCHours(),this.minute=u.getUTCMinutes(),this.second=u.getUTCSeconds(),this.millisecond=u.getUTCMilliseconds()}}toString(e="iso"){if(e==="iso"){let t=[];return t.push(Le(this.year,4)),t.push(Le(this.month,2)),t.push(Le(this.day,2)),t.push(Le(this.hour,2)),t.push(Le(this.minute,2)),t.push(Le(this.second,2)),this.millisecond!==0&&(t.push("."),t.push(Le(this.millisecond,3))),t.push("Z"),t.join("")}return super.toString(e)}toJSON(){return{...super.toJSON(),millisecond:this.millisecond}}};Pc=ms;I.GeneralizedTime=Pc;ms.NAME="GeneralizedTime";var Vc,ys=class extends At{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=31}};Vc=ys;I.DATE=Vc;ys.NAME="DATE";var Dc,bs=class extends At{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=32}};Dc=bs;I.TimeOfDay=Dc;bs.NAME="TimeOfDay";var Mc,ws=class extends At{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=33}};Mc=ws;I.DateTime=Mc;ws.NAME="DateTime";var Hc,xs=class extends At{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=34}};Hc=xs;I.Duration=Hc;xs.NAME="Duration";var Fc,vs=class extends At{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=14}};Fc=vs;I.TIME=Fc;vs.NAME="TIME";function fd(r){let{result:e}=Sr(r),t=e.valueBlock.value;return{n:D(ot(t[1].toBigInt()),"base64url"),e:D(ot(t[2].toBigInt()),"base64url"),d:D(ot(t[3].toBigInt()),"base64url"),p:D(ot(t[4].toBigInt()),"base64url"),q:D(ot(t[5].toBigInt()),"base64url"),dp:D(ot(t[6].toBigInt()),"base64url"),dq:D(ot(t[7].toBigInt()),"base64url"),qi:D(ot(t[8].toBigInt()),"base64url"),kty:"RSA",alg:"RS256"}}function hd(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 L("JWK was missing components","ERR_INVALID_PARAMETERS");let t=new ge({value:[new oe({value:0}),oe.fromBigInt(it(V(r.n,"base64url"))),oe.fromBigInt(it(V(r.e,"base64url"))),oe.fromBigInt(it(V(r.d,"base64url"))),oe.fromBigInt(it(V(r.p,"base64url"))),oe.fromBigInt(it(V(r.q,"base64url"))),oe.fromBigInt(it(V(r.dp,"base64url"))),oe.fromBigInt(it(V(r.dq,"base64url"))),oe.fromBigInt(it(V(r.qi,"base64url")))]}).toBER();return new Uint8Array(t,0,t.byteLength)}function dd(r){let{result:e}=Sr(r),t=e.valueBlock.value[1].valueBlock.value[0].valueBlock.value;return{kty:"RSA",n:D(ot(t[0].toBigInt()),"base64url"),e:D(ot(t[1].toBigInt()),"base64url")}}function pd(r){if(r.n==null||r.e==null)throw new L("JWK was missing components","ERR_INVALID_PARAMETERS");let t=new ge({value:[new ge({value:[new We({value:"1.2.840.113549.1.1.1"}),new Ft]}),new Ar({valueHex:new ge({value:[oe.fromBigInt(it(V(r.n,"base64url"))),oe.fromBigInt(it(V(r.e,"base64url")))]}).toBER()})]}).toBER();return new Uint8Array(t,0,t.byteLength)}function ot(r){let e=r.toString(16);e.length%2>0&&(e=`0${e}`);let t=e.length/2,n=new Uint8Array(t),s=0,o=0;for(;s<t;)n[s]=parseInt(e.slice(o,o+2),16),s+=1,o+=2;return n}function it(r){let e=[];return r.forEach(function(t){let n=t.toString(16);n.length%2>0&&(n=`0${n}`),e.push(n)}),BigInt("0x"+e.join(""))}var gd=16,ii=32,ai=1e4;async function md(r,e){let t=ke.get(),s=new ge({value:[new oe({value:0}),new ge({value:[new We({value:"1.2.840.113549.1.1.1"}),new Ft]}),new Bt({valueHex:r.marshal()})]}).toBER(),o=new Uint8Array(s,0,s.byteLength),i=nr(gd),a=await ti(Kr,e,i,{c:ai,dkLen:ii}),c=nr(16),f=await t.subtle.importKey("raw",a,"AES-CBC",!1,["encrypt"]),l=await t.subtle.encrypt({name:"AES-CBC",iv:c},f,o),u=new ge({value:[new Bt({valueHex:i}),new oe({value:ai}),new oe({value:ii}),new ge({value:[new We({value:"1.2.840.113549.2.11"}),new Ft]})]}),h=new ge({value:[new We({value:"1.2.840.113549.1.5.13"}),new ge({value:[new ge({value:[new We({value:"1.2.840.113549.1.5.12"}),u]}),new ge({value:[new We({value:"2.16.840.1.101.3.4.1.42"}),new Bt({valueHex:c})]})]})]}),b=new ge({value:[h,new Bt({valueHex:l})]}).toBER(),m=new Uint8Array(b,0,b.byteLength);return["-----BEGIN ENCRYPTED PRIVATE KEY-----",...D(m,"base64pad").split(/(.{64})/).filter(Boolean),"-----END ENCRYPTED PRIVATE KEY-----"].join(`
7
+ `)}async function yd(r,e){let t=ke.get(),n;if(r.includes("-----BEGIN ENCRYPTED PRIVATE KEY-----")){let s=V(r.replace("-----BEGIN ENCRYPTED PRIVATE KEY-----","").replace("-----END ENCRYPTED PRIVATE KEY-----","").replace(/\n/g,"").trim(),"base64pad"),{result:o}=Sr(s),{iv:i,salt:a,iterations:c,keySize:f,cipherText:l}=bd(o),u=await ti(Kr,e,a,{c,dkLen:f}),h=await t.subtle.importKey("raw",u,"AES-CBC",!1,["decrypt"]),y=sn(await t.subtle.decrypt({name:"AES-CBC",iv:i},h,l)),{result:b}=Sr(y);n=Kc(b)}else if(r.includes("-----BEGIN PRIVATE KEY-----")){let s=V(r.replace("-----BEGIN PRIVATE KEY-----","").replace("-----END PRIVATE KEY-----","").replace(/\n/g,"").trim(),"base64pad"),{result:o}=Sr(s);n=Kc(o)}else throw new L("Could not parse private key from PEM data","ERR_INVALID_PARAMETERS");return ci(n)}function bd(r){let e=r.valueBlock.value[0];if(e.valueBlock.value[0].toString()!=="OBJECT IDENTIFIER : 1.2.840.113549.1.5.13")throw new L("Only pkcs5PBES2 encrypted private keys are supported","ERR_INVALID_PARAMS");let n=e.valueBlock.value[1].valueBlock.value[0];if(n.valueBlock.value[0].toString()!=="OBJECT IDENTIFIER : 1.2.840.113549.1.5.12")throw new L("Only pkcs5PBKDF2 key derivation functions are supported","ERR_INVALID_PARAMS");let o=n.valueBlock.value[1],i=sn(o.valueBlock.value[0].getValue()),a=ai,c=ii;if(o.valueBlock.value.length===3)a=Number(o.valueBlock.value[1].toBigInt()),c=Number(o.valueBlock.value[2].toBigInt());else if(o.valueBlock.value.length===2)throw new L("Could not derive key size and iterations from PEM file - please use @libp2p/rsa to re-import your key","ERR_INVALID_PARAMS");let f=e.valueBlock.value[1].valueBlock.value[1],l=f.valueBlock.value[0].toString();if(l!=="OBJECT IDENTIFIER : 1.2.840.113549.3.7"){if(l!=="OBJECT IDENTIFIER : 1.3.14.3.2.7"){if(l!=="OBJECT IDENTIFIER : 2.16.840.1.101.3.4.1.2"){if(l!=="OBJECT IDENTIFIER : 2.16.840.1.101.3.4.1.22"){if(l!=="OBJECT IDENTIFIER : 2.16.840.1.101.3.4.1.42")throw new L("Only AES-CBC encryption schemes are supported","ERR_INVALID_PARAMS")}}}}let u=sn(f.valueBlock.value[1].getValue());return{cipherText:sn(r.valueBlock.value[1].getValue()),salt:i,iterations:a,keySize:c,iv:u}}function Kc(r){return sn(r.valueBlock.value[2].getValue())}function sn(r){return new Uint8Array(r,0,r.byteLength)}async function qc(r){let e=await ke.get().subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:r,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-256"}},!0,["sign","verify"]),t=await Gc(e);return{privateKey:t[0],publicKey:t[1]}}async function li(r){let t=[await ke.get().subtle.importKey("jwk",r,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["sign"]),await wd(r)],n=await Gc({privateKey:t[0],publicKey:t[1]});return{privateKey:n[0],publicKey:n[1]}}async function $c(r,e){let t=await ke.get().subtle.importKey("jwk",r,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["sign"]),n=await ke.get().subtle.sign({name:"RSASSA-PKCS1-v1_5"},t,e instanceof Uint8Array?e:e.subarray());return new Uint8Array(n,0,n.byteLength)}async function zc(r,e,t){let n=await ke.get().subtle.importKey("jwk",r,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["verify"]);return ke.get().subtle.verify({name:"RSASSA-PKCS1-v1_5"},n,e,t instanceof Uint8Array?t:t.subarray())}async function Gc(r){if(r.privateKey==null||r.publicKey==null)throw new L("Private and public key are required","ERR_INVALID_PARAMETERS");return Promise.all([ke.get().subtle.exportKey("jwk",r.privateKey),ke.get().subtle.exportKey("jwk",r.publicKey)])}async function wd(r){return ke.get().subtle.importKey("jwk",{kty:r.kty,n:r.n,e:r.e},{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["verify"])}function Bs(r){if(r.kty!=="RSA")throw new L("invalid key type","ERR_INVALID_KEY_TYPE");if(r.n==null)throw new L("invalid key modulus","ERR_INVALID_KEY_MODULUS");return V(r.n,"base64url").length*8}var an=8192,on=class{_key;constructor(e){this._key=e}verify(e,t){return zc(this._key,t,e)}marshal(){return Kt.jwkToPkix(this._key)}get bytes(){return rt.encode({Type:ee.RSA,Data:this.marshal()}).subarray()}equals(e){return pe(this.bytes,e.bytes)}hash(){let e=be.digest(this.bytes);return Ve(e)?e.then(({bytes:t})=>t):e.bytes}},kr=class{_key;_publicKey;constructor(e,t){this._key=e,this._publicKey=t}genSecret(){return nr(16)}sign(e){return $c(this._key,e)}get public(){if(this._publicKey==null)throw new L("public key not provided","ERR_PUBKEY_NOT_PROVIDED");return new on(this._publicKey)}marshal(){return Kt.jwkToPkcs1(this._key)}get bytes(){return nt.encode({Type:ee.RSA,Data:this.marshal()}).subarray()}equals(e){return pe(this.bytes,e.bytes)}hash(){let e=be.digest(this.bytes);return Ve(e)?e.then(({bytes:t})=>t):e.bytes}async id(){let e=await this.public.hash();return D(e,"base58btc")}async export(e,t="pkcs-8"){if(t==="pkcs-8")return Kt.exportToPem(this,e);if(t==="libp2p-key")return xr(this.bytes,e);throw new L(`export format '${t}' is not supported`,"ERR_INVALID_EXPORT_FORMAT")}};async function ci(r){let e=Kt.pkcs1ToJwk(r);if(Bs(e)>an)throw new L("key size is too large","ERR_KEY_SIZE_TOO_LARGE");let t=await li(e);return new kr(t.privateKey,t.publicKey)}function vd(r){let e=Kt.pkixToJwk(r);if(Bs(e)>an)throw new L("key size is too large","ERR_KEY_SIZE_TOO_LARGE");return new on(e)}async function Ed(r){if(Bs(r)>an)throw new L("key size is too large","ERR_KEY_SIZE_TOO_LARGE");let e=await li(r);return new kr(e.privateKey,e.publicKey)}async function Bd(r){if(r>an)throw new L("key size is too large","ERR_KEY_SIZE_TOO_LARGE");let e=await qc(r);return new kr(e.privateKey,e.publicKey)}var gi={};de(gi,{Secp256k1PrivateKey:()=>ln,Secp256k1PublicKey:()=>cn,generateKeyPair:()=>Pd,unmarshalSecp256k1PrivateKey:()=>Ud,unmarshalSecp256k1PublicKey:()=>Od});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]),qt=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),$t=new Uint32Array(64),fi=class extends mr{constructor(){super(64,32,8,!1),this.A=qt[0]|0,this.B=qt[1]|0,this.C=qt[2]|0,this.D=qt[3]|0,this.E=qt[4]|0,this.F=qt[5]|0,this.G=qt[6]|0,this.H=qt[7]|0}get(){let{A:e,B:t,C:n,D:s,E:o,F:i,G:a,H:c}=this;return[e,t,n,s,o,i,a,c]}set(e,t,n,s,o,i,a,c){this.A=e|0,this.B=t|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(e,t){for(let u=0;u<16;u++,t+=4)$t[u]=e.getUint32(t,!1);for(let u=16;u<64;u++){let h=$t[u-15],y=$t[u-2],b=Fe(h,7)^Fe(h,18)^h>>>3,m=Fe(y,17)^Fe(y,19)^y>>>10;$t[u]=m+$t[u-7]+b+$t[u-16]|0}let{A:n,B:s,C:o,D:i,E:a,F:c,G:f,H:l}=this;for(let u=0;u<64;u++){let h=Fe(a,6)^Fe(a,11)^Fe(a,25),y=l+h+Sa(a,c,f)+Ad[u]+$t[u]|0,m=(Fe(n,2)^Fe(n,13)^Fe(n,22))+ka(n,s,o)|0;l=f,f=c,c=a,a=i+y|0,i=o,o=s,s=n,n=y+m|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,f=f+this.G|0,l=l+this.H|0,this.set(n,s,o,i,a,c,f,l)}roundClean(){$t.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var jc=xn(()=>new fi);function Wc(r){r.lowS!==void 0&&Ke("lowS",r.lowS),r.prehash!==void 0&&Ke("prehash",r.prehash)}function Id(r){let e=zr(r);tt(e,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});let{endo:t,Fp:n,a:s}=e;if(t){if(!n.eql(s,n.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if(typeof t!="object"||typeof t.beta!="bigint"||typeof t.splitScalar!="function")throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...e})}var{bytesToNumberBE:Sd,hexToBytes:kd}=Bn,kt={Err:class extends Error{constructor(e=""){super(e)}},_tlv:{encode:(r,e)=>{let{Err:t}=kt;if(r<0||r>256)throw new t("tlv.encode: wrong tag");if(e.length&1)throw new t("tlv.encode: unpadded data");let n=e.length/2,s=Yt(n);if(s.length/2&128)throw new t("tlv.encode: long form length too big");let o=n>127?Yt(s.length/2|128):"";return`${Yt(r)}${o}${s}${e}`},decode(r,e){let{Err:t}=kt,n=0;if(r<0||r>256)throw new t("tlv.encode: wrong tag");if(e.length<2||e[n++]!==r)throw new t("tlv.decode: wrong tlv");let s=e[n++],o=!!(s&128),i=0;if(!o)i=s;else{let c=s&127;if(!c)throw new t("tlv.decode(long): indefinite length not supported");if(c>4)throw new t("tlv.decode(long): byte length is too big");let f=e.subarray(n,n+c);if(f.length!==c)throw new t("tlv.decode: length bytes not complete");if(f[0]===0)throw new t("tlv.decode(long): zero leftmost byte");for(let l of f)i=i<<8|l;if(n+=c,i<128)throw new t("tlv.decode(long): not minimal encoding")}let a=e.subarray(n,n+i);if(a.length!==i)throw new t("tlv.decode: wrong value length");return{v:a,l:e.subarray(n+i)}}},_int:{encode(r){let{Err:e}=kt;if(r<Nt)throw new e("integer: negative integers are not allowed");let t=Yt(r);if(Number.parseInt(t[0],16)&8&&(t="00"+t),t.length&1)throw new e("unexpected assertion");return t},decode(r){let{Err:e}=kt;if(r[0]&128)throw new e("Invalid signature integer: negative");if(r[0]===0&&!(r[1]&128))throw new e("Invalid signature integer: unnecessary leading zero");return Sd(r)}},toSig(r){let{Err:e,_int:t,_tlv:n}=kt,s=typeof r=="string"?kd(r):r;yr(s);let{v:o,l:i}=n.decode(48,s);if(i.length)throw new e("Invalid signature: left bytes after parsing");let{v:a,l:c}=n.decode(2,o),{v:f,l}=n.decode(2,c);if(l.length)throw new e("Invalid signature: left bytes after parsing");return{r:t.decode(a),s:t.decode(f)}},hexFromSig(r){let{_tlv:e,_int:t}=kt,n=`${e.encode(2,t.encode(r.r))}${e.encode(2,t.encode(r.s))}`;return e.encode(48,n)}},Nt=BigInt(0),me=BigInt(1),ny=BigInt(2),Yc=BigInt(3),sy=BigInt(4);function Nd(r){let e=Id(r),{Fp:t}=e,n=Vt(e.n,e.nBitLength),s=e.toBytes||((m,d,x)=>{let E=d.toAffine();return bt(Uint8Array.from([4]),t.toBytes(E.x),t.toBytes(E.y))}),o=e.fromBytes||(m=>{let d=m.subarray(1),x=t.fromBytes(d.subarray(0,t.BYTES)),E=t.fromBytes(d.subarray(t.BYTES,2*t.BYTES));return{x,y:E}});function i(m){let{a:d,b:x}=e,E=t.sqr(m),g=t.mul(E,m);return t.add(t.add(g,t.mul(m,d)),x)}if(!t.eql(t.sqr(e.Gy),i(e.Gx)))throw new Error("bad generator point: equation left != right");function a(m){return qr(m,me,e.n)}function c(m){let{allowedPrivateKeyLengths:d,nByteLength:x,wrapPrivateKey:E,n:g}=e;if(d&&typeof m!="bigint"){if(Ut(m)&&(m=mt(m)),typeof m!="string"||!d.includes(m.length))throw new Error("Invalid key");m=m.padStart(x*2,"0")}let B;try{B=typeof m=="bigint"?m:yt(re("private key",m,x))}catch{throw new Error(`private key must be ${x} bytes, hex or bigint, not ${typeof m}`)}return E&&(B=Y(B,g)),_e("private key",B,me,g),B}function f(m){if(!(m instanceof h))throw new Error("ProjectivePoint expected")}let l=Xt((m,d)=>{let{px:x,py:E,pz:g}=m;if(t.eql(g,t.ONE))return{x,y:E};let B=m.is0();d==null&&(d=B?t.ONE:t.inv(g));let C=t.mul(x,d),_=t.mul(E,d),S=t.mul(g,d);if(B)return{x:t.ZERO,y:t.ZERO};if(!t.eql(S,t.ONE))throw new Error("invZ was invalid");return{x:C,y:_}}),u=Xt(m=>{if(m.is0()){if(e.allowInfinityPoint&&!t.is0(m.py))return;throw new Error("bad point: ZERO")}let{x:d,y:x}=m.toAffine();if(!t.isValid(d)||!t.isValid(x))throw new Error("bad point: x or y not FE");let E=t.sqr(x),g=i(d);if(!t.eql(E,g))throw new Error("bad point: equation left != right");if(!m.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class h{constructor(d,x,E){if(this.px=d,this.py=x,this.pz=E,d==null||!t.isValid(d))throw new Error("x required");if(x==null||!t.isValid(x))throw new Error("y required");if(E==null||!t.isValid(E))throw new Error("z required");Object.freeze(this)}static fromAffine(d){let{x,y:E}=d||{};if(!d||!t.isValid(x)||!t.isValid(E))throw new Error("invalid affine point");if(d instanceof h)throw new Error("projective point not allowed");let g=B=>t.eql(B,t.ZERO);return g(x)&&g(E)?h.ZERO:new h(x,E,t.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(d){let x=t.invertBatch(d.map(E=>E.pz));return d.map((E,g)=>E.toAffine(x[g])).map(h.fromAffine)}static fromHex(d){let x=h.fromAffine(o(re("pointHex",d)));return x.assertValidity(),x}static fromPrivateKey(d){return h.BASE.multiply(c(d))}static msm(d,x){return Sn(h,n,d,x)}_setWindowSize(d){b.setWindowSize(this,d)}assertValidity(){u(this)}hasEvenY(){let{y:d}=this.toAffine();if(t.isOdd)return!t.isOdd(d);throw new Error("Field doesn't support isOdd")}equals(d){f(d);let{px:x,py:E,pz:g}=this,{px:B,py:C,pz:_}=d,S=t.eql(t.mul(x,_),t.mul(B,g)),k=t.eql(t.mul(E,_),t.mul(C,g));return S&&k}negate(){return new h(this.px,t.neg(this.py),this.pz)}double(){let{a:d,b:x}=e,E=t.mul(x,Yc),{px:g,py:B,pz:C}=this,_=t.ZERO,S=t.ZERO,k=t.ZERO,T=t.mul(g,g),ie=t.mul(B,B),$=t.mul(C,C),M=t.mul(g,B);return M=t.add(M,M),k=t.mul(g,C),k=t.add(k,k),_=t.mul(d,k),S=t.mul(E,$),S=t.add(_,S),_=t.sub(ie,S),S=t.add(ie,S),S=t.mul(_,S),_=t.mul(M,_),k=t.mul(E,k),$=t.mul(d,$),M=t.sub(T,$),M=t.mul(d,M),M=t.add(M,k),k=t.add(T,T),T=t.add(k,T),T=t.add(T,$),T=t.mul(T,M),S=t.add(S,T),$=t.mul(B,C),$=t.add($,$),T=t.mul($,M),_=t.sub(_,T),k=t.mul($,ie),k=t.add(k,k),k=t.add(k,k),new h(_,S,k)}add(d){f(d);let{px:x,py:E,pz:g}=this,{px:B,py:C,pz:_}=d,S=t.ZERO,k=t.ZERO,T=t.ZERO,ie=e.a,$=t.mul(e.b,Yc),M=t.mul(x,B),ae=t.mul(E,C),A=t.mul(g,_),N=t.add(x,E),w=t.add(B,C);N=t.mul(N,w),w=t.add(M,ae),N=t.sub(N,w),w=t.add(x,g);let p=t.add(B,_);return w=t.mul(w,p),p=t.add(M,A),w=t.sub(w,p),p=t.add(E,g),S=t.add(C,_),p=t.mul(p,S),S=t.add(ae,A),p=t.sub(p,S),T=t.mul(ie,w),S=t.mul($,A),T=t.add(S,T),S=t.sub(ae,T),T=t.add(ae,T),k=t.mul(S,T),ae=t.add(M,M),ae=t.add(ae,M),A=t.mul(ie,A),w=t.mul($,w),ae=t.add(ae,A),A=t.sub(M,A),A=t.mul(ie,A),w=t.add(w,A),M=t.mul(ae,w),k=t.add(k,M),M=t.mul(p,w),S=t.mul(N,S),S=t.sub(S,M),M=t.mul(N,ae),T=t.mul(p,T),T=t.add(T,M),new h(S,k,T)}subtract(d){return this.add(d.negate())}is0(){return this.equals(h.ZERO)}wNAF(d){return b.wNAFCached(this,d,h.normalizeZ)}multiplyUnsafe(d){_e("scalar",d,Nt,e.n);let x=h.ZERO;if(d===Nt)return x;if(d===me)return this;let{endo:E}=e;if(!E)return b.unsafeLadder(this,d);let{k1neg:g,k1:B,k2neg:C,k2:_}=E.splitScalar(d),S=x,k=x,T=this;for(;B>Nt||_>Nt;)B&me&&(S=S.add(T)),_&me&&(k=k.add(T)),T=T.double(),B>>=me,_>>=me;return g&&(S=S.negate()),C&&(k=k.negate()),k=new h(t.mul(k.px,E.beta),k.py,k.pz),S.add(k)}multiply(d){let{endo:x,n:E}=e;_e("scalar",d,me,E);let g,B;if(x){let{k1neg:C,k1:_,k2neg:S,k2:k}=x.splitScalar(d),{p:T,f:ie}=this.wNAF(_),{p:$,f:M}=this.wNAF(k);T=b.constTimeNegate(C,T),$=b.constTimeNegate(S,$),$=new h(t.mul($.px,x.beta),$.py,$.pz),g=T.add($),B=ie.add(M)}else{let{p:C,f:_}=this.wNAF(d);g=C,B=_}return h.normalizeZ([g,B])[0]}multiplyAndAddUnsafe(d,x,E){let g=h.BASE,B=(_,S)=>S===Nt||S===me||!_.equals(g)?_.multiplyUnsafe(S):_.multiply(S),C=B(this,x).add(B(d,E));return C.is0()?void 0:C}toAffine(d){return l(this,d)}isTorsionFree(){let{h:d,isTorsionFree:x}=e;if(d===me)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}=e;return d===me?this:x?x(h,this):this.multiplyUnsafe(e.h)}toRawBytes(d=!0){return Ke("isCompressed",d),this.assertValidity(),s(h,this,d)}toHex(d=!0){return Ke("isCompressed",d),mt(this.toRawBytes(d))}}h.BASE=new h(e.Gx,e.Gy,t.ONE),h.ZERO=new h(t.ZERO,t.ONE,t.ZERO);let y=e.nBitLength,b=In(h,e.endo?Math.ceil(y/2):y);return{CURVE:e,ProjectivePoint:h,normPrivateKeyToScalar:c,weierstrassEquation:i,isWithinCurveOrder:a}}function Rd(r){let e=zr(r);return tt(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function Zc(r){let e=Rd(r),{Fp:t,n}=e,s=t.BYTES+1,o=2*t.BYTES+1;function i(A){return Y(A,n)}function a(A){return An(A,n)}let{ProjectivePoint:c,normPrivateKeyToScalar:f,weierstrassEquation:l,isWithinCurveOrder:u}=Nd({...e,toBytes(A,N,w){let p=N.toAffine(),v=t.toBytes(p.x),R=bt;return Ke("isCompressed",w),w?R(Uint8Array.from([N.hasEvenY()?2:3]),v):R(Uint8Array.from([4]),v,t.toBytes(p.y))},fromBytes(A){let N=A.length,w=A[0],p=A.subarray(1);if(N===s&&(w===2||w===3)){let v=yt(p);if(!qr(v,me,t.ORDER))throw new Error("Point is not on curve");let R=l(v),U;try{U=t.sqrt(R)}catch(q){let F=q instanceof Error?": "+q.message:"";throw new Error("Point is not on curve"+F)}let O=(U&me)===me;return(w&1)===1!==O&&(U=t.neg(U)),{x:v,y:U}}else if(N===o&&w===4){let v=t.fromBytes(p.subarray(0,t.BYTES)),R=t.fromBytes(p.subarray(t.BYTES,2*t.BYTES));return{x:v,y:R}}else throw new Error(`Point of length ${N} was invalid. Expected ${s} compressed bytes or ${o} uncompressed bytes`)}}),h=A=>mt(Pt(A,e.nByteLength));function y(A){let N=n>>me;return A>N}function b(A){return y(A)?i(-A):A}let m=(A,N,w)=>yt(A.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=e.nByteLength;return N=re("compactSignature",N,w*2),new d(m(N,0,w),m(N,w,2*w))}static fromDER(N){let{r:w,s:p}=kt.toSig(re("DER",N));return new d(w,p)}assertValidity(){_e("r",this.r,me,n),_e("s",this.s,me,n)}addRecoveryBit(N){return new d(this.r,this.s,N)}recoverPublicKey(N){let{r:w,s:p,recovery:v}=this,R=_(re("msgHash",N));if(v==null||![0,1,2,3].includes(v))throw new Error("recovery id invalid");let U=v===2||v===3?w+e.n:w;if(U>=t.ORDER)throw new Error("recovery id 2 or 3 invalid");let O=v&1?"03":"02",H=c.fromHex(O+h(U)),q=a(U),F=i(-R*q),W=i(p*q),J=c.BASE.multiplyAndAddUnsafe(H,F,W);if(!J)throw new Error("point at infinify");return J.assertValidity(),J}hasHighS(){return y(this.s)}normalizeS(){return this.hasHighS()?new d(this.r,i(-this.s),this.recovery):this}toDERRawBytes(){return Zt(this.toDERHex())}toDERHex(){return kt.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Zt(this.toCompactHex())}toCompactHex(){return h(this.r)+h(this.s)}}let x={isValidPrivateKey(A){try{return f(A),!0}catch{return!1}},normPrivateKeyToScalar:f,randomPrivateKey:()=>{let A=To(e.n);return Oa(e.randomBytes(A),e.n)},precompute(A=8,N=c.BASE){return N._setWindowSize(A),N.multiply(BigInt(3)),N}};function E(A,N=!0){return c.fromPrivateKey(A).toRawBytes(N)}function g(A){let N=Ut(A),w=typeof A=="string",p=(N||w)&&A.length;return N?p===s||p===o:w?p===2*s||p===2*o:A instanceof c}function B(A,N,w=!0){if(g(A))throw new Error("first arg must be private key");if(!g(N))throw new Error("second arg must be public key");return c.fromHex(N).multiply(f(A)).toRawBytes(w)}let C=e.bits2int||function(A){let N=yt(A),w=A.length*8-e.nBitLength;return w>0?N>>BigInt(w):N},_=e.bits2int_modN||function(A){return i(C(A))},S=$r(e.nBitLength);function k(A){return _e(`num < 2^${e.nBitLength}`,A,Nt,S),Pt(A,e.nByteLength)}function T(A,N,w=ie){if(["recovered","canonical"].some(he=>he in w))throw new Error("sign() legacy options not supported");let{hash:p,randomBytes:v}=e,{lowS:R,prehash:U,extraEntropy:O}=w;R==null&&(R=!0),A=re("msgHash",A),Wc(w),U&&(A=re("prehashed msgHash",p(A)));let H=_(A),q=f(N),F=[k(q),k(H)];if(O!=null&&O!==!1){let he=O===!0?v(t.BYTES):O;F.push(re("extraEntropy",he))}let W=bt(...F),J=H;function fe(he){let ye=C(he);if(!u(ye))return;let Ie=a(ye),ce=c.BASE.multiply(ye).toAffine(),Re=i(ce.x);if(Re===Nt)return;let ut=i(Ie*i(J+Re*q));if(ut===Nt)return;let Pr=(ce.x===Re?0:2)|Number(ce.y&me),Vr=ut;return R&&y(ut)&&(Vr=b(ut),Pr^=1),new d(Re,Vr,Pr)}return{seed:W,k2sig:fe}}let ie={lowS:e.lowS,prehash:!1},$={lowS:e.lowS,prehash:!1};function M(A,N,w=ie){let{seed:p,k2sig:v}=T(A,N,w),R=e;return So(R.hash.outputLen,R.nByteLength,R.hmac)(p,v)}c.BASE._setWindowSize(8);function ae(A,N,w,p=$){let v=A;if(N=re("msgHash",N),w=re("publicKey",w),"strict"in p)throw new Error("options.strict was renamed to lowS");Wc(p);let{lowS:R,prehash:U}=p,O,H;try{if(typeof v=="string"||Ut(v))try{O=d.fromDER(v)}catch(ce){if(!(ce instanceof kt.Err))throw ce;O=d.fromCompact(v)}else if(typeof v=="object"&&typeof v.r=="bigint"&&typeof v.s=="bigint"){let{r:ce,s:Re}=v;O=new d(ce,Re)}else throw new Error("PARSE");H=c.fromHex(w)}catch(ce){if(ce.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(R&&O.hasHighS())return!1;U&&(N=e.hash(N));let{r:q,s:F}=O,W=_(N),J=a(F),fe=i(W*J),he=i(q*J),ye=c.BASE.multiplyAndAddUnsafe(H,fe,he)?.toAffine();return ye?i(ye.x)===q:!1}return{CURVE:e,getPublicKey:E,getSharedSecret:B,sign:M,verify:ae,ProjectivePoint:c,Signature:d,utils:x}}function Td(r){return{hash:r,hmac:(e,...t)=>Yr(r,e,bo(...t)),randomBytes:gr}}function Jc(r,e){let t=n=>Zc({...r,...Td(n)});return Object.freeze({...t(e),create:t})}var el=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),Xc=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),_d=BigInt(1),hi=BigInt(2),Qc=(r,e)=>(r+e/hi)/e;function Cd(r){let e=el,t=BigInt(3),n=BigInt(6),s=BigInt(11),o=BigInt(22),i=BigInt(23),a=BigInt(44),c=BigInt(88),f=r*r*r%e,l=f*f*r%e,u=Q(l,t,e)*l%e,h=Q(u,t,e)*l%e,y=Q(h,hi,e)*f%e,b=Q(y,s,e)*y%e,m=Q(b,o,e)*b%e,d=Q(m,a,e)*m%e,x=Q(d,c,e)*d%e,E=Q(x,a,e)*m%e,g=Q(E,t,e)*l%e,B=Q(g,i,e)*b%e,C=Q(B,n,e)*f%e,_=Q(C,hi,e);if(!di.eql(di.sqr(_),r))throw new Error("Cannot find square root");return _}var di=Vt(el,void 0,void 0,{sqrt:Cd}),Ze=Jc({a:BigInt(0),b:BigInt(7),Fp:di,n:Xc,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:r=>{let e=Xc,t=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-_d*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),s=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),o=t,i=BigInt("0x100000000000000000000000000000000"),a=Qc(o*r,e),c=Qc(-n*r,e),f=Y(r-a*t-c*s,e),l=Y(-a*n-c*o,e),u=f>i,h=l>i;if(u&&(f=e-f),h&&(l=e-l),f>i||l>i)throw new Error("splitScalar: Endomorphism failed, k="+r);return{k1neg:u,k1:f,k2neg:h,k2:l}}}},jc),dy=BigInt(0);var py=Ze.ProjectivePoint;function tl(){return Ze.utils.randomPrivateKey()}function rl(r,e){let t=be.digest(e instanceof Uint8Array?e:e.subarray());if(Ve(t))return t.then(({digest:n})=>Ze.sign(n,r).toDERRawBytes()).catch(n=>{throw new L(String(n),"ERR_INVALID_INPUT")});try{return Ze.sign(t.digest,r).toDERRawBytes()}catch(n){throw new L(String(n),"ERR_INVALID_INPUT")}}function nl(r,e,t){let n=be.digest(t instanceof Uint8Array?t:t.subarray());if(Ve(n))return n.then(({digest:s})=>Ze.verify(e,s,r)).catch(s=>{throw new L(String(s),"ERR_INVALID_INPUT")});try{return Ze.verify(e,n.digest,r)}catch(s){throw new L(String(s),"ERR_INVALID_INPUT")}}function sl(r){return Ze.ProjectivePoint.fromHex(r).toRawBytes(!0)}function ol(r){try{Ze.getPublicKey(r,!0)}catch(e){throw new L(String(e),"ERR_INVALID_PRIVATE_KEY")}}function pi(r){try{Ze.ProjectivePoint.fromHex(r)}catch(e){throw new L(String(e),"ERR_INVALID_PUBLIC_KEY")}}function il(r){try{return Ze.getPublicKey(r,!0)}catch(e){throw new L(String(e),"ERR_INVALID_PRIVATE_KEY")}}var cn=class{_key;constructor(e){pi(e),this._key=e}verify(e,t){return nl(this._key,t,e)}marshal(){return sl(this._key)}get bytes(){return rt.encode({Type:ee.Secp256k1,Data:this.marshal()}).subarray()}equals(e){return pe(this.bytes,e.bytes)}async hash(){let e=be.digest(this.bytes),t;return Ve(e)?{bytes:t}=await e:t=e.bytes,t}},ln=class{_key;_publicKey;constructor(e,t){this._key=e,this._publicKey=t??il(e),ol(this._key),pi(this._publicKey)}sign(e){return rl(this._key,e)}get public(){return new cn(this._publicKey)}marshal(){return this._key}get bytes(){return nt.encode({Type:ee.Secp256k1,Data:this.marshal()}).subarray()}equals(e){return pe(this.bytes,e.bytes)}hash(){let e=be.digest(this.bytes);return Ve(e)?e.then(({bytes:t})=>t):e.bytes}async id(){let e=await this.public.hash();return D(e,"base58btc")}async export(e,t="libp2p-key"){if(t==="libp2p-key")return xr(this.bytes,e);throw new L(`export format '${t}' is not supported`,"ERR_INVALID_EXPORT_FORMAT")}};function Ud(r){return new ln(r)}function Od(r){return new cn(r)}async function Pd(){let r=tl();return new ln(r)}var or={rsa:ui,ed25519:ei,secp256k1:gi};function al(r){let e=Object.keys(or).join(" / ");return new L(`invalid or unsupported key type ${r}. Must be ${e}`,"ERR_UNSUPPORTED_KEY_TYPE")}function cl(r){let e=rt.decode(r),t=e.Data??new Uint8Array;switch(e.Type){case ee.RSA:return or.rsa.unmarshalRsaPublicKey(t);case ee.Ed25519:return or.ed25519.unmarshalEd25519PublicKey(t);case ee.Secp256k1:return or.secp256k1.unmarshalSecp256k1PublicKey(t);default:throw al(e.Type??"unknown")}}async function ll(r){let e=nt.decode(r),t=e.Data??new Uint8Array;switch(e.Type){case ee.RSA:return or.rsa.unmarshalRsaPrivateKey(t);case ee.Ed25519:return or.ed25519.unmarshalEd25519PrivateKey(t);case ee.Secp256k1:return or.secp256k1.unmarshalSecp256k1PrivateKey(t);default:throw al(e.Type??"RSA")}}var fl=Symbol.for("nodejs.util.inspect.custom"),ul=Object.values(Tt).map(r=>r.decoder).reduce((r,e)=>r.or(e),Tt.identity.decoder),hl=114,bi=36,wi=37,un=class{type;multihash;privateKey;publicKey;string;constructor(e){this.type=e.type,this.multihash=e.multihash,this.privateKey=e.privateKey,Object.defineProperty(this,"string",{enumerable:!1,writable:!0})}get[Symbol.toStringTag](){return`PeerId(${this.toString()})`}[js]=!0;toString(){return this.string==null&&(this.string=ne.encode(this.multihash.bytes).slice(1)),this.string}toCID(){return Pe.createV1(hl,this.multihash)}toBytes(){return this.multihash.bytes}toJSON(){return this.toString()}equals(e){if(e==null)return!1;if(e instanceof Uint8Array)return pe(this.multihash.bytes,e);if(typeof e=="string")return Vd(e).equals(this);if(e?.multihash?.bytes!=null)return pe(this.multihash.bytes,e.multihash.bytes);throw new Error("not valid Id")}[fl](){return`PeerId(${this.toString()})`}},Nr=class extends un{type="RSA";publicKey;constructor(e){super({...e,type:"RSA"}),this.publicKey=e.publicKey}},Rr=class extends un{type="Ed25519";publicKey;constructor(e){super({...e,type:"Ed25519"}),this.publicKey=e.multihash.digest}},Tr=class extends un{type="secp256k1";publicKey;constructor(e){super({...e,type:"secp256k1"}),this.publicKey=e.multihash.digest}},mi=2336,yi=class{type="url";multihash;privateKey;publicKey;url;constructor(e){this.url=e.toString(),this.multihash=ht.digest(V(this.url))}[fl](){return`PeerId(${this.url})`}[js]=!0;toString(){return this.toCID().toString()}toCID(){return Pe.createV1(mi,this.multihash)}toBytes(){return this.toCID().bytes}equals(e){return e==null?!1:(e instanceof Uint8Array&&(e=D(e)),e.toString()===this.toString())}};function Vd(r,e){if(e=e??ul,r.charAt(0)==="1"||r.charAt(0)==="Q"){let t=Gt(ne.decode(`z${r}`));return r.startsWith("12D")?new Rr({multihash:t}):r.startsWith("16U")?new Tr({multihash:t}):new Nr({multihash:t})}return xi(ul.decode(r))}function xi(r){try{let e=Gt(r);if(e.code===ht.code){if(e.digest.length===bi)return new Rr({multihash:e});if(e.digest.length===wi)return new Tr({multihash:e})}if(e.code===be.code)return new Nr({multihash:e})}catch{return Dd(Pe.decode(r))}throw new Error("Supplied PeerID CID is invalid")}function Dd(r){if(r?.multihash==null||r.version==null||r.version===1&&r.code!==hl&&r.code!==mi)throw new Error("Supplied PeerID CID is invalid");if(r.code===mi){let t=D(r.multihash.digest);return new yi(new URL(t))}let e=r.multihash;if(e.code===be.code)return new Nr({multihash:r.multihash});if(e.code===ht.code){if(e.digest.length===bi)return new Rr({multihash:r.multihash});if(e.digest.length===wi)return new Tr({multihash:r.multihash})}throw new Error("Supplied PeerID CID is invalid")}async function _r(r,e){return r.length===bi?new Rr({multihash:et(ht.code,r),privateKey:e}):r.length===wi?new Tr({multihash:et(ht.code,r),privateKey:e}):new Nr({multihash:await be.digest(r),publicKey:r,privateKey:e})}var pl=Symbol.for("@achingbrain/uint8arraylist");function dl(r,e){if(e==null||e<0)throw new RangeError("index is out of bounds");let t=0;for(let n of r){let s=t+n.byteLength;if(e<s)return{buf:n,index:e-t};t=s}throw new RangeError("index is out of bounds")}function As(r){return!!r?.[pl]}var Je=class r{bufs;length;[pl]=!0;constructor(...e){this.bufs=[],this.length=0,e.length>0&&this.appendAll(e)}*[Symbol.iterator](){yield*this.bufs}get byteLength(){return this.length}append(...e){this.appendAll(e)}appendAll(e){let t=0;for(let n of e)if(n instanceof Uint8Array)t+=n.byteLength,this.bufs.push(n);else if(As(n))t+=n.byteLength,this.bufs.push(...n.bufs);else throw new Error("Could not append value, must be an Uint8Array or a Uint8ArrayList");this.length+=t}prepend(...e){this.prependAll(e)}prependAll(e){let t=0;for(let n of e.reverse())if(n instanceof Uint8Array)t+=n.byteLength,this.bufs.unshift(n);else if(As(n))t+=n.byteLength,this.bufs.unshift(...n.bufs);else throw new Error("Could not prepend value, must be an Uint8Array or a Uint8ArrayList");this.length+=t}get(e){let t=dl(this.bufs,e);return t.buf[t.index]}set(e,t){let n=dl(this.bufs,e);n.buf[n.index]=t}write(e,t=0){if(e instanceof Uint8Array)for(let n=0;n<e.length;n++)this.set(t+n,e[n]);else if(As(e))for(let n=0;n<e.length;n++)this.set(t+n,e.get(n));else throw new Error("Could not write value, must be an Uint8Array or a Uint8ArrayList")}consume(e){if(e=Math.trunc(e),!(Number.isNaN(e)||e<=0)){if(e===this.byteLength){this.bufs=[],this.length=0;return}for(;this.bufs.length>0;)if(e>=this.bufs[0].byteLength)e-=this.bufs[0].byteLength,this.length-=this.bufs[0].byteLength,this.bufs.shift();else{this.bufs[0]=this.bufs[0].subarray(e),this.length-=e;break}}}slice(e,t){let{bufs:n,length:s}=this._subList(e,t);return Se(n,s)}subarray(e,t){let{bufs:n,length:s}=this._subList(e,t);return n.length===1?n[0]:Se(n,s)}sublist(e,t){let{bufs:n,length:s}=this._subList(e,t),o=new r;return o.length=s,o.bufs=[...n],o}_subList(e,t){if(e=e??0,t=t??this.length,e<0&&(e=this.length+e),t<0&&(t=this.length+t),e<0||t>this.length)throw new RangeError("index is out of bounds");if(e===t)return{bufs:[],length:0};if(e===0&&t===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,e>=c)continue;let f=e>=a&&e<c,l=t>a&&t<=c;if(f&&l){if(e===a&&t===c){n.push(i);break}let u=e-a;n.push(i.subarray(u,u+(t-e)));break}if(f){if(e===0){n.push(i);continue}n.push(i.subarray(e-a));continue}if(l){if(t===c){n.push(i);break}n.push(i.subarray(0,t-a));break}n.push(i)}return{bufs:n,length:t-e}}indexOf(e,t=0){if(!As(e)&&!(e instanceof Uint8Array))throw new TypeError('The "value" argument must be a Uint8ArrayList or Uint8Array');let n=e instanceof Uint8Array?e:e.subarray();if(t=Number(t??0),isNaN(t)&&(t=0),t<0&&(t=this.length+t),t<0&&(t=0),e.length===0)return t>this.length?this.length:t;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 u=0;u<o;u++)i[u]=-1;for(let u=0;u<s;u++)i[n[u]]=u;let a=i,c=this.byteLength-n.byteLength,f=n.byteLength-1,l;for(let u=t;u<=c;u+=l){l=0;for(let h=f;h>=0;h--){let y=this.get(u+h);if(n[h]!==y){l=Math.max(1,h-a[y]);break}}if(l===0)return u}return-1}getInt8(e){let t=this.subarray(e,e+1);return new DataView(t.buffer,t.byteOffset,t.byteLength).getInt8(0)}setInt8(e,t){let n=Te(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setInt8(0,t),this.write(n,e)}getInt16(e,t){let n=this.subarray(e,e+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt16(0,t)}setInt16(e,t,n){let s=dt(2);new DataView(s.buffer,s.byteOffset,s.byteLength).setInt16(0,t,n),this.write(s,e)}getInt32(e,t){let n=this.subarray(e,e+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt32(0,t)}setInt32(e,t,n){let s=dt(4);new DataView(s.buffer,s.byteOffset,s.byteLength).setInt32(0,t,n),this.write(s,e)}getBigInt64(e,t){let n=this.subarray(e,e+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigInt64(0,t)}setBigInt64(e,t,n){let s=dt(8);new DataView(s.buffer,s.byteOffset,s.byteLength).setBigInt64(0,t,n),this.write(s,e)}getUint8(e){let t=this.subarray(e,e+1);return new DataView(t.buffer,t.byteOffset,t.byteLength).getUint8(0)}setUint8(e,t){let n=Te(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setUint8(0,t),this.write(n,e)}getUint16(e,t){let n=this.subarray(e,e+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint16(0,t)}setUint16(e,t,n){let s=dt(2);new DataView(s.buffer,s.byteOffset,s.byteLength).setUint16(0,t,n),this.write(s,e)}getUint32(e,t){let n=this.subarray(e,e+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint32(0,t)}setUint32(e,t,n){let s=dt(4);new DataView(s.buffer,s.byteOffset,s.byteLength).setUint32(0,t,n),this.write(s,e)}getBigUint64(e,t){let n=this.subarray(e,e+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigUint64(0,t)}setBigUint64(e,t,n){let s=dt(8);new DataView(s.buffer,s.byteOffset,s.byteLength).setBigUint64(0,t,n),this.write(s,e)}getFloat32(e,t){let n=this.subarray(e,e+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat32(0,t)}setFloat32(e,t,n){let s=dt(4);new DataView(s.buffer,s.byteOffset,s.byteLength).setFloat32(0,t,n),this.write(s,e)}getFloat64(e,t){let n=this.subarray(e,e+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat64(0,t)}setFloat64(e,t,n){let s=dt(8);new DataView(s.buffer,s.byteOffset,s.byteLength).setFloat64(0,t,n),this.write(s,e)}equals(e){if(e==null||!(e instanceof r)||e.bufs.length!==this.bufs.length)return!1;for(let t=0;t<this.bufs.length;t++)if(!pe(this.bufs[t],e.bufs[t]))return!1;return!0}static fromUint8Arrays(e,t){let n=new r;return n.bufs=e,t==null&&(t=e.reduce((s,o)=>s+o.byteLength,0)),n.length=t,n}};var gl={ERR_SIGNATURE_NOT_VALID:"ERR_SIGNATURE_NOT_VALID"};var fn;(function(r){let e;r.codec=()=>(e==null&&(e=je((t,n,s={})=>{s.lengthDelimited!==!1&&n.fork(),t.publicKey!=null&&t.publicKey.byteLength>0&&(n.uint32(10),n.bytes(t.publicKey)),t.payloadType!=null&&t.payloadType.byteLength>0&&(n.uint32(18),n.bytes(t.payloadType)),t.payload!=null&&t.payload.byteLength>0&&(n.uint32(26),n.bytes(t.payload)),t.signature!=null&&t.signature.byteLength>0&&(n.uint32(42),n.bytes(t.signature)),s.lengthDelimited!==!1&&n.ldelim()},(t,n)=>{let s={publicKey:new Uint8Array(0),payloadType:new Uint8Array(0),payload:new Uint8Array(0),signature:new Uint8Array(0)},o=n==null?t.len:t.pos+n;for(;t.pos<o;){let i=t.uint32();switch(i>>>3){case 1:s.publicKey=t.bytes();break;case 2:s.payloadType=t.bytes();break;case 3:s.payload=t.bytes();break;case 5:s.signature=t.bytes();break;default:t.skipType(i&7);break}}return s})),e),r.encode=t=>Ge(t,r.codec()),r.decode=t=>ze(t,r.codec())})(fn||(fn={}));var at=class r{static createFromProtobuf=async e=>{let t=fn.decode(e),n=await _r(t.publicKey);return new r({peerId:n,payloadType:t.payloadType,payload:t.payload,signature:t.signature})};static seal=async(e,t)=>{if(t.privateKey==null)throw new Error("Missing private key");let n=e.domain,s=e.codec,o=e.marshal(),i=ml(n,s,o),c=await(await ll(t.privateKey)).sign(i.subarray());return new r({peerId:t,payloadType:s,payload:o,signature:c})};static openAndCertify=async(e,t)=>{let n=await r.createFromProtobuf(e);if(!await n.validate(t))throw new L("envelope signature is not valid for the given domain",gl.ERR_SIGNATURE_NOT_VALID);return n};peerId;payloadType;payload;signature;marshaled;constructor(e){let{peerId:t,payloadType:n,payload:s,signature:o}=e;this.peerId=t,this.payloadType=n,this.payload=s,this.signature=o}marshal(){if(this.peerId.publicKey==null)throw new Error("Missing public key");return this.marshaled==null&&(this.marshaled=fn.encode({publicKey:this.peerId.publicKey,payloadType:this.payloadType,payload:this.payload.subarray(),signature:this.signature})),this.marshaled}equals(e){return pe(this.marshal(),e.marshal())}async validate(e){let t=ml(e,this.payloadType,this.payload);if(this.peerId.publicKey==null)throw new Error("Missing public key");return cl(this.peerId.publicKey).verify(t.subarray(),this.signature)}},ml=(r,e,t)=>{let n=V(r),s=De(n.byteLength),o=De(e.length),i=De(t.length);return new Je(s,n,o,e,i,t)};function yl(r,e){let t=(n,s)=>n.toString().localeCompare(s.toString());return r.length!==e.length?!1:(e.sort(t),r.sort(t).every((n,s)=>e[s].equals(n)))}var Is=class{index=0;input="";new(e){return this.index=0,this.input=e,this}readAtomically(e){let t=this.index,n=e();return n===void 0&&(this.index=t),n}parseWith(e){let t=e();if(this.index===this.input.length)return t}peekChar(){if(!(this.index>=this.input.length))return this.input[this.index]}readChar(){if(!(this.index>=this.input.length))return this.input[this.index++]}readGivenChar(e){return this.readAtomically(()=>{let t=this.readChar();if(t===e)return t})}readSeparator(e,t,n){return this.readAtomically(()=>{if(!(t>0&&this.readGivenChar(e)===void 0))return n()})}readNumber(e,t,n,s){return this.readAtomically(()=>{let o=0,i=0,a=this.peekChar();if(a===void 0)return;let c=a==="0",f=2**(8*s)-1;for(;;){let l=this.readAtomically(()=>{let u=this.readChar();if(u===void 0)return;let h=Number.parseInt(u,e);if(!Number.isNaN(h))return h});if(l===void 0)break;if(o*=e,o+=l,o>f||(i+=1,t!==void 0&&i>t))return}if(i!==0)return!n&&c&&i>1?void 0:o})}readIPv4Addr(){return this.readAtomically(()=>{let e=new Uint8Array(4);for(let t=0;t<e.length;t++){let n=this.readSeparator(".",t,()=>this.readNumber(10,3,!1,1));if(n===void 0)return;e[t]=n}return e})}readIPv6Addr(){let e=t=>{for(let n=0;n<t.length/2;n++){let s=n*2;if(n<t.length-3){let i=this.readSeparator(":",n,()=>this.readIPv4Addr());if(i!==void 0)return t[s]=i[0],t[s+1]=i[1],t[s+2]=i[2],t[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];t[s]=o>>8,t[s+1]=o&255}return[t.length,!1]};return this.readAtomically(()=>{let t=new Uint8Array(16),[n,s]=e(t);if(n===16)return t;if(s||this.readGivenChar(":")===void 0||this.readGivenChar(":")===void 0)return;let o=new Uint8Array(14),i=16-(n+2),[a]=e(o.subarray(0,i));return t.set(o.subarray(0,a),16-a),t})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var bl=45,Md=15,Cr=new Is;function vi(r){if(!(r.length>Md))return Cr.new(r).parseWith(()=>Cr.readIPv4Addr())}function Ei(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>bl))return Cr.new(r).parseWith(()=>Cr.readIPv6Addr())}function Ss(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>bl))return Cr.new(r).parseWith(()=>Cr.readIPAddr())}var ub=parseInt("0xFFFF",16),fb=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);function ks(r){return!!vi(r)}function Ns(r){return!!Ei(r)}function Rs(r){return!!Ss(r)}var vl=ks,$d=Ns,Bi=function(r){let e=0;if(r=r.toString().trim(),vl(r)){let t=new Uint8Array(e+4);return r.split(/\./g).forEach(n=>{t[e++]=parseInt(n,10)&255}),t}if($d(r)){let t=r.split(":",8),n;for(n=0;n<t.length;n++){let o=vl(t[n]),i;o&&(i=Bi(t[n]),t[n]=D(i.slice(0,2),"base16")),i!=null&&++n<8&&t.splice(n,0,D(i.slice(2,4),"base16"))}if(t[0]==="")for(;t.length<8;)t.unshift("0");else if(t[t.length-1]==="")for(;t.length<8;)t.push("0");else if(t.length<8){for(n=0;n<t.length&&t[n]!=="";n++);let o=[n,1];for(n=9-t.length;n>0;n--)o.push("0");t.splice.apply(t,o)}let s=new Uint8Array(e+16);for(n=0;n<t.length;n++){let o=parseInt(t[n],16);s[e++]=o>>8&255,s[e++]=o&255}return s}throw new Error("invalid ip address")},El=function(r,e=0,t){e=~~e,t=t??r.length-e;let n=new DataView(r.buffer);if(t===4){let s=[];for(let o=0;o<t;o++)s.push(r[e+o]);return s.join(".")}if(t===16){let s=[];for(let o=0;o<t;o+=2)s.push(n.getUint16(e+o).toString(16));return s.join(":").replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}return""};var Lr={},Ai={},Gd=[[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"]];Gd.forEach(r=>{let e=jd(...r);Ai[e.code]=e,Lr[e.name]=e});function jd(r,e,t,n,s){return{code:r,size:e,name:t,resolvable:!!n,path:!!s}}function z(r){if(typeof r=="number"){if(Ai[r]!=null)return Ai[r];throw new Error(`no protocol with code: ${r}`)}else if(typeof r=="string"){if(Lr[r]!=null)return Lr[r];throw new Error(`no protocol with name: ${r}`)}throw new Error(`invalid protocol id type: ${typeof r}`)}var Wb=z("ip4"),Yb=z("ip6"),Zb=z("ipcidr");function Ni(r,e){switch(z(r).code){case 4:case 41:return Yd(e);case 42:return ki(e);case 6:case 273:case 33:case 132:return Il(e).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return ki(e);case 421:return Qd(e);case 444:return Al(e);case 445:return Al(e);case 466:return Xd(e);case 481:return globalThis.encodeURIComponent(ki(e));default:return D(e,"base16")}}function Ri(r,e){switch(z(r).code){case 4:return Bl(e);case 41:return Bl(e);case 42:return Si(e);case 6:case 273:case 33:case 132:return Ti(parseInt(e,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return Si(e);case 421:return Zd(e);case 444:return ep(e);case 445:return tp(e);case 466:return Jd(e);case 481:return Si(globalThis.decodeURIComponent(e));default:return V(e,"base16")}}var Ii=Object.values(Tt).map(r=>r.decoder),Wd=function(){let r=Ii[0].or(Ii[1]);return Ii.slice(2).forEach(e=>r=r.or(e)),r}();function Bl(r){if(!Rs(r))throw new Error("invalid ip address");return Bi(r)}function Yd(r){let e=El(r,0,r.length);if(e==null)throw new Error("ipBuff is required");if(!Rs(e))throw new Error("invalid ip address");return e}function Ti(r){let e=new ArrayBuffer(2);return new DataView(e).setUint16(0,r),new Uint8Array(e)}function Il(r){return new DataView(r.buffer).getUint16(r.byteOffset)}function Si(r){let e=V(r),t=Uint8Array.from(De(e.length));return Se([t,e],t.length+e.length)}function ki(r){let e=xt(r);if(r=r.slice(Ee(e)),r.length!==e)throw new Error("inconsistent lengths");return D(r)}function Zd(r){let e;r[0]==="Q"||r[0]==="1"?e=Gt(ne.decode(`z${r}`)).bytes:e=Pe.parse(r).multihash.bytes;let t=Uint8Array.from(De(e.length));return Se([t,e],t.length+e.length)}function Jd(r){let e=Wd.decode(r),t=Uint8Array.from(De(e.length));return Se([t,e],t.length+e.length)}function Xd(r){let e=xt(r),t=r.slice(Ee(e));if(t.length!==e)throw new Error("inconsistent lengths");return"u"+D(t,"base64url")}function Qd(r){let e=xt(r),t=r.slice(Ee(e));if(t.length!==e)throw new Error("inconsistent lengths");return D(t,"base58btc")}function ep(r){let e=r.split(":");if(e.length!==2)throw new Error(`failed to parse onion addr: ["'${e.join('", "')}'"]' does not contain a port number`);if(e[0].length!==16)throw new Error(`failed to parse onion addr: ${e[0]} not a Tor onion address.`);let t=pt.decode("b"+e[0]),n=parseInt(e[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let s=Ti(n);return Se([t,s],t.length+s.length)}function tp(r){let e=r.split(":");if(e.length!==2)throw new Error(`failed to parse onion addr: ["'${e.join('", "')}'"]' does not contain a port number`);if(e[0].length!==56)throw new Error(`failed to parse onion addr: ${e[0]} not a Tor onion3 address.`);let t=pt.decode(`b${e[0]}`),n=parseInt(e[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let s=Ti(n);return Se([t,s],t.length+s.length)}function Al(r){let e=r.slice(0,r.length-2),t=r.slice(r.length-2),n=D(e,"base32"),s=Il(t);return`${n}:${s}`}function Sl(r){r=_i(r);let e=[],t=[],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){e.push([a.code]),t.push([a.code]);continue}if(o++,o>=s.length)throw Nl("invalid address: "+r);if(a.path===!0){n=_i(s.slice(o).join("/")),e.push([a.code,Ri(a.code,n)]),t.push([a.code,n]);break}let c=Ri(a.code,s[o]);e.push([a.code,c]),t.push([a.code,Ni(a.code,c)])}return{string:kl(t),bytes:Li(e),tuples:e,stringTuples:t,path:n}}function Ci(r){let e=[],t=[],n=null,s=0;for(;s<r.length;){let o=xt(r,s),i=Ee(o),a=z(o),c=rp(a,r.slice(s+i));if(c===0){e.push([o]),t.push([o]),s+=i;continue}let f=r.slice(s+i,s+i+c);if(s+=c+i,s>r.length)throw Nl("Invalid address Uint8Array: "+D(r,"base16"));e.push([o,f]);let l=Ni(o,f);if(t.push([o,l]),a.path===!0){n=l;break}}return{bytes:Uint8Array.from(r),string:kl(t),tuples:e,stringTuples:t,path:n}}function kl(r){let e=[];return r.map(t=>{let n=z(t[0]);return e.push(n.name),t.length>1&&t[1]!=null&&e.push(t[1]),null}),_i(e.join("/"))}function Li(r){return Se(r.map(e=>{let t=z(e[0]),n=Uint8Array.from(De(t.code));return e.length>1&&e[1]!=null&&(n=Se([n,e[1]])),n}))}function rp(r,e){if(r.size>0)return r.size/8;if(r.size===0)return 0;{let t=xt(e instanceof Uint8Array?e:Uint8Array.from(e));return t+Ee(t)}}function _i(r){return"/"+r.trim().split("/").filter(e=>e).join("/")}function Nl(r){return new Error("Error parsing address: "+r)}var np=Symbol.for("nodejs.util.inspect.custom"),Ui=Symbol.for("@multiformats/js-multiaddr/multiaddr"),sp=[z("dns").code,z("dns4").code,z("dns6").code,z("dnsaddr").code],Ts=class r{bytes;#t;#e;#r;#n;[Ui]=!0;constructor(e){e==null&&(e="");let t;if(e instanceof Uint8Array)t=Ci(e);else if(typeof e=="string"){if(e.length>0&&e.charAt(0)!=="/")throw new Error(`multiaddr "${e}" must start with a "/"`);t=Sl(e)}else if(Tl(e))t=Ci(e.bytes);else throw new Error("addr must be a string, Buffer, or another Multiaddr");this.bytes=t.bytes,this.#t=t.string,this.#e=t.tuples,this.#r=t.stringTuples,this.#n=t.path}toString(){return this.#t}toJSON(){return this.toString()}toOptions(){let e,t,n,s,o="",i=z("tcp"),a=z("udp"),c=z("ip4"),f=z("ip6"),l=z("dns6"),u=z("ip6zone");for(let[y,b]of this.stringTuples())y===u.code&&(o=`%${b??""}`),sp.includes(y)&&(t=i.name,s=443,n=`${b??""}${o}`,e=y===l.code?6:4),(y===i.code||y===a.code)&&(t=z(y).name,s=parseInt(b??"")),(y===c.code||y===f.code)&&(t=z(y).name,n=`${b??""}${o}`,e=y===f.code?6:4);if(e==null||t==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:e,host:n,transport:t,port:s}}protos(){return this.#e.map(([e])=>Object.assign({},z(e)))}protoCodes(){return this.#e.map(([e])=>e)}protoNames(){return this.#e.map(([e])=>z(e).name)}tuples(){return this.#e}stringTuples(){return this.#r}encapsulate(e){return e=new r(e),new r(this.toString()+e.toString())}decapsulate(e){let t=e.toString(),n=this.toString(),s=n.lastIndexOf(t);if(s<0)throw new Error(`Address ${this.toString()} does not contain subaddress: ${e.toString()}`);return new r(n.slice(0,s))}decapsulateCode(e){let t=this.tuples();for(let n=t.length-1;n>=0;n--)if(t[n][0]===e)return new r(Li(t.slice(0,n)));return this}getPeerId(){try{let e=[];this.stringTuples().forEach(([n,s])=>{n===Lr.p2p.code&&e.push([n,s]),n===Lr["p2p-circuit"].code&&(e=[])});let t=e.pop();if(t?.[1]!=null){let n=t[1];return n[0]==="Q"||n[0]==="1"?D(ne.decode(`z${n}`),"base58btc"):D(Pe.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){return this.#n}equals(e){return pe(this.bytes,e.bytes)}async resolve(e){let t=this.protos().find(o=>o.resolvable);if(t==null)return[this];let n=Rl.get(t.name);if(n==null)throw new L(`no available resolver for ${t.name}`,"ERR_NO_AVAILABLE_RESOLVER");return(await n(this,e)).map(o=>ct(o))}nodeAddress(){let e=this.toOptions();if(e.transport!=="tcp"&&e.transport!=="udp")throw new Error(`multiaddr must have a valid format - no protocol with name: "${e.transport}". Must have a valid transport protocol: "{tcp, udp}"`);return{family:e.family,address:e.host,port:e.port}}isThinWaistAddress(e){let t=(e??this).protos();return!(t.length!==2||t[0].code!==4&&t[0].code!==41||t[1].code!==6&&t[1].code!==273)}[np](){return`Multiaddr(${this.#t})`}};var Rl=new Map;function Tl(r){return!!r?.[Ui]}function ct(r){return new Ts(r)}var _l="libp2p-peer-record",Cl=Uint8Array.from([3,1]);var hn;(function(r){let e;(function(n){let s;n.codec=()=>(s==null&&(s=je((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)=>{let a={multiaddr:new Uint8Array(0)},c=i==null?o.len:o.pos+i;for(;o.pos<c;){let f=o.uint32();switch(f>>>3){case 1:a.multiaddr=o.bytes();break;default:o.skipType(f&7);break}}return a})),s),n.encode=o=>Ge(o,n.codec()),n.decode=o=>ze(o,n.codec())})(e=r.AddressInfo||(r.AddressInfo={}));let t;r.codec=()=>(t==null&&(t=je((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)=>{let o={peerId:new Uint8Array(0),seq:0n,addresses:[]},i=s==null?n.len:n.pos+s;for(;n.pos<i;){let a=n.uint32();switch(a>>>3){case 1:o.peerId=n.bytes();break;case 2:o.seq=n.uint64();break;case 3:o.addresses.push(r.AddressInfo.codec().decode(n,n.uint32()));break;default:n.skipType(a&7);break}}return o})),t),r.encode=n=>Ge(n,r.codec()),r.decode=n=>ze(n,r.codec())})(hn||(hn={}));var Xe=class r{static createFromProtobuf=e=>{let t=hn.decode(e),n=xi(t.peerId),s=(t.addresses??[]).map(i=>ct(i.multiaddr)),o=t.seq;return new r({peerId:n,multiaddrs:s,seqNumber:o})};static DOMAIN=_l;static CODEC=Cl;peerId;multiaddrs;seqNumber;domain=r.DOMAIN;codec=r.CODEC;marshaled;constructor(e){let{peerId:t,multiaddrs:n,seqNumber:s}=e;this.peerId=t,this.multiaddrs=n??[],this.seqNumber=s??BigInt(Date.now())}marshal(){return this.marshaled==null&&(this.marshaled=hn.encode({peerId:this.peerId.toBytes(),seq:BigInt(this.seqNumber),addresses:this.multiaddrs.map(e=>({multiaddr:e.bytes}))})),this.marshaled}equals(e){return!(!(e instanceof r)||!this.peerId.equals(e.peerId)||this.seqNumber!==e.seqNumber||!yl(this.multiaddrs,e.multiaddrs))}};function op(r){return r[Symbol.asyncIterator]!=null}function ip(r){if(op(r))return(async()=>{for await(let e of r);})();for(let e of r);}var Ll=ip;function Qe(){let r={};return r.promise=new Promise((e,t)=>{r.resolve=e,r.reject=t}),r}var _s=globalThis.CustomEvent??Event;async function*Oi(r,e={}){let t=e.concurrency??1/0;t<1&&(t=1/0);let n=e.ordered==null?!1:e.ordered,s=new EventTarget,o=[],i=Qe(),a=Qe(),c=!1,f,l=!1;s.addEventListener("task-complete",()=>{a.resolve()}),Promise.resolve().then(async()=>{try{for await(let b of r){if(o.length===t&&(i=Qe(),await i.promise),l)break;let m={done:!1};o.push(m),b().then(d=>{m.done=!0,m.ok=!0,m.value=d,s.dispatchEvent(new _s("task-complete"))},d=>{m.done=!0,m.err=d,s.dispatchEvent(new _s("task-complete"))})}c=!0,s.dispatchEvent(new _s("task-complete"))}catch(b){f=b,s.dispatchEvent(new _s("task-complete"))}});function u(){return n?o[0]?.done:!!o.find(b=>b.done)}function*h(){for(;o.length>0&&o[0].done;){let b=o[0];if(o.shift(),b.ok)yield b.value;else throw l=!0,i.resolve(),b.err;i.resolve()}}function*y(){for(;u();)for(let b=0;b<o.length;b++)if(o[b].done){let m=o[b];if(o.splice(b,1),b--,m.ok)yield m.value;else throw l=!0,i.resolve(),m.err;i.resolve()}}for(;;){if(u()||(a=Qe(),await a.promise),f!=null)throw f;if(n?yield*h():yield*y(),c&&o.length===0)break}}var Cs=class extends Error{type;code;constructor(e,t,n){super(e??"The operation was aborted"),this.type="aborted",this.name=n??"AbortError",this.code=t??"ABORT_ERR"}};async function Ul(r,e,t){if(e==null)return r;if(e.aborted)return Promise.reject(new Cs(t?.errorMessage,t?.errorCode,t?.errorName));let n,s=new Cs(t?.errorMessage,t?.errorCode,t?.errorName);try{return await Promise.race([r,new Promise((o,i)=>{n=()=>{i(s)},e.addEventListener("abort",n)})])}finally{n!=null&&e.removeEventListener("abort",n)}}var Pi=class{readNext;haveNext;ended;nextResult;constructor(){this.ended=!1,this.readNext=Qe(),this.haveNext=Qe()}[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 e=this.nextResult;return this.nextResult=void 0,this.readNext.resolve(),this.readNext=Qe(),e}async throw(e){return this.ended=!0,e!=null&&(this.haveNext.promise.catch(()=>{}),this.haveNext.reject(e)),{done:!0,value:void 0}}async return(){let e={done:!0,value:void 0};return await this._push(void 0),e}async push(e,t){await this._push(e,t)}async end(e,t){e!=null?await this.throw(e):await this._push(void 0,t)}async _push(e,t){if(e!=null&&this.ended)throw new Error("Cannot push value onto an ended pushable");for(;this.nextResult!=null;)await this.readNext.promise;e!=null?this.nextResult={done:!1,value:e}:(this.ended=!0,this.nextResult={done:!0,value:void 0}),this.haveNext.resolve(),this.haveNext=Qe(),await Ul(this.readNext.promise,t?.signal,t)}};function Ol(){return new Pi}var Ls=class extends Error{name="UnexpectedEOFError";code="ERR_UNEXPECTED_EOF"};var Vi=class extends Error{code;constructor(e,t){super(e),this.code=t}},Di=class extends Vi{type;constructor(e){super(e,"ABORT_ERR"),this.type="aborted",this.name="AbortError"}};function Pl(r,e){let t=Ol();r.sink(t).catch(async i=>{await t.end(i)}),r.sink=async i=>{for await(let a of i)await t.push(a);await t.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 Je;return{read:async(i,a)=>{a?.signal?.throwIfAborted();let c,f=new Promise((l,u)=>{c=()=>{u(new Di("Read aborted"))},a?.signal?.addEventListener("abort",c)});try{if(i==null){let{done:u,value:h}=await Promise.race([n.next(),f]);return u===!0?new Je:h}for(;s.byteLength<i;){let{value:u,done:h}=await Promise.race([n.next(),f]);if(h===!0)throw new Ls("unexpected end of input");s.append(u)}let l=s.sublist(0,i);return s.consume(i),l}finally{c!=null&&a?.signal?.removeEventListener("abort",c)}},write:async(i,a)=>{a?.signal?.throwIfAborted(),i instanceof Uint8Array?await t.push(i,a):await t.push(i.subarray(),a)},unwrap:()=>{if(s.byteLength>0){let i=r.source;r.source=async function*(){e?.yieldBytes===!1?yield s:yield*s,yield*i}()}return r}}}var Us=class extends Error{name="InvalidMessageLengthError";code="ERR_INVALID_MSG_LENGTH"},Os=class extends Error{name="InvalidDataLengthError";code="ERR_MSG_DATA_TOO_LONG"},Ps=class extends Error{name="InvalidDataLengthLengthError";code="ERR_MSG_LENGTH_TOO_LONG"};function Vl(r,e={}){let t=Pl(r,e);e.maxDataLength!=null&&e.maxLengthLength==null&&(e.maxLengthLength=Ee(e.maxDataLength));let n=e?.lengthDecoder??xt,s=e?.lengthEncoder??De;return{read:async i=>{let a=-1,c=new Je;for(;;){c.append(await t.read(1,i));try{a=n(c)}catch(f){if(f instanceof RangeError)continue;throw f}if(a<0)throw new Us("Invalid message length");if(e?.maxLengthLength!=null&&c.byteLength>e.maxLengthLength)throw new Ps("message length length too long");if(a>-1)break}if(e?.maxDataLength!=null&&a>e.maxDataLength)throw new Os("message length too long");return t.read(a,i)},write:async(i,a)=>{await t.write(new Je(s(i.byteLength),i),a)},writeV:async(i,a)=>{let c=new Je(...i.flatMap(f=>[s(f.byteLength),f]));await t.write(c,a)},unwrap:()=>t.unwrap()}}function Ur(r,e){let t=Vl(r,e),n={read:async(s,o)=>{let i=await t.read(o);return s.decode(i)},write:async(s,o,i)=>{await t.write(o.encode(s),i)},writeV:async(s,o,i)=>{await t.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:()=>t.unwrap()};return n}var Dl="0.1.0",Ml="id",Hl="id/push",Fl="1.0.0",Kl="1.0.0";var zt;(function(r){let e;r.codec=()=>(e==null&&(e=je((t,n,s={})=>{if(s.lengthDelimited!==!1&&n.fork(),t.protocolVersion!=null&&(n.uint32(42),n.string(t.protocolVersion)),t.agentVersion!=null&&(n.uint32(50),n.string(t.agentVersion)),t.publicKey!=null&&(n.uint32(10),n.bytes(t.publicKey)),t.listenAddrs!=null)for(let o of t.listenAddrs)n.uint32(18),n.bytes(o);if(t.observedAddr!=null&&(n.uint32(34),n.bytes(t.observedAddr)),t.protocols!=null)for(let o of t.protocols)n.uint32(26),n.string(o);t.signedPeerRecord!=null&&(n.uint32(66),n.bytes(t.signedPeerRecord)),s.lengthDelimited!==!1&&n.ldelim()},(t,n)=>{let s={listenAddrs:[],protocols:[]},o=n==null?t.len:t.pos+n;for(;t.pos<o;){let i=t.uint32();switch(i>>>3){case 5:s.protocolVersion=t.string();break;case 6:s.agentVersion=t.string();break;case 1:s.publicKey=t.bytes();break;case 2:s.listenAddrs.push(t.bytes());break;case 4:s.observedAddr=t.bytes();break;case 3:s.protocols.push(t.string());break;case 8:s.signedPeerRecord=t.bytes();break;default:t.skipType(i&7);break}}return s})),e),r.encode=t=>Ge(t,r.codec()),r.decode=t=>ze(t,r.codec())})(zt||(zt={}));var zl=ta($l(),1),Mi=typeof window=="object"&&typeof document=="object"&&document.nodeType===9,Vs=(0,zl.default)(),Gl=Mi&&!Vs,jl=Vs&&!Mi,Wl=Vs&&Mi,Yl=typeof globalThis.process<"u"&&typeof globalThis.process.release<"u"&&globalThis.process.release.name==="node"&&!Vs,Zl=typeof importScripts=="function"&&typeof self<"u"&&typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope,nx=typeof globalThis.process<"u"&&typeof globalThis.process.env<"u"&&globalThis.process.env["NODE"+"_"+"ENV"]==="test",Jl=typeof navigator<"u"&&navigator.product==="ReactNative";var Ue={protocolPrefix:"ipfs",timeout:5e3,maxInboundStreams:1,maxOutboundStreams:1,maxObservedAddresses:10,maxMessageSize:8192,runOnConnectionOpen:!0,runOnSelfUpdate:!0,runOnTransientConnection:!0,concurrency:32};function Xl(r){if(r!=null&&r.length>0)try{return ct(r)}catch{}}function up(r,e){return e!=null||(e=`${r.name}/${r.version}`,Yl||jl?e+=` UserAgent=${globalThis.process.version}`:(Gl||Zl||Wl||Jl)&&(e+=` UserAgent=${globalThis.navigator.userAgent}`)),e}async function Ds(r,e,t,n,s){if(t("received identify from %p",n.remotePeer),s==null)throw new L("message was null or undefined","ERR_INVALID_MESSAGE");let o={};if(s.listenAddrs.length>0&&(o.addresses=s.listenAddrs.map(c=>({isCertified:!1,multiaddr:ct(c)}))),s.protocols.length>0&&(o.protocols=s.protocols),s.publicKey!=null&&(o.publicKey=s.publicKey,!(await _r(s.publicKey)).equals(n.remotePeer)))throw new L("public key did not match remote PeerId","ERR_INVALID_PUBLIC_KEY");let i;if(s.signedPeerRecord!=null){t("received signedPeerRecord from %p",n.remotePeer);let c=s.signedPeerRecord,f=await at.openAndCertify(c,Xe.DOMAIN),l=Xe.createFromProtobuf(f.payload);if(!l.peerId.equals(f.peerId))throw new L("signing key does not match PeerId in the PeerRecord","ERR_INVALID_SIGNING_KEY");if(!n.remotePeer.equals(l.peerId))throw new L("signing key does not match remote PeerId","ERR_INVALID_PEER_RECORD_KEY");let u;try{u=await r.get(l.peerId)}catch(h){if(h.code!=="ERR_NOT_FOUND")throw h}if(u!=null&&(o.metadata=u.metadata,u.peerRecordEnvelope!=null)){let h=await at.createFromProtobuf(u.peerRecordEnvelope),y=Xe.createFromProtobuf(h.payload);y.seqNumber>=l.seqNumber&&(t("sequence number was lower or equal to existing sequence number - stored: %d received: %d",y.seqNumber,l.seqNumber),l=y,c=u.peerRecordEnvelope)}o.peerRecordEnvelope=c,o.addresses=l.multiaddrs.map(h=>({isCertified:!0,multiaddr:h})),i={seq:l.seqNumber,addresses:l.multiaddrs}}else t("%p did not send a signed peer record",n.remotePeer);if(t("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=V(s.agentVersion)),s.protocolVersion!=null&&(c.ProtocolVersion=V(s.protocolVersion)),t("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=>ct(c)),observedAddr:s.observedAddr==null?void 0:ct(s.observedAddr),protocols:s.protocols,signedPeerRecord:i,connection:n};return e.safeDispatchEvent("peer:identify",{detail:a}),a}var Or=class{host;protocol;started;timeout;peerId;peerStore;registrar;addressManager;maxInboundStreams;maxOutboundStreams;maxMessageSize;maxObservedAddresses;events;runOnTransientConnection;log;constructor(e,t){this.protocol=t.protocol,this.started=!1,this.peerId=e.peerId,this.peerStore=e.peerStore,this.registrar=e.registrar,this.addressManager=e.addressManager,this.events=e.events,this.log=t.log,this.timeout=t.timeout??Ue.timeout,this.maxInboundStreams=t.maxInboundStreams??Ue.maxInboundStreams,this.maxOutboundStreams=t.maxOutboundStreams??Ue.maxOutboundStreams,this.maxMessageSize=t.maxMessageSize??Ue.maxMessageSize,this.maxObservedAddresses=t.maxObservedAddresses??Ue.maxObservedAddresses,this.runOnTransientConnection=t.runOnTransientConnection??Ue.runOnTransientConnection,this.host={protocolVersion:`${t.protocolPrefix??Ue.protocolPrefix}/${Dl}`,agentVersion:up(e.nodeInfo,t.agentVersion)}}isStarted(){return this.started}async start(){this.started||(await this.peerStore.merge(this.peerId,{metadata:{AgentVersion:V(this.host.agentVersion),ProtocolVersion:V(this.host.protocolVersion)}}),await this.registrar.handle(this.protocol,e=>{this.handleProtocol(e).catch(t=>{this.log.error(t)})},{maxInboundStreams:this.maxInboundStreams,maxOutboundStreams:this.maxOutboundStreams,runOnTransientConnection:this.runOnTransientConnection}),this.started=!0)}async stop(){await this.registrar.unhandle(this.protocol),this.started=!1}};var Ms=class extends Or{connectionManager;concurrency;constructor(e,t={}){super(e,{...t,protocol:`/${t.protocolPrefix??Ue.protocolPrefix}/${Hl}/${Kl}`,log:e.logger.forComponent("libp2p:identify-push")}),this.connectionManager=e.connectionManager,this.concurrency=t.concurrency??Ue.concurrency,(t.runOnSelfUpdate??Ue.runOnSelfUpdate)&&e.events.addEventListener("self:peer:update",n=>{this.push().catch(s=>{this.log.error(s)})})}[mn]=["@libp2p/identify-push"];async push(){if(!this.isStarted())return;let e=this.addressManager.getAddresses().map(l=>l.decapsulateCode(z("p2p").code)),t=new Xe({peerId:this.peerId,multiaddrs:e}),n=await at.seal(t,this.peerId),s=this.registrar.getProtocols(),o=await this.peerStore.get(this.peerId),i=D(o.metadata.get("AgentVersion")??V(this.host.agentVersion)),a=D(o.metadata.get("ProtocolVersion")??V(this.host.protocolVersion)),c=this;async function*f(){for(let l of c.connectionManager.getConnections())(await c.peerStore.get(l.remotePeer)).protocols.includes(c.protocol)&&(yield async()=>{let h,y=AbortSignal.timeout(c.timeout);Dr(1/0,y);try{h=await l.newStream(c.protocol,{signal:y,runOnTransientConnection:c.runOnTransientConnection}),await Ur(h,{maxDataLength:c.maxMessageSize}).pb(zt).write({listenAddrs:e.map(m=>m.bytes),signedPeerRecord:n.marshal(),protocols:s,agentVersion:i,protocolVersion:a},{signal:y}),await h.close({signal:y})}catch(b){c.log.error("could not push identify update to peer",b),h?.abort(b)}})}await Ll(Oi(f(),{concurrency:this.concurrency}))}async handleProtocol(e){let{connection:t,stream:n}=e;try{if(this.peerId.equals(t.remotePeer))throw new Error("received push from ourselves?");let s={signal:AbortSignal.timeout(this.timeout)},i=await Ur(n,{maxDataLength:this.maxMessageSize}).pb(zt).read(s);await n.close(s),await Ds(this.peerStore,this.events,this.log,t,i)}catch(s){this.log.error("received invalid message",s),n.abort(s);return}this.log("handled push from %p",t.remotePeer)}};var fp=r=>r.toString().split("/").slice(1),dn=r=>({match:e=>e.length<1?!1:r(e[0])?e.slice(1):!1,pattern:"fn"}),G=r=>({match:e=>dn(t=>t===r).match(e),pattern:r}),Ks=()=>({match:r=>dn(e=>typeof e=="string").match(r),pattern:"{string}"}),qs=()=>({match:r=>dn(e=>!isNaN(parseInt(e))).match(r),pattern:"{number}"}),xe=()=>({match:r=>{if(r.length<2||r[0]!=="p2p"&&r[0]!=="ipfs")return!1;if(r[1].startsWith("Q")||r[1].startsWith("1"))try{ne.decode(`z${r[1]}`)}catch{return!1}else return!1;return r.slice(2)},pattern:"/p2p/{peerid}"}),Hs=()=>({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}"}),ue=r=>({match:e=>{let t=r.match(e);return t===!1?e:t},pattern:`optional(${r.pattern})`}),He=(...r)=>({match:e=>{let t;for(let n of r){let s=n.match(e);s!==!1&&(t==null||s.length<t.length)&&(t=s)}return t??!1},pattern:`or(${r.map(e=>e.pattern).join(", ")})`}),Z=(...r)=>({match:e=>{for(let t of r){let n=t.match(e);if(n===!1)return!1;e=n}return e},pattern:`and(${r.map(e=>e.pattern).join(", ")})`});function se(...r){function e(s){let o=fp(s);for(let i of r){let a=i.match(o);if(a===!1)return!1;o=a}return o}function t(s){return e(s)!==!1}function n(s){let o=e(s);return o===!1?!1:o.length===0}return{matches:t,exactMatch:n}}var Fi=Z(G("dns4"),Ks()),Ki=Z(G("dns6"),Ks()),qi=Z(G("dnsaddr"),Ks()),Ql=Z(G("dns"),Ks()),Rx=se(Fi),Tx=se(Ki),_x=se(qi),Cx=se(He(Ql,qi,Fi,Ki)),eu=Z(G("ip4"),dn(ks)),tu=Z(G("ip6"),dn(Ns)),ru=He(eu,tu),lt=He(ru,Ql,Fi,Ki,qi),nu=se(lt),Lx=se(eu),Ux=se(tu),Ox=se(ru),$i=Z(lt,G("tcp"),qs()),pn=Z(lt,G("udp"),qs()),Px=se($i),Vx=se(pn),zi=Z(pn,G("quic")),$s=Z(pn,G("quic-v1")),hp=He(zi,$s),Dx=se(zi),Mx=se($s),Hi=He(lt,$i,pn,zi,$s),su=He(Z(Hi,G("ws"),ue(xe()))),Hx=se(su),ou=He(Z(Hi,G("wss"),ue(xe())),Z(Hi,G("tls"),G("ws"),ue(xe()))),Fx=se(ou),iu=Z(pn,G("webrtc-direct"),ue(Hs()),ue(Hs()),ue(xe())),Kx=se(iu),au=Z($s,G("webtransport"),ue(Hs()),ue(Hs()),ue(xe())),qx=se(au),Fs=He(su,ou,Z($i,ue(xe())),Z(hp,ue(xe())),Z(lt,ue(xe())),iu,au,xe()),$x=se(Fs),dp=Z(Fs,G("p2p-circuit"),xe()),zx=se(dp),pp=He(Z(Fs,G("p2p-circuit"),G("webrtc"),ue(xe())),Z(Fs,G("webrtc"),ue(xe())),G("webrtc")),Gx=se(pp),gp=He(Z(lt,G("tcp"),qs(),G("http"),ue(xe())),Z(lt,G("http"),ue(xe()))),jx=se(gp),mp=He(Z(lt,G("tcp"),He(Z(G("443"),G("http")),Z(qs(),G("https"))),ue(xe())),Z(lt,G("tls"),G("http"),ue(xe())),Z(lt,G("https"),ue(xe()))),Wx=se(mp);var zs=class extends Or{constructor(e,t={}){super(e,{...t,protocol:`/${t.protocolPrefix??Ue.protocolPrefix}/${Ml}/${Fl}`,log:e.logger.forComponent("libp2p:identify")}),(t.runOnConnectionOpen??Ue.runOnConnectionOpen)&&e.events.addEventListener("connection:open",n=>{let s=n.detail;this.identify(s).catch(o=>{this.log.error("error during identify trigged by connection:open",o)})})}[mn]=["@libp2p/identify"];async _identify(e,t={}){let n;if(t.signal==null){let s=AbortSignal.timeout(this.timeout);Dr(1/0,s),t={...t,signal:s}}try{n=await e.newStream(this.protocol,{...t,runOnTransientConnection:this.runOnTransientConnection});let o=await Ur(n,{maxDataLength:this.maxMessageSize}).pb(zt).read(t);return await n.close(t),o}catch(s){throw this.log.error("error while reading identify message",s),n?.abort(s),s}}async identify(e,t={}){let n=await this._identify(e,t),{publicKey:s,protocols:o,observedAddr:i}=n;if(s==null)throw new L("public key was missing from identify message","ERR_MISSING_PUBLIC_KEY");let a=await _r(s);if(!e.remotePeer.equals(a))throw new L("identified peer does not match the expected peer","ERR_INVALID_PEER");if(this.peerId.equals(a))throw new L("identified peer is our own peer id?","ERR_INVALID_PEER");let c=Xl(i);return this.log("identify completed for peer %p and protocols %o",a,o),this.log("our observed address is %a",c),c!=null&&this.addressManager.getObservedAddrs().length<(this.maxObservedAddresses??1/0)&&(this.log("storing our observed address %a",c),this.addressManager.addObservedAddr(c)),Ds(this.peerStore,this.events,this.log,e,n)}async handleProtocol(e){let{connection:t,stream:n}=e,s=AbortSignal.timeout(this.timeout);Dr(1/0,s);try{let o=this.peerId.publicKey??new Uint8Array(0),i=await this.peerStore.get(this.peerId),a=this.addressManager.getAddresses().map(u=>u.decapsulateCode(z("p2p").code)),c=i.peerRecordEnvelope;if(a.length>0&&c==null){let u=new Xe({peerId:this.peerId,multiaddrs:a});c=(await at.seal(u,this.peerId)).marshal().subarray()}let f=t.remoteAddr.bytes;nu.matches(t.remoteAddr)||(f=void 0),await Ur(n).pb(zt).write({protocolVersion:this.host.protocolVersion,agentVersion:this.host.agentVersion,publicKey:o,listenAddrs:a.map(u=>u.bytes),signedPeerRecord:c,observedAddr:f,protocols:i.protocols},{signal:s}),await n.close({signal:s})}catch(o){this.log.error("could not respond to identify request",o),n.abort(o)}}};function yp(r={}){return e=>new zs(e,r)}function bp(r={}){return e=>new Ms(e,r)}return vu(wp);})();
8
8
  /*! Bundled license information:
9
9
 
10
10
  pvtsutils/build/index.js:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@libp2p/identify",
3
- "version": "2.1.5-3c8dd5bbf",
3
+ "version": "2.1.5-737b3ea5b",
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,10 +52,10 @@
52
52
  "doc-check": "aegir doc-check"
53
53
  },
54
54
  "dependencies": {
55
- "@libp2p/interface": "1.7.0-3c8dd5bbf",
56
- "@libp2p/interface-internal": "1.3.4-3c8dd5bbf",
57
- "@libp2p/peer-id": "4.2.4-3c8dd5bbf",
58
- "@libp2p/peer-record": "7.0.25-3c8dd5bbf",
55
+ "@libp2p/interface": "1.7.0-737b3ea5b",
56
+ "@libp2p/interface-internal": "1.3.4-737b3ea5b",
57
+ "@libp2p/peer-id": "4.2.4-737b3ea5b",
58
+ "@libp2p/peer-record": "7.0.25-737b3ea5b",
59
59
  "@multiformats/multiaddr": "^12.2.3",
60
60
  "@multiformats/multiaddr-matcher": "^1.2.1",
61
61
  "it-drain": "^3.0.7",
@@ -67,9 +67,9 @@
67
67
  "wherearewe": "^2.0.1"
68
68
  },
69
69
  "devDependencies": {
70
- "@libp2p/interface-compliance-tests": "5.4.12-3c8dd5bbf",
71
- "@libp2p/logger": "4.0.20-3c8dd5bbf",
72
- "@libp2p/peer-id-factory": "4.2.4-3c8dd5bbf",
70
+ "@libp2p/interface-compliance-tests": "5.4.12-737b3ea5b",
71
+ "@libp2p/logger": "4.0.20-737b3ea5b",
72
+ "@libp2p/peer-id-factory": "4.2.4-737b3ea5b",
73
73
  "aegir": "^44.0.1",
74
74
  "delay": "^6.0.0",
75
75
  "it-length-prefixed": "^9.0.4",