@libp2p/mdns 11.0.13 → 11.0.14-5c4a79e5a

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.min.js CHANGED
@@ -1,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 Rs=Object.create;var ar=Object.defineProperty;var ks=Object.getOwnPropertyDescriptor;var Ds=Object.getOwnPropertyNames;var _s=Object.getPrototypeOf,Ms=Object.prototype.hasOwnProperty;var te=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,r)=>(typeof require<"u"?require:e)[r]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var ve=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),re=(t,e)=>{for(var r in e)ar(t,r,{get:e[r],enumerable:!0})},Oo=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Ds(e))!Ms.call(t,o)&&o!==r&&ar(t,o,{get:()=>e[o],enumerable:!(n=ks(e,o))||n.enumerable});return t};var Bt=(t,e,r)=>(r=t!=null?Rs(_s(t)):{},Oo(e||!t||!t.__esModule?ar(r,"default",{value:t,enumerable:!0}):r,t)),Fs=t=>Oo(ar({},"__esModule",{value:!0}),t);var Do=ve(jr=>{"use strict";jr.toString=function(t){switch(t){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_"+t};jr.toType=function(t){switch(t.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 t.toUpperCase().startsWith("UNKNOWN_")?parseInt(t.slice(8)):0}});var _o=ve(Gr=>{"use strict";Gr.toString=function(t){switch(t){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_"+t};Gr.toRcode=function(t){switch(t.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 Mo=ve(Yr=>{"use strict";Yr.toString=function(t){switch(t){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_"+t};Yr.toOpcode=function(t){switch(t.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 Fo=ve(Xr=>{"use strict";Xr.toString=function(t){switch(t){case 1:return"IN";case 2:return"CS";case 3:return"CH";case 4:return"HS";case 255:return"ANY"}return"UNKNOWN_"+t};Xr.toClass=function(t){switch(t.toUpperCase()){case"IN":return 1;case"CS":return 2;case"CH":return 3;case"HS":return 4;case"ANY":return 255}return 0}});var Ko=ve(Zr=>{"use strict";Zr.toString=function(t){switch(t){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 t<0?null:`OPTION_${t}`};Zr.toCode=function(t){if(typeof t=="number")return t;if(!t)return-1;switch(t.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=t.match(/_(\d+)$/);return e?parseInt(e[1],10):-1}});var zo=ve(($o,Wr)=>{var qo=function(t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.decode=u,t.encode=m,t.familyOf=d,t.name=void 0,t.sizeOf=c,t.v6=t.v4=void 0;let e=/^(\d{1,3}\.){3,3}\d{1,3}$/,r=4,n=/^(::)?(((\d{1,3}\.){3}(\d{1,3}){1})?([0-9a-f]){0,4}:{0,2}){1,8}(::)?$/i,o=16,i={name:"v4",size:r,isFormat:l=>e.test(l),encode(l,p,h){h=~~h,p=p||new Uint8Array(h+r);let y=l.length,g=0;for(let f=0;f<y;){let x=l.charCodeAt(f++);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]}`}};t.v4=i;let s={name:"v6",size:o,isFormat:l=>l.length>0&&n.test(l),encode(l,p,h){h=~~h;let y=h+o,g=-1,f=0,x=0,b=!0,I=!1;p=p||new Uint8Array(h+o);for(let N=0;N<l.length;N++){let v=l.charCodeAt(N);v===58?(b?g!==-1?(h<y&&(p[h]=0),h<y-1&&(p[h+1]=0),h+=2):h<y&&(g=h):(I===!0?(h<y&&(p[h]=x),h++):(h<y&&(p[h]=f>>8),h<y-1&&(p[h+1]=f&255),h+=2),f=0,x=0),b=!0,I=!1):v===46?(h<y&&(p[h]=x),h++,x=0,f=0,b=!1,I=!0):(b=!1,v>=97?v-=87:v>=65?v-=55:(v-=48,x=x*10+v),f=(f<<4)+v)}if(b===!1)I===!0?(h<y&&(p[h]=x),h++):(h<y&&(p[h]=f>>8),h<y-1&&(p[h+1]=f&255),h+=2);else if(g===0)h<y&&(p[h]=0),h<y-1&&(p[h+1]=0),h+=2;else if(g!==-1){h+=2;for(let N=Math.min(h-1,y-1);N>=g+2;N--)p[N]=p[N-2];p[g]=0,p[g+1]=0,g=h}if(g!==h&&g!==-1)for(h>y-2&&(h=y-2);y>g;)p[--y]=h<y&&h>g?p[--h]:0;else for(;h<y;)p[h++]=0;return p},decode(l,p){p=~~p;let h="";for(let y=0;y<o;y+=2)y!==0&&(h+=":"),h+=(l[p+y]<<8|l[p+y+1]).toString(16);return h.replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}};t.v6=s;let a="ip";t.name=a;function c(l){if(i.isFormat(l))return i.size;if(s.isFormat(l))return s.size;throw Error(`Invalid ip address: ${l}`)}function d(l){return c(l)===i.size?1:2}function m(l,p,h){h=~~h;let y=c(l);return typeof p=="function"&&(p=p(h+y)),y===i.size?i.encode(l,p,h):s.encode(l,p,h)}function u(l,p,h){if(p=~~p,h=h||l.length-p,h===i.size)return i.decode(l,p,h);if(h===s.size)return s.decode(l,p,h);throw Error(`Invalid buffer size needs to be ${i.size} for v4 or ${s.size} for v6.`)}return"default"in t?t.default:t}({});typeof define=="function"&&define.amd?define([],function(){return qo}):typeof Wr=="object"&&typeof $o=="object"&&(Wr.exports=qo)});var jo=ve(B=>{"use strict";var U=te("buffer").Buffer,qe=Do(),Ks=_o(),qs=Mo(),pr=Fo(),Qr=Ko(),lt=zo(),$s=0,Vo=32768,Jr=32768,zs=~Jr,Ho=32768,Vs=~Ho,w=B.name={};w.encode=function(t,e,r,{mail:n=!1}={}){e||(e=U.alloc(w.encodingLength(t))),r||(r=0);let o=r,i=t.replace(/^\.|\.$/gm,"");if(i.length){let s=[];if(n){let a="";i.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=i.split(".");for(let a=0;a<s.length;a++){let c=e.write(s[a],r+1);e[r]=c,r+=c+1}}return e[r++]=0,w.encode.bytes=r-o,e};w.encode.bytes=0;w.decode=function(t,e,{mail:r=!1}={}){e||(e=0);let n=[],o=e,i=0,s=0,a=!1;for(;;){if(e>=t.length)throw new Error("Cannot decode name (buffer overflow)");let c=t[e++];if(s+=a?0:1,c===0)break;if(c&192)if((c&192)===192){if(e+1>t.length)throw new Error("Cannot decode name (buffer overflow)");let d=t.readUInt16BE(e-1)-49152;if(d>=o)throw new Error("Cannot decode name (bad pointer)");e=d,o=d,s+=a?0:1,a=!0}else throw new Error("Cannot decode name (bad label)");else{if(e+c>t.length)throw new Error("Cannot decode name (buffer overflow)");if(i+=c+1,i>254)throw new Error("Cannot decode name (name too long)");let d=t.toString("utf-8",e,e+c);r&&(d=d.replace(/\./g,"\\.")),n.push(d),e+=c,s+=a?0:c}}return w.decode.bytes=s,n.length===0?".":n.join(".")};w.decode.bytes=0;w.encodingLength=function(t){return t==="."||t===".."?1:U.byteLength(t.replace(/^\.|\.$/gm,""))+2};var C={};C.encode=function(t,e,r){e||(e=U.alloc(C.encodingLength(t))),r||(r=0);let n=e.write(t,r+1);return e[r]=n,C.encode.bytes=n+1,e};C.encode.bytes=0;C.decode=function(t,e){e||(e=0);let r=t[e],n=t.toString("utf-8",e+1,e+1+r);return C.decode.bytes=r+1,n};C.decode.bytes=0;C.encodingLength=function(t){return U.byteLength(t)+1};var xe={};xe.encode=function(t,e,r){e||(e=xe.encodingLength(t)),r||(r=0);let n=(t.flags||0)&32767,o=t.type==="response"?Vo:$s;return e.writeUInt16BE(t.id||0,r),e.writeUInt16BE(n|o,r+2),e.writeUInt16BE(t.questions.length,r+4),e.writeUInt16BE(t.answers.length,r+6),e.writeUInt16BE(t.authorities.length,r+8),e.writeUInt16BE(t.additionals.length,r+10),e};xe.encode.bytes=12;xe.decode=function(t,e){if(e||(e=0),t.length<12)throw new Error("Header must be 12 bytes");let r=t.readUInt16BE(e+2);return{id:t.readUInt16BE(e),type:r&Vo?"response":"query",flags:r&32767,flag_qr:(r>>15&1)===1,opcode:qs.toString(r>>11&15),flag_aa:(r>>10&1)===1,flag_tc:(r>>9&1)===1,flag_rd:(r>>8&1)===1,flag_ra:(r>>7&1)===1,flag_z:(r>>6&1)===1,flag_ad:(r>>5&1)===1,flag_cd:(r>>4&1)===1,rcode:Ks.toString(r&15),questions:new Array(t.readUInt16BE(e+4)),answers:new Array(t.readUInt16BE(e+6)),authorities:new Array(t.readUInt16BE(e+8)),additionals:new Array(t.readUInt16BE(e+10))}};xe.decode.bytes=12;xe.encodingLength=function(){return 12};var Ce=B.unknown={};Ce.encode=function(t,e,r){return e||(e=U.alloc(Ce.encodingLength(t))),r||(r=0),e.writeUInt16BE(t.length,r),t.copy(e,r+2),Ce.encode.bytes=t.length+2,e};Ce.encode.bytes=0;Ce.decode=function(t,e){e||(e=0);let r=t.readUInt16BE(e),n=t.slice(e+2,e+2+r);return Ce.decode.bytes=r+2,n};Ce.decode.bytes=0;Ce.encodingLength=function(t){return t.length+2};var Pe=B.ns={};Pe.encode=function(t,e,r){return e||(e=U.alloc(Pe.encodingLength(t))),r||(r=0),w.encode(t,e,r+2),e.writeUInt16BE(w.encode.bytes,r),Pe.encode.bytes=w.encode.bytes+2,e};Pe.encode.bytes=0;Pe.decode=function(t,e){e||(e=0);let r=t.readUInt16BE(e),n=w.decode(t,e+2);return Pe.decode.bytes=r+2,n};Pe.decode.bytes=0;Pe.encodingLength=function(t){return w.encodingLength(t)+2};var Re=B.soa={};Re.encode=function(t,e,r){e||(e=U.alloc(Re.encodingLength(t))),r||(r=0);let n=r;return r+=2,w.encode(t.mname,e,r),r+=w.encode.bytes,w.encode(t.rname,e,r,{mail:!0}),r+=w.encode.bytes,e.writeUInt32BE(t.serial||0,r),r+=4,e.writeUInt32BE(t.refresh||0,r),r+=4,e.writeUInt32BE(t.retry||0,r),r+=4,e.writeUInt32BE(t.expire||0,r),r+=4,e.writeUInt32BE(t.minimum||0,r),r+=4,e.writeUInt16BE(r-n-2,n),Re.encode.bytes=r-n,e};Re.encode.bytes=0;Re.decode=function(t,e){e||(e=0);let r=e,n={};return e+=2,n.mname=w.decode(t,e),e+=w.decode.bytes,n.rname=w.decode(t,e,{mail:!0}),e+=w.decode.bytes,n.serial=t.readUInt32BE(e),e+=4,n.refresh=t.readUInt32BE(e),e+=4,n.retry=t.readUInt32BE(e),e+=4,n.expire=t.readUInt32BE(e),e+=4,n.minimum=t.readUInt32BE(e),e+=4,Re.decode.bytes=e-r,n};Re.decode.bytes=0;Re.encodingLength=function(t){return 22+w.encodingLength(t.mname)+w.encodingLength(t.rname)};var ke=B.txt={};ke.encode=function(t,e,r){Array.isArray(t)||(t=[t]);for(let o=0;o<t.length;o++)if(typeof t[o]=="string"&&(t[o]=U.from(t[o])),!U.isBuffer(t[o]))throw new Error("Must be a Buffer");e||(e=U.alloc(ke.encodingLength(t))),r||(r=0);let n=r;return r+=2,t.forEach(function(o){e[r++]=o.length,o.copy(e,r,0,o.length),r+=o.length}),e.writeUInt16BE(r-n-2,n),ke.encode.bytes=r-n,e};ke.encode.bytes=0;ke.decode=function(t,e){e||(e=0);let r=e,n=t.readUInt16BE(e);e+=2;let o=[];for(;n>0;){let i=t[e++];if(--n,n<i)throw new Error("Buffer overflow");o.push(t.slice(e,e+i)),e+=i,n-=i}return ke.decode.bytes=e-r,o};ke.decode.bytes=0;ke.encodingLength=function(t){Array.isArray(t)||(t=[t]);let e=2;return t.forEach(function(r){typeof r=="string"?e+=U.byteLength(r)+1:e+=r.length+1}),e};var De=B.null={};De.encode=function(t,e,r){e||(e=U.alloc(De.encodingLength(t))),r||(r=0),typeof t=="string"&&(t=U.from(t)),t||(t=U.alloc(0));let n=r;r+=2;let o=t.length;return t.copy(e,r,0,o),r+=o,e.writeUInt16BE(r-n-2,n),De.encode.bytes=r-n,e};De.encode.bytes=0;De.decode=function(t,e){e||(e=0);let r=e,n=t.readUInt16BE(e);e+=2;let o=t.slice(e,e+n);return e+=n,De.decode.bytes=e-r,o};De.decode.bytes=0;De.encodingLength=function(t){return t?(U.isBuffer(t)?t.length:U.byteLength(t))+2:2};var _e=B.hinfo={};_e.encode=function(t,e,r){e||(e=U.alloc(_e.encodingLength(t))),r||(r=0);let n=r;return r+=2,C.encode(t.cpu,e,r),r+=C.encode.bytes,C.encode(t.os,e,r),r+=C.encode.bytes,e.writeUInt16BE(r-n-2,n),_e.encode.bytes=r-n,e};_e.encode.bytes=0;_e.decode=function(t,e){e||(e=0);let r=e,n={};return e+=2,n.cpu=C.decode(t,e),e+=C.decode.bytes,n.os=C.decode(t,e),e+=C.decode.bytes,_e.decode.bytes=e-r,n};_e.decode.bytes=0;_e.encodingLength=function(t){return C.encodingLength(t.cpu)+C.encodingLength(t.os)+2};var fe=B.ptr={},Hs=B.cname=fe,js=B.dname=fe;fe.encode=function(t,e,r){return e||(e=U.alloc(fe.encodingLength(t))),r||(r=0),w.encode(t,e,r+2),e.writeUInt16BE(w.encode.bytes,r),fe.encode.bytes=w.encode.bytes+2,e};fe.encode.bytes=0;fe.decode=function(t,e){e||(e=0);let r=w.decode(t,e+2);return fe.decode.bytes=w.decode.bytes+2,r};fe.decode.bytes=0;fe.encodingLength=function(t){return w.encodingLength(t)+2};var Me=B.srv={};Me.encode=function(t,e,r){e||(e=U.alloc(Me.encodingLength(t))),r||(r=0),e.writeUInt16BE(t.priority||0,r+2),e.writeUInt16BE(t.weight||0,r+4),e.writeUInt16BE(t.port||0,r+6),w.encode(t.target,e,r+8);let n=w.encode.bytes+6;return e.writeUInt16BE(n,r),Me.encode.bytes=n+2,e};Me.encode.bytes=0;Me.decode=function(t,e){e||(e=0);let r=t.readUInt16BE(e),n={};return n.priority=t.readUInt16BE(e+2),n.weight=t.readUInt16BE(e+4),n.port=t.readUInt16BE(e+6),n.target=w.decode(t,e+8),Me.decode.bytes=r+2,n};Me.decode.bytes=0;Me.encodingLength=function(t){return 8+w.encodingLength(t.target)};var se=B.caa={};se.ISSUER_CRITICAL=128;se.encode=function(t,e,r){let n=se.encodingLength(t);return e||(e=U.alloc(se.encodingLength(t))),r||(r=0),t.issuerCritical&&(t.flags=se.ISSUER_CRITICAL),e.writeUInt16BE(n-2,r),r+=2,e.writeUInt8(t.flags||0,r),r+=1,C.encode(t.tag,e,r),r+=C.encode.bytes,e.write(t.value,r),r+=U.byteLength(t.value),se.encode.bytes=n,e};se.encode.bytes=0;se.decode=function(t,e){e||(e=0);let r=t.readUInt16BE(e);e+=2;let n=e,o={};return o.flags=t.readUInt8(e),e+=1,o.tag=C.decode(t,e),e+=C.decode.bytes,o.value=t.toString("utf-8",e,n+r),o.issuerCritical=!!(o.flags&se.ISSUER_CRITICAL),se.decode.bytes=r+2,o};se.decode.bytes=0;se.encodingLength=function(t){return C.encodingLength(t.tag)+C.encodingLength(t.value)+2};var et=B.mx={};et.encode=function(t,e,r){e||(e=U.alloc(et.encodingLength(t))),r||(r=0);let n=r;return r+=2,e.writeUInt16BE(t.preference||0,r),r+=2,w.encode(t.exchange,e,r),r+=w.encode.bytes,e.writeUInt16BE(r-n-2,n),et.encode.bytes=r-n,e};et.encode.bytes=0;et.decode=function(t,e){e||(e=0);let r=e,n={};return e+=2,n.preference=t.readUInt16BE(e),e+=2,n.exchange=w.decode(t,e),e+=w.decode.bytes,et.decode.bytes=e-r,n};et.encodingLength=function(t){return 4+w.encodingLength(t.exchange)};var Fe=B.a={};Fe.encode=function(t,e,r){return e||(e=U.alloc(Fe.encodingLength(t))),r||(r=0),e.writeUInt16BE(4,r),r+=2,lt.v4.encode(t,e,r),Fe.encode.bytes=6,e};Fe.encode.bytes=0;Fe.decode=function(t,e){e||(e=0),e+=2;let r=lt.v4.decode(t,e);return Fe.decode.bytes=6,r};Fe.decode.bytes=0;Fe.encodingLength=function(){return 6};var Ke=B.aaaa={};Ke.encode=function(t,e,r){return e||(e=U.alloc(Ke.encodingLength(t))),r||(r=0),e.writeUInt16BE(16,r),r+=2,lt.v6.encode(t,e,r),Ke.encode.bytes=18,e};Ke.encode.bytes=0;Ke.decode=function(t,e){e||(e=0),e+=2;let r=lt.v6.decode(t,e);return Ke.decode.bytes=18,r};Ke.decode.bytes=0;Ke.encodingLength=function(){return 18};var ne=B.option={};ne.encode=function(t,e,r){e||(e=U.alloc(ne.encodingLength(t))),r||(r=0);let n=r,o=Qr.toCode(t.code);if(e.writeUInt16BE(o,r),r+=2,t.data)e.writeUInt16BE(t.data.length,r),r+=2,t.data.copy(e,r),r+=t.data.length;else switch(o){case 8:let i=t.sourcePrefixLength||0,s=t.family||lt.familyOf(t.ip),a=lt.encode(t.ip,U.alloc),c=Math.ceil(i/8);e.writeUInt16BE(c+4,r),r+=2,e.writeUInt16BE(s,r),r+=2,e.writeUInt8(i,r++),e.writeUInt8(t.scopePrefixLength||0,r++),a.copy(e,r,0,c),r+=c;break;case 11:t.timeout?(e.writeUInt16BE(2,r),r+=2,e.writeUInt16BE(t.timeout,r),r+=2):(e.writeUInt16BE(0,r),r+=2);break;case 12:let d=t.length||0;e.writeUInt16BE(d,r),r+=2,e.fill(0,r,r+d),r+=d;break;case 14:let m=t.tags.length*2;e.writeUInt16BE(m,r),r+=2;for(let u of t.tags)e.writeUInt16BE(u,r),r+=2;break;default:throw new Error(`Unknown roption code: ${t.code}`)}return ne.encode.bytes=r-n,e};ne.encode.bytes=0;ne.decode=function(t,e){e||(e=0);let r={};r.code=t.readUInt16BE(e),r.type=Qr.toString(r.code),e+=2;let n=t.readUInt16BE(e);switch(e+=2,r.data=t.slice(e,e+n),r.code){case 8:r.family=t.readUInt16BE(e),e+=2,r.sourcePrefixLength=t.readUInt8(e++),r.scopePrefixLength=t.readUInt8(e++);let o=U.alloc(r.family===1?4:16);t.copy(o,0,e,e+n-4),r.ip=lt.decode(o);break;case 11:n>0&&(r.timeout=t.readUInt16BE(e),e+=2);break;case 14:r.tags=[];for(let i=0;i<n;i+=2)r.tags.push(t.readUInt16BE(e)),e+=2}return ne.decode.bytes=n+4,r};ne.decode.bytes=0;ne.encodingLength=function(t){if(t.data)return t.data.length+4;switch(Qr.toCode(t.code)){case 8:let r=t.sourcePrefixLength||0;return Math.ceil(r/8)+8;case 11:return typeof t.timeout=="number"?6:4;case 12:return t.length+4;case 14:return 4+t.tags.length*2}throw new Error(`Unknown roption code: ${t.code}`)};var ae=B.opt={};ae.encode=function(t,e,r){e||(e=U.alloc(ae.encodingLength(t))),r||(r=0);let n=r,o=Lt(t,ne);return e.writeUInt16BE(o,r),r=Ht(t,ne,e,r+2),ae.encode.bytes=r-n,e};ae.encode.bytes=0;ae.decode=function(t,e){e||(e=0);let r=e,n=[],o=t.readUInt16BE(e);e+=2;let i=0;for(;o>0;)n[i++]=ne.decode(t,e),e+=ne.decode.bytes,o-=ne.decode.bytes;return ae.decode.bytes=e-r,n};ae.decode.bytes=0;ae.encodingLength=function(t){return 2+Lt(t||[],ne)};var W=B.dnskey={};W.PROTOCOL_DNSSEC=3;W.ZONE_KEY=128;W.SECURE_ENTRYPOINT=32768;W.encode=function(t,e,r){e||(e=U.alloc(W.encodingLength(t))),r||(r=0);let n=r,o=t.key;if(!U.isBuffer(o))throw new Error("Key must be a Buffer");return r+=2,e.writeUInt16BE(t.flags,r),r+=2,e.writeUInt8(W.PROTOCOL_DNSSEC,r),r+=1,e.writeUInt8(t.algorithm,r),r+=1,o.copy(e,r,0,o.length),r+=o.length,W.encode.bytes=r-n,e.writeUInt16BE(W.encode.bytes-2,n),e};W.encode.bytes=0;W.decode=function(t,e){e||(e=0);let r=e;var n={},o=t.readUInt16BE(e);if(e+=2,n.flags=t.readUInt16BE(e),e+=2,t.readUInt8(e)!==W.PROTOCOL_DNSSEC)throw new Error("Protocol must be 3");return e+=1,n.algorithm=t.readUInt8(e),e+=1,n.key=t.slice(e,r+o+2),e+=n.key.length,W.decode.bytes=e-r,n};W.decode.bytes=0;W.encodingLength=function(t){return 6+U.byteLength(t.key)};var Se=B.rrsig={};Se.encode=function(t,e,r){e||(e=U.alloc(Se.encodingLength(t))),r||(r=0);let n=r,o=t.signature;if(!U.isBuffer(o))throw new Error("Signature must be a Buffer");return r+=2,e.writeUInt16BE(qe.toType(t.typeCovered),r),r+=2,e.writeUInt8(t.algorithm,r),r+=1,e.writeUInt8(t.labels,r),r+=1,e.writeUInt32BE(t.originalTTL,r),r+=4,e.writeUInt32BE(t.expiration,r),r+=4,e.writeUInt32BE(t.inception,r),r+=4,e.writeUInt16BE(t.keyTag,r),r+=2,w.encode(t.signersName,e,r),r+=w.encode.bytes,o.copy(e,r,0,o.length),r+=o.length,Se.encode.bytes=r-n,e.writeUInt16BE(Se.encode.bytes-2,n),e};Se.encode.bytes=0;Se.decode=function(t,e){e||(e=0);let r=e;var n={},o=t.readUInt16BE(e);return e+=2,n.typeCovered=qe.toString(t.readUInt16BE(e)),e+=2,n.algorithm=t.readUInt8(e),e+=1,n.labels=t.readUInt8(e),e+=1,n.originalTTL=t.readUInt32BE(e),e+=4,n.expiration=t.readUInt32BE(e),e+=4,n.inception=t.readUInt32BE(e),e+=4,n.keyTag=t.readUInt16BE(e),e+=2,n.signersName=w.decode(t,e),e+=w.decode.bytes,n.signature=t.slice(e,r+o+2),e+=n.signature.length,Se.decode.bytes=e-r,n};Se.decode.bytes=0;Se.encodingLength=function(t){return 20+w.encodingLength(t.signersName)+U.byteLength(t.signature)};var Ae=B.rp={};Ae.encode=function(t,e,r){e||(e=U.alloc(Ae.encodingLength(t))),r||(r=0);let n=r;return r+=2,w.encode(t.mbox||".",e,r,{mail:!0}),r+=w.encode.bytes,w.encode(t.txt||".",e,r),r+=w.encode.bytes,Ae.encode.bytes=r-n,e.writeUInt16BE(Ae.encode.bytes-2,n),e};Ae.encode.bytes=0;Ae.decode=function(t,e){e||(e=0);let r=e,n={};return e+=2,n.mbox=w.decode(t,e,{mail:!0})||".",e+=w.decode.bytes,n.txt=w.decode(t,e)||".",e+=w.decode.bytes,Ae.decode.bytes=e-r,n};Ae.decode.bytes=0;Ae.encodingLength=function(t){return 2+w.encodingLength(t.mbox||".")+w.encodingLength(t.txt||".")};var H={};H.encode=function(t,e,r){e||(e=U.alloc(H.encodingLength(t))),r||(r=0);let n=r;for(var o=[],i=0;i<t.length;i++){var s=qe.toType(t[i]);o[s>>8]===void 0&&(o[s>>8]=[]),o[s>>8][s>>3&31]|=1<<7-(s&7)}for(i=0;i<o.length;i++)if(o[i]!==void 0){var a=U.from(o[i]);e.writeUInt8(i,r),r+=1,e.writeUInt8(a.length,r),r+=1,a.copy(e,r),r+=a.length}return H.encode.bytes=r-n,e};H.encode.bytes=0;H.decode=function(t,e,r){e||(e=0);let n=e;for(var o=[];e-n<r;){var i=t.readUInt8(e);e+=1;var s=t.readUInt8(e);e+=1;for(var a=0;a<s;a++)for(var c=t.readUInt8(e+a),d=0;d<8;d++)if(c&1<<7-d){var m=qe.toString(i<<8|a<<3|d);o.push(m)}e+=s}return H.decode.bytes=e-n,o};H.decode.bytes=0;H.encodingLength=function(t){for(var e=[],r=0;r<t.length;r++){var n=qe.toType(t[r]);e[n>>8]=Math.max(e[n>>8]||0,n&255)}var o=0;for(r=0;r<e.length;r++)e[r]!==void 0&&(o+=2+Math.ceil((e[r]+1)/8));return o};var Be=B.nsec={};Be.encode=function(t,e,r){e||(e=U.alloc(Be.encodingLength(t))),r||(r=0);let n=r;return r+=2,w.encode(t.nextDomain,e,r),r+=w.encode.bytes,H.encode(t.rrtypes,e,r),r+=H.encode.bytes,Be.encode.bytes=r-n,e.writeUInt16BE(Be.encode.bytes-2,n),e};Be.encode.bytes=0;Be.decode=function(t,e){e||(e=0);let r=e;var n={},o=t.readUInt16BE(e);return e+=2,n.nextDomain=w.decode(t,e),e+=w.decode.bytes,n.rrtypes=H.decode(t,e,o-(e-r)),e+=H.decode.bytes,Be.decode.bytes=e-r,n};Be.decode.bytes=0;Be.encodingLength=function(t){return 2+w.encodingLength(t.nextDomain)+H.encodingLength(t.rrtypes)};var Ue=B.nsec3={};Ue.encode=function(t,e,r){e||(e=U.alloc(Ue.encodingLength(t))),r||(r=0);let n=r,o=t.salt;if(!U.isBuffer(o))throw new Error("salt must be a Buffer");let i=t.nextDomain;if(!U.isBuffer(i))throw new Error("nextDomain must be a Buffer");return r+=2,e.writeUInt8(t.algorithm,r),r+=1,e.writeUInt8(t.flags,r),r+=1,e.writeUInt16BE(t.iterations,r),r+=2,e.writeUInt8(o.length,r),r+=1,o.copy(e,r,0,o.length),r+=o.length,e.writeUInt8(i.length,r),r+=1,i.copy(e,r,0,i.length),r+=i.length,H.encode(t.rrtypes,e,r),r+=H.encode.bytes,Ue.encode.bytes=r-n,e.writeUInt16BE(Ue.encode.bytes-2,n),e};Ue.encode.bytes=0;Ue.decode=function(t,e){e||(e=0);let r=e;var n={},o=t.readUInt16BE(e);e+=2,n.algorithm=t.readUInt8(e),e+=1,n.flags=t.readUInt8(e),e+=1,n.iterations=t.readUInt16BE(e),e+=2;let i=t.readUInt8(e);e+=1,n.salt=t.slice(e,e+i),e+=i;let s=t.readUInt8(e);return e+=1,n.nextDomain=t.slice(e,e+s),e+=s,n.rrtypes=H.decode(t,e,o-(e-r)),e+=H.decode.bytes,Ue.decode.bytes=e-r,n};Ue.decode.bytes=0;Ue.encodingLength=function(t){return 8+t.salt.length+t.nextDomain.length+H.encodingLength(t.rrtypes)};var Le=B.ds={};Le.encode=function(t,e,r){e||(e=U.alloc(Le.encodingLength(t))),r||(r=0);let n=r,o=t.digest;if(!U.isBuffer(o))throw new Error("Digest must be a Buffer");return r+=2,e.writeUInt16BE(t.keyTag,r),r+=2,e.writeUInt8(t.algorithm,r),r+=1,e.writeUInt8(t.digestType,r),r+=1,o.copy(e,r,0,o.length),r+=o.length,Le.encode.bytes=r-n,e.writeUInt16BE(Le.encode.bytes-2,n),e};Le.encode.bytes=0;Le.decode=function(t,e){e||(e=0);let r=e;var n={},o=t.readUInt16BE(e);return e+=2,n.keyTag=t.readUInt16BE(e),e+=2,n.algorithm=t.readUInt8(e),e+=1,n.digestType=t.readUInt8(e),e+=1,n.digest=t.slice(e,r+o+2),e+=n.digest.length,Le.decode.bytes=e-r,n};Le.decode.bytes=0;Le.encodingLength=function(t){return 6+U.byteLength(t.digest)};var ce=B.sshfp={};ce.getFingerprintLengthForHashType=function(e){switch(e){case 1:return 20;case 2:return 32}};ce.encode=function(e,r,n){r||(r=U.alloc(ce.encodingLength(e))),n||(n=0);let o=n;n+=2,r[n]=e.algorithm,n+=1,r[n]=e.hash,n+=1;let i=U.from(e.fingerprint.toUpperCase(),"hex");if(i.length!==ce.getFingerprintLengthForHashType(e.hash))throw new Error("Invalid fingerprint length");return i.copy(r,n),n+=i.byteLength,ce.encode.bytes=n-o,r.writeUInt16BE(ce.encode.bytes-2,o),r};ce.encode.bytes=0;ce.decode=function(e,r){r||(r=0);let n=r,o={};r+=2,o.algorithm=e[r],r+=1,o.hash=e[r],r+=1;let i=ce.getFingerprintLengthForHashType(o.hash);return o.fingerprint=e.slice(r,r+i).toString("hex").toUpperCase(),r+=i,ce.decode.bytes=r-n,o};ce.decode.bytes=0;ce.encodingLength=function(t){return 4+U.from(t.fingerprint,"hex").byteLength};var Te=B.naptr={};Te.encode=function(t,e,r){e||(e=U.alloc(Te.encodingLength(t))),r||(r=0);let n=r;return r+=2,e.writeUInt16BE(t.order||0,r),r+=2,e.writeUInt16BE(t.preference||0,r),r+=2,C.encode(t.flags,e,r),r+=C.encode.bytes,C.encode(t.services,e,r),r+=C.encode.bytes,C.encode(t.regexp,e,r),r+=C.encode.bytes,w.encode(t.replacement,e,r),r+=w.encode.bytes,Te.encode.bytes=r-n,e.writeUInt16BE(Te.encode.bytes-2,n),e};Te.encode.bytes=0;Te.decode=function(t,e){e||(e=0);let r=e,n={};return e+=2,n.order=t.readUInt16BE(e),e+=2,n.preference=t.readUInt16BE(e),e+=2,n.flags=C.decode(t,e),e+=C.decode.bytes,n.services=C.decode(t,e),e+=C.decode.bytes,n.regexp=C.decode(t,e),e+=C.decode.bytes,n.replacement=w.decode(t,e),e+=w.decode.bytes,Te.decode.bytes=e-r,n};Te.decode.bytes=0;Te.encodingLength=function(t){return C.encodingLength(t.flags)+C.encodingLength(t.services)+C.encodingLength(t.regexp)+w.encodingLength(t.replacement)+6};var Ne=B.tlsa={};Ne.encode=function(t,e,r){e||(e=U.alloc(Ne.encodingLength(t))),r||(r=0);let n=r,o=t.certificate;if(!U.isBuffer(o))throw new Error("Certificate must be a Buffer");return r+=2,e.writeUInt8(t.usage,r),r+=1,e.writeUInt8(t.selector,r),r+=1,e.writeUInt8(t.matchingType,r),r+=1,o.copy(e,r,0,o.length),r+=o.length,Ne.encode.bytes=r-n,e.writeUInt16BE(Ne.encode.bytes-2,n),e};Ne.encode.bytes=0;Ne.decode=function(t,e){e||(e=0);let r=e,n={},o=t.readUInt16BE(e);return e+=2,n.usage=t.readUInt8(e),e+=1,n.selector=t.readUInt8(e),e+=1,n.matchingType=t.readUInt8(e),e+=1,n.certificate=t.slice(e,r+o+2),e+=n.certificate.length,Ne.decode.bytes=e-r,n};Ne.decode.bytes=0;Ne.encodingLength=function(t){return 5+U.byteLength(t.certificate)};var en=B.record=function(t){switch(t.toUpperCase()){case"A":return Fe;case"PTR":return fe;case"CNAME":return Hs;case"DNAME":return js;case"TXT":return ke;case"NULL":return De;case"AAAA":return Ke;case"SRV":return Me;case"HINFO":return _e;case"CAA":return se;case"NS":return Pe;case"SOA":return Re;case"MX":return et;case"OPT":return ae;case"DNSKEY":return W;case"RRSIG":return Se;case"RP":return Ae;case"NSEC":return Be;case"NSEC3":return Ue;case"SSHFP":return ce;case"DS":return Le;case"NAPTR":return Te;case"TLSA":return Ne}return Ce},G=B.answer={};G.encode=function(t,e,r){e||(e=U.alloc(G.encodingLength(t))),r||(r=0);let n=r;if(w.encode(t.name,e,r),r+=w.encode.bytes,e.writeUInt16BE(qe.toType(t.type),r),t.type.toUpperCase()==="OPT"){if(t.name!==".")throw new Error("OPT name must be root.");e.writeUInt16BE(t.udpPayloadSize||4096,r+2),e.writeUInt8(t.extendedRcode||0,r+4),e.writeUInt8(t.ednsVersion||0,r+5),e.writeUInt16BE(t.flags||0,r+6),r+=8,ae.encode(t.options||[],e,r),r+=ae.encode.bytes}else{let o=pr.toClass(t.class===void 0?"IN":t.class);t.flush&&(o|=Jr),e.writeUInt16BE(o,r+2),e.writeUInt32BE(t.ttl||0,r+4),r+=8;let i=en(t.type);i.encode(t.data,e,r),r+=i.encode.bytes}return G.encode.bytes=r-n,e};G.encode.bytes=0;G.decode=function(t,e){e||(e=0);let r={},n=e;if(r.name=w.decode(t,e),e+=w.decode.bytes,r.type=qe.toString(t.readUInt16BE(e)),r.type==="OPT")r.udpPayloadSize=t.readUInt16BE(e+2),r.extendedRcode=t.readUInt8(e+4),r.ednsVersion=t.readUInt8(e+5),r.flags=t.readUInt16BE(e+6),r.flag_do=(r.flags>>15&1)===1,r.options=ae.decode(t,e+8),e+=8+ae.decode.bytes;else{let o=t.readUInt16BE(e+2);r.ttl=t.readUInt32BE(e+4),r.class=pr.toString(o&zs),r.flush=!!(o&Jr);let i=en(r.type);r.data=i.decode(t,e+8),e+=8+i.decode.bytes}return G.decode.bytes=e-n,r};G.decode.bytes=0;G.encodingLength=function(t){let e=t.data!==null&&t.data!==void 0?t.data:t.options;return w.encodingLength(t.name)+8+en(t.type).encodingLength(e)};var we=B.question={};we.encode=function(t,e,r){e||(e=U.alloc(we.encodingLength(t))),r||(r=0);let n=r;return w.encode(t.name,e,r),r+=w.encode.bytes,e.writeUInt16BE(qe.toType(t.type),r),r+=2,e.writeUInt16BE(pr.toClass(t.class===void 0?"IN":t.class),r),r+=2,we.encode.bytes=r-n,t};we.encode.bytes=0;we.decode=function(t,e){e||(e=0);let r=e,n={};return n.name=w.decode(t,e),e+=w.decode.bytes,n.type=qe.toString(t.readUInt16BE(e)),e+=2,n.class=pr.toString(t.readUInt16BE(e)),e+=2,!!(n.class&Ho)&&(n.class&=Vs),we.decode.bytes=e-r,n};we.decode.bytes=0;we.encodingLength=function(t){return w.encodingLength(t.name)+4};B.AUTHORITATIVE_ANSWER=1024;B.TRUNCATED_RESPONSE=512;B.RECURSION_DESIRED=256;B.RECURSION_AVAILABLE=128;B.AUTHENTIC_DATA=32;B.CHECKING_DISABLED=16;B.DNSSEC_OK=32768;B.encode=function(t,e,r){let n=!e;n&&(e=U.alloc(B.encodingLength(t))),r||(r=0);let o=r;return t.questions||(t.questions=[]),t.answers||(t.answers=[]),t.authorities||(t.authorities=[]),t.additionals||(t.additionals=[]),xe.encode(t,e,r),r+=xe.encode.bytes,r=Ht(t.questions,we,e,r),r=Ht(t.answers,G,e,r),r=Ht(t.authorities,G,e,r),r=Ht(t.additionals,G,e,r),B.encode.bytes=r-o,n&&B.encode.bytes!==e.length?e.slice(0,B.encode.bytes):e};B.encode.bytes=0;B.decode=function(t,e){e||(e=0);let r=e,n=xe.decode(t,e);return e+=xe.decode.bytes,e=hr(n.questions,we,t,e),e=hr(n.answers,G,t,e),e=hr(n.authorities,G,t,e),e=hr(n.additionals,G,t,e),B.decode.bytes=e-r,n};B.decode.bytes=0;B.encodingLength=function(t){return xe.encodingLength(t)+Lt(t.questions||[],we)+Lt(t.answers||[],G)+Lt(t.authorities||[],G)+Lt(t.additionals||[],G)};B.streamEncode=function(t){let e=B.encode(t),r=U.alloc(2);r.writeUInt16BE(e.byteLength);let n=U.concat([r,e]);return B.streamEncode.bytes=n.byteLength,n};B.streamEncode.bytes=0;B.streamDecode=function(t){let e=t.readUInt16BE(0);if(t.byteLength<e+2)return null;let r=B.decode(t.slice(2));return B.streamDecode.bytes=B.decode.bytes,r};B.streamDecode.bytes=0;function Lt(t,e){let r=0;for(let n=0;n<t.length;n++)r+=e.encodingLength(t[n]);return r}function Ht(t,e,r,n){for(let o=0;o<t.length;o++)e.encode(t[o],r,n),n+=e.encode.bytes;return n}function hr(t,e,r,n){for(let o=0;o<t.length;o++)t[o]=e.decode(r,n),n+=e.decode.bytes;return n}});var Xo=ve((Iu,Yo)=>{"use strict";var Go=Qs;process.nextTick(Ws,42);Yo.exports=Gs;function Gs(t){var e=n;return r;function r(o){e(o||Xs)}function n(o){var i=[o];e=s,t(a);function s(c){i.push(c)}function a(c){var d=arguments;for(e=Ys(c)?n:m;i.length;)m(i.shift());function m(u){Go(Zs,u,d)}}}}function Ys(t){return Object.prototype.toString.call(t)==="[object Error]"}function Xs(){}function Zs(t,e){t.apply(null,e)}function Ws(t){t===42&&(Go=process.nextTick)}function Qs(t,e,r){process.nextTick(function(){t(e,r)})}});var Qo=ve((vu,Wo)=>{var tn=jo(),Js=te("dgram"),ec=Xo(),tc=te("events"),nn=te("os"),rn=function(){};Wo.exports=function(t){t||(t={});var e=new tc.EventEmitter,r=typeof t.port=="number"?t.port:5353,n=t.type||"udp4",o=t.ip||t.host||(n==="udp4"?"224.0.0.251":null),i={address:o,port:r},s={},a=!1,c=null;if(n==="udp6"&&(!o||!t.interface))throw new Error("For IPv6 multicast you must specify `ip` and `interface`");var d=t.socket||Js.createSocket({type:n,reuseAddr:t.reuseAddr!==!1,toString:function(){return n}});d.on("error",function(u){u.code==="EACCES"||u.code==="EADDRINUSE"?e.emit("error",u):e.emit("warning",u)}),d.on("message",function(u,l){try{u=tn.decode(u)}catch(p){e.emit("warning",p);return}e.emit("packet",u,l),u.type==="query"&&e.emit("query",u,l),u.type==="response"&&e.emit("response",u,l)}),d.on("listening",function(){r||(r=i.port=d.address().port),t.multicast!==!1&&(e.update(),c=setInterval(e.update,5e3),d.setMulticastTTL(t.ttl||255),d.setMulticastLoopback(t.loopback!==!1))});var m=ec(function(u){if(!r||t.bind===!1)return u(null);d.once("error",u),d.bind(r,t.bind||t.interface,function(){d.removeListener("error",u),u(null)})});return m(function(u){if(u)return e.emit("error",u);e.emit("ready")}),e.send=function(u,l,p){if(typeof l=="function")return e.send(u,null,l);p||(p=rn),l?!l.host&&!l.address&&(l.address=i.address):l=i,m(h);function h(y){if(a)return p();if(y)return p(y);var g=tn.encode(u);d.send(g,0,g.length,l.port,l.address||l.host,p)}},e.response=e.respond=function(u,l,p){Array.isArray(u)&&(u={answers:u}),u.type="response",u.flags=(u.flags||0)|tn.AUTHORITATIVE_ANSWER,e.send(u,l,p)},e.query=function(u,l,p,h){if(typeof l=="function")return e.query(u,null,null,l);if(typeof l=="object"&&l&&l.port)return e.query(u,null,l,p);if(typeof p=="function")return e.query(u,l,null,p);h||(h=rn),typeof u=="string"&&(u=[{name:u,type:l||"ANY"}]),Array.isArray(u)&&(u={type:"query",questions:u}),u.type="query",e.send(u,p,h)},e.destroy=function(u){if(u||(u=rn),a)return process.nextTick(u);a=!0,clearInterval(c);for(var l in s)try{d.dropMembership(o,l)}catch{}s={},d.close(u)},e.update=function(){for(var u=t.interface?[].concat(t.interface):nc(),l=!1,p=0;p<u.length;p++){var h=u[p];if(!s[h])try{d.addMembership(o,h),s[h]=!0,l=!0}catch(y){e.emit("warning",y)}}if(l){if(d.setMulticastInterface)try{d.setMulticastInterface(t.interface||rc())}catch(y){e.emit("warning",y)}e.emit("networkInterface")}},e};function rc(){for(var t=nn.networkInterfaces(),e=Object.keys(t),r=0;r<e.length;r++)for(var n=t[e[r]],o=0;o<n.length;o++){var i=n[o];if(Zo(i.family)&&!i.internal)return nn.platform()==="darwin"&&e[r]==="en0"?i.address:"0.0.0.0"}return"127.0.0.1"}function nc(){for(var t=nn.networkInterfaces(),e=Object.keys(t),r=[],n=0;n<e.length;n++)for(var o=t[e[n]],i=0;i<o.length;i++){var s=o[i];if(Zo(s.family)){r.push(s.address);break}}return r}function Zo(t){return t===4||t==="IPv4"}});var ps=ve(ir=>{(function(){var t,e,r,n,o,i,s,a;a=function(c){var d,m,u,l;return d=(c&255<<24)>>>24,m=(c&255<<16)>>>16,u=(c&65280)>>>8,l=c&255,[d,m,u,l].join(".")},s=function(c){var d,m,u,l,p,h;for(d=[],u=l=0;l<=3&&c.length!==0;u=++l){if(u>0){if(c[0]!==".")throw new Error("Invalid IP");c=c.substring(1)}h=e(c),p=h[0],m=h[1],c=c.substring(m),d.push(p)}if(c.length!==0)throw new Error("Invalid IP");switch(d.length){case 1:if(d[0]>4294967295)throw new Error("Invalid IP");return d[0]>>>0;case 2:if(d[0]>255||d[1]>16777215)throw new Error("Invalid IP");return(d[0]<<24|d[1])>>>0;case 3:if(d[0]>255||d[1]>255||d[2]>65535)throw new Error("Invalid IP");return(d[0]<<24|d[1]<<16|d[2])>>>0;case 4:if(d[0]>255||d[1]>255||d[2]>255||d[3]>255)throw new Error("Invalid IP");return(d[0]<<24|d[1]<<16|d[2]<<8|d[3])>>>0;default:throw new Error("Invalid IP")}},r=function(c){return c.charCodeAt(0)},n=r("0"),i=r("a"),o=r("A"),e=function(c){var d,m,u,l,p;for(l=0,d=10,m="9",u=0,c.length>1&&c[u]==="0"&&(c[u+1]==="x"||c[u+1]==="X"?(u+=2,d=16):"0"<=c[u+1]&&c[u+1]<="9"&&(u++,d=8,m="7")),p=u;u<c.length;){if("0"<=c[u]&&c[u]<=m)l=l*d+(r(c[u])-n)>>>0;else if(d===16)if("a"<=c[u]&&c[u]<="f")l=l*d+(10+r(c[u])-i)>>>0;else if("A"<=c[u]&&c[u]<="F")l=l*d+(10+r(c[u])-o)>>>0;else break;else break;if(l>4294967295)throw new Error("too large");u++}if(u===p)throw new Error("empty octet");return[l,u]},t=function(){function c(d,m){var u,l,p,h;if(typeof d!="string")throw new Error("Missing `net' parameter");if(m||(h=d.split("/",2),d=h[0],m=h[1]),m||(m=32),typeof m=="string"&&m.indexOf(".")>-1){try{this.maskLong=s(m)}catch(y){throw u=y,new Error("Invalid mask: "+m)}for(l=p=32;p>=0;l=--p)if(this.maskLong===4294967295<<32-l>>>0){this.bitmask=l;break}}else if(m||m===0)this.bitmask=parseInt(m,10),this.maskLong=0,this.bitmask>0&&(this.maskLong=4294967295<<32-this.bitmask>>>0);else throw new Error("Invalid mask: empty");try{this.netLong=(s(d)&this.maskLong)>>>0}catch(y){throw u=y,new Error("Invalid net address: "+d)}if(!(this.bitmask<=32))throw new Error("Invalid mask for ip4: "+m);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(d){return typeof d=="string"&&(d.indexOf("/")>0||d.split(".").length!==4)&&(d=new c(d)),d instanceof c?this.contains(d.base)&&this.contains(d.broadcast||d.last):(s(d)&this.maskLong)>>>0===(this.netLong&this.maskLong)>>>0},c.prototype.next=function(d){return d==null&&(d=1),new c(a(this.netLong+this.size*d),this.mask)},c.prototype.forEach=function(d){var m,u,l;for(l=s(this.first),u=s(this.last),m=0;l<=u;)d(a(l),l,m),m++,l++},c.prototype.toString=function(){return this.base+"/"+this.bitmask},c}(),ir.ip2long=s,ir.long2ip=a,ir.Netmask=t}).call(ir)});var Md={};re(Md,{mdns:()=>_d});var Co=Symbol.for("@libp2p/peer-discovery");var Hr=Symbol.for("@libp2p/peer-id");var Ut=class extends Error{static name="InvalidParametersError";constructor(e="Invalid parameters"){super(e),this.name="InvalidParametersError"}},dr=class extends Error{static name="InvalidPublicKeyError";constructor(e="Invalid public key"){super(e),this.name="InvalidPublicKeyError"}};var ur=class extends Error{static name="InvalidMultihashError";constructor(e="Invalid Multihash"){super(e),this.name="InvalidMultihashError"}};var Vt=class extends Error{static name="UnsupportedKeyTypeError";constructor(e="Unsupported key type"){super(e),this.name="UnsupportedKeyTypeError"}};var Po=te("events"),Ro=(t,...e)=>{try{(0,Po.setMaxListeners)(t,...e)}catch{}};var lr=class extends EventTarget{#e=new Map;constructor(){super(),Ro(1/0,this)}listenerCount(e){let r=this.#e.get(e);return r==null?0:r.length}addEventListener(e,r,n){super.addEventListener(e,r,n);let o=this.#e.get(e);o==null&&(o=[],this.#e.set(e,o)),o.push({callback:r,once:(n!==!0&&n!==!1&&n?.once)??!1})}removeEventListener(e,r,n){super.removeEventListener(e.toString(),r??null,n);let o=this.#e.get(e);o!=null&&(o=o.filter(({callback:i})=>i!==r),this.#e.set(e,o))}dispatchEvent(e){let r=super.dispatchEvent(e),n=this.#e.get(e.type);return n==null||(n=n.filter(({once:o})=>!o),this.#e.set(e.type,n)),r}safeDispatchEvent(e,r={}){return this.dispatchEvent(new CustomEvent(e,r))}};var ko=Symbol.for("@libp2p/service-capabilities"),jd=Symbol.for("@libp2p/service-dependencies");var Ps=Bt(Qo(),1);var dn={};re(dn,{base58btc:()=>K,base58flickr:()=>dc});var Su=new Uint8Array(0);function Jo(t,e){if(t===e)return!0;if(t.byteLength!==e.byteLength)return!1;for(let r=0;r<t.byteLength;r++)if(t[r]!==e[r])return!1;return!0}function pe(t){if(t instanceof Uint8Array&&t.constructor.name==="Uint8Array")return t;if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);throw new Error("Unknown type, must be binary type")}function ei(t){return new TextEncoder().encode(t)}function ti(t){return new TextDecoder().decode(t)}function oc(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var o=0;o<t.length;o++){var i=t.charAt(o),s=i.charCodeAt(0);if(r[s]!==255)throw new TypeError(i+" is ambiguous");r[s]=o}var a=t.length,c=t.charAt(0),d=Math.log(a)/Math.log(256),m=Math.log(256)/Math.log(a);function u(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 y=0,g=0,f=0,x=h.length;f!==x&&h[f]===0;)f++,y++;for(var b=(x-f)*m+1>>>0,I=new Uint8Array(b);f!==x;){for(var N=h[f],v=0,S=b-1;(N!==0||v<g)&&S!==-1;S--,v++)N+=256*I[S]>>>0,I[S]=N%a>>>0,N=N/a>>>0;if(N!==0)throw new Error("Non-zero carry");g=v,f++}for(var T=b-g;T!==b&&I[T]===0;)T++;for(var O=c.repeat(y);T<b;++T)O+=t.charAt(I[T]);return O}function l(h){if(typeof h!="string")throw new TypeError("Expected String");if(h.length===0)return new Uint8Array;var y=0;if(h[y]!==" "){for(var g=0,f=0;h[y]===c;)g++,y++;for(var x=(h.length-y)*d+1>>>0,b=new Uint8Array(x);h[y];){var I=r[h.charCodeAt(y)];if(I===255)return;for(var N=0,v=x-1;(I!==0||N<f)&&v!==-1;v--,N++)I+=a*b[v]>>>0,b[v]=I%256>>>0,I=I/256>>>0;if(I!==0)throw new Error("Non-zero carry");f=N,y++}if(h[y]!==" "){for(var S=x-f;S!==x&&b[S]===0;)S++;for(var T=new Uint8Array(g+(x-S)),O=g;S!==x;)T[O++]=b[S++];return T}}}function p(h){var y=l(h);if(y)return y;throw new Error(`Non-${e} character`)}return{encode:u,decodeUnsafe:l,decode:p}}var ic=oc,sc=ic,ni=sc;var on=class{name;prefix;baseEncode;constructor(e,r,n){this.name=e,this.prefix=r,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},sn=class{name;prefix;baseDecode;prefixCodePoint;constructor(e,r,n){this.name=e,this.prefix=r;let o=r.codePointAt(0);if(o===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=o,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 oi(this,e)}},cn=class{decoders;constructor(e){this.decoders=e}or(e){return oi(this,e)}decode(e){let r=e[0],n=this.decoders[r];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 oi(t,e){return new cn({...t.decoders??{[t.prefix]:t},...e.decoders??{[e.prefix]:e}})}var an=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(e,r,n,o){this.name=e,this.prefix=r,this.baseEncode=n,this.baseDecode=o,this.encoder=new on(e,r,n),this.decoder=new sn(e,r,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};function Tt({name:t,prefix:e,encode:r,decode:n}){return new an(t,e,r,n)}function tt({name:t,prefix:e,alphabet:r}){let{encode:n,decode:o}=ni(r,t);return Tt({prefix:e,name:t,encode:n,decode:i=>pe(o(i))})}function cc(t,e,r,n){let o={};for(let m=0;m<e.length;++m)o[e[m]]=m;let i=t.length;for(;t[i-1]==="=";)--i;let s=new Uint8Array(i*r/8|0),a=0,c=0,d=0;for(let m=0;m<i;++m){let u=o[t[m]];if(u===void 0)throw new SyntaxError(`Non-${n} character`);c=c<<r|u,a+=r,a>=8&&(a-=8,s[d++]=255&c>>a)}if(a>=r||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return s}function ac(t,e,r){let n=e[e.length-1]==="=",o=(1<<r)-1,i="",s=0,a=0;for(let c=0;c<t.length;++c)for(a=a<<8|t[c],s+=8;s>r;)s-=r,i+=e[o&a>>s];if(s!==0&&(i+=e[o&a<<r-s]),n)for(;i.length*r&7;)i+="=";return i}function F({name:t,prefix:e,bitsPerChar:r,alphabet:n}){return Tt({prefix:e,name:t,encode(o){return ac(o,n,r)},decode(o){return cc(o,n,r,t)}})}var K=tt({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),dc=tt({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var un={};re(un,{base32:()=>$e,base32hex:()=>pc,base32hexpad:()=>mc,base32hexpadupper:()=>yc,base32hexupper:()=>gc,base32pad:()=>lc,base32padupper:()=>hc,base32upper:()=>uc,base32z:()=>fc});var $e=F({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),uc=F({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),lc=F({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),hc=F({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),pc=F({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),gc=F({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),mc=F({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),yc=F({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),fc=F({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var ln={};re(ln,{base36:()=>jt,base36upper:()=>wc});var jt=tt({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),wc=tt({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var xc=ci,ii=128,Ec=127,bc=~Ec,Ic=Math.pow(2,31);function ci(t,e,r){e=e||[],r=r||0;for(var n=r;t>=Ic;)e[r++]=t&255|ii,t/=128;for(;t&bc;)e[r++]=t&255|ii,t>>>=7;return e[r]=t|0,ci.bytes=r-n+1,e}var vc=hn,Sc=128,si=127;function hn(t,n){var r=0,n=n||0,o=0,i=n,s,a=t.length;do{if(i>=a)throw hn.bytes=0,new RangeError("Could not decode varint");s=t[i++],r+=o<28?(s&si)<<o:(s&si)*Math.pow(2,o),o+=7}while(s>=Sc);return hn.bytes=i-n,r}var Ac=Math.pow(2,7),Bc=Math.pow(2,14),Uc=Math.pow(2,21),Lc=Math.pow(2,28),Tc=Math.pow(2,35),Nc=Math.pow(2,42),Oc=Math.pow(2,49),Cc=Math.pow(2,56),Pc=Math.pow(2,63),Rc=function(t){return t<Ac?1:t<Bc?2:t<Uc?3:t<Lc?4:t<Tc?5:t<Nc?6:t<Oc?7:t<Cc?8:t<Pc?9:10},kc={encode:xc,decode:vc,encodingLength:Rc},Dc=kc,Gt=Dc;function Yt(t,e=0){return[Gt.decode(t,e),Gt.decode.bytes]}function Nt(t,e,r=0){return Gt.encode(t,e,r),e}function Ot(t){return Gt.encodingLength(t)}function ht(t,e){let r=e.byteLength,n=Ot(t),o=n+Ot(r),i=new Uint8Array(o+r);return Nt(t,i,0),Nt(r,i,n),i.set(e,o),new Ct(t,r,e,i)}function pt(t){let e=pe(t),[r,n]=Yt(e),[o,i]=Yt(e.subarray(n)),s=e.subarray(n+i);if(s.byteLength!==o)throw new Error("Incorrect length");return new Ct(r,o,s,e)}function ai(t,e){if(t===e)return!0;{let r=e;return t.code===r.code&&t.size===r.size&&r.bytes instanceof Uint8Array&&Jo(t.bytes,r.bytes)}}var Ct=class{code;size;digest;bytes;constructor(e,r,n,o){this.code=e,this.size=r,this.digest=n,this.bytes=o}};function di(t,e){let{bytes:r,version:n}=t;switch(n){case 0:return Mc(r,pn(t),e??K.encoder);default:return Fc(r,pn(t),e??$e.encoder)}}var ui=new WeakMap;function pn(t){let e=ui.get(t);if(e==null){let r=new Map;return ui.set(t,r),r}return e}var Q=class t{code;version;multihash;bytes;"/";constructor(e,r,n,o){this.code=r,this.version=e,this.multihash=n,this.bytes=o,this["/"]=o}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:r}=this;if(e!==Xt)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==Kc)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return t.createV0(r)}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:r}=this.multihash,n=ht(e,r);return t.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 t.equals(this,e)}static equals(e,r){let n=r;return n!=null&&e.code===n.code&&e.version===n.version&&ai(e.multihash,n.multihash)}toString(e){return di(this,e)}toJSON(){return{"/":di(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 r=e;if(r instanceof t)return r;if(r["/"]!=null&&r["/"]===r.bytes||r.asCID===r){let{version:n,code:o,multihash:i,bytes:s}=r;return new t(n,o,i,s??li(n,o,i.bytes))}else if(r[qc]===!0){let{version:n,multihash:o,code:i}=r,s=pt(o);return t.create(n,i,s)}else return null}static create(e,r,n){if(typeof r!="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(r!==Xt)throw new Error(`Version 0 CID must use dag-pb (code: ${Xt}) block encoding`);return new t(e,r,n,n.bytes)}case 1:{let o=li(e,r,n.bytes);return new t(e,r,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return t.create(0,Xt,e)}static createV1(e,r){return t.create(1,e,r)}static decode(e){let[r,n]=t.decodeFirst(e);if(n.length!==0)throw new Error("Incorrect length");return r}static decodeFirst(e){let r=t.inspectBytes(e),n=r.size-r.multihashSize,o=pe(e.subarray(n,n+r.multihashSize));if(o.byteLength!==r.multihashSize)throw new Error("Incorrect length");let i=o.subarray(r.multihashSize-r.digestSize),s=new Ct(r.multihashCode,r.digestSize,i,o);return[r.version===0?t.createV0(s):t.createV1(r.codec,s),e.subarray(r.size)]}static inspectBytes(e){let r=0,n=()=>{let[u,l]=Yt(e.subarray(r));return r+=l,u},o=n(),i=Xt;if(o===18?(o=0,r=0):i=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let s=r,a=n(),c=n(),d=r+c,m=d-s;return{version:o,codec:i,multihashCode:a,digestSize:c,multihashSize:m,size:d}}static parse(e,r){let[n,o]=_c(e,r),i=t.decode(o);if(i.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return pn(i).set(n,e),i}};function _c(t,e){switch(t[0]){case"Q":{let r=e??K;return[K.prefix,r.decode(`${K.prefix}${t}`)]}case K.prefix:{let r=e??K;return[K.prefix,r.decode(t)]}case $e.prefix:{let r=e??$e;return[$e.prefix,r.decode(t)]}case jt.prefix:{let r=e??jt;return[jt.prefix,r.decode(t)]}default:{if(e==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[t[0],e.decode(t)]}}}function Mc(t,e,r){let{prefix:n}=r;if(n!==K.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);let o=e.get(n);if(o==null){let i=r.encode(t).slice(1);return e.set(n,i),i}else return o}function Fc(t,e,r){let{prefix:n}=r,o=e.get(n);if(o==null){let i=r.encode(t);return e.set(n,i),i}else return o}var Xt=112,Kc=18;function li(t,e,r){let n=Ot(t),o=n+Ot(e),i=new Uint8Array(o+r.byteLength);return Nt(t,i,0),Nt(e,i,n),i.set(r,o),i}var qc=Symbol.for("@ipld/js-cid/CID");var gn={};re(gn,{identity:()=>ze});var hi=0,$c="identity",pi=pe;function zc(t){return ht(hi,pi(t))}var ze={code:hi,name:$c,encode:pi,digest:zc};function Ve(t,e){if(t===e)return!0;if(t.byteLength!==e.byteLength)return!1;for(let r=0;r<t.byteLength;r++)if(t[r]!==e[r])return!1;return!0}var yr=Bt(te("crypto"),1);var gi=te("node:buffer");function Pt(t){return new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}function Oe(t,e){return Pt(gi.Buffer.concat(t,e))}var Ei=te("node:buffer");var mn={};re(mn,{base10:()=>Vc});var Vc=tt({prefix:"9",name:"base10",alphabet:"0123456789"});var yn={};re(yn,{base16:()=>Hc,base16upper:()=>jc});var Hc=F({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),jc=F({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var fn={};re(fn,{base2:()=>Gc});var Gc=F({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var wn={};re(wn,{base256emoji:()=>Qc});var mi=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}"),Yc=mi.reduce((t,e,r)=>(t[r]=e,t),[]),Xc=mi.reduce((t,e,r)=>{let n=e.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${e}`);return t[n]=r,t},[]);function Zc(t){return t.reduce((e,r)=>(e+=Yc[r],e),"")}function Wc(t){let e=[];for(let r of t){let n=r.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${r}`);let o=Xc[n];if(o==null)throw new Error(`Non-base256emoji character: ${r}`);e.push(o)}return new Uint8Array(e)}var Qc=Tt({prefix:"\u{1F680}",name:"base256emoji",encode:Zc,decode:Wc});var xn={};re(xn,{base64:()=>Jc,base64pad:()=>ea,base64url:()=>ta,base64urlpad:()=>ra});var Jc=F({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),ea=F({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),ta=F({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),ra=F({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var En={};re(En,{base8:()=>na});var na=F({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var bn={};re(bn,{identity:()=>oa});var oa=Tt({prefix:"\0",name:"identity",encode:t=>ti(t),decode:t=>ei(t)});var el=new TextEncoder,tl=new TextDecoder;var Bn={};re(Bn,{sha256:()=>An,sha512:()=>ca});var Sn=Bt(te("crypto"),1);function vn({name:t,code:e,encode:r}){return new In(t,e,r)}var In=class{name;code;encode;constructor(e,r,n){this.name=e,this.code=r,this.encode=n}digest(e){if(e instanceof Uint8Array){let r=this.encode(e);return r instanceof Uint8Array?ht(this.code,r):r.then(n=>ht(this.code,n))}else throw Error("Unknown type, must be binary type")}};var An=vn({name:"sha2-256",code:18,encode:t=>pe(Sn.default.createHash("sha256").update(t).digest())}),ca=vn({name:"sha2-512",code:19,encode:t=>pe(Sn.default.createHash("sha512").update(t).digest())});var Zt={...bn,...fn,...En,...mn,...yn,...un,...ln,...dn,...xn,...wn},gl={...Bn,...gn};var fi=te("node:buffer");function He(t=0){return Pt(fi.Buffer.allocUnsafe(t))}function xi(t,e,r,n){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:n}}}var wi=xi("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),Un=xi("ascii","a",t=>{let e="a";for(let r=0;r<t.length;r++)e+=String.fromCharCode(t[r]);return e},t=>{t=t.substring(1);let e=He(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}),aa={utf8:wi,"utf-8":wi,hex:Zt.base16,latin1:Un,ascii:Un,binary:Un,...Zt},mr=aa;function rt(t,e="utf8"){let r=mr[e];if(r==null)throw new Error(`Unsupported encoding "${e}"`);return e==="utf8"||e==="utf-8"?Pt(Ei.Buffer.from(t,"utf-8")):r.decoder.decode(`${r.prefix}${t}`)}var bi=te("node:buffer");function $(t,e="utf8"){let r=mr[e];if(r==null)throw new Error(`Unsupported encoding "${e}"`);return e==="utf8"||e==="utf-8"?bi.Buffer.from(t.buffer,t.byteOffset,t.byteLength).toString("utf8"):r.encoder.encode(t).substring(1)}var Tl=yr.default.generateKeyPairSync,Wt=32;var da=64;function Ii(t,e,r){if(t.byteLength!==Wt)throw new TypeError('"key" must be 32 bytes in length.');if(!(t instanceof Uint8Array))throw new TypeError('"key" must be a node.js Buffer, or Uint8Array.');if(e.byteLength!==da)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=yr.default.createPublicKey({format:"jwk",key:{crv:"Ed25519",x:$(t,"base64url"),kty:"OKP"}});return yr.default.verify(null,r instanceof Uint8Array?r:r.subarray(),n,e)}var fr=class{type="Ed25519";raw;constructor(e){this.raw=Ln(e,Wt)}toMultihash(){return ze.digest(wr(this))}toCID(){return Q.createV1(114,this.toMultihash())}toString(){return K.encode(this.toMultihash().bytes).substring(1)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:Ve(this.raw,e.raw)}verify(e,r){return Ii(this.raw,r,e)}};function Si(t){return t=Ln(t,Wt),new fr(t)}function Ln(t,e){if(t=Uint8Array.from(t??[]),t.length!==e)throw new Ut(`Key must be a Uint8Array of length ${e}, got ${t.length}`);return t}var la=Math.pow(2,7),ha=Math.pow(2,14),pa=Math.pow(2,21),Tn=Math.pow(2,28),Nn=Math.pow(2,35),On=Math.pow(2,42),Cn=Math.pow(2,49),R=128,Y=127;function oe(t){if(t<la)return 1;if(t<ha)return 2;if(t<pa)return 3;if(t<Tn)return 4;if(t<Nn)return 5;if(t<On)return 6;if(t<Cn)return 7;if(Number.MAX_SAFE_INTEGER!=null&&t>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function Pn(t,e,r=0){switch(oe(t)){case 8:e[r++]=t&255|R,t/=128;case 7:e[r++]=t&255|R,t/=128;case 6:e[r++]=t&255|R,t/=128;case 5:e[r++]=t&255|R,t/=128;case 4:e[r++]=t&255|R,t>>>=7;case 3:e[r++]=t&255|R,t>>>=7;case 2:e[r++]=t&255|R,t>>>=7;case 1:{e[r++]=t&255,t>>>=7;break}default:throw new Error("unreachable")}return e}function ga(t,e,r=0){switch(oe(t)){case 8:e.set(r++,t&255|R),t/=128;case 7:e.set(r++,t&255|R),t/=128;case 6:e.set(r++,t&255|R),t/=128;case 5:e.set(r++,t&255|R),t/=128;case 4:e.set(r++,t&255|R),t>>>=7;case 3:e.set(r++,t&255|R),t>>>=7;case 2:e.set(r++,t&255|R),t>>>=7;case 1:{e.set(r++,t&255),t>>>=7;break}default:throw new Error("unreachable")}return e}function Rn(t,e){let r=t[e],n=0;if(n+=r&Y,r<R||(r=t[e+1],n+=(r&Y)<<7,r<R)||(r=t[e+2],n+=(r&Y)<<14,r<R)||(r=t[e+3],n+=(r&Y)<<21,r<R)||(r=t[e+4],n+=(r&Y)*Tn,r<R)||(r=t[e+5],n+=(r&Y)*Nn,r<R)||(r=t[e+6],n+=(r&Y)*On,r<R)||(r=t[e+7],n+=(r&Y)*Cn,r<R))return n;throw new RangeError("Could not decode varint")}function ma(t,e){let r=t.get(e),n=0;if(n+=r&Y,r<R||(r=t.get(e+1),n+=(r&Y)<<7,r<R)||(r=t.get(e+2),n+=(r&Y)<<14,r<R)||(r=t.get(e+3),n+=(r&Y)<<21,r<R)||(r=t.get(e+4),n+=(r&Y)*Tn,r<R)||(r=t.get(e+5),n+=(r&Y)*Nn,r<R)||(r=t.get(e+6),n+=(r&Y)*On,r<R)||(r=t.get(e+7),n+=(r&Y)*Cn,r<R))return n;throw new RangeError("Could not decode varint")}function Rt(t,e,r=0){return e==null&&(e=He(oe(t))),e instanceof Uint8Array?Pn(t,e,r):ga(t,e,r)}function mt(t,e=0){return t instanceof Uint8Array?Rn(t,e):ma(t,e)}var kn=new Float32Array([-0]),nt=new Uint8Array(kn.buffer);function Bi(t,e,r){kn[0]=t,e[r]=nt[0],e[r+1]=nt[1],e[r+2]=nt[2],e[r+3]=nt[3]}function Ui(t,e){return nt[0]=t[e],nt[1]=t[e+1],nt[2]=t[e+2],nt[3]=t[e+3],kn[0]}var Dn=new Float64Array([-0]),X=new Uint8Array(Dn.buffer);function Li(t,e,r){Dn[0]=t,e[r]=X[0],e[r+1]=X[1],e[r+2]=X[2],e[r+3]=X[3],e[r+4]=X[4],e[r+5]=X[5],e[r+6]=X[6],e[r+7]=X[7]}function Ti(t,e){return X[0]=t[e],X[1]=t[e+1],X[2]=t[e+2],X[3]=t[e+3],X[4]=t[e+4],X[5]=t[e+5],X[6]=t[e+6],X[7]=t[e+7],Dn[0]}var ya=BigInt(Number.MAX_SAFE_INTEGER),fa=BigInt(Number.MIN_SAFE_INTEGER),de=class t{lo;hi;constructor(e,r){this.lo=e|0,this.hi=r|0}toNumber(e=!1){if(!e&&this.hi>>>31>0){let r=~this.lo+1>>>0,n=~this.hi>>>0;return r===0&&(n=n+1>>>0),-(r+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 r=~this.lo+1>>>0,n=~this.hi>>>0;return r===0&&(n=n+1>>>0),-(BigInt(r)+(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,r=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return n===0?r===0?e<16384?e<128?1:2:e<2097152?3:4:r<16384?r<128?5:6:r<2097152?7:8:n<128?9:10}static fromBigInt(e){if(e===0n)return yt;if(e<ya&&e>fa)return this.fromNumber(Number(e));let r=e<0n;r&&(e=-e);let n=e>>32n,o=e-(n<<32n);return r&&(n=~n|0n,o=~o|0n,++o>Ni&&(o=0n,++n>Ni&&(n=0n))),new t(Number(o),Number(n))}static fromNumber(e){if(e===0)return yt;let r=e<0;r&&(e=-e);let n=e>>>0,o=(e-n)/4294967296>>>0;return r&&(o=~o>>>0,n=~n>>>0,++n>4294967295&&(n=0,++o>4294967295&&(o=0))),new t(n,o)}static from(e){return typeof e=="number"?t.fromNumber(e):typeof e=="bigint"?t.fromBigInt(e):typeof e=="string"?t.fromBigInt(BigInt(e)):e.low!=null||e.high!=null?new t(e.low>>>0,e.high>>>0):yt}},yt=new de(0,0);yt.toBigInt=function(){return 0n};yt.zzEncode=yt.zzDecode=function(){return this};yt.length=function(){return 1};var Ni=4294967296n;function Oi(t){let e=0,r=0;for(let n=0;n<t.length;++n)r=t.charCodeAt(n),r<128?e+=1:r<2048?e+=2:(r&64512)===55296&&(t.charCodeAt(n+1)&64512)===56320?(++n,e+=4):e+=3;return e}function Ci(t,e,r){if(r-e<1)return"";let o,i=[],s=0,a;for(;e<r;)a=t[e++],a<128?i[s++]=a:a>191&&a<224?i[s++]=(a&31)<<6|t[e++]&63:a>239&&a<365?(a=((a&7)<<18|(t[e++]&63)<<12|(t[e++]&63)<<6|t[e++]&63)-65536,i[s++]=55296+(a>>10),i[s++]=56320+(a&1023)):i[s++]=(a&15)<<12|(t[e++]&63)<<6|t[e++]&63,s>8191&&((o??(o=[])).push(String.fromCharCode.apply(String,i)),s=0);return o!=null?(s>0&&o.push(String.fromCharCode.apply(String,i.slice(0,s))),o.join("")):String.fromCharCode.apply(String,i.slice(0,s))}function _n(t,e,r){let n=r,o,i;for(let s=0;s<t.length;++s)o=t.charCodeAt(s),o<128?e[r++]=o:o<2048?(e[r++]=o>>6|192,e[r++]=o&63|128):(o&64512)===55296&&((i=t.charCodeAt(s+1))&64512)===56320?(o=65536+((o&1023)<<10)+(i&1023),++s,e[r++]=o>>18|240,e[r++]=o>>12&63|128,e[r++]=o>>6&63|128,e[r++]=o&63|128):(e[r++]=o>>12|224,e[r++]=o>>6&63|128,e[r++]=o&63|128);return r-n}function Ee(t,e){return RangeError(`index out of range: ${t.pos} + ${e??1} > ${t.len}`)}function xr(t,e){return(t[e-4]|t[e-3]<<8|t[e-2]<<16|t[e-1]<<24)>>>0}var Mn=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,Ee(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 Ee(this,4);return xr(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw Ee(this,4);return xr(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw Ee(this,4);let e=Ui(this.buf,this.pos);return this.pos+=4,e}double(){if(this.pos+8>this.len)throw Ee(this,4);let e=Ti(this.buf,this.pos);return this.pos+=8,e}bytes(){let e=this.uint32(),r=this.pos,n=this.pos+e;if(n>this.len)throw Ee(this,e);return this.pos+=e,r===n?new Uint8Array(0):this.buf.subarray(r,n)}string(){let e=this.bytes();return Ci(e,0,e.length)}skip(e){if(typeof e=="number"){if(this.pos+e>this.len)throw Ee(this,e);this.pos+=e}else do if(this.pos>=this.len)throw Ee(this);while(this.buf[this.pos++]&128);return this}skipType(e){switch(e){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(e=this.uint32()&7)!==4;)this.skipType(e);break;case 5:this.skip(4);break;default:throw Error(`invalid wire type ${e} at offset ${this.pos}`)}return this}readLongVarint(){let e=new de(0,0),r=0;if(this.len-this.pos>4){for(;r<4;++r)if(e.lo=(e.lo|(this.buf[this.pos]&127)<<r*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;r=0}else{for(;r<3;++r){if(this.pos>=this.len)throw Ee(this);if(e.lo=(e.lo|(this.buf[this.pos]&127)<<r*7)>>>0,this.buf[this.pos++]<128)return e}return e.lo=(e.lo|(this.buf[this.pos++]&127)<<r*7)>>>0,e}if(this.len-this.pos>4){for(;r<5;++r)if(e.hi=(e.hi|(this.buf[this.pos]&127)<<r*7+3)>>>0,this.buf[this.pos++]<128)return e}else for(;r<5;++r){if(this.pos>=this.len)throw Ee(this);if(e.hi=(e.hi|(this.buf[this.pos]&127)<<r*7+3)>>>0,this.buf[this.pos++]<128)return e}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw Ee(this,8);let e=xr(this.buf,this.pos+=4),r=xr(this.buf,this.pos+=4);return new de(e,r)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){let e=Rn(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 Fn(t){return new Mn(t instanceof Uint8Array?t:t.subarray())}function Er(t,e,r){let n=Fn(t);return e.decode(n,void 0,r)}function Kn(t){let e=t??8192,r=e>>>1,n,o=e;return function(s){if(s<1||s>r)return He(s);o+s>e&&(n=He(e),o=0);let a=n.subarray(o,o+=s);return o&7&&(o=(o|7)+1),a}}var ft=class{fn;len;next;val;constructor(e,r,n){this.fn=e,this.len=r,this.next=void 0,this.val=n}};function qn(){}var zn=class{head;tail;len;next;constructor(e){this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}},wa=Kn();function xa(t){return globalThis.Buffer!=null?He(t):wa(t)}var Jt=class{len;head;tail;states;constructor(){this.len=0,this.head=new ft(qn,0,0),this.tail=this.head,this.states=null}_push(e,r,n){return this.tail=this.tail.next=new ft(e,r,n),this.len+=r,this}uint32(e){return this.len+=(this.tail=this.tail.next=new Vn((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(br,10,de.fromNumber(e)):this.uint32(e)}sint32(e){return this.uint32((e<<1^e>>31)>>>0)}uint64(e){let r=de.fromBigInt(e);return this._push(br,r.length(),r)}uint64Number(e){return this._push(Pn,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 r=de.fromBigInt(e).zzEncode();return this._push(br,r.length(),r)}sint64Number(e){let r=de.fromNumber(e).zzEncode();return this._push(br,r.length(),r)}sint64String(e){return this.sint64(BigInt(e))}bool(e){return this._push($n,1,e?1:0)}fixed32(e){return this._push(Qt,4,e>>>0)}sfixed32(e){return this.fixed32(e)}fixed64(e){let r=de.fromBigInt(e);return this._push(Qt,4,r.lo)._push(Qt,4,r.hi)}fixed64Number(e){let r=de.fromNumber(e);return this._push(Qt,4,r.lo)._push(Qt,4,r.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(Bi,4,e)}double(e){return this._push(Li,8,e)}bytes(e){let r=e.length>>>0;return r===0?this._push($n,1,0):this.uint32(r)._push(ba,r,e)}string(e){let r=Oi(e);return r!==0?this.uint32(r)._push(_n,r,e):this._push($n,1,0)}fork(){return this.states=new zn(this),this.head=this.tail=new ft(qn,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 ft(qn,0,0),this.len=0),this}ldelim(){let e=this.head,r=this.tail,n=this.len;return this.reset().uint32(n),n!==0&&(this.tail.next=e.next,this.tail=r,this.len+=n),this}finish(){let e=this.head.next,r=xa(this.len),n=0;for(;e!=null;)e.fn(e.val,r,n),n+=e.len,e=e.next;return r}};function $n(t,e,r){e[r]=t&255}function Ea(t,e,r){for(;t>127;)e[r++]=t&127|128,t>>>=7;e[r]=t}var Vn=class extends ft{next;constructor(e,r){super(Ea,e,r),this.next=void 0}};function br(t,e,r){for(;t.hi!==0;)e[r++]=t.lo&127|128,t.lo=(t.lo>>>7|t.hi<<25)>>>0,t.hi>>>=7;for(;t.lo>127;)e[r++]=t.lo&127|128,t.lo=t.lo>>>7;e[r++]=t.lo}function Qt(t,e,r){e[r]=t&255,e[r+1]=t>>>8&255,e[r+2]=t>>>16&255,e[r+3]=t>>>24}function ba(t,e,r){e.set(t,r)}globalThis.Buffer!=null&&(Jt.prototype.bytes=function(t){let e=t.length>>>0;return this.uint32(e),e>0&&this._push(Ia,e,t),this},Jt.prototype.string=function(t){let e=globalThis.Buffer.byteLength(t);return this.uint32(e),e>0&&this._push(va,e,t),this});function Ia(t,e,r){e.set(t,r)}function va(t,e,r){t.length<40?_n(t,e,r):e.utf8Write!=null?e.utf8Write(t,r):e.set(rt(t),r)}function Hn(){return new Jt}function Ir(t,e){let r=Hn();return e.encode(t,r,{lengthDelimited:!1}),r.finish()}var kt;(function(t){t[t.VARINT=0]="VARINT",t[t.BIT64=1]="BIT64",t[t.LENGTH_DELIMITED=2]="LENGTH_DELIMITED",t[t.START_GROUP=3]="START_GROUP",t[t.END_GROUP=4]="END_GROUP",t[t.BIT32=5]="BIT32"})(kt||(kt={}));function vr(t,e,r,n){return{name:t,type:e,encode:r,decode:n}}function jn(t){function e(o){if(t[o.toString()]==null)throw new Error("Invalid enum value");return t[o]}let r=function(i,s){let a=e(i);s.int32(a)},n=function(i){let s=i.int32();return e(s)};return vr("enum",kt.VARINT,r,n)}function Sr(t,e){return vr("message",kt.LENGTH_DELIMITED,t,e)}var ge;(function(t){t.RSA="RSA",t.Ed25519="Ed25519",t.secp256k1="secp256k1"})(ge||(ge={}));var Gn;(function(t){t[t.RSA=0]="RSA",t[t.Ed25519=1]="Ed25519",t[t.secp256k1=2]="secp256k1"})(Gn||(Gn={}));(function(t){t.codec=()=>jn(Gn)})(ge||(ge={}));var er;(function(t){let e;t.codec=()=>(e==null&&(e=Sr((r,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),r.Type!=null&&(n.uint32(8),ge.codec().encode(r.Type,n)),r.Data!=null&&(n.uint32(18),n.bytes(r.Data)),o.lengthDelimited!==!1&&n.ldelim()},(r,n,o={})=>{let i={},s=n==null?r.len:r.pos+n;for(;r.pos<s;){let a=r.uint32();switch(a>>>3){case 1:{i.Type=ge.codec().decode(r);break}case 2:{i.Data=r.bytes();break}default:{r.skipType(a&7);break}}}return i})),e),t.encode=r=>Ir(r,t.codec()),t.decode=(r,n)=>Er(r,t.codec(),n)})(er||(er={}));var Yn;(function(t){let e;t.codec=()=>(e==null&&(e=Sr((r,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),r.Type!=null&&(n.uint32(8),ge.codec().encode(r.Type,n)),r.Data!=null&&(n.uint32(18),n.bytes(r.Data)),o.lengthDelimited!==!1&&n.ldelim()},(r,n,o={})=>{let i={},s=n==null?r.len:r.pos+n;for(;r.pos<s;){let a=r.uint32();switch(a>>>3){case 1:{i.Type=ge.codec().decode(r);break}case 2:{i.Data=r.bytes();break}default:{r.skipType(a&7);break}}}return i})),e),t.encode=r=>Ir(r,t.codec()),t.decode=(r,n)=>Er(r,t.codec(),n)})(Yn||(Yn={}));function Ri(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`positive integer expected, not ${t}`)}function Aa(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}function Dt(t,...e){if(!Aa(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error(`Uint8Array expected of length ${e}, not of length=${t.length}`)}function ki(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");Ri(t.outputLen),Ri(t.blockLen)}function _t(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function Di(t,e){Dt(t);let r=e.outputLen;if(t.length<r)throw new Error(`digestInto() expects output buffer of length at least ${r}`)}var je=Bt(te("node:crypto"),1),wt=je&&typeof je=="object"&&"webcrypto"in je?je.webcrypto:je&&typeof je=="object"&&"randomBytes"in je?je:void 0;var Ar=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),be=(t,e)=>t<<32-e|t>>>e;var Lh=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function Ba(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}function tr(t){return typeof t=="string"&&(t=Ba(t)),Dt(t),t}function _i(...t){let e=0;for(let n=0;n<t.length;n++){let o=t[n];Dt(o),e+=o.length}let r=new Uint8Array(e);for(let n=0,o=0;n<t.length;n++){let i=t[n];r.set(i,o),o+=i.length}return r}var Mt=class{clone(){return this._cloneInto()}},Th={}.toString;function Mi(t){let e=n=>t().update(tr(n)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}function Fi(t=32){if(wt&&typeof wt.getRandomValues=="function")return wt.getRandomValues(new Uint8Array(t));if(wt&&typeof wt.randomBytes=="function")return wt.randomBytes(t);throw new Error("crypto.getRandomValues must be defined")}function Ua(t,e,r,n){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,r,n);let o=BigInt(32),i=BigInt(4294967295),s=Number(r>>o&i),a=Number(r&i),c=n?4:0,d=n?0:4;t.setUint32(e+c,s,n),t.setUint32(e+d,a,n)}var Ki=(t,e,r)=>t&e^~t&r,qi=(t,e,r)=>t&e^t&r^e&r,Br=class extends Mt{constructor(e,r,n,o){super(),this.blockLen=e,this.outputLen=r,this.padOffset=n,this.isLE=o,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=Ar(this.buffer)}update(e){_t(this);let{view:r,buffer:n,blockLen:o}=this;e=tr(e);let i=e.length;for(let s=0;s<i;){let a=Math.min(o-this.pos,i-s);if(a===o){let c=Ar(e);for(;o<=i-s;s+=o)this.process(c,s);continue}n.set(e.subarray(s,s+a),this.pos),this.pos+=a,s+=a,this.pos===o&&(this.process(r,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){_t(this),Di(e,this),this.finished=!0;let{buffer:r,view:n,blockLen:o,isLE:i}=this,{pos:s}=this;r[s++]=128,this.buffer.subarray(s).fill(0),this.padOffset>o-s&&(this.process(n,0),s=0);for(let u=s;u<o;u++)r[u]=0;Ua(n,o-8,BigInt(this.length*8),i),this.process(n,0);let a=Ar(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let d=c/4,m=this.get();if(d>m.length)throw new Error("_sha2: outputLen bigger than state");for(let u=0;u<d;u++)a.setUint32(4*u,m[u],i)}digest(){let{buffer:e,outputLen:r}=this;this.digestInto(e);let n=e.slice(0,r);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());let{blockLen:r,buffer:n,length:o,finished:i,destroyed:s,pos:a}=this;return e.length=o,e.pos=a,e.finished=i,e.destroyed=s,o%r&&e.buffer.set(n),e}};var La=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]),ot=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),it=new Uint32Array(64),Xn=class extends Br{constructor(){super(64,32,8,!1),this.A=ot[0]|0,this.B=ot[1]|0,this.C=ot[2]|0,this.D=ot[3]|0,this.E=ot[4]|0,this.F=ot[5]|0,this.G=ot[6]|0,this.H=ot[7]|0}get(){let{A:e,B:r,C:n,D:o,E:i,F:s,G:a,H:c}=this;return[e,r,n,o,i,s,a,c]}set(e,r,n,o,i,s,a,c){this.A=e|0,this.B=r|0,this.C=n|0,this.D=o|0,this.E=i|0,this.F=s|0,this.G=a|0,this.H=c|0}process(e,r){for(let u=0;u<16;u++,r+=4)it[u]=e.getUint32(r,!1);for(let u=16;u<64;u++){let l=it[u-15],p=it[u-2],h=be(l,7)^be(l,18)^l>>>3,y=be(p,17)^be(p,19)^p>>>10;it[u]=y+it[u-7]+h+it[u-16]|0}let{A:n,B:o,C:i,D:s,E:a,F:c,G:d,H:m}=this;for(let u=0;u<64;u++){let l=be(a,6)^be(a,11)^be(a,25),p=m+l+Ki(a,c,d)+La[u]+it[u]|0,y=(be(n,2)^be(n,13)^be(n,22))+qi(n,o,i)|0;m=d,d=c,c=a,a=s+p|0,s=i,i=o,o=n,n=p+y|0}n=n+this.A|0,o=o+this.B|0,i=i+this.C|0,s=s+this.D|0,a=a+this.E|0,c=c+this.F|0,d=d+this.G|0,m=m+this.H|0,this.set(n,o,i,s,a,c,d,m)}roundClean(){it.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var $i=Mi(()=>new Xn);var Ur=class extends Mt{constructor(e,r){super(),this.finished=!1,this.destroyed=!1,ki(e);let n=tr(r);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 o=this.blockLen,i=new Uint8Array(o);i.set(n.length>o?e.create().update(n).digest():n);for(let s=0;s<i.length;s++)i[s]^=54;this.iHash.update(i),this.oHash=e.create();for(let s=0;s<i.length;s++)i[s]^=106;this.oHash.update(i),i.fill(0)}update(e){return _t(this),this.iHash.update(e),this}digestInto(e){_t(this),Dt(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:r,iHash:n,finished:o,destroyed:i,blockLen:s,outputLen:a}=this;return e=e,e.finished=o,e.destroyed=i,e.blockLen=s,e.outputLen=a,e.oHash=r._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},Zn=(t,e,r)=>new Ur(t,e).update(r).digest();Zn.create=(t,e)=>new Ur(t,e);var no={};re(no,{aInRange:()=>at,abool:()=>xt,abytes:()=>Ft,bitGet:()=>Ra,bitLen:()=>to,bitMask:()=>nr,bitSet:()=>ka,bytesToHex:()=>Et,bytesToNumberBE:()=>Ye,bytesToNumberLE:()=>Tr,concatBytes:()=>Kt,createHmacDrbg:()=>ro,ensureBytes:()=>ue,equalBytes:()=>Ca,hexToBytes:()=>It,hexToNumber:()=>eo,inRange:()=>rr,isBytes:()=>st,memoized:()=>Or,notImplemented:()=>_a,numberToBytesBE:()=>ct,numberToBytesLE:()=>Nr,numberToHexUnpadded:()=>bt,numberToVarBytesBE:()=>Oa,utf8ToBytes:()=>Pa,validateObject:()=>dt});var Jn=BigInt(0),Lr=BigInt(1),Ta=BigInt(2);function st(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}function Ft(t){if(!st(t))throw new Error("Uint8Array expected")}function xt(t,e){if(typeof e!="boolean")throw new Error(`${t} must be valid boolean, got "${e}".`)}var Na=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function Et(t){Ft(t);let e="";for(let r=0;r<t.length;r++)e+=Na[t[r]];return e}function bt(t){let e=t.toString(16);return e.length&1?`0${e}`:e}function eo(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return BigInt(t===""?"0":`0x${t}`)}var Ge={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function zi(t){if(t>=Ge._0&&t<=Ge._9)return t-Ge._0;if(t>=Ge._A&&t<=Ge._F)return t-(Ge._A-10);if(t>=Ge._a&&t<=Ge._f)return t-(Ge._a-10)}function It(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);let e=t.length,r=e/2;if(e%2)throw new Error("padded hex string expected, got unpadded hex of length "+e);let n=new Uint8Array(r);for(let o=0,i=0;o<r;o++,i+=2){let s=zi(t.charCodeAt(i)),a=zi(t.charCodeAt(i+1));if(s===void 0||a===void 0){let c=t[i]+t[i+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+i)}n[o]=s*16+a}return n}function Ye(t){return eo(Et(t))}function Tr(t){return Ft(t),eo(Et(Uint8Array.from(t).reverse()))}function ct(t,e){return It(t.toString(16).padStart(e*2,"0"))}function Nr(t,e){return ct(t,e).reverse()}function Oa(t){return It(bt(t))}function ue(t,e,r){let n;if(typeof e=="string")try{n=It(e)}catch(i){throw new Error(`${t} must be valid hex string, got "${e}". Cause: ${i}`)}else if(st(e))n=Uint8Array.from(e);else throw new Error(`${t} must be hex string or Uint8Array`);let o=n.length;if(typeof r=="number"&&o!==r)throw new Error(`${t} expected ${r} bytes, got ${o}`);return n}function Kt(...t){let e=0;for(let n=0;n<t.length;n++){let o=t[n];Ft(o),e+=o.length}let r=new Uint8Array(e);for(let n=0,o=0;n<t.length;n++){let i=t[n];r.set(i,o),o+=i.length}return r}function Ca(t,e){if(t.length!==e.length)return!1;let r=0;for(let n=0;n<t.length;n++)r|=t[n]^e[n];return r===0}function Pa(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}var Wn=t=>typeof t=="bigint"&&Jn<=t;function rr(t,e,r){return Wn(t)&&Wn(e)&&Wn(r)&&e<=t&&t<r}function at(t,e,r,n){if(!rr(e,r,n))throw new Error(`expected valid ${t}: ${r} <= n < ${n}, got ${typeof e} ${e}`)}function to(t){let e;for(e=0;t>Jn;t>>=Lr,e+=1);return e}function Ra(t,e){return t>>BigInt(e)&Lr}function ka(t,e,r){return t|(r?Lr:Jn)<<BigInt(e)}var nr=t=>(Ta<<BigInt(t-1))-Lr,Qn=t=>new Uint8Array(t),Vi=t=>Uint8Array.from(t);function ro(t,e,r){if(typeof t!="number"||t<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 r!="function")throw new Error("hmacFn must be a function");let n=Qn(t),o=Qn(t),i=0,s=()=>{n.fill(1),o.fill(0),i=0},a=(...u)=>r(o,n,...u),c=(u=Qn())=>{o=a(Vi([0]),u),n=a(),u.length!==0&&(o=a(Vi([1]),u),n=a())},d=()=>{if(i++>=1e3)throw new Error("drbg: tried 1000 values");let u=0,l=[];for(;u<e;){n=a();let p=n.slice();l.push(p),u+=n.length}return Kt(...l)};return(u,l)=>{s(),c(u);let p;for(;!(p=l(d()));)c();return s(),p}}var Da={bigint:t=>typeof t=="bigint",function:t=>typeof t=="function",boolean:t=>typeof t=="boolean",string:t=>typeof t=="string",stringOrUint8Array:t=>typeof t=="string"||st(t),isSafeInteger:t=>Number.isSafeInteger(t),array:t=>Array.isArray(t),field:(t,e)=>e.Fp.isValid(t),hash:t=>typeof t=="function"&&Number.isSafeInteger(t.outputLen)};function dt(t,e,r={}){let n=(o,i,s)=>{let a=Da[i];if(typeof a!="function")throw new Error(`Invalid validator "${i}", expected function`);let c=t[o];if(!(s&&c===void 0)&&!a(c,t))throw new Error(`Invalid param ${String(o)}=${c} (${typeof c}), expected ${i}`)};for(let[o,i]of Object.entries(e))n(o,i,!1);for(let[o,i]of Object.entries(r))n(o,i,!0);return t}var _a=()=>{throw new Error("not implemented")};function Or(t){let e=new WeakMap;return(r,...n)=>{let o=e.get(r);if(o!==void 0)return o;let i=t(r,...n);return e.set(r,i),i}}var z=BigInt(0),q=BigInt(1),vt=BigInt(2),Ma=BigInt(3),oo=BigInt(4),Hi=BigInt(5),ji=BigInt(8),Fa=BigInt(9),Ka=BigInt(16);function Z(t,e){let r=t%e;return r>=z?r:e+r}function qa(t,e,r){if(r<=z||e<z)throw new Error("Expected power/modulo > 0");if(r===q)return z;let n=q;for(;e>z;)e&q&&(n=n*t%r),t=t*t%r,e>>=q;return n}function le(t,e,r){let n=t;for(;e-- >z;)n*=n,n%=r;return n}function Cr(t,e){if(t===z||e<=z)throw new Error(`invert: expected positive integers, got n=${t} mod=${e}`);let r=Z(t,e),n=e,o=z,i=q,s=q,a=z;for(;r!==z;){let d=n/r,m=n%r,u=o-s*d,l=i-a*d;n=r,r=m,o=s,i=a,s=u,a=l}if(n!==q)throw new Error("invert: does not exist");return Z(o,e)}function $a(t){let e=(t-q)/vt,r,n,o;for(r=t-q,n=0;r%vt===z;r/=vt,n++);for(o=vt;o<t&&qa(o,e,t)!==t-q;o++);if(n===1){let s=(t+q)/oo;return function(c,d){let m=c.pow(d,s);if(!c.eql(c.sqr(m),d))throw new Error("Cannot find square root");return m}}let i=(r+q)/vt;return function(a,c){if(a.pow(c,e)===a.neg(a.ONE))throw new Error("Cannot find square root");let d=n,m=a.pow(a.mul(a.ONE,o),r),u=a.pow(c,i),l=a.pow(c,r);for(;!a.eql(l,a.ONE);){if(a.eql(l,a.ZERO))return a.ZERO;let p=1;for(let y=a.sqr(l);p<d&&!a.eql(y,a.ONE);p++)y=a.sqr(y);let h=a.pow(m,q<<BigInt(d-p-1));m=a.sqr(h),u=a.mul(u,h),l=a.mul(l,m),d=p}return u}}function za(t){if(t%oo===Ma){let e=(t+q)/oo;return function(n,o){let i=n.pow(o,e);if(!n.eql(n.sqr(i),o))throw new Error("Cannot find square root");return i}}if(t%ji===Hi){let e=(t-Hi)/ji;return function(n,o){let i=n.mul(o,vt),s=n.pow(i,e),a=n.mul(o,s),c=n.mul(n.mul(a,vt),s),d=n.mul(a,n.sub(c,n.ONE));if(!n.eql(n.sqr(d),o))throw new Error("Cannot find square root");return d}}return t%Ka,$a(t)}var Va=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function io(t){let e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},r=Va.reduce((n,o)=>(n[o]="function",n),e);return dt(t,r)}function Ha(t,e,r){if(r<z)throw new Error("Expected power > 0");if(r===z)return t.ONE;if(r===q)return e;let n=t.ONE,o=e;for(;r>z;)r&q&&(n=t.mul(n,o)),o=t.sqr(o),r>>=q;return n}function ja(t,e){let r=new Array(e.length),n=e.reduce((i,s,a)=>t.is0(s)?i:(r[a]=i,t.mul(i,s)),t.ONE),o=t.inv(n);return e.reduceRight((i,s,a)=>t.is0(s)?i:(r[a]=t.mul(i,r[a]),t.mul(i,s)),o),r}function so(t,e){let r=e!==void 0?e:t.toString(2).length,n=Math.ceil(r/8);return{nBitLength:r,nByteLength:n}}function Pr(t,e,r=!1,n={}){if(t<=z)throw new Error(`Expected Field ORDER > 0, got ${t}`);let{nBitLength:o,nByteLength:i}=so(t,e);if(i>2048)throw new Error("Field lengths over 2048 bytes are not supported");let s=za(t),a=Object.freeze({ORDER:t,BITS:o,BYTES:i,MASK:nr(o),ZERO:z,ONE:q,create:c=>Z(c,t),isValid:c=>{if(typeof c!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof c}`);return z<=c&&c<t},is0:c=>c===z,isOdd:c=>(c&q)===q,neg:c=>Z(-c,t),eql:(c,d)=>c===d,sqr:c=>Z(c*c,t),add:(c,d)=>Z(c+d,t),sub:(c,d)=>Z(c-d,t),mul:(c,d)=>Z(c*d,t),pow:(c,d)=>Ha(a,c,d),div:(c,d)=>Z(c*Cr(d,t),t),sqrN:c=>c*c,addN:(c,d)=>c+d,subN:(c,d)=>c-d,mulN:(c,d)=>c*d,inv:c=>Cr(c,t),sqrt:n.sqrt||(c=>s(a,c)),invertBatch:c=>ja(a,c),cmov:(c,d,m)=>m?d:c,toBytes:c=>r?Nr(c,i):ct(c,i),fromBytes:c=>{if(c.length!==i)throw new Error(`Fp.fromBytes: expected ${i}, got ${c.length}`);return r?Tr(c):Ye(c)}});return Object.freeze(a)}function Gi(t){if(typeof t!="bigint")throw new Error("field order must be bigint");let e=t.toString(2).length;return Math.ceil(e/8)}function co(t){let e=Gi(t);return e+Math.ceil(e/2)}function Yi(t,e,r=!1){let n=t.length,o=Gi(e),i=co(e);if(n<16||n<i||n>1024)throw new Error(`expected ${i}-1024 bytes of input, got ${n}`);let s=r?Ye(t):Tr(t),a=Z(s,e-q)+q;return r?Nr(a,o):ct(a,o)}var Ya=BigInt(0),ao=BigInt(1),uo=new WeakMap,Xi=new WeakMap;function Zi(t,e){let r=(i,s)=>{let a=s.negate();return i?a:s},n=i=>{if(!Number.isSafeInteger(i)||i<=0||i>e)throw new Error(`Wrong window size=${i}, should be [1..${e}]`)},o=i=>{n(i);let s=Math.ceil(e/i)+1,a=2**(i-1);return{windows:s,windowSize:a}};return{constTimeNegate:r,unsafeLadder(i,s){let a=t.ZERO,c=i;for(;s>Ya;)s&ao&&(a=a.add(c)),c=c.double(),s>>=ao;return a},precomputeWindow(i,s){let{windows:a,windowSize:c}=o(s),d=[],m=i,u=m;for(let l=0;l<a;l++){u=m,d.push(u);for(let p=1;p<c;p++)u=u.add(m),d.push(u);m=u.double()}return d},wNAF(i,s,a){let{windows:c,windowSize:d}=o(i),m=t.ZERO,u=t.BASE,l=BigInt(2**i-1),p=2**i,h=BigInt(i);for(let y=0;y<c;y++){let g=y*d,f=Number(a&l);a>>=h,f>d&&(f-=p,a+=ao);let x=g,b=g+Math.abs(f)-1,I=y%2!==0,N=f<0;f===0?u=u.add(r(I,s[x])):m=m.add(r(N,s[b]))}return{p:m,f:u}},wNAFCached(i,s,a){let c=Xi.get(i)||1,d=uo.get(i);return d||(d=this.precomputeWindow(i,c),c!==1&&uo.set(i,a(d))),this.wNAF(c,d,s)},setWindowSize(i,s){n(s),Xi.set(i,s),uo.delete(i)}}}function Wi(t,e,r,n){if(!Array.isArray(r)||!Array.isArray(n)||n.length!==r.length)throw new Error("arrays of points and scalars must have equal length");n.forEach((m,u)=>{if(!e.isValid(m))throw new Error(`wrong scalar at index ${u}`)}),r.forEach((m,u)=>{if(!(m instanceof t))throw new Error(`wrong point at index ${u}`)});let o=to(BigInt(r.length)),i=o>12?o-3:o>4?o-2:o?2:1,s=(1<<i)-1,a=new Array(s+1).fill(t.ZERO),c=Math.floor((e.BITS-1)/i)*i,d=t.ZERO;for(let m=c;m>=0;m-=i){a.fill(t.ZERO);for(let l=0;l<n.length;l++){let p=n[l],h=Number(p>>BigInt(m)&BigInt(s));a[h]=a[h].add(r[l])}let u=t.ZERO;for(let l=a.length-1,p=t.ZERO;l>0;l--)p=p.add(a[l]),u=u.add(p);if(d=d.add(u),m!==0)for(let l=0;l<i;l++)d=d.double()}return d}function lo(t){return io(t.Fp),dt(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...so(t.n,t.nBitLength),...t,p:t.Fp.ORDER})}function Qi(t){t.lowS!==void 0&&xt("lowS",t.lowS),t.prehash!==void 0&&xt("prehash",t.prehash)}function Xa(t){let e=lo(t);dt(e,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});let{endo:r,Fp:n,a:o}=e;if(r){if(!n.eql(o,n.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if(typeof r!="object"||typeof r.beta!="bigint"||typeof r.splitScalar!="function")throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...e})}var{bytesToNumberBE:Za,hexToBytes:Wa}=no,Xe={Err:class extends Error{constructor(e=""){super(e)}},_tlv:{encode:(t,e)=>{let{Err:r}=Xe;if(t<0||t>256)throw new r("tlv.encode: wrong tag");if(e.length&1)throw new r("tlv.encode: unpadded data");let n=e.length/2,o=bt(n);if(o.length/2&128)throw new r("tlv.encode: long form length too big");let i=n>127?bt(o.length/2|128):"";return`${bt(t)}${i}${o}${e}`},decode(t,e){let{Err:r}=Xe,n=0;if(t<0||t>256)throw new r("tlv.encode: wrong tag");if(e.length<2||e[n++]!==t)throw new r("tlv.decode: wrong tlv");let o=e[n++],i=!!(o&128),s=0;if(!i)s=o;else{let c=o&127;if(!c)throw new r("tlv.decode(long): indefinite length not supported");if(c>4)throw new r("tlv.decode(long): byte length is too big");let d=e.subarray(n,n+c);if(d.length!==c)throw new r("tlv.decode: length bytes not complete");if(d[0]===0)throw new r("tlv.decode(long): zero leftmost byte");for(let m of d)s=s<<8|m;if(n+=c,s<128)throw new r("tlv.decode(long): not minimal encoding")}let a=e.subarray(n,n+s);if(a.length!==s)throw new r("tlv.decode: wrong value length");return{v:a,l:e.subarray(n+s)}}},_int:{encode(t){let{Err:e}=Xe;if(t<Ze)throw new e("integer: negative integers are not allowed");let r=bt(t);if(Number.parseInt(r[0],16)&8&&(r="00"+r),r.length&1)throw new e("unexpected assertion");return r},decode(t){let{Err:e}=Xe;if(t[0]&128)throw new e("Invalid signature integer: negative");if(t[0]===0&&!(t[1]&128))throw new e("Invalid signature integer: unnecessary leading zero");return Za(t)}},toSig(t){let{Err:e,_int:r,_tlv:n}=Xe,o=typeof t=="string"?Wa(t):t;Ft(o);let{v:i,l:s}=n.decode(48,o);if(s.length)throw new e("Invalid signature: left bytes after parsing");let{v:a,l:c}=n.decode(2,i),{v:d,l:m}=n.decode(2,c);if(m.length)throw new e("Invalid signature: left bytes after parsing");return{r:r.decode(a),s:r.decode(d)}},hexFromSig(t){let{_tlv:e,_int:r}=Xe,n=`${e.encode(2,r.encode(t.r))}${e.encode(2,r.encode(t.s))}`;return e.encode(48,n)}},Ze=BigInt(0),j=BigInt(1),Gh=BigInt(2),Ji=BigInt(3),Yh=BigInt(4);function Qa(t){let e=Xa(t),{Fp:r}=e,n=Pr(e.n,e.nBitLength),o=e.toBytes||((y,g,f)=>{let x=g.toAffine();return Kt(Uint8Array.from([4]),r.toBytes(x.x),r.toBytes(x.y))}),i=e.fromBytes||(y=>{let g=y.subarray(1),f=r.fromBytes(g.subarray(0,r.BYTES)),x=r.fromBytes(g.subarray(r.BYTES,2*r.BYTES));return{x:f,y:x}});function s(y){let{a:g,b:f}=e,x=r.sqr(y),b=r.mul(x,y);return r.add(r.add(b,r.mul(y,g)),f)}if(!r.eql(r.sqr(e.Gy),s(e.Gx)))throw new Error("bad generator point: equation left != right");function a(y){return rr(y,j,e.n)}function c(y){let{allowedPrivateKeyLengths:g,nByteLength:f,wrapPrivateKey:x,n:b}=e;if(g&&typeof y!="bigint"){if(st(y)&&(y=Et(y)),typeof y!="string"||!g.includes(y.length))throw new Error("Invalid key");y=y.padStart(f*2,"0")}let I;try{I=typeof y=="bigint"?y:Ye(ue("private key",y,f))}catch{throw new Error(`private key must be ${f} bytes, hex or bigint, not ${typeof y}`)}return x&&(I=Z(I,b)),at("private key",I,j,b),I}function d(y){if(!(y instanceof l))throw new Error("ProjectivePoint expected")}let m=Or((y,g)=>{let{px:f,py:x,pz:b}=y;if(r.eql(b,r.ONE))return{x:f,y:x};let I=y.is0();g==null&&(g=I?r.ONE:r.inv(b));let N=r.mul(f,g),v=r.mul(x,g),S=r.mul(b,g);if(I)return{x:r.ZERO,y:r.ZERO};if(!r.eql(S,r.ONE))throw new Error("invZ was invalid");return{x:N,y:v}}),u=Or(y=>{if(y.is0()){if(e.allowInfinityPoint&&!r.is0(y.py))return;throw new Error("bad point: ZERO")}let{x:g,y:f}=y.toAffine();if(!r.isValid(g)||!r.isValid(f))throw new Error("bad point: x or y not FE");let x=r.sqr(f),b=s(g);if(!r.eql(x,b))throw new Error("bad point: equation left != right");if(!y.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class l{constructor(g,f,x){if(this.px=g,this.py=f,this.pz=x,g==null||!r.isValid(g))throw new Error("x required");if(f==null||!r.isValid(f))throw new Error("y required");if(x==null||!r.isValid(x))throw new Error("z required");Object.freeze(this)}static fromAffine(g){let{x:f,y:x}=g||{};if(!g||!r.isValid(f)||!r.isValid(x))throw new Error("invalid affine point");if(g instanceof l)throw new Error("projective point not allowed");let b=I=>r.eql(I,r.ZERO);return b(f)&&b(x)?l.ZERO:new l(f,x,r.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(g){let f=r.invertBatch(g.map(x=>x.pz));return g.map((x,b)=>x.toAffine(f[b])).map(l.fromAffine)}static fromHex(g){let f=l.fromAffine(i(ue("pointHex",g)));return f.assertValidity(),f}static fromPrivateKey(g){return l.BASE.multiply(c(g))}static msm(g,f){return Wi(l,n,g,f)}_setWindowSize(g){h.setWindowSize(this,g)}assertValidity(){u(this)}hasEvenY(){let{y:g}=this.toAffine();if(r.isOdd)return!r.isOdd(g);throw new Error("Field doesn't support isOdd")}equals(g){d(g);let{px:f,py:x,pz:b}=this,{px:I,py:N,pz:v}=g,S=r.eql(r.mul(f,v),r.mul(I,b)),T=r.eql(r.mul(x,v),r.mul(N,b));return S&&T}negate(){return new l(this.px,r.neg(this.py),this.pz)}double(){let{a:g,b:f}=e,x=r.mul(f,Ji),{px:b,py:I,pz:N}=this,v=r.ZERO,S=r.ZERO,T=r.ZERO,O=r.mul(b,b),he=r.mul(I,I),M=r.mul(N,N),D=r.mul(b,I);return D=r.add(D,D),T=r.mul(b,N),T=r.add(T,T),v=r.mul(g,T),S=r.mul(x,M),S=r.add(v,S),v=r.sub(he,S),S=r.add(he,S),S=r.mul(v,S),v=r.mul(D,v),T=r.mul(x,T),M=r.mul(g,M),D=r.sub(O,M),D=r.mul(g,D),D=r.add(D,T),T=r.add(O,O),O=r.add(T,O),O=r.add(O,M),O=r.mul(O,D),S=r.add(S,O),M=r.mul(I,N),M=r.add(M,M),O=r.mul(M,D),v=r.sub(v,O),T=r.mul(M,he),T=r.add(T,T),T=r.add(T,T),new l(v,S,T)}add(g){d(g);let{px:f,py:x,pz:b}=this,{px:I,py:N,pz:v}=g,S=r.ZERO,T=r.ZERO,O=r.ZERO,he=e.a,M=r.mul(e.b,Ji),D=r.mul(f,I),ie=r.mul(x,N),E=r.mul(b,v),A=r.add(f,x),L=r.add(I,N);A=r.mul(A,L),L=r.add(D,ie),A=r.sub(A,L),L=r.add(f,b);let P=r.add(I,v);return L=r.mul(L,P),P=r.add(D,E),L=r.sub(L,P),P=r.add(x,b),S=r.add(N,v),P=r.mul(P,S),S=r.add(ie,E),P=r.sub(P,S),O=r.mul(he,L),S=r.mul(M,E),O=r.add(S,O),S=r.sub(ie,O),O=r.add(ie,O),T=r.mul(S,O),ie=r.add(D,D),ie=r.add(ie,D),E=r.mul(he,E),L=r.mul(M,L),ie=r.add(ie,E),E=r.sub(D,E),E=r.mul(he,E),L=r.add(L,E),D=r.mul(ie,L),T=r.add(T,D),D=r.mul(P,L),S=r.mul(A,S),S=r.sub(S,D),D=r.mul(A,ie),O=r.mul(P,O),O=r.add(O,D),new l(S,T,O)}subtract(g){return this.add(g.negate())}is0(){return this.equals(l.ZERO)}wNAF(g){return h.wNAFCached(this,g,l.normalizeZ)}multiplyUnsafe(g){at("scalar",g,Ze,e.n);let f=l.ZERO;if(g===Ze)return f;if(g===j)return this;let{endo:x}=e;if(!x)return h.unsafeLadder(this,g);let{k1neg:b,k1:I,k2neg:N,k2:v}=x.splitScalar(g),S=f,T=f,O=this;for(;I>Ze||v>Ze;)I&j&&(S=S.add(O)),v&j&&(T=T.add(O)),O=O.double(),I>>=j,v>>=j;return b&&(S=S.negate()),N&&(T=T.negate()),T=new l(r.mul(T.px,x.beta),T.py,T.pz),S.add(T)}multiply(g){let{endo:f,n:x}=e;at("scalar",g,j,x);let b,I;if(f){let{k1neg:N,k1:v,k2neg:S,k2:T}=f.splitScalar(g),{p:O,f:he}=this.wNAF(v),{p:M,f:D}=this.wNAF(T);O=h.constTimeNegate(N,O),M=h.constTimeNegate(S,M),M=new l(r.mul(M.px,f.beta),M.py,M.pz),b=O.add(M),I=he.add(D)}else{let{p:N,f:v}=this.wNAF(g);b=N,I=v}return l.normalizeZ([b,I])[0]}multiplyAndAddUnsafe(g,f,x){let b=l.BASE,I=(v,S)=>S===Ze||S===j||!v.equals(b)?v.multiplyUnsafe(S):v.multiply(S),N=I(this,f).add(I(g,x));return N.is0()?void 0:N}toAffine(g){return m(this,g)}isTorsionFree(){let{h:g,isTorsionFree:f}=e;if(g===j)return!0;if(f)return f(l,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h:g,clearCofactor:f}=e;return g===j?this:f?f(l,this):this.multiplyUnsafe(e.h)}toRawBytes(g=!0){return xt("isCompressed",g),this.assertValidity(),o(l,this,g)}toHex(g=!0){return xt("isCompressed",g),Et(this.toRawBytes(g))}}l.BASE=new l(e.Gx,e.Gy,r.ONE),l.ZERO=new l(r.ZERO,r.ONE,r.ZERO);let p=e.nBitLength,h=Zi(l,e.endo?Math.ceil(p/2):p);return{CURVE:e,ProjectivePoint:l,normPrivateKeyToScalar:c,weierstrassEquation:s,isWithinCurveOrder:a}}function Ja(t){let e=lo(t);return dt(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function es(t){let e=Ja(t),{Fp:r,n}=e,o=r.BYTES+1,i=2*r.BYTES+1;function s(E){return Z(E,n)}function a(E){return Cr(E,n)}let{ProjectivePoint:c,normPrivateKeyToScalar:d,weierstrassEquation:m,isWithinCurveOrder:u}=Qa({...e,toBytes(E,A,L){let P=A.toAffine(),_=r.toBytes(P.x),V=Kt;return xt("isCompressed",L),L?V(Uint8Array.from([A.hasEvenY()?2:3]),_):V(Uint8Array.from([4]),_,r.toBytes(P.y))},fromBytes(E){let A=E.length,L=E[0],P=E.subarray(1);if(A===o&&(L===2||L===3)){let _=Ye(P);if(!rr(_,j,r.ORDER))throw new Error("Point is not on curve");let V=m(_),J;try{J=r.sqrt(V)}catch(ye){let Qe=ye instanceof Error?": "+ye.message:"";throw new Error("Point is not on curve"+Qe)}let ee=(J&j)===j;return(L&1)===1!==ee&&(J=r.neg(J)),{x:_,y:J}}else if(A===i&&L===4){let _=r.fromBytes(P.subarray(0,r.BYTES)),V=r.fromBytes(P.subarray(r.BYTES,2*r.BYTES));return{x:_,y:V}}else throw new Error(`Point of length ${A} was invalid. Expected ${o} compressed bytes or ${i} uncompressed bytes`)}}),l=E=>Et(ct(E,e.nByteLength));function p(E){let A=n>>j;return E>A}function h(E){return p(E)?s(-E):E}let y=(E,A,L)=>Ye(E.slice(A,L));class g{constructor(A,L,P){this.r=A,this.s=L,this.recovery=P,this.assertValidity()}static fromCompact(A){let L=e.nByteLength;return A=ue("compactSignature",A,L*2),new g(y(A,0,L),y(A,L,2*L))}static fromDER(A){let{r:L,s:P}=Xe.toSig(ue("DER",A));return new g(L,P)}assertValidity(){at("r",this.r,j,n),at("s",this.s,j,n)}addRecoveryBit(A){return new g(this.r,this.s,A)}recoverPublicKey(A){let{r:L,s:P,recovery:_}=this,V=v(ue("msgHash",A));if(_==null||![0,1,2,3].includes(_))throw new Error("recovery id invalid");let J=_===2||_===3?L+e.n:L;if(J>=r.ORDER)throw new Error("recovery id 2 or 3 invalid");let ee=_&1?"03":"02",We=c.fromHex(ee+l(J)),ye=a(J),Qe=s(-V*ye),zt=s(P*ye),Je=c.BASE.multiplyAndAddUnsafe(We,Qe,zt);if(!Je)throw new Error("point at infinify");return Je.assertValidity(),Je}hasHighS(){return p(this.s)}normalizeS(){return this.hasHighS()?new g(this.r,s(-this.s),this.recovery):this}toDERRawBytes(){return It(this.toDERHex())}toDERHex(){return Xe.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return It(this.toCompactHex())}toCompactHex(){return l(this.r)+l(this.s)}}let f={isValidPrivateKey(E){try{return d(E),!0}catch{return!1}},normPrivateKeyToScalar:d,randomPrivateKey:()=>{let E=co(e.n);return Yi(e.randomBytes(E),e.n)},precompute(E=8,A=c.BASE){return A._setWindowSize(E),A.multiply(BigInt(3)),A}};function x(E,A=!0){return c.fromPrivateKey(E).toRawBytes(A)}function b(E){let A=st(E),L=typeof E=="string",P=(A||L)&&E.length;return A?P===o||P===i:L?P===2*o||P===2*i:E instanceof c}function I(E,A,L=!0){if(b(E))throw new Error("first arg must be private key");if(!b(A))throw new Error("second arg must be public key");return c.fromHex(A).multiply(d(E)).toRawBytes(L)}let N=e.bits2int||function(E){let A=Ye(E),L=E.length*8-e.nBitLength;return L>0?A>>BigInt(L):A},v=e.bits2int_modN||function(E){return s(N(E))},S=nr(e.nBitLength);function T(E){return at(`num < 2^${e.nBitLength}`,E,Ze,S),ct(E,e.nByteLength)}function O(E,A,L=he){if(["recovered","canonical"].some(ut=>ut in L))throw new Error("sign() legacy options not supported");let{hash:P,randomBytes:_}=e,{lowS:V,prehash:J,extraEntropy:ee}=L;V==null&&(V=!0),E=ue("msgHash",E),Qi(L),J&&(E=ue("prehashed msgHash",P(E)));let We=v(E),ye=d(A),Qe=[T(ye),T(We)];if(ee!=null&&ee!==!1){let ut=ee===!0?_(r.BYTES):ee;Qe.push(ue("extraEntropy",ut))}let zt=Kt(...Qe),Je=We;function Vr(ut){let St=N(ut);if(!u(St))return;let Lo=a(St),Ie=c.BASE.multiply(St).toAffine(),At=s(Ie.x);if(At===Ze)return;let cr=s(Lo*s(Je+At*ye));if(cr===Ze)return;let To=(Ie.x===At?0:2)|Number(Ie.y&j),No=cr;return V&&p(cr)&&(No=h(cr),To^=1),new g(At,No,To)}return{seed:zt,k2sig:Vr}}let he={lowS:e.lowS,prehash:!1},M={lowS:e.lowS,prehash:!1};function D(E,A,L=he){let{seed:P,k2sig:_}=O(E,A,L),V=e;return ro(V.hash.outputLen,V.nByteLength,V.hmac)(P,_)}c.BASE._setWindowSize(8);function ie(E,A,L,P=M){let _=E;if(A=ue("msgHash",A),L=ue("publicKey",L),"strict"in P)throw new Error("options.strict was renamed to lowS");Qi(P);let{lowS:V,prehash:J}=P,ee,We;try{if(typeof _=="string"||st(_))try{ee=g.fromDER(_)}catch(Ie){if(!(Ie instanceof Xe.Err))throw Ie;ee=g.fromCompact(_)}else if(typeof _=="object"&&typeof _.r=="bigint"&&typeof _.s=="bigint"){let{r:Ie,s:At}=_;ee=new g(Ie,At)}else throw new Error("PARSE");We=c.fromHex(L)}catch(Ie){if(Ie.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(V&&ee.hasHighS())return!1;J&&(A=e.hash(A));let{r:ye,s:Qe}=ee,zt=v(A),Je=a(Qe),Vr=s(zt*Je),ut=s(ye*Je),St=c.BASE.multiplyAndAddUnsafe(We,Vr,ut)?.toAffine();return St?s(St.x)===ye:!1}return{CURVE:e,getPublicKey:x,getSharedSecret:I,sign:D,verify:ie,ProjectivePoint:c,Signature:g,utils:f}}function ed(t){return{hash:t,hmac:(e,...r)=>Zn(t,e,_i(...r)),randomBytes:Fi}}function ts(t,e){let r=n=>es({...t,...ed(n)});return Object.freeze({...r(e),create:r})}var os=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),rs=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),td=BigInt(1),ho=BigInt(2),ns=(t,e)=>(t+e/ho)/e;function rd(t){let e=os,r=BigInt(3),n=BigInt(6),o=BigInt(11),i=BigInt(22),s=BigInt(23),a=BigInt(44),c=BigInt(88),d=t*t*t%e,m=d*d*t%e,u=le(m,r,e)*m%e,l=le(u,r,e)*m%e,p=le(l,ho,e)*d%e,h=le(p,o,e)*p%e,y=le(h,i,e)*h%e,g=le(y,a,e)*y%e,f=le(g,c,e)*g%e,x=le(f,a,e)*y%e,b=le(x,r,e)*m%e,I=le(b,s,e)*h%e,N=le(I,n,e)*d%e,v=le(N,ho,e);if(!po.eql(po.sqr(v),t))throw new Error("Cannot find square root");return v}var po=Pr(os,void 0,void 0,{sqrt:rd}),qt=ts({a:BigInt(0),b:BigInt(7),Fp:po,n:rs,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:t=>{let e=rs,r=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-td*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),i=r,s=BigInt("0x100000000000000000000000000000000"),a=ns(i*t,e),c=ns(-n*t,e),d=Z(t-a*r-c*o,e),m=Z(-a*n-c*i,e),u=d>s,l=m>s;if(u&&(d=e-d),l&&(m=e-m),d>s||m>s)throw new Error("splitScalar: Endomorphism failed, k="+t);return{k1neg:u,k1:d,k2neg:l,k2:m}}}},$i),np=BigInt(0);var op=qt.ProjectivePoint;var is=Bt(te("node:crypto"),1);var Rr=class extends Error{constructor(e="An error occurred while verifying a message"){super(e),this.name="VerificationError"}};function ss(t,e,r){let n=is.default.createHash("sha256");if(r instanceof Uint8Array)n.update(r);else for(let i of r)n.update(i);let o=n.digest();try{return qt.verify(e,o,t)}catch(i){throw new Rr(String(i))}}var kr=class{type="secp256k1";raw;_key;constructor(e){this._key=as(e),this.raw=cs(this._key)}toMultihash(){return ze.digest(wr(this))}toCID(){return Q.createV1(114,this.toMultihash())}toString(){return K.encode(this.toMultihash().bytes).substring(1)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:Ve(this.raw,e.raw)}verify(e,r){return ss(this._key,r,e)}};function ds(t){return new kr(t)}function cs(t){return qt.ProjectivePoint.fromHex(t).toRawBytes(!0)}function as(t){try{return qt.ProjectivePoint.fromHex(t),t}catch(e){throw new dr(String(e))}}function us(t){let{Type:e,Data:r}=er.decode(t.digest),n=r??new Uint8Array;switch(e){case ge.Ed25519:return Si(n);case ge.secp256k1:return ds(n);default:throw new Vt}}function wr(t){return er.encode({Type:ge[t.type],Data:t.raw})}var ls=Symbol.for("nodejs.util.inspect.custom"),nd=114,or=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()})`}[Hr]=!0;toString(){return this.string==null&&(this.string=K.encode(this.multihash.bytes).slice(1)),this.string}toMultihash(){return this.multihash}toCID(){return Q.createV1(nd,this.multihash)}toJSON(){return this.toString()}equals(e){if(e==null)return!1;if(e instanceof Uint8Array)return Ve(this.multihash.bytes,e);if(typeof e=="string")return this.toString()===e;if(e?.toMultihash()?.bytes!=null)return Ve(this.multihash.bytes,e.toMultihash().bytes);throw new Error("not valid Id")}[ls](){return`PeerId(${this.toString()})`}},Dr=class extends or{type="RSA";publicKey;constructor(e){super({...e,type:"RSA"}),this.publicKey=e.publicKey}},_r=class extends or{type="Ed25519";publicKey;constructor(e){super({...e,type:"Ed25519"}),this.publicKey=e.publicKey}},Mr=class extends or{type="secp256k1";publicKey;constructor(e){super({...e,type:"secp256k1"}),this.publicKey=e.publicKey}},od=2336,Fr=class{type="url";multihash;publicKey;url;constructor(e){this.url=e.toString(),this.multihash=ze.digest(rt(this.url))}[ls](){return`PeerId(${this.url})`}[Hr]=!0;toString(){return this.toCID().toString()}toMultihash(){return this.multihash}toCID(){return Q.createV1(od,this.toMultihash())}toJSON(){return this.toString()}equals(e){return e==null?!1:(e instanceof Uint8Array&&(e=$(e)),e.toString()===this.toString())}};function hs(t,e){let r;if(t.charAt(0)==="1"||t.charAt(0)==="Q")r=pt(K.decode(`z${t}`));else{if(e==null)throw new Ut('Please pass a multibase decoder for strings that do not start with "1" or "Q"');r=pt(e.decode(t))}return id(r)}function id(t){if(cd(t))return new Dr({multihash:t});if(sd(t))try{let e=us(t);if(e.type==="Ed25519")return new _r({multihash:t,publicKey:e});if(e.type==="secp256k1")return new Mr({multihash:t,publicKey:e})}catch{let r=$(t.digest);return new Fr(new URL(r))}throw new ur("Supplied PeerID Multihash is invalid")}function sd(t){return t.code===ze.code}function cd(t){return t.code===An.code}var me=te("node:net");function Kr(t){return!!(0,me.isIP)(t)}var gs=Bt(ps(),1),ad=["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"],dd=ad.map(t=>new gs.Netmask(t));function go(t){for(let e of dd)if(e.contains(t))return!0;return!1}function ud(t){return/^::ffff:([0-9a-fA-F]{1,4}):([0-9a-fA-F]{1,4})$/.test(t)}function ld(t){let e=t.split(":");if(e.length<2)return!1;let r=e[e.length-1].padStart(4,"0"),n=e[e.length-2].padStart(4,"0"),o=`${parseInt(n.substring(0,2),16)}.${parseInt(n.substring(2),16)}.${parseInt(r.substring(0,2),16)}.${parseInt(r.substring(2),16)}`;return go(o)}function hd(t){return/^::ffff:([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(t)}function pd(t){let e=t.split(":"),r=e[e.length-1];return go(r)}function gd(t){return/^::$/.test(t)||/^::1$/.test(t)||/^64:ff9b::([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(t)||/^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(t)||/^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(t)||/^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(t)||/^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(t)||/^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(t)||/^f[c-d]([0-9a-fA-F]{2,2}):/i.test(t)||/^fe[8-9a-bA-B][0-9a-fA-F]:/i.test(t)||/^ff([0-9a-fA-F]{2,2}):/i.test(t)}function ms(t){return(0,me.isIPv4)(t)?go(t):ud(t)?ld(t):hd(t)?pd(t):(0,me.isIPv6)(t)?gd(t):void 0}function ys(t){try{let{address:e}=t.nodeAddress();return!!ms(e)}catch{return!0}}var qr=class{index=0;input="";new(e){return this.index=0,this.input=e,this}readAtomically(e){let r=this.index,n=e();return n===void 0&&(this.index=r),n}parseWith(e){let r=e();if(this.index===this.input.length)return r}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 r=this.readChar();if(r===e)return r})}readSeparator(e,r,n){return this.readAtomically(()=>{if(!(r>0&&this.readGivenChar(e)===void 0))return n()})}readNumber(e,r,n,o){return this.readAtomically(()=>{let i=0,s=0,a=this.peekChar();if(a===void 0)return;let c=a==="0",d=2**(8*o)-1;for(;;){let m=this.readAtomically(()=>{let u=this.readChar();if(u===void 0)return;let l=Number.parseInt(u,e);if(!Number.isNaN(l))return l});if(m===void 0)break;if(i*=e,i+=m,i>d||(s+=1,r!==void 0&&s>r))return}if(s!==0)return!n&&c&&s>1?void 0:i})}readIPv4Addr(){return this.readAtomically(()=>{let e=new Uint8Array(4);for(let r=0;r<e.length;r++){let n=this.readSeparator(".",r,()=>this.readNumber(10,3,!1,1));if(n===void 0)return;e[r]=n}return e})}readIPv6Addr(){let e=r=>{for(let n=0;n<r.length/2;n++){let o=n*2;if(n<r.length-3){let s=this.readSeparator(":",n,()=>this.readIPv4Addr());if(s!==void 0)return r[o]=s[0],r[o+1]=s[1],r[o+2]=s[2],r[o+3]=s[3],[o+4,!0]}let i=this.readSeparator(":",n,()=>this.readNumber(16,4,!0,2));if(i===void 0)return[o,!1];r[o]=i>>8,r[o+1]=i&255}return[r.length,!1]};return this.readAtomically(()=>{let r=new Uint8Array(16),[n,o]=e(r);if(n===16)return r;if(o||this.readGivenChar(":")===void 0||this.readGivenChar(":")===void 0)return;let i=new Uint8Array(14),s=16-(n+2),[a]=e(i.subarray(0,s));return r.set(i.subarray(0,a),16-a),r})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var d0=new qr;var f0=parseInt("0xFFFF",16),w0=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);var xs=me.isIPv4,Ed=me.isIPv6,mo=function(t){let e=0;if(t=t.toString().trim(),xs(t)){let r=new Uint8Array(e+4);return t.split(/\./g).forEach(n=>{r[e++]=parseInt(n,10)&255}),r}if(Ed(t)){let r=t.split(":",8),n;for(n=0;n<r.length;n++){let i=xs(r[n]),s;i&&(s=mo(r[n]),r[n]=$(s.slice(0,2),"base16")),s!=null&&++n<8&&r.splice(n,0,$(s.slice(2,4),"base16"))}if(r[0]==="")for(;r.length<8;)r.unshift("0");else if(r[r.length-1]==="")for(;r.length<8;)r.push("0");else if(r.length<8){for(n=0;n<r.length&&r[n]!=="";n++);let i=[n,1];for(n=9-r.length;n>0;n--)i.push("0");r.splice.apply(r,i)}let o=new Uint8Array(e+16);for(n=0;n<r.length;n++){let i=parseInt(r[n],16);o[e++]=i>>8&255,o[e++]=i&255}return o}throw new Error("invalid ip address")},Es=function(t,e=0,r){e=~~e,r=r??t.length-e;let n=new DataView(t.buffer);if(r===4){let o=[];for(let i=0;i<r;i++)o.push(t[e+i]);return o.join(".")}if(r===16){let o=[];for(let i=0;i<r;i+=2)o.push(n.getUint16(e+i).toString(16));return o.join(":").replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}return""};var $t={},yo={},Id=[[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"]];Id.forEach(t=>{let e=vd(...t);yo[e.code]=e,$t[e.name]=e});function vd(t,e,r,n,o){return{code:t,size:e,name:r,resolvable:!!n,path:!!o}}function k(t){if(typeof t=="number"){if(yo[t]!=null)return yo[t];throw new Error(`no protocol with code: ${t}`)}else if(typeof t=="string"){if($t[t]!=null)return $t[t];throw new Error(`no protocol with name: ${t}`)}throw new Error(`invalid protocol id type: ${typeof t}`)}var tg=k("ip4"),rg=k("ip6"),ng=k("ipcidr");function Eo(t,e){switch(k(t).code){case 4:case 41:return Ad(e);case 42:return xo(e);case 6:case 273:case 33:case 132:return vs(e).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return xo(e);case 421:return Td(e);case 444:return Is(e);case 445:return Is(e);case 466:return Ld(e);case 481:return globalThis.encodeURIComponent(xo(e));default:return $(e,"base16")}}function bo(t,e){switch(k(t).code){case 4:return bs(e);case 41:return bs(e);case 42:return wo(e);case 6:case 273:case 33:case 132:return Io(parseInt(e,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return wo(e);case 421:return Bd(e);case 444:return Nd(e);case 445:return Od(e);case 466:return Ud(e);case 481:return wo(globalThis.decodeURIComponent(e));default:return rt(e,"base16")}}var fo=Object.values(Zt).map(t=>t.decoder),Sd=function(){let t=fo[0].or(fo[1]);return fo.slice(2).forEach(e=>t=t.or(e)),t}();function bs(t){if(!Kr(t))throw new Error("invalid ip address");return mo(t)}function Ad(t){let e=Es(t,0,t.length);if(e==null)throw new Error("ipBuff is required");if(!Kr(e))throw new Error("invalid ip address");return e}function Io(t){let e=new ArrayBuffer(2);return new DataView(e).setUint16(0,t),new Uint8Array(e)}function vs(t){return new DataView(t.buffer).getUint16(t.byteOffset)}function wo(t){let e=rt(t),r=Uint8Array.from(Rt(e.length));return Oe([r,e],r.length+e.length)}function xo(t){let e=mt(t);if(t=t.slice(oe(e)),t.length!==e)throw new Error("inconsistent lengths");return $(t)}function Bd(t){let e;t[0]==="Q"||t[0]==="1"?e=pt(K.decode(`z${t}`)).bytes:e=Q.parse(t).multihash.bytes;let r=Uint8Array.from(Rt(e.length));return Oe([r,e],r.length+e.length)}function Ud(t){let e=Sd.decode(t),r=Uint8Array.from(Rt(e.length));return Oe([r,e],r.length+e.length)}function Ld(t){let e=mt(t),r=t.slice(oe(e));if(r.length!==e)throw new Error("inconsistent lengths");return"u"+$(r,"base64url")}function Td(t){let e=mt(t),r=t.slice(oe(e));if(r.length!==e)throw new Error("inconsistent lengths");return $(r,"base58btc")}function Nd(t){let e=t.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 r=$e.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 o=Io(n);return Oe([r,o],r.length+o.length)}function Od(t){let e=t.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 r=$e.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 o=Io(n);return Oe([r,o],r.length+o.length)}function Is(t){let e=t.slice(0,t.length-2),r=t.slice(t.length-2),n=$(e,"base32"),o=vs(r);return`${n}:${o}`}function Ss(t){t=vo(t);let e=[],r=[],n=null,o=t.split("/").slice(1);if(o.length===1&&o[0]==="")return{bytes:new Uint8Array,string:"/",tuples:[],stringTuples:[],path:null};for(let i=0;i<o.length;i++){let s=o[i],a=k(s);if(a.size===0){e.push([a.code]),r.push([a.code]);continue}if(i++,i>=o.length)throw Bs("invalid address: "+t);if(a.path===!0){n=vo(o.slice(i).join("/")),e.push([a.code,bo(a.code,n)]),r.push([a.code,n]);break}let c=bo(a.code,o[i]);e.push([a.code,c]),r.push([a.code,Eo(a.code,c)])}return{string:As(r),bytes:Ao(e),tuples:e,stringTuples:r,path:n}}function So(t){let e=[],r=[],n=null,o=0;for(;o<t.length;){let i=mt(t,o),s=oe(i),a=k(i),c=Cd(a,t.slice(o+s));if(c===0){e.push([i]),r.push([i]),o+=s;continue}let d=t.slice(o+s,o+s+c);if(o+=c+s,o>t.length)throw Bs("Invalid address Uint8Array: "+$(t,"base16"));e.push([i,d]);let m=Eo(i,d);if(r.push([i,m]),a.path===!0){n=m;break}}return{bytes:Uint8Array.from(t),string:As(r),tuples:e,stringTuples:r,path:n}}function As(t){let e=[];return t.map(r=>{let n=k(r[0]);return e.push(n.name),r.length>1&&r[1]!=null&&e.push(r[1]),null}),vo(e.join("/"))}function Ao(t){return Oe(t.map(e=>{let r=k(e[0]),n=Uint8Array.from(Rt(r.code));return e.length>1&&e[1]!=null&&(n=Oe([n,e[1]])),n}))}function Cd(t,e){if(t.size>0)return t.size/8;if(t.size===0)return 0;{let r=mt(e instanceof Uint8Array?e:Uint8Array.from(e));return r+oe(r)}}function vo(t){return"/"+t.trim().split("/").filter(e=>e).join("/")}function Bs(t){return new Error("Error parsing address: "+t)}var Pd=Symbol.for("nodejs.util.inspect.custom"),Uo=Symbol.for("@multiformats/js-multiaddr/multiaddr"),Rd=[k("dns").code,k("dns4").code,k("dns6").code,k("dnsaddr").code],Bo=class extends Error{constructor(e="No available resolver"){super(e),this.name="NoAvailableResolverError"}},$r=class t{bytes;#e;#t;#r;#n;[Uo]=!0;constructor(e){e==null&&(e="");let r;if(e instanceof Uint8Array)r=So(e);else if(typeof e=="string"){if(e.length>0&&e.charAt(0)!=="/")throw new Error(`multiaddr "${e}" must start with a "/"`);r=Ss(e)}else if(Ls(e))r=So(e.bytes);else throw new Error("addr must be a string, Buffer, or another Multiaddr");this.bytes=r.bytes,this.#e=r.string,this.#t=r.tuples,this.#r=r.stringTuples,this.#n=r.path}toString(){return this.#e}toJSON(){return this.toString()}toOptions(){let e,r,n,o,i="",s=k("tcp"),a=k("udp"),c=k("ip4"),d=k("ip6"),m=k("dns6"),u=k("ip6zone");for(let[p,h]of this.stringTuples())p===u.code&&(i=`%${h??""}`),Rd.includes(p)&&(r=s.name,o=443,n=`${h??""}${i}`,e=p===m.code?6:4),(p===s.code||p===a.code)&&(r=k(p).name,o=parseInt(h??"")),(p===c.code||p===d.code)&&(r=k(p).name,n=`${h??""}${i}`,e=p===d.code?6:4);if(e==null||r==null||n==null||o==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:r,port:o}}protos(){return this.#t.map(([e])=>Object.assign({},k(e)))}protoCodes(){return this.#t.map(([e])=>e)}protoNames(){return this.#t.map(([e])=>k(e).name)}tuples(){return this.#t}stringTuples(){return this.#r}encapsulate(e){return e=new t(e),new t(this.toString()+e.toString())}decapsulate(e){let r=e.toString(),n=this.toString(),o=n.lastIndexOf(r);if(o<0)throw new Error(`Address ${this.toString()} does not contain subaddress: ${e.toString()}`);return new t(n.slice(0,o))}decapsulateCode(e){let r=this.tuples();for(let n=r.length-1;n>=0;n--)if(r[n][0]===e)return new t(Ao(r.slice(0,n)));return this}getPeerId(){try{let e=[];this.stringTuples().forEach(([n,o])=>{n===$t.p2p.code&&e.push([n,o]),n===$t["p2p-circuit"].code&&(e=[])});let r=e.pop();if(r?.[1]!=null){let n=r[1];return n[0]==="Q"||n[0]==="1"?$(K.decode(`z${n}`),"base58btc"):$(Q.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){return this.#n}equals(e){return Ve(this.bytes,e.bytes)}async resolve(e){let r=this.protos().find(i=>i.resolvable);if(r==null)return[this];let n=Us.get(r.name);if(n==null)throw new Bo(`no available resolver for ${r.name}`);return(await n(this,e)).map(i=>sr(i))}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 r=(e??this).protos();return!(r.length!==2||r[0].code!==4&&r[0].code!==41||r[1].code!==6&&r[1].code!==273)}[Pd](){return`Multiaddr(${this.#e})`}};var Us=new Map;function Ls(t){return!!t?.[Uo]}function sr(t){return new $r(t)}function Ts(t,e,r,n){let o=()=>{n?.log.trace("query",e),t.query({questions:[{name:e,type:"PTR"}]})};return o(),setInterval(o,r)}function Ns(t,e,r,n){if(t.answers==null)return;let o,i=[];if(t.answers.forEach(s=>{switch(s.type){case"PTR":o=s;break;case"TXT":i.push(s);break;default:break}}),t.additionals.forEach(s=>{switch(s.type){case"TXT":i.push(s);break;default:break}}),!(o==null||o?.name!==r||i.length===0||o.data.startsWith(e)))try{let s=i.flatMap(c=>c.data).filter(c=>c.toString().startsWith("dnsaddr=")).map(c=>sr(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:hs(a),multiaddrs:s.map(c=>c.decapsulateCode(k("p2p").code))}}catch(s){n?.log.error("failed to parse mdns response",s)}}function Os(t,e,r,n,o,i,s){if(!i){s?.log("not responding to mDNS query as broadcast mode is false");return}if(n.length!==0&&t.questions[0]!=null&&t.questions[0].name===o){let a=[];a.push({name:o,type:"PTR",class:"IN",ttl:120,data:r+"."+o}),n.filter(kd).forEach(c=>{let d="dnsaddr="+c.toString();if(d.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:r+"."+o,type:"TXT",class:"IN",ttl:120,data:d})}),s?.log.trace("responding to query"),e.respond(a)}}function kd(t){return!!ys(t)}function Cs(t){let e="",r="abcdefghijklmnopqrstuvwxyz0123456789";for(let n=0;n<t;n++)e+=r.charAt(Math.floor(Math.random()*r.length));return e}var zr=class extends lr{mdns;log;broadcast;interval;serviceTag;peerName;port;ip;_queryInterval;components;constructor(e,r={}){if(super(),this.log=e.logger.forComponent("libp2p:mdns"),this.broadcast=r.broadcast!==!1,this.interval=r.interval??1e3*10,this.serviceTag=r.serviceTag??"_p2p._udp.local",this.ip=r.ip??"224.0.0.251",this.peerName=r.peerName??Cs(63),this.peerName.length>=64)throw new Error("Peer name should be less than 64 chars long");this.port=r.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)}[Co]=this;[Symbol.toStringTag]="@libp2p/mdns";[ko]=["@libp2p/peer-discovery"];isStarted(){return!!this.mdns}async start(){this.mdns==null&&(this.mdns=(0,Ps.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=Ts(this.mdns,this.serviceTag,this.interval,{log:this.log}))}_onMdnsQuery(e){this.mdns!=null&&(this.log.trace("received incoming mDNS query"),Os(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 r=Ns(e,this.peerName,this.serviceTag,{log:this.log});r!=null&&(this.log("discovered peer in mDNS query response %p",r.id),this.dispatchEvent(new CustomEvent("peer",{detail:r})))}catch(r){this.log.error("Error processing peer response",r)}}_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 _d(t={}){return e=>new zr(e,t)}return Fs(Md);})();
2
+ "use strict";var Libp2PMdns=(()=>{var Fs=Object.create;var dr=Object.defineProperty;var Ks=Object.getOwnPropertyDescriptor;var qs=Object.getOwnPropertyNames;var zs=Object.getPrototypeOf,Vs=Object.prototype.hasOwnProperty;var ne=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,r)=>(typeof require<"u"?require:e)[r]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var ve=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),oe=(t,e)=>{for(var r in e)dr(t,r,{get:e[r],enumerable:!0})},Ro=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of qs(e))!Vs.call(t,o)&&o!==r&&dr(t,o,{get:()=>e[o],enumerable:!(n=Ks(e,o))||n.enumerable});return t};var Ut=(t,e,r)=>(r=t!=null?Fs(zs(t)):{},Ro(e||!t||!t.__esModule?dr(r,"default",{value:t,enumerable:!0}):r,t)),Hs=t=>Ro(dr({},"__esModule",{value:!0}),t);var Fo=ve(Zr=>{"use strict";Zr.toString=function(t){switch(t){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_"+t};Zr.toType=function(t){switch(t.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 t.toUpperCase().startsWith("UNKNOWN_")?parseInt(t.slice(8)):0}});var Ko=ve(Wr=>{"use strict";Wr.toString=function(t){switch(t){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_"+t};Wr.toRcode=function(t){switch(t.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 qo=ve(Qr=>{"use strict";Qr.toString=function(t){switch(t){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_"+t};Qr.toOpcode=function(t){switch(t.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 zo=ve(Jr=>{"use strict";Jr.toString=function(t){switch(t){case 1:return"IN";case 2:return"CS";case 3:return"CH";case 4:return"HS";case 255:return"ANY"}return"UNKNOWN_"+t};Jr.toClass=function(t){switch(t.toUpperCase()){case"IN":return 1;case"CS":return 2;case"CH":return 3;case"HS":return 4;case"ANY":return 255}return 0}});var Vo=ve(en=>{"use strict";en.toString=function(t){switch(t){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 t<0?null:`OPTION_${t}`};en.toCode=function(t){if(typeof t=="number")return t;if(!t)return-1;switch(t.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=t.match(/_(\d+)$/);return e?parseInt(e[1],10):-1}});var $o=ve((jo,tn)=>{var Ho=function(t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.decode=l,t.encode=g,t.familyOf=d,t.name=void 0,t.sizeOf=c,t.v6=t.v4=void 0;let e=/^(\d{1,3}\.){3,3}\d{1,3}$/,r=4,n=/^(::)?(((\d{1,3}\.){3}(\d{1,3}){1})?([0-9a-f]){0,4}:{0,2}){1,8}(::)?$/i,o=16,i={name:"v4",size:r,isFormat:u=>e.test(u),encode(u,p,h){h=~~h,p=p||new Uint8Array(h+r);let y=u.length,m=0;for(let f=0;f<y;){let x=u.charCodeAt(f++);x===46?(p[h++]=m,m=0):m=m*10+(x-48)}return p[h]=m,p},decode(u,p){return p=~~p,`${u[p++]}.${u[p++]}.${u[p++]}.${u[p]}`}};t.v4=i;let s={name:"v6",size:o,isFormat:u=>u.length>0&&n.test(u),encode(u,p,h){h=~~h;let y=h+o,m=-1,f=0,x=0,b=!0,L=!1;p=p||new Uint8Array(h+o);for(let T=0;T<u.length;T++){let B=u.charCodeAt(T);B===58?(b?m!==-1?(h<y&&(p[h]=0),h<y-1&&(p[h+1]=0),h+=2):h<y&&(m=h):(L===!0?(h<y&&(p[h]=x),h++):(h<y&&(p[h]=f>>8),h<y-1&&(p[h+1]=f&255),h+=2),f=0,x=0),b=!0,L=!1):B===46?(h<y&&(p[h]=x),h++,x=0,f=0,b=!1,L=!0):(b=!1,B>=97?B-=87:B>=65?B-=55:(B-=48,x=x*10+B),f=(f<<4)+B)}if(b===!1)L===!0?(h<y&&(p[h]=x),h++):(h<y&&(p[h]=f>>8),h<y-1&&(p[h+1]=f&255),h+=2);else if(m===0)h<y&&(p[h]=0),h<y-1&&(p[h+1]=0),h+=2;else if(m!==-1){h+=2;for(let T=Math.min(h-1,y-1);T>=m+2;T--)p[T]=p[T-2];p[m]=0,p[m+1]=0,m=h}if(m!==h&&m!==-1)for(h>y-2&&(h=y-2);y>m;)p[--y]=h<y&&h>m?p[--h]:0;else for(;h<y;)p[h++]=0;return p},decode(u,p){p=~~p;let h="";for(let y=0;y<o;y+=2)y!==0&&(h+=":"),h+=(u[p+y]<<8|u[p+y+1]).toString(16);return h.replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}};t.v6=s;let a="ip";t.name=a;function c(u){if(i.isFormat(u))return i.size;if(s.isFormat(u))return s.size;throw Error(`Invalid ip address: ${u}`)}function d(u){return c(u)===i.size?1:2}function g(u,p,h){h=~~h;let y=c(u);return typeof p=="function"&&(p=p(h+y)),y===i.size?i.encode(u,p,h):s.encode(u,p,h)}function l(u,p,h){if(p=~~p,h=h||u.length-p,h===i.size)return i.decode(u,p,h);if(h===s.size)return s.decode(u,p,h);throw Error(`Invalid buffer size needs to be ${i.size} for v4 or ${s.size} for v6.`)}return"default"in t?t.default:t}({});typeof define=="function"&&define.amd?define([],function(){return Ho}):typeof tn=="object"&&typeof jo=="object"&&(tn.exports=Ho)});var Xo=ve(v=>{"use strict";var S=ne("buffer").Buffer,ze=Fo(),js=Ko(),$s=qo(),mr=zo(),rn=Vo(),lt=$o(),Gs=0,Go=32768,nn=32768,Ys=~nn,Yo=32768,Xs=~Yo,w=v.name={};w.encode=function(t,e,r,{mail:n=!1}={}){e||(e=S.alloc(w.encodingLength(t))),r||(r=0);let o=r,i=t.replace(/^\.|\.$/gm,"");if(i.length){let s=[];if(n){let a="";i.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=i.split(".");for(let a=0;a<s.length;a++){let c=e.write(s[a],r+1);e[r]=c,r+=c+1}}return e[r++]=0,w.encode.bytes=r-o,e};w.encode.bytes=0;w.decode=function(t,e,{mail:r=!1}={}){e||(e=0);let n=[],o=e,i=0,s=0,a=!1;for(;;){if(e>=t.length)throw new Error("Cannot decode name (buffer overflow)");let c=t[e++];if(s+=a?0:1,c===0)break;if(c&192)if((c&192)===192){if(e+1>t.length)throw new Error("Cannot decode name (buffer overflow)");let d=t.readUInt16BE(e-1)-49152;if(d>=o)throw new Error("Cannot decode name (bad pointer)");e=d,o=d,s+=a?0:1,a=!0}else throw new Error("Cannot decode name (bad label)");else{if(e+c>t.length)throw new Error("Cannot decode name (buffer overflow)");if(i+=c+1,i>254)throw new Error("Cannot decode name (name too long)");let d=t.toString("utf-8",e,e+c);r&&(d=d.replace(/\./g,"\\.")),n.push(d),e+=c,s+=a?0:c}}return w.decode.bytes=s,n.length===0?".":n.join(".")};w.decode.bytes=0;w.encodingLength=function(t){return t==="."||t===".."?1:S.byteLength(t.replace(/^\.|\.$/gm,""))+2};var O={};O.encode=function(t,e,r){e||(e=S.alloc(O.encodingLength(t))),r||(r=0);let n=e.write(t,r+1);return e[r]=n,O.encode.bytes=n+1,e};O.encode.bytes=0;O.decode=function(t,e){e||(e=0);let r=t[e],n=t.toString("utf-8",e+1,e+1+r);return O.decode.bytes=r+1,n};O.decode.bytes=0;O.encodingLength=function(t){return S.byteLength(t)+1};var Ee={};Ee.encode=function(t,e,r){e||(e=Ee.encodingLength(t)),r||(r=0);let n=(t.flags||0)&32767,o=t.type==="response"?Go:Gs;return e.writeUInt16BE(t.id||0,r),e.writeUInt16BE(n|o,r+2),e.writeUInt16BE(t.questions.length,r+4),e.writeUInt16BE(t.answers.length,r+6),e.writeUInt16BE(t.authorities.length,r+8),e.writeUInt16BE(t.additionals.length,r+10),e};Ee.encode.bytes=12;Ee.decode=function(t,e){if(e||(e=0),t.length<12)throw new Error("Header must be 12 bytes");let r=t.readUInt16BE(e+2);return{id:t.readUInt16BE(e),type:r&Go?"response":"query",flags:r&32767,flag_qr:(r>>15&1)===1,opcode:$s.toString(r>>11&15),flag_aa:(r>>10&1)===1,flag_tc:(r>>9&1)===1,flag_rd:(r>>8&1)===1,flag_ra:(r>>7&1)===1,flag_z:(r>>6&1)===1,flag_ad:(r>>5&1)===1,flag_cd:(r>>4&1)===1,rcode:js.toString(r&15),questions:new Array(t.readUInt16BE(e+4)),answers:new Array(t.readUInt16BE(e+6)),authorities:new Array(t.readUInt16BE(e+8)),additionals:new Array(t.readUInt16BE(e+10))}};Ee.decode.bytes=12;Ee.encodingLength=function(){return 12};var Pe=v.unknown={};Pe.encode=function(t,e,r){return e||(e=S.alloc(Pe.encodingLength(t))),r||(r=0),e.writeUInt16BE(t.length,r),t.copy(e,r+2),Pe.encode.bytes=t.length+2,e};Pe.encode.bytes=0;Pe.decode=function(t,e){e||(e=0);let r=t.readUInt16BE(e),n=t.slice(e+2,e+2+r);return Pe.decode.bytes=r+2,n};Pe.decode.bytes=0;Pe.encodingLength=function(t){return t.length+2};var Re=v.ns={};Re.encode=function(t,e,r){return e||(e=S.alloc(Re.encodingLength(t))),r||(r=0),w.encode(t,e,r+2),e.writeUInt16BE(w.encode.bytes,r),Re.encode.bytes=w.encode.bytes+2,e};Re.encode.bytes=0;Re.decode=function(t,e){e||(e=0);let r=t.readUInt16BE(e),n=w.decode(t,e+2);return Re.decode.bytes=r+2,n};Re.decode.bytes=0;Re.encodingLength=function(t){return w.encodingLength(t)+2};var De=v.soa={};De.encode=function(t,e,r){e||(e=S.alloc(De.encodingLength(t))),r||(r=0);let n=r;return r+=2,w.encode(t.mname,e,r),r+=w.encode.bytes,w.encode(t.rname,e,r,{mail:!0}),r+=w.encode.bytes,e.writeUInt32BE(t.serial||0,r),r+=4,e.writeUInt32BE(t.refresh||0,r),r+=4,e.writeUInt32BE(t.retry||0,r),r+=4,e.writeUInt32BE(t.expire||0,r),r+=4,e.writeUInt32BE(t.minimum||0,r),r+=4,e.writeUInt16BE(r-n-2,n),De.encode.bytes=r-n,e};De.encode.bytes=0;De.decode=function(t,e){e||(e=0);let r=e,n={};return e+=2,n.mname=w.decode(t,e),e+=w.decode.bytes,n.rname=w.decode(t,e,{mail:!0}),e+=w.decode.bytes,n.serial=t.readUInt32BE(e),e+=4,n.refresh=t.readUInt32BE(e),e+=4,n.retry=t.readUInt32BE(e),e+=4,n.expire=t.readUInt32BE(e),e+=4,n.minimum=t.readUInt32BE(e),e+=4,De.decode.bytes=e-r,n};De.decode.bytes=0;De.encodingLength=function(t){return 22+w.encodingLength(t.mname)+w.encodingLength(t.rname)};var ke=v.txt={};ke.encode=function(t,e,r){Array.isArray(t)||(t=[t]);for(let o=0;o<t.length;o++)if(typeof t[o]=="string"&&(t[o]=S.from(t[o])),!S.isBuffer(t[o]))throw new Error("Must be a Buffer");e||(e=S.alloc(ke.encodingLength(t))),r||(r=0);let n=r;return r+=2,t.forEach(function(o){e[r++]=o.length,o.copy(e,r,0,o.length),r+=o.length}),e.writeUInt16BE(r-n-2,n),ke.encode.bytes=r-n,e};ke.encode.bytes=0;ke.decode=function(t,e){e||(e=0);let r=e,n=t.readUInt16BE(e);e+=2;let o=[];for(;n>0;){let i=t[e++];if(--n,n<i)throw new Error("Buffer overflow");o.push(t.slice(e,e+i)),e+=i,n-=i}return ke.decode.bytes=e-r,o};ke.decode.bytes=0;ke.encodingLength=function(t){Array.isArray(t)||(t=[t]);let e=2;return t.forEach(function(r){typeof r=="string"?e+=S.byteLength(r)+1:e+=r.length+1}),e};var _e=v.null={};_e.encode=function(t,e,r){e||(e=S.alloc(_e.encodingLength(t))),r||(r=0),typeof t=="string"&&(t=S.from(t)),t||(t=S.alloc(0));let n=r;r+=2;let o=t.length;return t.copy(e,r,0,o),r+=o,e.writeUInt16BE(r-n-2,n),_e.encode.bytes=r-n,e};_e.encode.bytes=0;_e.decode=function(t,e){e||(e=0);let r=e,n=t.readUInt16BE(e);e+=2;let o=t.slice(e,e+n);return e+=n,_e.decode.bytes=e-r,o};_e.decode.bytes=0;_e.encodingLength=function(t){return t?(S.isBuffer(t)?t.length:S.byteLength(t))+2:2};var Me=v.hinfo={};Me.encode=function(t,e,r){e||(e=S.alloc(Me.encodingLength(t))),r||(r=0);let n=r;return r+=2,O.encode(t.cpu,e,r),r+=O.encode.bytes,O.encode(t.os,e,r),r+=O.encode.bytes,e.writeUInt16BE(r-n-2,n),Me.encode.bytes=r-n,e};Me.encode.bytes=0;Me.decode=function(t,e){e||(e=0);let r=e,n={};return e+=2,n.cpu=O.decode(t,e),e+=O.decode.bytes,n.os=O.decode(t,e),e+=O.decode.bytes,Me.decode.bytes=e-r,n};Me.decode.bytes=0;Me.encodingLength=function(t){return O.encodingLength(t.cpu)+O.encodingLength(t.os)+2};var we=v.ptr={},Zs=v.cname=we,Ws=v.dname=we;we.encode=function(t,e,r){return e||(e=S.alloc(we.encodingLength(t))),r||(r=0),w.encode(t,e,r+2),e.writeUInt16BE(w.encode.bytes,r),we.encode.bytes=w.encode.bytes+2,e};we.encode.bytes=0;we.decode=function(t,e){e||(e=0);let r=w.decode(t,e+2);return we.decode.bytes=w.decode.bytes+2,r};we.decode.bytes=0;we.encodingLength=function(t){return w.encodingLength(t)+2};var Fe=v.srv={};Fe.encode=function(t,e,r){e||(e=S.alloc(Fe.encodingLength(t))),r||(r=0),e.writeUInt16BE(t.priority||0,r+2),e.writeUInt16BE(t.weight||0,r+4),e.writeUInt16BE(t.port||0,r+6),w.encode(t.target,e,r+8);let n=w.encode.bytes+6;return e.writeUInt16BE(n,r),Fe.encode.bytes=n+2,e};Fe.encode.bytes=0;Fe.decode=function(t,e){e||(e=0);let r=t.readUInt16BE(e),n={};return n.priority=t.readUInt16BE(e+2),n.weight=t.readUInt16BE(e+4),n.port=t.readUInt16BE(e+6),n.target=w.decode(t,e+8),Fe.decode.bytes=r+2,n};Fe.decode.bytes=0;Fe.encodingLength=function(t){return 8+w.encodingLength(t.target)};var ae=v.caa={};ae.ISSUER_CRITICAL=128;ae.encode=function(t,e,r){let n=ae.encodingLength(t);return e||(e=S.alloc(ae.encodingLength(t))),r||(r=0),t.issuerCritical&&(t.flags=ae.ISSUER_CRITICAL),e.writeUInt16BE(n-2,r),r+=2,e.writeUInt8(t.flags||0,r),r+=1,O.encode(t.tag,e,r),r+=O.encode.bytes,e.write(t.value,r),r+=S.byteLength(t.value),ae.encode.bytes=n,e};ae.encode.bytes=0;ae.decode=function(t,e){e||(e=0);let r=t.readUInt16BE(e);e+=2;let n=e,o={};return o.flags=t.readUInt8(e),e+=1,o.tag=O.decode(t,e),e+=O.decode.bytes,o.value=t.toString("utf-8",e,n+r),o.issuerCritical=!!(o.flags&ae.ISSUER_CRITICAL),ae.decode.bytes=r+2,o};ae.decode.bytes=0;ae.encodingLength=function(t){return O.encodingLength(t.tag)+O.encodingLength(t.value)+2};var et=v.mx={};et.encode=function(t,e,r){e||(e=S.alloc(et.encodingLength(t))),r||(r=0);let n=r;return r+=2,e.writeUInt16BE(t.preference||0,r),r+=2,w.encode(t.exchange,e,r),r+=w.encode.bytes,e.writeUInt16BE(r-n-2,n),et.encode.bytes=r-n,e};et.encode.bytes=0;et.decode=function(t,e){e||(e=0);let r=e,n={};return e+=2,n.preference=t.readUInt16BE(e),e+=2,n.exchange=w.decode(t,e),e+=w.decode.bytes,et.decode.bytes=e-r,n};et.encodingLength=function(t){return 4+w.encodingLength(t.exchange)};var Ke=v.a={};Ke.encode=function(t,e,r){return e||(e=S.alloc(Ke.encodingLength(t))),r||(r=0),e.writeUInt16BE(4,r),r+=2,lt.v4.encode(t,e,r),Ke.encode.bytes=6,e};Ke.encode.bytes=0;Ke.decode=function(t,e){e||(e=0),e+=2;let r=lt.v4.decode(t,e);return Ke.decode.bytes=6,r};Ke.decode.bytes=0;Ke.encodingLength=function(){return 6};var qe=v.aaaa={};qe.encode=function(t,e,r){return e||(e=S.alloc(qe.encodingLength(t))),r||(r=0),e.writeUInt16BE(16,r),r+=2,lt.v6.encode(t,e,r),qe.encode.bytes=18,e};qe.encode.bytes=0;qe.decode=function(t,e){e||(e=0),e+=2;let r=lt.v6.decode(t,e);return qe.decode.bytes=18,r};qe.decode.bytes=0;qe.encodingLength=function(){return 18};var ie=v.option={};ie.encode=function(t,e,r){e||(e=S.alloc(ie.encodingLength(t))),r||(r=0);let n=r,o=rn.toCode(t.code);if(e.writeUInt16BE(o,r),r+=2,t.data)e.writeUInt16BE(t.data.length,r),r+=2,t.data.copy(e,r),r+=t.data.length;else switch(o){case 8:let i=t.sourcePrefixLength||0,s=t.family||lt.familyOf(t.ip),a=lt.encode(t.ip,S.alloc),c=Math.ceil(i/8);e.writeUInt16BE(c+4,r),r+=2,e.writeUInt16BE(s,r),r+=2,e.writeUInt8(i,r++),e.writeUInt8(t.scopePrefixLength||0,r++),a.copy(e,r,0,c),r+=c;break;case 11:t.timeout?(e.writeUInt16BE(2,r),r+=2,e.writeUInt16BE(t.timeout,r),r+=2):(e.writeUInt16BE(0,r),r+=2);break;case 12:let d=t.length||0;e.writeUInt16BE(d,r),r+=2,e.fill(0,r,r+d),r+=d;break;case 14:let g=t.tags.length*2;e.writeUInt16BE(g,r),r+=2;for(let l of t.tags)e.writeUInt16BE(l,r),r+=2;break;default:throw new Error(`Unknown roption code: ${t.code}`)}return ie.encode.bytes=r-n,e};ie.encode.bytes=0;ie.decode=function(t,e){e||(e=0);let r={};r.code=t.readUInt16BE(e),r.type=rn.toString(r.code),e+=2;let n=t.readUInt16BE(e);switch(e+=2,r.data=t.slice(e,e+n),r.code){case 8:r.family=t.readUInt16BE(e),e+=2,r.sourcePrefixLength=t.readUInt8(e++),r.scopePrefixLength=t.readUInt8(e++);let o=S.alloc(r.family===1?4:16);t.copy(o,0,e,e+n-4),r.ip=lt.decode(o);break;case 11:n>0&&(r.timeout=t.readUInt16BE(e),e+=2);break;case 14:r.tags=[];for(let i=0;i<n;i+=2)r.tags.push(t.readUInt16BE(e)),e+=2}return ie.decode.bytes=n+4,r};ie.decode.bytes=0;ie.encodingLength=function(t){if(t.data)return t.data.length+4;switch(rn.toCode(t.code)){case 8:let r=t.sourcePrefixLength||0;return Math.ceil(r/8)+8;case 11:return typeof t.timeout=="number"?6:4;case 12:return t.length+4;case 14:return 4+t.tags.length*2}throw new Error(`Unknown roption code: ${t.code}`)};var ue=v.opt={};ue.encode=function(t,e,r){e||(e=S.alloc(ue.encodingLength(t))),r||(r=0);let n=r,o=Tt(t,ie);return e.writeUInt16BE(o,r),r=Gt(t,ie,e,r+2),ue.encode.bytes=r-n,e};ue.encode.bytes=0;ue.decode=function(t,e){e||(e=0);let r=e,n=[],o=t.readUInt16BE(e);e+=2;let i=0;for(;o>0;)n[i++]=ie.decode(t,e),e+=ie.decode.bytes,o-=ie.decode.bytes;return ue.decode.bytes=e-r,n};ue.decode.bytes=0;ue.encodingLength=function(t){return 2+Tt(t||[],ie)};var J=v.dnskey={};J.PROTOCOL_DNSSEC=3;J.ZONE_KEY=128;J.SECURE_ENTRYPOINT=32768;J.encode=function(t,e,r){e||(e=S.alloc(J.encodingLength(t))),r||(r=0);let n=r,o=t.key;if(!S.isBuffer(o))throw new Error("Key must be a Buffer");return r+=2,e.writeUInt16BE(t.flags,r),r+=2,e.writeUInt8(J.PROTOCOL_DNSSEC,r),r+=1,e.writeUInt8(t.algorithm,r),r+=1,o.copy(e,r,0,o.length),r+=o.length,J.encode.bytes=r-n,e.writeUInt16BE(J.encode.bytes-2,n),e};J.encode.bytes=0;J.decode=function(t,e){e||(e=0);let r=e;var n={},o=t.readUInt16BE(e);if(e+=2,n.flags=t.readUInt16BE(e),e+=2,t.readUInt8(e)!==J.PROTOCOL_DNSSEC)throw new Error("Protocol must be 3");return e+=1,n.algorithm=t.readUInt8(e),e+=1,n.key=t.slice(e,r+o+2),e+=n.key.length,J.decode.bytes=e-r,n};J.decode.bytes=0;J.encodingLength=function(t){return 6+S.byteLength(t.key)};var Se=v.rrsig={};Se.encode=function(t,e,r){e||(e=S.alloc(Se.encodingLength(t))),r||(r=0);let n=r,o=t.signature;if(!S.isBuffer(o))throw new Error("Signature must be a Buffer");return r+=2,e.writeUInt16BE(ze.toType(t.typeCovered),r),r+=2,e.writeUInt8(t.algorithm,r),r+=1,e.writeUInt8(t.labels,r),r+=1,e.writeUInt32BE(t.originalTTL,r),r+=4,e.writeUInt32BE(t.expiration,r),r+=4,e.writeUInt32BE(t.inception,r),r+=4,e.writeUInt16BE(t.keyTag,r),r+=2,w.encode(t.signersName,e,r),r+=w.encode.bytes,o.copy(e,r,0,o.length),r+=o.length,Se.encode.bytes=r-n,e.writeUInt16BE(Se.encode.bytes-2,n),e};Se.encode.bytes=0;Se.decode=function(t,e){e||(e=0);let r=e;var n={},o=t.readUInt16BE(e);return e+=2,n.typeCovered=ze.toString(t.readUInt16BE(e)),e+=2,n.algorithm=t.readUInt8(e),e+=1,n.labels=t.readUInt8(e),e+=1,n.originalTTL=t.readUInt32BE(e),e+=4,n.expiration=t.readUInt32BE(e),e+=4,n.inception=t.readUInt32BE(e),e+=4,n.keyTag=t.readUInt16BE(e),e+=2,n.signersName=w.decode(t,e),e+=w.decode.bytes,n.signature=t.slice(e,r+o+2),e+=n.signature.length,Se.decode.bytes=e-r,n};Se.decode.bytes=0;Se.encodingLength=function(t){return 20+w.encodingLength(t.signersName)+S.byteLength(t.signature)};var Ae=v.rp={};Ae.encode=function(t,e,r){e||(e=S.alloc(Ae.encodingLength(t))),r||(r=0);let n=r;return r+=2,w.encode(t.mbox||".",e,r,{mail:!0}),r+=w.encode.bytes,w.encode(t.txt||".",e,r),r+=w.encode.bytes,Ae.encode.bytes=r-n,e.writeUInt16BE(Ae.encode.bytes-2,n),e};Ae.encode.bytes=0;Ae.decode=function(t,e){e||(e=0);let r=e,n={};return e+=2,n.mbox=w.decode(t,e,{mail:!0})||".",e+=w.decode.bytes,n.txt=w.decode(t,e)||".",e+=w.decode.bytes,Ae.decode.bytes=e-r,n};Ae.decode.bytes=0;Ae.encodingLength=function(t){return 2+w.encodingLength(t.mbox||".")+w.encodingLength(t.txt||".")};var j={};j.encode=function(t,e,r){e||(e=S.alloc(j.encodingLength(t))),r||(r=0);let n=r;for(var o=[],i=0;i<t.length;i++){var s=ze.toType(t[i]);o[s>>8]===void 0&&(o[s>>8]=[]),o[s>>8][s>>3&31]|=1<<7-(s&7)}for(i=0;i<o.length;i++)if(o[i]!==void 0){var a=S.from(o[i]);e.writeUInt8(i,r),r+=1,e.writeUInt8(a.length,r),r+=1,a.copy(e,r),r+=a.length}return j.encode.bytes=r-n,e};j.encode.bytes=0;j.decode=function(t,e,r){e||(e=0);let n=e;for(var o=[];e-n<r;){var i=t.readUInt8(e);e+=1;var s=t.readUInt8(e);e+=1;for(var a=0;a<s;a++)for(var c=t.readUInt8(e+a),d=0;d<8;d++)if(c&1<<7-d){var g=ze.toString(i<<8|a<<3|d);o.push(g)}e+=s}return j.decode.bytes=e-n,o};j.decode.bytes=0;j.encodingLength=function(t){for(var e=[],r=0;r<t.length;r++){var n=ze.toType(t[r]);e[n>>8]=Math.max(e[n>>8]||0,n&255)}var o=0;for(r=0;r<e.length;r++)e[r]!==void 0&&(o+=2+Math.ceil((e[r]+1)/8));return o};var Be=v.nsec={};Be.encode=function(t,e,r){e||(e=S.alloc(Be.encodingLength(t))),r||(r=0);let n=r;return r+=2,w.encode(t.nextDomain,e,r),r+=w.encode.bytes,j.encode(t.rrtypes,e,r),r+=j.encode.bytes,Be.encode.bytes=r-n,e.writeUInt16BE(Be.encode.bytes-2,n),e};Be.encode.bytes=0;Be.decode=function(t,e){e||(e=0);let r=e;var n={},o=t.readUInt16BE(e);return e+=2,n.nextDomain=w.decode(t,e),e+=w.decode.bytes,n.rrtypes=j.decode(t,e,o-(e-r)),e+=j.decode.bytes,Be.decode.bytes=e-r,n};Be.decode.bytes=0;Be.encodingLength=function(t){return 2+w.encodingLength(t.nextDomain)+j.encodingLength(t.rrtypes)};var Ue=v.nsec3={};Ue.encode=function(t,e,r){e||(e=S.alloc(Ue.encodingLength(t))),r||(r=0);let n=r,o=t.salt;if(!S.isBuffer(o))throw new Error("salt must be a Buffer");let i=t.nextDomain;if(!S.isBuffer(i))throw new Error("nextDomain must be a Buffer");return r+=2,e.writeUInt8(t.algorithm,r),r+=1,e.writeUInt8(t.flags,r),r+=1,e.writeUInt16BE(t.iterations,r),r+=2,e.writeUInt8(o.length,r),r+=1,o.copy(e,r,0,o.length),r+=o.length,e.writeUInt8(i.length,r),r+=1,i.copy(e,r,0,i.length),r+=i.length,j.encode(t.rrtypes,e,r),r+=j.encode.bytes,Ue.encode.bytes=r-n,e.writeUInt16BE(Ue.encode.bytes-2,n),e};Ue.encode.bytes=0;Ue.decode=function(t,e){e||(e=0);let r=e;var n={},o=t.readUInt16BE(e);e+=2,n.algorithm=t.readUInt8(e),e+=1,n.flags=t.readUInt8(e),e+=1,n.iterations=t.readUInt16BE(e),e+=2;let i=t.readUInt8(e);e+=1,n.salt=t.slice(e,e+i),e+=i;let s=t.readUInt8(e);return e+=1,n.nextDomain=t.slice(e,e+s),e+=s,n.rrtypes=j.decode(t,e,o-(e-r)),e+=j.decode.bytes,Ue.decode.bytes=e-r,n};Ue.decode.bytes=0;Ue.encodingLength=function(t){return 8+t.salt.length+t.nextDomain.length+j.encodingLength(t.rrtypes)};var Le=v.ds={};Le.encode=function(t,e,r){e||(e=S.alloc(Le.encodingLength(t))),r||(r=0);let n=r,o=t.digest;if(!S.isBuffer(o))throw new Error("Digest must be a Buffer");return r+=2,e.writeUInt16BE(t.keyTag,r),r+=2,e.writeUInt8(t.algorithm,r),r+=1,e.writeUInt8(t.digestType,r),r+=1,o.copy(e,r,0,o.length),r+=o.length,Le.encode.bytes=r-n,e.writeUInt16BE(Le.encode.bytes-2,n),e};Le.encode.bytes=0;Le.decode=function(t,e){e||(e=0);let r=e;var n={},o=t.readUInt16BE(e);return e+=2,n.keyTag=t.readUInt16BE(e),e+=2,n.algorithm=t.readUInt8(e),e+=1,n.digestType=t.readUInt8(e),e+=1,n.digest=t.slice(e,r+o+2),e+=n.digest.length,Le.decode.bytes=e-r,n};Le.decode.bytes=0;Le.encodingLength=function(t){return 6+S.byteLength(t.digest)};var de=v.sshfp={};de.getFingerprintLengthForHashType=function(e){switch(e){case 1:return 20;case 2:return 32}};de.encode=function(e,r,n){r||(r=S.alloc(de.encodingLength(e))),n||(n=0);let o=n;n+=2,r[n]=e.algorithm,n+=1,r[n]=e.hash,n+=1;let i=S.from(e.fingerprint.toUpperCase(),"hex");if(i.length!==de.getFingerprintLengthForHashType(e.hash))throw new Error("Invalid fingerprint length");return i.copy(r,n),n+=i.byteLength,de.encode.bytes=n-o,r.writeUInt16BE(de.encode.bytes-2,o),r};de.encode.bytes=0;de.decode=function(e,r){r||(r=0);let n=r,o={};r+=2,o.algorithm=e[r],r+=1,o.hash=e[r],r+=1;let i=de.getFingerprintLengthForHashType(o.hash);return o.fingerprint=e.slice(r,r+i).toString("hex").toUpperCase(),r+=i,de.decode.bytes=r-n,o};de.decode.bytes=0;de.encodingLength=function(t){return 4+S.from(t.fingerprint,"hex").byteLength};var Te=v.naptr={};Te.encode=function(t,e,r){e||(e=S.alloc(Te.encodingLength(t))),r||(r=0);let n=r;return r+=2,e.writeUInt16BE(t.order||0,r),r+=2,e.writeUInt16BE(t.preference||0,r),r+=2,O.encode(t.flags,e,r),r+=O.encode.bytes,O.encode(t.services,e,r),r+=O.encode.bytes,O.encode(t.regexp,e,r),r+=O.encode.bytes,w.encode(t.replacement,e,r),r+=w.encode.bytes,Te.encode.bytes=r-n,e.writeUInt16BE(Te.encode.bytes-2,n),e};Te.encode.bytes=0;Te.decode=function(t,e){e||(e=0);let r=e,n={};return e+=2,n.order=t.readUInt16BE(e),e+=2,n.preference=t.readUInt16BE(e),e+=2,n.flags=O.decode(t,e),e+=O.decode.bytes,n.services=O.decode(t,e),e+=O.decode.bytes,n.regexp=O.decode(t,e),e+=O.decode.bytes,n.replacement=w.decode(t,e),e+=w.decode.bytes,Te.decode.bytes=e-r,n};Te.decode.bytes=0;Te.encodingLength=function(t){return O.encodingLength(t.flags)+O.encodingLength(t.services)+O.encodingLength(t.regexp)+w.encodingLength(t.replacement)+6};var Ne=v.tlsa={};Ne.encode=function(t,e,r){e||(e=S.alloc(Ne.encodingLength(t))),r||(r=0);let n=r,o=t.certificate;if(!S.isBuffer(o))throw new Error("Certificate must be a Buffer");return r+=2,e.writeUInt8(t.usage,r),r+=1,e.writeUInt8(t.selector,r),r+=1,e.writeUInt8(t.matchingType,r),r+=1,o.copy(e,r,0,o.length),r+=o.length,Ne.encode.bytes=r-n,e.writeUInt16BE(Ne.encode.bytes-2,n),e};Ne.encode.bytes=0;Ne.decode=function(t,e){e||(e=0);let r=e,n={},o=t.readUInt16BE(e);return e+=2,n.usage=t.readUInt8(e),e+=1,n.selector=t.readUInt8(e),e+=1,n.matchingType=t.readUInt8(e),e+=1,n.certificate=t.slice(e,r+o+2),e+=n.certificate.length,Ne.decode.bytes=e-r,n};Ne.decode.bytes=0;Ne.encodingLength=function(t){return 5+S.byteLength(t.certificate)};var on=v.record=function(t){switch(t.toUpperCase()){case"A":return Ke;case"PTR":return we;case"CNAME":return Zs;case"DNAME":return Ws;case"TXT":return ke;case"NULL":return _e;case"AAAA":return qe;case"SRV":return Fe;case"HINFO":return Me;case"CAA":return ae;case"NS":return Re;case"SOA":return De;case"MX":return et;case"OPT":return ue;case"DNSKEY":return J;case"RRSIG":return Se;case"RP":return Ae;case"NSEC":return Be;case"NSEC3":return Ue;case"SSHFP":return de;case"DS":return Le;case"NAPTR":return Te;case"TLSA":return Ne}return Pe},Y=v.answer={};Y.encode=function(t,e,r){e||(e=S.alloc(Y.encodingLength(t))),r||(r=0);let n=r;if(w.encode(t.name,e,r),r+=w.encode.bytes,e.writeUInt16BE(ze.toType(t.type),r),t.type.toUpperCase()==="OPT"){if(t.name!==".")throw new Error("OPT name must be root.");e.writeUInt16BE(t.udpPayloadSize||4096,r+2),e.writeUInt8(t.extendedRcode||0,r+4),e.writeUInt8(t.ednsVersion||0,r+5),e.writeUInt16BE(t.flags||0,r+6),r+=8,ue.encode(t.options||[],e,r),r+=ue.encode.bytes}else{let o=mr.toClass(t.class===void 0?"IN":t.class);t.flush&&(o|=nn),e.writeUInt16BE(o,r+2),e.writeUInt32BE(t.ttl||0,r+4),r+=8;let i=on(t.type);i.encode(t.data,e,r),r+=i.encode.bytes}return Y.encode.bytes=r-n,e};Y.encode.bytes=0;Y.decode=function(t,e){e||(e=0);let r={},n=e;if(r.name=w.decode(t,e),e+=w.decode.bytes,r.type=ze.toString(t.readUInt16BE(e)),r.type==="OPT")r.udpPayloadSize=t.readUInt16BE(e+2),r.extendedRcode=t.readUInt8(e+4),r.ednsVersion=t.readUInt8(e+5),r.flags=t.readUInt16BE(e+6),r.flag_do=(r.flags>>15&1)===1,r.options=ue.decode(t,e+8),e+=8+ue.decode.bytes;else{let o=t.readUInt16BE(e+2);r.ttl=t.readUInt32BE(e+4),r.class=mr.toString(o&Ys),r.flush=!!(o&nn);let i=on(r.type);r.data=i.decode(t,e+8),e+=8+i.decode.bytes}return Y.decode.bytes=e-n,r};Y.decode.bytes=0;Y.encodingLength=function(t){let e=t.data!==null&&t.data!==void 0?t.data:t.options;return w.encodingLength(t.name)+8+on(t.type).encodingLength(e)};var xe=v.question={};xe.encode=function(t,e,r){e||(e=S.alloc(xe.encodingLength(t))),r||(r=0);let n=r;return w.encode(t.name,e,r),r+=w.encode.bytes,e.writeUInt16BE(ze.toType(t.type),r),r+=2,e.writeUInt16BE(mr.toClass(t.class===void 0?"IN":t.class),r),r+=2,xe.encode.bytes=r-n,t};xe.encode.bytes=0;xe.decode=function(t,e){e||(e=0);let r=e,n={};return n.name=w.decode(t,e),e+=w.decode.bytes,n.type=ze.toString(t.readUInt16BE(e)),e+=2,n.class=mr.toString(t.readUInt16BE(e)),e+=2,!!(n.class&Yo)&&(n.class&=Xs),xe.decode.bytes=e-r,n};xe.decode.bytes=0;xe.encodingLength=function(t){return w.encodingLength(t.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(t,e,r){let n=!e;n&&(e=S.alloc(v.encodingLength(t))),r||(r=0);let o=r;return t.questions||(t.questions=[]),t.answers||(t.answers=[]),t.authorities||(t.authorities=[]),t.additionals||(t.additionals=[]),Ee.encode(t,e,r),r+=Ee.encode.bytes,r=Gt(t.questions,xe,e,r),r=Gt(t.answers,Y,e,r),r=Gt(t.authorities,Y,e,r),r=Gt(t.additionals,Y,e,r),v.encode.bytes=r-o,n&&v.encode.bytes!==e.length?e.slice(0,v.encode.bytes):e};v.encode.bytes=0;v.decode=function(t,e){e||(e=0);let r=e,n=Ee.decode(t,e);return e+=Ee.decode.bytes,e=pr(n.questions,xe,t,e),e=pr(n.answers,Y,t,e),e=pr(n.authorities,Y,t,e),e=pr(n.additionals,Y,t,e),v.decode.bytes=e-r,n};v.decode.bytes=0;v.encodingLength=function(t){return Ee.encodingLength(t)+Tt(t.questions||[],xe)+Tt(t.answers||[],Y)+Tt(t.authorities||[],Y)+Tt(t.additionals||[],Y)};v.streamEncode=function(t){let e=v.encode(t),r=S.alloc(2);r.writeUInt16BE(e.byteLength);let n=S.concat([r,e]);return v.streamEncode.bytes=n.byteLength,n};v.streamEncode.bytes=0;v.streamDecode=function(t){let e=t.readUInt16BE(0);if(t.byteLength<e+2)return null;let r=v.decode(t.slice(2));return v.streamDecode.bytes=v.decode.bytes,r};v.streamDecode.bytes=0;function Tt(t,e){let r=0;for(let n=0;n<t.length;n++)r+=e.encodingLength(t[n]);return r}function Gt(t,e,r,n){for(let o=0;o<t.length;o++)e.encode(t[o],r,n),n+=e.encode.bytes;return n}function pr(t,e,r,n){for(let o=0;o<t.length;o++)t[o]=e.decode(r,n),n+=e.decode.bytes;return n}});var Qo=ve((Ru,Wo)=>{"use strict";var Zo=nc;process.nextTick(rc,42);Wo.exports=Qs;function Qs(t){var e=n;return r;function r(o){e(o||ec)}function n(o){var i=[o];e=s,t(a);function s(c){i.push(c)}function a(c){var d=arguments;for(e=Js(c)?n:g;i.length;)g(i.shift());function g(l){Zo(tc,l,d)}}}}function Js(t){return Object.prototype.toString.call(t)==="[object Error]"}function ec(){}function tc(t,e){t.apply(null,e)}function rc(t){t===42&&(Zo=process.nextTick)}function nc(t,e,r){process.nextTick(function(){t(e,r)})}});var ti=ve((Du,ei)=>{var sn=Xo(),oc=ne("dgram"),ic=Qo(),sc=ne("events"),an=ne("os"),cn=function(){};ei.exports=function(t){t||(t={});var e=new sc.EventEmitter,r=typeof t.port=="number"?t.port:5353,n=t.type||"udp4",o=t.ip||t.host||(n==="udp4"?"224.0.0.251":null),i={address:o,port:r},s={},a=!1,c=null;if(n==="udp6"&&(!o||!t.interface))throw new Error("For IPv6 multicast you must specify `ip` and `interface`");var d=t.socket||oc.createSocket({type:n,reuseAddr:t.reuseAddr!==!1,toString:function(){return n}});d.on("error",function(l){l.code==="EACCES"||l.code==="EADDRINUSE"?e.emit("error",l):e.emit("warning",l)}),d.on("message",function(l,u){try{l=sn.decode(l)}catch(p){e.emit("warning",p);return}e.emit("packet",l,u),l.type==="query"&&e.emit("query",l,u),l.type==="response"&&e.emit("response",l,u)}),d.on("listening",function(){r||(r=i.port=d.address().port),t.multicast!==!1&&(e.update(),c=setInterval(e.update,5e3),d.setMulticastTTL(t.ttl||255),d.setMulticastLoopback(t.loopback!==!1))});var g=ic(function(l){if(!r||t.bind===!1)return l(null);d.once("error",l),d.bind(r,t.bind||t.interface,function(){d.removeListener("error",l),l(null)})});return g(function(l){if(l)return e.emit("error",l);e.emit("ready")}),e.send=function(l,u,p){if(typeof u=="function")return e.send(l,null,u);p||(p=cn),u?!u.host&&!u.address&&(u.address=i.address):u=i,g(h);function h(y){if(a)return p();if(y)return p(y);var m=sn.encode(l);d.send(m,0,m.length,u.port,u.address||u.host,p)}},e.response=e.respond=function(l,u,p){Array.isArray(l)&&(l={answers:l}),l.type="response",l.flags=(l.flags||0)|sn.AUTHORITATIVE_ANSWER,e.send(l,u,p)},e.query=function(l,u,p,h){if(typeof u=="function")return e.query(l,null,null,u);if(typeof u=="object"&&u&&u.port)return e.query(l,null,u,p);if(typeof p=="function")return e.query(l,u,null,p);h||(h=cn),typeof l=="string"&&(l=[{name:l,type:u||"ANY"}]),Array.isArray(l)&&(l={type:"query",questions:l}),l.type="query",e.send(l,p,h)},e.destroy=function(l){if(l||(l=cn),a)return process.nextTick(l);a=!0,clearInterval(c);for(var u in s)try{d.dropMembership(o,u)}catch{}s={},d.close(l)},e.update=function(){for(var l=t.interface?[].concat(t.interface):ac(),u=!1,p=0;p<l.length;p++){var h=l[p];if(!s[h])try{d.addMembership(o,h),s[h]=!0,u=!0}catch(y){e.emit("warning",y)}}if(u){if(d.setMulticastInterface)try{d.setMulticastInterface(t.interface||cc())}catch(y){e.emit("warning",y)}e.emit("networkInterface")}},e};function cc(){for(var t=an.networkInterfaces(),e=Object.keys(t),r=0;r<e.length;r++)for(var n=t[e[r]],o=0;o<n.length;o++){var i=n[o];if(Jo(i.family)&&!i.internal)return an.platform()==="darwin"&&e[r]==="en0"?i.address:"0.0.0.0"}return"127.0.0.1"}function ac(){for(var t=an.networkInterfaces(),e=Object.keys(t),r=[],n=0;n<e.length;n++)for(var o=t[e[n]],i=0;i<o.length;i++){var s=o[i];if(Jo(s.family)){r.push(s.address);break}}return r}function Jo(t){return t===4||t==="IPv4"}});var ws=ve(cr=>{(function(){var t,e,r,n,o,i,s,a;a=function(c){var d,g,l,u;return d=(c&255<<24)>>>24,g=(c&255<<16)>>>16,l=(c&65280)>>>8,u=c&255,[d,g,l,u].join(".")},s=function(c){var d,g,l,u,p,h;for(d=[],l=u=0;u<=3&&c.length!==0;l=++u){if(l>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),d.push(p)}if(c.length!==0)throw new Error("Invalid IP");switch(d.length){case 1:if(d[0]>4294967295)throw new Error("Invalid IP");return d[0]>>>0;case 2:if(d[0]>255||d[1]>16777215)throw new Error("Invalid IP");return(d[0]<<24|d[1])>>>0;case 3:if(d[0]>255||d[1]>255||d[2]>65535)throw new Error("Invalid IP");return(d[0]<<24|d[1]<<16|d[2])>>>0;case 4:if(d[0]>255||d[1]>255||d[2]>255||d[3]>255)throw new Error("Invalid IP");return(d[0]<<24|d[1]<<16|d[2]<<8|d[3])>>>0;default:throw new Error("Invalid IP")}},r=function(c){return c.charCodeAt(0)},n=r("0"),i=r("a"),o=r("A"),e=function(c){var d,g,l,u,p;for(u=0,d=10,g="9",l=0,c.length>1&&c[l]==="0"&&(c[l+1]==="x"||c[l+1]==="X"?(l+=2,d=16):"0"<=c[l+1]&&c[l+1]<="9"&&(l++,d=8,g="7")),p=l;l<c.length;){if("0"<=c[l]&&c[l]<=g)u=u*d+(r(c[l])-n)>>>0;else if(d===16)if("a"<=c[l]&&c[l]<="f")u=u*d+(10+r(c[l])-i)>>>0;else if("A"<=c[l]&&c[l]<="F")u=u*d+(10+r(c[l])-o)>>>0;else break;else break;if(u>4294967295)throw new Error("too large");l++}if(l===p)throw new Error("empty octet");return[u,l]},t=function(){function c(d,g){var l,u,p,h;if(typeof d!="string")throw new Error("Missing `net' parameter");if(g||(h=d.split("/",2),d=h[0],g=h[1]),g||(g=32),typeof g=="string"&&g.indexOf(".")>-1){try{this.maskLong=s(g)}catch(y){throw l=y,new Error("Invalid mask: "+g)}for(u=p=32;p>=0;u=--p)if(this.maskLong===4294967295<<32-u>>>0){this.bitmask=u;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(d)&this.maskLong)>>>0}catch(y){throw l=y,new Error("Invalid net address: "+d)}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(d){return typeof d=="string"&&(d.indexOf("/")>0||d.split(".").length!==4)&&(d=new c(d)),d instanceof c?this.contains(d.base)&&this.contains(d.broadcast||d.last):(s(d)&this.maskLong)>>>0===(this.netLong&this.maskLong)>>>0},c.prototype.next=function(d){return d==null&&(d=1),new c(a(this.netLong+this.size*d),this.mask)},c.prototype.forEach=function(d){var g,l,u;for(u=s(this.first),l=s(this.last),g=0;u<=l;)d(a(u),u,g),g++,u++},c.prototype.toString=function(){return this.base+"/"+this.bitmask},c}(),cr.ip2long=s,cr.long2ip=a,cr.Netmask=t}).call(cr)});var Zd={};oe(Zd,{mdns:()=>Xd});var Do=Symbol.for("@libp2p/peer-discovery");var Xr=Symbol.for("@libp2p/peer-id");var Lt=class extends Error{static name="InvalidParametersError";constructor(e="Invalid parameters"){super(e),this.name="InvalidParametersError"}},ur=class extends Error{static name="InvalidPublicKeyError";constructor(e="Invalid public key"){super(e),this.name="InvalidPublicKeyError"}};var lr=class extends Error{static name="InvalidMultihashError";constructor(e="Invalid Multihash"){super(e),this.name="InvalidMultihashError"}};var $t=class extends Error{static name="UnsupportedKeyTypeError";constructor(e="Unsupported key type"){super(e),this.name="UnsupportedKeyTypeError"}};var ko=ne("events"),_o=(t,...e)=>{try{(0,ko.setMaxListeners)(t,...e)}catch{}};var hr=class extends EventTarget{#e=new Map;constructor(){super(),_o(1/0,this)}listenerCount(e){let r=this.#e.get(e);return r==null?0:r.length}addEventListener(e,r,n){super.addEventListener(e,r,n);let o=this.#e.get(e);o==null&&(o=[],this.#e.set(e,o)),o.push({callback:r,once:(n!==!0&&n!==!1&&n?.once)??!1})}removeEventListener(e,r,n){super.removeEventListener(e.toString(),r??null,n);let o=this.#e.get(e);o!=null&&(o=o.filter(({callback:i})=>i!==r),this.#e.set(e,o))}dispatchEvent(e){let r=super.dispatchEvent(e),n=this.#e.get(e.type);return n==null||(n=n.filter(({once:o})=>!o),this.#e.set(e.type,n)),r}safeDispatchEvent(e,r={}){return this.dispatchEvent(new CustomEvent(e,r))}};var Mo=Symbol.for("@libp2p/service-capabilities"),ou=Symbol.for("@libp2p/service-dependencies");var Ms=Ut(ti(),1);var pn={};oe(pn,{base58btc:()=>K,base58flickr:()=>mc});var ku=new Uint8Array(0);function ri(t,e){if(t===e)return!0;if(t.byteLength!==e.byteLength)return!1;for(let r=0;r<t.byteLength;r++)if(t[r]!==e[r])return!1;return!0}function me(t){if(t instanceof Uint8Array&&t.constructor.name==="Uint8Array")return t;if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);throw new Error("Unknown type, must be binary type")}function ni(t){return new TextEncoder().encode(t)}function oi(t){return new TextDecoder().decode(t)}function dc(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var o=0;o<t.length;o++){var i=t.charAt(o),s=i.charCodeAt(0);if(r[s]!==255)throw new TypeError(i+" is ambiguous");r[s]=o}var a=t.length,c=t.charAt(0),d=Math.log(a)/Math.log(256),g=Math.log(256)/Math.log(a);function l(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 y=0,m=0,f=0,x=h.length;f!==x&&h[f]===0;)f++,y++;for(var b=(x-f)*g+1>>>0,L=new Uint8Array(b);f!==x;){for(var T=h[f],B=0,U=b-1;(T!==0||B<m)&&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");m=B,f++}for(var N=b-m;N!==b&&L[N]===0;)N++;for(var C=c.repeat(y);N<b;++N)C+=t.charAt(L[N]);return C}function u(h){if(typeof h!="string")throw new TypeError("Expected String");if(h.length===0)return new Uint8Array;var y=0;if(h[y]!==" "){for(var m=0,f=0;h[y]===c;)m++,y++;for(var x=(h.length-y)*d+1>>>0,b=new Uint8Array(x);h[y];){var L=r[h.charCodeAt(y)];if(L===255)return;for(var T=0,B=x-1;(L!==0||T<f)&&B!==-1;B--,T++)L+=a*b[B]>>>0,b[B]=L%256>>>0,L=L/256>>>0;if(L!==0)throw new Error("Non-zero carry");f=T,y++}if(h[y]!==" "){for(var U=x-f;U!==x&&b[U]===0;)U++;for(var N=new Uint8Array(m+(x-U)),C=m;U!==x;)N[C++]=b[U++];return N}}}function p(h){var y=u(h);if(y)return y;throw new Error(`Non-${e} character`)}return{encode:l,decodeUnsafe:u,decode:p}}var uc=dc,lc=uc,si=lc;var dn=class{name;prefix;baseEncode;constructor(e,r,n){this.name=e,this.prefix=r,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},un=class{name;prefix;baseDecode;prefixCodePoint;constructor(e,r,n){this.name=e,this.prefix=r;let o=r.codePointAt(0);if(o===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=o,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 ci(this,e)}},ln=class{decoders;constructor(e){this.decoders=e}or(e){return ci(this,e)}decode(e){let r=e[0],n=this.decoders[r];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 ci(t,e){return new ln({...t.decoders??{[t.prefix]:t},...e.decoders??{[e.prefix]:e}})}var hn=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(e,r,n,o){this.name=e,this.prefix=r,this.baseEncode=n,this.baseDecode=o,this.encoder=new dn(e,r,n),this.decoder=new un(e,r,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};function Nt({name:t,prefix:e,encode:r,decode:n}){return new hn(t,e,r,n)}function tt({name:t,prefix:e,alphabet:r}){let{encode:n,decode:o}=si(r,t);return Nt({prefix:e,name:t,encode:n,decode:i=>me(o(i))})}function hc(t,e,r,n){let o={};for(let g=0;g<e.length;++g)o[e[g]]=g;let i=t.length;for(;t[i-1]==="=";)--i;let s=new Uint8Array(i*r/8|0),a=0,c=0,d=0;for(let g=0;g<i;++g){let l=o[t[g]];if(l===void 0)throw new SyntaxError(`Non-${n} character`);c=c<<r|l,a+=r,a>=8&&(a-=8,s[d++]=255&c>>a)}if(a>=r||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return s}function pc(t,e,r){let n=e[e.length-1]==="=",o=(1<<r)-1,i="",s=0,a=0;for(let c=0;c<t.length;++c)for(a=a<<8|t[c],s+=8;s>r;)s-=r,i+=e[o&a>>s];if(s!==0&&(i+=e[o&a<<r-s]),n)for(;i.length*r&7;)i+="=";return i}function F({name:t,prefix:e,bitsPerChar:r,alphabet:n}){return Nt({prefix:e,name:t,encode(o){return pc(o,n,r)},decode(o){return hc(o,n,r,t)}})}var K=tt({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),mc=tt({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var mn={};oe(mn,{base32:()=>Ve,base32hex:()=>wc,base32hexpad:()=>Ec,base32hexpadupper:()=>bc,base32hexupper:()=>xc,base32pad:()=>yc,base32padupper:()=>fc,base32upper:()=>gc,base32z:()=>Ic});var Ve=F({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),gc=F({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),yc=F({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),fc=F({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),wc=F({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),xc=F({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Ec=F({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),bc=F({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Ic=F({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var gn={};oe(gn,{base36:()=>Yt,base36upper:()=>vc});var Yt=tt({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),vc=tt({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Sc=ui,ai=128,Ac=127,Bc=~Ac,Uc=Math.pow(2,31);function ui(t,e,r){e=e||[],r=r||0;for(var n=r;t>=Uc;)e[r++]=t&255|ai,t/=128;for(;t&Bc;)e[r++]=t&255|ai,t>>>=7;return e[r]=t|0,ui.bytes=r-n+1,e}var Lc=yn,Tc=128,di=127;function yn(t,n){var r=0,n=n||0,o=0,i=n,s,a=t.length;do{if(i>=a)throw yn.bytes=0,new RangeError("Could not decode varint");s=t[i++],r+=o<28?(s&di)<<o:(s&di)*Math.pow(2,o),o+=7}while(s>=Tc);return yn.bytes=i-n,r}var Nc=Math.pow(2,7),Cc=Math.pow(2,14),Oc=Math.pow(2,21),Pc=Math.pow(2,28),Rc=Math.pow(2,35),Dc=Math.pow(2,42),kc=Math.pow(2,49),_c=Math.pow(2,56),Mc=Math.pow(2,63),Fc=function(t){return t<Nc?1:t<Cc?2:t<Oc?3:t<Pc?4:t<Rc?5:t<Dc?6:t<kc?7:t<_c?8:t<Mc?9:10},Kc={encode:Sc,decode:Lc,encodingLength:Fc},qc=Kc,Xt=qc;function Zt(t,e=0){return[Xt.decode(t,e),Xt.decode.bytes]}function Ct(t,e,r=0){return Xt.encode(t,e,r),e}function Ot(t){return Xt.encodingLength(t)}function ht(t,e){let r=e.byteLength,n=Ot(t),o=n+Ot(r),i=new Uint8Array(o+r);return Ct(t,i,0),Ct(r,i,n),i.set(e,o),new Pt(t,r,e,i)}function pt(t){let e=me(t),[r,n]=Zt(e),[o,i]=Zt(e.subarray(n)),s=e.subarray(n+i);if(s.byteLength!==o)throw new Error("Incorrect length");return new Pt(r,o,s,e)}function li(t,e){if(t===e)return!0;{let r=e;return t.code===r.code&&t.size===r.size&&r.bytes instanceof Uint8Array&&ri(t.bytes,r.bytes)}}var Pt=class{code;size;digest;bytes;constructor(e,r,n,o){this.code=e,this.size=r,this.digest=n,this.bytes=o}};function hi(t,e){let{bytes:r,version:n}=t;switch(n){case 0:return Vc(r,fn(t),e??K.encoder);default:return Hc(r,fn(t),e??Ve.encoder)}}var pi=new WeakMap;function fn(t){let e=pi.get(t);if(e==null){let r=new Map;return pi.set(t,r),r}return e}var ee=class t{code;version;multihash;bytes;"/";constructor(e,r,n,o){this.code=r,this.version=e,this.multihash=n,this.bytes=o,this["/"]=o}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:r}=this;if(e!==Wt)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==jc)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return t.createV0(r)}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:r}=this.multihash,n=ht(e,r);return t.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 t.equals(this,e)}static equals(e,r){let n=r;return n!=null&&e.code===n.code&&e.version===n.version&&li(e.multihash,n.multihash)}toString(e){return hi(this,e)}toJSON(){return{"/":hi(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 r=e;if(r instanceof t)return r;if(r["/"]!=null&&r["/"]===r.bytes||r.asCID===r){let{version:n,code:o,multihash:i,bytes:s}=r;return new t(n,o,i,s??mi(n,o,i.bytes))}else if(r[$c]===!0){let{version:n,multihash:o,code:i}=r,s=pt(o);return t.create(n,i,s)}else return null}static create(e,r,n){if(typeof r!="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(r!==Wt)throw new Error(`Version 0 CID must use dag-pb (code: ${Wt}) block encoding`);return new t(e,r,n,n.bytes)}case 1:{let o=mi(e,r,n.bytes);return new t(e,r,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return t.create(0,Wt,e)}static createV1(e,r){return t.create(1,e,r)}static decode(e){let[r,n]=t.decodeFirst(e);if(n.length!==0)throw new Error("Incorrect length");return r}static decodeFirst(e){let r=t.inspectBytes(e),n=r.size-r.multihashSize,o=me(e.subarray(n,n+r.multihashSize));if(o.byteLength!==r.multihashSize)throw new Error("Incorrect length");let i=o.subarray(r.multihashSize-r.digestSize),s=new Pt(r.multihashCode,r.digestSize,i,o);return[r.version===0?t.createV0(s):t.createV1(r.codec,s),e.subarray(r.size)]}static inspectBytes(e){let r=0,n=()=>{let[l,u]=Zt(e.subarray(r));return r+=u,l},o=n(),i=Wt;if(o===18?(o=0,r=0):i=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let s=r,a=n(),c=n(),d=r+c,g=d-s;return{version:o,codec:i,multihashCode:a,digestSize:c,multihashSize:g,size:d}}static parse(e,r){let[n,o]=zc(e,r),i=t.decode(o);if(i.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return fn(i).set(n,e),i}};function zc(t,e){switch(t[0]){case"Q":{let r=e??K;return[K.prefix,r.decode(`${K.prefix}${t}`)]}case K.prefix:{let r=e??K;return[K.prefix,r.decode(t)]}case Ve.prefix:{let r=e??Ve;return[Ve.prefix,r.decode(t)]}case Yt.prefix:{let r=e??Yt;return[Yt.prefix,r.decode(t)]}default:{if(e==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[t[0],e.decode(t)]}}}function Vc(t,e,r){let{prefix:n}=r;if(n!==K.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);let o=e.get(n);if(o==null){let i=r.encode(t).slice(1);return e.set(n,i),i}else return o}function Hc(t,e,r){let{prefix:n}=r,o=e.get(n);if(o==null){let i=r.encode(t);return e.set(n,i),i}else return o}var Wt=112,jc=18;function mi(t,e,r){let n=Ot(t),o=n+Ot(e),i=new Uint8Array(o+r.byteLength);return Ct(t,i,0),Ct(e,i,n),i.set(r,o),i}var $c=Symbol.for("@ipld/js-cid/CID");var wn={};oe(wn,{identity:()=>He});var gi=0,Gc="identity",yi=me;function Yc(t){return ht(gi,yi(t))}var He={code:gi,name:Gc,encode:yi,digest:Yc};function je(t,e){if(t===e)return!0;if(t.byteLength!==e.byteLength)return!1;for(let r=0;r<t.byteLength;r++)if(t[r]!==e[r])return!1;return!0}var fr=Ut(ne("crypto"),1);var fi=ne("node:buffer");function Rt(t){return new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}function Ce(t,e){return Rt(fi.Buffer.concat(t,e))}var vi=ne("node:buffer");var xn={};oe(xn,{base10:()=>Xc});var Xc=tt({prefix:"9",name:"base10",alphabet:"0123456789"});var En={};oe(En,{base16:()=>Zc,base16upper:()=>Wc});var Zc=F({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Wc=F({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var bn={};oe(bn,{base2:()=>Qc});var Qc=F({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var In={};oe(In,{base256emoji:()=>na});var wi=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}"),Jc=wi.reduce((t,e,r)=>(t[r]=e,t),[]),ea=wi.reduce((t,e,r)=>{let n=e.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${e}`);return t[n]=r,t},[]);function ta(t){return t.reduce((e,r)=>(e+=Jc[r],e),"")}function ra(t){let e=[];for(let r of t){let n=r.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${r}`);let o=ea[n];if(o==null)throw new Error(`Non-base256emoji character: ${r}`);e.push(o)}return new Uint8Array(e)}var na=Nt({prefix:"\u{1F680}",name:"base256emoji",encode:ta,decode:ra});var vn={};oe(vn,{base64:()=>oa,base64pad:()=>ia,base64url:()=>sa,base64urlpad:()=>ca});var oa=F({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),ia=F({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),sa=F({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),ca=F({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Sn={};oe(Sn,{base8:()=>aa});var aa=F({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var An={};oe(An,{identity:()=>da});var da=Nt({prefix:"\0",name:"identity",encode:t=>oi(t),decode:t=>ni(t)});var hl=new TextEncoder,pl=new TextDecoder;var Nn={};oe(Nn,{sha256:()=>Tn,sha512:()=>ha});var Ln=Ut(ne("crypto"),1);function Un({name:t,code:e,encode:r}){return new Bn(t,e,r)}var Bn=class{name;code;encode;constructor(e,r,n){this.name=e,this.code=r,this.encode=n}digest(e){if(e instanceof Uint8Array){let r=this.encode(e);return r instanceof Uint8Array?ht(this.code,r):r.then(n=>ht(this.code,n))}else throw Error("Unknown type, must be binary type")}};var Tn=Un({name:"sha2-256",code:18,encode:t=>me(Ln.default.createHash("sha256").update(t).digest())}),ha=Un({name:"sha2-512",code:19,encode:t=>me(Ln.default.createHash("sha512").update(t).digest())});var Qt={...An,...bn,...Sn,...xn,...En,...mn,...gn,...pn,...vn,...In},Bl={...Nn,...wn};var Ei=ne("node:buffer");function $e(t=0){return Rt(Ei.Buffer.allocUnsafe(t))}function Ii(t,e,r,n){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:n}}}var bi=Ii("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),Cn=Ii("ascii","a",t=>{let e="a";for(let r=0;r<t.length;r++)e+=String.fromCharCode(t[r]);return e},t=>{t=t.substring(1);let e=$e(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}),pa={utf8:bi,"utf-8":bi,hex:Qt.base16,latin1:Cn,ascii:Cn,binary:Cn,...Qt},yr=pa;function Ge(t,e="utf8"){let r=yr[e];if(r==null)throw new Error(`Unsupported encoding "${e}"`);return e==="utf8"||e==="utf-8"?Rt(vi.Buffer.from(t,"utf-8")):r.decoder.decode(`${r.prefix}${t}`)}var Si=ne("node:buffer");function z(t,e="utf8"){let r=yr[e];if(r==null)throw new Error(`Unsupported encoding "${e}"`);return e==="utf8"||e==="utf-8"?Si.Buffer.from(t.buffer,t.byteOffset,t.byteLength).toString("utf8"):r.encoder.encode(t).substring(1)}var ql=fr.default.generateKeyPairSync,Jt=32;var ma=64;function Ai(t,e,r){if(t.byteLength!==Jt)throw new TypeError('"key" must be 32 bytes in length.');if(!(t instanceof Uint8Array))throw new TypeError('"key" must be a node.js Buffer, or Uint8Array.');if(e.byteLength!==ma)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=fr.default.createPublicKey({format:"jwk",key:{crv:"Ed25519",x:z(t,"base64url"),kty:"OKP"}});return fr.default.verify(null,r instanceof Uint8Array?r:r.subarray(),n,e)}var wr=class{type="Ed25519";raw;constructor(e){this.raw=On(e,Jt)}toMultihash(){return He.digest(xr(this))}toCID(){return ee.createV1(114,this.toMultihash())}toString(){return K.encode(this.toMultihash().bytes).substring(1)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:je(this.raw,e.raw)}verify(e,r){return Ai(this.raw,r,e)}};function Ui(t){return t=On(t,Jt),new wr(t)}function On(t,e){if(t=Uint8Array.from(t??[]),t.length!==e)throw new Lt(`Key must be a Uint8Array of length ${e}, got ${t.length}`);return t}var ya=Math.pow(2,7),fa=Math.pow(2,14),wa=Math.pow(2,21),Pn=Math.pow(2,28),Rn=Math.pow(2,35),Dn=Math.pow(2,42),kn=Math.pow(2,49),D=128,X=127;function se(t){if(t<ya)return 1;if(t<fa)return 2;if(t<wa)return 3;if(t<Pn)return 4;if(t<Rn)return 5;if(t<Dn)return 6;if(t<kn)return 7;if(Number.MAX_SAFE_INTEGER!=null&&t>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function _n(t,e,r=0){switch(se(t)){case 8:e[r++]=t&255|D,t/=128;case 7:e[r++]=t&255|D,t/=128;case 6:e[r++]=t&255|D,t/=128;case 5:e[r++]=t&255|D,t/=128;case 4:e[r++]=t&255|D,t>>>=7;case 3:e[r++]=t&255|D,t>>>=7;case 2:e[r++]=t&255|D,t>>>=7;case 1:{e[r++]=t&255,t>>>=7;break}default:throw new Error("unreachable")}return e}function xa(t,e,r=0){switch(se(t)){case 8:e.set(r++,t&255|D),t/=128;case 7:e.set(r++,t&255|D),t/=128;case 6:e.set(r++,t&255|D),t/=128;case 5:e.set(r++,t&255|D),t/=128;case 4:e.set(r++,t&255|D),t>>>=7;case 3:e.set(r++,t&255|D),t>>>=7;case 2:e.set(r++,t&255|D),t>>>=7;case 1:{e.set(r++,t&255),t>>>=7;break}default:throw new Error("unreachable")}return e}function Mn(t,e){let r=t[e],n=0;if(n+=r&X,r<D||(r=t[e+1],n+=(r&X)<<7,r<D)||(r=t[e+2],n+=(r&X)<<14,r<D)||(r=t[e+3],n+=(r&X)<<21,r<D)||(r=t[e+4],n+=(r&X)*Pn,r<D)||(r=t[e+5],n+=(r&X)*Rn,r<D)||(r=t[e+6],n+=(r&X)*Dn,r<D)||(r=t[e+7],n+=(r&X)*kn,r<D))return n;throw new RangeError("Could not decode varint")}function Ea(t,e){let r=t.get(e),n=0;if(n+=r&X,r<D||(r=t.get(e+1),n+=(r&X)<<7,r<D)||(r=t.get(e+2),n+=(r&X)<<14,r<D)||(r=t.get(e+3),n+=(r&X)<<21,r<D)||(r=t.get(e+4),n+=(r&X)*Pn,r<D)||(r=t.get(e+5),n+=(r&X)*Rn,r<D)||(r=t.get(e+6),n+=(r&X)*Dn,r<D)||(r=t.get(e+7),n+=(r&X)*kn,r<D))return n;throw new RangeError("Could not decode varint")}function Dt(t,e,r=0){return e==null&&(e=$e(se(t))),e instanceof Uint8Array?_n(t,e,r):xa(t,e,r)}function gt(t,e=0){return t instanceof Uint8Array?Mn(t,e):Ea(t,e)}var Fn=new Float32Array([-0]),rt=new Uint8Array(Fn.buffer);function Ti(t,e,r){Fn[0]=t,e[r]=rt[0],e[r+1]=rt[1],e[r+2]=rt[2],e[r+3]=rt[3]}function Ni(t,e){return rt[0]=t[e],rt[1]=t[e+1],rt[2]=t[e+2],rt[3]=t[e+3],Fn[0]}var Kn=new Float64Array([-0]),Z=new Uint8Array(Kn.buffer);function Ci(t,e,r){Kn[0]=t,e[r]=Z[0],e[r+1]=Z[1],e[r+2]=Z[2],e[r+3]=Z[3],e[r+4]=Z[4],e[r+5]=Z[5],e[r+6]=Z[6],e[r+7]=Z[7]}function Oi(t,e){return Z[0]=t[e],Z[1]=t[e+1],Z[2]=t[e+2],Z[3]=t[e+3],Z[4]=t[e+4],Z[5]=t[e+5],Z[6]=t[e+6],Z[7]=t[e+7],Kn[0]}var ba=BigInt(Number.MAX_SAFE_INTEGER),Ia=BigInt(Number.MIN_SAFE_INTEGER),le=class t{lo;hi;constructor(e,r){this.lo=e|0,this.hi=r|0}toNumber(e=!1){if(!e&&this.hi>>>31>0){let r=~this.lo+1>>>0,n=~this.hi>>>0;return r===0&&(n=n+1>>>0),-(r+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 r=~this.lo+1>>>0,n=~this.hi>>>0;return r===0&&(n=n+1>>>0),-(BigInt(r)+(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,r=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return n===0?r===0?e<16384?e<128?1:2:e<2097152?3:4:r<16384?r<128?5:6:r<2097152?7:8:n<128?9:10}static fromBigInt(e){if(e===0n)return yt;if(e<ba&&e>Ia)return this.fromNumber(Number(e));let r=e<0n;r&&(e=-e);let n=e>>32n,o=e-(n<<32n);return r&&(n=~n|0n,o=~o|0n,++o>Pi&&(o=0n,++n>Pi&&(n=0n))),new t(Number(o),Number(n))}static fromNumber(e){if(e===0)return yt;let r=e<0;r&&(e=-e);let n=e>>>0,o=(e-n)/4294967296>>>0;return r&&(o=~o>>>0,n=~n>>>0,++n>4294967295&&(n=0,++o>4294967295&&(o=0))),new t(n,o)}static from(e){return typeof e=="number"?t.fromNumber(e):typeof e=="bigint"?t.fromBigInt(e):typeof e=="string"?t.fromBigInt(BigInt(e)):e.low!=null||e.high!=null?new t(e.low>>>0,e.high>>>0):yt}},yt=new le(0,0);yt.toBigInt=function(){return 0n};yt.zzEncode=yt.zzDecode=function(){return this};yt.length=function(){return 1};var Pi=4294967296n;function Ri(t){let e=0,r=0;for(let n=0;n<t.length;++n)r=t.charCodeAt(n),r<128?e+=1:r<2048?e+=2:(r&64512)===55296&&(t.charCodeAt(n+1)&64512)===56320?(++n,e+=4):e+=3;return e}function Di(t,e,r){if(r-e<1)return"";let o,i=[],s=0,a;for(;e<r;)a=t[e++],a<128?i[s++]=a:a>191&&a<224?i[s++]=(a&31)<<6|t[e++]&63:a>239&&a<365?(a=((a&7)<<18|(t[e++]&63)<<12|(t[e++]&63)<<6|t[e++]&63)-65536,i[s++]=55296+(a>>10),i[s++]=56320+(a&1023)):i[s++]=(a&15)<<12|(t[e++]&63)<<6|t[e++]&63,s>8191&&((o??(o=[])).push(String.fromCharCode.apply(String,i)),s=0);return o!=null?(s>0&&o.push(String.fromCharCode.apply(String,i.slice(0,s))),o.join("")):String.fromCharCode.apply(String,i.slice(0,s))}function qn(t,e,r){let n=r,o,i;for(let s=0;s<t.length;++s)o=t.charCodeAt(s),o<128?e[r++]=o:o<2048?(e[r++]=o>>6|192,e[r++]=o&63|128):(o&64512)===55296&&((i=t.charCodeAt(s+1))&64512)===56320?(o=65536+((o&1023)<<10)+(i&1023),++s,e[r++]=o>>18|240,e[r++]=o>>12&63|128,e[r++]=o>>6&63|128,e[r++]=o&63|128):(e[r++]=o>>12|224,e[r++]=o>>6&63|128,e[r++]=o&63|128);return r-n}function be(t,e){return RangeError(`index out of range: ${t.pos} + ${e??1} > ${t.len}`)}function Er(t,e){return(t[e-4]|t[e-3]<<8|t[e-2]<<16|t[e-1]<<24)>>>0}var zn=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,be(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 be(this,4);return Er(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw be(this,4);return Er(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw be(this,4);let e=Ni(this.buf,this.pos);return this.pos+=4,e}double(){if(this.pos+8>this.len)throw be(this,4);let e=Oi(this.buf,this.pos);return this.pos+=8,e}bytes(){let e=this.uint32(),r=this.pos,n=this.pos+e;if(n>this.len)throw be(this,e);return this.pos+=e,r===n?new Uint8Array(0):this.buf.subarray(r,n)}string(){let e=this.bytes();return Di(e,0,e.length)}skip(e){if(typeof e=="number"){if(this.pos+e>this.len)throw be(this,e);this.pos+=e}else do if(this.pos>=this.len)throw be(this);while(this.buf[this.pos++]&128);return this}skipType(e){switch(e){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(e=this.uint32()&7)!==4;)this.skipType(e);break;case 5:this.skip(4);break;default:throw Error(`invalid wire type ${e} at offset ${this.pos}`)}return this}readLongVarint(){let e=new le(0,0),r=0;if(this.len-this.pos>4){for(;r<4;++r)if(e.lo=(e.lo|(this.buf[this.pos]&127)<<r*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;r=0}else{for(;r<3;++r){if(this.pos>=this.len)throw be(this);if(e.lo=(e.lo|(this.buf[this.pos]&127)<<r*7)>>>0,this.buf[this.pos++]<128)return e}return e.lo=(e.lo|(this.buf[this.pos++]&127)<<r*7)>>>0,e}if(this.len-this.pos>4){for(;r<5;++r)if(e.hi=(e.hi|(this.buf[this.pos]&127)<<r*7+3)>>>0,this.buf[this.pos++]<128)return e}else for(;r<5;++r){if(this.pos>=this.len)throw be(this);if(e.hi=(e.hi|(this.buf[this.pos]&127)<<r*7+3)>>>0,this.buf[this.pos++]<128)return e}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw be(this,8);let e=Er(this.buf,this.pos+=4),r=Er(this.buf,this.pos+=4);return new le(e,r)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){let e=Mn(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 Vn(t){return new zn(t instanceof Uint8Array?t:t.subarray())}function br(t,e,r){let n=Vn(t);return e.decode(n,void 0,r)}function Hn(t){let e=t??8192,r=e>>>1,n,o=e;return function(s){if(s<1||s>r)return $e(s);o+s>e&&(n=$e(e),o=0);let a=n.subarray(o,o+=s);return o&7&&(o=(o|7)+1),a}}var ft=class{fn;len;next;val;constructor(e,r,n){this.fn=e,this.len=r,this.next=void 0,this.val=n}};function jn(){}var Gn=class{head;tail;len;next;constructor(e){this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}},va=Hn();function Sa(t){return globalThis.Buffer!=null?$e(t):va(t)}var tr=class{len;head;tail;states;constructor(){this.len=0,this.head=new ft(jn,0,0),this.tail=this.head,this.states=null}_push(e,r,n){return this.tail=this.tail.next=new ft(e,r,n),this.len+=r,this}uint32(e){return this.len+=(this.tail=this.tail.next=new Yn((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(Ir,10,le.fromNumber(e)):this.uint32(e)}sint32(e){return this.uint32((e<<1^e>>31)>>>0)}uint64(e){let r=le.fromBigInt(e);return this._push(Ir,r.length(),r)}uint64Number(e){return this._push(_n,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 r=le.fromBigInt(e).zzEncode();return this._push(Ir,r.length(),r)}sint64Number(e){let r=le.fromNumber(e).zzEncode();return this._push(Ir,r.length(),r)}sint64String(e){return this.sint64(BigInt(e))}bool(e){return this._push($n,1,e?1:0)}fixed32(e){return this._push(er,4,e>>>0)}sfixed32(e){return this.fixed32(e)}fixed64(e){let r=le.fromBigInt(e);return this._push(er,4,r.lo)._push(er,4,r.hi)}fixed64Number(e){let r=le.fromNumber(e);return this._push(er,4,r.lo)._push(er,4,r.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(Ti,4,e)}double(e){return this._push(Ci,8,e)}bytes(e){let r=e.length>>>0;return r===0?this._push($n,1,0):this.uint32(r)._push(Ba,r,e)}string(e){let r=Ri(e);return r!==0?this.uint32(r)._push(qn,r,e):this._push($n,1,0)}fork(){return this.states=new Gn(this),this.head=this.tail=new ft(jn,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 ft(jn,0,0),this.len=0),this}ldelim(){let e=this.head,r=this.tail,n=this.len;return this.reset().uint32(n),n!==0&&(this.tail.next=e.next,this.tail=r,this.len+=n),this}finish(){let e=this.head.next,r=Sa(this.len),n=0;for(;e!=null;)e.fn(e.val,r,n),n+=e.len,e=e.next;return r}};function $n(t,e,r){e[r]=t&255}function Aa(t,e,r){for(;t>127;)e[r++]=t&127|128,t>>>=7;e[r]=t}var Yn=class extends ft{next;constructor(e,r){super(Aa,e,r),this.next=void 0}};function Ir(t,e,r){for(;t.hi!==0;)e[r++]=t.lo&127|128,t.lo=(t.lo>>>7|t.hi<<25)>>>0,t.hi>>>=7;for(;t.lo>127;)e[r++]=t.lo&127|128,t.lo=t.lo>>>7;e[r++]=t.lo}function er(t,e,r){e[r]=t&255,e[r+1]=t>>>8&255,e[r+2]=t>>>16&255,e[r+3]=t>>>24}function Ba(t,e,r){e.set(t,r)}globalThis.Buffer!=null&&(tr.prototype.bytes=function(t){let e=t.length>>>0;return this.uint32(e),e>0&&this._push(Ua,e,t),this},tr.prototype.string=function(t){let e=globalThis.Buffer.byteLength(t);return this.uint32(e),e>0&&this._push(La,e,t),this});function Ua(t,e,r){e.set(t,r)}function La(t,e,r){t.length<40?qn(t,e,r):e.utf8Write!=null?e.utf8Write(t,r):e.set(Ge(t),r)}function Xn(){return new tr}function vr(t,e){let r=Xn();return e.encode(t,r,{lengthDelimited:!1}),r.finish()}var kt;(function(t){t[t.VARINT=0]="VARINT",t[t.BIT64=1]="BIT64",t[t.LENGTH_DELIMITED=2]="LENGTH_DELIMITED",t[t.START_GROUP=3]="START_GROUP",t[t.END_GROUP=4]="END_GROUP",t[t.BIT32=5]="BIT32"})(kt||(kt={}));function Sr(t,e,r,n){return{name:t,type:e,encode:r,decode:n}}function Zn(t){function e(o){if(t[o.toString()]==null)throw new Error("Invalid enum value");return t[o]}let r=function(i,s){let a=e(i);s.int32(a)},n=function(i){let s=i.int32();return e(s)};return Sr("enum",kt.VARINT,r,n)}function Ar(t,e){return Sr("message",kt.LENGTH_DELIMITED,t,e)}var ge;(function(t){t.RSA="RSA",t.Ed25519="Ed25519",t.secp256k1="secp256k1"})(ge||(ge={}));var Wn;(function(t){t[t.RSA=0]="RSA",t[t.Ed25519=1]="Ed25519",t[t.secp256k1=2]="secp256k1"})(Wn||(Wn={}));(function(t){t.codec=()=>Zn(Wn)})(ge||(ge={}));var rr;(function(t){let e;t.codec=()=>(e==null&&(e=Ar((r,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),r.Type!=null&&(n.uint32(8),ge.codec().encode(r.Type,n)),r.Data!=null&&(n.uint32(18),n.bytes(r.Data)),o.lengthDelimited!==!1&&n.ldelim()},(r,n,o={})=>{let i={},s=n==null?r.len:r.pos+n;for(;r.pos<s;){let a=r.uint32();switch(a>>>3){case 1:{i.Type=ge.codec().decode(r);break}case 2:{i.Data=r.bytes();break}default:{r.skipType(a&7);break}}}return i})),e),t.encode=r=>vr(r,t.codec()),t.decode=(r,n)=>br(r,t.codec(),n)})(rr||(rr={}));var Qn;(function(t){let e;t.codec=()=>(e==null&&(e=Ar((r,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),r.Type!=null&&(n.uint32(8),ge.codec().encode(r.Type,n)),r.Data!=null&&(n.uint32(18),n.bytes(r.Data)),o.lengthDelimited!==!1&&n.ldelim()},(r,n,o={})=>{let i={},s=n==null?r.len:r.pos+n;for(;r.pos<s;){let a=r.uint32();switch(a>>>3){case 1:{i.Type=ge.codec().decode(r);break}case 2:{i.Data=r.bytes();break}default:{r.skipType(a&7);break}}}return i})),e),t.encode=r=>vr(r,t.codec()),t.decode=(r,n)=>br(r,t.codec(),n)})(Qn||(Qn={}));function _i(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function Na(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function _t(t,...e){if(!Na(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function Mi(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");_i(t.outputLen),_i(t.blockLen)}function Mt(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function Fi(t,e){_t(t);let r=e.outputLen;if(t.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}var Ye=Ut(ne("node:crypto"),1),wt=Ye&&typeof Ye=="object"&&"webcrypto"in Ye?Ye.webcrypto:Ye&&typeof Ye=="object"&&"randomBytes"in Ye?Ye:void 0;var Br=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),Ie=(t,e)=>t<<32-e|t>>>e;function Ca(t){if(typeof t!="string")throw new Error("utf8ToBytes expected string, got "+typeof t);return new Uint8Array(new TextEncoder().encode(t))}function nr(t){return typeof t=="string"&&(t=Ca(t)),_t(t),t}function Ki(...t){let e=0;for(let n=0;n<t.length;n++){let o=t[n];_t(o),e+=o.length}let r=new Uint8Array(e);for(let n=0,o=0;n<t.length;n++){let i=t[n];r.set(i,o),o+=i.length}return r}var Ft=class{clone(){return this._cloneInto()}};function qi(t){let e=n=>t().update(nr(n)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}function zi(t=32){if(wt&&typeof wt.getRandomValues=="function")return wt.getRandomValues(new Uint8Array(t));if(wt&&typeof wt.randomBytes=="function")return wt.randomBytes(t);throw new Error("crypto.getRandomValues must be defined")}function Oa(t,e,r,n){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,r,n);let o=BigInt(32),i=BigInt(4294967295),s=Number(r>>o&i),a=Number(r&i),c=n?4:0,d=n?0:4;t.setUint32(e+c,s,n),t.setUint32(e+d,a,n)}var Vi=(t,e,r)=>t&e^~t&r,Hi=(t,e,r)=>t&e^t&r^e&r,Ur=class extends Ft{constructor(e,r,n,o){super(),this.blockLen=e,this.outputLen=r,this.padOffset=n,this.isLE=o,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=Br(this.buffer)}update(e){Mt(this);let{view:r,buffer:n,blockLen:o}=this;e=nr(e);let i=e.length;for(let s=0;s<i;){let a=Math.min(o-this.pos,i-s);if(a===o){let c=Br(e);for(;o<=i-s;s+=o)this.process(c,s);continue}n.set(e.subarray(s,s+a),this.pos),this.pos+=a,s+=a,this.pos===o&&(this.process(r,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){Mt(this),Fi(e,this),this.finished=!0;let{buffer:r,view:n,blockLen:o,isLE:i}=this,{pos:s}=this;r[s++]=128,this.buffer.subarray(s).fill(0),this.padOffset>o-s&&(this.process(n,0),s=0);for(let l=s;l<o;l++)r[l]=0;Oa(n,o-8,BigInt(this.length*8),i),this.process(n,0);let a=Br(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let d=c/4,g=this.get();if(d>g.length)throw new Error("_sha2: outputLen bigger than state");for(let l=0;l<d;l++)a.setUint32(4*l,g[l],i)}digest(){let{buffer:e,outputLen:r}=this;this.digestInto(e);let n=e.slice(0,r);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());let{blockLen:r,buffer:n,length:o,finished:i,destroyed:s,pos:a}=this;return e.length=o,e.pos=a,e.finished=i,e.destroyed=s,o%r&&e.buffer.set(n),e}};var Pa=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]),nt=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),ot=new Uint32Array(64),Jn=class extends Ur{constructor(){super(64,32,8,!1),this.A=nt[0]|0,this.B=nt[1]|0,this.C=nt[2]|0,this.D=nt[3]|0,this.E=nt[4]|0,this.F=nt[5]|0,this.G=nt[6]|0,this.H=nt[7]|0}get(){let{A:e,B:r,C:n,D:o,E:i,F:s,G:a,H:c}=this;return[e,r,n,o,i,s,a,c]}set(e,r,n,o,i,s,a,c){this.A=e|0,this.B=r|0,this.C=n|0,this.D=o|0,this.E=i|0,this.F=s|0,this.G=a|0,this.H=c|0}process(e,r){for(let l=0;l<16;l++,r+=4)ot[l]=e.getUint32(r,!1);for(let l=16;l<64;l++){let u=ot[l-15],p=ot[l-2],h=Ie(u,7)^Ie(u,18)^u>>>3,y=Ie(p,17)^Ie(p,19)^p>>>10;ot[l]=y+ot[l-7]+h+ot[l-16]|0}let{A:n,B:o,C:i,D:s,E:a,F:c,G:d,H:g}=this;for(let l=0;l<64;l++){let u=Ie(a,6)^Ie(a,11)^Ie(a,25),p=g+u+Vi(a,c,d)+Pa[l]+ot[l]|0,y=(Ie(n,2)^Ie(n,13)^Ie(n,22))+Hi(n,o,i)|0;g=d,d=c,c=a,a=s+p|0,s=i,i=o,o=n,n=p+y|0}n=n+this.A|0,o=o+this.B|0,i=i+this.C|0,s=s+this.D|0,a=a+this.E|0,c=c+this.F|0,d=d+this.G|0,g=g+this.H|0,this.set(n,o,i,s,a,c,d,g)}roundClean(){ot.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var ji=qi(()=>new Jn);var Lr=class extends Ft{constructor(e,r){super(),this.finished=!1,this.destroyed=!1,Mi(e);let n=nr(r);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 o=this.blockLen,i=new Uint8Array(o);i.set(n.length>o?e.create().update(n).digest():n);for(let s=0;s<i.length;s++)i[s]^=54;this.iHash.update(i),this.oHash=e.create();for(let s=0;s<i.length;s++)i[s]^=106;this.oHash.update(i),i.fill(0)}update(e){return Mt(this),this.iHash.update(e),this}digestInto(e){Mt(this),_t(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:r,iHash:n,finished:o,destroyed:i,blockLen:s,outputLen:a}=this;return e=e,e.finished=o,e.destroyed=i,e.blockLen=s,e.outputLen=a,e.oHash=r._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},eo=(t,e,r)=>new Lr(t,e).update(r).digest();eo.create=(t,e)=>new Lr(t,e);var so={};oe(so,{aInRange:()=>ct,abool:()=>xt,abytes:()=>Kt,bitGet:()=>Fa,bitLen:()=>oo,bitMask:()=>ir,bitSet:()=>Ka,bytesToHex:()=>Et,bytesToNumberBE:()=>Ze,bytesToNumberLE:()=>Cr,concatBytes:()=>qt,createHmacDrbg:()=>io,ensureBytes:()=>he,equalBytes:()=>_a,hexToBytes:()=>It,hexToNumber:()=>no,inRange:()=>or,isBytes:()=>it,memoized:()=>Pr,notImplemented:()=>za,numberToBytesBE:()=>st,numberToBytesLE:()=>Or,numberToHexUnpadded:()=>bt,numberToVarBytesBE:()=>ka,utf8ToBytes:()=>Ma,validateObject:()=>at});var Tr=BigInt(0),Nr=BigInt(1),Ra=BigInt(2);function it(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function Kt(t){if(!it(t))throw new Error("Uint8Array expected")}function xt(t,e){if(typeof e!="boolean")throw new Error(t+" boolean expected, got "+e)}var Da=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function Et(t){Kt(t);let e="";for(let r=0;r<t.length;r++)e+=Da[t[r]];return e}function bt(t){let e=t.toString(16);return e.length&1?"0"+e:e}function no(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return t===""?Tr:BigInt("0x"+t)}var Xe={_0:48,_9:57,A:65,F:70,a:97,f:102};function $i(t){if(t>=Xe._0&&t<=Xe._9)return t-Xe._0;if(t>=Xe.A&&t<=Xe.F)return t-(Xe.A-10);if(t>=Xe.a&&t<=Xe.f)return t-(Xe.a-10)}function It(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);let e=t.length,r=e/2;if(e%2)throw new Error("hex string expected, got unpadded hex of length "+e);let n=new Uint8Array(r);for(let o=0,i=0;o<r;o++,i+=2){let s=$i(t.charCodeAt(i)),a=$i(t.charCodeAt(i+1));if(s===void 0||a===void 0){let c=t[i]+t[i+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+i)}n[o]=s*16+a}return n}function Ze(t){return no(Et(t))}function Cr(t){return Kt(t),no(Et(Uint8Array.from(t).reverse()))}function st(t,e){return It(t.toString(16).padStart(e*2,"0"))}function Or(t,e){return st(t,e).reverse()}function ka(t){return It(bt(t))}function he(t,e,r){let n;if(typeof e=="string")try{n=It(e)}catch(i){throw new Error(t+" must be hex string or Uint8Array, cause: "+i)}else if(it(e))n=Uint8Array.from(e);else throw new Error(t+" must be hex string or Uint8Array");let o=n.length;if(typeof r=="number"&&o!==r)throw new Error(t+" of length "+r+" expected, got "+o);return n}function qt(...t){let e=0;for(let n=0;n<t.length;n++){let o=t[n];Kt(o),e+=o.length}let r=new Uint8Array(e);for(let n=0,o=0;n<t.length;n++){let i=t[n];r.set(i,o),o+=i.length}return r}function _a(t,e){if(t.length!==e.length)return!1;let r=0;for(let n=0;n<t.length;n++)r|=t[n]^e[n];return r===0}function Ma(t){if(typeof t!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(t))}var to=t=>typeof t=="bigint"&&Tr<=t;function or(t,e,r){return to(t)&&to(e)&&to(r)&&e<=t&&t<r}function ct(t,e,r,n){if(!or(e,r,n))throw new Error("expected valid "+t+": "+r+" <= n < "+n+", got "+e)}function oo(t){let e;for(e=0;t>Tr;t>>=Nr,e+=1);return e}function Fa(t,e){return t>>BigInt(e)&Nr}function Ka(t,e,r){return t|(r?Nr:Tr)<<BigInt(e)}var ir=t=>(Ra<<BigInt(t-1))-Nr,ro=t=>new Uint8Array(t),Gi=t=>Uint8Array.from(t);function io(t,e,r){if(typeof t!="number"||t<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 r!="function")throw new Error("hmacFn must be a function");let n=ro(t),o=ro(t),i=0,s=()=>{n.fill(1),o.fill(0),i=0},a=(...l)=>r(o,n,...l),c=(l=ro())=>{o=a(Gi([0]),l),n=a(),l.length!==0&&(o=a(Gi([1]),l),n=a())},d=()=>{if(i++>=1e3)throw new Error("drbg: tried 1000 values");let l=0,u=[];for(;l<e;){n=a();let p=n.slice();u.push(p),l+=n.length}return qt(...u)};return(l,u)=>{s(),c(l);let p;for(;!(p=u(d()));)c();return s(),p}}var qa={bigint:t=>typeof t=="bigint",function:t=>typeof t=="function",boolean:t=>typeof t=="boolean",string:t=>typeof t=="string",stringOrUint8Array:t=>typeof t=="string"||it(t),isSafeInteger:t=>Number.isSafeInteger(t),array:t=>Array.isArray(t),field:(t,e)=>e.Fp.isValid(t),hash:t=>typeof t=="function"&&Number.isSafeInteger(t.outputLen)};function at(t,e,r={}){let n=(o,i,s)=>{let a=qa[i];if(typeof a!="function")throw new Error("invalid validator function");let c=t[o];if(!(s&&c===void 0)&&!a(c,t))throw new Error("param "+String(o)+" is invalid. Expected "+i+", got "+c)};for(let[o,i]of Object.entries(e))n(o,i,!1);for(let[o,i]of Object.entries(r))n(o,i,!0);return t}var za=()=>{throw new Error("not implemented")};function Pr(t){let e=new WeakMap;return(r,...n)=>{let o=e.get(r);if(o!==void 0)return o;let i=t(r,...n);return e.set(r,i),i}}var H=BigInt(0),q=BigInt(1),vt=BigInt(2),Va=BigInt(3),co=BigInt(4),Yi=BigInt(5),Xi=BigInt(8),Ha=BigInt(9),ja=BigInt(16);function W(t,e){let r=t%e;return r>=H?r:e+r}function $a(t,e,r){if(e<H)throw new Error("invalid exponent, negatives unsupported");if(r<=H)throw new Error("invalid modulus");if(r===q)return H;let n=q;for(;e>H;)e&q&&(n=n*t%r),t=t*t%r,e>>=q;return n}function pe(t,e,r){let n=t;for(;e-- >H;)n*=n,n%=r;return n}function Rr(t,e){if(t===H)throw new Error("invert: expected non-zero number");if(e<=H)throw new Error("invert: expected positive modulus, got "+e);let r=W(t,e),n=e,o=H,i=q,s=q,a=H;for(;r!==H;){let d=n/r,g=n%r,l=o-s*d,u=i-a*d;n=r,r=g,o=s,i=a,s=l,a=u}if(n!==q)throw new Error("invert: does not exist");return W(o,e)}function Ga(t){let e=(t-q)/vt,r,n,o;for(r=t-q,n=0;r%vt===H;r/=vt,n++);for(o=vt;o<t&&$a(o,e,t)!==t-q;o++)if(o>1e3)throw new Error("Cannot find square root: likely non-prime P");if(n===1){let s=(t+q)/co;return function(c,d){let g=c.pow(d,s);if(!c.eql(c.sqr(g),d))throw new Error("Cannot find square root");return g}}let i=(r+q)/vt;return function(a,c){if(a.pow(c,e)===a.neg(a.ONE))throw new Error("Cannot find square root");let d=n,g=a.pow(a.mul(a.ONE,o),r),l=a.pow(c,i),u=a.pow(c,r);for(;!a.eql(u,a.ONE);){if(a.eql(u,a.ZERO))return a.ZERO;let p=1;for(let y=a.sqr(u);p<d&&!a.eql(y,a.ONE);p++)y=a.sqr(y);let h=a.pow(g,q<<BigInt(d-p-1));g=a.sqr(h),l=a.mul(l,h),u=a.mul(u,g),d=p}return l}}function Ya(t){if(t%co===Va){let e=(t+q)/co;return function(n,o){let i=n.pow(o,e);if(!n.eql(n.sqr(i),o))throw new Error("Cannot find square root");return i}}if(t%Xi===Yi){let e=(t-Yi)/Xi;return function(n,o){let i=n.mul(o,vt),s=n.pow(i,e),a=n.mul(o,s),c=n.mul(n.mul(a,vt),s),d=n.mul(a,n.sub(c,n.ONE));if(!n.eql(n.sqr(d),o))throw new Error("Cannot find square root");return d}}return t%ja,Ga(t)}var Xa=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function ao(t){let e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},r=Xa.reduce((n,o)=>(n[o]="function",n),e);return at(t,r)}function Za(t,e,r){if(r<H)throw new Error("invalid exponent, negatives unsupported");if(r===H)return t.ONE;if(r===q)return e;let n=t.ONE,o=e;for(;r>H;)r&q&&(n=t.mul(n,o)),o=t.sqr(o),r>>=q;return n}function Wa(t,e){let r=new Array(e.length),n=e.reduce((i,s,a)=>t.is0(s)?i:(r[a]=i,t.mul(i,s)),t.ONE),o=t.inv(n);return e.reduceRight((i,s,a)=>t.is0(s)?i:(r[a]=t.mul(i,r[a]),t.mul(i,s)),o),r}function uo(t,e){let r=e!==void 0?e:t.toString(2).length,n=Math.ceil(r/8);return{nBitLength:r,nByteLength:n}}function Dr(t,e,r=!1,n={}){if(t<=H)throw new Error("invalid field: expected ORDER > 0, got "+t);let{nBitLength:o,nByteLength:i}=uo(t,e);if(i>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let s,a=Object.freeze({ORDER:t,BITS:o,BYTES:i,MASK:ir(o),ZERO:H,ONE:q,create:c=>W(c,t),isValid:c=>{if(typeof c!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof c);return H<=c&&c<t},is0:c=>c===H,isOdd:c=>(c&q)===q,neg:c=>W(-c,t),eql:(c,d)=>c===d,sqr:c=>W(c*c,t),add:(c,d)=>W(c+d,t),sub:(c,d)=>W(c-d,t),mul:(c,d)=>W(c*d,t),pow:(c,d)=>Za(a,c,d),div:(c,d)=>W(c*Rr(d,t),t),sqrN:c=>c*c,addN:(c,d)=>c+d,subN:(c,d)=>c-d,mulN:(c,d)=>c*d,inv:c=>Rr(c,t),sqrt:n.sqrt||(c=>(s||(s=Ya(t)),s(a,c))),invertBatch:c=>Wa(a,c),cmov:(c,d,g)=>g?d:c,toBytes:c=>r?Or(c,i):st(c,i),fromBytes:c=>{if(c.length!==i)throw new Error("Field.fromBytes: expected "+i+" bytes, got "+c.length);return r?Cr(c):Ze(c)}});return Object.freeze(a)}function Zi(t){if(typeof t!="bigint")throw new Error("field order must be bigint");let e=t.toString(2).length;return Math.ceil(e/8)}function lo(t){let e=Zi(t);return e+Math.ceil(e/2)}function Wi(t,e,r=!1){let n=t.length,o=Zi(e),i=lo(e);if(n<16||n<i||n>1024)throw new Error("expected "+i+"-1024 bytes of input, got "+n);let s=r?Ze(t):Cr(t),a=W(s,e-q)+q;return r?Or(a,o):st(a,o)}var Qi=BigInt(0),kr=BigInt(1);function ho(t,e){let r=e.negate();return t?r:e}function Ji(t,e){if(!Number.isSafeInteger(t)||t<=0||t>e)throw new Error("invalid window size, expected [1.."+e+"], got W="+t)}function po(t,e){Ji(t,e);let r=Math.ceil(e/t)+1,n=2**(t-1);return{windows:r,windowSize:n}}function Ja(t,e){if(!Array.isArray(t))throw new Error("array expected");t.forEach((r,n)=>{if(!(r instanceof e))throw new Error("invalid point at index "+n)})}function ed(t,e){if(!Array.isArray(t))throw new Error("array of scalars expected");t.forEach((r,n)=>{if(!e.isValid(r))throw new Error("invalid scalar at index "+n)})}var mo=new WeakMap,es=new WeakMap;function go(t){return es.get(t)||1}function ts(t,e){return{constTimeNegate:ho,hasPrecomputes(r){return go(r)!==1},unsafeLadder(r,n,o=t.ZERO){let i=r;for(;n>Qi;)n&kr&&(o=o.add(i)),i=i.double(),n>>=kr;return o},precomputeWindow(r,n){let{windows:o,windowSize:i}=po(n,e),s=[],a=r,c=a;for(let d=0;d<o;d++){c=a,s.push(c);for(let g=1;g<i;g++)c=c.add(a),s.push(c);a=c.double()}return s},wNAF(r,n,o){let{windows:i,windowSize:s}=po(r,e),a=t.ZERO,c=t.BASE,d=BigInt(2**r-1),g=2**r,l=BigInt(r);for(let u=0;u<i;u++){let p=u*s,h=Number(o&d);o>>=l,h>s&&(h-=g,o+=kr);let y=p,m=p+Math.abs(h)-1,f=u%2!==0,x=h<0;h===0?c=c.add(ho(f,n[y])):a=a.add(ho(x,n[m]))}return{p:a,f:c}},wNAFUnsafe(r,n,o,i=t.ZERO){let{windows:s,windowSize:a}=po(r,e),c=BigInt(2**r-1),d=2**r,g=BigInt(r);for(let l=0;l<s;l++){let u=l*a;if(o===Qi)break;let p=Number(o&c);if(o>>=g,p>a&&(p-=d,o+=kr),p===0)continue;let h=n[u+Math.abs(p)-1];p<0&&(h=h.negate()),i=i.add(h)}return i},getPrecomputes(r,n,o){let i=mo.get(n);return i||(i=this.precomputeWindow(n,r),r!==1&&mo.set(n,o(i))),i},wNAFCached(r,n,o){let i=go(r);return this.wNAF(i,this.getPrecomputes(i,r,o),n)},wNAFCachedUnsafe(r,n,o,i){let s=go(r);return s===1?this.unsafeLadder(r,n,i):this.wNAFUnsafe(s,this.getPrecomputes(s,r,o),n,i)},setWindowSize(r,n){Ji(n,e),es.set(r,n),mo.delete(r)}}}function rs(t,e,r,n){if(Ja(r,t),ed(n,e),r.length!==n.length)throw new Error("arrays of points and scalars must have equal length");let o=t.ZERO,i=oo(BigInt(r.length)),s=i>12?i-3:i>4?i-2:i?2:1,a=(1<<s)-1,c=new Array(a+1).fill(o),d=Math.floor((e.BITS-1)/s)*s,g=o;for(let l=d;l>=0;l-=s){c.fill(o);for(let p=0;p<n.length;p++){let h=n[p],y=Number(h>>BigInt(l)&BigInt(a));c[y]=c[y].add(r[p])}let u=o;for(let p=c.length-1,h=o;p>0;p--)h=h.add(c[p]),u=u.add(h);if(g=g.add(u),l!==0)for(let p=0;p<s;p++)g=g.double()}return g}function yo(t){return ao(t.Fp),at(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...uo(t.n,t.nBitLength),...t,p:t.Fp.ORDER})}function ns(t){t.lowS!==void 0&&xt("lowS",t.lowS),t.prehash!==void 0&&xt("prehash",t.prehash)}function td(t){let e=yo(t);at(e,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});let{endo:r,Fp:n,a:o}=e;if(r){if(!n.eql(o,n.ZERO))throw new Error("invalid endomorphism, can only be defined for Koblitz curves that have a=0");if(typeof r!="object"||typeof r.beta!="bigint"||typeof r.splitScalar!="function")throw new Error("invalid endomorphism, expected beta: bigint and splitScalar: function")}return Object.freeze({...e})}var{bytesToNumberBE:rd,hexToBytes:nd}=so,We={Err:class extends Error{constructor(e=""){super(e)}},_tlv:{encode:(t,e)=>{let{Err:r}=We;if(t<0||t>256)throw new r("tlv.encode: wrong tag");if(e.length&1)throw new r("tlv.encode: unpadded data");let n=e.length/2,o=bt(n);if(o.length/2&128)throw new r("tlv.encode: long form length too big");let i=n>127?bt(o.length/2|128):"";return bt(t)+i+o+e},decode(t,e){let{Err:r}=We,n=0;if(t<0||t>256)throw new r("tlv.encode: wrong tag");if(e.length<2||e[n++]!==t)throw new r("tlv.decode: wrong tlv");let o=e[n++],i=!!(o&128),s=0;if(!i)s=o;else{let c=o&127;if(!c)throw new r("tlv.decode(long): indefinite length not supported");if(c>4)throw new r("tlv.decode(long): byte length is too big");let d=e.subarray(n,n+c);if(d.length!==c)throw new r("tlv.decode: length bytes not complete");if(d[0]===0)throw new r("tlv.decode(long): zero leftmost byte");for(let g of d)s=s<<8|g;if(n+=c,s<128)throw new r("tlv.decode(long): not minimal encoding")}let a=e.subarray(n,n+s);if(a.length!==s)throw new r("tlv.decode: wrong value length");return{v:a,l:e.subarray(n+s)}}},_int:{encode(t){let{Err:e}=We;if(t<Qe)throw new e("integer: negative integers are not allowed");let r=bt(t);if(Number.parseInt(r[0],16)&8&&(r="00"+r),r.length&1)throw new e("unexpected DER parsing assertion: unpadded hex");return r},decode(t){let{Err:e}=We;if(t[0]&128)throw new e("invalid signature integer: negative");if(t[0]===0&&!(t[1]&128))throw new e("invalid signature integer: unnecessary leading zero");return rd(t)}},toSig(t){let{Err:e,_int:r,_tlv:n}=We,o=typeof t=="string"?nd(t):t;Kt(o);let{v:i,l:s}=n.decode(48,o);if(s.length)throw new e("invalid signature: left bytes after parsing");let{v:a,l:c}=n.decode(2,i),{v:d,l:g}=n.decode(2,c);if(g.length)throw new e("invalid signature: left bytes after parsing");return{r:r.decode(a),s:r.decode(d)}},hexFromSig(t){let{_tlv:e,_int:r}=We,n=e.encode(2,r.encode(t.r)),o=e.encode(2,r.encode(t.s)),i=n+o;return e.encode(48,i)}},Qe=BigInt(0),$=BigInt(1),np=BigInt(2),os=BigInt(3),op=BigInt(4);function od(t){let e=td(t),{Fp:r}=e,n=Dr(e.n,e.nBitLength),o=e.toBytes||((y,m,f)=>{let x=m.toAffine();return qt(Uint8Array.from([4]),r.toBytes(x.x),r.toBytes(x.y))}),i=e.fromBytes||(y=>{let m=y.subarray(1),f=r.fromBytes(m.subarray(0,r.BYTES)),x=r.fromBytes(m.subarray(r.BYTES,2*r.BYTES));return{x:f,y:x}});function s(y){let{a:m,b:f}=e,x=r.sqr(y),b=r.mul(x,y);return r.add(r.add(b,r.mul(y,m)),f)}if(!r.eql(r.sqr(e.Gy),s(e.Gx)))throw new Error("bad generator point: equation left != right");function a(y){return or(y,$,e.n)}function c(y){let{allowedPrivateKeyLengths:m,nByteLength:f,wrapPrivateKey:x,n:b}=e;if(m&&typeof y!="bigint"){if(it(y)&&(y=Et(y)),typeof y!="string"||!m.includes(y.length))throw new Error("invalid private key");y=y.padStart(f*2,"0")}let L;try{L=typeof y=="bigint"?y:Ze(he("private key",y,f))}catch{throw new Error("invalid private key, expected hex or "+f+" bytes, got "+typeof y)}return x&&(L=W(L,b)),ct("private key",L,$,b),L}function d(y){if(!(y instanceof u))throw new Error("ProjectivePoint expected")}let g=Pr((y,m)=>{let{px:f,py:x,pz:b}=y;if(r.eql(b,r.ONE))return{x:f,y:x};let L=y.is0();m==null&&(m=L?r.ONE:r.inv(b));let T=r.mul(f,m),B=r.mul(x,m),U=r.mul(b,m);if(L)return{x:r.ZERO,y:r.ZERO};if(!r.eql(U,r.ONE))throw new Error("invZ was invalid");return{x:T,y:B}}),l=Pr(y=>{if(y.is0()){if(e.allowInfinityPoint&&!r.is0(y.py))return;throw new Error("bad point: ZERO")}let{x:m,y:f}=y.toAffine();if(!r.isValid(m)||!r.isValid(f))throw new Error("bad point: x or y not FE");let x=r.sqr(f),b=s(m);if(!r.eql(x,b))throw new Error("bad point: equation left != right");if(!y.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class u{constructor(m,f,x){if(this.px=m,this.py=f,this.pz=x,m==null||!r.isValid(m))throw new Error("x required");if(f==null||!r.isValid(f))throw new Error("y required");if(x==null||!r.isValid(x))throw new Error("z required");Object.freeze(this)}static fromAffine(m){let{x:f,y:x}=m||{};if(!m||!r.isValid(f)||!r.isValid(x))throw new Error("invalid affine point");if(m instanceof u)throw new Error("projective point not allowed");let b=L=>r.eql(L,r.ZERO);return b(f)&&b(x)?u.ZERO:new u(f,x,r.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(m){let f=r.invertBatch(m.map(x=>x.pz));return m.map((x,b)=>x.toAffine(f[b])).map(u.fromAffine)}static fromHex(m){let f=u.fromAffine(i(he("pointHex",m)));return f.assertValidity(),f}static fromPrivateKey(m){return u.BASE.multiply(c(m))}static msm(m,f){return rs(u,n,m,f)}_setWindowSize(m){h.setWindowSize(this,m)}assertValidity(){l(this)}hasEvenY(){let{y:m}=this.toAffine();if(r.isOdd)return!r.isOdd(m);throw new Error("Field doesn't support isOdd")}equals(m){d(m);let{px:f,py:x,pz:b}=this,{px:L,py:T,pz:B}=m,U=r.eql(r.mul(f,B),r.mul(L,b)),N=r.eql(r.mul(x,B),r.mul(T,b));return U&&N}negate(){return new u(this.px,r.neg(this.py),this.pz)}double(){let{a:m,b:f}=e,x=r.mul(f,os),{px:b,py:L,pz:T}=this,B=r.ZERO,U=r.ZERO,N=r.ZERO,C=r.mul(b,b),G=r.mul(L,L),M=r.mul(T,T),_=r.mul(b,L);return _=r.add(_,_),N=r.mul(b,T),N=r.add(N,N),B=r.mul(m,N),U=r.mul(x,M),U=r.add(B,U),B=r.sub(G,U),U=r.add(G,U),U=r.mul(B,U),B=r.mul(_,B),N=r.mul(x,N),M=r.mul(m,M),_=r.sub(C,M),_=r.mul(m,_),_=r.add(_,N),N=r.add(C,C),C=r.add(N,C),C=r.add(C,M),C=r.mul(C,_),U=r.add(U,C),M=r.mul(L,T),M=r.add(M,M),C=r.mul(M,_),B=r.sub(B,C),N=r.mul(M,G),N=r.add(N,N),N=r.add(N,N),new u(B,U,N)}add(m){d(m);let{px:f,py:x,pz:b}=this,{px:L,py:T,pz:B}=m,U=r.ZERO,N=r.ZERO,C=r.ZERO,G=e.a,M=r.mul(e.b,os),_=r.mul(f,L),ce=r.mul(x,T),E=r.mul(b,B),I=r.add(f,x),A=r.add(L,T);I=r.mul(I,A),A=r.add(_,ce),I=r.sub(I,A),A=r.add(f,b);let P=r.add(L,B);return A=r.mul(A,P),P=r.add(_,E),A=r.sub(A,P),P=r.add(x,b),U=r.add(T,B),P=r.mul(P,U),U=r.add(ce,E),P=r.sub(P,U),C=r.mul(G,A),U=r.mul(M,E),C=r.add(U,C),U=r.sub(ce,C),C=r.add(ce,C),N=r.mul(U,C),ce=r.add(_,_),ce=r.add(ce,_),E=r.mul(G,E),A=r.mul(M,A),ce=r.add(ce,E),E=r.sub(_,E),E=r.mul(G,E),A=r.add(A,E),_=r.mul(ce,A),N=r.add(N,_),_=r.mul(P,A),U=r.mul(I,U),U=r.sub(U,_),_=r.mul(I,ce),C=r.mul(P,C),C=r.add(C,_),new u(U,N,C)}subtract(m){return this.add(m.negate())}is0(){return this.equals(u.ZERO)}wNAF(m){return h.wNAFCached(this,m,u.normalizeZ)}multiplyUnsafe(m){let{endo:f,n:x}=e;ct("scalar",m,Qe,x);let b=u.ZERO;if(m===Qe)return b;if(this.is0()||m===$)return this;if(!f||h.hasPrecomputes(this))return h.wNAFCachedUnsafe(this,m,u.normalizeZ);let{k1neg:L,k1:T,k2neg:B,k2:U}=f.splitScalar(m),N=b,C=b,G=this;for(;T>Qe||U>Qe;)T&$&&(N=N.add(G)),U&$&&(C=C.add(G)),G=G.double(),T>>=$,U>>=$;return L&&(N=N.negate()),B&&(C=C.negate()),C=new u(r.mul(C.px,f.beta),C.py,C.pz),N.add(C)}multiply(m){let{endo:f,n:x}=e;ct("scalar",m,$,x);let b,L;if(f){let{k1neg:T,k1:B,k2neg:U,k2:N}=f.splitScalar(m),{p:C,f:G}=this.wNAF(B),{p:M,f:_}=this.wNAF(N);C=h.constTimeNegate(T,C),M=h.constTimeNegate(U,M),M=new u(r.mul(M.px,f.beta),M.py,M.pz),b=C.add(M),L=G.add(_)}else{let{p:T,f:B}=this.wNAF(m);b=T,L=B}return u.normalizeZ([b,L])[0]}multiplyAndAddUnsafe(m,f,x){let b=u.BASE,L=(B,U)=>U===Qe||U===$||!B.equals(b)?B.multiplyUnsafe(U):B.multiply(U),T=L(this,f).add(L(m,x));return T.is0()?void 0:T}toAffine(m){return g(this,m)}isTorsionFree(){let{h:m,isTorsionFree:f}=e;if(m===$)return!0;if(f)return f(u,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h:m,clearCofactor:f}=e;return m===$?this:f?f(u,this):this.multiplyUnsafe(e.h)}toRawBytes(m=!0){return xt("isCompressed",m),this.assertValidity(),o(u,this,m)}toHex(m=!0){return xt("isCompressed",m),Et(this.toRawBytes(m))}}u.BASE=new u(e.Gx,e.Gy,r.ONE),u.ZERO=new u(r.ZERO,r.ONE,r.ZERO);let p=e.nBitLength,h=ts(u,e.endo?Math.ceil(p/2):p);return{CURVE:e,ProjectivePoint:u,normPrivateKeyToScalar:c,weierstrassEquation:s,isWithinCurveOrder:a}}function id(t){let e=yo(t);return at(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function is(t){let e=id(t),{Fp:r,n}=e,o=r.BYTES+1,i=2*r.BYTES+1;function s(E){return W(E,n)}function a(E){return Rr(E,n)}let{ProjectivePoint:c,normPrivateKeyToScalar:d,weierstrassEquation:g,isWithinCurveOrder:l}=od({...e,toBytes(E,I,A){let P=I.toAffine(),R=r.toBytes(P.x),V=qt;return xt("isCompressed",A),A?V(Uint8Array.from([I.hasEvenY()?2:3]),R):V(Uint8Array.from([4]),R,r.toBytes(P.y))},fromBytes(E){let I=E.length,A=E[0],P=E.subarray(1);if(I===o&&(A===2||A===3)){let R=Ze(P);if(!or(R,$,r.ORDER))throw new Error("Point is not on curve");let V=g(R),te;try{te=r.sqrt(V)}catch(fe){let re=fe instanceof Error?": "+fe.message:"";throw new Error("Point is not on curve"+re)}let Q=(te&$)===$;return(A&1)===1!==Q&&(te=r.neg(te)),{x:R,y:te}}else if(I===i&&A===4){let R=r.fromBytes(P.subarray(0,r.BYTES)),V=r.fromBytes(P.subarray(r.BYTES,2*r.BYTES));return{x:R,y:V}}else{let R=o,V=i;throw new Error("invalid Point, expected length of "+R+", or uncompressed "+V+", got "+I)}}}),u=E=>Et(st(E,e.nByteLength));function p(E){let I=n>>$;return E>I}function h(E){return p(E)?s(-E):E}let y=(E,I,A)=>Ze(E.slice(I,A));class m{constructor(I,A,P){this.r=I,this.s=A,this.recovery=P,this.assertValidity()}static fromCompact(I){let A=e.nByteLength;return I=he("compactSignature",I,A*2),new m(y(I,0,A),y(I,A,2*A))}static fromDER(I){let{r:A,s:P}=We.toSig(he("DER",I));return new m(A,P)}assertValidity(){ct("r",this.r,$,n),ct("s",this.s,$,n)}addRecoveryBit(I){return new m(this.r,this.s,I)}recoverPublicKey(I){let{r:A,s:P,recovery:R}=this,V=B(he("msgHash",I));if(R==null||![0,1,2,3].includes(R))throw new Error("recovery id invalid");let te=R===2||R===3?A+e.n:A;if(te>=r.ORDER)throw new Error("recovery id 2 or 3 invalid");let Q=R&1?"03":"02",Oe=c.fromHex(Q+u(te)),fe=a(te),re=s(-V*fe),St=s(P*fe),Je=c.BASE.multiplyAndAddUnsafe(Oe,re,St);if(!Je)throw new Error("point at infinify");return Je.assertValidity(),Je}hasHighS(){return p(this.s)}normalizeS(){return this.hasHighS()?new m(this.r,s(-this.s),this.recovery):this}toDERRawBytes(){return It(this.toDERHex())}toDERHex(){return We.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return It(this.toCompactHex())}toCompactHex(){return u(this.r)+u(this.s)}}let f={isValidPrivateKey(E){try{return d(E),!0}catch{return!1}},normPrivateKeyToScalar:d,randomPrivateKey:()=>{let E=lo(e.n);return Wi(e.randomBytes(E),e.n)},precompute(E=8,I=c.BASE){return I._setWindowSize(E),I.multiply(BigInt(3)),I}};function x(E,I=!0){return c.fromPrivateKey(E).toRawBytes(I)}function b(E){let I=it(E),A=typeof E=="string",P=(I||A)&&E.length;return I?P===o||P===i:A?P===2*o||P===2*i:E instanceof c}function L(E,I,A=!0){if(b(E))throw new Error("first arg must be private key");if(!b(I))throw new Error("second arg must be public key");return c.fromHex(I).multiply(d(E)).toRawBytes(A)}let T=e.bits2int||function(E){if(E.length>8192)throw new Error("input is too large");let I=Ze(E),A=E.length*8-e.nBitLength;return A>0?I>>BigInt(A):I},B=e.bits2int_modN||function(E){return s(T(E))},U=ir(e.nBitLength);function N(E){return ct("num < 2^"+e.nBitLength,E,Qe,U),st(E,e.nByteLength)}function C(E,I,A=G){if(["recovered","canonical"].some(dt=>dt in A))throw new Error("sign() legacy options not supported");let{hash:P,randomBytes:R}=e,{lowS:V,prehash:te,extraEntropy:Q}=A;V==null&&(V=!0),E=he("msgHash",E),ns(A),te&&(E=he("prehashed msgHash",P(E)));let Oe=B(E),fe=d(I),re=[N(fe),N(Oe)];if(Q!=null&&Q!==!1){let dt=Q===!0?R(r.BYTES):Q;re.push(he("extraEntropy",dt))}let St=qt(...re),Je=Oe;function Gr(dt){let At=T(dt);if(!l(At))return;let Yr=a(At),Ht=c.BASE.multiply(At).toAffine(),ut=s(Ht.x);if(ut===Qe)return;let jt=s(Yr*s(Je+ut*fe));if(jt===Qe)return;let Bt=(Ht.x===ut?0:2)|Number(Ht.y&$),Po=jt;return V&&p(jt)&&(Po=h(jt),Bt^=1),new m(ut,Po,Bt)}return{seed:St,k2sig:Gr}}let G={lowS:e.lowS,prehash:!1},M={lowS:e.lowS,prehash:!1};function _(E,I,A=G){let{seed:P,k2sig:R}=C(E,I,A),V=e;return io(V.hash.outputLen,V.nByteLength,V.hmac)(P,R)}c.BASE._setWindowSize(8);function ce(E,I,A,P=M){let R=E;I=he("msgHash",I),A=he("publicKey",A);let{lowS:V,prehash:te,format:Q}=P;if(ns(P),"strict"in P)throw new Error("options.strict was renamed to lowS");if(Q!==void 0&&Q!=="compact"&&Q!=="der")throw new Error("format must be compact or der");let Oe=typeof R=="string"||it(R),fe=!Oe&&!Q&&typeof R=="object"&&R!==null&&typeof R.r=="bigint"&&typeof R.s=="bigint";if(!Oe&&!fe)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let re,St;try{if(fe&&(re=new m(R.r,R.s)),Oe){try{Q!=="compact"&&(re=m.fromDER(R))}catch(Bt){if(!(Bt instanceof We.Err))throw Bt}!re&&Q!=="der"&&(re=m.fromCompact(R))}St=c.fromHex(A)}catch{return!1}if(!re||V&&re.hasHighS())return!1;te&&(I=e.hash(I));let{r:Je,s:Gr}=re,dt=B(I),At=a(Gr),Yr=s(dt*At),Ht=s(Je*At),ut=c.BASE.multiplyAndAddUnsafe(St,Yr,Ht)?.toAffine();return ut?s(ut.x)===Je:!1}return{CURVE:e,getPublicKey:x,getSharedSecret:L,sign:_,verify:ce,ProjectivePoint:c,Signature:m,utils:f}}function sd(t){return{hash:t,hmac:(e,...r)=>eo(t,e,Ki(...r)),randomBytes:zi}}function ss(t,e){let r=n=>is({...t,...sd(n)});return Object.freeze({...r(e),create:r})}var ds=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),cs=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),cd=BigInt(1),fo=BigInt(2),as=(t,e)=>(t+e/fo)/e;function ad(t){let e=ds,r=BigInt(3),n=BigInt(6),o=BigInt(11),i=BigInt(22),s=BigInt(23),a=BigInt(44),c=BigInt(88),d=t*t*t%e,g=d*d*t%e,l=pe(g,r,e)*g%e,u=pe(l,r,e)*g%e,p=pe(u,fo,e)*d%e,h=pe(p,o,e)*p%e,y=pe(h,i,e)*h%e,m=pe(y,a,e)*y%e,f=pe(m,c,e)*m%e,x=pe(f,a,e)*y%e,b=pe(x,r,e)*g%e,L=pe(b,s,e)*h%e,T=pe(L,n,e)*d%e,B=pe(T,fo,e);if(!wo.eql(wo.sqr(B),t))throw new Error("Cannot find square root");return B}var wo=Dr(ds,void 0,void 0,{sqrt:ad}),zt=ss({a:BigInt(0),b:BigInt(7),Fp:wo,n:cs,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:t=>{let e=cs,r=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-cd*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),i=r,s=BigInt("0x100000000000000000000000000000000"),a=as(i*t,e),c=as(-n*t,e),d=W(t-a*r-c*o,e),g=W(-a*n-c*i,e),l=d>s,u=g>s;if(l&&(d=e-d),u&&(g=e-g),d>s||g>s)throw new Error("splitScalar: Endomorphism failed, k="+t);return{k1neg:l,k1:d,k2neg:u,k2:g}}}},ji),pp=BigInt(0);var mp=zt.ProjectivePoint;var us=Ut(ne("node:crypto"),1);var _r=class extends Error{constructor(e="An error occurred while verifying a message"){super(e),this.name="VerificationError"}};function ls(t,e,r){let n=us.default.createHash("sha256");if(r instanceof Uint8Array)n.update(r);else for(let i of r)n.update(i);let o=n.digest();try{return zt.verify(e,o,t)}catch(i){throw new _r(String(i))}}var Mr=class{type="secp256k1";raw;_key;constructor(e){this._key=ps(e),this.raw=hs(this._key)}toMultihash(){return He.digest(xr(this))}toCID(){return ee.createV1(114,this.toMultihash())}toString(){return K.encode(this.toMultihash().bytes).substring(1)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:je(this.raw,e.raw)}verify(e,r){return ls(this._key,r,e)}};function ms(t){return new Mr(t)}function hs(t){return zt.ProjectivePoint.fromHex(t).toRawBytes(!0)}function ps(t){try{return zt.ProjectivePoint.fromHex(t),t}catch(e){throw new ur(String(e))}}function gs(t){let{Type:e,Data:r}=rr.decode(t.digest),n=r??new Uint8Array;switch(e){case ge.Ed25519:return Ui(n);case ge.secp256k1:return ms(n);default:throw new $t}}function xr(t){return rr.encode({Type:ge[t.type],Data:t.raw})}var ys=Symbol.for("nodejs.util.inspect.custom"),dd=114,sr=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()})`}[Xr]=!0;toString(){return this.string==null&&(this.string=K.encode(this.multihash.bytes).slice(1)),this.string}toMultihash(){return this.multihash}toCID(){return ee.createV1(dd,this.multihash)}toJSON(){return this.toString()}equals(e){if(e==null)return!1;if(e instanceof Uint8Array)return je(this.multihash.bytes,e);if(typeof e=="string")return this.toString()===e;if(e?.toMultihash()?.bytes!=null)return je(this.multihash.bytes,e.toMultihash().bytes);throw new Error("not valid Id")}[ys](){return`PeerId(${this.toString()})`}},Fr=class extends sr{type="RSA";publicKey;constructor(e){super({...e,type:"RSA"}),this.publicKey=e.publicKey}},Kr=class extends sr{type="Ed25519";publicKey;constructor(e){super({...e,type:"Ed25519"}),this.publicKey=e.publicKey}},qr=class extends sr{type="secp256k1";publicKey;constructor(e){super({...e,type:"secp256k1"}),this.publicKey=e.publicKey}},ud=2336,zr=class{type="url";multihash;publicKey;url;constructor(e){this.url=e.toString(),this.multihash=He.digest(Ge(this.url))}[ys](){return`PeerId(${this.url})`}[Xr]=!0;toString(){return this.toCID().toString()}toMultihash(){return this.multihash}toCID(){return ee.createV1(ud,this.toMultihash())}toJSON(){return this.toString()}equals(e){return e==null?!1:(e instanceof Uint8Array&&(e=z(e)),e.toString()===this.toString())}};function fs(t,e){let r;if(t.charAt(0)==="1"||t.charAt(0)==="Q")r=pt(K.decode(`z${t}`));else{if(e==null)throw new Lt('Please pass a multibase decoder for strings that do not start with "1" or "Q"');r=pt(e.decode(t))}return ld(r)}function ld(t){if(pd(t))return new Fr({multihash:t});if(hd(t))try{let e=gs(t);if(e.type==="Ed25519")return new Kr({multihash:t,publicKey:e});if(e.type==="secp256k1")return new qr({multihash:t,publicKey:e})}catch{let r=z(t.digest);return new zr(new URL(r))}throw new lr("Supplied PeerID Multihash is invalid")}function hd(t){return t.code===He.code}function pd(t){return t.code===Tn.code}var ye=ne("node:net");function Vr(t){return!!(0,ye.isIP)(t)}var xs=Ut(ws(),1),md=["0.0.0.0/8","10.0.0.0/8","100.64.0.0/10","127.0.0.0/8","169.254.0.0/16","172.16.0.0/12","192.0.0.0/24","192.0.0.0/29","192.0.0.8/32","192.0.0.9/32","192.0.0.10/32","192.0.0.170/32","192.0.0.171/32","192.0.2.0/24","192.31.196.0/24","192.52.193.0/24","192.88.99.0/24","192.168.0.0/16","192.175.48.0/24","198.18.0.0/15","198.51.100.0/24","203.0.113.0/24","240.0.0.0/4","255.255.255.255/32"],gd=md.map(t=>new xs.Netmask(t));function xo(t){for(let e of gd)if(e.contains(t))return!0;return!1}function yd(t){return/^::ffff:([0-9a-fA-F]{1,4}):([0-9a-fA-F]{1,4})$/.test(t)}function fd(t){let e=t.split(":");if(e.length<2)return!1;let r=e[e.length-1].padStart(4,"0"),n=e[e.length-2].padStart(4,"0"),o=`${parseInt(n.substring(0,2),16)}.${parseInt(n.substring(2),16)}.${parseInt(r.substring(0,2),16)}.${parseInt(r.substring(2),16)}`;return xo(o)}function wd(t){return/^::ffff:([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(t)}function xd(t){let e=t.split(":"),r=e[e.length-1];return xo(r)}function Ed(t){return/^::$/.test(t)||/^::1$/.test(t)||/^64:ff9b::([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(t)||/^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(t)||/^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(t)||/^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(t)||/^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(t)||/^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(t)||/^f[c-d]([0-9a-fA-F]{2,2}):/i.test(t)||/^fe[8-9a-bA-B][0-9a-fA-F]:/i.test(t)||/^ff([0-9a-fA-F]{2,2}):/i.test(t)}function Es(t){return(0,ye.isIPv4)(t)?xo(t):yd(t)?fd(t):wd(t)?xd(t):(0,ye.isIPv6)(t)?Ed(t):void 0}var bd=4,Id=41,vd=53,Sd=54,Ad=55,Bd=56;function bs(t){try{let[[e,r]]=t.stringTuples();if(r==null)return!0;if(e===vd||e===Sd||e===Ad||e===Bd)return!1;if(e===bd||e===Id)return Es(r)??!1}catch{}return!0}var Hr=class{index=0;input="";new(e){return this.index=0,this.input=e,this}readAtomically(e){let r=this.index,n=e();return n===void 0&&(this.index=r),n}parseWith(e){let r=e();if(this.index===this.input.length)return r}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 r=this.readChar();if(r===e)return r})}readSeparator(e,r,n){return this.readAtomically(()=>{if(!(r>0&&this.readGivenChar(e)===void 0))return n()})}readNumber(e,r,n,o){return this.readAtomically(()=>{let i=0,s=0,a=this.peekChar();if(a===void 0)return;let c=a==="0",d=2**(8*o)-1;for(;;){let g=this.readAtomically(()=>{let l=this.readChar();if(l===void 0)return;let u=Number.parseInt(l,e);if(!Number.isNaN(u))return u});if(g===void 0)break;if(i*=e,i+=g,i>d||(s+=1,r!==void 0&&s>r))return}if(s!==0)return!n&&c&&s>1?void 0:i})}readIPv4Addr(){return this.readAtomically(()=>{let e=new Uint8Array(4);for(let r=0;r<e.length;r++){let n=this.readSeparator(".",r,()=>this.readNumber(10,3,!1,1));if(n===void 0)return;e[r]=n}return e})}readIPv6Addr(){let e=r=>{for(let n=0;n<r.length/2;n++){let o=n*2;if(n<r.length-3){let s=this.readSeparator(":",n,()=>this.readIPv4Addr());if(s!==void 0)return r[o]=s[0],r[o+1]=s[1],r[o+2]=s[2],r[o+3]=s[3],[o+4,!0]}let i=this.readSeparator(":",n,()=>this.readNumber(16,4,!0,2));if(i===void 0)return[o,!1];r[o]=i>>8,r[o+1]=i&255}return[r.length,!1]};return this.readAtomically(()=>{let r=new Uint8Array(16),[n,o]=e(r);if(n===16)return r;if(o||this.readGivenChar(":")===void 0||this.readGivenChar(":")===void 0)return;let i=new Uint8Array(14),s=16-(n+2),[a]=e(i.subarray(0,s));return r.set(i.subarray(0,a),16-a),r})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var x0=new Hr;var U0=parseInt("0xFFFF",16),L0=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);var Ss=ye.isIPv4,Od=ye.isIPv6,Eo=function(t){let e=0;if(t=t.toString().trim(),Ss(t)){let r=new Uint8Array(e+4);return t.split(/\./g).forEach(n=>{r[e++]=parseInt(n,10)&255}),r}if(Od(t)){let r=t.split(":",8),n;for(n=0;n<r.length;n++){let i=Ss(r[n]),s;i&&(s=Eo(r[n]),r[n]=z(s.slice(0,2),"base16")),s!=null&&++n<8&&r.splice(n,0,z(s.slice(2,4),"base16"))}if(r[0]==="")for(;r.length<8;)r.unshift("0");else if(r[r.length-1]==="")for(;r.length<8;)r.push("0");else if(r.length<8){for(n=0;n<r.length&&r[n]!=="";n++);let i=[n,1];for(n=9-r.length;n>0;n--)i.push("0");r.splice.apply(r,i)}let o=new Uint8Array(e+16);for(n=0;n<r.length;n++){let i=parseInt(r[n],16);o[e++]=i>>8&255,o[e++]=i&255}return o}throw new Error("invalid ip address")},As=function(t,e=0,r){e=~~e,r=r??t.length-e;let n=new DataView(t.buffer);if(r===4){let o=[];for(let i=0;i<r;i++)o.push(t[e+i]);return o.join(".")}if(r===16){let o=[];for(let i=0;i<r;i+=2)o.push(n.getUint16(e+i).toString(16));return o.join(":").replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}return""};var Vt={},bo={},Rd=[[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"]];Rd.forEach(t=>{let e=Dd(...t);bo[e.code]=e,Vt[e.name]=e});function Dd(t,e,r,n,o){return{code:t,size:e,name:r,resolvable:!!n,path:!!o}}function k(t){if(typeof t=="number"){if(bo[t]!=null)return bo[t];throw new Error(`no protocol with code: ${t}`)}else if(typeof t=="string"){if(Vt[t]!=null)return Vt[t];throw new Error(`no protocol with name: ${t}`)}throw new Error(`invalid protocol id type: ${typeof t}`)}var lm=k("ip4"),hm=k("ip6"),pm=k("ipcidr");function Ao(t,e){switch(k(t).code){case 4:case 41:return _d(e);case 42:return So(e);case 43:return z(e,"base10");case 6:case 273:case 33:case 132:return Ls(e).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return So(e);case 421:return qd(e);case 444:return Us(e);case 445:return Us(e);case 466:return Kd(e);case 481:return globalThis.encodeURIComponent(So(e));default:return z(e,"base16")}}function Bo(t,e){switch(k(t).code){case 4:return Bs(e);case 41:return Bs(e);case 42:return vo(e);case 43:return Ge(e,"base10");case 6:case 273:case 33:case 132:return Uo(parseInt(e,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return vo(e);case 421:return Md(e);case 444:return zd(e);case 445:return Vd(e);case 466:return Fd(e);case 481:return vo(globalThis.decodeURIComponent(e));default:return Ge(e,"base16")}}var Io=Object.values(Qt).map(t=>t.decoder),kd=function(){let t=Io[0].or(Io[1]);return Io.slice(2).forEach(e=>t=t.or(e)),t}();function Bs(t){if(!Vr(t))throw new Error("invalid ip address");return Eo(t)}function _d(t){let e=As(t,0,t.length);if(e==null)throw new Error("ipBuff is required");if(!Vr(e))throw new Error("invalid ip address");return e}function Uo(t){let e=new ArrayBuffer(2);return new DataView(e).setUint16(0,t),new Uint8Array(e)}function Ls(t){return new DataView(t.buffer).getUint16(t.byteOffset)}function vo(t){let e=Ge(t),r=Uint8Array.from(Dt(e.length));return Ce([r,e],r.length+e.length)}function So(t){let e=gt(t);if(t=t.slice(se(e)),t.length!==e)throw new Error("inconsistent lengths");return z(t)}function Md(t){let e;t[0]==="Q"||t[0]==="1"?e=pt(K.decode(`z${t}`)).bytes:e=ee.parse(t).multihash.bytes;let r=Uint8Array.from(Dt(e.length));return Ce([r,e],r.length+e.length)}function Fd(t){let e=kd.decode(t),r=Uint8Array.from(Dt(e.length));return Ce([r,e],r.length+e.length)}function Kd(t){let e=gt(t),r=t.slice(se(e));if(r.length!==e)throw new Error("inconsistent lengths");return"u"+z(r,"base64url")}function qd(t){let e=gt(t),r=t.slice(se(e));if(r.length!==e)throw new Error("inconsistent lengths");return z(r,"base58btc")}function zd(t){let e=t.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 r=Ve.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 o=Uo(n);return Ce([r,o],r.length+o.length)}function Vd(t){let e=t.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 r=Ve.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 o=Uo(n);return Ce([r,o],r.length+o.length)}function Us(t){let e=t.slice(0,t.length-2),r=t.slice(t.length-2),n=z(e,"base32"),o=Ls(r);return`${n}:${o}`}function Ts(t){t=Lo(t);let e=[],r=[],n=null,o=t.split("/").slice(1);if(o.length===1&&o[0]==="")return{bytes:new Uint8Array,string:"/",tuples:[],stringTuples:[],path:null};for(let i=0;i<o.length;i++){let s=o[i],a=k(s);if(a.size===0){e.push([a.code]),r.push([a.code]);continue}if(i++,i>=o.length)throw Cs("invalid address: "+t);if(a.path===!0){n=Lo(o.slice(i).join("/")),e.push([a.code,Bo(a.code,n)]),r.push([a.code,n]);break}let c=Bo(a.code,o[i]);e.push([a.code,c]),r.push([a.code,Ao(a.code,c)])}return{string:Ns(r),bytes:No(e),tuples:e,stringTuples:r,path:n}}function To(t){let e=[],r=[],n=null,o=0;for(;o<t.length;){let i=gt(t,o),s=se(i),a=k(i),c=Hd(a,t.slice(o+s));if(c===0){e.push([i]),r.push([i]),o+=s;continue}let d=t.slice(o+s,o+s+c);if(o+=c+s,o>t.length)throw Cs("Invalid address Uint8Array: "+z(t,"base16"));e.push([i,d]);let g=Ao(i,d);if(r.push([i,g]),a.path===!0){n=g;break}}return{bytes:Uint8Array.from(t),string:Ns(r),tuples:e,stringTuples:r,path:n}}function Ns(t){let e=[];return t.map(r=>{let n=k(r[0]);return e.push(n.name),r.length>1&&r[1]!=null&&e.push(r[1]),null}),Lo(e.join("/"))}function No(t){return Ce(t.map(e=>{let r=k(e[0]),n=Uint8Array.from(Dt(r.code));return e.length>1&&e[1]!=null&&(n=Ce([n,e[1]])),n}))}function Hd(t,e){if(t.size>0)return t.size/8;if(t.size===0)return 0;{let r=gt(e instanceof Uint8Array?e:Uint8Array.from(e));return r+se(r)}}function Lo(t){return"/"+t.trim().split("/").filter(e=>e).join("/")}function Cs(t){return new Error("Error parsing address: "+t)}var jd=Symbol.for("nodejs.util.inspect.custom"),Oo=Symbol.for("@multiformats/js-multiaddr/multiaddr"),$d=[k("dns").code,k("dns4").code,k("dns6").code,k("dnsaddr").code],Co=class extends Error{constructor(e="No available resolver"){super(e),this.name="NoAvailableResolverError"}},jr=class t{bytes;#e;#t;#r;#n;[Oo]=!0;constructor(e){e==null&&(e="");let r;if(e instanceof Uint8Array)r=To(e);else if(typeof e=="string"){if(e.length>0&&e.charAt(0)!=="/")throw new Error(`multiaddr "${e}" must start with a "/"`);r=Ts(e)}else if(Ps(e))r=To(e.bytes);else throw new Error("addr must be a string, Buffer, or another Multiaddr");this.bytes=r.bytes,this.#e=r.string,this.#t=r.tuples,this.#r=r.stringTuples,this.#n=r.path}toString(){return this.#e}toJSON(){return this.toString()}toOptions(){let e,r,n,o,i="",s=k("tcp"),a=k("udp"),c=k("ip4"),d=k("ip6"),g=k("dns6"),l=k("ip6zone");for(let[p,h]of this.stringTuples())p===l.code&&(i=`%${h??""}`),$d.includes(p)&&(r=s.name,o=443,n=`${h??""}${i}`,e=p===g.code?6:4),(p===s.code||p===a.code)&&(r=k(p).name,o=parseInt(h??"")),(p===c.code||p===d.code)&&(r=k(p).name,n=`${h??""}${i}`,e=p===d.code?6:4);if(e==null||r==null||n==null||o==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:r,port:o}}protos(){return this.#t.map(([e])=>Object.assign({},k(e)))}protoCodes(){return this.#t.map(([e])=>e)}protoNames(){return this.#t.map(([e])=>k(e).name)}tuples(){return this.#t.map(([e,r])=>r==null?[e]:[e,r])}stringTuples(){return this.#r.map(([e,r])=>r==null?[e]:[e,r])}encapsulate(e){return e=new t(e),new t(this.toString()+e.toString())}decapsulate(e){let r=e.toString(),n=this.toString(),o=n.lastIndexOf(r);if(o<0)throw new Error(`Address ${this.toString()} does not contain subaddress: ${e.toString()}`);return new t(n.slice(0,o))}decapsulateCode(e){let r=this.tuples();for(let n=r.length-1;n>=0;n--)if(r[n][0]===e)return new t(No(r.slice(0,n)));return this}getPeerId(){try{let e=[];this.stringTuples().forEach(([n,o])=>{n===Vt.p2p.code&&e.push([n,o]),n===Vt["p2p-circuit"].code&&(e=[])});let r=e.pop();if(r?.[1]!=null){let n=r[1];return n[0]==="Q"||n[0]==="1"?z(K.decode(`z${n}`),"base58btc"):z(ee.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){return this.#n}equals(e){return je(this.bytes,e.bytes)}async resolve(e){let r=this.protos().find(i=>i.resolvable);if(r==null)return[this];let n=Os.get(r.name);if(n==null)throw new Co(`no available resolver for ${r.name}`);return(await n(this,e)).map(i=>ar(i))}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 r=(e??this).protos();return!(r.length!==2||r[0].code!==4&&r[0].code!==41||r[1].code!==6&&r[1].code!==273)}[jd](){return`Multiaddr(${this.#e})`}};var Os=new Map;function Ps(t){return!!t?.[Oo]}function ar(t){return new jr(t)}function Rs(t,e,r,n){let o=()=>{n?.log.trace("query",e),t.query({questions:[{name:e,type:"PTR"}]})};return o(),setInterval(o,r)}function Ds(t,e,r,n){if(t.answers==null)return;let o,i=[];if(t.answers.forEach(s=>{switch(s.type){case"PTR":o=s;break;case"TXT":i.push(s);break;default:break}}),t.additionals.forEach(s=>{switch(s.type){case"TXT":i.push(s);break;default:break}}),!(o==null||o?.name!==r||i.length===0||o.data.startsWith(e)))try{let s=i.flatMap(c=>c.data).filter(c=>c.toString().startsWith("dnsaddr=")).map(c=>ar(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:fs(a),multiaddrs:s.map(c=>c.decapsulateCode(k("p2p").code))}}catch(s){n?.log.error("failed to parse mdns response",s)}}function ks(t,e,r,n,o,i,s){if(!i){s?.log("not responding to mDNS query as broadcast mode is false");return}if(n.length!==0&&t.questions[0]!=null&&t.questions[0].name===o){let a=[];a.push({name:o,type:"PTR",class:"IN",ttl:120,data:r+"."+o}),n.filter(Gd).forEach(c=>{let d="dnsaddr="+c.toString();if(d.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:r+"."+o,type:"TXT",class:"IN",ttl:120,data:d})}),s?.log.trace("responding to query"),e.respond(a)}}function Gd(t){return!!bs(t)}function _s(t){let e="",r="abcdefghijklmnopqrstuvwxyz0123456789";for(let n=0;n<t;n++)e+=r.charAt(Math.floor(Math.random()*r.length));return e}var $r=class extends hr{mdns;log;broadcast;interval;serviceTag;peerName;port;ip;_queryInterval;components;constructor(e,r={}){if(super(),this.log=e.logger.forComponent("libp2p:mdns"),this.broadcast=r.broadcast!==!1,this.interval=r.interval??1e3*10,this.serviceTag=r.serviceTag??"_p2p._udp.local",this.ip=r.ip??"224.0.0.251",this.peerName=r.peerName??_s(63),this.peerName.length>=64)throw new Error("Peer name should be less than 64 chars long");this.port=r.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)}[Do]=this;[Symbol.toStringTag]="@libp2p/mdns";[Mo]=["@libp2p/peer-discovery"];isStarted(){return!!this.mdns}async start(){this.mdns==null&&(this.mdns=(0,Ms.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=Rs(this.mdns,this.serviceTag,this.interval,{log:this.log}))}_onMdnsQuery(e){this.mdns!=null&&(this.log.trace("received incoming mDNS query"),ks(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 r=Ds(e,this.peerName,this.serviceTag,{log:this.log});r!=null&&(this.log("discovered peer in mDNS query response %p",r.id),this.dispatchEvent(new CustomEvent("peer",{detail:r})))}catch(r){this.log.error("Error processing peer response",r)}}_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 Xd(t={}){return e=>new $r(e,t)}return Hs(Zd);})();
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.13",
3
+ "version": "11.0.14-5c4a79e5a",
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,20 +50,20 @@
50
50
  "test:electron-main": "aegir test -t electron-main"
51
51
  },
52
52
  "dependencies": {
53
- "@libp2p/interface": "^2.2.1",
54
- "@libp2p/interface-internal": "^2.1.1",
55
- "@libp2p/peer-id": "^5.0.8",
56
- "@libp2p/utils": "^6.2.1",
57
- "@multiformats/multiaddr": "^12.2.3",
53
+ "@libp2p/interface": "2.3.0-5c4a79e5a",
54
+ "@libp2p/interface-internal": "2.2.0-5c4a79e5a",
55
+ "@libp2p/peer-id": "5.0.9-5c4a79e5a",
56
+ "@libp2p/utils": "6.3.0-5c4a79e5a",
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.0.7",
64
- "@libp2p/interface-compliance-tests": "^6.1.11",
65
- "@libp2p/logger": "^5.1.4",
66
- "aegir": "^44.0.1",
63
+ "@libp2p/crypto": "5.0.8-5c4a79e5a",
64
+ "@libp2p/interface-compliance-tests": "6.2.0-5c4a79e5a",
65
+ "@libp2p/logger": "5.1.5-5c4a79e5a",
66
+ "aegir": "^45.0.5",
67
67
  "p-wait-for": "^5.0.2",
68
68
  "sinon-ts": "^2.0.0"
69
69
  },
package/LICENSE DELETED
@@ -1,4 +0,0 @@
1
- This project is dual licensed under MIT and Apache-2.0.
2
-
3
- MIT: https://www.opensource.org/licenses/mit
4
- Apache-2.0: https://www.apache.org/licenses/license-2.0
@@ -1,6 +0,0 @@
1
- {
2
- "MulticastDNSComponents": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_mdns.MulticastDNSComponents.html",
3
- "MulticastDNSInit": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_mdns.MulticastDNSInit.html",
4
- "mdns": "https://libp2p.github.io/js-libp2p/functions/_libp2p_mdns.mdns.html",
5
- ".:mdns": "https://libp2p.github.io/js-libp2p/functions/_libp2p_mdns.mdns.html"
6
- }