@libp2p/mdns 12.0.25-bfb7ceb0f → 12.0.25-dd084c0b2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +3 -3
- package/package.json +9 -9
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 Yc=Object.create;var vr=Object.defineProperty;var Gc=Object.getOwnPropertyDescriptor;var Wc=Object.getOwnPropertyNames;var Xc=Object.getPrototypeOf,Zc=Object.prototype.hasOwnProperty;var pe=(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 Se=(t,e)=>()=>{try{return e||t((e={exports:{}}).exports,e),e.exports}catch(r){throw e=0,r}},fe=(t,e)=>{for(var r in e)vr(t,r,{get:e[r],enumerable:!0})},mi=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Wc(e))!Zc.call(t,o)&&o!==r&&vr(t,o,{get:()=>e[o],enumerable:!(n=Gc(e,o))||n.enumerable});return t};var Zt=(t,e,r)=>(r=t!=null?Yc(Xc(t)):{},mi(e||!t||!t.__esModule?vr(r,"default",{value:t,enumerable:!0}):r,t)),Qc=t=>mi(vr({},"__esModule",{value:!0}),t);var xi=Se(wn=>{"use strict";wn.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};wn.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 Ei=Se(bn=>{"use strict";bn.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};bn.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 Ii=Se(xn=>{"use strict";xn.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};xn.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 Si=Se(En=>{"use strict";En.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};En.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 vi=Se(In=>{"use strict";In.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}`};In.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 Ci=Se((Bi,Sn)=>{var Ai=(function(t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.decode=d,t.encode=p,t.familyOf=u,t.name=void 0,t.sizeOf=a,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:f=>e.test(f),encode(f,h,l){l=~~l,h=h||new Uint8Array(l+r);let m=f.length,x=0;for(let L=0;L<m;){let D=f.charCodeAt(L++);D===46?(h[l++]=x,x=0):x=x*10+(D-48)}return h[l]=x,h},decode(f,h){return h=~~h,`${f[h++]}.${f[h++]}.${f[h++]}.${f[h]}`}};t.v4=i;let s={name:"v6",size:o,isFormat:f=>f.length>0&&n.test(f),encode(f,h,l){l=~~l;let m=l+o,x=-1,L=0,D=0,K=!0,N=!1;h=h||new Uint8Array(l+o);for(let P=0;P<f.length;P++){let k=f.charCodeAt(P);k===58?(K?x!==-1?(l<m&&(h[l]=0),l<m-1&&(h[l+1]=0),l+=2):l<m&&(x=l):(N===!0?(l<m&&(h[l]=D),l++):(l<m&&(h[l]=L>>8),l<m-1&&(h[l+1]=L&255),l+=2),L=0,D=0),K=!0,N=!1):k===46?(l<m&&(h[l]=D),l++,D=0,L=0,K=!1,N=!0):(K=!1,k>=97?k-=87:k>=65?k-=55:(k-=48,D=D*10+k),L=(L<<4)+k)}if(K===!1)N===!0?(l<m&&(h[l]=D),l++):(l<m&&(h[l]=L>>8),l<m-1&&(h[l+1]=L&255),l+=2);else if(x===0)l<m&&(h[l]=0),l<m-1&&(h[l+1]=0),l+=2;else if(x!==-1){l+=2;for(let P=Math.min(l-1,m-1);P>=x+2;P--)h[P]=h[P-2];h[x]=0,h[x+1]=0,x=l}if(x!==l&&x!==-1)for(l>m-2&&(l=m-2);m>x;)h[--m]=l<m&&l>x?h[--l]:0;else for(;l<m;)h[l++]=0;return h},decode(f,h){h=~~h;let l="";for(let m=0;m<o;m+=2)m!==0&&(l+=":"),l+=(f[h+m]<<8|f[h+m+1]).toString(16);return l.replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}};t.v6=s;let c="ip";t.name=c;function a(f){if(i.isFormat(f))return i.size;if(s.isFormat(f))return s.size;throw Error(`Invalid ip address: ${f}`)}function u(f){return a(f)===i.size?1:2}function p(f,h,l){l=~~l;let m=a(f);return typeof h=="function"&&(h=h(l+m)),m===i.size?i.encode(f,h,l):s.encode(f,h,l)}function d(f,h,l){if(h=~~h,l=l||f.length-h,l===i.size)return i.decode(f,h,l);if(l===s.size)return s.decode(f,h,l);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 Ai}):typeof Sn=="object"&&typeof Bi=="object"&&(Sn.exports=Ai)});var Ti=Se(v=>{"use strict";var A=pe("buffer").Buffer,ot=xi(),ta=Ei(),ra=Ii(),Tr=Si(),vn=vi(),xt=Ci(),na=0,Li=32768,An=32768,oa=~An,Oi=32768,ia=~Oi,y=v.name={};y.encode=function(t,e,r,{mail:n=!1}={}){e||(e=A.alloc(y.encodingLength(t))),r||(r=0);let o=r,i=t.replace(/^\.|\.$/gm,"");if(i.length){let s=[];if(n){let c="";i.split(".").forEach(a=>{a.endsWith("\\")?c+=(c.length?".":"")+a.slice(0,-1):s.length===0&&c.length?s.push(c+"."+a):s.push(a)})}else s=i.split(".");for(let c=0;c<s.length;c++){let a=e.write(s[c],r+1);e[r]=a,r+=a+1}}return e[r++]=0,y.encode.bytes=r-o,e};y.encode.bytes=0;y.decode=function(t,e,{mail:r=!1}={}){e||(e=0);let n=[],o=e,i=0,s=0,c=!1;for(;;){if(e>=t.length)throw new Error("Cannot decode name (buffer overflow)");let a=t[e++];if(s+=c?0:1,a===0)break;if((a&192)===0){if(e+a>t.length)throw new Error("Cannot decode name (buffer overflow)");if(i+=a+1,i>254)throw new Error("Cannot decode name (name too long)");let u=t.toString("utf-8",e,e+a);r&&(u=u.replace(/\./g,"\\.")),n.push(u),e+=a,s+=c?0:a}else if((a&192)===192){if(e+1>t.length)throw new Error("Cannot decode name (buffer overflow)");let u=t.readUInt16BE(e-1)-49152;if(u>=o)throw new Error("Cannot decode name (bad pointer)");e=u,o=u,s+=c?0:1,c=!0}else throw new Error("Cannot decode name (bad label)")}return y.decode.bytes=s,n.length===0?".":n.join(".")};y.decode.bytes=0;y.encodingLength=function(t){return t==="."||t===".."?1:A.byteLength(t.replace(/^\.|\.$/gm,""))+2};var U={};U.encode=function(t,e,r){e||(e=A.alloc(U.encodingLength(t))),r||(r=0);let n=e.write(t,r+1);return e[r]=n,U.encode.bytes=n+1,e};U.encode.bytes=0;U.decode=function(t,e){e||(e=0);let r=t[e],n=t.toString("utf-8",e+1,e+1+r);return U.decode.bytes=r+1,n};U.decode.bytes=0;U.encodingLength=function(t){return A.byteLength(t)+1};var Oe={};Oe.encode=function(t,e,r){e||(e=Oe.encodingLength(t)),r||(r=0);let n=(t.flags||0)&32767,o=t.type==="response"?Li:na;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};Oe.encode.bytes=12;Oe.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&Li?"response":"query",flags:r&32767,flag_qr:(r>>15&1)===1,opcode:ra.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:ta.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))}};Oe.decode.bytes=12;Oe.encodingLength=function(){return 12};var We=v.unknown={};We.encode=function(t,e,r){return e||(e=A.alloc(We.encodingLength(t))),r||(r=0),e.writeUInt16BE(t.length,r),t.copy(e,r+2),We.encode.bytes=t.length+2,e};We.encode.bytes=0;We.decode=function(t,e){e||(e=0);let r=t.readUInt16BE(e),n=t.slice(e+2,e+2+r);return We.decode.bytes=r+2,n};We.decode.bytes=0;We.encodingLength=function(t){return t.length+2};var Xe=v.ns={};Xe.encode=function(t,e,r){return e||(e=A.alloc(Xe.encodingLength(t))),r||(r=0),y.encode(t,e,r+2),e.writeUInt16BE(y.encode.bytes,r),Xe.encode.bytes=y.encode.bytes+2,e};Xe.encode.bytes=0;Xe.decode=function(t,e){e||(e=0);let r=t.readUInt16BE(e),n=y.decode(t,e+2);return Xe.decode.bytes=r+2,n};Xe.decode.bytes=0;Xe.encodingLength=function(t){return y.encodingLength(t)+2};var Ze=v.soa={};Ze.encode=function(t,e,r){e||(e=A.alloc(Ze.encodingLength(t))),r||(r=0);let n=r;return r+=2,y.encode(t.mname,e,r),r+=y.encode.bytes,y.encode(t.rname,e,r,{mail:!0}),r+=y.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),Ze.encode.bytes=r-n,e};Ze.encode.bytes=0;Ze.decode=function(t,e){e||(e=0);let r=e,n={};return e+=2,n.mname=y.decode(t,e),e+=y.decode.bytes,n.rname=y.decode(t,e,{mail:!0}),e+=y.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,Ze.decode.bytes=e-r,n};Ze.decode.bytes=0;Ze.encodingLength=function(t){return 22+y.encodingLength(t.mname)+y.encodingLength(t.rname)};var Qe=v.txt={};Qe.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]=A.from(t[o])),!A.isBuffer(t[o]))throw new Error("Must be a Buffer");e||(e=A.alloc(Qe.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),Qe.encode.bytes=r-n,e};Qe.encode.bytes=0;Qe.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 Qe.decode.bytes=e-r,o};Qe.decode.bytes=0;Qe.encodingLength=function(t){Array.isArray(t)||(t=[t]);let e=2;return t.forEach(function(r){typeof r=="string"?e+=A.byteLength(r)+1:e+=r.length+1}),e};var Je=v.null={};Je.encode=function(t,e,r){e||(e=A.alloc(Je.encodingLength(t))),r||(r=0),typeof t=="string"&&(t=A.from(t)),t||(t=A.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),Je.encode.bytes=r-n,e};Je.encode.bytes=0;Je.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,Je.decode.bytes=e-r,o};Je.decode.bytes=0;Je.encodingLength=function(t){return t?(A.isBuffer(t)?t.length:A.byteLength(t))+2:2};var et=v.hinfo={};et.encode=function(t,e,r){e||(e=A.alloc(et.encodingLength(t))),r||(r=0);let n=r;return r+=2,U.encode(t.cpu,e,r),r+=U.encode.bytes,U.encode(t.os,e,r),r+=U.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.cpu=U.decode(t,e),e+=U.decode.bytes,n.os=U.decode(t,e),e+=U.decode.bytes,et.decode.bytes=e-r,n};et.decode.bytes=0;et.encodingLength=function(t){return U.encodingLength(t.cpu)+U.encodingLength(t.os)+2};var Ce=v.ptr={},sa=v.cname=Ce,ca=v.dname=Ce;Ce.encode=function(t,e,r){return e||(e=A.alloc(Ce.encodingLength(t))),r||(r=0),y.encode(t,e,r+2),e.writeUInt16BE(y.encode.bytes,r),Ce.encode.bytes=y.encode.bytes+2,e};Ce.encode.bytes=0;Ce.decode=function(t,e){e||(e=0);let r=y.decode(t,e+2);return Ce.decode.bytes=y.decode.bytes+2,r};Ce.decode.bytes=0;Ce.encodingLength=function(t){return y.encodingLength(t)+2};var tt=v.srv={};tt.encode=function(t,e,r){e||(e=A.alloc(tt.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),y.encode(t.target,e,r+8);let n=y.encode.bytes+6;return e.writeUInt16BE(n,r),tt.encode.bytes=n+2,e};tt.encode.bytes=0;tt.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=y.decode(t,e+8),tt.decode.bytes=r+2,n};tt.decode.bytes=0;tt.encodingLength=function(t){return 8+y.encodingLength(t.target)};var me=v.caa={};me.ISSUER_CRITICAL=128;me.encode=function(t,e,r){let n=me.encodingLength(t);return e||(e=A.alloc(me.encodingLength(t))),r||(r=0),t.issuerCritical&&(t.flags=me.ISSUER_CRITICAL),e.writeUInt16BE(n-2,r),r+=2,e.writeUInt8(t.flags||0,r),r+=1,U.encode(t.tag,e,r),r+=U.encode.bytes,e.write(t.value,r),r+=A.byteLength(t.value),me.encode.bytes=n,e};me.encode.bytes=0;me.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=U.decode(t,e),e+=U.decode.bytes,o.value=t.toString("utf-8",e,n+r),o.issuerCritical=!!(o.flags&me.ISSUER_CRITICAL),me.decode.bytes=r+2,o};me.decode.bytes=0;me.encodingLength=function(t){return U.encodingLength(t.tag)+U.encodingLength(t.value)+2};var dt=v.mx={};dt.encode=function(t,e,r){e||(e=A.alloc(dt.encodingLength(t))),r||(r=0);let n=r;return r+=2,e.writeUInt16BE(t.preference||0,r),r+=2,y.encode(t.exchange,e,r),r+=y.encode.bytes,e.writeUInt16BE(r-n-2,n),dt.encode.bytes=r-n,e};dt.encode.bytes=0;dt.decode=function(t,e){e||(e=0);let r=e,n={};return e+=2,n.preference=t.readUInt16BE(e),e+=2,n.exchange=y.decode(t,e),e+=y.decode.bytes,dt.decode.bytes=e-r,n};dt.encodingLength=function(t){return 4+y.encodingLength(t.exchange)};var rt=v.a={};rt.encode=function(t,e,r){return e||(e=A.alloc(rt.encodingLength(t))),r||(r=0),e.writeUInt16BE(4,r),r+=2,xt.v4.encode(t,e,r),rt.encode.bytes=6,e};rt.encode.bytes=0;rt.decode=function(t,e){e||(e=0),e+=2;let r=xt.v4.decode(t,e);return rt.decode.bytes=6,r};rt.decode.bytes=0;rt.encodingLength=function(){return 6};var nt=v.aaaa={};nt.encode=function(t,e,r){return e||(e=A.alloc(nt.encodingLength(t))),r||(r=0),e.writeUInt16BE(16,r),r+=2,xt.v6.encode(t,e,r),nt.encode.bytes=18,e};nt.encode.bytes=0;nt.decode=function(t,e){e||(e=0),e+=2;let r=xt.v6.decode(t,e);return nt.decode.bytes=18,r};nt.decode.bytes=0;nt.encodingLength=function(){return 18};var le=v.option={};le.encode=function(t,e,r){e||(e=A.alloc(le.encodingLength(t))),r||(r=0);let n=r,o=vn.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||xt.familyOf(t.ip),c=xt.encode(t.ip,A.alloc),a=Math.ceil(i/8);e.writeUInt16BE(a+4,r),r+=2,e.writeUInt16BE(s,r),r+=2,e.writeUInt8(i,r++),e.writeUInt8(t.scopePrefixLength||0,r++),c.copy(e,r,0,a),r+=a;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 u=t.length||0;e.writeUInt16BE(u,r),r+=2,e.fill(0,r,r+u),r+=u;break;case 14:let p=t.tags.length*2;e.writeUInt16BE(p,r),r+=2;for(let d of t.tags)e.writeUInt16BE(d,r),r+=2;break;default:throw new Error(`Unknown roption code: ${t.code}`)}return le.encode.bytes=r-n,e};le.encode.bytes=0;le.decode=function(t,e){e||(e=0);let r={};r.code=t.readUInt16BE(e),r.type=vn.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=A.alloc(r.family===1?4:16);t.copy(o,0,e,e+n-4),r.ip=xt.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 le.decode.bytes=n+4,r};le.decode.bytes=0;le.encodingLength=function(t){if(t.data)return t.data.length+4;switch(vn.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 ye=v.opt={};ye.encode=function(t,e,r){e||(e=A.alloc(ye.encodingLength(t))),r||(r=0);let n=r,o=Ut(t,le);return e.writeUInt16BE(o,r),r=Jt(t,le,e,r+2),ye.encode.bytes=r-n,e};ye.encode.bytes=0;ye.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++]=le.decode(t,e),e+=le.decode.bytes,o-=le.decode.bytes;return ye.decode.bytes=e-r,n};ye.decode.bytes=0;ye.encodingLength=function(t){return 2+Ut(t||[],le)};var ce=v.dnskey={};ce.PROTOCOL_DNSSEC=3;ce.ZONE_KEY=128;ce.SECURE_ENTRYPOINT=32768;ce.encode=function(t,e,r){e||(e=A.alloc(ce.encodingLength(t))),r||(r=0);let n=r,o=t.key;if(!A.isBuffer(o))throw new Error("Key must be a Buffer");return r+=2,e.writeUInt16BE(t.flags,r),r+=2,e.writeUInt8(ce.PROTOCOL_DNSSEC,r),r+=1,e.writeUInt8(t.algorithm,r),r+=1,o.copy(e,r,0,o.length),r+=o.length,ce.encode.bytes=r-n,e.writeUInt16BE(ce.encode.bytes-2,n),e};ce.encode.bytes=0;ce.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)!==ce.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,ce.decode.bytes=e-r,n};ce.decode.bytes=0;ce.encodingLength=function(t){return 6+A.byteLength(t.key)};var Ne=v.rrsig={};Ne.encode=function(t,e,r){e||(e=A.alloc(Ne.encodingLength(t))),r||(r=0);let n=r,o=t.signature;if(!A.isBuffer(o))throw new Error("Signature must be a Buffer");return r+=2,e.writeUInt16BE(ot.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,y.encode(t.signersName,e,r),r+=y.encode.bytes,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;var n={},o=t.readUInt16BE(e);return e+=2,n.typeCovered=ot.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=y.decode(t,e),e+=y.decode.bytes,n.signature=t.slice(e,r+o+2),e+=n.signature.length,Ne.decode.bytes=e-r,n};Ne.decode.bytes=0;Ne.encodingLength=function(t){return 20+y.encodingLength(t.signersName)+A.byteLength(t.signature)};var Fe=v.rp={};Fe.encode=function(t,e,r){e||(e=A.alloc(Fe.encodingLength(t))),r||(r=0);let n=r;return r+=2,y.encode(t.mbox||".",e,r,{mail:!0}),r+=y.encode.bytes,y.encode(t.txt||".",e,r),r+=y.encode.bytes,Fe.encode.bytes=r-n,e.writeUInt16BE(Fe.encode.bytes-2,n),e};Fe.encode.bytes=0;Fe.decode=function(t,e){e||(e=0);let r=e,n={};return e+=2,n.mbox=y.decode(t,e,{mail:!0})||".",e+=y.decode.bytes,n.txt=y.decode(t,e)||".",e+=y.decode.bytes,Fe.decode.bytes=e-r,n};Fe.decode.bytes=0;Fe.encodingLength=function(t){return 2+y.encodingLength(t.mbox||".")+y.encodingLength(t.txt||".")};var W={};W.encode=function(t,e,r){e||(e=A.alloc(W.encodingLength(t))),r||(r=0);let n=r;for(var o=[],i=0;i<t.length;i++){var s=ot.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 c=A.from(o[i]);e.writeUInt8(i,r),r+=1,e.writeUInt8(c.length,r),r+=1,c.copy(e,r),r+=c.length}return W.encode.bytes=r-n,e};W.encode.bytes=0;W.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 c=0;c<s;c++)for(var a=t.readUInt8(e+c),u=0;u<8;u++)if(a&1<<7-u){var p=ot.toString(i<<8|c<<3|u);o.push(p)}e+=s}return W.decode.bytes=e-n,o};W.decode.bytes=0;W.encodingLength=function(t){for(var e=[],r=0;r<t.length;r++){var n=ot.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 ke=v.nsec={};ke.encode=function(t,e,r){e||(e=A.alloc(ke.encodingLength(t))),r||(r=0);let n=r;return r+=2,y.encode(t.nextDomain,e,r),r+=y.encode.bytes,W.encode(t.rrtypes,e,r),r+=W.encode.bytes,ke.encode.bytes=r-n,e.writeUInt16BE(ke.encode.bytes-2,n),e};ke.encode.bytes=0;ke.decode=function(t,e){e||(e=0);let r=e;var n={},o=t.readUInt16BE(e);return e+=2,n.nextDomain=y.decode(t,e),e+=y.decode.bytes,n.rrtypes=W.decode(t,e,o-(e-r)),e+=W.decode.bytes,ke.decode.bytes=e-r,n};ke.decode.bytes=0;ke.encodingLength=function(t){return 2+y.encodingLength(t.nextDomain)+W.encodingLength(t.rrtypes)};var Ke=v.nsec3={};Ke.encode=function(t,e,r){e||(e=A.alloc(Ke.encodingLength(t))),r||(r=0);let n=r,o=t.salt;if(!A.isBuffer(o))throw new Error("salt must be a Buffer");let i=t.nextDomain;if(!A.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,W.encode(t.rrtypes,e,r),r+=W.encode.bytes,Ke.encode.bytes=r-n,e.writeUInt16BE(Ke.encode.bytes-2,n),e};Ke.encode.bytes=0;Ke.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=W.decode(t,e,o-(e-r)),e+=W.decode.bytes,Ke.decode.bytes=e-r,n};Ke.decode.bytes=0;Ke.encodingLength=function(t){return 8+t.salt.length+t.nextDomain.length+W.encodingLength(t.rrtypes)};var Me=v.ds={};Me.encode=function(t,e,r){e||(e=A.alloc(Me.encodingLength(t))),r||(r=0);let n=r,o=t.digest;if(!A.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,Me.encode.bytes=r-n,e.writeUInt16BE(Me.encode.bytes-2,n),e};Me.encode.bytes=0;Me.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,Me.decode.bytes=e-r,n};Me.decode.bytes=0;Me.encodingLength=function(t){return 6+A.byteLength(t.digest)};var ge=v.sshfp={};ge.getFingerprintLengthForHashType=function(e){switch(e){case 1:return 20;case 2:return 32}};ge.encode=function(e,r,n){r||(r=A.alloc(ge.encodingLength(e))),n||(n=0);let o=n;n+=2,r[n]=e.algorithm,n+=1,r[n]=e.hash,n+=1;let i=A.from(e.fingerprint.toUpperCase(),"hex");if(i.length!==ge.getFingerprintLengthForHashType(e.hash))throw new Error("Invalid fingerprint length");return i.copy(r,n),n+=i.byteLength,ge.encode.bytes=n-o,r.writeUInt16BE(ge.encode.bytes-2,o),r};ge.encode.bytes=0;ge.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=ge.getFingerprintLengthForHashType(o.hash);return o.fingerprint=e.slice(r,r+i).toString("hex").toUpperCase(),r+=i,ge.decode.bytes=r-n,o};ge.decode.bytes=0;ge.encodingLength=function(t){return 4+A.from(t.fingerprint,"hex").byteLength};var He=v.naptr={};He.encode=function(t,e,r){e||(e=A.alloc(He.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,U.encode(t.flags,e,r),r+=U.encode.bytes,U.encode(t.services,e,r),r+=U.encode.bytes,U.encode(t.regexp,e,r),r+=U.encode.bytes,y.encode(t.replacement,e,r),r+=y.encode.bytes,He.encode.bytes=r-n,e.writeUInt16BE(He.encode.bytes-2,n),e};He.encode.bytes=0;He.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=U.decode(t,e),e+=U.decode.bytes,n.services=U.decode(t,e),e+=U.decode.bytes,n.regexp=U.decode(t,e),e+=U.decode.bytes,n.replacement=y.decode(t,e),e+=y.decode.bytes,He.decode.bytes=e-r,n};He.decode.bytes=0;He.encodingLength=function(t){return U.encodingLength(t.flags)+U.encodingLength(t.services)+U.encodingLength(t.regexp)+y.encodingLength(t.replacement)+6};var qe=v.tlsa={};qe.encode=function(t,e,r){e||(e=A.alloc(qe.encodingLength(t))),r||(r=0);let n=r,o=t.certificate;if(!A.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,qe.encode.bytes=r-n,e.writeUInt16BE(qe.encode.bytes-2,n),e};qe.encode.bytes=0;qe.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,qe.decode.bytes=e-r,n};qe.decode.bytes=0;qe.encodingLength=function(t){return 5+A.byteLength(t.certificate)};var Bn=v.record=function(t){switch(t.toUpperCase()){case"A":return rt;case"PTR":return Ce;case"CNAME":return sa;case"DNAME":return ca;case"TXT":return Qe;case"NULL":return Je;case"AAAA":return nt;case"SRV":return tt;case"HINFO":return et;case"CAA":return me;case"NS":return Xe;case"SOA":return Ze;case"MX":return dt;case"OPT":return ye;case"DNSKEY":return ce;case"RRSIG":return Ne;case"RP":return Fe;case"NSEC":return ke;case"NSEC3":return Ke;case"SSHFP":return ge;case"DS":return Me;case"NAPTR":return He;case"TLSA":return qe}return We},te=v.answer={};te.encode=function(t,e,r){e||(e=A.alloc(te.encodingLength(t))),r||(r=0);let n=r;if(y.encode(t.name,e,r),r+=y.encode.bytes,e.writeUInt16BE(ot.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,ye.encode(t.options||[],e,r),r+=ye.encode.bytes}else{let o=Tr.toClass(t.class===void 0?"IN":t.class);t.flush&&(o|=An),e.writeUInt16BE(o,r+2),e.writeUInt32BE(t.ttl||0,r+4),r+=8;let i=Bn(t.type);i.encode(t.data,e,r),r+=i.encode.bytes}return te.encode.bytes=r-n,e};te.encode.bytes=0;te.decode=function(t,e){e||(e=0);let r={},n=e;if(r.name=y.decode(t,e),e+=y.decode.bytes,r.type=ot.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=ye.decode(t,e+8),e+=8+ye.decode.bytes;else{let o=t.readUInt16BE(e+2);r.ttl=t.readUInt32BE(e+4),r.class=Tr.toString(o&oa),r.flush=!!(o&An);let i=Bn(r.type);r.data=i.decode(t,e+8),e+=8+i.decode.bytes}return te.decode.bytes=e-n,r};te.decode.bytes=0;te.encodingLength=function(t){let e=t.data!==null&&t.data!==void 0?t.data:t.options;return y.encodingLength(t.name)+8+Bn(t.type).encodingLength(e)};var Le=v.question={};Le.encode=function(t,e,r){e||(e=A.alloc(Le.encodingLength(t))),r||(r=0);let n=r;return y.encode(t.name,e,r),r+=y.encode.bytes,e.writeUInt16BE(ot.toType(t.type),r),r+=2,e.writeUInt16BE(Tr.toClass(t.class===void 0?"IN":t.class),r),r+=2,Le.encode.bytes=r-n,t};Le.encode.bytes=0;Le.decode=function(t,e){e||(e=0);let r=e,n={};return n.name=y.decode(t,e),e+=y.decode.bytes,n.type=ot.toString(t.readUInt16BE(e)),e+=2,n.class=Tr.toString(t.readUInt16BE(e)),e+=2,n.class&Oi&&(n.class&=ia),Le.decode.bytes=e-r,n};Le.decode.bytes=0;Le.encodingLength=function(t){return y.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=A.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=[]),Oe.encode(t,e,r),r+=Oe.encode.bytes,r=Jt(t.questions,Le,e,r),r=Jt(t.answers,te,e,r),r=Jt(t.authorities,te,e,r),r=Jt(t.additionals,te,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=Oe.decode(t,e);return e+=Oe.decode.bytes,e=Or(n.questions,Le,t,e),e=Or(n.answers,te,t,e),e=Or(n.authorities,te,t,e),e=Or(n.additionals,te,t,e),v.decode.bytes=e-r,n};v.decode.bytes=0;v.encodingLength=function(t){return Oe.encodingLength(t)+Ut(t.questions||[],Le)+Ut(t.answers||[],te)+Ut(t.authorities||[],te)+Ut(t.additionals||[],te)};v.streamEncode=function(t){let e=v.encode(t),r=A.alloc(2);r.writeUInt16BE(e.byteLength);let n=A.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 Ut(t,e){let r=0;for(let n=0;n<t.length;n++)r+=e.encodingLength(t[n]);return r}function Jt(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 Or(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 _i=Se((Ah,Ui)=>{"use strict";var Di=pa;process.nextTick(ha,42);Ui.exports=aa;function aa(t){var e=n;return r;function r(o){e(o||da)}function n(o){var i=[o];e=s,t(c);function s(a){i.push(a)}function c(a){var u=arguments;for(e=ua(a)?n:p;i.length;)p(i.shift());function p(d){Di(la,d,u)}}}}function ua(t){return Object.prototype.toString.call(t)==="[object Error]"}function da(){}function la(t,e){t.apply(null,e)}function ha(t){t===42&&(Di=process.nextTick)}function pa(t,e,r){process.nextTick(function(){t(e,r)})}});var Ni=Se((Bh,Ri)=>{var Cn=Ti(),fa=pe("dgram"),ma=_i(),ga=pe("events"),On=pe("os"),Ln=function(){};Ri.exports=function(t){t||(t={});var e=new ga.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={},c=!1,a=null;if(n==="udp6"&&(!o||!t.interface))throw new Error("For IPv6 multicast you must specify `ip` and `interface`");var u=t.socket||fa.createSocket({type:n,reuseAddr:t.reuseAddr!==!1,toString:function(){return n}});u.on("error",function(d){d.code==="EACCES"||d.code==="EADDRINUSE"?e.emit("error",d):e.emit("warning",d)}),u.on("message",function(d,f){try{d=Cn.decode(d)}catch(h){e.emit("warning",h);return}e.emit("packet",d,f),d.type==="query"&&e.emit("query",d,f),d.type==="response"&&e.emit("response",d,f)}),u.on("listening",function(){r||(r=i.port=u.address().port),t.multicast!==!1&&(e.update(),a=setInterval(e.update,5e3),u.setMulticastTTL(t.ttl||255),u.setMulticastLoopback(t.loopback!==!1))});var p=ma(function(d){if(!r||t.bind===!1)return d(null);u.once("error",d),u.bind(r,t.bind||t.interface,function(){u.removeListener("error",d),d(null)})});return p(function(d){if(d)return e.emit("error",d);e.emit("ready")}),e.send=function(d,f,h){if(typeof f=="function")return e.send(d,null,f);h||(h=Ln),f?!f.host&&!f.address&&(f.address=i.address):f=i,p(l);function l(m){if(c)return h();if(m)return h(m);var x=Cn.encode(d);u.send(x,0,x.length,f.port,f.address||f.host,h)}},e.response=e.respond=function(d,f,h){Array.isArray(d)&&(d={answers:d}),d.type="response",d.flags=(d.flags||0)|Cn.AUTHORITATIVE_ANSWER,e.send(d,f,h)},e.query=function(d,f,h,l){if(typeof f=="function")return e.query(d,null,null,f);if(typeof f=="object"&&f&&f.port)return e.query(d,null,f,h);if(typeof h=="function")return e.query(d,f,null,h);l||(l=Ln),typeof d=="string"&&(d=[{name:d,type:f||"ANY"}]),Array.isArray(d)&&(d={type:"query",questions:d}),d.type="query",e.send(d,h,l)},e.destroy=function(d){if(d||(d=Ln),c)return process.nextTick(d);c=!0,clearInterval(a);for(var f in s)try{u.dropMembership(o,f)}catch{}s={},u.close(d)},e.update=function(){for(var d=t.interface?[].concat(t.interface):wa(),f=!1,h=0;h<d.length;h++){var l=d[h];if(!s[l])try{u.addMembership(o,l),s[l]=!0,f=!0}catch(m){e.emit("warning",m)}}if(f){if(u.setMulticastInterface)try{u.setMulticastInterface(t.interface||ya())}catch(m){e.emit("warning",m)}e.emit("networkInterface")}},e};function ya(){for(var t=On.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(Pi(i.family)&&!i.internal)return On.platform()==="darwin"&&e[r]==="en0"?i.address:"0.0.0.0"}return"127.0.0.1"}function wa(){for(var t=On.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(Pi(s.family)){r.push(s.address);break}}return r}function Pi(t){return t===4||t==="IPv4"}});var ei=Se(Yt=>{"use strict";Object.defineProperty(Yt,"__esModule",{value:!0});Yt.Netmask4Impl=void 0;Yt.ip2long=jt;Yt.long2ip=Ye;function Ye(t){let e=(t&-16777216)>>>24,r=(t&255<<16)>>>16,n=(t&65280)>>>8,o=t&255;return[e,r,n,o].join(".")}var Od=48,Td=97,Dd=65;function Ud(t){let e=0,r=10,n="9",o=0;t.length>1&&t[o]==="0"&&(t[o+1]==="x"||t[o+1]==="X"?(o+=2,r=16):"0"<=t[o+1]&&t[o+1]<="9"&&(o++,r=8,n="7"));let i=o;for(;o<t.length;){if("0"<=t[o]&&t[o]<=n)e=e*r+(t.charCodeAt(o)-Od)>>>0;else if(r===16)if("a"<=t[o]&&t[o]<="f")e=e*r+(10+t.charCodeAt(o)-Td)>>>0;else if("A"<=t[o]&&t[o]<="F")e=e*r+(10+t.charCodeAt(o)-Dd)>>>0;else break;else break;if(e>4294967295)throw new Error("too large");o++}if(o===i)throw new Error("empty octet");return[e,o]}function jt(t){let e=[];for(let r=0;r<=3&&t.length!==0;r++){if(r>0){if(t[0]!==".")throw new Error("Invalid IP");t=t.substring(1)}let[n,o]=Ud(t);t=t.substring(o),e.push(n)}if(t.length!==0)throw new Error("Invalid IP");switch(e.length){case 1:if(e[0]>4294967295)throw new Error("Invalid IP");return e[0]>>>0;case 2:if(e[0]>255||e[1]>16777215)throw new Error("Invalid IP");return(e[0]<<24|e[1])>>>0;case 3:if(e[0]>255||e[1]>255||e[2]>65535)throw new Error("Invalid IP");return(e[0]<<24|e[1]<<16|e[2])>>>0;case 4:if(e[0]>255||e[1]>255||e[2]>255||e[3]>255)throw new Error("Invalid IP");return(e[0]<<24|e[1]<<16|e[2]<<8|e[3])>>>0;default:throw new Error("Invalid IP")}}var Jo=class t{constructor(e,r){if(typeof e!="string")throw new Error("Missing `net' parameter");let n=r;if(!n){let o=e.split("/",2);e=o[0],n=o[1]}if(n||(n=32),typeof n=="string"&&n.indexOf(".")>-1){try{this.maskLong=jt(n)}catch{throw new Error("Invalid mask: "+n)}this.bitmask=NaN;for(let o=32;o>=0;o--)if(this.maskLong===4294967295<<32-o>>>0){this.bitmask=o;break}}else if(n||n===0)this.bitmask=parseInt(n,10),this.maskLong=0,this.bitmask>0&&(this.maskLong=4294967295<<32-this.bitmask>>>0);else throw new Error("Invalid mask: empty");try{this.netLong=(jt(e)&this.maskLong)>>>0}catch{throw new Error("Invalid net address: "+e)}if(!(this.bitmask<=32))throw new Error("Invalid mask for ip4: "+n);this.size=Math.pow(2,32-this.bitmask),this.base=Ye(this.netLong),this.mask=Ye(this.maskLong),this.hostmask=Ye(~this.maskLong),this.first=this.bitmask<=30?Ye(this.netLong+1):this.base,this.last=this.bitmask<=30?Ye(this.netLong+this.size-2):Ye(this.netLong+this.size-1),this.broadcast=this.bitmask<=30?Ye(this.netLong+this.size-1):void 0}contains(e){return typeof e=="string"&&(e.indexOf("/")>0||e.split(".").length!==4)&&(e=new t(e)),e instanceof t?this.contains(e.base)&&this.contains(e.broadcast||e.last):(jt(e)&this.maskLong)>>>0===(this.netLong&this.maskLong)>>>0}next(e=1){return new t(Ye(this.netLong+this.size*e),this.mask)}forEach(e){let r=jt(this.first),n=jt(this.last),o=0;for(;r<=n;)e(Ye(r),r,o),o++,r++}toString(){return this.base+"/"+this.bitmask}};Yt.Netmask4Impl=Jo});var Sc=Se(Gt=>{"use strict";Object.defineProperty(Gt,"__esModule",{value:!0});Gt.Netmask6Impl=void 0;Gt.ip6bigint=ri;Gt.bigint2ip6=Ot;var _d=ei(),ti=(1n<<128n)-1n;function ri(t){let e=t.indexOf("%");e!==-1&&(t=t.substring(0,e));let r=t.lastIndexOf(":");if(r!==-1&&t.indexOf(".",r)!==-1){let n=t.substring(r+1),o=(0,_d.ip2long)(n),i=t.substring(0,r+1)+"0:0";return Ic(i)&~0xffffffffn|BigInt(o)}return Ic(t)}function Ic(t){let e=t.indexOf("::"),r;if(e!==-1){let o=t.substring(0,e),i=t.substring(e+2),s=o===""?[]:o.split(":"),c=i===""?[]:i.split(":"),a=8-s.length-c.length;if(a<0)throw new Error("Invalid IPv6: too many groups");r=[...s,...Array(a).fill("0"),...c]}else r=t.split(":");if(r.length!==8)throw new Error("Invalid IPv6: expected 8 groups, got "+r.length);let n=0n;for(let o=0;o<8;o++){let i=r[o];if(i.length===0||i.length>4)throw new Error('Invalid IPv6: bad group "'+i+'"');let s=parseInt(i,16);if(isNaN(s)||s<0||s>65535)throw new Error('Invalid IPv6: bad group "'+i+'"');n=n<<16n|BigInt(s)}return n}function Ot(t){if(t<0n||t>ti)throw new Error("Invalid IPv6 address value");let e=[];for(let s=0;s<8;s++)e.unshift(Number(t&0xffffn)),t>>=16n;let r=-1,n=0,o=-1,i=0;for(let s=0;s<8;s++)e[s]===0?o===-1?(o=s,i=1):i++:(i>n&&i>=2&&(r=o,n=i),o=-1,i=0);if(i>n&&i>=2&&(r=o,n=i),r!==-1&&r+n===8&&r>0)return e.slice(0,r).map(c=>c.toString(16)).join(":")+"::";if(r===0)return"::"+e.slice(n).map(c=>c.toString(16)).join(":");if(r>0){let s=e.slice(0,r).map(a=>a.toString(16)),c=e.slice(r+n).map(a=>a.toString(16));return s.join(":")+"::"+c.join(":")}else return e.map(s=>s.toString(16)).join(":")}var ni=class t{constructor(e,r){if(typeof e!="string")throw new Error("Missing `net' parameter");let n=r;if(n==null){let o=e.indexOf("/");o!==-1?(n=parseInt(e.substring(o+1),10),e=e.substring(0,o)):n=128}if(isNaN(n)||n<0||n>128)throw new Error("Invalid mask for IPv6: "+n);this.bitmask=n,this.bitmask===0?this.maskBigint=0n:this.maskBigint=ti>>BigInt(128-this.bitmask)<<BigInt(128-this.bitmask);try{this.netBigint=ri(e)&this.maskBigint}catch{throw new Error("Invalid IPv6 net address: "+e)}this.size=Number(1n<<BigInt(128-this.bitmask)),this.base=Ot(this.netBigint),this.mask=Ot(this.maskBigint),this.hostmask=Ot(~this.maskBigint&ti),this.first=this.base,this.last=Ot(this.netBigint+(1n<<BigInt(128-this.bitmask))-1n),this.broadcast=void 0}contains(e){return typeof e=="string"&&e.indexOf("/")>0&&(e=new t(e)),e instanceof t?this.contains(e.base)&&this.contains(e.last):(ri(e)&this.maskBigint)===this.netBigint}next(e=1){let r=1n<<BigInt(128-this.bitmask);return new t(Ot(this.netBigint+r*BigInt(e)),this.bitmask)}forEach(e){let r=this.netBigint,n=1n<<BigInt(128-this.bitmask),o=this.netBigint+n-1n,i=0;for(;r<=o;)e(Ot(r),Number(r),i),i++,r++}toString(){return this.base+"/"+this.bitmask}};Gt.Netmask6Impl=ni});var vc=Se(bt=>{"use strict";Object.defineProperty(bt,"__esModule",{value:!0});bt.long2ip=bt.ip2long=bt.Netmask=void 0;var hn=ei();Object.defineProperty(bt,"ip2long",{enumerable:!0,get:function(){return hn.ip2long}});Object.defineProperty(bt,"long2ip",{enumerable:!0,get:function(){return hn.long2ip}});var Pd=Sc(),oi=class t{constructor(e,r){if(typeof e!="string")throw new Error("Missing `net' parameter");(e.indexOf("/")!==-1?e.substring(0,e.indexOf("/")):e).indexOf(":")!==-1?this._impl=new Pd.Netmask6Impl(e,r):this._impl=new hn.Netmask4Impl(e,r),this.base=this._impl.base,this.mask=this._impl.mask,this.hostmask=this._impl.hostmask,this.bitmask=this._impl.bitmask,this.size=this._impl.size,this.first=this._impl.first,this.last=this._impl.last,this.broadcast=this._impl.broadcast,this._impl instanceof hn.Netmask4Impl?(this.maskLong=this._impl.maskLong,this.netLong=this._impl.netLong):(this.maskLong=0,this.netLong=0)}contains(e){return typeof e=="string"&&(e.indexOf("/")>0?e=new t(e):e.indexOf(":")===-1&&e.split(".").length!==4&&(e=new t(e))),e instanceof t?this.contains(e.base)&&this.contains(e.broadcast||e.last):this._impl.contains(e)}next(e=1){let r=this._impl.next(e);return new t(r.base,r.bitmask)}forEach(e){this._impl.forEach(e)}toString(){return this._impl.toString()}};bt.Netmask=oi});var Ml={};fe(Ml,{mdns:()=>Kl});var ve=class extends Error{static name="InvalidParametersError";constructor(e="Invalid parameters"){super(e),this.name="InvalidParametersError"}},Ar=class extends Error{static name="InvalidPublicKeyError";constructor(e="Invalid public key"){super(e),this.name="InvalidPublicKeyError"}};var Br=class extends Error{static name="InvalidCIDError";constructor(e="Invalid CID"){super(e),this.name="InvalidCIDError"}},Cr=class extends Error{static name="InvalidMultihashError";constructor(e="Invalid Multihash"){super(e),this.name="InvalidMultihashError"}};var Qt=class extends Error{static name="UnsupportedKeyTypeError";constructor(e="Unsupported key type"){super(e),this.name="UnsupportedKeyTypeError"}};var gi=Symbol.for("@libp2p/peer-discovery");var yn=Symbol.for("@libp2p/peer-id");var yi=pe("node:events"),wi=(t,...e)=>{try{(0,yi.setMaxListeners)(t,...e)}catch{}};function Jc(t){return typeof t?.handleEvent=="function"}function ea(t){return(t!==!0&&t!==!1&&t?.once)??!1}var Lr=class extends EventTarget{#e=new Map;constructor(){super(),wi(1/0,this)}listenerCount(e){let r=this.#e.get(e);return r==null?0:r.length}addEventListener(e,r,n){let o=ea(n);super.addEventListener(e,s=>{if(o){let c=this.#e.get(s.type);c!=null&&(c=c.filter(({callback:a})=>a!==r),this.#e.set(s.type,c))}Jc(r)?r.handleEvent(s):r(s)},n);let i=this.#e.get(e);i==null&&(i=[],this.#e.set(e,i)),i.push({callback:r,once:o})}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))}safeDispatchEvent(e,r={}){return this.dispatchEvent(new CustomEvent(e,r))}};var bi=Symbol.for("@libp2p/service-capabilities");var jc=Zt(Ni(),1);var Pn={};fe(Pn,{base58btc:()=>j,base58flickr:()=>Ba});var Ch=new Uint8Array(0);function Fi(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 Ae(t){if(t instanceof Uint8Array&&t.constructor.name==="Uint8Array")return Et(t);if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return Et(new Uint8Array(t.buffer,t.byteOffset,t.byteLength));throw new Error("Unknown type, must be binary type")}function ki(t){return new TextEncoder().encode(t)}function Ki(t){return new TextDecoder().decode(t)}function ba(t){return t?.buffer instanceof ArrayBuffer}function Et(t){return ba(t)?t:t.slice()}function xa(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 c=t.length,a=t.charAt(0),u=Math.log(c)/Math.log(256),p=Math.log(256)/Math.log(c);function d(l){if(l instanceof Uint8Array||(ArrayBuffer.isView(l)?l=new Uint8Array(l.buffer,l.byteOffset,l.byteLength):Array.isArray(l)&&(l=Uint8Array.from(l))),!(l instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(l.length===0)return"";for(var m=0,x=0,L=0,D=l.length;L!==D&&l[L]===0;)L++,m++;for(var K=(D-L)*p+1>>>0,N=new Uint8Array(K);L!==D;){for(var P=l[L],k=0,G=K-1;(P!==0||k<x)&&G!==-1;G--,k++)P+=256*N[G]>>>0,N[G]=P%c>>>0,P=P/c>>>0;if(P!==0)throw new Error("Non-zero carry");x=k,L++}for(var _=K-x;_!==K&&N[_]===0;)_++;for(var Be=a.repeat(m);_<K;++_)Be+=t.charAt(N[_]);return Be}function f(l){if(typeof l!="string")throw new TypeError("Expected String");if(l.length===0)return new Uint8Array;var m=0;if(l[m]!==" "){for(var x=0,L=0;l[m]===a;)x++,m++;for(var D=(l.length-m)*u+1>>>0,K=new Uint8Array(D);l[m];){var N=r[l.charCodeAt(m)];if(N===255)return;for(var P=0,k=D-1;(N!==0||P<L)&&k!==-1;k--,P++)N+=c*K[k]>>>0,K[k]=N%256>>>0,N=N/256>>>0;if(N!==0)throw new Error("Non-zero carry");L=P,m++}if(l[m]!==" "){for(var G=D-L;G!==D&&K[G]===0;)G++;for(var _=new Uint8Array(x+(D-G)),Be=x;G!==D;)_[Be++]=K[G++];return _}}}function h(l){var m=f(l);if(m)return m;throw new Error(`Non-${e} character`)}return{encode:d,decodeUnsafe:f,decode:h}}var Ea=xa,Ia=Ea,Hi=Ia;var Tn=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")}},Dn=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 qi(this,e)}},Un=class{decoders;constructor(e){this.decoders=e}or(e){return qi(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 qi(t,e){return new Un({...t.decoders??{[t.prefix]:t},...e.decoders??{[e.prefix]:e}})}var _n=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 Tn(e,r,n),this.decoder=new Dn(e,r,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};function _t({name:t,prefix:e,encode:r,decode:n}){return new _n(t,e,r,n)}function lt({name:t,prefix:e,alphabet:r}){let{encode:n,decode:o}=Hi(r,t);return _t({prefix:e,name:t,encode:n,decode:i=>Ae(o(i))})}function Sa(t,e,r,n){let o=t.length;for(;t[o-1]==="=";)--o;let i=new Uint8Array(o*r/8|0),s=0,c=0,a=0;for(let u=0;u<o;++u){let p=e[t[u]];if(p===void 0)throw new SyntaxError(`Non-${n} character`);c=c<<r|p,s+=r,s>=8&&(s-=8,i[a++]=255&c>>s)}if(s>=r||(255&c<<8-s)!==0)throw new SyntaxError("Unexpected end of data");return i}function va(t,e,r){let n=e[e.length-1]==="=",o=(1<<r)-1,i="",s=0,c=0;for(let a=0;a<t.length;++a)for(c=c<<8|t[a],s+=8;s>r;)s-=r,i+=e[o&c>>s];if(s!==0&&(i+=e[o&c<<r-s]),n)for(;(i.length*r&7)!==0;)i+="=";return i}function Aa(t){let e={};for(let r=0;r<t.length;++r)e[t[r]]=r;return e}function q({name:t,prefix:e,bitsPerChar:r,alphabet:n}){let o=Aa(n);return _t({prefix:e,name:t,encode(i){return va(i,n,r)},decode(i){return Sa(i,o,r,t)}})}var j=lt({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Ba=lt({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Rn={};fe(Rn,{base32:()=>ht,base32hex:()=>Ta,base32hexpad:()=>Ua,base32hexpadupper:()=>_a,base32hexupper:()=>Da,base32pad:()=>La,base32padupper:()=>Oa,base32upper:()=>Ca,base32z:()=>Pa});var ht=q({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Ca=q({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),La=q({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Oa=q({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Ta=q({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Da=q({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Ua=q({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),_a=q({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Pa=q({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Nn={};fe(Nn,{base36:()=>er,base36upper:()=>Ra});var er=lt({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Ra=lt({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Na=$i,Vi=128,Fa=127,ka=~Fa,Ka=Math.pow(2,31);function $i(t,e,r){e=e||[],r=r||0;for(var n=r;t>=Ka;)e[r++]=t&255|Vi,t/=128;for(;t&ka;)e[r++]=t&255|Vi,t>>>=7;return e[r]=t|0,$i.bytes=r-n+1,e}var Ma=Fn,Ha=128,zi=127;function Fn(t,n){var r=0,n=n||0,o=0,i=n,s,c=t.length;do{if(i>=c)throw Fn.bytes=0,new RangeError("Could not decode varint");s=t[i++],r+=o<28?(s&zi)<<o:(s&zi)*Math.pow(2,o),o+=7}while(s>=Ha);return Fn.bytes=i-n,r}var qa=Math.pow(2,7),Va=Math.pow(2,14),za=Math.pow(2,21),$a=Math.pow(2,28),ja=Math.pow(2,35),Ya=Math.pow(2,42),Ga=Math.pow(2,49),Wa=Math.pow(2,56),Xa=Math.pow(2,63),Za=function(t){return t<qa?1:t<Va?2:t<za?3:t<$a?4:t<ja?5:t<Ya?6:t<Ga?7:t<Wa?8:t<Xa?9:10},Qa={encode:Na,decode:Ma,encodingLength:Za},Ja=Qa,tr=Ja;function rr(t,e=0){return[tr.decode(t,e),tr.decode.bytes]}function Pt(t,e,r=0){return tr.encode(t,e,r),e}function Rt(t){return tr.encodingLength(t)}function Ft(t,e){let r=e.byteLength,n=Rt(t),o=n+Rt(r),i=new Uint8Array(o+r);return Pt(t,i,0),Pt(r,i,n),i.set(e,o),new Nt(t,r,e,i)}function nr(t){let e=Ae(t),[r,n]=rr(e),[o,i]=rr(e.subarray(n)),s=e.subarray(n+i);if(s.byteLength!==o)throw new Error("Incorrect length");return new Nt(r,o,s,e)}function ji(t,e){if(t===e)return!0;{let r=e;return t.code===r.code&&t.size===r.size&&r.bytes instanceof Uint8Array&&Fi(t.bytes,r.bytes)}}var Nt=class{code;size;digest;bytes;constructor(e,r,n,o){this.code=e,this.size=r,this.digest=Et(n),this.bytes=Et(o)}};function Yi(t,e){let{bytes:r,version:n}=t;return n===0?tu(r,kn(t),e??j.encoder):ru(r,kn(t),e??ht.encoder)}var Gi=new WeakMap;function kn(t){let e=Gi.get(t);if(e==null){let r=new Map;return Gi.set(t,r),r}return e}var re=class t{code;version;multihash;bytes;"/";constructor(e,r,n,o){this.code=r,this.version=e,this.multihash=n,this.bytes=Et(o),this["/"]=this.bytes}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!==or)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==nu)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=Ft(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&&ji(e.multihash,n.multihash)}toString(e){return Yi(this,e)}toJSON(){return{"/":Yi(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??Wi(n,o,i.bytes))}else if(r[ou]===!0){let{version:n,multihash:o,code:i}=r,s=nr(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!==or)throw new Error(`Version 0 CID must use dag-pb (code: ${or}) block encoding`);return new t(e,r,n,n.bytes)}case 1:{let o=Wi(e,r,n.bytes);return new t(e,r,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return t.create(0,or,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=Ae(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 Nt(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[d,f]=rr(e.subarray(r));return r+=f,d},o=n(),i=or;if(o===18?(o=0,r=0):i=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let s=r,c=n(),a=n(),u=r+a,p=u-s;return{version:o,codec:i,multihashCode:c,digestSize:a,multihashSize:p,size:u}}static parse(e,r){let[n,o]=eu(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 kn(i).set(n,e),i}};function eu(t,e){switch(t[0]){case"Q":{let r=e??j;return[j.prefix,r.decode(`${j.prefix}${t}`)]}case j.prefix:{let r=e??j;return[j.prefix,r.decode(t)]}case ht.prefix:{let r=e??ht;return[ht.prefix,r.decode(t)]}case er.prefix:{let r=e??er;return[er.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 tu(t,e,r){let{prefix:n}=r;if(n!==j.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 ru(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 or=112,nu=18;function Wi(t,e,r){let n=Rt(t),o=n+Rt(e),i=new Uint8Array(o+r.byteLength);return Pt(t,i,0),Pt(e,i,n),i.set(r,o),i}var ou=Symbol.for("@ipld/js-cid/CID");var Kn={};fe(Kn,{identity:()=>Te});var Xi=0,iu="identity",Zi=Ae;function su(t,e){if(e?.truncate!=null&&e.truncate!==t.byteLength){if(e.truncate<0||e.truncate>t.byteLength)throw new Error(`Invalid truncate option, must be less than or equal to ${t.byteLength}`);t=t.subarray(0,e.truncate)}return Ft(Xi,Zi(t))}var Te={code:Xi,name:iu,encode:Zi,digest:su};function he(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 cu(t){return t.buffer instanceof ArrayBuffer}function pt(t){return cu(t)?t:t.slice()}async function Qi(t,e,r,n){let o=await crypto.subtle.importKey("jwk",t,{name:"ECDSA",namedCurve:t.crv??"P-256"},!1,["verify"]);n?.signal?.throwIfAborted();let i=await crypto.subtle.verify({name:"ECDSA",hash:{name:"SHA-256"}},o,pt(e),pt(r.subarray()));return n?.signal?.throwIfAborted(),i}var Mn=pe("node:buffer");function ft(t){if(t.buffer instanceof ArrayBuffer)return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);let e=t.slice();return new Uint8Array(e.buffer,0,e.byteLength)}function Ve(t=0){return ft(Mn.Buffer.alloc(t))}function we(t=0){return ft(Mn.Buffer.allocUnsafe(t))}var Ji=pe("node:buffer");function De(t,e){return ft(Ji.Buffer.concat(t,e))}var ts=Symbol.for("@achingbrain/uint8arraylist");function es(t,e){if(e==null||e<0)throw new RangeError("index is out of bounds");let r=0;for(let n of t){let o=r+n.byteLength;if(e<o)return{buf:n,index:e-r};r=o}throw new RangeError("index is out of bounds")}function Ur(t){return!!t?.[ts]}var be=class t{bufs;length;[ts]=!0;constructor(...e){this.bufs=[],this.length=0,e.length>0&&this.appendAll(e)}*[Symbol.iterator](){yield*this.bufs}get byteLength(){return this.length}append(...e){this.appendAll(e)}appendAll(e){let r=0;for(let n of e)if(n instanceof Uint8Array)r+=n.byteLength,this.bufs.push(n);else if(Ur(n)){r+=n.byteLength;for(let o of n.bufs)this.bufs.push(o)}else throw new Error("Could not append value, must be an Uint8Array or a Uint8ArrayList");this.length+=r}prepend(...e){this.prependAll(e)}prependAll(e){let r=0;for(let n of e.reverse())if(n instanceof Uint8Array)r+=n.byteLength,this.bufs.unshift(n);else if(Ur(n))r+=n.byteLength,this.bufs.unshift(...n.bufs);else throw new Error("Could not prepend value, must be an Uint8Array or a Uint8ArrayList");this.length+=r}get(e){let r=es(this.bufs,e);return r.buf[r.index]}set(e,r){let n=es(this.bufs,e);n.buf[n.index]=r}write(e,r=0){if(e instanceof Uint8Array)for(let n=0;n<e.length;n++)this.set(r+n,e[n]);else if(Ur(e))for(let n=0;n<e.length;n++)this.set(r+n,e.get(n));else throw new Error("Could not write value, must be an Uint8Array or a Uint8ArrayList")}consume(e){if(e=Math.trunc(e),!(Number.isNaN(e)||e<=0)){if(e===this.byteLength){this.bufs=[],this.length=0;return}for(;this.bufs.length>0;)if(e>=this.bufs[0].byteLength)e-=this.bufs[0].byteLength,this.length-=this.bufs[0].byteLength,this.bufs.shift();else{this.bufs[0]=this.bufs[0].subarray(e),this.length-=e;break}}}slice(e,r){let{bufs:n,length:o}=this._subList(e,r);return De(n,o)}subarray(e,r){let{bufs:n,length:o}=this._subList(e,r);return n.length===1?n[0]:De(n,o)}sublist(e,r){let{bufs:n,length:o}=this._subList(e,r),i=new t;return i.length=o,i.bufs=n,i}_subList(e,r){if(e=e??0,r=r??this.length,e<0&&(e=this.length+e),r<0&&(r=this.length+r),e<0||r>this.length)throw new RangeError("index is out of bounds");if(e===r)return{bufs:[],length:0};if(e===0&&r===this.length)return{bufs:[...this.bufs],length:this.length};let n=[],o=0;for(let i=0;i<this.bufs.length;i++){let s=this.bufs[i],c=o,a=c+s.byteLength;if(o=a,e>=a)continue;let u=e>=c&&e<a,p=r>c&&r<=a;if(u&&p){if(e===c&&r===a){n.push(s);break}let d=e-c;n.push(s.subarray(d,d+(r-e)));break}if(u){if(e===0){n.push(s);continue}n.push(s.subarray(e-c));continue}if(p){if(r===a){n.push(s);break}n.push(s.subarray(0,r-c));break}n.push(s)}return{bufs:n,length:r-e}}indexOf(e,r=0){if(!Ur(e)&&!(e instanceof Uint8Array))throw new TypeError('The "value" argument must be a Uint8ArrayList or Uint8Array');let n=e instanceof Uint8Array?e:e.subarray();if(r=Number(r??0),isNaN(r)&&(r=0),r<0&&(r=this.length+r),r<0&&(r=0),e.length===0)return r>this.length?this.length:r;let o=n.byteLength;if(o===0)throw new TypeError("search must be at least 1 byte long");let i=256,s=new Int32Array(i);for(let d=0;d<i;d++)s[d]=-1;for(let d=0;d<o;d++)s[n[d]]=d;let c=s,a=this.byteLength-n.byteLength,u=n.byteLength-1,p;for(let d=r;d<=a;d+=p){p=0;for(let f=u;f>=0;f--){let h=this.get(d+f);if(n[f]!==h){p=Math.max(1,f-c[h]);break}}if(p===0)return d}return-1}getInt8(e){let r=this.subarray(e,e+1);return new DataView(r.buffer,r.byteOffset,r.byteLength).getInt8(0)}setInt8(e,r){let n=we(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setInt8(0,r),this.write(n,e)}getInt16(e,r){let n=this.subarray(e,e+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt16(0,r)}setInt16(e,r,n){let o=Ve(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt16(0,r,n),this.write(o,e)}getInt32(e,r){let n=this.subarray(e,e+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt32(0,r)}setInt32(e,r,n){let o=Ve(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt32(0,r,n),this.write(o,e)}getBigInt64(e,r){let n=this.subarray(e,e+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigInt64(0,r)}setBigInt64(e,r,n){let o=Ve(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigInt64(0,r,n),this.write(o,e)}getUint8(e){let r=this.subarray(e,e+1);return new DataView(r.buffer,r.byteOffset,r.byteLength).getUint8(0)}setUint8(e,r){let n=we(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setUint8(0,r),this.write(n,e)}getUint16(e,r){let n=this.subarray(e,e+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint16(0,r)}setUint16(e,r,n){let o=Ve(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint16(0,r,n),this.write(o,e)}getUint32(e,r){let n=this.subarray(e,e+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint32(0,r)}setUint32(e,r,n){let o=Ve(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint32(0,r,n),this.write(o,e)}getBigUint64(e,r){let n=this.subarray(e,e+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigUint64(0,r)}setBigUint64(e,r,n){let o=Ve(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigUint64(0,r,n),this.write(o,e)}getFloat32(e,r){let n=this.subarray(e,e+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat32(0,r)}setFloat32(e,r,n){let o=Ve(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat32(0,r,n),this.write(o,e)}getFloat64(e,r){let n=this.subarray(e,e+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat64(0,r)}setFloat64(e,r,n){let o=Ve(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat64(0,r,n),this.write(o,e)}equals(e){if(e==null||!(e instanceof t)||e.bufs.length!==this.bufs.length)return!1;for(let r=0;r<this.bufs.length;r++)if(!he(this.bufs[r],e.bufs[r]))return!1;return!0}static fromUint8Arrays(e,r){let n=new t;return n.bufs=e,r==null&&(r=e.reduce((o,i)=>o+i.byteLength,0)),n.length=r,n}};var cs=pe("node:buffer");var Hn={};fe(Hn,{base10:()=>au});var au=lt({prefix:"9",name:"base10",alphabet:"0123456789"});var qn={};fe(qn,{base16:()=>uu,base16upper:()=>du});var uu=q({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),du=q({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Vn={};fe(Vn,{base2:()=>lu});var lu=q({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var zn={};fe(zn,{base256emoji:()=>gu});var rs=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}"),hu=rs.reduce((t,e,r)=>(t[r]=e,t),[]),pu=rs.reduce((t,e,r)=>{let n=e.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${e}`);return t[n]=r,t},[]);function fu(t){return t.reduce((e,r)=>(e+=hu[r],e),"")}function mu(t){let e=[];for(let r of t){let n=r.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${r}`);let o=pu[n];if(o==null)throw new Error(`Non-base256emoji character: ${r}`);e.push(o)}return new Uint8Array(e)}var gu=_t({prefix:"\u{1F680}",name:"base256emoji",encode:fu,decode:mu});var jn={};fe(jn,{base64:()=>yu,base64pad:()=>wu,base64url:()=>$n,base64urlpad:()=>bu});var yu=q({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),wu=q({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),$n=q({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),bu=q({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Yn={};fe(Yn,{base8:()=>xu});var xu=q({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Gn={};fe(Gn,{identity:()=>Eu});var Eu=_t({prefix:"\0",name:"identity",encode:t=>Ki(t),decode:t=>ki(t)});var hp=new TextEncoder,pp=new TextDecoder;var Jn={};fe(Jn,{sha256:()=>Qn,sha512:()=>Au});var Zn=Zt(pe("node:crypto"),1);var vu=20;function Xn({name:t,code:e,encode:r,minDigestLength:n,maxDigestLength:o}){return new Wn(t,e,r,n,o)}var Wn=class{name;code;encode;minDigestLength;maxDigestLength;constructor(e,r,n,o,i){this.name=e,this.code=r,this.encode=n,this.minDigestLength=o??vu,this.maxDigestLength=i}digest(e,r){if(r?.truncate!=null){if(r.truncate<this.minDigestLength)throw new Error(`Invalid truncate option, must be greater than or equal to ${this.minDigestLength}`);if(this.maxDigestLength!=null&&r.truncate>this.maxDigestLength)throw new Error(`Invalid truncate option, must be less than or equal to ${this.maxDigestLength}`)}if(e instanceof Uint8Array){let n=this.encode(e);return n instanceof Uint8Array?ns(n,this.code,r?.truncate):n.then(o=>ns(o,this.code,r?.truncate))}else throw Error("Unknown type, must be binary type")}};function ns(t,e,r){if(r!=null&&r!==t.byteLength){if(r>t.byteLength)throw new Error(`Invalid truncate option, must be less than or equal to ${t.byteLength}`);t=t.subarray(0,r)}return Ft(e,t)}var Qn=Xn({name:"sha2-256",code:18,encode:t=>Ae(Zn.default.createHash("sha256").update(t).digest())}),Au=Xn({name:"sha2-512",code:19,encode:t=>Ae(Zn.default.createHash("sha512").update(t).digest())});var ir={...Gn,...Vn,...Yn,...Hn,...qn,...Rn,...Nn,...Pn,...jn,...zn},Bp={...Jn,...Kn};function ss(t,e,r,n){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:n}}}var is=ss("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),eo=ss("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=we(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}),Bu={utf8:is,"utf-8":is,hex:ir.base16,latin1:eo,ascii:eo,binary:eo,...ir},_r=Bu;function ae(t,e="utf8"){let r=_r[e];if(r==null)throw new Error(`Unsupported encoding "${e}"`);return e==="utf8"||e==="utf-8"?ft(cs.Buffer.from(t,"utf-8")):r.decoder.decode(`${r.prefix}${t}`)}var as=pe("node:buffer");function V(t,e="utf8"){let r=_r[e];if(r==null)throw new Error(`Unsupported encoding "${e}"`);return e==="utf8"||e==="utf-8"?as.Buffer.from(t.buffer,t.byteOffset,t.byteLength).toString("utf8"):r.encoder.encode(t).substring(1)}var Cu=parseInt("11111",2),to=parseInt("10000000",2),Lu=parseInt("01111111",2),us={0:sr,1:sr,2:Ou,3:Uu,4:_u,5:Du,6:Tu,16:sr,22:sr,48:sr};function ro(t,e={offset:0}){let r=t[e.offset]&Cu;if(e.offset++,us[r]!=null)return us[r](t,e);throw new Error("No decoder for tag "+r)}function cr(t,e){let r=0;if((t[e.offset]&to)===to){let n=t[e.offset]&Lu,o="0x";e.offset++;for(let i=0;i<n;i++,e.offset++)o+=t[e.offset].toString(16).padStart(2,"0");r=parseInt(o,16)}else r=t[e.offset],e.offset++;return r}function sr(t,e){cr(t,e);let r=[];for(;!(e.offset>=t.byteLength);){let n=ro(t,e);if(n===null)break;r.push(n)}return r}function Ou(t,e){let r=cr(t,e),n=e.offset,o=e.offset+r,i=[];for(let s=n;s<o;s++)s===n&&t[s]===0||i.push(t[s]);return e.offset+=r,Uint8Array.from(i)}function Tu(t,e){let r=cr(t,e),n=e.offset+r,o=t[e.offset];e.offset++;let i=0,s=0;o<40?(i=0,s=o):o<80?(i=1,s=o-40):(i=2,s=o-80);let c=`${i}.${s}`,a=[];for(;e.offset<n;){let u=t[e.offset];if(e.offset++,a.push(u&127),u<128){a.reverse();let p=0;for(let d=0;d<a.length;d++)p+=a[d]<<d*7;c+=`.${p}`,a=[]}}return c}function Du(t,e){return e.offset++,null}function Uu(t,e){let r=cr(t,e),n=t[e.offset];e.offset++;let o=t.subarray(e.offset,e.offset+r-1);if(e.offset+=r,n!==0)throw new Error("Unused bits in bit string is unimplemented");return o}function _u(t,e){let r=cr(t,e),n=t.subarray(e.offset,e.offset+r);return e.offset+=r,n}function Pu(t){let e=t.toString(16);e.length%2===1&&(e="0"+e);let r=new be;for(let n=0;n<e.length;n+=2)r.append(Uint8Array.from([parseInt(`${e[n]}${e[n+1]}`,16)]));return r}function no(t){if(t.byteLength<128)return Uint8Array.from([t.byteLength]);let e=Pu(t.byteLength);return new be(Uint8Array.from([e.byteLength|to]),e)}function ds(t){let e=new be,r=128;return(t.subarray()[0]&r)===r&&e.append(Uint8Array.from([0])),e.append(t),new be(Uint8Array.from([2]),no(e),e)}function ls(t){let e=Uint8Array.from([0]),r=new be(e,t);return new be(Uint8Array.from([3]),no(r),r)}function Pr(t,e=48){let r=new be;for(let n of t)r.append(n);return new be(Uint8Array.from([e]),no(r),r)}var Ru=Uint8Array.from([6,8,42,134,72,206,61,3,1,7]),Nu=Uint8Array.from([6,5,43,129,4,0,34]),Fu=Uint8Array.from([6,5,43,129,4,0,35]),ku={ext:!0,kty:"EC",crv:"P-256"},Ku={ext:!0,kty:"EC",crv:"P-384"},Mu={ext:!0,kty:"EC",crv:"P-521"},oo=32,io=48,so=66;function hs(t){let e=ro(t);return ps(e)}function ps(t){let e=t[1][1][0],r=1,n,o;if(e.byteLength===oo*2+1)return n=V(e.subarray(r,r+oo),"base64url"),o=V(e.subarray(r+oo),"base64url"),new Kt({...ku,key_ops:["verify"],x:n,y:o});if(e.byteLength===io*2+1)return n=V(e.subarray(r,r+io),"base64url"),o=V(e.subarray(r+io),"base64url"),new Kt({...Ku,key_ops:["verify"],x:n,y:o});if(e.byteLength===so*2+1)return n=V(e.subarray(r,r+so),"base64url"),o=V(e.subarray(r+so),"base64url"),new Kt({...Mu,key_ops:["verify"],x:n,y:o});throw new ve(`coordinates were wrong length, got ${e.byteLength}, expected 65, 97 or 133`)}function fs(t){return Pr([ds(Uint8Array.from([1])),Pr([Hu(t.crv)],160),Pr([ls(new be(Uint8Array.from([4]),ae(t.x??"","base64url"),ae(t.y??"","base64url")))],161)]).subarray()}function Hu(t){if(t==="P-256")return Ru;if(t==="P-384")return Nu;if(t==="P-521")return Fu;throw new ve(`Invalid curve ${t}`)}var Kt=class{type="ECDSA";jwk;_raw;constructor(e){this.jwk=e}get raw(){return this._raw==null&&(this._raw=fs(this.jwk)),this._raw}toMultihash(){return Te.digest(Mt(this))}toCID(){return re.createV1(114,this.toMultihash())}toString(){return j.encode(this.toMultihash().bytes).substring(1)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:he(this.raw,e.raw)}async verify(e,r,n){return Qi(this.jwk,r,e,n)}};var Gr=Zt(pe("crypto"),1);function co(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"&&"BYTES_PER_ELEMENT"in t&&t.BYTES_PER_ELEMENT===1}function mt(t,e=""){if(typeof t!="number"){let r=e&&`"${e}" `;throw new TypeError(`${r}expected number, got ${typeof t}`)}if(!Number.isSafeInteger(t)||t<0){let r=e&&`"${e}" `;throw new RangeError(`${r}expected integer >= 0, got ${t}`)}}function ze(t,e,r=""){let n=co(t),o=t?.length,i=e!==void 0;if(!n||i&&o!==e){let s=r&&`"${r}" `,c=i?` of length ${e}`:"",a=n?`length=${o}`:`type=${typeof t}`,u=s+"expected Uint8Array"+c+", got "+a;throw n?new RangeError(u):new TypeError(u)}return t}function Rr(t){if(typeof t!="function"||typeof t.create!="function")throw new TypeError("Hash must wrapped by utils.createHasher");if(mt(t.outputLen),mt(t.blockLen),t.outputLen<1)throw new Error('"outputLen" must be >= 1');if(t.blockLen<1)throw new Error('"blockLen" must be >= 1')}function Ht(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 Nr(t,e){ze(t,void 0,"digestInto() output");let r=e.outputLen;if(t.length<r)throw new RangeError('"digestInto() output" expected to be of length >='+r)}function It(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}function Fr(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function Ue(t,e){return t<<32-e|t>>>e}var gs=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",qu=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function kr(t){if(ze(t),gs)return t.toHex();let e="";for(let r=0;r<t.length;r++)e+=qu[t[r]];return e}var it={_0:48,_9:57,A:65,F:70,a:97,f:102};function ms(t){if(t>=it._0&&t<=it._9)return t-it._0;if(t>=it.A&&t<=it.F)return t-(it.A-10);if(t>=it.a&&t<=it.f)return t-(it.a-10)}function ao(t){if(typeof t!="string")throw new TypeError("hex string expected, got "+typeof t);if(gs)try{return Uint8Array.fromHex(t)}catch(o){throw o instanceof SyntaxError?new RangeError(o.message):o}let e=t.length,r=e/2;if(e%2)throw new RangeError("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=ms(t.charCodeAt(i)),c=ms(t.charCodeAt(i+1));if(s===void 0||c===void 0){let a=t[i]+t[i+1];throw new RangeError('hex string expected, got non-hex character "'+a+'" at index '+i)}n[o]=s*16+c}return n}function ys(...t){let e=0;for(let n=0;n<t.length;n++){let o=t[n];ze(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 ws(t,e={}){let r=(o,i)=>t(i).update(o).digest(),n=t(void 0);return r.outputLen=n.outputLen,r.blockLen=n.blockLen,r.canXOF=n.canXOF,r.create=o=>t(o),Object.assign(r,e),Object.freeze(r)}function bs(t=32){mt(t,"bytesLength");let e=typeof globalThis=="object"?globalThis.crypto:null;if(typeof e?.getRandomValues!="function")throw new Error("crypto.getRandomValues must be defined");if(t>65536)throw new RangeError(`"bytesLength" expected <= 65536, got ${t}`);return e.getRandomValues(new Uint8Array(t))}var xs=t=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,t])});function Es(t,e,r){return t&e^~t&r}function Is(t,e,r){return t&e^t&r^e&r}var Kr=class{blockLen;outputLen;canXOF=!1;padOffset;isLE;buffer;view;finished=!1;length=0;pos=0;destroyed=!1;constructor(e,r,n,o){this.blockLen=e,this.outputLen=r,this.padOffset=n,this.isLE=o,this.buffer=new Uint8Array(e),this.view=Fr(this.buffer)}update(e){Ht(this),ze(e);let{view:r,buffer:n,blockLen:o}=this,i=e.length;for(let s=0;s<i;){let c=Math.min(o-this.pos,i-s);if(c===o){let a=Fr(e);for(;o<=i-s;s+=o)this.process(a,s);continue}n.set(e.subarray(s,s+c),this.pos),this.pos+=c,s+=c,this.pos===o&&(this.process(r,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){Ht(this),Nr(e,this),this.finished=!0;let{buffer:r,view:n,blockLen:o,isLE:i}=this,{pos:s}=this;r[s++]=128,It(this.buffer.subarray(s)),this.padOffset>o-s&&(this.process(n,0),s=0);for(let d=s;d<o;d++)r[d]=0;n.setBigUint64(o-8,BigInt(this.length*8),i),this.process(n,0);let c=Fr(e),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen must be aligned to 32bit");let u=a/4,p=this.get();if(u>p.length)throw new Error("_sha2: outputLen bigger than state");for(let d=0;d<u;d++)c.setUint32(4*d,p[d],i)}digest(){let{buffer:e,outputLen:r}=this;this.digestInto(e);let n=e.slice(0,r);return this.destroy(),n}_cloneInto(e){e||=new this.constructor,e.set(...this.get());let{blockLen:r,buffer:n,length:o,finished:i,destroyed:s,pos:c}=this;return e.destroyed=s,e.finished=i,e.length=o,e.pos=c,o%r&&e.buffer.set(n),e}clone(){return this._cloneInto()}},st=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var Vu=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),gt=new Uint32Array(64),uo=class extends Kr{constructor(e){super(64,e,8,!1)}get(){let{A:e,B:r,C:n,D:o,E:i,F:s,G:c,H:a}=this;return[e,r,n,o,i,s,c,a]}set(e,r,n,o,i,s,c,a){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=c|0,this.H=a|0}process(e,r){for(let d=0;d<16;d++,r+=4)gt[d]=e.getUint32(r,!1);for(let d=16;d<64;d++){let f=gt[d-15],h=gt[d-2],l=Ue(f,7)^Ue(f,18)^f>>>3,m=Ue(h,17)^Ue(h,19)^h>>>10;gt[d]=m+gt[d-7]+l+gt[d-16]|0}let{A:n,B:o,C:i,D:s,E:c,F:a,G:u,H:p}=this;for(let d=0;d<64;d++){let f=Ue(c,6)^Ue(c,11)^Ue(c,25),h=p+f+Es(c,a,u)+Vu[d]+gt[d]|0,m=(Ue(n,2)^Ue(n,13)^Ue(n,22))+Is(n,o,i)|0;p=u,u=a,a=c,c=s+h|0,s=i,i=o,o=n,n=h+m|0}n=n+this.A|0,o=o+this.B|0,i=i+this.C|0,s=s+this.D|0,c=c+this.E|0,a=a+this.F|0,u=u+this.G|0,p=p+this.H|0,this.set(n,o,i,s,c,a,u,p)}roundClean(){It(gt)}destroy(){this.destroyed=!0,this.set(0,0,0,0,0,0,0,0),It(this.buffer)}},lo=class extends uo{A=st[0]|0;B=st[1]|0;C=st[2]|0;D=st[3]|0;E=st[4]|0;F=st[5]|0;G=st[6]|0;H=st[7]|0;constructor(){super(32)}};var Ss=ws(()=>new lo,xs(1));var X=(t,e,r)=>ze(t,e,r),po=mt,fo=kr,ct=(...t)=>ys(...t),qr=t=>ao(t),mo=co,go=t=>bs(t),Hr=BigInt(0),ho=BigInt(1);function St(t,e=""){if(typeof t!="boolean"){let r=e&&`"${e}" `;throw new TypeError(r+"expected boolean, got type="+typeof t)}return t}function Vr(t){if(typeof t=="bigint"){if(!Mr(t))throw new RangeError("positive bigint expected, got "+t)}else po(t);return t}function ar(t,e=""){if(typeof t!="number"){let r=e&&`"${e}" `;throw new TypeError(r+"expected number, got type="+typeof t)}if(!Number.isSafeInteger(t)){let r=e&&`"${e}" `;throw new RangeError(r+"expected safe integer, got "+t)}}function ur(t){let e=Vr(t).toString(16);return e.length&1?"0"+e:e}function vs(t){if(typeof t!="string")throw new TypeError("hex string expected, got "+typeof t);return t===""?Hr:BigInt("0x"+t)}function qt(t){return vs(kr(t))}function yo(t){return vs(kr(zu(ze(t)).reverse()))}function zr(t,e){if(mt(e),e===0)throw new RangeError("zero length");t=Vr(t);let r=t.toString(16);if(r.length>e*2)throw new RangeError("number too large");return ao(r.padStart(e*2,"0"))}function wo(t,e){return zr(t,e).reverse()}function zu(t){return Uint8Array.from(X(t))}var Mr=t=>typeof t=="bigint"&&Hr<=t;function $u(t,e,r){return Mr(t)&&Mr(e)&&Mr(r)&&e<=t&&t<r}function bo(t,e,r,n){if(!$u(e,r,n))throw new RangeError("expected valid "+t+": "+r+" <= n < "+n+", got "+e)}function Vt(t){if(t<Hr)throw new Error("expected non-negative bigint, got "+t);let e;for(e=0;t>Hr;t>>=ho,e+=1);return e}var dr=t=>(ho<<BigInt(t))-ho;function As(t,e,r){if(mt(t,"hashLen"),mt(e,"qByteLen"),typeof r!="function")throw new TypeError("hmacFn must be a function");let n=x=>new Uint8Array(x),o=Uint8Array.of(),i=Uint8Array.of(0),s=Uint8Array.of(1),c=1e3,a=n(t),u=n(t),p=0,d=()=>{a.fill(1),u.fill(0),p=0},f=(...x)=>r(u,ct(a,...x)),h=(x=o)=>{u=f(i,x),a=f(),x.length!==0&&(u=f(s,x),a=f())},l=()=>{if(p++>=c)throw new Error("drbg: tried max amount of iterations");let x=0,L=[];for(;x<e;){a=f();let D=a.slice();L.push(D),x+=a.length}return ct(...L)};return(x,L)=>{d(),h(x);let D;for(;(D=L(l()))===void 0;)h();return d(),D}}function vt(t,e={},r={}){if(Object.prototype.toString.call(t)!=="[object Object]")throw new TypeError("expected valid options object");function n(i,s,c){if(!c&&s!=="function"&&!Object.hasOwn(t,i))throw new TypeError(`param "${i}" is invalid: expected own property`);let a=t[i];if(c&&a===void 0)return;let u=typeof a;if(u!==s||a===null)throw new TypeError(`param "${i}" is invalid: expected ${s}, got ${u}`)}let o=(i,s)=>Object.entries(i).forEach(([c,a])=>n(c,a,s));o(e,!1),o(r,!0)}var ne=BigInt(0),Y=BigInt(1),At=BigInt(2),Os=BigInt(3),Ts=BigInt(4),Ds=BigInt(5),ju=BigInt(7),Us=BigInt(8),Yu=BigInt(9),_s=BigInt(16);function _e(t,e){if(e<=ne)throw new Error("mod: expected positive modulus, got "+e);let r=t%e;return r>=ne?r:e+r}function xe(t,e,r){if(e<ne)throw new Error("pow2: expected non-negative exponent, got "+e);let n=t;for(;e-- >ne;)n*=n,n%=r;return n}function Bs(t,e){if(t===ne)throw new Error("invert: expected non-zero number");if(e<=ne)throw new Error("invert: expected positive modulus, got "+e);let r=_e(t,e),n=e,o=ne,i=Y,s=Y,c=ne;for(;r!==ne;){let u=n/r,p=n-r*u,d=o-s*u,f=i-c*u;n=r,r=p,o=s,i=c,s=d,c=f}if(n!==Y)throw new Error("invert: does not exist");return _e(o,e)}function xo(t,e,r){let n=t;if(!n.eql(n.sqr(e),r))throw new Error("Cannot find square root")}function Ps(t,e){let r=t,n=(r.ORDER+Y)/Ts,o=r.pow(e,n);return xo(r,o,e),o}function Gu(t,e){let r=t,n=(r.ORDER-Ds)/Us,o=r.mul(e,At),i=r.pow(o,n),s=r.mul(e,i),c=r.mul(r.mul(s,At),i),a=r.mul(s,r.sub(c,r.ONE));return xo(r,a,e),a}function Wu(t){let e=zt(t),r=Rs(t),n=r(e,e.neg(e.ONE)),o=r(e,n),i=r(e,e.neg(n)),s=(t+ju)/_s;return((c,a)=>{let u=c,p=u.pow(a,s),d=u.mul(p,n),f=u.mul(p,o),h=u.mul(p,i),l=u.eql(u.sqr(d),a),m=u.eql(u.sqr(f),a);p=u.cmov(p,d,l),d=u.cmov(h,f,m);let x=u.eql(u.sqr(d),a),L=u.cmov(p,d,x);return xo(u,L,a),L})}function Rs(t){if(t<Os)throw new Error("sqrt is not defined for small field");let e=t-Y,r=0;for(;e%At===ne;)e/=At,r++;let n=At,o=zt(t);for(;Cs(o,n)===1;)if(n++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(r===1)return Ps;let i=o.pow(n,e),s=(e+Y)/At;return function(a,u){let p=a;if(p.is0(u))return u;if(Cs(p,u)!==1)throw new Error("Cannot find square root");let d=r,f=p.mul(p.ONE,i),h=p.pow(u,e),l=p.pow(u,s);for(;!p.eql(h,p.ONE);){if(p.is0(h))return p.ZERO;let m=1,x=p.sqr(h);for(;!p.eql(x,p.ONE);)if(m++,x=p.sqr(x),m===d)throw new Error("Cannot find square root");let L=Y<<BigInt(d-m-1),D=p.pow(f,L);d=m,f=p.sqr(D),h=p.mul(h,f),l=p.mul(l,D)}return l}}function Xu(t){return t%Ts===Os?Ps:t%Us===Ds?Gu:t%_s===Yu?Wu(t):Rs(t)}var Zu=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Eo(t){let e={ORDER:"bigint",BYTES:"number",BITS:"number"},r=Zu.reduce((n,o)=>(n[o]="function",n),e);if(vt(t,r),ar(t.BYTES,"BYTES"),ar(t.BITS,"BITS"),t.BYTES<1||t.BITS<1)throw new Error("invalid field: expected BYTES/BITS > 0");if(t.ORDER<=Y)throw new Error("invalid field: expected ORDER > 1, got "+t.ORDER);return t}function Qu(t,e,r){let n=t;if(r<ne)throw new Error("invalid exponent, negatives unsupported");if(r===ne)return n.ONE;if(r===Y)return e;let o=n.ONE,i=e;for(;r>ne;)r&Y&&(o=n.mul(o,i)),i=n.sqr(i),r>>=Y;return o}function jr(t,e,r=!1){let n=t,o=new Array(e.length).fill(r?n.ZERO:void 0),i=e.reduce((c,a,u)=>n.is0(a)?c:(o[u]=c,n.mul(c,a)),n.ONE),s=n.inv(i);return e.reduceRight((c,a,u)=>n.is0(a)?c:(o[u]=n.mul(c,o[u]),n.mul(c,a)),s),o}function Cs(t,e){let r=t,n=(r.ORDER-Y)/At,o=r.pow(e,n),i=r.eql(o,r.ONE),s=r.eql(o,r.ZERO),c=r.eql(o,r.neg(r.ONE));if(!i&&!s&&!c)throw new Error("invalid Legendre symbol result");return i?1:s?0:-1}function Ju(t,e){if(e!==void 0&&po(e),t<=ne)throw new Error("invalid n length: expected positive n, got "+t);if(e!==void 0&&e<1)throw new Error("invalid n length: expected positive bit length, got "+e);let r=Vt(t);if(e!==void 0&&e<r)throw new Error(`invalid n length: expected bit length (${r}) >= n.length (${e})`);let n=e!==void 0?e:r,o=Math.ceil(n/8);return{nBitLength:n,nByteLength:o}}var Ls=new WeakMap,$r=class{ORDER;BITS;BYTES;isLE;ZERO=ne;ONE=Y;_lengths;_mod;constructor(e,r={}){if(e<=Y)throw new Error("invalid field: expected ORDER > 1, got "+e);let n;this.isLE=!1,r!=null&&typeof r=="object"&&(typeof r.BITS=="number"&&(n=r.BITS),typeof r.sqrt=="function"&&Object.defineProperty(this,"sqrt",{value:r.sqrt,enumerable:!0}),typeof r.isLE=="boolean"&&(this.isLE=r.isLE),r.allowedLengths&&(this._lengths=Object.freeze(r.allowedLengths.slice())),typeof r.modFromBytes=="boolean"&&(this._mod=r.modFromBytes));let{nBitLength:o,nByteLength:i}=Ju(e,n);if(i>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");this.ORDER=e,this.BITS=o,this.BYTES=i,Object.freeze(this)}create(e){return _e(e,this.ORDER)}isValid(e){if(typeof e!="bigint")throw new TypeError("invalid field element: expected bigint, got "+typeof e);return ne<=e&&e<this.ORDER}is0(e){return e===ne}isValidNot0(e){return!this.is0(e)&&this.isValid(e)}isOdd(e){return(e&Y)===Y}neg(e){return _e(-e,this.ORDER)}eql(e,r){return e===r}sqr(e){return _e(e*e,this.ORDER)}add(e,r){return _e(e+r,this.ORDER)}sub(e,r){return _e(e-r,this.ORDER)}mul(e,r){return _e(e*r,this.ORDER)}pow(e,r){return Qu(this,e,r)}div(e,r){return _e(e*Bs(r,this.ORDER),this.ORDER)}sqrN(e){return e*e}addN(e,r){return e+r}subN(e,r){return e-r}mulN(e,r){return e*r}inv(e){return Bs(e,this.ORDER)}sqrt(e){let r=Ls.get(this);return r||Ls.set(this,r=Xu(this.ORDER)),r(this,e)}toBytes(e){return this.isLE?wo(e,this.BYTES):zr(e,this.BYTES)}fromBytes(e,r=!1){X(e);let{_lengths:n,BYTES:o,isLE:i,ORDER:s,_mod:c}=this;if(n){if(e.length<1||!n.includes(e.length)||e.length>o)throw new Error("Field.fromBytes: expected "+n+" bytes, got "+e.length);let u=new Uint8Array(o);u.set(e,i?0:u.length-e.length),e=u}if(e.length!==o)throw new Error("Field.fromBytes: expected "+o+" bytes, got "+e.length);let a=i?yo(e):qt(e);if(c&&(a=_e(a,s)),!r&&!this.isValid(a))throw new Error("invalid field element: outside of range 0..ORDER");return a}invertBatch(e){return jr(this,e)}cmov(e,r,n){return St(n,"condition"),n?r:e}};Object.freeze($r.prototype);function zt(t,e={}){return new $r(t,e)}function Ns(t){if(typeof t!="bigint")throw new Error("field order must be bigint");if(t<=Y)throw new Error("field order must be greater than 1");let e=Vt(t-Y);return Math.ceil(e/8)}function Io(t){let e=Ns(t);return e+Math.ceil(e/2)}function So(t,e,r=!1){X(t);let n=t.length,o=Ns(e),i=Math.max(Io(e),16);if(n<i||n>1024)throw new Error("expected "+i+"-1024 bytes of input, got "+n);let s=r?yo(t):qt(t),c=_e(s,e-Y)+Y;return r?wo(c,o):zr(c,o)}var $t=BigInt(0),Bt=BigInt(1);function lr(t,e){let r=e.negate();return t?r:e}function Co(t,e){let r=jr(t.Fp,e.map(n=>n.Z));return e.map((n,o)=>t.fromAffine(n.toAffine(r[o])))}function Ms(t,e){if(!Number.isSafeInteger(t)||t<=0||t>e)throw new Error("invalid window size, expected [1.."+e+"], got W="+t)}function vo(t,e){Ms(t,e);let r=Math.ceil(e/t)+1,n=2**(t-1),o=2**t,i=dr(t),s=BigInt(t);return{windows:r,windowSize:n,mask:i,maxNumber:o,shiftBy:s}}function Fs(t,e,r){let{windowSize:n,mask:o,maxNumber:i,shiftBy:s}=r,c=Number(t&o),a=t>>s;c>n&&(c-=i,a+=Bt);let u=e*n,p=u+Math.abs(c)-1,d=c===0,f=c<0,h=e%2!==0;return{nextN:a,offset:p,isZero:d,isNeg:f,isNegF:h,offsetF:u}}var Ao=new WeakMap,Hs=new WeakMap;function Bo(t){return Hs.get(t)||1}function ks(t){if(t!==$t)throw new Error("invalid wNAF")}var Yr=class{BASE;ZERO;Fn;bits;constructor(e,r){this.BASE=e.BASE,this.ZERO=e.ZERO,this.Fn=e.Fn,this.bits=r}_unsafeLadder(e,r,n=this.ZERO){let o=e;for(;r>$t;)r&Bt&&(n=n.add(o)),o=o.double(),r>>=Bt;return n}precomputeWindow(e,r){let{windows:n,windowSize:o}=vo(r,this.bits),i=[],s=e,c=s;for(let a=0;a<n;a++){c=s,i.push(c);for(let u=1;u<o;u++)c=c.add(s),i.push(c);s=c.double()}return i}wNAF(e,r,n){if(!this.Fn.isValid(n))throw new Error("invalid scalar");let o=this.ZERO,i=this.BASE,s=vo(e,this.bits);for(let c=0;c<s.windows;c++){let{nextN:a,offset:u,isZero:p,isNeg:d,isNegF:f,offsetF:h}=Fs(n,c,s);n=a,p?i=i.add(lr(f,r[h])):o=o.add(lr(d,r[u]))}return ks(n),{p:o,f:i}}wNAFUnsafe(e,r,n,o=this.ZERO){let i=vo(e,this.bits);for(let s=0;s<i.windows&&n!==$t;s++){let{nextN:c,offset:a,isZero:u,isNeg:p}=Fs(n,s,i);if(n=c,!u){let d=r[a];o=o.add(p?d.negate():d)}}return ks(n),o}getPrecomputes(e,r,n){let o=Ao.get(r);return o||(o=this.precomputeWindow(r,e),e!==1&&(typeof n=="function"&&(o=n(o)),Ao.set(r,o))),o}cached(e,r,n){let o=Bo(e);return this.wNAF(o,this.getPrecomputes(o,e,n),r)}unsafe(e,r,n,o){let i=Bo(e);return i===1?this._unsafeLadder(e,r,o):this.wNAFUnsafe(i,this.getPrecomputes(i,e,n),r,o)}createCache(e,r){Ms(r,this.bits),Hs.set(e,r),Ao.delete(e)}hasCache(e){return Bo(e)!==1}};function qs(t,e,r,n){let o=e,i=t.ZERO,s=t.ZERO;for(;r>$t||n>$t;)r&Bt&&(i=i.add(o)),n&Bt&&(s=s.add(o)),o=o.double(),r>>=Bt,n>>=Bt;return{p1:i,p2:s}}function Ks(t,e,r){if(e){if(e.ORDER!==t)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return Eo(e),e}else return zt(t,{isLE:r})}function Vs(t,e,r={},n){if(n===void 0&&(n=t==="edwards"),!e||typeof e!="object")throw new Error(`expected valid ${t} CURVE object`);for(let a of["p","n","h"]){let u=e[a];if(!(typeof u=="bigint"&&u>$t))throw new Error(`CURVE.${a} must be positive bigint`)}let o=Ks(e.p,r.Fp,n),i=Ks(e.n,r.Fn,n),c=["Gx","Gy","a",t==="weierstrass"?"b":"d"];for(let a of c)if(!o.isValid(e[a]))throw new Error(`CURVE.${a} must be valid field element of CURVE.Fp`);return e=Object.freeze(Object.assign({},e)),{CURVE:e,Fp:o,Fn:i}}function zs(t,e){return function(n){let o=t(n);return{secretKey:o,publicKey:e(o)}}}var I0=Gr.default.generateKeyPairSync,hr=32;var ed=64;function $s(t,e,r){if(t.byteLength!==hr)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!==ed)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=Gr.default.createPublicKey({format:"jwk",key:{crv:"Ed25519",x:V(t,"base64url"),kty:"OKP"}});return Gr.default.verify(null,r instanceof Uint8Array?r:r.subarray(),n,e)}function Ys(t){return t==null?!1:typeof t.then=="function"&&typeof t.catch=="function"&&typeof t.finally=="function"}var Wr=class{type="Ed25519";raw;constructor(e){this.raw=Lo(e,hr)}toMultihash(){return Te.digest(Mt(this))}toCID(){return re.createV1(114,this.toMultihash())}toString(){return j.encode(this.toMultihash().bytes).substring(1)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:he(this.raw,e.raw)}verify(e,r,n){n?.signal?.throwIfAborted();let o=$s(this.raw,r,e);return Ys(o)?o.then(i=>(n?.signal?.throwIfAborted(),i)):o}};function Gs(t){return t=Lo(t,hr),new Wr(t)}function Lo(t,e){if(t=Uint8Array.from(t??[]),t.length!==e)throw new ve(`Key must be a Uint8Array of length ${e}, got ${t.length}`);return t}var rd=Math.pow(2,7),nd=Math.pow(2,14),od=Math.pow(2,21),Oo=Math.pow(2,28),To=Math.pow(2,35),Do=Math.pow(2,42),Uo=Math.pow(2,49),H=128,ie=127;function $e(t){if(t<rd)return 1;if(t<nd)return 2;if(t<od)return 3;if(t<Oo)return 4;if(t<To)return 5;if(t<Do)return 6;if(t<Uo)return 7;if(Number.MAX_SAFE_INTEGER!=null&&t>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function pr(t,e,r=0){switch($e(t)){case 8:e[r++]=t&255|H,t/=128;case 7:e[r++]=t&255|H,t/=128;case 6:e[r++]=t&255|H,t/=128;case 5:e[r++]=t&255|H,t/=128;case 4:e[r++]=t&255|H,t>>>=7;case 3:e[r++]=t&255|H,t>>>=7;case 2:e[r++]=t&255|H,t>>>=7;case 1:{e[r++]=t&255,t>>>=7;break}default:throw new Error("unreachable")}return e}function _o(t,e){let r=t[e],n=0;if(n+=r&ie,r<H||(r=t[e+1],n+=(r&ie)<<7,r<H)||(r=t[e+2],n+=(r&ie)<<14,r<H)||(r=t[e+3],n+=(r&ie)<<21,r<H)||(r=t[e+4],n+=(r&ie)*Oo,r<H)||(r=t[e+5],n+=(r&ie)*To,r<H)||(r=t[e+6],n+=(r&ie)*Do,r<H)||(r=t[e+7],n+=(r&ie)*Uo,r<H))return n;throw new RangeError("Could not decode varint")}function id(t,e){let r=t.get(e),n=0;if(n+=r&ie,r<H||(r=t.get(e+1),n+=(r&ie)<<7,r<H)||(r=t.get(e+2),n+=(r&ie)<<14,r<H)||(r=t.get(e+3),n+=(r&ie)<<21,r<H)||(r=t.get(e+4),n+=(r&ie)*Oo,r<H)||(r=t.get(e+5),n+=(r&ie)*To,r<H)||(r=t.get(e+6),n+=(r&ie)*Do,r<H)||(r=t.get(e+7),n+=(r&ie)*Uo,r<H))return n;throw new RangeError("Could not decode varint")}function Po(t,e=0){return t instanceof Uint8Array?_o(t,e):id(t,e)}var Ro=new Float32Array([-0]),yt=new Uint8Array(Ro.buffer);function Ws(t,e,r){Ro[0]=t,e[r]=yt[0],e[r+1]=yt[1],e[r+2]=yt[2],e[r+3]=yt[3]}function Xs(t,e){return yt[0]=t[e],yt[1]=t[e+1],yt[2]=t[e+2],yt[3]=t[e+3],Ro[0]}var No=new Float64Array([-0]),se=new Uint8Array(No.buffer);function Zs(t,e,r){No[0]=t,e[r]=se[0],e[r+1]=se[1],e[r+2]=se[2],e[r+3]=se[3],e[r+4]=se[4],e[r+5]=se[5],e[r+6]=se[6],e[r+7]=se[7]}function Qs(t,e){return se[0]=t[e],se[1]=t[e+1],se[2]=t[e+2],se[3]=t[e+3],se[4]=t[e+4],se[5]=t[e+5],se[6]=t[e+6],se[7]=t[e+7],No[0]}var cd=BigInt(Number.MAX_SAFE_INTEGER),ad=BigInt(Number.MIN_SAFE_INTEGER),Ee=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 Ct;if(e<cd&&e>ad)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>Js&&(o=0n,++n>Js&&(n=0n))),new t(Number(o),Number(n))}static fromNumber(e){if(e===0)return Ct;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):Ct}},Ct=new Ee(0,0);Ct.toBigInt=function(){return 0n};Ct.zzEncode=Ct.zzDecode=function(){return this};Ct.length=function(){return 1};var Js=4294967296n;function ec(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 tc(t,e,r){if(r-e<1)return"";let o,i=[],s=0,c;for(;e<r;)c=t[e++],c<128?i[s++]=c:c>191&&c<224?i[s++]=(c&31)<<6|t[e++]&63:c>239&&c<365?(c=((c&7)<<18|(t[e++]&63)<<12|(t[e++]&63)<<6|t[e++]&63)-65536,i[s++]=55296+(c>>10),i[s++]=56320+(c&1023)):i[s++]=(c&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 Fo(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 Pe(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 ko=class{buf;pos;len;_slice=Uint8Array.prototype.subarray;constructor(e){this.buf=pt(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,Pe(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 Pe(this,4);return Xr(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw Pe(this,4);return Xr(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw Pe(this,4);let e=Xs(this.buf,this.pos);return this.pos+=4,e}double(){if(this.pos+8>this.len)throw Pe(this,4);let e=Qs(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 Pe(this,e);return this.pos+=e,r===n?new Uint8Array(0):this.buf.subarray(r,n)}string(){let e=this.bytes();return tc(e,0,e.length)}skip(e){if(typeof e=="number"){if(this.pos+e>this.len)throw Pe(this,e);this.pos+=e}else do if(this.pos>=this.len)throw Pe(this);while((this.buf[this.pos++]&128)!==0);return this}skipType(e){switch(e){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(e=this.uint32()&7)!==4;)this.skipType(e);break;case 5:this.skip(4);break;default:throw Error(`invalid wire type ${e} at offset ${this.pos}`)}return this}readLongVarint(){let e=new Ee(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 Pe(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 Pe(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 Pe(this,8);let e=Xr(this.buf,this.pos+=4),r=Xr(this.buf,this.pos+=4);return new Ee(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=_o(this.buf,this.pos);return this.pos+=$e(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 fr(t){return new ko(t instanceof Uint8Array?t:t.subarray())}function Zr(t,e,r){let n=fr(t);return e.decode(n,void 0,r)}function Ko(t){let e=t??8192,r=e>>>1,n,o=e;return function(s){if(s<1||s>r)return we(s);o+s>e&&(n=we(e),o=0);let c=n.subarray(o,o+=s);return(o&7)!==0&&(o=(o|7)+1),c}}var Lt=class{fn;len;next;val;constructor(e,r,n){this.fn=e,this.len=r,this.next=void 0,this.val=n}};function Mo(){}var qo=class{head;tail;len;next;constructor(e){this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}},ud=Ko();function dd(t){return globalThis.Buffer!=null?we(t):ud(t)}var gr=class{len;head;tail;states;constructor(){this.len=0,this.head=new Lt(Mo,0,0),this.tail=this.head,this.states=null}_push(e,r,n){return this.tail=this.tail.next=new Lt(e,r,n),this.len+=r,this}uint32(e){return this.len+=(this.tail=this.tail.next=new Vo((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(Qr,10,Ee.fromNumber(e)):this.uint32(e)}sint32(e){return this.uint32((e<<1^e>>31)>>>0)}uint64(e){let r=Ee.fromBigInt(e);return this._push(Qr,r.length(),r)}uint64Number(e){return this._push(pr,$e(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=Ee.fromBigInt(e).zzEncode();return this._push(Qr,r.length(),r)}sint64Number(e){let r=Ee.fromNumber(e).zzEncode();return this._push(Qr,r.length(),r)}sint64String(e){return this.sint64(BigInt(e))}bool(e){return this._push(Ho,1,e?1:0)}fixed32(e){return this._push(mr,4,e>>>0)}sfixed32(e){return this.fixed32(e)}fixed64(e){let r=Ee.fromBigInt(e);return this._push(mr,4,r.lo)._push(mr,4,r.hi)}fixed64Number(e){let r=Ee.fromNumber(e);return this._push(mr,4,r.lo)._push(mr,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(Ws,4,e)}double(e){return this._push(Zs,8,e)}bytes(e){let r=e.length>>>0;return r===0?this._push(Ho,1,0):this.uint32(r)._push(hd,r,e)}string(e){let r=ec(e);return r!==0?this.uint32(r)._push(Fo,r,e):this._push(Ho,1,0)}fork(){return this.states=new qo(this),this.head=this.tail=new Lt(Mo,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 Lt(Mo,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=dd(this.len),n=0;for(;e!=null;)e.fn(e.val,r,n),n+=e.len,e=e.next;return r}};function Ho(t,e,r){e[r]=t&255}function ld(t,e,r){for(;t>127;)e[r++]=t&127|128,t>>>=7;e[r]=t}var Vo=class extends Lt{next;constructor(e,r){super(ld,e,r),this.next=void 0}};function Qr(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 mr(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 hd(t,e,r){e.set(t,r)}globalThis.Buffer!=null&&(gr.prototype.bytes=function(t){let e=t.length>>>0;return this.uint32(e),e>0&&this._push(pd,e,t),this},gr.prototype.string=function(t){let e=globalThis.Buffer.byteLength(t);return this.uint32(e),e>0&&this._push(fd,e,t),this});function pd(t,e,r){e.set(t,r)}function fd(t,e,r){t.length<40?Fo(t,e,r):e.utf8Write!=null?e.utf8Write(t,r):e.set(ae(t),r)}function zo(){return new gr}function Jr(t,e){let r=zo();return e.encode(t,r,{lengthDelimited:!1}),r.finish()}function*en(t,e,r){let n=fr(t);yield*e.stream(n,void 0,"$",r)}var tn={VARINT:0,BIT64:1,LENGTH_DELIMITED:2,START_GROUP:3,END_GROUP:4,BIT32:5};function rn(t,e,r,n,o){return{name:t,type:e,encode:r,decode:n,stream:o}}function $o(t){function e(i){if(t[i.toString()]==null)throw new Error("Invalid enum value");return t[i]}let r=function(s,c){let a=e(s);c.int32(a)},n=function(s){let c=s.int32();return e(c)},o=function*(s){let c=s.int32();yield e(c)};return rn("enum",tn.VARINT,r,n,o)}function nn(t,e,r){return rn("message",tn.LENGTH_DELIMITED,t,e,r)}var ue;(function(t){t.RSA="RSA",t.Ed25519="Ed25519",t.secp256k1="secp256k1",t.ECDSA="ECDSA"})(ue||(ue={}));var jo;(function(t){t[t.RSA=0]="RSA",t[t.Ed25519=1]="Ed25519",t[t.secp256k1=2]="secp256k1",t[t.ECDSA=3]="ECDSA"})(jo||(jo={}));(function(t){t.codec=()=>$o(jo)})(ue||(ue={}));var yr;(function(t){let e;t.codec=()=>(e==null&&(e=nn((i,s,c={})=>{c.lengthDelimited!==!1&&s.fork(),i.Type!=null&&(s.uint32(8),ue.codec().encode(i.Type,s)),i.Data!=null&&(s.uint32(18),s.bytes(i.Data)),c.lengthDelimited!==!1&&s.ldelim()},(i,s,c={})=>{let a={},u=s==null?i.len:i.pos+s;for(;i.pos<u;){let p=i.uint32();switch(p>>>3){case 1:{a.Type=ue.codec().decode(i);break}case 2:{a.Data=i.bytes();break}default:{i.skipType(p&7);break}}}return a},function*(i,s,c,a={}){let u=s==null?i.len:i.pos+s;for(;i.pos<u;){let p=i.uint32();switch(p>>>3){case 1:{yield{field:`${c}.Type`,value:ue.codec().decode(i)};break}case 2:{yield{field:`${c}.Data`,value:i.bytes()};break}default:{i.skipType(p&7);break}}}})),e);function r(i){return Jr(i,t.codec())}t.encode=r;function n(i,s){return Zr(i,t.codec(),s)}t.decode=n;function o(i,s){return en(i,t.codec(),s)}t.stream=o})(yr||(yr={}));var Yo;(function(t){let e;t.codec=()=>(e==null&&(e=nn((i,s,c={})=>{c.lengthDelimited!==!1&&s.fork(),i.Type!=null&&(s.uint32(8),ue.codec().encode(i.Type,s)),i.Data!=null&&(s.uint32(18),s.bytes(i.Data)),c.lengthDelimited!==!1&&s.ldelim()},(i,s,c={})=>{let a={},u=s==null?i.len:i.pos+s;for(;i.pos<u;){let p=i.uint32();switch(p>>>3){case 1:{a.Type=ue.codec().decode(i);break}case 2:{a.Data=i.bytes();break}default:{i.skipType(p&7);break}}}return a},function*(i,s,c,a={}){let u=s==null?i.len:i.pos+s;for(;i.pos<u;){let p=i.uint32();switch(p>>>3){case 1:{yield{field:`${c}.Type`,value:ue.codec().decode(i)};break}case 2:{yield{field:`${c}.Data`,value:i.bytes()};break}default:{i.skipType(p&7);break}}}})),e);function r(i){return Jr(i,t.codec())}t.encode=r;function n(i,s){return Zr(i,t.codec(),s)}t.decode=n;function o(i,s){return en(i,t.codec(),s)}t.stream=o})(Yo||(Yo={}));var lc=Zt(pe("node:crypto"),1);var on=class{oHash;iHash;blockLen;outputLen;canXOF=!1;finished=!1;destroyed=!1;constructor(e,r){if(Rr(e),ze(r,void 0,"key"),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 n=this.blockLen,o=new Uint8Array(n);o.set(r.length>n?e.create().update(r).digest():r);for(let i=0;i<o.length;i++)o[i]^=54;this.iHash.update(o),this.oHash=e.create();for(let i=0;i<o.length;i++)o[i]^=106;this.oHash.update(o),It(o)}update(e){return Ht(this),this.iHash.update(e),this}digestInto(e){Ht(this),Nr(e,this),this.finished=!0;let r=e.subarray(0,this.outputLen);this.iHash.digestInto(r),this.oHash.update(r),this.oHash.digestInto(r),this.destroy()}digest(){let e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||=Object.create(Object.getPrototypeOf(this),{});let{oHash:r,iHash:n,finished:o,destroyed:i,blockLen:s,outputLen:c}=this;return e=e,e.finished=o,e.destroyed=i,e.blockLen=s,e.outputLen=c,e.oHash=r._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},nc=(()=>{let t=((e,r,n)=>new on(e,r).update(n).digest());return t.create=(e,r)=>new on(e,r),t})();var oc=(t,e)=>(t+(t>=0?e:-e)/ic)/e;function gd(t,e,r){bo("scalar",t,je,r);let[[n,o],[i,s]]=e,c=oc(s*t,r),a=oc(-o*t,r),u=t-c*n-a*i,p=-c*o-a*s,d=u<je,f=p<je;d&&(u=-u),f&&(p=-p);let h=dr(Math.ceil(Vt(r)/2))+wt;if(u<je||u>=h||p<je||p>=h)throw new Error("splitScalar (endomorphism): failed for k");return{k1neg:d,k1:u,k2neg:f,k2:p}}function Wo(t){if(!["compact","recovered","der"].includes(t))throw new Error('Signature format must be "compact", "recovered", or "der"');return t}function Go(t,e){vt(t);let r={};for(let n of Object.keys(e))r[n]=t[n]===void 0?e[n]:t[n];return St(r.lowS,"lowS"),St(r.prehash,"prehash"),r.format!==void 0&&Wo(r.format),r}var Xo=class extends Error{constructor(e=""){super(e)}},Re={Err:Xo,_tlv:{encode:(t,e)=>{let{Err:r}=Re;if(ar(t,"tag"),t<0||t>255)throw new r("tlv.encode: wrong tag");if(typeof e!="string")throw new TypeError('"data" expected string, got type='+typeof e);if(e.length&1)throw new r("tlv.encode: unpadded data");let n=e.length/2,o=ur(n);if(o.length/2&128)throw new r("tlv.encode: long form length too big");let i=n>127?ur(o.length/2|128):"";return ur(t)+i+o+e},decode(t,e){let{Err:r}=Re;e=X(e,void 0,"DER data");let n=0;if(t<0||t>255)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 a=o&127;if(!a)throw new r("tlv.decode(long): indefinite length not supported");if(a>4)throw new r("tlv.decode(long): byte length is too big");let u=e.subarray(n,n+a);if(u.length!==a)throw new r("tlv.decode: length bytes not complete");if(u[0]===0)throw new r("tlv.decode(long): zero leftmost byte");for(let p of u)s=s<<8|p;if(n+=a,s<128)throw new r("tlv.decode(long): not minimal encoding")}let c=e.subarray(n,n+s);if(c.length!==s)throw new r("tlv.decode: wrong value length");return{v:c,l:e.subarray(n+s)}}},_int:{encode(t){let{Err:e}=Re;if(Vr(t),t<je)throw new e("integer: negative integers are not allowed");let r=ur(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}=Re;if(t.length<1)throw new e("invalid signature integer: empty");if(t[0]&128)throw new e("invalid signature integer: negative");if(t.length>1&&t[0]===0&&!(t[1]&128))throw new e("invalid signature integer: unnecessary leading zero");return qt(t)}},toSig(t){let{Err:e,_int:r,_tlv:n}=Re,o=X(t,void 0,"signature"),{v:i,l:s}=n.decode(48,o);if(s.length)throw new e("invalid signature: left bytes after parsing");let{v:c,l:a}=n.decode(2,i),{v:u,l:p}=n.decode(2,a);if(p.length)throw new e("invalid signature: left bytes after parsing");return{r:r.decode(c),s:r.decode(u)}},hexFromSig(t){let{_tlv:e,_int:r}=Re,n=e.encode(2,r.encode(t.r)),o=e.encode(2,r.encode(t.s)),i=n+o;return e.encode(48,i)}};Object.freeze(Re._tlv);Object.freeze(Re._int);Object.freeze(Re);var je=BigInt(0),wt=BigInt(1),ic=BigInt(2),sn=BigInt(3),yd=BigInt(4);function sc(t,e={}){let r=Vs("weierstrass",t,e),n=r.Fp,o=r.Fn,i=r.CURVE,{h:s,n:c}=i;vt(e,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object"});let{endo:a,allowInfinityPoint:u}=e;if(a&&(!n.is0(i.a)||typeof a.beta!="bigint"||!Array.isArray(a.basises)))throw new Error('invalid endo: expected "beta": bigint and "basises": array');let p=ac(n,o);function d(){if(!n.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}function f(z,w,B){if(u&&w.is0())return Uint8Array.of(0);let{x:O,y:b}=w.toAffine(),g=n.toBytes(O);if(St(B,"isCompressed"),B){d();let E=!n.isOdd(b);return ct(cc(E),g)}else return ct(Uint8Array.of(4),g,n.toBytes(b))}function h(z){X(z,void 0,"Point");let{publicKey:w,publicKeyUncompressed:B}=p,O=z.length,b=z[0],g=z.subarray(1);if(u&&O===1&&b===0)return{x:n.ZERO,y:n.ZERO};if(O===w&&(b===2||b===3)){let E=n.fromBytes(g);if(!n.isValid(E))throw new Error("bad point: is not on curve, wrong x");let S=x(E),I;try{I=n.sqrt(S)}catch(M){let F=M instanceof Error?": "+M.message:"";throw new Error("bad point: is not on curve, sqrt error"+F)}d();let C=n.isOdd(I);return(b&1)===1!==C&&(I=n.neg(I)),{x:E,y:I}}else if(O===B&&b===4){let E=n.BYTES,S=n.fromBytes(g.subarray(0,E)),I=n.fromBytes(g.subarray(E,E*2));if(!L(S,I))throw new Error("bad point: is not on curve");return{x:S,y:I}}else throw new Error(`bad point: got length ${O}, expected compressed=${w} or uncompressed=${B}`)}let l=e.toBytes===void 0?f:e.toBytes,m=e.fromBytes===void 0?h:e.fromBytes;function x(z){let w=n.sqr(z),B=n.mul(w,z);return n.add(n.add(B,n.mul(z,i.a)),i.b)}function L(z,w){let B=n.sqr(w),O=x(z);return n.eql(B,O)}if(!L(i.Gx,i.Gy))throw new Error("bad curve params: generator point");let D=n.mul(n.pow(i.a,sn),yd),K=n.mul(n.sqr(i.b),BigInt(27));if(n.is0(n.add(D,K)))throw new Error("bad curve params: a or b");function N(z,w,B=!1){if(!n.isValid(w)||B&&n.is0(w))throw new Error(`bad point coordinate ${z}`);return w}function P(z){if(!(z instanceof _))throw new Error("Weierstrass Point expected")}function k(z){if(!a||!a.basises)throw new Error("no endo");return gd(z,a.basises,o.ORDER)}function G(z,w,B,O,b){return B=new _(n.mul(B.X,z),B.Y,B.Z),w=lr(O,w),B=lr(b,B),w.add(B)}class _{static BASE=new _(i.Gx,i.Gy,n.ONE);static ZERO=new _(n.ZERO,n.ONE,n.ZERO);static Fp=n;static Fn=o;X;Y;Z;constructor(w,B,O){this.X=N("x",w),this.Y=N("y",B,!0),this.Z=N("z",O),Object.freeze(this)}static CURVE(){return i}static fromAffine(w){let{x:B,y:O}=w||{};if(!w||!n.isValid(B)||!n.isValid(O))throw new Error("invalid affine point");if(w instanceof _)throw new Error("projective point not allowed");return n.is0(B)&&n.is0(O)?_.ZERO:new _(B,O,n.ONE)}static fromBytes(w){let B=_.fromAffine(m(X(w,void 0,"point")));return B.assertValidity(),B}static fromHex(w){return _.fromBytes(qr(w))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(w=8,B=!0){return Ge.createCache(this,w),B||this.multiply(sn),this}assertValidity(){let w=this;if(w.is0()){if(e.allowInfinityPoint&&n.is0(w.X)&&n.eql(w.Y,n.ONE)&&n.is0(w.Z))return;throw new Error("bad point: ZERO")}let{x:B,y:O}=w.toAffine();if(!n.isValid(B)||!n.isValid(O))throw new Error("bad point: x or y not field elements");if(!L(B,O))throw new Error("bad point: equation left != right");if(!w.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){let{y:w}=this.toAffine();if(!n.isOdd)throw new Error("Field doesn't support isOdd");return!n.isOdd(w)}equals(w){P(w);let{X:B,Y:O,Z:b}=this,{X:g,Y:E,Z:S}=w,I=n.eql(n.mul(B,S),n.mul(g,b)),C=n.eql(n.mul(O,S),n.mul(E,b));return I&&C}negate(){return new _(this.X,n.neg(this.Y),this.Z)}double(){let{a:w,b:B}=i,O=n.mul(B,sn),{X:b,Y:g,Z:E}=this,S=n.ZERO,I=n.ZERO,C=n.ZERO,T=n.mul(b,b),M=n.mul(g,g),F=n.mul(E,E),R=n.mul(b,g);return R=n.add(R,R),C=n.mul(b,E),C=n.add(C,C),S=n.mul(w,C),I=n.mul(O,F),I=n.add(S,I),S=n.sub(M,I),I=n.add(M,I),I=n.mul(S,I),S=n.mul(R,S),C=n.mul(O,C),F=n.mul(w,F),R=n.sub(T,F),R=n.mul(w,R),R=n.add(R,C),C=n.add(T,T),T=n.add(C,T),T=n.add(T,F),T=n.mul(T,R),I=n.add(I,T),F=n.mul(g,E),F=n.add(F,F),T=n.mul(F,R),S=n.sub(S,T),C=n.mul(F,M),C=n.add(C,C),C=n.add(C,C),new _(S,I,C)}add(w){P(w);let{X:B,Y:O,Z:b}=this,{X:g,Y:E,Z:S}=w,I=n.ZERO,C=n.ZERO,T=n.ZERO,M=i.a,F=n.mul(i.b,sn),R=n.mul(B,g),Q=n.mul(O,E),J=n.mul(b,S),ee=n.add(B,O),$=n.add(g,E);ee=n.mul(ee,$),$=n.add(R,Q),ee=n.sub(ee,$),$=n.add(B,b);let de=n.add(g,S);return $=n.mul($,de),de=n.add(R,J),$=n.sub($,de),de=n.add(O,b),I=n.add(E,S),de=n.mul(de,I),I=n.add(Q,J),de=n.sub(de,I),T=n.mul(M,$),I=n.mul(F,J),T=n.add(I,T),I=n.sub(Q,T),T=n.add(Q,T),C=n.mul(I,T),Q=n.add(R,R),Q=n.add(Q,R),J=n.mul(M,J),$=n.mul(F,$),Q=n.add(Q,J),J=n.sub(R,J),J=n.mul(M,J),$=n.add($,J),R=n.mul(Q,$),C=n.add(C,R),R=n.mul(de,$),I=n.mul(ee,I),I=n.sub(I,R),R=n.mul(ee,Q),T=n.mul(de,T),T=n.add(T,R),new _(I,C,T)}subtract(w){return P(w),this.add(w.negate())}is0(){return this.equals(_.ZERO)}multiply(w){let{endo:B}=e;if(!o.isValidNot0(w))throw new RangeError("invalid scalar: out of range");let O,b,g=E=>Ge.cached(this,E,S=>Co(_,S));if(B){let{k1neg:E,k1:S,k2neg:I,k2:C}=k(w),{p:T,f:M}=g(S),{p:F,f:R}=g(C);b=M.add(R),O=G(B.beta,T,F,E,I)}else{let{p:E,f:S}=g(w);O=E,b=S}return Co(_,[O,b])[0]}multiplyUnsafe(w){let{endo:B}=e,O=this,b=w;if(!o.isValid(b))throw new RangeError("invalid scalar: out of range");if(b===je||O.is0())return _.ZERO;if(b===wt)return O;if(Ge.hasCache(this))return this.multiply(b);if(B){let{k1neg:g,k1:E,k2neg:S,k2:I}=k(b),{p1:C,p2:T}=qs(_,O,E,I);return G(B.beta,C,T,g,S)}else return Ge.unsafe(O,b)}toAffine(w){let B=this,O=w,{X:b,Y:g,Z:E}=B;if(n.eql(E,n.ONE))return{x:b,y:g};let S=B.is0();O==null&&(O=S?n.ONE:n.inv(E));let I=n.mul(b,O),C=n.mul(g,O),T=n.mul(E,O);if(S)return{x:n.ZERO,y:n.ZERO};if(!n.eql(T,n.ONE))throw new Error("invZ was invalid");return{x:I,y:C}}isTorsionFree(){let{isTorsionFree:w}=e;return s===wt?!0:w?w(_,this):Ge.unsafe(this,c).is0()}clearCofactor(){let{clearCofactor:w}=e;return s===wt?this:w?w(_,this):this.multiplyUnsafe(s)}isSmallOrder(){return s===wt?this.is0():this.clearCofactor().is0()}toBytes(w=!0){return St(w,"isCompressed"),this.assertValidity(),l(_,this,w)}toHex(w=!0){return fo(this.toBytes(w))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let Be=o.BITS,Ge=new Yr(_,e.endo?Math.ceil(Be/2):Be);return Be>=8&&_.BASE.precompute(8),Object.freeze(_.prototype),Object.freeze(_),_}function cc(t){return Uint8Array.of(t?2:3)}function ac(t,e){return{secretKey:e.BYTES,publicKey:1+t.BYTES,publicKeyUncompressed:1+2*t.BYTES,publicKeyHasPrefix:!0,signature:2*e.BYTES}}function wd(t,e={}){let{Fn:r}=t,n=e.randomBytes===void 0?go:e.randomBytes,o=Object.assign(ac(t.Fp,r),{seed:Math.max(Io(r.ORDER),16)});function i(h){try{let l=r.fromBytes(h);return r.isValidNot0(l)}catch{return!1}}function s(h,l){let{publicKey:m,publicKeyUncompressed:x}=o;try{let L=h.length;return l===!0&&L!==m||l===!1&&L!==x?!1:!!t.fromBytes(h)}catch{return!1}}function c(h){return h=h===void 0?n(o.seed):h,So(X(h,o.seed,"seed"),r.ORDER)}function a(h,l=!0){return t.BASE.multiply(r.fromBytes(h)).toBytes(l)}function u(h){let{secretKey:l,publicKey:m,publicKeyUncompressed:x}=o,L=r._lengths;if(!mo(h))return;let D=X(h,void 0,"key").length,K=D===m||D===x,N=D===l||!!L?.includes(D);if(!(K&&N))return K}function p(h,l,m=!0){if(u(h)===!0)throw new Error("first arg must be private key");if(u(l)===!1)throw new Error("second arg must be public key");let x=r.fromBytes(h);return t.fromBytes(l).multiply(x).toBytes(m)}let d={isValidSecretKey:i,isValidPublicKey:s,randomSecretKey:c},f=zs(c,a);return Object.freeze(d),Object.freeze(o),Object.freeze({getPublicKey:a,getSharedSecret:p,keygen:f,Point:t,utils:d,lengths:o})}function uc(t,e,r={}){let n=e;Rr(n),vt(r,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"}),r=Object.assign({},r);let o=r.randomBytes===void 0?go:r.randomBytes,i=r.hmac===void 0?(b,g)=>nc(n,b,g):r.hmac,{Fp:s,Fn:c}=t,{ORDER:a,BITS:u}=c,{keygen:p,getPublicKey:d,getSharedSecret:f,utils:h,lengths:l}=wd(t,r),m={prehash:!0,lowS:typeof r.lowS=="boolean"?r.lowS:!0,format:"compact",extraEntropy:!1},x=a*ic+wt<s.ORDER;function L(b){let g=a>>wt;return b>g}function D(b,g){if(!c.isValidNot0(g))throw new Error(`invalid signature ${b}: out of range 1..Point.Fn.ORDER`);return g}function K(){if(x)throw new Error('"recovered" sig type is not supported for cofactor >2 curves')}function N(b,g){Wo(g);let E=l.signature,S=g==="compact"?E:g==="recovered"?E+1:void 0;return X(b,S)}class P{r;s;recovery;constructor(g,E,S){if(this.r=D("r",g),this.s=D("s",E),S!=null){if(K(),![0,1,2,3].includes(S))throw new Error("invalid recovery id");this.recovery=S}Object.freeze(this)}static fromBytes(g,E=m.format){N(g,E);let S;if(E==="der"){let{r:M,s:F}=Re.toSig(X(g));return new P(M,F)}E==="recovered"&&(S=g[0],E="compact",g=g.subarray(1));let I=l.signature/2,C=g.subarray(0,I),T=g.subarray(I,I*2);return new P(c.fromBytes(C),c.fromBytes(T),S)}static fromHex(g,E){return this.fromBytes(qr(g),E)}assertRecovery(){let{recovery:g}=this;if(g==null)throw new Error("invalid recovery id: must be present");return g}addRecoveryBit(g){return new P(this.r,this.s,g)}recoverPublicKey(g){let{r:E,s:S}=this,I=this.assertRecovery(),C=I===2||I===3?E+a:E;if(!s.isValid(C))throw new Error("invalid recovery id: sig.r+curve.n != R.x");let T=s.toBytes(C),M=t.fromBytes(ct(cc((I&1)===0),T)),F=c.inv(C),R=G(X(g,void 0,"msgHash")),Q=c.create(-R*F),J=c.create(S*F),ee=t.BASE.multiplyUnsafe(Q).add(M.multiplyUnsafe(J));if(ee.is0())throw new Error("invalid recovery: point at infinify");return ee.assertValidity(),ee}hasHighS(){return L(this.s)}toBytes(g=m.format){if(Wo(g),g==="der")return qr(Re.hexFromSig(this));let{r:E,s:S}=this,I=c.toBytes(E),C=c.toBytes(S);return g==="recovered"?(K(),ct(Uint8Array.of(this.assertRecovery()),I,C)):ct(I,C)}toHex(g){return fo(this.toBytes(g))}}Object.freeze(P.prototype),Object.freeze(P);let k=r.bits2int===void 0?function(g){if(g.length>8192)throw new Error("input is too large");let E=qt(g),S=g.length*8-u;return S>0?E>>BigInt(S):E}:r.bits2int,G=r.bits2int_modN===void 0?function(g){return c.create(k(g))}:r.bits2int_modN,_=dr(u);function Be(b){return bo("num < 2^"+u,b,je,_),c.toBytes(b)}function Ge(b,g){return X(b,void 0,"message"),g?X(n(b),void 0,"prehashed message"):b}function z(b,g,E){let{lowS:S,prehash:I,extraEntropy:C}=Go(E,m);b=Ge(b,I);let T=G(b),M=c.fromBytes(g);if(!c.isValidNot0(M))throw new Error("invalid private key");let F=[Be(M),Be(T)];if(C!=null&&C!==!1){let ee=C===!0?o(l.secretKey):C;F.push(X(ee,void 0,"extraEntropy"))}let R=ct(...F),Q=T;function J(ee){let $=k(ee);if(!c.isValidNot0($))return;let de=c.inv($),Dt=t.BASE.multiply($).toAffine(),Xt=c.create(Dt.x);if(Xt===je)return;let Sr=c.create(de*c.create(Q+Xt*M));if(Sr===je)return;let pi=(Dt.x===Xt?0:2)|Number(Dt.y&wt),fi=Sr;return S&&L(Sr)&&(fi=c.neg(Sr),pi^=1),new P(Xt,fi,x?void 0:pi)}return{seed:R,k2sig:J}}function w(b,g,E={}){let{seed:S,k2sig:I}=z(b,g,E);return As(n.outputLen,c.BYTES,i)(S,I).toBytes(E.format)}function B(b,g,E,S={}){let{lowS:I,prehash:C,format:T}=Go(S,m);if(E=X(E,void 0,"publicKey"),g=Ge(g,C),!mo(b)){let M=b instanceof P?", use sig.toBytes()":"";throw new Error("verify expects Uint8Array signature"+M)}N(b,T);try{let M=P.fromBytes(b,T),F=t.fromBytes(E);if(I&&M.hasHighS())return!1;let{r:R,s:Q}=M,J=G(g),ee=c.inv(Q),$=c.create(J*ee),de=c.create(R*ee),Dt=t.BASE.multiplyUnsafe($).add(F.multiplyUnsafe(de));return Dt.is0()?!1:c.create(Dt.x)===R}catch{return!1}}function O(b,g,E={}){let{prehash:S}=Go(E,m);return g=Ge(g,S),P.fromBytes(b,"recovered").recoverPublicKey(g).toBytes()}return Object.freeze({keygen:p,getPublicKey:d,getSharedSecret:f,utils:h,lengths:l,Point:t,sign:w,verify:B,recoverPublicKey:O,Signature:P,hash:n})}var Qo={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},bd={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]};var dc=BigInt(2);function xd(t){let e=Qo.p,r=BigInt(3),n=BigInt(6),o=BigInt(11),i=BigInt(22),s=BigInt(23),c=BigInt(44),a=BigInt(88),u=t*t*t%e,p=u*u*t%e,d=xe(p,r,e)*p%e,f=xe(d,r,e)*p%e,h=xe(f,dc,e)*u%e,l=xe(h,o,e)*h%e,m=xe(l,i,e)*l%e,x=xe(m,c,e)*m%e,L=xe(x,a,e)*x%e,D=xe(L,c,e)*m%e,K=xe(D,r,e)*p%e,N=xe(K,s,e)*l%e,P=xe(N,n,e)*u%e,k=xe(P,dc,e);if(!Zo.eql(Zo.sqr(k),t))throw new Error("Cannot find square root");return k}var Zo=zt(Qo.p,{sqrt:xd}),Ed=sc(Qo,{Fp:Zo,endo:bd}),wr=uc(Ed,Ss);var cn=class extends Error{constructor(e="An error occurred while verifying a message"){super(e),this.name="VerificationError"}};function hc(t,e,r,n){n?.signal?.throwIfAborted();let o=lc.default.createHash("sha256");if(r instanceof Uint8Array)o.update(r);else for(let s of r)o.update(s);let i=o.digest();try{return wr.verify(e,i,t,{prehash:!1,format:"der"})}catch(s){throw new cn(String(s))}}var an=class{type="secp256k1";raw;_key;constructor(e){this._key=fc(e),this.raw=pc(this._key)}toMultihash(){return Te.digest(Mt(this))}toCID(){return re.createV1(114,this.toMultihash())}toString(){return j.encode(this.toMultihash().bytes).substring(1)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:he(this.raw,e.raw)}verify(e,r,n){return hc(this._key,r,e,n)}};function mc(t){return new an(t)}function pc(t){return wr.Point.fromBytes(t).toBytes()}function fc(t){try{return wr.Point.fromBytes(t),t}catch(e){throw new Ar(String(e))}}function gc(t){let{Type:e,Data:r}=yr.decode(t.digest),n=r??new Uint8Array;switch(e){case ue.Ed25519:return Gs(n);case ue.secp256k1:return mc(n);case ue.ECDSA:return hs(n);default:throw new Qt}}function Mt(t){return yr.encode({Type:ue[t.type],Data:t.raw})}var yc=Symbol.for("nodejs.util.inspect.custom"),Id=114,br=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()})`}[yn]=!0;toString(){return this.string==null&&(this.string=j.encode(this.multihash.bytes).slice(1)),this.string}toMultihash(){return this.multihash}toCID(){return re.createV1(Id,this.multihash)}toJSON(){return this.toString()}equals(e){if(e==null)return!1;if(e instanceof Uint8Array)return he(this.multihash.bytes,e);if(typeof e=="string")return this.toString()===e;if(e?.toMultihash()?.bytes!=null)return he(this.multihash.bytes,e.toMultihash().bytes);throw new Error("not valid Id")}[yc](){return`PeerId(${this.toString()})`}},un=class extends br{type="RSA";publicKey;constructor(e){super({...e,type:"RSA"}),this.publicKey=e.publicKey}},dn=class extends br{type="Ed25519";publicKey;constructor(e){super({...e,type:"Ed25519"}),this.publicKey=e.publicKey}},ln=class extends br{type="secp256k1";publicKey;constructor(e){super({...e,type:"secp256k1"}),this.publicKey=e.publicKey}},Sd=2336,xr=class{type="url";multihash;publicKey;url;constructor(e){this.url=e.toString(),this.multihash=Te.digest(ae(this.url))}[yc](){return`PeerId(${this.url})`}[yn]=!0;toString(){return this.toCID().toString()}toMultihash(){return this.multihash}toCID(){return re.createV1(Sd,this.toMultihash())}toJSON(){return this.toString()}equals(e){return e==null?!1:(e instanceof Uint8Array&&(e=V(e)),e.toString()===this.toString())}};var vd=114,wc=2336;function bc(t,e){let r;if(t.charAt(0)==="1"||t.charAt(0)==="Q")r=nr(j.decode(`z${t}`));else{if(t.startsWith("k51qzi5uqu5")||t.startsWith("kzwfwjn5ji4")||t.startsWith("k2k4r8")||t.startsWith("bafz"))return Ad(re.parse(t));if(e==null)throw new ve('Please pass a multibase decoder for strings that do not start with "1" or "Q"');r=nr(e.decode(t))}return xc(r)}function xc(t){if(Cd(t))return new un({multihash:t});if(Bd(t))try{let e=gc(t);if(e.type==="Ed25519")return new dn({multihash:t,publicKey:e});if(e.type==="secp256k1")return new ln({multihash:t,publicKey:e})}catch{let r=V(t.digest);return new xr(new URL(r))}throw new Cr("Supplied PeerID Multihash is invalid")}function Ad(t){if(t?.multihash==null||t.version==null||t.version===1&&t.code!==vd&&t.code!==wc)throw new Br("Supplied PeerID CID is invalid");if(t.code===wc){let e=V(t.multihash.digest);return new xr(new URL(e))}return xc(t.multihash)}function Bd(t){return t.code===Te.code}function Cd(t){return t.code===Qn.code}function Ld(t){let e=t.getComponents(),r={},n=0;return e[n]?.name==="ip6zone"&&(r.zone=`${e[n].value}`,n++),e[n]?.name==="ip4"||e[n]?.name==="ip6"||e[n]?.name==="dns"||e[n]?.name==="dns4"||e[n]?.name==="dns6"?(r.type=e[n].name,r.host=e[n].value,n++):e[n]?.name==="dnsaddr"&&(r.type=e[n].name,r.host=`_dnsaddr.${e[n].value}`,n++),(e[n]?.name==="tcp"||e[n]?.name==="udp")&&(r.protocol=e[n].name==="tcp"?"tcp":"udp",r.port=parseInt(`${e[n].value}`),n++),e[n]?.name==="ipcidr"&&(r.type==="ip4"?r.cidr=parseInt(`${e[n].value}`):r.type==="ip6"&&(r.cidr=`${e[n].value}`),n++),r.type==null||r.host==null?null:(e[n]?.name==="tls"&&e[n+1]?.name==="sni"&&(r.sni=e[n+1].value,n+=2),r)}function Ec(t){let e=Ld(t);if(e==null)throw new ve(`Multiaddr ${t} was not an IPv4, IPv6, DNS, DNS4, DNS6 or DNSADDR address`);return e}var Ie=pe("node:net");var Ac=Zt(vc(),1),Rd=["0.0.0.0/8","10.0.0.0/8","100.64.0.0/10","127.0.0.0/8","169.254.0.0/16","172.16.0.0/12","192.0.0.0/24","192.0.0.0/29","192.0.0.8/32","192.0.0.9/32","192.0.0.10/32","192.0.0.170/32","192.0.0.171/32","192.0.2.0/24","192.31.196.0/24","192.52.193.0/24","192.88.99.0/24","192.168.0.0/16","192.175.48.0/24","198.18.0.0/15","198.51.100.0/24","203.0.113.0/24","240.0.0.0/4","255.255.255.255/32"],Nd=Rd.map(t=>new Ac.Netmask(t));function ii(t){for(let e of Nd)if(e.contains(t))return!0;return!1}function Fd(t){return/^::ffff:([0-9a-fA-F]{1,4}):([0-9a-fA-F]{1,4})$/.test(t)}function kd(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 ii(o)}function Kd(t){return/^::ffff:([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(t)}function Md(t){let e=t.split(":"),r=e[e.length-1];return ii(r)}function Hd(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 Bc(t){if((0,Ie.isIPv4)(t))return ii(t);if(Fd(t))return kd(t);if(Kd(t))return Md(t);if((0,Ie.isIPv6)(t))return Hd(t)}function Cc(t){try{let e=Ec(t);switch(e.type){case"ip4":case"ip6":return Bc(e.host)??!1;default:return e.host==="localhost"}}catch{return!1}}var oe=class extends Error{static name="InvalidMultiaddrError";name="InvalidMultiaddrError"},at=class extends Error{static name="ValidationError";name="ValidationError"},pn=class extends Error{static name="InvalidParametersError";name="InvalidParametersError"},fn=class extends Error{static name="UnknownProtocolError";name="UnknownProtocolError"};function ci(t){return e=>V(e,t)}function ai(t){return e=>ae(e,t)}function Wt(t){return new DataView(t.buffer).getUint16(t.byteOffset).toString()}function Tt(t){let e=new ArrayBuffer(2);return new DataView(e).setUint16(0,typeof t=="string"?parseInt(t):t),new Uint8Array(e)}function Lc(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=ae(e[0],"base32"),n=parseInt(e[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=Tt(n);return De([r,o],r.length+o.length)}function Oc(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=ht.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=Tt(n);return De([r,o],r.length+o.length)}function ui(t){let e=t.subarray(0,t.length-2),r=t.subarray(t.length-2),n=V(e,"base32"),o=Wt(r);return`${n}:${o}`}var di=function(t){t=t.toString().trim();let e=new Uint8Array(4);return t.split(/\./g).forEach((r,n)=>{let o=parseInt(r,10);if(isNaN(o)||o<0||o>255)throw new oe("Invalid byte value in IP address");e[n]=o}),e},Tc=function(t){let e=0;t=t.toString().trim();let r=t.split(":",8),n;for(n=0;n<r.length;n++){let i=(0,Ie.isIPv4)(r[n]),s;i&&(s=di(r[n]),r[n]=V(s.subarray(0,2),"base16")),s!=null&&++n<8&&r.splice(n,0,V(s.subarray(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++){r[n]===""&&(r[n]="0");let i=parseInt(r[n],16);if(isNaN(i)||i<0||i>65535)throw new oe("Invalid byte value in IP address");o[e++]=i>>8&255,o[e++]=i&255}return o},Dc=function(t){if(t.byteLength!==4)throw new oe("IPv4 address was incorrect length");let e=[];for(let r=0;r<t.byteLength;r++)e.push(t[r]);return e.join(".")},Uc=function(t){if(t.byteLength!==16)throw new oe("IPv6 address was incorrect length");let e=[];for(let n=0;n<t.byteLength;n+=2){let o=t[n],i=t[n+1],s=`${o.toString(16).padStart(2,"0")}${i.toString(16).padStart(2,"0")}`;e.push(s)}let r=e.join(":");try{let n=new URL(`http://[${r}]`);return n.hostname.substring(1,n.hostname.length-1)}catch{throw new oe(`Invalid IPv6 address "${r}"`)}};function _c(t){try{let e=new URL(`http://[${t}]`);return e.hostname.substring(1,e.hostname.length-1)}catch{throw new oe(`Invalid IPv6 address "${t}"`)}}var si=Object.values(ir).map(t=>t.decoder),qd=(function(){let t=si[0].or(si[1]);return si.slice(2).forEach(e=>t=t.or(e)),t})();function Pc(t){return qd.decode(t)}function Rc(t){return e=>t.encoder.encode(e)}function Vd(t){if(parseInt(t).toString()!==t)throw new at("Value must be an integer")}function zd(t){if(t<0)throw new at("Value must be a positive integer, or zero")}function $d(t){return e=>{if(e>t)throw new at(`Value must be smaller than or equal to ${t}`)}}function jd(...t){return e=>{for(let r of t)r(e)}}var Er=jd(Vd,zd,$d(65535));var Z=-1,li=class{protocolsByCode=new Map;protocolsByName=new Map;getProtocol(e){let r;if(typeof e=="string"?r=this.protocolsByName.get(e):r=this.protocolsByCode.get(e),r==null)throw new fn(`Protocol ${e} was unknown`);return r}addProtocol(e){this.protocolsByCode.set(e.code,e),this.protocolsByName.set(e.name,e),e.aliases?.forEach(r=>{this.protocolsByName.set(r,e)})}removeProtocol(e){let r=this.protocolsByCode.get(e);r!=null&&(this.protocolsByCode.delete(r.code),this.protocolsByName.delete(r.name),r.aliases?.forEach(n=>{this.protocolsByName.delete(n)}))}},ut=new li,Ul=[{code:4,name:"ip4",size:32,valueToBytes:di,bytesToValue:Dc,validate:t=>{if(!(0,Ie.isIPv4)(t))throw new at(`Invalid IPv4 address "${t}"`)}},{code:6,name:"tcp",size:16,valueToBytes:Tt,bytesToValue:Wt,validate:Er},{code:273,name:"udp",size:16,valueToBytes:Tt,bytesToValue:Wt,validate:Er},{code:33,name:"dccp",size:16,valueToBytes:Tt,bytesToValue:Wt,validate:Er},{code:41,name:"ip6",size:128,valueToBytes:Tc,bytesToValue:Uc,stringToValue:_c,validate:t=>{if(!(0,Ie.isIPv6)(t))throw new at(`Invalid IPv6 address "${t}"`)}},{code:42,name:"ip6zone",size:Z},{code:43,name:"ipcidr",size:8,bytesToValue:ci("base10"),valueToBytes:ai("base10")},{code:53,name:"dns",size:Z},{code:54,name:"dns4",size:Z},{code:55,name:"dns6",size:Z},{code:56,name:"dnsaddr",size:Z},{code:132,name:"sctp",size:16,valueToBytes:Tt,bytesToValue:Wt,validate:Er},{code:301,name:"udt"},{code:302,name:"utp"},{code:400,name:"unix",size:Z,stringToValue:t=>decodeURIComponent(t),valueToString:t=>encodeURIComponent(t)},{code:421,name:"p2p",aliases:["ipfs"],size:Z,bytesToValue:ci("base58btc"),valueToBytes:t=>t.startsWith("Q")||t.startsWith("1")?ai("base58btc")(t):re.parse(t).multihash.bytes},{code:444,name:"onion",size:96,bytesToValue:ui,valueToBytes:Lc},{code:445,name:"onion3",size:296,bytesToValue:ui,valueToBytes:Oc},{code:446,name:"garlic64",size:Z},{code:447,name:"garlic32",size:Z},{code:448,name:"tls"},{code:449,name:"sni",size:Z},{code:454,name:"noise"},{code:460,name:"quic"},{code:461,name:"quic-v1"},{code:465,name:"webtransport"},{code:466,name:"certhash",size:Z,bytesToValue:Rc($n),valueToBytes:Pc},{code:480,name:"http"},{code:481,name:"http-path",size:Z,stringToValue:t=>`/${decodeURIComponent(t)}`,valueToString:t=>encodeURIComponent(t.substring(1))},{code:443,name:"https"},{code:477,name:"ws"},{code:478,name:"wss"},{code:479,name:"p2p-websocket-star"},{code:277,name:"p2p-stardust"},{code:275,name:"p2p-webrtc-star"},{code:276,name:"p2p-webrtc-direct"},{code:280,name:"webrtc-direct"},{code:281,name:"webrtc"},{code:290,name:"p2p-circuit"},{code:777,name:"memory",size:Z}];Ul.forEach(t=>{ut.addProtocol(t)});function Nc(t){let e=[],r=0;for(;r<t.length;){let n=Po(t,r),o=ut.getProtocol(n),i=$e(n),s=_l(o,t,r+i),c=0;s>0&&o.size===Z&&(c=$e(s));let a=i+c+s,u={code:n,name:o.name,bytes:pt(t.subarray(r,r+a))};if(s>0){let p=r+i+c,d=t.subarray(p,p+s);u.value=o.bytesToValue?.(d)??V(d)}e.push(u),r+=a}return e}function Fc(t){let e=0,r=[];for(let n of t){if(n.bytes==null){let o=ut.getProtocol(n.code),i=$e(n.code),s,c=0,a=0;n.value!=null&&(s=o.valueToBytes?.(n.value)??ae(n.value),c=s.byteLength,o.size===Z&&(a=$e(c)));let u=new Uint8Array(i+a+c),p=0;pr(n.code,u,p),p+=i,s!=null&&(o.size===Z&&(pr(c,u,p),p+=a),u.set(s,p)),n.bytes=u}r.push(n.bytes),e+=n.bytes.byteLength}return De(r,e)}function kc(t){if(t.charAt(0)!=="/")throw new oe('String multiaddr must start with "/"');let e=[],r="protocol",n="",o="";for(let i=1;i<t.length;i++){let s=t.charAt(i);s!=="/"&&(r==="protocol"?o+=t.charAt(i):n+=t.charAt(i));let c=i===t.length-1;if(s==="/"||c){let a=ut.getProtocol(o);if(r==="protocol"){if(a.size==null||a.size===0){e.push({code:a.code,name:a.name}),n="",o="",r="protocol";continue}else if(c)throw new oe(`Component ${o} was missing value`);r="value"}else if(r==="value"){let u={code:a.code,name:a.name};if(a.size!=null&&a.size!==0){if(n==="")throw new oe(`Component ${o} was missing value`);u.value=a.stringToValue?.(n)??n}e.push(u),n="",o="",r="protocol"}}}if(o!==""&&n!=="")throw new oe("Incomplete multiaddr");return e}function Kc(t){return`/${t.flatMap(e=>{if(e.value==null)return e.name;let r=ut.getProtocol(e.code);if(r==null)throw new oe(`Unknown protocol code ${e.code}`);return[e.name,r.valueToString?.(e.value)??e.value]}).join("/")}`}function _l(t,e,r){return t.size==null||t.size===0?0:t.size>0?t.size/8:Po(e,r)}var Pl=Symbol.for("nodejs.util.inspect.custom"),hi=Symbol.for("@multiformats/multiaddr");function Rl(t){if(t==null&&(t="/"),Mc(t))return t.getComponents();if(t instanceof Uint8Array)return Nc(t);if(typeof t=="string")return t=t.replace(/\/(\/)+/,"/").replace(/(\/)+$/,""),t===""&&(t="/"),kc(t);if(Array.isArray(t))return t;throw new oe("Must be a string, Uint8Array, Component[], or another Multiaddr")}var mn=class t{[hi]=!0;#e;#t;#r;constructor(e="/",r={}){this.#e=Rl(e),r.validate!==!1&&Nl(this)}get bytes(){return this.#r==null&&(this.#r=Fc(this.#e)),this.#r}toString(){return this.#t==null&&(this.#t=Kc(this.#e)),this.#t}toJSON(){return this.toString()}getComponents(){return[...this.#e.map(e=>({...e}))]}encapsulate(e){let r=new t(e);return new t([...this.#e,...r.getComponents()],{validate:!1})}decapsulate(e){let r=e.toString(),n=this.toString(),o=n.lastIndexOf(r);if(o<0)throw new pn(`Address ${this.toString()} does not contain subaddress: ${r}`);return new t(n.slice(0,o),{validate:!1})}decapsulateCode(e){let r;for(let n=this.#e.length-1;n>-1;n--)if(this.#e[n].code===e){r=n;break}return new t(this.#e.slice(0,r),{validate:!1})}equals(e){return he(this.bytes,e.bytes)}[Pl](){return`Multiaddr(${this.toString()})`}};function Nl(t){t.getComponents().forEach(e=>{let r=ut.getProtocol(e.code);e.value!=null&&r.validate?.(e.value)})}function Mc(t){return!!t?.[hi]}function Hc(t){return new mn(t)}function qc(t,e,r,n){let o=()=>{n?.log.trace("query",e),t.query({questions:[{name:e,type:"PTR"}]})};return o(),setInterval(o,r)}function Vc(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=>{s.type==="TXT"&&i.push(s)}),!(o==null||o?.name!==r||i.length===0||o.data.startsWith(e)))try{let s=i.flatMap(a=>a.data).filter(a=>a.toString().startsWith("dnsaddr=")).map(a=>Hc(a.toString().substring(8))),c=s[0].getComponents().findLast(a=>a.code===421)?.value;if(c==null)throw new Error("Multiaddr doesn't contain PeerId");return n?.log("peer found %p",c),{id:bc(c),multiaddrs:s.map(a=>a.decapsulateCode(421))}}catch(s){n?.log.error("failed to parse mdns response - %e",s)}}function zc(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 c=[];c.push({name:o,type:"PTR",class:"IN",ttl:120,data:r+"."+o}),n.filter(Fl).forEach(a=>{let u="dnsaddr="+a.toString();if(u.length>255){s?.log("multiaddr %a is too long to use in mDNS query response",a);return}if(a.getComponents().findLast(p=>p.code===421)?.value==null){s?.log("multiaddr %a did not have a peer ID so cannot be used in mDNS query response",a);return}c.push({name:r+"."+o,type:"TXT",class:"IN",ttl:120,data:u})}),s?.log.trace("responding to query"),e.respond(c)}}function Fl(t){return!!Cc(t)}function $c(t){let e="",r="abcdefghijklmnopqrstuvwxyz0123456789";for(let n=0;n<t;n++)e+=r.charAt(Math.floor(Math.random()*r.length));return e}var gn=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??$c(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)}[gi]=this;[Symbol.toStringTag]="@libp2p/mdns";[bi]=["@libp2p/peer-discovery"];isStarted(){return!!this.mdns}async start(){this.mdns==null&&(this.mdns=(0,jc.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=qc(this.mdns,this.serviceTag,this.interval,{log:this.log}))}_onMdnsQuery(e){this.mdns!=null&&(this.log.trace("received incoming mDNS query"),zc(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=Vc(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 - %e",r)}}_onMdnsWarning(e){this.log.error("mdns warning - %e",e)}_onMdnsError(e){this.log.error("mdns error - %e",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 Kl(t={}){return e=>new gn(e,t)}return Qc(Ml);})();
|
|
2
|
+
"use strict";var Libp2PMdns=(()=>{var Gc=Object.create;var vr=Object.defineProperty;var Wc=Object.getOwnPropertyDescriptor;var Xc=Object.getOwnPropertyNames;var Zc=Object.getPrototypeOf,Qc=Object.prototype.hasOwnProperty;var ge=(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 Be=(t,e)=>()=>{try{return e||t((e={exports:{}}).exports,e),e.exports}catch(r){throw e=0,r}},ye=(t,e)=>{for(var r in e)vr(t,r,{get:e[r],enumerable:!0})},mi=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Xc(e))!Qc.call(t,o)&&o!==r&&vr(t,o,{get:()=>e[o],enumerable:!(n=Wc(e,o))||n.enumerable});return t};var Zt=(t,e,r)=>(r=t!=null?Gc(Zc(t)):{},mi(e||!t||!t.__esModule?vr(r,"default",{value:t,enumerable:!0}):r,t)),Jc=t=>mi(vr({},"__esModule",{value:!0}),t);var xi=Be(wn=>{"use strict";wn.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};wn.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 Ei=Be(bn=>{"use strict";bn.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};bn.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 Ii=Be(xn=>{"use strict";xn.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};xn.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 Si=Be(En=>{"use strict";En.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};En.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 vi=Be(In=>{"use strict";In.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}`};In.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 Ci=Be((Bi,Sn)=>{var Ai=(function(t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.decode=d,t.encode=h,t.familyOf=u,t.name=void 0,t.sizeOf=a,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:f=>e.test(f),encode(f,l,p){p=~~p,l=l||new Uint8Array(p+r);let w=f.length,S=0;for(let x=0;x<w;){let O=f.charCodeAt(x++);O===46?(l[p++]=S,S=0):S=S*10+(O-48)}return l[p]=S,l},decode(f,l){return l=~~l,`${f[l++]}.${f[l++]}.${f[l++]}.${f[l]}`}};t.v4=i;let s={name:"v6",size:o,isFormat:f=>f.length>0&&n.test(f),encode(f,l,p){p=~~p;let w=p+o,S=-1,x=0,O=0,H=!0,K=!1;l=l||new Uint8Array(p+o);for(let P=0;P<f.length;P++){let F=f.charCodeAt(P);F===58?(H?S!==-1?(p<w&&(l[p]=0),p<w-1&&(l[p+1]=0),p+=2):p<w&&(S=p):(K===!0?(p<w&&(l[p]=O),p++):(p<w&&(l[p]=x>>8),p<w-1&&(l[p+1]=x&255),p+=2),x=0,O=0),H=!0,K=!1):F===46?(p<w&&(l[p]=O),p++,O=0,x=0,H=!1,K=!0):(H=!1,F>=97?F-=87:F>=65?F-=55:(F-=48,O=O*10+F),x=(x<<4)+F)}if(H===!1)K===!0?(p<w&&(l[p]=O),p++):(p<w&&(l[p]=x>>8),p<w-1&&(l[p+1]=x&255),p+=2);else if(S===0)p<w&&(l[p]=0),p<w-1&&(l[p+1]=0),p+=2;else if(S!==-1){p+=2;for(let P=Math.min(p-1,w-1);P>=S+2;P--)l[P]=l[P-2];l[S]=0,l[S+1]=0,S=p}if(S!==p&&S!==-1)for(p>w-2&&(p=w-2);w>S;)l[--w]=p<w&&p>S?l[--p]:0;else for(;p<w;)l[p++]=0;return l},decode(f,l){l=~~l;let p="";for(let w=0;w<o;w+=2)w!==0&&(p+=":"),p+=(f[l+w]<<8|f[l+w+1]).toString(16);return p.replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}};t.v6=s;let c="ip";t.name=c;function a(f){if(i.isFormat(f))return i.size;if(s.isFormat(f))return s.size;throw Error(`Invalid ip address: ${f}`)}function u(f){return a(f)===i.size?1:2}function h(f,l,p){p=~~p;let w=a(f);return typeof l=="function"&&(l=l(p+w)),w===i.size?i.encode(f,l,p):s.encode(f,l,p)}function d(f,l,p){if(l=~~l,p=p||f.length-l,p===i.size)return i.decode(f,l,p);if(p===s.size)return s.decode(f,l,p);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 Ai}):typeof Sn=="object"&&typeof Bi=="object"&&(Sn.exports=Ai)});var Ti=Be(A=>{"use strict";var B=ge("buffer").Buffer,ot=xi(),ra=Ei(),na=Ii(),Tr=Si(),vn=vi(),xt=Ci(),oa=0,Li=32768,An=32768,ia=~An,Oi=32768,sa=~Oi,y=A.name={};y.encode=function(t,e,r,{mail:n=!1}={}){e||(e=B.alloc(y.encodingLength(t))),r||(r=0);let o=r,i=t.replace(/^\.|\.$/gm,"");if(i.length){let s=[];if(n){let c="";i.split(".").forEach(a=>{a.endsWith("\\")?c+=(c.length?".":"")+a.slice(0,-1):s.length===0&&c.length?s.push(c+"."+a):s.push(a)})}else s=i.split(".");for(let c=0;c<s.length;c++){let a=e.write(s[c],r+1);e[r]=a,r+=a+1}}return e[r++]=0,y.encode.bytes=r-o,e};y.encode.bytes=0;y.decode=function(t,e,{mail:r=!1}={}){e||(e=0);let n=[],o=e,i=0,s=0,c=!1;for(;;){if(e>=t.length)throw new Error("Cannot decode name (buffer overflow)");let a=t[e++];if(s+=c?0:1,a===0)break;if((a&192)===0){if(e+a>t.length)throw new Error("Cannot decode name (buffer overflow)");if(i+=a+1,i>254)throw new Error("Cannot decode name (name too long)");let u=t.toString("utf-8",e,e+a);r&&(u=u.replace(/\./g,"\\.")),n.push(u),e+=a,s+=c?0:a}else if((a&192)===192){if(e+1>t.length)throw new Error("Cannot decode name (buffer overflow)");let u=t.readUInt16BE(e-1)-49152;if(u>=o)throw new Error("Cannot decode name (bad pointer)");e=u,o=u,s+=c?0:1,c=!0}else throw new Error("Cannot decode name (bad label)")}return y.decode.bytes=s,n.length===0?".":n.join(".")};y.decode.bytes=0;y.encodingLength=function(t){return t==="."||t===".."?1:B.byteLength(t.replace(/^\.|\.$/gm,""))+2};var _={};_.encode=function(t,e,r){e||(e=B.alloc(_.encodingLength(t))),r||(r=0);let n=e.write(t,r+1);return e[r]=n,_.encode.bytes=n+1,e};_.encode.bytes=0;_.decode=function(t,e){e||(e=0);let r=t[e],n=t.toString("utf-8",e+1,e+1+r);return _.decode.bytes=r+1,n};_.decode.bytes=0;_.encodingLength=function(t){return B.byteLength(t)+1};var Te={};Te.encode=function(t,e,r){e||(e=Te.encodingLength(t)),r||(r=0);let n=(t.flags||0)&32767,o=t.type==="response"?Li:oa;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};Te.encode.bytes=12;Te.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&Li?"response":"query",flags:r&32767,flag_qr:(r>>15&1)===1,opcode:na.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:ra.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))}};Te.decode.bytes=12;Te.encodingLength=function(){return 12};var We=A.unknown={};We.encode=function(t,e,r){return e||(e=B.alloc(We.encodingLength(t))),r||(r=0),e.writeUInt16BE(t.length,r),t.copy(e,r+2),We.encode.bytes=t.length+2,e};We.encode.bytes=0;We.decode=function(t,e){e||(e=0);let r=t.readUInt16BE(e),n=t.slice(e+2,e+2+r);return We.decode.bytes=r+2,n};We.decode.bytes=0;We.encodingLength=function(t){return t.length+2};var Xe=A.ns={};Xe.encode=function(t,e,r){return e||(e=B.alloc(Xe.encodingLength(t))),r||(r=0),y.encode(t,e,r+2),e.writeUInt16BE(y.encode.bytes,r),Xe.encode.bytes=y.encode.bytes+2,e};Xe.encode.bytes=0;Xe.decode=function(t,e){e||(e=0);let r=t.readUInt16BE(e),n=y.decode(t,e+2);return Xe.decode.bytes=r+2,n};Xe.decode.bytes=0;Xe.encodingLength=function(t){return y.encodingLength(t)+2};var Ze=A.soa={};Ze.encode=function(t,e,r){e||(e=B.alloc(Ze.encodingLength(t))),r||(r=0);let n=r;return r+=2,y.encode(t.mname,e,r),r+=y.encode.bytes,y.encode(t.rname,e,r,{mail:!0}),r+=y.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),Ze.encode.bytes=r-n,e};Ze.encode.bytes=0;Ze.decode=function(t,e){e||(e=0);let r=e,n={};return e+=2,n.mname=y.decode(t,e),e+=y.decode.bytes,n.rname=y.decode(t,e,{mail:!0}),e+=y.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,Ze.decode.bytes=e-r,n};Ze.decode.bytes=0;Ze.encodingLength=function(t){return 22+y.encodingLength(t.mname)+y.encodingLength(t.rname)};var Qe=A.txt={};Qe.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]=B.from(t[o])),!B.isBuffer(t[o]))throw new Error("Must be a Buffer");e||(e=B.alloc(Qe.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),Qe.encode.bytes=r-n,e};Qe.encode.bytes=0;Qe.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 Qe.decode.bytes=e-r,o};Qe.decode.bytes=0;Qe.encodingLength=function(t){Array.isArray(t)||(t=[t]);let e=2;return t.forEach(function(r){typeof r=="string"?e+=B.byteLength(r)+1:e+=r.length+1}),e};var Je=A.null={};Je.encode=function(t,e,r){e||(e=B.alloc(Je.encodingLength(t))),r||(r=0),typeof t=="string"&&(t=B.from(t)),t||(t=B.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),Je.encode.bytes=r-n,e};Je.encode.bytes=0;Je.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,Je.decode.bytes=e-r,o};Je.decode.bytes=0;Je.encodingLength=function(t){return t?(B.isBuffer(t)?t.length:B.byteLength(t))+2:2};var et=A.hinfo={};et.encode=function(t,e,r){e||(e=B.alloc(et.encodingLength(t))),r||(r=0);let n=r;return r+=2,_.encode(t.cpu,e,r),r+=_.encode.bytes,_.encode(t.os,e,r),r+=_.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.cpu=_.decode(t,e),e+=_.decode.bytes,n.os=_.decode(t,e),e+=_.decode.bytes,et.decode.bytes=e-r,n};et.decode.bytes=0;et.encodingLength=function(t){return _.encodingLength(t.cpu)+_.encodingLength(t.os)+2};var Le=A.ptr={},ca=A.cname=Le,aa=A.dname=Le;Le.encode=function(t,e,r){return e||(e=B.alloc(Le.encodingLength(t))),r||(r=0),y.encode(t,e,r+2),e.writeUInt16BE(y.encode.bytes,r),Le.encode.bytes=y.encode.bytes+2,e};Le.encode.bytes=0;Le.decode=function(t,e){e||(e=0);let r=y.decode(t,e+2);return Le.decode.bytes=y.decode.bytes+2,r};Le.decode.bytes=0;Le.encodingLength=function(t){return y.encodingLength(t)+2};var tt=A.srv={};tt.encode=function(t,e,r){e||(e=B.alloc(tt.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),y.encode(t.target,e,r+8);let n=y.encode.bytes+6;return e.writeUInt16BE(n,r),tt.encode.bytes=n+2,e};tt.encode.bytes=0;tt.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=y.decode(t,e+8),tt.decode.bytes=r+2,n};tt.decode.bytes=0;tt.encodingLength=function(t){return 8+y.encodingLength(t.target)};var we=A.caa={};we.ISSUER_CRITICAL=128;we.encode=function(t,e,r){let n=we.encodingLength(t);return e||(e=B.alloc(we.encodingLength(t))),r||(r=0),t.issuerCritical&&(t.flags=we.ISSUER_CRITICAL),e.writeUInt16BE(n-2,r),r+=2,e.writeUInt8(t.flags||0,r),r+=1,_.encode(t.tag,e,r),r+=_.encode.bytes,e.write(t.value,r),r+=B.byteLength(t.value),we.encode.bytes=n,e};we.encode.bytes=0;we.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=_.decode(t,e),e+=_.decode.bytes,o.value=t.toString("utf-8",e,n+r),o.issuerCritical=!!(o.flags&we.ISSUER_CRITICAL),we.decode.bytes=r+2,o};we.decode.bytes=0;we.encodingLength=function(t){return _.encodingLength(t.tag)+_.encodingLength(t.value)+2};var dt=A.mx={};dt.encode=function(t,e,r){e||(e=B.alloc(dt.encodingLength(t))),r||(r=0);let n=r;return r+=2,e.writeUInt16BE(t.preference||0,r),r+=2,y.encode(t.exchange,e,r),r+=y.encode.bytes,e.writeUInt16BE(r-n-2,n),dt.encode.bytes=r-n,e};dt.encode.bytes=0;dt.decode=function(t,e){e||(e=0);let r=e,n={};return e+=2,n.preference=t.readUInt16BE(e),e+=2,n.exchange=y.decode(t,e),e+=y.decode.bytes,dt.decode.bytes=e-r,n};dt.encodingLength=function(t){return 4+y.encodingLength(t.exchange)};var rt=A.a={};rt.encode=function(t,e,r){return e||(e=B.alloc(rt.encodingLength(t))),r||(r=0),e.writeUInt16BE(4,r),r+=2,xt.v4.encode(t,e,r),rt.encode.bytes=6,e};rt.encode.bytes=0;rt.decode=function(t,e){e||(e=0),e+=2;let r=xt.v4.decode(t,e);return rt.decode.bytes=6,r};rt.decode.bytes=0;rt.encodingLength=function(){return 6};var nt=A.aaaa={};nt.encode=function(t,e,r){return e||(e=B.alloc(nt.encodingLength(t))),r||(r=0),e.writeUInt16BE(16,r),r+=2,xt.v6.encode(t,e,r),nt.encode.bytes=18,e};nt.encode.bytes=0;nt.decode=function(t,e){e||(e=0),e+=2;let r=xt.v6.decode(t,e);return nt.decode.bytes=18,r};nt.decode.bytes=0;nt.encodingLength=function(){return 18};var fe=A.option={};fe.encode=function(t,e,r){e||(e=B.alloc(fe.encodingLength(t))),r||(r=0);let n=r,o=vn.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||xt.familyOf(t.ip),c=xt.encode(t.ip,B.alloc),a=Math.ceil(i/8);e.writeUInt16BE(a+4,r),r+=2,e.writeUInt16BE(s,r),r+=2,e.writeUInt8(i,r++),e.writeUInt8(t.scopePrefixLength||0,r++),c.copy(e,r,0,a),r+=a;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 u=t.length||0;e.writeUInt16BE(u,r),r+=2,e.fill(0,r,r+u),r+=u;break;case 14:let h=t.tags.length*2;e.writeUInt16BE(h,r),r+=2;for(let d of t.tags)e.writeUInt16BE(d,r),r+=2;break;default:throw new Error(`Unknown roption code: ${t.code}`)}return fe.encode.bytes=r-n,e};fe.encode.bytes=0;fe.decode=function(t,e){e||(e=0);let r={};r.code=t.readUInt16BE(e),r.type=vn.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=B.alloc(r.family===1?4:16);t.copy(o,0,e,e+n-4),r.ip=xt.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 fe.decode.bytes=n+4,r};fe.decode.bytes=0;fe.encodingLength=function(t){if(t.data)return t.data.length+4;switch(vn.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 xe=A.opt={};xe.encode=function(t,e,r){e||(e=B.alloc(xe.encodingLength(t))),r||(r=0);let n=r,o=Ut(t,fe);return e.writeUInt16BE(o,r),r=Jt(t,fe,e,r+2),xe.encode.bytes=r-n,e};xe.encode.bytes=0;xe.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++]=fe.decode(t,e),e+=fe.decode.bytes,o-=fe.decode.bytes;return xe.decode.bytes=e-r,n};xe.decode.bytes=0;xe.encodingLength=function(t){return 2+Ut(t||[],fe)};var ue=A.dnskey={};ue.PROTOCOL_DNSSEC=3;ue.ZONE_KEY=128;ue.SECURE_ENTRYPOINT=32768;ue.encode=function(t,e,r){e||(e=B.alloc(ue.encodingLength(t))),r||(r=0);let n=r,o=t.key;if(!B.isBuffer(o))throw new Error("Key must be a Buffer");return r+=2,e.writeUInt16BE(t.flags,r),r+=2,e.writeUInt8(ue.PROTOCOL_DNSSEC,r),r+=1,e.writeUInt8(t.algorithm,r),r+=1,o.copy(e,r,0,o.length),r+=o.length,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);if(e+=2,n.flags=t.readUInt16BE(e),e+=2,t.readUInt8(e)!==ue.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,ue.decode.bytes=e-r,n};ue.decode.bytes=0;ue.encodingLength=function(t){return 6+B.byteLength(t.key)};var Fe=A.rrsig={};Fe.encode=function(t,e,r){e||(e=B.alloc(Fe.encodingLength(t))),r||(r=0);let n=r,o=t.signature;if(!B.isBuffer(o))throw new Error("Signature must be a Buffer");return r+=2,e.writeUInt16BE(ot.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,y.encode(t.signersName,e,r),r+=y.encode.bytes,o.copy(e,r,0,o.length),r+=o.length,Fe.encode.bytes=r-n,e.writeUInt16BE(Fe.encode.bytes-2,n),e};Fe.encode.bytes=0;Fe.decode=function(t,e){e||(e=0);let r=e;var n={},o=t.readUInt16BE(e);return e+=2,n.typeCovered=ot.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=y.decode(t,e),e+=y.decode.bytes,n.signature=t.slice(e,r+o+2),e+=n.signature.length,Fe.decode.bytes=e-r,n};Fe.decode.bytes=0;Fe.encodingLength=function(t){return 20+y.encodingLength(t.signersName)+B.byteLength(t.signature)};var ke=A.rp={};ke.encode=function(t,e,r){e||(e=B.alloc(ke.encodingLength(t))),r||(r=0);let n=r;return r+=2,y.encode(t.mbox||".",e,r,{mail:!0}),r+=y.encode.bytes,y.encode(t.txt||".",e,r),r+=y.encode.bytes,ke.encode.bytes=r-n,e.writeUInt16BE(ke.encode.bytes-2,n),e};ke.encode.bytes=0;ke.decode=function(t,e){e||(e=0);let r=e,n={};return e+=2,n.mbox=y.decode(t,e,{mail:!0})||".",e+=y.decode.bytes,n.txt=y.decode(t,e)||".",e+=y.decode.bytes,ke.decode.bytes=e-r,n};ke.decode.bytes=0;ke.encodingLength=function(t){return 2+y.encodingLength(t.mbox||".")+y.encodingLength(t.txt||".")};var X={};X.encode=function(t,e,r){e||(e=B.alloc(X.encodingLength(t))),r||(r=0);let n=r;for(var o=[],i=0;i<t.length;i++){var s=ot.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 c=B.from(o[i]);e.writeUInt8(i,r),r+=1,e.writeUInt8(c.length,r),r+=1,c.copy(e,r),r+=c.length}return X.encode.bytes=r-n,e};X.encode.bytes=0;X.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 c=0;c<s;c++)for(var a=t.readUInt8(e+c),u=0;u<8;u++)if(a&1<<7-u){var h=ot.toString(i<<8|c<<3|u);o.push(h)}e+=s}return X.decode.bytes=e-n,o};X.decode.bytes=0;X.encodingLength=function(t){for(var e=[],r=0;r<t.length;r++){var n=ot.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 Ke=A.nsec={};Ke.encode=function(t,e,r){e||(e=B.alloc(Ke.encodingLength(t))),r||(r=0);let n=r;return r+=2,y.encode(t.nextDomain,e,r),r+=y.encode.bytes,X.encode(t.rrtypes,e,r),r+=X.encode.bytes,Ke.encode.bytes=r-n,e.writeUInt16BE(Ke.encode.bytes-2,n),e};Ke.encode.bytes=0;Ke.decode=function(t,e){e||(e=0);let r=e;var n={},o=t.readUInt16BE(e);return e+=2,n.nextDomain=y.decode(t,e),e+=y.decode.bytes,n.rrtypes=X.decode(t,e,o-(e-r)),e+=X.decode.bytes,Ke.decode.bytes=e-r,n};Ke.decode.bytes=0;Ke.encodingLength=function(t){return 2+y.encodingLength(t.nextDomain)+X.encodingLength(t.rrtypes)};var Me=A.nsec3={};Me.encode=function(t,e,r){e||(e=B.alloc(Me.encodingLength(t))),r||(r=0);let n=r,o=t.salt;if(!B.isBuffer(o))throw new Error("salt must be a Buffer");let i=t.nextDomain;if(!B.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,X.encode(t.rrtypes,e,r),r+=X.encode.bytes,Me.encode.bytes=r-n,e.writeUInt16BE(Me.encode.bytes-2,n),e};Me.encode.bytes=0;Me.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=X.decode(t,e,o-(e-r)),e+=X.decode.bytes,Me.decode.bytes=e-r,n};Me.decode.bytes=0;Me.encodingLength=function(t){return 8+t.salt.length+t.nextDomain.length+X.encodingLength(t.rrtypes)};var He=A.ds={};He.encode=function(t,e,r){e||(e=B.alloc(He.encodingLength(t))),r||(r=0);let n=r,o=t.digest;if(!B.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,He.encode.bytes=r-n,e.writeUInt16BE(He.encode.bytes-2,n),e};He.encode.bytes=0;He.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,He.decode.bytes=e-r,n};He.decode.bytes=0;He.encodingLength=function(t){return 6+B.byteLength(t.digest)};var be=A.sshfp={};be.getFingerprintLengthForHashType=function(e){switch(e){case 1:return 20;case 2:return 32}};be.encode=function(e,r,n){r||(r=B.alloc(be.encodingLength(e))),n||(n=0);let o=n;n+=2,r[n]=e.algorithm,n+=1,r[n]=e.hash,n+=1;let i=B.from(e.fingerprint.toUpperCase(),"hex");if(i.length!==be.getFingerprintLengthForHashType(e.hash))throw new Error("Invalid fingerprint length");return i.copy(r,n),n+=i.byteLength,be.encode.bytes=n-o,r.writeUInt16BE(be.encode.bytes-2,o),r};be.encode.bytes=0;be.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=be.getFingerprintLengthForHashType(o.hash);return o.fingerprint=e.slice(r,r+i).toString("hex").toUpperCase(),r+=i,be.decode.bytes=r-n,o};be.decode.bytes=0;be.encodingLength=function(t){return 4+B.from(t.fingerprint,"hex").byteLength};var qe=A.naptr={};qe.encode=function(t,e,r){e||(e=B.alloc(qe.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,_.encode(t.flags,e,r),r+=_.encode.bytes,_.encode(t.services,e,r),r+=_.encode.bytes,_.encode(t.regexp,e,r),r+=_.encode.bytes,y.encode(t.replacement,e,r),r+=y.encode.bytes,qe.encode.bytes=r-n,e.writeUInt16BE(qe.encode.bytes-2,n),e};qe.encode.bytes=0;qe.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=_.decode(t,e),e+=_.decode.bytes,n.services=_.decode(t,e),e+=_.decode.bytes,n.regexp=_.decode(t,e),e+=_.decode.bytes,n.replacement=y.decode(t,e),e+=y.decode.bytes,qe.decode.bytes=e-r,n};qe.decode.bytes=0;qe.encodingLength=function(t){return _.encodingLength(t.flags)+_.encodingLength(t.services)+_.encodingLength(t.regexp)+y.encodingLength(t.replacement)+6};var Ve=A.tlsa={};Ve.encode=function(t,e,r){e||(e=B.alloc(Ve.encodingLength(t))),r||(r=0);let n=r,o=t.certificate;if(!B.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,Ve.encode.bytes=r-n,e.writeUInt16BE(Ve.encode.bytes-2,n),e};Ve.encode.bytes=0;Ve.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,Ve.decode.bytes=e-r,n};Ve.decode.bytes=0;Ve.encodingLength=function(t){return 5+B.byteLength(t.certificate)};var Bn=A.record=function(t){switch(t.toUpperCase()){case"A":return rt;case"PTR":return Le;case"CNAME":return ca;case"DNAME":return aa;case"TXT":return Qe;case"NULL":return Je;case"AAAA":return nt;case"SRV":return tt;case"HINFO":return et;case"CAA":return we;case"NS":return Xe;case"SOA":return Ze;case"MX":return dt;case"OPT":return xe;case"DNSKEY":return ue;case"RRSIG":return Fe;case"RP":return ke;case"NSEC":return Ke;case"NSEC3":return Me;case"SSHFP":return be;case"DS":return He;case"NAPTR":return qe;case"TLSA":return Ve}return We},re=A.answer={};re.encode=function(t,e,r){e||(e=B.alloc(re.encodingLength(t))),r||(r=0);let n=r;if(y.encode(t.name,e,r),r+=y.encode.bytes,e.writeUInt16BE(ot.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,xe.encode(t.options||[],e,r),r+=xe.encode.bytes}else{let o=Tr.toClass(t.class===void 0?"IN":t.class);t.flush&&(o|=An),e.writeUInt16BE(o,r+2),e.writeUInt32BE(t.ttl||0,r+4),r+=8;let i=Bn(t.type);i.encode(t.data,e,r),r+=i.encode.bytes}return re.encode.bytes=r-n,e};re.encode.bytes=0;re.decode=function(t,e){e||(e=0);let r={},n=e;if(r.name=y.decode(t,e),e+=y.decode.bytes,r.type=ot.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=xe.decode(t,e+8),e+=8+xe.decode.bytes;else{let o=t.readUInt16BE(e+2);r.ttl=t.readUInt32BE(e+4),r.class=Tr.toString(o&ia),r.flush=!!(o&An);let i=Bn(r.type);r.data=i.decode(t,e+8),e+=8+i.decode.bytes}return re.decode.bytes=e-n,r};re.decode.bytes=0;re.encodingLength=function(t){let e=t.data!==null&&t.data!==void 0?t.data:t.options;return y.encodingLength(t.name)+8+Bn(t.type).encodingLength(e)};var Oe=A.question={};Oe.encode=function(t,e,r){e||(e=B.alloc(Oe.encodingLength(t))),r||(r=0);let n=r;return y.encode(t.name,e,r),r+=y.encode.bytes,e.writeUInt16BE(ot.toType(t.type),r),r+=2,e.writeUInt16BE(Tr.toClass(t.class===void 0?"IN":t.class),r),r+=2,Oe.encode.bytes=r-n,t};Oe.encode.bytes=0;Oe.decode=function(t,e){e||(e=0);let r=e,n={};return n.name=y.decode(t,e),e+=y.decode.bytes,n.type=ot.toString(t.readUInt16BE(e)),e+=2,n.class=Tr.toString(t.readUInt16BE(e)),e+=2,n.class&Oi&&(n.class&=sa),Oe.decode.bytes=e-r,n};Oe.decode.bytes=0;Oe.encodingLength=function(t){return y.encodingLength(t.name)+4};A.AUTHORITATIVE_ANSWER=1024;A.TRUNCATED_RESPONSE=512;A.RECURSION_DESIRED=256;A.RECURSION_AVAILABLE=128;A.AUTHENTIC_DATA=32;A.CHECKING_DISABLED=16;A.DNSSEC_OK=32768;A.encode=function(t,e,r){let n=!e;n&&(e=B.alloc(A.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=[]),Te.encode(t,e,r),r+=Te.encode.bytes,r=Jt(t.questions,Oe,e,r),r=Jt(t.answers,re,e,r),r=Jt(t.authorities,re,e,r),r=Jt(t.additionals,re,e,r),A.encode.bytes=r-o,n&&A.encode.bytes!==e.length?e.slice(0,A.encode.bytes):e};A.encode.bytes=0;A.decode=function(t,e){e||(e=0);let r=e,n=Te.decode(t,e);return e+=Te.decode.bytes,e=Or(n.questions,Oe,t,e),e=Or(n.answers,re,t,e),e=Or(n.authorities,re,t,e),e=Or(n.additionals,re,t,e),A.decode.bytes=e-r,n};A.decode.bytes=0;A.encodingLength=function(t){return Te.encodingLength(t)+Ut(t.questions||[],Oe)+Ut(t.answers||[],re)+Ut(t.authorities||[],re)+Ut(t.additionals||[],re)};A.streamEncode=function(t){let e=A.encode(t),r=B.alloc(2);r.writeUInt16BE(e.byteLength);let n=B.concat([r,e]);return A.streamEncode.bytes=n.byteLength,n};A.streamEncode.bytes=0;A.streamDecode=function(t){let e=t.readUInt16BE(0);if(t.byteLength<e+2)return null;let r=A.decode(t.slice(2));return A.streamDecode.bytes=A.decode.bytes,r};A.streamDecode.bytes=0;function Ut(t,e){let r=0;for(let n=0;n<t.length;n++)r+=e.encodingLength(t[n]);return r}function Jt(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 Or(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 _i=Be((Bh,Ui)=>{"use strict";var Di=fa;process.nextTick(pa,42);Ui.exports=ua;function ua(t){var e=n;return r;function r(o){e(o||la)}function n(o){var i=[o];e=s,t(c);function s(a){i.push(a)}function c(a){var u=arguments;for(e=da(a)?n:h;i.length;)h(i.shift());function h(d){Di(ha,d,u)}}}}function da(t){return Object.prototype.toString.call(t)==="[object Error]"}function la(){}function ha(t,e){t.apply(null,e)}function pa(t){t===42&&(Di=process.nextTick)}function fa(t,e,r){process.nextTick(function(){t(e,r)})}});var Ni=Be((Ch,Ri)=>{var Cn=Ti(),ma=ge("dgram"),ga=_i(),ya=ge("events"),On=ge("os"),Ln=function(){};Ri.exports=function(t){t||(t={});var e=new ya.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={},c=!1,a=null;if(n==="udp6"&&(!o||!t.interface))throw new Error("For IPv6 multicast you must specify `ip` and `interface`");var u=t.socket||ma.createSocket({type:n,reuseAddr:t.reuseAddr!==!1,toString:function(){return n}});u.on("error",function(d){d.code==="EACCES"||d.code==="EADDRINUSE"?e.emit("error",d):e.emit("warning",d)}),u.on("message",function(d,f){try{d=Cn.decode(d)}catch(l){e.emit("warning",l);return}e.emit("packet",d,f),d.type==="query"&&e.emit("query",d,f),d.type==="response"&&e.emit("response",d,f)}),u.on("listening",function(){r||(r=i.port=u.address().port),t.multicast!==!1&&(e.update(),a=setInterval(e.update,5e3),u.setMulticastTTL(t.ttl||255),u.setMulticastLoopback(t.loopback!==!1))});var h=ga(function(d){if(!r||t.bind===!1)return d(null);u.once("error",d),u.bind(r,t.bind||t.interface,function(){u.removeListener("error",d),d(null)})});return h(function(d){if(d)return e.emit("error",d);e.emit("ready")}),e.send=function(d,f,l){if(typeof f=="function")return e.send(d,null,f);l||(l=Ln),f?!f.host&&!f.address&&(f.address=i.address):f=i,h(p);function p(w){if(c)return l();if(w)return l(w);var S=Cn.encode(d);u.send(S,0,S.length,f.port,f.address||f.host,l)}},e.response=e.respond=function(d,f,l){Array.isArray(d)&&(d={answers:d}),d.type="response",d.flags=(d.flags||0)|Cn.AUTHORITATIVE_ANSWER,e.send(d,f,l)},e.query=function(d,f,l,p){if(typeof f=="function")return e.query(d,null,null,f);if(typeof f=="object"&&f&&f.port)return e.query(d,null,f,l);if(typeof l=="function")return e.query(d,f,null,l);p||(p=Ln),typeof d=="string"&&(d=[{name:d,type:f||"ANY"}]),Array.isArray(d)&&(d={type:"query",questions:d}),d.type="query",e.send(d,l,p)},e.destroy=function(d){if(d||(d=Ln),c)return process.nextTick(d);c=!0,clearInterval(a);for(var f in s)try{u.dropMembership(o,f)}catch{}s={},u.close(d)},e.update=function(){for(var d=t.interface?[].concat(t.interface):ba(),f=!1,l=0;l<d.length;l++){var p=d[l];if(!s[p])try{u.addMembership(o,p),s[p]=!0,f=!0}catch(w){e.emit("warning",w)}}if(f){if(u.setMulticastInterface)try{u.setMulticastInterface(t.interface||wa())}catch(w){e.emit("warning",w)}e.emit("networkInterface")}},e};function wa(){for(var t=On.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(Pi(i.family)&&!i.internal)return On.platform()==="darwin"&&e[r]==="en0"?i.address:"0.0.0.0"}return"127.0.0.1"}function ba(){for(var t=On.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(Pi(s.family)){r.push(s.address);break}}return r}function Pi(t){return t===4||t==="IPv4"}});var ei=Be(Yt=>{"use strict";Object.defineProperty(Yt,"__esModule",{value:!0});Yt.Netmask4Impl=void 0;Yt.ip2long=jt;Yt.long2ip=Ge;function Ge(t){let e=(t&-16777216)>>>24,r=(t&255<<16)>>>16,n=(t&65280)>>>8,o=t&255;return[e,r,n,o].join(".")}var Td=48,Dd=97,Ud=65;function _d(t){let e=0,r=10,n="9",o=0;t.length>1&&t[o]==="0"&&(t[o+1]==="x"||t[o+1]==="X"?(o+=2,r=16):"0"<=t[o+1]&&t[o+1]<="9"&&(o++,r=8,n="7"));let i=o;for(;o<t.length;){if("0"<=t[o]&&t[o]<=n)e=e*r+(t.charCodeAt(o)-Td)>>>0;else if(r===16)if("a"<=t[o]&&t[o]<="f")e=e*r+(10+t.charCodeAt(o)-Dd)>>>0;else if("A"<=t[o]&&t[o]<="F")e=e*r+(10+t.charCodeAt(o)-Ud)>>>0;else break;else break;if(e>4294967295)throw new Error("too large");o++}if(o===i)throw new Error("empty octet");return[e,o]}function jt(t){let e=[];for(let r=0;r<=3&&t.length!==0;r++){if(r>0){if(t[0]!==".")throw new Error("Invalid IP");t=t.substring(1)}let[n,o]=_d(t);t=t.substring(o),e.push(n)}if(t.length!==0)throw new Error("Invalid IP");switch(e.length){case 1:if(e[0]>4294967295)throw new Error("Invalid IP");return e[0]>>>0;case 2:if(e[0]>255||e[1]>16777215)throw new Error("Invalid IP");return(e[0]<<24|e[1])>>>0;case 3:if(e[0]>255||e[1]>255||e[2]>65535)throw new Error("Invalid IP");return(e[0]<<24|e[1]<<16|e[2])>>>0;case 4:if(e[0]>255||e[1]>255||e[2]>255||e[3]>255)throw new Error("Invalid IP");return(e[0]<<24|e[1]<<16|e[2]<<8|e[3])>>>0;default:throw new Error("Invalid IP")}}var Jo=class t{constructor(e,r){if(typeof e!="string")throw new Error("Missing `net' parameter");let n=r;if(!n){let o=e.split("/",2);e=o[0],n=o[1]}if(n||(n=32),typeof n=="string"&&n.indexOf(".")>-1){try{this.maskLong=jt(n)}catch{throw new Error("Invalid mask: "+n)}this.bitmask=NaN;for(let o=32;o>=0;o--)if(this.maskLong===4294967295<<32-o>>>0){this.bitmask=o;break}}else if(n||n===0)this.bitmask=parseInt(n,10),this.maskLong=0,this.bitmask>0&&(this.maskLong=4294967295<<32-this.bitmask>>>0);else throw new Error("Invalid mask: empty");try{this.netLong=(jt(e)&this.maskLong)>>>0}catch{throw new Error("Invalid net address: "+e)}if(!(this.bitmask<=32))throw new Error("Invalid mask for ip4: "+n);this.size=Math.pow(2,32-this.bitmask),this.base=Ge(this.netLong),this.mask=Ge(this.maskLong),this.hostmask=Ge(~this.maskLong),this.first=this.bitmask<=30?Ge(this.netLong+1):this.base,this.last=this.bitmask<=30?Ge(this.netLong+this.size-2):Ge(this.netLong+this.size-1),this.broadcast=this.bitmask<=30?Ge(this.netLong+this.size-1):void 0}contains(e){return typeof e=="string"&&(e.indexOf("/")>0||e.split(".").length!==4)&&(e=new t(e)),e instanceof t?this.contains(e.base)&&this.contains(e.broadcast||e.last):(jt(e)&this.maskLong)>>>0===(this.netLong&this.maskLong)>>>0}next(e=1){return new t(Ge(this.netLong+this.size*e),this.mask)}forEach(e){let r=jt(this.first),n=jt(this.last),o=0;for(;r<=n;)e(Ge(r),r,o),o++,r++}toString(){return this.base+"/"+this.bitmask}};Yt.Netmask4Impl=Jo});var vc=Be(Gt=>{"use strict";Object.defineProperty(Gt,"__esModule",{value:!0});Gt.Netmask6Impl=void 0;Gt.ip6bigint=ri;Gt.bigint2ip6=Ot;var Pd=ei(),ti=(1n<<128n)-1n;function ri(t){let e=t.indexOf("%");e!==-1&&(t=t.substring(0,e));let r=t.lastIndexOf(":");if(r!==-1&&t.indexOf(".",r)!==-1){let n=t.substring(r+1),o=(0,Pd.ip2long)(n),i=t.substring(0,r+1)+"0:0";return Sc(i)&~0xffffffffn|BigInt(o)}return Sc(t)}function Sc(t){let e=t.indexOf("::"),r;if(e!==-1){let o=t.substring(0,e),i=t.substring(e+2),s=o===""?[]:o.split(":"),c=i===""?[]:i.split(":"),a=8-s.length-c.length;if(a<0)throw new Error("Invalid IPv6: too many groups");r=[...s,...Array(a).fill("0"),...c]}else r=t.split(":");if(r.length!==8)throw new Error("Invalid IPv6: expected 8 groups, got "+r.length);let n=0n;for(let o=0;o<8;o++){let i=r[o];if(i.length===0||i.length>4)throw new Error('Invalid IPv6: bad group "'+i+'"');let s=parseInt(i,16);if(isNaN(s)||s<0||s>65535)throw new Error('Invalid IPv6: bad group "'+i+'"');n=n<<16n|BigInt(s)}return n}function Ot(t){if(t<0n||t>ti)throw new Error("Invalid IPv6 address value");let e=[];for(let s=0;s<8;s++)e.unshift(Number(t&0xffffn)),t>>=16n;let r=-1,n=0,o=-1,i=0;for(let s=0;s<8;s++)e[s]===0?o===-1?(o=s,i=1):i++:(i>n&&i>=2&&(r=o,n=i),o=-1,i=0);if(i>n&&i>=2&&(r=o,n=i),r!==-1&&r+n===8&&r>0)return e.slice(0,r).map(c=>c.toString(16)).join(":")+"::";if(r===0)return"::"+e.slice(n).map(c=>c.toString(16)).join(":");if(r>0){let s=e.slice(0,r).map(a=>a.toString(16)),c=e.slice(r+n).map(a=>a.toString(16));return s.join(":")+"::"+c.join(":")}else return e.map(s=>s.toString(16)).join(":")}var ni=class t{constructor(e,r){if(typeof e!="string")throw new Error("Missing `net' parameter");let n=r;if(n==null){let o=e.indexOf("/");o!==-1?(n=parseInt(e.substring(o+1),10),e=e.substring(0,o)):n=128}if(isNaN(n)||n<0||n>128)throw new Error("Invalid mask for IPv6: "+n);this.bitmask=n,this.bitmask===0?this.maskBigint=0n:this.maskBigint=ti>>BigInt(128-this.bitmask)<<BigInt(128-this.bitmask);try{this.netBigint=ri(e)&this.maskBigint}catch{throw new Error("Invalid IPv6 net address: "+e)}this.size=Number(1n<<BigInt(128-this.bitmask)),this.base=Ot(this.netBigint),this.mask=Ot(this.maskBigint),this.hostmask=Ot(~this.maskBigint&ti),this.first=this.base,this.last=Ot(this.netBigint+(1n<<BigInt(128-this.bitmask))-1n),this.broadcast=void 0}contains(e){return typeof e=="string"&&e.indexOf("/")>0&&(e=new t(e)),e instanceof t?this.contains(e.base)&&this.contains(e.last):(ri(e)&this.maskBigint)===this.netBigint}next(e=1){let r=1n<<BigInt(128-this.bitmask);return new t(Ot(this.netBigint+r*BigInt(e)),this.bitmask)}forEach(e){let r=this.netBigint,n=1n<<BigInt(128-this.bitmask),o=this.netBigint+n-1n,i=0;for(;r<=o;)e(Ot(r),Number(r),i),i++,r++}toString(){return this.base+"/"+this.bitmask}};Gt.Netmask6Impl=ni});var Ac=Be(bt=>{"use strict";Object.defineProperty(bt,"__esModule",{value:!0});bt.long2ip=bt.ip2long=bt.Netmask=void 0;var hn=ei();Object.defineProperty(bt,"ip2long",{enumerable:!0,get:function(){return hn.ip2long}});Object.defineProperty(bt,"long2ip",{enumerable:!0,get:function(){return hn.long2ip}});var Rd=vc(),oi=class t{constructor(e,r){if(typeof e!="string")throw new Error("Missing `net' parameter");(e.indexOf("/")!==-1?e.substring(0,e.indexOf("/")):e).indexOf(":")!==-1?this._impl=new Rd.Netmask6Impl(e,r):this._impl=new hn.Netmask4Impl(e,r),this.base=this._impl.base,this.mask=this._impl.mask,this.hostmask=this._impl.hostmask,this.bitmask=this._impl.bitmask,this.size=this._impl.size,this.first=this._impl.first,this.last=this._impl.last,this.broadcast=this._impl.broadcast,this._impl instanceof hn.Netmask4Impl?(this.maskLong=this._impl.maskLong,this.netLong=this._impl.netLong):(this.maskLong=0,this.netLong=0)}contains(e){return typeof e=="string"&&(e.indexOf("/")>0?e=new t(e):e.indexOf(":")===-1&&e.split(".").length!==4&&(e=new t(e))),e instanceof t?this.contains(e.base)&&this.contains(e.broadcast||e.last):this._impl.contains(e)}next(e=1){let r=this._impl.next(e);return new t(r.base,r.bitmask)}forEach(e){this._impl.forEach(e)}toString(){return this._impl.toString()}};bt.Netmask=oi});var Hl={};ye(Hl,{mdns:()=>Ml});var Ce=class extends Error{static name="InvalidParametersError";constructor(e="Invalid parameters"){super(e),this.name="InvalidParametersError"}},Ar=class extends Error{static name="InvalidPublicKeyError";constructor(e="Invalid public key"){super(e),this.name="InvalidPublicKeyError"}};var Br=class extends Error{static name="InvalidCIDError";constructor(e="Invalid CID"){super(e),this.name="InvalidCIDError"}},Cr=class extends Error{static name="InvalidMultihashError";constructor(e="Invalid Multihash"){super(e),this.name="InvalidMultihashError"}};var Qt=class extends Error{static name="UnsupportedKeyTypeError";constructor(e="Unsupported key type"){super(e),this.name="UnsupportedKeyTypeError"}};var gi=Symbol.for("@libp2p/peer-discovery");var yn=Symbol.for("@libp2p/peer-id");var yi=ge("node:events"),wi=(t,...e)=>{try{(0,yi.setMaxListeners)(t,...e)}catch{}};function ea(t){return typeof t?.handleEvent=="function"}function ta(t){return(t!==!0&&t!==!1&&t?.once)??!1}var Lr=class extends EventTarget{#e=new Map;constructor(){super(),wi(1/0,this)}listenerCount(e){let r=this.#e.get(e);return r==null?0:r.length}addEventListener(e,r,n){let o=ta(n);super.addEventListener(e,s=>{if(o){let c=this.#e.get(s.type);c!=null&&(c=c.filter(({callback:a})=>a!==r),this.#e.set(s.type,c))}ea(r)?r.handleEvent(s):r(s)},n);let i=this.#e.get(e);i==null&&(i=[],this.#e.set(e,i)),i.push({callback:r,once:o})}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))}safeDispatchEvent(e,r={}){return this.dispatchEvent(new CustomEvent(e,r))}};var bi=Symbol.for("@libp2p/service-capabilities");var Yc=Zt(Ni(),1);var Pn={};ye(Pn,{base58btc:()=>Y,base58flickr:()=>Ca});var Lh=new Uint8Array(0);function ki(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 de(t){if(t instanceof Uint8Array&&t.constructor.name==="Uint8Array")return Et(t);if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return Et(new Uint8Array(t.buffer,t.byteOffset,t.byteLength));throw new Error("Unknown type, must be binary type")}function Ki(t){let e=new Uint8Array(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}var Fi=4096;function Mi(t){let e=t.length;if(e<=Fi)return String.fromCharCode.apply(String,t);let r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.subarray(n,n+=Fi));return r}function xa(t){return t?.buffer instanceof ArrayBuffer}function Et(t){return xa(t)?t:t.slice()}function Ea(t,e,r){if(t.length>=255)throw new TypeError("Alphabet too long");for(var n=new Uint8Array(256),o=0;o<n.length;o++)n[o]=255;for(var i=0;i<t.length;i++){var s=t.charAt(i),c=s.charCodeAt(0);if(n[c]!==255)throw new TypeError(s+" is ambiguous");if(n[c]=i,r){var a=s.toLowerCase().charCodeAt(0),u=s.toUpperCase().charCodeAt(0);a!==c&&(n[a]=i),u!==c&&(n[u]=i)}}var h=t.length,d=t.charAt(0),f=Math.log(h)/Math.log(256),l=Math.log(256)/Math.log(h);function p(x){if(x instanceof Uint8Array||(ArrayBuffer.isView(x)?x=new Uint8Array(x.buffer,x.byteOffset,x.byteLength):Array.isArray(x)&&(x=Uint8Array.from(x))),!(x instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(x.length===0)return"";for(var O=0,H=0,K=0,P=x.length;K!==P&&x[K]===0;)K++,O++;for(var F=(P-K)*l+1>>>0,W=new Uint8Array(F);K!==P;){for(var U=x[K],ae=0,$=F-1;(U!==0||ae<H)&&$!==-1;$--,ae++)U+=256*W[$]>>>0,W[$]=U%h>>>0,U=U/h>>>0;if(U!==0)throw new Error("Non-zero carry");H=ae,K++}for(var N=F-H;N!==F&&W[N]===0;)N++;for(var g=d.repeat(O);N<F;++N)g+=t.charAt(W[N]);return g}function w(x){if(typeof x!="string")throw new TypeError("Expected String");if(x.length===0)return new Uint8Array;var O=0;if(x[O]!==" "){for(var H=0,K=0;x[O]===d;)H++,O++;for(var P=(x.length-O)*f+1>>>0,F=new Uint8Array(P);x[O];){var W=n[x.charCodeAt(O)];if(W===255)return;for(var U=0,ae=P-1;(W!==0||U<K)&&ae!==-1;ae--,U++)W+=h*F[ae]>>>0,F[ae]=W%256>>>0,W=W/256>>>0;if(W!==0)throw new Error("Non-zero carry");K=U,O++}if(x[O]!==" "){for(var $=P-K;$!==P&&F[$]===0;)$++;for(var N=new Uint8Array(H+(P-$)),g=H;$!==P;)N[g++]=F[$++];return N}}}function S(x){var O=w(x);if(O)return O;throw new Error(`Non-${e} character`)}return{encode:p,decodeUnsafe:w,decode:S}}var Ia=Ea,Sa=Ia,qi=Sa;var Tn=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")}},Dn=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 Vi(this,e)}},Un=class{decoders;constructor(e){this.decoders=e}or(e){return Vi(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 Vi(t,e){return new Un({...t.decoders??{[t.prefix]:t},...e.decoders??{[e.prefix]:e}})}var _n=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 Tn(e,r,n),this.decoder=new Dn(e,r,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};function _t({name:t,prefix:e,encode:r,decode:n}){return new _n(t,e,r,n)}function lt({name:t,prefix:e,alphabet:r,caseInsensitive:n=!1}){let{encode:o,decode:i}=qi(r,t,n);return _t({prefix:e,name:t,encode:o,decode:s=>de(i(s))})}function va(t,e,r,n){let o=t.length;for(;t[o-1]==="=";)--o;let i=new Uint8Array(o*r/8|0),s=0,c=0,a=0;for(let u=0;u<o;++u){let h=e[t[u]];if(h===void 0)throw new SyntaxError(`Non-${n} character`);c=c<<r|h,s+=r,s>=8&&(s-=8,i[a++]=255&c>>s)}if(s>=r||(255&c<<8-s)!==0)throw new SyntaxError("Unexpected end of data");return i}function Aa(t,e,r){let n=e[e.length-1]==="=",o=(1<<r)-1,i="",s=0,c=0;for(let a=0;a<t.length;++a)for(c=c<<8|t[a],s+=8;s>r;)s-=r,i+=e[o&c>>s];if(s!==0&&(i+=e[o&c<<r-s]),n)for(;(i.length*r&7)!==0;)i+="=";return i}function Ba(t,e){let r={};for(let n=0;n<t.length;++n)if(r[t[n]]=n,e){let o=t[n].toLowerCase(),i=t[n].toUpperCase();o!==t[n]&&(r[o]=n),i!==t[n]&&(r[i]=n)}return r}function V({name:t,prefix:e,bitsPerChar:r,alphabet:n,caseInsensitive:o=!1}){let i=Ba(n,o);return _t({prefix:e,name:t,encode(s){return Aa(s,n,r)},decode(s){return va(s,i,r,t)}})}var Y=lt({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Ca=lt({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Rn={};ye(Rn,{base32:()=>ht,base32hex:()=>Da,base32hexpad:()=>_a,base32hexpadupper:()=>Pa,base32hexupper:()=>Ua,base32pad:()=>Oa,base32padupper:()=>Ta,base32upper:()=>La,base32z:()=>Ra});var ht=V({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5,caseInsensitive:!0}),La=V({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5,caseInsensitive:!0}),Oa=V({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5,caseInsensitive:!0}),Ta=V({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5,caseInsensitive:!0}),Da=V({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5,caseInsensitive:!0}),Ua=V({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5,caseInsensitive:!0}),_a=V({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5,caseInsensitive:!0}),Pa=V({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5,caseInsensitive:!0}),Ra=V({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Nn={};ye(Nn,{base36:()=>er,base36upper:()=>Na});var er=lt({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz",caseInsensitive:!0}),Na=lt({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ",caseInsensitive:!0});var Fa=ji,zi=128,ka=127,Ka=~ka,Ma=Math.pow(2,31);function ji(t,e,r){e=e||[],r=r||0;for(var n=r;t>=Ma;)e[r++]=t&255|zi,t/=128;for(;t&Ka;)e[r++]=t&255|zi,t>>>=7;return e[r]=t|0,ji.bytes=r-n+1,e}var Ha=Fn,qa=128,$i=127;function Fn(t,n){var r=0,n=n||0,o=0,i=n,s,c=t.length;do{if(i>=c)throw Fn.bytes=0,new RangeError("Could not decode varint");s=t[i++],r+=o<28?(s&$i)<<o:(s&$i)*Math.pow(2,o),o+=7}while(s>=qa);return Fn.bytes=i-n,r}var Va=Math.pow(2,7),za=Math.pow(2,14),$a=Math.pow(2,21),ja=Math.pow(2,28),Ya=Math.pow(2,35),Ga=Math.pow(2,42),Wa=Math.pow(2,49),Xa=Math.pow(2,56),Za=Math.pow(2,63),Qa=function(t){return t<Va?1:t<za?2:t<$a?3:t<ja?4:t<Ya?5:t<Ga?6:t<Wa?7:t<Xa?8:t<Za?9:10},Ja={encode:Fa,decode:Ha,encodingLength:Qa},eu=Ja,tr=eu;function rr(t,e=0){return[tr.decode(t,e),tr.decode.bytes]}function Pt(t,e,r=0){return tr.encode(t,e,r),e}function Rt(t){return tr.encodingLength(t)}function Ft(t,e){let r=e.byteLength,n=Rt(t),o=n+Rt(r),i=new Uint8Array(o+r);return Pt(t,i,0),Pt(r,i,n),i.set(e,o),new Nt(t,r,e,i)}function nr(t){let e=de(t),[r,n]=rr(e),[o,i]=rr(e.subarray(n)),s=e.subarray(n+i);if(s.byteLength!==o)throw new Error("Incorrect length");return new Nt(r,o,s,e)}function Yi(t,e){if(t===e)return!0;{let r=e;return t.code===r.code&&t.size===r.size&&r.bytes instanceof Uint8Array&&ki(t.bytes,r.bytes)}}var Nt=class{code;size;digest;bytes;constructor(e,r,n,o){this.code=e,this.size=r,this.digest=Et(n),this.bytes=Et(o)}};function Gi(t,e){let{bytes:r,version:n}=t;return n===0?ru(r,kn(t),e??Y.encoder):nu(r,kn(t),e??ht.encoder)}var Wi=new WeakMap;function kn(t){let e=Wi.get(t);if(e==null){let r=new Map;return Wi.set(t,r),r}return e}var ne=class t{code;version;multihash;bytes;"/";constructor(e,r,n,o){this.code=r,this.version=e,this.multihash=n,this.bytes=Et(o),this["/"]=this.bytes}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!==or)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==ou)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=Ft(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&&Yi(e.multihash,n.multihash)}toString(e){return Gi(this,e)}toJSON(){return{"/":Gi(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??Xi(n,o,i.bytes))}else if(r[iu]===!0){let{version:n,multihash:o,code:i}=r,s=nr(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!==or)throw new Error(`Version 0 CID must use dag-pb (code: ${or}) block encoding`);return new t(e,r,n,n.bytes)}case 1:{let o=Xi(e,r,n.bytes);return new t(e,r,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return t.create(0,or,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=de(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 Nt(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[d,f]=rr(e.subarray(r));return r+=f,d},o=n(),i=or;if(o===18?(o=0,r=0):i=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let s=r,c=n(),a=n(),u=r+a,h=u-s;return{version:o,codec:i,multihashCode:c,digestSize:a,multihashSize:h,size:u}}static parse(e,r){let[n,o]=tu(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 kn(i).set(n,e),i}};function tu(t,e){switch(t[0]){case"Q":{let r=e??Y;return[Y.prefix,r.decode(`${Y.prefix}${t}`)]}case Y.prefix:{let r=e??Y;return[Y.prefix,r.decode(t)]}case ht.prefix:{let r=e??ht;return[ht.prefix,r.decode(t)]}case er.prefix:{let r=e??er;return[er.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 ru(t,e,r){let{prefix:n}=r;if(n!==Y.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 nu(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 or=112,ou=18;function Xi(t,e,r){let n=Rt(t),o=n+Rt(e),i=new Uint8Array(o+r.byteLength);return Pt(t,i,0),Pt(e,i,n),i.set(r,o),i}var iu=Symbol.for("@ipld/js-cid/CID");var Kn={};ye(Kn,{identity:()=>De});var Zi=0,su="identity",Qi=de;function cu(t,e){if(e?.truncate!=null&&e.truncate!==t.byteLength){if(e.truncate<0||e.truncate>t.byteLength)throw new Error(`Invalid truncate option, must be less than or equal to ${t.byteLength}`);t=t.subarray(0,e.truncate)}return Ft(Zi,Qi(t))}var De={code:Zi,name:su,encode:Qi,digest:cu};function me(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 au(t){return t.buffer instanceof ArrayBuffer}function pt(t){return au(t)?t:t.slice()}async function Ji(t,e,r,n){let o=await crypto.subtle.importKey("jwk",t,{name:"ECDSA",namedCurve:t.crv??"P-256"},!1,["verify"]);n?.signal?.throwIfAborted();let i=await crypto.subtle.verify({name:"ECDSA",hash:{name:"SHA-256"}},o,pt(e),pt(r.subarray()));return n?.signal?.throwIfAborted(),i}var Mn=ge("node:buffer");function ft(t){if(t.buffer instanceof ArrayBuffer)return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);let e=t.slice();return new Uint8Array(e.buffer,0,e.byteLength)}function ze(t=0){return ft(Mn.Buffer.alloc(t))}function Ee(t=0){return ft(Mn.Buffer.allocUnsafe(t))}var es=ge("node:buffer");function Ue(t,e){return ft(es.Buffer.concat(t,e))}var rs=Symbol.for("@achingbrain/uint8arraylist");function ts(t,e){if(e==null||e<0)throw new RangeError("index is out of bounds");let r=0;for(let n of t){let o=r+n.byteLength;if(e<o)return{buf:n,index:e-r};r=o}throw new RangeError("index is out of bounds")}function Ur(t){return!!t?.[rs]}var Ie=class t{bufs;length;[rs]=!0;constructor(...e){this.bufs=[],this.length=0,e.length>0&&this.appendAll(e)}*[Symbol.iterator](){yield*this.bufs}get byteLength(){return this.length}append(...e){this.appendAll(e)}appendAll(e){let r=0;for(let n of e)if(n instanceof Uint8Array)r+=n.byteLength,this.bufs.push(n);else if(Ur(n)){r+=n.byteLength;for(let o of n.bufs)this.bufs.push(o)}else throw new Error("Could not append value, must be an Uint8Array or a Uint8ArrayList");this.length+=r}prepend(...e){this.prependAll(e)}prependAll(e){let r=0;for(let n of e.reverse())if(n instanceof Uint8Array)r+=n.byteLength,this.bufs.unshift(n);else if(Ur(n))r+=n.byteLength,this.bufs.unshift(...n.bufs);else throw new Error("Could not prepend value, must be an Uint8Array or a Uint8ArrayList");this.length+=r}get(e){let r=ts(this.bufs,e);return r.buf[r.index]}set(e,r){let n=ts(this.bufs,e);n.buf[n.index]=r}write(e,r=0){if(e instanceof Uint8Array)for(let n=0;n<e.length;n++)this.set(r+n,e[n]);else if(Ur(e))for(let n=0;n<e.length;n++)this.set(r+n,e.get(n));else throw new Error("Could not write value, must be an Uint8Array or a Uint8ArrayList")}consume(e){if(e=Math.trunc(e),!(Number.isNaN(e)||e<=0)){if(e===this.byteLength){this.bufs=[],this.length=0;return}for(;this.bufs.length>0;)if(e>=this.bufs[0].byteLength)e-=this.bufs[0].byteLength,this.length-=this.bufs[0].byteLength,this.bufs.shift();else{this.bufs[0]=this.bufs[0].subarray(e),this.length-=e;break}}}slice(e,r){let{bufs:n,length:o}=this._subList(e,r);return Ue(n,o)}subarray(e,r){let{bufs:n,length:o}=this._subList(e,r);return n.length===1?n[0]:Ue(n,o)}sublist(e,r){let{bufs:n,length:o}=this._subList(e,r),i=new t;return i.length=o,i.bufs=n,i}_subList(e,r){if(e=e??0,r=r??this.length,e<0&&(e=this.length+e),r<0&&(r=this.length+r),e<0||r>this.length)throw new RangeError("index is out of bounds");if(e===r)return{bufs:[],length:0};if(e===0&&r===this.length)return{bufs:[...this.bufs],length:this.length};let n=[],o=0;for(let i=0;i<this.bufs.length;i++){let s=this.bufs[i],c=o,a=c+s.byteLength;if(o=a,e>=a)continue;let u=e>=c&&e<a,h=r>c&&r<=a;if(u&&h){if(e===c&&r===a){n.push(s);break}let d=e-c;n.push(s.subarray(d,d+(r-e)));break}if(u){if(e===0){n.push(s);continue}n.push(s.subarray(e-c));continue}if(h){if(r===a){n.push(s);break}n.push(s.subarray(0,r-c));break}n.push(s)}return{bufs:n,length:r-e}}indexOf(e,r=0){if(!Ur(e)&&!(e instanceof Uint8Array))throw new TypeError('The "value" argument must be a Uint8ArrayList or Uint8Array');let n=e instanceof Uint8Array?e:e.subarray();if(r=Number(r??0),isNaN(r)&&(r=0),r<0&&(r=this.length+r),r<0&&(r=0),e.length===0)return r>this.length?this.length:r;let o=n.byteLength;if(o===0)throw new TypeError("search must be at least 1 byte long");let i=256,s=new Int32Array(i);for(let d=0;d<i;d++)s[d]=-1;for(let d=0;d<o;d++)s[n[d]]=d;let c=s,a=this.byteLength-n.byteLength,u=n.byteLength-1,h;for(let d=r;d<=a;d+=h){h=0;for(let f=u;f>=0;f--){let l=this.get(d+f);if(n[f]!==l){h=Math.max(1,f-c[l]);break}}if(h===0)return d}return-1}getInt8(e){let r=this.subarray(e,e+1);return new DataView(r.buffer,r.byteOffset,r.byteLength).getInt8(0)}setInt8(e,r){let n=Ee(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setInt8(0,r),this.write(n,e)}getInt16(e,r){let n=this.subarray(e,e+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt16(0,r)}setInt16(e,r,n){let o=ze(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt16(0,r,n),this.write(o,e)}getInt32(e,r){let n=this.subarray(e,e+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt32(0,r)}setInt32(e,r,n){let o=ze(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt32(0,r,n),this.write(o,e)}getBigInt64(e,r){let n=this.subarray(e,e+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigInt64(0,r)}setBigInt64(e,r,n){let o=ze(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigInt64(0,r,n),this.write(o,e)}getUint8(e){let r=this.subarray(e,e+1);return new DataView(r.buffer,r.byteOffset,r.byteLength).getUint8(0)}setUint8(e,r){let n=Ee(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setUint8(0,r),this.write(n,e)}getUint16(e,r){let n=this.subarray(e,e+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint16(0,r)}setUint16(e,r,n){let o=ze(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint16(0,r,n),this.write(o,e)}getUint32(e,r){let n=this.subarray(e,e+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint32(0,r)}setUint32(e,r,n){let o=ze(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint32(0,r,n),this.write(o,e)}getBigUint64(e,r){let n=this.subarray(e,e+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigUint64(0,r)}setBigUint64(e,r,n){let o=ze(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigUint64(0,r,n),this.write(o,e)}getFloat32(e,r){let n=this.subarray(e,e+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat32(0,r)}setFloat32(e,r,n){let o=ze(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat32(0,r,n),this.write(o,e)}getFloat64(e,r){let n=this.subarray(e,e+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat64(0,r)}setFloat64(e,r,n){let o=ze(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat64(0,r,n),this.write(o,e)}equals(e){if(e==null||!(e instanceof t)||e.bufs.length!==this.bufs.length)return!1;for(let r=0;r<this.bufs.length;r++)if(!me(this.bufs[r],e.bufs[r]))return!1;return!0}static fromUint8Arrays(e,r){let n=new t;return n.bufs=e,r==null&&(r=e.reduce((o,i)=>o+i.byteLength,0)),n.length=r,n}};var as=ge("node:buffer");var Hn={};ye(Hn,{base10:()=>uu});var uu=lt({prefix:"9",name:"base10",alphabet:"0123456789"});var qn={};ye(qn,{base16:()=>du,base16upper:()=>lu});var du=V({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4,caseInsensitive:!0}),lu=V({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4,caseInsensitive:!0});var Vn={};ye(Vn,{base2:()=>hu});var hu=V({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var zn={};ye(zn,{base256emoji:()=>yu});var ns=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}"),pu=ns.reduce((t,e,r)=>(t[r]=e,t),[]),fu=ns.reduce((t,e,r)=>{let n=e.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${e}`);return t[n]=r,t},[]);function mu(t){return t.reduce((e,r)=>(e+=pu[r],e),"")}function gu(t){let e=[];for(let r of t){let n=r.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${r}`);let o=fu[n];if(o==null)throw new Error(`Non-base256emoji character: ${r}`);e.push(o)}return new Uint8Array(e)}var yu=_t({prefix:"\u{1F680}",name:"base256emoji",encode:mu,decode:gu});var jn={};ye(jn,{base64:()=>wu,base64pad:()=>bu,base64url:()=>$n,base64urlpad:()=>xu});var wu=V({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),bu=V({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),$n=V({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),xu=V({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Yn={};ye(Yn,{base8:()=>Eu});var Eu=V({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Gn={};ye(Gn,{identity:()=>Iu});var Iu=_t({prefix:"\0",name:"identity",encode:t=>Mi(de(t)),decode:t=>de(Ki(t))});var pp=new TextEncoder,fp=new TextDecoder;var Jn={};ye(Jn,{sha256:()=>Qn,sha512:()=>Bu});var Zn=Zt(ge("node:crypto"),1);var Au=20;function Xn({name:t,code:e,encode:r,minDigestLength:n,maxDigestLength:o}){return new Wn(t,e,r,n,o)}var Wn=class{name;code;encode;minDigestLength;maxDigestLength;constructor(e,r,n,o,i){this.name=e,this.code=r,this.encode=n,this.minDigestLength=o??Au,this.maxDigestLength=i}digest(e,r){if(r?.truncate!=null){if(r.truncate<this.minDigestLength)throw new Error(`Invalid truncate option, must be greater than or equal to ${this.minDigestLength}`);if(this.maxDigestLength!=null&&r.truncate>this.maxDigestLength)throw new Error(`Invalid truncate option, must be less than or equal to ${this.maxDigestLength}`)}if(e instanceof Uint8Array){let n=this.encode(e);return n instanceof Uint8Array?os(n,this.code,r?.truncate):n.then(o=>os(o,this.code,r?.truncate))}else throw Error("Unknown type, must be binary type")}};function os(t,e,r){if(r!=null&&r!==t.byteLength){if(r>t.byteLength)throw new Error(`Invalid truncate option, must be less than or equal to ${t.byteLength}`);t=t.subarray(0,r)}return Ft(e,t)}var Qn=Xn({name:"sha2-256",code:18,encode:t=>de(Zn.default.createHash("sha256").update(t).digest())}),Bu=Xn({name:"sha2-512",code:19,encode:t=>de(Zn.default.createHash("sha512").update(t).digest())});var ir={...Gn,...Vn,...Yn,...Hn,...qn,...Rn,...Nn,...Pn,...jn,...zn},Cp={...Jn,...Kn};function cs(t,e,r,n){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:n}}}var ss=cs("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),eo=cs("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=Ee(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}),Cu={utf8:ss,"utf-8":ss,hex:ir.base16,latin1:eo,ascii:eo,binary:eo,...ir},_r=Cu;function le(t,e="utf8"){let r=_r[e];if(r==null)throw new Error(`Unsupported encoding "${e}"`);return e==="utf8"||e==="utf-8"?ft(as.Buffer.from(t,"utf-8")):r.decoder.decode(`${r.prefix}${t}`)}var us=ge("node:buffer");function z(t,e="utf8"){let r=_r[e];if(r==null)throw new Error(`Unsupported encoding "${e}"`);return e==="utf8"||e==="utf-8"?us.Buffer.from(t.buffer,t.byteOffset,t.byteLength).toString("utf8"):r.encoder.encode(t).substring(1)}var Lu=parseInt("11111",2),to=parseInt("10000000",2),Ou=parseInt("01111111",2),ds={0:sr,1:sr,2:Tu,3:_u,4:Pu,5:Uu,6:Du,16:sr,22:sr,48:sr};function ro(t,e={offset:0}){let r=t[e.offset]&Lu;if(e.offset++,ds[r]!=null)return ds[r](t,e);throw new Error("No decoder for tag "+r)}function cr(t,e){let r=0;if((t[e.offset]&to)===to){let n=t[e.offset]&Ou,o="0x";e.offset++;for(let i=0;i<n;i++,e.offset++)o+=t[e.offset].toString(16).padStart(2,"0");r=parseInt(o,16)}else r=t[e.offset],e.offset++;return r}function sr(t,e){cr(t,e);let r=[];for(;!(e.offset>=t.byteLength);){let n=ro(t,e);if(n===null)break;r.push(n)}return r}function Tu(t,e){let r=cr(t,e),n=e.offset,o=e.offset+r,i=[];for(let s=n;s<o;s++)s===n&&t[s]===0||i.push(t[s]);return e.offset+=r,Uint8Array.from(i)}function Du(t,e){let r=cr(t,e),n=e.offset+r,o=t[e.offset];e.offset++;let i=0,s=0;o<40?(i=0,s=o):o<80?(i=1,s=o-40):(i=2,s=o-80);let c=`${i}.${s}`,a=[];for(;e.offset<n;){let u=t[e.offset];if(e.offset++,a.push(u&127),u<128){a.reverse();let h=0;for(let d=0;d<a.length;d++)h+=a[d]<<d*7;c+=`.${h}`,a=[]}}return c}function Uu(t,e){return e.offset++,null}function _u(t,e){let r=cr(t,e),n=t[e.offset];e.offset++;let o=t.subarray(e.offset,e.offset+r-1);if(e.offset+=r,n!==0)throw new Error("Unused bits in bit string is unimplemented");return o}function Pu(t,e){let r=cr(t,e),n=t.subarray(e.offset,e.offset+r);return e.offset+=r,n}function Ru(t){let e=t.toString(16);e.length%2===1&&(e="0"+e);let r=new Ie;for(let n=0;n<e.length;n+=2)r.append(Uint8Array.from([parseInt(`${e[n]}${e[n+1]}`,16)]));return r}function no(t){if(t.byteLength<128)return Uint8Array.from([t.byteLength]);let e=Ru(t.byteLength);return new Ie(Uint8Array.from([e.byteLength|to]),e)}function ls(t){let e=new Ie,r=128;return(t.subarray()[0]&r)===r&&e.append(Uint8Array.from([0])),e.append(t),new Ie(Uint8Array.from([2]),no(e),e)}function hs(t){let e=Uint8Array.from([0]),r=new Ie(e,t);return new Ie(Uint8Array.from([3]),no(r),r)}function Pr(t,e=48){let r=new Ie;for(let n of t)r.append(n);return new Ie(Uint8Array.from([e]),no(r),r)}var Nu=Uint8Array.from([6,8,42,134,72,206,61,3,1,7]),Fu=Uint8Array.from([6,5,43,129,4,0,34]),ku=Uint8Array.from([6,5,43,129,4,0,35]),Ku={ext:!0,kty:"EC",crv:"P-256"},Mu={ext:!0,kty:"EC",crv:"P-384"},Hu={ext:!0,kty:"EC",crv:"P-521"},oo=32,io=48,so=66;function ps(t){let e=ro(t);return fs(e)}function fs(t){let e=t[1][1][0],r=1,n,o;if(e.byteLength===oo*2+1)return n=z(e.subarray(r,r+oo),"base64url"),o=z(e.subarray(r+oo),"base64url"),new Kt({...Ku,key_ops:["verify"],x:n,y:o});if(e.byteLength===io*2+1)return n=z(e.subarray(r,r+io),"base64url"),o=z(e.subarray(r+io),"base64url"),new Kt({...Mu,key_ops:["verify"],x:n,y:o});if(e.byteLength===so*2+1)return n=z(e.subarray(r,r+so),"base64url"),o=z(e.subarray(r+so),"base64url"),new Kt({...Hu,key_ops:["verify"],x:n,y:o});throw new Ce(`coordinates were wrong length, got ${e.byteLength}, expected 65, 97 or 133`)}function ms(t){return Pr([ls(Uint8Array.from([1])),Pr([qu(t.crv)],160),Pr([hs(new Ie(Uint8Array.from([4]),le(t.x??"","base64url"),le(t.y??"","base64url")))],161)]).subarray()}function qu(t){if(t==="P-256")return Nu;if(t==="P-384")return Fu;if(t==="P-521")return ku;throw new Ce(`Invalid curve ${t}`)}var Kt=class{type="ECDSA";jwk;_raw;constructor(e){this.jwk=e}get raw(){return this._raw==null&&(this._raw=ms(this.jwk)),this._raw}toMultihash(){return De.digest(Mt(this))}toCID(){return ne.createV1(114,this.toMultihash())}toString(){return Y.encode(this.toMultihash().bytes).substring(1)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:me(this.raw,e.raw)}async verify(e,r,n){return Ji(this.jwk,r,e,n)}};var Gr=Zt(ge("crypto"),1);function co(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"&&"BYTES_PER_ELEMENT"in t&&t.BYTES_PER_ELEMENT===1}function mt(t,e=""){if(typeof t!="number"){let r=e&&`"${e}" `;throw new TypeError(`${r}expected number, got ${typeof t}`)}if(!Number.isSafeInteger(t)||t<0){let r=e&&`"${e}" `;throw new RangeError(`${r}expected integer >= 0, got ${t}`)}}function $e(t,e,r=""){let n=co(t),o=t?.length,i=e!==void 0;if(!n||i&&o!==e){let s=r&&`"${r}" `,c=i?` of length ${e}`:"",a=n?`length=${o}`:`type=${typeof t}`,u=s+"expected Uint8Array"+c+", got "+a;throw n?new RangeError(u):new TypeError(u)}return t}function Rr(t){if(typeof t!="function"||typeof t.create!="function")throw new TypeError("Hash must wrapped by utils.createHasher");if(mt(t.outputLen),mt(t.blockLen),t.outputLen<1)throw new Error('"outputLen" must be >= 1');if(t.blockLen<1)throw new Error('"blockLen" must be >= 1')}function Ht(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 Nr(t,e){$e(t,void 0,"digestInto() output");let r=e.outputLen;if(t.length<r)throw new RangeError('"digestInto() output" expected to be of length >='+r)}function It(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}function Fr(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function _e(t,e){return t<<32-e|t>>>e}var ys=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",Vu=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function kr(t){if($e(t),ys)return t.toHex();let e="";for(let r=0;r<t.length;r++)e+=Vu[t[r]];return e}var it={_0:48,_9:57,A:65,F:70,a:97,f:102};function gs(t){if(t>=it._0&&t<=it._9)return t-it._0;if(t>=it.A&&t<=it.F)return t-(it.A-10);if(t>=it.a&&t<=it.f)return t-(it.a-10)}function ao(t){if(typeof t!="string")throw new TypeError("hex string expected, got "+typeof t);if(ys)try{return Uint8Array.fromHex(t)}catch(o){throw o instanceof SyntaxError?new RangeError(o.message):o}let e=t.length,r=e/2;if(e%2)throw new RangeError("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=gs(t.charCodeAt(i)),c=gs(t.charCodeAt(i+1));if(s===void 0||c===void 0){let a=t[i]+t[i+1];throw new RangeError('hex string expected, got non-hex character "'+a+'" at index '+i)}n[o]=s*16+c}return n}function ws(...t){let e=0;for(let n=0;n<t.length;n++){let o=t[n];$e(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 bs(t,e={}){let r=(o,i)=>t(i).update(o).digest(),n=t(void 0);return r.outputLen=n.outputLen,r.blockLen=n.blockLen,r.canXOF=n.canXOF,r.create=o=>t(o),Object.assign(r,e),Object.freeze(r)}function xs(t=32){mt(t,"bytesLength");let e=typeof globalThis=="object"?globalThis.crypto:null;if(typeof e?.getRandomValues!="function")throw new Error("crypto.getRandomValues must be defined");if(t>65536)throw new RangeError(`"bytesLength" expected <= 65536, got ${t}`);return e.getRandomValues(new Uint8Array(t))}var Es=t=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,t])});function Is(t,e,r){return t&e^~t&r}function Ss(t,e,r){return t&e^t&r^e&r}var Kr=class{blockLen;outputLen;canXOF=!1;padOffset;isLE;buffer;view;finished=!1;length=0;pos=0;destroyed=!1;constructor(e,r,n,o){this.blockLen=e,this.outputLen=r,this.padOffset=n,this.isLE=o,this.buffer=new Uint8Array(e),this.view=Fr(this.buffer)}update(e){Ht(this),$e(e);let{view:r,buffer:n,blockLen:o}=this,i=e.length;for(let s=0;s<i;){let c=Math.min(o-this.pos,i-s);if(c===o){let a=Fr(e);for(;o<=i-s;s+=o)this.process(a,s);continue}n.set(e.subarray(s,s+c),this.pos),this.pos+=c,s+=c,this.pos===o&&(this.process(r,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){Ht(this),Nr(e,this),this.finished=!0;let{buffer:r,view:n,blockLen:o,isLE:i}=this,{pos:s}=this;r[s++]=128,It(this.buffer.subarray(s)),this.padOffset>o-s&&(this.process(n,0),s=0);for(let d=s;d<o;d++)r[d]=0;n.setBigUint64(o-8,BigInt(this.length*8),i),this.process(n,0);let c=Fr(e),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen must be aligned to 32bit");let u=a/4,h=this.get();if(u>h.length)throw new Error("_sha2: outputLen bigger than state");for(let d=0;d<u;d++)c.setUint32(4*d,h[d],i)}digest(){let{buffer:e,outputLen:r}=this;this.digestInto(e);let n=e.slice(0,r);return this.destroy(),n}_cloneInto(e){e||=new this.constructor,e.set(...this.get());let{blockLen:r,buffer:n,length:o,finished:i,destroyed:s,pos:c}=this;return e.destroyed=s,e.finished=i,e.length=o,e.pos=c,o%r&&e.buffer.set(n),e}clone(){return this._cloneInto()}},st=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var zu=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),gt=new Uint32Array(64),uo=class extends Kr{constructor(e){super(64,e,8,!1)}get(){let{A:e,B:r,C:n,D:o,E:i,F:s,G:c,H:a}=this;return[e,r,n,o,i,s,c,a]}set(e,r,n,o,i,s,c,a){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=c|0,this.H=a|0}process(e,r){for(let d=0;d<16;d++,r+=4)gt[d]=e.getUint32(r,!1);for(let d=16;d<64;d++){let f=gt[d-15],l=gt[d-2],p=_e(f,7)^_e(f,18)^f>>>3,w=_e(l,17)^_e(l,19)^l>>>10;gt[d]=w+gt[d-7]+p+gt[d-16]|0}let{A:n,B:o,C:i,D:s,E:c,F:a,G:u,H:h}=this;for(let d=0;d<64;d++){let f=_e(c,6)^_e(c,11)^_e(c,25),l=h+f+Is(c,a,u)+zu[d]+gt[d]|0,w=(_e(n,2)^_e(n,13)^_e(n,22))+Ss(n,o,i)|0;h=u,u=a,a=c,c=s+l|0,s=i,i=o,o=n,n=l+w|0}n=n+this.A|0,o=o+this.B|0,i=i+this.C|0,s=s+this.D|0,c=c+this.E|0,a=a+this.F|0,u=u+this.G|0,h=h+this.H|0,this.set(n,o,i,s,c,a,u,h)}roundClean(){It(gt)}destroy(){this.destroyed=!0,this.set(0,0,0,0,0,0,0,0),It(this.buffer)}},lo=class extends uo{A=st[0]|0;B=st[1]|0;C=st[2]|0;D=st[3]|0;E=st[4]|0;F=st[5]|0;G=st[6]|0;H=st[7]|0;constructor(){super(32)}};var vs=bs(()=>new lo,Es(1));var Z=(t,e,r)=>$e(t,e,r),po=mt,fo=kr,ct=(...t)=>ws(...t),qr=t=>ao(t),mo=co,go=t=>xs(t),Hr=BigInt(0),ho=BigInt(1);function St(t,e=""){if(typeof t!="boolean"){let r=e&&`"${e}" `;throw new TypeError(r+"expected boolean, got type="+typeof t)}return t}function Vr(t){if(typeof t=="bigint"){if(!Mr(t))throw new RangeError("positive bigint expected, got "+t)}else po(t);return t}function ar(t,e=""){if(typeof t!="number"){let r=e&&`"${e}" `;throw new TypeError(r+"expected number, got type="+typeof t)}if(!Number.isSafeInteger(t)){let r=e&&`"${e}" `;throw new RangeError(r+"expected safe integer, got "+t)}}function ur(t){let e=Vr(t).toString(16);return e.length&1?"0"+e:e}function As(t){if(typeof t!="string")throw new TypeError("hex string expected, got "+typeof t);return t===""?Hr:BigInt("0x"+t)}function qt(t){return As(kr(t))}function yo(t){return As(kr($u($e(t)).reverse()))}function zr(t,e){if(mt(e),e===0)throw new RangeError("zero length");t=Vr(t);let r=t.toString(16);if(r.length>e*2)throw new RangeError("number too large");return ao(r.padStart(e*2,"0"))}function wo(t,e){return zr(t,e).reverse()}function $u(t){return Uint8Array.from(Z(t))}var Mr=t=>typeof t=="bigint"&&Hr<=t;function ju(t,e,r){return Mr(t)&&Mr(e)&&Mr(r)&&e<=t&&t<r}function bo(t,e,r,n){if(!ju(e,r,n))throw new RangeError("expected valid "+t+": "+r+" <= n < "+n+", got "+e)}function Vt(t){if(t<Hr)throw new Error("expected non-negative bigint, got "+t);let e;for(e=0;t>Hr;t>>=ho,e+=1);return e}var dr=t=>(ho<<BigInt(t))-ho;function Bs(t,e,r){if(mt(t,"hashLen"),mt(e,"qByteLen"),typeof r!="function")throw new TypeError("hmacFn must be a function");let n=S=>new Uint8Array(S),o=Uint8Array.of(),i=Uint8Array.of(0),s=Uint8Array.of(1),c=1e3,a=n(t),u=n(t),h=0,d=()=>{a.fill(1),u.fill(0),h=0},f=(...S)=>r(u,ct(a,...S)),l=(S=o)=>{u=f(i,S),a=f(),S.length!==0&&(u=f(s,S),a=f())},p=()=>{if(h++>=c)throw new Error("drbg: tried max amount of iterations");let S=0,x=[];for(;S<e;){a=f();let O=a.slice();x.push(O),S+=a.length}return ct(...x)};return(S,x)=>{d(),l(S);let O;for(;(O=x(p()))===void 0;)l();return d(),O}}function vt(t,e={},r={}){if(Object.prototype.toString.call(t)!=="[object Object]")throw new TypeError("expected valid options object");function n(i,s,c){if(!c&&s!=="function"&&!Object.hasOwn(t,i))throw new TypeError(`param "${i}" is invalid: expected own property`);let a=t[i];if(c&&a===void 0)return;let u=typeof a;if(u!==s||a===null)throw new TypeError(`param "${i}" is invalid: expected ${s}, got ${u}`)}let o=(i,s)=>Object.entries(i).forEach(([c,a])=>n(c,a,s));o(e,!1),o(r,!0)}var oe=BigInt(0),G=BigInt(1),At=BigInt(2),Ts=BigInt(3),Ds=BigInt(4),Us=BigInt(5),Yu=BigInt(7),_s=BigInt(8),Gu=BigInt(9),Ps=BigInt(16);function Pe(t,e){if(e<=oe)throw new Error("mod: expected positive modulus, got "+e);let r=t%e;return r>=oe?r:e+r}function Se(t,e,r){if(e<oe)throw new Error("pow2: expected non-negative exponent, got "+e);let n=t;for(;e-- >oe;)n*=n,n%=r;return n}function Cs(t,e){if(t===oe)throw new Error("invert: expected non-zero number");if(e<=oe)throw new Error("invert: expected positive modulus, got "+e);let r=Pe(t,e),n=e,o=oe,i=G,s=G,c=oe;for(;r!==oe;){let u=n/r,h=n-r*u,d=o-s*u,f=i-c*u;n=r,r=h,o=s,i=c,s=d,c=f}if(n!==G)throw new Error("invert: does not exist");return Pe(o,e)}function xo(t,e,r){let n=t;if(!n.eql(n.sqr(e),r))throw new Error("Cannot find square root")}function Rs(t,e){let r=t,n=(r.ORDER+G)/Ds,o=r.pow(e,n);return xo(r,o,e),o}function Wu(t,e){let r=t,n=(r.ORDER-Us)/_s,o=r.mul(e,At),i=r.pow(o,n),s=r.mul(e,i),c=r.mul(r.mul(s,At),i),a=r.mul(s,r.sub(c,r.ONE));return xo(r,a,e),a}function Xu(t){let e=zt(t),r=Ns(t),n=r(e,e.neg(e.ONE)),o=r(e,n),i=r(e,e.neg(n)),s=(t+Yu)/Ps;return((c,a)=>{let u=c,h=u.pow(a,s),d=u.mul(h,n),f=u.mul(h,o),l=u.mul(h,i),p=u.eql(u.sqr(d),a),w=u.eql(u.sqr(f),a);h=u.cmov(h,d,p),d=u.cmov(l,f,w);let S=u.eql(u.sqr(d),a),x=u.cmov(h,d,S);return xo(u,x,a),x})}function Ns(t){if(t<Ts)throw new Error("sqrt is not defined for small field");let e=t-G,r=0;for(;e%At===oe;)e/=At,r++;let n=At,o=zt(t);for(;Ls(o,n)===1;)if(n++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(r===1)return Rs;let i=o.pow(n,e),s=(e+G)/At;return function(a,u){let h=a;if(h.is0(u))return u;if(Ls(h,u)!==1)throw new Error("Cannot find square root");let d=r,f=h.mul(h.ONE,i),l=h.pow(u,e),p=h.pow(u,s);for(;!h.eql(l,h.ONE);){if(h.is0(l))return h.ZERO;let w=1,S=h.sqr(l);for(;!h.eql(S,h.ONE);)if(w++,S=h.sqr(S),w===d)throw new Error("Cannot find square root");let x=G<<BigInt(d-w-1),O=h.pow(f,x);d=w,f=h.sqr(O),l=h.mul(l,f),p=h.mul(p,O)}return p}}function Zu(t){return t%Ds===Ts?Rs:t%_s===Us?Wu:t%Ps===Gu?Xu(t):Ns(t)}var Qu=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Eo(t){let e={ORDER:"bigint",BYTES:"number",BITS:"number"},r=Qu.reduce((n,o)=>(n[o]="function",n),e);if(vt(t,r),ar(t.BYTES,"BYTES"),ar(t.BITS,"BITS"),t.BYTES<1||t.BITS<1)throw new Error("invalid field: expected BYTES/BITS > 0");if(t.ORDER<=G)throw new Error("invalid field: expected ORDER > 1, got "+t.ORDER);return t}function Ju(t,e,r){let n=t;if(r<oe)throw new Error("invalid exponent, negatives unsupported");if(r===oe)return n.ONE;if(r===G)return e;let o=n.ONE,i=e;for(;r>oe;)r&G&&(o=n.mul(o,i)),i=n.sqr(i),r>>=G;return o}function jr(t,e,r=!1){let n=t,o=new Array(e.length).fill(r?n.ZERO:void 0),i=e.reduce((c,a,u)=>n.is0(a)?c:(o[u]=c,n.mul(c,a)),n.ONE),s=n.inv(i);return e.reduceRight((c,a,u)=>n.is0(a)?c:(o[u]=n.mul(c,o[u]),n.mul(c,a)),s),o}function Ls(t,e){let r=t,n=(r.ORDER-G)/At,o=r.pow(e,n),i=r.eql(o,r.ONE),s=r.eql(o,r.ZERO),c=r.eql(o,r.neg(r.ONE));if(!i&&!s&&!c)throw new Error("invalid Legendre symbol result");return i?1:s?0:-1}function ed(t,e){if(e!==void 0&&po(e),t<=oe)throw new Error("invalid n length: expected positive n, got "+t);if(e!==void 0&&e<1)throw new Error("invalid n length: expected positive bit length, got "+e);let r=Vt(t);if(e!==void 0&&e<r)throw new Error(`invalid n length: expected bit length (${r}) >= n.length (${e})`);let n=e!==void 0?e:r,o=Math.ceil(n/8);return{nBitLength:n,nByteLength:o}}var Os=new WeakMap,$r=class{ORDER;BITS;BYTES;isLE;ZERO=oe;ONE=G;_lengths;_mod;constructor(e,r={}){if(e<=G)throw new Error("invalid field: expected ORDER > 1, got "+e);let n;this.isLE=!1,r!=null&&typeof r=="object"&&(typeof r.BITS=="number"&&(n=r.BITS),typeof r.sqrt=="function"&&Object.defineProperty(this,"sqrt",{value:r.sqrt,enumerable:!0}),typeof r.isLE=="boolean"&&(this.isLE=r.isLE),r.allowedLengths&&(this._lengths=Object.freeze(r.allowedLengths.slice())),typeof r.modFromBytes=="boolean"&&(this._mod=r.modFromBytes));let{nBitLength:o,nByteLength:i}=ed(e,n);if(i>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");this.ORDER=e,this.BITS=o,this.BYTES=i,Object.freeze(this)}create(e){return Pe(e,this.ORDER)}isValid(e){if(typeof e!="bigint")throw new TypeError("invalid field element: expected bigint, got "+typeof e);return oe<=e&&e<this.ORDER}is0(e){return e===oe}isValidNot0(e){return!this.is0(e)&&this.isValid(e)}isOdd(e){return(e&G)===G}neg(e){return Pe(-e,this.ORDER)}eql(e,r){return e===r}sqr(e){return Pe(e*e,this.ORDER)}add(e,r){return Pe(e+r,this.ORDER)}sub(e,r){return Pe(e-r,this.ORDER)}mul(e,r){return Pe(e*r,this.ORDER)}pow(e,r){return Ju(this,e,r)}div(e,r){return Pe(e*Cs(r,this.ORDER),this.ORDER)}sqrN(e){return e*e}addN(e,r){return e+r}subN(e,r){return e-r}mulN(e,r){return e*r}inv(e){return Cs(e,this.ORDER)}sqrt(e){let r=Os.get(this);return r||Os.set(this,r=Zu(this.ORDER)),r(this,e)}toBytes(e){return this.isLE?wo(e,this.BYTES):zr(e,this.BYTES)}fromBytes(e,r=!1){Z(e);let{_lengths:n,BYTES:o,isLE:i,ORDER:s,_mod:c}=this;if(n){if(e.length<1||!n.includes(e.length)||e.length>o)throw new Error("Field.fromBytes: expected "+n+" bytes, got "+e.length);let u=new Uint8Array(o);u.set(e,i?0:u.length-e.length),e=u}if(e.length!==o)throw new Error("Field.fromBytes: expected "+o+" bytes, got "+e.length);let a=i?yo(e):qt(e);if(c&&(a=Pe(a,s)),!r&&!this.isValid(a))throw new Error("invalid field element: outside of range 0..ORDER");return a}invertBatch(e){return jr(this,e)}cmov(e,r,n){return St(n,"condition"),n?r:e}};Object.freeze($r.prototype);function zt(t,e={}){return new $r(t,e)}function Fs(t){if(typeof t!="bigint")throw new Error("field order must be bigint");if(t<=G)throw new Error("field order must be greater than 1");let e=Vt(t-G);return Math.ceil(e/8)}function Io(t){let e=Fs(t);return e+Math.ceil(e/2)}function So(t,e,r=!1){Z(t);let n=t.length,o=Fs(e),i=Math.max(Io(e),16);if(n<i||n>1024)throw new Error("expected "+i+"-1024 bytes of input, got "+n);let s=r?yo(t):qt(t),c=Pe(s,e-G)+G;return r?wo(c,o):zr(c,o)}var $t=BigInt(0),Bt=BigInt(1);function lr(t,e){let r=e.negate();return t?r:e}function Co(t,e){let r=jr(t.Fp,e.map(n=>n.Z));return e.map((n,o)=>t.fromAffine(n.toAffine(r[o])))}function Hs(t,e){if(!Number.isSafeInteger(t)||t<=0||t>e)throw new Error("invalid window size, expected [1.."+e+"], got W="+t)}function vo(t,e){Hs(t,e);let r=Math.ceil(e/t)+1,n=2**(t-1),o=2**t,i=dr(t),s=BigInt(t);return{windows:r,windowSize:n,mask:i,maxNumber:o,shiftBy:s}}function ks(t,e,r){let{windowSize:n,mask:o,maxNumber:i,shiftBy:s}=r,c=Number(t&o),a=t>>s;c>n&&(c-=i,a+=Bt);let u=e*n,h=u+Math.abs(c)-1,d=c===0,f=c<0,l=e%2!==0;return{nextN:a,offset:h,isZero:d,isNeg:f,isNegF:l,offsetF:u}}var Ao=new WeakMap,qs=new WeakMap;function Bo(t){return qs.get(t)||1}function Ks(t){if(t!==$t)throw new Error("invalid wNAF")}var Yr=class{BASE;ZERO;Fn;bits;constructor(e,r){this.BASE=e.BASE,this.ZERO=e.ZERO,this.Fn=e.Fn,this.bits=r}_unsafeLadder(e,r,n=this.ZERO){let o=e;for(;r>$t;)r&Bt&&(n=n.add(o)),o=o.double(),r>>=Bt;return n}precomputeWindow(e,r){let{windows:n,windowSize:o}=vo(r,this.bits),i=[],s=e,c=s;for(let a=0;a<n;a++){c=s,i.push(c);for(let u=1;u<o;u++)c=c.add(s),i.push(c);s=c.double()}return i}wNAF(e,r,n){if(!this.Fn.isValid(n))throw new Error("invalid scalar");let o=this.ZERO,i=this.BASE,s=vo(e,this.bits);for(let c=0;c<s.windows;c++){let{nextN:a,offset:u,isZero:h,isNeg:d,isNegF:f,offsetF:l}=ks(n,c,s);n=a,h?i=i.add(lr(f,r[l])):o=o.add(lr(d,r[u]))}return Ks(n),{p:o,f:i}}wNAFUnsafe(e,r,n,o=this.ZERO){let i=vo(e,this.bits);for(let s=0;s<i.windows&&n!==$t;s++){let{nextN:c,offset:a,isZero:u,isNeg:h}=ks(n,s,i);if(n=c,!u){let d=r[a];o=o.add(h?d.negate():d)}}return Ks(n),o}getPrecomputes(e,r,n){let o=Ao.get(r);return o||(o=this.precomputeWindow(r,e),e!==1&&(typeof n=="function"&&(o=n(o)),Ao.set(r,o))),o}cached(e,r,n){let o=Bo(e);return this.wNAF(o,this.getPrecomputes(o,e,n),r)}unsafe(e,r,n,o){let i=Bo(e);return i===1?this._unsafeLadder(e,r,o):this.wNAFUnsafe(i,this.getPrecomputes(i,e,n),r,o)}createCache(e,r){Hs(r,this.bits),qs.set(e,r),Ao.delete(e)}hasCache(e){return Bo(e)!==1}};function Vs(t,e,r,n){let o=e,i=t.ZERO,s=t.ZERO;for(;r>$t||n>$t;)r&Bt&&(i=i.add(o)),n&Bt&&(s=s.add(o)),o=o.double(),r>>=Bt,n>>=Bt;return{p1:i,p2:s}}function Ms(t,e,r){if(e){if(e.ORDER!==t)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return Eo(e),e}else return zt(t,{isLE:r})}function zs(t,e,r={},n){if(n===void 0&&(n=t==="edwards"),!e||typeof e!="object")throw new Error(`expected valid ${t} CURVE object`);for(let a of["p","n","h"]){let u=e[a];if(!(typeof u=="bigint"&&u>$t))throw new Error(`CURVE.${a} must be positive bigint`)}let o=Ms(e.p,r.Fp,n),i=Ms(e.n,r.Fn,n),c=["Gx","Gy","a",t==="weierstrass"?"b":"d"];for(let a of c)if(!o.isValid(e[a]))throw new Error(`CURVE.${a} must be valid field element of CURVE.Fp`);return e=Object.freeze(Object.assign({},e)),{CURVE:e,Fp:o,Fn:i}}function $s(t,e){return function(n){let o=t(n);return{secretKey:o,publicKey:e(o)}}}var S0=Gr.default.generateKeyPairSync,hr=32;var td=64;function js(t,e,r){if(t.byteLength!==hr)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!==td)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=Gr.default.createPublicKey({format:"jwk",key:{crv:"Ed25519",x:z(t,"base64url"),kty:"OKP"}});return Gr.default.verify(null,r instanceof Uint8Array?r:r.subarray(),n,e)}function Gs(t){return t==null?!1:typeof t.then=="function"&&typeof t.catch=="function"&&typeof t.finally=="function"}var Wr=class{type="Ed25519";raw;constructor(e){this.raw=Lo(e,hr)}toMultihash(){return De.digest(Mt(this))}toCID(){return ne.createV1(114,this.toMultihash())}toString(){return Y.encode(this.toMultihash().bytes).substring(1)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:me(this.raw,e.raw)}verify(e,r,n){n?.signal?.throwIfAborted();let o=js(this.raw,r,e);return Gs(o)?o.then(i=>(n?.signal?.throwIfAborted(),i)):o}};function Ws(t){return t=Lo(t,hr),new Wr(t)}function Lo(t,e){if(t=Uint8Array.from(t??[]),t.length!==e)throw new Ce(`Key must be a Uint8Array of length ${e}, got ${t.length}`);return t}var nd=Math.pow(2,7),od=Math.pow(2,14),id=Math.pow(2,21),Oo=Math.pow(2,28),To=Math.pow(2,35),Do=Math.pow(2,42),Uo=Math.pow(2,49),q=128,se=127;function je(t){if(t<nd)return 1;if(t<od)return 2;if(t<id)return 3;if(t<Oo)return 4;if(t<To)return 5;if(t<Do)return 6;if(t<Uo)return 7;if(Number.MAX_SAFE_INTEGER!=null&&t>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function pr(t,e,r=0){switch(je(t)){case 8:e[r++]=t&255|q,t/=128;case 7:e[r++]=t&255|q,t/=128;case 6:e[r++]=t&255|q,t/=128;case 5:e[r++]=t&255|q,t/=128;case 4:e[r++]=t&255|q,t>>>=7;case 3:e[r++]=t&255|q,t>>>=7;case 2:e[r++]=t&255|q,t>>>=7;case 1:{e[r++]=t&255,t>>>=7;break}default:throw new Error("unreachable")}return e}function _o(t,e){let r=t[e],n=0;if(n+=r&se,r<q||(r=t[e+1],n+=(r&se)<<7,r<q)||(r=t[e+2],n+=(r&se)<<14,r<q)||(r=t[e+3],n+=(r&se)<<21,r<q)||(r=t[e+4],n+=(r&se)*Oo,r<q)||(r=t[e+5],n+=(r&se)*To,r<q)||(r=t[e+6],n+=(r&se)*Do,r<q)||(r=t[e+7],n+=(r&se)*Uo,r<q))return n;throw new RangeError("Could not decode varint")}function sd(t,e){let r=t.get(e),n=0;if(n+=r&se,r<q||(r=t.get(e+1),n+=(r&se)<<7,r<q)||(r=t.get(e+2),n+=(r&se)<<14,r<q)||(r=t.get(e+3),n+=(r&se)<<21,r<q)||(r=t.get(e+4),n+=(r&se)*Oo,r<q)||(r=t.get(e+5),n+=(r&se)*To,r<q)||(r=t.get(e+6),n+=(r&se)*Do,r<q)||(r=t.get(e+7),n+=(r&se)*Uo,r<q))return n;throw new RangeError("Could not decode varint")}function Po(t,e=0){return t instanceof Uint8Array?_o(t,e):sd(t,e)}var Ro=new Float32Array([-0]),yt=new Uint8Array(Ro.buffer);function Xs(t,e,r){Ro[0]=t,e[r]=yt[0],e[r+1]=yt[1],e[r+2]=yt[2],e[r+3]=yt[3]}function Zs(t,e){return yt[0]=t[e],yt[1]=t[e+1],yt[2]=t[e+2],yt[3]=t[e+3],Ro[0]}var No=new Float64Array([-0]),ce=new Uint8Array(No.buffer);function Qs(t,e,r){No[0]=t,e[r]=ce[0],e[r+1]=ce[1],e[r+2]=ce[2],e[r+3]=ce[3],e[r+4]=ce[4],e[r+5]=ce[5],e[r+6]=ce[6],e[r+7]=ce[7]}function Js(t,e){return ce[0]=t[e],ce[1]=t[e+1],ce[2]=t[e+2],ce[3]=t[e+3],ce[4]=t[e+4],ce[5]=t[e+5],ce[6]=t[e+6],ce[7]=t[e+7],No[0]}var ad=BigInt(Number.MAX_SAFE_INTEGER),ud=BigInt(Number.MIN_SAFE_INTEGER),ve=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 Ct;if(e<ad&&e>ud)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>ec&&(o=0n,++n>ec&&(n=0n))),new t(Number(o),Number(n))}static fromNumber(e){if(e===0)return Ct;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):Ct}},Ct=new ve(0,0);Ct.toBigInt=function(){return 0n};Ct.zzEncode=Ct.zzDecode=function(){return this};Ct.length=function(){return 1};var ec=4294967296n;function tc(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 rc(t,e,r){if(r-e<1)return"";let o,i=[],s=0,c;for(;e<r;)c=t[e++],c<128?i[s++]=c:c>191&&c<224?i[s++]=(c&31)<<6|t[e++]&63:c>239&&c<365?(c=((c&7)<<18|(t[e++]&63)<<12|(t[e++]&63)<<6|t[e++]&63)-65536,i[s++]=55296+(c>>10),i[s++]=56320+(c&1023)):i[s++]=(c&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 Fo(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 Re(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 ko=class{buf;pos;len;_slice=Uint8Array.prototype.subarray;constructor(e){this.buf=pt(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,Re(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 Re(this,4);return Xr(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw Re(this,4);return Xr(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw Re(this,4);let e=Zs(this.buf,this.pos);return this.pos+=4,e}double(){if(this.pos+8>this.len)throw Re(this,4);let e=Js(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 Re(this,e);return this.pos+=e,r===n?new Uint8Array(0):this.buf.subarray(r,n)}string(){let e=this.bytes();return rc(e,0,e.length)}skip(e){if(typeof e=="number"){if(this.pos+e>this.len)throw Re(this,e);this.pos+=e}else do if(this.pos>=this.len)throw Re(this);while((this.buf[this.pos++]&128)!==0);return this}skipType(e){switch(e){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(e=this.uint32()&7)!==4;)this.skipType(e);break;case 5:this.skip(4);break;default:throw Error(`invalid wire type ${e} at offset ${this.pos}`)}return this}readLongVarint(){let e=new ve(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 Re(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 Re(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 Re(this,8);let e=Xr(this.buf,this.pos+=4),r=Xr(this.buf,this.pos+=4);return new ve(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=_o(this.buf,this.pos);return this.pos+=je(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 fr(t){return new ko(t instanceof Uint8Array?t:t.subarray())}function Zr(t,e,r){let n=fr(t);return e.decode(n,void 0,r)}function Ko(t){let e=t??8192,r=e>>>1,n,o=e;return function(s){if(s<1||s>r)return Ee(s);o+s>e&&(n=Ee(e),o=0);let c=n.subarray(o,o+=s);return(o&7)!==0&&(o=(o|7)+1),c}}var Lt=class{fn;len;next;val;constructor(e,r,n){this.fn=e,this.len=r,this.next=void 0,this.val=n}};function Mo(){}var qo=class{head;tail;len;next;constructor(e){this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}},dd=Ko();function ld(t){return globalThis.Buffer!=null?Ee(t):dd(t)}var gr=class{len;head;tail;states;constructor(){this.len=0,this.head=new Lt(Mo,0,0),this.tail=this.head,this.states=null}_push(e,r,n){return this.tail=this.tail.next=new Lt(e,r,n),this.len+=r,this}uint32(e){return this.len+=(this.tail=this.tail.next=new Vo((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(Qr,10,ve.fromNumber(e)):this.uint32(e)}sint32(e){return this.uint32((e<<1^e>>31)>>>0)}uint64(e){let r=ve.fromBigInt(e);return this._push(Qr,r.length(),r)}uint64Number(e){return this._push(pr,je(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=ve.fromBigInt(e).zzEncode();return this._push(Qr,r.length(),r)}sint64Number(e){let r=ve.fromNumber(e).zzEncode();return this._push(Qr,r.length(),r)}sint64String(e){return this.sint64(BigInt(e))}bool(e){return this._push(Ho,1,e?1:0)}fixed32(e){return this._push(mr,4,e>>>0)}sfixed32(e){return this.fixed32(e)}fixed64(e){let r=ve.fromBigInt(e);return this._push(mr,4,r.lo)._push(mr,4,r.hi)}fixed64Number(e){let r=ve.fromNumber(e);return this._push(mr,4,r.lo)._push(mr,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(Xs,4,e)}double(e){return this._push(Qs,8,e)}bytes(e){let r=e.length>>>0;return r===0?this._push(Ho,1,0):this.uint32(r)._push(pd,r,e)}string(e){let r=tc(e);return r!==0?this.uint32(r)._push(Fo,r,e):this._push(Ho,1,0)}fork(){return this.states=new qo(this),this.head=this.tail=new Lt(Mo,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 Lt(Mo,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=ld(this.len),n=0;for(;e!=null;)e.fn(e.val,r,n),n+=e.len,e=e.next;return r}};function Ho(t,e,r){e[r]=t&255}function hd(t,e,r){for(;t>127;)e[r++]=t&127|128,t>>>=7;e[r]=t}var Vo=class extends Lt{next;constructor(e,r){super(hd,e,r),this.next=void 0}};function Qr(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 mr(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 pd(t,e,r){e.set(t,r)}globalThis.Buffer!=null&&(gr.prototype.bytes=function(t){let e=t.length>>>0;return this.uint32(e),e>0&&this._push(fd,e,t),this},gr.prototype.string=function(t){let e=globalThis.Buffer.byteLength(t);return this.uint32(e),e>0&&this._push(md,e,t),this});function fd(t,e,r){e.set(t,r)}function md(t,e,r){t.length<40?Fo(t,e,r):e.utf8Write!=null?e.utf8Write(t,r):e.set(le(t),r)}function zo(){return new gr}function Jr(t,e){let r=zo();return e.encode(t,r,{lengthDelimited:!1}),r.finish()}function*en(t,e,r){let n=fr(t);yield*e.stream(n,void 0,"$",r)}var tn={VARINT:0,BIT64:1,LENGTH_DELIMITED:2,START_GROUP:3,END_GROUP:4,BIT32:5};function rn(t,e,r,n,o){return{name:t,type:e,encode:r,decode:n,stream:o}}function $o(t){function e(i){if(t[i.toString()]==null)throw new Error("Invalid enum value");return t[i]}let r=function(s,c){let a=e(s);c.int32(a)},n=function(s){let c=s.int32();return e(c)},o=function*(s){let c=s.int32();yield e(c)};return rn("enum",tn.VARINT,r,n,o)}function nn(t,e,r){return rn("message",tn.LENGTH_DELIMITED,t,e,r)}var he;(function(t){t.RSA="RSA",t.Ed25519="Ed25519",t.secp256k1="secp256k1",t.ECDSA="ECDSA"})(he||(he={}));var jo;(function(t){t[t.RSA=0]="RSA",t[t.Ed25519=1]="Ed25519",t[t.secp256k1=2]="secp256k1",t[t.ECDSA=3]="ECDSA"})(jo||(jo={}));(function(t){t.codec=()=>$o(jo)})(he||(he={}));var yr;(function(t){let e;t.codec=()=>(e==null&&(e=nn((i,s,c={})=>{c.lengthDelimited!==!1&&s.fork(),i.Type!=null&&(s.uint32(8),he.codec().encode(i.Type,s)),i.Data!=null&&(s.uint32(18),s.bytes(i.Data)),c.lengthDelimited!==!1&&s.ldelim()},(i,s,c={})=>{let a={},u=s==null?i.len:i.pos+s;for(;i.pos<u;){let h=i.uint32();switch(h>>>3){case 1:{a.Type=he.codec().decode(i);break}case 2:{a.Data=i.bytes();break}default:{i.skipType(h&7);break}}}return a},function*(i,s,c,a={}){let u=s==null?i.len:i.pos+s;for(;i.pos<u;){let h=i.uint32();switch(h>>>3){case 1:{yield{field:`${c}.Type`,value:he.codec().decode(i)};break}case 2:{yield{field:`${c}.Data`,value:i.bytes()};break}default:{i.skipType(h&7);break}}}})),e);function r(i){return Jr(i,t.codec())}t.encode=r;function n(i,s){return Zr(i,t.codec(),s)}t.decode=n;function o(i,s){return en(i,t.codec(),s)}t.stream=o})(yr||(yr={}));var Yo;(function(t){let e;t.codec=()=>(e==null&&(e=nn((i,s,c={})=>{c.lengthDelimited!==!1&&s.fork(),i.Type!=null&&(s.uint32(8),he.codec().encode(i.Type,s)),i.Data!=null&&(s.uint32(18),s.bytes(i.Data)),c.lengthDelimited!==!1&&s.ldelim()},(i,s,c={})=>{let a={},u=s==null?i.len:i.pos+s;for(;i.pos<u;){let h=i.uint32();switch(h>>>3){case 1:{a.Type=he.codec().decode(i);break}case 2:{a.Data=i.bytes();break}default:{i.skipType(h&7);break}}}return a},function*(i,s,c,a={}){let u=s==null?i.len:i.pos+s;for(;i.pos<u;){let h=i.uint32();switch(h>>>3){case 1:{yield{field:`${c}.Type`,value:he.codec().decode(i)};break}case 2:{yield{field:`${c}.Data`,value:i.bytes()};break}default:{i.skipType(h&7);break}}}})),e);function r(i){return Jr(i,t.codec())}t.encode=r;function n(i,s){return Zr(i,t.codec(),s)}t.decode=n;function o(i,s){return en(i,t.codec(),s)}t.stream=o})(Yo||(Yo={}));var hc=Zt(ge("node:crypto"),1);var on=class{oHash;iHash;blockLen;outputLen;canXOF=!1;finished=!1;destroyed=!1;constructor(e,r){if(Rr(e),$e(r,void 0,"key"),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 n=this.blockLen,o=new Uint8Array(n);o.set(r.length>n?e.create().update(r).digest():r);for(let i=0;i<o.length;i++)o[i]^=54;this.iHash.update(o),this.oHash=e.create();for(let i=0;i<o.length;i++)o[i]^=106;this.oHash.update(o),It(o)}update(e){return Ht(this),this.iHash.update(e),this}digestInto(e){Ht(this),Nr(e,this),this.finished=!0;let r=e.subarray(0,this.outputLen);this.iHash.digestInto(r),this.oHash.update(r),this.oHash.digestInto(r),this.destroy()}digest(){let e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||=Object.create(Object.getPrototypeOf(this),{});let{oHash:r,iHash:n,finished:o,destroyed:i,blockLen:s,outputLen:c}=this;return e=e,e.finished=o,e.destroyed=i,e.blockLen=s,e.outputLen=c,e.oHash=r._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},oc=(()=>{let t=((e,r,n)=>new on(e,r).update(n).digest());return t.create=(e,r)=>new on(e,r),t})();var ic=(t,e)=>(t+(t>=0?e:-e)/sc)/e;function yd(t,e,r){bo("scalar",t,Ye,r);let[[n,o],[i,s]]=e,c=ic(s*t,r),a=ic(-o*t,r),u=t-c*n-a*i,h=-c*o-a*s,d=u<Ye,f=h<Ye;d&&(u=-u),f&&(h=-h);let l=dr(Math.ceil(Vt(r)/2))+wt;if(u<Ye||u>=l||h<Ye||h>=l)throw new Error("splitScalar (endomorphism): failed for k");return{k1neg:d,k1:u,k2neg:f,k2:h}}function Wo(t){if(!["compact","recovered","der"].includes(t))throw new Error('Signature format must be "compact", "recovered", or "der"');return t}function Go(t,e){vt(t);let r={};for(let n of Object.keys(e))r[n]=t[n]===void 0?e[n]:t[n];return St(r.lowS,"lowS"),St(r.prehash,"prehash"),r.format!==void 0&&Wo(r.format),r}var Xo=class extends Error{constructor(e=""){super(e)}},Ne={Err:Xo,_tlv:{encode:(t,e)=>{let{Err:r}=Ne;if(ar(t,"tag"),t<0||t>255)throw new r("tlv.encode: wrong tag");if(typeof e!="string")throw new TypeError('"data" expected string, got type='+typeof e);if(e.length&1)throw new r("tlv.encode: unpadded data");let n=e.length/2,o=ur(n);if(o.length/2&128)throw new r("tlv.encode: long form length too big");let i=n>127?ur(o.length/2|128):"";return ur(t)+i+o+e},decode(t,e){let{Err:r}=Ne;e=Z(e,void 0,"DER data");let n=0;if(t<0||t>255)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 a=o&127;if(!a)throw new r("tlv.decode(long): indefinite length not supported");if(a>4)throw new r("tlv.decode(long): byte length is too big");let u=e.subarray(n,n+a);if(u.length!==a)throw new r("tlv.decode: length bytes not complete");if(u[0]===0)throw new r("tlv.decode(long): zero leftmost byte");for(let h of u)s=s<<8|h;if(n+=a,s<128)throw new r("tlv.decode(long): not minimal encoding")}let c=e.subarray(n,n+s);if(c.length!==s)throw new r("tlv.decode: wrong value length");return{v:c,l:e.subarray(n+s)}}},_int:{encode(t){let{Err:e}=Ne;if(Vr(t),t<Ye)throw new e("integer: negative integers are not allowed");let r=ur(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}=Ne;if(t.length<1)throw new e("invalid signature integer: empty");if(t[0]&128)throw new e("invalid signature integer: negative");if(t.length>1&&t[0]===0&&!(t[1]&128))throw new e("invalid signature integer: unnecessary leading zero");return qt(t)}},toSig(t){let{Err:e,_int:r,_tlv:n}=Ne,o=Z(t,void 0,"signature"),{v:i,l:s}=n.decode(48,o);if(s.length)throw new e("invalid signature: left bytes after parsing");let{v:c,l:a}=n.decode(2,i),{v:u,l:h}=n.decode(2,a);if(h.length)throw new e("invalid signature: left bytes after parsing");return{r:r.decode(c),s:r.decode(u)}},hexFromSig(t){let{_tlv:e,_int:r}=Ne,n=e.encode(2,r.encode(t.r)),o=e.encode(2,r.encode(t.s)),i=n+o;return e.encode(48,i)}};Object.freeze(Ne._tlv);Object.freeze(Ne._int);Object.freeze(Ne);var Ye=BigInt(0),wt=BigInt(1),sc=BigInt(2),sn=BigInt(3),wd=BigInt(4);function cc(t,e={}){let r=zs("weierstrass",t,e),n=r.Fp,o=r.Fn,i=r.CURVE,{h:s,n:c}=i;vt(e,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object"});let{endo:a,allowInfinityPoint:u}=e;if(a&&(!n.is0(i.a)||typeof a.beta!="bigint"||!Array.isArray(a.basises)))throw new Error('invalid endo: expected "beta": bigint and "basises": array');let h=uc(n,o);function d(){if(!n.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}function f(N,g,C){if(u&&g.is0())return Uint8Array.of(0);let{x:T,y:b}=g.toAffine(),m=n.toBytes(T);if(St(C,"isCompressed"),C){d();let E=!n.isOdd(b);return ct(ac(E),m)}else return ct(Uint8Array.of(4),m,n.toBytes(b))}function l(N){Z(N,void 0,"Point");let{publicKey:g,publicKeyUncompressed:C}=h,T=N.length,b=N[0],m=N.subarray(1);if(u&&T===1&&b===0)return{x:n.ZERO,y:n.ZERO};if(T===g&&(b===2||b===3)){let E=n.fromBytes(m);if(!n.isValid(E))throw new Error("bad point: is not on curve, wrong x");let v=S(E),I;try{I=n.sqrt(v)}catch(M){let k=M instanceof Error?": "+M.message:"";throw new Error("bad point: is not on curve, sqrt error"+k)}d();let L=n.isOdd(I);return(b&1)===1!==L&&(I=n.neg(I)),{x:E,y:I}}else if(T===C&&b===4){let E=n.BYTES,v=n.fromBytes(m.subarray(0,E)),I=n.fromBytes(m.subarray(E,E*2));if(!x(v,I))throw new Error("bad point: is not on curve");return{x:v,y:I}}else throw new Error(`bad point: got length ${T}, expected compressed=${g} or uncompressed=${C}`)}let p=e.toBytes===void 0?f:e.toBytes,w=e.fromBytes===void 0?l:e.fromBytes;function S(N){let g=n.sqr(N),C=n.mul(g,N);return n.add(n.add(C,n.mul(N,i.a)),i.b)}function x(N,g){let C=n.sqr(g),T=S(N);return n.eql(C,T)}if(!x(i.Gx,i.Gy))throw new Error("bad curve params: generator point");let O=n.mul(n.pow(i.a,sn),wd),H=n.mul(n.sqr(i.b),BigInt(27));if(n.is0(n.add(O,H)))throw new Error("bad curve params: a or b");function K(N,g,C=!1){if(!n.isValid(g)||C&&n.is0(g))throw new Error(`bad point coordinate ${N}`);return g}function P(N){if(!(N instanceof U))throw new Error("Weierstrass Point expected")}function F(N){if(!a||!a.basises)throw new Error("no endo");return yd(N,a.basises,o.ORDER)}function W(N,g,C,T,b){return C=new U(n.mul(C.X,N),C.Y,C.Z),g=lr(T,g),C=lr(b,C),g.add(C)}class U{static BASE=new U(i.Gx,i.Gy,n.ONE);static ZERO=new U(n.ZERO,n.ONE,n.ZERO);static Fp=n;static Fn=o;X;Y;Z;constructor(g,C,T){this.X=K("x",g),this.Y=K("y",C,!0),this.Z=K("z",T),Object.freeze(this)}static CURVE(){return i}static fromAffine(g){let{x:C,y:T}=g||{};if(!g||!n.isValid(C)||!n.isValid(T))throw new Error("invalid affine point");if(g instanceof U)throw new Error("projective point not allowed");return n.is0(C)&&n.is0(T)?U.ZERO:new U(C,T,n.ONE)}static fromBytes(g){let C=U.fromAffine(w(Z(g,void 0,"point")));return C.assertValidity(),C}static fromHex(g){return U.fromBytes(qr(g))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(g=8,C=!0){return $.createCache(this,g),C||this.multiply(sn),this}assertValidity(){let g=this;if(g.is0()){if(e.allowInfinityPoint&&n.is0(g.X)&&n.eql(g.Y,n.ONE)&&n.is0(g.Z))return;throw new Error("bad point: ZERO")}let{x:C,y:T}=g.toAffine();if(!n.isValid(C)||!n.isValid(T))throw new Error("bad point: x or y not field elements");if(!x(C,T))throw new Error("bad point: equation left != right");if(!g.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){let{y:g}=this.toAffine();if(!n.isOdd)throw new Error("Field doesn't support isOdd");return!n.isOdd(g)}equals(g){P(g);let{X:C,Y:T,Z:b}=this,{X:m,Y:E,Z:v}=g,I=n.eql(n.mul(C,v),n.mul(m,b)),L=n.eql(n.mul(T,v),n.mul(E,b));return I&&L}negate(){return new U(this.X,n.neg(this.Y),this.Z)}double(){let{a:g,b:C}=i,T=n.mul(C,sn),{X:b,Y:m,Z:E}=this,v=n.ZERO,I=n.ZERO,L=n.ZERO,D=n.mul(b,b),M=n.mul(m,m),k=n.mul(E,E),R=n.mul(b,m);return R=n.add(R,R),L=n.mul(b,E),L=n.add(L,L),v=n.mul(g,L),I=n.mul(T,k),I=n.add(v,I),v=n.sub(M,I),I=n.add(M,I),I=n.mul(v,I),v=n.mul(R,v),L=n.mul(T,L),k=n.mul(g,k),R=n.sub(D,k),R=n.mul(g,R),R=n.add(R,L),L=n.add(D,D),D=n.add(L,D),D=n.add(D,k),D=n.mul(D,R),I=n.add(I,D),k=n.mul(m,E),k=n.add(k,k),D=n.mul(k,R),v=n.sub(v,D),L=n.mul(k,M),L=n.add(L,L),L=n.add(L,L),new U(v,I,L)}add(g){P(g);let{X:C,Y:T,Z:b}=this,{X:m,Y:E,Z:v}=g,I=n.ZERO,L=n.ZERO,D=n.ZERO,M=i.a,k=n.mul(i.b,sn),R=n.mul(C,m),J=n.mul(T,E),ee=n.mul(b,v),te=n.add(C,T),j=n.add(m,E);te=n.mul(te,j),j=n.add(R,J),te=n.sub(te,j),j=n.add(C,b);let pe=n.add(m,v);return j=n.mul(j,pe),pe=n.add(R,ee),j=n.sub(j,pe),pe=n.add(T,b),I=n.add(E,v),pe=n.mul(pe,I),I=n.add(J,ee),pe=n.sub(pe,I),D=n.mul(M,j),I=n.mul(k,ee),D=n.add(I,D),I=n.sub(J,D),D=n.add(J,D),L=n.mul(I,D),J=n.add(R,R),J=n.add(J,R),ee=n.mul(M,ee),j=n.mul(k,j),J=n.add(J,ee),ee=n.sub(R,ee),ee=n.mul(M,ee),j=n.add(j,ee),R=n.mul(J,j),L=n.add(L,R),R=n.mul(pe,j),I=n.mul(te,I),I=n.sub(I,R),R=n.mul(te,J),D=n.mul(pe,D),D=n.add(D,R),new U(I,L,D)}subtract(g){return P(g),this.add(g.negate())}is0(){return this.equals(U.ZERO)}multiply(g){let{endo:C}=e;if(!o.isValidNot0(g))throw new RangeError("invalid scalar: out of range");let T,b,m=E=>$.cached(this,E,v=>Co(U,v));if(C){let{k1neg:E,k1:v,k2neg:I,k2:L}=F(g),{p:D,f:M}=m(v),{p:k,f:R}=m(L);b=M.add(R),T=W(C.beta,D,k,E,I)}else{let{p:E,f:v}=m(g);T=E,b=v}return Co(U,[T,b])[0]}multiplyUnsafe(g){let{endo:C}=e,T=this,b=g;if(!o.isValid(b))throw new RangeError("invalid scalar: out of range");if(b===Ye||T.is0())return U.ZERO;if(b===wt)return T;if($.hasCache(this))return this.multiply(b);if(C){let{k1neg:m,k1:E,k2neg:v,k2:I}=F(b),{p1:L,p2:D}=Vs(U,T,E,I);return W(C.beta,L,D,m,v)}else return $.unsafe(T,b)}toAffine(g){let C=this,T=g,{X:b,Y:m,Z:E}=C;if(n.eql(E,n.ONE))return{x:b,y:m};let v=C.is0();T==null&&(T=v?n.ONE:n.inv(E));let I=n.mul(b,T),L=n.mul(m,T),D=n.mul(E,T);if(v)return{x:n.ZERO,y:n.ZERO};if(!n.eql(D,n.ONE))throw new Error("invZ was invalid");return{x:I,y:L}}isTorsionFree(){let{isTorsionFree:g}=e;return s===wt?!0:g?g(U,this):$.unsafe(this,c).is0()}clearCofactor(){let{clearCofactor:g}=e;return s===wt?this:g?g(U,this):this.multiplyUnsafe(s)}isSmallOrder(){return s===wt?this.is0():this.clearCofactor().is0()}toBytes(g=!0){return St(g,"isCompressed"),this.assertValidity(),p(U,this,g)}toHex(g=!0){return fo(this.toBytes(g))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let ae=o.BITS,$=new Yr(U,e.endo?Math.ceil(ae/2):ae);return ae>=8&&U.BASE.precompute(8),Object.freeze(U.prototype),Object.freeze(U),U}function ac(t){return Uint8Array.of(t?2:3)}function uc(t,e){return{secretKey:e.BYTES,publicKey:1+t.BYTES,publicKeyUncompressed:1+2*t.BYTES,publicKeyHasPrefix:!0,signature:2*e.BYTES}}function bd(t,e={}){let{Fn:r}=t,n=e.randomBytes===void 0?go:e.randomBytes,o=Object.assign(uc(t.Fp,r),{seed:Math.max(Io(r.ORDER),16)});function i(l){try{let p=r.fromBytes(l);return r.isValidNot0(p)}catch{return!1}}function s(l,p){let{publicKey:w,publicKeyUncompressed:S}=o;try{let x=l.length;return p===!0&&x!==w||p===!1&&x!==S?!1:!!t.fromBytes(l)}catch{return!1}}function c(l){return l=l===void 0?n(o.seed):l,So(Z(l,o.seed,"seed"),r.ORDER)}function a(l,p=!0){return t.BASE.multiply(r.fromBytes(l)).toBytes(p)}function u(l){let{secretKey:p,publicKey:w,publicKeyUncompressed:S}=o,x=r._lengths;if(!mo(l))return;let O=Z(l,void 0,"key").length,H=O===w||O===S,K=O===p||!!x?.includes(O);if(!(H&&K))return H}function h(l,p,w=!0){if(u(l)===!0)throw new Error("first arg must be private key");if(u(p)===!1)throw new Error("second arg must be public key");let S=r.fromBytes(l);return t.fromBytes(p).multiply(S).toBytes(w)}let d={isValidSecretKey:i,isValidPublicKey:s,randomSecretKey:c},f=$s(c,a);return Object.freeze(d),Object.freeze(o),Object.freeze({getPublicKey:a,getSharedSecret:h,keygen:f,Point:t,utils:d,lengths:o})}function dc(t,e,r={}){let n=e;Rr(n),vt(r,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"}),r=Object.assign({},r);let o=r.randomBytes===void 0?go:r.randomBytes,i=r.hmac===void 0?(b,m)=>oc(n,b,m):r.hmac,{Fp:s,Fn:c}=t,{ORDER:a,BITS:u}=c,{keygen:h,getPublicKey:d,getSharedSecret:f,utils:l,lengths:p}=bd(t,r),w={prehash:!0,lowS:typeof r.lowS=="boolean"?r.lowS:!0,format:"compact",extraEntropy:!1},S=a*sc+wt<s.ORDER;function x(b){let m=a>>wt;return b>m}function O(b,m){if(!c.isValidNot0(m))throw new Error(`invalid signature ${b}: out of range 1..Point.Fn.ORDER`);return m}function H(){if(S)throw new Error('"recovered" sig type is not supported for cofactor >2 curves')}function K(b,m){Wo(m);let E=p.signature,v=m==="compact"?E:m==="recovered"?E+1:void 0;return Z(b,v)}class P{r;s;recovery;constructor(m,E,v){if(this.r=O("r",m),this.s=O("s",E),v!=null){if(H(),![0,1,2,3].includes(v))throw new Error("invalid recovery id");this.recovery=v}Object.freeze(this)}static fromBytes(m,E=w.format){K(m,E);let v;if(E==="der"){let{r:M,s:k}=Ne.toSig(Z(m));return new P(M,k)}E==="recovered"&&(v=m[0],E="compact",m=m.subarray(1));let I=p.signature/2,L=m.subarray(0,I),D=m.subarray(I,I*2);return new P(c.fromBytes(L),c.fromBytes(D),v)}static fromHex(m,E){return this.fromBytes(qr(m),E)}assertRecovery(){let{recovery:m}=this;if(m==null)throw new Error("invalid recovery id: must be present");return m}addRecoveryBit(m){return new P(this.r,this.s,m)}recoverPublicKey(m){let{r:E,s:v}=this,I=this.assertRecovery(),L=I===2||I===3?E+a:E;if(!s.isValid(L))throw new Error("invalid recovery id: sig.r+curve.n != R.x");let D=s.toBytes(L),M=t.fromBytes(ct(ac((I&1)===0),D)),k=c.inv(L),R=W(Z(m,void 0,"msgHash")),J=c.create(-R*k),ee=c.create(v*k),te=t.BASE.multiplyUnsafe(J).add(M.multiplyUnsafe(ee));if(te.is0())throw new Error("invalid recovery: point at infinify");return te.assertValidity(),te}hasHighS(){return x(this.s)}toBytes(m=w.format){if(Wo(m),m==="der")return qr(Ne.hexFromSig(this));let{r:E,s:v}=this,I=c.toBytes(E),L=c.toBytes(v);return m==="recovered"?(H(),ct(Uint8Array.of(this.assertRecovery()),I,L)):ct(I,L)}toHex(m){return fo(this.toBytes(m))}}Object.freeze(P.prototype),Object.freeze(P);let F=r.bits2int===void 0?function(m){if(m.length>8192)throw new Error("input is too large");let E=qt(m),v=m.length*8-u;return v>0?E>>BigInt(v):E}:r.bits2int,W=r.bits2int_modN===void 0?function(m){return c.create(F(m))}:r.bits2int_modN,U=dr(u);function ae(b){return bo("num < 2^"+u,b,Ye,U),c.toBytes(b)}function $(b,m){return Z(b,void 0,"message"),m?Z(n(b),void 0,"prehashed message"):b}function N(b,m,E){let{lowS:v,prehash:I,extraEntropy:L}=Go(E,w);b=$(b,I);let D=W(b),M=c.fromBytes(m);if(!c.isValidNot0(M))throw new Error("invalid private key");let k=[ae(M),ae(D)];if(L!=null&&L!==!1){let te=L===!0?o(p.secretKey):L;k.push(Z(te,void 0,"extraEntropy"))}let R=ct(...k),J=D;function ee(te){let j=F(te);if(!c.isValidNot0(j))return;let pe=c.inv(j),Dt=t.BASE.multiply(j).toAffine(),Xt=c.create(Dt.x);if(Xt===Ye)return;let Sr=c.create(pe*c.create(J+Xt*M));if(Sr===Ye)return;let pi=(Dt.x===Xt?0:2)|Number(Dt.y&wt),fi=Sr;return v&&x(Sr)&&(fi=c.neg(Sr),pi^=1),new P(Xt,fi,S?void 0:pi)}return{seed:R,k2sig:ee}}function g(b,m,E={}){let{seed:v,k2sig:I}=N(b,m,E);return Bs(n.outputLen,c.BYTES,i)(v,I).toBytes(E.format)}function C(b,m,E,v={}){let{lowS:I,prehash:L,format:D}=Go(v,w);if(E=Z(E,void 0,"publicKey"),m=$(m,L),!mo(b)){let M=b instanceof P?", use sig.toBytes()":"";throw new Error("verify expects Uint8Array signature"+M)}K(b,D);try{let M=P.fromBytes(b,D),k=t.fromBytes(E);if(I&&M.hasHighS())return!1;let{r:R,s:J}=M,ee=W(m),te=c.inv(J),j=c.create(ee*te),pe=c.create(R*te),Dt=t.BASE.multiplyUnsafe(j).add(k.multiplyUnsafe(pe));return Dt.is0()?!1:c.create(Dt.x)===R}catch{return!1}}function T(b,m,E={}){let{prehash:v}=Go(E,w);return m=$(m,v),P.fromBytes(b,"recovered").recoverPublicKey(m).toBytes()}return Object.freeze({keygen:h,getPublicKey:d,getSharedSecret:f,utils:l,lengths:p,Point:t,sign:g,verify:C,recoverPublicKey:T,Signature:P,hash:n})}var Qo={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},xd={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]};var lc=BigInt(2);function Ed(t){let e=Qo.p,r=BigInt(3),n=BigInt(6),o=BigInt(11),i=BigInt(22),s=BigInt(23),c=BigInt(44),a=BigInt(88),u=t*t*t%e,h=u*u*t%e,d=Se(h,r,e)*h%e,f=Se(d,r,e)*h%e,l=Se(f,lc,e)*u%e,p=Se(l,o,e)*l%e,w=Se(p,i,e)*p%e,S=Se(w,c,e)*w%e,x=Se(S,a,e)*S%e,O=Se(x,c,e)*w%e,H=Se(O,r,e)*h%e,K=Se(H,s,e)*p%e,P=Se(K,n,e)*u%e,F=Se(P,lc,e);if(!Zo.eql(Zo.sqr(F),t))throw new Error("Cannot find square root");return F}var Zo=zt(Qo.p,{sqrt:Ed}),Id=cc(Qo,{Fp:Zo,endo:xd}),wr=dc(Id,vs);var cn=class extends Error{constructor(e="An error occurred while verifying a message"){super(e),this.name="VerificationError"}};function pc(t,e,r,n){n?.signal?.throwIfAborted();let o=hc.default.createHash("sha256");if(r instanceof Uint8Array)o.update(r);else for(let s of r)o.update(s);let i=o.digest();try{return wr.verify(e,i,t,{prehash:!1,format:"der"})}catch(s){throw new cn(String(s))}}var an=class{type="secp256k1";raw;_key;constructor(e){this._key=mc(e),this.raw=fc(this._key)}toMultihash(){return De.digest(Mt(this))}toCID(){return ne.createV1(114,this.toMultihash())}toString(){return Y.encode(this.toMultihash().bytes).substring(1)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:me(this.raw,e.raw)}verify(e,r,n){return pc(this._key,r,e,n)}};function gc(t){return new an(t)}function fc(t){return wr.Point.fromBytes(t).toBytes()}function mc(t){try{return wr.Point.fromBytes(t),t}catch(e){throw new Ar(String(e))}}function yc(t){let{Type:e,Data:r}=yr.decode(t.digest),n=r??new Uint8Array;switch(e){case he.Ed25519:return Ws(n);case he.secp256k1:return gc(n);case he.ECDSA:return ps(n);default:throw new Qt}}function Mt(t){return yr.encode({Type:he[t.type],Data:t.raw})}var wc=Symbol.for("nodejs.util.inspect.custom"),Sd=114,br=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()})`}[yn]=!0;toString(){return this.string==null&&(this.string=Y.encode(this.multihash.bytes).slice(1)),this.string}toMultihash(){return this.multihash}toCID(){return ne.createV1(Sd,this.multihash)}toJSON(){return this.toString()}equals(e){if(e==null)return!1;if(e instanceof Uint8Array)return me(this.multihash.bytes,e);if(typeof e=="string")return this.toString()===e;if(e?.toMultihash()?.bytes!=null)return me(this.multihash.bytes,e.toMultihash().bytes);throw new Error("not valid Id")}[wc](){return`PeerId(${this.toString()})`}},un=class extends br{type="RSA";publicKey;constructor(e){super({...e,type:"RSA"}),this.publicKey=e.publicKey}},dn=class extends br{type="Ed25519";publicKey;constructor(e){super({...e,type:"Ed25519"}),this.publicKey=e.publicKey}},ln=class extends br{type="secp256k1";publicKey;constructor(e){super({...e,type:"secp256k1"}),this.publicKey=e.publicKey}},vd=2336,xr=class{type="url";multihash;publicKey;url;constructor(e){this.url=e.toString(),this.multihash=De.digest(le(this.url))}[wc](){return`PeerId(${this.url})`}[yn]=!0;toString(){return this.toCID().toString()}toMultihash(){return this.multihash}toCID(){return ne.createV1(vd,this.toMultihash())}toJSON(){return this.toString()}equals(e){return e==null?!1:(e instanceof Uint8Array&&(e=z(e)),e.toString()===this.toString())}};var Ad=114,bc=2336;function xc(t,e){let r;if(t.charAt(0)==="1"||t.charAt(0)==="Q")r=nr(Y.decode(`z${t}`));else{if(t.startsWith("k51qzi5uqu5")||t.startsWith("kzwfwjn5ji4")||t.startsWith("k2k4r8")||t.startsWith("bafz"))return Bd(ne.parse(t));if(e==null)throw new Ce('Please pass a multibase decoder for strings that do not start with "1" or "Q"');r=nr(e.decode(t))}return Ec(r)}function Ec(t){if(Ld(t))return new un({multihash:t});if(Cd(t))try{let e=yc(t);if(e.type==="Ed25519")return new dn({multihash:t,publicKey:e});if(e.type==="secp256k1")return new ln({multihash:t,publicKey:e})}catch{let r=z(t.digest);return new xr(new URL(r))}throw new Cr("Supplied PeerID Multihash is invalid")}function Bd(t){if(t?.multihash==null||t.version==null||t.version===1&&t.code!==Ad&&t.code!==bc)throw new Br("Supplied PeerID CID is invalid");if(t.code===bc){let e=z(t.multihash.digest);return new xr(new URL(e))}return Ec(t.multihash)}function Cd(t){return t.code===De.code}function Ld(t){return t.code===Qn.code}function Od(t){let e=t.getComponents(),r={},n=0;return e[n]?.name==="ip6zone"&&(r.zone=`${e[n].value}`,n++),e[n]?.name==="ip4"||e[n]?.name==="ip6"||e[n]?.name==="dns"||e[n]?.name==="dns4"||e[n]?.name==="dns6"?(r.type=e[n].name,r.host=e[n].value,n++):e[n]?.name==="dnsaddr"&&(r.type=e[n].name,r.host=`_dnsaddr.${e[n].value}`,n++),(e[n]?.name==="tcp"||e[n]?.name==="udp")&&(r.protocol=e[n].name==="tcp"?"tcp":"udp",r.port=parseInt(`${e[n].value}`),n++),e[n]?.name==="ipcidr"&&(r.type==="ip4"?r.cidr=parseInt(`${e[n].value}`):r.type==="ip6"&&(r.cidr=`${e[n].value}`),n++),r.type==null||r.host==null?null:(e[n]?.name==="tls"&&e[n+1]?.name==="sni"&&(r.sni=e[n+1].value,n+=2),r)}function Ic(t){let e=Od(t);if(e==null)throw new Ce(`Multiaddr ${t} was not an IPv4, IPv6, DNS, DNS4, DNS6 or DNSADDR address`);return e}var Ae=ge("node:net");var Bc=Zt(Ac(),1),Nd=["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"],Fd=Nd.map(t=>new Bc.Netmask(t));function ii(t){for(let e of Fd)if(e.contains(t))return!0;return!1}function kd(t){return/^::ffff:([0-9a-fA-F]{1,4}):([0-9a-fA-F]{1,4})$/.test(t)}function Kd(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 ii(o)}function Md(t){return/^::ffff:([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(t)}function Hd(t){let e=t.split(":"),r=e[e.length-1];return ii(r)}function qd(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 Cc(t){if((0,Ae.isIPv4)(t))return ii(t);if(kd(t))return Kd(t);if(Md(t))return Hd(t);if((0,Ae.isIPv6)(t))return qd(t)}function Lc(t){try{let e=Ic(t);switch(e.type){case"ip4":case"ip6":return Cc(e.host)??!1;default:return e.host==="localhost"}}catch{return!1}}var ie=class extends Error{static name="InvalidMultiaddrError";name="InvalidMultiaddrError"},at=class extends Error{static name="ValidationError";name="ValidationError"},pn=class extends Error{static name="InvalidParametersError";name="InvalidParametersError"},fn=class extends Error{static name="UnknownProtocolError";name="UnknownProtocolError"};function ci(t){return e=>z(e,t)}function ai(t){return e=>le(e,t)}function Wt(t){return new DataView(t.buffer).getUint16(t.byteOffset).toString()}function Tt(t){let e=new ArrayBuffer(2);return new DataView(e).setUint16(0,typeof t=="string"?parseInt(t):t),new Uint8Array(e)}function Oc(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=le(e[0],"base32"),n=parseInt(e[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=Tt(n);return Ue([r,o],r.length+o.length)}function Tc(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=ht.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=Tt(n);return Ue([r,o],r.length+o.length)}function ui(t){let e=t.subarray(0,t.length-2),r=t.subarray(t.length-2),n=z(e,"base32"),o=Wt(r);return`${n}:${o}`}var di=function(t){t=t.toString().trim();let e=new Uint8Array(4);return t.split(/\./g).forEach((r,n)=>{let o=parseInt(r,10);if(isNaN(o)||o<0||o>255)throw new ie("Invalid byte value in IP address");e[n]=o}),e},Dc=function(t){let e=0;t=t.toString().trim();let r=t.split(":",8),n;for(n=0;n<r.length;n++){let i=(0,Ae.isIPv4)(r[n]),s;i&&(s=di(r[n]),r[n]=z(s.subarray(0,2),"base16")),s!=null&&++n<8&&r.splice(n,0,z(s.subarray(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++){r[n]===""&&(r[n]="0");let i=parseInt(r[n],16);if(isNaN(i)||i<0||i>65535)throw new ie("Invalid byte value in IP address");o[e++]=i>>8&255,o[e++]=i&255}return o},Uc=function(t){if(t.byteLength!==4)throw new ie("IPv4 address was incorrect length");let e=[];for(let r=0;r<t.byteLength;r++)e.push(t[r]);return e.join(".")},_c=function(t){if(t.byteLength!==16)throw new ie("IPv6 address was incorrect length");let e=[];for(let n=0;n<t.byteLength;n+=2){let o=t[n],i=t[n+1],s=`${o.toString(16).padStart(2,"0")}${i.toString(16).padStart(2,"0")}`;e.push(s)}let r=e.join(":");try{let n=new URL(`http://[${r}]`);return n.hostname.substring(1,n.hostname.length-1)}catch{throw new ie(`Invalid IPv6 address "${r}"`)}};function Pc(t){try{let e=new URL(`http://[${t}]`);return e.hostname.substring(1,e.hostname.length-1)}catch{throw new ie(`Invalid IPv6 address "${t}"`)}}var si=Object.values(ir).map(t=>t.decoder),Vd=(function(){let t=si[0].or(si[1]);return si.slice(2).forEach(e=>t=t.or(e)),t})();function Rc(t){return Vd.decode(t)}function Nc(t){return e=>t.encoder.encode(e)}function zd(t){if(parseInt(t).toString()!==t)throw new at("Value must be an integer")}function $d(t){if(t<0)throw new at("Value must be a positive integer, or zero")}function jd(t){return e=>{if(e>t)throw new at(`Value must be smaller than or equal to ${t}`)}}function Yd(...t){return e=>{for(let r of t)r(e)}}var Er=Yd(zd,$d,jd(65535));var Q=-1,li=class{protocolsByCode=new Map;protocolsByName=new Map;getProtocol(e){let r;if(typeof e=="string"?r=this.protocolsByName.get(e):r=this.protocolsByCode.get(e),r==null)throw new fn(`Protocol ${e} was unknown`);return r}addProtocol(e){this.protocolsByCode.set(e.code,e),this.protocolsByName.set(e.name,e),e.aliases?.forEach(r=>{this.protocolsByName.set(r,e)})}removeProtocol(e){let r=this.protocolsByCode.get(e);r!=null&&(this.protocolsByCode.delete(r.code),this.protocolsByName.delete(r.name),r.aliases?.forEach(n=>{this.protocolsByName.delete(n)}))}},ut=new li,_l=[{code:4,name:"ip4",size:32,valueToBytes:di,bytesToValue:Uc,validate:t=>{if(!(0,Ae.isIPv4)(t))throw new at(`Invalid IPv4 address "${t}"`)}},{code:6,name:"tcp",size:16,valueToBytes:Tt,bytesToValue:Wt,validate:Er},{code:273,name:"udp",size:16,valueToBytes:Tt,bytesToValue:Wt,validate:Er},{code:33,name:"dccp",size:16,valueToBytes:Tt,bytesToValue:Wt,validate:Er},{code:41,name:"ip6",size:128,valueToBytes:Dc,bytesToValue:_c,stringToValue:Pc,validate:t=>{if(!(0,Ae.isIPv6)(t))throw new at(`Invalid IPv6 address "${t}"`)}},{code:42,name:"ip6zone",size:Q},{code:43,name:"ipcidr",size:8,bytesToValue:ci("base10"),valueToBytes:ai("base10")},{code:53,name:"dns",size:Q},{code:54,name:"dns4",size:Q},{code:55,name:"dns6",size:Q},{code:56,name:"dnsaddr",size:Q},{code:132,name:"sctp",size:16,valueToBytes:Tt,bytesToValue:Wt,validate:Er},{code:301,name:"udt"},{code:302,name:"utp"},{code:400,name:"unix",size:Q,stringToValue:t=>decodeURIComponent(t),valueToString:t=>encodeURIComponent(t)},{code:421,name:"p2p",aliases:["ipfs"],size:Q,bytesToValue:ci("base58btc"),valueToBytes:t=>t.startsWith("Q")||t.startsWith("1")?ai("base58btc")(t):ne.parse(t).multihash.bytes},{code:444,name:"onion",size:96,bytesToValue:ui,valueToBytes:Oc},{code:445,name:"onion3",size:296,bytesToValue:ui,valueToBytes:Tc},{code:446,name:"garlic64",size:Q},{code:447,name:"garlic32",size:Q},{code:448,name:"tls"},{code:449,name:"sni",size:Q},{code:454,name:"noise"},{code:460,name:"quic"},{code:461,name:"quic-v1"},{code:465,name:"webtransport"},{code:466,name:"certhash",size:Q,bytesToValue:Nc($n),valueToBytes:Rc},{code:480,name:"http"},{code:481,name:"http-path",size:Q,stringToValue:t=>`/${decodeURIComponent(t)}`,valueToString:t=>encodeURIComponent(t.substring(1))},{code:443,name:"https"},{code:477,name:"ws"},{code:478,name:"wss"},{code:479,name:"p2p-websocket-star"},{code:277,name:"p2p-stardust"},{code:275,name:"p2p-webrtc-star"},{code:276,name:"p2p-webrtc-direct"},{code:280,name:"webrtc-direct"},{code:281,name:"webrtc"},{code:290,name:"p2p-circuit"},{code:777,name:"memory",size:Q}];_l.forEach(t=>{ut.addProtocol(t)});function Fc(t){let e=[],r=0;for(;r<t.length;){let n=Po(t,r),o=ut.getProtocol(n),i=je(n),s=Pl(o,t,r+i),c=0;s>0&&o.size===Q&&(c=je(s));let a=i+c+s,u={code:n,name:o.name,bytes:pt(t.subarray(r,r+a))};if(s>0){let h=r+i+c,d=t.subarray(h,h+s);u.value=o.bytesToValue?.(d)??z(d)}e.push(u),r+=a}return e}function kc(t){let e=0,r=[];for(let n of t){if(n.bytes==null){let o=ut.getProtocol(n.code),i=je(n.code),s,c=0,a=0;n.value!=null&&(s=o.valueToBytes?.(n.value)??le(n.value),c=s.byteLength,o.size===Q&&(a=je(c)));let u=new Uint8Array(i+a+c),h=0;pr(n.code,u,h),h+=i,s!=null&&(o.size===Q&&(pr(c,u,h),h+=a),u.set(s,h)),n.bytes=u}r.push(n.bytes),e+=n.bytes.byteLength}return Ue(r,e)}function Kc(t){if(t.charAt(0)!=="/")throw new ie('String multiaddr must start with "/"');let e=[],r="protocol",n="",o="";for(let i=1;i<t.length;i++){let s=t.charAt(i);s!=="/"&&(r==="protocol"?o+=t.charAt(i):n+=t.charAt(i));let c=i===t.length-1;if(s==="/"||c){let a=ut.getProtocol(o);if(r==="protocol"){if(a.size==null||a.size===0){e.push({code:a.code,name:a.name}),n="",o="",r="protocol";continue}else if(c)throw new ie(`Component ${o} was missing value`);r="value"}else if(r==="value"){let u={code:a.code,name:a.name};if(a.size!=null&&a.size!==0){if(n==="")throw new ie(`Component ${o} was missing value`);u.value=a.stringToValue?.(n)??n}e.push(u),n="",o="",r="protocol"}}}if(o!==""&&n!=="")throw new ie("Incomplete multiaddr");return e}function Mc(t){return`/${t.flatMap(e=>{if(e.value==null)return e.name;let r=ut.getProtocol(e.code);if(r==null)throw new ie(`Unknown protocol code ${e.code}`);return[e.name,r.valueToString?.(e.value)??e.value]}).join("/")}`}function Pl(t,e,r){return t.size==null||t.size===0?0:t.size>0?t.size/8:Po(e,r)}var Rl=Symbol.for("nodejs.util.inspect.custom"),hi=Symbol.for("@multiformats/multiaddr");function Nl(t){if(t==null&&(t="/"),Hc(t))return t.getComponents();if(t instanceof Uint8Array)return Fc(t);if(typeof t=="string")return t=t.replace(/\/(\/)+/,"/").replace(/(\/)+$/,""),t===""&&(t="/"),Kc(t);if(Array.isArray(t))return t;throw new ie("Must be a string, Uint8Array, Component[], or another Multiaddr")}var mn=class t{[hi]=!0;#e;#t;#r;constructor(e="/",r={}){this.#e=Nl(e),r.validate!==!1&&Fl(this)}get bytes(){return this.#r==null&&(this.#r=kc(this.#e)),this.#r}toString(){return this.#t==null&&(this.#t=Mc(this.#e)),this.#t}toJSON(){return this.toString()}getComponents(){return[...this.#e.map(e=>({...e}))]}encapsulate(e){let r=new t(e);return new t([...this.#e,...r.getComponents()],{validate:!1})}decapsulate(e){let r=e.toString(),n=this.toString(),o=n.lastIndexOf(r);if(o<0)throw new pn(`Address ${this.toString()} does not contain subaddress: ${r}`);return new t(n.slice(0,o),{validate:!1})}decapsulateCode(e){let r;for(let n=this.#e.length-1;n>-1;n--)if(this.#e[n].code===e){r=n;break}return new t(this.#e.slice(0,r),{validate:!1})}equals(e){return me(this.bytes,e.bytes)}[Rl](){return`Multiaddr(${this.toString()})`}};function Fl(t){t.getComponents().forEach(e=>{let r=ut.getProtocol(e.code);e.value!=null&&r.validate?.(e.value)})}function Hc(t){return!!t?.[hi]}function qc(t){return new mn(t)}function Vc(t,e,r,n){let o=()=>{n?.log.trace("query",e),t.query({questions:[{name:e,type:"PTR"}]})};return o(),setInterval(o,r)}function zc(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=>{s.type==="TXT"&&i.push(s)}),!(o==null||o?.name!==r||i.length===0||o.data.startsWith(e)))try{let s=i.flatMap(a=>a.data).filter(a=>a.toString().startsWith("dnsaddr=")).map(a=>qc(a.toString().substring(8))),c=s[0].getComponents().findLast(a=>a.code===421)?.value;if(c==null)throw new Error("Multiaddr doesn't contain PeerId");return n?.log("peer found %p",c),{id:xc(c),multiaddrs:s.map(a=>a.decapsulateCode(421))}}catch(s){n?.log.error("failed to parse mdns response - %e",s)}}function $c(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 c=[];c.push({name:o,type:"PTR",class:"IN",ttl:120,data:r+"."+o}),n.filter(kl).forEach(a=>{let u="dnsaddr="+a.toString();if(u.length>255){s?.log("multiaddr %a is too long to use in mDNS query response",a);return}if(a.getComponents().findLast(h=>h.code===421)?.value==null){s?.log("multiaddr %a did not have a peer ID so cannot be used in mDNS query response",a);return}c.push({name:r+"."+o,type:"TXT",class:"IN",ttl:120,data:u})}),s?.log.trace("responding to query"),e.respond(c)}}function kl(t){return!!Lc(t)}function jc(t){let e="",r="abcdefghijklmnopqrstuvwxyz0123456789";for(let n=0;n<t;n++)e+=r.charAt(Math.floor(Math.random()*r.length));return e}var gn=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??jc(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)}[gi]=this;[Symbol.toStringTag]="@libp2p/mdns";[bi]=["@libp2p/peer-discovery"];isStarted(){return!!this.mdns}async start(){this.mdns==null&&(this.mdns=(0,Yc.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=Vc(this.mdns,this.serviceTag,this.interval,{log:this.log}))}_onMdnsQuery(e){this.mdns!=null&&(this.log.trace("received incoming mDNS query"),$c(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=zc(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 - %e",r)}}_onMdnsWarning(e){this.log.error("mdns warning - %e",e)}_onMdnsError(e){this.log.error("mdns error - %e",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 Ml(t={}){return e=>new gn(e,t)}return Jc(Hl);})();
|
|
3
3
|
/*! Bundled license information:
|
|
4
4
|
|
|
5
5
|
@noble/curves/utils.js:
|