@libp2p/mdns 11.0.38 → 11.0.39-ae595d8db
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 +2 -2
- package/dist/index.min.js.map +4 -4
- package/dist/src/mdns.d.ts +2 -1
- package/dist/src/mdns.d.ts.map +1 -1
- package/dist/src/mdns.js +2 -1
- package/dist/src/mdns.js.map +1 -1
- package/package.json +10 -9
- package/src/mdns.ts +2 -1
- package/dist/typedoc-urls.json +0 -6
package/dist/index.min.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
(function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.Libp2PMdns = factory()}(typeof self !== 'undefined' ? self : this, function () {
|
|
2
|
-
"use strict";var Libp2PMdns=(()=>{var xc=Object.create;var yr=Object.defineProperty;var bc=Object.getOwnPropertyDescriptor;var Ec=Object.getOwnPropertyNames;var Ic=Object.getPrototypeOf,Ac=Object.prototype.hasOwnProperty;var oe=(r=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(r,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):r)(function(r){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+r+'" is not supported')});var Te=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),ue=(r,e)=>{for(var t in e)yr(r,t,{get:e[t],enumerable:!0})},Zi=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Ec(e))!Ac.call(r,i)&&i!==t&&yr(r,i,{get:()=>e[i],enumerable:!(n=bc(e,i))||n.enumerable});return r};var Tt=(r,e,t)=>(t=r!=null?xc(Ic(r)):{},Zi(e||!r||!r.__esModule?yr(t,"default",{value:r,enumerable:!0}):t,r)),vc=r=>Zi(yr({},"__esModule",{value:!0}),r);var ro=Te(rn=>{"use strict";rn.toString=function(r){switch(r){case 1:return"A";case 10:return"NULL";case 28:return"AAAA";case 18:return"AFSDB";case 42:return"APL";case 257:return"CAA";case 60:return"CDNSKEY";case 59:return"CDS";case 37:return"CERT";case 5:return"CNAME";case 49:return"DHCID";case 32769:return"DLV";case 39:return"DNAME";case 48:return"DNSKEY";case 43:return"DS";case 55:return"HIP";case 13:return"HINFO";case 45:return"IPSECKEY";case 25:return"KEY";case 36:return"KX";case 29:return"LOC";case 15:return"MX";case 35:return"NAPTR";case 2:return"NS";case 47:return"NSEC";case 50:return"NSEC3";case 51:return"NSEC3PARAM";case 12:return"PTR";case 46:return"RRSIG";case 17:return"RP";case 24:return"SIG";case 6:return"SOA";case 99:return"SPF";case 33:return"SRV";case 44:return"SSHFP";case 32768:return"TA";case 249:return"TKEY";case 52:return"TLSA";case 250:return"TSIG";case 16:return"TXT";case 252:return"AXFR";case 251:return"IXFR";case 41:return"OPT";case 255:return"ANY"}return"UNKNOWN_"+r};rn.toType=function(r){switch(r.toUpperCase()){case"A":return 1;case"NULL":return 10;case"AAAA":return 28;case"AFSDB":return 18;case"APL":return 42;case"CAA":return 257;case"CDNSKEY":return 60;case"CDS":return 59;case"CERT":return 37;case"CNAME":return 5;case"DHCID":return 49;case"DLV":return 32769;case"DNAME":return 39;case"DNSKEY":return 48;case"DS":return 43;case"HIP":return 55;case"HINFO":return 13;case"IPSECKEY":return 45;case"KEY":return 25;case"KX":return 36;case"LOC":return 29;case"MX":return 15;case"NAPTR":return 35;case"NS":return 2;case"NSEC":return 47;case"NSEC3":return 50;case"NSEC3PARAM":return 51;case"PTR":return 12;case"RRSIG":return 46;case"RP":return 17;case"SIG":return 24;case"SOA":return 6;case"SPF":return 99;case"SRV":return 33;case"SSHFP":return 44;case"TA":return 32768;case"TKEY":return 249;case"TLSA":return 52;case"TSIG":return 250;case"TXT":return 16;case"AXFR":return 252;case"IXFR":return 251;case"OPT":return 41;case"ANY":return 255;case"*":return 255}return r.toUpperCase().startsWith("UNKNOWN_")?parseInt(r.slice(8)):0}});var no=Te(nn=>{"use strict";nn.toString=function(r){switch(r){case 0:return"NOERROR";case 1:return"FORMERR";case 2:return"SERVFAIL";case 3:return"NXDOMAIN";case 4:return"NOTIMP";case 5:return"REFUSED";case 6:return"YXDOMAIN";case 7:return"YXRRSET";case 8:return"NXRRSET";case 9:return"NOTAUTH";case 10:return"NOTZONE";case 11:return"RCODE_11";case 12:return"RCODE_12";case 13:return"RCODE_13";case 14:return"RCODE_14";case 15:return"RCODE_15"}return"RCODE_"+r};nn.toRcode=function(r){switch(r.toUpperCase()){case"NOERROR":return 0;case"FORMERR":return 1;case"SERVFAIL":return 2;case"NXDOMAIN":return 3;case"NOTIMP":return 4;case"REFUSED":return 5;case"YXDOMAIN":return 6;case"YXRRSET":return 7;case"NXRRSET":return 8;case"NOTAUTH":return 9;case"NOTZONE":return 10;case"RCODE_11":return 11;case"RCODE_12":return 12;case"RCODE_13":return 13;case"RCODE_14":return 14;case"RCODE_15":return 15}return 0}});var io=Te(on=>{"use strict";on.toString=function(r){switch(r){case 0:return"QUERY";case 1:return"IQUERY";case 2:return"STATUS";case 3:return"OPCODE_3";case 4:return"NOTIFY";case 5:return"UPDATE";case 6:return"OPCODE_6";case 7:return"OPCODE_7";case 8:return"OPCODE_8";case 9:return"OPCODE_9";case 10:return"OPCODE_10";case 11:return"OPCODE_11";case 12:return"OPCODE_12";case 13:return"OPCODE_13";case 14:return"OPCODE_14";case 15:return"OPCODE_15"}return"OPCODE_"+r};on.toOpcode=function(r){switch(r.toUpperCase()){case"QUERY":return 0;case"IQUERY":return 1;case"STATUS":return 2;case"OPCODE_3":return 3;case"NOTIFY":return 4;case"UPDATE":return 5;case"OPCODE_6":return 6;case"OPCODE_7":return 7;case"OPCODE_8":return 8;case"OPCODE_9":return 9;case"OPCODE_10":return 10;case"OPCODE_11":return 11;case"OPCODE_12":return 12;case"OPCODE_13":return 13;case"OPCODE_14":return 14;case"OPCODE_15":return 15}return 0}});var oo=Te(sn=>{"use strict";sn.toString=function(r){switch(r){case 1:return"IN";case 2:return"CS";case 3:return"CH";case 4:return"HS";case 255:return"ANY"}return"UNKNOWN_"+r};sn.toClass=function(r){switch(r.toUpperCase()){case"IN":return 1;case"CS":return 2;case"CH":return 3;case"HS":return 4;case"ANY":return 255}return 0}});var so=Te(cn=>{"use strict";cn.toString=function(r){switch(r){case 1:return"LLQ";case 2:return"UL";case 3:return"NSID";case 5:return"DAU";case 6:return"DHU";case 7:return"N3U";case 8:return"CLIENT_SUBNET";case 9:return"EXPIRE";case 10:return"COOKIE";case 11:return"TCP_KEEPALIVE";case 12:return"PADDING";case 13:return"CHAIN";case 14:return"KEY_TAG";case 26946:return"DEVICEID"}return r<0?null:`OPTION_${r}`};cn.toCode=function(r){if(typeof r=="number")return r;if(!r)return-1;switch(r.toUpperCase()){case"OPTION_0":return 0;case"LLQ":return 1;case"UL":return 2;case"NSID":return 3;case"OPTION_4":return 4;case"DAU":return 5;case"DHU":return 6;case"N3U":return 7;case"CLIENT_SUBNET":return 8;case"EXPIRE":return 9;case"COOKIE":return 10;case"TCP_KEEPALIVE":return 11;case"PADDING":return 12;case"CHAIN":return 13;case"KEY_TAG":return 14;case"DEVICEID":return 26946;case"OPTION_65535":return 65535}let e=r.match(/_(\d+)$/);return e?parseInt(e[1],10):-1}});var uo=Te((ao,an)=>{var co=function(r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.decode=d,r.encode=f,r.familyOf=u,r.name=void 0,r.sizeOf=c,r.v6=r.v4=void 0;let e=/^(\d{1,3}\.){3,3}\d{1,3}$/,t=4,n=/^(::)?(((\d{1,3}\.){3}(\d{1,3}){1})?([0-9a-f]){0,4}:{0,2}){1,8}(::)?$/i,i=16,o={name:"v4",size:t,isFormat:l=>e.test(l),encode(l,p,h){h=~~h,p=p||new Uint8Array(h+t);let g=l.length,U=0;for(let L=0;L<g;){let R=l.charCodeAt(L++);R===46?(p[h++]=U,U=0):U=U*10+(R-48)}return p[h]=U,p},decode(l,p){return p=~~p,`${l[p++]}.${l[p++]}.${l[p++]}.${l[p]}`}};r.v4=o;let s={name:"v6",size:i,isFormat:l=>l.length>0&&n.test(l),encode(l,p,h){h=~~h;let g=h+i,U=-1,L=0,R=0,v=!0,m=!1;p=p||new Uint8Array(h+i);for(let y=0;y<l.length;y++){let E=l.charCodeAt(y);E===58?(v?U!==-1?(h<g&&(p[h]=0),h<g-1&&(p[h+1]=0),h+=2):h<g&&(U=h):(m===!0?(h<g&&(p[h]=R),h++):(h<g&&(p[h]=L>>8),h<g-1&&(p[h+1]=L&255),h+=2),L=0,R=0),v=!0,m=!1):E===46?(h<g&&(p[h]=R),h++,R=0,L=0,v=!1,m=!0):(v=!1,E>=97?E-=87:E>=65?E-=55:(E-=48,R=R*10+E),L=(L<<4)+E)}if(v===!1)m===!0?(h<g&&(p[h]=R),h++):(h<g&&(p[h]=L>>8),h<g-1&&(p[h+1]=L&255),h+=2);else if(U===0)h<g&&(p[h]=0),h<g-1&&(p[h+1]=0),h+=2;else if(U!==-1){h+=2;for(let y=Math.min(h-1,g-1);y>=U+2;y--)p[y]=p[y-2];p[U]=0,p[U+1]=0,U=h}if(U!==h&&U!==-1)for(h>g-2&&(h=g-2);g>U;)p[--g]=h<g&&h>U?p[--h]:0;else for(;h<g;)p[h++]=0;return p},decode(l,p){p=~~p;let h="";for(let g=0;g<i;g+=2)g!==0&&(h+=":"),h+=(l[p+g]<<8|l[p+g+1]).toString(16);return h.replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}};r.v6=s;let a="ip";r.name=a;function c(l){if(o.isFormat(l))return o.size;if(s.isFormat(l))return s.size;throw Error(`Invalid ip address: ${l}`)}function u(l){return c(l)===o.size?1:2}function f(l,p,h){h=~~h;let g=c(l);return typeof p=="function"&&(p=p(h+g)),g===o.size?o.encode(l,p,h):s.encode(l,p,h)}function d(l,p,h){if(p=~~p,h=h||l.length-p,h===o.size)return o.decode(l,p,h);if(h===s.size)return s.decode(l,p,h);throw Error(`Invalid buffer size needs to be ${o.size} for v4 or ${s.size} for v6.`)}return"default"in r?r.default:r}({});typeof define=="function"&&define.amd?define([],function(){return co}):typeof an=="object"&&typeof ao=="object"&&(an.exports=co)});var po=Te(I=>{"use strict";var A=oe("buffer").Buffer,We=ro(),Sc=no(),Bc=io(),Ar=oo(),un=so(),lt=uo(),Uc=0,lo=32768,dn=32768,Lc=~dn,ho=32768,Cc=~ho,b=I.name={};b.encode=function(r,e,t,{mail:n=!1}={}){e||(e=A.alloc(b.encodingLength(r))),t||(t=0);let i=t,o=r.replace(/^\.|\.$/gm,"");if(o.length){let s=[];if(n){let a="";o.split(".").forEach(c=>{c.endsWith("\\")?a+=(a.length?".":"")+c.slice(0,-1):s.length===0&&a.length?s.push(a+"."+c):s.push(c)})}else s=o.split(".");for(let a=0;a<s.length;a++){let c=e.write(s[a],t+1);e[t]=c,t+=c+1}}return e[t++]=0,b.encode.bytes=t-i,e};b.encode.bytes=0;b.decode=function(r,e,{mail:t=!1}={}){e||(e=0);let n=[],i=e,o=0,s=0,a=!1;for(;;){if(e>=r.length)throw new Error("Cannot decode name (buffer overflow)");let c=r[e++];if(s+=a?0:1,c===0)break;if((c&192)===0){if(e+c>r.length)throw new Error("Cannot decode name (buffer overflow)");if(o+=c+1,o>254)throw new Error("Cannot decode name (name too long)");let u=r.toString("utf-8",e,e+c);t&&(u=u.replace(/\./g,"\\.")),n.push(u),e+=c,s+=a?0:c}else if((c&192)===192){if(e+1>r.length)throw new Error("Cannot decode name (buffer overflow)");let u=r.readUInt16BE(e-1)-49152;if(u>=i)throw new Error("Cannot decode name (bad pointer)");e=u,i=u,s+=a?0:1,a=!0}else throw new Error("Cannot decode name (bad label)")}return b.decode.bytes=s,n.length===0?".":n.join(".")};b.decode.bytes=0;b.encodingLength=function(r){return r==="."||r===".."?1:A.byteLength(r.replace(/^\.|\.$/gm,""))+2};var D={};D.encode=function(r,e,t){e||(e=A.alloc(D.encodingLength(r))),t||(t=0);let n=e.write(r,t+1);return e[t]=n,D.encode.bytes=n+1,e};D.encode.bytes=0;D.decode=function(r,e){e||(e=0);let t=r[e],n=r.toString("utf-8",e+1,e+1+t);return D.decode.bytes=t+1,n};D.decode.bytes=0;D.encodingLength=function(r){return A.byteLength(r)+1};var Be={};Be.encode=function(r,e,t){e||(e=Be.encodingLength(r)),t||(t=0);let n=(r.flags||0)&32767,i=r.type==="response"?lo:Uc;return e.writeUInt16BE(r.id||0,t),e.writeUInt16BE(n|i,t+2),e.writeUInt16BE(r.questions.length,t+4),e.writeUInt16BE(r.answers.length,t+6),e.writeUInt16BE(r.authorities.length,t+8),e.writeUInt16BE(r.additionals.length,t+10),e};Be.encode.bytes=12;Be.decode=function(r,e){if(e||(e=0),r.length<12)throw new Error("Header must be 12 bytes");let t=r.readUInt16BE(e+2);return{id:r.readUInt16BE(e),type:t&lo?"response":"query",flags:t&32767,flag_qr:(t>>15&1)===1,opcode:Bc.toString(t>>11&15),flag_aa:(t>>10&1)===1,flag_tc:(t>>9&1)===1,flag_rd:(t>>8&1)===1,flag_ra:(t>>7&1)===1,flag_z:(t>>6&1)===1,flag_ad:(t>>5&1)===1,flag_cd:(t>>4&1)===1,rcode:Sc.toString(t&15),questions:new Array(r.readUInt16BE(e+4)),answers:new Array(r.readUInt16BE(e+6)),authorities:new Array(r.readUInt16BE(e+8)),additionals:new Array(r.readUInt16BE(e+10))}};Be.decode.bytes=12;Be.encodingLength=function(){return 12};var Fe=I.unknown={};Fe.encode=function(r,e,t){return e||(e=A.alloc(Fe.encodingLength(r))),t||(t=0),e.writeUInt16BE(r.length,t),r.copy(e,t+2),Fe.encode.bytes=r.length+2,e};Fe.encode.bytes=0;Fe.decode=function(r,e){e||(e=0);let t=r.readUInt16BE(e),n=r.slice(e+2,e+2+t);return Fe.decode.bytes=t+2,n};Fe.decode.bytes=0;Fe.encodingLength=function(r){return r.length+2};var He=I.ns={};He.encode=function(r,e,t){return e||(e=A.alloc(He.encodingLength(r))),t||(t=0),b.encode(r,e,t+2),e.writeUInt16BE(b.encode.bytes,t),He.encode.bytes=b.encode.bytes+2,e};He.encode.bytes=0;He.decode=function(r,e){e||(e=0);let t=r.readUInt16BE(e),n=b.decode(r,e+2);return He.decode.bytes=t+2,n};He.decode.bytes=0;He.encodingLength=function(r){return b.encodingLength(r)+2};var qe=I.soa={};qe.encode=function(r,e,t){e||(e=A.alloc(qe.encodingLength(r))),t||(t=0);let n=t;return t+=2,b.encode(r.mname,e,t),t+=b.encode.bytes,b.encode(r.rname,e,t,{mail:!0}),t+=b.encode.bytes,e.writeUInt32BE(r.serial||0,t),t+=4,e.writeUInt32BE(r.refresh||0,t),t+=4,e.writeUInt32BE(r.retry||0,t),t+=4,e.writeUInt32BE(r.expire||0,t),t+=4,e.writeUInt32BE(r.minimum||0,t),t+=4,e.writeUInt16BE(t-n-2,n),qe.encode.bytes=t-n,e};qe.encode.bytes=0;qe.decode=function(r,e){e||(e=0);let t=e,n={};return e+=2,n.mname=b.decode(r,e),e+=b.decode.bytes,n.rname=b.decode(r,e,{mail:!0}),e+=b.decode.bytes,n.serial=r.readUInt32BE(e),e+=4,n.refresh=r.readUInt32BE(e),e+=4,n.retry=r.readUInt32BE(e),e+=4,n.expire=r.readUInt32BE(e),e+=4,n.minimum=r.readUInt32BE(e),e+=4,qe.decode.bytes=e-t,n};qe.decode.bytes=0;qe.encodingLength=function(r){return 22+b.encodingLength(r.mname)+b.encodingLength(r.rname)};var Ve=I.txt={};Ve.encode=function(r,e,t){Array.isArray(r)||(r=[r]);for(let i=0;i<r.length;i++)if(typeof r[i]=="string"&&(r[i]=A.from(r[i])),!A.isBuffer(r[i]))throw new Error("Must be a Buffer");e||(e=A.alloc(Ve.encodingLength(r))),t||(t=0);let n=t;return t+=2,r.forEach(function(i){e[t++]=i.length,i.copy(e,t,0,i.length),t+=i.length}),e.writeUInt16BE(t-n-2,n),Ve.encode.bytes=t-n,e};Ve.encode.bytes=0;Ve.decode=function(r,e){e||(e=0);let t=e,n=r.readUInt16BE(e);e+=2;let i=[];for(;n>0;){let o=r[e++];if(--n,n<o)throw new Error("Buffer overflow");i.push(r.slice(e,e+o)),e+=o,n-=o}return Ve.decode.bytes=e-t,i};Ve.decode.bytes=0;Ve.encodingLength=function(r){Array.isArray(r)||(r=[r]);let e=2;return r.forEach(function(t){typeof t=="string"?e+=A.byteLength(t)+1:e+=t.length+1}),e};var ze=I.null={};ze.encode=function(r,e,t){e||(e=A.alloc(ze.encodingLength(r))),t||(t=0),typeof r=="string"&&(r=A.from(r)),r||(r=A.alloc(0));let n=t;t+=2;let i=r.length;return r.copy(e,t,0,i),t+=i,e.writeUInt16BE(t-n-2,n),ze.encode.bytes=t-n,e};ze.encode.bytes=0;ze.decode=function(r,e){e||(e=0);let t=e,n=r.readUInt16BE(e);e+=2;let i=r.slice(e,e+n);return e+=n,ze.decode.bytes=e-t,i};ze.decode.bytes=0;ze.encodingLength=function(r){return r?(A.isBuffer(r)?r.length:A.byteLength(r))+2:2};var je=I.hinfo={};je.encode=function(r,e,t){e||(e=A.alloc(je.encodingLength(r))),t||(t=0);let n=t;return t+=2,D.encode(r.cpu,e,t),t+=D.encode.bytes,D.encode(r.os,e,t),t+=D.encode.bytes,e.writeUInt16BE(t-n-2,n),je.encode.bytes=t-n,e};je.encode.bytes=0;je.decode=function(r,e){e||(e=0);let t=e,n={};return e+=2,n.cpu=D.decode(r,e),e+=D.decode.bytes,n.os=D.decode(r,e),e+=D.decode.bytes,je.decode.bytes=e-t,n};je.decode.bytes=0;je.encodingLength=function(r){return D.encodingLength(r.cpu)+D.encodingLength(r.os)+2};var ve=I.ptr={},Tc=I.cname=ve,Pc=I.dname=ve;ve.encode=function(r,e,t){return e||(e=A.alloc(ve.encodingLength(r))),t||(t=0),b.encode(r,e,t+2),e.writeUInt16BE(b.encode.bytes,t),ve.encode.bytes=b.encode.bytes+2,e};ve.encode.bytes=0;ve.decode=function(r,e){e||(e=0);let t=b.decode(r,e+2);return ve.decode.bytes=b.decode.bytes+2,t};ve.decode.bytes=0;ve.encodingLength=function(r){return b.encodingLength(r)+2};var Ge=I.srv={};Ge.encode=function(r,e,t){e||(e=A.alloc(Ge.encodingLength(r))),t||(t=0),e.writeUInt16BE(r.priority||0,t+2),e.writeUInt16BE(r.weight||0,t+4),e.writeUInt16BE(r.port||0,t+6),b.encode(r.target,e,t+8);let n=b.encode.bytes+6;return e.writeUInt16BE(n,t),Ge.encode.bytes=n+2,e};Ge.encode.bytes=0;Ge.decode=function(r,e){e||(e=0);let t=r.readUInt16BE(e),n={};return n.priority=r.readUInt16BE(e+2),n.weight=r.readUInt16BE(e+4),n.port=r.readUInt16BE(e+6),n.target=b.decode(r,e+8),Ge.decode.bytes=t+2,n};Ge.decode.bytes=0;Ge.encodingLength=function(r){return 8+b.encodingLength(r.target)};var de=I.caa={};de.ISSUER_CRITICAL=128;de.encode=function(r,e,t){let n=de.encodingLength(r);return e||(e=A.alloc(de.encodingLength(r))),t||(t=0),r.issuerCritical&&(r.flags=de.ISSUER_CRITICAL),e.writeUInt16BE(n-2,t),t+=2,e.writeUInt8(r.flags||0,t),t+=1,D.encode(r.tag,e,t),t+=D.encode.bytes,e.write(r.value,t),t+=A.byteLength(r.value),de.encode.bytes=n,e};de.encode.bytes=0;de.decode=function(r,e){e||(e=0);let t=r.readUInt16BE(e);e+=2;let n=e,i={};return i.flags=r.readUInt8(e),e+=1,i.tag=D.decode(r,e),e+=D.decode.bytes,i.value=r.toString("utf-8",e,n+t),i.issuerCritical=!!(i.flags&de.ISSUER_CRITICAL),de.decode.bytes=t+2,i};de.decode.bytes=0;de.encodingLength=function(r){return D.encodingLength(r.tag)+D.encodingLength(r.value)+2};var ot=I.mx={};ot.encode=function(r,e,t){e||(e=A.alloc(ot.encodingLength(r))),t||(t=0);let n=t;return t+=2,e.writeUInt16BE(r.preference||0,t),t+=2,b.encode(r.exchange,e,t),t+=b.encode.bytes,e.writeUInt16BE(t-n-2,n),ot.encode.bytes=t-n,e};ot.encode.bytes=0;ot.decode=function(r,e){e||(e=0);let t=e,n={};return e+=2,n.preference=r.readUInt16BE(e),e+=2,n.exchange=b.decode(r,e),e+=b.decode.bytes,ot.decode.bytes=e-t,n};ot.encodingLength=function(r){return 4+b.encodingLength(r.exchange)};var $e=I.a={};$e.encode=function(r,e,t){return e||(e=A.alloc($e.encodingLength(r))),t||(t=0),e.writeUInt16BE(4,t),t+=2,lt.v4.encode(r,e,t),$e.encode.bytes=6,e};$e.encode.bytes=0;$e.decode=function(r,e){e||(e=0),e+=2;let t=lt.v4.decode(r,e);return $e.decode.bytes=6,t};$e.decode.bytes=0;$e.encodingLength=function(){return 6};var Ye=I.aaaa={};Ye.encode=function(r,e,t){return e||(e=A.alloc(Ye.encodingLength(r))),t||(t=0),e.writeUInt16BE(16,t),t+=2,lt.v6.encode(r,e,t),Ye.encode.bytes=18,e};Ye.encode.bytes=0;Ye.decode=function(r,e){e||(e=0),e+=2;let t=lt.v6.decode(r,e);return Ye.decode.bytes=18,t};Ye.decode.bytes=0;Ye.encodingLength=function(){return 18};var se=I.option={};se.encode=function(r,e,t){e||(e=A.alloc(se.encodingLength(r))),t||(t=0);let n=t,i=un.toCode(r.code);if(e.writeUInt16BE(i,t),t+=2,r.data)e.writeUInt16BE(r.data.length,t),t+=2,r.data.copy(e,t),t+=r.data.length;else switch(i){case 8:let o=r.sourcePrefixLength||0,s=r.family||lt.familyOf(r.ip),a=lt.encode(r.ip,A.alloc),c=Math.ceil(o/8);e.writeUInt16BE(c+4,t),t+=2,e.writeUInt16BE(s,t),t+=2,e.writeUInt8(o,t++),e.writeUInt8(r.scopePrefixLength||0,t++),a.copy(e,t,0,c),t+=c;break;case 11:r.timeout?(e.writeUInt16BE(2,t),t+=2,e.writeUInt16BE(r.timeout,t),t+=2):(e.writeUInt16BE(0,t),t+=2);break;case 12:let u=r.length||0;e.writeUInt16BE(u,t),t+=2,e.fill(0,t,t+u),t+=u;break;case 14:let f=r.tags.length*2;e.writeUInt16BE(f,t),t+=2;for(let d of r.tags)e.writeUInt16BE(d,t),t+=2;break;default:throw new Error(`Unknown roption code: ${r.code}`)}return se.encode.bytes=t-n,e};se.encode.bytes=0;se.decode=function(r,e){e||(e=0);let t={};t.code=r.readUInt16BE(e),t.type=un.toString(t.code),e+=2;let n=r.readUInt16BE(e);switch(e+=2,t.data=r.slice(e,e+n),t.code){case 8:t.family=r.readUInt16BE(e),e+=2,t.sourcePrefixLength=r.readUInt8(e++),t.scopePrefixLength=r.readUInt8(e++);let i=A.alloc(t.family===1?4:16);r.copy(i,0,e,e+n-4),t.ip=lt.decode(i);break;case 11:n>0&&(t.timeout=r.readUInt16BE(e),e+=2);break;case 14:t.tags=[];for(let o=0;o<n;o+=2)t.tags.push(r.readUInt16BE(e)),e+=2}return se.decode.bytes=n+4,t};se.decode.bytes=0;se.encodingLength=function(r){if(r.data)return r.data.length+4;switch(un.toCode(r.code)){case 8:let t=r.sourcePrefixLength||0;return Math.ceil(t/8)+8;case 11:return typeof r.timeout=="number"?6:4;case 12:return r.length+4;case 14:return 4+r.tags.length*2}throw new Error(`Unknown roption code: ${r.code}`)};var he=I.opt={};he.encode=function(r,e,t){e||(e=A.alloc(he.encodingLength(r))),t||(t=0);let n=t,i=Pt(r,se);return e.writeUInt16BE(i,t),t=Wt(r,se,e,t+2),he.encode.bytes=t-n,e};he.encode.bytes=0;he.decode=function(r,e){e||(e=0);let t=e,n=[],i=r.readUInt16BE(e);e+=2;let o=0;for(;i>0;)n[o++]=se.decode(r,e),e+=se.decode.bytes,i-=se.decode.bytes;return he.decode.bytes=e-t,n};he.decode.bytes=0;he.encodingLength=function(r){return 2+Pt(r||[],se)};var re=I.dnskey={};re.PROTOCOL_DNSSEC=3;re.ZONE_KEY=128;re.SECURE_ENTRYPOINT=32768;re.encode=function(r,e,t){e||(e=A.alloc(re.encodingLength(r))),t||(t=0);let n=t,i=r.key;if(!A.isBuffer(i))throw new Error("Key must be a Buffer");return t+=2,e.writeUInt16BE(r.flags,t),t+=2,e.writeUInt8(re.PROTOCOL_DNSSEC,t),t+=1,e.writeUInt8(r.algorithm,t),t+=1,i.copy(e,t,0,i.length),t+=i.length,re.encode.bytes=t-n,e.writeUInt16BE(re.encode.bytes-2,n),e};re.encode.bytes=0;re.decode=function(r,e){e||(e=0);let t=e;var n={},i=r.readUInt16BE(e);if(e+=2,n.flags=r.readUInt16BE(e),e+=2,r.readUInt8(e)!==re.PROTOCOL_DNSSEC)throw new Error("Protocol must be 3");return e+=1,n.algorithm=r.readUInt8(e),e+=1,n.key=r.slice(e,t+i+2),e+=n.key.length,re.decode.bytes=e-t,n};re.decode.bytes=0;re.encodingLength=function(r){return 6+A.byteLength(r.key)};var Oe=I.rrsig={};Oe.encode=function(r,e,t){e||(e=A.alloc(Oe.encodingLength(r))),t||(t=0);let n=t,i=r.signature;if(!A.isBuffer(i))throw new Error("Signature must be a Buffer");return t+=2,e.writeUInt16BE(We.toType(r.typeCovered),t),t+=2,e.writeUInt8(r.algorithm,t),t+=1,e.writeUInt8(r.labels,t),t+=1,e.writeUInt32BE(r.originalTTL,t),t+=4,e.writeUInt32BE(r.expiration,t),t+=4,e.writeUInt32BE(r.inception,t),t+=4,e.writeUInt16BE(r.keyTag,t),t+=2,b.encode(r.signersName,e,t),t+=b.encode.bytes,i.copy(e,t,0,i.length),t+=i.length,Oe.encode.bytes=t-n,e.writeUInt16BE(Oe.encode.bytes-2,n),e};Oe.encode.bytes=0;Oe.decode=function(r,e){e||(e=0);let t=e;var n={},i=r.readUInt16BE(e);return e+=2,n.typeCovered=We.toString(r.readUInt16BE(e)),e+=2,n.algorithm=r.readUInt8(e),e+=1,n.labels=r.readUInt8(e),e+=1,n.originalTTL=r.readUInt32BE(e),e+=4,n.expiration=r.readUInt32BE(e),e+=4,n.inception=r.readUInt32BE(e),e+=4,n.keyTag=r.readUInt16BE(e),e+=2,n.signersName=b.decode(r,e),e+=b.decode.bytes,n.signature=r.slice(e,t+i+2),e+=n.signature.length,Oe.decode.bytes=e-t,n};Oe.decode.bytes=0;Oe.encodingLength=function(r){return 20+b.encodingLength(r.signersName)+A.byteLength(r.signature)};var De=I.rp={};De.encode=function(r,e,t){e||(e=A.alloc(De.encodingLength(r))),t||(t=0);let n=t;return t+=2,b.encode(r.mbox||".",e,t,{mail:!0}),t+=b.encode.bytes,b.encode(r.txt||".",e,t),t+=b.encode.bytes,De.encode.bytes=t-n,e.writeUInt16BE(De.encode.bytes-2,n),e};De.encode.bytes=0;De.decode=function(r,e){e||(e=0);let t=e,n={};return e+=2,n.mbox=b.decode(r,e,{mail:!0})||".",e+=b.decode.bytes,n.txt=b.decode(r,e)||".",e+=b.decode.bytes,De.decode.bytes=e-t,n};De.decode.bytes=0;De.encodingLength=function(r){return 2+b.encodingLength(r.mbox||".")+b.encodingLength(r.txt||".")};var $={};$.encode=function(r,e,t){e||(e=A.alloc($.encodingLength(r))),t||(t=0);let n=t;for(var i=[],o=0;o<r.length;o++){var s=We.toType(r[o]);i[s>>8]===void 0&&(i[s>>8]=[]),i[s>>8][s>>3&31]|=1<<7-(s&7)}for(o=0;o<i.length;o++)if(i[o]!==void 0){var a=A.from(i[o]);e.writeUInt8(o,t),t+=1,e.writeUInt8(a.length,t),t+=1,a.copy(e,t),t+=a.length}return $.encode.bytes=t-n,e};$.encode.bytes=0;$.decode=function(r,e,t){e||(e=0);let n=e;for(var i=[];e-n<t;){var o=r.readUInt8(e);e+=1;var s=r.readUInt8(e);e+=1;for(var a=0;a<s;a++)for(var c=r.readUInt8(e+a),u=0;u<8;u++)if(c&1<<7-u){var f=We.toString(o<<8|a<<3|u);i.push(f)}e+=s}return $.decode.bytes=e-n,i};$.decode.bytes=0;$.encodingLength=function(r){for(var e=[],t=0;t<r.length;t++){var n=We.toType(r[t]);e[n>>8]=Math.max(e[n>>8]||0,n&255)}var i=0;for(t=0;t<e.length;t++)e[t]!==void 0&&(i+=2+Math.ceil((e[t]+1)/8));return i};var Ne=I.nsec={};Ne.encode=function(r,e,t){e||(e=A.alloc(Ne.encodingLength(r))),t||(t=0);let n=t;return t+=2,b.encode(r.nextDomain,e,t),t+=b.encode.bytes,$.encode(r.rrtypes,e,t),t+=$.encode.bytes,Ne.encode.bytes=t-n,e.writeUInt16BE(Ne.encode.bytes-2,n),e};Ne.encode.bytes=0;Ne.decode=function(r,e){e||(e=0);let t=e;var n={},i=r.readUInt16BE(e);return e+=2,n.nextDomain=b.decode(r,e),e+=b.decode.bytes,n.rrtypes=$.decode(r,e,i-(e-t)),e+=$.decode.bytes,Ne.decode.bytes=e-t,n};Ne.decode.bytes=0;Ne.encodingLength=function(r){return 2+b.encodingLength(r.nextDomain)+$.encodingLength(r.rrtypes)};var _e=I.nsec3={};_e.encode=function(r,e,t){e||(e=A.alloc(_e.encodingLength(r))),t||(t=0);let n=t,i=r.salt;if(!A.isBuffer(i))throw new Error("salt must be a Buffer");let o=r.nextDomain;if(!A.isBuffer(o))throw new Error("nextDomain must be a Buffer");return t+=2,e.writeUInt8(r.algorithm,t),t+=1,e.writeUInt8(r.flags,t),t+=1,e.writeUInt16BE(r.iterations,t),t+=2,e.writeUInt8(i.length,t),t+=1,i.copy(e,t,0,i.length),t+=i.length,e.writeUInt8(o.length,t),t+=1,o.copy(e,t,0,o.length),t+=o.length,$.encode(r.rrtypes,e,t),t+=$.encode.bytes,_e.encode.bytes=t-n,e.writeUInt16BE(_e.encode.bytes-2,n),e};_e.encode.bytes=0;_e.decode=function(r,e){e||(e=0);let t=e;var n={},i=r.readUInt16BE(e);e+=2,n.algorithm=r.readUInt8(e),e+=1,n.flags=r.readUInt8(e),e+=1,n.iterations=r.readUInt16BE(e),e+=2;let o=r.readUInt8(e);e+=1,n.salt=r.slice(e,e+o),e+=o;let s=r.readUInt8(e);return e+=1,n.nextDomain=r.slice(e,e+s),e+=s,n.rrtypes=$.decode(r,e,i-(e-t)),e+=$.decode.bytes,_e.decode.bytes=e-t,n};_e.decode.bytes=0;_e.encodingLength=function(r){return 8+r.salt.length+r.nextDomain.length+$.encodingLength(r.rrtypes)};var ke=I.ds={};ke.encode=function(r,e,t){e||(e=A.alloc(ke.encodingLength(r))),t||(t=0);let n=t,i=r.digest;if(!A.isBuffer(i))throw new Error("Digest must be a Buffer");return t+=2,e.writeUInt16BE(r.keyTag,t),t+=2,e.writeUInt8(r.algorithm,t),t+=1,e.writeUInt8(r.digestType,t),t+=1,i.copy(e,t,0,i.length),t+=i.length,ke.encode.bytes=t-n,e.writeUInt16BE(ke.encode.bytes-2,n),e};ke.encode.bytes=0;ke.decode=function(r,e){e||(e=0);let t=e;var n={},i=r.readUInt16BE(e);return e+=2,n.keyTag=r.readUInt16BE(e),e+=2,n.algorithm=r.readUInt8(e),e+=1,n.digestType=r.readUInt8(e),e+=1,n.digest=r.slice(e,t+i+2),e+=n.digest.length,ke.decode.bytes=e-t,n};ke.decode.bytes=0;ke.encodingLength=function(r){return 6+A.byteLength(r.digest)};var le=I.sshfp={};le.getFingerprintLengthForHashType=function(e){switch(e){case 1:return 20;case 2:return 32}};le.encode=function(e,t,n){t||(t=A.alloc(le.encodingLength(e))),n||(n=0);let i=n;n+=2,t[n]=e.algorithm,n+=1,t[n]=e.hash,n+=1;let o=A.from(e.fingerprint.toUpperCase(),"hex");if(o.length!==le.getFingerprintLengthForHashType(e.hash))throw new Error("Invalid fingerprint length");return o.copy(t,n),n+=o.byteLength,le.encode.bytes=n-i,t.writeUInt16BE(le.encode.bytes-2,i),t};le.encode.bytes=0;le.decode=function(e,t){t||(t=0);let n=t,i={};t+=2,i.algorithm=e[t],t+=1,i.hash=e[t],t+=1;let o=le.getFingerprintLengthForHashType(i.hash);return i.fingerprint=e.slice(t,t+o).toString("hex").toUpperCase(),t+=o,le.decode.bytes=t-n,i};le.decode.bytes=0;le.encodingLength=function(r){return 4+A.from(r.fingerprint,"hex").byteLength};var Re=I.naptr={};Re.encode=function(r,e,t){e||(e=A.alloc(Re.encodingLength(r))),t||(t=0);let n=t;return t+=2,e.writeUInt16BE(r.order||0,t),t+=2,e.writeUInt16BE(r.preference||0,t),t+=2,D.encode(r.flags,e,t),t+=D.encode.bytes,D.encode(r.services,e,t),t+=D.encode.bytes,D.encode(r.regexp,e,t),t+=D.encode.bytes,b.encode(r.replacement,e,t),t+=b.encode.bytes,Re.encode.bytes=t-n,e.writeUInt16BE(Re.encode.bytes-2,n),e};Re.encode.bytes=0;Re.decode=function(r,e){e||(e=0);let t=e,n={};return e+=2,n.order=r.readUInt16BE(e),e+=2,n.preference=r.readUInt16BE(e),e+=2,n.flags=D.decode(r,e),e+=D.decode.bytes,n.services=D.decode(r,e),e+=D.decode.bytes,n.regexp=D.decode(r,e),e+=D.decode.bytes,n.replacement=b.decode(r,e),e+=b.decode.bytes,Re.decode.bytes=e-t,n};Re.decode.bytes=0;Re.encodingLength=function(r){return D.encodingLength(r.flags)+D.encodingLength(r.services)+D.encodingLength(r.regexp)+b.encodingLength(r.replacement)+6};var Ke=I.tlsa={};Ke.encode=function(r,e,t){e||(e=A.alloc(Ke.encodingLength(r))),t||(t=0);let n=t,i=r.certificate;if(!A.isBuffer(i))throw new Error("Certificate must be a Buffer");return t+=2,e.writeUInt8(r.usage,t),t+=1,e.writeUInt8(r.selector,t),t+=1,e.writeUInt8(r.matchingType,t),t+=1,i.copy(e,t,0,i.length),t+=i.length,Ke.encode.bytes=t-n,e.writeUInt16BE(Ke.encode.bytes-2,n),e};Ke.encode.bytes=0;Ke.decode=function(r,e){e||(e=0);let t=e,n={},i=r.readUInt16BE(e);return e+=2,n.usage=r.readUInt8(e),e+=1,n.selector=r.readUInt8(e),e+=1,n.matchingType=r.readUInt8(e),e+=1,n.certificate=r.slice(e,t+i+2),e+=n.certificate.length,Ke.decode.bytes=e-t,n};Ke.decode.bytes=0;Ke.encodingLength=function(r){return 5+A.byteLength(r.certificate)};var ln=I.record=function(r){switch(r.toUpperCase()){case"A":return $e;case"PTR":return ve;case"CNAME":return Tc;case"DNAME":return Pc;case"TXT":return Ve;case"NULL":return ze;case"AAAA":return Ye;case"SRV":return Ge;case"HINFO":return je;case"CAA":return de;case"NS":return He;case"SOA":return qe;case"MX":return ot;case"OPT":return he;case"DNSKEY":return re;case"RRSIG":return Oe;case"RP":return De;case"NSEC":return Ne;case"NSEC3":return _e;case"SSHFP":return le;case"DS":return ke;case"NAPTR":return Re;case"TLSA":return Ke}return Fe},W=I.answer={};W.encode=function(r,e,t){e||(e=A.alloc(W.encodingLength(r))),t||(t=0);let n=t;if(b.encode(r.name,e,t),t+=b.encode.bytes,e.writeUInt16BE(We.toType(r.type),t),r.type.toUpperCase()==="OPT"){if(r.name!==".")throw new Error("OPT name must be root.");e.writeUInt16BE(r.udpPayloadSize||4096,t+2),e.writeUInt8(r.extendedRcode||0,t+4),e.writeUInt8(r.ednsVersion||0,t+5),e.writeUInt16BE(r.flags||0,t+6),t+=8,he.encode(r.options||[],e,t),t+=he.encode.bytes}else{let i=Ar.toClass(r.class===void 0?"IN":r.class);r.flush&&(i|=dn),e.writeUInt16BE(i,t+2),e.writeUInt32BE(r.ttl||0,t+4),t+=8;let o=ln(r.type);o.encode(r.data,e,t),t+=o.encode.bytes}return W.encode.bytes=t-n,e};W.encode.bytes=0;W.decode=function(r,e){e||(e=0);let t={},n=e;if(t.name=b.decode(r,e),e+=b.decode.bytes,t.type=We.toString(r.readUInt16BE(e)),t.type==="OPT")t.udpPayloadSize=r.readUInt16BE(e+2),t.extendedRcode=r.readUInt8(e+4),t.ednsVersion=r.readUInt8(e+5),t.flags=r.readUInt16BE(e+6),t.flag_do=(t.flags>>15&1)===1,t.options=he.decode(r,e+8),e+=8+he.decode.bytes;else{let i=r.readUInt16BE(e+2);t.ttl=r.readUInt32BE(e+4),t.class=Ar.toString(i&Lc),t.flush=!!(i&dn);let o=ln(t.type);t.data=o.decode(r,e+8),e+=8+o.decode.bytes}return W.decode.bytes=e-n,t};W.decode.bytes=0;W.encodingLength=function(r){let e=r.data!==null&&r.data!==void 0?r.data:r.options;return b.encodingLength(r.name)+8+ln(r.type).encodingLength(e)};var Se=I.question={};Se.encode=function(r,e,t){e||(e=A.alloc(Se.encodingLength(r))),t||(t=0);let n=t;return b.encode(r.name,e,t),t+=b.encode.bytes,e.writeUInt16BE(We.toType(r.type),t),t+=2,e.writeUInt16BE(Ar.toClass(r.class===void 0?"IN":r.class),t),t+=2,Se.encode.bytes=t-n,r};Se.encode.bytes=0;Se.decode=function(r,e){e||(e=0);let t=e,n={};return n.name=b.decode(r,e),e+=b.decode.bytes,n.type=We.toString(r.readUInt16BE(e)),e+=2,n.class=Ar.toString(r.readUInt16BE(e)),e+=2,!!(n.class&ho)&&(n.class&=Cc),Se.decode.bytes=e-t,n};Se.decode.bytes=0;Se.encodingLength=function(r){return b.encodingLength(r.name)+4};I.AUTHORITATIVE_ANSWER=1024;I.TRUNCATED_RESPONSE=512;I.RECURSION_DESIRED=256;I.RECURSION_AVAILABLE=128;I.AUTHENTIC_DATA=32;I.CHECKING_DISABLED=16;I.DNSSEC_OK=32768;I.encode=function(r,e,t){let n=!e;n&&(e=A.alloc(I.encodingLength(r))),t||(t=0);let i=t;return r.questions||(r.questions=[]),r.answers||(r.answers=[]),r.authorities||(r.authorities=[]),r.additionals||(r.additionals=[]),Be.encode(r,e,t),t+=Be.encode.bytes,t=Wt(r.questions,Se,e,t),t=Wt(r.answers,W,e,t),t=Wt(r.authorities,W,e,t),t=Wt(r.additionals,W,e,t),I.encode.bytes=t-i,n&&I.encode.bytes!==e.length?e.slice(0,I.encode.bytes):e};I.encode.bytes=0;I.decode=function(r,e){e||(e=0);let t=e,n=Be.decode(r,e);return e+=Be.decode.bytes,e=Ir(n.questions,Se,r,e),e=Ir(n.answers,W,r,e),e=Ir(n.authorities,W,r,e),e=Ir(n.additionals,W,r,e),I.decode.bytes=e-t,n};I.decode.bytes=0;I.encodingLength=function(r){return Be.encodingLength(r)+Pt(r.questions||[],Se)+Pt(r.answers||[],W)+Pt(r.authorities||[],W)+Pt(r.additionals||[],W)};I.streamEncode=function(r){let e=I.encode(r),t=A.alloc(2);t.writeUInt16BE(e.byteLength);let n=A.concat([t,e]);return I.streamEncode.bytes=n.byteLength,n};I.streamEncode.bytes=0;I.streamDecode=function(r){let e=r.readUInt16BE(0);if(r.byteLength<e+2)return null;let t=I.decode(r.slice(2));return I.streamDecode.bytes=I.decode.bytes,t};I.streamDecode.bytes=0;function Pt(r,e){let t=0;for(let n=0;n<r.length;n++)t+=e.encodingLength(r[n]);return t}function Wt(r,e,t,n){for(let i=0;i<r.length;i++)e.encode(r[i],t,n),n+=e.encode.bytes;return n}function Ir(r,e,t,n){for(let i=0;i<r.length;i++)r[i]=e.decode(t,n),n+=e.decode.bytes;return n}});var mo=Te((pl,go)=>{"use strict";var fo=Rc;process.nextTick(kc,42);go.exports=Oc;function Oc(r){var e=n;return t;function t(i){e(i||Nc)}function n(i){var o=[i];e=s,r(a);function s(c){o.push(c)}function a(c){var u=arguments;for(e=Dc(c)?n:f;o.length;)f(o.shift());function f(d){fo(_c,d,u)}}}}function Dc(r){return Object.prototype.toString.call(r)==="[object Error]"}function Nc(){}function _c(r,e){r.apply(null,e)}function kc(r){r===42&&(fo=process.nextTick)}function Rc(r,e,t){process.nextTick(function(){r(e,t)})}});var xo=Te((fl,wo)=>{var hn=po(),Kc=oe("dgram"),Mc=mo(),Fc=oe("events"),fn=oe("os"),pn=function(){};wo.exports=function(r){r||(r={});var e=new Fc.EventEmitter,t=typeof r.port=="number"?r.port:5353,n=r.type||"udp4",i=r.ip||r.host||(n==="udp4"?"224.0.0.251":null),o={address:i,port:t},s={},a=!1,c=null;if(n==="udp6"&&(!i||!r.interface))throw new Error("For IPv6 multicast you must specify `ip` and `interface`");var u=r.socket||Kc.createSocket({type:n,reuseAddr:r.reuseAddr!==!1,toString:function(){return n}});u.on("error",function(d){d.code==="EACCES"||d.code==="EADDRINUSE"?e.emit("error",d):e.emit("warning",d)}),u.on("message",function(d,l){try{d=hn.decode(d)}catch(p){e.emit("warning",p);return}e.emit("packet",d,l),d.type==="query"&&e.emit("query",d,l),d.type==="response"&&e.emit("response",d,l)}),u.on("listening",function(){t||(t=o.port=u.address().port),r.multicast!==!1&&(e.update(),c=setInterval(e.update,5e3),u.setMulticastTTL(r.ttl||255),u.setMulticastLoopback(r.loopback!==!1))});var f=Mc(function(d){if(!t||r.bind===!1)return d(null);u.once("error",d),u.bind(t,r.bind||r.interface,function(){u.removeListener("error",d),d(null)})});return f(function(d){if(d)return e.emit("error",d);e.emit("ready")}),e.send=function(d,l,p){if(typeof l=="function")return e.send(d,null,l);p||(p=pn),l?!l.host&&!l.address&&(l.address=o.address):l=o,f(h);function h(g){if(a)return p();if(g)return p(g);var U=hn.encode(d);u.send(U,0,U.length,l.port,l.address||l.host,p)}},e.response=e.respond=function(d,l,p){Array.isArray(d)&&(d={answers:d}),d.type="response",d.flags=(d.flags||0)|hn.AUTHORITATIVE_ANSWER,e.send(d,l,p)},e.query=function(d,l,p,h){if(typeof l=="function")return e.query(d,null,null,l);if(typeof l=="object"&&l&&l.port)return e.query(d,null,l,p);if(typeof p=="function")return e.query(d,l,null,p);h||(h=pn),typeof d=="string"&&(d=[{name:d,type:l||"ANY"}]),Array.isArray(d)&&(d={type:"query",questions:d}),d.type="query",e.send(d,p,h)},e.destroy=function(d){if(d||(d=pn),a)return process.nextTick(d);a=!0,clearInterval(c);for(var l in s)try{u.dropMembership(i,l)}catch{}s={},u.close(d)},e.update=function(){for(var d=r.interface?[].concat(r.interface):qc(),l=!1,p=0;p<d.length;p++){var h=d[p];if(!s[h])try{u.addMembership(i,h),s[h]=!0,l=!0}catch(g){e.emit("warning",g)}}if(l){if(u.setMulticastInterface)try{u.setMulticastInterface(r.interface||Hc())}catch(g){e.emit("warning",g)}e.emit("networkInterface")}},e};function Hc(){for(var r=fn.networkInterfaces(),e=Object.keys(r),t=0;t<e.length;t++)for(var n=r[e[t]],i=0;i<n.length;i++){var o=n[i];if(yo(o.family)&&!o.internal)return fn.platform()==="darwin"&&e[t]==="en0"?o.address:"0.0.0.0"}return"127.0.0.1"}function qc(){for(var r=fn.networkInterfaces(),e=Object.keys(r),t=[],n=0;n<e.length;n++)for(var i=r[e[n]],o=0;o<i.length;o++){var s=i[o];if(yo(s.family)){t.push(s.address);break}}return t}function yo(r){return r===4||r==="IPv4"}});var Qs=Te(gr=>{(function(){var r,e,t,n,i,o,s,a;a=function(c){var u,f,d,l;return u=(c&255<<24)>>>24,f=(c&255<<16)>>>16,d=(c&65280)>>>8,l=c&255,[u,f,d,l].join(".")},s=function(c){var u,f,d,l,p,h;for(u=[],d=l=0;l<=3&&c.length!==0;d=++l){if(d>0){if(c[0]!==".")throw new Error("Invalid IP");c=c.substring(1)}h=e(c),p=h[0],f=h[1],c=c.substring(f),u.push(p)}if(c.length!==0)throw new Error("Invalid IP");switch(u.length){case 1:if(u[0]>4294967295)throw new Error("Invalid IP");return u[0]>>>0;case 2:if(u[0]>255||u[1]>16777215)throw new Error("Invalid IP");return(u[0]<<24|u[1])>>>0;case 3:if(u[0]>255||u[1]>255||u[2]>65535)throw new Error("Invalid IP");return(u[0]<<24|u[1]<<16|u[2])>>>0;case 4:if(u[0]>255||u[1]>255||u[2]>255||u[3]>255)throw new Error("Invalid IP");return(u[0]<<24|u[1]<<16|u[2]<<8|u[3])>>>0;default:throw new Error("Invalid IP")}},t=function(c){return c.charCodeAt(0)},n=t("0"),o=t("a"),i=t("A"),e=function(c){var u,f,d,l,p;for(l=0,u=10,f="9",d=0,c.length>1&&c[d]==="0"&&(c[d+1]==="x"||c[d+1]==="X"?(d+=2,u=16):"0"<=c[d+1]&&c[d+1]<="9"&&(d++,u=8,f="7")),p=d;d<c.length;){if("0"<=c[d]&&c[d]<=f)l=l*u+(t(c[d])-n)>>>0;else if(u===16)if("a"<=c[d]&&c[d]<="f")l=l*u+(10+t(c[d])-o)>>>0;else if("A"<=c[d]&&c[d]<="F")l=l*u+(10+t(c[d])-i)>>>0;else break;else break;if(l>4294967295)throw new Error("too large");d++}if(d===p)throw new Error("empty octet");return[l,d]},r=function(){function c(u,f){var d,l,p,h;if(typeof u!="string")throw new Error("Missing `net' parameter");if(f||(h=u.split("/",2),u=h[0],f=h[1]),f||(f=32),typeof f=="string"&&f.indexOf(".")>-1){try{this.maskLong=s(f)}catch(g){throw d=g,new Error("Invalid mask: "+f)}for(l=p=32;p>=0;l=--p)if(this.maskLong===4294967295<<32-l>>>0){this.bitmask=l;break}}else if(f||f===0)this.bitmask=parseInt(f,10),this.maskLong=0,this.bitmask>0&&(this.maskLong=4294967295<<32-this.bitmask>>>0);else throw new Error("Invalid mask: empty");try{this.netLong=(s(u)&this.maskLong)>>>0}catch(g){throw d=g,new Error("Invalid net address: "+u)}if(!(this.bitmask<=32))throw new Error("Invalid mask for ip4: "+f);this.size=Math.pow(2,32-this.bitmask),this.base=a(this.netLong),this.mask=a(this.maskLong),this.hostmask=a(~this.maskLong),this.first=this.bitmask<=30?a(this.netLong+1):this.base,this.last=this.bitmask<=30?a(this.netLong+this.size-2):a(this.netLong+this.size-1),this.broadcast=this.bitmask<=30?a(this.netLong+this.size-1):void 0}return c.prototype.contains=function(u){return typeof u=="string"&&(u.indexOf("/")>0||u.split(".").length!==4)&&(u=new c(u)),u instanceof c?this.contains(u.base)&&this.contains(u.broadcast||u.last):(s(u)&this.maskLong)>>>0===(this.netLong&this.maskLong)>>>0},c.prototype.next=function(u){return u==null&&(u=1),new c(a(this.netLong+this.size*u),this.mask)},c.prototype.forEach=function(u){var f,d,l;for(l=s(this.first),d=s(this.last),f=0;l<=d;)u(a(l),l,f),f++,l++},c.prototype.toString=function(){return this.base+"/"+this.bitmask},c}(),gr.ip2long=s,gr.long2ip=a,gr.Netmask=r}).call(gr)});var Td={};ue(Td,{mdns:()=>Cd});var Qi=Symbol.for("@libp2p/peer-discovery");var tn=Symbol.for("@libp2p/peer-id");var Pe=class extends Error{static name="InvalidParametersError";constructor(e="Invalid parameters"){super(e),this.name="InvalidParametersError"}},wr=class extends Error{static name="InvalidPublicKeyError";constructor(e="Invalid public key"){super(e),this.name="InvalidPublicKeyError"}};var xr=class extends Error{static name="InvalidCIDError";constructor(e="Invalid CID"){super(e),this.name="InvalidCIDError"}},br=class extends Error{static name="InvalidMultihashError";constructor(e="Invalid Multihash"){super(e),this.name="InvalidMultihashError"}};var Yt=class extends Error{static name="UnsupportedKeyTypeError";constructor(e="Unsupported key type"){super(e),this.name="UnsupportedKeyTypeError"}};var Ji=oe("node:events"),eo=(r,...e)=>{try{(0,Ji.setMaxListeners)(r,...e)}catch{}};var Er=class extends EventTarget{#e=new Map;constructor(){super(),eo(1/0,this)}listenerCount(e){let t=this.#e.get(e);return t==null?0:t.length}addEventListener(e,t,n){super.addEventListener(e,t,n);let i=this.#e.get(e);i==null&&(i=[],this.#e.set(e,i)),i.push({callback:t,once:(n!==!0&&n!==!1&&n?.once)??!1})}removeEventListener(e,t,n){super.removeEventListener(e.toString(),t??null,n);let i=this.#e.get(e);i!=null&&(i=i.filter(({callback:o})=>o!==t),this.#e.set(e,i))}dispatchEvent(e){let t=super.dispatchEvent(e),n=this.#e.get(e.type);return n==null||(n=n.filter(({once:i})=>!i),this.#e.set(e.type,n)),t}safeDispatchEvent(e,t={}){return this.dispatchEvent(new CustomEvent(e,t))}};var to=Symbol.for("@libp2p/service-capabilities"),Kd=Symbol.for("@libp2p/service-dependencies");var wc=Tt(xo(),1);var xn={};ue(xn,{base58btc:()=>z,base58flickr:()=>Wc});var gl=new Uint8Array(0);function bo(r,e){if(r===e)return!0;if(r.byteLength!==e.byteLength)return!1;for(let t=0;t<r.byteLength;t++)if(r[t]!==e[t])return!1;return!0}function xe(r){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 Eo(r){return new TextEncoder().encode(r)}function Io(r){return new TextDecoder().decode(r)}function Vc(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 i=0;i<r.length;i++){var o=r.charAt(i),s=o.charCodeAt(0);if(t[s]!==255)throw new TypeError(o+" is ambiguous");t[s]=i}var a=r.length,c=r.charAt(0),u=Math.log(a)/Math.log(256),f=Math.log(256)/Math.log(a);function d(h){if(h instanceof Uint8Array||(ArrayBuffer.isView(h)?h=new Uint8Array(h.buffer,h.byteOffset,h.byteLength):Array.isArray(h)&&(h=Uint8Array.from(h))),!(h instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(h.length===0)return"";for(var g=0,U=0,L=0,R=h.length;L!==R&&h[L]===0;)L++,g++;for(var v=(R-L)*f+1>>>0,m=new Uint8Array(v);L!==R;){for(var y=h[L],E=0,B=v-1;(y!==0||E<U)&&B!==-1;B--,E++)y+=256*m[B]>>>0,m[B]=y%a>>>0,y=y/a>>>0;if(y!==0)throw new Error("Non-zero carry");U=E,L++}for(var T=v-U;T!==v&&m[T]===0;)T++;for(var K=c.repeat(g);T<v;++T)K+=r.charAt(m[T]);return K}function l(h){if(typeof h!="string")throw new TypeError("Expected String");if(h.length===0)return new Uint8Array;var g=0;if(h[g]!==" "){for(var U=0,L=0;h[g]===c;)U++,g++;for(var R=(h.length-g)*u+1>>>0,v=new Uint8Array(R);h[g];){var m=t[h.charCodeAt(g)];if(m===255)return;for(var y=0,E=R-1;(m!==0||y<L)&&E!==-1;E--,y++)m+=a*v[E]>>>0,v[E]=m%256>>>0,m=m/256>>>0;if(m!==0)throw new Error("Non-zero carry");L=y,g++}if(h[g]!==" "){for(var B=R-L;B!==R&&v[B]===0;)B++;for(var T=new Uint8Array(U+(R-B)),K=U;B!==R;)T[K++]=v[B++];return T}}}function p(h){var g=l(h);if(g)return g;throw new Error(`Non-${e} character`)}return{encode:d,decodeUnsafe:l,decode:p}}var zc=Vc,jc=zc,vo=jc;var gn=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")}},mn=class{name;prefix;baseDecode;prefixCodePoint;constructor(e,t,n){this.name=e,this.prefix=t;let i=t.codePointAt(0);if(i===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=i,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 So(this,e)}},yn=class{decoders;constructor(e){this.decoders=e}or(e){return So(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 So(r,e){return new yn({...r.decoders??{[r.prefix]:r},...e.decoders??{[e.prefix]:e}})}var wn=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(e,t,n,i){this.name=e,this.prefix=t,this.baseEncode=n,this.baseDecode=i,this.encoder=new gn(e,t,n),this.decoder=new mn(e,t,i)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};function Ot({name:r,prefix:e,encode:t,decode:n}){return new wn(r,e,t,n)}function st({name:r,prefix:e,alphabet:t}){let{encode:n,decode:i}=vo(t,r);return Ot({prefix:e,name:r,encode:n,decode:o=>xe(i(o))})}function Gc(r,e,t,n){let i=r.length;for(;r[i-1]==="=";)--i;let o=new Uint8Array(i*t/8|0),s=0,a=0,c=0;for(let u=0;u<i;++u){let f=e[r[u]];if(f===void 0)throw new SyntaxError(`Non-${n} character`);a=a<<t|f,s+=t,s>=8&&(s-=8,o[c++]=255&a>>s)}if(s>=t||(255&a<<8-s)!==0)throw new SyntaxError("Unexpected end of data");return o}function $c(r,e,t){let n=e[e.length-1]==="=",i=(1<<t)-1,o="",s=0,a=0;for(let c=0;c<r.length;++c)for(a=a<<8|r[c],s+=8;s>t;)s-=t,o+=e[i&a>>s];if(s!==0&&(o+=e[i&a<<t-s]),n)for(;(o.length*t&7)!==0;)o+="=";return o}function Yc(r){let e={};for(let t=0;t<r.length;++t)e[r[t]]=t;return e}function j({name:r,prefix:e,bitsPerChar:t,alphabet:n}){let i=Yc(n);return Ot({prefix:e,name:r,encode(o){return $c(o,n,t)},decode(o){return Gc(o,i,t,r)}})}var z=st({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Wc=st({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var bn={};ue(bn,{base32:()=>Xe,base32hex:()=>Jc,base32hexpad:()=>ta,base32hexpadupper:()=>ra,base32hexupper:()=>ea,base32pad:()=>Zc,base32padupper:()=>Qc,base32upper:()=>Xc,base32z:()=>na});var Xe=j({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Xc=j({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Zc=j({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Qc=j({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Jc=j({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),ea=j({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),ta=j({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),ra=j({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),na=j({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var En={};ue(En,{base36:()=>Xt,base36upper:()=>ia});var Xt=st({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),ia=st({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var oa=Lo,Bo=128,sa=127,ca=~sa,aa=Math.pow(2,31);function Lo(r,e,t){e=e||[],t=t||0;for(var n=t;r>=aa;)e[t++]=r&255|Bo,r/=128;for(;r&ca;)e[t++]=r&255|Bo,r>>>=7;return e[t]=r|0,Lo.bytes=t-n+1,e}var ua=In,da=128,Uo=127;function In(r,n){var t=0,n=n||0,i=0,o=n,s,a=r.length;do{if(o>=a)throw In.bytes=0,new RangeError("Could not decode varint");s=r[o++],t+=i<28?(s&Uo)<<i:(s&Uo)*Math.pow(2,i),i+=7}while(s>=da);return In.bytes=o-n,t}var la=Math.pow(2,7),ha=Math.pow(2,14),pa=Math.pow(2,21),fa=Math.pow(2,28),ga=Math.pow(2,35),ma=Math.pow(2,42),ya=Math.pow(2,49),wa=Math.pow(2,56),xa=Math.pow(2,63),ba=function(r){return r<la?1:r<ha?2:r<pa?3:r<fa?4:r<ga?5:r<ma?6:r<ya?7:r<wa?8:r<xa?9:10},Ea={encode:oa,decode:ua,encodingLength:ba},Ia=Ea,Zt=Ia;function Qt(r,e=0){return[Zt.decode(r,e),Zt.decode.bytes]}function Dt(r,e,t=0){return Zt.encode(r,e,t),e}function Nt(r){return Zt.encodingLength(r)}function ht(r,e){let t=e.byteLength,n=Nt(r),i=n+Nt(t),o=new Uint8Array(i+t);return Dt(r,o,0),Dt(t,o,n),o.set(e,i),new _t(r,t,e,o)}function pt(r){let e=xe(r),[t,n]=Qt(e),[i,o]=Qt(e.subarray(n)),s=e.subarray(n+o);if(s.byteLength!==i)throw new Error("Incorrect length");return new _t(t,i,s,e)}function Co(r,e){if(r===e)return!0;{let t=e;return r.code===t.code&&r.size===t.size&&t.bytes instanceof Uint8Array&&bo(r.bytes,t.bytes)}}var _t=class{code;size;digest;bytes;constructor(e,t,n,i){this.code=e,this.size=t,this.digest=n,this.bytes=i}};function To(r,e){let{bytes:t,version:n}=r;switch(n){case 0:return va(t,An(r),e??z.encoder);default:return Sa(t,An(r),e??Xe.encoder)}}var Po=new WeakMap;function An(r){let e=Po.get(r);if(e==null){let t=new Map;return Po.set(r,t),t}return e}var G=class r{code;version;multihash;bytes;"/";constructor(e,t,n,i){this.code=t,this.version=e,this.multihash=n,this.bytes=i,this["/"]=i}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!==Jt)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==Ba)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=ht(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&&Co(e.multihash,n.multihash)}toString(e){return To(this,e)}toJSON(){return{"/":To(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:i,multihash:o,bytes:s}=t;return new r(n,i,o,s??Oo(n,i,o.bytes))}else if(t[Ua]===!0){let{version:n,multihash:i,code:o}=t,s=pt(i);return r.create(n,o,s)}else return null}static create(e,t,n){if(typeof t!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(e){case 0:{if(t!==Jt)throw new Error(`Version 0 CID must use dag-pb (code: ${Jt}) block encoding`);return new r(e,t,n,n.bytes)}case 1:{let i=Oo(e,t,n.bytes);return new r(e,t,n,i)}default:throw new Error("Invalid version")}}static createV0(e){return r.create(0,Jt,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,i=xe(e.subarray(n,n+t.multihashSize));if(i.byteLength!==t.multihashSize)throw new Error("Incorrect length");let o=i.subarray(t.multihashSize-t.digestSize),s=new _t(t.multihashCode,t.digestSize,o,i);return[t.version===0?r.createV0(s):r.createV1(t.codec,s),e.subarray(t.size)]}static inspectBytes(e){let t=0,n=()=>{let[d,l]=Qt(e.subarray(t));return t+=l,d},i=n(),o=Jt;if(i===18?(i=0,t=0):o=n(),i!==0&&i!==1)throw new RangeError(`Invalid CID version ${i}`);let s=t,a=n(),c=n(),u=t+c,f=u-s;return{version:i,codec:o,multihashCode:a,digestSize:c,multihashSize:f,size:u}}static parse(e,t){let[n,i]=Aa(e,t),o=r.decode(i);if(o.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return An(o).set(n,e),o}};function Aa(r,e){switch(r[0]){case"Q":{let t=e??z;return[z.prefix,t.decode(`${z.prefix}${r}`)]}case z.prefix:{let t=e??z;return[z.prefix,t.decode(r)]}case Xe.prefix:{let t=e??Xe;return[Xe.prefix,t.decode(r)]}case Xt.prefix:{let t=e??Xt;return[Xt.prefix,t.decode(r)]}default:{if(e==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[r[0],e.decode(r)]}}}function va(r,e,t){let{prefix:n}=t;if(n!==z.prefix)throw Error(`Cannot string encode V0 in ${t.name} encoding`);let i=e.get(n);if(i==null){let o=t.encode(r).slice(1);return e.set(n,o),o}else return i}function Sa(r,e,t){let{prefix:n}=t,i=e.get(n);if(i==null){let o=t.encode(r);return e.set(n,o),o}else return i}var Jt=112,Ba=18;function Oo(r,e,t){let n=Nt(r),i=n+Nt(e),o=new Uint8Array(i+t.byteLength);return Dt(r,o,0),Dt(e,o,n),o.set(t,i),o}var Ua=Symbol.for("@ipld/js-cid/CID");var vn={};ue(vn,{identity:()=>Ue});var Do=0,La="identity",No=xe;function Ca(r){return ht(Do,No(r))}var Ue={code:Do,name:La,encode:No,digest:Ca};function pe(r,e){if(r===e)return!0;if(r.byteLength!==e.byteLength)return!1;for(let t=0;t<r.byteLength;t++)if(r[t]!==e[t])return!1;return!0}var Sn=oe("node:buffer");function gt(r){return new Uint8Array(r.buffer,r.byteOffset,r.byteLength)}function Ze(r=0){return gt(Sn.Buffer.alloc(r))}function be(r=0){return gt(Sn.Buffer.allocUnsafe(r))}var _o=oe("node:buffer");function fe(r,e){return gt(_o.Buffer.concat(r,e))}var Ro=Symbol.for("@achingbrain/uint8arraylist");function ko(r,e){if(e==null||e<0)throw new RangeError("index is out of bounds");let t=0;for(let n of r){let i=t+n.byteLength;if(e<i)return{buf:n,index:e-t};t=i}throw new RangeError("index is out of bounds")}function Sr(r){return!!r?.[Ro]}var ge=class r{bufs;length;[Ro]=!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(Sr(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(Sr(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=ko(this.bufs,e);return t.buf[t.index]}set(e,t){let n=ko(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(Sr(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:i}=this._subList(e,t);return fe(n,i)}subarray(e,t){let{bufs:n,length:i}=this._subList(e,t);return n.length===1?n[0]:fe(n,i)}sublist(e,t){let{bufs:n,length:i}=this._subList(e,t),o=new r;return o.length=i,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=[],i=0;for(let o=0;o<this.bufs.length;o++){let s=this.bufs[o],a=i,c=a+s.byteLength;if(i=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(s);break}let d=e-a;n.push(s.subarray(d,d+(t-e)));break}if(u){if(e===0){n.push(s);continue}n.push(s.subarray(e-a));continue}if(f){if(t===c){n.push(s);break}n.push(s.subarray(0,t-a));break}n.push(s)}return{bufs:n,length:t-e}}indexOf(e,t=0){if(!Sr(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 i=n.byteLength;if(i===0)throw new TypeError("search must be at least 1 byte long");let o=256,s=new Int32Array(o);for(let d=0;d<o;d++)s[d]=-1;for(let d=0;d<i;d++)s[n[d]]=d;let a=s,c=this.byteLength-n.byteLength,u=n.byteLength-1,f;for(let d=t;d<=c;d+=f){f=0;for(let l=u;l>=0;l--){let p=this.get(d+l);if(n[l]!==p){f=Math.max(1,l-a[p]);break}}if(f===0)return d}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=be(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 i=Ze(2);new DataView(i.buffer,i.byteOffset,i.byteLength).setInt16(0,t,n),this.write(i,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 i=Ze(4);new DataView(i.buffer,i.byteOffset,i.byteLength).setInt32(0,t,n),this.write(i,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 i=Ze(8);new DataView(i.buffer,i.byteOffset,i.byteLength).setBigInt64(0,t,n),this.write(i,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=be(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 i=Ze(2);new DataView(i.buffer,i.byteOffset,i.byteLength).setUint16(0,t,n),this.write(i,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 i=Ze(4);new DataView(i.buffer,i.byteOffset,i.byteLength).setUint32(0,t,n),this.write(i,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 i=Ze(8);new DataView(i.buffer,i.byteOffset,i.byteLength).setBigUint64(0,t,n),this.write(i,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 i=Ze(4);new DataView(i.buffer,i.byteOffset,i.byteLength).setFloat32(0,t,n),this.write(i,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 i=Ze(8);new DataView(i.buffer,i.byteOffset,i.byteLength).setFloat64(0,t,n),this.write(i,e)}equals(e){if(e==null||!(e instanceof r)||e.bufs.length!==this.bufs.length)return!1;for(let t=0;t<this.bufs.length;t++)if(!pe(this.bufs[t],e.bufs[t]))return!1;return!0}static fromUint8Arrays(e,t){let n=new r;return n.bufs=e,t==null&&(t=e.reduce((i,o)=>i+o.byteLength,0)),n.length=t,n}};var qo=oe("node:buffer");var Bn={};ue(Bn,{base10:()=>Ta});var Ta=st({prefix:"9",name:"base10",alphabet:"0123456789"});var Un={};ue(Un,{base16:()=>Pa,base16upper:()=>Oa});var Pa=j({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Oa=j({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Ln={};ue(Ln,{base2:()=>Da});var Da=j({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Cn={};ue(Cn,{base256emoji:()=>Ka});var Ko=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}"),Na=Ko.reduce((r,e,t)=>(r[t]=e,r),[]),_a=Ko.reduce((r,e,t)=>{let n=e.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${e}`);return r[n]=t,r},[]);function ka(r){return r.reduce((e,t)=>(e+=Na[t],e),"")}function Ra(r){let e=[];for(let t of r){let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);let i=_a[n];if(i==null)throw new Error(`Non-base256emoji character: ${t}`);e.push(i)}return new Uint8Array(e)}var Ka=Ot({prefix:"\u{1F680}",name:"base256emoji",encode:ka,decode:Ra});var Tn={};ue(Tn,{base64:()=>Ma,base64pad:()=>Fa,base64url:()=>Ha,base64urlpad:()=>qa});var Ma=j({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Fa=j({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Ha=j({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),qa=j({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Pn={};ue(Pn,{base8:()=>Va});var Va=j({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var On={};ue(On,{identity:()=>za});var za=Ot({prefix:"\0",name:"identity",encode:r=>Io(r),decode:r=>Eo(r)});var Zl=new TextEncoder,Ql=new TextDecoder;var Rn={};ue(Rn,{sha256:()=>kn,sha512:()=>$a});var _n=Tt(oe("crypto"),1);function Nn({name:r,code:e,encode:t}){return new Dn(r,e,t)}var Dn=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?ht(this.code,t):t.then(n=>ht(this.code,n))}else throw Error("Unknown type, must be binary type")}};var kn=Nn({name:"sha2-256",code:18,encode:r=>xe(_n.default.createHash("sha256").update(r).digest())}),$a=Nn({name:"sha2-512",code:19,encode:r=>xe(_n.default.createHash("sha512").update(r).digest())});var er={...On,...Ln,...Pn,...Bn,...Un,...bn,...En,...xn,...Tn,...Cn},lh={...Rn,...vn};function Ho(r,e,t,n){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:n}}}var Fo=Ho("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),Kn=Ho("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=be(r.length);for(let t=0;t<r.length;t++)e[t]=r.charCodeAt(t);return e}),Ya={utf8:Fo,"utf-8":Fo,hex:er.base16,latin1:Kn,ascii:Kn,binary:Kn,...er},Br=Ya;function Ee(r,e="utf8"){let t=Br[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return e==="utf8"||e==="utf-8"?gt(qo.Buffer.from(r,"utf-8")):t.decoder.decode(`${t.prefix}${r}`)}var Vo=oe("node:buffer");function H(r,e="utf8"){let t=Br[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return e==="utf8"||e==="utf-8"?Vo.Buffer.from(r.buffer,r.byteOffset,r.byteLength).toString("utf8"):t.encoder.encode(r).substring(1)}var Wa=parseInt("11111",2),Mn=parseInt("10000000",2),Xa=parseInt("01111111",2),zo={0:tr,1:tr,2:Za,3:eu,4:tu,5:Ja,6:Qa,16:tr,22:tr,48:tr};function Fn(r,e={offset:0}){let t=r[e.offset]&Wa;if(e.offset++,zo[t]!=null)return zo[t](r,e);throw new Error("No decoder for tag "+t)}function rr(r,e){let t=0;if((r[e.offset]&Mn)===Mn){let n=r[e.offset]&Xa,i="0x";e.offset++;for(let o=0;o<n;o++,e.offset++)i+=r[e.offset].toString(16).padStart(2,"0");t=parseInt(i,16)}else t=r[e.offset],e.offset++;return t}function tr(r,e){rr(r,e);let t=[];for(;!(e.offset>=r.byteLength);){let n=Fn(r,e);if(n===null)break;t.push(n)}return t}function Za(r,e){let t=rr(r,e),n=e.offset,i=e.offset+t,o=[];for(let s=n;s<i;s++)s===n&&r[s]===0||o.push(r[s]);return e.offset+=t,Uint8Array.from(o)}function Qa(r,e){let t=rr(r,e),n=e.offset+t,i=r[e.offset];e.offset++;let o=0,s=0;i<40?(o=0,s=i):i<80?(o=1,s=i-40):(o=2,s=i-80);let a=`${o}.${s}`,c=[];for(;e.offset<n;){let u=r[e.offset];if(e.offset++,c.push(u&127),u<128){c.reverse();let f=0;for(let d=0;d<c.length;d++)f+=c[d]<<d*7;a+=`.${f}`,c=[]}}return a}function Ja(r,e){return e.offset++,null}function eu(r,e){let t=rr(r,e),n=r[e.offset];e.offset++;let i=r.subarray(e.offset,e.offset+t-1);if(e.offset+=t,n!==0)throw new Error("Unused bits in bit string is unimplemented");return i}function tu(r,e){let t=rr(r,e),n=r.subarray(e.offset,e.offset+t);return e.offset+=t,n}function ru(r){let e=r.toString(16);e.length%2===1&&(e="0"+e);let t=new ge;for(let n=0;n<e.length;n+=2)t.append(Uint8Array.from([parseInt(`${e[n]}${e[n+1]}`,16)]));return t}function Hn(r){if(r.byteLength<128)return Uint8Array.from([r.byteLength]);let e=ru(r.byteLength);return new ge(Uint8Array.from([e.byteLength|Mn]),e)}function jo(r){let e=new ge,t=128;return(r.subarray()[0]&t)===t&&e.append(Uint8Array.from([0])),e.append(r),new ge(Uint8Array.from([2]),Hn(e),e)}function Go(r){let e=Uint8Array.from([0]),t=new ge(e,r);return new ge(Uint8Array.from([3]),Hn(t),t)}function Ur(r,e=48){let t=new ge;for(let n of r)t.append(n);return new ge(Uint8Array.from([e]),Hn(t),t)}async function $o(r,e,t){let n=await crypto.subtle.importKey("jwk",r,{name:"ECDSA",namedCurve:r.crv??"P-256"},!1,["verify"]);return crypto.subtle.verify({name:"ECDSA",hash:{name:"SHA-256"}},n,e,t.subarray())}var nu=Uint8Array.from([6,8,42,134,72,206,61,3,1,7]),iu=Uint8Array.from([6,5,43,129,4,0,34]),ou=Uint8Array.from([6,5,43,129,4,0,35]),su={ext:!0,kty:"EC",crv:"P-256"},cu={ext:!0,kty:"EC",crv:"P-384"},au={ext:!0,kty:"EC",crv:"P-521"},qn=32,Vn=48,zn=66;function Yo(r){let e=Fn(r);return Wo(e)}function Wo(r){let e=r[1][1][0],t=1,n,i;if(e.byteLength===qn*2+1)return n=H(e.subarray(t,t+qn),"base64url"),i=H(e.subarray(t+qn),"base64url"),new kt({...su,key_ops:["verify"],x:n,y:i});if(e.byteLength===Vn*2+1)return n=H(e.subarray(t,t+Vn),"base64url"),i=H(e.subarray(t+Vn),"base64url"),new kt({...cu,key_ops:["verify"],x:n,y:i});if(e.byteLength===zn*2+1)return n=H(e.subarray(t,t+zn),"base64url"),i=H(e.subarray(t+zn),"base64url"),new kt({...au,key_ops:["verify"],x:n,y:i});throw new Pe(`coordinates were wrong length, got ${e.byteLength}, expected 65, 97 or 133`)}function Xo(r){return Ur([jo(Uint8Array.from([1])),Ur([uu(r.crv)],160),Ur([Go(new ge(Uint8Array.from([4]),Ee(r.x??"","base64url"),Ee(r.y??"","base64url")))],161)]).subarray()}function uu(r){if(r==="P-256")return nu;if(r==="P-384")return iu;if(r==="P-521")return ou;throw new Pe(`Invalid curve ${r}`)}var kt=class{type="ECDSA";jwk;_raw;constructor(e){this.jwk=e}get raw(){return this._raw==null&&(this._raw=Xo(this.jwk)),this._raw}toMultihash(){return Ue.digest(Rt(this))}toCID(){return G.createV1(114,this.toMultihash())}toString(){return z.encode(this.toMultihash().bytes).substring(1)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:pe(this.raw,e.raw)}async verify(e,t){return $o(this.jwk,t,e)}};var Lr=Tt(oe("crypto"),1);var Gh=Lr.default.generateKeyPairSync,nr=32;var du=64;function Zo(r,e,t){if(r.byteLength!==nr)throw new TypeError('"key" must be 32 bytes in length.');if(!(r instanceof Uint8Array))throw new TypeError('"key" must be a node.js Buffer, or Uint8Array.');if(e.byteLength!==du)throw new TypeError('"sig" must be 64 bytes in length.');if(!(e instanceof Uint8Array))throw new TypeError('"sig" must be a node.js Buffer, or Uint8Array.');let n=Lr.default.createPublicKey({format:"jwk",key:{crv:"Ed25519",x:H(r,"base64url"),kty:"OKP"}});return Lr.default.verify(null,t instanceof Uint8Array?t:t.subarray(),n,e)}var Cr=class{type="Ed25519";raw;constructor(e){this.raw=jn(e,nr)}toMultihash(){return Ue.digest(Rt(this))}toCID(){return G.createV1(114,this.toMultihash())}toString(){return z.encode(this.toMultihash().bytes).substring(1)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:pe(this.raw,e.raw)}verify(e,t){return Zo(this.raw,t,e)}};function Jo(r){return r=jn(r,nr),new Cr(r)}function jn(r,e){if(r=Uint8Array.from(r??[]),r.length!==e)throw new Pe(`Key must be a Uint8Array of length ${e}, got ${r.length}`);return r}var hu=Math.pow(2,7),pu=Math.pow(2,14),fu=Math.pow(2,21),Gn=Math.pow(2,28),$n=Math.pow(2,35),Yn=Math.pow(2,42),Wn=Math.pow(2,49),F=128,Z=127;function ce(r){if(r<hu)return 1;if(r<pu)return 2;if(r<fu)return 3;if(r<Gn)return 4;if(r<$n)return 5;if(r<Yn)return 6;if(r<Wn)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function Xn(r,e,t=0){switch(ce(r)){case 8:e[t++]=r&255|F,r/=128;case 7:e[t++]=r&255|F,r/=128;case 6:e[t++]=r&255|F,r/=128;case 5:e[t++]=r&255|F,r/=128;case 4:e[t++]=r&255|F,r>>>=7;case 3:e[t++]=r&255|F,r>>>=7;case 2:e[t++]=r&255|F,r>>>=7;case 1:{e[t++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return e}function gu(r,e,t=0){switch(ce(r)){case 8:e.set(t++,r&255|F),r/=128;case 7:e.set(t++,r&255|F),r/=128;case 6:e.set(t++,r&255|F),r/=128;case 5:e.set(t++,r&255|F),r/=128;case 4:e.set(t++,r&255|F),r>>>=7;case 3:e.set(t++,r&255|F),r>>>=7;case 2:e.set(t++,r&255|F),r>>>=7;case 1:{e.set(t++,r&255),r>>>=7;break}default:throw new Error("unreachable")}return e}function Zn(r,e){let t=r[e],n=0;if(n+=t&Z,t<F||(t=r[e+1],n+=(t&Z)<<7,t<F)||(t=r[e+2],n+=(t&Z)<<14,t<F)||(t=r[e+3],n+=(t&Z)<<21,t<F)||(t=r[e+4],n+=(t&Z)*Gn,t<F)||(t=r[e+5],n+=(t&Z)*$n,t<F)||(t=r[e+6],n+=(t&Z)*Yn,t<F)||(t=r[e+7],n+=(t&Z)*Wn,t<F))return n;throw new RangeError("Could not decode varint")}function mu(r,e){let t=r.get(e),n=0;if(n+=t&Z,t<F||(t=r.get(e+1),n+=(t&Z)<<7,t<F)||(t=r.get(e+2),n+=(t&Z)<<14,t<F)||(t=r.get(e+3),n+=(t&Z)<<21,t<F)||(t=r.get(e+4),n+=(t&Z)*Gn,t<F)||(t=r.get(e+5),n+=(t&Z)*$n,t<F)||(t=r.get(e+6),n+=(t&Z)*Yn,t<F)||(t=r.get(e+7),n+=(t&Z)*Wn,t<F))return n;throw new RangeError("Could not decode varint")}function Kt(r,e,t=0){return e==null&&(e=be(ce(r))),e instanceof Uint8Array?Xn(r,e,t):gu(r,e,t)}function mt(r,e=0){return r instanceof Uint8Array?Zn(r,e):mu(r,e)}var Qn=new Float32Array([-0]),ct=new Uint8Array(Qn.buffer);function ts(r,e,t){Qn[0]=r,e[t]=ct[0],e[t+1]=ct[1],e[t+2]=ct[2],e[t+3]=ct[3]}function rs(r,e){return ct[0]=r[e],ct[1]=r[e+1],ct[2]=r[e+2],ct[3]=r[e+3],Qn[0]}var Jn=new Float64Array([-0]),Q=new Uint8Array(Jn.buffer);function ns(r,e,t){Jn[0]=r,e[t]=Q[0],e[t+1]=Q[1],e[t+2]=Q[2],e[t+3]=Q[3],e[t+4]=Q[4],e[t+5]=Q[5],e[t+6]=Q[6],e[t+7]=Q[7]}function is(r,e){return Q[0]=r[e],Q[1]=r[e+1],Q[2]=r[e+2],Q[3]=r[e+3],Q[4]=r[e+4],Q[5]=r[e+5],Q[6]=r[e+6],Q[7]=r[e+7],Jn[0]}var yu=BigInt(Number.MAX_SAFE_INTEGER),wu=BigInt(Number.MIN_SAFE_INTEGER),me=class r{lo;hi;constructor(e,t){this.lo=e|0,this.hi=t|0}toNumber(e=!1){if(!e&&this.hi>>>31>0){let t=~this.lo+1>>>0,n=~this.hi>>>0;return t===0&&(n=n+1>>>0),-(t+n*4294967296)}return this.lo+this.hi*4294967296}toBigInt(e=!1){if(e)return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31){let t=~this.lo+1>>>0,n=~this.hi>>>0;return t===0&&(n=n+1>>>0),-(BigInt(t)+(BigInt(n)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toString(e=!1){return this.toBigInt(e).toString()}zzEncode(){let e=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^e)>>>0,this.lo=(this.lo<<1^e)>>>0,this}zzDecode(){let e=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^e)>>>0,this.hi=(this.hi>>>1^e)>>>0,this}length(){let e=this.lo,t=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return n===0?t===0?e<16384?e<128?1:2:e<2097152?3:4:t<16384?t<128?5:6:t<2097152?7:8:n<128?9:10}static fromBigInt(e){if(e===0n)return yt;if(e<yu&&e>wu)return this.fromNumber(Number(e));let t=e<0n;t&&(e=-e);let n=e>>32n,i=e-(n<<32n);return t&&(n=~n|0n,i=~i|0n,++i>os&&(i=0n,++n>os&&(n=0n))),new r(Number(i),Number(n))}static fromNumber(e){if(e===0)return yt;let t=e<0;t&&(e=-e);let n=e>>>0,i=(e-n)/4294967296>>>0;return t&&(i=~i>>>0,n=~n>>>0,++n>4294967295&&(n=0,++i>4294967295&&(i=0))),new r(n,i)}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 me(0,0);yt.toBigInt=function(){return 0n};yt.zzEncode=yt.zzDecode=function(){return this};yt.length=function(){return 1};var os=4294967296n;function ss(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 cs(r,e,t){if(t-e<1)return"";let i,o=[],s=0,a;for(;e<t;)a=r[e++],a<128?o[s++]=a:a>191&&a<224?o[s++]=(a&31)<<6|r[e++]&63:a>239&&a<365?(a=((a&7)<<18|(r[e++]&63)<<12|(r[e++]&63)<<6|r[e++]&63)-65536,o[s++]=55296+(a>>10),o[s++]=56320+(a&1023)):o[s++]=(a&15)<<12|(r[e++]&63)<<6|r[e++]&63,s>8191&&((i??(i=[])).push(String.fromCharCode.apply(String,o)),s=0);return i!=null?(s>0&&i.push(String.fromCharCode.apply(String,o.slice(0,s))),i.join("")):String.fromCharCode.apply(String,o.slice(0,s))}function ei(r,e,t){let n=t,i,o;for(let s=0;s<r.length;++s)i=r.charCodeAt(s),i<128?e[t++]=i:i<2048?(e[t++]=i>>6|192,e[t++]=i&63|128):(i&64512)===55296&&((o=r.charCodeAt(s+1))&64512)===56320?(i=65536+((i&1023)<<10)+(o&1023),++s,e[t++]=i>>18|240,e[t++]=i>>12&63|128,e[t++]=i>>6&63|128,e[t++]=i&63|128):(e[t++]=i>>12|224,e[t++]=i>>6&63|128,e[t++]=i&63|128);return t-n}function Le(r,e){return RangeError(`index out of range: ${r.pos} + ${e??1} > ${r.len}`)}function Tr(r,e){return(r[e-4]|r[e-3]<<8|r[e-2]<<16|r[e-1]<<24)>>>0}var ti=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,Le(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 Le(this,4);return Tr(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw Le(this,4);return Tr(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw Le(this,4);let e=rs(this.buf,this.pos);return this.pos+=4,e}double(){if(this.pos+8>this.len)throw Le(this,4);let e=is(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 Le(this,e);return this.pos+=e,t===n?new Uint8Array(0):this.buf.subarray(t,n)}string(){let e=this.bytes();return cs(e,0,e.length)}skip(e){if(typeof e=="number"){if(this.pos+e>this.len)throw Le(this,e);this.pos+=e}else do if(this.pos>=this.len)throw Le(this);while((this.buf[this.pos++]&128)!==0);return this}skipType(e){switch(e){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(e=this.uint32()&7)!==4;)this.skipType(e);break;case 5:this.skip(4);break;default:throw Error(`invalid wire type ${e} at offset ${this.pos}`)}return this}readLongVarint(){let e=new me(0,0),t=0;if(this.len-this.pos>4){for(;t<4;++t)if(e.lo=(e.lo|(this.buf[this.pos]&127)<<t*7)>>>0,this.buf[this.pos++]<128)return e;if(e.lo=(e.lo|(this.buf[this.pos]&127)<<28)>>>0,e.hi=(e.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return e;t=0}else{for(;t<3;++t){if(this.pos>=this.len)throw Le(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 Le(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 Le(this,8);let e=Tr(this.buf,this.pos+=4),t=Tr(this.buf,this.pos+=4);return new me(e,t)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){let e=Zn(this.buf,this.pos);return this.pos+=ce(e),e}uint64String(){return this.readLongVarint().toString(!0)}sint64(){return this.readLongVarint().zzDecode().toBigInt()}sint64Number(){return this.readLongVarint().zzDecode().toNumber()}sint64String(){return this.readLongVarint().zzDecode().toString()}fixed64(){return this.readFixed64().toBigInt()}fixed64Number(){return this.readFixed64().toNumber()}fixed64String(){return this.readFixed64().toString()}sfixed64(){return this.readFixed64().toBigInt()}sfixed64Number(){return this.readFixed64().toNumber()}sfixed64String(){return this.readFixed64().toString()}};function ri(r){return new ti(r instanceof Uint8Array?r:r.subarray())}function Pr(r,e,t){let n=ri(r);return e.decode(n,void 0,t)}function ni(r){let e=r??8192,t=e>>>1,n,i=e;return function(s){if(s<1||s>t)return be(s);i+s>e&&(n=be(e),i=0);let a=n.subarray(i,i+=s);return(i&7)!==0&&(i=(i|7)+1),a}}var wt=class{fn;len;next;val;constructor(e,t,n){this.fn=e,this.len=t,this.next=void 0,this.val=n}};function ii(){}var si=class{head;tail;len;next;constructor(e){this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}},xu=ni();function bu(r){return globalThis.Buffer!=null?be(r):xu(r)}var or=class{len;head;tail;states;constructor(){this.len=0,this.head=new wt(ii,0,0),this.tail=this.head,this.states=null}_push(e,t,n){return this.tail=this.tail.next=new wt(e,t,n),this.len+=t,this}uint32(e){return this.len+=(this.tail=this.tail.next=new ci((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(Or,10,me.fromNumber(e)):this.uint32(e)}sint32(e){return this.uint32((e<<1^e>>31)>>>0)}uint64(e){let t=me.fromBigInt(e);return this._push(Or,t.length(),t)}uint64Number(e){return this._push(Xn,ce(e),e)}uint64String(e){return this.uint64(BigInt(e))}int64(e){return this.uint64(e)}int64Number(e){return this.uint64Number(e)}int64String(e){return this.uint64String(e)}sint64(e){let t=me.fromBigInt(e).zzEncode();return this._push(Or,t.length(),t)}sint64Number(e){let t=me.fromNumber(e).zzEncode();return this._push(Or,t.length(),t)}sint64String(e){return this.sint64(BigInt(e))}bool(e){return this._push(oi,1,e?1:0)}fixed32(e){return this._push(ir,4,e>>>0)}sfixed32(e){return this.fixed32(e)}fixed64(e){let t=me.fromBigInt(e);return this._push(ir,4,t.lo)._push(ir,4,t.hi)}fixed64Number(e){let t=me.fromNumber(e);return this._push(ir,4,t.lo)._push(ir,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(ts,4,e)}double(e){return this._push(ns,8,e)}bytes(e){let t=e.length>>>0;return t===0?this._push(oi,1,0):this.uint32(t)._push(Iu,t,e)}string(e){let t=ss(e);return t!==0?this.uint32(t)._push(ei,t,e):this._push(oi,1,0)}fork(){return this.states=new si(this),this.head=this.tail=new wt(ii,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 wt(ii,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=bu(this.len),n=0;for(;e!=null;)e.fn(e.val,t,n),n+=e.len,e=e.next;return t}};function oi(r,e,t){e[t]=r&255}function Eu(r,e,t){for(;r>127;)e[t++]=r&127|128,r>>>=7;e[t]=r}var ci=class extends wt{next;constructor(e,t){super(Eu,e,t),this.next=void 0}};function Or(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 ir(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 Iu(r,e,t){e.set(r,t)}globalThis.Buffer!=null&&(or.prototype.bytes=function(r){let e=r.length>>>0;return this.uint32(e),e>0&&this._push(Au,e,r),this},or.prototype.string=function(r){let e=globalThis.Buffer.byteLength(r);return this.uint32(e),e>0&&this._push(vu,e,r),this});function Au(r,e,t){e.set(r,t)}function vu(r,e,t){r.length<40?ei(r,e,t):e.utf8Write!=null?e.utf8Write(r,t):e.set(Ee(r),t)}function ai(){return new or}function Dr(r,e){let t=ai();return e.encode(r,t,{lengthDelimited:!1}),t.finish()}var Mt;(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"})(Mt||(Mt={}));function Nr(r,e,t,n){return{name:r,type:e,encode:t,decode:n}}function ui(r){function e(i){if(r[i.toString()]==null)throw new Error("Invalid enum value");return r[i]}let t=function(o,s){let a=e(o);s.int32(a)},n=function(o){let s=o.int32();return e(s)};return Nr("enum",Mt.VARINT,t,n)}function _r(r,e){return Nr("message",Mt.LENGTH_DELIMITED,r,e)}var ye;(function(r){r.RSA="RSA",r.Ed25519="Ed25519",r.secp256k1="secp256k1",r.ECDSA="ECDSA"})(ye||(ye={}));var di;(function(r){r[r.RSA=0]="RSA",r[r.Ed25519=1]="Ed25519",r[r.secp256k1=2]="secp256k1",r[r.ECDSA=3]="ECDSA"})(di||(di={}));(function(r){r.codec=()=>ui(di)})(ye||(ye={}));var sr;(function(r){let e;r.codec=()=>(e==null&&(e=_r((t,n,i={})=>{i.lengthDelimited!==!1&&n.fork(),t.Type!=null&&(n.uint32(8),ye.codec().encode(t.Type,n)),t.Data!=null&&(n.uint32(18),n.bytes(t.Data)),i.lengthDelimited!==!1&&n.ldelim()},(t,n,i={})=>{let o={},s=n==null?t.len:t.pos+n;for(;t.pos<s;){let a=t.uint32();switch(a>>>3){case 1:{o.Type=ye.codec().decode(t);break}case 2:{o.Data=t.bytes();break}default:{t.skipType(a&7);break}}}return o})),e),r.encode=t=>Dr(t,r.codec()),r.decode=(t,n)=>Pr(t,r.codec(),n)})(sr||(sr={}));var li;(function(r){let e;r.codec=()=>(e==null&&(e=_r((t,n,i={})=>{i.lengthDelimited!==!1&&n.fork(),t.Type!=null&&(n.uint32(8),ye.codec().encode(t.Type,n)),t.Data!=null&&(n.uint32(18),n.bytes(t.Data)),i.lengthDelimited!==!1&&n.ldelim()},(t,n,i={})=>{let o={},s=n==null?t.len:t.pos+n;for(;t.pos<s;){let a=t.uint32();switch(a>>>3){case 1:{o.Type=ye.codec().decode(t);break}case 2:{o.Data=t.bytes();break}default:{t.skipType(a&7);break}}}return o})),e),r.encode=t=>Dr(t,r.codec()),r.decode=(t,n)=>Pr(t,r.codec(),n)})(li||(li={}));var Qe=Tt(oe("node:crypto"),1),xt=Qe&&typeof Qe=="object"&&"webcrypto"in Qe?Qe.webcrypto:Qe&&typeof Qe=="object"&&"randomBytes"in Qe?Qe:void 0;function Bu(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function kr(r){if(!Number.isSafeInteger(r)||r<0)throw new Error("positive integer expected, got "+r)}function bt(r,...e){if(!Bu(r))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(r.length))throw new Error("Uint8Array expected of length "+e+", got length="+r.length)}function us(r){if(typeof r!="function"||typeof r.create!="function")throw new Error("Hash should be wrapped by utils.createHasher");kr(r.outputLen),kr(r.blockLen)}function Ht(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 ds(r,e){bt(r);let t=e.outputLen;if(r.length<t)throw new Error("digestInto() expects output buffer of length at least "+t)}function Et(...r){for(let e=0;e<r.length;e++)r[e].fill(0)}function Rr(r){return new DataView(r.buffer,r.byteOffset,r.byteLength)}function Ce(r,e){return r<<32-e|r>>>e}function Uu(r){if(typeof r!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(r))}function cr(r){return typeof r=="string"&&(r=Uu(r)),bt(r),r}function ls(...r){let e=0;for(let n=0;n<r.length;n++){let i=r[n];bt(i),e+=i.length}let t=new Uint8Array(e);for(let n=0,i=0;n<r.length;n++){let o=r[n];t.set(o,i),i+=o.length}return t}var Ft=class{};function hs(r){let e=n=>r().update(cr(n)).digest(),t=r();return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=()=>r(),e}function ps(r=32){if(xt&&typeof xt.getRandomValues=="function")return xt.getRandomValues(new Uint8Array(r));if(xt&&typeof xt.randomBytes=="function")return Uint8Array.from(xt.randomBytes(r));throw new Error("crypto.getRandomValues must be defined")}function Lu(r,e,t,n){if(typeof r.setBigUint64=="function")return r.setBigUint64(e,t,n);let i=BigInt(32),o=BigInt(4294967295),s=Number(t>>i&o),a=Number(t&o),c=n?4:0,u=n?0:4;r.setUint32(e+c,s,n),r.setUint32(e+u,a,n)}function fs(r,e,t){return r&e^~r&t}function gs(r,e,t){return r&e^r&t^e&t}var Kr=class extends Ft{constructor(e,t,n,i){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=i,this.buffer=new Uint8Array(e),this.view=Rr(this.buffer)}update(e){Ht(this),e=cr(e),bt(e);let{view:t,buffer:n,blockLen:i}=this,o=e.length;for(let s=0;s<o;){let a=Math.min(i-this.pos,o-s);if(a===i){let c=Rr(e);for(;i<=o-s;s+=i)this.process(c,s);continue}n.set(e.subarray(s,s+a),this.pos),this.pos+=a,s+=a,this.pos===i&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){Ht(this),ds(e,this),this.finished=!0;let{buffer:t,view:n,blockLen:i,isLE:o}=this,{pos:s}=this;t[s++]=128,Et(this.buffer.subarray(s)),this.padOffset>i-s&&(this.process(n,0),s=0);for(let d=s;d<i;d++)t[d]=0;Lu(n,i-8,BigInt(this.length*8),o),this.process(n,0);let a=Rr(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 d=0;d<u;d++)a.setUint32(4*d,f[d],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:i,finished:o,destroyed:s,pos:a}=this;return e.destroyed=s,e.finished=o,e.length=i,e.pos=a,i%t&&e.buffer.set(n),e}clone(){return this._cloneInto()}},Je=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var Cu=Uint32Array.from([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]),at=new Uint32Array(64),hi=class extends Kr{constructor(e=32){super(64,e,8,!1),this.A=Je[0]|0,this.B=Je[1]|0,this.C=Je[2]|0,this.D=Je[3]|0,this.E=Je[4]|0,this.F=Je[5]|0,this.G=Je[6]|0,this.H=Je[7]|0}get(){let{A:e,B:t,C:n,D:i,E:o,F:s,G:a,H:c}=this;return[e,t,n,i,o,s,a,c]}set(e,t,n,i,o,s,a,c){this.A=e|0,this.B=t|0,this.C=n|0,this.D=i|0,this.E=o|0,this.F=s|0,this.G=a|0,this.H=c|0}process(e,t){for(let d=0;d<16;d++,t+=4)at[d]=e.getUint32(t,!1);for(let d=16;d<64;d++){let l=at[d-15],p=at[d-2],h=Ce(l,7)^Ce(l,18)^l>>>3,g=Ce(p,17)^Ce(p,19)^p>>>10;at[d]=g+at[d-7]+h+at[d-16]|0}let{A:n,B:i,C:o,D:s,E:a,F:c,G:u,H:f}=this;for(let d=0;d<64;d++){let l=Ce(a,6)^Ce(a,11)^Ce(a,25),p=f+l+fs(a,c,u)+Cu[d]+at[d]|0,g=(Ce(n,2)^Ce(n,13)^Ce(n,22))+gs(n,i,o)|0;f=u,u=c,c=a,a=s+p|0,s=o,o=i,i=n,n=p+g|0}n=n+this.A|0,i=i+this.B|0,o=o+this.C|0,s=s+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,i,o,s,a,c,u,f)}roundClean(){Et(at)}destroy(){this.set(0,0,0,0,0,0,0,0),Et(this.buffer)}};var ms=hs(()=>new hi);var qs=Tt(oe("node:crypto"),1);var Mr=class extends Ft{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,us(e);let n=cr(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 i=this.blockLen,o=new Uint8Array(i);o.set(n.length>i?e.create().update(n).digest():n);for(let s=0;s<o.length;s++)o[s]^=54;this.iHash.update(o),this.oHash=e.create();for(let s=0;s<o.length;s++)o[s]^=106;this.oHash.update(o),Et(o)}update(e){return Ht(this),this.iHash.update(e),this}digestInto(e){Ht(this),bt(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:i,destroyed:o,blockLen:s,outputLen:a}=this;return e=e,e.finished=i,e.destroyed=o,e.blockLen=s,e.outputLen=a,e.oHash=t._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},pi=(r,e,t)=>new Mr(r,e).update(t).digest();pi.create=(r,e)=>new Mr(r,e);var yi=BigInt(0),mi=BigInt(1);function qt(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function wi(r){if(!qt(r))throw new Error("Uint8Array expected")}function Vt(r,e){if(typeof e!="boolean")throw new Error(r+" boolean expected, got "+e)}function ar(r){let e=r.toString(16);return e.length&1?"0"+e:e}function xs(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return r===""?yi:BigInt("0x"+r)}var bs=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",Tu=Array.from({length:256},(r,e)=>e.toString(16).padStart(2,"0"));function zt(r){if(wi(r),bs)return r.toHex();let e="";for(let t=0;t<r.length;t++)e+=Tu[r[t]];return e}var et={_0:48,_9:57,A:65,F:70,a:97,f:102};function ys(r){if(r>=et._0&&r<=et._9)return r-et._0;if(r>=et.A&&r<=et.F)return r-(et.A-10);if(r>=et.a&&r<=et.f)return r-(et.a-10)}function ur(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);if(bs)return Uint8Array.fromHex(r);let e=r.length,t=e/2;if(e%2)throw new Error("hex string expected, got unpadded hex of length "+e);let n=new Uint8Array(t);for(let i=0,o=0;i<t;i++,o+=2){let s=ys(r.charCodeAt(o)),a=ys(r.charCodeAt(o+1));if(s===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[i]=s*16+a}return n}function tt(r){return xs(zt(r))}function xi(r){return wi(r),xs(zt(Uint8Array.from(r).reverse()))}function It(r,e){return ur(r.toString(16).padStart(e*2,"0"))}function bi(r,e){return It(r,e).reverse()}function ae(r,e,t){let n;if(typeof e=="string")try{n=ur(e)}catch(o){throw new Error(r+" must be hex string or Uint8Array, cause: "+o)}else if(qt(e))n=Uint8Array.from(e);else throw new Error(r+" must be hex string or Uint8Array");let i=n.length;if(typeof t=="number"&&i!==t)throw new Error(r+" of length "+t+" expected, got "+i);return n}function dr(...r){let e=0;for(let n=0;n<r.length;n++){let i=r[n];wi(i),e+=i.length}let t=new Uint8Array(e);for(let n=0,i=0;n<r.length;n++){let o=r[n];t.set(o,i),i+=o.length}return t}var fi=r=>typeof r=="bigint"&&yi<=r;function Fr(r,e,t){return fi(r)&&fi(e)&&fi(t)&&e<=r&&r<t}function At(r,e,t,n){if(!Fr(e,t,n))throw new Error("expected valid "+r+": "+t+" <= n < "+n+", got "+e)}function Es(r){let e;for(e=0;r>yi;r>>=mi,e+=1);return e}var vt=r=>(mi<<BigInt(r))-mi,gi=r=>new Uint8Array(r),ws=r=>Uint8Array.from(r);function Is(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=gi(r),i=gi(r),o=0,s=()=>{n.fill(1),i.fill(0),o=0},a=(...d)=>t(i,n,...d),c=(d=gi(0))=>{i=a(ws([0]),d),n=a(),d.length!==0&&(i=a(ws([1]),d),n=a())},u=()=>{if(o++>=1e3)throw new Error("drbg: tried 1000 values");let d=0,l=[];for(;d<e;){n=a();let p=n.slice();l.push(p),d+=n.length}return dr(...l)};return(d,l)=>{s(),c(d);let p;for(;!(p=l(u()));)c();return s(),p}}var Pu={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"||qt(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 St(r,e,t={}){let n=(i,o,s)=>{let a=Pu[o];if(typeof a!="function")throw new Error("invalid validator function");let c=r[i];if(!(s&&c===void 0)&&!a(c,r))throw new Error("param "+String(i)+" is invalid. Expected "+o+", got "+c)};for(let[i,o]of Object.entries(e))n(i,o,!1);for(let[i,o]of Object.entries(t))n(i,o,!0);return r}function Ei(r){let e=new WeakMap;return(t,...n)=>{let i=e.get(t);if(i!==void 0)return i;let o=r(t,...n);return e.set(t,o),o}}var ne=BigInt(0),ee=BigInt(1),Bt=BigInt(2),Ou=BigInt(3),vs=BigInt(4),Ss=BigInt(5),Bs=BigInt(8);function J(r,e){let t=r%e;return t>=ne?t:e+t}function we(r,e,t){let n=r;for(;e-- >ne;)n*=n,n%=t;return n}function Hr(r,e){if(r===ne)throw new Error("invert: expected non-zero number");if(e<=ne)throw new Error("invert: expected positive modulus, got "+e);let t=J(r,e),n=e,i=ne,o=ee,s=ee,a=ne;for(;t!==ne;){let u=n/t,f=n%t,d=i-s*u,l=o-a*u;n=t,t=f,i=s,o=a,s=d,a=l}if(n!==ee)throw new Error("invert: does not exist");return J(i,e)}function Us(r,e){let t=(r.ORDER+ee)/vs,n=r.pow(e,t);if(!r.eql(r.sqr(n),e))throw new Error("Cannot find square root");return n}function Du(r,e){let t=(r.ORDER-Ss)/Bs,n=r.mul(e,Bt),i=r.pow(n,t),o=r.mul(e,i),s=r.mul(r.mul(o,Bt),i),a=r.mul(o,r.sub(s,r.ONE));if(!r.eql(r.sqr(a),e))throw new Error("Cannot find square root");return a}function Nu(r){if(r<BigInt(3))throw new Error("sqrt is not defined for small field");let e=r-ee,t=0;for(;e%Bt===ne;)e/=Bt,t++;let n=Bt,i=lr(r);for(;As(i,n)===1;)if(n++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(t===1)return Us;let o=i.pow(n,e),s=(e+ee)/Bt;return function(c,u){if(c.is0(u))return u;if(As(c,u)!==1)throw new Error("Cannot find square root");let f=t,d=c.mul(c.ONE,o),l=c.pow(u,e),p=c.pow(u,s);for(;!c.eql(l,c.ONE);){if(c.is0(l))return c.ZERO;let h=1,g=c.sqr(l);for(;!c.eql(g,c.ONE);)if(h++,g=c.sqr(g),h===f)throw new Error("Cannot find square root");let U=ee<<BigInt(f-h-1),L=c.pow(d,U);f=h,d=c.sqr(L),l=c.mul(l,d),p=c.mul(p,L)}return p}}function _u(r){return r%vs===Ou?Us:r%Bs===Ss?Du:Nu(r)}var ku=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Ii(r){let e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},t=ku.reduce((n,i)=>(n[i]="function",n),e);return St(r,t)}function Ru(r,e,t){if(t<ne)throw new Error("invalid exponent, negatives unsupported");if(t===ne)return r.ONE;if(t===ee)return e;let n=r.ONE,i=e;for(;t>ne;)t&ee&&(n=r.mul(n,i)),i=r.sqr(i),t>>=ee;return n}function Ai(r,e,t=!1){let n=new Array(e.length).fill(t?r.ZERO:void 0),i=e.reduce((s,a,c)=>r.is0(a)?s:(n[c]=s,r.mul(s,a)),r.ONE),o=r.inv(i);return e.reduceRight((s,a,c)=>r.is0(a)?s:(n[c]=r.mul(s,n[c]),r.mul(s,a)),o),n}function As(r,e){let t=(r.ORDER-ee)/Bt,n=r.pow(e,t),i=r.eql(n,r.ONE),o=r.eql(n,r.ZERO),s=r.eql(n,r.neg(r.ONE));if(!i&&!o&&!s)throw new Error("invalid Legendre symbol result");return i?1:o?0:-1}function vi(r,e){e!==void 0&&kr(e);let t=e!==void 0?e:r.toString(2).length,n=Math.ceil(t/8);return{nBitLength:t,nByteLength:n}}function lr(r,e,t=!1,n={}){if(r<=ne)throw new Error("invalid field: expected ORDER > 0, got "+r);let{nBitLength:i,nByteLength:o}=vi(r,e);if(o>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let s,a=Object.freeze({ORDER:r,isLE:t,BITS:i,BYTES:o,MASK:vt(i),ZERO:ne,ONE:ee,create:c=>J(c,r),isValid:c=>{if(typeof c!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof c);return ne<=c&&c<r},is0:c=>c===ne,isOdd:c=>(c&ee)===ee,neg:c=>J(-c,r),eql:(c,u)=>c===u,sqr:c=>J(c*c,r),add:(c,u)=>J(c+u,r),sub:(c,u)=>J(c-u,r),mul:(c,u)=>J(c*u,r),pow:(c,u)=>Ru(a,c,u),div:(c,u)=>J(c*Hr(u,r),r),sqrN:c=>c*c,addN:(c,u)=>c+u,subN:(c,u)=>c-u,mulN:(c,u)=>c*u,inv:c=>Hr(c,r),sqrt:n.sqrt||(c=>(s||(s=_u(r)),s(a,c))),toBytes:c=>t?bi(c,o):It(c,o),fromBytes:c=>{if(c.length!==o)throw new Error("Field.fromBytes: expected "+o+" bytes, got "+c.length);return t?xi(c):tt(c)},invertBatch:c=>Ai(a,c),cmov:(c,u,f)=>f?u:c});return Object.freeze(a)}function Ls(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 Si(r){let e=Ls(r);return e+Math.ceil(e/2)}function Cs(r,e,t=!1){let n=r.length,i=Ls(e),o=Si(e);if(n<16||n<o||n>1024)throw new Error("expected "+o+"-1024 bytes of input, got "+n);let s=t?xi(r):tt(r),a=J(s,e-ee)+ee;return t?bi(a,i):It(a,i)}var Ts=BigInt(0),Ti=BigInt(1);function Bi(r,e){let t=e.negate();return r?t:e}function Os(r,e){if(!Number.isSafeInteger(r)||r<=0||r>e)throw new Error("invalid window size, expected [1.."+e+"], got W="+r)}function Ui(r,e){Os(r,e);let t=Math.ceil(e/r)+1,n=2**(r-1),i=2**r,o=vt(r),s=BigInt(r);return{windows:t,windowSize:n,mask:o,maxNumber:i,shiftBy:s}}function Ps(r,e,t){let{windowSize:n,mask:i,maxNumber:o,shiftBy:s}=t,a=Number(r&i),c=r>>s;a>n&&(a-=o,c+=Ti);let u=e*n,f=u+Math.abs(a)-1,d=a===0,l=a<0,p=e%2!==0;return{nextN:c,offset:f,isZero:d,isNeg:l,isNegF:p,offsetF:u}}function Ku(r,e){if(!Array.isArray(r))throw new Error("array expected");r.forEach((t,n)=>{if(!(t instanceof e))throw new Error("invalid point at index "+n)})}function Mu(r,e){if(!Array.isArray(r))throw new Error("array of scalars expected");r.forEach((t,n)=>{if(!e.isValid(t))throw new Error("invalid scalar at index "+n)})}var Li=new WeakMap,Ds=new WeakMap;function Ci(r){return Ds.get(r)||1}function Ns(r,e){return{constTimeNegate:Bi,hasPrecomputes(t){return Ci(t)!==1},unsafeLadder(t,n,i=r.ZERO){let o=t;for(;n>Ts;)n&Ti&&(i=i.add(o)),o=o.double(),n>>=Ti;return i},precomputeWindow(t,n){let{windows:i,windowSize:o}=Ui(n,e),s=[],a=t,c=a;for(let u=0;u<i;u++){c=a,s.push(c);for(let f=1;f<o;f++)c=c.add(a),s.push(c);a=c.double()}return s},wNAF(t,n,i){let o=r.ZERO,s=r.BASE,a=Ui(t,e);for(let c=0;c<a.windows;c++){let{nextN:u,offset:f,isZero:d,isNeg:l,isNegF:p,offsetF:h}=Ps(i,c,a);i=u,d?s=s.add(Bi(p,n[h])):o=o.add(Bi(l,n[f]))}return{p:o,f:s}},wNAFUnsafe(t,n,i,o=r.ZERO){let s=Ui(t,e);for(let a=0;a<s.windows&&i!==Ts;a++){let{nextN:c,offset:u,isZero:f,isNeg:d}=Ps(i,a,s);if(i=c,!f){let l=n[u];o=o.add(d?l.negate():l)}}return o},getPrecomputes(t,n,i){let o=Li.get(n);return o||(o=this.precomputeWindow(n,t),t!==1&&Li.set(n,i(o))),o},wNAFCached(t,n,i){let o=Ci(t);return this.wNAF(o,this.getPrecomputes(o,t,i),n)},wNAFCachedUnsafe(t,n,i,o){let s=Ci(t);return s===1?this.unsafeLadder(t,n,o):this.wNAFUnsafe(s,this.getPrecomputes(s,t,i),n,o)},setWindowSize(t,n){Os(n,e),Ds.set(t,n),Li.delete(t)}}}function _s(r,e,t,n){Ku(t,r),Mu(n,e);let i=t.length,o=n.length;if(i!==o)throw new Error("arrays of points and scalars must have equal length");let s=r.ZERO,a=Es(BigInt(i)),c=1;a>12?c=a-3:a>4?c=a-2:a>0&&(c=2);let u=vt(c),f=new Array(Number(u)+1).fill(s),d=Math.floor((e.BITS-1)/c)*c,l=s;for(let p=d;p>=0;p-=c){f.fill(s);for(let g=0;g<o;g++){let U=n[g],L=Number(U>>BigInt(p)&u);f[L]=f[L].add(t[g])}let h=s;for(let g=f.length-1,U=s;g>0;g--)U=U.add(f[g]),h=h.add(U);if(l=l.add(h),p!==0)for(let g=0;g<c;g++)l=l.double()}return l}function Pi(r){return Ii(r.Fp),St(r,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...vi(r.n,r.nBitLength),...r,p:r.Fp.ORDER})}function ks(r){r.lowS!==void 0&&Vt("lowS",r.lowS),r.prehash!==void 0&&Vt("prehash",r.prehash)}function Fu(r){let e=Pi(r);St(e,{a:"field",b:"field"},{allowInfinityPoint:"boolean",allowedPrivateKeyLengths:"array",clearCofactor:"function",fromBytes:"function",isTorsionFree:"function",toBytes:"function",wrapPrivateKey:"boolean"});let{endo:t,Fp:n,a:i}=e;if(t){if(!n.eql(i,n.ZERO))throw new Error("invalid endo: CURVE.a must be 0");if(typeof t!="object"||typeof t.beta!="bigint"||typeof t.splitScalar!="function")throw new Error('invalid endo: expected "beta": bigint and "splitScalar": function')}return Object.freeze({...e})}var Ni=class extends Error{constructor(e=""){super(e)}},rt={Err:Ni,_tlv:{encode:(r,e)=>{let{Err:t}=rt;if(r<0||r>256)throw new t("tlv.encode: wrong tag");if(e.length&1)throw new t("tlv.encode: unpadded data");let n=e.length/2,i=ar(n);if(i.length/2&128)throw new t("tlv.encode: long form length too big");let o=n>127?ar(i.length/2|128):"";return ar(r)+o+i+e},decode(r,e){let{Err:t}=rt,n=0;if(r<0||r>256)throw new t("tlv.encode: wrong tag");if(e.length<2||e[n++]!==r)throw new t("tlv.decode: wrong tlv");let i=e[n++],o=!!(i&128),s=0;if(!o)s=i;else{let c=i&127;if(!c)throw new t("tlv.decode(long): indefinite length not supported");if(c>4)throw new t("tlv.decode(long): byte length is too big");let u=e.subarray(n,n+c);if(u.length!==c)throw new t("tlv.decode: length bytes not complete");if(u[0]===0)throw new t("tlv.decode(long): zero leftmost byte");for(let f of u)s=s<<8|f;if(n+=c,s<128)throw new t("tlv.decode(long): not minimal encoding")}let a=e.subarray(n,n+s);if(a.length!==s)throw new t("tlv.decode: wrong value length");return{v:a,l:e.subarray(n+s)}}},_int:{encode(r){let{Err:e}=rt;if(r<nt)throw new e("integer: negative integers are not allowed");let t=ar(r);if(Number.parseInt(t[0],16)&8&&(t="00"+t),t.length&1)throw new e("unexpected DER parsing assertion: unpadded hex");return t},decode(r){let{Err:e}=rt;if(r[0]&128)throw new e("invalid signature integer: negative");if(r[0]===0&&!(r[1]&128))throw new e("invalid signature integer: unnecessary leading zero");return tt(r)}},toSig(r){let{Err:e,_int:t,_tlv:n}=rt,i=ae("signature",r),{v:o,l:s}=n.decode(48,i);if(s.length)throw new e("invalid signature: left bytes after parsing");let{v:a,l:c}=n.decode(2,o),{v:u,l:f}=n.decode(2,c);if(f.length)throw new e("invalid signature: left bytes after parsing");return{r:t.decode(a),s:t.decode(u)}},hexFromSig(r){let{_tlv:e,_int:t}=rt,n=e.encode(2,t.encode(r.r)),i=e.encode(2,t.encode(r.s)),o=n+i;return e.encode(48,o)}};function Oi(r,e){return zt(It(r,e))}var nt=BigInt(0),Y=BigInt(1),up=BigInt(2),Di=BigInt(3),Hu=BigInt(4);function qu(r){let e=Fu(r),{Fp:t}=e,n=lr(e.n,e.nBitLength),i=e.toBytes||((v,m,y)=>{let E=m.toAffine();return dr(Uint8Array.from([4]),t.toBytes(E.x),t.toBytes(E.y))}),o=e.fromBytes||(v=>{let m=v.subarray(1),y=t.fromBytes(m.subarray(0,t.BYTES)),E=t.fromBytes(m.subarray(t.BYTES,2*t.BYTES));return{x:y,y:E}});function s(v){let{a:m,b:y}=e,E=t.sqr(v),B=t.mul(E,v);return t.add(t.add(B,t.mul(v,m)),y)}function a(v,m){let y=t.sqr(m),E=s(v);return t.eql(y,E)}if(!a(e.Gx,e.Gy))throw new Error("bad curve params: generator point");let c=t.mul(t.pow(e.a,Di),Hu),u=t.mul(t.sqr(e.b),BigInt(27));if(t.is0(t.add(c,u)))throw new Error("bad curve params: a or b");function f(v){return Fr(v,Y,e.n)}function d(v){let{allowedPrivateKeyLengths:m,nByteLength:y,wrapPrivateKey:E,n:B}=e;if(m&&typeof v!="bigint"){if(qt(v)&&(v=zt(v)),typeof v!="string"||!m.includes(v.length))throw new Error("invalid private key");v=v.padStart(y*2,"0")}let T;try{T=typeof v=="bigint"?v:tt(ae("private key",v,y))}catch{throw new Error("invalid private key, expected hex or "+y+" bytes, got "+typeof v)}return E&&(T=J(T,B)),At("private key",T,Y,B),T}function l(v){if(!(v instanceof g))throw new Error("ProjectivePoint expected")}let p=Ei((v,m)=>{let{px:y,py:E,pz:B}=v;if(t.eql(B,t.ONE))return{x:y,y:E};let T=v.is0();m==null&&(m=T?t.ONE:t.inv(B));let K=t.mul(y,m),M=t.mul(E,m),C=t.mul(B,m);if(T)return{x:t.ZERO,y:t.ZERO};if(!t.eql(C,t.ONE))throw new Error("invZ was invalid");return{x:K,y:M}}),h=Ei(v=>{if(v.is0()){if(e.allowInfinityPoint&&!t.is0(v.py))return;throw new Error("bad point: ZERO")}let{x:m,y}=v.toAffine();if(!t.isValid(m)||!t.isValid(y))throw new Error("bad point: x or y not FE");if(!a(m,y))throw new Error("bad point: equation left != right");if(!v.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class g{constructor(m,y,E){if(m==null||!t.isValid(m))throw new Error("x required");if(y==null||!t.isValid(y)||t.is0(y))throw new Error("y required");if(E==null||!t.isValid(E))throw new Error("z required");this.px=m,this.py=y,this.pz=E,Object.freeze(this)}static fromAffine(m){let{x:y,y:E}=m||{};if(!m||!t.isValid(y)||!t.isValid(E))throw new Error("invalid affine point");if(m instanceof g)throw new Error("projective point not allowed");let B=T=>t.eql(T,t.ZERO);return B(y)&&B(E)?g.ZERO:new g(y,E,t.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(m){let y=Ai(t,m.map(E=>E.pz));return m.map((E,B)=>E.toAffine(y[B])).map(g.fromAffine)}static fromHex(m){let y=g.fromAffine(o(ae("pointHex",m)));return y.assertValidity(),y}static fromPrivateKey(m){return g.BASE.multiply(d(m))}static msm(m,y){return _s(g,n,m,y)}_setWindowSize(m){R.setWindowSize(this,m)}assertValidity(){h(this)}hasEvenY(){let{y:m}=this.toAffine();if(t.isOdd)return!t.isOdd(m);throw new Error("Field doesn't support isOdd")}equals(m){l(m);let{px:y,py:E,pz:B}=this,{px:T,py:K,pz:M}=m,C=t.eql(t.mul(y,M),t.mul(T,B)),k=t.eql(t.mul(E,M),t.mul(K,B));return C&&k}negate(){return new g(this.px,t.neg(this.py),this.pz)}double(){let{a:m,b:y}=e,E=t.mul(y,Di),{px:B,py:T,pz:K}=this,M=t.ZERO,C=t.ZERO,k=t.ZERO,P=t.mul(B,B),X=t.mul(T,T),x=t.mul(K,K),w=t.mul(B,T);return w=t.add(w,w),k=t.mul(B,K),k=t.add(k,k),M=t.mul(m,k),C=t.mul(E,x),C=t.add(M,C),M=t.sub(X,C),C=t.add(X,C),C=t.mul(M,C),M=t.mul(w,M),k=t.mul(E,k),x=t.mul(m,x),w=t.sub(P,x),w=t.mul(m,w),w=t.add(w,k),k=t.add(P,P),P=t.add(k,P),P=t.add(P,x),P=t.mul(P,w),C=t.add(C,P),x=t.mul(T,K),x=t.add(x,x),P=t.mul(x,w),M=t.sub(M,P),k=t.mul(x,X),k=t.add(k,k),k=t.add(k,k),new g(M,C,k)}add(m){l(m);let{px:y,py:E,pz:B}=this,{px:T,py:K,pz:M}=m,C=t.ZERO,k=t.ZERO,P=t.ZERO,X=e.a,x=t.mul(e.b,Di),w=t.mul(y,T),S=t.mul(E,K),_=t.mul(B,M),O=t.add(y,E),N=t.add(T,K);O=t.mul(O,N),N=t.add(w,S),O=t.sub(O,N),N=t.add(y,B);let V=t.add(T,M);return N=t.mul(N,V),V=t.add(w,_),N=t.sub(N,V),V=t.add(E,B),C=t.add(K,M),V=t.mul(V,C),C=t.add(S,_),V=t.sub(V,C),P=t.mul(X,N),C=t.mul(x,_),P=t.add(C,P),C=t.sub(S,P),P=t.add(S,P),k=t.mul(C,P),S=t.add(w,w),S=t.add(S,w),_=t.mul(X,_),N=t.mul(x,N),S=t.add(S,_),_=t.sub(w,_),_=t.mul(X,_),N=t.add(N,_),w=t.mul(S,N),k=t.add(k,w),w=t.mul(V,N),C=t.mul(O,C),C=t.sub(C,w),w=t.mul(O,S),P=t.mul(V,P),P=t.add(P,w),new g(C,k,P)}subtract(m){return this.add(m.negate())}is0(){return this.equals(g.ZERO)}wNAF(m){return R.wNAFCached(this,m,g.normalizeZ)}multiplyUnsafe(m){let{endo:y,n:E}=e;At("scalar",m,nt,E);let B=g.ZERO;if(m===nt)return B;if(this.is0()||m===Y)return this;if(!y||R.hasPrecomputes(this))return R.wNAFCachedUnsafe(this,m,g.normalizeZ);let{k1neg:T,k1:K,k2neg:M,k2:C}=y.splitScalar(m),k=B,P=B,X=this;for(;K>nt||C>nt;)K&Y&&(k=k.add(X)),C&Y&&(P=P.add(X)),X=X.double(),K>>=Y,C>>=Y;return T&&(k=k.negate()),M&&(P=P.negate()),P=new g(t.mul(P.px,y.beta),P.py,P.pz),k.add(P)}multiply(m){let{endo:y,n:E}=e;At("scalar",m,Y,E);let B,T;if(y){let{k1neg:K,k1:M,k2neg:C,k2:k}=y.splitScalar(m),{p:P,f:X}=this.wNAF(M),{p:x,f:w}=this.wNAF(k);P=R.constTimeNegate(K,P),x=R.constTimeNegate(C,x),x=new g(t.mul(x.px,y.beta),x.py,x.pz),B=P.add(x),T=X.add(w)}else{let{p:K,f:M}=this.wNAF(m);B=K,T=M}return g.normalizeZ([B,T])[0]}multiplyAndAddUnsafe(m,y,E){let B=g.BASE,T=(M,C)=>C===nt||C===Y||!M.equals(B)?M.multiplyUnsafe(C):M.multiply(C),K=T(this,y).add(T(m,E));return K.is0()?void 0:K}toAffine(m){return p(this,m)}isTorsionFree(){let{h:m,isTorsionFree:y}=e;if(m===Y)return!0;if(y)return y(g,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h:m,clearCofactor:y}=e;return m===Y?this:y?y(g,this):this.multiplyUnsafe(e.h)}toRawBytes(m=!0){return Vt("isCompressed",m),this.assertValidity(),i(g,this,m)}toHex(m=!0){return Vt("isCompressed",m),zt(this.toRawBytes(m))}}g.BASE=new g(e.Gx,e.Gy,t.ONE),g.ZERO=new g(t.ZERO,t.ONE,t.ZERO);let{endo:U,nBitLength:L}=e,R=Ns(g,U?Math.ceil(L/2):L);return{CURVE:e,ProjectivePoint:g,normPrivateKeyToScalar:d,weierstrassEquation:s,isWithinCurveOrder:f}}function Vu(r){let e=Pi(r);return St(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function Rs(r){let e=Vu(r),{Fp:t,n,nByteLength:i,nBitLength:o}=e,s=t.BYTES+1,a=2*t.BYTES+1;function c(x){return J(x,n)}function u(x){return Hr(x,n)}let{ProjectivePoint:f,normPrivateKeyToScalar:d,weierstrassEquation:l,isWithinCurveOrder:p}=qu({...e,toBytes(x,w,S){let _=w.toAffine(),O=t.toBytes(_.x),N=dr;return Vt("isCompressed",S),S?N(Uint8Array.from([w.hasEvenY()?2:3]),O):N(Uint8Array.from([4]),O,t.toBytes(_.y))},fromBytes(x){let w=x.length,S=x[0],_=x.subarray(1);if(w===s&&(S===2||S===3)){let O=tt(_);if(!Fr(O,Y,t.ORDER))throw new Error("Point is not on curve");let N=l(O),V;try{V=t.sqrt(N)}catch(Ae){let ie=Ae instanceof Error?": "+Ae.message:"";throw new Error("Point is not on curve"+ie)}let te=(V&Y)===Y;return(S&1)===1!==te&&(V=t.neg(V)),{x:O,y:V}}else if(w===a&&S===4){let O=t.fromBytes(_.subarray(0,t.BYTES)),N=t.fromBytes(_.subarray(t.BYTES,2*t.BYTES));return{x:O,y:N}}else{let O=s,N=a;throw new Error("invalid Point, expected length of "+O+", or uncompressed "+N+", got "+w)}}});function h(x){let w=n>>Y;return x>w}function g(x){return h(x)?c(-x):x}let U=(x,w,S)=>tt(x.slice(w,S));class L{constructor(w,S,_){At("r",w,Y,n),At("s",S,Y,n),this.r=w,this.s=S,_!=null&&(this.recovery=_),Object.freeze(this)}static fromCompact(w){let S=i;return w=ae("compactSignature",w,S*2),new L(U(w,0,S),U(w,S,2*S))}static fromDER(w){let{r:S,s:_}=rt.toSig(ae("DER",w));return new L(S,_)}assertValidity(){}addRecoveryBit(w){return new L(this.r,this.s,w)}recoverPublicKey(w){let{r:S,s:_,recovery:O}=this,N=B(ae("msgHash",w));if(O==null||![0,1,2,3].includes(O))throw new Error("recovery id invalid");let V=O===2||O===3?S+e.n:S;if(V>=t.ORDER)throw new Error("recovery id 2 or 3 invalid");let te=(O&1)===0?"02":"03",Me=f.fromHex(te+Oi(V,t.BYTES)),Ae=u(V),ie=c(-N*Ae),Ut=c(_*Ae),it=f.BASE.multiplyAndAddUnsafe(Me,ie,Ut);if(!it)throw new Error("point at infinify");return it.assertValidity(),it}hasHighS(){return h(this.s)}normalizeS(){return this.hasHighS()?new L(this.r,c(-this.s),this.recovery):this}toDERRawBytes(){return ur(this.toDERHex())}toDERHex(){return rt.hexFromSig(this)}toCompactRawBytes(){return ur(this.toCompactHex())}toCompactHex(){let w=i;return Oi(this.r,w)+Oi(this.s,w)}}let R={isValidPrivateKey(x){try{return d(x),!0}catch{return!1}},normPrivateKeyToScalar:d,randomPrivateKey:()=>{let x=Si(e.n);return Cs(e.randomBytes(x),e.n)},precompute(x=8,w=f.BASE){return w._setWindowSize(x),w.multiply(BigInt(3)),w}};function v(x,w=!0){return f.fromPrivateKey(x).toRawBytes(w)}function m(x){if(typeof x=="bigint")return!1;if(x instanceof f)return!0;let S=ae("key",x).length,_=t.BYTES,O=_+1,N=2*_+1;if(!(e.allowedPrivateKeyLengths||i===O))return S===O||S===N}function y(x,w,S=!0){if(m(x)===!0)throw new Error("first arg must be private key");if(m(w)===!1)throw new Error("second arg must be public key");return f.fromHex(w).multiply(d(x)).toRawBytes(S)}let E=e.bits2int||function(x){if(x.length>8192)throw new Error("input is too large");let w=tt(x),S=x.length*8-o;return S>0?w>>BigInt(S):w},B=e.bits2int_modN||function(x){return c(E(x))},T=vt(o);function K(x){return At("num < 2^"+o,x,nt,T),It(x,i)}function M(x,w,S=C){if(["recovered","canonical"].some(ut=>ut in S))throw new Error("sign() legacy options not supported");let{hash:_,randomBytes:O}=e,{lowS:N,prehash:V,extraEntropy:te}=S;N==null&&(N=!0),x=ae("msgHash",x),ks(S),V&&(x=ae("prehashed msgHash",_(x)));let Me=B(x),Ae=d(w),ie=[K(Ae),K(Me)];if(te!=null&&te!==!1){let ut=te===!0?O(t.BYTES):te;ie.push(ae("extraEntropy",ut))}let Ut=dr(...ie),it=Me;function Jr(ut){let Lt=E(ut);if(!p(Lt))return;let en=u(Lt),Gt=f.BASE.multiply(Lt).toAffine(),dt=c(Gt.x);if(dt===nt)return;let $t=c(en*c(it+dt*Ae));if($t===nt)return;let Ct=(Gt.x===dt?0:2)|Number(Gt.y&Y),Xi=$t;return N&&h($t)&&(Xi=g($t),Ct^=1),new L(dt,Xi,Ct)}return{seed:Ut,k2sig:Jr}}let C={lowS:e.lowS,prehash:!1},k={lowS:e.lowS,prehash:!1};function P(x,w,S=C){let{seed:_,k2sig:O}=M(x,w,S),N=e;return Is(N.hash.outputLen,N.nByteLength,N.hmac)(_,O)}f.BASE._setWindowSize(8);function X(x,w,S,_=k){let O=x;w=ae("msgHash",w),S=ae("publicKey",S);let{lowS:N,prehash:V,format:te}=_;if(ks(_),"strict"in _)throw new Error("options.strict was renamed to lowS");if(te!==void 0&&te!=="compact"&&te!=="der")throw new Error("format must be compact or der");let Me=typeof O=="string"||qt(O),Ae=!Me&&!te&&typeof O=="object"&&O!==null&&typeof O.r=="bigint"&&typeof O.s=="bigint";if(!Me&&!Ae)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let ie,Ut;try{if(Ae&&(ie=new L(O.r,O.s)),Me){try{te!=="compact"&&(ie=L.fromDER(O))}catch(Ct){if(!(Ct instanceof rt.Err))throw Ct}!ie&&te!=="der"&&(ie=L.fromCompact(O))}Ut=f.fromHex(S)}catch{return!1}if(!ie||N&&ie.hasHighS())return!1;V&&(w=e.hash(w));let{r:it,s:Jr}=ie,ut=B(w),Lt=u(Jr),en=c(ut*Lt),Gt=c(it*Lt),dt=f.BASE.multiplyAndAddUnsafe(Ut,en,Gt)?.toAffine();return dt?c(dt.x)===it:!1}return{CURVE:e,getPublicKey:v,getSharedSecret:y,sign:P,verify:X,ProjectivePoint:f,Signature:L,utils:R}}function zu(r){return{hash:r,hmac:(e,...t)=>pi(r,e,ls(...t)),randomBytes:ps}}function Ks(r,e){let t=n=>Rs({...r,...zu(n)});return{...t(e),create:t}}var Hs=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),Ms=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),ju=BigInt(0),Gu=BigInt(1),_i=BigInt(2),Fs=(r,e)=>(r+e/_i)/e;function $u(r){let e=Hs,t=BigInt(3),n=BigInt(6),i=BigInt(11),o=BigInt(22),s=BigInt(23),a=BigInt(44),c=BigInt(88),u=r*r*r%e,f=u*u*r%e,d=we(f,t,e)*f%e,l=we(d,t,e)*f%e,p=we(l,_i,e)*u%e,h=we(p,i,e)*p%e,g=we(h,o,e)*h%e,U=we(g,a,e)*g%e,L=we(U,c,e)*U%e,R=we(L,a,e)*g%e,v=we(R,t,e)*f%e,m=we(v,s,e)*h%e,y=we(m,n,e)*u%e,E=we(y,_i,e);if(!ki.eql(ki.sqr(E),r))throw new Error("Cannot find square root");return E}var ki=lr(Hs,void 0,void 0,{sqrt:$u}),hr=Ks({a:ju,b:BigInt(7),Fp:ki,n:Ms,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:r=>{let e=Ms,t=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-Gu*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),i=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),o=t,s=BigInt("0x100000000000000000000000000000000"),a=Fs(o*r,e),c=Fs(-n*r,e),u=J(r-a*t-c*i,e),f=J(-a*n-c*o,e),d=u>s,l=f>s;if(d&&(u=e-u),l&&(f=e-f),u>s||f>s)throw new Error("splitScalar: Endomorphism failed, k="+r);return{k1neg:d,k1:u,k2neg:l,k2:f}}}},ms);var qr=class extends Error{constructor(e="An error occurred while verifying a message"){super(e),this.name="VerificationError"}};function Vs(r,e,t){let n=qs.default.createHash("sha256");if(t instanceof Uint8Array)n.update(t);else for(let o of t)n.update(o);let i=n.digest();try{return hr.verify(e,i,r)}catch(o){throw new qr(String(o))}}var Vr=class{type="secp256k1";raw;_key;constructor(e){this._key=js(e),this.raw=zs(this._key)}toMultihash(){return Ue.digest(Rt(this))}toCID(){return G.createV1(114,this.toMultihash())}toString(){return z.encode(this.toMultihash().bytes).substring(1)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:pe(this.raw,e.raw)}verify(e,t){return Vs(this._key,t,e)}};function Gs(r){return new Vr(r)}function zs(r){return hr.ProjectivePoint.fromHex(r).toRawBytes(!0)}function js(r){try{return hr.ProjectivePoint.fromHex(r),r}catch(e){throw new wr(String(e))}}function $s(r){let{Type:e,Data:t}=sr.decode(r.digest),n=t??new Uint8Array;switch(e){case ye.Ed25519:return Jo(n);case ye.secp256k1:return Gs(n);case ye.ECDSA:return Yo(n);default:throw new Yt}}function Rt(r){return sr.encode({Type:ye[r.type],Data:r.raw})}var Ys=Symbol.for("nodejs.util.inspect.custom"),Yu=114,pr=class{type;multihash;publicKey;string;constructor(e){this.type=e.type,this.multihash=e.multihash,Object.defineProperty(this,"string",{enumerable:!1,writable:!0})}get[Symbol.toStringTag](){return`PeerId(${this.toString()})`}[tn]=!0;toString(){return this.string==null&&(this.string=z.encode(this.multihash.bytes).slice(1)),this.string}toMultihash(){return this.multihash}toCID(){return G.createV1(Yu,this.multihash)}toJSON(){return this.toString()}equals(e){if(e==null)return!1;if(e instanceof Uint8Array)return pe(this.multihash.bytes,e);if(typeof e=="string")return this.toString()===e;if(e?.toMultihash()?.bytes!=null)return pe(this.multihash.bytes,e.toMultihash().bytes);throw new Error("not valid Id")}[Ys](){return`PeerId(${this.toString()})`}},zr=class extends pr{type="RSA";publicKey;constructor(e){super({...e,type:"RSA"}),this.publicKey=e.publicKey}},jr=class extends pr{type="Ed25519";publicKey;constructor(e){super({...e,type:"Ed25519"}),this.publicKey=e.publicKey}},Gr=class extends pr{type="secp256k1";publicKey;constructor(e){super({...e,type:"secp256k1"}),this.publicKey=e.publicKey}},Wu=2336,fr=class{type="url";multihash;publicKey;url;constructor(e){this.url=e.toString(),this.multihash=Ue.digest(Ee(this.url))}[Ys](){return`PeerId(${this.url})`}[tn]=!0;toString(){return this.toCID().toString()}toMultihash(){return this.multihash}toCID(){return G.createV1(Wu,this.toMultihash())}toJSON(){return this.toString()}equals(e){return e==null?!1:(e instanceof Uint8Array&&(e=H(e)),e.toString()===this.toString())}};var Xu=114,Ws=2336;function Xs(r,e){let t;if(r.charAt(0)==="1"||r.charAt(0)==="Q")t=pt(z.decode(`z${r}`));else{if(r.startsWith("k51qzi5uqu5")||r.startsWith("kzwfwjn5ji4")||r.startsWith("k2k4r8")||r.startsWith("bafz"))return Zu(G.parse(r));if(e==null)throw new Pe('Please pass a multibase decoder for strings that do not start with "1" or "Q"');t=pt(e.decode(r))}return Zs(t)}function Zs(r){if(Ju(r))return new zr({multihash:r});if(Qu(r))try{let e=$s(r);if(e.type==="Ed25519")return new jr({multihash:r,publicKey:e});if(e.type==="secp256k1")return new Gr({multihash:r,publicKey:e})}catch{let t=H(r.digest);return new fr(new URL(t))}throw new br("Supplied PeerID Multihash is invalid")}function Zu(r){if(r?.multihash==null||r.version==null||r.version===1&&r.code!==Xu&&r.code!==Ws)throw new xr("Supplied PeerID CID is invalid");if(r.code===Ws){let e=H(r.multihash.digest);return new fr(new URL(e))}return Zs(r.multihash)}function Qu(r){return r.code===Ue.code}function Ju(r){return r.code===kn.code}var Ie=oe("node:net");function $r(r){return!!(0,Ie.isIP)(r)}var Js=Tt(Qs(),1),ed=["0.0.0.0/8","10.0.0.0/8","100.64.0.0/10","127.0.0.0/8","169.254.0.0/16","172.16.0.0/12","192.0.0.0/24","192.0.0.0/29","192.0.0.8/32","192.0.0.9/32","192.0.0.10/32","192.0.0.170/32","192.0.0.171/32","192.0.2.0/24","192.31.196.0/24","192.52.193.0/24","192.88.99.0/24","192.168.0.0/16","192.175.48.0/24","198.18.0.0/15","198.51.100.0/24","203.0.113.0/24","240.0.0.0/4","255.255.255.255/32"],td=ed.map(r=>new Js.Netmask(r));function Ri(r){for(let e of td)if(e.contains(r))return!0;return!1}function rd(r){return/^::ffff:([0-9a-fA-F]{1,4}):([0-9a-fA-F]{1,4})$/.test(r)}function nd(r){let e=r.split(":");if(e.length<2)return!1;let t=e[e.length-1].padStart(4,"0"),n=e[e.length-2].padStart(4,"0"),i=`${parseInt(n.substring(0,2),16)}.${parseInt(n.substring(2),16)}.${parseInt(t.substring(0,2),16)}.${parseInt(t.substring(2),16)}`;return Ri(i)}function id(r){return/^::ffff:([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(r)}function od(r){let e=r.split(":"),t=e[e.length-1];return Ri(t)}function sd(r){return/^::$/.test(r)||/^::1$/.test(r)||/^64:ff9b::([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(r)||/^100::([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^2001::([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^2001:2[0-9a-fA-F]:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^2001:db8:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^2002:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^f[c-d]([0-9a-fA-F]{2,2}):/i.test(r)||/^fe[8-9a-bA-B][0-9a-fA-F]:/i.test(r)||/^ff([0-9a-fA-F]{2,2}):/i.test(r)}function ec(r){return(0,Ie.isIPv4)(r)?Ri(r):rd(r)?nd(r):id(r)?od(r):(0,Ie.isIPv6)(r)?sd(r):void 0}function tc(r){try{let[[e]]=r.stringTuples();return e===4||e===41}catch{}return!1}function rc(r){try{if(!tc(r))return!1;let[[,e]]=r.stringTuples();return e==null?!1:ec(e)??!1}catch{}return!0}var Yr=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,i){return this.readAtomically(()=>{let o=0,s=0,a=this.peekChar();if(a===void 0)return;let c=a==="0",u=2**(8*i)-1;for(;;){let f=this.readAtomically(()=>{let d=this.readChar();if(d===void 0)return;let l=Number.parseInt(d,e);if(!Number.isNaN(l))return l});if(f===void 0)break;if(o*=e,o+=f,o>u||(s+=1,t!==void 0&&s>t))return}if(s!==0)return!n&&c&&s>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 i=n*2;if(n<t.length-3){let s=this.readSeparator(":",n,()=>this.readIPv4Addr());if(s!==void 0)return t[i]=s[0],t[i+1]=s[1],t[i+2]=s[2],t[i+3]=s[3],[i+4,!0]}let o=this.readSeparator(":",n,()=>this.readNumber(16,4,!0,2));if(o===void 0)return[i,!1];t[i]=o>>8,t[i+1]=o&255}return[t.length,!1]};return this.readAtomically(()=>{let t=new Uint8Array(16),[n,i]=e(t);if(n===16)return t;if(i||this.readGivenChar(":")===void 0||this.readGivenChar(":")===void 0)return;let o=new Uint8Array(14),s=16-(n+2),[a]=e(o.subarray(0,s));return t.set(o.subarray(0,a),16-a),t})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var Lf=new Yr;var kf=parseInt("0xFFFF",16),Rf=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);var oc=Ie.isIPv4,hd=Ie.isIPv6,Ki=function(r){let e=0;if(r=r.toString().trim(),oc(r)){let t=new Uint8Array(e+4);return r.split(/\./g).forEach(n=>{t[e++]=parseInt(n,10)&255}),t}if(hd(r)){let t=r.split(":",8),n;for(n=0;n<t.length;n++){let o=oc(t[n]),s;o&&(s=Ki(t[n]),t[n]=H(s.slice(0,2),"base16")),s!=null&&++n<8&&t.splice(n,0,H(s.slice(2,4),"base16"))}if(t[0]==="")for(;t.length<8;)t.unshift("0");else if(t[t.length-1]==="")for(;t.length<8;)t.push("0");else if(t.length<8){for(n=0;n<t.length&&t[n]!=="";n++);let o=[n,1];for(n=9-t.length;n>0;n--)o.push("0");t.splice.apply(t,o)}let i=new Uint8Array(e+16);for(n=0;n<t.length;n++){let o=parseInt(t[n],16);i[e++]=o>>8&255,i[e++]=o&255}return i}throw new Error("invalid ip address")},sc=function(r,e=0,t){e=~~e,t=t??r.length-e;let n=new DataView(r.buffer);if(t===4){let i=[];for(let o=0;o<t;o++)i.push(r[e+o]);return i.join(".")}if(t===16){let i=[];for(let o=0;o<t;o+=2)i.push(n.getUint16(e+o).toString(16));return i.join(":").replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}return""};var jt={},Mi={},fd=[[4,32,"ip4"],[6,16,"tcp"],[33,16,"dccp"],[41,128,"ip6"],[42,-1,"ip6zone"],[43,8,"ipcidr"],[53,-1,"dns",!0],[54,-1,"dns4",!0],[55,-1,"dns6",!0],[56,-1,"dnsaddr",!0],[132,16,"sctp"],[273,16,"udp"],[275,0,"p2p-webrtc-star"],[276,0,"p2p-webrtc-direct"],[277,0,"p2p-stardust"],[280,0,"webrtc-direct"],[281,0,"webrtc"],[290,0,"p2p-circuit"],[301,0,"udt"],[302,0,"utp"],[400,-1,"unix",!1,!0],[421,-1,"ipfs"],[421,-1,"p2p"],[443,0,"https"],[444,96,"onion"],[445,296,"onion3"],[446,-1,"garlic64"],[448,0,"tls"],[449,-1,"sni"],[460,0,"quic"],[461,0,"quic-v1"],[465,0,"webtransport"],[466,-1,"certhash"],[477,0,"ws"],[478,0,"wss"],[479,0,"p2p-websocket-star"],[480,0,"http"],[481,-1,"http-path"],[777,-1,"memory"]];fd.forEach(r=>{let e=gd(...r);Mi[e.code]=e,jt[e.name]=e});function gd(r,e,t,n,i){return{code:r,size:e,name:t,resolvable:!!n,path:!!i}}function q(r){if(typeof r=="number"){if(Mi[r]!=null)return Mi[r];throw new Error(`no protocol with code: ${r}`)}else if(typeof r=="string"){if(jt[r]!=null)return jt[r];throw new Error(`no protocol with name: ${r}`)}throw new Error(`invalid protocol id type: ${typeof r}`)}var bg=q("ip4"),Eg=q("ip6"),Ig=q("ipcidr");function Vi(r,e){switch(q(r).code){case 4:case 41:return yd(e);case 42:return qi(e);case 43:return H(e,"base10");case 6:case 273:case 33:case 132:return uc(e).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return qi(e);case 421:return Ed(e);case 444:return ac(e);case 445:return ac(e);case 466:return bd(e);case 481:return globalThis.encodeURIComponent(qi(e));default:return H(e,"base16")}}function zi(r,e){switch(q(r).code){case 4:return cc(e);case 41:return cc(e);case 42:return Hi(e);case 43:return Ee(e,"base10");case 6:case 273:case 33:case 132:return ji(parseInt(e,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return Hi(e);case 421:return wd(e);case 444:return Id(e);case 445:return Ad(e);case 466:return xd(e);case 481:return Hi(globalThis.decodeURIComponent(e));default:return Ee(e,"base16")}}var Fi=Object.values(er).map(r=>r.decoder),md=function(){let r=Fi[0].or(Fi[1]);return Fi.slice(2).forEach(e=>r=r.or(e)),r}();function cc(r){if(!$r(r))throw new Error("invalid ip address");return Ki(r)}function yd(r){let e=sc(r,0,r.length);if(e==null)throw new Error("ipBuff is required");if(!$r(e))throw new Error("invalid ip address");return e}function ji(r){let e=new ArrayBuffer(2);return new DataView(e).setUint16(0,r),new Uint8Array(e)}function uc(r){return new DataView(r.buffer).getUint16(r.byteOffset)}function Hi(r){let e=Ee(r),t=Uint8Array.from(Kt(e.length));return fe([t,e],t.length+e.length)}function qi(r){let e=mt(r);if(r=r.slice(ce(e)),r.length!==e)throw new Error("inconsistent lengths");return H(r)}function wd(r){let e;r[0]==="Q"||r[0]==="1"?e=pt(z.decode(`z${r}`)).bytes:e=G.parse(r).multihash.bytes;let t=Uint8Array.from(Kt(e.length));return fe([t,e],t.length+e.length)}function xd(r){let e=md.decode(r),t=Uint8Array.from(Kt(e.length));return fe([t,e],t.length+e.length)}function bd(r){let e=mt(r),t=r.slice(ce(e));if(t.length!==e)throw new Error("inconsistent lengths");return"u"+H(t,"base64url")}function Ed(r){let e=mt(r),t=r.slice(ce(e));if(t.length!==e)throw new Error("inconsistent lengths");return H(t,"base58btc")}function Id(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=Xe.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 i=ji(n);return fe([t,i],t.length+i.length)}function Ad(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=Xe.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 i=ji(n);return fe([t,i],t.length+i.length)}function ac(r){let e=r.slice(0,r.length-2),t=r.slice(r.length-2),n=H(e,"base32"),i=uc(t);return`${n}:${i}`}function dc(r){r=Gi(r);let e=[],t=[],n=null,i=r.split("/").slice(1);if(i.length===1&&i[0]==="")return{bytes:new Uint8Array,string:"/",tuples:[],stringTuples:[],path:null};for(let o=0;o<i.length;o++){let s=i[o],a=q(s);if(a.size===0){e.push([a.code]),t.push([a.code]);continue}if(o++,o>=i.length)throw new Wr("invalid address: "+r);if(a.path===!0){n=Gi(i.slice(o).join("/")),e.push([a.code,zi(a.code,n)]),t.push([a.code,n]);break}let c=zi(a.code,i[o]);e.push([a.code,c]),t.push([a.code,Vi(a.code,c)])}return{string:lc(t),bytes:Xr(e),tuples:e,stringTuples:t,path:n}}function $i(r){let e=[],t=[],n=null,i=0;for(;i<r.length;){let o=mt(r,i),s=ce(o),a=q(o),c=vd(a,r.slice(i+s));if(c===0){e.push([o]),t.push([o]),i+=s;continue}let u=r.slice(i+s,i+s+c);if(i+=c+s,i>r.length)throw new Wr("Invalid address Uint8Array: "+H(r,"base16"));e.push([o,u]);let f=Vi(o,u);if(t.push([o,f]),a.path===!0){n=f;break}}return{bytes:Uint8Array.from(r),string:lc(t),tuples:e,stringTuples:t,path:n}}function lc(r){let e=[];return r.map(t=>{let n=q(t[0]);return e.push(n.name),t.length>1&&t[1]!=null&&e.push(t[1]),null}),Gi(e.join("/"))}function Xr(r){return fe(r.map(e=>{let t=q(e[0]),n=Uint8Array.from(Kt(t.code));return e.length>1&&e[1]!=null&&(n=fe([n,e[1]])),n}))}function vd(r,e){if(r.size>0)return r.size/8;if(r.size===0)return 0;{let t=mt(e instanceof Uint8Array?e:Uint8Array.from(e));return t+ce(t)}}function Gi(r){return"/"+r.trim().split("/").filter(e=>e).join("/")}var Wr=class extends Error{static name="ParseError";name="ParseError";constructor(e){super(`Error parsing address: ${e}`)}};var Sd=Symbol.for("nodejs.util.inspect.custom"),Wi=Symbol.for("@multiformats/js-multiaddr/multiaddr"),Bd=[q("dns").code,q("dns4").code,q("dns6").code,q("dnsaddr").code],Yi=class extends Error{constructor(e="No available resolver"){super(e),this.name="NoAvailableResolverError"}},Zr=class r{bytes;#e;#t;#r;#n;[Wi]=!0;constructor(e){e==null&&(e="");let t;if(e instanceof Uint8Array)t=$i(e);else if(typeof e=="string"){if(e.length>0&&e.charAt(0)!=="/")throw new Error(`multiaddr "${e}" must start with a "/"`);t=dc(e)}else if(pc(e))t=$i(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,i,o="",s=q("tcp"),a=q("udp"),c=q("ip4"),u=q("ip6"),f=q("dns6"),d=q("ip6zone");for(let[p,h]of this.stringTuples())p===d.code&&(o=`%${h??""}`),Bd.includes(p)&&(t=s.name==="tcp"?"tcp":"udp",i=443,n=`${h??""}${o}`,e=p===f.code?6:4),(p===s.code||p===a.code)&&(t=q(p).name==="tcp"?"tcp":"udp",i=parseInt(h??"")),(p===c.code||p===u.code)&&(t=q(p).name==="tcp"?"tcp":"udp",n=`${h??""}${o}`,e=p===u.code?6:4);if(e==null||t==null||n==null||i==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:i}}protos(){return this.#t.map(([e])=>Object.assign({},q(e)))}protoCodes(){return this.#t.map(([e])=>e)}protoNames(){return this.#t.map(([e])=>q(e).name)}tuples(){return this.#t.map(([e,t])=>t==null?[e]:[e,t])}stringTuples(){return this.#r.map(([e,t])=>t==null?[e]:[e,t])}encapsulate(e){return e=new r(e),new r(this.toString()+e.toString())}decapsulate(e){let t=e.toString(),n=this.toString(),i=n.lastIndexOf(t);if(i<0)throw new Error(`Address ${this.toString()} does not contain subaddress: ${e.toString()}`);return new r(n.slice(0,i))}decapsulateCode(e){let t=this.tuples();for(let n=t.length-1;n>=0;n--)if(t[n][0]===e)return new r(Xr(t.slice(0,n)));return this}getPeerId(){try{let e=[];this.stringTuples().forEach(([n,i])=>{n===jt.p2p.code&&e.push([n,i]),n===jt["p2p-circuit"].code&&(e=[])});let t=e.pop();if(t?.[1]!=null){let n=t[1];return n[0]==="Q"||n[0]==="1"?H(z.decode(`z${n}`),"base58btc"):H(G.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){return this.#n}equals(e){return pe(this.bytes,e.bytes)}async resolve(e){let t=this.protos().find(o=>o.resolvable);if(t==null)return[this];let n=hc.get(t.name);if(n==null)throw new Yi(`no available resolver for ${t.name}`);return(await n(this,e)).map(o=>mr(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)}[Sd](){return`Multiaddr(${this.#e})`}};var hc=new Map;function pc(r){return!!r?.[Wi]}function mr(r){return new Zr(r)}function fc(r,e,t,n){let i=()=>{n?.log.trace("query",e),r.query({questions:[{name:e,type:"PTR"}]})};return i(),setInterval(i,t)}function gc(r,e,t,n){if(r.answers==null)return;let i,o=[];if(r.answers.forEach(s=>{switch(s.type){case"PTR":i=s;break;case"TXT":o.push(s);break;default:break}}),r.additionals.forEach(s=>{switch(s.type){case"TXT":o.push(s);break;default:break}}),!(i==null||i?.name!==t||o.length===0||i.data.startsWith(e)))try{let s=o.flatMap(c=>c.data).filter(c=>c.toString().startsWith("dnsaddr=")).map(c=>mr(c.toString().substring(8))),a=s[0].getPeerId();if(a==null)throw new Error("Multiaddr doesn't contain PeerId");return n?.log("peer found %p",a),{id:Xs(a),multiaddrs:s.map(c=>c.decapsulateCode(q("p2p").code))}}catch(s){n?.log.error("failed to parse mdns response",s)}}function mc(r,e,t,n,i,o,s){if(!o){s?.log("not responding to mDNS query as broadcast mode is false");return}if(n.length!==0&&r.questions[0]!=null&&r.questions[0].name===i){let a=[];a.push({name:i,type:"PTR",class:"IN",ttl:120,data:t+"."+i}),n.filter(Ud).forEach(c=>{let u="dnsaddr="+c.toString();if(u.length>255){s?.log("multiaddr %a is too long to use in mDNS query response",c);return}if(c.getPeerId()==null){s?.log("multiaddr %a did not have a peer ID so cannot be used in mDNS query response",c);return}a.push({name:t+"."+i,type:"TXT",class:"IN",ttl:120,data:u})}),s?.log.trace("responding to query"),e.respond(a)}}function Ud(r){return!!rc(r)}function yc(r){let e="",t="abcdefghijklmnopqrstuvwxyz0123456789";for(let n=0;n<r;n++)e+=t.charAt(Math.floor(Math.random()*t.length));return e}var Qr=class extends Er{mdns;log;broadcast;interval;serviceTag;peerName;port;ip;_queryInterval;components;constructor(e,t={}){if(super(),this.log=e.logger.forComponent("libp2p:mdns"),this.broadcast=t.broadcast!==!1,this.interval=t.interval??1e3*10,this.serviceTag=t.serviceTag??"_p2p._udp.local",this.ip=t.ip??"224.0.0.251",this.peerName=t.peerName??yc(63),this.peerName.length>=64)throw new Error("Peer name should be less than 64 chars long");this.port=t.port??5353,this.components=e,this._queryInterval=null,this._onMdnsQuery=this._onMdnsQuery.bind(this),this._onMdnsResponse=this._onMdnsResponse.bind(this),this._onMdnsWarning=this._onMdnsWarning.bind(this),this._onMdnsError=this._onMdnsError.bind(this)}[Qi]=this;[Symbol.toStringTag]="@libp2p/mdns";[to]=["@libp2p/peer-discovery"];isStarted(){return!!this.mdns}async start(){this.mdns==null&&(this.mdns=(0,wc.default)({port:this.port,ip:this.ip}),this.mdns.on("query",this._onMdnsQuery),this.mdns.on("response",this._onMdnsResponse),this.mdns.on("warning",this._onMdnsWarning),this.mdns.on("error",this._onMdnsError),this._queryInterval=fc(this.mdns,this.serviceTag,this.interval,{log:this.log}))}_onMdnsQuery(e){this.mdns!=null&&(this.log.trace("received incoming mDNS query"),mc(e,this.mdns,this.peerName,this.components.addressManager.getAddresses(),this.serviceTag,this.broadcast,{log:this.log}))}_onMdnsResponse(e){this.log.trace("received mDNS query response");try{let t=gc(e,this.peerName,this.serviceTag,{log:this.log});t!=null&&(this.log("discovered peer in mDNS query response %p",t.id),this.dispatchEvent(new CustomEvent("peer",{detail:t})))}catch(t){this.log.error("Error processing peer response",t)}}_onMdnsWarning(e){this.log.error("mdns warning",e)}_onMdnsError(e){this.log.error("mdns error",e)}async stop(){this.mdns!=null&&(this.mdns.removeListener("query",this._onMdnsQuery),this.mdns.removeListener("response",this._onMdnsResponse),this.mdns.removeListener("warning",this._onMdnsWarning),this.mdns.removeListener("error",this._onMdnsError),this._queryInterval!=null&&(clearInterval(this._queryInterval),this._queryInterval=null),await new Promise(e=>{this.mdns!=null?this.mdns.destroy(e):e()}),this.mdns=void 0)}};function Cd(r={}){return e=>new Qr(e,r)}return vc(Td);})();
|
|
2
|
+
"use strict";var Libp2PMdns=(()=>{var mc=Object.create;var mr=Object.defineProperty;var yc=Object.getOwnPropertyDescriptor;var wc=Object.getOwnPropertyNames;var xc=Object.getPrototypeOf,bc=Object.prototype.hasOwnProperty;var se=(r=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(r,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):r)(function(r){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+r+'" is not supported')});var De=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),he=(r,e)=>{for(var t in e)mr(r,t,{get:e[t],enumerable:!0})},Hi=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of wc(e))!bc.call(r,i)&&i!==t&&mr(r,i,{get:()=>e[i],enumerable:!(n=yc(e,i))||n.enumerable});return r};var Bt=(r,e,t)=>(t=r!=null?mc(xc(r)):{},Hi(e||!r||!r.__esModule?mr(t,"default",{value:r,enumerable:!0}):t,r)),Ec=r=>Hi(mr({},"__esModule",{value:!0}),r);var $i=De(tn=>{"use strict";tn.toString=function(r){switch(r){case 1:return"A";case 10:return"NULL";case 28:return"AAAA";case 18:return"AFSDB";case 42:return"APL";case 257:return"CAA";case 60:return"CDNSKEY";case 59:return"CDS";case 37:return"CERT";case 5:return"CNAME";case 49:return"DHCID";case 32769:return"DLV";case 39:return"DNAME";case 48:return"DNSKEY";case 43:return"DS";case 55:return"HIP";case 13:return"HINFO";case 45:return"IPSECKEY";case 25:return"KEY";case 36:return"KX";case 29:return"LOC";case 15:return"MX";case 35:return"NAPTR";case 2:return"NS";case 47:return"NSEC";case 50:return"NSEC3";case 51:return"NSEC3PARAM";case 12:return"PTR";case 46:return"RRSIG";case 17:return"RP";case 24:return"SIG";case 6:return"SOA";case 99:return"SPF";case 33:return"SRV";case 44:return"SSHFP";case 32768:return"TA";case 249:return"TKEY";case 52:return"TLSA";case 250:return"TSIG";case 16:return"TXT";case 252:return"AXFR";case 251:return"IXFR";case 41:return"OPT";case 255:return"ANY"}return"UNKNOWN_"+r};tn.toType=function(r){switch(r.toUpperCase()){case"A":return 1;case"NULL":return 10;case"AAAA":return 28;case"AFSDB":return 18;case"APL":return 42;case"CAA":return 257;case"CDNSKEY":return 60;case"CDS":return 59;case"CERT":return 37;case"CNAME":return 5;case"DHCID":return 49;case"DLV":return 32769;case"DNAME":return 39;case"DNSKEY":return 48;case"DS":return 43;case"HIP":return 55;case"HINFO":return 13;case"IPSECKEY":return 45;case"KEY":return 25;case"KX":return 36;case"LOC":return 29;case"MX":return 15;case"NAPTR":return 35;case"NS":return 2;case"NSEC":return 47;case"NSEC3":return 50;case"NSEC3PARAM":return 51;case"PTR":return 12;case"RRSIG":return 46;case"RP":return 17;case"SIG":return 24;case"SOA":return 6;case"SPF":return 99;case"SRV":return 33;case"SSHFP":return 44;case"TA":return 32768;case"TKEY":return 249;case"TLSA":return 52;case"TSIG":return 250;case"TXT":return 16;case"AXFR":return 252;case"IXFR":return 251;case"OPT":return 41;case"ANY":return 255;case"*":return 255}return r.toUpperCase().startsWith("UNKNOWN_")?parseInt(r.slice(8)):0}});var Gi=De(rn=>{"use strict";rn.toString=function(r){switch(r){case 0:return"NOERROR";case 1:return"FORMERR";case 2:return"SERVFAIL";case 3:return"NXDOMAIN";case 4:return"NOTIMP";case 5:return"REFUSED";case 6:return"YXDOMAIN";case 7:return"YXRRSET";case 8:return"NXRRSET";case 9:return"NOTAUTH";case 10:return"NOTZONE";case 11:return"RCODE_11";case 12:return"RCODE_12";case 13:return"RCODE_13";case 14:return"RCODE_14";case 15:return"RCODE_15"}return"RCODE_"+r};rn.toRcode=function(r){switch(r.toUpperCase()){case"NOERROR":return 0;case"FORMERR":return 1;case"SERVFAIL":return 2;case"NXDOMAIN":return 3;case"NOTIMP":return 4;case"REFUSED":return 5;case"YXDOMAIN":return 6;case"YXRRSET":return 7;case"NXRRSET":return 8;case"NOTAUTH":return 9;case"NOTZONE":return 10;case"RCODE_11":return 11;case"RCODE_12":return 12;case"RCODE_13":return 13;case"RCODE_14":return 14;case"RCODE_15":return 15}return 0}});var Yi=De(nn=>{"use strict";nn.toString=function(r){switch(r){case 0:return"QUERY";case 1:return"IQUERY";case 2:return"STATUS";case 3:return"OPCODE_3";case 4:return"NOTIFY";case 5:return"UPDATE";case 6:return"OPCODE_6";case 7:return"OPCODE_7";case 8:return"OPCODE_8";case 9:return"OPCODE_9";case 10:return"OPCODE_10";case 11:return"OPCODE_11";case 12:return"OPCODE_12";case 13:return"OPCODE_13";case 14:return"OPCODE_14";case 15:return"OPCODE_15"}return"OPCODE_"+r};nn.toOpcode=function(r){switch(r.toUpperCase()){case"QUERY":return 0;case"IQUERY":return 1;case"STATUS":return 2;case"OPCODE_3":return 3;case"NOTIFY":return 4;case"UPDATE":return 5;case"OPCODE_6":return 6;case"OPCODE_7":return 7;case"OPCODE_8":return 8;case"OPCODE_9":return 9;case"OPCODE_10":return 10;case"OPCODE_11":return 11;case"OPCODE_12":return 12;case"OPCODE_13":return 13;case"OPCODE_14":return 14;case"OPCODE_15":return 15}return 0}});var Wi=De(on=>{"use strict";on.toString=function(r){switch(r){case 1:return"IN";case 2:return"CS";case 3:return"CH";case 4:return"HS";case 255:return"ANY"}return"UNKNOWN_"+r};on.toClass=function(r){switch(r.toUpperCase()){case"IN":return 1;case"CS":return 2;case"CH":return 3;case"HS":return 4;case"ANY":return 255}return 0}});var Xi=De(sn=>{"use strict";sn.toString=function(r){switch(r){case 1:return"LLQ";case 2:return"UL";case 3:return"NSID";case 5:return"DAU";case 6:return"DHU";case 7:return"N3U";case 8:return"CLIENT_SUBNET";case 9:return"EXPIRE";case 10:return"COOKIE";case 11:return"TCP_KEEPALIVE";case 12:return"PADDING";case 13:return"CHAIN";case 14:return"KEY_TAG";case 26946:return"DEVICEID"}return r<0?null:`OPTION_${r}`};sn.toCode=function(r){if(typeof r=="number")return r;if(!r)return-1;switch(r.toUpperCase()){case"OPTION_0":return 0;case"LLQ":return 1;case"UL":return 2;case"NSID":return 3;case"OPTION_4":return 4;case"DAU":return 5;case"DHU":return 6;case"N3U":return 7;case"CLIENT_SUBNET":return 8;case"EXPIRE":return 9;case"COOKIE":return 10;case"TCP_KEEPALIVE":return 11;case"PADDING":return 12;case"CHAIN":return 13;case"KEY_TAG":return 14;case"DEVICEID":return 26946;case"OPTION_65535":return 65535}let e=r.match(/_(\d+)$/);return e?parseInt(e[1],10):-1}});var Ji=De((Qi,cn)=>{var Zi=function(r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.decode=u,r.encode=l,r.familyOf=d,r.name=void 0,r.sizeOf=a,r.v6=r.v4=void 0;let e=/^(\d{1,3}\.){3,3}\d{1,3}$/,t=4,n=/^(::)?(((\d{1,3}\.){3}(\d{1,3}){1})?([0-9a-f]){0,4}:{0,2}){1,8}(::)?$/i,i=16,o={name:"v4",size:t,isFormat:h=>e.test(h),encode(h,f,p){p=~~p,f=f||new Uint8Array(p+t);let m=h.length,L=0;for(let _=0;_<m;){let K=h.charCodeAt(_++);K===46?(f[p++]=L,L=0):L=L*10+(K-48)}return f[p]=L,f},decode(h,f){return f=~~f,`${h[f++]}.${h[f++]}.${h[f++]}.${h[f]}`}};r.v4=o;let s={name:"v6",size:i,isFormat:h=>h.length>0&&n.test(h),encode(h,f,p){p=~~p;let m=p+i,L=-1,_=0,K=0,q=!0,V=!1;f=f||new Uint8Array(p+i);for(let S=0;S<h.length;S++){let F=h.charCodeAt(S);F===58?(q?L!==-1?(p<m&&(f[p]=0),p<m-1&&(f[p+1]=0),p+=2):p<m&&(L=p):(V===!0?(p<m&&(f[p]=K),p++):(p<m&&(f[p]=_>>8),p<m-1&&(f[p+1]=_&255),p+=2),_=0,K=0),q=!0,V=!1):F===46?(p<m&&(f[p]=K),p++,K=0,_=0,q=!1,V=!0):(q=!1,F>=97?F-=87:F>=65?F-=55:(F-=48,K=K*10+F),_=(_<<4)+F)}if(q===!1)V===!0?(p<m&&(f[p]=K),p++):(p<m&&(f[p]=_>>8),p<m-1&&(f[p+1]=_&255),p+=2);else if(L===0)p<m&&(f[p]=0),p<m-1&&(f[p+1]=0),p+=2;else if(L!==-1){p+=2;for(let S=Math.min(p-1,m-1);S>=L+2;S--)f[S]=f[S-2];f[L]=0,f[L+1]=0,L=p}if(L!==p&&L!==-1)for(p>m-2&&(p=m-2);m>L;)f[--m]=p<m&&p>L?f[--p]:0;else for(;p<m;)f[p++]=0;return f},decode(h,f){f=~~f;let p="";for(let m=0;m<i;m+=2)m!==0&&(p+=":"),p+=(h[f+m]<<8|h[f+m+1]).toString(16);return p.replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}};r.v6=s;let c="ip";r.name=c;function a(h){if(o.isFormat(h))return o.size;if(s.isFormat(h))return s.size;throw Error(`Invalid ip address: ${h}`)}function d(h){return a(h)===o.size?1:2}function l(h,f,p){p=~~p;let m=a(h);return typeof f=="function"&&(f=f(p+m)),m===o.size?o.encode(h,f,p):s.encode(h,f,p)}function u(h,f,p){if(f=~~f,p=p||h.length-f,p===o.size)return o.decode(h,f,p);if(p===s.size)return s.decode(h,f,p);throw Error(`Invalid buffer size needs to be ${o.size} for v4 or ${s.size} for v6.`)}return"default"in r?r.default:r}({});typeof define=="function"&&define.amd?define([],function(){return Zi}):typeof cn=="object"&&typeof Qi=="object"&&(cn.exports=Zi)});var ro=De(I=>{"use strict";var v=se("buffer").Buffer,Ze=$i(),Ic=Gi(),vc=Yi(),Ir=Wi(),an=Xi(),dt=Ji(),Sc=0,eo=32768,un=32768,Ac=~un,to=32768,Bc=~to,x=I.name={};x.encode=function(r,e,t,{mail:n=!1}={}){e||(e=v.alloc(x.encodingLength(r))),t||(t=0);let i=t,o=r.replace(/^\.|\.$/gm,"");if(o.length){let s=[];if(n){let c="";o.split(".").forEach(a=>{a.endsWith("\\")?c+=(c.length?".":"")+a.slice(0,-1):s.length===0&&c.length?s.push(c+"."+a):s.push(a)})}else s=o.split(".");for(let c=0;c<s.length;c++){let a=e.write(s[c],t+1);e[t]=a,t+=a+1}}return e[t++]=0,x.encode.bytes=t-i,e};x.encode.bytes=0;x.decode=function(r,e,{mail:t=!1}={}){e||(e=0);let n=[],i=e,o=0,s=0,c=!1;for(;;){if(e>=r.length)throw new Error("Cannot decode name (buffer overflow)");let a=r[e++];if(s+=c?0:1,a===0)break;if((a&192)===0){if(e+a>r.length)throw new Error("Cannot decode name (buffer overflow)");if(o+=a+1,o>254)throw new Error("Cannot decode name (name too long)");let d=r.toString("utf-8",e,e+a);t&&(d=d.replace(/\./g,"\\.")),n.push(d),e+=a,s+=c?0:a}else if((a&192)===192){if(e+1>r.length)throw new Error("Cannot decode name (buffer overflow)");let d=r.readUInt16BE(e-1)-49152;if(d>=i)throw new Error("Cannot decode name (bad pointer)");e=d,i=d,s+=c?0:1,c=!0}else throw new Error("Cannot decode name (bad label)")}return x.decode.bytes=s,n.length===0?".":n.join(".")};x.decode.bytes=0;x.encodingLength=function(r){return r==="."||r===".."?1:v.byteLength(r.replace(/^\.|\.$/gm,""))+2};var D={};D.encode=function(r,e,t){e||(e=v.alloc(D.encodingLength(r))),t||(t=0);let n=e.write(r,t+1);return e[t]=n,D.encode.bytes=n+1,e};D.encode.bytes=0;D.decode=function(r,e){e||(e=0);let t=r[e],n=r.toString("utf-8",e+1,e+1+t);return D.decode.bytes=t+1,n};D.decode.bytes=0;D.encodingLength=function(r){return v.byteLength(r)+1};var Le={};Le.encode=function(r,e,t){e||(e=Le.encodingLength(r)),t||(t=0);let n=(r.flags||0)&32767,i=r.type==="response"?eo:Sc;return e.writeUInt16BE(r.id||0,t),e.writeUInt16BE(n|i,t+2),e.writeUInt16BE(r.questions.length,t+4),e.writeUInt16BE(r.answers.length,t+6),e.writeUInt16BE(r.authorities.length,t+8),e.writeUInt16BE(r.additionals.length,t+10),e};Le.encode.bytes=12;Le.decode=function(r,e){if(e||(e=0),r.length<12)throw new Error("Header must be 12 bytes");let t=r.readUInt16BE(e+2);return{id:r.readUInt16BE(e),type:t&eo?"response":"query",flags:t&32767,flag_qr:(t>>15&1)===1,opcode:vc.toString(t>>11&15),flag_aa:(t>>10&1)===1,flag_tc:(t>>9&1)===1,flag_rd:(t>>8&1)===1,flag_ra:(t>>7&1)===1,flag_z:(t>>6&1)===1,flag_ad:(t>>5&1)===1,flag_cd:(t>>4&1)===1,rcode:Ic.toString(t&15),questions:new Array(r.readUInt16BE(e+4)),answers:new Array(r.readUInt16BE(e+6)),authorities:new Array(r.readUInt16BE(e+8)),additionals:new Array(r.readUInt16BE(e+10))}};Le.decode.bytes=12;Le.encodingLength=function(){return 12};var qe=I.unknown={};qe.encode=function(r,e,t){return e||(e=v.alloc(qe.encodingLength(r))),t||(t=0),e.writeUInt16BE(r.length,t),r.copy(e,t+2),qe.encode.bytes=r.length+2,e};qe.encode.bytes=0;qe.decode=function(r,e){e||(e=0);let t=r.readUInt16BE(e),n=r.slice(e+2,e+2+t);return qe.decode.bytes=t+2,n};qe.decode.bytes=0;qe.encodingLength=function(r){return r.length+2};var Ve=I.ns={};Ve.encode=function(r,e,t){return e||(e=v.alloc(Ve.encodingLength(r))),t||(t=0),x.encode(r,e,t+2),e.writeUInt16BE(x.encode.bytes,t),Ve.encode.bytes=x.encode.bytes+2,e};Ve.encode.bytes=0;Ve.decode=function(r,e){e||(e=0);let t=r.readUInt16BE(e),n=x.decode(r,e+2);return Ve.decode.bytes=t+2,n};Ve.decode.bytes=0;Ve.encodingLength=function(r){return x.encodingLength(r)+2};var ze=I.soa={};ze.encode=function(r,e,t){e||(e=v.alloc(ze.encodingLength(r))),t||(t=0);let n=t;return t+=2,x.encode(r.mname,e,t),t+=x.encode.bytes,x.encode(r.rname,e,t,{mail:!0}),t+=x.encode.bytes,e.writeUInt32BE(r.serial||0,t),t+=4,e.writeUInt32BE(r.refresh||0,t),t+=4,e.writeUInt32BE(r.retry||0,t),t+=4,e.writeUInt32BE(r.expire||0,t),t+=4,e.writeUInt32BE(r.minimum||0,t),t+=4,e.writeUInt16BE(t-n-2,n),ze.encode.bytes=t-n,e};ze.encode.bytes=0;ze.decode=function(r,e){e||(e=0);let t=e,n={};return e+=2,n.mname=x.decode(r,e),e+=x.decode.bytes,n.rname=x.decode(r,e,{mail:!0}),e+=x.decode.bytes,n.serial=r.readUInt32BE(e),e+=4,n.refresh=r.readUInt32BE(e),e+=4,n.retry=r.readUInt32BE(e),e+=4,n.expire=r.readUInt32BE(e),e+=4,n.minimum=r.readUInt32BE(e),e+=4,ze.decode.bytes=e-t,n};ze.decode.bytes=0;ze.encodingLength=function(r){return 22+x.encodingLength(r.mname)+x.encodingLength(r.rname)};var je=I.txt={};je.encode=function(r,e,t){Array.isArray(r)||(r=[r]);for(let i=0;i<r.length;i++)if(typeof r[i]=="string"&&(r[i]=v.from(r[i])),!v.isBuffer(r[i]))throw new Error("Must be a Buffer");e||(e=v.alloc(je.encodingLength(r))),t||(t=0);let n=t;return t+=2,r.forEach(function(i){e[t++]=i.length,i.copy(e,t,0,i.length),t+=i.length}),e.writeUInt16BE(t-n-2,n),je.encode.bytes=t-n,e};je.encode.bytes=0;je.decode=function(r,e){e||(e=0);let t=e,n=r.readUInt16BE(e);e+=2;let i=[];for(;n>0;){let o=r[e++];if(--n,n<o)throw new Error("Buffer overflow");i.push(r.slice(e,e+o)),e+=o,n-=o}return je.decode.bytes=e-t,i};je.decode.bytes=0;je.encodingLength=function(r){Array.isArray(r)||(r=[r]);let e=2;return r.forEach(function(t){typeof t=="string"?e+=v.byteLength(t)+1:e+=t.length+1}),e};var $e=I.null={};$e.encode=function(r,e,t){e||(e=v.alloc($e.encodingLength(r))),t||(t=0),typeof r=="string"&&(r=v.from(r)),r||(r=v.alloc(0));let n=t;t+=2;let i=r.length;return r.copy(e,t,0,i),t+=i,e.writeUInt16BE(t-n-2,n),$e.encode.bytes=t-n,e};$e.encode.bytes=0;$e.decode=function(r,e){e||(e=0);let t=e,n=r.readUInt16BE(e);e+=2;let i=r.slice(e,e+n);return e+=n,$e.decode.bytes=e-t,i};$e.decode.bytes=0;$e.encodingLength=function(r){return r?(v.isBuffer(r)?r.length:v.byteLength(r))+2:2};var Ge=I.hinfo={};Ge.encode=function(r,e,t){e||(e=v.alloc(Ge.encodingLength(r))),t||(t=0);let n=t;return t+=2,D.encode(r.cpu,e,t),t+=D.encode.bytes,D.encode(r.os,e,t),t+=D.encode.bytes,e.writeUInt16BE(t-n-2,n),Ge.encode.bytes=t-n,e};Ge.encode.bytes=0;Ge.decode=function(r,e){e||(e=0);let t=e,n={};return e+=2,n.cpu=D.decode(r,e),e+=D.decode.bytes,n.os=D.decode(r,e),e+=D.decode.bytes,Ge.decode.bytes=e-t,n};Ge.decode.bytes=0;Ge.encodingLength=function(r){return D.encodingLength(r.cpu)+D.encodingLength(r.os)+2};var Be=I.ptr={},Uc=I.cname=Be,Lc=I.dname=Be;Be.encode=function(r,e,t){return e||(e=v.alloc(Be.encodingLength(r))),t||(t=0),x.encode(r,e,t+2),e.writeUInt16BE(x.encode.bytes,t),Be.encode.bytes=x.encode.bytes+2,e};Be.encode.bytes=0;Be.decode=function(r,e){e||(e=0);let t=x.decode(r,e+2);return Be.decode.bytes=x.decode.bytes+2,t};Be.decode.bytes=0;Be.encodingLength=function(r){return x.encodingLength(r)+2};var Ye=I.srv={};Ye.encode=function(r,e,t){e||(e=v.alloc(Ye.encodingLength(r))),t||(t=0),e.writeUInt16BE(r.priority||0,t+2),e.writeUInt16BE(r.weight||0,t+4),e.writeUInt16BE(r.port||0,t+6),x.encode(r.target,e,t+8);let n=x.encode.bytes+6;return e.writeUInt16BE(n,t),Ye.encode.bytes=n+2,e};Ye.encode.bytes=0;Ye.decode=function(r,e){e||(e=0);let t=r.readUInt16BE(e),n={};return n.priority=r.readUInt16BE(e+2),n.weight=r.readUInt16BE(e+4),n.port=r.readUInt16BE(e+6),n.target=x.decode(r,e+8),Ye.decode.bytes=t+2,n};Ye.decode.bytes=0;Ye.encodingLength=function(r){return 8+x.encodingLength(r.target)};var pe=I.caa={};pe.ISSUER_CRITICAL=128;pe.encode=function(r,e,t){let n=pe.encodingLength(r);return e||(e=v.alloc(pe.encodingLength(r))),t||(t=0),r.issuerCritical&&(r.flags=pe.ISSUER_CRITICAL),e.writeUInt16BE(n-2,t),t+=2,e.writeUInt8(r.flags||0,t),t+=1,D.encode(r.tag,e,t),t+=D.encode.bytes,e.write(r.value,t),t+=v.byteLength(r.value),pe.encode.bytes=n,e};pe.encode.bytes=0;pe.decode=function(r,e){e||(e=0);let t=r.readUInt16BE(e);e+=2;let n=e,i={};return i.flags=r.readUInt8(e),e+=1,i.tag=D.decode(r,e),e+=D.decode.bytes,i.value=r.toString("utf-8",e,n+t),i.issuerCritical=!!(i.flags&pe.ISSUER_CRITICAL),pe.decode.bytes=t+2,i};pe.decode.bytes=0;pe.encodingLength=function(r){return D.encodingLength(r.tag)+D.encodingLength(r.value)+2};var it=I.mx={};it.encode=function(r,e,t){e||(e=v.alloc(it.encodingLength(r))),t||(t=0);let n=t;return t+=2,e.writeUInt16BE(r.preference||0,t),t+=2,x.encode(r.exchange,e,t),t+=x.encode.bytes,e.writeUInt16BE(t-n-2,n),it.encode.bytes=t-n,e};it.encode.bytes=0;it.decode=function(r,e){e||(e=0);let t=e,n={};return e+=2,n.preference=r.readUInt16BE(e),e+=2,n.exchange=x.decode(r,e),e+=x.decode.bytes,it.decode.bytes=e-t,n};it.encodingLength=function(r){return 4+x.encodingLength(r.exchange)};var We=I.a={};We.encode=function(r,e,t){return e||(e=v.alloc(We.encodingLength(r))),t||(t=0),e.writeUInt16BE(4,t),t+=2,dt.v4.encode(r,e,t),We.encode.bytes=6,e};We.encode.bytes=0;We.decode=function(r,e){e||(e=0),e+=2;let t=dt.v4.decode(r,e);return We.decode.bytes=6,t};We.decode.bytes=0;We.encodingLength=function(){return 6};var Xe=I.aaaa={};Xe.encode=function(r,e,t){return e||(e=v.alloc(Xe.encodingLength(r))),t||(t=0),e.writeUInt16BE(16,t),t+=2,dt.v6.encode(r,e,t),Xe.encode.bytes=18,e};Xe.encode.bytes=0;Xe.decode=function(r,e){e||(e=0),e+=2;let t=dt.v6.decode(r,e);return Xe.decode.bytes=18,t};Xe.decode.bytes=0;Xe.encodingLength=function(){return 18};var ce=I.option={};ce.encode=function(r,e,t){e||(e=v.alloc(ce.encodingLength(r))),t||(t=0);let n=t,i=an.toCode(r.code);if(e.writeUInt16BE(i,t),t+=2,r.data)e.writeUInt16BE(r.data.length,t),t+=2,r.data.copy(e,t),t+=r.data.length;else switch(i){case 8:let o=r.sourcePrefixLength||0,s=r.family||dt.familyOf(r.ip),c=dt.encode(r.ip,v.alloc),a=Math.ceil(o/8);e.writeUInt16BE(a+4,t),t+=2,e.writeUInt16BE(s,t),t+=2,e.writeUInt8(o,t++),e.writeUInt8(r.scopePrefixLength||0,t++),c.copy(e,t,0,a),t+=a;break;case 11:r.timeout?(e.writeUInt16BE(2,t),t+=2,e.writeUInt16BE(r.timeout,t),t+=2):(e.writeUInt16BE(0,t),t+=2);break;case 12:let d=r.length||0;e.writeUInt16BE(d,t),t+=2,e.fill(0,t,t+d),t+=d;break;case 14:let l=r.tags.length*2;e.writeUInt16BE(l,t),t+=2;for(let u of r.tags)e.writeUInt16BE(u,t),t+=2;break;default:throw new Error(`Unknown roption code: ${r.code}`)}return ce.encode.bytes=t-n,e};ce.encode.bytes=0;ce.decode=function(r,e){e||(e=0);let t={};t.code=r.readUInt16BE(e),t.type=an.toString(t.code),e+=2;let n=r.readUInt16BE(e);switch(e+=2,t.data=r.slice(e,e+n),t.code){case 8:t.family=r.readUInt16BE(e),e+=2,t.sourcePrefixLength=r.readUInt8(e++),t.scopePrefixLength=r.readUInt8(e++);let i=v.alloc(t.family===1?4:16);r.copy(i,0,e,e+n-4),t.ip=dt.decode(i);break;case 11:n>0&&(t.timeout=r.readUInt16BE(e),e+=2);break;case 14:t.tags=[];for(let o=0;o<n;o+=2)t.tags.push(r.readUInt16BE(e)),e+=2}return ce.decode.bytes=n+4,t};ce.decode.bytes=0;ce.encodingLength=function(r){if(r.data)return r.data.length+4;switch(an.toCode(r.code)){case 8:let t=r.sourcePrefixLength||0;return Math.ceil(t/8)+8;case 11:return typeof r.timeout=="number"?6:4;case 12:return r.length+4;case 14:return 4+r.tags.length*2}throw new Error(`Unknown roption code: ${r.code}`)};var ge=I.opt={};ge.encode=function(r,e,t){e||(e=v.alloc(ge.encodingLength(r))),t||(t=0);let n=t,i=Ut(r,ce);return e.writeUInt16BE(i,t),t=$t(r,ce,e,t+2),ge.encode.bytes=t-n,e};ge.encode.bytes=0;ge.decode=function(r,e){e||(e=0);let t=e,n=[],i=r.readUInt16BE(e);e+=2;let o=0;for(;i>0;)n[o++]=ce.decode(r,e),e+=ce.decode.bytes,i-=ce.decode.bytes;return ge.decode.bytes=e-t,n};ge.decode.bytes=0;ge.encodingLength=function(r){return 2+Ut(r||[],ce)};var ie=I.dnskey={};ie.PROTOCOL_DNSSEC=3;ie.ZONE_KEY=128;ie.SECURE_ENTRYPOINT=32768;ie.encode=function(r,e,t){e||(e=v.alloc(ie.encodingLength(r))),t||(t=0);let n=t,i=r.key;if(!v.isBuffer(i))throw new Error("Key must be a Buffer");return t+=2,e.writeUInt16BE(r.flags,t),t+=2,e.writeUInt8(ie.PROTOCOL_DNSSEC,t),t+=1,e.writeUInt8(r.algorithm,t),t+=1,i.copy(e,t,0,i.length),t+=i.length,ie.encode.bytes=t-n,e.writeUInt16BE(ie.encode.bytes-2,n),e};ie.encode.bytes=0;ie.decode=function(r,e){e||(e=0);let t=e;var n={},i=r.readUInt16BE(e);if(e+=2,n.flags=r.readUInt16BE(e),e+=2,r.readUInt8(e)!==ie.PROTOCOL_DNSSEC)throw new Error("Protocol must be 3");return e+=1,n.algorithm=r.readUInt8(e),e+=1,n.key=r.slice(e,t+i+2),e+=n.key.length,ie.decode.bytes=e-t,n};ie.decode.bytes=0;ie.encodingLength=function(r){return 6+v.byteLength(r.key)};var Ne=I.rrsig={};Ne.encode=function(r,e,t){e||(e=v.alloc(Ne.encodingLength(r))),t||(t=0);let n=t,i=r.signature;if(!v.isBuffer(i))throw new Error("Signature must be a Buffer");return t+=2,e.writeUInt16BE(Ze.toType(r.typeCovered),t),t+=2,e.writeUInt8(r.algorithm,t),t+=1,e.writeUInt8(r.labels,t),t+=1,e.writeUInt32BE(r.originalTTL,t),t+=4,e.writeUInt32BE(r.expiration,t),t+=4,e.writeUInt32BE(r.inception,t),t+=4,e.writeUInt16BE(r.keyTag,t),t+=2,x.encode(r.signersName,e,t),t+=x.encode.bytes,i.copy(e,t,0,i.length),t+=i.length,Ne.encode.bytes=t-n,e.writeUInt16BE(Ne.encode.bytes-2,n),e};Ne.encode.bytes=0;Ne.decode=function(r,e){e||(e=0);let t=e;var n={},i=r.readUInt16BE(e);return e+=2,n.typeCovered=Ze.toString(r.readUInt16BE(e)),e+=2,n.algorithm=r.readUInt8(e),e+=1,n.labels=r.readUInt8(e),e+=1,n.originalTTL=r.readUInt32BE(e),e+=4,n.expiration=r.readUInt32BE(e),e+=4,n.inception=r.readUInt32BE(e),e+=4,n.keyTag=r.readUInt16BE(e),e+=2,n.signersName=x.decode(r,e),e+=x.decode.bytes,n.signature=r.slice(e,t+i+2),e+=n.signature.length,Ne.decode.bytes=e-t,n};Ne.decode.bytes=0;Ne.encodingLength=function(r){return 20+x.encodingLength(r.signersName)+v.byteLength(r.signature)};var Oe=I.rp={};Oe.encode=function(r,e,t){e||(e=v.alloc(Oe.encodingLength(r))),t||(t=0);let n=t;return t+=2,x.encode(r.mbox||".",e,t,{mail:!0}),t+=x.encode.bytes,x.encode(r.txt||".",e,t),t+=x.encode.bytes,Oe.encode.bytes=t-n,e.writeUInt16BE(Oe.encode.bytes-2,n),e};Oe.encode.bytes=0;Oe.decode=function(r,e){e||(e=0);let t=e,n={};return e+=2,n.mbox=x.decode(r,e,{mail:!0})||".",e+=x.decode.bytes,n.txt=x.decode(r,e)||".",e+=x.decode.bytes,Oe.decode.bytes=e-t,n};Oe.decode.bytes=0;Oe.encodingLength=function(r){return 2+x.encodingLength(r.mbox||".")+x.encodingLength(r.txt||".")};var Z={};Z.encode=function(r,e,t){e||(e=v.alloc(Z.encodingLength(r))),t||(t=0);let n=t;for(var i=[],o=0;o<r.length;o++){var s=Ze.toType(r[o]);i[s>>8]===void 0&&(i[s>>8]=[]),i[s>>8][s>>3&31]|=1<<7-(s&7)}for(o=0;o<i.length;o++)if(i[o]!==void 0){var c=v.from(i[o]);e.writeUInt8(o,t),t+=1,e.writeUInt8(c.length,t),t+=1,c.copy(e,t),t+=c.length}return Z.encode.bytes=t-n,e};Z.encode.bytes=0;Z.decode=function(r,e,t){e||(e=0);let n=e;for(var i=[];e-n<t;){var o=r.readUInt8(e);e+=1;var s=r.readUInt8(e);e+=1;for(var c=0;c<s;c++)for(var a=r.readUInt8(e+c),d=0;d<8;d++)if(a&1<<7-d){var l=Ze.toString(o<<8|c<<3|d);i.push(l)}e+=s}return Z.decode.bytes=e-n,i};Z.decode.bytes=0;Z.encodingLength=function(r){for(var e=[],t=0;t<r.length;t++){var n=Ze.toType(r[t]);e[n>>8]=Math.max(e[n>>8]||0,n&255)}var i=0;for(t=0;t<e.length;t++)e[t]!==void 0&&(i+=2+Math.ceil((e[t]+1)/8));return i};var ke=I.nsec={};ke.encode=function(r,e,t){e||(e=v.alloc(ke.encodingLength(r))),t||(t=0);let n=t;return t+=2,x.encode(r.nextDomain,e,t),t+=x.encode.bytes,Z.encode(r.rrtypes,e,t),t+=Z.encode.bytes,ke.encode.bytes=t-n,e.writeUInt16BE(ke.encode.bytes-2,n),e};ke.encode.bytes=0;ke.decode=function(r,e){e||(e=0);let t=e;var n={},i=r.readUInt16BE(e);return e+=2,n.nextDomain=x.decode(r,e),e+=x.decode.bytes,n.rrtypes=Z.decode(r,e,i-(e-t)),e+=Z.decode.bytes,ke.decode.bytes=e-t,n};ke.decode.bytes=0;ke.encodingLength=function(r){return 2+x.encodingLength(r.nextDomain)+Z.encodingLength(r.rrtypes)};var Re=I.nsec3={};Re.encode=function(r,e,t){e||(e=v.alloc(Re.encodingLength(r))),t||(t=0);let n=t,i=r.salt;if(!v.isBuffer(i))throw new Error("salt must be a Buffer");let o=r.nextDomain;if(!v.isBuffer(o))throw new Error("nextDomain must be a Buffer");return t+=2,e.writeUInt8(r.algorithm,t),t+=1,e.writeUInt8(r.flags,t),t+=1,e.writeUInt16BE(r.iterations,t),t+=2,e.writeUInt8(i.length,t),t+=1,i.copy(e,t,0,i.length),t+=i.length,e.writeUInt8(o.length,t),t+=1,o.copy(e,t,0,o.length),t+=o.length,Z.encode(r.rrtypes,e,t),t+=Z.encode.bytes,Re.encode.bytes=t-n,e.writeUInt16BE(Re.encode.bytes-2,n),e};Re.encode.bytes=0;Re.decode=function(r,e){e||(e=0);let t=e;var n={},i=r.readUInt16BE(e);e+=2,n.algorithm=r.readUInt8(e),e+=1,n.flags=r.readUInt8(e),e+=1,n.iterations=r.readUInt16BE(e),e+=2;let o=r.readUInt8(e);e+=1,n.salt=r.slice(e,e+o),e+=o;let s=r.readUInt8(e);return e+=1,n.nextDomain=r.slice(e,e+s),e+=s,n.rrtypes=Z.decode(r,e,i-(e-t)),e+=Z.decode.bytes,Re.decode.bytes=e-t,n};Re.decode.bytes=0;Re.encodingLength=function(r){return 8+r.salt.length+r.nextDomain.length+Z.encodingLength(r.rrtypes)};var Ke=I.ds={};Ke.encode=function(r,e,t){e||(e=v.alloc(Ke.encodingLength(r))),t||(t=0);let n=t,i=r.digest;if(!v.isBuffer(i))throw new Error("Digest must be a Buffer");return t+=2,e.writeUInt16BE(r.keyTag,t),t+=2,e.writeUInt8(r.algorithm,t),t+=1,e.writeUInt8(r.digestType,t),t+=1,i.copy(e,t,0,i.length),t+=i.length,Ke.encode.bytes=t-n,e.writeUInt16BE(Ke.encode.bytes-2,n),e};Ke.encode.bytes=0;Ke.decode=function(r,e){e||(e=0);let t=e;var n={},i=r.readUInt16BE(e);return e+=2,n.keyTag=r.readUInt16BE(e),e+=2,n.algorithm=r.readUInt8(e),e+=1,n.digestType=r.readUInt8(e),e+=1,n.digest=r.slice(e,t+i+2),e+=n.digest.length,Ke.decode.bytes=e-t,n};Ke.decode.bytes=0;Ke.encodingLength=function(r){return 6+v.byteLength(r.digest)};var fe=I.sshfp={};fe.getFingerprintLengthForHashType=function(e){switch(e){case 1:return 20;case 2:return 32}};fe.encode=function(e,t,n){t||(t=v.alloc(fe.encodingLength(e))),n||(n=0);let i=n;n+=2,t[n]=e.algorithm,n+=1,t[n]=e.hash,n+=1;let o=v.from(e.fingerprint.toUpperCase(),"hex");if(o.length!==fe.getFingerprintLengthForHashType(e.hash))throw new Error("Invalid fingerprint length");return o.copy(t,n),n+=o.byteLength,fe.encode.bytes=n-i,t.writeUInt16BE(fe.encode.bytes-2,i),t};fe.encode.bytes=0;fe.decode=function(e,t){t||(t=0);let n=t,i={};t+=2,i.algorithm=e[t],t+=1,i.hash=e[t],t+=1;let o=fe.getFingerprintLengthForHashType(i.hash);return i.fingerprint=e.slice(t,t+o).toString("hex").toUpperCase(),t+=o,fe.decode.bytes=t-n,i};fe.decode.bytes=0;fe.encodingLength=function(r){return 4+v.from(r.fingerprint,"hex").byteLength};var Me=I.naptr={};Me.encode=function(r,e,t){e||(e=v.alloc(Me.encodingLength(r))),t||(t=0);let n=t;return t+=2,e.writeUInt16BE(r.order||0,t),t+=2,e.writeUInt16BE(r.preference||0,t),t+=2,D.encode(r.flags,e,t),t+=D.encode.bytes,D.encode(r.services,e,t),t+=D.encode.bytes,D.encode(r.regexp,e,t),t+=D.encode.bytes,x.encode(r.replacement,e,t),t+=x.encode.bytes,Me.encode.bytes=t-n,e.writeUInt16BE(Me.encode.bytes-2,n),e};Me.encode.bytes=0;Me.decode=function(r,e){e||(e=0);let t=e,n={};return e+=2,n.order=r.readUInt16BE(e),e+=2,n.preference=r.readUInt16BE(e),e+=2,n.flags=D.decode(r,e),e+=D.decode.bytes,n.services=D.decode(r,e),e+=D.decode.bytes,n.regexp=D.decode(r,e),e+=D.decode.bytes,n.replacement=x.decode(r,e),e+=x.decode.bytes,Me.decode.bytes=e-t,n};Me.decode.bytes=0;Me.encodingLength=function(r){return D.encodingLength(r.flags)+D.encodingLength(r.services)+D.encodingLength(r.regexp)+x.encodingLength(r.replacement)+6};var Fe=I.tlsa={};Fe.encode=function(r,e,t){e||(e=v.alloc(Fe.encodingLength(r))),t||(t=0);let n=t,i=r.certificate;if(!v.isBuffer(i))throw new Error("Certificate must be a Buffer");return t+=2,e.writeUInt8(r.usage,t),t+=1,e.writeUInt8(r.selector,t),t+=1,e.writeUInt8(r.matchingType,t),t+=1,i.copy(e,t,0,i.length),t+=i.length,Fe.encode.bytes=t-n,e.writeUInt16BE(Fe.encode.bytes-2,n),e};Fe.encode.bytes=0;Fe.decode=function(r,e){e||(e=0);let t=e,n={},i=r.readUInt16BE(e);return e+=2,n.usage=r.readUInt8(e),e+=1,n.selector=r.readUInt8(e),e+=1,n.matchingType=r.readUInt8(e),e+=1,n.certificate=r.slice(e,t+i+2),e+=n.certificate.length,Fe.decode.bytes=e-t,n};Fe.decode.bytes=0;Fe.encodingLength=function(r){return 5+v.byteLength(r.certificate)};var dn=I.record=function(r){switch(r.toUpperCase()){case"A":return We;case"PTR":return Be;case"CNAME":return Uc;case"DNAME":return Lc;case"TXT":return je;case"NULL":return $e;case"AAAA":return Xe;case"SRV":return Ye;case"HINFO":return Ge;case"CAA":return pe;case"NS":return Ve;case"SOA":return ze;case"MX":return it;case"OPT":return ge;case"DNSKEY":return ie;case"RRSIG":return Ne;case"RP":return Oe;case"NSEC":return ke;case"NSEC3":return Re;case"SSHFP":return fe;case"DS":return Ke;case"NAPTR":return Me;case"TLSA":return Fe}return qe},Q=I.answer={};Q.encode=function(r,e,t){e||(e=v.alloc(Q.encodingLength(r))),t||(t=0);let n=t;if(x.encode(r.name,e,t),t+=x.encode.bytes,e.writeUInt16BE(Ze.toType(r.type),t),r.type.toUpperCase()==="OPT"){if(r.name!==".")throw new Error("OPT name must be root.");e.writeUInt16BE(r.udpPayloadSize||4096,t+2),e.writeUInt8(r.extendedRcode||0,t+4),e.writeUInt8(r.ednsVersion||0,t+5),e.writeUInt16BE(r.flags||0,t+6),t+=8,ge.encode(r.options||[],e,t),t+=ge.encode.bytes}else{let i=Ir.toClass(r.class===void 0?"IN":r.class);r.flush&&(i|=un),e.writeUInt16BE(i,t+2),e.writeUInt32BE(r.ttl||0,t+4),t+=8;let o=dn(r.type);o.encode(r.data,e,t),t+=o.encode.bytes}return Q.encode.bytes=t-n,e};Q.encode.bytes=0;Q.decode=function(r,e){e||(e=0);let t={},n=e;if(t.name=x.decode(r,e),e+=x.decode.bytes,t.type=Ze.toString(r.readUInt16BE(e)),t.type==="OPT")t.udpPayloadSize=r.readUInt16BE(e+2),t.extendedRcode=r.readUInt8(e+4),t.ednsVersion=r.readUInt8(e+5),t.flags=r.readUInt16BE(e+6),t.flag_do=(t.flags>>15&1)===1,t.options=ge.decode(r,e+8),e+=8+ge.decode.bytes;else{let i=r.readUInt16BE(e+2);t.ttl=r.readUInt32BE(e+4),t.class=Ir.toString(i&Ac),t.flush=!!(i&un);let o=dn(t.type);t.data=o.decode(r,e+8),e+=8+o.decode.bytes}return Q.decode.bytes=e-n,t};Q.decode.bytes=0;Q.encodingLength=function(r){let e=r.data!==null&&r.data!==void 0?r.data:r.options;return x.encodingLength(r.name)+8+dn(r.type).encodingLength(e)};var Ue=I.question={};Ue.encode=function(r,e,t){e||(e=v.alloc(Ue.encodingLength(r))),t||(t=0);let n=t;return x.encode(r.name,e,t),t+=x.encode.bytes,e.writeUInt16BE(Ze.toType(r.type),t),t+=2,e.writeUInt16BE(Ir.toClass(r.class===void 0?"IN":r.class),t),t+=2,Ue.encode.bytes=t-n,r};Ue.encode.bytes=0;Ue.decode=function(r,e){e||(e=0);let t=e,n={};return n.name=x.decode(r,e),e+=x.decode.bytes,n.type=Ze.toString(r.readUInt16BE(e)),e+=2,n.class=Ir.toString(r.readUInt16BE(e)),e+=2,!!(n.class&to)&&(n.class&=Bc),Ue.decode.bytes=e-t,n};Ue.decode.bytes=0;Ue.encodingLength=function(r){return x.encodingLength(r.name)+4};I.AUTHORITATIVE_ANSWER=1024;I.TRUNCATED_RESPONSE=512;I.RECURSION_DESIRED=256;I.RECURSION_AVAILABLE=128;I.AUTHENTIC_DATA=32;I.CHECKING_DISABLED=16;I.DNSSEC_OK=32768;I.encode=function(r,e,t){let n=!e;n&&(e=v.alloc(I.encodingLength(r))),t||(t=0);let i=t;return r.questions||(r.questions=[]),r.answers||(r.answers=[]),r.authorities||(r.authorities=[]),r.additionals||(r.additionals=[]),Le.encode(r,e,t),t+=Le.encode.bytes,t=$t(r.questions,Ue,e,t),t=$t(r.answers,Q,e,t),t=$t(r.authorities,Q,e,t),t=$t(r.additionals,Q,e,t),I.encode.bytes=t-i,n&&I.encode.bytes!==e.length?e.slice(0,I.encode.bytes):e};I.encode.bytes=0;I.decode=function(r,e){e||(e=0);let t=e,n=Le.decode(r,e);return e+=Le.decode.bytes,e=Er(n.questions,Ue,r,e),e=Er(n.answers,Q,r,e),e=Er(n.authorities,Q,r,e),e=Er(n.additionals,Q,r,e),I.decode.bytes=e-t,n};I.decode.bytes=0;I.encodingLength=function(r){return Le.encodingLength(r)+Ut(r.questions||[],Ue)+Ut(r.answers||[],Q)+Ut(r.authorities||[],Q)+Ut(r.additionals||[],Q)};I.streamEncode=function(r){let e=I.encode(r),t=v.alloc(2);t.writeUInt16BE(e.byteLength);let n=v.concat([t,e]);return I.streamEncode.bytes=n.byteLength,n};I.streamEncode.bytes=0;I.streamDecode=function(r){let e=r.readUInt16BE(0);if(r.byteLength<e+2)return null;let t=I.decode(r.slice(2));return I.streamDecode.bytes=I.decode.bytes,t};I.streamDecode.bytes=0;function Ut(r,e){let t=0;for(let n=0;n<r.length;n++)t+=e.encodingLength(r[n]);return t}function $t(r,e,t,n){for(let i=0;i<r.length;i++)e.encode(r[i],t,n),n+=e.encode.bytes;return n}function Er(r,e,t,n){for(let i=0;i<r.length;i++)r[i]=e.decode(t,n),n+=e.decode.bytes;return n}});var oo=De((al,io)=>{"use strict";var no=Nc;process.nextTick(_c,42);io.exports=Cc;function Cc(r){var e=n;return t;function t(i){e(i||Pc)}function n(i){var o=[i];e=s,r(c);function s(a){o.push(a)}function c(a){var d=arguments;for(e=Tc(a)?n:l;o.length;)l(o.shift());function l(u){no(Dc,u,d)}}}}function Tc(r){return Object.prototype.toString.call(r)==="[object Error]"}function Pc(){}function Dc(r,e){r.apply(null,e)}function _c(r){r===42&&(no=process.nextTick)}function Nc(r,e,t){process.nextTick(function(){r(e,t)})}});var ao=De((ul,co)=>{var ln=ro(),Oc=se("dgram"),kc=oo(),Rc=se("events"),pn=se("os"),hn=function(){};co.exports=function(r){r||(r={});var e=new Rc.EventEmitter,t=typeof r.port=="number"?r.port:5353,n=r.type||"udp4",i=r.ip||r.host||(n==="udp4"?"224.0.0.251":null),o={address:i,port:t},s={},c=!1,a=null;if(n==="udp6"&&(!i||!r.interface))throw new Error("For IPv6 multicast you must specify `ip` and `interface`");var d=r.socket||Oc.createSocket({type:n,reuseAddr:r.reuseAddr!==!1,toString:function(){return n}});d.on("error",function(u){u.code==="EACCES"||u.code==="EADDRINUSE"?e.emit("error",u):e.emit("warning",u)}),d.on("message",function(u,h){try{u=ln.decode(u)}catch(f){e.emit("warning",f);return}e.emit("packet",u,h),u.type==="query"&&e.emit("query",u,h),u.type==="response"&&e.emit("response",u,h)}),d.on("listening",function(){t||(t=o.port=d.address().port),r.multicast!==!1&&(e.update(),a=setInterval(e.update,5e3),d.setMulticastTTL(r.ttl||255),d.setMulticastLoopback(r.loopback!==!1))});var l=kc(function(u){if(!t||r.bind===!1)return u(null);d.once("error",u),d.bind(t,r.bind||r.interface,function(){d.removeListener("error",u),u(null)})});return l(function(u){if(u)return e.emit("error",u);e.emit("ready")}),e.send=function(u,h,f){if(typeof h=="function")return e.send(u,null,h);f||(f=hn),h?!h.host&&!h.address&&(h.address=o.address):h=o,l(p);function p(m){if(c)return f();if(m)return f(m);var L=ln.encode(u);d.send(L,0,L.length,h.port,h.address||h.host,f)}},e.response=e.respond=function(u,h,f){Array.isArray(u)&&(u={answers:u}),u.type="response",u.flags=(u.flags||0)|ln.AUTHORITATIVE_ANSWER,e.send(u,h,f)},e.query=function(u,h,f,p){if(typeof h=="function")return e.query(u,null,null,h);if(typeof h=="object"&&h&&h.port)return e.query(u,null,h,f);if(typeof f=="function")return e.query(u,h,null,f);p||(p=hn),typeof u=="string"&&(u=[{name:u,type:h||"ANY"}]),Array.isArray(u)&&(u={type:"query",questions:u}),u.type="query",e.send(u,f,p)},e.destroy=function(u){if(u||(u=hn),c)return process.nextTick(u);c=!0,clearInterval(a);for(var h in s)try{d.dropMembership(i,h)}catch{}s={},d.close(u)},e.update=function(){for(var u=r.interface?[].concat(r.interface):Mc(),h=!1,f=0;f<u.length;f++){var p=u[f];if(!s[p])try{d.addMembership(i,p),s[p]=!0,h=!0}catch(m){e.emit("warning",m)}}if(h){if(d.setMulticastInterface)try{d.setMulticastInterface(r.interface||Kc())}catch(m){e.emit("warning",m)}e.emit("networkInterface")}},e};function Kc(){for(var r=pn.networkInterfaces(),e=Object.keys(r),t=0;t<e.length;t++)for(var n=r[e[t]],i=0;i<n.length;i++){var o=n[i];if(so(o.family)&&!o.internal)return pn.platform()==="darwin"&&e[t]==="en0"?o.address:"0.0.0.0"}return"127.0.0.1"}function Mc(){for(var r=pn.networkInterfaces(),e=Object.keys(r),t=[],n=0;n<e.length;n++)for(var i=r[e[n]],o=0;o<i.length;o++){var s=i[o];if(so(s.family)){t.push(s.address);break}}return t}function so(r){return r===4||r==="IPv4"}});var Ws=De(fr=>{(function(){var r,e,t,n,i,o,s,c;c=function(a){var d,l,u,h;return d=(a&255<<24)>>>24,l=(a&255<<16)>>>16,u=(a&65280)>>>8,h=a&255,[d,l,u,h].join(".")},s=function(a){var d,l,u,h,f,p;for(d=[],u=h=0;h<=3&&a.length!==0;u=++h){if(u>0){if(a[0]!==".")throw new Error("Invalid IP");a=a.substring(1)}p=e(a),f=p[0],l=p[1],a=a.substring(l),d.push(f)}if(a.length!==0)throw new Error("Invalid IP");switch(d.length){case 1:if(d[0]>4294967295)throw new Error("Invalid IP");return d[0]>>>0;case 2:if(d[0]>255||d[1]>16777215)throw new Error("Invalid IP");return(d[0]<<24|d[1])>>>0;case 3:if(d[0]>255||d[1]>255||d[2]>65535)throw new Error("Invalid IP");return(d[0]<<24|d[1]<<16|d[2])>>>0;case 4:if(d[0]>255||d[1]>255||d[2]>255||d[3]>255)throw new Error("Invalid IP");return(d[0]<<24|d[1]<<16|d[2]<<8|d[3])>>>0;default:throw new Error("Invalid IP")}},t=function(a){return a.charCodeAt(0)},n=t("0"),o=t("a"),i=t("A"),e=function(a){var d,l,u,h,f;for(h=0,d=10,l="9",u=0,a.length>1&&a[u]==="0"&&(a[u+1]==="x"||a[u+1]==="X"?(u+=2,d=16):"0"<=a[u+1]&&a[u+1]<="9"&&(u++,d=8,l="7")),f=u;u<a.length;){if("0"<=a[u]&&a[u]<=l)h=h*d+(t(a[u])-n)>>>0;else if(d===16)if("a"<=a[u]&&a[u]<="f")h=h*d+(10+t(a[u])-o)>>>0;else if("A"<=a[u]&&a[u]<="F")h=h*d+(10+t(a[u])-i)>>>0;else break;else break;if(h>4294967295)throw new Error("too large");u++}if(u===f)throw new Error("empty octet");return[h,u]},r=function(){function a(d,l){var u,h,f,p;if(typeof d!="string")throw new Error("Missing `net' parameter");if(l||(p=d.split("/",2),d=p[0],l=p[1]),l||(l=32),typeof l=="string"&&l.indexOf(".")>-1){try{this.maskLong=s(l)}catch(m){throw u=m,new Error("Invalid mask: "+l)}for(h=f=32;f>=0;h=--f)if(this.maskLong===4294967295<<32-h>>>0){this.bitmask=h;break}}else if(l||l===0)this.bitmask=parseInt(l,10),this.maskLong=0,this.bitmask>0&&(this.maskLong=4294967295<<32-this.bitmask>>>0);else throw new Error("Invalid mask: empty");try{this.netLong=(s(d)&this.maskLong)>>>0}catch(m){throw u=m,new Error("Invalid net address: "+d)}if(!(this.bitmask<=32))throw new Error("Invalid mask for ip4: "+l);this.size=Math.pow(2,32-this.bitmask),this.base=c(this.netLong),this.mask=c(this.maskLong),this.hostmask=c(~this.maskLong),this.first=this.bitmask<=30?c(this.netLong+1):this.base,this.last=this.bitmask<=30?c(this.netLong+this.size-2):c(this.netLong+this.size-1),this.broadcast=this.bitmask<=30?c(this.netLong+this.size-1):void 0}return a.prototype.contains=function(d){return typeof d=="string"&&(d.indexOf("/")>0||d.split(".").length!==4)&&(d=new a(d)),d instanceof a?this.contains(d.base)&&this.contains(d.broadcast||d.last):(s(d)&this.maskLong)>>>0===(this.netLong&this.maskLong)>>>0},a.prototype.next=function(d){return d==null&&(d=1),new a(c(this.netLong+this.size*d),this.mask)},a.prototype.forEach=function(d){var l,u,h;for(h=s(this.first),u=s(this.last),l=0;h<=u;)d(c(h),h,l),l++,h++},a.prototype.toString=function(){return this.base+"/"+this.bitmask},a}(),fr.ip2long=s,fr.long2ip=c,fr.Netmask=r}).call(fr)});var Bd={};he(Bd,{mdns:()=>Ad});var qi=Symbol.for("@libp2p/peer-discovery");var en=Symbol.for("@libp2p/peer-id");var _e=class extends Error{static name="InvalidParametersError";constructor(e="Invalid parameters"){super(e),this.name="InvalidParametersError"}},yr=class extends Error{static name="InvalidPublicKeyError";constructor(e="Invalid public key"){super(e),this.name="InvalidPublicKeyError"}};var wr=class extends Error{static name="InvalidCIDError";constructor(e="Invalid CID"){super(e),this.name="InvalidCIDError"}},xr=class extends Error{static name="InvalidMultihashError";constructor(e="Invalid Multihash"){super(e),this.name="InvalidMultihashError"}};var jt=class extends Error{static name="UnsupportedKeyTypeError";constructor(e="Unsupported key type"){super(e),this.name="UnsupportedKeyTypeError"}};var Vi=se("node:events"),zi=(r,...e)=>{try{(0,Vi.setMaxListeners)(r,...e)}catch{}};var br=class extends EventTarget{#e=new Map;constructor(){super(),zi(1/0,this)}listenerCount(e){let t=this.#e.get(e);return t==null?0:t.length}addEventListener(e,t,n){super.addEventListener(e,t,n);let i=this.#e.get(e);i==null&&(i=[],this.#e.set(e,i)),i.push({callback:t,once:(n!==!0&&n!==!1&&n?.once)??!1})}removeEventListener(e,t,n){super.removeEventListener(e.toString(),t??null,n);let i=this.#e.get(e);i!=null&&(i=i.filter(({callback:o})=>o!==t),this.#e.set(e,i))}dispatchEvent(e){let t=super.dispatchEvent(e),n=this.#e.get(e.type);return n==null||(n=n.filter(({once:i})=>!i),this.#e.set(e.type,n)),t}safeDispatchEvent(e,t={}){return this.dispatchEvent(new CustomEvent(e,t))}};var ji=Symbol.for("@libp2p/service-capabilities"),Nd=Symbol.for("@libp2p/service-dependencies");var gc=Bt(ao(),1);var wn={};he(wn,{base58btc:()=>z,base58flickr:()=>$c});var dl=new Uint8Array(0);function uo(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 ve(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 lo(r){return new TextEncoder().encode(r)}function ho(r){return new TextDecoder().decode(r)}function Fc(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 i=0;i<r.length;i++){var o=r.charAt(i),s=o.charCodeAt(0);if(t[s]!==255)throw new TypeError(o+" is ambiguous");t[s]=i}var c=r.length,a=r.charAt(0),d=Math.log(c)/Math.log(256),l=Math.log(256)/Math.log(c);function u(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 m=0,L=0,_=0,K=p.length;_!==K&&p[_]===0;)_++,m++;for(var q=(K-_)*l+1>>>0,V=new Uint8Array(q);_!==K;){for(var S=p[_],F=0,$=q-1;(S!==0||F<L)&&$!==-1;$--,F++)S+=256*V[$]>>>0,V[$]=S%c>>>0,S=S/c>>>0;if(S!==0)throw new Error("Non-zero carry");L=F,_++}for(var N=q-L;N!==q&&V[N]===0;)N++;for(var g=a.repeat(m);N<q;++N)g+=r.charAt(V[N]);return g}function h(p){if(typeof p!="string")throw new TypeError("Expected String");if(p.length===0)return new Uint8Array;var m=0;if(p[m]!==" "){for(var L=0,_=0;p[m]===a;)L++,m++;for(var K=(p.length-m)*d+1>>>0,q=new Uint8Array(K);p[m];){var V=t[p.charCodeAt(m)];if(V===255)return;for(var S=0,F=K-1;(V!==0||S<_)&&F!==-1;F--,S++)V+=c*q[F]>>>0,q[F]=V%256>>>0,V=V/256>>>0;if(V!==0)throw new Error("Non-zero carry");_=S,m++}if(p[m]!==" "){for(var $=K-_;$!==K&&q[$]===0;)$++;for(var N=new Uint8Array(L+(K-$)),g=L;$!==K;)N[g++]=q[$++];return N}}}function f(p){var m=h(p);if(m)return m;throw new Error(`Non-${e} character`)}return{encode:u,decodeUnsafe:h,decode:f}}var Hc=Fc,qc=Hc,fo=qc;var fn=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")}},gn=class{name;prefix;baseDecode;prefixCodePoint;constructor(e,t,n){this.name=e,this.prefix=t;let i=t.codePointAt(0);if(i===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=i,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 go(this,e)}},mn=class{decoders;constructor(e){this.decoders=e}or(e){return go(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 go(r,e){return new mn({...r.decoders??{[r.prefix]:r},...e.decoders??{[e.prefix]:e}})}var yn=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(e,t,n,i){this.name=e,this.prefix=t,this.baseEncode=n,this.baseDecode=i,this.encoder=new fn(e,t,n),this.decoder=new gn(e,t,i)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};function Lt({name:r,prefix:e,encode:t,decode:n}){return new yn(r,e,t,n)}function ot({name:r,prefix:e,alphabet:t}){let{encode:n,decode:i}=fo(t,r);return Lt({prefix:e,name:r,encode:n,decode:o=>ve(i(o))})}function Vc(r,e,t,n){let i=r.length;for(;r[i-1]==="=";)--i;let o=new Uint8Array(i*t/8|0),s=0,c=0,a=0;for(let d=0;d<i;++d){let l=e[r[d]];if(l===void 0)throw new SyntaxError(`Non-${n} character`);c=c<<t|l,s+=t,s>=8&&(s-=8,o[a++]=255&c>>s)}if(s>=t||(255&c<<8-s)!==0)throw new SyntaxError("Unexpected end of data");return o}function zc(r,e,t){let n=e[e.length-1]==="=",i=(1<<t)-1,o="",s=0,c=0;for(let a=0;a<r.length;++a)for(c=c<<8|r[a],s+=8;s>t;)s-=t,o+=e[i&c>>s];if(s!==0&&(o+=e[i&c<<t-s]),n)for(;(o.length*t&7)!==0;)o+="=";return o}function jc(r){let e={};for(let t=0;t<r.length;++t)e[r[t]]=t;return e}function j({name:r,prefix:e,bitsPerChar:t,alphabet:n}){let i=jc(n);return Lt({prefix:e,name:r,encode(o){return zc(o,n,t)},decode(o){return Vc(o,i,t,r)}})}var z=ot({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),$c=ot({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var xn={};he(xn,{base32:()=>Qe,base32hex:()=>Xc,base32hexpad:()=>Qc,base32hexpadupper:()=>Jc,base32hexupper:()=>Zc,base32pad:()=>Yc,base32padupper:()=>Wc,base32upper:()=>Gc,base32z:()=>ea});var Qe=j({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Gc=j({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Yc=j({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Wc=j({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Xc=j({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Zc=j({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Qc=j({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Jc=j({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),ea=j({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var bn={};he(bn,{base36:()=>Gt,base36upper:()=>ta});var Gt=ot({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),ta=ot({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var ra=wo,mo=128,na=127,ia=~na,oa=Math.pow(2,31);function wo(r,e,t){e=e||[],t=t||0;for(var n=t;r>=oa;)e[t++]=r&255|mo,r/=128;for(;r&ia;)e[t++]=r&255|mo,r>>>=7;return e[t]=r|0,wo.bytes=t-n+1,e}var sa=En,ca=128,yo=127;function En(r,n){var t=0,n=n||0,i=0,o=n,s,c=r.length;do{if(o>=c)throw En.bytes=0,new RangeError("Could not decode varint");s=r[o++],t+=i<28?(s&yo)<<i:(s&yo)*Math.pow(2,i),i+=7}while(s>=ca);return En.bytes=o-n,t}var aa=Math.pow(2,7),ua=Math.pow(2,14),da=Math.pow(2,21),la=Math.pow(2,28),ha=Math.pow(2,35),pa=Math.pow(2,42),fa=Math.pow(2,49),ga=Math.pow(2,56),ma=Math.pow(2,63),ya=function(r){return r<aa?1:r<ua?2:r<da?3:r<la?4:r<ha?5:r<pa?6:r<fa?7:r<ga?8:r<ma?9:10},wa={encode:ra,decode:sa,encodingLength:ya},xa=wa,Yt=xa;function Wt(r,e=0){return[Yt.decode(r,e),Yt.decode.bytes]}function Ct(r,e,t=0){return Yt.encode(r,e,t),e}function Tt(r){return Yt.encodingLength(r)}function lt(r,e){let t=e.byteLength,n=Tt(r),i=n+Tt(t),o=new Uint8Array(i+t);return Ct(r,o,0),Ct(t,o,n),o.set(e,i),new Pt(r,t,e,o)}function ht(r){let e=ve(r),[t,n]=Wt(e),[i,o]=Wt(e.subarray(n)),s=e.subarray(n+o);if(s.byteLength!==i)throw new Error("Incorrect length");return new Pt(t,i,s,e)}function xo(r,e){if(r===e)return!0;{let t=e;return r.code===t.code&&r.size===t.size&&t.bytes instanceof Uint8Array&&uo(r.bytes,t.bytes)}}var Pt=class{code;size;digest;bytes;constructor(e,t,n,i){this.code=e,this.size=t,this.digest=n,this.bytes=i}};function bo(r,e){let{bytes:t,version:n}=r;switch(n){case 0:return Ea(t,In(r),e??z.encoder);default:return Ia(t,In(r),e??Qe.encoder)}}var Eo=new WeakMap;function In(r){let e=Eo.get(r);if(e==null){let t=new Map;return Eo.set(r,t),t}return e}var Y=class r{code;version;multihash;bytes;"/";constructor(e,t,n,i){this.code=t,this.version=e,this.multihash=n,this.bytes=i,this["/"]=i}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!==Xt)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==va)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=lt(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&&xo(e.multihash,n.multihash)}toString(e){return bo(this,e)}toJSON(){return{"/":bo(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:i,multihash:o,bytes:s}=t;return new r(n,i,o,s??Io(n,i,o.bytes))}else if(t[Sa]===!0){let{version:n,multihash:i,code:o}=t,s=ht(i);return r.create(n,o,s)}else return null}static create(e,t,n){if(typeof t!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(e){case 0:{if(t!==Xt)throw new Error(`Version 0 CID must use dag-pb (code: ${Xt}) block encoding`);return new r(e,t,n,n.bytes)}case 1:{let i=Io(e,t,n.bytes);return new r(e,t,n,i)}default:throw new Error("Invalid version")}}static createV0(e){return r.create(0,Xt,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,i=ve(e.subarray(n,n+t.multihashSize));if(i.byteLength!==t.multihashSize)throw new Error("Incorrect length");let o=i.subarray(t.multihashSize-t.digestSize),s=new Pt(t.multihashCode,t.digestSize,o,i);return[t.version===0?r.createV0(s):r.createV1(t.codec,s),e.subarray(t.size)]}static inspectBytes(e){let t=0,n=()=>{let[u,h]=Wt(e.subarray(t));return t+=h,u},i=n(),o=Xt;if(i===18?(i=0,t=0):o=n(),i!==0&&i!==1)throw new RangeError(`Invalid CID version ${i}`);let s=t,c=n(),a=n(),d=t+a,l=d-s;return{version:i,codec:o,multihashCode:c,digestSize:a,multihashSize:l,size:d}}static parse(e,t){let[n,i]=ba(e,t),o=r.decode(i);if(o.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return In(o).set(n,e),o}};function ba(r,e){switch(r[0]){case"Q":{let t=e??z;return[z.prefix,t.decode(`${z.prefix}${r}`)]}case z.prefix:{let t=e??z;return[z.prefix,t.decode(r)]}case Qe.prefix:{let t=e??Qe;return[Qe.prefix,t.decode(r)]}case Gt.prefix:{let t=e??Gt;return[Gt.prefix,t.decode(r)]}default:{if(e==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[r[0],e.decode(r)]}}}function Ea(r,e,t){let{prefix:n}=t;if(n!==z.prefix)throw Error(`Cannot string encode V0 in ${t.name} encoding`);let i=e.get(n);if(i==null){let o=t.encode(r).slice(1);return e.set(n,o),o}else return i}function Ia(r,e,t){let{prefix:n}=t,i=e.get(n);if(i==null){let o=t.encode(r);return e.set(n,o),o}else return i}var Xt=112,va=18;function Io(r,e,t){let n=Tt(r),i=n+Tt(e),o=new Uint8Array(i+t.byteLength);return Ct(r,o,0),Ct(e,o,n),o.set(t,i),o}var Sa=Symbol.for("@ipld/js-cid/CID");var vn={};he(vn,{identity:()=>Ce});var vo=0,Aa="identity",So=ve;function Ba(r){return lt(vo,So(r))}var Ce={code:vo,name:Aa,encode:So,digest:Ba};function me(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 Sn=se("node:buffer");function ft(r){return new Uint8Array(r.buffer,r.byteOffset,r.byteLength)}function Je(r=0){return ft(Sn.Buffer.alloc(r))}function Se(r=0){return ft(Sn.Buffer.allocUnsafe(r))}var Ao=se("node:buffer");function ae(r,e){return ft(Ao.Buffer.concat(r,e))}var Uo=Symbol.for("@achingbrain/uint8arraylist");function Bo(r,e){if(e==null||e<0)throw new RangeError("index is out of bounds");let t=0;for(let n of r){let i=t+n.byteLength;if(e<i)return{buf:n,index:e-t};t=i}throw new RangeError("index is out of bounds")}function Sr(r){return!!r?.[Uo]}var ye=class r{bufs;length;[Uo]=!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(Sr(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(Sr(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=Bo(this.bufs,e);return t.buf[t.index]}set(e,t){let n=Bo(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(Sr(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:i}=this._subList(e,t);return ae(n,i)}subarray(e,t){let{bufs:n,length:i}=this._subList(e,t);return n.length===1?n[0]:ae(n,i)}sublist(e,t){let{bufs:n,length:i}=this._subList(e,t),o=new r;return o.length=i,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=[],i=0;for(let o=0;o<this.bufs.length;o++){let s=this.bufs[o],c=i,a=c+s.byteLength;if(i=a,e>=a)continue;let d=e>=c&&e<a,l=t>c&&t<=a;if(d&&l){if(e===c&&t===a){n.push(s);break}let u=e-c;n.push(s.subarray(u,u+(t-e)));break}if(d){if(e===0){n.push(s);continue}n.push(s.subarray(e-c));continue}if(l){if(t===a){n.push(s);break}n.push(s.subarray(0,t-c));break}n.push(s)}return{bufs:n,length:t-e}}indexOf(e,t=0){if(!Sr(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 i=n.byteLength;if(i===0)throw new TypeError("search must be at least 1 byte long");let o=256,s=new Int32Array(o);for(let u=0;u<o;u++)s[u]=-1;for(let u=0;u<i;u++)s[n[u]]=u;let c=s,a=this.byteLength-n.byteLength,d=n.byteLength-1,l;for(let u=t;u<=a;u+=l){l=0;for(let h=d;h>=0;h--){let f=this.get(u+h);if(n[h]!==f){l=Math.max(1,h-c[f]);break}}if(l===0)return u}return-1}getInt8(e){let t=this.subarray(e,e+1);return new DataView(t.buffer,t.byteOffset,t.byteLength).getInt8(0)}setInt8(e,t){let n=Se(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 i=Je(2);new DataView(i.buffer,i.byteOffset,i.byteLength).setInt16(0,t,n),this.write(i,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 i=Je(4);new DataView(i.buffer,i.byteOffset,i.byteLength).setInt32(0,t,n),this.write(i,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 i=Je(8);new DataView(i.buffer,i.byteOffset,i.byteLength).setBigInt64(0,t,n),this.write(i,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=Se(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 i=Je(2);new DataView(i.buffer,i.byteOffset,i.byteLength).setUint16(0,t,n),this.write(i,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 i=Je(4);new DataView(i.buffer,i.byteOffset,i.byteLength).setUint32(0,t,n),this.write(i,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 i=Je(8);new DataView(i.buffer,i.byteOffset,i.byteLength).setBigUint64(0,t,n),this.write(i,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 i=Je(4);new DataView(i.buffer,i.byteOffset,i.byteLength).setFloat32(0,t,n),this.write(i,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 i=Je(8);new DataView(i.buffer,i.byteOffset,i.byteLength).setFloat64(0,t,n),this.write(i,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(!me(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((i,o)=>i+o.byteLength,0)),n.length=t,n}};var Do=se("node:buffer");var An={};he(An,{base10:()=>Ua});var Ua=ot({prefix:"9",name:"base10",alphabet:"0123456789"});var Bn={};he(Bn,{base16:()=>La,base16upper:()=>Ca});var La=j({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Ca=j({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Un={};he(Un,{base2:()=>Ta});var Ta=j({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Ln={};he(Ln,{base256emoji:()=>Oa});var Lo=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}"),Pa=Lo.reduce((r,e,t)=>(r[t]=e,r),[]),Da=Lo.reduce((r,e,t)=>{let n=e.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${e}`);return r[n]=t,r},[]);function _a(r){return r.reduce((e,t)=>(e+=Pa[t],e),"")}function Na(r){let e=[];for(let t of r){let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);let i=Da[n];if(i==null)throw new Error(`Non-base256emoji character: ${t}`);e.push(i)}return new Uint8Array(e)}var Oa=Lt({prefix:"\u{1F680}",name:"base256emoji",encode:_a,decode:Na});var Cn={};he(Cn,{base64:()=>ka,base64pad:()=>Ra,base64url:()=>Ka,base64urlpad:()=>Ma});var ka=j({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Ra=j({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Ka=j({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Ma=j({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Tn={};he(Tn,{base8:()=>Fa});var Fa=j({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Pn={};he(Pn,{identity:()=>Ha});var Ha=Lt({prefix:"\0",name:"identity",encode:r=>ho(r),decode:r=>lo(r)});var $l=new TextEncoder,Gl=new TextDecoder;var kn={};he(kn,{sha256:()=>On,sha512:()=>za});var Nn=Bt(se("crypto"),1);function _n({name:r,code:e,encode:t}){return new Dn(r,e,t)}var Dn=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?lt(this.code,t):t.then(n=>lt(this.code,n))}else throw Error("Unknown type, must be binary type")}};var On=_n({name:"sha2-256",code:18,encode:r=>ve(Nn.default.createHash("sha256").update(r).digest())}),za=_n({name:"sha2-512",code:19,encode:r=>ve(Nn.default.createHash("sha512").update(r).digest())});var Zt={...Pn,...Un,...Tn,...An,...Bn,...xn,...bn,...wn,...Cn,...Ln},sh={...kn,...vn};function Po(r,e,t,n){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:n}}}var To=Po("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),Rn=Po("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=Se(r.length);for(let t=0;t<r.length;t++)e[t]=r.charCodeAt(t);return e}),ja={utf8:To,"utf-8":To,hex:Zt.base16,latin1:Rn,ascii:Rn,binary:Rn,...Zt},Ar=ja;function we(r,e="utf8"){let t=Ar[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return e==="utf8"||e==="utf-8"?ft(Do.Buffer.from(r,"utf-8")):t.decoder.decode(`${t.prefix}${r}`)}var _o=se("node:buffer");function k(r,e="utf8"){let t=Ar[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return e==="utf8"||e==="utf-8"?_o.Buffer.from(r.buffer,r.byteOffset,r.byteLength).toString("utf8"):t.encoder.encode(r).substring(1)}var $a=parseInt("11111",2),Kn=parseInt("10000000",2),Ga=parseInt("01111111",2),No={0:Qt,1:Qt,2:Ya,3:Za,4:Qa,5:Xa,6:Wa,16:Qt,22:Qt,48:Qt};function Mn(r,e={offset:0}){let t=r[e.offset]&$a;if(e.offset++,No[t]!=null)return No[t](r,e);throw new Error("No decoder for tag "+t)}function Jt(r,e){let t=0;if((r[e.offset]&Kn)===Kn){let n=r[e.offset]&Ga,i="0x";e.offset++;for(let o=0;o<n;o++,e.offset++)i+=r[e.offset].toString(16).padStart(2,"0");t=parseInt(i,16)}else t=r[e.offset],e.offset++;return t}function Qt(r,e){Jt(r,e);let t=[];for(;!(e.offset>=r.byteLength);){let n=Mn(r,e);if(n===null)break;t.push(n)}return t}function Ya(r,e){let t=Jt(r,e),n=e.offset,i=e.offset+t,o=[];for(let s=n;s<i;s++)s===n&&r[s]===0||o.push(r[s]);return e.offset+=t,Uint8Array.from(o)}function Wa(r,e){let t=Jt(r,e),n=e.offset+t,i=r[e.offset];e.offset++;let o=0,s=0;i<40?(o=0,s=i):i<80?(o=1,s=i-40):(o=2,s=i-80);let c=`${o}.${s}`,a=[];for(;e.offset<n;){let d=r[e.offset];if(e.offset++,a.push(d&127),d<128){a.reverse();let l=0;for(let u=0;u<a.length;u++)l+=a[u]<<u*7;c+=`.${l}`,a=[]}}return c}function Xa(r,e){return e.offset++,null}function Za(r,e){let t=Jt(r,e),n=r[e.offset];e.offset++;let i=r.subarray(e.offset,e.offset+t-1);if(e.offset+=t,n!==0)throw new Error("Unused bits in bit string is unimplemented");return i}function Qa(r,e){let t=Jt(r,e),n=r.subarray(e.offset,e.offset+t);return e.offset+=t,n}function Ja(r){let e=r.toString(16);e.length%2===1&&(e="0"+e);let t=new ye;for(let n=0;n<e.length;n+=2)t.append(Uint8Array.from([parseInt(`${e[n]}${e[n+1]}`,16)]));return t}function Fn(r){if(r.byteLength<128)return Uint8Array.from([r.byteLength]);let e=Ja(r.byteLength);return new ye(Uint8Array.from([e.byteLength|Kn]),e)}function Oo(r){let e=new ye,t=128;return(r.subarray()[0]&t)===t&&e.append(Uint8Array.from([0])),e.append(r),new ye(Uint8Array.from([2]),Fn(e),e)}function ko(r){let e=Uint8Array.from([0]),t=new ye(e,r);return new ye(Uint8Array.from([3]),Fn(t),t)}function Br(r,e=48){let t=new ye;for(let n of r)t.append(n);return new ye(Uint8Array.from([e]),Fn(t),t)}async function Ro(r,e,t,n){let i=await crypto.subtle.importKey("jwk",r,{name:"ECDSA",namedCurve:r.crv??"P-256"},!1,["verify"]);n?.signal?.throwIfAborted();let o=await crypto.subtle.verify({name:"ECDSA",hash:{name:"SHA-256"}},i,e,t.subarray());return n?.signal?.throwIfAborted(),o}var eu=Uint8Array.from([6,8,42,134,72,206,61,3,1,7]),tu=Uint8Array.from([6,5,43,129,4,0,34]),ru=Uint8Array.from([6,5,43,129,4,0,35]),nu={ext:!0,kty:"EC",crv:"P-256"},iu={ext:!0,kty:"EC",crv:"P-384"},ou={ext:!0,kty:"EC",crv:"P-521"},Hn=32,qn=48,Vn=66;function Ko(r){let e=Mn(r);return Mo(e)}function Mo(r){let e=r[1][1][0],t=1,n,i;if(e.byteLength===Hn*2+1)return n=k(e.subarray(t,t+Hn),"base64url"),i=k(e.subarray(t+Hn),"base64url"),new Dt({...nu,key_ops:["verify"],x:n,y:i});if(e.byteLength===qn*2+1)return n=k(e.subarray(t,t+qn),"base64url"),i=k(e.subarray(t+qn),"base64url"),new Dt({...iu,key_ops:["verify"],x:n,y:i});if(e.byteLength===Vn*2+1)return n=k(e.subarray(t,t+Vn),"base64url"),i=k(e.subarray(t+Vn),"base64url"),new Dt({...ou,key_ops:["verify"],x:n,y:i});throw new _e(`coordinates were wrong length, got ${e.byteLength}, expected 65, 97 or 133`)}function Fo(r){return Br([Oo(Uint8Array.from([1])),Br([su(r.crv)],160),Br([ko(new ye(Uint8Array.from([4]),we(r.x??"","base64url"),we(r.y??"","base64url")))],161)]).subarray()}function su(r){if(r==="P-256")return eu;if(r==="P-384")return tu;if(r==="P-521")return ru;throw new _e(`Invalid curve ${r}`)}var Dt=class{type="ECDSA";jwk;_raw;constructor(e){this.jwk=e}get raw(){return this._raw==null&&(this._raw=Fo(this.jwk)),this._raw}toMultihash(){return Ce.digest(_t(this))}toCID(){return Y.createV1(114,this.toMultihash())}toString(){return z.encode(this.toMultihash().bytes).substring(1)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:me(this.raw,e.raw)}async verify(e,t,n){return Ro(this.jwk,t,e,n)}};var Ur=Bt(se("crypto"),1);var Hh=Ur.default.generateKeyPairSync,er=32;var cu=64;function Ho(r,e,t){if(r.byteLength!==er)throw new TypeError('"key" must be 32 bytes in length.');if(!(r instanceof Uint8Array))throw new TypeError('"key" must be a node.js Buffer, or Uint8Array.');if(e.byteLength!==cu)throw new TypeError('"sig" must be 64 bytes in length.');if(!(e instanceof Uint8Array))throw new TypeError('"sig" must be a node.js Buffer, or Uint8Array.');let n=Ur.default.createPublicKey({format:"jwk",key:{crv:"Ed25519",x:k(r,"base64url"),kty:"OKP"}});return Ur.default.verify(null,t instanceof Uint8Array?t:t.subarray(),n,e)}function Vo(r){return r==null?!1:typeof r.then=="function"&&typeof r.catch=="function"&&typeof r.finally=="function"}var Lr=class{type="Ed25519";raw;constructor(e){this.raw=zn(e,er)}toMultihash(){return Ce.digest(_t(this))}toCID(){return Y.createV1(114,this.toMultihash())}toString(){return z.encode(this.toMultihash().bytes).substring(1)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:me(this.raw,e.raw)}verify(e,t,n){n?.signal?.throwIfAborted();let i=Ho(this.raw,t,e);return Vo(i)?i.then(o=>(n?.signal?.throwIfAborted(),o)):i}};function zo(r){return r=zn(r,er),new Lr(r)}function zn(r,e){if(r=Uint8Array.from(r??[]),r.length!==e)throw new _e(`Key must be a Uint8Array of length ${e}, got ${r.length}`);return r}var uu=Math.pow(2,7),du=Math.pow(2,14),lu=Math.pow(2,21),jn=Math.pow(2,28),$n=Math.pow(2,35),Gn=Math.pow(2,42),Yn=Math.pow(2,49),O=128,ee=127;function ue(r){if(r<uu)return 1;if(r<du)return 2;if(r<lu)return 3;if(r<jn)return 4;if(r<$n)return 5;if(r<Gn)return 6;if(r<Yn)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function Wn(r,e,t=0){switch(ue(r)){case 8:e[t++]=r&255|O,r/=128;case 7:e[t++]=r&255|O,r/=128;case 6:e[t++]=r&255|O,r/=128;case 5:e[t++]=r&255|O,r/=128;case 4:e[t++]=r&255|O,r>>>=7;case 3:e[t++]=r&255|O,r>>>=7;case 2:e[t++]=r&255|O,r>>>=7;case 1:{e[t++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return e}function hu(r,e,t=0){switch(ue(r)){case 8:e.set(t++,r&255|O),r/=128;case 7:e.set(t++,r&255|O),r/=128;case 6:e.set(t++,r&255|O),r/=128;case 5:e.set(t++,r&255|O),r/=128;case 4:e.set(t++,r&255|O),r>>>=7;case 3:e.set(t++,r&255|O),r>>>=7;case 2:e.set(t++,r&255|O),r>>>=7;case 1:{e.set(t++,r&255),r>>>=7;break}default:throw new Error("unreachable")}return e}function Xn(r,e){let t=r[e],n=0;if(n+=t&ee,t<O||(t=r[e+1],n+=(t&ee)<<7,t<O)||(t=r[e+2],n+=(t&ee)<<14,t<O)||(t=r[e+3],n+=(t&ee)<<21,t<O)||(t=r[e+4],n+=(t&ee)*jn,t<O)||(t=r[e+5],n+=(t&ee)*$n,t<O)||(t=r[e+6],n+=(t&ee)*Gn,t<O)||(t=r[e+7],n+=(t&ee)*Yn,t<O))return n;throw new RangeError("Could not decode varint")}function pu(r,e){let t=r.get(e),n=0;if(n+=t&ee,t<O||(t=r.get(e+1),n+=(t&ee)<<7,t<O)||(t=r.get(e+2),n+=(t&ee)<<14,t<O)||(t=r.get(e+3),n+=(t&ee)<<21,t<O)||(t=r.get(e+4),n+=(t&ee)*jn,t<O)||(t=r.get(e+5),n+=(t&ee)*$n,t<O)||(t=r.get(e+6),n+=(t&ee)*Gn,t<O)||(t=r.get(e+7),n+=(t&ee)*Yn,t<O))return n;throw new RangeError("Could not decode varint")}function Nt(r,e,t=0){return e==null&&(e=Se(ue(r))),e instanceof Uint8Array?Wn(r,e,t):hu(r,e,t)}function gt(r,e=0){return r instanceof Uint8Array?Xn(r,e):pu(r,e)}var Zn=new Float32Array([-0]),st=new Uint8Array(Zn.buffer);function $o(r,e,t){Zn[0]=r,e[t]=st[0],e[t+1]=st[1],e[t+2]=st[2],e[t+3]=st[3]}function Go(r,e){return st[0]=r[e],st[1]=r[e+1],st[2]=r[e+2],st[3]=r[e+3],Zn[0]}var Qn=new Float64Array([-0]),te=new Uint8Array(Qn.buffer);function Yo(r,e,t){Qn[0]=r,e[t]=te[0],e[t+1]=te[1],e[t+2]=te[2],e[t+3]=te[3],e[t+4]=te[4],e[t+5]=te[5],e[t+6]=te[6],e[t+7]=te[7]}function Wo(r,e){return te[0]=r[e],te[1]=r[e+1],te[2]=r[e+2],te[3]=r[e+3],te[4]=r[e+4],te[5]=r[e+5],te[6]=r[e+6],te[7]=r[e+7],Qn[0]}var fu=BigInt(Number.MAX_SAFE_INTEGER),gu=BigInt(Number.MIN_SAFE_INTEGER),xe=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 mt;if(e<fu&&e>gu)return this.fromNumber(Number(e));let t=e<0n;t&&(e=-e);let n=e>>32n,i=e-(n<<32n);return t&&(n=~n|0n,i=~i|0n,++i>Xo&&(i=0n,++n>Xo&&(n=0n))),new r(Number(i),Number(n))}static fromNumber(e){if(e===0)return mt;let t=e<0;t&&(e=-e);let n=e>>>0,i=(e-n)/4294967296>>>0;return t&&(i=~i>>>0,n=~n>>>0,++n>4294967295&&(n=0,++i>4294967295&&(i=0))),new r(n,i)}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):mt}},mt=new xe(0,0);mt.toBigInt=function(){return 0n};mt.zzEncode=mt.zzDecode=function(){return this};mt.length=function(){return 1};var Xo=4294967296n;function Zo(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 Qo(r,e,t){if(t-e<1)return"";let i,o=[],s=0,c;for(;e<t;)c=r[e++],c<128?o[s++]=c:c>191&&c<224?o[s++]=(c&31)<<6|r[e++]&63:c>239&&c<365?(c=((c&7)<<18|(r[e++]&63)<<12|(r[e++]&63)<<6|r[e++]&63)-65536,o[s++]=55296+(c>>10),o[s++]=56320+(c&1023)):o[s++]=(c&15)<<12|(r[e++]&63)<<6|r[e++]&63,s>8191&&((i??(i=[])).push(String.fromCharCode.apply(String,o)),s=0);return i!=null?(s>0&&i.push(String.fromCharCode.apply(String,o.slice(0,s))),i.join("")):String.fromCharCode.apply(String,o.slice(0,s))}function Jn(r,e,t){let n=t,i,o;for(let s=0;s<r.length;++s)i=r.charCodeAt(s),i<128?e[t++]=i:i<2048?(e[t++]=i>>6|192,e[t++]=i&63|128):(i&64512)===55296&&((o=r.charCodeAt(s+1))&64512)===56320?(i=65536+((i&1023)<<10)+(o&1023),++s,e[t++]=i>>18|240,e[t++]=i>>12&63|128,e[t++]=i>>6&63|128,e[t++]=i&63|128):(e[t++]=i>>12|224,e[t++]=i>>6&63|128,e[t++]=i&63|128);return t-n}function Te(r,e){return RangeError(`index out of range: ${r.pos} + ${e??1} > ${r.len}`)}function Cr(r,e){return(r[e-4]|r[e-3]<<8|r[e-2]<<16|r[e-1]<<24)>>>0}var ei=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,Te(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 Te(this,4);return Cr(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw Te(this,4);return Cr(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw Te(this,4);let e=Go(this.buf,this.pos);return this.pos+=4,e}double(){if(this.pos+8>this.len)throw Te(this,4);let e=Wo(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 Te(this,e);return this.pos+=e,t===n?new Uint8Array(0):this.buf.subarray(t,n)}string(){let e=this.bytes();return Qo(e,0,e.length)}skip(e){if(typeof e=="number"){if(this.pos+e>this.len)throw Te(this,e);this.pos+=e}else do if(this.pos>=this.len)throw Te(this);while((this.buf[this.pos++]&128)!==0);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 xe(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 Te(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 Te(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 Te(this,8);let e=Cr(this.buf,this.pos+=4),t=Cr(this.buf,this.pos+=4);return new xe(e,t)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){let e=Xn(this.buf,this.pos);return this.pos+=ue(e),e}uint64String(){return this.readLongVarint().toString(!0)}sint64(){return this.readLongVarint().zzDecode().toBigInt()}sint64Number(){return this.readLongVarint().zzDecode().toNumber()}sint64String(){return this.readLongVarint().zzDecode().toString()}fixed64(){return this.readFixed64().toBigInt()}fixed64Number(){return this.readFixed64().toNumber()}fixed64String(){return this.readFixed64().toString()}sfixed64(){return this.readFixed64().toBigInt()}sfixed64Number(){return this.readFixed64().toNumber()}sfixed64String(){return this.readFixed64().toString()}};function ti(r){return new ei(r instanceof Uint8Array?r:r.subarray())}function Tr(r,e,t){let n=ti(r);return e.decode(n,void 0,t)}function ri(r){let e=r??8192,t=e>>>1,n,i=e;return function(s){if(s<1||s>t)return Se(s);i+s>e&&(n=Se(e),i=0);let c=n.subarray(i,i+=s);return(i&7)!==0&&(i=(i|7)+1),c}}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 ni(){}var oi=class{head;tail;len;next;constructor(e){this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}},mu=ri();function yu(r){return globalThis.Buffer!=null?Se(r):mu(r)}var rr=class{len;head;tail;states;constructor(){this.len=0,this.head=new yt(ni,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 si((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(Pr,10,xe.fromNumber(e)):this.uint32(e)}sint32(e){return this.uint32((e<<1^e>>31)>>>0)}uint64(e){let t=xe.fromBigInt(e);return this._push(Pr,t.length(),t)}uint64Number(e){return this._push(Wn,ue(e),e)}uint64String(e){return this.uint64(BigInt(e))}int64(e){return this.uint64(e)}int64Number(e){return this.uint64Number(e)}int64String(e){return this.uint64String(e)}sint64(e){let t=xe.fromBigInt(e).zzEncode();return this._push(Pr,t.length(),t)}sint64Number(e){let t=xe.fromNumber(e).zzEncode();return this._push(Pr,t.length(),t)}sint64String(e){return this.sint64(BigInt(e))}bool(e){return this._push(ii,1,e?1:0)}fixed32(e){return this._push(tr,4,e>>>0)}sfixed32(e){return this.fixed32(e)}fixed64(e){let t=xe.fromBigInt(e);return this._push(tr,4,t.lo)._push(tr,4,t.hi)}fixed64Number(e){let t=xe.fromNumber(e);return this._push(tr,4,t.lo)._push(tr,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($o,4,e)}double(e){return this._push(Yo,8,e)}bytes(e){let t=e.length>>>0;return t===0?this._push(ii,1,0):this.uint32(t)._push(xu,t,e)}string(e){let t=Zo(e);return t!==0?this.uint32(t)._push(Jn,t,e):this._push(ii,1,0)}fork(){return this.states=new oi(this),this.head=this.tail=new yt(ni,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(ni,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=yu(this.len),n=0;for(;e!=null;)e.fn(e.val,t,n),n+=e.len,e=e.next;return t}};function ii(r,e,t){e[t]=r&255}function wu(r,e,t){for(;r>127;)e[t++]=r&127|128,r>>>=7;e[t]=r}var si=class extends yt{next;constructor(e,t){super(wu,e,t),this.next=void 0}};function Pr(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 tr(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 xu(r,e,t){e.set(r,t)}globalThis.Buffer!=null&&(rr.prototype.bytes=function(r){let e=r.length>>>0;return this.uint32(e),e>0&&this._push(bu,e,r),this},rr.prototype.string=function(r){let e=globalThis.Buffer.byteLength(r);return this.uint32(e),e>0&&this._push(Eu,e,r),this});function bu(r,e,t){e.set(r,t)}function Eu(r,e,t){r.length<40?Jn(r,e,t):e.utf8Write!=null?e.utf8Write(r,t):e.set(we(r),t)}function ci(){return new rr}function Dr(r,e){let t=ci();return e.encode(r,t,{lengthDelimited:!1}),t.finish()}var Ot;(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"})(Ot||(Ot={}));function _r(r,e,t,n){return{name:r,type:e,encode:t,decode:n}}function ai(r){function e(i){if(r[i.toString()]==null)throw new Error("Invalid enum value");return r[i]}let t=function(o,s){let c=e(o);s.int32(c)},n=function(o){let s=o.int32();return e(s)};return _r("enum",Ot.VARINT,t,n)}function Nr(r,e){return _r("message",Ot.LENGTH_DELIMITED,r,e)}var be;(function(r){r.RSA="RSA",r.Ed25519="Ed25519",r.secp256k1="secp256k1",r.ECDSA="ECDSA"})(be||(be={}));var ui;(function(r){r[r.RSA=0]="RSA",r[r.Ed25519=1]="Ed25519",r[r.secp256k1=2]="secp256k1",r[r.ECDSA=3]="ECDSA"})(ui||(ui={}));(function(r){r.codec=()=>ai(ui)})(be||(be={}));var nr;(function(r){let e;r.codec=()=>(e==null&&(e=Nr((t,n,i={})=>{i.lengthDelimited!==!1&&n.fork(),t.Type!=null&&(n.uint32(8),be.codec().encode(t.Type,n)),t.Data!=null&&(n.uint32(18),n.bytes(t.Data)),i.lengthDelimited!==!1&&n.ldelim()},(t,n,i={})=>{let o={},s=n==null?t.len:t.pos+n;for(;t.pos<s;){let c=t.uint32();switch(c>>>3){case 1:{o.Type=be.codec().decode(t);break}case 2:{o.Data=t.bytes();break}default:{t.skipType(c&7);break}}}return o})),e),r.encode=t=>Dr(t,r.codec()),r.decode=(t,n)=>Tr(t,r.codec(),n)})(nr||(nr={}));var di;(function(r){let e;r.codec=()=>(e==null&&(e=Nr((t,n,i={})=>{i.lengthDelimited!==!1&&n.fork(),t.Type!=null&&(n.uint32(8),be.codec().encode(t.Type,n)),t.Data!=null&&(n.uint32(18),n.bytes(t.Data)),i.lengthDelimited!==!1&&n.ldelim()},(t,n,i={})=>{let o={},s=n==null?t.len:t.pos+n;for(;t.pos<s;){let c=t.uint32();switch(c>>>3){case 1:{o.Type=be.codec().decode(t);break}case 2:{o.Data=t.bytes();break}default:{t.skipType(c&7);break}}}return o})),e),r.encode=t=>Dr(t,r.codec()),r.decode=(t,n)=>Tr(t,r.codec(),n)})(di||(di={}));var et=Bt(se("node:crypto"),1),wt=et&&typeof et=="object"&&"webcrypto"in et?et.webcrypto:et&&typeof et=="object"&&"randomBytes"in et?et:void 0;function Rt(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function ir(r){if(!Number.isSafeInteger(r)||r<0)throw new Error("positive integer expected, got "+r)}function de(r,...e){if(!Rt(r))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(r.length))throw new Error("Uint8Array expected of length "+e+", got length="+r.length)}function ts(r){if(typeof r!="function"||typeof r.create!="function")throw new Error("Hash should be wrapped by utils.createHasher");ir(r.outputLen),ir(r.blockLen)}function Kt(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 rs(r,e){de(r);let t=e.outputLen;if(r.length<t)throw new Error("digestInto() expects output buffer of length at least "+t)}function xt(...r){for(let e=0;e<r.length;e++)r[e].fill(0)}function Or(r){return new DataView(r.buffer,r.byteOffset,r.byteLength)}function Pe(r,e){return r<<32-e|r>>>e}var ns=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",vu=Array.from({length:256},(r,e)=>e.toString(16).padStart(2,"0"));function ct(r){if(de(r),ns)return r.toHex();let e="";for(let t=0;t<r.length;t++)e+=vu[r[t]];return e}var tt={_0:48,_9:57,A:65,F:70,a:97,f:102};function es(r){if(r>=tt._0&&r<=tt._9)return r-tt._0;if(r>=tt.A&&r<=tt.F)return r-(tt.A-10);if(r>=tt.a&&r<=tt.f)return r-(tt.a-10)}function Mt(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);if(ns)return Uint8Array.fromHex(r);let e=r.length,t=e/2;if(e%2)throw new Error("hex string expected, got unpadded hex of length "+e);let n=new Uint8Array(t);for(let i=0,o=0;i<t;i++,o+=2){let s=es(r.charCodeAt(o)),c=es(r.charCodeAt(o+1));if(s===void 0||c===void 0){let a=r[o]+r[o+1];throw new Error('hex string expected, got non-hex character "'+a+'" at index '+o)}n[i]=s*16+c}return n}function is(r){if(typeof r!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(r))}function or(r){return typeof r=="string"&&(r=is(r)),de(r),r}function He(...r){let e=0;for(let n=0;n<r.length;n++){let i=r[n];de(i),e+=i.length}let t=new Uint8Array(e);for(let n=0,i=0;n<r.length;n++){let o=r[n];t.set(o,i),i+=o.length}return t}var kt=class{};function os(r){let e=n=>r().update(or(n)).digest(),t=r();return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=()=>r(),e}function li(r=32){if(wt&&typeof wt.getRandomValues=="function")return wt.getRandomValues(new Uint8Array(r));if(wt&&typeof wt.randomBytes=="function")return Uint8Array.from(wt.randomBytes(r));throw new Error("crypto.getRandomValues must be defined")}function Su(r,e,t,n){if(typeof r.setBigUint64=="function")return r.setBigUint64(e,t,n);let i=BigInt(32),o=BigInt(4294967295),s=Number(t>>i&o),c=Number(t&o),a=n?4:0,d=n?0:4;r.setUint32(e+a,s,n),r.setUint32(e+d,c,n)}function ss(r,e,t){return r&e^~r&t}function cs(r,e,t){return r&e^r&t^e&t}var kr=class extends kt{constructor(e,t,n,i){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=i,this.buffer=new Uint8Array(e),this.view=Or(this.buffer)}update(e){Kt(this),e=or(e),de(e);let{view:t,buffer:n,blockLen:i}=this,o=e.length;for(let s=0;s<o;){let c=Math.min(i-this.pos,o-s);if(c===i){let a=Or(e);for(;i<=o-s;s+=i)this.process(a,s);continue}n.set(e.subarray(s,s+c),this.pos),this.pos+=c,s+=c,this.pos===i&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){Kt(this),rs(e,this),this.finished=!0;let{buffer:t,view:n,blockLen:i,isLE:o}=this,{pos:s}=this;t[s++]=128,xt(this.buffer.subarray(s)),this.padOffset>i-s&&(this.process(n,0),s=0);for(let u=s;u<i;u++)t[u]=0;Su(n,i-8,BigInt(this.length*8),o),this.process(n,0);let c=Or(e),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let d=a/4,l=this.get();if(d>l.length)throw new Error("_sha2: outputLen bigger than state");for(let u=0;u<d;u++)c.setUint32(4*u,l[u],o)}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let n=e.slice(0,t);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());let{blockLen:t,buffer:n,length:i,finished:o,destroyed:s,pos:c}=this;return e.destroyed=s,e.finished=o,e.length=i,e.pos=c,i%t&&e.buffer.set(n),e}clone(){return this._cloneInto()}},rt=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var Au=Uint32Array.from([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]),at=new Uint32Array(64),hi=class extends kr{constructor(e=32){super(64,e,8,!1),this.A=rt[0]|0,this.B=rt[1]|0,this.C=rt[2]|0,this.D=rt[3]|0,this.E=rt[4]|0,this.F=rt[5]|0,this.G=rt[6]|0,this.H=rt[7]|0}get(){let{A:e,B:t,C:n,D:i,E:o,F:s,G:c,H:a}=this;return[e,t,n,i,o,s,c,a]}set(e,t,n,i,o,s,c,a){this.A=e|0,this.B=t|0,this.C=n|0,this.D=i|0,this.E=o|0,this.F=s|0,this.G=c|0,this.H=a|0}process(e,t){for(let u=0;u<16;u++,t+=4)at[u]=e.getUint32(t,!1);for(let u=16;u<64;u++){let h=at[u-15],f=at[u-2],p=Pe(h,7)^Pe(h,18)^h>>>3,m=Pe(f,17)^Pe(f,19)^f>>>10;at[u]=m+at[u-7]+p+at[u-16]|0}let{A:n,B:i,C:o,D:s,E:c,F:a,G:d,H:l}=this;for(let u=0;u<64;u++){let h=Pe(c,6)^Pe(c,11)^Pe(c,25),f=l+h+ss(c,a,d)+Au[u]+at[u]|0,m=(Pe(n,2)^Pe(n,13)^Pe(n,22))+cs(n,i,o)|0;l=d,d=a,a=c,c=s+f|0,s=o,o=i,i=n,n=f+m|0}n=n+this.A|0,i=i+this.B|0,o=o+this.C|0,s=s+this.D|0,c=c+this.E|0,a=a+this.F|0,d=d+this.G|0,l=l+this.H|0,this.set(n,i,o,s,c,a,d,l)}roundClean(){xt(at)}destroy(){this.set(0,0,0,0,0,0,0,0),xt(this.buffer)}};var as=os(()=>new hi);var Ms=Bt(se("node:crypto"),1);var Rr=class extends kt{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,ts(e);let n=or(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 i=this.blockLen,o=new Uint8Array(i);o.set(n.length>i?e.create().update(n).digest():n);for(let s=0;s<o.length;s++)o[s]^=54;this.iHash.update(o),this.oHash=e.create();for(let s=0;s<o.length;s++)o[s]^=106;this.oHash.update(o),xt(o)}update(e){return Kt(this),this.iHash.update(e),this}digestInto(e){Kt(this),de(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:i,destroyed:o,blockLen:s,outputLen:c}=this;return e=e,e.finished=i,e.destroyed=o,e.blockLen=s,e.outputLen=c,e.oHash=t._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},pi=(r,e,t)=>new Rr(r,e).update(t).digest();pi.create=(r,e)=>new Rr(r,e);var mi=BigInt(0),gi=BigInt(1);function sr(r,e){if(typeof e!="boolean")throw new Error(r+" boolean expected, got "+e)}function cr(r){let e=r.toString(16);return e.length&1?"0"+e:e}function us(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return r===""?mi:BigInt("0x"+r)}function Ft(r){return us(ct(r))}function yi(r){return de(r),us(ct(Uint8Array.from(r).reverse()))}function Kr(r,e){return Mt(r.toString(16).padStart(e*2,"0"))}function wi(r,e){return Kr(r,e).reverse()}function le(r,e,t){let n;if(typeof e=="string")try{n=Mt(e)}catch(o){throw new Error(r+" must be hex string or Uint8Array, cause: "+o)}else if(Rt(e))n=Uint8Array.from(e);else throw new Error(r+" must be hex string or Uint8Array");let i=n.length;if(typeof t=="number"&&i!==t)throw new Error(r+" of length "+t+" expected, got "+i);return n}var fi=r=>typeof r=="bigint"&&mi<=r;function ds(r,e,t){return fi(r)&&fi(e)&&fi(t)&&e<=r&&r<t}function ls(r,e,t,n){if(!ds(e,t,n))throw new Error("expected valid "+r+": "+t+" <= n < "+n+", got "+e)}function hs(r){let e;for(e=0;r>mi;r>>=gi,e+=1);return e}var bt=r=>(gi<<BigInt(r))-gi;function ps(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=f=>new Uint8Array(f),i=f=>Uint8Array.of(f),o=n(r),s=n(r),c=0,a=()=>{o.fill(1),s.fill(0),c=0},d=(...f)=>t(s,o,...f),l=(f=n(0))=>{s=d(i(0),f),o=d(),f.length!==0&&(s=d(i(1),f),o=d())},u=()=>{if(c++>=1e3)throw new Error("drbg: tried 1000 values");let f=0,p=[];for(;f<e;){o=d();let m=o.slice();p.push(m),f+=o.length}return He(...p)};return(f,p)=>{a(),l(f);let m;for(;!(m=p(u()));)l();return a(),m}}function ar(r,e,t={}){if(!r||typeof r!="object")throw new Error("expected valid options object");function n(i,o,s){let c=r[i];if(s&&c===void 0)return;let a=typeof c;if(a!==o||c===null)throw new Error(`param "${i}" is invalid: expected ${o}, got ${a}`)}Object.entries(e).forEach(([i,o])=>n(i,o,!1)),Object.entries(t).forEach(([i,o])=>n(i,o,!0))}function xi(r){let e=new WeakMap;return(t,...n)=>{let i=e.get(t);if(i!==void 0)return i;let o=r(t,...n);return e.set(t,o),o}}var oe=BigInt(0),re=BigInt(1),Et=BigInt(2),Bu=BigInt(3),ms=BigInt(4),ys=BigInt(5),ws=BigInt(8);function Ee(r,e){let t=r%e;return t>=oe?t:e+t}function Ie(r,e,t){let n=r;for(;e-- >oe;)n*=n,n%=t;return n}function fs(r,e){if(r===oe)throw new Error("invert: expected non-zero number");if(e<=oe)throw new Error("invert: expected positive modulus, got "+e);let t=Ee(r,e),n=e,i=oe,o=re,s=re,c=oe;for(;t!==oe;){let d=n/t,l=n%t,u=i-s*d,h=o-c*d;n=t,t=l,i=s,o=c,s=u,c=h}if(n!==re)throw new Error("invert: does not exist");return Ee(i,e)}function xs(r,e){let t=(r.ORDER+re)/ms,n=r.pow(e,t);if(!r.eql(r.sqr(n),e))throw new Error("Cannot find square root");return n}function Uu(r,e){let t=(r.ORDER-ys)/ws,n=r.mul(e,Et),i=r.pow(n,t),o=r.mul(e,i),s=r.mul(r.mul(o,Et),i),c=r.mul(o,r.sub(s,r.ONE));if(!r.eql(r.sqr(c),e))throw new Error("Cannot find square root");return c}function Lu(r){if(r<BigInt(3))throw new Error("sqrt is not defined for small field");let e=r-re,t=0;for(;e%Et===oe;)e/=Et,t++;let n=Et,i=It(r);for(;gs(i,n)===1;)if(n++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(t===1)return xs;let o=i.pow(n,e),s=(e+re)/Et;return function(a,d){if(a.is0(d))return d;if(gs(a,d)!==1)throw new Error("Cannot find square root");let l=t,u=a.mul(a.ONE,o),h=a.pow(d,e),f=a.pow(d,s);for(;!a.eql(h,a.ONE);){if(a.is0(h))return a.ZERO;let p=1,m=a.sqr(h);for(;!a.eql(m,a.ONE);)if(p++,m=a.sqr(m),p===l)throw new Error("Cannot find square root");let L=re<<BigInt(l-p-1),_=a.pow(u,L);l=p,u=a.sqr(_),h=a.mul(h,u),f=a.mul(f,_)}return f}}function Cu(r){return r%ms===Bu?xs:r%ws===ys?Uu:Lu(r)}var Tu=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function bi(r){let e={ORDER:"bigint",MASK:"bigint",BYTES:"number",BITS:"number"},t=Tu.reduce((n,i)=>(n[i]="function",n),e);return ar(r,t),r}function Pu(r,e,t){if(t<oe)throw new Error("invalid exponent, negatives unsupported");if(t===oe)return r.ONE;if(t===re)return e;let n=r.ONE,i=e;for(;t>oe;)t&re&&(n=r.mul(n,i)),i=r.sqr(i),t>>=re;return n}function Mr(r,e,t=!1){let n=new Array(e.length).fill(t?r.ZERO:void 0),i=e.reduce((s,c,a)=>r.is0(c)?s:(n[a]=s,r.mul(s,c)),r.ONE),o=r.inv(i);return e.reduceRight((s,c,a)=>r.is0(c)?s:(n[a]=r.mul(s,n[a]),r.mul(s,c)),o),n}function gs(r,e){let t=(r.ORDER-re)/Et,n=r.pow(e,t),i=r.eql(n,r.ONE),o=r.eql(n,r.ZERO),s=r.eql(n,r.neg(r.ONE));if(!i&&!o&&!s)throw new Error("invalid Legendre symbol result");return i?1:o?0:-1}function bs(r,e){e!==void 0&&ir(e);let t=e!==void 0?e:r.toString(2).length,n=Math.ceil(t/8);return{nBitLength:t,nByteLength:n}}function It(r,e,t=!1,n={}){if(r<=oe)throw new Error("invalid field: expected ORDER > 0, got "+r);let i,o;if(typeof e=="object"&&e!=null){if(n.sqrt||t)throw new Error("cannot specify opts in two arguments");let l=e;l.BITS&&(i=l.BITS),l.sqrt&&(o=l.sqrt),typeof l.isLE=="boolean"&&(t=l.isLE)}else typeof e=="number"&&(i=e),n.sqrt&&(o=n.sqrt);let{nBitLength:s,nByteLength:c}=bs(r,i);if(c>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let a,d=Object.freeze({ORDER:r,isLE:t,BITS:s,BYTES:c,MASK:bt(s),ZERO:oe,ONE:re,create:l=>Ee(l,r),isValid:l=>{if(typeof l!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof l);return oe<=l&&l<r},is0:l=>l===oe,isValidNot0:l=>!d.is0(l)&&d.isValid(l),isOdd:l=>(l&re)===re,neg:l=>Ee(-l,r),eql:(l,u)=>l===u,sqr:l=>Ee(l*l,r),add:(l,u)=>Ee(l+u,r),sub:(l,u)=>Ee(l-u,r),mul:(l,u)=>Ee(l*u,r),pow:(l,u)=>Pu(d,l,u),div:(l,u)=>Ee(l*fs(u,r),r),sqrN:l=>l*l,addN:(l,u)=>l+u,subN:(l,u)=>l-u,mulN:(l,u)=>l*u,inv:l=>fs(l,r),sqrt:o||(l=>(a||(a=Cu(r)),a(d,l))),toBytes:l=>t?wi(l,c):Kr(l,c),fromBytes:l=>{if(l.length!==c)throw new Error("Field.fromBytes: expected "+c+" bytes, got "+l.length);return t?yi(l):Ft(l)},invertBatch:l=>Mr(d,l),cmov:(l,u,h)=>h?u:l});return Object.freeze(d)}function Es(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 Ei(r){let e=Es(r);return e+Math.ceil(e/2)}function Is(r,e,t=!1){let n=r.length,i=Es(e),o=Ei(e);if(n<16||n<o||n>1024)throw new Error("expected "+o+"-1024 bytes of input, got "+n);let s=t?yi(r):Ft(r),c=Ee(s,e-re)+re;return t?wi(c,i):Kr(c,i)}var qt=BigInt(0),vt=BigInt(1);function Ht(r,e){let t=e.negate();return r?t:e}function Bs(r,e,t){let n=e==="pz"?s=>s.pz:s=>s.ez,i=Mr(r.Fp,t.map(n));return t.map((s,c)=>s.toAffine(i[c])).map(r.fromAffine)}function Us(r,e){if(!Number.isSafeInteger(r)||r<=0||r>e)throw new Error("invalid window size, expected [1.."+e+"], got W="+r)}function Ii(r,e){Us(r,e);let t=Math.ceil(e/r)+1,n=2**(r-1),i=2**r,o=bt(r),s=BigInt(r);return{windows:t,windowSize:n,mask:o,maxNumber:i,shiftBy:s}}function vs(r,e,t){let{windowSize:n,mask:i,maxNumber:o,shiftBy:s}=t,c=Number(r&i),a=r>>s;c>n&&(c-=o,a+=vt);let d=e*n,l=d+Math.abs(c)-1,u=c===0,h=c<0,f=e%2!==0;return{nextN:a,offset:l,isZero:u,isNeg:h,isNegF:f,offsetF:d}}function Du(r,e){if(!Array.isArray(r))throw new Error("array expected");r.forEach((t,n)=>{if(!(t instanceof e))throw new Error("invalid point at index "+n)})}function _u(r,e){if(!Array.isArray(r))throw new Error("array of scalars expected");r.forEach((t,n)=>{if(!e.isValid(t))throw new Error("invalid scalar at index "+n)})}var vi=new WeakMap,Ls=new WeakMap;function Si(r){return Ls.get(r)||1}function Ss(r){if(r!==qt)throw new Error("invalid wNAF")}function Cs(r,e){return{constTimeNegate:Ht,hasPrecomputes(t){return Si(t)!==1},unsafeLadder(t,n,i=r.ZERO){let o=t;for(;n>qt;)n&vt&&(i=i.add(o)),o=o.double(),n>>=vt;return i},precomputeWindow(t,n){let{windows:i,windowSize:o}=Ii(n,e),s=[],c=t,a=c;for(let d=0;d<i;d++){a=c,s.push(a);for(let l=1;l<o;l++)a=a.add(c),s.push(a);c=a.double()}return s},wNAF(t,n,i){let o=r.ZERO,s=r.BASE,c=Ii(t,e);for(let a=0;a<c.windows;a++){let{nextN:d,offset:l,isZero:u,isNeg:h,isNegF:f,offsetF:p}=vs(i,a,c);i=d,u?s=s.add(Ht(f,n[p])):o=o.add(Ht(h,n[l]))}return Ss(i),{p:o,f:s}},wNAFUnsafe(t,n,i,o=r.ZERO){let s=Ii(t,e);for(let c=0;c<s.windows&&i!==qt;c++){let{nextN:a,offset:d,isZero:l,isNeg:u}=vs(i,c,s);if(i=a,!l){let h=n[d];o=o.add(u?h.negate():h)}}return Ss(i),o},getPrecomputes(t,n,i){let o=vi.get(n);return o||(o=this.precomputeWindow(n,t),t!==1&&(typeof i=="function"&&(o=i(o)),vi.set(n,o))),o},wNAFCached(t,n,i){let o=Si(t);return this.wNAF(o,this.getPrecomputes(o,t,i),n)},wNAFCachedUnsafe(t,n,i,o){let s=Si(t);return s===1?this.unsafeLadder(t,n,o):this.wNAFUnsafe(s,this.getPrecomputes(s,t,i),n,o)},setWindowSize(t,n){Us(n,e),Ls.set(t,n),vi.delete(t)}}}function Ts(r,e,t,n){let i=e,o=r.ZERO,s=r.ZERO;for(;t>qt||n>qt;)t&vt&&(o=o.add(i)),n&vt&&(s=s.add(i)),i=i.double(),t>>=vt,n>>=vt;return{p1:o,p2:s}}function Ps(r,e,t,n){Du(t,r),_u(n,e);let i=t.length,o=n.length;if(i!==o)throw new Error("arrays of points and scalars must have equal length");let s=r.ZERO,c=hs(BigInt(i)),a=1;c>12?a=c-3:c>4?a=c-2:c>0&&(a=2);let d=bt(a),l=new Array(Number(d)+1).fill(s),u=Math.floor((e.BITS-1)/a)*a,h=s;for(let f=u;f>=0;f-=a){l.fill(s);for(let m=0;m<o;m++){let L=n[m],_=Number(L>>BigInt(f)&d);l[_]=l[_].add(t[m])}let p=s;for(let m=l.length-1,L=s;m>0;m--)L=L.add(l[m]),p=p.add(L);if(h=h.add(p),f!==0)for(let m=0;m<a;m++)h=h.double()}return h}function As(r,e){if(e){if(e.ORDER!==r)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return bi(e),e}else return It(r)}function Ds(r,e,t={}){if(!e||typeof e!="object")throw new Error(`expected valid ${r} CURVE object`);for(let c of["p","n","h"]){let a=e[c];if(!(typeof a=="bigint"&&a>qt))throw new Error(`CURVE.${c} must be positive bigint`)}let n=As(e.p,t.Fp),i=As(e.n,t.Fn),s=["Gx","Gy","a",r==="weierstrass"?"b":"d"];for(let c of s)if(!n.isValid(e[c]))throw new Error(`CURVE.${c} must be valid field element of CURVE.Fp`);return{Fp:n,Fn:i}}function _s(r){r.lowS!==void 0&&sr("lowS",r.lowS),r.prehash!==void 0&&sr("prehash",r.prehash)}var Ai=class extends Error{constructor(e=""){super(e)}},nt={Err:Ai,_tlv:{encode:(r,e)=>{let{Err:t}=nt;if(r<0||r>256)throw new t("tlv.encode: wrong tag");if(e.length&1)throw new t("tlv.encode: unpadded data");let n=e.length/2,i=cr(n);if(i.length/2&128)throw new t("tlv.encode: long form length too big");let o=n>127?cr(i.length/2|128):"";return cr(r)+o+i+e},decode(r,e){let{Err:t}=nt,n=0;if(r<0||r>256)throw new t("tlv.encode: wrong tag");if(e.length<2||e[n++]!==r)throw new t("tlv.decode: wrong tlv");let i=e[n++],o=!!(i&128),s=0;if(!o)s=i;else{let a=i&127;if(!a)throw new t("tlv.decode(long): indefinite length not supported");if(a>4)throw new t("tlv.decode(long): byte length is too big");let d=e.subarray(n,n+a);if(d.length!==a)throw new t("tlv.decode: length bytes not complete");if(d[0]===0)throw new t("tlv.decode(long): zero leftmost byte");for(let l of d)s=s<<8|l;if(n+=a,s<128)throw new t("tlv.decode(long): not minimal encoding")}let c=e.subarray(n,n+s);if(c.length!==s)throw new t("tlv.decode: wrong value length");return{v:c,l:e.subarray(n+s)}}},_int:{encode(r){let{Err:e}=nt;if(r<ur)throw new e("integer: negative integers are not allowed");let t=cr(r);if(Number.parseInt(t[0],16)&8&&(t="00"+t),t.length&1)throw new e("unexpected DER parsing assertion: unpadded hex");return t},decode(r){let{Err:e}=nt;if(r[0]&128)throw new e("invalid signature integer: negative");if(r[0]===0&&!(r[1]&128))throw new e("invalid signature integer: unnecessary leading zero");return Ft(r)}},toSig(r){let{Err:e,_int:t,_tlv:n}=nt,i=le("signature",r),{v:o,l:s}=n.decode(48,i);if(s.length)throw new e("invalid signature: left bytes after parsing");let{v:c,l:a}=n.decode(2,o),{v:d,l}=n.decode(2,a);if(l.length)throw new e("invalid signature: left bytes after parsing");return{r:t.decode(c),s:t.decode(d)}},hexFromSig(r){let{_tlv:e,_int:t}=nt,n=e.encode(2,t.encode(r.r)),i=e.encode(2,t.encode(r.s)),o=n+i;return e.encode(48,o)}},ur=BigInt(0),dr=BigInt(1),Nu=BigInt(2),Fr=BigInt(3),Ou=BigInt(4);function ku(r,e,t){function n(i){let o=r.sqr(i),s=r.mul(o,i);return r.add(r.add(s,r.mul(i,e)),t)}return n}function Ns(r,e,t){let{BYTES:n}=r;function i(o){let s;if(typeof o=="bigint")s=o;else{let c=le("private key",o);if(e){if(!e.includes(c.length*2))throw new Error("invalid private key");let a=new Uint8Array(n);a.set(c,a.length-c.length),c=a}try{s=r.fromBytes(c)}catch{throw new Error(`invalid private key: expected ui8a of size ${n}, got ${typeof o}`)}}if(t&&(s=r.create(s)),!r.isValidNot0(s))throw new Error("invalid private key: out of range [1..N-1]");return s}return i}function Ru(r,e={}){let{Fp:t,Fn:n}=Ds("weierstrass",r,e),{h:i,n:o}=r;ar(e,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object",wrapPrivateKey:"boolean"});let{endo:s}=e;if(s&&(!t.is0(r.a)||typeof s.beta!="bigint"||typeof s.splitScalar!="function"))throw new Error('invalid endo: expected "beta": bigint and "splitScalar": function');function c(){if(!t.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}function a(N,g,b){let{x:y,y:w}=g.toAffine(),E=t.toBytes(y);if(sr("isCompressed",b),b){c();let U=!t.isOdd(w);return He(Os(U),E)}else return He(Uint8Array.of(4),E,t.toBytes(w))}function d(N){de(N);let g=t.BYTES,b=g+1,y=2*g+1,w=N.length,E=N[0],U=N.subarray(1);if(w===b&&(E===2||E===3)){let A=t.fromBytes(U);if(!t.isValid(A))throw new Error("bad point: is not on curve, wrong x");let B=h(A),T;try{T=t.sqrt(B)}catch(M){let P=M instanceof Error?": "+M.message:"";throw new Error("bad point: is not on curve, sqrt error"+P)}c();let C=t.isOdd(T);return(E&1)===1!==C&&(T=t.neg(T)),{x:A,y:T}}else if(w===y&&E===4){let A=t.fromBytes(U.subarray(g*0,g*1)),B=t.fromBytes(U.subarray(g*1,g*2));if(!f(A,B))throw new Error("bad point: is not on curve");return{x:A,y:B}}else throw new Error(`bad point: got length ${w}, expected compressed=${b} or uncompressed=${y}`)}let l=e.toBytes||a,u=e.fromBytes||d,h=ku(t,r.a,r.b);function f(N,g){let b=t.sqr(g),y=h(N);return t.eql(b,y)}if(!f(r.Gx,r.Gy))throw new Error("bad curve params: generator point");let p=t.mul(t.pow(r.a,Fr),Ou),m=t.mul(t.sqr(r.b),BigInt(27));if(t.is0(t.add(p,m)))throw new Error("bad curve params: a or b");function L(N,g,b=!1){if(!t.isValid(g)||b&&t.is0(g))throw new Error(`bad point coordinate ${N}`);return g}function _(N){if(!(N instanceof S))throw new Error("ProjectivePoint expected")}let K=xi((N,g)=>{let{px:b,py:y,pz:w}=N;if(t.eql(w,t.ONE))return{x:b,y};let E=N.is0();g==null&&(g=E?t.ONE:t.inv(w));let U=t.mul(b,g),A=t.mul(y,g),B=t.mul(w,g);if(E)return{x:t.ZERO,y:t.ZERO};if(!t.eql(B,t.ONE))throw new Error("invZ was invalid");return{x:U,y:A}}),q=xi(N=>{if(N.is0()){if(e.allowInfinityPoint&&!t.is0(N.py))return;throw new Error("bad point: ZERO")}let{x:g,y:b}=N.toAffine();if(!t.isValid(g)||!t.isValid(b))throw new Error("bad point: x or y not field elements");if(!f(g,b))throw new Error("bad point: equation left != right");if(!N.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});function V(N,g,b,y,w){return b=new S(t.mul(b.px,N),b.py,b.pz),g=Ht(y,g),b=Ht(w,b),g.add(b)}class S{constructor(g,b,y){this.px=L("x",g),this.py=L("y",b,!0),this.pz=L("z",y),Object.freeze(this)}static fromAffine(g){let{x:b,y}=g||{};if(!g||!t.isValid(b)||!t.isValid(y))throw new Error("invalid affine point");if(g instanceof S)throw new Error("projective point not allowed");return t.is0(b)&&t.is0(y)?S.ZERO:new S(b,y,t.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(g){return Bs(S,"pz",g)}static fromBytes(g){return de(g),S.fromHex(g)}static fromHex(g){let b=S.fromAffine(u(le("pointHex",g)));return b.assertValidity(),b}static fromPrivateKey(g){let b=Ns(n,e.allowedPrivateKeyLengths,e.wrapPrivateKey);return S.BASE.multiply(b(g))}static msm(g,b){return Ps(S,n,g,b)}precompute(g=8,b=!0){return $.setWindowSize(this,g),b||this.multiply(Fr),this}_setWindowSize(g){this.precompute(g)}assertValidity(){q(this)}hasEvenY(){let{y:g}=this.toAffine();if(!t.isOdd)throw new Error("Field doesn't support isOdd");return!t.isOdd(g)}equals(g){_(g);let{px:b,py:y,pz:w}=this,{px:E,py:U,pz:A}=g,B=t.eql(t.mul(b,A),t.mul(E,w)),T=t.eql(t.mul(y,A),t.mul(U,w));return B&&T}negate(){return new S(this.px,t.neg(this.py),this.pz)}double(){let{a:g,b}=r,y=t.mul(b,Fr),{px:w,py:E,pz:U}=this,A=t.ZERO,B=t.ZERO,T=t.ZERO,C=t.mul(w,w),G=t.mul(E,E),M=t.mul(U,U),P=t.mul(w,E);return P=t.add(P,P),T=t.mul(w,U),T=t.add(T,T),A=t.mul(g,T),B=t.mul(y,M),B=t.add(A,B),A=t.sub(G,B),B=t.add(G,B),B=t.mul(A,B),A=t.mul(P,A),T=t.mul(y,T),M=t.mul(g,M),P=t.sub(C,M),P=t.mul(g,P),P=t.add(P,T),T=t.add(C,C),C=t.add(T,C),C=t.add(C,M),C=t.mul(C,P),B=t.add(B,C),M=t.mul(E,U),M=t.add(M,M),C=t.mul(M,P),A=t.sub(A,C),T=t.mul(M,G),T=t.add(T,T),T=t.add(T,T),new S(A,B,T)}add(g){_(g);let{px:b,py:y,pz:w}=this,{px:E,py:U,pz:A}=g,B=t.ZERO,T=t.ZERO,C=t.ZERO,G=r.a,M=t.mul(r.b,Fr),P=t.mul(b,E),W=t.mul(y,U),X=t.mul(w,A),J=t.add(b,y),H=t.add(E,U);J=t.mul(J,H),H=t.add(P,W),J=t.sub(J,H),H=t.add(b,w);let ne=t.add(E,A);return H=t.mul(H,ne),ne=t.add(P,X),H=t.sub(H,ne),ne=t.add(y,w),B=t.add(U,A),ne=t.mul(ne,B),B=t.add(W,X),ne=t.sub(ne,B),C=t.mul(G,H),B=t.mul(M,X),C=t.add(B,C),B=t.sub(W,C),C=t.add(W,C),T=t.mul(B,C),W=t.add(P,P),W=t.add(W,P),X=t.mul(G,X),H=t.mul(M,H),W=t.add(W,X),X=t.sub(P,X),X=t.mul(G,X),H=t.add(H,X),P=t.mul(W,H),T=t.add(T,P),P=t.mul(ne,H),B=t.mul(J,B),B=t.sub(B,P),P=t.mul(J,W),C=t.mul(ne,C),C=t.add(C,P),new S(B,T,C)}subtract(g){return this.add(g.negate())}is0(){return this.equals(S.ZERO)}multiply(g){let{endo:b}=e;if(!n.isValidNot0(g))throw new Error("invalid scalar: out of range");let y,w,E=U=>$.wNAFCached(this,U,S.normalizeZ);if(b){let{k1neg:U,k1:A,k2neg:B,k2:T}=b.splitScalar(g),{p:C,f:G}=E(A),{p:M,f:P}=E(T);w=G.add(P),y=V(b.beta,C,M,U,B)}else{let{p:U,f:A}=E(g);y=U,w=A}return S.normalizeZ([y,w])[0]}multiplyUnsafe(g){let{endo:b}=e,y=this;if(!n.isValid(g))throw new Error("invalid scalar: out of range");if(g===ur||y.is0())return S.ZERO;if(g===dr)return y;if($.hasPrecomputes(this))return this.multiply(g);if(b){let{k1neg:w,k1:E,k2neg:U,k2:A}=b.splitScalar(g),{p1:B,p2:T}=Ts(S,y,E,A);return V(b.beta,B,T,w,U)}else return $.wNAFCachedUnsafe(y,g)}multiplyAndAddUnsafe(g,b,y){let w=this.multiplyUnsafe(b).add(g.multiplyUnsafe(y));return w.is0()?void 0:w}toAffine(g){return K(this,g)}isTorsionFree(){let{isTorsionFree:g}=e;return i===dr?!0:g?g(S,this):$.wNAFCachedUnsafe(this,o).is0()}clearCofactor(){let{clearCofactor:g}=e;return i===dr?this:g?g(S,this):this.multiplyUnsafe(i)}toBytes(g=!0){return sr("isCompressed",g),this.assertValidity(),l(S,this,g)}toRawBytes(g=!0){return this.toBytes(g)}toHex(g=!0){return ct(this.toBytes(g))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}S.BASE=new S(r.Gx,r.Gy,t.ONE),S.ZERO=new S(t.ZERO,t.ONE,t.ZERO),S.Fp=t,S.Fn=n;let F=n.BITS,$=Cs(S,e.endo?Math.ceil(F/2):F);return S}function Os(r){return Uint8Array.of(r?2:3)}function Ku(r,e,t={}){ar(e,{hash:"function"},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"});let n=e.randomBytes||li,i=e.hmac||((y,...w)=>pi(e.hash,y,He(...w))),{Fp:o,Fn:s}=r,{ORDER:c,BITS:a}=s;function d(y){let w=c>>dr;return y>w}function l(y){return d(y)?s.neg(y):y}function u(y,w){if(!s.isValidNot0(w))throw new Error(`invalid signature ${y}: out of range 1..CURVE.n`)}class h{constructor(w,E,U){u("r",w),u("s",E),this.r=w,this.s=E,U!=null&&(this.recovery=U),Object.freeze(this)}static fromCompact(w){let E=s.BYTES,U=le("compactSignature",w,E*2);return new h(s.fromBytes(U.subarray(0,E)),s.fromBytes(U.subarray(E,E*2)))}static fromDER(w){let{r:E,s:U}=nt.toSig(le("DER",w));return new h(E,U)}assertValidity(){}addRecoveryBit(w){return new h(this.r,this.s,w)}recoverPublicKey(w){let E=o.ORDER,{r:U,s:A,recovery:B}=this;if(B==null||![0,1,2,3].includes(B))throw new Error("recovery id invalid");if(c*Nu<E&&B>1)throw new Error("recovery id is ambiguous for h>1 curve");let C=B===2||B===3?U+c:U;if(!o.isValid(C))throw new Error("recovery id 2 or 3 invalid");let G=o.toBytes(C),M=r.fromHex(He(Os((B&1)===0),G)),P=s.inv(C),W=q(le("msgHash",w)),X=s.create(-W*P),J=s.create(A*P),H=r.BASE.multiplyUnsafe(X).add(M.multiplyUnsafe(J));if(H.is0())throw new Error("point at infinify");return H.assertValidity(),H}hasHighS(){return d(this.s)}normalizeS(){return this.hasHighS()?new h(this.r,s.neg(this.s),this.recovery):this}toBytes(w){if(w==="compact")return He(s.toBytes(this.r),s.toBytes(this.s));if(w==="der")return Mt(nt.hexFromSig(this));throw new Error("invalid format")}toDERRawBytes(){return this.toBytes("der")}toDERHex(){return ct(this.toBytes("der"))}toCompactRawBytes(){return this.toBytes("compact")}toCompactHex(){return ct(this.toBytes("compact"))}}let f=Ns(s,t.allowedPrivateKeyLengths,t.wrapPrivateKey),p={isValidPrivateKey(y){try{return f(y),!0}catch{return!1}},normPrivateKeyToScalar:f,randomPrivateKey:()=>{let y=c;return Is(n(Ei(y)),y)},precompute(y=8,w=r.BASE){return w.precompute(y,!1)}};function m(y,w=!0){return r.fromPrivateKey(y).toBytes(w)}function L(y){if(typeof y=="bigint")return!1;if(y instanceof r)return!0;let E=le("key",y).length,U=o.BYTES,A=U+1,B=2*U+1;if(!(t.allowedPrivateKeyLengths||s.BYTES===A))return E===A||E===B}function _(y,w,E=!0){if(L(y)===!0)throw new Error("first arg must be private key");if(L(w)===!1)throw new Error("second arg must be public key");return r.fromHex(w).multiply(f(y)).toBytes(E)}let K=e.bits2int||function(y){if(y.length>8192)throw new Error("input is too large");let w=Ft(y),E=y.length*8-a;return E>0?w>>BigInt(E):w},q=e.bits2int_modN||function(y){return s.create(K(y))},V=bt(a);function S(y){return ls("num < 2^"+a,y,ur,V),s.toBytes(y)}function F(y,w,E=$){if(["recovered","canonical"].some(J=>J in E))throw new Error("sign() legacy options not supported");let{hash:U}=e,{lowS:A,prehash:B,extraEntropy:T}=E;A==null&&(A=!0),y=le("msgHash",y),_s(E),B&&(y=le("prehashed msgHash",U(y)));let C=q(y),G=f(w),M=[S(G),S(C)];if(T!=null&&T!==!1){let J=T===!0?n(o.BYTES):T;M.push(le("extraEntropy",J))}let P=He(...M),W=C;function X(J){let H=K(J);if(!s.isValidNot0(H))return;let ne=s.inv(H),zt=r.BASE.multiply(H).toAffine(),St=s.create(zt.x);if(St===ur)return;let ut=s.create(ne*s.create(W+St*G));if(ut===ur)return;let Jr=(zt.x===St?0:2)|Number(zt.y&dr),At=ut;return A&&d(ut)&&(At=l(ut),Jr^=1),new h(St,At,Jr)}return{seed:P,k2sig:X}}let $={lowS:e.lowS,prehash:!1},N={lowS:e.lowS,prehash:!1};function g(y,w,E=$){let{seed:U,k2sig:A}=F(y,w,E);return ps(e.hash.outputLen,s.BYTES,i)(U,A)}r.BASE.precompute(8);function b(y,w,E,U=N){let A=y;w=le("msgHash",w),E=le("publicKey",E),_s(U);let{lowS:B,prehash:T,format:C}=U;if("strict"in U)throw new Error("options.strict was renamed to lowS");if(C!==void 0&&!["compact","der","js"].includes(C))throw new Error('format must be "compact", "der" or "js"');let G=typeof A=="string"||Rt(A),M=!G&&!C&&typeof A=="object"&&A!==null&&typeof A.r=="bigint"&&typeof A.s=="bigint";if(!G&&!M)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let P,W;try{if(M)if(C===void 0||C==="js")P=new h(A.r,A.s);else throw new Error("invalid format");if(G){try{C!=="compact"&&(P=h.fromDER(A))}catch(At){if(!(At instanceof nt.Err))throw At}!P&&C!=="der"&&(P=h.fromCompact(A))}W=r.fromHex(E)}catch{return!1}if(!P||B&&P.hasHighS())return!1;T&&(w=e.hash(w));let{r:X,s:J}=P,H=q(w),ne=s.inv(J),zt=s.create(H*ne),St=s.create(X*ne),ut=r.BASE.multiplyUnsafe(zt).add(W.multiplyUnsafe(St));return ut.is0()?!1:s.create(ut.x)===X}return Object.freeze({getPublicKey:m,getSharedSecret:_,sign:g,verify:b,utils:p,Point:r,Signature:h})}function Mu(r){let e={a:r.a,b:r.b,p:r.Fp.ORDER,n:r.n,h:r.h,Gx:r.Gx,Gy:r.Gy},t=r.Fp,n=It(e.n,r.nBitLength),i={Fp:t,Fn:n,allowedPrivateKeyLengths:r.allowedPrivateKeyLengths,allowInfinityPoint:r.allowInfinityPoint,endo:r.endo,wrapPrivateKey:r.wrapPrivateKey,isTorsionFree:r.isTorsionFree,clearCofactor:r.clearCofactor,fromBytes:r.fromBytes,toBytes:r.toBytes};return{CURVE:e,curveOpts:i}}function Fu(r){let{CURVE:e,curveOpts:t}=Mu(r),n={hash:r.hash,hmac:r.hmac,randomBytes:r.randomBytes,lowS:r.lowS,bits2int:r.bits2int,bits2int_modN:r.bits2int_modN};return{CURVE:e,curveOpts:t,ecdsaOpts:n}}function Hu(r,e){return Object.assign({},e,{ProjectivePoint:e.Point,CURVE:r})}function ks(r){let{CURVE:e,curveOpts:t,ecdsaOpts:n}=Fu(r),i=Ru(e,t),o=Ku(i,n,t);return Hu(r,o)}function Rs(r,e){let t=n=>ks({...r,hash:n});return{...t(e),create:t}}var Hr={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},wp=BigInt(0),qu=BigInt(1),Bi=BigInt(2),Ks=(r,e)=>(r+e/Bi)/e;function Vu(r){let e=Hr.p,t=BigInt(3),n=BigInt(6),i=BigInt(11),o=BigInt(22),s=BigInt(23),c=BigInt(44),a=BigInt(88),d=r*r*r%e,l=d*d*r%e,u=Ie(l,t,e)*l%e,h=Ie(u,t,e)*l%e,f=Ie(h,Bi,e)*d%e,p=Ie(f,i,e)*f%e,m=Ie(p,o,e)*p%e,L=Ie(m,c,e)*m%e,_=Ie(L,a,e)*L%e,K=Ie(_,c,e)*m%e,q=Ie(K,t,e)*l%e,V=Ie(q,s,e)*p%e,S=Ie(V,n,e)*d%e,F=Ie(S,Bi,e);if(!Ui.eql(Ui.sqr(F),r))throw new Error("Cannot find square root");return F}var Ui=It(Hr.p,void 0,void 0,{sqrt:Vu}),lr=Rs({...Hr,Fp:Ui,lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:r=>{let e=Hr.n,t=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-qu*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),i=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),o=t,s=BigInt("0x100000000000000000000000000000000"),c=Ks(o*r,e),a=Ks(-n*r,e),d=Ee(r-c*t-a*i,e),l=Ee(-c*n-a*o,e),u=d>s,h=l>s;if(u&&(d=e-d),h&&(l=e-l),d>s||l>s)throw new Error("splitScalar: Endomorphism failed, k="+r);return{k1neg:u,k1:d,k2neg:h,k2:l}}}},as);var qr=class extends Error{constructor(e="An error occurred while verifying a message"){super(e),this.name="VerificationError"}};function Fs(r,e,t,n){n?.signal?.throwIfAborted();let i=Ms.default.createHash("sha256");if(t instanceof Uint8Array)i.update(t);else for(let s of t)i.update(s);let o=i.digest();try{return lr.verify(e,o,r)}catch(s){throw new qr(String(s))}}var Vr=class{type="secp256k1";raw;_key;constructor(e){this._key=qs(e),this.raw=Hs(this._key)}toMultihash(){return Ce.digest(_t(this))}toCID(){return Y.createV1(114,this.toMultihash())}toString(){return z.encode(this.toMultihash().bytes).substring(1)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:me(this.raw,e.raw)}verify(e,t,n){return Fs(this._key,t,e,n)}};function Vs(r){return new Vr(r)}function Hs(r){return lr.ProjectivePoint.fromHex(r).toRawBytes(!0)}function qs(r){try{return lr.ProjectivePoint.fromHex(r),r}catch(e){throw new yr(String(e))}}function zs(r){let{Type:e,Data:t}=nr.decode(r.digest),n=t??new Uint8Array;switch(e){case be.Ed25519:return zo(n);case be.secp256k1:return Vs(n);case be.ECDSA:return Ko(n);default:throw new jt}}function _t(r){return nr.encode({Type:be[r.type],Data:r.raw})}var js=Symbol.for("nodejs.util.inspect.custom"),zu=114,hr=class{type;multihash;publicKey;string;constructor(e){this.type=e.type,this.multihash=e.multihash,Object.defineProperty(this,"string",{enumerable:!1,writable:!0})}get[Symbol.toStringTag](){return`PeerId(${this.toString()})`}[en]=!0;toString(){return this.string==null&&(this.string=z.encode(this.multihash.bytes).slice(1)),this.string}toMultihash(){return this.multihash}toCID(){return Y.createV1(zu,this.multihash)}toJSON(){return this.toString()}equals(e){if(e==null)return!1;if(e instanceof Uint8Array)return me(this.multihash.bytes,e);if(typeof e=="string")return this.toString()===e;if(e?.toMultihash()?.bytes!=null)return me(this.multihash.bytes,e.toMultihash().bytes);throw new Error("not valid Id")}[js](){return`PeerId(${this.toString()})`}},zr=class extends hr{type="RSA";publicKey;constructor(e){super({...e,type:"RSA"}),this.publicKey=e.publicKey}},jr=class extends hr{type="Ed25519";publicKey;constructor(e){super({...e,type:"Ed25519"}),this.publicKey=e.publicKey}},$r=class extends hr{type="secp256k1";publicKey;constructor(e){super({...e,type:"secp256k1"}),this.publicKey=e.publicKey}},ju=2336,pr=class{type="url";multihash;publicKey;url;constructor(e){this.url=e.toString(),this.multihash=Ce.digest(we(this.url))}[js](){return`PeerId(${this.url})`}[en]=!0;toString(){return this.toCID().toString()}toMultihash(){return this.multihash}toCID(){return Y.createV1(ju,this.toMultihash())}toJSON(){return this.toString()}equals(e){return e==null?!1:(e instanceof Uint8Array&&(e=k(e)),e.toString()===this.toString())}};var $u=114,$s=2336;function Gs(r,e){let t;if(r.charAt(0)==="1"||r.charAt(0)==="Q")t=ht(z.decode(`z${r}`));else{if(r.startsWith("k51qzi5uqu5")||r.startsWith("kzwfwjn5ji4")||r.startsWith("k2k4r8")||r.startsWith("bafz"))return Gu(Y.parse(r));if(e==null)throw new _e('Please pass a multibase decoder for strings that do not start with "1" or "Q"');t=ht(e.decode(r))}return Ys(t)}function Ys(r){if(Wu(r))return new zr({multihash:r});if(Yu(r))try{let e=zs(r);if(e.type==="Ed25519")return new jr({multihash:r,publicKey:e});if(e.type==="secp256k1")return new $r({multihash:r,publicKey:e})}catch{let t=k(r.digest);return new pr(new URL(t))}throw new xr("Supplied PeerID Multihash is invalid")}function Gu(r){if(r?.multihash==null||r.version==null||r.version===1&&r.code!==$u&&r.code!==$s)throw new wr("Supplied PeerID CID is invalid");if(r.code===$s){let e=k(r.multihash.digest);return new pr(new URL(e))}return Ys(r.multihash)}function Yu(r){return r.code===Ce.code}function Wu(r){return r.code===On.code}var Ae=se("node:net");function Gr(r){return!!(0,Ae.isIP)(r)}var Xs=Bt(Ws(),1),Xu=["0.0.0.0/8","10.0.0.0/8","100.64.0.0/10","127.0.0.0/8","169.254.0.0/16","172.16.0.0/12","192.0.0.0/24","192.0.0.0/29","192.0.0.8/32","192.0.0.9/32","192.0.0.10/32","192.0.0.170/32","192.0.0.171/32","192.0.2.0/24","192.31.196.0/24","192.52.193.0/24","192.88.99.0/24","192.168.0.0/16","192.175.48.0/24","198.18.0.0/15","198.51.100.0/24","203.0.113.0/24","240.0.0.0/4","255.255.255.255/32"],Zu=Xu.map(r=>new Xs.Netmask(r));function Li(r){for(let e of Zu)if(e.contains(r))return!0;return!1}function Qu(r){return/^::ffff:([0-9a-fA-F]{1,4}):([0-9a-fA-F]{1,4})$/.test(r)}function Ju(r){let e=r.split(":");if(e.length<2)return!1;let t=e[e.length-1].padStart(4,"0"),n=e[e.length-2].padStart(4,"0"),i=`${parseInt(n.substring(0,2),16)}.${parseInt(n.substring(2),16)}.${parseInt(t.substring(0,2),16)}.${parseInt(t.substring(2),16)}`;return Li(i)}function ed(r){return/^::ffff:([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(r)}function td(r){let e=r.split(":"),t=e[e.length-1];return Li(t)}function rd(r){return/^::$/.test(r)||/^::1$/.test(r)||/^64:ff9b::([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(r)||/^100::([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^2001::([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^2001:2[0-9a-fA-F]:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^2001:db8:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^2002:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^f[c-d]([0-9a-fA-F]{2,2}):/i.test(r)||/^fe[8-9a-bA-B][0-9a-fA-F]:/i.test(r)||/^ff([0-9a-fA-F]{2,2}):/i.test(r)}function Zs(r){return(0,Ae.isIPv4)(r)?Li(r):Qu(r)?Ju(r):ed(r)?td(r):(0,Ae.isIPv6)(r)?rd(r):void 0}function Qs(r){try{let[[e]]=r.stringTuples();return e===4||e===41}catch{}return!1}function Js(r){try{if(!Qs(r))return!1;let[[,e]]=r.stringTuples();return e==null?!1:Zs(e)??!1}catch{}return!0}var Yr=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,i){return this.readAtomically(()=>{let o=0,s=0,c=this.peekChar();if(c===void 0)return;let a=c==="0",d=2**(8*i)-1;for(;;){let l=this.readAtomically(()=>{let u=this.readChar();if(u===void 0)return;let h=Number.parseInt(u,e);if(!Number.isNaN(h))return h});if(l===void 0)break;if(o*=e,o+=l,o>d||(s+=1,t!==void 0&&s>t))return}if(s!==0)return!n&&a&&s>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 i=n*2;if(n<t.length-3){let s=this.readSeparator(":",n,()=>this.readIPv4Addr());if(s!==void 0)return t[i]=s[0],t[i+1]=s[1],t[i+2]=s[2],t[i+3]=s[3],[i+4,!0]}let o=this.readSeparator(":",n,()=>this.readNumber(16,4,!0,2));if(o===void 0)return[i,!1];t[i]=o>>8,t[i+1]=o&255}return[t.length,!1]};return this.readAtomically(()=>{let t=new Uint8Array(16),[n,i]=e(t);if(n===16)return t;if(i||this.readGivenChar(":")===void 0||this.readGivenChar(":")===void 0)return;let o=new Uint8Array(14),s=16-(n+2),[c]=e(o.subarray(0,s));return t.set(o.subarray(0,c),16-c),t})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var Cf=new Yr;var Rf=parseInt("0xFFFF",16),Kf=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);var rc=Ae.isIPv4,ad=Ae.isIPv6,Ci=function(r){let e=0;if(r=r.toString().trim(),rc(r)){let t=new Uint8Array(e+4);return r.split(/\./g).forEach(n=>{t[e++]=parseInt(n,10)&255}),t}if(ad(r)){let t=r.split(":",8),n;for(n=0;n<t.length;n++){let o=rc(t[n]),s;o&&(s=Ci(t[n]),t[n]=k(s.slice(0,2),"base16")),s!=null&&++n<8&&t.splice(n,0,k(s.slice(2,4),"base16"))}if(t[0]==="")for(;t.length<8;)t.unshift("0");else if(t[t.length-1]==="")for(;t.length<8;)t.push("0");else if(t.length<8){for(n=0;n<t.length&&t[n]!=="";n++);let o=[n,1];for(n=9-t.length;n>0;n--)o.push("0");t.splice.apply(t,o)}let i=new Uint8Array(e+16);for(n=0;n<t.length;n++){let o=parseInt(t[n],16);i[e++]=o>>8&255,i[e++]=o&255}return i}throw new Error("invalid ip address")},nc=function(r,e=0,t){e=~~e,t=t??r.length-e;let n=new DataView(r.buffer);if(t===4){let i=[];for(let o=0;o<t;o++)i.push(r[e+o]);return i.join(".")}if(t===16){let i=[];for(let o=0;o<t;o+=2)i.push(n.getUint16(e+o).toString(16));return i.join(":").replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}return""};var Vt={},Ti={},dd=[[4,32,"ip4"],[6,16,"tcp"],[33,16,"dccp"],[41,128,"ip6"],[42,-1,"ip6zone"],[43,8,"ipcidr"],[53,-1,"dns",!0],[54,-1,"dns4",!0],[55,-1,"dns6",!0],[56,-1,"dnsaddr",!0],[132,16,"sctp"],[273,16,"udp"],[275,0,"p2p-webrtc-star"],[276,0,"p2p-webrtc-direct"],[277,0,"p2p-stardust"],[280,0,"webrtc-direct"],[281,0,"webrtc"],[290,0,"p2p-circuit"],[301,0,"udt"],[302,0,"utp"],[400,-1,"unix",!1,!0],[421,-1,"ipfs"],[421,-1,"p2p"],[443,0,"https"],[444,96,"onion"],[445,296,"onion3"],[446,-1,"garlic64"],[448,0,"tls"],[449,-1,"sni"],[460,0,"quic"],[461,0,"quic-v1"],[465,0,"webtransport"],[466,-1,"certhash"],[477,0,"ws"],[478,0,"wss"],[479,0,"p2p-websocket-star"],[480,0,"http"],[481,-1,"http-path"],[777,-1,"memory"]];dd.forEach(r=>{let e=ld(...r);Ti[e.code]=e,Vt[e.name]=e});function ld(r,e,t,n,i){return{code:r,size:e,name:t,resolvable:!!n,path:!!i}}function R(r){if(typeof r=="number"){if(Ti[r]!=null)return Ti[r];throw new Error(`no protocol with code: ${r}`)}else if(typeof r=="string"){if(Vt[r]!=null)return Vt[r];throw new Error(`no protocol with name: ${r}`)}throw new Error(`invalid protocol id type: ${typeof r}`)}var Eg=R("ip4"),Ig=R("ip6"),vg=R("ipcidr");function Ni(r,e){switch(R(r).code){case 4:case 41:return pd(e);case 42:return _i(e);case 43:return k(e,"base10");case 6:case 273:case 33:case 132:return sc(e).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return _i(e);case 421:return yd(e);case 444:return oc(e);case 445:return oc(e);case 466:return md(e);case 481:return globalThis.encodeURIComponent(_i(e));default:return k(e,"base16")}}function Oi(r,e){switch(R(r).code){case 4:return ic(e);case 41:return ic(e);case 42:return Di(e);case 43:return we(e,"base10");case 6:case 273:case 33:case 132:return ki(parseInt(e,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return Di(e);case 421:return fd(e);case 444:return wd(e);case 445:return xd(e);case 466:return gd(e);case 481:return Di(globalThis.decodeURIComponent(e));default:return we(e,"base16")}}var Pi=Object.values(Zt).map(r=>r.decoder),hd=function(){let r=Pi[0].or(Pi[1]);return Pi.slice(2).forEach(e=>r=r.or(e)),r}();function ic(r){if(!Gr(r))throw new Error("invalid ip address");return Ci(r)}function pd(r){let e=nc(r,0,r.length);if(e==null)throw new Error("ipBuff is required");if(!Gr(e))throw new Error("invalid ip address");return e}function ki(r){let e=new ArrayBuffer(2);return new DataView(e).setUint16(0,r),new Uint8Array(e)}function sc(r){return new DataView(r.buffer).getUint16(r.byteOffset)}function Di(r){let e=we(r),t=Uint8Array.from(Nt(e.length));return ae([t,e],t.length+e.length)}function _i(r){let e=gt(r);if(r=r.slice(ue(e)),r.length!==e)throw new Error("inconsistent lengths");return k(r)}function fd(r){let e;r[0]==="Q"||r[0]==="1"?e=ht(z.decode(`z${r}`)).bytes:e=Y.parse(r).multihash.bytes;let t=Uint8Array.from(Nt(e.length));return ae([t,e],t.length+e.length)}function gd(r){let e=hd.decode(r),t=Uint8Array.from(Nt(e.length));return ae([t,e],t.length+e.length)}function md(r){let e=gt(r),t=r.slice(ue(e));if(t.length!==e)throw new Error("inconsistent lengths");return"u"+k(t,"base64url")}function yd(r){let e=gt(r),t=r.slice(ue(e));if(t.length!==e)throw new Error("inconsistent lengths");return k(t,"base58btc")}function wd(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=Qe.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 i=ki(n);return ae([t,i],t.length+i.length)}function xd(r){let e=r.split(":");if(e.length!==2)throw new Error(`failed to parse onion addr: ["'${e.join('", "')}'"]' does not contain a port number`);if(e[0].length!==56)throw new Error(`failed to parse onion addr: ${e[0]} not a Tor onion3 address.`);let t=Qe.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 i=ki(n);return ae([t,i],t.length+i.length)}function oc(r){let e=r.slice(0,r.length-2),t=r.slice(r.length-2),n=k(e,"base32"),i=sc(t);return`${n}:${i}`}function cc(r){r=Ri(r);let e=[],t=[],n=null,i=r.split("/").slice(1);if(i.length===1&&i[0]==="")return{bytes:new Uint8Array,string:"/",tuples:[],stringTuples:[],path:null};for(let o=0;o<i.length;o++){let s=i[o],c=R(s);if(c.size===0){e.push([c.code]),t.push([c.code]);continue}if(o++,o>=i.length)throw new Wr("invalid address: "+r);if(c.path===!0){n=Ri(i.slice(o).join("/")),e.push([c.code,Oi(c.code,n)]),t.push([c.code,n]);break}let a=Oi(c.code,i[o]);e.push([c.code,a]),t.push([c.code,Ni(c.code,a)])}return{string:ac(t),bytes:Xr(e),tuples:e,stringTuples:t,path:n}}function Ki(r){let e=[],t=[],n=null,i=0;for(;i<r.length;){let o=gt(r,i),s=ue(o),c=R(o),a=bd(c,r.slice(i+s));if(a===0){e.push([o]),t.push([o]),i+=s;continue}let d=r.slice(i+s,i+s+a);if(i+=a+s,i>r.length)throw new Wr("Invalid address Uint8Array: "+k(r,"base16"));e.push([o,d]);let l=Ni(o,d);if(t.push([o,l]),c.path===!0){n=l;break}}return{bytes:Uint8Array.from(r),string:ac(t),tuples:e,stringTuples:t,path:n}}function ac(r){let e=[];return r.map(t=>{let n=R(t[0]);return e.push(n.name),t.length>1&&t[1]!=null&&e.push(t[1]),null}),Ri(e.join("/"))}function Xr(r){return ae(r.map(e=>{let t=R(e[0]),n=Uint8Array.from(Nt(t.code));return e.length>1&&e[1]!=null&&(n=ae([n,e[1]])),n}))}function bd(r,e){if(r.size>0)return r.size/8;if(r.size===0)return 0;{let t=gt(e instanceof Uint8Array?e:Uint8Array.from(e));return t+ue(t)}}function Ri(r){return"/"+r.trim().split("/").filter(e=>e).join("/")}var Wr=class extends Error{static name="ParseError";name="ParseError";constructor(e){super(`Error parsing address: ${e}`)}};var Ed=Symbol.for("nodejs.util.inspect.custom"),Fi=Symbol.for("@multiformats/js-multiaddr/multiaddr"),Id=[R("dns").code,R("dns4").code,R("dns6").code,R("dnsaddr").code],Mi=class extends Error{constructor(e="No available resolver"){super(e),this.name="NoAvailableResolverError"}},Zr=class r{bytes;#e;#t;#r;#n;[Fi]=!0;constructor(e){e==null&&(e="");let t;if(e instanceof Uint8Array)t=Ki(e);else if(typeof e=="string"){if(e.length>0&&e.charAt(0)!=="/")throw new Error(`multiaddr "${e}" must start with a "/"`);t=cc(e)}else if(dc(e))t=Ki(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,i,o="",s=R("tcp"),c=R("udp"),a=R("ip4"),d=R("ip6"),l=R("dns6"),u=R("ip6zone");for(let[f,p]of this.stringTuples())f===u.code&&(o=`%${p??""}`),Id.includes(f)&&(t=s.name==="tcp"?"tcp":"udp",i=443,n=`${p??""}${o}`,e=f===l.code?6:4),(f===s.code||f===c.code)&&(t=R(f).name==="tcp"?"tcp":"udp",i=parseInt(p??"")),(f===a.code||f===d.code)&&(t=R(f).name==="tcp"?"tcp":"udp",n=`${p??""}${o}`,e=f===d.code?6:4);if(e==null||t==null||n==null||i==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:i}}protos(){return this.#t.map(([e])=>Object.assign({},R(e)))}protoCodes(){return this.#t.map(([e])=>e)}protoNames(){return this.#t.map(([e])=>R(e).name)}tuples(){return this.#t.map(([e,t])=>t==null?[e]:[e,t])}stringTuples(){return this.#r.map(([e,t])=>t==null?[e]:[e,t])}encapsulate(e){return e=new r(e),new r(this.toString()+e.toString())}decapsulate(e){let t=e.toString(),n=this.toString(),i=n.lastIndexOf(t);if(i<0)throw new Error(`Address ${this.toString()} does not contain subaddress: ${e.toString()}`);return new r(n.slice(0,i))}decapsulateCode(e){let t=this.tuples();for(let n=t.length-1;n>=0;n--)if(t[n][0]===e)return new r(Xr(t.slice(0,n)));return this}getPeerId(){try{let e=[];this.stringTuples().forEach(([n,i])=>{n===Vt.p2p.code&&e.push([n,i]),n===Vt["p2p-circuit"].code&&(e=[])});let t=e.pop();if(t?.[1]!=null){let n=t[1];return n[0]==="Q"||n[0]==="1"?k(z.decode(`z${n}`),"base58btc"):k(Y.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){return this.#n}equals(e){return me(this.bytes,e.bytes)}async resolve(e){let t=this.protos().find(o=>o.resolvable);if(t==null)return[this];let n=uc.get(t.name);if(n==null)throw new Mi(`no available resolver for ${t.name}`);return(await n(this,e)).map(o=>gr(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)}[Ed](){return`Multiaddr(${this.#e})`}};var uc=new Map;function dc(r){return!!r?.[Fi]}function gr(r){return new Zr(r)}function lc(r,e,t,n){let i=()=>{n?.log.trace("query",e),r.query({questions:[{name:e,type:"PTR"}]})};return i(),setInterval(i,t)}function hc(r,e,t,n){if(r.answers==null)return;let i,o=[];if(r.answers.forEach(s=>{switch(s.type){case"PTR":i=s;break;case"TXT":o.push(s);break;default:break}}),r.additionals.forEach(s=>{switch(s.type){case"TXT":o.push(s);break;default:break}}),!(i==null||i?.name!==t||o.length===0||i.data.startsWith(e)))try{let s=o.flatMap(a=>a.data).filter(a=>a.toString().startsWith("dnsaddr=")).map(a=>gr(a.toString().substring(8))),c=s[0].getPeerId();if(c==null)throw new Error("Multiaddr doesn't contain PeerId");return n?.log("peer found %p",c),{id:Gs(c),multiaddrs:s.map(a=>a.decapsulateCode(R("p2p").code))}}catch(s){n?.log.error("failed to parse mdns response",s)}}function pc(r,e,t,n,i,o,s){if(!o){s?.log("not responding to mDNS query as broadcast mode is false");return}if(n.length!==0&&r.questions[0]!=null&&r.questions[0].name===i){let c=[];c.push({name:i,type:"PTR",class:"IN",ttl:120,data:t+"."+i}),n.filter(vd).forEach(a=>{let d="dnsaddr="+a.toString();if(d.length>255){s?.log("multiaddr %a is too long to use in mDNS query response",a);return}if(a.getPeerId()==null){s?.log("multiaddr %a did not have a peer ID so cannot be used in mDNS query response",a);return}c.push({name:t+"."+i,type:"TXT",class:"IN",ttl:120,data:d})}),s?.log.trace("responding to query"),e.respond(c)}}function vd(r){return!!Js(r)}function fc(r){let e="",t="abcdefghijklmnopqrstuvwxyz0123456789";for(let n=0;n<r;n++)e+=t.charAt(Math.floor(Math.random()*t.length));return e}var Qr=class extends br{mdns;log;broadcast;interval;serviceTag;peerName;port;ip;_queryInterval;components;constructor(e,t={}){if(super(),this.log=e.logger.forComponent("libp2p:mdns"),this.broadcast=t.broadcast!==!1,this.interval=t.interval??1e3*10,this.serviceTag=t.serviceTag??"_p2p._udp.local",this.ip=t.ip??"224.0.0.251",this.peerName=t.peerName??fc(63),this.peerName.length>=64)throw new Error("Peer name should be less than 64 chars long");this.port=t.port??5353,this.components=e,this._queryInterval=null,this._onMdnsQuery=this._onMdnsQuery.bind(this),this._onMdnsResponse=this._onMdnsResponse.bind(this),this._onMdnsWarning=this._onMdnsWarning.bind(this),this._onMdnsError=this._onMdnsError.bind(this)}[qi]=this;[Symbol.toStringTag]="@libp2p/mdns";[ji]=["@libp2p/peer-discovery"];isStarted(){return!!this.mdns}async start(){this.mdns==null&&(this.mdns=(0,gc.default)({port:this.port,ip:this.ip}),this.mdns.on("query",this._onMdnsQuery),this.mdns.on("response",this._onMdnsResponse),this.mdns.on("warning",this._onMdnsWarning),this.mdns.on("error",this._onMdnsError),this._queryInterval=lc(this.mdns,this.serviceTag,this.interval,{log:this.log}))}_onMdnsQuery(e){this.mdns!=null&&(this.log.trace("received incoming mDNS query"),pc(e,this.mdns,this.peerName,this.components.addressManager.getAddresses(),this.serviceTag,this.broadcast,{log:this.log}))}_onMdnsResponse(e){this.log.trace("received mDNS query response");try{let t=hc(e,this.peerName,this.serviceTag,{log:this.log});t!=null&&(this.log("discovered peer in mDNS query response %p",t.id),this.dispatchEvent(new CustomEvent("peer",{detail:t})))}catch(t){this.log.error("Error processing peer response",t)}}_onMdnsWarning(e){this.log.error("mdns warning",e)}_onMdnsError(e){this.log.error("mdns error",e)}async stop(){this.mdns!=null&&(this.mdns.removeListener("query",this._onMdnsQuery),this.mdns.removeListener("response",this._onMdnsResponse),this.mdns.removeListener("warning",this._onMdnsWarning),this.mdns.removeListener("error",this._onMdnsError),this._queryInterval!=null&&(clearInterval(this._queryInterval),this._queryInterval=null),await new Promise(e=>{this.mdns!=null?this.mdns.destroy(e):e()}),this.mdns=void 0)}};function Ad(r={}){return e=>new Qr(e,r)}return Ec(Bd);})();
|
|
3
3
|
/*! Bundled license information:
|
|
4
4
|
|
|
5
5
|
@noble/hashes/esm/utils.js:
|
|
6
6
|
(*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
7
7
|
|
|
8
|
-
@noble/curves/esm/
|
|
8
|
+
@noble/curves/esm/utils.js:
|
|
9
9
|
@noble/curves/esm/abstract/modular.js:
|
|
10
10
|
@noble/curves/esm/abstract/curve.js:
|
|
11
11
|
@noble/curves/esm/abstract/weierstrass.js:
|