@libp2p/mdns 11.0.33 → 11.0.34
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 +1 -1
- package/package.json +8 -8
package/dist/index.min.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
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 hc=Object.create;var mr=Object.defineProperty;var pc=Object.getOwnPropertyDescriptor;var gc=Object.getOwnPropertyNames;var fc=Object.getPrototypeOf,mc=Object.prototype.hasOwnProperty;var ne=(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),ie=(r,e)=>{for(var t in e)mr(r,t,{get:e[t],enumerable:!0})},Xi=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of gc(e))!mc.call(r,i)&&i!==t&&mr(r,i,{get:()=>e[i],enumerable:!(n=pc(e,i))||n.enumerable});return r};var Pt=(r,e,t)=>(t=r!=null?hc(fc(r)):{},Xi(e||!r||!r.__esModule?mr(t,"default",{value:r,enumerable:!0}):t,r)),yc=r=>Xi(mr({},"__esModule",{value:!0}),r);var to=Te(cn=>{"use strict";cn.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};cn.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 ro=Te(an=>{"use strict";an.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};an.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 no=Te(un=>{"use strict";un.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};un.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 io=Te(dn=>{"use strict";dn.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};dn.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 oo=Te(ln=>{"use strict";ln.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}`};ln.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 ao=Te((co,hn)=>{var so=function(r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.decode=d,r.encode=g,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 m=l.length,f=0;for(let y=0;y<m;){let x=l.charCodeAt(y++);x===46?(p[h++]=f,f=0):f=f*10+(x-48)}return p[h]=f,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 m=h+i,f=-1,y=0,x=0,E=!0,L=!1;p=p||new Uint8Array(h+i);for(let T=0;T<l.length;T++){let B=l.charCodeAt(T);B===58?(E?f!==-1?(h<m&&(p[h]=0),h<m-1&&(p[h+1]=0),h+=2):h<m&&(f=h):(L===!0?(h<m&&(p[h]=x),h++):(h<m&&(p[h]=y>>8),h<m-1&&(p[h+1]=y&255),h+=2),y=0,x=0),E=!0,L=!1):B===46?(h<m&&(p[h]=x),h++,x=0,y=0,E=!1,L=!0):(E=!1,B>=97?B-=87:B>=65?B-=55:(B-=48,x=x*10+B),y=(y<<4)+B)}if(E===!1)L===!0?(h<m&&(p[h]=x),h++):(h<m&&(p[h]=y>>8),h<m-1&&(p[h+1]=y&255),h+=2);else if(f===0)h<m&&(p[h]=0),h<m-1&&(p[h+1]=0),h+=2;else if(f!==-1){h+=2;for(let T=Math.min(h-1,m-1);T>=f+2;T--)p[T]=p[T-2];p[f]=0,p[f+1]=0,f=h}if(f!==h&&f!==-1)for(h>m-2&&(h=m-2);m>f;)p[--m]=h<m&&h>f?p[--h]:0;else for(;h<m;)p[h++]=0;return p},decode(l,p){p=~~p;let h="";for(let m=0;m<i;m+=2)m!==0&&(h+=":"),h+=(l[p+m]<<8|l[p+m+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 g(l,p,h){h=~~h;let m=c(l);return typeof p=="function"&&(p=p(h+m)),m===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 so}):typeof hn=="object"&&typeof co=="object"&&(hn.exports=so)});var ho=Te(v=>{"use strict";var A=ne("buffer").Buffer,Ye=to(),wc=ro(),xc=no(),Ir=io(),pn=oo(),gt=ao(),bc=0,uo=32768,gn=32768,Ec=~gn,lo=32768,Ic=~lo,w=v.name={};w.encode=function(r,e,t,{mail:n=!1}={}){e||(e=A.alloc(w.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,w.encode.bytes=t-i,e};w.encode.bytes=0;w.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 w.decode.bytes=s,n.length===0?".":n.join(".")};w.decode.bytes=0;w.encodingLength=function(r){return r==="."||r===".."?1:A.byteLength(r.replace(/^\.|\.$/gm,""))+2};var O={};O.encode=function(r,e,t){e||(e=A.alloc(O.encodingLength(r))),t||(t=0);let n=e.write(r,t+1);return e[t]=n,O.encode.bytes=n+1,e};O.encode.bytes=0;O.decode=function(r,e){e||(e=0);let t=r[e],n=r.toString("utf-8",e+1,e+1+t);return O.decode.bytes=t+1,n};O.decode.bytes=0;O.encodingLength=function(r){return A.byteLength(r)+1};var Se={};Se.encode=function(r,e,t){e||(e=Se.encodingLength(r)),t||(t=0);let n=(r.flags||0)&32767,i=r.type==="response"?uo:bc;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};Se.encode.bytes=12;Se.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&uo?"response":"query",flags:t&32767,flag_qr:(t>>15&1)===1,opcode:xc.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:wc.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))}};Se.decode.bytes=12;Se.encodingLength=function(){return 12};var Me=v.unknown={};Me.encode=function(r,e,t){return e||(e=A.alloc(Me.encodingLength(r))),t||(t=0),e.writeUInt16BE(r.length,t),r.copy(e,t+2),Me.encode.bytes=r.length+2,e};Me.encode.bytes=0;Me.decode=function(r,e){e||(e=0);let t=r.readUInt16BE(e),n=r.slice(e+2,e+2+t);return Me.decode.bytes=t+2,n};Me.decode.bytes=0;Me.encodingLength=function(r){return r.length+2};var Fe=v.ns={};Fe.encode=function(r,e,t){return e||(e=A.alloc(Fe.encodingLength(r))),t||(t=0),w.encode(r,e,t+2),e.writeUInt16BE(w.encode.bytes,t),Fe.encode.bytes=w.encode.bytes+2,e};Fe.encode.bytes=0;Fe.decode=function(r,e){e||(e=0);let t=r.readUInt16BE(e),n=w.decode(r,e+2);return Fe.decode.bytes=t+2,n};Fe.decode.bytes=0;Fe.encodingLength=function(r){return w.encodingLength(r)+2};var qe=v.soa={};qe.encode=function(r,e,t){e||(e=A.alloc(qe.encodingLength(r))),t||(t=0);let n=t;return t+=2,w.encode(r.mname,e,t),t+=w.encode.bytes,w.encode(r.rname,e,t,{mail:!0}),t+=w.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=w.decode(r,e),e+=w.decode.bytes,n.rname=w.decode(r,e,{mail:!0}),e+=w.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+w.encodingLength(r.mname)+w.encodingLength(r.rname)};var Ve=v.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=v.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 He=v.hinfo={};He.encode=function(r,e,t){e||(e=A.alloc(He.encodingLength(r))),t||(t=0);let n=t;return t+=2,O.encode(r.cpu,e,t),t+=O.encode.bytes,O.encode(r.os,e,t),t+=O.encode.bytes,e.writeUInt16BE(t-n-2,n),He.encode.bytes=t-n,e};He.encode.bytes=0;He.decode=function(r,e){e||(e=0);let t=e,n={};return e+=2,n.cpu=O.decode(r,e),e+=O.decode.bytes,n.os=O.decode(r,e),e+=O.decode.bytes,He.decode.bytes=e-t,n};He.decode.bytes=0;He.encodingLength=function(r){return O.encodingLength(r.cpu)+O.encodingLength(r.os)+2};var ve=v.ptr={},vc=v.cname=ve,Ac=v.dname=ve;ve.encode=function(r,e,t){return e||(e=A.alloc(ve.encodingLength(r))),t||(t=0),w.encode(r,e,t+2),e.writeUInt16BE(w.encode.bytes,t),ve.encode.bytes=w.encode.bytes+2,e};ve.encode.bytes=0;ve.decode=function(r,e){e||(e=0);let t=w.decode(r,e+2);return ve.decode.bytes=w.decode.bytes+2,t};ve.decode.bytes=0;ve.encodingLength=function(r){return w.encodingLength(r)+2};var je=v.srv={};je.encode=function(r,e,t){e||(e=A.alloc(je.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),w.encode(r.target,e,t+8);let n=w.encode.bytes+6;return e.writeUInt16BE(n,t),je.encode.bytes=n+2,e};je.encode.bytes=0;je.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=w.decode(r,e+8),je.decode.bytes=t+2,n};je.decode.bytes=0;je.encodingLength=function(r){return 8+w.encodingLength(r.target)};var ae=v.caa={};ae.ISSUER_CRITICAL=128;ae.encode=function(r,e,t){let n=ae.encodingLength(r);return e||(e=A.alloc(ae.encodingLength(r))),t||(t=0),r.issuerCritical&&(r.flags=ae.ISSUER_CRITICAL),e.writeUInt16BE(n-2,t),t+=2,e.writeUInt8(r.flags||0,t),t+=1,O.encode(r.tag,e,t),t+=O.encode.bytes,e.write(r.value,t),t+=A.byteLength(r.value),ae.encode.bytes=n,e};ae.encode.bytes=0;ae.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=O.decode(r,e),e+=O.decode.bytes,i.value=r.toString("utf-8",e,n+t),i.issuerCritical=!!(i.flags&ae.ISSUER_CRITICAL),ae.decode.bytes=t+2,i};ae.decode.bytes=0;ae.encodingLength=function(r){return O.encodingLength(r.tag)+O.encodingLength(r.value)+2};var nt=v.mx={};nt.encode=function(r,e,t){e||(e=A.alloc(nt.encodingLength(r))),t||(t=0);let n=t;return t+=2,e.writeUInt16BE(r.preference||0,t),t+=2,w.encode(r.exchange,e,t),t+=w.encode.bytes,e.writeUInt16BE(t-n-2,n),nt.encode.bytes=t-n,e};nt.encode.bytes=0;nt.decode=function(r,e){e||(e=0);let t=e,n={};return e+=2,n.preference=r.readUInt16BE(e),e+=2,n.exchange=w.decode(r,e),e+=w.decode.bytes,nt.decode.bytes=e-t,n};nt.encodingLength=function(r){return 4+w.encodingLength(r.exchange)};var $e=v.a={};$e.encode=function(r,e,t){return e||(e=A.alloc($e.encodingLength(r))),t||(t=0),e.writeUInt16BE(4,t),t+=2,gt.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=gt.v4.decode(r,e);return $e.decode.bytes=6,t};$e.decode.bytes=0;$e.encodingLength=function(){return 6};var Ge=v.aaaa={};Ge.encode=function(r,e,t){return e||(e=A.alloc(Ge.encodingLength(r))),t||(t=0),e.writeUInt16BE(16,t),t+=2,gt.v6.encode(r,e,t),Ge.encode.bytes=18,e};Ge.encode.bytes=0;Ge.decode=function(r,e){e||(e=0),e+=2;let t=gt.v6.decode(r,e);return Ge.decode.bytes=18,t};Ge.decode.bytes=0;Ge.encodingLength=function(){return 18};var oe=v.option={};oe.encode=function(r,e,t){e||(e=A.alloc(oe.encodingLength(r))),t||(t=0);let n=t,i=pn.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||gt.familyOf(r.ip),a=gt.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 g=r.tags.length*2;e.writeUInt16BE(g,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 oe.encode.bytes=t-n,e};oe.encode.bytes=0;oe.decode=function(r,e){e||(e=0);let t={};t.code=r.readUInt16BE(e),t.type=pn.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=gt.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 oe.decode.bytes=n+4,t};oe.decode.bytes=0;oe.encodingLength=function(r){if(r.data)return r.data.length+4;switch(pn.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 de=v.opt={};de.encode=function(r,e,t){e||(e=A.alloc(de.encodingLength(r))),t||(t=0);let n=t,i=Ot(r,oe);return e.writeUInt16BE(i,t),t=Zt(r,oe,e,t+2),de.encode.bytes=t-n,e};de.encode.bytes=0;de.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++]=oe.decode(r,e),e+=oe.decode.bytes,i-=oe.decode.bytes;return de.decode.bytes=e-t,n};de.decode.bytes=0;de.encodingLength=function(r){return 2+Ot(r||[],oe)};var ee=v.dnskey={};ee.PROTOCOL_DNSSEC=3;ee.ZONE_KEY=128;ee.SECURE_ENTRYPOINT=32768;ee.encode=function(r,e,t){e||(e=A.alloc(ee.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(ee.PROTOCOL_DNSSEC,t),t+=1,e.writeUInt8(r.algorithm,t),t+=1,i.copy(e,t,0,i.length),t+=i.length,ee.encode.bytes=t-n,e.writeUInt16BE(ee.encode.bytes-2,n),e};ee.encode.bytes=0;ee.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)!==ee.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,ee.decode.bytes=e-t,n};ee.decode.bytes=0;ee.encodingLength=function(r){return 6+A.byteLength(r.key)};var Pe=v.rrsig={};Pe.encode=function(r,e,t){e||(e=A.alloc(Pe.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(Ye.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,w.encode(r.signersName,e,t),t+=w.encode.bytes,i.copy(e,t,0,i.length),t+=i.length,Pe.encode.bytes=t-n,e.writeUInt16BE(Pe.encode.bytes-2,n),e};Pe.encode.bytes=0;Pe.decode=function(r,e){e||(e=0);let t=e;var n={},i=r.readUInt16BE(e);return e+=2,n.typeCovered=Ye.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=w.decode(r,e),e+=w.decode.bytes,n.signature=r.slice(e,t+i+2),e+=n.signature.length,Pe.decode.bytes=e-t,n};Pe.decode.bytes=0;Pe.encodingLength=function(r){return 20+w.encodingLength(r.signersName)+A.byteLength(r.signature)};var Oe=v.rp={};Oe.encode=function(r,e,t){e||(e=A.alloc(Oe.encodingLength(r))),t||(t=0);let n=t;return t+=2,w.encode(r.mbox||".",e,t,{mail:!0}),t+=w.encode.bytes,w.encode(r.txt||".",e,t),t+=w.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=w.decode(r,e,{mail:!0})||".",e+=w.decode.bytes,n.txt=w.decode(r,e)||".",e+=w.decode.bytes,Oe.decode.bytes=e-t,n};Oe.decode.bytes=0;Oe.encodingLength=function(r){return 2+w.encodingLength(r.mbox||".")+w.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=Ye.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 g=Ye.toString(o<<8|a<<3|u);i.push(g)}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=Ye.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=v.nsec={};Ne.encode=function(r,e,t){e||(e=A.alloc(Ne.encodingLength(r))),t||(t=0);let n=t;return t+=2,w.encode(r.nextDomain,e,t),t+=w.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=w.decode(r,e),e+=w.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+w.encodingLength(r.nextDomain)+$.encodingLength(r.rrtypes)};var De=v.nsec3={};De.encode=function(r,e,t){e||(e=A.alloc(De.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,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;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,De.decode.bytes=e-t,n};De.decode.bytes=0;De.encodingLength=function(r){return 8+r.salt.length+r.nextDomain.length+$.encodingLength(r.rrtypes)};var ke=v.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 ue=v.sshfp={};ue.getFingerprintLengthForHashType=function(e){switch(e){case 1:return 20;case 2:return 32}};ue.encode=function(e,t,n){t||(t=A.alloc(ue.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!==ue.getFingerprintLengthForHashType(e.hash))throw new Error("Invalid fingerprint length");return o.copy(t,n),n+=o.byteLength,ue.encode.bytes=n-i,t.writeUInt16BE(ue.encode.bytes-2,i),t};ue.encode.bytes=0;ue.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=ue.getFingerprintLengthForHashType(i.hash);return i.fingerprint=e.slice(t,t+o).toString("hex").toUpperCase(),t+=o,ue.decode.bytes=t-n,i};ue.decode.bytes=0;ue.encodingLength=function(r){return 4+A.from(r.fingerprint,"hex").byteLength};var _e=v.naptr={};_e.encode=function(r,e,t){e||(e=A.alloc(_e.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,O.encode(r.flags,e,t),t+=O.encode.bytes,O.encode(r.services,e,t),t+=O.encode.bytes,O.encode(r.regexp,e,t),t+=O.encode.bytes,w.encode(r.replacement,e,t),t+=w.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,n={};return e+=2,n.order=r.readUInt16BE(e),e+=2,n.preference=r.readUInt16BE(e),e+=2,n.flags=O.decode(r,e),e+=O.decode.bytes,n.services=O.decode(r,e),e+=O.decode.bytes,n.regexp=O.decode(r,e),e+=O.decode.bytes,n.replacement=w.decode(r,e),e+=w.decode.bytes,_e.decode.bytes=e-t,n};_e.decode.bytes=0;_e.encodingLength=function(r){return O.encodingLength(r.flags)+O.encodingLength(r.services)+O.encodingLength(r.regexp)+w.encodingLength(r.replacement)+6};var Re=v.tlsa={};Re.encode=function(r,e,t){e||(e=A.alloc(Re.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,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={},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,Re.decode.bytes=e-t,n};Re.decode.bytes=0;Re.encodingLength=function(r){return 5+A.byteLength(r.certificate)};var fn=v.record=function(r){switch(r.toUpperCase()){case"A":return $e;case"PTR":return ve;case"CNAME":return vc;case"DNAME":return Ac;case"TXT":return Ve;case"NULL":return ze;case"AAAA":return Ge;case"SRV":return je;case"HINFO":return He;case"CAA":return ae;case"NS":return Fe;case"SOA":return qe;case"MX":return nt;case"OPT":return de;case"DNSKEY":return ee;case"RRSIG":return Pe;case"RP":return Oe;case"NSEC":return Ne;case"NSEC3":return De;case"SSHFP":return ue;case"DS":return ke;case"NAPTR":return _e;case"TLSA":return Re}return Me},W=v.answer={};W.encode=function(r,e,t){e||(e=A.alloc(W.encodingLength(r))),t||(t=0);let n=t;if(w.encode(r.name,e,t),t+=w.encode.bytes,e.writeUInt16BE(Ye.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,de.encode(r.options||[],e,t),t+=de.encode.bytes}else{let i=Ir.toClass(r.class===void 0?"IN":r.class);r.flush&&(i|=gn),e.writeUInt16BE(i,t+2),e.writeUInt32BE(r.ttl||0,t+4),t+=8;let o=fn(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=w.decode(r,e),e+=w.decode.bytes,t.type=Ye.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=de.decode(r,e+8),e+=8+de.decode.bytes;else{let i=r.readUInt16BE(e+2);t.ttl=r.readUInt32BE(e+4),t.class=Ir.toString(i&Ec),t.flush=!!(i&gn);let o=fn(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 w.encodingLength(r.name)+8+fn(r.type).encodingLength(e)};var Ae=v.question={};Ae.encode=function(r,e,t){e||(e=A.alloc(Ae.encodingLength(r))),t||(t=0);let n=t;return w.encode(r.name,e,t),t+=w.encode.bytes,e.writeUInt16BE(Ye.toType(r.type),t),t+=2,e.writeUInt16BE(Ir.toClass(r.class===void 0?"IN":r.class),t),t+=2,Ae.encode.bytes=t-n,r};Ae.encode.bytes=0;Ae.decode=function(r,e){e||(e=0);let t=e,n={};return n.name=w.decode(r,e),e+=w.decode.bytes,n.type=Ye.toString(r.readUInt16BE(e)),e+=2,n.class=Ir.toString(r.readUInt16BE(e)),e+=2,!!(n.class&lo)&&(n.class&=Ic),Ae.decode.bytes=e-t,n};Ae.decode.bytes=0;Ae.encodingLength=function(r){return w.encodingLength(r.name)+4};v.AUTHORITATIVE_ANSWER=1024;v.TRUNCATED_RESPONSE=512;v.RECURSION_DESIRED=256;v.RECURSION_AVAILABLE=128;v.AUTHENTIC_DATA=32;v.CHECKING_DISABLED=16;v.DNSSEC_OK=32768;v.encode=function(r,e,t){let n=!e;n&&(e=A.alloc(v.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=[]),Se.encode(r,e,t),t+=Se.encode.bytes,t=Zt(r.questions,Ae,e,t),t=Zt(r.answers,W,e,t),t=Zt(r.authorities,W,e,t),t=Zt(r.additionals,W,e,t),v.encode.bytes=t-i,n&&v.encode.bytes!==e.length?e.slice(0,v.encode.bytes):e};v.encode.bytes=0;v.decode=function(r,e){e||(e=0);let t=e,n=Se.decode(r,e);return e+=Se.decode.bytes,e=Er(n.questions,Ae,r,e),e=Er(n.answers,W,r,e),e=Er(n.authorities,W,r,e),e=Er(n.additionals,W,r,e),v.decode.bytes=e-t,n};v.decode.bytes=0;v.encodingLength=function(r){return Se.encodingLength(r)+Ot(r.questions||[],Ae)+Ot(r.answers||[],W)+Ot(r.authorities||[],W)+Ot(r.additionals||[],W)};v.streamEncode=function(r){let e=v.encode(r),t=A.alloc(2);t.writeUInt16BE(e.byteLength);let n=A.concat([t,e]);return v.streamEncode.bytes=n.byteLength,n};v.streamEncode.bytes=0;v.streamDecode=function(r){let e=r.readUInt16BE(0);if(r.byteLength<e+2)return null;let t=v.decode(r.slice(2));return v.streamDecode.bytes=v.decode.bytes,t};v.streamDecode.bytes=0;function Ot(r,e){let t=0;for(let n=0;n<r.length;n++)t+=e.encodingLength(r[n]);return t}function Zt(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 fo=Te((fl,go)=>{"use strict";var po=Cc;process.nextTick(Tc,42);go.exports=Sc;function Sc(r){var e=n;return t;function t(i){e(i||Uc)}function n(i){var o=[i];e=s,r(a);function s(c){o.push(c)}function a(c){var u=arguments;for(e=Bc(c)?n:g;o.length;)g(o.shift());function g(d){po(Lc,d,u)}}}}function Bc(r){return Object.prototype.toString.call(r)==="[object Error]"}function Uc(){}function Lc(r,e){r.apply(null,e)}function Tc(r){r===42&&(po=process.nextTick)}function Cc(r,e,t){process.nextTick(function(){r(e,t)})}});var wo=Te((ml,yo)=>{var mn=ho(),Pc=ne("dgram"),Oc=fo(),Nc=ne("events"),wn=ne("os"),yn=function(){};yo.exports=function(r){r||(r={});var e=new Nc.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||Pc.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=mn.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 g=Oc(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 g(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=yn),l?!l.host&&!l.address&&(l.address=o.address):l=o,g(h);function h(m){if(a)return p();if(m)return p(m);var f=mn.encode(d);u.send(f,0,f.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)|mn.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=yn),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=yn),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):kc(),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(m){e.emit("warning",m)}}if(l){if(u.setMulticastInterface)try{u.setMulticastInterface(r.interface||Dc())}catch(m){e.emit("warning",m)}e.emit("networkInterface")}},e};function Dc(){for(var r=wn.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(mo(o.family)&&!o.internal)return wn.platform()==="darwin"&&e[t]==="en0"?o.address:"0.0.0.0"}return"127.0.0.1"}function kc(){for(var r=wn.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(mo(s.family)){t.push(s.address);break}}return t}function mo(r){return r===4||r==="IPv4"}});var js=Te(gr=>{(function(){var r,e,t,n,i,o,s,a;a=function(c){var u,g,d,l;return u=(c&255<<24)>>>24,g=(c&255<<16)>>>16,d=(c&65280)>>>8,l=c&255,[u,g,d,l].join(".")},s=function(c){var u,g,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],g=h[1],c=c.substring(g),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,g,d,l,p;for(l=0,u=10,g="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,g="7")),p=d;d<c.length;){if("0"<=c[d]&&c[d]<=g)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,g){var d,l,p,h;if(typeof u!="string")throw new Error("Missing `net' parameter");if(g||(h=u.split("/",2),u=h[0],g=h[1]),g||(g=32),typeof g=="string"&&g.indexOf(".")>-1){try{this.maskLong=s(g)}catch(m){throw d=m,new Error("Invalid mask: "+g)}for(l=p=32;p>=0;l=--p)if(this.maskLong===4294967295<<32-l>>>0){this.bitmask=l;break}}else if(g||g===0)this.bitmask=parseInt(g,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(m){throw d=m,new Error("Invalid net address: "+u)}if(!(this.bitmask<=32))throw new Error("Invalid mask for ip4: "+g);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 g,d,l;for(l=s(this.first),d=s(this.last),g=0;l<=d;)u(a(l),l,g),g++,l++},c.prototype.toString=function(){return this.base+"/"+this.bitmask},c}(),gr.ip2long=s,gr.long2ip=a,gr.Netmask=r}).call(gr)});var Od={};ie(Od,{mdns:()=>Pd});var Zi=Symbol.for("@libp2p/peer-discovery");var sn=Symbol.for("@libp2p/peer-id");var Ce=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 Xt=class extends Error{static name="UnsupportedKeyTypeError";constructor(e="Unsupported key type"){super(e),this.name="UnsupportedKeyTypeError"}};var Qi=ne("node:events"),Ji=(r,...e)=>{try{(0,Qi.setMaxListeners)(r,...e)}catch{}};var br=class extends EventTarget{#e=new Map;constructor(){super(),Ji(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 eo=Symbol.for("@libp2p/service-capabilities"),Fd=Symbol.for("@libp2p/service-dependencies");var lc=Pt(wo(),1);var vn={};ie(vn,{base58btc:()=>F,base58flickr:()=>qc});var yl=new Uint8Array(0);function xo(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 we(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 bo(r){return new TextEncoder().encode(r)}function Eo(r){return new TextDecoder().decode(r)}function _c(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),g=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 m=0,f=0,y=0,x=h.length;y!==x&&h[y]===0;)y++,m++;for(var E=(x-y)*g+1>>>0,L=new Uint8Array(E);y!==x;){for(var T=h[y],B=0,U=E-1;(T!==0||B<f)&&U!==-1;U--,B++)T+=256*L[U]>>>0,L[U]=T%a>>>0,T=T/a>>>0;if(T!==0)throw new Error("Non-zero carry");f=B,y++}for(var C=E-f;C!==E&&L[C]===0;)C++;for(var P=c.repeat(m);C<E;++C)P+=r.charAt(L[C]);return P}function l(h){if(typeof h!="string")throw new TypeError("Expected String");if(h.length===0)return new Uint8Array;var m=0;if(h[m]!==" "){for(var f=0,y=0;h[m]===c;)f++,m++;for(var x=(h.length-m)*u+1>>>0,E=new Uint8Array(x);h[m];){var L=t[h.charCodeAt(m)];if(L===255)return;for(var T=0,B=x-1;(L!==0||T<y)&&B!==-1;B--,T++)L+=a*E[B]>>>0,E[B]=L%256>>>0,L=L/256>>>0;if(L!==0)throw new Error("Non-zero carry");y=T,m++}if(h[m]!==" "){for(var U=x-y;U!==x&&E[U]===0;)U++;for(var C=new Uint8Array(f+(x-U)),P=f;U!==x;)C[P++]=E[U++];return C}}}function p(h){var m=l(h);if(m)return m;throw new Error(`Non-${e} character`)}return{encode:d,decodeUnsafe:l,decode:p}}var Rc=_c,Kc=Rc,vo=Kc;var xn=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")}},bn=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 Ao(this,e)}},En=class{decoders;constructor(e){this.decoders=e}or(e){return Ao(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 Ao(r,e){return new En({...r.decoders??{[r.prefix]:r},...e.decoders??{[e.prefix]:e}})}var In=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 xn(e,t,n),this.decoder=new bn(e,t,i)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};function Nt({name:r,prefix:e,encode:t,decode:n}){return new In(r,e,t,n)}function it({name:r,prefix:e,alphabet:t}){let{encode:n,decode:i}=vo(t,r);return Nt({prefix:e,name:r,encode:n,decode:o=>we(i(o))})}function Mc(r,e,t,n){let i={};for(let g=0;g<e.length;++g)i[e[g]]=g;let o=r.length;for(;r[o-1]==="=";)--o;let s=new Uint8Array(o*t/8|0),a=0,c=0,u=0;for(let g=0;g<o;++g){let d=i[r[g]];if(d===void 0)throw new SyntaxError(`Non-${n} character`);c=c<<t|d,a+=t,a>=8&&(a-=8,s[u++]=255&c>>a)}if(a>=t||(255&c<<8-a)!==0)throw new SyntaxError("Unexpected end of data");return s}function Fc(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 q({name:r,prefix:e,bitsPerChar:t,alphabet:n}){return Nt({prefix:e,name:r,encode(i){return Fc(i,n,t)},decode(i){return Mc(i,n,t,r)}})}var F=it({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),qc=it({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var An={};ie(An,{base32:()=>We,base32hex:()=>jc,base32hexpad:()=>Gc,base32hexpadupper:()=>Yc,base32hexupper:()=>$c,base32pad:()=>zc,base32padupper:()=>Hc,base32upper:()=>Vc,base32z:()=>Wc});var We=q({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Vc=q({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),zc=q({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Hc=q({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),jc=q({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),$c=q({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Gc=q({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Yc=q({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Wc=q({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Sn={};ie(Sn,{base36:()=>Qt,base36upper:()=>Xc});var Qt=it({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Xc=it({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Zc=Uo,So=128,Qc=127,Jc=~Qc,ea=Math.pow(2,31);function Uo(r,e,t){e=e||[],t=t||0;for(var n=t;r>=ea;)e[t++]=r&255|So,r/=128;for(;r&Jc;)e[t++]=r&255|So,r>>>=7;return e[t]=r|0,Uo.bytes=t-n+1,e}var ta=Bn,ra=128,Bo=127;function Bn(r,n){var t=0,n=n||0,i=0,o=n,s,a=r.length;do{if(o>=a)throw Bn.bytes=0,new RangeError("Could not decode varint");s=r[o++],t+=i<28?(s&Bo)<<i:(s&Bo)*Math.pow(2,i),i+=7}while(s>=ra);return Bn.bytes=o-n,t}var na=Math.pow(2,7),ia=Math.pow(2,14),oa=Math.pow(2,21),sa=Math.pow(2,28),ca=Math.pow(2,35),aa=Math.pow(2,42),ua=Math.pow(2,49),da=Math.pow(2,56),la=Math.pow(2,63),ha=function(r){return r<na?1:r<ia?2:r<oa?3:r<sa?4:r<ca?5:r<aa?6:r<ua?7:r<da?8:r<la?9:10},pa={encode:Zc,decode:ta,encodingLength:ha},ga=pa,Jt=ga;function er(r,e=0){return[Jt.decode(r,e),Jt.decode.bytes]}function Dt(r,e,t=0){return Jt.encode(r,e,t),e}function kt(r){return Jt.encodingLength(r)}function ft(r,e){let t=e.byteLength,n=kt(r),i=n+kt(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 mt(r){let e=we(r),[t,n]=er(e),[i,o]=er(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 Lo(r,e){if(r===e)return!0;{let t=e;return r.code===t.code&&r.size===t.size&&t.bytes instanceof Uint8Array&&xo(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 ma(t,Un(r),e??F.encoder);default:return ya(t,Un(r),e??We.encoder)}}var Co=new WeakMap;function Un(r){let e=Co.get(r);if(e==null){let t=new Map;return Co.set(r,t),t}return e}var H=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!==tr)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==wa)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=ft(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&&Lo(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??Po(n,i,o.bytes))}else if(t[xa]===!0){let{version:n,multihash:i,code:o}=t,s=mt(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!==tr)throw new Error(`Version 0 CID must use dag-pb (code: ${tr}) block encoding`);return new r(e,t,n,n.bytes)}case 1:{let i=Po(e,t,n.bytes);return new r(e,t,n,i)}default:throw new Error("Invalid version")}}static createV0(e){return r.create(0,tr,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=we(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]=er(e.subarray(t));return t+=l,d},i=n(),o=tr;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,g=u-s;return{version:i,codec:o,multihashCode:a,digestSize:c,multihashSize:g,size:u}}static parse(e,t){let[n,i]=fa(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 Un(o).set(n,e),o}};function fa(r,e){switch(r[0]){case"Q":{let t=e??F;return[F.prefix,t.decode(`${F.prefix}${r}`)]}case F.prefix:{let t=e??F;return[F.prefix,t.decode(r)]}case We.prefix:{let t=e??We;return[We.prefix,t.decode(r)]}case Qt.prefix:{let t=e??Qt;return[Qt.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 ma(r,e,t){let{prefix:n}=t;if(n!==F.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 ya(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 tr=112,wa=18;function Po(r,e,t){let n=kt(r),i=n+kt(e),o=new Uint8Array(i+t.byteLength);return Dt(r,o,0),Dt(e,o,n),o.set(t,i),o}var xa=Symbol.for("@ipld/js-cid/CID");var Ln={};ie(Ln,{identity:()=>Be});var Oo=0,ba="identity",No=we;function Ea(r){return ft(Oo,No(r))}var Be={code:Oo,name:ba,encode:No,digest:Ea};function le(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 Tn=ne("node:buffer");function wt(r){return new Uint8Array(r.buffer,r.byteOffset,r.byteLength)}function Xe(r=0){return wt(Tn.Buffer.alloc(r))}function xe(r=0){return wt(Tn.Buffer.allocUnsafe(r))}var Do=ne("node:buffer");function he(r,e){return wt(Do.Buffer.concat(r,e))}var _o=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 Ar(r){return!!r?.[_o]}var pe=class r{bufs;length;[_o]=!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(Ar(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(Ar(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(Ar(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 he(n,i)}subarray(e,t){let{bufs:n,length:i}=this._subList(e,t);return n.length===1?n[0]:he(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,g=t>a&&t<=c;if(u&&g){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(g){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(!Ar(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,g;for(let d=t;d<=c;d+=g){g=0;for(let l=u;l>=0;l--){let p=this.get(d+l);if(n[l]!==p){g=Math.max(1,l-a[p]);break}}if(g===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=xe(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setInt8(0,t),this.write(n,e)}getInt16(e,t){let n=this.subarray(e,e+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt16(0,t)}setInt16(e,t,n){let i=Xe(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=Xe(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=Xe(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=xe(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setUint8(0,t),this.write(n,e)}getUint16(e,t){let n=this.subarray(e,e+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint16(0,t)}setUint16(e,t,n){let i=Xe(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=Xe(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=Xe(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=Xe(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=Xe(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(!le(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=ne("node:buffer");var Cn={};ie(Cn,{base10:()=>Ia});var Ia=it({prefix:"9",name:"base10",alphabet:"0123456789"});var Pn={};ie(Pn,{base16:()=>va,base16upper:()=>Aa});var va=q({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Aa=q({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var On={};ie(On,{base2:()=>Sa});var Sa=q({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Nn={};ie(Nn,{base256emoji:()=>Ca});var Ro=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}"),Ba=Ro.reduce((r,e,t)=>(r[t]=e,r),[]),Ua=Ro.reduce((r,e,t)=>{let n=e.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${e}`);return r[n]=t,r},[]);function La(r){return r.reduce((e,t)=>(e+=Ba[t],e),"")}function Ta(r){let e=[];for(let t of r){let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);let i=Ua[n];if(i==null)throw new Error(`Non-base256emoji character: ${t}`);e.push(i)}return new Uint8Array(e)}var Ca=Nt({prefix:"\u{1F680}",name:"base256emoji",encode:La,decode:Ta});var Dn={};ie(Dn,{base64:()=>Pa,base64pad:()=>Oa,base64url:()=>Na,base64urlpad:()=>Da});var Pa=q({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Oa=q({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Na=q({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Da=q({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var kn={};ie(kn,{base8:()=>ka});var ka=q({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var _n={};ie(_n,{identity:()=>_a});var _a=Nt({prefix:"\0",name:"identity",encode:r=>Eo(r),decode:r=>bo(r)});var Jl=new TextEncoder,eh=new TextDecoder;var qn={};ie(qn,{sha256:()=>Fn,sha512:()=>Ma});var Mn=Pt(ne("crypto"),1);function Kn({name:r,code:e,encode:t}){return new Rn(r,e,t)}var Rn=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?ft(this.code,t):t.then(n=>ft(this.code,n))}else throw Error("Unknown type, must be binary type")}};var Fn=Kn({name:"sha2-256",code:18,encode:r=>we(Mn.default.createHash("sha256").update(r).digest())}),Ma=Kn({name:"sha2-512",code:19,encode:r=>we(Mn.default.createHash("sha512").update(r).digest())});var rr={..._n,...On,...kn,...Cn,...Pn,...An,...Sn,...vn,...Dn,...Nn},ph={...qn,...Ln};function Fo(r,e,t,n){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:n}}}var Mo=Fo("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),Vn=Fo("ascii","a",r=>{let e="a";for(let t=0;t<r.length;t++)e+=String.fromCharCode(r[t]);return e},r=>{r=r.substring(1);let e=xe(r.length);for(let t=0;t<r.length;t++)e[t]=r.charCodeAt(t);return e}),Fa={utf8:Mo,"utf-8":Mo,hex:rr.base16,latin1:Vn,ascii:Vn,binary:Vn,...rr},Sr=Fa;function be(r,e="utf8"){let t=Sr[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return e==="utf8"||e==="utf-8"?wt(qo.Buffer.from(r,"utf-8")):t.decoder.decode(`${t.prefix}${r}`)}var Vo=ne("node:buffer");function _(r,e="utf8"){let t=Sr[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 qa=parseInt("11111",2),zn=parseInt("10000000",2),Va=parseInt("01111111",2),zo={0:nr,1:nr,2:za,3:$a,4:Ga,5:ja,6:Ha,16:nr,22:nr,48:nr};function Hn(r,e={offset:0}){let t=r[e.offset]&qa;if(e.offset++,zo[t]!=null)return zo[t](r,e);throw new Error("No decoder for tag "+t)}function ir(r,e){let t=0;if((r[e.offset]&zn)===zn){let n=r[e.offset]&Va,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 nr(r,e){ir(r,e);let t=[];for(;!(e.offset>=r.byteLength);){let n=Hn(r,e);if(n===null)break;t.push(n)}return t}function za(r,e){let t=ir(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 Ha(r,e){let t=ir(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 g=0;for(let d=0;d<c.length;d++)g+=c[d]<<d*7;a+=`.${g}`,c=[]}}return a}function ja(r,e){return e.offset++,null}function $a(r,e){let t=ir(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 Ga(r,e){let t=ir(r,e),n=r.subarray(e.offset,e.offset+t);return e.offset+=t,n}function Ya(r){let e=r.toString(16);e.length%2===1&&(e="0"+e);let t=new pe;for(let n=0;n<e.length;n+=2)t.append(Uint8Array.from([parseInt(`${e[n]}${e[n+1]}`,16)]));return t}function jn(r){if(r.byteLength<128)return Uint8Array.from([r.byteLength]);let e=Ya(r.byteLength);return new pe(Uint8Array.from([e.byteLength|zn]),e)}function Ho(r){let e=new pe,t=128;return(r.subarray()[0]&t)===t&&e.append(Uint8Array.from([0])),e.append(r),new pe(Uint8Array.from([2]),jn(e),e)}function jo(r){let e=Uint8Array.from([0]),t=new pe(e,r);return new pe(Uint8Array.from([3]),jn(t),t)}function Br(r,e=48){let t=new pe;for(let n of r)t.append(n);return new pe(Uint8Array.from([e]),jn(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 Wa=Uint8Array.from([6,8,42,134,72,206,61,3,1,7]),Xa=Uint8Array.from([6,5,43,129,4,0,34]),Za=Uint8Array.from([6,5,43,129,4,0,35]),Qa={ext:!0,kty:"EC",crv:"P-256"},Ja={ext:!0,kty:"EC",crv:"P-384"},eu={ext:!0,kty:"EC",crv:"P-521"},$n=32,Gn=48,Yn=66;function Go(r){let e=Hn(r);return Yo(e)}function Yo(r){let e=r[1][1][0],t=1,n,i;if(e.byteLength===$n*2+1)return n=_(e.subarray(t,t+$n),"base64url"),i=_(e.subarray(t+$n),"base64url"),new Rt({...Qa,key_ops:["verify"],x:n,y:i});if(e.byteLength===Gn*2+1)return n=_(e.subarray(t,t+Gn),"base64url"),i=_(e.subarray(t+Gn),"base64url"),new Rt({...Ja,key_ops:["verify"],x:n,y:i});if(e.byteLength===Yn*2+1)return n=_(e.subarray(t,t+Yn),"base64url"),i=_(e.subarray(t+Yn),"base64url"),new Rt({...eu,key_ops:["verify"],x:n,y:i});throw new Ce(`coordinates were wrong length, got ${e.byteLength}, expected 65, 97 or 133`)}function Wo(r){return Br([Ho(Uint8Array.from([1])),Br([tu(r.crv)],160),Br([jo(new pe(Uint8Array.from([4]),be(r.x??"","base64url"),be(r.y??"","base64url")))],161)]).subarray()}function tu(r){if(r==="P-256")return Wa;if(r==="P-384")return Xa;if(r==="P-521")return Za;throw new Ce(`Invalid curve ${r}`)}var Rt=class{type="ECDSA";jwk;_raw;constructor(e){this.jwk=e}get raw(){return this._raw==null&&(this._raw=Wo(this.jwk)),this._raw}toMultihash(){return Be.digest(Kt(this))}toCID(){return H.createV1(114,this.toMultihash())}toString(){return F.encode(this.toMultihash().bytes).substring(1)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:le(this.raw,e.raw)}async verify(e,t){return $o(this.jwk,t,e)}};var Ur=Pt(ne("crypto"),1);var Yh=Ur.default.generateKeyPairSync,or=32;var ru=64;function Xo(r,e,t){if(r.byteLength!==or)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!==ru)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:_(r,"base64url"),kty:"OKP"}});return Ur.default.verify(null,t instanceof Uint8Array?t:t.subarray(),n,e)}var Lr=class{type="Ed25519";raw;constructor(e){this.raw=Wn(e,or)}toMultihash(){return Be.digest(Kt(this))}toCID(){return H.createV1(114,this.toMultihash())}toString(){return F.encode(this.toMultihash().bytes).substring(1)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:le(this.raw,e.raw)}verify(e,t){return Xo(this.raw,t,e)}};function Qo(r){return r=Wn(r,or),new Lr(r)}function Wn(r,e){if(r=Uint8Array.from(r??[]),r.length!==e)throw new Ce(`Key must be a Uint8Array of length ${e}, got ${r.length}`);return r}var iu=Math.pow(2,7),ou=Math.pow(2,14),su=Math.pow(2,21),Xn=Math.pow(2,28),Zn=Math.pow(2,35),Qn=Math.pow(2,42),Jn=Math.pow(2,49),k=128,X=127;function se(r){if(r<iu)return 1;if(r<ou)return 2;if(r<su)return 3;if(r<Xn)return 4;if(r<Zn)return 5;if(r<Qn)return 6;if(r<Jn)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function ei(r,e,t=0){switch(se(r)){case 8:e[t++]=r&255|k,r/=128;case 7:e[t++]=r&255|k,r/=128;case 6:e[t++]=r&255|k,r/=128;case 5:e[t++]=r&255|k,r/=128;case 4:e[t++]=r&255|k,r>>>=7;case 3:e[t++]=r&255|k,r>>>=7;case 2:e[t++]=r&255|k,r>>>=7;case 1:{e[t++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return e}function cu(r,e,t=0){switch(se(r)){case 8:e.set(t++,r&255|k),r/=128;case 7:e.set(t++,r&255|k),r/=128;case 6:e.set(t++,r&255|k),r/=128;case 5:e.set(t++,r&255|k),r/=128;case 4:e.set(t++,r&255|k),r>>>=7;case 3:e.set(t++,r&255|k),r>>>=7;case 2:e.set(t++,r&255|k),r>>>=7;case 1:{e.set(t++,r&255),r>>>=7;break}default:throw new Error("unreachable")}return e}function ti(r,e){let t=r[e],n=0;if(n+=t&X,t<k||(t=r[e+1],n+=(t&X)<<7,t<k)||(t=r[e+2],n+=(t&X)<<14,t<k)||(t=r[e+3],n+=(t&X)<<21,t<k)||(t=r[e+4],n+=(t&X)*Xn,t<k)||(t=r[e+5],n+=(t&X)*Zn,t<k)||(t=r[e+6],n+=(t&X)*Qn,t<k)||(t=r[e+7],n+=(t&X)*Jn,t<k))return n;throw new RangeError("Could not decode varint")}function au(r,e){let t=r.get(e),n=0;if(n+=t&X,t<k||(t=r.get(e+1),n+=(t&X)<<7,t<k)||(t=r.get(e+2),n+=(t&X)<<14,t<k)||(t=r.get(e+3),n+=(t&X)<<21,t<k)||(t=r.get(e+4),n+=(t&X)*Xn,t<k)||(t=r.get(e+5),n+=(t&X)*Zn,t<k)||(t=r.get(e+6),n+=(t&X)*Qn,t<k)||(t=r.get(e+7),n+=(t&X)*Jn,t<k))return n;throw new RangeError("Could not decode varint")}function Mt(r,e,t=0){return e==null&&(e=xe(se(r))),e instanceof Uint8Array?ei(r,e,t):cu(r,e,t)}function xt(r,e=0){return r instanceof Uint8Array?ti(r,e):au(r,e)}var ri=new Float32Array([-0]),ot=new Uint8Array(ri.buffer);function es(r,e,t){ri[0]=r,e[t]=ot[0],e[t+1]=ot[1],e[t+2]=ot[2],e[t+3]=ot[3]}function ts(r,e){return ot[0]=r[e],ot[1]=r[e+1],ot[2]=r[e+2],ot[3]=r[e+3],ri[0]}var ni=new Float64Array([-0]),Z=new Uint8Array(ni.buffer);function rs(r,e,t){ni[0]=r,e[t]=Z[0],e[t+1]=Z[1],e[t+2]=Z[2],e[t+3]=Z[3],e[t+4]=Z[4],e[t+5]=Z[5],e[t+6]=Z[6],e[t+7]=Z[7]}function ns(r,e){return Z[0]=r[e],Z[1]=r[e+1],Z[2]=r[e+2],Z[3]=r[e+3],Z[4]=r[e+4],Z[5]=r[e+5],Z[6]=r[e+6],Z[7]=r[e+7],ni[0]}var uu=BigInt(Number.MAX_SAFE_INTEGER),du=BigInt(Number.MIN_SAFE_INTEGER),ge=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 bt;if(e<uu&&e>du)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>is&&(i=0n,++n>is&&(n=0n))),new r(Number(i),Number(n))}static fromNumber(e){if(e===0)return bt;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):bt}},bt=new ge(0,0);bt.toBigInt=function(){return 0n};bt.zzEncode=bt.zzDecode=function(){return this};bt.length=function(){return 1};var is=4294967296n;function os(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 ss(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 ii(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 Ue(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 oi=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,Ue(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 Ue(this,4);return Tr(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw Ue(this,4);return Tr(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw Ue(this,4);let e=ts(this.buf,this.pos);return this.pos+=4,e}double(){if(this.pos+8>this.len)throw Ue(this,4);let e=ns(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 Ue(this,e);return this.pos+=e,t===n?new Uint8Array(0):this.buf.subarray(t,n)}string(){let e=this.bytes();return ss(e,0,e.length)}skip(e){if(typeof e=="number"){if(this.pos+e>this.len)throw Ue(this,e);this.pos+=e}else do if(this.pos>=this.len)throw Ue(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 ge(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 Ue(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 Ue(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 Ue(this,8);let e=Tr(this.buf,this.pos+=4),t=Tr(this.buf,this.pos+=4);return new ge(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=ti(this.buf,this.pos);return this.pos+=se(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 si(r){return new oi(r instanceof Uint8Array?r:r.subarray())}function Cr(r,e,t){let n=si(r);return e.decode(n,void 0,t)}function ci(r){let e=r??8192,t=e>>>1,n,i=e;return function(s){if(s<1||s>t)return xe(s);i+s>e&&(n=xe(e),i=0);let a=n.subarray(i,i+=s);return(i&7)!==0&&(i=(i|7)+1),a}}var Et=class{fn;len;next;val;constructor(e,t,n){this.fn=e,this.len=t,this.next=void 0,this.val=n}};function ai(){}var di=class{head;tail;len;next;constructor(e){this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}},lu=ci();function hu(r){return globalThis.Buffer!=null?xe(r):lu(r)}var cr=class{len;head;tail;states;constructor(){this.len=0,this.head=new Et(ai,0,0),this.tail=this.head,this.states=null}_push(e,t,n){return this.tail=this.tail.next=new Et(e,t,n),this.len+=t,this}uint32(e){return this.len+=(this.tail=this.tail.next=new li((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,ge.fromNumber(e)):this.uint32(e)}sint32(e){return this.uint32((e<<1^e>>31)>>>0)}uint64(e){let t=ge.fromBigInt(e);return this._push(Pr,t.length(),t)}uint64Number(e){return this._push(ei,se(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=ge.fromBigInt(e).zzEncode();return this._push(Pr,t.length(),t)}sint64Number(e){let t=ge.fromNumber(e).zzEncode();return this._push(Pr,t.length(),t)}sint64String(e){return this.sint64(BigInt(e))}bool(e){return this._push(ui,1,e?1:0)}fixed32(e){return this._push(sr,4,e>>>0)}sfixed32(e){return this.fixed32(e)}fixed64(e){let t=ge.fromBigInt(e);return this._push(sr,4,t.lo)._push(sr,4,t.hi)}fixed64Number(e){let t=ge.fromNumber(e);return this._push(sr,4,t.lo)._push(sr,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(es,4,e)}double(e){return this._push(rs,8,e)}bytes(e){let t=e.length>>>0;return t===0?this._push(ui,1,0):this.uint32(t)._push(gu,t,e)}string(e){let t=os(e);return t!==0?this.uint32(t)._push(ii,t,e):this._push(ui,1,0)}fork(){return this.states=new di(this),this.head=this.tail=new Et(ai,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 Et(ai,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=hu(this.len),n=0;for(;e!=null;)e.fn(e.val,t,n),n+=e.len,e=e.next;return t}};function ui(r,e,t){e[t]=r&255}function pu(r,e,t){for(;r>127;)e[t++]=r&127|128,r>>>=7;e[t]=r}var li=class extends Et{next;constructor(e,t){super(pu,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 sr(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 gu(r,e,t){e.set(r,t)}globalThis.Buffer!=null&&(cr.prototype.bytes=function(r){let e=r.length>>>0;return this.uint32(e),e>0&&this._push(fu,e,r),this},cr.prototype.string=function(r){let e=globalThis.Buffer.byteLength(r);return this.uint32(e),e>0&&this._push(mu,e,r),this});function fu(r,e,t){e.set(r,t)}function mu(r,e,t){r.length<40?ii(r,e,t):e.utf8Write!=null?e.utf8Write(r,t):e.set(be(r),t)}function hi(){return new cr}function Or(r,e){let t=hi();return e.encode(r,t,{lengthDelimited:!1}),t.finish()}var Ft;(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"})(Ft||(Ft={}));function Nr(r,e,t,n){return{name:r,type:e,encode:t,decode:n}}function pi(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",Ft.VARINT,t,n)}function Dr(r,e){return Nr("message",Ft.LENGTH_DELIMITED,r,e)}var fe;(function(r){r.RSA="RSA",r.Ed25519="Ed25519",r.secp256k1="secp256k1",r.ECDSA="ECDSA"})(fe||(fe={}));var gi;(function(r){r[r.RSA=0]="RSA",r[r.Ed25519=1]="Ed25519",r[r.secp256k1=2]="secp256k1",r[r.ECDSA=3]="ECDSA"})(gi||(gi={}));(function(r){r.codec=()=>pi(gi)})(fe||(fe={}));var ar;(function(r){let e;r.codec=()=>(e==null&&(e=Dr((t,n,i={})=>{i.lengthDelimited!==!1&&n.fork(),t.Type!=null&&(n.uint32(8),fe.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=fe.codec().decode(t);break}case 2:{o.Data=t.bytes();break}default:{t.skipType(a&7);break}}}return o})),e),r.encode=t=>Or(t,r.codec()),r.decode=(t,n)=>Cr(t,r.codec(),n)})(ar||(ar={}));var fi;(function(r){let e;r.codec=()=>(e==null&&(e=Dr((t,n,i={})=>{i.lengthDelimited!==!1&&n.fork(),t.Type!=null&&(n.uint32(8),fe.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=fe.codec().decode(t);break}case 2:{o.Data=t.bytes();break}default:{t.skipType(a&7);break}}}return o})),e),r.encode=t=>Or(t,r.codec()),r.decode=(t,n)=>Cr(t,r.codec(),n)})(fi||(fi={}));var Ze=Pt(ne("node:crypto"),1),It=Ze&&typeof Ze=="object"&&"webcrypto"in Ze?Ze.webcrypto:Ze&&typeof Ze=="object"&&"randomBytes"in Ze?Ze:void 0;function as(r){if(!Number.isSafeInteger(r)||r<0)throw new Error("positive integer expected, got "+r)}function wu(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function qt(r,...e){if(!wu(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.wrapConstructor");as(r.outputLen),as(r.blockLen)}function Vt(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){qt(r);let t=e.outputLen;if(r.length<t)throw new Error("digestInto() expects output buffer of length at least "+t)}function kr(r){return new DataView(r.buffer,r.byteOffset,r.byteLength)}function Le(r,e){return r<<32-e|r>>>e}function xu(r){if(typeof r!="string")throw new Error("utf8ToBytes expected string, got "+typeof r);return new Uint8Array(new TextEncoder().encode(r))}function ur(r){return typeof r=="string"&&(r=xu(r)),qt(r),r}function ls(...r){let e=0;for(let n=0;n<r.length;n++){let i=r[n];qt(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 zt=class{clone(){return this._cloneInto()}};function hs(r){let e=n=>r().update(ur(n)).digest(),t=r();return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=()=>r(),e}function ps(r=32){if(It&&typeof It.getRandomValues=="function")return It.getRandomValues(new Uint8Array(r));if(It&&typeof It.randomBytes=="function")return It.randomBytes(r);throw new Error("crypto.getRandomValues must be defined")}function bu(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 gs(r,e,t){return r&e^~r&t}function fs(r,e,t){return r&e^r&t^e&t}var _r=class extends zt{constructor(e,t,n,i){super(),this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=i,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=kr(this.buffer)}update(e){Vt(this);let{view:t,buffer:n,blockLen:i}=this;e=ur(e);let o=e.length;for(let s=0;s<o;){let a=Math.min(i-this.pos,o-s);if(a===i){let c=kr(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){Vt(this),ds(e,this),this.finished=!0;let{buffer:t,view:n,blockLen:i,isLE:o}=this,{pos:s}=this;t[s++]=128,this.buffer.subarray(s).fill(0),this.padOffset>i-s&&(this.process(n,0),s=0);for(let d=s;d<i;d++)t[d]=0;bu(n,i-8,BigInt(this.length*8),o),this.process(n,0);let a=kr(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let u=c/4,g=this.get();if(u>g.length)throw new Error("_sha2: outputLen bigger than state");for(let d=0;d<u;d++)a.setUint32(4*d,g[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.length=i,e.pos=a,e.finished=o,e.destroyed=s,i%t&&e.buffer.set(n),e}};var Eu=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),st=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),ct=new Uint32Array(64),mi=class extends _r{constructor(){super(64,32,8,!1),this.A=st[0]|0,this.B=st[1]|0,this.C=st[2]|0,this.D=st[3]|0,this.E=st[4]|0,this.F=st[5]|0,this.G=st[6]|0,this.H=st[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)ct[d]=e.getUint32(t,!1);for(let d=16;d<64;d++){let l=ct[d-15],p=ct[d-2],h=Le(l,7)^Le(l,18)^l>>>3,m=Le(p,17)^Le(p,19)^p>>>10;ct[d]=m+ct[d-7]+h+ct[d-16]|0}let{A:n,B:i,C:o,D:s,E:a,F:c,G:u,H:g}=this;for(let d=0;d<64;d++){let l=Le(a,6)^Le(a,11)^Le(a,25),p=g+l+gs(a,c,u)+Eu[d]+ct[d]|0,m=(Le(n,2)^Le(n,13)^Le(n,22))+fs(n,i,o)|0;g=u,u=c,c=a,a=s+p|0,s=o,o=i,i=n,n=p+m|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,g=g+this.H|0,this.set(n,i,o,s,a,c,u,g)}roundClean(){ct.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var ms=hs(()=>new mi);var ks=Pt(ne("node:crypto"),1);var Rr=class extends zt{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,us(e);let n=ur(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),o.fill(0)}update(e){return Vt(this),this.iHash.update(e),this}digestInto(e){Vt(this),qt(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}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},yi=(r,e,t)=>new Rr(r,e).update(t).digest();yi.create=(r,e)=>new Rr(r,e);var vi={};ie(vi,{aInRange:()=>dt,abool:()=>vt,abytes:()=>Ht,bitGet:()=>Uu,bitLen:()=>Ei,bitMask:()=>lr,bitSet:()=>Lu,bytesToHex:()=>At,bytesToNumberBE:()=>Je,bytesToNumberLE:()=>Fr,concatBytes:()=>jt,createHmacDrbg:()=>Ii,ensureBytes:()=>me,equalBytes:()=>Su,hexToBytes:()=>Bt,hexToNumber:()=>bi,inRange:()=>dr,isBytes:()=>at,memoized:()=>Vr,notImplemented:()=>Cu,numberToBytesBE:()=>ut,numberToBytesLE:()=>qr,numberToHexUnpadded:()=>St,numberToVarBytesBE:()=>Au,utf8ToBytes:()=>Bu,validateObject:()=>lt});var Kr=BigInt(0),Mr=BigInt(1),Iu=BigInt(2);function at(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function Ht(r){if(!at(r))throw new Error("Uint8Array expected")}function vt(r,e){if(typeof e!="boolean")throw new Error(r+" boolean expected, got "+e)}var vu=Array.from({length:256},(r,e)=>e.toString(16).padStart(2,"0"));function At(r){Ht(r);let e="";for(let t=0;t<r.length;t++)e+=vu[r[t]];return e}function St(r){let e=r.toString(16);return e.length&1?"0"+e:e}function bi(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return r===""?Kr:BigInt("0x"+r)}var Qe={_0:48,_9:57,A:65,F:70,a:97,f:102};function ys(r){if(r>=Qe._0&&r<=Qe._9)return r-Qe._0;if(r>=Qe.A&&r<=Qe.F)return r-(Qe.A-10);if(r>=Qe.a&&r<=Qe.f)return r-(Qe.a-10)}function Bt(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);let e=r.length,t=e/2;if(e%2)throw new Error("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 Je(r){return bi(At(r))}function Fr(r){return Ht(r),bi(At(Uint8Array.from(r).reverse()))}function ut(r,e){return Bt(r.toString(16).padStart(e*2,"0"))}function qr(r,e){return ut(r,e).reverse()}function Au(r){return Bt(St(r))}function me(r,e,t){let n;if(typeof e=="string")try{n=Bt(e)}catch(o){throw new Error(r+" must be hex string or Uint8Array, cause: "+o)}else if(at(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 jt(...r){let e=0;for(let n=0;n<r.length;n++){let i=r[n];Ht(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}function Su(r,e){if(r.length!==e.length)return!1;let t=0;for(let n=0;n<r.length;n++)t|=r[n]^e[n];return t===0}function Bu(r){if(typeof r!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(r))}var wi=r=>typeof r=="bigint"&&Kr<=r;function dr(r,e,t){return wi(r)&&wi(e)&&wi(t)&&e<=r&&r<t}function dt(r,e,t,n){if(!dr(e,t,n))throw new Error("expected valid "+r+": "+t+" <= n < "+n+", got "+e)}function Ei(r){let e;for(e=0;r>Kr;r>>=Mr,e+=1);return e}function Uu(r,e){return r>>BigInt(e)&Mr}function Lu(r,e,t){return r|(t?Mr:Kr)<<BigInt(e)}var lr=r=>(Iu<<BigInt(r-1))-Mr,xi=r=>new Uint8Array(r),ws=r=>Uint8Array.from(r);function Ii(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=xi(r),i=xi(r),o=0,s=()=>{n.fill(1),i.fill(0),o=0},a=(...d)=>t(i,n,...d),c=(d=xi())=>{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 jt(...l)};return(d,l)=>{s(),c(d);let p;for(;!(p=l(u()));)c();return s(),p}}var Tu={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"||at(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 lt(r,e,t={}){let n=(i,o,s)=>{let a=Tu[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}var Cu=()=>{throw new Error("not implemented")};function Vr(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 j=BigInt(0),V=BigInt(1),Ut=BigInt(2),Pu=BigInt(3),Ai=BigInt(4),xs=BigInt(5),bs=BigInt(8),Ou=BigInt(9),Nu=BigInt(16);function Q(r,e){let t=r%e;return t>=j?t:e+t}function Du(r,e,t){if(e<j)throw new Error("invalid exponent, negatives unsupported");if(t<=j)throw new Error("invalid modulus");if(t===V)return j;let n=V;for(;e>j;)e&V&&(n=n*r%t),r=r*r%t,e>>=V;return n}function ye(r,e,t){let n=r;for(;e-- >j;)n*=n,n%=t;return n}function zr(r,e){if(r===j)throw new Error("invert: expected non-zero number");if(e<=j)throw new Error("invert: expected positive modulus, got "+e);let t=Q(r,e),n=e,i=j,o=V,s=V,a=j;for(;t!==j;){let u=n/t,g=n%t,d=i-s*u,l=o-a*u;n=t,t=g,i=s,o=a,s=d,a=l}if(n!==V)throw new Error("invert: does not exist");return Q(i,e)}function ku(r){let e=(r-V)/Ut,t,n,i;for(t=r-V,n=0;t%Ut===j;t/=Ut,n++);for(i=Ut;i<r&&Du(i,e,r)!==r-V;i++)if(i>1e3)throw new Error("Cannot find square root: likely non-prime P");if(n===1){let s=(r+V)/Ai;return function(c,u){let g=c.pow(u,s);if(!c.eql(c.sqr(g),u))throw new Error("Cannot find square root");return g}}let o=(t+V)/Ut;return function(a,c){if(a.pow(c,e)===a.neg(a.ONE))throw new Error("Cannot find square root");let u=n,g=a.pow(a.mul(a.ONE,i),t),d=a.pow(c,o),l=a.pow(c,t);for(;!a.eql(l,a.ONE);){if(a.eql(l,a.ZERO))return a.ZERO;let p=1;for(let m=a.sqr(l);p<u&&!a.eql(m,a.ONE);p++)m=a.sqr(m);let h=a.pow(g,V<<BigInt(u-p-1));g=a.sqr(h),d=a.mul(d,h),l=a.mul(l,g),u=p}return d}}function _u(r){if(r%Ai===Pu){let e=(r+V)/Ai;return function(n,i){let o=n.pow(i,e);if(!n.eql(n.sqr(o),i))throw new Error("Cannot find square root");return o}}if(r%bs===xs){let e=(r-xs)/bs;return function(n,i){let o=n.mul(i,Ut),s=n.pow(o,e),a=n.mul(i,s),c=n.mul(n.mul(a,Ut),s),u=n.mul(a,n.sub(c,n.ONE));if(!n.eql(n.sqr(u),i))throw new Error("Cannot find square root");return u}}return r%Nu,ku(r)}var Ru=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Si(r){let e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},t=Ru.reduce((n,i)=>(n[i]="function",n),e);return lt(r,t)}function Ku(r,e,t){if(t<j)throw new Error("invalid exponent, negatives unsupported");if(t===j)return r.ONE;if(t===V)return e;let n=r.ONE,i=e;for(;t>j;)t&V&&(n=r.mul(n,i)),i=r.sqr(i),t>>=V;return n}function Mu(r,e){let t=new Array(e.length),n=e.reduce((o,s,a)=>r.is0(s)?o:(t[a]=o,r.mul(o,s)),r.ONE),i=r.inv(n);return e.reduceRight((o,s,a)=>r.is0(s)?o:(t[a]=r.mul(o,t[a]),r.mul(o,s)),i),t}function Bi(r,e){let t=e!==void 0?e:r.toString(2).length,n=Math.ceil(t/8);return{nBitLength:t,nByteLength:n}}function Hr(r,e,t=!1,n={}){if(r<=j)throw new Error("invalid field: expected ORDER > 0, got "+r);let{nBitLength:i,nByteLength:o}=Bi(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:lr(i),ZERO:j,ONE:V,create:c=>Q(c,r),isValid:c=>{if(typeof c!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof c);return j<=c&&c<r},is0:c=>c===j,isOdd:c=>(c&V)===V,neg:c=>Q(-c,r),eql:(c,u)=>c===u,sqr:c=>Q(c*c,r),add:(c,u)=>Q(c+u,r),sub:(c,u)=>Q(c-u,r),mul:(c,u)=>Q(c*u,r),pow:(c,u)=>Ku(a,c,u),div:(c,u)=>Q(c*zr(u,r),r),sqrN:c=>c*c,addN:(c,u)=>c+u,subN:(c,u)=>c-u,mulN:(c,u)=>c*u,inv:c=>zr(c,r),sqrt:n.sqrt||(c=>(s||(s=_u(r)),s(a,c))),invertBatch:c=>Mu(a,c),cmov:(c,u,g)=>g?u:c,toBytes:c=>t?qr(c,o):ut(c,o),fromBytes:c=>{if(c.length!==o)throw new Error("Field.fromBytes: expected "+o+" bytes, got "+c.length);return t?Fr(c):Je(c)}});return Object.freeze(a)}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 Ui(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=Ui(e);if(n<16||n<o||n>1024)throw new Error("expected "+o+"-1024 bytes of input, got "+n);let s=t?Fr(r):Je(r),a=Q(s,e-V)+V;return t?qr(a,i):ut(a,i)}var vs=BigInt(0),jr=BigInt(1);function Li(r,e){let t=e.negate();return r?t:e}function As(r,e){if(!Number.isSafeInteger(r)||r<=0||r>e)throw new Error("invalid window size, expected [1.."+e+"], got W="+r)}function Ti(r,e){As(r,e);let t=Math.ceil(e/r)+1,n=2**(r-1);return{windows:t,windowSize:n}}function Fu(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 qu(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 Ci=new WeakMap,Ss=new WeakMap;function Pi(r){return Ss.get(r)||1}function Bs(r,e){return{constTimeNegate:Li,hasPrecomputes(t){return Pi(t)!==1},unsafeLadder(t,n,i=r.ZERO){let o=t;for(;n>vs;)n&jr&&(i=i.add(o)),o=o.double(),n>>=jr;return i},precomputeWindow(t,n){let{windows:i,windowSize:o}=Ti(n,e),s=[],a=t,c=a;for(let u=0;u<i;u++){c=a,s.push(c);for(let g=1;g<o;g++)c=c.add(a),s.push(c);a=c.double()}return s},wNAF(t,n,i){let{windows:o,windowSize:s}=Ti(t,e),a=r.ZERO,c=r.BASE,u=BigInt(2**t-1),g=2**t,d=BigInt(t);for(let l=0;l<o;l++){let p=l*s,h=Number(i&u);i>>=d,h>s&&(h-=g,i+=jr);let m=p,f=p+Math.abs(h)-1,y=l%2!==0,x=h<0;h===0?c=c.add(Li(y,n[m])):a=a.add(Li(x,n[f]))}return{p:a,f:c}},wNAFUnsafe(t,n,i,o=r.ZERO){let{windows:s,windowSize:a}=Ti(t,e),c=BigInt(2**t-1),u=2**t,g=BigInt(t);for(let d=0;d<s;d++){let l=d*a;if(i===vs)break;let p=Number(i&c);if(i>>=g,p>a&&(p-=u,i+=jr),p===0)continue;let h=n[l+Math.abs(p)-1];p<0&&(h=h.negate()),o=o.add(h)}return o},getPrecomputes(t,n,i){let o=Ci.get(n);return o||(o=this.precomputeWindow(n,t),t!==1&&Ci.set(n,i(o))),o},wNAFCached(t,n,i){let o=Pi(t);return this.wNAF(o,this.getPrecomputes(o,t,i),n)},wNAFCachedUnsafe(t,n,i,o){let s=Pi(t);return s===1?this.unsafeLadder(t,n,o):this.wNAFUnsafe(s,this.getPrecomputes(s,t,i),n,o)},setWindowSize(t,n){As(n,e),Ss.set(t,n),Ci.delete(t)}}}function Us(r,e,t,n){if(Fu(t,r),qu(n,e),t.length!==n.length)throw new Error("arrays of points and scalars must have equal length");let i=r.ZERO,o=Ei(BigInt(t.length)),s=o>12?o-3:o>4?o-2:o?2:1,a=(1<<s)-1,c=new Array(a+1).fill(i),u=Math.floor((e.BITS-1)/s)*s,g=i;for(let d=u;d>=0;d-=s){c.fill(i);for(let p=0;p<n.length;p++){let h=n[p],m=Number(h>>BigInt(d)&BigInt(a));c[m]=c[m].add(t[p])}let l=i;for(let p=c.length-1,h=i;p>0;p--)h=h.add(c[p]),l=l.add(h);if(g=g.add(l),d!==0)for(let p=0;p<s;p++)g=g.double()}return g}function Oi(r){return Si(r.Fp),lt(r,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Bi(r.n,r.nBitLength),...r,p:r.Fp.ORDER})}function Ls(r){r.lowS!==void 0&&vt("lowS",r.lowS),r.prehash!==void 0&&vt("prehash",r.prehash)}function Vu(r){let e=Oi(r);lt(e,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});let{endo:t,Fp:n,a:i}=e;if(t){if(!n.eql(i,n.ZERO))throw new Error("invalid endomorphism, can only be defined for Koblitz curves that have a=0");if(typeof t!="object"||typeof t.beta!="bigint"||typeof t.splitScalar!="function")throw new Error("invalid endomorphism, expected beta: bigint and splitScalar: function")}return Object.freeze({...e})}var{bytesToNumberBE:zu,hexToBytes:Hu}=vi,Ni=class extends Error{constructor(e=""){super(e)}},et={Err:Ni,_tlv:{encode:(r,e)=>{let{Err:t}=et;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=St(n);if(i.length/2&128)throw new t("tlv.encode: long form length too big");let o=n>127?St(i.length/2|128):"";return St(r)+o+i+e},decode(r,e){let{Err:t}=et,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 g of u)s=s<<8|g;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}=et;if(r<tt)throw new e("integer: negative integers are not allowed");let t=St(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}=et;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 zu(r)}},toSig(r){let{Err:e,_int:t,_tlv:n}=et,i=typeof r=="string"?Hu(r):r;Ht(i);let{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:g}=n.decode(2,c);if(g.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}=et,n=e.encode(2,t.encode(r.r)),i=e.encode(2,t.encode(r.s)),o=n+i;return e.encode(48,o)}},tt=BigInt(0),G=BigInt(1),l0=BigInt(2),Ts=BigInt(3),h0=BigInt(4);function ju(r){let e=Vu(r),{Fp:t}=e,n=Hr(e.n,e.nBitLength),i=e.toBytes||((m,f,y)=>{let x=f.toAffine();return jt(Uint8Array.from([4]),t.toBytes(x.x),t.toBytes(x.y))}),o=e.fromBytes||(m=>{let f=m.subarray(1),y=t.fromBytes(f.subarray(0,t.BYTES)),x=t.fromBytes(f.subarray(t.BYTES,2*t.BYTES));return{x:y,y:x}});function s(m){let{a:f,b:y}=e,x=t.sqr(m),E=t.mul(x,m);return t.add(t.add(E,t.mul(m,f)),y)}if(!t.eql(t.sqr(e.Gy),s(e.Gx)))throw new Error("bad generator point: equation left != right");function a(m){return dr(m,G,e.n)}function c(m){let{allowedPrivateKeyLengths:f,nByteLength:y,wrapPrivateKey:x,n:E}=e;if(f&&typeof m!="bigint"){if(at(m)&&(m=At(m)),typeof m!="string"||!f.includes(m.length))throw new Error("invalid private key");m=m.padStart(y*2,"0")}let L;try{L=typeof m=="bigint"?m:Je(me("private key",m,y))}catch{throw new Error("invalid private key, expected hex or "+y+" bytes, got "+typeof m)}return x&&(L=Q(L,E)),dt("private key",L,G,E),L}function u(m){if(!(m instanceof l))throw new Error("ProjectivePoint expected")}let g=Vr((m,f)=>{let{px:y,py:x,pz:E}=m;if(t.eql(E,t.ONE))return{x:y,y:x};let L=m.is0();f==null&&(f=L?t.ONE:t.inv(E));let T=t.mul(y,f),B=t.mul(x,f),U=t.mul(E,f);if(L)return{x:t.ZERO,y:t.ZERO};if(!t.eql(U,t.ONE))throw new Error("invZ was invalid");return{x:T,y:B}}),d=Vr(m=>{if(m.is0()){if(e.allowInfinityPoint&&!t.is0(m.py))return;throw new Error("bad point: ZERO")}let{x:f,y}=m.toAffine();if(!t.isValid(f)||!t.isValid(y))throw new Error("bad point: x or y not FE");let x=t.sqr(y),E=s(f);if(!t.eql(x,E))throw new Error("bad point: equation left != right");if(!m.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class l{constructor(f,y,x){if(this.px=f,this.py=y,this.pz=x,f==null||!t.isValid(f))throw new Error("x required");if(y==null||!t.isValid(y))throw new Error("y required");if(x==null||!t.isValid(x))throw new Error("z required");Object.freeze(this)}static fromAffine(f){let{x:y,y:x}=f||{};if(!f||!t.isValid(y)||!t.isValid(x))throw new Error("invalid affine point");if(f instanceof l)throw new Error("projective point not allowed");let E=L=>t.eql(L,t.ZERO);return E(y)&&E(x)?l.ZERO:new l(y,x,t.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(f){let y=t.invertBatch(f.map(x=>x.pz));return f.map((x,E)=>x.toAffine(y[E])).map(l.fromAffine)}static fromHex(f){let y=l.fromAffine(o(me("pointHex",f)));return y.assertValidity(),y}static fromPrivateKey(f){return l.BASE.multiply(c(f))}static msm(f,y){return Us(l,n,f,y)}_setWindowSize(f){h.setWindowSize(this,f)}assertValidity(){d(this)}hasEvenY(){let{y:f}=this.toAffine();if(t.isOdd)return!t.isOdd(f);throw new Error("Field doesn't support isOdd")}equals(f){u(f);let{px:y,py:x,pz:E}=this,{px:L,py:T,pz:B}=f,U=t.eql(t.mul(y,B),t.mul(L,E)),C=t.eql(t.mul(x,B),t.mul(T,E));return U&&C}negate(){return new l(this.px,t.neg(this.py),this.pz)}double(){let{a:f,b:y}=e,x=t.mul(y,Ts),{px:E,py:L,pz:T}=this,B=t.ZERO,U=t.ZERO,C=t.ZERO,P=t.mul(E,E),Y=t.mul(L,L),M=t.mul(T,T),K=t.mul(E,L);return K=t.add(K,K),C=t.mul(E,T),C=t.add(C,C),B=t.mul(f,C),U=t.mul(x,M),U=t.add(B,U),B=t.sub(Y,U),U=t.add(Y,U),U=t.mul(B,U),B=t.mul(K,B),C=t.mul(x,C),M=t.mul(f,M),K=t.sub(P,M),K=t.mul(f,K),K=t.add(K,C),C=t.add(P,P),P=t.add(C,P),P=t.add(P,M),P=t.mul(P,K),U=t.add(U,P),M=t.mul(L,T),M=t.add(M,M),P=t.mul(M,K),B=t.sub(B,P),C=t.mul(M,Y),C=t.add(C,C),C=t.add(C,C),new l(B,U,C)}add(f){u(f);let{px:y,py:x,pz:E}=this,{px:L,py:T,pz:B}=f,U=t.ZERO,C=t.ZERO,P=t.ZERO,Y=e.a,M=t.mul(e.b,Ts),K=t.mul(y,L),ce=t.mul(x,T),b=t.mul(E,B),I=t.add(y,x),S=t.add(L,T);I=t.mul(I,S),S=t.add(K,ce),I=t.sub(I,S),S=t.add(y,E);let N=t.add(L,B);return S=t.mul(S,N),N=t.add(K,b),S=t.sub(S,N),N=t.add(x,E),U=t.add(T,B),N=t.mul(N,U),U=t.add(ce,b),N=t.sub(N,U),P=t.mul(Y,S),U=t.mul(M,b),P=t.add(U,P),U=t.sub(ce,P),P=t.add(ce,P),C=t.mul(U,P),ce=t.add(K,K),ce=t.add(ce,K),b=t.mul(Y,b),S=t.mul(M,S),ce=t.add(ce,b),b=t.sub(K,b),b=t.mul(Y,b),S=t.add(S,b),K=t.mul(ce,S),C=t.add(C,K),K=t.mul(N,S),U=t.mul(I,U),U=t.sub(U,K),K=t.mul(I,ce),P=t.mul(N,P),P=t.add(P,K),new l(U,C,P)}subtract(f){return this.add(f.negate())}is0(){return this.equals(l.ZERO)}wNAF(f){return h.wNAFCached(this,f,l.normalizeZ)}multiplyUnsafe(f){let{endo:y,n:x}=e;dt("scalar",f,tt,x);let E=l.ZERO;if(f===tt)return E;if(this.is0()||f===G)return this;if(!y||h.hasPrecomputes(this))return h.wNAFCachedUnsafe(this,f,l.normalizeZ);let{k1neg:L,k1:T,k2neg:B,k2:U}=y.splitScalar(f),C=E,P=E,Y=this;for(;T>tt||U>tt;)T&G&&(C=C.add(Y)),U&G&&(P=P.add(Y)),Y=Y.double(),T>>=G,U>>=G;return L&&(C=C.negate()),B&&(P=P.negate()),P=new l(t.mul(P.px,y.beta),P.py,P.pz),C.add(P)}multiply(f){let{endo:y,n:x}=e;dt("scalar",f,G,x);let E,L;if(y){let{k1neg:T,k1:B,k2neg:U,k2:C}=y.splitScalar(f),{p:P,f:Y}=this.wNAF(B),{p:M,f:K}=this.wNAF(C);P=h.constTimeNegate(T,P),M=h.constTimeNegate(U,M),M=new l(t.mul(M.px,y.beta),M.py,M.pz),E=P.add(M),L=Y.add(K)}else{let{p:T,f:B}=this.wNAF(f);E=T,L=B}return l.normalizeZ([E,L])[0]}multiplyAndAddUnsafe(f,y,x){let E=l.BASE,L=(B,U)=>U===tt||U===G||!B.equals(E)?B.multiplyUnsafe(U):B.multiply(U),T=L(this,y).add(L(f,x));return T.is0()?void 0:T}toAffine(f){return g(this,f)}isTorsionFree(){let{h:f,isTorsionFree:y}=e;if(f===G)return!0;if(y)return y(l,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h:f,clearCofactor:y}=e;return f===G?this:y?y(l,this):this.multiplyUnsafe(e.h)}toRawBytes(f=!0){return vt("isCompressed",f),this.assertValidity(),i(l,this,f)}toHex(f=!0){return vt("isCompressed",f),At(this.toRawBytes(f))}}l.BASE=new l(e.Gx,e.Gy,t.ONE),l.ZERO=new l(t.ZERO,t.ONE,t.ZERO);let p=e.nBitLength,h=Bs(l,e.endo?Math.ceil(p/2):p);return{CURVE:e,ProjectivePoint:l,normPrivateKeyToScalar:c,weierstrassEquation:s,isWithinCurveOrder:a}}function $u(r){let e=Oi(r);return lt(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function Cs(r){let e=$u(r),{Fp:t,n}=e,i=t.BYTES+1,o=2*t.BYTES+1;function s(b){return Q(b,n)}function a(b){return zr(b,n)}let{ProjectivePoint:c,normPrivateKeyToScalar:u,weierstrassEquation:g,isWithinCurveOrder:d}=ju({...e,toBytes(b,I,S){let N=I.toAffine(),D=t.toBytes(N.x),z=jt;return vt("isCompressed",S),S?z(Uint8Array.from([I.hasEvenY()?2:3]),D):z(Uint8Array.from([4]),D,t.toBytes(N.y))},fromBytes(b){let I=b.length,S=b[0],N=b.subarray(1);if(I===i&&(S===2||S===3)){let D=Je(N);if(!dr(D,G,t.ORDER))throw new Error("Point is not on curve");let z=g(D),te;try{te=t.sqrt(z)}catch(Ie){let re=Ie instanceof Error?": "+Ie.message:"";throw new Error("Point is not on curve"+re)}let J=(te&G)===G;return(S&1)===1!==J&&(te=t.neg(te)),{x:D,y:te}}else if(I===o&&S===4){let D=t.fromBytes(N.subarray(0,t.BYTES)),z=t.fromBytes(N.subarray(t.BYTES,2*t.BYTES));return{x:D,y:z}}else{let D=i,z=o;throw new Error("invalid Point, expected length of "+D+", or uncompressed "+z+", got "+I)}}}),l=b=>At(ut(b,e.nByteLength));function p(b){let I=n>>G;return b>I}function h(b){return p(b)?s(-b):b}let m=(b,I,S)=>Je(b.slice(I,S));class f{constructor(I,S,N){this.r=I,this.s=S,this.recovery=N,this.assertValidity()}static fromCompact(I){let S=e.nByteLength;return I=me("compactSignature",I,S*2),new f(m(I,0,S),m(I,S,2*S))}static fromDER(I){let{r:S,s:N}=et.toSig(me("DER",I));return new f(S,N)}assertValidity(){dt("r",this.r,G,n),dt("s",this.s,G,n)}addRecoveryBit(I){return new f(this.r,this.s,I)}recoverPublicKey(I){let{r:S,s:N,recovery:D}=this,z=B(me("msgHash",I));if(D==null||![0,1,2,3].includes(D))throw new Error("recovery id invalid");let te=D===2||D===3?S+e.n:S;if(te>=t.ORDER)throw new Error("recovery id 2 or 3 invalid");let J=(D&1)===0?"02":"03",Ke=c.fromHex(J+l(te)),Ie=a(te),re=s(-z*Ie),Lt=s(N*Ie),rt=c.BASE.multiplyAndAddUnsafe(Ke,re,Lt);if(!rt)throw new Error("point at infinify");return rt.assertValidity(),rt}hasHighS(){return p(this.s)}normalizeS(){return this.hasHighS()?new f(this.r,s(-this.s),this.recovery):this}toDERRawBytes(){return Bt(this.toDERHex())}toDERHex(){return et.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Bt(this.toCompactHex())}toCompactHex(){return l(this.r)+l(this.s)}}let y={isValidPrivateKey(b){try{return u(b),!0}catch{return!1}},normPrivateKeyToScalar:u,randomPrivateKey:()=>{let b=Ui(e.n);return Is(e.randomBytes(b),e.n)},precompute(b=8,I=c.BASE){return I._setWindowSize(b),I.multiply(BigInt(3)),I}};function x(b,I=!0){return c.fromPrivateKey(b).toRawBytes(I)}function E(b){let I=at(b),S=typeof b=="string",N=(I||S)&&b.length;return I?N===i||N===o:S?N===2*i||N===2*o:b instanceof c}function L(b,I,S=!0){if(E(b))throw new Error("first arg must be private key");if(!E(I))throw new Error("second arg must be public key");return c.fromHex(I).multiply(u(b)).toRawBytes(S)}let T=e.bits2int||function(b){if(b.length>8192)throw new Error("input is too large");let I=Je(b),S=b.length*8-e.nBitLength;return S>0?I>>BigInt(S):I},B=e.bits2int_modN||function(b){return s(T(b))},U=lr(e.nBitLength);function C(b){return dt("num < 2^"+e.nBitLength,b,tt,U),ut(b,e.nByteLength)}function P(b,I,S=Y){if(["recovered","canonical"].some(ht=>ht in S))throw new Error("sign() legacy options not supported");let{hash:N,randomBytes:D}=e,{lowS:z,prehash:te,extraEntropy:J}=S;z==null&&(z=!0),b=me("msgHash",b),Ls(S),te&&(b=me("prehashed msgHash",N(b)));let Ke=B(b),Ie=u(I),re=[C(Ie),C(Ke)];if(J!=null&&J!==!1){let ht=J===!0?D(t.BYTES):J;re.push(me("extraEntropy",ht))}let Lt=jt(...re),rt=Ke;function nn(ht){let Tt=T(ht);if(!d(Tt))return;let on=a(Tt),Yt=c.BASE.multiply(Tt).toAffine(),pt=s(Yt.x);if(pt===tt)return;let Wt=s(on*s(rt+pt*Ie));if(Wt===tt)return;let Ct=(Yt.x===pt?0:2)|Number(Yt.y&G),Wi=Wt;return z&&p(Wt)&&(Wi=h(Wt),Ct^=1),new f(pt,Wi,Ct)}return{seed:Lt,k2sig:nn}}let Y={lowS:e.lowS,prehash:!1},M={lowS:e.lowS,prehash:!1};function K(b,I,S=Y){let{seed:N,k2sig:D}=P(b,I,S),z=e;return Ii(z.hash.outputLen,z.nByteLength,z.hmac)(N,D)}c.BASE._setWindowSize(8);function ce(b,I,S,N=M){let D=b;I=me("msgHash",I),S=me("publicKey",S);let{lowS:z,prehash:te,format:J}=N;if(Ls(N),"strict"in N)throw new Error("options.strict was renamed to lowS");if(J!==void 0&&J!=="compact"&&J!=="der")throw new Error("format must be compact or der");let Ke=typeof D=="string"||at(D),Ie=!Ke&&!J&&typeof D=="object"&&D!==null&&typeof D.r=="bigint"&&typeof D.s=="bigint";if(!Ke&&!Ie)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let re,Lt;try{if(Ie&&(re=new f(D.r,D.s)),Ke){try{J!=="compact"&&(re=f.fromDER(D))}catch(Ct){if(!(Ct instanceof et.Err))throw Ct}!re&&J!=="der"&&(re=f.fromCompact(D))}Lt=c.fromHex(S)}catch{return!1}if(!re||z&&re.hasHighS())return!1;te&&(I=e.hash(I));let{r:rt,s:nn}=re,ht=B(I),Tt=a(nn),on=s(ht*Tt),Yt=s(rt*Tt),pt=c.BASE.multiplyAndAddUnsafe(Lt,on,Yt)?.toAffine();return pt?s(pt.x)===rt:!1}return{CURVE:e,getPublicKey:x,getSharedSecret:L,sign:K,verify:ce,ProjectivePoint:c,Signature:f,utils:y}}function Gu(r){return{hash:r,hmac:(e,...t)=>yi(r,e,ls(...t)),randomBytes:ps}}function Ps(r,e){let t=n=>Cs({...r,...Gu(n)});return{...t(e),create:t}}var Ds=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),Os=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),Yu=BigInt(1),Di=BigInt(2),Ns=(r,e)=>(r+e/Di)/e;function Wu(r){let e=Ds,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,g=u*u*r%e,d=ye(g,t,e)*g%e,l=ye(d,t,e)*g%e,p=ye(l,Di,e)*u%e,h=ye(p,i,e)*p%e,m=ye(h,o,e)*h%e,f=ye(m,a,e)*m%e,y=ye(f,c,e)*f%e,x=ye(y,a,e)*m%e,E=ye(x,t,e)*g%e,L=ye(E,s,e)*h%e,T=ye(L,n,e)*u%e,B=ye(T,Di,e);if(!ki.eql(ki.sqr(B),r))throw new Error("Cannot find square root");return B}var ki=Hr(Ds,void 0,void 0,{sqrt:Wu}),$t=Ps({a:BigInt(0),b:BigInt(7),Fp:ki,n:Os,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:r=>{let e=Os,t=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-Yu*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),i=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),o=t,s=BigInt("0x100000000000000000000000000000000"),a=Ns(o*r,e),c=Ns(-n*r,e),u=Q(r-a*t-c*i,e),g=Q(-a*n-c*o,e),d=u>s,l=g>s;if(d&&(u=e-u),l&&(g=e-g),u>s||g>s)throw new Error("splitScalar: Endomorphism failed, k="+r);return{k1neg:d,k1:u,k2neg:l,k2:g}}}},ms),E0=BigInt(0);var I0=$t.ProjectivePoint;var $r=class extends Error{constructor(e="An error occurred while verifying a message"){super(e),this.name="VerificationError"}};function _s(r,e,t){let n=ks.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 $t.verify(e,i,r)}catch(o){throw new $r(String(o))}}var Gr=class{type="secp256k1";raw;_key;constructor(e){this._key=Ks(e),this.raw=Rs(this._key)}toMultihash(){return Be.digest(Kt(this))}toCID(){return H.createV1(114,this.toMultihash())}toString(){return F.encode(this.toMultihash().bytes).substring(1)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:le(this.raw,e.raw)}verify(e,t){return _s(this._key,t,e)}};function Ms(r){return new Gr(r)}function Rs(r){return $t.ProjectivePoint.fromHex(r).toRawBytes(!0)}function Ks(r){try{return $t.ProjectivePoint.fromHex(r),r}catch(e){throw new yr(String(e))}}function Fs(r){let{Type:e,Data:t}=ar.decode(r.digest),n=t??new Uint8Array;switch(e){case fe.Ed25519:return Qo(n);case fe.secp256k1:return Ms(n);case fe.ECDSA:return Go(n);default:throw new Xt}}function Kt(r){return ar.encode({Type:fe[r.type],Data:r.raw})}var qs=Symbol.for("nodejs.util.inspect.custom"),Xu=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()})`}[sn]=!0;toString(){return this.string==null&&(this.string=F.encode(this.multihash.bytes).slice(1)),this.string}toMultihash(){return this.multihash}toCID(){return H.createV1(Xu,this.multihash)}toJSON(){return this.toString()}equals(e){if(e==null)return!1;if(e instanceof Uint8Array)return le(this.multihash.bytes,e);if(typeof e=="string")return this.toString()===e;if(e?.toMultihash()?.bytes!=null)return le(this.multihash.bytes,e.toMultihash().bytes);throw new Error("not valid Id")}[qs](){return`PeerId(${this.toString()})`}},Yr=class extends hr{type="RSA";publicKey;constructor(e){super({...e,type:"RSA"}),this.publicKey=e.publicKey}},Wr=class extends hr{type="Ed25519";publicKey;constructor(e){super({...e,type:"Ed25519"}),this.publicKey=e.publicKey}},Xr=class extends hr{type="secp256k1";publicKey;constructor(e){super({...e,type:"secp256k1"}),this.publicKey=e.publicKey}},Zu=2336,pr=class{type="url";multihash;publicKey;url;constructor(e){this.url=e.toString(),this.multihash=Be.digest(be(this.url))}[qs](){return`PeerId(${this.url})`}[sn]=!0;toString(){return this.toCID().toString()}toMultihash(){return this.multihash}toCID(){return H.createV1(Zu,this.toMultihash())}toJSON(){return this.toString()}equals(e){return e==null?!1:(e instanceof Uint8Array&&(e=_(e)),e.toString()===this.toString())}};var Qu=114,Vs=2336;function zs(r,e){let t;if(r.charAt(0)==="1"||r.charAt(0)==="Q")t=mt(F.decode(`z${r}`));else{if(r.startsWith("k51qzi5uqu5")||r.startsWith("kzwfwjn5ji4")||r.startsWith("k2k4r8")||r.startsWith("bafz"))return Ju(H.parse(r));if(e==null)throw new Ce('Please pass a multibase decoder for strings that do not start with "1" or "Q"');t=mt(e.decode(r))}return Hs(t)}function Hs(r){if(td(r))return new Yr({multihash:r});if(ed(r))try{let e=Fs(r);if(e.type==="Ed25519")return new Wr({multihash:r,publicKey:e});if(e.type==="secp256k1")return new Xr({multihash:r,publicKey:e})}catch{let t=_(r.digest);return new pr(new URL(t))}throw new xr("Supplied PeerID Multihash is invalid")}function Ju(r){if(r?.multihash==null||r.version==null||r.version===1&&r.code!==Qu&&r.code!==Vs)throw new wr("Supplied PeerID CID is invalid");if(r.code===Vs){let e=_(r.multihash.digest);return new pr(new URL(e))}return Hs(r.multihash)}function ed(r){return r.code===Be.code}function td(r){return r.code===Fn.code}var Ee=ne("node:net");function Zr(r){return!!(0,Ee.isIP)(r)}var $s=Pt(js(),1),rd=["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"],nd=rd.map(r=>new $s.Netmask(r));function _i(r){for(let e of nd)if(e.contains(r))return!0;return!1}function id(r){return/^::ffff:([0-9a-fA-F]{1,4}):([0-9a-fA-F]{1,4})$/.test(r)}function od(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 _i(i)}function sd(r){return/^::ffff:([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(r)}function cd(r){let e=r.split(":"),t=e[e.length-1];return _i(t)}function ad(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 Gs(r){return(0,Ee.isIPv4)(r)?_i(r):id(r)?od(r):sd(r)?cd(r):(0,Ee.isIPv6)(r)?ad(r):void 0}function Ys(r){try{let[[e]]=r.stringTuples();return e===4||e===41}catch{}return!1}function Ws(r){try{if(!Ys(r))return!1;let[[,e]]=r.stringTuples();return e==null?!1:Gs(e)??!1}catch{}return!0}var Qr=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 g=this.readAtomically(()=>{let d=this.readChar();if(d===void 0)return;let l=Number.parseInt(d,e);if(!Number.isNaN(l))return l});if(g===void 0)break;if(o*=e,o+=g,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 Og=new Qr;var Fg=parseInt("0xFFFF",16),qg=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);var Qs=Ee.isIPv4,gd=Ee.isIPv6,Ri=function(r){let e=0;if(r=r.toString().trim(),Qs(r)){let t=new Uint8Array(e+4);return r.split(/\./g).forEach(n=>{t[e++]=parseInt(n,10)&255}),t}if(gd(r)){let t=r.split(":",8),n;for(n=0;n<t.length;n++){let o=Qs(t[n]),s;o&&(s=Ri(t[n]),t[n]=_(s.slice(0,2),"base16")),s!=null&&++n<8&&t.splice(n,0,_(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")},Js=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 Gt={},Ki={},md=[[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"]];md.forEach(r=>{let e=yd(...r);Ki[e.code]=e,Gt[e.name]=e});function yd(r,e,t,n,i){return{code:r,size:e,name:t,resolvable:!!n,path:!!i}}function R(r){if(typeof r=="number"){if(Ki[r]!=null)return Ki[r];throw new Error(`no protocol with code: ${r}`)}else if(typeof r=="string"){if(Gt[r]!=null)return Gt[r];throw new Error(`no protocol with name: ${r}`)}throw new Error(`invalid protocol id type: ${typeof r}`)}var Sf=R("ip4"),Bf=R("ip6"),Uf=R("ipcidr");function Vi(r,e){switch(R(r).code){case 4:case 41:return xd(e);case 42:return qi(e);case 43:return _(e,"base10");case 6:case 273:case 33:case 132:return rc(e).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return qi(e);case 421:return vd(e);case 444:return tc(e);case 445:return tc(e);case 466:return Id(e);case 481:return globalThis.encodeURIComponent(qi(e));default:return _(e,"base16")}}function zi(r,e){switch(R(r).code){case 4:return ec(e);case 41:return ec(e);case 42:return Fi(e);case 43:return be(e,"base10");case 6:case 273:case 33:case 132:return Hi(parseInt(e,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return Fi(e);case 421:return bd(e);case 444:return Ad(e);case 445:return Sd(e);case 466:return Ed(e);case 481:return Fi(globalThis.decodeURIComponent(e));default:return be(e,"base16")}}var Mi=Object.values(rr).map(r=>r.decoder),wd=function(){let r=Mi[0].or(Mi[1]);return Mi.slice(2).forEach(e=>r=r.or(e)),r}();function ec(r){if(!Zr(r))throw new Error("invalid ip address");return Ri(r)}function xd(r){let e=Js(r,0,r.length);if(e==null)throw new Error("ipBuff is required");if(!Zr(e))throw new Error("invalid ip address");return e}function Hi(r){let e=new ArrayBuffer(2);return new DataView(e).setUint16(0,r),new Uint8Array(e)}function rc(r){return new DataView(r.buffer).getUint16(r.byteOffset)}function Fi(r){let e=be(r),t=Uint8Array.from(Mt(e.length));return he([t,e],t.length+e.length)}function qi(r){let e=xt(r);if(r=r.slice(se(e)),r.length!==e)throw new Error("inconsistent lengths");return _(r)}function bd(r){let e;r[0]==="Q"||r[0]==="1"?e=mt(F.decode(`z${r}`)).bytes:e=H.parse(r).multihash.bytes;let t=Uint8Array.from(Mt(e.length));return he([t,e],t.length+e.length)}function Ed(r){let e=wd.decode(r),t=Uint8Array.from(Mt(e.length));return he([t,e],t.length+e.length)}function Id(r){let e=xt(r),t=r.slice(se(e));if(t.length!==e)throw new Error("inconsistent lengths");return"u"+_(t,"base64url")}function vd(r){let e=xt(r),t=r.slice(se(e));if(t.length!==e)throw new Error("inconsistent lengths");return _(t,"base58btc")}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!==16)throw new Error(`failed to parse onion addr: ${e[0]} not a Tor onion address.`);let t=We.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=Hi(n);return he([t,i],t.length+i.length)}function Sd(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=We.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=Hi(n);return he([t,i],t.length+i.length)}function tc(r){let e=r.slice(0,r.length-2),t=r.slice(r.length-2),n=_(e,"base32"),i=rc(t);return`${n}:${i}`}function nc(r){r=ji(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=R(s);if(a.size===0){e.push([a.code]),t.push([a.code]);continue}if(o++,o>=i.length)throw new Jr("invalid address: "+r);if(a.path===!0){n=ji(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:ic(t),bytes:en(e),tuples:e,stringTuples:t,path:n}}function $i(r){let e=[],t=[],n=null,i=0;for(;i<r.length;){let o=xt(r,i),s=se(o),a=R(o),c=Bd(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 Jr("Invalid address Uint8Array: "+_(r,"base16"));e.push([o,u]);let g=Vi(o,u);if(t.push([o,g]),a.path===!0){n=g;break}}return{bytes:Uint8Array.from(r),string:ic(t),tuples:e,stringTuples:t,path:n}}function ic(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}),ji(e.join("/"))}function en(r){return he(r.map(e=>{let t=R(e[0]),n=Uint8Array.from(Mt(t.code));return e.length>1&&e[1]!=null&&(n=he([n,e[1]])),n}))}function Bd(r,e){if(r.size>0)return r.size/8;if(r.size===0)return 0;{let t=xt(e instanceof Uint8Array?e:Uint8Array.from(e));return t+se(t)}}function ji(r){return"/"+r.trim().split("/").filter(e=>e).join("/")}var Jr=class extends Error{static name="ParseError";name="ParseError";constructor(e){super(`Error parsing address: ${e}`)}};var Ud=Symbol.for("nodejs.util.inspect.custom"),Yi=Symbol.for("@multiformats/js-multiaddr/multiaddr"),Ld=[R("dns").code,R("dns4").code,R("dns6").code,R("dnsaddr").code],Gi=class extends Error{constructor(e="No available resolver"){super(e),this.name="NoAvailableResolverError"}},tn=class r{bytes;#e;#t;#r;#n;[Yi]=!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=nc(e)}else if(sc(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=R("tcp"),a=R("udp"),c=R("ip4"),u=R("ip6"),g=R("dns6"),d=R("ip6zone");for(let[p,h]of this.stringTuples())p===d.code&&(o=`%${h??""}`),Ld.includes(p)&&(t=s.name==="tcp"?"tcp":"udp",i=443,n=`${h??""}${o}`,e=p===g.code?6:4),(p===s.code||p===a.code)&&(t=R(p).name==="tcp"?"tcp":"udp",i=parseInt(h??"")),(p===c.code||p===u.code)&&(t=R(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({},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(en(t.slice(0,n)));return this}getPeerId(){try{let e=[];this.stringTuples().forEach(([n,i])=>{n===Gt.p2p.code&&e.push([n,i]),n===Gt["p2p-circuit"].code&&(e=[])});let t=e.pop();if(t?.[1]!=null){let n=t[1];return n[0]==="Q"||n[0]==="1"?_(F.decode(`z${n}`),"base58btc"):_(H.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){return this.#n}equals(e){return le(this.bytes,e.bytes)}async resolve(e){let t=this.protos().find(o=>o.resolvable);if(t==null)return[this];let n=oc.get(t.name);if(n==null)throw new Gi(`no available resolver for ${t.name}`);return(await n(this,e)).map(o=>fr(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)}[Ud](){return`Multiaddr(${this.#e})`}};var oc=new Map;function sc(r){return!!r?.[Yi]}function fr(r){return new tn(r)}function cc(r,e,t,n){let i=()=>{n?.log.trace("query",e),r.query({questions:[{name:e,type:"PTR"}]})};return i(),setInterval(i,t)}function ac(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=>fr(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:zs(a),multiaddrs:s.map(c=>c.decapsulateCode(R("p2p").code))}}catch(s){n?.log.error("failed to parse mdns response",s)}}function uc(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(Td).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 Td(r){return!!Ws(r)}function dc(r){let e="",t="abcdefghijklmnopqrstuvwxyz0123456789";for(let n=0;n<r;n++)e+=t.charAt(Math.floor(Math.random()*t.length));return e}var rn=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??dc(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)}[Zi]=this;[Symbol.toStringTag]="@libp2p/mdns";[eo]=["@libp2p/peer-discovery"];isStarted(){return!!this.mdns}async start(){this.mdns==null&&(this.mdns=(0,lc.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=cc(this.mdns,this.serviceTag,this.interval,{log:this.log}))}_onMdnsQuery(e){this.mdns!=null&&(this.log.trace("received incoming mDNS query"),uc(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=ac(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 Pd(r={}){return e=>new rn(e,r)}return yc(Od);})();
|
|
2
|
+
"use strict";var Libp2PMdns=(()=>{var pc=Object.create;var fr=Object.defineProperty;var fc=Object.getOwnPropertyDescriptor;var gc=Object.getOwnPropertyNames;var mc=Object.getPrototypeOf,yc=Object.prototype.hasOwnProperty;var ne=(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 Ce=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),ce=(r,e)=>{for(var t in e)fr(r,t,{get:e[t],enumerable:!0})},Gi=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of gc(e))!yc.call(r,i)&&i!==t&&fr(r,i,{get:()=>e[i],enumerable:!(n=fc(e,i))||n.enumerable});return r};var Lt=(r,e,t)=>(t=r!=null?pc(mc(r)):{},Gi(e||!r||!r.__esModule?fr(t,"default",{value:r,enumerable:!0}):t,r)),wc=r=>Gi(fr({},"__esModule",{value:!0}),r);var Qi=Ce(Jr=>{"use strict";Jr.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};Jr.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 Ji=Ce(en=>{"use strict";en.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};en.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 eo=Ce(tn=>{"use strict";tn.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};tn.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 to=Ce(rn=>{"use strict";rn.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};rn.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 ro=Ce(nn=>{"use strict";nn.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}`};nn.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 oo=Ce((io,on)=>{var no=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 m=l.length,g=0;for(let y=0;y<m;){let x=l.charCodeAt(y++);x===46?(p[h++]=g,g=0):g=g*10+(x-48)}return p[h]=g,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 m=h+i,g=-1,y=0,x=0,E=!0,L=!1;p=p||new Uint8Array(h+i);for(let C=0;C<l.length;C++){let B=l.charCodeAt(C);B===58?(E?g!==-1?(h<m&&(p[h]=0),h<m-1&&(p[h+1]=0),h+=2):h<m&&(g=h):(L===!0?(h<m&&(p[h]=x),h++):(h<m&&(p[h]=y>>8),h<m-1&&(p[h+1]=y&255),h+=2),y=0,x=0),E=!0,L=!1):B===46?(h<m&&(p[h]=x),h++,x=0,y=0,E=!1,L=!0):(E=!1,B>=97?B-=87:B>=65?B-=55:(B-=48,x=x*10+B),y=(y<<4)+B)}if(E===!1)L===!0?(h<m&&(p[h]=x),h++):(h<m&&(p[h]=y>>8),h<m-1&&(p[h+1]=y&255),h+=2);else if(g===0)h<m&&(p[h]=0),h<m-1&&(p[h+1]=0),h+=2;else if(g!==-1){h+=2;for(let C=Math.min(h-1,m-1);C>=g+2;C--)p[C]=p[C-2];p[g]=0,p[g+1]=0,g=h}if(g!==h&&g!==-1)for(h>m-2&&(h=m-2);m>g;)p[--m]=h<m&&h>g?p[--h]:0;else for(;h<m;)p[h++]=0;return p},decode(l,p){p=~~p;let h="";for(let m=0;m<i;m+=2)m!==0&&(h+=":"),h+=(l[p+m]<<8|l[p+m+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 m=c(l);return typeof p=="function"&&(p=p(h+m)),m===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 no}):typeof on=="object"&&typeof io=="object"&&(on.exports=no)});var ao=Ce(A=>{"use strict";var S=ne("buffer").Buffer,Ye=Qi(),xc=Ji(),bc=eo(),br=to(),sn=ro(),dt=oo(),Ec=0,so=32768,cn=32768,Ic=~cn,co=32768,vc=~co,w=A.name={};w.encode=function(r,e,t,{mail:n=!1}={}){e||(e=S.alloc(w.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,w.encode.bytes=t-i,e};w.encode.bytes=0;w.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 w.decode.bytes=s,n.length===0?".":n.join(".")};w.decode.bytes=0;w.encodingLength=function(r){return r==="."||r===".."?1:S.byteLength(r.replace(/^\.|\.$/gm,""))+2};var O={};O.encode=function(r,e,t){e||(e=S.alloc(O.encodingLength(r))),t||(t=0);let n=e.write(r,t+1);return e[t]=n,O.encode.bytes=n+1,e};O.encode.bytes=0;O.decode=function(r,e){e||(e=0);let t=r[e],n=r.toString("utf-8",e+1,e+1+t);return O.decode.bytes=t+1,n};O.decode.bytes=0;O.encodingLength=function(r){return S.byteLength(r)+1};var Se={};Se.encode=function(r,e,t){e||(e=Se.encodingLength(r)),t||(t=0);let n=(r.flags||0)&32767,i=r.type==="response"?so:Ec;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};Se.encode.bytes=12;Se.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&so?"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:xc.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))}};Se.decode.bytes=12;Se.encodingLength=function(){return 12};var Me=A.unknown={};Me.encode=function(r,e,t){return e||(e=S.alloc(Me.encodingLength(r))),t||(t=0),e.writeUInt16BE(r.length,t),r.copy(e,t+2),Me.encode.bytes=r.length+2,e};Me.encode.bytes=0;Me.decode=function(r,e){e||(e=0);let t=r.readUInt16BE(e),n=r.slice(e+2,e+2+t);return Me.decode.bytes=t+2,n};Me.decode.bytes=0;Me.encodingLength=function(r){return r.length+2};var Fe=A.ns={};Fe.encode=function(r,e,t){return e||(e=S.alloc(Fe.encodingLength(r))),t||(t=0),w.encode(r,e,t+2),e.writeUInt16BE(w.encode.bytes,t),Fe.encode.bytes=w.encode.bytes+2,e};Fe.encode.bytes=0;Fe.decode=function(r,e){e||(e=0);let t=r.readUInt16BE(e),n=w.decode(r,e+2);return Fe.decode.bytes=t+2,n};Fe.decode.bytes=0;Fe.encodingLength=function(r){return w.encodingLength(r)+2};var qe=A.soa={};qe.encode=function(r,e,t){e||(e=S.alloc(qe.encodingLength(r))),t||(t=0);let n=t;return t+=2,w.encode(r.mname,e,t),t+=w.encode.bytes,w.encode(r.rname,e,t,{mail:!0}),t+=w.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=w.decode(r,e),e+=w.decode.bytes,n.rname=w.decode(r,e,{mail:!0}),e+=w.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+w.encodingLength(r.mname)+w.encodingLength(r.rname)};var Ve=A.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]=S.from(r[i])),!S.isBuffer(r[i]))throw new Error("Must be a Buffer");e||(e=S.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+=S.byteLength(t)+1:e+=t.length+1}),e};var He=A.null={};He.encode=function(r,e,t){e||(e=S.alloc(He.encodingLength(r))),t||(t=0),typeof r=="string"&&(r=S.from(r)),r||(r=S.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),He.encode.bytes=t-n,e};He.encode.bytes=0;He.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,He.decode.bytes=e-t,i};He.decode.bytes=0;He.encodingLength=function(r){return r?(S.isBuffer(r)?r.length:S.byteLength(r))+2:2};var ze=A.hinfo={};ze.encode=function(r,e,t){e||(e=S.alloc(ze.encodingLength(r))),t||(t=0);let n=t;return t+=2,O.encode(r.cpu,e,t),t+=O.encode.bytes,O.encode(r.os,e,t),t+=O.encode.bytes,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.cpu=O.decode(r,e),e+=O.decode.bytes,n.os=O.decode(r,e),e+=O.decode.bytes,ze.decode.bytes=e-t,n};ze.decode.bytes=0;ze.encodingLength=function(r){return O.encodingLength(r.cpu)+O.encodingLength(r.os)+2};var ve=A.ptr={},Ac=A.cname=ve,Sc=A.dname=ve;ve.encode=function(r,e,t){return e||(e=S.alloc(ve.encodingLength(r))),t||(t=0),w.encode(r,e,t+2),e.writeUInt16BE(w.encode.bytes,t),ve.encode.bytes=w.encode.bytes+2,e};ve.encode.bytes=0;ve.decode=function(r,e){e||(e=0);let t=w.decode(r,e+2);return ve.decode.bytes=w.decode.bytes+2,t};ve.decode.bytes=0;ve.encodingLength=function(r){return w.encodingLength(r)+2};var je=A.srv={};je.encode=function(r,e,t){e||(e=S.alloc(je.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),w.encode(r.target,e,t+8);let n=w.encode.bytes+6;return e.writeUInt16BE(n,t),je.encode.bytes=n+2,e};je.encode.bytes=0;je.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=w.decode(r,e+8),je.decode.bytes=t+2,n};je.decode.bytes=0;je.encodingLength=function(r){return 8+w.encodingLength(r.target)};var ae=A.caa={};ae.ISSUER_CRITICAL=128;ae.encode=function(r,e,t){let n=ae.encodingLength(r);return e||(e=S.alloc(ae.encodingLength(r))),t||(t=0),r.issuerCritical&&(r.flags=ae.ISSUER_CRITICAL),e.writeUInt16BE(n-2,t),t+=2,e.writeUInt8(r.flags||0,t),t+=1,O.encode(r.tag,e,t),t+=O.encode.bytes,e.write(r.value,t),t+=S.byteLength(r.value),ae.encode.bytes=n,e};ae.encode.bytes=0;ae.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=O.decode(r,e),e+=O.decode.bytes,i.value=r.toString("utf-8",e,n+t),i.issuerCritical=!!(i.flags&ae.ISSUER_CRITICAL),ae.decode.bytes=t+2,i};ae.decode.bytes=0;ae.encodingLength=function(r){return O.encodingLength(r.tag)+O.encodingLength(r.value)+2};var nt=A.mx={};nt.encode=function(r,e,t){e||(e=S.alloc(nt.encodingLength(r))),t||(t=0);let n=t;return t+=2,e.writeUInt16BE(r.preference||0,t),t+=2,w.encode(r.exchange,e,t),t+=w.encode.bytes,e.writeUInt16BE(t-n-2,n),nt.encode.bytes=t-n,e};nt.encode.bytes=0;nt.decode=function(r,e){e||(e=0);let t=e,n={};return e+=2,n.preference=r.readUInt16BE(e),e+=2,n.exchange=w.decode(r,e),e+=w.decode.bytes,nt.decode.bytes=e-t,n};nt.encodingLength=function(r){return 4+w.encodingLength(r.exchange)};var $e=A.a={};$e.encode=function(r,e,t){return e||(e=S.alloc($e.encodingLength(r))),t||(t=0),e.writeUInt16BE(4,t),t+=2,dt.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=dt.v4.decode(r,e);return $e.decode.bytes=6,t};$e.decode.bytes=0;$e.encodingLength=function(){return 6};var Ge=A.aaaa={};Ge.encode=function(r,e,t){return e||(e=S.alloc(Ge.encodingLength(r))),t||(t=0),e.writeUInt16BE(16,t),t+=2,dt.v6.encode(r,e,t),Ge.encode.bytes=18,e};Ge.encode.bytes=0;Ge.decode=function(r,e){e||(e=0),e+=2;let t=dt.v6.decode(r,e);return Ge.decode.bytes=18,t};Ge.decode.bytes=0;Ge.encodingLength=function(){return 18};var ie=A.option={};ie.encode=function(r,e,t){e||(e=S.alloc(ie.encodingLength(r))),t||(t=0);let n=t,i=sn.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),a=dt.encode(r.ip,S.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 ie.encode.bytes=t-n,e};ie.encode.bytes=0;ie.decode=function(r,e){e||(e=0);let t={};t.code=r.readUInt16BE(e),t.type=sn.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=S.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 ie.decode.bytes=n+4,t};ie.decode.bytes=0;ie.encodingLength=function(r){if(r.data)return r.data.length+4;switch(sn.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 de=A.opt={};de.encode=function(r,e,t){e||(e=S.alloc(de.encodingLength(r))),t||(t=0);let n=t,i=Ct(r,ie);return e.writeUInt16BE(i,t),t=Yt(r,ie,e,t+2),de.encode.bytes=t-n,e};de.encode.bytes=0;de.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++]=ie.decode(r,e),e+=ie.decode.bytes,i-=ie.decode.bytes;return de.decode.bytes=e-t,n};de.decode.bytes=0;de.encodingLength=function(r){return 2+Ct(r||[],ie)};var ee=A.dnskey={};ee.PROTOCOL_DNSSEC=3;ee.ZONE_KEY=128;ee.SECURE_ENTRYPOINT=32768;ee.encode=function(r,e,t){e||(e=S.alloc(ee.encodingLength(r))),t||(t=0);let n=t,i=r.key;if(!S.isBuffer(i))throw new Error("Key must be a Buffer");return t+=2,e.writeUInt16BE(r.flags,t),t+=2,e.writeUInt8(ee.PROTOCOL_DNSSEC,t),t+=1,e.writeUInt8(r.algorithm,t),t+=1,i.copy(e,t,0,i.length),t+=i.length,ee.encode.bytes=t-n,e.writeUInt16BE(ee.encode.bytes-2,n),e};ee.encode.bytes=0;ee.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)!==ee.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,ee.decode.bytes=e-t,n};ee.decode.bytes=0;ee.encodingLength=function(r){return 6+S.byteLength(r.key)};var Pe=A.rrsig={};Pe.encode=function(r,e,t){e||(e=S.alloc(Pe.encodingLength(r))),t||(t=0);let n=t,i=r.signature;if(!S.isBuffer(i))throw new Error("Signature must be a Buffer");return t+=2,e.writeUInt16BE(Ye.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,w.encode(r.signersName,e,t),t+=w.encode.bytes,i.copy(e,t,0,i.length),t+=i.length,Pe.encode.bytes=t-n,e.writeUInt16BE(Pe.encode.bytes-2,n),e};Pe.encode.bytes=0;Pe.decode=function(r,e){e||(e=0);let t=e;var n={},i=r.readUInt16BE(e);return e+=2,n.typeCovered=Ye.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=w.decode(r,e),e+=w.decode.bytes,n.signature=r.slice(e,t+i+2),e+=n.signature.length,Pe.decode.bytes=e-t,n};Pe.decode.bytes=0;Pe.encodingLength=function(r){return 20+w.encodingLength(r.signersName)+S.byteLength(r.signature)};var Oe=A.rp={};Oe.encode=function(r,e,t){e||(e=S.alloc(Oe.encodingLength(r))),t||(t=0);let n=t;return t+=2,w.encode(r.mbox||".",e,t,{mail:!0}),t+=w.encode.bytes,w.encode(r.txt||".",e,t),t+=w.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=w.decode(r,e,{mail:!0})||".",e+=w.decode.bytes,n.txt=w.decode(r,e)||".",e+=w.decode.bytes,Oe.decode.bytes=e-t,n};Oe.decode.bytes=0;Oe.encodingLength=function(r){return 2+w.encodingLength(r.mbox||".")+w.encodingLength(r.txt||".")};var $={};$.encode=function(r,e,t){e||(e=S.alloc($.encodingLength(r))),t||(t=0);let n=t;for(var i=[],o=0;o<r.length;o++){var s=Ye.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=S.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=Ye.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=Ye.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=A.nsec={};Ne.encode=function(r,e,t){e||(e=S.alloc(Ne.encodingLength(r))),t||(t=0);let n=t;return t+=2,w.encode(r.nextDomain,e,t),t+=w.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=w.decode(r,e),e+=w.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+w.encodingLength(r.nextDomain)+$.encodingLength(r.rrtypes)};var De=A.nsec3={};De.encode=function(r,e,t){e||(e=S.alloc(De.encodingLength(r))),t||(t=0);let n=t,i=r.salt;if(!S.isBuffer(i))throw new Error("salt must be a Buffer");let o=r.nextDomain;if(!S.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,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;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,De.decode.bytes=e-t,n};De.decode.bytes=0;De.encodingLength=function(r){return 8+r.salt.length+r.nextDomain.length+$.encodingLength(r.rrtypes)};var ke=A.ds={};ke.encode=function(r,e,t){e||(e=S.alloc(ke.encodingLength(r))),t||(t=0);let n=t,i=r.digest;if(!S.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+S.byteLength(r.digest)};var ue=A.sshfp={};ue.getFingerprintLengthForHashType=function(e){switch(e){case 1:return 20;case 2:return 32}};ue.encode=function(e,t,n){t||(t=S.alloc(ue.encodingLength(e))),n||(n=0);let i=n;n+=2,t[n]=e.algorithm,n+=1,t[n]=e.hash,n+=1;let o=S.from(e.fingerprint.toUpperCase(),"hex");if(o.length!==ue.getFingerprintLengthForHashType(e.hash))throw new Error("Invalid fingerprint length");return o.copy(t,n),n+=o.byteLength,ue.encode.bytes=n-i,t.writeUInt16BE(ue.encode.bytes-2,i),t};ue.encode.bytes=0;ue.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=ue.getFingerprintLengthForHashType(i.hash);return i.fingerprint=e.slice(t,t+o).toString("hex").toUpperCase(),t+=o,ue.decode.bytes=t-n,i};ue.decode.bytes=0;ue.encodingLength=function(r){return 4+S.from(r.fingerprint,"hex").byteLength};var _e=A.naptr={};_e.encode=function(r,e,t){e||(e=S.alloc(_e.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,O.encode(r.flags,e,t),t+=O.encode.bytes,O.encode(r.services,e,t),t+=O.encode.bytes,O.encode(r.regexp,e,t),t+=O.encode.bytes,w.encode(r.replacement,e,t),t+=w.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,n={};return e+=2,n.order=r.readUInt16BE(e),e+=2,n.preference=r.readUInt16BE(e),e+=2,n.flags=O.decode(r,e),e+=O.decode.bytes,n.services=O.decode(r,e),e+=O.decode.bytes,n.regexp=O.decode(r,e),e+=O.decode.bytes,n.replacement=w.decode(r,e),e+=w.decode.bytes,_e.decode.bytes=e-t,n};_e.decode.bytes=0;_e.encodingLength=function(r){return O.encodingLength(r.flags)+O.encodingLength(r.services)+O.encodingLength(r.regexp)+w.encodingLength(r.replacement)+6};var Re=A.tlsa={};Re.encode=function(r,e,t){e||(e=S.alloc(Re.encodingLength(r))),t||(t=0);let n=t,i=r.certificate;if(!S.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,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={},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,Re.decode.bytes=e-t,n};Re.decode.bytes=0;Re.encodingLength=function(r){return 5+S.byteLength(r.certificate)};var an=A.record=function(r){switch(r.toUpperCase()){case"A":return $e;case"PTR":return ve;case"CNAME":return Ac;case"DNAME":return Sc;case"TXT":return Ve;case"NULL":return He;case"AAAA":return Ge;case"SRV":return je;case"HINFO":return ze;case"CAA":return ae;case"NS":return Fe;case"SOA":return qe;case"MX":return nt;case"OPT":return de;case"DNSKEY":return ee;case"RRSIG":return Pe;case"RP":return Oe;case"NSEC":return Ne;case"NSEC3":return De;case"SSHFP":return ue;case"DS":return ke;case"NAPTR":return _e;case"TLSA":return Re}return Me},W=A.answer={};W.encode=function(r,e,t){e||(e=S.alloc(W.encodingLength(r))),t||(t=0);let n=t;if(w.encode(r.name,e,t),t+=w.encode.bytes,e.writeUInt16BE(Ye.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,de.encode(r.options||[],e,t),t+=de.encode.bytes}else{let i=br.toClass(r.class===void 0?"IN":r.class);r.flush&&(i|=cn),e.writeUInt16BE(i,t+2),e.writeUInt32BE(r.ttl||0,t+4),t+=8;let o=an(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=w.decode(r,e),e+=w.decode.bytes,t.type=Ye.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=de.decode(r,e+8),e+=8+de.decode.bytes;else{let i=r.readUInt16BE(e+2);t.ttl=r.readUInt32BE(e+4),t.class=br.toString(i&Ic),t.flush=!!(i&cn);let o=an(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 w.encodingLength(r.name)+8+an(r.type).encodingLength(e)};var Ae=A.question={};Ae.encode=function(r,e,t){e||(e=S.alloc(Ae.encodingLength(r))),t||(t=0);let n=t;return w.encode(r.name,e,t),t+=w.encode.bytes,e.writeUInt16BE(Ye.toType(r.type),t),t+=2,e.writeUInt16BE(br.toClass(r.class===void 0?"IN":r.class),t),t+=2,Ae.encode.bytes=t-n,r};Ae.encode.bytes=0;Ae.decode=function(r,e){e||(e=0);let t=e,n={};return n.name=w.decode(r,e),e+=w.decode.bytes,n.type=Ye.toString(r.readUInt16BE(e)),e+=2,n.class=br.toString(r.readUInt16BE(e)),e+=2,!!(n.class&co)&&(n.class&=vc),Ae.decode.bytes=e-t,n};Ae.decode.bytes=0;Ae.encodingLength=function(r){return w.encodingLength(r.name)+4};A.AUTHORITATIVE_ANSWER=1024;A.TRUNCATED_RESPONSE=512;A.RECURSION_DESIRED=256;A.RECURSION_AVAILABLE=128;A.AUTHENTIC_DATA=32;A.CHECKING_DISABLED=16;A.DNSSEC_OK=32768;A.encode=function(r,e,t){let n=!e;n&&(e=S.alloc(A.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=[]),Se.encode(r,e,t),t+=Se.encode.bytes,t=Yt(r.questions,Ae,e,t),t=Yt(r.answers,W,e,t),t=Yt(r.authorities,W,e,t),t=Yt(r.additionals,W,e,t),A.encode.bytes=t-i,n&&A.encode.bytes!==e.length?e.slice(0,A.encode.bytes):e};A.encode.bytes=0;A.decode=function(r,e){e||(e=0);let t=e,n=Se.decode(r,e);return e+=Se.decode.bytes,e=xr(n.questions,Ae,r,e),e=xr(n.answers,W,r,e),e=xr(n.authorities,W,r,e),e=xr(n.additionals,W,r,e),A.decode.bytes=e-t,n};A.decode.bytes=0;A.encodingLength=function(r){return Se.encodingLength(r)+Ct(r.questions||[],Ae)+Ct(r.answers||[],W)+Ct(r.authorities||[],W)+Ct(r.additionals||[],W)};A.streamEncode=function(r){let e=A.encode(r),t=S.alloc(2);t.writeUInt16BE(e.byteLength);let n=S.concat([t,e]);return A.streamEncode.bytes=n.byteLength,n};A.streamEncode.bytes=0;A.streamDecode=function(r){let e=r.readUInt16BE(0);if(r.byteLength<e+2)return null;let t=A.decode(r.slice(2));return A.streamDecode.bytes=A.decode.bytes,t};A.streamDecode.bytes=0;function Ct(r,e){let t=0;for(let n=0;n<r.length;n++)t+=e.encodingLength(r[n]);return t}function Yt(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 xr(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 ho=Ce((cl,lo)=>{"use strict";var uo=Pc;process.nextTick(Tc,42);lo.exports=Bc;function Bc(r){var e=n;return t;function t(i){e(i||Lc)}function n(i){var o=[i];e=s,r(a);function s(c){o.push(c)}function a(c){var u=arguments;for(e=Uc(c)?n:f;o.length;)f(o.shift());function f(d){uo(Cc,d,u)}}}}function Uc(r){return Object.prototype.toString.call(r)==="[object Error]"}function Lc(){}function Cc(r,e){r.apply(null,e)}function Tc(r){r===42&&(uo=process.nextTick)}function Pc(r,e,t){process.nextTick(function(){r(e,t)})}});var go=Ce((al,fo)=>{var un=ao(),Oc=ne("dgram"),Nc=ho(),Dc=ne("events"),ln=ne("os"),dn=function(){};fo.exports=function(r){r||(r={});var e=new Dc.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||Oc.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=un.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=Nc(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=dn),l?!l.host&&!l.address&&(l.address=o.address):l=o,f(h);function h(m){if(a)return p();if(m)return p(m);var g=un.encode(d);u.send(g,0,g.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)|un.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=dn),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=dn),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):_c(),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(m){e.emit("warning",m)}}if(l){if(u.setMulticastInterface)try{u.setMulticastInterface(r.interface||kc())}catch(m){e.emit("warning",m)}e.emit("networkInterface")}},e};function kc(){for(var r=ln.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(po(o.family)&&!o.internal)return ln.platform()==="darwin"&&e[t]==="en0"?o.address:"0.0.0.0"}return"127.0.0.1"}function _c(){for(var r=ln.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(po(s.family)){t.push(s.address);break}}return t}function po(r){return r===4||r==="IPv4"}});var $s=Ce(hr=>{(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(m){throw d=m,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(m){throw d=m,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}(),hr.ip2long=s,hr.long2ip=a,hr.Netmask=r}).call(hr)});var Ad={};ce(Ad,{mdns:()=>vd});var Yi=Symbol.for("@libp2p/peer-discovery");var Qr=Symbol.for("@libp2p/peer-id");var Te=class extends Error{static name="InvalidParametersError";constructor(e="Invalid parameters"){super(e),this.name="InvalidParametersError"}},gr=class extends Error{static name="InvalidPublicKeyError";constructor(e="Invalid public key"){super(e),this.name="InvalidPublicKeyError"}};var mr=class extends Error{static name="InvalidCIDError";constructor(e="Invalid CID"){super(e),this.name="InvalidCIDError"}},yr=class extends Error{static name="InvalidMultihashError";constructor(e="Invalid Multihash"){super(e),this.name="InvalidMultihashError"}};var Gt=class extends Error{static name="UnsupportedKeyTypeError";constructor(e="Unsupported key type"){super(e),this.name="UnsupportedKeyTypeError"}};var Wi=ne("node:events"),Zi=(r,...e)=>{try{(0,Wi.setMaxListeners)(r,...e)}catch{}};var wr=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 Xi=Symbol.for("@libp2p/service-capabilities"),Od=Symbol.for("@libp2p/service-dependencies");var hc=Lt(go(),1);var mn={};ce(mn,{base58btc:()=>F,base58flickr:()=>Vc});var ul=new Uint8Array(0);function mo(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 we(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 yo(r){return new TextEncoder().encode(r)}function wo(r){return new TextDecoder().decode(r)}function Rc(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 m=0,g=0,y=0,x=h.length;y!==x&&h[y]===0;)y++,m++;for(var E=(x-y)*f+1>>>0,L=new Uint8Array(E);y!==x;){for(var C=h[y],B=0,U=E-1;(C!==0||B<g)&&U!==-1;U--,B++)C+=256*L[U]>>>0,L[U]=C%a>>>0,C=C/a>>>0;if(C!==0)throw new Error("Non-zero carry");g=B,y++}for(var T=E-g;T!==E&&L[T]===0;)T++;for(var P=c.repeat(m);T<E;++T)P+=r.charAt(L[T]);return P}function l(h){if(typeof h!="string")throw new TypeError("Expected String");if(h.length===0)return new Uint8Array;var m=0;if(h[m]!==" "){for(var g=0,y=0;h[m]===c;)g++,m++;for(var x=(h.length-m)*u+1>>>0,E=new Uint8Array(x);h[m];){var L=t[h.charCodeAt(m)];if(L===255)return;for(var C=0,B=x-1;(L!==0||C<y)&&B!==-1;B--,C++)L+=a*E[B]>>>0,E[B]=L%256>>>0,L=L/256>>>0;if(L!==0)throw new Error("Non-zero carry");y=C,m++}if(h[m]!==" "){for(var U=x-y;U!==x&&E[U]===0;)U++;for(var T=new Uint8Array(g+(x-U)),P=g;U!==x;)T[P++]=E[U++];return T}}}function p(h){var m=l(h);if(m)return m;throw new Error(`Non-${e} character`)}return{encode:d,decodeUnsafe:l,decode:p}}var Kc=Rc,Mc=Kc,bo=Mc;var hn=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")}},pn=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 Eo(this,e)}},fn=class{decoders;constructor(e){this.decoders=e}or(e){return Eo(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 Eo(r,e){return new fn({...r.decoders??{[r.prefix]:r},...e.decoders??{[e.prefix]:e}})}var gn=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 hn(e,t,n),this.decoder=new pn(e,t,i)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};function Tt({name:r,prefix:e,encode:t,decode:n}){return new gn(r,e,t,n)}function it({name:r,prefix:e,alphabet:t}){let{encode:n,decode:i}=bo(t,r);return Tt({prefix:e,name:r,encode:n,decode:o=>we(i(o))})}function Fc(r,e,t,n){let i={};for(let f=0;f<e.length;++f)i[e[f]]=f;let o=r.length;for(;r[o-1]==="=";)--o;let s=new Uint8Array(o*t/8|0),a=0,c=0,u=0;for(let f=0;f<o;++f){let d=i[r[f]];if(d===void 0)throw new SyntaxError(`Non-${n} character`);c=c<<t|d,a+=t,a>=8&&(a-=8,s[u++]=255&c>>a)}if(a>=t||(255&c<<8-a)!==0)throw new SyntaxError("Unexpected end of data");return s}function qc(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 q({name:r,prefix:e,bitsPerChar:t,alphabet:n}){return Tt({prefix:e,name:r,encode(i){return qc(i,n,t)},decode(i){return Fc(i,n,t,r)}})}var F=it({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Vc=it({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var yn={};ce(yn,{base32:()=>We,base32hex:()=>$c,base32hexpad:()=>Yc,base32hexpadupper:()=>Wc,base32hexupper:()=>Gc,base32pad:()=>zc,base32padupper:()=>jc,base32upper:()=>Hc,base32z:()=>Zc});var We=q({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Hc=q({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),zc=q({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),jc=q({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),$c=q({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Gc=q({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Yc=q({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Wc=q({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Zc=q({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var wn={};ce(wn,{base36:()=>Wt,base36upper:()=>Xc});var Wt=it({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Xc=it({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Qc=Ao,Io=128,Jc=127,ea=~Jc,ta=Math.pow(2,31);function Ao(r,e,t){e=e||[],t=t||0;for(var n=t;r>=ta;)e[t++]=r&255|Io,r/=128;for(;r&ea;)e[t++]=r&255|Io,r>>>=7;return e[t]=r|0,Ao.bytes=t-n+1,e}var ra=xn,na=128,vo=127;function xn(r,n){var t=0,n=n||0,i=0,o=n,s,a=r.length;do{if(o>=a)throw xn.bytes=0,new RangeError("Could not decode varint");s=r[o++],t+=i<28?(s&vo)<<i:(s&vo)*Math.pow(2,i),i+=7}while(s>=na);return xn.bytes=o-n,t}var ia=Math.pow(2,7),oa=Math.pow(2,14),sa=Math.pow(2,21),ca=Math.pow(2,28),aa=Math.pow(2,35),ua=Math.pow(2,42),da=Math.pow(2,49),la=Math.pow(2,56),ha=Math.pow(2,63),pa=function(r){return r<ia?1:r<oa?2:r<sa?3:r<ca?4:r<aa?5:r<ua?6:r<da?7:r<la?8:r<ha?9:10},fa={encode:Qc,decode:ra,encodingLength:pa},ga=fa,Zt=ga;function Xt(r,e=0){return[Zt.decode(r,e),Zt.decode.bytes]}function Pt(r,e,t=0){return Zt.encode(r,e,t),e}function Ot(r){return Zt.encodingLength(r)}function lt(r,e){let t=e.byteLength,n=Ot(r),i=n+Ot(t),o=new Uint8Array(i+t);return Pt(r,o,0),Pt(t,o,n),o.set(e,i),new Nt(r,t,e,o)}function ht(r){let e=we(r),[t,n]=Xt(e),[i,o]=Xt(e.subarray(n)),s=e.subarray(n+o);if(s.byteLength!==i)throw new Error("Incorrect length");return new Nt(t,i,s,e)}function So(r,e){if(r===e)return!0;{let t=e;return r.code===t.code&&r.size===t.size&&t.bytes instanceof Uint8Array&&mo(r.bytes,t.bytes)}}var Nt=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 ya(t,bn(r),e??F.encoder);default:return wa(t,bn(r),e??We.encoder)}}var Uo=new WeakMap;function bn(r){let e=Uo.get(r);if(e==null){let t=new Map;return Uo.set(r,t),t}return e}var z=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!==Qt)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==xa)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&&So(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??Lo(n,i,o.bytes))}else if(t[ba]===!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!==Qt)throw new Error(`Version 0 CID must use dag-pb (code: ${Qt}) block encoding`);return new r(e,t,n,n.bytes)}case 1:{let i=Lo(e,t,n.bytes);return new r(e,t,n,i)}default:throw new Error("Invalid version")}}static createV0(e){return r.create(0,Qt,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=we(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 Nt(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]=Xt(e.subarray(t));return t+=l,d},i=n(),o=Qt;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]=ma(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 bn(o).set(n,e),o}};function ma(r,e){switch(r[0]){case"Q":{let t=e??F;return[F.prefix,t.decode(`${F.prefix}${r}`)]}case F.prefix:{let t=e??F;return[F.prefix,t.decode(r)]}case We.prefix:{let t=e??We;return[We.prefix,t.decode(r)]}case Wt.prefix:{let t=e??Wt;return[Wt.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 ya(r,e,t){let{prefix:n}=t;if(n!==F.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 wa(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 Qt=112,xa=18;function Lo(r,e,t){let n=Ot(r),i=n+Ot(e),o=new Uint8Array(i+t.byteLength);return Pt(r,o,0),Pt(e,o,n),o.set(t,i),o}var ba=Symbol.for("@ipld/js-cid/CID");var En={};ce(En,{identity:()=>Be});var Co=0,Ea="identity",To=we;function Ia(r){return lt(Co,To(r))}var Be={code:Co,name:Ea,encode:To,digest:Ia};function le(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 In=ne("node:buffer");function ft(r){return new Uint8Array(r.buffer,r.byteOffset,r.byteLength)}function Ze(r=0){return ft(In.Buffer.alloc(r))}function xe(r=0){return ft(In.Buffer.allocUnsafe(r))}var Po=ne("node:buffer");function he(r,e){return ft(Po.Buffer.concat(r,e))}var No=Symbol.for("@achingbrain/uint8arraylist");function Oo(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 Ir(r){return!!r?.[No]}var pe=class r{bufs;length;[No]=!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(Ir(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(Ir(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=Oo(this.bufs,e);return t.buf[t.index]}set(e,t){let n=Oo(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(Ir(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 he(n,i)}subarray(e,t){let{bufs:n,length:i}=this._subList(e,t);return n.length===1?n[0]:he(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(!Ir(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=xe(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setInt8(0,t),this.write(n,e)}getInt16(e,t){let n=this.subarray(e,e+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt16(0,t)}setInt16(e,t,n){let 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=xe(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setUint8(0,t),this.write(n,e)}getUint16(e,t){let n=this.subarray(e,e+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint16(0,t)}setUint16(e,t,n){let 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(!le(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 Ko=ne("node:buffer");var vn={};ce(vn,{base10:()=>va});var va=it({prefix:"9",name:"base10",alphabet:"0123456789"});var An={};ce(An,{base16:()=>Aa,base16upper:()=>Sa});var Aa=q({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Sa=q({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Sn={};ce(Sn,{base2:()=>Ba});var Ba=q({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Bn={};ce(Bn,{base256emoji:()=>Pa});var Do=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}"),Ua=Do.reduce((r,e,t)=>(r[t]=e,r),[]),La=Do.reduce((r,e,t)=>{let n=e.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${e}`);return r[n]=t,r},[]);function Ca(r){return r.reduce((e,t)=>(e+=Ua[t],e),"")}function Ta(r){let e=[];for(let t of r){let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);let i=La[n];if(i==null)throw new Error(`Non-base256emoji character: ${t}`);e.push(i)}return new Uint8Array(e)}var Pa=Tt({prefix:"\u{1F680}",name:"base256emoji",encode:Ca,decode:Ta});var Un={};ce(Un,{base64:()=>Oa,base64pad:()=>Na,base64url:()=>Da,base64urlpad:()=>ka});var Oa=q({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Na=q({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Da=q({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),ka=q({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Ln={};ce(Ln,{base8:()=>_a});var _a=q({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Cn={};ce(Cn,{identity:()=>Ra});var Ra=Tt({prefix:"\0",name:"identity",encode:r=>wo(r),decode:r=>yo(r)});var jl=new TextEncoder,$l=new TextDecoder;var Dn={};ce(Dn,{sha256:()=>Nn,sha512:()=>Fa});var On=Lt(ne("crypto"),1);function Pn({name:r,code:e,encode:t}){return new Tn(r,e,t)}var Tn=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 Nn=Pn({name:"sha2-256",code:18,encode:r=>we(On.default.createHash("sha256").update(r).digest())}),Fa=Pn({name:"sha2-512",code:19,encode:r=>we(On.default.createHash("sha512").update(r).digest())});var Jt={...Cn,...Sn,...Ln,...vn,...An,...yn,...wn,...mn,...Un,...Bn},oh={...Dn,...En};function Ro(r,e,t,n){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:n}}}var _o=Ro("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),kn=Ro("ascii","a",r=>{let e="a";for(let t=0;t<r.length;t++)e+=String.fromCharCode(r[t]);return e},r=>{r=r.substring(1);let e=xe(r.length);for(let t=0;t<r.length;t++)e[t]=r.charCodeAt(t);return e}),qa={utf8:_o,"utf-8":_o,hex:Jt.base16,latin1:kn,ascii:kn,binary:kn,...Jt},vr=qa;function be(r,e="utf8"){let t=vr[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return e==="utf8"||e==="utf-8"?ft(Ko.Buffer.from(r,"utf-8")):t.decoder.decode(`${t.prefix}${r}`)}var Mo=ne("node:buffer");function _(r,e="utf8"){let t=vr[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return e==="utf8"||e==="utf-8"?Mo.Buffer.from(r.buffer,r.byteOffset,r.byteLength).toString("utf8"):t.encoder.encode(r).substring(1)}var Va=parseInt("11111",2),_n=parseInt("10000000",2),Ha=parseInt("01111111",2),Fo={0:er,1:er,2:za,3:Ga,4:Ya,5:$a,6:ja,16:er,22:er,48:er};function Rn(r,e={offset:0}){let t=r[e.offset]&Va;if(e.offset++,Fo[t]!=null)return Fo[t](r,e);throw new Error("No decoder for tag "+t)}function tr(r,e){let t=0;if((r[e.offset]&_n)===_n){let n=r[e.offset]&Ha,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 er(r,e){tr(r,e);let t=[];for(;!(e.offset>=r.byteLength);){let n=Rn(r,e);if(n===null)break;t.push(n)}return t}function za(r,e){let t=tr(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 ja(r,e){let t=tr(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 $a(r,e){return e.offset++,null}function Ga(r,e){let t=tr(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 Ya(r,e){let t=tr(r,e),n=r.subarray(e.offset,e.offset+t);return e.offset+=t,n}function Wa(r){let e=r.toString(16);e.length%2===1&&(e="0"+e);let t=new pe;for(let n=0;n<e.length;n+=2)t.append(Uint8Array.from([parseInt(`${e[n]}${e[n+1]}`,16)]));return t}function Kn(r){if(r.byteLength<128)return Uint8Array.from([r.byteLength]);let e=Wa(r.byteLength);return new pe(Uint8Array.from([e.byteLength|_n]),e)}function qo(r){let e=new pe,t=128;return(r.subarray()[0]&t)===t&&e.append(Uint8Array.from([0])),e.append(r),new pe(Uint8Array.from([2]),Kn(e),e)}function Vo(r){let e=Uint8Array.from([0]),t=new pe(e,r);return new pe(Uint8Array.from([3]),Kn(t),t)}function Ar(r,e=48){let t=new pe;for(let n of r)t.append(n);return new pe(Uint8Array.from([e]),Kn(t),t)}async function Ho(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 Za=Uint8Array.from([6,8,42,134,72,206,61,3,1,7]),Xa=Uint8Array.from([6,5,43,129,4,0,34]),Qa=Uint8Array.from([6,5,43,129,4,0,35]),Ja={ext:!0,kty:"EC",crv:"P-256"},eu={ext:!0,kty:"EC",crv:"P-384"},tu={ext:!0,kty:"EC",crv:"P-521"},Mn=32,Fn=48,qn=66;function zo(r){let e=Rn(r);return jo(e)}function jo(r){let e=r[1][1][0],t=1,n,i;if(e.byteLength===Mn*2+1)return n=_(e.subarray(t,t+Mn),"base64url"),i=_(e.subarray(t+Mn),"base64url"),new Dt({...Ja,key_ops:["verify"],x:n,y:i});if(e.byteLength===Fn*2+1)return n=_(e.subarray(t,t+Fn),"base64url"),i=_(e.subarray(t+Fn),"base64url"),new Dt({...eu,key_ops:["verify"],x:n,y:i});if(e.byteLength===qn*2+1)return n=_(e.subarray(t,t+qn),"base64url"),i=_(e.subarray(t+qn),"base64url"),new Dt({...tu,key_ops:["verify"],x:n,y:i});throw new Te(`coordinates were wrong length, got ${e.byteLength}, expected 65, 97 or 133`)}function $o(r){return Ar([qo(Uint8Array.from([1])),Ar([ru(r.crv)],160),Ar([Vo(new pe(Uint8Array.from([4]),be(r.x??"","base64url"),be(r.y??"","base64url")))],161)]).subarray()}function ru(r){if(r==="P-256")return Za;if(r==="P-384")return Xa;if(r==="P-521")return Qa;throw new Te(`Invalid curve ${r}`)}var Dt=class{type="ECDSA";jwk;_raw;constructor(e){this.jwk=e}get raw(){return this._raw==null&&(this._raw=$o(this.jwk)),this._raw}toMultihash(){return Be.digest(kt(this))}toCID(){return z.createV1(114,this.toMultihash())}toString(){return F.encode(this.toMultihash().bytes).substring(1)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:le(this.raw,e.raw)}async verify(e,t){return Ho(this.jwk,t,e)}};var Sr=Lt(ne("crypto"),1);var Fh=Sr.default.generateKeyPairSync,rr=32;var nu=64;function Go(r,e,t){if(r.byteLength!==rr)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!==nu)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=Sr.default.createPublicKey({format:"jwk",key:{crv:"Ed25519",x:_(r,"base64url"),kty:"OKP"}});return Sr.default.verify(null,t instanceof Uint8Array?t:t.subarray(),n,e)}var Br=class{type="Ed25519";raw;constructor(e){this.raw=Vn(e,rr)}toMultihash(){return Be.digest(kt(this))}toCID(){return z.createV1(114,this.toMultihash())}toString(){return F.encode(this.toMultihash().bytes).substring(1)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:le(this.raw,e.raw)}verify(e,t){return Go(this.raw,t,e)}};function Wo(r){return r=Vn(r,rr),new Br(r)}function Vn(r,e){if(r=Uint8Array.from(r??[]),r.length!==e)throw new Te(`Key must be a Uint8Array of length ${e}, got ${r.length}`);return r}var ou=Math.pow(2,7),su=Math.pow(2,14),cu=Math.pow(2,21),Hn=Math.pow(2,28),zn=Math.pow(2,35),jn=Math.pow(2,42),$n=Math.pow(2,49),k=128,Z=127;function oe(r){if(r<ou)return 1;if(r<su)return 2;if(r<cu)return 3;if(r<Hn)return 4;if(r<zn)return 5;if(r<jn)return 6;if(r<$n)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function Gn(r,e,t=0){switch(oe(r)){case 8:e[t++]=r&255|k,r/=128;case 7:e[t++]=r&255|k,r/=128;case 6:e[t++]=r&255|k,r/=128;case 5:e[t++]=r&255|k,r/=128;case 4:e[t++]=r&255|k,r>>>=7;case 3:e[t++]=r&255|k,r>>>=7;case 2:e[t++]=r&255|k,r>>>=7;case 1:{e[t++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return e}function au(r,e,t=0){switch(oe(r)){case 8:e.set(t++,r&255|k),r/=128;case 7:e.set(t++,r&255|k),r/=128;case 6:e.set(t++,r&255|k),r/=128;case 5:e.set(t++,r&255|k),r/=128;case 4:e.set(t++,r&255|k),r>>>=7;case 3:e.set(t++,r&255|k),r>>>=7;case 2:e.set(t++,r&255|k),r>>>=7;case 1:{e.set(t++,r&255),r>>>=7;break}default:throw new Error("unreachable")}return e}function Yn(r,e){let t=r[e],n=0;if(n+=t&Z,t<k||(t=r[e+1],n+=(t&Z)<<7,t<k)||(t=r[e+2],n+=(t&Z)<<14,t<k)||(t=r[e+3],n+=(t&Z)<<21,t<k)||(t=r[e+4],n+=(t&Z)*Hn,t<k)||(t=r[e+5],n+=(t&Z)*zn,t<k)||(t=r[e+6],n+=(t&Z)*jn,t<k)||(t=r[e+7],n+=(t&Z)*$n,t<k))return n;throw new RangeError("Could not decode varint")}function uu(r,e){let t=r.get(e),n=0;if(n+=t&Z,t<k||(t=r.get(e+1),n+=(t&Z)<<7,t<k)||(t=r.get(e+2),n+=(t&Z)<<14,t<k)||(t=r.get(e+3),n+=(t&Z)<<21,t<k)||(t=r.get(e+4),n+=(t&Z)*Hn,t<k)||(t=r.get(e+5),n+=(t&Z)*zn,t<k)||(t=r.get(e+6),n+=(t&Z)*jn,t<k)||(t=r.get(e+7),n+=(t&Z)*$n,t<k))return n;throw new RangeError("Could not decode varint")}function _t(r,e,t=0){return e==null&&(e=xe(oe(r))),e instanceof Uint8Array?Gn(r,e,t):au(r,e,t)}function gt(r,e=0){return r instanceof Uint8Array?Yn(r,e):uu(r,e)}var Wn=new Float32Array([-0]),ot=new Uint8Array(Wn.buffer);function Xo(r,e,t){Wn[0]=r,e[t]=ot[0],e[t+1]=ot[1],e[t+2]=ot[2],e[t+3]=ot[3]}function Qo(r,e){return ot[0]=r[e],ot[1]=r[e+1],ot[2]=r[e+2],ot[3]=r[e+3],Wn[0]}var Zn=new Float64Array([-0]),X=new Uint8Array(Zn.buffer);function Jo(r,e,t){Zn[0]=r,e[t]=X[0],e[t+1]=X[1],e[t+2]=X[2],e[t+3]=X[3],e[t+4]=X[4],e[t+5]=X[5],e[t+6]=X[6],e[t+7]=X[7]}function es(r,e){return X[0]=r[e],X[1]=r[e+1],X[2]=r[e+2],X[3]=r[e+3],X[4]=r[e+4],X[5]=r[e+5],X[6]=r[e+6],X[7]=r[e+7],Zn[0]}var du=BigInt(Number.MAX_SAFE_INTEGER),lu=BigInt(Number.MIN_SAFE_INTEGER),fe=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<du&&e>lu)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>ts&&(i=0n,++n>ts&&(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 fe(0,0);mt.toBigInt=function(){return 0n};mt.zzEncode=mt.zzDecode=function(){return this};mt.length=function(){return 1};var ts=4294967296n;function rs(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 ns(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 Xn(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 Ue(r,e){return RangeError(`index out of range: ${r.pos} + ${e??1} > ${r.len}`)}function Ur(r,e){return(r[e-4]|r[e-3]<<8|r[e-2]<<16|r[e-1]<<24)>>>0}var Qn=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,Ue(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 Ue(this,4);return Ur(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw Ue(this,4);return Ur(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw Ue(this,4);let e=Qo(this.buf,this.pos);return this.pos+=4,e}double(){if(this.pos+8>this.len)throw Ue(this,4);let e=es(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 Ue(this,e);return this.pos+=e,t===n?new Uint8Array(0):this.buf.subarray(t,n)}string(){let e=this.bytes();return ns(e,0,e.length)}skip(e){if(typeof e=="number"){if(this.pos+e>this.len)throw Ue(this,e);this.pos+=e}else do if(this.pos>=this.len)throw Ue(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 fe(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 Ue(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 Ue(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 Ue(this,8);let e=Ur(this.buf,this.pos+=4),t=Ur(this.buf,this.pos+=4);return new fe(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=Yn(this.buf,this.pos);return this.pos+=oe(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 Jn(r){return new Qn(r instanceof Uint8Array?r:r.subarray())}function Lr(r,e,t){let n=Jn(r);return e.decode(n,void 0,t)}function ei(r){let e=r??8192,t=e>>>1,n,i=e;return function(s){if(s<1||s>t)return xe(s);i+s>e&&(n=xe(e),i=0);let a=n.subarray(i,i+=s);return(i&7)!==0&&(i=(i|7)+1),a}}var yt=class{fn;len;next;val;constructor(e,t,n){this.fn=e,this.len=t,this.next=void 0,this.val=n}};function ti(){}var ni=class{head;tail;len;next;constructor(e){this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}},hu=ei();function pu(r){return globalThis.Buffer!=null?xe(r):hu(r)}var ir=class{len;head;tail;states;constructor(){this.len=0,this.head=new yt(ti,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 ii((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(Cr,10,fe.fromNumber(e)):this.uint32(e)}sint32(e){return this.uint32((e<<1^e>>31)>>>0)}uint64(e){let t=fe.fromBigInt(e);return this._push(Cr,t.length(),t)}uint64Number(e){return this._push(Gn,oe(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=fe.fromBigInt(e).zzEncode();return this._push(Cr,t.length(),t)}sint64Number(e){let t=fe.fromNumber(e).zzEncode();return this._push(Cr,t.length(),t)}sint64String(e){return this.sint64(BigInt(e))}bool(e){return this._push(ri,1,e?1:0)}fixed32(e){return this._push(nr,4,e>>>0)}sfixed32(e){return this.fixed32(e)}fixed64(e){let t=fe.fromBigInt(e);return this._push(nr,4,t.lo)._push(nr,4,t.hi)}fixed64Number(e){let t=fe.fromNumber(e);return this._push(nr,4,t.lo)._push(nr,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(Xo,4,e)}double(e){return this._push(Jo,8,e)}bytes(e){let t=e.length>>>0;return t===0?this._push(ri,1,0):this.uint32(t)._push(gu,t,e)}string(e){let t=rs(e);return t!==0?this.uint32(t)._push(Xn,t,e):this._push(ri,1,0)}fork(){return this.states=new ni(this),this.head=this.tail=new yt(ti,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(ti,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=pu(this.len),n=0;for(;e!=null;)e.fn(e.val,t,n),n+=e.len,e=e.next;return t}};function ri(r,e,t){e[t]=r&255}function fu(r,e,t){for(;r>127;)e[t++]=r&127|128,r>>>=7;e[t]=r}var ii=class extends yt{next;constructor(e,t){super(fu,e,t),this.next=void 0}};function Cr(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 nr(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 gu(r,e,t){e.set(r,t)}globalThis.Buffer!=null&&(ir.prototype.bytes=function(r){let e=r.length>>>0;return this.uint32(e),e>0&&this._push(mu,e,r),this},ir.prototype.string=function(r){let e=globalThis.Buffer.byteLength(r);return this.uint32(e),e>0&&this._push(yu,e,r),this});function mu(r,e,t){e.set(r,t)}function yu(r,e,t){r.length<40?Xn(r,e,t):e.utf8Write!=null?e.utf8Write(r,t):e.set(be(r),t)}function oi(){return new ir}function Tr(r,e){let t=oi();return e.encode(r,t,{lengthDelimited:!1}),t.finish()}var Rt;(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"})(Rt||(Rt={}));function Pr(r,e,t,n){return{name:r,type:e,encode:t,decode:n}}function si(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 Pr("enum",Rt.VARINT,t,n)}function Or(r,e){return Pr("message",Rt.LENGTH_DELIMITED,r,e)}var ge;(function(r){r.RSA="RSA",r.Ed25519="Ed25519",r.secp256k1="secp256k1",r.ECDSA="ECDSA"})(ge||(ge={}));var ci;(function(r){r[r.RSA=0]="RSA",r[r.Ed25519=1]="Ed25519",r[r.secp256k1=2]="secp256k1",r[r.ECDSA=3]="ECDSA"})(ci||(ci={}));(function(r){r.codec=()=>si(ci)})(ge||(ge={}));var or;(function(r){let e;r.codec=()=>(e==null&&(e=Or((t,n,i={})=>{i.lengthDelimited!==!1&&n.fork(),t.Type!=null&&(n.uint32(8),ge.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=ge.codec().decode(t);break}case 2:{o.Data=t.bytes();break}default:{t.skipType(a&7);break}}}return o})),e),r.encode=t=>Tr(t,r.codec()),r.decode=(t,n)=>Lr(t,r.codec(),n)})(or||(or={}));var ai;(function(r){let e;r.codec=()=>(e==null&&(e=Or((t,n,i={})=>{i.lengthDelimited!==!1&&n.fork(),t.Type!=null&&(n.uint32(8),ge.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=ge.codec().decode(t);break}case 2:{o.Data=t.bytes();break}default:{t.skipType(a&7);break}}}return o})),e),r.encode=t=>Tr(t,r.codec()),r.decode=(t,n)=>Lr(t,r.codec(),n)})(ai||(ai={}));var Xe=Lt(ne("node:crypto"),1),wt=Xe&&typeof Xe=="object"&&"webcrypto"in Xe?Xe.webcrypto:Xe&&typeof Xe=="object"&&"randomBytes"in Xe?Xe:void 0;function os(r){if(!Number.isSafeInteger(r)||r<0)throw new Error("positive integer expected, got "+r)}function xu(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function Kt(r,...e){if(!xu(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 ss(r){if(typeof r!="function"||typeof r.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");os(r.outputLen),os(r.blockLen)}function Mt(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 cs(r,e){Kt(r);let t=e.outputLen;if(r.length<t)throw new Error("digestInto() expects output buffer of length at least "+t)}function Nr(r){return new DataView(r.buffer,r.byteOffset,r.byteLength)}function Le(r,e){return r<<32-e|r>>>e}var Mp=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function";function bu(r){if(typeof r!="string")throw new Error("utf8ToBytes expected string, got "+typeof r);return new Uint8Array(new TextEncoder().encode(r))}function sr(r){return typeof r=="string"&&(r=bu(r)),Kt(r),r}function as(...r){let e=0;for(let n=0;n<r.length;n++){let i=r[n];Kt(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{clone(){return this._cloneInto()}};function us(r){let e=n=>r().update(sr(n)).digest(),t=r();return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=()=>r(),e}function ds(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 Eu(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 ls(r,e,t){return r&e^~r&t}function hs(r,e,t){return r&e^r&t^e&t}var Dr=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=Nr(this.buffer)}update(e){Mt(this);let{view:t,buffer:n,blockLen:i}=this;e=sr(e);let o=e.length;for(let s=0;s<o;){let a=Math.min(i-this.pos,o-s);if(a===i){let c=Nr(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){Mt(this),cs(e,this),this.finished=!0;let{buffer:t,view:n,blockLen:i,isLE:o}=this,{pos:s}=this;t[s++]=128,this.buffer.subarray(s).fill(0),this.padOffset>i-s&&(this.process(n,0),s=0);for(let d=s;d<i;d++)t[d]=0;Eu(n,i-8,BigInt(this.length*8),o),this.process(n,0);let a=Nr(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.length=i,e.pos=a,e.finished=o,e.destroyed=s,i%t&&e.buffer.set(n),e}};var Iu=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),st=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),ct=new Uint32Array(64),ui=class extends Dr{constructor(e=32){super(64,e,8,!1),this.A=st[0]|0,this.B=st[1]|0,this.C=st[2]|0,this.D=st[3]|0,this.E=st[4]|0,this.F=st[5]|0,this.G=st[6]|0,this.H=st[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)ct[d]=e.getUint32(t,!1);for(let d=16;d<64;d++){let l=ct[d-15],p=ct[d-2],h=Le(l,7)^Le(l,18)^l>>>3,m=Le(p,17)^Le(p,19)^p>>>10;ct[d]=m+ct[d-7]+h+ct[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=Le(a,6)^Le(a,11)^Le(a,25),p=f+l+ls(a,c,u)+Iu[d]+ct[d]|0,m=(Le(n,2)^Le(n,13)^Le(n,22))+hs(n,i,o)|0;f=u,u=c,c=a,a=s+p|0,s=o,o=i,i=n,n=p+m|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(){ct.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var di=us(()=>new ui);var _s=Lt(ne("node:crypto"),1);var kr=class extends Ft{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,ss(e);let n=sr(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),o.fill(0)}update(e){return Mt(this),this.iHash.update(e),this}digestInto(e){Mt(this),Kt(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}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},li=(r,e,t)=>new kr(r,e).update(t).digest();li.create=(r,e)=>new kr(r,e);var gi=BigInt(0),fi=BigInt(1);function xt(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function mi(r){if(!xt(r))throw new Error("Uint8Array expected")}function qt(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 gs(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return r===""?gi:BigInt("0x"+r)}var ms=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",vu=Array.from({length:256},(r,e)=>e.toString(16).padStart(2,"0"));function Vt(r){if(mi(r),ms)return r.toHex();let e="";for(let t=0;t<r.length;t++)e+=vu[r[t]];return e}var Qe={_0:48,_9:57,A:65,F:70,a:97,f:102};function ps(r){if(r>=Qe._0&&r<=Qe._9)return r-Qe._0;if(r>=Qe.A&&r<=Qe.F)return r-(Qe.A-10);if(r>=Qe.a&&r<=Qe.f)return r-(Qe.a-10)}function ar(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);if(ms)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=ps(r.charCodeAt(o)),a=ps(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 Je(r){return gs(Vt(r))}function yi(r){return mi(r),gs(Vt(Uint8Array.from(r).reverse()))}function bt(r,e){return ar(r.toString(16).padStart(e*2,"0"))}function wi(r,e){return bt(r,e).reverse()}function me(r,e,t){let n;if(typeof e=="string")try{n=ar(e)}catch(o){throw new Error(r+" must be hex string or Uint8Array, cause: "+o)}else if(xt(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 ur(...r){let e=0;for(let n=0;n<r.length;n++){let i=r[n];mi(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 hi=r=>typeof r=="bigint"&&gi<=r;function _r(r,e,t){return hi(r)&&hi(e)&&hi(t)&&e<=r&&r<t}function Et(r,e,t,n){if(!_r(e,t,n))throw new Error("expected valid "+r+": "+t+" <= n < "+n+", got "+e)}function ys(r){let e;for(e=0;r>gi;r>>=fi,e+=1);return e}var It=r=>(fi<<BigInt(r))-fi,pi=r=>new Uint8Array(r),fs=r=>Uint8Array.from(r);function ws(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=pi(r),i=pi(r),o=0,s=()=>{n.fill(1),i.fill(0),o=0},a=(...d)=>t(i,n,...d),c=(d=pi(0))=>{i=a(fs([0]),d),n=a(),d.length!==0&&(i=a(fs([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 ur(...l)};return(d,l)=>{s(),c(d);let p;for(;!(p=l(u()));)c();return s(),p}}var Au={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"||xt(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 vt(r,e,t={}){let n=(i,o,s)=>{let a=Au[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 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 j=BigInt(0),V=BigInt(1),At=BigInt(2),Su=BigInt(3),bi=BigInt(4),xs=BigInt(5),bs=BigInt(8),Bu=BigInt(9),Uu=BigInt(16);function Q(r,e){let t=r%e;return t>=j?t:e+t}function Lu(r,e,t){if(e<j)throw new Error("invalid exponent, negatives unsupported");if(t<=j)throw new Error("invalid modulus");if(t===V)return j;let n=V;for(;e>j;)e&V&&(n=n*r%t),r=r*r%t,e>>=V;return n}function ye(r,e,t){let n=r;for(;e-- >j;)n*=n,n%=t;return n}function Rr(r,e){if(r===j)throw new Error("invert: expected non-zero number");if(e<=j)throw new Error("invert: expected positive modulus, got "+e);let t=Q(r,e),n=e,i=j,o=V,s=V,a=j;for(;t!==j;){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!==V)throw new Error("invert: does not exist");return Q(i,e)}function Cu(r){let e=(r-V)/At,t,n,i;for(t=r-V,n=0;t%At===j;t/=At,n++);for(i=At;i<r&&Lu(i,e,r)!==r-V;i++)if(i>1e3)throw new Error("Cannot find square root: likely non-prime P");if(n===1){let s=(r+V)/bi;return function(c,u){let f=c.pow(u,s);if(!c.eql(c.sqr(f),u))throw new Error("Cannot find square root");return f}}let o=(t+V)/At;return function(a,c){if(a.pow(c,e)===a.neg(a.ONE))throw new Error("Cannot find square root");let u=n,f=a.pow(a.mul(a.ONE,i),t),d=a.pow(c,o),l=a.pow(c,t);for(;!a.eql(l,a.ONE);){if(a.eql(l,a.ZERO))return a.ZERO;let p=1;for(let m=a.sqr(l);p<u&&!a.eql(m,a.ONE);p++)m=a.sqr(m);let h=a.pow(f,V<<BigInt(u-p-1));f=a.sqr(h),d=a.mul(d,h),l=a.mul(l,f),u=p}return d}}function Tu(r){if(r%bi===Su){let e=(r+V)/bi;return function(n,i){let o=n.pow(i,e);if(!n.eql(n.sqr(o),i))throw new Error("Cannot find square root");return o}}if(r%bs===xs){let e=(r-xs)/bs;return function(n,i){let o=n.mul(i,At),s=n.pow(o,e),a=n.mul(i,s),c=n.mul(n.mul(a,At),s),u=n.mul(a,n.sub(c,n.ONE));if(!n.eql(n.sqr(u),i))throw new Error("Cannot find square root");return u}}return r%Uu,Cu(r)}var Pu=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Ei(r){let e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},t=Pu.reduce((n,i)=>(n[i]="function",n),e);return vt(r,t)}function Ou(r,e,t){if(t<j)throw new Error("invalid exponent, negatives unsupported");if(t===j)return r.ONE;if(t===V)return e;let n=r.ONE,i=e;for(;t>j;)t&V&&(n=r.mul(n,i)),i=r.sqr(i),t>>=V;return n}function Nu(r,e){let t=new Array(e.length),n=e.reduce((o,s,a)=>r.is0(s)?o:(t[a]=o,r.mul(o,s)),r.ONE),i=r.inv(n);return e.reduceRight((o,s,a)=>r.is0(s)?o:(t[a]=r.mul(o,t[a]),r.mul(o,s)),i),t}function Ii(r,e){let t=e!==void 0?e:r.toString(2).length,n=Math.ceil(t/8);return{nBitLength:t,nByteLength:n}}function Kr(r,e,t=!1,n={}){if(r<=j)throw new Error("invalid field: expected ORDER > 0, got "+r);let{nBitLength:i,nByteLength:o}=Ii(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:It(i),ZERO:j,ONE:V,create:c=>Q(c,r),isValid:c=>{if(typeof c!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof c);return j<=c&&c<r},is0:c=>c===j,isOdd:c=>(c&V)===V,neg:c=>Q(-c,r),eql:(c,u)=>c===u,sqr:c=>Q(c*c,r),add:(c,u)=>Q(c+u,r),sub:(c,u)=>Q(c-u,r),mul:(c,u)=>Q(c*u,r),pow:(c,u)=>Ou(a,c,u),div:(c,u)=>Q(c*Rr(u,r),r),sqrN:c=>c*c,addN:(c,u)=>c+u,subN:(c,u)=>c-u,mulN:(c,u)=>c*u,inv:c=>Rr(c,r),sqrt:n.sqrt||(c=>(s||(s=Tu(r)),s(a,c))),invertBatch:c=>Nu(a,c),cmov:(c,u,f)=>f?u:c,toBytes:c=>t?wi(c,o):bt(c,o),fromBytes:c=>{if(c.length!==o)throw new Error("Field.fromBytes: expected "+o+" bytes, got "+c.length);return t?yi(c):Je(c)}});return Object.freeze(a)}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 vi(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=vi(e);if(n<16||n<o||n>1024)throw new Error("expected "+o+"-1024 bytes of input, got "+n);let s=t?yi(r):Je(r),a=Q(s,e-V)+V;return t?wi(a,i):bt(a,i)}var vs=BigInt(0),Li=BigInt(1);function Ai(r,e){let t=e.negate();return r?t:e}function Ss(r,e){if(!Number.isSafeInteger(r)||r<=0||r>e)throw new Error("invalid window size, expected [1.."+e+"], got W="+r)}function Si(r,e){Ss(r,e);let t=Math.ceil(e/r)+1,n=2**(r-1),i=2**r,o=It(r),s=BigInt(r);return{windows:t,windowSize:n,mask:o,maxNumber:i,shiftBy:s}}function As(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+=Li);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 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 ku(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 Bi=new WeakMap,Bs=new WeakMap;function Ui(r){return Bs.get(r)||1}function Us(r,e){return{constTimeNegate:Ai,hasPrecomputes(t){return Ui(t)!==1},unsafeLadder(t,n,i=r.ZERO){let o=t;for(;n>vs;)n&Li&&(i=i.add(o)),o=o.double(),n>>=Li;return i},precomputeWindow(t,n){let{windows:i,windowSize:o}=Si(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=Si(t,e);for(let c=0;c<a.windows;c++){let{nextN:u,offset:f,isZero:d,isNeg:l,isNegF:p,offsetF:h}=As(i,c,a);i=u,d?s=s.add(Ai(p,n[h])):o=o.add(Ai(l,n[f]))}return{p:o,f:s}},wNAFUnsafe(t,n,i,o=r.ZERO){let s=Si(t,e);for(let a=0;a<s.windows&&i!==vs;a++){let{nextN:c,offset:u,isZero:f,isNeg:d}=As(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=Bi.get(n);return o||(o=this.precomputeWindow(n,t),t!==1&&Bi.set(n,i(o))),o},wNAFCached(t,n,i){let o=Ui(t);return this.wNAF(o,this.getPrecomputes(o,t,i),n)},wNAFCachedUnsafe(t,n,i,o){let s=Ui(t);return s===1?this.unsafeLadder(t,n,o):this.wNAFUnsafe(s,this.getPrecomputes(s,t,i),n,o)},setWindowSize(t,n){Ss(n,e),Bs.set(t,n),Bi.delete(t)}}}function Ls(r,e,t,n){if(Du(t,r),ku(n,e),t.length!==n.length)throw new Error("arrays of points and scalars must have equal length");let i=r.ZERO,o=ys(BigInt(t.length)),s=o>12?o-3:o>4?o-2:o?2:1,a=It(s),c=new Array(Number(a)+1).fill(i),u=Math.floor((e.BITS-1)/s)*s,f=i;for(let d=u;d>=0;d-=s){c.fill(i);for(let p=0;p<n.length;p++){let h=n[p],m=Number(h>>BigInt(d)&a);c[m]=c[m].add(t[p])}let l=i;for(let p=c.length-1,h=i;p>0;p--)h=h.add(c[p]),l=l.add(h);if(f=f.add(l),d!==0)for(let p=0;p<s;p++)f=f.double()}return f}function Ci(r){return Ei(r.Fp),vt(r,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Ii(r.n,r.nBitLength),...r,p:r.Fp.ORDER})}function Cs(r){r.lowS!==void 0&&qt("lowS",r.lowS),r.prehash!==void 0&&qt("prehash",r.prehash)}function _u(r){let e=Ci(r);vt(e,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});let{endo:t,Fp:n,a:i}=e;if(t){if(!n.eql(i,n.ZERO))throw new Error("invalid endomorphism, can only be defined for Koblitz curves that have a=0");if(typeof t!="object"||typeof t.beta!="bigint"||typeof t.splitScalar!="function")throw new Error("invalid endomorphism, expected beta: bigint and splitScalar: function")}return Object.freeze({...e})}var Ti=class extends Error{constructor(e=""){super(e)}},et={Err:Ti,_tlv:{encode:(r,e)=>{let{Err:t}=et;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}=et,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}=et;if(r<tt)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}=et;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 Je(r)}},toSig(r){let{Err:e,_int:t,_tlv:n}=et,i=me("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}=et,n=e.encode(2,t.encode(r.r)),i=e.encode(2,t.encode(r.s)),o=n+i;return e.encode(48,o)}},tt=BigInt(0),G=BigInt(1),a0=BigInt(2),Ts=BigInt(3),u0=BigInt(4);function Ru(r){let e=_u(r),{Fp:t}=e,n=Kr(e.n,e.nBitLength),i=e.toBytes||((m,g,y)=>{let x=g.toAffine();return ur(Uint8Array.from([4]),t.toBytes(x.x),t.toBytes(x.y))}),o=e.fromBytes||(m=>{let g=m.subarray(1),y=t.fromBytes(g.subarray(0,t.BYTES)),x=t.fromBytes(g.subarray(t.BYTES,2*t.BYTES));return{x:y,y:x}});function s(m){let{a:g,b:y}=e,x=t.sqr(m),E=t.mul(x,m);return t.add(t.add(E,t.mul(m,g)),y)}if(!t.eql(t.sqr(e.Gy),s(e.Gx)))throw new Error("bad generator point: equation left != right");function a(m){return _r(m,G,e.n)}function c(m){let{allowedPrivateKeyLengths:g,nByteLength:y,wrapPrivateKey:x,n:E}=e;if(g&&typeof m!="bigint"){if(xt(m)&&(m=Vt(m)),typeof m!="string"||!g.includes(m.length))throw new Error("invalid private key");m=m.padStart(y*2,"0")}let L;try{L=typeof m=="bigint"?m:Je(me("private key",m,y))}catch{throw new Error("invalid private key, expected hex or "+y+" bytes, got "+typeof m)}return x&&(L=Q(L,E)),Et("private key",L,G,E),L}function u(m){if(!(m instanceof l))throw new Error("ProjectivePoint expected")}let f=xi((m,g)=>{let{px:y,py:x,pz:E}=m;if(t.eql(E,t.ONE))return{x:y,y:x};let L=m.is0();g==null&&(g=L?t.ONE:t.inv(E));let C=t.mul(y,g),B=t.mul(x,g),U=t.mul(E,g);if(L)return{x:t.ZERO,y:t.ZERO};if(!t.eql(U,t.ONE))throw new Error("invZ was invalid");return{x:C,y:B}}),d=xi(m=>{if(m.is0()){if(e.allowInfinityPoint&&!t.is0(m.py))return;throw new Error("bad point: ZERO")}let{x:g,y}=m.toAffine();if(!t.isValid(g)||!t.isValid(y))throw new Error("bad point: x or y not FE");let x=t.sqr(y),E=s(g);if(!t.eql(x,E))throw new Error("bad point: equation left != right");if(!m.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class l{constructor(g,y,x){if(g==null||!t.isValid(g))throw new Error("x required");if(y==null||!t.isValid(y))throw new Error("y required");if(x==null||!t.isValid(x))throw new Error("z required");this.px=g,this.py=y,this.pz=x,Object.freeze(this)}static fromAffine(g){let{x:y,y:x}=g||{};if(!g||!t.isValid(y)||!t.isValid(x))throw new Error("invalid affine point");if(g instanceof l)throw new Error("projective point not allowed");let E=L=>t.eql(L,t.ZERO);return E(y)&&E(x)?l.ZERO:new l(y,x,t.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(g){let y=t.invertBatch(g.map(x=>x.pz));return g.map((x,E)=>x.toAffine(y[E])).map(l.fromAffine)}static fromHex(g){let y=l.fromAffine(o(me("pointHex",g)));return y.assertValidity(),y}static fromPrivateKey(g){return l.BASE.multiply(c(g))}static msm(g,y){return Ls(l,n,g,y)}_setWindowSize(g){h.setWindowSize(this,g)}assertValidity(){d(this)}hasEvenY(){let{y:g}=this.toAffine();if(t.isOdd)return!t.isOdd(g);throw new Error("Field doesn't support isOdd")}equals(g){u(g);let{px:y,py:x,pz:E}=this,{px:L,py:C,pz:B}=g,U=t.eql(t.mul(y,B),t.mul(L,E)),T=t.eql(t.mul(x,B),t.mul(C,E));return U&&T}negate(){return new l(this.px,t.neg(this.py),this.pz)}double(){let{a:g,b:y}=e,x=t.mul(y,Ts),{px:E,py:L,pz:C}=this,B=t.ZERO,U=t.ZERO,T=t.ZERO,P=t.mul(E,E),Y=t.mul(L,L),M=t.mul(C,C),K=t.mul(E,L);return K=t.add(K,K),T=t.mul(E,C),T=t.add(T,T),B=t.mul(g,T),U=t.mul(x,M),U=t.add(B,U),B=t.sub(Y,U),U=t.add(Y,U),U=t.mul(B,U),B=t.mul(K,B),T=t.mul(x,T),M=t.mul(g,M),K=t.sub(P,M),K=t.mul(g,K),K=t.add(K,T),T=t.add(P,P),P=t.add(T,P),P=t.add(P,M),P=t.mul(P,K),U=t.add(U,P),M=t.mul(L,C),M=t.add(M,M),P=t.mul(M,K),B=t.sub(B,P),T=t.mul(M,Y),T=t.add(T,T),T=t.add(T,T),new l(B,U,T)}add(g){u(g);let{px:y,py:x,pz:E}=this,{px:L,py:C,pz:B}=g,U=t.ZERO,T=t.ZERO,P=t.ZERO,Y=e.a,M=t.mul(e.b,Ts),K=t.mul(y,L),se=t.mul(x,C),b=t.mul(E,B),I=t.add(y,x),v=t.add(L,C);I=t.mul(I,v),v=t.add(K,se),I=t.sub(I,v),v=t.add(y,E);let N=t.add(L,B);return v=t.mul(v,N),N=t.add(K,b),v=t.sub(v,N),N=t.add(x,E),U=t.add(C,B),N=t.mul(N,U),U=t.add(se,b),N=t.sub(N,U),P=t.mul(Y,v),U=t.mul(M,b),P=t.add(U,P),U=t.sub(se,P),P=t.add(se,P),T=t.mul(U,P),se=t.add(K,K),se=t.add(se,K),b=t.mul(Y,b),v=t.mul(M,v),se=t.add(se,b),b=t.sub(K,b),b=t.mul(Y,b),v=t.add(v,b),K=t.mul(se,v),T=t.add(T,K),K=t.mul(N,v),U=t.mul(I,U),U=t.sub(U,K),K=t.mul(I,se),P=t.mul(N,P),P=t.add(P,K),new l(U,T,P)}subtract(g){return this.add(g.negate())}is0(){return this.equals(l.ZERO)}wNAF(g){return h.wNAFCached(this,g,l.normalizeZ)}multiplyUnsafe(g){let{endo:y,n:x}=e;Et("scalar",g,tt,x);let E=l.ZERO;if(g===tt)return E;if(this.is0()||g===G)return this;if(!y||h.hasPrecomputes(this))return h.wNAFCachedUnsafe(this,g,l.normalizeZ);let{k1neg:L,k1:C,k2neg:B,k2:U}=y.splitScalar(g),T=E,P=E,Y=this;for(;C>tt||U>tt;)C&G&&(T=T.add(Y)),U&G&&(P=P.add(Y)),Y=Y.double(),C>>=G,U>>=G;return L&&(T=T.negate()),B&&(P=P.negate()),P=new l(t.mul(P.px,y.beta),P.py,P.pz),T.add(P)}multiply(g){let{endo:y,n:x}=e;Et("scalar",g,G,x);let E,L;if(y){let{k1neg:C,k1:B,k2neg:U,k2:T}=y.splitScalar(g),{p:P,f:Y}=this.wNAF(B),{p:M,f:K}=this.wNAF(T);P=h.constTimeNegate(C,P),M=h.constTimeNegate(U,M),M=new l(t.mul(M.px,y.beta),M.py,M.pz),E=P.add(M),L=Y.add(K)}else{let{p:C,f:B}=this.wNAF(g);E=C,L=B}return l.normalizeZ([E,L])[0]}multiplyAndAddUnsafe(g,y,x){let E=l.BASE,L=(B,U)=>U===tt||U===G||!B.equals(E)?B.multiplyUnsafe(U):B.multiply(U),C=L(this,y).add(L(g,x));return C.is0()?void 0:C}toAffine(g){return f(this,g)}isTorsionFree(){let{h:g,isTorsionFree:y}=e;if(g===G)return!0;if(y)return y(l,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h:g,clearCofactor:y}=e;return g===G?this:y?y(l,this):this.multiplyUnsafe(e.h)}toRawBytes(g=!0){return qt("isCompressed",g),this.assertValidity(),i(l,this,g)}toHex(g=!0){return qt("isCompressed",g),Vt(this.toRawBytes(g))}}l.BASE=new l(e.Gx,e.Gy,t.ONE),l.ZERO=new l(t.ZERO,t.ONE,t.ZERO);let p=e.nBitLength,h=Us(l,e.endo?Math.ceil(p/2):p);return{CURVE:e,ProjectivePoint:l,normPrivateKeyToScalar:c,weierstrassEquation:s,isWithinCurveOrder:a}}function Ku(r){let e=Ci(r);return vt(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function Ps(r){let e=Ku(r),{Fp:t,n}=e,i=t.BYTES+1,o=2*t.BYTES+1;function s(b){return Q(b,n)}function a(b){return Rr(b,n)}let{ProjectivePoint:c,normPrivateKeyToScalar:u,weierstrassEquation:f,isWithinCurveOrder:d}=Ru({...e,toBytes(b,I,v){let N=I.toAffine(),D=t.toBytes(N.x),H=ur;return qt("isCompressed",v),v?H(Uint8Array.from([I.hasEvenY()?2:3]),D):H(Uint8Array.from([4]),D,t.toBytes(N.y))},fromBytes(b){let I=b.length,v=b[0],N=b.subarray(1);if(I===i&&(v===2||v===3)){let D=Je(N);if(!_r(D,G,t.ORDER))throw new Error("Point is not on curve");let H=f(D),te;try{te=t.sqrt(H)}catch(Ie){let re=Ie instanceof Error?": "+Ie.message:"";throw new Error("Point is not on curve"+re)}let J=(te&G)===G;return(v&1)===1!==J&&(te=t.neg(te)),{x:D,y:te}}else if(I===o&&v===4){let D=t.fromBytes(N.subarray(0,t.BYTES)),H=t.fromBytes(N.subarray(t.BYTES,2*t.BYTES));return{x:D,y:H}}else{let D=i,H=o;throw new Error("invalid Point, expected length of "+D+", or uncompressed "+H+", got "+I)}}}),l=b=>Vt(bt(b,e.nByteLength));function p(b){let I=n>>G;return b>I}function h(b){return p(b)?s(-b):b}let m=(b,I,v)=>Je(b.slice(I,v));class g{constructor(I,v,N){Et("r",I,G,n),Et("s",v,G,n),this.r=I,this.s=v,N!=null&&(this.recovery=N),Object.freeze(this)}static fromCompact(I){let v=e.nByteLength;return I=me("compactSignature",I,v*2),new g(m(I,0,v),m(I,v,2*v))}static fromDER(I){let{r:v,s:N}=et.toSig(me("DER",I));return new g(v,N)}assertValidity(){}addRecoveryBit(I){return new g(this.r,this.s,I)}recoverPublicKey(I){let{r:v,s:N,recovery:D}=this,H=B(me("msgHash",I));if(D==null||![0,1,2,3].includes(D))throw new Error("recovery id invalid");let te=D===2||D===3?v+e.n:v;if(te>=t.ORDER)throw new Error("recovery id 2 or 3 invalid");let J=(D&1)===0?"02":"03",Ke=c.fromHex(J+l(te)),Ie=a(te),re=s(-H*Ie),St=s(N*Ie),rt=c.BASE.multiplyAndAddUnsafe(Ke,re,St);if(!rt)throw new Error("point at infinify");return rt.assertValidity(),rt}hasHighS(){return p(this.s)}normalizeS(){return this.hasHighS()?new g(this.r,s(-this.s),this.recovery):this}toDERRawBytes(){return ar(this.toDERHex())}toDERHex(){return et.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return ar(this.toCompactHex())}toCompactHex(){return l(this.r)+l(this.s)}}let y={isValidPrivateKey(b){try{return u(b),!0}catch{return!1}},normPrivateKeyToScalar:u,randomPrivateKey:()=>{let b=vi(e.n);return Is(e.randomBytes(b),e.n)},precompute(b=8,I=c.BASE){return I._setWindowSize(b),I.multiply(BigInt(3)),I}};function x(b,I=!0){return c.fromPrivateKey(b).toRawBytes(I)}function E(b){let I=xt(b),v=typeof b=="string",N=(I||v)&&b.length;return I?N===i||N===o:v?N===2*i||N===2*o:b instanceof c}function L(b,I,v=!0){if(E(b))throw new Error("first arg must be private key");if(!E(I))throw new Error("second arg must be public key");return c.fromHex(I).multiply(u(b)).toRawBytes(v)}let C=e.bits2int||function(b){if(b.length>8192)throw new Error("input is too large");let I=Je(b),v=b.length*8-e.nBitLength;return v>0?I>>BigInt(v):I},B=e.bits2int_modN||function(b){return s(C(b))},U=It(e.nBitLength);function T(b){return Et("num < 2^"+e.nBitLength,b,tt,U),bt(b,e.nByteLength)}function P(b,I,v=Y){if(["recovered","canonical"].some(at=>at in v))throw new Error("sign() legacy options not supported");let{hash:N,randomBytes:D}=e,{lowS:H,prehash:te,extraEntropy:J}=v;H==null&&(H=!0),b=me("msgHash",b),Cs(v),te&&(b=me("prehashed msgHash",N(b)));let Ke=B(b),Ie=u(I),re=[T(Ie),T(Ke)];if(J!=null&&J!==!1){let at=J===!0?D(t.BYTES):J;re.push(me("extraEntropy",at))}let St=ur(...re),rt=Ke;function Zr(at){let Bt=C(at);if(!d(Bt))return;let Xr=a(Bt),jt=c.BASE.multiply(Bt).toAffine(),ut=s(jt.x);if(ut===tt)return;let $t=s(Xr*s(rt+ut*Ie));if($t===tt)return;let Ut=(jt.x===ut?0:2)|Number(jt.y&G),$i=$t;return H&&p($t)&&($i=h($t),Ut^=1),new g(ut,$i,Ut)}return{seed:St,k2sig:Zr}}let Y={lowS:e.lowS,prehash:!1},M={lowS:e.lowS,prehash:!1};function K(b,I,v=Y){let{seed:N,k2sig:D}=P(b,I,v),H=e;return ws(H.hash.outputLen,H.nByteLength,H.hmac)(N,D)}c.BASE._setWindowSize(8);function se(b,I,v,N=M){let D=b;I=me("msgHash",I),v=me("publicKey",v);let{lowS:H,prehash:te,format:J}=N;if(Cs(N),"strict"in N)throw new Error("options.strict was renamed to lowS");if(J!==void 0&&J!=="compact"&&J!=="der")throw new Error("format must be compact or der");let Ke=typeof D=="string"||xt(D),Ie=!Ke&&!J&&typeof D=="object"&&D!==null&&typeof D.r=="bigint"&&typeof D.s=="bigint";if(!Ke&&!Ie)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let re,St;try{if(Ie&&(re=new g(D.r,D.s)),Ke){try{J!=="compact"&&(re=g.fromDER(D))}catch(Ut){if(!(Ut instanceof et.Err))throw Ut}!re&&J!=="der"&&(re=g.fromCompact(D))}St=c.fromHex(v)}catch{return!1}if(!re||H&&re.hasHighS())return!1;te&&(I=e.hash(I));let{r:rt,s:Zr}=re,at=B(I),Bt=a(Zr),Xr=s(at*Bt),jt=s(rt*Bt),ut=c.BASE.multiplyAndAddUnsafe(St,Xr,jt)?.toAffine();return ut?s(ut.x)===rt:!1}return{CURVE:e,getPublicKey:x,getSharedSecret:L,sign:K,verify:se,ProjectivePoint:c,Signature:g,utils:y}}function Mu(r){return{hash:r,hmac:(e,...t)=>li(r,e,as(...t)),randomBytes:ds}}function Os(r,e){let t=n=>Ps({...r,...Mu(n)});return{...t(e),create:t}}var ks=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),Ns=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),Fu=BigInt(1),Pi=BigInt(2),Ds=(r,e)=>(r+e/Pi)/e;function qu(r){let e=ks,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=ye(f,t,e)*f%e,l=ye(d,t,e)*f%e,p=ye(l,Pi,e)*u%e,h=ye(p,i,e)*p%e,m=ye(h,o,e)*h%e,g=ye(m,a,e)*m%e,y=ye(g,c,e)*g%e,x=ye(y,a,e)*m%e,E=ye(x,t,e)*f%e,L=ye(E,s,e)*h%e,C=ye(L,n,e)*u%e,B=ye(C,Pi,e);if(!Oi.eql(Oi.sqr(B),r))throw new Error("Cannot find square root");return B}var Oi=Kr(ks,void 0,void 0,{sqrt:qu}),Ht=Os({a:BigInt(0),b:BigInt(7),Fp:Oi,n:Ns,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:r=>{let e=Ns,t=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-Fu*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),i=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),o=t,s=BigInt("0x100000000000000000000000000000000"),a=Ds(o*r,e),c=Ds(-n*r,e),u=Q(r-a*t-c*i,e),f=Q(-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}}}},di),w0=BigInt(0);var x0=Ht.ProjectivePoint;var Mr=class extends Error{constructor(e="An error occurred while verifying a message"){super(e),this.name="VerificationError"}};function Rs(r,e,t){let n=_s.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 Ht.verify(e,i,r)}catch(o){throw new Mr(String(o))}}var Fr=class{type="secp256k1";raw;_key;constructor(e){this._key=Ms(e),this.raw=Ks(this._key)}toMultihash(){return Be.digest(kt(this))}toCID(){return z.createV1(114,this.toMultihash())}toString(){return F.encode(this.toMultihash().bytes).substring(1)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:le(this.raw,e.raw)}verify(e,t){return Rs(this._key,t,e)}};function Fs(r){return new Fr(r)}function Ks(r){return Ht.ProjectivePoint.fromHex(r).toRawBytes(!0)}function Ms(r){try{return Ht.ProjectivePoint.fromHex(r),r}catch(e){throw new gr(String(e))}}function qs(r){let{Type:e,Data:t}=or.decode(r.digest),n=t??new Uint8Array;switch(e){case ge.Ed25519:return Wo(n);case ge.secp256k1:return Fs(n);case ge.ECDSA:return zo(n);default:throw new Gt}}function kt(r){return or.encode({Type:ge[r.type],Data:r.raw})}var Vs=Symbol.for("nodejs.util.inspect.custom"),Vu=114,dr=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()})`}[Qr]=!0;toString(){return this.string==null&&(this.string=F.encode(this.multihash.bytes).slice(1)),this.string}toMultihash(){return this.multihash}toCID(){return z.createV1(Vu,this.multihash)}toJSON(){return this.toString()}equals(e){if(e==null)return!1;if(e instanceof Uint8Array)return le(this.multihash.bytes,e);if(typeof e=="string")return this.toString()===e;if(e?.toMultihash()?.bytes!=null)return le(this.multihash.bytes,e.toMultihash().bytes);throw new Error("not valid Id")}[Vs](){return`PeerId(${this.toString()})`}},qr=class extends dr{type="RSA";publicKey;constructor(e){super({...e,type:"RSA"}),this.publicKey=e.publicKey}},Vr=class extends dr{type="Ed25519";publicKey;constructor(e){super({...e,type:"Ed25519"}),this.publicKey=e.publicKey}},Hr=class extends dr{type="secp256k1";publicKey;constructor(e){super({...e,type:"secp256k1"}),this.publicKey=e.publicKey}},Hu=2336,lr=class{type="url";multihash;publicKey;url;constructor(e){this.url=e.toString(),this.multihash=Be.digest(be(this.url))}[Vs](){return`PeerId(${this.url})`}[Qr]=!0;toString(){return this.toCID().toString()}toMultihash(){return this.multihash}toCID(){return z.createV1(Hu,this.toMultihash())}toJSON(){return this.toString()}equals(e){return e==null?!1:(e instanceof Uint8Array&&(e=_(e)),e.toString()===this.toString())}};var zu=114,Hs=2336;function zs(r,e){let t;if(r.charAt(0)==="1"||r.charAt(0)==="Q")t=ht(F.decode(`z${r}`));else{if(r.startsWith("k51qzi5uqu5")||r.startsWith("kzwfwjn5ji4")||r.startsWith("k2k4r8")||r.startsWith("bafz"))return ju(z.parse(r));if(e==null)throw new Te('Please pass a multibase decoder for strings that do not start with "1" or "Q"');t=ht(e.decode(r))}return js(t)}function js(r){if(Gu(r))return new qr({multihash:r});if($u(r))try{let e=qs(r);if(e.type==="Ed25519")return new Vr({multihash:r,publicKey:e});if(e.type==="secp256k1")return new Hr({multihash:r,publicKey:e})}catch{let t=_(r.digest);return new lr(new URL(t))}throw new yr("Supplied PeerID Multihash is invalid")}function ju(r){if(r?.multihash==null||r.version==null||r.version===1&&r.code!==zu&&r.code!==Hs)throw new mr("Supplied PeerID CID is invalid");if(r.code===Hs){let e=_(r.multihash.digest);return new lr(new URL(e))}return js(r.multihash)}function $u(r){return r.code===Be.code}function Gu(r){return r.code===Nn.code}var Ee=ne("node:net");function zr(r){return!!(0,Ee.isIP)(r)}var Gs=Lt($s(),1),Yu=["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"],Wu=Yu.map(r=>new Gs.Netmask(r));function Ni(r){for(let e of Wu)if(e.contains(r))return!0;return!1}function Zu(r){return/^::ffff:([0-9a-fA-F]{1,4}):([0-9a-fA-F]{1,4})$/.test(r)}function Xu(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 Ni(i)}function Qu(r){return/^::ffff:([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(r)}function Ju(r){let e=r.split(":"),t=e[e.length-1];return Ni(t)}function ed(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 Ys(r){return(0,Ee.isIPv4)(r)?Ni(r):Zu(r)?Xu(r):Qu(r)?Ju(r):(0,Ee.isIPv6)(r)?ed(r):void 0}function Ws(r){try{let[[e]]=r.stringTuples();return e===4||e===41}catch{}return!1}function Zs(r){try{if(!Ws(r))return!1;let[[,e]]=r.stringTuples();return e==null?!1:Ys(e)??!1}catch{}return!0}var jr=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 Tf=new jr;var Kf=parseInt("0xFFFF",16),Mf=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);var Js=Ee.isIPv4,sd=Ee.isIPv6,Di=function(r){let e=0;if(r=r.toString().trim(),Js(r)){let t=new Uint8Array(e+4);return r.split(/\./g).forEach(n=>{t[e++]=parseInt(n,10)&255}),t}if(sd(r)){let t=r.split(":",8),n;for(n=0;n<t.length;n++){let o=Js(t[n]),s;o&&(s=Di(t[n]),t[n]=_(s.slice(0,2),"base16")),s!=null&&++n<8&&t.splice(n,0,_(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")},ec=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 zt={},ki={},ad=[[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"]];ad.forEach(r=>{let e=ud(...r);ki[e.code]=e,zt[e.name]=e});function ud(r,e,t,n,i){return{code:r,size:e,name:t,resolvable:!!n,path:!!i}}function R(r){if(typeof r=="number"){if(ki[r]!=null)return ki[r];throw new Error(`no protocol with code: ${r}`)}else if(typeof r=="string"){if(zt[r]!=null)return zt[r];throw new Error(`no protocol with name: ${r}`)}throw new Error(`invalid protocol id type: ${typeof r}`)}var Ig=R("ip4"),vg=R("ip6"),Ag=R("ipcidr");function Mi(r,e){switch(R(r).code){case 4:case 41:return ld(e);case 42:return Ki(e);case 43:return _(e,"base10");case 6:case 273:case 33:case 132:return nc(e).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return Ki(e);case 421:return gd(e);case 444:return rc(e);case 445:return rc(e);case 466:return fd(e);case 481:return globalThis.encodeURIComponent(Ki(e));default:return _(e,"base16")}}function Fi(r,e){switch(R(r).code){case 4:return tc(e);case 41:return tc(e);case 42:return Ri(e);case 43:return be(e,"base10");case 6:case 273:case 33:case 132:return qi(parseInt(e,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return Ri(e);case 421:return hd(e);case 444:return md(e);case 445:return yd(e);case 466:return pd(e);case 481:return Ri(globalThis.decodeURIComponent(e));default:return be(e,"base16")}}var _i=Object.values(Jt).map(r=>r.decoder),dd=function(){let r=_i[0].or(_i[1]);return _i.slice(2).forEach(e=>r=r.or(e)),r}();function tc(r){if(!zr(r))throw new Error("invalid ip address");return Di(r)}function ld(r){let e=ec(r,0,r.length);if(e==null)throw new Error("ipBuff is required");if(!zr(e))throw new Error("invalid ip address");return e}function qi(r){let e=new ArrayBuffer(2);return new DataView(e).setUint16(0,r),new Uint8Array(e)}function nc(r){return new DataView(r.buffer).getUint16(r.byteOffset)}function Ri(r){let e=be(r),t=Uint8Array.from(_t(e.length));return he([t,e],t.length+e.length)}function Ki(r){let e=gt(r);if(r=r.slice(oe(e)),r.length!==e)throw new Error("inconsistent lengths");return _(r)}function hd(r){let e;r[0]==="Q"||r[0]==="1"?e=ht(F.decode(`z${r}`)).bytes:e=z.parse(r).multihash.bytes;let t=Uint8Array.from(_t(e.length));return he([t,e],t.length+e.length)}function pd(r){let e=dd.decode(r),t=Uint8Array.from(_t(e.length));return he([t,e],t.length+e.length)}function fd(r){let e=gt(r),t=r.slice(oe(e));if(t.length!==e)throw new Error("inconsistent lengths");return"u"+_(t,"base64url")}function gd(r){let e=gt(r),t=r.slice(oe(e));if(t.length!==e)throw new Error("inconsistent lengths");return _(t,"base58btc")}function md(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=We.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=qi(n);return he([t,i],t.length+i.length)}function yd(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=We.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=qi(n);return he([t,i],t.length+i.length)}function rc(r){let e=r.slice(0,r.length-2),t=r.slice(r.length-2),n=_(e,"base32"),i=nc(t);return`${n}:${i}`}function ic(r){r=Vi(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=R(s);if(a.size===0){e.push([a.code]),t.push([a.code]);continue}if(o++,o>=i.length)throw new $r("invalid address: "+r);if(a.path===!0){n=Vi(i.slice(o).join("/")),e.push([a.code,Fi(a.code,n)]),t.push([a.code,n]);break}let c=Fi(a.code,i[o]);e.push([a.code,c]),t.push([a.code,Mi(a.code,c)])}return{string:oc(t),bytes:Gr(e),tuples:e,stringTuples:t,path:n}}function Hi(r){let e=[],t=[],n=null,i=0;for(;i<r.length;){let o=gt(r,i),s=oe(o),a=R(o),c=wd(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 $r("Invalid address Uint8Array: "+_(r,"base16"));e.push([o,u]);let f=Mi(o,u);if(t.push([o,f]),a.path===!0){n=f;break}}return{bytes:Uint8Array.from(r),string:oc(t),tuples:e,stringTuples:t,path:n}}function oc(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}),Vi(e.join("/"))}function Gr(r){return he(r.map(e=>{let t=R(e[0]),n=Uint8Array.from(_t(t.code));return e.length>1&&e[1]!=null&&(n=he([n,e[1]])),n}))}function wd(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+oe(t)}}function Vi(r){return"/"+r.trim().split("/").filter(e=>e).join("/")}var $r=class extends Error{static name="ParseError";name="ParseError";constructor(e){super(`Error parsing address: ${e}`)}};var xd=Symbol.for("nodejs.util.inspect.custom"),ji=Symbol.for("@multiformats/js-multiaddr/multiaddr"),bd=[R("dns").code,R("dns4").code,R("dns6").code,R("dnsaddr").code],zi=class extends Error{constructor(e="No available resolver"){super(e),this.name="NoAvailableResolverError"}},Yr=class r{bytes;#e;#t;#r;#n;[ji]=!0;constructor(e){e==null&&(e="");let t;if(e instanceof Uint8Array)t=Hi(e);else if(typeof e=="string"){if(e.length>0&&e.charAt(0)!=="/")throw new Error(`multiaddr "${e}" must start with a "/"`);t=ic(e)}else if(cc(e))t=Hi(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"),a=R("udp"),c=R("ip4"),u=R("ip6"),f=R("dns6"),d=R("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=R(p).name==="tcp"?"tcp":"udp",i=parseInt(h??"")),(p===c.code||p===u.code)&&(t=R(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({},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(Gr(t.slice(0,n)));return this}getPeerId(){try{let e=[];this.stringTuples().forEach(([n,i])=>{n===zt.p2p.code&&e.push([n,i]),n===zt["p2p-circuit"].code&&(e=[])});let t=e.pop();if(t?.[1]!=null){let n=t[1];return n[0]==="Q"||n[0]==="1"?_(F.decode(`z${n}`),"base58btc"):_(z.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){return this.#n}equals(e){return le(this.bytes,e.bytes)}async resolve(e){let t=this.protos().find(o=>o.resolvable);if(t==null)return[this];let n=sc.get(t.name);if(n==null)throw new zi(`no available resolver for ${t.name}`);return(await n(this,e)).map(o=>pr(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)}[xd](){return`Multiaddr(${this.#e})`}};var sc=new Map;function cc(r){return!!r?.[ji]}function pr(r){return new Yr(r)}function ac(r,e,t,n){let i=()=>{n?.log.trace("query",e),r.query({questions:[{name:e,type:"PTR"}]})};return i(),setInterval(i,t)}function uc(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=>pr(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:zs(a),multiaddrs:s.map(c=>c.decapsulateCode(R("p2p").code))}}catch(s){n?.log.error("failed to parse mdns response",s)}}function dc(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(Ed).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 Ed(r){return!!Zs(r)}function lc(r){let e="",t="abcdefghijklmnopqrstuvwxyz0123456789";for(let n=0;n<r;n++)e+=t.charAt(Math.floor(Math.random()*t.length));return e}var Wr=class extends wr{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??lc(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)}[Yi]=this;[Symbol.toStringTag]="@libp2p/mdns";[Xi]=["@libp2p/peer-discovery"];isStarted(){return!!this.mdns}async start(){this.mdns==null&&(this.mdns=(0,hc.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=ac(this.mdns,this.serviceTag,this.interval,{log:this.log}))}_onMdnsQuery(e){this.mdns!=null&&(this.log.trace("received incoming mDNS query"),dc(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=uc(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 vd(r={}){return e=>new Wr(e,r)}return wc(Ad);})();
|
|
3
3
|
/*! Bundled license information:
|
|
4
4
|
|
|
5
5
|
@noble/hashes/esm/utils.js:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@libp2p/mdns",
|
|
3
|
-
"version": "11.0.
|
|
3
|
+
"version": "11.0.34",
|
|
4
4
|
"description": "Node.js libp2p mDNS discovery implementation for peer discovery",
|
|
5
5
|
"license": "Apache-2.0 OR MIT",
|
|
6
6
|
"homepage": "https://github.com/libp2p/js-libp2p/tree/main/packages/peer-discovery-mdns#readme",
|
|
@@ -50,19 +50,19 @@
|
|
|
50
50
|
"test:electron-main": "aegir test -t electron-main"
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
|
-
"@libp2p/interface": "^2.
|
|
54
|
-
"@libp2p/interface-internal": "^2.3.
|
|
55
|
-
"@libp2p/peer-id": "^5.1.
|
|
56
|
-
"@libp2p/utils": "^6.6.
|
|
53
|
+
"@libp2p/interface": "^2.9.0",
|
|
54
|
+
"@libp2p/interface-internal": "^2.3.11",
|
|
55
|
+
"@libp2p/peer-id": "^5.1.2",
|
|
56
|
+
"@libp2p/utils": "^6.6.2",
|
|
57
57
|
"@multiformats/multiaddr": "^12.3.3",
|
|
58
58
|
"@types/multicast-dns": "^7.2.4",
|
|
59
59
|
"dns-packet": "^5.6.1",
|
|
60
60
|
"multicast-dns": "^7.2.5"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
|
-
"@libp2p/crypto": "^5.1.
|
|
64
|
-
"@libp2p/interface-compliance-tests": "^6.4.
|
|
65
|
-
"@libp2p/logger": "^5.1.
|
|
63
|
+
"@libp2p/crypto": "^5.1.1",
|
|
64
|
+
"@libp2p/interface-compliance-tests": "^6.4.4",
|
|
65
|
+
"@libp2p/logger": "^5.1.15",
|
|
66
66
|
"aegir": "^45.1.1",
|
|
67
67
|
"p-wait-for": "^5.0.2",
|
|
68
68
|
"sinon-ts": "^2.0.0"
|