From bd2f5d40cdea2e2464e5107448d1fe848761ea95 Mon Sep 17 00:00:00 2001 From: status-im-auto Date: Mon, 26 Sep 2022 04:19:18 +0000 Subject: [PATCH] Updates --- rln-js/index.html | 2 ++ .../6c569aa52e8fecc76efe.module.wasm | Bin rln-react-ts/asset-manifest.json | 17 +++++++++++++++++ {rln-reactts => rln-react-ts}/favicon.ico | Bin rln-react-ts/index.html | 1 + {rln-reactts => rln-react-ts}/manifest.json | 0 {rln-reactts => rln-react-ts}/robots.txt | 0 .../static/css/main.271a57b5.css | 0 .../static/css/main.271a57b5.css.map | 0 .../static/js/913.9518dccb.chunk.js | 0 .../static/js/913.9518dccb.chunk.js.map | 0 .../static/js/main.e42c30f1.js | 6 +++--- .../static/js/main.e42c30f1.js.LICENSE.txt | 0 rln-react-ts/static/js/main.e42c30f1.js.map | 1 + .../static/media/rpc.93e8f6196bd2c425bf03.cjs | 0 rln-reactts/asset-manifest.json | 17 ----------------- rln-reactts/index.html | 1 - rln-reactts/static/js/main.24f1d8e6.js.map | 1 - 18 files changed, 24 insertions(+), 22 deletions(-) rename {rln-reactts => rln-react-ts}/6c569aa52e8fecc76efe.module.wasm (100%) create mode 100644 rln-react-ts/asset-manifest.json rename {rln-reactts => rln-react-ts}/favicon.ico (100%) create mode 100644 rln-react-ts/index.html rename {rln-reactts => rln-react-ts}/manifest.json (100%) rename {rln-reactts => rln-react-ts}/robots.txt (100%) rename {rln-reactts => rln-react-ts}/static/css/main.271a57b5.css (100%) rename {rln-reactts => rln-react-ts}/static/css/main.271a57b5.css.map (100%) rename {rln-reactts => rln-react-ts}/static/js/913.9518dccb.chunk.js (100%) rename {rln-reactts => rln-react-ts}/static/js/913.9518dccb.chunk.js.map (100%) rename rln-reactts/static/js/main.24f1d8e6.js => rln-react-ts/static/js/main.e42c30f1.js (60%) rename rln-reactts/static/js/main.24f1d8e6.js.LICENSE.txt => rln-react-ts/static/js/main.e42c30f1.js.LICENSE.txt (100%) create mode 100644 rln-react-ts/static/js/main.e42c30f1.js.map rename {rln-reactts => rln-react-ts}/static/media/rpc.93e8f6196bd2c425bf03.cjs (100%) delete mode 100644 rln-reactts/asset-manifest.json delete mode 100644 rln-reactts/index.html delete mode 100644 rln-reactts/static/js/main.24f1d8e6.js.map diff --git a/rln-js/index.html b/rln-js/index.html index 97a7461..c6048e9 100644 --- a/rln-js/index.html +++ b/rln-js/index.html @@ -63,7 +63,9 @@ const keyDiv = document.getElementById('key'); const commitmentDiv = document.getElementById('commitment'); + generateCredsButton.disabled = true; const rlnInstance = await create(); + generateCredsButton.disabled = false; let membership; generateCredsButton.onclick = () => { diff --git a/rln-reactts/6c569aa52e8fecc76efe.module.wasm b/rln-react-ts/6c569aa52e8fecc76efe.module.wasm similarity index 100% rename from rln-reactts/6c569aa52e8fecc76efe.module.wasm rename to rln-react-ts/6c569aa52e8fecc76efe.module.wasm diff --git a/rln-react-ts/asset-manifest.json b/rln-react-ts/asset-manifest.json new file mode 100644 index 0000000..10e3f64 --- /dev/null +++ b/rln-react-ts/asset-manifest.json @@ -0,0 +1,17 @@ +{ + "files": { + "main.css": "/rln-react-ts/static/css/main.271a57b5.css", + "main.js": "/rln-react-ts/static/js/main.e42c30f1.js", + "static/js/913.9518dccb.chunk.js": "/rln-react-ts/static/js/913.9518dccb.chunk.js", + "module.wasm": "/rln-react-ts/6c569aa52e8fecc76efe.module.wasm", + "static/media/rpc.cjs": "/rln-react-ts/static/media/rpc.93e8f6196bd2c425bf03.cjs", + "index.html": "/rln-react-ts/index.html", + "main.271a57b5.css.map": "/rln-react-ts/static/css/main.271a57b5.css.map", + "main.e42c30f1.js.map": "/rln-react-ts/static/js/main.e42c30f1.js.map", + "913.9518dccb.chunk.js.map": "/rln-react-ts/static/js/913.9518dccb.chunk.js.map" + }, + "entrypoints": [ + "static/css/main.271a57b5.css", + "static/js/main.e42c30f1.js" + ] +} \ No newline at end of file diff --git a/rln-reactts/favicon.ico b/rln-react-ts/favicon.ico similarity index 100% rename from rln-reactts/favicon.ico rename to rln-react-ts/favicon.ico diff --git a/rln-react-ts/index.html b/rln-react-ts/index.html new file mode 100644 index 0000000..1043072 --- /dev/null +++ b/rln-react-ts/index.html @@ -0,0 +1 @@ +React App
\ No newline at end of file diff --git a/rln-reactts/manifest.json b/rln-react-ts/manifest.json similarity index 100% rename from rln-reactts/manifest.json rename to rln-react-ts/manifest.json diff --git a/rln-reactts/robots.txt b/rln-react-ts/robots.txt similarity index 100% rename from rln-reactts/robots.txt rename to rln-react-ts/robots.txt diff --git a/rln-reactts/static/css/main.271a57b5.css b/rln-react-ts/static/css/main.271a57b5.css similarity index 100% rename from rln-reactts/static/css/main.271a57b5.css rename to rln-react-ts/static/css/main.271a57b5.css diff --git a/rln-reactts/static/css/main.271a57b5.css.map b/rln-react-ts/static/css/main.271a57b5.css.map similarity index 100% rename from rln-reactts/static/css/main.271a57b5.css.map rename to rln-react-ts/static/css/main.271a57b5.css.map diff --git a/rln-reactts/static/js/913.9518dccb.chunk.js b/rln-react-ts/static/js/913.9518dccb.chunk.js similarity index 100% rename from rln-reactts/static/js/913.9518dccb.chunk.js rename to rln-react-ts/static/js/913.9518dccb.chunk.js diff --git a/rln-reactts/static/js/913.9518dccb.chunk.js.map b/rln-react-ts/static/js/913.9518dccb.chunk.js.map similarity index 100% rename from rln-reactts/static/js/913.9518dccb.chunk.js.map rename to rln-react-ts/static/js/913.9518dccb.chunk.js.map diff --git a/rln-reactts/static/js/main.24f1d8e6.js b/rln-react-ts/static/js/main.e42c30f1.js similarity index 60% rename from rln-reactts/static/js/main.24f1d8e6.js rename to rln-react-ts/static/js/main.e42c30f1.js index f0c8233..9710190 100644 --- a/rln-reactts/static/js/main.24f1d8e6.js +++ b/rln-react-ts/static/js/main.e42c30f1.js @@ -1,3 +1,3 @@ -/*! For license information please see main.24f1d8e6.js.LICENSE.txt */ -(function(){var __webpack_modules__={4989:function(e,t,r){"use strict";var n={};r.r(n),r.d(n,{identity:function(){return pt}});var i={};r.r(i),r.d(i,{base2:function(){return vt}});var o={};r.r(o),r.d(o,{base8:function(){return gt}});var a={};r.r(a),r.d(a,{base10:function(){return yt}});var s={};r.r(s),r.d(s,{base16:function(){return mt},base16upper:function(){return bt}});var u={};r.r(u),r.d(u,{base32:function(){return wt},base32hex:function(){return _t},base32hexpad:function(){return At},base32hexpadupper:function(){return It},base32hexupper:function(){return St},base32pad:function(){return Et},base32padupper:function(){return xt},base32upper:function(){return kt},base32z:function(){return Ct}});var c={};r.r(c),r.d(c,{base36:function(){return Tt},base36upper:function(){return Pt}});var l={};r.r(l),r.d(l,{base58btc:function(){return Rt},base58flickr:function(){return Bt}});var f={};r.r(f),r.d(f,{base64:function(){return Mt},base64pad:function(){return Nt},base64url:function(){return Ot},base64urlpad:function(){return Dt}});var h={};r.r(h),r.d(h,{base256emoji:function(){return zt}});var d={};r.r(d),r.d(d,{sha256:function(){return cr},sha512:function(){return lr}});var p={};r.r(p),r.d(p,{identity:function(){return hr}});var v={};r.r(v),r.d(v,{code:function(){return pr},decode:function(){return gr},encode:function(){return vr},name:function(){return dr}});var g={};r.r(g),r.d(g,{code:function(){return wr},decode:function(){return Er},encode:function(){return kr},name:function(){return br}});var y={};r.r(y),r.d(y,{decode:function(){return Un},encode:function(){return On}});var m={};r.r(m),r.d(m,{RsaPrivateKey:function(){return fo},RsaPublicKey:function(){return lo},fromJwk:function(){return go},generateKeyPair:function(){return mo},unmarshalRsaPrivateKey:function(){return ho},unmarshalRsaPublicKey:function(){return vo}});var b={};r.r(b),r.d(b,{Ed25519PrivateKey:function(){return Na},Ed25519PublicKey:function(){return Ma},generateKeyPair:function(){return La},generateKeyPairFromSeed:function(){return Fa},unmarshalEd25519PrivateKey:function(){return Oa},unmarshalEd25519PublicKey:function(){return Da}});var w={};r.r(w),r.d(w,{Secp256k1PrivateKey:function(){return Qa},Secp256k1PublicKey:function(){return Wa},generateKeyPair:function(){return Xa},unmarshalSecp256k1PrivateKey:function(){return Ja},unmarshalSecp256k1PublicKey:function(){return Ya}});var k=r(5151),E=r.t(k,2),x=r(7874),_=r(6097),S=r(7324);function A(e){if(Array.isArray(e))return e}function I(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);rX;)n&$&&(i=i.add(o)),o=o.double(),n>>=$;return i}for(var a=Be(n),s=a.k1neg,u=a.k1,c=a.k2neg,l=a.k2,f=r,h=r,d=this;u>X||l>X;)u&$&&(f=f.add(d)),l&$&&(h=h.add(d)),d=d.double(),u>>=$,l>>=$;return s&&(f=f.negate()),c&&(h=h.negate()),h=new e(Se(h.x*ne.beta),h.y,h.z),f.add(h)}},{key:"precomputeWindow",value:function(e){for(var t=oe?128/e+1:256/e+1,r=[],n=this,i=n,o=0;o>=f,p>u&&(p-=l,t+=$),0===p){var v=i[d];h%2&&(v=v.negate()),a=a.add(v)}else{var g=i[d+Math.abs(p)-1];p<0&&(g=g.negate()),o=o.add(g)}}return{p:o,f:a}}},{key:"multiply",value:function(t,r){var n,i,o=_e(t);if(oe){var a=Be(o),s=a.k1neg,u=a.k1,c=a.k2neg,l=a.k2,f=this.wNAF(u,r),h=f.p,d=f.f,p=this.wNAF(l,r),v=p.p,g=p.f;s&&(h=h.negate()),c&&(v=v.negate()),v=new e(Se(v.x*ne.beta),v.y,v.z),n=h.add(v),i=d.add(g)}else{var y=this.wNAF(o,r);n=y.p,i=y.f}return e.normalizeZ([n,i])[0]}},{key:"toAffine",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Ie(this.z),t=this.x,r=this.y,n=this.z,i=e,o=Se(i*i),a=Se(o*i),s=Se(t*o),u=Se(r*a),c=Se(n*i);if(c!==$)throw new Error("invZ was invalid");return new ce(s,u)}}],[{key:"fromAffine",value:function(t){if(!(t instanceof ce))throw new TypeError("JacobianPoint#fromAffine: expected Point");return new e(t.x,t.y,$)}},{key:"toAffineBatch",value:function(e){var t=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:ne.P,r=new Array(e.length),n=e.reduce((function(e,n,i){return n===X?e:(r[i]=e,Se(e*n,t))}),$),i=Ie(n,t);return e.reduceRight((function(e,n,i){return n===X?e:(r[i]=Se(e*r[i],t),Se(e*n,t))}),i),r}(e.map((function(e){return e.z})));return e.map((function(e,r){return e.toAffine(t[r])}))}},{key:"normalizeZ",value:function(t){return e.toAffineBatch(t).map(e.fromAffine)}}]),e}();se.BASE=new se(ne.Gx,ne.Gy,$),se.ZERO=new se(X,$,X);var ue=new WeakMap,ce=function(){function e(t,r){(0,F.Z)(this,e),this.x=t,this.y=r}return(0,U.Z)(e,[{key:"_setWindowSize",value:function(e){this._WINDOW_SIZE=e,ue.delete(this)}},{key:"hasEvenY",value:function(){return this.y%ee===X}},{key:"toRawBytes",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return ke(this.toHex(e))}},{key:"toHex",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=ye(this.x);if(e){var r=this.hasEvenY()?"02":"03";return"".concat(r).concat(t)}return"04".concat(t).concat(ye(this.y))}},{key:"toHexX",value:function(){return this.toHex(!0).slice(2)}},{key:"toRawX",value:function(){return this.toRawBytes(!0).slice(1)}},{key:"assertValidity",value:function(){var e="Point is not on elliptic curve",t=this.x,r=this.y;if(!De(t)||!De(r))throw new Error(e);var n=Se(r*r);if(Se(n-ie(t))!==X)throw new Error(e)}},{key:"equals",value:function(e){return this.x===e.x&&this.y===e.y}},{key:"negate",value:function(){return new e(this.x,Se(-this.y))}},{key:"double",value:function(){return se.fromAffine(this).double().toAffine()}},{key:"add",value:function(e){return se.fromAffine(this).add(se.fromAffine(e)).toAffine()}},{key:"subtract",value:function(e){return this.add(e.negate())}},{key:"multiply",value:function(e){return se.fromAffine(this).multiply(e,this).toAffine()}},{key:"multiplyAndAddUnsafe",value:function(t,r,n){var i=se.fromAffine(this),o=r===X||r===$||this!==e.BASE?i.multiplyUnsafe(r):i.multiply(r),a=se.fromAffine(t).multiplyUnsafe(n),s=o.add(a);return s.equals(se.ZERO)?void 0:s.toAffine()}}],[{key:"fromCompressedHex",value:function(t){var r=32===t.length,n=Ee(r?t:t.subarray(1));if(!De(n))throw new Error("Point is not on curve");var i=function(e){var t=ne.P,r=BigInt(6),n=BigInt(11),i=BigInt(22),o=BigInt(23),a=BigInt(44),s=BigInt(88),u=e*e*e%t,c=u*u*e%t,l=Ae(c,te)*c%t,f=Ae(l,te)*c%t,h=Ae(f,ee)*u%t,d=Ae(h,n)*h%t,p=Ae(d,i)*d%t,v=Ae(p,a)*p%t,g=Ae(v,s)*v%t,y=Ae(g,a)*p%t,m=Ae(y,te)*c%t,b=Ae(m,o)*d%t,w=Ae(b,r)*u%t;return Ae(w,ee)}(ie(n)),o=(i&$)===$;r?o&&(i=Se(-i)):1===(1&t[0])!==o&&(i=Se(-i));var a=new e(n,i);return a.assertValidity(),a}},{key:"fromUncompressedHex",value:function(t){var r=new e(Ee(t.subarray(1,33)),Ee(t.subarray(33,65)));return r.assertValidity(),r}},{key:"fromHex",value:function(e){var t=xe(e),r=t.length,n=t[0];if(32===r||33===r&&(2===n||3===n))return this.fromCompressedHex(t);if(65===r&&4===n)return this.fromUncompressedHex(t);throw new Error("Point.fromHex: received invalid point. Expected 32-33 compressed bytes or 65 uncompressed bytes, not ".concat(r))}},{key:"fromPrivateKey",value:function(t){return e.BASE.multiply(Ue(t))}},{key:"fromSignature",value:function(t,r,n){var i=Me(t=xe(t)),o=ze(r),a=o.r,s=o.s;if(0!==n&&1!==n)throw new Error("Cannot recover signature: invalid recovery bit");var u=1&n?"03":"02",c=e.fromHex(u+ye(a)),l=ne.n,f=Ie(a,l),h=Se(-i*f,l),d=Se(s*f,l),p=e.BASE.multiplyAndAddUnsafe(c,h,d);if(!p)throw new Error("Cannot recover signature: point at infinify");return p.assertValidity(),p}}]),e}();function le(e){return Number.parseInt(e[0],16)>=8?"00"+e:e}function fe(e){if(e.length<2||2!==e[0])throw new Error("Invalid signature integer tag: ".concat(ve(e)));var t=e[1],r=e.subarray(2,t+2);if(!t||r.length!==t)throw new Error("Invalid signature integer: wrong length");if(0===r[0]&&r[1]<=127)throw new Error("Invalid signature integer: trailing length");return{data:Ee(r),left:e.subarray(t+2)}}ce.BASE=new ce(ne.Gx,ne.Gy),ce.ZERO=new ce(X,X);var he=function(){function e(t,r){(0,F.Z)(this,e),this.r=t,this.s=r,this.assertValidity()}return(0,U.Z)(e,[{key:"assertValidity",value:function(){var e=this.r,t=this.s;if(!Oe(e))throw new Error("Invalid Signature: r must be 0 < r < n");if(!Oe(t))throw new Error("Invalid Signature: s must be 0 < s < n")}},{key:"hasHighS",value:function(){var e=ne.n>>$;return this.s>e}},{key:"normalizeS",value:function(){return this.hasHighS()?new e(this.r,ne.n-this.s):this}},{key:"toDERRawBytes",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return ke(this.toDERHex(e))}},{key:"toDERHex",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=le(be(this.s));if(e)return t;var r=le(be(this.r)),n=be(r.length/2),i=be(t.length/2),o=be(r.length/2+t.length/2+4);return"30".concat(o,"02").concat(n).concat(r,"02").concat(i).concat(t)}},{key:"toRawBytes",value:function(){return this.toDERRawBytes()}},{key:"toHex",value:function(){return this.toDERHex()}},{key:"toCompactRawBytes",value:function(){return ke(this.toCompactHex())}},{key:"toCompactHex",value:function(){return ye(this.r)+ye(this.s)}}],[{key:"fromCompact",value:function(t){var r=t instanceof Uint8Array,n="Signature.fromCompact";if("string"!==typeof t&&!r)throw new TypeError("".concat(n,": Expected string or Uint8Array"));var i=r?ve(t):t;if(128!==i.length)throw new Error("".concat(n,": Expected 64-byte hex"));return new e(we(i.slice(0,64)),we(i.slice(64,128)))}},{key:"fromDER",value:function(t){var r=t instanceof Uint8Array;if("string"!==typeof t&&!r)throw new TypeError("Signature.fromDER: Expected string or Uint8Array");var n=function(e){if(e.length<2||48!=e[0])throw new Error("Invalid signature tag: ".concat(ve(e)));if(e[1]!==e.length-2)throw new Error("Invalid signature: incorrect length");var t=fe(e.subarray(2)),r=t.data,n=fe(t.left),i=n.data,o=n.left;if(o.length)throw new Error("Invalid signature: left bytes after parsing: ".concat(ve(o)));return{r:r,s:i}}(r?t:ke(t));return new e(n.r,n.s)}},{key:"fromHex",value:function(e){return this.fromDER(e)}}]),e}();function de(){for(var e=arguments.length,t=new Array(e),r=0;r0)return BigInt(e);if("bigint"===typeof e&&Oe(e))return e;throw new TypeError("Expected valid private scalar: 0 < scalar < curve.n")}function Se(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:ne.P,r=e%t;return r>=X?r:t+r}function Ae(e,t){for(var r=ne.P,n=e;t-- >X;)n*=n,n%=r;return n}function Ie(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:ne.P;if(e===X||t<=X)throw new Error("invert: expected positive integers, got n=".concat(e," mod=").concat(t));for(var r=Se(e,t),n=t,i=X,o=$,a=$,s=X;r!==X;){var u=n/r,c=n%r,l=i-a*u,f=o-s*u;n=r,r=c,i=a,o=s,a=l,s=f}var h=n;if(h!==$)throw new Error("invert: does not exist");return Se(i,t)}var Ce,Te,Pe=function(e,t){return(e+t/ee)/t},Re={a1:BigInt("0x3086d221a7d46bcde86c90e49284eb15"),b1:-$*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),a2:BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),b2:BigInt("0x3086d221a7d46bcde86c90e49284eb15"),POW_2_128:BigInt("0x100000000000000000000000000000000")};function Be(e){var t=ne.n,r=Re.a1,n=Re.b1,i=Re.a2,o=Re.b2,a=Re.POW_2_128,s=Pe(o*e,t),u=Pe(-n*e,t),c=Se(e-s*r-u*i,t),l=Se(-s*n-u*o,t),f=c>a,h=l>a;if(f&&(c=t-c),h&&(l=t-l),c>a||l>a)throw new Error("splitScalarEndo: Endomorphism failed, k="+e);return{k1neg:f,k1:c,k2neg:h,k2:l}}function Me(e){var t=ne.n,r=8*e.length-256,n=Ee(e);return r>0&&(n>>=BigInt(r)),n>=t&&(n-=t),n}var Ne=function(){function e(){(0,F.Z)(this,e),this.v=new Uint8Array(32).fill(1),this.k=new Uint8Array(32).fill(0),this.counter=0}return(0,U.Z)(e,[{key:"hmac",value:function(){for(var e=arguments.length,t=new Array(e),r=0;r=1e3)throw new Error("Tried 1,000 k values for sign(), all were invalid");this.counter+=1}},{key:"reseed",value:function(){var e=(0,S.Z)((0,_.Z)().mark((function e(){var t,r=arguments;return(0,_.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=r.length>0&&void 0!==r[0]?r[0]:new Uint8Array,e.next=3,this.hmac(this.v,Uint8Array.from([0]),t);case 3:return this.k=e.sent,e.next=6,this.hmac(this.v);case 6:if(this.v=e.sent,0!==t.length){e.next=9;break}return e.abrupt("return");case 9:return e.next=11,this.hmac(this.v,Uint8Array.from([1]),t);case 11:return this.k=e.sent,e.next=14,this.hmac(this.v);case 14:this.v=e.sent;case 15:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}()},{key:"reseedSync",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new Uint8Array;this.checkSync(),this.k=this.hmacSync(this.v,Uint8Array.from([0]),e),this.v=this.hmacSync(this.v),0!==e.length&&(this.k=this.hmacSync(this.v,Uint8Array.from([1]),e),this.v=this.hmacSync(this.v))}},{key:"generate",value:function(){var e=(0,S.Z)((0,_.Z)().mark((function e(){return(0,_.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.incr(),e.next=3,this.hmac(this.v);case 3:return this.v=e.sent,e.abrupt("return",this.v);case 5:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}()},{key:"generateSync",value:function(){return this.checkSync(),this.incr(),this.v=this.hmacSync(this.v),this.v}}]),e}();function Oe(e){return X0)t=BigInt(e);else if("string"===typeof e){if(64!==e.length)throw new Error("Expected 32 bytes of private key");t=we(e)}else{if(!(e instanceof Uint8Array))throw new TypeError("Expected valid private key");if(32!==e.length)throw new Error("Expected 32 bytes of private key");t=Ee(e)}if(!Oe(t))throw new Error("Expected private key: 0 < key < n");return t}function Fe(e){return e instanceof ce?(e.assertValidity(),e):ce.fromHex(e)}function ze(e){if(e instanceof he)return e.assertValidity(),e;try{return he.fromDER(e)}catch(t){return he.fromCompact(e)}}function Ze(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return ce.fromPrivateKey(e).toRawBytes(t)}function je(e){return Ee(e.length>32?e.slice(0,32):e)}function qe(e){var t=je(e),r=Se(t,ne.n);return Ke(r2&&void 0!==l[2]?l[2]:{},i=Ve(t,r,n.extraEntropy),o=i.seed,a=i.m,s=i.d,c=new Ne,e.next=5,c.reseed(o);case 5:return e.t0=Le,e.next=8,c.generate();case 8:if(e.t1=e.sent,e.t2=a,e.t3=s,u=(0,e.t0)(e.t1,e.t2,e.t3)){e.next=16;break}return e.next=14,c.reseed();case 14:e.next=5;break;case 16:return e.abrupt("return",He(u,n));case 17:case"end":return e.stop()}}),e)}))),We.apply(this,arguments)}var Qe={strict:!0};function Je(e,t,r){var n,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:Qe;try{n=ze(e),t=xe(t)}catch(g){return!1}var o=n,a=o.r,s=o.s;if(i.strict&&n.hasHighS())return!1;var u,c=Me(t);try{u=Fe(r)}catch(g){return!1}var l=ne.n,f=Ie(s,l),h=Se(c*f,l),d=Se(a*f,l),p=ce.BASE.multiplyAndAddUnsafe(u,h,d);if(!p)return!1;var v=Se(p.x,l);return v===a}ce.BASE._setWindowSize(8);var Ye={node:Y,web:"object"===typeof self&&"crypto"in self?self.crypto:void 0},Xe={},$e={bytesToHex:ve,hexToBytes:ke,concatBytes:de,mod:Se,invert:Ie,isValidPrivateKey:function(e){try{return Ue(e),!0}catch(t){return!1}},_bigintTo32Bytes:me,_normalizePrivateKey:Ue,hashToPrivateKey:function(e){if((e=xe(e)).length<40||e.length>1024)throw new Error("Expected 40-1024 bytes of private key as per FIPS 186");return me(Se(Ee(e),ne.n-$)+$)},randomBytes:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:32;if(Ye.web)return Ye.web.getRandomValues(new Uint8Array(e));if(Ye.node){var t=Ye.node.randomBytes;return Uint8Array.from(t(e))}throw new Error("The environment doesn't have randomBytes function")},randomPrivateKey:function(){return $e.hashToPrivateKey($e.randomBytes(40))},sha256:function(){var e=(0,S.Z)((0,_.Z)().mark((function e(){var t,r,n,i,o,a,s=arguments;return(0,_.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(t=s.length,r=new Array(t),n=0;n1?r-1:0),i=1;i1?i-1:0),a=1;a1?n-1:0),o=1;o0&&void 0!==arguments[0]?arguments[0]:8,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:ce.BASE,r=t===ce.BASE?t:new ce(t.x,t.y);return r._setWindowSize(e),r.multiply(te),r}};Object.defineProperties($e,{sha256Sync:{configurable:!1,get:function(){return Ce},set:function(e){Ce||(Ce=e)}},hmacSha256Sync:{configurable:!1,get:function(){return Te},set:function(e){Te||(Te=e)}}});var et=r(6984),tt=r.n(et);function rt(e,t){var r="undefined"!==typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=C(e))||t&&e&&"number"===typeof e.length){r&&(e=r);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return a=e.done,e},e:function(e){s=!0,o=e},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw o}}}}var nt=function(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n>>0,a=new Uint8Array(o);e[t];){var l=r[e.charCodeAt(t)];if(255===l)return;for(var f=0,h=o-1;(0!==l||f>>0,a[h]=l%256>>>0,l=l/256>>>0;if(0!==l)throw new Error("Non-zero carry");i=f,t++}if(" "!==e[t]){for(var d=o-i;d!==o&&0===a[d];)d++;for(var p=new Uint8Array(n+(o-d)),v=n;d!==o;)p[v++]=a[d++];return p}}}return{encode:function(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===t.length)return"";for(var r=0,n=0,i=0,o=t.length;i!==o&&0===t[i];)i++,r++;for(var a=(o-i)*l+1>>>0,c=new Uint8Array(a);i!==o;){for(var f=t[i],h=0,d=a-1;(0!==f||h>>0,c[d]=f%s>>>0,f=f/s>>>0;if(0!==f)throw new Error("Non-zero carry");n=h,i++}for(var p=a-n;p!==a&&0===c[p];)p++;for(var v=u.repeat(r);pr;)o+=t[i&s>>(a-=r)];if(a&&(o+=t[i&s<=8&&(u-=8,s[l++]=255&c>>u)}if(u>=r||255&c<<8-u)throw new SyntaxError("Unexpected end of data");return s}(e,i,n,t)}})},pt=ft({prefix:"\0",name:"identity",encode:function(e){return t=e,(new TextDecoder).decode(t);var t},decode:function(e){return function(e){return(new TextEncoder).encode(e)}(e)}}),vt=dt({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),gt=dt({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),yt=ht({prefix:"9",name:"base10",alphabet:"0123456789"}),mt=dt({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),bt=dt({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),wt=dt({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),kt=dt({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Et=dt({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),xt=dt({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),_t=dt({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),St=dt({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),At=dt({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),It=dt({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Ct=dt({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),Tt=ht({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Pt=ht({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),Rt=ht({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Bt=ht({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),Mt=dt({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Nt=dt({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Ot=dt({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Dt=dt({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),Lt=Array.from("\ud83d\ude80\ud83e\ude90\u2604\ud83d\udef0\ud83c\udf0c\ud83c\udf11\ud83c\udf12\ud83c\udf13\ud83c\udf14\ud83c\udf15\ud83c\udf16\ud83c\udf17\ud83c\udf18\ud83c\udf0d\ud83c\udf0f\ud83c\udf0e\ud83d\udc09\u2600\ud83d\udcbb\ud83d\udda5\ud83d\udcbe\ud83d\udcbf\ud83d\ude02\u2764\ud83d\ude0d\ud83e\udd23\ud83d\ude0a\ud83d\ude4f\ud83d\udc95\ud83d\ude2d\ud83d\ude18\ud83d\udc4d\ud83d\ude05\ud83d\udc4f\ud83d\ude01\ud83d\udd25\ud83e\udd70\ud83d\udc94\ud83d\udc96\ud83d\udc99\ud83d\ude22\ud83e\udd14\ud83d\ude06\ud83d\ude44\ud83d\udcaa\ud83d\ude09\u263a\ud83d\udc4c\ud83e\udd17\ud83d\udc9c\ud83d\ude14\ud83d\ude0e\ud83d\ude07\ud83c\udf39\ud83e\udd26\ud83c\udf89\ud83d\udc9e\u270c\u2728\ud83e\udd37\ud83d\ude31\ud83d\ude0c\ud83c\udf38\ud83d\ude4c\ud83d\ude0b\ud83d\udc97\ud83d\udc9a\ud83d\ude0f\ud83d\udc9b\ud83d\ude42\ud83d\udc93\ud83e\udd29\ud83d\ude04\ud83d\ude00\ud83d\udda4\ud83d\ude03\ud83d\udcaf\ud83d\ude48\ud83d\udc47\ud83c\udfb6\ud83d\ude12\ud83e\udd2d\u2763\ud83d\ude1c\ud83d\udc8b\ud83d\udc40\ud83d\ude2a\ud83d\ude11\ud83d\udca5\ud83d\ude4b\ud83d\ude1e\ud83d\ude29\ud83d\ude21\ud83e\udd2a\ud83d\udc4a\ud83e\udd73\ud83d\ude25\ud83e\udd24\ud83d\udc49\ud83d\udc83\ud83d\ude33\u270b\ud83d\ude1a\ud83d\ude1d\ud83d\ude34\ud83c\udf1f\ud83d\ude2c\ud83d\ude43\ud83c\udf40\ud83c\udf37\ud83d\ude3b\ud83d\ude13\u2b50\u2705\ud83e\udd7a\ud83c\udf08\ud83d\ude08\ud83e\udd18\ud83d\udca6\u2714\ud83d\ude23\ud83c\udfc3\ud83d\udc90\u2639\ud83c\udf8a\ud83d\udc98\ud83d\ude20\u261d\ud83d\ude15\ud83c\udf3a\ud83c\udf82\ud83c\udf3b\ud83d\ude10\ud83d\udd95\ud83d\udc9d\ud83d\ude4a\ud83d\ude39\ud83d\udde3\ud83d\udcab\ud83d\udc80\ud83d\udc51\ud83c\udfb5\ud83e\udd1e\ud83d\ude1b\ud83d\udd34\ud83d\ude24\ud83c\udf3c\ud83d\ude2b\u26bd\ud83e\udd19\u2615\ud83c\udfc6\ud83e\udd2b\ud83d\udc48\ud83d\ude2e\ud83d\ude46\ud83c\udf7b\ud83c\udf43\ud83d\udc36\ud83d\udc81\ud83d\ude32\ud83c\udf3f\ud83e\udde1\ud83c\udf81\u26a1\ud83c\udf1e\ud83c\udf88\u274c\u270a\ud83d\udc4b\ud83d\ude30\ud83e\udd28\ud83d\ude36\ud83e\udd1d\ud83d\udeb6\ud83d\udcb0\ud83c\udf53\ud83d\udca2\ud83e\udd1f\ud83d\ude41\ud83d\udea8\ud83d\udca8\ud83e\udd2c\u2708\ud83c\udf80\ud83c\udf7a\ud83e\udd13\ud83d\ude19\ud83d\udc9f\ud83c\udf31\ud83d\ude16\ud83d\udc76\ud83e\udd74\u25b6\u27a1\u2753\ud83d\udc8e\ud83d\udcb8\u2b07\ud83d\ude28\ud83c\udf1a\ud83e\udd8b\ud83d\ude37\ud83d\udd7a\u26a0\ud83d\ude45\ud83d\ude1f\ud83d\ude35\ud83d\udc4e\ud83e\udd32\ud83e\udd20\ud83e\udd27\ud83d\udccc\ud83d\udd35\ud83d\udc85\ud83e\uddd0\ud83d\udc3e\ud83c\udf52\ud83d\ude17\ud83e\udd11\ud83c\udf0a\ud83e\udd2f\ud83d\udc37\u260e\ud83d\udca7\ud83d\ude2f\ud83d\udc86\ud83d\udc46\ud83c\udfa4\ud83d\ude47\ud83c\udf51\u2744\ud83c\udf34\ud83d\udca3\ud83d\udc38\ud83d\udc8c\ud83d\udccd\ud83e\udd40\ud83e\udd22\ud83d\udc45\ud83d\udca1\ud83d\udca9\ud83d\udc50\ud83d\udcf8\ud83d\udc7b\ud83e\udd10\ud83e\udd2e\ud83c\udfbc\ud83e\udd75\ud83d\udea9\ud83c\udf4e\ud83c\udf4a\ud83d\udc7c\ud83d\udc8d\ud83d\udce3\ud83e\udd42"),Ut=Lt.reduce((function(e,t,r){return e[r]=t,e}),[]),Ft=Lt.reduce((function(e,t,r){return e[t.codePointAt(0)]=r,e}),[]);var zt=ft({prefix:"\ud83d\ude80",name:"base256emoji",encode:function(e){return e.reduce((function(e,t){return e+=Ut[t]}),"")},decode:function(e){var t,r=[],n=rt(e);try{for(n.s();!(t=n.n()).done;){var i=t.value,o=Ft[i.codePointAt(0)];if(void 0===o)throw new Error("Non-base256emoji character: ".concat(i));r.push(o)}}catch(a){n.e(a)}finally{n.f()}return new Uint8Array(r)}}),Zt=function e(t,r,n){r=r||[];var i=n=n||0;for(;t>=jt;)r[n++]=255&t|128,t/=128;for(;-128&t;)r[n++]=255&t|128,t>>>=7;return r[n]=0|t,e.bytes=n-i+1,r},jt=Math.pow(2,31);var qt=function e(t,r){var n,i=0,o=0,a=r=r||0,s=t.length;do{if(a>=s)throw e.bytes=0,new RangeError("Could not decode varint");n=t[a++],i+=o<28?(127&n)<=128);return e.bytes=a-r,i};var Kt=Math.pow(2,7),Vt=Math.pow(2,14),Ht=Math.pow(2,21),Gt=Math.pow(2,28),Wt=Math.pow(2,35),Qt=Math.pow(2,42),Jt=Math.pow(2,49),Yt=Math.pow(2,56),Xt=Math.pow(2,63),$t={encode:Zt,decode:qt,encodingLength:function(e){return e1&&void 0!==arguments[1]?arguments[1]:0,r=$t.decode(e,t);return[r,$t.decode.bytes]},tr=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return $t.encode(e,t,r),t},rr=function(e){return $t.encodingLength(e)},nr=function(e,t){var r=t.byteLength,n=rr(e),i=n+rr(r),o=new Uint8Array(i+r);return tr(e,o,0),tr(r,o,n),o.set(t,i),new or(e,r,t,o)},ir=function(e){var t=ot(e),r=P(er(t),2),n=r[0],i=r[1],o=P(er(t.subarray(i)),2),a=o[0],s=o[1],u=t.subarray(i+s);if(u.byteLength!==a)throw new Error("Incorrect length");return new or(n,a,u,t)},or=(0,U.Z)((function e(t,r,n,i){(0,F.Z)(this,e),this.code=t,this.size=r,this.digest=n,this.bytes=i})),ar=function(e){var t=e.name,r=e.code,n=e.encode;return new sr(t,r,n)},sr=function(){function e(t,r,n){(0,F.Z)(this,e),this.name=t,this.code=r,this.encode=n}return(0,U.Z)(e,[{key:"digest",value:function(e){var t=this;if(e instanceof Uint8Array){var r=this.encode(e);return r instanceof Uint8Array?nr(this.code,r):r.then((function(e){return nr(t.code,e)}))}throw Error("Unknown type, must be binary type")}}]),e}(),ur=function(e){return function(){var t=(0,S.Z)((0,_.Z)().mark((function t(r){return(0,_.Z)().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.t0=Uint8Array,t.next=3,crypto.subtle.digest(e,r);case 3:return t.t1=t.sent,t.abrupt("return",new t.t0(t.t1));case 5:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()},cr=ar({name:"sha2-256",code:18,encode:ur("SHA-256")}),lr=ar({name:"sha2-512",code:19,encode:ur("SHA-512")}),fr=ot,hr={code:0,name:"identity",encode:fr,digest:function(e){return nr(0,fr(e))}},dr="raw",pr=85,vr=function(e){return ot(e)},gr=function(e){return ot(e)},yr=new TextEncoder,mr=new TextDecoder,br="json",wr=512,kr=function(e){return yr.encode(JSON.stringify(e))},Er=function(e){return JSON.parse(mr.decode(e))},xr=function(e,t){function r(e,t,n,i){(0,F.Z)(this,r),this.code=t,this.version=e,this.multihash=n,this.bytes=i,this.byteOffset=i.byteOffset,this.byteLength=i.byteLength,this.asCID=this,this._baseCache=new Map,Object.defineProperties(this,{byteOffset:Br,byteLength:Br,code:Rr,version:Rr,multihash:Rr,bytes:Rr,_baseCache:Br,asCID:Br})}return(0,U.Z)(r,[{key:"toV0",value:function(){if(0===this.version)return this;var e=this.code,t=this.multihash;if(e!==Ir)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==Cr)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return r.createV0(t)}},{key:"toV1",value:function(){switch(this.version){case 0:var e=this.multihash,t=e.code,n=e.digest,i=nr(t,n);return r.createV1(this.code,i);case 1:return this;default:throw Error("Can not convert CID version ".concat(this.version," to version 0. This is a bug please report"))}}},{key:"equals",value:function(e){return e&&this.code===e.code&&this.version===e.version&&(t=this.multihash,r=e.multihash,t===r||t.code===r.code&&t.size===r.size&&function(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:0;return null!=globalThis.Buffer&&null!=globalThis.Buffer.alloc?globalThis.Buffer.alloc(e):new Uint8Array(e)}function Lr(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return null!=globalThis.Buffer&&null!=globalThis.Buffer.allocUnsafe?globalThis.Buffer.allocUnsafe(e):new Uint8Array(e)}function Ur(e,t,r,n){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:n}}}var Fr=Ur("utf8","u",(function(e){return"u"+new TextDecoder("utf8").decode(e)}),(function(e){return(new TextEncoder).encode(e.substring(1))})),zr=Ur("ascii","a",(function(e){for(var t="a",r=0;r1&&void 0!==arguments[1]?arguments[1]:"utf8",r=Zr[t];if(!r)throw new Error('Unsupported encoding "'.concat(t,'"'));return"utf8"!==t&&"utf-8"!==t||null==globalThis.Buffer||null==globalThis.Buffer.from?r.decoder.decode("".concat(r.prefix).concat(e)):globalThis.Buffer.from(e,"utf8")}function qr(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"utf8",r=Zr[t];if(!r)throw new Error('Unsupported encoding "'.concat(t,'"'));return"utf8"!==t&&"utf-8"!==t||null==globalThis.Buffer||null==globalThis.Buffer.from?r.encoder.encode(e).substring(1):globalThis.Buffer.from(e.buffer,e.byteOffset,e.byteLength).toString("utf8")}function Kr(e){return"string"===typeof e?jr(e.replace(/^0x/i,"").toLowerCase(),"base16"):e}var Vr=function(e){return qr(e,"base16")},Hr=function(e){return qr(e,"utf8")},Gr=function(e){return jr(e,"utf8")};"object"===typeof self&&"crypto"in self&&self.crypto;var Wr=$e.randomBytes;$e.sha256;function Qr(e){return new Uint8Array(et.keccak256.arrayBuffer(e))}function Jr(e){return 64===e.length&&(e=function(e,t){var r,n=null!==t&&void 0!==t?t:e.reduce((function(e,t){return e+t.length}),0),i=new Uint8Array(n),o=0,a=rt(e);try{for(a.s();!(r=a.n()).done;){var s=r.value;i.set(s,o),o+=s.length}}catch(u){a.e(u)}finally{a.f()}return i}([new Uint8Array([4]),e],65)),ce.fromHex(e).toRawBytes(!0)}function Yr(e,t,r){try{return Je(he.fromCompact(e.slice(0,64)),t,r)}catch(n){return!1}}function Xr(e){if("undefined"!==typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function $r(e){return function(e){if(Array.isArray(e))return I(e)}(e)||Xr(e)||C(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function en(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=j(e)););return e}function tn(){return tn="undefined"!==typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,r){var n=en(e,t);if(n){var i=Object.getOwnPropertyDescriptor(n,t);return i.get?i.get.call(arguments.length<3?e:r):i.value}},tn.apply(this,arguments)}var rn=!1,nn=!1,on={debug:1,default:2,info:2,warning:3,error:4,off:5},an=on.default,sn=null;var un,cn,ln=function(){try{var e=[];if(["NFD","NFC","NFKD","NFKC"].forEach((function(t){try{if("test"!=="test".normalize(t))throw new Error("bad normalize")}catch(r){e.push(t)}})),e.length)throw new Error("missing "+e.join(", "));if(String.fromCharCode(233).normalize("NFD")!==String.fromCharCode(101,769))throw new Error("broken implementation")}catch(t){return t.message}return null}();!function(e){e.DEBUG="DEBUG",e.INFO="INFO",e.WARNING="WARNING",e.ERROR="ERROR",e.OFF="OFF"}(un||(un={})),function(e){e.UNKNOWN_ERROR="UNKNOWN_ERROR",e.NOT_IMPLEMENTED="NOT_IMPLEMENTED",e.UNSUPPORTED_OPERATION="UNSUPPORTED_OPERATION",e.NETWORK_ERROR="NETWORK_ERROR",e.SERVER_ERROR="SERVER_ERROR",e.TIMEOUT="TIMEOUT",e.BUFFER_OVERRUN="BUFFER_OVERRUN",e.NUMERIC_FAULT="NUMERIC_FAULT",e.MISSING_NEW="MISSING_NEW",e.INVALID_ARGUMENT="INVALID_ARGUMENT",e.MISSING_ARGUMENT="MISSING_ARGUMENT",e.UNEXPECTED_ARGUMENT="UNEXPECTED_ARGUMENT",e.CALL_EXCEPTION="CALL_EXCEPTION",e.INSUFFICIENT_FUNDS="INSUFFICIENT_FUNDS",e.NONCE_EXPIRED="NONCE_EXPIRED",e.REPLACEMENT_UNDERPRICED="REPLACEMENT_UNDERPRICED",e.UNPREDICTABLE_GAS_LIMIT="UNPREDICTABLE_GAS_LIMIT",e.TRANSACTION_REPLACED="TRANSACTION_REPLACED",e.ACTION_REJECTED="ACTION_REJECTED"}(cn||(cn={}));var fn="0123456789abcdef",hn=function(){function e(t){(0,F.Z)(this,e),Object.defineProperty(this,"version",{enumerable:!0,value:t,writable:!1})}return(0,U.Z)(e,[{key:"_log",value:function(e,t){var r=e.toLowerCase();null==on[r]&&this.throwArgumentError("invalid log level name","logLevel",e),an>on[r]||console.log.apply(console,t)}},{key:"debug",value:function(){for(var t=arguments.length,r=new Array(t),n=0;n>4],r+=fn[15&t[o]];i.push(e+"=Uint8Array(0x"+r+")")}else i.push(e+"="+JSON.stringify(t))}catch(u){i.push(e+"="+JSON.stringify(n[e].toString()))}})),i.push("code=".concat(r)),i.push("version=".concat(this.version));var o=t,a="";switch(r){case cn.NUMERIC_FAULT:a="NUMERIC_FAULT";var s=t;switch(s){case"overflow":case"underflow":case"division-by-zero":a+="-"+s;break;case"negative-power":case"negative-width":a+="-unsupported";break;case"unbound-bitwise-result":a+="-unbound-result"}break;case cn.CALL_EXCEPTION:case cn.INSUFFICIENT_FUNDS:case cn.MISSING_NEW:case cn.NONCE_EXPIRED:case cn.REPLACEMENT_UNDERPRICED:case cn.TRANSACTION_REPLACED:case cn.UNPREDICTABLE_GAS_LIMIT:a=r}a&&(t+=" [ See: https://links.ethers.org/v5-errors-"+a+" ]"),i.length&&(t+=" ("+i.join(", ")+")");var u=new Error(t);return u.reason=o,u.code=r,Object.keys(n).forEach((function(e){u[e]=n[e]})),u}},{key:"throwError",value:function(e,t,r){throw this.makeError(e,t,r)}},{key:"throwArgumentError",value:function(t,r,n){return this.throwError(t,e.errors.INVALID_ARGUMENT,{argument:r,value:n})}},{key:"assert",value:function(e,t,r,n){e||this.throwError(t,r,n)}},{key:"assertArgument",value:function(e,t,r,n){e||this.throwArgumentError(t,r,n)}},{key:"checkNormalize",value:function(t){null==t&&(t="platform missing String.prototype.normalize"),ln&&this.throwError("platform missing String.prototype.normalize",e.errors.UNSUPPORTED_OPERATION,{operation:"String.prototype.normalize",form:ln})}},{key:"checkSafeUint53",value:function(t,r){"number"===typeof t&&(null==r&&(r="value not safe"),(t<0||t>=9007199254740991)&&this.throwError(r,e.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"out-of-safe-range",value:t}),t%1&&this.throwError(r,e.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"non-integer",value:t}))}},{key:"checkArgumentCount",value:function(t,r,n){n=n?": "+n:"",tr&&this.throwError("too many arguments"+n,e.errors.UNEXPECTED_ARGUMENT,{count:t,expectedCount:r})}},{key:"checkNew",value:function(t,r){t!==Object&&null!=t||this.throwError("missing new",e.errors.MISSING_NEW,{name:r.name})}},{key:"checkAbstract",value:function(t,r){t===r?this.throwError("cannot instantiate abstract class "+JSON.stringify(r.name)+" directly; use a sub-class",e.errors.UNSUPPORTED_OPERATION,{name:t.name,operation:"new"}):t!==Object&&null!=t||this.throwError("missing new",e.errors.MISSING_NEW,{name:r.name})}}],[{key:"globalLogger",value:function(){return sn||(sn=new e("logger/5.7.0")),sn}},{key:"setCensorship",value:function(t,r){if(!t&&r&&this.globalLogger().throwError("cannot permanently disable censorship",e.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"}),rn){if(!t)return;this.globalLogger().throwError("error censorship permanent",e.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"})}nn=!!t,rn=!!r}},{key:"setLogLevel",value:function(t){var r=on[t.toLowerCase()];null!=r?an=r:e.globalLogger().warn("invalid log level - "+t)}},{key:"from",value:function(t){return new e(t)}}]),e}();hn.errors=cn,hn.levels=un;var dn=new hn("bytes/5.7.0");function pn(e){return!!e.toHexString}function vn(e){return e.slice||(e.slice=function(){var t=Array.prototype.slice.call(arguments);return vn(new Uint8Array(Array.prototype.slice.apply(e,t)))}),e}function gn(e){return En(e)&&!(e.length%2)||mn(e)}function yn(e){return"number"===typeof e&&e==e&&e%1===0}function mn(e){if(null==e)return!1;if(e.constructor===Uint8Array)return!0;if("string"===typeof e)return!1;if(!yn(e.length)||e.length<0)return!1;for(var t=0;t=256)return!1}return!0}function bn(e,t){if(t||(t={}),"number"===typeof e){dn.checkSafeUint53(e,"invalid arrayify value");for(var r=[];e;)r.unshift(255&e),e=parseInt(String(e/256));return 0===r.length&&r.push(0),vn(new Uint8Array(r))}if(t.allowMissingPrefix&&"string"===typeof e&&"0x"!==e.substring(0,2)&&(e="0x"+e),pn(e)&&(e=e.toHexString()),En(e)){var n=e.substring(2);n.length%2&&("left"===t.hexPad?n="0"+n:"right"===t.hexPad?n+="0":dn.throwArgumentError("hex data is odd-length","value",e));for(var i=[],o=0;o>4]+xn[15&o]}return n}return dn.throwArgumentError("invalid hexlify value","value",e)}function Sn(e){if("string"!==typeof e)e=_n(e);else if(!En(e)||e.length%2)return null;return(e.length-2)/2}function An(e,t,r){return"string"!==typeof e?e=_n(e):(!En(e)||e.length%2)&&dn.throwArgumentError("invalid hexData","value",e),t=2+2*t,null!=r?"0x"+e.substring(t,2+2*r):"0x"+e.substring(t)}function In(e){var t="0x";return e.forEach((function(e){t+=_n(e).substring(2)})),t}function Cn(e){var t=function(e){"string"!==typeof e&&(e=_n(e));En(e)||dn.throwArgumentError("invalid hex string","value",e);e=e.substring(2);var t=0;for(;t2*t+2&&dn.throwArgumentError("value out of range","value",arguments[1]);e.length<2*t+2;)e="0x0"+e.substring(2);return e}function Pn(e){var t={r:"0x",s:"0x",_vs:"0x",recoveryParam:0,v:0,yParityAndS:"0x",compact:"0x"};if(gn(e)){var r=bn(e);64===r.length?(t.v=27+(r[32]>>7),r[32]&=127,t.r=_n(r.slice(0,32)),t.s=_n(r.slice(32,64))):65===r.length?(t.r=_n(r.slice(0,32)),t.s=_n(r.slice(32,64)),t.v=r[64]):dn.throwArgumentError("invalid signature string","signature",e),t.v<27&&(0===t.v||1===t.v?t.v+=27:dn.throwArgumentError("signature invalid v byte","signature",e)),t.recoveryParam=1-t.v%2,t.recoveryParam&&(r[32]|=128),t._vs=_n(r.slice(32,64))}else{if(t.r=e.r,t.s=e.s,t.v=e.v,t.recoveryParam=e.recoveryParam,t._vs=e._vs,null!=t._vs){var n=function(e,t){(e=bn(e)).length>t&&dn.throwArgumentError("value out of range","value",arguments[0]);var r=new Uint8Array(t);return r.set(e,t-e.length),vn(r)}(bn(t._vs),32);t._vs=_n(n);var i=n[0]>=128?1:0;null==t.recoveryParam?t.recoveryParam=i:t.recoveryParam!==i&&dn.throwArgumentError("signature recoveryParam mismatch _vs","signature",e),n[0]&=127;var o=_n(n);null==t.s?t.s=o:t.s!==o&&dn.throwArgumentError("signature v mismatch _vs","signature",e)}if(null==t.recoveryParam)null==t.v?dn.throwArgumentError("signature missing v and recoveryParam","signature",e):0===t.v||1===t.v?t.recoveryParam=t.v:t.recoveryParam=1-t.v%2;else if(null==t.v)t.v=27+t.recoveryParam;else{var a=0===t.v||1===t.v?t.v:1-t.v%2;t.recoveryParam!==a&&dn.throwArgumentError("signature recoveryParam mismatch v","signature",e)}null!=t.r&&En(t.r)?t.r=Tn(t.r,32):dn.throwArgumentError("signature missing or invalid r","signature",e),null!=t.s&&En(t.s)?t.s=Tn(t.s,32):dn.throwArgumentError("signature missing or invalid s","signature",e);var s=bn(t.s);s[0]>=128&&dn.throwArgumentError("signature s out of range","signature",e),t.recoveryParam&&(s[0]|=128);var u=_n(s);t._vs&&(En(t._vs)||dn.throwArgumentError("signature invalid _vs","signature",e),t._vs=Tn(t._vs,32)),null==t._vs?t._vs=u:t._vs!==u&&dn.throwArgumentError("signature _vs mismatch v and s","signature",e)}return t.yParityAndS=t._vs,t.compact=t.r+t.yParityAndS.substring(2),t}var Rn=new hn("rlp/5.7.0");function Bn(e){for(var t=[];e;)t.unshift(255&e),e>>=8;return t}function Mn(e,t,r){for(var n=0,i=0;it+1+n&&Rn.throwError("child data too short",hn.errors.BUFFER_OVERRUN,{})}return{consumed:1+n,result:i}}function Ln(e,t){if(0===e.length&&Rn.throwError("data too short",hn.errors.BUFFER_OVERRUN,{}),e[t]>=248){var r=e[t]-247;t+1+r>e.length&&Rn.throwError("data short segment too short",hn.errors.BUFFER_OVERRUN,{});var n=Mn(e,t+1,r);return t+1+r+n>e.length&&Rn.throwError("data long segment too short",hn.errors.BUFFER_OVERRUN,{}),Dn(e,t,t+1+r,r+n)}if(e[t]>=192){var i=e[t]-192;return t+1+i>e.length&&Rn.throwError("data array too short",hn.errors.BUFFER_OVERRUN,{}),Dn(e,t,t+1,i)}if(e[t]>=184){var o=e[t]-183;t+1+o>e.length&&Rn.throwError("data array too short",hn.errors.BUFFER_OVERRUN,{});var a=Mn(e,t+1,o);return t+1+o+a>e.length&&Rn.throwError("data array too short",hn.errors.BUFFER_OVERRUN,{}),{consumed:1+o+a,result:_n(e.slice(t+1+o,t+1+o+a))}}if(e[t]>=128){var s=e[t]-128;return t+1+s>e.length&&Rn.throwError("data too short",hn.errors.BUFFER_OVERRUN,{}),{consumed:1+s,result:_n(e.slice(t+1,t+1+s))}}return{consumed:1,result:_n(e[t])}}function Un(e){var t=bn(e),r=Ln(t,0);return r.consumed!==t.length&&Rn.throwArgumentError("invalid rlp data","data",e),r.result}var Fn="[a-fA-F\\d:]",zn=function(e){return e&&e.includeBoundaries?"(?:(?<=\\s|^)(?=".concat(Fn,")|(?<=").concat(Fn,")(?=\\s|$))"):""},Zn="(?: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}",jn="[a-fA-F\\d]{1,4}",qn="\n(?:\n(?:".concat(jn,":){7}(?:").concat(jn,"|:)| // 1:2:3:4:5:6:7:: 1:2:3:4:5:6:7:8\n(?:").concat(jn,":){6}(?:").concat(Zn,"|:").concat(jn,"|:)| // 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\n(?:").concat(jn,":){5}(?::").concat(Zn,"|(?::").concat(jn,"){1,2}|:)| // 1:2:3:4:5:: 1:2:3:4:5::7:8 1:2:3:4:5::8 1:2:3:4:5::7:1.2.3.4\n(?:").concat(jn,":){4}(?:(?::").concat(jn,"){0,1}:").concat(Zn,"|(?::").concat(jn,"){1,3}|:)| // 1:2:3:4:: 1:2:3:4::6:7:8 1:2:3:4::8 1:2:3:4::6:7:1.2.3.4\n(?:").concat(jn,":){3}(?:(?::").concat(jn,"){0,2}:").concat(Zn,"|(?::").concat(jn,"){1,4}|:)| // 1:2:3:: 1:2:3::5:6:7:8 1:2:3::8 1:2:3::5:6:7:1.2.3.4\n(?:").concat(jn,":){2}(?:(?::").concat(jn,"){0,3}:").concat(Zn,"|(?::").concat(jn,"){1,5}|:)| // 1:2:: 1:2::4:5:6:7:8 1:2::8 1:2::4:5:6:7:1.2.3.4\n(?:").concat(jn,":){1}(?:(?::").concat(jn,"){0,4}:").concat(Zn,"|(?::").concat(jn,"){1,6}|:)| // 1:: 1::3:4:5:6:7:8 1::8 1::3:4:5:6:7:1.2.3.4\n(?::(?:(?::").concat(jn,"){0,5}:").concat(Zn,"|(?::").concat(jn,"){1,7}|:)) // ::2:3:4:5:6:7:8 ::2:3:4:5:6:7:8 ::8 ::1.2.3.4\n)(?:%[0-9a-zA-Z]{1,})? // %eth0 %1\n").replace(/\s*\/\/.*$/gm,"").replace(/\n/g,"").trim(),Kn=new RegExp("(?:^".concat(Zn,"$)|(?:^").concat(qn,"$)")),Vn=new RegExp("^".concat(Zn,"$")),Hn=new RegExp("^".concat(qn,"$")),Gn=function(e){return e&&e.exact?Kn:new RegExp("(?:".concat(zn(e)).concat(Zn).concat(zn(e),")|(?:").concat(zn(e)).concat(qn).concat(zn(e),")"),"g")};Gn.v4=function(e){return e&&e.exact?Vn:new RegExp("".concat(zn(e)).concat(Zn).concat(zn(e)),"g")},Gn.v6=function(e){return e&&e.exact?Hn:new RegExp("".concat(zn(e)).concat(qn).concat(zn(e)),"g")};var Wn=Gn;function Qn(e){var t=function(){return e.apply(void 0,arguments)};return Object.defineProperty(t,"name",{value:"functionTimeout(".concat(e.name||"",")"),configurable:!0}),t}var Jn=Object.prototype.toString;function Yn(e){return"[object RegExp]"===Jn.call(e)}var Xn={global:"g",ignoreCase:"i",multiline:"m",dotAll:"s",sticky:"y",unicode:"u"};function $n(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!Yn(e))throw new TypeError("Expected a RegExp instance");var r=Object.keys(Xn).map((function(r){return("boolean"===typeof t[r]?t[r]:e[r])?Xn[r]:""})).join(""),n=new RegExp(t.source||e.source,r);return n.lastIndex="number"===typeof t.lastIndex?t.lastIndex:e.lastIndex,n}function ei(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};r.timeout;try{return Qn((function(){return $n(e).test(t)}))()}catch(n){throw n}}var ti={timeout:400};function ri(e){return ei(Wn({exact:!0}),e.slice(0,45),ti)}function ni(e){return ei(Wn.v6({exact:!0}),e.slice(0,45),ti)}function ii(e){return ei(Wn.v4({exact:!0}),e.slice(0,15),ti)}var oi=ii,ai=ni,si=function e(t){var r,n=0;if(t=t.trim(),oi(t))r=new Uint8Array(n+4),t.split(/\./g).forEach((function(e){r[n++]=255&parseInt(e,10)}));else if(ai(t)){var i,o=t.split(":",8);for(i=0;i0;i--)s.push("0");o.splice.apply(o,s)}for(r=new Uint8Array(n+16),i=0;i>8&255,r[n++]=255&u}}if(null==r)throw new Error('invalid ip address "'.concat(t,'"'));return r},ui=-1,ci={},li={};function fi(e,t,r,n,i){return{code:e,size:t,name:r,resolvable:Boolean(n),path:Boolean(i)}}function hi(e){if("number"===typeof e){if(null!=li[e])return li[e];throw new Error("no protocol with code: ".concat(e))}if("string"===typeof e){if(null!=ci[e])return ci[e];throw new Error("no protocol with name: ".concat(e))}throw new Error("invalid protocol id type: ".concat(typeof e))}[[4,32,"ip4"],[6,16,"tcp"],[33,16,"dccp"],[41,128,"ip6"],[42,ui,"ip6zone"],[53,ui,"dns",!0],[54,ui,"dns4",!0],[55,ui,"dns6",!0],[56,ui,"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,ui,"unix",!1,!0],[421,ui,"ipfs"],[421,ui,"p2p"],[443,0,"https"],[444,96,"onion"],[445,296,"onion3"],[446,ui,"garlic64"],[460,0,"quic"],[465,0,"webtransport"],[466,ui,"certhash"],[477,0,"ws"],[478,0,"wss"],[479,0,"p2p-websocket-star"],[480,0,"http"],[777,ui,"memory"]].forEach((function(e){var t=fi.apply(void 0,$r(e));li[t.code]=t,ci[t.name]=t}));var di=r(8705);function pi(e,t){t||(t=e.reduce((function(e,t){return e+t.length}),0));var r,n=Lr(t),i=0,o=rt(e);try{for(o.s();!(r=o.n()).done;){var a=r.value;n.set(a,i),i+=a.length}}catch(s){o.e(s)}finally{o.f()}return n}function vi(e,t){switch(hi(e).code){case 4:case 41:return function(e){var t=function(e){var t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2?arguments[2]:void 0;r=~~r,n=null!==(t=n)&&void 0!==t?t:e.length-r;var i=[],o="",a=new DataView(e.buffer);if(4===n){for(var s=0;s65536)throw new Error("Port number is not in range(1, 65536)");var i=wi(n);return pi([r,i],r.length+i.length)}(t);case 445:return function(e){var t=e.split(":");if(2!==t.length)throw new Error("failed to parse onion addr: [\"'".concat(t.join('", "'),"'\"]' does not contain a port number"));if(56!==t[0].length)throw new Error("failed to parse onion addr: ".concat(t[0]," not a Tor onion3 address."));var r=wt.decode("b".concat(t[0])),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");var i=wi(n);return pi([r,i],r.length+i.length)}(t);case 466:return function(e){var t=mi.decode(e),r=Uint8Array.from(di.encode(t.length));return pi([r,t],r.length+t.length)}(t);default:return jr(t,"base16")}}var yi=Object.values(Or).map((function(e){return e.decoder})),mi=function(){var e=yi[0].or(yi[1]);return yi.slice(2).forEach((function(t){return e=e.or(t)})),e}();function bi(e){if(!ri(e))throw new Error('invalid ip address "'.concat(e,'"'));return si(e)}function wi(e){var t=new ArrayBuffer(2);return new DataView(t).setUint16(0,e),new Uint8Array(t)}function ki(e){return new DataView(e.buffer).getUint16(e.byteOffset)}function Ei(e){var t=e.slice(0,e.length-2),r=e.slice(e.length-2),n=qr(t,"base32"),i=ki(r);return"".concat(n,":").concat(i)}var xi=r(5467),_i="Invalid record id",Si=r(2989),Ai=Si.Reader;function Ii(e,t){var r=Ai.create(e instanceof Uint8Array?e:e.subarray());return t.decode(r)}["uint64","int64","sint64","fixed64","sfixed64"].forEach((function(e){var t=Ai.prototype[e];Ai.prototype[e]=function(){return BigInt(t.call(this).toString())}}));var Ci,Ti,Pi,Ri,Bi,Mi=Si.Writer;function Ni(e,t){var r=Mi.create();return t.encode(e,r,{lengthDelimited:!1}),r.finish()}function Oi(e,t,r,n){return{name:e,type:t,encode:r,decode:n}}function Di(e){function t(t){if(null==e[t.toString()])throw new Error("Invalid enum value");return e[t]}return Oi("enum",Ci.VARINT,(function(e,r){var n=t(e);r.int32(n)}),(function(e){return t(e.uint32())}))}function Li(e,t){return Oi("message",Ci.LENGTH_DELIMITED,e,t)}["uint64","int64","sint64","fixed64","sfixed64"].forEach((function(e){var t=Mi.prototype[e];Mi.prototype[e]=function(e){return t.call(this,e.toString())}})),function(e){e[e.VARINT=0]="VARINT",e[e.BIT64=1]="BIT64",e[e.LENGTH_DELIMITED=2]="LENGTH_DELIMITED",e[e.START_GROUP=3]="START_GROUP",e[e.END_GROUP=4]="END_GROUP",e[e.BIT32=5]="BIT32"}(Ci||(Ci={})),function(e){e.RSA="RSA",e.Ed25519="Ed25519",e.Secp256k1="Secp256k1"}(Ti||(Ti={})),function(e){e[e.RSA=0]="RSA",e[e.Ed25519=1]="Ed25519",e[e.Secp256k1=2]="Secp256k1"}(Pi||(Pi={})),function(e){e.codec=function(){return Di(Pi)}}(Ti||(Ti={})),function(e){var t;e.codec=function(){return null==t&&(t=Li((function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!1!==r.lengthDelimited&&t.fork(),null==e.Type)throw new Error('Protocol error: required field "Type" was not found in object');if(t.uint32(8),Ti.codec().encode(e.Type,t),null==e.Data)throw new Error('Protocol error: required field "Data" was not found in object');t.uint32(18),t.bytes(e.Data),!1!==r.lengthDelimited&&t.ldelim()}),(function(e,t){for(var r={Type:Ti.RSA,Data:new Uint8Array(0)},n=null==t?e.len:e.pos+t;e.pos>>3){case 1:r.Type=Ti.codec().decode(e);break;case 2:r.Data=e.bytes();break;default:e.skipType(7&i)}}if(null==r.Type)throw new Error('Protocol error: value for required field "Type" was not found in protobuf');if(null==r.Data)throw new Error('Protocol error: value for required field "Data" was not found in protobuf');return r}))),t},e.encode=function(t){return Ni(t,e.codec())},e.decode=function(t){return Ii(t,e.codec())}}(Ri||(Ri={})),function(e){var t;e.codec=function(){return null==t&&(t=Li((function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!1!==r.lengthDelimited&&t.fork(),null==e.Type)throw new Error('Protocol error: required field "Type" was not found in object');if(t.uint32(8),Ti.codec().encode(e.Type,t),null==e.Data)throw new Error('Protocol error: required field "Data" was not found in object');t.uint32(18),t.bytes(e.Data),!1!==r.lengthDelimited&&t.ldelim()}),(function(e,t){for(var r={Type:Ti.RSA,Data:new Uint8Array(0)},n=null==t?e.len:e.pos+t;e.pos>>3){case 1:r.Type=Ti.codec().decode(e);break;case 2:r.Data=e.bytes();break;default:e.skipType(7&i)}}if(null==r.Type)throw new Error('Protocol error: value for required field "Type" was not found in protobuf');if(null==r.Data)throw new Error('Protocol error: value for required field "Data" was not found in protobuf');return r}))),t},e.encode=function(t){return Ni(t,e.codec())},e.decode=function(t){return Ii(t,e.codec())}}(Bi||(Bi={}));r(5406),r(4392);var Ui=r(3299),Fi=r(5697),zi=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:globalThis,t=e.crypto;if(null==t||null==t.subtle)throw Object.assign(new Error("Missing Web Crypto API. The most likely cause of this error is that this page is being accessed from an insecure context (i.e. not HTTPS). For more information and possible resolutions see https://github.com/libp2p/js-libp2p-crypto/blob/master/README.md#web-crypto-api"),{code:"ERR_MISSING_WEB_CRYPTO"});return t};r(9327),r(8580);function Zi(e,t){var r=Uint8Array.from(e.abs().toByteArray());if(r=0===r[0]?r.slice(1):r,null!=t){if(r.length>t)throw new Error("byte array longer than desired length");r=pi([new Uint8Array(t-r.length),r])}return qr(r,"base64url")}function ji(e){var t=function(e,t){var r=jr(e,"base64urlpad");if(null!=t){if(r.length>t)throw new Error("byte array longer than desired length");r=pi([new Uint8Array(t-r.length),r])}return r}(e);return new Ui.jsbn.BigInteger(qr(t,"base16"),16)}var qi={"P-256":256,"P-384":384,"P-521":521};Object.keys(qi).join(" / ");function Ki(e){var t,r,n,i,o,a,s=null!==(t=null===e||void 0===e?void 0:e.algorithm)&&void 0!==t?t:"AES-GCM",u=null!==(r=null===e||void 0===e?void 0:e.keyLength)&&void 0!==r?r:16,c=null!==(n=null===e||void 0===e?void 0:e.nonceLength)&&void 0!==n?n:12,l=null!==(i=null===e||void 0===e?void 0:e.digest)&&void 0!==i?i:"SHA-256",f=null!==(o=null===e||void 0===e?void 0:e.saltLength)&&void 0!==o?o:16,h=null!==(a=null===e||void 0===e?void 0:e.iterations)&&void 0!==a?a:32767,d=zi();function p(){return(p=(0,S.Z)((0,_.Z)().mark((function e(t,r){var n,i,o,a,p,v,g;return(0,_.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=d.getRandomValues(new Uint8Array(f)),i=d.getRandomValues(new Uint8Array(c)),o={name:s,iv:i},"string"===typeof r&&(r=jr(r)),a={name:"PBKDF2",salt:n,iterations:h,hash:{name:l}},e.next=7,d.subtle.importKey("raw",r,{name:"PBKDF2"},!1,["deriveKey","deriveBits"]);case 7:return p=e.sent,e.next=10,d.subtle.deriveKey(a,p,{name:s,length:u},!0,["encrypt"]);case 10:return v=e.sent,e.next=13,d.subtle.encrypt(o,v,t);case 13:return g=e.sent,e.abrupt("return",pi([n,o.iv,new Uint8Array(g)]));case 15:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function v(){return(v=(0,S.Z)((0,_.Z)().mark((function e(t,r){var n,i,o,a,p,v,g,y;return(0,_.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.slice(0,f),i=t.slice(f,f+c),o=t.slice(f+c),a={name:s,iv:i},"string"===typeof r&&(r=jr(r)),p={name:"PBKDF2",salt:n,iterations:h,hash:{name:l}},e.next=8,d.subtle.importKey("raw",r,{name:"PBKDF2"},!1,["deriveKey","deriveBits"]);case 8:return v=e.sent,e.next=11,d.subtle.deriveKey(p,v,{name:s,length:u},!0,["decrypt"]);case 11:return g=e.sent,e.next=14,d.subtle.decrypt(a,g,o);case 14:return y=e.sent,e.abrupt("return",new Uint8Array(y));case 16:case"end":return e.stop()}}),e)})))).apply(this,arguments)}u*=8;var g={encrypt:function(e,t){return p.apply(this,arguments)},decrypt:function(e,t){return v.apply(this,arguments)}};return g}function Vi(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(var r=0;r1&&void 0!==s[1]?s[1]:"pkcs-8")){e.next=9;break}return n=new Ui.util.ByteBuffer(this.marshal()),i=Ui.asn1.fromDer(n),o=Ui.pki.privateKeyFromAsn1(i),a={algorithm:"aes256",count:1e4,saltSize:16,prfAlgorithm:"sha512"},e.abrupt("return",Ui.pki.encryptRsaPrivateKey(o,t,a));case 9:if("libp2p-key"!==r){e.next=15;break}return e.next=12,uo(this.bytes,t);case 12:return e.abrupt("return",e.sent);case 15:throw Fi(new Error("export format '".concat(r,"' is not supported")),"ERR_INVALID_EXPORT_FORMAT");case 16:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}()}]),e}();function ho(e){return po.apply(this,arguments)}function po(){return(po=(0,S.Z)((0,_.Z)().mark((function e(t){var r,n;return(0,_.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=Gi(t),e.next=3,Yi(r);case 3:return n=e.sent,e.abrupt("return",new fo(n.privateKey,n.publicKey));case 5:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function vo(e){var t=function(e){var t=Ui.asn1.fromDer(qr(e,"ascii")),r=Ui.pki.publicKeyFromAsn1(t);return{kty:"RSA",n:Zi(r.n),e:Zi(r.e)}}(e);return new lo(t)}function go(e){return yo.apply(this,arguments)}function yo(){return(yo=(0,S.Z)((0,_.Z)().mark((function e(t){var r;return(0,_.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,Yi(t);case 2:return r=e.sent,e.abrupt("return",new fo(r.privateKey,r.publicKey));case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function mo(e){return bo.apply(this,arguments)}function bo(){return bo=(0,S.Z)((0,_.Z)().mark((function e(t){var r;return(0,_.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,Qi(t);case 2:return r=e.sent,e.abrupt("return",new fo(r.privateKey,r.publicKey));case 4:case"end":return e.stop()}}),e)}))),bo.apply(this,arguments)}var wo=r(9572),ko=r.t(wo,2),Eo=BigInt(0),xo=BigInt(1),_o=BigInt(2),So=BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),Ao=Object.freeze({a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),P:BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),l:So,n:So,h:BigInt(8),Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960")}),Io=BigInt("0x10000000000000000000000000000000000000000000000000000000000000000"),Co=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),To=(BigInt("6853475219497561581579357271197624642482790079785650197046958215289687604742"),BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235")),Po=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),Ro=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),Bo=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952"),Mo=function(){function e(t,r,n,i){(0,F.Z)(this,e),this.x=t,this.y=r,this.z=n,this.t=i}return(0,U.Z)(e,[{key:"equals",value:function(e){No(e);var t=this.x,r=this.y,n=this.z,i=e.x,o=e.y,a=e.z,s=Xo(t*a),u=Xo(i*n),c=Xo(r*a),l=Xo(o*n);return s===u&&c===l}},{key:"negate",value:function(){return new e(Xo(-this.x),this.y,this.z,Xo(-this.t))}},{key:"double",value:function(){var t=this.x,r=this.y,n=this.z,i=Ao.a,o=Xo(t*t),a=Xo(r*r),s=Xo(_o*Xo(n*n)),u=Xo(i*o),c=t+r,l=Xo(Xo(c*c)-o-a),f=u+a,h=f-s,d=u-a,p=Xo(l*h),v=Xo(f*d),g=Xo(l*d);return new e(p,v,Xo(h*f),g)}},{key:"add",value:function(t){No(t);var r=this.x,n=this.y,i=this.z,o=this.t,a=t.x,s=t.y,u=t.z,c=t.t,l=Xo((n-r)*(s+a)),f=Xo((n+r)*(s-a)),h=Xo(f-l);if(h===Eo)return this.double();var d=Xo(i*_o*c),p=Xo(o*_o*u),v=p+d,g=f+l,y=p-d,m=Xo(v*h),b=Xo(g*y),w=Xo(v*y);return new e(m,b,Xo(h*g),w)}},{key:"subtract",value:function(e){return this.add(e.negate())}},{key:"precomputeWindow",value:function(e){for(var t=1+256/e,r=[],n=this,i=n,o=0;o>=f,p>u&&(p-=l,t+=xo),0===p){var v=i[d];h%2&&(v=v.negate()),a=a.add(v)}else{var g=i[d+Math.abs(p)-1];p<0&&(g=g.negate()),o=o.add(g)}}return e.normalizeZ([o,a])[0]}},{key:"multiply",value:function(e,t){return this.wNAF(aa(e,Ao.l),t)}},{key:"multiplyUnsafe",value:function(t){var r=aa(t,Ao.l,!1),n=e.BASE,i=e.ZERO;if(r===Eo)return i;if(this.equals(i)||r===xo)return this;if(this.equals(n))return this.wNAF(r);for(var o=i,a=this;r>Eo;)r&xo&&(o=o.add(a)),a=a.double(),r>>=xo;return o}},{key:"isSmallOrder",value:function(){return this.multiplyUnsafe(Ao.h).equals(e.ZERO)}},{key:"isTorsionFree",value:function(){return this.multiplyUnsafe(Ao.l).equals(e.ZERO)}},{key:"toAffine",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:$o(this.z),t=this.x,r=this.y,n=this.z,i=Xo(t*e),o=Xo(r*e),a=Xo(n*e);if(a!==xo)throw new Error("invZ was invalid");return new Fo(i,o)}},{key:"fromRistrettoBytes",value:function(){Do()}},{key:"toRistrettoBytes",value:function(){Do()}},{key:"fromRistrettoHash",value:function(){Do()}}],[{key:"fromAffine",value:function(t){if(!(t instanceof Fo))throw new TypeError("ExtendedPoint#fromAffine: expected Point");return t.equals(Fo.ZERO)?e.ZERO:new e(t.x,t.y,xo,Xo(t.x*t.y))}},{key:"toAffineBatch",value:function(e){var t=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Ao.P,r=new Array(e.length),n=e.reduce((function(e,n,i){return n===Eo?e:(r[i]=e,Xo(e*n,t))}),xo),i=$o(n,t);return e.reduceRight((function(e,n,i){return n===Eo?e:(r[i]=Xo(e*r[i],t),Xo(e*n,t))}),i),r}(e.map((function(e){return e.z})));return e.map((function(e,r){return e.toAffine(t[r])}))}},{key:"normalizeZ",value:function(e){return this.toAffineBatch(e).map(this.fromAffine)}}]),e}();function No(e){if(!(e instanceof Mo))throw new TypeError("ExtendedPoint expected")}function Oo(e){if(!(e instanceof Lo))throw new TypeError("RistrettoPoint expected")}function Do(){throw new Error("Legacy method: switch to RistrettoPoint")}Mo.BASE=new Mo(Ao.Gx,Ao.Gy,xo,Xo(Ao.Gx*Ao.Gy)),Mo.ZERO=new Mo(Eo,xo,xo,Eo);var Lo=function(){function e(t){(0,F.Z)(this,e),this.ep=t}return(0,U.Z)(e,[{key:"toRawBytes",value:function(){var e,t=this.ep,r=t.x,n=t.y,i=t.z,o=t.t,a=Xo(Xo(i+n)*Xo(i-n)),s=Xo(r*n),u=Xo(s*s),c=na(Xo(a*u)).value,l=Xo(c*a),f=Xo(c*s),h=Xo(l*f*o);if(Go(o*h)){var d=Xo(n*Co),p=Xo(r*Co);r=d,n=p,e=Xo(l*Po)}else e=f;Go(r*h)&&(n=Xo(-n));var v=Xo((i-n)*e);return Go(v)&&(v=Xo(-v)),Ho(v)}},{key:"toHex",value:function(){return qo(this.toRawBytes())}},{key:"toString",value:function(){return this.toHex()}},{key:"equals",value:function(e){Oo(e);var t=this.ep,r=e.ep,n=Xo(t.x*r.y)===Xo(t.y*r.x),i=Xo(t.y*r.y)===Xo(t.x*r.x);return n||i}},{key:"add",value:function(t){return Oo(t),new e(this.ep.add(t.ep))}},{key:"subtract",value:function(t){return Oo(t),new e(this.ep.subtract(t.ep))}},{key:"multiply",value:function(t){return new e(this.ep.multiply(t))}},{key:"multiplyUnsafe",value:function(t){return new e(this.ep.multiplyUnsafe(t))}}],[{key:"calcElligatorRistrettoMap",value:function(e){var t=Ao.d,r=Xo(Co*e*e),n=Xo((r+xo)*Ro),i=BigInt(-1),o=Xo((i-t*r)*Xo(r+t)),a=ra(n,o),s=a.isValid,u=a.value,c=Xo(u*e);Go(c)||(c=Xo(-c)),s||(u=c),s||(i=r);var l=Xo(i*(r-xo)*Bo-o),f=u*u,h=Xo((u+u)*o),d=Xo(l*To),p=Xo(xo-f),v=Xo(xo+f);return new Mo(Xo(h*v),Xo(p*d),Xo(d*v),Xo(h*p))}},{key:"hashToCurve",value:function(t){var r=Yo((t=oa(t,64)).slice(0,32)),n=this.calcElligatorRistrettoMap(r),i=Yo(t.slice(32,64)),o=this.calcElligatorRistrettoMap(i);return new e(n.add(o))}},{key:"fromHex",value:function(t){t=oa(t,32);var r=Ao.a,n=Ao.d,i="RistrettoPoint.fromHex: the hex is not valid encoding of RistrettoPoint",o=Yo(t);if(!function(e,t){if(e.length!==t.length)return!1;for(var r=0;r1&&void 0!==arguments[1])||arguments[1],n=Ao.d,i=Ao.P,o=(t=oa(t,32)).slice();o[31]=-129&t[31];var a=Wo(o);if(r&&a>=i)throw new Error("Expected 0 < hex < P");if(!r&&a>=Io)throw new Error("Expected 0 < hex < 2**256");var s=Xo(a*a),u=Xo(s-xo),c=Xo(n*s+xo),l=ra(u,c),f=l.isValid,h=l.value;if(!f)throw new Error("Point.fromHex: invalid y coordinate");var d=(h&xo)===xo,p=0!==(128&t[31]);return p!==d&&(h=Xo(-h)),new e(h,a)}},{key:"fromPrivateKey",value:function(){var e=(0,S.Z)((0,_.Z)().mark((function e(t){return(0,_.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,la(t);case 2:return e.abrupt("return",e.sent.point);case 3:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()}]),e}();Fo.BASE=new Fo(Ao.Gx,Ao.Gy),Fo.ZERO=new Fo(Eo,xo);var zo=function(){function e(t,r){(0,F.Z)(this,e),this.r=t,this.s=r,this.assertValidity()}return(0,U.Z)(e,[{key:"assertValidity",value:function(){var e=this.r,t=this.s;if(!(e instanceof Fo))throw new Error("Expected Point instance");return aa(t,Ao.l,!1),this}},{key:"toRawBytes",value:function(){var e=new Uint8Array(64);return e.set(this.r.toRawBytes()),e.set(Ho(this.s),32),e}},{key:"toHex",value:function(){return qo(this.toRawBytes())}}],[{key:"fromHex",value:function(t){var r=oa(t,64);return new e(Fo.fromHex(r.slice(0,32),!1),Wo(r.slice(32,64)))}}]),e}();function Zo(){for(var e=arguments.length,t=new Array(e),r=0;r1&&void 0!==arguments[1]?arguments[1]:Ao.P,r=e%t;return r>=Eo?r:t+r}function $o(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Ao.P;if(e===Eo||t<=Eo)throw new Error("invert: expected positive integers, got n=".concat(e," mod=").concat(t));for(var r=Xo(e,t),n=t,i=Eo,o=xo,a=xo,s=Eo;r!==Eo;){var u=n/r,c=n%r,l=i-a*u,f=o-s*u;n=r,r=c,i=a,o=s,a=l,s=f}var h=n;if(h!==xo)throw new Error("invert: does not exist");return Xo(i,t)}function ea(e,t){for(var r=Ao.P,n=e;t-- >Eo;)n*=n,n%=r;return n}function ta(e){var t=Ao.P,r=BigInt(5),n=BigInt(10),i=BigInt(20),o=BigInt(40),a=BigInt(80),s=e*e%t*e%t,u=ea(s,_o)*s%t,c=ea(u,xo)*e%t,l=ea(c,r)*c%t,f=ea(l,n)*l%t,h=ea(f,i)*f%t,d=ea(h,o)*h%t,p=ea(d,a)*d%t,v=ea(p,a)*d%t,g=ea(v,n)*l%t;return{pow_p_5_8:ea(g,_o)*e%t,b2:s}}function ra(e,t){var r=Xo(t*t*t),n=Xo(r*r*t),i=Xo(e*r*ta(e*n).pow_p_5_8),o=Xo(t*i*i),a=i,s=Xo(i*Co),u=o===e,c=o===Xo(-e),l=o===Xo(-e*Co);return u&&(i=a),(c||l)&&(i=s),Go(i)&&(i=Xo(-i)),{isValid:u||c,value:i}}function na(e){return ra(xo,e)}function ia(e){return Xo(Wo(e),Ao.l)}function oa(e,t){var r=e instanceof Uint8Array?Uint8Array.from(e):Ko(e);if("number"===typeof t&&r.length!==t)throw new Error("Expected ".concat(t," bytes"));return r}function aa(e,t){var r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if(!t)throw new TypeError("Specify max value");if("number"===typeof e&&Number.isSafeInteger(e)&&(e=BigInt(e)),"bigint"===typeof e&&e1024)throw new Error("Expected 40-1024 bytes of private key as per FIPS 186");return Xo(Wo(e),Ao.l-xo)+xo},randomBytes:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:32;if(wa.web)return wa.web.getRandomValues(new Uint8Array(e));if(wa.node){var t=wa.node.randomBytes;return new Uint8Array(t(e).buffer)}throw new Error("The environment doesn't have randomBytes function")},randomPrivateKey:function(){return ka.randomBytes(32)},sha512:function(){var e=(0,S.Z)((0,_.Z)().mark((function e(){var t,r,n=arguments;return(0,_.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=Zo.apply(void 0,n),!wa.web){e.next=8;break}return e.next=4,wa.web.subtle.digest("SHA-512",t.buffer);case 4:return r=e.sent,e.abrupt("return",new Uint8Array(r));case 8:if(!wa.node){e.next=12;break}return e.abrupt("return",Uint8Array.from(wa.node.createHash("sha512").update(t).digest()));case 12:throw new Error("The environment doesn't have sha512 function");case 13:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),precompute:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:8,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Fo.BASE,r=t.equals(Fo.BASE)?t:new Fo(t.x,t.y);return r._setWindowSize(e),r.multiply(_o),r},sha512Sync:void 0};Object.defineProperties(ka,{sha512Sync:{configurable:!1,get:function(){return Qo},set:function(e){Qo||(Qo=e)}}});var Ea=64,xa=32;function _a(){return Sa.apply(this,arguments)}function Sa(){return(Sa=(0,S.Z)((0,_.Z)().mark((function e(){var t,r,n;return(0,_.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=ka.randomPrivateKey(),e.next=3,ha(t);case 3:return r=e.sent,n=Ba(t,r),e.abrupt("return",{privateKey:n,publicKey:r});case 6:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Aa(e){return Ia.apply(this,arguments)}function Ia(){return(Ia=(0,S.Z)((0,_.Z)().mark((function e(t){var r,n,i;return(0,_.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t.length===xa){e.next=4;break}throw new TypeError('"seed" must be 32 bytes in length.');case 4:if(t instanceof Uint8Array){e.next=6;break}throw new TypeError('"seed" must be a node.js Buffer, or Uint8Array.');case 6:return r=t,e.next=9,ha(r);case 9:return n=e.sent,i=Ba(r,n),e.abrupt("return",{privateKey:i,publicKey:n});case 12:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Ca(e,t){return Ta.apply(this,arguments)}function Ta(){return(Ta=(0,S.Z)((0,_.Z)().mark((function e(t,r){var n;return(0,_.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.slice(0,xa),e.next=3,pa(r,n);case 3:return e.abrupt("return",e.sent);case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Pa(e,t,r){return Ra.apply(this,arguments)}function Ra(){return(Ra=(0,S.Z)((0,_.Z)().mark((function e(t,r,n){return(0,_.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,ma(r,n,t);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Ba(e,t){for(var r=new Uint8Array(Ea),n=0;n1&&void 0!==n[1]?n[1]:"libp2p-key")){e.next=7;break}return e.next=4,uo(this.bytes,t);case 4:return e.abrupt("return",e.sent);case 7:throw Fi(new Error("export format '".concat(r,"' is not supported")),"ERR_INVALID_EXPORT_FORMAT");case 8:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}()}]),e}();function Oa(e){if(e.length>Ea){var t=(e=Za(e,96)).slice(0,Ea),r=e.slice(Ea,e.length);return new Na(t,r)}var n=(e=Za(e,Ea)).slice(0,Ea),i=e.slice(32);return new Na(n,i)}function Da(e){return e=Za(e,32),new Ma(e)}function La(){return Ua.apply(this,arguments)}function Ua(){return(Ua=(0,S.Z)((0,_.Z)().mark((function e(){var t,r,n;return(0,_.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,_a();case 2:return t=e.sent,r=t.privateKey,n=t.publicKey,e.abrupt("return",new Na(r,n));case 6:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Fa(e){return za.apply(this,arguments)}function za(){return(za=(0,S.Z)((0,_.Z)().mark((function e(t){var r,n,i;return(0,_.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,Aa(t);case 2:return r=e.sent,n=r.privateKey,i=r.publicKey,e.abrupt("return",new Na(n,i));case 6:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Za(e,t){var r;if((e=Uint8Array.from(null!==(r=e)&&void 0!==r?r:[])).length!==t)throw Fi(new Error("Key must be a Uint8Array of length ".concat(t,", got ").concat(e.length)),"ERR_INVALID_KEY_TYPE");return e}function ja(){return $e.randomPrivateKey()}function qa(e,t){return Ka.apply(this,arguments)}function Ka(){return Ka=(0,S.Z)((0,_.Z)().mark((function e(t,r){var n,i;return(0,_.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,cr.digest(r);case 2:return n=e.sent,i=n.digest,e.prev=4,e.next=7,Ge(i,t);case 7:return e.abrupt("return",e.sent);case 10:throw e.prev=10,e.t0=e.catch(4),Fi(e.t0,"ERR_INVALID_INPUT");case 13:case"end":return e.stop()}}),e,null,[[4,10]])}))),Ka.apply(this,arguments)}function Va(e,t,r){return Ha.apply(this,arguments)}function Ha(){return Ha=(0,S.Z)((0,_.Z)().mark((function e(t,r,n){var i,o;return(0,_.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,cr.digest(n);case 3:return i=e.sent,o=i.digest,e.abrupt("return",Je(r,o,t));case 8:throw e.prev=8,e.t0=e.catch(0),Fi(e.t0,"ERR_INVALID_INPUT");case 11:case"end":return e.stop()}}),e,null,[[0,8]])}))),Ha.apply(this,arguments)}function Ga(e){try{ce.fromHex(e)}catch(t){throw Fi(t,"ERR_INVALID_PUBLIC_KEY")}}var Wa=function(){function e(t){(0,F.Z)(this,e),Ga(t),this._key=t}return(0,U.Z)(e,[{key:"verify",value:function(){var e=(0,S.Z)((0,_.Z)().mark((function e(t,r){return(0,_.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,Va(this._key,r,t);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e,this)})));return function(t,r){return e.apply(this,arguments)}}()},{key:"marshal",value:function(){return function(e){return ce.fromHex(e).toRawBytes(!0)}(this._key)}},{key:"bytes",get:function(){return Ri.encode({Type:Ti.Secp256k1,Data:this.marshal()}).subarray()}},{key:"equals",value:function(e){return Vi(this.bytes,e.bytes)}},{key:"hash",value:function(){var e=(0,S.Z)((0,_.Z)().mark((function e(){var t,r;return(0,_.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,cr.digest(this.bytes);case 2:return t=e.sent,r=t.bytes,e.abrupt("return",r);case 5:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}()}]),e}(),Qa=function(){function e(t,r){(0,F.Z)(this,e),this._key=t,this._publicKey=null!==r&&void 0!==r?r:function(e){try{return Ze(e,!0)}catch(t){throw Fi(t,"ERR_INVALID_PRIVATE_KEY")}}(t),function(e){try{Ze(e,!0)}catch(t){throw Fi(t,"ERR_INVALID_PRIVATE_KEY")}}(this._key),Ga(this._publicKey)}return(0,U.Z)(e,[{key:"sign",value:function(){var e=(0,S.Z)((0,_.Z)().mark((function e(t){return(0,_.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,qa(this._key,t);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}()},{key:"public",get:function(){return new Wa(this._publicKey)}},{key:"marshal",value:function(){return this._key}},{key:"bytes",get:function(){return Bi.encode({Type:Ti.Secp256k1,Data:this.marshal()}).subarray()}},{key:"equals",value:function(e){return Vi(this.bytes,e.bytes)}},{key:"hash",value:function(){var e=(0,S.Z)((0,_.Z)().mark((function e(){var t,r;return(0,_.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,cr.digest(this.bytes);case 2:return t=e.sent,r=t.bytes,e.abrupt("return",r);case 5:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}()},{key:"id",value:function(){var e=(0,S.Z)((0,_.Z)().mark((function e(){var t;return(0,_.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.public.hash();case 2:return t=e.sent,e.abrupt("return",qr(t,"base58btc"));case 4:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}()},{key:"export",value:function(){var e=(0,S.Z)((0,_.Z)().mark((function e(t){var r,n=arguments;return(0,_.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("libp2p-key"!==(r=n.length>1&&void 0!==n[1]?n[1]:"libp2p-key")){e.next=7;break}return e.next=4,uo(this.bytes,t);case 4:return e.abrupt("return",e.sent);case 7:throw Fi(new Error("export format '".concat(r,"' is not supported")),"ERR_INVALID_EXPORT_FORMAT");case 8:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}()}]),e}();function Ja(e){return new Qa(e)}function Ya(e){return new Wa(e)}function Xa(){return $a.apply(this,arguments)}function $a(){return($a=(0,S.Z)((0,_.Z)().mark((function e(){var t;return(0,_.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,ja();case 2:return t=e.sent,e.abrupt("return",new Qa(t));case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var es={rsa:m,ed25519:b,secp256k1:w};function ts(e){var t=Object.keys(es).join(" / ");return Fi(new Error("invalid or unsupported key type ".concat(e,". Must be ").concat(t)),"ERR_UNSUPPORTED_KEY_TYPE")}function rs(e){if("rsa"===(e=e.toLowerCase())||"ed25519"===e||"secp256k1"===e)return es[e];throw ts(e)}function ns(e){var t=Ri.decode(e),r=t.Data;switch(t.Type){case Ti.RSA:return es.rsa.unmarshalRsaPublicKey(r);case Ti.Ed25519:return es.ed25519.unmarshalEd25519PublicKey(r);case Ti.Secp256k1:return es.secp256k1.unmarshalSecp256k1PublicKey(r);default:throw ts(t.Type)}}function is(e,t){var r;return rs(t=(null!==(r=t)&&void 0!==r?r:"rsa").toLowerCase()),e.bytes}function os(e){return as.apply(this,arguments)}function as(){return(as=(0,S.Z)((0,_.Z)().mark((function e(t){var r,n;return(0,_.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=Bi.decode(t),n=r.Data,e.t0=r.Type,e.next=e.t0===Ti.RSA?5:e.t0===Ti.Ed25519?8:e.t0===Ti.Secp256k1?9:10;break;case 5:return e.next=7,es.rsa.unmarshalRsaPrivateKey(n);case 7:return e.abrupt("return",e.sent);case 8:return e.abrupt("return",es.ed25519.unmarshalEd25519PrivateKey(n));case 9:return e.abrupt("return",es.secp256k1.unmarshalSecp256k1PrivateKey(n));case 10:throw ts(r.Type);case 11:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var ss=Symbol.for("@libp2p/peer-id");var us,cs=Object.values(Or).map((function(e){return e.decoder})).reduce((function(e,t){return e.or(t)}),Or.identity.decoder),ls=function(e){function t(e){(0,F.Z)(this,t),this.type=e.type,this.multihash=e.multihash,this.privateKey=e.privateKey,Object.defineProperty(this,"string",{enumerable:!1,writable:!0})}return(0,U.Z)(t,[{key:e,get:function(){return"PeerId(".concat(this.toString(),")")}},{key:ss,get:function(){return!0}},{key:"toString",value:function(){return null==this.string&&(this.string=Rt.encode(this.multihash.bytes).slice(1)),this.string}},{key:"toCID",value:function(){return xr.createV1(114,this.multihash)}},{key:"toBytes",value:function(){return this.multihash.bytes}},{key:"toJSON",value:function(){return this.toString()}},{key:"equals",value:function(e){var t;if(e instanceof Uint8Array)return Vi(this.multihash.bytes,e);if("string"===typeof e)return ps(e).equals(this);if(null!=(null===e||void 0===e||null===(t=e.multihash)||void 0===t?void 0:t.bytes))return Vi(this.multihash.bytes,e.multihash.bytes);throw new Error("not valid Id")}}]),t}(Symbol.toStringTag),fs=function(e){Z(r,e);var t=G(r);function r(e){var n;return(0,F.Z)(this,r),(n=t.call(this,L(L({},e),{},{type:"RSA"}))).type="RSA",n.publicKey=e.publicKey,n}return(0,U.Z)(r)}(ls),hs=function(e){Z(r,e);var t=G(r);function r(e){var n;return(0,F.Z)(this,r),(n=t.call(this,L(L({},e),{},{type:"Ed25519"}))).type="Ed25519",n.publicKey=e.multihash.digest,n}return(0,U.Z)(r)}(ls),ds=function(e){Z(r,e);var t=G(r);function r(e){var n;return(0,F.Z)(this,r),(n=t.call(this,L(L({},e),{},{type:"secp256k1"}))).type="secp256k1",n.publicKey=e.multihash.digest,n}return(0,U.Z)(r)}(ls);function ps(e,t){var r;if(t=null!==(r=t)&&void 0!==r?r:cs,"1"===e.charAt(0)||"Q"===e.charAt(0)){var n=ir(Rt.decode("z".concat(e)));return e.startsWith("12D")?new hs({multihash:n}):e.startsWith("16U")?new ds({multihash:n}):new fs({multihash:n})}return vs(cs.decode(e))}function vs(e){try{var t=ir(e);if(t.code===hr.code){if(36===t.digest.length)return new hs({multihash:t});if(37===t.digest.length)return new ds({multihash:t})}if(t.code===cr.code)return new fs({multihash:t})}catch(r){return function(e){if(null==e||null==e.multihash||null==e.version||1===e.version&&114!==e.code)throw new Error("Supplied PeerID CID is invalid");var t=e.multihash;if(t.code===cr.code)return new fs({multihash:e.multihash});if(t.code===hr.code){if(36===t.digest.length)return new hs({multihash:e.multihash});if(37===t.digest.length)return new ds({multihash:e.multihash})}throw new Error("Supplied PeerID CID is invalid")}(xr.decode(e))}throw new Error("Supplied PeerID CID is invalid")}function gs(e,t){return ys.apply(this,arguments)}function ys(){return(ys=(0,S.Z)((0,_.Z)().mark((function e(t,r){return(0,_.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(36!==t.length){e.next=2;break}return e.abrupt("return",new hs({multihash:nr(hr.code,t),privateKey:r}));case 2:if(37!==t.length){e.next=4;break}return e.abrupt("return",new ds({multihash:nr(hr.code,t),privateKey:r}));case 4:return e.t0=fs,e.next=7,cr.digest(t);case 7:return e.t1=e.sent,e.t2=t,e.t3=r,e.t4={multihash:e.t1,publicKey:e.t2,privateKey:e.t3},e.abrupt("return",new e.t0(e.t4));case 12:case"end":return e.stop()}}),e)})))).apply(this,arguments)}!function(e){e[e.rsa=0]="rsa",e[e.ed25519=1]="ed25519",e[e.secp256k1=2]="secp256k1"}(us||(us={}));var ms=function(){function e(t,r){(0,F.Z)(this,e);var n=r;if(n&&(n=Jr(n)),(this._privateKey=t)&&!this.privateKeyVerify())throw new Error("Invalid private key");if((this._publicKey=n)&&!this.publicKeyVerify())throw new Error("Invalid public key");this.type=us.secp256k1}return(0,U.Z)(e,[{key:"privateKeyVerify",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this._privateKey;return!e||$e.isValidPrivateKey(e)}},{key:"publicKeyVerify",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this._publicKey;if(e)try{return ce.fromHex(e),!0}catch(t){return!1}return!0}},{key:"privateKey",get:function(){if(!this._privateKey)throw new Error;return this._privateKey}},{key:"publicKey",get:function(){if(!this._publicKey)throw new Error;return this._publicKey}},{key:"hasPrivateKey",value:function(){return!!this._privateKey}}],[{key:"generate",value:function(){var t=(0,S.Z)((0,_.Z)().mark((function t(){var r,n;return(0,_.Z)().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Wr(32),n=Ze(r),t.abrupt("return",new e(r,n));case 3:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}()}]),e}(),bs="Keypair type not implemented";function ws(e,t,r){if(e===us.secp256k1)return new ms(t,r);throw new Error(bs)}function ks(e){return Es.apply(this,arguments)}function Es(){return(Es=(0,S.Z)((0,_.Z)().mark((function e(t){var r,n;return(0,_.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:e.t0=t.type,e.next=e.t0===us.secp256k1?3:6;break;case 3:return r=new es.secp256k1.Secp256k1PublicKey(t.publicKey),n=t.hasPrivateKey()?new es.secp256k1.Secp256k1PrivateKey(t.privateKey):void 0,e.abrupt("return",gs(r.bytes,null===n||void 0===n?void 0:n.bytes));case 6:throw new Error(bs);case 7:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function xs(e){return _s.apply(this,arguments)}function _s(){return(_s=(0,S.Z)((0,_.Z)().mark((function e(t){var r,n,i;return(0,_.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:e.t0=t.type,e.next="RSA"===e.t0?3:"Ed25519"===e.t0?5:"secp256k1"===e.t0?7:9;break;case 3:return r=us.rsa,e.abrupt("break",10);case 5:return r=us.ed25519,e.abrupt("break",10);case 7:return r=us.secp256k1,e.abrupt("break",10);case 9:throw new Error("Unsupported peer id type");case 10:if(n=t.publicKey?ns(t.publicKey):void 0,!t.privateKey){e.next=17;break}return e.next=14,os(t.privateKey);case 14:e.t1=e.sent,e.next=18;break;case 17:e.t1=void 0;case 18:return i=e.t1,e.abrupt("return",ws(r,null===i||void 0===i?void 0:i.marshal(),null===n||void 0===n?void 0:n.marshal()));case 20:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Ss(e){return e.map((function(e){var t=Os(e);return null!=e[1]?[t.code,vi(t.code,e[1])]:[t.code]}))}function As(e){return Rs(pi(e.map((function(e){var t=Os(e),r=Uint8Array.from(di.encode(t.code));return e.length>1&&null!=e[1]&&(r=pi([r,e[1]])),r}))))}function Is(e,t){return e.size>0?e.size/8:0===e.size?0:di.decode(t)+di.decode.bytes}function Cs(e){for(var t=[],r=0;re.length)throw Ns("Invalid address Uint8Array: "+qr(e,"base16"));t.push([n,a])}else t.push([n]),r+=i}return t}function Ts(e){return function(e){var t=[];return e.map((function(e){var r=Os(e);return t.push(r.name),e.length>1&&null!=e[1]&&t.push(e[1]),null})),Ms(t.join("/"))}(Ss(Cs(e)))}function Ps(e){var t=function(e){var t=[],r=e.split("/").slice(1);if(1===r.length&&""===r[0])return[];for(var n=0;n=r.length)throw Ns("invalid address: "+e);if(!0===o.path){t.push([i,Ms(r.slice(n).join("/"))]);break}t.push([i,r[n]])}else t.push([i])}return t}(e=Ms(e));return As(t.map((function(e){Array.isArray(e)||(e=[e]);var t=Os(e);return e.length>1?[t.code,gi(t.code,e[1])]:[t.code]})))}function Rs(e){var t=Bs(e);if(null!=t)throw t;return Uint8Array.from(e)}function Bs(e){try{Cs(e)}catch(t){return t}}function Ms(e){return"/"+e.trim().split("/").filter((function(e){return e})).join("/")}function Ns(e){return new Error("Error parsing address: "+e)}function Os(e){return hi(e[0])}var Ds=Symbol.for("nodejs.util.inspect.custom"),Ls=[hi("dns").code,hi("dns4").code,hi("dns6").code,hi("dnsaddr").code],Us=[hi("p2p").code,hi("ipfs").code],Fs=new Map,zs=Symbol.for("@multiformats/js-multiaddr/multiaddr"),Zs=function(){function e(t){if((0,F.Z)(this,e),null==t&&(t=""),Object.defineProperty(this,zs,{value:!0}),t instanceof Uint8Array)this.bytes=Rs(t);else if("string"===typeof t){if(t.length>0&&"/"!==t.charAt(0))throw new Error('multiaddr "'.concat(t,'" must start with a "/"'));this.bytes=Ps(t)}else{if(!e.isMultiaddr(t))throw new Error("addr must be a string, Buffer, or another Multiaddr");this.bytes=Rs(t.bytes)}}return(0,U.Z)(e,[{key:"toString",value:function(){return Ts(this.bytes)}},{key:"toJSON",value:function(){return this.toString()}},{key:"toOptions",value:function(){var e,t,r=this.protoCodes(),n=this.toString().split("/").slice(1);if(n.length>2)Ls.includes(r[0])&&Us.includes(r[1])?(e=hi("tcp").name,t=443):(e=hi(n[2]).name,t=parseInt(n[3]));else{if(!Ls.includes(r[0]))throw new Error('multiaddr must have a valid format: "/{ip4, ip6, dns4, dns6, dnsaddr}/{address}/{tcp, udp}/{port}".');e=hi("tcp").name,t=443}return{family:41===r[0]||55===r[0]?6:4,host:n[1],transport:e,port:t}}},{key:"protos",value:function(){return this.protoCodes().map((function(e){return Object.assign({},hi(e))}))}},{key:"protoCodes",value:function(){for(var e=[],t=this.bytes,r=0;r=0;n--)if(r[n][0]===t)return new e(As(r.slice(0,n)));return this}},{key:"getPeerId",value:function(){try{var e=this.stringTuples().filter((function(e){return e[0]===ci.ipfs.code})),t=e.pop();if(null!=(null===t||void 0===t?void 0:t[1])){var r=t[1];return"Q"===r[0]||"1"===r[0]?qr(Rt.decode("z".concat(r)),"base58btc"):qr(xr.parse(r).multihash.bytes,"base58btc")}return null}catch(n){return null}}},{key:"getPath",value:function(){var e=null;try{null==(e=this.stringTuples().filter((function(e){return!0===hi(e[0]).path}))[0][1])&&(e=null)}catch(t){e=null}return e}},{key:"equals",value:function(e){return Vi(this.bytes,e.bytes)}},{key:"resolve",value:function(){var t=(0,S.Z)((0,_.Z)().mark((function t(r){var n,i,o;return(0,_.Z)().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(null!=(n=this.protos().find((function(e){return e.resolvable})))){t.next=3;break}return t.abrupt("return",[this]);case 3:if(null!=(i=Fs.get(n.name))){t.next=6;break}throw Fi(new Error("no available resolver for ".concat(n.name)),"ERR_NO_AVAILABLE_RESOLVER");case 6:return t.next=8,i(this,r);case 8:return o=t.sent,t.abrupt("return",o.map((function(t){return new e(t)})));case 10:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}()},{key:"nodeAddress",value:function(){var e=this.toOptions();if("tcp"!==e.transport&&"udp"!==e.transport)throw new Error('multiaddr must have a valid format - no protocol with name: "'.concat(e.transport,'". Must have a valid transport protocol: "{tcp, udp}"'));return{family:e.family,address:e.host,port:e.port}}},{key:"isThinWaistAddress",value:function(e){var t=(null!==e&&void 0!==e?e:this).protos();return 2===t.length&&((4===t[0].code||41===t[0].code)&&(6===t[1].code||273===t[1].code))}},{key:Ds,value:function(){return""}},{key:"inspect",value:function(){return""}}],[{key:"fromNodeAddress",value:function(t,r){if(null==t)throw new Error("requires node address object");if(null==r)throw new Error("requires transport protocol");var n;switch(t.family){case 4:n="ip4";break;case 6:n="ip6";break;default:throw Error("Invalid addr family, should be 4 or 6.")}return new e("/"+[n,t.address,r,t.port].join("/"))}},{key:"isName",value:function(t){return!!e.isMultiaddr(t)&&t.protos().some((function(e){return e.resolvable}))}},{key:"isMultiaddr",value:function(e){return Boolean(null===e||void 0===e?void 0:e[zs])}}]),e}();function js(e,t){return qs.apply(this,arguments)}function qs(){return(qs=(0,S.Z)((0,_.Z)().mark((function e(t,r){return(0,_.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",Ge(Qr(r),t,{der:!1}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}Zs.resolvers=Fs;var Ks,Vs,Hs=xi("waku:enr"),Gs=function(e){Z(r,e);var t=G(r);function r(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:BigInt(1),o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;return(0,F.Z)(this,r),(e=t.call(this,Object.entries(n))).seq=i,e.signature=o,e}return(0,U.Z)(r,[{key:"set",value:function(e,t){return this.signature=null,this.seq++,tn(j(r.prototype),"set",this).call(this,e,t)}},{key:"id",get:function(){var e=this.get("id");if(!e)throw new Error("id not found.");return Hr(e)}},{key:"keypairType",get:function(){if("v4"===this.id)return us.secp256k1;throw new Error(_i)}},{key:"publicKey",get:function(){if("v4"===this.id)return this.get("secp256k1");throw new Error(_i)}},{key:"keypair",get:function(){if(this.publicKey){var e=this.publicKey;return ws(this.keypairType,void 0,e)}}},{key:"nodeId",get:function(){if("v4"===this.id)return this.publicKey?function(e){var t=ce.fromHex(e).toRawBytes(!1);return Vr(Qr(t.slice(1)))}(this.publicKey):void 0;throw new Error(_i)}},{key:"ip",get:function(){var e=this.get("ip");return e?vi("ip4",e):void 0},set:function(e){e?this.set("ip",gi("ip4",e)):this.delete("ip")}},{key:"tcp",get:function(){var e=this.get("tcp");return e?Number(vi("tcp",e)):void 0},set:function(e){void 0===e?this.delete("tcp"):this.set("tcp",gi("tcp",e.toString(10)))}},{key:"udp",get:function(){var e=this.get("udp");return e?Number(vi("udp",e)):void 0},set:function(e){void 0===e?this.delete("udp"):this.set("udp",gi("udp",e.toString(10)))}},{key:"ip6",get:function(){var e=this.get("ip6");return e?vi("ip6",e):void 0},set:function(e){e?this.set("ip6",gi("ip6",e)):this.delete("ip6")}},{key:"tcp6",get:function(){var e=this.get("tcp6");return e?Number(vi("tcp",e)):void 0},set:function(e){void 0===e?this.delete("tcp6"):this.set("tcp6",gi("tcp",e.toString(10)))}},{key:"udp6",get:function(){var e=this.get("udp6");return e?Number(vi("udp",e)):void 0},set:function(e){void 0===e?this.delete("udp6"):this.set("udp6",gi("udp",e.toString(10)))}},{key:"multiaddrs",get:function(){var e=this.get("multiaddrs");if(e)return function(e){for(var t=[],r=0;r>=1)%2&&(t.store=!0),(e>>=1)%2&&(t.filter=!0),(e>>=1)%2&&(t.lightPush=!0),t}(e[0])},set:function(e){if(void 0===e)this.delete("waku2");else{var t=function(e){var t=0;return e.lightPush&&(t+=1),t<<=1,e.filter&&(t+=1),t<<=1,e.store&&(t+=1),t<<=1,e.relay&&(t+=1),t}(e);this.set("waku2",new Uint8Array([t]))}}},{key:"verify",value:function(e,t){if(!this.get("id")||"v4"!==this.id)throw new Error(_i);if(!this.publicKey)throw new Error("Failed to verify ENR: No public key");return Yr(t,Qr(e),this.publicKey)}},{key:"sign",value:function(){var e=(0,S.Z)((0,_.Z)().mark((function e(t,r){return(0,_.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:e.t0=this.id,e.next="v4"===e.t0?3:7;break;case 3:return e.next=5,js(r,t);case 5:return this.signature=e.sent,e.abrupt("break",8);case 7:throw new Error(_i);case 8:return e.abrupt("return",this.signature);case 9:case"end":return e.stop()}}),e,this)})));return function(t,r){return e.apply(this,arguments)}}()},{key:"encodeToValues",value:function(){var e=(0,S.Z)((0,_.Z)().mark((function e(t){var r,n=this;return(0,_.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if((r=Array.from(this.keys()).sort((function(e,t){return e.localeCompare(t)})).map((function(e){return[e,n.get(e)]})).map((function(e){var t=P(e,2),r=t[0],n=t[1];return[Gr(r),n]})).flat()).unshift(new Uint8Array([Number(this.seq)])),!t){e.next=10;break}return e.t0=r,e.next=6,this.sign(Kr(On(r)),t);case 6:e.t1=e.sent,e.t0.unshift.call(e.t0,e.t1),e.next=13;break;case 10:if(this.signature){e.next=12;break}throw new Error("No valid signature found");case 12:r.unshift(this.signature);case 13:return e.abrupt("return",r);case 14:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}()},{key:"encode",value:function(){var e=(0,S.Z)((0,_.Z)().mark((function e(t){var r;return(0,_.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.t0=Kr,e.t1=y,e.next=4,this.encodeToValues(t);case 4:if(e.t2=e.sent,e.t3=e.t1.encode.call(e.t1,e.t2),!((r=(0,e.t0)(e.t3)).length>=300)){e.next=9;break}throw new Error("ENR must be less than 300 bytes");case 9:return e.abrupt("return",r);case 10:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}()},{key:"encodeTxt",value:function(){var e=(0,S.Z)((0,_.Z)().mark((function e(t){return(0,_.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.t0=r.RECORD_PREFIX,e.t1=qr,e.next=4,this.encode(t);case 4:return e.t2=e.sent,e.t3=(0,e.t1)(e.t2,"base64url"),e.abrupt("return",e.t0+e.t3);case 7:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}()}],[{key:"create",value:function(){var e=(0,S.Z)((0,_.Z)().mark((function e(){var t,n,i,o,a,s,u=arguments;return(0,_.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=u.length>0&&void 0!==u[0]?u[0]:{},n=u.length>1&&void 0!==u[1]?u[1]:BigInt(1),i=u.length>2&&void 0!==u[2]?u[2]:null,o=new r(t,n,i),e.prev=4,!(a=o.publicKey)){e.next=11;break}return s=ws(o.keypairType,void 0,a),e.next=10,ks(s);case 10:o.peerId=e.sent;case 11:e.next=16;break;case 13:e.prev=13,e.t0=e.catch(4),Hs("Could not calculate peer id for ENR",e.t0);case 16:return e.abrupt("return",o);case 17:case"end":return e.stop()}}),e,null,[[4,13]])})));return function(){return e.apply(this,arguments)}}()},{key:"createV4",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return 33!==e.length&&(e=Jr(e)),r.create(L(L({},t),{},{id:Gr("v4"),secp256k1:e}))}},{key:"createFromPeerId",value:function(){var e=(0,S.Z)((0,_.Z)().mark((function e(t){var n,i,o=arguments;return(0,_.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=o.length>1&&void 0!==o[1]?o[1]:{},e.next=3,xs(t);case 3:i=e.sent,e.t0=i.type,e.next=e.t0===us.secp256k1?7:8;break;case 7:return e.abrupt("return",r.createV4(i.publicKey,n));case 8:throw new Error;case 9:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()},{key:"decodeFromValues",value:function(){var e=(0,S.Z)((0,_.Z)().mark((function e(t){var n,i,o,a,s,u,c,l,f;return(0,_.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(Array.isArray(t)){e.next=2;break}throw new Error("Decoded ENR must be an array");case 2:if(t.length%2===0){e.next=4;break}throw new Error("Decoded ENR must have an even number of elements");case 4:if(n=A(h=t)||Xr(h)||C(h)||T(),i=n[0],o=n[1],a=n.slice(2),i&&!Array.isArray(i)){e.next=7;break}throw new Error("Decoded ENR invalid signature: must be a byte array");case 7:if(o&&!Array.isArray(o)){e.next=9;break}throw new Error("Decoded ENR invalid sequence number: must be a byte array");case 9:for(s={},u=0;u2&&void 0!==arguments[2]?arguments[2]:{};!1!==r.lengthDelimited&&t.fork(),null!=e.payload&&(t.uint32(10),t.bytes(e.payload)),null!=e.contentTopic&&(t.uint32(18),t.string(e.contentTopic)),null!=e.version&&(t.uint32(24),t.uint32(e.version)),null!=e.timestampDeprecated&&(t.uint32(33),t.double(e.timestampDeprecated)),null!=e.timestamp&&(t.uint32(80),t.sint64(e.timestamp)),!1!==r.lengthDelimited&&t.ldelim()}),(function(e,t){for(var r={},n=null==t?e.len:e.pos+t;e.pos>>3){case 1:r.payload=e.bytes();break;case 2:r.contentTopic=e.string();break;case 3:r.version=e.uint32();break;case 4:r.timestampDeprecated=e.double();break;case 10:r.timestamp=e.sint64();break;default:e.skipType(7&i)}}return r}))),t},e.encode=function(t){return Ni(t,e.codec())},e.decode=function(t){return Ii(t,e.codec())}}(Ks||(Ks={})),function(e){var t;e.codec=function(){return null==t&&(t=Li((function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==r.lengthDelimited&&t.fork(),null!=e.contentTopic&&(t.uint32(18),t.string(e.contentTopic)),!1!==r.lengthDelimited&&t.ldelim()}),(function(e,t){for(var r={},n=null==t?e.len:e.pos+t;e.pos>>3===2)r.contentTopic=e.string();else e.skipType(7&i)}return r}))),t},e.encode=function(t){return Ni(t,e.codec())},e.decode=function(t){return Ii(t,e.codec())}}(Vs||(Vs={}));r(8873);function Ws(e,t){this.v=e,this.k=t}function Qs(e){var t,r;function n(t,r){try{var o=e[t](r),a=o.value,s=a instanceof Ws;Promise.resolve(s?a.v:a).then((function(r){if(s){var u="return"===t?"return":"next";if(!a.k||r.done)return n(u,r);r=e[u](r).value}i(o.done?"return":"normal",r)}),(function(e){n("throw",e)}))}catch(u){i("throw",u)}}function i(e,i){switch(e){case"return":t.resolve({value:i,done:!0});break;case"throw":t.reject(i);break;default:t.resolve({value:i,done:!1})}(t=t.next)?n(t.key,t.arg):r=null}this._invoke=function(e,i){return new Promise((function(o,a){var s={key:e,arg:i,resolve:o,reject:a,next:null};r?r=r.next=s:(t=r=s,n(e,i))}))},"function"!=typeof e.return&&(this.return=void 0)}function Js(e){return function(){return new Qs(e.apply(this,arguments))}}function Ys(e){return new Ws(e,0)}function Xs(e){var t={},r=!1;function n(t,n){return r=!0,{done:!1,value:new Ws(n=new Promise((function(r){r(e[t](n))})),1)}}return t["undefined"!=typeof Symbol&&Symbol.iterator||"@@iterator"]=function(){return this},t.next=function(e){return r?(r=!1,e):n("next",e)},"function"==typeof e.throw&&(t.throw=function(e){if(r)throw r=!1,e;return n("throw",e)}),"function"==typeof e.return&&(t.return=function(e){return r?(r=!1,e):n("return",e)}),t}function $s(e){var t,r,n,i=2;for("undefined"!=typeof Symbol&&(r=Symbol.asyncIterator,n=Symbol.iterator);i--;){if(r&&null!=(t=e[r]))return t.call(e);if(n&&null!=(t=e[n]))return new eu(t.call(e));r="@@asyncIterator",n="@@iterator"}throw new TypeError("Object is not async iterable")}function eu(e){function t(e){if(Object(e)!==e)return Promise.reject(new TypeError(e+" is not an object."));var t=e.done;return Promise.resolve(e.value).then((function(e){return{value:e,done:t}}))}return eu=function(e){this.s=e,this.n=e.next},eu.prototype={s:null,n:null,next:function(){return t(this.n.apply(this.s,arguments))},return:function(e){var r=this.s.return;return void 0===r?Promise.resolve({value:e,done:!0}):t(r.apply(this.s,arguments))},throw:function(e){var r=this.s.return;return void 0===r?Promise.reject(e):t(r.apply(this.s,arguments))}},new eu(e)}Qs.prototype["function"==typeof Symbol&&Symbol.asyncIterator||"@@asyncIterator"]=function(){return this},Qs.prototype.next=function(e){return this._invoke("next",e)},Qs.prototype.throw=function(e){return this._invoke("throw",e)},Qs.prototype.return=function(e){return this._invoke("return",e)};var tu=Symbol.for("@achingbrain/uint8arraylist");function ru(e,t){if(null==t||t<0)throw new RangeError("index is out of bounds");var r,n=0,i=rt(e);try{for(i.s();!(r=i.n()).done;){var o=r.value,a=n+o.byteLength;if(t0&&this.appendAll(r)}return(0,U.Z)(t,[{key:e,value:(0,_.Z)().mark((function e(){return(0,_.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.delegateYield(this.bufs,"t0",1);case 1:case"end":return e.stop()}}),e,this)}))},{key:"byteLength",get:function(){return this.length}},{key:"append",value:function(){for(var e=arguments.length,t=new Array(e),r=0;r1&&void 0!==arguments[1]?arguments[1]:0;if(e instanceof Uint8Array)for(var r=0;r0;){if(!(e>=this.bufs[0].byteLength)){this.bufs[0]=this.bufs[0].subarray(e),this.length-=e;break}e-=this.bufs[0].byteLength,this.length-=this.bufs[0].byteLength,this.bufs.shift()}}},{key:"slice",value:function(e,t){var r=this._subList(e,t);return pi(r.bufs,r.length)}},{key:"subarray",value:function(e,t){var r=this._subList(e,t),n=r.bufs,i=r.length;return 1===n.length?n[0]:pi(n,i)}},{key:"sublist",value:function(e,r){var n=this._subList(e,r),i=n.bufs,o=n.length,a=new t;return a.length=o,a.bufs=i,a}},{key:"_subList",value:function(e,t){var r,n;if(e=null!==(r=e)&&void 0!==r?r:0,t=null!==(n=t)&&void 0!==n?n:this.length,e<0&&(e=this.length+e),t<0&&(t=this.length+t),e<0||t>this.length)throw new RangeError("index is out of bounds");if(e===t)return{bufs:[],length:0};if(0===e&&t===this.length)return{bufs:$r(this.bufs),length:this.length};for(var i=[],o=0,a=0;a=c)){var l=e>=u&&eu&&t<=c;if(l&&f){if(e===u&&t===c){i.push(s);break}var h=e-u;i.push(s.subarray(h,h+(t-e)));break}if(l){if(0===e){i.push(s);continue}i.push(s.subarray(e-u))}else{if(f){if(t===c){i.push(s);break}i.push(s.subarray(0,t-u));break}i.push(s)}}}return{bufs:i,length:t-e}}},{key:"getInt8",value:function(e){var t=this.subarray(e,e+1);return new DataView(t.buffer,t.byteOffset,t.byteLength).getInt8(0)}},{key:"setInt8",value:function(e,t){var r=Lr(1);new DataView(r.buffer,r.byteOffset,r.byteLength).setInt8(0,t),this.write(r,e)}},{key:"getInt16",value:function(e,t){var r=this.subarray(e,e+2);return new DataView(r.buffer,r.byteOffset,r.byteLength).getInt16(0,t)}},{key:"setInt16",value:function(e,t,r){var n=Dr(2);new DataView(n.buffer,n.byteOffset,n.byteLength).setInt16(0,t,r),this.write(n,e)}},{key:"getInt32",value:function(e,t){var r=this.subarray(e,e+4);return new DataView(r.buffer,r.byteOffset,r.byteLength).getInt32(0,t)}},{key:"setInt32",value:function(e,t,r){var n=Dr(4);new DataView(n.buffer,n.byteOffset,n.byteLength).setInt32(0,t,r),this.write(n,e)}},{key:"getBigInt64",value:function(e,t){var r=this.subarray(e,e+8);return new DataView(r.buffer,r.byteOffset,r.byteLength).getBigInt64(0,t)}},{key:"setBigInt64",value:function(e,t,r){var n=Dr(8);new DataView(n.buffer,n.byteOffset,n.byteLength).setBigInt64(0,t,r),this.write(n,e)}},{key:"getUint8",value:function(e){var t=this.subarray(e,e+1);return new DataView(t.buffer,t.byteOffset,t.byteLength).getUint8(0)}},{key:"setUint8",value:function(e,t){var r=Lr(1);new DataView(r.buffer,r.byteOffset,r.byteLength).setUint8(0,t),this.write(r,e)}},{key:"getUint16",value:function(e,t){var r=this.subarray(e,e+2);return new DataView(r.buffer,r.byteOffset,r.byteLength).getUint16(0,t)}},{key:"setUint16",value:function(e,t,r){var n=Dr(2);new DataView(n.buffer,n.byteOffset,n.byteLength).setUint16(0,t,r),this.write(n,e)}},{key:"getUint32",value:function(e,t){var r=this.subarray(e,e+4);return new DataView(r.buffer,r.byteOffset,r.byteLength).getUint32(0,t)}},{key:"setUint32",value:function(e,t,r){var n=Dr(4);new DataView(n.buffer,n.byteOffset,n.byteLength).setUint32(0,t,r),this.write(n,e)}},{key:"getBigUint64",value:function(e,t){var r=this.subarray(e,e+8);return new DataView(r.buffer,r.byteOffset,r.byteLength).getBigUint64(0,t)}},{key:"setBigUint64",value:function(e,t,r){var n=Dr(8);new DataView(n.buffer,n.byteOffset,n.byteLength).setBigUint64(0,t,r),this.write(n,e)}},{key:"getFloat32",value:function(e,t){var r=this.subarray(e,e+4);return new DataView(r.buffer,r.byteOffset,r.byteLength).getFloat32(0,t)}},{key:"setFloat32",value:function(e,t,r){var n=Dr(4);new DataView(n.buffer,n.byteOffset,n.byteLength).setFloat32(0,t,r),this.write(n,e)}},{key:"getFloat64",value:function(e,t){var r=this.subarray(e,e+8);return new DataView(r.buffer,r.byteOffset,r.byteLength).getFloat64(0,t)}},{key:"setFloat64",value:function(e,t,r){var n=Dr(8);new DataView(n.buffer,n.byteOffset,n.byteLength).setFloat64(0,t,r),this.write(n,e)}},{key:"equals",value:function(e){if(null==e)return!1;if(!(e instanceof t))return!1;if(e.bufs.length!==this.bufs.length)return!1;for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:0,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;(0,F.Z)(this,e),this.hi=t,this.lo=r}return(0,U.Z)(e,[{key:"toBigInt",value:function(e){if(!0===e)return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31!==0){var t=1+~this.lo>>>0,r=~this.hi>>>0;return 0===t&&(r=r+1>>>0),-(BigInt(t)+(BigInt(r)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}},{key:"toNumber",value:function(e){return Number(this.toBigInt(e))}},{key:"zzDecode",value:function(){var t=-(1&this.lo),r=((this.lo>>>1|this.hi<<31)^t)>>>0;return new e((this.hi>>>1^t)>>>0,r)}},{key:"zzEncode",value:function(){var t=this.hi>>31;return new e(((this.hi<<1|this.lo>>>31)^t)>>>0,(this.lo<<1^t)>>>0)}},{key:"toBytes",value:function(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=ou(e);this.hi>0;)r.set(t++,127&this.lo|128),this.lo=(this.lo>>>7|this.hi<<25)>>>0,this.hi>>>=7;for(;this.lo>127;)r.set(t++,127&this.lo|128),this.lo=this.lo>>>7;r.set(t++,this.lo)}}],[{key:"fromBigInt",value:function(t){if(0n===t)return new e;var r=t<0;r&&(t=-t);var n=0|Number(t>>32n),i=0|Number(t-(BigInt(n)<<32n));return r&&(n=~n>>>0,i=~i>>>0,++i>au&&(i=0,++n>au&&(n=0))),new e(n,i)}},{key:"fromNumber",value:function(t){if(0===t)return new e;var r=t<0;r&&(t=-t);var n=t>>>0,i=(t-n)/4294967296>>>0;return r&&(i=~i>>>0,n=~n>>>0,++n>4294967295&&(n=0,++i>4294967295&&(i=0))),new e(i,n)}},{key:"fromBytes",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=ou(t),i=new e,o=0;if(t.length-r>4){for(;o<4;++o)if(i.lo=(i.lo|(127&n.get(r))<<7*o)>>>0,n.get(r++)<128)return i;if(i.lo=(i.lo|(127&n.get(r))<<28)>>>0,i.hi=(i.hi|(127&n.get(r))>>4)>>>0,n.get(r++)<128)return i;o=0}else for(;o<4;++o){if(r>=t.length)throw RangeError("index out of range: ".concat(r," > ").concat(t.length));if(i.lo=(i.lo|(127&n.get(r))<<7*o)>>>0,n.get(r++)<128)return i}if(t.length-r>4){for(;o<5;++o)if(i.hi=(i.hi|(127&n.get(r))<<7*o+3)>>>0,n.get(r++)<128)return i}else if(r=t.length)throw RangeError("index out of range: ".concat(r," > ").concat(t.length));if(i.hi=(i.hi|(127&n.get(r))<<7*o+3)>>>0,n.get(r++)<128)return i}throw RangeError("invalid varint encoding")}}]),e}(),uu=Math.pow(2,7),cu=Math.pow(2,14),lu=Math.pow(2,21),fu=Math.pow(2,28),hu=Math.pow(2,35),du=Math.pow(2,42),pu=Math.pow(2,49),vu=Math.pow(2,56),gu=Math.pow(2,63),yu={encodingLength:function(e){return e2&&void 0!==arguments[2]?arguments[2]:0;if(null!=Number.MAX_SAFE_INTEGER&&e>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return null==t&&(t=Lr(yu.encodingLength(e))),su.fromNumber(e).toBytes(t,r),t},decode:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return su.fromBytes(e,t).toNumber(!0)}};var mu=function e(t){var r=yu.encodingLength(t),n=function(e){var t;return null!=(null===globalThis||void 0===globalThis||null===(t=globalThis.Buffer)||void 0===t?void 0:t.allocUnsafe)?globalThis.Buffer.allocUnsafe(e):new Uint8Array(e)}(r);return yu.encode(t,n),e.bytes=r,n};function bu(e){var t,r,n=null!==(r=(e=null!==(t=e)&&void 0!==t?t:{}).lengthEncoder)&&void 0!==r?r:mu,i=function(){var e=Js((0,_.Z)().mark((function e(t){var r,i,o,a,s,u,c;return(0,_.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=!1,i=!1,e.prev=2,a=$s(t);case 4:return e.next=6,Ys(a.next());case 6:if(!(r=!(s=e.sent).done)){e.next=24;break}if(u=s.value,!((c=n(u.byteLength))instanceof Uint8Array)){e.next=14;break}return e.next=12,c;case 12:e.next=15;break;case 14:return e.delegateYield(Xs($s(c)),"t0",15);case 15:if(!(u instanceof Uint8Array)){e.next=20;break}return e.next=18,u;case 18:e.next=21;break;case 20:return e.delegateYield(Xs($s(u)),"t1",21);case 21:r=!1,e.next=4;break;case 24:e.next=30;break;case 26:e.prev=26,e.t2=e.catch(2),i=!0,o=e.t2;case 30:if(e.prev=30,e.prev=31,!r||null==a.return){e.next=35;break}return e.next=35,Ys(a.return());case 35:if(e.prev=35,!i){e.next=38;break}throw o;case 38:return e.finish(35);case 39:return e.finish(30);case 40:case"end":return e.stop()}}),e,null,[[2,26,30,40],[31,,35,39]])})));return function(t){return e.apply(this,arguments)}}();return i}mu.bytes=0,bu.single=function(e,t){var r,n,i=null!==(n=(t=null!==(r=t)&&void 0!==r?r:{}).lengthEncoder)&&void 0!==n?n:mu;return new iu(i(e.byteLength),e)};var wu;!function(e){e[e.LENGTH=0]="LENGTH",e[e.DATA=1]="DATA"}(wu||(wu={}));var ku=function e(t){var r=yu.decode(t);return e.bytes=yu.encodingLength(r),r};function Eu(e){var t=function(){var t=Js((0,_.Z)().mark((function t(r){var n,i,o,a,s,u,c,l,f,h,d,p,v,g,y,m,b;return(0,_.Z)().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:a=new iu,s=wu.LENGTH,u=-1,c=null!==(n=null===e||void 0===e?void 0:e.lengthDecoder)&&void 0!==n?n:ku,l=null!==(i=null===e||void 0===e?void 0:e.maxLengthLength)&&void 0!==i?i:8,f=null!==(o=null===e||void 0===e?void 0:e.maxDataLength)&&void 0!==o?o:4194304,h=!1,d=!1,t.prev=8,v=$s(r);case 10:return t.next=12,Ys(v.next());case 12:if(!(h=!(g=t.sent).done)){t.next=50;break}y=g.value,a.append(y);case 15:if(!(a.byteLength>0)){t.next=47;break}if(s!==wu.LENGTH){t.next=36;break}if(t.prev=17,!((u=c(a))<0)){t.next=21;break}throw Fi(new Error("invalid message length"),"ERR_INVALID_MSG_LENGTH");case 21:if(!(u>f)){t.next=23;break}throw Fi(new Error("message length too long"),"ERR_MSG_DATA_TOO_LONG");case 23:m=c.bytes,a.consume(m),null!=(null===e||void 0===e?void 0:e.onLength)&&e.onLength(u),s=wu.DATA,t.next=36;break;case 29:if(t.prev=29,t.t0=t.catch(17),!(t.t0 instanceof RangeError)){t.next=35;break}if(!(a.byteLength>l)){t.next=34;break}throw Fi(new Error("message length length too long"),"ERR_MSG_LENGTH_TOO_LONG");case 34:return t.abrupt("break",47);case 35:throw t.t0;case 36:if(s!==wu.DATA){t.next=45;break}if(!(a.byteLength0)){t.next=68;break}throw Fi(new Error("unexpected end of input"),"ERR_UNEXPECTED_EOF");case 68:case"end":return t.stop()}}),t,null,[[8,52,56,66],[17,29],[57,,61,65]])})));return function(e){return t.apply(this,arguments)}}();return t}function xu(e,t){for(var r in t){(o=t[r]).configurable=o.enumerable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,r,o)}if(Object.getOwnPropertySymbols)for(var n=Object.getOwnPropertySymbols(t),i=0;i0)||0!==(t-1&t))throw new Error("Max size for a FixedFIFO should be a power of two");this.buffer=new Array(t),this.mask=t-1,this.top=0,this.btm=0,this.next=null}return(0,U.Z)(e,[{key:"push",value:function(e){return void 0===this.buffer[this.top]&&(this.buffer[this.top]=e,this.top=this.top+1&this.mask,!0)}},{key:"shift",value:function(){var e=this.buffer[this.btm];if(void 0!==e)return this.buffer[this.btm]=void 0,this.btm=this.btm+1&this.mask,e}},{key:"isEmpty",value:function(){return void 0===this.buffer[this.btm]}}]),e}(),Su=function(){function e(){var t,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};(0,F.Z)(this,e),this.hwm=null!==(t=r.splitLimit)&&void 0!==t?t:16,this.head=new _u(this.hwm),this.tail=this.head,this.size=0}return(0,U.Z)(e,[{key:"calculateSize",value:function(e){return null!=(null===e||void 0===e?void 0:e.byteLength)?e.byteLength:1}},{key:"push",value:function(e){if(null!=(null===e||void 0===e?void 0:e.value)&&(this.size+=this.calculateSize(e.value)),!this.head.push(e)){var t=this.head;this.head=t.next=new _u(2*this.head.buffer.length),this.head.push(e)}}},{key:"shift",value:function(){var e,t=this.tail.shift();if(void 0===t&&null!=this.tail.next){var r=this.tail.next;this.tail.next=null,this.tail=r,t=this.tail.shift()}return null!=(null===(e=t)||void 0===e?void 0:e.value)&&(this.size-=this.calculateSize(t.value)),t}},{key:"isEmpty",value:function(){return this.head.isEmpty()}}]),e}();function Au(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=function(e){var t=e.shift();if(null==t)return{done:!0};if(null!=t.error)throw t.error;return{done:!0===t.done,value:t.value}};return Iu(t,e)}function Iu(e,t){var r,n,i,o,a,s,u,c,l=(t=null!==(r=t)&&void 0!==r?r:{}).onEnd,f=new Su,h=function(){var t=(0,S.Z)((0,_.Z)().mark((function t(){return(0,_.Z)().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(f.isEmpty()){t.next=2;break}return t.abrupt("return",e(f));case 2:if(!c){t.next=4;break}return t.abrupt("return",{done:!0});case 4:return t.next=6,new Promise((function(t,r){u=function(n){u=null,f.push(n);try{t(e(f))}catch(i){r(i)}return s}}));case 6:return t.abrupt("return",t.sent);case 7:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}(),d=function(e){return null!=u?u(e):(f.push(e),s)},p=function(e){var r;if(c)return s;if(!0!==(null===(r=t)||void 0===r?void 0:r.objectMode)&&null==(null===e||void 0===e?void 0:e.byteLength))throw new Error("objectMode was not true but tried to push non-Uint8Array value");return d({done:!1,value:e})},v=function(e){return c?s:(c=!0,null!=e?function(e){return f=new Su,null!=u?u({error:e}):(f.push({error:e}),s)}(e):d({done:!0}))};if(O(n={},Symbol.asyncIterator,(function(){return this})),O(n,"next",h),O(n,"return",(function(){return f=new Su,v(),{done:!0}})),O(n,"throw",(function(e){return v(e),{done:!0}})),O(n,"push",p),O(n,"end",v),"readableLength",(i={}).readableLength=i.readableLength||{},i.readableLength.get=function(){return f.size},xu(n,i),s=n,null==l)return s;var g=s;return O(o={},Symbol.asyncIterator,(function(){return this})),O(o,"next",(function(){return g.next()})),O(o,"throw",(function(e){return g.throw(e),null!=l&&(l(e),l=void 0),{done:!0}})),O(o,"return",(function(){return g.return(),null!=l&&(l(),l=void 0),{done:!0}})),O(o,"push",p),O(o,"end",(function(e){return g.end(e),null!=l&&(l(e),l=void 0),s})),"readableLength",(a={}).readableLength=a.readableLength||{},a.readableLength.get=function(){return g.readableLength},xu(o,a),s=o}var Cu=r(8315),Tu=function(){for(var e,t=arguments.length,r=new Array(t),n=0;n0;)e=r.shift()(e);return e},Pu=function(e){return null!=e&&("function"===typeof e[Symbol.asyncIterator]||"function"===typeof e[Symbol.iterator]||"function"===typeof e.next)},Ru=function(e){return null!=e&&"function"===typeof e.sink&&Pu(e.source)},Bu=function(e){return function(t){var r=e.sink(t);if(null!=r.then){var n=Au({objectMode:!0});r.then((function(){n.end()}),(function(e){n.end(e)}));var i=function(){var t=Js((0,_.Z)().mark((function t(){return(0,_.Z)().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.delegateYield(Xs($s(e.source)),"t0",1);case 1:n.end();case 2:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}();return Cu(n,i())}return e.source}};function Mu(e){if(Ru(e)){var t=e;e=function(){return t.source}}else if(Pu(e)){var r=e;e=function(){return r}}for(var n=arguments.length,i=new Array(n>1?n-1:0),o=1;o1&&Ru(a[a.length-1])&&(a[a.length-1]=a[a.length-1].sink),a.length>2)for(var s=1;s2&&void 0!==arguments[2]?arguments[2]:{};!1!==r.lengthDelimited&&t.fork(),null!=e.contentTopic&&(t.uint32(10),t.string(e.contentTopic)),!1!==r.lengthDelimited&&t.ldelim()}),(function(e,t){for(var r={},n=null==t?e.len:e.pos+t;e.pos>>3===1)r.contentTopic=e.string();else e.skipType(7&i)}return r}))),t},e.encode=function(t){return Ni(t,e.codec())},e.decode=function(t){return Ii(t,e.codec())}}(e.ContentFilter||(e.ContentFilter={})),e.codec=function(){return null==t&&(t=Li((function(t,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!1!==n.lengthDelimited&&r.fork(),null!=t.subscribe&&(r.uint32(8),r.bool(t.subscribe)),null!=t.topic&&(r.uint32(18),r.string(t.topic)),null==t.contentFilters)throw new Error('Protocol error: required field "contentFilters" was not found in object');var i,o=rt(t.contentFilters);try{for(o.s();!(i=o.n()).done;){var a=i.value;r.uint32(26),e.ContentFilter.codec().encode(a,r)}}catch(s){o.e(s)}finally{o.f()}!1!==n.lengthDelimited&&r.ldelim()}),(function(t,r){for(var n={contentFilters:[]},i=null==r?t.len:t.pos+r;t.pos>>3){case 1:n.subscribe=t.bool();break;case 2:n.topic=t.string();break;case 3:n.contentFilters.push(e.ContentFilter.codec().decode(t,t.uint32()));break;default:t.skipType(7&o)}}return n}))),t},e.encode=function(t){return Ni(t,e.codec())},e.decode=function(t){return Ii(t,e.codec())}}(Nu||(Nu={})),function(e){var t;e.codec=function(){return null==t&&(t=Li((function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!1!==r.lengthDelimited&&t.fork(),null==e.messages)throw new Error('Protocol error: required field "messages" was not found in object');var n,i=rt(e.messages);try{for(i.s();!(n=i.n()).done;){var o=n.value;t.uint32(10),Lu.codec().encode(o,t)}}catch(a){i.e(a)}finally{i.f()}!1!==r.lengthDelimited&&t.ldelim()}),(function(e,t){for(var r={messages:[]},n=null==t?e.len:e.pos+t;e.pos>>3===1)r.messages.push(Lu.codec().decode(e,e.uint32()));else e.skipType(7&i)}return r}))),t},e.encode=function(t){return Ni(t,e.codec())},e.decode=function(t){return Ii(t,e.codec())}}(Ou||(Ou={})),function(e){var t;e.codec=function(){return null==t&&(t=Li((function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==r.lengthDelimited&&t.fork(),null!=e.requestId&&(t.uint32(10),t.string(e.requestId)),null!=e.request&&(t.uint32(18),Nu.codec().encode(e.request,t)),null!=e.push&&(t.uint32(26),Ou.codec().encode(e.push,t)),!1!==r.lengthDelimited&&t.ldelim()}),(function(e,t){for(var r={},n=null==t?e.len:e.pos+t;e.pos>>3){case 1:r.requestId=e.string();break;case 2:r.request=Nu.codec().decode(e,e.uint32());break;case 3:r.push=Ou.codec().decode(e,e.uint32());break;default:e.skipType(7&i)}}return r}))),t},e.encode=function(t){return Ni(t,e.codec())},e.decode=function(t){return Ii(t,e.codec())}}(Du||(Du={})),function(e){var t;e.codec=function(){return null==t&&(t=Li((function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==r.lengthDelimited&&t.fork(),null!=e.payload&&(t.uint32(10),t.bytes(e.payload)),null!=e.contentTopic&&(t.uint32(18),t.string(e.contentTopic)),null!=e.version&&(t.uint32(24),t.uint32(e.version)),null!=e.timestampDeprecated&&(t.uint32(33),t.double(e.timestampDeprecated)),null!=e.timestamp&&(t.uint32(80),t.sint64(e.timestamp)),!1!==r.lengthDelimited&&t.ldelim()}),(function(e,t){for(var r={},n=null==t?e.len:e.pos+t;e.pos>>3){case 1:r.payload=e.bytes();break;case 2:r.contentTopic=e.string();break;case 3:r.version=e.uint32();break;case 4:r.timestampDeprecated=e.double();break;case 10:r.timestamp=e.sint64();break;default:e.skipType(7&i)}}return r}))),t},e.encode=function(t){return Ni(t,e.codec())},e.decode=function(t){return Ii(t,e.codec())}}(Lu||(Lu={}));var Uu,Fu,zu,Zu;xi("waku:filter");!function(e){var t;e.codec=function(){return null==t&&(t=Li((function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==r.lengthDelimited&&t.fork(),null!=e.pubSubTopic&&(t.uint32(10),t.string(e.pubSubTopic)),null!=e.message&&(t.uint32(18),Zu.codec().encode(e.message,t)),!1!==r.lengthDelimited&&t.ldelim()}),(function(e,t){for(var r={},n=null==t?e.len:e.pos+t;e.pos>>3){case 1:r.pubSubTopic=e.string();break;case 2:r.message=Zu.codec().decode(e,e.uint32());break;default:e.skipType(7&i)}}return r}))),t},e.encode=function(t){return Ni(t,e.codec())},e.decode=function(t){return Ii(t,e.codec())}}(Uu||(Uu={})),function(e){var t;e.codec=function(){return null==t&&(t=Li((function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==r.lengthDelimited&&t.fork(),null!=e.isSuccess&&(t.uint32(8),t.bool(e.isSuccess)),null!=e.info&&(t.uint32(18),t.string(e.info)),!1!==r.lengthDelimited&&t.ldelim()}),(function(e,t){for(var r={},n=null==t?e.len:e.pos+t;e.pos>>3){case 1:r.isSuccess=e.bool();break;case 2:r.info=e.string();break;default:e.skipType(7&i)}}return r}))),t},e.encode=function(t){return Ni(t,e.codec())},e.decode=function(t){return Ii(t,e.codec())}}(Fu||(Fu={})),function(e){var t;e.codec=function(){return null==t&&(t=Li((function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==r.lengthDelimited&&t.fork(),null!=e.requestId&&(t.uint32(10),t.string(e.requestId)),null!=e.request&&(t.uint32(18),Uu.codec().encode(e.request,t)),null!=e.response&&(t.uint32(26),Fu.codec().encode(e.response,t)),!1!==r.lengthDelimited&&t.ldelim()}),(function(e,t){for(var r={},n=null==t?e.len:e.pos+t;e.pos>>3){case 1:r.requestId=e.string();break;case 2:r.request=Uu.codec().decode(e,e.uint32());break;case 3:r.response=Fu.codec().decode(e,e.uint32());break;default:e.skipType(7&i)}}return r}))),t},e.encode=function(t){return Ni(t,e.codec())},e.decode=function(t){return Ii(t,e.codec())}}(zu||(zu={})),function(e){var t;e.codec=function(){return null==t&&(t=Li((function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==r.lengthDelimited&&t.fork(),null!=e.payload&&(t.uint32(10),t.bytes(e.payload)),null!=e.contentTopic&&(t.uint32(18),t.string(e.contentTopic)),null!=e.version&&(t.uint32(24),t.uint32(e.version)),null!=e.timestampDeprecated&&(t.uint32(33),t.double(e.timestampDeprecated)),null!=e.timestamp&&(t.uint32(80),t.sint64(e.timestamp)),!1!==r.lengthDelimited&&t.ldelim()}),(function(e,t){for(var r={},n=null==t?e.len:e.pos+t;e.pos>>3){case 1:r.payload=e.bytes();break;case 2:r.contentTopic=e.string();break;case 3:r.version=e.uint32();break;case 4:r.timestampDeprecated=e.double();break;case 10:r.timestamp=e.sint64();break;default:e.skipType(7&i)}}return r}))),t},e.encode=function(t){return Ni(t,e.codec())},e.decode=function(t){return Ii(t,e.codec())}}(Zu||(Zu={}));xi("waku:light-push"),xi("waku:message:version-0"),BigInt(1e6);var ju,qu,Ku,Vu,Hu,Gu,Wu,Qu,Ju,Yu,Xu,$u,ec,tc,rc,nc=["/vac/waku/relay/2.0.0-beta2","/vac/waku/relay/2.0.0"];!function(e){var t;e.codec=function(){return null==t&&(t=Li((function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==r.lengthDelimited&&t.fork(),null!=e.digest&&(t.uint32(10),t.bytes(e.digest)),null!=e.receivedTime&&(t.uint32(16),t.sint64(e.receivedTime)),null!=e.senderTime&&(t.uint32(24),t.sint64(e.senderTime)),null!=e.pubsubTopic&&(t.uint32(34),t.string(e.pubsubTopic)),!1!==r.lengthDelimited&&t.ldelim()}),(function(e,t){for(var r={},n=null==t?e.len:e.pos+t;e.pos>>3){case 1:r.digest=e.bytes();break;case 2:r.receivedTime=e.sint64();break;case 3:r.senderTime=e.sint64();break;case 4:r.pubsubTopic=e.string();break;default:e.skipType(7&i)}}return r}))),t},e.encode=function(t){return Ni(t,e.codec())},e.decode=function(t){return Ii(t,e.codec())}}(ju||(ju={})),function(e){var t,r;!function(e){e.DIRECTION_BACKWARD_UNSPECIFIED="DIRECTION_BACKWARD_UNSPECIFIED",e.DIRECTION_FORWARD="DIRECTION_FORWARD"}(e.Direction||(e.Direction={})),function(e){e[e.DIRECTION_BACKWARD_UNSPECIFIED=0]="DIRECTION_BACKWARD_UNSPECIFIED",e[e.DIRECTION_FORWARD=1]="DIRECTION_FORWARD"}(t||(t={})),function(e){e.codec=function(){return Di(t)}}(e.Direction||(e.Direction={})),e.codec=function(){return null==r&&(r=Li((function(t,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==n.lengthDelimited&&r.fork(),null!=t.pageSize&&(r.uint32(8),r.uint64(t.pageSize)),null!=t.cursor&&(r.uint32(18),ju.codec().encode(t.cursor,r)),null!=t.direction&&(r.uint32(24),e.Direction.codec().encode(t.direction,r)),!1!==n.lengthDelimited&&r.ldelim()}),(function(t,r){for(var n={},i=null==r?t.len:t.pos+r;t.pos>>3){case 1:n.pageSize=t.uint64();break;case 2:n.cursor=ju.codec().decode(t,t.uint32());break;case 3:n.direction=e.Direction.codec().decode(t);break;default:t.skipType(7&o)}}return n}))),r},e.encode=function(t){return Ni(t,e.codec())},e.decode=function(t){return Ii(t,e.codec())}}(qu||(qu={})),function(e){var t;e.codec=function(){return null==t&&(t=Li((function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==r.lengthDelimited&&t.fork(),null!=e.contentTopic&&(t.uint32(10),t.string(e.contentTopic)),!1!==r.lengthDelimited&&t.ldelim()}),(function(e,t){for(var r={},n=null==t?e.len:e.pos+t;e.pos>>3===1)r.contentTopic=e.string();else e.skipType(7&i)}return r}))),t},e.encode=function(t){return Ni(t,e.codec())},e.decode=function(t){return Ii(t,e.codec())}}(Ku||(Ku={})),function(e){var t;e.codec=function(){return null==t&&(t=Li((function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!1!==r.lengthDelimited&&t.fork(),null!=e.pubSubTopic&&(t.uint32(18),t.string(e.pubSubTopic)),null==e.contentFilters)throw new Error('Protocol error: required field "contentFilters" was not found in object');var n,i=rt(e.contentFilters);try{for(i.s();!(n=i.n()).done;){var o=n.value;t.uint32(26),Ku.codec().encode(o,t)}}catch(a){i.e(a)}finally{i.f()}null!=e.pagingInfo&&(t.uint32(34),qu.codec().encode(e.pagingInfo,t)),null!=e.startTime&&(t.uint32(40),t.sint64(e.startTime)),null!=e.endTime&&(t.uint32(48),t.sint64(e.endTime)),!1!==r.lengthDelimited&&t.ldelim()}),(function(e,t){for(var r={contentFilters:[]},n=null==t?e.len:e.pos+t;e.pos>>3){case 2:r.pubSubTopic=e.string();break;case 3:r.contentFilters.push(Ku.codec().decode(e,e.uint32()));break;case 4:r.pagingInfo=qu.codec().decode(e,e.uint32());break;case 5:r.startTime=e.sint64();break;case 6:r.endTime=e.sint64();break;default:e.skipType(7&i)}}return r}))),t},e.encode=function(t){return Ni(t,e.codec())},e.decode=function(t){return Ii(t,e.codec())}}(Vu||(Vu={})),function(e){var t,r;!function(e){e.ERROR_NONE_UNSPECIFIED="ERROR_NONE_UNSPECIFIED",e.ERROR_INVALID_CURSOR="ERROR_INVALID_CURSOR"}(e.HistoryError||(e.HistoryError={})),function(e){e[e.ERROR_NONE_UNSPECIFIED=0]="ERROR_NONE_UNSPECIFIED",e[e.ERROR_INVALID_CURSOR=1]="ERROR_INVALID_CURSOR"}(t||(t={})),function(e){e.codec=function(){return Di(t)}}(e.HistoryError||(e.HistoryError={})),e.codec=function(){return null==r&&(r=Li((function(t,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!1!==n.lengthDelimited&&r.fork(),null==t.messages)throw new Error('Protocol error: required field "messages" was not found in object');var i,o=rt(t.messages);try{for(o.s();!(i=o.n()).done;){var a=i.value;r.uint32(18),Wu.codec().encode(a,r)}}catch(s){o.e(s)}finally{o.f()}null!=t.pagingInfo&&(r.uint32(26),qu.codec().encode(t.pagingInfo,r)),null!=t.error&&(r.uint32(32),e.HistoryError.codec().encode(t.error,r)),!1!==n.lengthDelimited&&r.ldelim()}),(function(t,r){for(var n={messages:[]},i=null==r?t.len:t.pos+r;t.pos>>3){case 2:n.messages.push(Wu.codec().decode(t,t.uint32()));break;case 3:n.pagingInfo=qu.codec().decode(t,t.uint32());break;case 4:n.error=e.HistoryError.codec().decode(t);break;default:t.skipType(7&o)}}return n}))),r},e.encode=function(t){return Ni(t,e.codec())},e.decode=function(t){return Ii(t,e.codec())}}(Hu||(Hu={})),function(e){var t;e.codec=function(){return null==t&&(t=Li((function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==r.lengthDelimited&&t.fork(),null!=e.requestId&&(t.uint32(10),t.string(e.requestId)),null!=e.query&&(t.uint32(18),Vu.codec().encode(e.query,t)),null!=e.response&&(t.uint32(26),Hu.codec().encode(e.response,t)),!1!==r.lengthDelimited&&t.ldelim()}),(function(e,t){for(var r={},n=null==t?e.len:e.pos+t;e.pos>>3){case 1:r.requestId=e.string();break;case 2:r.query=Vu.codec().decode(e,e.uint32());break;case 3:r.response=Hu.codec().decode(e,e.uint32());break;default:e.skipType(7&i)}}return r}))),t},e.encode=function(t){return Ni(t,e.codec())},e.decode=function(t){return Ii(t,e.codec())}}(Gu||(Gu={})),function(e){var t;e.codec=function(){return null==t&&(t=Li((function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==r.lengthDelimited&&t.fork(),null!=e.payload&&(t.uint32(10),t.bytes(e.payload)),null!=e.contentTopic&&(t.uint32(18),t.string(e.contentTopic)),null!=e.version&&(t.uint32(24),t.uint32(e.version)),null!=e.timestampDeprecated&&(t.uint32(33),t.double(e.timestampDeprecated)),null!=e.timestamp&&(t.uint32(80),t.sint64(e.timestamp)),!1!==r.lengthDelimited&&t.ldelim()}),(function(e,t){for(var r={},n=null==t?e.len:e.pos+t;e.pos>>3){case 1:r.payload=e.bytes();break;case 2:r.contentTopic=e.string();break;case 3:r.version=e.uint32();break;case 4:r.timestampDeprecated=e.double();break;case 10:r.timestamp=e.sint64();break;default:e.skipType(7&i)}}return r}))),t},e.encode=function(t){return Ni(t,e.codec())},e.decode=function(t){return Ii(t,e.codec())}}(Wu||(Wu={})),function(e){var t;e.codec=function(){return null==t&&(t=Li((function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==r.lengthDelimited&&t.fork(),null!=e.digest&&(t.uint32(10),t.bytes(e.digest)),null!=e.receivedTime&&(t.uint32(17),t.double(e.receivedTime)),null!=e.senderTime&&(t.uint32(25),t.double(e.senderTime)),!1!==r.lengthDelimited&&t.ldelim()}),(function(e,t){for(var r={},n=null==t?e.len:e.pos+t;e.pos>>3){case 1:r.digest=e.bytes();break;case 2:r.receivedTime=e.double();break;case 3:r.senderTime=e.double();break;default:e.skipType(7&i)}}return r}))),t},e.encode=function(t){return Ni(t,e.codec())},e.decode=function(t){return Ii(t,e.codec())}}(Qu||(Qu={})),function(e){var t,r;!function(e){e.DIRECTION_BACKWARD_UNSPECIFIED="DIRECTION_BACKWARD_UNSPECIFIED",e.DIRECTION_FORWARD="DIRECTION_FORWARD"}(e.Direction||(e.Direction={})),function(e){e[e.DIRECTION_BACKWARD_UNSPECIFIED=0]="DIRECTION_BACKWARD_UNSPECIFIED",e[e.DIRECTION_FORWARD=1]="DIRECTION_FORWARD"}(t||(t={})),function(e){e.codec=function(){return Di(t)}}(e.Direction||(e.Direction={})),e.codec=function(){return null==r&&(r=Li((function(t,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==n.lengthDelimited&&r.fork(),null!=t.pageSize&&(r.uint32(8),r.uint64(t.pageSize)),null!=t.cursor&&(r.uint32(18),Qu.codec().encode(t.cursor,r)),null!=t.direction&&(r.uint32(24),e.Direction.codec().encode(t.direction,r)),!1!==n.lengthDelimited&&r.ldelim()}),(function(t,r){for(var n={},i=null==r?t.len:t.pos+r;t.pos>>3){case 1:n.pageSize=t.uint64();break;case 2:n.cursor=Qu.codec().decode(t,t.uint32());break;case 3:n.direction=e.Direction.codec().decode(t);break;default:t.skipType(7&o)}}return n}))),r},e.encode=function(t){return Ni(t,e.codec())},e.decode=function(t){return Ii(t,e.codec())}}(Ju||(Ju={})),function(e){var t;e.codec=function(){return null==t&&(t=Li((function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==r.lengthDelimited&&t.fork(),null!=e.contentTopic&&(t.uint32(10),t.string(e.contentTopic)),!1!==r.lengthDelimited&&t.ldelim()}),(function(e,t){for(var r={},n=null==t?e.len:e.pos+t;e.pos>>3===1)r.contentTopic=e.string();else e.skipType(7&i)}return r}))),t},e.encode=function(t){return Ni(t,e.codec())},e.decode=function(t){return Ii(t,e.codec())}}(Yu||(Yu={})),function(e){var t;e.codec=function(){return null==t&&(t=Li((function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!1!==r.lengthDelimited&&t.fork(),null!=e.pubSubTopic&&(t.uint32(18),t.string(e.pubSubTopic)),null==e.contentFilters)throw new Error('Protocol error: required field "contentFilters" was not found in object');var n,i=rt(e.contentFilters);try{for(i.s();!(n=i.n()).done;){var o=n.value;t.uint32(26),Yu.codec().encode(o,t)}}catch(a){i.e(a)}finally{i.f()}null!=e.pagingInfo&&(t.uint32(34),Ju.codec().encode(e.pagingInfo,t)),null!=e.startTime&&(t.uint32(41),t.double(e.startTime)),null!=e.endTime&&(t.uint32(49),t.double(e.endTime)),!1!==r.lengthDelimited&&t.ldelim()}),(function(e,t){for(var r={contentFilters:[]},n=null==t?e.len:e.pos+t;e.pos>>3){case 2:r.pubSubTopic=e.string();break;case 3:r.contentFilters.push(Yu.codec().decode(e,e.uint32()));break;case 4:r.pagingInfo=Ju.codec().decode(e,e.uint32());break;case 5:r.startTime=e.double();break;case 6:r.endTime=e.double();break;default:e.skipType(7&i)}}return r}))),t},e.encode=function(t){return Ni(t,e.codec())},e.decode=function(t){return Ii(t,e.codec())}}(Xu||(Xu={})),function(e){var t,r;!function(e){e.ERROR_NONE_UNSPECIFIED="ERROR_NONE_UNSPECIFIED",e.ERROR_INVALID_CURSOR="ERROR_INVALID_CURSOR"}(e.HistoryError||(e.HistoryError={})),function(e){e[e.ERROR_NONE_UNSPECIFIED=0]="ERROR_NONE_UNSPECIFIED",e[e.ERROR_INVALID_CURSOR=1]="ERROR_INVALID_CURSOR"}(t||(t={})),function(e){e.codec=function(){return Di(t)}}(e.HistoryError||(e.HistoryError={})),e.codec=function(){return null==r&&(r=Li((function(t,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!1!==n.lengthDelimited&&r.fork(),null==t.messages)throw new Error('Protocol error: required field "messages" was not found in object');var i,o=rt(t.messages);try{for(o.s();!(i=o.n()).done;){var a=i.value;r.uint32(18),tc.codec().encode(a,r)}}catch(s){o.e(s)}finally{o.f()}null!=t.pagingInfo&&(r.uint32(26),Ju.codec().encode(t.pagingInfo,r)),null!=t.error&&(r.uint32(32),e.HistoryError.codec().encode(t.error,r)),!1!==n.lengthDelimited&&r.ldelim()}),(function(t,r){for(var n={messages:[]},i=null==r?t.len:t.pos+r;t.pos>>3){case 2:n.messages.push(tc.codec().decode(t,t.uint32()));break;case 3:n.pagingInfo=Ju.codec().decode(t,t.uint32());break;case 4:n.error=e.HistoryError.codec().decode(t);break;default:t.skipType(7&o)}}return n}))),r},e.encode=function(t){return Ni(t,e.codec())},e.decode=function(t){return Ii(t,e.codec())}}($u||($u={})),function(e){var t;e.codec=function(){return null==t&&(t=Li((function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==r.lengthDelimited&&t.fork(),null!=e.requestId&&(t.uint32(10),t.string(e.requestId)),null!=e.query&&(t.uint32(18),Xu.codec().encode(e.query,t)),null!=e.response&&(t.uint32(26),$u.codec().encode(e.response,t)),!1!==r.lengthDelimited&&t.ldelim()}),(function(e,t){for(var r={},n=null==t?e.len:e.pos+t;e.pos>>3){case 1:r.requestId=e.string();break;case 2:r.query=Xu.codec().decode(e,e.uint32());break;case 3:r.response=$u.codec().decode(e,e.uint32());break;default:e.skipType(7&i)}}return r}))),t},e.encode=function(t){return Ni(t,e.codec())},e.decode=function(t){return Ii(t,e.codec())}}(ec||(ec={})),function(e){var t;e.codec=function(){return null==t&&(t=Li((function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==r.lengthDelimited&&t.fork(),null!=e.payload&&(t.uint32(10),t.bytes(e.payload)),null!=e.contentTopic&&(t.uint32(18),t.string(e.contentTopic)),null!=e.version&&(t.uint32(24),t.uint32(e.version)),null!=e.timestampDeprecated&&(t.uint32(33),t.double(e.timestampDeprecated)),null!=e.timestamp&&(t.uint32(80),t.sint64(e.timestamp)),!1!==r.lengthDelimited&&t.ldelim()}),(function(e,t){for(var r={},n=null==t?e.len:e.pos+t;e.pos>>3){case 1:r.payload=e.bytes();break;case 2:r.contentTopic=e.string();break;case 3:r.version=e.uint32();break;case 4:r.timestampDeprecated=e.double();break;case 10:r.timestamp=e.sint64();break;default:e.skipType(7&i)}}return r}))),t},e.encode=function(t){return Ni(t,e.codec())},e.decode=function(t){return Ii(t,e.codec())}}(tc||(tc={})),function(e){e.V2Beta3="/vac/waku/store/2.0.0-beta3",e.V2Beta4="/vac/waku/store/2.0.0-beta4"}(rc||(rc={}));var ic;BigInt(1e6);!function(e){e.BACKWARD="backward",e.FORWARD="forward"}(ic||(ic={}));Hu.HistoryError,xi("waku:store");var oc;xi("waku:waku");!function(e){e.Relay="relay",e.Store="store",e.LightPush="lightpush",e.Filter="filter"}(oc||(oc={}));var ac,sc="ERR_SIGNATURE_NOT_VALID";!function(e){var t;e.codec=function(){return null==t&&(t=Li((function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!1!==r.lengthDelimited&&t.fork(),null==e.publicKey)throw new Error('Protocol error: required field "publicKey" was not found in object');if(t.uint32(10),t.bytes(e.publicKey),null==e.payloadType)throw new Error('Protocol error: required field "payloadType" was not found in object');if(t.uint32(18),t.bytes(e.payloadType),null==e.payload)throw new Error('Protocol error: required field "payload" was not found in object');if(t.uint32(26),t.bytes(e.payload),null==e.signature)throw new Error('Protocol error: required field "signature" was not found in object');t.uint32(42),t.bytes(e.signature),!1!==r.lengthDelimited&&t.ldelim()}),(function(e,t){for(var r={publicKey:new Uint8Array(0),payloadType:new Uint8Array(0),payload:new Uint8Array(0),signature:new Uint8Array(0)},n=null==t?e.len:e.pos+t;e.pos>>3){case 1:r.publicKey=e.bytes();break;case 2:r.payloadType=e.bytes();break;case 3:r.payload=e.bytes();break;case 5:r.signature=e.bytes();break;default:e.skipType(7&i)}}if(null==r.publicKey)throw new Error('Protocol error: value for required field "publicKey" was not found in protobuf');if(null==r.payloadType)throw new Error('Protocol error: value for required field "payloadType" was not found in protobuf');if(null==r.payload)throw new Error('Protocol error: value for required field "payload" was not found in protobuf');if(null==r.signature)throw new Error('Protocol error: value for required field "signature" was not found in protobuf');return r}))),t},e.encode=function(t){return Ni(t,e.codec())},e.decode=function(t){return Ii(t,e.codec())}}(ac||(ac={}));var uc=function(){function e(t){(0,F.Z)(this,e);var r=t.peerId,n=t.payloadType,i=t.payload,o=t.signature;this.peerId=r,this.payloadType=n,this.payload=i,this.signature=o}return(0,U.Z)(e,[{key:"marshal",value:function(){if(null==this.peerId.publicKey)throw new Error("Missing public key");return null==this.marshaled&&(this.marshaled=ac.encode({publicKey:this.peerId.publicKey,payloadType:this.payloadType,payload:this.payload.subarray(),signature:this.signature})),this.marshaled}},{key:"equals",value:function(e){return Vi(this.marshal(),e.marshal())}},{key:"validate",value:function(){var e=(0,S.Z)((0,_.Z)().mark((function e(t){var r,n;return(0,_.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=cc(t,this.payloadType,this.payload),null!=this.peerId.publicKey){e.next=3;break}throw new Error("Missing public key");case 3:return n=ns(this.peerId.publicKey),e.next=6,n.verify(r.subarray(),this.signature);case 6:return e.abrupt("return",e.sent);case 7:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}()}]),e}();uc.createFromProtobuf=function(){var e=(0,S.Z)((0,_.Z)().mark((function e(t){var r,n;return(0,_.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=ac.decode(t),e.next=3,gs(r.publicKey);case 3:return n=e.sent,e.abrupt("return",new uc({peerId:n,payloadType:r.payloadType,payload:r.payload,signature:r.signature}));case 5:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),uc.seal=function(){var e=(0,S.Z)((0,_.Z)().mark((function e(t,r){var n,i,o,a,s,u;return(0,_.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null!=r.privateKey){e.next=2;break}throw new Error("Missing private key");case 2:return n=t.domain,i=t.codec,o=t.marshal(),a=cc(n,i,o),e.next=8,os(r.privateKey);case 8:return s=e.sent,e.next=11,s.sign(a.subarray());case 11:return u=e.sent,e.abrupt("return",new uc({peerId:r,payloadType:i,payload:o,signature:u}));case 13:case"end":return e.stop()}}),e)})));return function(t,r){return e.apply(this,arguments)}}(),uc.openAndCertify=function(){var e=(0,S.Z)((0,_.Z)().mark((function e(t,r){var n;return(0,_.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,uc.createFromProtobuf(t);case 2:return n=e.sent,e.next=5,n.validate(r);case 5:if(e.sent){e.next=8;break}throw Fi(new Error("envelope signature is not valid for the given domain"),sc);case 8:return e.abrupt("return",n);case 9:case"end":return e.stop()}}),e)})));return function(t,r){return e.apply(this,arguments)}}();var cc=function(e,t,r){var n=jr(e),i=yu.encode(n.byteLength),o=yu.encode(t.length),a=yu.encode(r.length);return new iu(i,n,o,t,a,r)},lc=ii,fc=ni,hc=function e(t){var r=0;if(t=t.toString().trim(),lc(t)){var n=new Uint8Array(r+4);return t.split(/\./g).forEach((function(e){n[r++]=255&parseInt(e,10)})),n}if(fc(t)){var i,o=t.split(":",8);for(i=0;i0;i--)s.push("0");o.splice.apply(o,s)}var u=new Uint8Array(r+16);for(i=0;i>8&255,u[r++]=255&c}return u}throw new Error("invalid ip address")},dc=-1,pc={},vc={};function gc(e,t,r,n,i){return{code:e,size:t,name:r,resolvable:Boolean(n),path:Boolean(i)}}function yc(e){if("number"===typeof e){if(null!=vc[e])return vc[e];throw new Error("no protocol with code: ".concat(e))}if("string"===typeof e){if(null!=pc[e])return pc[e];throw new Error("no protocol with name: ".concat(e))}throw new Error("invalid protocol id type: ".concat(typeof e))}function mc(e,t){switch(yc(e).code){case 4:case 41:return function(e){var t=function(e){var t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2?arguments[2]:void 0;r=~~r,n=null!==(t=n)&&void 0!==t?t:e.length-r;var i=new DataView(e.buffer);if(4===n){for(var o=[],a=0;a65536)throw new Error("Port number is not in range(1, 65536)");var i=_c(n);return pi([r,i],r.length+i.length)}(t);case 445:return function(e){var t=e.split(":");if(2!==t.length)throw new Error("failed to parse onion addr: [\"'".concat(t.join('", "'),"'\"]' does not contain a port number"));if(56!==t[0].length)throw new Error("failed to parse onion addr: ".concat(t[0]," not a Tor onion3 address."));var r=wt.decode("b".concat(t[0])),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");var i=_c(n);return pi([r,i],r.length+i.length)}(t);case 466:return function(e){var t=Ec.decode(e),r=Uint8Array.from(di.encode(t.length));return pi([r,t],r.length+t.length)}(t);default:return jr(t,"base16")}}[[4,32,"ip4"],[6,16,"tcp"],[33,16,"dccp"],[41,128,"ip6"],[42,dc,"ip6zone"],[53,dc,"dns",!0],[54,dc,"dns4",!0],[55,dc,"dns6",!0],[56,dc,"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,dc,"unix",!1,!0],[421,dc,"ipfs"],[421,dc,"p2p"],[443,0,"https"],[444,96,"onion"],[445,296,"onion3"],[446,dc,"garlic64"],[460,0,"quic"],[465,0,"webtransport"],[466,dc,"certhash"],[477,0,"ws"],[478,0,"wss"],[479,0,"p2p-websocket-star"],[480,0,"http"],[777,dc,"memory"]].forEach((function(e){var t=gc.apply(void 0,$r(e));vc[t.code]=t,pc[t.name]=t}));var wc,kc=Object.values(Or).map((function(e){return e.decoder})),Ec=function(){var e=kc[0].or(kc[1]);return kc.slice(2).forEach((function(t){return e=e.or(t)})),e}();function xc(e){if(!ri(e))throw new Error("invalid ip address");return hc(e)}function _c(e){var t=new ArrayBuffer(2);return new DataView(t).setUint16(0,e),new Uint8Array(t)}function Sc(e){return new DataView(e.buffer).getUint16(e.byteOffset)}function Ac(e){var t=e.slice(0,e.length-2),r=e.slice(e.length-2),n=qr(t,"base32"),i=Sc(r);return"".concat(n,":").concat(i)}function Ic(e){return e.map((function(e){var t=Lc(e);return null!=e[1]?[t.code,mc(t.code,e[1])]:[t.code]}))}function Cc(e){return Mc(pi(e.map((function(e){var t=Lc(e),r=Uint8Array.from(di.encode(t.code));return e.length>1&&null!=e[1]&&(r=pi([r,e[1]])),r}))))}function Tc(e,t){return e.size>0?e.size/8:0===e.size?0:di.decode(t)+di.decode.bytes}function Pc(e){for(var t=[],r=0;re.length)throw Dc("Invalid address Uint8Array: "+qr(e,"base16"));t.push([n,a])}else t.push([n]),r+=i}return t}function Rc(e){return function(e){var t=[];return e.map((function(e){var r=Lc(e);return t.push(r.name),e.length>1&&null!=e[1]&&t.push(e[1]),null})),Oc(t.join("/"))}(Ic(Pc(e)))}function Bc(e){var t=function(e){var t=[],r=e.split("/").slice(1);if(1===r.length&&""===r[0])return[];for(var n=0;n=r.length)throw Dc("invalid address: "+e);if(!0===o.path){t.push([i,Oc(r.slice(n).join("/"))]);break}t.push([i,r[n]])}else t.push([i])}return t}(e=Oc(e));return Cc(t.map((function(e){Array.isArray(e)||(e=[e]);var t=Lc(e);return e.length>1?[t.code,bc(t.code,e[1])]:[t.code]})))}function Mc(e){var t=Nc(e);if(null!=t)throw t;return Uint8Array.from(e)}function Nc(e){try{Pc(e)}catch(t){return t}}function Oc(e){return"/"+e.trim().split("/").filter((function(e){return e})).join("/")}function Dc(e){return new Error("Error parsing address: "+e)}function Lc(e){return yc(e[0])}var Uc=Symbol.for("nodejs.util.inspect.custom"),Fc=[yc("dns").code,yc("dns4").code,yc("dns6").code,yc("dnsaddr").code],zc=[yc("p2p").code,yc("ipfs").code],Zc=new Map,jc=Symbol.for("@multiformats/js-multiaddr/multiaddr");function qc(e){return Boolean(null===e||void 0===e?void 0:e[jc])}var Kc,Vc=function(e){function t(e){if((0,F.Z)(this,t),this[wc]=!0,null==e&&(e=""),e instanceof Uint8Array)this.bytes=Mc(e);else if("string"===typeof e){if(e.length>0&&"/"!==e.charAt(0))throw new Error('multiaddr "'.concat(e,'" must start with a "/"'));this.bytes=Bc(e)}else{if(!qc(e))throw new Error("addr must be a string, Buffer, or another Multiaddr");this.bytes=Mc(e.bytes)}}return(0,U.Z)(t,[{key:"toString",value:function(){return Rc(this.bytes)}},{key:"toJSON",value:function(){return this.toString()}},{key:"toOptions",value:function(){var e,t,r=this.protoCodes(),n=this.toString().split("/").slice(1);if(n.length>2)Fc.includes(r[0])&&zc.includes(r[1])?(e=yc("tcp").name,t=443):(e=yc(n[2]).name,t=parseInt(n[3]));else{if(!Fc.includes(r[0]))throw new Error('multiaddr must have a valid format: "/{ip4, ip6, dns4, dns6, dnsaddr}/{address}/{tcp, udp}/{port}".');e=yc("tcp").name,t=443}return{family:41===r[0]||55===r[0]?6:4,host:n[1],transport:e,port:t}}},{key:"protos",value:function(){return this.protoCodes().map((function(e){return Object.assign({},yc(e))}))}},{key:"protoCodes",value:function(){for(var e=[],t=this.bytes,r=0;r=0;n--)if(r[n][0]===e)return new t(Cc(r.slice(0,n)));return this}},{key:"getPeerId",value:function(){try{var e=this.stringTuples().filter((function(e){return e[0]===pc.ipfs.code})),t=e.pop();if(null!=(null===t||void 0===t?void 0:t[1])){var r=t[1];return"Q"===r[0]||"1"===r[0]?qr(Rt.decode("z".concat(r)),"base58btc"):qr(xr.parse(r).multihash.bytes,"base58btc")}return null}catch(n){return null}}},{key:"getPath",value:function(){var e=null;try{null==(e=this.stringTuples().filter((function(e){return!0===yc(e[0]).path}))[0][1])&&(e=null)}catch(t){e=null}return e}},{key:"equals",value:function(e){return Vi(this.bytes,e.bytes)}},{key:"resolve",value:function(){var e=(0,S.Z)((0,_.Z)().mark((function e(r){var n,i,o;return(0,_.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null!=(n=this.protos().find((function(e){return e.resolvable})))){e.next=3;break}return e.abrupt("return",[this]);case 3:if(null!=(i=Zc.get(n.name))){e.next=6;break}throw Fi(new Error("no available resolver for ".concat(n.name)),"ERR_NO_AVAILABLE_RESOLVER");case 6:return e.next=8,i(this,r);case 8:return o=e.sent,e.abrupt("return",o.map((function(e){return new t(e)})));case 10:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}()},{key:"nodeAddress",value:function(){var e=this.toOptions();if("tcp"!==e.transport&&"udp"!==e.transport)throw new Error('multiaddr must have a valid format - no protocol with name: "'.concat(e.transport,'". Must have a valid transport protocol: "{tcp, udp}"'));return{family:e.family,address:e.host,port:e.port}}},{key:"isThinWaistAddress",value:function(e){var t=(null!==e&&void 0!==e?e:this).protos();return 2===t.length&&((4===t[0].code||41===t[0].code)&&(6===t[1].code||273===t[1].code))}},{key:e,value:function(){return this.inspect()}},{key:"inspect",value:function(){return""}}]),t}((wc=jc,Uc));!function(e){var t;!function(e){var t;e.codec=function(){return null==t&&(t=Li((function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!1!==r.lengthDelimited&&t.fork(),null==e.multiaddr)throw new Error('Protocol error: required field "multiaddr" was not found in object');t.uint32(10),t.bytes(e.multiaddr),!1!==r.lengthDelimited&&t.ldelim()}),(function(e,t){for(var r={multiaddr:new Uint8Array(0)},n=null==t?e.len:e.pos+t;e.pos>>3===1)r.multiaddr=e.bytes();else e.skipType(7&i)}if(null==r.multiaddr)throw new Error('Protocol error: value for required field "multiaddr" was not found in protobuf');return r}))),t},e.encode=function(t){return Ni(t,e.codec())},e.decode=function(t){return Ii(t,e.codec())}}(e.AddressInfo||(e.AddressInfo={})),e.codec=function(){return null==t&&(t=Li((function(t,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!1!==n.lengthDelimited&&r.fork(),null==t.peerId)throw new Error('Protocol error: required field "peerId" was not found in object');if(r.uint32(10),r.bytes(t.peerId),null==t.seq)throw new Error('Protocol error: required field "seq" was not found in object');if(r.uint32(16),r.uint64(t.seq),null==t.addresses)throw new Error('Protocol error: required field "addresses" was not found in object');var i,o=rt(t.addresses);try{for(o.s();!(i=o.n()).done;){var a=i.value;r.uint32(26),e.AddressInfo.codec().encode(a,r)}}catch(s){o.e(s)}finally{o.f()}!1!==n.lengthDelimited&&r.ldelim()}),(function(t,r){for(var n={peerId:new Uint8Array(0),seq:0n,addresses:[]},i=null==r?t.len:t.pos+r;t.pos>>3){case 1:n.peerId=t.bytes();break;case 2:n.seq=t.uint64();break;case 3:n.addresses.push(e.AddressInfo.codec().decode(t,t.uint32()));break;default:t.skipType(7&o)}}if(null==n.peerId)throw new Error('Protocol error: value for required field "peerId" was not found in protobuf');if(null==n.seq)throw new Error('Protocol error: value for required field "seq" was not found in protobuf');return n}))),t},e.encode=function(t){return Ni(t,e.codec())},e.decode=function(t){return Ii(t,e.codec())}}(Kc||(Kc={}));var Hc=Uint8Array.from([3,1]),Gc=function(){function e(t){(0,F.Z)(this,e),this.domain=e.DOMAIN,this.codec=e.CODEC;var r=t.peerId,n=t.multiaddrs,i=t.seqNumber;this.peerId=r,this.multiaddrs=null!==n&&void 0!==n?n:[],this.seqNumber=null!==i&&void 0!==i?i:BigInt(Date.now())}return(0,U.Z)(e,[{key:"marshal",value:function(){return null==this.marshaled&&(this.marshaled=Kc.encode({peerId:this.peerId.toBytes(),seq:BigInt(this.seqNumber),addresses:this.multiaddrs.map((function(e){return{multiaddr:e.bytes}}))})),this.marshaled}},{key:"equals",value:function(t){return t instanceof e&&(!!this.peerId.equals(t.peerId)&&(this.seqNumber===t.seqNumber&&!!function(e,t){var r=function(e,t){return e.toString().localeCompare(t.toString())};return e.length===t.length&&(t.sort(r),e.sort(r).every((function(e,r){return t[r].equals(e)})))}(this.multiaddrs,t.multiaddrs)))}}]),e}();function Wc(e){return Object.assign(xi(e),{error:xi("".concat(e,":error")),trace:xi("".concat(e,":trace"))})}Gc.createFromProtobuf=function(e){var t,r=Kc.decode(e),n=vs(r.peerId),i=(null!==(t=r.addresses)&&void 0!==t?t:[]).map((function(e){return t=e.multiaddr,new Vc(t);var t})),o=r.seq;return new Gc({peerId:n,multiaddrs:i,seqNumber:o})},Gc.DOMAIN="libp2p-peer-record",Gc.CODEC=Hc,xi.formatters.b=function(e){return null==e?"undefined":Rt.baseEncode(e)},xi.formatters.t=function(e){return null==e?"undefined":wt.baseEncode(e)},xi.formatters.m=function(e){return null==e?"undefined":Mt.baseEncode(e)},xi.formatters.p=function(e){return null==e?"undefined":e.toString()},xi.formatters.c=function(e){return null==e?"undefined":e.toString()},xi.formatters.k=function(e){return null==e?"undefined":e.toString()};var Qc=Symbol.for("@libp2p/topology");var Jc,Yc=function(){},Xc=function(e){function t(e){var r,n,i,o;(0,F.Z)(this,t),this.min=null!==(r=e.min)&&void 0!==r?r:0,this.max=null!==(n=e.max)&&void 0!==n?n:1/0,this.peers=new Set,this.onConnect=null!==(i=e.onConnect)&&void 0!==i?i:Yc,this.onDisconnect=null!==(o=e.onDisconnect)&&void 0!==o?o:Yc}return(0,U.Z)(t,[{key:e,get:function(){return Qc.toString()}},{key:Qc,get:function(){return!0}},{key:"setRegistrar",value:function(){var e=(0,S.Z)((0,_.Z)().mark((function e(t){return(0,_.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.registrar=t;case 1:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}()},{key:"disconnect",value:function(e){this.onDisconnect(e)}}]),t}(Symbol.toStringTag);var $c,el=function(e,t,r,n){if("a"===r&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"===typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?n:"a"===r?n.call(e):n?n.value:t.get(e)},tl=function(e){Z(r,e);var t=G(r);function r(){var e;return(0,F.Z)(this,r),e=t.apply(this,arguments),$c.set(V(e),new Map),e}return(0,U.Z)(r,[{key:"listenerCount",value:function(e){var t=el(this,$c,"f").get(e);return null==t?0:t.length}},{key:"addEventListener",value:function(e,t,n){var i;tn(j(r.prototype),"addEventListener",this).call(this,e,t,n);var o=el(this,$c,"f").get(e);null==o&&(o=[],el(this,$c,"f").set(e,o)),o.push({callback:t,once:null!==(i=!0!==n&&!1!==n&&(null===n||void 0===n?void 0:n.once))&&void 0!==i&&i})}},{key:"removeEventListener",value:function(e,t,n){tn(j(r.prototype),"removeEventListener",this).call(this,e.toString(),null!==t&&void 0!==t?t:null,n);var i=el(this,$c,"f").get(e);null!=i&&(i=i.filter((function(e){return e.callback!==t})),el(this,$c,"f").set(e,i))}},{key:"dispatchEvent",value:function(e){var t=tn(j(r.prototype),"dispatchEvent",this).call(this,e),n=el(this,$c,"f").get(e.type);return null==n||(n=n.filter((function(e){return!e.once})),el(this,$c,"f").set(e.type,n)),t}}]),r}(Q(EventTarget));$c=new WeakMap;var rl=function(e){Z(r,e);var t=G(r);function r(e,n){var i;return(0,F.Z)(this,r),(i=t.call(this,e,n)).detail=null===n||void 0===n?void 0:n.detail,i}return(0,U.Z)(r)}(Q(Event)),nl=null!==(Jc=globalThis.CustomEvent)&&void 0!==Jc?Jc:rl,il=function(){function e(t,r,n){(0,F.Z)(this,e),this.gossip=t,this.msgs=new Map,this.history=[],this.msgIdToStrFn=n;for(var i=0;i2&&void 0!==arguments[2]&&arguments[2],n=e.msgIdStr;return!this.msgs.has(n)&&(this.msgs.set(n,{message:t,validated:r,originatingPeers:new Set,iwantCounts:new Map}),this.history[0].push(L(L({},e),{},{topic:t.topic})),!0)}},{key:"observeDuplicate",value:function(e,t){var r=this.msgs.get(e);r&&!r.validated&&r.originatingPeers.add(t)}},{key:"get",value:function(e){var t;return null===(t=this.msgs.get(this.msgIdToStrFn(e)))||void 0===t?void 0:t.message}},{key:"getWithIWantCount",value:function(e,t){var r,n=this.msgs.get(e);if(!n)return null;var i=(null!==(r=n.iwantCounts.get(t))&&void 0!==r?r:0)+1;return n.iwantCounts.set(t,i),{msg:n.message,count:i}}},{key:"getGossipIDs",value:function(e){for(var t=this,r=new Map,n=0;n0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1?arguments[1]:void 0;return{subscriptions:[],messages:e,control:t?{graft:t.graft||[],prune:t.prune||[],ihave:t.ihave||[],iwant:t.iwant||[]}:void 0}}function hl(e){if(e.length<=1)return e;for(var t=0;t0&&void 0!==arguments[0]?arguments[0]:{};return L(L(L({},Al),e),{},{topics:e.topics?Object.entries(e.topics).reduce((function(e,t){var r=P(t,2),n=r[0],i=r[1];return e[n]=Tl(i),e}),{}):{}})}function Tl(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return L(L({},Il),e)}function Pl(e){if(e.topicWeight<0)throw Fi(new Error("invalid topic weight; must be >= 0"),Sl);if(0===e.timeInMeshQuantum)throw Fi(new Error("invalid TimeInMeshQuantum; must be non zero"),Sl);if(e.timeInMeshWeight<0)throw Fi(new Error("invalid TimeInMeshWeight; must be positive (or 0 to disable)"),Sl);if(0!==e.timeInMeshWeight&&e.timeInMeshQuantum<=0)throw Fi(new Error("invalid TimeInMeshQuantum; must be positive"),Sl);if(0!==e.timeInMeshWeight&&e.timeInMeshCap<=0)throw Fi(new Error("invalid TimeInMeshCap; must be positive"),Sl);if(e.firstMessageDeliveriesWeight<0)throw Fi(new Error("invallid FirstMessageDeliveriesWeight; must be positive (or 0 to disable)"),Sl);if(0!==e.firstMessageDeliveriesWeight&&(e.firstMessageDeliveriesDecay<=0||e.firstMessageDeliveriesDecay>=1))throw Fi(new Error("invalid FirstMessageDeliveriesDecay; must be between 0 and 1"),Sl);if(0!==e.firstMessageDeliveriesWeight&&e.firstMessageDeliveriesCap<=0)throw Fi(new Error("invalid FirstMessageDeliveriesCap; must be positive"),Sl);if(e.meshMessageDeliveriesWeight>0)throw Fi(new Error("invalid MeshMessageDeliveriesWeight; must be negative (or 0 to disable)"),Sl);if(0!==e.meshMessageDeliveriesWeight&&(e.meshMessageDeliveriesDecay<=0||e.meshMessageDeliveriesDecay>=1))throw Fi(new Error("invalid MeshMessageDeliveriesDecay; must be between 0 and 1"),Sl);if(0!==e.meshMessageDeliveriesWeight&&e.meshMessageDeliveriesCap<=0)throw Fi(new Error("invalid MeshMessageDeliveriesCap; must be positive"),Sl);if(0!==e.meshMessageDeliveriesWeight&&e.meshMessageDeliveriesThreshold<=0)throw Fi(new Error("invalid MeshMessageDeliveriesThreshold; must be positive"),Sl);if(e.meshMessageDeliveriesWindow<0)throw Fi(new Error("invalid MeshMessageDeliveriesWindow; must be non-negative"),Sl);if(0!==e.meshMessageDeliveriesWeight&&e.meshMessageDeliveriesActivation<1e3)throw Fi(new Error("invalid MeshMessageDeliveriesActivation; must be at least 1s"),Sl);if(e.meshFailurePenaltyWeight>0)throw Fi(new Error("invalid MeshFailurePenaltyWeight; must be negative (or 0 to disable)"),Sl);if(0!==e.meshFailurePenaltyWeight&&(e.meshFailurePenaltyDecay<=0||e.meshFailurePenaltyDecay>=1))throw Fi(new Error("invalid MeshFailurePenaltyDecay; must be between 0 and 1"),Sl);if(e.invalidMessageDeliveriesWeight>0)throw Fi(new Error("invalid InvalidMessageDeliveriesWeight; must be negative (or 0 to disable)"),Sl);if(e.invalidMessageDeliveriesDecay<=0||e.invalidMessageDeliveriesDecay>=1)throw Fi(new Error("invalid InvalidMessageDeliveriesDecay; must be between 0 and 1"),Sl)}var Rl={gossipThreshold:-10,publishThreshold:-50,graylistThreshold:-80,acceptPXThreshold:10,opportunisticGraftThreshold:20};function Bl(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return L(L({},Rl),e)}function Ml(e,t,r,n){var i=0;Object.entries(t.topics).forEach((function(e){var t=P(e,2),n=t[0],o=t[1],a=r.topics[n];if(void 0!==a){var s=0;if(o.inMesh){var u=o.meshTime/a.timeInMeshQuantum;u>a.timeInMeshCap&&(u=a.timeInMeshCap),s+=u*a.timeInMeshWeight}var c=o.firstMessageDeliveries;if(c>a.firstMessageDeliveriesCap&&(c=a.firstMessageDeliveriesCap),s+=c*a.firstMessageDeliveriesWeight,o.meshMessageDeliveriesActive&&o.meshMessageDeliveries0&&i>r.topicScoreCap&&(i=r.topicScoreCap);var o=r.appSpecificScore(e);if(i+=o*r.appSpecificWeight,t.ips.forEach((function(e){if(!r.IPColocationFactorWhitelist.has(e)){var t=n.get(e),o=t?t.size:0;if(o>r.IPColocationFactorThreshold){var a=o-r.IPColocationFactorThreshold;i+=a*a*r.IPColocationFactorWeight}}})),t.behaviourPenalty>r.behaviourPenaltyThreshold){var a=t.behaviourPenalty-r.behaviourPenaltyThreshold;i+=a*a*r.behaviourPenaltyWeight}return i}var Nl,Ol=r(6167);!function(e){e[e.unknown=0]="unknown",e[e.valid=1]="valid",e[e.invalid=2]="invalid",e[e.ignored=3]="ignored"}(Nl||(Nl={}));var Dl=function(){function e(){(0,F.Z)(this,e),this.records=new Map,this.queue=new Ol}return(0,U.Z)(e,[{key:"ensureRecord",value:function(e){var t=this.records.get(e);if(t)return t;t={status:Nl.unknown,firstSeen:Date.now(),validated:0,peers:new Set},this.records.set(e,t);var r={msgId:e,expire:Date.now()+12e4};return this.queue.push(r),t}},{key:"gc",value:function(){for(var e=Date.now(),t=this.queue.peekFront();t&&t.expire0&&void 0!==arguments[0]?arguments[0]:{};(0,F.Z)(this,e),this.started=!1,null!=t.peerId&&this.setPeerId(t.peerId),null!=t.addressManager&&this.setAddressManager(t.addressManager),null!=t.peerStore&&this.setPeerStore(t.peerStore),null!=t.upgrader&&this.setUpgrader(t.upgrader),null!=t.metrics&&this.setMetrics(t.metrics),null!=t.registrar&&this.setRegistrar(t.registrar),null!=t.connectionManager&&this.setConnectionManager(t.connectionManager),null!=t.transportManager&&this.setTransportManager(t.transportManager),null!=t.connectionGater&&this.setConnectionGater(t.connectionGater),null!=t.contentRouting&&this.setContentRouting(t.contentRouting),null!=t.peerRouting&&this.setPeerRouting(t.peerRouting),null!=t.datastore&&this.setDatastore(t.datastore),null!=t.connectionProtector&&this.setConnectionProtector(t.connectionProtector),null!=t.dht&&this.setDHT(t.dht),null!=t.pubsub&&this.setPubSub(t.pubsub)}return(0,U.Z)(e,[{key:"isStarted",value:function(){return this.started}},{key:"beforeStart",value:function(){var e=(0,S.Z)((0,_.Z)().mark((function e(){return(0,_.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,Promise.all(Object.values(this).filter((function(e){return Ll(e)})).map(function(){var e=(0,S.Z)((0,_.Z)().mark((function e(t){return(0,_.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null==t.beforeStart){e.next=3;break}return e.next=3,t.beforeStart();case 3:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()));case 2:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}()},{key:"start",value:function(){var e=(0,S.Z)((0,_.Z)().mark((function e(){return(0,_.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,Promise.all(Object.values(this).filter((function(e){return Ll(e)})).map(function(){var e=(0,S.Z)((0,_.Z)().mark((function e(t){return(0,_.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.start();case 2:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()));case 2:this.started=!0;case 3:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}()},{key:"afterStart",value:function(){var e=(0,S.Z)((0,_.Z)().mark((function e(){return(0,_.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,Promise.all(Object.values(this).filter((function(e){return Ll(e)})).map(function(){var e=(0,S.Z)((0,_.Z)().mark((function e(t){return(0,_.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null==t.afterStart){e.next=3;break}return e.next=3,t.afterStart();case 3:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()));case 2:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}()},{key:"beforeStop",value:function(){var e=(0,S.Z)((0,_.Z)().mark((function e(){return(0,_.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,Promise.all(Object.values(this).filter((function(e){return Ll(e)})).map(function(){var e=(0,S.Z)((0,_.Z)().mark((function e(t){return(0,_.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null==t.beforeStop){e.next=3;break}return e.next=3,t.beforeStop();case 3:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()));case 2:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}()},{key:"stop",value:function(){var e=(0,S.Z)((0,_.Z)().mark((function e(){return(0,_.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,Promise.all(Object.values(this).filter((function(e){return Ll(e)})).map(function(){var e=(0,S.Z)((0,_.Z)().mark((function e(t){return(0,_.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.stop();case 2:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()));case 2:this.started=!1;case 3:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}()},{key:"afterStop",value:function(){var e=(0,S.Z)((0,_.Z)().mark((function e(){return(0,_.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,Promise.all(Object.values(this).filter((function(e){return Ll(e)})).map(function(){var e=(0,S.Z)((0,_.Z)().mark((function e(t){return(0,_.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null==t.afterStop){e.next=3;break}return e.next=3,t.afterStop();case 3:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()));case 2:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}()},{key:"setPeerId",value:function(e){return this.peerId=e,e}},{key:"getPeerId",value:function(){if(null==this.peerId)throw Fi(new Error("peerId not set"),"ERR_SERVICE_MISSING");return this.peerId}},{key:"setMetrics",value:function(e){return this.metrics=e,Ul(e)&&e.init(this),e}},{key:"getMetrics",value:function(){return this.metrics}},{key:"setAddressManager",value:function(e){return this.addressManager=e,Ul(e)&&e.init(this),e}},{key:"getAddressManager",value:function(){if(null==this.addressManager)throw Fi(new Error("addressManager not set"),"ERR_SERVICE_MISSING");return this.addressManager}},{key:"setPeerStore",value:function(e){return this.peerStore=e,Ul(e)&&e.init(this),e}},{key:"getPeerStore",value:function(){if(null==this.peerStore)throw Fi(new Error("peerStore not set"),"ERR_SERVICE_MISSING");return this.peerStore}},{key:"setUpgrader",value:function(e){return this.upgrader=e,Ul(e)&&e.init(this),e}},{key:"getUpgrader",value:function(){if(null==this.upgrader)throw Fi(new Error("upgrader not set"),"ERR_SERVICE_MISSING");return this.upgrader}},{key:"setRegistrar",value:function(e){return this.registrar=e,Ul(e)&&e.init(this),e}},{key:"getRegistrar",value:function(){if(null==this.registrar)throw Fi(new Error("registrar not set"),"ERR_SERVICE_MISSING");return this.registrar}},{key:"setConnectionManager",value:function(e){return this.connectionManager=e,Ul(e)&&e.init(this),e}},{key:"getConnectionManager",value:function(){if(null==this.connectionManager)throw Fi(new Error("connectionManager not set"),"ERR_SERVICE_MISSING");return this.connectionManager}},{key:"setTransportManager",value:function(e){return this.transportManager=e,Ul(e)&&e.init(this),e}},{key:"getTransportManager",value:function(){if(null==this.transportManager)throw Fi(new Error("transportManager not set"),"ERR_SERVICE_MISSING");return this.transportManager}},{key:"setConnectionGater",value:function(e){return this.connectionGater=e,Ul(e)&&e.init(this),e}},{key:"getConnectionGater",value:function(){if(null==this.connectionGater)throw Fi(new Error("connectionGater not set"),"ERR_SERVICE_MISSING");return this.connectionGater}},{key:"setContentRouting",value:function(e){return this.contentRouting=e,Ul(e)&&e.init(this),e}},{key:"getContentRouting",value:function(){if(null==this.contentRouting)throw Fi(new Error("contentRouting not set"),"ERR_SERVICE_MISSING");return this.contentRouting}},{key:"setPeerRouting",value:function(e){return this.peerRouting=e,Ul(e)&&e.init(this),e}},{key:"getPeerRouting",value:function(){if(null==this.peerRouting)throw Fi(new Error("peerRouting not set"),"ERR_SERVICE_MISSING");return this.peerRouting}},{key:"setDatastore",value:function(e){return this.datastore=e,Ul(e)&&e.init(this),e}},{key:"getDatastore",value:function(){if(null==this.datastore)throw Fi(new Error("datastore not set"),"ERR_SERVICE_MISSING");return this.datastore}},{key:"setConnectionProtector",value:function(e){return this.connectionProtector=e,Ul(e)&&e.init(this),e}},{key:"getConnectionProtector",value:function(){return this.connectionProtector}},{key:"setDHT",value:function(e){return this.dht=e,Ul(e)&&e.init(this),e}},{key:"getDHT",value:function(){if(null==this.dht)throw Fi(new Error("dht not set"),"ERR_SERVICE_MISSING");return this.dht}},{key:"setPubSub",value:function(e){return this.pubsub=e,Ul(e)&&e.init(this),e}},{key:"getPubSub",value:function(){if(null==this.pubsub)throw Fi(new Error("pubsub not set"),"ERR_SERVICE_MISSING");return this.pubsub}},{key:"setDialer",value:function(e){return this.dialer=e,Ul(e)&&e.init(this),e}},{key:"getDialer",value:function(){if(null==this.dialer)throw Fi(new Error("dialer not set"),"ERR_SERVICE_MISSING");return this.dialer}}]),e}(),Hl=Wc("libp2p:gossipsub:score"),Gl=function(){function e(t,r,n){var i;(0,F.Z)(this,e),this.params=t,this.metrics=r,this.peerStats=new Map,this.peerIPs=new Map,this.scoreCache=new Map,this.deliveryRecords=new Dl,this.components=new Vl,function(e){for(var t=0,r=Object.entries(e.topics);t0)throw Fi(new Error("invalid IPColocationFactorWeight; must be negative (or 0 to disable)"),Sl);if(0!==e.IPColocationFactorWeight&&e.IPColocationFactorThreshold<1)throw Fi(new Error("invalid IPColocationFactorThreshold; must be at least 1"),Sl);if(e.behaviourPenaltyWeight>0)throw Fi(new Error("invalid BehaviourPenaltyWeight; must be negative (or 0 to disable)"),Sl);if(0!==e.behaviourPenaltyWeight&&(e.behaviourPenaltyDecay<=0||e.behaviourPenaltyDecay>=1))throw Fi(new Error("invalid BehaviourPenaltyDecay; must be between 0 and 1"),Sl);if(e.decayInterval<1e3)throw Fi(new Error("invalid DecayInterval; must be at least 1s"),Sl);if(e.decayToZero<=0||e.decayToZero>=1)throw Fi(new Error("invalid DecayToZero; must be between 0 and 1"),Sl)}(t),this.scoreCacheValidityMs=n.scoreCacheValidityMs,this.computeScore=null!==(i=n.computeScore)&&void 0!==i?i:Ml}return(0,U.Z)(e,[{key:"init",value:function(e){this.components=e}},{key:"size",get:function(){return this.peerStats.size}},{key:"start",value:function(){var e=this;this._backgroundInterval?Hl("Peer score already running"):(this._backgroundInterval=setInterval((function(){return e.background()}),this.params.decayInterval),Hl("started"))}},{key:"stop",value:function(){this._backgroundInterval?(clearInterval(this._backgroundInterval),delete this._backgroundInterval,this.peerIPs.clear(),this.peerStats.clear(),this.deliveryRecords.clear(),Hl("stopped")):Hl("Peer score already stopped")}},{key:"background",value:function(){this.refreshScores(),this.updateIPs(),this.deliveryRecords.gc()}},{key:"dumpPeerScoreStats",value:function(){return Object.fromEntries(Array.from(this.peerStats.entries()).map((function(e){var t=P(e,2);return[t[0],t[1]]})))}},{key:"refreshScores",value:function(){var e=this,t=Date.now(),r=this.params.decayToZero;this.peerStats.forEach((function(n,i){n.connected?(Object.entries(n.topics).forEach((function(n){var i=P(n,2),o=i[0],a=i[1],s=e.params.topics[o];void 0!==s&&(a.firstMessageDeliveries*=s.firstMessageDeliveriesDecay,a.firstMessageDeliveriess.meshMessageDeliveriesActivation&&(a.meshMessageDeliveriesActive=!0)))})),n.behaviourPenalty*=e.params.behaviourPenaltyDecay,n.behaviourPenaltyn.expire&&(e.removeIPs(i,n.ips),e.peerStats.delete(i),e.scoreCache.delete(i))}))}},{key:"score",value:function(e){var t,r;null===(t=this.metrics)||void 0===t||t.scoreFnCalls.inc();var n=this.peerStats.get(e);if(!n)return 0;var i=Date.now(),o=this.scoreCache.get(e);if(o&&o.cacheUntil>i)return o.score;null===(r=this.metrics)||void 0===r||r.scoreFnRuns.inc();var a,s=this.computeScore(e,n,this.params,this.peerIPs),u=i+this.scoreCacheValidityMs;o?(null===(a=this.metrics)||void 0===a||a.scoreCachedDelta.observe(Math.abs(s-o.score)),o.score=s,o.cacheUntil=u):this.scoreCache.set(e,{score:s,cacheUntil:u});return s}},{key:"addPenalty",value:function(e,t,r){var n,i=this.peerStats.get(e);i&&(i.behaviourPenalty+=t,null===(n=this.metrics)||void 0===n||n.onScorePenalty(r))}},{key:"addPeer",value:function(e){var t={connected:!0,expire:0,topics:{},ips:[],behaviourPenalty:0};this.peerStats.set(e,t);var r=this.getIPs(e);this.setIPs(e,r,t.ips),t.ips=r}},{key:"removePeer",value:function(e){var t=this,r=this.peerStats.get(e);if(r){if(this.score(e)>0)return this.removeIPs(e,r.ips),void this.peerStats.delete(e);Object.entries(r.topics).forEach((function(e){var r=P(e,2),n=r[0],i=r[1];i.firstMessageDeliveries=0;var o=t.params.topics[n].meshMessageDeliveriesThreshold;if(i.inMesh&&i.meshMessageDeliveriesActive&&i.meshMessageDeliveriesa.meshMessageDeliveriesWindow;if(null===(s=this.metrics)||void 0===s||s.onDuplicateMsgDelivery(t,u,c),c)return}var l=a.meshMessageDeliveriesCap;o.meshMessageDeliveries=Math.min(l,o.meshMessageDeliveries+1)}}}},{key:"getIPs",value:function(e){return this.components.getConnectionManager().getConnections(ps(e)).map((function(e){return e.remoteAddr.toOptions().host}))}},{key:"setIPs",value:function(e,t,r){var n,i=rt(t);try{e:for(i.s();!(n=i.n()).done;){var o,a=n.value,s=rt(r);try{for(s.s();!(o=s.n()).done;){if(a===o.value)continue e}}catch(v){s.e(v)}finally{s.f()}var u=this.peerIPs.get(a);u||(u=new Set,this.peerIPs.set(a,u)),u.add(e)}}catch(v){i.e(v)}finally{i.f()}var c,l=rt(r);try{e:for(l.s();!(c=l.n()).done;){var f,h=c.value,d=rt(t);try{for(d.s();!(f=d.n()).done;){if(h===f.value)continue e}}catch(v){d.e(v)}finally{d.f()}var p=this.peerIPs.get(h);p&&(p.delete(e),p.size||this.peerIPs.delete(h))}}catch(v){l.e(v)}finally{l.f()}}},{key:"removeIPs",value:function(e,t){var r=this;t.forEach((function(t){var n=r.peerIPs.get(t);n&&(n.delete(e),n.size||r.peerIPs.delete(t))}))}},{key:"updateIPs",value:function(){var e=this;this.peerStats.forEach((function(t,r){var n=e.getIPs(r);e.setIPs(r,n,t.ips),t.ips=n}))}},{key:"getPtopicStats",value:function(e,t){var r=e.topics[t];return void 0!==r?r:void 0!==this.params.topics[t]?(r={inMesh:!1,graftTime:0,meshTime:0,firstMessageDeliveries:0,meshMessageDeliveries:0,meshMessageDeliveriesActive:!1,meshFailurePenalty:0,invalidMessageDeliveries:0},e.topics[t]=r,r):null}}]),e}(),Wl=function(){function e(t,r,n){(0,F.Z)(this,e),this.gossipsubIWantFollowupMs=t,this.msgIdToStrFn=r,this.metrics=n,this.promises=new Map,this.requestMsByMsg=new Map,this.requestMsByMsgExpire=10*t}return(0,U.Z)(e,[{key:"size",get:function(){return this.promises.size}},{key:"requestMsByMsgSize",get:function(){return this.requestMsByMsg.size}},{key:"addPromise",value:function(e,t){var r=t[Math.floor(Math.random()*t.length)],n=this.msgIdToStrFn(r),i=this.promises.get(n);i||(i=new Map,this.promises.set(n,i));var o=Date.now();i.has(e)||(i.set(e,o+this.gossipsubIWantFollowupMs),this.metrics&&(this.metrics.iwantPromiseStarted.inc(1),this.requestMsByMsg.has(n)||this.requestMsByMsg.set(n,o)))}},{key:"getBrokenPromises",value:function(){var e,t=this,r=Date.now(),n=new Map,i=0;return this.promises.forEach((function(e,o){e.forEach((function(t,o){var a;t=Date.now()?t.value:void 0}},{key:"clear",value:function(){this.entries.clear()}}]),e}();function Jl(e,t,r){return{protocolsEnabled:e.gauge({name:"gossipsub_protocol",help:"Status of enabled protocols",labelNames:["protocol"]}),topicSubscriptionStatus:e.gauge({name:"gossipsub_topic_subscription_status",help:"Status of our subscription to this topic",labelNames:["topicStr"]}),topicPeersCount:e.gauge({name:"gossipsub_topic_peer_count",help:"Number of peers subscribed to each topic",labelNames:["topicStr"]}),meshPeerCounts:e.gauge({name:"gossipsub_mesh_peer_count",help:"Number of peers in our mesh",labelNames:["topicStr"]}),meshPeerInclusionEvents:e.gauge({name:"gossipsub_mesh_peer_inclusion_events_total",help:"Number of times we include peers in a topic mesh for different reasons",labelNames:["topic","reason"]}),meshPeerChurnEvents:e.gauge({name:"gossipsub_peer_churn_events_total",help:"Number of times we remove peers in a topic mesh for different reasons",labelNames:["topic","reason"]}),peersPerProtocol:e.gauge({name:"gossipsub_peers_per_protocol_count",help:"Peers connected for each topic",labelNames:["protocol"]}),heartbeatDuration:e.histogram({name:"gossipsub_heartbeat_duration_seconds",help:"The time it takes to complete one iteration of the heartbeat",buckets:[.01,.1,1]}),heartbeatSkipped:e.gauge({name:"gossipsub_heartbeat_skipped",help:"Heartbeat run took longer than heartbeat interval so next is skipped"}),asyncValidationResult:e.gauge({name:"gossipsub_async_validation_result_total",help:"Message validation result for each topic",labelNames:["topic","acceptance"]}),asyncValidationMcacheHit:e.gauge({name:"gossipsub_async_validation_mcache_hit_total",help:"Async validation result reported by the user layer",labelNames:["hit"]}),rpcRecvBytes:e.gauge({name:"gossipsub_rpc_recv_bytes_total",help:"RPC recv"}),rpcRecvCount:e.gauge({name:"gossipsub_rpc_recv_count_total",help:"RPC recv"}),rpcRecvSubscription:e.gauge({name:"gossipsub_rpc_recv_subscription_total",help:"RPC recv"}),rpcRecvMessage:e.gauge({name:"gossipsub_rpc_recv_message_total",help:"RPC recv"}),rpcRecvControl:e.gauge({name:"gossipsub_rpc_recv_control_total",help:"RPC recv"}),rpcRecvIHave:e.gauge({name:"gossipsub_rpc_recv_ihave_total",help:"RPC recv"}),rpcRecvIWant:e.gauge({name:"gossipsub_rpc_recv_iwant_total",help:"RPC recv"}),rpcRecvGraft:e.gauge({name:"gossipsub_rpc_recv_graft_total",help:"RPC recv"}),rpcRecvPrune:e.gauge({name:"gossipsub_rpc_recv_prune_total",help:"RPC recv"}),rpcRecvNotAccepted:e.gauge({name:"gossipsub_rpc_rcv_not_accepted_total",help:"Total count of RPC dropped because acceptFrom() == false"}),rpcSentBytes:e.gauge({name:"gossipsub_rpc_sent_bytes_total",help:"RPC sent"}),rpcSentCount:e.gauge({name:"gossipsub_rpc_sent_count_total",help:"RPC sent"}),rpcSentSubscription:e.gauge({name:"gossipsub_rpc_sent_subscription_total",help:"RPC sent"}),rpcSentMessage:e.gauge({name:"gossipsub_rpc_sent_message_total",help:"RPC sent"}),rpcSentControl:e.gauge({name:"gossipsub_rpc_sent_control_total",help:"RPC sent"}),rpcSentIHave:e.gauge({name:"gossipsub_rpc_sent_ihave_total",help:"RPC sent"}),rpcSentIWant:e.gauge({name:"gossipsub_rpc_sent_iwant_total",help:"RPC sent"}),rpcSentGraft:e.gauge({name:"gossipsub_rpc_sent_graft_total",help:"RPC sent"}),rpcSentPrune:e.gauge({name:"gossipsub_rpc_sent_prune_total",help:"RPC sent"}),msgPublishCount:e.gauge({name:"gossipsub_msg_publish_count_total",help:"Total count of msg published by topic",labelNames:["topic"]}),msgPublishPeers:e.gauge({name:"gossipsub_msg_publish_peers_total",help:"Total count of peers that we publish a msg to",labelNames:["topic"]}),msgPublishPeersByGroup:e.gauge({name:"gossipsub_msg_publish_peers_by_group",help:"Total count of peers (by group) that we publish a msg to",labelNames:["topic","peerGroup"]}),msgPublishBytes:e.gauge({name:"gossipsub_msg_publish_bytes_total",help:"Total count of msg publish data.length bytes",labelNames:["topic"]}),msgForwardCount:e.gauge({name:"gossipsub_msg_forward_count_total",help:"Total count of msg forwarded by topic",labelNames:["topic"]}),msgForwardPeers:e.gauge({name:"gossipsub_msg_forward_peers_total",help:"Total count of peers that we forward a msg to",labelNames:["topic"]}),msgReceivedPreValidation:e.gauge({name:"gossipsub_msg_received_prevalidation_total",help:"Total count of recv msgs before any validation",labelNames:["topic"]}),msgReceivedStatus:e.gauge({name:"gossipsub_msg_received_status_total",help:"Tracks distribution of recv msgs by duplicate, invalid, valid",labelNames:["topic","status"]}),msgReceivedInvalid:e.gauge({name:"gossipsub_msg_received_invalid_total",help:"Tracks specific reason of invalid",labelNames:["topic","error"]}),duplicateMsgDeliveryDelay:e.histogram({name:"gossisub_duplicate_msg_delivery_delay_seconds",help:"Time since the 1st duplicated message validated",labelNames:["topic"],buckets:[.25*r.maxMeshMessageDeliveriesWindowSec,.5*r.maxMeshMessageDeliveriesWindowSec,1*r.maxMeshMessageDeliveriesWindowSec,2*r.maxMeshMessageDeliveriesWindowSec,4*r.maxMeshMessageDeliveriesWindowSec]}),duplicateMsgLateDelivery:e.gauge({name:"gossisub_duplicate_msg_late_delivery_total",help:"Total count of late duplicate message delivery by topic, which triggers P3 penalty",labelNames:["topic"]}),scoreFnCalls:e.gauge({name:"gossipsub_score_fn_calls_total",help:"Total times score() is called"}),scoreFnRuns:e.gauge({name:"gossipsub_score_fn_runs_total",help:"Total times score() call actually computed computeScore(), no cache"}),scoreCachedDelta:e.histogram({name:"gossipsub_score_cache_delta",help:"Delta of score between cached values that expired",buckets:[10,100,1e3]}),peersByScoreThreshold:e.gauge({name:"gossipsub_peers_by_score_threshold_count",help:"Current count of peers by score threshold",labelNames:["threshold"]}),score:e.avgMinMax({name:"gossipsub_score",help:"Avg min max of gossip scores",labelNames:["topic","p"]}),scoreWeights:e.avgMinMax({name:"gossipsub_score_weights",help:"Separate score weights",labelNames:["topic","p"]}),scorePerMesh:e.avgMinMax({name:"gossipsub_score_per_mesh",help:"Histogram of the scores for each mesh topic",labelNames:["topic"]}),scoringPenalties:e.gauge({name:"gossipsub_scoring_penalties_total",help:"A counter of the kind of penalties being applied to peers",labelNames:["penalty"]}),behaviourPenalty:e.histogram({name:"gossipsub_peer_stat_behaviour_penalty",help:"Current peer stat behaviour_penalty at each scrape",buckets:[.25*r.behaviourPenaltyThreshold,.5*r.behaviourPenaltyThreshold,1*r.behaviourPenaltyThreshold,2*r.behaviourPenaltyThreshold,4*r.behaviourPenaltyThreshold]}),ihaveRcvIgnored:e.gauge({name:"gossipsub_ihave_rcv_ignored_total",help:"Total received IHAVE messages that we ignore for some reason",labelNames:["reason"]}),ihaveRcvMsgids:e.gauge({name:"gossipsub_ihave_rcv_msgids_total",help:"Total received IHAVE messages by topic",labelNames:["topic"]}),ihaveRcvNotSeenMsgids:e.gauge({name:"gossipsub_ihave_rcv_not_seen_msgids_total",help:"Total messages per topic we do not have, not actual requests",labelNames:["topic"]}),iwantRcvMsgids:e.gauge({name:"gossipsub_iwant_rcv_msgids_total",help:"Total received IWANT messages by topic",labelNames:["topic"]}),iwantRcvDonthaveMsgids:e.gauge({name:"gossipsub_iwant_rcv_dont_have_msgids_total",help:"Total requested messageIDs that we do not have"}),iwantPromiseStarted:e.gauge({name:"gossipsub_iwant_promise_sent_total",help:"Total count of started IWANT promises"}),iwantPromiseResolved:e.gauge({name:"gossipsub_iwant_promise_resolved_total",help:"Total count of resolved IWANT promises"}),iwantPromiseResolvedPeers:e.gauge({name:"gossipsub_iwant_promise_resolved_peers",help:"Total count of peers we have asked IWANT promises that are resolved"}),iwantPromiseBroken:e.gauge({name:"gossipsub_iwant_promise_broken",help:"Total count of broken IWANT promises"}),iwantPromiseDeliveryTime:e.histogram({name:"gossipsub_iwant_promise_delivery_seconds",help:"Histogram of delivery time of resolved IWANT promises",buckets:[.5*r.gossipPromiseExpireSec,1*r.gossipPromiseExpireSec,2*r.gossipPromiseExpireSec,4*r.gossipPromiseExpireSec]}),cacheSize:e.gauge({name:"gossipsub_cache_size",help:"Unbounded cache sizes",labelNames:["cache"]}),mcacheSize:e.gauge({name:"gossipsub_mcache_size",help:"Current mcache msg count"}),topicStrToLabel:t,toTopic:function(e){var t;return null!==(t=this.topicStrToLabel.get(e))&&void 0!==t?t:e},onJoin:function(e){this.topicSubscriptionStatus.set({topicStr:e},1),this.meshPeerCounts.set({topicStr:e},0)},onLeave:function(e){this.topicSubscriptionStatus.set({topicStr:e},0),this.meshPeerCounts.set({topicStr:e},0)},onAddToMesh:function(e,t,r){var n=this.toTopic(e);this.meshPeerInclusionEvents.inc({topic:n,reason:t},r)},onRemoveFromMesh:function(e,t,r){var n=this.toTopic(e);this.meshPeerChurnEvents.inc({topic:n,reason:t},r)},onReportValidationMcacheHit:function(e){this.asyncValidationMcacheHit.inc({hit:e?"hit":"miss"})},onReportValidation:function(e,t){var r=this.toTopic(e);this.asyncValidationResult.inc({topic:r,acceptance:t})},onScorePenalty:function(e){this.scoringPenalties.inc({penalty:e},1)},onIhaveRcv:function(e,t,r){var n=this.toTopic(e);this.ihaveRcvMsgids.inc({topic:n},t),this.ihaveRcvNotSeenMsgids.inc({topic:n},r)},onIwantRcv:function(e,t){var r,n=rt(e);try{for(n.s();!(r=n.n()).done;){var i=P(r.value,2),o=i[0],a=i[1],s=this.toTopic(o);this.iwantRcvMsgids.inc({topic:s},a)}}catch(u){n.e(u)}finally{n.f()}this.iwantRcvDonthaveMsgids.inc(t)},onForwardMsg:function(e,t){var r=this.toTopic(e);this.msgForwardCount.inc({topic:r},1),this.msgForwardPeers.inc({topic:r},t)},onPublishMsg:function(e,t,r,n){var i=this.toTopic(e);this.msgPublishCount.inc({topic:i},1),this.msgPublishBytes.inc({topic:i},r*n),this.msgPublishPeers.inc({topic:i},r),this.msgPublishPeersByGroup.inc({topic:i,peerGroup:"direct"},t.direct),this.msgPublishPeersByGroup.inc({topic:i,peerGroup:"floodsub"},t.floodsub),this.msgPublishPeersByGroup.inc({topic:i,peerGroup:"mesh"},t.mesh),this.msgPublishPeersByGroup.inc({topic:i,peerGroup:"fanout"},t.fanout)},onMsgRecvPreValidation:function(e){var t=this.toTopic(e);this.msgReceivedPreValidation.inc({topic:t},1)},onMsgRecvResult:function(e,t){var r=this.toTopic(e);this.msgReceivedStatus.inc({topic:r,status:t})},onMsgRecvInvalid:function(e,t){var r=this.toTopic(e),n=t.reason===yl.Error?t.error:t.reason;this.msgReceivedInvalid.inc({topic:r,error:n},1)},onDuplicateMsgDelivery:function(e,t,r){if(this.duplicateMsgDeliveryDelay.observe(t/1e3),r){var n=this.toTopic(e);this.duplicateMsgLateDelivery.inc({topic:n},1)}},onRpcRecv:function(e,t){this.rpcRecvBytes.inc(t),this.rpcRecvCount.inc(1),e.subscriptions&&this.rpcRecvSubscription.inc(e.subscriptions.length),e.messages&&this.rpcRecvMessage.inc(e.messages.length),e.control&&(this.rpcRecvControl.inc(1),e.control.ihave&&this.rpcRecvIHave.inc(e.control.ihave.length),e.control.iwant&&this.rpcRecvIWant.inc(e.control.iwant.length),e.control.graft&&this.rpcRecvGraft.inc(e.control.graft.length),e.control.prune&&this.rpcRecvPrune.inc(e.control.prune.length))},onRpcSent:function(e,t){if(this.rpcSentBytes.inc(t),this.rpcSentCount.inc(1),e.subscriptions&&this.rpcSentSubscription.inc(e.subscriptions.length),e.messages&&this.rpcSentMessage.inc(e.messages.length),e.control){var r,n,i,o,a,s,u,c,l=null!==(r=null===(n=e.control.ihave)||void 0===n?void 0:n.length)&&void 0!==r?r:0,f=null!==(i=null===(o=e.control.iwant)||void 0===o?void 0:o.length)&&void 0!==i?i:0,h=null!==(a=null===(s=e.control.graft)||void 0===s?void 0:s.length)&&void 0!==a?a:0,d=null!==(u=null===(c=e.control.prune)||void 0===c?void 0:c.length)&&void 0!==u?u:0;l>0&&this.rpcSentIHave.inc(l),f>0&&this.rpcSentIWant.inc(f),h>0&&this.rpcSentGraft.inc(h),d>0&&this.rpcSentPrune.inc(d),(l>0||f>0||h>0||d>0)&&this.rpcSentControl.inc(1)}},registerScores:function(e,t){var r,n=0,i=0,o=0,a=0,s=rt(e);try{for(s.s();!(r=s.n()).done;){var u=r.value;u>=t.graylistThreshold&&n++,u>=t.publishThreshold&&i++,u>=t.gossipThreshold&&o++,u>=0&&a++}}catch(c){s.e(c)}finally{s.f()}this.peersByScoreThreshold.set({threshold:Kl.graylist},n),this.peersByScoreThreshold.set({threshold:Kl.publish},i),this.peersByScoreThreshold.set({threshold:Kl.gossip},o),this.peersByScoreThreshold.set({threshold:Kl.mesh},a),this.score.set(e)},registerScoreWeights:function(e){var t,r=rt(e.byTopic);try{for(r.s();!(t=r.n()).done;){var n=P(t.value,2),i=n[0],o=n[1];this.scoreWeights.set({topic:i,p:"p1"},o.p1w),this.scoreWeights.set({topic:i,p:"p2"},o.p2w),this.scoreWeights.set({topic:i,p:"p3"},o.p3w),this.scoreWeights.set({topic:i,p:"p3b"},o.p3bw),this.scoreWeights.set({topic:i,p:"p4"},o.p4w)}}catch(a){r.e(a)}finally{r.f()}this.scoreWeights.set({p:"p5"},e.p5w),this.scoreWeights.set({p:"p6"},e.p6w),this.scoreWeights.set({p:"p7"},e.p7w)},registerScorePerMesh:function(e,t){var r=this,n=new Map;e.forEach((function(e,t){var i,o=null!==(i=r.topicStrToLabel.get(t))&&void 0!==i?i:"unknown",a=n.get(o);a||(a=new Set,n.set(o,a)),e.forEach((function(e){var t;return null===(t=a)||void 0===t?void 0:t.add(e)}))}));var i,o=rt(n);try{var a=function(){var e=P(i.value,2),n=e[0],o=e[1],a=[];o.forEach((function(e){var r;a.push(null!==(r=t.get(e))&&void 0!==r?r:0)})),r.scorePerMesh.set({topic:n},a)};for(o.s();!(i=o.n()).done;)a()}catch(s){o.e(s)}finally{o.f()}}}}!function(e){e.forward="forward",e.publish="publish"}(Fl||(Fl={})),function(e){e.Fanout="fanout",e.Random="random",e.Subscribed="subscribed",e.Outbound="outbound",e.NotEnough="not_enough",e.Opportunistic="opportunistic"}(zl||(zl={})),function(e){e.Dc="disconnected",e.BadScore="bad_score",e.Prune="prune",e.Unsub="unsubscribed",e.Excess="excess"}(Zl||(Zl={})),function(e){e.GraftBackoff="graft_backoff",e.BrokenPromise="broken_promise",e.MessageDeficit="message_deficit",e.IPColocation="IP_colocation"}(jl||(jl={})),function(e){e.LowScore="low_score",e.MaxIhave="max_ihave",e.MaxIasked="max_iasked"}(ql||(ql={})),function(e){e.graylist="graylist",e.publish="publish",e.gossip="gossip",e.mesh="mesh"}(Kl||(Kl={}));r(9521);r(3611);var Yl=jr("libp2p-pubsub:");function Xl(e,t,r,n){return $l.apply(this,arguments)}function $l(){return($l=(0,S.Z)((0,_.Z)().mark((function e(t,r,n,i){var o,a,s;return(0,_.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:e.t0=t.type,e.next=e.t0===vl.Signing?3:e.t0===vl.Anonymous?11:12;break;case 3:return o={from:t.author.toBytes(),data:i,seqno:Hi(8),topic:r,signature:void 0,key:void 0},a=pi([Yl,ol.Message.encode(o).finish()]),e.next=7,t.privateKey.sign(a);case 7:return o.signature=e.sent,o.key=t.key,s={type:"signed",from:t.author,data:n,sequenceNumber:BigInt("0x".concat(qr(o.seqno,"base16"))),topic:r,signature:o.signature,key:o.key},e.abrupt("return",{raw:o,msg:s});case 11:return e.abrupt("return",{raw:{from:void 0,data:i,seqno:void 0,topic:r,signature:void 0,key:void 0},msg:{type:"unsigned",data:n,topic:r}});case 12:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function ef(e,t){return tf.apply(this,arguments)}function tf(){return(tf=(0,S.Z)((0,_.Z)().mark((function e(t,r){var n,i,o,a,s,u,c;return(0,_.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:e.t0=t,e.next=e.t0===kl?3:e.t0===wl?10:41;break;case 3:if(null==r.signature){e.next=5;break}return e.abrupt("return",{valid:!1,error:ml.SignaturePresent});case 5:if(null==r.seqno){e.next=7;break}return e.abrupt("return",{valid:!1,error:ml.SeqnoPresent});case 7:if(null==r.key){e.next=9;break}return e.abrupt("return",{valid:!1,error:ml.FromPresent});case 9:return e.abrupt("return",{valid:!0,message:{type:"unsigned",topic:r.topic,data:null!==(n=r.data)&&void 0!==n?n:new Uint8Array(0)}});case 10:if(null!=r.seqno){e.next=12;break}return e.abrupt("return",{valid:!1,error:ml.InvalidSeqno});case 12:if(8===r.seqno.length){e.next=14;break}return e.abrupt("return",{valid:!1,error:ml.InvalidSeqno});case 14:if(null!=r.signature){e.next=16;break}return e.abrupt("return",{valid:!1,error:ml.InvalidSignature});case 16:if(null!=r.from){e.next=18;break}return e.abrupt("return",{valid:!1,error:ml.InvalidPeerId});case 18:e.prev=18,a=vs(r.from),e.next=25;break;case 22:return e.prev=22,e.t1=e.catch(18),e.abrupt("return",{valid:!1,error:ml.InvalidPeerId});case 25:if(!r.key){e.next=31;break}if(s=ns(r.key),void 0===a.publicKey||Vi(s.bytes,a.publicKey)){e.next=29;break}return e.abrupt("return",{valid:!1,error:ml.InvalidPeerId});case 29:e.next=34;break;case 31:if(null!=a.publicKey){e.next=33;break}return e.abrupt("return",{valid:!1,error:ml.InvalidPeerId});case 33:s=ns(a.publicKey);case 34:return u={from:r.from,data:r.data,seqno:r.seqno,topic:r.topic,signature:void 0,key:void 0},c=pi([Yl,ol.Message.encode(u).finish()]),e.next=38,s.verify(c,r.signature);case 38:if(e.sent){e.next=40;break}return e.abrupt("return",{valid:!1,error:ml.InvalidSignature});case 40:return e.abrupt("return",{valid:!0,message:{type:"signed",from:a,data:null!==(i=r.data)&&void 0!==i?i:new Uint8Array(0),sequenceNumber:BigInt("0x".concat(qr(r.seqno,"base16"))),topic:r.topic,signature:r.signature,key:null!==(o=r.key)&&void 0!==o?o:is(s)}});case 41:case"end":return e.stop()}}),e,null,[[18,22]])})))).apply(this,arguments)}function rf(e){if("signed"!==e.type)throw new Error("expected signed message type");if(null==e.sequenceNumber)throw Error("missing seqno field");return function(e,t){var r=jr(t.toString(16).padStart(16,"0"),"base16"),n=new Uint8Array(e.length+r.length);return n.set(e,0),n.set(r,e.length),n}(e.from.toBytes(),e.sequenceNumber)}function nf(e){return of.apply(this,arguments)}function of(){return(of=(0,S.Z)((0,_.Z)().mark((function e(t){return(0,_.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,cr.encode(t.data);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function af(e,t,r,n,i){var o=0,a=new Map;if(Object.entries(t.topics).forEach((function(e){var t,n=P(e,2),s=n[0],u=n[1],c=null!==(t=i.get(s))&&void 0!==t?t:"unknown",l=r.topics[s];if(void 0!==l){var f=a.get(c);f||(f={p1w:0,p2w:0,p3w:0,p3bw:0,p4w:0},a.set(c,f));var h=0,d=0,p=0,v=0,g=0;if(u.inMesh)h+=Math.max(u.meshTime/l.timeInMeshQuantum,l.timeInMeshCap)*l.timeInMeshWeight;var y=u.firstMessageDeliveries;if(y>l.firstMessageDeliveriesCap&&(y=l.firstMessageDeliveriesCap),d+=y*l.firstMessageDeliveriesWeight,u.meshMessageDeliveriesActive&&u.meshMessageDeliveries0&&o>r.topicScoreCap){o=r.topicScoreCap;var s,u=r.topicScoreCap/o,c=rt(a.values());try{for(c.s();!(s=c.n()).done;){var l=s.value;l.p1w*=u,l.p2w*=u,l.p3w*=u,l.p3bw*=u,l.p4w*=u}}catch(p){c.e(p)}finally{c.f()}}var f=0,h=0,d=0;return f+=r.appSpecificScore(e)*r.appSpecificWeight,t.ips.forEach((function(e){if(!r.IPColocationFactorWhitelist.has(e)){var t=n.get(e),i=t?t.size:0;if(i>r.IPColocationFactorThreshold){var o=i-r.IPColocationFactorThreshold;h+=o*o*r.IPColocationFactorWeight}}})),d+=t.behaviourPenalty*t.behaviourPenalty*r.behaviourPenaltyWeight,{byTopic:a,p5w:f,p6w:h,p7w:d,score:o+=f+h+d}}function sf(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:function(){return!0},n=new Set;if(t<=0)return n;var i,o=rt(e);try{for(o.s();!(i=o.n()).done;){var a=i.value;if(n.size>=t)break;r(a)&&(n.add(a),e.delete(a))}}catch(s){o.e(s)}finally{o.f()}return n}function uf(e,t){return sf(e,t,(function(){return!0}))}var cf=function(e){Z(r,e);var t=G(r);function r(e,n){var i;return(0,F.Z)(this,r),(i=t.call(this,null!==e&&void 0!==e?e:"The operation was aborted")).type="aborted",i.code=null!==n&&void 0!==n?n:"ABORT_ERR",i}return(0,U.Z)(r)}(Q(Error));function lf(e,t,r){var n=null!==r&&void 0!==r?r:{},i=function(e){if(null!=e){if("function"===typeof e[Symbol.iterator])return e[Symbol.iterator]();if("function"===typeof e[Symbol.asyncIterator])return e[Symbol.asyncIterator]();if("function"===typeof e.next)return e}throw new Error("argument is not an iterator or iterable")}(e);function o(){return(o=Js((0,_.Z)().mark((function r(){var o,a,s,u,c,l,f,h;return(0,_.Z)().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:a=function(){null!=o&&o()},t.addEventListener("abort",a);case 2:if(s=void 0,r.prev=4,!t.aborted){r.next=8;break}throw u=n.abortMessage,c=n.abortCode,new cf(u,c);case 8:return l=new Promise((function(e,t){o=function(){var e=n.abortMessage,r=n.abortCode;t(new cf(e,r))}})),r.next=11,Ys(Promise.race([l,i.next()]));case 11:s=r.sent,o=null,r.next=26;break;case 15:if(r.prev=15,r.t0=r.catch(4),t.removeEventListener("abort",a),!(f="aborted"===r.t0.type&&t.aborted)||null==n.onAbort){r.next=22;break}return r.next=22,Ys(n.onAbort(e));case 22:if("function"===typeof i.return)try{(h=i.return())instanceof Promise&&h.catch((function(e){null!=n.onReturnError&&n.onReturnError(e)}))}catch(d){null!=n.onReturnError&&n.onReturnError(d)}if(!f||!0!==n.returnOnAbort){r.next=25;break}return r.abrupt("return");case 25:throw r.t0;case 26:if(!0!==s.done){r.next=28;break}return r.abrupt("break",32);case 28:return r.next=30,s.value;case 30:r.next=2;break;case 32:t.removeEventListener("abort",a);case 33:case"end":return r.stop()}}),r,null,[[4,15]])})))).apply(this,arguments)}return function(){return o.apply(this,arguments)}()}var ff,hf=function(){function e(t,r,n){var i;(0,F.Z)(this,e),this.rawStream=t,this.pushable=Au({objectMode:!1}),this.closeController=new AbortController,this.maxBufferSize=null!==(i=n.maxBufferSize)&&void 0!==i?i:1/0,Mu(lf(this.pushable,this.closeController.signal,{returnOnAbort:!0}),bu(),this.rawStream).catch(r)}return(0,U.Z)(e,[{key:"protocol",get:function(){return this.rawStream.stat.protocol}},{key:"push",value:function(e){if(this.pushable.readableLength>this.maxBufferSize)throw Error("OutboundStream buffer full, size > ".concat(this.maxBufferSize));this.pushable.push(e)}},{key:"close",value:function(){this.closeController.abort(),this.pushable.return(),this.rawStream.close()}}]),e}(),df=function(){function e(t){(0,F.Z)(this,e),this.rawStream=t,this.closeController=new AbortController,this.source=lf(Mu(this.rawStream,Eu()),this.closeController.signal,{returnOnAbort:!0})}return(0,U.Z)(e,[{key:"close",value:function(){this.closeController.abort(),this.rawStream.close()}}]),e}();!function(e){e[e.started=0]="started",e[e.stopped=1]="stopped"}(ff||(ff={}));var pf=function(e){Z(r,e);var t=G(r);function r(){var e,n,i,o,a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};(0,F.Z)(this,r),(o=t.call(this)).multicodecs=[ul,sl],o.peers=new Set,o.streamsInbound=new Map,o.streamsOutbound=new Map,o.outboundInflightQueue=Au({objectMode:!0}),o.direct=new Set,o.floodsubPeers=new Set,o.acceptFromWhitelist=new Map,o.topics=new Map,o.subscriptions=new Set,o.mesh=new Map,o.fanout=new Map,o.fanoutLastpub=new Map,o.gossip=new Map,o.control=new Map,o.peerhave=new Map,o.iasked=new Map,o.backoff=new Map,o.outbound=new Map,o.topicValidators=new Map,o.heartbeatTicks=0,o.components=new Vl,o.directPeerInitial=null,o.status={code:ff.stopped},o.heartbeatTimer=null,o.runHeartbeat=function(){var e,t=null===(e=o.metrics)||void 0===e?void 0:e.heartbeatDuration.startTimer();o.heartbeat().catch((function(e){o.log("Error running heartbeat",e)})).finally((function(){if(null!=t&&t(),o.status.code===ff.started){clearTimeout(o.status.heartbeatTimeout);var e,r=o.opts.heartbeatInterval-(Date.now()-o.status.hearbeatStartMs)%o.opts.heartbeatInterval;if(r<.25*o.opts.heartbeatInterval)r+=o.opts.heartbeatInterval,null===(e=o.metrics)||void 0===e||e.heartbeatSkipped.inc();o.status.heartbeatTimeout=setTimeout(o.runHeartbeat,r)}}))};var s=L(L({fallbackToFloodsub:!0,floodPublish:!0,doPX:!1,directPeers:[],D:6,Dlo:4,Dhi:12,Dscore:4,Dout:2,Dlazy:6,heartbeatInterval:1e3,fanoutTTL:6e4,mcacheLength:5,mcacheGossip:3,seenTTL:ll,gossipsubIWantFollowupMs:3e3,prunePeers:16,pruneBackoff:6e4,graftFloodThreshold:1e4,opportunisticGraftPeers:2,opportunisticGraftTicks:60,directConnectTicks:300},a),{},{scoreParams:Cl(a.scoreParams),scoreThresholds:Bl(a.scoreThresholds)});if(o.globalSignaturePolicy=null!==(e=s.globalSignaturePolicy)&&void 0!==e?e:wl,s.fallbackToFloodsub&&o.multicodecs.push(al),o.log=Wc(null!==(n=s.debugName)&&void 0!==n?n:"libp2p:gossipsub"),o.opts=s,o.direct=new Set(s.directPeers.map((function(e){return e.id.toString()}))),o.seenCache=new Ql({validityMs:s.seenTTL}),o.publishedMessageIds=new Ql({validityMs:s.seenTTL}),a.msgIdFn)o.msgIdFn=a.msgIdFn;else switch(o.globalSignaturePolicy){case wl:o.msgIdFn=rf;break;case kl:o.msgIdFn=nf}if(a.fastMsgIdFn&&(o.fastMsgIdFn=a.fastMsgIdFn,o.fastMsgIdCache=new Ql({validityMs:s.seenTTL})),o.msgIdToStrFn=null!==(i=a.msgIdToStrFn)&&void 0!==i?i:dl,o.mcache=a.messageCache||new il(s.mcacheGossip,s.mcacheLength,o.msgIdToStrFn),a.dataTransform&&(o.dataTransform=a.dataTransform),a.metricsRegister){if(!a.metricsTopicStrToLabel)throw Error("Must set metricsTopicStrToLabel with metrics");var u=Math.max.apply(Math,$r(Object.values(s.scoreParams.topics).map((function(e){return e.meshMessageDeliveriesWindow}))).concat([1e3])),c=Jl(a.metricsRegister,a.metricsTopicStrToLabel,{gossipPromiseExpireSec:o.opts.gossipsubIWantFollowupMs/1e3,behaviourPenaltyThreshold:s.scoreParams.behaviourPenaltyThreshold,maxMeshMessageDeliveriesWindowSec:u/1e3});c.mcacheSize.addCollect((function(){return o.onScrapeMetrics(c)}));var l,f=rt(o.multicodecs);try{for(f.s();!(l=f.n()).done;){var h=l.value;c.protocolsEnabled.set({protocol:h},1)}}catch(d){f.e(d)}finally{f.f()}o.metrics=c}else o.metrics=null;return o.gossipTracer=new Wl(o.opts.gossipsubIWantFollowupMs,o.msgIdToStrFn,o.metrics),o.score=new Gl(o.opts.scoreParams,o.metrics,{scoreCacheValidityMs:s.heartbeatInterval}),o.maxInboundStreams=a.maxInboundStreams,o.maxOutboundStreams=a.maxOutboundStreams,o}return(0,U.Z)(r,[{key:"getPeers",value:function(){return $r(this.peers.keys()).map((function(e){return ps(e)}))}},{key:"isStarted",value:function(){return this.status.code===ff.started}},{key:"init",value:function(){var e=(0,S.Z)((0,_.Z)().mark((function e(t){return(0,_.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.components=t,this.score.init(t);case 2:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}()},{key:"start",value:function(){var e=(0,S.Z)((0,_.Z)().mark((function e(){var t,r,n,i,o=this;return(0,_.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.isStarted()){e.next=2;break}return e.abrupt("return");case 2:return this.log("starting"),e.next=5,xl(this.globalSignaturePolicy,this.components.getPeerId());case 5:return this.publishConfig=e.sent,this.outboundInflightQueue=Au({objectMode:!0}),Mu(this.outboundInflightQueue,function(){var e=(0,S.Z)((0,_.Z)().mark((function e(t){var r,n,i,a,s,u,c,l;return(0,_.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=!1,n=!1,e.prev=2,a=$s(t);case 4:return e.next=6,a.next();case 6:if(!(r=!(s=e.sent).done)){e.next=13;break}return u=s.value,c=u.peerId,l=u.connection,e.next=10,o.createOutboundStream(c,l);case 10:r=!1,e.next=4;break;case 13:e.next=19;break;case 15:e.prev=15,e.t0=e.catch(2),n=!0,i=e.t0;case 19:if(e.prev=19,e.prev=20,!r||null==a.return){e.next=24;break}return e.next=24,a.return();case 24:if(e.prev=24,!n){e.next=27;break}throw i;case 27:return e.finish(24);case 28:return e.finish(19);case 29:case"end":return e.stop()}}),e,null,[[2,15,19,29],[20,,24,28]])})));return function(t){return e.apply(this,arguments)}}()).catch((function(e){return o.log.error("outbound inflight queue error",e)})),e.next=10,Promise.all(this.opts.directPeers.map(function(){var e=(0,S.Z)((0,_.Z)().mark((function e(t){return(0,_.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,o.components.getPeerStore().addressBook.add(t.id,t.addrs);case 2:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()));case 10:return t=this.components.getRegistrar(),e.next=13,Promise.all(this.multicodecs.map((function(e){return t.handle(e,o.onIncomingStream.bind(o),{maxInboundStreams:o.maxInboundStreams,maxOutboundStreams:o.maxOutboundStreams})})));case 13:return a={onConnect:this.onPeerConnected.bind(this),onDisconnect:this.onPeerDisconnected.bind(this)},r=new Xc(a),e.next=16,Promise.all(this.multicodecs.map((function(e){return t.register(e,r)})));case 16:n=e.sent,i=setTimeout(this.runHeartbeat,100),this.status={code:ff.started,registrarTopologyIds:n,heartbeatTimeout:i,hearbeatStartMs:Date.now()+100},this.score.start(),this.directPeerInitial=setTimeout((function(){Promise.resolve().then((0,S.Z)((0,_.Z)().mark((function e(){return(0,_.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,Promise.all(Array.from(o.direct).map(function(){var e=(0,S.Z)((0,_.Z)().mark((function e(t){return(0,_.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,o.connect(t);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()));case 2:case"end":return e.stop()}}),e)})))).catch((function(e){o.log(e)}))}),1e3),this.log("started");case 22:case"end":return e.stop()}var a}),e,this)})));return function(){return e.apply(this,arguments)}}()},{key:"stop",value:function(){var e=(0,S.Z)((0,_.Z)().mark((function e(){var t,r,n,i,o,a;return(0,_.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.log("stopping"),this.status.code===ff.started){e.next=3;break}return e.abrupt("return");case 3:t=this.status.registrarTopologyIds,this.status={code:ff.stopped},r=this.components.getRegistrar(),t.forEach((function(e){return r.unregister(e)})),this.outboundInflightQueue.end(),n=rt(this.streamsOutbound.values());try{for(n.s();!(i=n.n()).done;)i.value.close()}catch(s){n.e(s)}finally{n.f()}this.streamsOutbound.clear(),o=rt(this.streamsInbound.values());try{for(o.s();!(a=o.n()).done;)a.value.close()}catch(s){o.e(s)}finally{o.f()}this.streamsInbound.clear(),this.peers.clear(),this.subscriptions.clear(),this.heartbeatTimer&&(this.heartbeatTimer.cancel(),this.heartbeatTimer=null),this.score.stop(),this.mesh.clear(),this.fanout.clear(),this.fanoutLastpub.clear(),this.gossip.clear(),this.control.clear(),this.peerhave.clear(),this.iasked.clear(),this.backoff.clear(),this.outbound.clear(),this.gossipTracer.clear(),this.seenCache.clear(),this.fastMsgIdCache&&this.fastMsgIdCache.clear(),this.directPeerInitial&&clearTimeout(this.directPeerInitial),this.log("stopped");case 32:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}()},{key:"dumpPeerScoreStats",value:function(){return this.score.dumpPeerScoreStats()}},{key:"onIncomingStream",value:function(e){var t=e.stream,r=e.connection;if(this.isStarted()){var n=r.remotePeer;this.addPeer(n,r.stat.direction),this.createInboundStream(n,t),this.outboundInflightQueue.push({peerId:n,connection:r})}}},{key:"onPeerConnected",value:function(e,t){this.isStarted()&&(this.addPeer(e,t.stat.direction),this.outboundInflightQueue.push({peerId:e,connection:t}))}},{key:"onPeerDisconnected",value:function(e){this.log("connection ended %p",e),this.removePeer(e)}},{key:"createOutboundStream",value:function(){var e=(0,S.Z)((0,_.Z)().mark((function e(t,r){var n,i,o,a,s=this;return(0,_.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.isStarted()){e.next=2;break}return e.abrupt("return");case 2:if(n=t.toString(),this.peers.has(n)){e.next=5;break}return e.abrupt("return");case 5:if(!this.streamsOutbound.has(n)){e.next=7;break}return e.abrupt("return");case 7:return e.prev=7,e.t0=hf,e.next=11,r.newStream(this.multicodecs);case 11:e.t1=e.sent,e.t2=function(e){return s.log.error("outbound pipe error",e)},e.t3={maxBufferSize:this.opts.maxOutboundBufferSize},o=new e.t0(e.t1,e.t2,e.t3),this.log("create outbound stream %p",t),this.streamsOutbound.set(n,o),(a=o.protocol)===al&&this.floodsubPeers.add(n),null===(i=this.metrics)||void 0===i||i.peersPerProtocol.inc({protocol:a},1),this.subscriptions.size>0&&(this.log("send subscriptions to",n),this.sendSubscriptions(n,Array.from(this.subscriptions),!0)),e.next=26;break;case 23:e.prev=23,e.t4=e.catch(7),this.log.error("createOutboundStream error",e.t4);case 26:case"end":return e.stop()}}),e,this,[[7,23]])})));return function(t,r){return e.apply(this,arguments)}}()},{key:"createInboundStream",value:function(){var e=(0,S.Z)((0,_.Z)().mark((function e(t,r){var n,i,o,a=this;return(0,_.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.isStarted()){e.next=2;break}return e.abrupt("return");case 2:if(n=t.toString(),this.peers.has(n)){e.next=5;break}return e.abrupt("return");case 5:void 0!==(i=this.streamsInbound.get(n))&&(this.log("replacing existing inbound steam %s",n),i.close()),this.log("create inbound stream %s",n),o=new df(r),this.streamsInbound.set(n,o),this.pipePeerReadStream(t,o.source).catch((function(e){return a.log(e)}));case 11:case"end":return e.stop()}}),e,this)})));return function(t,r){return e.apply(this,arguments)}}()},{key:"addPeer",value:function(e,t){var r=e.toString();this.peers.has(r)||(this.log("new peer %p",e),this.peers.add(r),this.score.addPeer(r),this.outbound.has(r)||this.outbound.set(r,"outbound"===t))}},{key:"removePeer",value:function(e){var t=e.toString();if(this.peers.has(t)){this.log("delete peer %p",e),this.peers.delete(t);var r,n=this.streamsOutbound.get(t),i=this.streamsInbound.get(t);if(n)null===(r=this.metrics)||void 0===r||r.peersPerProtocol.inc({protocol:n.protocol},-1);null===n||void 0===n||n.close(),null===i||void 0===i||i.close(),this.streamsOutbound.delete(t),this.streamsInbound.delete(t);var o,a=rt(this.topics.values());try{for(a.s();!(o=a.n()).done;){o.value.delete(t)}}catch(p){a.e(p)}finally{a.f()}var s,u=rt(this.mesh);try{for(u.s();!(s=u.n()).done;){var c,l=P(s.value,2),f=l[0];if(!0===l[1].delete(t))null===(c=this.metrics)||void 0===c||c.onRemoveFromMesh(f,Zl.Dc,1)}}catch(p){u.e(p)}finally{u.f()}var h,d=rt(this.fanout.values());try{for(d.s();!(h=d.n()).done;){h.value.delete(t)}}catch(p){d.e(p)}finally{d.f()}this.floodsubPeers.delete(t),this.gossip.delete(t),this.control.delete(t),this.outbound.delete(t),this.score.removePeer(t),this.acceptFromWhitelist.delete(t)}}},{key:"started",get:function(){return this.status.code===ff.started}},{key:"getMeshPeers",value:function(e){var t=this.mesh.get(e);return t?Array.from(t):[]}},{key:"getSubscribers",value:function(e){var t=this.topics.get(e);return(t?Array.from(t):[]).map((function(e){return ps(e)}))}},{key:"getTopics",value:function(){return Array.from(this.subscriptions)}},{key:"pipePeerReadStream",value:function(){var e=(0,S.Z)((0,_.Z)().mark((function e(t,r){var n=this;return(0,_.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,Mu(r,function(){var e=(0,S.Z)((0,_.Z)().mark((function e(r){var i,o,a,s,u,c,l,f,h;return(0,_.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:i=!1,o=!1,e.prev=2,s=$s(r);case 4:return e.next=6,s.next();case 6:if(!(i=!(u=e.sent).done)){e.next=26;break}if(c=u.value,e.prev=8,f=c.subarray(),h=ol.decode(f),null===(l=n.metrics)||void 0===l||l.onRpcRecv(h,f.length),!n.opts.awaitRpcHandler){e.next=17;break}return e.next=15,n.handleReceivedRpc(t,h);case 15:e.next=18;break;case 17:n.handleReceivedRpc(t,h).catch((function(e){return n.log(e)}));case 18:e.next=23;break;case 20:e.prev=20,e.t0=e.catch(8),n.log(e.t0);case 23:i=!1,e.next=4;break;case 26:e.next=32;break;case 28:e.prev=28,e.t1=e.catch(2),o=!0,a=e.t1;case 32:if(e.prev=32,e.prev=33,!i||null==s.return){e.next=37;break}return e.next=37,s.return();case 37:if(e.prev=37,!o){e.next=40;break}throw a;case 40:return e.finish(37);case 41:return e.finish(32);case 42:case"end":return e.stop()}}),e,null,[[2,28,32,42],[8,20],[33,,37,41]])})));return function(t){return e.apply(this,arguments)}}());case 3:e.next=9;break;case 5:e.prev=5,e.t0=e.catch(0),this.log.error(e.t0),this.onPeerDisconnected(t);case 9:case"end":return e.stop()}}),e,this,[[0,5]])})));return function(t,r){return e.apply(this,arguments)}}()},{key:"handleReceivedRpc",value:function(){var e=(0,S.Z)((0,_.Z)().mark((function e(t,r){var n,i,o,a,s,u=this;return(0,_.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.acceptFrom(t.toString())){e.next=4;break}return this.log("received message from unacceptable peer %p",t),null===(n=this.metrics)||void 0===n||n.rpcRecvNotAccepted.inc(),e.abrupt("return");case 4:if(this.log("rpc from %p",t),r.subscriptions&&r.subscriptions.length>0&&(r.subscriptions.forEach((function(e){u.handleReceivedSubscription(t,e)})),this.dispatchEvent(new nl("subscription-change",{detail:{peerId:t,subscriptions:r.subscriptions.filter((function(e){return null!==e.topic})).map((function(e){var t;return{topic:null!==(t=e.topic)&&void 0!==t?t:"",subscribe:Boolean(e.subscribe)}}))}}))),!r.messages){e.next=26;break}i=rt(r.messages),e.prev=8,i.s();case 10:if((o=i.n()).done){e.next=18;break}if(a=o.value,s=this.handleReceivedMessage(t,a).catch((function(e){return u.log(e)})),!this.opts.awaitRpcMessageHandler){e.next=16;break}return e.next=16,s;case 16:e.next=10;break;case 18:e.next=23;break;case 20:e.prev=20,e.t0=e.catch(8),i.e(e.t0);case 23:return e.prev=23,i.f(),e.finish(23);case 26:if(!r.control){e.next=29;break}return e.next=29,this.handleControlMessage(t.toString(),r.control);case 29:case"end":return e.stop()}}),e,this,[[8,20,23,26]])})));return function(t,r){return e.apply(this,arguments)}}()},{key:"handleReceivedSubscription",value:function(e,t){if(null!=t.topic){this.log("subscription update from %p topic %s",e,t.topic);var r=this.topics.get(t.topic);null==r&&(r=new Set,this.topics.set(t.topic,r)),t.subscribe?r.add(e.toString()):r.delete(e.toString())}}},{key:"handleReceivedMessage",value:function(){var e=(0,S.Z)((0,_.Z)().mark((function e(t,n){var i,o,a,s,u;return(0,_.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return null===(i=this.metrics)||void 0===i||i.onMsgRecvPreValidation(n.topic),e.next=3,this.validateReceivedMessage(t,n);case 3:s=e.sent,null===(o=this.metrics)||void 0===o||o.onMsgRecvResult(n.topic,s.code),e.t0=s.code,e.next=e.t0===bl.duplicate?8:e.t0===bl.invalid?11:e.t0===bl.valid?14:19;break;case 8:return this.score.duplicateMessage(t.toString(),s.msgIdStr,n.topic),this.mcache.observeDuplicate(s.msgIdStr,t.toString()),e.abrupt("return");case 11:return s.msgIdStr?(u=s.msgIdStr,this.score.rejectMessage(t.toString(),u,n.topic,s.reason),this.gossipTracer.rejectMessage(u,s.reason)):this.score.rejectInvalidMessage(t.toString(),n.topic),null===(a=this.metrics)||void 0===a||a.onMsgRecvInvalid(n.topic,s),e.abrupt("return");case 14:this.score.validateMessage(s.messageId.msgIdStr),this.gossipTracer.deliverMessage(s.messageId.msgIdStr),this.mcache.put(s.messageId,n,!this.opts.asyncValidation),this.subscriptions.has(n.topic)&&(this.components.getPeerId().equals(t)&&!this.opts.emitSelf||(tn(j(r.prototype),"dispatchEvent",this).call(this,new nl("gossipsub:message",{detail:{propagationSource:t,msgId:s.messageId.msgIdStr,msg:s.msg}})),tn(j(r.prototype),"dispatchEvent",this).call(this,new nl("message",{detail:s.msg})))),this.opts.asyncValidation||this.forwardMessage(s.messageId.msgIdStr,n,t.toString());case 19:case"end":return e.stop()}}),e,this)})));return function(t,r){return e.apply(this,arguments)}}()},{key:"validateReceivedMessage",value:function(){var e=(0,S.Z)((0,_.Z)().mark((function e(t,r){var n,i,o,a,s,u,c,l,f,h,d,p,v;return(0,_.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(a=null===(n=this.fastMsgIdFn)||void 0===n?void 0:n.call(this,r),!(s=a?null===(i=this.fastMsgIdCache)||void 0===i?void 0:i.get(a):void 0)){e.next=4;break}return e.abrupt("return",{code:bl.duplicate,msgIdStr:s});case 4:return e.next=6,ef(this.globalSignaturePolicy,r);case 6:if((u=e.sent).valid){e.next=9;break}return e.abrupt("return",{code:bl.invalid,reason:yl.Error,error:u.error});case 9:c=u.message,e.prev=10,this.dataTransform&&(c.data=this.dataTransform.inboundTransform(r.topic,c.data)),e.next=18;break;case 14:return e.prev=14,e.t0=e.catch(10),this.log("Invalid message, transform failed",e.t0),e.abrupt("return",{code:bl.invalid,reason:yl.Error,error:ml.TransformFailed});case 18:return e.next=20,this.msgIdFn(c);case 20:if(l=e.sent,f=this.msgIdToStrFn(l),h={msgId:l,msgIdStr:f},a&&(null===(o=this.fastMsgIdCache)||void 0===o||o.put(a,f)),!this.seenCache.has(f)){e.next=28;break}return e.abrupt("return",{code:bl.duplicate,msgIdStr:f});case 28:this.seenCache.put(f);case 29:if(null==(d=this.topicValidators.get(r.topic))){e.next=44;break}return e.prev=31,e.next=34,d(c.topic,c,t);case 34:p=e.sent,e.next=42;break;case 37:e.prev=37,e.t1=e.catch(31),"ERR_TOPIC_VALIDATOR_IGNORE"===(v=e.t1.code)&&(p=gl.Ignore),p="ERR_TOPIC_VALIDATOR_REJECT"===v?gl.Reject:gl.Ignore;case 42:if(p===gl.Accept){e.next=44;break}return e.abrupt("return",{code:bl.invalid,reason:El(p),msgIdStr:f});case 44:return e.abrupt("return",{code:bl.valid,messageId:h,msg:c});case 45:case"end":return e.stop()}}),e,this,[[10,14],[31,37]])})));return function(t,r){return e.apply(this,arguments)}}()},{key:"getScore",value:function(e){return this.score.score(e)}},{key:"sendSubscriptions",value:function(e,t,r){this.sendRpc(e,{subscriptions:t.map((function(e){return{topic:e,subscribe:r}})),messages:[]})}},{key:"handleControlMessage",value:function(){var e=(0,S.Z)((0,_.Z)().mark((function e(t,r){var n,i,o;return(0,_.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==r){e.next=2;break}return e.abrupt("return");case 2:if(n=r.ihave?this.handleIHave(t,r.ihave):[],i=r.iwant?this.handleIWant(t,r.iwant):[],!r.graft){e.next=10;break}return e.next=7,this.handleGraft(t,r.graft);case 7:e.t0=e.sent,e.next=11;break;case 10:e.t0=[];case 11:if(o=e.t0,e.t1=r.prune,!e.t1){e.next=16;break}return e.next=16,this.handlePrune(t,r.prune);case 16:if(n.length||i.length||o.length){e.next=18;break}return e.abrupt("return");case 18:this.sendRpc(t,fl(i,{iwant:n,prune:o}));case 19:case"end":return e.stop()}}),e,this)})));return function(t,r){return e.apply(this,arguments)}}()},{key:"acceptFrom",value:function(e){if(this.direct.has(e))return!0;var t=Date.now(),r=this.acceptFromWhitelist.get(e);if(r&&r.messagesAccepted<128&&r.acceptUntil>=t)return r.messagesAccepted+=1,!0;var n=this.score.score(e);return n>=0?this.acceptFromWhitelist.set(e,{messagesAccepted:0,acceptUntil:t+1e3}):this.acceptFromWhitelist.delete(e),n>=this.opts.scoreThresholds.graylistThreshold}},{key:"handleIHave",value:function(e,t){var r,n,i=this;if(!t.length)return[];var o,a=this.score.score(e);if(a10)return this.log("IHAVE: peer %s has advertised too many times (%d) within this heartbeat interval; ignoring",e,u),null===(s=this.metrics)||void 0===s||s.ihaveRcvIgnored.inc({reason:ql.MaxIhave}),[];var c,l=null!==(n=this.iasked.get(e))&&void 0!==n?n:0;if(l>=cl)return this.log("IHAVE: peer %s has already advertised too many messages (%d); ignoring",e,l),null===(c=this.metrics)||void 0===c||c.ihaveRcvIgnored.inc({reason:ql.MaxIasked}),[];var f=new Map;if(t.forEach((function(e){var t,r=e.topicID,n=e.messageIDs;if(r&&n&&i.mesh.has(r)){var o=0;n.forEach((function(e){var t=i.msgIdToStrFn(e);i.seenCache.has(t)||(f.set(t,e),o++)})),null===(t=i.metrics)||void 0===t||t.onIhaveRcv(r,n.length,o)}})),!f.size)return[];var h=f.size;h+l>cl&&(h=cl-l),this.log("IHAVE: Asking for %d out of %d messages from %s",h,f.size,e);var d=Array.from(f.values());return hl(d),d=d.slice(0,h),this.iasked.set(e,l+h),this.gossipTracer.addPromise(e,d),[{messageIDs:d}]}},{key:"handleIWant",value:function(e,t){var r,n=this;if(!t.length)return[];var i=this.score.score(e);if(i3?n.log("IWANT: Peer %s has asked for message %s too many times: ignoring request",e,t):o.set(i,u.msg)):s++}))})),null===(r=this.metrics)||void 0===r||r.onIwantRcv(a,s),o.size?(this.log("IWANT: Sending %d messages to %s",o.size,e),Array.from(o.values())):(this.log("IWANT: Could not provide any wanted messages to %s",e),[])}},{key:"handleGraft",value:function(){var e=(0,S.Z)((0,_.Z)().mark((function e(t,r){var n,i,o,a,s=this;return(0,_.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=[],i=this.score.score(t),o=Date.now(),a=this.opts.doPX,r.forEach((function(e){var r,u,c=e.topicID;if(c){var l=s.mesh.get(c);if(l){if(!l.has(t)){if(s.direct.has(t))return s.log("GRAFT: ignoring request from direct peer %s",t),n.push(c),void(a=!1);var f=null===(r=s.backoff.get(c))||void 0===r?void 0:r.get(t);if("number"===typeof f&&o=s.opts.Dhi&&!s.outbound.get(t))return n.push(c),void s.addBackoff(t,c);s.log("GRAFT: Add mesh link from %s in %s",t,c),s.score.graft(t,c),l.add(t),null===(u=s.metrics)||void 0===u||u.onAddToMesh(c,zl.Subscribed,1)}}else a=!1}})),n.length){e.next=7;break}return e.abrupt("return",[]);case 7:return e.next=9,Promise.all(n.map((function(e){return s.makePrune(t,e,a)})));case 9:return e.abrupt("return",e.sent);case 10:case"end":return e.stop()}}),e,this)})));return function(t,r){return e.apply(this,arguments)}}()},{key:"handlePrune",value:function(){var e=(0,S.Z)((0,_.Z)().mark((function e(t,r){var n,i,o,a,s,u,c,l,f;return(0,_.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=this.score.score(t),i=rt(r),e.prev=2,i.s();case 4:if((o=i.n()).done){e.next=23;break}if(a=o.value,s=a.topicID,u=a.backoff,c=a.peers,null!=s){e.next=8;break}return e.abrupt("continue",21);case 8:if(l=this.mesh.get(s)){e.next=11;break}return e.abrupt("return");case 11:if(this.log("PRUNE: Remove mesh link to %s in %s",t,s),this.score.prune(t,s),l.has(t)&&(l.delete(t),null===(f=this.metrics)||void 0===f||f.onRemoveFromMesh(s,Zl.Unsub,1)),"number"===typeof u&&u>0?this.doAddBackoff(t,s,1e3*u):this.addBackoff(t,s),!c||!c.length){e.next=21;break}if(!(nthis.opts.prunePeers&&(hl(t),t=t.slice(0,this.opts.prunePeers)),r=[],e.next=4,Promise.all(t.map(function(){var e=(0,S.Z)((0,_.Z)().mark((function e(t){var i,o,a;return(0,_.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t.peerID){e.next=2;break}return e.abrupt("return");case 2:if(i=vs(t.peerID).toString(),!n.peers.has(i)){e.next=5;break}return e.abrupt("return");case 5:if(t.signedPeerRecord){e.next=8;break}return r.push(i),e.abrupt("return");case 8:return e.prev=8,e.next=11,uc.openAndCertify(t.signedPeerRecord,"libp2p-peer-record");case 11:if(o=e.sent,a=o.peerId,o.peerId.equals(i)){e.next=16;break}return n.log("bogus peer record obtained through px: peer ID %p doesn't match expected peer %p",a,i),e.abrupt("return");case 16:return e.next=18,n.components.getPeerStore().addressBook.consumePeerRecord(o);case 18:if(e.sent){e.next=21;break}return n.log("bogus peer record obtained through px: could not add peer record to address book"),e.abrupt("return");case 21:r.push(i),e.next=27;break;case 24:e.prev=24,e.t0=e.catch(8),n.log("bogus peer record obtained through px: invalid signature or not a peer record");case 27:case"end":return e.stop()}}),e,null,[[8,24]])})));return function(t){return e.apply(this,arguments)}}()));case 4:if(r.length){e.next=6;break}return e.abrupt("return");case 6:return e.next=8,Promise.all(r.map(function(){var e=(0,S.Z)((0,_.Z)().mark((function e(t){return(0,_.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,n.connect(t);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()));case 8:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}()},{key:"connect",value:function(){var e=(0,S.Z)((0,_.Z)().mark((function e(t){var r,n,i,o,a,s,u;return(0,_.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.log("Initiating connection with %s",t),r=ps(t),e.next=4,this.components.getConnectionManager().openConnection(r);case 4:n=e.sent,i=rt(this.multicodecs);try{for(i.s();!(o=i.n()).done;){a=o.value,s=rt(this.components.getRegistrar().getTopologies(a));try{for(s.s();!(u=s.n()).done;)u.value.onConnect(r,n)}catch(c){s.e(c)}finally{s.f()}}}catch(c){i.e(c)}finally{i.f()}case 7:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}()},{key:"subscribe",value:function(e){if(this.status.code!==ff.started)throw new Error("Pubsub has not started");if(!this.subscriptions.has(e)){this.subscriptions.add(e);var t,r=rt(this.peers.keys());try{for(r.s();!(t=r.n()).done;){var n=t.value;this.sendSubscriptions(n,[e],!0)}}catch(i){r.e(i)}finally{r.f()}}this.join(e)}},{key:"unsubscribe",value:function(e){var t=this;if(this.status.code!==ff.started)throw new Error("Pubsub is not started");var r=this.subscriptions.delete(e);if(this.log("unsubscribe from %s - am subscribed %s",e,r),r){var n,i=rt(this.peers.keys());try{for(i.s();!(n=i.n()).done;){var o=n.value;this.sendSubscriptions(o,[e],!1)}}catch(a){i.e(a)}finally{i.f()}}this.leave(e).catch((function(e){t.log(e)}))}},{key:"join",value:function(e){var t,r=this;if(this.status.code!==ff.started)throw new Error("Gossipsub has not started");if(!this.mesh.has(e)){this.log("JOIN %s",e),null===(t=this.metrics)||void 0===t||t.onJoin(e);var n,i=new Set,o=this.fanout.get(e);if(o)this.fanout.delete(e),this.fanoutLastpub.delete(e),o.forEach((function(e){!r.direct.has(e)&&r.score.score(e)>=0&&i.add(e)})),null===(n=this.metrics)||void 0===n||n.onAddToMesh(e,zl.Fanout,i.size);if(i.size=0}));u.forEach((function(e){i.add(e)})),null===(a=this.metrics)||void 0===a||a.onAddToMesh(e,zl.Random,i.size-s)}this.mesh.set(e,i),i.forEach((function(t){r.log("JOIN: Add mesh link to %s in %s",t,e),r.sendGraft(t,e)}))}}},{key:"leave",value:function(){var e=(0,S.Z)((0,_.Z)().mark((function e(t){var r,n,i=this;return(0,_.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.status.code===ff.started){e.next=2;break}throw new Error("Gossipsub has not started");case 2:if(this.log("LEAVE %s",t),null===(r=this.metrics)||void 0===r||r.onLeave(t),!(n=this.mesh.get(t))){e.next=9;break}return e.next=8,Promise.all(Array.from(n).map(function(){var e=(0,S.Z)((0,_.Z)().mark((function e(r){return(0,_.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i.log("LEAVE: Remove mesh link to %s in %s",r,t),e.next=3,i.sendPrune(r,t);case 3:return e.abrupt("return",e.sent);case 4:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()));case 8:this.mesh.delete(t);case 9:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}()},{key:"selectPeersToForward",value:function(e,t,r){var n=this,i=new Set,o=this.topics.get(e);o&&(this.direct.forEach((function(e){!o.has(e)||t===e||null!==r&&void 0!==r&&r.has(e)||i.add(e)})),this.floodsubPeers.forEach((function(e){o.has(e)&&t!==e&&(null===r||void 0===r||!r.has(e))&&n.score.score(e)>=n.opts.scoreThresholds.publishThreshold&&i.add(e)})));var a=this.mesh.get(e);return a&&a.size>0&&a.forEach((function(e){t===e||null!==r&&void 0!==r&&r.has(e)||i.add(e)})),i}},{key:"selectPeersToPublish",value:function(e){var t=this,r=new Set,n={direct:0,floodsub:0,mesh:0,fanout:0},i=this.topics.get(e);if(i)if(this.opts.floodPublish)i.forEach((function(e){t.direct.has(e)?(r.add(e),n.direct++):t.score.score(e)>=t.opts.scoreThresholds.publishThreshold&&(r.add(e),n.floodsub++)}));else{this.direct.forEach((function(e){i.has(e)&&(r.add(e),n.direct++)})),this.floodsubPeers.forEach((function(e){i.has(e)&&t.score.score(e)>=t.opts.scoreThresholds.publishThreshold&&(r.add(e),n.floodsub++)}));var o=this.mesh.get(e);if(o&&o.size>0)o.forEach((function(e){r.add(e),n.mesh++}));else{var a=this.fanout.get(e);if(a&&a.size>0)a.forEach((function(e){r.add(e),n.fanout++}));else{var s=this.getRandomGossipPeers(e,this.opts.D,(function(e){return t.score.score(e)>=t.opts.scoreThresholds.publishThreshold}));s.size>0&&(this.fanout.set(e,s),s.forEach((function(e){r.add(e),n.fanout++})))}this.fanoutLastpub.set(e,Date.now())}}return{tosend:r,tosendCount:n}}},{key:"forwardMessage",value:function(e,t,r,n){var i,o=this;r&&this.score.deliverMessage(r,e,t.topic);var a=this.selectPeersToForward(t.topic,r,n),s=fl([t]);a.forEach((function(e){o.sendRpc(e,s)})),null===(i=this.metrics)||void 0===i||i.onForwardMsg(t.topic,a.size)}},{key:"publish",value:function(){var e=(0,S.Z)((0,_.Z)().mark((function e(t,n){var i,o,a,s,u,c,l,f,h,d,p,v,g,y,m;return(0,_.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o=this.dataTransform?this.dataTransform.outboundTransform(t,n):n,null!=this.publishConfig){e.next=3;break}throw Error("PublishError.Uninitialized");case 3:return e.next=5,Xl(this.publishConfig,t,n,o);case 5:return a=e.sent,s=a.raw,u=a.msg,e.next=10,this.msgIdFn(u);case 10:if(c=e.sent,l=this.msgIdToStrFn(c),!this.seenCache.has(l)){e.next=14;break}throw Error("PublishError.Duplicate");case 14:if(f=this.selectPeersToPublish(t),h=f.tosend,d=f.tosendCount,p=!0===this.opts.emitSelf&&this.subscriptions.has(t),0!==h.size||this.opts.allowPublishToZeroPeers||p){e.next=18;break}throw Error("PublishError.InsufficientPeers");case 18:this.seenCache.put(l),this.mcache.put({msgId:c,msgIdStr:l},s,!0),this.publishedMessageIds.put(l),v=fl([s]),g=rt(h);try{for(g.s();!(y=g.n()).done;)m=y.value,this.sendRpc(m,v)||h.delete(m)}catch(b){g.e(b)}finally{g.f()}return null===(i=this.metrics)||void 0===i||i.onPublishMsg(t,d,h.size,null!=s.data?s.data.length:0),p&&(h.add(this.components.getPeerId().toString()),tn(j(r.prototype),"dispatchEvent",this).call(this,new nl("gossipsub:message",{detail:{propagationSource:this.components.getPeerId(),msgId:l,msg:u}})),tn(j(r.prototype),"dispatchEvent",this).call(this,new nl("message",{detail:u}))),e.abrupt("return",{recipients:Array.from(h.values()).map((function(e){return ps(e)}))});case 27:case"end":return e.stop()}}),e,this)})));return function(t,r){return e.apply(this,arguments)}}()},{key:"reportMessageValidationResult",value:function(e,t,r){if(r===gl.Accept){var n,i=this.mcache.validate(e);if(null===(n=this.metrics)||void 0===n||n.onReportValidationMcacheHit(null!==i),null!=i){var o,a=i.message,s=i.originatingPeers;this.score.deliverMessage(t.toString(),e,a.topic),this.forwardMessage(e,i.message,t.toString(),s),null===(o=this.metrics)||void 0===o||o.onReportValidation(a.topic,r)}}else{var u,c=this.mcache.remove(e);if(null===(u=this.metrics)||void 0===u||u.onReportValidationMcacheHit(null!==c),c){var l,f=El(r),h=c.message,d=c.originatingPeers;this.score.rejectMessage(t.toString(),e,h.topic,f);var p,v=rt(d);try{for(v.s();!(p=v.n()).done;){var g=p.value;this.score.rejectMessage(g,e,h.topic,f)}}catch(y){v.e(y)}finally{v.f()}null===(l=this.metrics)||void 0===l||l.onReportValidation(h.topic,r)}}}},{key:"sendGraft",value:function(e,t){var r=fl([],{graft:[{topicID:t}]});this.sendRpc(e,r)}},{key:"sendPrune",value:function(){var e=(0,S.Z)((0,_.Z)().mark((function e(t,r){var n,i;return(0,_.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.makePrune(t,r,this.opts.doPX);case 2:e.t0=e.sent,n=[e.t0],i=fl([],{prune:n}),this.sendRpc(t,i);case 6:case"end":return e.stop()}}),e,this)})));return function(t,r){return e.apply(this,arguments)}}()},{key:"sendRpc",value:function(e,t){var r,n=this.streamsOutbound.get(e);if(!n)return this.log("Cannot send RPC to ".concat(e," as there is no open stream to it available")),!1;var i=this.control.get(e);i&&(this.piggybackControl(e,t,i),this.control.delete(e));var o=this.gossip.get(e);o&&(this.piggybackGossip(e,t,o),this.gossip.delete(e));var a=ol.encode(t).finish();try{n.push(a)}catch(s){return this.log.error("Cannot send rpc to ".concat(e),s),i&&this.control.set(e,i),o&&this.gossip.set(e,o),!1}return null===(r=this.metrics)||void 0===r||r.onRpcSent(t,a.length),!0}},{key:"piggybackControl",value:function(e,t,r){var n=this,i=(r.graft||[]).filter((function(t){var r=t.topicID;return(r&&n.mesh.get(r)||new Set).has(e)})),o=(r.prune||[]).filter((function(t){var r=t.topicID;return!(r&&n.mesh.get(r)||new Set).has(e)}));(i.length||o.length)&&(t.control?(t.control.graft=t.control.graft&&t.control.graft.concat(i),t.control.prune=t.control.prune&&t.control.prune.concat(o)):t.control={graft:i,prune:o,ihave:[],iwant:[]})}},{key:"piggybackGossip",value:function(e,t,r){t.control||(t.control={ihave:[],iwant:[],graft:[],prune:[]}),t.control.ihave=r}},{key:"sendGraftPrune",value:function(){var e=(0,S.Z)((0,_.Z)().mark((function e(t,r,n){var i,o,a,s,u,c,l,f=this;return(0,_.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:i=this.opts.doPX,o=rt(t),e.prev=2,s=(0,_.Z)().mark((function e(){var t,o,s,u,c,l,h;return(0,_.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=P(a.value,2),o=t[0],s=t[1],u=s.map((function(e){return{topicID:e}})),c=[],!(l=r.get(o))){e.next=9;break}return e.next=7,Promise.all(l.map(function(){var e=(0,S.Z)((0,_.Z)().mark((function e(t){var r;return(0,_.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,f.makePrune(o,t,i&&!(null!==(r=n.get(o))&&void 0!==r&&r));case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()));case 7:c=e.sent,r.delete(o);case 9:h=fl([],{graft:u,prune:c}),f.sendRpc(o,h);case 11:case"end":return e.stop()}}),e)})),o.s();case 5:if((a=o.n()).done){e.next=9;break}return e.delegateYield(s(),"t0",7);case 7:e.next=5;break;case 9:e.next=14;break;case 11:e.prev=11,e.t1=e.catch(2),o.e(e.t1);case 14:return e.prev=14,o.f(),e.finish(14);case 17:u=rt(r),e.prev=18,l=(0,_.Z)().mark((function e(){var t,r,o,a,s;return(0,_.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=P(c.value,2),r=t[0],o=t[1],e.next=3,Promise.all(o.map(function(){var e=(0,S.Z)((0,_.Z)().mark((function e(t){var o;return(0,_.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,f.makePrune(r,t,i&&!(null!==(o=n.get(r))&&void 0!==o&&o));case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()));case 3:a=e.sent,s=fl([],{prune:a}),f.sendRpc(r,s);case 6:case"end":return e.stop()}}),e)})),u.s();case 21:if((c=u.n()).done){e.next=25;break}return e.delegateYield(l(),"t2",23);case 23:e.next=21;break;case 25:e.next=30;break;case 27:e.prev=27,e.t3=e.catch(18),u.e(e.t3);case 30:return e.prev=30,u.f(),e.finish(30);case 33:case"end":return e.stop()}}),e,this,[[2,11,14,17],[18,27,30,33]])})));return function(t,r,n){return e.apply(this,arguments)}}()},{key:"emitGossip",value:function(e){var t,r=this.mcache.getGossipIDs(new Set(e.keys())),n=rt(e);try{for(n.s();!(t=n.n()).done;){var i,o=P(t.value,2),a=o[0],s=o[1];this.doEmitGossip(a,s,null!==(i=r.get(a))&&void 0!==i?i:[])}}catch(u){n.e(u)}finally{n.f()}}},{key:"doEmitGossip",value:function(e,t,r){var n=this;if(r.length&&(hl(r),r.length>cl&&this.log("too many messages for gossip; will truncate IHAVE list (%d messages)",r.length),t.size)){var i=this.opts.Dlazy,o=.25*t.size,a=t;o>i&&(i=o),i>a.size?i=a.size:a=hl(Array.from(a)).slice(0,i),a.forEach((function(t){var i=r;r.length>cl&&(i=hl(i.slice()).slice(0,cl)),n.pushGossip(t,{topicID:e,messageIDs:i})}))}}},{key:"flush",value:function(){var e,t=rt(this.gossip.entries());try{for(t.s();!(e=t.n()).done;){var r=P(e.value,2),n=r[0],i=r[1];this.gossip.delete(n),this.sendRpc(n,fl([],{ihave:i}))}}catch(l){t.e(l)}finally{t.f()}var o,a=rt(this.control.entries());try{for(a.s();!(o=a.n()).done;){var s=P(o.value,2),u=s[0],c=s[1];this.control.delete(u),this.sendRpc(u,fl([],{graft:c.graft,prune:c.prune}))}}catch(l){a.e(l)}finally{a.f()}}},{key:"pushGossip",value:function(e,t){this.log("Add gossip to %s",e);var r=this.gossip.get(e)||[];this.gossip.set(e,r.concat(t))}},{key:"makePrune",value:function(){var e=(0,S.Z)((0,_.Z)().mark((function e(t,r,n){var i,o,a,s=this;return(0,_.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.score.prune(t,r),this.streamsOutbound.get(t).protocol!==sl){e.next=3;break}return e.abrupt("return",{topicID:r,peers:[]});case 3:if(i=this.opts.pruneBackoff/1e3,n){e.next=6;break}return e.abrupt("return",{topicID:r,peers:[],backoff:i});case 6:return o=this.getRandomGossipPeers(r,this.opts.prunePeers,(function(e){return e!==t&&s.score.score(e)>=0})),e.next=9,Promise.all(Array.from(o).map(function(){var e=(0,S.Z)((0,_.Z)().mark((function e(t){var r;return(0,_.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=ps(t),e.t0=r.toBytes(),e.next=4,s.components.getPeerStore().addressBook.getRawEnvelope(r);case 4:return e.t1=e.sent,e.abrupt("return",{peerID:e.t0,signedPeerRecord:e.t1});case 6:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()));case 9:return a=e.sent,e.abrupt("return",{topicID:r,peers:a,backoff:i});case 11:case"end":return e.stop()}}),e,this)})));return function(t,r,n){return e.apply(this,arguments)}}()},{key:"heartbeat",value:function(){var e=(0,S.Z)((0,_.Z)().mark((function e(){var t,r,n,i,o,a,s,u,c,l,f,h,d,p,v,g,y=this;return(0,_.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=this.opts,i=n.D,o=n.Dlo,a=n.Dhi,s=n.Dscore,u=n.Dout,c=n.fanoutTTL,this.heartbeatTicks++,l=new Map,f=function(e){var t=l.get(e);return void 0===t&&(t=y.score.score(e),l.set(e,t)),t},h=new Map,d=new Map,p=new Map,this.clearBackoff(),this.peerhave.clear(),null===(t=this.metrics)||void 0===t||t.cacheSize.set({cache:"iasked"},this.iasked.size),this.iasked.clear(),this.applyIwantPenalties(),this.heartbeatTicks%this.opts.directConnectTicks!==0){e.next=15;break}return e.next=15,this.directConnect();case 15:return null===(r=this.fastMsgIdCache)||void 0===r||r.prune(),this.seenCache.prune(),this.gossipTracer.prune(),this.publishedMessageIds.prune(),v=new Map,this.mesh.forEach((function(e,t){var r=y.topics.get(t),n=new Set,c=new Set;if(v.set(t,c),r){var l,g=hl(Array.from(r)),m=y.backoff.get(t),b=rt(g);try{for(b.s();!(l=b.n()).done;){var w=l.value,k=y.streamsOutbound.get(w);if(k&&y.multicodecs.includes(k.protocol)&&!e.has(w)&&!y.direct.has(w)){var E=f(w);m&&m.has(w)||!(E>=0)||n.add(w),E>=y.opts.scoreThresholds.gossipThreshold&&c.add(w)}}}catch(Z){b.e(Z)}finally{b.f()}}var x=function(r,n){var i;y.log("HEARTBEAT: Remove mesh link to %s in %s",r,t),y.addBackoff(r,t),e.delete(r),f(r)>=y.opts.scoreThresholds.gossipThreshold&&c.add(r),null===(i=y.metrics)||void 0===i||i.onRemoveFromMesh(t,n,1);var o=d.get(r);o?o.push(t):d.set(r,[t])},_=function(r,n){var i;y.log("HEARTBEAT: Add mesh link to %s in %s",r,t),y.score.graft(r,t),e.add(r),c.delete(r),null===(i=y.metrics)||void 0===i||i.onAddToMesh(t,n,1);var o=h.get(r);o?o.push(t):h.set(r,[t])};(e.forEach((function(e){var r=f(e);r<0&&(y.log("HEARTBEAT: Prune peer %s with negative score: score=%d, topic=%s",e,r,t),x(e,Zl.BadScore),p.set(e,!0))})),e.sizea){var S=Array.from(e);S.sort((function(e,t){return f(t)-f(e)})),S=S.slice(0,s).concat(hl(S.slice(s)));var A=0;if(S.slice(0,i).forEach((function(e){y.outbound.get(e)&&A++})),A0;r--)S[r]=S[r-1];S[0]=t};if(A>0)for(var C=A,T=1;T0;T++)y.outbound.get(S[T])&&(I(T),C--);for(var P=i-A,R=i;R0;R++)y.outbound.get(S[R])&&(I(R),P--)}S.slice(i).forEach((function(e){x(e,Zl.Excess)}))}if(e.size>=o){var B=0;if(e.forEach((function(e){y.outbound.get(e)&&B++})),B1){var N=Array.from(e).sort((function(e,t){return f(e)-f(t)})),O=Math.floor(e.size/2),D=f(N[O]);if(DD})),F=rt(U);try{for(F.s();!(L=F.n()).done;){var z=L.value;y.log("HEARTBEAT: Opportunistically graft peer %s on topic %s",z,t),_(z,zl.Opportunistic)}}catch(Z){F.e(Z)}finally{F.f()}}}})),g=Date.now(),this.fanoutLastpub.forEach((function(e,t){e+c=y.opts.scoreThresholds.publishThreshold&&o.push(c),h>=y.opts.scoreThresholds.gossipThreshold&&a.add(c)}}}catch(p){u.e(p)}finally{u.f()}}if(e.size2&&void 0!==arguments[2]?arguments[2]:function(){return!0},i=this.topics.get(e);if(!i)return new Set;var o=[];return i.forEach((function(e){var t=r.streamsOutbound.get(e);t&&r.multicodecs.includes(t.protocol)&&n(e)&&o.push(e)})),o=hl(o),t>0&&o.length>t&&(o=o.slice(0,t)),new Set(o)}},{key:"onScrapeMetrics",value:function(e){var t,r;e.mcacheSize.set(this.mcache.size),e.cacheSize.set({cache:"direct"},this.direct.size),e.cacheSize.set({cache:"seenCache"},this.seenCache.size),e.cacheSize.set({cache:"fastMsgIdCache"},null!==(t=null===(r=this.fastMsgIdCache)||void 0===r?void 0:r.size)&&void 0!==t?t:0),e.cacheSize.set({cache:"publishedMessageIds"},this.publishedMessageIds.size),e.cacheSize.set({cache:"mcache"},this.mcache.size),e.cacheSize.set({cache:"score"},this.score.size),e.cacheSize.set({cache:"gossipTracer.promises"},this.gossipTracer.size),e.cacheSize.set({cache:"gossipTracer.requests"},this.gossipTracer.requestMsByMsgSize),e.cacheSize.set({cache:"topics"},this.topics.size),e.cacheSize.set({cache:"subscriptions"},this.subscriptions.size),e.cacheSize.set({cache:"mesh"},this.mesh.size),e.cacheSize.set({cache:"fanout"},this.fanout.size),e.cacheSize.set({cache:"peers"},this.peers.size),e.cacheSize.set({cache:"streamsOutbound"},this.streamsOutbound.size),e.cacheSize.set({cache:"streamsInbound"},this.streamsInbound.size),e.cacheSize.set({cache:"acceptFromWhitelist"},this.acceptFromWhitelist.size),e.cacheSize.set({cache:"gossip"},this.gossip.size),e.cacheSize.set({cache:"control"},this.control.size),e.cacheSize.set({cache:"peerhave"},this.peerhave.size),e.cacheSize.set({cache:"outbound"},this.outbound.size);var n,i=0,o=rt(this.backoff.values());try{for(o.s();!(n=o.n()).done;){i+=n.value.size}}catch(S){o.e(S)}finally{o.f()}e.cacheSize.set({cache:"backoff"},i);var a,s=rt(this.topics);try{for(s.s();!(a=s.n()).done;){var u=P(a.value,2),c=u[0],l=u[1];e.topicPeersCount.set({topicStr:c},l.size)}}catch(S){s.e(S)}finally{s.f()}var f,h=rt(this.mesh);try{for(h.s();!(f=h.n()).done;){var d=P(f.value,2),p=d[0],v=d[1];e.meshPeerCounts.set({topicStr:p},v.size)}}catch(S){h.e(S)}finally{h.f()}var g=[],y=new Map;e.behaviourPenalty.reset();var m,b=rt(this.peers.keys());try{for(b.s();!(m=b.n()).done;){var w,k,E=m.value,x=this.score.score(E);g.push(x),y.set(E,x),e.behaviourPenalty.observe(null!==(w=null===(k=this.score.peerStats.get(E))||void 0===k?void 0:k.behaviourPenalty)&&void 0!==w?w:0)}}catch(S){b.e(S)}finally{b.f()}e.registerScores(g,this.opts.scoreThresholds),e.registerScorePerMesh(this.mesh,y);var _=function(e,t,r,n,i){var o,a={byTopic:new Map,p5w:[],p6w:[],p7w:[],score:[]},s=rt(e);try{for(s.s();!(o=s.n()).done;){var u=o.value,c=t.get(u);if(c){var l,f=af(u,c,r,n,i),h=rt(f.byTopic);try{for(h.s();!(l=h.n()).done;){var d=P(l.value,2),p=d[0],v=d[1],g=a.byTopic.get(p);g||(g={p1w:[],p2w:[],p3w:[],p3bw:[],p4w:[]},a.byTopic.set(p,g)),g.p1w.push(v.p1w),g.p2w.push(v.p2w),g.p3w.push(v.p3w),g.p3bw.push(v.p3bw),g.p4w.push(v.p4w)}}catch(S){h.e(S)}finally{h.f()}a.p5w.push(f.p5w),a.p6w.push(f.p6w),a.p7w.push(f.p7w),a.score.push(f.score)}else a.p5w.push(0),a.p6w.push(0),a.p7w.push(0),a.score.push(0)}}catch(S){s.e(S)}finally{s.f()}return a}(this.peers.keys(),this.score.peerStats,this.score.params,this.score.peerIPs,e.topicStrToLabel);e.registerScoreWeights(_)}}]),r}(tl);pf.multicodec=ul;var vf=xi("waku:message:topic-only"),gf=function(){function e(t){(0,F.Z)(this,e),this.proto=t}return(0,U.Z)(e,[{key:"contentTopic",get:function(){var e;return null!==(e=this.proto.contentTopic)&&void 0!==e?e:""}}]),e}(),yf=function(){function e(){(0,F.Z)(this,e),this.contentTopic=""}return(0,U.Z)(e,[{key:"decodeProto",value:function(e){var t=Vs.decode(e);return vf("Message decoded",t),Promise.resolve(t)}},{key:"decode",value:function(){var e=(0,S.Z)((0,_.Z)().mark((function e(t){return(0,_.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new gf(t));case 1:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()}]),e}(),mf=xi("waku:relay"),bf=function(e){Z(r,e);var t=G(r);function r(e){var n,i,o,a;return(0,F.Z)(this,r),e=Object.assign(null!==(n=e)&&void 0!==n?n:{},{globalSignaturePolicy:pl.StrictNoSign,fallbackToFloodsub:!1}),(a=t.call(this,e)).multicodecs=nc,a.observers=new Map,a.pubSubTopic=null!==(i=null===(o=e)||void 0===o?void 0:o.pubSubTopic)&&void 0!==i?i:"/waku/2/default-waku/proto",a.defaultDecoder=new yf,a}return(0,U.Z)(r,[{key:"start",value:function(){var e=(0,S.Z)((0,_.Z)().mark((function e(){return(0,_.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,tn(j(r.prototype),"start",this).call(this);case 2:this.subscribe(this.pubSubTopic);case 3:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}()},{key:"send",value:function(){var e=(0,S.Z)((0,_.Z)().mark((function e(t,r){var n;return(0,_.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.encode(r);case 2:if(n=e.sent){e.next=6;break}return mf("Failed to encode message, aborting publish"),e.abrupt("return",{recipients:[]});case 6:return e.abrupt("return",this.publish(this.pubSubTopic,n));case 7:case"end":return e.stop()}}),e,this)})));return function(t,r){return e.apply(this,arguments)}}()},{key:"addObserver",value:function(e,t){var r=this,n={decoder:e,callback:t};return function(e,t,r){var n=e.get(t);"undefined"===typeof n&&(e.set(t,new Set),n=e.get(t)),n.add(r)}(this.observers,e.contentTopic,n),function(){var t=r.observers.get(e.contentTopic);t&&t.delete(n)}}},{key:"subscribe",value:function(e){var t=this;this.addEventListener("gossipsub:message",function(){var r=(0,S.Z)((0,_.Z)().mark((function r(n){var i,o;return(0,_.Z)().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(n.detail.msg.topic===e){r.next=2;break}return r.abrupt("return");case 2:return mf("Message received on ".concat(e)),r.next=5,t.defaultDecoder.decodeProto(n.detail.msg.data);case 5:if((i=r.sent)&&i.contentTopic){r.next=9;break}return mf("Message does not have a content topic, skipping"),r.abrupt("return");case 9:if(o=t.observers.get(i.contentTopic)){r.next=12;break}return r.abrupt("return");case 12:return r.next=14,Promise.all(Array.from(o).map(function(){var e=(0,S.Z)((0,_.Z)().mark((function e(t){var r,o,a,s;return(0,_.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.decoder,o=t.callback,e.next=3,r.decodeProto(n.detail.msg.data);case 3:if(a=e.sent){e.next=7;break}return mf("Internal error: message previously decoded failed on 2nd pass."),e.abrupt("return");case 7:return e.next=9,r.decode(a);case 9:(s=e.sent)?o(s):mf("Failed to decode messages on",i.contentTopic);case 11:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()));case 14:case"end":return r.stop()}}),r)})));return function(e){return r.apply(this,arguments)}}()),tn(j(r.prototype),"subscribe",this).call(this,e)}},{key:"getMeshPeers",value:function(e){return tn(j(r.prototype),"getMeshPeers",this).call(this,null!==e&&void 0!==e?e:this.pubSubTopic)}}]),r}(pf);function wf(e,t){if(null==e)return{};var r,n,i={},o=Object.keys(e);for(n=0;n=0||(i[r]=e[r]);return i}function kf(){return kf=Object.assign?Object.assign.bind():function(e){for(var t=1;t1&&void 0!==arguments[1]?arguments[1]:0,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;return Math.min(Math.max(t,e),r)}function Cf(e){if(e.type)return e;if("#"===e.charAt(0))return Cf(function(e){e=e.slice(1);var t=new RegExp(".{1,".concat(e.length>=6?2:1,"}"),"g"),r=e.match(t);return r&&1===r[0].length&&(r=r.map((function(e){return e+e}))),r?"rgb".concat(4===r.length?"a":"","(").concat(r.map((function(e,t){return t<3?parseInt(e,16):Math.round(parseInt(e,16)/255*1e3)/1e3})).join(", "),")"):""}(e));var t=e.indexOf("("),r=e.substring(0,t);if(-1===["rgb","rgba","hsl","hsla","color"].indexOf(r))throw new Error(Af(9,e));var n,i=e.substring(t+1,e.length-1);if("color"===r){if(n=(i=i.split(" ")).shift(),4===i.length&&"/"===i[3].charAt(0)&&(i[3]=i[3].slice(1)),-1===["srgb","display-p3","a98-rgb","prophoto-rgb","rec-2020"].indexOf(n))throw new Error(Af(10,n))}else i=i.split(",");return{type:r,values:i=i.map((function(e){return parseFloat(e)})),colorSpace:n}}function Tf(e){var t=e.type,r=e.colorSpace,n=e.values;return-1!==t.indexOf("rgb")?n=n.map((function(e,t){return t<3?parseInt(e,10):e})):-1!==t.indexOf("hsl")&&(n[1]="".concat(n[1],"%"),n[2]="".concat(n[2],"%")),n=-1!==t.indexOf("color")?"".concat(r," ").concat(n.join(" ")):"".concat(n.join(", ")),"".concat(t,"(").concat(n,")")}function Pf(e){var t="hsl"===(e=Cf(e)).type?Cf(function(e){var t=(e=Cf(e)).values,r=t[0],n=t[1]/100,i=t[2]/100,o=n*Math.min(i,1-i),a=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:(e+r/30)%12;return i-o*Math.max(Math.min(t-3,9-t,1),-1)},s="rgb",u=[Math.round(255*a(0)),Math.round(255*a(8)),Math.round(255*a(4))];return"hsla"===e.type&&(s+="a",u.push(t[3])),Tf({type:s,values:u})}(e)).values:e.values;return t=t.map((function(t){return"color"!==e.type&&(t/=255),t<=.03928?t/12.92:Math.pow((t+.055)/1.055,2.4)})),Number((.2126*t[0]+.7152*t[1]+.0722*t[2]).toFixed(3))}function Rf(e,t){return e=Cf(e),t=If(t),"rgb"!==e.type&&"hsl"!==e.type||(e.type+="a"),"color"===e.type?e.values[3]="/".concat(t):e.values[3]=t,Tf(e)}function Bf(e,t){if(e=Cf(e),t=If(t),-1!==e.type.indexOf("hsl"))e.values[2]*=1-t;else if(-1!==e.type.indexOf("rgb")||-1!==e.type.indexOf("color"))for(var r=0;r<3;r+=1)e.values[r]*=1-t;return Tf(e)}function Mf(e,t){if(e=Cf(e),t=If(t),-1!==e.type.indexOf("hsl"))e.values[2]+=(100-e.values[2])*t;else if(-1!==e.type.indexOf("rgb"))for(var r=0;r<3;r+=1)e.values[r]+=(255-e.values[r])*t;else if(-1!==e.type.indexOf("color"))for(var n=0;n<3;n+=1)e.values[n]+=(1-e.values[n])*t;return Tf(e)}var Nf=function(e){var t=Object.create(null);return function(r){return void 0===t[r]&&(t[r]=e(r)),t[r]}},Of=/^((children|dangerouslySetInnerHTML|key|ref|autoFocus|defaultValue|defaultChecked|innerHTML|suppressContentEditableWarning|suppressHydrationWarning|valueLink|abbr|accept|acceptCharset|accessKey|action|allow|allowUserMedia|allowPaymentRequest|allowFullScreen|allowTransparency|alt|async|autoComplete|autoPlay|capture|cellPadding|cellSpacing|challenge|charSet|checked|cite|classID|className|cols|colSpan|content|contentEditable|contextMenu|controls|controlsList|coords|crossOrigin|data|dateTime|decoding|default|defer|dir|disabled|disablePictureInPicture|download|draggable|encType|enterKeyHint|form|formAction|formEncType|formMethod|formNoValidate|formTarget|frameBorder|headers|height|hidden|high|href|hrefLang|htmlFor|httpEquiv|id|inputMode|integrity|is|keyParams|keyType|kind|label|lang|list|loading|loop|low|marginHeight|marginWidth|max|maxLength|media|mediaGroup|method|min|minLength|multiple|muted|name|nonce|noValidate|open|optimum|pattern|placeholder|playsInline|poster|preload|profile|radioGroup|readOnly|referrerPolicy|rel|required|reversed|role|rows|rowSpan|sandbox|scope|scoped|scrolling|seamless|selected|shape|size|sizes|slot|span|spellCheck|src|srcDoc|srcLang|srcSet|start|step|style|summary|tabIndex|target|title|translate|type|useMap|value|width|wmode|wrap|about|datatype|inlist|prefix|property|resource|typeof|vocab|autoCapitalize|autoCorrect|autoSave|color|incremental|fallback|inert|itemProp|itemScope|itemType|itemID|itemRef|on|option|results|security|unselectable|accentHeight|accumulate|additive|alignmentBaseline|allowReorder|alphabetic|amplitude|arabicForm|ascent|attributeName|attributeType|autoReverse|azimuth|baseFrequency|baselineShift|baseProfile|bbox|begin|bias|by|calcMode|capHeight|clip|clipPathUnits|clipPath|clipRule|colorInterpolation|colorInterpolationFilters|colorProfile|colorRendering|contentScriptType|contentStyleType|cursor|cx|cy|d|decelerate|descent|diffuseConstant|direction|display|divisor|dominantBaseline|dur|dx|dy|edgeMode|elevation|enableBackground|end|exponent|externalResourcesRequired|fill|fillOpacity|fillRule|filter|filterRes|filterUnits|floodColor|floodOpacity|focusable|fontFamily|fontSize|fontSizeAdjust|fontStretch|fontStyle|fontVariant|fontWeight|format|from|fr|fx|fy|g1|g2|glyphName|glyphOrientationHorizontal|glyphOrientationVertical|glyphRef|gradientTransform|gradientUnits|hanging|horizAdvX|horizOriginX|ideographic|imageRendering|in|in2|intercept|k|k1|k2|k3|k4|kernelMatrix|kernelUnitLength|kerning|keyPoints|keySplines|keyTimes|lengthAdjust|letterSpacing|lightingColor|limitingConeAngle|local|markerEnd|markerMid|markerStart|markerHeight|markerUnits|markerWidth|mask|maskContentUnits|maskUnits|mathematical|mode|numOctaves|offset|opacity|operator|order|orient|orientation|origin|overflow|overlinePosition|overlineThickness|panose1|paintOrder|pathLength|patternContentUnits|patternTransform|patternUnits|pointerEvents|points|pointsAtX|pointsAtY|pointsAtZ|preserveAlpha|preserveAspectRatio|primitiveUnits|r|radius|refX|refY|renderingIntent|repeatCount|repeatDur|requiredExtensions|requiredFeatures|restart|result|rotate|rx|ry|scale|seed|shapeRendering|slope|spacing|specularConstant|specularExponent|speed|spreadMethod|startOffset|stdDeviation|stemh|stemv|stitchTiles|stopColor|stopOpacity|strikethroughPosition|strikethroughThickness|string|stroke|strokeDasharray|strokeDashoffset|strokeLinecap|strokeLinejoin|strokeMiterlimit|strokeOpacity|strokeWidth|surfaceScale|systemLanguage|tableValues|targetX|targetY|textAnchor|textDecoration|textRendering|textLength|to|transform|u1|u2|underlinePosition|underlineThickness|unicode|unicodeBidi|unicodeRange|unitsPerEm|vAlphabetic|vHanging|vIdeographic|vMathematical|values|vectorEffect|version|vertAdvY|vertOriginX|vertOriginY|viewBox|viewTarget|visibility|widths|wordSpacing|writingMode|x|xHeight|x1|x2|xChannelSelector|xlinkActuate|xlinkArcrole|xlinkHref|xlinkRole|xlinkShow|xlinkTitle|xlinkType|xmlBase|xmlns|xmlnsXlink|xmlLang|xmlSpace|y|y1|y2|yChannelSelector|z|zoomAndPan|for|class|autofocus)|(([Dd][Aa][Tt][Aa]|[Aa][Rr][Ii][Aa]|x)-.*))$/,Df=Nf((function(e){return Of.test(e)||111===e.charCodeAt(0)&&110===e.charCodeAt(1)&&e.charCodeAt(2)<91}));var Lf=function(){function e(e){var t=this;this._insertTag=function(e){var r;r=0===t.tags.length?t.insertionPoint?t.insertionPoint.nextSibling:t.prepend?t.container.firstChild:t.before:t.tags[t.tags.length-1].nextSibling,t.container.insertBefore(e,r),t.tags.push(e)},this.isSpeedy=void 0===e.speedy||e.speedy,this.tags=[],this.ctr=0,this.nonce=e.nonce,this.key=e.key,this.container=e.container,this.prepend=e.prepend,this.insertionPoint=e.insertionPoint,this.before=null}var t=e.prototype;return t.hydrate=function(e){e.forEach(this._insertTag)},t.insert=function(e){this.ctr%(this.isSpeedy?65e3:1)===0&&this._insertTag(function(e){var t=document.createElement("style");return t.setAttribute("data-emotion",e.key),void 0!==e.nonce&&t.setAttribute("nonce",e.nonce),t.appendChild(document.createTextNode("")),t.setAttribute("data-s",""),t}(this));var t=this.tags[this.tags.length-1];if(this.isSpeedy){var r=function(e){if(e.sheet)return e.sheet;for(var t=0;t0?Kf(eh,--Xf):0,Jf--,10===$f&&(Jf=1,Qf--),$f}function ih(){return $f=Xf2||uh($f)>3?"":" "}function dh(e,t){for(;--t&&ih()&&!($f<48||$f>102||$f>57&&$f<65||$f>70&&$f<97););return sh(e,ah()+(t<6&&32==oh()&&32==ih()))}function ph(e){for(;ih();)switch($f){case e:return Xf;case 34:case 39:34!==e&&39!==e&&ph($f);break;case 40:41===e&&ph(e);break;case 92:ih()}return Xf}function vh(e,t){for(;ih()&&e+$f!==57&&(e+$f!==84||47!==oh()););return"/*"+sh(t,Xf-1)+"*"+Ff(47===e?e:ih())}function gh(e){for(;!uh(oh());)ih();return sh(e,Xf)}var yh="-ms-",mh="-moz-",bh="-webkit-",wh="comm",kh="rule",Eh="decl",xh="@keyframes";function _h(e,t){for(var r="",n=Gf(e),i=0;i6)switch(Kf(e,t+1)){case 109:if(45!==Kf(e,t+4))break;case 102:return jf(e,/(.+:)(.+)-([^]+)/,"$1-webkit-$2-$3$1"+mh+(108==Kf(e,t+3)?"$3":"$2-$3"))+e;case 115:return~qf(e,"stretch")?Ah(jf(e,"stretch","fill-available"),t)+e:e}break;case 4949:if(115!==Kf(e,t+1))break;case 6444:switch(Kf(e,Hf(e)-3-(~qf(e,"!important")&&10))){case 107:return jf(e,":",":"+bh)+e;case 101:return jf(e,/(.+:)([^;!]+)(;|!.+)?/,"$1"+bh+(45===Kf(e,14)?"inline-":"")+"box$3$1"+bh+"$2$3$1"+yh+"$2box$3")+e}break;case 5936:switch(Kf(e,t+11)){case 114:return bh+e+yh+jf(e,/[svh]\w+-[tblr]{2}/,"tb")+e;case 108:return bh+e+yh+jf(e,/[svh]\w+-[tblr]{2}/,"tb-rl")+e;case 45:return bh+e+yh+jf(e,/[svh]\w+-[tblr]{2}/,"lr")+e}return bh+e+yh+e+e}return e}function Ih(e){return lh(Ch("",null,null,null,[""],e=ch(e),0,[0],e))}function Ch(e,t,r,n,i,o,a,s,u){for(var c=0,l=0,f=a,h=0,d=0,p=0,v=1,g=1,y=1,m=0,b="",w=i,k=o,E=n,x=b;g;)switch(p=m,m=ih()){case 40:if(108!=p&&58==x.charCodeAt(f-1)){-1!=qf(x+=jf(fh(m),"&","&\f"),"&\f")&&(y=-1);break}case 34:case 39:case 91:x+=fh(m);break;case 9:case 10:case 13:case 32:x+=hh(p);break;case 92:x+=dh(ah()-1,7);continue;case 47:switch(oh()){case 42:case 47:Wf(Ph(vh(ih(),ah()),t,r),u);break;default:x+="/"}break;case 123*v:s[c++]=Hf(x)*y;case 125*v:case 59:case 0:switch(m){case 0:case 125:g=0;case 59+l:d>0&&Hf(x)-f&&Wf(d>32?Rh(x+";",n,r,f-1):Rh(jf(x," ","")+";",n,r,f-2),u);break;case 59:x+=";";default:if(Wf(E=Th(x,t,r,c,l,i,s,b,w=[],k=[],f),o),123===m)if(0===l)Ch(x,t,E,E,w,o,f,s,k);else switch(h){case 100:case 109:case 115:Ch(e,E,E,n&&Wf(Th(e,E,E,0,0,i,s,b,i,w=[],f),k),i,k,f,s,n?w:k);break;default:Ch(x,E,E,E,[""],k,0,s,k)}}c=l=d=0,v=y=1,b=x="",f=a;break;case 58:f=1+Hf(x),d=p;default:if(v<1)if(123==m)--v;else if(125==m&&0==v++&&125==nh())continue;switch(x+=Ff(m),m*v){case 38:y=l>0?1:(x+="\f",-1);break;case 44:s[c++]=(Hf(x)-1)*y,y=1;break;case 64:45===oh()&&(x+=fh(ih())),h=oh(),l=f=Hf(b=x+=gh(ah())),m++;break;case 45:45===p&&2==Hf(x)&&(v=0)}}return o}function Th(e,t,r,n,i,o,a,s,u,c,l){for(var f=i-1,h=0===i?o:[""],d=Gf(h),p=0,v=0,g=0;p0?h[y]+" "+m:jf(m,/&\f/g,h[y])))&&(u[g++]=b);return th(e,t,r,0===i?kh:s,u,c,l)}function Ph(e,t,r){return th(e,t,r,wh,Ff($f),Vf(e,2,-2),0)}function Rh(e,t,r,n){return th(e,t,r,Eh,Vf(e,0,n),Vf(e,n+1,-1),n)}var Bh=function(e,t,r){for(var n=0,i=0;n=i,i=oh(),38===n&&12===i&&(t[r]=1),!uh(i);)ih();return sh(e,Xf)},Mh=function(e,t){return lh(function(e,t){var r=-1,n=44;do{switch(uh(n)){case 0:38===n&&12===oh()&&(t[r]=1),e[r]+=Bh(Xf-1,t,r);break;case 2:e[r]+=fh(n);break;case 4:if(44===n){e[++r]=58===oh()?"&\f":"",t[r]=e[r].length;break}default:e[r]+=Ff(n)}}while(n=ih());return e}(ch(e),t))},Nh=new WeakMap,Oh=function(e){if("rule"===e.type&&e.parent&&!(e.length<1)){for(var t=e.value,r=e.parent,n=e.column===r.column&&e.line===r.line;"rule"!==r.type;)if(!(r=r.parent))return;if((1!==e.props.length||58===t.charCodeAt(0)||Nh.get(r))&&!n){Nh.set(e,!0);for(var i=[],o=Mh(t,i),a=r.props,s=0,u=0;s-1&&!e.return)switch(e.type){case Eh:e.return=Ah(e.value,e.length);break;case xh:return _h([rh(e,{value:jf(e.value,"@","@"+bh)})],n);case kh:if(e.length)return function(e,t){return e.map(t).join("")}(e.props,(function(t){switch(function(e,t){return(e=t.exec(e))?e[0]:e}(t,/(::plac\w+|:read-\w+)/)){case":read-only":case":read-write":return _h([rh(e,{props:[jf(t,/:(read-\w+)/,":-moz-$1")]})],n);case"::placeholder":return _h([rh(e,{props:[jf(t,/:(plac\w+)/,":-webkit-input-$1")]}),rh(e,{props:[jf(t,/:(plac\w+)/,":-moz-$1")]}),rh(e,{props:[jf(t,/:(plac\w+)/,yh+"input-$1")]})],n)}return""}))}}],Uh=function(e){var t=e.key;if("css"===t){var r=document.querySelectorAll("style[data-emotion]:not([data-s])");Array.prototype.forEach.call(r,(function(e){-1!==e.getAttribute("data-emotion").indexOf(" ")&&(document.head.appendChild(e),e.setAttribute("data-s",""))}))}var n=e.stylisPlugins||Lh;var i,o,a={},s=[];i=e.container||document.head,Array.prototype.forEach.call(document.querySelectorAll('style[data-emotion^="'+t+' "]'),(function(e){for(var t=e.getAttribute("data-emotion").split(" "),r=1;r=4;++n,i-=4)t=1540483477*(65535&(t=255&e.charCodeAt(n)|(255&e.charCodeAt(++n))<<8|(255&e.charCodeAt(++n))<<16|(255&e.charCodeAt(++n))<<24))+(59797*(t>>>16)<<16),r=1540483477*(65535&(t^=t>>>24))+(59797*(t>>>16)<<16)^1540483477*(65535&r)+(59797*(r>>>16)<<16);switch(i){case 3:r^=(255&e.charCodeAt(n+2))<<16;case 2:r^=(255&e.charCodeAt(n+1))<<8;case 1:r=1540483477*(65535&(r^=255&e.charCodeAt(n)))+(59797*(r>>>16)<<16)}return(((r=1540483477*(65535&(r^=r>>>13))+(59797*(r>>>16)<<16))^r>>>15)>>>0).toString(36)},zh={animationIterationCount:1,borderImageOutset:1,borderImageSlice:1,borderImageWidth:1,boxFlex:1,boxFlexGroup:1,boxOrdinalGroup:1,columnCount:1,columns:1,flex:1,flexGrow:1,flexPositive:1,flexShrink:1,flexNegative:1,flexOrder:1,gridRow:1,gridRowEnd:1,gridRowSpan:1,gridRowStart:1,gridColumn:1,gridColumnEnd:1,gridColumnSpan:1,gridColumnStart:1,msGridRow:1,msGridRowSpan:1,msGridColumn:1,msGridColumnSpan:1,fontWeight:1,lineHeight:1,opacity:1,order:1,orphans:1,tabSize:1,widows:1,zIndex:1,zoom:1,WebkitLineClamp:1,fillOpacity:1,floodOpacity:1,stopOpacity:1,strokeDasharray:1,strokeDashoffset:1,strokeMiterlimit:1,strokeOpacity:1,strokeWidth:1},Zh=/[A-Z]|^ms/g,jh=/_EMO_([^_]+?)_([^]*?)_EMO_/g,qh=function(e){return 45===e.charCodeAt(1)},Kh=function(e){return null!=e&&"boolean"!==typeof e},Vh=Nf((function(e){return qh(e)?e:e.replace(Zh,"-$&").toLowerCase()})),Hh=function(e,t){switch(e){case"animation":case"animationName":if("string"===typeof t)return t.replace(jh,(function(e,t,r){return Wh={name:t,styles:r,next:Wh},t}))}return 1===zh[e]||qh(e)||"number"!==typeof t||0===t?t:t+"px"};function Gh(e,t,r){if(null==r)return"";if(void 0!==r.__emotion_styles)return r;switch(typeof r){case"boolean":return"";case"object":if(1===r.anim)return Wh={name:r.name,styles:r.styles,next:Wh},r.name;if(void 0!==r.styles){var n=r.next;if(void 0!==n)for(;void 0!==n;)Wh={name:n.name,styles:n.styles,next:Wh},n=n.next;return r.styles+";"}return function(e,t,r){var n="";if(Array.isArray(r))for(var i=0;i96?id:od},sd=function(e,t,r){var n;if(t){var i=t.shouldForwardProp;n=e.__emotion_forwardProp&&i?function(t){return e.__emotion_forwardProp(t)&&i(t)}:i}return"function"!==typeof n&&r&&(n=e.__emotion_forwardProp),n},ud=function(e){var t=e.cache,r=e.serialized,n=e.isStringTag;nd(t,r,n);Xh((function(){return function(e,t,r){nd(e,t,r);var n=e.key+"-"+t.name;if(void 0===e.inserted[t.name]){var i=t;do{e.insert(t===i?"."+n:"",i,e.sheet,!0),i=i.next}while(void 0!==i)}}(t,r,n)}));return null},cd=function e(t,r){var n,i,o=t.__emotion_real===t,a=o&&t.__emotion_base||t;void 0!==r&&(n=r.label,i=r.target);var s=sd(t,r,o),u=s||ad(a),c=!u("as");return function(){var l=arguments,f=o&&void 0!==t.__emotion_styles?t.__emotion_styles.slice(0):[];if(void 0!==n&&f.push("label:"+n+";"),null==l[0]||void 0===l[0].raw)f.push.apply(f,l);else{0,f.push(l[0][0]);for(var h=l.length,d=1;d2&&void 0!==arguments[2]?arguments[2]:{clone:!0},n=r.clone?kf({},e):e;return pd(e)&&pd(t)&&Object.keys(t).forEach((function(i){"__proto__"!==i&&(pd(t[i])&&i in e&&pd(e[i])?n[i]=vd(e[i],t[i],r):n[i]=t[i])})),n}var gd=["values","unit","step"];function yd(e){var t=e.values,r=void 0===t?{xs:0,sm:600,md:900,lg:1200,xl:1536}:t,n=e.unit,i=void 0===n?"px":n,o=e.step,a=void 0===o?5:o,s=wf(e,gd),u=function(e){var t=Object.keys(e).map((function(t){return{key:t,val:e[t]}}))||[];return t.sort((function(e,t){return e.val-t.val})),t.reduce((function(e,t){return kf({},e,O({},t.key,t.val))}),{})}(r),c=Object.keys(u);function l(e){var t="number"===typeof r[e]?r[e]:e;return"@media (min-width:".concat(t).concat(i,")")}function f(e){var t="number"===typeof r[e]?r[e]:e;return"@media (max-width:".concat(t-a/100).concat(i,")")}function h(e,t){var n=c.indexOf(t);return"@media (min-width:".concat("number"===typeof r[e]?r[e]:e).concat(i,") and ")+"(max-width:".concat((-1!==n&&"number"===typeof r[c[n]]?r[c[n]]:t)-a/100).concat(i,")")}return kf({keys:c,values:u,up:l,down:f,between:h,only:function(e){return c.indexOf(e)+10&&void 0!==arguments[0]?arguments[0]:{},r=null==(e=t.keys)?void 0:e.reduce((function(e,r){return e[t.up(r)]={},e}),{});return r||{}}function xd(e,t){return e.reduce((function(e,t){var r=e[t];return(!r||0===Object.keys(r).length)&&delete e[t],e}),t)}function _d(e){if("string"!==typeof e)throw new Error(Af(7));return e.charAt(0).toUpperCase()+e.slice(1)}function Sd(e,t){var r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if(!t||"string"!==typeof t)return null;if(e&&e.vars&&r){var n="vars.".concat(t).split(".").reduce((function(e,t){return e&&e[t]?e[t]:null}),e);if(null!=n)return n}return t.split(".").reduce((function(e,t){return e&&null!=e[t]?e[t]:null}),e)}function Ad(e,t,r){var n,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:r;return n="function"===typeof e?e(r):Array.isArray(e)?e[r]||i:Sd(e,r)||i,t&&(n=t(n)),n}var Id=function(e){var t=e.prop,r=e.cssProperty,n=void 0===r?e.prop:r,i=e.themeKey,o=e.transform,a=function(e){if(null==e[t])return null;var r=e[t],a=Sd(e.theme,i)||{};return kd(e,r,(function(e){var r=Ad(a,o,e);return e===r&&"string"===typeof e&&(r=Ad(a,o,"".concat(t).concat("default"===e?"":_d(e)),e)),!1===n?r:O({},n,r)}))};return a.propTypes={},a.filterProps=[t],a};var Cd=function(e,t){return t?vd(e,t,{clone:!1}):e};var Td={m:"margin",p:"padding"},Pd={t:"Top",r:"Right",b:"Bottom",l:"Left",x:["Left","Right"],y:["Top","Bottom"]},Rd={marginX:"mx",marginY:"my",paddingX:"px",paddingY:"py"},Bd=function(e){var t={};return function(r){return void 0===t[r]&&(t[r]=e(r)),t[r]}}((function(e){if(e.length>2){if(!Rd[e])return[e];e=Rd[e]}var t=P(e.split(""),2),r=t[0],n=t[1],i=Td[r],o=Pd[n]||"";return Array.isArray(o)?o.map((function(e){return i+e})):[i+o]})),Md=["m","mt","mr","mb","ml","mx","my","margin","marginTop","marginRight","marginBottom","marginLeft","marginX","marginY","marginInline","marginInlineStart","marginInlineEnd","marginBlock","marginBlockStart","marginBlockEnd"],Nd=["p","pt","pr","pb","pl","px","py","padding","paddingTop","paddingRight","paddingBottom","paddingLeft","paddingX","paddingY","paddingInline","paddingInlineStart","paddingInlineEnd","paddingBlock","paddingBlockStart","paddingBlockEnd"],Od=[].concat(Md,Nd);function Dd(e,t,r,n){var i,o=null!=(i=Sd(e,t,!1))?i:r;return"number"===typeof o?function(e){return"string"===typeof e?e:o*e}:Array.isArray(o)?function(e){return"string"===typeof e?e:o[e]}:"function"===typeof o?o:function(){}}function Ld(e){return Dd(e,"spacing",8)}function Ud(e,t){if("string"===typeof t||null==t)return t;var r=e(Math.abs(t));return t>=0?r:"number"===typeof r?-r:"-".concat(r)}function Fd(e,t,r,n){if(-1===t.indexOf(r))return null;var i=function(e,t){return function(r){return e.reduce((function(e,n){return e[n]=Ud(t,r),e}),{})}}(Bd(r),n);return kd(e,e[r],i)}function zd(e,t){var r=Ld(e.theme);return Object.keys(e).map((function(n){return Fd(e,t,n,r)})).reduce(Cd,{})}function Zd(e){return zd(e,Md)}function jd(e){return zd(e,Nd)}function qd(e){return zd(e,Od)}Zd.propTypes={},Zd.filterProps=Md,jd.propTypes={},jd.filterProps=Nd,qd.propTypes={},qd.filterProps=Od;var Kd=qd;function Vd(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:8;if(e.mui)return e;var t=Ld({spacing:e}),r=function(){for(var e=arguments.length,r=new Array(e),n=0;n0&&void 0!==arguments[0]?arguments[0]:{},t=e.breakpoints,r=void 0===t?{}:t,n=e.palette,i=void 0===n?{}:n,o=e.spacing,a=e.shape,s=void 0===a?{}:a,u=wf(e,Hd),c=yd(r),l=Vd(o),f=vd({breakpoints:c,direction:"ltr",components:{},palette:kf({mode:"light"},i),spacing:l,shape:kf({},md,s)},u),h=arguments.length,d=new Array(h>1?h-1:0),p=1;p0&&void 0!==arguments[0]?arguments[0]:Up,t=Object.keys(e).reduce((function(t,r){return e[r].filterProps.forEach((function(n){t[n]=e[r]})),t}),{});function r(e,r,n){var i,o=(O(i={},e,r),O(i,"theme",n),i),a=t[e];return a?a(o):O({},e,r)}function n(e){var i=e||{},o=i.sx,a=i.theme,s=void 0===a?{}:a;if(!o)return null;function u(e){var i=e;if("function"===typeof e)i=e(s);else if("object"!==typeof e)return e;if(!i)return null;var o=Ed(s.breakpoints),a=Object.keys(o),u=o;return Object.keys(i).forEach((function(e){var o=zp(i[e],s);if(null!==o&&void 0!==o)if("object"===typeof o)if(t[e])u=Cd(u,r(e,o,s));else{var a=kd({theme:s},o,(function(t){return O({},e,t)}));Fp(a,o)?u[e]=n({sx:o,theme:s}):u=Cd(u,a)}else u=Cd(u,r(e,o,s))})),xd(a,u)}return Array.isArray(o)?o.map(u):u(o)}return n}();Zp.filterProps=["sx"];var jp=Zp,qp=["name","slot","skipVariantsResolver","skipSx","overridesResolver"],Kp=["theme"],Vp=["theme"];function Hp(e){return 0===Object.keys(e).length}function Gp(e){return"string"===typeof e&&e.charCodeAt(0)>96}var Wp=function(e,t){return t.components&&t.components[e]&&t.components[e].styleOverrides?t.components[e].styleOverrides:null},Qp=function(e,t){var r=[];t&&t.components&&t.components[e]&&t.components[e].variants&&(r=t.components[e].variants);var n={};return r.forEach((function(e){var t=Jd(e.props);n[t]=e.style})),n},Jp=function(e,t,r,n){var i,o,a=e.ownerState,s=void 0===a?{}:a,u=[],c=null==r||null==(i=r.components)||null==(o=i[n])?void 0:o.variants;return c&&c.forEach((function(r){var n=!0;Object.keys(r.props).forEach((function(t){s[t]!==r.props[t]&&e[t]!==r.props[t]&&(n=!1)})),n&&u.push(t[Jd(r.props)])})),u};function Yp(e){return"ownerState"!==e&&"theme"!==e&&"sx"!==e&&"as"!==e}var Xp=Gd();function $p(e,t){var r;return kf({toolbar:(r={minHeight:56},O(r,e.up("xs"),{"@media (orientation: landscape)":{minHeight:48}}),O(r,e.up("sm"),{minHeight:64}),r)},t)}var ev={black:"#000",white:"#fff"},tv={50:"#fafafa",100:"#f5f5f5",200:"#eeeeee",300:"#e0e0e0",400:"#bdbdbd",500:"#9e9e9e",600:"#757575",700:"#616161",800:"#424242",900:"#212121",A100:"#f5f5f5",A200:"#eeeeee",A400:"#bdbdbd",A700:"#616161"},rv={50:"#f3e5f5",100:"#e1bee7",200:"#ce93d8",300:"#ba68c8",400:"#ab47bc",500:"#9c27b0",600:"#8e24aa",700:"#7b1fa2",800:"#6a1b9a",900:"#4a148c",A100:"#ea80fc",A200:"#e040fb",A400:"#d500f9",A700:"#aa00ff"},nv={50:"#ffebee",100:"#ffcdd2",200:"#ef9a9a",300:"#e57373",400:"#ef5350",500:"#f44336",600:"#e53935",700:"#d32f2f",800:"#c62828",900:"#b71c1c",A100:"#ff8a80",A200:"#ff5252",A400:"#ff1744",A700:"#d50000"},iv={50:"#fff3e0",100:"#ffe0b2",200:"#ffcc80",300:"#ffb74d",400:"#ffa726",500:"#ff9800",600:"#fb8c00",700:"#f57c00",800:"#ef6c00",900:"#e65100",A100:"#ffd180",A200:"#ffab40",A400:"#ff9100",A700:"#ff6d00"},ov={50:"#e3f2fd",100:"#bbdefb",200:"#90caf9",300:"#64b5f6",400:"#42a5f5",500:"#2196f3",600:"#1e88e5",700:"#1976d2",800:"#1565c0",900:"#0d47a1",A100:"#82b1ff",A200:"#448aff",A400:"#2979ff",A700:"#2962ff"},av={50:"#e1f5fe",100:"#b3e5fc",200:"#81d4fa",300:"#4fc3f7",400:"#29b6f6",500:"#03a9f4",600:"#039be5",700:"#0288d1",800:"#0277bd",900:"#01579b",A100:"#80d8ff",A200:"#40c4ff",A400:"#00b0ff",A700:"#0091ea"},sv={50:"#e8f5e9",100:"#c8e6c9",200:"#a5d6a7",300:"#81c784",400:"#66bb6a",500:"#4caf50",600:"#43a047",700:"#388e3c",800:"#2e7d32",900:"#1b5e20",A100:"#b9f6ca",A200:"#69f0ae",A400:"#00e676",A700:"#00c853"},uv=["mode","contrastThreshold","tonalOffset"],cv={text:{primary:"rgba(0, 0, 0, 0.87)",secondary:"rgba(0, 0, 0, 0.6)",disabled:"rgba(0, 0, 0, 0.38)"},divider:"rgba(0, 0, 0, 0.12)",background:{paper:ev.white,default:ev.white},action:{active:"rgba(0, 0, 0, 0.54)",hover:"rgba(0, 0, 0, 0.04)",hoverOpacity:.04,selected:"rgba(0, 0, 0, 0.08)",selectedOpacity:.08,disabled:"rgba(0, 0, 0, 0.26)",disabledBackground:"rgba(0, 0, 0, 0.12)",disabledOpacity:.38,focus:"rgba(0, 0, 0, 0.12)",focusOpacity:.12,activatedOpacity:.12}},lv={text:{primary:ev.white,secondary:"rgba(255, 255, 255, 0.7)",disabled:"rgba(255, 255, 255, 0.5)",icon:"rgba(255, 255, 255, 0.5)"},divider:"rgba(255, 255, 255, 0.12)",background:{paper:"#121212",default:"#121212"},action:{active:ev.white,hover:"rgba(255, 255, 255, 0.08)",hoverOpacity:.08,selected:"rgba(255, 255, 255, 0.16)",selectedOpacity:.16,disabled:"rgba(255, 255, 255, 0.3)",disabledBackground:"rgba(255, 255, 255, 0.12)",disabledOpacity:.38,focus:"rgba(255, 255, 255, 0.12)",focusOpacity:.12,activatedOpacity:.24}};function fv(e,t,r,n){var i=n.light||n,o=n.dark||1.5*n;e[t]||(e.hasOwnProperty(r)?e[t]=e[r]:"light"===t?e.light=Mf(e.main,i):"dark"===t&&(e.dark=Bf(e.main,o)))}function hv(e){var t=e.mode,r=void 0===t?"light":t,n=e.contrastThreshold,i=void 0===n?3:n,o=e.tonalOffset,a=void 0===o?.2:o,s=wf(e,uv),u=e.primary||function(){return"dark"===(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"light")?{main:ov[200],light:ov[50],dark:ov[400]}:{main:ov[700],light:ov[400],dark:ov[800]}}(r),c=e.secondary||function(){return"dark"===(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"light")?{main:rv[200],light:rv[50],dark:rv[400]}:{main:rv[500],light:rv[300],dark:rv[700]}}(r),l=e.error||function(){return"dark"===(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"light")?{main:nv[500],light:nv[300],dark:nv[700]}:{main:nv[700],light:nv[400],dark:nv[800]}}(r),f=e.info||function(){return"dark"===(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"light")?{main:av[400],light:av[300],dark:av[700]}:{main:av[700],light:av[500],dark:av[900]}}(r),h=e.success||function(){return"dark"===(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"light")?{main:sv[400],light:sv[300],dark:sv[700]}:{main:sv[800],light:sv[500],dark:sv[900]}}(r),d=e.warning||function(){return"dark"===(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"light")?{main:iv[400],light:iv[300],dark:iv[700]}:{main:"#ed6c02",light:iv[500],dark:iv[900]}}(r);function p(e){var t=function(e,t){var r=Pf(e),n=Pf(t);return(Math.max(r,n)+.05)/(Math.min(r,n)+.05)}(e,lv.text.primary)>=i?lv.text.primary:cv.text.primary;return t}var v=function(e){var t=e.color,r=e.name,n=e.mainShade,i=void 0===n?500:n,o=e.lightShade,s=void 0===o?300:o,u=e.darkShade,c=void 0===u?700:u;if(!(t=kf({},t)).main&&t[i]&&(t.main=t[i]),!t.hasOwnProperty("main"))throw new Error(Af(11,r?" (".concat(r,")"):"",i));if("string"!==typeof t.main)throw new Error(Af(12,r?" (".concat(r,")"):"",JSON.stringify(t.main)));return fv(t,"light",s,a),fv(t,"dark",c,a),t.contrastText||(t.contrastText=p(t.main)),t},g={dark:lv,light:cv};return vd(kf({common:kf({},ev),mode:r,primary:v({color:u,name:"primary"}),secondary:v({color:c,name:"secondary",mainShade:"A400",lightShade:"A200",darkShade:"A700"}),error:v({color:l,name:"error"}),warning:v({color:d,name:"warning"}),info:v({color:f,name:"info"}),success:v({color:h,name:"success"}),grey:tv,contrastThreshold:i,getContrastText:p,augmentColor:v,tonalOffset:a},g[r]),s)}var dv=["fontFamily","fontSize","fontWeightLight","fontWeightRegular","fontWeightMedium","fontWeightBold","htmlFontSize","allVariants","pxToRem"];var pv={textTransform:"uppercase"},vv='"Roboto", "Helvetica", "Arial", sans-serif';function gv(e,t){var r="function"===typeof t?t(e):t,n=r.fontFamily,i=void 0===n?vv:n,o=r.fontSize,a=void 0===o?14:o,s=r.fontWeightLight,u=void 0===s?300:s,c=r.fontWeightRegular,l=void 0===c?400:c,f=r.fontWeightMedium,h=void 0===f?500:f,d=r.fontWeightBold,p=void 0===d?700:d,v=r.htmlFontSize,g=void 0===v?16:v,y=r.allVariants,m=r.pxToRem,b=wf(r,dv);var w=a/14,k=m||function(e){return"".concat(e/g*w,"rem")},E=function(e,t,r,n,o){return kf({fontFamily:i,fontWeight:e,fontSize:k(t),lineHeight:r},i===vv?{letterSpacing:"".concat((a=n/t,Math.round(1e5*a)/1e5),"em")}:{},o,y);var a},x={h1:E(u,96,1.167,-1.5),h2:E(u,60,1.2,-.5),h3:E(l,48,1.167,0),h4:E(l,34,1.235,.25),h5:E(l,24,1.334,0),h6:E(h,20,1.6,.15),subtitle1:E(l,16,1.75,.15),subtitle2:E(h,14,1.57,.1),body1:E(l,16,1.5,.15),body2:E(l,14,1.43,.15),button:E(h,14,1.75,.4,pv),caption:E(l,12,1.66,.4),overline:E(l,12,2.66,1,pv)};return vd(kf({htmlFontSize:g,pxToRem:k,fontFamily:i,fontSize:a,fontWeightLight:u,fontWeightRegular:l,fontWeightMedium:h,fontWeightBold:p},x),b,{clone:!1})}function yv(){return["".concat(arguments.length<=0?void 0:arguments[0],"px ").concat(arguments.length<=1?void 0:arguments[1],"px ").concat(arguments.length<=2?void 0:arguments[2],"px ").concat(arguments.length<=3?void 0:arguments[3],"px rgba(0,0,0,").concat(.2,")"),"".concat(arguments.length<=4?void 0:arguments[4],"px ").concat(arguments.length<=5?void 0:arguments[5],"px ").concat(arguments.length<=6?void 0:arguments[6],"px ").concat(arguments.length<=7?void 0:arguments[7],"px rgba(0,0,0,").concat(.14,")"),"".concat(arguments.length<=8?void 0:arguments[8],"px ").concat(arguments.length<=9?void 0:arguments[9],"px ").concat(arguments.length<=10?void 0:arguments[10],"px ").concat(arguments.length<=11?void 0:arguments[11],"px rgba(0,0,0,").concat(.12,")")].join(",")}var mv=["none",yv(0,2,1,-1,0,1,1,0,0,1,3,0),yv(0,3,1,-2,0,2,2,0,0,1,5,0),yv(0,3,3,-2,0,3,4,0,0,1,8,0),yv(0,2,4,-1,0,4,5,0,0,1,10,0),yv(0,3,5,-1,0,5,8,0,0,1,14,0),yv(0,3,5,-1,0,6,10,0,0,1,18,0),yv(0,4,5,-2,0,7,10,1,0,2,16,1),yv(0,5,5,-3,0,8,10,1,0,3,14,2),yv(0,5,6,-3,0,9,12,1,0,3,16,2),yv(0,6,6,-3,0,10,14,1,0,4,18,3),yv(0,6,7,-4,0,11,15,1,0,4,20,3),yv(0,7,8,-4,0,12,17,2,0,5,22,4),yv(0,7,8,-4,0,13,19,2,0,5,24,4),yv(0,7,9,-4,0,14,21,2,0,5,26,4),yv(0,8,9,-5,0,15,22,2,0,6,28,5),yv(0,8,10,-5,0,16,24,2,0,6,30,5),yv(0,8,11,-5,0,17,26,2,0,6,32,5),yv(0,9,11,-5,0,18,28,2,0,7,34,6),yv(0,9,12,-6,0,19,29,2,0,7,36,6),yv(0,10,13,-6,0,20,31,3,0,8,38,7),yv(0,10,13,-6,0,21,33,3,0,8,40,7),yv(0,10,14,-6,0,22,35,3,0,8,42,7),yv(0,11,14,-7,0,23,36,3,0,9,44,8),yv(0,11,15,-7,0,24,38,3,0,9,46,8)],bv=["duration","easing","delay"],wv={easeInOut:"cubic-bezier(0.4, 0, 0.2, 1)",easeOut:"cubic-bezier(0.0, 0, 0.2, 1)",easeIn:"cubic-bezier(0.4, 0, 1, 1)",sharp:"cubic-bezier(0.4, 0, 0.6, 1)"},kv={shortest:150,shorter:200,short:250,standard:300,complex:375,enteringScreen:225,leavingScreen:195};function Ev(e){return"".concat(Math.round(e),"ms")}function xv(e){if(!e)return 0;var t=e/36;return Math.round(10*(4+15*Math.pow(t,.25)+t/5))}function _v(e){var t=kf({},wv,e.easing),r=kf({},kv,e.duration);return kf({getAutoHeightDuration:xv,create:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:["all"],n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=n.duration,o=void 0===i?r.standard:i,a=n.easing,s=void 0===a?t.easeInOut:a,u=n.delay,c=void 0===u?0:u;wf(n,bv);return(Array.isArray(e)?e:[e]).map((function(e){return"".concat(e," ").concat("string"===typeof o?o:Ev(o)," ").concat(s," ").concat("string"===typeof c?c:Ev(c))})).join(",")}},e,{easing:t,duration:r})}var Sv={mobileStepper:1e3,fab:1050,speedDial:1050,appBar:1100,drawer:1200,modal:1300,snackbar:1400,tooltip:1500},Av=["breakpoints","mixins","spacing","palette","transitions","typography","shape"];function Iv(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.mixins,r=void 0===t?{}:t,n=e.palette,i=void 0===n?{}:n,o=e.transitions,a=void 0===o?{}:o,s=e.typography,u=void 0===s?{}:s,c=wf(e,Av);if(e.vars)throw new Error(Af(18));var l=hv(i),f=Gd(e),h=vd(f,{mixins:$p(f.breakpoints,r),palette:l,shadows:mv.slice(),typography:gv(l,u),transitions:_v(a),zIndex:kf({},Sv)});h=vd(h,c);for(var d=arguments.length,p=new Array(d>1?d-1:0),v=1;v0&&void 0!==arguments[0]?arguments[0]:{},t=e.defaultTheme,r=void 0===t?Xp:t,n=e.rootShouldForwardProp,i=void 0===n?Yp:n,o=e.slotShouldForwardProp,a=void 0===o?Yp:o,s=e.styleFunctionSx,u=void 0===s?jp:s,c=function(e){var t=Hp(e.theme)?r:e.theme;return u(kf({},e,{theme:t}))};return c.__mui_systemSx=!0,function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};dd(e,(function(e){return e.filter((function(e){return!(null!=e&&e.__mui_systemSx)}))}));var n,o=t.name,s=t.slot,u=t.skipVariantsResolver,l=t.skipSx,f=t.overridesResolver,h=wf(t,qp),d=void 0!==u?u:s&&"Root"!==s||!1,p=l||!1;var v=Yp;"Root"===s?v=i:s?v=a:Gp(e)&&(v=void 0);var g=hd(e,kf({shouldForwardProp:v,label:n},h)),y=function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i0){var l=new Array(u).fill("");(s=[].concat($r(e),$r(l))).raw=[].concat($r(e.raw),$r(l))}else"function"===typeof e&&e.__emotion_real!==e&&(s=function(t){var n=t.theme,i=wf(t,Vp);return e(kf({theme:Hp(n)?r:n},i))});var h=g.apply(void 0,[s].concat($r(a)));return h};return g.withConfig&&(y.withConfig=g.withConfig),y}}({defaultTheme:Cv,rootShouldForwardProp:Tv}),Rv=Pv;var Bv=k.createContext(null);function Mv(){return k.useContext(Bv)}function Nv(e){return 0===Object.keys(e).length}var Ov=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,t=Mv();return!t||Nv(t)?e:t},Dv=Gd();var Lv=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Dv;return Ov(e)};function Uv(e){var t=e.props,r=e.name,n=e.defaultTheme,i=function(e){var t=e.theme,r=e.name,n=e.props;return t&&t.components&&t.components[r]&&t.components[r].defaultProps?_f(t.components[r].defaultProps,n):n}({theme:Lv(n),name:r,props:t});return i}function Fv(e){return Uv({props:e.props,name:e.name,defaultTheme:Cv})}function zv(e,t){"function"===typeof e?e(t):e&&(e.current=t)}var Zv=function(e,t){return k.useMemo((function(){return null==e&&null==t?null:function(r){zv(e,r),zv(t,r)}}),[e,t])},jv="undefined"!==typeof window?k.useLayoutEffect:k.useEffect;var qv,Kv=function(e){var t=k.useRef(e);return jv((function(){t.current=e})),k.useCallback((function(){return t.current.apply(void 0,arguments)}),[])},Vv=!0,Hv=!1,Gv={text:!0,search:!0,url:!0,tel:!0,email:!0,password:!0,number:!0,date:!0,month:!0,week:!0,time:!0,datetime:!0,"datetime-local":!0};function Wv(e){e.metaKey||e.altKey||e.ctrlKey||(Vv=!0)}function Qv(){Vv=!1}function Jv(){"hidden"===this.visibilityState&&Hv&&(Vv=!0)}function Yv(e){var t=e.target;try{return t.matches(":focus-visible")}catch(r){}return Vv||function(e){var t=e.type,r=e.tagName;return!("INPUT"!==r||!Gv[t]||e.readOnly)||"TEXTAREA"===r&&!e.readOnly||!!e.isContentEditable}(t)}var Xv=function(){var e=k.useCallback((function(e){var t;null!=e&&((t=e.ownerDocument).addEventListener("keydown",Wv,!0),t.addEventListener("mousedown",Qv,!0),t.addEventListener("pointerdown",Qv,!0),t.addEventListener("touchstart",Qv,!0),t.addEventListener("visibilitychange",Jv,!0))}),[]),t=k.useRef(!1);return{isFocusVisibleRef:t,onFocus:function(e){return!!Yv(e)&&(t.current=!0,!0)},onBlur:function(){return!!t.current&&(Hv=!0,window.clearTimeout(qv),qv=window.setTimeout((function(){Hv=!1}),100),t.current=!1,!0)},ref:e}};function $v(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}var eg=k.createContext(null);function tg(e,t){var r=Object.create(null);return e&&k.Children.map(e,(function(e){return e})).forEach((function(e){r[e.key]=function(e){return t&&(0,k.isValidElement)(e)?t(e):e}(e)})),r}function rg(e,t,r){return null!=r[t]?r[t]:e.props[t]}function ng(e,t,r){var n=tg(e.children),i=function(e,t){function r(r){return r in t?t[r]:e[r]}e=e||{},t=t||{};var n,i=Object.create(null),o=[];for(var a in e)a in t?o.length&&(i[a]=o,o=[]):o.push(a);var s={};for(var u in t){if(i[u])for(n=0;n2&&void 0!==arguments[2]?arguments[2]:"Mui",n=dg[t];return n?"".concat(r,"-").concat(n):"".concat(hg.generate(e),"-").concat(t)}function vg(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"Mui",n={};return t.forEach((function(t){n[t]=pg(e,t,r)})),n}var gg,yg,mg,bg,wg,kg,Eg,xg,_g=vg("MuiTouchRipple",["root","ripple","rippleVisible","ripplePulsate","child","childLeaving","childPulsate"]),Sg=["center","classes","className"],Ag=ug(wg||(wg=gg||(gg=$v(["\n 0% {\n transform: scale(0);\n opacity: 0.1;\n }\n\n 100% {\n transform: scale(1);\n opacity: 0.3;\n }\n"])))),Ig=ug(kg||(kg=yg||(yg=$v(["\n 0% {\n opacity: 1;\n }\n\n 100% {\n opacity: 0;\n }\n"])))),Cg=ug(Eg||(Eg=mg||(mg=$v(["\n 0% {\n transform: scale(1);\n }\n\n 50% {\n transform: scale(0.92);\n }\n\n 100% {\n transform: scale(1);\n }\n"])))),Tg=Rv("span",{name:"MuiTouchRipple",slot:"Root"})({overflow:"hidden",pointerEvents:"none",position:"absolute",zIndex:0,top:0,right:0,bottom:0,left:0,borderRadius:"inherit"}),Pg=Rv(lg,{name:"MuiTouchRipple",slot:"Ripple"})(xg||(xg=bg||(bg=$v(["\n opacity: 0;\n position: absolute;\n\n &."," {\n opacity: 0.3;\n transform: scale(1);\n animation-name: ",";\n animation-duration: ","ms;\n animation-timing-function: ",";\n }\n\n &."," {\n animation-duration: ","ms;\n }\n\n & ."," {\n opacity: 1;\n display: block;\n width: 100%;\n height: 100%;\n border-radius: 50%;\n background-color: currentColor;\n }\n\n & ."," {\n opacity: 0;\n animation-name: ",";\n animation-duration: ","ms;\n animation-timing-function: ",";\n }\n\n & ."," {\n position: absolute;\n /* @noflip */\n left: 0px;\n top: 0;\n animation-name: ",";\n animation-duration: 2500ms;\n animation-timing-function: ",";\n animation-iteration-count: infinite;\n animation-delay: 200ms;\n }\n"]))),_g.rippleVisible,Ag,550,(function(e){return e.theme.transitions.easing.easeInOut}),_g.ripplePulsate,(function(e){return e.theme.transitions.duration.shorter}),_g.child,_g.childLeaving,Ig,550,(function(e){return e.theme.transitions.easing.easeInOut}),_g.childPulsate,Cg,(function(e){return e.theme.transitions.easing.easeInOut})),Rg=k.forwardRef((function(e,t){var r=Fv({props:e,name:"MuiTouchRipple"}),n=r.center,i=void 0!==n&&n,o=r.classes,a=void 0===o?{}:o,s=r.className,u=wf(r,Sg),c=P(k.useState([]),2),l=c[0],f=c[1],h=k.useRef(0),d=k.useRef(null);k.useEffect((function(){d.current&&(d.current(),d.current=null)}),[l]);var p=k.useRef(!1),v=k.useRef(null),g=k.useRef(null),y=k.useRef(null);k.useEffect((function(){return function(){clearTimeout(v.current)}}),[]);var m=k.useCallback((function(e){var t=e.pulsate,r=e.rippleX,n=e.rippleY,i=e.rippleSize,o=e.cb;f((function(e){return[].concat($r(e),[(0,cg.jsx)(Pg,{classes:{ripple:xf(a.ripple,_g.ripple),rippleVisible:xf(a.rippleVisible,_g.rippleVisible),ripplePulsate:xf(a.ripplePulsate,_g.ripplePulsate),child:xf(a.child,_g.child),childLeaving:xf(a.childLeaving,_g.childLeaving),childPulsate:xf(a.childPulsate,_g.childPulsate)},timeout:550,pulsate:t,rippleX:r,rippleY:n,rippleSize:i},h.current)])})),h.current+=1,d.current=o}),[a]),b=k.useCallback((function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2?arguments[2]:void 0,n=t.pulsate,o=void 0!==n&&n,a=t.center,s=void 0===a?i||t.pulsate:a,u=t.fakeElement,c=void 0!==u&&u;if("mousedown"===(null==e?void 0:e.type)&&p.current)p.current=!1;else{"touchstart"===(null==e?void 0:e.type)&&(p.current=!0);var l,f,h,d=c?null:y.current,b=d?d.getBoundingClientRect():{width:0,height:0,left:0,top:0};if(s||void 0===e||0===e.clientX&&0===e.clientY||!e.clientX&&!e.touches)l=Math.round(b.width/2),f=Math.round(b.height/2);else{var w=e.touches&&e.touches.length>0?e.touches[0]:e,k=w.clientX,E=w.clientY;l=Math.round(k-b.left),f=Math.round(E-b.top)}if(s)(h=Math.sqrt((2*Math.pow(b.width,2)+Math.pow(b.height,2))/3))%2===0&&(h+=1);else{var x=2*Math.max(Math.abs((d?d.clientWidth:0)-l),l)+2,_=2*Math.max(Math.abs((d?d.clientHeight:0)-f),f)+2;h=Math.sqrt(Math.pow(x,2)+Math.pow(_,2))}null!=e&&e.touches?null===g.current&&(g.current=function(){m({pulsate:o,rippleX:l,rippleY:f,rippleSize:h,cb:r})},v.current=setTimeout((function(){g.current&&(g.current(),g.current=null)}),80)):m({pulsate:o,rippleX:l,rippleY:f,rippleSize:h,cb:r})}}),[i,m]),w=k.useCallback((function(){b({},{pulsate:!0})}),[b]),E=k.useCallback((function(e,t){if(clearTimeout(v.current),"touchend"===(null==e?void 0:e.type)&&g.current)return g.current(),g.current=null,void(v.current=setTimeout((function(){E(e,t)})));g.current=null,f((function(e){return e.length>0?e.slice(1):e})),d.current=t}),[]);return k.useImperativeHandle(t,(function(){return{pulsate:w,start:b,stop:E}}),[w,b,E]),(0,cg.jsx)(Tg,kf({className:xf(_g.root,a.root,s),ref:y},u,{children:(0,cg.jsx)(ag,{component:null,exit:!0,children:l})}))})),Bg=Rg;function Mg(e){return pg("MuiButtonBase",e)}var Ng,Og=vg("MuiButtonBase",["root","disabled","focusVisible"]),Dg=["action","centerRipple","children","className","component","disabled","disableRipple","disableTouchRipple","focusRipple","focusVisibleClassName","LinkComponent","onBlur","onClick","onContextMenu","onDragLeave","onFocus","onFocusVisible","onKeyDown","onKeyUp","onMouseDown","onMouseLeave","onMouseUp","onTouchEnd","onTouchMove","onTouchStart","tabIndex","TouchRippleProps","touchRippleRef","type"],Lg=Rv("button",{name:"MuiButtonBase",slot:"Root",overridesResolver:function(e,t){return t.root}})((O(Ng={display:"inline-flex",alignItems:"center",justifyContent:"center",position:"relative",boxSizing:"border-box",WebkitTapHighlightColor:"transparent",backgroundColor:"transparent",outline:0,border:0,margin:0,borderRadius:0,padding:0,cursor:"pointer",userSelect:"none",verticalAlign:"middle",MozAppearance:"none",WebkitAppearance:"none",textDecoration:"none",color:"inherit","&::-moz-focus-inner":{borderStyle:"none"}},"&.".concat(Og.disabled),{pointerEvents:"none",cursor:"default"}),O(Ng,"@media print",{colorAdjust:"exact"}),Ng)),Ug=k.forwardRef((function(e,t){var r=Fv({props:e,name:"MuiButtonBase"}),n=r.action,i=r.centerRipple,o=void 0!==i&&i,a=r.children,s=r.className,u=r.component,c=void 0===u?"button":u,l=r.disabled,f=void 0!==l&&l,h=r.disableRipple,d=void 0!==h&&h,p=r.disableTouchRipple,v=void 0!==p&&p,g=r.focusRipple,y=void 0!==g&&g,m=r.LinkComponent,b=void 0===m?"a":m,w=r.onBlur,E=r.onClick,x=r.onContextMenu,_=r.onDragLeave,S=r.onFocus,A=r.onFocusVisible,I=r.onKeyDown,C=r.onKeyUp,T=r.onMouseDown,R=r.onMouseLeave,B=r.onMouseUp,M=r.onTouchEnd,N=r.onTouchMove,O=r.onTouchStart,D=r.tabIndex,L=void 0===D?0:D,U=r.TouchRippleProps,F=r.touchRippleRef,z=r.type,Z=wf(r,Dg),j=k.useRef(null),q=k.useRef(null),K=Zv(q,F),V=Xv(),H=V.isFocusVisibleRef,G=V.onFocus,W=V.onBlur,Q=V.ref,J=P(k.useState(!1),2),Y=J[0],X=J[1];f&&Y&&X(!1),k.useImperativeHandle(n,(function(){return{focusVisible:function(){X(!0),j.current.focus()}}}),[]);var $=P(k.useState(!1),2),ee=$[0],te=$[1];k.useEffect((function(){te(!0)}),[]);var re=ee&&!d&&!f;function ne(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:v;return Kv((function(n){return t&&t(n),!r&&q.current&&q.current[e](n),!0}))}k.useEffect((function(){Y&&y&&!d&&ee&&q.current.pulsate()}),[d,y,Y,ee]);var ie=ne("start",T),oe=ne("stop",x),ae=ne("stop",_),se=ne("stop",B),ue=ne("stop",(function(e){Y&&e.preventDefault(),R&&R(e)})),ce=ne("start",O),le=ne("stop",M),fe=ne("stop",N),he=ne("stop",(function(e){W(e),!1===H.current&&X(!1),w&&w(e)}),!1),de=Kv((function(e){j.current||(j.current=e.currentTarget),G(e),!0===H.current&&(X(!0),A&&A(e)),S&&S(e)})),pe=function(){var e=j.current;return c&&"button"!==c&&!("A"===e.tagName&&e.href)},ve=k.useRef(!1),ge=Kv((function(e){y&&!ve.current&&Y&&q.current&&" "===e.key&&(ve.current=!0,q.current.stop(e,(function(){q.current.start(e)}))),e.target===e.currentTarget&&pe()&&" "===e.key&&e.preventDefault(),I&&I(e),e.target===e.currentTarget&&pe()&&"Enter"===e.key&&!f&&(e.preventDefault(),E&&E(e))})),ye=Kv((function(e){y&&" "===e.key&&q.current&&Y&&!e.defaultPrevented&&(ve.current=!1,q.current.stop(e,(function(){q.current.pulsate(e)}))),C&&C(e),E&&e.target===e.currentTarget&&pe()&&" "===e.key&&!e.defaultPrevented&&E(e)})),me=c;"button"===me&&(Z.href||Z.to)&&(me=b);var be={};"button"===me?(be.type=void 0===z?"button":z,be.disabled=f):(Z.href||Z.to||(be.role="button"),f&&(be["aria-disabled"]=f));var we=Zv(Q,j),ke=Zv(t,we);var Ee=kf({},r,{centerRipple:o,component:c,disabled:f,disableRipple:d,disableTouchRipple:v,focusRipple:y,tabIndex:L,focusVisible:Y}),xe=function(e){var t=e.disabled,r=e.focusVisible,n=e.focusVisibleClassName,i=Sf({root:["root",t&&"disabled",r&&"focusVisible"]},Mg,e.classes);return r&&n&&(i.root+=" ".concat(n)),i}(Ee);return(0,cg.jsxs)(Lg,kf({as:me,className:xf(xe.root,s),ownerState:Ee,onBlur:he,onClick:E,onContextMenu:oe,onFocus:de,onKeyDown:ge,onKeyUp:ye,onMouseDown:ie,onMouseLeave:ue,onMouseUp:se,onDragLeave:ae,onTouchEnd:le,onTouchMove:fe,onTouchStart:ce,ref:ke,tabIndex:f?-1:L,type:z},be,Z,{children:[a,re?(0,cg.jsx)(Bg,kf({ref:K,center:o},U)):null]}))})),Fg=Ug,zg=_d;function Zg(e){return pg("MuiButton",e)}var jg=vg("MuiButton",["root","text","textInherit","textPrimary","textSecondary","textSuccess","textError","textInfo","textWarning","outlined","outlinedInherit","outlinedPrimary","outlinedSecondary","outlinedSuccess","outlinedError","outlinedInfo","outlinedWarning","contained","containedInherit","containedPrimary","containedSecondary","containedSuccess","containedError","containedInfo","containedWarning","disableElevation","focusVisible","disabled","colorInherit","textSizeSmall","textSizeMedium","textSizeLarge","outlinedSizeSmall","outlinedSizeMedium","outlinedSizeLarge","containedSizeSmall","containedSizeMedium","containedSizeLarge","sizeMedium","sizeSmall","sizeLarge","fullWidth","startIcon","endIcon","iconSizeSmall","iconSizeMedium","iconSizeLarge"]);var qg=k.createContext({}),Kg=["children","color","component","className","disabled","disableElevation","disableFocusRipple","endIcon","focusVisibleClassName","fullWidth","size","startIcon","type","variant"],Vg=["root"],Hg=function(e){return kf({},"small"===e.size&&{"& > *:nth-of-type(1)":{fontSize:18}},"medium"===e.size&&{"& > *:nth-of-type(1)":{fontSize:20}},"large"===e.size&&{"& > *:nth-of-type(1)":{fontSize:22}})},Gg=Rv(Fg,{shouldForwardProp:function(e){return Tv(e)||"classes"===e},name:"MuiButton",slot:"Root",overridesResolver:function(e,t){var r=e.ownerState;return[t.root,t[r.variant],t["".concat(r.variant).concat(zg(r.color))],t["size".concat(zg(r.size))],t["".concat(r.variant,"Size").concat(zg(r.size))],"inherit"===r.color&&t.colorInherit,r.disableElevation&&t.disableElevation,r.fullWidth&&t.fullWidth]}})((function(e){var t,r,n,i=e.theme,o=e.ownerState;return kf({},i.typography.button,(O(t={minWidth:64,padding:"6px 16px",borderRadius:(i.vars||i).shape.borderRadius,transition:i.transitions.create(["background-color","box-shadow","border-color","color"],{duration:i.transitions.duration.short}),"&:hover":kf({textDecoration:"none",backgroundColor:i.vars?"rgba(".concat(i.vars.palette.text.primaryChannel," / ").concat(i.vars.palette.action.hoverOpacity,")"):Rf(i.palette.text.primary,i.palette.action.hoverOpacity),"@media (hover: none)":{backgroundColor:"transparent"}},"text"===o.variant&&"inherit"!==o.color&&{backgroundColor:i.vars?"rgba(".concat(i.vars.palette[o.color].mainChannel," / ").concat(i.vars.palette.action.hoverOpacity,")"):Rf(i.palette[o.color].main,i.palette.action.hoverOpacity),"@media (hover: none)":{backgroundColor:"transparent"}},"outlined"===o.variant&&"inherit"!==o.color&&{border:"1px solid ".concat((i.vars||i).palette[o.color].main),backgroundColor:i.vars?"rgba(".concat(i.vars.palette[o.color].mainChannel," / ").concat(i.vars.palette.action.hoverOpacity,")"):Rf(i.palette[o.color].main,i.palette.action.hoverOpacity),"@media (hover: none)":{backgroundColor:"transparent"}},"contained"===o.variant&&{backgroundColor:(i.vars||i).palette.grey.A100,boxShadow:(i.vars||i).shadows[4],"@media (hover: none)":{boxShadow:(i.vars||i).shadows[2],backgroundColor:(i.vars||i).palette.grey[300]}},"contained"===o.variant&&"inherit"!==o.color&&{backgroundColor:(i.vars||i).palette[o.color].dark,"@media (hover: none)":{backgroundColor:(i.vars||i).palette[o.color].main}}),"&:active":kf({},"contained"===o.variant&&{boxShadow:(i.vars||i).shadows[8]})},"&.".concat(jg.focusVisible),kf({},"contained"===o.variant&&{boxShadow:(i.vars||i).shadows[6]})),O(t,"&.".concat(jg.disabled),kf({color:(i.vars||i).palette.action.disabled},"outlined"===o.variant&&{border:"1px solid ".concat((i.vars||i).palette.action.disabledBackground)},"outlined"===o.variant&&"secondary"===o.color&&{border:"1px solid ".concat((i.vars||i).palette.action.disabled)},"contained"===o.variant&&{color:(i.vars||i).palette.action.disabled,boxShadow:(i.vars||i).shadows[0],backgroundColor:(i.vars||i).palette.action.disabledBackground})),t),"text"===o.variant&&{padding:"6px 8px"},"text"===o.variant&&"inherit"!==o.color&&{color:(i.vars||i).palette[o.color].main},"outlined"===o.variant&&{padding:"5px 15px",border:"1px solid currentColor"},"outlined"===o.variant&&"inherit"!==o.color&&{color:(i.vars||i).palette[o.color].main,border:i.vars?"1px solid rgba(".concat(i.vars.palette[o.color].mainChannel," / 0.5)"):"1px solid ".concat(Rf(i.palette[o.color].main,.5))},"contained"===o.variant&&{color:i.vars?i.vars.palette.text.primary:null==(r=(n=i.palette).getContrastText)?void 0:r.call(n,i.palette.grey[300]),backgroundColor:(i.vars||i).palette.grey[300],boxShadow:(i.vars||i).shadows[2]},"contained"===o.variant&&"inherit"!==o.color&&{color:(i.vars||i).palette[o.color].contrastText,backgroundColor:(i.vars||i).palette[o.color].main},"inherit"===o.color&&{color:"inherit",borderColor:"currentColor"},"small"===o.size&&"text"===o.variant&&{padding:"4px 5px",fontSize:i.typography.pxToRem(13)},"large"===o.size&&"text"===o.variant&&{padding:"8px 11px",fontSize:i.typography.pxToRem(15)},"small"===o.size&&"outlined"===o.variant&&{padding:"3px 9px",fontSize:i.typography.pxToRem(13)},"large"===o.size&&"outlined"===o.variant&&{padding:"7px 21px",fontSize:i.typography.pxToRem(15)},"small"===o.size&&"contained"===o.variant&&{padding:"4px 10px",fontSize:i.typography.pxToRem(13)},"large"===o.size&&"contained"===o.variant&&{padding:"8px 22px",fontSize:i.typography.pxToRem(15)},o.fullWidth&&{width:"100%"})}),(function(e){var t;return e.ownerState.disableElevation&&(O(t={boxShadow:"none","&:hover":{boxShadow:"none"}},"&.".concat(jg.focusVisible),{boxShadow:"none"}),O(t,"&:active",{boxShadow:"none"}),O(t,"&.".concat(jg.disabled),{boxShadow:"none"}),t)})),Wg=Rv("span",{name:"MuiButton",slot:"StartIcon",overridesResolver:function(e,t){var r=e.ownerState;return[t.startIcon,t["iconSize".concat(zg(r.size))]]}})((function(e){var t=e.ownerState;return kf({display:"inherit",marginRight:8,marginLeft:-4},"small"===t.size&&{marginLeft:-2},Hg(t))})),Qg=Rv("span",{name:"MuiButton",slot:"EndIcon",overridesResolver:function(e,t){var r=e.ownerState;return[t.endIcon,t["iconSize".concat(zg(r.size))]]}})((function(e){var t=e.ownerState;return kf({display:"inherit",marginRight:-4,marginLeft:8},"small"===t.size&&{marginRight:-2},Hg(t))})),Jg=k.forwardRef((function(e,t){var r=k.useContext(qg),n=Fv({props:_f(r,e),name:"MuiButton"}),i=n.children,o=n.color,a=void 0===o?"primary":o,s=n.component,u=void 0===s?"button":s,c=n.className,l=n.disabled,f=void 0!==l&&l,h=n.disableElevation,d=void 0!==h&&h,p=n.disableFocusRipple,v=void 0!==p&&p,g=n.endIcon,y=n.focusVisibleClassName,m=n.fullWidth,b=void 0!==m&&m,w=n.size,E=void 0===w?"medium":w,x=n.startIcon,_=n.type,S=n.variant,A=void 0===S?"text":S,I=wf(n,Kg),C=kf({},n,{color:a,component:u,disabled:f,disableElevation:d,disableFocusRipple:v,fullWidth:b,size:E,type:_,variant:A}),T=function(e){var t=e.color,r=e.disableElevation,n=e.fullWidth,i=e.size,o=e.variant,a=e.classes;return kf({},a,Sf({root:["root",o,"".concat(o).concat(zg(t)),"size".concat(zg(i)),"".concat(o,"Size").concat(zg(i)),"inherit"===t&&"colorInherit",r&&"disableElevation",n&&"fullWidth"],label:["label"],startIcon:["startIcon","iconSize".concat(zg(i))],endIcon:["endIcon","iconSize".concat(zg(i))]},Zg,a))}(C),P=T.root,R=wf(T,Vg),B=x&&(0,cg.jsx)(Wg,{className:R.startIcon,ownerState:C,children:x}),M=g&&(0,cg.jsx)(Qg,{className:R.endIcon,ownerState:C,children:g});return(0,cg.jsxs)(Gg,kf({ownerState:C,className:xf(r.className,P,c),component:u,disabled:f,focusRipple:!v,focusVisibleClassName:xf(R.focusVisible,y),ref:t,type:_},I,{classes:R,children:[B,i,M]}))})),Yg=Jg,Xg=function(e,t,r,n){return new(r||(r=Promise))((function(i,o){function a(e){try{u(n.next(e))}catch(t){o(t)}}function s(e){try{u(n.throw(e))}catch(t){o(t)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(a,s)}u((n=n.apply(e,t||[])).next())}))},$g=new hn("properties/5.7.0");function ey(e,t,r){Object.defineProperty(e,t,{enumerable:!0,value:r,writable:!1})}function ty(e,t){for(var r=0;r<32;r++){if(e[t])return e[t];if(!e.prototype||"object"!==typeof e.prototype)break;e=Object.getPrototypeOf(e.prototype).constructor}return null}function ry(e){return Xg(this,void 0,void 0,(0,_.Z)().mark((function t(){var r,n;return(0,_.Z)().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Object.keys(e).map((function(t){var r=e[t];return Promise.resolve(r).then((function(e){return{key:t,value:e}}))})),t.next=3,Promise.all(r);case 3:return n=t.sent,t.abrupt("return",n.reduce((function(e,t){return e[t.key]=t.value,e}),{}));case 5:case"end":return t.stop()}}),t)})))}function ny(e){var t={};for(var r in e)t[r]=e[r];return t}var iy={bigint:!0,boolean:!0,function:!0,number:!0,string:!0};function oy(e){if(void 0===e||null===e||iy[typeof e])return!0;if(Array.isArray(e)||"object"===typeof e){if(!Object.isFrozen(e))return!1;for(var t=Object.keys(e),r=0;r=0)throw e;return fy.throwError("cannot estimate gas; transaction may fail or may require manual gas limit",hn.errors.UNPREDICTABLE_GAS_LIMIT,{error:e,tx:r})}))),null==r.chainId?r.chainId=this.getChainId():r.chainId=Promise.all([Promise.resolve(r.chainId),this.getChainId()]).then((function(t){return 0!==t[1]&&t[0]!==t[1]&&fy.throwArgumentError("chainId address mismatch","transaction",e),t[0]})),t.next=23,ry(r);case 23:return t.abrupt("return",t.sent);case 24:case"end":return t.stop()}}),t,this)})))}},{key:"_checkProvider",value:function(e){this.provider||fy.throwError("missing provider",hn.errors.UNSUPPORTED_OPERATION,{operation:e||"_checkProvider"})}}],[{key:"isSigner",value:function(e){return!(!e||!e._isSigner)}}]),e}(),vy=r(9867),gy=r.n(vy),yy=gy().BN,my=new hn("bignumber/5.7.0"),by={},wy=9007199254740991;var ky=!1,Ey=function(){function e(t,r){(0,F.Z)(this,e),t!==by&&my.throwError("cannot call constructor directly; use BigNumber.from",hn.errors.UNSUPPORTED_OPERATION,{operation:"new (BigNumber)"}),this._hex=r,this._isBigNumber=!0,Object.freeze(this)}return(0,U.Z)(e,[{key:"fromTwos",value:function(e){return _y(Sy(this).fromTwos(e))}},{key:"toTwos",value:function(e){return _y(Sy(this).toTwos(e))}},{key:"abs",value:function(){return"-"===this._hex[0]?e.from(this._hex.substring(1)):this}},{key:"add",value:function(e){return _y(Sy(this).add(Sy(e)))}},{key:"sub",value:function(e){return _y(Sy(this).sub(Sy(e)))}},{key:"div",value:function(t){return e.from(t).isZero()&&Ay("division-by-zero","div"),_y(Sy(this).div(Sy(t)))}},{key:"mul",value:function(e){return _y(Sy(this).mul(Sy(e)))}},{key:"mod",value:function(e){var t=Sy(e);return t.isNeg()&&Ay("division-by-zero","mod"),_y(Sy(this).umod(t))}},{key:"pow",value:function(e){var t=Sy(e);return t.isNeg()&&Ay("negative-power","pow"),_y(Sy(this).pow(t))}},{key:"and",value:function(e){var t=Sy(e);return(this.isNegative()||t.isNeg())&&Ay("unbound-bitwise-result","and"),_y(Sy(this).and(t))}},{key:"or",value:function(e){var t=Sy(e);return(this.isNegative()||t.isNeg())&&Ay("unbound-bitwise-result","or"),_y(Sy(this).or(t))}},{key:"xor",value:function(e){var t=Sy(e);return(this.isNegative()||t.isNeg())&&Ay("unbound-bitwise-result","xor"),_y(Sy(this).xor(t))}},{key:"mask",value:function(e){return(this.isNegative()||e<0)&&Ay("negative-width","mask"),_y(Sy(this).maskn(e))}},{key:"shl",value:function(e){return(this.isNegative()||e<0)&&Ay("negative-width","shl"),_y(Sy(this).shln(e))}},{key:"shr",value:function(e){return(this.isNegative()||e<0)&&Ay("negative-width","shr"),_y(Sy(this).shrn(e))}},{key:"eq",value:function(e){return Sy(this).eq(Sy(e))}},{key:"lt",value:function(e){return Sy(this).lt(Sy(e))}},{key:"lte",value:function(e){return Sy(this).lte(Sy(e))}},{key:"gt",value:function(e){return Sy(this).gt(Sy(e))}},{key:"gte",value:function(e){return Sy(this).gte(Sy(e))}},{key:"isNegative",value:function(){return"-"===this._hex[0]}},{key:"isZero",value:function(){return Sy(this).isZero()}},{key:"toNumber",value:function(){try{return Sy(this).toNumber()}catch(e){Ay("overflow","toNumber",this.toString())}return null}},{key:"toBigInt",value:function(){try{return BigInt(this.toString())}catch(e){}return my.throwError("this platform does not support BigInt",hn.errors.UNSUPPORTED_OPERATION,{value:this.toString()})}},{key:"toString",value:function(){return arguments.length>0&&(10===arguments[0]?ky||(ky=!0,my.warn("BigNumber.toString does not accept any parameters; base-10 is assumed")):16===arguments[0]?my.throwError("BigNumber.toString does not accept any parameters; use bigNumber.toHexString()",hn.errors.UNEXPECTED_ARGUMENT,{}):my.throwError("BigNumber.toString does not accept parameters",hn.errors.UNEXPECTED_ARGUMENT,{})),Sy(this).toString(10)}},{key:"toHexString",value:function(){return this._hex}},{key:"toJSON",value:function(e){return{type:"BigNumber",hex:this.toHexString()}}}],[{key:"from",value:function(t){if(t instanceof e)return t;if("string"===typeof t)return t.match(/^-?0x[0-9a-f]+$/i)?new e(by,xy(t)):t.match(/^-?[0-9]+$/)?new e(by,xy(new yy(t))):my.throwArgumentError("invalid BigNumber string","value",t);if("number"===typeof t)return t%1&&Ay("underflow","BigNumber.from",t),(t>=wy||t<=-wy)&&Ay("overflow","BigNumber.from",t),e.from(String(t));var r=t;if("bigint"===typeof r)return e.from(r.toString());if(mn(r))return e.from(_n(r));if(r)if(r.toHexString){var n=r.toHexString();if("string"===typeof n)return e.from(n)}else{var i=r._hex;if(null==i&&"BigNumber"===r.type&&(i=r.hex),"string"===typeof i&&(En(i)||"-"===i[0]&&En(i.substring(1))))return e.from(i)}return my.throwArgumentError("invalid BigNumber value","value",t)}},{key:"isBigNumber",value:function(e){return!(!e||!e._isBigNumber)}}]),e}();function xy(e){if("string"!==typeof e)return xy(e.toString(16));if("-"===e[0])return"-"===(e=e.substring(1))[0]&&my.throwArgumentError("invalid hex","value",e),"0x00"===(e=xy(e))?e:"-"+e;if("0x"!==e.substring(0,2)&&(e="0x"+e),"0x"===e)return"0x00";for(e.length%2&&(e="0x0"+e.substring(2));e.length>4&&"0x00"===e.substring(0,4);)e="0x"+e.substring(4);return e}function _y(e){return Ey.from(xy(e))}function Sy(e){var t=Ey.from(e).toHexString();return"-"===t[0]?new yy("-"+t.substring(3),16):new yy(t.substring(2),16)}function Ay(e,t,r){var n={fault:e,operation:t};return null!=r&&(n.value=r),my.throwError(e,hn.errors.NUMERIC_FAULT,n)}function Iy(e){return"0x"+tt().keccak_256(bn(e))}var Cy=new hn("address/5.7.0");function Ty(e){En(e,20)||Cy.throwArgumentError("invalid address","address",e);for(var t=(e=e.toLowerCase()).substring(2).split(""),r=new Uint8Array(40),n=0;n<40;n++)r[n]=t[n].charCodeAt(0);for(var i=bn(Iy(r)),o=0;o<40;o+=2)i[o>>1]>>4>=8&&(t[o]=t[o].toUpperCase()),(15&i[o>>1])>=8&&(t[o+1]=t[o+1].toUpperCase());return"0x"+t.join("")}for(var Py={},Ry=0;Ry<10;Ry++)Py[String(Ry)]=String(Ry);for(var By=0;By<26;By++)Py[String.fromCharCode(65+By)]=String(10+By);var My,Ny=Math.floor((My=9007199254740991,Math.log10?Math.log10(My):Math.log(My)/Math.LN10));function Oy(e){for(var t=(e=(e=e.toUpperCase()).substring(4)+e.substring(0,2)+"00").split("").map((function(e){return Py[e]})).join("");t.length>=Ny;){var r=t.substring(0,Ny);t=parseInt(r,10)%97+t.substring(r.length)}for(var n=String(98-parseInt(t,10)%97);n.length<2;)n="0"+n;return n}function Dy(e){var t,r=null;if("string"!==typeof e&&Cy.throwArgumentError("invalid address","address",e),e.match(/^(0x)?[0-9a-fA-F]{40}$/))"0x"!==e.substring(0,2)&&(e="0x"+e),r=Ty(e),e.match(/([A-F].*[a-f])|([a-f].*[A-F])/)&&r!==e&&Cy.throwArgumentError("bad address checksum","address",e);else if(e.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)){for(e.substring(2,4)!==Oy(e)&&Cy.throwArgumentError("bad icap checksum","address",e),t=e.substring(4),r=new yy(t,36).toString(16);r.length<40;)r="0"+r;r=Ty("0x"+r)}else Cy.throwArgumentError("invalid address","address",e);return r}var Ly,Uy,Fy="hash/5.7.0",zy=new hn("strings/5.7.0");function Zy(e,t,r,n,i){if(e===Uy.BAD_PREFIX||e===Uy.UNEXPECTED_CONTINUE){for(var o=0,a=t+1;a>6===2;a++)o++;return o}return e===Uy.OVERRUN?r.length-t-1:0}!function(e){e.current="",e.NFC="NFC",e.NFD="NFD",e.NFKC="NFKC",e.NFKD="NFKD"}(Ly||(Ly={})),function(e){e.UNEXPECTED_CONTINUE="unexpected continuation byte",e.BAD_PREFIX="bad codepoint prefix",e.OVERRUN="string overrun",e.MISSING_CONTINUE="missing continuation byte",e.OUT_OF_RANGE="out of UTF-8 range",e.UTF16_SURROGATE="UTF-16 surrogate",e.OVERLONG="overlong representation"}(Uy||(Uy={}));var jy=Object.freeze({error:function(e,t,r,n,i){return zy.throwArgumentError("invalid codepoint at offset ".concat(t,"; ").concat(e),"bytes",r)},ignore:Zy,replace:function(e,t,r,n,i){return e===Uy.OVERLONG?(n.push(i),0):(n.push(65533),Zy(e,t,r))}});function qy(e,t){null==t&&(t=jy.error),e=bn(e);for(var r=[],n=0;n>7!==0){var o=null,a=null;if(192===(224&i))o=1,a=127;else if(224===(240&i))o=2,a=2047;else{if(240!==(248&i)){n+=t(128===(192&i)?Uy.UNEXPECTED_CONTINUE:Uy.BAD_PREFIX,n-1,e,r);continue}o=3,a=65535}if(n-1+o>=e.length)n+=t(Uy.OVERRUN,n-1,e,r);else{for(var s=i&(1<<8-o-1)-1,u=0;u1114111?n+=t(Uy.OUT_OF_RANGE,n-1-o,e,r,s):s>=55296&&s<=57343?n+=t(Uy.UTF16_SURROGATE,n-1-o,e,r,s):s<=a?n+=t(Uy.OVERLONG,n-1-o,e,r,s):r.push(s))}}else r.push(i)}return r}function Ky(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Ly.current;t!=Ly.current&&(zy.checkNormalize(),e=e.normalize(t));for(var r=[],n=0;n>6|192),r.push(63&i|128);else if(55296==(64512&i)){n++;var o=e.charCodeAt(n);if(n>=e.length||56320!==(64512&o))throw new Error("invalid utf-8 string");var a=65536+((1023&i)<<10)+(1023&o);r.push(a>>18|240),r.push(a>>12&63|128),r.push(a>>6&63|128),r.push(63&a|128)}else r.push(i>>12|224),r.push(i>>6&63|128),r.push(63&i|128)}return bn(r)}function Vy(e,t){return qy(e,t).map((function(e){return e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode(55296+(e>>10&1023),56320+(1023&e)))})).join("")}function Hy(e){return Iy(Ky(e))}var Gy=function(e,t,r,n){return new(r||(r=Promise))((function(i,o){function a(e){try{u(n.next(e))}catch(t){o(t)}}function s(e){try{u(n.throw(e))}catch(t){o(t)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(a,s)}u((n=n.apply(e,t||[])).next())}))},Wy=new hn(Fy),Qy=new Uint8Array(32);Qy.fill(0);var Jy=Ey.from(-1),Yy=Ey.from(0),Xy=Ey.from(1),$y=Ey.from("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");var em=Tn(Xy.toHexString(),32),tm=Tn(Yy.toHexString(),32),rm={name:"string",version:"string",chainId:"uint256",verifyingContract:"address",salt:"bytes32"},nm=["name","version","chainId","verifyingContract","salt"];function im(e){return function(t){return"string"!==typeof t&&Wy.throwArgumentError("invalid domain value for ".concat(JSON.stringify(e)),"domain.".concat(e),t),t}}var om={name:im("name"),version:im("version"),chainId:function(e){try{return Ey.from(e).toString()}catch(t){}return Wy.throwArgumentError('invalid domain value for "chainId"',"domain.chainId",e)},verifyingContract:function(e){try{return Dy(e).toLowerCase()}catch(t){}return Wy.throwArgumentError('invalid domain value "verifyingContract"',"domain.verifyingContract",e)},salt:function(e){try{var t=bn(e);if(32!==t.length)throw new Error("bad length");return _n(t)}catch(r){}return Wy.throwArgumentError('invalid domain value "salt"',"domain.salt",e)}};function am(e){var t=e.match(/^(u?)int(\d*)$/);if(t){var r=""===t[1],n=parseInt(t[2]||"256");(n%8!==0||n>256||t[2]&&t[2]!==String(n))&&Wy.throwArgumentError("invalid numeric width","type",e);var i=$y.mask(r?n-1:n),o=r?i.add(Xy).mul(Jy):Yy;return function(t){var r=Ey.from(t);return(r.lt(o)||r.gt(i))&&Wy.throwArgumentError("value out-of-bounds for ".concat(e),"value",t),Tn(r.toTwos(256).toHexString(),32)}}var a=e.match(/^bytes(\d+)$/);if(a){var s=parseInt(a[1]);return(0===s||s>32||a[1]!==String(s))&&Wy.throwArgumentError("invalid bytes width","type",e),function(t){return bn(t).length!==s&&Wy.throwArgumentError("invalid length for ".concat(e),"value",t),function(e){var t=bn(e),r=t.length%32;return r?In([t,Qy.slice(r)]):_n(t)}(t)}}switch(e){case"address":return function(e){return Tn(Dy(e),32)};case"bool":return function(e){return e?em:tm};case"bytes":return function(e){return Iy(e)};case"string":return function(e){return Hy(e)}}return null}function sm(e,t){return"".concat(e,"(").concat(t.map((function(e){var t=e.name;return e.type+" "+t})).join(","),")")}var um=function(){function e(t){(0,F.Z)(this,e),ey(this,"types",Object.freeze(sy(t))),ey(this,"_encoderCache",{}),ey(this,"_types",{});var r={},n={},i={};Object.keys(t).forEach((function(e){r[e]={},n[e]=[],i[e]={}}));var o=function(e){var i={};t[e].forEach((function(o){i[o.name]&&Wy.throwArgumentError("duplicate variable name ".concat(JSON.stringify(o.name)," in ").concat(JSON.stringify(e)),"types",t),i[o.name]=!0;var a=o.type.match(/^([^\x5b]*)(\x5b|$)/)[1];a===e&&Wy.throwArgumentError("circular type reference to ".concat(JSON.stringify(a)),"types",t),am(a)||(n[a]||Wy.throwArgumentError("unknown type ".concat(JSON.stringify(a)),"types",t),n[a].push(e),r[e][a]=!0)}))};for(var a in t)o(a);var s=Object.keys(n).filter((function(e){return 0===n[e].length}));for(var u in 0===s.length?Wy.throwArgumentError("missing primary type","types",t):s.length>1&&Wy.throwArgumentError("ambiguous primary types or unused types: ".concat(s.map((function(e){return JSON.stringify(e)})).join(", ")),"types",t),ey(this,"primaryType",s[0]),function e(o,a){a[o]&&Wy.throwArgumentError("circular type reference to ".concat(JSON.stringify(o)),"types",t),a[o]=!0,Object.keys(r[o]).forEach((function(t){n[t]&&(e(t,a),Object.keys(a).forEach((function(e){i[e][t]=!0})))})),delete a[o]}(this.primaryType,{}),i){var c=Object.keys(i[u]);c.sort(),this._types[u]=sm(u,t[u])+c.map((function(e){return sm(e,t[e])})).join("")}}return(0,U.Z)(e,[{key:"getEncoder",value:function(e){var t=this._encoderCache[e];return t||(t=this._encoderCache[e]=this._getEncoder(e)),t}},{key:"_getEncoder",value:function(e){var t=this,r=am(e);if(r)return r;var n=e.match(/^(.*)(\x5b(\d*)\x5d)$/);if(n){var i=n[1],o=this.getEncoder(i),a=parseInt(n[3]);return function(e){a>=0&&e.length!==a&&Wy.throwArgumentError("array length mismatch; expected length ${ arrayLength }","value",e);var r=e.map(o);return t._types[i]&&(r=r.map(Iy)),Iy(In(r))}}var s=this.types[e];if(s){var u=Hy(this._types[e]);return function(e){var r=s.map((function(r){var n=r.name,i=r.type,o=t.getEncoder(i)(e[n]);return t._types[i]?Iy(o):o}));return r.unshift(u),In(r)}}return Wy.throwArgumentError("unknown type: ".concat(e),"type",e)}},{key:"encodeType",value:function(e){var t=this._types[e];return t||Wy.throwArgumentError("unknown type: ".concat(JSON.stringify(e)),"name",e),t}},{key:"encodeData",value:function(e,t){return this.getEncoder(e)(t)}},{key:"hashStruct",value:function(e,t){return Iy(this.encodeData(e,t))}},{key:"encode",value:function(e){return this.encodeData(this.primaryType,e)}},{key:"hash",value:function(e){return this.hashStruct(this.primaryType,e)}},{key:"_visit",value:function(e,t,r){var n=this;if(am(e))return r(e,t);var i=e.match(/^(.*)(\x5b(\d*)\x5d)$/);if(i){var o=i[1],a=parseInt(i[3]);return a>=0&&t.length!==a&&Wy.throwArgumentError("array length mismatch; expected length ${ arrayLength }","value",t),t.map((function(e){return n._visit(o,e,r)}))}var s=this.types[e];return s?s.reduce((function(e,i){var o=i.name,a=i.type;return e[o]=n._visit(a,t[o],r),e}),{}):Wy.throwArgumentError("unknown type: ".concat(e),"type",e)}},{key:"visit",value:function(e,t){return this._visit(this.primaryType,e,t)}}],[{key:"from",value:function(t){return new e(t)}},{key:"getPrimaryType",value:function(t){return e.from(t).primaryType}},{key:"hashStruct",value:function(t,r,n){return e.from(r).hashStruct(t,n)}},{key:"hashDomain",value:function(t){var r=[];for(var n in t){var i=rm[n];i||Wy.throwArgumentError("invalid typed-data domain key: ".concat(JSON.stringify(n)),"domain",t),r.push({name:n,type:i})}return r.sort((function(e,t){return nm.indexOf(e.name)-nm.indexOf(t.name)})),e.hashStruct("EIP712Domain",{EIP712Domain:r},t)}},{key:"encode",value:function(t,r,n){return In(["0x1901",e.hashDomain(t),e.from(r).hash(n)])}},{key:"hash",value:function(t,r,n){return Iy(e.encode(t,r,n))}},{key:"resolveNames",value:function(t,r,n,i){return Gy(this,void 0,void 0,(0,_.Z)().mark((function o(){var a,s,u;return(0,_.Z)().wrap((function(o){for(;;)switch(o.prev=o.next){case 0:t=ny(t),a={},t.verifyingContract&&!En(t.verifyingContract,20)&&(a[t.verifyingContract]="0x"),(s=e.from(r)).visit(n,(function(e,t){return"address"!==e||En(t,20)||(a[t]="0x"),t})),o.t0=(0,_.Z)().keys(a);case 6:if((o.t1=o.t0()).done){o.next=13;break}return u=o.t1.value,o.next=10,i(u);case 10:a[u]=o.sent,o.next=6;break;case 13:return t.verifyingContract&&a[t.verifyingContract]&&(t.verifyingContract=a[t.verifyingContract]),n=s.visit(n,(function(e,t){return"address"===e&&a[t]?a[t]:t})),o.abrupt("return",{domain:t,value:n});case 16:case"end":return o.stop()}}),o)})))}},{key:"getPayload",value:function(t,r,n){e.hashDomain(t);var i={},o=[];nm.forEach((function(e){var r=t[e];null!=r&&(i[e]=om[e](r),o.push({name:e,type:rm[e]}))}));var a=e.from(r),s=ny(r);return s.EIP712Domain?Wy.throwArgumentError("types must not contain EIP712Domain type","types.EIP712Domain",r):s.EIP712Domain=o,a.encode(n),{types:s,domain:i,primaryType:a.primaryType,message:a.visit(n,(function(e,t){if(e.match(/^bytes(\d*)/))return _n(bn(t));if(e.match(/^u?int/))return Ey.from(t).toString();switch(e){case"address":return t.toLowerCase();case"bool":return!!t;case"string":return"string"!==typeof t&&Wy.throwArgumentError("invalid string","value",t),t}return Wy.throwArgumentError("unsupported type","type",e)}))}}}]),e}(),cm=Ey.from(0),lm=r(7185),fm=r.n(lm);"undefined"!==typeof globalThis?globalThis:"undefined"!==typeof window?window:"undefined"!==typeof r.g?r.g:"undefined"!==typeof self&&self;function hm(e,t,r){return r={path:t,exports:{},require:function(e,t){return function(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}((void 0===t||null===t)&&r.path)}},e(r,r.exports),r.exports}var dm=pm;function pm(e,t){if(!e)throw new Error(t||"Assertion failed")}pm.equal=function(e,t,r){if(e!=t)throw new Error(r||"Assertion failed: "+e+" != "+t)};var vm=hm((function(e,t){var r=t;function n(e){return 1===e.length?"0"+e:e}function i(e){for(var t="",r=0;r>8,a=255&i;o?r.push(o,a):r.push(a)}return r},r.zero2=n,r.toHex=i,r.encode=function(e,t){return"hex"===t?i(e):e}})),gm=hm((function(e,t){var r=t;r.assert=dm,r.toArray=vm.toArray,r.zero2=vm.zero2,r.toHex=vm.toHex,r.encode=vm.encode,r.getNAF=function(e,t,r){var n=new Array(Math.max(e.bitLength(),r)+1);n.fill(0);for(var i=1<(i>>1)-1?(i>>1)-u:u,o.isubn(s)):s=0,n[a]=s,o.iushrn(1)}return n},r.getJSF=function(e,t){var r=[[],[]];e=e.clone(),t=t.clone();for(var n,i=0,o=0;e.cmpn(-i)>0||t.cmpn(-o)>0;){var a,s,u=e.andln(3)+i&3,c=t.andln(3)+o&3;3===u&&(u=-1),3===c&&(c=-1),a=0===(1&u)?0:3!==(n=e.andln(7)+i&7)&&5!==n||2!==c?u:-u,r[0].push(a),s=0===(1&c)?0:3!==(n=t.andln(7)+o&7)&&5!==n||2!==u?c:-c,r[1].push(s),2*i===a+1&&(i=1-i),2*o===s+1&&(o=1-o),e.iushrn(1),t.iushrn(1)}return r},r.cachedProperty=function(e,t,r){var n="_"+t;e.prototype[t]=function(){return void 0!==this[n]?this[n]:this[n]=r.call(this)}},r.parseBytes=function(e){return"string"===typeof e?r.toArray(e,"hex"):e},r.intFromLE=function(e){return new(gy())(e,"hex","le")}})),ym=gm.getNAF,mm=gm.getJSF,bm=gm.assert;function wm(e,t){this.type=e,this.p=new(gy())(t.p,16),this.red=t.prime?gy().red(t.prime):gy().mont(this.p),this.zero=new(gy())(0).toRed(this.red),this.one=new(gy())(1).toRed(this.red),this.two=new(gy())(2).toRed(this.red),this.n=t.n&&new(gy())(t.n,16),this.g=t.g&&this.pointFromJSON(t.g,t.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4),this._bitLength=this.n?this.n.bitLength():0;var r=this.n&&this.p.div(this.n);!r||r.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}var km=wm;function Em(e,t){this.curve=e,this.type=t,this.precomputed=null}wm.prototype.point=function(){throw new Error("Not implemented")},wm.prototype.validate=function(){throw new Error("Not implemented")},wm.prototype._fixedNafMul=function(e,t){bm(e.precomputed);var r=e._getDoubles(),n=ym(t,1,this._bitLength),i=(1<=o;u--)a=(a<<1)+n[u];s.push(a)}for(var c=this.jpoint(null,null,null),l=this.jpoint(null,null,null),f=i;f>0;f--){for(o=0;o=0;s--){for(var u=0;s>=0&&0===o[s];s--)u++;if(s>=0&&u++,a=a.dblp(u),s<0)break;var c=o[s];bm(0!==c),a="affine"===e.type?c>0?a.mixedAdd(i[c-1>>1]):a.mixedAdd(i[-c-1>>1].neg()):c>0?a.add(i[c-1>>1]):a.add(i[-c-1>>1].neg())}return"affine"===e.type?a.toP():a},wm.prototype._wnafMulAdd=function(e,t,r,n,i){var o,a,s,u=this._wnafT1,c=this._wnafT2,l=this._wnafT3,f=0;for(o=0;o=1;o-=2){var d=o-1,p=o;if(1===u[d]&&1===u[p]){var v=[t[d],null,null,t[p]];0===t[d].y.cmp(t[p].y)?(v[1]=t[d].add(t[p]),v[2]=t[d].toJ().mixedAdd(t[p].neg())):0===t[d].y.cmp(t[p].y.redNeg())?(v[1]=t[d].toJ().mixedAdd(t[p]),v[2]=t[d].add(t[p].neg())):(v[1]=t[d].toJ().mixedAdd(t[p]),v[2]=t[d].toJ().mixedAdd(t[p].neg()));var g=[-3,-1,-5,-7,0,7,5,1,3],y=mm(r[d],r[p]);for(f=Math.max(y[0].length,f),l[d]=new Array(f),l[p]=new Array(f),a=0;a=0;o--){for(var E=0;o>=0;){var x=!0;for(a=0;a=0&&E++,w=w.dblp(E),o<0)break;for(a=0;a0?s=c[a][_-1>>1]:_<0&&(s=c[a][-_-1>>1].neg()),w="affine"===s.type?w.mixedAdd(s):w.add(s))}}for(o=0;o=Math.ceil((e.bitLength()+1)/t.step)},Em.prototype._getDoubles=function(e,t){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var r=[this],n=this,i=0;i=0&&(o=t,a=r),n.negative&&(n=n.neg(),i=i.neg()),o.negative&&(o=o.neg(),a=a.neg()),[{a:n,b:i},{a:o,b:a}]},Sm.prototype._endoSplit=function(e){var t=this.endo.basis,r=t[0],n=t[1],i=n.b.mul(e).divRound(this.n),o=r.b.neg().mul(e).divRound(this.n),a=i.mul(r.a),s=o.mul(n.a),u=i.mul(r.b),c=o.mul(n.b);return{k1:e.sub(a).sub(s),k2:u.add(c).neg()}},Sm.prototype.pointFromX=function(e,t){(e=new(gy())(e,16)).red||(e=e.toRed(this.red));var r=e.redSqr().redMul(e).redIAdd(e.redMul(this.a)).redIAdd(this.b),n=r.redSqrt();if(0!==n.redSqr().redSub(r).cmp(this.zero))throw new Error("invalid point");var i=n.fromRed().isOdd();return(t&&!i||!t&&i)&&(n=n.redNeg()),this.point(e,n)},Sm.prototype.validate=function(e){if(e.inf)return!0;var t=e.x,r=e.y,n=this.a.redMul(t),i=t.redSqr().redMul(t).redIAdd(n).redIAdd(this.b);return 0===r.redSqr().redISub(i).cmpn(0)},Sm.prototype._endoWnafMulAdd=function(e,t,r){for(var n=this._endoWnafT1,i=this._endoWnafT2,o=0;o":""},Im.prototype.isInfinity=function(){return this.inf},Im.prototype.add=function(e){if(this.inf)return e;if(e.inf)return this;if(this.eq(e))return this.dbl();if(this.neg().eq(e))return this.curve.point(null,null);if(0===this.x.cmp(e.x))return this.curve.point(null,null);var t=this.y.redSub(e.y);0!==t.cmpn(0)&&(t=t.redMul(this.x.redSub(e.x).redInvm()));var r=t.redSqr().redISub(this.x).redISub(e.x),n=t.redMul(this.x.redSub(r)).redISub(this.y);return this.curve.point(r,n)},Im.prototype.dbl=function(){if(this.inf)return this;var e=this.y.redAdd(this.y);if(0===e.cmpn(0))return this.curve.point(null,null);var t=this.curve.a,r=this.x.redSqr(),n=e.redInvm(),i=r.redAdd(r).redIAdd(r).redIAdd(t).redMul(n),o=i.redSqr().redISub(this.x.redAdd(this.x)),a=i.redMul(this.x.redSub(o)).redISub(this.y);return this.curve.point(o,a)},Im.prototype.getX=function(){return this.x.fromRed()},Im.prototype.getY=function(){return this.y.fromRed()},Im.prototype.mul=function(e){return e=new(gy())(e,16),this.isInfinity()?this:this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve.endo?this.curve._endoWnafMulAdd([this],[e]):this.curve._wnafMul(this,e)},Im.prototype.mulAdd=function(e,t,r){var n=[this,t],i=[e,r];return this.curve.endo?this.curve._endoWnafMulAdd(n,i):this.curve._wnafMulAdd(1,n,i,2)},Im.prototype.jmulAdd=function(e,t,r){var n=[this,t],i=[e,r];return this.curve.endo?this.curve._endoWnafMulAdd(n,i,!0):this.curve._wnafMulAdd(1,n,i,2,!0)},Im.prototype.eq=function(e){return this===e||this.inf===e.inf&&(this.inf||0===this.x.cmp(e.x)&&0===this.y.cmp(e.y))},Im.prototype.neg=function(e){if(this.inf)return this;var t=this.curve.point(this.x,this.y.redNeg());if(e&&this.precomputed){var r=this.precomputed,n=function(e){return e.neg()};t.precomputed={naf:r.naf&&{wnd:r.naf.wnd,points:r.naf.points.map(n)},doubles:r.doubles&&{step:r.doubles.step,points:r.doubles.points.map(n)}}}return t},Im.prototype.toJ=function(){return this.inf?this.curve.jpoint(null,null,null):this.curve.jpoint(this.x,this.y,this.curve.one)},xm(Cm,km.BasePoint),Sm.prototype.jpoint=function(e,t,r){return new Cm(this,e,t,r)},Cm.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var e=this.z.redInvm(),t=e.redSqr(),r=this.x.redMul(t),n=this.y.redMul(t).redMul(e);return this.curve.point(r,n)},Cm.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},Cm.prototype.add=function(e){if(this.isInfinity())return e;if(e.isInfinity())return this;var t=e.z.redSqr(),r=this.z.redSqr(),n=this.x.redMul(t),i=e.x.redMul(r),o=this.y.redMul(t.redMul(e.z)),a=e.y.redMul(r.redMul(this.z)),s=n.redSub(i),u=o.redSub(a);if(0===s.cmpn(0))return 0!==u.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var c=s.redSqr(),l=c.redMul(s),f=n.redMul(c),h=u.redSqr().redIAdd(l).redISub(f).redISub(f),d=u.redMul(f.redISub(h)).redISub(o.redMul(l)),p=this.z.redMul(e.z).redMul(s);return this.curve.jpoint(h,d,p)},Cm.prototype.mixedAdd=function(e){if(this.isInfinity())return e.toJ();if(e.isInfinity())return this;var t=this.z.redSqr(),r=this.x,n=e.x.redMul(t),i=this.y,o=e.y.redMul(t).redMul(this.z),a=r.redSub(n),s=i.redSub(o);if(0===a.cmpn(0))return 0!==s.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var u=a.redSqr(),c=u.redMul(a),l=r.redMul(u),f=s.redSqr().redIAdd(c).redISub(l).redISub(l),h=s.redMul(l.redISub(f)).redISub(i.redMul(c)),d=this.z.redMul(a);return this.curve.jpoint(f,h,d)},Cm.prototype.dblp=function(e){if(0===e)return this;if(this.isInfinity())return this;if(!e)return this.dbl();var t;if(this.curve.zeroA||this.curve.threeA){var r=this;for(t=0;t=0)return!1;if(r.redIAdd(i),0===this.x.cmp(r))return!0}},Cm.prototype.inspect=function(){return this.isInfinity()?"":""},Cm.prototype.isInfinity=function(){return 0===this.z.cmpn(0)};var Tm=hm((function(e,t){var r=t;r.base=km,r.short=Am,r.mont=null,r.edwards=null})),Pm=hm((function(e,t){var r,n=t,i=gm.assert;function o(e){"short"===e.type?this.curve=new Tm.short(e):"edwards"===e.type?this.curve=new Tm.edwards(e):this.curve=new Tm.mont(e),this.g=this.curve.g,this.n=this.curve.n,this.hash=e.hash,i(this.g.validate(),"Invalid curve"),i(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}function a(e,t){Object.defineProperty(n,e,{configurable:!0,enumerable:!0,get:function(){var r=new o(t);return Object.defineProperty(n,e,{configurable:!0,enumerable:!0,value:r}),r}})}n.PresetCurve=o,a("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:fm().sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),a("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:fm().sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),a("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:fm().sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),a("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:fm().sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),a("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:fm().sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),a("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:fm().sha256,gRed:!1,g:["9"]}),a("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:fm().sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});try{r=null.crash()}catch(s){r=void 0}a("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:fm().sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",r]})}));function Rm(e){if(!(this instanceof Rm))return new Rm(e);this.hash=e.hash,this.predResist=!!e.predResist,this.outLen=this.hash.outSize,this.minEntropy=e.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var t=vm.toArray(e.entropy,e.entropyEnc||"hex"),r=vm.toArray(e.nonce,e.nonceEnc||"hex"),n=vm.toArray(e.pers,e.persEnc||"hex");dm(t.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(t,r,n)}var Bm=Rm;Rm.prototype._init=function(e,t,r){var n=e.concat(t).concat(r);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var i=0;i=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(e.concat(r||[])),this._reseed=1},Rm.prototype.generate=function(e,t,r,n){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");"string"!==typeof t&&(n=r,r=t,t=null),r&&(r=vm.toArray(r,n||"hex"),this._update(r));for(var i=[];i.length"};var Dm=gm.assert;function Lm(e,t){if(e instanceof Lm)return e;this._importDER(e,t)||(Dm(e.r&&e.s,"Signature without r or s"),this.r=new(gy())(e.r,16),this.s=new(gy())(e.s,16),void 0===e.recoveryParam?this.recoveryParam=null:this.recoveryParam=e.recoveryParam)}var Um=Lm;function Fm(){this.place=0}function zm(e,t){var r=e[t.place++];if(!(128&r))return r;var n=15&r;if(0===n||n>4)return!1;for(var i=0,o=0,a=t.place;o>>=0;return!(i<=127)&&(t.place=a,i)}function Zm(e){for(var t=0,r=e.length-1;!e[t]&&!(128&e[t+1])&&t>>3);for(e.push(128|r);--r;)e.push(t>>>(r<<3)&255);e.push(t)}}Lm.prototype._importDER=function(e,t){e=gm.toArray(e,t);var r=new Fm;if(48!==e[r.place++])return!1;var n=zm(e,r);if(!1===n)return!1;if(n+r.place!==e.length)return!1;if(2!==e[r.place++])return!1;var i=zm(e,r);if(!1===i)return!1;var o=e.slice(r.place,i+r.place);if(r.place+=i,2!==e[r.place++])return!1;var a=zm(e,r);if(!1===a)return!1;if(e.length!==a+r.place)return!1;var s=e.slice(r.place,a+r.place);if(0===o[0]){if(!(128&o[1]))return!1;o=o.slice(1)}if(0===s[0]){if(!(128&s[1]))return!1;s=s.slice(1)}return this.r=new(gy())(o),this.s=new(gy())(s),this.recoveryParam=null,!0},Lm.prototype.toDER=function(e){var t=this.r.toArray(),r=this.s.toArray();for(128&t[0]&&(t=[0].concat(t)),128&r[0]&&(r=[0].concat(r)),t=Zm(t),r=Zm(r);!r[0]&&!(128&r[1]);)r=r.slice(1);var n=[2];jm(n,t.length),(n=n.concat(t)).push(2),jm(n,r.length);var i=n.concat(r),o=[48];return jm(o,i.length),o=o.concat(i),gm.encode(o,e)};var qm=function(){throw new Error("unsupported")},Km=gm.assert;function Vm(e){if(!(this instanceof Vm))return new Vm(e);"string"===typeof e&&(Km(Object.prototype.hasOwnProperty.call(Pm,e),"Unknown curve "+e),e=Pm[e]),e instanceof Pm.PresetCurve&&(e={curve:e}),this.curve=e.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=e.curve.g,this.g.precompute(e.curve.n.bitLength()+1),this.hash=e.hash||e.curve.hash}var Hm=Vm;Vm.prototype.keyPair=function(e){return new Om(this,e)},Vm.prototype.keyFromPrivate=function(e,t){return Om.fromPrivate(this,e,t)},Vm.prototype.keyFromPublic=function(e,t){return Om.fromPublic(this,e,t)},Vm.prototype.genKeyPair=function(e){e||(e={});for(var t=new Bm({hash:this.hash,pers:e.pers,persEnc:e.persEnc||"utf8",entropy:e.entropy||qm(this.hash.hmacStrength),entropyEnc:e.entropy&&e.entropyEnc||"utf8",nonce:this.n.toArray()}),r=this.n.byteLength(),n=this.n.sub(new(gy())(2));;){var i=new(gy())(t.generate(r));if(!(i.cmp(n)>0))return i.iaddn(1),this.keyFromPrivate(i)}},Vm.prototype._truncateToN=function(e,t){var r=8*e.byteLength()-this.n.bitLength();return r>0&&(e=e.ushrn(r)),!t&&e.cmp(this.n)>=0?e.sub(this.n):e},Vm.prototype.sign=function(e,t,r,n){"object"===typeof r&&(n=r,r=null),n||(n={}),t=this.keyFromPrivate(t,r),e=this._truncateToN(new(gy())(e,16));for(var i=this.n.byteLength(),o=t.getPrivate().toArray("be",i),a=e.toArray("be",i),s=new Bm({hash:this.hash,entropy:o,nonce:a,pers:n.pers,persEnc:n.persEnc||"utf8"}),u=this.n.sub(new(gy())(1)),c=0;;c++){var l=n.k?n.k(c):new(gy())(s.generate(this.n.byteLength()));if(!((l=this._truncateToN(l,!0)).cmpn(1)<=0||l.cmp(u)>=0)){var f=this.g.mul(l);if(!f.isInfinity()){var h=f.getX(),d=h.umod(this.n);if(0!==d.cmpn(0)){var p=l.invm(this.n).mul(d.mul(t.getPrivate()).iadd(e));if(0!==(p=p.umod(this.n)).cmpn(0)){var v=(f.getY().isOdd()?1:0)|(0!==h.cmp(d)?2:0);return n.canonical&&p.cmp(this.nh)>0&&(p=this.n.sub(p),v^=1),new Um({r:d,s:p,recoveryParam:v})}}}}}},Vm.prototype.verify=function(e,t,r,n){e=this._truncateToN(new(gy())(e,16)),r=this.keyFromPublic(r,n);var i=(t=new Um(t,"hex")).r,o=t.s;if(i.cmpn(1)<0||i.cmp(this.n)>=0)return!1;if(o.cmpn(1)<0||o.cmp(this.n)>=0)return!1;var a,s=o.invm(this.n),u=s.mul(e).umod(this.n),c=s.mul(i).umod(this.n);return this.curve._maxwellTrick?!(a=this.g.jmulAdd(u,r.getPublic(),c)).isInfinity()&&a.eqXToP(i):!(a=this.g.mulAdd(u,r.getPublic(),c)).isInfinity()&&0===a.getX().umod(this.n).cmp(i)},Vm.prototype.recoverPubKey=function(e,t,r,n){Km((3&r)===r,"The recovery param is more than two bits"),t=new Um(t,n);var i=this.n,o=new(gy())(e),a=t.r,s=t.s,u=1&r,c=r>>1;if(a.cmp(this.curve.p.umod(this.curve.n))>=0&&c)throw new Error("Unable to find sencond key candinate");a=c?this.curve.pointFromX(a.add(this.curve.n),u):this.curve.pointFromX(a,u);var l=t.r.invm(i),f=i.sub(o).mul(l).umod(i),h=s.mul(l).umod(i);return this.g.mulAdd(f,a,h)},Vm.prototype.getKeyRecoveryParam=function(e,t,r,n){if(null!==(t=new Um(t,n)).recoveryParam)return t.recoveryParam;for(var i=0;i<4;i++){var o;try{o=this.recoverPubKey(e,t,i)}catch(e){continue}if(o.eq(r))return i}throw new Error("Unable to find valid recovery factor")};var Gm=hm((function(e,t){var r=t;r.version="6.5.4",r.utils=gm,r.rand=function(){throw new Error("unsupported")},r.curve=Tm,r.curves=Pm,r.ec=Hm,r.eddsa=null})).ec,Wm=new hn("signing-key/5.7.0"),Qm=null;function Jm(){return Qm||(Qm=new Gm("secp256k1")),Qm}var Ym=function(){function e(t){(0,F.Z)(this,e),ey(this,"curve","secp256k1"),ey(this,"privateKey",_n(t)),32!==Sn(this.privateKey)&&Wm.throwArgumentError("invalid private key","privateKey","[[ REDACTED ]]");var r=Jm().keyFromPrivate(bn(this.privateKey));ey(this,"publicKey","0x"+r.getPublic(!1,"hex")),ey(this,"compressedPublicKey","0x"+r.getPublic(!0,"hex")),ey(this,"_isSigningKey",!0)}return(0,U.Z)(e,[{key:"_addPoint",value:function(e){var t=Jm().keyFromPublic(bn(this.publicKey)),r=Jm().keyFromPublic(bn(e));return"0x"+t.pub.add(r.pub).encodeCompressed("hex")}},{key:"signDigest",value:function(e){var t=Jm().keyFromPrivate(bn(this.privateKey)),r=bn(e);32!==r.length&&Wm.throwArgumentError("bad digest length","digest",e);var n=t.sign(r,{canonical:!0});return Pn({recoveryParam:n.recoveryParam,r:Tn("0x"+n.r.toString(16),32),s:Tn("0x"+n.s.toString(16),32)})}},{key:"computeSharedSecret",value:function(e){var t=Jm().keyFromPrivate(bn(this.privateKey)),r=Jm().keyFromPublic(bn(Xm(e)));return Tn("0x"+t.derive(r.getPublic()).toString(16),32)}}],[{key:"isSigningKey",value:function(e){return!(!e||!e._isSigningKey)}}]),e}();function Xm(e,t){var r=bn(e);if(32===r.length){var n=new Ym(r);return t?"0x"+Jm().keyFromPrivate(r).getPublic(!0,"hex"):n.publicKey}return 33===r.length?t?_n(r):"0x"+Jm().keyFromPublic(r).getPublic(!1,"hex"):65===r.length?t?"0x"+Jm().keyFromPublic(r).getPublic(!0,"hex"):_n(r):Wm.throwArgumentError("invalid public or private key","key","[REDACTED]")}var $m,eb=new hn("transactions/5.7.0");function tb(e){return"0x"===e?null:Dy(e)}function rb(e){return"0x"===e?cm:Ey.from(e)}!function(e){e[e.legacy=0]="legacy",e[e.eip2930=1]="eip2930",e[e.eip1559=2]="eip1559"}($m||($m={}));function nb(e,t){return function(e){return Dy(An(Iy(An(Xm(e),1)),12))}(function(e,t){var r=Pn(t),n={r:bn(r.r),s:bn(r.s)};return"0x"+Jm().recoverPubKey(bn(e),n,r.recoveryParam).encode("hex",!1)}(bn(e),t))}function ib(e,t){var r=kn(Ey.from(e).toHexString());return r.length>32&&eb.throwArgumentError("invalid length for "+t,"transaction:"+t,e),r}function ob(e,t){return{address:Dy(e),storageKeys:(t||[]).map((function(t,r){return 32!==Sn(t)&&eb.throwArgumentError("invalid access list storageKey","accessList[".concat(e,":").concat(r,"]"),t),t.toLowerCase()}))}}function ab(e){if(Array.isArray(e))return e.map((function(e,t){return Array.isArray(e)?(e.length>2&&eb.throwArgumentError("access list expected to be [ address, storageKeys[] ]","value[".concat(t,"]"),e),ob(e[0],e[1])):ob(e.address,e.storageKeys)}));var t=Object.keys(e).map((function(t){var r=e[t].reduce((function(e,t){return e[t]=!0,e}),{});return ob(t,Object.keys(r).sort())}));return t.sort((function(e,t){return e.address.localeCompare(t.address)})),t}function sb(e){return ab(e).map((function(e){return[e.address,e.storageKeys]}))}function ub(e,t){if(null!=e.gasPrice){var r=Ey.from(e.gasPrice),n=Ey.from(e.maxFeePerGas||0);r.eq(n)||eb.throwArgumentError("mismatch EIP-1559 gasPrice != maxFeePerGas","tx",{gasPrice:r,maxFeePerGas:n})}var i=[ib(e.chainId||0,"chainId"),ib(e.nonce||0,"nonce"),ib(e.maxPriorityFeePerGas||0,"maxPriorityFeePerGas"),ib(e.maxFeePerGas||0,"maxFeePerGas"),ib(e.gasLimit||0,"gasLimit"),null!=e.to?Dy(e.to):"0x",ib(e.value||0,"value"),e.data||"0x",sb(e.accessList||[])];if(t){var o=Pn(t);i.push(ib(o.recoveryParam,"recoveryParam")),i.push(kn(o.r)),i.push(kn(o.s))}return In(["0x02",On(i)])}function cb(e,t){var r=[ib(e.chainId||0,"chainId"),ib(e.nonce||0,"nonce"),ib(e.gasPrice||0,"gasPrice"),ib(e.gasLimit||0,"gasLimit"),null!=e.to?Dy(e.to):"0x",ib(e.value||0,"value"),e.data||"0x",sb(e.accessList||[])];if(t){var n=Pn(t);r.push(ib(n.recoveryParam,"recoveryParam")),r.push(kn(n.r)),r.push(kn(n.s))}return In(["0x01",On(r)])}function lb(e,t,r){try{var n=rb(t[0]).toNumber();if(0!==n&&1!==n)throw new Error("bad recid");e.v=n}catch(o){eb.throwArgumentError("invalid v for transaction type: 1","v",t[0])}e.r=Tn(t[1],32),e.s=Tn(t[2],32);try{var i=Iy(r(e));e.from=nb(i,{r:e.r,s:e.s,recoveryParam:e.v})}catch(o){}}function fb(e){var t=bn(e);if(t[0]>127)return function(e){var t=Un(e);9!==t.length&&6!==t.length&&eb.throwArgumentError("invalid raw transaction","rawTransaction",e);var r={nonce:rb(t[0]).toNumber(),gasPrice:rb(t[1]),gasLimit:rb(t[2]),to:tb(t[3]),value:rb(t[4]),data:t[5],chainId:0};if(6===t.length)return r;try{r.v=Ey.from(t[6]).toNumber()}catch(a){return r}if(r.r=Tn(t[7],32),r.s=Tn(t[8],32),Ey.from(r.r).isZero()&&Ey.from(r.s).isZero())r.chainId=r.v,r.v=0;else{r.chainId=Math.floor((r.v-35)/2),r.chainId<0&&(r.chainId=0);var n=r.v-27,i=t.slice(0,6);0!==r.chainId&&(i.push(_n(r.chainId)),i.push("0x"),i.push("0x"),n-=2*r.chainId+8);var o=Iy(On(i));try{r.from=nb(o,{r:_n(r.r),s:_n(r.s),recoveryParam:n})}catch(a){}r.hash=Iy(e)}return r.type=null,r}(t);switch(t[0]){case 1:return function(e){var t=Un(e.slice(1));8!==t.length&&11!==t.length&&eb.throwArgumentError("invalid component count for transaction type: 1","payload",_n(e));var r={type:1,chainId:rb(t[0]).toNumber(),nonce:rb(t[1]).toNumber(),gasPrice:rb(t[2]),gasLimit:rb(t[3]),to:tb(t[4]),value:rb(t[5]),data:t[6],accessList:ab(t[7])};return 8===t.length||(r.hash=Iy(e),lb(r,t.slice(8),cb)),r}(t);case 2:return function(e){var t=Un(e.slice(1));9!==t.length&&12!==t.length&&eb.throwArgumentError("invalid component count for transaction type: 2","payload",_n(e));var r=rb(t[2]),n=rb(t[3]),i={type:2,chainId:rb(t[0]).toNumber(),nonce:rb(t[1]).toNumber(),maxPriorityFeePerGas:r,maxFeePerGas:n,gasPrice:null,gasLimit:rb(t[4]),to:tb(t[5]),value:rb(t[6]),data:t[7],accessList:ab(t[8])};return 9===t.length||(i.hash=Iy(e),lb(i,t.slice(9),ub)),i}(t)}return eb.throwError("unsupported transaction type: ".concat(t[0]),hn.errors.UNSUPPORTED_OPERATION,{operation:"parseTransaction",transactionType:t[0]})}function hb(e){e=atob(e);for(var t=[],r=0;r0&&n%1===0,"invalid connection throttle limit","connection.throttleLimit",n);var i="object"===typeof e?e.throttleCallback:null,o="object"===typeof e&&"number"===typeof e.throttleSlotInterval?e.throttleSlotInterval:100;yb.assertArgument(o>0&&o%1===0,"invalid connection throttle slot interval","connection.throttleSlotInterval",o);var a="object"===typeof e&&!!e.errorPassThrough,s={},u=null,c={method:"GET"},l=!1,f=12e4;if("string"===typeof e)u=e;else if("object"===typeof e){if(null!=e&&null!=e.url||yb.throwArgumentError("missing URL","connection.url",e),u=e.url,"number"===typeof e.timeout&&e.timeout>0&&(f=e.timeout),e.headers)for(var h in e.headers)s[h.toLowerCase()]={key:h,value:String(e.headers[h])},["if-none-match","if-modified-since"].indexOf(h.toLowerCase())>=0&&(l=!0);if(c.allowGzip=!!e.allowGzip,null!=e.user&&null!=e.password){"https:"!==u.substring(0,6)&&!0!==e.allowInsecureAuthentication&&yb.throwError("basic authentication requires a secure https url",hn.errors.INVALID_ARGUMENT,{argument:"url",url:u,user:e.user,password:"[REDACTED]"});var d=e.user+":"+e.password;s.authorization={key:"Authorization",value:"Basic "+db(Ky(d))}}null!=e.skipFetchSetup&&(c.skipFetchSetup=!!e.skipFetchSetup),null!=e.fetchOptions&&(c.fetchOptions=ny(e.fetchOptions))}var p,v=new RegExp("^data:([^;:]*)?(;base64)?,(.*)$","i"),g=u?u.match(v):null;if(g)try{var y={statusCode:200,statusMessage:"OK",headers:{"content-type":g[1]||"text/plain"},body:g[2]?hb(g[3]):(p=g[3],Ky(p.replace(/%([0-9a-f][0-9a-f])/gi,(function(e,t){return String.fromCharCode(parseInt(t,16))}))))},m=y.body;return r&&(m=r(y.body,y)),Promise.resolve(m)}catch(E){yb.throwError("processing response error",hn.errors.SERVER_ERROR,{body:bb(g[1],g[2]),error:E,requestBody:null,requestMethod:"GET",url:u})}t&&(c.method="POST",c.body=t,null==s["content-type"]&&(s["content-type"]={key:"Content-Type",value:"application/octet-stream"}),null==s["content-length"]&&(s["content-length"]={key:"Content-Length",value:String(t.length)}));var b={};Object.keys(s).forEach((function(e){var t=s[e];b[t.key]=t.value})),c.headers=b;var w=function(){var e=null;return{promise:new Promise((function(t,r){f&&(e=setTimeout((function(){null!=e&&(e=null,r(yb.makeError("timeout",hn.errors.TIMEOUT,{requestBody:bb(c.body,b["content-type"]),requestMethod:c.method,timeout:f,url:u})))}),f))})),cancel:function(){null!=e&&(clearTimeout(e),e=null)}}}(),k=function(){return gb(this,void 0,void 0,(0,_.Z)().mark((function e(){var t,s,f,h,d,p,v,g,y,m;return(0,_.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=0;case 1:if(!(t=300)&&(w.cancel(),yb.throwError("bad response",hn.errors.SERVER_ERROR,{status:s.statusCode,headers:s.headers,body:bb(v,s.headers?s.headers["content-type"]:null),requestBody:bb(c.body,b["content-type"]),requestMethod:c.method,url:u})),!r){e.next=60;break}return e.prev=37,e.next=40,r(v,s);case 40:return g=e.sent,w.cancel(),e.abrupt("return",g);case 45:if(e.prev=45,e.t1=e.catch(37),!(e.t1.throttleRetry&&ts)return void(a()&&n(new Error("retry limit reached")));var c=t.interval*parseInt(String(Math.random()*Math.pow(2,u)));ct.ceiling&&(c=t.ceiling),setTimeout(i,c)}return null}),(function(e){a()&&n(e)}))}()}))}var Eb=function(e,t,r,n){return new(r||(r=Promise))((function(i,o){function a(e){try{u(n.next(e))}catch(t){o(t)}}function s(e){try{u(n.throw(e))}catch(t){o(t)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(a,s)}u((n=n.apply(e,t||[])).next())}))},xb=new hn("abstract-provider/5.7.0"),_b=function(e){Z(r,e);var t=G(r);function r(){return(0,F.Z)(this,r),t.apply(this,arguments)}return(0,U.Z)(r,null,[{key:"isForkEvent",value:function(e){return!(!e||!e._isForkEvent)}}]),r}(uy),Sb=function(){function e(){(0,F.Z)(this,e),xb.checkAbstract(this instanceof e?this.constructor:void 0,e),ey(this,"_isProvider",!0)}return(0,U.Z)(e,[{key:"getFeeData",value:function(){return Eb(this,void 0,void 0,(0,_.Z)().mark((function e(){var t,r,n,i,o,a;return(0,_.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,ry({block:this.getBlock("latest"),gasPrice:this.getGasPrice().catch((function(e){return null}))});case 2:return t=e.sent,r=t.block,n=t.gasPrice,i=null,o=null,a=null,r&&r.baseFeePerGas&&(i=r.baseFeePerGas,a=Ey.from("1500000000"),o=r.baseFeePerGas.mul(2).add(a)),e.abrupt("return",{lastBaseFeePerGas:i,maxFeePerGas:o,maxPriorityFeePerGas:a,gasPrice:n});case 8:case"end":return e.stop()}}),e,this)})))}},{key:"addListener",value:function(e,t){return this.on(e,t)}},{key:"removeListener",value:function(e,t){return this.off(e,t)}}],[{key:"isProvider",value:function(e){return!(!e||!e._isProvider)}}]),e}(),Ab=function(){function e(t){(0,F.Z)(this,e),ey(this,"alphabet",t),ey(this,"base",t.length),ey(this,"_alphabetMap",{}),ey(this,"_leader",t.charAt(0));for(var r=0;r0;)r.push(i%this.base),i=i/this.base|0}for(var a="",s=0;0===t[s]&&s=0;--u)a+=this.alphabet[r[u]];return a}},{key:"decode",value:function(e){if("string"!==typeof e)throw new TypeError("Expected String");var t=[];if(0===e.length)return new Uint8Array(t);t.push(0);for(var r=0;r>=8;for(;i>0;)t.push(255&i),i>>=8}for(var a=0;e[a]===this._leader&&a0&&Array.isArray(t)?e(t,i-1):r.push(t)}))}(e,t),r}function Tb(e){return function(e){var t=0;return function(){return e[t++]}}(function(e){var t=0;function r(){return e[t++]<<8|e[t++]}for(var n=r(),i=1,o=[0,1],a=1;a>--c&1}for(var h=Math.pow(2,31),d=h>>>1,p=d>>1,v=h-1,g=0,y=0;y<31;y++)g=g<<1|f();for(var m=[],b=0,w=h;;){for(var k=Math.floor(((g-b+1)*i-1)/w),E=0,x=n;x-E>1;){var _=E+x>>>1;k>>1|f(),S=S<<1^d,A=(A^d)<<1|d|1;b=S,w=1+A-S}var I=n-4;return m.map((function(t){switch(t-I){case 3:return I+65792+(e[u++]<<16|e[u++]<<8|e[u++]);case 2:return I+256+(e[u++]<<8|e[u++]);case 1:return I+e[u++];default:return t-1}}))}(e))}function Pb(e){return 1&e?~e>>1:e>>1}function Rb(e,t){for(var r=Array(e),n=0,i=-1;n>=1),check:2==o}}()}(Lb);function jb(e){return function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Ly.current;return qy(Ky(e,t))}(e)}function qb(e){return e.filter((function(e){return 65039!=e}))}function Kb(e){var t,r=rt(e.split("."));try{for(r.s();!(t=r.n()).done;){var n=t.value,i=jb(n);try{for(var o=i.lastIndexOf(95)-1;o>=0;o--)if(95!==i[o])throw new Error("underscore only allowed at start");if(i.length>=4&&i.every((function(e){return e<128}))&&45===i[2]&&45===i[3])throw new Error("invalid label extension")}catch(a){throw new Error('Invalid label "'.concat(n,'": ').concat(a.message))}}}catch(a){r.e(a)}finally{r.f()}return e}function Vb(e){return Kb(function(e,t){var r=jb(e).reverse(),n=[];for(;r.length;){var i=Hb(r);if(i)n.push.apply(n,$r(t(i)));else{var o=r.pop();if(Ub.has(o))n.push(o);else if(!Fb.has(o)){var a=zb[o];if(!a)throw new Error("Disallowed codepoint: 0x".concat(o.toString(16).toUpperCase()));n.push.apply(n,$r(a))}}}return Kb((s=String.fromCodePoint.apply(String,n),s.normalize("NFC")));var s}(e,qb))}function Hb(e,t){var r,n,i,o=Zb,a=[],s=e.length;t&&(t.length=0);for(var u=function(){var u=e[--s];if(o=null===(r=o.branches.find((function(e){return e.set.has(u)})))||void 0===r?void 0:r.node,!o)return"break";if(o.save)i=u;else if(o.check&&u===i)return"break";a.push(u),o.fe0f&&(a.push(65039),s>0&&65039==e[s-1]&&s--),o.valid&&(n=a.slice(),2==o.valid&&n.splice(1,1),t&&t.push.apply(t,$r(e.slice(s).reverse())),e.length=s)};s;){if("break"===u())break}return n}var Gb=new hn(Fy),Wb=new Uint8Array(32);function Qb(e){if(0===e.length)throw new Error("invalid ENS name; empty component");return e}function Jb(e){var t=Ky(Vb(e)),r=[];if(0===e.length)return r;for(var n=0,i=0;i=t.length)throw new Error("invalid ENS name; empty component");return r.push(Qb(t.slice(n))),r}function Yb(e){"string"!==typeof e&&Gb.throwArgumentError("invalid ENS name; not a string","name",e);for(var t=Wb,r=Jb(e);r.length;)t=Iy(wn([t,Iy(r.pop())]));return _n(t)}Wb.fill(0);var Xb=new hn("networks/5.7.1");function $b(e){var t=function(t,r){null==r&&(r={});var n=[];if(t.InfuraProvider&&"-"!==r.infura)try{n.push(new t.InfuraProvider(e,r.infura))}catch(s){}if(t.EtherscanProvider&&"-"!==r.etherscan)try{n.push(new t.EtherscanProvider(e,r.etherscan))}catch(s){}if(t.AlchemyProvider&&"-"!==r.alchemy)try{n.push(new t.AlchemyProvider(e,r.alchemy))}catch(s){}if(t.PocketProvider&&"-"!==r.pocket){try{var i=new t.PocketProvider(e,r.pocket);i.network&&-1===["goerli","ropsten","rinkeby","sepolia"].indexOf(i.network.name)&&n.push(i)}catch(s){}}if(t.CloudflareProvider&&"-"!==r.cloudflare)try{n.push(new t.CloudflareProvider(e))}catch(s){}if(t.AnkrProvider&&"-"!==r.ankr)try{var o=new t.AnkrProvider(e,r.ankr);o.network&&-1===["ropsten"].indexOf(o.network.name)&&n.push(o)}catch(s){}if(0===n.length)return null;if(t.FallbackProvider){var a=1;return null!=r.quorum?a=r.quorum:"homestead"===e&&(a=2),new t.FallbackProvider(n,a)}return n[0]};return t.renetwork=function(e){return $b(e)},t}function ew(e,t){var r=function(r,n){return r.JsonRpcProvider?new r.JsonRpcProvider(e,t):null};return r.renetwork=function(t){return ew(e,t)},r}var tw={chainId:1,ensAddress:"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",name:"homestead",_defaultProvider:$b("homestead")},rw={chainId:3,ensAddress:"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",name:"ropsten",_defaultProvider:$b("ropsten")},nw={chainId:63,name:"classicMordor",_defaultProvider:ew("https://www.ethercluster.com/mordor","classicMordor")},iw={unspecified:{chainId:0,name:"unspecified"},homestead:tw,mainnet:tw,morden:{chainId:2,name:"morden"},ropsten:rw,testnet:rw,rinkeby:{chainId:4,ensAddress:"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",name:"rinkeby",_defaultProvider:$b("rinkeby")},kovan:{chainId:42,name:"kovan",_defaultProvider:$b("kovan")},goerli:{chainId:5,ensAddress:"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",name:"goerli",_defaultProvider:$b("goerli")},kintsugi:{chainId:1337702,name:"kintsugi"},sepolia:{chainId:11155111,name:"sepolia",_defaultProvider:$b("sepolia")},classic:{chainId:61,name:"classic",_defaultProvider:ew("https://www.ethercluster.com/etc","classic")},classicMorden:{chainId:62,name:"classicMorden"},classicMordor:nw,classicTestnet:nw,classicKotti:{chainId:6,name:"classicKotti",_defaultProvider:ew("https://www.ethercluster.com/kotti","classicKotti")},xdai:{chainId:100,name:"xdai"},matic:{chainId:137,name:"matic",_defaultProvider:$b("matic")},maticmum:{chainId:80001,name:"maticmum"},optimism:{chainId:10,name:"optimism",_defaultProvider:$b("optimism")},"optimism-kovan":{chainId:69,name:"optimism-kovan"},"optimism-goerli":{chainId:420,name:"optimism-goerli"},arbitrum:{chainId:42161,name:"arbitrum"},"arbitrum-rinkeby":{chainId:421611,name:"arbitrum-rinkeby"},"arbitrum-goerli":{chainId:421613,name:"arbitrum-goerli"},bnb:{chainId:56,name:"bnb"},bnbt:{chainId:97,name:"bnbt"}};new hn("sha2/5.7.0");function ow(e){return"0x"+fm().sha256().update(bn(e)).digest("hex")}var aw=r(2571),sw=r.n(aw),uw=new hn(cy),cw=function(){function e(){(0,F.Z)(this,e),this.formats=this.getDefaultFormats()}return(0,U.Z)(e,[{key:"getDefaultFormats",value:function(){var t=this,r={},n=this.address.bind(this),i=this.bigNumber.bind(this),o=this.blockTag.bind(this),a=this.data.bind(this),s=this.hash.bind(this),u=this.hex.bind(this),c=this.number.bind(this),l=this.type.bind(this);return r.transaction={hash:s,type:l,accessList:e.allowNull(this.accessList.bind(this),null),blockHash:e.allowNull(s,null),blockNumber:e.allowNull(c,null),transactionIndex:e.allowNull(c,null),confirmations:e.allowNull(c,null),from:n,gasPrice:e.allowNull(i),maxPriorityFeePerGas:e.allowNull(i),maxFeePerGas:e.allowNull(i),gasLimit:i,to:e.allowNull(n,null),value:i,nonce:c,data:a,r:e.allowNull(this.uint256),s:e.allowNull(this.uint256),v:e.allowNull(c),creates:e.allowNull(n,null),raw:e.allowNull(a)},r.transactionRequest={from:e.allowNull(n),nonce:e.allowNull(c),gasLimit:e.allowNull(i),gasPrice:e.allowNull(i),maxPriorityFeePerGas:e.allowNull(i),maxFeePerGas:e.allowNull(i),to:e.allowNull(n),value:e.allowNull(i),data:e.allowNull((function(e){return t.data(e,!0)})),type:e.allowNull(c),accessList:e.allowNull(this.accessList.bind(this),null)},r.receiptLog={transactionIndex:c,blockNumber:c,transactionHash:s,address:n,topics:e.arrayOf(s),data:a,logIndex:c,blockHash:s},r.receipt={to:e.allowNull(this.address,null),from:e.allowNull(this.address,null),contractAddress:e.allowNull(n,null),transactionIndex:c,root:e.allowNull(u),gasUsed:i,logsBloom:e.allowNull(a),blockHash:s,transactionHash:s,logs:e.arrayOf(this.receiptLog.bind(this)),blockNumber:c,confirmations:e.allowNull(c,null),cumulativeGasUsed:i,effectiveGasPrice:e.allowNull(i),status:e.allowNull(c),type:l},r.block={hash:e.allowNull(s),parentHash:s,number:c,timestamp:c,nonce:e.allowNull(u),difficulty:this.difficulty.bind(this),gasLimit:i,gasUsed:i,miner:e.allowNull(n),extraData:a,transactions:e.allowNull(e.arrayOf(s)),baseFeePerGas:e.allowNull(i)},r.blockWithTransactions=ny(r.block),r.blockWithTransactions.transactions=e.allowNull(e.arrayOf(this.transactionResponse.bind(this))),r.filter={fromBlock:e.allowNull(o,void 0),toBlock:e.allowNull(o,void 0),blockHash:e.allowNull(s,void 0),address:e.allowNull(n,void 0),topics:e.allowNull(this.topics.bind(this),void 0)},r.filterLog={blockNumber:e.allowNull(c),blockHash:e.allowNull(s),transactionIndex:c,removed:e.allowNull(this.boolean.bind(this)),address:n,data:e.allowFalsish(a,"0x"),topics:e.arrayOf(s),transactionHash:s,logIndex:c},r}},{key:"accessList",value:function(e){return ab(e||[])}},{key:"number",value:function(e){return"0x"===e?0:Ey.from(e).toNumber()}},{key:"type",value:function(e){return"0x"===e||null==e?0:Ey.from(e).toNumber()}},{key:"bigNumber",value:function(e){return Ey.from(e)}},{key:"boolean",value:function(e){if("boolean"===typeof e)return e;if("string"===typeof e){if("true"===(e=e.toLowerCase()))return!0;if("false"===e)return!1}throw new Error("invalid boolean - "+e)}},{key:"hex",value:function(e,t){return"string"===typeof e&&(t||"0x"===e.substring(0,2)||(e="0x"+e),En(e))?e.toLowerCase():uw.throwArgumentError("invalid hash","value",e)}},{key:"data",value:function(e,t){var r=this.hex(e,t);if(r.length%2!==0)throw new Error("invalid data; odd-length - "+e);return r}},{key:"address",value:function(e){return Dy(e)}},{key:"callAddress",value:function(e){if(!En(e,32))return null;var t=Dy(An(e,12));return"0x0000000000000000000000000000000000000000"===t?null:t}},{key:"contractAddress",value:function(e){return function(e){var t=null;try{t=Dy(e.from)}catch(r){Cy.throwArgumentError("missing from address","transaction",e)}return Dy(An(Iy(On([t,kn(bn(Ey.from(e.nonce).toHexString()))])),12))}(e)}},{key:"blockTag",value:function(e){if(null==e)return"latest";if("earliest"===e)return"0x0";switch(e){case"earliest":return"0x0";case"latest":case"pending":case"safe":case"finalized":return e}if("number"===typeof e||En(e))return Cn(e);throw new Error("invalid blockTag")}},{key:"hash",value:function(e,t){var r=this.hex(e,t);return 32!==Sn(r)?uw.throwArgumentError("invalid hash","value",e):r}},{key:"difficulty",value:function(e){if(null==e)return null;var t=Ey.from(e);try{return t.toNumber()}catch(r){}return null}},{key:"uint256",value:function(e){if(!En(e))throw new Error("invalid uint256");return Tn(e,32)}},{key:"_block",value:function(t,r){null!=t.author&&null==t.miner&&(t.miner=t.author);var n=null!=t._difficulty?t._difficulty:t.difficulty,i=e.check(r,t);return i._difficulty=null==n?null:Ey.from(n),i}},{key:"block",value:function(e){return this._block(e,this.formats.block)}},{key:"blockWithTransactions",value:function(e){return this._block(e,this.formats.blockWithTransactions)}},{key:"transactionRequest",value:function(t){return e.check(this.formats.transactionRequest,t)}},{key:"transactionResponse",value:function(t){null!=t.gas&&null==t.gasLimit&&(t.gasLimit=t.gas),t.to&&Ey.from(t.to).isZero()&&(t.to="0x0000000000000000000000000000000000000000"),null!=t.input&&null==t.data&&(t.data=t.input),null==t.to&&null==t.creates&&(t.creates=this.contractAddress(t)),1!==t.type&&2!==t.type||null!=t.accessList||(t.accessList=[]);var r=e.check(this.formats.transaction,t);if(null!=t.chainId){var n=t.chainId;En(n)&&(n=Ey.from(n).toNumber()),r.chainId=n}else{var i=t.networkId;null==i&&null==r.v&&(i=t.chainId),En(i)&&(i=Ey.from(i).toNumber()),"number"!==typeof i&&null!=r.v&&((i=(r.v-35)/2)<0&&(i=0),i=parseInt(i)),"number"!==typeof i&&(i=0),r.chainId=i}return r.blockHash&&"x"===r.blockHash.replace(/0/g,"")&&(r.blockHash=null),r}},{key:"transaction",value:function(e){return fb(e)}},{key:"receiptLog",value:function(t){return e.check(this.formats.receiptLog,t)}},{key:"receipt",value:function(t){var r=e.check(this.formats.receipt,t);if(null!=r.root)if(r.root.length<=4){var n=Ey.from(r.root).toNumber();0===n||1===n?(null!=r.status&&r.status!==n&&uw.throwArgumentError("alt-root-status/status mismatch","value",{root:r.root,status:r.status}),r.status=n,delete r.root):uw.throwArgumentError("invalid alt-root-status","value.root",r.root)}else 66!==r.root.length&&uw.throwArgumentError("invalid root hash","value.root",r.root);return null!=r.status&&(r.byzantium=!0),r}},{key:"topics",value:function(e){var t=this;return Array.isArray(e)?e.map((function(e){return t.topics(e)})):null!=e?this.hash(e,!0):null}},{key:"filter",value:function(t){return e.check(this.formats.filter,t)}},{key:"filterLog",value:function(t){return e.check(this.formats.filterLog,t)}}],[{key:"check",value:function(e,t){var r={};for(var n in e)try{var i=e[n](t[n]);void 0!==i&&(r[n]=i)}catch(o){throw o.checkKey=n,o.checkValue=t[n],o}return r}},{key:"allowNull",value:function(e,t){return function(r){return null==r?t:e(r)}}},{key:"allowFalsish",value:function(e,t){return function(r){return r?e(r):t}}},{key:"arrayOf",value:function(e){return function(t){if(!Array.isArray(t))throw new Error("not an array");var r=[];return t.forEach((function(t){r.push(e(t))})),r}}}]),e}();var lw=function(e,t,r,n){return new(r||(r=Promise))((function(i,o){function a(e){try{u(n.next(e))}catch(t){o(t)}}function s(e){try{u(n.throw(e))}catch(t){o(t)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(a,s)}u((n=n.apply(e,t||[])).next())}))},fw=new hn(cy);function hw(e){return null==e?"null":(32!==Sn(e)&&fw.throwArgumentError("invalid topic","topic",e),e.toLowerCase())}function dw(e){for(e=e.slice();e.length>0&&null==e[e.length-1];)e.pop();return e.map((function(e){if(Array.isArray(e)){var t={};e.forEach((function(e){t[hw(e)]=!0}));var r=Object.keys(t);return r.sort(),r.join("|")}return hw(e)})).join("&")}function pw(e){if("string"===typeof e){if(32===Sn(e=e.toLowerCase()))return"tx:"+e;if(-1===e.indexOf(":"))return e}else{if(Array.isArray(e))return"filter:*:"+dw(e);if(_b.isForkEvent(e))throw fw.warn("not implemented"),new Error("not implemented");if(e&&"object"===typeof e)return"filter:"+(e.address||"*")+":"+dw(e.topics||[])}throw new Error("invalid event - "+e)}function vw(){return(new Date).getTime()}function gw(e){return new Promise((function(t){setTimeout(t,e)}))}var yw=["block","network","pending","poll"],mw=function(){function e(t,r,n){(0,F.Z)(this,e),ey(this,"tag",t),ey(this,"listener",r),ey(this,"once",n),this._lastBlockNumber=-2,this._inflight=!1}return(0,U.Z)(e,[{key:"event",get:function(){switch(this.type){case"tx":return this.hash;case"filter":return this.filter}return this.tag}},{key:"type",get:function(){return this.tag.split(":")[0]}},{key:"hash",get:function(){var e=this.tag.split(":");return"tx"!==e[0]?null:e[1]}},{key:"filter",get:function(){var e=this.tag.split(":");if("filter"!==e[0])return null;var t,r=e[1],n=""===(t=e[2])?[]:t.split(/&/g).map((function(e){if(""===e)return[];var t=e.split("|").map((function(e){return"null"===e?null:e}));return 1===t.length?t[0]:t})),i={};return n.length>0&&(i.topics=n),r&&"*"!==r&&(i.address=r),i}},{key:"pollable",value:function(){return this.tag.indexOf(":")>=0||yw.indexOf(this.tag)>=0}}]),e}(),bw={0:{symbol:"btc",p2pkh:0,p2sh:5,prefix:"bc"},2:{symbol:"ltc",p2pkh:48,p2sh:50,prefix:"ltc"},3:{symbol:"doge",p2pkh:30,p2sh:22},60:{symbol:"eth",ilk:"eth"},61:{symbol:"etc",ilk:"eth"},700:{symbol:"xdai",ilk:"eth"}};function ww(e){return Tn(Ey.from(e).toHexString(),32)}function kw(e){return Ib.encode(wn([e,An(ow(ow(e)),0,4)]))}var Ew=new RegExp("^(ipfs)://(.*)$","i"),xw=[new RegExp("^(https)://(.*)$","i"),new RegExp("^(data):(.*)$","i"),Ew,new RegExp("^eip155:[0-9]+/(erc[0-9]+):(.*)$","i")];function _w(e,t){try{return Vy(Sw(e,t))}catch(r){}return null}function Sw(e,t){if("0x"===e)return null;var r=Ey.from(An(e,t,t+32)).toNumber(),n=Ey.from(An(e,r,r+32)).toNumber();return An(e,r+32,r+32+n)}function Aw(e){return e.match(/^ipfs:\/\/ipfs\//i)?e=e.substring(12):e.match(/^ipfs:\/\//i)?e=e.substring(7):fw.throwArgumentError("unsupported IPFS format","link",e),"https://gateway.ipfs.io/ipfs/".concat(e)}function Iw(e){var t=bn(e);if(t.length>32)throw new Error("internal; should not happen");var r=new Uint8Array(32);return r.set(t,32-t.length),r}function Cw(e){if(e.length%32===0)return e;var t=new Uint8Array(32*Math.ceil(e.length/32));return t.set(e),t}function Tw(e){for(var t=[],r=0,n=0;n63)throw new Error("invalid DNS encoded entry; length exceeds 63 bytes");var t=new Uint8Array(e.length+1);return t.set(e,1),t[0]=t.length-1,t}))))+"00"),n.data])]);case 7:return r.prev=7,r.next=10,this.provider.call(n);case 10:return bn(o=r.sent).length%32===4&&fw.throwError("resolver threw error",hn.errors.CALL_EXCEPTION,{transaction:n,data:o}),i&&(o=Sw(o,0)),r.abrupt("return",o);case 16:if(r.prev=16,r.t0=r.catch(7),r.t0.code!==hn.errors.CALL_EXCEPTION){r.next=20;break}return r.abrupt("return",null);case 20:throw r.t0;case 21:case"end":return r.stop()}var a}),r,this,[[7,16]])})))}},{key:"_fetchBytes",value:function(e,t){return lw(this,void 0,void 0,(0,_.Z)().mark((function r(){var n;return(0,_.Z)().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,this._fetch(e,t);case 2:if(null==(n=r.sent)){r.next=5;break}return r.abrupt("return",Sw(n,0));case 5:return r.abrupt("return",null);case 6:case"end":return r.stop()}}),r,this)})))}},{key:"_getAddress",value:function(e,t){var r=bw[String(e)];if(null==r&&fw.throwError("unsupported coin type: ".concat(e),hn.errors.UNSUPPORTED_OPERATION,{operation:"getAddress(".concat(e,")")}),"eth"===r.ilk)return this.provider.formatter.address(t);var n=bn(t);if(null!=r.p2pkh){var i=t.match(/^0x76a9([0-9a-f][0-9a-f])([0-9a-f]*)88ac$/);if(i){var o=parseInt(i[1],16);if(i[2].length===2*o&&o>=1&&o<=75)return kw(wn([[r.p2pkh],"0x"+i[2]]))}}if(null!=r.p2sh){var a=t.match(/^0xa9([0-9a-f][0-9a-f])([0-9a-f]*)87$/);if(a){var s=parseInt(a[1],16);if(a[2].length===2*s&&s>=1&&s<=75)return kw(wn([[r.p2sh],"0x"+a[2]]))}}if(null!=r.prefix){var u=n[1],c=n[0];if(0===c?20!==u&&32!==u&&(c=-1):c=-1,c>=0&&n.length===2+u&&u>=1&&u<=75){var l=sw().toWords(n.slice(2));return l.unshift(c),sw().encode(r.prefix,l)}}return null}},{key:"getAddress",value:function(e){return lw(this,void 0,void 0,(0,_.Z)().mark((function t(){var r,n,i;return(0,_.Z)().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(null==e&&(e=60),60!==e){t.next=16;break}return t.prev=2,t.next=5,this._fetch("0x3b3b57de");case 5:if("0x"!==(r=t.sent)&&"0x0000000000000000000000000000000000000000000000000000000000000000"!==r){t.next=8;break}return t.abrupt("return",null);case 8:return t.abrupt("return",this.provider.formatter.callAddress(r));case 11:if(t.prev=11,t.t0=t.catch(2),t.t0.code!==hn.errors.CALL_EXCEPTION){t.next=15;break}return t.abrupt("return",null);case 15:throw t.t0;case 16:return t.next=18,this._fetchBytes("0xf1cb7e06",ww(e));case 18:if(null!=(n=t.sent)&&"0x"!==n){t.next=21;break}return t.abrupt("return",null);case 21:return null==(i=this._getAddress(e,n))&&fw.throwError("invalid or unsupported coin data",hn.errors.UNSUPPORTED_OPERATION,{operation:"getAddress(".concat(e,")"),coinType:e,data:n}),t.abrupt("return",i);case 24:case"end":return t.stop()}}),t,this,[[2,11]])})))}},{key:"getAvatar",value:function(){return lw(this,void 0,void 0,(0,_.Z)().mark((function e(){var t,r,n,i,o,a,s,u,c,l,f,h,d,p,v,g;return(0,_.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=[{type:"name",content:this.name}],e.prev=1,e.next=4,this.getText("avatar");case 4:if(null!=(r=e.sent)){e.next=7;break}return e.abrupt("return",null);case 7:n=0;case 8:if(!(n=0?null:JSON.stringify({data:o,sender:i}),n.next=12,wb({url:c,errorPassThrough:!0},l,(function(e,t){return e.status=t.statusCode,e}));case 12:if(!(f=n.sent).data){n.next=15;break}return n.abrupt("return",f.data);case 15:if(h=f.message||"unknown error",!(f.status>=400&&f.status<500)){n.next=18;break}return n.abrupt("return",fw.throwError("response not found during CCIP fetch: ".concat(h),hn.errors.SERVER_ERROR,{url:u,errorMessage:h}));case 18:a.push(h);case 19:s++,n.next=6;break;case 22:return n.abrupt("return",fw.throwError("error encountered during CCIP fetch: ".concat(a.map((function(e){return JSON.stringify(e)})).join(", ")),hn.errors.SERVER_ERROR,{urls:r,errorMessages:a}));case 23:case"end":return n.stop()}}),n,this)})))}},{key:"_getInternalBlockNumber",value:function(e){return lw(this,void 0,void 0,(0,_.Z)().mark((function t(){var r,n,i,o,a=this;return(0,_.Z)().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this._ready();case 2:if(!(e>0)){t.next=20;break}case 3:if(!this._internalBlockNumber){t.next=20;break}return r=this._internalBlockNumber,t.prev=5,t.next=8,r;case 8:if(n=t.sent,!(vw()-n.respTime<=e)){t.next=11;break}return t.abrupt("return",n.blockNumber);case 11:return t.abrupt("break",20);case 14:if(t.prev=14,t.t0=t.catch(5),this._internalBlockNumber!==r){t.next=18;break}return t.abrupt("break",20);case 18:t.next=3;break;case 20:return i=vw(),o=ry({blockNumber:this.perform("getBlockNumber",{}),networkError:this.getNetwork().then((function(e){return null}),(function(e){return e}))}).then((function(e){var t=e.blockNumber,r=e.networkError;if(r)throw a._internalBlockNumber===o&&(a._internalBlockNumber=null),r;var n=vw();return(t=Ey.from(t).toNumber())1e3)fw.warn("network block skew detected; skipping block events (emitted=".concat(this._emitted.block," blockNumber").concat(n,")")),this.emit("error",fw.makeError("network block skew detected",hn.errors.NETWORK_ERROR,{blockNumber:n,event:"blockSkew",previousBlockNumber:this._emitted.block})),this.emit("block",n);else for(i=this._emitted.block+1;i<=n;i++)this.emit("block",i);return this._emitted.block!==n&&(this._emitted.block=n,Object.keys(this._emitted).forEach((function(e){if("block"!==e){var t=o._emitted[e];"pending"!==t&&n-t>12&&delete o._emitted[e]}}))),-2===this._lastBlockNumber&&(this._lastBlockNumber=n-1),this._events.forEach((function(e){switch(e.type){case"tx":var t=e.hash,i=o.getTransactionReceipt(t).then((function(e){return e&&null!=e.blockNumber?(o._emitted["t:"+t]=e.blockNumber,o.emit(t,e),null):null})).catch((function(e){o.emit("error",e)}));r.push(i);break;case"filter":if(!e._inflight){e._inflight=!0,-2===e._lastBlockNumber&&(e._lastBlockNumber=n-1);var a=e.filter;a.fromBlock=e._lastBlockNumber+1,a.toBlock=n;var s=a.toBlock-o._maxFilterBlockRange;s>a.fromBlock&&(a.fromBlock=s),a.fromBlock<0&&(a.fromBlock=0);var u=o.getLogs(a).then((function(t){e._inflight=!1,0!==t.length&&t.forEach((function(t){t.blockNumber>e._lastBlockNumber&&(e._lastBlockNumber=t.blockNumber),o._emitted["b:"+t.blockHash]=t.blockNumber,o._emitted["t:"+t.transactionHash]=t.blockNumber,o.emit(a,t)}))})).catch((function(t){o.emit("error",t),e._inflight=!1}));r.push(u)}}})),this._lastBlockNumber=n,Promise.all(r).then((function(){o.emit("didPoll",t)})).catch((function(e){o.emit("error",e)})),e.abrupt("return");case 26:case"end":return e.stop()}}),e,this,[[3,9]])})))}},{key:"resetEventsBlock",value:function(e){this._lastBlockNumber=e-1,this.polling&&this.poll()}},{key:"network",get:function(){return this._network}},{key:"detectNetwork",value:function(){return lw(this,void 0,void 0,(0,_.Z)().mark((function e(){return(0,_.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",fw.throwError("provider does not support network detection",hn.errors.UNSUPPORTED_OPERATION,{operation:"provider.detectNetwork"}));case 1:case"end":return e.stop()}}),e)})))}},{key:"getNetwork",value:function(){return lw(this,void 0,void 0,(0,_.Z)().mark((function e(){var t,r,n;return(0,_.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._ready();case 2:return t=e.sent,e.next=5,this.detectNetwork();case 5:if(r=e.sent,t.chainId===r.chainId){e.next=23;break}if(!this.anyNetwork){e.next=20;break}return this._network=r,this._lastBlockNumber=-2,this._fastBlockNumber=null,this._fastBlockNumberPromise=null,this._fastQueryDate=0,this._emitted.block=-2,this._maxInternalBlockNumber=-1024,this._internalBlockNumber=null,this.emit("network",r,t),e.next=19,gw(0);case 19:return e.abrupt("return",this._network);case 20:throw n=fw.makeError("underlying network changed",hn.errors.NETWORK_ERROR,{event:"changed",network:t,detectedNetwork:r}),this.emit("error",n),n;case 23:return e.abrupt("return",t);case 24:case"end":return e.stop()}}),e,this)})))}},{key:"blockNumber",get:function(){var e=this;return this._getInternalBlockNumber(100+this.pollingInterval/2).then((function(t){e._setFastBlockNumber(t)}),(function(e){})),null!=this._fastBlockNumber?this._fastBlockNumber:-1}},{key:"polling",get:function(){return null!=this._poller},set:function(e){var t=this;e&&!this._poller?(this._poller=setInterval((function(){t.poll()}),this.pollingInterval),this._bootstrapPoll||(this._bootstrapPoll=setTimeout((function(){t.poll(),t._bootstrapPoll=setTimeout((function(){t._poller||t.poll(),t._bootstrapPoll=null}),t.pollingInterval)}),0))):!e&&this._poller&&(clearInterval(this._poller),this._poller=null)}},{key:"pollingInterval",get:function(){return this._pollingInterval},set:function(e){var t=this;if("number"!==typeof e||e<=0||parseInt(String(e))!=e)throw new Error("invalid polling interval");this._pollingInterval=e,this._poller&&(clearInterval(this._poller),this._poller=setInterval((function(){t.poll()}),this._pollingInterval))}},{key:"_getFastBlockNumber",value:function(){var e=this,t=vw();return t-this._fastQueryDate>2*this._pollingInterval&&(this._fastQueryDate=t,this._fastBlockNumberPromise=this.getBlockNumber().then((function(t){return(null==e._fastBlockNumber||t>e._fastBlockNumber)&&(e._fastBlockNumber=t),e._fastBlockNumber}))),this._fastBlockNumberPromise}},{key:"_setFastBlockNumber",value:function(e){null!=this._fastBlockNumber&&ethis._fastBlockNumber)&&(this._fastBlockNumber=e,this._fastBlockNumberPromise=Promise.resolve(e)))}},{key:"waitForTransaction",value:function(e,t,r){return lw(this,void 0,void 0,(0,_.Z)().mark((function n(){return(0,_.Z)().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",this._waitForTransaction(e,null==t?1:t,r||0,null));case 1:case"end":return n.stop()}}),n,this)})))}},{key:"_waitForTransaction",value:function(e,t,r,n){return lw(this,void 0,void 0,(0,_.Z)().mark((function i(){var o,a=this;return(0,_.Z)().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,this.getTransactionReceipt(e);case 2:if(!(((o=i.sent)?o.confirmations:0)>=t)){i.next=5;break}return i.abrupt("return",o);case 5:return i.abrupt("return",new Promise((function(i,o){var s=[],u=!1,c=function(){return!!u||(u=!0,s.forEach((function(e){e()})),!1)},l=function(e){e.confirmations0){var p=setTimeout((function(){c()||o(fw.makeError("timeout exceeded",hn.errors.TIMEOUT,{timeout:r}))}),r);p.unref&&p.unref(),s.push((function(){clearTimeout(p)}))}})));case 6:case"end":return i.stop()}}),i,this)})))}},{key:"getBlockNumber",value:function(){return lw(this,void 0,void 0,(0,_.Z)().mark((function e(){return(0,_.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._getInternalBlockNumber(0));case 1:case"end":return e.stop()}}),e,this)})))}},{key:"getGasPrice",value:function(){return lw(this,void 0,void 0,(0,_.Z)().mark((function e(){var t;return(0,_.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getNetwork();case 2:return e.next=4,this.perform("getGasPrice",{});case 4:return t=e.sent,e.prev=5,e.abrupt("return",Ey.from(t));case 9:return e.prev=9,e.t0=e.catch(5),e.abrupt("return",fw.throwError("bad result from backend",hn.errors.SERVER_ERROR,{method:"getGasPrice",result:t,error:e.t0}));case 12:case"end":return e.stop()}}),e,this,[[5,9]])})))}},{key:"getBalance",value:function(e,t){return lw(this,void 0,void 0,(0,_.Z)().mark((function r(){var n,i;return(0,_.Z)().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,this.getNetwork();case 2:return r.next=4,ry({address:this._getAddress(e),blockTag:this._getBlockTag(t)});case 4:return n=r.sent,r.next=7,this.perform("getBalance",n);case 7:return i=r.sent,r.prev=8,r.abrupt("return",Ey.from(i));case 12:return r.prev=12,r.t0=r.catch(8),r.abrupt("return",fw.throwError("bad result from backend",hn.errors.SERVER_ERROR,{method:"getBalance",params:n,result:i,error:r.t0}));case 15:case"end":return r.stop()}}),r,this,[[8,12]])})))}},{key:"getTransactionCount",value:function(e,t){return lw(this,void 0,void 0,(0,_.Z)().mark((function r(){var n,i;return(0,_.Z)().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,this.getNetwork();case 2:return r.next=4,ry({address:this._getAddress(e),blockTag:this._getBlockTag(t)});case 4:return n=r.sent,r.next=7,this.perform("getTransactionCount",n);case 7:return i=r.sent,r.prev=8,r.abrupt("return",Ey.from(i).toNumber());case 12:return r.prev=12,r.t0=r.catch(8),r.abrupt("return",fw.throwError("bad result from backend",hn.errors.SERVER_ERROR,{method:"getTransactionCount",params:n,result:i,error:r.t0}));case 15:case"end":return r.stop()}}),r,this,[[8,12]])})))}},{key:"getCode",value:function(e,t){return lw(this,void 0,void 0,(0,_.Z)().mark((function r(){var n,i;return(0,_.Z)().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,this.getNetwork();case 2:return r.next=4,ry({address:this._getAddress(e),blockTag:this._getBlockTag(t)});case 4:return n=r.sent,r.next=7,this.perform("getCode",n);case 7:return i=r.sent,r.prev=8,r.abrupt("return",_n(i));case 12:return r.prev=12,r.t0=r.catch(8),r.abrupt("return",fw.throwError("bad result from backend",hn.errors.SERVER_ERROR,{method:"getCode",params:n,result:i,error:r.t0}));case 15:case"end":return r.stop()}}),r,this,[[8,12]])})))}},{key:"getStorageAt",value:function(e,t,r){return lw(this,void 0,void 0,(0,_.Z)().mark((function n(){var i,o;return(0,_.Z)().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,this.getNetwork();case 2:return n.next=4,ry({address:this._getAddress(e),blockTag:this._getBlockTag(r),position:Promise.resolve(t).then((function(e){return Cn(e)}))});case 4:return i=n.sent,n.next=7,this.perform("getStorageAt",i);case 7:return o=n.sent,n.prev=8,n.abrupt("return",_n(o));case 12:return n.prev=12,n.t0=n.catch(8),n.abrupt("return",fw.throwError("bad result from backend",hn.errors.SERVER_ERROR,{method:"getStorageAt",params:i,result:o,error:n.t0}));case 15:case"end":return n.stop()}}),n,this,[[8,12]])})))}},{key:"_wrapTransaction",value:function(e,t,r){var n=this;if(null!=t&&32!==Sn(t))throw new Error("invalid response - sendTransaction");var i=e;return null!=t&&e.hash!==t&&fw.throwError("Transaction hash mismatch from Provider.sendTransaction.",hn.errors.UNKNOWN_ERROR,{expectedHash:e.hash,returnedHash:t}),i.wait=function(t,i){return lw(n,void 0,void 0,(0,_.Z)().mark((function n(){var o,a;return(0,_.Z)().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return null==t&&(t=1),null==i&&(i=0),o=void 0,0!==t&&null!=r&&(o={data:e.data,from:e.from,nonce:e.nonce,to:e.to,value:e.value,startBlock:r}),n.next=6,this._waitForTransaction(e.hash,t,i,o);case 6:if(null!=(a=n.sent)||0!==t){n.next=9;break}return n.abrupt("return",null);case 9:return this._emitted["t:"+e.hash]=a.blockNumber,0===a.status&&fw.throwError("transaction failed",hn.errors.CALL_EXCEPTION,{transactionHash:e.hash,transaction:e,receipt:a}),n.abrupt("return",a);case 12:case"end":return n.stop()}}),n,this)})))},i}},{key:"sendTransaction",value:function(e){return lw(this,void 0,void 0,(0,_.Z)().mark((function t(){var r,n,i,o;return(0,_.Z)().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getNetwork();case 2:return t.next=4,Promise.resolve(e).then((function(e){return _n(e)}));case 4:return r=t.sent,null==(n=this.formatter.transaction(e)).confirmations&&(n.confirmations=0),t.next=9,this._getInternalBlockNumber(100+2*this.pollingInterval);case 9:return i=t.sent,t.prev=10,t.next=13,this.perform("sendTransaction",{signedTransaction:r});case 13:return o=t.sent,t.abrupt("return",this._wrapTransaction(n,o,i));case 17:throw t.prev=17,t.t0=t.catch(10),t.t0.transaction=n,t.t0.transactionHash=n.hash,t.t0;case 22:case"end":return t.stop()}}),t,this,[[10,17]])})))}},{key:"_getTransactionRequest",value:function(e){return lw(this,void 0,void 0,(0,_.Z)().mark((function t(){var r,n,i=this;return(0,_.Z)().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e;case 2:return r=t.sent,n={},["from","to"].forEach((function(e){null!=r[e]&&(n[e]=Promise.resolve(r[e]).then((function(e){return e?i._getAddress(e):null})))})),["gasLimit","gasPrice","maxFeePerGas","maxPriorityFeePerGas","value"].forEach((function(e){null!=r[e]&&(n[e]=Promise.resolve(r[e]).then((function(e){return e?Ey.from(e):null})))})),["type"].forEach((function(e){null!=r[e]&&(n[e]=Promise.resolve(r[e]).then((function(e){return null!=e?e:null})))})),r.accessList&&(n.accessList=this.formatter.accessList(r.accessList)),["data"].forEach((function(e){null!=r[e]&&(n[e]=Promise.resolve(r[e]).then((function(e){return e?_n(e):null})))})),t.t0=this.formatter,t.next=12,ry(n);case 12:return t.t1=t.sent,t.abrupt("return",t.t0.transactionRequest.call(t.t0,t.t1));case 14:case"end":return t.stop()}}),t,this)})))}},{key:"_getFilter",value:function(e){return lw(this,void 0,void 0,(0,_.Z)().mark((function t(){var r,n=this;return(0,_.Z)().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e;case 2:return e=t.sent,r={},null!=e.address&&(r.address=this._getAddress(e.address)),["blockHash","topics"].forEach((function(t){null!=e[t]&&(r[t]=e[t])})),["fromBlock","toBlock"].forEach((function(t){null!=e[t]&&(r[t]=n._getBlockTag(e[t]))})),t.t0=this.formatter,t.next=10,ry(r);case 10:return t.t1=t.sent,t.abrupt("return",t.t0.filter.call(t.t0,t.t1));case 12:case"end":return t.stop()}}),t,this)})))}},{key:"_call",value:function(e,t,r){return lw(this,void 0,void 0,(0,_.Z)().mark((function n(){var i,o,a,s,u,c,l,f,h,d,p,v,g,y,m;return(0,_.Z)().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r>=10&&fw.throwError("CCIP read exceeded maximum redirections",hn.errors.SERVER_ERROR,{redirects:r,transaction:e}),i=e.to,n.next=4,this.perform("call",{transaction:e,blockTag:t});case 4:if(o=n.sent,!(r>=0&&"latest"===t&&null!=i&&"0x556f1830"===o.substring(0,10)&&Sn(o)%32===4)){n.next=31;break}for(n.prev=6,a=An(o,4),s=An(a,0,32),Ey.from(s).eq(i)||fw.throwError("CCIP Read sender did not match",hn.errors.CALL_EXCEPTION,{name:"OffchainLookup",signature:"OffchainLookup(address,string[],bytes,bytes4,bytes)",transaction:e,data:o}),u=[],c=Ey.from(An(a,32,64)).toNumber(),l=Ey.from(An(a,c,c+32)).toNumber(),f=An(a,c+32),h=0;hthis._emitted.block)){e.next=10;break}return e.abrupt("return",null);case 10:return e.abrupt("return",void 0);case 11:if(!t){e.next=34;break}o=null,a=0;case 14:if(!(a0}},{key:"_stopEvent",value:function(e){this.polling=this._events.filter((function(e){return e.pollable()})).length>0}},{key:"_addEventListener",value:function(e,t,r){var n=new mw(pw(e),t,r);return this._events.push(n),this._startEvent(n),this}},{key:"on",value:function(e,t){return this._addEventListener(e,t,!1)}},{key:"once",value:function(e,t){return this._addEventListener(e,t,!0)}},{key:"emit",value:function(e){for(var t=this,r=arguments.length,n=new Array(r>1?r-1:0),i=1;i=0&&a.match(/gas required exceeds allowance|always failing transaction|execution reverted/)&&Ow.throwError("cannot estimate gas; transaction may fail or may require manual gas limit",hn.errors.UNPREDICTABLE_GAS_LIMIT,{error:t,method:e,transaction:n}),t}function Fw(e){return new Promise((function(t){setTimeout(t,e)}))}function zw(e){if(e.error){var t=new Error(e.error.message);throw t.code=e.error.code,t.data=e.error.data,t}return e.result}function Zw(e){return e?e.toLowerCase():e}var jw={},qw=function(e){Z(r,e);var t=G(r);function r(e,n,i){var o;if((0,F.Z)(this,r),o=t.call(this),e!==jw)throw new Error("do not call the JsonRpcSigner constructor directly; use provider.getSigner");return ey(V(o),"provider",n),null==i&&(i=0),"string"===typeof i?(ey(V(o),"_address",o.provider.formatter.address(i)),ey(V(o),"_index",null)):"number"===typeof i?(ey(V(o),"_index",i),ey(V(o),"_address",null)):Ow.throwArgumentError("invalid address or index","addressOrIndex",i),o}return(0,U.Z)(r,[{key:"connect",value:function(e){return Ow.throwError("cannot alter JSON-RPC Signer connection",hn.errors.UNSUPPORTED_OPERATION,{operation:"connect"})}},{key:"connectUnchecked",value:function(){return new Kw(jw,this.provider,this._address||this._index)}},{key:"getAddress",value:function(){var e=this;return this._address?Promise.resolve(this._address):this.provider.send("eth_accounts",[]).then((function(t){return t.length<=e._index&&Ow.throwError("unknown account #"+e._index,hn.errors.UNSUPPORTED_OPERATION,{operation:"getAddress"}),e.provider.formatter.address(t[e._index])}))}},{key:"sendUncheckedTransaction",value:function(e){var t=this;e=ny(e);var r=this.getAddress().then((function(e){return e&&(e=e.toLowerCase()),e}));if(null==e.gasLimit){var n=ny(e);n.from=r,e.gasLimit=this.provider.estimateGas(n)}return null!=e.to&&(e.to=Promise.resolve(e.to).then((function(e){return Nw(t,void 0,void 0,(0,_.Z)().mark((function t(){var r;return(0,_.Z)().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(null!=e){t.next=2;break}return t.abrupt("return",null);case 2:return t.next=4,this.provider.resolveName(e);case 4:return null==(r=t.sent)&&Ow.throwArgumentError("provided ENS name resolves to null","tx.to",e),t.abrupt("return",r);case 7:case"end":return t.stop()}}),t,this)})))}))),ry({tx:ry(e),sender:r}).then((function(r){var n=r.tx,i=r.sender;null!=n.from?n.from.toLowerCase()!==i&&Ow.throwArgumentError("from address mismatch","transaction",e):n.from=i;var o=t.provider.constructor.hexlifyTransaction(n,{from:!0});return t.provider.send("eth_sendTransaction",[o]).then((function(e){return e}),(function(e){return"string"===typeof e.message&&e.message.match(/user denied/i)&&Ow.throwError("user rejected transaction",hn.errors.ACTION_REJECTED,{action:"sendTransaction",transaction:n}),Uw("sendTransaction",e,o)}))}))}},{key:"signTransaction",value:function(e){return Ow.throwError("signing transactions is unsupported",hn.errors.UNSUPPORTED_OPERATION,{operation:"signTransaction"})}},{key:"sendTransaction",value:function(e){return Nw(this,void 0,void 0,(0,_.Z)().mark((function t(){var r,n,i=this;return(0,_.Z)().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.provider._getInternalBlockNumber(100+2*this.provider.pollingInterval);case 2:return r=t.sent,t.next=5,this.sendUncheckedTransaction(e);case 5:return n=t.sent,t.prev=6,t.next=9,kb((function(){return Nw(i,void 0,void 0,(0,_.Z)().mark((function e(){var t;return(0,_.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.provider.getTransaction(n);case 2:if(null!==(t=e.sent)){e.next=5;break}return e.abrupt("return",void 0);case 5:return e.abrupt("return",this.provider._wrapTransaction(t,n,r));case 6:case"end":return e.stop()}}),e,this)})))}),{oncePoll:this.provider});case 9:return t.abrupt("return",t.sent);case 12:throw t.prev=12,t.t0=t.catch(6),t.t0.transactionHash=n,t.t0;case 16:case"end":return t.stop()}}),t,this,[[6,12]])})))}},{key:"signMessage",value:function(e){return Nw(this,void 0,void 0,(0,_.Z)().mark((function t(){var r,n;return(0,_.Z)().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r="string"===typeof e?Ky(e):e,t.next=3,this.getAddress();case 3:return n=t.sent,t.prev=4,t.next=7,this.provider.send("personal_sign",[_n(r),n.toLowerCase()]);case 7:return t.abrupt("return",t.sent);case 10:throw t.prev=10,t.t0=t.catch(4),"string"===typeof t.t0.message&&t.t0.message.match(/user denied/i)&&Ow.throwError("user rejected signing",hn.errors.ACTION_REJECTED,{action:"signMessage",from:n,messageData:e}),t.t0;case 14:case"end":return t.stop()}}),t,this,[[4,10]])})))}},{key:"_legacySignMessage",value:function(e){return Nw(this,void 0,void 0,(0,_.Z)().mark((function t(){var r,n;return(0,_.Z)().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r="string"===typeof e?Ky(e):e,t.next=3,this.getAddress();case 3:return n=t.sent,t.prev=4,t.next=7,this.provider.send("eth_sign",[n.toLowerCase(),_n(r)]);case 7:return t.abrupt("return",t.sent);case 10:throw t.prev=10,t.t0=t.catch(4),"string"===typeof t.t0.message&&t.t0.message.match(/user denied/i)&&Ow.throwError("user rejected signing",hn.errors.ACTION_REJECTED,{action:"_legacySignMessage",from:n,messageData:e}),t.t0;case 14:case"end":return t.stop()}}),t,this,[[4,10]])})))}},{key:"_signTypedData",value:function(e,t,r){return Nw(this,void 0,void 0,(0,_.Z)().mark((function n(){var i,o,a=this;return(0,_.Z)().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,um.resolveNames(e,t,r,(function(e){return a.provider.resolveName(e)}));case 2:return i=n.sent,n.next=5,this.getAddress();case 5:return o=n.sent,n.prev=6,n.next=9,this.provider.send("eth_signTypedData_v4",[o.toLowerCase(),JSON.stringify(um.getPayload(i.domain,t,i.value))]);case 9:return n.abrupt("return",n.sent);case 12:throw n.prev=12,n.t0=n.catch(6),"string"===typeof n.t0.message&&n.t0.message.match(/user denied/i)&&Ow.throwError("user rejected signing",hn.errors.ACTION_REJECTED,{action:"_signTypedData",from:o,messageData:{domain:i.domain,types:t,value:i.value}}),n.t0;case 16:case"end":return n.stop()}}),n,this,[[6,12]])})))}},{key:"unlock",value:function(e){return Nw(this,void 0,void 0,(0,_.Z)().mark((function t(){var r,n;return(0,_.Z)().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=this.provider,t.next=3,this.getAddress();case 3:return n=t.sent,t.abrupt("return",r.send("personal_unlockAccount",[n.toLowerCase(),e,null]));case 5:case"end":return t.stop()}}),t,this)})))}}]),r}(py),Kw=function(e){Z(r,e);var t=G(r);function r(){return(0,F.Z)(this,r),t.apply(this,arguments)}return(0,U.Z)(r,[{key:"sendTransaction",value:function(e){var t=this;return this.sendUncheckedTransaction(e).then((function(e){return{hash:e,nonce:null,gasLimit:null,gasPrice:null,data:null,value:null,chainId:null,confirmations:0,from:null,wait:function(r){return t.provider.waitForTransaction(e,r)}}}))}}]),r}(qw),Vw={chainId:!0,data:!0,gasLimit:!0,gasPrice:!0,nonce:!0,to:!0,value:!0,type:!0,accessList:!0,maxFeePerGas:!0,maxPriorityFeePerGas:!0},Hw=function(e){Z(r,e);var t=G(r);function r(e,n){var i;(0,F.Z)(this,r);var o=n;return null==o&&(o=new Promise((function(e,t){setTimeout((function(){i.detectNetwork().then((function(t){e(t)}),(function(e){t(e)}))}),0)}))),i=t.call(this,o),e||(e=ty(i.constructor,"defaultUrl")()),ey(V(i),"connection","string"===typeof e?Object.freeze({url:e}):Object.freeze(ny(e))),i._nextId=42,i}return(0,U.Z)(r,[{key:"_cache",get:function(){return null==this._eventLoopCache&&(this._eventLoopCache={}),this._eventLoopCache}},{key:"detectNetwork",value:function(){var e=this;return this._cache.detectNetwork||(this._cache.detectNetwork=this._uncachedDetectNetwork(),setTimeout((function(){e._cache.detectNetwork=null}),0)),this._cache.detectNetwork}},{key:"_uncachedDetectNetwork",value:function(){return Nw(this,void 0,void 0,(0,_.Z)().mark((function e(){var t,r;return(0,_.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,Fw(0);case 2:return t=null,e.prev=3,e.next=6,this.send("eth_chainId",[]);case 6:t=e.sent,e.next=19;break;case 9:return e.prev=9,e.t0=e.catch(3),e.prev=11,e.next=14,this.send("net_version",[]);case 14:t=e.sent,e.next=19;break;case 17:e.prev=17,e.t1=e.catch(11);case 19:if(null==t){e.next=28;break}return r=ty(this.constructor,"getNetwork"),e.prev=21,e.abrupt("return",r(Ey.from(t).toNumber()));case 25:return e.prev=25,e.t2=e.catch(21),e.abrupt("return",Ow.throwError("could not detect network",hn.errors.NETWORK_ERROR,{chainId:t,event:"invalidNetwork",serverError:e.t2}));case 28:return e.abrupt("return",Ow.throwError("could not detect network",hn.errors.NETWORK_ERROR,{event:"noNetwork"}));case 29:case"end":return e.stop()}}),e,this,[[3,9],[11,17],[21,25]])})))}},{key:"getSigner",value:function(e){return new qw(jw,this,e)}},{key:"getUncheckedSigner",value:function(e){return this.getSigner(e).connectUnchecked()}},{key:"listAccounts",value:function(){var e=this;return this.send("eth_accounts",[]).then((function(t){return t.map((function(t){return e.formatter.address(t)}))}))}},{key:"send",value:function(e,t){var r=this,n={method:e,params:t,id:this._nextId++,jsonrpc:"2.0"};this.emit("debug",{action:"request",request:sy(n),provider:this});var i=["eth_chainId","eth_blockNumber"].indexOf(e)>=0;if(i&&this._cache[e])return this._cache[e];var o=wb(this.connection,JSON.stringify(n),zw).then((function(e){return r.emit("debug",{action:"response",request:n,response:e,provider:r}),e}),(function(e){throw r.emit("debug",{action:"response",error:e,request:n,provider:r}),e}));return i&&(this._cache[e]=o,setTimeout((function(){r._cache[e]=null}),0)),o}},{key:"prepareRequest",value:function(e,t){switch(e){case"getBlockNumber":return["eth_blockNumber",[]];case"getGasPrice":return["eth_gasPrice",[]];case"getBalance":return["eth_getBalance",[Zw(t.address),t.blockTag]];case"getTransactionCount":return["eth_getTransactionCount",[Zw(t.address),t.blockTag]];case"getCode":return["eth_getCode",[Zw(t.address),t.blockTag]];case"getStorageAt":return["eth_getStorageAt",[Zw(t.address),Tn(t.position,32),t.blockTag]];case"sendTransaction":return["eth_sendRawTransaction",[t.signedTransaction]];case"getBlock":return t.blockTag?["eth_getBlockByNumber",[t.blockTag,!!t.includeTransactions]]:t.blockHash?["eth_getBlockByHash",[t.blockHash,!!t.includeTransactions]]:null;case"getTransaction":return["eth_getTransactionByHash",[t.transactionHash]];case"getTransactionReceipt":return["eth_getTransactionReceipt",[t.transactionHash]];case"call":return["eth_call",[ty(this.constructor,"hexlifyTransaction")(t.transaction,{from:!0}),t.blockTag]];case"estimateGas":return["eth_estimateGas",[ty(this.constructor,"hexlifyTransaction")(t.transaction,{from:!0})]];case"getLogs":return t.filter&&null!=t.filter.address&&(t.filter.address=Zw(t.filter.address)),["eth_getLogs",[t.filter]]}return null}},{key:"perform",value:function(e,t){return Nw(this,void 0,void 0,(0,_.Z)().mark((function r(){var n,i,o;return(0,_.Z)().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if("call"!==e&&"estimateGas"!==e){r.next=8;break}if(!(n=t.transaction)||null==n.type||!Ey.from(n.type).isZero()){r.next=8;break}if(null!=n.maxFeePerGas||null!=n.maxPriorityFeePerGas){r.next=8;break}return r.next=6,this.getFeeData();case 6:null==(i=r.sent).maxFeePerGas&&null==i.maxPriorityFeePerGas&&((t=ny(t)).transaction=ny(n),delete t.transaction.type);case 8:return null==(o=this.prepareRequest(e,t))&&Ow.throwError(e+" not implemented",hn.errors.NOT_IMPLEMENTED,{operation:e}),r.prev=10,r.next=13,this.send(o[0],o[1]);case 13:return r.abrupt("return",r.sent);case 16:return r.prev=16,r.t0=r.catch(10),r.abrupt("return",Uw(e,r.t0,t));case 19:case"end":return r.stop()}}),r,this,[[10,16]])})))}},{key:"_startEvent",value:function(e){"pending"===e.tag&&this._startPending(),tn(j(r.prototype),"_startEvent",this).call(this,e)}},{key:"_startPending",value:function(){if(null==this._pendingFilter){var e=this,t=this.send("eth_newPendingTransactionFilter",[]);this._pendingFilter=t,t.then((function(r){return function n(){e.send("eth_getFilterChanges",[r]).then((function(r){if(e._pendingFilter!=t)return null;var n=Promise.resolve();return r.forEach((function(t){e._emitted["t:"+t.toLowerCase()]="pending",n=n.then((function(){return e.getTransaction(t).then((function(t){return e.emit("pending",t),null}))}))})),n.then((function(){return Fw(1e3)}))})).then((function(){if(e._pendingFilter==t)return setTimeout((function(){n()}),0),null;e.send("eth_uninstallFilter",[r])})).catch((function(e){}))}(),r})).catch((function(e){}))}}},{key:"_stopEvent",value:function(e){"pending"===e.tag&&0===this.listenerCount("pending")&&(this._pendingFilter=null),tn(j(r.prototype),"_stopEvent",this).call(this,e)}}],[{key:"defaultUrl",value:function(){return"http://localhost:8545"}},{key:"hexlifyTransaction",value:function(e,t){var r=ny(Vw);if(t)for(var n in t)t[n]&&(r[n]=!0);!function(e,t){e&&"object"===typeof e||$g.throwArgumentError("invalid object","object",e),Object.keys(e).forEach((function(r){t[r]||$g.throwArgumentError("invalid object key - "+r,"transaction:"+r,e)}))}(e,r);var i={};return["chainId","gasLimit","gasPrice","type","maxFeePerGas","maxPriorityFeePerGas","nonce","value"].forEach((function(t){if(null!=e[t]){var r=Cn(Ey.from(e[t]));"gasLimit"===t&&(t="gas"),i[t]=r}})),["from","to","data"].forEach((function(t){null!=e[t]&&(i[t]=_n(e[t]))})),e.accessList&&(i.accessList=ab(e.accessList)),i}}]),r}(Mw),Gw=new hn(cy),Ww=1;function Qw(e,t){var r="Web3LegacyFetcher";return function(e,n){var i=this,o={method:e,params:n,id:Ww++,jsonrpc:"2.0"};return new Promise((function(e,n){i.emit("debug",{action:"request",fetcher:r,request:sy(o),provider:i}),t(o,(function(t,a){if(t)return i.emit("debug",{action:"response",fetcher:r,error:t,request:o,provider:i}),n(t);if(i.emit("debug",{action:"response",fetcher:r,request:o,response:a,provider:i}),a.error){var s=new Error(a.error.message);return s.code=a.error.code,s.data=a.error.data,n(s)}e(a.result)}))}))}}var Jw=function(e){Z(r,e);var t=G(r);function r(e,n){var i;(0,F.Z)(this,r),null==e&&Gw.throwArgumentError("missing provider","provider",e);var o=null,a=null,s=null;return"function"===typeof e?(o="unknown:",a=e):(!(o=e.host||e.path||"")&&e.isMetaMask&&(o="metamask"),s=e,e.request?(""===o&&(o="eip-1193:"),a=function(e){return function(t,r){var n=this;null==r&&(r=[]);var i={method:t,params:r};return this.emit("debug",{action:"request",fetcher:"Eip1193Fetcher",request:sy(i),provider:this}),e.request(i).then((function(e){return n.emit("debug",{action:"response",fetcher:"Eip1193Fetcher",request:i,response:e,provider:n}),e}),(function(e){throw n.emit("debug",{action:"response",fetcher:"Eip1193Fetcher",request:i,error:e,provider:n}),e}))}}(e)):e.sendAsync?a=Qw(0,e.sendAsync.bind(e)):e.send?a=Qw(0,e.send.bind(e)):Gw.throwArgumentError("unsupported provider","provider",e),o||(o="unknown:")),ey(V(i=t.call(this,o,n)),"jsonRpcFetchFunc",a),ey(V(i),"provider",s),i}return(0,U.Z)(r,[{key:"send",value:function(e,t){return this.jsonRpcFetchFunc(e,t)}}]),r}(Hw);function Yw(e){var t=e.setAddress,r=e.setProvider,n=function(){var e=(0,S.Z)((0,_.Z)().mark((function e(){var n,i;return(0,_.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,n=new Jw(window.ethereum),e.next=4,n.send("eth_requestAccounts",[]);case 4:i=e.sent,t(i[0]),r(n),e.next=12;break;case 9:e.prev=9,e.t0=e.catch(0),console.error("No web3 provider available",e.t0);case 12:case"end":return e.stop()}}),e,null,[[0,9]])})));return function(){return e.apply(this,arguments)}}();return(0,cg.jsx)(Yg,{variant:"contained",color:"primary",onClick:n,children:"Connect Wallet"})}var Xw=function(){var e=P((0,k.useState)(),2),t=e[0],r=e[1],n=P((0,k.useState)(),2),i=n[0],o=n[1],a=P((0,k.useState)(),2),s=a[0],u=a[1],c=P((0,k.useState)(),2),l=c[0],f=c[1],h=P((0,k.useState)(),2),d=h[0],p=h[1],v=P((0,k.useState)(),2),g=v[0],y=v[1],m=P((0,k.useState)(),2),b=m[0],w=m[1];return(0,k.useEffect)((function(){t||(0,S.Z)((0,_.Z)().mark((function e(){var t;return(0,_.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,R();case 2:t=e.sent,r(t);case 4:case"end":return e.stop()}}),e)})))()})),(0,k.useEffect)((function(){if(i){var e=Vr(i.IDKey),t=Vr(i.IDCommitment);u(e),f(t)}}),[i]),(0,k.useEffect)((function(){d&&(0,S.Z)((0,_.Z)().mark((function e(){var t;return(0,_.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,d.detectNetwork();case 2:t=e.sent,w(t.name);case 4:case"end":return e.stop()}}),e)})))()}),[d]),(0,cg.jsxs)("div",{className:"App",children:[(0,cg.jsx)("h2",{children:"RLN Credentials:"}),(0,cg.jsxs)("p",{children:["key: ",s]}),(0,cg.jsxs)("p",{children:["commitment: ",l]}),(0,cg.jsx)($w,{rlnInstance:t,setMembershipKey:o}),(0,cg.jsx)("h2",{children:"Wallet"}),(0,cg.jsxs)("p",{children:["network: ",b]}),(0,cg.jsxs)("p",{children:["address: ",g]}),(0,cg.jsx)(Yw,{setAddress:y,setProvider:p})]})};function $w(e){var t=e.rlnInstance,r=e.setMembershipKey,n=function(){var e=(0,S.Z)((0,_.Z)().mark((function e(){var n;return(0,_.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t){e.next=2;break}return e.abrupt("return");case 2:n=t.generateMembershipKey(),r(n);case 4:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}();return(0,cg.jsx)("div",{children:(0,cg.jsx)(Yg,{variant:"contained",onClick:n,disabled:!t,children:"Generate RLN Credentials"})})}x.createRoot(document.getElementById("root")).render((0,cg.jsx)(k.StrictMode,{children:(0,cg.jsx)(Xw,{})}))},193:function(e){"use strict";e.exports=function(e,t){var r=new Array(arguments.length-1),n=0,i=2,o=!0;for(;i1&&"="===e.charAt(t);)++r;return Math.ceil(3*e.length)/4-r};for(var n=new Array(64),i=new Array(123),o=0;o<64;)i[n[o]=o<26?o+65:o<52?o+71:o<62?o-4:o-59|43]=o++;r.encode=function(e,t,r){for(var i,o=null,a=[],s=0,u=0;t>2],i=(3&c)<<4,u=1;break;case 1:a[s++]=n[i|c>>4],i=(15&c)<<2,u=2;break;case 2:a[s++]=n[i|c>>6],a[s++]=n[63&c],u=0}s>8191&&((o||(o=[])).push(String.fromCharCode.apply(String,a)),s=0)}return u&&(a[s++]=n[i],a[s++]=61,1===u&&(a[s++]=61)),o?(s&&o.push(String.fromCharCode.apply(String,a.slice(0,s))),o.join("")):String.fromCharCode.apply(String,a.slice(0,s))};var a="invalid encoding";r.decode=function(e,t,r){for(var n,o=r,s=0,u=0;u1)break;if(void 0===(c=i[c]))throw Error(a);switch(s){case 0:n=c,s=1;break;case 1:t[r++]=n<<2|(48&c)>>4,n=c,s=2;break;case 2:t[r++]=(15&n)<<4|(60&c)>>2,n=c,s=3;break;case 3:t[r++]=(3&n)<<6|c,s=0}}if(1===s)throw Error(a);return r-o},r.test=function(e){return/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(e)}},7988:function(e){"use strict";function t(e,r){"string"===typeof e&&(r=e,e=void 0);var n=[];function i(e){if("string"!==typeof e){var r=o();if(t.verbose&&console.log("codegen: "+r),r="return "+r,e){for(var a=Object.keys(e),s=new Array(a.length+1),u=new Array(a.length),c=0;c0?0:2147483648,r,n);else if(isNaN(t))e(2143289344,r,n);else if(t>34028234663852886e22)e((i<<31|2139095040)>>>0,r,n);else if(t<11754943508222875e-54)e((i<<31|Math.round(t/1401298464324817e-60))>>>0,r,n);else{var o=Math.floor(Math.log(t)/Math.LN2);e((i<<31|o+127<<23|8388607&Math.round(t*Math.pow(2,-o)*8388608))>>>0,r,n)}}function a(e,t,r){var n=e(t,r),i=2*(n>>31)+1,o=n>>>23&255,a=8388607&n;return 255===o?a?NaN:i*(1/0):0===o?1401298464324817e-60*i*a:i*Math.pow(2,o-150)*(a+8388608)}e.writeFloatLE=t.bind(null,r),e.writeFloatBE=t.bind(null,n),e.readFloatLE=a.bind(null,i),e.readFloatBE=a.bind(null,o)}(),"undefined"!==typeof Float64Array?function(){var t=new Float64Array([-0]),r=new Uint8Array(t.buffer),n=128===r[7];function i(e,n,i){t[0]=e,n[i]=r[0],n[i+1]=r[1],n[i+2]=r[2],n[i+3]=r[3],n[i+4]=r[4],n[i+5]=r[5],n[i+6]=r[6],n[i+7]=r[7]}function o(e,n,i){t[0]=e,n[i]=r[7],n[i+1]=r[6],n[i+2]=r[5],n[i+3]=r[4],n[i+4]=r[3],n[i+5]=r[2],n[i+6]=r[1],n[i+7]=r[0]}function a(e,n){return r[0]=e[n],r[1]=e[n+1],r[2]=e[n+2],r[3]=e[n+3],r[4]=e[n+4],r[5]=e[n+5],r[6]=e[n+6],r[7]=e[n+7],t[0]}function s(e,n){return r[7]=e[n],r[6]=e[n+1],r[5]=e[n+2],r[4]=e[n+3],r[3]=e[n+4],r[2]=e[n+5],r[1]=e[n+6],r[0]=e[n+7],t[0]}e.writeDoubleLE=n?i:o,e.writeDoubleBE=n?o:i,e.readDoubleLE=n?a:s,e.readDoubleBE=n?s:a}():function(){function t(e,t,r,n,i,o){var a=n<0?1:0;if(a&&(n=-n),0===n)e(0,i,o+t),e(1/n>0?0:2147483648,i,o+r);else if(isNaN(n))e(0,i,o+t),e(2146959360,i,o+r);else if(n>17976931348623157e292)e(0,i,o+t),e((a<<31|2146435072)>>>0,i,o+r);else{var s;if(n<22250738585072014e-324)e((s=n/5e-324)>>>0,i,o+t),e((a<<31|s/4294967296)>>>0,i,o+r);else{var u=Math.floor(Math.log(n)/Math.LN2);1024===u&&(u=1023),e(4503599627370496*(s=n*Math.pow(2,-u))>>>0,i,o+t),e((a<<31|u+1023<<20|1048576*s&1048575)>>>0,i,o+r)}}}function a(e,t,r,n,i){var o=e(n,i+t),a=e(n,i+r),s=2*(a>>31)+1,u=a>>>20&2047,c=4294967296*(1048575&a)+o;return 2047===u?c?NaN:s*(1/0):0===u?5e-324*s*c:s*Math.pow(2,u-1075)*(c+4503599627370496)}e.writeDoubleLE=t.bind(null,r,0,4),e.writeDoubleBE=t.bind(null,n,4,0),e.readDoubleLE=a.bind(null,i,0,4),e.readDoubleBE=a.bind(null,o,4,0)}(),e}function r(e,t,r){t[r]=255&e,t[r+1]=e>>>8&255,t[r+2]=e>>>16&255,t[r+3]=e>>>24}function n(e,t,r){t[r]=e>>>24,t[r+1]=e>>>16&255,t[r+2]=e>>>8&255,t[r+3]=255&e}function i(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0}function o(e,t){return(e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3])>>>0}e.exports=t(t)},861:function(module){"use strict";function inquire(moduleName){try{var mod=eval("quire".replace(/^/,"re"))(moduleName);if(mod&&(mod.length||Object.keys(mod).length))return mod}catch(e){}return null}module.exports=inquire},5310:function(e,t){"use strict";var r=t,n=r.isAbsolute=function(e){return/^(?:\/|\w+:)/.test(e)},i=r.normalize=function(e){var t=(e=e.replace(/\\/g,"/").replace(/\/{2,}/g,"/")).split("/"),r=n(e),i="";r&&(i=t.shift()+"/");for(var o=0;o0&&".."!==t[o-1]?t.splice(--o,2):r?t.splice(o,1):++o:"."===t[o]?t.splice(o,1):++o;return i+t.join("/")};r.resolve=function(e,t,r){return r||(t=i(t)),n(t)?t:(r||(e=i(e)),(e=e.replace(/(?:\/|^)[^/]+$/,"")).length?i(e+"/"+t):t)}},2888:function(e){"use strict";e.exports=function(e,t,r){var n=r||8192,i=n>>>1,o=null,a=n;return function(r){if(r<1||r>i)return e(r);a+r>n&&(o=e(n),a=0);var s=t.call(o,a,a+=r);return 7&a&&(a=1+(7|a)),s}}},1748:function(e,t){"use strict";var r=t;r.length=function(e){for(var t=0,r=0,n=0;n191&&n<224?o[a++]=(31&n)<<6|63&e[t++]:n>239&&n<365?(n=((7&n)<<18|(63&e[t++])<<12|(63&e[t++])<<6|63&e[t++])-65536,o[a++]=55296+(n>>10),o[a++]=56320+(1023&n)):o[a++]=(15&n)<<12|(63&e[t++])<<6|63&e[t++],a>8191&&((i||(i=[])).push(String.fromCharCode.apply(String,o)),a=0);return i?(a&&i.push(String.fromCharCode.apply(String,o.slice(0,a))),i.join("")):String.fromCharCode.apply(String,o.slice(0,a))},r.write=function(e,t,r){for(var n,i,o=r,a=0;a>6|192,t[r++]=63&n|128):55296===(64512&n)&&56320===(64512&(i=e.charCodeAt(a+1)))?(n=65536+((1023&n)<<10)+(1023&i),++a,t[r++]=n>>18|240,t[r++]=n>>12&63|128,t[r++]=n>>6&63|128,t[r++]=63&n|128):(t[r++]=n>>12|224,t[r++]=n>>6&63|128,t[r++]=63&n|128);return r-o}},2571:function(e){"use strict";for(var t="qpzry9x8gf2tvdw0s3jn54khce6mua7l",r={},n=0;n>25;return(33554431&e)<<5^996825010&-(t>>0&1)^642813549&-(t>>1&1)^513874426&-(t>>2&1)^1027748829&-(t>>3&1)^705979059&-(t>>4&1)}function a(e){for(var t=1,r=0;r126)return"Invalid prefix ("+e+")";t=o(t)^n>>5}for(t=o(t),r=0;rt)return"Exceeds length limit";var n=e.toLowerCase(),i=e.toUpperCase();if(e!==n&&e!==i)return"Mixed-case string "+e;var s=(e=n).lastIndexOf("1");if(-1===s)return"No separator character for "+e;if(0===s)return"Missing prefix for "+e;var u=e.slice(0,s),c=e.slice(s+1);if(c.length<6)return"Data too short";var l=a(u);if("string"===typeof l)return l;for(var f=[],h=0;h=c.length||f.push(p)}return 1!==l?"Invalid checksum for "+e:{prefix:u,words:f}}function u(e,t,r,n){for(var i=0,o=0,a=(1<=r;)o-=r,s.push(i>>o&a);if(n)o>0&&s.push(i<=t)return"Excess padding";if(i<n)throw new TypeError("Exceeds length limit");var i=a(e=e.toLowerCase());if("string"===typeof i)throw new Error(i);for(var s=e+"1",u=0;u>5!==0)throw new Error("Non 5-bit word");i=o(i)^c,s+=t.charAt(c)}for(u=0;u<6;++u)i=o(i);for(i^=1,u=0;u<6;++u){s+=t.charAt(i>>5*(5-u)&31)}return s},toWordsUnsafe:function(e){var t=u(e,8,5,!0);if(Array.isArray(t))return t},toWords:function(e){var t=u(e,8,5,!0);if(Array.isArray(t))return t;throw new Error(t)},fromWordsUnsafe:function(e){var t=u(e,5,8,!1);if(Array.isArray(t))return t},fromWords:function(e){var t=u(e,5,8,!1);if(Array.isArray(t))return t;throw new Error(t)}}},9867:function(e,t,r){!function(e,t){"use strict";function n(e,t){if(!e)throw new Error(t||"Assertion failed")}function i(e,t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e}function o(e,t,r){if(o.isBN(e))return e;this.negative=0,this.words=null,this.length=0,this.red=null,null!==e&&("le"!==t&&"be"!==t||(r=t,t=10),this._init(e||0,t||10,r||"be"))}var a;"object"===typeof e?e.exports=o:t.BN=o,o.BN=o,o.wordSize=26;try{a="undefined"!==typeof window&&"undefined"!==typeof window.Buffer?window.Buffer:r(9391).Buffer}catch(C){}function s(e,t){var r=e.charCodeAt(t);return r>=48&&r<=57?r-48:r>=65&&r<=70?r-55:r>=97&&r<=102?r-87:void n(!1,"Invalid character in "+e)}function u(e,t,r){var n=s(e,r);return r-1>=t&&(n|=s(e,r-1)<<4),n}function c(e,t,r,i){for(var o=0,a=0,s=Math.min(e.length,r),u=t;u=49?c-49+10:c>=17?c-17+10:c,n(c>=0&&a0?e:t},o.min=function(e,t){return e.cmp(t)<0?e:t},o.prototype._init=function(e,t,r){if("number"===typeof e)return this._initNumber(e,t,r);if("object"===typeof e)return this._initArray(e,t,r);"hex"===t&&(t=16),n(t===(0|t)&&t>=2&&t<=36);var i=0;"-"===(e=e.toString().replace(/\s+/g,""))[0]&&(i++,this.negative=1),i=0;i-=3)a=e[i]|e[i-1]<<8|e[i-2]<<16,this.words[o]|=a<>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);else if("le"===r)for(i=0,o=0;i>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);return this._strip()},o.prototype._parseHex=function(e,t,r){this.length=Math.ceil((e.length-t)/6),this.words=new Array(this.length);for(var n=0;n=t;n-=2)i=u(e,t,n)<=18?(o-=18,a+=1,this.words[a]|=i>>>26):o+=8;else for(n=(e.length-t)%2===0?t+1:t;n=18?(o-=18,a+=1,this.words[a]|=i>>>26):o+=8;this._strip()},o.prototype._parseBase=function(e,t,r){this.words=[0],this.length=1;for(var n=0,i=1;i<=67108863;i*=t)n++;n--,i=i/t|0;for(var o=e.length-r,a=o%n,s=Math.min(o,o-a)+r,u=0,l=r;l1&&0===this.words[this.length-1];)this.length--;return this._normSign()},o.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},"undefined"!==typeof Symbol&&"function"===typeof Symbol.for)try{o.prototype[Symbol.for("nodejs.util.inspect.custom")]=f}catch(C){o.prototype.inspect=f}else o.prototype.inspect=f;function f(){return(this.red?""}var h=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],d=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],p=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];o.prototype.toString=function(e,t){var r;if(t=0|t||1,16===(e=e||10)||"hex"===e){r="";for(var i=0,o=0,a=0;a>>24-i&16777215,(i+=2)>=26&&(i-=26,a--),r=0!==o||a!==this.length-1?h[6-u.length]+u+r:u+r}for(0!==o&&(r=o.toString(16)+r);r.length%t!==0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}if(e===(0|e)&&e>=2&&e<=36){var c=d[e],l=p[e];r="";var f=this.clone();for(f.negative=0;!f.isZero();){var v=f.modrn(l).toString(e);r=(f=f.idivn(l)).isZero()?v+r:h[c-v.length]+v+r}for(this.isZero()&&(r="0"+r);r.length%t!==0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}n(!1,"Base should be between 2 and 36")},o.prototype.toNumber=function(){var e=this.words[0];return 2===this.length?e+=67108864*this.words[1]:3===this.length&&1===this.words[2]?e+=4503599627370496+67108864*this.words[1]:this.length>2&&n(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-e:e},o.prototype.toJSON=function(){return this.toString(16,2)},a&&(o.prototype.toBuffer=function(e,t){return this.toArrayLike(a,e,t)}),o.prototype.toArray=function(e,t){return this.toArrayLike(Array,e,t)};function v(e,t,r){r.negative=t.negative^e.negative;var n=e.length+t.length|0;r.length=n,n=n-1|0;var i=0|e.words[0],o=0|t.words[0],a=i*o,s=67108863&a,u=a/67108864|0;r.words[0]=s;for(var c=1;c>>26,f=67108863&u,h=Math.min(c,t.length-1),d=Math.max(0,c-e.length+1);d<=h;d++){var p=c-d|0;l+=(a=(i=0|e.words[p])*(o=0|t.words[d])+f)/67108864|0,f=67108863&a}r.words[c]=0|f,u=0|l}return 0!==u?r.words[c]=0|u:r.length--,r._strip()}o.prototype.toArrayLike=function(e,t,r){this._strip();var i=this.byteLength(),o=r||Math.max(1,i);n(i<=o,"byte array longer than desired length"),n(o>0,"Requested array length <= 0");var a=function(e,t){return e.allocUnsafe?e.allocUnsafe(t):new e(t)}(e,o);return this["_toArrayLike"+("le"===t?"LE":"BE")](a,i),a},o.prototype._toArrayLikeLE=function(e,t){for(var r=0,n=0,i=0,o=0;i>8&255),r>16&255),6===o?(r>24&255),n=0,o=0):(n=a>>>24,o+=2)}if(r=0&&(e[r--]=a>>8&255),r>=0&&(e[r--]=a>>16&255),6===o?(r>=0&&(e[r--]=a>>24&255),n=0,o=0):(n=a>>>24,o+=2)}if(r>=0)for(e[r--]=n;r>=0;)e[r--]=0},Math.clz32?o.prototype._countBits=function(e){return 32-Math.clz32(e)}:o.prototype._countBits=function(e){var t=e,r=0;return t>=4096&&(r+=13,t>>>=13),t>=64&&(r+=7,t>>>=7),t>=8&&(r+=4,t>>>=4),t>=2&&(r+=2,t>>>=2),r+t},o.prototype._zeroBits=function(e){if(0===e)return 26;var t=e,r=0;return 0===(8191&t)&&(r+=13,t>>>=13),0===(127&t)&&(r+=7,t>>>=7),0===(15&t)&&(r+=4,t>>>=4),0===(3&t)&&(r+=2,t>>>=2),0===(1&t)&&r++,r},o.prototype.bitLength=function(){var e=this.words[this.length-1],t=this._countBits(e);return 26*(this.length-1)+t},o.prototype.zeroBits=function(){if(this.isZero())return 0;for(var e=0,t=0;te.length?this.clone().ior(e):e.clone().ior(this)},o.prototype.uor=function(e){return this.length>e.length?this.clone().iuor(e):e.clone().iuor(this)},o.prototype.iuand=function(e){var t;t=this.length>e.length?e:this;for(var r=0;re.length?this.clone().iand(e):e.clone().iand(this)},o.prototype.uand=function(e){return this.length>e.length?this.clone().iuand(e):e.clone().iuand(this)},o.prototype.iuxor=function(e){var t,r;this.length>e.length?(t=this,r=e):(t=e,r=this);for(var n=0;ne.length?this.clone().ixor(e):e.clone().ixor(this)},o.prototype.uxor=function(e){return this.length>e.length?this.clone().iuxor(e):e.clone().iuxor(this)},o.prototype.inotn=function(e){n("number"===typeof e&&e>=0);var t=0|Math.ceil(e/26),r=e%26;this._expand(t),r>0&&t--;for(var i=0;i0&&(this.words[i]=~this.words[i]&67108863>>26-r),this._strip()},o.prototype.notn=function(e){return this.clone().inotn(e)},o.prototype.setn=function(e,t){n("number"===typeof e&&e>=0);var r=e/26|0,i=e%26;return this._expand(r+1),this.words[r]=t?this.words[r]|1<e.length?(r=this,n=e):(r=e,n=this);for(var i=0,o=0;o>>26;for(;0!==i&&o>>26;if(this.length=r.length,0!==i)this.words[this.length]=i,this.length++;else if(r!==this)for(;oe.length?this.clone().iadd(e):e.clone().iadd(this)},o.prototype.isub=function(e){if(0!==e.negative){e.negative=0;var t=this.iadd(e);return e.negative=1,t._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(e),this.negative=1,this._normSign();var r,n,i=this.cmp(e);if(0===i)return this.negative=0,this.length=1,this.words[0]=0,this;i>0?(r=this,n=e):(r=e,n=this);for(var o=0,a=0;a>26,this.words[a]=67108863&t;for(;0!==o&&a>26,this.words[a]=67108863&t;if(0===o&&a>>13,d=0|a[1],p=8191&d,v=d>>>13,g=0|a[2],y=8191&g,m=g>>>13,b=0|a[3],w=8191&b,k=b>>>13,E=0|a[4],x=8191&E,_=E>>>13,S=0|a[5],A=8191&S,I=S>>>13,C=0|a[6],T=8191&C,P=C>>>13,R=0|a[7],B=8191&R,M=R>>>13,N=0|a[8],O=8191&N,D=N>>>13,L=0|a[9],U=8191&L,F=L>>>13,z=0|s[0],Z=8191&z,j=z>>>13,q=0|s[1],K=8191&q,V=q>>>13,H=0|s[2],G=8191&H,W=H>>>13,Q=0|s[3],J=8191&Q,Y=Q>>>13,X=0|s[4],$=8191&X,ee=X>>>13,te=0|s[5],re=8191&te,ne=te>>>13,ie=0|s[6],oe=8191&ie,ae=ie>>>13,se=0|s[7],ue=8191&se,ce=se>>>13,le=0|s[8],fe=8191&le,he=le>>>13,de=0|s[9],pe=8191&de,ve=de>>>13;r.negative=e.negative^t.negative,r.length=19;var ge=(c+(n=Math.imul(f,Z))|0)+((8191&(i=(i=Math.imul(f,j))+Math.imul(h,Z)|0))<<13)|0;c=((o=Math.imul(h,j))+(i>>>13)|0)+(ge>>>26)|0,ge&=67108863,n=Math.imul(p,Z),i=(i=Math.imul(p,j))+Math.imul(v,Z)|0,o=Math.imul(v,j);var ye=(c+(n=n+Math.imul(f,K)|0)|0)+((8191&(i=(i=i+Math.imul(f,V)|0)+Math.imul(h,K)|0))<<13)|0;c=((o=o+Math.imul(h,V)|0)+(i>>>13)|0)+(ye>>>26)|0,ye&=67108863,n=Math.imul(y,Z),i=(i=Math.imul(y,j))+Math.imul(m,Z)|0,o=Math.imul(m,j),n=n+Math.imul(p,K)|0,i=(i=i+Math.imul(p,V)|0)+Math.imul(v,K)|0,o=o+Math.imul(v,V)|0;var me=(c+(n=n+Math.imul(f,G)|0)|0)+((8191&(i=(i=i+Math.imul(f,W)|0)+Math.imul(h,G)|0))<<13)|0;c=((o=o+Math.imul(h,W)|0)+(i>>>13)|0)+(me>>>26)|0,me&=67108863,n=Math.imul(w,Z),i=(i=Math.imul(w,j))+Math.imul(k,Z)|0,o=Math.imul(k,j),n=n+Math.imul(y,K)|0,i=(i=i+Math.imul(y,V)|0)+Math.imul(m,K)|0,o=o+Math.imul(m,V)|0,n=n+Math.imul(p,G)|0,i=(i=i+Math.imul(p,W)|0)+Math.imul(v,G)|0,o=o+Math.imul(v,W)|0;var be=(c+(n=n+Math.imul(f,J)|0)|0)+((8191&(i=(i=i+Math.imul(f,Y)|0)+Math.imul(h,J)|0))<<13)|0;c=((o=o+Math.imul(h,Y)|0)+(i>>>13)|0)+(be>>>26)|0,be&=67108863,n=Math.imul(x,Z),i=(i=Math.imul(x,j))+Math.imul(_,Z)|0,o=Math.imul(_,j),n=n+Math.imul(w,K)|0,i=(i=i+Math.imul(w,V)|0)+Math.imul(k,K)|0,o=o+Math.imul(k,V)|0,n=n+Math.imul(y,G)|0,i=(i=i+Math.imul(y,W)|0)+Math.imul(m,G)|0,o=o+Math.imul(m,W)|0,n=n+Math.imul(p,J)|0,i=(i=i+Math.imul(p,Y)|0)+Math.imul(v,J)|0,o=o+Math.imul(v,Y)|0;var we=(c+(n=n+Math.imul(f,$)|0)|0)+((8191&(i=(i=i+Math.imul(f,ee)|0)+Math.imul(h,$)|0))<<13)|0;c=((o=o+Math.imul(h,ee)|0)+(i>>>13)|0)+(we>>>26)|0,we&=67108863,n=Math.imul(A,Z),i=(i=Math.imul(A,j))+Math.imul(I,Z)|0,o=Math.imul(I,j),n=n+Math.imul(x,K)|0,i=(i=i+Math.imul(x,V)|0)+Math.imul(_,K)|0,o=o+Math.imul(_,V)|0,n=n+Math.imul(w,G)|0,i=(i=i+Math.imul(w,W)|0)+Math.imul(k,G)|0,o=o+Math.imul(k,W)|0,n=n+Math.imul(y,J)|0,i=(i=i+Math.imul(y,Y)|0)+Math.imul(m,J)|0,o=o+Math.imul(m,Y)|0,n=n+Math.imul(p,$)|0,i=(i=i+Math.imul(p,ee)|0)+Math.imul(v,$)|0,o=o+Math.imul(v,ee)|0;var ke=(c+(n=n+Math.imul(f,re)|0)|0)+((8191&(i=(i=i+Math.imul(f,ne)|0)+Math.imul(h,re)|0))<<13)|0;c=((o=o+Math.imul(h,ne)|0)+(i>>>13)|0)+(ke>>>26)|0,ke&=67108863,n=Math.imul(T,Z),i=(i=Math.imul(T,j))+Math.imul(P,Z)|0,o=Math.imul(P,j),n=n+Math.imul(A,K)|0,i=(i=i+Math.imul(A,V)|0)+Math.imul(I,K)|0,o=o+Math.imul(I,V)|0,n=n+Math.imul(x,G)|0,i=(i=i+Math.imul(x,W)|0)+Math.imul(_,G)|0,o=o+Math.imul(_,W)|0,n=n+Math.imul(w,J)|0,i=(i=i+Math.imul(w,Y)|0)+Math.imul(k,J)|0,o=o+Math.imul(k,Y)|0,n=n+Math.imul(y,$)|0,i=(i=i+Math.imul(y,ee)|0)+Math.imul(m,$)|0,o=o+Math.imul(m,ee)|0,n=n+Math.imul(p,re)|0,i=(i=i+Math.imul(p,ne)|0)+Math.imul(v,re)|0,o=o+Math.imul(v,ne)|0;var Ee=(c+(n=n+Math.imul(f,oe)|0)|0)+((8191&(i=(i=i+Math.imul(f,ae)|0)+Math.imul(h,oe)|0))<<13)|0;c=((o=o+Math.imul(h,ae)|0)+(i>>>13)|0)+(Ee>>>26)|0,Ee&=67108863,n=Math.imul(B,Z),i=(i=Math.imul(B,j))+Math.imul(M,Z)|0,o=Math.imul(M,j),n=n+Math.imul(T,K)|0,i=(i=i+Math.imul(T,V)|0)+Math.imul(P,K)|0,o=o+Math.imul(P,V)|0,n=n+Math.imul(A,G)|0,i=(i=i+Math.imul(A,W)|0)+Math.imul(I,G)|0,o=o+Math.imul(I,W)|0,n=n+Math.imul(x,J)|0,i=(i=i+Math.imul(x,Y)|0)+Math.imul(_,J)|0,o=o+Math.imul(_,Y)|0,n=n+Math.imul(w,$)|0,i=(i=i+Math.imul(w,ee)|0)+Math.imul(k,$)|0,o=o+Math.imul(k,ee)|0,n=n+Math.imul(y,re)|0,i=(i=i+Math.imul(y,ne)|0)+Math.imul(m,re)|0,o=o+Math.imul(m,ne)|0,n=n+Math.imul(p,oe)|0,i=(i=i+Math.imul(p,ae)|0)+Math.imul(v,oe)|0,o=o+Math.imul(v,ae)|0;var xe=(c+(n=n+Math.imul(f,ue)|0)|0)+((8191&(i=(i=i+Math.imul(f,ce)|0)+Math.imul(h,ue)|0))<<13)|0;c=((o=o+Math.imul(h,ce)|0)+(i>>>13)|0)+(xe>>>26)|0,xe&=67108863,n=Math.imul(O,Z),i=(i=Math.imul(O,j))+Math.imul(D,Z)|0,o=Math.imul(D,j),n=n+Math.imul(B,K)|0,i=(i=i+Math.imul(B,V)|0)+Math.imul(M,K)|0,o=o+Math.imul(M,V)|0,n=n+Math.imul(T,G)|0,i=(i=i+Math.imul(T,W)|0)+Math.imul(P,G)|0,o=o+Math.imul(P,W)|0,n=n+Math.imul(A,J)|0,i=(i=i+Math.imul(A,Y)|0)+Math.imul(I,J)|0,o=o+Math.imul(I,Y)|0,n=n+Math.imul(x,$)|0,i=(i=i+Math.imul(x,ee)|0)+Math.imul(_,$)|0,o=o+Math.imul(_,ee)|0,n=n+Math.imul(w,re)|0,i=(i=i+Math.imul(w,ne)|0)+Math.imul(k,re)|0,o=o+Math.imul(k,ne)|0,n=n+Math.imul(y,oe)|0,i=(i=i+Math.imul(y,ae)|0)+Math.imul(m,oe)|0,o=o+Math.imul(m,ae)|0,n=n+Math.imul(p,ue)|0,i=(i=i+Math.imul(p,ce)|0)+Math.imul(v,ue)|0,o=o+Math.imul(v,ce)|0;var _e=(c+(n=n+Math.imul(f,fe)|0)|0)+((8191&(i=(i=i+Math.imul(f,he)|0)+Math.imul(h,fe)|0))<<13)|0;c=((o=o+Math.imul(h,he)|0)+(i>>>13)|0)+(_e>>>26)|0,_e&=67108863,n=Math.imul(U,Z),i=(i=Math.imul(U,j))+Math.imul(F,Z)|0,o=Math.imul(F,j),n=n+Math.imul(O,K)|0,i=(i=i+Math.imul(O,V)|0)+Math.imul(D,K)|0,o=o+Math.imul(D,V)|0,n=n+Math.imul(B,G)|0,i=(i=i+Math.imul(B,W)|0)+Math.imul(M,G)|0,o=o+Math.imul(M,W)|0,n=n+Math.imul(T,J)|0,i=(i=i+Math.imul(T,Y)|0)+Math.imul(P,J)|0,o=o+Math.imul(P,Y)|0,n=n+Math.imul(A,$)|0,i=(i=i+Math.imul(A,ee)|0)+Math.imul(I,$)|0,o=o+Math.imul(I,ee)|0,n=n+Math.imul(x,re)|0,i=(i=i+Math.imul(x,ne)|0)+Math.imul(_,re)|0,o=o+Math.imul(_,ne)|0,n=n+Math.imul(w,oe)|0,i=(i=i+Math.imul(w,ae)|0)+Math.imul(k,oe)|0,o=o+Math.imul(k,ae)|0,n=n+Math.imul(y,ue)|0,i=(i=i+Math.imul(y,ce)|0)+Math.imul(m,ue)|0,o=o+Math.imul(m,ce)|0,n=n+Math.imul(p,fe)|0,i=(i=i+Math.imul(p,he)|0)+Math.imul(v,fe)|0,o=o+Math.imul(v,he)|0;var Se=(c+(n=n+Math.imul(f,pe)|0)|0)+((8191&(i=(i=i+Math.imul(f,ve)|0)+Math.imul(h,pe)|0))<<13)|0;c=((o=o+Math.imul(h,ve)|0)+(i>>>13)|0)+(Se>>>26)|0,Se&=67108863,n=Math.imul(U,K),i=(i=Math.imul(U,V))+Math.imul(F,K)|0,o=Math.imul(F,V),n=n+Math.imul(O,G)|0,i=(i=i+Math.imul(O,W)|0)+Math.imul(D,G)|0,o=o+Math.imul(D,W)|0,n=n+Math.imul(B,J)|0,i=(i=i+Math.imul(B,Y)|0)+Math.imul(M,J)|0,o=o+Math.imul(M,Y)|0,n=n+Math.imul(T,$)|0,i=(i=i+Math.imul(T,ee)|0)+Math.imul(P,$)|0,o=o+Math.imul(P,ee)|0,n=n+Math.imul(A,re)|0,i=(i=i+Math.imul(A,ne)|0)+Math.imul(I,re)|0,o=o+Math.imul(I,ne)|0,n=n+Math.imul(x,oe)|0,i=(i=i+Math.imul(x,ae)|0)+Math.imul(_,oe)|0,o=o+Math.imul(_,ae)|0,n=n+Math.imul(w,ue)|0,i=(i=i+Math.imul(w,ce)|0)+Math.imul(k,ue)|0,o=o+Math.imul(k,ce)|0,n=n+Math.imul(y,fe)|0,i=(i=i+Math.imul(y,he)|0)+Math.imul(m,fe)|0,o=o+Math.imul(m,he)|0;var Ae=(c+(n=n+Math.imul(p,pe)|0)|0)+((8191&(i=(i=i+Math.imul(p,ve)|0)+Math.imul(v,pe)|0))<<13)|0;c=((o=o+Math.imul(v,ve)|0)+(i>>>13)|0)+(Ae>>>26)|0,Ae&=67108863,n=Math.imul(U,G),i=(i=Math.imul(U,W))+Math.imul(F,G)|0,o=Math.imul(F,W),n=n+Math.imul(O,J)|0,i=(i=i+Math.imul(O,Y)|0)+Math.imul(D,J)|0,o=o+Math.imul(D,Y)|0,n=n+Math.imul(B,$)|0,i=(i=i+Math.imul(B,ee)|0)+Math.imul(M,$)|0,o=o+Math.imul(M,ee)|0,n=n+Math.imul(T,re)|0,i=(i=i+Math.imul(T,ne)|0)+Math.imul(P,re)|0,o=o+Math.imul(P,ne)|0,n=n+Math.imul(A,oe)|0,i=(i=i+Math.imul(A,ae)|0)+Math.imul(I,oe)|0,o=o+Math.imul(I,ae)|0,n=n+Math.imul(x,ue)|0,i=(i=i+Math.imul(x,ce)|0)+Math.imul(_,ue)|0,o=o+Math.imul(_,ce)|0,n=n+Math.imul(w,fe)|0,i=(i=i+Math.imul(w,he)|0)+Math.imul(k,fe)|0,o=o+Math.imul(k,he)|0;var Ie=(c+(n=n+Math.imul(y,pe)|0)|0)+((8191&(i=(i=i+Math.imul(y,ve)|0)+Math.imul(m,pe)|0))<<13)|0;c=((o=o+Math.imul(m,ve)|0)+(i>>>13)|0)+(Ie>>>26)|0,Ie&=67108863,n=Math.imul(U,J),i=(i=Math.imul(U,Y))+Math.imul(F,J)|0,o=Math.imul(F,Y),n=n+Math.imul(O,$)|0,i=(i=i+Math.imul(O,ee)|0)+Math.imul(D,$)|0,o=o+Math.imul(D,ee)|0,n=n+Math.imul(B,re)|0,i=(i=i+Math.imul(B,ne)|0)+Math.imul(M,re)|0,o=o+Math.imul(M,ne)|0,n=n+Math.imul(T,oe)|0,i=(i=i+Math.imul(T,ae)|0)+Math.imul(P,oe)|0,o=o+Math.imul(P,ae)|0,n=n+Math.imul(A,ue)|0,i=(i=i+Math.imul(A,ce)|0)+Math.imul(I,ue)|0,o=o+Math.imul(I,ce)|0,n=n+Math.imul(x,fe)|0,i=(i=i+Math.imul(x,he)|0)+Math.imul(_,fe)|0,o=o+Math.imul(_,he)|0;var Ce=(c+(n=n+Math.imul(w,pe)|0)|0)+((8191&(i=(i=i+Math.imul(w,ve)|0)+Math.imul(k,pe)|0))<<13)|0;c=((o=o+Math.imul(k,ve)|0)+(i>>>13)|0)+(Ce>>>26)|0,Ce&=67108863,n=Math.imul(U,$),i=(i=Math.imul(U,ee))+Math.imul(F,$)|0,o=Math.imul(F,ee),n=n+Math.imul(O,re)|0,i=(i=i+Math.imul(O,ne)|0)+Math.imul(D,re)|0,o=o+Math.imul(D,ne)|0,n=n+Math.imul(B,oe)|0,i=(i=i+Math.imul(B,ae)|0)+Math.imul(M,oe)|0,o=o+Math.imul(M,ae)|0,n=n+Math.imul(T,ue)|0,i=(i=i+Math.imul(T,ce)|0)+Math.imul(P,ue)|0,o=o+Math.imul(P,ce)|0,n=n+Math.imul(A,fe)|0,i=(i=i+Math.imul(A,he)|0)+Math.imul(I,fe)|0,o=o+Math.imul(I,he)|0;var Te=(c+(n=n+Math.imul(x,pe)|0)|0)+((8191&(i=(i=i+Math.imul(x,ve)|0)+Math.imul(_,pe)|0))<<13)|0;c=((o=o+Math.imul(_,ve)|0)+(i>>>13)|0)+(Te>>>26)|0,Te&=67108863,n=Math.imul(U,re),i=(i=Math.imul(U,ne))+Math.imul(F,re)|0,o=Math.imul(F,ne),n=n+Math.imul(O,oe)|0,i=(i=i+Math.imul(O,ae)|0)+Math.imul(D,oe)|0,o=o+Math.imul(D,ae)|0,n=n+Math.imul(B,ue)|0,i=(i=i+Math.imul(B,ce)|0)+Math.imul(M,ue)|0,o=o+Math.imul(M,ce)|0,n=n+Math.imul(T,fe)|0,i=(i=i+Math.imul(T,he)|0)+Math.imul(P,fe)|0,o=o+Math.imul(P,he)|0;var Pe=(c+(n=n+Math.imul(A,pe)|0)|0)+((8191&(i=(i=i+Math.imul(A,ve)|0)+Math.imul(I,pe)|0))<<13)|0;c=((o=o+Math.imul(I,ve)|0)+(i>>>13)|0)+(Pe>>>26)|0,Pe&=67108863,n=Math.imul(U,oe),i=(i=Math.imul(U,ae))+Math.imul(F,oe)|0,o=Math.imul(F,ae),n=n+Math.imul(O,ue)|0,i=(i=i+Math.imul(O,ce)|0)+Math.imul(D,ue)|0,o=o+Math.imul(D,ce)|0,n=n+Math.imul(B,fe)|0,i=(i=i+Math.imul(B,he)|0)+Math.imul(M,fe)|0,o=o+Math.imul(M,he)|0;var Re=(c+(n=n+Math.imul(T,pe)|0)|0)+((8191&(i=(i=i+Math.imul(T,ve)|0)+Math.imul(P,pe)|0))<<13)|0;c=((o=o+Math.imul(P,ve)|0)+(i>>>13)|0)+(Re>>>26)|0,Re&=67108863,n=Math.imul(U,ue),i=(i=Math.imul(U,ce))+Math.imul(F,ue)|0,o=Math.imul(F,ce),n=n+Math.imul(O,fe)|0,i=(i=i+Math.imul(O,he)|0)+Math.imul(D,fe)|0,o=o+Math.imul(D,he)|0;var Be=(c+(n=n+Math.imul(B,pe)|0)|0)+((8191&(i=(i=i+Math.imul(B,ve)|0)+Math.imul(M,pe)|0))<<13)|0;c=((o=o+Math.imul(M,ve)|0)+(i>>>13)|0)+(Be>>>26)|0,Be&=67108863,n=Math.imul(U,fe),i=(i=Math.imul(U,he))+Math.imul(F,fe)|0,o=Math.imul(F,he);var Me=(c+(n=n+Math.imul(O,pe)|0)|0)+((8191&(i=(i=i+Math.imul(O,ve)|0)+Math.imul(D,pe)|0))<<13)|0;c=((o=o+Math.imul(D,ve)|0)+(i>>>13)|0)+(Me>>>26)|0,Me&=67108863;var Ne=(c+(n=Math.imul(U,pe))|0)+((8191&(i=(i=Math.imul(U,ve))+Math.imul(F,pe)|0))<<13)|0;return c=((o=Math.imul(F,ve))+(i>>>13)|0)+(Ne>>>26)|0,Ne&=67108863,u[0]=ge,u[1]=ye,u[2]=me,u[3]=be,u[4]=we,u[5]=ke,u[6]=Ee,u[7]=xe,u[8]=_e,u[9]=Se,u[10]=Ae,u[11]=Ie,u[12]=Ce,u[13]=Te,u[14]=Pe,u[15]=Re,u[16]=Be,u[17]=Me,u[18]=Ne,0!==c&&(u[19]=c,r.length++),r};function y(e,t,r){r.negative=t.negative^e.negative,r.length=e.length+t.length;for(var n=0,i=0,o=0;o>>26)|0)>>>26,a&=67108863}r.words[o]=s,n=a,a=i}return 0!==n?r.words[o]=n:r.length--,r._strip()}function m(e,t,r){return y(e,t,r)}function b(e,t){this.x=e,this.y=t}Math.imul||(g=v),o.prototype.mulTo=function(e,t){var r=this.length+e.length;return 10===this.length&&10===e.length?g(this,e,t):r<63?v(this,e,t):r<1024?y(this,e,t):m(this,e,t)},b.prototype.makeRBT=function(e){for(var t=new Array(e),r=o.prototype._countBits(e)-1,n=0;n>=1;return n},b.prototype.permute=function(e,t,r,n,i,o){for(var a=0;a>>=1)i++;return 1<>>=13,r[2*a+1]=8191&o,o>>>=13;for(a=2*t;a>=26,r+=o/67108864|0,r+=a>>>26,this.words[i]=67108863&a}return 0!==r&&(this.words[i]=r,this.length++),t?this.ineg():this},o.prototype.muln=function(e){return this.clone().imuln(e)},o.prototype.sqr=function(){return this.mul(this)},o.prototype.isqr=function(){return this.imul(this.clone())},o.prototype.pow=function(e){var t=function(e){for(var t=new Array(e.bitLength()),r=0;r>>i&1}return t}(e);if(0===t.length)return new o(1);for(var r=this,n=0;n=0);var t,r=e%26,i=(e-r)/26,o=67108863>>>26-r<<26-r;if(0!==r){var a=0;for(t=0;t>>26-r}a&&(this.words[t]=a,this.length++)}if(0!==i){for(t=this.length-1;t>=0;t--)this.words[t+i]=this.words[t];for(t=0;t=0),i=t?(t-t%26)/26:0;var o=e%26,a=Math.min((e-o)/26,this.length),s=67108863^67108863>>>o<a)for(this.length-=a,c=0;c=0&&(0!==l||c>=i);c--){var f=0|this.words[c];this.words[c]=l<<26-o|f>>>o,l=f&s}return u&&0!==l&&(u.words[u.length++]=l),0===this.length&&(this.words[0]=0,this.length=1),this._strip()},o.prototype.ishrn=function(e,t,r){return n(0===this.negative),this.iushrn(e,t,r)},o.prototype.shln=function(e){return this.clone().ishln(e)},o.prototype.ushln=function(e){return this.clone().iushln(e)},o.prototype.shrn=function(e){return this.clone().ishrn(e)},o.prototype.ushrn=function(e){return this.clone().iushrn(e)},o.prototype.testn=function(e){n("number"===typeof e&&e>=0);var t=e%26,r=(e-t)/26,i=1<=0);var t=e%26,r=(e-t)/26;if(n(0===this.negative,"imaskn works only with positive numbers"),this.length<=r)return this;if(0!==t&&r++,this.length=Math.min(r,this.length),0!==t){var i=67108863^67108863>>>t<=67108864;t++)this.words[t]-=67108864,t===this.length-1?this.words[t+1]=1:this.words[t+1]++;return this.length=Math.max(this.length,t+1),this},o.prototype.isubn=function(e){if(n("number"===typeof e),n(e<67108864),e<0)return this.iaddn(-e);if(0!==this.negative)return this.negative=0,this.iaddn(e),this.negative=1,this;if(this.words[0]-=e,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var t=0;t>26)-(u/67108864|0),this.words[i+r]=67108863&o}for(;i>26,this.words[i+r]=67108863&o;if(0===s)return this._strip();for(n(-1===s),s=0,i=0;i>26,this.words[i]=67108863&o;return this.negative=1,this._strip()},o.prototype._wordDiv=function(e,t){var r=(this.length,e.length),n=this.clone(),i=e,a=0|i.words[i.length-1];0!==(r=26-this._countBits(a))&&(i=i.ushln(r),n.iushln(r),a=0|i.words[i.length-1]);var s,u=n.length-i.length;if("mod"!==t){(s=new o(null)).length=u+1,s.words=new Array(s.length);for(var c=0;c=0;f--){var h=67108864*(0|n.words[i.length+f])+(0|n.words[i.length+f-1]);for(h=Math.min(h/a|0,67108863),n._ishlnsubmul(i,h,f);0!==n.negative;)h--,n.negative=0,n._ishlnsubmul(i,1,f),n.isZero()||(n.negative^=1);s&&(s.words[f]=h)}return s&&s._strip(),n._strip(),"div"!==t&&0!==r&&n.iushrn(r),{div:s||null,mod:n}},o.prototype.divmod=function(e,t,r){return n(!e.isZero()),this.isZero()?{div:new o(0),mod:new o(0)}:0!==this.negative&&0===e.negative?(s=this.neg().divmod(e,t),"mod"!==t&&(i=s.div.neg()),"div"!==t&&(a=s.mod.neg(),r&&0!==a.negative&&a.iadd(e)),{div:i,mod:a}):0===this.negative&&0!==e.negative?(s=this.divmod(e.neg(),t),"mod"!==t&&(i=s.div.neg()),{div:i,mod:s.mod}):0!==(this.negative&e.negative)?(s=this.neg().divmod(e.neg(),t),"div"!==t&&(a=s.mod.neg(),r&&0!==a.negative&&a.isub(e)),{div:s.div,mod:a}):e.length>this.length||this.cmp(e)<0?{div:new o(0),mod:this}:1===e.length?"div"===t?{div:this.divn(e.words[0]),mod:null}:"mod"===t?{div:null,mod:new o(this.modrn(e.words[0]))}:{div:this.divn(e.words[0]),mod:new o(this.modrn(e.words[0]))}:this._wordDiv(e,t);var i,a,s},o.prototype.div=function(e){return this.divmod(e,"div",!1).div},o.prototype.mod=function(e){return this.divmod(e,"mod",!1).mod},o.prototype.umod=function(e){return this.divmod(e,"mod",!0).mod},o.prototype.divRound=function(e){var t=this.divmod(e);if(t.mod.isZero())return t.div;var r=0!==t.div.negative?t.mod.isub(e):t.mod,n=e.ushrn(1),i=e.andln(1),o=r.cmp(n);return o<0||1===i&&0===o?t.div:0!==t.div.negative?t.div.isubn(1):t.div.iaddn(1)},o.prototype.modrn=function(e){var t=e<0;t&&(e=-e),n(e<=67108863);for(var r=(1<<26)%e,i=0,o=this.length-1;o>=0;o--)i=(r*i+(0|this.words[o]))%e;return t?-i:i},o.prototype.modn=function(e){return this.modrn(e)},o.prototype.idivn=function(e){var t=e<0;t&&(e=-e),n(e<=67108863);for(var r=0,i=this.length-1;i>=0;i--){var o=(0|this.words[i])+67108864*r;this.words[i]=o/e|0,r=o%e}return this._strip(),t?this.ineg():this},o.prototype.divn=function(e){return this.clone().idivn(e)},o.prototype.egcd=function(e){n(0===e.negative),n(!e.isZero());var t=this,r=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var i=new o(1),a=new o(0),s=new o(0),u=new o(1),c=0;t.isEven()&&r.isEven();)t.iushrn(1),r.iushrn(1),++c;for(var l=r.clone(),f=t.clone();!t.isZero();){for(var h=0,d=1;0===(t.words[0]&d)&&h<26;++h,d<<=1);if(h>0)for(t.iushrn(h);h-- >0;)(i.isOdd()||a.isOdd())&&(i.iadd(l),a.isub(f)),i.iushrn(1),a.iushrn(1);for(var p=0,v=1;0===(r.words[0]&v)&&p<26;++p,v<<=1);if(p>0)for(r.iushrn(p);p-- >0;)(s.isOdd()||u.isOdd())&&(s.iadd(l),u.isub(f)),s.iushrn(1),u.iushrn(1);t.cmp(r)>=0?(t.isub(r),i.isub(s),a.isub(u)):(r.isub(t),s.isub(i),u.isub(a))}return{a:s,b:u,gcd:r.iushln(c)}},o.prototype._invmp=function(e){n(0===e.negative),n(!e.isZero());var t=this,r=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var i,a=new o(1),s=new o(0),u=r.clone();t.cmpn(1)>0&&r.cmpn(1)>0;){for(var c=0,l=1;0===(t.words[0]&l)&&c<26;++c,l<<=1);if(c>0)for(t.iushrn(c);c-- >0;)a.isOdd()&&a.iadd(u),a.iushrn(1);for(var f=0,h=1;0===(r.words[0]&h)&&f<26;++f,h<<=1);if(f>0)for(r.iushrn(f);f-- >0;)s.isOdd()&&s.iadd(u),s.iushrn(1);t.cmp(r)>=0?(t.isub(r),a.isub(s)):(r.isub(t),s.isub(a))}return(i=0===t.cmpn(1)?a:s).cmpn(0)<0&&i.iadd(e),i},o.prototype.gcd=function(e){if(this.isZero())return e.abs();if(e.isZero())return this.abs();var t=this.clone(),r=e.clone();t.negative=0,r.negative=0;for(var n=0;t.isEven()&&r.isEven();n++)t.iushrn(1),r.iushrn(1);for(;;){for(;t.isEven();)t.iushrn(1);for(;r.isEven();)r.iushrn(1);var i=t.cmp(r);if(i<0){var o=t;t=r,r=o}else if(0===i||0===r.cmpn(1))break;t.isub(r)}return r.iushln(n)},o.prototype.invm=function(e){return this.egcd(e).a.umod(e)},o.prototype.isEven=function(){return 0===(1&this.words[0])},o.prototype.isOdd=function(){return 1===(1&this.words[0])},o.prototype.andln=function(e){return this.words[0]&e},o.prototype.bincn=function(e){n("number"===typeof e);var t=e%26,r=(e-t)/26,i=1<>>26,s&=67108863,this.words[a]=s}return 0!==o&&(this.words[a]=o,this.length++),this},o.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},o.prototype.cmpn=function(e){var t,r=e<0;if(0!==this.negative&&!r)return-1;if(0===this.negative&&r)return 1;if(this._strip(),this.length>1)t=1;else{r&&(e=-e),n(e<=67108863,"Number is too big");var i=0|this.words[0];t=i===e?0:ie.length)return 1;if(this.length=0;r--){var n=0|this.words[r],i=0|e.words[r];if(n!==i){ni&&(t=1);break}}return t},o.prototype.gtn=function(e){return 1===this.cmpn(e)},o.prototype.gt=function(e){return 1===this.cmp(e)},o.prototype.gten=function(e){return this.cmpn(e)>=0},o.prototype.gte=function(e){return this.cmp(e)>=0},o.prototype.ltn=function(e){return-1===this.cmpn(e)},o.prototype.lt=function(e){return-1===this.cmp(e)},o.prototype.lten=function(e){return this.cmpn(e)<=0},o.prototype.lte=function(e){return this.cmp(e)<=0},o.prototype.eqn=function(e){return 0===this.cmpn(e)},o.prototype.eq=function(e){return 0===this.cmp(e)},o.red=function(e){return new A(e)},o.prototype.toRed=function(e){return n(!this.red,"Already a number in reduction context"),n(0===this.negative,"red works only with positives"),e.convertTo(this)._forceRed(e)},o.prototype.fromRed=function(){return n(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},o.prototype._forceRed=function(e){return this.red=e,this},o.prototype.forceRed=function(e){return n(!this.red,"Already a number in reduction context"),this._forceRed(e)},o.prototype.redAdd=function(e){return n(this.red,"redAdd works only with red numbers"),this.red.add(this,e)},o.prototype.redIAdd=function(e){return n(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,e)},o.prototype.redSub=function(e){return n(this.red,"redSub works only with red numbers"),this.red.sub(this,e)},o.prototype.redISub=function(e){return n(this.red,"redISub works only with red numbers"),this.red.isub(this,e)},o.prototype.redShl=function(e){return n(this.red,"redShl works only with red numbers"),this.red.shl(this,e)},o.prototype.redMul=function(e){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.mul(this,e)},o.prototype.redIMul=function(e){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.imul(this,e)},o.prototype.redSqr=function(){return n(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},o.prototype.redISqr=function(){return n(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},o.prototype.redSqrt=function(){return n(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},o.prototype.redInvm=function(){return n(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},o.prototype.redNeg=function(){return n(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},o.prototype.redPow=function(e){return n(this.red&&!e.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,e)};var w={k256:null,p224:null,p192:null,p25519:null};function k(e,t){this.name=e,this.p=new o(t,16),this.n=this.p.bitLength(),this.k=new o(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function E(){k.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function x(){k.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function _(){k.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function S(){k.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function A(e){if("string"===typeof e){var t=o._prime(e);this.m=t.p,this.prime=t}else n(e.gtn(1),"modulus must be greater than 1"),this.m=e,this.prime=null}function I(e){A.call(this,e),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new o(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}k.prototype._tmp=function(){var e=new o(null);return e.words=new Array(Math.ceil(this.n/13)),e},k.prototype.ireduce=function(e){var t,r=e;do{this.split(r,this.tmp),t=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(t>this.n);var n=t0?r.isub(this.p):void 0!==r.strip?r.strip():r._strip(),r},k.prototype.split=function(e,t){e.iushrn(this.n,0,t)},k.prototype.imulK=function(e){return e.imul(this.k)},i(E,k),E.prototype.split=function(e,t){for(var r=4194303,n=Math.min(e.length,9),i=0;i>>22,o=a}o>>>=22,e.words[i-10]=o,0===o&&e.length>10?e.length-=10:e.length-=9},E.prototype.imulK=function(e){e.words[e.length]=0,e.words[e.length+1]=0,e.length+=2;for(var t=0,r=0;r>>=26,e.words[r]=i,t=n}return 0!==t&&(e.words[e.length++]=t),e},o._prime=function(e){if(w[e])return w[e];var t;if("k256"===e)t=new E;else if("p224"===e)t=new x;else if("p192"===e)t=new _;else{if("p25519"!==e)throw new Error("Unknown prime "+e);t=new S}return w[e]=t,t},A.prototype._verify1=function(e){n(0===e.negative,"red works only with positives"),n(e.red,"red works only with red numbers")},A.prototype._verify2=function(e,t){n(0===(e.negative|t.negative),"red works only with positives"),n(e.red&&e.red===t.red,"red works only with red numbers")},A.prototype.imod=function(e){return this.prime?this.prime.ireduce(e)._forceRed(this):(l(e,e.umod(this.m)._forceRed(this)),e)},A.prototype.neg=function(e){return e.isZero()?e.clone():this.m.sub(e)._forceRed(this)},A.prototype.add=function(e,t){this._verify2(e,t);var r=e.add(t);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},A.prototype.iadd=function(e,t){this._verify2(e,t);var r=e.iadd(t);return r.cmp(this.m)>=0&&r.isub(this.m),r},A.prototype.sub=function(e,t){this._verify2(e,t);var r=e.sub(t);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},A.prototype.isub=function(e,t){this._verify2(e,t);var r=e.isub(t);return r.cmpn(0)<0&&r.iadd(this.m),r},A.prototype.shl=function(e,t){return this._verify1(e),this.imod(e.ushln(t))},A.prototype.imul=function(e,t){return this._verify2(e,t),this.imod(e.imul(t))},A.prototype.mul=function(e,t){return this._verify2(e,t),this.imod(e.mul(t))},A.prototype.isqr=function(e){return this.imul(e,e.clone())},A.prototype.sqr=function(e){return this.mul(e,e)},A.prototype.sqrt=function(e){if(e.isZero())return e.clone();var t=this.m.andln(3);if(n(t%2===1),3===t){var r=this.m.add(new o(1)).iushrn(2);return this.pow(e,r)}for(var i=this.m.subn(1),a=0;!i.isZero()&&0===i.andln(1);)a++,i.iushrn(1);n(!i.isZero());var s=new o(1).toRed(this),u=s.redNeg(),c=this.m.subn(1).iushrn(1),l=this.m.bitLength();for(l=new o(2*l*l).toRed(this);0!==this.pow(l,c).cmp(u);)l.redIAdd(u);for(var f=this.pow(l,i),h=this.pow(e,i.addn(1).iushrn(1)),d=this.pow(e,i),p=a;0!==d.cmp(s);){for(var v=d,g=0;0!==v.cmp(s);g++)v=v.redSqr();n(g=0;n--){for(var c=t.words[n],l=u-1;l>=0;l--){var f=c>>l&1;i!==r[0]&&(i=this.sqr(i)),0!==f||0!==a?(a<<=1,a|=f,(4===++s||0===n&&0===l)&&(i=this.mul(i,r[a]),s=0,a=0)):s=0}u=26}return i},A.prototype.convertTo=function(e){var t=e.umod(this.m);return t===e?t.clone():t},A.prototype.convertFrom=function(e){var t=e.clone();return t.red=null,t},o.mont=function(e){return new I(e)},i(I,A),I.prototype.convertTo=function(e){return this.imod(e.ushln(this.shift))},I.prototype.convertFrom=function(e){var t=this.imod(e.mul(this.rinv));return t.red=null,t},I.prototype.imul=function(e,t){if(e.isZero()||t.isZero())return e.words[0]=0,e.length=1,e;var r=e.imul(t),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),o=i;return i.cmp(this.m)>=0?o=i.isub(this.m):i.cmpn(0)<0&&(o=i.iadd(this.m)),o._forceRed(this)},I.prototype.mul=function(e,t){if(e.isZero()||t.isZero())return new o(0)._forceRed(this);var r=e.mul(t),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),a=i;return i.cmp(this.m)>=0?a=i.isub(this.m):i.cmpn(0)<0&&(a=i.iadd(this.m)),a._forceRed(this)},I.prototype.invm=function(e){return this.imod(e._invmp(this.m).mul(this.r2))._forceRed(this)}}(e=r.nmd(e),this)},5467:function(e,t,r){t.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;var r="color: "+this.color;t.splice(1,0,r,"color: inherit");var n=0,i=0;t[0].replace(/%[a-zA-Z%]/g,(function(e){"%%"!==e&&(n++,"%c"===e&&(i=n))})),t.splice(i,0,r)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(r){}},t.load=function(){var e;try{e=t.storage.getItem("debug")}catch(r){}!e&&"undefined"!==typeof process&&"env"in process&&(e={NODE_ENV:"production",PUBLIC_URL:"/rln-reaccts",WDS_SOCKET_HOST:void 0,WDS_SOCKET_PATH:void 0,WDS_SOCKET_PORT:void 0,FAST_REFRESH:!0}.DEBUG);return e},t.useColors=function(){if("undefined"!==typeof window&&window.process&&("renderer"===window.process.type||window.process.__nwjs))return!0;if("undefined"!==typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;return"undefined"!==typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!==typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!==typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!==typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},t.storage=function(){try{return localStorage}catch(e){}}(),t.destroy=function(){var e=!1;return function(){e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}}(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.log=console.debug||console.log||function(){},e.exports=r(3760)(t),e.exports.formatters.j=function(e){try{return JSON.stringify(e)}catch(t){return"[UnexpectedJSONParseError]: "+t.message}}},3760:function(e,t,r){var n=r(9616).default;e.exports=function(e){function t(e){var r,n,o,a=null;function s(){for(var e=arguments.length,n=new Array(e),i=0;i=r||t<-r))return t<0&&(t+=r),t=this._head+t&this._capacityMask,this._list[t]}},t.prototype.get=function(e){return this.peekAt(e)},t.prototype.peek=function(){if(this._head!==this._tail)return this._list[this._head]},t.prototype.peekFront=function(){return this.peek()},t.prototype.peekBack=function(){return this.peekAt(-1)},Object.defineProperty(t.prototype,"length",{get:function(){return this.size()}}),t.prototype.size=function(){return this._head===this._tail?0:this._headthis._capacity&&this.pop(),this._head1e4&&this._tail<=this._list.length>>>2&&this._shrinkArray(),t}},t.prototype.push=function(e){if(void 0===e)return this.size();var t=this._tail;return this._list[t]=e,this._tail=t+1&this._capacityMask,this._tail===this._head&&this._growArray(),this._capacity&&this.size()>this._capacity&&this.shift(),this._head1e4&&e<=t>>>2&&this._shrinkArray(),r}},t.prototype.removeOne=function(e){var t=e;if(t===(0|t)&&this._head!==this._tail){var r=this.size(),n=this._list.length;if(!(t>=r||t<-r)){t<0&&(t+=r),t=this._head+t&this._capacityMask;var i,o=this._list[t];if(e0;i--)this._list[t]=this._list[t=t-1+n&this._capacityMask];this._list[t]=void 0,this._head=this._head+1+n&this._capacityMask}else{for(i=r-1-e;i>0;i--)this._list[t]=this._list[t=t+1+n&this._capacityMask];this._list[t]=void 0,this._tail=this._tail-1+n&this._capacityMask}return o}}},t.prototype.remove=function(e,t){var r,n=e,i=t;if(n===(0|n)&&this._head!==this._tail){var o=this.size(),a=this._list.length;if(!(n>=o||n<-o||t<1)){if(n<0&&(n+=o),1===t||!t)return(r=new Array(1))[0]=this.removeOne(n),r;if(0===n&&n+t>=o)return r=this.toArray(),this.clear(),r;var s;for(n+t>o&&(t=o-n),r=new Array(t),s=0;s0;s--)this._list[n=n+1+a&this._capacityMask]=void 0;return r}if(0===e){for(this._head=this._head+t+a&this._capacityMask,s=t-1;s>0;s--)this._list[n=n+1+a&this._capacityMask]=void 0;return r}if(n0;s--)this.unshift(this._list[n=n-1+a&this._capacityMask]);for(n=this._head-1+a&this._capacityMask;i>0;)this._list[n=n-1+a&this._capacityMask]=void 0,i--;e<0&&(this._tail=n)}else{for(this._tail=n,n=n+t+a&this._capacityMask,s=o-(t+e);s>0;s--)this.push(this._list[n++]);for(n=this._tail;i>0;)this._list[n=n+1+a&this._capacityMask]=void 0,i--}return this._head<2&&this._tail>1e4&&this._tail<=a>>>2&&this._shrinkArray(),r}}},t.prototype.splice=function(e,t){var r=e;if(r===(0|r)){var n=this.size();if(r<0&&(r+=n),!(r>n)){if(arguments.length>2){var i,o,a,s=arguments.length,u=this._list.length,c=2;if(!n||r0&&(this._head=this._head+r+u&this._capacityMask)):(a=this.remove(r,t),this._head=this._head+r+u&this._capacityMask);s>c;)this.unshift(arguments[--s]);for(i=r;i>0;i--)this.unshift(o[i-1])}else{var l=(o=new Array(n-(r+t))).length;for(i=0;ithis._tail){for(t=this._head;t>>=1,this._capacityMask>>>=1},e.exports=t},5697:function(e){"use strict";function t(e,t){for(var r in t)Object.defineProperty(e,r,{value:t[r],enumerable:!0,configurable:!0});return e}e.exports=function(e,r,n){if(!e||"string"===typeof e)throw new TypeError("Please pass an Error to err-code");n||(n={}),"object"===typeof r&&(n=r,r=""),r&&(n.code=r);try{return t(e,n)}catch(o){n.message=e.message,n.stack=e.stack;var i=function(){};return i.prototype=Object.create(Object.getPrototypeOf(e)),t(new i,n)}}},693:function(e,t,r){var n=r(361).default,i=r(6117).default;e.exports=function(){"use strict";function e(t){if(n(this,e),!(t>0)||0!==(t-1&t))throw new Error("Max size for a FixedFIFO should be a power of two");this.buffer=new Array(t),this.mask=t-1,this.top=0,this.btm=0,this.next=null}return i(e,[{key:"push",value:function(e){return void 0===this.buffer[this.top]&&(this.buffer[this.top]=e,this.top=this.top+1&this.mask,!0)}},{key:"shift",value:function(){var e=this.buffer[this.btm];if(void 0!==e)return this.buffer[this.btm]=void 0,this.btm=this.btm+1&this.mask,e}},{key:"peek",value:function(){return this.buffer[this.btm]}},{key:"isEmpty",value:function(){return void 0===this.buffer[this.btm]}}]),e}()},1207:function(e,t,r){var n=r(361).default,i=r(6117).default,o=r(693);e.exports=function(){"use strict";function e(t){n(this,e),this.hwm=t||16,this.head=new o(this.hwm),this.tail=this.head}return i(e,[{key:"push",value:function(e){if(!this.head.push(e)){var t=this.head;this.head=t.next=new o(2*this.head.buffer.length),this.head.push(e)}}},{key:"shift",value:function(){var e=this.tail.shift();if(void 0===e&&this.tail.next){var t=this.tail.next;return this.tail.next=null,this.tail=t,this.tail.shift()}return e}},{key:"peek",value:function(){return this.tail.peek()}},{key:"isEmpty",value:function(){return this.head.isEmpty()}}]),e}()},7185:function(e,t,r){var n=t;n.utils=r(5542),n.common=r(1725),n.sha=r(3402),n.ripemd=r(6015),n.hmac=r(3859),n.sha1=n.sha.sha1,n.sha256=n.sha.sha256,n.sha224=n.sha.sha224,n.sha384=n.sha.sha384,n.sha512=n.sha.sha512,n.ripemd160=n.ripemd.ripemd160},1725:function(e,t,r){"use strict";var n=r(5542),i=r(6082);function o(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian="big",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}t.BlockHash=o,o.prototype.update=function(e,t){if(e=n.toArray(e,t),this.pending?this.pending=this.pending.concat(e):this.pending=e,this.pendingTotal+=e.length,this.pending.length>=this._delta8){var r=(e=this.pending).length%this._delta8;this.pending=e.slice(e.length-r,e.length),0===this.pending.length&&(this.pending=null),e=n.join32(e,0,e.length-r,this.endian);for(var i=0;i>>24&255,n[i++]=e>>>16&255,n[i++]=e>>>8&255,n[i++]=255&e}else for(n[i++]=255&e,n[i++]=e>>>8&255,n[i++]=e>>>16&255,n[i++]=e>>>24&255,n[i++]=0,n[i++]=0,n[i++]=0,n[i++]=0,o=8;othis.blockSize&&(e=(new this.Hash).update(e).digest()),i(e.length<=this.blockSize);for(var t=e.length;t>>3},t.g1_256=function(e){return n(e,17)^n(e,19)^e>>>10}},5542:function(e,t,r){"use strict";var n=r(6082),i=r(7022);function o(e,t){return 55296===(64512&e.charCodeAt(t))&&(!(t<0||t+1>=e.length)&&56320===(64512&e.charCodeAt(t+1)))}function a(e){return(e>>>24|e>>>8&65280|e<<8&16711680|(255&e)<<24)>>>0}function s(e){return 1===e.length?"0"+e:e}function u(e){return 7===e.length?"0"+e:6===e.length?"00"+e:5===e.length?"000"+e:4===e.length?"0000"+e:3===e.length?"00000"+e:2===e.length?"000000"+e:1===e.length?"0000000"+e:e}t.inherits=i,t.toArray=function(e,t){if(Array.isArray(e))return e.slice();if(!e)return[];var r=[];if("string"===typeof e)if(t){if("hex"===t)for((e=e.replace(/[^a-z0-9]+/gi,"")).length%2!==0&&(e="0"+e),i=0;i>6|192,r[n++]=63&a|128):o(e,i)?(a=65536+((1023&a)<<10)+(1023&e.charCodeAt(++i)),r[n++]=a>>18|240,r[n++]=a>>12&63|128,r[n++]=a>>6&63|128,r[n++]=63&a|128):(r[n++]=a>>12|224,r[n++]=a>>6&63|128,r[n++]=63&a|128)}else for(i=0;i>>0}return a},t.split32=function(e,t){for(var r=new Array(4*e.length),n=0,i=0;n>>24,r[i+1]=o>>>16&255,r[i+2]=o>>>8&255,r[i+3]=255&o):(r[i+3]=o>>>24,r[i+2]=o>>>16&255,r[i+1]=o>>>8&255,r[i]=255&o)}return r},t.rotr32=function(e,t){return e>>>t|e<<32-t},t.rotl32=function(e,t){return e<>>32-t},t.sum32=function(e,t){return e+t>>>0},t.sum32_3=function(e,t,r){return e+t+r>>>0},t.sum32_4=function(e,t,r,n){return e+t+r+n>>>0},t.sum32_5=function(e,t,r,n,i){return e+t+r+n+i>>>0},t.sum64=function(e,t,r,n){var i=e[t],o=n+e[t+1]>>>0,a=(o>>0,e[t+1]=o},t.sum64_hi=function(e,t,r,n){return(t+n>>>0>>0},t.sum64_lo=function(e,t,r,n){return t+n>>>0},t.sum64_4_hi=function(e,t,r,n,i,o,a,s){var u=0,c=t;return u+=(c=c+n>>>0)>>0)>>0)>>0},t.sum64_4_lo=function(e,t,r,n,i,o,a,s){return t+n+o+s>>>0},t.sum64_5_hi=function(e,t,r,n,i,o,a,s,u,c){var l=0,f=t;return l+=(f=f+n>>>0)>>0)>>0)>>0)>>0},t.sum64_5_lo=function(e,t,r,n,i,o,a,s,u,c){return t+n+o+s+c>>>0},t.rotr64_hi=function(e,t,r){return(t<<32-r|e>>>r)>>>0},t.rotr64_lo=function(e,t,r){return(e<<32-r|t>>>r)>>>0},t.shr64_hi=function(e,t,r){return e>>>r},t.shr64_lo=function(e,t,r){return(e<<32-r|t>>>r)>>>0}},2990:function(e,t,r){"use strict";var n=r(6782),i={childContextTypes:!0,contextType:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,getDerivedStateFromError:!0,getDerivedStateFromProps:!0,mixins:!0,propTypes:!0,type:!0},o={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0},a={$$typeof:!0,compare:!0,defaultProps:!0,displayName:!0,propTypes:!0,type:!0},s={};function u(e){return n.isMemo(e)?a:s[e.$$typeof]||i}s[n.ForwardRef]={$$typeof:!0,render:!0,defaultProps:!0,displayName:!0,propTypes:!0},s[n.Memo]=a;var c=Object.defineProperty,l=Object.getOwnPropertyNames,f=Object.getOwnPropertySymbols,h=Object.getOwnPropertyDescriptor,d=Object.getPrototypeOf,p=Object.prototype;e.exports=function e(t,r,n){if("string"!==typeof r){if(p){var i=d(r);i&&i!==p&&e(t,i,n)}var a=l(r);f&&(a=a.concat(f(r)));for(var s=u(t),v=u(r),g=0;g>5,this.byteCount=this.blockCount<<2,this.outputBlocks=r>>5,this.extraBytes=(31&r)>>3;for(var n=0;n<50;++n)this.s[n]=0}function O(e,t,r){N.call(this,e,t,r)}N.prototype.update=function(e){if(this.finalized)throw new Error("finalize already called");var t,r=typeof e;if("string"!==r){if("object"!==r)throw new Error(i);if(null===e)throw new Error(i);if(l&&e.constructor===ArrayBuffer)e=new Uint8Array(e);else if(!Array.isArray(e)&&(!l||!ArrayBuffer.isView(e)))throw new Error(i);t=!0}for(var n,o,a=this.blocks,s=this.byteCount,u=e.length,c=this.blockCount,f=0,h=this.s;f>2]|=e[f]<>2]|=o<>2]|=(192|o>>6)<>2]|=(128|63&o)<=57344?(a[n>>2]|=(224|o>>12)<>2]|=(128|o>>6&63)<>2]|=(128|63&o)<>2]|=(240|o>>18)<>2]|=(128|o>>12&63)<>2]|=(128|o>>6&63)<>2]|=(128|63&o)<=s){for(this.start=n-s,this.block=a[c],n=0;n>=8);r>0;)i.unshift(r),r=255&(e>>=8),++n;return t?i.push(n):i.unshift(n),this.update(i),i.length},N.prototype.encodeString=function(e){var t,r=typeof e;if("string"!==r){if("object"!==r)throw new Error(i);if(null===e)throw new Error(i);if(l&&e.constructor===ArrayBuffer)e=new Uint8Array(e);else if(!Array.isArray(e)&&(!l||!ArrayBuffer.isView(e)))throw new Error(i);t=!0}var n=0,o=e.length;if(t)n=o;else for(var a=0;a=57344?n+=3:(s=65536+((1023&s)<<10|1023&e.charCodeAt(++a)),n+=4)}return n+=this.encode(8*n),this.update(e),n},N.prototype.bytepad=function(e,t){for(var r=this.encode(t),n=0;n>2]|=this.padding[3&t],this.lastByteIndex===this.byteCount)for(e[0]=e[r],t=1;t>4&15]+f[15&e]+f[e>>12&15]+f[e>>8&15]+f[e>>20&15]+f[e>>16&15]+f[e>>28&15]+f[e>>24&15];a%t===0&&(D(r),o=0)}return i&&(e=r[o],s+=f[e>>4&15]+f[15&e],i>1&&(s+=f[e>>12&15]+f[e>>8&15]),i>2&&(s+=f[e>>20&15]+f[e>>16&15])),s},N.prototype.arrayBuffer=function(){this.finalize();var e,t=this.blockCount,r=this.s,n=this.outputBlocks,i=this.extraBytes,o=0,a=0,s=this.outputBits>>3;e=i?new ArrayBuffer(n+1<<2):new ArrayBuffer(s);for(var u=new Uint32Array(e);a>8&255,u[e+2]=t>>16&255,u[e+3]=t>>24&255;s%r===0&&D(n)}return o&&(e=s<<2,t=n[a],u[e]=255&t,o>1&&(u[e+1]=t>>8&255),o>2&&(u[e+2]=t>>16&255)),u},O.prototype=new N,O.prototype.finalize=function(){return this.encode(this.outputBits,!0),N.prototype.finalize.call(this)};var D=function(e){var t,r,n,i,o,a,s,u,c,l,f,h,d,v,g,y,m,b,w,k,E,x,_,S,A,I,C,T,P,R,B,M,N,O,D,L,U,F,z,Z,j,q,K,V,H,G,W,Q,J,Y,X,$,ee,te,re,ne,ie,oe,ae,se,ue,ce,le;for(n=0;n<48;n+=2)i=e[0]^e[10]^e[20]^e[30]^e[40],o=e[1]^e[11]^e[21]^e[31]^e[41],a=e[2]^e[12]^e[22]^e[32]^e[42],s=e[3]^e[13]^e[23]^e[33]^e[43],u=e[4]^e[14]^e[24]^e[34]^e[44],c=e[5]^e[15]^e[25]^e[35]^e[45],l=e[6]^e[16]^e[26]^e[36]^e[46],f=e[7]^e[17]^e[27]^e[37]^e[47],t=(h=e[8]^e[18]^e[28]^e[38]^e[48])^(a<<1|s>>>31),r=(d=e[9]^e[19]^e[29]^e[39]^e[49])^(s<<1|a>>>31),e[0]^=t,e[1]^=r,e[10]^=t,e[11]^=r,e[20]^=t,e[21]^=r,e[30]^=t,e[31]^=r,e[40]^=t,e[41]^=r,t=i^(u<<1|c>>>31),r=o^(c<<1|u>>>31),e[2]^=t,e[3]^=r,e[12]^=t,e[13]^=r,e[22]^=t,e[23]^=r,e[32]^=t,e[33]^=r,e[42]^=t,e[43]^=r,t=a^(l<<1|f>>>31),r=s^(f<<1|l>>>31),e[4]^=t,e[5]^=r,e[14]^=t,e[15]^=r,e[24]^=t,e[25]^=r,e[34]^=t,e[35]^=r,e[44]^=t,e[45]^=r,t=u^(h<<1|d>>>31),r=c^(d<<1|h>>>31),e[6]^=t,e[7]^=r,e[16]^=t,e[17]^=r,e[26]^=t,e[27]^=r,e[36]^=t,e[37]^=r,e[46]^=t,e[47]^=r,t=l^(i<<1|o>>>31),r=f^(o<<1|i>>>31),e[8]^=t,e[9]^=r,e[18]^=t,e[19]^=r,e[28]^=t,e[29]^=r,e[38]^=t,e[39]^=r,e[48]^=t,e[49]^=r,v=e[0],g=e[1],G=e[11]<<4|e[10]>>>28,W=e[10]<<4|e[11]>>>28,T=e[20]<<3|e[21]>>>29,P=e[21]<<3|e[20]>>>29,se=e[31]<<9|e[30]>>>23,ue=e[30]<<9|e[31]>>>23,q=e[40]<<18|e[41]>>>14,K=e[41]<<18|e[40]>>>14,O=e[2]<<1|e[3]>>>31,D=e[3]<<1|e[2]>>>31,y=e[13]<<12|e[12]>>>20,m=e[12]<<12|e[13]>>>20,Q=e[22]<<10|e[23]>>>22,J=e[23]<<10|e[22]>>>22,R=e[33]<<13|e[32]>>>19,B=e[32]<<13|e[33]>>>19,ce=e[42]<<2|e[43]>>>30,le=e[43]<<2|e[42]>>>30,te=e[5]<<30|e[4]>>>2,re=e[4]<<30|e[5]>>>2,L=e[14]<<6|e[15]>>>26,U=e[15]<<6|e[14]>>>26,b=e[25]<<11|e[24]>>>21,w=e[24]<<11|e[25]>>>21,Y=e[34]<<15|e[35]>>>17,X=e[35]<<15|e[34]>>>17,M=e[45]<<29|e[44]>>>3,N=e[44]<<29|e[45]>>>3,S=e[6]<<28|e[7]>>>4,A=e[7]<<28|e[6]>>>4,ne=e[17]<<23|e[16]>>>9,ie=e[16]<<23|e[17]>>>9,F=e[26]<<25|e[27]>>>7,z=e[27]<<25|e[26]>>>7,k=e[36]<<21|e[37]>>>11,E=e[37]<<21|e[36]>>>11,$=e[47]<<24|e[46]>>>8,ee=e[46]<<24|e[47]>>>8,V=e[8]<<27|e[9]>>>5,H=e[9]<<27|e[8]>>>5,I=e[18]<<20|e[19]>>>12,C=e[19]<<20|e[18]>>>12,oe=e[29]<<7|e[28]>>>25,ae=e[28]<<7|e[29]>>>25,Z=e[38]<<8|e[39]>>>24,j=e[39]<<8|e[38]>>>24,x=e[48]<<14|e[49]>>>18,_=e[49]<<14|e[48]>>>18,e[0]=v^~y&b,e[1]=g^~m&w,e[10]=S^~I&T,e[11]=A^~C&P,e[20]=O^~L&F,e[21]=D^~U&z,e[30]=V^~G&Q,e[31]=H^~W&J,e[40]=te^~ne&oe,e[41]=re^~ie&ae,e[2]=y^~b&k,e[3]=m^~w&E,e[12]=I^~T&R,e[13]=C^~P&B,e[22]=L^~F&Z,e[23]=U^~z&j,e[32]=G^~Q&Y,e[33]=W^~J&X,e[42]=ne^~oe&se,e[43]=ie^~ae&ue,e[4]=b^~k&x,e[5]=w^~E&_,e[14]=T^~R&M,e[15]=P^~B&N,e[24]=F^~Z&q,e[25]=z^~j&K,e[34]=Q^~Y&$,e[35]=J^~X&ee,e[44]=oe^~se&ce,e[45]=ae^~ue&le,e[6]=k^~x&v,e[7]=E^~_&g,e[16]=R^~M&S,e[17]=B^~N&A,e[26]=Z^~q&O,e[27]=j^~K&D,e[36]=Y^~$&V,e[37]=X^~ee&H,e[46]=se^~ce&te,e[47]=ue^~le&re,e[8]=x^~v&y,e[9]=_^~g&m,e[18]=M^~S&I,e[19]=N^~A&C,e[28]=q^~O&L,e[29]=K^~D&U,e[38]=$^~V&G,e[39]=ee^~H&W,e[48]=ce^~te&ne,e[49]=le^~re&ie,e[0]^=p[n],e[1]^=p[n+1]};if(u)e.exports=A;else{for(C=0;C0)return function(e){if((e=String(e)).length>100)return;var s=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(!s)return;var u=parseFloat(s[1]);switch((s[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return u*a;case"weeks":case"week":case"w":return u*o;case"days":case"day":case"d":return u*i;case"hours":case"hour":case"hrs":case"hr":case"h":return u*n;case"minutes":case"minute":case"mins":case"min":case"m":return u*r;case"seconds":case"second":case"secs":case"sec":case"s":return u*t;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return u;default:return}}(e);if("number"===c&&isFinite(e))return u.long?function(e){var o=Math.abs(e);if(o>=i)return s(e,o,i,"day");if(o>=n)return s(e,o,n,"hour");if(o>=r)return s(e,o,r,"minute");if(o>=t)return s(e,o,t,"second");return e+" ms"}(e):function(e){var o=Math.abs(e);if(o>=i)return Math.round(e/i)+"d";if(o>=n)return Math.round(e/n)+"h";if(o>=r)return Math.round(e/r)+"m";if(o>=t)return Math.round(e/t)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},9521:function(e,t,r){var n=r(3299);function i(e,t){n.cipher.registerAlgorithm(e,(function(){return new n.aes.Algorithm(e,t)}))}r(6894),r(2156),r(9327),e.exports=n.aes=n.aes||{},n.aes.startEncrypting=function(e,t,r,n){var i=p({key:e,output:r,decrypt:!1,mode:n});return i.start(t),i},n.aes.createEncryptionCipher=function(e,t){return p({key:e,output:null,decrypt:!1,mode:t})},n.aes.startDecrypting=function(e,t,r,n){var i=p({key:e,output:r,decrypt:!0,mode:n});return i.start(t),i},n.aes.createDecryptionCipher=function(e,t){return p({key:e,output:null,decrypt:!0,mode:t})},n.aes.Algorithm=function(e,t){l||f();var r=this;r.name=e,r.mode=new t({blockSize:16,cipher:{encrypt:function(e,t){return d(r._w,e,t,!1)},decrypt:function(e,t){return d(r._w,e,t,!0)}}}),r._init=!1},n.aes.Algorithm.prototype.initialize=function(e){if(!this._init){var t,r=e.key;if("string"!==typeof r||16!==r.length&&24!==r.length&&32!==r.length){if(n.util.isArray(r)&&(16===r.length||24===r.length||32===r.length)){t=r,r=n.util.createBuffer();for(var i=0;i>>=2;for(i=0;i>8^255&f^99,o[v]=f,a[f]=v,d=(h=e[f])<<24^f<<16^f<<8^f^h,p=((r=e[v])^(n=e[r])^(i=e[n]))<<24^(v^i)<<16^(v^n^i)<<8^v^r^i;for(var y=0;y<4;++y)u[y][v]=d,c[y][f]=p,d=d<<24|d>>>8,p=p<<24|p>>>8;0===v?v=g=1:(v=r^e[e[e[r^i]]],g^=e[e[g]])}}function h(e,t){for(var r,n=e.slice(0),i=1,a=n.length,u=4*(a+6+1),l=a;l>>16&255]<<24^o[r>>>8&255]<<16^o[255&r]<<8^o[r>>>24]^s[i]<<24,i++):a>6&&l%a===4&&(r=o[r>>>24]<<24^o[r>>>16&255]<<16^o[r>>>8&255]<<8^o[255&r]),n[l]=n[l-a]^r;if(t){for(var f,h=c[0],d=c[1],p=c[2],v=c[3],g=n.slice(0),y=(l=0,(u=n.length)-4);l>>24]]^d[o[f>>>16&255]]^p[o[f>>>8&255]]^v[o[255&f]];n=g}return n}function d(e,t,r,n){var i,s,l,f,h,d,p,v,g,y,m,b,w=e.length/4-1;n?(i=c[0],s=c[1],l=c[2],f=c[3],h=a):(i=u[0],s=u[1],l=u[2],f=u[3],h=o),d=t[0]^e[0],p=t[n?3:1]^e[1],v=t[2]^e[2],g=t[n?1:3]^e[3];for(var k=3,E=1;E>>24]^s[p>>>16&255]^l[v>>>8&255]^f[255&g]^e[++k],m=i[p>>>24]^s[v>>>16&255]^l[g>>>8&255]^f[255&d]^e[++k],b=i[v>>>24]^s[g>>>16&255]^l[d>>>8&255]^f[255&p]^e[++k],g=i[g>>>24]^s[d>>>16&255]^l[p>>>8&255]^f[255&v]^e[++k],d=y,p=m,v=b;r[0]=h[d>>>24]<<24^h[p>>>16&255]<<16^h[v>>>8&255]<<8^h[255&g]^e[++k],r[n?3:1]=h[p>>>24]<<24^h[v>>>16&255]<<16^h[g>>>8&255]<<8^h[255&d]^e[++k],r[2]=h[v>>>24]<<24^h[g>>>16&255]<<16^h[d>>>8&255]<<8^h[255&p]^e[++k],r[n?1:3]=h[g>>>24]<<24^h[d>>>16&255]<<16^h[p>>>8&255]<<8^h[255&v]^e[++k]}function p(e){var t,r="AES-"+((e=e||{}).mode||"CBC").toUpperCase(),i=(t=e.decrypt?n.cipher.createDecipher(r,e.key):n.cipher.createCipher(r,e.key)).start;return t.start=function(e,r){var o=null;r instanceof n.util.ByteBuffer&&(o=r,r={}),(r=r||{}).output=o,r.iv=e,i.call(t,r)},t}},5406:function(e,t,r){var n=r(3299);r(9327),r(2458);var i=e.exports=n.asn1=n.asn1||{};function o(e,t,r){if(r>t){var n=new Error("Too few bytes to parse DER.");throw n.available=e.length(),n.remaining=t,n.requested=r,n}}i.Class={UNIVERSAL:0,APPLICATION:64,CONTEXT_SPECIFIC:128,PRIVATE:192},i.Type={NONE:0,BOOLEAN:1,INTEGER:2,BITSTRING:3,OCTETSTRING:4,NULL:5,OID:6,ODESC:7,EXTERNAL:8,REAL:9,ENUMERATED:10,EMBEDDED:11,UTF8:12,ROID:13,SEQUENCE:16,SET:17,PRINTABLESTRING:19,IA5STRING:22,UTCTIME:23,GENERALIZEDTIME:24,BMPSTRING:30},i.create=function(e,t,r,o,a){if(n.util.isArray(o)){for(var s=[],u=0;ut){if(n.strict){var p=new Error("Too few bytes to read ASN.1 value.");throw p.available=e.length(),p.remaining=t,p.requested=d,p}d=t}var v=32===(32&u);if(v)if(f=[],void 0===d)for(;;){if(o(e,t,2),e.bytes(2)===String.fromCharCode(0,0)){e.getBytes(2),t-=2;break}s=e.length(),f.push(a(e,t,r+1,n)),t-=s-e.length()}else for(;d>0;)s=e.length(),f.push(a(e,d,r+1,n)),t-=s-e.length(),d-=s-e.length();if(void 0===f&&c===i.Class.UNIVERSAL&&l===i.Type.BITSTRING&&(h=e.bytes(d)),void 0===f&&n.decodeBitStrings&&c===i.Class.UNIVERSAL&&l===i.Type.BITSTRING&&d>1){var g=e.read,y=t,m=0;if(l===i.Type.BITSTRING&&(o(e,t,1),m=e.getByte(),t--),0===m)try{s=e.length();var b=a(e,t,r+1,{strict:!0,decodeBitStrings:!0}),w=s-e.length();t-=w,l==i.Type.BITSTRING&&w++;var k=b.tagClass;w!==d||k!==i.Class.UNIVERSAL&&k!==i.Class.CONTEXT_SPECIFIC||(f=[b])}catch(x){}void 0===f&&(e.read=g,t=y)}if(void 0===f){if(void 0===d){if(n.strict)throw new Error("Non-constructed ASN.1 object of indefinite length.");d=t}if(l===i.Type.BMPSTRING)for(f="";d>0;d-=2)o(e,t,2),f+=String.fromCharCode(e.getInt16()),t-=2;else f=e.getBytes(d),t-=d}var E=void 0===h?null:{bitStringContents:h};return i.create(c,l,v,f,E)}i.fromDer=function(e,t){void 0===t&&(t={strict:!0,parseAllBytes:!0,decodeBitStrings:!0}),"boolean"===typeof t&&(t={strict:t,parseAllBytes:!0,decodeBitStrings:!0}),"strict"in t||(t.strict=!0),"parseAllBytes"in t||(t.parseAllBytes=!0),"decodeBitStrings"in t||(t.decodeBitStrings=!0),"string"===typeof e&&(e=n.util.createBuffer(e));var r=e.length(),i=a(e,e.length(),0,t);if(t.parseAllBytes&&0!==e.length()){var o=new Error("Unparsed DER bytes remain after ASN.1 parsing.");throw o.byteCount=r,o.remaining=e.length(),o}return i},i.toDer=function(e){var t=n.util.createBuffer(),r=e.tagClass|e.type,o=n.util.createBuffer(),a=!1;if("bitStringContents"in e&&(a=!0,e.original&&(a=i.equals(e,e.original))),a)o.putBytes(e.bitStringContents);else if(e.composed){e.constructed?r|=32:o.putByte(0);for(var s=0;s1&&(0===e.value.charCodeAt(0)&&0===(128&e.value.charCodeAt(1))||255===e.value.charCodeAt(0)&&128===(128&e.value.charCodeAt(1)))?o.putBytes(e.value.substr(1)):o.putBytes(e.value);if(t.putByte(r),o.length()<=127)t.putByte(127&o.length());else{var u=o.length(),c="";do{c+=String.fromCharCode(255&u),u>>>=8}while(u>0);t.putByte(128|c.length);for(s=c.length-1;s>=0;--s)t.putByte(c.charCodeAt(s))}return t.putBuffer(o),t},i.oidToDer=function(e){var t,r,i,o,a=e.split("."),s=n.util.createBuffer();s.putByte(40*parseInt(a[0],10)+parseInt(a[1],10));for(var u=2;u>>=7,t||(o|=128),r.push(o),t=!1}while(i>0);for(var c=r.length-1;c>=0;--c)s.putByte(r[c])}return s},i.derToOid=function(e){var t;"string"===typeof e&&(e=n.util.createBuffer(e));var r=e.getByte();t=Math.floor(r/40)+"."+r%40;for(var i=0;e.length()>0;)i<<=7,128&(r=e.getByte())?i+=127&r:(t+="."+(i+r),i=0);return t},i.utcTimeToDate=function(e){var t=new Date,r=parseInt(e.substr(0,2),10);r=r>=50?1900+r:2e3+r;var n=parseInt(e.substr(2,2),10)-1,i=parseInt(e.substr(4,2),10),o=parseInt(e.substr(6,2),10),a=parseInt(e.substr(8,2),10),s=0;if(e.length>11){var u=e.charAt(10),c=10;"+"!==u&&"-"!==u&&(s=parseInt(e.substr(10,2),10),c+=2)}if(t.setUTCFullYear(r,n,i),t.setUTCHours(o,a,s,0),c&&("+"===(u=e.charAt(c))||"-"===u)){var l=60*parseInt(e.substr(c+1,2),10)+parseInt(e.substr(c+4,2),10);l*=6e4,"+"===u?t.setTime(+t-l):t.setTime(+t+l)}return t},i.generalizedTimeToDate=function(e){var t=new Date,r=parseInt(e.substr(0,4),10),n=parseInt(e.substr(4,2),10)-1,i=parseInt(e.substr(6,2),10),o=parseInt(e.substr(8,2),10),a=parseInt(e.substr(10,2),10),s=parseInt(e.substr(12,2),10),u=0,c=0,l=!1;"Z"===e.charAt(e.length-1)&&(l=!0);var f=e.length-5,h=e.charAt(f);"+"!==h&&"-"!==h||(c=60*parseInt(e.substr(f+1,2),10)+parseInt(e.substr(f+4,2),10),c*=6e4,"+"===h&&(c*=-1),l=!0);return"."===e.charAt(14)&&(u=1e3*parseFloat(e.substr(14),10)),l?(t.setUTCFullYear(r,n,i),t.setUTCHours(o,a,s,u),t.setTime(+t+c)):(t.setFullYear(r,n,i),t.setHours(o,a,s,u)),t},i.dateToUtcTime=function(e){if("string"===typeof e)return e;var t="",r=[];r.push((""+e.getUTCFullYear()).substr(2)),r.push(""+(e.getUTCMonth()+1)),r.push(""+e.getUTCDate()),r.push(""+e.getUTCHours()),r.push(""+e.getUTCMinutes()),r.push(""+e.getUTCSeconds());for(var n=0;n=-128&&e<128)return t.putSignedInt(e,8);if(e>=-32768&&e<32768)return t.putSignedInt(e,16);if(e>=-8388608&&e<8388608)return t.putSignedInt(e,24);if(e>=-2147483648&&e<2147483648)return t.putSignedInt(e,32);var r=new Error("Integer too large; max is 32-bits.");throw r.integer=e,r},i.derToInteger=function(e){"string"===typeof e&&(e=n.util.createBuffer(e));var t=8*e.length();if(t>32)throw new Error("Integer too large; max is 32-bits.");return e.getSignedInt(t)},i.validate=function(e,t,r,o){var a=!1;if(e.tagClass!==t.tagClass&&"undefined"!==typeof t.tagClass||e.type!==t.type&&"undefined"!==typeof t.type)o&&(e.tagClass!==t.tagClass&&o.push("["+t.name+'] Expected tag class "'+t.tagClass+'", got "'+e.tagClass+'"'),e.type!==t.type&&o.push("["+t.name+'] Expected type "'+t.type+'", got "'+e.type+'"'));else if(e.constructed===t.constructed||"undefined"===typeof t.constructed){if(a=!0,t.value&&n.util.isArray(t.value))for(var s=0,u=0;a&&u0&&(o+="\n");for(var a="",u=0;u1?o+="0x"+n.util.bytesToHex(e.value.slice(1)):o+="(none)",e.value.length>0){var h=e.value.charCodeAt(0);1==h?o+=" (1 unused bit shown)":h>1&&(o+=" ("+h+" unused bits shown)")}}else if(e.type===i.Type.OCTETSTRING)s.test(e.value)||(o+="("+e.value+") "),o+="0x"+n.util.bytesToHex(e.value);else if(e.type===i.Type.UTF8)try{o+=n.util.decodeUtf8(e.value)}catch(p){if("URI malformed"!==p.message)throw p;o+="0x"+n.util.bytesToHex(e.value)+" (malformed UTF8)"}else e.type===i.Type.PRINTABLESTRING||e.type===i.Type.IA5String?o+=e.value:s.test(e.value)?o+="0x"+n.util.bytesToHex(e.value):0===e.value.length?o+="[null]":o+=e.value}return o}},8270:function(e){var t={};e.exports=t;var r={};t.encode=function(e,t,r){if("string"!==typeof t)throw new TypeError('"alphabet" must be a string.');if(void 0!==r&&"number"!==typeof r)throw new TypeError('"maxline" must be a number.');var n="";if(e instanceof Uint8Array){var i=0,o=t.length,a=t.charAt(0),s=[0];for(i=0;i0;)s.push(c%o),c=c/o|0}for(i=0;0===e[i]&&i=0;--i)n+=t[s[i]]}else n=function(e,t){var r=0,n=t.length,i=t.charAt(0),o=[0];for(r=0;r0;)o.push(s%n),s=s/n|0}var u="";for(r=0;0===e.at(r)&&r=0;--r)u+=t[o[r]];return u}(e,t);if(r){var l=new RegExp(".{1,"+r+"}","g");n=n.match(l).join("\r\n")}return n},t.decode=function(e,t){if("string"!==typeof e)throw new TypeError('"input" must be a string.');if("string"!==typeof t)throw new TypeError('"alphabet" must be a string.');var n=r[t];if(!n){n=r[t]=[];for(var i=0;i>=8;for(;l>0;)s.push(255&l),l>>=8}for(var f=0;e[f]===a&&f4){var r=e;e=n.util.createBuffer();for(var i=0;i0))return!0;for(var n=0;n0))return!0;for(var n=0;n0)return!1;var r=e.length(),n=e.at(r-1);return!(n>this.blockSize<<2)&&(e.truncate(n),!0)},i.cbc=function(e){e=e||{},this.name="CBC",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=new Array(this._ints),this._outBlock=new Array(this._ints)},i.cbc.prototype.start=function(e){if(null===e.iv){if(!this._prev)throw new Error("Invalid IV parameter.");this._iv=this._prev.slice(0)}else{if(!("iv"in e))throw new Error("Invalid IV parameter.");this._iv=o(e.iv,this.blockSize),this._prev=this._iv.slice(0)}},i.cbc.prototype.encrypt=function(e,t,r){if(e.length()0))return!0;for(var n=0;n0))return!0;for(var n=0;n0)return!1;var r=e.length(),n=e.at(r-1);return!(n>this.blockSize<<2)&&(e.truncate(n),!0)},i.cfb=function(e){e=e||{},this.name="CFB",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialBlock=new Array(this._ints),this._partialOutput=n.util.createBuffer(),this._partialBytes=0},i.cfb.prototype.start=function(e){if(!("iv"in e))throw new Error("Invalid IV parameter.");this._iv=o(e.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},i.cfb.prototype.encrypt=function(e,t,r){var n=e.length();if(0===n)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&n>=this.blockSize)for(var i=0;i0&&(o=this.blockSize-o),this._partialOutput.clear();for(i=0;i0)e.read-=this.blockSize;else for(i=0;i0&&this._partialOutput.getBytes(this._partialBytes),o>0&&!r)return t.putBytes(this._partialOutput.getBytes(o-this._partialBytes)),this._partialBytes=o,!0;t.putBytes(this._partialOutput.getBytes(n-this._partialBytes)),this._partialBytes=0}},i.cfb.prototype.decrypt=function(e,t,r){var n=e.length();if(0===n)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&n>=this.blockSize)for(var i=0;i0&&(o=this.blockSize-o),this._partialOutput.clear();for(i=0;i0)e.read-=this.blockSize;else for(i=0;i0&&this._partialOutput.getBytes(this._partialBytes),o>0&&!r)return t.putBytes(this._partialOutput.getBytes(o-this._partialBytes)),this._partialBytes=o,!0;t.putBytes(this._partialOutput.getBytes(n-this._partialBytes)),this._partialBytes=0}},i.ofb=function(e){e=e||{},this.name="OFB",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialOutput=n.util.createBuffer(),this._partialBytes=0},i.ofb.prototype.start=function(e){if(!("iv"in e))throw new Error("Invalid IV parameter.");this._iv=o(e.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},i.ofb.prototype.encrypt=function(e,t,r){var n=e.length();if(0===e.length())return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&n>=this.blockSize)for(var i=0;i0&&(o=this.blockSize-o),this._partialOutput.clear();for(i=0;i0)e.read-=this.blockSize;else for(i=0;i0&&this._partialOutput.getBytes(this._partialBytes),o>0&&!r)return t.putBytes(this._partialOutput.getBytes(o-this._partialBytes)),this._partialBytes=o,!0;t.putBytes(this._partialOutput.getBytes(n-this._partialBytes)),this._partialBytes=0}},i.ofb.prototype.decrypt=i.ofb.prototype.encrypt,i.ctr=function(e){e=e||{},this.name="CTR",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialOutput=n.util.createBuffer(),this._partialBytes=0},i.ctr.prototype.start=function(e){if(!("iv"in e))throw new Error("Invalid IV parameter.");this._iv=o(e.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},i.ctr.prototype.encrypt=function(e,t,r){var n=e.length();if(0===n)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&n>=this.blockSize)for(var i=0;i0&&(o=this.blockSize-o),this._partialOutput.clear();for(i=0;i0&&(e.read-=this.blockSize),this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),o>0&&!r)return t.putBytes(this._partialOutput.getBytes(o-this._partialBytes)),this._partialBytes=o,!0;t.putBytes(this._partialOutput.getBytes(n-this._partialBytes)),this._partialBytes=0}a(this._inBlock)},i.ctr.prototype.decrypt=i.ctr.prototype.encrypt,i.gcm=function(e){e=e||{},this.name="GCM",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=new Array(this._ints),this._outBlock=new Array(this._ints),this._partialOutput=n.util.createBuffer(),this._partialBytes=0,this._R=3774873600},i.gcm.prototype.start=function(e){if(!("iv"in e))throw new Error("Invalid IV parameter.");var t,r=n.util.createBuffer(e.iv);if(this._cipherLength=0,t="additionalData"in e?n.util.createBuffer(e.additionalData):n.util.createBuffer(),this._tagLength="tagLength"in e?e.tagLength:128,this._tag=null,e.decrypt&&(this._tag=n.util.createBuffer(e.tag).getBytes(),this._tag.length!==this._tagLength/8))throw new Error("Authentication tag does not match tag length.");this._hashBlock=new Array(this._ints),this.tag=null,this._hashSubkey=new Array(this._ints),this.cipher.encrypt([0,0,0,0],this._hashSubkey),this.componentBits=4,this._m=this.generateHashTable(this._hashSubkey,this.componentBits);var i=r.length();if(12===i)this._j0=[r.getInt32(),r.getInt32(),r.getInt32(),1];else{for(this._j0=[0,0,0,0];r.length()>0;)this._j0=this.ghash(this._hashSubkey,this._j0,[r.getInt32(),r.getInt32(),r.getInt32(),r.getInt32()]);this._j0=this.ghash(this._hashSubkey,this._j0,[0,0].concat(s(8*i)))}this._inBlock=this._j0.slice(0),a(this._inBlock),this._partialBytes=0,t=n.util.createBuffer(t),this._aDataLength=s(8*t.length());var o=t.length()%this.blockSize;for(o&&t.fillWithByte(0,this.blockSize-o),this._s=[0,0,0,0];t.length()>0;)this._s=this.ghash(this._hashSubkey,this._s,[t.getInt32(),t.getInt32(),t.getInt32(),t.getInt32()])},i.gcm.prototype.encrypt=function(e,t,r){var n=e.length();if(0===n)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&n>=this.blockSize){for(var i=0;i0&&(o=this.blockSize-o),this._partialOutput.clear();for(i=0;i0&&this._partialOutput.getBytes(this._partialBytes),o>0&&!r)return e.read-=this.blockSize,t.putBytes(this._partialOutput.getBytes(o-this._partialBytes)),this._partialBytes=o,!0;t.putBytes(this._partialOutput.getBytes(n-this._partialBytes)),this._partialBytes=0}this._s=this.ghash(this._hashSubkey,this._s,this._outBlock),a(this._inBlock)},i.gcm.prototype.decrypt=function(e,t,r){var n=e.length();if(n0))return!0;this.cipher.encrypt(this._inBlock,this._outBlock),a(this._inBlock),this._hashBlock[0]=e.getInt32(),this._hashBlock[1]=e.getInt32(),this._hashBlock[2]=e.getInt32(),this._hashBlock[3]=e.getInt32(),this._s=this.ghash(this._hashSubkey,this._s,this._hashBlock);for(var i=0;i0;--n)t[n]=e[n]>>>1|(1&e[n-1])<<31;t[0]=e[0]>>>1,r&&(t[0]^=this._R)},i.gcm.prototype.tableMultiply=function(e){for(var t=[0,0,0,0],r=0;r<32;++r){var n=e[r/8|0]>>>4*(7-r%8)&15,i=this._m[r][n];t[0]^=i[0],t[1]^=i[1],t[2]^=i[2],t[3]^=i[3]}return t},i.gcm.prototype.ghash=function(e,t,r){return t[0]^=r[0],t[1]^=r[1],t[2]^=r[2],t[3]^=r[3],this.tableMultiply(t)},i.gcm.prototype.generateHashTable=function(e,t){for(var r=8/t,n=4*r,i=16*r,o=new Array(i),a=0;a>>1,i=new Array(r);i[n]=e.slice(0);for(var o=n>>>1;o>0;)this.pow(i[2*o],i[o]=[]),o>>=1;for(o=2;o8?3:1,y=[],m=[0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,0],b=0,w=0;w>>4^E))<<4,k^=t=65535&((E^=t)>>>-16^k),k^=(t=858993459&(k>>>2^(E^=t<<-16)))<<2,k^=t=65535&((E^=t)>>>-16^k),k^=(t=1431655765&(k>>>1^(E^=t<<-16)))<<1,k^=t=16711935&((E^=t)>>>8^k),t=(k^=(t=1431655765&(k>>>1^(E^=t<<8)))<<1)<<8|(E^=t)>>>20&240,k=E<<24|E<<8&16711680|E>>>8&65280|E>>>24&240,E=t;for(var x=0;x>>26,E=E<<2|E>>>26):(k=k<<1|k>>>27,E=E<<1|E>>>27),E&=-15;var _=r[(k&=-15)>>>28]|n[k>>>24&15]|i[k>>>20&15]|o[k>>>16&15]|a[k>>>12&15]|s[k>>>8&15]|u[k>>>4&15],S=c[E>>>28]|l[E>>>24&15]|f[E>>>20&15]|h[E>>>16&15]|d[E>>>12&15]|p[E>>>8&15]|v[E>>>4&15];t=65535&(S>>>16^_),y[b++]=_^t,y[b++]=S^t<<16}}return y}(t),this._init=!0}},i("DES-ECB",n.cipher.modes.ecb),i("DES-CBC",n.cipher.modes.cbc),i("DES-CFB",n.cipher.modes.cfb),i("DES-OFB",n.cipher.modes.ofb),i("DES-CTR",n.cipher.modes.ctr),i("3DES-ECB",n.cipher.modes.ecb),i("3DES-CBC",n.cipher.modes.cbc),i("3DES-CFB",n.cipher.modes.cfb),i("3DES-OFB",n.cipher.modes.ofb),i("3DES-CTR",n.cipher.modes.ctr);var o=[16843776,0,65536,16843780,16842756,66564,4,65536,1024,16843776,16843780,1024,16778244,16842756,16777216,4,1028,16778240,16778240,66560,66560,16842752,16842752,16778244,65540,16777220,16777220,65540,0,1028,66564,16777216,65536,16843780,4,16842752,16843776,16777216,16777216,1024,16842756,65536,66560,16777220,1024,4,16778244,66564,16843780,65540,16842752,16778244,16777220,1028,66564,16843776,1028,16778240,16778240,0,65540,66560,0,16842756],a=[-2146402272,-2147450880,32768,1081376,1048576,32,-2146435040,-2147450848,-2147483616,-2146402272,-2146402304,-2147483648,-2147450880,1048576,32,-2146435040,1081344,1048608,-2147450848,0,-2147483648,32768,1081376,-2146435072,1048608,-2147483616,0,1081344,32800,-2146402304,-2146435072,32800,0,1081376,-2146435040,1048576,-2147450848,-2146435072,-2146402304,32768,-2146435072,-2147450880,32,-2146402272,1081376,32,32768,-2147483648,32800,-2146402304,1048576,-2147483616,1048608,-2147450848,-2147483616,1048608,1081344,0,-2147450880,32800,-2147483648,-2146435040,-2146402272,1081344],s=[520,134349312,0,134348808,134218240,0,131592,134218240,131080,134217736,134217736,131072,134349320,131080,134348800,520,134217728,8,134349312,512,131584,134348800,134348808,131592,134218248,131584,131072,134218248,8,134349320,512,134217728,134349312,134217728,131080,520,131072,134349312,134218240,0,512,131080,134349320,134218240,134217736,512,0,134348808,134218248,131072,134217728,134349320,8,131592,131584,134217736,134348800,134218248,520,134348800,131592,8,134348808,131584],u=[8396801,8321,8321,128,8396928,8388737,8388609,8193,0,8396800,8396800,8396929,129,0,8388736,8388609,1,8192,8388608,8396801,128,8388608,8193,8320,8388737,1,8320,8388736,8192,8396928,8396929,129,8388736,8388609,8396800,8396929,129,0,0,8396800,8320,8388736,8388737,1,8396801,8321,8321,128,8396929,129,1,8192,8388609,8193,8396928,8388737,8193,8320,8388608,8396801,128,8388608,8192,8396928],c=[256,34078976,34078720,1107296512,524288,256,1073741824,34078720,1074266368,524288,33554688,1074266368,1107296512,1107820544,524544,1073741824,33554432,1074266112,1074266112,0,1073742080,1107820800,1107820800,33554688,1107820544,1073742080,0,1107296256,34078976,33554432,1107296256,524544,524288,1107296512,256,33554432,1073741824,34078720,1107296512,1074266368,33554688,1073741824,1107820544,34078976,1074266368,256,33554432,1107820544,1107820800,524544,1107296256,1107820800,34078720,0,1074266112,1107296256,524544,33554688,1073742080,524288,0,1074266112,34078976,1073742080],l=[536870928,541065216,16384,541081616,541065216,16,541081616,4194304,536887296,4210704,4194304,536870928,4194320,536887296,536870912,16400,0,4194320,536887312,16384,4210688,536887312,16,541065232,541065232,0,4210704,541081600,16400,4210688,541081600,536870912,536887296,16,541065232,4210688,541081616,4194304,16400,536870928,4194304,536887296,536870912,16400,536870928,541081616,4210688,541065216,4210704,541081600,0,541065232,16,16384,541065216,4210704,16384,4194320,536887312,0,541081600,536870912,4194320,536887312],f=[2097152,69206018,67110914,0,2048,67110914,2099202,69208064,69208066,2097152,0,67108866,2,67108864,69206018,2050,67110912,2099202,2097154,67110912,67108866,69206016,69208064,2097154,69206016,2048,2050,69208066,2099200,2,67108864,2099200,67108864,2099200,2097152,67110914,67110914,69206018,69206018,2,2097154,67108864,67110912,2097152,69208064,2050,2099202,69208064,2050,67108866,69208066,69206016,2099200,0,2,69208066,0,2099202,69206016,2048,67108866,67110912,2048,2097154],h=[268439616,4096,262144,268701760,268435456,268439616,64,268435456,262208,268697600,268701760,266240,268701696,266304,4096,64,268697600,268435520,268439552,4160,266240,262208,268697664,268701696,4160,0,0,268697664,268435520,268439552,266304,262144,266304,262144,268701696,4096,64,268697664,4096,266304,268439552,64,268435520,268697600,268697664,268435456,262144,268439616,0,268701760,262208,268435520,268697600,268439552,268439616,0,268701760,266240,266240,4160,4160,262208,268435456,268701696];function d(e,t,r,n){var i,d,p=32===e.length?3:9;i=3===p?n?[30,-2,-2]:[0,32,2]:n?[94,62,-2,32,64,2,30,-2,-2]:[0,32,2,62,30,-2,64,96,2];var v=t[0],g=t[1];v^=(d=252645135&(v>>>4^g))<<4,v^=(d=65535&(v>>>16^(g^=d)))<<16,v^=d=858993459&((g^=d)>>>2^v),v^=d=16711935&((g^=d<<2)>>>8^v),v=(v^=(d=1431655765&(v>>>1^(g^=d<<8)))<<1)<<1|v>>>31,g=(g^=d)<<1|g>>>31;for(var y=0;y>>4|g<<28)^e[w+1];d=v,v=g,g=d^(a[k>>>24&63]|u[k>>>16&63]|l[k>>>8&63]|h[63&k]|o[E>>>24&63]|s[E>>>16&63]|c[E>>>8&63]|f[63&E])}d=v,v=g,g=d}g=g>>>1|g<<31,g^=d=1431655765&((v=v>>>1|v<<31)>>>1^g),g^=(d=16711935&(g>>>8^(v^=d<<1)))<<8,g^=(d=858993459&(g>>>2^(v^=d)))<<2,g^=d=65535&((v^=d)>>>16^g),g^=d=252645135&((v^=d<<16)>>>4^g),v^=d<<4,r[0]=v,r[1]=g}function p(e){var t,r="DES-"+((e=e||{}).mode||"CBC").toUpperCase(),i=(t=e.decrypt?n.cipher.createDecipher(r,e.key):n.cipher.createCipher(r,e.key)).start;return t.start=function(e,r){var o=null;r instanceof n.util.ByteBuffer&&(o=r,r={}),(r=r||{}).output=o,r.iv=e,i.call(t,r)},t}},3299:function(e){e.exports={options:{usePureJavaScript:!1}}},2589:function(e,t,r){var n=r(3299);r(4744),r(9327),(e.exports=n.hmac=n.hmac||{}).create=function(){var e=null,t=null,r=null,i=null,o={start:function(o,a){if(null!==o)if("string"===typeof o){if(!((o=o.toLowerCase())in n.md.algorithms))throw new Error('Unknown hash algorithm "'+o+'"');t=n.md.algorithms[o].create()}else t=o;if(null===a)a=e;else{if("string"===typeof a)a=n.util.createBuffer(a);else if(n.util.isArray(a)){var s=a;a=n.util.createBuffer();for(var u=0;ut.blockLength&&(t.start(),t.update(a.bytes()),a=t.digest()),r=n.util.createBuffer(),i=n.util.createBuffer(),c=a.length();for(u=0;u>14;--o>=0;){var u=16383&this.data[e],c=this.data[e++]>>14,l=s*u+c*a;i=((u=a*u+((16383&l)<<14)+r.data[n]+i)>>28)+(l>>14)+s*c,r.data[n++]=268435455&u}return i}i.jsbn.BigInteger=o,"undefined"===typeof navigator?(o.prototype.am=s,n=28):"Microsoft Internet Explorer"==navigator.appName?(o.prototype.am=function(e,t,r,n,i,o){for(var a=32767&t,s=t>>15;--o>=0;){var u=32767&this.data[e],c=this.data[e++]>>15,l=s*u+c*a;i=((u=a*u+((32767&l)<<15)+r.data[n]+(1073741823&i))>>>30)+(l>>>15)+s*c+(i>>>30),r.data[n++]=1073741823&u}return i},n=30):"Netscape"!=navigator.appName?(o.prototype.am=function(e,t,r,n,i,o){for(;--o>=0;){var a=t*this.data[e++]+r.data[n]+i;i=Math.floor(a/67108864),r.data[n++]=67108863&a}return i},n=26):(o.prototype.am=s,n=28),o.prototype.DB=n,o.prototype.DM=(1<>>16)&&(e=t,r+=16),0!=(t=e>>8)&&(e=t,r+=8),0!=(t=e>>4)&&(e=t,r+=4),0!=(t=e>>2)&&(e=t,r+=2),0!=(t=e>>1)&&(e=t,r+=1),r}function v(e){this.m=e}function g(e){this.m=e,this.mp=e.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<>=16,t+=16),0==(255&e)&&(e>>=8,t+=8),0==(15&e)&&(e>>=4,t+=4),0==(3&e)&&(e>>=2,t+=2),0==(1&e)&&++t,t}function E(e){for(var t=0;0!=e;)e&=e-1,++t;return t}function x(){}function _(e){return e}function S(e){this.r2=a(),this.q3=a(),o.ONE.dlShiftTo(2*e.t,this.r2),this.mu=this.r2.divide(e),this.m=e}v.prototype.convert=function(e){return e.s<0||e.compareTo(this.m)>=0?e.mod(this.m):e},v.prototype.revert=function(e){return e},v.prototype.reduce=function(e){e.divRemTo(this.m,null,e)},v.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r),this.reduce(r)},v.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)},g.prototype.convert=function(e){var t=a();return e.abs().dlShiftTo(this.m.t,t),t.divRemTo(this.m,null,t),e.s<0&&t.compareTo(o.ZERO)>0&&this.m.subTo(t,t),t},g.prototype.revert=function(e){var t=a();return e.copyTo(t),this.reduce(t),t},g.prototype.reduce=function(e){for(;e.t<=this.mt2;)e.data[e.t++]=0;for(var t=0;t>15)*this.mpl&this.um)<<15)&e.DM;for(r=t+this.m.t,e.data[r]+=this.m.am(0,n,e,t,0,this.m.t);e.data[r]>=e.DV;)e.data[r]-=e.DV,e.data[++r]++}e.clamp(),e.drShiftTo(this.m.t,e),e.compareTo(this.m)>=0&&e.subTo(this.m,e)},g.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r),this.reduce(r)},g.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)},o.prototype.copyTo=function(e){for(var t=this.t-1;t>=0;--t)e.data[t]=this.data[t];e.t=this.t,e.s=this.s},o.prototype.fromInt=function(e){this.t=1,this.s=e<0?-1:0,e>0?this.data[0]=e:e<-1?this.data[0]=e+this.DV:this.t=0},o.prototype.fromString=function(e,t){var r;if(16==t)r=4;else if(8==t)r=3;else if(256==t)r=8;else if(2==t)r=1;else if(32==t)r=5;else{if(4!=t)return void this.fromRadix(e,t);r=2}this.t=0,this.s=0;for(var n=e.length,i=!1,a=0;--n>=0;){var s=8==r?255&e[n]:h(e,n);s<0?"-"==e.charAt(n)&&(i=!0):(i=!1,0==a?this.data[this.t++]=s:a+r>this.DB?(this.data[this.t-1]|=(s&(1<>this.DB-a):this.data[this.t-1]|=s<=this.DB&&(a-=this.DB))}8==r&&0!=(128&e[0])&&(this.s=-1,a>0&&(this.data[this.t-1]|=(1<0&&this.data[this.t-1]==e;)--this.t},o.prototype.dlShiftTo=function(e,t){var r;for(r=this.t-1;r>=0;--r)t.data[r+e]=this.data[r];for(r=e-1;r>=0;--r)t.data[r]=0;t.t=this.t+e,t.s=this.s},o.prototype.drShiftTo=function(e,t){for(var r=e;r=0;--r)t.data[r+a+1]=this.data[r]>>i|s,s=(this.data[r]&o)<=0;--r)t.data[r]=0;t.data[a]=s,t.t=this.t+a+1,t.s=this.s,t.clamp()},o.prototype.rShiftTo=function(e,t){t.s=this.s;var r=Math.floor(e/this.DB);if(r>=this.t)t.t=0;else{var n=e%this.DB,i=this.DB-n,o=(1<>n;for(var a=r+1;a>n;n>0&&(t.data[this.t-r-1]|=(this.s&o)<>=this.DB;if(e.t>=this.DB;n+=this.s}else{for(n+=this.s;r>=this.DB;n-=e.s}t.s=n<0?-1:0,n<-1?t.data[r++]=this.DV+n:n>0&&(t.data[r++]=n),t.t=r,t.clamp()},o.prototype.multiplyTo=function(e,t){var r=this.abs(),n=e.abs(),i=r.t;for(t.t=i+n.t;--i>=0;)t.data[i]=0;for(i=0;i=0;)e.data[r]=0;for(r=0;r=t.DV&&(e.data[r+t.t]-=t.DV,e.data[r+t.t+1]=1)}e.t>0&&(e.data[e.t-1]+=t.am(r,t.data[r],e,2*r,0,1)),e.s=0,e.clamp()},o.prototype.divRemTo=function(e,t,r){var n=e.abs();if(!(n.t<=0)){var i=this.abs();if(i.t0?(n.lShiftTo(l,s),i.lShiftTo(l,r)):(n.copyTo(s),i.copyTo(r));var f=s.t,h=s.data[f-1];if(0!=h){var d=h*(1<1?s.data[f-2]>>this.F2:0),v=this.FV/d,g=(1<=0&&(r.data[r.t++]=1,r.subTo(w,r)),o.ONE.dlShiftTo(f,w),w.subTo(s,s);s.t=0;){var k=r.data[--m]==h?this.DM:Math.floor(r.data[m]*v+(r.data[m-1]+y)*g);if((r.data[m]+=s.am(0,k,r,b,0,f))0&&r.rShiftTo(l,r),u<0&&o.ZERO.subTo(r,r)}}},o.prototype.invDigit=function(){if(this.t<1)return 0;var e=this.data[0];if(0==(1&e))return 0;var t=3&e;return(t=(t=(t=(t=t*(2-(15&e)*t)&15)*(2-(255&e)*t)&255)*(2-((65535&e)*t&65535))&65535)*(2-e*t%this.DV)%this.DV)>0?this.DV-t:-t},o.prototype.isEven=function(){return 0==(this.t>0?1&this.data[0]:this.s)},o.prototype.exp=function(e,t){if(e>4294967295||e<1)return o.ONE;var r=a(),n=a(),i=t.convert(this),s=p(e)-1;for(i.copyTo(r);--s>=0;)if(t.sqrTo(r,n),(e&1<0)t.mulTo(n,i,r);else{var u=r;r=n,n=u}return t.revert(r)},o.prototype.toString=function(e){if(this.s<0)return"-"+this.negate().toString(e);var t;if(16==e)t=4;else if(8==e)t=3;else if(2==e)t=1;else if(32==e)t=5;else{if(4!=e)return this.toRadix(e);t=2}var r,n=(1<0)for(s>s)>0&&(i=!0,o=f(r));a>=0;)s>(s+=this.DB-t)):(r=this.data[a]>>(s-=t)&n,s<=0&&(s+=this.DB,--a)),r>0&&(i=!0),i&&(o+=f(r));return i?o:"0"},o.prototype.negate=function(){var e=a();return o.ZERO.subTo(this,e),e},o.prototype.abs=function(){return this.s<0?this.negate():this},o.prototype.compareTo=function(e){var t=this.s-e.s;if(0!=t)return t;var r=this.t;if(0!=(t=r-e.t))return this.s<0?-t:t;for(;--r>=0;)if(0!=(t=this.data[r]-e.data[r]))return t;return 0},o.prototype.bitLength=function(){return this.t<=0?0:this.DB*(this.t-1)+p(this.data[this.t-1]^this.s&this.DM)},o.prototype.mod=function(e){var t=a();return this.abs().divRemTo(e,null,t),this.s<0&&t.compareTo(o.ZERO)>0&&e.subTo(t,t),t},o.prototype.modPowInt=function(e,t){var r;return r=e<256||t.isEven()?new v(t):new g(t),this.exp(e,r)},o.ZERO=d(0),o.ONE=d(1),x.prototype.convert=_,x.prototype.revert=_,x.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r)},x.prototype.sqrTo=function(e,t){e.squareTo(t)},S.prototype.convert=function(e){if(e.s<0||e.t>2*this.m.t)return e.mod(this.m);if(e.compareTo(this.m)<0)return e;var t=a();return e.copyTo(t),this.reduce(t),t},S.prototype.revert=function(e){return e},S.prototype.reduce=function(e){for(e.drShiftTo(this.m.t-1,this.r2),e.t>this.m.t+1&&(e.t=this.m.t+1,e.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);e.compareTo(this.r2)<0;)e.dAddOffset(1,this.m.t+1);for(e.subTo(this.r2,e);e.compareTo(this.m)>=0;)e.subTo(this.m,e)},S.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r),this.reduce(r)},S.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)};var A=[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],I=(1<<26)/A[A.length-1];o.prototype.chunkSize=function(e){return Math.floor(Math.LN2*this.DB/Math.log(e))},o.prototype.toRadix=function(e){if(null==e&&(e=10),0==this.signum()||e<2||e>36)return"0";var t=this.chunkSize(e),r=Math.pow(e,t),n=d(r),i=a(),o=a(),s="";for(this.divRemTo(n,i,o);i.signum()>0;)s=(r+o.intValue()).toString(e).substr(1)+s,i.divRemTo(n,i,o);return o.intValue().toString(e)+s},o.prototype.fromRadix=function(e,t){this.fromInt(0),null==t&&(t=10);for(var r=this.chunkSize(t),n=Math.pow(t,r),i=!1,a=0,s=0,u=0;u=r&&(this.dMultiply(n),this.dAddOffset(s,0),a=0,s=0))}a>0&&(this.dMultiply(Math.pow(t,a)),this.dAddOffset(s,0)),i&&o.ZERO.subTo(this,this)},o.prototype.fromNumber=function(e,t,r){if("number"==typeof t)if(e<2)this.fromInt(1);else for(this.fromNumber(e,r),this.testBit(e-1)||this.bitwiseTo(o.ONE.shiftLeft(e-1),m,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(t);)this.dAddOffset(2,0),this.bitLength()>e&&this.subTo(o.ONE.shiftLeft(e-1),this);else{var n=new Array,i=7&e;n.length=1+(e>>3),t.nextBytes(n),i>0?n[0]&=(1<>=this.DB;if(e.t>=this.DB;n+=this.s}else{for(n+=this.s;r>=this.DB;n+=e.s}t.s=n<0?-1:0,n>0?t.data[r++]=n:n<-1&&(t.data[r++]=this.DV+n),t.t=r,t.clamp()},o.prototype.dMultiply=function(e){this.data[this.t]=this.am(0,e-1,this,0,0,this.t),++this.t,this.clamp()},o.prototype.dAddOffset=function(e,t){if(0!=e){for(;this.t<=t;)this.data[this.t++]=0;for(this.data[t]+=e;this.data[t]>=this.DV;)this.data[t]-=this.DV,++t>=this.t&&(this.data[this.t++]=0),++this.data[t]}},o.prototype.multiplyLowerTo=function(e,t,r){var n,i=Math.min(this.t+e.t,t);for(r.s=0,r.t=i;i>0;)r.data[--i]=0;for(n=r.t-this.t;i=0;)r.data[n]=0;for(n=Math.max(t-this.t,0);n0)if(0==t)r=this.data[0]%e;else for(var n=this.t-1;n>=0;--n)r=(t*r+this.data[n])%e;return r},o.prototype.millerRabin=function(e){var t=this.subtract(o.ONE),r=t.getLowestSetBit();if(r<=0)return!1;for(var n,i=t.shiftRight(r),a={nextBytes:function(e){for(var t=0;t=0);var u=n.modPow(i,this);if(0!=u.compareTo(o.ONE)&&0!=u.compareTo(t)){for(var c=1;c++>24},o.prototype.shortValue=function(){return 0==this.t?this.s:this.data[0]<<16>>16},o.prototype.signum=function(){return this.s<0?-1:this.t<=0||1==this.t&&this.data[0]<=0?0:1},o.prototype.toByteArray=function(){var e=this.t,t=new Array;t[0]=this.s;var r,n=this.DB-e*this.DB%8,i=0;if(e-- >0)for(n>n)!=(this.s&this.DM)>>n&&(t[i++]=r|this.s<=0;)n<8?(r=(this.data[e]&(1<>(n+=this.DB-8)):(r=this.data[e]>>(n-=8)&255,n<=0&&(n+=this.DB,--e)),0!=(128&r)&&(r|=-256),0==i&&(128&this.s)!=(128&r)&&++i,(i>0||r!=this.s)&&(t[i++]=r);return t},o.prototype.equals=function(e){return 0==this.compareTo(e)},o.prototype.min=function(e){return this.compareTo(e)<0?this:e},o.prototype.max=function(e){return this.compareTo(e)>0?this:e},o.prototype.and=function(e){var t=a();return this.bitwiseTo(e,y,t),t},o.prototype.or=function(e){var t=a();return this.bitwiseTo(e,m,t),t},o.prototype.xor=function(e){var t=a();return this.bitwiseTo(e,b,t),t},o.prototype.andNot=function(e){var t=a();return this.bitwiseTo(e,w,t),t},o.prototype.not=function(){for(var e=a(),t=0;t=this.t?0!=this.s:0!=(this.data[t]&1<1){var f=a();for(n.sqrTo(s[1],f);u<=l;)s[u]=a(),n.mulTo(f,s[u-2],s[u]),u+=2}var h,y,m=e.t-1,b=!0,w=a();for(i=p(e.data[m])-1;m>=0;){for(i>=c?h=e.data[m]>>i-c&l:(h=(e.data[m]&(1<0&&(h|=e.data[m-1]>>this.DB+i-c)),u=r;0==(1&h);)h>>=1,--u;if((i-=u)<0&&(i+=this.DB,--m),b)s[h].copyTo(o),b=!1;else{for(;u>1;)n.sqrTo(o,w),n.sqrTo(w,o),u-=2;u>0?n.sqrTo(o,w):(y=o,o=w,w=y),n.mulTo(w,s[h],o)}for(;m>=0&&0==(e.data[m]&1<=0?(r.subTo(n,r),t&&i.subTo(s,i),a.subTo(u,a)):(n.subTo(r,n),t&&s.subTo(i,s),u.subTo(a,u))}return 0!=n.compareTo(o.ONE)?o.ZERO:u.compareTo(e)>=0?u.subtract(e):u.signum()<0?(u.addTo(e,u),u.signum()<0?u.add(e):u):u},o.prototype.pow=function(e){return this.exp(e,new x)},o.prototype.gcd=function(e){var t=this.s<0?this.negate():this.clone(),r=e.s<0?e.negate():e.clone();if(t.compareTo(r)<0){var n=t;t=r,r=n}var i=t.getLowestSetBit(),o=r.getLowestSetBit();if(o<0)return t;for(i0&&(t.rShiftTo(o,t),r.rShiftTo(o,r));t.signum()>0;)(i=t.getLowestSetBit())>0&&t.rShiftTo(i,t),(i=r.getLowestSetBit())>0&&r.rShiftTo(i,r),t.compareTo(r)>=0?(t.subTo(r,t),t.rShiftTo(1,t)):(r.subTo(t,r),r.rShiftTo(1,r));return o>0&&r.lShiftTo(o,r),r},o.prototype.isProbablePrime=function(e){var t,r=this.abs();if(1==r.t&&r.data[0]<=A[A.length-1]){for(t=0;t=0;u--)T>>=8,T+=S.at(u)+C.at(u),C.setAt(u,255&T);I.putBuffer(C)}w=I,f.putBuffer(x)}return f.truncate(f.length()-o),f},a.pbe.getCipher=function(e,t,r){switch(e){case a.oids.pkcs5PBES2:return a.pbe.getCipherForPBES2(e,t,r);case a.oids["pbeWithSHAAnd3-KeyTripleDES-CBC"]:case a.oids["pbewithSHAAnd40BitRC2-CBC"]:return a.pbe.getCipherForPKCS12PBE(e,t,r);default:var n=new Error("Cannot read encrypted PBE data block. Unsupported OID.");throw n.oid=e,n.supportedOids=["pkcs5PBES2","pbeWithSHAAnd3-KeyTripleDES-CBC","pbewithSHAAnd40BitRC2-CBC"],n}},a.pbe.getCipherForPBES2=function(e,t,r){var i,s={},u=[];if(!o.validate(t,c,s,u))throw(i=new Error("Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.")).errors=u,i;if((e=o.derToOid(s.kdfOid))!==a.oids.pkcs5PBKDF2)throw(i=new Error("Cannot read encrypted private key. Unsupported key derivation function OID.")).oid=e,i.supportedOids=["pkcs5PBKDF2"],i;if((e=o.derToOid(s.encOid))!==a.oids["aes128-CBC"]&&e!==a.oids["aes192-CBC"]&&e!==a.oids["aes256-CBC"]&&e!==a.oids["des-EDE3-CBC"]&&e!==a.oids.desCBC)throw(i=new Error("Cannot read encrypted private key. Unsupported encryption scheme OID.")).oid=e,i.supportedOids=["aes128-CBC","aes192-CBC","aes256-CBC","des-EDE3-CBC","desCBC"],i;var l,f,d=s.kdfSalt,p=n.util.createBuffer(s.kdfIterationCount);switch(p=p.getInt(p.length()<<3),a.oids[e]){case"aes128-CBC":l=16,f=n.aes.createDecryptionCipher;break;case"aes192-CBC":l=24,f=n.aes.createDecryptionCipher;break;case"aes256-CBC":l=32,f=n.aes.createDecryptionCipher;break;case"des-EDE3-CBC":l=24,f=n.des.createDecryptionCipher;break;case"desCBC":l=8,f=n.des.createDecryptionCipher}var v=h(s.prfOid),g=n.pkcs5.pbkdf2(r,d,p,l,v),y=s.encIv,m=f(g);return m.start(y),m},a.pbe.getCipherForPKCS12PBE=function(e,t,r){var i={},s=[];if(!o.validate(t,l,i,s))throw(v=new Error("Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.")).errors=s,v;var u,c,f,d=n.util.createBuffer(i.salt),p=n.util.createBuffer(i.iterations);switch(p=p.getInt(p.length()<<3),e){case a.oids["pbeWithSHAAnd3-KeyTripleDES-CBC"]:u=24,c=8,f=n.des.startDecrypting;break;case a.oids["pbewithSHAAnd40BitRC2-CBC"]:u=5,c=8,f=function(e,t){var r=n.rc2.createDecryptionCipher(e,40);return r.start(t,null),r};break;default:var v;throw(v=new Error("Cannot read PKCS #12 PBE data block. Unsupported OID.")).oid=e,v}var g=h(i.prfOid),y=a.pbe.generatePkcs12Key(r,d,1,p,u,g);return g.start(),f(y,a.pbe.generatePkcs12Key(r,d,2,p,c,g))},a.pbe.opensslDeriveBytes=function(e,t,r,i){if("undefined"===typeof i||null===i){if(!("md5"in n.md))throw new Error('"md5" hash algorithm unavailable.');i=n.md.md5.create()}null===t&&(t="");for(var o=[f(i,e+t)],a=16,s=1;a4||!a||"sha1"===a))return"string"!==typeof a&&(a="sha1"),e=Buffer.from(e,"binary"),t=Buffer.from(t,"binary"),s?4===i.pbkdf2Sync.length?i.pbkdf2(e,t,r,o,(function(e,t){if(e)return s(e);s(null,t.toString("binary"))})):i.pbkdf2(e,t,r,o,a,(function(e,t){if(e)return s(e);s(null,t.toString("binary"))})):4===i.pbkdf2Sync.length?i.pbkdf2Sync(e,t,r,o).toString("binary"):i.pbkdf2Sync(e,t,r,o,a).toString("binary");if("undefined"!==typeof a&&null!==a||(a="sha1"),"string"===typeof a){if(!(a in n.md.algorithms))throw new Error("Unknown hash algorithm: "+a);a=n.md[a].create()}var u=a.digestLength;if(o>4294967295*u){var c=new Error("Derived key is too long.");if(s)return s(c);throw c}var l=Math.ceil(o/u),f=o-(l-1)*u,h=n.hmac.create();h.start(a,e);var d,p,v,g="";if(!s){for(var y=1;y<=l;++y){h.start(null,null),h.update(t),h.update(n.util.int32ToBytes(y)),d=v=h.digest().getBytes();for(var m=2;m<=r;++m)h.start(null,null),h.update(v),p=h.digest().getBytes(),d=n.util.xorBytes(d,p,u),v=p;g+=yl)return s(null,g);h.start(null,null),h.update(t),h.update(n.util.int32ToBytes(y)),d=v=h.digest().getBytes(),m=2,w()}function w(){if(m<=r)return h.start(null,null),h.update(v),p=h.digest().getBytes(),d=n.util.xorBytes(d,p,u),v=p,++m,n.util.setImmediate(w);g+=y65&&-1!==a){var s=t[a];","===s?(++a,t=t.substr(0,a)+"\r\n "+t.substr(a)):t=t.substr(0,a)+"\r\n"+s+t.substr(a+1),o=i-a-1,a=-1,++i}else" "!==t[i]&&"\t"!==t[i]&&","!==t[i]||(a=i);return t}function a(e){return e.replace(/^\s+/,"")}i.encode=function(e,t){t=t||{};var r,i="-----BEGIN "+e.type+"-----\r\n";if(e.procType&&(i+=o(r={name:"Proc-Type",values:[String(e.procType.version),e.procType.type]})),e.contentDomain&&(i+=o(r={name:"Content-Domain",values:[e.contentDomain]})),e.dekInfo&&(r={name:"DEK-Info",values:[e.dekInfo.algorithm]},e.dekInfo.parameters&&r.values.push(e.dekInfo.parameters),i+=o(r)),e.headers)for(var a=0;a>24&255,a>>16&255,a>>8&255,255&a);r.start(),r.update(e+s),i+=r.digest().getBytes()}return i.substring(0,t)}i.encode_rsa_oaep=function(e,t,r){var i,a,s,u;"string"===typeof r?(i=r,a=arguments[3]||void 0,s=arguments[4]||void 0):r&&(i=r.label||void 0,a=r.seed||void 0,s=r.md||void 0,r.mgf1&&r.mgf1.md&&(u=r.mgf1.md)),s?s.start():s=n.md.sha1.create(),u||(u=s);var c=Math.ceil(e.n.bitLength()/8),l=c-2*s.digestLength-2;if(t.length>l)throw(g=new Error("RSAES-OAEP input message length is too long.")).length=t.length,g.maxLength=l,g;i||(i=""),s.update(i,"raw");for(var f=s.digest(),h="",d=l-t.length,p=0;pe&&(a=c(e,t));var d=a.toString(16);i.target.postMessage({hex:d,workLoad:l}),a.dAddOffset(f,0)}}}d()}(e,t,i,o);return s(e,t,i,o)}(e,u,o.options,i);throw new Error("Invalid prime generation algorithm: "+o.name)}}function s(e,t,r,n){var i=c(e,t),o=function(e){return e<=100?27:e<=150?18:e<=200?15:e<=250?12:e<=300?9:e<=350?8:e<=400?7:e<=500?6:e<=600?5:e<=800?4:e<=1250?3:2}(i.bitLength());"millerRabinTests"in r&&(o=r.millerRabinTests);var a=10;"maxBlockTime"in r&&(a=r.maxBlockTime),u(i,e,t,0,o,a,n)}function u(e,t,r,o,a,s,l){var f=+new Date;do{if(e.bitLength()>t&&(e=c(t,r)),e.isProbablePrime(a))return l(null,e);e.dAddOffset(i[o++%8],0)}while(s<0||+new Date-f=32)return u();var e=32-t.pools[0].messageLength<<5;t.collect(t.seedFileSync(e)),u()}function u(){t.reseeds=4294967295===t.reseeds?0:t.reseeds+1;var e=t.plugin.md.create();e.update(t.keyBytes);for(var r=1,n=0;n<32;++n)t.reseeds%r===0&&(e.update(t.pools[n].digest().getBytes()),t.pools[n].start()),r<<=1;t.keyBytes=e.digest().getBytes(),e.start(),e.update(t.keyBytes);var i=e.digest().getBytes();t.key=t.plugin.formatKey(t.keyBytes),t.seed=t.plugin.formatSeed(i),t.generated=0}function c(e){var t=null,r=n.util.globalScope,i=r.crypto||r.msCrypto;i&&i.getRandomValues&&(t=function(e){return i.getRandomValues(e)});var o=n.util.createBuffer();if(t)for(;o.length()>16)))<<16,h=4294967295&(l=(2147483647&(l+=c>>15))+(l>>31));for(u=0;u<3;++u)f=h>>>(u<<3),f^=Math.floor(256*Math.random()),o.putByte(255&f)}return o.getBytes(e)}return t.pools=o,t.pool=0,t.generate=function(e,r){if(!r)return t.generateSync(e);var i=t.plugin.cipher,o=t.plugin.increment,a=t.plugin.formatKey,s=t.plugin.formatSeed,c=n.util.createBuffer();t.key=null,function l(f){if(f)return r(f);if(c.length()>=e)return r(null,c.getBytes(e));t.generated>1048575&&(t.key=null);if(null===t.key)return n.util.nextTick((function(){!function(e){if(t.pools[0].messageLength>=32)return u(),e();var r=32-t.pools[0].messageLength<<5;t.seedFile(r,(function(r,n){if(r)return e(r);t.collect(n),u(),e()}))}(l)}));var h=i(t.key,t.seed);t.generated+=h.length,c.putBytes(h),t.key=a(i(t.key,o(t.seed))),t.seed=s(i(t.key,t.seed)),n.util.setImmediate(l)}()},t.generateSync=function(e){var r=t.plugin.cipher,i=t.plugin.increment,o=t.plugin.formatKey,a=t.plugin.formatSeed;t.key=null;for(var u=n.util.createBuffer();u.length()1048575&&(t.key=null),null===t.key&&s();var c=r(t.key,t.seed);t.generated+=c.length,u.putBytes(c),t.key=o(r(t.key,i(t.seed))),t.seed=a(r(t.key,t.seed))}return u.getBytes(e)},i?(t.seedFile=function(e,t){i.randomBytes(e,(function(e,r){if(e)return t(e);t(null,r.toString())}))},t.seedFileSync=function(e){return i.randomBytes(e).toString()}):(t.seedFile=function(e,t){try{t(null,c(e))}catch(r){t(r)}},t.seedFileSync=c),t.collect=function(e){for(var r=e.length,n=0;n>i&255);t.collect(n)},t.registerWorker=function(e){if(e===self)t.seedFile=function(e,t){self.addEventListener("message",(function e(r){var n=r.data;n.forge&&n.forge.prng&&(self.removeEventListener("message",e),t(n.forge.prng.err,n.forge.prng.bytes))})),self.postMessage({forge:{prng:{needed:e}}})};else{e.addEventListener("message",(function(r){var n=r.data;n.forge&&n.forge.prng&&t.seedFile(n.forge.prng.needed,(function(t,r){e.postMessage({forge:{prng:{err:t,bytes:r}}})}))}))}},t}},8217:function(e,t,r){var n=r(3299);r(9521),r(8282),r(6422),r(9327),n.random&&n.random.getBytes?e.exports=n.random:function(t){var r={},i=new Array(4),o=n.util.createBuffer();function a(){var e=n.prng.create(r);return e.getBytes=function(t,r){return e.generate(t,r)},e.getBytesSync=function(t){return e.generate(t)},e}r.formatKey=function(e){var t=n.util.createBuffer(e);return(e=new Array(4))[0]=t.getInt32(),e[1]=t.getInt32(),e[2]=t.getInt32(),e[3]=t.getInt32(),n.aes._expandKey(e,!1)},r.formatSeed=function(e){var t=n.util.createBuffer(e);return(e=new Array(4))[0]=t.getInt32(),e[1]=t.getInt32(),e[2]=t.getInt32(),e[3]=t.getInt32(),e},r.cipher=function(e,t){return n.aes._updateBlock(e,t,i,!1),o.putInt32(i[0]),o.putInt32(i[1]),o.putInt32(i[2]),o.putInt32(i[3]),o.getBytes()},r.increment=function(e){return++e[3],e},r.md=n.md.sha256;var s=a(),u=null,c=n.util.globalScope,l=c.crypto||c.msCrypto;if(l&&l.getRandomValues&&(u=function(e){return l.getRandomValues(e)}),n.options.usePureJavaScript||!n.util.isNodejs&&!u){if("undefined"===typeof window||window.document,s.collectInt(+new Date,32),"undefined"!==typeof navigator){var f="";for(var h in navigator)try{"string"==typeof navigator[h]&&(f+=navigator[h])}catch(d){}s.collect(f),f=null}t&&(t().mousemove((function(e){s.collectInt(e.clientX,16),s.collectInt(e.clientY,16)})),t().keypress((function(e){s.collectInt(e.charCode,8)})))}if(n.random)for(var h in s)n.random[h]=s[h];else n.random=s;n.random.createInstance=a,e.exports=n.random}("undefined"!==typeof jQuery?jQuery:null)},9932:function(e,t,r){var n=r(3299);r(9327);var i=[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],o=[1,2,3,5],a=function(e,t){return e<>16-t},s=function(e,t){return(65535&e)>>t|e<<16-t&65535};e.exports=n.rc2=n.rc2||{},n.rc2.expandKey=function(e,t){"string"===typeof e&&(e=n.util.createBuffer(e)),t=t||128;var r,o=e,a=e.length(),s=t,u=Math.ceil(s/8),c=255>>(7&s);for(r=a;r<128;r++)o.putByte(i[o.at(r-1)+o.at(r-a)&255]);for(o.setAt(128-u,i[o.at(128-u)&c]),r=127-u;r>=0;r--)o.setAt(r,i[o.at(r+1)^o.at(r+u)]);return o};var u=function(e,t,r){var i,u,c,l,f=!1,h=null,d=null,p=null,v=[];for(e=n.rc2.expandKey(e,t),c=0;c<64;c++)v.push(e.getInt16Le());r?(i=function(e){for(c=0;c<4;c++)e[c]+=v[l]+(e[(c+3)%4]&e[(c+2)%4])+(~e[(c+3)%4]&e[(c+1)%4]),e[c]=a(e[c],o[c]),l++},u=function(e){for(c=0;c<4;c++)e[c]+=v[63&e[(c+3)%4]]}):(i=function(e){for(c=3;c>=0;c--)e[c]=s(e[c],o[c]),e[c]-=v[l]+(e[(c+3)%4]&e[(c+2)%4])+(~e[(c+3)%4]&e[(c+1)%4]),l--},u=function(e){for(c=3;c>=0;c--)e[c]-=v[63&e[(c+3)%4]]});var g=function(e){var t=[];for(c=0;c<4;c++){var n=h.getInt16Le();null!==p&&(r?n^=p.getInt16Le():p.putInt16Le(n)),t.push(65535&n)}l=r?0:63;for(var i=0;i=8;)g([[5,i],[1,u],[6,i],[1,u],[5,i]])},finish:function(e){var t=!0;if(r)if(e)t=e(8,h,!r);else{var n=8===h.length()?8:8-h.length();h.fillWithByte(n,n)}if(t&&(f=!0,y.update()),!r&&(t=0===h.length()))if(e)t=e(8,d,!r);else{var i=d.length(),o=d.at(i-1);o>i?t=!1:d.truncate(o)}return t}}};n.rc2.startEncrypting=function(e,t,r){var i=n.rc2.createEncryptionCipher(e,128);return i.start(t,r),i},n.rc2.createEncryptionCipher=function(e,t){return u(e,t,!0)},n.rc2.startDecrypting=function(e,t,r){var i=n.rc2.createDecryptionCipher(e,128);return i.start(t,r),i},n.rc2.createDecryptionCipher=function(e,t){return u(e,t,!1)}},4199:function(e,t,r){var n=r(3299);if(r(5406),r(8580),r(2458),r(236),r(869),r(8217),r(9327),"undefined"===typeof i)var i=n.jsbn.BigInteger;var o=n.util.isNodejs?r(9437):null,a=n.asn1,s=n.util;n.pki=n.pki||{},e.exports=n.pki.rsa=n.rsa=n.rsa||{};var u=n.pki,c=[6,4,2,4,2,4,6,2],l={name:"PrivateKeyInfo",tagClass:a.Class.UNIVERSAL,type:a.Type.SEQUENCE,constructed:!0,value:[{name:"PrivateKeyInfo.version",tagClass:a.Class.UNIVERSAL,type:a.Type.INTEGER,constructed:!1,capture:"privateKeyVersion"},{name:"PrivateKeyInfo.privateKeyAlgorithm",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:"privateKeyOid"}]},{name:"PrivateKeyInfo",tagClass:a.Class.UNIVERSAL,type:a.Type.OCTETSTRING,constructed:!1,capture:"privateKey"}]},f={name:"RSAPrivateKey",tagClass:a.Class.UNIVERSAL,type:a.Type.SEQUENCE,constructed:!0,value:[{name:"RSAPrivateKey.version",tagClass:a.Class.UNIVERSAL,type:a.Type.INTEGER,constructed:!1,capture:"privateKeyVersion"},{name:"RSAPrivateKey.modulus",tagClass:a.Class.UNIVERSAL,type:a.Type.INTEGER,constructed:!1,capture:"privateKeyModulus"},{name:"RSAPrivateKey.publicExponent",tagClass:a.Class.UNIVERSAL,type:a.Type.INTEGER,constructed:!1,capture:"privateKeyPublicExponent"},{name:"RSAPrivateKey.privateExponent",tagClass:a.Class.UNIVERSAL,type:a.Type.INTEGER,constructed:!1,capture:"privateKeyPrivateExponent"},{name:"RSAPrivateKey.prime1",tagClass:a.Class.UNIVERSAL,type:a.Type.INTEGER,constructed:!1,capture:"privateKeyPrime1"},{name:"RSAPrivateKey.prime2",tagClass:a.Class.UNIVERSAL,type:a.Type.INTEGER,constructed:!1,capture:"privateKeyPrime2"},{name:"RSAPrivateKey.exponent1",tagClass:a.Class.UNIVERSAL,type:a.Type.INTEGER,constructed:!1,capture:"privateKeyExponent1"},{name:"RSAPrivateKey.exponent2",tagClass:a.Class.UNIVERSAL,type:a.Type.INTEGER,constructed:!1,capture:"privateKeyExponent2"},{name:"RSAPrivateKey.coefficient",tagClass:a.Class.UNIVERSAL,type:a.Type.INTEGER,constructed:!1,capture:"privateKeyCoefficient"}]},h={name:"RSAPublicKey",tagClass:a.Class.UNIVERSAL,type:a.Type.SEQUENCE,constructed:!0,value:[{name:"RSAPublicKey.modulus",tagClass:a.Class.UNIVERSAL,type:a.Type.INTEGER,constructed:!1,capture:"publicKeyModulus"},{name:"RSAPublicKey.exponent",tagClass:a.Class.UNIVERSAL,type:a.Type.INTEGER,constructed:!1,capture:"publicKeyExponent"}]},d=n.pki.rsa.publicKeyValidator={name:"SubjectPublicKeyInfo",tagClass:a.Class.UNIVERSAL,type:a.Type.SEQUENCE,constructed:!0,captureAsn1:"subjectPublicKeyInfo",value:[{name:"SubjectPublicKeyInfo.AlgorithmIdentifier",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:"publicKeyOid"}]},{name:"SubjectPublicKeyInfo.subjectPublicKey",tagClass:a.Class.UNIVERSAL,type:a.Type.BITSTRING,constructed:!1,value:[{name:"SubjectPublicKeyInfo.subjectPublicKey.RSAPublicKey",tagClass:a.Class.UNIVERSAL,type:a.Type.SEQUENCE,constructed:!0,optional:!0,captureAsn1:"rsaPublicKey"}]}]},p={name:"DigestInfo",tagClass:a.Class.UNIVERSAL,type:a.Type.SEQUENCE,constructed:!0,value:[{name:"DigestInfo.DigestAlgorithm",tagClass:a.Class.UNIVERSAL,type:a.Type.SEQUENCE,constructed:!0,value:[{name:"DigestInfo.DigestAlgorithm.algorithmIdentifier",tagClass:a.Class.UNIVERSAL,type:a.Type.OID,constructed:!1,capture:"algorithmIdentifier"},{name:"DigestInfo.DigestAlgorithm.parameters",tagClass:a.Class.UNIVERSAL,type:a.Type.NULL,capture:"parameters",optional:!0,constructed:!1}]},{name:"DigestInfo.digest",tagClass:a.Class.UNIVERSAL,type:a.Type.OCTETSTRING,constructed:!1,capture:"digest"}]},v=function(e){var t;if(!(e.algorithm in u.oids)){var r=new Error("Unknown message digest algorithm.");throw r.algorithm=e.algorithm,r}t=u.oids[e.algorithm];var n=a.oidToDer(t).getBytes(),i=a.create(a.Class.UNIVERSAL,a.Type.SEQUENCE,!0,[]),o=a.create(a.Class.UNIVERSAL,a.Type.SEQUENCE,!0,[]);o.value.push(a.create(a.Class.UNIVERSAL,a.Type.OID,!1,n)),o.value.push(a.create(a.Class.UNIVERSAL,a.Type.NULL,!1,""));var s=a.create(a.Class.UNIVERSAL,a.Type.OCTETSTRING,!1,e.digest().getBytes());return i.value.push(o),i.value.push(s),a.toDer(i).getBytes()},g=function(e,t,r){if(r)return e.modPow(t.e,t.n);if(!t.p||!t.q)return e.modPow(t.d,t.n);var o;t.dP||(t.dP=t.d.mod(t.p.subtract(i.ONE))),t.dQ||(t.dQ=t.d.mod(t.q.subtract(i.ONE))),t.qInv||(t.qInv=t.q.modInverse(t.p));do{o=new i(n.util.bytesToHex(n.random.getBytes(t.n.bitLength()/8)),16)}while(o.compareTo(t.n)>=0||!o.gcd(t.n).equals(i.ONE));for(var a=(e=e.multiply(o.modPow(t.e,t.n)).mod(t.n)).mod(t.p).modPow(t.dP,t.p),s=e.mod(t.q).modPow(t.dQ,t.q);a.compareTo(s)<0;)a=a.add(t.p);var u=a.subtract(s).multiply(t.qInv).mod(t.p).multiply(t.q).add(s);return u=u.multiply(o.modInverse(t.n)).mod(t.n)};function y(e,t,r){var i=n.util.createBuffer(),o=Math.ceil(t.n.bitLength()/8);if(e.length>o-11){var a=new Error("Message is too long for PKCS#1 v1.5 padding.");throw a.length=e.length,a.max=o-11,a}i.putByte(0),i.putByte(r);var s,u=o-3-e.length;if(0===r||1===r){s=0===r?0:255;for(var c=0;c0;){var l=0,f=n.random.getBytes(u);for(c=0;c1;){if(255!==a.getByte()){--a.read;break}++c}else if(2===u)for(c=0;a.length()>1;){if(0===a.getByte()){--a.read;break}++c}if(0!==a.getByte()||c!==o-3-a.length())throw new Error("Encryption block is invalid.");return a.getBytes()}function b(e,t,r){"function"===typeof t&&(r=t,t={});var o={algorithm:{name:(t=t||{}).algorithm||"PRIMEINC",options:{workers:t.workers||2,workLoad:t.workLoad||100,workerScript:t.workerScript}}};function a(){s(e.pBits,(function(t,n){return t?r(t):(e.p=n,null!==e.q?c(t,e.q):void s(e.qBits,c))}))}function s(e,t){n.prime.generateProbablePrime(e,o,t)}function c(t,n){if(t)return r(t);if(e.q=n,e.p.compareTo(e.q)<0){var o=e.p;e.p=e.q,e.q=o}if(0!==e.p.subtract(i.ONE).gcd(e.e).compareTo(i.ONE))return e.p=null,void a();if(0!==e.q.subtract(i.ONE).gcd(e.e).compareTo(i.ONE))return e.q=null,void s(e.qBits,c);if(e.p1=e.p.subtract(i.ONE),e.q1=e.q.subtract(i.ONE),e.phi=e.p1.multiply(e.q1),0!==e.phi.gcd(e.e).compareTo(i.ONE))return e.p=e.q=null,void a();if(e.n=e.p.multiply(e.q),e.n.bitLength()!==e.bits)return e.q=null,void s(e.qBits,c);var l=e.e.modInverse(e.phi);e.keys={privateKey:u.rsa.setPrivateKey(e.n,e.e,l,e.p,e.q,l.mod(e.p1),l.mod(e.q1),e.q.modInverse(e.p)),publicKey:u.rsa.setPublicKey(e.n,e.e)},r(null,e.keys)}"prng"in t&&(o.prng=t.prng),a()}function w(e){var t=e.toString(16);t[0]>="8"&&(t="00"+t);var r=n.util.hexToBytes(t);return r.length>1&&(0===r.charCodeAt(0)&&0===(128&r.charCodeAt(1))||255===r.charCodeAt(0)&&128===(128&r.charCodeAt(1)))?r.substr(1):r}function k(e){return e<=100?27:e<=150?18:e<=200?15:e<=250?12:e<=300?9:e<=350?8:e<=400?7:e<=500?6:e<=600?5:e<=800?4:e<=1250?3:2}function E(e){return n.util.isNodejs&&"function"===typeof o[e]}function x(e){return"undefined"!==typeof s.globalScope&&"object"===typeof s.globalScope.crypto&&"object"===typeof s.globalScope.crypto.subtle&&"function"===typeof s.globalScope.crypto.subtle[e]}function _(e){return"undefined"!==typeof s.globalScope&&"object"===typeof s.globalScope.msCrypto&&"object"===typeof s.globalScope.msCrypto.subtle&&"function"===typeof s.globalScope.msCrypto.subtle[e]}function S(e){for(var t=n.util.hexToBytes(e.toString(16)),r=new Uint8Array(t.length),i=0;i0;)l.putByte(0),--f;return l.putBytes(n.util.hexToBytes(c)),l.getBytes()},u.rsa.decrypt=function(e,t,r,o){var a=Math.ceil(t.n.bitLength()/8);if(e.length!==a){var s=new Error("Encrypted message length is invalid.");throw s.length=e.length,s.expected=a,s}var u=new i(n.util.createBuffer(e).toHex(),16);if(u.compareTo(t.n)>=0)throw new Error("Encrypted message is invalid.");for(var c=g(u,t,r).toString(16),l=n.util.createBuffer(),f=a-Math.ceil(c.length/2);f>0;)l.putByte(0),--f;return l.putBytes(n.util.hexToBytes(c)),!1!==o?m(l.getBytes(),t,r):l.getBytes()},u.rsa.createKeyPairGenerationState=function(e,t,r){"string"===typeof e&&(e=parseInt(e,10)),e=e||2048;var o,a=(r=r||{}).prng||n.random,s={nextBytes:function(e){for(var t=a.getBytesSync(e.length),r=0;r>1,pBits:e-(e>>1),pqState:0,num:null,keys:null}).e.fromInt(o.eInt),o},u.rsa.stepKeyPairGenerationState=function(e,t){"algorithm"in e||(e.algorithm="PRIMEINC");var r=new i(null);r.fromInt(30);for(var n,o=0,a=function(e,t){return e|t},s=+new Date,l=0;null===e.keys&&(t<=0||lf?e.pqState=0:e.num.isProbablePrime(k(e.num.bitLength()))?++e.pqState:e.num.dAddOffset(c[o++%8],0):2===e.pqState?e.pqState=0===e.num.subtract(i.ONE).gcd(e.e).compareTo(i.ONE)?3:0:3===e.pqState&&(e.pqState=0,null===e.p?e.p=e.num:e.q=e.num,null!==e.p&&null!==e.q&&++e.state,e.num=null)}else if(1===e.state)e.p.compareTo(e.q)<0&&(e.num=e.p,e.p=e.q,e.q=e.num),++e.state;else if(2===e.state)e.p1=e.p.subtract(i.ONE),e.q1=e.q.subtract(i.ONE),e.phi=e.p1.multiply(e.q1),++e.state;else if(3===e.state)0===e.phi.gcd(e.e).compareTo(i.ONE)?++e.state:(e.p=null,e.q=null,e.state=0);else if(4===e.state)e.n=e.p.multiply(e.q),e.n.bitLength()===e.bits?++e.state:(e.q=null,e.state=0);else if(5===e.state){var d=e.e.modInverse(e.phi);e.keys={privateKey:u.rsa.setPrivateKey(e.n,e.e,d,e.p,e.q,d.mod(e.p1),d.mod(e.q1),e.q.modInverse(e.p)),publicKey:u.rsa.setPublicKey(e.n,e.e)}}l+=(n=+new Date)-s,s=n}return null!==e.keys},u.rsa.generateKeyPair=function(e,t,r,i){if(1===arguments.length?"object"===typeof e?(r=e,e=void 0):"function"===typeof e&&(i=e,e=void 0):2===arguments.length?"number"===typeof e?"function"===typeof t?(i=t,t=void 0):"number"!==typeof t&&(r=t,t=void 0):(r=e,i=t,e=void 0,t=void 0):3===arguments.length&&("number"===typeof t?"function"===typeof r&&(i=r,r=void 0):(i=r,r=t,t=void 0)),r=r||{},void 0===e&&(e=r.bits||2048),void 0===t&&(t=r.e||65537),!n.options.usePureJavaScript&&!r.prng&&e>=256&&e<=16384&&(65537===t||3===t))if(i){if(E("generateKeyPair"))return o.generateKeyPair("rsa",{modulusLength:e,publicExponent:t,publicKeyEncoding:{type:"spki",format:"pem"},privateKeyEncoding:{type:"pkcs8",format:"pem"}},(function(e,t,r){if(e)return i(e);i(null,{privateKey:u.privateKeyFromPem(r),publicKey:u.publicKeyFromPem(t)})}));if(x("generateKey")&&x("exportKey"))return s.globalScope.crypto.subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:e,publicExponent:S(t),hash:{name:"SHA-256"}},!0,["sign","verify"]).then((function(e){return s.globalScope.crypto.subtle.exportKey("pkcs8",e.privateKey)})).then(void 0,(function(e){i(e)})).then((function(e){if(e){var t=u.privateKeyFromAsn1(a.fromDer(n.util.createBuffer(e)));i(null,{privateKey:t,publicKey:u.setRsaPublicKey(t.n,t.e)})}}));if(_("generateKey")&&_("exportKey")){var c=s.globalScope.msCrypto.subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:e,publicExponent:S(t),hash:{name:"SHA-256"}},!0,["sign","verify"]);return c.oncomplete=function(e){var t=e.target.result,r=s.globalScope.msCrypto.subtle.exportKey("pkcs8",t.privateKey);r.oncomplete=function(e){var t=e.target.result,r=u.privateKeyFromAsn1(a.fromDer(n.util.createBuffer(t)));i(null,{privateKey:r,publicKey:u.setRsaPublicKey(r.n,r.e)})},r.onerror=function(e){i(e)}},void(c.onerror=function(e){i(e)})}}else if(E("generateKeyPairSync")){var l=o.generateKeyPairSync("rsa",{modulusLength:e,publicExponent:t,publicKeyEncoding:{type:"spki",format:"pem"},privateKeyEncoding:{type:"pkcs8",format:"pem"}});return{privateKey:u.privateKeyFromPem(l.privateKey),publicKey:u.publicKeyFromPem(l.publicKey)}}var f=u.rsa.createKeyPairGenerationState(e,t,r);if(!i)return u.rsa.stepKeyPairGenerationState(f,0),f.keys;b(f,r,i)},u.setRsaPublicKey=u.rsa.setPublicKey=function(e,t){var r={n:e,e:t,encrypt:function(e,t,i){if("string"===typeof t?t=t.toUpperCase():void 0===t&&(t="RSAES-PKCS1-V1_5"),"RSAES-PKCS1-V1_5"===t)t={encode:function(e,t,r){return y(e,t,2).getBytes()}};else if("RSA-OAEP"===t||"RSAES-OAEP"===t)t={encode:function(e,t){return n.pkcs1.encode_rsa_oaep(t,e,i)}};else if(-1!==["RAW","NONE","NULL",null].indexOf(t))t={encode:function(e){return e}};else if("string"===typeof t)throw new Error('Unsupported encryption scheme: "'+t+'".');var o=t.encode(e,r,!0);return u.rsa.encrypt(o,r,!0)},verify:function(e,t,i,o){"string"===typeof i?i=i.toUpperCase():void 0===i&&(i="RSASSA-PKCS1-V1_5"),void 0===o&&(o={_parseAllDigestBytes:!0}),"_parseAllDigestBytes"in o||(o._parseAllDigestBytes=!0),"RSASSA-PKCS1-V1_5"===i?i={verify:function(e,t){t=m(t,r,!0);var i=a.fromDer(t,{parseAllBytes:o._parseAllDigestBytes}),s={},u=[];if(!a.validate(i,p,s,u))throw(c=new Error("ASN.1 object does not contain a valid RSASSA-PKCS1-v1_5 DigestInfo value.")).errors=u,c;var c,l=a.derToOid(s.algorithmIdentifier);if(l!==n.oids.md2&&l!==n.oids.md5&&l!==n.oids.sha1&&l!==n.oids.sha224&&l!==n.oids.sha256&&l!==n.oids.sha384&&l!==n.oids.sha512&&l!==n.oids["sha512-224"]&&l!==n.oids["sha512-256"])throw(c=new Error("Unknown RSASSA-PKCS1-v1_5 DigestAlgorithm identifier.")).oid=l,c;if((l===n.oids.md2||l===n.oids.md5)&&!("parameters"in s))throw new Error("ASN.1 object does not contain a valid RSASSA-PKCS1-v1_5 DigestInfo value. Missing algorithm identifer NULL parameters.");return e===s.digest}}:"NONE"!==i&&"NULL"!==i&&null!==i||(i={verify:function(e,t){return e===(t=m(t,r,!0))}});var s=u.rsa.decrypt(t,r,!0,!1);return i.verify(e,s,r.n.bitLength())}};return r},u.setRsaPrivateKey=u.rsa.setPrivateKey=function(e,t,r,i,o,a,s,c){var l={n:e,e:t,d:r,p:i,q:o,dP:a,dQ:s,qInv:c,decrypt:function(e,t,r){"string"===typeof t?t=t.toUpperCase():void 0===t&&(t="RSAES-PKCS1-V1_5");var i=u.rsa.decrypt(e,l,!1,!1);if("RSAES-PKCS1-V1_5"===t)t={decode:m};else if("RSA-OAEP"===t||"RSAES-OAEP"===t)t={decode:function(e,t){return n.pkcs1.decode_rsa_oaep(t,e,r)}};else{if(-1===["RAW","NONE","NULL",null].indexOf(t))throw new Error('Unsupported encryption scheme: "'+t+'".');t={decode:function(e){return e}}}return t.decode(i,l,!1)},sign:function(e,t){var r=!1;"string"===typeof t&&(t=t.toUpperCase()),void 0===t||"RSASSA-PKCS1-V1_5"===t?(t={encode:v},r=1):"NONE"!==t&&"NULL"!==t&&null!==t||(t={encode:function(){return e}},r=1);var n=t.encode(e,l.n.bitLength());return u.rsa.encrypt(n,l,r)}};return l},u.wrapRsaPrivateKey=function(e){return a.create(a.Class.UNIVERSAL,a.Type.SEQUENCE,!0,[a.create(a.Class.UNIVERSAL,a.Type.INTEGER,!1,a.integerToDer(0).getBytes()),a.create(a.Class.UNIVERSAL,a.Type.SEQUENCE,!0,[a.create(a.Class.UNIVERSAL,a.Type.OID,!1,a.oidToDer(u.oids.rsaEncryption).getBytes()),a.create(a.Class.UNIVERSAL,a.Type.NULL,!1,"")]),a.create(a.Class.UNIVERSAL,a.Type.OCTETSTRING,!1,a.toDer(e).getBytes())])},u.privateKeyFromAsn1=function(e){var t,r,o,s,c,h,d,p,v={},g=[];if(a.validate(e,l,v,g)&&(e=a.fromDer(n.util.createBuffer(v.privateKey))),v={},g=[],!a.validate(e,f,v,g)){var y=new Error("Cannot read private key. ASN.1 object does not contain an RSAPrivateKey.");throw y.errors=g,y}return t=n.util.createBuffer(v.privateKeyModulus).toHex(),r=n.util.createBuffer(v.privateKeyPublicExponent).toHex(),o=n.util.createBuffer(v.privateKeyPrivateExponent).toHex(),s=n.util.createBuffer(v.privateKeyPrime1).toHex(),c=n.util.createBuffer(v.privateKeyPrime2).toHex(),h=n.util.createBuffer(v.privateKeyExponent1).toHex(),d=n.util.createBuffer(v.privateKeyExponent2).toHex(),p=n.util.createBuffer(v.privateKeyCoefficient).toHex(),u.setRsaPrivateKey(new i(t,16),new i(r,16),new i(o,16),new i(s,16),new i(c,16),new i(h,16),new i(d,16),new i(p,16))},u.privateKeyToAsn1=u.privateKeyToRSAPrivateKey=function(e){return a.create(a.Class.UNIVERSAL,a.Type.SEQUENCE,!0,[a.create(a.Class.UNIVERSAL,a.Type.INTEGER,!1,a.integerToDer(0).getBytes()),a.create(a.Class.UNIVERSAL,a.Type.INTEGER,!1,w(e.n)),a.create(a.Class.UNIVERSAL,a.Type.INTEGER,!1,w(e.e)),a.create(a.Class.UNIVERSAL,a.Type.INTEGER,!1,w(e.d)),a.create(a.Class.UNIVERSAL,a.Type.INTEGER,!1,w(e.p)),a.create(a.Class.UNIVERSAL,a.Type.INTEGER,!1,w(e.q)),a.create(a.Class.UNIVERSAL,a.Type.INTEGER,!1,w(e.dP)),a.create(a.Class.UNIVERSAL,a.Type.INTEGER,!1,w(e.dQ)),a.create(a.Class.UNIVERSAL,a.Type.INTEGER,!1,w(e.qInv))])},u.publicKeyFromAsn1=function(e){var t={},r=[];if(a.validate(e,d,t,r)){var o,s=a.derToOid(t.publicKeyOid);if(s!==u.oids.rsaEncryption)throw(o=new Error("Cannot read public key. Unknown OID.")).oid=s,o;e=t.rsaPublicKey}if(r=[],!a.validate(e,h,t,r))throw(o=new Error("Cannot read public key. ASN.1 object does not contain an RSAPublicKey.")).errors=r,o;var c=n.util.createBuffer(t.publicKeyModulus).toHex(),l=n.util.createBuffer(t.publicKeyExponent).toHex();return u.setRsaPublicKey(new i(c,16),new i(l,16))},u.publicKeyToAsn1=u.publicKeyToSubjectPublicKeyInfo=function(e){return 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(u.oids.rsaEncryption).getBytes()),a.create(a.Class.UNIVERSAL,a.Type.NULL,!1,"")]),a.create(a.Class.UNIVERSAL,a.Type.BITSTRING,!1,[u.publicKeyToRSAPublicKey(e)])])},u.publicKeyToRSAPublicKey=function(e){return a.create(a.Class.UNIVERSAL,a.Type.SEQUENCE,!0,[a.create(a.Class.UNIVERSAL,a.Type.INTEGER,!1,w(e.n)),a.create(a.Class.UNIVERSAL,a.Type.INTEGER,!1,w(e.e))])}},5458:function(e,t,r){var n=r(3299);r(4744),r(9327);var i=e.exports=n.sha1=n.sha1||{};n.md.sha1=n.md.algorithms.sha1=i,i.create=function(){a||(o=String.fromCharCode(128),o+=n.util.fillString(String.fromCharCode(0),64),a=!0);var e=null,t=n.util.createBuffer(),r=new Array(80),i={algorithm:"sha1",blockLength:64,digestLength:20,messageLength:0,fullMessageLength:null,messageLengthSize:8,start:function(){i.messageLength=0,i.fullMessageLength=i.messageLength64=[];for(var r=i.messageLengthSize/4,o=0;o>>0,u>>>0];for(var c=i.fullMessageLength.length-1;c>=0;--c)i.fullMessageLength[c]+=u[1],u[1]=u[0]+(i.fullMessageLength[c]/4294967296>>>0),i.fullMessageLength[c]=i.fullMessageLength[c]>>>0,u[0]=u[1]/4294967296>>>0;return t.putBytes(o),s(e,r,t),(t.read>2048||0===t.length())&&t.compact(),i},i.digest=function(){var a=n.util.createBuffer();a.putBytes(t.bytes());var u,c=i.fullMessageLength[i.fullMessageLength.length-1]+i.messageLengthSize&i.blockLength-1;a.putBytes(o.substr(0,i.blockLength-c));for(var l=8*i.fullMessageLength[0],f=0;f>>0,a.putInt32(l>>>0),l=u>>>0;a.putInt32(l);var h={h0:e.h0,h1:e.h1,h2:e.h2,h3:e.h3,h4:e.h4};s(h,r,a);var d=n.util.createBuffer();return d.putInt32(h.h0),d.putInt32(h.h1),d.putInt32(h.h2),d.putInt32(h.h3),d.putInt32(h.h4),d},i};var o=null,a=!1;function s(e,t,r){for(var n,i,o,a,s,u,c,l=r.length();l>=64;){for(i=e.h0,o=e.h1,a=e.h2,s=e.h3,u=e.h4,c=0;c<16;++c)n=r.getInt32(),t[c]=n,n=(i<<5|i>>>27)+(s^o&(a^s))+u+1518500249+n,u=s,s=a,a=(o<<30|o>>>2)>>>0,o=i,i=n;for(;c<20;++c)n=(n=t[c-3]^t[c-8]^t[c-14]^t[c-16])<<1|n>>>31,t[c]=n,n=(i<<5|i>>>27)+(s^o&(a^s))+u+1518500249+n,u=s,s=a,a=(o<<30|o>>>2)>>>0,o=i,i=n;for(;c<32;++c)n=(n=t[c-3]^t[c-8]^t[c-14]^t[c-16])<<1|n>>>31,t[c]=n,n=(i<<5|i>>>27)+(o^a^s)+u+1859775393+n,u=s,s=a,a=(o<<30|o>>>2)>>>0,o=i,i=n;for(;c<40;++c)n=(n=t[c-6]^t[c-16]^t[c-28]^t[c-32])<<2|n>>>30,t[c]=n,n=(i<<5|i>>>27)+(o^a^s)+u+1859775393+n,u=s,s=a,a=(o<<30|o>>>2)>>>0,o=i,i=n;for(;c<60;++c)n=(n=t[c-6]^t[c-16]^t[c-28]^t[c-32])<<2|n>>>30,t[c]=n,n=(i<<5|i>>>27)+(o&a|s&(o^a))+u+2400959708+n,u=s,s=a,a=(o<<30|o>>>2)>>>0,o=i,i=n;for(;c<80;++c)n=(n=t[c-6]^t[c-16]^t[c-28]^t[c-32])<<2|n>>>30,t[c]=n,n=(i<<5|i>>>27)+(o^a^s)+u+3395469782+n,u=s,s=a,a=(o<<30|o>>>2)>>>0,o=i,i=n;e.h0=e.h0+i|0,e.h1=e.h1+o|0,e.h2=e.h2+a|0,e.h3=e.h3+s|0,e.h4=e.h4+u|0,l-=64}}},8282:function(e,t,r){var n=r(3299);r(4744),r(9327);var i=e.exports=n.sha256=n.sha256||{};n.md.sha256=n.md.algorithms.sha256=i,i.create=function(){a||(o=String.fromCharCode(128),o+=n.util.fillString(String.fromCharCode(0),64),s=[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],a=!0);var e=null,t=n.util.createBuffer(),r=new Array(64),i={algorithm:"sha256",blockLength:64,digestLength:32,messageLength:0,fullMessageLength:null,messageLengthSize:8,start:function(){i.messageLength=0,i.fullMessageLength=i.messageLength64=[];for(var r=i.messageLengthSize/4,o=0;o>>0,s>>>0];for(var c=i.fullMessageLength.length-1;c>=0;--c)i.fullMessageLength[c]+=s[1],s[1]=s[0]+(i.fullMessageLength[c]/4294967296>>>0),i.fullMessageLength[c]=i.fullMessageLength[c]>>>0,s[0]=s[1]/4294967296>>>0;return t.putBytes(o),u(e,r,t),(t.read>2048||0===t.length())&&t.compact(),i},i.digest=function(){var a=n.util.createBuffer();a.putBytes(t.bytes());var s,c=i.fullMessageLength[i.fullMessageLength.length-1]+i.messageLengthSize&i.blockLength-1;a.putBytes(o.substr(0,i.blockLength-c));for(var l=8*i.fullMessageLength[0],f=0;f>>0,a.putInt32(l>>>0),l=s>>>0;a.putInt32(l);var h={h0:e.h0,h1:e.h1,h2:e.h2,h3:e.h3,h4:e.h4,h5:e.h5,h6:e.h6,h7:e.h7};u(h,r,a);var d=n.util.createBuffer();return d.putInt32(h.h0),d.putInt32(h.h1),d.putInt32(h.h2),d.putInt32(h.h3),d.putInt32(h.h4),d.putInt32(h.h5),d.putInt32(h.h6),d.putInt32(h.h7),d},i};var o=null,a=!1,s=null;function u(e,t,r){for(var n,i,o,a,u,c,l,f,h,d,p,v,g,y=r.length();y>=64;){for(u=0;u<16;++u)t[u]=r.getInt32();for(;u<64;++u)n=((n=t[u-2])>>>17|n<<15)^(n>>>19|n<<13)^n>>>10,i=((i=t[u-15])>>>7|i<<25)^(i>>>18|i<<14)^i>>>3,t[u]=n+t[u-7]+i+t[u-16]|0;for(c=e.h0,l=e.h1,f=e.h2,h=e.h3,d=e.h4,p=e.h5,v=e.h6,g=e.h7,u=0;u<64;++u)o=(c>>>2|c<<30)^(c>>>13|c<<19)^(c>>>22|c<<10),a=c&l|f&(c^l),n=g+((d>>>6|d<<26)^(d>>>11|d<<21)^(d>>>25|d<<7))+(v^d&(p^v))+s[u]+t[u],g=v,v=p,p=d,d=h+n>>>0,h=f,f=l,l=c,c=n+(i=o+a)>>>0;e.h0=e.h0+c|0,e.h1=e.h1+l|0,e.h2=e.h2+f|0,e.h3=e.h3+h|0,e.h4=e.h4+d|0,e.h5=e.h5+p|0,e.h6=e.h6+v|0,e.h7=e.h7+g|0,y-=64}}},6237:function(e,t,r){var n=r(3299);r(4744),r(9327);var i=e.exports=n.sha512=n.sha512||{};n.md.sha512=n.md.algorithms.sha512=i;var o=n.sha384=n.sha512.sha384=n.sha512.sha384||{};o.create=function(){return i.create("SHA-384")},n.md.sha384=n.md.algorithms.sha384=o,n.sha512.sha256=n.sha512.sha256||{create:function(){return i.create("SHA-512/256")}},n.md["sha512/256"]=n.md.algorithms["sha512/256"]=n.sha512.sha256,n.sha512.sha224=n.sha512.sha224||{create:function(){return i.create("SHA-512/224")}},n.md["sha512/224"]=n.md.algorithms["sha512/224"]=n.sha512.sha224,i.create=function(e){if(s||(a=String.fromCharCode(128),a+=n.util.fillString(String.fromCharCode(0),128),u=[[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]],(c={})["SHA-512"]=[[1779033703,4089235720],[3144134277,2227873595],[1013904242,4271175723],[2773480762,1595750129],[1359893119,2917565137],[2600822924,725511199],[528734635,4215389547],[1541459225,327033209]],c["SHA-384"]=[[3418070365,3238371032],[1654270250,914150663],[2438529370,812702999],[355462360,4144912697],[1731405415,4290775857],[2394180231,1750603025],[3675008525,1694076839],[1203062813,3204075428]],c["SHA-512/256"]=[[573645204,4230739756],[2673172387,3360449730],[596883563,1867755857],[2520282905,1497426621],[2519219938,2827943907],[3193839141,1401305490],[721525244,746961066],[246885852,2177182882]],c["SHA-512/224"]=[[2352822216,424955298],[1944164710,2312950998],[502970286,855612546],[1738396948,1479516111],[258812777,2077511080],[2011393907,79989058],[1067287976,1780299464],[286451373,2446758561]],s=!0),"undefined"===typeof e&&(e="SHA-512"),!(e in c))throw new Error("Invalid SHA-512 algorithm: "+e);for(var t=c[e],r=null,i=n.util.createBuffer(),o=new Array(80),f=0;f<80;++f)o[f]=new Array(2);var h=64;switch(e){case"SHA-384":h=48;break;case"SHA-512/256":h=32;break;case"SHA-512/224":h=28}var d={algorithm:e.replace("-","").toLowerCase(),blockLength:128,digestLength:h,messageLength:0,fullMessageLength:null,messageLengthSize:16,start:function(){d.messageLength=0,d.fullMessageLength=d.messageLength128=[];for(var e=d.messageLengthSize/4,o=0;o>>0,a>>>0];for(var s=d.fullMessageLength.length-1;s>=0;--s)d.fullMessageLength[s]+=a[1],a[1]=a[0]+(d.fullMessageLength[s]/4294967296>>>0),d.fullMessageLength[s]=d.fullMessageLength[s]>>>0,a[0]=a[1]/4294967296>>>0;return i.putBytes(e),l(r,o,i),(i.read>2048||0===i.length())&&i.compact(),d},d.digest=function(){var t=n.util.createBuffer();t.putBytes(i.bytes());var s,u=d.fullMessageLength[d.fullMessageLength.length-1]+d.messageLengthSize&d.blockLength-1;t.putBytes(a.substr(0,d.blockLength-u));for(var c=8*d.fullMessageLength[0],f=0;f>>0,t.putInt32(c>>>0),c=s>>>0;t.putInt32(c);var h=new Array(r.length);for(f=0;f=128;){for(P=0;P<16;++P)t[P][0]=r.getInt32()>>>0,t[P][1]=r.getInt32()>>>0;for(;P<80;++P)n=(((R=(M=t[P-2])[0])>>>19|(B=M[1])<<13)^(B>>>29|R<<3)^R>>>6)>>>0,i=((R<<13|B>>>19)^(B<<3|R>>>29)^(R<<26|B>>>6))>>>0,o=(((R=(O=t[P-15])[0])>>>1|(B=O[1])<<31)^(R>>>8|B<<24)^R>>>7)>>>0,a=((R<<31|B>>>1)^(R<<24|B>>>8)^(R<<25|B>>>7))>>>0,N=t[P-7],D=t[P-16],B=i+N[1]+a+D[1],t[P][0]=n+N[0]+o+D[0]+(B/4294967296>>>0)>>>0,t[P][1]=B>>>0;for(p=e[0][0],v=e[0][1],g=e[1][0],y=e[1][1],m=e[2][0],b=e[2][1],w=e[3][0],k=e[3][1],E=e[4][0],x=e[4][1],_=e[5][0],S=e[5][1],A=e[6][0],I=e[6][1],C=e[7][0],T=e[7][1],P=0;P<80;++P)l=((E>>>14|x<<18)^(E>>>18|x<<14)^(x>>>9|E<<23))>>>0,f=(A^E&(_^A))>>>0,s=((p>>>28|v<<4)^(v>>>2|p<<30)^(v>>>7|p<<25))>>>0,c=((p<<4|v>>>28)^(v<<30|p>>>2)^(v<<25|p>>>7))>>>0,h=(p&g|m&(p^g))>>>0,d=(v&y|b&(v^y))>>>0,B=T+(((E<<18|x>>>14)^(E<<14|x>>>18)^(x<<23|E>>>9))>>>0)+((I^x&(S^I))>>>0)+u[P][1]+t[P][1],n=C+l+f+u[P][0]+t[P][0]+(B/4294967296>>>0)>>>0,i=B>>>0,o=s+h+((B=c+d)/4294967296>>>0)>>>0,a=B>>>0,C=A,T=I,A=_,I=S,_=E,S=x,E=w+n+((B=k+i)/4294967296>>>0)>>>0,x=B>>>0,w=m,k=b,m=g,b=y,g=p,y=v,p=n+o+((B=i+a)/4294967296>>>0)>>>0,v=B>>>0;B=e[0][1]+v,e[0][0]=e[0][0]+p+(B/4294967296>>>0)>>>0,e[0][1]=B>>>0,B=e[1][1]+y,e[1][0]=e[1][0]+g+(B/4294967296>>>0)>>>0,e[1][1]=B>>>0,B=e[2][1]+b,e[2][0]=e[2][0]+m+(B/4294967296>>>0)>>>0,e[2][1]=B>>>0,B=e[3][1]+k,e[3][0]=e[3][0]+w+(B/4294967296>>>0)>>>0,e[3][1]=B>>>0,B=e[4][1]+x,e[4][0]=e[4][0]+E+(B/4294967296>>>0)>>>0,e[4][1]=B>>>0,B=e[5][1]+S,e[5][0]=e[5][0]+_+(B/4294967296>>>0)>>>0,e[5][1]=B>>>0,B=e[6][1]+I,e[6][0]=e[6][0]+A+(B/4294967296>>>0)>>>0,e[6][1]=B>>>0,B=e[7][1]+T,e[7][0]=e[7][0]+C+(B/4294967296>>>0)>>>0,e[7][1]=B>>>0,L-=128}}},9327:function(e,t,r){var n=r(3299),i=r(8270),o=e.exports=n.util=n.util||{};function a(e){if(8!==e&&16!==e&&24!==e&&32!==e)throw new Error("Only 8, 16, 24, or 32 bits supported: "+e)}function s(e){if(this.data="",this.read=0,"string"===typeof e)this.data=e;else if(o.isArrayBuffer(e)||o.isArrayBufferView(e))if("undefined"!==typeof Buffer&&e instanceof Buffer)this.data=e.toString("binary");else{var t=new Uint8Array(e);try{this.data=String.fromCharCode.apply(null,t)}catch(n){for(var r=0;r15?(r=Date.now(),a(e)):(t.push(e),1===t.length&&i.setAttribute("a",n=!n))}}o.nextTick=o.setImmediate}(),o.isNodejs="undefined"!==typeof process&&process.versions&&process.versions.node,o.globalScope=o.isNodejs?r.g:"undefined"===typeof self?window:self,o.isArray=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)},o.isArrayBuffer=function(e){return"undefined"!==typeof ArrayBuffer&&e instanceof ArrayBuffer},o.isArrayBufferView=function(e){return e&&o.isArrayBuffer(e.buffer)&&void 0!==e.byteLength},o.ByteBuffer=s,o.ByteStringBuffer=s;o.ByteStringBuffer.prototype._optimizeConstructedString=function(e){this._constructedStringLength+=e,this._constructedStringLength>4096&&(this.data.substr(0,1),this._constructedStringLength=0)},o.ByteStringBuffer.prototype.length=function(){return this.data.length-this.read},o.ByteStringBuffer.prototype.isEmpty=function(){return this.length()<=0},o.ByteStringBuffer.prototype.putByte=function(e){return this.putBytes(String.fromCharCode(e))},o.ByteStringBuffer.prototype.fillWithByte=function(e,t){e=String.fromCharCode(e);for(var r=this.data;t>0;)1&t&&(r+=e),(t>>>=1)>0&&(e+=e);return this.data=r,this._optimizeConstructedString(t),this},o.ByteStringBuffer.prototype.putBytes=function(e){return this.data+=e,this._optimizeConstructedString(e.length),this},o.ByteStringBuffer.prototype.putString=function(e){return this.putBytes(o.encodeUtf8(e))},o.ByteStringBuffer.prototype.putInt16=function(e){return this.putBytes(String.fromCharCode(e>>8&255)+String.fromCharCode(255&e))},o.ByteStringBuffer.prototype.putInt24=function(e){return this.putBytes(String.fromCharCode(e>>16&255)+String.fromCharCode(e>>8&255)+String.fromCharCode(255&e))},o.ByteStringBuffer.prototype.putInt32=function(e){return this.putBytes(String.fromCharCode(e>>24&255)+String.fromCharCode(e>>16&255)+String.fromCharCode(e>>8&255)+String.fromCharCode(255&e))},o.ByteStringBuffer.prototype.putInt16Le=function(e){return this.putBytes(String.fromCharCode(255&e)+String.fromCharCode(e>>8&255))},o.ByteStringBuffer.prototype.putInt24Le=function(e){return this.putBytes(String.fromCharCode(255&e)+String.fromCharCode(e>>8&255)+String.fromCharCode(e>>16&255))},o.ByteStringBuffer.prototype.putInt32Le=function(e){return this.putBytes(String.fromCharCode(255&e)+String.fromCharCode(e>>8&255)+String.fromCharCode(e>>16&255)+String.fromCharCode(e>>24&255))},o.ByteStringBuffer.prototype.putInt=function(e,t){a(t);var r="";do{t-=8,r+=String.fromCharCode(e>>t&255)}while(t>0);return this.putBytes(r)},o.ByteStringBuffer.prototype.putSignedInt=function(e,t){return e<0&&(e+=2<0);return t},o.ByteStringBuffer.prototype.getSignedInt=function(e){var t=this.getInt(e),r=2<=r&&(t-=r<<1),t},o.ByteStringBuffer.prototype.getBytes=function(e){var t;return e?(e=Math.min(this.length(),e),t=this.data.slice(this.read,this.read+e),this.read+=e):0===e?t="":(t=0===this.read?this.data:this.data.slice(this.read),this.clear()),t},o.ByteStringBuffer.prototype.bytes=function(e){return"undefined"===typeof e?this.data.slice(this.read):this.data.slice(this.read,this.read+e)},o.ByteStringBuffer.prototype.at=function(e){return this.data.charCodeAt(this.read+e)},o.ByteStringBuffer.prototype.setAt=function(e,t){return this.data=this.data.substr(0,this.read+e)+String.fromCharCode(t)+this.data.substr(this.read+e+1),this},o.ByteStringBuffer.prototype.last=function(){return this.data.charCodeAt(this.data.length-1)},o.ByteStringBuffer.prototype.copy=function(){var e=o.createBuffer(this.data);return e.read=this.read,e},o.ByteStringBuffer.prototype.compact=function(){return this.read>0&&(this.data=this.data.slice(this.read),this.read=0),this},o.ByteStringBuffer.prototype.clear=function(){return this.data="",this.read=0,this},o.ByteStringBuffer.prototype.truncate=function(e){var t=Math.max(0,this.length()-e);return this.data=this.data.substr(this.read,t),this.read=0,this},o.ByteStringBuffer.prototype.toHex=function(){for(var e="",t=this.read;t=e)return this;t=Math.max(t||this.growSize,e);var r=new Uint8Array(this.data.buffer,this.data.byteOffset,this.data.byteLength),n=new Uint8Array(this.length()+t);return n.set(r),this.data=new DataView(n.buffer),this},o.DataBuffer.prototype.putByte=function(e){return this.accommodate(1),this.data.setUint8(this.write++,e),this},o.DataBuffer.prototype.fillWithByte=function(e,t){this.accommodate(t);for(var r=0;r>8&65535),this.data.setInt8(this.write,e>>16&255),this.write+=3,this},o.DataBuffer.prototype.putInt32=function(e){return this.accommodate(4),this.data.setInt32(this.write,e),this.write+=4,this},o.DataBuffer.prototype.putInt16Le=function(e){return this.accommodate(2),this.data.setInt16(this.write,e,!0),this.write+=2,this},o.DataBuffer.prototype.putInt24Le=function(e){return this.accommodate(3),this.data.setInt8(this.write,e>>16&255),this.data.setInt16(this.write,e>>8&65535,!0),this.write+=3,this},o.DataBuffer.prototype.putInt32Le=function(e){return this.accommodate(4),this.data.setInt32(this.write,e,!0),this.write+=4,this},o.DataBuffer.prototype.putInt=function(e,t){a(t),this.accommodate(t/8);do{t-=8,this.data.setInt8(this.write++,e>>t&255)}while(t>0);return this},o.DataBuffer.prototype.putSignedInt=function(e,t){return a(t),this.accommodate(t/8),e<0&&(e+=2<0);return t},o.DataBuffer.prototype.getSignedInt=function(e){var t=this.getInt(e),r=2<=r&&(t-=r<<1),t},o.DataBuffer.prototype.getBytes=function(e){var t;return e?(e=Math.min(this.length(),e),t=this.data.slice(this.read,this.read+e),this.read+=e):0===e?t="":(t=0===this.read?this.data:this.data.slice(this.read),this.clear()),t},o.DataBuffer.prototype.bytes=function(e){return"undefined"===typeof e?this.data.slice(this.read):this.data.slice(this.read,this.read+e)},o.DataBuffer.prototype.at=function(e){return this.data.getUint8(this.read+e)},o.DataBuffer.prototype.setAt=function(e,t){return this.data.setUint8(e,t),this},o.DataBuffer.prototype.last=function(){return this.data.getUint8(this.write-1)},o.DataBuffer.prototype.copy=function(){return new o.DataBuffer(this)},o.DataBuffer.prototype.compact=function(){if(this.read>0){var e=new Uint8Array(this.data.buffer,this.read),t=new Uint8Array(e.byteLength);t.set(e),this.data=new DataView(t),this.write-=this.read,this.read=0}return this},o.DataBuffer.prototype.clear=function(){return this.data=new DataView(new ArrayBuffer(0)),this.read=this.write=0,this},o.DataBuffer.prototype.truncate=function(e){return this.write=Math.max(0,this.length()-e),this.read=Math.min(this.read,this.write),this},o.DataBuffer.prototype.toHex=function(){for(var e="",t=this.read;t0;)1&t&&(r+=e),(t>>>=1)>0&&(e+=e);return r},o.xorBytes=function(e,t,r){for(var n="",i="",o="",a=0,s=0;r>0;--r,++a)i=e.charCodeAt(a)^t.charCodeAt(a),s>=10&&(n+=o,o="",s=0),o+=String.fromCharCode(i),++s;return n+=o},o.hexToBytes=function(e){var t="",r=0;for(!0&e.length&&(r=1,t+=String.fromCharCode(parseInt(e[0],16)));r>24&255)+String.fromCharCode(e>>16&255)+String.fromCharCode(e>>8&255)+String.fromCharCode(255&e)};var u="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",c=[62,-1,-1,-1,63,52,53,54,55,56,57,58,59,60,61,-1,-1,-1,64,-1,-1,-1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,-1,-1,-1,-1,-1,-1,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51],l="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";o.encode64=function(e,t){for(var r,n,i,o="",a="",s=0;s>2),o+=u.charAt((3&r)<<4|n>>4),isNaN(n)?o+="==":(o+=u.charAt((15&n)<<2|i>>6),o+=isNaN(i)?"=":u.charAt(63&i)),t&&o.length>t&&(a+=o.substr(0,t)+"\r\n",o=o.substr(t));return a+=o},o.decode64=function(e){e=e.replace(/[^A-Za-z0-9\+\/\=]/g,"");for(var t,r,n,i,o="",a=0;a>4),64!==n&&(o+=String.fromCharCode((15&r)<<4|n>>2),64!==i&&(o+=String.fromCharCode((3&n)<<6|i)));return o},o.encodeUtf8=function(e){return unescape(encodeURIComponent(e))},o.decodeUtf8=function(e){return decodeURIComponent(escape(e))},o.binary={raw:{},hex:{},base64:{},base58:{},baseN:{encode:i.encode,decode:i.decode}},o.binary.raw.encode=function(e){return String.fromCharCode.apply(null,e)},o.binary.raw.decode=function(e,t,r){var n=t;n||(n=new Uint8Array(e.length));for(var i=r=r||0,o=0;o>2),o+=u.charAt((3&r)<<4|n>>4),isNaN(n)?o+="==":(o+=u.charAt((15&n)<<2|i>>6),o+=isNaN(i)?"=":u.charAt(63&i)),t&&o.length>t&&(a+=o.substr(0,t)+"\r\n",o=o.substr(t));return a+=o},o.binary.base64.decode=function(e,t,r){var n,i,o,a,s=t;s||(s=new Uint8Array(3*Math.ceil(e.length/4))),e=e.replace(/[^A-Za-z0-9\+\/\=]/g,"");for(var u=0,l=r=r||0;u>4,64!==o&&(s[l++]=(15&i)<<4|o>>2,64!==a&&(s[l++]=(3&o)<<6|a));return t?l-r:s.subarray(0,l)},o.binary.base58.encode=function(e,t){return o.binary.baseN.encode(e,l,t)},o.binary.base58.decode=function(e,t){return o.binary.baseN.decode(e,l,t)},o.text={utf8:{},utf16:{}},o.text.utf8.encode=function(e,t,r){e=o.encodeUtf8(e);var n=t;n||(n=new Uint8Array(e.length));for(var i=r=r||0,a=0;a0&&o.push(r),a=n.lastIndex;var s=t[0][1];switch(s){case"s":case"o":i");break;case"%":o.push("%");break;default:o.push("<%"+s+"?>")}}return o.push(e.substring(a)),o.join("")},o.formatNumber=function(e,t,r,n){var i=e,o=isNaN(t=Math.abs(t))?2:t,a=void 0===r?",":r,s=void 0===n?".":n,u=i<0?"-":"",c=parseInt(i=Math.abs(+i||0).toFixed(o),10)+"",l=c.length>3?c.length%3:0;return u+(l?c.substr(0,l)+s:"")+c.substr(l).replace(/(\d{3})(?=\d)/g,"$1"+s)+(o?a+Math.abs(i-c).toFixed(o).slice(2):"")},o.formatSize=function(e){return e=e>=1073741824?o.formatNumber(e/1073741824,2,".","")+" GiB":e>=1048576?o.formatNumber(e/1048576,2,".","")+" MiB":e>=1024?o.formatNumber(e/1024,0)+" KiB":o.formatNumber(e,0)+" bytes"},o.bytesFromIP=function(e){return-1!==e.indexOf(".")?o.bytesFromIPv4(e):-1!==e.indexOf(":")?o.bytesFromIPv6(e):null},o.bytesFromIPv4=function(e){if(4!==(e=e.split(".")).length)return null;for(var t=o.createBuffer(),r=0;rr[n].end-r[n].start&&(n=r.length-1)):r.push({start:u,end:u})}t.push(a)}if(r.length>0){var c=r[n];c.end-c.start>0&&(t.splice(c.start,c.end-c.start+1,""),0===c.start&&t.unshift(""),7===c.end&&t.push(""))}return t.join(":")},o.estimateCores=function(e,t){if("function"===typeof e&&(t=e,e={}),e=e||{},"cores"in o&&!e.update)return t(null,o.cores);if("undefined"!==typeof navigator&&"hardwareConcurrency"in navigator&&navigator.hardwareConcurrency>0)return o.cores=navigator.hardwareConcurrency,t(null,o.cores);if("undefined"===typeof Worker)return o.cores=1,t(null,o.cores);if("undefined"===typeof Blob)return o.cores=2,t(null,o.cores);var r=URL.createObjectURL(new Blob(["(",function(){self.addEventListener("message",(function(e){for(var t=Date.now(),r=t+4;Date.now()s.st&&i.sti.st&&s.st>>0",n,n);break;case"int32":case"sint32":case"sfixed32":e("m%s=d%s|0",n,n);break;case"uint64":c=!0;case"int64":case"sint64":case"fixed64":case"sfixed64":e("if(util.Long)")("(m%s=util.Long.fromValue(d%s)).unsigned=%j",n,n,c)('else if(typeof d%s==="string")',n)("m%s=parseInt(d%s,10)",n,n)('else if(typeof d%s==="number")',n)("m%s=d%s",n,n)('else if(typeof d%s==="object")',n)("m%s=new util.LongBits(d%s.low>>>0,d%s.high>>>0).toNumber(%s)",n,n,n,c?"true":"");break;case"bytes":e('if(typeof d%s==="string")',n)("util.base64.decode(d%s,m%s=util.newBuffer(util.base64.length(d%s)),0)",n,n,n)("else if(d%s.length >= 0)",n)("m%s=d%s",n,n);break;case"string":e("m%s=String(d%s)",n,n);break;case"bool":e("m%s=Boolean(d%s)",n,n)}}return e}function s(e,t,r,n){if(t.resolvedType)t.resolvedType instanceof i?e("d%s=o.enums===String?(types[%i].values[m%s]===undefined?m%s:types[%i].values[m%s]):m%s",n,r,n,n,r,n,n):e("d%s=types[%i].toObject(m%s,o)",n,r,n);else{var o=!1;switch(t.type){case"double":case"float":e("d%s=o.json&&!isFinite(m%s)?String(m%s):m%s",n,n,n,n);break;case"uint64":o=!0;case"int64":case"sint64":case"fixed64":case"sfixed64":e('if(typeof m%s==="number")',n)("d%s=o.longs===String?String(m%s):m%s",n,n,n)("else")("d%s=o.longs===String?util.Long.prototype.toString.call(m%s):o.longs===Number?new util.LongBits(m%s.low>>>0,m%s.high>>>0).toNumber(%s):m%s",n,n,n,n,o?"true":"",n);break;case"bytes":e("d%s=o.bytes===String?util.base64.encode(m%s,0,m%s.length):o.bytes===Array?Array.prototype.slice.call(m%s):m%s",n,n,n,n,n);break;default:e("d%s=m%s",n,n)}}return e}n.fromObject=function(e){var t=e.fieldsArray,r=o.codegen(["d"],e.name+"$fromObject")("if(d instanceof this.ctor)")("return d");if(!t.length)return r("return new this.ctor");r("var m=new this.ctor");for(var n=0;n>>3){");for(var r=0;r>>3){")("case 1: k=r.%s(); break",s.keyType)("case 2:"),void 0===i.basic[u]?t("value=types[%i].decode(r,r.uint32())",r):t("value=r.%s()",u),t("break")("default:")("r.skipType(tag2&7)")("break")("}")("}"),void 0!==i.long[s.keyType]?t('%s[typeof k==="object"?util.longToHash(k):k]=value',c):t("%s[k]=value",c)):s.repeated?(t("if(!(%s&&%s.length))",c,c)("%s=[]",c),void 0!==i.packed[u]&&t("if((t&7)===2){")("var c2=r.uint32()+r.pos")("while(r.pos>>0,8|i.mapKey[c.keyType],c.keyType),void 0===h?r("types[%i].encode(%s[ks[i]],w.uint32(18).fork()).ldelim().ldelim()",l,t):r(".uint32(%i).%s(%s[ks[i]]).ldelim()",16|h,f,t),r("}")("}")):c.repeated?(r("if(%s!=null&&%s.length){",t,t),c.packed&&void 0!==i.packed[f]?r("w.uint32(%i).fork()",(c.id<<3|2)>>>0)("for(var i=0;i<%s.length;++i)",t)("w.%s(%s[i])",f,t)("w.ldelim()"):(r("for(var i=0;i<%s.length;++i)",t),void 0===h?a(r,c,l,t+"[i]"):r("w.uint32(%i).%s(%s[i])",(c.id<<3|h)>>>0,f,t)),r("}")):(c.optional&&r("if(%s!=null&&Object.hasOwnProperty.call(m,%j))",t,c.name),void 0===h?a(r,c,l,t):r("w.uint32(%i).%s(%s)",(c.id<<3|h)>>>0,f,t))}return r("return w")};var n=r(986),i=r(3372),o=r(6021);function a(e,t,r,n){return t.resolvedType.group?e("types[%i].encode(%s,w.uint32(%i)).uint32(%i)",r,n,(t.id<<3|3)>>>0,(t.id<<3|4)>>>0):e("types[%i].encode(%s,w.uint32(%i).fork()).ldelim()",r,n,(t.id<<3|2)>>>0)}},986:function(e,t,r){"use strict";e.exports=a;var n=r(3594);((a.prototype=Object.create(n.prototype)).constructor=a).className="Enum";var i=r(7905),o=r(6021);function a(e,t,r,i,o,a){if(n.call(this,e,r),t&&"object"!==typeof t)throw TypeError("values must be an object");if(this.valuesById={},this.values=Object.create(this.valuesById),this.comment=i,this.comments=o||{},this.valuesOptions=a,this.reserved=void 0,t)for(var s=Object.keys(t),u=0;ut)return!0;return!1},f.isReservedName=function(e,t){if(e)for(var r=0;r0;){var n=e.shift();if(r.nested&&r.nested[n]){if(!((r=r.nested[n])instanceof f))throw Error("path conflicts with non-namespace objects")}else r.add(r=new f(n))}return t&&r.addJSON(t),r},f.prototype.resolveAll=function(){for(var e=this.nestedArray,t=0;t-1)return n}else if(n instanceof f&&(n=n.lookup(e.slice(1),t,!0)))return n}else for(var i=0;i-1&&this.oneof.splice(t,1),e.partOf=null,this},a.prototype.onAdd=function(e){n.prototype.onAdd.call(this,e);for(var t=0;t");var n=B();if(!k.test(n))throw Z(n,"name");O("=");var i=new s(z(n),V(B()),t,r);J(i,(function(e){if("option"!==e)throw Z(e);ee(i,e),O(";")}),(function(){ne(i)})),e.add(i)}(r);break;case"required":case"repeated":X(r,e);break;case"optional":X(r,U?"proto3_optional":"optional");break;case"oneof":!function(e,t){if(!k.test(t=B()))throw Z(t,"name");var r=new u(z(t));J(r,(function(e){"option"===e?(ee(r,e),O(";")):(M(e),X(r,"optional"))})),e.add(r)}(r,e);break;case"extensions":K(r.extensions||(r.extensions=[]));break;case"reserved":K(r.reserved||(r.reserved=[]),!0);break;default:if(!U||!E.test(e))throw Z(e);M(e),X(r,"optional")}})),e.add(r)}function X(e,t,r){var n=B();if("group"!==n){if(!E.test(n))throw Z(n,"type");var i=B();if(!k.test(i))throw Z(i,"name");i=z(i),O("=");var s=new a(i,V(B()),n,t,r);if(J(s,(function(e){if("option"!==e)throw Z(e);ee(s,e),O(";")}),(function(){ne(s)})),"proto3_optional"===t){var c=new u("_"+i);s.setOption("proto3_optional",!0),c.add(s),e.add(c)}else e.add(s);U||!s.repeated||void 0===h.packed[n]&&void 0!==h.basic[n]||s.setOption("packed",!1,!0)}else!function(e,t){var r=B();if(!k.test(r))throw Z(r,"name");var n=d.lcFirst(r);r===n&&(r=d.ucFirst(r));O("=");var i=V(B()),s=new o(r);s.group=!0;var u=new a(n,i,r,t);u.filename=_.filename,J(s,(function(e){switch(e){case"option":ee(s,e),O(";");break;case"required":case"repeated":X(s,e);break;case"optional":X(s,U?"proto3_optional":"optional");break;case"message":Y(s,e);break;case"enum":$(s,e);break;default:throw Z(e)}})),e.add(s).add(u)}(e,t)}function $(e,t){if(!k.test(t=B()))throw Z(t,"name");var r=new c(t);J(r,(function(e){switch(e){case"option":ee(r,e),O(";");break;case"reserved":K(r.reserved||(r.reserved=[]),!0);break;default:!function(e,t){if(!k.test(t))throw Z(t,"name");O("=");var r=V(B(),!0),n={options:void 0,setOption:function(e,t){void 0===this.options&&(this.options={}),this.options[e]=t}};J(n,(function(e){if("option"!==e)throw Z(e);ee(n,e),O(";")}),(function(){ne(n)})),e.add(t,r,n.comment,n.options)}(r,e)}})),e.add(r)}function ee(e,t){var r=O("(",!0);if(!E.test(t=B()))throw Z(t,"name");var n,i=t,o=i;r&&(O(")"),o=i="("+i+")",t=N(),x.test(t)&&(n=t.slice(1),i+=t,B())),O("="),function(e,t,r,n){e.setParsedOption&&e.setParsedOption(t,r,n)}(e,o,te(e,i),n)}function te(e,t){if(O("{",!0)){for(var r={};!O("}",!0);){if(!k.test(T=B()))throw Z(T,"name");var n,i=T;if(O(":",!0),"{"===N())n=te(e,t+"."+T);else if("["===N()){var o;if(n=[],O("[",!0)){do{o=q(!0),n.push(o)}while(O(",",!0));O("]"),"undefined"!==typeof o&&re(e,t+"."+T,o)}}else n=q(!0),re(e,t+"."+T,n);var a=r[i];a&&(n=[].concat(a).concat(n)),r[i]=n,O(",",!0),O(";",!0)}return r}var s=q(!0);return re(e,t,s),s}function re(e,t,r){e.setOption&&e.setOption(t,r)}function ne(e){if(O("[",!0)){do{ee(e,"option")}while(O(",",!0));O("]")}return e}for(;null!==(T=B());)switch(T){case"package":if(!L)throw Z(T);H();break;case"import":if(!L)throw Z(T);G();break;case"syntax":if(!L)throw Z(T);W();break;case"option":ee(F,T),O(";");break;default:if(Q(F,T)){L=!1;continue}throw Z(T)}return _.filename=null,{package:S,imports:A,weakImports:I,syntax:C,root:t}}},9430:function(e,t,r){"use strict";e.exports=u;var n,i=r(8335),o=i.LongBits,a=i.utf8;function s(e,t){return RangeError("index out of range: "+e.pos+" + "+(t||1)+" > "+e.len)}function u(e){this.buf=e,this.pos=0,this.len=e.length}var c="undefined"!==typeof Uint8Array?function(e){if(e instanceof Uint8Array||Array.isArray(e))return new u(e);throw Error("illegal buffer")}:function(e){if(Array.isArray(e))return new u(e);throw Error("illegal buffer")},l=function(){return i.Buffer?function(e){return(u.create=function(e){return i.Buffer.isBuffer(e)?new n(e):c(e)})(e)}:c};function f(){var e=new o(0,0),t=0;if(!(this.len-this.pos>4)){for(;t<3;++t){if(this.pos>=this.len)throw s(this);if(e.lo=(e.lo|(127&this.buf[this.pos])<<7*t)>>>0,this.buf[this.pos++]<128)return e}return e.lo=(e.lo|(127&this.buf[this.pos++])<<7*t)>>>0,e}for(;t<4;++t)if(e.lo=(e.lo|(127&this.buf[this.pos])<<7*t)>>>0,this.buf[this.pos++]<128)return e;if(e.lo=(e.lo|(127&this.buf[this.pos])<<28)>>>0,e.hi=(e.hi|(127&this.buf[this.pos])>>4)>>>0,this.buf[this.pos++]<128)return e;if(t=0,this.len-this.pos>4){for(;t<5;++t)if(e.hi=(e.hi|(127&this.buf[this.pos])<<7*t+3)>>>0,this.buf[this.pos++]<128)return e}else for(;t<5;++t){if(this.pos>=this.len)throw s(this);if(e.hi=(e.hi|(127&this.buf[this.pos])<<7*t+3)>>>0,this.buf[this.pos++]<128)return e}throw Error("invalid varint encoding")}function h(e,t){return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0}function d(){if(this.pos+8>this.len)throw s(this,8);return new o(h(this.buf,this.pos+=4),h(this.buf,this.pos+=4))}u.create=l(),u.prototype._slice=i.Array.prototype.subarray||i.Array.prototype.slice,u.prototype.uint32=function(){var e=4294967295;return function(){if(e=(127&this.buf[this.pos])>>>0,this.buf[this.pos++]<128)return e;if(e=(e|(127&this.buf[this.pos])<<7)>>>0,this.buf[this.pos++]<128)return e;if(e=(e|(127&this.buf[this.pos])<<14)>>>0,this.buf[this.pos++]<128)return e;if(e=(e|(127&this.buf[this.pos])<<21)>>>0,this.buf[this.pos++]<128)return e;if(e=(e|(15&this.buf[this.pos])<<28)>>>0,this.buf[this.pos++]<128)return e;if((this.pos+=5)>this.len)throw this.pos=this.len,s(this,10);return e}}(),u.prototype.int32=function(){return 0|this.uint32()},u.prototype.sint32=function(){var e=this.uint32();return e>>>1^-(1&e)|0},u.prototype.bool=function(){return 0!==this.uint32()},u.prototype.fixed32=function(){if(this.pos+4>this.len)throw s(this,4);return h(this.buf,this.pos+=4)},u.prototype.sfixed32=function(){if(this.pos+4>this.len)throw s(this,4);return 0|h(this.buf,this.pos+=4)},u.prototype.float=function(){if(this.pos+4>this.len)throw s(this,4);var e=i.float.readFloatLE(this.buf,this.pos);return this.pos+=4,e},u.prototype.double=function(){if(this.pos+8>this.len)throw s(this,4);var e=i.float.readDoubleLE(this.buf,this.pos);return this.pos+=8,e},u.prototype.bytes=function(){var e=this.uint32(),t=this.pos,r=this.pos+e;if(r>this.len)throw s(this,e);return this.pos+=e,Array.isArray(this.buf)?this.buf.slice(t,r):t===r?new this.buf.constructor(0):this._slice.call(this.buf,t,r)},u.prototype.string=function(){var e=this.bytes();return a.read(e,0,e.length)},u.prototype.skip=function(e){if("number"===typeof e){if(this.pos+e>this.len)throw s(this,e);this.pos+=e}else do{if(this.pos>=this.len)throw s(this)}while(128&this.buf[this.pos++]);return this},u.prototype.skipType=function(e){switch(e){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;4!==(e=7&this.uint32());)this.skipType(e);break;case 5:this.skip(4);break;default:throw Error("invalid wire type "+e+" at offset "+this.pos)}return this},u._configure=function(e){n=e,u.create=l(),n._configure();var t=i.Long?"toLong":"toNumber";i.merge(u.prototype,{int64:function(){return f.call(this)[t](!1)},uint64:function(){return f.call(this)[t](!0)},sint64:function(){return f.call(this).zzDecode()[t](!1)},fixed64:function(){return d.call(this)[t](!0)},sfixed64:function(){return d.call(this)[t](!1)}})}},5393:function(e,t,r){"use strict";e.exports=o;var n=r(9430);(o.prototype=Object.create(n.prototype)).constructor=o;var i=r(8335);function o(e){n.call(this,e)}o._configure=function(){i.Buffer&&(o.prototype._slice=i.Buffer.prototype.slice)},o.prototype.string=function(){var e=this.uint32();return this.buf.utf8Slice?this.buf.utf8Slice(this.pos,this.pos=Math.min(this.pos+e,this.len)):this.buf.toString("utf-8",this.pos,this.pos=Math.min(this.pos+e,this.len))},o._configure()},9894:function(e,t,r){"use strict";e.exports=f;var n=r(7905);((f.prototype=Object.create(n.prototype)).constructor=f).className="Root";var i,o,a,s=r(229),u=r(986),c=r(2698),l=r(6021);function f(e){n.call(this,"",e),this.deferred=[],this.files=[]}function h(){}f.fromJSON=function(e,t){return t||(t=new f),e.options&&t.setOptions(e.options),t.addJSON(e.nested)},f.prototype.resolvePath=l.path.resolve,f.prototype.fetch=l.fetch,f.prototype.load=function e(t,r,n){"function"===typeof r&&(n=r,r=void 0);var i=this;if(!n)return l.asPromise(e,i,t,r);var s=n===h;function u(e,t){if(n){var r=n;if(n=null,s)throw e;r(e,t)}}function c(e){var t=e.lastIndexOf("google/protobuf/");if(t>-1){var r=e.substring(t);if(r in a)return r}return null}function f(e,t){try{if(l.isString(t)&&"{"===t.charAt(0)&&(t=JSON.parse(t)),l.isString(t)){o.filename=e;var n,a=o(t,i,r),f=0;if(a.imports)for(;f-1))if(i.files.push(e),e in a)s?f(e,a[e]):(++p,setTimeout((function(){--p,f(e,a[e])})));else if(s){var r;try{r=l.fs.readFileSync(e).toString("utf8")}catch(o){return void(t||u(o))}f(e,r)}else++p,i.fetch(e,(function(r,o){--p,n&&(r?t?p||u(null,i):u(r):f(e,o))}))}var p=0;l.isString(t)&&(t=[t]);for(var v,g=0;g-1&&this.deferred.splice(t,1)}}else if(e instanceof u)d.test(e.name)&&delete e.parent[e.name];else if(e instanceof n){for(var r=0;r]/g,r=/(?:"([^"\\]*(?:\\.[^"\\]*)*)")/g,n=/(?:'([^'\\]*(?:\\.[^'\\]*)*)')/g,i=/^ *[*/]+ */,o=/^\s*\*?\/*/,a=/\n/g,s=/\s/,u=/\\(.?)/g,c={0:"\0",r:"\r",n:"\n",t:"\t"};function l(e){return e.replace(u,(function(e,t){switch(t){case"\\":case"":return t;default:return c[t]||""}}))}function f(e,u){e=e.toString();var c=0,f=e.length,h=1,d=0,p={},v=[],g=null;function y(e){return Error("illegal "+e+" (line "+h+")")}function m(t){return e.charAt(t)}function b(t,r,n){var s,c={type:e.charAt(t++),lineEmpty:!1,leading:n},l=t-(u?2:3);do{if(--l<0||"\n"===(s=e.charAt(l))){c.lineEmpty=!0;break}}while(" "===s||"\t"===s);for(var f=e.substring(t,r).split(a),v=0;v0)return v.shift();if(g)return function(){var t="'"===g?n:r;t.lastIndex=c-1;var i=t.exec(e);if(!i)throw y("string");return c=t.lastIndex,x(g),g=null,l(i[1])}();var i,o,a,d,p,E=0===c;do{if(c===f)return null;for(i=!1;s.test(a=m(c));)if("\n"===a&&(E=!0,++h),++c===f)return null;if("/"===m(c)){if(++c===f)throw y("comment");if("/"===m(c))if(u){if(d=c,p=!1,w(c)){p=!0;do{if((c=k(c))===f)break;if(c++,!E)break}while(w(c))}else c=Math.min(f,k(c)+1);p&&(b(d,c,E),E=!0),h++,i=!0}else{for(p="/"===m(d=c+1);"\n"!==m(++c);)if(c===f)return null;++c,p&&(b(d,c-1,E),E=!0),++h,i=!0}else{if("*"!==(a=m(c)))return"/";d=c+1,p=u||"*"===m(d);do{if("\n"===a&&++h,++c===f)throw y("comment");o=a,a=m(c)}while("*"!==o||"/"!==a);++c,p&&(b(d,c-2,E),E=!0),i=!0}}}while(i);var _=c;if(t.lastIndex=0,!t.test(m(_++)))for(;_0)t[i]=e(t[i]||{},r,n);else{var o=t[i];o&&(n=[].concat(o).concat(n)),t[i]=n}return t}(e,t=t.split("."),r)},Object.defineProperty(o,"decorateRoot",{get:function(){return a.decorated||(a.decorated=new(r(9894)))}})},8564:function(e,t,r){"use strict";e.exports=i;var n=r(8335);function i(e,t){this.lo=e>>>0,this.hi=t>>>0}var o=i.zero=new i(0,0);o.toNumber=function(){return 0},o.zzEncode=o.zzDecode=function(){return this},o.length=function(){return 1};var a=i.zeroHash="\0\0\0\0\0\0\0\0";i.fromNumber=function(e){if(0===e)return o;var t=e<0;t&&(e=-e);var r=e>>>0,n=(e-r)/4294967296>>>0;return t&&(n=~n>>>0,r=~r>>>0,++r>4294967295&&(r=0,++n>4294967295&&(n=0))),new i(r,n)},i.from=function(e){if("number"===typeof e)return i.fromNumber(e);if(n.isString(e)){if(!n.Long)return i.fromNumber(parseInt(e,10));e=n.Long.fromString(e)}return e.low||e.high?new i(e.low>>>0,e.high>>>0):o},i.prototype.toNumber=function(e){if(!e&&this.hi>>>31){var t=1+~this.lo>>>0,r=~this.hi>>>0;return t||(r=r+1>>>0),-(t+4294967296*r)}return this.lo+4294967296*this.hi},i.prototype.toLong=function(e){return n.Long?new n.Long(0|this.lo,0|this.hi,Boolean(e)):{low:0|this.lo,high:0|this.hi,unsigned:Boolean(e)}};var s=String.prototype.charCodeAt;i.fromHash=function(e){return e===a?o:new i((s.call(e,0)|s.call(e,1)<<8|s.call(e,2)<<16|s.call(e,3)<<24)>>>0,(s.call(e,4)|s.call(e,5)<<8|s.call(e,6)<<16|s.call(e,7)<<24)>>>0)},i.prototype.toHash=function(){return String.fromCharCode(255&this.lo,this.lo>>>8&255,this.lo>>>16&255,this.lo>>>24,255&this.hi,this.hi>>>8&255,this.hi>>>16&255,this.hi>>>24)},i.prototype.zzEncode=function(){var e=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^e)>>>0,this.lo=(this.lo<<1^e)>>>0,this},i.prototype.zzDecode=function(){var e=-(1&this.lo);return this.lo=((this.lo>>>1|this.hi<<31)^e)>>>0,this.hi=(this.hi>>>1^e)>>>0,this},i.prototype.length=function(){var e=this.lo,t=(this.lo>>>28|this.hi<<4)>>>0,r=this.hi>>>24;return 0===r?0===t?e<16384?e<128?1:2:e<2097152?3:4:t<16384?t<128?5:6:t<2097152?7:8:r<128?9:10}},8335:function(e,t,r){"use strict";var n=t;function i(e,t,r){for(var n=Object.keys(t),i=0;i0)},n.Buffer=function(){try{var e=n.inquire("buffer").Buffer;return e.prototype.utf8Write?e:null}catch(t){return null}}(),n._Buffer_from=null,n._Buffer_allocUnsafe=null,n.newBuffer=function(e){return"number"===typeof e?n.Buffer?n._Buffer_allocUnsafe(e):new n.Array(e):n.Buffer?n._Buffer_from(e):"undefined"===typeof Uint8Array?e:new Uint8Array(e)},n.Array="undefined"!==typeof Uint8Array?Uint8Array:Array,n.Long=n.global.dcodeIO&&n.global.dcodeIO.Long||n.global.Long||n.inquire("long"),n.key2Re=/^true|false|0|1$/,n.key32Re=/^-?(?:0|[1-9][0-9]*)$/,n.key64Re=/^(?:[\\x00-\\xff]{8}|-?(?:0|[1-9][0-9]*))$/,n.longToHash=function(e){return e?n.LongBits.from(e).toHash():n.LongBits.zeroHash},n.longFromHash=function(e,t){var r=n.LongBits.fromHash(e);return n.Long?n.Long.fromBits(r.lo,r.hi,t):r.toNumber(Boolean(t))},n.merge=i,n.lcFirst=function(e){return e.charAt(0).toLowerCase()+e.substring(1)},n.newError=o,n.ProtocolError=o("ProtocolError"),n.oneOfGetter=function(e){for(var t={},r=0;r-1;--r)if(1===t[e[r]]&&void 0!==this[e[r]]&&null!==this[e[r]])return e[r]}},n.oneOfSetter=function(e){return function(t){for(var r=0;r>>7|e.hi<<25)>>>0,e.hi>>>=7;for(;e.lo>127;)t[r++]=127&e.lo|128,e.lo=e.lo>>>7;t[r++]=e.lo}function g(e,t,r){t[r]=255&e,t[r+1]=e>>>8&255,t[r+2]=e>>>16&255,t[r+3]=e>>>24}f.create=h(),f.alloc=function(e){return new i.Array(e)},i.Array!==Array&&(f.alloc=i.pool(f.alloc,i.Array.prototype.subarray)),f.prototype._push=function(e,t,r){return this.tail=this.tail.next=new u(e,t,r),this.len+=t,this},p.prototype=Object.create(u.prototype),p.prototype.fn=function(e,t,r){for(;e>127;)t[r++]=127&e|128,e>>>=7;t[r]=e},f.prototype.uint32=function(e){return this.len+=(this.tail=this.tail.next=new p((e>>>=0)<128?1:e<16384?2:e<2097152?3:e<268435456?4:5,e)).len,this},f.prototype.int32=function(e){return e<0?this._push(v,10,o.fromNumber(e)):this.uint32(e)},f.prototype.sint32=function(e){return this.uint32((e<<1^e>>31)>>>0)},f.prototype.uint64=function(e){var t=o.from(e);return this._push(v,t.length(),t)},f.prototype.int64=f.prototype.uint64,f.prototype.sint64=function(e){var t=o.from(e).zzEncode();return this._push(v,t.length(),t)},f.prototype.bool=function(e){return this._push(d,1,e?1:0)},f.prototype.fixed32=function(e){return this._push(g,4,e>>>0)},f.prototype.sfixed32=f.prototype.fixed32,f.prototype.fixed64=function(e){var t=o.from(e);return this._push(g,4,t.lo)._push(g,4,t.hi)},f.prototype.sfixed64=f.prototype.fixed64,f.prototype.float=function(e){return this._push(i.float.writeFloatLE,4,e)},f.prototype.double=function(e){return this._push(i.float.writeDoubleLE,8,e)};var y=i.Array.prototype.set?function(e,t,r){t.set(e,r)}:function(e,t,r){for(var n=0;n>>0;if(!t)return this._push(d,1,0);if(i.isString(e)){var r=f.alloc(t=a.length(e));a.decode(e,r,0),e=r}return this.uint32(t)._push(y,t,e)},f.prototype.string=function(e){var t=s.length(e);return t?this.uint32(t)._push(s.write,t,e):this._push(d,1,0)},f.prototype.fork=function(){return this.states=new l(this),this.head=this.tail=new u(c,0,0),this.len=0,this},f.prototype.reset=function(){return this.states?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new u(c,0,0),this.len=0),this},f.prototype.ldelim=function(){var e=this.head,t=this.tail,r=this.len;return this.reset().uint32(r),r&&(this.tail.next=e.next,this.tail=t,this.len+=r),this},f.prototype.finish=function(){for(var e=this.head.next,t=this.constructor.alloc(this.len),r=0;e;)e.fn(e.val,t,r),r+=e.len,e=e.next;return t},f._configure=function(e){n=e,f.create=h(),n._configure()}},2549:function(e,t,r){"use strict";e.exports=o;var n=r(3471);(o.prototype=Object.create(n.prototype)).constructor=o;var i=r(8335);function o(){n.call(this)}function a(e,t,r){e.length<40?i.utf8.write(e,t,r):t.utf8Write?t.utf8Write(e,r):t.write(e,r)}o._configure=function(){o.alloc=i._Buffer_allocUnsafe,o.writeBytesBuffer=i.Buffer&&i.Buffer.prototype instanceof Uint8Array&&"set"===i.Buffer.prototype.set.name?function(e,t,r){t.set(e,r)}:function(e,t,r){if(e.copy)e.copy(t,r,0,e.length);else for(var n=0;n>>0;return this.uint32(t),t&&this._push(o.writeBytesBuffer,t,e),this},o.prototype.string=function(e){var t=i.Buffer.byteLength(e);return this.uint32(t),t&&this._push(a,t,e),this},o._configure()},3355:function(e,t,r){"use strict";var n=r(5151),i=r(4711);function o(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,r=1;r