libp2p 0.41.0-340e2dd → 0.41.0-43d0bc6
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/src/connection-manager/index.d.ts +1 -1
- package/dist/src/connection-manager/index.d.ts.map +1 -1
- package/dist/src/connection-manager/index.js +10 -8
- package/dist/src/connection-manager/index.js.map +1 -1
- package/dist/src/identify/index.d.ts +4 -1
- package/dist/src/identify/index.d.ts.map +1 -1
- package/dist/src/libp2p.d.ts +1 -1
- package/dist/src/libp2p.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/connection-manager/index.ts +11 -9
- package/src/identify/index.ts +1 -1
- package/src/libp2p.ts +1 -1
- package/src/version.ts +1 -1
package/dist/index.min.js
CHANGED
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
`,r};ng.decode=function(t){for(var e=[],r=/\s*-----BEGIN ([A-Z0-9- ]+)-----\r?\n?([\x21-\x7e\s]+?(?:\r?\n\r?\n))?([:A-Za-z0-9+\/=\s]+?)-----END \1-----/g,n=/([\x21-\x7e]+):\s*([\x21-\x7e\s^:]+)/,i=/\r?\n/,s;s=r.exec(t),!!s;){var o=s[1];o==="NEW CERTIFICATE REQUEST"&&(o="CERTIFICATE REQUEST");var a={type:o,procType:null,contentDomain:null,dekInfo:null,headers:[],body:ac.util.decode64(s[3])};if(e.push(a),!!s[2]){for(var c=s[2].split(i),u=0;s&&u<c.length;){for(var l=c[u].replace(/\s+$/,""),f=u+1;f<c.length;++f){var h=c[f];if(!/\s/.test(h[0]))break;l+=h,u=f}if(s=l.match(n),s){for(var d={name:s[1],values:[]},p=s[2].split(","),y=0;y<p.length;++y)d.values.push(r_(p[y]));if(a.procType)if(!a.contentDomain&&d.name==="Content-Domain")a.contentDomain=p[0]||"";else if(!a.dekInfo&&d.name==="DEK-Info"){if(d.values.length===0)throw new Error('Invalid PEM formatted message. The "DEK-Info" header must have at least one subfield.');a.dekInfo={algorithm:p[0],parameters:p[1]||null}}else a.headers.push(d);else{if(d.name!=="Proc-Type")throw new Error('Invalid PEM formatted message. The first encapsulated header must be "Proc-Type".');if(d.values.length!==2)throw new Error('Invalid PEM formatted message. The "Proc-Type" header must have two subfields.');a.procType={version:p[0],type:p[1]}}}++u}if(a.procType==="ENCRYPTED"&&!a.dekInfo)throw new Error('Invalid PEM formatted message. The "DEK-Info" header must be present if "Proc-Type" is "ENCRYPTED".')}}if(e.length===0)throw new Error("Invalid PEM formatted message.");return e};function oc(t){for(var e=t.name+": ",r=[],n=function(c,u){return" "+u},i=0;i<t.values.length;++i)r.push(t.values[i].replace(/^(\S+\r\n)/,n));e+=r.join(",")+`\r
|
|
35
35
|
`;for(var s=0,o=-1,i=0;i<e.length;++i,++s)if(s>65&&o!==-1){var a=e[o];a===","?(++o,e=e.substr(0,o)+`\r
|
|
36
36
|
`+e.substr(o)):e=e.substr(0,o)+`\r
|
|
37
|
-
`+a+e.substr(o+1),s=i-o-1,o=-1,++i}else(e[i]===" "||e[i]===" "||e[i]===",")&&(o=i);return e}function r_(t){return t.replace(/^\s+/,"")}});var cg=R((U4,ag)=>{var is=ie();An();De();var U=is.asn1,ss=ag.exports=is.pkcs7asn1=is.pkcs7asn1||{};is.pkcs7=is.pkcs7||{};is.pkcs7.asn1=ss;var sg={name:"ContentInfo",tagClass:U.Class.UNIVERSAL,type:U.Type.SEQUENCE,constructed:!0,value:[{name:"ContentInfo.ContentType",tagClass:U.Class.UNIVERSAL,type:U.Type.OID,constructed:!1,capture:"contentType"},{name:"ContentInfo.content",tagClass:U.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,captureAsn1:"content"}]};ss.contentInfoValidator=sg;var og={name:"EncryptedContentInfo",tagClass:U.Class.UNIVERSAL,type:U.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedContentInfo.contentType",tagClass:U.Class.UNIVERSAL,type:U.Type.OID,constructed:!1,capture:"contentType"},{name:"EncryptedContentInfo.contentEncryptionAlgorithm",tagClass:U.Class.UNIVERSAL,type:U.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedContentInfo.contentEncryptionAlgorithm.algorithm",tagClass:U.Class.UNIVERSAL,type:U.Type.OID,constructed:!1,capture:"encAlgorithm"},{name:"EncryptedContentInfo.contentEncryptionAlgorithm.parameter",tagClass:U.Class.UNIVERSAL,captureAsn1:"encParameter"}]},{name:"EncryptedContentInfo.encryptedContent",tagClass:U.Class.CONTEXT_SPECIFIC,type:0,capture:"encryptedContent",captureAsn1:"encryptedContentAsn1"}]};ss.envelopedDataValidator={name:"EnvelopedData",tagClass:U.Class.UNIVERSAL,type:U.Type.SEQUENCE,constructed:!0,value:[{name:"EnvelopedData.Version",tagClass:U.Class.UNIVERSAL,type:U.Type.INTEGER,constructed:!1,capture:"version"},{name:"EnvelopedData.RecipientInfos",tagClass:U.Class.UNIVERSAL,type:U.Type.SET,constructed:!0,captureAsn1:"recipientInfos"}].concat(og)};ss.encryptedDataValidator={name:"EncryptedData",tagClass:U.Class.UNIVERSAL,type:U.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedData.Version",tagClass:U.Class.UNIVERSAL,type:U.Type.INTEGER,constructed:!1,capture:"version"}].concat(og)};var n_={name:"SignerInfo",tagClass:U.Class.UNIVERSAL,type:U.Type.SEQUENCE,constructed:!0,value:[{name:"SignerInfo.version",tagClass:U.Class.UNIVERSAL,type:U.Type.INTEGER,constructed:!1},{name:"SignerInfo.issuerAndSerialNumber",tagClass:U.Class.UNIVERSAL,type:U.Type.SEQUENCE,constructed:!0,value:[{name:"SignerInfo.issuerAndSerialNumber.issuer",tagClass:U.Class.UNIVERSAL,type:U.Type.SEQUENCE,constructed:!0,captureAsn1:"issuer"},{name:"SignerInfo.issuerAndSerialNumber.serialNumber",tagClass:U.Class.UNIVERSAL,type:U.Type.INTEGER,constructed:!1,capture:"serial"}]},{name:"SignerInfo.digestAlgorithm",tagClass:U.Class.UNIVERSAL,type:U.Type.SEQUENCE,constructed:!0,value:[{name:"SignerInfo.digestAlgorithm.algorithm",tagClass:U.Class.UNIVERSAL,type:U.Type.OID,constructed:!1,capture:"digestAlgorithm"},{name:"SignerInfo.digestAlgorithm.parameter",tagClass:U.Class.UNIVERSAL,constructed:!1,captureAsn1:"digestParameter",optional:!0}]},{name:"SignerInfo.authenticatedAttributes",tagClass:U.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,capture:"authenticatedAttributes"},{name:"SignerInfo.digestEncryptionAlgorithm",tagClass:U.Class.UNIVERSAL,type:U.Type.SEQUENCE,constructed:!0,capture:"signatureAlgorithm"},{name:"SignerInfo.encryptedDigest",tagClass:U.Class.UNIVERSAL,type:U.Type.OCTETSTRING,constructed:!1,capture:"signature"},{name:"SignerInfo.unauthenticatedAttributes",tagClass:U.Class.CONTEXT_SPECIFIC,type:1,constructed:!0,optional:!0,capture:"unauthenticatedAttributes"}]};ss.signedDataValidator={name:"SignedData",tagClass:U.Class.UNIVERSAL,type:U.Type.SEQUENCE,constructed:!0,value:[{name:"SignedData.Version",tagClass:U.Class.UNIVERSAL,type:U.Type.INTEGER,constructed:!1,capture:"version"},{name:"SignedData.DigestAlgorithms",tagClass:U.Class.UNIVERSAL,type:U.Type.SET,constructed:!0,captureAsn1:"digestAlgorithms"},sg,{name:"SignedData.Certificates",tagClass:U.Class.CONTEXT_SPECIFIC,type:0,optional:!0,captureAsn1:"certificates"},{name:"SignedData.CertificateRevocationLists",tagClass:U.Class.CONTEXT_SPECIFIC,type:1,optional:!0,captureAsn1:"crls"},{name:"SignedData.SignerInfos",tagClass:U.Class.UNIVERSAL,type:U.Type.SET,capture:"signerInfos",optional:!0,value:[n_]}]};ss.recipientInfoValidator={name:"RecipientInfo",tagClass:U.Class.UNIVERSAL,type:U.Type.SEQUENCE,constructed:!0,value:[{name:"RecipientInfo.version",tagClass:U.Class.UNIVERSAL,type:U.Type.INTEGER,constructed:!1,capture:"version"},{name:"RecipientInfo.issuerAndSerial",tagClass:U.Class.UNIVERSAL,type:U.Type.SEQUENCE,constructed:!0,value:[{name:"RecipientInfo.issuerAndSerial.issuer",tagClass:U.Class.UNIVERSAL,type:U.Type.SEQUENCE,constructed:!0,captureAsn1:"issuer"},{name:"RecipientInfo.issuerAndSerial.serialNumber",tagClass:U.Class.UNIVERSAL,type:U.Type.INTEGER,constructed:!1,capture:"serial"}]},{name:"RecipientInfo.keyEncryptionAlgorithm",tagClass:U.Class.UNIVERSAL,type:U.Type.SEQUENCE,constructed:!0,value:[{name:"RecipientInfo.keyEncryptionAlgorithm.algorithm",tagClass:U.Class.UNIVERSAL,type:U.Type.OID,constructed:!1,capture:"encAlgorithm"},{name:"RecipientInfo.keyEncryptionAlgorithm.parameter",tagClass:U.Class.UNIVERSAL,constructed:!1,captureAsn1:"encParameter",optional:!0}]},{name:"RecipientInfo.encryptedKey",tagClass:U.Class.UNIVERSAL,type:U.Type.OCTETSTRING,constructed:!1,capture:"encKey"}]}});var Cn=R((M4,ug)=>{var uc=ie();ug.exports=uc.md=uc.md||{};uc.md.algorithms=uc.md.algorithms||{}});var mg=R((F4,pg)=>{var vr=ie();Cn();De();var fg=pg.exports=vr.sha256=vr.sha256||{};vr.md.sha256=vr.md.algorithms.sha256=fg;fg.create=function(){hg||i_();var t=null,e=vr.util.createBuffer(),r=new Array(64),n={algorithm:"sha256",blockLength:64,digestLength:32,messageLength:0,fullMessageLength:null,messageLengthSize:8};return n.start=function(){n.messageLength=0,n.fullMessageLength=n.messageLength64=[];for(var i=n.messageLengthSize/4,s=0;s<i;++s)n.fullMessageLength.push(0);return e=vr.util.createBuffer(),t={h0:1779033703,h1:3144134277,h2:1013904242,h3:2773480762,h4:1359893119,h5:2600822924,h6:528734635,h7:1541459225},n},n.start(),n.update=function(i,s){s==="utf8"&&(i=vr.util.encodeUtf8(i));var o=i.length;n.messageLength+=o,o=[o/4294967296>>>0,o>>>0];for(var a=n.fullMessageLength.length-1;a>=0;--a)n.fullMessageLength[a]+=o[1],o[1]=o[0]+(n.fullMessageLength[a]/4294967296>>>0),n.fullMessageLength[a]=n.fullMessageLength[a]>>>0,o[0]=o[1]/4294967296>>>0;return e.putBytes(i),lg(t,r,e),(e.read>2048||e.length()===0)&&e.compact(),n},n.digest=function(){var i=vr.util.createBuffer();i.putBytes(e.bytes());var s=n.fullMessageLength[n.fullMessageLength.length-1]+n.messageLengthSize,o=s&n.blockLength-1;i.putBytes(Cf.substr(0,n.blockLength-o));for(var a,c,u=n.fullMessageLength[0]*8,l=0;l<n.fullMessageLength.length-1;++l)a=n.fullMessageLength[l+1]*8,c=a/4294967296>>>0,u+=c,i.putInt32(u>>>0),u=a>>>0;i.putInt32(u);var f={h0:t.h0,h1:t.h1,h2:t.h2,h3:t.h3,h4:t.h4,h5:t.h5,h6:t.h6,h7:t.h7};lg(f,r,i);var h=vr.util.createBuffer();return h.putInt32(f.h0),h.putInt32(f.h1),h.putInt32(f.h2),h.putInt32(f.h3),h.putInt32(f.h4),h.putInt32(f.h5),h.putInt32(f.h6),h.putInt32(f.h7),h},n};var Cf=null,hg=!1,dg=null;function i_(){Cf=String.fromCharCode(128),Cf+=vr.util.fillString(String.fromCharCode(0),64),dg=[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],hg=!0}function lg(t,e,r){for(var n,i,s,o,a,c,u,l,f,h,d,p,y,g,E,x=r.length();x>=64;){for(u=0;u<16;++u)e[u]=r.getInt32();for(;u<64;++u)n=e[u-2],n=(n>>>17|n<<15)^(n>>>19|n<<13)^n>>>10,i=e[u-15],i=(i>>>7|i<<25)^(i>>>18|i<<14)^i>>>3,e[u]=n+e[u-7]+i+e[u-16]|0;for(l=t.h0,f=t.h1,h=t.h2,d=t.h3,p=t.h4,y=t.h5,g=t.h6,E=t.h7,u=0;u<64;++u)o=(p>>>6|p<<26)^(p>>>11|p<<21)^(p>>>25|p<<7),a=g^p&(y^g),s=(l>>>2|l<<30)^(l>>>13|l<<19)^(l>>>22|l<<10),c=l&f|h&(l^f),n=E+o+a+dg[u]+e[u],i=s+c,E=g,g=y,y=p,p=d+n>>>0,d=h,h=f,f=l,l=n+i>>>0;t.h0=t.h0+l|0,t.h1=t.h1+f|0,t.h2=t.h2+h|0,t.h3=t.h3+d|0,t.h4=t.h4+p|0,t.h5=t.h5+y|0,t.h6=t.h6+g|0,t.h7=t.h7+E|0,x-=64}}});var gg=R((K4,yg)=>{var wr=ie();De();var lc=null;wr.util.isNodejs&&!wr.options.usePureJavaScript&&!process.versions["node-webkit"]&&(lc=Jn());var s_=yg.exports=wr.prng=wr.prng||{};s_.create=function(t){for(var e={plugin:t,key:null,seed:null,time:null,reseeds:0,generated:0,keyBytes:""},r=t.md,n=new Array(32),i=0;i<32;++i)n[i]=r.create();e.pools=n,e.pool=0,e.generate=function(u,l){if(!l)return e.generateSync(u);var f=e.plugin.cipher,h=e.plugin.increment,d=e.plugin.formatKey,p=e.plugin.formatSeed,y=wr.util.createBuffer();e.key=null,g();function g(E){if(E)return l(E);if(y.length()>=u)return l(null,y.getBytes(u));if(e.generated>1048575&&(e.key=null),e.key===null)return wr.util.nextTick(function(){s(g)});var x=f(e.key,e.seed);e.generated+=x.length,y.putBytes(x),e.key=d(f(e.key,h(e.seed))),e.seed=p(f(e.key,e.seed)),wr.util.setImmediate(g)}},e.generateSync=function(u){var l=e.plugin.cipher,f=e.plugin.increment,h=e.plugin.formatKey,d=e.plugin.formatSeed;e.key=null;for(var p=wr.util.createBuffer();p.length()<u;){e.generated>1048575&&(e.key=null),e.key===null&&o();var y=l(e.key,e.seed);e.generated+=y.length,p.putBytes(y),e.key=h(l(e.key,f(e.seed))),e.seed=d(l(e.key,e.seed))}return p.getBytes(u)};function s(u){if(e.pools[0].messageLength>=32)return a(),u();var l=32-e.pools[0].messageLength<<5;e.seedFile(l,function(f,h){if(f)return u(f);e.collect(h),a(),u()})}function o(){if(e.pools[0].messageLength>=32)return a();var u=32-e.pools[0].messageLength<<5;e.collect(e.seedFileSync(u)),a()}function a(){e.reseeds=e.reseeds===4294967295?0:e.reseeds+1;var u=e.plugin.md.create();u.update(e.keyBytes);for(var l=1,f=0;f<32;++f)e.reseeds%l===0&&(u.update(e.pools[f].digest().getBytes()),e.pools[f].start()),l=l<<1;e.keyBytes=u.digest().getBytes(),u.start(),u.update(e.keyBytes);var h=u.digest().getBytes();e.key=e.plugin.formatKey(e.keyBytes),e.seed=e.plugin.formatSeed(h),e.generated=0}function c(u){var l=null,f=wr.util.globalScope,h=f.crypto||f.msCrypto;h&&h.getRandomValues&&(l=function(D){return h.getRandomValues(D)});var d=wr.util.createBuffer();if(l)for(;d.length()<u;){var p=Math.max(1,Math.min(u-d.length(),65536)/4),y=new Uint32Array(Math.floor(p));try{l(y);for(var g=0;g<y.length;++g)d.putInt32(y[g])}catch(D){if(!(typeof QuotaExceededError<"u"&&D instanceof QuotaExceededError))throw D}}if(d.length()<u)for(var E,x,_,B=Math.floor(Math.random()*65536);d.length()<u;){x=16807*(B&65535),E=16807*(B>>16),x+=(E&32767)<<16,x+=E>>15,x=(x&2147483647)+(x>>31),B=x&4294967295;for(var g=0;g<3;++g)_=B>>>(g<<3),_^=Math.floor(Math.random()*256),d.putByte(_&255)}return d.getBytes(u)}return lc?(e.seedFile=function(u,l){lc.randomBytes(u,function(f,h){if(f)return l(f);l(null,h.toString())})},e.seedFileSync=function(u){return lc.randomBytes(u).toString()}):(e.seedFile=function(u,l){try{l(null,c(u))}catch(f){l(f)}},e.seedFileSync=c),e.collect=function(u){for(var l=u.length,f=0;f<l;++f)e.pools[e.pool].update(u.substr(f,1)),e.pool=e.pool===31?0:e.pool+1},e.collectInt=function(u,l){for(var f="",h=0;h<l;h+=8)f+=String.fromCharCode(u>>h&255);e.collect(f)},e.registerWorker=function(u){if(u===self)e.seedFile=function(f,h){function d(p){var y=p.data;y.forge&&y.forge.prng&&(self.removeEventListener("message",d),h(y.forge.prng.err,y.forge.prng.bytes))}self.addEventListener("message",d),self.postMessage({forge:{prng:{needed:f}}})};else{var l=function(f){var h=f.data;h.forge&&h.forge.prng&&e.seedFile(h.forge.prng.needed,function(d,p){u.postMessage({forge:{prng:{err:d,bytes:p}}})})};u.addEventListener("message",l)}},e}});var ai=R((V4,If)=>{var ht=ie();rs();mg();gg();De();(function(){if(ht.random&&ht.random.getBytes){If.exports=ht.random;return}(function(t){var e={},r=new Array(4),n=ht.util.createBuffer();e.formatKey=function(f){var h=ht.util.createBuffer(f);return f=new Array(4),f[0]=h.getInt32(),f[1]=h.getInt32(),f[2]=h.getInt32(),f[3]=h.getInt32(),ht.aes._expandKey(f,!1)},e.formatSeed=function(f){var h=ht.util.createBuffer(f);return f=new Array(4),f[0]=h.getInt32(),f[1]=h.getInt32(),f[2]=h.getInt32(),f[3]=h.getInt32(),f},e.cipher=function(f,h){return ht.aes._updateBlock(f,h,r,!1),n.putInt32(r[0]),n.putInt32(r[1]),n.putInt32(r[2]),n.putInt32(r[3]),n.getBytes()},e.increment=function(f){return++f[3],f},e.md=ht.md.sha256;function i(){var f=ht.prng.create(e);return f.getBytes=function(h,d){return f.generate(h,d)},f.getBytesSync=function(h){return f.generate(h)},f}var s=i(),o=null,a=ht.util.globalScope,c=a.crypto||a.msCrypto;if(c&&c.getRandomValues&&(o=function(f){return c.getRandomValues(f)}),ht.options.usePureJavaScript||!ht.util.isNodejs&&!o){if(typeof window>"u"||window.document,s.collectInt(+new Date,32),typeof navigator<"u"){var u="";for(var l in navigator)try{typeof navigator[l]=="string"&&(u+=navigator[l])}catch{}s.collect(u),u=null}t&&(t().mousemove(function(f){s.collectInt(f.clientX,16),s.collectInt(f.clientY,16)}),t().keypress(function(f){s.collectInt(f.charCode,8)}))}if(!ht.random)ht.random=s;else for(var l in s)ht.random[l]=s[l];ht.random.createInstance=i,If.exports=ht.random})(typeof jQuery<"u"?jQuery:null)})()});var vg=R((q4,Eg)=>{var ci=ie();De();ci.mgf=ci.mgf||{};var o_=Eg.exports=ci.mgf.mgf1=ci.mgf1=ci.mgf1||{};o_.create=function(t){var e={generate:function(r,n){for(var i=new ci.util.ByteBuffer,s=Math.ceil(n/t.digestLength),o=0;o<s;o++){var a=new ci.util.ByteBuffer;a.putInt32(o),t.start(),t.update(r+a.getBytes()),i.putBuffer(t.digest())}return i.truncate(i.length()-n),i.getBytes()}};return e}});var xg=R((H4,wg)=>{var fc=ie();vg();wg.exports=fc.mgf=fc.mgf||{};fc.mgf.mgf1=fc.mgf1});var Sg=R((z4,bg)=>{var ui=ie();ai();De();var a_=bg.exports=ui.pss=ui.pss||{};a_.create=function(t){arguments.length===3&&(t={md:arguments[0],mgf:arguments[1],saltLength:arguments[2]});var e=t.md,r=t.mgf,n=e.digestLength,i=t.salt||null;typeof i=="string"&&(i=ui.util.createBuffer(i));var s;if("saltLength"in t)s=t.saltLength;else if(i!==null)s=i.length();else throw new Error("Salt length not specified or specific salt not given.");if(i!==null&&i.length()!==s)throw new Error("Given salt length does not match length of given salt.");var o=t.prng||ui.random,a={};return a.encode=function(c,u){var l,f=u-1,h=Math.ceil(f/8),d=c.digest().getBytes();if(h<n+s+2)throw new Error("Message is too long to encrypt.");var p;i===null?p=o.getBytesSync(s):p=i.bytes();var y=new ui.util.ByteBuffer;y.fillWithByte(0,8),y.putBytes(d),y.putBytes(p),e.start(),e.update(y.getBytes());var g=e.digest().getBytes(),E=new ui.util.ByteBuffer;E.fillWithByte(0,h-s-n-2),E.putByte(1),E.putBytes(p);var x=E.getBytes(),_=h-n-1,B=r.generate(g,_),D="";for(l=0;l<_;l++)D+=String.fromCharCode(x.charCodeAt(l)^B.charCodeAt(l));var P=65280>>8*h-f&255;return D=String.fromCharCode(D.charCodeAt(0)&~P)+D.substr(1),D+g+String.fromCharCode(188)},a.verify=function(c,u,l){var f,h=l-1,d=Math.ceil(h/8);if(u=u.substr(-d),d<n+s+2)throw new Error("Inconsistent parameters to PSS signature verification.");if(u.charCodeAt(d-1)!==188)throw new Error("Encoded message does not end in 0xBC.");var p=d-n-1,y=u.substr(0,p),g=u.substr(p,n),E=65280>>8*d-h&255;if(y.charCodeAt(0)&E)throw new Error("Bits beyond keysize not zero as expected.");var x=r.generate(g,p),_="";for(f=0;f<p;f++)_+=String.fromCharCode(y.charCodeAt(f)^x.charCodeAt(f));_=String.fromCharCode(_.charCodeAt(0)&~E)+_.substr(1);var B=d-n-s-2;for(f=0;f<B;f++)if(_.charCodeAt(f)!==0)throw new Error("Leftmost octets not zero as expected");if(_.charCodeAt(B)!==1)throw new Error("Inconsistent PSS signature, 0x01 marker not found");var D=_.substr(-s),P=new ui.util.ByteBuffer;P.fillWithByte(0,8),P.putBytes(c),P.putBytes(D),e.start(),e.update(P.getBytes());var te=e.digest().getBytes();return g===te},a}});var pc=R(($4,Dg)=>{var Tf=ie();Dg.exports=Tf.jsbn=Tf.jsbn||{};var Gr,c_=0xdeadbeefcafe,_g=(c_&16777215)==15715070;function I(t,e,r){this.data=[],t!=null&&(typeof t=="number"?this.fromNumber(t,e,r):e==null&&typeof t!="string"?this.fromString(t,256):this.fromString(t,e))}Tf.jsbn.BigInteger=I;function pe(){return new I(null)}function u_(t,e,r,n,i,s){for(;--s>=0;){var o=e*this.data[t++]+r.data[n]+i;i=Math.floor(o/67108864),r.data[n++]=o&67108863}return i}function l_(t,e,r,n,i,s){for(var o=e&32767,a=e>>15;--s>=0;){var c=this.data[t]&32767,u=this.data[t++]>>15,l=a*c+u*o;c=o*c+((l&32767)<<15)+r.data[n]+(i&1073741823),i=(c>>>30)+(l>>>15)+a*u+(i>>>30),r.data[n++]=c&1073741823}return i}function Ag(t,e,r,n,i,s){for(var o=e&16383,a=e>>14;--s>=0;){var c=this.data[t]&16383,u=this.data[t++]>>14,l=a*c+u*o;c=o*c+((l&16383)<<14)+r.data[n]+i,i=(c>>28)+(l>>14)+a*u,r.data[n++]=c&268435455}return i}typeof navigator>"u"?(I.prototype.am=Ag,Gr=28):_g&&navigator.appName=="Microsoft Internet Explorer"?(I.prototype.am=l_,Gr=30):_g&&navigator.appName!="Netscape"?(I.prototype.am=u_,Gr=26):(I.prototype.am=Ag,Gr=28);I.prototype.DB=Gr;I.prototype.DM=(1<<Gr)-1;I.prototype.DV=1<<Gr;var Rf=52;I.prototype.FV=Math.pow(2,Rf);I.prototype.F1=Rf-Gr;I.prototype.F2=2*Gr-Rf;var f_="0123456789abcdefghijklmnopqrstuvwxyz",hc=new Array,os,zt;os="0".charCodeAt(0);for(zt=0;zt<=9;++zt)hc[os++]=zt;os="a".charCodeAt(0);for(zt=10;zt<36;++zt)hc[os++]=zt;os="A".charCodeAt(0);for(zt=10;zt<36;++zt)hc[os++]=zt;function Cg(t){return f_.charAt(t)}function Ig(t,e){var r=hc[t.charCodeAt(e)];return r??-1}function h_(t){for(var e=this.t-1;e>=0;--e)t.data[e]=this.data[e];t.t=this.t,t.s=this.s}function d_(t){this.t=1,this.s=t<0?-1:0,t>0?this.data[0]=t:t<-1?this.data[0]=t+this.DV:this.t=0}function In(t){var e=pe();return e.fromInt(t),e}function p_(t,e){var r;if(e==16)r=4;else if(e==8)r=3;else if(e==256)r=8;else if(e==2)r=1;else if(e==32)r=5;else if(e==4)r=2;else{this.fromRadix(t,e);return}this.t=0,this.s=0;for(var n=t.length,i=!1,s=0;--n>=0;){var o=r==8?t[n]&255:Ig(t,n);if(o<0){t.charAt(n)=="-"&&(i=!0);continue}i=!1,s==0?this.data[this.t++]=o:s+r>this.DB?(this.data[this.t-1]|=(o&(1<<this.DB-s)-1)<<s,this.data[this.t++]=o>>this.DB-s):this.data[this.t-1]|=o<<s,s+=r,s>=this.DB&&(s-=this.DB)}r==8&&t[0]&128&&(this.s=-1,s>0&&(this.data[this.t-1]|=(1<<this.DB-s)-1<<s)),this.clamp(),i&&I.ZERO.subTo(this,this)}function m_(){for(var t=this.s&this.DM;this.t>0&&this.data[this.t-1]==t;)--this.t}function y_(t){if(this.s<0)return"-"+this.negate().toString(t);var e;if(t==16)e=4;else if(t==8)e=3;else if(t==2)e=1;else if(t==32)e=5;else if(t==4)e=2;else return this.toRadix(t);var r=(1<<e)-1,n,i=!1,s="",o=this.t,a=this.DB-o*this.DB%e;if(o-- >0)for(a<this.DB&&(n=this.data[o]>>a)>0&&(i=!0,s=Cg(n));o>=0;)a<e?(n=(this.data[o]&(1<<a)-1)<<e-a,n|=this.data[--o]>>(a+=this.DB-e)):(n=this.data[o]>>(a-=e)&r,a<=0&&(a+=this.DB,--o)),n>0&&(i=!0),i&&(s+=Cg(n));return i?s:"0"}function g_(){var t=pe();return I.ZERO.subTo(this,t),t}function E_(){return this.s<0?this.negate():this}function v_(t){var e=this.s-t.s;if(e!=0)return e;var r=this.t;if(e=r-t.t,e!=0)return this.s<0?-e:e;for(;--r>=0;)if((e=this.data[r]-t.data[r])!=0)return e;return 0}function dc(t){var e=1,r;return(r=t>>>16)!=0&&(t=r,e+=16),(r=t>>8)!=0&&(t=r,e+=8),(r=t>>4)!=0&&(t=r,e+=4),(r=t>>2)!=0&&(t=r,e+=2),(r=t>>1)!=0&&(t=r,e+=1),e}function w_(){return this.t<=0?0:this.DB*(this.t-1)+dc(this.data[this.t-1]^this.s&this.DM)}function x_(t,e){var r;for(r=this.t-1;r>=0;--r)e.data[r+t]=this.data[r];for(r=t-1;r>=0;--r)e.data[r]=0;e.t=this.t+t,e.s=this.s}function b_(t,e){for(var r=t;r<this.t;++r)e.data[r-t]=this.data[r];e.t=Math.max(this.t-t,0),e.s=this.s}function S_(t,e){var r=t%this.DB,n=this.DB-r,i=(1<<n)-1,s=Math.floor(t/this.DB),o=this.s<<r&this.DM,a;for(a=this.t-1;a>=0;--a)e.data[a+s+1]=this.data[a]>>n|o,o=(this.data[a]&i)<<r;for(a=s-1;a>=0;--a)e.data[a]=0;e.data[s]=o,e.t=this.t+s+1,e.s=this.s,e.clamp()}function __(t,e){e.s=this.s;var r=Math.floor(t/this.DB);if(r>=this.t){e.t=0;return}var n=t%this.DB,i=this.DB-n,s=(1<<n)-1;e.data[0]=this.data[r]>>n;for(var o=r+1;o<this.t;++o)e.data[o-r-1]|=(this.data[o]&s)<<i,e.data[o-r]=this.data[o]>>n;n>0&&(e.data[this.t-r-1]|=(this.s&s)<<i),e.t=this.t-r,e.clamp()}function A_(t,e){for(var r=0,n=0,i=Math.min(t.t,this.t);r<i;)n+=this.data[r]-t.data[r],e.data[r++]=n&this.DM,n>>=this.DB;if(t.t<this.t){for(n-=t.s;r<this.t;)n+=this.data[r],e.data[r++]=n&this.DM,n>>=this.DB;n+=this.s}else{for(n+=this.s;r<t.t;)n-=t.data[r],e.data[r++]=n&this.DM,n>>=this.DB;n-=t.s}e.s=n<0?-1:0,n<-1?e.data[r++]=this.DV+n:n>0&&(e.data[r++]=n),e.t=r,e.clamp()}function C_(t,e){var r=this.abs(),n=t.abs(),i=r.t;for(e.t=i+n.t;--i>=0;)e.data[i]=0;for(i=0;i<n.t;++i)e.data[i+r.t]=r.am(0,n.data[i],e,i,0,r.t);e.s=0,e.clamp(),this.s!=t.s&&I.ZERO.subTo(e,e)}function I_(t){for(var e=this.abs(),r=t.t=2*e.t;--r>=0;)t.data[r]=0;for(r=0;r<e.t-1;++r){var n=e.am(r,e.data[r],t,2*r,0,1);(t.data[r+e.t]+=e.am(r+1,2*e.data[r],t,2*r+1,n,e.t-r-1))>=e.DV&&(t.data[r+e.t]-=e.DV,t.data[r+e.t+1]=1)}t.t>0&&(t.data[t.t-1]+=e.am(r,e.data[r],t,2*r,0,1)),t.s=0,t.clamp()}function T_(t,e,r){var n=t.abs();if(!(n.t<=0)){var i=this.abs();if(i.t<n.t){e?.fromInt(0),r!=null&&this.copyTo(r);return}r==null&&(r=pe());var s=pe(),o=this.s,a=t.s,c=this.DB-dc(n.data[n.t-1]);c>0?(n.lShiftTo(c,s),i.lShiftTo(c,r)):(n.copyTo(s),i.copyTo(r));var u=s.t,l=s.data[u-1];if(l!=0){var f=l*(1<<this.F1)+(u>1?s.data[u-2]>>this.F2:0),h=this.FV/f,d=(1<<this.F1)/f,p=1<<this.F2,y=r.t,g=y-u,E=e??pe();for(s.dlShiftTo(g,E),r.compareTo(E)>=0&&(r.data[r.t++]=1,r.subTo(E,r)),I.ONE.dlShiftTo(u,E),E.subTo(s,s);s.t<u;)s.data[s.t++]=0;for(;--g>=0;){var x=r.data[--y]==l?this.DM:Math.floor(r.data[y]*h+(r.data[y-1]+p)*d);if((r.data[y]+=s.am(0,x,r,g,0,u))<x)for(s.dlShiftTo(g,E),r.subTo(E,r);r.data[y]<--x;)r.subTo(E,r)}e!=null&&(r.drShiftTo(u,e),o!=a&&I.ZERO.subTo(e,e)),r.t=u,r.clamp(),c>0&&r.rShiftTo(c,r),o<0&&I.ZERO.subTo(r,r)}}}function R_(t){var e=pe();return this.abs().divRemTo(t,null,e),this.s<0&&e.compareTo(I.ZERO)>0&&t.subTo(e,e),e}function li(t){this.m=t}function N_(t){return t.s<0||t.compareTo(this.m)>=0?t.mod(this.m):t}function D_(t){return t}function L_(t){t.divRemTo(this.m,null,t)}function P_(t,e,r){t.multiplyTo(e,r),this.reduce(r)}function B_(t,e){t.squareTo(e),this.reduce(e)}li.prototype.convert=N_;li.prototype.revert=D_;li.prototype.reduce=L_;li.prototype.mulTo=P_;li.prototype.sqrTo=B_;function O_(){if(this.t<1)return 0;var t=this.data[0];if(!(t&1))return 0;var e=t&3;return e=e*(2-(t&15)*e)&15,e=e*(2-(t&255)*e)&255,e=e*(2-((t&65535)*e&65535))&65535,e=e*(2-t*e%this.DV)%this.DV,e>0?this.DV-e:-e}function fi(t){this.m=t,this.mp=t.invDigit(),this.mpl=this.mp&32767,this.mph=this.mp>>15,this.um=(1<<t.DB-15)-1,this.mt2=2*t.t}function k_(t){var e=pe();return t.abs().dlShiftTo(this.m.t,e),e.divRemTo(this.m,null,e),t.s<0&&e.compareTo(I.ZERO)>0&&this.m.subTo(e,e),e}function U_(t){var e=pe();return t.copyTo(e),this.reduce(e),e}function M_(t){for(;t.t<=this.mt2;)t.data[t.t++]=0;for(var e=0;e<this.m.t;++e){var r=t.data[e]&32767,n=r*this.mpl+((r*this.mph+(t.data[e]>>15)*this.mpl&this.um)<<15)&t.DM;for(r=e+this.m.t,t.data[r]+=this.m.am(0,n,t,e,0,this.m.t);t.data[r]>=t.DV;)t.data[r]-=t.DV,t.data[++r]++}t.clamp(),t.drShiftTo(this.m.t,t),t.compareTo(this.m)>=0&&t.subTo(this.m,t)}function F_(t,e){t.squareTo(e),this.reduce(e)}function K_(t,e,r){t.multiplyTo(e,r),this.reduce(r)}fi.prototype.convert=k_;fi.prototype.revert=U_;fi.prototype.reduce=M_;fi.prototype.mulTo=K_;fi.prototype.sqrTo=F_;function V_(){return(this.t>0?this.data[0]&1:this.s)==0}function q_(t,e){if(t>4294967295||t<1)return I.ONE;var r=pe(),n=pe(),i=e.convert(this),s=dc(t)-1;for(i.copyTo(r);--s>=0;)if(e.sqrTo(r,n),(t&1<<s)>0)e.mulTo(n,i,r);else{var o=r;r=n,n=o}return e.revert(r)}function H_(t,e){var r;return t<256||e.isEven()?r=new li(e):r=new fi(e),this.exp(t,r)}I.prototype.copyTo=h_;I.prototype.fromInt=d_;I.prototype.fromString=p_;I.prototype.clamp=m_;I.prototype.dlShiftTo=x_;I.prototype.drShiftTo=b_;I.prototype.lShiftTo=S_;I.prototype.rShiftTo=__;I.prototype.subTo=A_;I.prototype.multiplyTo=C_;I.prototype.squareTo=I_;I.prototype.divRemTo=T_;I.prototype.invDigit=O_;I.prototype.isEven=V_;I.prototype.exp=q_;I.prototype.toString=y_;I.prototype.negate=g_;I.prototype.abs=E_;I.prototype.compareTo=v_;I.prototype.bitLength=w_;I.prototype.mod=R_;I.prototype.modPowInt=H_;I.ZERO=In(0);I.ONE=In(1);function z_(){var t=pe();return this.copyTo(t),t}function $_(){if(this.s<0){if(this.t==1)return this.data[0]-this.DV;if(this.t==0)return-1}else{if(this.t==1)return this.data[0];if(this.t==0)return 0}return(this.data[1]&(1<<32-this.DB)-1)<<this.DB|this.data[0]}function G_(){return this.t==0?this.s:this.data[0]<<24>>24}function Y_(){return this.t==0?this.s:this.data[0]<<16>>16}function W_(t){return Math.floor(Math.LN2*this.DB/Math.log(t))}function Q_(){return this.s<0?-1:this.t<=0||this.t==1&&this.data[0]<=0?0:1}function X_(t){if(t==null&&(t=10),this.signum()==0||t<2||t>36)return"0";var e=this.chunkSize(t),r=Math.pow(t,e),n=In(r),i=pe(),s=pe(),o="";for(this.divRemTo(n,i,s);i.signum()>0;)o=(r+s.intValue()).toString(t).substr(1)+o,i.divRemTo(n,i,s);return s.intValue().toString(t)+o}function j_(t,e){this.fromInt(0),e==null&&(e=10);for(var r=this.chunkSize(e),n=Math.pow(e,r),i=!1,s=0,o=0,a=0;a<t.length;++a){var c=Ig(t,a);if(c<0){t.charAt(a)=="-"&&this.signum()==0&&(i=!0);continue}o=e*o+c,++s>=r&&(this.dMultiply(n),this.dAddOffset(o,0),s=0,o=0)}s>0&&(this.dMultiply(Math.pow(e,s)),this.dAddOffset(o,0)),i&&I.ZERO.subTo(this,this)}function Z_(t,e,r){if(typeof e=="number")if(t<2)this.fromInt(1);else for(this.fromNumber(t,r),this.testBit(t-1)||this.bitwiseTo(I.ONE.shiftLeft(t-1),Nf,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(e);)this.dAddOffset(2,0),this.bitLength()>t&&this.subTo(I.ONE.shiftLeft(t-1),this);else{var n=new Array,i=t&7;n.length=(t>>3)+1,e.nextBytes(n),i>0?n[0]&=(1<<i)-1:n[0]=0,this.fromString(n,256)}}function J_(){var t=this.t,e=new Array;e[0]=this.s;var r=this.DB-t*this.DB%8,n,i=0;if(t-- >0)for(r<this.DB&&(n=this.data[t]>>r)!=(this.s&this.DM)>>r&&(e[i++]=n|this.s<<this.DB-r);t>=0;)r<8?(n=(this.data[t]&(1<<r)-1)<<8-r,n|=this.data[--t]>>(r+=this.DB-8)):(n=this.data[t]>>(r-=8)&255,r<=0&&(r+=this.DB,--t)),n&128&&(n|=-256),i==0&&(this.s&128)!=(n&128)&&++i,(i>0||n!=this.s)&&(e[i++]=n);return e}function eA(t){return this.compareTo(t)==0}function tA(t){return this.compareTo(t)<0?this:t}function rA(t){return this.compareTo(t)>0?this:t}function nA(t,e,r){var n,i,s=Math.min(t.t,this.t);for(n=0;n<s;++n)r.data[n]=e(this.data[n],t.data[n]);if(t.t<this.t){for(i=t.s&this.DM,n=s;n<this.t;++n)r.data[n]=e(this.data[n],i);r.t=this.t}else{for(i=this.s&this.DM,n=s;n<t.t;++n)r.data[n]=e(i,t.data[n]);r.t=t.t}r.s=e(this.s,t.s),r.clamp()}function iA(t,e){return t&e}function sA(t){var e=pe();return this.bitwiseTo(t,iA,e),e}function Nf(t,e){return t|e}function oA(t){var e=pe();return this.bitwiseTo(t,Nf,e),e}function Tg(t,e){return t^e}function aA(t){var e=pe();return this.bitwiseTo(t,Tg,e),e}function Rg(t,e){return t&~e}function cA(t){var e=pe();return this.bitwiseTo(t,Rg,e),e}function uA(){for(var t=pe(),e=0;e<this.t;++e)t.data[e]=this.DM&~this.data[e];return t.t=this.t,t.s=~this.s,t}function lA(t){var e=pe();return t<0?this.rShiftTo(-t,e):this.lShiftTo(t,e),e}function fA(t){var e=pe();return t<0?this.lShiftTo(-t,e):this.rShiftTo(t,e),e}function hA(t){if(t==0)return-1;var e=0;return t&65535||(t>>=16,e+=16),t&255||(t>>=8,e+=8),t&15||(t>>=4,e+=4),t&3||(t>>=2,e+=2),t&1||++e,e}function dA(){for(var t=0;t<this.t;++t)if(this.data[t]!=0)return t*this.DB+hA(this.data[t]);return this.s<0?this.t*this.DB:-1}function pA(t){for(var e=0;t!=0;)t&=t-1,++e;return e}function mA(){for(var t=0,e=this.s&this.DM,r=0;r<this.t;++r)t+=pA(this.data[r]^e);return t}function yA(t){var e=Math.floor(t/this.DB);return e>=this.t?this.s!=0:(this.data[e]&1<<t%this.DB)!=0}function gA(t,e){var r=I.ONE.shiftLeft(t);return this.bitwiseTo(r,e,r),r}function EA(t){return this.changeBit(t,Nf)}function vA(t){return this.changeBit(t,Rg)}function wA(t){return this.changeBit(t,Tg)}function xA(t,e){for(var r=0,n=0,i=Math.min(t.t,this.t);r<i;)n+=this.data[r]+t.data[r],e.data[r++]=n&this.DM,n>>=this.DB;if(t.t<this.t){for(n+=t.s;r<this.t;)n+=this.data[r],e.data[r++]=n&this.DM,n>>=this.DB;n+=this.s}else{for(n+=this.s;r<t.t;)n+=t.data[r],e.data[r++]=n&this.DM,n>>=this.DB;n+=t.s}e.s=n<0?-1:0,n>0?e.data[r++]=n:n<-1&&(e.data[r++]=this.DV+n),e.t=r,e.clamp()}function bA(t){var e=pe();return this.addTo(t,e),e}function SA(t){var e=pe();return this.subTo(t,e),e}function _A(t){var e=pe();return this.multiplyTo(t,e),e}function AA(t){var e=pe();return this.divRemTo(t,e,null),e}function CA(t){var e=pe();return this.divRemTo(t,null,e),e}function IA(t){var e=pe(),r=pe();return this.divRemTo(t,e,r),new Array(e,r)}function TA(t){this.data[this.t]=this.am(0,t-1,this,0,0,this.t),++this.t,this.clamp()}function RA(t,e){if(t!=0){for(;this.t<=e;)this.data[this.t++]=0;for(this.data[e]+=t;this.data[e]>=this.DV;)this.data[e]-=this.DV,++e>=this.t&&(this.data[this.t++]=0),++this.data[e]}}function oo(){}function Ng(t){return t}function NA(t,e,r){t.multiplyTo(e,r)}function DA(t,e){t.squareTo(e)}oo.prototype.convert=Ng;oo.prototype.revert=Ng;oo.prototype.mulTo=NA;oo.prototype.sqrTo=DA;function LA(t){return this.exp(t,new oo)}function PA(t,e,r){var n=Math.min(this.t+t.t,e);for(r.s=0,r.t=n;n>0;)r.data[--n]=0;var i;for(i=r.t-this.t;n<i;++n)r.data[n+this.t]=this.am(0,t.data[n],r,n,0,this.t);for(i=Math.min(t.t,e);n<i;++n)this.am(0,t.data[n],r,n,0,e-n);r.clamp()}function BA(t,e,r){--e;var n=r.t=this.t+t.t-e;for(r.s=0;--n>=0;)r.data[n]=0;for(n=Math.max(e-this.t,0);n<t.t;++n)r.data[this.t+n-e]=this.am(e-n,t.data[n],r,0,0,this.t+n-e);r.clamp(),r.drShiftTo(1,r)}function as(t){this.r2=pe(),this.q3=pe(),I.ONE.dlShiftTo(2*t.t,this.r2),this.mu=this.r2.divide(t),this.m=t}function OA(t){if(t.s<0||t.t>2*this.m.t)return t.mod(this.m);if(t.compareTo(this.m)<0)return t;var e=pe();return t.copyTo(e),this.reduce(e),e}function kA(t){return t}function UA(t){for(t.drShiftTo(this.m.t-1,this.r2),t.t>this.m.t+1&&(t.t=this.m.t+1,t.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);t.compareTo(this.r2)<0;)t.dAddOffset(1,this.m.t+1);for(t.subTo(this.r2,t);t.compareTo(this.m)>=0;)t.subTo(this.m,t)}function MA(t,e){t.squareTo(e),this.reduce(e)}function FA(t,e,r){t.multiplyTo(e,r),this.reduce(r)}as.prototype.convert=OA;as.prototype.revert=kA;as.prototype.reduce=UA;as.prototype.mulTo=FA;as.prototype.sqrTo=MA;function KA(t,e){var r=t.bitLength(),n,i=In(1),s;if(r<=0)return i;r<18?n=1:r<48?n=3:r<144?n=4:r<768?n=5:n=6,r<8?s=new li(e):e.isEven()?s=new as(e):s=new fi(e);var o=new Array,a=3,c=n-1,u=(1<<n)-1;if(o[1]=s.convert(this),n>1){var l=pe();for(s.sqrTo(o[1],l);a<=u;)o[a]=pe(),s.mulTo(l,o[a-2],o[a]),a+=2}var f=t.t-1,h,d=!0,p=pe(),y;for(r=dc(t.data[f])-1;f>=0;){for(r>=c?h=t.data[f]>>r-c&u:(h=(t.data[f]&(1<<r+1)-1)<<c-r,f>0&&(h|=t.data[f-1]>>this.DB+r-c)),a=n;!(h&1);)h>>=1,--a;if((r-=a)<0&&(r+=this.DB,--f),d)o[h].copyTo(i),d=!1;else{for(;a>1;)s.sqrTo(i,p),s.sqrTo(p,i),a-=2;a>0?s.sqrTo(i,p):(y=i,i=p,p=y),s.mulTo(p,o[h],i)}for(;f>=0&&!(t.data[f]&1<<r);)s.sqrTo(i,p),y=i,i=p,p=y,--r<0&&(r=this.DB-1,--f)}return s.revert(i)}function VA(t){var e=this.s<0?this.negate():this.clone(),r=t.s<0?t.negate():t.clone();if(e.compareTo(r)<0){var n=e;e=r,r=n}var i=e.getLowestSetBit(),s=r.getLowestSetBit();if(s<0)return e;for(i<s&&(s=i),s>0&&(e.rShiftTo(s,e),r.rShiftTo(s,r));e.signum()>0;)(i=e.getLowestSetBit())>0&&e.rShiftTo(i,e),(i=r.getLowestSetBit())>0&&r.rShiftTo(i,r),e.compareTo(r)>=0?(e.subTo(r,e),e.rShiftTo(1,e)):(r.subTo(e,r),r.rShiftTo(1,r));return s>0&&r.lShiftTo(s,r),r}function qA(t){if(t<=0)return 0;var e=this.DV%t,r=this.s<0?t-1:0;if(this.t>0)if(e==0)r=this.data[0]%t;else for(var n=this.t-1;n>=0;--n)r=(e*r+this.data[n])%t;return r}function HA(t){var e=t.isEven();if(this.isEven()&&e||t.signum()==0)return I.ZERO;for(var r=t.clone(),n=this.clone(),i=In(1),s=In(0),o=In(0),a=In(1);r.signum()!=0;){for(;r.isEven();)r.rShiftTo(1,r),e?((!i.isEven()||!s.isEven())&&(i.addTo(this,i),s.subTo(t,s)),i.rShiftTo(1,i)):s.isEven()||s.subTo(t,s),s.rShiftTo(1,s);for(;n.isEven();)n.rShiftTo(1,n),e?((!o.isEven()||!a.isEven())&&(o.addTo(this,o),a.subTo(t,a)),o.rShiftTo(1,o)):a.isEven()||a.subTo(t,a),a.rShiftTo(1,a);r.compareTo(n)>=0?(r.subTo(n,r),e&&i.subTo(o,i),s.subTo(a,s)):(n.subTo(r,n),e&&o.subTo(i,o),a.subTo(s,a))}if(n.compareTo(I.ONE)!=0)return I.ZERO;if(a.compareTo(t)>=0)return a.subtract(t);if(a.signum()<0)a.addTo(t,a);else return a;return a.signum()<0?a.add(t):a}var nr=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509],zA=(1<<26)/nr[nr.length-1];function $A(t){var e,r=this.abs();if(r.t==1&&r.data[0]<=nr[nr.length-1]){for(e=0;e<nr.length;++e)if(r.data[0]==nr[e])return!0;return!1}if(r.isEven())return!1;for(e=1;e<nr.length;){for(var n=nr[e],i=e+1;i<nr.length&&n<zA;)n*=nr[i++];for(n=r.modInt(n);e<i;)if(n%nr[e++]==0)return!1}return r.millerRabin(t)}function GA(t){var e=this.subtract(I.ONE),r=e.getLowestSetBit();if(r<=0)return!1;for(var n=e.shiftRight(r),i=YA(),s,o=0;o<t;++o){do s=new I(this.bitLength(),i);while(s.compareTo(I.ONE)<=0||s.compareTo(e)>=0);var a=s.modPow(n,this);if(a.compareTo(I.ONE)!=0&&a.compareTo(e)!=0){for(var c=1;c++<r&&a.compareTo(e)!=0;)if(a=a.modPowInt(2,this),a.compareTo(I.ONE)==0)return!1;if(a.compareTo(e)!=0)return!1}}return!0}function YA(){return{nextBytes:function(t){for(var e=0;e<t.length;++e)t[e]=Math.floor(Math.random()*256)}}}I.prototype.chunkSize=W_;I.prototype.toRadix=X_;I.prototype.fromRadix=j_;I.prototype.fromNumber=Z_;I.prototype.bitwiseTo=nA;I.prototype.changeBit=gA;I.prototype.addTo=xA;I.prototype.dMultiply=TA;I.prototype.dAddOffset=RA;I.prototype.multiplyLowerTo=PA;I.prototype.multiplyUpperTo=BA;I.prototype.modInt=qA;I.prototype.millerRabin=GA;I.prototype.clone=z_;I.prototype.intValue=$_;I.prototype.byteValue=G_;I.prototype.shortValue=Y_;I.prototype.signum=Q_;I.prototype.toByteArray=J_;I.prototype.equals=eA;I.prototype.min=tA;I.prototype.max=rA;I.prototype.and=sA;I.prototype.or=oA;I.prototype.xor=aA;I.prototype.andNot=cA;I.prototype.not=uA;I.prototype.shiftLeft=lA;I.prototype.shiftRight=fA;I.prototype.getLowestSetBit=dA;I.prototype.bitCount=mA;I.prototype.testBit=yA;I.prototype.setBit=EA;I.prototype.clearBit=vA;I.prototype.flipBit=wA;I.prototype.add=bA;I.prototype.subtract=SA;I.prototype.multiply=_A;I.prototype.divide=AA;I.prototype.remainder=CA;I.prototype.divideAndRemainder=IA;I.prototype.modPow=KA;I.prototype.modInverse=HA;I.prototype.pow=LA;I.prototype.gcd=VA;I.prototype.isProbablePrime=$A});var kg=R((G4,Og)=>{var xr=ie();Cn();De();var Pg=Og.exports=xr.sha1=xr.sha1||{};xr.md.sha1=xr.md.algorithms.sha1=Pg;Pg.create=function(){Bg||WA();var t=null,e=xr.util.createBuffer(),r=new Array(80),n={algorithm:"sha1",blockLength:64,digestLength:20,messageLength:0,fullMessageLength:null,messageLengthSize:8};return n.start=function(){n.messageLength=0,n.fullMessageLength=n.messageLength64=[];for(var i=n.messageLengthSize/4,s=0;s<i;++s)n.fullMessageLength.push(0);return e=xr.util.createBuffer(),t={h0:1732584193,h1:4023233417,h2:2562383102,h3:271733878,h4:3285377520},n},n.start(),n.update=function(i,s){s==="utf8"&&(i=xr.util.encodeUtf8(i));var o=i.length;n.messageLength+=o,o=[o/4294967296>>>0,o>>>0];for(var a=n.fullMessageLength.length-1;a>=0;--a)n.fullMessageLength[a]+=o[1],o[1]=o[0]+(n.fullMessageLength[a]/4294967296>>>0),n.fullMessageLength[a]=n.fullMessageLength[a]>>>0,o[0]=o[1]/4294967296>>>0;return e.putBytes(i),Lg(t,r,e),(e.read>2048||e.length()===0)&&e.compact(),n},n.digest=function(){var i=xr.util.createBuffer();i.putBytes(e.bytes());var s=n.fullMessageLength[n.fullMessageLength.length-1]+n.messageLengthSize,o=s&n.blockLength-1;i.putBytes(Df.substr(0,n.blockLength-o));for(var a,c,u=n.fullMessageLength[0]*8,l=0;l<n.fullMessageLength.length-1;++l)a=n.fullMessageLength[l+1]*8,c=a/4294967296>>>0,u+=c,i.putInt32(u>>>0),u=a>>>0;i.putInt32(u);var f={h0:t.h0,h1:t.h1,h2:t.h2,h3:t.h3,h4:t.h4};Lg(f,r,i);var h=xr.util.createBuffer();return h.putInt32(f.h0),h.putInt32(f.h1),h.putInt32(f.h2),h.putInt32(f.h3),h.putInt32(f.h4),h},n};var Df=null,Bg=!1;function WA(){Df=String.fromCharCode(128),Df+=xr.util.fillString(String.fromCharCode(0),64),Bg=!0}function Lg(t,e,r){for(var n,i,s,o,a,c,u,l,f=r.length();f>=64;){for(i=t.h0,s=t.h1,o=t.h2,a=t.h3,c=t.h4,l=0;l<16;++l)n=r.getInt32(),e[l]=n,u=a^s&(o^a),n=(i<<5|i>>>27)+u+c+1518500249+n,c=a,a=o,o=(s<<30|s>>>2)>>>0,s=i,i=n;for(;l<20;++l)n=e[l-3]^e[l-8]^e[l-14]^e[l-16],n=n<<1|n>>>31,e[l]=n,u=a^s&(o^a),n=(i<<5|i>>>27)+u+c+1518500249+n,c=a,a=o,o=(s<<30|s>>>2)>>>0,s=i,i=n;for(;l<32;++l)n=e[l-3]^e[l-8]^e[l-14]^e[l-16],n=n<<1|n>>>31,e[l]=n,u=s^o^a,n=(i<<5|i>>>27)+u+c+1859775393+n,c=a,a=o,o=(s<<30|s>>>2)>>>0,s=i,i=n;for(;l<40;++l)n=e[l-6]^e[l-16]^e[l-28]^e[l-32],n=n<<2|n>>>30,e[l]=n,u=s^o^a,n=(i<<5|i>>>27)+u+c+1859775393+n,c=a,a=o,o=(s<<30|s>>>2)>>>0,s=i,i=n;for(;l<60;++l)n=e[l-6]^e[l-16]^e[l-28]^e[l-32],n=n<<2|n>>>30,e[l]=n,u=s&o|a&(s^o),n=(i<<5|i>>>27)+u+c+2400959708+n,c=a,a=o,o=(s<<30|s>>>2)>>>0,s=i,i=n;for(;l<80;++l)n=e[l-6]^e[l-16]^e[l-28]^e[l-32],n=n<<2|n>>>30,e[l]=n,u=s^o^a,n=(i<<5|i>>>27)+u+c+3395469782+n,c=a,a=o,o=(s<<30|s>>>2)>>>0,s=i,i=n;t.h0=t.h0+i|0,t.h1=t.h1+s|0,t.h2=t.h2+o|0,t.h3=t.h3+a|0,t.h4=t.h4+c|0,f-=64}}});var Fg=R((Y4,Mg)=>{var br=ie();De();ai();kg();var Ug=Mg.exports=br.pkcs1=br.pkcs1||{};Ug.encode_rsa_oaep=function(t,e,r){var n,i,s,o;typeof r=="string"?(n=r,i=arguments[3]||void 0,s=arguments[4]||void 0):r&&(n=r.label||void 0,i=r.seed||void 0,s=r.md||void 0,r.mgf1&&r.mgf1.md&&(o=r.mgf1.md)),s?s.start():s=br.md.sha1.create(),o||(o=s);var a=Math.ceil(t.n.bitLength()/8),c=a-2*s.digestLength-2;if(e.length>c){var u=new Error("RSAES-OAEP input message length is too long.");throw u.length=e.length,u.maxLength=c,u}n||(n=""),s.update(n,"raw");for(var l=s.digest(),f="",h=c-e.length,d=0;d<h;d++)f+="\0";var p=l.getBytes()+f+""+e;if(!i)i=br.random.getBytes(s.digestLength);else if(i.length!==s.digestLength){var u=new Error("Invalid RSAES-OAEP seed. The seed length must match the digest length.");throw u.seedLength=i.length,u.digestLength=s.digestLength,u}var y=mc(i,a-s.digestLength-1,o),g=br.util.xorBytes(p,y,p.length),E=mc(g,s.digestLength,o),x=br.util.xorBytes(i,E,i.length);return"\0"+x+g};Ug.decode_rsa_oaep=function(t,e,r){var n,i,s;typeof r=="string"?(n=r,i=arguments[3]||void 0):r&&(n=r.label||void 0,i=r.md||void 0,r.mgf1&&r.mgf1.md&&(s=r.mgf1.md));var o=Math.ceil(t.n.bitLength()/8);if(e.length!==o){var g=new Error("RSAES-OAEP encoded message length is invalid.");throw g.length=e.length,g.expectedLength=o,g}if(i===void 0?i=br.md.sha1.create():i.start(),s||(s=i),o<2*i.digestLength+2)throw new Error("RSAES-OAEP key is too short for the hash function.");n||(n=""),i.update(n,"raw");for(var a=i.digest().getBytes(),c=e.charAt(0),u=e.substring(1,i.digestLength+1),l=e.substring(1+i.digestLength),f=mc(l,i.digestLength,s),h=br.util.xorBytes(u,f,u.length),d=mc(h,o-i.digestLength-1,s),p=br.util.xorBytes(l,d,l.length),y=p.substring(0,i.digestLength),g=c!=="\0",E=0;E<i.digestLength;++E)g|=a.charAt(E)!==y.charAt(E);for(var x=1,_=i.digestLength,B=i.digestLength;B<p.length;B++){var D=p.charCodeAt(B),P=D&1^1,te=x?65534:0;g|=D&te,x=x&P,_+=x}if(g||p.charCodeAt(_)!==1)throw new Error("Invalid RSAES-OAEP padding.");return p.substring(_+1)};function mc(t,e,r){r||(r=br.md.sha1.create());for(var n="",i=Math.ceil(e/r.digestLength),s=0;s<i;++s){var o=String.fromCharCode(s>>24&255,s>>16&255,s>>8&255,s&255);r.start(),r.update(t+o),n+=r.digest().getBytes()}return n.substring(0,e)}});var Kg=R((W4,Lf)=>{var Tn=ie();De();pc();ai();(function(){if(Tn.prime){Lf.exports=Tn.prime;return}var t=Lf.exports=Tn.prime=Tn.prime||{},e=Tn.jsbn.BigInteger,r=[6,4,2,4,2,4,6,2],n=new e(null);n.fromInt(30);var i=function(f,h){return f|h};t.generateProbablePrime=function(f,h,d){typeof h=="function"&&(d=h,h={}),h=h||{};var p=h.algorithm||"PRIMEINC";typeof p=="string"&&(p={name:p}),p.options=p.options||{};var y=h.prng||Tn.random,g={nextBytes:function(E){for(var x=y.getBytesSync(E.length),_=0;_<E.length;++_)E[_]=x.charCodeAt(_)}};if(p.name==="PRIMEINC")return s(f,g,p.options,d);throw new Error("Invalid prime generation algorithm: "+p.name)};function s(f,h,d,p){return"workers"in d?c(f,h,d,p):o(f,h,d,p)}function o(f,h,d,p){var y=u(f,h),g=0,E=l(y.bitLength());"millerRabinTests"in d&&(E=d.millerRabinTests);var x=10;"maxBlockTime"in d&&(x=d.maxBlockTime),a(y,f,h,g,E,x,p)}function a(f,h,d,p,y,g,E){var x=+new Date;do{if(f.bitLength()>h&&(f=u(h,d)),f.isProbablePrime(y))return E(null,f);f.dAddOffset(r[p++%8],0)}while(g<0||+new Date-x<g);Tn.util.setImmediate(function(){a(f,h,d,p,y,g,E)})}function c(f,h,d,p){if(typeof Worker>"u")return o(f,h,d,p);var y=u(f,h),g=d.workers,E=d.workLoad||100,x=E*30/8,_=d.workerScript||"forge/prime.worker.js";if(g===-1)return Tn.util.estimateCores(function(D,P){D&&(P=2),g=P-1,B()});B();function B(){g=Math.max(1,g);for(var D=[],P=0;P<g;++P)D[P]=new Worker(_);for(var te=g,P=0;P<g;++P)D[P].addEventListener("message",st);var ae=!1;function st(jt){if(!ae){--te;var Ct=jt.data;if(Ct.found){for(var gt=0;gt<D.length;++gt)D[gt].terminate();return ae=!0,p(null,new e(Ct.prime,16))}y.bitLength()>f&&(y=u(f,h));var Ci=y.toString(16);jt.target.postMessage({hex:Ci,workLoad:E}),y.dAddOffset(x,0)}}}}function u(f,h){var d=new e(f,h),p=f-1;return d.testBit(p)||d.bitwiseTo(e.ONE.shiftLeft(p),i,d),d.dAddOffset(31-d.mod(n).byteValue(),0),d}function l(f){return f<=100?27:f<=150?18:f<=200?15:f<=250?12:f<=300?9:f<=350?8:f<=400?7:f<=500?6:f<=600?5:f<=800?4:f<=1250?3:2}})()});var ao=R((Q4,Yg)=>{var z=ie();An();pc();ns();Fg();Kg();ai();De();typeof ce>"u"&&(ce=z.jsbn.BigInteger);var ce,Pf=z.util.isNodejs?Jn():null,S=z.asn1,$t=z.util;z.pki=z.pki||{};Yg.exports=z.pki.rsa=z.rsa=z.rsa||{};var Z=z.pki,QA=[6,4,2,4,2,4,6,2],XA={name:"PrivateKeyInfo",tagClass:S.Class.UNIVERSAL,type:S.Type.SEQUENCE,constructed:!0,value:[{name:"PrivateKeyInfo.version",tagClass:S.Class.UNIVERSAL,type:S.Type.INTEGER,constructed:!1,capture:"privateKeyVersion"},{name:"PrivateKeyInfo.privateKeyAlgorithm",tagClass:S.Class.UNIVERSAL,type:S.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:S.Class.UNIVERSAL,type:S.Type.OID,constructed:!1,capture:"privateKeyOid"}]},{name:"PrivateKeyInfo",tagClass:S.Class.UNIVERSAL,type:S.Type.OCTETSTRING,constructed:!1,capture:"privateKey"}]},jA={name:"RSAPrivateKey",tagClass:S.Class.UNIVERSAL,type:S.Type.SEQUENCE,constructed:!0,value:[{name:"RSAPrivateKey.version",tagClass:S.Class.UNIVERSAL,type:S.Type.INTEGER,constructed:!1,capture:"privateKeyVersion"},{name:"RSAPrivateKey.modulus",tagClass:S.Class.UNIVERSAL,type:S.Type.INTEGER,constructed:!1,capture:"privateKeyModulus"},{name:"RSAPrivateKey.publicExponent",tagClass:S.Class.UNIVERSAL,type:S.Type.INTEGER,constructed:!1,capture:"privateKeyPublicExponent"},{name:"RSAPrivateKey.privateExponent",tagClass:S.Class.UNIVERSAL,type:S.Type.INTEGER,constructed:!1,capture:"privateKeyPrivateExponent"},{name:"RSAPrivateKey.prime1",tagClass:S.Class.UNIVERSAL,type:S.Type.INTEGER,constructed:!1,capture:"privateKeyPrime1"},{name:"RSAPrivateKey.prime2",tagClass:S.Class.UNIVERSAL,type:S.Type.INTEGER,constructed:!1,capture:"privateKeyPrime2"},{name:"RSAPrivateKey.exponent1",tagClass:S.Class.UNIVERSAL,type:S.Type.INTEGER,constructed:!1,capture:"privateKeyExponent1"},{name:"RSAPrivateKey.exponent2",tagClass:S.Class.UNIVERSAL,type:S.Type.INTEGER,constructed:!1,capture:"privateKeyExponent2"},{name:"RSAPrivateKey.coefficient",tagClass:S.Class.UNIVERSAL,type:S.Type.INTEGER,constructed:!1,capture:"privateKeyCoefficient"}]},ZA={name:"RSAPublicKey",tagClass:S.Class.UNIVERSAL,type:S.Type.SEQUENCE,constructed:!0,value:[{name:"RSAPublicKey.modulus",tagClass:S.Class.UNIVERSAL,type:S.Type.INTEGER,constructed:!1,capture:"publicKeyModulus"},{name:"RSAPublicKey.exponent",tagClass:S.Class.UNIVERSAL,type:S.Type.INTEGER,constructed:!1,capture:"publicKeyExponent"}]},JA=z.pki.rsa.publicKeyValidator={name:"SubjectPublicKeyInfo",tagClass:S.Class.UNIVERSAL,type:S.Type.SEQUENCE,constructed:!0,captureAsn1:"subjectPublicKeyInfo",value:[{name:"SubjectPublicKeyInfo.AlgorithmIdentifier",tagClass:S.Class.UNIVERSAL,type:S.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:S.Class.UNIVERSAL,type:S.Type.OID,constructed:!1,capture:"publicKeyOid"}]},{name:"SubjectPublicKeyInfo.subjectPublicKey",tagClass:S.Class.UNIVERSAL,type:S.Type.BITSTRING,constructed:!1,value:[{name:"SubjectPublicKeyInfo.subjectPublicKey.RSAPublicKey",tagClass:S.Class.UNIVERSAL,type:S.Type.SEQUENCE,constructed:!0,optional:!0,captureAsn1:"rsaPublicKey"}]}]},eC={name:"DigestInfo",tagClass:S.Class.UNIVERSAL,type:S.Type.SEQUENCE,constructed:!0,value:[{name:"DigestInfo.DigestAlgorithm",tagClass:S.Class.UNIVERSAL,type:S.Type.SEQUENCE,constructed:!0,value:[{name:"DigestInfo.DigestAlgorithm.algorithmIdentifier",tagClass:S.Class.UNIVERSAL,type:S.Type.OID,constructed:!1,capture:"algorithmIdentifier"},{name:"DigestInfo.DigestAlgorithm.parameters",tagClass:S.Class.UNIVERSAL,type:S.Type.NULL,capture:"parameters",optional:!0,constructed:!1}]},{name:"DigestInfo.digest",tagClass:S.Class.UNIVERSAL,type:S.Type.OCTETSTRING,constructed:!1,capture:"digest"}]},tC=function(t){var e;if(t.algorithm in Z.oids)e=Z.oids[t.algorithm];else{var r=new Error("Unknown message digest algorithm.");throw r.algorithm=t.algorithm,r}var n=S.oidToDer(e).getBytes(),i=S.create(S.Class.UNIVERSAL,S.Type.SEQUENCE,!0,[]),s=S.create(S.Class.UNIVERSAL,S.Type.SEQUENCE,!0,[]);s.value.push(S.create(S.Class.UNIVERSAL,S.Type.OID,!1,n)),s.value.push(S.create(S.Class.UNIVERSAL,S.Type.NULL,!1,""));var o=S.create(S.Class.UNIVERSAL,S.Type.OCTETSTRING,!1,t.digest().getBytes());return i.value.push(s),i.value.push(o),S.toDer(i).getBytes()},$g=function(t,e,r){if(r)return t.modPow(e.e,e.n);if(!e.p||!e.q)return t.modPow(e.d,e.n);e.dP||(e.dP=e.d.mod(e.p.subtract(ce.ONE))),e.dQ||(e.dQ=e.d.mod(e.q.subtract(ce.ONE))),e.qInv||(e.qInv=e.q.modInverse(e.p));var n;do n=new ce(z.util.bytesToHex(z.random.getBytes(e.n.bitLength()/8)),16);while(n.compareTo(e.n)>=0||!n.gcd(e.n).equals(ce.ONE));t=t.multiply(n.modPow(e.e,e.n)).mod(e.n);for(var i=t.mod(e.p).modPow(e.dP,e.p),s=t.mod(e.q).modPow(e.dQ,e.q);i.compareTo(s)<0;)i=i.add(e.p);var o=i.subtract(s).multiply(e.qInv).mod(e.p).multiply(e.q).add(s);return o=o.multiply(n.modInverse(e.n)).mod(e.n),o};Z.rsa.encrypt=function(t,e,r){var n=r,i,s=Math.ceil(e.n.bitLength()/8);r!==!1&&r!==!0?(n=r===2,i=Gg(t,e,r)):(i=z.util.createBuffer(),i.putBytes(t));for(var o=new ce(i.toHex(),16),a=$g(o,e,n),c=a.toString(16),u=z.util.createBuffer(),l=s-Math.ceil(c.length/2);l>0;)u.putByte(0),--l;return u.putBytes(z.util.hexToBytes(c)),u.getBytes()};Z.rsa.decrypt=function(t,e,r,n){var i=Math.ceil(e.n.bitLength()/8);if(t.length!==i){var s=new Error("Encrypted message length is invalid.");throw s.length=t.length,s.expected=i,s}var o=new ce(z.util.createBuffer(t).toHex(),16);if(o.compareTo(e.n)>=0)throw new Error("Encrypted message is invalid.");for(var a=$g(o,e,r),c=a.toString(16),u=z.util.createBuffer(),l=i-Math.ceil(c.length/2);l>0;)u.putByte(0),--l;return u.putBytes(z.util.hexToBytes(c)),n!==!1?yc(u.getBytes(),e,r):u.getBytes()};Z.rsa.createKeyPairGenerationState=function(t,e,r){typeof t=="string"&&(t=parseInt(t,10)),t=t||2048,r=r||{};var n=r.prng||z.random,i={nextBytes:function(a){for(var c=n.getBytesSync(a.length),u=0;u<a.length;++u)a[u]=c.charCodeAt(u)}},s=r.algorithm||"PRIMEINC",o;if(s==="PRIMEINC")o={algorithm:s,state:0,bits:t,rng:i,eInt:e||65537,e:new ce(null),p:null,q:null,qBits:t>>1,pBits:t-(t>>1),pqState:0,num:null,keys:null},o.e.fromInt(o.eInt);else throw new Error("Invalid key generation algorithm: "+s);return o};Z.rsa.stepKeyPairGenerationState=function(t,e){"algorithm"in t||(t.algorithm="PRIMEINC");var r=new ce(null);r.fromInt(30);for(var n=0,i=function(f,h){return f|h},s=+new Date,o,a=0;t.keys===null&&(e<=0||a<e);){if(t.state===0){var c=t.p===null?t.pBits:t.qBits,u=c-1;t.pqState===0?(t.num=new ce(c,t.rng),t.num.testBit(u)||t.num.bitwiseTo(ce.ONE.shiftLeft(u),i,t.num),t.num.dAddOffset(31-t.num.mod(r).byteValue(),0),n=0,++t.pqState):t.pqState===1?t.num.bitLength()>c?t.pqState=0:t.num.isProbablePrime(nC(t.num.bitLength()))?++t.pqState:t.num.dAddOffset(QA[n++%8],0):t.pqState===2?t.pqState=t.num.subtract(ce.ONE).gcd(t.e).compareTo(ce.ONE)===0?3:0:t.pqState===3&&(t.pqState=0,t.p===null?t.p=t.num:t.q=t.num,t.p!==null&&t.q!==null&&++t.state,t.num=null)}else if(t.state===1)t.p.compareTo(t.q)<0&&(t.num=t.p,t.p=t.q,t.q=t.num),++t.state;else if(t.state===2)t.p1=t.p.subtract(ce.ONE),t.q1=t.q.subtract(ce.ONE),t.phi=t.p1.multiply(t.q1),++t.state;else if(t.state===3)t.phi.gcd(t.e).compareTo(ce.ONE)===0?++t.state:(t.p=null,t.q=null,t.state=0);else if(t.state===4)t.n=t.p.multiply(t.q),t.n.bitLength()===t.bits?++t.state:(t.q=null,t.state=0);else if(t.state===5){var l=t.e.modInverse(t.phi);t.keys={privateKey:Z.rsa.setPrivateKey(t.n,t.e,l,t.p,t.q,l.mod(t.p1),l.mod(t.q1),t.q.modInverse(t.p)),publicKey:Z.rsa.setPublicKey(t.n,t.e)}}o=+new Date,a+=o-s,s=o}return t.keys!==null};Z.rsa.generateKeyPair=function(t,e,r,n){if(arguments.length===1?typeof t=="object"?(r=t,t=void 0):typeof t=="function"&&(n=t,t=void 0):arguments.length===2?typeof t=="number"?typeof e=="function"?(n=e,e=void 0):typeof e!="number"&&(r=e,e=void 0):(r=t,n=e,t=void 0,e=void 0):arguments.length===3&&(typeof e=="number"?typeof r=="function"&&(n=r,r=void 0):(n=r,r=e,e=void 0)),r=r||{},t===void 0&&(t=r.bits||2048),e===void 0&&(e=r.e||65537),!z.options.usePureJavaScript&&!r.prng&&t>=256&&t<=16384&&(e===65537||e===3)){if(n){if(Vg("generateKeyPair"))return Pf.generateKeyPair("rsa",{modulusLength:t,publicExponent:e,publicKeyEncoding:{type:"spki",format:"pem"},privateKeyEncoding:{type:"pkcs8",format:"pem"}},function(a,c,u){if(a)return n(a);n(null,{privateKey:Z.privateKeyFromPem(u),publicKey:Z.publicKeyFromPem(c)})});if(qg("generateKey")&&qg("exportKey"))return $t.globalScope.crypto.subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:t,publicExponent:zg(e),hash:{name:"SHA-256"}},!0,["sign","verify"]).then(function(a){return $t.globalScope.crypto.subtle.exportKey("pkcs8",a.privateKey)}).then(void 0,function(a){n(a)}).then(function(a){if(a){var c=Z.privateKeyFromAsn1(S.fromDer(z.util.createBuffer(a)));n(null,{privateKey:c,publicKey:Z.setRsaPublicKey(c.n,c.e)})}});if(Hg("generateKey")&&Hg("exportKey")){var i=$t.globalScope.msCrypto.subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:t,publicExponent:zg(e),hash:{name:"SHA-256"}},!0,["sign","verify"]);i.oncomplete=function(a){var c=a.target.result,u=$t.globalScope.msCrypto.subtle.exportKey("pkcs8",c.privateKey);u.oncomplete=function(l){var f=l.target.result,h=Z.privateKeyFromAsn1(S.fromDer(z.util.createBuffer(f)));n(null,{privateKey:h,publicKey:Z.setRsaPublicKey(h.n,h.e)})},u.onerror=function(l){n(l)}},i.onerror=function(a){n(a)};return}}else if(Vg("generateKeyPairSync")){var s=Pf.generateKeyPairSync("rsa",{modulusLength:t,publicExponent:e,publicKeyEncoding:{type:"spki",format:"pem"},privateKeyEncoding:{type:"pkcs8",format:"pem"}});return{privateKey:Z.privateKeyFromPem(s.privateKey),publicKey:Z.publicKeyFromPem(s.publicKey)}}}var o=Z.rsa.createKeyPairGenerationState(t,e,r);if(!n)return Z.rsa.stepKeyPairGenerationState(o,0),o.keys;rC(o,r,n)};Z.setRsaPublicKey=Z.rsa.setPublicKey=function(t,e){var r={n:t,e};return r.encrypt=function(n,i,s){if(typeof i=="string"?i=i.toUpperCase():i===void 0&&(i="RSAES-PKCS1-V1_5"),i==="RSAES-PKCS1-V1_5")i={encode:function(a,c,u){return Gg(a,c,2).getBytes()}};else if(i==="RSA-OAEP"||i==="RSAES-OAEP")i={encode:function(a,c){return z.pkcs1.encode_rsa_oaep(c,a,s)}};else if(["RAW","NONE","NULL",null].indexOf(i)!==-1)i={encode:function(a){return a}};else if(typeof i=="string")throw new Error('Unsupported encryption scheme: "'+i+'".');var o=i.encode(n,r,!0);return Z.rsa.encrypt(o,r,!0)},r.verify=function(n,i,s,o){typeof s=="string"?s=s.toUpperCase():s===void 0&&(s="RSASSA-PKCS1-V1_5"),o===void 0&&(o={_parseAllDigestBytes:!0}),"_parseAllDigestBytes"in o||(o._parseAllDigestBytes=!0),s==="RSASSA-PKCS1-V1_5"?s={verify:function(c,u){u=yc(u,r,!0);var l=S.fromDer(u,{parseAllBytes:o._parseAllDigestBytes}),f={},h=[];if(!S.validate(l,eC,f,h)){var d=new Error("ASN.1 object does not contain a valid RSASSA-PKCS1-v1_5 DigestInfo value.");throw d.errors=h,d}var p=S.derToOid(f.algorithmIdentifier);if(!(p===z.oids.md2||p===z.oids.md5||p===z.oids.sha1||p===z.oids.sha224||p===z.oids.sha256||p===z.oids.sha384||p===z.oids.sha512||p===z.oids["sha512-224"]||p===z.oids["sha512-256"])){var d=new Error("Unknown RSASSA-PKCS1-v1_5 DigestAlgorithm identifier.");throw d.oid=p,d}if((p===z.oids.md2||p===z.oids.md5)&&!("parameters"in f))throw new Error("ASN.1 object does not contain a valid RSASSA-PKCS1-v1_5 DigestInfo value. Missing algorithm identifer NULL parameters.");return c===f.digest}}:(s==="NONE"||s==="NULL"||s===null)&&(s={verify:function(c,u){return u=yc(u,r,!0),c===u}});var a=Z.rsa.decrypt(i,r,!0,!1);return s.verify(n,a,r.n.bitLength())},r};Z.setRsaPrivateKey=Z.rsa.setPrivateKey=function(t,e,r,n,i,s,o,a){var c={n:t,e,d:r,p:n,q:i,dP:s,dQ:o,qInv:a};return c.decrypt=function(u,l,f){typeof l=="string"?l=l.toUpperCase():l===void 0&&(l="RSAES-PKCS1-V1_5");var h=Z.rsa.decrypt(u,c,!1,!1);if(l==="RSAES-PKCS1-V1_5")l={decode:yc};else if(l==="RSA-OAEP"||l==="RSAES-OAEP")l={decode:function(d,p){return z.pkcs1.decode_rsa_oaep(p,d,f)}};else if(["RAW","NONE","NULL",null].indexOf(l)!==-1)l={decode:function(d){return d}};else throw new Error('Unsupported encryption scheme: "'+l+'".');return l.decode(h,c,!1)},c.sign=function(u,l){var f=!1;typeof l=="string"&&(l=l.toUpperCase()),l===void 0||l==="RSASSA-PKCS1-V1_5"?(l={encode:tC},f=1):(l==="NONE"||l==="NULL"||l===null)&&(l={encode:function(){return u}},f=1);var h=l.encode(u,c.n.bitLength());return Z.rsa.encrypt(h,c,f)},c};Z.wrapRsaPrivateKey=function(t){return S.create(S.Class.UNIVERSAL,S.Type.SEQUENCE,!0,[S.create(S.Class.UNIVERSAL,S.Type.INTEGER,!1,S.integerToDer(0).getBytes()),S.create(S.Class.UNIVERSAL,S.Type.SEQUENCE,!0,[S.create(S.Class.UNIVERSAL,S.Type.OID,!1,S.oidToDer(Z.oids.rsaEncryption).getBytes()),S.create(S.Class.UNIVERSAL,S.Type.NULL,!1,"")]),S.create(S.Class.UNIVERSAL,S.Type.OCTETSTRING,!1,S.toDer(t).getBytes())])};Z.privateKeyFromAsn1=function(t){var e={},r=[];if(S.validate(t,XA,e,r)&&(t=S.fromDer(z.util.createBuffer(e.privateKey))),e={},r=[],!S.validate(t,jA,e,r)){var n=new Error("Cannot read private key. ASN.1 object does not contain an RSAPrivateKey.");throw n.errors=r,n}var i,s,o,a,c,u,l,f;return i=z.util.createBuffer(e.privateKeyModulus).toHex(),s=z.util.createBuffer(e.privateKeyPublicExponent).toHex(),o=z.util.createBuffer(e.privateKeyPrivateExponent).toHex(),a=z.util.createBuffer(e.privateKeyPrime1).toHex(),c=z.util.createBuffer(e.privateKeyPrime2).toHex(),u=z.util.createBuffer(e.privateKeyExponent1).toHex(),l=z.util.createBuffer(e.privateKeyExponent2).toHex(),f=z.util.createBuffer(e.privateKeyCoefficient).toHex(),Z.setRsaPrivateKey(new ce(i,16),new ce(s,16),new ce(o,16),new ce(a,16),new ce(c,16),new ce(u,16),new ce(l,16),new ce(f,16))};Z.privateKeyToAsn1=Z.privateKeyToRSAPrivateKey=function(t){return S.create(S.Class.UNIVERSAL,S.Type.SEQUENCE,!0,[S.create(S.Class.UNIVERSAL,S.Type.INTEGER,!1,S.integerToDer(0).getBytes()),S.create(S.Class.UNIVERSAL,S.Type.INTEGER,!1,Sr(t.n)),S.create(S.Class.UNIVERSAL,S.Type.INTEGER,!1,Sr(t.e)),S.create(S.Class.UNIVERSAL,S.Type.INTEGER,!1,Sr(t.d)),S.create(S.Class.UNIVERSAL,S.Type.INTEGER,!1,Sr(t.p)),S.create(S.Class.UNIVERSAL,S.Type.INTEGER,!1,Sr(t.q)),S.create(S.Class.UNIVERSAL,S.Type.INTEGER,!1,Sr(t.dP)),S.create(S.Class.UNIVERSAL,S.Type.INTEGER,!1,Sr(t.dQ)),S.create(S.Class.UNIVERSAL,S.Type.INTEGER,!1,Sr(t.qInv))])};Z.publicKeyFromAsn1=function(t){var e={},r=[];if(S.validate(t,JA,e,r)){var n=S.derToOid(e.publicKeyOid);if(n!==Z.oids.rsaEncryption){var i=new Error("Cannot read public key. Unknown OID.");throw i.oid=n,i}t=e.rsaPublicKey}if(r=[],!S.validate(t,ZA,e,r)){var i=new Error("Cannot read public key. ASN.1 object does not contain an RSAPublicKey.");throw i.errors=r,i}var s=z.util.createBuffer(e.publicKeyModulus).toHex(),o=z.util.createBuffer(e.publicKeyExponent).toHex();return Z.setRsaPublicKey(new ce(s,16),new ce(o,16))};Z.publicKeyToAsn1=Z.publicKeyToSubjectPublicKeyInfo=function(t){return S.create(S.Class.UNIVERSAL,S.Type.SEQUENCE,!0,[S.create(S.Class.UNIVERSAL,S.Type.SEQUENCE,!0,[S.create(S.Class.UNIVERSAL,S.Type.OID,!1,S.oidToDer(Z.oids.rsaEncryption).getBytes()),S.create(S.Class.UNIVERSAL,S.Type.NULL,!1,"")]),S.create(S.Class.UNIVERSAL,S.Type.BITSTRING,!1,[Z.publicKeyToRSAPublicKey(t)])])};Z.publicKeyToRSAPublicKey=function(t){return S.create(S.Class.UNIVERSAL,S.Type.SEQUENCE,!0,[S.create(S.Class.UNIVERSAL,S.Type.INTEGER,!1,Sr(t.n)),S.create(S.Class.UNIVERSAL,S.Type.INTEGER,!1,Sr(t.e))])};function Gg(t,e,r){var n=z.util.createBuffer(),i=Math.ceil(e.n.bitLength()/8);if(t.length>i-11){var s=new Error("Message is too long for PKCS#1 v1.5 padding.");throw s.length=t.length,s.max=i-11,s}n.putByte(0),n.putByte(r);var o=i-3-t.length,a;if(r===0||r===1){a=r===0?0:255;for(var c=0;c<o;++c)n.putByte(a)}else for(;o>0;){for(var u=0,l=z.random.getBytes(o),c=0;c<o;++c)a=l.charCodeAt(c),a===0?++u:n.putByte(a);o=u}return n.putByte(0),n.putBytes(t),n}function yc(t,e,r,n){var i=Math.ceil(e.n.bitLength()/8),s=z.util.createBuffer(t),o=s.getByte(),a=s.getByte();if(o!==0||r&&a!==0&&a!==1||!r&&a!=2||r&&a===0&&typeof n>"u")throw new Error("Encryption block is invalid.");var c=0;if(a===0){c=i-3-n;for(var u=0;u<c;++u)if(s.getByte()!==0)throw new Error("Encryption block is invalid.")}else if(a===1)for(c=0;s.length()>1;){if(s.getByte()!==255){--s.read;break}++c}else if(a===2)for(c=0;s.length()>1;){if(s.getByte()===0){--s.read;break}++c}var l=s.getByte();if(l!==0||c!==i-3-s.length())throw new Error("Encryption block is invalid.");return s.getBytes()}function rC(t,e,r){typeof e=="function"&&(r=e,e={}),e=e||{};var n={algorithm:{name:e.algorithm||"PRIMEINC",options:{workers:e.workers||2,workLoad:e.workLoad||100,workerScript:e.workerScript}}};"prng"in e&&(n.prng=e.prng),i();function i(){s(t.pBits,function(a,c){if(a)return r(a);if(t.p=c,t.q!==null)return o(a,t.q);s(t.qBits,o)})}function s(a,c){z.prime.generateProbablePrime(a,n,c)}function o(a,c){if(a)return r(a);if(t.q=c,t.p.compareTo(t.q)<0){var u=t.p;t.p=t.q,t.q=u}if(t.p.subtract(ce.ONE).gcd(t.e).compareTo(ce.ONE)!==0){t.p=null,i();return}if(t.q.subtract(ce.ONE).gcd(t.e).compareTo(ce.ONE)!==0){t.q=null,s(t.qBits,o);return}if(t.p1=t.p.subtract(ce.ONE),t.q1=t.q.subtract(ce.ONE),t.phi=t.p1.multiply(t.q1),t.phi.gcd(t.e).compareTo(ce.ONE)!==0){t.p=t.q=null,i();return}if(t.n=t.p.multiply(t.q),t.n.bitLength()!==t.bits){t.q=null,s(t.qBits,o);return}var l=t.e.modInverse(t.phi);t.keys={privateKey:Z.rsa.setPrivateKey(t.n,t.e,l,t.p,t.q,l.mod(t.p1),l.mod(t.q1),t.q.modInverse(t.p)),publicKey:Z.rsa.setPublicKey(t.n,t.e)},r(null,t.keys)}}function Sr(t){var e=t.toString(16);e[0]>="8"&&(e="00"+e);var r=z.util.hexToBytes(e);return r.length>1&&(r.charCodeAt(0)===0&&!(r.charCodeAt(1)&128)||r.charCodeAt(0)===255&&(r.charCodeAt(1)&128)===128)?r.substr(1):r}function nC(t){return t<=100?27:t<=150?18:t<=200?15:t<=250?12:t<=300?9:t<=350?8:t<=400?7:t<=500?6:t<=600?5:t<=800?4:t<=1250?3:2}function Vg(t){return z.util.isNodejs&&typeof Pf[t]=="function"}function qg(t){return typeof $t.globalScope<"u"&&typeof $t.globalScope.crypto=="object"&&typeof $t.globalScope.crypto.subtle=="object"&&typeof $t.globalScope.crypto.subtle[t]=="function"}function Hg(t){return typeof $t.globalScope<"u"&&typeof $t.globalScope.msCrypto=="object"&&typeof $t.globalScope.msCrypto.subtle=="object"&&typeof $t.globalScope.msCrypto.subtle[t]=="function"}function zg(t){for(var e=z.util.hexToBytes(t.toString(16)),r=new Uint8Array(e.length),n=0;n<e.length;++n)r[n]=e.charCodeAt(n);return r}});var Of=R((X4,Zg)=>{var $=ie();rs();An();sc();Cn();xg();ns();cc();Sg();ao();De();var m=$.asn1,L=Zg.exports=$.pki=$.pki||{},ue=L.oids,Ye={};Ye.CN=ue.commonName;Ye.commonName="CN";Ye.C=ue.countryName;Ye.countryName="C";Ye.L=ue.localityName;Ye.localityName="L";Ye.ST=ue.stateOrProvinceName;Ye.stateOrProvinceName="ST";Ye.O=ue.organizationName;Ye.organizationName="O";Ye.OU=ue.organizationalUnitName;Ye.organizationalUnitName="OU";Ye.E=ue.emailAddress;Ye.emailAddress="E";var Qg=$.pki.rsa.publicKeyValidator,iC={name:"Certificate",tagClass:m.Class.UNIVERSAL,type:m.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.TBSCertificate",tagClass:m.Class.UNIVERSAL,type:m.Type.SEQUENCE,constructed:!0,captureAsn1:"tbsCertificate",value:[{name:"Certificate.TBSCertificate.version",tagClass:m.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,value:[{name:"Certificate.TBSCertificate.version.integer",tagClass:m.Class.UNIVERSAL,type:m.Type.INTEGER,constructed:!1,capture:"certVersion"}]},{name:"Certificate.TBSCertificate.serialNumber",tagClass:m.Class.UNIVERSAL,type:m.Type.INTEGER,constructed:!1,capture:"certSerialNumber"},{name:"Certificate.TBSCertificate.signature",tagClass:m.Class.UNIVERSAL,type:m.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.TBSCertificate.signature.algorithm",tagClass:m.Class.UNIVERSAL,type:m.Type.OID,constructed:!1,capture:"certinfoSignatureOid"},{name:"Certificate.TBSCertificate.signature.parameters",tagClass:m.Class.UNIVERSAL,optional:!0,captureAsn1:"certinfoSignatureParams"}]},{name:"Certificate.TBSCertificate.issuer",tagClass:m.Class.UNIVERSAL,type:m.Type.SEQUENCE,constructed:!0,captureAsn1:"certIssuer"},{name:"Certificate.TBSCertificate.validity",tagClass:m.Class.UNIVERSAL,type:m.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.TBSCertificate.validity.notBefore (utc)",tagClass:m.Class.UNIVERSAL,type:m.Type.UTCTIME,constructed:!1,optional:!0,capture:"certValidity1UTCTime"},{name:"Certificate.TBSCertificate.validity.notBefore (generalized)",tagClass:m.Class.UNIVERSAL,type:m.Type.GENERALIZEDTIME,constructed:!1,optional:!0,capture:"certValidity2GeneralizedTime"},{name:"Certificate.TBSCertificate.validity.notAfter (utc)",tagClass:m.Class.UNIVERSAL,type:m.Type.UTCTIME,constructed:!1,optional:!0,capture:"certValidity3UTCTime"},{name:"Certificate.TBSCertificate.validity.notAfter (generalized)",tagClass:m.Class.UNIVERSAL,type:m.Type.GENERALIZEDTIME,constructed:!1,optional:!0,capture:"certValidity4GeneralizedTime"}]},{name:"Certificate.TBSCertificate.subject",tagClass:m.Class.UNIVERSAL,type:m.Type.SEQUENCE,constructed:!0,captureAsn1:"certSubject"},Qg,{name:"Certificate.TBSCertificate.issuerUniqueID",tagClass:m.Class.CONTEXT_SPECIFIC,type:1,constructed:!0,optional:!0,value:[{name:"Certificate.TBSCertificate.issuerUniqueID.id",tagClass:m.Class.UNIVERSAL,type:m.Type.BITSTRING,constructed:!1,captureBitStringValue:"certIssuerUniqueId"}]},{name:"Certificate.TBSCertificate.subjectUniqueID",tagClass:m.Class.CONTEXT_SPECIFIC,type:2,constructed:!0,optional:!0,value:[{name:"Certificate.TBSCertificate.subjectUniqueID.id",tagClass:m.Class.UNIVERSAL,type:m.Type.BITSTRING,constructed:!1,captureBitStringValue:"certSubjectUniqueId"}]},{name:"Certificate.TBSCertificate.extensions",tagClass:m.Class.CONTEXT_SPECIFIC,type:3,constructed:!0,captureAsn1:"certExtensions",optional:!0}]},{name:"Certificate.signatureAlgorithm",tagClass:m.Class.UNIVERSAL,type:m.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.signatureAlgorithm.algorithm",tagClass:m.Class.UNIVERSAL,type:m.Type.OID,constructed:!1,capture:"certSignatureOid"},{name:"Certificate.TBSCertificate.signature.parameters",tagClass:m.Class.UNIVERSAL,optional:!0,captureAsn1:"certSignatureParams"}]},{name:"Certificate.signatureValue",tagClass:m.Class.UNIVERSAL,type:m.Type.BITSTRING,constructed:!1,captureBitStringValue:"certSignature"}]},sC={name:"rsapss",tagClass:m.Class.UNIVERSAL,type:m.Type.SEQUENCE,constructed:!0,value:[{name:"rsapss.hashAlgorithm",tagClass:m.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,value:[{name:"rsapss.hashAlgorithm.AlgorithmIdentifier",tagClass:m.Class.UNIVERSAL,type:m.Class.SEQUENCE,constructed:!0,optional:!0,value:[{name:"rsapss.hashAlgorithm.AlgorithmIdentifier.algorithm",tagClass:m.Class.UNIVERSAL,type:m.Type.OID,constructed:!1,capture:"hashOid"}]}]},{name:"rsapss.maskGenAlgorithm",tagClass:m.Class.CONTEXT_SPECIFIC,type:1,constructed:!0,value:[{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier",tagClass:m.Class.UNIVERSAL,type:m.Class.SEQUENCE,constructed:!0,optional:!0,value:[{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier.algorithm",tagClass:m.Class.UNIVERSAL,type:m.Type.OID,constructed:!1,capture:"maskGenOid"},{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier.params",tagClass:m.Class.UNIVERSAL,type:m.Type.SEQUENCE,constructed:!0,value:[{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier.params.algorithm",tagClass:m.Class.UNIVERSAL,type:m.Type.OID,constructed:!1,capture:"maskGenHashOid"}]}]}]},{name:"rsapss.saltLength",tagClass:m.Class.CONTEXT_SPECIFIC,type:2,optional:!0,value:[{name:"rsapss.saltLength.saltLength",tagClass:m.Class.UNIVERSAL,type:m.Class.INTEGER,constructed:!1,capture:"saltLength"}]},{name:"rsapss.trailerField",tagClass:m.Class.CONTEXT_SPECIFIC,type:3,optional:!0,value:[{name:"rsapss.trailer.trailer",tagClass:m.Class.UNIVERSAL,type:m.Class.INTEGER,constructed:!1,capture:"trailer"}]}]},oC={name:"CertificationRequestInfo",tagClass:m.Class.UNIVERSAL,type:m.Type.SEQUENCE,constructed:!0,captureAsn1:"certificationRequestInfo",value:[{name:"CertificationRequestInfo.integer",tagClass:m.Class.UNIVERSAL,type:m.Type.INTEGER,constructed:!1,capture:"certificationRequestInfoVersion"},{name:"CertificationRequestInfo.subject",tagClass:m.Class.UNIVERSAL,type:m.Type.SEQUENCE,constructed:!0,captureAsn1:"certificationRequestInfoSubject"},Qg,{name:"CertificationRequestInfo.attributes",tagClass:m.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,capture:"certificationRequestInfoAttributes",value:[{name:"CertificationRequestInfo.attributes",tagClass:m.Class.UNIVERSAL,type:m.Type.SEQUENCE,constructed:!0,value:[{name:"CertificationRequestInfo.attributes.type",tagClass:m.Class.UNIVERSAL,type:m.Type.OID,constructed:!1},{name:"CertificationRequestInfo.attributes.value",tagClass:m.Class.UNIVERSAL,type:m.Type.SET,constructed:!0}]}]}]},aC={name:"CertificationRequest",tagClass:m.Class.UNIVERSAL,type:m.Type.SEQUENCE,constructed:!0,captureAsn1:"csr",value:[oC,{name:"CertificationRequest.signatureAlgorithm",tagClass:m.Class.UNIVERSAL,type:m.Type.SEQUENCE,constructed:!0,value:[{name:"CertificationRequest.signatureAlgorithm.algorithm",tagClass:m.Class.UNIVERSAL,type:m.Type.OID,constructed:!1,capture:"csrSignatureOid"},{name:"CertificationRequest.signatureAlgorithm.parameters",tagClass:m.Class.UNIVERSAL,optional:!0,captureAsn1:"csrSignatureParams"}]},{name:"CertificationRequest.signature",tagClass:m.Class.UNIVERSAL,type:m.Type.BITSTRING,constructed:!1,captureBitStringValue:"csrSignature"}]};L.RDNAttributesAsArray=function(t,e){for(var r=[],n,i,s,o=0;o<t.value.length;++o){n=t.value[o];for(var a=0;a<n.value.length;++a)s={},i=n.value[a],s.type=m.derToOid(i.value[0].value),s.value=i.value[1].value,s.valueTagClass=i.value[1].type,s.type in ue&&(s.name=ue[s.type],s.name in Ye&&(s.shortName=Ye[s.name])),e&&(e.update(s.type),e.update(s.value)),r.push(s)}return r};L.CRIAttributesAsArray=function(t){for(var e=[],r=0;r<t.length;++r)for(var n=t[r],i=m.derToOid(n.value[0].value),s=n.value[1].value,o=0;o<s.length;++o){var a={};if(a.type=i,a.value=s[o].value,a.valueTagClass=s[o].type,a.type in ue&&(a.name=ue[a.type],a.name in Ye&&(a.shortName=Ye[a.name])),a.type===ue.extensionRequest){a.extensions=[];for(var c=0;c<a.value.length;++c)a.extensions.push(L.certificateExtensionFromAsn1(a.value[c]))}e.push(a)}return e};function Rn(t,e){typeof e=="string"&&(e={shortName:e});for(var r=null,n,i=0;r===null&&i<t.attributes.length;++i)n=t.attributes[i],(e.type&&e.type===n.type||e.name&&e.name===n.name||e.shortName&&e.shortName===n.shortName)&&(r=n);return r}var gc=function(t,e,r){var n={};if(t!==ue["RSASSA-PSS"])return n;r&&(n={hash:{algorithmOid:ue.sha1},mgf:{algorithmOid:ue.mgf1,hash:{algorithmOid:ue.sha1}},saltLength:20});var i={},s=[];if(!m.validate(e,sC,i,s)){var o=new Error("Cannot read RSASSA-PSS parameter block.");throw o.errors=s,o}return i.hashOid!==void 0&&(n.hash=n.hash||{},n.hash.algorithmOid=m.derToOid(i.hashOid)),i.maskGenOid!==void 0&&(n.mgf=n.mgf||{},n.mgf.algorithmOid=m.derToOid(i.maskGenOid),n.mgf.hash=n.mgf.hash||{},n.mgf.hash.algorithmOid=m.derToOid(i.maskGenHashOid)),i.saltLength!==void 0&&(n.saltLength=i.saltLength.charCodeAt(0)),n},Ec=function(t){switch(ue[t.signatureOid]){case"sha1WithRSAEncryption":case"sha1WithRSASignature":return $.md.sha1.create();case"md5WithRSAEncryption":return $.md.md5.create();case"sha256WithRSAEncryption":return $.md.sha256.create();case"sha384WithRSAEncryption":return $.md.sha384.create();case"sha512WithRSAEncryption":return $.md.sha512.create();case"RSASSA-PSS":return $.md.sha256.create();default:var e=new Error("Could not compute "+t.type+" digest. Unknown signature OID.");throw e.signatureOid=t.signatureOid,e}},Xg=function(t){var e=t.certificate,r;switch(e.signatureOid){case ue.sha1WithRSAEncryption:case ue.sha1WithRSASignature:break;case ue["RSASSA-PSS"]:var n,i;if(n=ue[e.signatureParameters.mgf.hash.algorithmOid],n===void 0||$.md[n]===void 0){var s=new Error("Unsupported MGF hash function.");throw s.oid=e.signatureParameters.mgf.hash.algorithmOid,s.name=n,s}if(i=ue[e.signatureParameters.mgf.algorithmOid],i===void 0||$.mgf[i]===void 0){var s=new Error("Unsupported MGF function.");throw s.oid=e.signatureParameters.mgf.algorithmOid,s.name=i,s}if(i=$.mgf[i].create($.md[n].create()),n=ue[e.signatureParameters.hash.algorithmOid],n===void 0||$.md[n]===void 0){var s=new Error("Unsupported RSASSA-PSS hash function.");throw s.oid=e.signatureParameters.hash.algorithmOid,s.name=n,s}r=$.pss.create($.md[n].create(),i,e.signatureParameters.saltLength);break}return e.publicKey.verify(t.md.digest().getBytes(),t.signature,r)};L.certificateFromPem=function(t,e,r){var n=$.pem.decode(t)[0];if(n.type!=="CERTIFICATE"&&n.type!=="X509 CERTIFICATE"&&n.type!=="TRUSTED CERTIFICATE"){var i=new Error('Could not convert certificate from PEM; PEM header type is not "CERTIFICATE", "X509 CERTIFICATE", or "TRUSTED CERTIFICATE".');throw i.headerType=n.type,i}if(n.procType&&n.procType.type==="ENCRYPTED")throw new Error("Could not convert certificate from PEM; PEM is encrypted.");var s=m.fromDer(n.body,r);return L.certificateFromAsn1(s,e)};L.certificateToPem=function(t,e){var r={type:"CERTIFICATE",body:m.toDer(L.certificateToAsn1(t)).getBytes()};return $.pem.encode(r,{maxline:e})};L.publicKeyFromPem=function(t){var e=$.pem.decode(t)[0];if(e.type!=="PUBLIC KEY"&&e.type!=="RSA PUBLIC KEY"){var r=new Error('Could not convert public key from PEM; PEM header type is not "PUBLIC KEY" or "RSA PUBLIC KEY".');throw r.headerType=e.type,r}if(e.procType&&e.procType.type==="ENCRYPTED")throw new Error("Could not convert public key from PEM; PEM is encrypted.");var n=m.fromDer(e.body);return L.publicKeyFromAsn1(n)};L.publicKeyToPem=function(t,e){var r={type:"PUBLIC KEY",body:m.toDer(L.publicKeyToAsn1(t)).getBytes()};return $.pem.encode(r,{maxline:e})};L.publicKeyToRSAPublicKeyPem=function(t,e){var r={type:"RSA PUBLIC KEY",body:m.toDer(L.publicKeyToRSAPublicKey(t)).getBytes()};return $.pem.encode(r,{maxline:e})};L.getPublicKeyFingerprint=function(t,e){e=e||{};var r=e.md||$.md.sha1.create(),n=e.type||"RSAPublicKey",i;switch(n){case"RSAPublicKey":i=m.toDer(L.publicKeyToRSAPublicKey(t)).getBytes();break;case"SubjectPublicKeyInfo":i=m.toDer(L.publicKeyToAsn1(t)).getBytes();break;default:throw new Error('Unknown fingerprint type "'+e.type+'".')}r.start(),r.update(i);var s=r.digest();if(e.encoding==="hex"){var o=s.toHex();return e.delimiter?o.match(/.{2}/g).join(e.delimiter):o}else{if(e.encoding==="binary")return s.getBytes();if(e.encoding)throw new Error('Unknown encoding "'+e.encoding+'".')}return s};L.certificationRequestFromPem=function(t,e,r){var n=$.pem.decode(t)[0];if(n.type!=="CERTIFICATE REQUEST"){var i=new Error('Could not convert certification request from PEM; PEM header type is not "CERTIFICATE REQUEST".');throw i.headerType=n.type,i}if(n.procType&&n.procType.type==="ENCRYPTED")throw new Error("Could not convert certification request from PEM; PEM is encrypted.");var s=m.fromDer(n.body,r);return L.certificationRequestFromAsn1(s,e)};L.certificationRequestToPem=function(t,e){var r={type:"CERTIFICATE REQUEST",body:m.toDer(L.certificationRequestToAsn1(t)).getBytes()};return $.pem.encode(r,{maxline:e})};L.createCertificate=function(){var t={};return t.version=2,t.serialNumber="00",t.signatureOid=null,t.signature=null,t.siginfo={},t.siginfo.algorithmOid=null,t.validity={},t.validity.notBefore=new Date,t.validity.notAfter=new Date,t.issuer={},t.issuer.getField=function(e){return Rn(t.issuer,e)},t.issuer.addField=function(e){Gt([e]),t.issuer.attributes.push(e)},t.issuer.attributes=[],t.issuer.hash=null,t.subject={},t.subject.getField=function(e){return Rn(t.subject,e)},t.subject.addField=function(e){Gt([e]),t.subject.attributes.push(e)},t.subject.attributes=[],t.subject.hash=null,t.extensions=[],t.publicKey=null,t.md=null,t.setSubject=function(e,r){Gt(e),t.subject.attributes=e,delete t.subject.uniqueId,r&&(t.subject.uniqueId=r),t.subject.hash=null},t.setIssuer=function(e,r){Gt(e),t.issuer.attributes=e,delete t.issuer.uniqueId,r&&(t.issuer.uniqueId=r),t.issuer.hash=null},t.setExtensions=function(e){for(var r=0;r<e.length;++r)jg(e[r],{cert:t});t.extensions=e},t.getExtension=function(e){typeof e=="string"&&(e={name:e});for(var r=null,n,i=0;r===null&&i<t.extensions.length;++i)n=t.extensions[i],(e.id&&n.id===e.id||e.name&&n.name===e.name)&&(r=n);return r},t.sign=function(e,r){t.md=r||$.md.sha1.create();var n=ue[t.md.algorithm+"WithRSAEncryption"];if(!n){var i=new Error("Could not compute certificate digest. Unknown message digest algorithm OID.");throw i.algorithm=t.md.algorithm,i}t.signatureOid=t.siginfo.algorithmOid=n,t.tbsCertificate=L.getTBSCertificate(t);var s=m.toDer(t.tbsCertificate);t.md.update(s.getBytes()),t.signature=e.sign(t.md)},t.verify=function(e){var r=!1;if(!t.issued(e)){var n=e.issuer,i=t.subject,s=new Error("The parent certificate did not issue the given child certificate; the child certificate's issuer does not match the parent's subject.");throw s.expectedIssuer=i.attributes,s.actualIssuer=n.attributes,s}var o=e.md;if(o===null){o=Ec({signatureOid:e.signatureOid,type:"certificate"});var a=e.tbsCertificate||L.getTBSCertificate(e),c=m.toDer(a);o.update(c.getBytes())}return o!==null&&(r=Xg({certificate:t,md:o,signature:e.signature})),r},t.isIssuer=function(e){var r=!1,n=t.issuer,i=e.subject;if(n.hash&&i.hash)r=n.hash===i.hash;else if(n.attributes.length===i.attributes.length){r=!0;for(var s,o,a=0;r&&a<n.attributes.length;++a)s=n.attributes[a],o=i.attributes[a],(s.type!==o.type||s.value!==o.value)&&(r=!1)}return r},t.issued=function(e){return e.isIssuer(t)},t.generateSubjectKeyIdentifier=function(){return L.getPublicKeyFingerprint(t.publicKey,{type:"RSAPublicKey"})},t.verifySubjectKeyIdentifier=function(){for(var e=ue.subjectKeyIdentifier,r=0;r<t.extensions.length;++r){var n=t.extensions[r];if(n.id===e){var i=t.generateSubjectKeyIdentifier().getBytes();return $.util.hexToBytes(n.subjectKeyIdentifier)===i}}return!1},t};L.certificateFromAsn1=function(t,e){var r={},n=[];if(!m.validate(t,iC,r,n)){var i=new Error("Cannot read X.509 certificate. ASN.1 object is not an X509v3 Certificate.");throw i.errors=n,i}var s=m.derToOid(r.publicKeyOid);if(s!==L.oids.rsaEncryption)throw new Error("Cannot read public key. OID is not RSA.");var o=L.createCertificate();o.version=r.certVersion?r.certVersion.charCodeAt(0):0;var a=$.util.createBuffer(r.certSerialNumber);o.serialNumber=a.toHex(),o.signatureOid=$.asn1.derToOid(r.certSignatureOid),o.signatureParameters=gc(o.signatureOid,r.certSignatureParams,!0),o.siginfo.algorithmOid=$.asn1.derToOid(r.certinfoSignatureOid),o.siginfo.parameters=gc(o.siginfo.algorithmOid,r.certinfoSignatureParams,!1),o.signature=r.certSignature;var c=[];if(r.certValidity1UTCTime!==void 0&&c.push(m.utcTimeToDate(r.certValidity1UTCTime)),r.certValidity2GeneralizedTime!==void 0&&c.push(m.generalizedTimeToDate(r.certValidity2GeneralizedTime)),r.certValidity3UTCTime!==void 0&&c.push(m.utcTimeToDate(r.certValidity3UTCTime)),r.certValidity4GeneralizedTime!==void 0&&c.push(m.generalizedTimeToDate(r.certValidity4GeneralizedTime)),c.length>2)throw new Error("Cannot read notBefore/notAfter validity times; more than two times were provided in the certificate.");if(c.length<2)throw new Error("Cannot read notBefore/notAfter validity times; they were not provided as either UTCTime or GeneralizedTime.");if(o.validity.notBefore=c[0],o.validity.notAfter=c[1],o.tbsCertificate=r.tbsCertificate,e){o.md=Ec({signatureOid:o.signatureOid,type:"certificate"});var u=m.toDer(o.tbsCertificate);o.md.update(u.getBytes())}var l=$.md.sha1.create(),f=m.toDer(r.certIssuer);l.update(f.getBytes()),o.issuer.getField=function(p){return Rn(o.issuer,p)},o.issuer.addField=function(p){Gt([p]),o.issuer.attributes.push(p)},o.issuer.attributes=L.RDNAttributesAsArray(r.certIssuer),r.certIssuerUniqueId&&(o.issuer.uniqueId=r.certIssuerUniqueId),o.issuer.hash=l.digest().toHex();var h=$.md.sha1.create(),d=m.toDer(r.certSubject);return h.update(d.getBytes()),o.subject.getField=function(p){return Rn(o.subject,p)},o.subject.addField=function(p){Gt([p]),o.subject.attributes.push(p)},o.subject.attributes=L.RDNAttributesAsArray(r.certSubject),r.certSubjectUniqueId&&(o.subject.uniqueId=r.certSubjectUniqueId),o.subject.hash=h.digest().toHex(),r.certExtensions?o.extensions=L.certificateExtensionsFromAsn1(r.certExtensions):o.extensions=[],o.publicKey=L.publicKeyFromAsn1(r.subjectPublicKeyInfo),o};L.certificateExtensionsFromAsn1=function(t){for(var e=[],r=0;r<t.value.length;++r)for(var n=t.value[r],i=0;i<n.value.length;++i)e.push(L.certificateExtensionFromAsn1(n.value[i]));return e};L.certificateExtensionFromAsn1=function(t){var e={};if(e.id=m.derToOid(t.value[0].value),e.critical=!1,t.value[1].type===m.Type.BOOLEAN?(e.critical=t.value[1].value.charCodeAt(0)!==0,e.value=t.value[2].value):e.value=t.value[1].value,e.id in ue){if(e.name=ue[e.id],e.name==="keyUsage"){var r=m.fromDer(e.value),n=0,i=0;r.value.length>1&&(n=r.value.charCodeAt(1),i=r.value.length>2?r.value.charCodeAt(2):0),e.digitalSignature=(n&128)===128,e.nonRepudiation=(n&64)===64,e.keyEncipherment=(n&32)===32,e.dataEncipherment=(n&16)===16,e.keyAgreement=(n&8)===8,e.keyCertSign=(n&4)===4,e.cRLSign=(n&2)===2,e.encipherOnly=(n&1)===1,e.decipherOnly=(i&128)===128}else if(e.name==="basicConstraints"){var r=m.fromDer(e.value);r.value.length>0&&r.value[0].type===m.Type.BOOLEAN?e.cA=r.value[0].value.charCodeAt(0)!==0:e.cA=!1;var s=null;r.value.length>0&&r.value[0].type===m.Type.INTEGER?s=r.value[0].value:r.value.length>1&&(s=r.value[1].value),s!==null&&(e.pathLenConstraint=m.derToInteger(s))}else if(e.name==="extKeyUsage")for(var r=m.fromDer(e.value),o=0;o<r.value.length;++o){var a=m.derToOid(r.value[o].value);a in ue?e[ue[a]]=!0:e[a]=!0}else if(e.name==="nsCertType"){var r=m.fromDer(e.value),n=0;r.value.length>1&&(n=r.value.charCodeAt(1)),e.client=(n&128)===128,e.server=(n&64)===64,e.email=(n&32)===32,e.objsign=(n&16)===16,e.reserved=(n&8)===8,e.sslCA=(n&4)===4,e.emailCA=(n&2)===2,e.objCA=(n&1)===1}else if(e.name==="subjectAltName"||e.name==="issuerAltName"){e.altNames=[];for(var c,r=m.fromDer(e.value),u=0;u<r.value.length;++u){c=r.value[u];var l={type:c.type,value:c.value};switch(e.altNames.push(l),c.type){case 1:case 2:case 6:break;case 7:l.ip=$.util.bytesToIP(c.value);break;case 8:l.oid=m.derToOid(c.value);break;default:}}}else if(e.name==="subjectKeyIdentifier"){var r=m.fromDer(e.value);e.subjectKeyIdentifier=$.util.bytesToHex(r.value)}}return e};L.certificationRequestFromAsn1=function(t,e){var r={},n=[];if(!m.validate(t,aC,r,n)){var i=new Error("Cannot read PKCS#10 certificate request. ASN.1 object is not a PKCS#10 CertificationRequest.");throw i.errors=n,i}var s=m.derToOid(r.publicKeyOid);if(s!==L.oids.rsaEncryption)throw new Error("Cannot read public key. OID is not RSA.");var o=L.createCertificationRequest();if(o.version=r.csrVersion?r.csrVersion.charCodeAt(0):0,o.signatureOid=$.asn1.derToOid(r.csrSignatureOid),o.signatureParameters=gc(o.signatureOid,r.csrSignatureParams,!0),o.siginfo.algorithmOid=$.asn1.derToOid(r.csrSignatureOid),o.siginfo.parameters=gc(o.siginfo.algorithmOid,r.csrSignatureParams,!1),o.signature=r.csrSignature,o.certificationRequestInfo=r.certificationRequestInfo,e){o.md=Ec({signatureOid:o.signatureOid,type:"certification request"});var a=m.toDer(o.certificationRequestInfo);o.md.update(a.getBytes())}var c=$.md.sha1.create();return o.subject.getField=function(u){return Rn(o.subject,u)},o.subject.addField=function(u){Gt([u]),o.subject.attributes.push(u)},o.subject.attributes=L.RDNAttributesAsArray(r.certificationRequestInfoSubject,c),o.subject.hash=c.digest().toHex(),o.publicKey=L.publicKeyFromAsn1(r.subjectPublicKeyInfo),o.getAttribute=function(u){return Rn(o,u)},o.addAttribute=function(u){Gt([u]),o.attributes.push(u)},o.attributes=L.CRIAttributesAsArray(r.certificationRequestInfoAttributes||[]),o};L.createCertificationRequest=function(){var t={};return t.version=0,t.signatureOid=null,t.signature=null,t.siginfo={},t.siginfo.algorithmOid=null,t.subject={},t.subject.getField=function(e){return Rn(t.subject,e)},t.subject.addField=function(e){Gt([e]),t.subject.attributes.push(e)},t.subject.attributes=[],t.subject.hash=null,t.publicKey=null,t.attributes=[],t.getAttribute=function(e){return Rn(t,e)},t.addAttribute=function(e){Gt([e]),t.attributes.push(e)},t.md=null,t.setSubject=function(e){Gt(e),t.subject.attributes=e,t.subject.hash=null},t.setAttributes=function(e){Gt(e),t.attributes=e},t.sign=function(e,r){t.md=r||$.md.sha1.create();var n=ue[t.md.algorithm+"WithRSAEncryption"];if(!n){var i=new Error("Could not compute certification request digest. Unknown message digest algorithm OID.");throw i.algorithm=t.md.algorithm,i}t.signatureOid=t.siginfo.algorithmOid=n,t.certificationRequestInfo=L.getCertificationRequestInfo(t);var s=m.toDer(t.certificationRequestInfo);t.md.update(s.getBytes()),t.signature=e.sign(t.md)},t.verify=function(){var e=!1,r=t.md;if(r===null){r=Ec({signatureOid:t.signatureOid,type:"certification request"});var n=t.certificationRequestInfo||L.getCertificationRequestInfo(t),i=m.toDer(n);r.update(i.getBytes())}return r!==null&&(e=Xg({certificate:t,md:r,signature:t.signature})),e},t};function cs(t){for(var e=m.create(m.Class.UNIVERSAL,m.Type.SEQUENCE,!0,[]),r,n,i=t.attributes,s=0;s<i.length;++s){r=i[s];var o=r.value,a=m.Type.PRINTABLESTRING;"valueTagClass"in r&&(a=r.valueTagClass,a===m.Type.UTF8&&(o=$.util.encodeUtf8(o))),n=m.create(m.Class.UNIVERSAL,m.Type.SET,!0,[m.create(m.Class.UNIVERSAL,m.Type.SEQUENCE,!0,[m.create(m.Class.UNIVERSAL,m.Type.OID,!1,m.oidToDer(r.type).getBytes()),m.create(m.Class.UNIVERSAL,a,!1,o)])]),e.value.push(n)}return e}function Gt(t){for(var e,r=0;r<t.length;++r){if(e=t[r],typeof e.name>"u"&&(e.type&&e.type in L.oids?e.name=L.oids[e.type]:e.shortName&&e.shortName in Ye&&(e.name=L.oids[Ye[e.shortName]])),typeof e.type>"u")if(e.name&&e.name in L.oids)e.type=L.oids[e.name];else{var n=new Error("Attribute type not specified.");throw n.attribute=e,n}if(typeof e.shortName>"u"&&e.name&&e.name in Ye&&(e.shortName=Ye[e.name]),e.type===ue.extensionRequest&&(e.valueConstructed=!0,e.valueTagClass=m.Type.SEQUENCE,!e.value&&e.extensions)){e.value=[];for(var i=0;i<e.extensions.length;++i)e.value.push(L.certificateExtensionToAsn1(jg(e.extensions[i])))}if(typeof e.value>"u"){var n=new Error("Attribute value not specified.");throw n.attribute=e,n}}}function jg(t,e){if(e=e||{},typeof t.name>"u"&&t.id&&t.id in L.oids&&(t.name=L.oids[t.id]),typeof t.id>"u")if(t.name&&t.name in L.oids)t.id=L.oids[t.name];else{var r=new Error("Extension ID not specified.");throw r.extension=t,r}if(typeof t.value<"u")return t;if(t.name==="keyUsage"){var n=0,i=0,s=0;t.digitalSignature&&(i|=128,n=7),t.nonRepudiation&&(i|=64,n=6),t.keyEncipherment&&(i|=32,n=5),t.dataEncipherment&&(i|=16,n=4),t.keyAgreement&&(i|=8,n=3),t.keyCertSign&&(i|=4,n=2),t.cRLSign&&(i|=2,n=1),t.encipherOnly&&(i|=1,n=0),t.decipherOnly&&(s|=128,n=7);var o=String.fromCharCode(n);s!==0?o+=String.fromCharCode(i)+String.fromCharCode(s):i!==0&&(o+=String.fromCharCode(i)),t.value=m.create(m.Class.UNIVERSAL,m.Type.BITSTRING,!1,o)}else if(t.name==="basicConstraints")t.value=m.create(m.Class.UNIVERSAL,m.Type.SEQUENCE,!0,[]),t.cA&&t.value.value.push(m.create(m.Class.UNIVERSAL,m.Type.BOOLEAN,!1,String.fromCharCode(255))),"pathLenConstraint"in t&&t.value.value.push(m.create(m.Class.UNIVERSAL,m.Type.INTEGER,!1,m.integerToDer(t.pathLenConstraint).getBytes()));else if(t.name==="extKeyUsage"){t.value=m.create(m.Class.UNIVERSAL,m.Type.SEQUENCE,!0,[]);var a=t.value.value;for(var c in t)t[c]===!0&&(c in ue?a.push(m.create(m.Class.UNIVERSAL,m.Type.OID,!1,m.oidToDer(ue[c]).getBytes())):c.indexOf(".")!==-1&&a.push(m.create(m.Class.UNIVERSAL,m.Type.OID,!1,m.oidToDer(c).getBytes())))}else if(t.name==="nsCertType"){var n=0,i=0;t.client&&(i|=128,n=7),t.server&&(i|=64,n=6),t.email&&(i|=32,n=5),t.objsign&&(i|=16,n=4),t.reserved&&(i|=8,n=3),t.sslCA&&(i|=4,n=2),t.emailCA&&(i|=2,n=1),t.objCA&&(i|=1,n=0);var o=String.fromCharCode(n);i!==0&&(o+=String.fromCharCode(i)),t.value=m.create(m.Class.UNIVERSAL,m.Type.BITSTRING,!1,o)}else if(t.name==="subjectAltName"||t.name==="issuerAltName"){t.value=m.create(m.Class.UNIVERSAL,m.Type.SEQUENCE,!0,[]);for(var u,l=0;l<t.altNames.length;++l){u=t.altNames[l];var o=u.value;if(u.type===7&&u.ip){if(o=$.util.bytesFromIP(u.ip),o===null){var r=new Error('Extension "ip" value is not a valid IPv4 or IPv6 address.');throw r.extension=t,r}}else u.type===8&&(u.oid?o=m.oidToDer(m.oidToDer(u.oid)):o=m.oidToDer(o));t.value.value.push(m.create(m.Class.CONTEXT_SPECIFIC,u.type,!1,o))}}else if(t.name==="nsComment"&&e.cert){if(!/^[\x00-\x7F]*$/.test(t.comment)||t.comment.length<1||t.comment.length>128)throw new Error('Invalid "nsComment" content.');t.value=m.create(m.Class.UNIVERSAL,m.Type.IA5STRING,!1,t.comment)}else if(t.name==="subjectKeyIdentifier"&&e.cert){var f=e.cert.generateSubjectKeyIdentifier();t.subjectKeyIdentifier=f.toHex(),t.value=m.create(m.Class.UNIVERSAL,m.Type.OCTETSTRING,!1,f.getBytes())}else if(t.name==="authorityKeyIdentifier"&&e.cert){t.value=m.create(m.Class.UNIVERSAL,m.Type.SEQUENCE,!0,[]);var a=t.value.value;if(t.keyIdentifier){var h=t.keyIdentifier===!0?e.cert.generateSubjectKeyIdentifier().getBytes():t.keyIdentifier;a.push(m.create(m.Class.CONTEXT_SPECIFIC,0,!1,h))}if(t.authorityCertIssuer){var d=[m.create(m.Class.CONTEXT_SPECIFIC,4,!0,[cs(t.authorityCertIssuer===!0?e.cert.issuer:t.authorityCertIssuer)])];a.push(m.create(m.Class.CONTEXT_SPECIFIC,1,!0,d))}if(t.serialNumber){var p=$.util.hexToBytes(t.serialNumber===!0?e.cert.serialNumber:t.serialNumber);a.push(m.create(m.Class.CONTEXT_SPECIFIC,2,!1,p))}}else if(t.name==="cRLDistributionPoints"){t.value=m.create(m.Class.UNIVERSAL,m.Type.SEQUENCE,!0,[]);for(var a=t.value.value,y=m.create(m.Class.UNIVERSAL,m.Type.SEQUENCE,!0,[]),g=m.create(m.Class.CONTEXT_SPECIFIC,0,!0,[]),u,l=0;l<t.altNames.length;++l){u=t.altNames[l];var o=u.value;if(u.type===7&&u.ip){if(o=$.util.bytesFromIP(u.ip),o===null){var r=new Error('Extension "ip" value is not a valid IPv4 or IPv6 address.');throw r.extension=t,r}}else u.type===8&&(u.oid?o=m.oidToDer(m.oidToDer(u.oid)):o=m.oidToDer(o));g.value.push(m.create(m.Class.CONTEXT_SPECIFIC,u.type,!1,o))}y.value.push(m.create(m.Class.CONTEXT_SPECIFIC,0,!0,[g])),a.push(y)}if(typeof t.value>"u"){var r=new Error("Extension value not specified.");throw r.extension=t,r}return t}function Bf(t,e){switch(t){case ue["RSASSA-PSS"]:var r=[];return e.hash.algorithmOid!==void 0&&r.push(m.create(m.Class.CONTEXT_SPECIFIC,0,!0,[m.create(m.Class.UNIVERSAL,m.Type.SEQUENCE,!0,[m.create(m.Class.UNIVERSAL,m.Type.OID,!1,m.oidToDer(e.hash.algorithmOid).getBytes()),m.create(m.Class.UNIVERSAL,m.Type.NULL,!1,"")])])),e.mgf.algorithmOid!==void 0&&r.push(m.create(m.Class.CONTEXT_SPECIFIC,1,!0,[m.create(m.Class.UNIVERSAL,m.Type.SEQUENCE,!0,[m.create(m.Class.UNIVERSAL,m.Type.OID,!1,m.oidToDer(e.mgf.algorithmOid).getBytes()),m.create(m.Class.UNIVERSAL,m.Type.SEQUENCE,!0,[m.create(m.Class.UNIVERSAL,m.Type.OID,!1,m.oidToDer(e.mgf.hash.algorithmOid).getBytes()),m.create(m.Class.UNIVERSAL,m.Type.NULL,!1,"")])])])),e.saltLength!==void 0&&r.push(m.create(m.Class.CONTEXT_SPECIFIC,2,!0,[m.create(m.Class.UNIVERSAL,m.Type.INTEGER,!1,m.integerToDer(e.saltLength).getBytes())])),m.create(m.Class.UNIVERSAL,m.Type.SEQUENCE,!0,r);default:return m.create(m.Class.UNIVERSAL,m.Type.NULL,!1,"")}}function cC(t){var e=m.create(m.Class.CONTEXT_SPECIFIC,0,!0,[]);if(t.attributes.length===0)return e;for(var r=t.attributes,n=0;n<r.length;++n){var i=r[n],s=i.value,o=m.Type.UTF8;"valueTagClass"in i&&(o=i.valueTagClass),o===m.Type.UTF8&&(s=$.util.encodeUtf8(s));var a=!1;"valueConstructed"in i&&(a=i.valueConstructed);var c=m.create(m.Class.UNIVERSAL,m.Type.SEQUENCE,!0,[m.create(m.Class.UNIVERSAL,m.Type.OID,!1,m.oidToDer(i.type).getBytes()),m.create(m.Class.UNIVERSAL,m.Type.SET,!0,[m.create(m.Class.UNIVERSAL,o,a,s)])]);e.value.push(c)}return e}var uC=new Date("1950-01-01T00:00:00Z"),lC=new Date("2050-01-01T00:00:00Z");function Wg(t){return t>=uC&&t<lC?m.create(m.Class.UNIVERSAL,m.Type.UTCTIME,!1,m.dateToUtcTime(t)):m.create(m.Class.UNIVERSAL,m.Type.GENERALIZEDTIME,!1,m.dateToGeneralizedTime(t))}L.getTBSCertificate=function(t){var e=Wg(t.validity.notBefore),r=Wg(t.validity.notAfter),n=m.create(m.Class.UNIVERSAL,m.Type.SEQUENCE,!0,[m.create(m.Class.CONTEXT_SPECIFIC,0,!0,[m.create(m.Class.UNIVERSAL,m.Type.INTEGER,!1,m.integerToDer(t.version).getBytes())]),m.create(m.Class.UNIVERSAL,m.Type.INTEGER,!1,$.util.hexToBytes(t.serialNumber)),m.create(m.Class.UNIVERSAL,m.Type.SEQUENCE,!0,[m.create(m.Class.UNIVERSAL,m.Type.OID,!1,m.oidToDer(t.siginfo.algorithmOid).getBytes()),Bf(t.siginfo.algorithmOid,t.siginfo.parameters)]),cs(t.issuer),m.create(m.Class.UNIVERSAL,m.Type.SEQUENCE,!0,[e,r]),cs(t.subject),L.publicKeyToAsn1(t.publicKey)]);return t.issuer.uniqueId&&n.value.push(m.create(m.Class.CONTEXT_SPECIFIC,1,!0,[m.create(m.Class.UNIVERSAL,m.Type.BITSTRING,!1,String.fromCharCode(0)+t.issuer.uniqueId)])),t.subject.uniqueId&&n.value.push(m.create(m.Class.CONTEXT_SPECIFIC,2,!0,[m.create(m.Class.UNIVERSAL,m.Type.BITSTRING,!1,String.fromCharCode(0)+t.subject.uniqueId)])),t.extensions.length>0&&n.value.push(L.certificateExtensionsToAsn1(t.extensions)),n};L.getCertificationRequestInfo=function(t){var e=m.create(m.Class.UNIVERSAL,m.Type.SEQUENCE,!0,[m.create(m.Class.UNIVERSAL,m.Type.INTEGER,!1,m.integerToDer(t.version).getBytes()),cs(t.subject),L.publicKeyToAsn1(t.publicKey),cC(t)]);return e};L.distinguishedNameToAsn1=function(t){return cs(t)};L.certificateToAsn1=function(t){var e=t.tbsCertificate||L.getTBSCertificate(t);return m.create(m.Class.UNIVERSAL,m.Type.SEQUENCE,!0,[e,m.create(m.Class.UNIVERSAL,m.Type.SEQUENCE,!0,[m.create(m.Class.UNIVERSAL,m.Type.OID,!1,m.oidToDer(t.signatureOid).getBytes()),Bf(t.signatureOid,t.signatureParameters)]),m.create(m.Class.UNIVERSAL,m.Type.BITSTRING,!1,String.fromCharCode(0)+t.signature)])};L.certificateExtensionsToAsn1=function(t){var e=m.create(m.Class.CONTEXT_SPECIFIC,3,!0,[]),r=m.create(m.Class.UNIVERSAL,m.Type.SEQUENCE,!0,[]);e.value.push(r);for(var n=0;n<t.length;++n)r.value.push(L.certificateExtensionToAsn1(t[n]));return e};L.certificateExtensionToAsn1=function(t){var e=m.create(m.Class.UNIVERSAL,m.Type.SEQUENCE,!0,[]);e.value.push(m.create(m.Class.UNIVERSAL,m.Type.OID,!1,m.oidToDer(t.id).getBytes())),t.critical&&e.value.push(m.create(m.Class.UNIVERSAL,m.Type.BOOLEAN,!1,String.fromCharCode(255)));var r=t.value;return typeof t.value!="string"&&(r=m.toDer(r).getBytes()),e.value.push(m.create(m.Class.UNIVERSAL,m.Type.OCTETSTRING,!1,r)),e};L.certificationRequestToAsn1=function(t){var e=t.certificationRequestInfo||L.getCertificationRequestInfo(t);return m.create(m.Class.UNIVERSAL,m.Type.SEQUENCE,!0,[e,m.create(m.Class.UNIVERSAL,m.Type.SEQUENCE,!0,[m.create(m.Class.UNIVERSAL,m.Type.OID,!1,m.oidToDer(t.signatureOid).getBytes()),Bf(t.signatureOid,t.signatureParameters)]),m.create(m.Class.UNIVERSAL,m.Type.BITSTRING,!1,String.fromCharCode(0)+t.signature)])};L.createCaStore=function(t){var e={certs:{}};e.getIssuer=function(o){var a=r(o.issuer);return a},e.addCertificate=function(o){if(typeof o=="string"&&(o=$.pki.certificateFromPem(o)),n(o.subject),!e.hasCertificate(o))if(o.subject.hash in e.certs){var a=e.certs[o.subject.hash];$.util.isArray(a)||(a=[a]),a.push(o),e.certs[o.subject.hash]=a}else e.certs[o.subject.hash]=o},e.hasCertificate=function(o){typeof o=="string"&&(o=$.pki.certificateFromPem(o));var a=r(o.subject);if(!a)return!1;$.util.isArray(a)||(a=[a]);for(var c=m.toDer(L.certificateToAsn1(o)).getBytes(),u=0;u<a.length;++u){var l=m.toDer(L.certificateToAsn1(a[u])).getBytes();if(c===l)return!0}return!1},e.listAllCertificates=function(){var o=[];for(var a in e.certs)if(e.certs.hasOwnProperty(a)){var c=e.certs[a];if(!$.util.isArray(c))o.push(c);else for(var u=0;u<c.length;++u)o.push(c[u])}return o},e.removeCertificate=function(o){var a;if(typeof o=="string"&&(o=$.pki.certificateFromPem(o)),n(o.subject),!e.hasCertificate(o))return null;var c=r(o.subject);if(!$.util.isArray(c))return a=e.certs[o.subject.hash],delete e.certs[o.subject.hash],a;for(var u=m.toDer(L.certificateToAsn1(o)).getBytes(),l=0;l<c.length;++l){var f=m.toDer(L.certificateToAsn1(c[l])).getBytes();u===f&&(a=c[l],c.splice(l,1))}return c.length===0&&delete e.certs[o.subject.hash],a};function r(o){return n(o),e.certs[o.hash]||null}function n(o){if(!o.hash){var a=$.md.sha1.create();o.attributes=L.RDNAttributesAsArray(cs(o),a),o.hash=a.digest().toHex()}}if(t)for(var i=0;i<t.length;++i){var s=t[i];e.addCertificate(s)}return e};L.certificateError={bad_certificate:"forge.pki.BadCertificate",unsupported_certificate:"forge.pki.UnsupportedCertificate",certificate_revoked:"forge.pki.CertificateRevoked",certificate_expired:"forge.pki.CertificateExpired",certificate_unknown:"forge.pki.CertificateUnknown",unknown_ca:"forge.pki.UnknownCertificateAuthority"};L.verifyCertificateChain=function(t,e,r){typeof r=="function"&&(r={verify:r}),r=r||{},e=e.slice(0);var n=e.slice(0),i=r.validityCheckDate;typeof i>"u"&&(i=new Date);var s=!0,o=null,a=0;do{var c=e.shift(),u=null,l=!1;if(i&&(i<c.validity.notBefore||i>c.validity.notAfter)&&(o={message:"Certificate is not valid yet or has expired.",error:L.certificateError.certificate_expired,notBefore:c.validity.notBefore,notAfter:c.validity.notAfter,now:i}),o===null){if(u=e[0]||t.getIssuer(c),u===null&&c.isIssuer(c)&&(l=!0,u=c),u){var f=u;$.util.isArray(f)||(f=[f]);for(var h=!1;!h&&f.length>0;){u=f.shift();try{h=u.verify(c)}catch{}}h||(o={message:"Certificate signature is invalid.",error:L.certificateError.bad_certificate})}o===null&&(!u||l)&&!t.hasCertificate(c)&&(o={message:"Certificate is not trusted.",error:L.certificateError.unknown_ca})}if(o===null&&u&&!c.isIssuer(u)&&(o={message:"Certificate issuer is invalid.",error:L.certificateError.bad_certificate}),o===null)for(var d={keyUsage:!0,basicConstraints:!0},p=0;o===null&&p<c.extensions.length;++p){var y=c.extensions[p];y.critical&&!(y.name in d)&&(o={message:"Certificate has an unsupported critical extension.",error:L.certificateError.unsupported_certificate})}if(o===null&&(!s||e.length===0&&(!u||l))){var g=c.getExtension("basicConstraints"),E=c.getExtension("keyUsage");if(E!==null&&(!E.keyCertSign||g===null)&&(o={message:"Certificate keyUsage or basicConstraints conflict or indicate that the certificate is not a CA. If the certificate is the only one in the chain or isn't the first then the certificate must be a valid CA.",error:L.certificateError.bad_certificate}),o===null&&g!==null&&!g.cA&&(o={message:"Certificate basicConstraints indicates the certificate is not a CA.",error:L.certificateError.bad_certificate}),o===null&&E!==null&&"pathLenConstraint"in g){var x=a-1;x>g.pathLenConstraint&&(o={message:"Certificate basicConstraints pathLenConstraint violated.",error:L.certificateError.bad_certificate})}}var _=o===null?!0:o.error,B=r.verify?r.verify(_,a,n):_;if(B===!0)o=null;else throw _===!0&&(o={message:"The application rejected the certificate.",error:L.certificateError.bad_certificate}),(B||B===0)&&(typeof B=="object"&&!$.util.isArray(B)?(B.message&&(o.message=B.message),B.error&&(o.error=B.error)):typeof B=="string"&&(o.error=B)),o;s=!1,++a}while(e.length>0);return!0}});var tE=R((j4,eE)=>{var O=ie();rs();An();sc();ns();cc();cg();ai();De();Of();var v=O.asn1,vt=eE.exports=O.pkcs7=O.pkcs7||{};vt.messageFromPem=function(t){var e=O.pem.decode(t)[0];if(e.type!=="PKCS7"){var r=new Error('Could not convert PKCS#7 message from PEM; PEM header type is not "PKCS#7".');throw r.headerType=e.type,r}if(e.procType&&e.procType.type==="ENCRYPTED")throw new Error("Could not convert PKCS#7 message from PEM; PEM is encrypted.");var n=v.fromDer(e.body);return vt.messageFromAsn1(n)};vt.messageToPem=function(t,e){var r={type:"PKCS7",body:v.toDer(t.toAsn1()).getBytes()};return O.pem.encode(r,{maxline:e})};vt.messageFromAsn1=function(t){var e={},r=[];if(!v.validate(t,vt.asn1.contentInfoValidator,e,r)){var n=new Error("Cannot read PKCS#7 message. ASN.1 object is not an PKCS#7 ContentInfo.");throw n.errors=r,n}var i=v.derToOid(e.contentType),s;switch(i){case O.pki.oids.envelopedData:s=vt.createEnvelopedData();break;case O.pki.oids.encryptedData:s=vt.createEncryptedData();break;case O.pki.oids.signedData:s=vt.createSignedData();break;default:throw new Error("Cannot read PKCS#7 message. ContentType with OID "+i+" is not (yet) supported.")}return s.fromAsn1(e.content.value[0]),s};vt.createSignedData=function(){var t=null;return t={type:O.pki.oids.signedData,version:1,certificates:[],crls:[],signers:[],digestAlgorithmIdentifiers:[],contentInfo:null,signerInfos:[],fromAsn1:function(n){if(Uf(t,n,vt.asn1.signedDataValidator),t.certificates=[],t.crls=[],t.digestAlgorithmIdentifiers=[],t.contentInfo=null,t.signerInfos=[],t.rawCapture.certificates)for(var i=t.rawCapture.certificates.value,s=0;s<i.length;++s)t.certificates.push(O.pki.certificateFromAsn1(i[s]))},toAsn1:function(){t.contentInfo||t.sign();for(var n=[],i=0;i<t.certificates.length;++i)n.push(O.pki.certificateToAsn1(t.certificates[i]));var s=[],o=v.create(v.Class.CONTEXT_SPECIFIC,0,!0,[v.create(v.Class.UNIVERSAL,v.Type.SEQUENCE,!0,[v.create(v.Class.UNIVERSAL,v.Type.INTEGER,!1,v.integerToDer(t.version).getBytes()),v.create(v.Class.UNIVERSAL,v.Type.SET,!0,t.digestAlgorithmIdentifiers),t.contentInfo])]);return n.length>0&&o.value[0].value.push(v.create(v.Class.CONTEXT_SPECIFIC,0,!0,n)),s.length>0&&o.value[0].value.push(v.create(v.Class.CONTEXT_SPECIFIC,1,!0,s)),o.value[0].value.push(v.create(v.Class.UNIVERSAL,v.Type.SET,!0,t.signerInfos)),v.create(v.Class.UNIVERSAL,v.Type.SEQUENCE,!0,[v.create(v.Class.UNIVERSAL,v.Type.OID,!1,v.oidToDer(t.type).getBytes()),o])},addSigner:function(n){var i=n.issuer,s=n.serialNumber;if(n.certificate){var o=n.certificate;typeof o=="string"&&(o=O.pki.certificateFromPem(o)),i=o.issuer.attributes,s=o.serialNumber}var a=n.key;if(!a)throw new Error("Could not add PKCS#7 signer; no private key specified.");typeof a=="string"&&(a=O.pki.privateKeyFromPem(a));var c=n.digestAlgorithm||O.pki.oids.sha1;switch(c){case O.pki.oids.sha1:case O.pki.oids.sha256:case O.pki.oids.sha384:case O.pki.oids.sha512:case O.pki.oids.md5:break;default:throw new Error("Could not add PKCS#7 signer; unknown message digest algorithm: "+c)}var u=n.authenticatedAttributes||[];if(u.length>0){for(var l=!1,f=!1,h=0;h<u.length;++h){var d=u[h];if(!l&&d.type===O.pki.oids.contentType){if(l=!0,f)break;continue}if(!f&&d.type===O.pki.oids.messageDigest){if(f=!0,l)break;continue}}if(!l||!f)throw new Error("Invalid signer.authenticatedAttributes. If signer.authenticatedAttributes is specified, then it must contain at least two attributes, PKCS #9 content-type and PKCS #9 message-digest.")}t.signers.push({key:a,version:1,issuer:i,serialNumber:s,digestAlgorithm:c,signatureAlgorithm:O.pki.oids.rsaEncryption,signature:null,authenticatedAttributes:u,unauthenticatedAttributes:[]})},sign:function(n){if(n=n||{},(typeof t.content!="object"||t.contentInfo===null)&&(t.contentInfo=v.create(v.Class.UNIVERSAL,v.Type.SEQUENCE,!0,[v.create(v.Class.UNIVERSAL,v.Type.OID,!1,v.oidToDer(O.pki.oids.data).getBytes())]),"content"in t)){var i;t.content instanceof O.util.ByteBuffer?i=t.content.bytes():typeof t.content=="string"&&(i=O.util.encodeUtf8(t.content)),n.detached?t.detachedContent=v.create(v.Class.UNIVERSAL,v.Type.OCTETSTRING,!1,i):t.contentInfo.value.push(v.create(v.Class.CONTEXT_SPECIFIC,0,!0,[v.create(v.Class.UNIVERSAL,v.Type.OCTETSTRING,!1,i)]))}if(t.signers.length!==0){var s=e();r(s)}},verify:function(){throw new Error("PKCS#7 signature verification not yet implemented.")},addCertificate:function(n){typeof n=="string"&&(n=O.pki.certificateFromPem(n)),t.certificates.push(n)},addCertificateRevokationList:function(n){throw new Error("PKCS#7 CRL support not yet implemented.")}},t;function e(){for(var n={},i=0;i<t.signers.length;++i){var s=t.signers[i],o=s.digestAlgorithm;o in n||(n[o]=O.md[O.pki.oids[o]].create()),s.authenticatedAttributes.length===0?s.md=n[o]:s.md=O.md[O.pki.oids[o]].create()}t.digestAlgorithmIdentifiers=[];for(var o in n)t.digestAlgorithmIdentifiers.push(v.create(v.Class.UNIVERSAL,v.Type.SEQUENCE,!0,[v.create(v.Class.UNIVERSAL,v.Type.OID,!1,v.oidToDer(o).getBytes()),v.create(v.Class.UNIVERSAL,v.Type.NULL,!1,"")]));return n}function r(n){var i;if(t.detachedContent?i=t.detachedContent:(i=t.contentInfo.value[1],i=i.value[0]),!i)throw new Error("Could not sign PKCS#7 message; there is no content to sign.");var s=v.derToOid(t.contentInfo.value[0].value),o=v.toDer(i);o.getByte(),v.getBerValueLength(o),o=o.getBytes();for(var a in n)n[a].start().update(o);for(var c=new Date,u=0;u<t.signers.length;++u){var l=t.signers[u];if(l.authenticatedAttributes.length===0){if(s!==O.pki.oids.data)throw new Error("Invalid signer; authenticatedAttributes must be present when the ContentInfo content type is not PKCS#7 Data.")}else{l.authenticatedAttributesAsn1=v.create(v.Class.CONTEXT_SPECIFIC,0,!0,[]);for(var f=v.create(v.Class.UNIVERSAL,v.Type.SET,!0,[]),h=0;h<l.authenticatedAttributes.length;++h){var d=l.authenticatedAttributes[h];d.type===O.pki.oids.messageDigest?d.value=n[l.digestAlgorithm].digest():d.type===O.pki.oids.signingTime&&(d.value||(d.value=c)),f.value.push(kf(d)),l.authenticatedAttributesAsn1.value.push(kf(d))}o=v.toDer(f).getBytes(),l.md.start().update(o)}l.signature=l.key.sign(l.md,"RSASSA-PKCS1-V1_5")}t.signerInfos=yC(t.signers)}};vt.createEncryptedData=function(){var t=null;return t={type:O.pki.oids.encryptedData,version:0,encryptedContent:{algorithm:O.pki.oids["aes256-CBC"]},fromAsn1:function(e){Uf(t,e,vt.asn1.encryptedDataValidator)},decrypt:function(e){e!==void 0&&(t.encryptedContent.key=e),Jg(t)}},t};vt.createEnvelopedData=function(){var t=null;return t={type:O.pki.oids.envelopedData,version:0,recipients:[],encryptedContent:{algorithm:O.pki.oids["aes256-CBC"]},fromAsn1:function(e){var r=Uf(t,e,vt.asn1.envelopedDataValidator);t.recipients=dC(r.recipientInfos.value)},toAsn1:function(){return v.create(v.Class.UNIVERSAL,v.Type.SEQUENCE,!0,[v.create(v.Class.UNIVERSAL,v.Type.OID,!1,v.oidToDer(t.type).getBytes()),v.create(v.Class.CONTEXT_SPECIFIC,0,!0,[v.create(v.Class.UNIVERSAL,v.Type.SEQUENCE,!0,[v.create(v.Class.UNIVERSAL,v.Type.INTEGER,!1,v.integerToDer(t.version).getBytes()),v.create(v.Class.UNIVERSAL,v.Type.SET,!0,pC(t.recipients)),v.create(v.Class.UNIVERSAL,v.Type.SEQUENCE,!0,gC(t.encryptedContent))])])])},findRecipient:function(e){for(var r=e.issuer.attributes,n=0;n<t.recipients.length;++n){var i=t.recipients[n],s=i.issuer;if(i.serialNumber===e.serialNumber&&s.length===r.length){for(var o=!0,a=0;a<r.length;++a)if(s[a].type!==r[a].type||s[a].value!==r[a].value){o=!1;break}if(o)return i}}return null},decrypt:function(e,r){if(t.encryptedContent.key===void 0&&e!==void 0&&r!==void 0)switch(e.encryptedContent.algorithm){case O.pki.oids.rsaEncryption:case O.pki.oids.desCBC:var n=r.decrypt(e.encryptedContent.content);t.encryptedContent.key=O.util.createBuffer(n);break;default:throw new Error("Unsupported asymmetric cipher, OID "+e.encryptedContent.algorithm)}Jg(t)},addRecipient:function(e){t.recipients.push({version:0,issuer:e.issuer.attributes,serialNumber:e.serialNumber,encryptedContent:{algorithm:O.pki.oids.rsaEncryption,key:e.publicKey}})},encrypt:function(e,r){if(t.encryptedContent.content===void 0){r=r||t.encryptedContent.algorithm,e=e||t.encryptedContent.key;var n,i,s;switch(r){case O.pki.oids["aes128-CBC"]:n=16,i=16,s=O.aes.createEncryptionCipher;break;case O.pki.oids["aes192-CBC"]:n=24,i=16,s=O.aes.createEncryptionCipher;break;case O.pki.oids["aes256-CBC"]:n=32,i=16,s=O.aes.createEncryptionCipher;break;case O.pki.oids["des-EDE3-CBC"]:n=24,i=8,s=O.des.createEncryptionCipher;break;default:throw new Error("Unsupported symmetric cipher, OID "+r)}if(e===void 0)e=O.util.createBuffer(O.random.getBytes(n));else if(e.length()!=n)throw new Error("Symmetric key has wrong length; got "+e.length()+" bytes, expected "+n+".");t.encryptedContent.algorithm=r,t.encryptedContent.key=e,t.encryptedContent.parameter=O.util.createBuffer(O.random.getBytes(i));var o=s(e);if(o.start(t.encryptedContent.parameter.copy()),o.update(t.content),!o.finish())throw new Error("Symmetric encryption failed.");t.encryptedContent.content=o.output}for(var a=0;a<t.recipients.length;++a){var c=t.recipients[a];if(c.encryptedContent.content===void 0)switch(c.encryptedContent.algorithm){case O.pki.oids.rsaEncryption:c.encryptedContent.content=c.encryptedContent.key.encrypt(t.encryptedContent.key.data);break;default:throw new Error("Unsupported asymmetric cipher, OID "+c.encryptedContent.algorithm)}}}},t};function fC(t){var e={},r=[];if(!v.validate(t,vt.asn1.recipientInfoValidator,e,r)){var n=new Error("Cannot read PKCS#7 RecipientInfo. ASN.1 object is not an PKCS#7 RecipientInfo.");throw n.errors=r,n}return{version:e.version.charCodeAt(0),issuer:O.pki.RDNAttributesAsArray(e.issuer),serialNumber:O.util.createBuffer(e.serial).toHex(),encryptedContent:{algorithm:v.derToOid(e.encAlgorithm),parameter:e.encParameter?e.encParameter.value:void 0,content:e.encKey}}}function hC(t){return v.create(v.Class.UNIVERSAL,v.Type.SEQUENCE,!0,[v.create(v.Class.UNIVERSAL,v.Type.INTEGER,!1,v.integerToDer(t.version).getBytes()),v.create(v.Class.UNIVERSAL,v.Type.SEQUENCE,!0,[O.pki.distinguishedNameToAsn1({attributes:t.issuer}),v.create(v.Class.UNIVERSAL,v.Type.INTEGER,!1,O.util.hexToBytes(t.serialNumber))]),v.create(v.Class.UNIVERSAL,v.Type.SEQUENCE,!0,[v.create(v.Class.UNIVERSAL,v.Type.OID,!1,v.oidToDer(t.encryptedContent.algorithm).getBytes()),v.create(v.Class.UNIVERSAL,v.Type.NULL,!1,"")]),v.create(v.Class.UNIVERSAL,v.Type.OCTETSTRING,!1,t.encryptedContent.content)])}function dC(t){for(var e=[],r=0;r<t.length;++r)e.push(fC(t[r]));return e}function pC(t){for(var e=[],r=0;r<t.length;++r)e.push(hC(t[r]));return e}function mC(t){var e=v.create(v.Class.UNIVERSAL,v.Type.SEQUENCE,!0,[v.create(v.Class.UNIVERSAL,v.Type.INTEGER,!1,v.integerToDer(t.version).getBytes()),v.create(v.Class.UNIVERSAL,v.Type.SEQUENCE,!0,[O.pki.distinguishedNameToAsn1({attributes:t.issuer}),v.create(v.Class.UNIVERSAL,v.Type.INTEGER,!1,O.util.hexToBytes(t.serialNumber))]),v.create(v.Class.UNIVERSAL,v.Type.SEQUENCE,!0,[v.create(v.Class.UNIVERSAL,v.Type.OID,!1,v.oidToDer(t.digestAlgorithm).getBytes()),v.create(v.Class.UNIVERSAL,v.Type.NULL,!1,"")])]);if(t.authenticatedAttributesAsn1&&e.value.push(t.authenticatedAttributesAsn1),e.value.push(v.create(v.Class.UNIVERSAL,v.Type.SEQUENCE,!0,[v.create(v.Class.UNIVERSAL,v.Type.OID,!1,v.oidToDer(t.signatureAlgorithm).getBytes()),v.create(v.Class.UNIVERSAL,v.Type.NULL,!1,"")])),e.value.push(v.create(v.Class.UNIVERSAL,v.Type.OCTETSTRING,!1,t.signature)),t.unauthenticatedAttributes.length>0){for(var r=v.create(v.Class.CONTEXT_SPECIFIC,1,!0,[]),n=0;n<t.unauthenticatedAttributes.length;++n){var i=t.unauthenticatedAttributes[n];r.values.push(kf(i))}e.value.push(r)}return e}function yC(t){for(var e=[],r=0;r<t.length;++r)e.push(mC(t[r]));return e}function kf(t){var e;if(t.type===O.pki.oids.contentType)e=v.create(v.Class.UNIVERSAL,v.Type.OID,!1,v.oidToDer(t.value).getBytes());else if(t.type===O.pki.oids.messageDigest)e=v.create(v.Class.UNIVERSAL,v.Type.OCTETSTRING,!1,t.value.bytes());else if(t.type===O.pki.oids.signingTime){var r=new Date("1950-01-01T00:00:00Z"),n=new Date("2050-01-01T00:00:00Z"),i=t.value;if(typeof i=="string"){var s=Date.parse(i);isNaN(s)?i.length===13?i=v.utcTimeToDate(i):i=v.generalizedTimeToDate(i):i=new Date(s)}i>=r&&i<n?e=v.create(v.Class.UNIVERSAL,v.Type.UTCTIME,!1,v.dateToUtcTime(i)):e=v.create(v.Class.UNIVERSAL,v.Type.GENERALIZEDTIME,!1,v.dateToGeneralizedTime(i))}return v.create(v.Class.UNIVERSAL,v.Type.SEQUENCE,!0,[v.create(v.Class.UNIVERSAL,v.Type.OID,!1,v.oidToDer(t.type).getBytes()),v.create(v.Class.UNIVERSAL,v.Type.SET,!0,[e])])}function gC(t){return[v.create(v.Class.UNIVERSAL,v.Type.OID,!1,v.oidToDer(O.pki.oids.data).getBytes()),v.create(v.Class.UNIVERSAL,v.Type.SEQUENCE,!0,[v.create(v.Class.UNIVERSAL,v.Type.OID,!1,v.oidToDer(t.algorithm).getBytes()),t.parameter?v.create(v.Class.UNIVERSAL,v.Type.OCTETSTRING,!1,t.parameter.getBytes()):void 0]),v.create(v.Class.CONTEXT_SPECIFIC,0,!0,[v.create(v.Class.UNIVERSAL,v.Type.OCTETSTRING,!1,t.content.getBytes())])]}function Uf(t,e,r){var n={},i=[];if(!v.validate(e,r,n,i)){var s=new Error("Cannot read PKCS#7 message. ASN.1 object is not a supported PKCS#7 message.");throw s.errors=s,s}var o=v.derToOid(n.contentType);if(o!==O.pki.oids.data)throw new Error("Unsupported PKCS#7 message. Only wrapped ContentType Data supported.");if(n.encryptedContent){var a="";if(O.util.isArray(n.encryptedContent))for(var c=0;c<n.encryptedContent.length;++c){if(n.encryptedContent[c].type!==v.Type.OCTETSTRING)throw new Error("Malformed PKCS#7 message, expecting encrypted content constructed of only OCTET STRING objects.");a+=n.encryptedContent[c].value}else a=n.encryptedContent;t.encryptedContent={algorithm:v.derToOid(n.encAlgorithm),parameter:O.util.createBuffer(n.encParameter.value),content:O.util.createBuffer(a)}}if(n.content){var a="";if(O.util.isArray(n.content))for(var c=0;c<n.content.length;++c){if(n.content[c].type!==v.Type.OCTETSTRING)throw new Error("Malformed PKCS#7 message, expecting content constructed of only OCTET STRING objects.");a+=n.content[c].value}else a=n.content;t.content=O.util.createBuffer(a)}return t.version=n.version.charCodeAt(0),t.rawCapture=n,n}function Jg(t){if(t.encryptedContent.key===void 0)throw new Error("Symmetric key not available.");if(t.content===void 0){var e;switch(t.encryptedContent.algorithm){case O.pki.oids["aes128-CBC"]:case O.pki.oids["aes192-CBC"]:case O.pki.oids["aes256-CBC"]:e=O.aes.createDecryptionCipher(t.encryptedContent.key);break;case O.pki.oids.desCBC:case O.pki.oids["des-EDE3-CBC"]:e=O.des.createDecryptionCipher(t.encryptedContent.key);break;default:throw new Error("Unsupported symmetric cipher, OID "+t.encryptedContent.algorithm)}if(e.start(t.encryptedContent.parameter),e.update(t.encryptedContent.content),!e.finish())throw new Error("Symmetric decryption failed.");t.content=e.output}}});var nE=R((Z4,rE)=>{var Yr=ie();Cn();De();var EC=rE.exports=Yr.hmac=Yr.hmac||{};EC.create=function(){var t=null,e=null,r=null,n=null,i={};return i.start=function(s,o){if(s!==null)if(typeof s=="string")if(s=s.toLowerCase(),s in Yr.md.algorithms)e=Yr.md.algorithms[s].create();else throw new Error('Unknown hash algorithm "'+s+'"');else e=s;if(o===null)o=t;else{if(typeof o=="string")o=Yr.util.createBuffer(o);else if(Yr.util.isArray(o)){var a=o;o=Yr.util.createBuffer();for(var c=0;c<a.length;++c)o.putByte(a[c])}var u=o.length();u>e.blockLength&&(e.start(),e.update(o.bytes()),o=e.digest()),r=Yr.util.createBuffer(),n=Yr.util.createBuffer(),u=o.length();for(var c=0;c<u;++c){var a=o.at(c);r.putByte(54^a),n.putByte(92^a)}if(u<e.blockLength)for(var a=e.blockLength-u,c=0;c<a;++c)r.putByte(54),n.putByte(92);t=o,r=r.bytes(),n=n.bytes()}e.start(),e.update(r)},i.update=function(s){e.update(s)},i.getMac=function(){var s=e.digest().bytes();return e.start(),e.update(n),e.update(s),e.digest()},i.digest=i.getMac,i}});var Mf=R((J4,iE)=>{var wt=ie();nE();Cn();De();var vC=wt.pkcs5=wt.pkcs5||{},Wr;wt.util.isNodejs&&!wt.options.usePureJavaScript&&(Wr=Jn());iE.exports=wt.pbkdf2=vC.pbkdf2=function(t,e,r,n,i,s){if(typeof i=="function"&&(s=i,i=null),wt.util.isNodejs&&!wt.options.usePureJavaScript&&Wr.pbkdf2&&(i===null||typeof i!="object")&&(Wr.pbkdf2Sync.length>4||!i||i==="sha1"))return typeof i!="string"&&(i="sha1"),t=Buffer.from(t,"binary"),e=Buffer.from(e,"binary"),s?Wr.pbkdf2Sync.length===4?Wr.pbkdf2(t,e,r,n,function(_,B){if(_)return s(_);s(null,B.toString("binary"))}):Wr.pbkdf2(t,e,r,n,i,function(_,B){if(_)return s(_);s(null,B.toString("binary"))}):Wr.pbkdf2Sync.length===4?Wr.pbkdf2Sync(t,e,r,n).toString("binary"):Wr.pbkdf2Sync(t,e,r,n,i).toString("binary");if((typeof i>"u"||i===null)&&(i="sha1"),typeof i=="string"){if(!(i in wt.md.algorithms))throw new Error("Unknown hash algorithm: "+i);i=wt.md[i].create()}var o=i.digestLength;if(n>4294967295*o){var a=new Error("Derived key is too long.");if(s)return s(a);throw a}var c=Math.ceil(n/o),u=n-(c-1)*o,l=wt.hmac.create();l.start(i,t);var f="",h,d,p;if(!s){for(var y=1;y<=c;++y){l.start(null,null),l.update(e),l.update(wt.util.int32ToBytes(y)),h=p=l.digest().getBytes();for(var g=2;g<=r;++g)l.start(null,null),l.update(p),d=l.digest().getBytes(),h=wt.util.xorBytes(h,d,o),p=d;f+=y<c?h:h.substr(0,u)}return f}var y=1,g;function E(){if(y>c)return s(null,f);l.start(null,null),l.update(e),l.update(wt.util.int32ToBytes(y)),h=p=l.digest().getBytes(),g=2,x()}function x(){if(g<=r)return l.start(null,null),l.update(p),d=l.digest().getBytes(),h=wt.util.xorBytes(h,d,o),p=d,++g,wt.util.setImmediate(x);f+=y<c?h:h.substr(0,u),++y,E()}E()}});var cE=R((e8,aE)=>{var St=ie();De();var Ff=[217,120,249,196,25,221,181,237,40,233,253,121,74,160,216,157,198,126,55,131,43,118,83,142,98,76,100,136,68,139,251,162,23,154,89,245,135,179,79,19,97,69,109,141,9,129,125,50,189,143,64,235,134,183,123,11,240,149,33,34,92,107,78,130,84,214,101,147,206,96,178,28,115,86,192,20,167,140,241,220,18,117,202,31,59,190,228,209,66,61,212,48,163,60,182,38,111,191,14,218,70,105,7,87,39,242,29,155,188,148,67,3,248,17,199,246,144,239,62,231,6,195,213,47,200,102,30,215,8,232,234,222,128,82,238,247,132,170,114,172,53,77,106,42,150,26,210,113,90,21,73,116,75,159,208,94,4,24,164,236,194,224,65,110,15,81,203,204,36,145,175,80,161,244,112,57,153,124,58,133,35,184,180,122,252,2,54,91,37,85,151,49,45,93,250,152,227,138,146,174,5,223,41,16,103,108,186,201,211,0,230,207,225,158,168,44,99,22,1,63,88,226,137,169,13,56,52,27,171,51,255,176,187,72,12,95,185,177,205,46,197,243,219,71,229,165,156,119,10,166,32,104,254,127,193,173],sE=[1,2,3,5],wC=function(t,e){return t<<e&65535|(t&65535)>>16-e},xC=function(t,e){return(t&65535)>>e|t<<16-e&65535};aE.exports=St.rc2=St.rc2||{};St.rc2.expandKey=function(t,e){typeof t=="string"&&(t=St.util.createBuffer(t)),e=e||128;var r=t,n=t.length(),i=e,s=Math.ceil(i/8),o=255>>(i&7),a;for(a=n;a<128;a++)r.putByte(Ff[r.at(a-1)+r.at(a-n)&255]);for(r.setAt(128-s,Ff[r.at(128-s)&o]),a=127-s;a>=0;a--)r.setAt(a,Ff[r.at(a+1)^r.at(a+s)]);return r};var oE=function(t,e,r){var n=!1,i=null,s=null,o=null,a,c,u,l,f=[];for(t=St.rc2.expandKey(t,e),u=0;u<64;u++)f.push(t.getInt16Le());r?(a=function(p){for(u=0;u<4;u++)p[u]+=f[l]+(p[(u+3)%4]&p[(u+2)%4])+(~p[(u+3)%4]&p[(u+1)%4]),p[u]=wC(p[u],sE[u]),l++},c=function(p){for(u=0;u<4;u++)p[u]+=f[p[(u+3)%4]&63]}):(a=function(p){for(u=3;u>=0;u--)p[u]=xC(p[u],sE[u]),p[u]-=f[l]+(p[(u+3)%4]&p[(u+2)%4])+(~p[(u+3)%4]&p[(u+1)%4]),l--},c=function(p){for(u=3;u>=0;u--)p[u]-=f[p[(u+3)%4]&63]});var h=function(p){var y=[];for(u=0;u<4;u++){var g=i.getInt16Le();o!==null&&(r?g^=o.getInt16Le():o.putInt16Le(g)),y.push(g&65535)}l=r?0:63;for(var E=0;E<p.length;E++)for(var x=0;x<p[E][0];x++)p[E][1](y);for(u=0;u<4;u++)o!==null&&(r?o.putInt16Le(y[u]):y[u]^=o.getInt16Le()),s.putInt16Le(y[u])},d=null;return d={start:function(p,y){p&&typeof p=="string"&&(p=St.util.createBuffer(p)),n=!1,i=St.util.createBuffer(),s=y||new St.util.createBuffer,o=p,d.output=s},update:function(p){for(n||i.putBuffer(p);i.length()>=8;)h([[5,a],[1,c],[6,a],[1,c],[5,a]])},finish:function(p){var y=!0;if(r)if(p)y=p(8,i,!r);else{var g=i.length()===8?8:8-i.length();i.fillWithByte(g,g)}if(y&&(n=!0,d.update()),!r&&(y=i.length()===0,y))if(p)y=p(8,s,!r);else{var E=s.length(),x=s.at(E-1);x>E?y=!1:s.truncate(x)}return y}},d};St.rc2.startEncrypting=function(t,e,r){var n=St.rc2.createEncryptionCipher(t,128);return n.start(e,r),n};St.rc2.createEncryptionCipher=function(t,e){return oE(t,e,!0)};St.rc2.startDecrypting=function(t,e,r){var n=St.rc2.createDecryptionCipher(t,128);return n.start(e,r),n};St.rc2.createDecryptionCipher=function(t,e){return oE(t,e,!1)}});var Kf=R((t8,dE)=>{var F=ie();rs();An();sc();Cn();ns();Mf();cc();ai();cE();ao();De();typeof uE>"u"&&(uE=F.jsbn.BigInteger);var uE,A=F.asn1,J=F.pki=F.pki||{};dE.exports=J.pbe=F.pbe=F.pbe||{};var hi=J.oids,bC={name:"EncryptedPrivateKeyInfo",tagClass:A.Class.UNIVERSAL,type:A.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedPrivateKeyInfo.encryptionAlgorithm",tagClass:A.Class.UNIVERSAL,type:A.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:A.Class.UNIVERSAL,type:A.Type.OID,constructed:!1,capture:"encryptionOid"},{name:"AlgorithmIdentifier.parameters",tagClass:A.Class.UNIVERSAL,type:A.Type.SEQUENCE,constructed:!0,captureAsn1:"encryptionParams"}]},{name:"EncryptedPrivateKeyInfo.encryptedData",tagClass:A.Class.UNIVERSAL,type:A.Type.OCTETSTRING,constructed:!1,capture:"encryptedData"}]},SC={name:"PBES2Algorithms",tagClass:A.Class.UNIVERSAL,type:A.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.keyDerivationFunc",tagClass:A.Class.UNIVERSAL,type:A.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.keyDerivationFunc.oid",tagClass:A.Class.UNIVERSAL,type:A.Type.OID,constructed:!1,capture:"kdfOid"},{name:"PBES2Algorithms.params",tagClass:A.Class.UNIVERSAL,type:A.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.params.salt",tagClass:A.Class.UNIVERSAL,type:A.Type.OCTETSTRING,constructed:!1,capture:"kdfSalt"},{name:"PBES2Algorithms.params.iterationCount",tagClass:A.Class.UNIVERSAL,type:A.Type.INTEGER,constructed:!1,capture:"kdfIterationCount"},{name:"PBES2Algorithms.params.keyLength",tagClass:A.Class.UNIVERSAL,type:A.Type.INTEGER,constructed:!1,optional:!0,capture:"keyLength"},{name:"PBES2Algorithms.params.prf",tagClass:A.Class.UNIVERSAL,type:A.Type.SEQUENCE,constructed:!0,optional:!0,value:[{name:"PBES2Algorithms.params.prf.algorithm",tagClass:A.Class.UNIVERSAL,type:A.Type.OID,constructed:!1,capture:"prfOid"}]}]}]},{name:"PBES2Algorithms.encryptionScheme",tagClass:A.Class.UNIVERSAL,type:A.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.encryptionScheme.oid",tagClass:A.Class.UNIVERSAL,type:A.Type.OID,constructed:!1,capture:"encOid"},{name:"PBES2Algorithms.encryptionScheme.iv",tagClass:A.Class.UNIVERSAL,type:A.Type.OCTETSTRING,constructed:!1,capture:"encIv"}]}]},_C={name:"pkcs-12PbeParams",tagClass:A.Class.UNIVERSAL,type:A.Type.SEQUENCE,constructed:!0,value:[{name:"pkcs-12PbeParams.salt",tagClass:A.Class.UNIVERSAL,type:A.Type.OCTETSTRING,constructed:!1,capture:"salt"},{name:"pkcs-12PbeParams.iterations",tagClass:A.Class.UNIVERSAL,type:A.Type.INTEGER,constructed:!1,capture:"iterations"}]};J.encryptPrivateKeyInfo=function(t,e,r){r=r||{},r.saltSize=r.saltSize||8,r.count=r.count||2048,r.algorithm=r.algorithm||"aes128",r.prfAlgorithm=r.prfAlgorithm||"sha1";var n=F.random.getBytesSync(r.saltSize),i=r.count,s=A.integerToDer(i),o,a,c;if(r.algorithm.indexOf("aes")===0||r.algorithm==="des"){var u,l,f;switch(r.algorithm){case"aes128":o=16,u=16,l=hi["aes128-CBC"],f=F.aes.createEncryptionCipher;break;case"aes192":o=24,u=16,l=hi["aes192-CBC"],f=F.aes.createEncryptionCipher;break;case"aes256":o=32,u=16,l=hi["aes256-CBC"],f=F.aes.createEncryptionCipher;break;case"des":o=8,u=8,l=hi.desCBC,f=F.des.createEncryptionCipher;break;default:var h=new Error("Cannot encrypt private key. Unknown encryption algorithm.");throw h.algorithm=r.algorithm,h}var d="hmacWith"+r.prfAlgorithm.toUpperCase(),p=hE(d),y=F.pkcs5.pbkdf2(e,n,i,o,p),g=F.random.getBytesSync(u),E=f(y);E.start(g),E.update(A.toDer(t)),E.finish(),c=E.output.getBytes();var x=AC(n,s,o,d);a=A.create(A.Class.UNIVERSAL,A.Type.SEQUENCE,!0,[A.create(A.Class.UNIVERSAL,A.Type.OID,!1,A.oidToDer(hi.pkcs5PBES2).getBytes()),A.create(A.Class.UNIVERSAL,A.Type.SEQUENCE,!0,[A.create(A.Class.UNIVERSAL,A.Type.SEQUENCE,!0,[A.create(A.Class.UNIVERSAL,A.Type.OID,!1,A.oidToDer(hi.pkcs5PBKDF2).getBytes()),x]),A.create(A.Class.UNIVERSAL,A.Type.SEQUENCE,!0,[A.create(A.Class.UNIVERSAL,A.Type.OID,!1,A.oidToDer(l).getBytes()),A.create(A.Class.UNIVERSAL,A.Type.OCTETSTRING,!1,g)])])])}else if(r.algorithm==="3des"){o=24;var _=new F.util.ByteBuffer(n),y=J.pbe.generatePkcs12Key(e,_,1,i,o),g=J.pbe.generatePkcs12Key(e,_,2,i,o),E=F.des.createEncryptionCipher(y);E.start(g),E.update(A.toDer(t)),E.finish(),c=E.output.getBytes(),a=A.create(A.Class.UNIVERSAL,A.Type.SEQUENCE,!0,[A.create(A.Class.UNIVERSAL,A.Type.OID,!1,A.oidToDer(hi["pbeWithSHAAnd3-KeyTripleDES-CBC"]).getBytes()),A.create(A.Class.UNIVERSAL,A.Type.SEQUENCE,!0,[A.create(A.Class.UNIVERSAL,A.Type.OCTETSTRING,!1,n),A.create(A.Class.UNIVERSAL,A.Type.INTEGER,!1,s.getBytes())])])}else{var h=new Error("Cannot encrypt private key. Unknown encryption algorithm.");throw h.algorithm=r.algorithm,h}var B=A.create(A.Class.UNIVERSAL,A.Type.SEQUENCE,!0,[a,A.create(A.Class.UNIVERSAL,A.Type.OCTETSTRING,!1,c)]);return B};J.decryptPrivateKeyInfo=function(t,e){var r=null,n={},i=[];if(!A.validate(t,bC,n,i)){var s=new Error("Cannot read encrypted private key. ASN.1 object is not a supported EncryptedPrivateKeyInfo.");throw s.errors=i,s}var o=A.derToOid(n.encryptionOid),a=J.pbe.getCipher(o,n.encryptionParams,e),c=F.util.createBuffer(n.encryptedData);return a.update(c),a.finish()&&(r=A.fromDer(a.output)),r};J.encryptedPrivateKeyToPem=function(t,e){var r={type:"ENCRYPTED PRIVATE KEY",body:A.toDer(t).getBytes()};return F.pem.encode(r,{maxline:e})};J.encryptedPrivateKeyFromPem=function(t){var e=F.pem.decode(t)[0];if(e.type!=="ENCRYPTED PRIVATE KEY"){var r=new Error('Could not convert encrypted private key from PEM; PEM header type is "ENCRYPTED PRIVATE KEY".');throw r.headerType=e.type,r}if(e.procType&&e.procType.type==="ENCRYPTED")throw new Error("Could not convert encrypted private key from PEM; PEM is encrypted.");return A.fromDer(e.body)};J.encryptRsaPrivateKey=function(t,e,r){if(r=r||{},!r.legacy){var n=J.wrapRsaPrivateKey(J.privateKeyToAsn1(t));return n=J.encryptPrivateKeyInfo(n,e,r),J.encryptedPrivateKeyToPem(n)}var i,s,o,a;switch(r.algorithm){case"aes128":i="AES-128-CBC",o=16,s=F.random.getBytesSync(16),a=F.aes.createEncryptionCipher;break;case"aes192":i="AES-192-CBC",o=24,s=F.random.getBytesSync(16),a=F.aes.createEncryptionCipher;break;case"aes256":i="AES-256-CBC",o=32,s=F.random.getBytesSync(16),a=F.aes.createEncryptionCipher;break;case"3des":i="DES-EDE3-CBC",o=24,s=F.random.getBytesSync(8),a=F.des.createEncryptionCipher;break;case"des":i="DES-CBC",o=8,s=F.random.getBytesSync(8),a=F.des.createEncryptionCipher;break;default:var c=new Error('Could not encrypt RSA private key; unsupported encryption algorithm "'+r.algorithm+'".');throw c.algorithm=r.algorithm,c}var u=F.pbe.opensslDeriveBytes(e,s.substr(0,8),o),l=a(u);l.start(s),l.update(A.toDer(J.privateKeyToAsn1(t))),l.finish();var f={type:"RSA PRIVATE KEY",procType:{version:"4",type:"ENCRYPTED"},dekInfo:{algorithm:i,parameters:F.util.bytesToHex(s).toUpperCase()},body:l.output.getBytes()};return F.pem.encode(f)};J.decryptRsaPrivateKey=function(t,e){var r=null,n=F.pem.decode(t)[0];if(n.type!=="ENCRYPTED PRIVATE KEY"&&n.type!=="PRIVATE KEY"&&n.type!=="RSA PRIVATE KEY"){var i=new Error('Could not convert private key from PEM; PEM header type is not "ENCRYPTED PRIVATE KEY", "PRIVATE KEY", or "RSA PRIVATE KEY".');throw i.headerType=i,i}if(n.procType&&n.procType.type==="ENCRYPTED"){var s,o;switch(n.dekInfo.algorithm){case"DES-CBC":s=8,o=F.des.createDecryptionCipher;break;case"DES-EDE3-CBC":s=24,o=F.des.createDecryptionCipher;break;case"AES-128-CBC":s=16,o=F.aes.createDecryptionCipher;break;case"AES-192-CBC":s=24,o=F.aes.createDecryptionCipher;break;case"AES-256-CBC":s=32,o=F.aes.createDecryptionCipher;break;case"RC2-40-CBC":s=5,o=function(f){return F.rc2.createDecryptionCipher(f,40)};break;case"RC2-64-CBC":s=8,o=function(f){return F.rc2.createDecryptionCipher(f,64)};break;case"RC2-128-CBC":s=16,o=function(f){return F.rc2.createDecryptionCipher(f,128)};break;default:var i=new Error('Could not decrypt private key; unsupported encryption algorithm "'+n.dekInfo.algorithm+'".');throw i.algorithm=n.dekInfo.algorithm,i}var a=F.util.hexToBytes(n.dekInfo.parameters),c=F.pbe.opensslDeriveBytes(e,a.substr(0,8),s),u=o(c);if(u.start(a),u.update(F.util.createBuffer(n.body)),u.finish())r=u.output.getBytes();else return r}else r=n.body;return n.type==="ENCRYPTED PRIVATE KEY"?r=J.decryptPrivateKeyInfo(A.fromDer(r),e):r=A.fromDer(r),r!==null&&(r=J.privateKeyFromAsn1(r)),r};J.pbe.generatePkcs12Key=function(t,e,r,n,i,s){var o,a;if(typeof s>"u"||s===null){if(!("sha1"in F.md))throw new Error('"sha1" hash algorithm unavailable.');s=F.md.sha1.create()}var c=s.digestLength,u=s.blockLength,l=new F.util.ByteBuffer,f=new F.util.ByteBuffer;if(t!=null){for(a=0;a<t.length;a++)f.putInt16(t.charCodeAt(a));f.putInt16(0)}var h=f.length(),d=e.length(),p=new F.util.ByteBuffer;p.fillWithByte(r,u);var y=u*Math.ceil(d/u),g=new F.util.ByteBuffer;for(a=0;a<y;a++)g.putByte(e.at(a%d));var E=u*Math.ceil(h/u),x=new F.util.ByteBuffer;for(a=0;a<E;a++)x.putByte(f.at(a%h));var _=g;_.putBuffer(x);for(var B=Math.ceil(i/c),D=1;D<=B;D++){var P=new F.util.ByteBuffer;P.putBytes(p.bytes()),P.putBytes(_.bytes());for(var te=0;te<n;te++)s.start(),s.update(P.getBytes()),P=s.digest();var ae=new F.util.ByteBuffer;for(a=0;a<u;a++)ae.putByte(P.at(a%c));var st=Math.ceil(d/u)+Math.ceil(h/u),jt=new F.util.ByteBuffer;for(o=0;o<st;o++){var Ct=new F.util.ByteBuffer(_.getBytes(u)),gt=511;for(a=ae.length()-1;a>=0;a--)gt=gt>>8,gt+=ae.at(a)+Ct.at(a),Ct.setAt(a,gt&255);jt.putBuffer(Ct)}_=jt,l.putBuffer(P)}return l.truncate(l.length()-i),l};J.pbe.getCipher=function(t,e,r){switch(t){case J.oids.pkcs5PBES2:return J.pbe.getCipherForPBES2(t,e,r);case J.oids["pbeWithSHAAnd3-KeyTripleDES-CBC"]:case J.oids["pbewithSHAAnd40BitRC2-CBC"]:return J.pbe.getCipherForPKCS12PBE(t,e,r);default:var n=new Error("Cannot read encrypted PBE data block. Unsupported OID.");throw n.oid=t,n.supportedOids=["pkcs5PBES2","pbeWithSHAAnd3-KeyTripleDES-CBC","pbewithSHAAnd40BitRC2-CBC"],n}};J.pbe.getCipherForPBES2=function(t,e,r){var n={},i=[];if(!A.validate(e,SC,n,i)){var s=new Error("Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.");throw s.errors=i,s}if(t=A.derToOid(n.kdfOid),t!==J.oids.pkcs5PBKDF2){var s=new Error("Cannot read encrypted private key. Unsupported key derivation function OID.");throw s.oid=t,s.supportedOids=["pkcs5PBKDF2"],s}if(t=A.derToOid(n.encOid),t!==J.oids["aes128-CBC"]&&t!==J.oids["aes192-CBC"]&&t!==J.oids["aes256-CBC"]&&t!==J.oids["des-EDE3-CBC"]&&t!==J.oids.desCBC){var s=new Error("Cannot read encrypted private key. Unsupported encryption scheme OID.");throw s.oid=t,s.supportedOids=["aes128-CBC","aes192-CBC","aes256-CBC","des-EDE3-CBC","desCBC"],s}var o=n.kdfSalt,a=F.util.createBuffer(n.kdfIterationCount);a=a.getInt(a.length()<<3);var c,u;switch(J.oids[t]){case"aes128-CBC":c=16,u=F.aes.createDecryptionCipher;break;case"aes192-CBC":c=24,u=F.aes.createDecryptionCipher;break;case"aes256-CBC":c=32,u=F.aes.createDecryptionCipher;break;case"des-EDE3-CBC":c=24,u=F.des.createDecryptionCipher;break;case"desCBC":c=8,u=F.des.createDecryptionCipher;break}var l=fE(n.prfOid),f=F.pkcs5.pbkdf2(r,o,a,c,l),h=n.encIv,d=u(f);return d.start(h),d};J.pbe.getCipherForPKCS12PBE=function(t,e,r){var n={},i=[];if(!A.validate(e,_C,n,i)){var s=new Error("Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.");throw s.errors=i,s}var o=F.util.createBuffer(n.salt),a=F.util.createBuffer(n.iterations);a=a.getInt(a.length()<<3);var c,u,l;switch(t){case J.oids["pbeWithSHAAnd3-KeyTripleDES-CBC"]:c=24,u=8,l=F.des.startDecrypting;break;case J.oids["pbewithSHAAnd40BitRC2-CBC"]:c=5,u=8,l=function(y,g){var E=F.rc2.createDecryptionCipher(y,40);return E.start(g,null),E};break;default:var s=new Error("Cannot read PKCS #12 PBE data block. Unsupported OID.");throw s.oid=t,s}var f=fE(n.prfOid),h=J.pbe.generatePkcs12Key(r,o,1,a,c,f);f.start();var d=J.pbe.generatePkcs12Key(r,o,2,a,u,f);return l(h,d)};J.pbe.opensslDeriveBytes=function(t,e,r,n){if(typeof n>"u"||n===null){if(!("md5"in F.md))throw new Error('"md5" hash algorithm unavailable.');n=F.md.md5.create()}e===null&&(e="");for(var i=[lE(n,t+e)],s=16,o=1;s<r;++o,s+=16)i.push(lE(n,i[o-1]+t+e));return i.join("").substr(0,r)};function lE(t,e){return t.start().update(e).digest().getBytes()}function fE(t){var e;if(!t)e="hmacWithSHA1";else if(e=J.oids[A.derToOid(t)],!e){var r=new Error("Unsupported PRF OID.");throw r.oid=t,r.supported=["hmacWithSHA1","hmacWithSHA224","hmacWithSHA256","hmacWithSHA384","hmacWithSHA512"],r}return hE(e)}function hE(t){var e=F.md;switch(t){case"hmacWithSHA224":e=F.md.sha512;case"hmacWithSHA1":case"hmacWithSHA256":case"hmacWithSHA384":case"hmacWithSHA512":t=t.substr(8).toLowerCase();break;default:var r=new Error("Unsupported PRF algorithm.");throw r.algorithm=t,r.supported=["hmacWithSHA1","hmacWithSHA224","hmacWithSHA256","hmacWithSHA384","hmacWithSHA512"],r}if(!e||!(t in e))throw new Error("Unknown hash algorithm: "+t);return e[t].create()}function AC(t,e,r,n){var i=A.create(A.Class.UNIVERSAL,A.Type.SEQUENCE,!0,[A.create(A.Class.UNIVERSAL,A.Type.OCTETSTRING,!1,t),A.create(A.Class.UNIVERSAL,A.Type.INTEGER,!1,e.getBytes())]);return n!=="hmacWithSHA1"&&i.value.push(A.create(A.Class.UNIVERSAL,A.Type.INTEGER,!1,F.util.hexToBytes(r.toString(16))),A.create(A.Class.UNIVERSAL,A.Type.SEQUENCE,!0,[A.create(A.Class.UNIVERSAL,A.Type.OID,!1,A.oidToDer(J.oids[n]).getBytes()),A.create(A.Class.UNIVERSAL,A.Type.NULL,!1,"")])),i}});var IE=R((H8,CE)=>{var Oe=ie();Cn();De();var co=CE.exports=Oe.sha512=Oe.sha512||{};Oe.md.sha512=Oe.md.algorithms.sha512=co;var _E=Oe.sha384=Oe.sha512.sha384=Oe.sha512.sha384||{};_E.create=function(){return co.create("SHA-384")};Oe.md.sha384=Oe.md.algorithms.sha384=_E;Oe.sha512.sha256=Oe.sha512.sha256||{create:function(){return co.create("SHA-512/256")}};Oe.md["sha512/256"]=Oe.md.algorithms["sha512/256"]=Oe.sha512.sha256;Oe.sha512.sha224=Oe.sha512.sha224||{create:function(){return co.create("SHA-512/224")}};Oe.md["sha512/224"]=Oe.md.algorithms["sha512/224"]=Oe.sha512.sha224;co.create=function(t){if(AE||DC(),typeof t>"u"&&(t="SHA-512"),!(t in di))throw new Error("Invalid SHA-512 algorithm: "+t);for(var e=di[t],r=null,n=Oe.util.createBuffer(),i=new Array(80),s=0;s<80;++s)i[s]=new Array(2);var o=64;switch(t){case"SHA-384":o=48;break;case"SHA-512/256":o=32;break;case"SHA-512/224":o=28;break}var a={algorithm:t.replace("-","").toLowerCase(),blockLength:128,digestLength:o,messageLength:0,fullMessageLength:null,messageLengthSize:16};return a.start=function(){a.messageLength=0,a.fullMessageLength=a.messageLength128=[];for(var c=a.messageLengthSize/4,u=0;u<c;++u)a.fullMessageLength.push(0);n=Oe.util.createBuffer(),r=new Array(e.length);for(var u=0;u<e.length;++u)r[u]=e[u].slice(0);return a},a.start(),a.update=function(c,u){u==="utf8"&&(c=Oe.util.encodeUtf8(c));var l=c.length;a.messageLength+=l,l=[l/4294967296>>>0,l>>>0];for(var f=a.fullMessageLength.length-1;f>=0;--f)a.fullMessageLength[f]+=l[1],l[1]=l[0]+(a.fullMessageLength[f]/4294967296>>>0),a.fullMessageLength[f]=a.fullMessageLength[f]>>>0,l[0]=l[1]/4294967296>>>0;return n.putBytes(c),SE(r,i,n),(n.read>2048||n.length()===0)&&n.compact(),a},a.digest=function(){var c=Oe.util.createBuffer();c.putBytes(n.bytes());var u=a.fullMessageLength[a.fullMessageLength.length-1]+a.messageLengthSize,l=u&a.blockLength-1;c.putBytes(Hf.substr(0,a.blockLength-l));for(var f,h,d=a.fullMessageLength[0]*8,p=0;p<a.fullMessageLength.length-1;++p)f=a.fullMessageLength[p+1]*8,h=f/4294967296>>>0,d+=h,c.putInt32(d>>>0),d=f>>>0;c.putInt32(d);for(var y=new Array(r.length),p=0;p<r.length;++p)y[p]=r[p].slice(0);SE(y,i,c);var g=Oe.util.createBuffer(),E;t==="SHA-512"?E=y.length:t==="SHA-384"?E=y.length-2:E=y.length-4;for(var p=0;p<E;++p)g.putInt32(y[p][0]),(p!==E-1||t!=="SHA-512/224")&&g.putInt32(y[p][1]);return g},a};var Hf=null,AE=!1,zf=null,di=null;function DC(){Hf=String.fromCharCode(128),Hf+=Oe.util.fillString(String.fromCharCode(0),128),zf=[[1116352408,3609767458],[1899447441,602891725],[3049323471,3964484399],[3921009573,2173295548],[961987163,4081628472],[1508970993,3053834265],[2453635748,2937671579],[2870763221,3664609560],[3624381080,2734883394],[310598401,1164996542],[607225278,1323610764],[1426881987,3590304994],[1925078388,4068182383],[2162078206,991336113],[2614888103,633803317],[3248222580,3479774868],[3835390401,2666613458],[4022224774,944711139],[264347078,2341262773],[604807628,2007800933],[770255983,1495990901],[1249150122,1856431235],[1555081692,3175218132],[1996064986,2198950837],[2554220882,3999719339],[2821834349,766784016],[2952996808,2566594879],[3210313671,3203337956],[3336571891,1034457026],[3584528711,2466948901],[113926993,3758326383],[338241895,168717936],[666307205,1188179964],[773529912,1546045734],[1294757372,1522805485],[1396182291,2643833823],[1695183700,2343527390],[1986661051,1014477480],[2177026350,1206759142],[2456956037,344077627],[2730485921,1290863460],[2820302411,3158454273],[3259730800,3505952657],[3345764771,106217008],[3516065817,3606008344],[3600352804,1432725776],[4094571909,1467031594],[275423344,851169720],[430227734,3100823752],[506948616,1363258195],[659060556,3750685593],[883997877,3785050280],[958139571,3318307427],[1322822218,3812723403],[1537002063,2003034995],[1747873779,3602036899],[1955562222,1575990012],[2024104815,1125592928],[2227730452,2716904306],[2361852424,442776044],[2428436474,593698344],[2756734187,3733110249],[3204031479,2999351573],[3329325298,3815920427],[3391569614,3928383900],[3515267271,566280711],[3940187606,3454069534],[4118630271,4000239992],[116418474,1914138554],[174292421,2731055270],[289380356,3203993006],[460393269,320620315],[685471733,587496836],[852142971,1086792851],[1017036298,365543100],[1126000580,2618297676],[1288033470,3409855158],[1501505948,4234509866],[1607167915,987167468],[1816402316,1246189591]],di={},di["SHA-512"]=[[1779033703,4089235720],[3144134277,2227873595],[1013904242,4271175723],[2773480762,1595750129],[1359893119,2917565137],[2600822924,725511199],[528734635,4215389547],[1541459225,327033209]],di["SHA-384"]=[[3418070365,3238371032],[1654270250,914150663],[2438529370,812702999],[355462360,4144912697],[1731405415,4290775857],[2394180231,1750603025],[3675008525,1694076839],[1203062813,3204075428]],di["SHA-512/256"]=[[573645204,4230739756],[2673172387,3360449730],[596883563,1867755857],[2520282905,1497426621],[2519219938,2827943907],[3193839141,1401305490],[721525244,746961066],[246885852,2177182882]],di["SHA-512/224"]=[[2352822216,424955298],[1944164710,2312950998],[502970286,855612546],[1738396948,1479516111],[258812777,2077511080],[2011393907,79989058],[1067287976,1780299464],[286451373,2446758561]],AE=!0}function SE(t,e,r){for(var n,i,s,o,a,c,u,l,f,h,d,p,y,g,E,x,_,B,D,P,te,ae,st,jt,Ct,gt,Ci,jo,Je,bt,Y,Su,_u,Au,Cu,yd=r.length();yd>=128;){for(Je=0;Je<16;++Je)e[Je][0]=r.getInt32()>>>0,e[Je][1]=r.getInt32()>>>0;for(;Je<80;++Je)Su=e[Je-2],bt=Su[0],Y=Su[1],n=((bt>>>19|Y<<13)^(Y>>>29|bt<<3)^bt>>>6)>>>0,i=((bt<<13|Y>>>19)^(Y<<3|bt>>>29)^(bt<<26|Y>>>6))>>>0,Au=e[Je-15],bt=Au[0],Y=Au[1],s=((bt>>>1|Y<<31)^(bt>>>8|Y<<24)^bt>>>7)>>>0,o=((bt<<31|Y>>>1)^(bt<<24|Y>>>8)^(bt<<25|Y>>>7))>>>0,_u=e[Je-7],Cu=e[Je-16],Y=i+_u[1]+o+Cu[1],e[Je][0]=n+_u[0]+s+Cu[0]+(Y/4294967296>>>0)>>>0,e[Je][1]=Y>>>0;for(y=t[0][0],g=t[0][1],E=t[1][0],x=t[1][1],_=t[2][0],B=t[2][1],D=t[3][0],P=t[3][1],te=t[4][0],ae=t[4][1],st=t[5][0],jt=t[5][1],Ct=t[6][0],gt=t[6][1],Ci=t[7][0],jo=t[7][1],Je=0;Je<80;++Je)u=((te>>>14|ae<<18)^(te>>>18|ae<<14)^(ae>>>9|te<<23))>>>0,l=((te<<18|ae>>>14)^(te<<14|ae>>>18)^(ae<<23|te>>>9))>>>0,f=(Ct^te&(st^Ct))>>>0,h=(gt^ae&(jt^gt))>>>0,a=((y>>>28|g<<4)^(g>>>2|y<<30)^(g>>>7|y<<25))>>>0,c=((y<<4|g>>>28)^(g<<30|y>>>2)^(g<<25|y>>>7))>>>0,d=(y&E|_&(y^E))>>>0,p=(g&x|B&(g^x))>>>0,Y=jo+l+h+zf[Je][1]+e[Je][1],n=Ci+u+f+zf[Je][0]+e[Je][0]+(Y/4294967296>>>0)>>>0,i=Y>>>0,Y=c+p,s=a+d+(Y/4294967296>>>0)>>>0,o=Y>>>0,Ci=Ct,jo=gt,Ct=st,gt=jt,st=te,jt=ae,Y=P+i,te=D+n+(Y/4294967296>>>0)>>>0,ae=Y>>>0,D=_,P=B,_=E,B=x,E=y,x=g,Y=i+o,y=n+s+(Y/4294967296>>>0)>>>0,g=Y>>>0;Y=t[0][1]+g,t[0][0]=t[0][0]+y+(Y/4294967296>>>0)>>>0,t[0][1]=Y>>>0,Y=t[1][1]+x,t[1][0]=t[1][0]+E+(Y/4294967296>>>0)>>>0,t[1][1]=Y>>>0,Y=t[2][1]+B,t[2][0]=t[2][0]+_+(Y/4294967296>>>0)>>>0,t[2][1]=Y>>>0,Y=t[3][1]+P,t[3][0]=t[3][0]+D+(Y/4294967296>>>0)>>>0,t[3][1]=Y>>>0,Y=t[4][1]+ae,t[4][0]=t[4][0]+te+(Y/4294967296>>>0)>>>0,t[4][1]=Y>>>0,Y=t[5][1]+jt,t[5][0]=t[5][0]+st+(Y/4294967296>>>0)>>>0,t[5][1]=Y>>>0,Y=t[6][1]+gt,t[6][0]=t[6][0]+Ct+(Y/4294967296>>>0)>>>0,t[6][1]=Y>>>0,Y=t[7][1]+jo,t[7][0]=t[7][0]+Ci+(Y/4294967296>>>0)>>>0,t[7][1]=Y>>>0,yd-=128}}});var ow=R((w6,sw)=>{function zI(){return!!(typeof window<"u"&&typeof window.process=="object"&&window.process.type==="renderer"||typeof process<"u"&&typeof process.versions=="object"&&process.versions.electron||typeof navigator=="object"&&typeof navigator.userAgent=="string"&&navigator.userAgent.indexOf("Electron")>=0)}sw.exports=zI});var ww=R((v5,kh)=>{"use strict";var WI=Object.prototype.hasOwnProperty,xt="~";function Vo(){}Object.create&&(Vo.prototype=Object.create(null),new Vo().__proto__||(xt=!1));function QI(t,e,r){this.fn=t,this.context=e,this.once=r||!1}function vw(t,e,r,n,i){if(typeof r!="function")throw new TypeError("The listener must be a function");var s=new QI(r,n||t,i),o=xt?xt+e:e;return t._events[o]?t._events[o].fn?t._events[o]=[t._events[o],s]:t._events[o].push(s):(t._events[o]=s,t._eventsCount++),t}function iu(t,e){--t._eventsCount===0?t._events=new Vo:delete t._events[e]}function yt(){this._events=new Vo,this._eventsCount=0}yt.prototype.eventNames=function(){var e=[],r,n;if(this._eventsCount===0)return e;for(n in r=this._events)WI.call(r,n)&&e.push(xt?n.slice(1):n);return Object.getOwnPropertySymbols?e.concat(Object.getOwnPropertySymbols(r)):e};yt.prototype.listeners=function(e){var r=xt?xt+e:e,n=this._events[r];if(!n)return[];if(n.fn)return[n.fn];for(var i=0,s=n.length,o=new Array(s);i<s;i++)o[i]=n[i].fn;return o};yt.prototype.listenerCount=function(e){var r=xt?xt+e:e,n=this._events[r];return n?n.fn?1:n.length:0};yt.prototype.emit=function(e,r,n,i,s,o){var a=xt?xt+e:e;if(!this._events[a])return!1;var c=this._events[a],u=arguments.length,l,f;if(c.fn){switch(c.once&&this.removeListener(e,c.fn,void 0,!0),u){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,r),!0;case 3:return c.fn.call(c.context,r,n),!0;case 4:return c.fn.call(c.context,r,n,i),!0;case 5:return c.fn.call(c.context,r,n,i,s),!0;case 6:return c.fn.call(c.context,r,n,i,s,o),!0}for(f=1,l=new Array(u-1);f<u;f++)l[f-1]=arguments[f];c.fn.apply(c.context,l)}else{var h=c.length,d;for(f=0;f<h;f++)switch(c[f].once&&this.removeListener(e,c[f].fn,void 0,!0),u){case 1:c[f].fn.call(c[f].context);break;case 2:c[f].fn.call(c[f].context,r);break;case 3:c[f].fn.call(c[f].context,r,n);break;case 4:c[f].fn.call(c[f].context,r,n,i);break;default:if(!l)for(d=1,l=new Array(u-1);d<u;d++)l[d-1]=arguments[d];c[f].fn.apply(c[f].context,l)}}return!0};yt.prototype.on=function(e,r,n){return vw(this,e,r,n,!1)};yt.prototype.once=function(e,r,n){return vw(this,e,r,n,!0)};yt.prototype.removeListener=function(e,r,n,i){var s=xt?xt+e:e;if(!this._events[s])return this;if(!r)return iu(this,s),this;var o=this._events[s];if(o.fn)o.fn===r&&(!i||o.once)&&(!n||o.context===n)&&iu(this,s);else{for(var a=0,c=[],u=o.length;a<u;a++)(o[a].fn!==r||i&&!o[a].once||n&&o[a].context!==n)&&c.push(o[a]);c.length?this._events[s]=c.length===1?c[0]:c:iu(this,s)}return this};yt.prototype.removeAllListeners=function(e){var r;return e?(r=xt?xt+e:e,this._events[r]&&iu(this,r)):(this._events=new Vo,this._eventsCount=0),this};yt.prototype.off=yt.prototype.removeListener;yt.prototype.addListener=yt.prototype.on;yt.prefixed=xt;yt.EventEmitter=yt;typeof kh<"u"&&(kh.exports=yt)});var Kw=R((uU,Fw)=>{"use strict";Fw.exports=Mw;var eT=Iu(),Kn=Mw.prototype,tT=new Date%1e9;function rT(){return(Math.random()*1e9>>>0)+tT++}function Mw(t){t=t||{},this.id=t.id||rT(),this.max=t.max||1/0,this.items=t.items||[],this._lookup={},this.size=this.items.length,this.lastModified=new Date(t.lastModified||new Date);for(var e,r,n=this.items.length;n--;)e=this.items[n],r=new Date(e.expires)-new Date,this._lookup[e.key]=e,r>0?this.expire(e.key,r):r<=0&&this.delete(e.key)}Kn.has=function(t){return t in this._lookup};Kn.get=function(t){if(!this.has(t))return null;var e=this._lookup[t];return e.refresh&&this.expire(t,e.refresh),this.items.splice(this.items.indexOf(e),1),this.items.push(e),e.value};Kn.meta=function(t){if(!this.has(t))return null;var e=this._lookup[t];return"meta"in e?e.meta:null};Kn.set=function(t,e,r){var n=this._lookup[t],i=this._lookup[t]={key:t,value:e};return this.lastModified=new Date,n?(clearTimeout(n.timeout),this.items.splice(this.items.indexOf(n),1,i)):(this.size>=this.max&&this.delete(this.items[0].key),this.items.push(i),this.size++),r&&("ttl"in r&&this.expire(t,r.ttl),"meta"in r&&(i.meta=r.meta),r.refresh&&(i.refresh=r.ttl)),this};Kn.delete=function(t){var e=this._lookup[t];return e?(this.lastModified=new Date,this.items.splice(this.items.indexOf(e),1),clearTimeout(e.timeout),delete this._lookup[t],this.size--,this):!1};Kn.expire=function(t,e){var r=e||0,n=this._lookup[t];if(!n)return this;if(typeof r=="string"&&(r=eT(e)),typeof r!="number")throw new TypeError("Expiration time must be a string or number.");return clearTimeout(n.timeout),n.timeout=setTimeout(this.delete.bind(this,n.key),r),n.expires=Number(new Date)+r,this};Kn.clear=function(){for(var t=this.items.length;t--;)this.delete(this.items[t].key);return this};Kn.toJSON=function(){for(var t=new Array(this.items.length),e,r=t.length;r--;)e=this.items[r],t[r]={key:e.key,meta:e.meta,value:e.value,expires:e.expires,refresh:e.refresh};return{id:this.id,max:isFinite(this.max)?this.max:void 0,lastModified:this.lastModified,items:t}}});var hd=R((HU,fd)=>{function Xw(t){let e=new globalThis.AbortController;function r(){e.abort();for(let n of t)!n||!n.removeEventListener||n.removeEventListener("abort",r)}for(let n of t)if(!(!n||!n.addEventListener)){if(n.aborted){r();break}n.addEventListener("abort",r)}return e.signal}fd.exports=Xw;fd.exports.anySignal=Xw});var Zw=R(($U,jw)=>{jw.exports=class{constructor(e){if(!(e>0)||e-1&e)throw new Error("Max size for a FixedFIFO should be a power of two");this.buffer=new Array(e),this.mask=e-1,this.top=0,this.btm=0,this.next=null}push(e){return this.buffer[this.top]!==void 0?!1:(this.buffer[this.top]=e,this.top=this.top+1&this.mask,!0)}shift(){let e=this.buffer[this.btm];if(e!==void 0)return this.buffer[this.btm]=void 0,this.btm=this.btm+1&this.mask,e}peek(){return this.buffer[this.btm]}isEmpty(){return this.buffer[this.btm]===void 0}}});var t1=R((YU,e1)=>{var Jw=Zw();e1.exports=class{constructor(e){this.hwm=e||16,this.head=new Jw(this.hwm),this.tail=this.head}push(e){if(!this.head.push(e)){let r=this.head;this.head=r.next=new Jw(2*this.head.buffer.length),this.head.push(e)}}shift(){let e=this.tail.shift();if(e===void 0&&this.tail.next){let r=this.tail.next;return this.tail.next=null,this.tail=r,this.tail.shift()}return e}peek(){return this.tail.peek()}isEmpty(){return this.head.isEmpty()}}});var n1=R((WU,r1)=>{"use strict";var fT=()=>{let t={};return t.promise=new Promise((e,r)=>{t.resolve=e,t.reject=r}),t};r1.exports=fT});var a1=R((XU,o1)=>{var i1=t1(),s1=n1();o1.exports=class{constructor(){this._buffer=new i1,this._waitingConsumers=new i1}push(e){let{promise:r,resolve:n}=s1();return this._buffer.push({chunk:e,resolve:n}),this._consume(),r}_consume(){for(;!this._waitingConsumers.isEmpty()&&!this._buffer.isEmpty();){let e=this._waitingConsumers.shift(),r=this._buffer.shift();e.resolve(r.chunk),r.resolve()}}shift(){let{promise:e,resolve:r}=s1();return this._waitingConsumers.push({resolve:r}),this._consume(),e}isEmpty(){return this._buffer.isEmpty()}}});var mT={};pt(mT,{createLibp2p:()=>pT});var ur=C(Tu(),1);var Pu={};pt(Pu,{base58btc:()=>We,base58flickr:()=>M1});function P1(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 i=0;i<t.length;i++){var s=t.charAt(i),o=s.charCodeAt(0);if(r[o]!==255)throw new TypeError(s+" is ambiguous");r[o]=i}var a=t.length,c=t.charAt(0),u=Math.log(a)/Math.log(256),l=Math.log(256)/Math.log(a);function f(p){if(p instanceof Uint8Array||(ArrayBuffer.isView(p)?p=new Uint8Array(p.buffer,p.byteOffset,p.byteLength):Array.isArray(p)&&(p=Uint8Array.from(p))),!(p instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(p.length===0)return"";for(var y=0,g=0,E=0,x=p.length;E!==x&&p[E]===0;)E++,y++;for(var _=(x-E)*l+1>>>0,B=new Uint8Array(_);E!==x;){for(var D=p[E],P=0,te=_-1;(D!==0||P<g)&&te!==-1;te--,P++)D+=256*B[te]>>>0,B[te]=D%a>>>0,D=D/a>>>0;if(D!==0)throw new Error("Non-zero carry");g=P,E++}for(var ae=_-g;ae!==_&&B[ae]===0;)ae++;for(var st=c.repeat(y);ae<_;++ae)st+=t.charAt(B[ae]);return st}function h(p){if(typeof p!="string")throw new TypeError("Expected String");if(p.length===0)return new Uint8Array;var y=0;if(p[y]!==" "){for(var g=0,E=0;p[y]===c;)g++,y++;for(var x=(p.length-y)*u+1>>>0,_=new Uint8Array(x);p[y];){var B=r[p.charCodeAt(y)];if(B===255)return;for(var D=0,P=x-1;(B!==0||D<E)&&P!==-1;P--,D++)B+=a*_[P]>>>0,_[P]=B%256>>>0,B=B/256>>>0;if(B!==0)throw new Error("Non-zero carry");E=D,y++}if(p[y]!==" "){for(var te=x-E;te!==x&&_[te]===0;)te++;for(var ae=new Uint8Array(g+(x-te)),st=g;te!==x;)ae[st++]=_[te++];return ae}}}function d(p){var y=h(p);if(y)return y;throw new Error(`Non-${e} character`)}return{encode:f,decodeUnsafe:h,decode:d}}var B1=P1,O1=B1,xd=O1;var wT=new Uint8Array(0);var bd=(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},Nr=t=>{if(t instanceof Uint8Array&&t.constructor.name==="Uint8Array")return t;if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);throw new Error("Unknown type, must be binary type")};var Sd=t=>new TextEncoder().encode(t),_d=t=>new TextDecoder().decode(t);var Ru=class{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")}},Nu=class{constructor(e,r,n){if(this.name=e,this.prefix=r,r.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=r.codePointAt(0),this.baseDecode=n}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return Cd(this,e)}},Du=class{constructor(e){this.decoders=e}or(e){return Cd(this,e)}decode(e){let r=e[0],n=this.decoders[r];if(n)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},Cd=(t,e)=>new Du({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}}),Lu=class{constructor(e,r,n,i){this.name=e,this.prefix=r,this.baseEncode=n,this.baseDecode=i,this.encoder=new Ru(e,r,n),this.decoder=new Nu(e,r,i)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}},Ni=({name:t,prefix:e,encode:r,decode:n})=>new Lu(t,e,r,n),ln=({prefix:t,name:e,alphabet:r})=>{let{encode:n,decode:i}=xd(r,e);return Ni({prefix:t,name:e,encode:n,decode:s=>Nr(i(s))})},k1=(t,e,r,n)=>{let i={};for(let l=0;l<e.length;++l)i[e[l]]=l;let s=t.length;for(;t[s-1]==="=";)--s;let o=new Uint8Array(s*r/8|0),a=0,c=0,u=0;for(let l=0;l<s;++l){let f=i[t[l]];if(f===void 0)throw new SyntaxError(`Non-${n} character`);c=c<<r|f,a+=r,a>=8&&(a-=8,o[u++]=255&c>>a)}if(a>=r||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return o},U1=(t,e,r)=>{let n=e[e.length-1]==="=",i=(1<<r)-1,s="",o=0,a=0;for(let c=0;c<t.length;++c)for(a=a<<8|t[c],o+=8;o>r;)o-=r,s+=e[i&a>>o];if(o&&(s+=e[i&a<<r-o]),n)for(;s.length*r&7;)s+="=";return s},ze=({name:t,prefix:e,bitsPerChar:r,alphabet:n})=>Ni({prefix:e,name:t,encode(i){return U1(i,n,r)},decode(i){return k1(i,n,r,t)}});var We=ln({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),M1=ln({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Bu={};pt(Bu,{base32:()=>Tt,base32hex:()=>q1,base32hexpad:()=>z1,base32hexpadupper:()=>$1,base32hexupper:()=>H1,base32pad:()=>K1,base32padupper:()=>V1,base32upper:()=>F1,base32z:()=>G1});var Tt=ze({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),F1=ze({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),K1=ze({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),V1=ze({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),q1=ze({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),H1=ze({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),z1=ze({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),$1=ze({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),G1=ze({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Ou={};pt(Ou,{base64:()=>qn,base64pad:()=>Y1,base64url:()=>W1,base64urlpad:()=>Q1});var qn=ze({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Y1=ze({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),W1=ze({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Q1=ze({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});ur.default.formatters.b=t=>t==null?"undefined":We.baseEncode(t);ur.default.formatters.t=t=>t==null?"undefined":Tt.baseEncode(t);ur.default.formatters.m=t=>t==null?"undefined":qn.baseEncode(t);ur.default.formatters.p=t=>t==null?"undefined":t.toString();ur.default.formatters.c=t=>t==null?"undefined":t.toString();ur.default.formatters.k=t=>t==null?"undefined":t.toString();function M(t){return Object.assign((0,ur.default)(t),{error:(0,ur.default)(`${t}:error`),trace:(0,ur.default)(`${t}:trace`)})}var Hn=function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},Dr,Ue=class extends EventTarget{constructor(){super(...arguments),Dr.set(this,new Map)}listenerCount(e){let r=Hn(this,Dr,"f").get(e);return r==null?0:r.length}addEventListener(e,r,n){super.addEventListener(e,r,n);let i=Hn(this,Dr,"f").get(e);i==null&&(i=[],Hn(this,Dr,"f").set(e,i)),i.push({callback:r,once:(n!==!0&&n!==!1&&n?.once)??!1})}removeEventListener(e,r,n){super.removeEventListener(e.toString(),r??null,n);let i=Hn(this,Dr,"f").get(e);i!=null&&(i=i.filter(({callback:s})=>s!==r),Hn(this,Dr,"f").set(e,i))}dispatchEvent(e){let r=super.dispatchEvent(e),n=Hn(this,Dr,"f").get(e.type);return n==null||(n=n.filter(({once:i})=>!i),Hn(this,Dr,"f").set(e.type,n)),r}};Dr=new WeakMap;var ku=class extends Event{constructor(e,r){super(e,r),this.detail=r?.detail}},X=globalThis.CustomEvent??ku;function Lr(t){return t!=null&&typeof t.start=="function"&&typeof t.stop=="function"}var Rd=C(Td(),1),Uu=(t,e)=>async function*(){yield*(await(0,Rd.default)(t)).sort(e)}();var Mu=C(Dd(),1),zn=C(Pd(),1),Fu=C(Od(),1),ta=class{open(){return Promise.reject(new Error(".open is not implemented"))}close(){return Promise.reject(new Error(".close is not implemented"))}put(e,r,n){return Promise.reject(new Error(".put is not implemented"))}get(e,r){return Promise.reject(new Error(".get is not implemented"))}has(e,r){return Promise.reject(new Error(".has is not implemented"))}delete(e,r){return Promise.reject(new Error(".delete is not implemented"))}async*putMany(e,r={}){for await(let{key:n,value:i}of e)await this.put(n,i,r),yield{key:n,value:i}}async*getMany(e,r={}){for await(let n of e)yield this.get(n,r)}async*deleteMany(e,r={}){for await(let n of e)await this.delete(n,r),yield n}batch(){let e=[],r=[];return{put(n,i){e.push({key:n,value:i})},delete(n){r.push(n)},commit:async n=>{await(0,Mu.default)(this.putMany(e,n)),e=[],await(0,Mu.default)(this.deleteMany(r,n)),r=[]}}}async*_all(e,r){throw new Error("._all is not implemented")}async*_allKeys(e,r){throw new Error("._allKeys is not implemented")}query(e,r){let n=this._all(e,r);if(e.prefix!=null&&(n=(0,zn.default)(n,i=>i.key.toString().startsWith(e.prefix))),Array.isArray(e.filters)&&(n=e.filters.reduce((i,s)=>(0,zn.default)(i,s),n)),Array.isArray(e.orders)&&(n=e.orders.reduce((i,s)=>Uu(i,s),n)),e.offset!=null){let i=0;n=(0,zn.default)(n,()=>i++>=e.offset)}return e.limit!=null&&(n=(0,Fu.default)(n,e.limit)),n}queryKeys(e,r){let n=this._allKeys(e,r);if(e.prefix!=null&&(n=(0,zn.default)(n,i=>i.toString().startsWith(e.prefix))),Array.isArray(e.filters)&&(n=e.filters.reduce((i,s)=>(0,zn.default)(i,s),n)),Array.isArray(e.orders)&&(n=e.orders.reduce((i,s)=>Uu(i,s),n)),e.offset!=null){let i=0;n=(0,zn.default)(n,()=>i++>=e.offset)}return e.limit!=null&&(n=(0,Fu.default)(n,e.limit)),n}};var ra=(t=21)=>crypto.getRandomValues(new Uint8Array(t)).reduce((e,r)=>(r&=63,r<36?e+=r.toString(36):r<62?e+=(r-26).toString(36).toUpperCase():r>62?e+="-":e+="_",e),"");var Ku={};pt(Ku,{identity:()=>ex});var ex=Ni({prefix:"\0",name:"identity",encode:t=>_d(t),decode:t=>Sd(t)});var Vu={};pt(Vu,{base2:()=>tx});var tx=ze({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var qu={};pt(qu,{base8:()=>rx});var rx=ze({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Hu={};pt(Hu,{base10:()=>nx});var nx=ln({prefix:"9",name:"base10",alphabet:"0123456789"});var zu={};pt(zu,{base16:()=>ix,base16upper:()=>sx});var ix=ze({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),sx=ze({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var $u={};pt($u,{base36:()=>ox,base36upper:()=>ax});var ox=ln({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),ax=ln({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Gu={};pt(Gu,{base256emoji:()=>hx});var kd=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}"),cx=kd.reduce((t,e,r)=>(t[r]=e,t),[]),ux=kd.reduce((t,e,r)=>(t[e.codePointAt(0)]=r,t),[]);function lx(t){return t.reduce((e,r)=>(e+=cx[r],e),"")}function fx(t){let e=[];for(let r of t){let n=ux[r.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${r}`);e.push(n)}return new Uint8Array(e)}var hx=Ni({prefix:"\u{1F680}",name:"base256emoji",encode:lx,decode:fx});var Xu={};pt(Xu,{sha256:()=>ot,sha512:()=>Dx});var dx=Fd,Ud=128,px=127,mx=~px,yx=Math.pow(2,31);function Fd(t,e,r){e=e||[],r=r||0;for(var n=r;t>=yx;)e[r++]=t&255|Ud,t/=128;for(;t&mx;)e[r++]=t&255|Ud,t>>>=7;return e[r]=t|0,Fd.bytes=r-n+1,e}var gx=Yu,Ex=128,Md=127;function Yu(t,n){var r=0,n=n||0,i=0,s=n,o,a=t.length;do{if(s>=a)throw Yu.bytes=0,new RangeError("Could not decode varint");o=t[s++],r+=i<28?(o&Md)<<i:(o&Md)*Math.pow(2,i),i+=7}while(o>=Ex);return Yu.bytes=s-n,r}var vx=Math.pow(2,7),wx=Math.pow(2,14),xx=Math.pow(2,21),bx=Math.pow(2,28),Sx=Math.pow(2,35),_x=Math.pow(2,42),Ax=Math.pow(2,49),Cx=Math.pow(2,56),Ix=Math.pow(2,63),Tx=function(t){return t<vx?1:t<wx?2:t<xx?3:t<bx?4:t<Sx?5:t<_x?6:t<Ax?7:t<Cx?8:t<Ix?9:10},Rx={encode:dx,decode:gx,encodingLength:Tx},Nx=Rx,Rs=Nx;var Ns=(t,e=0)=>[Rs.decode(t,e),Rs.decode.bytes],Di=(t,e,r=0)=>(Rs.encode(t,e,r),e),Li=t=>Rs.encodingLength(t);var lr=(t,e)=>{let r=e.byteLength,n=Li(t),i=n+Li(r),s=new Uint8Array(i+r);return Di(t,s,0),Di(r,s,n),s.set(e,i),new Pi(t,r,e,s)},$n=t=>{let e=Nr(t),[r,n]=Ns(e),[i,s]=Ns(e.subarray(n)),o=e.subarray(n+s);if(o.byteLength!==i)throw new Error("Incorrect length");return new Pi(r,i,o,e)},Kd=(t,e)=>{if(t===e)return!0;{let r=e;return t.code===r.code&&t.size===r.size&&r.bytes instanceof Uint8Array&&bd(t.bytes,r.bytes)}},Pi=class{constructor(e,r,n,i){this.code=e,this.size=r,this.digest=n,this.bytes=i}};var Qu=({name:t,code:e,encode:r})=>new Wu(t,e,r),Wu=class{constructor(e,r,n){this.name=e,this.code=r,this.encode=n}digest(e){if(e instanceof Uint8Array){let r=this.encode(e);return r instanceof Uint8Array?lr(this.code,r):r.then(n=>lr(this.code,n))}else throw Error("Unknown type, must be binary type")}};var qd=t=>async e=>new Uint8Array(await crypto.subtle.digest(t,e)),ot=Qu({name:"sha2-256",code:18,encode:qd("SHA-256")}),Dx=Qu({name:"sha2-512",code:19,encode:qd("SHA-512")});var ju={};pt(ju,{identity:()=>fn});var Hd=0,Lx="identity",zd=Nr,Px=t=>lr(Hd,zd(t)),fn={code:Hd,name:Lx,encode:zd,digest:Px};var tR=new TextEncoder,rR=new TextDecoder;var kx=(t,e)=>{let{bytes:r,version:n}=t;switch(n){case 0:return Mx(r,Zu(t),e||We.encoder);default:return Fx(r,Zu(t),e||Tt.encoder)}},$d=new WeakMap,Zu=t=>{let e=$d.get(t);if(e==null){let r=new Map;return $d.set(t,r),r}return e},ve=class{constructor(e,r,n,i){this.code=r,this.version=e,this.multihash=n,this.bytes=i,this["/"]=i}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:e,multihash:r}=this;if(e!==Ds)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==Kx)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return ve.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=lr(e,r);return ve.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 ve.equals(this,e)}static equals(e,r){let n=r;return n&&e.code===n.code&&e.version===n.version&&Kd(e.multihash,n.multihash)}toString(e){return kx(this,e)}toJSON(){return{code:this.code,version:this.version,hash:this.multihash.bytes}}link(){return this}get[Symbol.toStringTag](){return"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 ve)return r;if(r["/"]!=null&&r["/"]===r.bytes||r.asCID===r){let{version:n,code:i,multihash:s,bytes:o}=r;return new ve(n,i,s,o||Gd(n,i,s.bytes))}else if(r[Vx]===!0){let{version:n,multihash:i,code:s}=r,o=$n(i);return ve.create(n,s,o)}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!==Ds)throw new Error(`Version 0 CID must use dag-pb (code: ${Ds}) block encoding`);return new ve(e,r,n,n.bytes)}case 1:{let i=Gd(e,r,n.bytes);return new ve(e,r,n,i)}default:throw new Error("Invalid version")}}static createV0(e){return ve.create(0,Ds,e)}static createV1(e,r){return ve.create(1,e,r)}static decode(e){let[r,n]=ve.decodeFirst(e);if(n.length)throw new Error("Incorrect length");return r}static decodeFirst(e){let r=ve.inspectBytes(e),n=r.size-r.multihashSize,i=Nr(e.subarray(n,n+r.multihashSize));if(i.byteLength!==r.multihashSize)throw new Error("Incorrect length");let s=i.subarray(r.multihashSize-r.digestSize),o=new Pi(r.multihashCode,r.digestSize,s,i);return[r.version===0?ve.createV0(o):ve.createV1(r.codec,o),e.subarray(r.size)]}static inspectBytes(e){let r=0,n=()=>{let[f,h]=Ns(e.subarray(r));return r+=h,f},i=n(),s=Ds;if(i===18?(i=0,r=0):s=n(),i!==0&&i!==1)throw new RangeError(`Invalid CID version ${i}`);let o=r,a=n(),c=n(),u=r+c,l=u-o;return{version:i,codec:s,multihashCode:a,digestSize:c,multihashSize:l,size:u}}static parse(e,r){let[n,i]=Ux(e,r),s=ve.decode(i);return Zu(s).set(n,e),s}},Ux=(t,e)=>{switch(t[0]){case"Q":{let r=e||We;return[We.prefix,r.decode(`${We.prefix}${t}`)]}case We.prefix:{let r=e||We;return[We.prefix,r.decode(t)]}case Tt.prefix:{let r=e||Tt;return[Tt.prefix,r.decode(t)]}default:{if(e==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[t[0],e.decode(t)]}}},Mx=(t,e,r)=>{let{prefix:n}=r;if(n!==We.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);let i=e.get(n);if(i==null){let s=r.encode(t).slice(1);return e.set(n,s),s}else return i},Fx=(t,e,r)=>{let{prefix:n}=r,i=e.get(n);if(i==null){let s=r.encode(t);return e.set(n,s),s}else return i},Ds=112,Kx=18,Gd=(t,e,r)=>{let n=Li(t),i=n+Li(e),s=new Uint8Array(i+r.byteLength);return Di(t,s,0),Di(e,s,n),s.set(r,i),s},Vx=Symbol.for("@ipld/js-cid/CID");var hn={...Ku,...Vu,...qu,...Hu,...zu,...Bu,...$u,...Pu,...Ou,...Gu},hR={...Xu,...ju};function Yn(t){return globalThis.Buffer!=null?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):t}function Pr(t=0){return globalThis.Buffer?.alloc!=null?Yn(globalThis.Buffer.alloc(t)):new Uint8Array(t)}function Br(t=0){return globalThis.Buffer?.allocUnsafe!=null?Yn(globalThis.Buffer.allocUnsafe(t)):new Uint8Array(t)}function Wd(t,e,r,n){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:n}}}var Yd=Wd("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),Ju=Wd("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=Br(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}),qx={utf8:Yd,"utf-8":Yd,hex:hn.base16,latin1:Ju,ascii:Ju,binary:Ju,...hn},ia=qx;function Q(t,e="utf8"){let r=ia[e];if(r==null)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(t.buffer,t.byteOffset,t.byteLength).toString("utf8"):r.encoder.encode(t).substring(1)}function q(t,e="utf8"){let r=ia[e];if(r==null)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?Yn(globalThis.Buffer.from(t,"utf-8")):r.decoder.decode(`${r.prefix}${t}`)}var Or="/",Qd=new TextEncoder().encode(Or),sa=Qd[0],$e=class{constructor(e,r){if(typeof e=="string")this._buf=q(e);else if(e instanceof Uint8Array)this._buf=e;else throw new Error("Invalid key, should be String of Uint8Array");if(r==null&&(r=!0),r&&this.clean(),this._buf.byteLength===0||this._buf[0]!==sa)throw new Error("Invalid key")}toString(e="utf8"){return Q(this._buf,e)}uint8Array(){return this._buf}get[Symbol.toStringTag](){return`Key(${this.toString()})`}static withNamespaces(e){return new $e(e.join(Or))}static random(){return new $e(ra().replace(/-/g,""))}static asKey(e){return e instanceof Uint8Array||typeof e=="string"?new $e(e):typeof e.uint8Array=="function"?new $e(e.uint8Array()):null}clean(){if((this._buf==null||this._buf.byteLength===0)&&(this._buf=Qd),this._buf[0]!==sa){let e=new Uint8Array(this._buf.byteLength+1);e.fill(sa,0,1),e.set(this._buf,1),this._buf=e}for(;this._buf.byteLength>1&&this._buf[this._buf.byteLength-1]===sa;)this._buf=this._buf.subarray(0,-1)}less(e){let r=this.list(),n=e.list();for(let i=0;i<r.length;i++){if(n.length<i+1)return!1;let s=r[i],o=n[i];if(s<o)return!0;if(s>o)return!1}return r.length<n.length}reverse(){return $e.withNamespaces(this.list().slice().reverse())}namespaces(){return this.list()}baseNamespace(){let e=this.namespaces();return e[e.length-1]}list(){return this.toString().split(Or).slice(1)}type(){return Hx(this.baseNamespace())}name(){return zx(this.baseNamespace())}instance(e){return new $e(this.toString()+":"+e)}path(){let e=this.parent().toString();return e.endsWith(Or)||(e+=Or),e+=this.type(),new $e(e)}parent(){let e=this.list();return e.length===1?new $e(Or):new $e(e.slice(0,-1).join(Or))}child(e){return this.toString()===Or?e:e.toString()===Or?this:new $e(this.toString()+e.toString(),!1)}isAncestorOf(e){return e.toString()===this.toString()?!1:e.toString().startsWith(this.toString())}isDecendantOf(e){return e.toString()===this.toString()?!1:this.toString().startsWith(e.toString())}isTopLevel(){return this.list().length===1}concat(...e){return $e.withNamespaces([...this.namespaces(),...$x(e.map(r=>r.namespaces()))])}};function Hx(t){let e=t.split(":");return e.length<2?"":e.slice(0,-1).join(":")}function zx(t){let e=t.split(":");return e[e.length-1]}function $x(t){return[].concat(...t)}var Zd=C(G(),1);function Jd(t){return t=t||new Error("Not Found"),(0,Zd.default)(t,"ERR_NOT_FOUND")}var oa=class extends ta{constructor(){super(),this.data={}}open(){return Promise.resolve()}close(){return Promise.resolve()}async put(e,r){this.data[e.toString()]=r}async get(e){if(!await this.has(e))throw Jd();return this.data[e.toString()]}async has(e){return this.data[e.toString()]!==void 0}async delete(e){delete this.data[e.toString()]}async*_all(){yield*Object.entries(this.data).map(([e,r])=>({key:new $e(e),value:r}))}async*_allKeys(){yield*Object.entries(this.data).map(([e])=>new $e(e))}};var Os=C(G(),1);var ne;(function(t){t.NOT_STARTED_YET="The libp2p node is not started yet",t.DHT_DISABLED="DHT is not available",t.PUBSUB_DISABLED="PubSub is not available",t.CONN_ENCRYPTION_REQUIRED="At least one connection encryption module is required",t.ERR_TRANSPORTS_REQUIRED="At least one transport module is required",t.ERR_PROTECTOR_REQUIRED="Private network is enforced, but no protector was provided",t.NOT_FOUND="Not found"})(ne||(ne={}));var b;(function(t){t.DHT_DISABLED="ERR_DHT_DISABLED",t.ERR_PUBSUB_DISABLED="ERR_PUBSUB_DISABLED",t.PUBSUB_NOT_STARTED="ERR_PUBSUB_NOT_STARTED",t.DHT_NOT_STARTED="ERR_DHT_NOT_STARTED",t.CONN_ENCRYPTION_REQUIRED="ERR_CONN_ENCRYPTION_REQUIRED",t.ERR_TRANSPORTS_REQUIRED="ERR_TRANSPORTS_REQUIRED",t.ERR_PROTECTOR_REQUIRED="ERR_PROTECTOR_REQUIRED",t.ERR_PEER_DIAL_INTERCEPTED="ERR_PEER_DIAL_INTERCEPTED",t.ERR_CONNECTION_INTERCEPTED="ERR_CONNECTION_INTERCEPTED",t.ERR_INVALID_PROTOCOLS_FOR_STREAM="ERR_INVALID_PROTOCOLS_FOR_STREAM",t.ERR_CONNECTION_ENDED="ERR_CONNECTION_ENDED",t.ERR_CONNECTION_FAILED="ERR_CONNECTION_FAILED",t.ERR_NODE_NOT_STARTED="ERR_NODE_NOT_STARTED",t.ERR_ALREADY_ABORTED="ERR_ALREADY_ABORTED",t.ERR_TOO_MANY_ADDRESSES="ERR_TOO_MANY_ADDRESSES",t.ERR_NO_VALID_ADDRESSES="ERR_NO_VALID_ADDRESSES",t.ERR_RELAYED_DIAL="ERR_RELAYED_DIAL",t.ERR_DIALED_SELF="ERR_DIALED_SELF",t.ERR_DISCOVERED_SELF="ERR_DISCOVERED_SELF",t.ERR_DUPLICATE_TRANSPORT="ERR_DUPLICATE_TRANSPORT",t.ERR_ENCRYPTION_FAILED="ERR_ENCRYPTION_FAILED",t.ERR_HOP_REQUEST_FAILED="ERR_HOP_REQUEST_FAILED",t.ERR_INVALID_KEY="ERR_INVALID_KEY",t.ERR_INVALID_MESSAGE="ERR_INVALID_MESSAGE",t.ERR_INVALID_PARAMETERS="ERR_INVALID_PARAMETERS",t.ERR_INVALID_PEER="ERR_INVALID_PEER",t.ERR_MUXER_UNAVAILABLE="ERR_MUXER_UNAVAILABLE",t.ERR_NOT_FOUND="ERR_NOT_FOUND",t.ERR_TIMEOUT="ERR_TIMEOUT",t.ERR_TRANSPORT_UNAVAILABLE="ERR_TRANSPORT_UNAVAILABLE",t.ERR_TRANSPORT_DIAL_FAILED="ERR_TRANSPORT_DIAL_FAILED",t.ERR_UNSUPPORTED_PROTOCOL="ERR_UNSUPPORTED_PROTOCOL",t.ERR_PROTOCOL_HANDLER_ALREADY_REGISTERED="ERR_PROTOCOL_HANDLER_ALREADY_REGISTERED",t.ERR_INVALID_MULTIADDR="ERR_INVALID_MULTIADDR",t.ERR_SIGNATURE_NOT_VALID="ERR_SIGNATURE_NOT_VALID",t.ERR_FIND_SELF="ERR_FIND_SELF",t.ERR_NO_ROUTERS_AVAILABLE="ERR_NO_ROUTERS_AVAILABLE",t.ERR_CONNECTION_NOT_MULTIPLEXED="ERR_CONNECTION_NOT_MULTIPLEXED",t.ERR_NO_DIAL_TOKENS="ERR_NO_DIAL_TOKENS",t.ERR_KEYCHAIN_REQUIRED="ERR_KEYCHAIN_REQUIRED",t.ERR_INVALID_CMS="ERR_INVALID_CMS",t.ERR_MISSING_KEYS="ERR_MISSING_KEYS",t.ERR_NO_KEY="ERR_NO_KEY",t.ERR_INVALID_KEY_NAME="ERR_INVALID_KEY_NAME",t.ERR_INVALID_KEY_TYPE="ERR_INVALID_KEY_TYPE",t.ERR_KEY_ALREADY_EXISTS="ERR_KEY_ALREADY_EXISTS",t.ERR_INVALID_KEY_SIZE="ERR_INVALID_KEY_SIZE",t.ERR_KEY_NOT_FOUND="ERR_KEY_NOT_FOUND",t.ERR_OLD_KEY_NAME_INVALID="ERR_OLD_KEY_NAME_INVALID",t.ERR_NEW_KEY_NAME_INVALID="ERR_NEW_KEY_NAME_INVALID",t.ERR_PASSWORD_REQUIRED="ERR_PASSWORD_REQUIRED",t.ERR_PEM_REQUIRED="ERR_PEM_REQUIRED",t.ERR_CANNOT_READ_KEY="ERR_CANNOT_READ_KEY",t.ERR_MISSING_PRIVATE_KEY="ERR_MISSING_PRIVATE_KEY",t.ERR_MISSING_PUBLIC_KEY="ERR_MISSING_PUBLIC_KEY",t.ERR_INVALID_OLD_PASS_TYPE="ERR_INVALID_OLD_PASS_TYPE",t.ERR_INVALID_NEW_PASS_TYPE="ERR_INVALID_NEW_PASS_TYPE",t.ERR_INVALID_PASS_LENGTH="ERR_INVALID_PASS_LENGTH",t.ERR_NOT_IMPLEMENTED="ERR_NOT_IMPLEMENTED",t.ERR_WRONG_PING_ACK="ERR_WRONG_PING_ACK",t.ERR_INVALID_RECORD="ERR_INVALID_RECORD",t.ERR_ALREADY_SUCCEEDED="ERR_ALREADY_SUCCEEDED",t.ERR_NO_HANDLER_FOR_PROTOCOL="ERR_NO_HANDLER_FOR_PROTOCOL",t.ERR_TOO_MANY_OUTBOUND_PROTOCOL_STREAMS="ERR_TOO_MANY_OUTBOUND_PROTOCOL_STREAMS",t.ERR_TOO_MANY_INBOUND_PROTOCOL_STREAMS="ERR_TOO_MANY_INBOUND_PROTOCOL_STREAMS",t.ERR_CONNECTION_DENIED="ERR_CONNECTION_DENIED"})(b||(b={}));var ep=C(G(),1);async function*kr(t,e){for await(let r of t)await e(r)&&(yield r)}async function*Ls(t,e){for await(let r of t)yield e(r)}async function*Ps(t,e){yield*Ls(t,async r=>(await e.addressBook.add(r.id,r.multiaddrs),r))}function aa(t){let e=new Set;return kr(t,r=>e.has(r.id.toString())?!1:(e.add(r.id.toString()),!0))}async function*ca(t,e=1){let r=0;for await(let n of t)r++,yield n;if(r<e)throw(0,ep.default)(new Error("not found"),"NOT_FOUND")}var vp=C(Ur(),1);var la=class{constructor(e){if(!(e>0)||e-1&e)throw new Error("Max size for a FixedFIFO should be a power of two");this.buffer=new Array(e),this.mask=e-1,this.top=0,this.btm=0,this.next=null}push(e){return this.buffer[this.top]!==void 0?!1:(this.buffer[this.top]=e,this.top=this.top+1&this.mask,!0)}shift(){let e=this.buffer[this.btm];if(e!==void 0)return this.buffer[this.btm]=void 0,this.btm=this.btm+1&this.mask,e}isEmpty(){return this.buffer[this.btm]===void 0}},Bi=class{constructor(e={}){this.hwm=e.splitLimit??16,this.head=new la(this.hwm),this.tail=this.head,this.size=0}calculateSize(e){return e?.byteLength!=null?e.byteLength:1}push(e){if(e?.value!=null&&(this.size+=this.calculateSize(e.value)),!this.head.push(e)){let r=this.head;this.head=r.next=new la(2*this.head.buffer.length),this.head.push(e)}}shift(){let e=this.tail.shift();if(e===void 0&&this.tail.next!=null){let r=this.tail.next;this.tail.next=null,this.tail=r,e=this.tail.shift()}return e?.value!=null&&(this.size-=this.calculateSize(e.value)),e}isEmpty(){return this.head.isEmpty()}};function Wn(t={}){return Xx(r=>{let n=r.shift();if(n==null)return{done:!0};if(n.error!=null)throw n.error;return{done:n.done===!0,value:n.value}},t)}function Xx(t,e){e=e??{};let r=e.onEnd,n=new Bi,i,s,o,a=async()=>n.isEmpty()?o?{done:!0}:await new Promise((y,g)=>{s=E=>{s=null,n.push(E);try{y(t(n))}catch(x){g(x)}return i}}):t(n),c=y=>s!=null?s(y):(n.push(y),i),u=y=>(n=new Bi,s!=null?s({error:y}):(n.push({error:y}),i)),l=y=>{if(o)return i;if(e?.objectMode!==!0&&y?.byteLength==null)throw new Error("objectMode was not true but tried to push non-Uint8Array value");return c({done:!1,value:y})},f=y=>o?i:(o=!0,y!=null?u(y):c({done:!0})),h=()=>(n=new Bi,f(),{done:!0}),d=y=>(f(y),{done:!0});if(i={[Symbol.asyncIterator](){return this},next:a,return:h,throw:d,push:l,end:f,get readableLength(){return n.size}},r==null)return i;let p=i;return i={[Symbol.asyncIterator](){return this},next(){return p.next()},throw(y){return p.throw(y),r!=null&&(r(y),r=void 0),{done:!0}},return(){return p.return(),r!=null&&(r(),r=void 0),{done:!0}},push:l,end(y){return p.end(y),r!=null&&(r(y),r=void 0),i},get readableLength(){return p.readableLength}},i}async function*Mr(...t){let e=Wn({objectMode:!0});Promise.resolve().then(async()=>{try{await Promise.all(t.map(async r=>{for await(let n of r)e.push(n)})),e.end()}catch(r){e.end(r)}}),yield*e}var jx=(...t)=>{let e;for(;t.length>0;)e=t.shift()(e);return e},op=t=>t!=null&&(typeof t[Symbol.asyncIterator]=="function"||typeof t[Symbol.iterator]=="function"||typeof t.next=="function"),rl=t=>t!=null&&typeof t.sink=="function"&&op(t.source),Zx=t=>e=>{let r=t.sink(e);if(r.then!=null){let n=Wn({objectMode:!0});return r.then(()=>{n.end()},s=>{n.end(s)}),Mr(n,async function*(){yield*t.source,n.end()}())}return t.source};function Ce(t,...e){if(rl(t)){let n=t;t=()=>n.source}else if(op(t)){let n=t;t=()=>n}let r=[t,...e];if(r.length>1&&rl(r[r.length-1])&&(r[r.length-1]=r[r.length-1].sink),r.length>2)for(let n=1;n<r.length-1;n++)rl(r[n])&&(r[n]=Zx(r[n]));return jx(...r)}async function Rt(t){for await(let e of t)return e}async function dn(t){for await(let e of t);}var pa=C(nl(),1),wp=C(fr(),1),Ep=M("libp2p:peer-routing"),da=class{constructor(e,r){this.components=e,this.routers=r.routers??[],this.refreshManagerInit=r.refreshManager??{},this.started=!1,this._findClosestPeersTask=this._findClosestPeersTask.bind(this)}isStarted(){return this.started}async start(){this.started||this.routers.length===0||this.timeoutId!=null||this.refreshManagerInit.enabled===!1||(this.timeoutId=(0,pa.setDelayedInterval)(this._findClosestPeersTask,this.refreshManagerInit.interval,this.refreshManagerInit.bootDelay),this.started=!0)}async _findClosestPeersTask(){if(this.abortController==null)try{this.abortController=new vp.TimeoutController(this.refreshManagerInit.timeout??1e4);try{(0,wp.setMaxListeners)?.(1/0,this.abortController.signal)}catch{}await dn(this.getClosestPeers(this.components.peerId.toBytes(),{signal:this.abortController.signal}))}catch(e){Ep.error(e)}finally{this.abortController?.clear(),this.abortController=void 0}}async stop(){(0,pa.clearDelayedInterval)(this.timeoutId),this.abortController?.abort(),this.started=!1}async findPeer(e,r){if(this.routers.length===0)throw(0,Os.default)(new Error("No peer routers available"),b.ERR_NO_ROUTERS_AVAILABLE);if(e.toString()===this.components.peerId.toString())throw(0,Os.default)(new Error("Should not try to find self"),b.ERR_FIND_SELF);let n=await Ce(Mr(...this.routers.map(i=>async function*(){try{yield await i.findPeer(e,r)}catch(s){Ep.error(s)}}())),i=>kr(i,Boolean),i=>Ps(i,this.components.peerStore),async i=>await Rt(i));if(n!=null)return n;throw(0,Os.default)(new Error(ne.NOT_FOUND),b.ERR_NOT_FOUND)}async*getClosestPeers(e,r){if(this.routers.length===0)throw(0,Os.default)(new Error("No peer routers available"),b.ERR_NO_ROUTERS_AVAILABLE);yield*Ce(Mr(...this.routers.map(n=>n.getClosestPeers(e,r))),n=>Ps(n,this.components.peerStore),n=>aa(n),n=>ca(n))}};var pn=C(G(),1);var ma=class{constructor(e,r){this.routers=r.routers??[],this.started=!1,this.components=e}isStarted(){return this.started}async start(){this.started=!0}async stop(){this.started=!1}async*findProviders(e,r={}){if(this.routers.length===0)throw(0,pn.default)(new Error("No content this.routers available"),b.ERR_NO_ROUTERS_AVAILABLE);yield*Ce(Mr(...this.routers.map(n=>n.findProviders(e,r))),n=>Ps(n,this.components.peerStore),n=>aa(n),n=>ca(n))}async provide(e,r={}){if(this.routers.length===0)throw(0,pn.default)(new Error("No content routers available"),b.ERR_NO_ROUTERS_AVAILABLE);await Promise.all(this.routers.map(async n=>await n.provide(e,r)))}async put(e,r,n){if(!this.isStarted())throw(0,pn.default)(new Error(ne.NOT_STARTED_YET),b.DHT_NOT_STARTED);let i=this.components.dht;i!=null&&await dn(i.put(e,r,n))}async get(e,r){if(!this.isStarted())throw(0,pn.default)(new Error(ne.NOT_STARTED_YET),b.DHT_NOT_STARTED);let n=this.components.dht;if(n!=null){for await(let i of n.get(e,r))if(i.name==="VALUE")return i.value}throw(0,pn.default)(new Error(ne.NOT_FOUND),b.ERR_NOT_FOUND)}async*getMany(e,r,n){if(!this.isStarted())throw(0,pn.default)(new Error(ne.NOT_STARTED_YET),b.DHT_NOT_STARTED);if(r==null||r===0)return;let i=0,s=this.components.dht;if(s!=null){for await(let o of s.get(e,n))if(o.name==="VALUE"&&(yield{from:o.from,val:o.value},i++,i===r))break}if(i===0)throw(0,pn.default)(new Error(ne.NOT_FOUND),b.ERR_NOT_FOUND)}};function _e(t,e){if(t===e)return!0;if(t.byteLength!==e.byteLength)return!1;for(let r=0;r<t.byteLength;r++)if(t[r]!==e[r])return!1;return!0}var bp=C(G(),1);var sl=Symbol.for("@libp2p/peer-id");function Qn(t){return t!=null&&Boolean(t[sl])}var ub=Symbol.for("nodejs.util.inspect.custom"),xp=Object.values(hn).map(t=>t.decoder).reduce((t,e)=>t.or(e),hn.identity.decoder),Sp=114,ol=36,al=37,ks=class{constructor(e){this.type=e.type,this.multihash=e.multihash,this.privateKey=e.privateKey,Object.defineProperty(this,"string",{enumerable:!1,writable:!0})}get[Symbol.toStringTag](){return`PeerId(${this.toString()})`}get[sl](){return!0}toString(){return this.string==null&&(this.string=We.encode(this.multihash.bytes).slice(1)),this.string}toCID(){return ve.createV1(Sp,this.multihash)}toBytes(){return this.multihash.bytes}toJSON(){return this.toString()}equals(e){if(e instanceof Uint8Array)return _e(this.multihash.bytes,e);if(typeof e=="string")return me(e).equals(this);if(e?.multihash?.bytes!=null)return _e(this.multihash.bytes,e.multihash.bytes);throw new Error("not valid Id")}[ub](){return`PeerId(${this.toString()})`}},Xn=class extends ks{constructor(e){super({...e,type:"RSA"}),this.type="RSA",this.publicKey=e.publicKey}},jn=class extends ks{constructor(e){super({...e,type:"Ed25519"}),this.type="Ed25519",this.publicKey=e.multihash.digest}},Zn=class extends ks{constructor(e){super({...e,type:"secp256k1"}),this.type="secp256k1",this.publicKey=e.multihash.digest}};function Qe(t){if(t.type==="RSA")return new Xn(t);if(t.type==="Ed25519")return new jn(t);if(t.type==="secp256k1")return new Zn(t);throw(0,bp.default)(new Error("Not a PeerId"),"ERR_INVALID_PARAMETERS")}function me(t,e){if(e=e??xp,t.charAt(0)==="1"||t.charAt(0)==="Q"){let r=$n(We.decode(`z${t}`));return t.startsWith("12D")?new jn({multihash:r}):t.startsWith("16U")?new Zn({multihash:r}):new Xn({multihash:r})}return mn(xp.decode(t))}function mn(t){try{let e=$n(t);if(e.code===fn.code){if(e.digest.length===ol)return new jn({multihash:e});if(e.digest.length===al)return new Zn({multihash:e})}if(e.code===ot.code)return new Xn({multihash:e})}catch{return lb(ve.decode(t))}throw new Error("Supplied PeerID CID is invalid")}function lb(t){if(t==null||t.multihash==null||t.version==null||t.version===1&&t.code!==Sp)throw new Error("Supplied PeerID CID is invalid");let e=t.multihash;if(e.code===ot.code)return new Xn({multihash:t.multihash});if(e.code===fn.code){if(e.digest.length===ol)return new jn({multihash:t.multihash});if(e.digest.length===al)return new Zn({multihash:t.multihash})}throw new Error("Supplied PeerID CID is invalid")}async function Ui(t,e){return t.length===ol?new jn({multihash:lr(fn.code,t),privateKey:e}):t.length===al?new Zn({multihash:lr(fn.code,t),privateKey:e}):new Xn({multihash:await ot.digest(t),publicKey:t,privateKey:e})}var ya=class{index=0;input="";new(e){return this.index=0,this.input=e,this}readAtomically(e){let r=this.index,n=e();return n===void 0&&(this.index=r),n}parseWith(e){let r=e();if(this.index===this.input.length)return r}peekChar(){if(!(this.index>=this.input.length))return this.input[this.index]}readChar(){if(!(this.index>=this.input.length))return this.input[this.index++]}readGivenChar(e){return this.readAtomically(()=>{let r=this.readChar();if(r===e)return r})}readSeparator(e,r,n){return this.readAtomically(()=>{if(!(r>0&&this.readGivenChar(e)===void 0))return n()})}readNumber(e,r,n,i){return this.readAtomically(()=>{let s=0,o=0,a=this.peekChar();if(a===void 0)return;let c=a==="0",u=2**(8*i)-1;for(;;){let l=this.readAtomically(()=>{let f=this.readChar();if(f===void 0)return;let h=Number.parseInt(f,e);if(!Number.isNaN(h))return h});if(l===void 0)break;if(s*=e,s+=l,s>u||(o+=1,r!==void 0&&o>r))return}if(o!==0)return!n&&c&&o>1?void 0:s})}readIPv4Addr(){return this.readAtomically(()=>{let e=new Uint8Array(4);for(let r=0;r<e.length;r++){let n=this.readSeparator(".",r,()=>this.readNumber(10,3,!1,1));if(n===void 0)return;e[r]=n}return e})}readIPv6Addr(){let e=r=>{for(let n=0;n<r.length/2;n++){let i=n*2;if(n<r.length-3){let o=this.readSeparator(":",n,()=>this.readIPv4Addr());if(o!==void 0)return r[i]=o[0],r[i+1]=o[1],r[i+2]=o[2],r[i+3]=o[3],[i+4,!0]}let s=this.readSeparator(":",n,()=>this.readNumber(16,4,!0,2));if(s===void 0)return[i,!1];r[i]=s>>8,r[i+1]=s&255}return[r.length,!1]};return this.readAtomically(()=>{let r=new Uint8Array(16),[n,i]=e(r);if(n===16)return r;if(i||this.readGivenChar(":")===void 0||this.readGivenChar(":")===void 0)return;let s=new Uint8Array(14),o=16-(n+2),[a]=e(s.subarray(0,o));return r.set(s.subarray(0,a),16-a),r})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var _p=45,fb=15,Mi=new ya;function Ap(t){if(!(t.length>fb))return Mi.new(t).parseWith(()=>Mi.readIPv4Addr())}function Cp(t){if(!(t.length>_p))return Mi.new(t).parseWith(()=>Mi.readIPv6Addr())}function Ip(t){if(!(t.length>_p))return Mi.new(t).parseWith(()=>Mi.readIPAddr())}function Tp(t){return Boolean(Ap(t))}function Rp(t){return Boolean(Cp(t))}function Fi(t){return Boolean(Ip(t))}var Np=Tp,hb=Rp,cl=function(t){let e=0;if(t=t.toString().trim(),Np(t)){let r=new Uint8Array(e+4);return t.split(/\./g).forEach(n=>{r[e++]=parseInt(n,10)&255}),r}if(hb(t)){let r=t.split(":",8),n;for(n=0;n<r.length;n++){let s=Np(r[n]),o;s&&(o=cl(r[n]),r[n]=Q(o.slice(0,2),"base16")),o!=null&&++n<8&&r.splice(n,0,Q(o.slice(2,4),"base16"))}if(r[0]==="")for(;r.length<8;)r.unshift("0");else if(r[r.length-1]==="")for(;r.length<8;)r.push("0");else if(r.length<8){for(n=0;n<r.length&&r[n]!=="";n++);let s=[n,1];for(n=9-r.length;n>0;n--)s.push("0");r.splice.apply(r,s)}let i=new Uint8Array(e+16);for(n=0;n<r.length;n++){let s=parseInt(r[n],16);i[e++]=s>>8&255,i[e++]=s&255}return i}throw new Error("invalid ip address")},Dp=function(t,e=0,r){e=~~e,r=r??t.length-e;let n=new DataView(t.buffer);if(r===4){let i=[];for(let s=0;s<r;s++)i.push(t[e+s]);return i.join(".")}if(r===16){let i=[];for(let s=0;s<r;s+=2)i.push(n.getUint16(e+s).toString(16));return i.join(":").replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}return""};var Us={},ul={},pb=[[4,32,"ip4"],[6,16,"tcp"],[33,16,"dccp"],[41,128,"ip6"],[42,-1,"ip6zone"],[53,-1,"dns",!0],[54,-1,"dns4",!0],[55,-1,"dns6",!0],[56,-1,"dnsaddr",!0],[132,16,"sctp"],[273,16,"udp"],[275,0,"p2p-webrtc-star"],[276,0,"p2p-webrtc-direct"],[277,0,"p2p-stardust"],[280,0,"webrtc"],[290,0,"p2p-circuit"],[301,0,"udt"],[302,0,"utp"],[400,-1,"unix",!1,!0],[421,-1,"ipfs"],[421,-1,"p2p"],[443,0,"https"],[444,96,"onion"],[445,296,"onion3"],[446,-1,"garlic64"],[460,0,"quic"],[461,0,"quic-v1"],[465,0,"webtransport"],[466,-1,"certhash"],[477,0,"ws"],[478,0,"wss"],[479,0,"p2p-websocket-star"],[480,0,"http"],[777,-1,"memory"]];pb.forEach(t=>{let e=mb(...t);ul[e.code]=e,Us[e.name]=e});function mb(t,e,r,n,i){return{code:t,size:e,name:r,resolvable:Boolean(n),path:Boolean(i)}}function Ie(t){if(typeof t=="number"){if(ul[t]!=null)return ul[t];throw new Error(`no protocol with code: ${t}`)}else if(typeof t=="string"){if(Us[t]!=null)return Us[t];throw new Error(`no protocol with name: ${t}`)}throw new Error(`invalid protocol id type: ${typeof t}`)}var hr=C(ga(),1);function Xe(t,e){e==null&&(e=t.reduce((i,s)=>i+s.length,0));let r=Br(e),n=0;for(let i of t)r.set(i,n),n+=i.length;return Yn(r)}function Hp(t,e){switch(Ie(t).code){case 4:case 41:return Nb(e);case 6:case 273:case 33:case 132:return $p(e).toString();case 53:case 54:case 55:case 56:case 400:case 777:return Lb(e);case 421:return kb(e);case 444:return qp(e);case 445:return qp(e);case 466:return Ob(e);default:return Q(e,"base16")}}function zp(t,e){switch(Ie(t).code){case 4:return Vp(e);case 41:return Vp(e);case 6:case 273:case 33:case 132:return dl(parseInt(e,10));case 53:case 54:case 55:case 56:case 400:case 777:return Db(e);case 421:return Pb(e);case 444:return Ub(e);case 445:return Mb(e);case 466:return Bb(e);default:return q(e,"base16")}}var hl=Object.values(hn).map(t=>t.decoder),Rb=function(){let t=hl[0].or(hl[1]);return hl.slice(2).forEach(e=>t=t.or(e)),t}();function Vp(t){if(!Fi(t))throw new Error("invalid ip address");return cl(t)}function Nb(t){let e=Dp(t,0,t.length);if(e==null)throw new Error("ipBuff is required");if(!Fi(e))throw new Error("invalid ip address");return e}function dl(t){let e=new ArrayBuffer(2);return new DataView(e).setUint16(0,t),new Uint8Array(e)}function $p(t){return new DataView(t.buffer).getUint16(t.byteOffset)}function Db(t){let e=q(t),r=Uint8Array.from(hr.default.encode(e.length));return Xe([r,e],r.length+e.length)}function Lb(t){let e=hr.default.decode(t);if(t=t.slice(hr.default.decode.bytes),t.length!==e)throw new Error("inconsistent lengths");return Q(t)}function Pb(t){let e;t[0]==="Q"||t[0]==="1"?e=$n(We.decode(`z${t}`)).bytes:e=ve.parse(t).multihash.bytes;let r=Uint8Array.from(hr.default.encode(e.length));return Xe([r,e],r.length+e.length)}function Bb(t){let e=Rb.decode(t),r=Uint8Array.from(hr.default.encode(e.length));return Xe([r,e],r.length+e.length)}function Ob(t){let e=hr.default.decode(t),r=t.slice(hr.default.decode.bytes);if(r.length!==e)throw new Error("inconsistent lengths");return"u"+Q(r,"base64url")}function kb(t){let e=hr.default.decode(t),r=t.slice(hr.default.decode.bytes);if(r.length!==e)throw new Error("inconsistent lengths");return Q(r,"base58btc")}function Ub(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=Tt.decode("b"+e[0]),n=parseInt(e[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let i=dl(n);return Xe([r,i],r.length+i.length)}function Mb(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=Tt.decode(`b${e[0]}`),n=parseInt(e[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let i=dl(n);return Xe([r,i],r.length+i.length)}function qp(t){let e=t.slice(0,t.length-2),r=t.slice(t.length-2),n=Q(e,"base32"),i=$p(r);return`${n}:${i}`}var Ki=C(ga(),1);function Fb(t){let e=[],r=t.split("/").slice(1);if(r.length===1&&r[0]==="")return[];for(let n=0;n<r.length;n++){let i=r[n],s=Ie(i);if(s.size===0){e.push([i]);continue}if(n++,n>=r.length)throw Yp("invalid address: "+t);if(s.path===!0){e.push([i,El(r.slice(n).join("/"))]);break}e.push([i,r[n]])}return e}function Kb(t){let e=[];return t.map(r=>{let n=wa(r);return e.push(n.name),r.length>1&&r[1]!=null&&e.push(r[1]),null}),El(e.join("/"))}function Vb(t){return t.map(e=>{Array.isArray(e)||(e=[e]);let r=wa(e);return e.length>1?[r.code,zp(r.code,e[1])]:[r.code]})}function pl(t){return t.map(e=>{let r=wa(e);return e[1]!=null?[r.code,Hp(r.code,e[1])]:[r.code]})}function ml(t){return va(Xe(t.map(e=>{let r=wa(e),n=Uint8Array.from(Ki.default.encode(r.code));return e.length>1&&e[1]!=null&&(n=Xe([n,e[1]])),n})))}function yl(t,e){return t.size>0?t.size/8:t.size===0?0:Ki.default.decode(e)+(Ki.default.decode.bytes??0)}function Ea(t){let e=[],r=0;for(;r<t.length;){let n=Ki.default.decode(t,r),i=Ki.default.decode.bytes??0,s=Ie(n),o=yl(s,t.slice(r+i));if(o===0){e.push([n]),r+=i;continue}let a=t.slice(r+i,r+i+o);if(r+=o+i,r>t.length)throw Yp("Invalid address Uint8Array: "+Q(t,"base16"));e.push([n,a])}return e}function gl(t){let e=Ea(t),r=pl(e);return Kb(r)}function qb(t){t=El(t);let e=Fb(t),r=Vb(e);return ml(r)}function Gp(t){return qb(t)}function va(t){let e=Hb(t);if(e!=null)throw e;return Uint8Array.from(t)}function Hb(t){try{Ea(t)}catch(e){return e}}function El(t){return"/"+t.trim().split("/").filter(e=>e).join("/")}function Yp(t){return new Error("Error parsing address: "+t)}function wa(t){return Ie(t[0])}var wl=C(ga(),1);var Xp=C(G(),1);var Vi=function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},vl=function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},Ms,Fs,Ks,Wp,$b=Symbol.for("nodejs.util.inspect.custom"),Qp=[Ie("dns").code,Ie("dns4").code,Ie("dns6").code,Ie("dnsaddr").code],Gb=[Ie("p2p").code,Ie("ipfs").code],xl=new Map,jp=Symbol.for("@multiformats/js-multiaddr/multiaddr");function Zp(t,e){if(t==null)throw new Error("requires node address object");if(e==null)throw new Error("requires transport protocol");let r;switch(t.family){case 4:r="ip4";break;case 6:r="ip6";break;default:throw Error("Invalid addr family, should be 4 or 6.")}return new dr("/"+[r,t.address,e,t.port].join("/"))}function Fr(t){return Boolean(t?.[jp])}var dr=class{constructor(e){if(Ms.set(this,void 0),Fs.set(this,void 0),Ks.set(this,void 0),this[Wp]=!0,e==null&&(e=""),e instanceof Uint8Array)this.bytes=va(e);else if(typeof e=="string"){if(e.length>0&&e.charAt(0)!=="/")throw new Error(`multiaddr "${e}" must start with a "/"`);this.bytes=Gp(e)}else if(Fr(e))this.bytes=va(e.bytes);else throw new Error("addr must be a string, Buffer, or another Multiaddr")}toString(){return Vi(this,Ms,"f")==null&&vl(this,Ms,gl(this.bytes),"f"),Vi(this,Ms,"f")}toJSON(){return this.toString()}toOptions(){let e=this.protoCodes(),r=this.toString().split("/").slice(1),n,i;if(r.length>2)Qp.includes(e[0])&&Gb.includes(e[1])?(n=Ie("tcp").name,i=443):(n=Ie(r[2]).name,i=parseInt(r[3]));else if(Qp.includes(e[0]))n=Ie("tcp").name,i=443;else throw new Error('multiaddr must have a valid format: "/{ip4, ip6, dns4, dns6, dnsaddr}/{address}/{tcp, udp}/{port}".');return{family:e[0]===41||e[0]===55?6:4,host:r[1],transport:n,port:i}}protos(){return this.protoCodes().map(e=>Object.assign({},Ie(e)))}protoCodes(){let e=[],r=this.bytes,n=0;for(;n<r.length;){let i=wl.default.decode(r,n),s=wl.default.decode.bytes??0,o=Ie(i),a=yl(o,r.slice(n+s));n+=a+s,e.push(i)}return e}protoNames(){return this.protos().map(e=>e.name)}tuples(){return Vi(this,Fs,"f")==null&&vl(this,Fs,Ea(this.bytes),"f"),Vi(this,Fs,"f")}stringTuples(){return Vi(this,Ks,"f")==null&&vl(this,Ks,pl(this.tuples()),"f"),Vi(this,Ks,"f")}encapsulate(e){return e=new dr(e),new dr(this.toString()+e.toString())}decapsulate(e){let r=e.toString(),n=this.toString(),i=n.lastIndexOf(r);if(i<0)throw new Error(`Address ${this.toString()} does not contain subaddress: ${e.toString()}`);return new dr(n.slice(0,i))}decapsulateCode(e){let r=this.tuples();for(let n=r.length-1;n>=0;n--)if(r[n][0]===e)return new dr(ml(r.slice(0,n)));return this}getPeerId(){try{let r=this.stringTuples().filter(n=>n[0]===Us.ipfs.code).pop();if(r?.[1]!=null){let n=r[1];return n[0]==="Q"||n[0]==="1"?Q(We.decode(`z${n}`),"base58btc"):Q(ve.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){let e=null;try{e=this.stringTuples().filter(r=>Ie(r[0]).path===!0)[0][1],e==null&&(e=null)}catch{e=null}return e}equals(e){return _e(this.bytes,e.bytes)}async resolve(e){let r=this.protos().find(s=>s.resolvable);if(r==null)return[this];let n=xl.get(r.name);if(n==null)throw(0,Xp.default)(new Error(`no available resolver for ${r.name}`),"ERR_NO_AVAILABLE_RESOLVER");return(await n(this,e)).map(s=>new dr(s))}nodeAddress(){let e=this.toOptions();if(e.transport!=="tcp"&&e.transport!=="udp")throw new Error(`multiaddr must have a valid format - no protocol with name: "${e.transport}". Must have a valid transport protocol: "{tcp, udp}"`);return{family:e.family,address:e.host,port:e.port}}isThinWaistAddress(e){let r=(e??this).protos();return!(r.length!==2||r[0].code!==4&&r[0].code!==41||r[1].code!==6&&r[1].code!==273)}[(Ms=new WeakMap,Fs=new WeakMap,Ks=new WeakMap,Wp=jp,$b)](){return`Multiaddr(${gl(this.bytes)})`}};function oe(t){return new dr(t)}var bl=C(G(),1);function Yb(t){let e=t.getPeerId();if(e==null)throw(0,bl.default)(new Error(`${t.toString()} does not have a valid peer type`),b.ERR_INVALID_MULTIADDR);try{return me(e)}catch{throw(0,bl.default)(new Error(`${t.toString()} is not a valid peer type`),b.ERR_INVALID_MULTIADDR)}}function Kr(t){if(Qn(t))return{id:t,multiaddrs:[],protocols:[]};let e;return Fr(t)&&(e=t,t=Yb(t)),{id:t,multiaddrs:e!=null?[e]:[],protocols:[]}}var Wb=t=>t,xa=class extends Ue{constructor(e,r){super();let{listen:n=[],announce:i=[]}=r;this.components=e,this.listen=n.map(s=>s.toString()),this.announce=new Set(i.map(s=>s.toString())),this.observed=new Set,this.announceFilter=r.announceFilter??Wb}getListenAddrs(){return Array.from(this.listen).map(e=>oe(e))}getAnnounceAddrs(){return Array.from(this.announce).map(e=>oe(e))}getObservedAddrs(){return Array.from(this.observed).map(e=>oe(e))}confirmObservedAddr(e){}removeObservedAddr(e){}addObservedAddr(e){let r=oe(e),n=r.getPeerId();n!=null&&me(n).equals(this.components.peerId)&&(r=r.decapsulate(oe(`/p2p/${this.components.peerId.toString()}`)));let i=r.toString();this.observed.has(i)||(this.observed.add(i),this.dispatchEvent(new X("change:addresses")))}getAddresses(){let e=this.getAnnounceAddrs().map(n=>n.toString());e.length===0&&(e=this.components.transportManager.getAddrs().map(n=>n.toString())),e=e.concat(this.getObservedAddrs().map(n=>n.toString()));let r=new Set(e);return this.announceFilter(Array.from(r).map(n=>oe(n))).map(n=>n.getPeerId()===this.components.peerId.toString()?n:n.encapsulate(`/p2p/${this.components.peerId.toString()}`))}};var Ra=C(G(),1);var a0=C(o0(),1),pr=a0.default;var c0=M("libp2p:connection-manager:latency-monitor:visibility-change-emitter"),_a=class extends Ue{constructor(){super(),this.hidden="hidden",this.visibilityChange="visibilityChange",globalThis.document!=null&&(this._initializeVisibilityVarNames(),this._addVisibilityChangeListener())}_initializeVisibilityVarNames(){let e="hidden",r="visibilitychange";typeof globalThis.document.hidden<"u"?(e="hidden",r="visibilitychange"):typeof globalThis.document.mozHidden<"u"?(e="mozHidden",r="mozvisibilitychange"):typeof globalThis.document.msHidden<"u"?(e="msHidden",r="msvisibilitychange"):typeof globalThis.document.webkitHidden<"u"&&(e="webkitHidden",r="webkitvisibilitychange"),this.hidden=e,this.visibilityChange=r}_addVisibilityChangeListener(){typeof globalThis.document.addEventListener>"u"||typeof document[this.hidden]>"u"?c0("Checking page visibility requires a browser that supports the Page Visibility API."):globalThis.document.addEventListener(this.visibilityChange,this._handleVisibilityChange.bind(this),!1)}isVisible(){if(!(this.hidden===void 0||document[this.hidden]===void 0))return document[this.hidden]==null}_handleVisibilityChange(){let e=globalThis.document[this.hidden]===!1;c0(e?"Page Visible":"Page Hidden"),this.dispatchEvent(new X("visibilityChange",{detail:e}))}};var Vr=M("libp2p:connection-manager:latency-monitor"),Aa=class extends Ue{constructor(e={}){super();let{latencyCheckIntervalMs:r,dataEmitIntervalMs:n,asyncTestFn:i,latencyRandomPercentage:s}=e;this.latencyCheckIntervalMs=r??500,this.latencyRandomPercentage=s??10,this.latencyCheckMultiply=2*(this.latencyRandomPercentage/100)*this.latencyCheckIntervalMs,this.latencyCheckSubtract=this.latencyCheckMultiply/2,this.dataEmitIntervalMs=n===null||n===0?void 0:n??5*1e3,Vr("latencyCheckIntervalMs: %s dataEmitIntervalMs: %s",this.latencyCheckIntervalMs,this.dataEmitIntervalMs),this.dataEmitIntervalMs!=null?Vr("Expecting ~%s events per summary",this.latencyCheckIntervalMs/this.dataEmitIntervalMs):Vr("Not emitting summaries"),this.asyncTestFn=i,globalThis.process?.hrtime!=null?(Vr("Using process.hrtime for timing"),this.now=globalThis.process.hrtime,this.getDeltaMS=o=>{let a=this.now(o);return a[0]*1e3+a[1]/1e6}):typeof window<"u"&&window.performance?.now!=null?(Vr("Using performance.now for timing"),this.now=window.performance.now.bind(window.performance),this.getDeltaMS=o=>Math.round(this.now()-o)):(Vr("Using Date.now for timing"),this.now=Date.now,this.getDeltaMS=o=>this.now()-o),this.latencyData=this.initLatencyData()}start(){e2()&&(this.visibilityChangeEmitter=new _a,this.visibilityChangeEmitter.addEventListener("visibilityChange",e=>{let{detail:r}=e;r?this._startTimers():(this._emitSummary(),this._stopTimers())})),this.visibilityChangeEmitter?.isVisible()===!0&&this._startTimers()}stop(){this._stopTimers()}_startTimers(){this.checkLatencyID==null&&(this.checkLatency(),this.dataEmitIntervalMs!=null&&(this.emitIntervalID=setInterval(()=>this._emitSummary(),this.dataEmitIntervalMs),typeof this.emitIntervalID.unref=="function"&&this.emitIntervalID.unref()))}_stopTimers(){this.checkLatencyID!=null&&(clearTimeout(this.checkLatencyID),this.checkLatencyID=void 0),this.emitIntervalID!=null&&(clearInterval(this.emitIntervalID),this.emitIntervalID=void 0)}_emitSummary(){let e=this.getSummary();e.events>0&&this.dispatchEvent(new X("data",{detail:e}))}getSummary(){let e={events:this.latencyData.events,minMs:this.latencyData.minMs,maxMs:this.latencyData.maxMs,avgMs:this.latencyData.events>0?this.latencyData.totalMs/this.latencyData.events:Number.POSITIVE_INFINITY,lengthMs:this.getDeltaMS(this.latencyData.startTime)};return this.latencyData=this.initLatencyData(),Vr.trace("Summary: %O",e),e}checkLatency(){let e=Math.random()*this.latencyCheckMultiply-this.latencyCheckSubtract,r={deltaOffset:Math.ceil(this.latencyCheckIntervalMs+e),startTime:this.now()},n=()=>{if(this.checkLatencyID==null)return;let i=this.getDeltaMS(r.startTime)-r.deltaOffset;this.checkLatency(),this.latencyData.events++,this.latencyData.minMs=Math.min(this.latencyData.minMs,i),this.latencyData.maxMs=Math.max(this.latencyData.maxMs,i),this.latencyData.totalMs+=i,Vr.trace("MS: %s Data: %O",i,this.latencyData)};Vr.trace("localData: %O",r),this.checkLatencyID=setTimeout(()=>{this.asyncTestFn!=null?(r.deltaOffset=0,r.startTime=this.now(),this.asyncTestFn(n)):(r.deltaOffset-=1,n())},r.deltaOffset),typeof this.checkLatencyID.unref=="function"&&this.checkLatencyID.unref()}initLatencyData(){return{startTime:this.now(),minMs:Number.POSITIVE_INFINITY,maxMs:Number.NEGATIVE_INFINITY,events:0,totalMs:0}}};function e2(){return typeof globalThis.window<"u"}var Na=C(fr(),1);var Ca="OPEN",_l="CLOSING",Ia="CLOSED";function qr(t,e){let r={[Symbol.iterator]:()=>r,next:()=>{let n=t.next(),i=n.value;return n.done===!0||i==null?{done:!0,value:void 0}:{done:!1,value:e(i)}}};return r}var Vs=class{constructor(e){if(this.map=new Map,e!=null)for(let[r,n]of e.entries())this.map.set(r.toString(),n)}[Symbol.iterator](){return this.entries()}clear(){this.map.clear()}delete(e){this.map.delete(e.toString())}entries(){return qr(this.map.entries(),e=>[me(e[0]),e[1]])}forEach(e){this.map.forEach((r,n)=>{e(r,me(n),this)})}get(e){return this.map.get(e.toString())}has(e){return this.map.has(e.toString())}set(e,r){this.map.set(e.toString(),r)}keys(){return qr(this.map.keys(),e=>me(e))}values(){return this.map.values()}get size(){return this.map.size}};var Hr=class{constructor(e){if(this.set=new Set,e!=null)for(let r of e)this.set.add(r.toString())}get size(){return this.set.size}[Symbol.iterator](){return this.values()}add(e){this.set.add(e.toString())}clear(){this.set.clear()}delete(e){this.set.delete(e.toString())}entries(){return qr(this.set.entries(),e=>{let r=me(e[0]);return[r,r]})}forEach(e){this.set.forEach(r=>{let n=me(r);e(n,n,this)})}has(e){return this.set.has(e.toString())}values(){return qr(this.set.values(),e=>me(e))}intersection(e){let r=new Hr;for(let n of e)this.has(n)&&r.add(n);return r}difference(e){let r=new Hr;for(let n of this)e.has(n)||r.add(n);return r}union(e){let r=new Hr;for(let n of e)r.add(n);for(let n of this)r.add(n);return r}};var zi=class{constructor(e){if(this.list=[],e!=null)for(let r of e)this.list.push(r.toString())}[Symbol.iterator](){return qr(this.list.entries(),e=>me(e[1]))}concat(e){let r=new zi(this);for(let n of e)r.push(n);return r}entries(){return qr(this.list.entries(),e=>[e[0],me(e[1])])}every(e){return this.list.every((r,n)=>e(me(r),n,this))}filter(e){let r=new zi;return this.list.forEach((n,i)=>{let s=me(n);e(s,i,this)&&r.push(s)}),r}find(e){let r=this.list.find((n,i)=>e(me(n),i,this));if(r!=null)return me(r)}findIndex(e){return this.list.findIndex((r,n)=>e(me(r),n,this))}forEach(e){this.list.forEach((r,n)=>{e(me(r),n,this)})}includes(e){return this.list.includes(e.toString())}indexOf(e){return this.list.indexOf(e.toString())}pop(){let e=this.list.pop();if(e!=null)return me(e)}push(...e){for(let r of e)this.list.push(r.toString())}shift(){let e=this.list.shift();if(e!=null)return me(e)}unshift(...e){let r=this.list.length;for(let n=e.length-1;n>-1;n--)r=this.list.unshift(e[n].toString());return r}get length(){return this.list.length}};var Ml=C(Ur(),1);var u0="keep-alive";var sm=C(im(),1);var et=M("libp2p:connection-manager"),U2={maxConnections:1/0,minConnections:0,maxEventLoopDelay:1/0,pollInterval:2e3,autoDialInterval:1e4,inboundConnectionThreshold:5,maxIncomingPendingConnections:10},M2=6e4,Da=class extends Ue{constructor(e,r){if(super(),this.opts=pr.call({ignoreUndefined:!0},U2,r),this.opts.maxConnections<this.opts.minConnections)throw(0,Ra.default)(new Error("Connection Manager maxConnections must be greater than minConnections"),b.ERR_INVALID_PARAMETERS);et("options: %o",this.opts),this.components=e,this.connections=new Map,this.started=!1,this.latencyMonitor=new Aa({latencyCheckIntervalMs:r.pollInterval,dataEmitIntervalMs:r.pollInterval});try{(0,Na.setMaxListeners)?.(1/0,this)}catch{}this.onConnect=this.onConnect.bind(this),this.onDisconnect=this.onDisconnect.bind(this),this.startupReconnectTimeout=r.startupReconnectTimeout??M2,this.dialTimeout=r.dialTimeout??3e4,this.allow=(r.allow??[]).map(n=>oe(n)),this.deny=(r.deny??[]).map(n=>oe(n)),this.inboundConnectionRateLimiter=new sm.RateLimiterMemory({points:this.opts.inboundConnectionThreshold,duration:1}),this.incomingPendingConnections=0}isStarted(){return this.started}async start(){this.components.metrics?.registerMetricGroup("libp2p_connection_manager_connections",{calculate:()=>{let e={inbound:0,outbound:0};for(let r of this.connections.values())for(let n of r)n.stat.direction==="inbound"?e.inbound++:e.outbound++;return e}}),this.components.metrics?.registerMetricGroup("libp2p_protocol_streams_total",{label:"protocol",calculate:()=>{let e={};for(let r of this.connections.values())for(let n of r)for(let i of n.streams){let s=`${i.stat.direction} ${i.stat.protocol??"unnegotiated"}`;e[s]=(e[s]??0)+1}return e}}),this.components.metrics?.registerMetricGroup("libp2p_connection_manager_protocol_streams_per_connection_90th_percentile",{label:"protocol",calculate:()=>{let e={};for(let n of this.connections.values())for(let i of n){let s={};for(let o of i.streams){let a=`${o.stat.direction} ${o.stat.protocol??"unnegotiated"}`;s[a]=(s[a]??0)+1}for(let[o,a]of Object.entries(s))e[o]=e[o]??[],e[o].push(a)}let r={};for(let[n,i]of Object.entries(e)){i=i.sort((o,a)=>o-a);let s=Math.floor(i.length*.9);r[n]=i[s]}return r}}),this.latencyMonitor.start(),this._onLatencyMeasure=this._onLatencyMeasure.bind(this),this.latencyMonitor.addEventListener("data",this._onLatencyMeasure),this.started=!0,et("started")}async afterStart(){this.components.upgrader.addEventListener("connection",this.onConnect),this.components.upgrader.addEventListener("connectionEnd",this.onDisconnect),Promise.resolve().then(async()=>{let e=[];for(let r of await this.components.peerStore.all())(await this.components.peerStore.getTags(r.id)).filter(s=>s.name===u0).length>0&&e.push(r.id);this.connectOnStartupController?.clear(),this.connectOnStartupController=new Ml.TimeoutController(this.startupReconnectTimeout);try{(0,Na.setMaxListeners)?.(1/0,this.connectOnStartupController.signal)}catch{}await Promise.all(e.map(async r=>{await this.openConnection(r,{signal:this.connectOnStartupController?.signal}).catch(n=>{et.error(n)})}))}).catch(e=>{et.error(e)}).finally(()=>{this.connectOnStartupController?.clear()})}async beforeStop(){this.connectOnStartupController?.abort(),this.components.upgrader.removeEventListener("connection",this.onConnect),this.components.upgrader.removeEventListener("connectionEnd",this.onDisconnect)}async stop(){this.latencyMonitor.removeEventListener("data",this._onLatencyMeasure),this.latencyMonitor.stop(),this.started=!1,await this._close(),et("stopped")}async _close(){let e=[];for(let r of this.connections.values())for(let n of r)e.push((async()=>{try{await n.close()}catch(i){et.error(i)}})());et("closing %d connections",e.length),await Promise.all(e),this.connections.clear()}onConnect(e){this._onConnect(e).catch(r=>{et.error(r)})}async _onConnect(e){let{detail:r}=e;if(!this.started){await r.close();return}let n=r.remotePeer,i=n.toString(),s=this.connections.get(i);s!=null?s.push(r):this.connections.set(i,[r]),n.publicKey!=null&&await this.components.peerStore.keyBook.set(n,n.publicKey);let o=this.getConnections().length,a=o-this.opts.maxConnections;await this._checkMaxLimit("maxConnections",o,a),this.dispatchEvent(new X("peer:connect",{detail:r}))}onDisconnect(e){let{detail:r}=e;if(!this.started)return;let n=r.remotePeer.toString(),i=this.connections.get(n);i!=null&&i.length>1?(i=i.filter(s=>s.id!==r.id),this.connections.set(n,i)):i!=null&&(this.connections.delete(n),this.dispatchEvent(new X("peer:disconnect",{detail:r})))}getConnections(e){if(e!=null)return this.connections.get(e.toString())??[];let r=[];for(let n of this.connections.values())r=r.concat(n);return r}async openConnection(e,r={}){let n;if(Qn(e))n=e;else if(Fr(e))n=Kr(e).id;else throw(0,Ra.default)(new TypeError("Can only open connections to PeerIds or Multiaddrs"),b.ERR_INVALID_PARAMETERS);et("dial to %p",n);let i=this.getConnections(n);if(i.length>0)return et("had an existing connection to %p",n),i[0];let s;if(r?.signal==null){s=new Ml.TimeoutController(this.dialTimeout),r.signal=s.signal;try{(0,Na.setMaxListeners)?.(1/0,s.signal)}catch{}}try{let o=await this.components.dialer.dial(e,r),a=this.connections.get(n.toString());a==null&&(a=[],this.connections.set(n.toString(),a));let c=!1;for(let u of a)u.id===o.id&&(c=!0);return c||a.push(o),o}finally{s?.clear()}}async closeConnections(e){let r=this.connections.get(e.toString())??[];await Promise.all(r.map(async n=>await n.close()))}getAll(e){if(!Qn(e))throw(0,Ra.default)(new Error("peerId must be an instance of peer-id"),b.ERR_INVALID_PARAMETERS);let r=e.toString(),n=this.connections.get(r);return n!=null?n.filter(i=>i.stat.status===Ca):[]}_onLatencyMeasure(e){let{detail:r}=e;this._checkMaxLimit("maxEventLoopDelay",r.avgMs,1).catch(n=>{et.error(n)})}async _checkMaxLimit(e,r,n=1){let i=this.opts[e];if(i==null){et.trace("limit %s was not set so it cannot be applied",e);return}et.trace("checking limit of %s. current value: %d of %d",e,r,i),r>i&&(et("%s: limit exceeded: %p, %d/%d, pruning %d connection(s)",this.components.peerId,e,r,i,n),await this._pruneConnections(n))}async _pruneConnections(e){let r=this.getConnections(),n=new Vs;for(let o of r){let a=o.remotePeer;if(n.has(a))continue;let c=await this.components.peerStore.getTags(a);n.set(a,c.reduce((u,l)=>u+l.value,0))}let i=r.sort((o,a)=>{let c=n.get(o.remotePeer)??0,u=n.get(a.remotePeer)??0;return c>u?1:c<u?-1:0}),s=[];for(let o of i)if(et("too many connections open - closing a connection to %p",o.remotePeer),s.push(o),s.length===e)break;await Promise.all(s.map(async o=>{try{await o.close()}catch(a){et.error(a)}this.onDisconnect(new X("connectionEnd",{detail:o}))}))}async acceptIncomingConnection(e){if(this.deny.some(i=>e.remoteAddr.toString().startsWith(i.toString())))return et("connection from %s refused - connection remote address was in deny list",e.remoteAddr),!1;if(this.allow.some(i=>e.remoteAddr.toString().startsWith(i.toString())))return this.incomingPendingConnections++,!0;if(this.incomingPendingConnections===this.opts.maxIncomingPendingConnections)return et("connection from %s refused - incomingPendingConnections exceeded by peer %s",e.remoteAddr),!1;if(e.remoteAddr.isThinWaistAddress()){let i=e.remoteAddr.nodeAddress().address;try{await this.inboundConnectionRateLimiter.consume(i,1)}catch{return et("connection from %s refused - inboundConnectionThreshold exceeded by host %s",i,e.remoteAddr),!1}}return this.getConnections().length<this.opts.maxConnections?(this.incomingPendingConnections++,!0):(et("connection from %s refused - maxConnections exceeded",e.remoteAddr),!1)}afterUpgradeInbound(){this.incomingPendingConnections--}};var Fl=C(tl(),1);async function zr(t){let e=[];for await(let r of t)e.push(r);return e}async function*zs(t,e){yield*(await zr(t)).sort(e)}var yn=M("libp2p:connection-manager:auto-dialler"),F2={enabled:!0,minConnections:0,autoDialInterval:1e4},La=class{constructor(e,r){this.components=e,this.options=pr.call({ignoreUndefined:!0},F2,r),this.running=!1,this._autoDial=this._autoDial.bind(this),yn("options: %j",this.options)}isStarted(){return this.running}async start(){if(!this.options.enabled){yn("not enabled");return}this.running=!0,this._autoDial().catch(e=>{yn.error("could start autodial",e)}),yn("started")}async stop(){if(!this.options.enabled){yn("not enabled");return}this.running=!1,this.autoDialTimeout!=null&&this.autoDialTimeout.clear(),yn("stopped")}async _autoDial(){this.autoDialTimeout!=null&&this.autoDialTimeout.clear();let e=this.options.minConnections;if(this.components.connectionManager.getConnections().length>=e){this.autoDialTimeout=(0,Fl.default)(this._autoDial,this.options.autoDialInterval);return}let r=await this.components.peerStore.all(),n=await Ce(r.sort(()=>Math.random()>.5?1:-1),i=>kr(i,s=>!s.id.equals(this.components.peerId)),i=>zs(i,(s,o)=>o.protocols.length>s.protocols.length||o.id.publicKey!=null&&s.id.publicKey==null?1:-1),async i=>await zr(i));for(let i=0;this.running&&i<n.length&&this.components.connectionManager.getConnections().length<e;i++){if(!this.running)return;let s=n[i];if(this.components.connectionManager.getConnections(s.id).length===0){yn("connecting to a peerStore stored peer %p",s.id);try{await this.components.connectionManager.openConnection(s.id)}catch(o){yn.error("could not connect to peerStore stored peer",o)}}}this.running&&(this.autoDialTimeout=(0,Fl.default)(this._autoDial,this.options.autoDialInterval))}};var yy=C(G(),1);var K2=W("dns4"),V2=W("dns6"),q2=W("dnsaddr"),Qi=mt(W("dns"),q2,K2,V2),Pa=mt(W("ip4"),W("ip6")),Ws=mt(ee(Pa,W("tcp")),ee(Qi,W("tcp"))),am=ee(Pa,W("udp")),H2=ee(am,W("utp")),z2=ee(am,W("quic")),$s=mt(ee(Ws,W("ws")),ee(Qi,W("ws"))),Gs=mt(ee(Ws,W("wss")),ee(Qi,W("wss"))),Kl=mt(ee(Ws,W("http")),ee(Pa,W("http")),ee(Qi,W("http"))),Vl=mt(ee(Ws,W("https")),ee(Pa,W("https")),ee(Qi,W("https"))),cm=mt(ee($s,W("p2p-webrtc-star"),W("p2p")),ee(Gs,W("p2p-webrtc-star"),W("p2p")),ee($s,W("p2p-webrtc-star")),ee(Gs,W("p2p-webrtc-star"))),qL=mt(ee($s,W("p2p-websocket-star"),W("p2p")),ee(Gs,W("p2p-websocket-star"),W("p2p")),ee($s,W("p2p-websocket-star")),ee(Gs,W("p2p-websocket-star"))),um=mt(ee(Kl,W("p2p-webrtc-direct"),W("p2p")),ee(Vl,W("p2p-webrtc-direct"),W("p2p")),ee(Kl,W("p2p-webrtc-direct")),ee(Vl,W("p2p-webrtc-direct"))),Ys=mt($s,Gs,Kl,Vl,cm,um,Ws,H2,z2,Qi),HL=mt(ee(Ys,W("p2p-stardust"),W("p2p")),ee(Ys,W("p2p-stardust"))),gn=mt(ee(Ys,W("p2p")),cm,um,W("p2p")),om=mt(ee(gn,W("p2p-circuit"),gn),ee(gn,W("p2p-circuit")),ee(W("p2p-circuit"),gn),ee(Ys,W("p2p-circuit")),ee(W("p2p-circuit"),Ys),W("p2p-circuit")),lm=()=>mt(ee(om,lm),om),ei=lm(),zL=mt(ee(ei,gn,ei),ee(gn,ei),ee(ei,gn),ei,gn);function fm(t){function e(r){let n;try{n=oe(r)}catch{return!1}let i=t(n.protoNames());return i===null?!1:i===!0||i===!1?i:i.length===0}return e}function ee(...t){function e(r){if(r.length<t.length)return null;let n=r;return t.some(i=>(n=typeof i=="function"?i().partialMatch(r):i.partialMatch(r),Array.isArray(n)&&(r=n),n===null)),n}return{toString:function(){return"{ "+t.join(" ")+" }"},input:t,matches:fm(e),partialMatch:e}}function mt(...t){function e(n){let i=null;return t.some(s=>{let o=typeof s=="function"?s().partialMatch(n):s.partialMatch(n);return o!=null?(i=o,!0):!1}),i}return{toString:function(){return"{ "+t.join(" ")+" }"},input:t,matches:fm(e),partialMatch:e}}function W(t){let e=t;function r(i){let s;try{s=oe(i)}catch{return!1}let o=s.protoNames();return o.length===1&&o[0]===e}function n(i){return i.length===0?null:i[0]===e?i.slice(1):null}return{toString:function(){return e},matches:r,partialMatch:n}}var ef=C(Gl(),1),Zm=C(zm(),1),tf=C(Jl(),1),Jm=C(jm(),1),ey=C(ri(),1);function eS(){ey.default._configure(),ef.default._configure(Zm.default),tf.default._configure(Jm.default)}eS();var ty=["uint64","int64","sint64","fixed64","sfixed64"];function tS(t){for(let e of ty){if(t[e]==null)continue;let r=t[e];t[e]=function(){return BigInt(r.call(this).toString())}}return t}function rf(t){return tS(new ef.default(t))}function rS(t){for(let e of ty){if(t[e]==null)continue;let r=t[e];t[e]=function(n){return r.call(this,n.toString())}}return t}function nf(){return rS(tf.default.create())}function Te(t,e){let r=rf(t instanceof Uint8Array?t:t.subarray());return e.decode(r)}function Re(t,e){let r=nf();return e.encode(t,r,{lengthDelimited:!1}),r.finish()}var ji;(function(t){t[t.VARINT=0]="VARINT",t[t.BIT64=1]="BIT64",t[t.LENGTH_DELIMITED=2]="LENGTH_DELIMITED",t[t.START_GROUP=3]="START_GROUP",t[t.END_GROUP=4]="END_GROUP",t[t.BIT32=5]="BIT32"})(ji||(ji={}));function Ma(t,e,r,n){return{name:t,type:e,encode:r,decode:n}}function wn(t){function e(i){if(t[i.toString()]==null)throw new Error("Invalid enum value");return t[i]}let r=function(s,o){let a=e(s);o.int32(a)},n=function(s){let o=s.int32();return e(o)};return Ma("enum",ji.VARINT,r,n)}function Ne(t,e){return Ma("message",ji.LENGTH_DELIMITED,t,e)}var j;(function(t){let e;(function(a){a.SUCCESS="SUCCESS",a.HOP_SRC_ADDR_TOO_LONG="HOP_SRC_ADDR_TOO_LONG",a.HOP_DST_ADDR_TOO_LONG="HOP_DST_ADDR_TOO_LONG",a.HOP_SRC_MULTIADDR_INVALID="HOP_SRC_MULTIADDR_INVALID",a.HOP_DST_MULTIADDR_INVALID="HOP_DST_MULTIADDR_INVALID",a.HOP_NO_CONN_TO_DST="HOP_NO_CONN_TO_DST",a.HOP_CANT_DIAL_DST="HOP_CANT_DIAL_DST",a.HOP_CANT_OPEN_DST_STREAM="HOP_CANT_OPEN_DST_STREAM",a.HOP_CANT_SPEAK_RELAY="HOP_CANT_SPEAK_RELAY",a.HOP_CANT_RELAY_TO_SELF="HOP_CANT_RELAY_TO_SELF",a.STOP_SRC_ADDR_TOO_LONG="STOP_SRC_ADDR_TOO_LONG",a.STOP_DST_ADDR_TOO_LONG="STOP_DST_ADDR_TOO_LONG",a.STOP_SRC_MULTIADDR_INVALID="STOP_SRC_MULTIADDR_INVALID",a.STOP_DST_MULTIADDR_INVALID="STOP_DST_MULTIADDR_INVALID",a.STOP_RELAY_REFUSED="STOP_RELAY_REFUSED",a.MALFORMED_MESSAGE="MALFORMED_MESSAGE"})(e=t.Status||(t.Status={}));let r;(function(a){a[a.SUCCESS=100]="SUCCESS",a[a.HOP_SRC_ADDR_TOO_LONG=220]="HOP_SRC_ADDR_TOO_LONG",a[a.HOP_DST_ADDR_TOO_LONG=221]="HOP_DST_ADDR_TOO_LONG",a[a.HOP_SRC_MULTIADDR_INVALID=250]="HOP_SRC_MULTIADDR_INVALID",a[a.HOP_DST_MULTIADDR_INVALID=251]="HOP_DST_MULTIADDR_INVALID",a[a.HOP_NO_CONN_TO_DST=260]="HOP_NO_CONN_TO_DST",a[a.HOP_CANT_DIAL_DST=261]="HOP_CANT_DIAL_DST",a[a.HOP_CANT_OPEN_DST_STREAM=262]="HOP_CANT_OPEN_DST_STREAM",a[a.HOP_CANT_SPEAK_RELAY=270]="HOP_CANT_SPEAK_RELAY",a[a.HOP_CANT_RELAY_TO_SELF=280]="HOP_CANT_RELAY_TO_SELF",a[a.STOP_SRC_ADDR_TOO_LONG=320]="STOP_SRC_ADDR_TOO_LONG",a[a.STOP_DST_ADDR_TOO_LONG=321]="STOP_DST_ADDR_TOO_LONG",a[a.STOP_SRC_MULTIADDR_INVALID=350]="STOP_SRC_MULTIADDR_INVALID",a[a.STOP_DST_MULTIADDR_INVALID=351]="STOP_DST_MULTIADDR_INVALID",a[a.STOP_RELAY_REFUSED=390]="STOP_RELAY_REFUSED",a[a.MALFORMED_MESSAGE=400]="MALFORMED_MESSAGE"})(r||(r={})),function(a){a.codec=()=>wn(r)}(e=t.Status||(t.Status={}));let n;(function(a){a.HOP="HOP",a.STOP="STOP",a.STATUS="STATUS",a.CAN_HOP="CAN_HOP"})(n=t.Type||(t.Type={}));let i;(function(a){a[a.HOP=1]="HOP",a[a.STOP=2]="STOP",a[a.STATUS=3]="STATUS",a[a.CAN_HOP=4]="CAN_HOP"})(i||(i={})),function(a){a.codec=()=>wn(i)}(n=t.Type||(t.Type={}));let s;(function(a){let c;a.codec=()=>(c==null&&(c=Ne((u,l,f={})=>{if(f.lengthDelimited!==!1&&l.fork(),(f.writeDefaults===!0||u.id!=null&&u.id.byteLength>0)&&(l.uint32(10),l.bytes(u.id)),u.addrs!=null)for(let h of u.addrs)l.uint32(18),l.bytes(h);f.lengthDelimited!==!1&&l.ldelim()},(u,l)=>{let f={id:new Uint8Array(0),addrs:[]},h=l==null?u.len:u.pos+l;for(;u.pos<h;){let d=u.uint32();switch(d>>>3){case 1:f.id=u.bytes();break;case 2:f.addrs.push(u.bytes());break;default:u.skipType(d&7);break}}return f})),c),a.encode=u=>Re(u,a.codec()),a.decode=u=>Te(u,a.codec())})(s=t.Peer||(t.Peer={}));let o;t.codec=()=>(o==null&&(o=Ne((a,c,u={})=>{u.lengthDelimited!==!1&&c.fork(),a.type!=null&&(c.uint32(8),t.Type.codec().encode(a.type,c)),a.srcPeer!=null&&(c.uint32(18),t.Peer.codec().encode(a.srcPeer,c,{writeDefaults:!1})),a.dstPeer!=null&&(c.uint32(26),t.Peer.codec().encode(a.dstPeer,c,{writeDefaults:!1})),a.code!=null&&(c.uint32(32),t.Status.codec().encode(a.code,c)),u.lengthDelimited!==!1&&c.ldelim()},(a,c)=>{let u={},l=c==null?a.len:a.pos+c;for(;a.pos<l;){let f=a.uint32();switch(f>>>3){case 1:u.type=t.Type.codec().decode(a);break;case 2:u.srcPeer=t.Peer.codec().decode(a,a.uint32());break;case 3:u.dstPeer=t.Peer.codec().decode(a,a.uint32());break;case 4:u.code=t.Status.codec().decode(a);break;default:a.skipType(f&7);break}}return u})),o),t.encode=a=>Re(a,t.codec()),t.decode=a=>Te(a,t.codec())})(j||(j={}));var js=class extends Error{constructor(e,r){super(e??"The operation was aborted"),this.type="aborted",this.code=r??"ABORT_ERR"}};function ry(t){if(t!=null){if(typeof t[Symbol.iterator]=="function")return t[Symbol.iterator]();if(typeof t[Symbol.asyncIterator]=="function")return t[Symbol.asyncIterator]();if(typeof t.next=="function")return t}throw new Error("argument is not an iterator or iterable")}function ii(t,e,r){let n=r??{},i=ry(t);async function*s(){let o,a=()=>{o?.()};for(e.addEventListener("abort",a);;){let c;try{if(e.aborted){let{abortMessage:l,abortCode:f}=n;throw new js(l,f)}let u=new Promise((l,f)=>{o=()=>{let{abortMessage:h,abortCode:d}=n;f(new js(h,d))}});c=await Promise.race([u,i.next()]),o=null}catch(u){e.removeEventListener("abort",a);let l=u.type==="aborted"&&e.aborted;if(l&&n.onAbort!=null&&await n.onAbort(t),typeof i.return=="function")try{let f=i.return();f instanceof Promise&&f.catch(h=>{n.onReturnError!=null&&n.onReturnError(h)})}catch(f){n.onReturnError!=null&&n.onReturnError(f)}if(l&&n.returnOnAbort===!0)return;throw u}if(c.done===!0)break;yield c.value}e.removeEventListener("abort",a)}return s()}function nS(t,e,r){return n=>t(ii(n,e,r))}function Dt(t,e,r){return{sink:nS(t.sink,e,{...r,onAbort:void 0}),source:ii(t.source,e,r)}}var iS=M("libp2p:stream:converter");function sf(t,e={}){let{stream:r,remoteAddr:n}=t,{sink:i,source:s}=r,o=async function*(){for await(let u of s)yield*u}(),a={async sink(u){e.signal!=null&&(u=ii(u,e.signal));try{await i(u),await c()}catch(l){l.type!=="aborted"&&iS(l)}},source:e.signal!=null?ii(o,e.signal):o,remoteAddr:n,timeline:{open:Date.now(),close:void 0},async close(){await i(async function*(){yield new Uint8Array(0)}()),await c()}};async function c(){return a.timeline.close==null&&(a.timeline.close=Date.now()),await Promise.resolve()}return a}var gr="/libp2p/circuit/relay/0.1.0";function ny(t){let e=new Map;async function r(s){let o=s.toString().split("/p2p-circuit").find(h=>h!==""),a=oe(o),c=a.getPeerId();if(c==null)throw new Error("Could not determine relay peer from multiaddr");let u=me(c);await t.peerStore.addressBook.add(u,[a]);let l=await t.connectionManager.openConnection(u),f=l.remoteAddr.encapsulate("/p2p-circuit");e.set(l.remotePeer.toString(),f),i.dispatchEvent(new X("listening"))}function n(){let s=[];for(let o of e.values())s.push(o);return s}let i=Object.assign(new Ue,{close:async()=>await Promise.resolve(),listen:r,getAddrs:n});return t.connectionManager.addEventListener("peer:disconnect",s=>{let{detail:o}=s;e.delete(o.remotePeer.toString())&&i.dispatchEvent(new X("close"))}),i}var uf=C(G(),1);function iy(t,e){t.write({type:j.Type.STATUS,code:e})}function Fa(t,e){try{t.dstPeer?.addrs!=null&&t.dstPeer.addrs.forEach(r=>oe(r))}catch(r){throw iy(e,t.type===j.Type.HOP?j.Status.HOP_DST_MULTIADDR_INVALID:j.Status.STOP_DST_MULTIADDR_INVALID),r}try{t.srcPeer?.addrs!=null&&t.srcPeer.addrs.forEach(r=>oe(r))}catch(r){throw iy(e,t.type===j.Type.HOP?j.Status.HOP_SRC_MULTIADDR_INVALID:j.Status.STOP_SRC_MULTIADDR_INVALID),r}}var oy=Symbol.for("@achingbrain/uint8arraylist");function sy(t,e){if(e==null||e<0)throw new RangeError("index is out of bounds");let r=0;for(let n of t){let i=r+n.byteLength;if(e<i)return{buf:n,index:e-r};r=i}throw new RangeError("index is out of bounds")}function Ka(t){return Boolean(t?.[oy])}var Ge=class{constructor(...e){Object.defineProperty(this,oy,{value:!0}),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(Ka(n))r+=n.byteLength,this.bufs.push(...n.bufs);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(Ka(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=sy(this.bufs,e);return r.buf[r.index]}set(e,r){let n=sy(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(Ka(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:i}=this._subList(e,r);return Xe(n,i)}subarray(e,r){let{bufs:n,length:i}=this._subList(e,r);return n.length===1?n[0]:Xe(n,i)}sublist(e,r){let{bufs:n,length:i}=this._subList(e,r),s=new Ge;return s.length=i,s.bufs=n,s}_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=[],i=0;for(let s=0;s<this.bufs.length;s++){let o=this.bufs[s],a=i,c=a+o.byteLength;if(i=c,e>=c)continue;let u=e>=a&&e<c,l=r>a&&r<=c;if(u&&l){if(e===a&&r===c){n.push(o);break}let f=e-a;n.push(o.subarray(f,f+(r-e)));break}if(u){if(e===0){n.push(o);continue}n.push(o.subarray(e-a));continue}if(l){if(r===c){n.push(o);break}n.push(o.subarray(0,r-a));break}n.push(o)}return{bufs:n,length:r-e}}indexOf(e,r=0){if(!Ka(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 i=n.byteLength;if(i===0)throw new TypeError("search must be at least 1 byte long");let s=256,o=new Int32Array(s);for(let f=0;f<s;f++)o[f]=-1;for(let f=0;f<i;f++)o[n[f]]=f;let a=o,c=this.byteLength-n.byteLength,u=n.byteLength-1,l;for(let f=r;f<=c;f+=l){l=0;for(let h=u;h>=0;h--){let d=this.get(f+h);if(n[h]!==d){l=Math.max(1,h-a[d]);break}}if(l===0)return f}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=Br(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 i=Pr(2);new DataView(i.buffer,i.byteOffset,i.byteLength).setInt16(0,r,n),this.write(i,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 i=Pr(4);new DataView(i.buffer,i.byteOffset,i.byteLength).setInt32(0,r,n),this.write(i,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 i=Pr(8);new DataView(i.buffer,i.byteOffset,i.byteLength).setBigInt64(0,r,n),this.write(i,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=Br(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 i=Pr(2);new DataView(i.buffer,i.byteOffset,i.byteLength).setUint16(0,r,n),this.write(i,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 i=Pr(4);new DataView(i.buffer,i.byteOffset,i.byteLength).setUint32(0,r,n),this.write(i,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 i=Pr(8);new DataView(i.buffer,i.byteOffset,i.byteLength).setBigUint64(0,r,n),this.write(i,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 i=Pr(4);new DataView(i.buffer,i.byteOffset,i.byteLength).setFloat32(0,r,n),this.write(i,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 i=Pr(8);new DataView(i.buffer,i.byteOffset,i.byteLength).setFloat64(0,r,n),this.write(i,e)}equals(e){if(e==null||!(e instanceof Ge)||e.bufs.length!==this.bufs.length)return!1;for(let r=0;r<this.bufs.length;r++)if(!_e(this.bufs[r],e.bufs[r]))return!1;return!0}static fromUint8Arrays(e,r){let n=new Ge;return n.bufs=e,r==null&&(r=e.reduce((i,s)=>i+s.byteLength,0)),n.length=r,n}};function Va(t){return t instanceof Uint8Array?{get(e){return t[e]},set(e,r){t[e]=r}}:{get(e){return t.get(e)},set(e,r){t.set(e,r)}}}var ay=4294967296,Lt=class{constructor(e=0,r=0){this.hi=e,this.lo=r}toBigInt(e){if(e===!0)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)}toNumber(e){return Number(this.toBigInt(e))}zzDecode(){let e=-(this.lo&1),r=((this.lo>>>1|this.hi<<31)^e)>>>0,n=(this.hi>>>1^e)>>>0;return new Lt(n,r)}zzEncode(){let e=this.hi>>31,r=((this.hi<<1|this.lo>>>31)^e)>>>0,n=(this.lo<<1^e)>>>0;return new Lt(r,n)}toBytes(e,r=0){let n=Va(e);for(;this.hi>0;)n.set(r++,this.lo&127|128),this.lo=(this.lo>>>7|this.hi<<25)>>>0,this.hi>>>=7;for(;this.lo>127;)n.set(r++,this.lo&127|128),this.lo=this.lo>>>7;n.set(r++,this.lo)}static fromBigInt(e){if(e===0n)return new Lt;let r=e<0;r&&(e=-e);let n=Number(e>>32n)|0,i=Number(e-(BigInt(n)<<32n))|0;return r&&(n=~n>>>0,i=~i>>>0,++i>ay&&(i=0,++n>ay&&(n=0))),new Lt(n,i)}static fromNumber(e){if(e===0)return new Lt;let r=e<0;r&&(e=-e);let n=e>>>0,i=(e-n)/4294967296>>>0;return r&&(i=~i>>>0,n=~n>>>0,++n>4294967295&&(n=0,++i>4294967295&&(i=0))),new Lt(i,n)}static fromBytes(e,r=0){let n=Va(e),i=new Lt,s=0;if(e.length-r>4){for(;s<4;++s)if(i.lo=(i.lo|(n.get(r)&127)<<s*7)>>>0,n.get(r++)<128)return i;if(i.lo=(i.lo|(n.get(r)&127)<<28)>>>0,i.hi=(i.hi|(n.get(r)&127)>>4)>>>0,n.get(r++)<128)return i;s=0}else for(;s<4;++s){if(r>=e.length)throw RangeError(`index out of range: ${r} > ${e.length}`);if(i.lo=(i.lo|(n.get(r)&127)<<s*7)>>>0,n.get(r++)<128)return i}if(e.length-r>4){for(;s<5;++s)if(i.hi=(i.hi|(n.get(r)&127)<<s*7+3)>>>0,n.get(r++)<128)return i}else if(r<e.byteLength)for(;s<5;++s){if(r>=e.length)throw RangeError(`index out of range: ${r} > ${e.length}`);if(i.hi=(i.hi|(n.get(r)&127)<<s*7+3)>>>0,n.get(r++)<128)return i}throw RangeError("invalid varint encoding")}};var sS=Math.pow(2,7),oS=Math.pow(2,14),aS=Math.pow(2,21),cS=Math.pow(2,28),uS=Math.pow(2,35),lS=Math.pow(2,42),fS=Math.pow(2,49),hS=Math.pow(2,56),dS=Math.pow(2,63),er={encodingLength(t){return t<sS?1:t<oS?2:t<aS?3:t<cS?4:t<uS?5:t<lS?6:t<fS?7:t<hS?8:t<dS?9:10},encode(t,e,r=0){if(Number.MAX_SAFE_INTEGER!=null&&t>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return e==null&&(e=Br(er.encodingLength(t))),Lt.fromNumber(t).toBytes(e,r),e},decode(t,e=0){return Lt.fromBytes(t,e).toNumber(!0)}};function cy(t){return globalThis?.Buffer?.allocUnsafe!=null?globalThis.Buffer.allocUnsafe(t):new Uint8Array(t)}var qa=t=>{let e=er.encodingLength(t),r=cy(e);return er.encode(t,r),qa.bytes=e,r};qa.bytes=0;function Vt(t){t=t??{};let e=t.lengthEncoder??qa;return async function*(n){for await(let i of n){let s=e(i.byteLength);s instanceof Uint8Array?yield s:yield*s,i instanceof Uint8Array?yield i:yield*i}}}Vt.single=(t,e)=>{e=e??{};let r=e.lengthEncoder??qa;return new Ge(r(t.byteLength),t)};var Zs=C(G(),1),pS=8,mS=1024*1024*4,si;(function(t){t[t.LENGTH=0]="LENGTH",t[t.DATA=1]="DATA"})(si||(si={}));var of=t=>{let e=er.decode(t);return of.bytes=er.encodingLength(e),e};of.bytes=0;function Pt(t){return async function*(r){let n=new Ge,i=si.LENGTH,s=-1,o=t?.lengthDecoder??of,a=t?.maxLengthLength??pS,c=t?.maxDataLength??mS;for await(let u of r)for(n.append(u);n.byteLength>0;){if(i===si.LENGTH)try{if(s=o(n),s<0)throw(0,Zs.default)(new Error("invalid message length"),"ERR_INVALID_MSG_LENGTH");if(s>c)throw(0,Zs.default)(new Error("message length too long"),"ERR_MSG_DATA_TOO_LONG");let l=o.bytes;n.consume(l),t?.onLength!=null&&t.onLength(s),i=si.DATA}catch(l){if(l instanceof RangeError){if(n.byteLength>a)throw(0,Zs.default)(new Error("message length length too long"),"ERR_MSG_LENGTH_TOO_LONG");break}throw l}if(i===si.DATA){if(n.byteLength<s)break;let l=n.sublist(0,s);n.consume(s),t?.onData!=null&&t.onData(l),yield l,i=si.LENGTH}}if(n.byteLength>0)throw(0,Zs.default)(new Error("unexpected end of input"),"ERR_UNEXPECTED_EOF")}}Pt.fromReader=(t,e)=>{let r=1,n=async function*(){for(;;)try{let{done:s,value:o}=await t.next(r);if(s===!0)return;o!=null&&(yield o)}catch(s){if(s.code==="ERR_UNDER_READ")return{done:!0,value:null};throw s}finally{r=1}}();return Pt({...e??{},onLength:s=>{r=s}})(n)};function af(t){let e=async function*(){let r=yield,n=new Ge;for await(let i of t){if(r==null){n.append(i),r=yield n,n=new Ge;continue}for(n.append(i);n.length>=r;){let s=n.sublist(0,r);if(n.consume(r),r=yield s,r==null){n.length>0&&(r=yield n,n=new Ge);break}}}if(r!=null)throw Object.assign(new Error(`stream ended before ${r} bytes became available`),{code:"ERR_UNDER_READ",buffer:n})}();return e.next(),e}function cf(){let t={};return t.promise=new Promise((e,r)=>{t.resolve=e,t.reject=r}),t}function Zi(t){let e=Wn(),r=af(t.source),n=cf(),i,s=t.sink(async function*(){yield*e,yield*await n.promise}());return s.catch(a=>{i=a}),{reader:r,writer:e,stream:{sink:async a=>i!=null?await Promise.reject(i):(n.resolve(a),await s),source:r},rest:()=>e.end(),write:e.push,read:async()=>{let a=await r.next();if(a.value!=null)return a.value}}}var Js=M("libp2p:circuit:stream-handler"),$r=class{constructor(e){let{stream:r,maxLength:n=4096}=e;this.stream=r,this.shake=Zi(this.stream),this.decoder=Pt.fromReader(this.shake.reader,{maxDataLength:n})}async read(){let e=await this.decoder.next();if(e.value!=null){let r=j.decode(e.value);return Js("read message type",r.type),r}Js("read received no value, closing stream"),this.close()}write(e){Js("write message type %s",e.type),this.shake.write(Vt.single(j.encode(e)))}rest(){return this.shake.rest(),this.shake.stream}end(e){this.write(e),this.close()}close(){Js("closing the stream"),this.rest().sink([]).catch(e=>{Js.error(e)})}};var eo=M("libp2p:circuit:stop");function uy(t){let{connection:e,request:r,streamHandler:n}=t;try{Fa(r,n)}catch(i){eo.error("invalid stop request via peer %p %o",e.remotePeer,i);return}return eo("stop request is valid"),n.write({type:j.Type.STATUS,code:j.Status.SUCCESS}),n.rest()}async function ly(t){let{connection:e,request:r,signal:n}=t,i=await e.newStream(gr,{signal:n});eo("starting stop request to %p",e.remotePeer);let s=new $r({stream:i});s.write(r);let o=await s.read();if(o==null){s.close();return}if(o.code===j.Status.SUCCESS)return eo("stop request to %p was successful",e.remotePeer),s.rest();eo("stop request failed with code %d",o.code),s.close()}var qt=M("libp2p:circuit:hop");async function fy(t){let{connection:e,request:r,streamHandler:n,circuit:i,connectionManager:s}=t;if(!i.hopEnabled())return qt("HOP request received but we are not acting as a relay"),n.end({type:j.Type.STATUS,code:j.Status.HOP_CANT_SPEAK_RELAY});try{Fa(r,n)}catch(f){qt.error("invalid hop request via peer %p %o",e.remotePeer,f);return}if(r.dstPeer==null){qt("HOP request received but we do not receive a dstPeer");return}let o=mn(r.dstPeer.id),a=s.getConnections(o);if(a.length===0&&!i.hopActive())return qt("HOP request received but we are not connected to the destination peer"),n.end({type:j.Type.STATUS,code:j.Status.HOP_NO_CONN_TO_DST});if(a.length===0)return qt("did not have connection to remote peer"),n.end({type:j.Type.STATUS,code:j.Status.HOP_NO_CONN_TO_DST});let c={type:j.Type.STOP,dstPeer:r.dstPeer,srcPeer:r.srcPeer},u;try{qt("performing STOP request");let f=await ly({connection:a[0],request:c});if(f==null)throw new Error("Could not stop");u=f}catch(f){qt.error(f);return}qt("hop request from %p is valid",e.remotePeer),n.write({type:j.Type.STATUS,code:j.Status.SUCCESS});let l=n.rest();return qt("creating related connections"),await Ce(l,u,l)}async function hy(t){let{connection:e,request:r,signal:n}=t,i=await e.newStream(gr,{signal:n}),s=new $r({stream:i});s.write(r);let o=await s.read();if(o==null)throw(0,uf.default)(new Error("HOP request had no response"),b.ERR_HOP_REQUEST_FAILED);if(o.code===j.Status.SUCCESS)return qt("hop request was successful"),s.rest();throw qt("hop request failed with code %d, closing stream",o.code),s.close(),(0,uf.default)(new Error(`HOP request failed with code "${o.code??"unknown"}"`),b.ERR_HOP_REQUEST_FAILED)}async function dy(t){let{connection:e,signal:r}=t,n=await e.newStream(gr,{signal:r}),i=new $r({stream:n});i.write({type:j.Type.CAN_HOP});let s=await i.read();return await i.close(),!(s==null||s.code!==j.Status.SUCCESS)}function py(t){let{connection:e,streamHandler:r,circuit:n}=t,i=n.hopEnabled();qt("can hop (%s) request from %p",i,e.remotePeer),r.end({type:j.Type.STATUS,code:i?j.Status.SUCCESS:j.Status.HOP_CANT_SPEAK_RELAY})}var my=Symbol.for("@libp2p/transport");var xn;(function(t){t[t.FATAL_ALL=0]="FATAL_ALL",t[t.NO_FATAL=1]="NO_FATAL"})(xn||(xn={}));var gy=C(Ur(),1),Ey=C(fr(),1),Ht=M("libp2p:circuit"),za=class{constructor(e,r){this._init=r,this.components=e,this._started=!1}isStarted(){return this._started}async start(){this._started||(this._started=!0,await this.components.registrar.handle(gr,e=>{this._onProtocol(e).catch(r=>{Ht.error(r)})}).catch(e=>{Ht.error(e)}))}async stop(){await this.components.registrar.unhandle(gr)}hopEnabled(){return!0}hopActive(){return!0}get[my](){return!0}get[Symbol.toStringTag](){return"libp2p/circuit-relay-v1"}async _onProtocol(e){let{connection:r,stream:n}=e,i=new gy.TimeoutController(this._init.hop.timeout);try{(0,Ey.setMaxListeners)?.(1/0,i.signal)}catch{}try{let s=Dt(n,i.signal),o=new $r({stream:{...n,...s}}),a=await o.read();if(a==null){Ht("request was invalid, could not read from stream"),o.write({type:j.Type.STATUS,code:j.Status.MALFORMED_MESSAGE}),o.close();return}let c;switch(a.type){case j.Type.CAN_HOP:{Ht("received CAN_HOP request from %p",r.remotePeer),await py({circuit:this,connection:r,streamHandler:o});break}case j.Type.HOP:{Ht("received HOP request from %p",r.remotePeer),await fy({connection:r,request:a,streamHandler:o,circuit:this,connectionManager:this.components.connectionManager});break}case j.Type.STOP:{Ht("received STOP request from %p",r.remotePeer),c=await uy({connection:r,request:a,streamHandler:o});break}default:{Ht("Request of type %s not supported",a.type),o.write({type:j.Type.STATUS,code:j.Status.MALFORMED_MESSAGE}),o.close();return}}if(c!=null){let u=r.remoteAddr.encapsulate("/p2p-circuit").encapsulate(oe(a.dstPeer?.addrs[0])),l=oe(a.srcPeer?.addrs[0]),f=sf({stream:c,remoteAddr:u,localAddr:l}),h=a.type===j.Type.HOP?"relay":"inbound";Ht("new %s connection %s",h,f.remoteAddr);let d=await this.components.upgrader.upgradeInbound(f);Ht("%s connection %s upgraded",h,f.remoteAddr),this.handler!=null&&this.handler(d)}}finally{i.clear()}}async dial(e,r={}){let n=e.toString().split("/p2p-circuit"),i=oe(n[0]),s=oe(n[n.length-1]),o=i.getPeerId(),a=s.getPeerId();if(o==null||a==null){let d="Circuit relay dial failed as addresses did not have peer id";throw Ht.error(d),(0,yy.default)(new Error(d),b.ERR_RELAYED_DIAL)}let c=me(o),u=me(a),l=!1,h=this.components.connectionManager.getConnections(c)[0];h==null&&(await this.components.peerStore.addressBook.add(c,[i]),h=await this.components.connectionManager.openConnection(c,r),l=!0);try{let d=await hy({...r,connection:h,request:{type:j.Type.HOP,srcPeer:{id:this.components.peerId.toBytes(),addrs:this.components.addressManager.getAddresses().map(g=>g.bytes)},dstPeer:{id:u.toBytes(),addrs:[oe(s).bytes]}}}),p=i.encapsulate(`/p2p-circuit/p2p/${this.components.peerId.toString()}`),y=sf({stream:d,remoteAddr:e,localAddr:p});return Ht("new outbound connection %s",y.remoteAddr),await this.components.upgrader.upgradeOutbound(y)}catch(d){throw Ht.error("Circuit relay dial failed",d),l&&await h.close(),d}}createListener(e){return this.handler=e.handler,ny({connectionManager:this.components.connectionManager,peerStore:this.components.peerStore})}filter(e){return e=Array.isArray(e)?e:[e],e.filter(r=>ei.matches(r))}};var Za=C(nl(),1);async function $a(t){let e=new TextEncoder().encode(t),r=await ot.digest(e);return ve.createV0(r)}var lf="hop_relay",ff="true",Ga="/libp2p/relay";var Ay=C(vy(),1);var wy="[a-fA-F\\d:]",bn=t=>t&&t.includeBoundaries?`(?:(?<=\\s|^)(?=${wy})|(?<=${wy})(?=\\s|$))`:"",tr="(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}",tt="[a-fA-F\\d]{1,4}",Ya=`
|
|
37
|
+
`+a+e.substr(o+1),s=i-o-1,o=-1,++i}else(e[i]===" "||e[i]===" "||e[i]===",")&&(o=i);return e}function r_(t){return t.replace(/^\s+/,"")}});var cg=R((U4,ag)=>{var is=ie();An();De();var U=is.asn1,ss=ag.exports=is.pkcs7asn1=is.pkcs7asn1||{};is.pkcs7=is.pkcs7||{};is.pkcs7.asn1=ss;var sg={name:"ContentInfo",tagClass:U.Class.UNIVERSAL,type:U.Type.SEQUENCE,constructed:!0,value:[{name:"ContentInfo.ContentType",tagClass:U.Class.UNIVERSAL,type:U.Type.OID,constructed:!1,capture:"contentType"},{name:"ContentInfo.content",tagClass:U.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,captureAsn1:"content"}]};ss.contentInfoValidator=sg;var og={name:"EncryptedContentInfo",tagClass:U.Class.UNIVERSAL,type:U.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedContentInfo.contentType",tagClass:U.Class.UNIVERSAL,type:U.Type.OID,constructed:!1,capture:"contentType"},{name:"EncryptedContentInfo.contentEncryptionAlgorithm",tagClass:U.Class.UNIVERSAL,type:U.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedContentInfo.contentEncryptionAlgorithm.algorithm",tagClass:U.Class.UNIVERSAL,type:U.Type.OID,constructed:!1,capture:"encAlgorithm"},{name:"EncryptedContentInfo.contentEncryptionAlgorithm.parameter",tagClass:U.Class.UNIVERSAL,captureAsn1:"encParameter"}]},{name:"EncryptedContentInfo.encryptedContent",tagClass:U.Class.CONTEXT_SPECIFIC,type:0,capture:"encryptedContent",captureAsn1:"encryptedContentAsn1"}]};ss.envelopedDataValidator={name:"EnvelopedData",tagClass:U.Class.UNIVERSAL,type:U.Type.SEQUENCE,constructed:!0,value:[{name:"EnvelopedData.Version",tagClass:U.Class.UNIVERSAL,type:U.Type.INTEGER,constructed:!1,capture:"version"},{name:"EnvelopedData.RecipientInfos",tagClass:U.Class.UNIVERSAL,type:U.Type.SET,constructed:!0,captureAsn1:"recipientInfos"}].concat(og)};ss.encryptedDataValidator={name:"EncryptedData",tagClass:U.Class.UNIVERSAL,type:U.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedData.Version",tagClass:U.Class.UNIVERSAL,type:U.Type.INTEGER,constructed:!1,capture:"version"}].concat(og)};var n_={name:"SignerInfo",tagClass:U.Class.UNIVERSAL,type:U.Type.SEQUENCE,constructed:!0,value:[{name:"SignerInfo.version",tagClass:U.Class.UNIVERSAL,type:U.Type.INTEGER,constructed:!1},{name:"SignerInfo.issuerAndSerialNumber",tagClass:U.Class.UNIVERSAL,type:U.Type.SEQUENCE,constructed:!0,value:[{name:"SignerInfo.issuerAndSerialNumber.issuer",tagClass:U.Class.UNIVERSAL,type:U.Type.SEQUENCE,constructed:!0,captureAsn1:"issuer"},{name:"SignerInfo.issuerAndSerialNumber.serialNumber",tagClass:U.Class.UNIVERSAL,type:U.Type.INTEGER,constructed:!1,capture:"serial"}]},{name:"SignerInfo.digestAlgorithm",tagClass:U.Class.UNIVERSAL,type:U.Type.SEQUENCE,constructed:!0,value:[{name:"SignerInfo.digestAlgorithm.algorithm",tagClass:U.Class.UNIVERSAL,type:U.Type.OID,constructed:!1,capture:"digestAlgorithm"},{name:"SignerInfo.digestAlgorithm.parameter",tagClass:U.Class.UNIVERSAL,constructed:!1,captureAsn1:"digestParameter",optional:!0}]},{name:"SignerInfo.authenticatedAttributes",tagClass:U.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,capture:"authenticatedAttributes"},{name:"SignerInfo.digestEncryptionAlgorithm",tagClass:U.Class.UNIVERSAL,type:U.Type.SEQUENCE,constructed:!0,capture:"signatureAlgorithm"},{name:"SignerInfo.encryptedDigest",tagClass:U.Class.UNIVERSAL,type:U.Type.OCTETSTRING,constructed:!1,capture:"signature"},{name:"SignerInfo.unauthenticatedAttributes",tagClass:U.Class.CONTEXT_SPECIFIC,type:1,constructed:!0,optional:!0,capture:"unauthenticatedAttributes"}]};ss.signedDataValidator={name:"SignedData",tagClass:U.Class.UNIVERSAL,type:U.Type.SEQUENCE,constructed:!0,value:[{name:"SignedData.Version",tagClass:U.Class.UNIVERSAL,type:U.Type.INTEGER,constructed:!1,capture:"version"},{name:"SignedData.DigestAlgorithms",tagClass:U.Class.UNIVERSAL,type:U.Type.SET,constructed:!0,captureAsn1:"digestAlgorithms"},sg,{name:"SignedData.Certificates",tagClass:U.Class.CONTEXT_SPECIFIC,type:0,optional:!0,captureAsn1:"certificates"},{name:"SignedData.CertificateRevocationLists",tagClass:U.Class.CONTEXT_SPECIFIC,type:1,optional:!0,captureAsn1:"crls"},{name:"SignedData.SignerInfos",tagClass:U.Class.UNIVERSAL,type:U.Type.SET,capture:"signerInfos",optional:!0,value:[n_]}]};ss.recipientInfoValidator={name:"RecipientInfo",tagClass:U.Class.UNIVERSAL,type:U.Type.SEQUENCE,constructed:!0,value:[{name:"RecipientInfo.version",tagClass:U.Class.UNIVERSAL,type:U.Type.INTEGER,constructed:!1,capture:"version"},{name:"RecipientInfo.issuerAndSerial",tagClass:U.Class.UNIVERSAL,type:U.Type.SEQUENCE,constructed:!0,value:[{name:"RecipientInfo.issuerAndSerial.issuer",tagClass:U.Class.UNIVERSAL,type:U.Type.SEQUENCE,constructed:!0,captureAsn1:"issuer"},{name:"RecipientInfo.issuerAndSerial.serialNumber",tagClass:U.Class.UNIVERSAL,type:U.Type.INTEGER,constructed:!1,capture:"serial"}]},{name:"RecipientInfo.keyEncryptionAlgorithm",tagClass:U.Class.UNIVERSAL,type:U.Type.SEQUENCE,constructed:!0,value:[{name:"RecipientInfo.keyEncryptionAlgorithm.algorithm",tagClass:U.Class.UNIVERSAL,type:U.Type.OID,constructed:!1,capture:"encAlgorithm"},{name:"RecipientInfo.keyEncryptionAlgorithm.parameter",tagClass:U.Class.UNIVERSAL,constructed:!1,captureAsn1:"encParameter",optional:!0}]},{name:"RecipientInfo.encryptedKey",tagClass:U.Class.UNIVERSAL,type:U.Type.OCTETSTRING,constructed:!1,capture:"encKey"}]}});var Cn=R((M4,ug)=>{var uc=ie();ug.exports=uc.md=uc.md||{};uc.md.algorithms=uc.md.algorithms||{}});var mg=R((F4,pg)=>{var vr=ie();Cn();De();var fg=pg.exports=vr.sha256=vr.sha256||{};vr.md.sha256=vr.md.algorithms.sha256=fg;fg.create=function(){hg||i_();var t=null,e=vr.util.createBuffer(),r=new Array(64),n={algorithm:"sha256",blockLength:64,digestLength:32,messageLength:0,fullMessageLength:null,messageLengthSize:8};return n.start=function(){n.messageLength=0,n.fullMessageLength=n.messageLength64=[];for(var i=n.messageLengthSize/4,s=0;s<i;++s)n.fullMessageLength.push(0);return e=vr.util.createBuffer(),t={h0:1779033703,h1:3144134277,h2:1013904242,h3:2773480762,h4:1359893119,h5:2600822924,h6:528734635,h7:1541459225},n},n.start(),n.update=function(i,s){s==="utf8"&&(i=vr.util.encodeUtf8(i));var o=i.length;n.messageLength+=o,o=[o/4294967296>>>0,o>>>0];for(var a=n.fullMessageLength.length-1;a>=0;--a)n.fullMessageLength[a]+=o[1],o[1]=o[0]+(n.fullMessageLength[a]/4294967296>>>0),n.fullMessageLength[a]=n.fullMessageLength[a]>>>0,o[0]=o[1]/4294967296>>>0;return e.putBytes(i),lg(t,r,e),(e.read>2048||e.length()===0)&&e.compact(),n},n.digest=function(){var i=vr.util.createBuffer();i.putBytes(e.bytes());var s=n.fullMessageLength[n.fullMessageLength.length-1]+n.messageLengthSize,o=s&n.blockLength-1;i.putBytes(Cf.substr(0,n.blockLength-o));for(var a,c,u=n.fullMessageLength[0]*8,l=0;l<n.fullMessageLength.length-1;++l)a=n.fullMessageLength[l+1]*8,c=a/4294967296>>>0,u+=c,i.putInt32(u>>>0),u=a>>>0;i.putInt32(u);var f={h0:t.h0,h1:t.h1,h2:t.h2,h3:t.h3,h4:t.h4,h5:t.h5,h6:t.h6,h7:t.h7};lg(f,r,i);var h=vr.util.createBuffer();return h.putInt32(f.h0),h.putInt32(f.h1),h.putInt32(f.h2),h.putInt32(f.h3),h.putInt32(f.h4),h.putInt32(f.h5),h.putInt32(f.h6),h.putInt32(f.h7),h},n};var Cf=null,hg=!1,dg=null;function i_(){Cf=String.fromCharCode(128),Cf+=vr.util.fillString(String.fromCharCode(0),64),dg=[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],hg=!0}function lg(t,e,r){for(var n,i,s,o,a,c,u,l,f,h,d,p,y,g,E,x=r.length();x>=64;){for(u=0;u<16;++u)e[u]=r.getInt32();for(;u<64;++u)n=e[u-2],n=(n>>>17|n<<15)^(n>>>19|n<<13)^n>>>10,i=e[u-15],i=(i>>>7|i<<25)^(i>>>18|i<<14)^i>>>3,e[u]=n+e[u-7]+i+e[u-16]|0;for(l=t.h0,f=t.h1,h=t.h2,d=t.h3,p=t.h4,y=t.h5,g=t.h6,E=t.h7,u=0;u<64;++u)o=(p>>>6|p<<26)^(p>>>11|p<<21)^(p>>>25|p<<7),a=g^p&(y^g),s=(l>>>2|l<<30)^(l>>>13|l<<19)^(l>>>22|l<<10),c=l&f|h&(l^f),n=E+o+a+dg[u]+e[u],i=s+c,E=g,g=y,y=p,p=d+n>>>0,d=h,h=f,f=l,l=n+i>>>0;t.h0=t.h0+l|0,t.h1=t.h1+f|0,t.h2=t.h2+h|0,t.h3=t.h3+d|0,t.h4=t.h4+p|0,t.h5=t.h5+y|0,t.h6=t.h6+g|0,t.h7=t.h7+E|0,x-=64}}});var gg=R((K4,yg)=>{var wr=ie();De();var lc=null;wr.util.isNodejs&&!wr.options.usePureJavaScript&&!process.versions["node-webkit"]&&(lc=Jn());var s_=yg.exports=wr.prng=wr.prng||{};s_.create=function(t){for(var e={plugin:t,key:null,seed:null,time:null,reseeds:0,generated:0,keyBytes:""},r=t.md,n=new Array(32),i=0;i<32;++i)n[i]=r.create();e.pools=n,e.pool=0,e.generate=function(u,l){if(!l)return e.generateSync(u);var f=e.plugin.cipher,h=e.plugin.increment,d=e.plugin.formatKey,p=e.plugin.formatSeed,y=wr.util.createBuffer();e.key=null,g();function g(E){if(E)return l(E);if(y.length()>=u)return l(null,y.getBytes(u));if(e.generated>1048575&&(e.key=null),e.key===null)return wr.util.nextTick(function(){s(g)});var x=f(e.key,e.seed);e.generated+=x.length,y.putBytes(x),e.key=d(f(e.key,h(e.seed))),e.seed=p(f(e.key,e.seed)),wr.util.setImmediate(g)}},e.generateSync=function(u){var l=e.plugin.cipher,f=e.plugin.increment,h=e.plugin.formatKey,d=e.plugin.formatSeed;e.key=null;for(var p=wr.util.createBuffer();p.length()<u;){e.generated>1048575&&(e.key=null),e.key===null&&o();var y=l(e.key,e.seed);e.generated+=y.length,p.putBytes(y),e.key=h(l(e.key,f(e.seed))),e.seed=d(l(e.key,e.seed))}return p.getBytes(u)};function s(u){if(e.pools[0].messageLength>=32)return a(),u();var l=32-e.pools[0].messageLength<<5;e.seedFile(l,function(f,h){if(f)return u(f);e.collect(h),a(),u()})}function o(){if(e.pools[0].messageLength>=32)return a();var u=32-e.pools[0].messageLength<<5;e.collect(e.seedFileSync(u)),a()}function a(){e.reseeds=e.reseeds===4294967295?0:e.reseeds+1;var u=e.plugin.md.create();u.update(e.keyBytes);for(var l=1,f=0;f<32;++f)e.reseeds%l===0&&(u.update(e.pools[f].digest().getBytes()),e.pools[f].start()),l=l<<1;e.keyBytes=u.digest().getBytes(),u.start(),u.update(e.keyBytes);var h=u.digest().getBytes();e.key=e.plugin.formatKey(e.keyBytes),e.seed=e.plugin.formatSeed(h),e.generated=0}function c(u){var l=null,f=wr.util.globalScope,h=f.crypto||f.msCrypto;h&&h.getRandomValues&&(l=function(D){return h.getRandomValues(D)});var d=wr.util.createBuffer();if(l)for(;d.length()<u;){var p=Math.max(1,Math.min(u-d.length(),65536)/4),y=new Uint32Array(Math.floor(p));try{l(y);for(var g=0;g<y.length;++g)d.putInt32(y[g])}catch(D){if(!(typeof QuotaExceededError<"u"&&D instanceof QuotaExceededError))throw D}}if(d.length()<u)for(var E,x,_,B=Math.floor(Math.random()*65536);d.length()<u;){x=16807*(B&65535),E=16807*(B>>16),x+=(E&32767)<<16,x+=E>>15,x=(x&2147483647)+(x>>31),B=x&4294967295;for(var g=0;g<3;++g)_=B>>>(g<<3),_^=Math.floor(Math.random()*256),d.putByte(_&255)}return d.getBytes(u)}return lc?(e.seedFile=function(u,l){lc.randomBytes(u,function(f,h){if(f)return l(f);l(null,h.toString())})},e.seedFileSync=function(u){return lc.randomBytes(u).toString()}):(e.seedFile=function(u,l){try{l(null,c(u))}catch(f){l(f)}},e.seedFileSync=c),e.collect=function(u){for(var l=u.length,f=0;f<l;++f)e.pools[e.pool].update(u.substr(f,1)),e.pool=e.pool===31?0:e.pool+1},e.collectInt=function(u,l){for(var f="",h=0;h<l;h+=8)f+=String.fromCharCode(u>>h&255);e.collect(f)},e.registerWorker=function(u){if(u===self)e.seedFile=function(f,h){function d(p){var y=p.data;y.forge&&y.forge.prng&&(self.removeEventListener("message",d),h(y.forge.prng.err,y.forge.prng.bytes))}self.addEventListener("message",d),self.postMessage({forge:{prng:{needed:f}}})};else{var l=function(f){var h=f.data;h.forge&&h.forge.prng&&e.seedFile(h.forge.prng.needed,function(d,p){u.postMessage({forge:{prng:{err:d,bytes:p}}})})};u.addEventListener("message",l)}},e}});var ai=R((V4,If)=>{var ht=ie();rs();mg();gg();De();(function(){if(ht.random&&ht.random.getBytes){If.exports=ht.random;return}(function(t){var e={},r=new Array(4),n=ht.util.createBuffer();e.formatKey=function(f){var h=ht.util.createBuffer(f);return f=new Array(4),f[0]=h.getInt32(),f[1]=h.getInt32(),f[2]=h.getInt32(),f[3]=h.getInt32(),ht.aes._expandKey(f,!1)},e.formatSeed=function(f){var h=ht.util.createBuffer(f);return f=new Array(4),f[0]=h.getInt32(),f[1]=h.getInt32(),f[2]=h.getInt32(),f[3]=h.getInt32(),f},e.cipher=function(f,h){return ht.aes._updateBlock(f,h,r,!1),n.putInt32(r[0]),n.putInt32(r[1]),n.putInt32(r[2]),n.putInt32(r[3]),n.getBytes()},e.increment=function(f){return++f[3],f},e.md=ht.md.sha256;function i(){var f=ht.prng.create(e);return f.getBytes=function(h,d){return f.generate(h,d)},f.getBytesSync=function(h){return f.generate(h)},f}var s=i(),o=null,a=ht.util.globalScope,c=a.crypto||a.msCrypto;if(c&&c.getRandomValues&&(o=function(f){return c.getRandomValues(f)}),ht.options.usePureJavaScript||!ht.util.isNodejs&&!o){if(typeof window>"u"||window.document,s.collectInt(+new Date,32),typeof navigator<"u"){var u="";for(var l in navigator)try{typeof navigator[l]=="string"&&(u+=navigator[l])}catch{}s.collect(u),u=null}t&&(t().mousemove(function(f){s.collectInt(f.clientX,16),s.collectInt(f.clientY,16)}),t().keypress(function(f){s.collectInt(f.charCode,8)}))}if(!ht.random)ht.random=s;else for(var l in s)ht.random[l]=s[l];ht.random.createInstance=i,If.exports=ht.random})(typeof jQuery<"u"?jQuery:null)})()});var vg=R((q4,Eg)=>{var ci=ie();De();ci.mgf=ci.mgf||{};var o_=Eg.exports=ci.mgf.mgf1=ci.mgf1=ci.mgf1||{};o_.create=function(t){var e={generate:function(r,n){for(var i=new ci.util.ByteBuffer,s=Math.ceil(n/t.digestLength),o=0;o<s;o++){var a=new ci.util.ByteBuffer;a.putInt32(o),t.start(),t.update(r+a.getBytes()),i.putBuffer(t.digest())}return i.truncate(i.length()-n),i.getBytes()}};return e}});var xg=R((H4,wg)=>{var fc=ie();vg();wg.exports=fc.mgf=fc.mgf||{};fc.mgf.mgf1=fc.mgf1});var Sg=R((z4,bg)=>{var ui=ie();ai();De();var a_=bg.exports=ui.pss=ui.pss||{};a_.create=function(t){arguments.length===3&&(t={md:arguments[0],mgf:arguments[1],saltLength:arguments[2]});var e=t.md,r=t.mgf,n=e.digestLength,i=t.salt||null;typeof i=="string"&&(i=ui.util.createBuffer(i));var s;if("saltLength"in t)s=t.saltLength;else if(i!==null)s=i.length();else throw new Error("Salt length not specified or specific salt not given.");if(i!==null&&i.length()!==s)throw new Error("Given salt length does not match length of given salt.");var o=t.prng||ui.random,a={};return a.encode=function(c,u){var l,f=u-1,h=Math.ceil(f/8),d=c.digest().getBytes();if(h<n+s+2)throw new Error("Message is too long to encrypt.");var p;i===null?p=o.getBytesSync(s):p=i.bytes();var y=new ui.util.ByteBuffer;y.fillWithByte(0,8),y.putBytes(d),y.putBytes(p),e.start(),e.update(y.getBytes());var g=e.digest().getBytes(),E=new ui.util.ByteBuffer;E.fillWithByte(0,h-s-n-2),E.putByte(1),E.putBytes(p);var x=E.getBytes(),_=h-n-1,B=r.generate(g,_),D="";for(l=0;l<_;l++)D+=String.fromCharCode(x.charCodeAt(l)^B.charCodeAt(l));var P=65280>>8*h-f&255;return D=String.fromCharCode(D.charCodeAt(0)&~P)+D.substr(1),D+g+String.fromCharCode(188)},a.verify=function(c,u,l){var f,h=l-1,d=Math.ceil(h/8);if(u=u.substr(-d),d<n+s+2)throw new Error("Inconsistent parameters to PSS signature verification.");if(u.charCodeAt(d-1)!==188)throw new Error("Encoded message does not end in 0xBC.");var p=d-n-1,y=u.substr(0,p),g=u.substr(p,n),E=65280>>8*d-h&255;if(y.charCodeAt(0)&E)throw new Error("Bits beyond keysize not zero as expected.");var x=r.generate(g,p),_="";for(f=0;f<p;f++)_+=String.fromCharCode(y.charCodeAt(f)^x.charCodeAt(f));_=String.fromCharCode(_.charCodeAt(0)&~E)+_.substr(1);var B=d-n-s-2;for(f=0;f<B;f++)if(_.charCodeAt(f)!==0)throw new Error("Leftmost octets not zero as expected");if(_.charCodeAt(B)!==1)throw new Error("Inconsistent PSS signature, 0x01 marker not found");var D=_.substr(-s),P=new ui.util.ByteBuffer;P.fillWithByte(0,8),P.putBytes(c),P.putBytes(D),e.start(),e.update(P.getBytes());var te=e.digest().getBytes();return g===te},a}});var pc=R(($4,Dg)=>{var Tf=ie();Dg.exports=Tf.jsbn=Tf.jsbn||{};var Gr,c_=0xdeadbeefcafe,_g=(c_&16777215)==15715070;function I(t,e,r){this.data=[],t!=null&&(typeof t=="number"?this.fromNumber(t,e,r):e==null&&typeof t!="string"?this.fromString(t,256):this.fromString(t,e))}Tf.jsbn.BigInteger=I;function pe(){return new I(null)}function u_(t,e,r,n,i,s){for(;--s>=0;){var o=e*this.data[t++]+r.data[n]+i;i=Math.floor(o/67108864),r.data[n++]=o&67108863}return i}function l_(t,e,r,n,i,s){for(var o=e&32767,a=e>>15;--s>=0;){var c=this.data[t]&32767,u=this.data[t++]>>15,l=a*c+u*o;c=o*c+((l&32767)<<15)+r.data[n]+(i&1073741823),i=(c>>>30)+(l>>>15)+a*u+(i>>>30),r.data[n++]=c&1073741823}return i}function Ag(t,e,r,n,i,s){for(var o=e&16383,a=e>>14;--s>=0;){var c=this.data[t]&16383,u=this.data[t++]>>14,l=a*c+u*o;c=o*c+((l&16383)<<14)+r.data[n]+i,i=(c>>28)+(l>>14)+a*u,r.data[n++]=c&268435455}return i}typeof navigator>"u"?(I.prototype.am=Ag,Gr=28):_g&&navigator.appName=="Microsoft Internet Explorer"?(I.prototype.am=l_,Gr=30):_g&&navigator.appName!="Netscape"?(I.prototype.am=u_,Gr=26):(I.prototype.am=Ag,Gr=28);I.prototype.DB=Gr;I.prototype.DM=(1<<Gr)-1;I.prototype.DV=1<<Gr;var Rf=52;I.prototype.FV=Math.pow(2,Rf);I.prototype.F1=Rf-Gr;I.prototype.F2=2*Gr-Rf;var f_="0123456789abcdefghijklmnopqrstuvwxyz",hc=new Array,os,zt;os="0".charCodeAt(0);for(zt=0;zt<=9;++zt)hc[os++]=zt;os="a".charCodeAt(0);for(zt=10;zt<36;++zt)hc[os++]=zt;os="A".charCodeAt(0);for(zt=10;zt<36;++zt)hc[os++]=zt;function Cg(t){return f_.charAt(t)}function Ig(t,e){var r=hc[t.charCodeAt(e)];return r??-1}function h_(t){for(var e=this.t-1;e>=0;--e)t.data[e]=this.data[e];t.t=this.t,t.s=this.s}function d_(t){this.t=1,this.s=t<0?-1:0,t>0?this.data[0]=t:t<-1?this.data[0]=t+this.DV:this.t=0}function In(t){var e=pe();return e.fromInt(t),e}function p_(t,e){var r;if(e==16)r=4;else if(e==8)r=3;else if(e==256)r=8;else if(e==2)r=1;else if(e==32)r=5;else if(e==4)r=2;else{this.fromRadix(t,e);return}this.t=0,this.s=0;for(var n=t.length,i=!1,s=0;--n>=0;){var o=r==8?t[n]&255:Ig(t,n);if(o<0){t.charAt(n)=="-"&&(i=!0);continue}i=!1,s==0?this.data[this.t++]=o:s+r>this.DB?(this.data[this.t-1]|=(o&(1<<this.DB-s)-1)<<s,this.data[this.t++]=o>>this.DB-s):this.data[this.t-1]|=o<<s,s+=r,s>=this.DB&&(s-=this.DB)}r==8&&t[0]&128&&(this.s=-1,s>0&&(this.data[this.t-1]|=(1<<this.DB-s)-1<<s)),this.clamp(),i&&I.ZERO.subTo(this,this)}function m_(){for(var t=this.s&this.DM;this.t>0&&this.data[this.t-1]==t;)--this.t}function y_(t){if(this.s<0)return"-"+this.negate().toString(t);var e;if(t==16)e=4;else if(t==8)e=3;else if(t==2)e=1;else if(t==32)e=5;else if(t==4)e=2;else return this.toRadix(t);var r=(1<<e)-1,n,i=!1,s="",o=this.t,a=this.DB-o*this.DB%e;if(o-- >0)for(a<this.DB&&(n=this.data[o]>>a)>0&&(i=!0,s=Cg(n));o>=0;)a<e?(n=(this.data[o]&(1<<a)-1)<<e-a,n|=this.data[--o]>>(a+=this.DB-e)):(n=this.data[o]>>(a-=e)&r,a<=0&&(a+=this.DB,--o)),n>0&&(i=!0),i&&(s+=Cg(n));return i?s:"0"}function g_(){var t=pe();return I.ZERO.subTo(this,t),t}function E_(){return this.s<0?this.negate():this}function v_(t){var e=this.s-t.s;if(e!=0)return e;var r=this.t;if(e=r-t.t,e!=0)return this.s<0?-e:e;for(;--r>=0;)if((e=this.data[r]-t.data[r])!=0)return e;return 0}function dc(t){var e=1,r;return(r=t>>>16)!=0&&(t=r,e+=16),(r=t>>8)!=0&&(t=r,e+=8),(r=t>>4)!=0&&(t=r,e+=4),(r=t>>2)!=0&&(t=r,e+=2),(r=t>>1)!=0&&(t=r,e+=1),e}function w_(){return this.t<=0?0:this.DB*(this.t-1)+dc(this.data[this.t-1]^this.s&this.DM)}function x_(t,e){var r;for(r=this.t-1;r>=0;--r)e.data[r+t]=this.data[r];for(r=t-1;r>=0;--r)e.data[r]=0;e.t=this.t+t,e.s=this.s}function b_(t,e){for(var r=t;r<this.t;++r)e.data[r-t]=this.data[r];e.t=Math.max(this.t-t,0),e.s=this.s}function S_(t,e){var r=t%this.DB,n=this.DB-r,i=(1<<n)-1,s=Math.floor(t/this.DB),o=this.s<<r&this.DM,a;for(a=this.t-1;a>=0;--a)e.data[a+s+1]=this.data[a]>>n|o,o=(this.data[a]&i)<<r;for(a=s-1;a>=0;--a)e.data[a]=0;e.data[s]=o,e.t=this.t+s+1,e.s=this.s,e.clamp()}function __(t,e){e.s=this.s;var r=Math.floor(t/this.DB);if(r>=this.t){e.t=0;return}var n=t%this.DB,i=this.DB-n,s=(1<<n)-1;e.data[0]=this.data[r]>>n;for(var o=r+1;o<this.t;++o)e.data[o-r-1]|=(this.data[o]&s)<<i,e.data[o-r]=this.data[o]>>n;n>0&&(e.data[this.t-r-1]|=(this.s&s)<<i),e.t=this.t-r,e.clamp()}function A_(t,e){for(var r=0,n=0,i=Math.min(t.t,this.t);r<i;)n+=this.data[r]-t.data[r],e.data[r++]=n&this.DM,n>>=this.DB;if(t.t<this.t){for(n-=t.s;r<this.t;)n+=this.data[r],e.data[r++]=n&this.DM,n>>=this.DB;n+=this.s}else{for(n+=this.s;r<t.t;)n-=t.data[r],e.data[r++]=n&this.DM,n>>=this.DB;n-=t.s}e.s=n<0?-1:0,n<-1?e.data[r++]=this.DV+n:n>0&&(e.data[r++]=n),e.t=r,e.clamp()}function C_(t,e){var r=this.abs(),n=t.abs(),i=r.t;for(e.t=i+n.t;--i>=0;)e.data[i]=0;for(i=0;i<n.t;++i)e.data[i+r.t]=r.am(0,n.data[i],e,i,0,r.t);e.s=0,e.clamp(),this.s!=t.s&&I.ZERO.subTo(e,e)}function I_(t){for(var e=this.abs(),r=t.t=2*e.t;--r>=0;)t.data[r]=0;for(r=0;r<e.t-1;++r){var n=e.am(r,e.data[r],t,2*r,0,1);(t.data[r+e.t]+=e.am(r+1,2*e.data[r],t,2*r+1,n,e.t-r-1))>=e.DV&&(t.data[r+e.t]-=e.DV,t.data[r+e.t+1]=1)}t.t>0&&(t.data[t.t-1]+=e.am(r,e.data[r],t,2*r,0,1)),t.s=0,t.clamp()}function T_(t,e,r){var n=t.abs();if(!(n.t<=0)){var i=this.abs();if(i.t<n.t){e?.fromInt(0),r!=null&&this.copyTo(r);return}r==null&&(r=pe());var s=pe(),o=this.s,a=t.s,c=this.DB-dc(n.data[n.t-1]);c>0?(n.lShiftTo(c,s),i.lShiftTo(c,r)):(n.copyTo(s),i.copyTo(r));var u=s.t,l=s.data[u-1];if(l!=0){var f=l*(1<<this.F1)+(u>1?s.data[u-2]>>this.F2:0),h=this.FV/f,d=(1<<this.F1)/f,p=1<<this.F2,y=r.t,g=y-u,E=e??pe();for(s.dlShiftTo(g,E),r.compareTo(E)>=0&&(r.data[r.t++]=1,r.subTo(E,r)),I.ONE.dlShiftTo(u,E),E.subTo(s,s);s.t<u;)s.data[s.t++]=0;for(;--g>=0;){var x=r.data[--y]==l?this.DM:Math.floor(r.data[y]*h+(r.data[y-1]+p)*d);if((r.data[y]+=s.am(0,x,r,g,0,u))<x)for(s.dlShiftTo(g,E),r.subTo(E,r);r.data[y]<--x;)r.subTo(E,r)}e!=null&&(r.drShiftTo(u,e),o!=a&&I.ZERO.subTo(e,e)),r.t=u,r.clamp(),c>0&&r.rShiftTo(c,r),o<0&&I.ZERO.subTo(r,r)}}}function R_(t){var e=pe();return this.abs().divRemTo(t,null,e),this.s<0&&e.compareTo(I.ZERO)>0&&t.subTo(e,e),e}function li(t){this.m=t}function N_(t){return t.s<0||t.compareTo(this.m)>=0?t.mod(this.m):t}function D_(t){return t}function L_(t){t.divRemTo(this.m,null,t)}function P_(t,e,r){t.multiplyTo(e,r),this.reduce(r)}function B_(t,e){t.squareTo(e),this.reduce(e)}li.prototype.convert=N_;li.prototype.revert=D_;li.prototype.reduce=L_;li.prototype.mulTo=P_;li.prototype.sqrTo=B_;function O_(){if(this.t<1)return 0;var t=this.data[0];if(!(t&1))return 0;var e=t&3;return e=e*(2-(t&15)*e)&15,e=e*(2-(t&255)*e)&255,e=e*(2-((t&65535)*e&65535))&65535,e=e*(2-t*e%this.DV)%this.DV,e>0?this.DV-e:-e}function fi(t){this.m=t,this.mp=t.invDigit(),this.mpl=this.mp&32767,this.mph=this.mp>>15,this.um=(1<<t.DB-15)-1,this.mt2=2*t.t}function k_(t){var e=pe();return t.abs().dlShiftTo(this.m.t,e),e.divRemTo(this.m,null,e),t.s<0&&e.compareTo(I.ZERO)>0&&this.m.subTo(e,e),e}function U_(t){var e=pe();return t.copyTo(e),this.reduce(e),e}function M_(t){for(;t.t<=this.mt2;)t.data[t.t++]=0;for(var e=0;e<this.m.t;++e){var r=t.data[e]&32767,n=r*this.mpl+((r*this.mph+(t.data[e]>>15)*this.mpl&this.um)<<15)&t.DM;for(r=e+this.m.t,t.data[r]+=this.m.am(0,n,t,e,0,this.m.t);t.data[r]>=t.DV;)t.data[r]-=t.DV,t.data[++r]++}t.clamp(),t.drShiftTo(this.m.t,t),t.compareTo(this.m)>=0&&t.subTo(this.m,t)}function F_(t,e){t.squareTo(e),this.reduce(e)}function K_(t,e,r){t.multiplyTo(e,r),this.reduce(r)}fi.prototype.convert=k_;fi.prototype.revert=U_;fi.prototype.reduce=M_;fi.prototype.mulTo=K_;fi.prototype.sqrTo=F_;function V_(){return(this.t>0?this.data[0]&1:this.s)==0}function q_(t,e){if(t>4294967295||t<1)return I.ONE;var r=pe(),n=pe(),i=e.convert(this),s=dc(t)-1;for(i.copyTo(r);--s>=0;)if(e.sqrTo(r,n),(t&1<<s)>0)e.mulTo(n,i,r);else{var o=r;r=n,n=o}return e.revert(r)}function H_(t,e){var r;return t<256||e.isEven()?r=new li(e):r=new fi(e),this.exp(t,r)}I.prototype.copyTo=h_;I.prototype.fromInt=d_;I.prototype.fromString=p_;I.prototype.clamp=m_;I.prototype.dlShiftTo=x_;I.prototype.drShiftTo=b_;I.prototype.lShiftTo=S_;I.prototype.rShiftTo=__;I.prototype.subTo=A_;I.prototype.multiplyTo=C_;I.prototype.squareTo=I_;I.prototype.divRemTo=T_;I.prototype.invDigit=O_;I.prototype.isEven=V_;I.prototype.exp=q_;I.prototype.toString=y_;I.prototype.negate=g_;I.prototype.abs=E_;I.prototype.compareTo=v_;I.prototype.bitLength=w_;I.prototype.mod=R_;I.prototype.modPowInt=H_;I.ZERO=In(0);I.ONE=In(1);function z_(){var t=pe();return this.copyTo(t),t}function $_(){if(this.s<0){if(this.t==1)return this.data[0]-this.DV;if(this.t==0)return-1}else{if(this.t==1)return this.data[0];if(this.t==0)return 0}return(this.data[1]&(1<<32-this.DB)-1)<<this.DB|this.data[0]}function G_(){return this.t==0?this.s:this.data[0]<<24>>24}function Y_(){return this.t==0?this.s:this.data[0]<<16>>16}function W_(t){return Math.floor(Math.LN2*this.DB/Math.log(t))}function Q_(){return this.s<0?-1:this.t<=0||this.t==1&&this.data[0]<=0?0:1}function X_(t){if(t==null&&(t=10),this.signum()==0||t<2||t>36)return"0";var e=this.chunkSize(t),r=Math.pow(t,e),n=In(r),i=pe(),s=pe(),o="";for(this.divRemTo(n,i,s);i.signum()>0;)o=(r+s.intValue()).toString(t).substr(1)+o,i.divRemTo(n,i,s);return s.intValue().toString(t)+o}function j_(t,e){this.fromInt(0),e==null&&(e=10);for(var r=this.chunkSize(e),n=Math.pow(e,r),i=!1,s=0,o=0,a=0;a<t.length;++a){var c=Ig(t,a);if(c<0){t.charAt(a)=="-"&&this.signum()==0&&(i=!0);continue}o=e*o+c,++s>=r&&(this.dMultiply(n),this.dAddOffset(o,0),s=0,o=0)}s>0&&(this.dMultiply(Math.pow(e,s)),this.dAddOffset(o,0)),i&&I.ZERO.subTo(this,this)}function Z_(t,e,r){if(typeof e=="number")if(t<2)this.fromInt(1);else for(this.fromNumber(t,r),this.testBit(t-1)||this.bitwiseTo(I.ONE.shiftLeft(t-1),Nf,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(e);)this.dAddOffset(2,0),this.bitLength()>t&&this.subTo(I.ONE.shiftLeft(t-1),this);else{var n=new Array,i=t&7;n.length=(t>>3)+1,e.nextBytes(n),i>0?n[0]&=(1<<i)-1:n[0]=0,this.fromString(n,256)}}function J_(){var t=this.t,e=new Array;e[0]=this.s;var r=this.DB-t*this.DB%8,n,i=0;if(t-- >0)for(r<this.DB&&(n=this.data[t]>>r)!=(this.s&this.DM)>>r&&(e[i++]=n|this.s<<this.DB-r);t>=0;)r<8?(n=(this.data[t]&(1<<r)-1)<<8-r,n|=this.data[--t]>>(r+=this.DB-8)):(n=this.data[t]>>(r-=8)&255,r<=0&&(r+=this.DB,--t)),n&128&&(n|=-256),i==0&&(this.s&128)!=(n&128)&&++i,(i>0||n!=this.s)&&(e[i++]=n);return e}function eA(t){return this.compareTo(t)==0}function tA(t){return this.compareTo(t)<0?this:t}function rA(t){return this.compareTo(t)>0?this:t}function nA(t,e,r){var n,i,s=Math.min(t.t,this.t);for(n=0;n<s;++n)r.data[n]=e(this.data[n],t.data[n]);if(t.t<this.t){for(i=t.s&this.DM,n=s;n<this.t;++n)r.data[n]=e(this.data[n],i);r.t=this.t}else{for(i=this.s&this.DM,n=s;n<t.t;++n)r.data[n]=e(i,t.data[n]);r.t=t.t}r.s=e(this.s,t.s),r.clamp()}function iA(t,e){return t&e}function sA(t){var e=pe();return this.bitwiseTo(t,iA,e),e}function Nf(t,e){return t|e}function oA(t){var e=pe();return this.bitwiseTo(t,Nf,e),e}function Tg(t,e){return t^e}function aA(t){var e=pe();return this.bitwiseTo(t,Tg,e),e}function Rg(t,e){return t&~e}function cA(t){var e=pe();return this.bitwiseTo(t,Rg,e),e}function uA(){for(var t=pe(),e=0;e<this.t;++e)t.data[e]=this.DM&~this.data[e];return t.t=this.t,t.s=~this.s,t}function lA(t){var e=pe();return t<0?this.rShiftTo(-t,e):this.lShiftTo(t,e),e}function fA(t){var e=pe();return t<0?this.lShiftTo(-t,e):this.rShiftTo(t,e),e}function hA(t){if(t==0)return-1;var e=0;return t&65535||(t>>=16,e+=16),t&255||(t>>=8,e+=8),t&15||(t>>=4,e+=4),t&3||(t>>=2,e+=2),t&1||++e,e}function dA(){for(var t=0;t<this.t;++t)if(this.data[t]!=0)return t*this.DB+hA(this.data[t]);return this.s<0?this.t*this.DB:-1}function pA(t){for(var e=0;t!=0;)t&=t-1,++e;return e}function mA(){for(var t=0,e=this.s&this.DM,r=0;r<this.t;++r)t+=pA(this.data[r]^e);return t}function yA(t){var e=Math.floor(t/this.DB);return e>=this.t?this.s!=0:(this.data[e]&1<<t%this.DB)!=0}function gA(t,e){var r=I.ONE.shiftLeft(t);return this.bitwiseTo(r,e,r),r}function EA(t){return this.changeBit(t,Nf)}function vA(t){return this.changeBit(t,Rg)}function wA(t){return this.changeBit(t,Tg)}function xA(t,e){for(var r=0,n=0,i=Math.min(t.t,this.t);r<i;)n+=this.data[r]+t.data[r],e.data[r++]=n&this.DM,n>>=this.DB;if(t.t<this.t){for(n+=t.s;r<this.t;)n+=this.data[r],e.data[r++]=n&this.DM,n>>=this.DB;n+=this.s}else{for(n+=this.s;r<t.t;)n+=t.data[r],e.data[r++]=n&this.DM,n>>=this.DB;n+=t.s}e.s=n<0?-1:0,n>0?e.data[r++]=n:n<-1&&(e.data[r++]=this.DV+n),e.t=r,e.clamp()}function bA(t){var e=pe();return this.addTo(t,e),e}function SA(t){var e=pe();return this.subTo(t,e),e}function _A(t){var e=pe();return this.multiplyTo(t,e),e}function AA(t){var e=pe();return this.divRemTo(t,e,null),e}function CA(t){var e=pe();return this.divRemTo(t,null,e),e}function IA(t){var e=pe(),r=pe();return this.divRemTo(t,e,r),new Array(e,r)}function TA(t){this.data[this.t]=this.am(0,t-1,this,0,0,this.t),++this.t,this.clamp()}function RA(t,e){if(t!=0){for(;this.t<=e;)this.data[this.t++]=0;for(this.data[e]+=t;this.data[e]>=this.DV;)this.data[e]-=this.DV,++e>=this.t&&(this.data[this.t++]=0),++this.data[e]}}function oo(){}function Ng(t){return t}function NA(t,e,r){t.multiplyTo(e,r)}function DA(t,e){t.squareTo(e)}oo.prototype.convert=Ng;oo.prototype.revert=Ng;oo.prototype.mulTo=NA;oo.prototype.sqrTo=DA;function LA(t){return this.exp(t,new oo)}function PA(t,e,r){var n=Math.min(this.t+t.t,e);for(r.s=0,r.t=n;n>0;)r.data[--n]=0;var i;for(i=r.t-this.t;n<i;++n)r.data[n+this.t]=this.am(0,t.data[n],r,n,0,this.t);for(i=Math.min(t.t,e);n<i;++n)this.am(0,t.data[n],r,n,0,e-n);r.clamp()}function BA(t,e,r){--e;var n=r.t=this.t+t.t-e;for(r.s=0;--n>=0;)r.data[n]=0;for(n=Math.max(e-this.t,0);n<t.t;++n)r.data[this.t+n-e]=this.am(e-n,t.data[n],r,0,0,this.t+n-e);r.clamp(),r.drShiftTo(1,r)}function as(t){this.r2=pe(),this.q3=pe(),I.ONE.dlShiftTo(2*t.t,this.r2),this.mu=this.r2.divide(t),this.m=t}function OA(t){if(t.s<0||t.t>2*this.m.t)return t.mod(this.m);if(t.compareTo(this.m)<0)return t;var e=pe();return t.copyTo(e),this.reduce(e),e}function kA(t){return t}function UA(t){for(t.drShiftTo(this.m.t-1,this.r2),t.t>this.m.t+1&&(t.t=this.m.t+1,t.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);t.compareTo(this.r2)<0;)t.dAddOffset(1,this.m.t+1);for(t.subTo(this.r2,t);t.compareTo(this.m)>=0;)t.subTo(this.m,t)}function MA(t,e){t.squareTo(e),this.reduce(e)}function FA(t,e,r){t.multiplyTo(e,r),this.reduce(r)}as.prototype.convert=OA;as.prototype.revert=kA;as.prototype.reduce=UA;as.prototype.mulTo=FA;as.prototype.sqrTo=MA;function KA(t,e){var r=t.bitLength(),n,i=In(1),s;if(r<=0)return i;r<18?n=1:r<48?n=3:r<144?n=4:r<768?n=5:n=6,r<8?s=new li(e):e.isEven()?s=new as(e):s=new fi(e);var o=new Array,a=3,c=n-1,u=(1<<n)-1;if(o[1]=s.convert(this),n>1){var l=pe();for(s.sqrTo(o[1],l);a<=u;)o[a]=pe(),s.mulTo(l,o[a-2],o[a]),a+=2}var f=t.t-1,h,d=!0,p=pe(),y;for(r=dc(t.data[f])-1;f>=0;){for(r>=c?h=t.data[f]>>r-c&u:(h=(t.data[f]&(1<<r+1)-1)<<c-r,f>0&&(h|=t.data[f-1]>>this.DB+r-c)),a=n;!(h&1);)h>>=1,--a;if((r-=a)<0&&(r+=this.DB,--f),d)o[h].copyTo(i),d=!1;else{for(;a>1;)s.sqrTo(i,p),s.sqrTo(p,i),a-=2;a>0?s.sqrTo(i,p):(y=i,i=p,p=y),s.mulTo(p,o[h],i)}for(;f>=0&&!(t.data[f]&1<<r);)s.sqrTo(i,p),y=i,i=p,p=y,--r<0&&(r=this.DB-1,--f)}return s.revert(i)}function VA(t){var e=this.s<0?this.negate():this.clone(),r=t.s<0?t.negate():t.clone();if(e.compareTo(r)<0){var n=e;e=r,r=n}var i=e.getLowestSetBit(),s=r.getLowestSetBit();if(s<0)return e;for(i<s&&(s=i),s>0&&(e.rShiftTo(s,e),r.rShiftTo(s,r));e.signum()>0;)(i=e.getLowestSetBit())>0&&e.rShiftTo(i,e),(i=r.getLowestSetBit())>0&&r.rShiftTo(i,r),e.compareTo(r)>=0?(e.subTo(r,e),e.rShiftTo(1,e)):(r.subTo(e,r),r.rShiftTo(1,r));return s>0&&r.lShiftTo(s,r),r}function qA(t){if(t<=0)return 0;var e=this.DV%t,r=this.s<0?t-1:0;if(this.t>0)if(e==0)r=this.data[0]%t;else for(var n=this.t-1;n>=0;--n)r=(e*r+this.data[n])%t;return r}function HA(t){var e=t.isEven();if(this.isEven()&&e||t.signum()==0)return I.ZERO;for(var r=t.clone(),n=this.clone(),i=In(1),s=In(0),o=In(0),a=In(1);r.signum()!=0;){for(;r.isEven();)r.rShiftTo(1,r),e?((!i.isEven()||!s.isEven())&&(i.addTo(this,i),s.subTo(t,s)),i.rShiftTo(1,i)):s.isEven()||s.subTo(t,s),s.rShiftTo(1,s);for(;n.isEven();)n.rShiftTo(1,n),e?((!o.isEven()||!a.isEven())&&(o.addTo(this,o),a.subTo(t,a)),o.rShiftTo(1,o)):a.isEven()||a.subTo(t,a),a.rShiftTo(1,a);r.compareTo(n)>=0?(r.subTo(n,r),e&&i.subTo(o,i),s.subTo(a,s)):(n.subTo(r,n),e&&o.subTo(i,o),a.subTo(s,a))}if(n.compareTo(I.ONE)!=0)return I.ZERO;if(a.compareTo(t)>=0)return a.subtract(t);if(a.signum()<0)a.addTo(t,a);else return a;return a.signum()<0?a.add(t):a}var nr=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509],zA=(1<<26)/nr[nr.length-1];function $A(t){var e,r=this.abs();if(r.t==1&&r.data[0]<=nr[nr.length-1]){for(e=0;e<nr.length;++e)if(r.data[0]==nr[e])return!0;return!1}if(r.isEven())return!1;for(e=1;e<nr.length;){for(var n=nr[e],i=e+1;i<nr.length&&n<zA;)n*=nr[i++];for(n=r.modInt(n);e<i;)if(n%nr[e++]==0)return!1}return r.millerRabin(t)}function GA(t){var e=this.subtract(I.ONE),r=e.getLowestSetBit();if(r<=0)return!1;for(var n=e.shiftRight(r),i=YA(),s,o=0;o<t;++o){do s=new I(this.bitLength(),i);while(s.compareTo(I.ONE)<=0||s.compareTo(e)>=0);var a=s.modPow(n,this);if(a.compareTo(I.ONE)!=0&&a.compareTo(e)!=0){for(var c=1;c++<r&&a.compareTo(e)!=0;)if(a=a.modPowInt(2,this),a.compareTo(I.ONE)==0)return!1;if(a.compareTo(e)!=0)return!1}}return!0}function YA(){return{nextBytes:function(t){for(var e=0;e<t.length;++e)t[e]=Math.floor(Math.random()*256)}}}I.prototype.chunkSize=W_;I.prototype.toRadix=X_;I.prototype.fromRadix=j_;I.prototype.fromNumber=Z_;I.prototype.bitwiseTo=nA;I.prototype.changeBit=gA;I.prototype.addTo=xA;I.prototype.dMultiply=TA;I.prototype.dAddOffset=RA;I.prototype.multiplyLowerTo=PA;I.prototype.multiplyUpperTo=BA;I.prototype.modInt=qA;I.prototype.millerRabin=GA;I.prototype.clone=z_;I.prototype.intValue=$_;I.prototype.byteValue=G_;I.prototype.shortValue=Y_;I.prototype.signum=Q_;I.prototype.toByteArray=J_;I.prototype.equals=eA;I.prototype.min=tA;I.prototype.max=rA;I.prototype.and=sA;I.prototype.or=oA;I.prototype.xor=aA;I.prototype.andNot=cA;I.prototype.not=uA;I.prototype.shiftLeft=lA;I.prototype.shiftRight=fA;I.prototype.getLowestSetBit=dA;I.prototype.bitCount=mA;I.prototype.testBit=yA;I.prototype.setBit=EA;I.prototype.clearBit=vA;I.prototype.flipBit=wA;I.prototype.add=bA;I.prototype.subtract=SA;I.prototype.multiply=_A;I.prototype.divide=AA;I.prototype.remainder=CA;I.prototype.divideAndRemainder=IA;I.prototype.modPow=KA;I.prototype.modInverse=HA;I.prototype.pow=LA;I.prototype.gcd=VA;I.prototype.isProbablePrime=$A});var kg=R((G4,Og)=>{var xr=ie();Cn();De();var Pg=Og.exports=xr.sha1=xr.sha1||{};xr.md.sha1=xr.md.algorithms.sha1=Pg;Pg.create=function(){Bg||WA();var t=null,e=xr.util.createBuffer(),r=new Array(80),n={algorithm:"sha1",blockLength:64,digestLength:20,messageLength:0,fullMessageLength:null,messageLengthSize:8};return n.start=function(){n.messageLength=0,n.fullMessageLength=n.messageLength64=[];for(var i=n.messageLengthSize/4,s=0;s<i;++s)n.fullMessageLength.push(0);return e=xr.util.createBuffer(),t={h0:1732584193,h1:4023233417,h2:2562383102,h3:271733878,h4:3285377520},n},n.start(),n.update=function(i,s){s==="utf8"&&(i=xr.util.encodeUtf8(i));var o=i.length;n.messageLength+=o,o=[o/4294967296>>>0,o>>>0];for(var a=n.fullMessageLength.length-1;a>=0;--a)n.fullMessageLength[a]+=o[1],o[1]=o[0]+(n.fullMessageLength[a]/4294967296>>>0),n.fullMessageLength[a]=n.fullMessageLength[a]>>>0,o[0]=o[1]/4294967296>>>0;return e.putBytes(i),Lg(t,r,e),(e.read>2048||e.length()===0)&&e.compact(),n},n.digest=function(){var i=xr.util.createBuffer();i.putBytes(e.bytes());var s=n.fullMessageLength[n.fullMessageLength.length-1]+n.messageLengthSize,o=s&n.blockLength-1;i.putBytes(Df.substr(0,n.blockLength-o));for(var a,c,u=n.fullMessageLength[0]*8,l=0;l<n.fullMessageLength.length-1;++l)a=n.fullMessageLength[l+1]*8,c=a/4294967296>>>0,u+=c,i.putInt32(u>>>0),u=a>>>0;i.putInt32(u);var f={h0:t.h0,h1:t.h1,h2:t.h2,h3:t.h3,h4:t.h4};Lg(f,r,i);var h=xr.util.createBuffer();return h.putInt32(f.h0),h.putInt32(f.h1),h.putInt32(f.h2),h.putInt32(f.h3),h.putInt32(f.h4),h},n};var Df=null,Bg=!1;function WA(){Df=String.fromCharCode(128),Df+=xr.util.fillString(String.fromCharCode(0),64),Bg=!0}function Lg(t,e,r){for(var n,i,s,o,a,c,u,l,f=r.length();f>=64;){for(i=t.h0,s=t.h1,o=t.h2,a=t.h3,c=t.h4,l=0;l<16;++l)n=r.getInt32(),e[l]=n,u=a^s&(o^a),n=(i<<5|i>>>27)+u+c+1518500249+n,c=a,a=o,o=(s<<30|s>>>2)>>>0,s=i,i=n;for(;l<20;++l)n=e[l-3]^e[l-8]^e[l-14]^e[l-16],n=n<<1|n>>>31,e[l]=n,u=a^s&(o^a),n=(i<<5|i>>>27)+u+c+1518500249+n,c=a,a=o,o=(s<<30|s>>>2)>>>0,s=i,i=n;for(;l<32;++l)n=e[l-3]^e[l-8]^e[l-14]^e[l-16],n=n<<1|n>>>31,e[l]=n,u=s^o^a,n=(i<<5|i>>>27)+u+c+1859775393+n,c=a,a=o,o=(s<<30|s>>>2)>>>0,s=i,i=n;for(;l<40;++l)n=e[l-6]^e[l-16]^e[l-28]^e[l-32],n=n<<2|n>>>30,e[l]=n,u=s^o^a,n=(i<<5|i>>>27)+u+c+1859775393+n,c=a,a=o,o=(s<<30|s>>>2)>>>0,s=i,i=n;for(;l<60;++l)n=e[l-6]^e[l-16]^e[l-28]^e[l-32],n=n<<2|n>>>30,e[l]=n,u=s&o|a&(s^o),n=(i<<5|i>>>27)+u+c+2400959708+n,c=a,a=o,o=(s<<30|s>>>2)>>>0,s=i,i=n;for(;l<80;++l)n=e[l-6]^e[l-16]^e[l-28]^e[l-32],n=n<<2|n>>>30,e[l]=n,u=s^o^a,n=(i<<5|i>>>27)+u+c+3395469782+n,c=a,a=o,o=(s<<30|s>>>2)>>>0,s=i,i=n;t.h0=t.h0+i|0,t.h1=t.h1+s|0,t.h2=t.h2+o|0,t.h3=t.h3+a|0,t.h4=t.h4+c|0,f-=64}}});var Fg=R((Y4,Mg)=>{var br=ie();De();ai();kg();var Ug=Mg.exports=br.pkcs1=br.pkcs1||{};Ug.encode_rsa_oaep=function(t,e,r){var n,i,s,o;typeof r=="string"?(n=r,i=arguments[3]||void 0,s=arguments[4]||void 0):r&&(n=r.label||void 0,i=r.seed||void 0,s=r.md||void 0,r.mgf1&&r.mgf1.md&&(o=r.mgf1.md)),s?s.start():s=br.md.sha1.create(),o||(o=s);var a=Math.ceil(t.n.bitLength()/8),c=a-2*s.digestLength-2;if(e.length>c){var u=new Error("RSAES-OAEP input message length is too long.");throw u.length=e.length,u.maxLength=c,u}n||(n=""),s.update(n,"raw");for(var l=s.digest(),f="",h=c-e.length,d=0;d<h;d++)f+="\0";var p=l.getBytes()+f+""+e;if(!i)i=br.random.getBytes(s.digestLength);else if(i.length!==s.digestLength){var u=new Error("Invalid RSAES-OAEP seed. The seed length must match the digest length.");throw u.seedLength=i.length,u.digestLength=s.digestLength,u}var y=mc(i,a-s.digestLength-1,o),g=br.util.xorBytes(p,y,p.length),E=mc(g,s.digestLength,o),x=br.util.xorBytes(i,E,i.length);return"\0"+x+g};Ug.decode_rsa_oaep=function(t,e,r){var n,i,s;typeof r=="string"?(n=r,i=arguments[3]||void 0):r&&(n=r.label||void 0,i=r.md||void 0,r.mgf1&&r.mgf1.md&&(s=r.mgf1.md));var o=Math.ceil(t.n.bitLength()/8);if(e.length!==o){var g=new Error("RSAES-OAEP encoded message length is invalid.");throw g.length=e.length,g.expectedLength=o,g}if(i===void 0?i=br.md.sha1.create():i.start(),s||(s=i),o<2*i.digestLength+2)throw new Error("RSAES-OAEP key is too short for the hash function.");n||(n=""),i.update(n,"raw");for(var a=i.digest().getBytes(),c=e.charAt(0),u=e.substring(1,i.digestLength+1),l=e.substring(1+i.digestLength),f=mc(l,i.digestLength,s),h=br.util.xorBytes(u,f,u.length),d=mc(h,o-i.digestLength-1,s),p=br.util.xorBytes(l,d,l.length),y=p.substring(0,i.digestLength),g=c!=="\0",E=0;E<i.digestLength;++E)g|=a.charAt(E)!==y.charAt(E);for(var x=1,_=i.digestLength,B=i.digestLength;B<p.length;B++){var D=p.charCodeAt(B),P=D&1^1,te=x?65534:0;g|=D&te,x=x&P,_+=x}if(g||p.charCodeAt(_)!==1)throw new Error("Invalid RSAES-OAEP padding.");return p.substring(_+1)};function mc(t,e,r){r||(r=br.md.sha1.create());for(var n="",i=Math.ceil(e/r.digestLength),s=0;s<i;++s){var o=String.fromCharCode(s>>24&255,s>>16&255,s>>8&255,s&255);r.start(),r.update(t+o),n+=r.digest().getBytes()}return n.substring(0,e)}});var Kg=R((W4,Lf)=>{var Tn=ie();De();pc();ai();(function(){if(Tn.prime){Lf.exports=Tn.prime;return}var t=Lf.exports=Tn.prime=Tn.prime||{},e=Tn.jsbn.BigInteger,r=[6,4,2,4,2,4,6,2],n=new e(null);n.fromInt(30);var i=function(f,h){return f|h};t.generateProbablePrime=function(f,h,d){typeof h=="function"&&(d=h,h={}),h=h||{};var p=h.algorithm||"PRIMEINC";typeof p=="string"&&(p={name:p}),p.options=p.options||{};var y=h.prng||Tn.random,g={nextBytes:function(E){for(var x=y.getBytesSync(E.length),_=0;_<E.length;++_)E[_]=x.charCodeAt(_)}};if(p.name==="PRIMEINC")return s(f,g,p.options,d);throw new Error("Invalid prime generation algorithm: "+p.name)};function s(f,h,d,p){return"workers"in d?c(f,h,d,p):o(f,h,d,p)}function o(f,h,d,p){var y=u(f,h),g=0,E=l(y.bitLength());"millerRabinTests"in d&&(E=d.millerRabinTests);var x=10;"maxBlockTime"in d&&(x=d.maxBlockTime),a(y,f,h,g,E,x,p)}function a(f,h,d,p,y,g,E){var x=+new Date;do{if(f.bitLength()>h&&(f=u(h,d)),f.isProbablePrime(y))return E(null,f);f.dAddOffset(r[p++%8],0)}while(g<0||+new Date-x<g);Tn.util.setImmediate(function(){a(f,h,d,p,y,g,E)})}function c(f,h,d,p){if(typeof Worker>"u")return o(f,h,d,p);var y=u(f,h),g=d.workers,E=d.workLoad||100,x=E*30/8,_=d.workerScript||"forge/prime.worker.js";if(g===-1)return Tn.util.estimateCores(function(D,P){D&&(P=2),g=P-1,B()});B();function B(){g=Math.max(1,g);for(var D=[],P=0;P<g;++P)D[P]=new Worker(_);for(var te=g,P=0;P<g;++P)D[P].addEventListener("message",st);var ae=!1;function st(jt){if(!ae){--te;var Ct=jt.data;if(Ct.found){for(var gt=0;gt<D.length;++gt)D[gt].terminate();return ae=!0,p(null,new e(Ct.prime,16))}y.bitLength()>f&&(y=u(f,h));var Ci=y.toString(16);jt.target.postMessage({hex:Ci,workLoad:E}),y.dAddOffset(x,0)}}}}function u(f,h){var d=new e(f,h),p=f-1;return d.testBit(p)||d.bitwiseTo(e.ONE.shiftLeft(p),i,d),d.dAddOffset(31-d.mod(n).byteValue(),0),d}function l(f){return f<=100?27:f<=150?18:f<=200?15:f<=250?12:f<=300?9:f<=350?8:f<=400?7:f<=500?6:f<=600?5:f<=800?4:f<=1250?3:2}})()});var ao=R((Q4,Yg)=>{var z=ie();An();pc();ns();Fg();Kg();ai();De();typeof ce>"u"&&(ce=z.jsbn.BigInteger);var ce,Pf=z.util.isNodejs?Jn():null,S=z.asn1,$t=z.util;z.pki=z.pki||{};Yg.exports=z.pki.rsa=z.rsa=z.rsa||{};var Z=z.pki,QA=[6,4,2,4,2,4,6,2],XA={name:"PrivateKeyInfo",tagClass:S.Class.UNIVERSAL,type:S.Type.SEQUENCE,constructed:!0,value:[{name:"PrivateKeyInfo.version",tagClass:S.Class.UNIVERSAL,type:S.Type.INTEGER,constructed:!1,capture:"privateKeyVersion"},{name:"PrivateKeyInfo.privateKeyAlgorithm",tagClass:S.Class.UNIVERSAL,type:S.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:S.Class.UNIVERSAL,type:S.Type.OID,constructed:!1,capture:"privateKeyOid"}]},{name:"PrivateKeyInfo",tagClass:S.Class.UNIVERSAL,type:S.Type.OCTETSTRING,constructed:!1,capture:"privateKey"}]},jA={name:"RSAPrivateKey",tagClass:S.Class.UNIVERSAL,type:S.Type.SEQUENCE,constructed:!0,value:[{name:"RSAPrivateKey.version",tagClass:S.Class.UNIVERSAL,type:S.Type.INTEGER,constructed:!1,capture:"privateKeyVersion"},{name:"RSAPrivateKey.modulus",tagClass:S.Class.UNIVERSAL,type:S.Type.INTEGER,constructed:!1,capture:"privateKeyModulus"},{name:"RSAPrivateKey.publicExponent",tagClass:S.Class.UNIVERSAL,type:S.Type.INTEGER,constructed:!1,capture:"privateKeyPublicExponent"},{name:"RSAPrivateKey.privateExponent",tagClass:S.Class.UNIVERSAL,type:S.Type.INTEGER,constructed:!1,capture:"privateKeyPrivateExponent"},{name:"RSAPrivateKey.prime1",tagClass:S.Class.UNIVERSAL,type:S.Type.INTEGER,constructed:!1,capture:"privateKeyPrime1"},{name:"RSAPrivateKey.prime2",tagClass:S.Class.UNIVERSAL,type:S.Type.INTEGER,constructed:!1,capture:"privateKeyPrime2"},{name:"RSAPrivateKey.exponent1",tagClass:S.Class.UNIVERSAL,type:S.Type.INTEGER,constructed:!1,capture:"privateKeyExponent1"},{name:"RSAPrivateKey.exponent2",tagClass:S.Class.UNIVERSAL,type:S.Type.INTEGER,constructed:!1,capture:"privateKeyExponent2"},{name:"RSAPrivateKey.coefficient",tagClass:S.Class.UNIVERSAL,type:S.Type.INTEGER,constructed:!1,capture:"privateKeyCoefficient"}]},ZA={name:"RSAPublicKey",tagClass:S.Class.UNIVERSAL,type:S.Type.SEQUENCE,constructed:!0,value:[{name:"RSAPublicKey.modulus",tagClass:S.Class.UNIVERSAL,type:S.Type.INTEGER,constructed:!1,capture:"publicKeyModulus"},{name:"RSAPublicKey.exponent",tagClass:S.Class.UNIVERSAL,type:S.Type.INTEGER,constructed:!1,capture:"publicKeyExponent"}]},JA=z.pki.rsa.publicKeyValidator={name:"SubjectPublicKeyInfo",tagClass:S.Class.UNIVERSAL,type:S.Type.SEQUENCE,constructed:!0,captureAsn1:"subjectPublicKeyInfo",value:[{name:"SubjectPublicKeyInfo.AlgorithmIdentifier",tagClass:S.Class.UNIVERSAL,type:S.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:S.Class.UNIVERSAL,type:S.Type.OID,constructed:!1,capture:"publicKeyOid"}]},{name:"SubjectPublicKeyInfo.subjectPublicKey",tagClass:S.Class.UNIVERSAL,type:S.Type.BITSTRING,constructed:!1,value:[{name:"SubjectPublicKeyInfo.subjectPublicKey.RSAPublicKey",tagClass:S.Class.UNIVERSAL,type:S.Type.SEQUENCE,constructed:!0,optional:!0,captureAsn1:"rsaPublicKey"}]}]},eC={name:"DigestInfo",tagClass:S.Class.UNIVERSAL,type:S.Type.SEQUENCE,constructed:!0,value:[{name:"DigestInfo.DigestAlgorithm",tagClass:S.Class.UNIVERSAL,type:S.Type.SEQUENCE,constructed:!0,value:[{name:"DigestInfo.DigestAlgorithm.algorithmIdentifier",tagClass:S.Class.UNIVERSAL,type:S.Type.OID,constructed:!1,capture:"algorithmIdentifier"},{name:"DigestInfo.DigestAlgorithm.parameters",tagClass:S.Class.UNIVERSAL,type:S.Type.NULL,capture:"parameters",optional:!0,constructed:!1}]},{name:"DigestInfo.digest",tagClass:S.Class.UNIVERSAL,type:S.Type.OCTETSTRING,constructed:!1,capture:"digest"}]},tC=function(t){var e;if(t.algorithm in Z.oids)e=Z.oids[t.algorithm];else{var r=new Error("Unknown message digest algorithm.");throw r.algorithm=t.algorithm,r}var n=S.oidToDer(e).getBytes(),i=S.create(S.Class.UNIVERSAL,S.Type.SEQUENCE,!0,[]),s=S.create(S.Class.UNIVERSAL,S.Type.SEQUENCE,!0,[]);s.value.push(S.create(S.Class.UNIVERSAL,S.Type.OID,!1,n)),s.value.push(S.create(S.Class.UNIVERSAL,S.Type.NULL,!1,""));var o=S.create(S.Class.UNIVERSAL,S.Type.OCTETSTRING,!1,t.digest().getBytes());return i.value.push(s),i.value.push(o),S.toDer(i).getBytes()},$g=function(t,e,r){if(r)return t.modPow(e.e,e.n);if(!e.p||!e.q)return t.modPow(e.d,e.n);e.dP||(e.dP=e.d.mod(e.p.subtract(ce.ONE))),e.dQ||(e.dQ=e.d.mod(e.q.subtract(ce.ONE))),e.qInv||(e.qInv=e.q.modInverse(e.p));var n;do n=new ce(z.util.bytesToHex(z.random.getBytes(e.n.bitLength()/8)),16);while(n.compareTo(e.n)>=0||!n.gcd(e.n).equals(ce.ONE));t=t.multiply(n.modPow(e.e,e.n)).mod(e.n);for(var i=t.mod(e.p).modPow(e.dP,e.p),s=t.mod(e.q).modPow(e.dQ,e.q);i.compareTo(s)<0;)i=i.add(e.p);var o=i.subtract(s).multiply(e.qInv).mod(e.p).multiply(e.q).add(s);return o=o.multiply(n.modInverse(e.n)).mod(e.n),o};Z.rsa.encrypt=function(t,e,r){var n=r,i,s=Math.ceil(e.n.bitLength()/8);r!==!1&&r!==!0?(n=r===2,i=Gg(t,e,r)):(i=z.util.createBuffer(),i.putBytes(t));for(var o=new ce(i.toHex(),16),a=$g(o,e,n),c=a.toString(16),u=z.util.createBuffer(),l=s-Math.ceil(c.length/2);l>0;)u.putByte(0),--l;return u.putBytes(z.util.hexToBytes(c)),u.getBytes()};Z.rsa.decrypt=function(t,e,r,n){var i=Math.ceil(e.n.bitLength()/8);if(t.length!==i){var s=new Error("Encrypted message length is invalid.");throw s.length=t.length,s.expected=i,s}var o=new ce(z.util.createBuffer(t).toHex(),16);if(o.compareTo(e.n)>=0)throw new Error("Encrypted message is invalid.");for(var a=$g(o,e,r),c=a.toString(16),u=z.util.createBuffer(),l=i-Math.ceil(c.length/2);l>0;)u.putByte(0),--l;return u.putBytes(z.util.hexToBytes(c)),n!==!1?yc(u.getBytes(),e,r):u.getBytes()};Z.rsa.createKeyPairGenerationState=function(t,e,r){typeof t=="string"&&(t=parseInt(t,10)),t=t||2048,r=r||{};var n=r.prng||z.random,i={nextBytes:function(a){for(var c=n.getBytesSync(a.length),u=0;u<a.length;++u)a[u]=c.charCodeAt(u)}},s=r.algorithm||"PRIMEINC",o;if(s==="PRIMEINC")o={algorithm:s,state:0,bits:t,rng:i,eInt:e||65537,e:new ce(null),p:null,q:null,qBits:t>>1,pBits:t-(t>>1),pqState:0,num:null,keys:null},o.e.fromInt(o.eInt);else throw new Error("Invalid key generation algorithm: "+s);return o};Z.rsa.stepKeyPairGenerationState=function(t,e){"algorithm"in t||(t.algorithm="PRIMEINC");var r=new ce(null);r.fromInt(30);for(var n=0,i=function(f,h){return f|h},s=+new Date,o,a=0;t.keys===null&&(e<=0||a<e);){if(t.state===0){var c=t.p===null?t.pBits:t.qBits,u=c-1;t.pqState===0?(t.num=new ce(c,t.rng),t.num.testBit(u)||t.num.bitwiseTo(ce.ONE.shiftLeft(u),i,t.num),t.num.dAddOffset(31-t.num.mod(r).byteValue(),0),n=0,++t.pqState):t.pqState===1?t.num.bitLength()>c?t.pqState=0:t.num.isProbablePrime(nC(t.num.bitLength()))?++t.pqState:t.num.dAddOffset(QA[n++%8],0):t.pqState===2?t.pqState=t.num.subtract(ce.ONE).gcd(t.e).compareTo(ce.ONE)===0?3:0:t.pqState===3&&(t.pqState=0,t.p===null?t.p=t.num:t.q=t.num,t.p!==null&&t.q!==null&&++t.state,t.num=null)}else if(t.state===1)t.p.compareTo(t.q)<0&&(t.num=t.p,t.p=t.q,t.q=t.num),++t.state;else if(t.state===2)t.p1=t.p.subtract(ce.ONE),t.q1=t.q.subtract(ce.ONE),t.phi=t.p1.multiply(t.q1),++t.state;else if(t.state===3)t.phi.gcd(t.e).compareTo(ce.ONE)===0?++t.state:(t.p=null,t.q=null,t.state=0);else if(t.state===4)t.n=t.p.multiply(t.q),t.n.bitLength()===t.bits?++t.state:(t.q=null,t.state=0);else if(t.state===5){var l=t.e.modInverse(t.phi);t.keys={privateKey:Z.rsa.setPrivateKey(t.n,t.e,l,t.p,t.q,l.mod(t.p1),l.mod(t.q1),t.q.modInverse(t.p)),publicKey:Z.rsa.setPublicKey(t.n,t.e)}}o=+new Date,a+=o-s,s=o}return t.keys!==null};Z.rsa.generateKeyPair=function(t,e,r,n){if(arguments.length===1?typeof t=="object"?(r=t,t=void 0):typeof t=="function"&&(n=t,t=void 0):arguments.length===2?typeof t=="number"?typeof e=="function"?(n=e,e=void 0):typeof e!="number"&&(r=e,e=void 0):(r=t,n=e,t=void 0,e=void 0):arguments.length===3&&(typeof e=="number"?typeof r=="function"&&(n=r,r=void 0):(n=r,r=e,e=void 0)),r=r||{},t===void 0&&(t=r.bits||2048),e===void 0&&(e=r.e||65537),!z.options.usePureJavaScript&&!r.prng&&t>=256&&t<=16384&&(e===65537||e===3)){if(n){if(Vg("generateKeyPair"))return Pf.generateKeyPair("rsa",{modulusLength:t,publicExponent:e,publicKeyEncoding:{type:"spki",format:"pem"},privateKeyEncoding:{type:"pkcs8",format:"pem"}},function(a,c,u){if(a)return n(a);n(null,{privateKey:Z.privateKeyFromPem(u),publicKey:Z.publicKeyFromPem(c)})});if(qg("generateKey")&&qg("exportKey"))return $t.globalScope.crypto.subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:t,publicExponent:zg(e),hash:{name:"SHA-256"}},!0,["sign","verify"]).then(function(a){return $t.globalScope.crypto.subtle.exportKey("pkcs8",a.privateKey)}).then(void 0,function(a){n(a)}).then(function(a){if(a){var c=Z.privateKeyFromAsn1(S.fromDer(z.util.createBuffer(a)));n(null,{privateKey:c,publicKey:Z.setRsaPublicKey(c.n,c.e)})}});if(Hg("generateKey")&&Hg("exportKey")){var i=$t.globalScope.msCrypto.subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:t,publicExponent:zg(e),hash:{name:"SHA-256"}},!0,["sign","verify"]);i.oncomplete=function(a){var c=a.target.result,u=$t.globalScope.msCrypto.subtle.exportKey("pkcs8",c.privateKey);u.oncomplete=function(l){var f=l.target.result,h=Z.privateKeyFromAsn1(S.fromDer(z.util.createBuffer(f)));n(null,{privateKey:h,publicKey:Z.setRsaPublicKey(h.n,h.e)})},u.onerror=function(l){n(l)}},i.onerror=function(a){n(a)};return}}else if(Vg("generateKeyPairSync")){var s=Pf.generateKeyPairSync("rsa",{modulusLength:t,publicExponent:e,publicKeyEncoding:{type:"spki",format:"pem"},privateKeyEncoding:{type:"pkcs8",format:"pem"}});return{privateKey:Z.privateKeyFromPem(s.privateKey),publicKey:Z.publicKeyFromPem(s.publicKey)}}}var o=Z.rsa.createKeyPairGenerationState(t,e,r);if(!n)return Z.rsa.stepKeyPairGenerationState(o,0),o.keys;rC(o,r,n)};Z.setRsaPublicKey=Z.rsa.setPublicKey=function(t,e){var r={n:t,e};return r.encrypt=function(n,i,s){if(typeof i=="string"?i=i.toUpperCase():i===void 0&&(i="RSAES-PKCS1-V1_5"),i==="RSAES-PKCS1-V1_5")i={encode:function(a,c,u){return Gg(a,c,2).getBytes()}};else if(i==="RSA-OAEP"||i==="RSAES-OAEP")i={encode:function(a,c){return z.pkcs1.encode_rsa_oaep(c,a,s)}};else if(["RAW","NONE","NULL",null].indexOf(i)!==-1)i={encode:function(a){return a}};else if(typeof i=="string")throw new Error('Unsupported encryption scheme: "'+i+'".');var o=i.encode(n,r,!0);return Z.rsa.encrypt(o,r,!0)},r.verify=function(n,i,s,o){typeof s=="string"?s=s.toUpperCase():s===void 0&&(s="RSASSA-PKCS1-V1_5"),o===void 0&&(o={_parseAllDigestBytes:!0}),"_parseAllDigestBytes"in o||(o._parseAllDigestBytes=!0),s==="RSASSA-PKCS1-V1_5"?s={verify:function(c,u){u=yc(u,r,!0);var l=S.fromDer(u,{parseAllBytes:o._parseAllDigestBytes}),f={},h=[];if(!S.validate(l,eC,f,h)){var d=new Error("ASN.1 object does not contain a valid RSASSA-PKCS1-v1_5 DigestInfo value.");throw d.errors=h,d}var p=S.derToOid(f.algorithmIdentifier);if(!(p===z.oids.md2||p===z.oids.md5||p===z.oids.sha1||p===z.oids.sha224||p===z.oids.sha256||p===z.oids.sha384||p===z.oids.sha512||p===z.oids["sha512-224"]||p===z.oids["sha512-256"])){var d=new Error("Unknown RSASSA-PKCS1-v1_5 DigestAlgorithm identifier.");throw d.oid=p,d}if((p===z.oids.md2||p===z.oids.md5)&&!("parameters"in f))throw new Error("ASN.1 object does not contain a valid RSASSA-PKCS1-v1_5 DigestInfo value. Missing algorithm identifer NULL parameters.");return c===f.digest}}:(s==="NONE"||s==="NULL"||s===null)&&(s={verify:function(c,u){return u=yc(u,r,!0),c===u}});var a=Z.rsa.decrypt(i,r,!0,!1);return s.verify(n,a,r.n.bitLength())},r};Z.setRsaPrivateKey=Z.rsa.setPrivateKey=function(t,e,r,n,i,s,o,a){var c={n:t,e,d:r,p:n,q:i,dP:s,dQ:o,qInv:a};return c.decrypt=function(u,l,f){typeof l=="string"?l=l.toUpperCase():l===void 0&&(l="RSAES-PKCS1-V1_5");var h=Z.rsa.decrypt(u,c,!1,!1);if(l==="RSAES-PKCS1-V1_5")l={decode:yc};else if(l==="RSA-OAEP"||l==="RSAES-OAEP")l={decode:function(d,p){return z.pkcs1.decode_rsa_oaep(p,d,f)}};else if(["RAW","NONE","NULL",null].indexOf(l)!==-1)l={decode:function(d){return d}};else throw new Error('Unsupported encryption scheme: "'+l+'".');return l.decode(h,c,!1)},c.sign=function(u,l){var f=!1;typeof l=="string"&&(l=l.toUpperCase()),l===void 0||l==="RSASSA-PKCS1-V1_5"?(l={encode:tC},f=1):(l==="NONE"||l==="NULL"||l===null)&&(l={encode:function(){return u}},f=1);var h=l.encode(u,c.n.bitLength());return Z.rsa.encrypt(h,c,f)},c};Z.wrapRsaPrivateKey=function(t){return S.create(S.Class.UNIVERSAL,S.Type.SEQUENCE,!0,[S.create(S.Class.UNIVERSAL,S.Type.INTEGER,!1,S.integerToDer(0).getBytes()),S.create(S.Class.UNIVERSAL,S.Type.SEQUENCE,!0,[S.create(S.Class.UNIVERSAL,S.Type.OID,!1,S.oidToDer(Z.oids.rsaEncryption).getBytes()),S.create(S.Class.UNIVERSAL,S.Type.NULL,!1,"")]),S.create(S.Class.UNIVERSAL,S.Type.OCTETSTRING,!1,S.toDer(t).getBytes())])};Z.privateKeyFromAsn1=function(t){var e={},r=[];if(S.validate(t,XA,e,r)&&(t=S.fromDer(z.util.createBuffer(e.privateKey))),e={},r=[],!S.validate(t,jA,e,r)){var n=new Error("Cannot read private key. ASN.1 object does not contain an RSAPrivateKey.");throw n.errors=r,n}var i,s,o,a,c,u,l,f;return i=z.util.createBuffer(e.privateKeyModulus).toHex(),s=z.util.createBuffer(e.privateKeyPublicExponent).toHex(),o=z.util.createBuffer(e.privateKeyPrivateExponent).toHex(),a=z.util.createBuffer(e.privateKeyPrime1).toHex(),c=z.util.createBuffer(e.privateKeyPrime2).toHex(),u=z.util.createBuffer(e.privateKeyExponent1).toHex(),l=z.util.createBuffer(e.privateKeyExponent2).toHex(),f=z.util.createBuffer(e.privateKeyCoefficient).toHex(),Z.setRsaPrivateKey(new ce(i,16),new ce(s,16),new ce(o,16),new ce(a,16),new ce(c,16),new ce(u,16),new ce(l,16),new ce(f,16))};Z.privateKeyToAsn1=Z.privateKeyToRSAPrivateKey=function(t){return S.create(S.Class.UNIVERSAL,S.Type.SEQUENCE,!0,[S.create(S.Class.UNIVERSAL,S.Type.INTEGER,!1,S.integerToDer(0).getBytes()),S.create(S.Class.UNIVERSAL,S.Type.INTEGER,!1,Sr(t.n)),S.create(S.Class.UNIVERSAL,S.Type.INTEGER,!1,Sr(t.e)),S.create(S.Class.UNIVERSAL,S.Type.INTEGER,!1,Sr(t.d)),S.create(S.Class.UNIVERSAL,S.Type.INTEGER,!1,Sr(t.p)),S.create(S.Class.UNIVERSAL,S.Type.INTEGER,!1,Sr(t.q)),S.create(S.Class.UNIVERSAL,S.Type.INTEGER,!1,Sr(t.dP)),S.create(S.Class.UNIVERSAL,S.Type.INTEGER,!1,Sr(t.dQ)),S.create(S.Class.UNIVERSAL,S.Type.INTEGER,!1,Sr(t.qInv))])};Z.publicKeyFromAsn1=function(t){var e={},r=[];if(S.validate(t,JA,e,r)){var n=S.derToOid(e.publicKeyOid);if(n!==Z.oids.rsaEncryption){var i=new Error("Cannot read public key. Unknown OID.");throw i.oid=n,i}t=e.rsaPublicKey}if(r=[],!S.validate(t,ZA,e,r)){var i=new Error("Cannot read public key. ASN.1 object does not contain an RSAPublicKey.");throw i.errors=r,i}var s=z.util.createBuffer(e.publicKeyModulus).toHex(),o=z.util.createBuffer(e.publicKeyExponent).toHex();return Z.setRsaPublicKey(new ce(s,16),new ce(o,16))};Z.publicKeyToAsn1=Z.publicKeyToSubjectPublicKeyInfo=function(t){return S.create(S.Class.UNIVERSAL,S.Type.SEQUENCE,!0,[S.create(S.Class.UNIVERSAL,S.Type.SEQUENCE,!0,[S.create(S.Class.UNIVERSAL,S.Type.OID,!1,S.oidToDer(Z.oids.rsaEncryption).getBytes()),S.create(S.Class.UNIVERSAL,S.Type.NULL,!1,"")]),S.create(S.Class.UNIVERSAL,S.Type.BITSTRING,!1,[Z.publicKeyToRSAPublicKey(t)])])};Z.publicKeyToRSAPublicKey=function(t){return S.create(S.Class.UNIVERSAL,S.Type.SEQUENCE,!0,[S.create(S.Class.UNIVERSAL,S.Type.INTEGER,!1,Sr(t.n)),S.create(S.Class.UNIVERSAL,S.Type.INTEGER,!1,Sr(t.e))])};function Gg(t,e,r){var n=z.util.createBuffer(),i=Math.ceil(e.n.bitLength()/8);if(t.length>i-11){var s=new Error("Message is too long for PKCS#1 v1.5 padding.");throw s.length=t.length,s.max=i-11,s}n.putByte(0),n.putByte(r);var o=i-3-t.length,a;if(r===0||r===1){a=r===0?0:255;for(var c=0;c<o;++c)n.putByte(a)}else for(;o>0;){for(var u=0,l=z.random.getBytes(o),c=0;c<o;++c)a=l.charCodeAt(c),a===0?++u:n.putByte(a);o=u}return n.putByte(0),n.putBytes(t),n}function yc(t,e,r,n){var i=Math.ceil(e.n.bitLength()/8),s=z.util.createBuffer(t),o=s.getByte(),a=s.getByte();if(o!==0||r&&a!==0&&a!==1||!r&&a!=2||r&&a===0&&typeof n>"u")throw new Error("Encryption block is invalid.");var c=0;if(a===0){c=i-3-n;for(var u=0;u<c;++u)if(s.getByte()!==0)throw new Error("Encryption block is invalid.")}else if(a===1)for(c=0;s.length()>1;){if(s.getByte()!==255){--s.read;break}++c}else if(a===2)for(c=0;s.length()>1;){if(s.getByte()===0){--s.read;break}++c}var l=s.getByte();if(l!==0||c!==i-3-s.length())throw new Error("Encryption block is invalid.");return s.getBytes()}function rC(t,e,r){typeof e=="function"&&(r=e,e={}),e=e||{};var n={algorithm:{name:e.algorithm||"PRIMEINC",options:{workers:e.workers||2,workLoad:e.workLoad||100,workerScript:e.workerScript}}};"prng"in e&&(n.prng=e.prng),i();function i(){s(t.pBits,function(a,c){if(a)return r(a);if(t.p=c,t.q!==null)return o(a,t.q);s(t.qBits,o)})}function s(a,c){z.prime.generateProbablePrime(a,n,c)}function o(a,c){if(a)return r(a);if(t.q=c,t.p.compareTo(t.q)<0){var u=t.p;t.p=t.q,t.q=u}if(t.p.subtract(ce.ONE).gcd(t.e).compareTo(ce.ONE)!==0){t.p=null,i();return}if(t.q.subtract(ce.ONE).gcd(t.e).compareTo(ce.ONE)!==0){t.q=null,s(t.qBits,o);return}if(t.p1=t.p.subtract(ce.ONE),t.q1=t.q.subtract(ce.ONE),t.phi=t.p1.multiply(t.q1),t.phi.gcd(t.e).compareTo(ce.ONE)!==0){t.p=t.q=null,i();return}if(t.n=t.p.multiply(t.q),t.n.bitLength()!==t.bits){t.q=null,s(t.qBits,o);return}var l=t.e.modInverse(t.phi);t.keys={privateKey:Z.rsa.setPrivateKey(t.n,t.e,l,t.p,t.q,l.mod(t.p1),l.mod(t.q1),t.q.modInverse(t.p)),publicKey:Z.rsa.setPublicKey(t.n,t.e)},r(null,t.keys)}}function Sr(t){var e=t.toString(16);e[0]>="8"&&(e="00"+e);var r=z.util.hexToBytes(e);return r.length>1&&(r.charCodeAt(0)===0&&!(r.charCodeAt(1)&128)||r.charCodeAt(0)===255&&(r.charCodeAt(1)&128)===128)?r.substr(1):r}function nC(t){return t<=100?27:t<=150?18:t<=200?15:t<=250?12:t<=300?9:t<=350?8:t<=400?7:t<=500?6:t<=600?5:t<=800?4:t<=1250?3:2}function Vg(t){return z.util.isNodejs&&typeof Pf[t]=="function"}function qg(t){return typeof $t.globalScope<"u"&&typeof $t.globalScope.crypto=="object"&&typeof $t.globalScope.crypto.subtle=="object"&&typeof $t.globalScope.crypto.subtle[t]=="function"}function Hg(t){return typeof $t.globalScope<"u"&&typeof $t.globalScope.msCrypto=="object"&&typeof $t.globalScope.msCrypto.subtle=="object"&&typeof $t.globalScope.msCrypto.subtle[t]=="function"}function zg(t){for(var e=z.util.hexToBytes(t.toString(16)),r=new Uint8Array(e.length),n=0;n<e.length;++n)r[n]=e.charCodeAt(n);return r}});var Of=R((X4,Zg)=>{var $=ie();rs();An();sc();Cn();xg();ns();cc();Sg();ao();De();var m=$.asn1,L=Zg.exports=$.pki=$.pki||{},ue=L.oids,Ye={};Ye.CN=ue.commonName;Ye.commonName="CN";Ye.C=ue.countryName;Ye.countryName="C";Ye.L=ue.localityName;Ye.localityName="L";Ye.ST=ue.stateOrProvinceName;Ye.stateOrProvinceName="ST";Ye.O=ue.organizationName;Ye.organizationName="O";Ye.OU=ue.organizationalUnitName;Ye.organizationalUnitName="OU";Ye.E=ue.emailAddress;Ye.emailAddress="E";var Qg=$.pki.rsa.publicKeyValidator,iC={name:"Certificate",tagClass:m.Class.UNIVERSAL,type:m.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.TBSCertificate",tagClass:m.Class.UNIVERSAL,type:m.Type.SEQUENCE,constructed:!0,captureAsn1:"tbsCertificate",value:[{name:"Certificate.TBSCertificate.version",tagClass:m.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,value:[{name:"Certificate.TBSCertificate.version.integer",tagClass:m.Class.UNIVERSAL,type:m.Type.INTEGER,constructed:!1,capture:"certVersion"}]},{name:"Certificate.TBSCertificate.serialNumber",tagClass:m.Class.UNIVERSAL,type:m.Type.INTEGER,constructed:!1,capture:"certSerialNumber"},{name:"Certificate.TBSCertificate.signature",tagClass:m.Class.UNIVERSAL,type:m.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.TBSCertificate.signature.algorithm",tagClass:m.Class.UNIVERSAL,type:m.Type.OID,constructed:!1,capture:"certinfoSignatureOid"},{name:"Certificate.TBSCertificate.signature.parameters",tagClass:m.Class.UNIVERSAL,optional:!0,captureAsn1:"certinfoSignatureParams"}]},{name:"Certificate.TBSCertificate.issuer",tagClass:m.Class.UNIVERSAL,type:m.Type.SEQUENCE,constructed:!0,captureAsn1:"certIssuer"},{name:"Certificate.TBSCertificate.validity",tagClass:m.Class.UNIVERSAL,type:m.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.TBSCertificate.validity.notBefore (utc)",tagClass:m.Class.UNIVERSAL,type:m.Type.UTCTIME,constructed:!1,optional:!0,capture:"certValidity1UTCTime"},{name:"Certificate.TBSCertificate.validity.notBefore (generalized)",tagClass:m.Class.UNIVERSAL,type:m.Type.GENERALIZEDTIME,constructed:!1,optional:!0,capture:"certValidity2GeneralizedTime"},{name:"Certificate.TBSCertificate.validity.notAfter (utc)",tagClass:m.Class.UNIVERSAL,type:m.Type.UTCTIME,constructed:!1,optional:!0,capture:"certValidity3UTCTime"},{name:"Certificate.TBSCertificate.validity.notAfter (generalized)",tagClass:m.Class.UNIVERSAL,type:m.Type.GENERALIZEDTIME,constructed:!1,optional:!0,capture:"certValidity4GeneralizedTime"}]},{name:"Certificate.TBSCertificate.subject",tagClass:m.Class.UNIVERSAL,type:m.Type.SEQUENCE,constructed:!0,captureAsn1:"certSubject"},Qg,{name:"Certificate.TBSCertificate.issuerUniqueID",tagClass:m.Class.CONTEXT_SPECIFIC,type:1,constructed:!0,optional:!0,value:[{name:"Certificate.TBSCertificate.issuerUniqueID.id",tagClass:m.Class.UNIVERSAL,type:m.Type.BITSTRING,constructed:!1,captureBitStringValue:"certIssuerUniqueId"}]},{name:"Certificate.TBSCertificate.subjectUniqueID",tagClass:m.Class.CONTEXT_SPECIFIC,type:2,constructed:!0,optional:!0,value:[{name:"Certificate.TBSCertificate.subjectUniqueID.id",tagClass:m.Class.UNIVERSAL,type:m.Type.BITSTRING,constructed:!1,captureBitStringValue:"certSubjectUniqueId"}]},{name:"Certificate.TBSCertificate.extensions",tagClass:m.Class.CONTEXT_SPECIFIC,type:3,constructed:!0,captureAsn1:"certExtensions",optional:!0}]},{name:"Certificate.signatureAlgorithm",tagClass:m.Class.UNIVERSAL,type:m.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.signatureAlgorithm.algorithm",tagClass:m.Class.UNIVERSAL,type:m.Type.OID,constructed:!1,capture:"certSignatureOid"},{name:"Certificate.TBSCertificate.signature.parameters",tagClass:m.Class.UNIVERSAL,optional:!0,captureAsn1:"certSignatureParams"}]},{name:"Certificate.signatureValue",tagClass:m.Class.UNIVERSAL,type:m.Type.BITSTRING,constructed:!1,captureBitStringValue:"certSignature"}]},sC={name:"rsapss",tagClass:m.Class.UNIVERSAL,type:m.Type.SEQUENCE,constructed:!0,value:[{name:"rsapss.hashAlgorithm",tagClass:m.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,value:[{name:"rsapss.hashAlgorithm.AlgorithmIdentifier",tagClass:m.Class.UNIVERSAL,type:m.Class.SEQUENCE,constructed:!0,optional:!0,value:[{name:"rsapss.hashAlgorithm.AlgorithmIdentifier.algorithm",tagClass:m.Class.UNIVERSAL,type:m.Type.OID,constructed:!1,capture:"hashOid"}]}]},{name:"rsapss.maskGenAlgorithm",tagClass:m.Class.CONTEXT_SPECIFIC,type:1,constructed:!0,value:[{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier",tagClass:m.Class.UNIVERSAL,type:m.Class.SEQUENCE,constructed:!0,optional:!0,value:[{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier.algorithm",tagClass:m.Class.UNIVERSAL,type:m.Type.OID,constructed:!1,capture:"maskGenOid"},{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier.params",tagClass:m.Class.UNIVERSAL,type:m.Type.SEQUENCE,constructed:!0,value:[{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier.params.algorithm",tagClass:m.Class.UNIVERSAL,type:m.Type.OID,constructed:!1,capture:"maskGenHashOid"}]}]}]},{name:"rsapss.saltLength",tagClass:m.Class.CONTEXT_SPECIFIC,type:2,optional:!0,value:[{name:"rsapss.saltLength.saltLength",tagClass:m.Class.UNIVERSAL,type:m.Class.INTEGER,constructed:!1,capture:"saltLength"}]},{name:"rsapss.trailerField",tagClass:m.Class.CONTEXT_SPECIFIC,type:3,optional:!0,value:[{name:"rsapss.trailer.trailer",tagClass:m.Class.UNIVERSAL,type:m.Class.INTEGER,constructed:!1,capture:"trailer"}]}]},oC={name:"CertificationRequestInfo",tagClass:m.Class.UNIVERSAL,type:m.Type.SEQUENCE,constructed:!0,captureAsn1:"certificationRequestInfo",value:[{name:"CertificationRequestInfo.integer",tagClass:m.Class.UNIVERSAL,type:m.Type.INTEGER,constructed:!1,capture:"certificationRequestInfoVersion"},{name:"CertificationRequestInfo.subject",tagClass:m.Class.UNIVERSAL,type:m.Type.SEQUENCE,constructed:!0,captureAsn1:"certificationRequestInfoSubject"},Qg,{name:"CertificationRequestInfo.attributes",tagClass:m.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,capture:"certificationRequestInfoAttributes",value:[{name:"CertificationRequestInfo.attributes",tagClass:m.Class.UNIVERSAL,type:m.Type.SEQUENCE,constructed:!0,value:[{name:"CertificationRequestInfo.attributes.type",tagClass:m.Class.UNIVERSAL,type:m.Type.OID,constructed:!1},{name:"CertificationRequestInfo.attributes.value",tagClass:m.Class.UNIVERSAL,type:m.Type.SET,constructed:!0}]}]}]},aC={name:"CertificationRequest",tagClass:m.Class.UNIVERSAL,type:m.Type.SEQUENCE,constructed:!0,captureAsn1:"csr",value:[oC,{name:"CertificationRequest.signatureAlgorithm",tagClass:m.Class.UNIVERSAL,type:m.Type.SEQUENCE,constructed:!0,value:[{name:"CertificationRequest.signatureAlgorithm.algorithm",tagClass:m.Class.UNIVERSAL,type:m.Type.OID,constructed:!1,capture:"csrSignatureOid"},{name:"CertificationRequest.signatureAlgorithm.parameters",tagClass:m.Class.UNIVERSAL,optional:!0,captureAsn1:"csrSignatureParams"}]},{name:"CertificationRequest.signature",tagClass:m.Class.UNIVERSAL,type:m.Type.BITSTRING,constructed:!1,captureBitStringValue:"csrSignature"}]};L.RDNAttributesAsArray=function(t,e){for(var r=[],n,i,s,o=0;o<t.value.length;++o){n=t.value[o];for(var a=0;a<n.value.length;++a)s={},i=n.value[a],s.type=m.derToOid(i.value[0].value),s.value=i.value[1].value,s.valueTagClass=i.value[1].type,s.type in ue&&(s.name=ue[s.type],s.name in Ye&&(s.shortName=Ye[s.name])),e&&(e.update(s.type),e.update(s.value)),r.push(s)}return r};L.CRIAttributesAsArray=function(t){for(var e=[],r=0;r<t.length;++r)for(var n=t[r],i=m.derToOid(n.value[0].value),s=n.value[1].value,o=0;o<s.length;++o){var a={};if(a.type=i,a.value=s[o].value,a.valueTagClass=s[o].type,a.type in ue&&(a.name=ue[a.type],a.name in Ye&&(a.shortName=Ye[a.name])),a.type===ue.extensionRequest){a.extensions=[];for(var c=0;c<a.value.length;++c)a.extensions.push(L.certificateExtensionFromAsn1(a.value[c]))}e.push(a)}return e};function Rn(t,e){typeof e=="string"&&(e={shortName:e});for(var r=null,n,i=0;r===null&&i<t.attributes.length;++i)n=t.attributes[i],(e.type&&e.type===n.type||e.name&&e.name===n.name||e.shortName&&e.shortName===n.shortName)&&(r=n);return r}var gc=function(t,e,r){var n={};if(t!==ue["RSASSA-PSS"])return n;r&&(n={hash:{algorithmOid:ue.sha1},mgf:{algorithmOid:ue.mgf1,hash:{algorithmOid:ue.sha1}},saltLength:20});var i={},s=[];if(!m.validate(e,sC,i,s)){var o=new Error("Cannot read RSASSA-PSS parameter block.");throw o.errors=s,o}return i.hashOid!==void 0&&(n.hash=n.hash||{},n.hash.algorithmOid=m.derToOid(i.hashOid)),i.maskGenOid!==void 0&&(n.mgf=n.mgf||{},n.mgf.algorithmOid=m.derToOid(i.maskGenOid),n.mgf.hash=n.mgf.hash||{},n.mgf.hash.algorithmOid=m.derToOid(i.maskGenHashOid)),i.saltLength!==void 0&&(n.saltLength=i.saltLength.charCodeAt(0)),n},Ec=function(t){switch(ue[t.signatureOid]){case"sha1WithRSAEncryption":case"sha1WithRSASignature":return $.md.sha1.create();case"md5WithRSAEncryption":return $.md.md5.create();case"sha256WithRSAEncryption":return $.md.sha256.create();case"sha384WithRSAEncryption":return $.md.sha384.create();case"sha512WithRSAEncryption":return $.md.sha512.create();case"RSASSA-PSS":return $.md.sha256.create();default:var e=new Error("Could not compute "+t.type+" digest. Unknown signature OID.");throw e.signatureOid=t.signatureOid,e}},Xg=function(t){var e=t.certificate,r;switch(e.signatureOid){case ue.sha1WithRSAEncryption:case ue.sha1WithRSASignature:break;case ue["RSASSA-PSS"]:var n,i;if(n=ue[e.signatureParameters.mgf.hash.algorithmOid],n===void 0||$.md[n]===void 0){var s=new Error("Unsupported MGF hash function.");throw s.oid=e.signatureParameters.mgf.hash.algorithmOid,s.name=n,s}if(i=ue[e.signatureParameters.mgf.algorithmOid],i===void 0||$.mgf[i]===void 0){var s=new Error("Unsupported MGF function.");throw s.oid=e.signatureParameters.mgf.algorithmOid,s.name=i,s}if(i=$.mgf[i].create($.md[n].create()),n=ue[e.signatureParameters.hash.algorithmOid],n===void 0||$.md[n]===void 0){var s=new Error("Unsupported RSASSA-PSS hash function.");throw s.oid=e.signatureParameters.hash.algorithmOid,s.name=n,s}r=$.pss.create($.md[n].create(),i,e.signatureParameters.saltLength);break}return e.publicKey.verify(t.md.digest().getBytes(),t.signature,r)};L.certificateFromPem=function(t,e,r){var n=$.pem.decode(t)[0];if(n.type!=="CERTIFICATE"&&n.type!=="X509 CERTIFICATE"&&n.type!=="TRUSTED CERTIFICATE"){var i=new Error('Could not convert certificate from PEM; PEM header type is not "CERTIFICATE", "X509 CERTIFICATE", or "TRUSTED CERTIFICATE".');throw i.headerType=n.type,i}if(n.procType&&n.procType.type==="ENCRYPTED")throw new Error("Could not convert certificate from PEM; PEM is encrypted.");var s=m.fromDer(n.body,r);return L.certificateFromAsn1(s,e)};L.certificateToPem=function(t,e){var r={type:"CERTIFICATE",body:m.toDer(L.certificateToAsn1(t)).getBytes()};return $.pem.encode(r,{maxline:e})};L.publicKeyFromPem=function(t){var e=$.pem.decode(t)[0];if(e.type!=="PUBLIC KEY"&&e.type!=="RSA PUBLIC KEY"){var r=new Error('Could not convert public key from PEM; PEM header type is not "PUBLIC KEY" or "RSA PUBLIC KEY".');throw r.headerType=e.type,r}if(e.procType&&e.procType.type==="ENCRYPTED")throw new Error("Could not convert public key from PEM; PEM is encrypted.");var n=m.fromDer(e.body);return L.publicKeyFromAsn1(n)};L.publicKeyToPem=function(t,e){var r={type:"PUBLIC KEY",body:m.toDer(L.publicKeyToAsn1(t)).getBytes()};return $.pem.encode(r,{maxline:e})};L.publicKeyToRSAPublicKeyPem=function(t,e){var r={type:"RSA PUBLIC KEY",body:m.toDer(L.publicKeyToRSAPublicKey(t)).getBytes()};return $.pem.encode(r,{maxline:e})};L.getPublicKeyFingerprint=function(t,e){e=e||{};var r=e.md||$.md.sha1.create(),n=e.type||"RSAPublicKey",i;switch(n){case"RSAPublicKey":i=m.toDer(L.publicKeyToRSAPublicKey(t)).getBytes();break;case"SubjectPublicKeyInfo":i=m.toDer(L.publicKeyToAsn1(t)).getBytes();break;default:throw new Error('Unknown fingerprint type "'+e.type+'".')}r.start(),r.update(i);var s=r.digest();if(e.encoding==="hex"){var o=s.toHex();return e.delimiter?o.match(/.{2}/g).join(e.delimiter):o}else{if(e.encoding==="binary")return s.getBytes();if(e.encoding)throw new Error('Unknown encoding "'+e.encoding+'".')}return s};L.certificationRequestFromPem=function(t,e,r){var n=$.pem.decode(t)[0];if(n.type!=="CERTIFICATE REQUEST"){var i=new Error('Could not convert certification request from PEM; PEM header type is not "CERTIFICATE REQUEST".');throw i.headerType=n.type,i}if(n.procType&&n.procType.type==="ENCRYPTED")throw new Error("Could not convert certification request from PEM; PEM is encrypted.");var s=m.fromDer(n.body,r);return L.certificationRequestFromAsn1(s,e)};L.certificationRequestToPem=function(t,e){var r={type:"CERTIFICATE REQUEST",body:m.toDer(L.certificationRequestToAsn1(t)).getBytes()};return $.pem.encode(r,{maxline:e})};L.createCertificate=function(){var t={};return t.version=2,t.serialNumber="00",t.signatureOid=null,t.signature=null,t.siginfo={},t.siginfo.algorithmOid=null,t.validity={},t.validity.notBefore=new Date,t.validity.notAfter=new Date,t.issuer={},t.issuer.getField=function(e){return Rn(t.issuer,e)},t.issuer.addField=function(e){Gt([e]),t.issuer.attributes.push(e)},t.issuer.attributes=[],t.issuer.hash=null,t.subject={},t.subject.getField=function(e){return Rn(t.subject,e)},t.subject.addField=function(e){Gt([e]),t.subject.attributes.push(e)},t.subject.attributes=[],t.subject.hash=null,t.extensions=[],t.publicKey=null,t.md=null,t.setSubject=function(e,r){Gt(e),t.subject.attributes=e,delete t.subject.uniqueId,r&&(t.subject.uniqueId=r),t.subject.hash=null},t.setIssuer=function(e,r){Gt(e),t.issuer.attributes=e,delete t.issuer.uniqueId,r&&(t.issuer.uniqueId=r),t.issuer.hash=null},t.setExtensions=function(e){for(var r=0;r<e.length;++r)jg(e[r],{cert:t});t.extensions=e},t.getExtension=function(e){typeof e=="string"&&(e={name:e});for(var r=null,n,i=0;r===null&&i<t.extensions.length;++i)n=t.extensions[i],(e.id&&n.id===e.id||e.name&&n.name===e.name)&&(r=n);return r},t.sign=function(e,r){t.md=r||$.md.sha1.create();var n=ue[t.md.algorithm+"WithRSAEncryption"];if(!n){var i=new Error("Could not compute certificate digest. Unknown message digest algorithm OID.");throw i.algorithm=t.md.algorithm,i}t.signatureOid=t.siginfo.algorithmOid=n,t.tbsCertificate=L.getTBSCertificate(t);var s=m.toDer(t.tbsCertificate);t.md.update(s.getBytes()),t.signature=e.sign(t.md)},t.verify=function(e){var r=!1;if(!t.issued(e)){var n=e.issuer,i=t.subject,s=new Error("The parent certificate did not issue the given child certificate; the child certificate's issuer does not match the parent's subject.");throw s.expectedIssuer=i.attributes,s.actualIssuer=n.attributes,s}var o=e.md;if(o===null){o=Ec({signatureOid:e.signatureOid,type:"certificate"});var a=e.tbsCertificate||L.getTBSCertificate(e),c=m.toDer(a);o.update(c.getBytes())}return o!==null&&(r=Xg({certificate:t,md:o,signature:e.signature})),r},t.isIssuer=function(e){var r=!1,n=t.issuer,i=e.subject;if(n.hash&&i.hash)r=n.hash===i.hash;else if(n.attributes.length===i.attributes.length){r=!0;for(var s,o,a=0;r&&a<n.attributes.length;++a)s=n.attributes[a],o=i.attributes[a],(s.type!==o.type||s.value!==o.value)&&(r=!1)}return r},t.issued=function(e){return e.isIssuer(t)},t.generateSubjectKeyIdentifier=function(){return L.getPublicKeyFingerprint(t.publicKey,{type:"RSAPublicKey"})},t.verifySubjectKeyIdentifier=function(){for(var e=ue.subjectKeyIdentifier,r=0;r<t.extensions.length;++r){var n=t.extensions[r];if(n.id===e){var i=t.generateSubjectKeyIdentifier().getBytes();return $.util.hexToBytes(n.subjectKeyIdentifier)===i}}return!1},t};L.certificateFromAsn1=function(t,e){var r={},n=[];if(!m.validate(t,iC,r,n)){var i=new Error("Cannot read X.509 certificate. ASN.1 object is not an X509v3 Certificate.");throw i.errors=n,i}var s=m.derToOid(r.publicKeyOid);if(s!==L.oids.rsaEncryption)throw new Error("Cannot read public key. OID is not RSA.");var o=L.createCertificate();o.version=r.certVersion?r.certVersion.charCodeAt(0):0;var a=$.util.createBuffer(r.certSerialNumber);o.serialNumber=a.toHex(),o.signatureOid=$.asn1.derToOid(r.certSignatureOid),o.signatureParameters=gc(o.signatureOid,r.certSignatureParams,!0),o.siginfo.algorithmOid=$.asn1.derToOid(r.certinfoSignatureOid),o.siginfo.parameters=gc(o.siginfo.algorithmOid,r.certinfoSignatureParams,!1),o.signature=r.certSignature;var c=[];if(r.certValidity1UTCTime!==void 0&&c.push(m.utcTimeToDate(r.certValidity1UTCTime)),r.certValidity2GeneralizedTime!==void 0&&c.push(m.generalizedTimeToDate(r.certValidity2GeneralizedTime)),r.certValidity3UTCTime!==void 0&&c.push(m.utcTimeToDate(r.certValidity3UTCTime)),r.certValidity4GeneralizedTime!==void 0&&c.push(m.generalizedTimeToDate(r.certValidity4GeneralizedTime)),c.length>2)throw new Error("Cannot read notBefore/notAfter validity times; more than two times were provided in the certificate.");if(c.length<2)throw new Error("Cannot read notBefore/notAfter validity times; they were not provided as either UTCTime or GeneralizedTime.");if(o.validity.notBefore=c[0],o.validity.notAfter=c[1],o.tbsCertificate=r.tbsCertificate,e){o.md=Ec({signatureOid:o.signatureOid,type:"certificate"});var u=m.toDer(o.tbsCertificate);o.md.update(u.getBytes())}var l=$.md.sha1.create(),f=m.toDer(r.certIssuer);l.update(f.getBytes()),o.issuer.getField=function(p){return Rn(o.issuer,p)},o.issuer.addField=function(p){Gt([p]),o.issuer.attributes.push(p)},o.issuer.attributes=L.RDNAttributesAsArray(r.certIssuer),r.certIssuerUniqueId&&(o.issuer.uniqueId=r.certIssuerUniqueId),o.issuer.hash=l.digest().toHex();var h=$.md.sha1.create(),d=m.toDer(r.certSubject);return h.update(d.getBytes()),o.subject.getField=function(p){return Rn(o.subject,p)},o.subject.addField=function(p){Gt([p]),o.subject.attributes.push(p)},o.subject.attributes=L.RDNAttributesAsArray(r.certSubject),r.certSubjectUniqueId&&(o.subject.uniqueId=r.certSubjectUniqueId),o.subject.hash=h.digest().toHex(),r.certExtensions?o.extensions=L.certificateExtensionsFromAsn1(r.certExtensions):o.extensions=[],o.publicKey=L.publicKeyFromAsn1(r.subjectPublicKeyInfo),o};L.certificateExtensionsFromAsn1=function(t){for(var e=[],r=0;r<t.value.length;++r)for(var n=t.value[r],i=0;i<n.value.length;++i)e.push(L.certificateExtensionFromAsn1(n.value[i]));return e};L.certificateExtensionFromAsn1=function(t){var e={};if(e.id=m.derToOid(t.value[0].value),e.critical=!1,t.value[1].type===m.Type.BOOLEAN?(e.critical=t.value[1].value.charCodeAt(0)!==0,e.value=t.value[2].value):e.value=t.value[1].value,e.id in ue){if(e.name=ue[e.id],e.name==="keyUsage"){var r=m.fromDer(e.value),n=0,i=0;r.value.length>1&&(n=r.value.charCodeAt(1),i=r.value.length>2?r.value.charCodeAt(2):0),e.digitalSignature=(n&128)===128,e.nonRepudiation=(n&64)===64,e.keyEncipherment=(n&32)===32,e.dataEncipherment=(n&16)===16,e.keyAgreement=(n&8)===8,e.keyCertSign=(n&4)===4,e.cRLSign=(n&2)===2,e.encipherOnly=(n&1)===1,e.decipherOnly=(i&128)===128}else if(e.name==="basicConstraints"){var r=m.fromDer(e.value);r.value.length>0&&r.value[0].type===m.Type.BOOLEAN?e.cA=r.value[0].value.charCodeAt(0)!==0:e.cA=!1;var s=null;r.value.length>0&&r.value[0].type===m.Type.INTEGER?s=r.value[0].value:r.value.length>1&&(s=r.value[1].value),s!==null&&(e.pathLenConstraint=m.derToInteger(s))}else if(e.name==="extKeyUsage")for(var r=m.fromDer(e.value),o=0;o<r.value.length;++o){var a=m.derToOid(r.value[o].value);a in ue?e[ue[a]]=!0:e[a]=!0}else if(e.name==="nsCertType"){var r=m.fromDer(e.value),n=0;r.value.length>1&&(n=r.value.charCodeAt(1)),e.client=(n&128)===128,e.server=(n&64)===64,e.email=(n&32)===32,e.objsign=(n&16)===16,e.reserved=(n&8)===8,e.sslCA=(n&4)===4,e.emailCA=(n&2)===2,e.objCA=(n&1)===1}else if(e.name==="subjectAltName"||e.name==="issuerAltName"){e.altNames=[];for(var c,r=m.fromDer(e.value),u=0;u<r.value.length;++u){c=r.value[u];var l={type:c.type,value:c.value};switch(e.altNames.push(l),c.type){case 1:case 2:case 6:break;case 7:l.ip=$.util.bytesToIP(c.value);break;case 8:l.oid=m.derToOid(c.value);break;default:}}}else if(e.name==="subjectKeyIdentifier"){var r=m.fromDer(e.value);e.subjectKeyIdentifier=$.util.bytesToHex(r.value)}}return e};L.certificationRequestFromAsn1=function(t,e){var r={},n=[];if(!m.validate(t,aC,r,n)){var i=new Error("Cannot read PKCS#10 certificate request. ASN.1 object is not a PKCS#10 CertificationRequest.");throw i.errors=n,i}var s=m.derToOid(r.publicKeyOid);if(s!==L.oids.rsaEncryption)throw new Error("Cannot read public key. OID is not RSA.");var o=L.createCertificationRequest();if(o.version=r.csrVersion?r.csrVersion.charCodeAt(0):0,o.signatureOid=$.asn1.derToOid(r.csrSignatureOid),o.signatureParameters=gc(o.signatureOid,r.csrSignatureParams,!0),o.siginfo.algorithmOid=$.asn1.derToOid(r.csrSignatureOid),o.siginfo.parameters=gc(o.siginfo.algorithmOid,r.csrSignatureParams,!1),o.signature=r.csrSignature,o.certificationRequestInfo=r.certificationRequestInfo,e){o.md=Ec({signatureOid:o.signatureOid,type:"certification request"});var a=m.toDer(o.certificationRequestInfo);o.md.update(a.getBytes())}var c=$.md.sha1.create();return o.subject.getField=function(u){return Rn(o.subject,u)},o.subject.addField=function(u){Gt([u]),o.subject.attributes.push(u)},o.subject.attributes=L.RDNAttributesAsArray(r.certificationRequestInfoSubject,c),o.subject.hash=c.digest().toHex(),o.publicKey=L.publicKeyFromAsn1(r.subjectPublicKeyInfo),o.getAttribute=function(u){return Rn(o,u)},o.addAttribute=function(u){Gt([u]),o.attributes.push(u)},o.attributes=L.CRIAttributesAsArray(r.certificationRequestInfoAttributes||[]),o};L.createCertificationRequest=function(){var t={};return t.version=0,t.signatureOid=null,t.signature=null,t.siginfo={},t.siginfo.algorithmOid=null,t.subject={},t.subject.getField=function(e){return Rn(t.subject,e)},t.subject.addField=function(e){Gt([e]),t.subject.attributes.push(e)},t.subject.attributes=[],t.subject.hash=null,t.publicKey=null,t.attributes=[],t.getAttribute=function(e){return Rn(t,e)},t.addAttribute=function(e){Gt([e]),t.attributes.push(e)},t.md=null,t.setSubject=function(e){Gt(e),t.subject.attributes=e,t.subject.hash=null},t.setAttributes=function(e){Gt(e),t.attributes=e},t.sign=function(e,r){t.md=r||$.md.sha1.create();var n=ue[t.md.algorithm+"WithRSAEncryption"];if(!n){var i=new Error("Could not compute certification request digest. Unknown message digest algorithm OID.");throw i.algorithm=t.md.algorithm,i}t.signatureOid=t.siginfo.algorithmOid=n,t.certificationRequestInfo=L.getCertificationRequestInfo(t);var s=m.toDer(t.certificationRequestInfo);t.md.update(s.getBytes()),t.signature=e.sign(t.md)},t.verify=function(){var e=!1,r=t.md;if(r===null){r=Ec({signatureOid:t.signatureOid,type:"certification request"});var n=t.certificationRequestInfo||L.getCertificationRequestInfo(t),i=m.toDer(n);r.update(i.getBytes())}return r!==null&&(e=Xg({certificate:t,md:r,signature:t.signature})),e},t};function cs(t){for(var e=m.create(m.Class.UNIVERSAL,m.Type.SEQUENCE,!0,[]),r,n,i=t.attributes,s=0;s<i.length;++s){r=i[s];var o=r.value,a=m.Type.PRINTABLESTRING;"valueTagClass"in r&&(a=r.valueTagClass,a===m.Type.UTF8&&(o=$.util.encodeUtf8(o))),n=m.create(m.Class.UNIVERSAL,m.Type.SET,!0,[m.create(m.Class.UNIVERSAL,m.Type.SEQUENCE,!0,[m.create(m.Class.UNIVERSAL,m.Type.OID,!1,m.oidToDer(r.type).getBytes()),m.create(m.Class.UNIVERSAL,a,!1,o)])]),e.value.push(n)}return e}function Gt(t){for(var e,r=0;r<t.length;++r){if(e=t[r],typeof e.name>"u"&&(e.type&&e.type in L.oids?e.name=L.oids[e.type]:e.shortName&&e.shortName in Ye&&(e.name=L.oids[Ye[e.shortName]])),typeof e.type>"u")if(e.name&&e.name in L.oids)e.type=L.oids[e.name];else{var n=new Error("Attribute type not specified.");throw n.attribute=e,n}if(typeof e.shortName>"u"&&e.name&&e.name in Ye&&(e.shortName=Ye[e.name]),e.type===ue.extensionRequest&&(e.valueConstructed=!0,e.valueTagClass=m.Type.SEQUENCE,!e.value&&e.extensions)){e.value=[];for(var i=0;i<e.extensions.length;++i)e.value.push(L.certificateExtensionToAsn1(jg(e.extensions[i])))}if(typeof e.value>"u"){var n=new Error("Attribute value not specified.");throw n.attribute=e,n}}}function jg(t,e){if(e=e||{},typeof t.name>"u"&&t.id&&t.id in L.oids&&(t.name=L.oids[t.id]),typeof t.id>"u")if(t.name&&t.name in L.oids)t.id=L.oids[t.name];else{var r=new Error("Extension ID not specified.");throw r.extension=t,r}if(typeof t.value<"u")return t;if(t.name==="keyUsage"){var n=0,i=0,s=0;t.digitalSignature&&(i|=128,n=7),t.nonRepudiation&&(i|=64,n=6),t.keyEncipherment&&(i|=32,n=5),t.dataEncipherment&&(i|=16,n=4),t.keyAgreement&&(i|=8,n=3),t.keyCertSign&&(i|=4,n=2),t.cRLSign&&(i|=2,n=1),t.encipherOnly&&(i|=1,n=0),t.decipherOnly&&(s|=128,n=7);var o=String.fromCharCode(n);s!==0?o+=String.fromCharCode(i)+String.fromCharCode(s):i!==0&&(o+=String.fromCharCode(i)),t.value=m.create(m.Class.UNIVERSAL,m.Type.BITSTRING,!1,o)}else if(t.name==="basicConstraints")t.value=m.create(m.Class.UNIVERSAL,m.Type.SEQUENCE,!0,[]),t.cA&&t.value.value.push(m.create(m.Class.UNIVERSAL,m.Type.BOOLEAN,!1,String.fromCharCode(255))),"pathLenConstraint"in t&&t.value.value.push(m.create(m.Class.UNIVERSAL,m.Type.INTEGER,!1,m.integerToDer(t.pathLenConstraint).getBytes()));else if(t.name==="extKeyUsage"){t.value=m.create(m.Class.UNIVERSAL,m.Type.SEQUENCE,!0,[]);var a=t.value.value;for(var c in t)t[c]===!0&&(c in ue?a.push(m.create(m.Class.UNIVERSAL,m.Type.OID,!1,m.oidToDer(ue[c]).getBytes())):c.indexOf(".")!==-1&&a.push(m.create(m.Class.UNIVERSAL,m.Type.OID,!1,m.oidToDer(c).getBytes())))}else if(t.name==="nsCertType"){var n=0,i=0;t.client&&(i|=128,n=7),t.server&&(i|=64,n=6),t.email&&(i|=32,n=5),t.objsign&&(i|=16,n=4),t.reserved&&(i|=8,n=3),t.sslCA&&(i|=4,n=2),t.emailCA&&(i|=2,n=1),t.objCA&&(i|=1,n=0);var o=String.fromCharCode(n);i!==0&&(o+=String.fromCharCode(i)),t.value=m.create(m.Class.UNIVERSAL,m.Type.BITSTRING,!1,o)}else if(t.name==="subjectAltName"||t.name==="issuerAltName"){t.value=m.create(m.Class.UNIVERSAL,m.Type.SEQUENCE,!0,[]);for(var u,l=0;l<t.altNames.length;++l){u=t.altNames[l];var o=u.value;if(u.type===7&&u.ip){if(o=$.util.bytesFromIP(u.ip),o===null){var r=new Error('Extension "ip" value is not a valid IPv4 or IPv6 address.');throw r.extension=t,r}}else u.type===8&&(u.oid?o=m.oidToDer(m.oidToDer(u.oid)):o=m.oidToDer(o));t.value.value.push(m.create(m.Class.CONTEXT_SPECIFIC,u.type,!1,o))}}else if(t.name==="nsComment"&&e.cert){if(!/^[\x00-\x7F]*$/.test(t.comment)||t.comment.length<1||t.comment.length>128)throw new Error('Invalid "nsComment" content.');t.value=m.create(m.Class.UNIVERSAL,m.Type.IA5STRING,!1,t.comment)}else if(t.name==="subjectKeyIdentifier"&&e.cert){var f=e.cert.generateSubjectKeyIdentifier();t.subjectKeyIdentifier=f.toHex(),t.value=m.create(m.Class.UNIVERSAL,m.Type.OCTETSTRING,!1,f.getBytes())}else if(t.name==="authorityKeyIdentifier"&&e.cert){t.value=m.create(m.Class.UNIVERSAL,m.Type.SEQUENCE,!0,[]);var a=t.value.value;if(t.keyIdentifier){var h=t.keyIdentifier===!0?e.cert.generateSubjectKeyIdentifier().getBytes():t.keyIdentifier;a.push(m.create(m.Class.CONTEXT_SPECIFIC,0,!1,h))}if(t.authorityCertIssuer){var d=[m.create(m.Class.CONTEXT_SPECIFIC,4,!0,[cs(t.authorityCertIssuer===!0?e.cert.issuer:t.authorityCertIssuer)])];a.push(m.create(m.Class.CONTEXT_SPECIFIC,1,!0,d))}if(t.serialNumber){var p=$.util.hexToBytes(t.serialNumber===!0?e.cert.serialNumber:t.serialNumber);a.push(m.create(m.Class.CONTEXT_SPECIFIC,2,!1,p))}}else if(t.name==="cRLDistributionPoints"){t.value=m.create(m.Class.UNIVERSAL,m.Type.SEQUENCE,!0,[]);for(var a=t.value.value,y=m.create(m.Class.UNIVERSAL,m.Type.SEQUENCE,!0,[]),g=m.create(m.Class.CONTEXT_SPECIFIC,0,!0,[]),u,l=0;l<t.altNames.length;++l){u=t.altNames[l];var o=u.value;if(u.type===7&&u.ip){if(o=$.util.bytesFromIP(u.ip),o===null){var r=new Error('Extension "ip" value is not a valid IPv4 or IPv6 address.');throw r.extension=t,r}}else u.type===8&&(u.oid?o=m.oidToDer(m.oidToDer(u.oid)):o=m.oidToDer(o));g.value.push(m.create(m.Class.CONTEXT_SPECIFIC,u.type,!1,o))}y.value.push(m.create(m.Class.CONTEXT_SPECIFIC,0,!0,[g])),a.push(y)}if(typeof t.value>"u"){var r=new Error("Extension value not specified.");throw r.extension=t,r}return t}function Bf(t,e){switch(t){case ue["RSASSA-PSS"]:var r=[];return e.hash.algorithmOid!==void 0&&r.push(m.create(m.Class.CONTEXT_SPECIFIC,0,!0,[m.create(m.Class.UNIVERSAL,m.Type.SEQUENCE,!0,[m.create(m.Class.UNIVERSAL,m.Type.OID,!1,m.oidToDer(e.hash.algorithmOid).getBytes()),m.create(m.Class.UNIVERSAL,m.Type.NULL,!1,"")])])),e.mgf.algorithmOid!==void 0&&r.push(m.create(m.Class.CONTEXT_SPECIFIC,1,!0,[m.create(m.Class.UNIVERSAL,m.Type.SEQUENCE,!0,[m.create(m.Class.UNIVERSAL,m.Type.OID,!1,m.oidToDer(e.mgf.algorithmOid).getBytes()),m.create(m.Class.UNIVERSAL,m.Type.SEQUENCE,!0,[m.create(m.Class.UNIVERSAL,m.Type.OID,!1,m.oidToDer(e.mgf.hash.algorithmOid).getBytes()),m.create(m.Class.UNIVERSAL,m.Type.NULL,!1,"")])])])),e.saltLength!==void 0&&r.push(m.create(m.Class.CONTEXT_SPECIFIC,2,!0,[m.create(m.Class.UNIVERSAL,m.Type.INTEGER,!1,m.integerToDer(e.saltLength).getBytes())])),m.create(m.Class.UNIVERSAL,m.Type.SEQUENCE,!0,r);default:return m.create(m.Class.UNIVERSAL,m.Type.NULL,!1,"")}}function cC(t){var e=m.create(m.Class.CONTEXT_SPECIFIC,0,!0,[]);if(t.attributes.length===0)return e;for(var r=t.attributes,n=0;n<r.length;++n){var i=r[n],s=i.value,o=m.Type.UTF8;"valueTagClass"in i&&(o=i.valueTagClass),o===m.Type.UTF8&&(s=$.util.encodeUtf8(s));var a=!1;"valueConstructed"in i&&(a=i.valueConstructed);var c=m.create(m.Class.UNIVERSAL,m.Type.SEQUENCE,!0,[m.create(m.Class.UNIVERSAL,m.Type.OID,!1,m.oidToDer(i.type).getBytes()),m.create(m.Class.UNIVERSAL,m.Type.SET,!0,[m.create(m.Class.UNIVERSAL,o,a,s)])]);e.value.push(c)}return e}var uC=new Date("1950-01-01T00:00:00Z"),lC=new Date("2050-01-01T00:00:00Z");function Wg(t){return t>=uC&&t<lC?m.create(m.Class.UNIVERSAL,m.Type.UTCTIME,!1,m.dateToUtcTime(t)):m.create(m.Class.UNIVERSAL,m.Type.GENERALIZEDTIME,!1,m.dateToGeneralizedTime(t))}L.getTBSCertificate=function(t){var e=Wg(t.validity.notBefore),r=Wg(t.validity.notAfter),n=m.create(m.Class.UNIVERSAL,m.Type.SEQUENCE,!0,[m.create(m.Class.CONTEXT_SPECIFIC,0,!0,[m.create(m.Class.UNIVERSAL,m.Type.INTEGER,!1,m.integerToDer(t.version).getBytes())]),m.create(m.Class.UNIVERSAL,m.Type.INTEGER,!1,$.util.hexToBytes(t.serialNumber)),m.create(m.Class.UNIVERSAL,m.Type.SEQUENCE,!0,[m.create(m.Class.UNIVERSAL,m.Type.OID,!1,m.oidToDer(t.siginfo.algorithmOid).getBytes()),Bf(t.siginfo.algorithmOid,t.siginfo.parameters)]),cs(t.issuer),m.create(m.Class.UNIVERSAL,m.Type.SEQUENCE,!0,[e,r]),cs(t.subject),L.publicKeyToAsn1(t.publicKey)]);return t.issuer.uniqueId&&n.value.push(m.create(m.Class.CONTEXT_SPECIFIC,1,!0,[m.create(m.Class.UNIVERSAL,m.Type.BITSTRING,!1,String.fromCharCode(0)+t.issuer.uniqueId)])),t.subject.uniqueId&&n.value.push(m.create(m.Class.CONTEXT_SPECIFIC,2,!0,[m.create(m.Class.UNIVERSAL,m.Type.BITSTRING,!1,String.fromCharCode(0)+t.subject.uniqueId)])),t.extensions.length>0&&n.value.push(L.certificateExtensionsToAsn1(t.extensions)),n};L.getCertificationRequestInfo=function(t){var e=m.create(m.Class.UNIVERSAL,m.Type.SEQUENCE,!0,[m.create(m.Class.UNIVERSAL,m.Type.INTEGER,!1,m.integerToDer(t.version).getBytes()),cs(t.subject),L.publicKeyToAsn1(t.publicKey),cC(t)]);return e};L.distinguishedNameToAsn1=function(t){return cs(t)};L.certificateToAsn1=function(t){var e=t.tbsCertificate||L.getTBSCertificate(t);return m.create(m.Class.UNIVERSAL,m.Type.SEQUENCE,!0,[e,m.create(m.Class.UNIVERSAL,m.Type.SEQUENCE,!0,[m.create(m.Class.UNIVERSAL,m.Type.OID,!1,m.oidToDer(t.signatureOid).getBytes()),Bf(t.signatureOid,t.signatureParameters)]),m.create(m.Class.UNIVERSAL,m.Type.BITSTRING,!1,String.fromCharCode(0)+t.signature)])};L.certificateExtensionsToAsn1=function(t){var e=m.create(m.Class.CONTEXT_SPECIFIC,3,!0,[]),r=m.create(m.Class.UNIVERSAL,m.Type.SEQUENCE,!0,[]);e.value.push(r);for(var n=0;n<t.length;++n)r.value.push(L.certificateExtensionToAsn1(t[n]));return e};L.certificateExtensionToAsn1=function(t){var e=m.create(m.Class.UNIVERSAL,m.Type.SEQUENCE,!0,[]);e.value.push(m.create(m.Class.UNIVERSAL,m.Type.OID,!1,m.oidToDer(t.id).getBytes())),t.critical&&e.value.push(m.create(m.Class.UNIVERSAL,m.Type.BOOLEAN,!1,String.fromCharCode(255)));var r=t.value;return typeof t.value!="string"&&(r=m.toDer(r).getBytes()),e.value.push(m.create(m.Class.UNIVERSAL,m.Type.OCTETSTRING,!1,r)),e};L.certificationRequestToAsn1=function(t){var e=t.certificationRequestInfo||L.getCertificationRequestInfo(t);return m.create(m.Class.UNIVERSAL,m.Type.SEQUENCE,!0,[e,m.create(m.Class.UNIVERSAL,m.Type.SEQUENCE,!0,[m.create(m.Class.UNIVERSAL,m.Type.OID,!1,m.oidToDer(t.signatureOid).getBytes()),Bf(t.signatureOid,t.signatureParameters)]),m.create(m.Class.UNIVERSAL,m.Type.BITSTRING,!1,String.fromCharCode(0)+t.signature)])};L.createCaStore=function(t){var e={certs:{}};e.getIssuer=function(o){var a=r(o.issuer);return a},e.addCertificate=function(o){if(typeof o=="string"&&(o=$.pki.certificateFromPem(o)),n(o.subject),!e.hasCertificate(o))if(o.subject.hash in e.certs){var a=e.certs[o.subject.hash];$.util.isArray(a)||(a=[a]),a.push(o),e.certs[o.subject.hash]=a}else e.certs[o.subject.hash]=o},e.hasCertificate=function(o){typeof o=="string"&&(o=$.pki.certificateFromPem(o));var a=r(o.subject);if(!a)return!1;$.util.isArray(a)||(a=[a]);for(var c=m.toDer(L.certificateToAsn1(o)).getBytes(),u=0;u<a.length;++u){var l=m.toDer(L.certificateToAsn1(a[u])).getBytes();if(c===l)return!0}return!1},e.listAllCertificates=function(){var o=[];for(var a in e.certs)if(e.certs.hasOwnProperty(a)){var c=e.certs[a];if(!$.util.isArray(c))o.push(c);else for(var u=0;u<c.length;++u)o.push(c[u])}return o},e.removeCertificate=function(o){var a;if(typeof o=="string"&&(o=$.pki.certificateFromPem(o)),n(o.subject),!e.hasCertificate(o))return null;var c=r(o.subject);if(!$.util.isArray(c))return a=e.certs[o.subject.hash],delete e.certs[o.subject.hash],a;for(var u=m.toDer(L.certificateToAsn1(o)).getBytes(),l=0;l<c.length;++l){var f=m.toDer(L.certificateToAsn1(c[l])).getBytes();u===f&&(a=c[l],c.splice(l,1))}return c.length===0&&delete e.certs[o.subject.hash],a};function r(o){return n(o),e.certs[o.hash]||null}function n(o){if(!o.hash){var a=$.md.sha1.create();o.attributes=L.RDNAttributesAsArray(cs(o),a),o.hash=a.digest().toHex()}}if(t)for(var i=0;i<t.length;++i){var s=t[i];e.addCertificate(s)}return e};L.certificateError={bad_certificate:"forge.pki.BadCertificate",unsupported_certificate:"forge.pki.UnsupportedCertificate",certificate_revoked:"forge.pki.CertificateRevoked",certificate_expired:"forge.pki.CertificateExpired",certificate_unknown:"forge.pki.CertificateUnknown",unknown_ca:"forge.pki.UnknownCertificateAuthority"};L.verifyCertificateChain=function(t,e,r){typeof r=="function"&&(r={verify:r}),r=r||{},e=e.slice(0);var n=e.slice(0),i=r.validityCheckDate;typeof i>"u"&&(i=new Date);var s=!0,o=null,a=0;do{var c=e.shift(),u=null,l=!1;if(i&&(i<c.validity.notBefore||i>c.validity.notAfter)&&(o={message:"Certificate is not valid yet or has expired.",error:L.certificateError.certificate_expired,notBefore:c.validity.notBefore,notAfter:c.validity.notAfter,now:i}),o===null){if(u=e[0]||t.getIssuer(c),u===null&&c.isIssuer(c)&&(l=!0,u=c),u){var f=u;$.util.isArray(f)||(f=[f]);for(var h=!1;!h&&f.length>0;){u=f.shift();try{h=u.verify(c)}catch{}}h||(o={message:"Certificate signature is invalid.",error:L.certificateError.bad_certificate})}o===null&&(!u||l)&&!t.hasCertificate(c)&&(o={message:"Certificate is not trusted.",error:L.certificateError.unknown_ca})}if(o===null&&u&&!c.isIssuer(u)&&(o={message:"Certificate issuer is invalid.",error:L.certificateError.bad_certificate}),o===null)for(var d={keyUsage:!0,basicConstraints:!0},p=0;o===null&&p<c.extensions.length;++p){var y=c.extensions[p];y.critical&&!(y.name in d)&&(o={message:"Certificate has an unsupported critical extension.",error:L.certificateError.unsupported_certificate})}if(o===null&&(!s||e.length===0&&(!u||l))){var g=c.getExtension("basicConstraints"),E=c.getExtension("keyUsage");if(E!==null&&(!E.keyCertSign||g===null)&&(o={message:"Certificate keyUsage or basicConstraints conflict or indicate that the certificate is not a CA. If the certificate is the only one in the chain or isn't the first then the certificate must be a valid CA.",error:L.certificateError.bad_certificate}),o===null&&g!==null&&!g.cA&&(o={message:"Certificate basicConstraints indicates the certificate is not a CA.",error:L.certificateError.bad_certificate}),o===null&&E!==null&&"pathLenConstraint"in g){var x=a-1;x>g.pathLenConstraint&&(o={message:"Certificate basicConstraints pathLenConstraint violated.",error:L.certificateError.bad_certificate})}}var _=o===null?!0:o.error,B=r.verify?r.verify(_,a,n):_;if(B===!0)o=null;else throw _===!0&&(o={message:"The application rejected the certificate.",error:L.certificateError.bad_certificate}),(B||B===0)&&(typeof B=="object"&&!$.util.isArray(B)?(B.message&&(o.message=B.message),B.error&&(o.error=B.error)):typeof B=="string"&&(o.error=B)),o;s=!1,++a}while(e.length>0);return!0}});var tE=R((j4,eE)=>{var O=ie();rs();An();sc();ns();cc();cg();ai();De();Of();var v=O.asn1,vt=eE.exports=O.pkcs7=O.pkcs7||{};vt.messageFromPem=function(t){var e=O.pem.decode(t)[0];if(e.type!=="PKCS7"){var r=new Error('Could not convert PKCS#7 message from PEM; PEM header type is not "PKCS#7".');throw r.headerType=e.type,r}if(e.procType&&e.procType.type==="ENCRYPTED")throw new Error("Could not convert PKCS#7 message from PEM; PEM is encrypted.");var n=v.fromDer(e.body);return vt.messageFromAsn1(n)};vt.messageToPem=function(t,e){var r={type:"PKCS7",body:v.toDer(t.toAsn1()).getBytes()};return O.pem.encode(r,{maxline:e})};vt.messageFromAsn1=function(t){var e={},r=[];if(!v.validate(t,vt.asn1.contentInfoValidator,e,r)){var n=new Error("Cannot read PKCS#7 message. ASN.1 object is not an PKCS#7 ContentInfo.");throw n.errors=r,n}var i=v.derToOid(e.contentType),s;switch(i){case O.pki.oids.envelopedData:s=vt.createEnvelopedData();break;case O.pki.oids.encryptedData:s=vt.createEncryptedData();break;case O.pki.oids.signedData:s=vt.createSignedData();break;default:throw new Error("Cannot read PKCS#7 message. ContentType with OID "+i+" is not (yet) supported.")}return s.fromAsn1(e.content.value[0]),s};vt.createSignedData=function(){var t=null;return t={type:O.pki.oids.signedData,version:1,certificates:[],crls:[],signers:[],digestAlgorithmIdentifiers:[],contentInfo:null,signerInfos:[],fromAsn1:function(n){if(Uf(t,n,vt.asn1.signedDataValidator),t.certificates=[],t.crls=[],t.digestAlgorithmIdentifiers=[],t.contentInfo=null,t.signerInfos=[],t.rawCapture.certificates)for(var i=t.rawCapture.certificates.value,s=0;s<i.length;++s)t.certificates.push(O.pki.certificateFromAsn1(i[s]))},toAsn1:function(){t.contentInfo||t.sign();for(var n=[],i=0;i<t.certificates.length;++i)n.push(O.pki.certificateToAsn1(t.certificates[i]));var s=[],o=v.create(v.Class.CONTEXT_SPECIFIC,0,!0,[v.create(v.Class.UNIVERSAL,v.Type.SEQUENCE,!0,[v.create(v.Class.UNIVERSAL,v.Type.INTEGER,!1,v.integerToDer(t.version).getBytes()),v.create(v.Class.UNIVERSAL,v.Type.SET,!0,t.digestAlgorithmIdentifiers),t.contentInfo])]);return n.length>0&&o.value[0].value.push(v.create(v.Class.CONTEXT_SPECIFIC,0,!0,n)),s.length>0&&o.value[0].value.push(v.create(v.Class.CONTEXT_SPECIFIC,1,!0,s)),o.value[0].value.push(v.create(v.Class.UNIVERSAL,v.Type.SET,!0,t.signerInfos)),v.create(v.Class.UNIVERSAL,v.Type.SEQUENCE,!0,[v.create(v.Class.UNIVERSAL,v.Type.OID,!1,v.oidToDer(t.type).getBytes()),o])},addSigner:function(n){var i=n.issuer,s=n.serialNumber;if(n.certificate){var o=n.certificate;typeof o=="string"&&(o=O.pki.certificateFromPem(o)),i=o.issuer.attributes,s=o.serialNumber}var a=n.key;if(!a)throw new Error("Could not add PKCS#7 signer; no private key specified.");typeof a=="string"&&(a=O.pki.privateKeyFromPem(a));var c=n.digestAlgorithm||O.pki.oids.sha1;switch(c){case O.pki.oids.sha1:case O.pki.oids.sha256:case O.pki.oids.sha384:case O.pki.oids.sha512:case O.pki.oids.md5:break;default:throw new Error("Could not add PKCS#7 signer; unknown message digest algorithm: "+c)}var u=n.authenticatedAttributes||[];if(u.length>0){for(var l=!1,f=!1,h=0;h<u.length;++h){var d=u[h];if(!l&&d.type===O.pki.oids.contentType){if(l=!0,f)break;continue}if(!f&&d.type===O.pki.oids.messageDigest){if(f=!0,l)break;continue}}if(!l||!f)throw new Error("Invalid signer.authenticatedAttributes. If signer.authenticatedAttributes is specified, then it must contain at least two attributes, PKCS #9 content-type and PKCS #9 message-digest.")}t.signers.push({key:a,version:1,issuer:i,serialNumber:s,digestAlgorithm:c,signatureAlgorithm:O.pki.oids.rsaEncryption,signature:null,authenticatedAttributes:u,unauthenticatedAttributes:[]})},sign:function(n){if(n=n||{},(typeof t.content!="object"||t.contentInfo===null)&&(t.contentInfo=v.create(v.Class.UNIVERSAL,v.Type.SEQUENCE,!0,[v.create(v.Class.UNIVERSAL,v.Type.OID,!1,v.oidToDer(O.pki.oids.data).getBytes())]),"content"in t)){var i;t.content instanceof O.util.ByteBuffer?i=t.content.bytes():typeof t.content=="string"&&(i=O.util.encodeUtf8(t.content)),n.detached?t.detachedContent=v.create(v.Class.UNIVERSAL,v.Type.OCTETSTRING,!1,i):t.contentInfo.value.push(v.create(v.Class.CONTEXT_SPECIFIC,0,!0,[v.create(v.Class.UNIVERSAL,v.Type.OCTETSTRING,!1,i)]))}if(t.signers.length!==0){var s=e();r(s)}},verify:function(){throw new Error("PKCS#7 signature verification not yet implemented.")},addCertificate:function(n){typeof n=="string"&&(n=O.pki.certificateFromPem(n)),t.certificates.push(n)},addCertificateRevokationList:function(n){throw new Error("PKCS#7 CRL support not yet implemented.")}},t;function e(){for(var n={},i=0;i<t.signers.length;++i){var s=t.signers[i],o=s.digestAlgorithm;o in n||(n[o]=O.md[O.pki.oids[o]].create()),s.authenticatedAttributes.length===0?s.md=n[o]:s.md=O.md[O.pki.oids[o]].create()}t.digestAlgorithmIdentifiers=[];for(var o in n)t.digestAlgorithmIdentifiers.push(v.create(v.Class.UNIVERSAL,v.Type.SEQUENCE,!0,[v.create(v.Class.UNIVERSAL,v.Type.OID,!1,v.oidToDer(o).getBytes()),v.create(v.Class.UNIVERSAL,v.Type.NULL,!1,"")]));return n}function r(n){var i;if(t.detachedContent?i=t.detachedContent:(i=t.contentInfo.value[1],i=i.value[0]),!i)throw new Error("Could not sign PKCS#7 message; there is no content to sign.");var s=v.derToOid(t.contentInfo.value[0].value),o=v.toDer(i);o.getByte(),v.getBerValueLength(o),o=o.getBytes();for(var a in n)n[a].start().update(o);for(var c=new Date,u=0;u<t.signers.length;++u){var l=t.signers[u];if(l.authenticatedAttributes.length===0){if(s!==O.pki.oids.data)throw new Error("Invalid signer; authenticatedAttributes must be present when the ContentInfo content type is not PKCS#7 Data.")}else{l.authenticatedAttributesAsn1=v.create(v.Class.CONTEXT_SPECIFIC,0,!0,[]);for(var f=v.create(v.Class.UNIVERSAL,v.Type.SET,!0,[]),h=0;h<l.authenticatedAttributes.length;++h){var d=l.authenticatedAttributes[h];d.type===O.pki.oids.messageDigest?d.value=n[l.digestAlgorithm].digest():d.type===O.pki.oids.signingTime&&(d.value||(d.value=c)),f.value.push(kf(d)),l.authenticatedAttributesAsn1.value.push(kf(d))}o=v.toDer(f).getBytes(),l.md.start().update(o)}l.signature=l.key.sign(l.md,"RSASSA-PKCS1-V1_5")}t.signerInfos=yC(t.signers)}};vt.createEncryptedData=function(){var t=null;return t={type:O.pki.oids.encryptedData,version:0,encryptedContent:{algorithm:O.pki.oids["aes256-CBC"]},fromAsn1:function(e){Uf(t,e,vt.asn1.encryptedDataValidator)},decrypt:function(e){e!==void 0&&(t.encryptedContent.key=e),Jg(t)}},t};vt.createEnvelopedData=function(){var t=null;return t={type:O.pki.oids.envelopedData,version:0,recipients:[],encryptedContent:{algorithm:O.pki.oids["aes256-CBC"]},fromAsn1:function(e){var r=Uf(t,e,vt.asn1.envelopedDataValidator);t.recipients=dC(r.recipientInfos.value)},toAsn1:function(){return v.create(v.Class.UNIVERSAL,v.Type.SEQUENCE,!0,[v.create(v.Class.UNIVERSAL,v.Type.OID,!1,v.oidToDer(t.type).getBytes()),v.create(v.Class.CONTEXT_SPECIFIC,0,!0,[v.create(v.Class.UNIVERSAL,v.Type.SEQUENCE,!0,[v.create(v.Class.UNIVERSAL,v.Type.INTEGER,!1,v.integerToDer(t.version).getBytes()),v.create(v.Class.UNIVERSAL,v.Type.SET,!0,pC(t.recipients)),v.create(v.Class.UNIVERSAL,v.Type.SEQUENCE,!0,gC(t.encryptedContent))])])])},findRecipient:function(e){for(var r=e.issuer.attributes,n=0;n<t.recipients.length;++n){var i=t.recipients[n],s=i.issuer;if(i.serialNumber===e.serialNumber&&s.length===r.length){for(var o=!0,a=0;a<r.length;++a)if(s[a].type!==r[a].type||s[a].value!==r[a].value){o=!1;break}if(o)return i}}return null},decrypt:function(e,r){if(t.encryptedContent.key===void 0&&e!==void 0&&r!==void 0)switch(e.encryptedContent.algorithm){case O.pki.oids.rsaEncryption:case O.pki.oids.desCBC:var n=r.decrypt(e.encryptedContent.content);t.encryptedContent.key=O.util.createBuffer(n);break;default:throw new Error("Unsupported asymmetric cipher, OID "+e.encryptedContent.algorithm)}Jg(t)},addRecipient:function(e){t.recipients.push({version:0,issuer:e.issuer.attributes,serialNumber:e.serialNumber,encryptedContent:{algorithm:O.pki.oids.rsaEncryption,key:e.publicKey}})},encrypt:function(e,r){if(t.encryptedContent.content===void 0){r=r||t.encryptedContent.algorithm,e=e||t.encryptedContent.key;var n,i,s;switch(r){case O.pki.oids["aes128-CBC"]:n=16,i=16,s=O.aes.createEncryptionCipher;break;case O.pki.oids["aes192-CBC"]:n=24,i=16,s=O.aes.createEncryptionCipher;break;case O.pki.oids["aes256-CBC"]:n=32,i=16,s=O.aes.createEncryptionCipher;break;case O.pki.oids["des-EDE3-CBC"]:n=24,i=8,s=O.des.createEncryptionCipher;break;default:throw new Error("Unsupported symmetric cipher, OID "+r)}if(e===void 0)e=O.util.createBuffer(O.random.getBytes(n));else if(e.length()!=n)throw new Error("Symmetric key has wrong length; got "+e.length()+" bytes, expected "+n+".");t.encryptedContent.algorithm=r,t.encryptedContent.key=e,t.encryptedContent.parameter=O.util.createBuffer(O.random.getBytes(i));var o=s(e);if(o.start(t.encryptedContent.parameter.copy()),o.update(t.content),!o.finish())throw new Error("Symmetric encryption failed.");t.encryptedContent.content=o.output}for(var a=0;a<t.recipients.length;++a){var c=t.recipients[a];if(c.encryptedContent.content===void 0)switch(c.encryptedContent.algorithm){case O.pki.oids.rsaEncryption:c.encryptedContent.content=c.encryptedContent.key.encrypt(t.encryptedContent.key.data);break;default:throw new Error("Unsupported asymmetric cipher, OID "+c.encryptedContent.algorithm)}}}},t};function fC(t){var e={},r=[];if(!v.validate(t,vt.asn1.recipientInfoValidator,e,r)){var n=new Error("Cannot read PKCS#7 RecipientInfo. ASN.1 object is not an PKCS#7 RecipientInfo.");throw n.errors=r,n}return{version:e.version.charCodeAt(0),issuer:O.pki.RDNAttributesAsArray(e.issuer),serialNumber:O.util.createBuffer(e.serial).toHex(),encryptedContent:{algorithm:v.derToOid(e.encAlgorithm),parameter:e.encParameter?e.encParameter.value:void 0,content:e.encKey}}}function hC(t){return v.create(v.Class.UNIVERSAL,v.Type.SEQUENCE,!0,[v.create(v.Class.UNIVERSAL,v.Type.INTEGER,!1,v.integerToDer(t.version).getBytes()),v.create(v.Class.UNIVERSAL,v.Type.SEQUENCE,!0,[O.pki.distinguishedNameToAsn1({attributes:t.issuer}),v.create(v.Class.UNIVERSAL,v.Type.INTEGER,!1,O.util.hexToBytes(t.serialNumber))]),v.create(v.Class.UNIVERSAL,v.Type.SEQUENCE,!0,[v.create(v.Class.UNIVERSAL,v.Type.OID,!1,v.oidToDer(t.encryptedContent.algorithm).getBytes()),v.create(v.Class.UNIVERSAL,v.Type.NULL,!1,"")]),v.create(v.Class.UNIVERSAL,v.Type.OCTETSTRING,!1,t.encryptedContent.content)])}function dC(t){for(var e=[],r=0;r<t.length;++r)e.push(fC(t[r]));return e}function pC(t){for(var e=[],r=0;r<t.length;++r)e.push(hC(t[r]));return e}function mC(t){var e=v.create(v.Class.UNIVERSAL,v.Type.SEQUENCE,!0,[v.create(v.Class.UNIVERSAL,v.Type.INTEGER,!1,v.integerToDer(t.version).getBytes()),v.create(v.Class.UNIVERSAL,v.Type.SEQUENCE,!0,[O.pki.distinguishedNameToAsn1({attributes:t.issuer}),v.create(v.Class.UNIVERSAL,v.Type.INTEGER,!1,O.util.hexToBytes(t.serialNumber))]),v.create(v.Class.UNIVERSAL,v.Type.SEQUENCE,!0,[v.create(v.Class.UNIVERSAL,v.Type.OID,!1,v.oidToDer(t.digestAlgorithm).getBytes()),v.create(v.Class.UNIVERSAL,v.Type.NULL,!1,"")])]);if(t.authenticatedAttributesAsn1&&e.value.push(t.authenticatedAttributesAsn1),e.value.push(v.create(v.Class.UNIVERSAL,v.Type.SEQUENCE,!0,[v.create(v.Class.UNIVERSAL,v.Type.OID,!1,v.oidToDer(t.signatureAlgorithm).getBytes()),v.create(v.Class.UNIVERSAL,v.Type.NULL,!1,"")])),e.value.push(v.create(v.Class.UNIVERSAL,v.Type.OCTETSTRING,!1,t.signature)),t.unauthenticatedAttributes.length>0){for(var r=v.create(v.Class.CONTEXT_SPECIFIC,1,!0,[]),n=0;n<t.unauthenticatedAttributes.length;++n){var i=t.unauthenticatedAttributes[n];r.values.push(kf(i))}e.value.push(r)}return e}function yC(t){for(var e=[],r=0;r<t.length;++r)e.push(mC(t[r]));return e}function kf(t){var e;if(t.type===O.pki.oids.contentType)e=v.create(v.Class.UNIVERSAL,v.Type.OID,!1,v.oidToDer(t.value).getBytes());else if(t.type===O.pki.oids.messageDigest)e=v.create(v.Class.UNIVERSAL,v.Type.OCTETSTRING,!1,t.value.bytes());else if(t.type===O.pki.oids.signingTime){var r=new Date("1950-01-01T00:00:00Z"),n=new Date("2050-01-01T00:00:00Z"),i=t.value;if(typeof i=="string"){var s=Date.parse(i);isNaN(s)?i.length===13?i=v.utcTimeToDate(i):i=v.generalizedTimeToDate(i):i=new Date(s)}i>=r&&i<n?e=v.create(v.Class.UNIVERSAL,v.Type.UTCTIME,!1,v.dateToUtcTime(i)):e=v.create(v.Class.UNIVERSAL,v.Type.GENERALIZEDTIME,!1,v.dateToGeneralizedTime(i))}return v.create(v.Class.UNIVERSAL,v.Type.SEQUENCE,!0,[v.create(v.Class.UNIVERSAL,v.Type.OID,!1,v.oidToDer(t.type).getBytes()),v.create(v.Class.UNIVERSAL,v.Type.SET,!0,[e])])}function gC(t){return[v.create(v.Class.UNIVERSAL,v.Type.OID,!1,v.oidToDer(O.pki.oids.data).getBytes()),v.create(v.Class.UNIVERSAL,v.Type.SEQUENCE,!0,[v.create(v.Class.UNIVERSAL,v.Type.OID,!1,v.oidToDer(t.algorithm).getBytes()),t.parameter?v.create(v.Class.UNIVERSAL,v.Type.OCTETSTRING,!1,t.parameter.getBytes()):void 0]),v.create(v.Class.CONTEXT_SPECIFIC,0,!0,[v.create(v.Class.UNIVERSAL,v.Type.OCTETSTRING,!1,t.content.getBytes())])]}function Uf(t,e,r){var n={},i=[];if(!v.validate(e,r,n,i)){var s=new Error("Cannot read PKCS#7 message. ASN.1 object is not a supported PKCS#7 message.");throw s.errors=s,s}var o=v.derToOid(n.contentType);if(o!==O.pki.oids.data)throw new Error("Unsupported PKCS#7 message. Only wrapped ContentType Data supported.");if(n.encryptedContent){var a="";if(O.util.isArray(n.encryptedContent))for(var c=0;c<n.encryptedContent.length;++c){if(n.encryptedContent[c].type!==v.Type.OCTETSTRING)throw new Error("Malformed PKCS#7 message, expecting encrypted content constructed of only OCTET STRING objects.");a+=n.encryptedContent[c].value}else a=n.encryptedContent;t.encryptedContent={algorithm:v.derToOid(n.encAlgorithm),parameter:O.util.createBuffer(n.encParameter.value),content:O.util.createBuffer(a)}}if(n.content){var a="";if(O.util.isArray(n.content))for(var c=0;c<n.content.length;++c){if(n.content[c].type!==v.Type.OCTETSTRING)throw new Error("Malformed PKCS#7 message, expecting content constructed of only OCTET STRING objects.");a+=n.content[c].value}else a=n.content;t.content=O.util.createBuffer(a)}return t.version=n.version.charCodeAt(0),t.rawCapture=n,n}function Jg(t){if(t.encryptedContent.key===void 0)throw new Error("Symmetric key not available.");if(t.content===void 0){var e;switch(t.encryptedContent.algorithm){case O.pki.oids["aes128-CBC"]:case O.pki.oids["aes192-CBC"]:case O.pki.oids["aes256-CBC"]:e=O.aes.createDecryptionCipher(t.encryptedContent.key);break;case O.pki.oids.desCBC:case O.pki.oids["des-EDE3-CBC"]:e=O.des.createDecryptionCipher(t.encryptedContent.key);break;default:throw new Error("Unsupported symmetric cipher, OID "+t.encryptedContent.algorithm)}if(e.start(t.encryptedContent.parameter),e.update(t.encryptedContent.content),!e.finish())throw new Error("Symmetric decryption failed.");t.content=e.output}}});var nE=R((Z4,rE)=>{var Yr=ie();Cn();De();var EC=rE.exports=Yr.hmac=Yr.hmac||{};EC.create=function(){var t=null,e=null,r=null,n=null,i={};return i.start=function(s,o){if(s!==null)if(typeof s=="string")if(s=s.toLowerCase(),s in Yr.md.algorithms)e=Yr.md.algorithms[s].create();else throw new Error('Unknown hash algorithm "'+s+'"');else e=s;if(o===null)o=t;else{if(typeof o=="string")o=Yr.util.createBuffer(o);else if(Yr.util.isArray(o)){var a=o;o=Yr.util.createBuffer();for(var c=0;c<a.length;++c)o.putByte(a[c])}var u=o.length();u>e.blockLength&&(e.start(),e.update(o.bytes()),o=e.digest()),r=Yr.util.createBuffer(),n=Yr.util.createBuffer(),u=o.length();for(var c=0;c<u;++c){var a=o.at(c);r.putByte(54^a),n.putByte(92^a)}if(u<e.blockLength)for(var a=e.blockLength-u,c=0;c<a;++c)r.putByte(54),n.putByte(92);t=o,r=r.bytes(),n=n.bytes()}e.start(),e.update(r)},i.update=function(s){e.update(s)},i.getMac=function(){var s=e.digest().bytes();return e.start(),e.update(n),e.update(s),e.digest()},i.digest=i.getMac,i}});var Mf=R((J4,iE)=>{var wt=ie();nE();Cn();De();var vC=wt.pkcs5=wt.pkcs5||{},Wr;wt.util.isNodejs&&!wt.options.usePureJavaScript&&(Wr=Jn());iE.exports=wt.pbkdf2=vC.pbkdf2=function(t,e,r,n,i,s){if(typeof i=="function"&&(s=i,i=null),wt.util.isNodejs&&!wt.options.usePureJavaScript&&Wr.pbkdf2&&(i===null||typeof i!="object")&&(Wr.pbkdf2Sync.length>4||!i||i==="sha1"))return typeof i!="string"&&(i="sha1"),t=Buffer.from(t,"binary"),e=Buffer.from(e,"binary"),s?Wr.pbkdf2Sync.length===4?Wr.pbkdf2(t,e,r,n,function(_,B){if(_)return s(_);s(null,B.toString("binary"))}):Wr.pbkdf2(t,e,r,n,i,function(_,B){if(_)return s(_);s(null,B.toString("binary"))}):Wr.pbkdf2Sync.length===4?Wr.pbkdf2Sync(t,e,r,n).toString("binary"):Wr.pbkdf2Sync(t,e,r,n,i).toString("binary");if((typeof i>"u"||i===null)&&(i="sha1"),typeof i=="string"){if(!(i in wt.md.algorithms))throw new Error("Unknown hash algorithm: "+i);i=wt.md[i].create()}var o=i.digestLength;if(n>4294967295*o){var a=new Error("Derived key is too long.");if(s)return s(a);throw a}var c=Math.ceil(n/o),u=n-(c-1)*o,l=wt.hmac.create();l.start(i,t);var f="",h,d,p;if(!s){for(var y=1;y<=c;++y){l.start(null,null),l.update(e),l.update(wt.util.int32ToBytes(y)),h=p=l.digest().getBytes();for(var g=2;g<=r;++g)l.start(null,null),l.update(p),d=l.digest().getBytes(),h=wt.util.xorBytes(h,d,o),p=d;f+=y<c?h:h.substr(0,u)}return f}var y=1,g;function E(){if(y>c)return s(null,f);l.start(null,null),l.update(e),l.update(wt.util.int32ToBytes(y)),h=p=l.digest().getBytes(),g=2,x()}function x(){if(g<=r)return l.start(null,null),l.update(p),d=l.digest().getBytes(),h=wt.util.xorBytes(h,d,o),p=d,++g,wt.util.setImmediate(x);f+=y<c?h:h.substr(0,u),++y,E()}E()}});var cE=R((e8,aE)=>{var St=ie();De();var Ff=[217,120,249,196,25,221,181,237,40,233,253,121,74,160,216,157,198,126,55,131,43,118,83,142,98,76,100,136,68,139,251,162,23,154,89,245,135,179,79,19,97,69,109,141,9,129,125,50,189,143,64,235,134,183,123,11,240,149,33,34,92,107,78,130,84,214,101,147,206,96,178,28,115,86,192,20,167,140,241,220,18,117,202,31,59,190,228,209,66,61,212,48,163,60,182,38,111,191,14,218,70,105,7,87,39,242,29,155,188,148,67,3,248,17,199,246,144,239,62,231,6,195,213,47,200,102,30,215,8,232,234,222,128,82,238,247,132,170,114,172,53,77,106,42,150,26,210,113,90,21,73,116,75,159,208,94,4,24,164,236,194,224,65,110,15,81,203,204,36,145,175,80,161,244,112,57,153,124,58,133,35,184,180,122,252,2,54,91,37,85,151,49,45,93,250,152,227,138,146,174,5,223,41,16,103,108,186,201,211,0,230,207,225,158,168,44,99,22,1,63,88,226,137,169,13,56,52,27,171,51,255,176,187,72,12,95,185,177,205,46,197,243,219,71,229,165,156,119,10,166,32,104,254,127,193,173],sE=[1,2,3,5],wC=function(t,e){return t<<e&65535|(t&65535)>>16-e},xC=function(t,e){return(t&65535)>>e|t<<16-e&65535};aE.exports=St.rc2=St.rc2||{};St.rc2.expandKey=function(t,e){typeof t=="string"&&(t=St.util.createBuffer(t)),e=e||128;var r=t,n=t.length(),i=e,s=Math.ceil(i/8),o=255>>(i&7),a;for(a=n;a<128;a++)r.putByte(Ff[r.at(a-1)+r.at(a-n)&255]);for(r.setAt(128-s,Ff[r.at(128-s)&o]),a=127-s;a>=0;a--)r.setAt(a,Ff[r.at(a+1)^r.at(a+s)]);return r};var oE=function(t,e,r){var n=!1,i=null,s=null,o=null,a,c,u,l,f=[];for(t=St.rc2.expandKey(t,e),u=0;u<64;u++)f.push(t.getInt16Le());r?(a=function(p){for(u=0;u<4;u++)p[u]+=f[l]+(p[(u+3)%4]&p[(u+2)%4])+(~p[(u+3)%4]&p[(u+1)%4]),p[u]=wC(p[u],sE[u]),l++},c=function(p){for(u=0;u<4;u++)p[u]+=f[p[(u+3)%4]&63]}):(a=function(p){for(u=3;u>=0;u--)p[u]=xC(p[u],sE[u]),p[u]-=f[l]+(p[(u+3)%4]&p[(u+2)%4])+(~p[(u+3)%4]&p[(u+1)%4]),l--},c=function(p){for(u=3;u>=0;u--)p[u]-=f[p[(u+3)%4]&63]});var h=function(p){var y=[];for(u=0;u<4;u++){var g=i.getInt16Le();o!==null&&(r?g^=o.getInt16Le():o.putInt16Le(g)),y.push(g&65535)}l=r?0:63;for(var E=0;E<p.length;E++)for(var x=0;x<p[E][0];x++)p[E][1](y);for(u=0;u<4;u++)o!==null&&(r?o.putInt16Le(y[u]):y[u]^=o.getInt16Le()),s.putInt16Le(y[u])},d=null;return d={start:function(p,y){p&&typeof p=="string"&&(p=St.util.createBuffer(p)),n=!1,i=St.util.createBuffer(),s=y||new St.util.createBuffer,o=p,d.output=s},update:function(p){for(n||i.putBuffer(p);i.length()>=8;)h([[5,a],[1,c],[6,a],[1,c],[5,a]])},finish:function(p){var y=!0;if(r)if(p)y=p(8,i,!r);else{var g=i.length()===8?8:8-i.length();i.fillWithByte(g,g)}if(y&&(n=!0,d.update()),!r&&(y=i.length()===0,y))if(p)y=p(8,s,!r);else{var E=s.length(),x=s.at(E-1);x>E?y=!1:s.truncate(x)}return y}},d};St.rc2.startEncrypting=function(t,e,r){var n=St.rc2.createEncryptionCipher(t,128);return n.start(e,r),n};St.rc2.createEncryptionCipher=function(t,e){return oE(t,e,!0)};St.rc2.startDecrypting=function(t,e,r){var n=St.rc2.createDecryptionCipher(t,128);return n.start(e,r),n};St.rc2.createDecryptionCipher=function(t,e){return oE(t,e,!1)}});var Kf=R((t8,dE)=>{var F=ie();rs();An();sc();Cn();ns();Mf();cc();ai();cE();ao();De();typeof uE>"u"&&(uE=F.jsbn.BigInteger);var uE,A=F.asn1,J=F.pki=F.pki||{};dE.exports=J.pbe=F.pbe=F.pbe||{};var hi=J.oids,bC={name:"EncryptedPrivateKeyInfo",tagClass:A.Class.UNIVERSAL,type:A.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedPrivateKeyInfo.encryptionAlgorithm",tagClass:A.Class.UNIVERSAL,type:A.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:A.Class.UNIVERSAL,type:A.Type.OID,constructed:!1,capture:"encryptionOid"},{name:"AlgorithmIdentifier.parameters",tagClass:A.Class.UNIVERSAL,type:A.Type.SEQUENCE,constructed:!0,captureAsn1:"encryptionParams"}]},{name:"EncryptedPrivateKeyInfo.encryptedData",tagClass:A.Class.UNIVERSAL,type:A.Type.OCTETSTRING,constructed:!1,capture:"encryptedData"}]},SC={name:"PBES2Algorithms",tagClass:A.Class.UNIVERSAL,type:A.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.keyDerivationFunc",tagClass:A.Class.UNIVERSAL,type:A.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.keyDerivationFunc.oid",tagClass:A.Class.UNIVERSAL,type:A.Type.OID,constructed:!1,capture:"kdfOid"},{name:"PBES2Algorithms.params",tagClass:A.Class.UNIVERSAL,type:A.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.params.salt",tagClass:A.Class.UNIVERSAL,type:A.Type.OCTETSTRING,constructed:!1,capture:"kdfSalt"},{name:"PBES2Algorithms.params.iterationCount",tagClass:A.Class.UNIVERSAL,type:A.Type.INTEGER,constructed:!1,capture:"kdfIterationCount"},{name:"PBES2Algorithms.params.keyLength",tagClass:A.Class.UNIVERSAL,type:A.Type.INTEGER,constructed:!1,optional:!0,capture:"keyLength"},{name:"PBES2Algorithms.params.prf",tagClass:A.Class.UNIVERSAL,type:A.Type.SEQUENCE,constructed:!0,optional:!0,value:[{name:"PBES2Algorithms.params.prf.algorithm",tagClass:A.Class.UNIVERSAL,type:A.Type.OID,constructed:!1,capture:"prfOid"}]}]}]},{name:"PBES2Algorithms.encryptionScheme",tagClass:A.Class.UNIVERSAL,type:A.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.encryptionScheme.oid",tagClass:A.Class.UNIVERSAL,type:A.Type.OID,constructed:!1,capture:"encOid"},{name:"PBES2Algorithms.encryptionScheme.iv",tagClass:A.Class.UNIVERSAL,type:A.Type.OCTETSTRING,constructed:!1,capture:"encIv"}]}]},_C={name:"pkcs-12PbeParams",tagClass:A.Class.UNIVERSAL,type:A.Type.SEQUENCE,constructed:!0,value:[{name:"pkcs-12PbeParams.salt",tagClass:A.Class.UNIVERSAL,type:A.Type.OCTETSTRING,constructed:!1,capture:"salt"},{name:"pkcs-12PbeParams.iterations",tagClass:A.Class.UNIVERSAL,type:A.Type.INTEGER,constructed:!1,capture:"iterations"}]};J.encryptPrivateKeyInfo=function(t,e,r){r=r||{},r.saltSize=r.saltSize||8,r.count=r.count||2048,r.algorithm=r.algorithm||"aes128",r.prfAlgorithm=r.prfAlgorithm||"sha1";var n=F.random.getBytesSync(r.saltSize),i=r.count,s=A.integerToDer(i),o,a,c;if(r.algorithm.indexOf("aes")===0||r.algorithm==="des"){var u,l,f;switch(r.algorithm){case"aes128":o=16,u=16,l=hi["aes128-CBC"],f=F.aes.createEncryptionCipher;break;case"aes192":o=24,u=16,l=hi["aes192-CBC"],f=F.aes.createEncryptionCipher;break;case"aes256":o=32,u=16,l=hi["aes256-CBC"],f=F.aes.createEncryptionCipher;break;case"des":o=8,u=8,l=hi.desCBC,f=F.des.createEncryptionCipher;break;default:var h=new Error("Cannot encrypt private key. Unknown encryption algorithm.");throw h.algorithm=r.algorithm,h}var d="hmacWith"+r.prfAlgorithm.toUpperCase(),p=hE(d),y=F.pkcs5.pbkdf2(e,n,i,o,p),g=F.random.getBytesSync(u),E=f(y);E.start(g),E.update(A.toDer(t)),E.finish(),c=E.output.getBytes();var x=AC(n,s,o,d);a=A.create(A.Class.UNIVERSAL,A.Type.SEQUENCE,!0,[A.create(A.Class.UNIVERSAL,A.Type.OID,!1,A.oidToDer(hi.pkcs5PBES2).getBytes()),A.create(A.Class.UNIVERSAL,A.Type.SEQUENCE,!0,[A.create(A.Class.UNIVERSAL,A.Type.SEQUENCE,!0,[A.create(A.Class.UNIVERSAL,A.Type.OID,!1,A.oidToDer(hi.pkcs5PBKDF2).getBytes()),x]),A.create(A.Class.UNIVERSAL,A.Type.SEQUENCE,!0,[A.create(A.Class.UNIVERSAL,A.Type.OID,!1,A.oidToDer(l).getBytes()),A.create(A.Class.UNIVERSAL,A.Type.OCTETSTRING,!1,g)])])])}else if(r.algorithm==="3des"){o=24;var _=new F.util.ByteBuffer(n),y=J.pbe.generatePkcs12Key(e,_,1,i,o),g=J.pbe.generatePkcs12Key(e,_,2,i,o),E=F.des.createEncryptionCipher(y);E.start(g),E.update(A.toDer(t)),E.finish(),c=E.output.getBytes(),a=A.create(A.Class.UNIVERSAL,A.Type.SEQUENCE,!0,[A.create(A.Class.UNIVERSAL,A.Type.OID,!1,A.oidToDer(hi["pbeWithSHAAnd3-KeyTripleDES-CBC"]).getBytes()),A.create(A.Class.UNIVERSAL,A.Type.SEQUENCE,!0,[A.create(A.Class.UNIVERSAL,A.Type.OCTETSTRING,!1,n),A.create(A.Class.UNIVERSAL,A.Type.INTEGER,!1,s.getBytes())])])}else{var h=new Error("Cannot encrypt private key. Unknown encryption algorithm.");throw h.algorithm=r.algorithm,h}var B=A.create(A.Class.UNIVERSAL,A.Type.SEQUENCE,!0,[a,A.create(A.Class.UNIVERSAL,A.Type.OCTETSTRING,!1,c)]);return B};J.decryptPrivateKeyInfo=function(t,e){var r=null,n={},i=[];if(!A.validate(t,bC,n,i)){var s=new Error("Cannot read encrypted private key. ASN.1 object is not a supported EncryptedPrivateKeyInfo.");throw s.errors=i,s}var o=A.derToOid(n.encryptionOid),a=J.pbe.getCipher(o,n.encryptionParams,e),c=F.util.createBuffer(n.encryptedData);return a.update(c),a.finish()&&(r=A.fromDer(a.output)),r};J.encryptedPrivateKeyToPem=function(t,e){var r={type:"ENCRYPTED PRIVATE KEY",body:A.toDer(t).getBytes()};return F.pem.encode(r,{maxline:e})};J.encryptedPrivateKeyFromPem=function(t){var e=F.pem.decode(t)[0];if(e.type!=="ENCRYPTED PRIVATE KEY"){var r=new Error('Could not convert encrypted private key from PEM; PEM header type is "ENCRYPTED PRIVATE KEY".');throw r.headerType=e.type,r}if(e.procType&&e.procType.type==="ENCRYPTED")throw new Error("Could not convert encrypted private key from PEM; PEM is encrypted.");return A.fromDer(e.body)};J.encryptRsaPrivateKey=function(t,e,r){if(r=r||{},!r.legacy){var n=J.wrapRsaPrivateKey(J.privateKeyToAsn1(t));return n=J.encryptPrivateKeyInfo(n,e,r),J.encryptedPrivateKeyToPem(n)}var i,s,o,a;switch(r.algorithm){case"aes128":i="AES-128-CBC",o=16,s=F.random.getBytesSync(16),a=F.aes.createEncryptionCipher;break;case"aes192":i="AES-192-CBC",o=24,s=F.random.getBytesSync(16),a=F.aes.createEncryptionCipher;break;case"aes256":i="AES-256-CBC",o=32,s=F.random.getBytesSync(16),a=F.aes.createEncryptionCipher;break;case"3des":i="DES-EDE3-CBC",o=24,s=F.random.getBytesSync(8),a=F.des.createEncryptionCipher;break;case"des":i="DES-CBC",o=8,s=F.random.getBytesSync(8),a=F.des.createEncryptionCipher;break;default:var c=new Error('Could not encrypt RSA private key; unsupported encryption algorithm "'+r.algorithm+'".');throw c.algorithm=r.algorithm,c}var u=F.pbe.opensslDeriveBytes(e,s.substr(0,8),o),l=a(u);l.start(s),l.update(A.toDer(J.privateKeyToAsn1(t))),l.finish();var f={type:"RSA PRIVATE KEY",procType:{version:"4",type:"ENCRYPTED"},dekInfo:{algorithm:i,parameters:F.util.bytesToHex(s).toUpperCase()},body:l.output.getBytes()};return F.pem.encode(f)};J.decryptRsaPrivateKey=function(t,e){var r=null,n=F.pem.decode(t)[0];if(n.type!=="ENCRYPTED PRIVATE KEY"&&n.type!=="PRIVATE KEY"&&n.type!=="RSA PRIVATE KEY"){var i=new Error('Could not convert private key from PEM; PEM header type is not "ENCRYPTED PRIVATE KEY", "PRIVATE KEY", or "RSA PRIVATE KEY".');throw i.headerType=i,i}if(n.procType&&n.procType.type==="ENCRYPTED"){var s,o;switch(n.dekInfo.algorithm){case"DES-CBC":s=8,o=F.des.createDecryptionCipher;break;case"DES-EDE3-CBC":s=24,o=F.des.createDecryptionCipher;break;case"AES-128-CBC":s=16,o=F.aes.createDecryptionCipher;break;case"AES-192-CBC":s=24,o=F.aes.createDecryptionCipher;break;case"AES-256-CBC":s=32,o=F.aes.createDecryptionCipher;break;case"RC2-40-CBC":s=5,o=function(f){return F.rc2.createDecryptionCipher(f,40)};break;case"RC2-64-CBC":s=8,o=function(f){return F.rc2.createDecryptionCipher(f,64)};break;case"RC2-128-CBC":s=16,o=function(f){return F.rc2.createDecryptionCipher(f,128)};break;default:var i=new Error('Could not decrypt private key; unsupported encryption algorithm "'+n.dekInfo.algorithm+'".');throw i.algorithm=n.dekInfo.algorithm,i}var a=F.util.hexToBytes(n.dekInfo.parameters),c=F.pbe.opensslDeriveBytes(e,a.substr(0,8),s),u=o(c);if(u.start(a),u.update(F.util.createBuffer(n.body)),u.finish())r=u.output.getBytes();else return r}else r=n.body;return n.type==="ENCRYPTED PRIVATE KEY"?r=J.decryptPrivateKeyInfo(A.fromDer(r),e):r=A.fromDer(r),r!==null&&(r=J.privateKeyFromAsn1(r)),r};J.pbe.generatePkcs12Key=function(t,e,r,n,i,s){var o,a;if(typeof s>"u"||s===null){if(!("sha1"in F.md))throw new Error('"sha1" hash algorithm unavailable.');s=F.md.sha1.create()}var c=s.digestLength,u=s.blockLength,l=new F.util.ByteBuffer,f=new F.util.ByteBuffer;if(t!=null){for(a=0;a<t.length;a++)f.putInt16(t.charCodeAt(a));f.putInt16(0)}var h=f.length(),d=e.length(),p=new F.util.ByteBuffer;p.fillWithByte(r,u);var y=u*Math.ceil(d/u),g=new F.util.ByteBuffer;for(a=0;a<y;a++)g.putByte(e.at(a%d));var E=u*Math.ceil(h/u),x=new F.util.ByteBuffer;for(a=0;a<E;a++)x.putByte(f.at(a%h));var _=g;_.putBuffer(x);for(var B=Math.ceil(i/c),D=1;D<=B;D++){var P=new F.util.ByteBuffer;P.putBytes(p.bytes()),P.putBytes(_.bytes());for(var te=0;te<n;te++)s.start(),s.update(P.getBytes()),P=s.digest();var ae=new F.util.ByteBuffer;for(a=0;a<u;a++)ae.putByte(P.at(a%c));var st=Math.ceil(d/u)+Math.ceil(h/u),jt=new F.util.ByteBuffer;for(o=0;o<st;o++){var Ct=new F.util.ByteBuffer(_.getBytes(u)),gt=511;for(a=ae.length()-1;a>=0;a--)gt=gt>>8,gt+=ae.at(a)+Ct.at(a),Ct.setAt(a,gt&255);jt.putBuffer(Ct)}_=jt,l.putBuffer(P)}return l.truncate(l.length()-i),l};J.pbe.getCipher=function(t,e,r){switch(t){case J.oids.pkcs5PBES2:return J.pbe.getCipherForPBES2(t,e,r);case J.oids["pbeWithSHAAnd3-KeyTripleDES-CBC"]:case J.oids["pbewithSHAAnd40BitRC2-CBC"]:return J.pbe.getCipherForPKCS12PBE(t,e,r);default:var n=new Error("Cannot read encrypted PBE data block. Unsupported OID.");throw n.oid=t,n.supportedOids=["pkcs5PBES2","pbeWithSHAAnd3-KeyTripleDES-CBC","pbewithSHAAnd40BitRC2-CBC"],n}};J.pbe.getCipherForPBES2=function(t,e,r){var n={},i=[];if(!A.validate(e,SC,n,i)){var s=new Error("Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.");throw s.errors=i,s}if(t=A.derToOid(n.kdfOid),t!==J.oids.pkcs5PBKDF2){var s=new Error("Cannot read encrypted private key. Unsupported key derivation function OID.");throw s.oid=t,s.supportedOids=["pkcs5PBKDF2"],s}if(t=A.derToOid(n.encOid),t!==J.oids["aes128-CBC"]&&t!==J.oids["aes192-CBC"]&&t!==J.oids["aes256-CBC"]&&t!==J.oids["des-EDE3-CBC"]&&t!==J.oids.desCBC){var s=new Error("Cannot read encrypted private key. Unsupported encryption scheme OID.");throw s.oid=t,s.supportedOids=["aes128-CBC","aes192-CBC","aes256-CBC","des-EDE3-CBC","desCBC"],s}var o=n.kdfSalt,a=F.util.createBuffer(n.kdfIterationCount);a=a.getInt(a.length()<<3);var c,u;switch(J.oids[t]){case"aes128-CBC":c=16,u=F.aes.createDecryptionCipher;break;case"aes192-CBC":c=24,u=F.aes.createDecryptionCipher;break;case"aes256-CBC":c=32,u=F.aes.createDecryptionCipher;break;case"des-EDE3-CBC":c=24,u=F.des.createDecryptionCipher;break;case"desCBC":c=8,u=F.des.createDecryptionCipher;break}var l=fE(n.prfOid),f=F.pkcs5.pbkdf2(r,o,a,c,l),h=n.encIv,d=u(f);return d.start(h),d};J.pbe.getCipherForPKCS12PBE=function(t,e,r){var n={},i=[];if(!A.validate(e,_C,n,i)){var s=new Error("Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.");throw s.errors=i,s}var o=F.util.createBuffer(n.salt),a=F.util.createBuffer(n.iterations);a=a.getInt(a.length()<<3);var c,u,l;switch(t){case J.oids["pbeWithSHAAnd3-KeyTripleDES-CBC"]:c=24,u=8,l=F.des.startDecrypting;break;case J.oids["pbewithSHAAnd40BitRC2-CBC"]:c=5,u=8,l=function(y,g){var E=F.rc2.createDecryptionCipher(y,40);return E.start(g,null),E};break;default:var s=new Error("Cannot read PKCS #12 PBE data block. Unsupported OID.");throw s.oid=t,s}var f=fE(n.prfOid),h=J.pbe.generatePkcs12Key(r,o,1,a,c,f);f.start();var d=J.pbe.generatePkcs12Key(r,o,2,a,u,f);return l(h,d)};J.pbe.opensslDeriveBytes=function(t,e,r,n){if(typeof n>"u"||n===null){if(!("md5"in F.md))throw new Error('"md5" hash algorithm unavailable.');n=F.md.md5.create()}e===null&&(e="");for(var i=[lE(n,t+e)],s=16,o=1;s<r;++o,s+=16)i.push(lE(n,i[o-1]+t+e));return i.join("").substr(0,r)};function lE(t,e){return t.start().update(e).digest().getBytes()}function fE(t){var e;if(!t)e="hmacWithSHA1";else if(e=J.oids[A.derToOid(t)],!e){var r=new Error("Unsupported PRF OID.");throw r.oid=t,r.supported=["hmacWithSHA1","hmacWithSHA224","hmacWithSHA256","hmacWithSHA384","hmacWithSHA512"],r}return hE(e)}function hE(t){var e=F.md;switch(t){case"hmacWithSHA224":e=F.md.sha512;case"hmacWithSHA1":case"hmacWithSHA256":case"hmacWithSHA384":case"hmacWithSHA512":t=t.substr(8).toLowerCase();break;default:var r=new Error("Unsupported PRF algorithm.");throw r.algorithm=t,r.supported=["hmacWithSHA1","hmacWithSHA224","hmacWithSHA256","hmacWithSHA384","hmacWithSHA512"],r}if(!e||!(t in e))throw new Error("Unknown hash algorithm: "+t);return e[t].create()}function AC(t,e,r,n){var i=A.create(A.Class.UNIVERSAL,A.Type.SEQUENCE,!0,[A.create(A.Class.UNIVERSAL,A.Type.OCTETSTRING,!1,t),A.create(A.Class.UNIVERSAL,A.Type.INTEGER,!1,e.getBytes())]);return n!=="hmacWithSHA1"&&i.value.push(A.create(A.Class.UNIVERSAL,A.Type.INTEGER,!1,F.util.hexToBytes(r.toString(16))),A.create(A.Class.UNIVERSAL,A.Type.SEQUENCE,!0,[A.create(A.Class.UNIVERSAL,A.Type.OID,!1,A.oidToDer(J.oids[n]).getBytes()),A.create(A.Class.UNIVERSAL,A.Type.NULL,!1,"")])),i}});var IE=R((H8,CE)=>{var Oe=ie();Cn();De();var co=CE.exports=Oe.sha512=Oe.sha512||{};Oe.md.sha512=Oe.md.algorithms.sha512=co;var _E=Oe.sha384=Oe.sha512.sha384=Oe.sha512.sha384||{};_E.create=function(){return co.create("SHA-384")};Oe.md.sha384=Oe.md.algorithms.sha384=_E;Oe.sha512.sha256=Oe.sha512.sha256||{create:function(){return co.create("SHA-512/256")}};Oe.md["sha512/256"]=Oe.md.algorithms["sha512/256"]=Oe.sha512.sha256;Oe.sha512.sha224=Oe.sha512.sha224||{create:function(){return co.create("SHA-512/224")}};Oe.md["sha512/224"]=Oe.md.algorithms["sha512/224"]=Oe.sha512.sha224;co.create=function(t){if(AE||DC(),typeof t>"u"&&(t="SHA-512"),!(t in di))throw new Error("Invalid SHA-512 algorithm: "+t);for(var e=di[t],r=null,n=Oe.util.createBuffer(),i=new Array(80),s=0;s<80;++s)i[s]=new Array(2);var o=64;switch(t){case"SHA-384":o=48;break;case"SHA-512/256":o=32;break;case"SHA-512/224":o=28;break}var a={algorithm:t.replace("-","").toLowerCase(),blockLength:128,digestLength:o,messageLength:0,fullMessageLength:null,messageLengthSize:16};return a.start=function(){a.messageLength=0,a.fullMessageLength=a.messageLength128=[];for(var c=a.messageLengthSize/4,u=0;u<c;++u)a.fullMessageLength.push(0);n=Oe.util.createBuffer(),r=new Array(e.length);for(var u=0;u<e.length;++u)r[u]=e[u].slice(0);return a},a.start(),a.update=function(c,u){u==="utf8"&&(c=Oe.util.encodeUtf8(c));var l=c.length;a.messageLength+=l,l=[l/4294967296>>>0,l>>>0];for(var f=a.fullMessageLength.length-1;f>=0;--f)a.fullMessageLength[f]+=l[1],l[1]=l[0]+(a.fullMessageLength[f]/4294967296>>>0),a.fullMessageLength[f]=a.fullMessageLength[f]>>>0,l[0]=l[1]/4294967296>>>0;return n.putBytes(c),SE(r,i,n),(n.read>2048||n.length()===0)&&n.compact(),a},a.digest=function(){var c=Oe.util.createBuffer();c.putBytes(n.bytes());var u=a.fullMessageLength[a.fullMessageLength.length-1]+a.messageLengthSize,l=u&a.blockLength-1;c.putBytes(Hf.substr(0,a.blockLength-l));for(var f,h,d=a.fullMessageLength[0]*8,p=0;p<a.fullMessageLength.length-1;++p)f=a.fullMessageLength[p+1]*8,h=f/4294967296>>>0,d+=h,c.putInt32(d>>>0),d=f>>>0;c.putInt32(d);for(var y=new Array(r.length),p=0;p<r.length;++p)y[p]=r[p].slice(0);SE(y,i,c);var g=Oe.util.createBuffer(),E;t==="SHA-512"?E=y.length:t==="SHA-384"?E=y.length-2:E=y.length-4;for(var p=0;p<E;++p)g.putInt32(y[p][0]),(p!==E-1||t!=="SHA-512/224")&&g.putInt32(y[p][1]);return g},a};var Hf=null,AE=!1,zf=null,di=null;function DC(){Hf=String.fromCharCode(128),Hf+=Oe.util.fillString(String.fromCharCode(0),128),zf=[[1116352408,3609767458],[1899447441,602891725],[3049323471,3964484399],[3921009573,2173295548],[961987163,4081628472],[1508970993,3053834265],[2453635748,2937671579],[2870763221,3664609560],[3624381080,2734883394],[310598401,1164996542],[607225278,1323610764],[1426881987,3590304994],[1925078388,4068182383],[2162078206,991336113],[2614888103,633803317],[3248222580,3479774868],[3835390401,2666613458],[4022224774,944711139],[264347078,2341262773],[604807628,2007800933],[770255983,1495990901],[1249150122,1856431235],[1555081692,3175218132],[1996064986,2198950837],[2554220882,3999719339],[2821834349,766784016],[2952996808,2566594879],[3210313671,3203337956],[3336571891,1034457026],[3584528711,2466948901],[113926993,3758326383],[338241895,168717936],[666307205,1188179964],[773529912,1546045734],[1294757372,1522805485],[1396182291,2643833823],[1695183700,2343527390],[1986661051,1014477480],[2177026350,1206759142],[2456956037,344077627],[2730485921,1290863460],[2820302411,3158454273],[3259730800,3505952657],[3345764771,106217008],[3516065817,3606008344],[3600352804,1432725776],[4094571909,1467031594],[275423344,851169720],[430227734,3100823752],[506948616,1363258195],[659060556,3750685593],[883997877,3785050280],[958139571,3318307427],[1322822218,3812723403],[1537002063,2003034995],[1747873779,3602036899],[1955562222,1575990012],[2024104815,1125592928],[2227730452,2716904306],[2361852424,442776044],[2428436474,593698344],[2756734187,3733110249],[3204031479,2999351573],[3329325298,3815920427],[3391569614,3928383900],[3515267271,566280711],[3940187606,3454069534],[4118630271,4000239992],[116418474,1914138554],[174292421,2731055270],[289380356,3203993006],[460393269,320620315],[685471733,587496836],[852142971,1086792851],[1017036298,365543100],[1126000580,2618297676],[1288033470,3409855158],[1501505948,4234509866],[1607167915,987167468],[1816402316,1246189591]],di={},di["SHA-512"]=[[1779033703,4089235720],[3144134277,2227873595],[1013904242,4271175723],[2773480762,1595750129],[1359893119,2917565137],[2600822924,725511199],[528734635,4215389547],[1541459225,327033209]],di["SHA-384"]=[[3418070365,3238371032],[1654270250,914150663],[2438529370,812702999],[355462360,4144912697],[1731405415,4290775857],[2394180231,1750603025],[3675008525,1694076839],[1203062813,3204075428]],di["SHA-512/256"]=[[573645204,4230739756],[2673172387,3360449730],[596883563,1867755857],[2520282905,1497426621],[2519219938,2827943907],[3193839141,1401305490],[721525244,746961066],[246885852,2177182882]],di["SHA-512/224"]=[[2352822216,424955298],[1944164710,2312950998],[502970286,855612546],[1738396948,1479516111],[258812777,2077511080],[2011393907,79989058],[1067287976,1780299464],[286451373,2446758561]],AE=!0}function SE(t,e,r){for(var n,i,s,o,a,c,u,l,f,h,d,p,y,g,E,x,_,B,D,P,te,ae,st,jt,Ct,gt,Ci,jo,Je,bt,Y,Su,_u,Au,Cu,yd=r.length();yd>=128;){for(Je=0;Je<16;++Je)e[Je][0]=r.getInt32()>>>0,e[Je][1]=r.getInt32()>>>0;for(;Je<80;++Je)Su=e[Je-2],bt=Su[0],Y=Su[1],n=((bt>>>19|Y<<13)^(Y>>>29|bt<<3)^bt>>>6)>>>0,i=((bt<<13|Y>>>19)^(Y<<3|bt>>>29)^(bt<<26|Y>>>6))>>>0,Au=e[Je-15],bt=Au[0],Y=Au[1],s=((bt>>>1|Y<<31)^(bt>>>8|Y<<24)^bt>>>7)>>>0,o=((bt<<31|Y>>>1)^(bt<<24|Y>>>8)^(bt<<25|Y>>>7))>>>0,_u=e[Je-7],Cu=e[Je-16],Y=i+_u[1]+o+Cu[1],e[Je][0]=n+_u[0]+s+Cu[0]+(Y/4294967296>>>0)>>>0,e[Je][1]=Y>>>0;for(y=t[0][0],g=t[0][1],E=t[1][0],x=t[1][1],_=t[2][0],B=t[2][1],D=t[3][0],P=t[3][1],te=t[4][0],ae=t[4][1],st=t[5][0],jt=t[5][1],Ct=t[6][0],gt=t[6][1],Ci=t[7][0],jo=t[7][1],Je=0;Je<80;++Je)u=((te>>>14|ae<<18)^(te>>>18|ae<<14)^(ae>>>9|te<<23))>>>0,l=((te<<18|ae>>>14)^(te<<14|ae>>>18)^(ae<<23|te>>>9))>>>0,f=(Ct^te&(st^Ct))>>>0,h=(gt^ae&(jt^gt))>>>0,a=((y>>>28|g<<4)^(g>>>2|y<<30)^(g>>>7|y<<25))>>>0,c=((y<<4|g>>>28)^(g<<30|y>>>2)^(g<<25|y>>>7))>>>0,d=(y&E|_&(y^E))>>>0,p=(g&x|B&(g^x))>>>0,Y=jo+l+h+zf[Je][1]+e[Je][1],n=Ci+u+f+zf[Je][0]+e[Je][0]+(Y/4294967296>>>0)>>>0,i=Y>>>0,Y=c+p,s=a+d+(Y/4294967296>>>0)>>>0,o=Y>>>0,Ci=Ct,jo=gt,Ct=st,gt=jt,st=te,jt=ae,Y=P+i,te=D+n+(Y/4294967296>>>0)>>>0,ae=Y>>>0,D=_,P=B,_=E,B=x,E=y,x=g,Y=i+o,y=n+s+(Y/4294967296>>>0)>>>0,g=Y>>>0;Y=t[0][1]+g,t[0][0]=t[0][0]+y+(Y/4294967296>>>0)>>>0,t[0][1]=Y>>>0,Y=t[1][1]+x,t[1][0]=t[1][0]+E+(Y/4294967296>>>0)>>>0,t[1][1]=Y>>>0,Y=t[2][1]+B,t[2][0]=t[2][0]+_+(Y/4294967296>>>0)>>>0,t[2][1]=Y>>>0,Y=t[3][1]+P,t[3][0]=t[3][0]+D+(Y/4294967296>>>0)>>>0,t[3][1]=Y>>>0,Y=t[4][1]+ae,t[4][0]=t[4][0]+te+(Y/4294967296>>>0)>>>0,t[4][1]=Y>>>0,Y=t[5][1]+jt,t[5][0]=t[5][0]+st+(Y/4294967296>>>0)>>>0,t[5][1]=Y>>>0,Y=t[6][1]+gt,t[6][0]=t[6][0]+Ct+(Y/4294967296>>>0)>>>0,t[6][1]=Y>>>0,Y=t[7][1]+jo,t[7][0]=t[7][0]+Ci+(Y/4294967296>>>0)>>>0,t[7][1]=Y>>>0,yd-=128}}});var ow=R((w6,sw)=>{function zI(){return!!(typeof window<"u"&&typeof window.process=="object"&&window.process.type==="renderer"||typeof process<"u"&&typeof process.versions=="object"&&process.versions.electron||typeof navigator=="object"&&typeof navigator.userAgent=="string"&&navigator.userAgent.indexOf("Electron")>=0)}sw.exports=zI});var ww=R((v5,kh)=>{"use strict";var WI=Object.prototype.hasOwnProperty,xt="~";function Vo(){}Object.create&&(Vo.prototype=Object.create(null),new Vo().__proto__||(xt=!1));function QI(t,e,r){this.fn=t,this.context=e,this.once=r||!1}function vw(t,e,r,n,i){if(typeof r!="function")throw new TypeError("The listener must be a function");var s=new QI(r,n||t,i),o=xt?xt+e:e;return t._events[o]?t._events[o].fn?t._events[o]=[t._events[o],s]:t._events[o].push(s):(t._events[o]=s,t._eventsCount++),t}function iu(t,e){--t._eventsCount===0?t._events=new Vo:delete t._events[e]}function yt(){this._events=new Vo,this._eventsCount=0}yt.prototype.eventNames=function(){var e=[],r,n;if(this._eventsCount===0)return e;for(n in r=this._events)WI.call(r,n)&&e.push(xt?n.slice(1):n);return Object.getOwnPropertySymbols?e.concat(Object.getOwnPropertySymbols(r)):e};yt.prototype.listeners=function(e){var r=xt?xt+e:e,n=this._events[r];if(!n)return[];if(n.fn)return[n.fn];for(var i=0,s=n.length,o=new Array(s);i<s;i++)o[i]=n[i].fn;return o};yt.prototype.listenerCount=function(e){var r=xt?xt+e:e,n=this._events[r];return n?n.fn?1:n.length:0};yt.prototype.emit=function(e,r,n,i,s,o){var a=xt?xt+e:e;if(!this._events[a])return!1;var c=this._events[a],u=arguments.length,l,f;if(c.fn){switch(c.once&&this.removeListener(e,c.fn,void 0,!0),u){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,r),!0;case 3:return c.fn.call(c.context,r,n),!0;case 4:return c.fn.call(c.context,r,n,i),!0;case 5:return c.fn.call(c.context,r,n,i,s),!0;case 6:return c.fn.call(c.context,r,n,i,s,o),!0}for(f=1,l=new Array(u-1);f<u;f++)l[f-1]=arguments[f];c.fn.apply(c.context,l)}else{var h=c.length,d;for(f=0;f<h;f++)switch(c[f].once&&this.removeListener(e,c[f].fn,void 0,!0),u){case 1:c[f].fn.call(c[f].context);break;case 2:c[f].fn.call(c[f].context,r);break;case 3:c[f].fn.call(c[f].context,r,n);break;case 4:c[f].fn.call(c[f].context,r,n,i);break;default:if(!l)for(d=1,l=new Array(u-1);d<u;d++)l[d-1]=arguments[d];c[f].fn.apply(c[f].context,l)}}return!0};yt.prototype.on=function(e,r,n){return vw(this,e,r,n,!1)};yt.prototype.once=function(e,r,n){return vw(this,e,r,n,!0)};yt.prototype.removeListener=function(e,r,n,i){var s=xt?xt+e:e;if(!this._events[s])return this;if(!r)return iu(this,s),this;var o=this._events[s];if(o.fn)o.fn===r&&(!i||o.once)&&(!n||o.context===n)&&iu(this,s);else{for(var a=0,c=[],u=o.length;a<u;a++)(o[a].fn!==r||i&&!o[a].once||n&&o[a].context!==n)&&c.push(o[a]);c.length?this._events[s]=c.length===1?c[0]:c:iu(this,s)}return this};yt.prototype.removeAllListeners=function(e){var r;return e?(r=xt?xt+e:e,this._events[r]&&iu(this,r)):(this._events=new Vo,this._eventsCount=0),this};yt.prototype.off=yt.prototype.removeListener;yt.prototype.addListener=yt.prototype.on;yt.prefixed=xt;yt.EventEmitter=yt;typeof kh<"u"&&(kh.exports=yt)});var Kw=R((uU,Fw)=>{"use strict";Fw.exports=Mw;var eT=Iu(),Kn=Mw.prototype,tT=new Date%1e9;function rT(){return(Math.random()*1e9>>>0)+tT++}function Mw(t){t=t||{},this.id=t.id||rT(),this.max=t.max||1/0,this.items=t.items||[],this._lookup={},this.size=this.items.length,this.lastModified=new Date(t.lastModified||new Date);for(var e,r,n=this.items.length;n--;)e=this.items[n],r=new Date(e.expires)-new Date,this._lookup[e.key]=e,r>0?this.expire(e.key,r):r<=0&&this.delete(e.key)}Kn.has=function(t){return t in this._lookup};Kn.get=function(t){if(!this.has(t))return null;var e=this._lookup[t];return e.refresh&&this.expire(t,e.refresh),this.items.splice(this.items.indexOf(e),1),this.items.push(e),e.value};Kn.meta=function(t){if(!this.has(t))return null;var e=this._lookup[t];return"meta"in e?e.meta:null};Kn.set=function(t,e,r){var n=this._lookup[t],i=this._lookup[t]={key:t,value:e};return this.lastModified=new Date,n?(clearTimeout(n.timeout),this.items.splice(this.items.indexOf(n),1,i)):(this.size>=this.max&&this.delete(this.items[0].key),this.items.push(i),this.size++),r&&("ttl"in r&&this.expire(t,r.ttl),"meta"in r&&(i.meta=r.meta),r.refresh&&(i.refresh=r.ttl)),this};Kn.delete=function(t){var e=this._lookup[t];return e?(this.lastModified=new Date,this.items.splice(this.items.indexOf(e),1),clearTimeout(e.timeout),delete this._lookup[t],this.size--,this):!1};Kn.expire=function(t,e){var r=e||0,n=this._lookup[t];if(!n)return this;if(typeof r=="string"&&(r=eT(e)),typeof r!="number")throw new TypeError("Expiration time must be a string or number.");return clearTimeout(n.timeout),n.timeout=setTimeout(this.delete.bind(this,n.key),r),n.expires=Number(new Date)+r,this};Kn.clear=function(){for(var t=this.items.length;t--;)this.delete(this.items[t].key);return this};Kn.toJSON=function(){for(var t=new Array(this.items.length),e,r=t.length;r--;)e=this.items[r],t[r]={key:e.key,meta:e.meta,value:e.value,expires:e.expires,refresh:e.refresh};return{id:this.id,max:isFinite(this.max)?this.max:void 0,lastModified:this.lastModified,items:t}}});var hd=R((HU,fd)=>{function Xw(t){let e=new globalThis.AbortController;function r(){e.abort();for(let n of t)!n||!n.removeEventListener||n.removeEventListener("abort",r)}for(let n of t)if(!(!n||!n.addEventListener)){if(n.aborted){r();break}n.addEventListener("abort",r)}return e.signal}fd.exports=Xw;fd.exports.anySignal=Xw});var Zw=R(($U,jw)=>{jw.exports=class{constructor(e){if(!(e>0)||e-1&e)throw new Error("Max size for a FixedFIFO should be a power of two");this.buffer=new Array(e),this.mask=e-1,this.top=0,this.btm=0,this.next=null}push(e){return this.buffer[this.top]!==void 0?!1:(this.buffer[this.top]=e,this.top=this.top+1&this.mask,!0)}shift(){let e=this.buffer[this.btm];if(e!==void 0)return this.buffer[this.btm]=void 0,this.btm=this.btm+1&this.mask,e}peek(){return this.buffer[this.btm]}isEmpty(){return this.buffer[this.btm]===void 0}}});var t1=R((YU,e1)=>{var Jw=Zw();e1.exports=class{constructor(e){this.hwm=e||16,this.head=new Jw(this.hwm),this.tail=this.head}push(e){if(!this.head.push(e)){let r=this.head;this.head=r.next=new Jw(2*this.head.buffer.length),this.head.push(e)}}shift(){let e=this.tail.shift();if(e===void 0&&this.tail.next){let r=this.tail.next;return this.tail.next=null,this.tail=r,this.tail.shift()}return e}peek(){return this.tail.peek()}isEmpty(){return this.head.isEmpty()}}});var n1=R((WU,r1)=>{"use strict";var fT=()=>{let t={};return t.promise=new Promise((e,r)=>{t.resolve=e,t.reject=r}),t};r1.exports=fT});var a1=R((XU,o1)=>{var i1=t1(),s1=n1();o1.exports=class{constructor(){this._buffer=new i1,this._waitingConsumers=new i1}push(e){let{promise:r,resolve:n}=s1();return this._buffer.push({chunk:e,resolve:n}),this._consume(),r}_consume(){for(;!this._waitingConsumers.isEmpty()&&!this._buffer.isEmpty();){let e=this._waitingConsumers.shift(),r=this._buffer.shift();e.resolve(r.chunk),r.resolve()}}shift(){let{promise:e,resolve:r}=s1();return this._waitingConsumers.push({resolve:r}),this._consume(),e}isEmpty(){return this._buffer.isEmpty()}}});var mT={};pt(mT,{createLibp2p:()=>pT});var ur=C(Tu(),1);var Pu={};pt(Pu,{base58btc:()=>We,base58flickr:()=>M1});function P1(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 i=0;i<t.length;i++){var s=t.charAt(i),o=s.charCodeAt(0);if(r[o]!==255)throw new TypeError(s+" is ambiguous");r[o]=i}var a=t.length,c=t.charAt(0),u=Math.log(a)/Math.log(256),l=Math.log(256)/Math.log(a);function f(p){if(p instanceof Uint8Array||(ArrayBuffer.isView(p)?p=new Uint8Array(p.buffer,p.byteOffset,p.byteLength):Array.isArray(p)&&(p=Uint8Array.from(p))),!(p instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(p.length===0)return"";for(var y=0,g=0,E=0,x=p.length;E!==x&&p[E]===0;)E++,y++;for(var _=(x-E)*l+1>>>0,B=new Uint8Array(_);E!==x;){for(var D=p[E],P=0,te=_-1;(D!==0||P<g)&&te!==-1;te--,P++)D+=256*B[te]>>>0,B[te]=D%a>>>0,D=D/a>>>0;if(D!==0)throw new Error("Non-zero carry");g=P,E++}for(var ae=_-g;ae!==_&&B[ae]===0;)ae++;for(var st=c.repeat(y);ae<_;++ae)st+=t.charAt(B[ae]);return st}function h(p){if(typeof p!="string")throw new TypeError("Expected String");if(p.length===0)return new Uint8Array;var y=0;if(p[y]!==" "){for(var g=0,E=0;p[y]===c;)g++,y++;for(var x=(p.length-y)*u+1>>>0,_=new Uint8Array(x);p[y];){var B=r[p.charCodeAt(y)];if(B===255)return;for(var D=0,P=x-1;(B!==0||D<E)&&P!==-1;P--,D++)B+=a*_[P]>>>0,_[P]=B%256>>>0,B=B/256>>>0;if(B!==0)throw new Error("Non-zero carry");E=D,y++}if(p[y]!==" "){for(var te=x-E;te!==x&&_[te]===0;)te++;for(var ae=new Uint8Array(g+(x-te)),st=g;te!==x;)ae[st++]=_[te++];return ae}}}function d(p){var y=h(p);if(y)return y;throw new Error(`Non-${e} character`)}return{encode:f,decodeUnsafe:h,decode:d}}var B1=P1,O1=B1,xd=O1;var wT=new Uint8Array(0);var bd=(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},Nr=t=>{if(t instanceof Uint8Array&&t.constructor.name==="Uint8Array")return t;if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);throw new Error("Unknown type, must be binary type")};var Sd=t=>new TextEncoder().encode(t),_d=t=>new TextDecoder().decode(t);var Ru=class{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")}},Nu=class{constructor(e,r,n){if(this.name=e,this.prefix=r,r.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=r.codePointAt(0),this.baseDecode=n}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return Cd(this,e)}},Du=class{constructor(e){this.decoders=e}or(e){return Cd(this,e)}decode(e){let r=e[0],n=this.decoders[r];if(n)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},Cd=(t,e)=>new Du({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}}),Lu=class{constructor(e,r,n,i){this.name=e,this.prefix=r,this.baseEncode=n,this.baseDecode=i,this.encoder=new Ru(e,r,n),this.decoder=new Nu(e,r,i)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}},Ni=({name:t,prefix:e,encode:r,decode:n})=>new Lu(t,e,r,n),ln=({prefix:t,name:e,alphabet:r})=>{let{encode:n,decode:i}=xd(r,e);return Ni({prefix:t,name:e,encode:n,decode:s=>Nr(i(s))})},k1=(t,e,r,n)=>{let i={};for(let l=0;l<e.length;++l)i[e[l]]=l;let s=t.length;for(;t[s-1]==="=";)--s;let o=new Uint8Array(s*r/8|0),a=0,c=0,u=0;for(let l=0;l<s;++l){let f=i[t[l]];if(f===void 0)throw new SyntaxError(`Non-${n} character`);c=c<<r|f,a+=r,a>=8&&(a-=8,o[u++]=255&c>>a)}if(a>=r||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return o},U1=(t,e,r)=>{let n=e[e.length-1]==="=",i=(1<<r)-1,s="",o=0,a=0;for(let c=0;c<t.length;++c)for(a=a<<8|t[c],o+=8;o>r;)o-=r,s+=e[i&a>>o];if(o&&(s+=e[i&a<<r-o]),n)for(;s.length*r&7;)s+="=";return s},ze=({name:t,prefix:e,bitsPerChar:r,alphabet:n})=>Ni({prefix:e,name:t,encode(i){return U1(i,n,r)},decode(i){return k1(i,n,r,t)}});var We=ln({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),M1=ln({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Bu={};pt(Bu,{base32:()=>Tt,base32hex:()=>q1,base32hexpad:()=>z1,base32hexpadupper:()=>$1,base32hexupper:()=>H1,base32pad:()=>K1,base32padupper:()=>V1,base32upper:()=>F1,base32z:()=>G1});var Tt=ze({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),F1=ze({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),K1=ze({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),V1=ze({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),q1=ze({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),H1=ze({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),z1=ze({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),$1=ze({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),G1=ze({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Ou={};pt(Ou,{base64:()=>qn,base64pad:()=>Y1,base64url:()=>W1,base64urlpad:()=>Q1});var qn=ze({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Y1=ze({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),W1=ze({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Q1=ze({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});ur.default.formatters.b=t=>t==null?"undefined":We.baseEncode(t);ur.default.formatters.t=t=>t==null?"undefined":Tt.baseEncode(t);ur.default.formatters.m=t=>t==null?"undefined":qn.baseEncode(t);ur.default.formatters.p=t=>t==null?"undefined":t.toString();ur.default.formatters.c=t=>t==null?"undefined":t.toString();ur.default.formatters.k=t=>t==null?"undefined":t.toString();function M(t){return Object.assign((0,ur.default)(t),{error:(0,ur.default)(`${t}:error`),trace:(0,ur.default)(`${t}:trace`)})}var Hn=function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},Dr,Ue=class extends EventTarget{constructor(){super(...arguments),Dr.set(this,new Map)}listenerCount(e){let r=Hn(this,Dr,"f").get(e);return r==null?0:r.length}addEventListener(e,r,n){super.addEventListener(e,r,n);let i=Hn(this,Dr,"f").get(e);i==null&&(i=[],Hn(this,Dr,"f").set(e,i)),i.push({callback:r,once:(n!==!0&&n!==!1&&n?.once)??!1})}removeEventListener(e,r,n){super.removeEventListener(e.toString(),r??null,n);let i=Hn(this,Dr,"f").get(e);i!=null&&(i=i.filter(({callback:s})=>s!==r),Hn(this,Dr,"f").set(e,i))}dispatchEvent(e){let r=super.dispatchEvent(e),n=Hn(this,Dr,"f").get(e.type);return n==null||(n=n.filter(({once:i})=>!i),Hn(this,Dr,"f").set(e.type,n)),r}};Dr=new WeakMap;var ku=class extends Event{constructor(e,r){super(e,r),this.detail=r?.detail}},X=globalThis.CustomEvent??ku;function Lr(t){return t!=null&&typeof t.start=="function"&&typeof t.stop=="function"}var Rd=C(Td(),1),Uu=(t,e)=>async function*(){yield*(await(0,Rd.default)(t)).sort(e)}();var Mu=C(Dd(),1),zn=C(Pd(),1),Fu=C(Od(),1),ta=class{open(){return Promise.reject(new Error(".open is not implemented"))}close(){return Promise.reject(new Error(".close is not implemented"))}put(e,r,n){return Promise.reject(new Error(".put is not implemented"))}get(e,r){return Promise.reject(new Error(".get is not implemented"))}has(e,r){return Promise.reject(new Error(".has is not implemented"))}delete(e,r){return Promise.reject(new Error(".delete is not implemented"))}async*putMany(e,r={}){for await(let{key:n,value:i}of e)await this.put(n,i,r),yield{key:n,value:i}}async*getMany(e,r={}){for await(let n of e)yield this.get(n,r)}async*deleteMany(e,r={}){for await(let n of e)await this.delete(n,r),yield n}batch(){let e=[],r=[];return{put(n,i){e.push({key:n,value:i})},delete(n){r.push(n)},commit:async n=>{await(0,Mu.default)(this.putMany(e,n)),e=[],await(0,Mu.default)(this.deleteMany(r,n)),r=[]}}}async*_all(e,r){throw new Error("._all is not implemented")}async*_allKeys(e,r){throw new Error("._allKeys is not implemented")}query(e,r){let n=this._all(e,r);if(e.prefix!=null&&(n=(0,zn.default)(n,i=>i.key.toString().startsWith(e.prefix))),Array.isArray(e.filters)&&(n=e.filters.reduce((i,s)=>(0,zn.default)(i,s),n)),Array.isArray(e.orders)&&(n=e.orders.reduce((i,s)=>Uu(i,s),n)),e.offset!=null){let i=0;n=(0,zn.default)(n,()=>i++>=e.offset)}return e.limit!=null&&(n=(0,Fu.default)(n,e.limit)),n}queryKeys(e,r){let n=this._allKeys(e,r);if(e.prefix!=null&&(n=(0,zn.default)(n,i=>i.toString().startsWith(e.prefix))),Array.isArray(e.filters)&&(n=e.filters.reduce((i,s)=>(0,zn.default)(i,s),n)),Array.isArray(e.orders)&&(n=e.orders.reduce((i,s)=>Uu(i,s),n)),e.offset!=null){let i=0;n=(0,zn.default)(n,()=>i++>=e.offset)}return e.limit!=null&&(n=(0,Fu.default)(n,e.limit)),n}};var ra=(t=21)=>crypto.getRandomValues(new Uint8Array(t)).reduce((e,r)=>(r&=63,r<36?e+=r.toString(36):r<62?e+=(r-26).toString(36).toUpperCase():r>62?e+="-":e+="_",e),"");var Ku={};pt(Ku,{identity:()=>ex});var ex=Ni({prefix:"\0",name:"identity",encode:t=>_d(t),decode:t=>Sd(t)});var Vu={};pt(Vu,{base2:()=>tx});var tx=ze({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var qu={};pt(qu,{base8:()=>rx});var rx=ze({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Hu={};pt(Hu,{base10:()=>nx});var nx=ln({prefix:"9",name:"base10",alphabet:"0123456789"});var zu={};pt(zu,{base16:()=>ix,base16upper:()=>sx});var ix=ze({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),sx=ze({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var $u={};pt($u,{base36:()=>ox,base36upper:()=>ax});var ox=ln({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),ax=ln({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Gu={};pt(Gu,{base256emoji:()=>hx});var kd=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}"),cx=kd.reduce((t,e,r)=>(t[r]=e,t),[]),ux=kd.reduce((t,e,r)=>(t[e.codePointAt(0)]=r,t),[]);function lx(t){return t.reduce((e,r)=>(e+=cx[r],e),"")}function fx(t){let e=[];for(let r of t){let n=ux[r.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${r}`);e.push(n)}return new Uint8Array(e)}var hx=Ni({prefix:"\u{1F680}",name:"base256emoji",encode:lx,decode:fx});var Xu={};pt(Xu,{sha256:()=>ot,sha512:()=>Dx});var dx=Fd,Ud=128,px=127,mx=~px,yx=Math.pow(2,31);function Fd(t,e,r){e=e||[],r=r||0;for(var n=r;t>=yx;)e[r++]=t&255|Ud,t/=128;for(;t&mx;)e[r++]=t&255|Ud,t>>>=7;return e[r]=t|0,Fd.bytes=r-n+1,e}var gx=Yu,Ex=128,Md=127;function Yu(t,n){var r=0,n=n||0,i=0,s=n,o,a=t.length;do{if(s>=a)throw Yu.bytes=0,new RangeError("Could not decode varint");o=t[s++],r+=i<28?(o&Md)<<i:(o&Md)*Math.pow(2,i),i+=7}while(o>=Ex);return Yu.bytes=s-n,r}var vx=Math.pow(2,7),wx=Math.pow(2,14),xx=Math.pow(2,21),bx=Math.pow(2,28),Sx=Math.pow(2,35),_x=Math.pow(2,42),Ax=Math.pow(2,49),Cx=Math.pow(2,56),Ix=Math.pow(2,63),Tx=function(t){return t<vx?1:t<wx?2:t<xx?3:t<bx?4:t<Sx?5:t<_x?6:t<Ax?7:t<Cx?8:t<Ix?9:10},Rx={encode:dx,decode:gx,encodingLength:Tx},Nx=Rx,Rs=Nx;var Ns=(t,e=0)=>[Rs.decode(t,e),Rs.decode.bytes],Di=(t,e,r=0)=>(Rs.encode(t,e,r),e),Li=t=>Rs.encodingLength(t);var lr=(t,e)=>{let r=e.byteLength,n=Li(t),i=n+Li(r),s=new Uint8Array(i+r);return Di(t,s,0),Di(r,s,n),s.set(e,i),new Pi(t,r,e,s)},$n=t=>{let e=Nr(t),[r,n]=Ns(e),[i,s]=Ns(e.subarray(n)),o=e.subarray(n+s);if(o.byteLength!==i)throw new Error("Incorrect length");return new Pi(r,i,o,e)},Kd=(t,e)=>{if(t===e)return!0;{let r=e;return t.code===r.code&&t.size===r.size&&r.bytes instanceof Uint8Array&&bd(t.bytes,r.bytes)}},Pi=class{constructor(e,r,n,i){this.code=e,this.size=r,this.digest=n,this.bytes=i}};var Qu=({name:t,code:e,encode:r})=>new Wu(t,e,r),Wu=class{constructor(e,r,n){this.name=e,this.code=r,this.encode=n}digest(e){if(e instanceof Uint8Array){let r=this.encode(e);return r instanceof Uint8Array?lr(this.code,r):r.then(n=>lr(this.code,n))}else throw Error("Unknown type, must be binary type")}};var qd=t=>async e=>new Uint8Array(await crypto.subtle.digest(t,e)),ot=Qu({name:"sha2-256",code:18,encode:qd("SHA-256")}),Dx=Qu({name:"sha2-512",code:19,encode:qd("SHA-512")});var ju={};pt(ju,{identity:()=>fn});var Hd=0,Lx="identity",zd=Nr,Px=t=>lr(Hd,zd(t)),fn={code:Hd,name:Lx,encode:zd,digest:Px};var tR=new TextEncoder,rR=new TextDecoder;var kx=(t,e)=>{let{bytes:r,version:n}=t;switch(n){case 0:return Mx(r,Zu(t),e||We.encoder);default:return Fx(r,Zu(t),e||Tt.encoder)}},$d=new WeakMap,Zu=t=>{let e=$d.get(t);if(e==null){let r=new Map;return $d.set(t,r),r}return e},ve=class{constructor(e,r,n,i){this.code=r,this.version=e,this.multihash=n,this.bytes=i,this["/"]=i}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:e,multihash:r}=this;if(e!==Ds)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==Kx)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return ve.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=lr(e,r);return ve.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 ve.equals(this,e)}static equals(e,r){let n=r;return n&&e.code===n.code&&e.version===n.version&&Kd(e.multihash,n.multihash)}toString(e){return kx(this,e)}toJSON(){return{code:this.code,version:this.version,hash:this.multihash.bytes}}link(){return this}get[Symbol.toStringTag](){return"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 ve)return r;if(r["/"]!=null&&r["/"]===r.bytes||r.asCID===r){let{version:n,code:i,multihash:s,bytes:o}=r;return new ve(n,i,s,o||Gd(n,i,s.bytes))}else if(r[Vx]===!0){let{version:n,multihash:i,code:s}=r,o=$n(i);return ve.create(n,s,o)}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!==Ds)throw new Error(`Version 0 CID must use dag-pb (code: ${Ds}) block encoding`);return new ve(e,r,n,n.bytes)}case 1:{let i=Gd(e,r,n.bytes);return new ve(e,r,n,i)}default:throw new Error("Invalid version")}}static createV0(e){return ve.create(0,Ds,e)}static createV1(e,r){return ve.create(1,e,r)}static decode(e){let[r,n]=ve.decodeFirst(e);if(n.length)throw new Error("Incorrect length");return r}static decodeFirst(e){let r=ve.inspectBytes(e),n=r.size-r.multihashSize,i=Nr(e.subarray(n,n+r.multihashSize));if(i.byteLength!==r.multihashSize)throw new Error("Incorrect length");let s=i.subarray(r.multihashSize-r.digestSize),o=new Pi(r.multihashCode,r.digestSize,s,i);return[r.version===0?ve.createV0(o):ve.createV1(r.codec,o),e.subarray(r.size)]}static inspectBytes(e){let r=0,n=()=>{let[f,h]=Ns(e.subarray(r));return r+=h,f},i=n(),s=Ds;if(i===18?(i=0,r=0):s=n(),i!==0&&i!==1)throw new RangeError(`Invalid CID version ${i}`);let o=r,a=n(),c=n(),u=r+c,l=u-o;return{version:i,codec:s,multihashCode:a,digestSize:c,multihashSize:l,size:u}}static parse(e,r){let[n,i]=Ux(e,r),s=ve.decode(i);return Zu(s).set(n,e),s}},Ux=(t,e)=>{switch(t[0]){case"Q":{let r=e||We;return[We.prefix,r.decode(`${We.prefix}${t}`)]}case We.prefix:{let r=e||We;return[We.prefix,r.decode(t)]}case Tt.prefix:{let r=e||Tt;return[Tt.prefix,r.decode(t)]}default:{if(e==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[t[0],e.decode(t)]}}},Mx=(t,e,r)=>{let{prefix:n}=r;if(n!==We.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);let i=e.get(n);if(i==null){let s=r.encode(t).slice(1);return e.set(n,s),s}else return i},Fx=(t,e,r)=>{let{prefix:n}=r,i=e.get(n);if(i==null){let s=r.encode(t);return e.set(n,s),s}else return i},Ds=112,Kx=18,Gd=(t,e,r)=>{let n=Li(t),i=n+Li(e),s=new Uint8Array(i+r.byteLength);return Di(t,s,0),Di(e,s,n),s.set(r,i),s},Vx=Symbol.for("@ipld/js-cid/CID");var hn={...Ku,...Vu,...qu,...Hu,...zu,...Bu,...$u,...Pu,...Ou,...Gu},hR={...Xu,...ju};function Yn(t){return globalThis.Buffer!=null?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):t}function Pr(t=0){return globalThis.Buffer?.alloc!=null?Yn(globalThis.Buffer.alloc(t)):new Uint8Array(t)}function Br(t=0){return globalThis.Buffer?.allocUnsafe!=null?Yn(globalThis.Buffer.allocUnsafe(t)):new Uint8Array(t)}function Wd(t,e,r,n){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:n}}}var Yd=Wd("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),Ju=Wd("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=Br(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}),qx={utf8:Yd,"utf-8":Yd,hex:hn.base16,latin1:Ju,ascii:Ju,binary:Ju,...hn},ia=qx;function Q(t,e="utf8"){let r=ia[e];if(r==null)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(t.buffer,t.byteOffset,t.byteLength).toString("utf8"):r.encoder.encode(t).substring(1)}function q(t,e="utf8"){let r=ia[e];if(r==null)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?Yn(globalThis.Buffer.from(t,"utf-8")):r.decoder.decode(`${r.prefix}${t}`)}var Or="/",Qd=new TextEncoder().encode(Or),sa=Qd[0],$e=class{constructor(e,r){if(typeof e=="string")this._buf=q(e);else if(e instanceof Uint8Array)this._buf=e;else throw new Error("Invalid key, should be String of Uint8Array");if(r==null&&(r=!0),r&&this.clean(),this._buf.byteLength===0||this._buf[0]!==sa)throw new Error("Invalid key")}toString(e="utf8"){return Q(this._buf,e)}uint8Array(){return this._buf}get[Symbol.toStringTag](){return`Key(${this.toString()})`}static withNamespaces(e){return new $e(e.join(Or))}static random(){return new $e(ra().replace(/-/g,""))}static asKey(e){return e instanceof Uint8Array||typeof e=="string"?new $e(e):typeof e.uint8Array=="function"?new $e(e.uint8Array()):null}clean(){if((this._buf==null||this._buf.byteLength===0)&&(this._buf=Qd),this._buf[0]!==sa){let e=new Uint8Array(this._buf.byteLength+1);e.fill(sa,0,1),e.set(this._buf,1),this._buf=e}for(;this._buf.byteLength>1&&this._buf[this._buf.byteLength-1]===sa;)this._buf=this._buf.subarray(0,-1)}less(e){let r=this.list(),n=e.list();for(let i=0;i<r.length;i++){if(n.length<i+1)return!1;let s=r[i],o=n[i];if(s<o)return!0;if(s>o)return!1}return r.length<n.length}reverse(){return $e.withNamespaces(this.list().slice().reverse())}namespaces(){return this.list()}baseNamespace(){let e=this.namespaces();return e[e.length-1]}list(){return this.toString().split(Or).slice(1)}type(){return Hx(this.baseNamespace())}name(){return zx(this.baseNamespace())}instance(e){return new $e(this.toString()+":"+e)}path(){let e=this.parent().toString();return e.endsWith(Or)||(e+=Or),e+=this.type(),new $e(e)}parent(){let e=this.list();return e.length===1?new $e(Or):new $e(e.slice(0,-1).join(Or))}child(e){return this.toString()===Or?e:e.toString()===Or?this:new $e(this.toString()+e.toString(),!1)}isAncestorOf(e){return e.toString()===this.toString()?!1:e.toString().startsWith(this.toString())}isDecendantOf(e){return e.toString()===this.toString()?!1:this.toString().startsWith(e.toString())}isTopLevel(){return this.list().length===1}concat(...e){return $e.withNamespaces([...this.namespaces(),...$x(e.map(r=>r.namespaces()))])}};function Hx(t){let e=t.split(":");return e.length<2?"":e.slice(0,-1).join(":")}function zx(t){let e=t.split(":");return e[e.length-1]}function $x(t){return[].concat(...t)}var Zd=C(G(),1);function Jd(t){return t=t||new Error("Not Found"),(0,Zd.default)(t,"ERR_NOT_FOUND")}var oa=class extends ta{constructor(){super(),this.data={}}open(){return Promise.resolve()}close(){return Promise.resolve()}async put(e,r){this.data[e.toString()]=r}async get(e){if(!await this.has(e))throw Jd();return this.data[e.toString()]}async has(e){return this.data[e.toString()]!==void 0}async delete(e){delete this.data[e.toString()]}async*_all(){yield*Object.entries(this.data).map(([e,r])=>({key:new $e(e),value:r}))}async*_allKeys(){yield*Object.entries(this.data).map(([e])=>new $e(e))}};var Os=C(G(),1);var ne;(function(t){t.NOT_STARTED_YET="The libp2p node is not started yet",t.DHT_DISABLED="DHT is not available",t.PUBSUB_DISABLED="PubSub is not available",t.CONN_ENCRYPTION_REQUIRED="At least one connection encryption module is required",t.ERR_TRANSPORTS_REQUIRED="At least one transport module is required",t.ERR_PROTECTOR_REQUIRED="Private network is enforced, but no protector was provided",t.NOT_FOUND="Not found"})(ne||(ne={}));var b;(function(t){t.DHT_DISABLED="ERR_DHT_DISABLED",t.ERR_PUBSUB_DISABLED="ERR_PUBSUB_DISABLED",t.PUBSUB_NOT_STARTED="ERR_PUBSUB_NOT_STARTED",t.DHT_NOT_STARTED="ERR_DHT_NOT_STARTED",t.CONN_ENCRYPTION_REQUIRED="ERR_CONN_ENCRYPTION_REQUIRED",t.ERR_TRANSPORTS_REQUIRED="ERR_TRANSPORTS_REQUIRED",t.ERR_PROTECTOR_REQUIRED="ERR_PROTECTOR_REQUIRED",t.ERR_PEER_DIAL_INTERCEPTED="ERR_PEER_DIAL_INTERCEPTED",t.ERR_CONNECTION_INTERCEPTED="ERR_CONNECTION_INTERCEPTED",t.ERR_INVALID_PROTOCOLS_FOR_STREAM="ERR_INVALID_PROTOCOLS_FOR_STREAM",t.ERR_CONNECTION_ENDED="ERR_CONNECTION_ENDED",t.ERR_CONNECTION_FAILED="ERR_CONNECTION_FAILED",t.ERR_NODE_NOT_STARTED="ERR_NODE_NOT_STARTED",t.ERR_ALREADY_ABORTED="ERR_ALREADY_ABORTED",t.ERR_TOO_MANY_ADDRESSES="ERR_TOO_MANY_ADDRESSES",t.ERR_NO_VALID_ADDRESSES="ERR_NO_VALID_ADDRESSES",t.ERR_RELAYED_DIAL="ERR_RELAYED_DIAL",t.ERR_DIALED_SELF="ERR_DIALED_SELF",t.ERR_DISCOVERED_SELF="ERR_DISCOVERED_SELF",t.ERR_DUPLICATE_TRANSPORT="ERR_DUPLICATE_TRANSPORT",t.ERR_ENCRYPTION_FAILED="ERR_ENCRYPTION_FAILED",t.ERR_HOP_REQUEST_FAILED="ERR_HOP_REQUEST_FAILED",t.ERR_INVALID_KEY="ERR_INVALID_KEY",t.ERR_INVALID_MESSAGE="ERR_INVALID_MESSAGE",t.ERR_INVALID_PARAMETERS="ERR_INVALID_PARAMETERS",t.ERR_INVALID_PEER="ERR_INVALID_PEER",t.ERR_MUXER_UNAVAILABLE="ERR_MUXER_UNAVAILABLE",t.ERR_NOT_FOUND="ERR_NOT_FOUND",t.ERR_TIMEOUT="ERR_TIMEOUT",t.ERR_TRANSPORT_UNAVAILABLE="ERR_TRANSPORT_UNAVAILABLE",t.ERR_TRANSPORT_DIAL_FAILED="ERR_TRANSPORT_DIAL_FAILED",t.ERR_UNSUPPORTED_PROTOCOL="ERR_UNSUPPORTED_PROTOCOL",t.ERR_PROTOCOL_HANDLER_ALREADY_REGISTERED="ERR_PROTOCOL_HANDLER_ALREADY_REGISTERED",t.ERR_INVALID_MULTIADDR="ERR_INVALID_MULTIADDR",t.ERR_SIGNATURE_NOT_VALID="ERR_SIGNATURE_NOT_VALID",t.ERR_FIND_SELF="ERR_FIND_SELF",t.ERR_NO_ROUTERS_AVAILABLE="ERR_NO_ROUTERS_AVAILABLE",t.ERR_CONNECTION_NOT_MULTIPLEXED="ERR_CONNECTION_NOT_MULTIPLEXED",t.ERR_NO_DIAL_TOKENS="ERR_NO_DIAL_TOKENS",t.ERR_KEYCHAIN_REQUIRED="ERR_KEYCHAIN_REQUIRED",t.ERR_INVALID_CMS="ERR_INVALID_CMS",t.ERR_MISSING_KEYS="ERR_MISSING_KEYS",t.ERR_NO_KEY="ERR_NO_KEY",t.ERR_INVALID_KEY_NAME="ERR_INVALID_KEY_NAME",t.ERR_INVALID_KEY_TYPE="ERR_INVALID_KEY_TYPE",t.ERR_KEY_ALREADY_EXISTS="ERR_KEY_ALREADY_EXISTS",t.ERR_INVALID_KEY_SIZE="ERR_INVALID_KEY_SIZE",t.ERR_KEY_NOT_FOUND="ERR_KEY_NOT_FOUND",t.ERR_OLD_KEY_NAME_INVALID="ERR_OLD_KEY_NAME_INVALID",t.ERR_NEW_KEY_NAME_INVALID="ERR_NEW_KEY_NAME_INVALID",t.ERR_PASSWORD_REQUIRED="ERR_PASSWORD_REQUIRED",t.ERR_PEM_REQUIRED="ERR_PEM_REQUIRED",t.ERR_CANNOT_READ_KEY="ERR_CANNOT_READ_KEY",t.ERR_MISSING_PRIVATE_KEY="ERR_MISSING_PRIVATE_KEY",t.ERR_MISSING_PUBLIC_KEY="ERR_MISSING_PUBLIC_KEY",t.ERR_INVALID_OLD_PASS_TYPE="ERR_INVALID_OLD_PASS_TYPE",t.ERR_INVALID_NEW_PASS_TYPE="ERR_INVALID_NEW_PASS_TYPE",t.ERR_INVALID_PASS_LENGTH="ERR_INVALID_PASS_LENGTH",t.ERR_NOT_IMPLEMENTED="ERR_NOT_IMPLEMENTED",t.ERR_WRONG_PING_ACK="ERR_WRONG_PING_ACK",t.ERR_INVALID_RECORD="ERR_INVALID_RECORD",t.ERR_ALREADY_SUCCEEDED="ERR_ALREADY_SUCCEEDED",t.ERR_NO_HANDLER_FOR_PROTOCOL="ERR_NO_HANDLER_FOR_PROTOCOL",t.ERR_TOO_MANY_OUTBOUND_PROTOCOL_STREAMS="ERR_TOO_MANY_OUTBOUND_PROTOCOL_STREAMS",t.ERR_TOO_MANY_INBOUND_PROTOCOL_STREAMS="ERR_TOO_MANY_INBOUND_PROTOCOL_STREAMS",t.ERR_CONNECTION_DENIED="ERR_CONNECTION_DENIED"})(b||(b={}));var ep=C(G(),1);async function*kr(t,e){for await(let r of t)await e(r)&&(yield r)}async function*Ls(t,e){for await(let r of t)yield e(r)}async function*Ps(t,e){yield*Ls(t,async r=>(await e.addressBook.add(r.id,r.multiaddrs),r))}function aa(t){let e=new Set;return kr(t,r=>e.has(r.id.toString())?!1:(e.add(r.id.toString()),!0))}async function*ca(t,e=1){let r=0;for await(let n of t)r++,yield n;if(r<e)throw(0,ep.default)(new Error("not found"),"NOT_FOUND")}var vp=C(Ur(),1);var la=class{constructor(e){if(!(e>0)||e-1&e)throw new Error("Max size for a FixedFIFO should be a power of two");this.buffer=new Array(e),this.mask=e-1,this.top=0,this.btm=0,this.next=null}push(e){return this.buffer[this.top]!==void 0?!1:(this.buffer[this.top]=e,this.top=this.top+1&this.mask,!0)}shift(){let e=this.buffer[this.btm];if(e!==void 0)return this.buffer[this.btm]=void 0,this.btm=this.btm+1&this.mask,e}isEmpty(){return this.buffer[this.btm]===void 0}},Bi=class{constructor(e={}){this.hwm=e.splitLimit??16,this.head=new la(this.hwm),this.tail=this.head,this.size=0}calculateSize(e){return e?.byteLength!=null?e.byteLength:1}push(e){if(e?.value!=null&&(this.size+=this.calculateSize(e.value)),!this.head.push(e)){let r=this.head;this.head=r.next=new la(2*this.head.buffer.length),this.head.push(e)}}shift(){let e=this.tail.shift();if(e===void 0&&this.tail.next!=null){let r=this.tail.next;this.tail.next=null,this.tail=r,e=this.tail.shift()}return e?.value!=null&&(this.size-=this.calculateSize(e.value)),e}isEmpty(){return this.head.isEmpty()}};function Wn(t={}){return Xx(r=>{let n=r.shift();if(n==null)return{done:!0};if(n.error!=null)throw n.error;return{done:n.done===!0,value:n.value}},t)}function Xx(t,e){e=e??{};let r=e.onEnd,n=new Bi,i,s,o,a=async()=>n.isEmpty()?o?{done:!0}:await new Promise((y,g)=>{s=E=>{s=null,n.push(E);try{y(t(n))}catch(x){g(x)}return i}}):t(n),c=y=>s!=null?s(y):(n.push(y),i),u=y=>(n=new Bi,s!=null?s({error:y}):(n.push({error:y}),i)),l=y=>{if(o)return i;if(e?.objectMode!==!0&&y?.byteLength==null)throw new Error("objectMode was not true but tried to push non-Uint8Array value");return c({done:!1,value:y})},f=y=>o?i:(o=!0,y!=null?u(y):c({done:!0})),h=()=>(n=new Bi,f(),{done:!0}),d=y=>(f(y),{done:!0});if(i={[Symbol.asyncIterator](){return this},next:a,return:h,throw:d,push:l,end:f,get readableLength(){return n.size}},r==null)return i;let p=i;return i={[Symbol.asyncIterator](){return this},next(){return p.next()},throw(y){return p.throw(y),r!=null&&(r(y),r=void 0),{done:!0}},return(){return p.return(),r!=null&&(r(),r=void 0),{done:!0}},push:l,end(y){return p.end(y),r!=null&&(r(y),r=void 0),i},get readableLength(){return p.readableLength}},i}async function*Mr(...t){let e=Wn({objectMode:!0});Promise.resolve().then(async()=>{try{await Promise.all(t.map(async r=>{for await(let n of r)e.push(n)})),e.end()}catch(r){e.end(r)}}),yield*e}var jx=(...t)=>{let e;for(;t.length>0;)e=t.shift()(e);return e},op=t=>t!=null&&(typeof t[Symbol.asyncIterator]=="function"||typeof t[Symbol.iterator]=="function"||typeof t.next=="function"),rl=t=>t!=null&&typeof t.sink=="function"&&op(t.source),Zx=t=>e=>{let r=t.sink(e);if(r.then!=null){let n=Wn({objectMode:!0});return r.then(()=>{n.end()},s=>{n.end(s)}),Mr(n,async function*(){yield*t.source,n.end()}())}return t.source};function Ce(t,...e){if(rl(t)){let n=t;t=()=>n.source}else if(op(t)){let n=t;t=()=>n}let r=[t,...e];if(r.length>1&&rl(r[r.length-1])&&(r[r.length-1]=r[r.length-1].sink),r.length>2)for(let n=1;n<r.length-1;n++)rl(r[n])&&(r[n]=Zx(r[n]));return jx(...r)}async function Rt(t){for await(let e of t)return e}async function dn(t){for await(let e of t);}var pa=C(nl(),1),wp=C(fr(),1),Ep=M("libp2p:peer-routing"),da=class{constructor(e,r){this.components=e,this.routers=r.routers??[],this.refreshManagerInit=r.refreshManager??{},this.started=!1,this._findClosestPeersTask=this._findClosestPeersTask.bind(this)}isStarted(){return this.started}async start(){this.started||this.routers.length===0||this.timeoutId!=null||this.refreshManagerInit.enabled===!1||(this.timeoutId=(0,pa.setDelayedInterval)(this._findClosestPeersTask,this.refreshManagerInit.interval,this.refreshManagerInit.bootDelay),this.started=!0)}async _findClosestPeersTask(){if(this.abortController==null)try{this.abortController=new vp.TimeoutController(this.refreshManagerInit.timeout??1e4);try{(0,wp.setMaxListeners)?.(1/0,this.abortController.signal)}catch{}await dn(this.getClosestPeers(this.components.peerId.toBytes(),{signal:this.abortController.signal}))}catch(e){Ep.error(e)}finally{this.abortController?.clear(),this.abortController=void 0}}async stop(){(0,pa.clearDelayedInterval)(this.timeoutId),this.abortController?.abort(),this.started=!1}async findPeer(e,r){if(this.routers.length===0)throw(0,Os.default)(new Error("No peer routers available"),b.ERR_NO_ROUTERS_AVAILABLE);if(e.toString()===this.components.peerId.toString())throw(0,Os.default)(new Error("Should not try to find self"),b.ERR_FIND_SELF);let n=await Ce(Mr(...this.routers.map(i=>async function*(){try{yield await i.findPeer(e,r)}catch(s){Ep.error(s)}}())),i=>kr(i,Boolean),i=>Ps(i,this.components.peerStore),async i=>await Rt(i));if(n!=null)return n;throw(0,Os.default)(new Error(ne.NOT_FOUND),b.ERR_NOT_FOUND)}async*getClosestPeers(e,r){if(this.routers.length===0)throw(0,Os.default)(new Error("No peer routers available"),b.ERR_NO_ROUTERS_AVAILABLE);yield*Ce(Mr(...this.routers.map(n=>n.getClosestPeers(e,r))),n=>Ps(n,this.components.peerStore),n=>aa(n),n=>ca(n))}};var pn=C(G(),1);var ma=class{constructor(e,r){this.routers=r.routers??[],this.started=!1,this.components=e}isStarted(){return this.started}async start(){this.started=!0}async stop(){this.started=!1}async*findProviders(e,r={}){if(this.routers.length===0)throw(0,pn.default)(new Error("No content this.routers available"),b.ERR_NO_ROUTERS_AVAILABLE);yield*Ce(Mr(...this.routers.map(n=>n.findProviders(e,r))),n=>Ps(n,this.components.peerStore),n=>aa(n),n=>ca(n))}async provide(e,r={}){if(this.routers.length===0)throw(0,pn.default)(new Error("No content routers available"),b.ERR_NO_ROUTERS_AVAILABLE);await Promise.all(this.routers.map(async n=>await n.provide(e,r)))}async put(e,r,n){if(!this.isStarted())throw(0,pn.default)(new Error(ne.NOT_STARTED_YET),b.DHT_NOT_STARTED);let i=this.components.dht;i!=null&&await dn(i.put(e,r,n))}async get(e,r){if(!this.isStarted())throw(0,pn.default)(new Error(ne.NOT_STARTED_YET),b.DHT_NOT_STARTED);let n=this.components.dht;if(n!=null){for await(let i of n.get(e,r))if(i.name==="VALUE")return i.value}throw(0,pn.default)(new Error(ne.NOT_FOUND),b.ERR_NOT_FOUND)}async*getMany(e,r,n){if(!this.isStarted())throw(0,pn.default)(new Error(ne.NOT_STARTED_YET),b.DHT_NOT_STARTED);if(r==null||r===0)return;let i=0,s=this.components.dht;if(s!=null){for await(let o of s.get(e,n))if(o.name==="VALUE"&&(yield{from:o.from,val:o.value},i++,i===r))break}if(i===0)throw(0,pn.default)(new Error(ne.NOT_FOUND),b.ERR_NOT_FOUND)}};function _e(t,e){if(t===e)return!0;if(t.byteLength!==e.byteLength)return!1;for(let r=0;r<t.byteLength;r++)if(t[r]!==e[r])return!1;return!0}var bp=C(G(),1);var sl=Symbol.for("@libp2p/peer-id");function Qn(t){return t!=null&&Boolean(t[sl])}var ub=Symbol.for("nodejs.util.inspect.custom"),xp=Object.values(hn).map(t=>t.decoder).reduce((t,e)=>t.or(e),hn.identity.decoder),Sp=114,ol=36,al=37,ks=class{constructor(e){this.type=e.type,this.multihash=e.multihash,this.privateKey=e.privateKey,Object.defineProperty(this,"string",{enumerable:!1,writable:!0})}get[Symbol.toStringTag](){return`PeerId(${this.toString()})`}get[sl](){return!0}toString(){return this.string==null&&(this.string=We.encode(this.multihash.bytes).slice(1)),this.string}toCID(){return ve.createV1(Sp,this.multihash)}toBytes(){return this.multihash.bytes}toJSON(){return this.toString()}equals(e){if(e instanceof Uint8Array)return _e(this.multihash.bytes,e);if(typeof e=="string")return me(e).equals(this);if(e?.multihash?.bytes!=null)return _e(this.multihash.bytes,e.multihash.bytes);throw new Error("not valid Id")}[ub](){return`PeerId(${this.toString()})`}},Xn=class extends ks{constructor(e){super({...e,type:"RSA"}),this.type="RSA",this.publicKey=e.publicKey}},jn=class extends ks{constructor(e){super({...e,type:"Ed25519"}),this.type="Ed25519",this.publicKey=e.multihash.digest}},Zn=class extends ks{constructor(e){super({...e,type:"secp256k1"}),this.type="secp256k1",this.publicKey=e.multihash.digest}};function Qe(t){if(t.type==="RSA")return new Xn(t);if(t.type==="Ed25519")return new jn(t);if(t.type==="secp256k1")return new Zn(t);throw(0,bp.default)(new Error("Not a PeerId"),"ERR_INVALID_PARAMETERS")}function me(t,e){if(e=e??xp,t.charAt(0)==="1"||t.charAt(0)==="Q"){let r=$n(We.decode(`z${t}`));return t.startsWith("12D")?new jn({multihash:r}):t.startsWith("16U")?new Zn({multihash:r}):new Xn({multihash:r})}return mn(xp.decode(t))}function mn(t){try{let e=$n(t);if(e.code===fn.code){if(e.digest.length===ol)return new jn({multihash:e});if(e.digest.length===al)return new Zn({multihash:e})}if(e.code===ot.code)return new Xn({multihash:e})}catch{return lb(ve.decode(t))}throw new Error("Supplied PeerID CID is invalid")}function lb(t){if(t==null||t.multihash==null||t.version==null||t.version===1&&t.code!==Sp)throw new Error("Supplied PeerID CID is invalid");let e=t.multihash;if(e.code===ot.code)return new Xn({multihash:t.multihash});if(e.code===fn.code){if(e.digest.length===ol)return new jn({multihash:t.multihash});if(e.digest.length===al)return new Zn({multihash:t.multihash})}throw new Error("Supplied PeerID CID is invalid")}async function Ui(t,e){return t.length===ol?new jn({multihash:lr(fn.code,t),privateKey:e}):t.length===al?new Zn({multihash:lr(fn.code,t),privateKey:e}):new Xn({multihash:await ot.digest(t),publicKey:t,privateKey:e})}var ya=class{index=0;input="";new(e){return this.index=0,this.input=e,this}readAtomically(e){let r=this.index,n=e();return n===void 0&&(this.index=r),n}parseWith(e){let r=e();if(this.index===this.input.length)return r}peekChar(){if(!(this.index>=this.input.length))return this.input[this.index]}readChar(){if(!(this.index>=this.input.length))return this.input[this.index++]}readGivenChar(e){return this.readAtomically(()=>{let r=this.readChar();if(r===e)return r})}readSeparator(e,r,n){return this.readAtomically(()=>{if(!(r>0&&this.readGivenChar(e)===void 0))return n()})}readNumber(e,r,n,i){return this.readAtomically(()=>{let s=0,o=0,a=this.peekChar();if(a===void 0)return;let c=a==="0",u=2**(8*i)-1;for(;;){let l=this.readAtomically(()=>{let f=this.readChar();if(f===void 0)return;let h=Number.parseInt(f,e);if(!Number.isNaN(h))return h});if(l===void 0)break;if(s*=e,s+=l,s>u||(o+=1,r!==void 0&&o>r))return}if(o!==0)return!n&&c&&o>1?void 0:s})}readIPv4Addr(){return this.readAtomically(()=>{let e=new Uint8Array(4);for(let r=0;r<e.length;r++){let n=this.readSeparator(".",r,()=>this.readNumber(10,3,!1,1));if(n===void 0)return;e[r]=n}return e})}readIPv6Addr(){let e=r=>{for(let n=0;n<r.length/2;n++){let i=n*2;if(n<r.length-3){let o=this.readSeparator(":",n,()=>this.readIPv4Addr());if(o!==void 0)return r[i]=o[0],r[i+1]=o[1],r[i+2]=o[2],r[i+3]=o[3],[i+4,!0]}let s=this.readSeparator(":",n,()=>this.readNumber(16,4,!0,2));if(s===void 0)return[i,!1];r[i]=s>>8,r[i+1]=s&255}return[r.length,!1]};return this.readAtomically(()=>{let r=new Uint8Array(16),[n,i]=e(r);if(n===16)return r;if(i||this.readGivenChar(":")===void 0||this.readGivenChar(":")===void 0)return;let s=new Uint8Array(14),o=16-(n+2),[a]=e(s.subarray(0,o));return r.set(s.subarray(0,a),16-a),r})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var _p=45,fb=15,Mi=new ya;function Ap(t){if(!(t.length>fb))return Mi.new(t).parseWith(()=>Mi.readIPv4Addr())}function Cp(t){if(!(t.length>_p))return Mi.new(t).parseWith(()=>Mi.readIPv6Addr())}function Ip(t){if(!(t.length>_p))return Mi.new(t).parseWith(()=>Mi.readIPAddr())}function Tp(t){return Boolean(Ap(t))}function Rp(t){return Boolean(Cp(t))}function Fi(t){return Boolean(Ip(t))}var Np=Tp,hb=Rp,cl=function(t){let e=0;if(t=t.toString().trim(),Np(t)){let r=new Uint8Array(e+4);return t.split(/\./g).forEach(n=>{r[e++]=parseInt(n,10)&255}),r}if(hb(t)){let r=t.split(":",8),n;for(n=0;n<r.length;n++){let s=Np(r[n]),o;s&&(o=cl(r[n]),r[n]=Q(o.slice(0,2),"base16")),o!=null&&++n<8&&r.splice(n,0,Q(o.slice(2,4),"base16"))}if(r[0]==="")for(;r.length<8;)r.unshift("0");else if(r[r.length-1]==="")for(;r.length<8;)r.push("0");else if(r.length<8){for(n=0;n<r.length&&r[n]!=="";n++);let s=[n,1];for(n=9-r.length;n>0;n--)s.push("0");r.splice.apply(r,s)}let i=new Uint8Array(e+16);for(n=0;n<r.length;n++){let s=parseInt(r[n],16);i[e++]=s>>8&255,i[e++]=s&255}return i}throw new Error("invalid ip address")},Dp=function(t,e=0,r){e=~~e,r=r??t.length-e;let n=new DataView(t.buffer);if(r===4){let i=[];for(let s=0;s<r;s++)i.push(t[e+s]);return i.join(".")}if(r===16){let i=[];for(let s=0;s<r;s+=2)i.push(n.getUint16(e+s).toString(16));return i.join(":").replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}return""};var Us={},ul={},pb=[[4,32,"ip4"],[6,16,"tcp"],[33,16,"dccp"],[41,128,"ip6"],[42,-1,"ip6zone"],[53,-1,"dns",!0],[54,-1,"dns4",!0],[55,-1,"dns6",!0],[56,-1,"dnsaddr",!0],[132,16,"sctp"],[273,16,"udp"],[275,0,"p2p-webrtc-star"],[276,0,"p2p-webrtc-direct"],[277,0,"p2p-stardust"],[280,0,"webrtc"],[290,0,"p2p-circuit"],[301,0,"udt"],[302,0,"utp"],[400,-1,"unix",!1,!0],[421,-1,"ipfs"],[421,-1,"p2p"],[443,0,"https"],[444,96,"onion"],[445,296,"onion3"],[446,-1,"garlic64"],[460,0,"quic"],[461,0,"quic-v1"],[465,0,"webtransport"],[466,-1,"certhash"],[477,0,"ws"],[478,0,"wss"],[479,0,"p2p-websocket-star"],[480,0,"http"],[777,-1,"memory"]];pb.forEach(t=>{let e=mb(...t);ul[e.code]=e,Us[e.name]=e});function mb(t,e,r,n,i){return{code:t,size:e,name:r,resolvable:Boolean(n),path:Boolean(i)}}function Ie(t){if(typeof t=="number"){if(ul[t]!=null)return ul[t];throw new Error(`no protocol with code: ${t}`)}else if(typeof t=="string"){if(Us[t]!=null)return Us[t];throw new Error(`no protocol with name: ${t}`)}throw new Error(`invalid protocol id type: ${typeof t}`)}var hr=C(ga(),1);function Xe(t,e){e==null&&(e=t.reduce((i,s)=>i+s.length,0));let r=Br(e),n=0;for(let i of t)r.set(i,n),n+=i.length;return Yn(r)}function Hp(t,e){switch(Ie(t).code){case 4:case 41:return Nb(e);case 6:case 273:case 33:case 132:return $p(e).toString();case 53:case 54:case 55:case 56:case 400:case 777:return Lb(e);case 421:return kb(e);case 444:return qp(e);case 445:return qp(e);case 466:return Ob(e);default:return Q(e,"base16")}}function zp(t,e){switch(Ie(t).code){case 4:return Vp(e);case 41:return Vp(e);case 6:case 273:case 33:case 132:return dl(parseInt(e,10));case 53:case 54:case 55:case 56:case 400:case 777:return Db(e);case 421:return Pb(e);case 444:return Ub(e);case 445:return Mb(e);case 466:return Bb(e);default:return q(e,"base16")}}var hl=Object.values(hn).map(t=>t.decoder),Rb=function(){let t=hl[0].or(hl[1]);return hl.slice(2).forEach(e=>t=t.or(e)),t}();function Vp(t){if(!Fi(t))throw new Error("invalid ip address");return cl(t)}function Nb(t){let e=Dp(t,0,t.length);if(e==null)throw new Error("ipBuff is required");if(!Fi(e))throw new Error("invalid ip address");return e}function dl(t){let e=new ArrayBuffer(2);return new DataView(e).setUint16(0,t),new Uint8Array(e)}function $p(t){return new DataView(t.buffer).getUint16(t.byteOffset)}function Db(t){let e=q(t),r=Uint8Array.from(hr.default.encode(e.length));return Xe([r,e],r.length+e.length)}function Lb(t){let e=hr.default.decode(t);if(t=t.slice(hr.default.decode.bytes),t.length!==e)throw new Error("inconsistent lengths");return Q(t)}function Pb(t){let e;t[0]==="Q"||t[0]==="1"?e=$n(We.decode(`z${t}`)).bytes:e=ve.parse(t).multihash.bytes;let r=Uint8Array.from(hr.default.encode(e.length));return Xe([r,e],r.length+e.length)}function Bb(t){let e=Rb.decode(t),r=Uint8Array.from(hr.default.encode(e.length));return Xe([r,e],r.length+e.length)}function Ob(t){let e=hr.default.decode(t),r=t.slice(hr.default.decode.bytes);if(r.length!==e)throw new Error("inconsistent lengths");return"u"+Q(r,"base64url")}function kb(t){let e=hr.default.decode(t),r=t.slice(hr.default.decode.bytes);if(r.length!==e)throw new Error("inconsistent lengths");return Q(r,"base58btc")}function Ub(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=Tt.decode("b"+e[0]),n=parseInt(e[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let i=dl(n);return Xe([r,i],r.length+i.length)}function Mb(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=Tt.decode(`b${e[0]}`),n=parseInt(e[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let i=dl(n);return Xe([r,i],r.length+i.length)}function qp(t){let e=t.slice(0,t.length-2),r=t.slice(t.length-2),n=Q(e,"base32"),i=$p(r);return`${n}:${i}`}var Ki=C(ga(),1);function Fb(t){let e=[],r=t.split("/").slice(1);if(r.length===1&&r[0]==="")return[];for(let n=0;n<r.length;n++){let i=r[n],s=Ie(i);if(s.size===0){e.push([i]);continue}if(n++,n>=r.length)throw Yp("invalid address: "+t);if(s.path===!0){e.push([i,El(r.slice(n).join("/"))]);break}e.push([i,r[n]])}return e}function Kb(t){let e=[];return t.map(r=>{let n=wa(r);return e.push(n.name),r.length>1&&r[1]!=null&&e.push(r[1]),null}),El(e.join("/"))}function Vb(t){return t.map(e=>{Array.isArray(e)||(e=[e]);let r=wa(e);return e.length>1?[r.code,zp(r.code,e[1])]:[r.code]})}function pl(t){return t.map(e=>{let r=wa(e);return e[1]!=null?[r.code,Hp(r.code,e[1])]:[r.code]})}function ml(t){return va(Xe(t.map(e=>{let r=wa(e),n=Uint8Array.from(Ki.default.encode(r.code));return e.length>1&&e[1]!=null&&(n=Xe([n,e[1]])),n})))}function yl(t,e){return t.size>0?t.size/8:t.size===0?0:Ki.default.decode(e)+(Ki.default.decode.bytes??0)}function Ea(t){let e=[],r=0;for(;r<t.length;){let n=Ki.default.decode(t,r),i=Ki.default.decode.bytes??0,s=Ie(n),o=yl(s,t.slice(r+i));if(o===0){e.push([n]),r+=i;continue}let a=t.slice(r+i,r+i+o);if(r+=o+i,r>t.length)throw Yp("Invalid address Uint8Array: "+Q(t,"base16"));e.push([n,a])}return e}function gl(t){let e=Ea(t),r=pl(e);return Kb(r)}function qb(t){t=El(t);let e=Fb(t),r=Vb(e);return ml(r)}function Gp(t){return qb(t)}function va(t){let e=Hb(t);if(e!=null)throw e;return Uint8Array.from(t)}function Hb(t){try{Ea(t)}catch(e){return e}}function El(t){return"/"+t.trim().split("/").filter(e=>e).join("/")}function Yp(t){return new Error("Error parsing address: "+t)}function wa(t){return Ie(t[0])}var wl=C(ga(),1);var Xp=C(G(),1);var Vi=function(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)},vl=function(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r},Ms,Fs,Ks,Wp,$b=Symbol.for("nodejs.util.inspect.custom"),Qp=[Ie("dns").code,Ie("dns4").code,Ie("dns6").code,Ie("dnsaddr").code],Gb=[Ie("p2p").code,Ie("ipfs").code],xl=new Map,jp=Symbol.for("@multiformats/js-multiaddr/multiaddr");function Zp(t,e){if(t==null)throw new Error("requires node address object");if(e==null)throw new Error("requires transport protocol");let r;switch(t.family){case 4:r="ip4";break;case 6:r="ip6";break;default:throw Error("Invalid addr family, should be 4 or 6.")}return new dr("/"+[r,t.address,e,t.port].join("/"))}function Fr(t){return Boolean(t?.[jp])}var dr=class{constructor(e){if(Ms.set(this,void 0),Fs.set(this,void 0),Ks.set(this,void 0),this[Wp]=!0,e==null&&(e=""),e instanceof Uint8Array)this.bytes=va(e);else if(typeof e=="string"){if(e.length>0&&e.charAt(0)!=="/")throw new Error(`multiaddr "${e}" must start with a "/"`);this.bytes=Gp(e)}else if(Fr(e))this.bytes=va(e.bytes);else throw new Error("addr must be a string, Buffer, or another Multiaddr")}toString(){return Vi(this,Ms,"f")==null&&vl(this,Ms,gl(this.bytes),"f"),Vi(this,Ms,"f")}toJSON(){return this.toString()}toOptions(){let e=this.protoCodes(),r=this.toString().split("/").slice(1),n,i;if(r.length>2)Qp.includes(e[0])&&Gb.includes(e[1])?(n=Ie("tcp").name,i=443):(n=Ie(r[2]).name,i=parseInt(r[3]));else if(Qp.includes(e[0]))n=Ie("tcp").name,i=443;else throw new Error('multiaddr must have a valid format: "/{ip4, ip6, dns4, dns6, dnsaddr}/{address}/{tcp, udp}/{port}".');return{family:e[0]===41||e[0]===55?6:4,host:r[1],transport:n,port:i}}protos(){return this.protoCodes().map(e=>Object.assign({},Ie(e)))}protoCodes(){let e=[],r=this.bytes,n=0;for(;n<r.length;){let i=wl.default.decode(r,n),s=wl.default.decode.bytes??0,o=Ie(i),a=yl(o,r.slice(n+s));n+=a+s,e.push(i)}return e}protoNames(){return this.protos().map(e=>e.name)}tuples(){return Vi(this,Fs,"f")==null&&vl(this,Fs,Ea(this.bytes),"f"),Vi(this,Fs,"f")}stringTuples(){return Vi(this,Ks,"f")==null&&vl(this,Ks,pl(this.tuples()),"f"),Vi(this,Ks,"f")}encapsulate(e){return e=new dr(e),new dr(this.toString()+e.toString())}decapsulate(e){let r=e.toString(),n=this.toString(),i=n.lastIndexOf(r);if(i<0)throw new Error(`Address ${this.toString()} does not contain subaddress: ${e.toString()}`);return new dr(n.slice(0,i))}decapsulateCode(e){let r=this.tuples();for(let n=r.length-1;n>=0;n--)if(r[n][0]===e)return new dr(ml(r.slice(0,n)));return this}getPeerId(){try{let r=this.stringTuples().filter(n=>n[0]===Us.ipfs.code).pop();if(r?.[1]!=null){let n=r[1];return n[0]==="Q"||n[0]==="1"?Q(We.decode(`z${n}`),"base58btc"):Q(ve.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){let e=null;try{e=this.stringTuples().filter(r=>Ie(r[0]).path===!0)[0][1],e==null&&(e=null)}catch{e=null}return e}equals(e){return _e(this.bytes,e.bytes)}async resolve(e){let r=this.protos().find(s=>s.resolvable);if(r==null)return[this];let n=xl.get(r.name);if(n==null)throw(0,Xp.default)(new Error(`no available resolver for ${r.name}`),"ERR_NO_AVAILABLE_RESOLVER");return(await n(this,e)).map(s=>new dr(s))}nodeAddress(){let e=this.toOptions();if(e.transport!=="tcp"&&e.transport!=="udp")throw new Error(`multiaddr must have a valid format - no protocol with name: "${e.transport}". Must have a valid transport protocol: "{tcp, udp}"`);return{family:e.family,address:e.host,port:e.port}}isThinWaistAddress(e){let r=(e??this).protos();return!(r.length!==2||r[0].code!==4&&r[0].code!==41||r[1].code!==6&&r[1].code!==273)}[(Ms=new WeakMap,Fs=new WeakMap,Ks=new WeakMap,Wp=jp,$b)](){return`Multiaddr(${gl(this.bytes)})`}};function oe(t){return new dr(t)}var bl=C(G(),1);function Yb(t){let e=t.getPeerId();if(e==null)throw(0,bl.default)(new Error(`${t.toString()} does not have a valid peer type`),b.ERR_INVALID_MULTIADDR);try{return me(e)}catch{throw(0,bl.default)(new Error(`${t.toString()} is not a valid peer type`),b.ERR_INVALID_MULTIADDR)}}function Kr(t){if(Qn(t))return{id:t,multiaddrs:[],protocols:[]};let e;return Fr(t)&&(e=t,t=Yb(t)),{id:t,multiaddrs:e!=null?[e]:[],protocols:[]}}var Wb=t=>t,xa=class extends Ue{constructor(e,r){super();let{listen:n=[],announce:i=[]}=r;this.components=e,this.listen=n.map(s=>s.toString()),this.announce=new Set(i.map(s=>s.toString())),this.observed=new Set,this.announceFilter=r.announceFilter??Wb}getListenAddrs(){return Array.from(this.listen).map(e=>oe(e))}getAnnounceAddrs(){return Array.from(this.announce).map(e=>oe(e))}getObservedAddrs(){return Array.from(this.observed).map(e=>oe(e))}confirmObservedAddr(e){}removeObservedAddr(e){}addObservedAddr(e){let r=oe(e),n=r.getPeerId();n!=null&&me(n).equals(this.components.peerId)&&(r=r.decapsulate(oe(`/p2p/${this.components.peerId.toString()}`)));let i=r.toString();this.observed.has(i)||(this.observed.add(i),this.dispatchEvent(new X("change:addresses")))}getAddresses(){let e=this.getAnnounceAddrs().map(n=>n.toString());e.length===0&&(e=this.components.transportManager.getAddrs().map(n=>n.toString())),e=e.concat(this.getObservedAddrs().map(n=>n.toString()));let r=new Set(e);return this.announceFilter(Array.from(r).map(n=>oe(n))).map(n=>n.getPeerId()===this.components.peerId.toString()?n:n.encapsulate(`/p2p/${this.components.peerId.toString()}`))}};var Ra=C(G(),1);var a0=C(o0(),1),pr=a0.default;var c0=M("libp2p:connection-manager:latency-monitor:visibility-change-emitter"),_a=class extends Ue{constructor(){super(),this.hidden="hidden",this.visibilityChange="visibilityChange",globalThis.document!=null&&(this._initializeVisibilityVarNames(),this._addVisibilityChangeListener())}_initializeVisibilityVarNames(){let e="hidden",r="visibilitychange";typeof globalThis.document.hidden<"u"?(e="hidden",r="visibilitychange"):typeof globalThis.document.mozHidden<"u"?(e="mozHidden",r="mozvisibilitychange"):typeof globalThis.document.msHidden<"u"?(e="msHidden",r="msvisibilitychange"):typeof globalThis.document.webkitHidden<"u"&&(e="webkitHidden",r="webkitvisibilitychange"),this.hidden=e,this.visibilityChange=r}_addVisibilityChangeListener(){typeof globalThis.document.addEventListener>"u"||typeof document[this.hidden]>"u"?c0("Checking page visibility requires a browser that supports the Page Visibility API."):globalThis.document.addEventListener(this.visibilityChange,this._handleVisibilityChange.bind(this),!1)}isVisible(){if(!(this.hidden===void 0||document[this.hidden]===void 0))return document[this.hidden]==null}_handleVisibilityChange(){let e=globalThis.document[this.hidden]===!1;c0(e?"Page Visible":"Page Hidden"),this.dispatchEvent(new X("visibilityChange",{detail:e}))}};var Vr=M("libp2p:connection-manager:latency-monitor"),Aa=class extends Ue{constructor(e={}){super();let{latencyCheckIntervalMs:r,dataEmitIntervalMs:n,asyncTestFn:i,latencyRandomPercentage:s}=e;this.latencyCheckIntervalMs=r??500,this.latencyRandomPercentage=s??10,this.latencyCheckMultiply=2*(this.latencyRandomPercentage/100)*this.latencyCheckIntervalMs,this.latencyCheckSubtract=this.latencyCheckMultiply/2,this.dataEmitIntervalMs=n===null||n===0?void 0:n??5*1e3,Vr("latencyCheckIntervalMs: %s dataEmitIntervalMs: %s",this.latencyCheckIntervalMs,this.dataEmitIntervalMs),this.dataEmitIntervalMs!=null?Vr("Expecting ~%s events per summary",this.latencyCheckIntervalMs/this.dataEmitIntervalMs):Vr("Not emitting summaries"),this.asyncTestFn=i,globalThis.process?.hrtime!=null?(Vr("Using process.hrtime for timing"),this.now=globalThis.process.hrtime,this.getDeltaMS=o=>{let a=this.now(o);return a[0]*1e3+a[1]/1e6}):typeof window<"u"&&window.performance?.now!=null?(Vr("Using performance.now for timing"),this.now=window.performance.now.bind(window.performance),this.getDeltaMS=o=>Math.round(this.now()-o)):(Vr("Using Date.now for timing"),this.now=Date.now,this.getDeltaMS=o=>this.now()-o),this.latencyData=this.initLatencyData()}start(){e2()&&(this.visibilityChangeEmitter=new _a,this.visibilityChangeEmitter.addEventListener("visibilityChange",e=>{let{detail:r}=e;r?this._startTimers():(this._emitSummary(),this._stopTimers())})),this.visibilityChangeEmitter?.isVisible()===!0&&this._startTimers()}stop(){this._stopTimers()}_startTimers(){this.checkLatencyID==null&&(this.checkLatency(),this.dataEmitIntervalMs!=null&&(this.emitIntervalID=setInterval(()=>this._emitSummary(),this.dataEmitIntervalMs),typeof this.emitIntervalID.unref=="function"&&this.emitIntervalID.unref()))}_stopTimers(){this.checkLatencyID!=null&&(clearTimeout(this.checkLatencyID),this.checkLatencyID=void 0),this.emitIntervalID!=null&&(clearInterval(this.emitIntervalID),this.emitIntervalID=void 0)}_emitSummary(){let e=this.getSummary();e.events>0&&this.dispatchEvent(new X("data",{detail:e}))}getSummary(){let e={events:this.latencyData.events,minMs:this.latencyData.minMs,maxMs:this.latencyData.maxMs,avgMs:this.latencyData.events>0?this.latencyData.totalMs/this.latencyData.events:Number.POSITIVE_INFINITY,lengthMs:this.getDeltaMS(this.latencyData.startTime)};return this.latencyData=this.initLatencyData(),Vr.trace("Summary: %O",e),e}checkLatency(){let e=Math.random()*this.latencyCheckMultiply-this.latencyCheckSubtract,r={deltaOffset:Math.ceil(this.latencyCheckIntervalMs+e),startTime:this.now()},n=()=>{if(this.checkLatencyID==null)return;let i=this.getDeltaMS(r.startTime)-r.deltaOffset;this.checkLatency(),this.latencyData.events++,this.latencyData.minMs=Math.min(this.latencyData.minMs,i),this.latencyData.maxMs=Math.max(this.latencyData.maxMs,i),this.latencyData.totalMs+=i,Vr.trace("MS: %s Data: %O",i,this.latencyData)};Vr.trace("localData: %O",r),this.checkLatencyID=setTimeout(()=>{this.asyncTestFn!=null?(r.deltaOffset=0,r.startTime=this.now(),this.asyncTestFn(n)):(r.deltaOffset-=1,n())},r.deltaOffset),typeof this.checkLatencyID.unref=="function"&&this.checkLatencyID.unref()}initLatencyData(){return{startTime:this.now(),minMs:Number.POSITIVE_INFINITY,maxMs:Number.NEGATIVE_INFINITY,events:0,totalMs:0}}};function e2(){return typeof globalThis.window<"u"}var Na=C(fr(),1);var Ca="OPEN",_l="CLOSING",Ia="CLOSED";function qr(t,e){let r={[Symbol.iterator]:()=>r,next:()=>{let n=t.next(),i=n.value;return n.done===!0||i==null?{done:!0,value:void 0}:{done:!1,value:e(i)}}};return r}var Vs=class{constructor(e){if(this.map=new Map,e!=null)for(let[r,n]of e.entries())this.map.set(r.toString(),n)}[Symbol.iterator](){return this.entries()}clear(){this.map.clear()}delete(e){this.map.delete(e.toString())}entries(){return qr(this.map.entries(),e=>[me(e[0]),e[1]])}forEach(e){this.map.forEach((r,n)=>{e(r,me(n),this)})}get(e){return this.map.get(e.toString())}has(e){return this.map.has(e.toString())}set(e,r){this.map.set(e.toString(),r)}keys(){return qr(this.map.keys(),e=>me(e))}values(){return this.map.values()}get size(){return this.map.size}};var Hr=class{constructor(e){if(this.set=new Set,e!=null)for(let r of e)this.set.add(r.toString())}get size(){return this.set.size}[Symbol.iterator](){return this.values()}add(e){this.set.add(e.toString())}clear(){this.set.clear()}delete(e){this.set.delete(e.toString())}entries(){return qr(this.set.entries(),e=>{let r=me(e[0]);return[r,r]})}forEach(e){this.set.forEach(r=>{let n=me(r);e(n,n,this)})}has(e){return this.set.has(e.toString())}values(){return qr(this.set.values(),e=>me(e))}intersection(e){let r=new Hr;for(let n of e)this.has(n)&&r.add(n);return r}difference(e){let r=new Hr;for(let n of this)e.has(n)||r.add(n);return r}union(e){let r=new Hr;for(let n of e)r.add(n);for(let n of this)r.add(n);return r}};var zi=class{constructor(e){if(this.list=[],e!=null)for(let r of e)this.list.push(r.toString())}[Symbol.iterator](){return qr(this.list.entries(),e=>me(e[1]))}concat(e){let r=new zi(this);for(let n of e)r.push(n);return r}entries(){return qr(this.list.entries(),e=>[e[0],me(e[1])])}every(e){return this.list.every((r,n)=>e(me(r),n,this))}filter(e){let r=new zi;return this.list.forEach((n,i)=>{let s=me(n);e(s,i,this)&&r.push(s)}),r}find(e){let r=this.list.find((n,i)=>e(me(n),i,this));if(r!=null)return me(r)}findIndex(e){return this.list.findIndex((r,n)=>e(me(r),n,this))}forEach(e){this.list.forEach((r,n)=>{e(me(r),n,this)})}includes(e){return this.list.includes(e.toString())}indexOf(e){return this.list.indexOf(e.toString())}pop(){let e=this.list.pop();if(e!=null)return me(e)}push(...e){for(let r of e)this.list.push(r.toString())}shift(){let e=this.list.shift();if(e!=null)return me(e)}unshift(...e){let r=this.list.length;for(let n=e.length-1;n>-1;n--)r=this.list.unshift(e[n].toString());return r}get length(){return this.list.length}};var Ml=C(Ur(),1);var u0="keep-alive";var sm=C(im(),1);var et=M("libp2p:connection-manager"),U2={maxConnections:1/0,minConnections:0,maxEventLoopDelay:1/0,pollInterval:2e3,autoDialInterval:1e4,inboundConnectionThreshold:5,maxIncomingPendingConnections:10},M2=6e4,Da=class extends Ue{constructor(e,r){if(super(),this.opts=pr.call({ignoreUndefined:!0},U2,r),this.opts.maxConnections<this.opts.minConnections)throw(0,Ra.default)(new Error("Connection Manager maxConnections must be greater than minConnections"),b.ERR_INVALID_PARAMETERS);et("options: %o",this.opts),this.components=e,this.connections=new Map,this.started=!1,r.maxEventLoopDelay!=null&&r.maxEventLoopDelay>0&&r.maxEventLoopDelay!==1/0&&(this.latencyMonitor=new Aa({latencyCheckIntervalMs:r.pollInterval,dataEmitIntervalMs:r.pollInterval}));try{(0,Na.setMaxListeners)?.(1/0,this)}catch{}this.onConnect=this.onConnect.bind(this),this.onDisconnect=this.onDisconnect.bind(this),this.startupReconnectTimeout=r.startupReconnectTimeout??M2,this.dialTimeout=r.dialTimeout??3e4,this.allow=(r.allow??[]).map(n=>oe(n)),this.deny=(r.deny??[]).map(n=>oe(n)),this.inboundConnectionRateLimiter=new sm.RateLimiterMemory({points:this.opts.inboundConnectionThreshold,duration:1}),this.incomingPendingConnections=0}isStarted(){return this.started}async start(){this.components.metrics?.registerMetricGroup("libp2p_connection_manager_connections",{calculate:()=>{let e={inbound:0,outbound:0};for(let r of this.connections.values())for(let n of r)n.stat.direction==="inbound"?e.inbound++:e.outbound++;return e}}),this.components.metrics?.registerMetricGroup("libp2p_protocol_streams_total",{label:"protocol",calculate:()=>{let e={};for(let r of this.connections.values())for(let n of r)for(let i of n.streams){let s=`${i.stat.direction} ${i.stat.protocol??"unnegotiated"}`;e[s]=(e[s]??0)+1}return e}}),this.components.metrics?.registerMetricGroup("libp2p_connection_manager_protocol_streams_per_connection_90th_percentile",{label:"protocol",calculate:()=>{let e={};for(let n of this.connections.values())for(let i of n){let s={};for(let o of i.streams){let a=`${o.stat.direction} ${o.stat.protocol??"unnegotiated"}`;s[a]=(s[a]??0)+1}for(let[o,a]of Object.entries(s))e[o]=e[o]??[],e[o].push(a)}let r={};for(let[n,i]of Object.entries(e)){i=i.sort((o,a)=>o-a);let s=Math.floor(i.length*.9);r[n]=i[s]}return r}}),this.latencyMonitor?.start(),this._onLatencyMeasure=this._onLatencyMeasure.bind(this),this.latencyMonitor?.addEventListener("data",this._onLatencyMeasure),this.started=!0,et("started")}async afterStart(){this.components.upgrader.addEventListener("connection",this.onConnect),this.components.upgrader.addEventListener("connectionEnd",this.onDisconnect),Promise.resolve().then(async()=>{let e=[];for(let r of await this.components.peerStore.all())(await this.components.peerStore.getTags(r.id)).filter(s=>s.name===u0).length>0&&e.push(r.id);this.connectOnStartupController?.clear(),this.connectOnStartupController=new Ml.TimeoutController(this.startupReconnectTimeout);try{(0,Na.setMaxListeners)?.(1/0,this.connectOnStartupController.signal)}catch{}await Promise.all(e.map(async r=>{await this.openConnection(r,{signal:this.connectOnStartupController?.signal}).catch(n=>{et.error(n)})}))}).catch(e=>{et.error(e)}).finally(()=>{this.connectOnStartupController?.clear()})}async beforeStop(){this.connectOnStartupController?.abort(),this.components.upgrader.removeEventListener("connection",this.onConnect),this.components.upgrader.removeEventListener("connectionEnd",this.onDisconnect)}async stop(){this.latencyMonitor?.removeEventListener("data",this._onLatencyMeasure),this.latencyMonitor?.stop(),this.started=!1,await this._close(),et("stopped")}async _close(){let e=[];for(let r of this.connections.values())for(let n of r)e.push((async()=>{try{await n.close()}catch(i){et.error(i)}})());et("closing %d connections",e.length),await Promise.all(e),this.connections.clear()}onConnect(e){this._onConnect(e).catch(r=>{et.error(r)})}async _onConnect(e){let{detail:r}=e;if(!this.started){await r.close();return}let n=r.remotePeer,i=n.toString(),s=this.connections.get(i);s!=null?s.push(r):this.connections.set(i,[r]),n.publicKey!=null&&await this.components.peerStore.keyBook.set(n,n.publicKey);let o=this.getConnections().length,a=o-this.opts.maxConnections;await this._checkMaxLimit("maxConnections",o,a),this.dispatchEvent(new X("peer:connect",{detail:r}))}onDisconnect(e){let{detail:r}=e;if(!this.started)return;let n=r.remotePeer.toString(),i=this.connections.get(n);i!=null&&i.length>1?(i=i.filter(s=>s.id!==r.id),this.connections.set(n,i)):i!=null&&(this.connections.delete(n),this.dispatchEvent(new X("peer:disconnect",{detail:r})))}getConnections(e){if(e!=null)return this.connections.get(e.toString())??[];let r=[];for(let n of this.connections.values())r=r.concat(n);return r}async openConnection(e,r={}){let n;if(Qn(e))n=e;else if(Fr(e))n=Kr(e).id;else throw(0,Ra.default)(new TypeError("Can only open connections to PeerIds or Multiaddrs"),b.ERR_INVALID_PARAMETERS);et("dial to %p",n);let i=this.getConnections(n);if(i.length>0)return et("had an existing connection to %p",n),i[0];let s;if(r?.signal==null){s=new Ml.TimeoutController(this.dialTimeout),r.signal=s.signal;try{(0,Na.setMaxListeners)?.(1/0,s.signal)}catch{}}try{let o=await this.components.dialer.dial(e,r),a=this.connections.get(n.toString());a==null&&(a=[],this.connections.set(n.toString(),a));let c=!1;for(let u of a)u.id===o.id&&(c=!0);return c||a.push(o),o}finally{s?.clear()}}async closeConnections(e){let r=this.connections.get(e.toString())??[];await Promise.all(r.map(async n=>await n.close()))}getAll(e){if(!Qn(e))throw(0,Ra.default)(new Error("peerId must be an instance of peer-id"),b.ERR_INVALID_PARAMETERS);let r=e.toString(),n=this.connections.get(r);return n!=null?n.filter(i=>i.stat.status===Ca):[]}_onLatencyMeasure(e){let{detail:r}=e;this._checkMaxLimit("maxEventLoopDelay",r.avgMs,1).catch(n=>{et.error(n)})}async _checkMaxLimit(e,r,n=1){let i=this.opts[e];if(i==null){et.trace("limit %s was not set so it cannot be applied",e);return}et.trace("checking limit of %s. current value: %d of %d",e,r,i),r>i&&(et("%s: limit exceeded: %p, %d/%d, pruning %d connection(s)",this.components.peerId,e,r,i,n),await this._pruneConnections(n))}async _pruneConnections(e){let r=this.getConnections(),n=new Vs;for(let o of r){let a=o.remotePeer;if(n.has(a))continue;let c=await this.components.peerStore.getTags(a);n.set(a,c.reduce((u,l)=>u+l.value,0))}let i=r.sort((o,a)=>{let c=n.get(o.remotePeer)??0,u=n.get(a.remotePeer)??0;return c>u?1:c<u?-1:0}),s=[];for(let o of i)if(et("too many connections open - closing a connection to %p",o.remotePeer),s.push(o),s.length===e)break;await Promise.all(s.map(async o=>{try{await o.close()}catch(a){et.error(a)}this.onDisconnect(new X("connectionEnd",{detail:o}))}))}async acceptIncomingConnection(e){if(this.deny.some(i=>e.remoteAddr.toString().startsWith(i.toString())))return et("connection from %s refused - connection remote address was in deny list",e.remoteAddr),!1;if(this.allow.some(i=>e.remoteAddr.toString().startsWith(i.toString())))return this.incomingPendingConnections++,!0;if(this.incomingPendingConnections===this.opts.maxIncomingPendingConnections)return et("connection from %s refused - incomingPendingConnections exceeded by peer %s",e.remoteAddr),!1;if(e.remoteAddr.isThinWaistAddress()){let i=e.remoteAddr.nodeAddress().address;try{await this.inboundConnectionRateLimiter.consume(i,1)}catch{return et("connection from %s refused - inboundConnectionThreshold exceeded by host %s",i,e.remoteAddr),!1}}return this.getConnections().length<this.opts.maxConnections?(this.incomingPendingConnections++,!0):(et("connection from %s refused - maxConnections exceeded",e.remoteAddr),!1)}afterUpgradeInbound(){this.incomingPendingConnections--}};var Fl=C(tl(),1);async function zr(t){let e=[];for await(let r of t)e.push(r);return e}async function*zs(t,e){yield*(await zr(t)).sort(e)}var yn=M("libp2p:connection-manager:auto-dialler"),F2={enabled:!0,minConnections:0,autoDialInterval:1e4},La=class{constructor(e,r){this.components=e,this.options=pr.call({ignoreUndefined:!0},F2,r),this.running=!1,this._autoDial=this._autoDial.bind(this),yn("options: %j",this.options)}isStarted(){return this.running}async start(){if(!this.options.enabled){yn("not enabled");return}this.running=!0,this._autoDial().catch(e=>{yn.error("could start autodial",e)}),yn("started")}async stop(){if(!this.options.enabled){yn("not enabled");return}this.running=!1,this.autoDialTimeout!=null&&this.autoDialTimeout.clear(),yn("stopped")}async _autoDial(){this.autoDialTimeout!=null&&this.autoDialTimeout.clear();let e=this.options.minConnections;if(this.components.connectionManager.getConnections().length>=e){this.autoDialTimeout=(0,Fl.default)(this._autoDial,this.options.autoDialInterval);return}let r=await this.components.peerStore.all(),n=await Ce(r.sort(()=>Math.random()>.5?1:-1),i=>kr(i,s=>!s.id.equals(this.components.peerId)),i=>zs(i,(s,o)=>o.protocols.length>s.protocols.length||o.id.publicKey!=null&&s.id.publicKey==null?1:-1),async i=>await zr(i));for(let i=0;this.running&&i<n.length&&this.components.connectionManager.getConnections().length<e;i++){if(!this.running)return;let s=n[i];if(this.components.connectionManager.getConnections(s.id).length===0){yn("connecting to a peerStore stored peer %p",s.id);try{await this.components.connectionManager.openConnection(s.id)}catch(o){yn.error("could not connect to peerStore stored peer",o)}}}this.running&&(this.autoDialTimeout=(0,Fl.default)(this._autoDial,this.options.autoDialInterval))}};var yy=C(G(),1);var K2=W("dns4"),V2=W("dns6"),q2=W("dnsaddr"),Qi=mt(W("dns"),q2,K2,V2),Pa=mt(W("ip4"),W("ip6")),Ws=mt(ee(Pa,W("tcp")),ee(Qi,W("tcp"))),am=ee(Pa,W("udp")),H2=ee(am,W("utp")),z2=ee(am,W("quic")),$s=mt(ee(Ws,W("ws")),ee(Qi,W("ws"))),Gs=mt(ee(Ws,W("wss")),ee(Qi,W("wss"))),Kl=mt(ee(Ws,W("http")),ee(Pa,W("http")),ee(Qi,W("http"))),Vl=mt(ee(Ws,W("https")),ee(Pa,W("https")),ee(Qi,W("https"))),cm=mt(ee($s,W("p2p-webrtc-star"),W("p2p")),ee(Gs,W("p2p-webrtc-star"),W("p2p")),ee($s,W("p2p-webrtc-star")),ee(Gs,W("p2p-webrtc-star"))),qL=mt(ee($s,W("p2p-websocket-star"),W("p2p")),ee(Gs,W("p2p-websocket-star"),W("p2p")),ee($s,W("p2p-websocket-star")),ee(Gs,W("p2p-websocket-star"))),um=mt(ee(Kl,W("p2p-webrtc-direct"),W("p2p")),ee(Vl,W("p2p-webrtc-direct"),W("p2p")),ee(Kl,W("p2p-webrtc-direct")),ee(Vl,W("p2p-webrtc-direct"))),Ys=mt($s,Gs,Kl,Vl,cm,um,Ws,H2,z2,Qi),HL=mt(ee(Ys,W("p2p-stardust"),W("p2p")),ee(Ys,W("p2p-stardust"))),gn=mt(ee(Ys,W("p2p")),cm,um,W("p2p")),om=mt(ee(gn,W("p2p-circuit"),gn),ee(gn,W("p2p-circuit")),ee(W("p2p-circuit"),gn),ee(Ys,W("p2p-circuit")),ee(W("p2p-circuit"),Ys),W("p2p-circuit")),lm=()=>mt(ee(om,lm),om),ei=lm(),zL=mt(ee(ei,gn,ei),ee(gn,ei),ee(ei,gn),ei,gn);function fm(t){function e(r){let n;try{n=oe(r)}catch{return!1}let i=t(n.protoNames());return i===null?!1:i===!0||i===!1?i:i.length===0}return e}function ee(...t){function e(r){if(r.length<t.length)return null;let n=r;return t.some(i=>(n=typeof i=="function"?i().partialMatch(r):i.partialMatch(r),Array.isArray(n)&&(r=n),n===null)),n}return{toString:function(){return"{ "+t.join(" ")+" }"},input:t,matches:fm(e),partialMatch:e}}function mt(...t){function e(n){let i=null;return t.some(s=>{let o=typeof s=="function"?s().partialMatch(n):s.partialMatch(n);return o!=null?(i=o,!0):!1}),i}return{toString:function(){return"{ "+t.join(" ")+" }"},input:t,matches:fm(e),partialMatch:e}}function W(t){let e=t;function r(i){let s;try{s=oe(i)}catch{return!1}let o=s.protoNames();return o.length===1&&o[0]===e}function n(i){return i.length===0?null:i[0]===e?i.slice(1):null}return{toString:function(){return e},matches:r,partialMatch:n}}var ef=C(Gl(),1),Zm=C(zm(),1),tf=C(Jl(),1),Jm=C(jm(),1),ey=C(ri(),1);function eS(){ey.default._configure(),ef.default._configure(Zm.default),tf.default._configure(Jm.default)}eS();var ty=["uint64","int64","sint64","fixed64","sfixed64"];function tS(t){for(let e of ty){if(t[e]==null)continue;let r=t[e];t[e]=function(){return BigInt(r.call(this).toString())}}return t}function rf(t){return tS(new ef.default(t))}function rS(t){for(let e of ty){if(t[e]==null)continue;let r=t[e];t[e]=function(n){return r.call(this,n.toString())}}return t}function nf(){return rS(tf.default.create())}function Te(t,e){let r=rf(t instanceof Uint8Array?t:t.subarray());return e.decode(r)}function Re(t,e){let r=nf();return e.encode(t,r,{lengthDelimited:!1}),r.finish()}var ji;(function(t){t[t.VARINT=0]="VARINT",t[t.BIT64=1]="BIT64",t[t.LENGTH_DELIMITED=2]="LENGTH_DELIMITED",t[t.START_GROUP=3]="START_GROUP",t[t.END_GROUP=4]="END_GROUP",t[t.BIT32=5]="BIT32"})(ji||(ji={}));function Ma(t,e,r,n){return{name:t,type:e,encode:r,decode:n}}function wn(t){function e(i){if(t[i.toString()]==null)throw new Error("Invalid enum value");return t[i]}let r=function(s,o){let a=e(s);o.int32(a)},n=function(s){let o=s.int32();return e(o)};return Ma("enum",ji.VARINT,r,n)}function Ne(t,e){return Ma("message",ji.LENGTH_DELIMITED,t,e)}var j;(function(t){let e;(function(a){a.SUCCESS="SUCCESS",a.HOP_SRC_ADDR_TOO_LONG="HOP_SRC_ADDR_TOO_LONG",a.HOP_DST_ADDR_TOO_LONG="HOP_DST_ADDR_TOO_LONG",a.HOP_SRC_MULTIADDR_INVALID="HOP_SRC_MULTIADDR_INVALID",a.HOP_DST_MULTIADDR_INVALID="HOP_DST_MULTIADDR_INVALID",a.HOP_NO_CONN_TO_DST="HOP_NO_CONN_TO_DST",a.HOP_CANT_DIAL_DST="HOP_CANT_DIAL_DST",a.HOP_CANT_OPEN_DST_STREAM="HOP_CANT_OPEN_DST_STREAM",a.HOP_CANT_SPEAK_RELAY="HOP_CANT_SPEAK_RELAY",a.HOP_CANT_RELAY_TO_SELF="HOP_CANT_RELAY_TO_SELF",a.STOP_SRC_ADDR_TOO_LONG="STOP_SRC_ADDR_TOO_LONG",a.STOP_DST_ADDR_TOO_LONG="STOP_DST_ADDR_TOO_LONG",a.STOP_SRC_MULTIADDR_INVALID="STOP_SRC_MULTIADDR_INVALID",a.STOP_DST_MULTIADDR_INVALID="STOP_DST_MULTIADDR_INVALID",a.STOP_RELAY_REFUSED="STOP_RELAY_REFUSED",a.MALFORMED_MESSAGE="MALFORMED_MESSAGE"})(e=t.Status||(t.Status={}));let r;(function(a){a[a.SUCCESS=100]="SUCCESS",a[a.HOP_SRC_ADDR_TOO_LONG=220]="HOP_SRC_ADDR_TOO_LONG",a[a.HOP_DST_ADDR_TOO_LONG=221]="HOP_DST_ADDR_TOO_LONG",a[a.HOP_SRC_MULTIADDR_INVALID=250]="HOP_SRC_MULTIADDR_INVALID",a[a.HOP_DST_MULTIADDR_INVALID=251]="HOP_DST_MULTIADDR_INVALID",a[a.HOP_NO_CONN_TO_DST=260]="HOP_NO_CONN_TO_DST",a[a.HOP_CANT_DIAL_DST=261]="HOP_CANT_DIAL_DST",a[a.HOP_CANT_OPEN_DST_STREAM=262]="HOP_CANT_OPEN_DST_STREAM",a[a.HOP_CANT_SPEAK_RELAY=270]="HOP_CANT_SPEAK_RELAY",a[a.HOP_CANT_RELAY_TO_SELF=280]="HOP_CANT_RELAY_TO_SELF",a[a.STOP_SRC_ADDR_TOO_LONG=320]="STOP_SRC_ADDR_TOO_LONG",a[a.STOP_DST_ADDR_TOO_LONG=321]="STOP_DST_ADDR_TOO_LONG",a[a.STOP_SRC_MULTIADDR_INVALID=350]="STOP_SRC_MULTIADDR_INVALID",a[a.STOP_DST_MULTIADDR_INVALID=351]="STOP_DST_MULTIADDR_INVALID",a[a.STOP_RELAY_REFUSED=390]="STOP_RELAY_REFUSED",a[a.MALFORMED_MESSAGE=400]="MALFORMED_MESSAGE"})(r||(r={})),function(a){a.codec=()=>wn(r)}(e=t.Status||(t.Status={}));let n;(function(a){a.HOP="HOP",a.STOP="STOP",a.STATUS="STATUS",a.CAN_HOP="CAN_HOP"})(n=t.Type||(t.Type={}));let i;(function(a){a[a.HOP=1]="HOP",a[a.STOP=2]="STOP",a[a.STATUS=3]="STATUS",a[a.CAN_HOP=4]="CAN_HOP"})(i||(i={})),function(a){a.codec=()=>wn(i)}(n=t.Type||(t.Type={}));let s;(function(a){let c;a.codec=()=>(c==null&&(c=Ne((u,l,f={})=>{if(f.lengthDelimited!==!1&&l.fork(),(f.writeDefaults===!0||u.id!=null&&u.id.byteLength>0)&&(l.uint32(10),l.bytes(u.id)),u.addrs!=null)for(let h of u.addrs)l.uint32(18),l.bytes(h);f.lengthDelimited!==!1&&l.ldelim()},(u,l)=>{let f={id:new Uint8Array(0),addrs:[]},h=l==null?u.len:u.pos+l;for(;u.pos<h;){let d=u.uint32();switch(d>>>3){case 1:f.id=u.bytes();break;case 2:f.addrs.push(u.bytes());break;default:u.skipType(d&7);break}}return f})),c),a.encode=u=>Re(u,a.codec()),a.decode=u=>Te(u,a.codec())})(s=t.Peer||(t.Peer={}));let o;t.codec=()=>(o==null&&(o=Ne((a,c,u={})=>{u.lengthDelimited!==!1&&c.fork(),a.type!=null&&(c.uint32(8),t.Type.codec().encode(a.type,c)),a.srcPeer!=null&&(c.uint32(18),t.Peer.codec().encode(a.srcPeer,c,{writeDefaults:!1})),a.dstPeer!=null&&(c.uint32(26),t.Peer.codec().encode(a.dstPeer,c,{writeDefaults:!1})),a.code!=null&&(c.uint32(32),t.Status.codec().encode(a.code,c)),u.lengthDelimited!==!1&&c.ldelim()},(a,c)=>{let u={},l=c==null?a.len:a.pos+c;for(;a.pos<l;){let f=a.uint32();switch(f>>>3){case 1:u.type=t.Type.codec().decode(a);break;case 2:u.srcPeer=t.Peer.codec().decode(a,a.uint32());break;case 3:u.dstPeer=t.Peer.codec().decode(a,a.uint32());break;case 4:u.code=t.Status.codec().decode(a);break;default:a.skipType(f&7);break}}return u})),o),t.encode=a=>Re(a,t.codec()),t.decode=a=>Te(a,t.codec())})(j||(j={}));var js=class extends Error{constructor(e,r){super(e??"The operation was aborted"),this.type="aborted",this.code=r??"ABORT_ERR"}};function ry(t){if(t!=null){if(typeof t[Symbol.iterator]=="function")return t[Symbol.iterator]();if(typeof t[Symbol.asyncIterator]=="function")return t[Symbol.asyncIterator]();if(typeof t.next=="function")return t}throw new Error("argument is not an iterator or iterable")}function ii(t,e,r){let n=r??{},i=ry(t);async function*s(){let o,a=()=>{o?.()};for(e.addEventListener("abort",a);;){let c;try{if(e.aborted){let{abortMessage:l,abortCode:f}=n;throw new js(l,f)}let u=new Promise((l,f)=>{o=()=>{let{abortMessage:h,abortCode:d}=n;f(new js(h,d))}});c=await Promise.race([u,i.next()]),o=null}catch(u){e.removeEventListener("abort",a);let l=u.type==="aborted"&&e.aborted;if(l&&n.onAbort!=null&&await n.onAbort(t),typeof i.return=="function")try{let f=i.return();f instanceof Promise&&f.catch(h=>{n.onReturnError!=null&&n.onReturnError(h)})}catch(f){n.onReturnError!=null&&n.onReturnError(f)}if(l&&n.returnOnAbort===!0)return;throw u}if(c.done===!0)break;yield c.value}e.removeEventListener("abort",a)}return s()}function nS(t,e,r){return n=>t(ii(n,e,r))}function Dt(t,e,r){return{sink:nS(t.sink,e,{...r,onAbort:void 0}),source:ii(t.source,e,r)}}var iS=M("libp2p:stream:converter");function sf(t,e={}){let{stream:r,remoteAddr:n}=t,{sink:i,source:s}=r,o=async function*(){for await(let u of s)yield*u}(),a={async sink(u){e.signal!=null&&(u=ii(u,e.signal));try{await i(u),await c()}catch(l){l.type!=="aborted"&&iS(l)}},source:e.signal!=null?ii(o,e.signal):o,remoteAddr:n,timeline:{open:Date.now(),close:void 0},async close(){await i(async function*(){yield new Uint8Array(0)}()),await c()}};async function c(){return a.timeline.close==null&&(a.timeline.close=Date.now()),await Promise.resolve()}return a}var gr="/libp2p/circuit/relay/0.1.0";function ny(t){let e=new Map;async function r(s){let o=s.toString().split("/p2p-circuit").find(h=>h!==""),a=oe(o),c=a.getPeerId();if(c==null)throw new Error("Could not determine relay peer from multiaddr");let u=me(c);await t.peerStore.addressBook.add(u,[a]);let l=await t.connectionManager.openConnection(u),f=l.remoteAddr.encapsulate("/p2p-circuit");e.set(l.remotePeer.toString(),f),i.dispatchEvent(new X("listening"))}function n(){let s=[];for(let o of e.values())s.push(o);return s}let i=Object.assign(new Ue,{close:async()=>await Promise.resolve(),listen:r,getAddrs:n});return t.connectionManager.addEventListener("peer:disconnect",s=>{let{detail:o}=s;e.delete(o.remotePeer.toString())&&i.dispatchEvent(new X("close"))}),i}var uf=C(G(),1);function iy(t,e){t.write({type:j.Type.STATUS,code:e})}function Fa(t,e){try{t.dstPeer?.addrs!=null&&t.dstPeer.addrs.forEach(r=>oe(r))}catch(r){throw iy(e,t.type===j.Type.HOP?j.Status.HOP_DST_MULTIADDR_INVALID:j.Status.STOP_DST_MULTIADDR_INVALID),r}try{t.srcPeer?.addrs!=null&&t.srcPeer.addrs.forEach(r=>oe(r))}catch(r){throw iy(e,t.type===j.Type.HOP?j.Status.HOP_SRC_MULTIADDR_INVALID:j.Status.STOP_SRC_MULTIADDR_INVALID),r}}var oy=Symbol.for("@achingbrain/uint8arraylist");function sy(t,e){if(e==null||e<0)throw new RangeError("index is out of bounds");let r=0;for(let n of t){let i=r+n.byteLength;if(e<i)return{buf:n,index:e-r};r=i}throw new RangeError("index is out of bounds")}function Ka(t){return Boolean(t?.[oy])}var Ge=class{constructor(...e){Object.defineProperty(this,oy,{value:!0}),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(Ka(n))r+=n.byteLength,this.bufs.push(...n.bufs);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(Ka(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=sy(this.bufs,e);return r.buf[r.index]}set(e,r){let n=sy(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(Ka(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:i}=this._subList(e,r);return Xe(n,i)}subarray(e,r){let{bufs:n,length:i}=this._subList(e,r);return n.length===1?n[0]:Xe(n,i)}sublist(e,r){let{bufs:n,length:i}=this._subList(e,r),s=new Ge;return s.length=i,s.bufs=n,s}_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=[],i=0;for(let s=0;s<this.bufs.length;s++){let o=this.bufs[s],a=i,c=a+o.byteLength;if(i=c,e>=c)continue;let u=e>=a&&e<c,l=r>a&&r<=c;if(u&&l){if(e===a&&r===c){n.push(o);break}let f=e-a;n.push(o.subarray(f,f+(r-e)));break}if(u){if(e===0){n.push(o);continue}n.push(o.subarray(e-a));continue}if(l){if(r===c){n.push(o);break}n.push(o.subarray(0,r-a));break}n.push(o)}return{bufs:n,length:r-e}}indexOf(e,r=0){if(!Ka(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 i=n.byteLength;if(i===0)throw new TypeError("search must be at least 1 byte long");let s=256,o=new Int32Array(s);for(let f=0;f<s;f++)o[f]=-1;for(let f=0;f<i;f++)o[n[f]]=f;let a=o,c=this.byteLength-n.byteLength,u=n.byteLength-1,l;for(let f=r;f<=c;f+=l){l=0;for(let h=u;h>=0;h--){let d=this.get(f+h);if(n[h]!==d){l=Math.max(1,h-a[d]);break}}if(l===0)return f}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=Br(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 i=Pr(2);new DataView(i.buffer,i.byteOffset,i.byteLength).setInt16(0,r,n),this.write(i,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 i=Pr(4);new DataView(i.buffer,i.byteOffset,i.byteLength).setInt32(0,r,n),this.write(i,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 i=Pr(8);new DataView(i.buffer,i.byteOffset,i.byteLength).setBigInt64(0,r,n),this.write(i,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=Br(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 i=Pr(2);new DataView(i.buffer,i.byteOffset,i.byteLength).setUint16(0,r,n),this.write(i,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 i=Pr(4);new DataView(i.buffer,i.byteOffset,i.byteLength).setUint32(0,r,n),this.write(i,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 i=Pr(8);new DataView(i.buffer,i.byteOffset,i.byteLength).setBigUint64(0,r,n),this.write(i,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 i=Pr(4);new DataView(i.buffer,i.byteOffset,i.byteLength).setFloat32(0,r,n),this.write(i,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 i=Pr(8);new DataView(i.buffer,i.byteOffset,i.byteLength).setFloat64(0,r,n),this.write(i,e)}equals(e){if(e==null||!(e instanceof Ge)||e.bufs.length!==this.bufs.length)return!1;for(let r=0;r<this.bufs.length;r++)if(!_e(this.bufs[r],e.bufs[r]))return!1;return!0}static fromUint8Arrays(e,r){let n=new Ge;return n.bufs=e,r==null&&(r=e.reduce((i,s)=>i+s.byteLength,0)),n.length=r,n}};function Va(t){return t instanceof Uint8Array?{get(e){return t[e]},set(e,r){t[e]=r}}:{get(e){return t.get(e)},set(e,r){t.set(e,r)}}}var ay=4294967296,Lt=class{constructor(e=0,r=0){this.hi=e,this.lo=r}toBigInt(e){if(e===!0)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)}toNumber(e){return Number(this.toBigInt(e))}zzDecode(){let e=-(this.lo&1),r=((this.lo>>>1|this.hi<<31)^e)>>>0,n=(this.hi>>>1^e)>>>0;return new Lt(n,r)}zzEncode(){let e=this.hi>>31,r=((this.hi<<1|this.lo>>>31)^e)>>>0,n=(this.lo<<1^e)>>>0;return new Lt(r,n)}toBytes(e,r=0){let n=Va(e);for(;this.hi>0;)n.set(r++,this.lo&127|128),this.lo=(this.lo>>>7|this.hi<<25)>>>0,this.hi>>>=7;for(;this.lo>127;)n.set(r++,this.lo&127|128),this.lo=this.lo>>>7;n.set(r++,this.lo)}static fromBigInt(e){if(e===0n)return new Lt;let r=e<0;r&&(e=-e);let n=Number(e>>32n)|0,i=Number(e-(BigInt(n)<<32n))|0;return r&&(n=~n>>>0,i=~i>>>0,++i>ay&&(i=0,++n>ay&&(n=0))),new Lt(n,i)}static fromNumber(e){if(e===0)return new Lt;let r=e<0;r&&(e=-e);let n=e>>>0,i=(e-n)/4294967296>>>0;return r&&(i=~i>>>0,n=~n>>>0,++n>4294967295&&(n=0,++i>4294967295&&(i=0))),new Lt(i,n)}static fromBytes(e,r=0){let n=Va(e),i=new Lt,s=0;if(e.length-r>4){for(;s<4;++s)if(i.lo=(i.lo|(n.get(r)&127)<<s*7)>>>0,n.get(r++)<128)return i;if(i.lo=(i.lo|(n.get(r)&127)<<28)>>>0,i.hi=(i.hi|(n.get(r)&127)>>4)>>>0,n.get(r++)<128)return i;s=0}else for(;s<4;++s){if(r>=e.length)throw RangeError(`index out of range: ${r} > ${e.length}`);if(i.lo=(i.lo|(n.get(r)&127)<<s*7)>>>0,n.get(r++)<128)return i}if(e.length-r>4){for(;s<5;++s)if(i.hi=(i.hi|(n.get(r)&127)<<s*7+3)>>>0,n.get(r++)<128)return i}else if(r<e.byteLength)for(;s<5;++s){if(r>=e.length)throw RangeError(`index out of range: ${r} > ${e.length}`);if(i.hi=(i.hi|(n.get(r)&127)<<s*7+3)>>>0,n.get(r++)<128)return i}throw RangeError("invalid varint encoding")}};var sS=Math.pow(2,7),oS=Math.pow(2,14),aS=Math.pow(2,21),cS=Math.pow(2,28),uS=Math.pow(2,35),lS=Math.pow(2,42),fS=Math.pow(2,49),hS=Math.pow(2,56),dS=Math.pow(2,63),er={encodingLength(t){return t<sS?1:t<oS?2:t<aS?3:t<cS?4:t<uS?5:t<lS?6:t<fS?7:t<hS?8:t<dS?9:10},encode(t,e,r=0){if(Number.MAX_SAFE_INTEGER!=null&&t>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return e==null&&(e=Br(er.encodingLength(t))),Lt.fromNumber(t).toBytes(e,r),e},decode(t,e=0){return Lt.fromBytes(t,e).toNumber(!0)}};function cy(t){return globalThis?.Buffer?.allocUnsafe!=null?globalThis.Buffer.allocUnsafe(t):new Uint8Array(t)}var qa=t=>{let e=er.encodingLength(t),r=cy(e);return er.encode(t,r),qa.bytes=e,r};qa.bytes=0;function Vt(t){t=t??{};let e=t.lengthEncoder??qa;return async function*(n){for await(let i of n){let s=e(i.byteLength);s instanceof Uint8Array?yield s:yield*s,i instanceof Uint8Array?yield i:yield*i}}}Vt.single=(t,e)=>{e=e??{};let r=e.lengthEncoder??qa;return new Ge(r(t.byteLength),t)};var Zs=C(G(),1),pS=8,mS=1024*1024*4,si;(function(t){t[t.LENGTH=0]="LENGTH",t[t.DATA=1]="DATA"})(si||(si={}));var of=t=>{let e=er.decode(t);return of.bytes=er.encodingLength(e),e};of.bytes=0;function Pt(t){return async function*(r){let n=new Ge,i=si.LENGTH,s=-1,o=t?.lengthDecoder??of,a=t?.maxLengthLength??pS,c=t?.maxDataLength??mS;for await(let u of r)for(n.append(u);n.byteLength>0;){if(i===si.LENGTH)try{if(s=o(n),s<0)throw(0,Zs.default)(new Error("invalid message length"),"ERR_INVALID_MSG_LENGTH");if(s>c)throw(0,Zs.default)(new Error("message length too long"),"ERR_MSG_DATA_TOO_LONG");let l=o.bytes;n.consume(l),t?.onLength!=null&&t.onLength(s),i=si.DATA}catch(l){if(l instanceof RangeError){if(n.byteLength>a)throw(0,Zs.default)(new Error("message length length too long"),"ERR_MSG_LENGTH_TOO_LONG");break}throw l}if(i===si.DATA){if(n.byteLength<s)break;let l=n.sublist(0,s);n.consume(s),t?.onData!=null&&t.onData(l),yield l,i=si.LENGTH}}if(n.byteLength>0)throw(0,Zs.default)(new Error("unexpected end of input"),"ERR_UNEXPECTED_EOF")}}Pt.fromReader=(t,e)=>{let r=1,n=async function*(){for(;;)try{let{done:s,value:o}=await t.next(r);if(s===!0)return;o!=null&&(yield o)}catch(s){if(s.code==="ERR_UNDER_READ")return{done:!0,value:null};throw s}finally{r=1}}();return Pt({...e??{},onLength:s=>{r=s}})(n)};function af(t){let e=async function*(){let r=yield,n=new Ge;for await(let i of t){if(r==null){n.append(i),r=yield n,n=new Ge;continue}for(n.append(i);n.length>=r;){let s=n.sublist(0,r);if(n.consume(r),r=yield s,r==null){n.length>0&&(r=yield n,n=new Ge);break}}}if(r!=null)throw Object.assign(new Error(`stream ended before ${r} bytes became available`),{code:"ERR_UNDER_READ",buffer:n})}();return e.next(),e}function cf(){let t={};return t.promise=new Promise((e,r)=>{t.resolve=e,t.reject=r}),t}function Zi(t){let e=Wn(),r=af(t.source),n=cf(),i,s=t.sink(async function*(){yield*e,yield*await n.promise}());return s.catch(a=>{i=a}),{reader:r,writer:e,stream:{sink:async a=>i!=null?await Promise.reject(i):(n.resolve(a),await s),source:r},rest:()=>e.end(),write:e.push,read:async()=>{let a=await r.next();if(a.value!=null)return a.value}}}var Js=M("libp2p:circuit:stream-handler"),$r=class{constructor(e){let{stream:r,maxLength:n=4096}=e;this.stream=r,this.shake=Zi(this.stream),this.decoder=Pt.fromReader(this.shake.reader,{maxDataLength:n})}async read(){let e=await this.decoder.next();if(e.value!=null){let r=j.decode(e.value);return Js("read message type",r.type),r}Js("read received no value, closing stream"),this.close()}write(e){Js("write message type %s",e.type),this.shake.write(Vt.single(j.encode(e)))}rest(){return this.shake.rest(),this.shake.stream}end(e){this.write(e),this.close()}close(){Js("closing the stream"),this.rest().sink([]).catch(e=>{Js.error(e)})}};var eo=M("libp2p:circuit:stop");function uy(t){let{connection:e,request:r,streamHandler:n}=t;try{Fa(r,n)}catch(i){eo.error("invalid stop request via peer %p %o",e.remotePeer,i);return}return eo("stop request is valid"),n.write({type:j.Type.STATUS,code:j.Status.SUCCESS}),n.rest()}async function ly(t){let{connection:e,request:r,signal:n}=t,i=await e.newStream(gr,{signal:n});eo("starting stop request to %p",e.remotePeer);let s=new $r({stream:i});s.write(r);let o=await s.read();if(o==null){s.close();return}if(o.code===j.Status.SUCCESS)return eo("stop request to %p was successful",e.remotePeer),s.rest();eo("stop request failed with code %d",o.code),s.close()}var qt=M("libp2p:circuit:hop");async function fy(t){let{connection:e,request:r,streamHandler:n,circuit:i,connectionManager:s}=t;if(!i.hopEnabled())return qt("HOP request received but we are not acting as a relay"),n.end({type:j.Type.STATUS,code:j.Status.HOP_CANT_SPEAK_RELAY});try{Fa(r,n)}catch(f){qt.error("invalid hop request via peer %p %o",e.remotePeer,f);return}if(r.dstPeer==null){qt("HOP request received but we do not receive a dstPeer");return}let o=mn(r.dstPeer.id),a=s.getConnections(o);if(a.length===0&&!i.hopActive())return qt("HOP request received but we are not connected to the destination peer"),n.end({type:j.Type.STATUS,code:j.Status.HOP_NO_CONN_TO_DST});if(a.length===0)return qt("did not have connection to remote peer"),n.end({type:j.Type.STATUS,code:j.Status.HOP_NO_CONN_TO_DST});let c={type:j.Type.STOP,dstPeer:r.dstPeer,srcPeer:r.srcPeer},u;try{qt("performing STOP request");let f=await ly({connection:a[0],request:c});if(f==null)throw new Error("Could not stop");u=f}catch(f){qt.error(f);return}qt("hop request from %p is valid",e.remotePeer),n.write({type:j.Type.STATUS,code:j.Status.SUCCESS});let l=n.rest();return qt("creating related connections"),await Ce(l,u,l)}async function hy(t){let{connection:e,request:r,signal:n}=t,i=await e.newStream(gr,{signal:n}),s=new $r({stream:i});s.write(r);let o=await s.read();if(o==null)throw(0,uf.default)(new Error("HOP request had no response"),b.ERR_HOP_REQUEST_FAILED);if(o.code===j.Status.SUCCESS)return qt("hop request was successful"),s.rest();throw qt("hop request failed with code %d, closing stream",o.code),s.close(),(0,uf.default)(new Error(`HOP request failed with code "${o.code??"unknown"}"`),b.ERR_HOP_REQUEST_FAILED)}async function dy(t){let{connection:e,signal:r}=t,n=await e.newStream(gr,{signal:r}),i=new $r({stream:n});i.write({type:j.Type.CAN_HOP});let s=await i.read();return await i.close(),!(s==null||s.code!==j.Status.SUCCESS)}function py(t){let{connection:e,streamHandler:r,circuit:n}=t,i=n.hopEnabled();qt("can hop (%s) request from %p",i,e.remotePeer),r.end({type:j.Type.STATUS,code:i?j.Status.SUCCESS:j.Status.HOP_CANT_SPEAK_RELAY})}var my=Symbol.for("@libp2p/transport");var xn;(function(t){t[t.FATAL_ALL=0]="FATAL_ALL",t[t.NO_FATAL=1]="NO_FATAL"})(xn||(xn={}));var gy=C(Ur(),1),Ey=C(fr(),1),Ht=M("libp2p:circuit"),za=class{constructor(e,r){this._init=r,this.components=e,this._started=!1}isStarted(){return this._started}async start(){this._started||(this._started=!0,await this.components.registrar.handle(gr,e=>{this._onProtocol(e).catch(r=>{Ht.error(r)})}).catch(e=>{Ht.error(e)}))}async stop(){await this.components.registrar.unhandle(gr)}hopEnabled(){return!0}hopActive(){return!0}get[my](){return!0}get[Symbol.toStringTag](){return"libp2p/circuit-relay-v1"}async _onProtocol(e){let{connection:r,stream:n}=e,i=new gy.TimeoutController(this._init.hop.timeout);try{(0,Ey.setMaxListeners)?.(1/0,i.signal)}catch{}try{let s=Dt(n,i.signal),o=new $r({stream:{...n,...s}}),a=await o.read();if(a==null){Ht("request was invalid, could not read from stream"),o.write({type:j.Type.STATUS,code:j.Status.MALFORMED_MESSAGE}),o.close();return}let c;switch(a.type){case j.Type.CAN_HOP:{Ht("received CAN_HOP request from %p",r.remotePeer),await py({circuit:this,connection:r,streamHandler:o});break}case j.Type.HOP:{Ht("received HOP request from %p",r.remotePeer),await fy({connection:r,request:a,streamHandler:o,circuit:this,connectionManager:this.components.connectionManager});break}case j.Type.STOP:{Ht("received STOP request from %p",r.remotePeer),c=await uy({connection:r,request:a,streamHandler:o});break}default:{Ht("Request of type %s not supported",a.type),o.write({type:j.Type.STATUS,code:j.Status.MALFORMED_MESSAGE}),o.close();return}}if(c!=null){let u=r.remoteAddr.encapsulate("/p2p-circuit").encapsulate(oe(a.dstPeer?.addrs[0])),l=oe(a.srcPeer?.addrs[0]),f=sf({stream:c,remoteAddr:u,localAddr:l}),h=a.type===j.Type.HOP?"relay":"inbound";Ht("new %s connection %s",h,f.remoteAddr);let d=await this.components.upgrader.upgradeInbound(f);Ht("%s connection %s upgraded",h,f.remoteAddr),this.handler!=null&&this.handler(d)}}finally{i.clear()}}async dial(e,r={}){let n=e.toString().split("/p2p-circuit"),i=oe(n[0]),s=oe(n[n.length-1]),o=i.getPeerId(),a=s.getPeerId();if(o==null||a==null){let d="Circuit relay dial failed as addresses did not have peer id";throw Ht.error(d),(0,yy.default)(new Error(d),b.ERR_RELAYED_DIAL)}let c=me(o),u=me(a),l=!1,h=this.components.connectionManager.getConnections(c)[0];h==null&&(await this.components.peerStore.addressBook.add(c,[i]),h=await this.components.connectionManager.openConnection(c,r),l=!0);try{let d=await hy({...r,connection:h,request:{type:j.Type.HOP,srcPeer:{id:this.components.peerId.toBytes(),addrs:this.components.addressManager.getAddresses().map(g=>g.bytes)},dstPeer:{id:u.toBytes(),addrs:[oe(s).bytes]}}}),p=i.encapsulate(`/p2p-circuit/p2p/${this.components.peerId.toString()}`),y=sf({stream:d,remoteAddr:e,localAddr:p});return Ht("new outbound connection %s",y.remoteAddr),await this.components.upgrader.upgradeOutbound(y)}catch(d){throw Ht.error("Circuit relay dial failed",d),l&&await h.close(),d}}createListener(e){return this.handler=e.handler,ny({connectionManager:this.components.connectionManager,peerStore:this.components.peerStore})}filter(e){return e=Array.isArray(e)?e:[e],e.filter(r=>ei.matches(r))}};var Za=C(nl(),1);async function $a(t){let e=new TextEncoder().encode(t),r=await ot.digest(e);return ve.createV0(r)}var lf="hop_relay",ff="true",Ga="/libp2p/relay";var Ay=C(vy(),1);var wy="[a-fA-F\\d:]",bn=t=>t&&t.includeBoundaries?`(?:(?<=\\s|^)(?=${wy})|(?<=${wy})(?=\\s|$))`:"",tr="(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}",tt="[a-fA-F\\d]{1,4}",Ya=`
|
|
38
38
|
(?:
|
|
39
39
|
(?:${tt}:){7}(?:${tt}|:)| // 1:2:3:4:5:6:7:: 1:2:3:4:5:6:7:8
|
|
40
40
|
(?:${tt}:){6}(?:${tr}|:${tt}|:)| // 1:2:3:4:5:6:: 1:2:3:4:5:6::8 1:2:3:4:5:6::8 1:2:3:4:5:6::1.2.3.4
|