@libp2p/identify 1.0.10-8bbd43628 → 1.0.11

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 yu=Object.create;var hn=Object.defineProperty;var bu=Object.getOwnPropertyDescriptor;var wu=Object.getOwnPropertyNames;var xu=Object.getPrototypeOf,vu=Object.prototype.hasOwnProperty;var qs=(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})},Gi=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of wu(e))!vu.call(r,s)&&s!==t&&hn(r,s,{get:()=>e[s],enumerable:!(n=bu(e,s))||n.enumerable});return r};var $s=(r,e,t)=>(t=r!=null?yu(xu(r)):{},Gi(e||!r||!r.__esModule?hn(t,"default",{value:r,enumerable:!0}):t,r)),Eu=r=>Gi(hn({},"__esModule",{value:!0}),r);var oc=qs(Ar=>{"use strict";var ed="[object ArrayBuffer]",mt=class r{static isArrayBuffer(e){return Object.prototype.toString.call(e)===ed}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}},Zo="string",td=/^[0-9a-f]+$/i,rd=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/,nd=/^[a-zA-Z0-9-_]+$/,Un=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=mt.toUint8Array(e),n="";for(let o=0;o<t.length;o++)n+=String.fromCharCode(t[o]);return decodeURIComponent(escape(n))}},Ue=class{static toString(e,t=!1){let n=mt.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===Zo&&td.test(e)}static isBase64(e){return typeof e===Zo&&rd.test(e)}static isBase64Url(e){return typeof e===Zo&&nd.test(e)}static ToString(e,t="utf8"){let n=mt.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 Ue.toString(n,!0);case"utf16":case"utf16be":return Ue.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 Ue.fromString(e,!0);case"utf16":case"utf16be":return Ue.fromString(e);default:throw new Error(`Unknown type of encoding '${t}'`)}}static ToBase64(e){let t=mt.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 Un.fromString(e);case"utf16":case"utf16be":return Ue.fromString(e);case"utf16le":case"usc2":return Ue.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 Un.toString(e);case"utf16":case"utf16be":return Ue.toString(e);case"utf16le":case"usc2":return Ue.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=mt.toUint8Array(e),n="";for(let s=0;s<t.length;s++)n+=String.fromCharCode(t[s]);return n}static ToHex(e){let t=mt.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 Ue.toString(e,t)}static FromUtf16String(e,t=!1){return Ue.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 sd(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 od(...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 id(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}Ar.BufferSourceConverter=mt;Ar.Convert=Pn;Ar.assign=sd;Ar.combine=od;Ar.isEqual=id});var Jl=qs((k1,Zl)=>{"use strict";function Yl(r,e){for(let t in e)Object.defineProperty(r,t,{value:e[t],enumerable:!0,configurable:!0});return r}function bp(r,e,t){if(!r||typeof r=="string")throw new TypeError("Please pass an Error to err-code");t||(t={}),typeof e=="object"&&(t=e,e=""),e&&(t.code=e);try{return Yl(r,t)}catch{t.message=r.message,t.stack=r.stack;let s=function(){};return s.prototype=Object.create(Object.getPrototypeOf(r)),Yl(new s,t)}}Zl.exports=bp});var tu=qs((V1,eu)=>{function Ep(){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)}eu.exports=Ep});var Ip={};de(Ip,{identify:()=>Sp,multicodecs:()=>Ap});var zi="/ipfs/id/1.0.0",ji="/ipfs/id/push/1.0.0",Wi="0.1.0",Yi="id",Zi="id/push",Ji="1.0.0",Xi="1.0.0";var Rp=Symbol.for("@libp2p/connection");var _p=Symbol.for("@libp2p/content-routing");var Up=Symbol.for("@libp2p/peer-discovery");var Qi=Symbol.for("@libp2p/peer-id");var Op=Symbol.for("@libp2p/peer-routing");var ea;(function(r){r.Accept="accept",r.Ignore="ignore",r.Reject="reject"})(ea||(ea={}));var Kp=Symbol.for("@libp2p/transport");var ta;(function(r){r[r.FATAL_ALL=0]="FATAL_ALL",r[r.NO_FATAL=1]="NO_FATAL"})(ta||(ta={}));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 ra="ERR_NOT_FOUND";var Gs=class extends Event{detail;constructor(e,t){super(e,t),this.detail=t?.detail}},$p=globalThis.CustomEvent??Gs;var dn=(r,...e)=>{try{[...e]}catch{}};var Zs={};de(Zs,{base58btc:()=>ne,base58flickr:()=>Nu});var x0=new Uint8Array(0);function na(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 at(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 sa(r){return new TextEncoder().encode(r)}function oa(r){return new TextDecoder().decode(r)}function Bu(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),u=Math.log(a)/Math.log(256),f=Math.log(256)/Math.log(a);function l(p){if(p instanceof Uint8Array||(ArrayBuffer.isView(p)?p=new Uint8Array(p.buffer,p.byteOffset,p.byteLength):Array.isArray(p)&&(p=Uint8Array.from(p))),!(p instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(p.length===0)return"";for(var h=0,m=0,y=0,B=p.length;y!==B&&p[y]===0;)y++,h++;for(var w=(B-y)*f+1>>>0,T=new Uint8Array(w);y!==B;){for(var x=p[y],A=0,N=w-1;(x!==0||A<m)&&N!==-1;N--,A++)x+=256*T[N]>>>0,T[N]=x%a>>>0,x=x/a>>>0;if(x!==0)throw new Error("Non-zero carry");m=A,y++}for(var R=w-m;R!==w&&T[R]===0;)R++;for(var G=c.repeat(h);R<w;++R)G+=r.charAt(T[R]);return G}function d(p){if(typeof p!="string")throw new TypeError("Expected String");if(p.length===0)return new Uint8Array;var h=0;if(p[h]!==" "){for(var m=0,y=0;p[h]===c;)m++,h++;for(var B=(p.length-h)*u+1>>>0,w=new Uint8Array(B);p[h];){var T=t[p.charCodeAt(h)];if(T===255)return;for(var x=0,A=B-1;(T!==0||x<y)&&A!==-1;A--,x++)T+=a*w[A]>>>0,w[A]=T%256>>>0,T=T/256>>>0;if(T!==0)throw new Error("Non-zero carry");y=x,h++}if(p[h]!==" "){for(var N=B-y;N!==B&&w[N]===0;)N++;for(var R=new Uint8Array(m+(B-N)),G=m;N!==B;)R[G++]=w[N++];return R}}}function b(p){var h=d(p);if(h)return h;throw new Error(`Non-${e} character`)}return{encode:l,decodeUnsafe:d,decode:b}}var Au=Bu,Su=Au,aa=Su;var zs=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 ca(this,e)}},Ws=class{decoders;constructor(e){this.decoders=e}or(e){return ca(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 ca(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 zs(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 sr({name:r,prefix:e,encode:t,decode:n}){return new Ys(r,e,t,n)}function At({name:r,prefix:e,alphabet:t}){let{encode:n,decode:s}=aa(t,r);return sr({prefix:e,name:r,encode:n,decode:o=>at(s(o))})}function Iu(r,e,t,n){let s={};for(let f=0;f<e.length;++f)s[e[f]]=f;let o=r.length;for(;r[o-1]==="=";)--o;let i=new Uint8Array(o*t/8|0),a=0,c=0,u=0;for(let f=0;f<o;++f){let l=s[r[f]];if(l===void 0)throw new SyntaxError(`Non-${n} character`);c=c<<t|l,a+=t,a>=8&&(a-=8,i[u++]=255&c>>a)}if(a>=t||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return i}function ku(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 ee({name:r,prefix:e,bitsPerChar:t,alphabet:n}){return sr({prefix:e,name:r,encode(s){return ku(s,n,t)},decode(s){return Iu(s,n,t,r)}})}var ne=At({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Nu=At({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Js={};de(Js,{base10:()=>Ru});var Ru=At({prefix:"9",name:"base10",alphabet:"0123456789"});var Xs={};de(Xs,{base16:()=>Tu,base16upper:()=>_u});var Tu=ee({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),_u=ee({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Qs={};de(Qs,{base2:()=>Lu});var Lu=ee({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var eo={};de(eo,{base256emoji:()=>Ou});var la=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}"),Cu=la.reduce((r,e,t)=>(r[t]=e,r),[]),Uu=la.reduce((r,e,t)=>(r[e.codePointAt(0)]=t,r),[]);function Pu(r){return r.reduce((e,t)=>(e+=Cu[t],e),"")}function Du(r){let e=[];for(let t of r){let n=Uu[t.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${t}`);e.push(n)}return new Uint8Array(e)}var Ou=sr({prefix:"\u{1F680}",name:"base256emoji",encode:Pu,decode:Du});var to={};de(to,{base32:()=>ct,base32hex:()=>Ku,base32hexpad:()=>qu,base32hexpadupper:()=>$u,base32hexupper:()=>Fu,base32pad:()=>Hu,base32padupper:()=>Mu,base32upper:()=>Vu,base32z:()=>Gu});var ct=ee({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Vu=ee({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Hu=ee({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Mu=ee({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Ku=ee({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Fu=ee({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),qu=ee({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),$u=ee({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Gu=ee({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var ro={};de(ro,{base36:()=>zu,base36upper:()=>ju});var zu=At({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),ju=At({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var so={};de(so,{base64:()=>pn,base64pad:()=>Wu,base64url:()=>no,base64urlpad:()=>Yu});var pn=ee({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Wu=ee({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),no=ee({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Yu=ee({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var oo={};de(oo,{base8:()=>Zu});var Zu=ee({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var io={};de(io,{identity:()=>Ju});var Ju=sr({prefix:"\0",name:"identity",encode:r=>oa(r),decode:r=>sa(r)});var D0=new TextEncoder,O0=new TextDecoder;var co={};de(co,{identity:()=>St});var ef=ha,ua=128,tf=127,rf=~tf,nf=Math.pow(2,31);function ha(r,e,t){e=e||[],t=t||0;for(var n=t;r>=nf;)e[t++]=r&255|ua,r/=128;for(;r&rf;)e[t++]=r&255|ua,r>>>=7;return e[t]=r|0,ha.bytes=t-n+1,e}var sf=ao,of=128,fa=127;function ao(r,n){var t=0,n=n||0,s=0,o=n,i,a=r.length;do{if(o>=a)throw ao.bytes=0,new RangeError("Could not decode varint");i=r[o++],t+=s<28?(i&fa)<<s:(i&fa)*Math.pow(2,s),s+=7}while(i>=of);return ao.bytes=o-n,t}var af=Math.pow(2,7),cf=Math.pow(2,14),lf=Math.pow(2,21),uf=Math.pow(2,28),ff=Math.pow(2,35),hf=Math.pow(2,42),df=Math.pow(2,49),pf=Math.pow(2,56),gf=Math.pow(2,63),mf=function(r){return r<af?1:r<cf?2:r<lf?3:r<uf?4:r<ff?5:r<hf?6:r<df?7:r<pf?8:r<gf?9:10},yf={encode:ef,decode:sf,encodingLength:mf},bf=yf,Vr=bf;function Hr(r,e=0){return[Vr.decode(r,e),Vr.decode.bytes]}function or(r,e,t=0){return Vr.encode(r,e,t),e}function ir(r){return Vr.encodingLength(r)}function Je(r,e){let t=e.byteLength,n=ir(r),s=n+ir(t),o=new Uint8Array(s+t);return or(r,o,0),or(t,o,n),o.set(e,s),new ar(r,t,e,o)}function $t(r){let e=at(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 ar(t,s,i,e)}function da(r,e){if(r===e)return!0;{let t=e;return r.code===t.code&&r.size===t.size&&t.bytes instanceof Uint8Array&&na(r.bytes,t.bytes)}}var ar=class{code;size;digest;bytes;constructor(e,t,n,s){this.code=e,this.size=t,this.digest=n,this.bytes=s}};var pa=0,wf="identity",ga=at;function xf(r){return Je(pa,ga(r))}var St={code:pa,name:wf,encode:ga,digest:xf};var fo={};de(fo,{sha256:()=>ye,sha512:()=>vf});function uo({name:r,code:e,encode:t}){return new lo(r,e,t)}var lo=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?Je(this.code,t):t.then(n=>Je(this.code,n))}else throw Error("Unknown type, must be binary type")}};function ya(r){return async e=>new Uint8Array(await crypto.subtle.digest(r,e))}var ye=uo({name:"sha2-256",code:18,encode:ya("SHA-256")}),vf=uo({name:"sha2-512",code:19,encode:ya("SHA-512")});function ba(r,e){let{bytes:t,version:n}=r;switch(n){case 0:return Bf(t,ho(r),e??ne.encoder);default:return Af(t,ho(r),e??ct.encoder)}}var wa=new WeakMap;function ho(r){let e=wa.get(r);if(e==null){let t=new Map;return wa.set(r,t),t}return e}var He=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!==Mr)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==Sf)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=Je(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&&da(e.multihash,n.multihash)}toString(e){return ba(this,e)}toJSON(){return{"/":ba(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??xa(n,s,o.bytes))}else if(t[If]===!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!==Mr)throw new Error(`Version 0 CID must use dag-pb (code: ${Mr}) block encoding`);return new r(e,t,n,n.bytes)}case 1:{let s=xa(e,t,n.bytes);return new r(e,t,n,s)}default:throw new Error("Invalid version")}}static createV0(e){return r.create(0,Mr,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=at(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 ar(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,d]=Hr(e.subarray(t));return t+=d,l},s=n(),o=Mr;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(),u=t+c,f=u-i;return{version:s,codec:o,multihashCode:a,digestSize:c,multihashSize:f,size:u}}static parse(e,t){let[n,s]=Ef(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 ho(o).set(n,e),o}};function Ef(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 ct.prefix:{let t=e??ct;return[ct.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 Bf(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 Af(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 Mr=112,Sf=18;function xa(r,e,t){let n=ir(r),s=n+ir(e),o=new Uint8Array(s+t.byteLength);return or(r,o,0),or(e,o,n),o.set(t,s),o}var If=Symbol.for("@ipld/js-cid/CID");var It={...io,...Qs,...oo,...Js,...Xs,...to,...ro,...Zs,...so,...eo},sg={...fo,...co};function ue(r,e){if(r===e)return!0;if(r.byteLength!==e.byteLength)return!1;for(let t=0;t<r.byteLength;t++)if(r[t]!==e[t])return!1;return!0}var kf=Symbol.for("nodejs.util.inspect.custom"),va=Object.values(It).map(r=>r.decoder).reduce((r,e)=>r.or(e),It.identity.decoder),Ea=114,po=36,go=37,Kr=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()})`}[Qi]=!0;toString(){return this.string==null&&(this.string=ne.encode(this.multihash.bytes).slice(1)),this.string}toCID(){return He.createV1(Ea,this.multihash)}toBytes(){return this.multihash.bytes}toJSON(){return this.toString()}equals(e){if(e==null)return!1;if(e instanceof Uint8Array)return ue(this.multihash.bytes,e);if(typeof e=="string")return Nf(e).equals(this);if(e?.multihash?.bytes!=null)return ue(this.multihash.bytes,e.multihash.bytes);throw new Error("not valid Id")}[kf](){return`PeerId(${this.toString()})`}},cr=class extends Kr{type="RSA";publicKey;constructor(e){super({...e,type:"RSA"}),this.publicKey=e.publicKey}},lr=class extends Kr{type="Ed25519";publicKey;constructor(e){super({...e,type:"Ed25519"}),this.publicKey=e.multihash.digest}},ur=class extends Kr{type="secp256k1";publicKey;constructor(e){super({...e,type:"secp256k1"}),this.publicKey=e.multihash.digest}};function Nf(r,e){if(e=e??va,r.charAt(0)==="1"||r.charAt(0)==="Q"){let t=$t(ne.decode(`z${r}`));return r.startsWith("12D")?new lr({multihash:t}):r.startsWith("16U")?new ur({multihash:t}):new cr({multihash:t})}return mo(va.decode(r))}function mo(r){try{let e=$t(r);if(e.code===St.code){if(e.digest.length===po)return new lr({multihash:e});if(e.digest.length===go)return new ur({multihash:e})}if(e.code===ye.code)return new cr({multihash:e})}catch{return Rf(He.decode(r))}throw new Error("Supplied PeerID CID is invalid")}function Rf(r){if(r==null||r.multihash==null||r.version==null||r.version===1&&r.code!==Ea)throw new Error("Supplied PeerID CID is invalid");let e=r.multihash;if(e.code===ye.code)return new cr({multihash:r.multihash});if(e.code===St.code){if(e.digest.length===po)return new lr({multihash:r.multihash});if(e.digest.length===go)return new ur({multihash:r.multihash})}throw new Error("Supplied PeerID CID is invalid")}async function Fr(r,e){return r.length===po?new lr({multihash:Je(St.code,r),privateKey:e}):r.length===go?new ur({multihash:Je(St.code,r),privateKey:e}):new cr({multihash:await ye.digest(r),publicKey:r,privateKey:e})}var Wo={};de(Wo,{Ed25519PrivateKey:()=>Ut,Ed25519PublicKey:()=>Er,generateKeyPair:()=>Wh,generateKeyPairFromSeed:()=>sc,unmarshalEd25519PrivateKey:()=>zh,unmarshalEd25519PublicKey:()=>jh});function kt(r){return globalThis.Buffer!=null?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r}function lt(r=0){return globalThis.Buffer?.alloc!=null?kt(globalThis.Buffer.alloc(r)):new Uint8Array(r)}function Ee(r=0){return globalThis.Buffer?.allocUnsafe!=null?kt(globalThis.Buffer.allocUnsafe(r)):new Uint8Array(r)}function be(r,e){if(globalThis.Buffer!=null)return kt(globalThis.Buffer.concat(r,e));e==null&&(e=r.reduce((s,o)=>s+o.length,0));let t=Ee(e),n=0;for(let s of r)t.set(s,n),n+=s.length;return kt(t)}function Aa(r,e,t,n){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:n}}}var Ba=Aa("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),yo=Aa("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=Ee(r.length);for(let t=0;t<r.length;t++)e[t]=r.charCodeAt(t);return e}),Tf={utf8:Ba,"utf-8":Ba,hex:It.base16,latin1:yo,ascii:yo,binary:yo,...It},mn=Tf;function K(r,e="utf8"){let t=mn[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?kt(globalThis.Buffer.from(r,"utf-8")):t.decoder.decode(`${t.prefix}${r}`)}function Ce(r){return r==null?!1:typeof r.then=="function"&&typeof r.catch=="function"&&typeof r.finally=="function"}function fr(r){if(!Number.isSafeInteger(r)||r<0)throw new Error(`Wrong positive integer: ${r}`)}function _f(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}function bo(r,...e){if(!_f(r))throw new Error("Expected Uint8Array");if(e.length>0&&!e.includes(r.length))throw new Error(`Expected Uint8Array of length ${e}, not of length=${r.length}`)}function yn(r){if(typeof r!="function"||typeof r.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");fr(r.outputLen),fr(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 Sa(r,e){bo(r);let t=e.outputLen;if(r.length<t)throw new Error(`digestInto() expects output buffer of length at least ${t}`)}var bn=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function Ia(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}var pr=r=>new DataView(r.buffer,r.byteOffset,r.byteLength),Me=(r,e)=>r<<32-e|r>>>e,Lf=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!Lf)throw new Error("Non little-endian hardware is not supported");var Cf=async()=>{};async function ka(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 Cf(),n+=o)}}function wo(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}function Nt(r){if(typeof r=="string"&&(r=wo(r)),!Ia(r))throw new Error(`expected Uint8Array, got ${typeof r}`);return r}function wn(...r){let e=0;for(let n=0;n<r.length;n++){let s=r[n];if(!Ia(s))throw new Error("Uint8Array expected");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()}},Uf={}.toString;function Na(r,e){if(e!==void 0&&Uf.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(Nt(n)).digest(),t=r();return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=()=>r(),e}function gr(r=32){if(bn&&typeof bn.getRandomValues=="function")return bn.getRandomValues(new Uint8Array(r));throw new Error("crypto.getRandomValues must be defined")}function Pf(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,u=n?0:4;r.setUint32(e+c,i,n),r.setUint32(e+u,a,n)}var 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=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=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),Sa(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;Pf(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 u=c/4,f=this.get();if(u>f.length)throw new Error("_sha2: outputLen bigger than state");for(let l=0;l<u;l++)a.setUint32(4*l,f[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 vn=BigInt(4294967295),xo=BigInt(32);function Ra(r,e=!1){return e?{h:Number(r&vn),l:Number(r>>xo&vn)}:{h:Number(r>>xo&vn)|0,l:Number(r&vn)|0}}function Df(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}=Ra(r[s],e);[t[s],n[s]]=[o,i]}return[t,n]}var Of=(r,e)=>BigInt(r>>>0)<<xo|BigInt(e>>>0),Vf=(r,e,t)=>r>>>t,Hf=(r,e,t)=>r<<32-t|e>>>t,Mf=(r,e,t)=>r>>>t|e<<32-t,Kf=(r,e,t)=>r<<32-t|e>>>t,Ff=(r,e,t)=>r<<64-t|e>>>t-32,qf=(r,e,t)=>r>>>t-32|e<<64-t,$f=(r,e)=>e,Gf=(r,e)=>r,zf=(r,e,t)=>r<<t|e>>>32-t,jf=(r,e,t)=>e<<t|r>>>32-t,Wf=(r,e,t)=>e<<t-32|r>>>64-t,Yf=(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 Jf=(r,e,t)=>(r>>>0)+(e>>>0)+(t>>>0),Xf=(r,e,t,n)=>e+t+n+(r/2**32|0)|0,Qf=(r,e,t,n)=>(r>>>0)+(e>>>0)+(t>>>0)+(n>>>0),eh=(r,e,t,n,s)=>e+t+n+s+(r/2**32|0)|0,th=(r,e,t,n,s)=>(r>>>0)+(e>>>0)+(t>>>0)+(n>>>0)+(s>>>0),rh=(r,e,t,n,s,o)=>e+t+n+s+o+(r/2**32|0)|0;var nh={fromBig:Ra,split:Df,toBig:Of,shrSH:Vf,shrSL:Hf,rotrSH:Mf,rotrSL:Kf,rotrBH:Ff,rotrBL:qf,rotr32H:$f,rotr32L:Gf,rotlSH:zf,rotlSL:jf,rotlBH:Wf,rotlBL:Yf,add:Zf,add3L:Jf,add3H:Xf,add4L:Qf,add4H:eh,add5H:rh,add5L:th},U=nh;var[sh,oh]=U.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),vo=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:u,El:f,Fh:l,Fl:d,Gh:b,Gl:p,Hh:h,Hl:m}=this;return[e,t,n,s,o,i,a,c,u,f,l,d,b,p,h,m]}set(e,t,n,s,o,i,a,c,u,f,l,d,b,p,h,m){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=u|0,this.El=f|0,this.Fh=l|0,this.Fl=d|0,this.Gh=b|0,this.Gl=p|0,this.Hh=h|0,this.Hl=m|0}process(e,t){for(let w=0;w<16;w++,t+=4)Rt[w]=e.getUint32(t),Tt[w]=e.getUint32(t+=4);for(let w=16;w<80;w++){let T=Rt[w-15]|0,x=Tt[w-15]|0,A=U.rotrSH(T,x,1)^U.rotrSH(T,x,8)^U.shrSH(T,x,7),N=U.rotrSL(T,x,1)^U.rotrSL(T,x,8)^U.shrSL(T,x,7),R=Rt[w-2]|0,G=Tt[w-2]|0,q=U.rotrSH(R,G,19)^U.rotrBH(R,G,61)^U.shrSH(R,G,6),P=U.rotrSL(R,G,19)^U.rotrBL(R,G,61)^U.shrSL(R,G,6),ie=U.add4L(N,P,Tt[w-7],Tt[w-16]),re=U.add4H(ie,A,q,Rt[w-7],Rt[w-16]);Rt[w]=re|0,Tt[w]=ie|0}let{Ah:n,Al:s,Bh:o,Bl:i,Ch:a,Cl:c,Dh:u,Dl:f,Eh:l,El:d,Fh:b,Fl:p,Gh:h,Gl:m,Hh:y,Hl:B}=this;for(let w=0;w<80;w++){let T=U.rotrSH(l,d,14)^U.rotrSH(l,d,18)^U.rotrBH(l,d,41),x=U.rotrSL(l,d,14)^U.rotrSL(l,d,18)^U.rotrBL(l,d,41),A=l&b^~l&h,N=d&p^~d&m,R=U.add5L(B,x,N,oh[w],Tt[w]),G=U.add5H(R,y,T,A,sh[w],Rt[w]),q=R|0,P=U.rotrSH(n,s,28)^U.rotrBH(n,s,34)^U.rotrBH(n,s,39),ie=U.rotrSL(n,s,28)^U.rotrBL(n,s,34)^U.rotrBL(n,s,39),re=n&o^n&a^o&a,Le=s&i^s&c^i&c;y=h|0,B=m|0,h=b|0,m=p|0,b=l|0,p=d|0,{h:l,l:d}=U.add(u|0,f|0,G|0,q|0),u=a|0,f=c|0,a=o|0,c=i|0,o=n|0,i=s|0;let v=U.add3L(q,ie,Le);n=U.add3H(v,G,P,re),s=v|0}({h:n,l:s}=U.add(this.Ah|0,this.Al|0,n|0,s|0)),{h:o,l:i}=U.add(this.Bh|0,this.Bl|0,o|0,i|0),{h:a,l:c}=U.add(this.Ch|0,this.Cl|0,a|0,c|0),{h:u,l:f}=U.add(this.Dh|0,this.Dl|0,u|0,f|0),{h:l,l:d}=U.add(this.Eh|0,this.El|0,l|0,d|0),{h:b,l:p}=U.add(this.Fh|0,this.Fl|0,b|0,p|0),{h,l:m}=U.add(this.Gh|0,this.Gl|0,h|0,m|0),{h:y,l:B}=U.add(this.Hh|0,this.Hl|0,y|0,B|0),this.set(n,s,o,i,a,c,u,f,l,d,b,p,h,m,y,B)}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 yr=xn(()=>new vo);var Bn={};de(Bn,{bitGet:()=>hh,bitLen:()=>fh,bitMask:()=>qr,bitSet:()=>dh,bytesToHex:()=>ft,bytesToNumberBE:()=>ht,bytesToNumberLE:()=>_t,concatBytes:()=>dt,createHmacDrbg:()=>Ao,ensureBytes:()=>te,equalBytes:()=>lh,hexToBytes:()=>zt,hexToNumber:()=>Bo,isBytes:()=>Ke,numberToBytesBE:()=>Lt,numberToBytesLE:()=>jt,numberToHexUnpadded:()=>Ca,numberToVarBytesBE:()=>ch,utf8ToBytes:()=>uh,validateObject:()=>Xe});var La=BigInt(0),En=BigInt(1),ih=BigInt(2);function Ke(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}var ah=Array.from({length:256},(r,e)=>e.toString(16).padStart(2,"0"));function ft(r){if(!Ke(r))throw new Error("Uint8Array expected");let e="";for(let t=0;t<r.length;t++)e+=ah[r[t]];return e}function Ca(r){let e=r.toString(16);return e.length&1?`0${e}`:e}function Bo(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return BigInt(r===""?"0":`0x${r}`)}var ut={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function Ta(r){if(r>=ut._0&&r<=ut._9)return r-ut._0;if(r>=ut._A&&r<=ut._F)return r-(ut._A-10);if(r>=ut._a&&r<=ut._f)return r-(ut._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=Ta(r.charCodeAt(o)),a=Ta(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 ht(r){return Bo(ft(r))}function _t(r){if(!Ke(r))throw new Error("Uint8Array expected");return Bo(ft(Uint8Array.from(r).reverse()))}function Lt(r,e){return zt(r.toString(16).padStart(e*2,"0"))}function jt(r,e){return Lt(r,e).reverse()}function ch(r){return zt(Ca(r))}function te(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(Ke(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 dt(...r){let e=0;for(let s=0;s<r.length;s++){let o=r[s];if(!Ke(o))throw new Error("Uint8Array expected");e+=o.length}let t=new Uint8Array(e),n=0;for(let s=0;s<r.length;s++){let o=r[s];t.set(o,n),n+=o.length}return t}function lh(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 uh(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}function fh(r){let e;for(e=0;r>La;r>>=En,e+=1);return e}function hh(r,e){return r>>BigInt(e)&En}var dh=(r,e,t)=>r|(t?En:La)<<BigInt(e),qr=r=>(ih<<BigInt(r-1))-En,Eo=r=>new Uint8Array(r),_a=r=>Uint8Array.from(r);function Ao(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=(...l)=>t(s,n,...l),c=(l=Eo())=>{s=a(_a([0]),l),n=a(),l.length!==0&&(s=a(_a([1]),l),n=a())},u=()=>{if(o++>=1e3)throw new Error("drbg: tried 1000 values");let l=0,d=[];for(;l<e;){n=a();let b=n.slice();d.push(b),l+=n.length}return dt(...d)};return(l,d)=>{i(),c(l);let b;for(;!(b=d(u()));)c();return i(),b}}var ph={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"||Ke(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 Xe(r,e,t={}){let n=(s,o,i)=>{let a=ph[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 fe=BigInt(0),Z=BigInt(1),Wt=BigInt(2),gh=BigInt(3),So=BigInt(4),Ua=BigInt(5),Pa=BigInt(8),mh=BigInt(9),yh=BigInt(16);function Y(r,e){let t=r%e;return t>=fe?t:e+t}function bh(r,e,t){if(t<=fe||e<fe)throw new Error("Expected power/modulo > 0");if(t===Z)return fe;let n=Z;for(;e>fe;)e&Z&&(n=n*r%t),r=r*r%t,e>>=Z;return n}function J(r,e,t){let n=r;for(;e-- >fe;)n*=n,n%=t;return n}function An(r,e){if(r===fe||e<=fe)throw new Error(`invert: expected positive integers, got n=${r} mod=${e}`);let t=Y(r,e),n=e,s=fe,o=Z,i=Z,a=fe;for(;t!==fe;){let u=n/t,f=n%t,l=s-i*u,d=o-a*u;n=t,t=f,s=i,o=a,i=l,a=d}if(n!==Z)throw new Error("invert: does not exist");return Y(s,e)}function wh(r){let e=(r-Z)/Wt,t,n,s;for(t=r-Z,n=0;t%Wt===fe;t/=Wt,n++);for(s=Wt;s<r&&bh(s,e,r)!==r-Z;s++);if(n===1){let i=(r+Z)/So;return function(c,u){let f=c.pow(u,i);if(!c.eql(c.sqr(f),u))throw new Error("Cannot find square root");return f}}let o=(t+Z)/Wt;return function(a,c){if(a.pow(c,e)===a.neg(a.ONE))throw new Error("Cannot find square root");let u=n,f=a.pow(a.mul(a.ONE,s),t),l=a.pow(c,o),d=a.pow(c,t);for(;!a.eql(d,a.ONE);){if(a.eql(d,a.ZERO))return a.ZERO;let b=1;for(let h=a.sqr(d);b<u&&!a.eql(h,a.ONE);b++)h=a.sqr(h);let p=a.pow(f,Z<<BigInt(u-b-1));f=a.sqr(p),l=a.mul(l,p),d=a.mul(d,f),u=b}return l}}function xh(r){if(r%So===gh){let e=(r+Z)/So;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%Pa===Ua){let e=(r-Ua)/Pa;return function(n,s){let o=n.mul(s,Wt),i=n.pow(o,e),a=n.mul(s,i),c=n.mul(n.mul(a,Wt),i),u=n.mul(a,n.sub(c,n.ONE));if(!n.eql(n.sqr(u),s))throw new Error("Cannot find square root");return u}}return r%yh,wh(r)}var Da=(r,e)=>(Y(r,e)&Z)===Z,vh=["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=vh.reduce((n,s)=>(n[s]="function",n),e);return Xe(r,t)}function Eh(r,e,t){if(t<fe)throw new Error("Expected power > 0");if(t===fe)return r.ONE;if(t===Z)return e;let n=r.ONE,s=e;for(;t>fe;)t&Z&&(n=r.mul(n,s)),s=r.sqr(s),t>>=Z;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 ko(r,e){let t=e!==void 0?e:r.toString(2).length,n=Math.ceil(t/8);return{nBitLength:t,nByteLength:n}}function Sn(r,e,t=!1,n={}){if(r<=fe)throw new Error(`Expected Field ORDER > 0, got ${r}`);let{nBitLength:s,nByteLength:o}=ko(r,e);if(o>2048)throw new Error("Field lengths over 2048 bytes are not supported");let i=xh(r),a=Object.freeze({ORDER:r,BITS:s,BYTES:o,MASK:qr(s),ZERO:fe,ONE:Z,create:c=>Y(c,r),isValid:c=>{if(typeof c!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof c}`);return fe<=c&&c<r},is0:c=>c===fe,isOdd:c=>(c&Z)===Z,neg:c=>Y(-c,r),eql:(c,u)=>c===u,sqr:c=>Y(c*c,r),add:(c,u)=>Y(c+u,r),sub:(c,u)=>Y(c-u,r),mul:(c,u)=>Y(c*u,r),pow:(c,u)=>Eh(a,c,u),div:(c,u)=>Y(c*An(u,r),r),sqrN:c=>c*c,addN:(c,u)=>c+u,subN:(c,u)=>c-u,mulN:(c,u)=>c*u,inv:c=>An(c,r),sqrt:n.sqrt||(c=>i(a,c)),invertBatch:c=>Bh(a,c),cmov:(c,u,f)=>f?u: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?_t(c):ht(c)}});return Object.freeze(a)}function Oa(r,e){if(!r.isOdd)throw new Error("Field doesn't have isOdd");let t=r.sqrt(e);return r.isOdd(t)?r.neg(t):t}function Va(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 No(r){let e=Va(r);return e+Math.ceil(e/2)}function Ha(r,e,t=!1){let n=r.length,s=Va(e),o=No(e);if(n<16||n<o||n>1024)throw new Error(`expected ${o}-1024 bytes of input, got ${n}`);let i=t?ht(r):_t(r),a=Y(i,e-Z)+Z;return t?jt(a,s):Lt(a,s)}var Sh=BigInt(0),Ro=BigInt(1);function In(r,e){let t=(s,o)=>{let i=o.negate();return s?i:o},n=s=>{let o=Math.ceil(e/s)+1,i=2**(s-1);return{windows:o,windowSize:i}};return{constTimeNegate:t,unsafeLadder(s,o){let i=r.ZERO,a=s;for(;o>Sh;)o&Ro&&(i=i.add(a)),a=a.double(),o>>=Ro;return i},precomputeWindow(s,o){let{windows:i,windowSize:a}=n(o),c=[],u=s,f=u;for(let l=0;l<i;l++){f=u,c.push(f);for(let d=1;d<a;d++)f=f.add(u),c.push(f);u=f.double()}return c},wNAF(s,o,i){let{windows:a,windowSize:c}=n(s),u=r.ZERO,f=r.BASE,l=BigInt(2**s-1),d=2**s,b=BigInt(s);for(let p=0;p<a;p++){let h=p*c,m=Number(i&l);i>>=b,m>c&&(m-=d,i+=Ro);let y=h,B=h+Math.abs(m)-1,w=p%2!==0,T=m<0;m===0?f=f.add(t(w,o[y])):u=u.add(t(T,o[B]))}return{p:u,f}},wNAFCached(s,o,i,a){let c=s._WINDOW_SIZE||1,u=o.get(s);return u||(u=this.precomputeWindow(s,c),c!==1&&o.set(s,a(u))),this.wNAF(c,u,i)}}}function $r(r){return Io(r.Fp),Xe(r,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...ko(r.n,r.nBitLength),...r,p:r.Fp.ORDER})}var Fe=BigInt(0),_e=BigInt(1),kn=BigInt(2),Ih=BigInt(8),kh={zip215:!0};function Nh(r){let e=$r(r);return Xe(r,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...e})}function Nn(r){let e=Nh(r),{Fp:t,n,prehash:s,hash:o,randomBytes:i,nByteLength:a,h:c}=e,u=kn<<BigInt(a*8)-_e,f=t.create,l=e.uvRatio||((E,g)=>{try{return{isValid:!0,value:t.sqrt(E*t.inv(g))}}catch{return{isValid:!1,value:Fe}}}),d=e.adjustScalarBytes||(E=>E),b=e.domain||((E,g,I)=>{if(g.length||I)throw new Error("Contexts/pre-hash are not supported");return E}),p=E=>typeof E=="bigint"&&Fe<E,h=(E,g)=>p(E)&&p(g)&&E<g,m=E=>E===Fe||h(E,u);function y(E,g){if(h(E,g))return E;throw new Error(`Expected valid scalar < ${g}, got ${typeof E} ${E}`)}function B(E){return E===Fe?E:y(E,n)}let w=new Map;function T(E){if(!(E instanceof x))throw new Error("ExtendedPoint expected")}class x{constructor(g,I,_,C){if(this.ex=g,this.ey=I,this.ez=_,this.et=C,!m(g))throw new Error("x required");if(!m(I))throw new Error("y required");if(!m(_))throw new Error("z required");if(!m(C))throw new Error("t required")}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(g){if(g instanceof x)throw new Error("extended point not allowed");let{x:I,y:_}=g||{};if(!m(I)||!m(_))throw new Error("invalid affine point");return new x(I,_,_e,f(I*_))}static normalizeZ(g){let I=t.invertBatch(g.map(_=>_.ez));return g.map((_,C)=>_.toAffine(I[C])).map(x.fromAffine)}_setWindowSize(g){this._WINDOW_SIZE=g,w.delete(this)}assertValidity(){let{a:g,d:I}=e;if(this.is0())throw new Error("bad point: ZERO");let{ex:_,ey:C,ez:O,et:V}=this,W=f(_*_),M=f(C*C),$=f(O*O),ae=f($*$),Q=f(W*g),ge=f($*f(Q+M)),me=f(ae+f(I*f(W*M)));if(ge!==me)throw new Error("bad point: equation left != right (1)");let le=f(_*C),ve=f(O*V);if(le!==ve)throw new Error("bad point: equation left != right (2)")}equals(g){T(g);let{ex:I,ey:_,ez:C}=this,{ex:O,ey:V,ez:W}=g,M=f(I*W),$=f(O*C),ae=f(_*W),Q=f(V*C);return M===$&&ae===Q}is0(){return this.equals(x.ZERO)}negate(){return new x(f(-this.ex),this.ey,this.ez,f(-this.et))}double(){let{a:g}=e,{ex:I,ey:_,ez:C}=this,O=f(I*I),V=f(_*_),W=f(kn*f(C*C)),M=f(g*O),$=I+_,ae=f(f($*$)-O-V),Q=M+V,ge=Q-W,me=M-V,le=f(ae*ge),ve=f(Q*me),it=f(ae*me),qt=f(ge*Q);return new x(le,ve,qt,it)}add(g){T(g);let{a:I,d:_}=e,{ex:C,ey:O,ez:V,et:W}=this,{ex:M,ey:$,ez:ae,et:Q}=g;if(I===BigInt(-1)){let Vi=f((O-C)*($+M)),Hi=f((O+C)*($-M)),Fs=f(Hi-Vi);if(Fs===Fe)return this.double();let Mi=f(V*kn*Q),Ki=f(W*kn*ae),Fi=Ki+Mi,qi=Hi+Vi,$i=Ki-Mi,du=f(Fi*Fs),pu=f(qi*$i),gu=f(Fi*$i),mu=f(Fs*qi);return new x(du,pu,mu,gu)}let ge=f(C*M),me=f(O*$),le=f(W*_*Q),ve=f(V*ae),it=f((C+O)*(M+$)-ge-me),qt=ve-le,Or=ve+le,Oi=f(me-I*ge),lu=f(it*qt),uu=f(Or*Oi),fu=f(it*Oi),hu=f(qt*Or);return new x(lu,uu,hu,fu)}subtract(g){return this.add(g.negate())}wNAF(g){return R.wNAFCached(this,w,g,x.normalizeZ)}multiply(g){let{p:I,f:_}=this.wNAF(y(g,n));return x.normalizeZ([I,_])[0]}multiplyUnsafe(g){let I=B(g);return I===Fe?N:this.equals(N)||I===_e?this:this.equals(A)?this.wNAF(I).p:R.unsafeLadder(this,I)}isSmallOrder(){return this.multiplyUnsafe(c).is0()}isTorsionFree(){return R.unsafeLadder(this,n).is0()}toAffine(g){let{ex:I,ey:_,ez:C}=this,O=this.is0();g==null&&(g=O?Ih:t.inv(C));let V=f(I*g),W=f(_*g),M=f(C*g);if(O)return{x:Fe,y:_e};if(M!==_e)throw new Error("invZ was invalid");return{x:V,y:W}}clearCofactor(){let{h:g}=e;return g===_e?this:this.multiplyUnsafe(g)}static fromHex(g,I=!1){let{d:_,a:C}=e,O=t.BYTES;g=te("pointHex",g,O);let V=g.slice(),W=g[O-1];V[O-1]=W&-129;let M=_t(V);M===Fe||(I?y(M,u):y(M,t.ORDER));let $=f(M*M),ae=f($-_e),Q=f(_*$-C),{isValid:ge,value:me}=l(ae,Q);if(!ge)throw new Error("Point.fromHex: invalid y coordinate");let le=(me&_e)===_e,ve=(W&128)!==0;if(!I&&me===Fe&&ve)throw new Error("Point.fromHex: x=0 and x_0=1");return ve!==le&&(me=f(-me)),x.fromAffine({x:me,y:M})}static fromPrivateKey(g){return P(g).point}toRawBytes(){let{x:g,y:I}=this.toAffine(),_=jt(I,t.BYTES);return _[_.length-1]|=g&_e?128:0,_}toHex(){return ft(this.toRawBytes())}}x.BASE=new x(e.Gx,e.Gy,_e,f(e.Gx*e.Gy)),x.ZERO=new x(Fe,_e,_e,Fe);let{BASE:A,ZERO:N}=x,R=In(x,a*8);function G(E){return Y(E,n)}function q(E){return G(_t(E))}function P(E){let g=a;E=te("private key",E,g);let I=te("hashed private key",o(E),2*g),_=d(I.slice(0,g)),C=I.slice(g,2*g),O=q(_),V=A.multiply(O),W=V.toRawBytes();return{head:_,prefix:C,scalar:O,point:V,pointBytes:W}}function ie(E){return P(E).pointBytes}function re(E=new Uint8Array,...g){let I=dt(...g);return q(o(b(I,te("context",E),!!s)))}function Le(E,g,I={}){E=te("message",E),s&&(E=s(E));let{prefix:_,scalar:C,pointBytes:O}=P(g),V=re(I.context,_,E),W=A.multiply(V).toRawBytes(),M=re(I.context,W,O,E),$=G(V+M*C);B($);let ae=dt(W,jt($,t.BYTES));return te("result",ae,a*2)}let v=kh;function k(E,g,I,_=v){let{context:C,zip215:O}=_,V=t.BYTES;E=te("signature",E,2*V),g=te("message",g),s&&(g=s(g));let W=_t(E.slice(V,2*V)),M,$,ae;try{M=x.fromHex(I,O),$=x.fromHex(E.slice(0,V),O),ae=A.multiplyUnsafe(W)}catch{return!1}if(!O&&M.isSmallOrder())return!1;let Q=re(C,$.toRawBytes(),M.toRawBytes(),g);return $.add(M.multiplyUnsafe(Q)).subtract(ae).clearCofactor().equals(x.ZERO)}return A._setWindowSize(8),{CURVE:e,getPublicKey:ie,sign:Le,verify:k,ExtendedPoint:x,utils:{getExtendedPublicKey:P,randomPrivateKey:()=>i(t.BYTES),precompute(E=8,g=x.BASE){return g._setWindowSize(E),g.multiply(BigInt(3)),g}}}}var _o=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),Ma=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),tm=BigInt(0),Rh=BigInt(1),To=BigInt(2),Th=BigInt(5),Ka=BigInt(10),_h=BigInt(20),Lh=BigInt(40),Fa=BigInt(80);function Ch(r){let e=_o,n=r*r%e*r%e,s=J(n,To,e)*n%e,o=J(s,Rh,e)*r%e,i=J(o,Th,e)*o%e,a=J(i,Ka,e)*i%e,c=J(a,_h,e)*a%e,u=J(c,Lh,e)*c%e,f=J(u,Fa,e)*u%e,l=J(f,Fa,e)*u%e,d=J(l,Ka,e)*i%e;return{pow_p_5_8:J(d,To,e)*r%e,b2:n}}function Uh(r){return r[0]&=248,r[31]&=127,r[31]|=64,r}function Ph(r,e){let t=_o,n=Y(e*e*e,t),s=Y(n*n*e,t),o=Ch(r*s).pow_p_5_8,i=Y(r*n*o,t),a=Y(e*i*i,t),c=i,u=Y(i*Ma,t),f=a===r,l=a===Y(-r,t),d=a===Y(-r*Ma,t);return f&&(i=c),(l||d)&&(i=u),Da(i,t)&&(i=Y(-i,t)),{isValid:f||l,value:i}}var pt=Sn(_o,void 0,!0),Lo={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:pt,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:BigInt(8),Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:yr,randomBytes:gr,adjustScalarBytes:Uh,uvRatio:Ph},br=Nn(Lo);function qa(r,e,t){if(e.length>255)throw new Error("Context is too big");return wn(wo("SigEd25519 no Ed25519 collisions"),new Uint8Array([t?1:0,e.length]),e,r)}var rm=Nn({...Lo,domain:qa}),nm=Nn({...Lo,domain:qa,prehash:yr});var Dh=(pt.ORDER+BigInt(3))/BigInt(8),sm=pt.pow(To,Dh),om=pt.sqrt(pt.neg(pt.ONE)),im=(pt.ORDER-BigInt(5))/BigInt(8),am=BigInt(486662);var cm=Oa(pt,pt.neg(BigInt(486664)));var lm=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),um=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),fm=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),hm=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952");var dm=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");var wr=32,gt=64,Rn=32;function $a(){let r=br.utils.randomPrivateKey(),e=br.getPublicKey(r);return{privateKey:Wa(r,e),publicKey:e}}function Ga(r){if(r.length!==Rn)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:Wa(e,t),publicKey:t}}function za(r,e){let t=r.subarray(0,Rn);return br.sign(e instanceof Uint8Array?e:e.subarray(),t)}function ja(r,e,t){return br.verify(e,t instanceof Uint8Array?t:t.subarray(),r)}function Wa(r,e){let t=new Uint8Array(gt);for(let n=0;n<Rn;n++)t[n]=r[n],t[Rn+n]=e[n];return t}var we={get(r=globalThis){let e=r.crypto;if(e==null||e.subtle==null)throw Object.assign(new Error("Missing Web Crypto API. The most likely cause of this error is that this page is being accessed from an insecure context (i.e. not HTTPS). For more information and possible resolutions see https://github.com/libp2p/js-libp2p/blob/main/packages/crypto/README.md#web-crypto-api"),{code:"ERR_MISSING_WEB_CRYPTO"});return e}};var Co={alg:"A128GCM",ext:!0,k:"scm9jmO_4BJAgdwWGVulLg",key_ops:["encrypt","decrypt"],kty:"oct"};function Uo(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=we.get();t*=8;async function c(l,d){let b=a.getRandomValues(new Uint8Array(o)),p=a.getRandomValues(new Uint8Array(n)),h={name:e,iv:p};typeof d=="string"&&(d=K(d));let m;if(d.length===0){m=await a.subtle.importKey("jwk",Co,{name:"AES-GCM"},!0,["encrypt"]);try{let B={name:"PBKDF2",salt:b,iterations:i,hash:{name:s}},w=await a.subtle.importKey("raw",d,{name:"PBKDF2"},!1,["deriveKey"]);m=await a.subtle.deriveKey(B,w,{name:e,length:t},!0,["encrypt"])}catch{m=await a.subtle.importKey("jwk",Co,{name:"AES-GCM"},!0,["encrypt"])}}else{let B={name:"PBKDF2",salt:b,iterations:i,hash:{name:s}},w=await a.subtle.importKey("raw",d,{name:"PBKDF2"},!1,["deriveKey"]);m=await a.subtle.deriveKey(B,w,{name:e,length:t},!0,["encrypt"])}let y=await a.subtle.encrypt(h,m,l);return be([b,h.iv,new Uint8Array(y)])}async function u(l,d){let b=l.subarray(0,o),p=l.subarray(o,o+n),h=l.subarray(o+n),m={name:e,iv:p};typeof d=="string"&&(d=K(d));let y;if(d.length===0)try{let w={name:"PBKDF2",salt:b,iterations:i,hash:{name:s}},T=await a.subtle.importKey("raw",d,{name:"PBKDF2"},!1,["deriveKey"]);y=await a.subtle.deriveKey(w,T,{name:e,length:t},!0,["decrypt"])}catch{y=await a.subtle.importKey("jwk",Co,{name:"AES-GCM"},!0,["decrypt"])}else{let w={name:"PBKDF2",salt:b,iterations:i,hash:{name:s}},T=await a.subtle.importKey("raw",d,{name:"PBKDF2"},!1,["deriveKey"]);y=await a.subtle.deriveKey(w,T,{name:e,length:t},!0,["decrypt"])}let B=await a.subtle.decrypt(m,y,h);return new Uint8Array(B)}return{encrypt:c,decrypt:u}}async function xr(r,e){let n=await Uo().encrypt(r,e);return pn.encode(n)}var Po=new Float32Array([-0]),Ct=new Uint8Array(Po.buffer);function Za(r,e,t){Po[0]=r,e[t]=Ct[0],e[t+1]=Ct[1],e[t+2]=Ct[2],e[t+3]=Ct[3]}function Ja(r,e){return Ct[0]=r[e],Ct[1]=r[e+1],Ct[2]=r[e+2],Ct[3]=r[e+3],Po[0]}var Do=new Float64Array([-0]),Be=new Uint8Array(Do.buffer);function Xa(r,e,t){Do[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 Qa(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],Do[0]}var Vh=BigInt(Number.MAX_SAFE_INTEGER),Hh=BigInt(Number.MIN_SAFE_INTEGER),Ne=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 Yt;if(e<Vh&&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>ec&&(s=0n,++n>ec&&(n=0n))),new r(Number(s),Number(n))}static fromNumber(e){if(e===0)return Yt;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):Yt}},Yt=new Ne(0,0);Yt.toBigInt=function(){return 0n};Yt.zzEncode=Yt.zzDecode=function(){return this};Yt.length=function(){return 1};var ec=4294967296n;function tc(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 rc(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 Oo(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 qe(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 Vo=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,qe(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 qe(this,4);return Tn(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw qe(this,4);return Tn(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw qe(this,4);let e=Ja(this.buf,this.pos);return this.pos+=4,e}double(){if(this.pos+8>this.len)throw qe(this,4);let e=Qa(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 qe(this,e);return this.pos+=e,t===n?new Uint8Array(0):this.buf.subarray(t,n)}string(){let e=this.bytes();return rc(e,0,e.length)}skip(e){if(typeof e=="number"){if(this.pos+e>this.len)throw qe(this,e);this.pos+=e}else do if(this.pos>=this.len)throw qe(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 Ne(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 qe(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 qe(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 qe(this,8);let e=Tn(this.buf,this.pos+=4),t=Tn(this.buf,this.pos+=4);return new Ne(e,t)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){return this.readLongVarint().toNumber(!0)}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 Ho(r){return new Vo(r instanceof Uint8Array?r:r.subarray())}function $e(r,e){let t=Ho(r);return e.decode(t)}function Mo(r){let e=r??8192,t=e>>>1,n,s=e;return function(i){if(i<1||i>t)return Ee(i);s+i>e&&(n=Ee(e),s=0);let a=n.subarray(s,s+=i);return s&7&&(s=(s|7)+1),a}}var Zt=class{fn;len;next;val;constructor(e,t,n){this.fn=e,this.len=t,this.next=void 0,this.val=n}};function Ko(){}var qo=class{head;tail;len;next;constructor(e){this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}},Mh=Mo();function Kh(r){return globalThis.Buffer!=null?Ee(r):Mh(r)}var jr=class{len;head;tail;states;constructor(){this.len=0,this.head=new Zt(Ko,0,0),this.tail=this.head,this.states=null}_push(e,t,n){return this.tail=this.tail.next=new Zt(e,t,n),this.len+=t,this}uint32(e){return this.len+=(this.tail=this.tail.next=new $o((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(Gr,10,Ne.fromNumber(e)):this.uint32(e)}sint32(e){return this.uint32((e<<1^e>>31)>>>0)}uint64(e){let t=Ne.fromBigInt(e);return this._push(Gr,t.length(),t)}uint64Number(e){let t=Ne.fromNumber(e);return this._push(Gr,t.length(),t)}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=Ne.fromBigInt(e).zzEncode();return this._push(Gr,t.length(),t)}sint64Number(e){let t=Ne.fromNumber(e).zzEncode();return this._push(Gr,t.length(),t)}sint64String(e){return this.sint64(BigInt(e))}bool(e){return this._push(Fo,1,e?1:0)}fixed32(e){return this._push(zr,4,e>>>0)}sfixed32(e){return this.fixed32(e)}fixed64(e){let t=Ne.fromBigInt(e);return this._push(zr,4,t.lo)._push(zr,4,t.hi)}fixed64Number(e){let t=Ne.fromNumber(e);return this._push(zr,4,t.lo)._push(zr,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(Za,4,e)}double(e){return this._push(Xa,8,e)}bytes(e){let t=e.length>>>0;return t===0?this._push(Fo,1,0):this.uint32(t)._push(qh,t,e)}string(e){let t=tc(e);return t!==0?this.uint32(t)._push(Oo,t,e):this._push(Fo,1,0)}fork(){return this.states=new qo(this),this.head=this.tail=new Zt(Ko,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 Zt(Ko,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 Fo(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 $o=class extends Zt{next;constructor(e,t){super(Fh,e,t),this.next=void 0}};function Gr(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 zr(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 qh(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($h,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 $h(r,e,t){e.set(r,t)}function Gh(r,e,t){r.length<40?Oo(r,e,t):e.utf8Write!=null?e.utf8Write(r,t):e.set(K(r),t)}function Go(){return new jr}function Ge(r,e){let t=Go();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 _n(r,e,t,n){return{name:r,type:e,encode:t,decode:n}}function zo(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 _n("enum",vr.VARINT,t,n)}function ze(r,e){return _n("message",vr.LENGTH_DELIMITED,r,e)}var X;(function(r){r.RSA="RSA",r.Ed25519="Ed25519",r.Secp256k1="Secp256k1"})(X||(X={}));var jo;(function(r){r[r.RSA=0]="RSA",r[r.Ed25519=1]="Ed25519",r[r.Secp256k1=2]="Secp256k1"})(jo||(jo={}));(function(r){r.codec=()=>zo(jo)})(X||(X={}));var Qe;(function(r){let e;r.codec=()=>(e==null&&(e=ze((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=>$e(t,r.codec())})(Qe||(Qe={}));var et;(function(r){let e;r.codec=()=>(e==null&&(e=ze((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=>$e(t,r.codec())})(et||(et={}));var Er=class{_key;constructor(e){this._key=Br(e,wr)}verify(e,t){return ja(this._key,t,e)}marshal(){return this._key}get bytes(){return Qe.encode({Type:X.Ed25519,Data:this.marshal()}).subarray()}equals(e){return ue(this.bytes,e.bytes)}hash(){let e=ye.digest(this.bytes);return Ce(e)?e.then(({bytes:t})=>t):e.bytes}},Ut=class{_key;_publicKey;constructor(e,t){this._key=Br(e,gt),this._publicKey=Br(t,wr)}sign(e){return za(this._key,e)}get public(){return new Er(this._publicKey)}marshal(){return this._key}get bytes(){return et.encode({Type:X.Ed25519,Data:this.marshal()}).subarray()}equals(e){return ue(this.bytes,e.bytes)}async hash(){let e=ye.digest(this.bytes),t;return Ce(e)?{bytes:t}=await e:t=e.bytes,t}async id(){let e=St.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 zh(r){if(r.length>gt){r=Br(r,gt+wr);let n=r.subarray(0,gt),s=r.subarray(gt,r.length);return new Ut(n,s)}r=Br(r,gt);let e=r.subarray(0,gt),t=r.subarray(wr);return new Ut(e,t)}function jh(r){return r=Br(r,wr),new Er(r)}async function Wh(){let{privateKey:r,publicKey:e}=$a();return new Ut(r,e)}async function sc(r){let{privateKey:e,publicKey:t}=Ga(r);return new Ut(e,t)}function Br(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 F(r,e="utf8"){let t=mn[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(r.buffer,r.byteOffset,r.byteLength).toString("utf8"):t.encoder.encode(r).substring(1)}var Yh={"P-256":256,"P-384":384,"P-521":521},Zh=Object.keys(Yh),py=Zh.join(" / ");var si={};de(si,{MAX_RSA_KEY_SIZE:()=>Rr,RsaPrivateKey:()=>Qt,RsaPublicKey:()=>Nr,fromJwk:()=>Bd,generateKeyPair:()=>Ad,unmarshalRsaPrivateKey:()=>ri,unmarshalRsaPublicKey:()=>Ed});function Jt(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 Vt={};de(Vt,{exportToPem:()=>bd,importFromPem:()=>jc,jwkToPkcs1:()=>pd,jwkToPkix:()=>md,pkcs1ToJwk:()=>dd,pkixToJwk:()=>gd});var Cn=class extends dr{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,yn(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 hr(this),this.iHash.update(e),this}digestInto(e){hr(this),bo(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()}},Wr=(r,e,t)=>new Cn(r,e).update(t).digest();Wr.create=(r,e)=>new Cn(r,e);function Xh(r,e,t,n){yn(r);let s=Na({dkLen:32,asyncTick:10},n),{c:o,dkLen:i,asyncTick:a}=s;if(fr(o),fr(i),fr(a),o<1)throw new Error("PBKDF2: iterations (c) should be >= 1");let c=Nt(e),u=Nt(t),f=new Uint8Array(i),l=Wr.create(r,c),d=l._cloneInto().update(u);return{c:o,dkLen:i,asyncTick:a,DK:f,PRF:l,PRFSalt:d}}function Qh(r,e,t,n,s){return r.destroy(),e.destroy(),n&&n.destroy(),s.fill(0),t}async function Yo(r,e,t,n){let{c:s,dkLen:o,asyncTick:i,DK:a,PRF:c,PRFSalt:u}=Xh(r,e,t,n),f,l=new Uint8Array(4),d=pr(l),b=new Uint8Array(c.outputLen);for(let p=1,h=0;h<o;p++,h+=c.outputLen){let m=a.subarray(h,h+c.outputLen);d.setInt32(0,p,!1),(f=u._cloneInto(f)).update(l).digestInto(b),m.set(b.subarray(0,m.length)),await ka(s-1,i,()=>{c._cloneInto(f).update(b).digestInto(b);for(let y=0;y<m.length;y++)m[y]^=b[y]})}return Qh(c,u,a,f,b)}var H=$s(oc());function Xt(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 u=new Uint8Array(c);for(let f=a-1;f>=0;f--){let l=Math.pow(2,f*e);u[o-f-1]=Math.floor(s/l),s-=u[o-f-1]*l}return c}i*=Math.pow(2,e)}return new ArrayBuffer(0)}function Dn(...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 Jo(){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=Xt(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,Xt(o,8)-n}function ic(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 ac(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 Re(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 Ky=Math.log(2);function On(){if(typeof BigInt>"u")throw new Error("BigInt is not defined. Your environment doesn't implement BigInt.")}function Xo(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 xt(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 Zr=class{constructor(){this.items=[]}write(e){this.items.push(e)}final(){return Xo(this.items)}},Yr=[new Uint8Array([1])],cc="0123456789";var Ir="",We=new ArrayBuffer(0),Qo=new Uint8Array(0),Jr="EndOfContent",uc="OCTET STRING",fc="BIT STRING";function vt(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?H.BufferSourceConverter.toUint8Array(o.valueHex):Qo}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(!xt(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",We)}toJSON(){return{...super.toJSON(),isHexOnly:this.isHexOnly,valueHex:H.Convert.ToHex(this.valueHexView)}}},e.NAME="hexBlock",e}var yt=class{constructor({blockLength:e=0,error:t=Ir,warnings:n=[],valueBeforeDecode:s=Qo}={}){this.blockLength=e,this.error=t,this.warnings=n,this.valueBeforeDecodeView=H.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:H.Convert.ToHex(this.valueBeforeDecodeView)}}};yt.NAME="baseBlock";var Ae=class extends yt{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 Vn=class extends vt(yt){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?H.BufferSourceConverter.toUint8Array(e.valueHex):Qo,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",We}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=H.BufferSourceConverter.toUint8Array(e);if(!xt(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,u=this.valueHexView=new Uint8Array(255),f=255;for(;o[c]&128;){if(u[c-1]=o[c]&127,c++,c>=o.length)return this.error="End of input reached before message was fully decoded",-1;if(c===f){f+=255;let d=new Uint8Array(f);for(let b=0;b<u.length;b++)d[b]=u[b];u=this.valueHexView=new Uint8Array(f)}}this.blockLength=c+1,u[c-1]=o[c]&127;let l=new Uint8Array(c);for(let d=0;d<c;d++)l[d]=u[d];u=this.valueHexView=new Uint8Array(c),u.set(l),this.blockLength<=9?this.tagNumber=Xt(u,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 Hn=class extends yt{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=H.BufferSourceConverter.toUint8Array(e);if(!xt(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=Xt(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",We;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 S={},xe=class extends yt{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 Vn(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 Zr;t||hc(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?We:n.final()}toJSON(){let e={...super.toJSON(),idBlock:this.idBlock.toJSON(),lenBlock:this.lenBlock.toJSON(),valueBlock:this.valueBlock.toJSON(),name:this.name,optional:this.optional};return this.primitiveSchema&&(e.primitiveSchema=this.primitiveSchema.toJSON()),e}toString(e="ascii"){return e==="ascii"?this.onAsciiEncoding():H.Convert.ToHex(this.toBER())}onAsciiEncoding(){return`${this.constructor.NAME} : ${H.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 ac(t,n)}};xe.NAME="BaseBlock";function hc(r){if(r instanceof S.Constructed)for(let e of r.valueBlock.value)hc(e)&&(r.lenBlock.isIndefiniteForm=!0);return!!r.lenBlock.isIndefiniteForm}var Mn=class extends xe{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}'`}};Mn.NAME="BaseStringBlock";var Kn=class extends vt(Ae){constructor({isHexOnly:e=!0,...t}={}){super(t),this.isHexOnly=e}};Kn.NAME="PrimitiveValueBlock";var dc,Fn=class extends xe{constructor(e={}){super(e,Kn),this.idBlock.isConstructed=!1}};dc=Fn;S.Primitive=dc;Fn.NAME="PRIMITIVE";function cd(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 vs(r,e=0,t=r.length){let n=e,s=new xe({},Ae),o=new yt;if(!xt(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=xe;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=S.EndOfContent;break;case 1:c=S.Boolean;break;case 2:c=S.Integer;break;case 3:c=S.BitString;break;case 4:c=S.OctetString;break;case 5:c=S.Null;break;case 6:c=S.ObjectIdentifier;break;case 10:c=S.Enumerated;break;case 12:c=S.Utf8String;break;case 13:c=S.RelativeObjectIdentifier;break;case 14:c=S.TIME;break;case 15:return s.error="[UNIVERSAL 15] is reserved by ASN.1 standard",{offset:-1,result:s};case 16:c=S.Sequence;break;case 17:c=S.Set;break;case 18:c=S.NumericString;break;case 19:c=S.PrintableString;break;case 20:c=S.TeletexString;break;case 21:c=S.VideotexString;break;case 22:c=S.IA5String;break;case 23:c=S.UTCTime;break;case 24:c=S.GeneralizedTime;break;case 25:c=S.GraphicString;break;case 26:c=S.VisibleString;break;case 27:c=S.GeneralString;break;case 28:c=S.UniversalString;break;case 29:c=S.CharacterString;break;case 30:c=S.BmpString;break;case 31:c=S.DATE;break;case 32:c=S.TimeOfDay;break;case 33:c=S.DateTime;break;case 34:c=S.Duration;break;default:{let u=s.idBlock.isConstructed?new S.Constructed:new S.Primitive;u.idBlock=s.idBlock,u.lenBlock=s.lenBlock,u.warnings=s.warnings,s=u}}break;case 2:case 3:case 4:default:c=s.idBlock.isConstructed?S.Constructed:S.Primitive}return s=cd(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 kr(r){if(!r.byteLength){let e=new xe({},Ae);return e.error="Input buffer has zero length",{offset:-1,result:e}}return vs(H.BufferSourceConverter.toUint8Array(r).slice(),0,r.byteLength)}function ld(r,e){return r?1:e}var tt=class extends Ae{constructor({value:e=[],isIndefiniteForm:t=!1,...n}={}){super(n),this.value=e,this.isIndefiniteForm=t}fromBER(e,t,n){let s=H.BufferSourceConverter.toUint8Array(e);if(!xt(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(;ld(this.isIndefiniteForm,n)>0;){let i=vs(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===Jr)break}return this.isIndefiniteForm&&(this.value[this.value.length-1].constructor.NAME===Jr?this.value.pop():this.warnings.push("No EndOfContent block encoded")),o}toBER(e,t){let n=t||new Zr;for(let s=0;s<this.value.length;s++)this.value[s].toBER(e,n);return t?We:n.final()}toJSON(){let e={...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,value:[]};for(let t of this.value)e.value.push(t.toJSON());return e}};tt.NAME="ConstructedValueBlock";var pc,Dt=class extends xe{constructor(e={}){super(e,tt),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 hu=Object.create;var hn=Object.defineProperty;var du=Object.getOwnPropertyDescriptor;var pu=Object.getOwnPropertyNames;var gu=Object.getPrototypeOf,mu=Object.prototype.hasOwnProperty;var Ks=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),he=(r,e)=>{for(var t in e)hn(r,t,{get:e[t],enumerable:!0})},qi=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of pu(e))!mu.call(r,s)&&s!==t&&hn(r,s,{get:()=>e[s],enumerable:!(n=du(e,s))||n.enumerable});return r};var qs=(r,e,t)=>(t=r!=null?hu(gu(r)):{},qi(e||!r||!r.__esModule?hn(t,"default",{value:r,enumerable:!0}):t,r)),yu=r=>qi(hn({},"__esModule",{value:!0}),r);var tc=Ks(Er=>{"use strict";var jh="[object ArrayBuffer]",mt=class r{static isArrayBuffer(e){return Object.prototype.toString.call(e)===jh}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}},Wo="string",Wh=/^[0-9a-f]+$/i,Yh=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/,Zh=/^[a-zA-Z0-9-_]+$/,Cn=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=mt.toUint8Array(e),n="";for(let o=0;o<t.length;o++)n+=String.fromCharCode(t[o]);return decodeURIComponent(escape(n))}},Ue=class{static toString(e,t=!1){let n=mt.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===Wo&&Wh.test(e)}static isBase64(e){return typeof e===Wo&&Yh.test(e)}static isBase64Url(e){return typeof e===Wo&&Zh.test(e)}static ToString(e,t="utf8"){let n=mt.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 Ue.toString(n,!0);case"utf16":case"utf16be":return Ue.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 Ue.fromString(e,!0);case"utf16":case"utf16be":return Ue.fromString(e);default:throw new Error(`Unknown type of encoding '${t}'`)}}static ToBase64(e){let t=mt.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 Cn.fromString(e);case"utf16":case"utf16be":return Ue.fromString(e);case"utf16le":case"usc2":return Ue.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 Cn.toString(e);case"utf16":case"utf16be":return Ue.toString(e);case"utf16le":case"usc2":return Ue.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=mt.toUint8Array(e),n="";for(let s=0;s<t.length;s++)n+=String.fromCharCode(t[s]);return n}static ToHex(e){let t=mt.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 Ue.toString(e,t)}static FromUtf16String(e,t=!1){return Ue.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 Jh(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 Xh(...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 Qh(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}Er.BufferSourceConverter=mt;Er.Convert=Un;Er.assign=Jh;Er.combine=Xh;Er.isEqual=Qh});var zl=Ks((Qw,Gl)=>{"use strict";function $l(r,e){for(let t in e)Object.defineProperty(r,t,{value:e[t],enumerable:!0,configurable:!0});return r}function h0(r,e,t){if(!r||typeof r=="string")throw new TypeError("Please pass an Error to err-code");t||(t={}),typeof e=="object"&&(t=e,e=""),e&&(t.code=e);try{return $l(r,t)}catch{t.message=r.message,t.stack=r.stack;let s=function(){};return s.prototype=Object.create(Object.getPrototypeOf(r)),$l(new s,t)}}Gl.exports=h0});var Zl=Ks((ux,Yl)=>{function m0(){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)}Yl.exports=m0});var x0={};he(x0,{identify:()=>w0,multicodecs:()=>b0});var $i="/ipfs/id/1.0.0",Gi="/ipfs/id/push/1.0.0",zi="0.1.0",ji="id",Wi="id/push",Yi="1.0.0",Zi="1.0.0";var Ji=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 Xi="ERR_NOT_FOUND";var dn=(r,...e)=>{try{[...e]}catch{}};var Ws={};he(Ws,{base58btc:()=>ne,base58flickr:()=>Bu});var S0=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 at(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 bu(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),u=Math.log(a)/Math.log(256),f=Math.log(256)/Math.log(a);function l(p){if(p instanceof Uint8Array||(ArrayBuffer.isView(p)?p=new Uint8Array(p.buffer,p.byteOffset,p.byteLength):Array.isArray(p)&&(p=Uint8Array.from(p))),!(p instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(p.length===0)return"";for(var h=0,m=0,y=0,B=p.length;y!==B&&p[y]===0;)y++,h++;for(var w=(B-y)*f+1>>>0,R=new Uint8Array(w);y!==B;){for(var x=p[y],A=0,N=w-1;(x!==0||A<m)&&N!==-1;N--,A++)x+=256*R[N]>>>0,R[N]=x%a>>>0,x=x/a>>>0;if(x!==0)throw new Error("Non-zero carry");m=A,y++}for(var T=w-m;T!==w&&R[T]===0;)T++;for(var G=c.repeat(h);T<w;++T)G+=r.charAt(R[T]);return G}function d(p){if(typeof p!="string")throw new TypeError("Expected String");if(p.length===0)return new Uint8Array;var h=0;if(p[h]!==" "){for(var m=0,y=0;p[h]===c;)m++,h++;for(var B=(p.length-h)*u+1>>>0,w=new Uint8Array(B);p[h];){var R=t[p.charCodeAt(h)];if(R===255)return;for(var x=0,A=B-1;(R!==0||x<y)&&A!==-1;A--,x++)R+=a*w[A]>>>0,w[A]=R%256>>>0,R=R/256>>>0;if(R!==0)throw new Error("Non-zero carry");y=x,h++}if(p[h]!==" "){for(var N=B-y;N!==B&&w[N]===0;)N++;for(var T=new Uint8Array(m+(B-N)),G=m;N!==B;)T[G++]=w[N++];return T}}}function b(p){var h=d(p);if(h)return h;throw new Error(`Non-${e} character`)}return{encode:l,decodeUnsafe:d,decode:b}}var wu=bu,xu=wu,na=xu;var $s=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")}},Gs=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)}},zs=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 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 $s(e,t,n),this.decoder=new Gs(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 js(r,e,t,n)}function At({name:r,prefix:e,alphabet:t}){let{encode:n,decode:s}=na(t,r);return nr({prefix:e,name:r,encode:n,decode:o=>at(s(o))})}function vu(r,e,t,n){let s={};for(let f=0;f<e.length;++f)s[e[f]]=f;let o=r.length;for(;r[o-1]==="=";)--o;let i=new Uint8Array(o*t/8|0),a=0,c=0,u=0;for(let f=0;f<o;++f){let l=s[r[f]];if(l===void 0)throw new SyntaxError(`Non-${n} character`);c=c<<t|l,a+=t,a>=8&&(a-=8,i[u++]=255&c>>a)}if(a>=t||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return i}function Eu(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 ee({name:r,prefix:e,bitsPerChar:t,alphabet:n}){return nr({prefix:e,name:r,encode(s){return Eu(s,n,t)},decode(s){return vu(s,n,t,r)}})}var ne=At({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Bu=At({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Ys={};he(Ys,{base10:()=>Au});var Au=At({prefix:"9",name:"base10",alphabet:"0123456789"});var Zs={};he(Zs,{base16:()=>Iu,base16upper:()=>Su});var Iu=ee({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Su=ee({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Js={};he(Js,{base2:()=>ku});var ku=ee({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Xs={};he(Xs,{base256emoji:()=>Lu});var oa=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}"),Nu=oa.reduce((r,e,t)=>(r[t]=e,r),[]),Tu=oa.reduce((r,e,t)=>(r[e.codePointAt(0)]=t,r),[]);function Ru(r){return r.reduce((e,t)=>(e+=Nu[t],e),"")}function _u(r){let e=[];for(let t of r){let n=Tu[t.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${t}`);e.push(n)}return new Uint8Array(e)}var Lu=nr({prefix:"\u{1F680}",name:"base256emoji",encode:Ru,decode:_u});var Qs={};he(Qs,{base32:()=>ct,base32hex:()=>Ou,base32hexpad:()=>Vu,base32hexpadupper:()=>Hu,base32hexupper:()=>Du,base32pad:()=>Uu,base32padupper:()=>Pu,base32upper:()=>Cu,base32z:()=>Mu});var ct=ee({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Cu=ee({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Uu=ee({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Pu=ee({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Ou=ee({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Du=ee({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Vu=ee({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Hu=ee({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Mu=ee({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var eo={};he(eo,{base36:()=>Fu,base36upper:()=>Ku});var Fu=At({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Ku=At({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var no={};he(no,{base64:()=>to,base64pad:()=>qu,base64url:()=>ro,base64urlpad:()=>$u});var to=ee({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),qu=ee({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),ro=ee({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),$u=ee({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var so={};he(so,{base8:()=>Gu});var Gu=ee({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var oo={};he(oo,{identity:()=>zu});var zu=nr({prefix:"\0",name:"identity",encode:r=>ta(r),decode:r=>ea(r)});var K0=new TextEncoder,q0=new TextDecoder;var ao={};he(ao,{identity:()=>It});var Yu=ca,ia=128,Zu=127,Ju=~Zu,Xu=Math.pow(2,31);function ca(r,e,t){e=e||[],t=t||0;for(var n=t;r>=Xu;)e[t++]=r&255|ia,r/=128;for(;r&Ju;)e[t++]=r&255|ia,r>>>=7;return e[t]=r|0,ca.bytes=t-n+1,e}var Qu=io,ef=128,aa=127;function io(r,n){var t=0,n=n||0,s=0,o=n,i,a=r.length;do{if(o>=a)throw io.bytes=0,new RangeError("Could not decode varint");i=r[o++],t+=s<28?(i&aa)<<s:(i&aa)*Math.pow(2,s),s+=7}while(i>=ef);return io.bytes=o-n,t}var tf=Math.pow(2,7),rf=Math.pow(2,14),nf=Math.pow(2,21),sf=Math.pow(2,28),of=Math.pow(2,35),af=Math.pow(2,42),cf=Math.pow(2,49),lf=Math.pow(2,56),uf=Math.pow(2,63),ff=function(r){return r<tf?1:r<rf?2:r<nf?3:r<sf?4:r<of?5:r<af?6:r<cf?7:r<lf?8:r<uf?9:10},hf={encode:Yu,decode:Qu,encodingLength:ff},df=hf,Cr=df;function Ur(r,e=0){return[Cr.decode(r,e),Cr.decode.bytes]}function sr(r,e,t=0){return Cr.encode(r,e,t),e}function or(r){return Cr.encodingLength(r)}function Je(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 qt(r){let e=at(r),[t,n]=Ur(e),[s,o]=Ur(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 la(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 ua=0,pf="identity",fa=at;function gf(r){return Je(ua,fa(r))}var It={code:ua,name:pf,encode:fa,digest:gf};var uo={};he(uo,{sha256:()=>ye,sha512:()=>mf});function lo({name:r,code:e,encode:t}){return new co(r,e,t)}var co=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?Je(this.code,t):t.then(n=>Je(this.code,n))}else throw Error("Unknown type, must be binary type")}};function da(r){return async e=>new Uint8Array(await crypto.subtle.digest(r,e))}var ye=lo({name:"sha2-256",code:18,encode:da("SHA-256")}),mf=lo({name:"sha2-512",code:19,encode:da("SHA-512")});function pa(r,e){let{bytes:t,version:n}=r;switch(n){case 0:return bf(t,fo(r),e??ne.encoder);default:return wf(t,fo(r),e??ct.encoder)}}var ga=new WeakMap;function fo(r){let e=ga.get(r);if(e==null){let t=new Map;return ga.set(r,t),t}return e}var He=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!==Pr)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==xf)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=Je(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&&la(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[vf]===!0){let{version:n,multihash:s,code:o}=t,i=qt(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!==Pr)throw new Error(`Version 0 CID must use dag-pb (code: ${Pr}) 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,Pr,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=at(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,d]=Ur(e.subarray(t));return t+=d,l},s=n(),o=Pr;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(),u=t+c,f=u-i;return{version:s,codec:o,multihashCode:a,digestSize:c,multihashSize:f,size:u}}static parse(e,t){let[n,s]=yf(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 fo(o).set(n,e),o}};function yf(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 ct.prefix:{let t=e??ct;return[ct.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 bf(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 wf(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 Pr=112,xf=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 vf=Symbol.for("@ipld/js-cid/CID");var St={...oo,...Js,...so,...Ys,...Zs,...Qs,...eo,...Ws,...no,...Xs},up={...uo,...ao};function de(r,e){if(r===e)return!0;if(r.byteLength!==e.byteLength)return!1;for(let t=0;t<r.byteLength;t++)if(r[t]!==e[t])return!1;return!0}var Ef=Symbol.for("nodejs.util.inspect.custom"),ya=Object.values(St).map(r=>r.decoder).reduce((r,e)=>r.or(e),St.identity.decoder),ba=114,ho=36,po=37,Or=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()})`}[Ji]=!0;toString(){return this.string==null&&(this.string=ne.encode(this.multihash.bytes).slice(1)),this.string}toCID(){return He.createV1(ba,this.multihash)}toBytes(){return this.multihash.bytes}toJSON(){return this.toString()}equals(e){if(e==null)return!1;if(e instanceof Uint8Array)return de(this.multihash.bytes,e);if(typeof e=="string")return Bf(e).equals(this);if(e?.multihash?.bytes!=null)return de(this.multihash.bytes,e.multihash.bytes);throw new Error("not valid Id")}[Ef](){return`PeerId(${this.toString()})`}},ar=class extends Or{type="RSA";publicKey;constructor(e){super({...e,type:"RSA"}),this.publicKey=e.publicKey}},cr=class extends Or{type="Ed25519";publicKey;constructor(e){super({...e,type:"Ed25519"}),this.publicKey=e.multihash.digest}},lr=class extends Or{type="secp256k1";publicKey;constructor(e){super({...e,type:"secp256k1"}),this.publicKey=e.multihash.digest}};function Bf(r,e){if(e=e??ya,r.charAt(0)==="1"||r.charAt(0)==="Q"){let t=qt(ne.decode(`z${r}`));return r.startsWith("12D")?new cr({multihash:t}):r.startsWith("16U")?new lr({multihash:t}):new ar({multihash:t})}return go(ya.decode(r))}function go(r){try{let e=qt(r);if(e.code===It.code){if(e.digest.length===ho)return new cr({multihash:e});if(e.digest.length===po)return new lr({multihash:e})}if(e.code===ye.code)return new ar({multihash:e})}catch{return Af(He.decode(r))}throw new Error("Supplied PeerID CID is invalid")}function Af(r){if(r==null||r.multihash==null||r.version==null||r.version===1&&r.code!==ba)throw new Error("Supplied PeerID CID is invalid");let e=r.multihash;if(e.code===ye.code)return new ar({multihash:r.multihash});if(e.code===It.code){if(e.digest.length===ho)return new cr({multihash:r.multihash});if(e.digest.length===po)return new lr({multihash:r.multihash})}throw new Error("Supplied PeerID CID is invalid")}async function Dr(r,e){return r.length===ho?new cr({multihash:Je(It.code,r),privateKey:e}):r.length===po?new lr({multihash:Je(It.code,r),privateKey:e}):new ar({multihash:await ye.digest(r),publicKey:r,privateKey:e})}var zo={};he(zo,{Ed25519PrivateKey:()=>Zt,Ed25519PublicKey:()=>qr,generateKeyPair:()=>$h,generateKeyPairFromSeed:()=>ec,unmarshalEd25519PrivateKey:()=>Kh,unmarshalEd25519PublicKey:()=>qh});function kt(r){return globalThis.Buffer!=null?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r}function lt(r=0){return globalThis.Buffer?.alloc!=null?kt(globalThis.Buffer.alloc(r)):new Uint8Array(r)}function xe(r=0){return globalThis.Buffer?.allocUnsafe!=null?kt(globalThis.Buffer.allocUnsafe(r)):new Uint8Array(r)}function Ie(r,e){if(globalThis.Buffer!=null)return kt(globalThis.Buffer.concat(r,e));e==null&&(e=r.reduce((s,o)=>s+o.length,0));let t=xe(e),n=0;for(let s of r)t.set(s,n),n+=s.length;return kt(t)}function xa(r,e,t,n){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:n}}}var wa=xa("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),mo=xa("ascii","a",r=>{let e="a";for(let t=0;t<r.length;t++)e+=String.fromCharCode(r[t]);return e},r=>{r=r.substring(1);let e=xe(r.length);for(let t=0;t<r.length;t++)e[t]=r.charCodeAt(t);return e}),If={utf8:wa,"utf-8":wa,hex:St.base16,latin1:mo,ascii:mo,binary:mo,...St},gn=If;function F(r,e="utf8"){let t=gn[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?kt(globalThis.Buffer.from(r,"utf-8")):t.decoder.decode(`${t.prefix}${r}`)}function Ce(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(`Wrong positive integer: ${r}`)}function Sf(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}function yo(r,...e){if(!Sf(r))throw new Error("Expected Uint8Array");if(e.length>0&&!e.includes(r.length))throw new Error(`Expected Uint8Array of length ${e}, not of length=${r.length}`)}function mn(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 fr(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 va(r,e){yo(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;function Ea(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}var dr=r=>new DataView(r.buffer,r.byteOffset,r.byteLength),Me=(r,e)=>r<<32-e|r>>>e,kf=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!kf)throw new Error("Non little-endian hardware is not supported");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 bo(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}function Nt(r){if(typeof r=="string"&&(r=bo(r)),!Ea(r))throw new Error(`expected Uint8Array, got ${typeof r}`);return r}function bn(...r){let e=0;for(let n=0;n<r.length;n++){let s=r[n];if(!Ea(s))throw new Error("Uint8Array expected");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 hr=class{clone(){return this._cloneInto()}},Tf={}.toString;function Aa(r,e){if(e!==void 0&&Tf.call(e)!=="[object Object]")throw new Error("Options should be object or undefined");return Object.assign(r,e)}function wn(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 pr(r=32){if(yn&&typeof yn.getRandomValues=="function")return yn.getRandomValues(new Uint8Array(r));throw new Error("crypto.getRandomValues must be defined")}function Rf(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,u=n?0:4;r.setUint32(e+c,i,n),r.setUint32(e+u,a,n)}var gr=class extends hr{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=dr(this.buffer)}update(e){fr(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=dr(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){fr(this),va(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;Rf(n,s-8,BigInt(this.length*8),o),this.process(n,0);let a=dr(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let u=c/4,f=this.get();if(u>f.length)throw new Error("_sha2: outputLen bigger than state");for(let l=0;l<u;l++)a.setUint32(4*l,f[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 xn=BigInt(4294967295),wo=BigInt(32);function Ia(r,e=!1){return e?{h:Number(r&xn),l:Number(r>>wo&xn)}:{h:Number(r>>wo&xn)|0,l:Number(r&xn)|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}=Ia(r[s],e);[t[s],n[s]]=[o,i]}return[t,n]}var Lf=(r,e)=>BigInt(r>>>0)<<wo|BigInt(e>>>0),Cf=(r,e,t)=>r>>>t,Uf=(r,e,t)=>r<<32-t|e>>>t,Pf=(r,e,t)=>r>>>t|e<<32-t,Of=(r,e,t)=>r<<32-t|e>>>t,Df=(r,e,t)=>r<<64-t|e>>>t-32,Vf=(r,e,t)=>r>>>t-32|e<<64-t,Hf=(r,e)=>e,Mf=(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 Gf(r,e,t,n){let s=(e>>>0)+(n>>>0);return{h:r+t+(s/2**32|0)|0,l:s|0}}var zf=(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:Ia,split:_f,toBig:Lf,shrSH:Cf,shrSL:Uf,rotrSH:Pf,rotrSL:Of,rotrBH:Df,rotrBL:Vf,rotr32H:Hf,rotr32L:Mf,rotlSH:Ff,rotlSL:Kf,rotlBH:qf,rotlBL:$f,add:Gf,add3L:zf,add3H:jf,add4L:Wf,add4H:Yf,add5H:Jf,add5L:Zf},U=Xf;var[Qf,eh]=U.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))),Tt=new Uint32Array(80),Rt=new Uint32Array(80),xo=class extends gr{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:u,El:f,Fh:l,Fl:d,Gh:b,Gl:p,Hh:h,Hl:m}=this;return[e,t,n,s,o,i,a,c,u,f,l,d,b,p,h,m]}set(e,t,n,s,o,i,a,c,u,f,l,d,b,p,h,m){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=u|0,this.El=f|0,this.Fh=l|0,this.Fl=d|0,this.Gh=b|0,this.Gl=p|0,this.Hh=h|0,this.Hl=m|0}process(e,t){for(let w=0;w<16;w++,t+=4)Tt[w]=e.getUint32(t),Rt[w]=e.getUint32(t+=4);for(let w=16;w<80;w++){let R=Tt[w-15]|0,x=Rt[w-15]|0,A=U.rotrSH(R,x,1)^U.rotrSH(R,x,8)^U.shrSH(R,x,7),N=U.rotrSL(R,x,1)^U.rotrSL(R,x,8)^U.shrSL(R,x,7),T=Tt[w-2]|0,G=Rt[w-2]|0,q=U.rotrSH(T,G,19)^U.rotrBH(T,G,61)^U.shrSH(T,G,6),P=U.rotrSL(T,G,19)^U.rotrBL(T,G,61)^U.shrSL(T,G,6),ie=U.add4L(N,P,Rt[w-7],Rt[w-16]),re=U.add4H(ie,A,q,Tt[w-7],Tt[w-16]);Tt[w]=re|0,Rt[w]=ie|0}let{Ah:n,Al:s,Bh:o,Bl:i,Ch:a,Cl:c,Dh:u,Dl:f,Eh:l,El:d,Fh:b,Fl:p,Gh:h,Gl:m,Hh:y,Hl:B}=this;for(let w=0;w<80;w++){let R=U.rotrSH(l,d,14)^U.rotrSH(l,d,18)^U.rotrBH(l,d,41),x=U.rotrSL(l,d,14)^U.rotrSL(l,d,18)^U.rotrBL(l,d,41),A=l&b^~l&h,N=d&p^~d&m,T=U.add5L(B,x,N,eh[w],Rt[w]),G=U.add5H(T,y,R,A,Qf[w],Tt[w]),q=T|0,P=U.rotrSH(n,s,28)^U.rotrBH(n,s,34)^U.rotrBH(n,s,39),ie=U.rotrSL(n,s,28)^U.rotrBL(n,s,34)^U.rotrBL(n,s,39),re=n&o^n&a^o&a,Le=s&i^s&c^i&c;y=h|0,B=m|0,h=b|0,m=p|0,b=l|0,p=d|0,{h:l,l:d}=U.add(u|0,f|0,G|0,q|0),u=a|0,f=c|0,a=o|0,c=i|0,o=n|0,i=s|0;let v=U.add3L(q,ie,Le);n=U.add3H(v,G,P,re),s=v|0}({h:n,l:s}=U.add(this.Ah|0,this.Al|0,n|0,s|0)),{h:o,l:i}=U.add(this.Bh|0,this.Bl|0,o|0,i|0),{h:a,l:c}=U.add(this.Ch|0,this.Cl|0,a|0,c|0),{h:u,l:f}=U.add(this.Dh|0,this.Dl|0,u|0,f|0),{h:l,l:d}=U.add(this.Eh|0,this.El|0,l|0,d|0),{h:b,l:p}=U.add(this.Fh|0,this.Fl|0,b|0,p|0),{h,l:m}=U.add(this.Gh|0,this.Gl|0,h|0,m|0),{h:y,l:B}=U.add(this.Hh|0,this.Hl|0,y|0,B|0),this.set(n,s,o,i,a,c,u,f,l,d,b,p,h,m,y,B)}roundClean(){Tt.fill(0),Rt.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 mr=wn(()=>new xo);var En={};he(En,{bitGet:()=>ah,bitLen:()=>ih,bitMask:()=>Vr,bitSet:()=>ch,bytesToHex:()=>ft,bytesToNumberBE:()=>ht,bytesToNumberLE:()=>_t,concatBytes:()=>dt,createHmacDrbg:()=>Bo,ensureBytes:()=>te,equalBytes:()=>sh,hexToBytes:()=>Gt,hexToNumber:()=>Eo,isBytes:()=>Fe,numberToBytesBE:()=>Lt,numberToBytesLE:()=>zt,numberToHexUnpadded:()=>Ta,numberToVarBytesBE:()=>nh,utf8ToBytes:()=>oh,validateObject:()=>Xe});var Na=BigInt(0),vn=BigInt(1),th=BigInt(2);function Fe(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}var rh=Array.from({length:256},(r,e)=>e.toString(16).padStart(2,"0"));function ft(r){if(!Fe(r))throw new Error("Uint8Array expected");let e="";for(let t=0;t<r.length;t++)e+=rh[r[t]];return e}function Ta(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 ut={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function Sa(r){if(r>=ut._0&&r<=ut._9)return r-ut._0;if(r>=ut._A&&r<=ut._F)return r-(ut._A-10);if(r>=ut._a&&r<=ut._f)return r-(ut._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 ht(r){return Eo(ft(r))}function _t(r){if(!Fe(r))throw new Error("Uint8Array expected");return Eo(ft(Uint8Array.from(r).reverse()))}function Lt(r,e){return Gt(r.toString(16).padStart(e*2,"0"))}function zt(r,e){return Lt(r,e).reverse()}function nh(r){return Gt(Ta(r))}function te(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(Fe(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 dt(...r){let e=0;for(let s=0;s<r.length;s++){let o=r[s];if(!Fe(o))throw new Error("Uint8Array expected");e+=o.length}let t=new Uint8Array(e),n=0;for(let s=0;s<r.length;s++){let o=r[s];t.set(o,n),n+=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))}function ih(r){let e;for(e=0;r>Na;r>>=vn,e+=1);return e}function ah(r,e){return r>>BigInt(e)&vn}var ch=(r,e,t)=>r|(t?vn:Na)<<BigInt(e),Vr=r=>(th<<BigInt(r-1))-vn,vo=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=vo(r),s=vo(r),o=0,i=()=>{n.fill(1),s.fill(0),o=0},a=(...l)=>t(s,n,...l),c=(l=vo())=>{s=a(ka([0]),l),n=a(),l.length!==0&&(s=a(ka([1]),l),n=a())},u=()=>{if(o++>=1e3)throw new Error("drbg: tried 1000 values");let l=0,d=[];for(;l<e;){n=a();let b=n.slice();d.push(b),l+=n.length}return dt(...d)};return(l,d)=>{i(),c(l);let b;for(;!(b=d(u()));)c();return i(),b}}var lh={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"||Fe(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 Xe(r,e,t={}){let n=(s,o,i)=>{let a=lh[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 ue=BigInt(0),Z=BigInt(1),jt=BigInt(2),uh=BigInt(3),Ao=BigInt(4),Ra=BigInt(5),_a=BigInt(8),fh=BigInt(9),hh=BigInt(16);function Y(r,e){let t=r%e;return t>=ue?t:e+t}function dh(r,e,t){if(t<=ue||e<ue)throw new Error("Expected power/modulo > 0");if(t===Z)return ue;let n=Z;for(;e>ue;)e&Z&&(n=n*r%t),r=r*r%t,e>>=Z;return n}function J(r,e,t){let n=r;for(;e-- >ue;)n*=n,n%=t;return n}function Bn(r,e){if(r===ue||e<=ue)throw new Error(`invert: expected positive integers, got n=${r} mod=${e}`);let t=Y(r,e),n=e,s=ue,o=Z,i=Z,a=ue;for(;t!==ue;){let u=n/t,f=n%t,l=s-i*u,d=o-a*u;n=t,t=f,s=i,o=a,i=l,a=d}if(n!==Z)throw new Error("invert: does not exist");return Y(s,e)}function ph(r){let e=(r-Z)/jt,t,n,s;for(t=r-Z,n=0;t%jt===ue;t/=jt,n++);for(s=jt;s<r&&dh(s,e,r)!==r-Z;s++);if(n===1){let i=(r+Z)/Ao;return function(c,u){let f=c.pow(u,i);if(!c.eql(c.sqr(f),u))throw new Error("Cannot find square root");return f}}let o=(t+Z)/jt;return function(a,c){if(a.pow(c,e)===a.neg(a.ONE))throw new Error("Cannot find square root");let u=n,f=a.pow(a.mul(a.ONE,s),t),l=a.pow(c,o),d=a.pow(c,t);for(;!a.eql(d,a.ONE);){if(a.eql(d,a.ZERO))return a.ZERO;let b=1;for(let h=a.sqr(d);b<u&&!a.eql(h,a.ONE);b++)h=a.sqr(h);let p=a.pow(f,Z<<BigInt(u-b-1));f=a.sqr(p),l=a.mul(l,p),d=a.mul(d,f),u=b}return l}}function gh(r){if(r%Ao===uh){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%_a===Ra){let e=(r-Ra)/_a;return function(n,s){let o=n.mul(s,jt),i=n.pow(o,e),a=n.mul(s,i),c=n.mul(n.mul(a,jt),i),u=n.mul(a,n.sub(c,n.ONE));if(!n.eql(n.sqr(u),s))throw new Error("Cannot find square root");return u}}return r%hh,ph(r)}var La=(r,e)=>(Y(r,e)&Z)===Z,mh=["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=mh.reduce((n,s)=>(n[s]="function",n),e);return Xe(r,t)}function yh(r,e,t){if(t<ue)throw new Error("Expected power > 0");if(t===ue)return r.ONE;if(t===Z)return e;let n=r.ONE,s=e;for(;t>ue;)t&Z&&(n=r.mul(n,s)),s=r.sqr(s),t>>=Z;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 So(r,e){let t=e!==void 0?e:r.toString(2).length,n=Math.ceil(t/8);return{nBitLength:t,nByteLength:n}}function An(r,e,t=!1,n={}){if(r<=ue)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=gh(r),a=Object.freeze({ORDER:r,BITS:s,BYTES:o,MASK:Vr(s),ZERO:ue,ONE:Z,create:c=>Y(c,r),isValid:c=>{if(typeof c!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof c}`);return ue<=c&&c<r},is0:c=>c===ue,isOdd:c=>(c&Z)===Z,neg:c=>Y(-c,r),eql:(c,u)=>c===u,sqr:c=>Y(c*c,r),add:(c,u)=>Y(c+u,r),sub:(c,u)=>Y(c-u,r),mul:(c,u)=>Y(c*u,r),pow:(c,u)=>yh(a,c,u),div:(c,u)=>Y(c*Bn(u,r),r),sqrN:c=>c*c,addN:(c,u)=>c+u,subN:(c,u)=>c-u,mulN:(c,u)=>c*u,inv:c=>Bn(c,r),sqrt:n.sqrt||(c=>i(a,c)),invertBatch:c=>bh(a,c),cmov:(c,u,f)=>f?u:c,toBytes:c=>t?zt(c,o):Lt(c,o),fromBytes:c=>{if(c.length!==o)throw new Error(`Fp.fromBytes: expected ${o}, got ${c.length}`);return t?_t(c):ht(c)}});return Object.freeze(a)}function Ca(r,e){if(!r.isOdd)throw new Error("Field doesn't have isOdd");let t=r.sqrt(e);return r.isOdd(t)?r.neg(t):t}function 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 ko(r){let e=Ua(r);return e+Math.ceil(e/2)}function Pa(r,e,t=!1){let n=r.length,s=Ua(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?ht(r):_t(r),a=Y(i,e-Z)+Z;return t?zt(a,s):Lt(a,s)}var xh=BigInt(0),No=BigInt(1);function In(r,e){let t=(s,o)=>{let i=o.negate();return s?i:o},n=s=>{let o=Math.ceil(e/s)+1,i=2**(s-1);return{windows:o,windowSize:i}};return{constTimeNegate:t,unsafeLadder(s,o){let i=r.ZERO,a=s;for(;o>xh;)o&No&&(i=i.add(a)),a=a.double(),o>>=No;return i},precomputeWindow(s,o){let{windows:i,windowSize:a}=n(o),c=[],u=s,f=u;for(let l=0;l<i;l++){f=u,c.push(f);for(let d=1;d<a;d++)f=f.add(u),c.push(f);u=f.double()}return c},wNAF(s,o,i){let{windows:a,windowSize:c}=n(s),u=r.ZERO,f=r.BASE,l=BigInt(2**s-1),d=2**s,b=BigInt(s);for(let p=0;p<a;p++){let h=p*c,m=Number(i&l);i>>=b,m>c&&(m-=d,i+=No);let y=h,B=h+Math.abs(m)-1,w=p%2!==0,R=m<0;m===0?f=f.add(t(w,o[y])):u=u.add(t(R,o[B]))}return{p:u,f}},wNAFCached(s,o,i,a){let c=s._WINDOW_SIZE||1,u=o.get(s);return u||(u=this.precomputeWindow(s,c),c!==1&&o.set(s,a(u))),this.wNAF(c,u,i)}}}function Hr(r){return Io(r.Fp),Xe(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 Ke=BigInt(0),_e=BigInt(1),Sn=BigInt(2),vh=BigInt(8),Eh={zip215:!0};function Bh(r){let e=Hr(r);return Xe(r,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...e})}function kn(r){let e=Bh(r),{Fp:t,n,prehash:s,hash:o,randomBytes:i,nByteLength:a,h:c}=e,u=Sn<<BigInt(a*8)-_e,f=t.create,l=e.uvRatio||((E,g)=>{try{return{isValid:!0,value:t.sqrt(E*t.inv(g))}}catch{return{isValid:!1,value:Ke}}}),d=e.adjustScalarBytes||(E=>E),b=e.domain||((E,g,S)=>{if(g.length||S)throw new Error("Contexts/pre-hash are not supported");return E}),p=E=>typeof E=="bigint"&&Ke<E,h=(E,g)=>p(E)&&p(g)&&E<g,m=E=>E===Ke||h(E,u);function y(E,g){if(h(E,g))return E;throw new Error(`Expected valid scalar < ${g}, got ${typeof E} ${E}`)}function B(E){return E===Ke?E:y(E,n)}let w=new Map;function R(E){if(!(E instanceof x))throw new Error("ExtendedPoint expected")}class x{constructor(g,S,_,C){if(this.ex=g,this.ey=S,this.ez=_,this.et=C,!m(g))throw new Error("x required");if(!m(S))throw new Error("y required");if(!m(_))throw new Error("z required");if(!m(C))throw new Error("t required")}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(g){if(g instanceof x)throw new Error("extended point not allowed");let{x:S,y:_}=g||{};if(!m(S)||!m(_))throw new Error("invalid affine point");return new x(S,_,_e,f(S*_))}static normalizeZ(g){let S=t.invertBatch(g.map(_=>_.ez));return g.map((_,C)=>_.toAffine(S[C])).map(x.fromAffine)}_setWindowSize(g){this._WINDOW_SIZE=g,w.delete(this)}assertValidity(){let{a:g,d:S}=e;if(this.is0())throw new Error("bad point: ZERO");let{ex:_,ey:C,ez:D,et:V}=this,W=f(_*_),M=f(C*C),$=f(D*D),ae=f($*$),Q=f(W*g),ge=f($*f(Q+M)),me=f(ae+f(S*f(W*M)));if(ge!==me)throw new Error("bad point: equation left != right (1)");let le=f(_*C),we=f(D*V);if(le!==we)throw new Error("bad point: equation left != right (2)")}equals(g){R(g);let{ex:S,ey:_,ez:C}=this,{ex:D,ey:V,ez:W}=g,M=f(S*W),$=f(D*C),ae=f(_*W),Q=f(V*C);return M===$&&ae===Q}is0(){return this.equals(x.ZERO)}negate(){return new x(f(-this.ex),this.ey,this.ez,f(-this.et))}double(){let{a:g}=e,{ex:S,ey:_,ez:C}=this,D=f(S*S),V=f(_*_),W=f(Sn*f(C*C)),M=f(g*D),$=S+_,ae=f(f($*$)-D-V),Q=M+V,ge=Q-W,me=M-V,le=f(ae*ge),we=f(Q*me),it=f(ae*me),Kt=f(ge*Q);return new x(le,we,Kt,it)}add(g){R(g);let{a:S,d:_}=e,{ex:C,ey:D,ez:V,et:W}=this,{ex:M,ey:$,ez:ae,et:Q}=g;if(S===BigInt(-1)){let Oi=f((D-C)*($+M)),Di=f((D+C)*($-M)),Fs=f(Di-Oi);if(Fs===Ke)return this.double();let Vi=f(V*Sn*Q),Hi=f(W*Sn*ae),Mi=Hi+Vi,Fi=Di+Oi,Ki=Hi-Vi,cu=f(Mi*Fs),lu=f(Fi*Ki),uu=f(Mi*Ki),fu=f(Fs*Fi);return new x(cu,lu,fu,uu)}let ge=f(C*M),me=f(D*$),le=f(W*_*Q),we=f(V*ae),it=f((C+D)*(M+$)-ge-me),Kt=we-le,Lr=we+le,Pi=f(me-S*ge),su=f(it*Kt),ou=f(Lr*Pi),iu=f(it*Pi),au=f(Kt*Lr);return new x(su,ou,au,iu)}subtract(g){return this.add(g.negate())}wNAF(g){return T.wNAFCached(this,w,g,x.normalizeZ)}multiply(g){let{p:S,f:_}=this.wNAF(y(g,n));return x.normalizeZ([S,_])[0]}multiplyUnsafe(g){let S=B(g);return S===Ke?N:this.equals(N)||S===_e?this:this.equals(A)?this.wNAF(S).p:T.unsafeLadder(this,S)}isSmallOrder(){return this.multiplyUnsafe(c).is0()}isTorsionFree(){return T.unsafeLadder(this,n).is0()}toAffine(g){let{ex:S,ey:_,ez:C}=this,D=this.is0();g==null&&(g=D?vh:t.inv(C));let V=f(S*g),W=f(_*g),M=f(C*g);if(D)return{x:Ke,y:_e};if(M!==_e)throw new Error("invZ was invalid");return{x:V,y:W}}clearCofactor(){let{h:g}=e;return g===_e?this:this.multiplyUnsafe(g)}static fromHex(g,S=!1){let{d:_,a:C}=e,D=t.BYTES;g=te("pointHex",g,D);let V=g.slice(),W=g[D-1];V[D-1]=W&-129;let M=_t(V);M===Ke||(S?y(M,u):y(M,t.ORDER));let $=f(M*M),ae=f($-_e),Q=f(_*$-C),{isValid:ge,value:me}=l(ae,Q);if(!ge)throw new Error("Point.fromHex: invalid y coordinate");let le=(me&_e)===_e,we=(W&128)!==0;if(!S&&me===Ke&&we)throw new Error("Point.fromHex: x=0 and x_0=1");return we!==le&&(me=f(-me)),x.fromAffine({x:me,y:M})}static fromPrivateKey(g){return P(g).point}toRawBytes(){let{x:g,y:S}=this.toAffine(),_=zt(S,t.BYTES);return _[_.length-1]|=g&_e?128:0,_}toHex(){return ft(this.toRawBytes())}}x.BASE=new x(e.Gx,e.Gy,_e,f(e.Gx*e.Gy)),x.ZERO=new x(Ke,_e,_e,Ke);let{BASE:A,ZERO:N}=x,T=In(x,a*8);function G(E){return Y(E,n)}function q(E){return G(_t(E))}function P(E){let g=a;E=te("private key",E,g);let S=te("hashed private key",o(E),2*g),_=d(S.slice(0,g)),C=S.slice(g,2*g),D=q(_),V=A.multiply(D),W=V.toRawBytes();return{head:_,prefix:C,scalar:D,point:V,pointBytes:W}}function ie(E){return P(E).pointBytes}function re(E=new Uint8Array,...g){let S=dt(...g);return q(o(b(S,te("context",E),!!s)))}function Le(E,g,S={}){E=te("message",E),s&&(E=s(E));let{prefix:_,scalar:C,pointBytes:D}=P(g),V=re(S.context,_,E),W=A.multiply(V).toRawBytes(),M=re(S.context,W,D,E),$=G(V+M*C);B($);let ae=dt(W,zt($,t.BYTES));return te("result",ae,a*2)}let v=Eh;function k(E,g,S,_=v){let{context:C,zip215:D}=_,V=t.BYTES;E=te("signature",E,2*V),g=te("message",g),s&&(g=s(g));let W=_t(E.slice(V,2*V)),M,$,ae;try{M=x.fromHex(S,D),$=x.fromHex(E.slice(0,V),D),ae=A.multiplyUnsafe(W)}catch{return!1}if(!D&&M.isSmallOrder())return!1;let Q=re(C,$.toRawBytes(),M.toRawBytes(),g);return $.add(M.multiplyUnsafe(Q)).subtract(ae).clearCofactor().equals(x.ZERO)}return A._setWindowSize(8),{CURVE:e,getPublicKey:ie,sign:Le,verify:k,ExtendedPoint:x,utils:{getExtendedPublicKey:P,randomPrivateKey:()=>i(t.BYTES),precompute(E=8,g=x.BASE){return g._setWindowSize(E),g.multiply(BigInt(3)),g}}}}var Ro=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),Oa=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),ig=BigInt(0),Ah=BigInt(1),To=BigInt(2),Ih=BigInt(5),Da=BigInt(10),Sh=BigInt(20),kh=BigInt(40),Va=BigInt(80);function Nh(r){let e=Ro,n=r*r%e*r%e,s=J(n,To,e)*n%e,o=J(s,Ah,e)*r%e,i=J(o,Ih,e)*o%e,a=J(i,Da,e)*i%e,c=J(a,Sh,e)*a%e,u=J(c,kh,e)*c%e,f=J(u,Va,e)*u%e,l=J(f,Va,e)*u%e,d=J(l,Da,e)*i%e;return{pow_p_5_8:J(d,To,e)*r%e,b2:n}}function Th(r){return r[0]&=248,r[31]&=127,r[31]|=64,r}function Rh(r,e){let t=Ro,n=Y(e*e*e,t),s=Y(n*n*e,t),o=Nh(r*s).pow_p_5_8,i=Y(r*n*o,t),a=Y(e*i*i,t),c=i,u=Y(i*Oa,t),f=a===r,l=a===Y(-r,t),d=a===Y(-r*Oa,t);return f&&(i=c),(l||d)&&(i=u),La(i,t)&&(i=Y(-i,t)),{isValid:f||l,value:i}}var pt=An(Ro,void 0,!0),_o={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:pt,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:BigInt(8),Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:mr,randomBytes:pr,adjustScalarBytes:Th,uvRatio:Rh},yr=kn(_o);function Ha(r,e,t){if(e.length>255)throw new Error("Context is too big");return bn(bo("SigEd25519 no Ed25519 collisions"),new Uint8Array([t?1:0,e.length]),e,r)}var ag=kn({..._o,domain:Ha}),cg=kn({..._o,domain:Ha,prehash:mr});var _h=(pt.ORDER+BigInt(3))/BigInt(8),lg=pt.pow(To,_h),ug=pt.sqrt(pt.neg(pt.ONE)),fg=(pt.ORDER-BigInt(5))/BigInt(8),hg=BigInt(486662);var dg=Ca(pt,pt.neg(BigInt(486664)));var pg=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),gg=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),mg=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),yg=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952");var bg=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");var br=32,gt=64,Nn=32;function Ma(){let r=yr.utils.randomPrivateKey(),e=yr.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=yr.getPublicKey(e);return{privateKey:$a(e,t),publicKey:t}}function Ka(r,e){let t=r.subarray(0,Nn);return yr.sign(e instanceof Uint8Array?e:e.subarray(),t)}function qa(r,e,t){return yr.verify(e,t instanceof Uint8Array?t:t.subarray(),r)}function $a(r,e){let t=new Uint8Array(gt);for(let n=0;n<Nn;n++)t[n]=r[n],t[Nn+n]=e[n];return t}var Se={get(r=globalThis){let e=r.crypto;if(e==null||e.subtle==null)throw Object.assign(new Error("Missing Web Crypto API. The most likely cause of this error is that this page is being accessed from an insecure context (i.e. not HTTPS). For more information and possible resolutions see https://github.com/libp2p/js-libp2p/blob/main/packages/crypto/README.md#web-crypto-api"),{code:"ERR_MISSING_WEB_CRYPTO"});return e}};var Lo={alg:"A128GCM",ext:!0,k:"scm9jmO_4BJAgdwWGVulLg",key_ops:["encrypt","decrypt"],kty:"oct"};function Ga(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=Se.get();t*=8;async function c(l,d){let b=a.getRandomValues(new Uint8Array(o)),p=a.getRandomValues(new Uint8Array(n)),h={name:e,iv:p};typeof d=="string"&&(d=F(d));let m;if(d.length===0){m=await a.subtle.importKey("jwk",Lo,{name:"AES-GCM"},!0,["encrypt"]);try{let B={name:"PBKDF2",salt:b,iterations:i,hash:{name:s}},w=await a.subtle.importKey("raw",d,{name:"PBKDF2"},!1,["deriveKey"]);m=await a.subtle.deriveKey(B,w,{name:e,length:t},!0,["encrypt"])}catch{m=await a.subtle.importKey("jwk",Lo,{name:"AES-GCM"},!0,["encrypt"])}}else{let B={name:"PBKDF2",salt:b,iterations:i,hash:{name:s}},w=await a.subtle.importKey("raw",d,{name:"PBKDF2"},!1,["deriveKey"]);m=await a.subtle.deriveKey(B,w,{name:e,length:t},!0,["encrypt"])}let y=await a.subtle.encrypt(h,m,l);return Ie([b,h.iv,new Uint8Array(y)])}async function u(l,d){let b=l.subarray(0,o),p=l.subarray(o,o+n),h=l.subarray(o+n),m={name:e,iv:p};typeof d=="string"&&(d=F(d));let y;if(d.length===0)try{let w={name:"PBKDF2",salt:b,iterations:i,hash:{name:s}},R=await a.subtle.importKey("raw",d,{name:"PBKDF2"},!1,["deriveKey"]);y=await a.subtle.deriveKey(w,R,{name:e,length:t},!0,["decrypt"])}catch{y=await a.subtle.importKey("jwk",Lo,{name:"AES-GCM"},!0,["decrypt"])}else{let w={name:"PBKDF2",salt:b,iterations:i,hash:{name:s}},R=await a.subtle.importKey("raw",d,{name:"PBKDF2"},!1,["deriveKey"]);y=await a.subtle.deriveKey(w,R,{name:e,length:t},!0,["decrypt"])}let B=await a.subtle.decrypt(m,y,h);return new Uint8Array(B)}return{encrypt:c,decrypt:u}}async function wr(r,e){let n=await Ga().encrypt(r,e);return to.encode(n)}var Co=new Float32Array([-0]),Ct=new Uint8Array(Co.buffer);function za(r,e,t){Co[0]=r,e[t]=Ct[0],e[t+1]=Ct[1],e[t+2]=Ct[2],e[t+3]=Ct[3]}function ja(r,e){return Ct[0]=r[e],Ct[1]=r[e+1],Ct[2]=r[e+2],Ct[3]=r[e+3],Co[0]}var Uo=new Float64Array([-0]),ve=new Uint8Array(Uo.buffer);function Wa(r,e,t){Uo[0]=r,e[t]=ve[0],e[t+1]=ve[1],e[t+2]=ve[2],e[t+3]=ve[3],e[t+4]=ve[4],e[t+5]=ve[5],e[t+6]=ve[6],e[t+7]=ve[7]}function Ya(r,e){return ve[0]=r[e],ve[1]=r[e+1],ve[2]=r[e+2],ve[3]=r[e+3],ve[4]=r[e+4],ve[5]=r[e+5],ve[6]=r[e+6],ve[7]=r[e+7],Uo[0]}var Uh=BigInt(Number.MAX_SAFE_INTEGER),Ph=BigInt(Number.MIN_SAFE_INTEGER),Ne=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 Wt;if(e<Uh&&e>Ph)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 Wt;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):Wt}},Wt=new Ne(0,0);Wt.toBigInt=function(){return 0n};Wt.zzEncode=Wt.zzDecode=function(){return this};Wt.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 Po(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 qe(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 Oo=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,qe(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 qe(this,4);return Tn(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw qe(this,4);return Tn(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw qe(this,4);let e=ja(this.buf,this.pos);return this.pos+=4,e}double(){if(this.pos+8>this.len)throw qe(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 qe(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 qe(this,e);this.pos+=e}else do if(this.pos>=this.len)throw qe(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 Ne(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 qe(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 qe(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 qe(this,8);let e=Tn(this.buf,this.pos+=4),t=Tn(this.buf,this.pos+=4);return new Ne(e,t)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){return this.readLongVarint().toNumber(!0)}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 Do(r){return new Oo(r instanceof Uint8Array?r:r.subarray())}function $e(r,e){let t=Do(r);return e.decode(t)}function Vo(r){let e=r??8192,t=e>>>1,n,s=e;return function(i){if(i<1||i>t)return xe(i);s+i>e&&(n=xe(e),s=0);let a=n.subarray(s,s+=i);return s&7&&(s=(s|7)+1),a}}var Yt=class{fn;len;next;val;constructor(e,t,n){this.fn=e,this.len=t,this.next=void 0,this.val=n}};function Ho(){}var Fo=class{head;tail;len;next;constructor(e){this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}},Oh=Vo();function Dh(r){return globalThis.Buffer!=null?xe(r):Oh(r)}var Kr=class{len;head;tail;states;constructor(){this.len=0,this.head=new Yt(Ho,0,0),this.tail=this.head,this.states=null}_push(e,t,n){return this.tail=this.tail.next=new Yt(e,t,n),this.len+=t,this}uint32(e){return this.len+=(this.tail=this.tail.next=new Ko((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(Mr,10,Ne.fromNumber(e)):this.uint32(e)}sint32(e){return this.uint32((e<<1^e>>31)>>>0)}uint64(e){let t=Ne.fromBigInt(e);return this._push(Mr,t.length(),t)}uint64Number(e){let t=Ne.fromNumber(e);return this._push(Mr,t.length(),t)}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=Ne.fromBigInt(e).zzEncode();return this._push(Mr,t.length(),t)}sint64Number(e){let t=Ne.fromNumber(e).zzEncode();return this._push(Mr,t.length(),t)}sint64String(e){return this.sint64(BigInt(e))}bool(e){return this._push(Mo,1,e?1:0)}fixed32(e){return this._push(Fr,4,e>>>0)}sfixed32(e){return this.fixed32(e)}fixed64(e){let t=Ne.fromBigInt(e);return this._push(Fr,4,t.lo)._push(Fr,4,t.hi)}fixed64Number(e){let t=Ne.fromNumber(e);return this._push(Fr,4,t.lo)._push(Fr,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(za,4,e)}double(e){return this._push(Wa,8,e)}bytes(e){let t=e.length>>>0;return t===0?this._push(Mo,1,0):this.uint32(t)._push(Hh,t,e)}string(e){let t=Ja(e);return t!==0?this.uint32(t)._push(Po,t,e):this._push(Mo,1,0)}fork(){return this.states=new Fo(this),this.head=this.tail=new Yt(Ho,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 Yt(Ho,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=Dh(this.len),n=0;for(;e!=null;)e.fn(e.val,t,n),n+=e.len,e=e.next;return t}};function Mo(r,e,t){e[t]=r&255}function Vh(r,e,t){for(;r>127;)e[t++]=r&127|128,r>>>=7;e[t]=r}var Ko=class extends Yt{next;constructor(e,t){super(Vh,e,t),this.next=void 0}};function Mr(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 Fr(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 Hh(r,e,t){e.set(r,t)}globalThis.Buffer!=null&&(Kr.prototype.bytes=function(r){let e=r.length>>>0;return this.uint32(e),e>0&&this._push(Mh,e,r),this},Kr.prototype.string=function(r){let e=globalThis.Buffer.byteLength(r);return this.uint32(e),e>0&&this._push(Fh,e,r),this});function Mh(r,e,t){e.set(r,t)}function Fh(r,e,t){r.length<40?Po(r,e,t):e.utf8Write!=null?e.utf8Write(r,t):e.set(F(r),t)}function qo(){return new Kr}function Ge(r,e){let t=qo();return e.encode(r,t,{lengthDelimited:!1}),t.finish()}var xr;(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"})(xr||(xr={}));function Rn(r,e,t,n){return{name:r,type:e,encode:t,decode:n}}function $o(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 Rn("enum",xr.VARINT,t,n)}function ze(r,e){return Rn("message",xr.LENGTH_DELIMITED,r,e)}var X;(function(r){r.RSA="RSA",r.Ed25519="Ed25519",r.Secp256k1="Secp256k1"})(X||(X={}));var Go;(function(r){r[r.RSA=0]="RSA",r[r.Ed25519=1]="Ed25519",r[r.Secp256k1=2]="Secp256k1"})(Go||(Go={}));(function(r){r.codec=()=>$o(Go)})(X||(X={}));var Qe;(function(r){let e;r.codec=()=>(e==null&&(e=ze((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=>$e(t,r.codec())})(Qe||(Qe={}));var et;(function(r){let e;r.codec=()=>(e==null&&(e=ze((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=>$e(t,r.codec())})(et||(et={}));var qr=class{_key;constructor(e){this._key=vr(e,br)}verify(e,t){return qa(this._key,t,e)}marshal(){return this._key}get bytes(){return Qe.encode({Type:X.Ed25519,Data:this.marshal()}).subarray()}equals(e){return de(this.bytes,e.bytes)}hash(){let e=ye.digest(this.bytes);return Ce(e)?e.then(({bytes:t})=>t):e.bytes}},Zt=class{_key;_publicKey;constructor(e,t){this._key=vr(e,gt),this._publicKey=vr(t,br)}sign(e){return Ka(this._key,e)}get public(){return new qr(this._publicKey)}marshal(){return this._key}get bytes(){return et.encode({Type:X.Ed25519,Data:this.marshal()}).subarray()}equals(e){return de(this.bytes,e.bytes)}async hash(){let e=ye.digest(this.bytes),t;return Ce(e)?{bytes:t}=await e:t=e.bytes,t}async id(){let e=It.digest(this.public.bytes);return ne.encode(e.bytes).substring(1)}async export(e,t="libp2p-key"){if(t==="libp2p-key")return wr(this.bytes,e);throw new L(`export format '${t}' is not supported`,"ERR_INVALID_EXPORT_FORMAT")}};function Kh(r){if(r.length>gt){r=vr(r,gt+br);let n=r.subarray(0,gt),s=r.subarray(gt,r.length);return new Zt(n,s)}r=vr(r,gt);let e=r.subarray(0,gt),t=r.subarray(br);return new Zt(e,t)}function qh(r){return r=vr(r,br),new qr(r)}async function $h(){let{privateKey:r,publicKey:e}=Ma();return new Zt(r,e)}async function ec(r){let{privateKey:e,publicKey:t}=Fa(r);return new Zt(e,t)}function vr(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 K(r,e="utf8"){let t=gn[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(r.buffer,r.byteOffset,r.byteLength).toString("utf8"):t.encoder.encode(r).substring(1)}var ri={};he(ri,{MAX_RSA_KEY_SIZE:()=>tn,RsaPrivateKey:()=>Sr,RsaPublicKey:()=>en,fromJwk:()=>yd,generateKeyPair:()=>bd,unmarshalRsaPrivateKey:()=>ei,unmarshalRsaPublicKey:()=>md});function Jt(r){if(isNaN(r)||r<=0)throw new L("random bytes length must be a Number bigger than 0","ERR_INVALID_LENGTH");return pr(r)}var Dt={};he(Dt,{exportToPem:()=>fd,importFromPem:()=>hd,jwkToPkcs1:()=>ad,jwkToPkix:()=>ld,pkcs1ToJwk:()=>id,pkixToJwk:()=>cd});var Ln=class extends hr{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 fr(this),this.iHash.update(e),this}digestInto(e){fr(this),yo(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()}},$r=(r,e,t)=>new Ln(r,e).update(t).digest();$r.create=(r,e)=>new Ln(r,e);function Gh(r,e,t,n){mn(r);let s=Aa({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=Nt(e),u=Nt(t),f=new Uint8Array(i),l=$r.create(r,c),d=l._cloneInto().update(u);return{c:o,dkLen:i,asyncTick:a,DK:f,PRF:l,PRFSalt:d}}function zh(r,e,t,n,s){return r.destroy(),e.destroy(),n&&n.destroy(),s.fill(0),t}async function jo(r,e,t,n){let{c:s,dkLen:o,asyncTick:i,DK:a,PRF:c,PRFSalt:u}=Gh(r,e,t,n),f,l=new Uint8Array(4),d=dr(l),b=new Uint8Array(c.outputLen);for(let p=1,h=0;h<o;p++,h+=c.outputLen){let m=a.subarray(h,h+c.outputLen);d.setInt32(0,p,!1),(f=u._cloneInto(f)).update(l).digestInto(b),m.set(b.subarray(0,m.length)),await Ba(s-1,i,()=>{c._cloneInto(f).update(b).digestInto(b);for(let y=0;y<m.length;y++)m[y]^=b[y]})}return zh(c,u,a,f,b)}var H=qs(tc());function Xt(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 Ut(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 u=new Uint8Array(c);for(let f=a-1;f>=0;f--){let l=Math.pow(2,f*e);u[o-f-1]=Math.floor(s/l),s-=u[o-f-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 Yo(){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=Xt(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,Xt(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=Ut(i,8,n),c=new Uint8Array(a);return c[0]|=128,a}let s=Ut(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 Te(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 Bm=Math.log(2);function On(){if(typeof BigInt>"u")throw new Error("BigInt is not defined. Your environment doesn't implement BigInt.")}function Zo(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 xt(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 zr=class{constructor(){this.items=[]}write(e){this.items.push(e)}final(){return Zo(this.items)}},Gr=[new Uint8Array([1])],sc="0123456789";var Ar="",We=new ArrayBuffer(0),Jo=new Uint8Array(0),jr="EndOfContent",ic="OCTET STRING",ac="BIT STRING";function vt(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?H.BufferSourceConverter.toUint8Array(o.valueHex):Jo}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(!xt(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",We)}toJSON(){return{...super.toJSON(),isHexOnly:this.isHexOnly,valueHex:H.Convert.ToHex(this.valueHexView)}}},e.NAME="hexBlock",e}var yt=class{constructor({blockLength:e=0,error:t=Ar,warnings:n=[],valueBeforeDecode:s=Jo}={}){this.blockLength=e,this.error=t,this.warnings=n,this.valueBeforeDecodeView=H.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:H.Convert.ToHex(this.valueBeforeDecodeView)}}};yt.NAME="baseBlock";var Ee=class extends yt{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'")}};Ee.NAME="valueBlock";var Dn=class extends vt(yt){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?H.BufferSourceConverter.toUint8Array(e.valueHex):Jo,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",We}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=Ut(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=H.BufferSourceConverter.toUint8Array(e);if(!xt(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,u=this.valueHexView=new Uint8Array(255),f=255;for(;o[c]&128;){if(u[c-1]=o[c]&127,c++,c>=o.length)return this.error="End of input reached before message was fully decoded",-1;if(c===f){f+=255;let d=new Uint8Array(f);for(let b=0;b<u.length;b++)d[b]=u[b];u=this.valueHexView=new Uint8Array(f)}}this.blockLength=c+1,u[c-1]=o[c]&127;let l=new Uint8Array(c);for(let d=0;d<c;d++)l[d]=u[d];u=this.valueHexView=new Uint8Array(c),u.set(l),this.blockLength<=9?this.tagNumber=Xt(u,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}}};Dn.NAME="identificationBlock";var Vn=class extends yt{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=H.BufferSourceConverter.toUint8Array(e);if(!xt(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=Xt(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=Ut(this.length,8);if(s.byteLength>127)return this.error="Too big length",We;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}}};Vn.NAME="lengthBlock";var I={},be=class extends yt{constructor({name:e=Ar,optional:t=!1,primitiveSchema:n,...s}={},o){super(s),this.name=e,this.optional=t,n&&(this.primitiveSchema=n),this.idBlock=new Dn(s),this.lenBlock=new Vn(s),this.valueBlock=o?new o(s):new Ee(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 zr;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?We:n.final()}toJSON(){let e={...super.toJSON(),idBlock:this.idBlock.toJSON(),lenBlock:this.lenBlock.toJSON(),valueBlock:this.valueBlock.toJSON(),name:this.name,optional:this.optional};return this.primitiveSchema&&(e.primitiveSchema=this.primitiveSchema.toJSON()),e}toString(e="ascii"){return e==="ascii"?this.onAsciiEncoding():H.Convert.ToHex(this.toBER())}onAsciiEncoding(){return`${this.constructor.NAME} : ${H.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)}};be.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 Hn=class extends be{constructor({value:e=Ar,...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}'`}};Hn.NAME="BaseStringBlock";var Mn=class extends vt(Ee){constructor({isHexOnly:e=!0,...t}={}){super(t),this.isHexOnly=e}};Mn.NAME="PrimitiveValueBlock";var lc,Fn=class extends be{constructor(e={}){super(e,Mn),this.idBlock.isConstructed=!1}};lc=Fn;I.Primitive=lc;Fn.NAME="PRIMITIVE";function td(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({},Ee),o=new yt;if(!xt(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=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 u=s.idBlock.isConstructed?new I.Constructed:new I.Primitive;u.idBlock=s.idBlock,u.lenBlock=s.lenBlock,u.warnings=s.warnings,s=u}}break;case 2:case 3:case 4:default:c=s.idBlock.isConstructed?I.Constructed:I.Primitive}return s=td(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 Ir(r){if(!r.byteLength){let e=new be({},Ee);return e.error="Input buffer has zero length",{offset:-1,result:e}}return xs(H.BufferSourceConverter.toUint8Array(r).slice(),0,r.byteLength)}function rd(r,e){return r?1:e}var tt=class extends Ee{constructor({value:e=[],isIndefiniteForm:t=!1,...n}={}){super(n),this.value=e,this.isIndefiniteForm=t}fromBER(e,t,n){let s=H.BufferSourceConverter.toUint8Array(e);if(!xt(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(;rd(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===jr)break}return this.isIndefiniteForm&&(this.value[this.value.length-1].constructor.NAME===jr?this.value.pop():this.warnings.push("No EndOfContent block encoded")),o}toBER(e,t){let n=t||new zr;for(let s=0;s<this.value.length;s++)this.value[s].toBER(e,n);return t?We:n.final()}toJSON(){let e={...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,value:[]};for(let t of this.value)e.value.push(t.toJSON());return e}};tt.NAME="ConstructedValueBlock";var uc,Pt=class extends be{constructor(e={}){super(e,tt),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} :`}};pc=Dt;S.Constructed=pc;Dt.NAME="CONSTRUCTED";var qn=class extends Ae{fromBER(e,t,n){return t}toBER(e){return We}};qn.override="EndOfContentValueBlock";var gc,$n=class extends xe{constructor(e={}){super(e,qn),this.idBlock.tagClass=1,this.idBlock.tagNumber=0}};gc=$n;S.EndOfContent=gc;$n.NAME=Jr;var mc,Ot=class extends xe{constructor(e={}){super(e,Ae),this.idBlock.tagClass=1,this.idBlock.tagNumber=5}fromBER(e,t,n){return this.lenBlock.length>0&&this.warnings.push("Non-zero length of value block for Null type"),this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.blockLength+=n,t+n>e.byteLength?(this.error="End of input reached before message was fully decoded (inconsistent offset and length values)",-1):t+n}toBER(e,t){let n=new ArrayBuffer(2);if(!e){let s=new Uint8Array(n);s[0]=5,s[1]=0}return t&&t.write(n),n}onAsciiEncoding(){return`${this.constructor.NAME}`}};mc=Ot;S.Null=mc;Ot.NAME="NULL";var Gn=class extends vt(Ae){constructor({value:e,...t}={}){super(t),t.valueHex?this.valueHexView=H.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=H.BufferSourceConverter.toUint8Array(e);return xt(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,Jo.call(this),this.blockLength=n,t+n):-1}toBER(){return this.valueHexView.slice()}toJSON(){return{...super.toJSON(),value:this.value}}};Gn.NAME="BooleanValueBlock";var yc,zn=class extends xe{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}`}};yc=zn;S.Boolean=yc;zn.NAME="BOOLEAN";var jn=class extends vt(tt){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=tt.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===Jr){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, OCTET STRING may consists of OCTET STRINGs only",-1}if(i!==uc)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?tt.prototype.toBER.call(this,e,t):e?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),isConstructed:this.isConstructed}}};jn.NAME="OctetStringValueBlock";var bc,bt=class r extends xe{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=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=vs(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?Dt.prototype.onAsciiEncoding.call(this):`${this.constructor.NAME} : ${H.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 H.BufferSourceConverter.concat(e)}};bc=bt;S.OctetString=bc;bt.NAME=uc;var Wn=class extends vt(tt){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=tt.prototype.fromBER.call(this,e,t,n),s===-1)return s;for(let a of this.value){let c=a.constructor.NAME;if(c===Jr){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, BIT STRING may consists of BIT STRINGs only",-1}if(c!==fc)return this.error="BIT STRING may consists of BIT STRINGs only",-1;let u=a.valueBlock;if(this.unusedBits>0&&u.unusedBits>0)return this.error='Using of "unused bits" inside constructive BIT STRING allowed for least one only',-1;this.unusedBits=u.unusedBits}return s}let o=H.BufferSourceConverter.toUint8Array(e);if(!xt(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=vs(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 tt.prototype.toBER.call(this,e,t);if(e)return new ArrayBuffer(this.valueHexView.byteLength+1);if(!this.valueHexView.byteLength)return We;let n=new Uint8Array(this.valueHexView.length+1);return n[0]=this.unusedBits,n.set(this.valueHexView,1),n.buffer}toJSON(){return{...super.toJSON(),unusedBits:this.unusedBits,isConstructed:this.isConstructed}}};Wn.NAME="BitStringValueBlock";var wc,Sr=class extends xe{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=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 Dt.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)}`}}};wc=Sr;S.BitString=wc;Sr.NAME=fc;var xc;function ud(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,u=0,f=c<i?i:c,l=0;for(let d=f;d>=0;d--,l++){switch(!0){case l<a.length:u=o[i-l]+a[c-l]+t[0];break;default:u=o[i-l]+t[0]}switch(t[0]=u/10,!0){case l>=o.length:o=Dn(new Uint8Array([u%10]),o);break;default:o[i-l]=u%10}}return t[0]>0&&(o=Dn(t,o)),o}function lc(r){if(r>=Yr.length)for(let e=Yr.length;e<=r;e++){let t=new Uint8Array([0]),n=Yr[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=Dn(t,n)),Yr.push(n)}return Yr[r]}function fd(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,u,f=0;for(let l=c;l>=0;l--,f++)switch(u=o[i-f]-a[c-f]-t,!0){case u<0:t=1,o[i-f]=u+10;break;default:t=0,o[i-f]=u}if(t>0)for(let l=i-c+1;l>=0;l--,f++)if(u=o[i-f]-t,u<0)t=1,o[i-f]=u+10;else{t=0,o[i-f]=u;break}return o.slice()}var Xr=class extends vt(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=Jo.call(this)))}set valueDec(e){this._valueDec=e,this.isHexOnly=!1,this.valueHexView=new Uint8Array(ic(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 u=0;u<8;u++){if((s&1)===1)switch(n){case e:t=fd(lc(n),t),i="-";break;default:t=ud(t,lc(n))}n++,s>>=1}}for(let c=0;c<t.length;c++)t[c]&&(a=!0),a&&(i+=cc.charAt(t[c]));return a===!1&&(i+=cc.charAt(0)),i}};xc=Xr;Xr.NAME="IntegerValueBlock";Object.defineProperty(xc.prototype,"valueHex",{set:function(r){this.valueHexView=new Uint8Array(r),this.setValueHex()},get:function(){return this.valueHexView.slice().buffer}});var vc,ce=class r extends xe{constructor(e={}){super(e,Xr),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 Zr,s=t.toString(16).replace(/^-/,""),o=new Uint8Array(H.Convert.FromHex(s));if(t<0){let a=new Uint8Array(o.length+(o[0]&128?1:0));a[0]|=128;let u=BigInt(`0x${H.Convert.ToHex(a)}`)+t,f=H.BufferSourceConverter.toUint8Array(H.Convert.FromHex(u.toString(16)));f[0]|=128,n.write(f)}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()}`}};vc=ce;S.Integer=vc;ce.NAME="INTEGER";var Ec,Yn=class extends ce{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=10}};Ec=Yn;S.Enumerated=Ec;Yn.NAME="ENUMERATED";var Qr=class extends vt(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=H.BufferSourceConverter.toUint8Array(e);if(!xt(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=Xt(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",We;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=H.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}}};Qr.NAME="sidBlock";var Zn=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 Qr;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,We;t.push(s)}return Xo(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 Qr;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}};Zn.NAME="ObjectIdentifierValueBlock";var Bc,je=class extends xe{constructor(e={}){super(e,Zn),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()}}};Bc=je;S.ObjectIdentifier=Bc;je.NAME="OBJECT IDENTIFIER";var en=class extends vt(yt){constructor({valueDec:e=0,...t}={}){super(t),this.valueDec=e}fromBER(e,t,n){if(n===0)return t;let s=H.BufferSourceConverter.toUint8Array(e);if(!xt(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=Xt(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",We;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=H.Convert.ToHex(this.valueHexView):e=this.valueDec.toString(),e}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}};en.NAME="relativeSidBlock";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.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,We;n.push(o)}return Xo(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 en;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}};Jn.NAME="RelativeObjectIdentifierValueBlock";var Ac,Xn=class extends xe{constructor(e={}){super(e,Jn),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()}}};Ac=Xn;S.RelativeObjectIdentifier=Ac;Xn.NAME="RelativeObjectIdentifier";var Sc,pe=class extends Dt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=16}};Sc=pe;S.Sequence=Sc;pe.NAME="SEQUENCE";var Ic,Qn=class extends Dt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=17}};Ic=Qn;S.Set=Ic;Qn.NAME="SET";var es=class extends vt(Ae){constructor({...e}={}){super(e),this.isHexOnly=!0,this.value=Ir}toJSON(){return{...super.toJSON(),value:this.value}}};es.NAME="StringValueBlock";var ts=class extends es{};ts.NAME="SimpleStringValueBlock";var ke=class extends Mn{constructor({...e}={}){super(e,ts)}fromBuffer(e){this.valueBlock.value=String.fromCharCode.apply(null,H.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}};ke.NAME="SIMPLE STRING";var rs=class extends ke{fromBuffer(e){this.valueBlock.valueHexView=H.BufferSourceConverter.toUint8Array(e);try{this.valueBlock.value=H.Convert.ToUtf8String(e)}catch(t){this.warnings.push(`Error during "decodeURIComponent": ${t}, using raw string`),this.valueBlock.value=H.Convert.ToBinary(e)}}fromString(e){this.valueBlock.valueHexView=new Uint8Array(H.Convert.FromUtf8String(e)),this.valueBlock.value=e}};rs.NAME="Utf8StringValueBlock";var kc,wt=class extends rs{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=12}};kc=wt;S.Utf8String=kc;wt.NAME="UTF8String";var ns=class extends ke{fromBuffer(e){this.valueBlock.value=H.Convert.ToUtf16String(e),this.valueBlock.valueHexView=H.BufferSourceConverter.toUint8Array(e)}fromString(e){this.valueBlock.value=e,this.valueBlock.valueHexView=new Uint8Array(H.Convert.FromUtf16String(e))}};ns.NAME="BmpStringValueBlock";var Nc,ss=class extends ns{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=30}};Nc=ss;S.BmpString=Nc;ss.NAME="BMPString";var os=class extends ke{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}};os.NAME="UniversalStringValueBlock";var Rc,is=class extends os{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=28}};Rc=is;S.UniversalString=Rc;is.NAME="UniversalString";var Tc,as=class extends ke{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=18}};Tc=as;S.NumericString=Tc;as.NAME="NumericString";var _c,cs=class extends ke{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=19}};_c=cs;S.PrintableString=_c;cs.NAME="PrintableString";var Lc,ls=class extends ke{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=20}};Lc=ls;S.TeletexString=Lc;ls.NAME="TeletexString";var Cc,us=class extends ke{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=21}};Cc=us;S.VideotexString=Cc;us.NAME="VideotexString";var Uc,fs=class extends ke{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=22}};Uc=fs;S.IA5String=Uc;fs.NAME="IA5String";var Pc,hs=class extends ke{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=25}};Pc=hs;S.GraphicString=Pc;hs.NAME="GraphicString";var Dc,tn=class extends ke{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=26}};Dc=tn;S.VisibleString=Dc;tn.NAME="VisibleString";var Oc,ds=class extends ke{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=27}};Oc=ds;S.GeneralString=Oc;ds.NAME="GeneralString";var Vc,ps=class extends ke{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=29}};Vc=ps;S.CharacterString=Vc;ps.NAME="CharacterString";var Hc,rn=class extends tn{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,H.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]=Re(this.year<2e3?this.year-1900:this.year-2e3,2),t[1]=Re(this.month,2),t[2]=Re(this.day,2),t[3]=Re(this.hour,2),t[4]=Re(this.minute,2),t[5]=Re(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}}};Hc=rn;S.UTCTime=Hc;rn.NAME="UTCTime";var Mc,gs=class extends rn{constructor(e={}){var t;super(e),(t=this.millisecond)!==null&&t!==void 0||(this.millisecond=0),this.idBlock.tagClass=1,this.idBlock.tagNumber=24}fromDate(e){super.fromDate(e),this.millisecond=e.getUTCMilliseconds()}toDate(){return new Date(Date.UTC(this.year,this.month-1,this.day,this.hour,this.minute,this.second,this.millisecond))}fromString(e){let t=!1,n="",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,d=n.indexOf("+"),b="";if(d===-1&&(d=n.indexOf("-"),l=-1),d!==-1){if(b=n.substring(d+1),n=n.substring(0,d),b.length!==2&&b.length!==4)throw new Error("Wrong input string for conversion");let p=parseInt(b.substring(0,2),10);if(isNaN(p.valueOf()))throw new Error("Wrong input string for conversion");if(a=l*p,b.length===4){if(p=parseInt(b.substring(2,4),10),isNaN(p.valueOf()))throw new Error("Wrong input string for conversion");c=l*p}}}let u=n.indexOf(".");if(u===-1&&(u=n.indexOf(",")),u!==-1){let l=new Number(`0${n.substring(u)}`);if(isNaN(l.valueOf()))throw new Error("Wrong input string for conversion");o=l.valueOf(),s=n.substring(0,u)}else s=n;switch(!0){case s.length===8:if(i=/(\d{4})(\d{2})(\d{2})/ig,u!==-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,u!==-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,u!==-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,u!==-1){let l=1e3*o;this.millisecond=Math.floor(l)}break;default:throw new Error("Wrong input string for conversion")}let f=i.exec(s);if(f===null)throw new Error("Wrong input string for conversion");for(let l=1;l<f.length;l++)switch(l){case 1:this.year=parseInt(f[l],10);break;case 2:this.month=parseInt(f[l],10);break;case 3:this.day=parseInt(f[l],10);break;case 4:this.hour=parseInt(f[l],10)+a;break;case 5:this.minute=parseInt(f[l],10)+c;break;case 6:this.second=parseInt(f[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(Re(this.year,4)),t.push(Re(this.month,2)),t.push(Re(this.day,2)),t.push(Re(this.hour,2)),t.push(Re(this.minute,2)),t.push(Re(this.second,2)),this.millisecond!==0&&(t.push("."),t.push(Re(this.millisecond,3))),t.push("Z"),t.join("")}return super.toString(e)}toJSON(){return{...super.toJSON(),millisecond:this.millisecond}}};Mc=gs;S.GeneralizedTime=Mc;gs.NAME="GeneralizedTime";var Kc,ms=class extends wt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=31}};Kc=ms;S.DATE=Kc;ms.NAME="DATE";var Fc,ys=class extends wt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=32}};Fc=ys;S.TimeOfDay=Fc;ys.NAME="TimeOfDay";var qc,bs=class extends wt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=33}};qc=bs;S.DateTime=qc;bs.NAME="DateTime";var $c,ws=class extends wt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=34}};$c=ws;S.Duration=$c;ws.NAME="Duration";var Gc,xs=class extends wt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=14}};Gc=xs;S.TIME=Gc;xs.NAME="TIME";function dd(r){let{result:e}=kr(r),t=e.valueBlock.value;return{n:F(rt(t[1].toBigInt()),"base64url"),e:F(rt(t[2].toBigInt()),"base64url"),d:F(rt(t[3].toBigInt()),"base64url"),p:F(rt(t[4].toBigInt()),"base64url"),q:F(rt(t[5].toBigInt()),"base64url"),dp:F(rt(t[6].toBigInt()),"base64url"),dq:F(rt(t[7].toBigInt()),"base64url"),qi:F(rt(t[8].toBigInt()),"base64url"),kty:"RSA",alg:"RS256"}}function pd(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 pe({value:[new ce({value:0}),ce.fromBigInt(nt(K(r.n,"base64url"))),ce.fromBigInt(nt(K(r.e,"base64url"))),ce.fromBigInt(nt(K(r.d,"base64url"))),ce.fromBigInt(nt(K(r.p,"base64url"))),ce.fromBigInt(nt(K(r.q,"base64url"))),ce.fromBigInt(nt(K(r.dp,"base64url"))),ce.fromBigInt(nt(K(r.dq,"base64url"))),ce.fromBigInt(nt(K(r.qi,"base64url")))]}).toBER();return new Uint8Array(t,0,t.byteLength)}function gd(r){let{result:e}=kr(r),t=e.valueBlock.value[1].valueBlock.value[0].valueBlock.value;return{kty:"RSA",n:F(rt(t[0].toBigInt()),"base64url"),e:F(rt(t[1].toBigInt()),"base64url")}}function md(r){if(r.n==null||r.e==null)throw new L("JWK was missing components","ERR_INVALID_PARAMETERS");let t=new pe({value:[new pe({value:[new je({value:"1.2.840.113549.1.1.1"}),new Ot]}),new Sr({valueHex:new pe({value:[ce.fromBigInt(nt(K(r.n,"base64url"))),ce.fromBigInt(nt(K(r.e,"base64url")))]}).toBER()})]}).toBER();return new Uint8Array(t,0,t.byteLength)}function rt(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 nt(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 yd=16,ei=32,ti=1e4;async function bd(r,e){let t=we.get(),s=new pe({value:[new ce({value:0}),new pe({value:[new je({value:"1.2.840.113549.1.1.1"}),new Ot]}),new bt({valueHex:r.marshal()})]}).toBER(),o=new Uint8Array(s,0,s.byteLength),i=Jt(yd),a=await Yo(yr,e,i,{c:ti,dkLen:ei}),c=Jt(16),u=await t.subtle.importKey("raw",a,"AES-CBC",!1,["encrypt"]),f=await t.subtle.encrypt({name:"AES-CBC",iv:c},u,o),l=new pe({value:[new bt({valueHex:i}),new ce({value:ti}),new ce({value:ei}),new pe({value:[new je({value:"1.2.840.113549.2.11"}),new Ot]})]}),d=new pe({value:[new je({value:"1.2.840.113549.1.5.13"}),new pe({value:[new pe({value:[new je({value:"1.2.840.113549.1.5.12"}),l]}),new pe({value:[new je({value:"2.16.840.1.101.3.4.1.42"}),new bt({valueHex:c})]})]})]}),p=new pe({value:[d,new bt({valueHex:f})]}).toBER(),h=new Uint8Array(p,0,p.byteLength);return["-----BEGIN ENCRYPTED PRIVATE KEY-----",...F(h,"base64pad").split(/(.{64})/).filter(Boolean),"-----END ENCRYPTED PRIVATE KEY-----"].join(`
7
- `)}async function jc(r,e){let t=we.get(),n;if(r.includes("-----BEGIN ENCRYPTED PRIVATE KEY-----")){let s=K(r.replace("-----BEGIN ENCRYPTED PRIVATE KEY-----","").replace("-----END ENCRYPTED PRIVATE KEY-----","").replace(/\n/g,"").trim(),"base64pad"),{result:o}=kr(s),{iv:i,salt:a,iterations:c,keySize:u,cipherText:f}=wd(o),l=await Yo(yr,e,a,{c,dkLen:u}),d=await t.subtle.importKey("raw",l,"AES-CBC",!1,["decrypt"]),b=nn(await t.subtle.decrypt({name:"AES-CBC",iv:i},d,f)),{result:p}=kr(b);n=zc(p)}else if(r.includes("-----BEGIN PRIVATE KEY-----")){let s=K(r.replace("-----BEGIN PRIVATE KEY-----","").replace("-----END PRIVATE KEY-----","").replace(/\n/g,"").trim(),"base64pad"),{result:o}=kr(s);n=zc(o)}else throw new L("Could not parse private key from PEM data","ERR_INVALID_PARAMETERS");return ri(n)}function wd(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=nn(o.valueBlock.value[0].getValue()),a=ti,c=ei;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 u=e.valueBlock.value[1].valueBlock.value[1],f=u.valueBlock.value[0].toString();if(f!=="OBJECT IDENTIFIER : 1.2.840.113549.3.7"){if(f!=="OBJECT IDENTIFIER : 1.3.14.3.2.7"){if(f!=="OBJECT IDENTIFIER : 2.16.840.1.101.3.4.1.2"){if(f!=="OBJECT IDENTIFIER : 2.16.840.1.101.3.4.1.22"){if(f!=="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 l=nn(u.valueBlock.value[1].getValue());return{cipherText:nn(r.valueBlock.value[1].getValue()),salt:i,iterations:a,keySize:c,iv:l}}function zc(r){return nn(r.valueBlock.value[2].getValue())}function nn(r){return new Uint8Array(r,0,r.byteLength)}async function Wc(r){let e=await we.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 Jc(e);return{privateKey:t[0],publicKey:t[1]}}async function ni(r){let t=[await we.get().subtle.importKey("jwk",r,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["sign"]),await xd(r)],n=await Jc({privateKey:t[0],publicKey:t[1]});return{privateKey:n[0],publicKey:n[1]}}async function Yc(r,e){let t=await we.get().subtle.importKey("jwk",r,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["sign"]),n=await we.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 we.get().subtle.importKey("jwk",r,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["verify"]);return we.get().subtle.verify({name:"RSASSA-PKCS1-v1_5"},n,e,t instanceof Uint8Array?t:t.subarray())}async function Jc(r){if(r.privateKey==null||r.publicKey==null)throw new L("Private and public key are required","ERR_INVALID_PARAMETERS");return Promise.all([we.get().subtle.exportKey("jwk",r.privateKey),we.get().subtle.exportKey("jwk",r.publicKey)])}async function xd(r){return we.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 Es(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 K(r.n,"base64url").length*8}var Rr=8192,Nr=class{_key;constructor(e){this._key=e}verify(e,t){return Zc(this._key,t,e)}marshal(){return Vt.jwkToPkix(this._key)}get bytes(){return Qe.encode({Type:X.RSA,Data:this.marshal()}).subarray()}equals(e){return ue(this.bytes,e.bytes)}hash(){let e=ye.digest(this.bytes);return Ce(e)?e.then(({bytes:t})=>t):e.bytes}},Qt=class{_key;_publicKey;constructor(e,t){this._key=e,this._publicKey=t}genSecret(){return Jt(16)}sign(e){return Yc(this._key,e)}get public(){if(this._publicKey==null)throw new L("public key not provided","ERR_PUBKEY_NOT_PROVIDED");return new Nr(this._publicKey)}marshal(){return Vt.jwkToPkcs1(this._key)}get bytes(){return et.encode({Type:X.RSA,Data:this.marshal()}).subarray()}equals(e){return ue(this.bytes,e.bytes)}hash(){let e=ye.digest(this.bytes);return Ce(e)?e.then(({bytes:t})=>t):e.bytes}async id(){let e=await this.public.hash();return F(e,"base58btc")}async export(e,t="pkcs-8"){if(t==="pkcs-8")return Vt.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 ri(r){let e=Vt.pkcs1ToJwk(r);if(Es(e)>Rr)throw new L("key size is too large","ERR_KEY_SIZE_TOO_LARGE");let t=await ni(e);return new Qt(t.privateKey,t.publicKey)}function Ed(r){let e=Vt.pkixToJwk(r);if(Es(e)>Rr)throw new L("key size is too large","ERR_KEY_SIZE_TOO_LARGE");return new Nr(e)}async function Bd(r){if(Es(r)>Rr)throw new L("key size is too large","ERR_KEY_SIZE_TOO_LARGE");let e=await ni(r);return new Qt(e.privateKey,e.publicKey)}async function Ad(r){if(r>Rr)throw new L("key size is too large","ERR_KEY_SIZE_TOO_LARGE");let e=await Wc(r);return new Qt(e.privateKey,e.publicKey)}var li={};de(li,{Secp256k1PrivateKey:()=>_r,Secp256k1PublicKey:()=>Tr,generateKeyPair:()=>Hd,unmarshalSecp256k1PrivateKey:()=>Od,unmarshalSecp256k1PublicKey:()=>Vd});var Sd=(r,e,t)=>r&e^~r&t,Id=(r,e,t)=>r&e^r&t^e&t,kd=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]),Ht=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Mt=new Uint32Array(64),oi=class extends mr{constructor(){super(64,32,8,!1),this.A=Ht[0]|0,this.B=Ht[1]|0,this.C=Ht[2]|0,this.D=Ht[3]|0,this.E=Ht[4]|0,this.F=Ht[5]|0,this.G=Ht[6]|0,this.H=Ht[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)Mt[l]=e.getUint32(t,!1);for(let l=16;l<64;l++){let d=Mt[l-15],b=Mt[l-2],p=Me(d,7)^Me(d,18)^d>>>3,h=Me(b,17)^Me(b,19)^b>>>10;Mt[l]=h+Mt[l-7]+p+Mt[l-16]|0}let{A:n,B:s,C:o,D:i,E:a,F:c,G:u,H:f}=this;for(let l=0;l<64;l++){let d=Me(a,6)^Me(a,11)^Me(a,25),b=f+d+Sd(a,c,u)+kd[l]+Mt[l]|0,h=(Me(n,2)^Me(n,13)^Me(n,22))+Id(n,s,o)|0;f=u,u=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,u=u+this.G|0,f=f+this.H|0,this.set(n,s,o,i,a,c,u,f)}roundClean(){Mt.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var Xc=xn(()=>new oi);function Nd(r){let e=$r(r);Xe(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:Rd,hexToBytes:Td}=Bn,er={Err:class extends Error{constructor(e=""){super(e)}},_parseInt(r){let{Err:e}=er;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:Rd(n),l:r.subarray(t+2)}},toSig(r){let{Err:e}=er,t=typeof r=="string"?Td(r):r;if(!Ke(t))throw new Error("ui8a expected");let n=t.length;if(n<2||t[0]!=48)throw new e("Invalid signature tag");if(t[1]!==n-2)throw new e("Invalid signature: incorrect length");let{d:s,l:o}=er._parseInt(t.subarray(2)),{d:i,l:a}=er._parseInt(o);if(a.length)throw new e("Invalid signature: left bytes after parsing");return{r:s,s:i}},hexFromSig(r){let e=u=>Number.parseInt(u[0],16)&8?"00"+u:u,t=u=>{let f=u.toString(16);return f.length&1?`0${f}`:f},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}`}},Et=BigInt(0),Pe=BigInt(1),db=BigInt(2),Qc=BigInt(3),pb=BigInt(4);function _d(r){let e=Nd(r),{Fp:t}=e,n=e.toBytes||((p,h,m)=>{let y=h.toAffine();return dt(Uint8Array.from([4]),t.toBytes(y.x),t.toBytes(y.y))}),s=e.fromBytes||(p=>{let h=p.subarray(1),m=t.fromBytes(h.subarray(0,t.BYTES)),y=t.fromBytes(h.subarray(t.BYTES,2*t.BYTES));return{x:m,y}});function o(p){let{a:h,b:m}=e,y=t.sqr(p),B=t.mul(y,p);return t.add(t.add(B,t.mul(p,h)),m)}if(!t.eql(t.sqr(e.Gy),o(e.Gx)))throw new Error("bad generator point: equation left != right");function i(p){return typeof p=="bigint"&&Et<p&&p<e.n}function a(p){if(!i(p))throw new Error("Expected valid bigint: 0 < bigint < curve.n")}function c(p){let{allowedPrivateKeyLengths:h,nByteLength:m,wrapPrivateKey:y,n:B}=e;if(h&&typeof p!="bigint"){if(Ke(p)&&(p=ft(p)),typeof p!="string"||!h.includes(p.length))throw new Error("Invalid key");p=p.padStart(m*2,"0")}let w;try{w=typeof p=="bigint"?p:ht(te("private key",p,m))}catch{throw new Error(`private key must be ${m} bytes, hex or bigint, not ${typeof p}`)}return y&&(w=Y(w,B)),a(w),w}let u=new Map;function f(p){if(!(p instanceof l))throw new Error("ProjectivePoint expected")}class l{constructor(h,m,y){if(this.px=h,this.py=m,this.pz=y,h==null||!t.isValid(h))throw new Error("x required");if(m==null||!t.isValid(m))throw new Error("y required");if(y==null||!t.isValid(y))throw new Error("z required")}static fromAffine(h){let{x:m,y}=h||{};if(!h||!t.isValid(m)||!t.isValid(y))throw new Error("invalid affine point");if(h instanceof l)throw new Error("projective point not allowed");let B=w=>t.eql(w,t.ZERO);return B(m)&&B(y)?l.ZERO:new l(m,y,t.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(h){let m=t.invertBatch(h.map(y=>y.pz));return h.map((y,B)=>y.toAffine(m[B])).map(l.fromAffine)}static fromHex(h){let m=l.fromAffine(s(te("pointHex",h)));return m.assertValidity(),m}static fromPrivateKey(h){return l.BASE.multiply(c(h))}_setWindowSize(h){this._WINDOW_SIZE=h,u.delete(this)}assertValidity(){if(this.is0()){if(e.allowInfinityPoint&&!t.is0(this.py))return;throw new Error("bad point: ZERO")}let{x:h,y:m}=this.toAffine();if(!t.isValid(h)||!t.isValid(m))throw new Error("bad point: x or y not FE");let y=t.sqr(m),B=o(h);if(!t.eql(y,B))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){let{y:h}=this.toAffine();if(t.isOdd)return!t.isOdd(h);throw new Error("Field doesn't support isOdd")}equals(h){f(h);let{px:m,py:y,pz:B}=this,{px:w,py:T,pz:x}=h,A=t.eql(t.mul(m,x),t.mul(w,B)),N=t.eql(t.mul(y,x),t.mul(T,B));return A&&N}negate(){return new l(this.px,t.neg(this.py),this.pz)}double(){let{a:h,b:m}=e,y=t.mul(m,Qc),{px:B,py:w,pz:T}=this,x=t.ZERO,A=t.ZERO,N=t.ZERO,R=t.mul(B,B),G=t.mul(w,w),q=t.mul(T,T),P=t.mul(B,w);return P=t.add(P,P),N=t.mul(B,T),N=t.add(N,N),x=t.mul(h,N),A=t.mul(y,q),A=t.add(x,A),x=t.sub(G,A),A=t.add(G,A),A=t.mul(x,A),x=t.mul(P,x),N=t.mul(y,N),q=t.mul(h,q),P=t.sub(R,q),P=t.mul(h,P),P=t.add(P,N),N=t.add(R,R),R=t.add(N,R),R=t.add(R,q),R=t.mul(R,P),A=t.add(A,R),q=t.mul(w,T),q=t.add(q,q),R=t.mul(q,P),x=t.sub(x,R),N=t.mul(q,G),N=t.add(N,N),N=t.add(N,N),new l(x,A,N)}add(h){f(h);let{px:m,py:y,pz:B}=this,{px:w,py:T,pz:x}=h,A=t.ZERO,N=t.ZERO,R=t.ZERO,G=e.a,q=t.mul(e.b,Qc),P=t.mul(m,w),ie=t.mul(y,T),re=t.mul(B,x),Le=t.add(m,y),v=t.add(w,T);Le=t.mul(Le,v),v=t.add(P,ie),Le=t.sub(Le,v),v=t.add(m,B);let k=t.add(w,x);return v=t.mul(v,k),k=t.add(P,re),v=t.sub(v,k),k=t.add(y,B),A=t.add(T,x),k=t.mul(k,A),A=t.add(ie,re),k=t.sub(k,A),R=t.mul(G,v),A=t.mul(q,re),R=t.add(A,R),A=t.sub(ie,R),R=t.add(ie,R),N=t.mul(A,R),ie=t.add(P,P),ie=t.add(ie,P),re=t.mul(G,re),v=t.mul(q,v),ie=t.add(ie,re),re=t.sub(P,re),re=t.mul(G,re),v=t.add(v,re),P=t.mul(ie,v),N=t.add(N,P),P=t.mul(k,v),A=t.mul(Le,A),A=t.sub(A,P),P=t.mul(Le,ie),R=t.mul(k,R),R=t.add(R,P),new l(A,N,R)}subtract(h){return this.add(h.negate())}is0(){return this.equals(l.ZERO)}wNAF(h){return b.wNAFCached(this,u,h,m=>{let y=t.invertBatch(m.map(B=>B.pz));return m.map((B,w)=>B.toAffine(y[w])).map(l.fromAffine)})}multiplyUnsafe(h){let m=l.ZERO;if(h===Et)return m;if(a(h),h===Pe)return this;let{endo:y}=e;if(!y)return b.unsafeLadder(this,h);let{k1neg:B,k1:w,k2neg:T,k2:x}=y.splitScalar(h),A=m,N=m,R=this;for(;w>Et||x>Et;)w&Pe&&(A=A.add(R)),x&Pe&&(N=N.add(R)),R=R.double(),w>>=Pe,x>>=Pe;return B&&(A=A.negate()),T&&(N=N.negate()),N=new l(t.mul(N.px,y.beta),N.py,N.pz),A.add(N)}multiply(h){a(h);let m=h,y,B,{endo:w}=e;if(w){let{k1neg:T,k1:x,k2neg:A,k2:N}=w.splitScalar(m),{p:R,f:G}=this.wNAF(x),{p:q,f:P}=this.wNAF(N);R=b.constTimeNegate(T,R),q=b.constTimeNegate(A,q),q=new l(t.mul(q.px,w.beta),q.py,q.pz),y=R.add(q),B=G.add(P)}else{let{p:T,f:x}=this.wNAF(m);y=T,B=x}return l.normalizeZ([y,B])[0]}multiplyAndAddUnsafe(h,m,y){let B=l.BASE,w=(x,A)=>A===Et||A===Pe||!x.equals(B)?x.multiplyUnsafe(A):x.multiply(A),T=w(this,m).add(w(h,y));return T.is0()?void 0:T}toAffine(h){let{px:m,py:y,pz:B}=this,w=this.is0();h==null&&(h=w?t.ONE:t.inv(B));let T=t.mul(m,h),x=t.mul(y,h),A=t.mul(B,h);if(w)return{x:t.ZERO,y:t.ZERO};if(!t.eql(A,t.ONE))throw new Error("invZ was invalid");return{x:T,y:x}}isTorsionFree(){let{h,isTorsionFree:m}=e;if(h===Pe)return!0;if(m)return m(l,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h,clearCofactor:m}=e;return h===Pe?this:m?m(l,this):this.multiplyUnsafe(e.h)}toRawBytes(h=!0){return this.assertValidity(),n(l,this,h)}toHex(h=!0){return ft(this.toRawBytes(h))}}l.BASE=new l(e.Gx,e.Gy,t.ONE),l.ZERO=new l(t.ZERO,t.ONE,t.ZERO);let d=e.nBitLength,b=In(l,e.endo?Math.ceil(d/2):d);return{CURVE:e,ProjectivePoint:l,normPrivateKeyToScalar:c,weierstrassEquation:o,isWithinCurveOrder:i}}function Ld(r){let e=$r(r);return Xe(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function el(r){let e=Ld(r),{Fp:t,n}=e,s=t.BYTES+1,o=2*t.BYTES+1;function i(v){return Et<v&&v<t.ORDER}function a(v){return Y(v,n)}function c(v){return An(v,n)}let{ProjectivePoint:u,normPrivateKeyToScalar:f,weierstrassEquation:l,isWithinCurveOrder:d}=_d({...e,toBytes(v,k,D){let E=k.toAffine(),g=t.toBytes(E.x),I=dt;return D?I(Uint8Array.from([k.hasEvenY()?2:3]),g):I(Uint8Array.from([4]),g,t.toBytes(E.y))},fromBytes(v){let k=v.length,D=v[0],E=v.subarray(1);if(k===s&&(D===2||D===3)){let g=ht(E);if(!i(g))throw new Error("Point is not on curve");let I=l(g),_=t.sqrt(I),C=(_&Pe)===Pe;return(D&1)===1!==C&&(_=t.neg(_)),{x:g,y:_}}else if(k===o&&D===4){let g=t.fromBytes(E.subarray(0,t.BYTES)),I=t.fromBytes(E.subarray(t.BYTES,2*t.BYTES));return{x:g,y:I}}else throw new Error(`Point of length ${k} was invalid. Expected ${s} compressed bytes or ${o} uncompressed bytes`)}}),b=v=>ft(Lt(v,e.nByteLength));function p(v){let k=n>>Pe;return v>k}function h(v){return p(v)?a(-v):v}let m=(v,k,D)=>ht(v.slice(k,D));class y{constructor(k,D,E){this.r=k,this.s=D,this.recovery=E,this.assertValidity()}static fromCompact(k){let D=e.nByteLength;return k=te("compactSignature",k,D*2),new y(m(k,0,D),m(k,D,2*D))}static fromDER(k){let{r:D,s:E}=er.toSig(te("DER",k));return new y(D,E)}assertValidity(){if(!d(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!d(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(k){return new y(this.r,this.s,k)}recoverPublicKey(k){let{r:D,s:E,recovery:g}=this,I=N(te("msgHash",k));if(g==null||![0,1,2,3].includes(g))throw new Error("recovery id invalid");let _=g===2||g===3?D+e.n:D;if(_>=t.ORDER)throw new Error("recovery id 2 or 3 invalid");let C=g&1?"03":"02",O=u.fromHex(C+b(_)),V=c(_),W=a(-I*V),M=a(E*V),$=u.BASE.multiplyAndAddUnsafe(O,W,M);if(!$)throw new Error("point at infinify");return $.assertValidity(),$}hasHighS(){return p(this.s)}normalizeS(){return this.hasHighS()?new y(this.r,a(-this.s),this.recovery):this}toDERRawBytes(){return zt(this.toDERHex())}toDERHex(){return er.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return zt(this.toCompactHex())}toCompactHex(){return b(this.r)+b(this.s)}}let B={isValidPrivateKey(v){try{return f(v),!0}catch{return!1}},normPrivateKeyToScalar:f,randomPrivateKey:()=>{let v=No(e.n);return Ha(e.randomBytes(v),e.n)},precompute(v=8,k=u.BASE){return k._setWindowSize(v),k.multiply(BigInt(3)),k}};function w(v,k=!0){return u.fromPrivateKey(v).toRawBytes(k)}function T(v){let k=Ke(v),D=typeof v=="string",E=(k||D)&&v.length;return k?E===s||E===o:D?E===2*s||E===2*o:v instanceof u}function x(v,k,D=!0){if(T(v))throw new Error("first arg must be private key");if(!T(k))throw new Error("second arg must be public key");return u.fromHex(k).multiply(f(v)).toRawBytes(D)}let A=e.bits2int||function(v){let k=ht(v),D=v.length*8-e.nBitLength;return D>0?k>>BigInt(D):k},N=e.bits2int_modN||function(v){return a(A(v))},R=qr(e.nBitLength);function G(v){if(typeof v!="bigint")throw new Error("bigint expected");if(!(Et<=v&&v<R))throw new Error(`bigint expected < 2^${e.nBitLength}`);return Lt(v,e.nByteLength)}function q(v,k,D=P){if(["recovered","canonical"].some(Q=>Q in D))throw new Error("sign() legacy options not supported");let{hash:E,randomBytes:g}=e,{lowS:I,prehash:_,extraEntropy:C}=D;I==null&&(I=!0),v=te("msgHash",v),_&&(v=te("prehashed msgHash",E(v)));let O=N(v),V=f(k),W=[G(V),G(O)];if(C!=null){let Q=C===!0?g(t.BYTES):C;W.push(te("extraEntropy",Q))}let M=dt(...W),$=O;function ae(Q){let ge=A(Q);if(!d(ge))return;let me=c(ge),le=u.BASE.multiply(ge).toAffine(),ve=a(le.x);if(ve===Et)return;let it=a(me*a($+ve*V));if(it===Et)return;let qt=(le.x===ve?0:2)|Number(le.y&Pe),Or=it;return I&&p(it)&&(Or=h(it),qt^=1),new y(ve,Or,qt)}return{seed:M,k2sig:ae}}let P={lowS:e.lowS,prehash:!1},ie={lowS:e.lowS,prehash:!1};function re(v,k,D=P){let{seed:E,k2sig:g}=q(v,k,D),I=e;return Ao(I.hash.outputLen,I.nByteLength,I.hmac)(E,g)}u.BASE._setWindowSize(8);function Le(v,k,D,E=ie){let g=v;if(k=te("msgHash",k),D=te("publicKey",D),"strict"in E)throw new Error("options.strict was renamed to lowS");let{lowS:I,prehash:_}=E,C,O;try{if(typeof g=="string"||Ke(g))try{C=y.fromDER(g)}catch(le){if(!(le instanceof er.Err))throw le;C=y.fromCompact(g)}else if(typeof g=="object"&&typeof g.r=="bigint"&&typeof g.s=="bigint"){let{r:le,s:ve}=g;C=new y(le,ve)}else throw new Error("PARSE");O=u.fromHex(D)}catch(le){if(le.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(I&&C.hasHighS())return!1;_&&(k=e.hash(k));let{r:V,s:W}=C,M=N(k),$=c(W),ae=a(M*$),Q=a(V*$),ge=u.BASE.multiplyAndAddUnsafe(O,ae,Q)?.toAffine();return ge?a(ge.x)===V:!1}return{CURVE:e,getPublicKey:w,getSharedSecret:x,sign:re,verify:Le,ProjectivePoint:u,Signature:y,utils:B}}function Cd(r){return{hash:r,hmac:(e,...t)=>Wr(r,e,wn(...t)),randomBytes:gr}}function tl(r,e){let t=n=>el({...r,...Cd(n)});return Object.freeze({...t(e),create:t})}var sl=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),rl=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),Ud=BigInt(1),ii=BigInt(2),nl=(r,e)=>(r+e/ii)/e;function Pd(r){let e=sl,t=BigInt(3),n=BigInt(6),s=BigInt(11),o=BigInt(22),i=BigInt(23),a=BigInt(44),c=BigInt(88),u=r*r*r%e,f=u*u*r%e,l=J(f,t,e)*f%e,d=J(l,t,e)*f%e,b=J(d,ii,e)*u%e,p=J(b,s,e)*b%e,h=J(p,o,e)*p%e,m=J(h,a,e)*h%e,y=J(m,c,e)*m%e,B=J(y,a,e)*h%e,w=J(B,t,e)*f%e,T=J(w,i,e)*p%e,x=J(T,n,e)*u%e,A=J(x,ii,e);if(!ai.eql(ai.sqr(A),r))throw new Error("Cannot find square root");return A}var ai=Sn(sl,void 0,void 0,{sqrt:Pd}),Ye=tl({a:BigInt(0),b:BigInt(7),Fp:ai,n:rl,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:r=>{let e=rl,t=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-Ud*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),s=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),o=t,i=BigInt("0x100000000000000000000000000000000"),a=nl(o*r,e),c=nl(-n*r,e),u=Y(r-a*t-c*s,e),f=Y(-a*n-c*o,e),l=u>i,d=f>i;if(l&&(u=e-u),d&&(f=e-f),u>i||f>i)throw new Error("splitScalar: Endomorphism failed, k="+r);return{k1neg:l,k1:u,k2neg:d,k2:f}}}},Xc),Bb=BigInt(0);var Ab=Ye.ProjectivePoint;function ol(){return Ye.utils.randomPrivateKey()}function il(r,e){let t=ye.digest(e instanceof Uint8Array?e:e.subarray());if(Ce(t))return t.then(({digest:n})=>Ye.sign(n,r).toDERRawBytes()).catch(n=>{throw new L(String(n),"ERR_INVALID_INPUT")});try{return Ye.sign(t.digest,r).toDERRawBytes()}catch(n){throw new L(String(n),"ERR_INVALID_INPUT")}}function al(r,e,t){let n=ye.digest(t instanceof Uint8Array?t:t.subarray());if(Ce(n))return n.then(({digest:s})=>Ye.verify(e,s,r)).catch(s=>{throw new L(String(s),"ERR_INVALID_INPUT")});try{return Ye.verify(e,n.digest,r)}catch(s){throw new L(String(s),"ERR_INVALID_INPUT")}}function cl(r){return Ye.ProjectivePoint.fromHex(r).toRawBytes(!0)}function ll(r){try{Ye.getPublicKey(r,!0)}catch(e){throw new L(String(e),"ERR_INVALID_PRIVATE_KEY")}}function ci(r){try{Ye.ProjectivePoint.fromHex(r)}catch(e){throw new L(String(e),"ERR_INVALID_PUBLIC_KEY")}}function ul(r){try{return Ye.getPublicKey(r,!0)}catch(e){throw new L(String(e),"ERR_INVALID_PRIVATE_KEY")}}var Tr=class{_key;constructor(e){ci(e),this._key=e}verify(e,t){return al(this._key,t,e)}marshal(){return cl(this._key)}get bytes(){return Qe.encode({Type:X.Secp256k1,Data:this.marshal()}).subarray()}equals(e){return ue(this.bytes,e.bytes)}async hash(){let e=ye.digest(this.bytes),t;return Ce(e)?{bytes:t}=await e:t=e.bytes,t}},_r=class{_key;_publicKey;constructor(e,t){this._key=e,this._publicKey=t??ul(e),ll(this._key),ci(this._publicKey)}sign(e){return il(this._key,e)}get public(){return new Tr(this._publicKey)}marshal(){return this._key}get bytes(){return et.encode({Type:X.Secp256k1,Data:this.marshal()}).subarray()}equals(e){return ue(this.bytes,e.bytes)}hash(){let e=ye.digest(this.bytes);return Ce(e)?e.then(({bytes:t})=>t):e.bytes}async id(){let e=await this.public.hash();return F(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 Od(r){return new _r(r)}function Vd(r){return new Tr(r)}async function Hd(){let r=ol();return new _r(r)}var tr={rsa:si,ed25519:Wo,secp256k1:li};function fl(r){let e=Object.keys(tr).join(" / ");return new L(`invalid or unsupported key type ${r}. Must be ${e}`,"ERR_UNSUPPORTED_KEY_TYPE")}function hl(r){let e=Qe.decode(r),t=e.Data??new Uint8Array;switch(e.Type){case X.RSA:return tr.rsa.unmarshalRsaPublicKey(t);case X.Ed25519:return tr.ed25519.unmarshalEd25519PublicKey(t);case X.Secp256k1:return tr.secp256k1.unmarshalSecp256k1PublicKey(t);default:throw fl(e.Type??"unknown")}}async function dl(r){let e=et.decode(r),t=e.Data??new Uint8Array;switch(e.Type){case X.RSA:return tr.rsa.unmarshalRsaPrivateKey(t);case X.Ed25519:return tr.ed25519.unmarshalEd25519PrivateKey(t);case X.Secp256k1:return tr.secp256k1.unmarshalSecp256k1PrivateKey(t);default:throw fl(e.Type??"RSA")}}var Md=Math.pow(2,7),Kd=Math.pow(2,14),Fd=Math.pow(2,21),ui=Math.pow(2,28),fi=Math.pow(2,35),hi=Math.pow(2,42),di=Math.pow(2,49),z=128,Se=127;function Ie(r){if(r<Md)return 1;if(r<Kd)return 2;if(r<Fd)return 3;if(r<ui)return 4;if(r<fi)return 5;if(r<hi)return 6;if(r<di)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function qd(r,e,t=0){switch(Ie(r)){case 8:e[t++]=r&255|z,r/=128;case 7:e[t++]=r&255|z,r/=128;case 6:e[t++]=r&255|z,r/=128;case 5:e[t++]=r&255|z,r/=128;case 4:e[t++]=r&255|z,r>>>=7;case 3:e[t++]=r&255|z,r>>>=7;case 2:e[t++]=r&255|z,r>>>=7;case 1:{e[t++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return e}function $d(r,e,t=0){switch(Ie(r)){case 8:e.set(t++,r&255|z),r/=128;case 7:e.set(t++,r&255|z),r/=128;case 6:e.set(t++,r&255|z),r/=128;case 5:e.set(t++,r&255|z),r/=128;case 4:e.set(t++,r&255|z),r>>>=7;case 3:e.set(t++,r&255|z),r>>>=7;case 2:e.set(t++,r&255|z),r>>>=7;case 1:{e.set(t++,r&255),r>>>=7;break}default:throw new Error("unreachable")}return e}function Gd(r,e){let t=r[e],n=0;if(n+=t&Se,t<z||(t=r[e+1],n+=(t&Se)<<7,t<z)||(t=r[e+2],n+=(t&Se)<<14,t<z)||(t=r[e+3],n+=(t&Se)<<21,t<z)||(t=r[e+4],n+=(t&Se)*ui,t<z)||(t=r[e+5],n+=(t&Se)*fi,t<z)||(t=r[e+6],n+=(t&Se)*hi,t<z)||(t=r[e+7],n+=(t&Se)*di,t<z))return n;throw new RangeError("Could not decode varint")}function zd(r,e){let t=r.get(e),n=0;if(n+=t&Se,t<z||(t=r.get(e+1),n+=(t&Se)<<7,t<z)||(t=r.get(e+2),n+=(t&Se)<<14,t<z)||(t=r.get(e+3),n+=(t&Se)<<21,t<z)||(t=r.get(e+4),n+=(t&Se)*ui,t<z)||(t=r.get(e+5),n+=(t&Se)*fi,t<z)||(t=r.get(e+6),n+=(t&Se)*hi,t<z)||(t=r.get(e+7),n+=(t&Se)*di,t<z))return n;throw new RangeError("Could not decode varint")}function De(r,e,t=0){return e==null&&(e=Ee(Ie(r))),e instanceof Uint8Array?qd(r,e,t):$d(r,e,t)}function Ze(r,e=0){return r instanceof Uint8Array?Gd(r,e):zd(r,e)}var gl=Symbol.for("@achingbrain/uint8arraylist");function pl(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 Bs(r){return!!r?.[gl]}var Te=class r{bufs;length;[gl]=!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(Bs(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(Bs(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=pl(this.bufs,e);return t.buf[t.index]}set(e,t){let n=pl(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(Bs(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 be(n,s)}subarray(e,t){let{bufs:n,length:s}=this._subList(e,t);return n.length===1?n[0]:be(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 u=e>=a&&e<c,f=t>a&&t<=c;if(u&&f){if(e===a&&t===c){n.push(i);break}let l=e-a;n.push(i.subarray(l,l+(t-e)));break}if(u){if(e===0){n.push(i);continue}n.push(i.subarray(e-a));continue}if(f){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(!Bs(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,u=n.byteLength-1,f;for(let l=t;l<=c;l+=f){f=0;for(let d=u;d>=0;d--){let b=this.get(l+d);if(n[d]!==b){f=Math.max(1,d-a[b]);break}}if(f===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=Ee(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=lt(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=lt(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=lt(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=Ee(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=lt(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=lt(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=lt(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=lt(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=lt(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(!ue(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 ml={ERR_SIGNATURE_NOT_VALID:"ERR_SIGNATURE_NOT_VALID"};var sn;(function(r){let e;r.codec=()=>(e==null&&(e=ze((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=>$e(t,r.codec())})(sn||(sn={}));var Kt=class r{static createFromProtobuf=async e=>{let t=sn.decode(e),n=await Fr(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=yl(n,s,o),c=await(await dl(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",ml.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=sn.encode({publicKey:this.peerId.publicKey,payloadType:this.payloadType,payload:this.payload.subarray(),signature:this.signature})),this.marshaled}equals(e){return ue(this.marshal(),e.marshal())}async validate(e){let t=yl(e,this.payloadType,this.payload);if(this.peerId.publicKey==null)throw new Error("Missing public key");return hl(this.peerId.publicKey).verify(t.subarray(),this.signature)}},yl=(r,e,t)=>{let n=K(r),s=De(n.byteLength),o=De(e.length),i=De(t.length);return new Te(s,n,o,e,i,t)};function bl(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 As=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",u=2**(8*s)-1;for(;;){let f=this.readAtomically(()=>{let l=this.readChar();if(l===void 0)return;let d=Number.parseInt(l,e);if(!Number.isNaN(d))return d});if(f===void 0)break;if(o*=e,o+=f,o>u||(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 wl=45,jd=15,Cr=new As;function pi(r){if(!(r.length>jd))return Cr.new(r).parseWith(()=>Cr.readIPv4Addr())}function gi(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>wl))return Cr.new(r).parseWith(()=>Cr.readIPv6Addr())}function Ss(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>wl))return Cr.new(r).parseWith(()=>Cr.readIPAddr())}var vw=parseInt("0xFFFF",16),Ew=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);function Is(r){return!!pi(r)}function ks(r){return!!gi(r)}function Ns(r){return!!Ss(r)}var El=Is,Xd=ks,mi=function(r){let e=0;if(r=r.toString().trim(),El(r)){let t=new Uint8Array(e+4);return r.split(/\./g).forEach(n=>{t[e++]=parseInt(n,10)&255}),t}if(Xd(r)){let t=r.split(":",8),n;for(n=0;n<t.length;n++){let o=El(t[n]),i;o&&(i=mi(t[n]),t[n]=F(i.slice(0,2),"base16")),i!=null&&++n<8&&t.splice(n,0,F(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")},Bl=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 Ur={},yi={},ep=[[4,32,"ip4"],[6,16,"tcp"],[33,16,"dccp"],[41,128,"ip6"],[42,-1,"ip6zone"],[43,8,"ipcidr"],[53,-1,"dns",!0],[54,-1,"dns4",!0],[55,-1,"dns6",!0],[56,-1,"dnsaddr",!0],[132,16,"sctp"],[273,16,"udp"],[275,0,"p2p-webrtc-star"],[276,0,"p2p-webrtc-direct"],[277,0,"p2p-stardust"],[280,0,"webrtc-direct"],[281,0,"webrtc"],[290,0,"p2p-circuit"],[301,0,"udt"],[302,0,"utp"],[400,-1,"unix",!1,!0],[421,-1,"ipfs"],[421,-1,"p2p"],[443,0,"https"],[444,96,"onion"],[445,296,"onion3"],[446,-1,"garlic64"],[448,0,"tls"],[449,-1,"sni"],[460,0,"quic"],[461,0,"quic-v1"],[465,0,"webtransport"],[466,-1,"certhash"],[477,0,"ws"],[478,0,"wss"],[479,0,"p2p-websocket-star"],[480,0,"http"],[777,-1,"memory"]];ep.forEach(r=>{let e=tp(...r);yi[e.code]=e,Ur[e.name]=e});function tp(r,e,t,n,s){return{code:r,size:e,name:t,resolvable:!!n,path:!!s}}function j(r){if(typeof r=="number"){if(yi[r]!=null)return yi[r];throw new Error(`no protocol with code: ${r}`)}else if(typeof r=="string"){if(Ur[r]!=null)return Ur[r];throw new Error(`no protocol with name: ${r}`)}throw new Error(`invalid protocol id type: ${typeof r}`)}var ox=j("ip4"),ix=j("ip6"),ax=j("ipcidr");function wi(r,e){switch(j(r).code){case 4:case 41:return np(e);case 42:return Il(e);case 6:case 273:case 33:case 132:return Nl(e).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return Il(e);case 421:return ap(e);case 444:return kl(e);case 445:return kl(e);case 466:return ip(e);default:return F(e,"base16")}}function xi(r,e){switch(j(r).code){case 4:return Al(e);case 41:return Al(e);case 42:return Sl(e);case 6:case 273:case 33:case 132:return vi(parseInt(e,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return Sl(e);case 421:return sp(e);case 444:return cp(e);case 445:return lp(e);case 466:return op(e);default:return K(e,"base16")}}var bi=Object.values(It).map(r=>r.decoder),rp=function(){let r=bi[0].or(bi[1]);return bi.slice(2).forEach(e=>r=r.or(e)),r}();function Al(r){if(!Ns(r))throw new Error("invalid ip address");return mi(r)}function np(r){let e=Bl(r,0,r.length);if(e==null)throw new Error("ipBuff is required");if(!Ns(e))throw new Error("invalid ip address");return e}function vi(r){let e=new ArrayBuffer(2);return new DataView(e).setUint16(0,r),new Uint8Array(e)}function Nl(r){return new DataView(r.buffer).getUint16(r.byteOffset)}function Sl(r){let e=K(r),t=Uint8Array.from(De(e.length));return be([t,e],t.length+e.length)}function Il(r){let e=Ze(r);if(r=r.slice(Ie(e)),r.length!==e)throw new Error("inconsistent lengths");return F(r)}function sp(r){let e;r[0]==="Q"||r[0]==="1"?e=$t(ne.decode(`z${r}`)).bytes:e=He.parse(r).multihash.bytes;let t=Uint8Array.from(De(e.length));return be([t,e],t.length+e.length)}function op(r){let e=rp.decode(r),t=Uint8Array.from(De(e.length));return be([t,e],t.length+e.length)}function ip(r){let e=Ze(r),t=r.slice(Ie(e));if(t.length!==e)throw new Error("inconsistent lengths");return"u"+F(t,"base64url")}function ap(r){let e=Ze(r),t=r.slice(Ie(e));if(t.length!==e)throw new Error("inconsistent lengths");return F(t,"base58btc")}function cp(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=ct.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=vi(n);return be([t,s],t.length+s.length)}function lp(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=ct.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=vi(n);return be([t,s],t.length+s.length)}function kl(r){let e=r.slice(0,r.length-2),t=r.slice(r.length-2),n=F(e,"base32"),s=Nl(t);return`${n}:${s}`}function Rl(r){r=Ei(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=j(i);if(a.size===0){e.push([a.code]),t.push([a.code]);continue}if(o++,o>=s.length)throw _l("invalid address: "+r);if(a.path===!0){n=Ei(s.slice(o).join("/")),e.push([a.code,xi(a.code,n)]),t.push([a.code,n]);break}let c=xi(a.code,s[o]);e.push([a.code,c]),t.push([a.code,wi(a.code,c)])}return{string:Tl(t),bytes:Ai(e),tuples:e,stringTuples:t,path:n}}function Bi(r){let e=[],t=[],n=null,s=0;for(;s<r.length;){let o=Ze(r,s),i=Ie(o),a=j(o),c=up(a,r.slice(s+i));if(c===0){e.push([o]),t.push([o]),s+=i;continue}let u=r.slice(s+i,s+i+c);if(s+=c+i,s>r.length)throw _l("Invalid address Uint8Array: "+F(r,"base16"));e.push([o,u]);let f=wi(o,u);if(t.push([o,f]),a.path===!0){n=f;break}}return{bytes:Uint8Array.from(r),string:Tl(t),tuples:e,stringTuples:t,path:n}}function Tl(r){let e=[];return r.map(t=>{let n=j(t[0]);return e.push(n.name),t.length>1&&t[1]!=null&&e.push(t[1]),null}),Ei(e.join("/"))}function Ai(r){return be(r.map(e=>{let t=j(e[0]),n=Uint8Array.from(De(t.code));return e.length>1&&e[1]!=null&&(n=be([n,e[1]])),n}))}function up(r,e){if(r.size>0)return r.size/8;if(r.size===0)return 0;{let t=Ze(e instanceof Uint8Array?e:Uint8Array.from(e));return t+Ie(t)}}function Ei(r){return"/"+r.trim().split("/").filter(e=>e).join("/")}function _l(r){return new Error("Error parsing address: "+r)}var fp=Symbol.for("nodejs.util.inspect.custom"),Si=Symbol.for("@multiformats/js-multiaddr/multiaddr"),hp=[j("dns").code,j("dns4").code,j("dns6").code,j("dnsaddr").code],Rs=class r{bytes;#e;#t;#r;#n;[Si]=!0;constructor(e){e==null&&(e="");let t;if(e instanceof Uint8Array)t=Bi(e);else if(typeof e=="string"){if(e.length>0&&e.charAt(0)!=="/")throw new Error(`multiaddr "${e}" must start with a "/"`);t=Rl(e)}else if(Cl(e))t=Bi(e.bytes);else throw new Error("addr must be a string, Buffer, or another Multiaddr");this.bytes=t.bytes,this.#e=t.string,this.#t=t.tuples,this.#r=t.stringTuples,this.#n=t.path}toString(){return this.#e}toJSON(){return this.toString()}toOptions(){let e,t,n,s,o="",i=j("tcp"),a=j("udp"),c=j("ip4"),u=j("ip6"),f=j("dns6"),l=j("ip6zone");for(let[b,p]of this.stringTuples())b===l.code&&(o=`%${p??""}`),hp.includes(b)&&(t=i.name,s=443,n=`${p??""}${o}`,e=b===f.code?6:4),(b===i.code||b===a.code)&&(t=j(b).name,s=parseInt(p??"")),(b===c.code||b===u.code)&&(t=j(b).name,n=`${p??""}${o}`,e=b===u.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.#t.map(([e])=>Object.assign({},j(e)))}protoCodes(){return this.#t.map(([e])=>e)}protoNames(){return this.#t.map(([e])=>j(e).name)}tuples(){return this.#t}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(Ai(t.slice(0,n)));return this}getPeerId(){try{let e=[];this.stringTuples().forEach(([n,s])=>{n===Ur.p2p.code&&e.push([n,s]),n===Ur["p2p-circuit"].code&&(e=[])});let t=e.pop();if(t?.[1]!=null){let n=t[1];return n[0]==="Q"||n[0]==="1"?F(ne.decode(`z${n}`),"base58btc"):F(He.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){return this.#n}equals(e){return ue(this.bytes,e.bytes)}async resolve(e){let t=this.protos().find(o=>o.resolvable);if(t==null)return[this];let n=Ll.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=>new r(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)}[fp](){return`Multiaddr(${this.#e})`}};var Ll=new Map;function Cl(r){return!!r?.[Si]}function Ft(r){return new Rs(r)}var Ul="libp2p-peer-record",Pl=Uint8Array.from([3,1]);var on;(function(r){let e;(function(n){let s;n.codec=()=>(s==null&&(s=ze((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 u=o.uint32();switch(u>>>3){case 1:a.multiaddr=o.bytes();break;default:o.skipType(u&7);break}}return a})),s),n.encode=o=>Ge(o,n.codec()),n.decode=o=>$e(o,n.codec())})(e=r.AddressInfo||(r.AddressInfo={}));let t;r.codec=()=>(t==null&&(t=ze((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=>$e(n,r.codec())})(on||(on={}));var Bt=class r{static createFromProtobuf=e=>{let t=on.decode(e),n=mo(t.peerId),s=(t.addresses??[]).map(i=>Ft(i.multiaddr)),o=t.seq;return new r({peerId:n,multiaddrs:s,seqNumber:o})};static DOMAIN=Ul;static CODEC=Pl;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=on.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||!bl(this.multiaddrs,e.multiaddrs))}};var dp=r=>r.toString().split("/").slice(1),an=r=>({match:e=>e.length<1?!1:r(e[0])?e.slice(1):!1,pattern:"fn"}),se=r=>({match:e=>an(t=>t===r).match(e),pattern:r}),Ls=()=>({match:r=>an(e=>typeof e=="string").match(r),pattern:"{string}"}),Dl=()=>({match:r=>an(e=>!isNaN(parseInt(e))).match(r),pattern:"{number}"}),Oe=()=>({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}"}),Ts=()=>({match:r=>{if(r.length<2||r[0]!=="certhash")return!1;try{no.decode(r[1])}catch{return!1}return r.slice(2)},pattern:"/certhash/{certhash}"}),st=r=>({match:e=>{let t=r.match(e);return t===!1?e:t},pattern:`optional(${r.pattern})`}),ot=(...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(", ")})`}),oe=(...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 he(...r){function e(s){let o=dp(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 ki=oe(se("dns4"),Ls()),Ni=oe(se("dns6"),Ls()),Ri=oe(se("dnsaddr"),Ls()),Ol=oe(se("dns"),Ls()),Wx=he(ki),Yx=he(Ni),Zx=he(Ri),Jx=he(ot(Ol,Ri,ki,Ni)),Vl=oe(se("ip4"),an(Is)),Hl=oe(se("ip6"),an(ks)),Ml=ot(Vl,Hl),cn=ot(Ml,Ol,ki,Ni,Ri),Kl=he(cn),Xx=he(Vl),Qx=he(Hl),e1=he(Ml),Cs=oe(cn,se("tcp"),Dl()),ln=oe(cn,se("udp"),Dl()),pp=ot(Cs,ln),t1=he(Cs),r1=he(ln),Ti=oe(ln,se("quic")),Us=oe(ln,se("quic-v1")),gp=ot(Ti,Us),n1=he(Ti),s1=he(Us),Ii=ot(cn,Cs,ln,Ti,Us),Fl=ot(oe(Ii,se("ws"),st(Oe()))),o1=he(Fl),ql=ot(oe(Ii,se("wss"),st(Oe())),oe(Ii,se("tls"),se("ws"),st(Oe()))),i1=he(ql),$l=oe(pp,se("webrtc-direct"),Ts(),st(Ts()),st(Oe())),a1=he($l),Gl=oe(Us,se("webtransport"),Ts(),Ts(),st(Oe())),c1=he(Gl),_s=ot(Fl,ql,oe(Cs,st(Oe())),oe(gp,st(Oe())),oe(cn,st(Oe())),$l,Gl,Oe()),l1=he(_s),mp=oe(_s,se("p2p-circuit"),Oe()),u1=he(mp),yp=ot(oe(_s,se("p2p-circuit"),se("webrtc"),Oe()),oe(_s,se("webrtc"),st(Oe())),se("webrtc")),f1=he(yp);function Pr(){let r={};return r.promise=new Promise((e,t)=>{r.resolve=e,r.reject=t}),r}var Ps=class extends Error{type;code;constructor(e,t){super(e??"The operation was aborted"),this.type="aborted",this.name="AbortError",this.code=t??"ABORT_ERR"}};async function zl(r,e,t){if(e==null)return r;if(e.aborted)return Promise.reject(new Ps(t?.errorMessage,t?.errorCode));let n,s=new Ps(t?.errorMessage,t?.errorCode);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 _i=class{needNext;haveNext;ended;nextResult;constructor(){this.ended=!1,this.needNext=Pr(),this.haveNext=Pr()}[Symbol.asyncIterator](){return this}async next(){if(this.nextResult==null&&await this.haveNext.promise,this.nextResult==null)throw new Error("Have next but next was undefined");let e=this.nextResult;return this.nextResult=void 0,this.needNext.resolve(),this.needNext=Pr(),e}async throw(e){return this.ended=!0,e!=null&&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");this.nextResult!=null&&await this.needNext.promise,e!=null?this.nextResult={done:!1,value:e}:(this.ended=!0,this.nextResult={done:!0,value:void 0}),this.haveNext.resolve(),this.haveNext=Pr(),await zl(this.needNext.promise,t?.signal,t)}};function jl(){return new _i}var Ds=class extends Error{code;constructor(e,t){super(e),this.code=t}},Li=class extends Ds{type;constructor(e){super(e,"ABORT_ERR"),this.type="aborted"}};function Wl(r,e){let t=jl();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 Te;return{read:async(i,a)=>{a?.signal?.throwIfAborted();let c,u=new Promise((f,l)=>{c=()=>{l(new Li("Read aborted"))},a?.signal?.addEventListener("abort",c)});try{if(i==null){let{done:l,value:d}=await Promise.race([n.next(),u]);return l===!0?new Te:d}for(;s.byteLength<i;){let{value:l,done:d}=await Promise.race([n.next(),u]);if(d===!0)throw new Ds("unexpected end of input","ERR_UNEXPECTED_EOF");s.append(l)}let f=s.sublist(0,i);return s.consume(i),f}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}}}function Os(r){return r[Symbol.asyncIterator]!=null}var Vs=r=>{let e=Ie(r),t=Ee(e);return De(r,t),Vs.bytes=e,t};Vs.bytes=0;function un(r,e){e=e??{};let t=e.lengthEncoder??Vs;function*n(s){let o=t(s.byteLength);o instanceof Uint8Array?yield o:yield*o,s instanceof Uint8Array?yield s:yield*s}return Os(r)?async function*(){for await(let s of r)yield*n(s)}():function*(){for(let s of r)yield*n(s)}()}un.single=(r,e)=>{e=e??{};let t=e.lengthEncoder??Vs;return new Te(t(r.byteLength),r)};var Dr=$s(Jl(),1);var wp=8,xp=1024*1024*4,rr;(function(r){r[r.LENGTH=0]="LENGTH",r[r.DATA=1]="DATA"})(rr||(rr={}));var Ui=r=>{let e=Ze(r);return Ui.bytes=Ie(e),e};Ui.bytes=0;function Ci(r,e){let t=new Te,n=rr.LENGTH,s=-1,o=e?.lengthDecoder??Ui,i=e?.maxLengthLength??wp,a=e?.maxDataLength??xp;function*c(){for(;t.byteLength>0;){if(n===rr.LENGTH)try{if(s=o(t),s<0)throw(0,Dr.default)(new Error("invalid message length"),"ERR_INVALID_MSG_LENGTH");if(s>a)throw(0,Dr.default)(new Error("message length too long"),"ERR_MSG_DATA_TOO_LONG");let u=o.bytes;t.consume(u),e?.onLength!=null&&e.onLength(s),n=rr.DATA}catch(u){if(u instanceof RangeError){if(t.byteLength>i)throw(0,Dr.default)(new Error("message length length too long"),"ERR_MSG_LENGTH_TOO_LONG");break}throw u}if(n===rr.DATA){if(t.byteLength<s)break;let u=t.sublist(0,s);t.consume(s),e?.onData!=null&&e.onData(u),yield u,n=rr.LENGTH}}}return Os(r)?async function*(){for await(let u of r)t.append(u),yield*c();if(t.byteLength>0)throw(0,Dr.default)(new Error("unexpected end of input"),"ERR_UNEXPECTED_EOF")}():function*(){for(let u of r)t.append(u),yield*c();if(t.byteLength>0)throw(0,Dr.default)(new Error("unexpected end of input"),"ERR_UNEXPECTED_EOF")}()}Ci.fromReader=(r,e)=>{let t=1,n=async function*(){for(;;)try{let{done:o,value:i}=await r.next(t);if(o===!0)return;i!=null&&(yield i)}catch(o){if(o.code==="ERR_UNDER_READ")return{done:!0,value:null};throw o}finally{t=1}}();return Ci(n,{...e??{},onLength:o=>{t=o}})};var Hs=class extends Error{code;constructor(e,t){super(e),this.code=t}},Xl=r=>Ze(r);Xl.bytes=0;function Ql(r,e={}){let t=Wl(r,e);return e.maxDataLength!=null&&e.maxLengthLength==null&&(e.maxLengthLength=Ie(e.maxDataLength)),{read:async s=>{let o=-1,i=new Te,a=e?.lengthDecoder??Xl;for(;;){i.append(await t.read(1,s));try{o=a(i)}catch(c){if(c instanceof RangeError)continue;throw c}if(e?.maxLengthLength!=null&&i.byteLength>e.maxLengthLength)throw new Hs("message length length too long","ERR_MSG_LENGTH_TOO_LONG");if(o>-1)break}if(e?.maxDataLength!=null&&o>e.maxDataLength)throw new Hs("message length too long","ERR_MSG_DATA_TOO_LONG");return t.read(o,s)},write:async(s,o)=>{await t.write(un.single(s,e),o)},writeV:async(s,o)=>{let i=new Te(...s.map(a=>un.single(a,e)));await t.write(i,o)},unwrap:()=>t.unwrap()}}function fn(r,e){let t=Ql(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 ru=$s(tu(),1),Pi=typeof window=="object"&&typeof document=="object"&&document.nodeType===9,Ms=(0,ru.default)(),nu=Pi&&!Ms,su=Ms&&!Pi,ou=Ms&&Pi,iu=typeof globalThis.process<"u"&&typeof globalThis.process.release<"u"&&globalThis.process.release.name==="node"&&!Ms,au=typeof importScripts=="function"&&typeof self<"u"&&typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope,H1=typeof globalThis.process<"u"&&typeof globalThis.process.env<"u"&&globalThis.process.env["NODE"+"_"+"ENV"]==="test",cu=typeof navigator<"u"&&navigator.product==="ReactNative";var nr;(function(r){let e;r.codec=()=>(e==null&&(e=ze((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=>$e(t,r.codec())})(nr||(nr={}));var Di=1024*8,Ve={protocolPrefix:"ipfs",timeout:6e4,maxInboundStreams:1,maxOutboundStreams:1,maxPushIncomingStreams:1,maxPushOutgoingStreams:1,maxObservedAddresses:10,maxIdentifyMessageSize:8192,runOnConnectionOpen:!0,runOnTransientConnection:!0},Ks=class{identifyProtocolStr;identifyPushProtocolStr;host;started;timeout;peerId;peerStore;registrar;connectionManager;addressManager;maxInboundStreams;maxOutboundStreams;maxPushIncomingStreams;maxPushOutgoingStreams;maxIdentifyMessageSize;maxObservedAddresses;events;runOnTransientConnection;log;constructor(e,t={}){this.started=!1,this.peerId=e.peerId,this.peerStore=e.peerStore,this.registrar=e.registrar,this.addressManager=e.addressManager,this.connectionManager=e.connectionManager,this.events=e.events,this.log=e.logger.forComponent("libp2p:identify"),this.identifyProtocolStr=`/${t.protocolPrefix??Ve.protocolPrefix}/${Yi}/${Ji}`,this.identifyPushProtocolStr=`/${t.protocolPrefix??Ve.protocolPrefix}/${Zi}/${Xi}`,this.timeout=t.timeout??Ve.timeout,this.maxInboundStreams=t.maxInboundStreams??Ve.maxInboundStreams,this.maxOutboundStreams=t.maxOutboundStreams??Ve.maxOutboundStreams,this.maxPushIncomingStreams=t.maxPushIncomingStreams??Ve.maxPushIncomingStreams,this.maxPushOutgoingStreams=t.maxPushOutgoingStreams??Ve.maxPushOutgoingStreams,this.maxIdentifyMessageSize=t.maxIdentifyMessageSize??Ve.maxIdentifyMessageSize,this.maxObservedAddresses=t.maxObservedAddresses??Ve.maxObservedAddresses,this.runOnTransientConnection=t.runOnTransientConnection??Ve.runOnTransientConnection,this.host={protocolVersion:`${t.protocolPrefix??Ve.protocolPrefix}/${Wi}`,agentVersion:t.agentVersion??`${e.nodeInfo.name}/${e.nodeInfo.version}`},(t.runOnConnectionOpen??Ve.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)})}),e.events.addEventListener("self:peer:update",n=>{this.push().catch(s=>{this.log.error(s)})}),this.host.agentVersion===`${e.nodeInfo.name}/${e.nodeInfo.version}`&&(iu||su?this.host.agentVersion+=` UserAgent=${globalThis.process.version}`:(nu||au||ou||cu)&&(this.host.agentVersion+=` UserAgent=${globalThis.navigator.userAgent}`))}isStarted(){return this.started}async start(){this.started||(await this.peerStore.merge(this.peerId,{metadata:{AgentVersion:K(this.host.agentVersion),ProtocolVersion:K(this.host.protocolVersion)}}),await this.registrar.handle(this.identifyProtocolStr,e=>{this._handleIdentify(e).catch(t=>{this.log.error(t)})},{maxInboundStreams:this.maxInboundStreams,maxOutboundStreams:this.maxOutboundStreams,runOnTransientConnection:this.runOnTransientConnection}),await this.registrar.handle(this.identifyPushProtocolStr,e=>{this._handlePush(e).catch(t=>{this.log.error(t)})},{maxInboundStreams:this.maxPushIncomingStreams,maxOutboundStreams:this.maxPushOutgoingStreams,runOnTransientConnection:this.runOnTransientConnection}),this.started=!0)}async stop(){await this.registrar.unhandle(this.identifyProtocolStr),await this.registrar.unhandle(this.identifyPushProtocolStr),this.started=!1}async pushToConnections(e){let t=this.addressManager.getAddresses().map(f=>f.decapsulateCode(j("p2p").code)),n=new Bt({peerId:this.peerId,multiaddrs:t}),s=await Kt.seal(n,this.peerId),o=this.registrar.getProtocols(),i=await this.peerStore.get(this.peerId),a=F(i.metadata.get("AgentVersion")??K(this.host.agentVersion)),c=F(i.metadata.get("ProtocolVersion")??K(this.host.protocolVersion)),u=e.map(async f=>{let l,d=AbortSignal.timeout(this.timeout);dn(1/0,d);try{l=await f.newStream(this.identifyPushProtocolStr,{signal:d,runOnTransientConnection:this.runOnTransientConnection}),await fn(l,{maxDataLength:this.maxIdentifyMessageSize??Di}).pb(nr).write({listenAddrs:t.map(p=>p.bytes),signedPeerRecord:s.marshal(),protocols:o,agentVersion:a,protocolVersion:c},{signal:d}),await l.close({signal:d})}catch(b){this.log.error("could not push identify update to peer",b),l?.abort(b)}});await Promise.all(u)}async push(){if(!this.isStarted())return;let e=[];await Promise.all(this.connectionManager.getConnections().map(async t=>{try{if(!(await this.peerStore.get(t.remotePeer)).protocols.includes(this.identifyPushProtocolStr))return;e.push(t)}catch(n){if(n.code!==ra)throw n}})),await this.pushToConnections(e)}async _identify(e,t={}){let n;if(t.signal==null){let s=AbortSignal.timeout(this.timeout);dn(1/0,s),t={...t,signal:s}}try{n=await e.newStream(this.identifyProtocolStr,{...t,runOnTransientConnection:this.runOnTransientConnection});let o=await fn(n,{maxDataLength:this.maxIdentifyMessageSize??Di}).pb(nr).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 Fr(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=Bp(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)),this.#e(e,n)}async _handleIdentify(e){let{connection:t,stream:n}=e,s=AbortSignal.timeout(this.timeout);dn(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(j("p2p").code)),c=i.peerRecordEnvelope;if(a.length>0&&c==null){let l=new Bt({peerId:this.peerId,multiaddrs:a});c=(await Kt.seal(l,this.peerId)).marshal().subarray()}let u=t.remoteAddr.bytes;Kl.matches(t.remoteAddr)||(u=void 0),await fn(n).pb(nr).write({protocolVersion:this.host.protocolVersion,agentVersion:this.host.agentVersion,publicKey:o,listenAddrs:a.map(l=>l.bytes),signedPeerRecord:c,observedAddr:u,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)}}async _handlePush(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 fn(n,{maxDataLength:this.maxIdentifyMessageSize??Di}).pb(nr).read(s);await n.close(s),await this.#e(t,i)}catch(s){this.log.error("received invalid message",s),n.abort(s);return}this.log("handled push from %p",t.remotePeer)}async#e(e,t){if(this.log("received identify from %p",e.remotePeer),t==null)throw new L("message was null or undefined","ERR_INVALID_MESSAGE");let n={};if(t.listenAddrs.length>0&&(n.addresses=t.listenAddrs.map(i=>({isCertified:!1,multiaddr:Ft(i)}))),t.protocols.length>0&&(n.protocols=t.protocols),t.publicKey!=null&&(n.publicKey=t.publicKey,!(await Fr(t.publicKey)).equals(e.remotePeer)))throw new L("public key did not match remote PeerId","ERR_INVALID_PUBLIC_KEY");let s;if(t.signedPeerRecord!=null){this.log("received signedPeerRecord from %p",e.remotePeer);let i=t.signedPeerRecord,a=await Kt.openAndCertify(i,Bt.DOMAIN),c=Bt.createFromProtobuf(a.payload);if(!c.peerId.equals(a.peerId))throw new L("signing key does not match PeerId in the PeerRecord","ERR_INVALID_SIGNING_KEY");if(!e.remotePeer.equals(c.peerId))throw new L("signing key does not match remote PeerId","ERR_INVALID_PEER_RECORD_KEY");let u;try{u=await this.peerStore.get(c.peerId)}catch(f){if(f.code!=="ERR_NOT_FOUND")throw f}if(u!=null&&(n.metadata=u.metadata,u.peerRecordEnvelope!=null)){let f=await Kt.createFromProtobuf(u.peerRecordEnvelope),l=Bt.createFromProtobuf(f.payload);l.seqNumber>=c.seqNumber&&(this.log("sequence number was lower or equal to existing sequence number - stored: %d received: %d",l.seqNumber,c.seqNumber),c=l,i=u.peerRecordEnvelope)}n.peerRecordEnvelope=i,n.addresses=c.multiaddrs.map(f=>({isCertified:!0,multiaddr:f})),s={seq:c.seqNumber,addresses:c.multiaddrs}}else this.log("%p did not send a signed peer record",e.remotePeer);if(this.log("patching %p with",e.remotePeer,n),await this.peerStore.patch(e.remotePeer,n),t.agentVersion!=null||t.protocolVersion!=null){let i={};t.agentVersion!=null&&(i.AgentVersion=K(t.agentVersion)),t.protocolVersion!=null&&(i.ProtocolVersion=K(t.protocolVersion)),this.log("merging %p metadata",e.remotePeer,i),await this.peerStore.merge(e.remotePeer,{metadata:i})}let o={peerId:e.remotePeer,protocolVersion:t.protocolVersion,agentVersion:t.agentVersion,publicKey:t.publicKey,listenAddrs:t.listenAddrs.map(i=>Ft(i)),observedAddr:t.observedAddr==null?void 0:Ft(t.observedAddr),protocols:t.protocols,signedPeerRecord:s,connection:e};return this.events.safeDispatchEvent("peer:identify",{detail:o}),o}};function Bp(r){if(r!=null&&r.length>0)try{return Ft(r)}catch{}}var Ap={IDENTIFY:zi,IDENTIFY_PUSH:ji};function Sp(r={}){return e=>new Ks(e,r)}return Eu(Ip);})();
6
+ `)}`:`${t} :`}};uc=Pt;I.Constructed=uc;Pt.NAME="CONSTRUCTED";var Kn=class extends Ee{fromBER(e,t,n){return t}toBER(e){return We}};Kn.override="EndOfContentValueBlock";var fc,qn=class extends be{constructor(e={}){super(e,Kn),this.idBlock.tagClass=1,this.idBlock.tagNumber=0}};fc=qn;I.EndOfContent=fc;qn.NAME=jr;var hc,Ot=class extends be{constructor(e={}){super(e,Ee),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=Ot;I.Null=hc;Ot.NAME="NULL";var $n=class extends vt(Ee){constructor({value:e,...t}={}){super(t),t.valueHex?this.valueHexView=H.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=H.BufferSourceConverter.toUint8Array(e);return xt(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,Yo.call(this),this.blockLength=n,t+n):-1}toBER(){return this.valueHexView.slice()}toJSON(){return{...super.toJSON(),value:this.value}}};$n.NAME="BooleanValueBlock";var dc,Gn=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}`}};dc=Gn;I.Boolean=dc;Gn.NAME="BOOLEAN";var zn=class extends vt(tt){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=tt.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===jr){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?tt.prototype.toBER.call(this,e,t):e?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),isConstructed:this.isConstructed}}};zn.NAME="OctetStringValueBlock";var pc,bt=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},zn),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?Pt.prototype.onAsciiEncoding.call(this):`${this.constructor.NAME} : ${H.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 H.BufferSourceConverter.concat(e)}};pc=bt;I.OctetString=pc;bt.NAME=ic;var jn=class extends vt(tt){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=tt.prototype.fromBER.call(this,e,t,n),s===-1)return s;for(let a of this.value){let c=a.constructor.NAME;if(c===jr){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 u=a.valueBlock;if(this.unusedBits>0&&u.unusedBits>0)return this.error='Using of "unused bits" inside constructive BIT STRING allowed for least one only',-1;this.unusedBits=u.unusedBits}return s}let o=H.BufferSourceConverter.toUint8Array(e);if(!xt(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 tt.prototype.toBER.call(this,e,t);if(e)return new ArrayBuffer(this.valueHexView.byteLength+1);if(!this.valueHexView.byteLength)return We;let n=new Uint8Array(this.valueHexView.length+1);return n[0]=this.unusedBits,n.set(this.valueHexView,1),n.buffer}toJSON(){return{...super.toJSON(),unusedBits:this.unusedBits,isConstructed:this.isConstructed}}};jn.NAME="BitStringValueBlock";var gc,Br=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 Pt.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=Br;I.BitString=gc;Br.NAME=ac;var mc;function nd(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,u=0,f=c<i?i:c,l=0;for(let d=f;d>=0;d--,l++){switch(!0){case l<a.length:u=o[i-l]+a[c-l]+t[0];break;default:u=o[i-l]+t[0]}switch(t[0]=u/10,!0){case l>=o.length:o=Pn(new Uint8Array([u%10]),o);break;default:o[i-l]=u%10}}return t[0]>0&&(o=Pn(t,o)),o}function oc(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 sd(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,u,f=0;for(let l=c;l>=0;l--,f++)switch(u=o[i-f]-a[c-f]-t,!0){case u<0:t=1,o[i-f]=u+10;break;default:t=0,o[i-f]=u}if(t>0)for(let l=i-c+1;l>=0;l--,f++)if(u=o[i-f]-t,u<0)t=1,o[i-f]=u+10;else{t=0,o[i-f]=u;break}return o.slice()}var Wr=class extends vt(Ee){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=Yo.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 u=0;u<8;u++){if((s&1)===1)switch(n){case e:t=sd(oc(n),t),i="-";break;default:t=nd(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=Wr;Wr.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,ce=class r extends be{constructor(e={}){super(e,Wr),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 zr,s=t.toString(16).replace(/^-/,""),o=new Uint8Array(H.Convert.FromHex(s));if(t<0){let a=new Uint8Array(o.length+(o[0]&128?1:0));a[0]|=128;let u=BigInt(`0x${H.Convert.ToHex(a)}`)+t,f=H.BufferSourceConverter.toUint8Array(H.Convert.FromHex(u.toString(16)));f[0]|=128,n.write(f)}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=ce;I.Integer=yc;ce.NAME="INTEGER";var bc,Wn=class extends ce{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=10}};bc=Wn;I.Enumerated=bc;Wn.NAME="ENUMERATED";var Yr=class extends vt(Ee){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=H.BufferSourceConverter.toUint8Array(e);if(!xt(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=Xt(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=Ut(this.valueDec,7);if(t.byteLength===0)return this.error="Error during encoding SID value",We;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=H.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}}};Yr.NAME="sidBlock";var Yn=class extends Ee{constructor({value:e=Ar,...t}={}){super(t),this.value=[],e&&this.fromString(e)}fromBER(e,t,n){let s=t;for(;n>0;){let o=new Yr;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,We;t.push(s)}return Zo(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 Yr;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 wc,je=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()}}};wc=je;I.ObjectIdentifier=wc;je.NAME="OBJECT IDENTIFIER";var Zr=class extends vt(yt){constructor({valueDec:e=0,...t}={}){super(t),this.valueDec=e}fromBER(e,t,n){if(n===0)return t;let s=H.BufferSourceConverter.toUint8Array(e);if(!xt(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=Xt(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=Ut(this.valueDec,7);if(t.byteLength===0)return this.error="Error during encoding SID value",We;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=H.Convert.ToHex(this.valueHexView):e=this.valueDec.toString(),e}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}};Zr.NAME="relativeSidBlock";var Zn=class extends Ee{constructor({value:e=Ar,...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.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,We;n.push(o)}return Zo(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 Zr;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 xc,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()}}};xc=Jn;I.RelativeObjectIdentifier=xc;Jn.NAME="RelativeObjectIdentifier";var vc,pe=class extends Pt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=16}};vc=pe;I.Sequence=vc;pe.NAME="SEQUENCE";var Ec,Xn=class extends Pt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=17}};Ec=Xn;I.Set=Ec;Xn.NAME="SET";var Qn=class extends vt(Ee){constructor({...e}={}){super(e),this.isHexOnly=!0,this.value=Ar}toJSON(){return{...super.toJSON(),value:this.value}}};Qn.NAME="StringValueBlock";var es=class extends Qn{};es.NAME="SimpleStringValueBlock";var ke=class extends Hn{constructor({...e}={}){super(e,es)}fromBuffer(e){this.valueBlock.value=String.fromCharCode.apply(null,H.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}};ke.NAME="SIMPLE STRING";var ts=class extends ke{fromBuffer(e){this.valueBlock.valueHexView=H.BufferSourceConverter.toUint8Array(e);try{this.valueBlock.value=H.Convert.ToUtf8String(e)}catch(t){this.warnings.push(`Error during "decodeURIComponent": ${t}, using raw string`),this.valueBlock.value=H.Convert.ToBinary(e)}}fromString(e){this.valueBlock.valueHexView=new Uint8Array(H.Convert.FromUtf8String(e)),this.valueBlock.value=e}};ts.NAME="Utf8StringValueBlock";var Bc,wt=class extends ts{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=12}};Bc=wt;I.Utf8String=Bc;wt.NAME="UTF8String";var rs=class extends ke{fromBuffer(e){this.valueBlock.value=H.Convert.ToUtf16String(e),this.valueBlock.valueHexView=H.BufferSourceConverter.toUint8Array(e)}fromString(e){this.valueBlock.value=e,this.valueBlock.valueHexView=new Uint8Array(H.Convert.FromUtf16String(e))}};rs.NAME="BmpStringValueBlock";var Ac,ns=class extends rs{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=30}};Ac=ns;I.BmpString=Ac;ns.NAME="BMPString";var ss=class extends ke{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=Ut(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 Ic,os=class extends ss{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=28}};Ic=os;I.UniversalString=Ic;os.NAME="UniversalString";var Sc,is=class extends ke{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=18}};Sc=is;I.NumericString=Sc;is.NAME="NumericString";var kc,as=class extends ke{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=19}};kc=as;I.PrintableString=kc;as.NAME="PrintableString";var Nc,cs=class extends ke{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=20}};Nc=cs;I.TeletexString=Nc;cs.NAME="TeletexString";var Tc,ls=class extends ke{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=21}};Tc=ls;I.VideotexString=Tc;ls.NAME="VideotexString";var Rc,us=class extends ke{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=22}};Rc=us;I.IA5String=Rc;us.NAME="IA5String";var _c,fs=class extends ke{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=25}};_c=fs;I.GraphicString=_c;fs.NAME="GraphicString";var Lc,Jr=class extends ke{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=26}};Lc=Jr;I.VisibleString=Lc;Jr.NAME="VisibleString";var Cc,hs=class extends ke{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=27}};Cc=hs;I.GeneralString=Cc;hs.NAME="GeneralString";var Uc,ds=class extends ke{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=29}};Uc=ds;I.CharacterString=Uc;ds.NAME="CharacterString";var Pc,Xr=class extends Jr{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,H.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]=Te(this.year<2e3?this.year-1900:this.year-2e3,2),t[1]=Te(this.month,2),t[2]=Te(this.day,2),t[3]=Te(this.hour,2),t[4]=Te(this.minute,2),t[5]=Te(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}}};Pc=Xr;I.UTCTime=Pc;Xr.NAME="UTCTime";var Oc,ps=class extends Xr{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,d=n.indexOf("+"),b="";if(d===-1&&(d=n.indexOf("-"),l=-1),d!==-1){if(b=n.substring(d+1),n=n.substring(0,d),b.length!==2&&b.length!==4)throw new Error("Wrong input string for conversion");let p=parseInt(b.substring(0,2),10);if(isNaN(p.valueOf()))throw new Error("Wrong input string for conversion");if(a=l*p,b.length===4){if(p=parseInt(b.substring(2,4),10),isNaN(p.valueOf()))throw new Error("Wrong input string for conversion");c=l*p}}}let u=n.indexOf(".");if(u===-1&&(u=n.indexOf(",")),u!==-1){let l=new Number(`0${n.substring(u)}`);if(isNaN(l.valueOf()))throw new Error("Wrong input string for conversion");o=l.valueOf(),s=n.substring(0,u)}else s=n;switch(!0){case s.length===8:if(i=/(\d{4})(\d{2})(\d{2})/ig,u!==-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,u!==-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,u!==-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,u!==-1){let l=1e3*o;this.millisecond=Math.floor(l)}break;default:throw new Error("Wrong input string for conversion")}let f=i.exec(s);if(f===null)throw new Error("Wrong input string for conversion");for(let l=1;l<f.length;l++)switch(l){case 1:this.year=parseInt(f[l],10);break;case 2:this.month=parseInt(f[l],10);break;case 3:this.day=parseInt(f[l],10);break;case 4:this.hour=parseInt(f[l],10)+a;break;case 5:this.minute=parseInt(f[l],10)+c;break;case 6:this.second=parseInt(f[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(Te(this.year,4)),t.push(Te(this.month,2)),t.push(Te(this.day,2)),t.push(Te(this.hour,2)),t.push(Te(this.minute,2)),t.push(Te(this.second,2)),this.millisecond!==0&&(t.push("."),t.push(Te(this.millisecond,3))),t.push("Z"),t.join("")}return super.toString(e)}toJSON(){return{...super.toJSON(),millisecond:this.millisecond}}};Oc=ps;I.GeneralizedTime=Oc;ps.NAME="GeneralizedTime";var Dc,gs=class extends wt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=31}};Dc=gs;I.DATE=Dc;gs.NAME="DATE";var Vc,ms=class extends wt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=32}};Vc=ms;I.TimeOfDay=Vc;ms.NAME="TimeOfDay";var Hc,ys=class extends wt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=33}};Hc=ys;I.DateTime=Hc;ys.NAME="DateTime";var Mc,bs=class extends wt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=34}};Mc=bs;I.Duration=Mc;bs.NAME="Duration";var Fc,ws=class extends wt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=14}};Fc=ws;I.TIME=Fc;ws.NAME="TIME";function id(r){let{result:e}=Ir(r),t=e.valueBlock.value;return{n:K(rt(t[1].toBigInt()),"base64url"),e:K(rt(t[2].toBigInt()),"base64url"),d:K(rt(t[3].toBigInt()),"base64url"),p:K(rt(t[4].toBigInt()),"base64url"),q:K(rt(t[5].toBigInt()),"base64url"),dp:K(rt(t[6].toBigInt()),"base64url"),dq:K(rt(t[7].toBigInt()),"base64url"),qi:K(rt(t[8].toBigInt()),"base64url"),kty:"RSA",alg:"RS256"}}function ad(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 pe({value:[new ce({value:0}),ce.fromBigInt(nt(F(r.n,"base64url"))),ce.fromBigInt(nt(F(r.e,"base64url"))),ce.fromBigInt(nt(F(r.d,"base64url"))),ce.fromBigInt(nt(F(r.p,"base64url"))),ce.fromBigInt(nt(F(r.q,"base64url"))),ce.fromBigInt(nt(F(r.dp,"base64url"))),ce.fromBigInt(nt(F(r.dq,"base64url"))),ce.fromBigInt(nt(F(r.qi,"base64url")))]}).toBER();return new Uint8Array(t,0,t.byteLength)}function cd(r){let{result:e}=Ir(r),t=e.valueBlock.value[1].valueBlock.value[0].valueBlock.value;return{kty:"RSA",n:K(rt(t[0].toBigInt()),"base64url"),e:K(rt(t[1].toBigInt()),"base64url")}}function ld(r){if(r.n==null||r.e==null)throw new L("JWK was missing components","ERR_INVALID_PARAMETERS");let t=new pe({value:[new pe({value:[new je({value:"1.2.840.113549.1.1.1"}),new Ot]}),new Br({valueHex:new pe({value:[ce.fromBigInt(nt(F(r.n,"base64url"))),ce.fromBigInt(nt(F(r.e,"base64url")))]}).toBER()})]}).toBER();return new Uint8Array(t,0,t.byteLength)}function rt(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 nt(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 ud=16,Xo=32,Qo=1e4;async function fd(r,e){let t=Se.get(),s=new pe({value:[new ce({value:0}),new pe({value:[new je({value:"1.2.840.113549.1.1.1"}),new Ot]}),new bt({valueHex:r.marshal()})]}).toBER(),o=new Uint8Array(s,0,s.byteLength),i=Jt(ud),a=await jo(mr,e,i,{c:Qo,dkLen:Xo}),c=Jt(16),u=await t.subtle.importKey("raw",a,"AES-CBC",!1,["encrypt"]),f=await t.subtle.encrypt({name:"AES-CBC",iv:c},u,o),l=new pe({value:[new bt({valueHex:i}),new ce({value:Qo}),new ce({value:Xo}),new pe({value:[new je({value:"1.2.840.113549.2.11"}),new Ot]})]}),d=new pe({value:[new je({value:"1.2.840.113549.1.5.13"}),new pe({value:[new pe({value:[new je({value:"1.2.840.113549.1.5.12"}),l]}),new pe({value:[new je({value:"2.16.840.1.101.3.4.1.42"}),new bt({valueHex:c})]})]})]}),p=new pe({value:[d,new bt({valueHex:f})]}).toBER(),h=new Uint8Array(p,0,p.byteLength);return["-----BEGIN ENCRYPTED PRIVATE KEY-----",...K(h,"base64pad").split(/(.{64})/).filter(Boolean),"-----END ENCRYPTED PRIVATE KEY-----"].join(`
7
+ `)}async function hd(r,e){let t=Se.get(),n;if(r.includes("-----BEGIN ENCRYPTED PRIVATE KEY-----")){let s=F(r.replace("-----BEGIN ENCRYPTED PRIVATE KEY-----","").replace("-----END ENCRYPTED PRIVATE KEY-----","").replace(/\n/g,"").trim(),"base64pad"),{result:o}=Ir(s),{iv:i,salt:a,iterations:c,keySize:u,cipherText:f}=dd(o),l=await jo(mr,e,a,{c,dkLen:u}),d=await t.subtle.importKey("raw",l,"AES-CBC",!1,["decrypt"]),b=Qr(await t.subtle.decrypt({name:"AES-CBC",iv:i},d,f)),{result:p}=Ir(b);n=Kc(p)}else if(r.includes("-----BEGIN PRIVATE KEY-----")){let s=F(r.replace("-----BEGIN PRIVATE KEY-----","").replace("-----END PRIVATE KEY-----","").replace(/\n/g,"").trim(),"base64pad"),{result:o}=Ir(s);n=Kc(o)}else throw new L("Could not parse private key from PEM data","ERR_INVALID_PARAMETERS");return ei(n)}function dd(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=Qr(o.valueBlock.value[0].getValue()),a=Qo,c=Xo;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 u=e.valueBlock.value[1].valueBlock.value[1],f=u.valueBlock.value[0].toString();if(f!=="OBJECT IDENTIFIER : 1.2.840.113549.3.7"){if(f!=="OBJECT IDENTIFIER : 1.3.14.3.2.7"){if(f!=="OBJECT IDENTIFIER : 2.16.840.1.101.3.4.1.2"){if(f!=="OBJECT IDENTIFIER : 2.16.840.1.101.3.4.1.22"){if(f!=="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 l=Qr(u.valueBlock.value[1].getValue());return{cipherText:Qr(r.valueBlock.value[1].getValue()),salt:i,iterations:a,keySize:c,iv:l}}function Kc(r){return Qr(r.valueBlock.value[2].getValue())}function Qr(r){return new Uint8Array(r,0,r.byteLength)}async function qc(r){let e=await Se.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 zc(e);return{privateKey:t[0],publicKey:t[1]}}async function ti(r){let t=[await Se.get().subtle.importKey("jwk",r,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["sign"]),await pd(r)],n=await zc({privateKey:t[0],publicKey:t[1]});return{privateKey:n[0],publicKey:n[1]}}async function $c(r,e){let t=await Se.get().subtle.importKey("jwk",r,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["sign"]),n=await Se.get().subtle.sign({name:"RSASSA-PKCS1-v1_5"},t,e instanceof Uint8Array?e:e.subarray());return new Uint8Array(n,0,n.byteLength)}async function Gc(r,e,t){let n=await Se.get().subtle.importKey("jwk",r,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["verify"]);return Se.get().subtle.verify({name:"RSASSA-PKCS1-v1_5"},n,e,t instanceof Uint8Array?t:t.subarray())}async function zc(r){if(r.privateKey==null||r.publicKey==null)throw new L("Private and public key are required","ERR_INVALID_PARAMETERS");return Promise.all([Se.get().subtle.exportKey("jwk",r.privateKey),Se.get().subtle.exportKey("jwk",r.publicKey)])}async function pd(r){return Se.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 L("invalid key type","ERR_INVALID_KEY_TYPE");if(r.n==null)throw new L("invalid key modulus","ERR_INVALID_KEY_MODULUS");return F(r.n,"base64url").length*8}var tn=8192,en=class{_key;constructor(e){this._key=e}verify(e,t){return Gc(this._key,t,e)}marshal(){return Dt.jwkToPkix(this._key)}get bytes(){return Qe.encode({Type:X.RSA,Data:this.marshal()}).subarray()}equals(e){return de(this.bytes,e.bytes)}hash(){let e=ye.digest(this.bytes);return Ce(e)?e.then(({bytes:t})=>t):e.bytes}},Sr=class{_key;_publicKey;constructor(e,t){this._key=e,this._publicKey=t}genSecret(){return Jt(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 en(this._publicKey)}marshal(){return Dt.jwkToPkcs1(this._key)}get bytes(){return et.encode({Type:X.RSA,Data:this.marshal()}).subarray()}equals(e){return de(this.bytes,e.bytes)}hash(){let e=ye.digest(this.bytes);return Ce(e)?e.then(({bytes:t})=>t):e.bytes}async id(){let e=await this.public.hash();return K(e,"base58btc")}async export(e,t="pkcs-8"){if(t==="pkcs-8")return Dt.exportToPem(this,e);if(t==="libp2p-key")return wr(this.bytes,e);throw new L(`export format '${t}' is not supported`,"ERR_INVALID_EXPORT_FORMAT")}};async function ei(r){let e=Dt.pkcs1ToJwk(r);if(vs(e)>tn)throw new L("key size is too large","ERR_KEY_SIZE_TOO_LARGE");let t=await ti(e);return new Sr(t.privateKey,t.publicKey)}function md(r){let e=Dt.pkixToJwk(r);if(vs(e)>tn)throw new L("key size is too large","ERR_KEY_SIZE_TOO_LARGE");return new en(e)}async function yd(r){if(vs(r)>tn)throw new L("key size is too large","ERR_KEY_SIZE_TOO_LARGE");let e=await ti(r);return new Sr(e.privateKey,e.publicKey)}async function bd(r){if(r>tn)throw new L("key size is too large","ERR_KEY_SIZE_TOO_LARGE");let e=await qc(r);return new Sr(e.privateKey,e.publicKey)}var ai={};he(ai,{Secp256k1PrivateKey:()=>nn,Secp256k1PublicKey:()=>rn,generateKeyPair:()=>Cd,unmarshalSecp256k1PrivateKey:()=>_d,unmarshalSecp256k1PublicKey:()=>Ld});var wd=(r,e,t)=>r&e^~r&t,xd=(r,e,t)=>r&e^r&t^e&t,vd=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]),Vt=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Ht=new Uint32Array(64),ni=class extends gr{constructor(){super(64,32,8,!1),this.A=Vt[0]|0,this.B=Vt[1]|0,this.C=Vt[2]|0,this.D=Vt[3]|0,this.E=Vt[4]|0,this.F=Vt[5]|0,this.G=Vt[6]|0,this.H=Vt[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 d=Ht[l-15],b=Ht[l-2],p=Me(d,7)^Me(d,18)^d>>>3,h=Me(b,17)^Me(b,19)^b>>>10;Ht[l]=h+Ht[l-7]+p+Ht[l-16]|0}let{A:n,B:s,C:o,D:i,E:a,F:c,G:u,H:f}=this;for(let l=0;l<64;l++){let d=Me(a,6)^Me(a,11)^Me(a,25),b=f+d+wd(a,c,u)+vd[l]+Ht[l]|0,h=(Me(n,2)^Me(n,13)^Me(n,22))+xd(n,s,o)|0;f=u,u=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,u=u+this.G|0,f=f+this.H|0,this.set(n,s,o,i,a,c,u,f)}roundClean(){Ht.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var jc=wn(()=>new ni);function Ed(r){let e=Hr(r);Xe(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:Bd,hexToBytes:Ad}=En,Qt={Err:class extends Error{constructor(e=""){super(e)}},_parseInt(r){let{Err:e}=Qt;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:Bd(n),l:r.subarray(t+2)}},toSig(r){let{Err:e}=Qt,t=typeof r=="string"?Ad(r):r;if(!Fe(t))throw new Error("ui8a expected");let n=t.length;if(n<2||t[0]!=48)throw new e("Invalid signature tag");if(t[1]!==n-2)throw new e("Invalid signature: incorrect length");let{d:s,l:o}=Qt._parseInt(t.subarray(2)),{d:i,l:a}=Qt._parseInt(o);if(a.length)throw new e("Invalid signature: left bytes after parsing");return{r:s,s:i}},hexFromSig(r){let e=u=>Number.parseInt(u[0],16)&8?"00"+u:u,t=u=>{let f=u.toString(16);return f.length&1?`0${f}`:f},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}`}},Et=BigInt(0),Pe=BigInt(1),Ym=BigInt(2),Wc=BigInt(3),Zm=BigInt(4);function Id(r){let e=Ed(r),{Fp:t}=e,n=e.toBytes||((p,h,m)=>{let y=h.toAffine();return dt(Uint8Array.from([4]),t.toBytes(y.x),t.toBytes(y.y))}),s=e.fromBytes||(p=>{let h=p.subarray(1),m=t.fromBytes(h.subarray(0,t.BYTES)),y=t.fromBytes(h.subarray(t.BYTES,2*t.BYTES));return{x:m,y}});function o(p){let{a:h,b:m}=e,y=t.sqr(p),B=t.mul(y,p);return t.add(t.add(B,t.mul(p,h)),m)}if(!t.eql(t.sqr(e.Gy),o(e.Gx)))throw new Error("bad generator point: equation left != right");function i(p){return typeof p=="bigint"&&Et<p&&p<e.n}function a(p){if(!i(p))throw new Error("Expected valid bigint: 0 < bigint < curve.n")}function c(p){let{allowedPrivateKeyLengths:h,nByteLength:m,wrapPrivateKey:y,n:B}=e;if(h&&typeof p!="bigint"){if(Fe(p)&&(p=ft(p)),typeof p!="string"||!h.includes(p.length))throw new Error("Invalid key");p=p.padStart(m*2,"0")}let w;try{w=typeof p=="bigint"?p:ht(te("private key",p,m))}catch{throw new Error(`private key must be ${m} bytes, hex or bigint, not ${typeof p}`)}return y&&(w=Y(w,B)),a(w),w}let u=new Map;function f(p){if(!(p instanceof l))throw new Error("ProjectivePoint expected")}class l{constructor(h,m,y){if(this.px=h,this.py=m,this.pz=y,h==null||!t.isValid(h))throw new Error("x required");if(m==null||!t.isValid(m))throw new Error("y required");if(y==null||!t.isValid(y))throw new Error("z required")}static fromAffine(h){let{x:m,y}=h||{};if(!h||!t.isValid(m)||!t.isValid(y))throw new Error("invalid affine point");if(h instanceof l)throw new Error("projective point not allowed");let B=w=>t.eql(w,t.ZERO);return B(m)&&B(y)?l.ZERO:new l(m,y,t.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(h){let m=t.invertBatch(h.map(y=>y.pz));return h.map((y,B)=>y.toAffine(m[B])).map(l.fromAffine)}static fromHex(h){let m=l.fromAffine(s(te("pointHex",h)));return m.assertValidity(),m}static fromPrivateKey(h){return l.BASE.multiply(c(h))}_setWindowSize(h){this._WINDOW_SIZE=h,u.delete(this)}assertValidity(){if(this.is0()){if(e.allowInfinityPoint&&!t.is0(this.py))return;throw new Error("bad point: ZERO")}let{x:h,y:m}=this.toAffine();if(!t.isValid(h)||!t.isValid(m))throw new Error("bad point: x or y not FE");let y=t.sqr(m),B=o(h);if(!t.eql(y,B))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){let{y:h}=this.toAffine();if(t.isOdd)return!t.isOdd(h);throw new Error("Field doesn't support isOdd")}equals(h){f(h);let{px:m,py:y,pz:B}=this,{px:w,py:R,pz:x}=h,A=t.eql(t.mul(m,x),t.mul(w,B)),N=t.eql(t.mul(y,x),t.mul(R,B));return A&&N}negate(){return new l(this.px,t.neg(this.py),this.pz)}double(){let{a:h,b:m}=e,y=t.mul(m,Wc),{px:B,py:w,pz:R}=this,x=t.ZERO,A=t.ZERO,N=t.ZERO,T=t.mul(B,B),G=t.mul(w,w),q=t.mul(R,R),P=t.mul(B,w);return P=t.add(P,P),N=t.mul(B,R),N=t.add(N,N),x=t.mul(h,N),A=t.mul(y,q),A=t.add(x,A),x=t.sub(G,A),A=t.add(G,A),A=t.mul(x,A),x=t.mul(P,x),N=t.mul(y,N),q=t.mul(h,q),P=t.sub(T,q),P=t.mul(h,P),P=t.add(P,N),N=t.add(T,T),T=t.add(N,T),T=t.add(T,q),T=t.mul(T,P),A=t.add(A,T),q=t.mul(w,R),q=t.add(q,q),T=t.mul(q,P),x=t.sub(x,T),N=t.mul(q,G),N=t.add(N,N),N=t.add(N,N),new l(x,A,N)}add(h){f(h);let{px:m,py:y,pz:B}=this,{px:w,py:R,pz:x}=h,A=t.ZERO,N=t.ZERO,T=t.ZERO,G=e.a,q=t.mul(e.b,Wc),P=t.mul(m,w),ie=t.mul(y,R),re=t.mul(B,x),Le=t.add(m,y),v=t.add(w,R);Le=t.mul(Le,v),v=t.add(P,ie),Le=t.sub(Le,v),v=t.add(m,B);let k=t.add(w,x);return v=t.mul(v,k),k=t.add(P,re),v=t.sub(v,k),k=t.add(y,B),A=t.add(R,x),k=t.mul(k,A),A=t.add(ie,re),k=t.sub(k,A),T=t.mul(G,v),A=t.mul(q,re),T=t.add(A,T),A=t.sub(ie,T),T=t.add(ie,T),N=t.mul(A,T),ie=t.add(P,P),ie=t.add(ie,P),re=t.mul(G,re),v=t.mul(q,v),ie=t.add(ie,re),re=t.sub(P,re),re=t.mul(G,re),v=t.add(v,re),P=t.mul(ie,v),N=t.add(N,P),P=t.mul(k,v),A=t.mul(Le,A),A=t.sub(A,P),P=t.mul(Le,ie),T=t.mul(k,T),T=t.add(T,P),new l(A,N,T)}subtract(h){return this.add(h.negate())}is0(){return this.equals(l.ZERO)}wNAF(h){return b.wNAFCached(this,u,h,m=>{let y=t.invertBatch(m.map(B=>B.pz));return m.map((B,w)=>B.toAffine(y[w])).map(l.fromAffine)})}multiplyUnsafe(h){let m=l.ZERO;if(h===Et)return m;if(a(h),h===Pe)return this;let{endo:y}=e;if(!y)return b.unsafeLadder(this,h);let{k1neg:B,k1:w,k2neg:R,k2:x}=y.splitScalar(h),A=m,N=m,T=this;for(;w>Et||x>Et;)w&Pe&&(A=A.add(T)),x&Pe&&(N=N.add(T)),T=T.double(),w>>=Pe,x>>=Pe;return B&&(A=A.negate()),R&&(N=N.negate()),N=new l(t.mul(N.px,y.beta),N.py,N.pz),A.add(N)}multiply(h){a(h);let m=h,y,B,{endo:w}=e;if(w){let{k1neg:R,k1:x,k2neg:A,k2:N}=w.splitScalar(m),{p:T,f:G}=this.wNAF(x),{p:q,f:P}=this.wNAF(N);T=b.constTimeNegate(R,T),q=b.constTimeNegate(A,q),q=new l(t.mul(q.px,w.beta),q.py,q.pz),y=T.add(q),B=G.add(P)}else{let{p:R,f:x}=this.wNAF(m);y=R,B=x}return l.normalizeZ([y,B])[0]}multiplyAndAddUnsafe(h,m,y){let B=l.BASE,w=(x,A)=>A===Et||A===Pe||!x.equals(B)?x.multiplyUnsafe(A):x.multiply(A),R=w(this,m).add(w(h,y));return R.is0()?void 0:R}toAffine(h){let{px:m,py:y,pz:B}=this,w=this.is0();h==null&&(h=w?t.ONE:t.inv(B));let R=t.mul(m,h),x=t.mul(y,h),A=t.mul(B,h);if(w)return{x:t.ZERO,y:t.ZERO};if(!t.eql(A,t.ONE))throw new Error("invZ was invalid");return{x:R,y:x}}isTorsionFree(){let{h,isTorsionFree:m}=e;if(h===Pe)return!0;if(m)return m(l,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h,clearCofactor:m}=e;return h===Pe?this:m?m(l,this):this.multiplyUnsafe(e.h)}toRawBytes(h=!0){return this.assertValidity(),n(l,this,h)}toHex(h=!0){return ft(this.toRawBytes(h))}}l.BASE=new l(e.Gx,e.Gy,t.ONE),l.ZERO=new l(t.ZERO,t.ONE,t.ZERO);let d=e.nBitLength,b=In(l,e.endo?Math.ceil(d/2):d);return{CURVE:e,ProjectivePoint:l,normPrivateKeyToScalar:c,weierstrassEquation:o,isWithinCurveOrder:i}}function Sd(r){let e=Hr(r);return Xe(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function Yc(r){let e=Sd(r),{Fp:t,n}=e,s=t.BYTES+1,o=2*t.BYTES+1;function i(v){return Et<v&&v<t.ORDER}function a(v){return Y(v,n)}function c(v){return Bn(v,n)}let{ProjectivePoint:u,normPrivateKeyToScalar:f,weierstrassEquation:l,isWithinCurveOrder:d}=Id({...e,toBytes(v,k,O){let E=k.toAffine(),g=t.toBytes(E.x),S=dt;return O?S(Uint8Array.from([k.hasEvenY()?2:3]),g):S(Uint8Array.from([4]),g,t.toBytes(E.y))},fromBytes(v){let k=v.length,O=v[0],E=v.subarray(1);if(k===s&&(O===2||O===3)){let g=ht(E);if(!i(g))throw new Error("Point is not on curve");let S=l(g),_=t.sqrt(S),C=(_&Pe)===Pe;return(O&1)===1!==C&&(_=t.neg(_)),{x:g,y:_}}else if(k===o&&O===4){let g=t.fromBytes(E.subarray(0,t.BYTES)),S=t.fromBytes(E.subarray(t.BYTES,2*t.BYTES));return{x:g,y:S}}else throw new Error(`Point of length ${k} was invalid. Expected ${s} compressed bytes or ${o} uncompressed bytes`)}}),b=v=>ft(Lt(v,e.nByteLength));function p(v){let k=n>>Pe;return v>k}function h(v){return p(v)?a(-v):v}let m=(v,k,O)=>ht(v.slice(k,O));class y{constructor(k,O,E){this.r=k,this.s=O,this.recovery=E,this.assertValidity()}static fromCompact(k){let O=e.nByteLength;return k=te("compactSignature",k,O*2),new y(m(k,0,O),m(k,O,2*O))}static fromDER(k){let{r:O,s:E}=Qt.toSig(te("DER",k));return new y(O,E)}assertValidity(){if(!d(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!d(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(k){return new y(this.r,this.s,k)}recoverPublicKey(k){let{r:O,s:E,recovery:g}=this,S=N(te("msgHash",k));if(g==null||![0,1,2,3].includes(g))throw new Error("recovery id invalid");let _=g===2||g===3?O+e.n:O;if(_>=t.ORDER)throw new Error("recovery id 2 or 3 invalid");let C=g&1?"03":"02",D=u.fromHex(C+b(_)),V=c(_),W=a(-S*V),M=a(E*V),$=u.BASE.multiplyAndAddUnsafe(D,W,M);if(!$)throw new Error("point at infinify");return $.assertValidity(),$}hasHighS(){return p(this.s)}normalizeS(){return this.hasHighS()?new y(this.r,a(-this.s),this.recovery):this}toDERRawBytes(){return Gt(this.toDERHex())}toDERHex(){return Qt.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Gt(this.toCompactHex())}toCompactHex(){return b(this.r)+b(this.s)}}let B={isValidPrivateKey(v){try{return f(v),!0}catch{return!1}},normPrivateKeyToScalar:f,randomPrivateKey:()=>{let v=ko(e.n);return Pa(e.randomBytes(v),e.n)},precompute(v=8,k=u.BASE){return k._setWindowSize(v),k.multiply(BigInt(3)),k}};function w(v,k=!0){return u.fromPrivateKey(v).toRawBytes(k)}function R(v){let k=Fe(v),O=typeof v=="string",E=(k||O)&&v.length;return k?E===s||E===o:O?E===2*s||E===2*o:v instanceof u}function x(v,k,O=!0){if(R(v))throw new Error("first arg must be private key");if(!R(k))throw new Error("second arg must be public key");return u.fromHex(k).multiply(f(v)).toRawBytes(O)}let A=e.bits2int||function(v){let k=ht(v),O=v.length*8-e.nBitLength;return O>0?k>>BigInt(O):k},N=e.bits2int_modN||function(v){return a(A(v))},T=Vr(e.nBitLength);function G(v){if(typeof v!="bigint")throw new Error("bigint expected");if(!(Et<=v&&v<T))throw new Error(`bigint expected < 2^${e.nBitLength}`);return Lt(v,e.nByteLength)}function q(v,k,O=P){if(["recovered","canonical"].some(Q=>Q in O))throw new Error("sign() legacy options not supported");let{hash:E,randomBytes:g}=e,{lowS:S,prehash:_,extraEntropy:C}=O;S==null&&(S=!0),v=te("msgHash",v),_&&(v=te("prehashed msgHash",E(v)));let D=N(v),V=f(k),W=[G(V),G(D)];if(C!=null){let Q=C===!0?g(t.BYTES):C;W.push(te("extraEntropy",Q))}let M=dt(...W),$=D;function ae(Q){let ge=A(Q);if(!d(ge))return;let me=c(ge),le=u.BASE.multiply(ge).toAffine(),we=a(le.x);if(we===Et)return;let it=a(me*a($+we*V));if(it===Et)return;let Kt=(le.x===we?0:2)|Number(le.y&Pe),Lr=it;return S&&p(it)&&(Lr=h(it),Kt^=1),new y(we,Lr,Kt)}return{seed:M,k2sig:ae}}let P={lowS:e.lowS,prehash:!1},ie={lowS:e.lowS,prehash:!1};function re(v,k,O=P){let{seed:E,k2sig:g}=q(v,k,O),S=e;return Bo(S.hash.outputLen,S.nByteLength,S.hmac)(E,g)}u.BASE._setWindowSize(8);function Le(v,k,O,E=ie){let g=v;if(k=te("msgHash",k),O=te("publicKey",O),"strict"in E)throw new Error("options.strict was renamed to lowS");let{lowS:S,prehash:_}=E,C,D;try{if(typeof g=="string"||Fe(g))try{C=y.fromDER(g)}catch(le){if(!(le instanceof Qt.Err))throw le;C=y.fromCompact(g)}else if(typeof g=="object"&&typeof g.r=="bigint"&&typeof g.s=="bigint"){let{r:le,s:we}=g;C=new y(le,we)}else throw new Error("PARSE");D=u.fromHex(O)}catch(le){if(le.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(S&&C.hasHighS())return!1;_&&(k=e.hash(k));let{r:V,s:W}=C,M=N(k),$=c(W),ae=a(M*$),Q=a(V*$),ge=u.BASE.multiplyAndAddUnsafe(D,ae,Q)?.toAffine();return ge?a(ge.x)===V:!1}return{CURVE:e,getPublicKey:w,getSharedSecret:x,sign:re,verify:Le,ProjectivePoint:u,Signature:y,utils:B}}function kd(r){return{hash:r,hmac:(e,...t)=>$r(r,e,bn(...t)),randomBytes:pr}}function Zc(r,e){let t=n=>Yc({...r,...kd(n)});return Object.freeze({...t(e),create:t})}var Qc=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),Jc=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),Nd=BigInt(1),si=BigInt(2),Xc=(r,e)=>(r+e/si)/e;function Td(r){let e=Qc,t=BigInt(3),n=BigInt(6),s=BigInt(11),o=BigInt(22),i=BigInt(23),a=BigInt(44),c=BigInt(88),u=r*r*r%e,f=u*u*r%e,l=J(f,t,e)*f%e,d=J(l,t,e)*f%e,b=J(d,si,e)*u%e,p=J(b,s,e)*b%e,h=J(p,o,e)*p%e,m=J(h,a,e)*h%e,y=J(m,c,e)*m%e,B=J(y,a,e)*h%e,w=J(B,t,e)*f%e,R=J(w,i,e)*p%e,x=J(R,n,e)*u%e,A=J(x,si,e);if(!oi.eql(oi.sqr(A),r))throw new Error("Cannot find square root");return A}var oi=An(Qc,void 0,void 0,{sqrt:Td}),Ye=Zc({a:BigInt(0),b:BigInt(7),Fp:oi,n:Jc,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:r=>{let e=Jc,t=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-Nd*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),s=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),o=t,i=BigInt("0x100000000000000000000000000000000"),a=Xc(o*r,e),c=Xc(-n*r,e),u=Y(r-a*t-c*s,e),f=Y(-a*n-c*o,e),l=u>i,d=f>i;if(l&&(u=e-u),d&&(f=e-f),u>i||f>i)throw new Error("splitScalar: Endomorphism failed, k="+r);return{k1neg:l,k1:u,k2neg:d,k2:f}}}},jc),oy=BigInt(0);var iy=Ye.ProjectivePoint;function el(){return Ye.utils.randomPrivateKey()}function tl(r,e){let t=ye.digest(e instanceof Uint8Array?e:e.subarray());if(Ce(t))return t.then(({digest:n})=>Ye.sign(n,r).toDERRawBytes()).catch(n=>{throw new L(String(n),"ERR_INVALID_INPUT")});try{return Ye.sign(t.digest,r).toDERRawBytes()}catch(n){throw new L(String(n),"ERR_INVALID_INPUT")}}function rl(r,e,t){let n=ye.digest(t instanceof Uint8Array?t:t.subarray());if(Ce(n))return n.then(({digest:s})=>Ye.verify(e,s,r)).catch(s=>{throw new L(String(s),"ERR_INVALID_INPUT")});try{return Ye.verify(e,n.digest,r)}catch(s){throw new L(String(s),"ERR_INVALID_INPUT")}}function nl(r){return Ye.ProjectivePoint.fromHex(r).toRawBytes(!0)}function sl(r){try{Ye.getPublicKey(r,!0)}catch(e){throw new L(String(e),"ERR_INVALID_PRIVATE_KEY")}}function ii(r){try{Ye.ProjectivePoint.fromHex(r)}catch(e){throw new L(String(e),"ERR_INVALID_PUBLIC_KEY")}}function ol(r){try{return Ye.getPublicKey(r,!0)}catch(e){throw new L(String(e),"ERR_INVALID_PRIVATE_KEY")}}var rn=class{_key;constructor(e){ii(e),this._key=e}verify(e,t){return rl(this._key,t,e)}marshal(){return nl(this._key)}get bytes(){return Qe.encode({Type:X.Secp256k1,Data:this.marshal()}).subarray()}equals(e){return de(this.bytes,e.bytes)}async hash(){let e=ye.digest(this.bytes),t;return Ce(e)?{bytes:t}=await e:t=e.bytes,t}},nn=class{_key;_publicKey;constructor(e,t){this._key=e,this._publicKey=t??ol(e),sl(this._key),ii(this._publicKey)}sign(e){return tl(this._key,e)}get public(){return new rn(this._publicKey)}marshal(){return this._key}get bytes(){return et.encode({Type:X.Secp256k1,Data:this.marshal()}).subarray()}equals(e){return de(this.bytes,e.bytes)}hash(){let e=ye.digest(this.bytes);return Ce(e)?e.then(({bytes:t})=>t):e.bytes}async id(){let e=await this.public.hash();return K(e,"base58btc")}async export(e,t="libp2p-key"){if(t==="libp2p-key")return wr(this.bytes,e);throw new L(`export format '${t}' is not supported`,"ERR_INVALID_EXPORT_FORMAT")}};function _d(r){return new nn(r)}function Ld(r){return new rn(r)}async function Cd(){let r=el();return new nn(r)}var er={rsa:ri,ed25519:zo,secp256k1:ai};function il(r){let e=Object.keys(er).join(" / ");return new L(`invalid or unsupported key type ${r}. Must be ${e}`,"ERR_UNSUPPORTED_KEY_TYPE")}function al(r){let e=Qe.decode(r),t=e.Data??new Uint8Array;switch(e.Type){case X.RSA:return er.rsa.unmarshalRsaPublicKey(t);case X.Ed25519:return er.ed25519.unmarshalEd25519PublicKey(t);case X.Secp256k1:return er.secp256k1.unmarshalSecp256k1PublicKey(t);default:throw il(e.Type??"unknown")}}async function cl(r){let e=et.decode(r),t=e.Data??new Uint8Array;switch(e.Type){case X.RSA:return er.rsa.unmarshalRsaPrivateKey(t);case X.Ed25519:return er.ed25519.unmarshalEd25519PrivateKey(t);case X.Secp256k1:return er.secp256k1.unmarshalSecp256k1PrivateKey(t);default:throw il(e.Type??"RSA")}}var Ud=Math.pow(2,7),Pd=Math.pow(2,14),Od=Math.pow(2,21),ci=Math.pow(2,28),li=Math.pow(2,35),ui=Math.pow(2,42),fi=Math.pow(2,49),z=128,Be=127;function Ae(r){if(r<Ud)return 1;if(r<Pd)return 2;if(r<Od)return 3;if(r<ci)return 4;if(r<li)return 5;if(r<ui)return 6;if(r<fi)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function Dd(r,e,t=0){switch(Ae(r)){case 8:e[t++]=r&255|z,r/=128;case 7:e[t++]=r&255|z,r/=128;case 6:e[t++]=r&255|z,r/=128;case 5:e[t++]=r&255|z,r/=128;case 4:e[t++]=r&255|z,r>>>=7;case 3:e[t++]=r&255|z,r>>>=7;case 2:e[t++]=r&255|z,r>>>=7;case 1:{e[t++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return e}function Vd(r,e,t=0){switch(Ae(r)){case 8:e.set(t++,r&255|z),r/=128;case 7:e.set(t++,r&255|z),r/=128;case 6:e.set(t++,r&255|z),r/=128;case 5:e.set(t++,r&255|z),r/=128;case 4:e.set(t++,r&255|z),r>>>=7;case 3:e.set(t++,r&255|z),r>>>=7;case 2:e.set(t++,r&255|z),r>>>=7;case 1:{e.set(t++,r&255),r>>>=7;break}default:throw new Error("unreachable")}return e}function Hd(r,e){let t=r[e],n=0;if(n+=t&Be,t<z||(t=r[e+1],n+=(t&Be)<<7,t<z)||(t=r[e+2],n+=(t&Be)<<14,t<z)||(t=r[e+3],n+=(t&Be)<<21,t<z)||(t=r[e+4],n+=(t&Be)*ci,t<z)||(t=r[e+5],n+=(t&Be)*li,t<z)||(t=r[e+6],n+=(t&Be)*ui,t<z)||(t=r[e+7],n+=(t&Be)*fi,t<z))return n;throw new RangeError("Could not decode varint")}function Md(r,e){let t=r.get(e),n=0;if(n+=t&Be,t<z||(t=r.get(e+1),n+=(t&Be)<<7,t<z)||(t=r.get(e+2),n+=(t&Be)<<14,t<z)||(t=r.get(e+3),n+=(t&Be)<<21,t<z)||(t=r.get(e+4),n+=(t&Be)*ci,t<z)||(t=r.get(e+5),n+=(t&Be)*li,t<z)||(t=r.get(e+6),n+=(t&Be)*ui,t<z)||(t=r.get(e+7),n+=(t&Be)*fi,t<z))return n;throw new RangeError("Could not decode varint")}function Oe(r,e,t=0){return e==null&&(e=xe(Ae(r))),e instanceof Uint8Array?Dd(r,e,t):Vd(r,e,t)}function Ze(r,e=0){return r instanceof Uint8Array?Hd(r,e):Md(r,e)}var ul=Symbol.for("@achingbrain/uint8arraylist");function ll(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?.[ul]}var Re=class r{bufs;length;[ul]=!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=ll(this.bufs,e);return t.buf[t.index]}set(e,t){let n=ll(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 Ie(n,s)}subarray(e,t){let{bufs:n,length:s}=this._subList(e,t);return n.length===1?n[0]:Ie(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 u=e>=a&&e<c,f=t>a&&t<=c;if(u&&f){if(e===a&&t===c){n.push(i);break}let l=e-a;n.push(i.subarray(l,l+(t-e)));break}if(u){if(e===0){n.push(i);continue}n.push(i.subarray(e-a));continue}if(f){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,u=n.byteLength-1,f;for(let l=t;l<=c;l+=f){f=0;for(let d=u;d>=0;d--){let b=this.get(l+d);if(n[d]!==b){f=Math.max(1,d-a[b]);break}}if(f===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=xe(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=lt(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=lt(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=lt(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=xe(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=lt(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=lt(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=lt(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=lt(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=lt(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(!de(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 fl={ERR_SIGNATURE_NOT_VALID:"ERR_SIGNATURE_NOT_VALID"};var sn;(function(r){let e;r.codec=()=>(e==null&&(e=ze((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=>$e(t,r.codec())})(sn||(sn={}));var Mt=class r{static createFromProtobuf=async e=>{let t=sn.decode(e),n=await Dr(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=hl(n,s,o),c=await(await cl(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",fl.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=sn.encode({publicKey:this.peerId.publicKey,payloadType:this.payloadType,payload:this.payload.subarray(),signature:this.signature})),this.marshaled}equals(e){return de(this.marshal(),e.marshal())}async validate(e){let t=hl(e,this.payloadType,this.payload);if(this.peerId.publicKey==null)throw new Error("Missing public key");return al(this.peerId.publicKey).verify(t.subarray(),this.signature)}},hl=(r,e,t)=>{let n=F(r),s=Oe(n.byteLength),o=Oe(e.length),i=Oe(t.length);return new Re(s,n,o,e,i,t)};function dl(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",u=2**(8*s)-1;for(;;){let f=this.readAtomically(()=>{let l=this.readChar();if(l===void 0)return;let d=Number.parseInt(l,e);if(!Number.isNaN(d))return d});if(f===void 0)break;if(o*=e,o+=f,o>u||(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 pl=45,Fd=15,Nr=new Bs;function hi(r){if(!(r.length>Fd))return Nr.new(r).parseWith(()=>Nr.readIPv4Addr())}function di(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>pl))return Nr.new(r).parseWith(()=>Nr.readIPv6Addr())}function As(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>pl))return Nr.new(r).parseWith(()=>Nr.readIPAddr())}var jy=parseInt("0xFFFF",16),Wy=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);function Is(r){return!!hi(r)}function Ss(r){return!!di(r)}function ks(r){return!!As(r)}var yl=Is,zd=Ss,pi=function(r){let e=0;if(r=r.toString().trim(),yl(r)){let t=new Uint8Array(e+4);return r.split(/\./g).forEach(n=>{t[e++]=parseInt(n,10)&255}),t}if(zd(r)){let t=r.split(":",8),n;for(n=0;n<t.length;n++){let o=yl(t[n]),i;o&&(i=pi(t[n]),t[n]=K(i.slice(0,2),"base16")),i!=null&&++n<8&&t.splice(n,0,K(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")},bl=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={},gi={},Wd=[[4,32,"ip4"],[6,16,"tcp"],[33,16,"dccp"],[41,128,"ip6"],[42,-1,"ip6zone"],[43,8,"ipcidr"],[53,-1,"dns",!0],[54,-1,"dns4",!0],[55,-1,"dns6",!0],[56,-1,"dnsaddr",!0],[132,16,"sctp"],[273,16,"udp"],[275,0,"p2p-webrtc-star"],[276,0,"p2p-webrtc-direct"],[277,0,"p2p-stardust"],[280,0,"webrtc-direct"],[281,0,"webrtc"],[290,0,"p2p-circuit"],[301,0,"udt"],[302,0,"utp"],[400,-1,"unix",!1,!0],[421,-1,"ipfs"],[421,-1,"p2p"],[443,0,"https"],[444,96,"onion"],[445,296,"onion3"],[446,-1,"garlic64"],[448,0,"tls"],[449,-1,"sni"],[460,0,"quic"],[461,0,"quic-v1"],[465,0,"webtransport"],[466,-1,"certhash"],[477,0,"ws"],[478,0,"wss"],[479,0,"p2p-websocket-star"],[480,0,"http"],[777,-1,"memory"]];Wd.forEach(r=>{let e=Yd(...r);gi[e.code]=e,Tr[e.name]=e});function Yd(r,e,t,n,s){return{code:r,size:e,name:t,resolvable:!!n,path:!!s}}function j(r){if(typeof r=="number"){if(gi[r]!=null)return gi[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 _b=j("ip4"),Lb=j("ip6"),Cb=j("ipcidr");function yi(r,e){switch(j(r).code){case 4:case 41:return Jd(e);case 42:return vl(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 vl(e);case 421:return t0(e);case 444:return El(e);case 445:return El(e);case 466:return e0(e);default:return K(e,"base16")}}function bi(r,e){switch(j(r).code){case 4:return wl(e);case 41:return wl(e);case 42:return xl(e);case 6:case 273:case 33:case 132:return wi(parseInt(e,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return xl(e);case 421:return Xd(e);case 444:return r0(e);case 445:return n0(e);case 466:return Qd(e);default:return F(e,"base16")}}var mi=Object.values(St).map(r=>r.decoder),Zd=function(){let r=mi[0].or(mi[1]);return mi.slice(2).forEach(e=>r=r.or(e)),r}();function wl(r){if(!ks(r))throw new Error("invalid ip address");return pi(r)}function Jd(r){let e=bl(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 wi(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 xl(r){let e=F(r),t=Uint8Array.from(Oe(e.length));return Ie([t,e],t.length+e.length)}function vl(r){let e=Ze(r);if(r=r.slice(Ae(e)),r.length!==e)throw new Error("inconsistent lengths");return K(r)}function Xd(r){let e;r[0]==="Q"||r[0]==="1"?e=qt(ne.decode(`z${r}`)).bytes:e=He.parse(r).multihash.bytes;let t=Uint8Array.from(Oe(e.length));return Ie([t,e],t.length+e.length)}function Qd(r){let e=Zd.decode(r),t=Uint8Array.from(Oe(e.length));return Ie([t,e],t.length+e.length)}function e0(r){let e=Ze(r),t=r.slice(Ae(e));if(t.length!==e)throw new Error("inconsistent lengths");return"u"+K(t,"base64url")}function t0(r){let e=Ze(r),t=r.slice(Ae(e));if(t.length!==e)throw new Error("inconsistent lengths");return K(t,"base58btc")}function r0(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=ct.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=wi(n);return Ie([t,s],t.length+s.length)}function n0(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=ct.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=wi(n);return Ie([t,s],t.length+s.length)}function El(r){let e=r.slice(0,r.length-2),t=r.slice(r.length-2),n=K(e,"base32"),s=Bl(t);return`${n}:${s}`}function Al(r){r=xi(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=j(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=xi(s.slice(o).join("/")),e.push([a.code,bi(a.code,n)]),t.push([a.code,n]);break}let c=bi(a.code,s[o]);e.push([a.code,c]),t.push([a.code,yi(a.code,c)])}return{string:Il(t),bytes:Ei(e),tuples:e,stringTuples:t,path:n}}function vi(r){let e=[],t=[],n=null,s=0;for(;s<r.length;){let o=Ze(r,s),i=Ae(o),a=j(o),c=s0(a,r.slice(s+i));if(c===0){e.push([o]),t.push([o]),s+=i;continue}let u=r.slice(s+i,s+i+c);if(s+=c+i,s>r.length)throw Sl("Invalid address Uint8Array: "+K(r,"base16"));e.push([o,u]);let f=yi(o,u);if(t.push([o,f]),a.path===!0){n=f;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=j(t[0]);return e.push(n.name),t.length>1&&t[1]!=null&&e.push(t[1]),null}),xi(e.join("/"))}function Ei(r){return Ie(r.map(e=>{let t=j(e[0]),n=Uint8Array.from(Oe(t.code));return e.length>1&&e[1]!=null&&(n=Ie([n,e[1]])),n}))}function s0(r,e){if(r.size>0)return r.size/8;if(r.size===0)return 0;{let t=Ze(e instanceof Uint8Array?e:Uint8Array.from(e));return t+Ae(t)}}function xi(r){return"/"+r.trim().split("/").filter(e=>e).join("/")}function Sl(r){return new Error("Error parsing address: "+r)}var o0=Symbol.for("nodejs.util.inspect.custom"),Bi=Symbol.for("@multiformats/js-multiaddr/multiaddr"),i0=[j("dns").code,j("dns4").code,j("dns6").code,j("dnsaddr").code],Ns=class r{bytes;#e;#t;#r;#n;[Bi]=!0;constructor(e){e==null&&(e="");let t;if(e instanceof Uint8Array)t=vi(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=vi(e.bytes);else throw new Error("addr must be a string, Buffer, or another Multiaddr");this.bytes=t.bytes,this.#e=t.string,this.#t=t.tuples,this.#r=t.stringTuples,this.#n=t.path}toString(){return this.#e}toJSON(){return this.toString()}toOptions(){let e,t,n,s,o="",i=j("tcp"),a=j("udp"),c=j("ip4"),u=j("ip6"),f=j("dns6"),l=j("ip6zone");for(let[b,p]of this.stringTuples())b===l.code&&(o=`%${p??""}`),i0.includes(b)&&(t=i.name,s=443,n=`${p??""}${o}`,e=b===f.code?6:4),(b===i.code||b===a.code)&&(t=j(b).name,s=parseInt(p??"")),(b===c.code||b===u.code)&&(t=j(b).name,n=`${p??""}${o}`,e=b===u.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.#t.map(([e])=>Object.assign({},j(e)))}protoCodes(){return this.#t.map(([e])=>e)}protoNames(){return this.#t.map(([e])=>j(e).name)}tuples(){return this.#t}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(Ei(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"?K(ne.decode(`z${n}`),"base58btc"):K(He.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){return this.#n}equals(e){return de(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 L(`no available resolver for ${t.name}`,"ERR_NO_AVAILABLE_RESOLVER");return(await n(this,e)).map(o=>new r(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)}[o0](){return`Multiaddr(${this.#e})`}};var kl=new Map;function Nl(r){return!!r?.[Bi]}function Ft(r){return new Ns(r)}var Tl="libp2p-peer-record",Rl=Uint8Array.from([3,1]);var on;(function(r){let e;(function(n){let s;n.codec=()=>(s==null&&(s=ze((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 u=o.uint32();switch(u>>>3){case 1:a.multiaddr=o.bytes();break;default:o.skipType(u&7);break}}return a})),s),n.encode=o=>Ge(o,n.codec()),n.decode=o=>$e(o,n.codec())})(e=r.AddressInfo||(r.AddressInfo={}));let t;r.codec=()=>(t==null&&(t=ze((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=>$e(n,r.codec())})(on||(on={}));var Bt=class r{static createFromProtobuf=e=>{let t=on.decode(e),n=go(t.peerId),s=(t.addresses??[]).map(i=>Ft(i.multiaddr)),o=t.seq;return new r({peerId:n,multiaddrs:s,seqNumber:o})};static DOMAIN=Tl;static CODEC=Rl;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=on.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||!dl(this.multiaddrs,e.multiaddrs))}};var a0=r=>r.toString().split("/").slice(1),an=r=>({match:e=>e.length<1?!1:r(e[0])?e.slice(1):!1,pattern:"fn"}),se=r=>({match:e=>an(t=>t===r).match(e),pattern:r}),_s=()=>({match:r=>an(e=>typeof e=="string").match(r),pattern:"{string}"}),_l=()=>({match:r=>an(e=>!isNaN(parseInt(e))).match(r),pattern:"{number}"}),De=()=>({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}"}),Ts=()=>({match:r=>{if(r.length<2||r[0]!=="certhash")return!1;try{ro.decode(r[1])}catch{return!1}return r.slice(2)},pattern:"/certhash/{certhash}"}),st=r=>({match:e=>{let t=r.match(e);return t===!1?e:t},pattern:`optional(${r.pattern})`}),ot=(...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(", ")})`}),oe=(...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 fe(...r){function e(s){let o=a0(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 Ii=oe(se("dns4"),_s()),Si=oe(se("dns6"),_s()),ki=oe(se("dnsaddr"),_s()),Ll=oe(se("dns"),_s()),xw=fe(Ii),vw=fe(Si),Ew=fe(ki),Bw=fe(ot(Ll,ki,Ii,Si)),Cl=oe(se("ip4"),an(Is)),Ul=oe(se("ip6"),an(Ss)),Pl=ot(Cl,Ul),cn=ot(Pl,Ll,Ii,Si,ki),Ol=fe(cn),Aw=fe(Cl),Iw=fe(Ul),Sw=fe(Pl),Ls=oe(cn,se("tcp"),_l()),ln=oe(cn,se("udp"),_l()),c0=ot(Ls,ln),kw=fe(Ls),Nw=fe(ln),Ni=oe(ln,se("quic")),Cs=oe(ln,se("quic-v1")),l0=ot(Ni,Cs),Tw=fe(Ni),Rw=fe(Cs),Ai=ot(cn,Ls,ln,Ni,Cs),Dl=ot(oe(Ai,se("ws"),st(De()))),_w=fe(Dl),Vl=ot(oe(Ai,se("wss"),st(De())),oe(Ai,se("tls"),se("ws"),st(De()))),Lw=fe(Vl),Hl=oe(c0,se("webrtc-direct"),Ts(),st(Ts()),st(De())),Cw=fe(Hl),Ml=oe(Cs,se("webtransport"),Ts(),Ts(),st(De())),Uw=fe(Ml),Rs=ot(Dl,Vl,oe(Ls,st(De())),oe(l0,st(De())),oe(cn,st(De())),Hl,Ml,De()),Pw=fe(Rs),u0=oe(Rs,se("p2p-circuit"),De()),Ow=fe(u0),f0=ot(oe(Rs,se("p2p-circuit"),se("webrtc"),De()),oe(Rs,se("webrtc"),st(De())),se("webrtc")),Dw=fe(f0);function Rr(){let r={};return r.promise=new Promise((e,t)=>{r.resolve=e,r.reject=t}),r}var Us=class extends Error{type;code;constructor(e,t){super(e??"The operation was aborted"),this.type="aborted",this.name="AbortError",this.code=t??"ABORT_ERR"}};async function Fl(r,e,t){if(e==null)return r;if(e.aborted)return Promise.reject(new Us(t?.errorMessage,t?.errorCode));let n,s=new Us(t?.errorMessage,t?.errorCode);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 Ti=class{needNext;haveNext;ended;nextResult;constructor(){this.ended=!1,this.needNext=Rr(),this.haveNext=Rr()}[Symbol.asyncIterator](){return this}async next(){if(this.nextResult==null&&await this.haveNext.promise,this.nextResult==null)throw new Error("Have next but next was undefined");let e=this.nextResult;return this.nextResult=void 0,this.needNext.resolve(),this.needNext=Rr(),e}async throw(e){return this.ended=!0,e!=null&&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");this.nextResult!=null&&await this.needNext.promise,e!=null?this.nextResult={done:!1,value:e}:(this.ended=!0,this.nextResult={done:!0,value:void 0}),this.haveNext.resolve(),this.haveNext=Rr(),await Fl(this.needNext.promise,t?.signal,t)}};function Kl(){return new Ti}var Ps=class extends Error{code;constructor(e,t){super(e),this.code=t}},Ri=class extends Ps{type;constructor(e){super(e,"ABORT_ERR"),this.type="aborted"}};function ql(r,e){let t=Kl();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 Re;return{read:async(i,a)=>{a?.signal?.throwIfAborted();let c,u=new Promise((f,l)=>{c=()=>{l(new Ri("Read aborted"))},a?.signal?.addEventListener("abort",c)});try{if(i==null){let{done:l,value:d}=await Promise.race([n.next(),u]);return l===!0?new Re:d}for(;s.byteLength<i;){let{value:l,done:d}=await Promise.race([n.next(),u]);if(d===!0)throw new Ps("unexpected end of input","ERR_UNEXPECTED_EOF");s.append(l)}let f=s.sublist(0,i);return s.consume(i),f}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}}}function Os(r){return r[Symbol.asyncIterator]!=null}var Ds=r=>{let e=Ae(r),t=xe(e);return Oe(r,t),Ds.bytes=e,t};Ds.bytes=0;function un(r,e){e=e??{};let t=e.lengthEncoder??Ds;function*n(s){let o=t(s.byteLength);o instanceof Uint8Array?yield o:yield*o,s instanceof Uint8Array?yield s:yield*s}return Os(r)?async function*(){for await(let s of r)yield*n(s)}():function*(){for(let s of r)yield*n(s)}()}un.single=(r,e)=>{e=e??{};let t=e.lengthEncoder??Ds;return new Re(t(r.byteLength),r)};var _r=qs(zl(),1);var d0=8,p0=1024*1024*4,tr;(function(r){r[r.LENGTH=0]="LENGTH",r[r.DATA=1]="DATA"})(tr||(tr={}));var Li=r=>{let e=Ze(r);return Li.bytes=Ae(e),e};Li.bytes=0;function _i(r,e){let t=new Re,n=tr.LENGTH,s=-1,o=e?.lengthDecoder??Li,i=e?.maxLengthLength??d0,a=e?.maxDataLength??p0;function*c(){for(;t.byteLength>0;){if(n===tr.LENGTH)try{if(s=o(t),s<0)throw(0,_r.default)(new Error("invalid message length"),"ERR_INVALID_MSG_LENGTH");if(s>a)throw(0,_r.default)(new Error("message length too long"),"ERR_MSG_DATA_TOO_LONG");let u=o.bytes;t.consume(u),e?.onLength!=null&&e.onLength(s),n=tr.DATA}catch(u){if(u instanceof RangeError){if(t.byteLength>i)throw(0,_r.default)(new Error("message length length too long"),"ERR_MSG_LENGTH_TOO_LONG");break}throw u}if(n===tr.DATA){if(t.byteLength<s)break;let u=t.sublist(0,s);t.consume(s),e?.onData!=null&&e.onData(u),yield u,n=tr.LENGTH}}}return Os(r)?async function*(){for await(let u of r)t.append(u),yield*c();if(t.byteLength>0)throw(0,_r.default)(new Error("unexpected end of input"),"ERR_UNEXPECTED_EOF")}():function*(){for(let u of r)t.append(u),yield*c();if(t.byteLength>0)throw(0,_r.default)(new Error("unexpected end of input"),"ERR_UNEXPECTED_EOF")}()}_i.fromReader=(r,e)=>{let t=1,n=async function*(){for(;;)try{let{done:o,value:i}=await r.next(t);if(o===!0)return;i!=null&&(yield i)}catch(o){if(o.code==="ERR_UNDER_READ")return{done:!0,value:null};throw o}finally{t=1}}();return _i(n,{...e??{},onLength:o=>{t=o}})};var Vs=class extends Error{code;constructor(e,t){super(e),this.code=t}},jl=r=>Ze(r);jl.bytes=0;function Wl(r,e={}){let t=ql(r,e);return e.maxDataLength!=null&&e.maxLengthLength==null&&(e.maxLengthLength=Ae(e.maxDataLength)),{read:async s=>{let o=-1,i=new Re,a=e?.lengthDecoder??jl;for(;;){i.append(await t.read(1,s));try{o=a(i)}catch(c){if(c instanceof RangeError)continue;throw c}if(e?.maxLengthLength!=null&&i.byteLength>e.maxLengthLength)throw new Vs("message length length too long","ERR_MSG_LENGTH_TOO_LONG");if(o>-1)break}if(e?.maxDataLength!=null&&o>e.maxDataLength)throw new Vs("message length too long","ERR_MSG_DATA_TOO_LONG");return t.read(o,s)},write:async(s,o)=>{await t.write(un.single(s,e),o)},writeV:async(s,o)=>{let i=new Re(...s.map(a=>un.single(a,e)));await t.write(i,o)},unwrap:()=>t.unwrap()}}function fn(r,e){let t=Wl(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 Jl=qs(Zl(),1),Ci=typeof window=="object"&&typeof document=="object"&&document.nodeType===9,Hs=(0,Jl.default)(),Xl=Ci&&!Hs,Ql=Hs&&!Ci,eu=Hs&&Ci,tu=typeof globalThis.process<"u"&&typeof globalThis.process.release<"u"&&globalThis.process.release.name==="node"&&!Hs,ru=typeof importScripts=="function"&&typeof self<"u"&&typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope,fx=typeof globalThis.process<"u"&&typeof globalThis.process.env<"u"&&globalThis.process.env["NODE"+"_"+"ENV"]==="test",nu=typeof navigator<"u"&&navigator.product==="ReactNative";var rr;(function(r){let e;r.codec=()=>(e==null&&(e=ze((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=>$e(t,r.codec())})(rr||(rr={}));var Ui=1024*8,Ve={protocolPrefix:"ipfs",timeout:6e4,maxInboundStreams:1,maxOutboundStreams:1,maxPushIncomingStreams:1,maxPushOutgoingStreams:1,maxObservedAddresses:10,maxIdentifyMessageSize:8192,runOnConnectionOpen:!0,runOnTransientConnection:!0},Ms=class{identifyProtocolStr;identifyPushProtocolStr;host;started;timeout;peerId;peerStore;registrar;connectionManager;addressManager;maxInboundStreams;maxOutboundStreams;maxPushIncomingStreams;maxPushOutgoingStreams;maxIdentifyMessageSize;maxObservedAddresses;events;runOnTransientConnection;log;constructor(e,t={}){this.started=!1,this.peerId=e.peerId,this.peerStore=e.peerStore,this.registrar=e.registrar,this.addressManager=e.addressManager,this.connectionManager=e.connectionManager,this.events=e.events,this.log=e.logger.forComponent("libp2p:identify"),this.identifyProtocolStr=`/${t.protocolPrefix??Ve.protocolPrefix}/${ji}/${Yi}`,this.identifyPushProtocolStr=`/${t.protocolPrefix??Ve.protocolPrefix}/${Wi}/${Zi}`,this.timeout=t.timeout??Ve.timeout,this.maxInboundStreams=t.maxInboundStreams??Ve.maxInboundStreams,this.maxOutboundStreams=t.maxOutboundStreams??Ve.maxOutboundStreams,this.maxPushIncomingStreams=t.maxPushIncomingStreams??Ve.maxPushIncomingStreams,this.maxPushOutgoingStreams=t.maxPushOutgoingStreams??Ve.maxPushOutgoingStreams,this.maxIdentifyMessageSize=t.maxIdentifyMessageSize??Ve.maxIdentifyMessageSize,this.maxObservedAddresses=t.maxObservedAddresses??Ve.maxObservedAddresses,this.runOnTransientConnection=t.runOnTransientConnection??Ve.runOnTransientConnection,this.host={protocolVersion:`${t.protocolPrefix??Ve.protocolPrefix}/${zi}`,agentVersion:t.agentVersion??`${e.nodeInfo.name}/${e.nodeInfo.version}`},(t.runOnConnectionOpen??Ve.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)})}),e.events.addEventListener("self:peer:update",n=>{this.push().catch(s=>{this.log.error(s)})}),this.host.agentVersion===`${e.nodeInfo.name}/${e.nodeInfo.version}`&&(tu||Ql?this.host.agentVersion+=` UserAgent=${globalThis.process.version}`:(Xl||ru||eu||nu)&&(this.host.agentVersion+=` UserAgent=${globalThis.navigator.userAgent}`))}isStarted(){return this.started}async start(){this.started||(await this.peerStore.merge(this.peerId,{metadata:{AgentVersion:F(this.host.agentVersion),ProtocolVersion:F(this.host.protocolVersion)}}),await this.registrar.handle(this.identifyProtocolStr,e=>{this._handleIdentify(e).catch(t=>{this.log.error(t)})},{maxInboundStreams:this.maxInboundStreams,maxOutboundStreams:this.maxOutboundStreams,runOnTransientConnection:this.runOnTransientConnection}),await this.registrar.handle(this.identifyPushProtocolStr,e=>{this._handlePush(e).catch(t=>{this.log.error(t)})},{maxInboundStreams:this.maxPushIncomingStreams,maxOutboundStreams:this.maxPushOutgoingStreams,runOnTransientConnection:this.runOnTransientConnection}),this.started=!0)}async stop(){await this.registrar.unhandle(this.identifyProtocolStr),await this.registrar.unhandle(this.identifyPushProtocolStr),this.started=!1}async pushToConnections(e){let t=this.addressManager.getAddresses().map(f=>f.decapsulateCode(j("p2p").code)),n=new Bt({peerId:this.peerId,multiaddrs:t}),s=await Mt.seal(n,this.peerId),o=this.registrar.getProtocols(),i=await this.peerStore.get(this.peerId),a=K(i.metadata.get("AgentVersion")??F(this.host.agentVersion)),c=K(i.metadata.get("ProtocolVersion")??F(this.host.protocolVersion)),u=e.map(async f=>{let l,d=AbortSignal.timeout(this.timeout);dn(1/0,d);try{l=await f.newStream(this.identifyPushProtocolStr,{signal:d,runOnTransientConnection:this.runOnTransientConnection}),await fn(l,{maxDataLength:this.maxIdentifyMessageSize??Ui}).pb(rr).write({listenAddrs:t.map(p=>p.bytes),signedPeerRecord:s.marshal(),protocols:o,agentVersion:a,protocolVersion:c},{signal:d}),await l.close({signal:d})}catch(b){this.log.error("could not push identify update to peer",b),l?.abort(b)}});await Promise.all(u)}async push(){if(!this.isStarted())return;let e=[];await Promise.all(this.connectionManager.getConnections().map(async t=>{try{if(!(await this.peerStore.get(t.remotePeer)).protocols.includes(this.identifyPushProtocolStr))return;e.push(t)}catch(n){if(n.code!==Xi)throw n}})),await this.pushToConnections(e)}async _identify(e,t={}){let n;if(t.signal==null){let s=AbortSignal.timeout(this.timeout);dn(1/0,s),t={...t,signal:s}}try{n=await e.newStream(this.identifyProtocolStr,{...t,runOnTransientConnection:this.runOnTransientConnection});let o=await fn(n,{maxDataLength:this.maxIdentifyMessageSize??Ui}).pb(rr).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 Dr(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=y0(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)),this.#e(e,n)}async _handleIdentify(e){let{connection:t,stream:n}=e,s=AbortSignal.timeout(this.timeout);dn(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(j("p2p").code)),c=i.peerRecordEnvelope;if(a.length>0&&c==null){let l=new Bt({peerId:this.peerId,multiaddrs:a});c=(await Mt.seal(l,this.peerId)).marshal().subarray()}let u=t.remoteAddr.bytes;Ol.matches(t.remoteAddr)||(u=void 0),await fn(n).pb(rr).write({protocolVersion:this.host.protocolVersion,agentVersion:this.host.agentVersion,publicKey:o,listenAddrs:a.map(l=>l.bytes),signedPeerRecord:c,observedAddr:u,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)}}async _handlePush(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 fn(n,{maxDataLength:this.maxIdentifyMessageSize??Ui}).pb(rr).read(s);await n.close(s),await this.#e(t,i)}catch(s){this.log.error("received invalid message",s),n.abort(s);return}this.log("handled push from %p",t.remotePeer)}async#e(e,t){if(this.log("received identify from %p",e.remotePeer),t==null)throw new L("message was null or undefined","ERR_INVALID_MESSAGE");let n={};if(t.listenAddrs.length>0&&(n.addresses=t.listenAddrs.map(i=>({isCertified:!1,multiaddr:Ft(i)}))),t.protocols.length>0&&(n.protocols=t.protocols),t.publicKey!=null&&(n.publicKey=t.publicKey,!(await Dr(t.publicKey)).equals(e.remotePeer)))throw new L("public key did not match remote PeerId","ERR_INVALID_PUBLIC_KEY");let s;if(t.signedPeerRecord!=null){this.log("received signedPeerRecord from %p",e.remotePeer);let i=t.signedPeerRecord,a=await Mt.openAndCertify(i,Bt.DOMAIN),c=Bt.createFromProtobuf(a.payload);if(!c.peerId.equals(a.peerId))throw new L("signing key does not match PeerId in the PeerRecord","ERR_INVALID_SIGNING_KEY");if(!e.remotePeer.equals(c.peerId))throw new L("signing key does not match remote PeerId","ERR_INVALID_PEER_RECORD_KEY");let u;try{u=await this.peerStore.get(c.peerId)}catch(f){if(f.code!=="ERR_NOT_FOUND")throw f}if(u!=null&&(n.metadata=u.metadata,u.peerRecordEnvelope!=null)){let f=await Mt.createFromProtobuf(u.peerRecordEnvelope),l=Bt.createFromProtobuf(f.payload);l.seqNumber>=c.seqNumber&&(this.log("sequence number was lower or equal to existing sequence number - stored: %d received: %d",l.seqNumber,c.seqNumber),c=l,i=u.peerRecordEnvelope)}n.peerRecordEnvelope=i,n.addresses=c.multiaddrs.map(f=>({isCertified:!0,multiaddr:f})),s={seq:c.seqNumber,addresses:c.multiaddrs}}else this.log("%p did not send a signed peer record",e.remotePeer);if(this.log("patching %p with",e.remotePeer,n),await this.peerStore.patch(e.remotePeer,n),t.agentVersion!=null||t.protocolVersion!=null){let i={};t.agentVersion!=null&&(i.AgentVersion=F(t.agentVersion)),t.protocolVersion!=null&&(i.ProtocolVersion=F(t.protocolVersion)),this.log("merging %p metadata",e.remotePeer,i),await this.peerStore.merge(e.remotePeer,{metadata:i})}let o={peerId:e.remotePeer,protocolVersion:t.protocolVersion,agentVersion:t.agentVersion,publicKey:t.publicKey,listenAddrs:t.listenAddrs.map(i=>Ft(i)),observedAddr:t.observedAddr==null?void 0:Ft(t.observedAddr),protocols:t.protocols,signedPeerRecord:s,connection:e};return this.events.safeDispatchEvent("peer:identify",{detail:o}),o}};function y0(r){if(r!=null&&r.length>0)try{return Ft(r)}catch{}}var b0={IDENTIFY:$i,IDENTIFY_PUSH:Gi};function w0(r={}){return e=>new Ms(e,r)}return yu(x0);})();
8
8
  /*! Bundled license information:
9
9
 
10
10
  pvtsutils/build/index.js:
@@ -0,0 +1,12 @@
1
+ {
2
+ "Identify": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_identify.Identify.html",
3
+ ".:Identify": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_identify.Identify.html",
4
+ "IdentifyComponents": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_identify.IdentifyComponents.html",
5
+ ".:IdentifyComponents": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_identify.IdentifyComponents.html",
6
+ "IdentifyInit": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_identify.IdentifyInit.html",
7
+ ".:IdentifyInit": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_identify.IdentifyInit.html",
8
+ "multicodecs": "https://libp2p.github.io/js-libp2p/variables/_libp2p_identify.multicodecs.html",
9
+ ".:multicodecs": "https://libp2p.github.io/js-libp2p/variables/_libp2p_identify.multicodecs.html",
10
+ "identify": "https://libp2p.github.io/js-libp2p/functions/_libp2p_identify.identify-1.html",
11
+ ".:identify": "https://libp2p.github.io/js-libp2p/functions/_libp2p_identify.identify-1.html"
12
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@libp2p/identify",
3
- "version": "1.0.10-8bbd43628",
3
+ "version": "1.0.11",
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",
@@ -51,10 +51,10 @@
51
51
  "dep-check": "aegir dep-check"
52
52
  },
53
53
  "dependencies": {
54
- "@libp2p/interface": "1.1.1-8bbd43628",
55
- "@libp2p/interface-internal": "1.0.6-8bbd43628",
56
- "@libp2p/peer-id": "4.0.4-8bbd43628",
57
- "@libp2p/peer-record": "7.0.5-8bbd43628",
54
+ "@libp2p/interface": "^1.1.2",
55
+ "@libp2p/interface-internal": "^1.0.7",
56
+ "@libp2p/peer-id": "^4.0.5",
57
+ "@libp2p/peer-record": "^7.0.6",
58
58
  "@multiformats/multiaddr": "^12.1.10",
59
59
  "@multiformats/multiaddr-matcher": "^1.1.0",
60
60
  "it-protobuf-stream": "^1.1.1",
@@ -64,8 +64,8 @@
64
64
  "wherearewe": "^2.0.1"
65
65
  },
66
66
  "devDependencies": {
67
- "@libp2p/logger": "4.0.4-8bbd43628",
68
- "@libp2p/peer-id-factory": "4.0.4-8bbd43628",
67
+ "@libp2p/logger": "^4.0.5",
68
+ "@libp2p/peer-id-factory": "^4.0.5",
69
69
  "aegir": "^42.0.0",
70
70
  "delay": "^6.0.0",
71
71
  "it-drain": "^3.0.5",
@@ -75,5 +75,6 @@
75
75
  "protons": "^7.3.0",
76
76
  "sinon": "^17.0.1",
77
77
  "sinon-ts": "^2.0.0"
78
- }
78
+ },
79
+ "sideEffects": false
79
80
  }