edge-core-js 2.48.0 → 2.48.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/android/src/main/assets/edge-core-js/edge-core.js +1 -1
- package/lib/util/nym.js +137 -43
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! For license information please see edge-core.js.LICENSE.txt */
|
|
2
|
-
!function(){var e={220:function(e,t,n){"use strict";var r=n(9404),o=n(7011),i=o.assert,a=o.cachedProperty,s=o.parseBytes;function c(e,t){this.eddsa=e,"object"!=typeof t&&(t=s(t)),Array.isArray(t)&&(t={R:t.slice(0,e.encodingLength),S:t.slice(e.encodingLength)}),i(t.R&&t.S,"Signature without R or S"),e.isPoint(t.R)&&(this._R=t.R),t.S instanceof r&&(this._S=t.S),this._Rencoded=Array.isArray(t.R)?t.R:t.Rencoded,this._Sencoded=Array.isArray(t.S)?t.S:t.Sencoded}a(c,"S",function(){return this.eddsa.decodeInt(this.Sencoded())}),a(c,"R",function(){return this.eddsa.decodePoint(this.Rencoded())}),a(c,"Rencoded",function(){return this.eddsa.encodePoint(this.R())}),a(c,"Sencoded",function(){return this.eddsa.encodeInt(this.S())}),c.prototype.toBytes=function(){return this.Rencoded().concat(this.Sencoded())},c.prototype.toHex=function(){return o.encode(this.toBytes(),"hex").toUpperCase()},e.exports=c},370:function(e,t,n){"use strict";var r=n(9404),o=n(6698),i=n(6677),a=n(7011);function s(e){i.call(this,"mont",e),this.a=new r(e.a,16).toRed(this.red),this.b=new r(e.b,16).toRed(this.red),this.i4=new r(4).toRed(this.red).redInvm(),this.two=new r(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}function c(e,t,n){i.BasePoint.call(this,e,"projective"),null===t&&null===n?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new r(t,16),this.z=new r(n,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}o(s,i),e.exports=s,s.prototype.validate=function(e){var t=e.normalize().x,n=t.redSqr(),r=n.redMul(t).redAdd(n.redMul(this.a)).redAdd(t);return 0===r.redSqrt().redSqr().cmp(r)},o(c,i.BasePoint),s.prototype.decodePoint=function(e,t){return this.point(a.toArray(e,t),1)},s.prototype.point=function(e,t){return new c(this,e,t)},s.prototype.pointFromJSON=function(e){return c.fromJSON(this,e)},c.prototype.precompute=function(){},c.prototype._encode=function(){return this.getX().toArray("be",this.curve.p.byteLength())},c.fromJSON=function(e,t){return new c(e,t[0],t[1]||e.one)},c.prototype.inspect=function(){return this.isInfinity()?"<EC Point Infinity>":"<EC Point x: "+this.x.fromRed().toString(16,2)+" z: "+this.z.fromRed().toString(16,2)+">"},c.prototype.isInfinity=function(){return 0===this.z.cmpn(0)},c.prototype.dbl=function(){var e=this.x.redAdd(this.z).redSqr(),t=this.x.redSub(this.z).redSqr(),n=e.redSub(t),r=e.redMul(t),o=n.redMul(t.redAdd(this.curve.a24.redMul(n)));return this.curve.point(r,o)},c.prototype.add=function(){throw new Error("Not supported on Montgomery curve")},c.prototype.diffAdd=function(e,t){var n=this.x.redAdd(this.z),r=this.x.redSub(this.z),o=e.x.redAdd(e.z),i=e.x.redSub(e.z).redMul(n),a=o.redMul(r),s=t.z.redMul(i.redAdd(a).redSqr()),c=t.x.redMul(i.redISub(a).redSqr());return this.curve.point(s,c)},c.prototype.mul=function(e){for(var t=e.clone(),n=this,r=this.curve.point(null,null),o=[];0!==t.cmpn(0);t.iushrn(1))o.push(t.andln(1));for(var i=o.length-1;i>=0;i--)0===o[i]?(n=n.diffAdd(r,this),r=r.dbl()):(r=n.diffAdd(r,this),n=n.dbl());return r},c.prototype.mulAdd=function(){throw new Error("Not supported on Montgomery curve")},c.prototype.jumlAdd=function(){throw new Error("Not supported on Montgomery curve")},c.prototype.eq=function(e){return 0===this.getX().cmp(e.getX())},c.prototype.normalize=function(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this},c.prototype.getX=function(){return this.normalize(),this.x.fromRed()}},480:function(e,t,n){"use strict";var r,o=t,i=n(7952),a=n(894),s=n(7011).assert;function c(e){"short"===e.type?this.curve=new a.short(e):"edwards"===e.type?this.curve=new a.edwards(e):this.curve=new a.mont(e),this.g=this.curve.g,this.n=this.curve.n,this.hash=e.hash,s(this.g.validate(),"Invalid curve"),s(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}function u(e,t){Object.defineProperty(o,e,{configurable:!0,enumerable:!0,get:function(){var n=new c(t);return Object.defineProperty(o,e,{configurable:!0,enumerable:!0,value:n}),n}})}o.PresetCurve=c,u("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:i.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),u("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:i.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),u("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:i.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),u("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:i.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"]}),u("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:i.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"]}),u("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:i.sha256,gRed:!1,g:["9"]}),u("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:i.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});try{r=n(4011)}catch(l){r=void 0}u("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:i.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",r]})},726:function(e){var t=e.exports=function(e,n){if("function"==typeof e||n)return t.by(e,n);for(var r={object:[],function:[],string:{},number:{},boolean:{},undefined:{}},o=[],i=0;i<e.length;i++){var a=e[i],s="__proto__"===a?r.objects:r[typeof a]||r.objects;Array.isArray(s)?s.indexOf(a)<0&&(s.push(a),o.push(a)):Object.hasOwnProperty.call(s,a)||(s[a]=!0,o.push(a))}return o};t.by=function(e,t){if("function"==typeof e){var n=t;t=e,e=n}for(var r=[],o=0;o<e.length;o++){for(var i=e[o],a=!1,s=0;s<r.length;s++){var c=r[s];if(t.call(r,i,c)){a=!0;break}}a||r.push(i)}return r}},894:function(e,t,n){"use strict";var r=t;r.base=n(6677),r.short=n(9188),r.mont=n(370),r.edwards=n(1298)},1200:function(e,t,n){"use strict";var r=n(9404),o=n(7011).assert;function i(e,t){this.ec=e,this.priv=null,this.pub=null,t.priv&&this._importPrivate(t.priv,t.privEnc),t.pub&&this._importPublic(t.pub,t.pubEnc)}e.exports=i,i.fromPublic=function(e,t,n){return t instanceof i?t:new i(e,{pub:t,pubEnc:n})},i.fromPrivate=function(e,t,n){return t instanceof i?t:new i(e,{priv:t,privEnc:n})},i.prototype.validate=function(){var e=this.getPublic();return e.isInfinity()?{result:!1,reason:"Invalid public key"}:e.validate()?e.mul(this.ec.curve.n).isInfinity()?{result:!0,reason:null}:{result:!1,reason:"Public key * N != O"}:{result:!1,reason:"Public key is not a point"}},i.prototype.getPublic=function(e,t){return"string"==typeof e&&(t=e,e=null),this.pub||(this.pub=this.ec.g.mul(this.priv)),t?this.pub.encode(t,e):this.pub},i.prototype.getPrivate=function(e){return"hex"===e?this.priv.toString(16,2):this.priv},i.prototype._importPrivate=function(e,t){this.priv=new r(e,t||16),this.priv=this.priv.umod(this.ec.curve.n)},i.prototype._importPublic=function(e,t){if(e.x||e.y)return"mont"===this.ec.curve.type?o(e.x,"Need x coordinate"):"short"!==this.ec.curve.type&&"edwards"!==this.ec.curve.type||o(e.x&&e.y,"Need both x and y coordinate"),void(this.pub=this.ec.curve.point(e.x,e.y));this.pub=this.ec.curve.decodePoint(e,t)},i.prototype.derive=function(e){return e.validate()||o(e.validate(),"public point not validated"),e.mul(this.priv).getX()},i.prototype.sign=function(e,t,n){return this.ec.sign(e,this,t,n)},i.prototype.verify=function(e,t){return this.ec.verify(e,t,this)},i.prototype.inspect=function(){return"<Key priv: "+(this.priv&&this.priv.toString(16,2))+" pub: "+(this.pub&&this.pub.inspect())+" >"}},1298:function(e,t,n){"use strict";var r=n(7011),o=n(9404),i=n(6698),a=n(6677),s=r.assert;function c(e){this.twisted=1!=(0|e.a),this.mOneA=this.twisted&&-1==(0|e.a),this.extended=this.mOneA,a.call(this,"edwards",e),this.a=new o(e.a,16).umod(this.red.m),this.a=this.a.toRed(this.red),this.c=new o(e.c,16).toRed(this.red),this.c2=this.c.redSqr(),this.d=new o(e.d,16).toRed(this.red),this.dd=this.d.redAdd(this.d),s(!this.twisted||0===this.c.fromRed().cmpn(1)),this.oneC=1==(0|e.c)}function u(e,t,n,r,i){a.BasePoint.call(this,e,"projective"),null===t&&null===n&&null===r?(this.x=this.curve.zero,this.y=this.curve.one,this.z=this.curve.one,this.t=this.curve.zero,this.zOne=!0):(this.x=new o(t,16),this.y=new o(n,16),this.z=r?new o(r,16):this.curve.one,this.t=i&&new o(i,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.t&&!this.t.red&&(this.t=this.t.toRed(this.curve.red)),this.zOne=this.z===this.curve.one,this.curve.extended&&!this.t&&(this.t=this.x.redMul(this.y),this.zOne||(this.t=this.t.redMul(this.z.redInvm()))))}i(c,a),e.exports=c,c.prototype._mulA=function(e){return this.mOneA?e.redNeg():this.a.redMul(e)},c.prototype._mulC=function(e){return this.oneC?e:this.c.redMul(e)},c.prototype.jpoint=function(e,t,n,r){return this.point(e,t,n,r)},c.prototype.pointFromX=function(e,t){(e=new o(e,16)).red||(e=e.toRed(this.red));var n=e.redSqr(),r=this.c2.redSub(this.a.redMul(n)),i=this.one.redSub(this.c2.redMul(this.d).redMul(n)),a=r.redMul(i.redInvm()),s=a.redSqrt();if(0!==s.redSqr().redSub(a).cmp(this.zero))throw new Error("invalid point");var c=s.fromRed().isOdd();return(t&&!c||!t&&c)&&(s=s.redNeg()),this.point(e,s)},c.prototype.pointFromY=function(e,t){(e=new o(e,16)).red||(e=e.toRed(this.red));var n=e.redSqr(),r=n.redSub(this.c2),i=n.redMul(this.d).redMul(this.c2).redSub(this.a),a=r.redMul(i.redInvm());if(0===a.cmp(this.zero)){if(t)throw new Error("invalid point");return this.point(this.zero,e)}var s=a.redSqrt();if(0!==s.redSqr().redSub(a).cmp(this.zero))throw new Error("invalid point");return s.fromRed().isOdd()!==t&&(s=s.redNeg()),this.point(s,e)},c.prototype.validate=function(e){if(e.isInfinity())return!0;e.normalize();var t=e.x.redSqr(),n=e.y.redSqr(),r=t.redMul(this.a).redAdd(n),o=this.c2.redMul(this.one.redAdd(this.d.redMul(t).redMul(n)));return 0===r.cmp(o)},i(u,a.BasePoint),c.prototype.pointFromJSON=function(e){return u.fromJSON(this,e)},c.prototype.point=function(e,t,n,r){return new u(this,e,t,n,r)},u.fromJSON=function(e,t){return new u(e,t[0],t[1],t[2])},u.prototype.inspect=function(){return this.isInfinity()?"<EC Point Infinity>":"<EC Point x: "+this.x.fromRed().toString(16,2)+" y: "+this.y.fromRed().toString(16,2)+" z: "+this.z.fromRed().toString(16,2)+">"},u.prototype.isInfinity=function(){return 0===this.x.cmpn(0)&&(0===this.y.cmp(this.z)||this.zOne&&0===this.y.cmp(this.curve.c))},u.prototype._extDbl=function(){var e=this.x.redSqr(),t=this.y.redSqr(),n=this.z.redSqr();n=n.redIAdd(n);var r=this.curve._mulA(e),o=this.x.redAdd(this.y).redSqr().redISub(e).redISub(t),i=r.redAdd(t),a=i.redSub(n),s=r.redSub(t),c=o.redMul(a),u=i.redMul(s),l=o.redMul(s),d=a.redMul(i);return this.curve.point(c,u,d,l)},u.prototype._projDbl=function(){var e,t,n,r,o,i,a=this.x.redAdd(this.y).redSqr(),s=this.x.redSqr(),c=this.y.redSqr();if(this.curve.twisted){var u=(r=this.curve._mulA(s)).redAdd(c);this.zOne?(e=a.redSub(s).redSub(c).redMul(u.redSub(this.curve.two)),t=u.redMul(r.redSub(c)),n=u.redSqr().redSub(u).redSub(u)):(o=this.z.redSqr(),i=u.redSub(o).redISub(o),e=a.redSub(s).redISub(c).redMul(i),t=u.redMul(r.redSub(c)),n=u.redMul(i))}else r=s.redAdd(c),o=this.curve._mulC(this.z).redSqr(),i=r.redSub(o).redSub(o),e=this.curve._mulC(a.redISub(r)).redMul(i),t=this.curve._mulC(r).redMul(s.redISub(c)),n=r.redMul(i);return this.curve.point(e,t,n)},u.prototype.dbl=function(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()},u.prototype._extAdd=function(e){var t=this.y.redSub(this.x).redMul(e.y.redSub(e.x)),n=this.y.redAdd(this.x).redMul(e.y.redAdd(e.x)),r=this.t.redMul(this.curve.dd).redMul(e.t),o=this.z.redMul(e.z.redAdd(e.z)),i=n.redSub(t),a=o.redSub(r),s=o.redAdd(r),c=n.redAdd(t),u=i.redMul(a),l=s.redMul(c),d=i.redMul(c),f=a.redMul(s);return this.curve.point(u,l,f,d)},u.prototype._projAdd=function(e){var t,n,r=this.z.redMul(e.z),o=r.redSqr(),i=this.x.redMul(e.x),a=this.y.redMul(e.y),s=this.curve.d.redMul(i).redMul(a),c=o.redSub(s),u=o.redAdd(s),l=this.x.redAdd(this.y).redMul(e.x.redAdd(e.y)).redISub(i).redISub(a),d=r.redMul(c).redMul(l);return this.curve.twisted?(t=r.redMul(u).redMul(a.redSub(this.curve._mulA(i))),n=c.redMul(u)):(t=r.redMul(u).redMul(a.redSub(i)),n=this.curve._mulC(c).redMul(u)),this.curve.point(d,t,n)},u.prototype.add=function(e){return this.isInfinity()?e:e.isInfinity()?this:this.curve.extended?this._extAdd(e):this._projAdd(e)},u.prototype.mul=function(e){return this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve._wnafMul(this,e)},u.prototype.mulAdd=function(e,t,n){return this.curve._wnafMulAdd(1,[this,t],[e,n],2,!1)},u.prototype.jmulAdd=function(e,t,n){return this.curve._wnafMulAdd(1,[this,t],[e,n],2,!0)},u.prototype.normalize=function(){if(this.zOne)return this;var e=this.z.redInvm();return this.x=this.x.redMul(e),this.y=this.y.redMul(e),this.t&&(this.t=this.t.redMul(e)),this.z=this.curve.one,this.zOne=!0,this},u.prototype.neg=function(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())},u.prototype.getX=function(){return this.normalize(),this.x.fromRed()},u.prototype.getY=function(){return this.normalize(),this.y.fromRed()},u.prototype.eq=function(e){return this===e||0===this.getX().cmp(e.getX())&&0===this.getY().cmp(e.getY())},u.prototype.eqXToP=function(e){var t=e.toRed(this.curve.red).redMul(this.z);if(0===this.x.cmp(t))return!0;for(var n=e.clone(),r=this.curve.redN.redMul(this.z);;){if(n.iadd(this.curve.n),n.cmp(this.curve.p)>=0)return!1;if(t.redIAdd(r),0===this.x.cmp(t))return!0}},u.prototype.toP=u.prototype.normalize,u.prototype.mixedAdd=u.prototype.add},1395:function(){},1636:function(e){"use strict";e.exports={rE:"6.5.4"}},1911:function(e,t,n){"use strict";var r=n(7426),o=n(7766);function i(){if(!(this instanceof i))return new i;o.call(this),this.h=[3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]}r.inherits(i,o),e.exports=i,i.blockSize=1024,i.outSize=384,i.hmacStrength=192,i.padLength=128,i.prototype._digest=function(e){return"hex"===e?r.toHex32(this.h.slice(0,12),"big"):r.split32(this.h.slice(0,12),"big")}},2287:function(e,t,n){"use strict";var r=n(7426),o=n(6166),i=n(6225),a=n(3349),s=r.sum32,c=r.sum32_4,u=r.sum32_5,l=i.ch32,d=i.maj32,f=i.s0_256,p=i.s1_256,h=i.g0_256,y=i.g1_256,b=o.BlockHash,g=[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];function w(){if(!(this instanceof w))return new w;b.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=g,this.W=new Array(64)}r.inherits(w,b),e.exports=w,w.blockSize=512,w.outSize=256,w.hmacStrength=192,w.padLength=64,w.prototype._update=function(e,t){for(var n=this.W,r=0;r<16;r++)n[r]=e[t+r];for(;r<n.length;r++)n[r]=c(y(n[r-2]),n[r-7],h(n[r-15]),n[r-16]);var o=this.h[0],i=this.h[1],b=this.h[2],g=this.h[3],w=this.h[4],v=this.h[5],m=this.h[6],I=this.h[7];for(a(this.k.length===n.length),r=0;r<n.length;r++){var E=u(I,p(w),l(w,v,m),this.k[r],n[r]),S=s(f(o),d(o,i,b));I=m,m=v,v=w,w=s(g,E),g=b,b=i,i=o,o=s(E,S)}this.h[0]=s(this.h[0],o),this.h[1]=s(this.h[1],i),this.h[2]=s(this.h[2],b),this.h[3]=s(this.h[3],g),this.h[4]=s(this.h[4],w),this.h[5]=s(this.h[5],v),this.h[6]=s(this.h[6],m),this.h[7]=s(this.h[7],I)},w.prototype._digest=function(e){return"hex"===e?r.toHex32(this.h,"big"):r.split32(this.h,"big")}},2723:function(e,t,n){"use strict";var r=n(7952),o=n(4367),i=n(3349);function a(e){if(!(this instanceof a))return new a(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=o.toArray(e.entropy,e.entropyEnc||"hex"),n=o.toArray(e.nonce,e.nonceEnc||"hex"),r=o.toArray(e.pers,e.persEnc||"hex");i(t.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(t,n,r)}e.exports=a,a.prototype._init=function(e,t,n){var r=e.concat(t).concat(n);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var o=0;o<this.V.length;o++)this.K[o]=0,this.V[o]=1;this._update(r),this._reseed=1,this.reseedInterval=281474976710656},a.prototype._hmac=function(){return new r.hmac(this.hash,this.K)},a.prototype._update=function(e){var t=this._hmac().update(this.V).update([0]);e&&(t=t.update(e)),this.K=t.digest(),this.V=this._hmac().update(this.V).digest(),e&&(this.K=this._hmac().update(this.V).update([1]).update(e).digest(),this.V=this._hmac().update(this.V).digest())},a.prototype.reseed=function(e,t,n,r){"string"!=typeof t&&(r=n,n=t,t=null),e=o.toArray(e,t),n=o.toArray(n,r),i(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(e.concat(n||[])),this._reseed=1},a.prototype.generate=function(e,t,n,r){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");"string"!=typeof t&&(r=n,n=t,t=null),n&&(n=o.toArray(n,r||"hex"),this._update(n));for(var i=[];i.length<e;)this.V=this._hmac().update(this.V).digest(),i=i.concat(this.V);var a=i.slice(0,e);return this._update(n),this._reseed++,o.encode(a,t)}},3349:function(e){function t(e,t){if(!e)throw new Error(t||"Assertion failed")}e.exports=t,t.equal=function(e,t,n){if(e!=t)throw new Error(n||"Assertion failed: "+e+" != "+t)}},3437:function(e,t,n){"use strict";e.exports=n.p+"fbcba1e9b05cb4dd9870.js"},3776:function(e){e.exports=function(e){for(var t={},n=e.length,r=e.charAt(0),o=0;o<e.length;o++)t[e.charAt(o)]=o;function i(e){if(0===e.length)return[];for(var o=[0],i=0;i<e.length;i++){var a=t[e[i]];if(void 0===a)return;for(var s=0,c=a;s<o.length;++s)c+=o[s]*n,o[s]=255&c,c>>=8;for(;c>0;)o.push(255&c),c>>=8}for(var u=0;e[u]===r&&u<e.length-1;++u)o.push(0);return o.reverse()}return{encode:function(t){if(0===t.length)return"";for(var r=[0],o=0;o<t.length;++o){for(var i=0,a=t[o];i<r.length;++i)a+=r[i]<<8,r[i]=a%n,a=a/n|0;for(;a>0;)r.push(a%n),a=a/n|0}for(var s="",c=0;0===t[c]&&c<t.length-1;++c)s+=e[0];for(var u=r.length-1;u>=0;--u)s+=e[r[u]];return s},decodeUnsafe:i,decode:function(e){var t=i(e);if(t)return t;throw new Error("Non-base"+n+" character")}}}},3836:function(e){"use strict";!function(){function t(e){return parseInt(e)===e}function n(e){if(!t(e.length))return!1;for(var n=0;n<e.length;n++)if(!t(e[n])||e[n]<0||e[n]>255)return!1;return!0}function r(e,r){if(e.buffer&&ArrayBuffer.isView(e)&&"Uint8Array"===e.name)return r&&(e=e.slice?e.slice():Array.prototype.slice.call(e)),e;if(Array.isArray(e)){if(!n(e))throw new Error("Array contains invalid value: "+e);return new Uint8Array(e)}if(t(e.length)&&n(e))return new Uint8Array(e);throw new Error("unsupported array-like object")}function o(e){return new Uint8Array(e)}function i(e,t,n,r,o){null==r&&null==o||(e=e.slice?e.slice(r,o):Array.prototype.slice.call(e,r,o)),t.set(e,n)}var a,s={toBytes:function(e){var t=[],n=0;for(e=encodeURI(e);n<e.length;){var o=e.charCodeAt(n++);37===o?(t.push(parseInt(e.substr(n,2),16)),n+=2):t.push(o)}return r(t)},fromBytes:function(e){for(var t=[],n=0;n<e.length;){var r=e[n];r<128?(t.push(String.fromCharCode(r)),n++):r>191&&r<224?(t.push(String.fromCharCode((31&r)<<6|63&e[n+1])),n+=2):(t.push(String.fromCharCode((15&r)<<12|(63&e[n+1])<<6|63&e[n+2])),n+=3)}return t.join("")}},c=(a="0123456789abcdef",{toBytes:function(e){for(var t=[],n=0;n<e.length;n+=2)t.push(parseInt(e.substr(n,2),16));return t},fromBytes:function(e){for(var t=[],n=0;n<e.length;n++){var r=e[n];t.push(a[(240&r)>>4]+a[15&r])}return t.join("")}}),u={16:10,24:12,32:14},l=[1,2,4,8,16,32,64,128,27,54,108,216,171,77,154,47,94,188,99,198,151,53,106,212,179,125,250,239,197,145],d=[99,124,119,123,242,107,111,197,48,1,103,43,254,215,171,118,202,130,201,125,250,89,71,240,173,212,162,175,156,164,114,192,183,253,147,38,54,63,247,204,52,165,229,241,113,216,49,21,4,199,35,195,24,150,5,154,7,18,128,226,235,39,178,117,9,131,44,26,27,110,90,160,82,59,214,179,41,227,47,132,83,209,0,237,32,252,177,91,106,203,190,57,74,76,88,207,208,239,170,251,67,77,51,133,69,249,2,127,80,60,159,168,81,163,64,143,146,157,56,245,188,182,218,33,16,255,243,210,205,12,19,236,95,151,68,23,196,167,126,61,100,93,25,115,96,129,79,220,34,42,144,136,70,238,184,20,222,94,11,219,224,50,58,10,73,6,36,92,194,211,172,98,145,149,228,121,231,200,55,109,141,213,78,169,108,86,244,234,101,122,174,8,186,120,37,46,28,166,180,198,232,221,116,31,75,189,139,138,112,62,181,102,72,3,246,14,97,53,87,185,134,193,29,158,225,248,152,17,105,217,142,148,155,30,135,233,206,85,40,223,140,161,137,13,191,230,66,104,65,153,45,15,176,84,187,22],f=[82,9,106,213,48,54,165,56,191,64,163,158,129,243,215,251,124,227,57,130,155,47,255,135,52,142,67,68,196,222,233,203,84,123,148,50,166,194,35,61,238,76,149,11,66,250,195,78,8,46,161,102,40,217,36,178,118,91,162,73,109,139,209,37,114,248,246,100,134,104,152,22,212,164,92,204,93,101,182,146,108,112,72,80,253,237,185,218,94,21,70,87,167,141,157,132,144,216,171,0,140,188,211,10,247,228,88,5,184,179,69,6,208,44,30,143,202,63,15,2,193,175,189,3,1,19,138,107,58,145,17,65,79,103,220,234,151,242,207,206,240,180,230,115,150,172,116,34,231,173,53,133,226,249,55,232,28,117,223,110,71,241,26,113,29,41,197,137,111,183,98,14,170,24,190,27,252,86,62,75,198,210,121,32,154,219,192,254,120,205,90,244,31,221,168,51,136,7,199,49,177,18,16,89,39,128,236,95,96,81,127,169,25,181,74,13,45,229,122,159,147,201,156,239,160,224,59,77,174,42,245,176,200,235,187,60,131,83,153,97,23,43,4,126,186,119,214,38,225,105,20,99,85,33,12,125],p=[3328402341,4168907908,4000806809,4135287693,4294111757,3597364157,3731845041,2445657428,1613770832,33620227,3462883241,1445669757,3892248089,3050821474,1303096294,3967186586,2412431941,528646813,2311702848,4202528135,4026202645,2992200171,2387036105,4226871307,1101901292,3017069671,1604494077,1169141738,597466303,1403299063,3832705686,2613100635,1974974402,3791519004,1033081774,1277568618,1815492186,2118074177,4126668546,2211236943,1748251740,1369810420,3521504564,4193382664,3799085459,2883115123,1647391059,706024767,134480908,2512897874,1176707941,2646852446,806885416,932615841,168101135,798661301,235341577,605164086,461406363,3756188221,3454790438,1311188841,2142417613,3933566367,302582043,495158174,1479289972,874125870,907746093,3698224818,3025820398,1537253627,2756858614,1983593293,3084310113,2108928974,1378429307,3722699582,1580150641,327451799,2790478837,3117535592,0,3253595436,1075847264,3825007647,2041688520,3059440621,3563743934,2378943302,1740553945,1916352843,2487896798,2555137236,2958579944,2244988746,3151024235,3320835882,1336584933,3992714006,2252555205,2588757463,1714631509,293963156,2319795663,3925473552,67240454,4269768577,2689618160,2017213508,631218106,1269344483,2723238387,1571005438,2151694528,93294474,1066570413,563977660,1882732616,4059428100,1673313503,2008463041,2950355573,1109467491,537923632,3858759450,4260623118,3218264685,2177748300,403442708,638784309,3287084079,3193921505,899127202,2286175436,773265209,2479146071,1437050866,4236148354,2050833735,3362022572,3126681063,840505643,3866325909,3227541664,427917720,2655997905,2749160575,1143087718,1412049534,999329963,193497219,2353415882,3354324521,1807268051,672404540,2816401017,3160301282,369822493,2916866934,3688947771,1681011286,1949973070,336202270,2454276571,201721354,1210328172,3093060836,2680341085,3184776046,1135389935,3294782118,965841320,831886756,3554993207,4068047243,3588745010,2345191491,1849112409,3664604599,26054028,2983581028,2622377682,1235855840,3630984372,2891339514,4092916743,3488279077,3395642799,4101667470,1202630377,268961816,1874508501,4034427016,1243948399,1546530418,941366308,1470539505,1941222599,2546386513,3421038627,2715671932,3899946140,1042226977,2521517021,1639824860,227249030,260737669,3765465232,2084453954,1907733956,3429263018,2420656344,100860677,4160157185,470683154,3261161891,1781871967,2924959737,1773779408,394692241,2579611992,974986535,664706745,3655459128,3958962195,731420851,571543859,3530123707,2849626480,126783113,865375399,765172662,1008606754,361203602,3387549984,2278477385,2857719295,1344809080,2782912378,59542671,1503764984,160008576,437062935,1707065306,3622233649,2218934982,3496503480,2185314755,697932208,1512910199,504303377,2075177163,2824099068,1841019862,739644986],h=[2781242211,2230877308,2582542199,2381740923,234877682,3184946027,2984144751,1418839493,1348481072,50462977,2848876391,2102799147,434634494,1656084439,3863849899,2599188086,1167051466,2636087938,1082771913,2281340285,368048890,3954334041,3381544775,201060592,3963727277,1739838676,4250903202,3930435503,3206782108,4149453988,2531553906,1536934080,3262494647,484572669,2923271059,1783375398,1517041206,1098792767,49674231,1334037708,1550332980,4098991525,886171109,150598129,2481090929,1940642008,1398944049,1059722517,201851908,1385547719,1699095331,1587397571,674240536,2704774806,252314885,3039795866,151914247,908333586,2602270848,1038082786,651029483,1766729511,3447698098,2682942837,454166793,2652734339,1951935532,775166490,758520603,3000790638,4004797018,4217086112,4137964114,1299594043,1639438038,3464344499,2068982057,1054729187,1901997871,2534638724,4121318227,1757008337,0,750906861,1614815264,535035132,3363418545,3988151131,3201591914,1183697867,3647454910,1265776953,3734260298,3566750796,3903871064,1250283471,1807470800,717615087,3847203498,384695291,3313910595,3617213773,1432761139,2484176261,3481945413,283769337,100925954,2180939647,4037038160,1148730428,3123027871,3813386408,4087501137,4267549603,3229630528,2315620239,2906624658,3156319645,1215313976,82966005,3747855548,3245848246,1974459098,1665278241,807407632,451280895,251524083,1841287890,1283575245,337120268,891687699,801369324,3787349855,2721421207,3431482436,959321879,1469301956,4065699751,2197585534,1199193405,2898814052,3887750493,724703513,2514908019,2696962144,2551808385,3516813135,2141445340,1715741218,2119445034,2872807568,2198571144,3398190662,700968686,3547052216,1009259540,2041044702,3803995742,487983883,1991105499,1004265696,1449407026,1316239930,504629770,3683797321,168560134,1816667172,3837287516,1570751170,1857934291,4014189740,2797888098,2822345105,2754712981,936633572,2347923833,852879335,1133234376,1500395319,3084545389,2348912013,1689376213,3533459022,3762923945,3034082412,4205598294,133428468,634383082,2949277029,2398386810,3913789102,403703816,3580869306,2297460856,1867130149,1918643758,607656988,4049053350,3346248884,1368901318,600565992,2090982877,2632479860,557719327,3717614411,3697393085,2249034635,2232388234,2430627952,1115438654,3295786421,2865522278,3633334344,84280067,33027830,303828494,2747425121,1600795957,4188952407,3496589753,2434238086,1486471617,658119965,3106381470,953803233,334231800,3005978776,857870609,3151128937,1890179545,2298973838,2805175444,3056442267,574365214,2450884487,550103529,1233637070,4289353045,2018519080,2057691103,2399374476,4166623649,2148108681,387583245,3664101311,836232934,3330556482,3100665960,3280093505,2955516313,2002398509,287182607,3413881008,4238890068,3597515707,975967766],y=[1671808611,2089089148,2006576759,2072901243,4061003762,1807603307,1873927791,3310653893,810573872,16974337,1739181671,729634347,4263110654,3613570519,2883997099,1989864566,3393556426,2191335298,3376449993,2106063485,4195741690,1508618841,1204391495,4027317232,2917941677,3563566036,2734514082,2951366063,2629772188,2767672228,1922491506,3227229120,3082974647,4246528509,2477669779,644500518,911895606,1061256767,4144166391,3427763148,878471220,2784252325,3845444069,4043897329,1905517169,3631459288,827548209,356461077,67897348,3344078279,593839651,3277757891,405286936,2527147926,84871685,2595565466,118033927,305538066,2157648768,3795705826,3945188843,661212711,2999812018,1973414517,152769033,2208177539,745822252,439235610,455947803,1857215598,1525593178,2700827552,1391895634,994932283,3596728278,3016654259,695947817,3812548067,795958831,2224493444,1408607827,3513301457,0,3979133421,543178784,4229948412,2982705585,1542305371,1790891114,3410398667,3201918910,961245753,1256100938,1289001036,1491644504,3477767631,3496721360,4012557807,2867154858,4212583931,1137018435,1305975373,861234739,2241073541,1171229253,4178635257,33948674,2139225727,1357946960,1011120188,2679776671,2833468328,1374921297,2751356323,1086357568,2408187279,2460827538,2646352285,944271416,4110742005,3168756668,3066132406,3665145818,560153121,271589392,4279952895,4077846003,3530407890,3444343245,202643468,322250259,3962553324,1608629855,2543990167,1154254916,389623319,3294073796,2817676711,2122513534,1028094525,1689045092,1575467613,422261273,1939203699,1621147744,2174228865,1339137615,3699352540,577127458,712922154,2427141008,2290289544,1187679302,3995715566,3100863416,339486740,3732514782,1591917662,186455563,3681988059,3762019296,844522546,978220090,169743370,1239126601,101321734,611076132,1558493276,3260915650,3547250131,2901361580,1655096418,2443721105,2510565781,3828863972,2039214713,3878868455,3359869896,928607799,1840765549,2374762893,3580146133,1322425422,2850048425,1823791212,1459268694,4094161908,3928346602,1706019429,2056189050,2934523822,135794696,3134549946,2022240376,628050469,779246638,472135708,2800834470,3032970164,3327236038,3894660072,3715932637,1956440180,522272287,1272813131,3185336765,2340818315,2323976074,1888542832,1044544574,3049550261,1722469478,1222152264,50660867,4127324150,236067854,1638122081,895445557,1475980887,3117443513,2257655686,3243809217,489110045,2662934430,3778599393,4162055160,2561878936,288563729,1773916777,3648039385,2391345038,2493985684,2612407707,505560094,2274497927,3911240169,3460925390,1442818645,678973480,3749357023,2358182796,2717407649,2306869641,219617805,3218761151,3862026214,1120306242,1756942440,1103331905,2578459033,762796589,252780047,2966125488,1425844308,3151392187,372911126],b=[1667474886,2088535288,2004326894,2071694838,4075949567,1802223062,1869591006,3318043793,808472672,16843522,1734846926,724270422,4278065639,3621216949,2880169549,1987484396,3402253711,2189597983,3385409673,2105378810,4210693615,1499065266,1195886990,4042263547,2913856577,3570689971,2728590687,2947541573,2627518243,2762274643,1920112356,3233831835,3082273397,4261223649,2475929149,640051788,909531756,1061110142,4160160501,3435941763,875846760,2779116625,3857003729,4059105529,1903268834,3638064043,825316194,353713962,67374088,3351728789,589522246,3284360861,404236336,2526454071,84217610,2593830191,117901582,303183396,2155911963,3806477791,3958056653,656894286,2998062463,1970642922,151591698,2206440989,741110872,437923380,454765878,1852748508,1515908788,2694904667,1381168804,993742198,3604373943,3014905469,690584402,3823320797,791638366,2223281939,1398011302,3520161977,0,3991743681,538992704,4244381667,2981218425,1532751286,1785380564,3419096717,3200178535,960056178,1246420628,1280103576,1482221744,3486468741,3503319995,4025428677,2863326543,4227536621,1128514950,1296947098,859002214,2240123921,1162203018,4193849577,33687044,2139062782,1347481760,1010582648,2678045221,2829640523,1364325282,2745433693,1077985408,2408548869,2459086143,2644360225,943212656,4126475505,3166494563,3065430391,3671750063,555836226,269496352,4294908645,4092792573,3537006015,3452783745,202118168,320025894,3974901699,1600119230,2543297077,1145359496,387397934,3301201811,2812801621,2122220284,1027426170,1684319432,1566435258,421079858,1936954854,1616945344,2172753945,1330631070,3705438115,572679748,707427924,2425400123,2290647819,1179044492,4008585671,3099120491,336870440,3739122087,1583276732,185277718,3688593069,3772791771,842159716,976899700,168435220,1229577106,101059084,606366792,1549591736,3267517855,3553849021,2897014595,1650632388,2442242105,2509612081,3840161747,2038008818,3890688725,3368567691,926374254,1835907034,2374863873,3587531953,1313788572,2846482505,1819063512,1448540844,4109633523,3941213647,1701162954,2054852340,2930698567,134748176,3132806511,2021165296,623210314,774795868,471606328,2795958615,3031746419,3334885783,3907527627,3722280097,1953799400,522133822,1263263126,3183336545,2341176845,2324333839,1886425312,1044267644,3048588401,1718004428,1212733584,50529542,4143317495,235803164,1633788866,892690282,1465383342,3115962473,2256965911,3250673817,488449850,2661202215,3789633753,4177007595,2560144171,286339874,1768537042,3654906025,2391705863,2492770099,2610673197,505291324,2273808917,3924369609,3469625735,1431699370,673740880,3755965093,2358021891,2711746649,2307489801,218961690,3217021541,3873845719,1111672452,1751693520,1094828930,2576986153,757954394,252645662,2964376443,1414855848,3149649517,370555436],g=[1374988112,2118214995,437757123,975658646,1001089995,530400753,2902087851,1273168787,540080725,2910219766,2295101073,4110568485,1340463100,3307916247,641025152,3043140495,3736164937,632953703,1172967064,1576976609,3274667266,2169303058,2370213795,1809054150,59727847,361929877,3211623147,2505202138,3569255213,1484005843,1239443753,2395588676,1975683434,4102977912,2572697195,666464733,3202437046,4035489047,3374361702,2110667444,1675577880,3843699074,2538681184,1649639237,2976151520,3144396420,4269907996,4178062228,1883793496,2403728665,2497604743,1383856311,2876494627,1917518562,3810496343,1716890410,3001755655,800440835,2261089178,3543599269,807962610,599762354,33778362,3977675356,2328828971,2809771154,4077384432,1315562145,1708848333,101039829,3509871135,3299278474,875451293,2733856160,92987698,2767645557,193195065,1080094634,1584504582,3178106961,1042385657,2531067453,3711829422,1306967366,2438237621,1908694277,67556463,1615861247,429456164,3602770327,2302690252,1742315127,2968011453,126454664,3877198648,2043211483,2709260871,2084704233,4169408201,0,159417987,841739592,504459436,1817866830,4245618683,260388950,1034867998,908933415,168810852,1750902305,2606453969,607530554,202008497,2472011535,3035535058,463180190,2160117071,1641816226,1517767529,470948374,3801332234,3231722213,1008918595,303765277,235474187,4069246893,766945465,337553864,1475418501,2943682380,4003061179,2743034109,4144047775,1551037884,1147550661,1543208500,2336434550,3408119516,3069049960,3102011747,3610369226,1113818384,328671808,2227573024,2236228733,3535486456,2935566865,3341394285,496906059,3702665459,226906860,2009195472,733156972,2842737049,294930682,1206477858,2835123396,2700099354,1451044056,573804783,2269728455,3644379585,2362090238,2564033334,2801107407,2776292904,3669462566,1068351396,742039012,1350078989,1784663195,1417561698,4136440770,2430122216,775550814,2193862645,2673705150,1775276924,1876241833,3475313331,3366754619,270040487,3902563182,3678124923,3441850377,1851332852,3969562369,2203032232,3868552805,2868897406,566021896,4011190502,3135740889,1248802510,3936291284,699432150,832877231,708780849,3332740144,899835584,1951317047,4236429990,3767586992,866637845,4043610186,1106041591,2144161806,395441711,1984812685,1139781709,3433712980,3835036895,2664543715,1282050075,3240894392,1181045119,2640243204,25965917,4203181171,4211818798,3009879386,2463879762,3910161971,1842759443,2597806476,933301370,1509430414,3943906441,3467192302,3076639029,3776767469,2051518780,2631065433,1441952575,404016761,1942435775,1408749034,1610459739,3745345300,2017778566,3400528769,3110650942,941896748,3265478751,371049330,3168937228,675039627,4279080257,967311729,135050206,3635733660,1683407248,2076935265,3576870512,1215061108,3501741890],w=[1347548327,1400783205,3273267108,2520393566,3409685355,4045380933,2880240216,2471224067,1428173050,4138563181,2441661558,636813900,4233094615,3620022987,2149987652,2411029155,1239331162,1730525723,2554718734,3781033664,46346101,310463728,2743944855,3328955385,3875770207,2501218972,3955191162,3667219033,768917123,3545789473,692707433,1150208456,1786102409,2029293177,1805211710,3710368113,3065962831,401639597,1724457132,3028143674,409198410,2196052529,1620529459,1164071807,3769721975,2226875310,486441376,2499348523,1483753576,428819965,2274680428,3075636216,598438867,3799141122,1474502543,711349675,129166120,53458370,2592523643,2782082824,4063242375,2988687269,3120694122,1559041666,730517276,2460449204,4042459122,2706270690,3446004468,3573941694,533804130,2328143614,2637442643,2695033685,839224033,1973745387,957055980,2856345839,106852767,1371368976,4181598602,1033297158,2933734917,1179510461,3046200461,91341917,1862534868,4284502037,605657339,2547432937,3431546947,2003294622,3182487618,2282195339,954669403,3682191598,1201765386,3917234703,3388507166,0,2198438022,1211247597,2887651696,1315723890,4227665663,1443857720,507358933,657861945,1678381017,560487590,3516619604,975451694,2970356327,261314535,3535072918,2652609425,1333838021,2724322336,1767536459,370938394,182621114,3854606378,1128014560,487725847,185469197,2918353863,3106780840,3356761769,2237133081,1286567175,3152976349,4255350624,2683765030,3160175349,3309594171,878443390,1988838185,3704300486,1756818940,1673061617,3403100636,272786309,1075025698,545572369,2105887268,4174560061,296679730,1841768865,1260232239,4091327024,3960309330,3497509347,1814803222,2578018489,4195456072,575138148,3299409036,446754879,3629546796,4011996048,3347532110,3252238545,4270639778,915985419,3483825537,681933534,651868046,2755636671,3828103837,223377554,2607439820,1649704518,3270937875,3901806776,1580087799,4118987695,3198115200,2087309459,2842678573,3016697106,1003007129,2802849917,1860738147,2077965243,164439672,4100872472,32283319,2827177882,1709610350,2125135846,136428751,3874428392,3652904859,3460984630,3572145929,3593056380,2939266226,824852259,818324884,3224740454,930369212,2801566410,2967507152,355706840,1257309336,4148292826,243256656,790073846,2373340630,1296297904,1422699085,3756299780,3818836405,457992840,3099667487,2135319889,77422314,1560382517,1945798516,788204353,1521706781,1385356242,870912086,325965383,2358957921,2050466060,2388260884,2313884476,4006521127,901210569,3990953189,1014646705,1503449823,1062597235,2031621326,3212035895,3931371469,1533017514,350174575,2256028891,2177544179,1052338372,741876788,1606591296,1914052035,213705253,2334669897,1107234197,1899603969,3725069491,2631447780,2422494913,1635502980,1893020342,1950903388,1120974935],v=[2807058932,1699970625,2764249623,1586903591,1808481195,1173430173,1487645946,59984867,4199882800,1844882806,1989249228,1277555970,3623636965,3419915562,1149249077,2744104290,1514790577,459744698,244860394,3235995134,1963115311,4027744588,2544078150,4190530515,1608975247,2627016082,2062270317,1507497298,2200818878,567498868,1764313568,3359936201,2305455554,2037970062,1047239e3,1910319033,1337376481,2904027272,2892417312,984907214,1243112415,830661914,861968209,2135253587,2011214180,2927934315,2686254721,731183368,1750626376,4246310725,1820824798,4172763771,3542330227,48394827,2404901663,2871682645,671593195,3254988725,2073724613,145085239,2280796200,2779915199,1790575107,2187128086,472615631,3029510009,4075877127,3802222185,4107101658,3201631749,1646252340,4270507174,1402811438,1436590835,3778151818,3950355702,3963161475,4020912224,2667994737,273792366,2331590177,104699613,95345982,3175501286,2377486676,1560637892,3564045318,369057872,4213447064,3919042237,1137477952,2658625497,1119727848,2340947849,1530455833,4007360968,172466556,266959938,516552836,0,2256734592,3980931627,1890328081,1917742170,4294704398,945164165,3575528878,958871085,3647212047,2787207260,1423022939,775562294,1739656202,3876557655,2530391278,2443058075,3310321856,547512796,1265195639,437656594,3121275539,719700128,3762502690,387781147,218828297,3350065803,2830708150,2848461854,428169201,122466165,3720081049,1627235199,648017665,4122762354,1002783846,2117360635,695634755,3336358691,4234721005,4049844452,3704280881,2232435299,574624663,287343814,612205898,1039717051,840019705,2708326185,793451934,821288114,1391201670,3822090177,376187827,3113855344,1224348052,1679968233,2361698556,1058709744,752375421,2431590963,1321699145,3519142200,2734591178,188127444,2177869557,3727205754,2384911031,3215212461,2648976442,2450346104,3432737375,1180849278,331544205,3102249176,4150144569,2952102595,2159976285,2474404304,766078933,313773861,2570832044,2108100632,1668212892,3145456443,2013908262,418672217,3070356634,2594734927,1852171925,3867060991,3473416636,3907448597,2614737639,919489135,164948639,2094410160,2997825956,590424639,2486224549,1723872674,3157750862,3399941250,3501252752,3625268135,2555048196,3673637356,1343127501,4130281361,3599595085,2957853679,1297403050,81781910,3051593425,2283490410,532201772,1367295589,3926170974,895287692,1953757831,1093597963,492483431,3528626907,1446242576,1192455638,1636604631,209336225,344873464,1015671571,669961897,3375740769,3857572124,2973530695,3747192018,1933530610,3464042516,935293895,3454686199,2858115069,1863638845,3683022916,4085369519,3292445032,875313188,1080017571,3279033885,621591778,1233856572,2504130317,24197544,3017672716,3835484340,3247465558,2220981195,3060847922,1551124588,1463996600],m=[4104605777,1097159550,396673818,660510266,2875968315,2638606623,4200115116,3808662347,821712160,1986918061,3430322568,38544885,3856137295,718002117,893681702,1654886325,2975484382,3122358053,3926825029,4274053469,796197571,1290801793,1184342925,3556361835,2405426947,2459735317,1836772287,1381620373,3196267988,1948373848,3764988233,3385345166,3263785589,2390325492,1480485785,3111247143,3780097726,2293045232,548169417,3459953789,3746175075,439452389,1362321559,1400849762,1685577905,1806599355,2174754046,137073913,1214797936,1174215055,3731654548,2079897426,1943217067,1258480242,529487843,1437280870,3945269170,3049390895,3313212038,923313619,679998e3,3215307299,57326082,377642221,3474729866,2041877159,133361907,1776460110,3673476453,96392454,878845905,2801699524,777231668,4082475170,2330014213,4142626212,2213296395,1626319424,1906247262,1846563261,562755902,3708173718,1040559837,3871163981,1418573201,3294430577,114585348,1343618912,2566595609,3186202582,1078185097,3651041127,3896688048,2307622919,425408743,3371096953,2081048481,1108339068,2216610296,0,2156299017,736970802,292596766,1517440620,251657213,2235061775,2933202493,758720310,265905162,1554391400,1532285339,908999204,174567692,1474760595,4002861748,2610011675,3234156416,3693126241,2001430874,303699484,2478443234,2687165888,585122620,454499602,151849742,2345119218,3064510765,514443284,4044981591,1963412655,2581445614,2137062819,19308535,1928707164,1715193156,4219352155,1126790795,600235211,3992742070,3841024952,836553431,1669664834,2535604243,3323011204,1243905413,3141400786,4180808110,698445255,2653899549,2989552604,2253581325,3252932727,3004591147,1891211689,2487810577,3915653703,4237083816,4030667424,2100090966,865136418,1229899655,953270745,3399679628,3557504664,4118925222,2061379749,3079546586,2915017791,983426092,2022837584,1607244650,2118541908,2366882550,3635996816,972512814,3283088770,1568718495,3499326569,3576539503,621982671,2895723464,410887952,2623762152,1002142683,645401037,1494807662,2595684844,1335535747,2507040230,4293295786,3167684641,367585007,3885750714,1865862730,2668221674,2960971305,2763173681,1059270954,2777952454,2724642869,1320957812,2194319100,2429595872,2815956275,77089521,3973773121,3444575871,2448830231,1305906550,4021308739,2857194700,2516901860,3518358430,1787304780,740276417,1699839814,1592394909,2352307457,2272556026,188821243,1729977011,3687994002,274084841,3594982253,3613494426,2701949495,4162096729,322734571,2837966542,1640576439,484830689,1202797690,3537852828,4067639125,349075736,3342319475,4157467219,4255800159,1030690015,1155237496,2951971274,1757691577,607398968,2738905026,499347990,3794078908,1011452712,227885567,2818666809,213114376,3034881240,1455525988,3414450555,850817237,1817998408,3092726480],I=[0,235474187,470948374,303765277,941896748,908933415,607530554,708780849,1883793496,2118214995,1817866830,1649639237,1215061108,1181045119,1417561698,1517767529,3767586992,4003061179,4236429990,4069246893,3635733660,3602770327,3299278474,3400528769,2430122216,2664543715,2362090238,2193862645,2835123396,2801107407,3035535058,3135740889,3678124923,3576870512,3341394285,3374361702,3810496343,3977675356,4279080257,4043610186,2876494627,2776292904,3076639029,3110650942,2472011535,2640243204,2403728665,2169303058,1001089995,899835584,666464733,699432150,59727847,226906860,530400753,294930682,1273168787,1172967064,1475418501,1509430414,1942435775,2110667444,1876241833,1641816226,2910219766,2743034109,2976151520,3211623147,2505202138,2606453969,2302690252,2269728455,3711829422,3543599269,3240894392,3475313331,3843699074,3943906441,4178062228,4144047775,1306967366,1139781709,1374988112,1610459739,1975683434,2076935265,1775276924,1742315127,1034867998,866637845,566021896,800440835,92987698,193195065,429456164,395441711,1984812685,2017778566,1784663195,1683407248,1315562145,1080094634,1383856311,1551037884,101039829,135050206,437757123,337553864,1042385657,807962610,573804783,742039012,2531067453,2564033334,2328828971,2227573024,2935566865,2700099354,3001755655,3168937228,3868552805,3902563182,4203181171,4102977912,3736164937,3501741890,3265478751,3433712980,1106041591,1340463100,1576976609,1408749034,2043211483,2009195472,1708848333,1809054150,832877231,1068351396,766945465,599762354,159417987,126454664,361929877,463180190,2709260871,2943682380,3178106961,3009879386,2572697195,2538681184,2236228733,2336434550,3509871135,3745345300,3441850377,3274667266,3910161971,3877198648,4110568485,4211818798,2597806476,2497604743,2261089178,2295101073,2733856160,2902087851,3202437046,2968011453,3936291284,3835036895,4136440770,4169408201,3535486456,3702665459,3467192302,3231722213,2051518780,1951317047,1716890410,1750902305,1113818384,1282050075,1584504582,1350078989,168810852,67556463,371049330,404016761,841739592,1008918595,775550814,540080725,3969562369,3801332234,4035489047,4269907996,3569255213,3669462566,3366754619,3332740144,2631065433,2463879762,2160117071,2395588676,2767645557,2868897406,3102011747,3069049960,202008497,33778362,270040487,504459436,875451293,975658646,675039627,641025152,2084704233,1917518562,1615861247,1851332852,1147550661,1248802510,1484005843,1451044056,933301370,967311729,733156972,632953703,260388950,25965917,328671808,496906059,1206477858,1239443753,1543208500,1441952575,2144161806,1908694277,1675577880,1842759443,3610369226,3644379585,3408119516,3307916247,4011190502,3776767469,4077384432,4245618683,2809771154,2842737049,3144396420,3043140495,2673705150,2438237621,2203032232,2370213795],E=[0,185469197,370938394,487725847,741876788,657861945,975451694,824852259,1483753576,1400783205,1315723890,1164071807,1950903388,2135319889,1649704518,1767536459,2967507152,3152976349,2801566410,2918353863,2631447780,2547432937,2328143614,2177544179,3901806776,3818836405,4270639778,4118987695,3299409036,3483825537,3535072918,3652904859,2077965243,1893020342,1841768865,1724457132,1474502543,1559041666,1107234197,1257309336,598438867,681933534,901210569,1052338372,261314535,77422314,428819965,310463728,3409685355,3224740454,3710368113,3593056380,3875770207,3960309330,4045380933,4195456072,2471224067,2554718734,2237133081,2388260884,3212035895,3028143674,2842678573,2724322336,4138563181,4255350624,3769721975,3955191162,3667219033,3516619604,3431546947,3347532110,2933734917,2782082824,3099667487,3016697106,2196052529,2313884476,2499348523,2683765030,1179510461,1296297904,1347548327,1533017514,1786102409,1635502980,2087309459,2003294622,507358933,355706840,136428751,53458370,839224033,957055980,605657339,790073846,2373340630,2256028891,2607439820,2422494913,2706270690,2856345839,3075636216,3160175349,3573941694,3725069491,3273267108,3356761769,4181598602,4063242375,4011996048,3828103837,1033297158,915985419,730517276,545572369,296679730,446754879,129166120,213705253,1709610350,1860738147,1945798516,2029293177,1239331162,1120974935,1606591296,1422699085,4148292826,4233094615,3781033664,3931371469,3682191598,3497509347,3446004468,3328955385,2939266226,2755636671,3106780840,2988687269,2198438022,2282195339,2501218972,2652609425,1201765386,1286567175,1371368976,1521706781,1805211710,1620529459,2105887268,1988838185,533804130,350174575,164439672,46346101,870912086,954669403,636813900,788204353,2358957921,2274680428,2592523643,2441661558,2695033685,2880240216,3065962831,3182487618,3572145929,3756299780,3270937875,3388507166,4174560061,4091327024,4006521127,3854606378,1014646705,930369212,711349675,560487590,272786309,457992840,106852767,223377554,1678381017,1862534868,1914052035,2031621326,1211247597,1128014560,1580087799,1428173050,32283319,182621114,401639597,486441376,768917123,651868046,1003007129,818324884,1503449823,1385356242,1333838021,1150208456,1973745387,2125135846,1673061617,1756818940,2970356327,3120694122,2802849917,2887651696,2637442643,2520393566,2334669897,2149987652,3917234703,3799141122,4284502037,4100872472,3309594171,3460984630,3545789473,3629546796,2050466060,1899603969,1814803222,1730525723,1443857720,1560382517,1075025698,1260232239,575138148,692707433,878443390,1062597235,243256656,91341917,409198410,325965383,3403100636,3252238545,3704300486,3620022987,3874428392,3990953189,4042459122,4227665663,2460449204,2578018489,2226875310,2411029155,3198115200,3046200461,2827177882,2743944855],S=[0,218828297,437656594,387781147,875313188,958871085,775562294,590424639,1750626376,1699970625,1917742170,2135253587,1551124588,1367295589,1180849278,1265195639,3501252752,3720081049,3399941250,3350065803,3835484340,3919042237,4270507174,4085369519,3102249176,3051593425,2734591178,2952102595,2361698556,2177869557,2530391278,2614737639,3145456443,3060847922,2708326185,2892417312,2404901663,2187128086,2504130317,2555048196,3542330227,3727205754,3375740769,3292445032,3876557655,3926170974,4246310725,4027744588,1808481195,1723872674,1910319033,2094410160,1608975247,1391201670,1173430173,1224348052,59984867,244860394,428169201,344873464,935293895,984907214,766078933,547512796,1844882806,1627235199,2011214180,2062270317,1507497298,1423022939,1137477952,1321699145,95345982,145085239,532201772,313773861,830661914,1015671571,731183368,648017665,3175501286,2957853679,2807058932,2858115069,2305455554,2220981195,2474404304,2658625497,3575528878,3625268135,3473416636,3254988725,3778151818,3963161475,4213447064,4130281361,3599595085,3683022916,3432737375,3247465558,3802222185,4020912224,4172763771,4122762354,3201631749,3017672716,2764249623,2848461854,2331590177,2280796200,2431590963,2648976442,104699613,188127444,472615631,287343814,840019705,1058709744,671593195,621591778,1852171925,1668212892,1953757831,2037970062,1514790577,1463996600,1080017571,1297403050,3673637356,3623636965,3235995134,3454686199,4007360968,3822090177,4107101658,4190530515,2997825956,3215212461,2830708150,2779915199,2256734592,2340947849,2627016082,2443058075,172466556,122466165,273792366,492483431,1047239e3,861968209,612205898,695634755,1646252340,1863638845,2013908262,1963115311,1446242576,1530455833,1277555970,1093597963,1636604631,1820824798,2073724613,1989249228,1436590835,1487645946,1337376481,1119727848,164948639,81781910,331544205,516552836,1039717051,821288114,669961897,719700128,2973530695,3157750862,2871682645,2787207260,2232435299,2283490410,2667994737,2450346104,3647212047,3564045318,3279033885,3464042516,3980931627,3762502690,4150144569,4199882800,3070356634,3121275539,2904027272,2686254721,2200818878,2384911031,2570832044,2486224549,3747192018,3528626907,3310321856,3359936201,3950355702,3867060991,4049844452,4234721005,1739656202,1790575107,2108100632,1890328081,1402811438,1586903591,1233856572,1149249077,266959938,48394827,369057872,418672217,1002783846,919489135,567498868,752375421,209336225,24197544,376187827,459744698,945164165,895287692,574624663,793451934,1679968233,1764313568,2117360635,1933530610,1343127501,1560637892,1243112415,1192455638,3704280881,3519142200,3336358691,3419915562,3907448597,3857572124,4075877127,4294704398,3029510009,3113855344,2927934315,2744104290,2159976285,2377486676,2594734927,2544078150],O=[0,151849742,303699484,454499602,607398968,758720310,908999204,1059270954,1214797936,1097159550,1517440620,1400849762,1817998408,1699839814,2118541908,2001430874,2429595872,2581445614,2194319100,2345119218,3034881240,3186202582,2801699524,2951971274,3635996816,3518358430,3399679628,3283088770,4237083816,4118925222,4002861748,3885750714,1002142683,850817237,698445255,548169417,529487843,377642221,227885567,77089521,1943217067,2061379749,1640576439,1757691577,1474760595,1592394909,1174215055,1290801793,2875968315,2724642869,3111247143,2960971305,2405426947,2253581325,2638606623,2487810577,3808662347,3926825029,4044981591,4162096729,3342319475,3459953789,3576539503,3693126241,1986918061,2137062819,1685577905,1836772287,1381620373,1532285339,1078185097,1229899655,1040559837,923313619,740276417,621982671,439452389,322734571,137073913,19308535,3871163981,4021308739,4104605777,4255800159,3263785589,3414450555,3499326569,3651041127,2933202493,2815956275,3167684641,3049390895,2330014213,2213296395,2566595609,2448830231,1305906550,1155237496,1607244650,1455525988,1776460110,1626319424,2079897426,1928707164,96392454,213114376,396673818,514443284,562755902,679998e3,865136418,983426092,3708173718,3557504664,3474729866,3323011204,4180808110,4030667424,3945269170,3794078908,2507040230,2623762152,2272556026,2390325492,2975484382,3092726480,2738905026,2857194700,3973773121,3856137295,4274053469,4157467219,3371096953,3252932727,3673476453,3556361835,2763173681,2915017791,3064510765,3215307299,2156299017,2307622919,2459735317,2610011675,2081048481,1963412655,1846563261,1729977011,1480485785,1362321559,1243905413,1126790795,878845905,1030690015,645401037,796197571,274084841,425408743,38544885,188821243,3613494426,3731654548,3313212038,3430322568,4082475170,4200115116,3780097726,3896688048,2668221674,2516901860,2366882550,2216610296,3141400786,2989552604,2837966542,2687165888,1202797690,1320957812,1437280870,1554391400,1669664834,1787304780,1906247262,2022837584,265905162,114585348,499347990,349075736,736970802,585122620,972512814,821712160,2595684844,2478443234,2293045232,2174754046,3196267988,3079546586,2895723464,2777952454,3537852828,3687994002,3234156416,3385345166,4142626212,4293295786,3841024952,3992742070,174567692,57326082,410887952,292596766,777231668,660510266,1011452712,893681702,1108339068,1258480242,1343618912,1494807662,1715193156,1865862730,1948373848,2100090966,2701949495,2818666809,3004591147,3122358053,2235061775,2352307457,2535604243,2653899549,3915653703,3764988233,4219352155,4067639125,3444575871,3294430577,3746175075,3594982253,836553431,953270745,600235211,718002117,367585007,484830689,133361907,251657213,2041877159,1891211689,1806599355,1654886325,1568718495,1418573201,1335535747,1184342925];function A(e){for(var t=[],n=0;n<e.length;n+=4)t.push(e[n]<<24|e[n+1]<<16|e[n+2]<<8|e[n+3]);return t}var T=function(e){if(!(this instanceof T))throw Error("AES must be instanitated with `new`");Object.defineProperty(this,"key",{value:r(e,!0)}),this._prepare()};T.prototype._prepare=function(){var e=u[this.key.length];if(null==e)throw new Error("invalid key size (must be 16, 24 or 32 bytes)");this._Ke=[],this._Kd=[];for(var t=0;t<=e;t++)this._Ke.push([0,0,0,0]),this._Kd.push([0,0,0,0]);var n,r=4*(e+1),o=this.key.length/4,i=A(this.key);for(t=0;t<o;t++)n=t>>2,this._Ke[n][t%4]=i[t],this._Kd[e-n][t%4]=i[t];for(var a,s=0,c=o;c<r;){if(a=i[o-1],i[0]^=d[a>>16&255]<<24^d[a>>8&255]<<16^d[255&a]<<8^d[a>>24&255]^l[s]<<24,s+=1,8!=o)for(t=1;t<o;t++)i[t]^=i[t-1];else{for(t=1;t<o/2;t++)i[t]^=i[t-1];a=i[o/2-1],i[o/2]^=d[255&a]^d[a>>8&255]<<8^d[a>>16&255]<<16^d[a>>24&255]<<24;for(t=o/2+1;t<o;t++)i[t]^=i[t-1]}for(t=0;t<o&&c<r;)f=c>>2,p=c%4,this._Ke[f][p]=i[t],this._Kd[e-f][p]=i[t++],c++}for(var f=1;f<e;f++)for(var p=0;p<4;p++)a=this._Kd[f][p],this._Kd[f][p]=I[a>>24&255]^E[a>>16&255]^S[a>>8&255]^O[255&a]},T.prototype.encrypt=function(e){if(16!=e.length)throw new Error("invalid plaintext size (must be 16 bytes)");for(var t=this._Ke.length-1,n=[0,0,0,0],r=A(e),i=0;i<4;i++)r[i]^=this._Ke[0][i];for(var a=1;a<t;a++){for(i=0;i<4;i++)n[i]=p[r[i]>>24&255]^h[r[(i+1)%4]>>16&255]^y[r[(i+2)%4]>>8&255]^b[255&r[(i+3)%4]]^this._Ke[a][i];r=n.slice()}var s,c=o(16);for(i=0;i<4;i++)s=this._Ke[t][i],c[4*i]=255&(d[r[i]>>24&255]^s>>24),c[4*i+1]=255&(d[r[(i+1)%4]>>16&255]^s>>16),c[4*i+2]=255&(d[r[(i+2)%4]>>8&255]^s>>8),c[4*i+3]=255&(d[255&r[(i+3)%4]]^s);return c},T.prototype.decrypt=function(e){if(16!=e.length)throw new Error("invalid ciphertext size (must be 16 bytes)");for(var t=this._Kd.length-1,n=[0,0,0,0],r=A(e),i=0;i<4;i++)r[i]^=this._Kd[0][i];for(var a=1;a<t;a++){for(i=0;i<4;i++)n[i]=g[r[i]>>24&255]^w[r[(i+3)%4]>>16&255]^v[r[(i+2)%4]>>8&255]^m[255&r[(i+1)%4]]^this._Kd[a][i];r=n.slice()}var s,c=o(16);for(i=0;i<4;i++)s=this._Kd[t][i],c[4*i]=255&(f[r[i]>>24&255]^s>>24),c[4*i+1]=255&(f[r[(i+3)%4]>>16&255]^s>>16),c[4*i+2]=255&(f[r[(i+2)%4]>>8&255]^s>>8),c[4*i+3]=255&(f[255&r[(i+1)%4]]^s);return c};var _=function(e){if(!(this instanceof _))throw Error("AES must be instanitated with `new`");this.description="Electronic Code Block",this.name="ecb",this._aes=new T(e)};_.prototype.encrypt=function(e){if((e=r(e)).length%16!=0)throw new Error("invalid plaintext size (must be multiple of 16 bytes)");for(var t=o(e.length),n=o(16),a=0;a<e.length;a+=16)i(e,n,0,a,a+16),i(n=this._aes.encrypt(n),t,a);return t},_.prototype.decrypt=function(e){if((e=r(e)).length%16!=0)throw new Error("invalid ciphertext size (must be multiple of 16 bytes)");for(var t=o(e.length),n=o(16),a=0;a<e.length;a+=16)i(e,n,0,a,a+16),i(n=this._aes.decrypt(n),t,a);return t};var k=function(e,t){if(!(this instanceof k))throw Error("AES must be instanitated with `new`");if(this.description="Cipher Block Chaining",this.name="cbc",t){if(16!=t.length)throw new Error("invalid initialation vector size (must be 16 bytes)")}else t=o(16);this._lastCipherblock=r(t,!0),this._aes=new T(e)};k.prototype.encrypt=function(e){if((e=r(e)).length%16!=0)throw new Error("invalid plaintext size (must be multiple of 16 bytes)");for(var t=o(e.length),n=o(16),a=0;a<e.length;a+=16){i(e,n,0,a,a+16);for(var s=0;s<16;s++)n[s]^=this._lastCipherblock[s];this._lastCipherblock=this._aes.encrypt(n),i(this._lastCipherblock,t,a)}return t},k.prototype.decrypt=function(e){if((e=r(e)).length%16!=0)throw new Error("invalid ciphertext size (must be multiple of 16 bytes)");for(var t=o(e.length),n=o(16),a=0;a<e.length;a+=16){i(e,n,0,a,a+16),n=this._aes.decrypt(n);for(var s=0;s<16;s++)t[a+s]=n[s]^this._lastCipherblock[s];i(e,this._lastCipherblock,0,a,a+16)}return t};var x=function(e,t,n){if(!(this instanceof x))throw Error("AES must be instanitated with `new`");if(this.description="Cipher Feedback",this.name="cfb",t){if(16!=t.length)throw new Error("invalid initialation vector size (must be 16 size)")}else t=o(16);n||(n=1),this.segmentSize=n,this._shiftRegister=r(t,!0),this._aes=new T(e)};x.prototype.encrypt=function(e){if(e.length%this.segmentSize!=0)throw new Error("invalid plaintext size (must be segmentSize bytes)");for(var t,n=r(e,!0),o=0;o<n.length;o+=this.segmentSize){t=this._aes.encrypt(this._shiftRegister);for(var a=0;a<this.segmentSize;a++)n[o+a]^=t[a];i(this._shiftRegister,this._shiftRegister,0,this.segmentSize),i(n,this._shiftRegister,16-this.segmentSize,o,o+this.segmentSize)}return n},x.prototype.decrypt=function(e){if(e.length%this.segmentSize!=0)throw new Error("invalid ciphertext size (must be segmentSize bytes)");for(var t,n=r(e,!0),o=0;o<n.length;o+=this.segmentSize){t=this._aes.encrypt(this._shiftRegister);for(var a=0;a<this.segmentSize;a++)n[o+a]^=t[a];i(this._shiftRegister,this._shiftRegister,0,this.segmentSize),i(e,this._shiftRegister,16-this.segmentSize,o,o+this.segmentSize)}return n};var P=function(e,t){if(!(this instanceof P))throw Error("AES must be instanitated with `new`");if(this.description="Output Feedback",this.name="ofb",t){if(16!=t.length)throw new Error("invalid initialation vector size (must be 16 bytes)")}else t=o(16);this._lastPrecipher=r(t,!0),this._lastPrecipherIndex=16,this._aes=new T(e)};P.prototype.encrypt=function(e){for(var t=r(e,!0),n=0;n<t.length;n++)16===this._lastPrecipherIndex&&(this._lastPrecipher=this._aes.encrypt(this._lastPrecipher),this._lastPrecipherIndex=0),t[n]^=this._lastPrecipher[this._lastPrecipherIndex++];return t},P.prototype.decrypt=P.prototype.encrypt;var M=function(e){if(!(this instanceof M))throw Error("Counter must be instanitated with `new`");0===e||e||(e=1),"number"==typeof e?(this._counter=o(16),this.setValue(e)):this.setBytes(e)};M.prototype.setValue=function(e){if("number"!=typeof e||parseInt(e)!=e)throw new Error("invalid counter value (must be an integer)");if(e>Number.MAX_SAFE_INTEGER)throw new Error("integer value out of safe range");for(var t=15;t>=0;--t)this._counter[t]=e%256,e=parseInt(e/256)},M.prototype.setBytes=function(e){if(16!=(e=r(e,!0)).length)throw new Error("invalid counter bytes size (must be 16 bytes)");this._counter=e},M.prototype.increment=function(){for(var e=15;e>=0;e--){if(255!==this._counter[e]){this._counter[e]++;break}this._counter[e]=0}};var C=function(e,t){if(!(this instanceof C))throw Error("AES must be instanitated with `new`");this.description="Counter",this.name="ctr",t instanceof M||(t=new M(t)),this._counter=t,this._remainingCounter=null,this._remainingCounterIndex=16,this._aes=new T(e)};C.prototype.encrypt=function(e){for(var t=r(e,!0),n=0;n<t.length;n++)16===this._remainingCounterIndex&&(this._remainingCounter=this._aes.encrypt(this._counter._counter),this._remainingCounterIndex=0,this._counter.increment()),t[n]^=this._remainingCounter[this._remainingCounterIndex++];return t},C.prototype.decrypt=C.prototype.encrypt;var N={AES:T,Counter:M,ModeOfOperation:{ecb:_,cbc:k,cfb:x,ofb:P,ctr:C},utils:{hex:c,utf8:s},padding:{pkcs7:{pad:function(e){var t=16-(e=r(e,!0)).length%16,n=o(e.length+t);i(e,n);for(var a=e.length;a<n.length;a++)n[a]=t;return n},strip:function(e){if((e=r(e,!0)).length<16)throw new Error("PKCS#7 invalid length");var t=e[e.length-1];if(t>16)throw new Error("PKCS#7 padding byte out of range");for(var n=e.length-t,a=0;a<t;a++)if(e[n+a]!==t)throw new Error("PKCS#7 invalid padding byte");var s=o(n);return i(e,s,0,0,n),s}}},_arrayTest:{coerceArray:r,createArray:o,copyArray:i}};e.exports=N}()},3917:function(e,t,n){"use strict";var r=n(7426),o=n(6166),i=n(6225),a=r.rotl32,s=r.sum32,c=r.sum32_5,u=i.ft_1,l=o.BlockHash,d=[1518500249,1859775393,2400959708,3395469782];function f(){if(!(this instanceof f))return new f;l.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=new Array(80)}r.inherits(f,l),e.exports=f,f.blockSize=512,f.outSize=160,f.hmacStrength=80,f.padLength=64,f.prototype._update=function(e,t){for(var n=this.W,r=0;r<16;r++)n[r]=e[t+r];for(;r<n.length;r++)n[r]=a(n[r-3]^n[r-8]^n[r-14]^n[r-16],1);var o=this.h[0],i=this.h[1],l=this.h[2],f=this.h[3],p=this.h[4];for(r=0;r<n.length;r++){var h=~~(r/20),y=c(a(o,5),u(h,i,l,f),p,n[r],d[h]);p=f,f=l,l=a(i,30),i=o,o=y}this.h[0]=s(this.h[0],o),this.h[1]=s(this.h[1],i),this.h[2]=s(this.h[2],l),this.h[3]=s(this.h[3],f),this.h[4]=s(this.h[4],p)},f.prototype._digest=function(e){return"hex"===e?r.toHex32(this.h,"big"):r.split32(this.h,"big")}},4011:function(e){e.exports={doubles:{step:4,points:[["e60fce93b59e9ec53011aabc21c23e97b2a31369b87a5ae9c44ee89e2a6dec0a","f7e3507399e595929db99f34f57937101296891e44d23f0be1f32cce69616821"],["8282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508","11f8a8098557dfe45e8256e830b60ace62d613ac2f7b17bed31b6eaff6e26caf"],["175e159f728b865a72f99cc6c6fc846de0b93833fd2222ed73fce5b551e5b739","d3506e0d9e3c79eba4ef97a51ff71f5eacb5955add24345c6efa6ffee9fed695"],["363d90d447b00c9c99ceac05b6262ee053441c7e55552ffe526bad8f83ff4640","4e273adfc732221953b445397f3363145b9a89008199ecb62003c7f3bee9de9"],["8b4b5f165df3c2be8c6244b5b745638843e4a781a15bcd1b69f79a55dffdf80c","4aad0a6f68d308b4b3fbd7813ab0da04f9e336546162ee56b3eff0c65fd4fd36"],["723cbaa6e5db996d6bf771c00bd548c7b700dbffa6c0e77bcb6115925232fcda","96e867b5595cc498a921137488824d6e2660a0653779494801dc069d9eb39f5f"],["eebfa4d493bebf98ba5feec812c2d3b50947961237a919839a533eca0e7dd7fa","5d9a8ca3970ef0f269ee7edaf178089d9ae4cdc3a711f712ddfd4fdae1de8999"],["100f44da696e71672791d0a09b7bde459f1215a29b3c03bfefd7835b39a48db0","cdd9e13192a00b772ec8f3300c090666b7ff4a18ff5195ac0fbd5cd62bc65a09"],["e1031be262c7ed1b1dc9227a4a04c017a77f8d4464f3b3852c8acde6e534fd2d","9d7061928940405e6bb6a4176597535af292dd419e1ced79a44f18f29456a00d"],["feea6cae46d55b530ac2839f143bd7ec5cf8b266a41d6af52d5e688d9094696d","e57c6b6c97dce1bab06e4e12bf3ecd5c981c8957cc41442d3155debf18090088"],["da67a91d91049cdcb367be4be6ffca3cfeed657d808583de33fa978bc1ec6cb1","9bacaa35481642bc41f463f7ec9780e5dec7adc508f740a17e9ea8e27a68be1d"],["53904faa0b334cdda6e000935ef22151ec08d0f7bb11069f57545ccc1a37b7c0","5bc087d0bc80106d88c9eccac20d3c1c13999981e14434699dcb096b022771c8"],["8e7bcd0bd35983a7719cca7764ca906779b53a043a9b8bcaeff959f43ad86047","10b7770b2a3da4b3940310420ca9514579e88e2e47fd68b3ea10047e8460372a"],["385eed34c1cdff21e6d0818689b81bde71a7f4f18397e6690a841e1599c43862","283bebc3e8ea23f56701de19e9ebf4576b304eec2086dc8cc0458fe5542e5453"],["6f9d9b803ecf191637c73a4413dfa180fddf84a5947fbc9c606ed86c3fac3a7","7c80c68e603059ba69b8e2a30e45c4d47ea4dd2f5c281002d86890603a842160"],["3322d401243c4e2582a2147c104d6ecbf774d163db0f5e5313b7e0e742d0e6bd","56e70797e9664ef5bfb019bc4ddaf9b72805f63ea2873af624f3a2e96c28b2a0"],["85672c7d2de0b7da2bd1770d89665868741b3f9af7643397721d74d28134ab83","7c481b9b5b43b2eb6374049bfa62c2e5e77f17fcc5298f44c8e3094f790313a6"],["948bf809b1988a46b06c9f1919413b10f9226c60f668832ffd959af60c82a0a","53a562856dcb6646dc6b74c5d1c3418c6d4dff08c97cd2bed4cb7f88d8c8e589"],["6260ce7f461801c34f067ce0f02873a8f1b0e44dfc69752accecd819f38fd8e8","bc2da82b6fa5b571a7f09049776a1ef7ecd292238051c198c1a84e95b2b4ae17"],["e5037de0afc1d8d43d8348414bbf4103043ec8f575bfdc432953cc8d2037fa2d","4571534baa94d3b5f9f98d09fb990bddbd5f5b03ec481f10e0e5dc841d755bda"],["e06372b0f4a207adf5ea905e8f1771b4e7e8dbd1c6a6c5b725866a0ae4fce725","7a908974bce18cfe12a27bb2ad5a488cd7484a7787104870b27034f94eee31dd"],["213c7a715cd5d45358d0bbf9dc0ce02204b10bdde2a3f58540ad6908d0559754","4b6dad0b5ae462507013ad06245ba190bb4850f5f36a7eeddff2c27534b458f2"],["4e7c272a7af4b34e8dbb9352a5419a87e2838c70adc62cddf0cc3a3b08fbd53c","17749c766c9d0b18e16fd09f6def681b530b9614bff7dd33e0b3941817dcaae6"],["fea74e3dbe778b1b10f238ad61686aa5c76e3db2be43057632427e2840fb27b6","6e0568db9b0b13297cf674deccb6af93126b596b973f7b77701d3db7f23cb96f"],["76e64113f677cf0e10a2570d599968d31544e179b760432952c02a4417bdde39","c90ddf8dee4e95cf577066d70681f0d35e2a33d2b56d2032b4b1752d1901ac01"],["c738c56b03b2abe1e8281baa743f8f9a8f7cc643df26cbee3ab150242bcbb891","893fb578951ad2537f718f2eacbfbbbb82314eef7880cfe917e735d9699a84c3"],["d895626548b65b81e264c7637c972877d1d72e5f3a925014372e9f6588f6c14b","febfaa38f2bc7eae728ec60818c340eb03428d632bb067e179363ed75d7d991f"],["b8da94032a957518eb0f6433571e8761ceffc73693e84edd49150a564f676e03","2804dfa44805a1e4d7c99cc9762808b092cc584d95ff3b511488e4e74efdf6e7"],["e80fea14441fb33a7d8adab9475d7fab2019effb5156a792f1a11778e3c0df5d","eed1de7f638e00771e89768ca3ca94472d155e80af322ea9fcb4291b6ac9ec78"],["a301697bdfcd704313ba48e51d567543f2a182031efd6915ddc07bbcc4e16070","7370f91cfb67e4f5081809fa25d40f9b1735dbf7c0a11a130c0d1a041e177ea1"],["90ad85b389d6b936463f9d0512678de208cc330b11307fffab7ac63e3fb04ed4","e507a3620a38261affdcbd9427222b839aefabe1582894d991d4d48cb6ef150"],["8f68b9d2f63b5f339239c1ad981f162ee88c5678723ea3351b7b444c9ec4c0da","662a9f2dba063986de1d90c2b6be215dbbea2cfe95510bfdf23cbf79501fff82"],["e4f3fb0176af85d65ff99ff9198c36091f48e86503681e3e6686fd5053231e11","1e63633ad0ef4f1c1661a6d0ea02b7286cc7e74ec951d1c9822c38576feb73bc"],["8c00fa9b18ebf331eb961537a45a4266c7034f2f0d4e1d0716fb6eae20eae29e","efa47267fea521a1a9dc343a3736c974c2fadafa81e36c54e7d2a4c66702414b"],["e7a26ce69dd4829f3e10cec0a9e98ed3143d084f308b92c0997fddfc60cb3e41","2a758e300fa7984b471b006a1aafbb18d0a6b2c0420e83e20e8a9421cf2cfd51"],["b6459e0ee3662ec8d23540c223bcbdc571cbcb967d79424f3cf29eb3de6b80ef","67c876d06f3e06de1dadf16e5661db3c4b3ae6d48e35b2ff30bf0b61a71ba45"],["d68a80c8280bb840793234aa118f06231d6f1fc67e73c5a5deda0f5b496943e8","db8ba9fff4b586d00c4b1f9177b0e28b5b0e7b8f7845295a294c84266b133120"],["324aed7df65c804252dc0270907a30b09612aeb973449cea4095980fc28d3d5d","648a365774b61f2ff130c0c35aec1f4f19213b0c7e332843967224af96ab7c84"],["4df9c14919cde61f6d51dfdbe5fee5dceec4143ba8d1ca888e8bd373fd054c96","35ec51092d8728050974c23a1d85d4b5d506cdc288490192ebac06cad10d5d"],["9c3919a84a474870faed8a9c1cc66021523489054d7f0308cbfc99c8ac1f98cd","ddb84f0f4a4ddd57584f044bf260e641905326f76c64c8e6be7e5e03d4fc599d"],["6057170b1dd12fdf8de05f281d8e06bb91e1493a8b91d4cc5a21382120a959e5","9a1af0b26a6a4807add9a2daf71df262465152bc3ee24c65e899be932385a2a8"],["a576df8e23a08411421439a4518da31880cef0fba7d4df12b1a6973eecb94266","40a6bf20e76640b2c92b97afe58cd82c432e10a7f514d9f3ee8be11ae1b28ec8"],["7778a78c28dec3e30a05fe9629de8c38bb30d1f5cf9a3a208f763889be58ad71","34626d9ab5a5b22ff7098e12f2ff580087b38411ff24ac563b513fc1fd9f43ac"],["928955ee637a84463729fd30e7afd2ed5f96274e5ad7e5cb09eda9c06d903ac","c25621003d3f42a827b78a13093a95eeac3d26efa8a8d83fc5180e935bcd091f"],["85d0fef3ec6db109399064f3a0e3b2855645b4a907ad354527aae75163d82751","1f03648413a38c0be29d496e582cf5663e8751e96877331582c237a24eb1f962"],["ff2b0dce97eece97c1c9b6041798b85dfdfb6d8882da20308f5404824526087e","493d13fef524ba188af4c4dc54d07936c7b7ed6fb90e2ceb2c951e01f0c29907"],["827fbbe4b1e880ea9ed2b2e6301b212b57f1ee148cd6dd28780e5e2cf856e241","c60f9c923c727b0b71bef2c67d1d12687ff7a63186903166d605b68baec293ec"],["eaa649f21f51bdbae7be4ae34ce6e5217a58fdce7f47f9aa7f3b58fa2120e2b3","be3279ed5bbbb03ac69a80f89879aa5a01a6b965f13f7e59d47a5305ba5ad93d"],["e4a42d43c5cf169d9391df6decf42ee541b6d8f0c9a137401e23632dda34d24f","4d9f92e716d1c73526fc99ccfb8ad34ce886eedfa8d8e4f13a7f7131deba9414"],["1ec80fef360cbdd954160fadab352b6b92b53576a88fea4947173b9d4300bf19","aeefe93756b5340d2f3a4958a7abbf5e0146e77f6295a07b671cdc1cc107cefd"],["146a778c04670c2f91b00af4680dfa8bce3490717d58ba889ddb5928366642be","b318e0ec3354028add669827f9d4b2870aaa971d2f7e5ed1d0b297483d83efd0"],["fa50c0f61d22e5f07e3acebb1aa07b128d0012209a28b9776d76a8793180eef9","6b84c6922397eba9b72cd2872281a68a5e683293a57a213b38cd8d7d3f4f2811"],["da1d61d0ca721a11b1a5bf6b7d88e8421a288ab5d5bba5220e53d32b5f067ec2","8157f55a7c99306c79c0766161c91e2966a73899d279b48a655fba0f1ad836f1"],["a8e282ff0c9706907215ff98e8fd416615311de0446f1e062a73b0610d064e13","7f97355b8db81c09abfb7f3c5b2515888b679a3e50dd6bd6cef7c73111f4cc0c"],["174a53b9c9a285872d39e56e6913cab15d59b1fa512508c022f382de8319497c","ccc9dc37abfc9c1657b4155f2c47f9e6646b3a1d8cb9854383da13ac079afa73"],["959396981943785c3d3e57edf5018cdbe039e730e4918b3d884fdff09475b7ba","2e7e552888c331dd8ba0386a4b9cd6849c653f64c8709385e9b8abf87524f2fd"],["d2a63a50ae401e56d645a1153b109a8fcca0a43d561fba2dbb51340c9d82b151","e82d86fb6443fcb7565aee58b2948220a70f750af484ca52d4142174dcf89405"],["64587e2335471eb890ee7896d7cfdc866bacbdbd3839317b3436f9b45617e073","d99fcdd5bf6902e2ae96dd6447c299a185b90a39133aeab358299e5e9faf6589"],["8481bde0e4e4d885b3a546d3e549de042f0aa6cea250e7fd358d6c86dd45e458","38ee7b8cba5404dd84a25bf39cecb2ca900a79c42b262e556d64b1b59779057e"],["13464a57a78102aa62b6979ae817f4637ffcfed3c4b1ce30bcd6303f6caf666b","69be159004614580ef7e433453ccb0ca48f300a81d0942e13f495a907f6ecc27"],["bc4a9df5b713fe2e9aef430bcc1dc97a0cd9ccede2f28588cada3a0d2d83f366","d3a81ca6e785c06383937adf4b798caa6e8a9fbfa547b16d758d666581f33c1"],["8c28a97bf8298bc0d23d8c749452a32e694b65e30a9472a3954ab30fe5324caa","40a30463a3305193378fedf31f7cc0eb7ae784f0451cb9459e71dc73cbef9482"],["8ea9666139527a8c1dd94ce4f071fd23c8b350c5a4bb33748c4ba111faccae0","620efabbc8ee2782e24e7c0cfb95c5d735b783be9cf0f8e955af34a30e62b945"],["dd3625faef5ba06074669716bbd3788d89bdde815959968092f76cc4eb9a9787","7a188fa3520e30d461da2501045731ca941461982883395937f68d00c644a573"],["f710d79d9eb962297e4f6232b40e8f7feb2bc63814614d692c12de752408221e","ea98e67232d3b3295d3b535532115ccac8612c721851617526ae47a9c77bfc82"]]},naf:{wnd:7,points:[["f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9","388f7b0f632de8140fe337e62a37f3566500a99934c2231b6cb9fd7584b8e672"],["2f8bde4d1a07209355b4a7250a5c5128e88b84bddc619ab7cba8d569b240efe4","d8ac222636e5e3d6d4dba9dda6c9c426f788271bab0d6840dca87d3aa6ac62d6"],["5cbdf0646e5db4eaa398f365f2ea7a0e3d419b7e0330e39ce92bddedcac4f9bc","6aebca40ba255960a3178d6d861a54dba813d0b813fde7b5a5082628087264da"],["acd484e2f0c7f65309ad178a9f559abde09796974c57e714c35f110dfc27ccbe","cc338921b0a7d9fd64380971763b61e9add888a4375f8e0f05cc262ac64f9c37"],["774ae7f858a9411e5ef4246b70c65aac5649980be5c17891bbec17895da008cb","d984a032eb6b5e190243dd56d7b7b365372db1e2dff9d6a8301d74c9c953c61b"],["f28773c2d975288bc7d1d205c3748651b075fbc6610e58cddeeddf8f19405aa8","ab0902e8d880a89758212eb65cdaf473a1a06da521fa91f29b5cb52db03ed81"],["d7924d4f7d43ea965a465ae3095ff41131e5946f3c85f79e44adbcf8e27e080e","581e2872a86c72a683842ec228cc6defea40af2bd896d3a5c504dc9ff6a26b58"],["defdea4cdb677750a420fee807eacf21eb9898ae79b9768766e4faa04a2d4a34","4211ab0694635168e997b0ead2a93daeced1f4a04a95c0f6cfb199f69e56eb77"],["2b4ea0a797a443d293ef5cff444f4979f06acfebd7e86d277475656138385b6c","85e89bc037945d93b343083b5a1c86131a01f60c50269763b570c854e5c09b7a"],["352bbf4a4cdd12564f93fa332ce333301d9ad40271f8107181340aef25be59d5","321eb4075348f534d59c18259dda3e1f4a1b3b2e71b1039c67bd3d8bcf81998c"],["2fa2104d6b38d11b0230010559879124e42ab8dfeff5ff29dc9cdadd4ecacc3f","2de1068295dd865b64569335bd5dd80181d70ecfc882648423ba76b532b7d67"],["9248279b09b4d68dab21a9b066edda83263c3d84e09572e269ca0cd7f5453714","73016f7bf234aade5d1aa71bdea2b1ff3fc0de2a887912ffe54a32ce97cb3402"],["daed4f2be3a8bf278e70132fb0beb7522f570e144bf615c07e996d443dee8729","a69dce4a7d6c98e8d4a1aca87ef8d7003f83c230f3afa726ab40e52290be1c55"],["c44d12c7065d812e8acf28d7cbb19f9011ecd9e9fdf281b0e6a3b5e87d22e7db","2119a460ce326cdc76c45926c982fdac0e106e861edf61c5a039063f0e0e6482"],["6a245bf6dc698504c89a20cfded60853152b695336c28063b61c65cbd269e6b4","e022cf42c2bd4a708b3f5126f16a24ad8b33ba48d0423b6efd5e6348100d8a82"],["1697ffa6fd9de627c077e3d2fe541084ce13300b0bec1146f95ae57f0d0bd6a5","b9c398f186806f5d27561506e4557433a2cf15009e498ae7adee9d63d01b2396"],["605bdb019981718b986d0f07e834cb0d9deb8360ffb7f61df982345ef27a7479","2972d2de4f8d20681a78d93ec96fe23c26bfae84fb14db43b01e1e9056b8c49"],["62d14dab4150bf497402fdc45a215e10dcb01c354959b10cfe31c7e9d87ff33d","80fc06bd8cc5b01098088a1950eed0db01aa132967ab472235f5642483b25eaf"],["80c60ad0040f27dade5b4b06c408e56b2c50e9f56b9b8b425e555c2f86308b6f","1c38303f1cc5c30f26e66bad7fe72f70a65eed4cbe7024eb1aa01f56430bd57a"],["7a9375ad6167ad54aa74c6348cc54d344cc5dc9487d847049d5eabb0fa03c8fb","d0e3fa9eca8726909559e0d79269046bdc59ea10c70ce2b02d499ec224dc7f7"],["d528ecd9b696b54c907a9ed045447a79bb408ec39b68df504bb51f459bc3ffc9","eecf41253136e5f99966f21881fd656ebc4345405c520dbc063465b521409933"],["49370a4b5f43412ea25f514e8ecdad05266115e4a7ecb1387231808f8b45963","758f3f41afd6ed428b3081b0512fd62a54c3f3afbb5b6764b653052a12949c9a"],["77f230936ee88cbbd73df930d64702ef881d811e0e1498e2f1c13eb1fc345d74","958ef42a7886b6400a08266e9ba1b37896c95330d97077cbbe8eb3c7671c60d6"],["f2dac991cc4ce4b9ea44887e5c7c0bce58c80074ab9d4dbaeb28531b7739f530","e0dedc9b3b2f8dad4da1f32dec2531df9eb5fbeb0598e4fd1a117dba703a3c37"],["463b3d9f662621fb1b4be8fbbe2520125a216cdfc9dae3debcba4850c690d45b","5ed430d78c296c3543114306dd8622d7c622e27c970a1de31cb377b01af7307e"],["f16f804244e46e2a09232d4aff3b59976b98fac14328a2d1a32496b49998f247","cedabd9b82203f7e13d206fcdf4e33d92a6c53c26e5cce26d6579962c4e31df6"],["caf754272dc84563b0352b7a14311af55d245315ace27c65369e15f7151d41d1","cb474660ef35f5f2a41b643fa5e460575f4fa9b7962232a5c32f908318a04476"],["2600ca4b282cb986f85d0f1709979d8b44a09c07cb86d7c124497bc86f082120","4119b88753c15bd6a693b03fcddbb45d5ac6be74ab5f0ef44b0be9475a7e4b40"],["7635ca72d7e8432c338ec53cd12220bc01c48685e24f7dc8c602a7746998e435","91b649609489d613d1d5e590f78e6d74ecfc061d57048bad9e76f302c5b9c61"],["754e3239f325570cdbbf4a87deee8a66b7f2b33479d468fbc1a50743bf56cc18","673fb86e5bda30fb3cd0ed304ea49a023ee33d0197a695d0c5d98093c536683"],["e3e6bd1071a1e96aff57859c82d570f0330800661d1c952f9fe2694691d9b9e8","59c9e0bba394e76f40c0aa58379a3cb6a5a2283993e90c4167002af4920e37f5"],["186b483d056a033826ae73d88f732985c4ccb1f32ba35f4b4cc47fdcf04aa6eb","3b952d32c67cf77e2e17446e204180ab21fb8090895138b4a4a797f86e80888b"],["df9d70a6b9876ce544c98561f4be4f725442e6d2b737d9c91a8321724ce0963f","55eb2dafd84d6ccd5f862b785dc39d4ab157222720ef9da217b8c45cf2ba2417"],["5edd5cc23c51e87a497ca815d5dce0f8ab52554f849ed8995de64c5f34ce7143","efae9c8dbc14130661e8cec030c89ad0c13c66c0d17a2905cdc706ab7399a868"],["290798c2b6476830da12fe02287e9e777aa3fba1c355b17a722d362f84614fba","e38da76dcd440621988d00bcf79af25d5b29c094db2a23146d003afd41943e7a"],["af3c423a95d9f5b3054754efa150ac39cd29552fe360257362dfdecef4053b45","f98a3fd831eb2b749a93b0e6f35cfb40c8cd5aa667a15581bc2feded498fd9c6"],["766dbb24d134e745cccaa28c99bf274906bb66b26dcf98df8d2fed50d884249a","744b1152eacbe5e38dcc887980da38b897584a65fa06cedd2c924f97cbac5996"],["59dbf46f8c94759ba21277c33784f41645f7b44f6c596a58ce92e666191abe3e","c534ad44175fbc300f4ea6ce648309a042ce739a7919798cd85e216c4a307f6e"],["f13ada95103c4537305e691e74e9a4a8dd647e711a95e73cb62dc6018cfd87b8","e13817b44ee14de663bf4bc808341f326949e21a6a75c2570778419bdaf5733d"],["7754b4fa0e8aced06d4167a2c59cca4cda1869c06ebadfb6488550015a88522c","30e93e864e669d82224b967c3020b8fa8d1e4e350b6cbcc537a48b57841163a2"],["948dcadf5990e048aa3874d46abef9d701858f95de8041d2a6828c99e2262519","e491a42537f6e597d5d28a3224b1bc25df9154efbd2ef1d2cbba2cae5347d57e"],["7962414450c76c1689c7b48f8202ec37fb224cf5ac0bfa1570328a8a3d7c77ab","100b610ec4ffb4760d5c1fc133ef6f6b12507a051f04ac5760afa5b29db83437"],["3514087834964b54b15b160644d915485a16977225b8847bb0dd085137ec47ca","ef0afbb2056205448e1652c48e8127fc6039e77c15c2378b7e7d15a0de293311"],["d3cc30ad6b483e4bc79ce2c9dd8bc54993e947eb8df787b442943d3f7b527eaf","8b378a22d827278d89c5e9be8f9508ae3c2ad46290358630afb34db04eede0a4"],["1624d84780732860ce1c78fcbfefe08b2b29823db913f6493975ba0ff4847610","68651cf9b6da903e0914448c6cd9d4ca896878f5282be4c8cc06e2a404078575"],["733ce80da955a8a26902c95633e62a985192474b5af207da6df7b4fd5fc61cd4","f5435a2bd2badf7d485a4d8b8db9fcce3e1ef8e0201e4578c54673bc1dc5ea1d"],["15d9441254945064cf1a1c33bbd3b49f8966c5092171e699ef258dfab81c045c","d56eb30b69463e7234f5137b73b84177434800bacebfc685fc37bbe9efe4070d"],["a1d0fcf2ec9de675b612136e5ce70d271c21417c9d2b8aaaac138599d0717940","edd77f50bcb5a3cab2e90737309667f2641462a54070f3d519212d39c197a629"],["e22fbe15c0af8ccc5780c0735f84dbe9a790badee8245c06c7ca37331cb36980","a855babad5cd60c88b430a69f53a1a7a38289154964799be43d06d77d31da06"],["311091dd9860e8e20ee13473c1155f5f69635e394704eaa74009452246cfa9b3","66db656f87d1f04fffd1f04788c06830871ec5a64feee685bd80f0b1286d8374"],["34c1fd04d301be89b31c0442d3e6ac24883928b45a9340781867d4232ec2dbdf","9414685e97b1b5954bd46f730174136d57f1ceeb487443dc5321857ba73abee"],["f219ea5d6b54701c1c14de5b557eb42a8d13f3abbcd08affcc2a5e6b049b8d63","4cb95957e83d40b0f73af4544cccf6b1f4b08d3c07b27fb8d8c2962a400766d1"],["d7b8740f74a8fbaab1f683db8f45de26543a5490bca627087236912469a0b448","fa77968128d9c92ee1010f337ad4717eff15db5ed3c049b3411e0315eaa4593b"],["32d31c222f8f6f0ef86f7c98d3a3335ead5bcd32abdd94289fe4d3091aa824bf","5f3032f5892156e39ccd3d7915b9e1da2e6dac9e6f26e961118d14b8462e1661"],["7461f371914ab32671045a155d9831ea8793d77cd59592c4340f86cbc18347b5","8ec0ba238b96bec0cbdddcae0aa442542eee1ff50c986ea6b39847b3cc092ff6"],["ee079adb1df1860074356a25aa38206a6d716b2c3e67453d287698bad7b2b2d6","8dc2412aafe3be5c4c5f37e0ecc5f9f6a446989af04c4e25ebaac479ec1c8c1e"],["16ec93e447ec83f0467b18302ee620f7e65de331874c9dc72bfd8616ba9da6b5","5e4631150e62fb40d0e8c2a7ca5804a39d58186a50e497139626778e25b0674d"],["eaa5f980c245f6f038978290afa70b6bd8855897f98b6aa485b96065d537bd99","f65f5d3e292c2e0819a528391c994624d784869d7e6ea67fb18041024edc07dc"],["78c9407544ac132692ee1910a02439958ae04877151342ea96c4b6b35a49f51","f3e0319169eb9b85d5404795539a5e68fa1fbd583c064d2462b675f194a3ddb4"],["494f4be219a1a77016dcd838431aea0001cdc8ae7a6fc688726578d9702857a5","42242a969283a5f339ba7f075e36ba2af925ce30d767ed6e55f4b031880d562c"],["a598a8030da6d86c6bc7f2f5144ea549d28211ea58faa70ebf4c1e665c1fe9b5","204b5d6f84822c307e4b4a7140737aec23fc63b65b35f86a10026dbd2d864e6b"],["c41916365abb2b5d09192f5f2dbeafec208f020f12570a184dbadc3e58595997","4f14351d0087efa49d245b328984989d5caf9450f34bfc0ed16e96b58fa9913"],["841d6063a586fa475a724604da03bc5b92a2e0d2e0a36acfe4c73a5514742881","73867f59c0659e81904f9a1c7543698e62562d6744c169ce7a36de01a8d6154"],["5e95bb399a6971d376026947f89bde2f282b33810928be4ded112ac4d70e20d5","39f23f366809085beebfc71181313775a99c9aed7d8ba38b161384c746012865"],["36e4641a53948fd476c39f8a99fd974e5ec07564b5315d8bf99471bca0ef2f66","d2424b1b1abe4eb8164227b085c9aa9456ea13493fd563e06fd51cf5694c78fc"],["336581ea7bfbbb290c191a2f507a41cf5643842170e914faeab27c2c579f726","ead12168595fe1be99252129b6e56b3391f7ab1410cd1e0ef3dcdcabd2fda224"],["8ab89816dadfd6b6a1f2634fcf00ec8403781025ed6890c4849742706bd43ede","6fdcef09f2f6d0a044e654aef624136f503d459c3e89845858a47a9129cdd24e"],["1e33f1a746c9c5778133344d9299fcaa20b0938e8acff2544bb40284b8c5fb94","60660257dd11b3aa9c8ed618d24edff2306d320f1d03010e33a7d2057f3b3b6"],["85b7c1dcb3cec1b7ee7f30ded79dd20a0ed1f4cc18cbcfcfa410361fd8f08f31","3d98a9cdd026dd43f39048f25a8847f4fcafad1895d7a633c6fed3c35e999511"],["29df9fbd8d9e46509275f4b125d6d45d7fbe9a3b878a7af872a2800661ac5f51","b4c4fe99c775a606e2d8862179139ffda61dc861c019e55cd2876eb2a27d84b"],["a0b1cae06b0a847a3fea6e671aaf8adfdfe58ca2f768105c8082b2e449fce252","ae434102edde0958ec4b19d917a6a28e6b72da1834aff0e650f049503a296cf2"],["4e8ceafb9b3e9a136dc7ff67e840295b499dfb3b2133e4ba113f2e4c0e121e5","cf2174118c8b6d7a4b48f6d534ce5c79422c086a63460502b827ce62a326683c"],["d24a44e047e19b6f5afb81c7ca2f69080a5076689a010919f42725c2b789a33b","6fb8d5591b466f8fc63db50f1c0f1c69013f996887b8244d2cdec417afea8fa3"],["ea01606a7a6c9cdd249fdfcfacb99584001edd28abbab77b5104e98e8e3b35d4","322af4908c7312b0cfbfe369f7a7b3cdb7d4494bc2823700cfd652188a3ea98d"],["af8addbf2b661c8a6c6328655eb96651252007d8c5ea31be4ad196de8ce2131f","6749e67c029b85f52a034eafd096836b2520818680e26ac8f3dfbcdb71749700"],["e3ae1974566ca06cc516d47e0fb165a674a3dabcfca15e722f0e3450f45889","2aeabe7e4531510116217f07bf4d07300de97e4874f81f533420a72eeb0bd6a4"],["591ee355313d99721cf6993ffed1e3e301993ff3ed258802075ea8ced397e246","b0ea558a113c30bea60fc4775460c7901ff0b053d25ca2bdeee98f1a4be5d196"],["11396d55fda54c49f19aa97318d8da61fa8584e47b084945077cf03255b52984","998c74a8cd45ac01289d5833a7beb4744ff536b01b257be4c5767bea93ea57a4"],["3c5d2a1ba39c5a1790000738c9e0c40b8dcdfd5468754b6405540157e017aa7a","b2284279995a34e2f9d4de7396fc18b80f9b8b9fdd270f6661f79ca4c81bd257"],["cc8704b8a60a0defa3a99a7299f2e9c3fbc395afb04ac078425ef8a1793cc030","bdd46039feed17881d1e0862db347f8cf395b74fc4bcdc4e940b74e3ac1f1b13"],["c533e4f7ea8555aacd9777ac5cad29b97dd4defccc53ee7ea204119b2889b197","6f0a256bc5efdf429a2fb6242f1a43a2d9b925bb4a4b3a26bb8e0f45eb596096"],["c14f8f2ccb27d6f109f6d08d03cc96a69ba8c34eec07bbcf566d48e33da6593","c359d6923bb398f7fd4473e16fe1c28475b740dd098075e6c0e8649113dc3a38"],["a6cbc3046bc6a450bac24789fa17115a4c9739ed75f8f21ce441f72e0b90e6ef","21ae7f4680e889bb130619e2c0f95a360ceb573c70603139862afd617fa9b9f"],["347d6d9a02c48927ebfb86c1359b1caf130a3c0267d11ce6344b39f99d43cc38","60ea7f61a353524d1c987f6ecec92f086d565ab687870cb12689ff1e31c74448"],["da6545d2181db8d983f7dcb375ef5866d47c67b1bf31c8cf855ef7437b72656a","49b96715ab6878a79e78f07ce5680c5d6673051b4935bd897fea824b77dc208a"],["c40747cc9d012cb1a13b8148309c6de7ec25d6945d657146b9d5994b8feb1111","5ca560753be2a12fc6de6caf2cb489565db936156b9514e1bb5e83037e0fa2d4"],["4e42c8ec82c99798ccf3a610be870e78338c7f713348bd34c8203ef4037f3502","7571d74ee5e0fb92a7a8b33a07783341a5492144cc54bcc40a94473693606437"],["3775ab7089bc6af823aba2e1af70b236d251cadb0c86743287522a1b3b0dedea","be52d107bcfa09d8bcb9736a828cfa7fac8db17bf7a76a2c42ad961409018cf7"],["cee31cbf7e34ec379d94fb814d3d775ad954595d1314ba8846959e3e82f74e26","8fd64a14c06b589c26b947ae2bcf6bfa0149ef0be14ed4d80f448a01c43b1c6d"],["b4f9eaea09b6917619f6ea6a4eb5464efddb58fd45b1ebefcdc1a01d08b47986","39e5c9925b5a54b07433a4f18c61726f8bb131c012ca542eb24a8ac07200682a"],["d4263dfc3d2df923a0179a48966d30ce84e2515afc3dccc1b77907792ebcc60e","62dfaf07a0f78feb30e30d6295853ce189e127760ad6cf7fae164e122a208d54"],["48457524820fa65a4f8d35eb6930857c0032acc0a4a2de422233eeda897612c4","25a748ab367979d98733c38a1fa1c2e7dc6cc07db2d60a9ae7a76aaa49bd0f77"],["dfeeef1881101f2cb11644f3a2afdfc2045e19919152923f367a1767c11cceda","ecfb7056cf1de042f9420bab396793c0c390bde74b4bbdff16a83ae09a9a7517"],["6d7ef6b17543f8373c573f44e1f389835d89bcbc6062ced36c82df83b8fae859","cd450ec335438986dfefa10c57fea9bcc521a0959b2d80bbf74b190dca712d10"],["e75605d59102a5a2684500d3b991f2e3f3c88b93225547035af25af66e04541f","f5c54754a8f71ee540b9b48728473e314f729ac5308b06938360990e2bfad125"],["eb98660f4c4dfaa06a2be453d5020bc99a0c2e60abe388457dd43fefb1ed620c","6cb9a8876d9cb8520609af3add26cd20a0a7cd8a9411131ce85f44100099223e"],["13e87b027d8514d35939f2e6892b19922154596941888336dc3563e3b8dba942","fef5a3c68059a6dec5d624114bf1e91aac2b9da568d6abeb2570d55646b8adf1"],["ee163026e9fd6fe017c38f06a5be6fc125424b371ce2708e7bf4491691e5764a","1acb250f255dd61c43d94ccc670d0f58f49ae3fa15b96623e5430da0ad6c62b2"],["b268f5ef9ad51e4d78de3a750c2dc89b1e626d43505867999932e5db33af3d80","5f310d4b3c99b9ebb19f77d41c1dee018cf0d34fd4191614003e945a1216e423"],["ff07f3118a9df035e9fad85eb6c7bfe42b02f01ca99ceea3bf7ffdba93c4750d","438136d603e858a3a5c440c38eccbaddc1d2942114e2eddd4740d098ced1f0d8"],["8d8b9855c7c052a34146fd20ffb658bea4b9f69e0d825ebec16e8c3ce2b526a1","cdb559eedc2d79f926baf44fb84ea4d44bcf50fee51d7ceb30e2e7f463036758"],["52db0b5384dfbf05bfa9d472d7ae26dfe4b851ceca91b1eba54263180da32b63","c3b997d050ee5d423ebaf66a6db9f57b3180c902875679de924b69d84a7b375"],["e62f9490d3d51da6395efd24e80919cc7d0f29c3f3fa48c6fff543becbd43352","6d89ad7ba4876b0b22c2ca280c682862f342c8591f1daf5170e07bfd9ccafa7d"],["7f30ea2476b399b4957509c88f77d0191afa2ff5cb7b14fd6d8e7d65aaab1193","ca5ef7d4b231c94c3b15389a5f6311e9daff7bb67b103e9880ef4bff637acaec"],["5098ff1e1d9f14fb46a210fada6c903fef0fb7b4a1dd1d9ac60a0361800b7a00","9731141d81fc8f8084d37c6e7542006b3ee1b40d60dfe5362a5b132fd17ddc0"],["32b78c7de9ee512a72895be6b9cbefa6e2f3c4ccce445c96b9f2c81e2778ad58","ee1849f513df71e32efc3896ee28260c73bb80547ae2275ba497237794c8753c"],["e2cb74fddc8e9fbcd076eef2a7c72b0ce37d50f08269dfc074b581550547a4f7","d3aa2ed71c9dd2247a62df062736eb0baddea9e36122d2be8641abcb005cc4a4"],["8438447566d4d7bedadc299496ab357426009a35f235cb141be0d99cd10ae3a8","c4e1020916980a4da5d01ac5e6ad330734ef0d7906631c4f2390426b2edd791f"],["4162d488b89402039b584c6fc6c308870587d9c46f660b878ab65c82c711d67e","67163e903236289f776f22c25fb8a3afc1732f2b84b4e95dbda47ae5a0852649"],["3fad3fa84caf0f34f0f89bfd2dcf54fc175d767aec3e50684f3ba4a4bf5f683d","cd1bc7cb6cc407bb2f0ca647c718a730cf71872e7d0d2a53fa20efcdfe61826"],["674f2600a3007a00568c1a7ce05d0816c1fb84bf1370798f1c69532faeb1a86b","299d21f9413f33b3edf43b257004580b70db57da0b182259e09eecc69e0d38a5"],["d32f4da54ade74abb81b815ad1fb3b263d82d6c692714bcff87d29bd5ee9f08f","f9429e738b8e53b968e99016c059707782e14f4535359d582fc416910b3eea87"],["30e4e670435385556e593657135845d36fbb6931f72b08cb1ed954f1e3ce3ff6","462f9bce619898638499350113bbc9b10a878d35da70740dc695a559eb88db7b"],["be2062003c51cc3004682904330e4dee7f3dcd10b01e580bf1971b04d4cad297","62188bc49d61e5428573d48a74e1c655b1c61090905682a0d5558ed72dccb9bc"],["93144423ace3451ed29e0fb9ac2af211cb6e84a601df5993c419859fff5df04a","7c10dfb164c3425f5c71a3f9d7992038f1065224f72bb9d1d902a6d13037b47c"],["b015f8044f5fcbdcf21ca26d6c34fb8197829205c7b7d2a7cb66418c157b112c","ab8c1e086d04e813744a655b2df8d5f83b3cdc6faa3088c1d3aea1454e3a1d5f"],["d5e9e1da649d97d89e4868117a465a3a4f8a18de57a140d36b3f2af341a21b52","4cb04437f391ed73111a13cc1d4dd0db1693465c2240480d8955e8592f27447a"],["d3ae41047dd7ca065dbf8ed77b992439983005cd72e16d6f996a5316d36966bb","bd1aeb21ad22ebb22a10f0303417c6d964f8cdd7df0aca614b10dc14d125ac46"],["463e2763d885f958fc66cdd22800f0a487197d0a82e377b49f80af87c897b065","bfefacdb0e5d0fd7df3a311a94de062b26b80c61fbc97508b79992671ef7ca7f"],["7985fdfd127c0567c6f53ec1bb63ec3158e597c40bfe747c83cddfc910641917","603c12daf3d9862ef2b25fe1de289aed24ed291e0ec6708703a5bd567f32ed03"],["74a1ad6b5f76e39db2dd249410eac7f99e74c59cb83d2d0ed5ff1543da7703e9","cc6157ef18c9c63cd6193d83631bbea0093e0968942e8c33d5737fd790e0db08"],["30682a50703375f602d416664ba19b7fc9bab42c72747463a71d0896b22f6da3","553e04f6b018b4fa6c8f39e7f311d3176290d0e0f19ca73f17714d9977a22ff8"],["9e2158f0d7c0d5f26c3791efefa79597654e7a2b2464f52b1ee6c1347769ef57","712fcdd1b9053f09003a3481fa7762e9ffd7c8ef35a38509e2fbf2629008373"],["176e26989a43c9cfeba4029c202538c28172e566e3c4fce7322857f3be327d66","ed8cc9d04b29eb877d270b4878dc43c19aefd31f4eee09ee7b47834c1fa4b1c3"],["75d46efea3771e6e68abb89a13ad747ecf1892393dfc4f1b7004788c50374da8","9852390a99507679fd0b86fd2b39a868d7efc22151346e1a3ca4726586a6bed8"],["809a20c67d64900ffb698c4c825f6d5f2310fb0451c869345b7319f645605721","9e994980d9917e22b76b061927fa04143d096ccc54963e6a5ebfa5f3f8e286c1"],["1b38903a43f7f114ed4500b4eac7083fdefece1cf29c63528d563446f972c180","4036edc931a60ae889353f77fd53de4a2708b26b6f5da72ad3394119daf408f9"]]}}},4367:function(e,t){"use strict";var n=t;function r(e){return 1===e.length?"0"+e:e}function o(e){for(var t="",n=0;n<e.length;n++)t+=r(e[n].toString(16));return t}n.toArray=function(e,t){if(Array.isArray(e))return e.slice();if(!e)return[];var n=[];if("string"!=typeof e){for(var r=0;r<e.length;r++)n[r]=0|e[r];return n}if("hex"===t){(e=e.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(e="0"+e);for(r=0;r<e.length;r+=2)n.push(parseInt(e[r]+e[r+1],16))}else for(r=0;r<e.length;r++){var o=e.charCodeAt(r),i=o>>8,a=255&o;i?n.push(i,a):n.push(a)}return n},n.zero2=r,n.toHex=o,n.encode=function(e,t){return"hex"===t?o(e):e}},4945:function(e,t){var n="undefined"!=typeof self?self:this,r=function(){function e(){this.fetch=!1,this.DOMException=n.DOMException}return e.prototype=n,new e}();!function(e){!function(t){var n="URLSearchParams"in e,r="Symbol"in e&&"iterator"in Symbol,o="FileReader"in e&&"Blob"in e&&function(){try{return new Blob,!0}catch(e){return!1}}(),i="FormData"in e,a="ArrayBuffer"in e;if(a)var s=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],c=ArrayBuffer.isView||function(e){return e&&s.indexOf(Object.prototype.toString.call(e))>-1};function u(e){if("string"!=typeof e&&(e=String(e)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(e))throw new TypeError("Invalid character in header field name");return e.toLowerCase()}function l(e){return"string"!=typeof e&&(e=String(e)),e}function d(e){var t={next:function(){var t=e.shift();return{done:void 0===t,value:t}}};return r&&(t[Symbol.iterator]=function(){return t}),t}function f(e){this.map={},e instanceof f?e.forEach(function(e,t){this.append(t,e)},this):Array.isArray(e)?e.forEach(function(e){this.append(e[0],e[1])},this):e&&Object.getOwnPropertyNames(e).forEach(function(t){this.append(t,e[t])},this)}function p(e){if(e.bodyUsed)return Promise.reject(new TypeError("Already read"));e.bodyUsed=!0}function h(e){return new Promise(function(t,n){e.onload=function(){t(e.result)},e.onerror=function(){n(e.error)}})}function y(e){var t=new FileReader,n=h(t);return t.readAsArrayBuffer(e),n}function b(e){if(e.slice)return e.slice(0);var t=new Uint8Array(e.byteLength);return t.set(new Uint8Array(e)),t.buffer}function g(){return this.bodyUsed=!1,this._initBody=function(e){var t;this._bodyInit=e,e?"string"==typeof e?this._bodyText=e:o&&Blob.prototype.isPrototypeOf(e)?this._bodyBlob=e:i&&FormData.prototype.isPrototypeOf(e)?this._bodyFormData=e:n&&URLSearchParams.prototype.isPrototypeOf(e)?this._bodyText=e.toString():a&&o&&((t=e)&&DataView.prototype.isPrototypeOf(t))?(this._bodyArrayBuffer=b(e.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):a&&(ArrayBuffer.prototype.isPrototypeOf(e)||c(e))?this._bodyArrayBuffer=b(e):this._bodyText=e=Object.prototype.toString.call(e):this._bodyText="",this.headers.get("content-type")||("string"==typeof e?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):n&&URLSearchParams.prototype.isPrototypeOf(e)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},o&&(this.blob=function(){var e=p(this);if(e)return e;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?p(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(y)}),this.text=function(){var e,t,n,r=p(this);if(r)return r;if(this._bodyBlob)return e=this._bodyBlob,t=new FileReader,n=h(t),t.readAsText(e),n;if(this._bodyArrayBuffer)return Promise.resolve(function(e){for(var t=new Uint8Array(e),n=new Array(t.length),r=0;r<t.length;r++)n[r]=String.fromCharCode(t[r]);return n.join("")}(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},i&&(this.formData=function(){return this.text().then(m)}),this.json=function(){return this.text().then(JSON.parse)},this}f.prototype.append=function(e,t){e=u(e),t=l(t);var n=this.map[e];this.map[e]=n?n+", "+t:t},f.prototype.delete=function(e){delete this.map[u(e)]},f.prototype.get=function(e){return e=u(e),this.has(e)?this.map[e]:null},f.prototype.has=function(e){return this.map.hasOwnProperty(u(e))},f.prototype.set=function(e,t){this.map[u(e)]=l(t)},f.prototype.forEach=function(e,t){for(var n in this.map)this.map.hasOwnProperty(n)&&e.call(t,this.map[n],n,this)},f.prototype.keys=function(){var e=[];return this.forEach(function(t,n){e.push(n)}),d(e)},f.prototype.values=function(){var e=[];return this.forEach(function(t){e.push(t)}),d(e)},f.prototype.entries=function(){var e=[];return this.forEach(function(t,n){e.push([n,t])}),d(e)},r&&(f.prototype[Symbol.iterator]=f.prototype.entries);var w=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function v(e,t){var n,r,o=(t=t||{}).body;if(e instanceof v){if(e.bodyUsed)throw new TypeError("Already read");this.url=e.url,this.credentials=e.credentials,t.headers||(this.headers=new f(e.headers)),this.method=e.method,this.mode=e.mode,this.signal=e.signal,o||null==e._bodyInit||(o=e._bodyInit,e.bodyUsed=!0)}else this.url=String(e);if(this.credentials=t.credentials||this.credentials||"same-origin",!t.headers&&this.headers||(this.headers=new f(t.headers)),this.method=(n=t.method||this.method||"GET",r=n.toUpperCase(),w.indexOf(r)>-1?r:n),this.mode=t.mode||this.mode||null,this.signal=t.signal||this.signal,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&o)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(o)}function m(e){var t=new FormData;return e.trim().split("&").forEach(function(e){if(e){var n=e.split("="),r=n.shift().replace(/\+/g," "),o=n.join("=").replace(/\+/g," ");t.append(decodeURIComponent(r),decodeURIComponent(o))}}),t}function I(e,t){t||(t={}),this.type="default",this.status=void 0===t.status?200:t.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in t?t.statusText:"OK",this.headers=new f(t.headers),this.url=t.url||"",this._initBody(e)}v.prototype.clone=function(){return new v(this,{body:this._bodyInit})},g.call(v.prototype),g.call(I.prototype),I.prototype.clone=function(){return new I(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new f(this.headers),url:this.url})},I.error=function(){var e=new I(null,{status:0,statusText:""});return e.type="error",e};var E=[301,302,303,307,308];I.redirect=function(e,t){if(-1===E.indexOf(t))throw new RangeError("Invalid status code");return new I(null,{status:t,headers:{location:e}})},t.DOMException=e.DOMException;try{new t.DOMException}catch(O){t.DOMException=function(e,t){this.message=e,this.name=t;var n=Error(e);this.stack=n.stack},t.DOMException.prototype=Object.create(Error.prototype),t.DOMException.prototype.constructor=t.DOMException}function S(e,n){return new Promise(function(r,i){var a=new v(e,n);if(a.signal&&a.signal.aborted)return i(new t.DOMException("Aborted","AbortError"));var s=new XMLHttpRequest;function c(){s.abort()}s.onload=function(){var e,t,n={status:s.status,statusText:s.statusText,headers:(e=s.getAllResponseHeaders()||"",t=new f,e.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach(function(e){var n=e.split(":"),r=n.shift().trim();if(r){var o=n.join(":").trim();t.append(r,o)}}),t)};n.url="responseURL"in s?s.responseURL:n.headers.get("X-Request-URL");var o="response"in s?s.response:s.responseText;r(new I(o,n))},s.onerror=function(){i(new TypeError("Network request failed"))},s.ontimeout=function(){i(new TypeError("Network request failed"))},s.onabort=function(){i(new t.DOMException("Aborted","AbortError"))},s.open(a.method,a.url,!0),"include"===a.credentials?s.withCredentials=!0:"omit"===a.credentials&&(s.withCredentials=!1),"responseType"in s&&o&&(s.responseType="blob"),a.headers.forEach(function(e,t){s.setRequestHeader(t,e)}),a.signal&&(a.signal.addEventListener("abort",c),s.onreadystatechange=function(){4===s.readyState&&a.signal.removeEventListener("abort",c)}),s.send(void 0===a._bodyInit?null:a._bodyInit)})}S.polyfill=!0,e.fetch||(e.fetch=S,e.Headers=f,e.Request=v,e.Response=I),t.Headers=f,t.Request=v,t.Response=I,t.fetch=S,Object.defineProperty(t,"__esModule",{value:!0})}({})}(r),r.fetch.ponyfill=!0,delete r.fetch.polyfill;var o=r;(t=o.fetch).default=o.fetch,t.fetch=o.fetch,t.Headers=o.Headers,t.Request=o.Request,t.Response=o.Response,e.exports=t},5037:function(e,t,n){var r;function o(e){this.rand=e}if(e.exports=function(e){return r||(r=new o(null)),r.generate(e)},e.exports.Rand=o,o.prototype.generate=function(e){return this._rand(e)},o.prototype._rand=function(e){if(this.rand.getBytes)return this.rand.getBytes(e);for(var t=new Uint8Array(e),n=0;n<t.length;n++)t[n]=this.rand.getByte();return t},"object"==typeof self)self.crypto&&self.crypto.getRandomValues?o.prototype._rand=function(e){var t=new Uint8Array(e);return self.crypto.getRandomValues(t),t}:self.msCrypto&&self.msCrypto.getRandomValues?o.prototype._rand=function(e){var t=new Uint8Array(e);return self.msCrypto.getRandomValues(t),t}:"object"==typeof window&&(o.prototype._rand=function(){throw new Error("Not implemented yet")});else try{var i=n(1395);if("function"!=typeof i.randomBytes)throw new Error("Not supported");o.prototype._rand=function(e){return i.randomBytes(e)}}catch(a){}},5364:function(e){"use strict";e.exports=function(e){if(e.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),n=0;n<t.length;n++)t[n]=255;for(var r=0;r<e.length;r++){var o=e.charAt(r),i=o.charCodeAt(0);if(255!==t[i])throw new TypeError(o+" is ambiguous");t[i]=r}var a=e.length,s=e.charAt(0),c=Math.log(a)/Math.log(256),u=Math.log(256)/Math.log(a);function l(e){if("string"!=typeof e)throw new TypeError("Expected String");if(0===e.length)return new Uint8Array;for(var n=0,r=0,o=0;e[n]===s;)r++,n++;for(var i=(e.length-n)*c+1>>>0,u=new Uint8Array(i);e[n];){var l=e.charCodeAt(n);if(l>255)return;var d=t[l];if(255===d)return;for(var f=0,p=i-1;(0!==d||f<o)&&-1!==p;p--,f++)d+=a*u[p]>>>0,u[p]=d%256>>>0,d=d/256>>>0;if(0!==d)throw new Error("Non-zero carry");o=f,n++}for(var h=i-o;h!==i&&0===u[h];)h++;for(var y=new Uint8Array(r+(i-h)),b=r;h!==i;)y[b++]=u[h++];return y}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 n=0,r=0,o=0,i=t.length;o!==i&&0===t[o];)o++,n++;for(var c=(i-o)*u+1>>>0,l=new Uint8Array(c);o!==i;){for(var d=t[o],f=0,p=c-1;(0!==d||f<r)&&-1!==p;p--,f++)d+=256*l[p]>>>0,l[p]=d%a>>>0,d=d/a>>>0;if(0!==d)throw new Error("Non-zero carry");r=f,o++}for(var h=c-r;h!==c&&0===l[h];)h++;for(var y=s.repeat(n);h<c;++h)y+=e.charAt(l[h]);return y},decodeUnsafe:l,decode:function(e){var t=l(e);if(t)return t;throw new Error("Non-base"+a+" character")}}}},5817:function(e,t,n){var r=n(6341),o=n(726),i=n(5949);t.ai=function(e){return r(i,function(t){return t.number===String(e)})}},5949:function(e){e.exports=[{code:"AED",number:"784",digits:2,currency:"UAE Dirham",countries:["United Arab Emirates (The)"]},{code:"AFN",number:"971",digits:2,currency:"Afghani",countries:["Afghanistan"]},{code:"ALL",number:"008",digits:2,currency:"Lek",countries:["Albania"]},{code:"AMD",number:"051",digits:2,currency:"Armenian Dram",countries:["Armenia"]},{code:"ANG",number:"532",digits:2,currency:"Netherlands Antillean Guilder",countries:["CuraçAo","Sint Maarten (Dutch Part)"]},{code:"AOA",number:"973",digits:2,currency:"Kwanza",countries:["Angola"]},{code:"ARS",number:"032",digits:2,currency:"Argentine Peso",countries:["Argentina"]},{code:"AUD",number:"036",digits:2,currency:"Australian Dollar",countries:["Australia","Christmas Island","Cocos (Keeling) Islands (The)","Heard Island And Mcdonald Islands","Kiribati","Nauru","Norfolk Island","Tuvalu"]},{code:"AWG",number:"533",digits:2,currency:"Aruban Florin",countries:["Aruba"]},{code:"AZN",number:"944",digits:2,currency:"Azerbaijan Manat",countries:["Azerbaijan"]},{code:"BAM",number:"977",digits:2,currency:"Convertible Mark",countries:["Bosnia And Herzegovina"]},{code:"BBD",number:"052",digits:2,currency:"Barbados Dollar",countries:["Barbados"]},{code:"BDT",number:"050",digits:2,currency:"Taka",countries:["Bangladesh"]},{code:"BGN",number:"975",digits:2,currency:"Bulgarian Lev",countries:["Bulgaria"]},{code:"BHD",number:"048",digits:3,currency:"Bahraini Dinar",countries:["Bahrain"]},{code:"BIF",number:"108",digits:0,currency:"Burundi Franc",countries:["Burundi"]},{code:"BMD",number:"060",digits:2,currency:"Bermudian Dollar",countries:["Bermuda"]},{code:"BND",number:"096",digits:2,currency:"Brunei Dollar",countries:["Brunei Darussalam"]},{code:"BOB",number:"068",digits:2,currency:"Boliviano",countries:["Bolivia (Plurinational State Of)"]},{code:"BOV",number:"984",digits:2,currency:"Mvdol",countries:["Bolivia (Plurinational State Of)"]},{code:"BRL",number:"986",digits:2,currency:"Brazilian Real",countries:["Brazil"]},{code:"BSD",number:"044",digits:2,currency:"Bahamian Dollar",countries:["Bahamas (The)"]},{code:"BTN",number:"064",digits:2,currency:"Ngultrum",countries:["Bhutan"]},{code:"BWP",number:"072",digits:2,currency:"Pula",countries:["Botswana"]},{code:"BYN",number:"933",digits:2,currency:"Belarusian Ruble",countries:["Belarus"]},{code:"BZD",number:"084",digits:2,currency:"Belize Dollar",countries:["Belize"]},{code:"CAD",number:"124",digits:2,currency:"Canadian Dollar",countries:["Canada"]},{code:"CDF",number:"976",digits:2,currency:"Congolese Franc",countries:["Congo (The Democratic Republic Of The)"]},{code:"CHE",number:"947",digits:2,currency:"WIR Euro",countries:["Switzerland"]},{code:"CHF",number:"756",digits:2,currency:"Swiss Franc",countries:["Liechtenstein","Switzerland"]},{code:"CHW",number:"948",digits:2,currency:"WIR Franc",countries:["Switzerland"]},{code:"CLF",number:"990",digits:4,currency:"Unidad de Fomento",countries:["Chile"]},{code:"CLP",number:"152",digits:0,currency:"Chilean Peso",countries:["Chile"]},{code:"CNY",number:"156",digits:2,currency:"Yuan Renminbi",countries:["China"]},{code:"COP",number:"170",digits:2,currency:"Colombian Peso",countries:["Colombia"]},{code:"COU",number:"970",digits:2,currency:"Unidad de Valor Real",countries:["Colombia"]},{code:"CRC",number:"188",digits:2,currency:"Costa Rican Colon",countries:["Costa Rica"]},{code:"CUC",number:"931",digits:2,currency:"Peso Convertible",countries:["Cuba"]},{code:"CUP",number:"192",digits:2,currency:"Cuban Peso",countries:["Cuba"]},{code:"CVE",number:"132",digits:2,currency:"Cabo Verde Escudo",countries:["Cabo Verde"]},{code:"CZK",number:"203",digits:2,currency:"Czech Koruna",countries:["Czechia"]},{code:"DJF",number:"262",digits:0,currency:"Djibouti Franc",countries:["Djibouti"]},{code:"DKK",number:"208",digits:2,currency:"Danish Krone",countries:["Denmark","Faroe Islands (The)","Greenland"]},{code:"DOP",number:"214",digits:2,currency:"Dominican Peso",countries:["Dominican Republic (The)"]},{code:"DZD",number:"012",digits:2,currency:"Algerian Dinar",countries:["Algeria"]},{code:"EGP",number:"818",digits:2,currency:"Egyptian Pound",countries:["Egypt"]},{code:"ERN",number:"232",digits:2,currency:"Nakfa",countries:["Eritrea"]},{code:"ETB",number:"230",digits:2,currency:"Ethiopian Birr",countries:["Ethiopia"]},{code:"EUR",number:"978",digits:2,currency:"Euro",countries:["Andorra","Austria","Belgium","Cyprus","Estonia","European Union","Finland","France","French Guiana","French Southern Territories (The)","Germany","Greece","Guadeloupe","Holy See (The)","Ireland","Italy","Latvia","Lithuania","Luxembourg","Malta","Martinique","Mayotte","Monaco","Montenegro","Netherlands (The)","Portugal","Réunion","Saint Barthélemy","Saint Martin (French Part)","Saint Pierre And Miquelon","San Marino","Slovakia","Slovenia","Spain","Åland Islands"]},{code:"FJD",number:"242",digits:2,currency:"Fiji Dollar",countries:["Fiji"]},{code:"FKP",number:"238",digits:2,currency:"Falkland Islands Pound",countries:["Falkland Islands (The) [Malvinas]"]},{code:"GBP",number:"826",digits:2,currency:"Pound Sterling",countries:["Guernsey","Isle Of Man","Jersey","United Kingdom Of Great Britain And Northern Ireland (The)"]},{code:"GEL",number:"981",digits:2,currency:"Lari",countries:["Georgia"]},{code:"GHS",number:"936",digits:2,currency:"Ghana Cedi",countries:["Ghana"]},{code:"GIP",number:"292",digits:2,currency:"Gibraltar Pound",countries:["Gibraltar"]},{code:"GMD",number:"270",digits:2,currency:"Dalasi",countries:["Gambia (The)"]},{code:"GNF",number:"324",digits:0,currency:"Guinean Franc",countries:["Guinea"]},{code:"GTQ",number:"320",digits:2,currency:"Quetzal",countries:["Guatemala"]},{code:"GYD",number:"328",digits:2,currency:"Guyana Dollar",countries:["Guyana"]},{code:"HKD",number:"344",digits:2,currency:"Hong Kong Dollar",countries:["Hong Kong"]},{code:"HNL",number:"340",digits:2,currency:"Lempira",countries:["Honduras"]},{code:"HRK",number:"191",digits:2,currency:"Kuna",countries:["Croatia"]},{code:"HTG",number:"332",digits:2,currency:"Gourde",countries:["Haiti"]},{code:"HUF",number:"348",digits:2,currency:"Forint",countries:["Hungary"]},{code:"IDR",number:"360",digits:2,currency:"Rupiah",countries:["Indonesia"]},{code:"ILS",number:"376",digits:2,currency:"New Israeli Sheqel",countries:["Israel"]},{code:"INR",number:"356",digits:2,currency:"Indian Rupee",countries:["Bhutan","India"]},{code:"IQD",number:"368",digits:3,currency:"Iraqi Dinar",countries:["Iraq"]},{code:"IRR",number:"364",digits:2,currency:"Iranian Rial",countries:["Iran (Islamic Republic Of)"]},{code:"ISK",number:"352",digits:0,currency:"Iceland Krona",countries:["Iceland"]},{code:"JMD",number:"388",digits:2,currency:"Jamaican Dollar",countries:["Jamaica"]},{code:"JOD",number:"400",digits:3,currency:"Jordanian Dinar",countries:["Jordan"]},{code:"JPY",number:"392",digits:0,currency:"Yen",countries:["Japan"]},{code:"KES",number:"404",digits:2,currency:"Kenyan Shilling",countries:["Kenya"]},{code:"KGS",number:"417",digits:2,currency:"Som",countries:["Kyrgyzstan"]},{code:"KHR",number:"116",digits:2,currency:"Riel",countries:["Cambodia"]},{code:"KMF",number:"174",digits:0,currency:"Comorian Franc ",countries:["Comoros (The)"]},{code:"KPW",number:"408",digits:2,currency:"North Korean Won",countries:["Korea (The Democratic People's Republic Of)"]},{code:"KRW",number:"410",digits:0,currency:"Won",countries:["Korea (The Republic Of)"]},{code:"KWD",number:"414",digits:3,currency:"Kuwaiti Dinar",countries:["Kuwait"]},{code:"KYD",number:"136",digits:2,currency:"Cayman Islands Dollar",countries:["Cayman Islands (The)"]},{code:"KZT",number:"398",digits:2,currency:"Tenge",countries:["Kazakhstan"]},{code:"LAK",number:"418",digits:2,currency:"Lao Kip",countries:["Lao People's Democratic Republic (The)"]},{code:"LBP",number:"422",digits:2,currency:"Lebanese Pound",countries:["Lebanon"]},{code:"LKR",number:"144",digits:2,currency:"Sri Lanka Rupee",countries:["Sri Lanka"]},{code:"LRD",number:"430",digits:2,currency:"Liberian Dollar",countries:["Liberia"]},{code:"LSL",number:"426",digits:2,currency:"Loti",countries:["Lesotho"]},{code:"LYD",number:"434",digits:3,currency:"Libyan Dinar",countries:["Libya"]},{code:"MAD",number:"504",digits:2,currency:"Moroccan Dirham",countries:["Morocco","Western Sahara"]},{code:"MDL",number:"498",digits:2,currency:"Moldovan Leu",countries:["Moldova (The Republic Of)"]},{code:"MGA",number:"969",digits:2,currency:"Malagasy Ariary",countries:["Madagascar"]},{code:"MKD",number:"807",digits:2,currency:"Denar",countries:["Macedonia (The Former Yugoslav Republic Of)"]},{code:"MMK",number:"104",digits:2,currency:"Kyat",countries:["Myanmar"]},{code:"MNT",number:"496",digits:2,currency:"Tugrik",countries:["Mongolia"]},{code:"MOP",number:"446",digits:2,currency:"Pataca",countries:["Macao"]},{code:"MRU",number:"929",digits:2,currency:"Ouguiya",countries:["Mauritania"]},{code:"MUR",number:"480",digits:2,currency:"Mauritius Rupee",countries:["Mauritius"]},{code:"MVR",number:"462",digits:2,currency:"Rufiyaa",countries:["Maldives"]},{code:"MWK",number:"454",digits:2,currency:"Malawi Kwacha",countries:["Malawi"]},{code:"MXN",number:"484",digits:2,currency:"Mexican Peso",countries:["Mexico"]},{code:"MXV",number:"979",digits:2,currency:"Mexican Unidad de Inversion (UDI)",countries:["Mexico"]},{code:"MYR",number:"458",digits:2,currency:"Malaysian Ringgit",countries:["Malaysia"]},{code:"MZN",number:"943",digits:2,currency:"Mozambique Metical",countries:["Mozambique"]},{code:"NAD",number:"516",digits:2,currency:"Namibia Dollar",countries:["Namibia"]},{code:"NGN",number:"566",digits:2,currency:"Naira",countries:["Nigeria"]},{code:"NIO",number:"558",digits:2,currency:"Cordoba Oro",countries:["Nicaragua"]},{code:"NOK",number:"578",digits:2,currency:"Norwegian Krone",countries:["Bouvet Island","Norway","Svalbard And Jan Mayen"]},{code:"NPR",number:"524",digits:2,currency:"Nepalese Rupee",countries:["Nepal"]},{code:"NZD",number:"554",digits:2,currency:"New Zealand Dollar",countries:["Cook Islands (The)","New Zealand","Niue","Pitcairn","Tokelau"]},{code:"OMR",number:"512",digits:3,currency:"Rial Omani",countries:["Oman"]},{code:"PAB",number:"590",digits:2,currency:"Balboa",countries:["Panama"]},{code:"PEN",number:"604",digits:2,currency:"Sol",countries:["Peru"]},{code:"PGK",number:"598",digits:2,currency:"Kina",countries:["Papua New Guinea"]},{code:"PHP",number:"608",digits:2,currency:"Philippine Piso",countries:["Philippines (The)"]},{code:"PKR",number:"586",digits:2,currency:"Pakistan Rupee",countries:["Pakistan"]},{code:"PLN",number:"985",digits:2,currency:"Zloty",countries:["Poland"]},{code:"PYG",number:"600",digits:0,currency:"Guarani",countries:["Paraguay"]},{code:"QAR",number:"634",digits:2,currency:"Qatari Rial",countries:["Qatar"]},{code:"RON",number:"946",digits:2,currency:"Romanian Leu",countries:["Romania"]},{code:"RSD",number:"941",digits:2,currency:"Serbian Dinar",countries:["Serbia"]},{code:"RUB",number:"643",digits:2,currency:"Russian Ruble",countries:["Russian Federation (The)"]},{code:"RWF",number:"646",digits:0,currency:"Rwanda Franc",countries:["Rwanda"]},{code:"SAR",number:"682",digits:2,currency:"Saudi Riyal",countries:["Saudi Arabia"]},{code:"SBD",number:"090",digits:2,currency:"Solomon Islands Dollar",countries:["Solomon Islands"]},{code:"SCR",number:"690",digits:2,currency:"Seychelles Rupee",countries:["Seychelles"]},{code:"SDG",number:"938",digits:2,currency:"Sudanese Pound",countries:["Sudan (The)"]},{code:"SEK",number:"752",digits:2,currency:"Swedish Krona",countries:["Sweden"]},{code:"SGD",number:"702",digits:2,currency:"Singapore Dollar",countries:["Singapore"]},{code:"SHP",number:"654",digits:2,currency:"Saint Helena Pound",countries:["Saint Helena, Ascension And Tristan Da Cunha"]},{code:"SLL",number:"694",digits:2,currency:"Leone",countries:["Sierra Leone"]},{code:"SOS",number:"706",digits:2,currency:"Somali Shilling",countries:["Somalia"]},{code:"SRD",number:"968",digits:2,currency:"Surinam Dollar",countries:["Suriname"]},{code:"SSP",number:"728",digits:2,currency:"South Sudanese Pound",countries:["South Sudan"]},{code:"STN",number:"930",digits:2,currency:"Dobra",countries:["Sao Tome And Principe"]},{code:"SVC",number:"222",digits:2,currency:"El Salvador Colon",countries:["El Salvador"]},{code:"SYP",number:"760",digits:2,currency:"Syrian Pound",countries:["Syrian Arab Republic"]},{code:"SZL",number:"748",digits:2,currency:"Lilangeni",countries:["Swaziland"]},{code:"THB",number:"764",digits:2,currency:"Baht",countries:["Thailand"]},{code:"TJS",number:"972",digits:2,currency:"Somoni",countries:["Tajikistan"]},{code:"TMT",number:"934",digits:2,currency:"Turkmenistan New Manat",countries:["Turkmenistan"]},{code:"TND",number:"788",digits:3,currency:"Tunisian Dinar",countries:["Tunisia"]},{code:"TOP",number:"776",digits:2,currency:"Pa'anga",countries:["Tonga"]},{code:"TRY",number:"949",digits:2,currency:"Turkish Lira",countries:["Turkey"]},{code:"TTD",number:"780",digits:2,currency:"Trinidad and Tobago Dollar",countries:["Trinidad And Tobago"]},{code:"TWD",number:"901",digits:2,currency:"New Taiwan Dollar",countries:["Taiwan (Province Of China)"]},{code:"TZS",number:"834",digits:2,currency:"Tanzanian Shilling",countries:["Tanzania, United Republic Of"]},{code:"UAH",number:"980",digits:2,currency:"Hryvnia",countries:["Ukraine"]},{code:"UGX",number:"800",digits:0,currency:"Uganda Shilling",countries:["Uganda"]},{code:"USD",number:"840",digits:2,currency:"US Dollar",countries:["American Samoa","Bonaire, Sint Eustatius And Saba","British Indian Ocean Territory (The)","Ecuador","El Salvador","Guam","Haiti","Marshall Islands (The)","Micronesia (Federated States Of)","Northern Mariana Islands (The)","Palau","Panama","Puerto Rico","Timor-Leste","Turks And Caicos Islands (The)","United States Minor Outlying Islands (The)","United States Of America (The)","Virgin Islands (British)","Virgin Islands (U.S.)"]},{code:"USN",number:"997",digits:2,currency:"US Dollar (Next day)",countries:["United States Of America (The)"]},{code:"UYI",number:"940",digits:0,currency:"Uruguay Peso en Unidades Indexadas (URUIURUI)",countries:["Uruguay"]},{code:"UYU",number:"858",digits:2,currency:"Peso Uruguayo",countries:["Uruguay"]},{code:"UZS",number:"860",digits:2,currency:"Uzbekistan Sum",countries:["Uzbekistan"]},{code:"VEF",number:"937",digits:2,currency:"Bolívar",countries:["Venezuela (Bolivarian Republic Of)"]},{code:"VND",number:"704",digits:0,currency:"Dong",countries:["Viet Nam"]},{code:"VUV",number:"548",digits:0,currency:"Vatu",countries:["Vanuatu"]},{code:"WST",number:"882",digits:2,currency:"Tala",countries:["Samoa"]},{code:"XAF",number:"950",digits:0,currency:"CFA Franc BEAC",countries:["Cameroon","Central African Republic (The)","Chad","Congo (The)","Equatorial Guinea","Gabon"]},{code:"XAG",number:"961",digits:0,currency:"Silver",countries:[]},{code:"XAU",number:"959",digits:0,currency:"Gold",countries:[]},{code:"XBA",number:"955",digits:0,currency:"Bond Markets Unit European Composite Unit (EURCO)",countries:[]},{code:"XBB",number:"956",digits:0,currency:"Bond Markets Unit European Monetary Unit (E.M.U.-6)",countries:[]},{code:"XBC",number:"957",digits:0,currency:"Bond Markets Unit European Unit of Account 9 (E.U.A.-9)",countries:[]},{code:"XBD",number:"958",digits:0,currency:"Bond Markets Unit European Unit of Account 17 (E.U.A.-17)",countries:[]},{code:"XCD",number:"951",digits:2,currency:"East Caribbean Dollar",countries:["Anguilla","Antigua And Barbuda","Dominica","Grenada","Montserrat","Saint Kitts And Nevis","Saint Lucia","Saint Vincent And The Grenadines"]},{code:"XDR",number:"960",digits:0,currency:"SDR (Special Drawing Right)",countries:["International Monetary Fund (Imf) "]},{code:"XOF",number:"952",digits:0,currency:"CFA Franc BCEAO",countries:["Benin","Burkina Faso","Côte d'Ivoire","Guinea-Bissau","Mali","Niger (The)","Senegal","Togo"]},{code:"XPD",number:"964",digits:0,currency:"Palladium",countries:[]},{code:"XPF",number:"953",digits:0,currency:"CFP Franc",countries:["French Polynesia","New Caledonia","Wallis And Futuna"]},{code:"XPT",number:"962",digits:0,currency:"Platinum",countries:[]},{code:"XSU",number:"994",digits:0,currency:"Sucre",countries:['Sistema Unitario De Compensacion Regional De Pagos "Sucre"']},{code:"XTS",number:"963",digits:0,currency:"Codes specifically reserved for testing purposes",countries:[]},{code:"XUA",number:"965",digits:0,currency:"ADB Unit of Account",countries:["Member Countries Of The African Development Bank Group"]},{code:"XXX",number:"999",digits:0,currency:"The codes assigned for transactions where no currency is involved",countries:[]},{code:"YER",number:"886",digits:2,currency:"Yemeni Rial",countries:["Yemen"]},{code:"ZAR",number:"710",digits:2,currency:"Rand",countries:["Lesotho","Namibia","South Africa"]},{code:"ZMW",number:"967",digits:2,currency:"Zambian Kwacha",countries:["Zambia"]},{code:"ZWL",number:"932",digits:2,currency:"Zimbabwe Dollar",countries:["Zimbabwe"]}]},6001:function(e,t,n){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.log10=t.toFixed=t.toBns=t.round=t.ceil=t.floor=t.max=t.abs=t.min=t.eq=t.gte=t.gt=t.lte=t.lt=t.div=t.sub=t.mul=t.add=void 0;const o=r(n(9404)),i=/^(-?\d*\.?\d*)e((?:\+|-)?\d+)$/;function a(e,t,n=10){if(10!==n&&16!==n)throw new Error("Unsupported base");let{x:r,y:i,shift:a}=h(e,t);const s=y(r)?16:10,c=y(i)?16:10;r=p(r),i=p(i);const u=new o.default(r,s),l=new o.default(i,c);let f=u.add(l).toString(n);return f=d(f,a),10===n?f:f.replace(/^(-)?/,"$10x")}function s(e,t,n=10){if(10!==n&&16!==n)throw new Error("Unsupported base");let{x:r,y:i,shift:a}=h(e,t);const s=y(r)?16:10,c=y(i)?16:10;r=p(r),i=p(i);const u=new o.default(r,s),l=new o.default(i,c);let f=u.mul(l).toString(n);return f=d(f,2*a),10===n?f:f.replace(/^(-)?/,"$10x")}function c(e,t){let{x:n,y:r}=h(e,t);const i=y(n)?16:10,a=y(r)?16:10;n=p(n),r=p(r);const s=new o.default(n,i),c=new o.default(r,a);return s.gt(c)}function u(e,t){let{x:n,y:r}=h(e,t);const i=y(n)?16:10,a=y(r)?16:10;n=p(n),r=p(r);const s=new o.default(n,i),c=new o.default(r,a);return s.gte(c)}function l(e){let t="number"==typeof e?e.toString():e.replace(/^\s+|\s+$/g,"");""!==t&&"."!==t||(t="0");const n=t.match(i);if(null!=n){t=function(e,t){const n=t>=0?"1"+"0".repeat(Math.abs(t)):`0.${"0".repeat(Math.abs(t)-1)}1`;return s(e,n)}(n[1],parseInt(n[2]))}return function(...e){for(const t of e){if(t.split(".").length-1>1)throw new Error(`Invalid number: more than one decimal point '${t}'`);if(t.split("-").length-1>1)throw new Error(`Invalid number: more than one negative sign '${t}'`);if(!/^-?(?:0x[0-9A-Fa-f]+|(?:\d+(?:\.\d*)?|\.\d+))$/.test(t))throw new Error(`Invalid number: non-number characters '${t}'`)}}(t),t}function d(e,t){if(0===t)return e;let n,r=!1;return"-"===e.slice(0,1)&&(r=!0,e=e.slice(1)),n=t>e.length?"0."+f("",t-e.length)+e:e.substr(0,e.length-t)+"."+e.substr(e.length-t,e.length),n=g(n),r&&(n=`-${n}`),n}function f(e,t){let n=e;for(let r=0;r<t;r++)n+="0";return n}function p(e){return e.replace("0x","")}function h(e,t,n){let r=l(e),o=l(t),i=r.indexOf("."),a=o.indexOf(".");const s=y(r),c=y(o);if(-1!==i&&(r=g(r),i=r.indexOf(".")),-1!==a&&(o=g(o),a=o.indexOf(".")),-1!==i||-1!==a||"number"==typeof n){if(s||c)throw new Error("Cannot operate on base16 float values");let e=0,t=0;-1!==i&&(e=r.length-i-1),-1!==a&&(t=o.length-a-1);const u=e>t?e:t;let l=0;"number"==typeof n&&(l=n),r=f(r.replace(".",""),u+l-e),o=f(o.replace(".",""),u-t);return{x:r,y:o,shift:u}}return{x:r,y:o,shift:0}}function y(e){const t=l(e);return!!(t.startsWith("0x")||t.startsWith("-0x")||t.toLowerCase().includes("a")||t.toLowerCase().includes("b")||t.toLowerCase().includes("c")||t.toLowerCase().includes("d")||t.toLowerCase().includes("e")||t.toLowerCase().includes("f"))}function b(e,t,n=0){var r,o;let i=l(t),s=!1,d="";i.includes("-")&&(s=!0,i=i.replace(/^-+/,""));const[f,p=""]=i.split("."),h=i.indexOf("."),y=-1!==h?h-n:i.length-n,b=f+p;if("round"===e){e=u(null!==(r=b[y])&&void 0!==r?r:"0","5")?"ceil":"floor"}const w=Math.max(b.length-y+1,0),v=new Array(w).join("0");let m=b.substring(0,y)+v;const I=c(b.substring(y),"0");if("ceil"===e&&I){const e="1"+v,t=(null!==(o=m.match(/^0+/))&&void 0!==o?o:[""])[0].length;m=new Array(t).join("0")+a(m,e)}const E=h+(m.length-b.length);return d=-1!==h?m.substring(0,E)+"."+m.substring(E):m,d=g(d),s&&"0"!==d&&(d="-"+d),d}function g(e){let t=e.replace(/^0+/,"");return t=t.replace(/^\.+/,"0."),t.includes(".")&&(t=t.replace(/0+$/,""),t=t.replace(/\.+$/,""),""===t&&(t="0")),""===t&&(t="0"),t}t.add=a,t.mul=s,t.sub=function(e,t,n=10){if(10!==n&&16!==n)throw new Error("Unsupported base");let{x:r,y:i,shift:a}=h(e,t);const s=y(r)?16:10,c=y(i)?16:10;r=p(r),i=p(i);const u=new o.default(r,s),l=new o.default(i,c);let f=u.sub(l).toString(n);return f=d(f,a),10===n?f:f.replace(/^(-)?/,"$10x")},t.div=function(e,t,n=0,r=10){if(10!==r&&n>0)throw new Error("Cannot operate on floating point hex values");if(10!==r&&16!==r)throw new Error("Unsupported base");let{x:i,y:a}=h(e,t,n);const s=y(i)?16:10,c=y(a)?16:10;i=p(i),a=p(a);const u=new o.default(i,s),l=new o.default(a,c);let f=u.div(l).toString(r);return f=d(f,n),10===r?f:f.replace(/^(-)?/,"$10x")},t.lt=function(e,t){let{x:n,y:r}=h(e,t);const i=y(n)?16:10,a=y(r)?16:10;n=p(n),r=p(r);const s=new o.default(n,i),c=new o.default(r,a);return s.lt(c)},t.lte=function(e,t){let{x:n,y:r}=h(e,t);const i=y(n)?16:10,a=y(r)?16:10;n=p(n),r=p(r);const s=new o.default(n,i),c=new o.default(r,a);return s.lte(c)},t.gt=c,t.gte=u,t.eq=function(e,t){let{x:n,y:r}=h(e,t);const i=y(n)?16:10,a=y(r)?16:10;n=p(n),r=p(r);const s=new o.default(n,i),c=new o.default(r,a);return s.eq(c)},t.min=function(e,t,n=10){let{x:r,y:i,shift:a}=h(e,t);const s=y(r)?16:10,c=y(i)?16:10;r=p(r),i=p(i);const u=new o.default(r,s),l=new o.default(i,c);let f;return f=u.lte(l)?u.toString(n):l.toString(n),f=d(f,a),10===n?f:f.replace(/^(-)?/,"$10x")},t.abs=function(e,t=10){if(10!==t&&16!==t)throw new Error("Unsupported base");let{x:n,shift:r}=h(e,"0");const i=y(e)?16:10;n=p(n);let a=new o.default(n,i).abs().toString(t);return a=d(a,r),10===t?a:a.replace(/^(-)?/,"$10x")},t.max=function(e,t,n=10){let{x:r,y:i,shift:a}=h(e,t);const s=y(r)?16:10,c=y(i)?16:10;r=p(r),i=p(i);const u=new o.default(r,s),l=new o.default(i,c);let f;return f=u.gte(l)?u.toString(n):l.toString(n),f=d(f,a),10===n?f:f.replace(/^(-)?/,"$10x")},t.floor=(e,t)=>b("floor",e,t),t.ceil=(e,t)=>b("ceil",e,t),t.round=(e,t)=>b("round",e,t),t.toBns=l,t.toFixed=function(e,t=2,n=8){let r=l(e),o=!1,i="";r.includes("-")&&(o=!0,r=r.replace(/^-+/,"")),r=g(r);const a=r.indexOf(".");if(-1===a)i=r+"."+f("",t);else{const e=r.length-a-1;i=e>n?r.substr(0,r.length-(e-n)):e<t?r+f("",t-e):r}return i=i.replace(/\.+$/,""),o&&"0"!==i&&(i="-"+i),i},t.log10=function(e){if(null===e.match(/^[0-1]+$/g))throw new Error("InvalidLogInputValue: Must be a power of 10");if(!e.startsWith("1"))throw new Error("InvalidLogInputValue: Must not have leading zeros");if((e.match(/1/g)||[]).length>1)throw new Error("InvalidLogInputValue: Must be power of 10.");return(e.match(/0/g)||[]).length}},6166:function(e,t,n){"use strict";var r=n(7426),o=n(3349);function i(){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=i,i.prototype.update=function(e,t){if(e=r.toArray(e,t),this.pending?this.pending=this.pending.concat(e):this.pending=e,this.pendingTotal+=e.length,this.pending.length>=this._delta8){var n=(e=this.pending).length%this._delta8;this.pending=e.slice(e.length-n,e.length),0===this.pending.length&&(this.pending=null),e=r.join32(e,0,e.length-n,this.endian);for(var o=0;o<e.length;o+=this._delta32)this._update(e,o,o+this._delta32)}return this},i.prototype.digest=function(e){return this.update(this._pad()),o(null===this.pending),this._digest(e)},i.prototype._pad=function(){var e=this.pendingTotal,t=this._delta8,n=t-(e+this.padLength)%t,r=new Array(n+this.padLength);r[0]=128;for(var o=1;o<n;o++)r[o]=0;if(e<<=3,"big"===this.endian){for(var i=8;i<this.padLength;i++)r[o++]=0;r[o++]=0,r[o++]=0,r[o++]=0,r[o++]=0,r[o++]=e>>>24&255,r[o++]=e>>>16&255,r[o++]=e>>>8&255,r[o++]=255&e}else for(r[o++]=255&e,r[o++]=e>>>8&255,r[o++]=e>>>16&255,r[o++]=e>>>24&255,r[o++]=0,r[o++]=0,r[o++]=0,r[o++]=0,i=8;i<this.padLength;i++)r[o++]=0;return r}},6225:function(e,t,n){"use strict";var r=n(7426).rotr32;function o(e,t,n){return e&t^~e&n}function i(e,t,n){return e&t^e&n^t&n}function a(e,t,n){return e^t^n}t.ft_1=function(e,t,n,r){return 0===e?o(t,n,r):1===e||3===e?a(t,n,r):2===e?i(t,n,r):void 0},t.ch32=o,t.maj32=i,t.p32=a,t.s0_256=function(e){return r(e,2)^r(e,13)^r(e,22)},t.s1_256=function(e){return r(e,6)^r(e,11)^r(e,25)},t.g0_256=function(e){return r(e,7)^r(e,18)^e>>>3},t.g1_256=function(e){return r(e,17)^r(e,19)^e>>>10}},6229:function(e,t,n){"use strict";t.sha1=n(3917),t.sha224=n(7714),t.sha256=n(2287),t.sha384=n(1911),t.sha512=n(7766)},6341:function(e){function t(e){return e}e.exports=function(e,n,r){n=n||t,r=r||e;for(var o=0,i=e.length;o<i;o+=1)if(n.call(r,e[o],o))return e[o]}},6661:function(e,t,n){"use strict";var r=n(7011),o=r.assert,i=r.parseBytes,a=r.cachedProperty;function s(e,t){this.eddsa=e,this._secret=i(t.secret),e.isPoint(t.pub)?this._pub=t.pub:this._pubBytes=i(t.pub)}s.fromPublic=function(e,t){return t instanceof s?t:new s(e,{pub:t})},s.fromSecret=function(e,t){return t instanceof s?t:new s(e,{secret:t})},s.prototype.secret=function(){return this._secret},a(s,"pubBytes",function(){return this.eddsa.encodePoint(this.pub())}),a(s,"pub",function(){return this._pubBytes?this.eddsa.decodePoint(this._pubBytes):this.eddsa.g.mul(this.priv())}),a(s,"privBytes",function(){var e=this.eddsa,t=this.hash(),n=e.encodingLength-1,r=t.slice(0,e.encodingLength);return r[0]&=248,r[n]&=127,r[n]|=64,r}),a(s,"priv",function(){return this.eddsa.decodeInt(this.privBytes())}),a(s,"hash",function(){return this.eddsa.hash().update(this.secret()).digest()}),a(s,"messagePrefix",function(){return this.hash().slice(this.eddsa.encodingLength)}),s.prototype.sign=function(e){return o(this._secret,"KeyPair can only verify"),this.eddsa.sign(e,this)},s.prototype.verify=function(e,t){return this.eddsa.verify(e,t,this)},s.prototype.getSecret=function(e){return o(this._secret,"KeyPair is public only"),r.encode(this.secret(),e)},s.prototype.getPublic=function(e){return r.encode(this.pubBytes(),e)},e.exports=s},6677:function(e,t,n){"use strict";var r=n(9404),o=n(7011),i=o.getNAF,a=o.getJSF,s=o.assert;function c(e,t){this.type=e,this.p=new r(t.p,16),this.red=t.prime?r.red(t.prime):r.mont(this.p),this.zero=new r(0).toRed(this.red),this.one=new r(1).toRed(this.red),this.two=new r(2).toRed(this.red),this.n=t.n&&new r(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 n=this.n&&this.p.div(this.n);!n||n.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}function u(e,t){this.curve=e,this.type=t,this.precomputed=null}e.exports=c,c.prototype.point=function(){throw new Error("Not implemented")},c.prototype.validate=function(){throw new Error("Not implemented")},c.prototype._fixedNafMul=function(e,t){s(e.precomputed);var n=e._getDoubles(),r=i(t,1,this._bitLength),o=(1<<n.step+1)-(n.step%2==0?2:1);o/=3;var a,c,u=[];for(a=0;a<r.length;a+=n.step){c=0;for(var l=a+n.step-1;l>=a;l--)c=(c<<1)+r[l];u.push(c)}for(var d=this.jpoint(null,null,null),f=this.jpoint(null,null,null),p=o;p>0;p--){for(a=0;a<u.length;a++)(c=u[a])===p?f=f.mixedAdd(n.points[a]):c===-p&&(f=f.mixedAdd(n.points[a].neg()));d=d.add(f)}return d.toP()},c.prototype._wnafMul=function(e,t){var n=4,r=e._getNAFPoints(n);n=r.wnd;for(var o=r.points,a=i(t,n,this._bitLength),c=this.jpoint(null,null,null),u=a.length-1;u>=0;u--){for(var l=0;u>=0&&0===a[u];u--)l++;if(u>=0&&l++,c=c.dblp(l),u<0)break;var d=a[u];s(0!==d),c="affine"===e.type?d>0?c.mixedAdd(o[d-1>>1]):c.mixedAdd(o[-d-1>>1].neg()):d>0?c.add(o[d-1>>1]):c.add(o[-d-1>>1].neg())}return"affine"===e.type?c.toP():c},c.prototype._wnafMulAdd=function(e,t,n,r,o){var s,c,u,l=this._wnafT1,d=this._wnafT2,f=this._wnafT3,p=0;for(s=0;s<r;s++){var h=(u=t[s])._getNAFPoints(e);l[s]=h.wnd,d[s]=h.points}for(s=r-1;s>=1;s-=2){var y=s-1,b=s;if(1===l[y]&&1===l[b]){var g=[t[y],null,null,t[b]];0===t[y].y.cmp(t[b].y)?(g[1]=t[y].add(t[b]),g[2]=t[y].toJ().mixedAdd(t[b].neg())):0===t[y].y.cmp(t[b].y.redNeg())?(g[1]=t[y].toJ().mixedAdd(t[b]),g[2]=t[y].add(t[b].neg())):(g[1]=t[y].toJ().mixedAdd(t[b]),g[2]=t[y].toJ().mixedAdd(t[b].neg()));var w=[-3,-1,-5,-7,0,7,5,1,3],v=a(n[y],n[b]);for(p=Math.max(v[0].length,p),f[y]=new Array(p),f[b]=new Array(p),c=0;c<p;c++){var m=0|v[0][c],I=0|v[1][c];f[y][c]=w[3*(m+1)+(I+1)],f[b][c]=0,d[y]=g}}else f[y]=i(n[y],l[y],this._bitLength),f[b]=i(n[b],l[b],this._bitLength),p=Math.max(f[y].length,p),p=Math.max(f[b].length,p)}var E=this.jpoint(null,null,null),S=this._wnafT4;for(s=p;s>=0;s--){for(var O=0;s>=0;){var A=!0;for(c=0;c<r;c++)S[c]=0|f[c][s],0!==S[c]&&(A=!1);if(!A)break;O++,s--}if(s>=0&&O++,E=E.dblp(O),s<0)break;for(c=0;c<r;c++){var T=S[c];0!==T&&(T>0?u=d[c][T-1>>1]:T<0&&(u=d[c][-T-1>>1].neg()),E="affine"===u.type?E.mixedAdd(u):E.add(u))}}for(s=0;s<r;s++)d[s]=null;return o?E:E.toP()},c.BasePoint=u,u.prototype.eq=function(){throw new Error("Not implemented")},u.prototype.validate=function(){return this.curve.validate(this)},c.prototype.decodePoint=function(e,t){e=o.toArray(e,t);var n=this.p.byteLength();if((4===e[0]||6===e[0]||7===e[0])&&e.length-1==2*n)return 6===e[0]?s(e[e.length-1]%2==0):7===e[0]&&s(e[e.length-1]%2==1),this.point(e.slice(1,1+n),e.slice(1+n,1+2*n));if((2===e[0]||3===e[0])&&e.length-1===n)return this.pointFromX(e.slice(1,1+n),3===e[0]);throw new Error("Unknown point format")},u.prototype.encodeCompressed=function(e){return this.encode(e,!0)},u.prototype._encode=function(e){var t=this.curve.p.byteLength(),n=this.getX().toArray("be",t);return e?[this.getY().isEven()?2:3].concat(n):[4].concat(n,this.getY().toArray("be",t))},u.prototype.encode=function(e,t){return o.encode(this._encode(t),e)},u.prototype.precompute=function(e){if(this.precomputed)return this;var t={doubles:null,naf:null,beta:null};return t.naf=this._getNAFPoints(8),t.doubles=this._getDoubles(4,e),t.beta=this._getBeta(),this.precomputed=t,this},u.prototype._hasDoubles=function(e){if(!this.precomputed)return!1;var t=this.precomputed.doubles;return!!t&&t.points.length>=Math.ceil((e.bitLength()+1)/t.step)},u.prototype._getDoubles=function(e,t){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var n=[this],r=this,o=0;o<t;o+=e){for(var i=0;i<e;i++)r=r.dbl();n.push(r)}return{step:e,points:n}},u.prototype._getNAFPoints=function(e){if(this.precomputed&&this.precomputed.naf)return this.precomputed.naf;for(var t=[this],n=(1<<e)-1,r=1===n?null:this.dbl(),o=1;o<n;o++)t[o]=t[o-1].add(r);return{wnd:e,points:t}},u.prototype._getBeta=function(){return null},u.prototype.dblp=function(e){for(var t=this,n=0;n<e;n++)t=t.dbl();return t}},6698:function(e){"function"==typeof Object.create?e.exports=function(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:e.exports=function(e,t){if(t){e.super_=t;var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e}}},6729:function(e,t,n){"use strict";var r=t;r.version=n(1636).rE,r.utils=n(7011),r.rand=n(5037),r.curve=n(894),r.curves=n(480),r.ec=n(7447),r.eddsa=n(8650)},6784:function(e,t,n){"use strict";var r=n(7426),o=n(6166),i=r.rotl32,a=r.sum32,s=r.sum32_3,c=r.sum32_4,u=o.BlockHash;function l(){if(!(this instanceof l))return new l;u.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.endian="little"}function d(e,t,n,r){return e<=15?t^n^r:e<=31?t&n|~t&r:e<=47?(t|~n)^r:e<=63?t&r|n&~r:t^(n|~r)}function f(e){return e<=15?0:e<=31?1518500249:e<=47?1859775393:e<=63?2400959708:2840853838}function p(e){return e<=15?1352829926:e<=31?1548603684:e<=47?1836072691:e<=63?2053994217:0}r.inherits(l,u),t.ripemd160=l,l.blockSize=512,l.outSize=160,l.hmacStrength=192,l.padLength=64,l.prototype._update=function(e,t){for(var n=this.h[0],r=this.h[1],o=this.h[2],u=this.h[3],l=this.h[4],w=n,v=r,m=o,I=u,E=l,S=0;S<80;S++){var O=a(i(c(n,d(S,r,o,u),e[h[S]+t],f(S)),b[S]),l);n=l,l=u,u=i(o,10),o=r,r=O,O=a(i(c(w,d(79-S,v,m,I),e[y[S]+t],p(S)),g[S]),E),w=E,E=I,I=i(m,10),m=v,v=O}O=s(this.h[1],o,I),this.h[1]=s(this.h[2],u,E),this.h[2]=s(this.h[3],l,w),this.h[3]=s(this.h[4],n,v),this.h[4]=s(this.h[0],r,m),this.h[0]=O},l.prototype._digest=function(e){return"hex"===e?r.toHex32(this.h,"little"):r.split32(this.h,"little")};var h=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],y=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],b=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],g=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]},7011:function(e,t,n){"use strict";var r=t,o=n(9404),i=n(3349),a=n(4367);r.assert=i,r.toArray=a.toArray,r.zero2=a.zero2,r.toHex=a.toHex,r.encode=a.encode,r.getNAF=function(e,t,n){var r=new Array(Math.max(e.bitLength(),n)+1);r.fill(0);for(var o=1<<t+1,i=e.clone(),a=0;a<r.length;a++){var s,c=i.andln(o-1);i.isOdd()?(s=c>(o>>1)-1?(o>>1)-c:c,i.isubn(s)):s=0,r[a]=s,i.iushrn(1)}return r},r.getJSF=function(e,t){var n=[[],[]];e=e.clone(),t=t.clone();for(var r,o=0,i=0;e.cmpn(-o)>0||t.cmpn(-i)>0;){var a,s,c=e.andln(3)+o&3,u=t.andln(3)+i&3;3===c&&(c=-1),3===u&&(u=-1),a=1&c?3!==(r=e.andln(7)+o&7)&&5!==r||2!==u?c:-c:0,n[0].push(a),s=1&u?3!==(r=t.andln(7)+i&7)&&5!==r||2!==c?u:-u:0,n[1].push(s),2*o===a+1&&(o=1-o),2*i===s+1&&(i=1-i),e.iushrn(1),t.iushrn(1)}return n},r.cachedProperty=function(e,t,n){var r="_"+t;e.prototype[t]=function(){return void 0!==this[r]?this[r]:this[r]=n.call(this)}},r.parseBytes=function(e){return"string"==typeof e?r.toArray(e,"hex"):e},r.intFromLE=function(e){return new o(e,"hex","le")}},7426:function(e,t,n){"use strict";var r=n(3349),o=n(6698);function i(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 c(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=o,t.toArray=function(e,t){if(Array.isArray(e))return e.slice();if(!e)return[];var n=[];if("string"==typeof e)if(t){if("hex"===t)for((e=e.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(e="0"+e),o=0;o<e.length;o+=2)n.push(parseInt(e[o]+e[o+1],16))}else for(var r=0,o=0;o<e.length;o++){var a=e.charCodeAt(o);a<128?n[r++]=a:a<2048?(n[r++]=a>>6|192,n[r++]=63&a|128):i(e,o)?(a=65536+((1023&a)<<10)+(1023&e.charCodeAt(++o)),n[r++]=a>>18|240,n[r++]=a>>12&63|128,n[r++]=a>>6&63|128,n[r++]=63&a|128):(n[r++]=a>>12|224,n[r++]=a>>6&63|128,n[r++]=63&a|128)}else for(o=0;o<e.length;o++)n[o]=0|e[o];return n},t.toHex=function(e){for(var t="",n=0;n<e.length;n++)t+=s(e[n].toString(16));return t},t.htonl=a,t.toHex32=function(e,t){for(var n="",r=0;r<e.length;r++){var o=e[r];"little"===t&&(o=a(o)),n+=c(o.toString(16))}return n},t.zero2=s,t.zero8=c,t.join32=function(e,t,n,o){var i=n-t;r(i%4==0);for(var a=new Array(i/4),s=0,c=t;s<a.length;s++,c+=4){var u;u="big"===o?e[c]<<24|e[c+1]<<16|e[c+2]<<8|e[c+3]:e[c+3]<<24|e[c+2]<<16|e[c+1]<<8|e[c],a[s]=u>>>0}return a},t.split32=function(e,t){for(var n=new Array(4*e.length),r=0,o=0;r<e.length;r++,o+=4){var i=e[r];"big"===t?(n[o]=i>>>24,n[o+1]=i>>>16&255,n[o+2]=i>>>8&255,n[o+3]=255&i):(n[o+3]=i>>>24,n[o+2]=i>>>16&255,n[o+1]=i>>>8&255,n[o]=255&i)}return n},t.rotr32=function(e,t){return e>>>t|e<<32-t},t.rotl32=function(e,t){return e<<t|e>>>32-t},t.sum32=function(e,t){return e+t>>>0},t.sum32_3=function(e,t,n){return e+t+n>>>0},t.sum32_4=function(e,t,n,r){return e+t+n+r>>>0},t.sum32_5=function(e,t,n,r,o){return e+t+n+r+o>>>0},t.sum64=function(e,t,n,r){var o=e[t],i=r+e[t+1]>>>0,a=(i<r?1:0)+n+o;e[t]=a>>>0,e[t+1]=i},t.sum64_hi=function(e,t,n,r){return(t+r>>>0<t?1:0)+e+n>>>0},t.sum64_lo=function(e,t,n,r){return t+r>>>0},t.sum64_4_hi=function(e,t,n,r,o,i,a,s){var c=0,u=t;return c+=(u=u+r>>>0)<t?1:0,c+=(u=u+i>>>0)<i?1:0,e+n+o+a+(c+=(u=u+s>>>0)<s?1:0)>>>0},t.sum64_4_lo=function(e,t,n,r,o,i,a,s){return t+r+i+s>>>0},t.sum64_5_hi=function(e,t,n,r,o,i,a,s,c,u){var l=0,d=t;return l+=(d=d+r>>>0)<t?1:0,l+=(d=d+i>>>0)<i?1:0,l+=(d=d+s>>>0)<s?1:0,e+n+o+a+c+(l+=(d=d+u>>>0)<u?1:0)>>>0},t.sum64_5_lo=function(e,t,n,r,o,i,a,s,c,u){return t+r+i+s+u>>>0},t.rotr64_hi=function(e,t,n){return(t<<32-n|e>>>n)>>>0},t.rotr64_lo=function(e,t,n){return(e<<32-n|t>>>n)>>>0},t.shr64_hi=function(e,t,n){return e>>>n},t.shr64_lo=function(e,t,n){return(e<<32-n|t>>>n)>>>0}},7447:function(e,t,n){"use strict";var r=n(9404),o=n(2723),i=n(7011),a=n(480),s=n(5037),c=i.assert,u=n(1200),l=n(8545);function d(e){if(!(this instanceof d))return new d(e);"string"==typeof e&&(c(Object.prototype.hasOwnProperty.call(a,e),"Unknown curve "+e),e=a[e]),e instanceof a.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}e.exports=d,d.prototype.keyPair=function(e){return new u(this,e)},d.prototype.keyFromPrivate=function(e,t){return u.fromPrivate(this,e,t)},d.prototype.keyFromPublic=function(e,t){return u.fromPublic(this,e,t)},d.prototype.genKeyPair=function(e){e||(e={});for(var t=new o({hash:this.hash,pers:e.pers,persEnc:e.persEnc||"utf8",entropy:e.entropy||s(this.hash.hmacStrength),entropyEnc:e.entropy&&e.entropyEnc||"utf8",nonce:this.n.toArray()}),n=this.n.byteLength(),i=this.n.sub(new r(2));;){var a=new r(t.generate(n));if(!(a.cmp(i)>0))return a.iaddn(1),this.keyFromPrivate(a)}},d.prototype._truncateToN=function(e,t){var n=8*e.byteLength()-this.n.bitLength();return n>0&&(e=e.ushrn(n)),!t&&e.cmp(this.n)>=0?e.sub(this.n):e},d.prototype.sign=function(e,t,n,i){"object"==typeof n&&(i=n,n=null),i||(i={}),t=this.keyFromPrivate(t,n),e=this._truncateToN(new r(e,16));for(var a=this.n.byteLength(),s=t.getPrivate().toArray("be",a),c=e.toArray("be",a),u=new o({hash:this.hash,entropy:s,nonce:c,pers:i.pers,persEnc:i.persEnc||"utf8"}),d=this.n.sub(new r(1)),f=0;;f++){var p=i.k?i.k(f):new r(u.generate(this.n.byteLength()));if(!((p=this._truncateToN(p,!0)).cmpn(1)<=0||p.cmp(d)>=0)){var h=this.g.mul(p);if(!h.isInfinity()){var y=h.getX(),b=y.umod(this.n);if(0!==b.cmpn(0)){var g=p.invm(this.n).mul(b.mul(t.getPrivate()).iadd(e));if(0!==(g=g.umod(this.n)).cmpn(0)){var w=(h.getY().isOdd()?1:0)|(0!==y.cmp(b)?2:0);return i.canonical&&g.cmp(this.nh)>0&&(g=this.n.sub(g),w^=1),new l({r:b,s:g,recoveryParam:w})}}}}}},d.prototype.verify=function(e,t,n,o){e=this._truncateToN(new r(e,16)),n=this.keyFromPublic(n,o);var i=(t=new l(t,"hex")).r,a=t.s;if(i.cmpn(1)<0||i.cmp(this.n)>=0)return!1;if(a.cmpn(1)<0||a.cmp(this.n)>=0)return!1;var s,c=a.invm(this.n),u=c.mul(e).umod(this.n),d=c.mul(i).umod(this.n);return this.curve._maxwellTrick?!(s=this.g.jmulAdd(u,n.getPublic(),d)).isInfinity()&&s.eqXToP(i):!(s=this.g.mulAdd(u,n.getPublic(),d)).isInfinity()&&0===s.getX().umod(this.n).cmp(i)},d.prototype.recoverPubKey=function(e,t,n,o){c((3&n)===n,"The recovery param is more than two bits"),t=new l(t,o);var i=this.n,a=new r(e),s=t.r,u=t.s,d=1&n,f=n>>1;if(s.cmp(this.curve.p.umod(this.curve.n))>=0&&f)throw new Error("Unable to find sencond key candinate");s=f?this.curve.pointFromX(s.add(this.curve.n),d):this.curve.pointFromX(s,d);var p=t.r.invm(i),h=i.sub(a).mul(p).umod(i),y=u.mul(p).umod(i);return this.g.mulAdd(h,s,y)},d.prototype.getKeyRecoveryParam=function(e,t,n,r){if(null!==(t=new l(t,r)).recoveryParam)return t.recoveryParam;for(var o=0;o<4;o++){var i;try{i=this.recoverPubKey(e,t,o)}catch(e){continue}if(i.eq(n))return o}throw new Error("Unable to find valid recovery factor")}},7714:function(e,t,n){"use strict";var r=n(7426),o=n(2287);function i(){if(!(this instanceof i))return new i;o.call(this),this.h=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]}r.inherits(i,o),e.exports=i,i.blockSize=512,i.outSize=224,i.hmacStrength=192,i.padLength=64,i.prototype._digest=function(e){return"hex"===e?r.toHex32(this.h.slice(0,7),"big"):r.split32(this.h.slice(0,7),"big")}},7766:function(e,t,n){"use strict";var r=n(7426),o=n(6166),i=n(3349),a=r.rotr64_hi,s=r.rotr64_lo,c=r.shr64_hi,u=r.shr64_lo,l=r.sum64,d=r.sum64_hi,f=r.sum64_lo,p=r.sum64_4_hi,h=r.sum64_4_lo,y=r.sum64_5_hi,b=r.sum64_5_lo,g=o.BlockHash,w=[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];function v(){if(!(this instanceof v))return new v;g.call(this),this.h=[1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209],this.k=w,this.W=new Array(160)}function m(e,t,n,r,o){var i=e&n^~e&o;return i<0&&(i+=4294967296),i}function I(e,t,n,r,o,i){var a=t&r^~t&i;return a<0&&(a+=4294967296),a}function E(e,t,n,r,o){var i=e&n^e&o^n&o;return i<0&&(i+=4294967296),i}function S(e,t,n,r,o,i){var a=t&r^t&i^r&i;return a<0&&(a+=4294967296),a}function O(e,t){var n=a(e,t,28)^a(t,e,2)^a(t,e,7);return n<0&&(n+=4294967296),n}function A(e,t){var n=s(e,t,28)^s(t,e,2)^s(t,e,7);return n<0&&(n+=4294967296),n}function T(e,t){var n=a(e,t,14)^a(e,t,18)^a(t,e,9);return n<0&&(n+=4294967296),n}function _(e,t){var n=s(e,t,14)^s(e,t,18)^s(t,e,9);return n<0&&(n+=4294967296),n}function k(e,t){var n=a(e,t,1)^a(e,t,8)^c(e,t,7);return n<0&&(n+=4294967296),n}function x(e,t){var n=s(e,t,1)^s(e,t,8)^u(e,t,7);return n<0&&(n+=4294967296),n}function P(e,t){var n=a(e,t,19)^a(t,e,29)^c(e,t,6);return n<0&&(n+=4294967296),n}function M(e,t){var n=s(e,t,19)^s(t,e,29)^u(e,t,6);return n<0&&(n+=4294967296),n}r.inherits(v,g),e.exports=v,v.blockSize=1024,v.outSize=512,v.hmacStrength=192,v.padLength=128,v.prototype._prepareBlock=function(e,t){for(var n=this.W,r=0;r<32;r++)n[r]=e[t+r];for(;r<n.length;r+=2){var o=P(n[r-4],n[r-3]),i=M(n[r-4],n[r-3]),a=n[r-14],s=n[r-13],c=k(n[r-30],n[r-29]),u=x(n[r-30],n[r-29]),l=n[r-32],d=n[r-31];n[r]=p(o,i,a,s,c,u,l,d),n[r+1]=h(o,i,a,s,c,u,l,d)}},v.prototype._update=function(e,t){this._prepareBlock(e,t);var n=this.W,r=this.h[0],o=this.h[1],a=this.h[2],s=this.h[3],c=this.h[4],u=this.h[5],p=this.h[6],h=this.h[7],g=this.h[8],w=this.h[9],v=this.h[10],k=this.h[11],x=this.h[12],P=this.h[13],M=this.h[14],C=this.h[15];i(this.k.length===n.length);for(var N=0;N<n.length;N+=2){var j=M,D=C,R=T(g,w),L=_(g,w),B=m(g,w,v,k,x),K=I(g,w,v,k,x,P),U=this.k[N],F=this.k[N+1],W=n[N],G=n[N+1],z=y(j,D,R,L,B,K,U,F,W,G),q=b(j,D,R,L,B,K,U,F,W,G);j=O(r,o),D=A(r,o),R=E(r,o,a,s,c),L=S(r,o,a,s,c,u);var $=d(j,D,R,L),H=f(j,D,R,L);M=x,C=P,x=v,P=k,v=g,k=w,g=d(p,h,z,q),w=f(h,h,z,q),p=c,h=u,c=a,u=s,a=r,s=o,r=d(z,q,$,H),o=f(z,q,$,H)}l(this.h,0,r,o),l(this.h,2,a,s),l(this.h,4,c,u),l(this.h,6,p,h),l(this.h,8,g,w),l(this.h,10,v,k),l(this.h,12,x,P),l(this.h,14,M,C)},v.prototype._digest=function(e){return"hex"===e?r.toHex32(this.h,"big"):r.split32(this.h,"big")}},7790:function(){},7952:function(e,t,n){var r=t;r.utils=n(7426),r.common=n(6166),r.sha=n(6229),r.ripemd=n(6784),r.hmac=n(8948),r.sha1=r.sha.sha1,r.sha256=r.sha.sha256,r.sha224=r.sha.sha224,r.sha384=r.sha.sha384,r.sha512=r.sha.sha512,r.ripemd160=r.ripemd.ripemd160},8545:function(e,t,n){"use strict";var r=n(9404),o=n(7011),i=o.assert;function a(e,t){if(e instanceof a)return e;this._importDER(e,t)||(i(e.r&&e.s,"Signature without r or s"),this.r=new r(e.r,16),this.s=new r(e.s,16),void 0===e.recoveryParam?this.recoveryParam=null:this.recoveryParam=e.recoveryParam)}function s(){this.place=0}function c(e,t){var n=e[t.place++];if(!(128&n))return n;var r=15&n;if(0===r||r>4)return!1;for(var o=0,i=0,a=t.place;i<r;i++,a++)o<<=8,o|=e[a],o>>>=0;return!(o<=127)&&(t.place=a,o)}function u(e){for(var t=0,n=e.length-1;!e[t]&&!(128&e[t+1])&&t<n;)t++;return 0===t?e:e.slice(t)}function l(e,t){if(t<128)e.push(t);else{var n=1+(Math.log(t)/Math.LN2>>>3);for(e.push(128|n);--n;)e.push(t>>>(n<<3)&255);e.push(t)}}e.exports=a,a.prototype._importDER=function(e,t){e=o.toArray(e,t);var n=new s;if(48!==e[n.place++])return!1;var i=c(e,n);if(!1===i)return!1;if(i+n.place!==e.length)return!1;if(2!==e[n.place++])return!1;var a=c(e,n);if(!1===a)return!1;var u=e.slice(n.place,a+n.place);if(n.place+=a,2!==e[n.place++])return!1;var l=c(e,n);if(!1===l)return!1;if(e.length!==l+n.place)return!1;var d=e.slice(n.place,l+n.place);if(0===u[0]){if(!(128&u[1]))return!1;u=u.slice(1)}if(0===d[0]){if(!(128&d[1]))return!1;d=d.slice(1)}return this.r=new r(u),this.s=new r(d),this.recoveryParam=null,!0},a.prototype.toDER=function(e){var t=this.r.toArray(),n=this.s.toArray();for(128&t[0]&&(t=[0].concat(t)),128&n[0]&&(n=[0].concat(n)),t=u(t),n=u(n);!(n[0]||128&n[1]);)n=n.slice(1);var r=[2];l(r,t.length),(r=r.concat(t)).push(2),l(r,n.length);var i=r.concat(n),a=[48];return l(a,i.length),a=a.concat(i),o.encode(a,e)}},8650:function(e,t,n){"use strict";var r=n(7952),o=n(480),i=n(7011),a=i.assert,s=i.parseBytes,c=n(6661),u=n(220);function l(e){if(a("ed25519"===e,"only tested with ed25519 so far"),!(this instanceof l))return new l(e);e=o[e].curve,this.curve=e,this.g=e.g,this.g.precompute(e.n.bitLength()+1),this.pointClass=e.point().constructor,this.encodingLength=Math.ceil(e.n.bitLength()/8),this.hash=r.sha512}e.exports=l,l.prototype.sign=function(e,t){e=s(e);var n=this.keyFromSecret(t),r=this.hashInt(n.messagePrefix(),e),o=this.g.mul(r),i=this.encodePoint(o),a=this.hashInt(i,n.pubBytes(),e).mul(n.priv()),c=r.add(a).umod(this.curve.n);return this.makeSignature({R:o,S:c,Rencoded:i})},l.prototype.verify=function(e,t,n){e=s(e),t=this.makeSignature(t);var r=this.keyFromPublic(n),o=this.hashInt(t.Rencoded(),r.pubBytes(),e),i=this.g.mul(t.S());return t.R().add(r.pub().mul(o)).eq(i)},l.prototype.hashInt=function(){for(var e=this.hash(),t=0;t<arguments.length;t++)e.update(arguments[t]);return i.intFromLE(e.digest()).umod(this.curve.n)},l.prototype.keyFromPublic=function(e){return c.fromPublic(this,e)},l.prototype.keyFromSecret=function(e){return c.fromSecret(this,e)},l.prototype.makeSignature=function(e){return e instanceof u?e:new u(this,e)},l.prototype.encodePoint=function(e){var t=e.getY().toArray("le",this.encodingLength);return t[this.encodingLength-1]|=e.getX().isOdd()?128:0,t},l.prototype.decodePoint=function(e){var t=(e=i.parseBytes(e)).length-1,n=e.slice(0,t).concat(-129&e[t]),r=!!(128&e[t]),o=i.intFromLE(n);return this.curve.pointFromY(o,r)},l.prototype.encodeInt=function(e){return e.toArray("le",this.encodingLength)},l.prototype.decodeInt=function(e){return i.intFromLE(e)},l.prototype.isPoint=function(e){return e instanceof this.pointClass}},8948:function(e,t,n){"use strict";var r=n(7426),o=n(3349);function i(e,t,n){if(!(this instanceof i))return new i(e,t,n);this.Hash=e,this.blockSize=e.blockSize/8,this.outSize=e.outSize/8,this.inner=null,this.outer=null,this._init(r.toArray(t,n))}e.exports=i,i.prototype._init=function(e){e.length>this.blockSize&&(e=(new this.Hash).update(e).digest()),o(e.length<=this.blockSize);for(var t=e.length;t<this.blockSize;t++)e.push(0);for(t=0;t<e.length;t++)e[t]^=54;for(this.inner=(new this.Hash).update(e),t=0;t<e.length;t++)e[t]^=106;this.outer=(new this.Hash).update(e)},i.prototype.update=function(e,t){return this.inner.update(e,t),this},i.prototype.digest=function(e){return this.outer.update(this.inner.digest()),this.outer.digest(e)}},9112:function(e,t,n){"use strict";var r=n(9420),o=n(4945),i=n(3776),a=n(7952),s=n(9211);function c(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var u=c(o),l=c(i),d=c(a);const f=/^[a-z0-9-_.]+(\/+[a-z0-9-_.]+)*$/i,p=/^[a-f0-9]{40}$/,h=r.asObject({infoServers:r.asOptional(r.asArray(r.asString)),syncServers:r.asOptional(r.asArray(r.asString))}),y=e=>{const t=r.asString(e);if(""===t)throw new TypeError("Expected non empty string");return t},b=e=>{const t=r.asString(e);if(!p.test(t))throw new TypeError(`Invalid sync key '${t}'`);return t},g=r.asObject({iv_hex:r.asString,encryptionType:r.asNumber,data_base64:r.asString}),w=r.asObject({success:r.asValue(!1),message:r.asString,stack:r.asOptional(r.asString)}),v=r.asEither(g,r.asNull),m=r.asObject(v),I=r.asObject({syncKey:b,hash:r.asOptional(y)}),E=r.asObject({hash:r.asOptional(r.asString),changes:m}),S=r.asObject({syncKey:b,hash:r.asOptional(y)}),O=r.asObject({changes:m}),A=r.asObject({hash:r.asString,changes:m}),T=r.asObject({syncKey:b}),_=r.asUndefined,k=()=>{};async function x(e,t,n={}){const{log:o=k,fetch:i=u.default}=n,{method:a,url:s,body:c,numbUrl:l=s,headers:d={}}=e,f=Date.now(),p=await i(s,{method:a,headers:{"Content-Type":"application/json",...d},body:JSON.stringify(c)}),h=Date.now()-f;o(`${a} ${l} returned ${p.status} in ${h}ms`);const y=await p.text();if(!p.ok)throw new Error(`Failed request ${a} ${l} failed ${p.status}: ${y}`);const b=r.asMaybe(w)(y);if(null!=b)throw new Error(`Failed request ${a} ${l} failed ${p.status}: ${b.message}`);return t(""!==y.trim()?JSON.parse(y):void 0)}const P=l.default("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),M=e=>{const t=C(C(s.base16.parse(e)));return P.encode(t)};function C(e){const t=d.default.sha256();return Uint8Array.from(t.update(e).digest())}class N extends Error{constructor(e="Cannot reach the network"){super(e),this.name="NetworkError"}}const j={infoServers:["https://info-eu1.edge.app","https://info-us1.edge.app"],syncServers:["https://sync-us1.edge.app","https://sync-us2.edge.app","https://sync-us3.edge.app","https://sync-us4.edge.app","https://sync-us5.edge.app","https://sync-us6.edge.app","https://sync-eu.edge.app"]};function D(e={}){const{log:t=()=>{}}=e,n={...j,...e.edgeServers},{edgeServersCacheTTL:r=6e5}=e,o=function(e,t){let n=Date.now()+t,r=e(void 0);return{get:()=>{if(Date.now()>n||null==r){n=Date.now()+t;const o=e(r);r=o}return r}}}((r={current:n})=>(r.current.infoServers.length>0&&async function(e,t={}){const{log:n=k,fetch:r=u.default}=t;let o=new Error("No info servers");for(const a of e){const[e,t]=["GET","/v1/edgeServers"],s=Date.now(),c=`${a}${t}`;try{const t=await r(c,{method:e,headers:{"Content-Type":"application/json"}}).catch(t=>{const r=Date.now()-s,o=`${e} ${c} failed in ${r}ms, ${String(t)}`;throw n(o),new N(o)}),{ok:o,status:i}=t,a=Date.now()-s,u=`${e} ${c} returned ${i} in ${a}ms`;if(!o)throw n(u),new N(u);n(u);const l=await t.text(),d=JSON.parse(l);return h(d)}catch(i){o=i;continue}}throw o}(r.current.infoServers,e).then(e=>{return r.current={...r.current,...e,infoServers:(t=e.infoServers,n=()=>j.infoServers,null!=t?t:n())};var t,n}).catch(async e=>{t(String(e))}),r),r);return{async getEdgeServers(){const{current:e}=await o.get();return e}}}function R(e,t){return null!=e?e:t()}t.jG=m,t.ZU=g,t.CS=h,t.ve=v,t.q3=I,t.FX=E,t.yq=y,t.w2=e=>{const t=r.asString(e);try{if(f.test(t))return function(e){if(/^\//.test(e))throw new Error("Absolute paths are not supported");const t=e.split("/");let n=0,r=0;for(;n<t.length;){const e=t[n++];if(".."===e?r--:"."!==e&&""!==e&&(t[r++]=e),r<0)throw new Error("Path would escape folder");if(0===r&&n===t.length)throw new Error("Path would evaluate to empty file name")}return t.slice(0,r).join("/")}(t)}catch(n){}throw new Error(`Invalid path '${t}'`)},t.CG=O,t.Kr=S,t.l3=A,t.N0=T,t.MH=_,t.fs=w,t.FA=b,t.NL=function(e={}){const t=D(e);async function n(){const{syncServers:e}=await t.getEdgeServers();return function(e){for(let t=e.length-1;t>0;t--){const n=Math.floor(Math.random()*(t+1));[e[t],e[n]]=[e[n],e[t]]}return e}(e)}return{async createRepo(t,r){const o=await n();let i=new Error(`Failed to create repo ${t}: empty sync server list`);for(const n of o){const o=`${n}/api/v2/store/${t}`,s=o.replace(t,`<${M(t)}>`);try{return await x({method:"PUT",url:o,numbUrl:s,headers:null!=r?{"X-API-Key":r}:{}},_,e)}catch(a){i=a}}throw i},async readRepo(t,r){const o=await n();let i=new Error(`Failed to read repo ${t}: empty sync server list`);for(const n of o){const o=`${n}/api/v2/store/${t}/${R(r,()=>"")}`,s=o.replace(t,`<${M(t)}>`);try{return await x({method:"GET",url:o,numbUrl:s},E,e)}catch(a){i=a}}throw i},async updateRepo(t,r,o){const i=await n();let a=new Error(`Failed to update repo ${t}: empty sync server list`);for(const n of i){const i=`${n}/api/v2/store/${t}/${R(r,()=>"")}`,c=i.replace(t,`<${M(t)}>`);try{return await x({method:"POST",url:i,numbUrl:c,body:o},A,e)}catch(s){a=s}}throw a}}},t.Tb=M},9188:function(e,t,n){"use strict";var r=n(7011),o=n(9404),i=n(6698),a=n(6677),s=r.assert;function c(e){a.call(this,"short",e),this.a=new o(e.a,16).toRed(this.red),this.b=new o(e.b,16).toRed(this.red),this.tinv=this.two.redInvm(),this.zeroA=0===this.a.fromRed().cmpn(0),this.threeA=0===this.a.fromRed().sub(this.p).cmpn(-3),this.endo=this._getEndomorphism(e),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}function u(e,t,n,r){a.BasePoint.call(this,e,"affine"),null===t&&null===n?(this.x=null,this.y=null,this.inf=!0):(this.x=new o(t,16),this.y=new o(n,16),r&&(this.x.forceRed(this.curve.red),this.y.forceRed(this.curve.red)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.inf=!1)}function l(e,t,n,r){a.BasePoint.call(this,e,"jacobian"),null===t&&null===n&&null===r?(this.x=this.curve.one,this.y=this.curve.one,this.z=new o(0)):(this.x=new o(t,16),this.y=new o(n,16),this.z=new o(r,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one}i(c,a),e.exports=c,c.prototype._getEndomorphism=function(e){if(this.zeroA&&this.g&&this.n&&1===this.p.modn(3)){var t,n;if(e.beta)t=new o(e.beta,16).toRed(this.red);else{var r=this._getEndoRoots(this.p);t=(t=r[0].cmp(r[1])<0?r[0]:r[1]).toRed(this.red)}if(e.lambda)n=new o(e.lambda,16);else{var i=this._getEndoRoots(this.n);0===this.g.mul(i[0]).x.cmp(this.g.x.redMul(t))?n=i[0]:(n=i[1],s(0===this.g.mul(n).x.cmp(this.g.x.redMul(t))))}return{beta:t,lambda:n,basis:e.basis?e.basis.map(function(e){return{a:new o(e.a,16),b:new o(e.b,16)}}):this._getEndoBasis(n)}}},c.prototype._getEndoRoots=function(e){var t=e===this.p?this.red:o.mont(e),n=new o(2).toRed(t).redInvm(),r=n.redNeg(),i=new o(3).toRed(t).redNeg().redSqrt().redMul(n);return[r.redAdd(i).fromRed(),r.redSub(i).fromRed()]},c.prototype._getEndoBasis=function(e){for(var t,n,r,i,a,s,c,u,l,d=this.n.ushrn(Math.floor(this.n.bitLength()/2)),f=e,p=this.n.clone(),h=new o(1),y=new o(0),b=new o(0),g=new o(1),w=0;0!==f.cmpn(0);){var v=p.div(f);u=p.sub(v.mul(f)),l=b.sub(v.mul(h));var m=g.sub(v.mul(y));if(!r&&u.cmp(d)<0)t=c.neg(),n=h,r=u.neg(),i=l;else if(r&&2===++w)break;c=u,p=f,f=u,b=h,h=l,g=y,y=m}a=u.neg(),s=l;var I=r.sqr().add(i.sqr());return a.sqr().add(s.sqr()).cmp(I)>=0&&(a=t,s=n),r.negative&&(r=r.neg(),i=i.neg()),a.negative&&(a=a.neg(),s=s.neg()),[{a:r,b:i},{a:a,b:s}]},c.prototype._endoSplit=function(e){var t=this.endo.basis,n=t[0],r=t[1],o=r.b.mul(e).divRound(this.n),i=n.b.neg().mul(e).divRound(this.n),a=o.mul(n.a),s=i.mul(r.a),c=o.mul(n.b),u=i.mul(r.b);return{k1:e.sub(a).sub(s),k2:c.add(u).neg()}},c.prototype.pointFromX=function(e,t){(e=new o(e,16)).red||(e=e.toRed(this.red));var n=e.redSqr().redMul(e).redIAdd(e.redMul(this.a)).redIAdd(this.b),r=n.redSqrt();if(0!==r.redSqr().redSub(n).cmp(this.zero))throw new Error("invalid point");var i=r.fromRed().isOdd();return(t&&!i||!t&&i)&&(r=r.redNeg()),this.point(e,r)},c.prototype.validate=function(e){if(e.inf)return!0;var t=e.x,n=e.y,r=this.a.redMul(t),o=t.redSqr().redMul(t).redIAdd(r).redIAdd(this.b);return 0===n.redSqr().redISub(o).cmpn(0)},c.prototype._endoWnafMulAdd=function(e,t,n){for(var r=this._endoWnafT1,o=this._endoWnafT2,i=0;i<e.length;i++){var a=this._endoSplit(t[i]),s=e[i],c=s._getBeta();a.k1.negative&&(a.k1.ineg(),s=s.neg(!0)),a.k2.negative&&(a.k2.ineg(),c=c.neg(!0)),r[2*i]=s,r[2*i+1]=c,o[2*i]=a.k1,o[2*i+1]=a.k2}for(var u=this._wnafMulAdd(1,r,o,2*i,n),l=0;l<2*i;l++)r[l]=null,o[l]=null;return u},i(u,a.BasePoint),c.prototype.point=function(e,t,n){return new u(this,e,t,n)},c.prototype.pointFromJSON=function(e,t){return u.fromJSON(this,e,t)},u.prototype._getBeta=function(){if(this.curve.endo){var e=this.precomputed;if(e&&e.beta)return e.beta;var t=this.curve.point(this.x.redMul(this.curve.endo.beta),this.y);if(e){var n=this.curve,r=function(e){return n.point(e.x.redMul(n.endo.beta),e.y)};e.beta=t,t.precomputed={beta:null,naf:e.naf&&{wnd:e.naf.wnd,points:e.naf.points.map(r)},doubles:e.doubles&&{step:e.doubles.step,points:e.doubles.points.map(r)}}}return t}},u.prototype.toJSON=function(){return this.precomputed?[this.x,this.y,this.precomputed&&{doubles:this.precomputed.doubles&&{step:this.precomputed.doubles.step,points:this.precomputed.doubles.points.slice(1)},naf:this.precomputed.naf&&{wnd:this.precomputed.naf.wnd,points:this.precomputed.naf.points.slice(1)}}]:[this.x,this.y]},u.fromJSON=function(e,t,n){"string"==typeof t&&(t=JSON.parse(t));var r=e.point(t[0],t[1],n);if(!t[2])return r;function o(t){return e.point(t[0],t[1],n)}var i=t[2];return r.precomputed={beta:null,doubles:i.doubles&&{step:i.doubles.step,points:[r].concat(i.doubles.points.map(o))},naf:i.naf&&{wnd:i.naf.wnd,points:[r].concat(i.naf.points.map(o))}},r},u.prototype.inspect=function(){return this.isInfinity()?"<EC Point Infinity>":"<EC Point x: "+this.x.fromRed().toString(16,2)+" y: "+this.y.fromRed().toString(16,2)+">"},u.prototype.isInfinity=function(){return this.inf},u.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 n=t.redSqr().redISub(this.x).redISub(e.x),r=t.redMul(this.x.redSub(n)).redISub(this.y);return this.curve.point(n,r)},u.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,n=this.x.redSqr(),r=e.redInvm(),o=n.redAdd(n).redIAdd(n).redIAdd(t).redMul(r),i=o.redSqr().redISub(this.x.redAdd(this.x)),a=o.redMul(this.x.redSub(i)).redISub(this.y);return this.curve.point(i,a)},u.prototype.getX=function(){return this.x.fromRed()},u.prototype.getY=function(){return this.y.fromRed()},u.prototype.mul=function(e){return e=new o(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)},u.prototype.mulAdd=function(e,t,n){var r=[this,t],o=[e,n];return this.curve.endo?this.curve._endoWnafMulAdd(r,o):this.curve._wnafMulAdd(1,r,o,2)},u.prototype.jmulAdd=function(e,t,n){var r=[this,t],o=[e,n];return this.curve.endo?this.curve._endoWnafMulAdd(r,o,!0):this.curve._wnafMulAdd(1,r,o,2,!0)},u.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))},u.prototype.neg=function(e){if(this.inf)return this;var t=this.curve.point(this.x,this.y.redNeg());if(e&&this.precomputed){var n=this.precomputed,r=function(e){return e.neg()};t.precomputed={naf:n.naf&&{wnd:n.naf.wnd,points:n.naf.points.map(r)},doubles:n.doubles&&{step:n.doubles.step,points:n.doubles.points.map(r)}}}return t},u.prototype.toJ=function(){return this.inf?this.curve.jpoint(null,null,null):this.curve.jpoint(this.x,this.y,this.curve.one)},i(l,a.BasePoint),c.prototype.jpoint=function(e,t,n){return new l(this,e,t,n)},l.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var e=this.z.redInvm(),t=e.redSqr(),n=this.x.redMul(t),r=this.y.redMul(t).redMul(e);return this.curve.point(n,r)},l.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},l.prototype.add=function(e){if(this.isInfinity())return e;if(e.isInfinity())return this;var t=e.z.redSqr(),n=this.z.redSqr(),r=this.x.redMul(t),o=e.x.redMul(n),i=this.y.redMul(t.redMul(e.z)),a=e.y.redMul(n.redMul(this.z)),s=r.redSub(o),c=i.redSub(a);if(0===s.cmpn(0))return 0!==c.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var u=s.redSqr(),l=u.redMul(s),d=r.redMul(u),f=c.redSqr().redIAdd(l).redISub(d).redISub(d),p=c.redMul(d.redISub(f)).redISub(i.redMul(l)),h=this.z.redMul(e.z).redMul(s);return this.curve.jpoint(f,p,h)},l.prototype.mixedAdd=function(e){if(this.isInfinity())return e.toJ();if(e.isInfinity())return this;var t=this.z.redSqr(),n=this.x,r=e.x.redMul(t),o=this.y,i=e.y.redMul(t).redMul(this.z),a=n.redSub(r),s=o.redSub(i);if(0===a.cmpn(0))return 0!==s.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var c=a.redSqr(),u=c.redMul(a),l=n.redMul(c),d=s.redSqr().redIAdd(u).redISub(l).redISub(l),f=s.redMul(l.redISub(d)).redISub(o.redMul(u)),p=this.z.redMul(a);return this.curve.jpoint(d,f,p)},l.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 n=this;for(t=0;t<e;t++)n=n.dbl();return n}var r=this.curve.a,o=this.curve.tinv,i=this.x,a=this.y,s=this.z,c=s.redSqr().redSqr(),u=a.redAdd(a);for(t=0;t<e;t++){var l=i.redSqr(),d=u.redSqr(),f=d.redSqr(),p=l.redAdd(l).redIAdd(l).redIAdd(r.redMul(c)),h=i.redMul(d),y=p.redSqr().redISub(h.redAdd(h)),b=h.redISub(y),g=p.redMul(b);g=g.redIAdd(g).redISub(f);var w=u.redMul(s);t+1<e&&(c=c.redMul(f)),i=y,s=w,u=g}return this.curve.jpoint(i,u.redMul(o),s)},l.prototype.dbl=function(){return this.isInfinity()?this:this.curve.zeroA?this._zeroDbl():this.curve.threeA?this._threeDbl():this._dbl()},l.prototype._zeroDbl=function(){var e,t,n;if(this.zOne){var r=this.x.redSqr(),o=this.y.redSqr(),i=o.redSqr(),a=this.x.redAdd(o).redSqr().redISub(r).redISub(i);a=a.redIAdd(a);var s=r.redAdd(r).redIAdd(r),c=s.redSqr().redISub(a).redISub(a),u=i.redIAdd(i);u=(u=u.redIAdd(u)).redIAdd(u),e=c,t=s.redMul(a.redISub(c)).redISub(u),n=this.y.redAdd(this.y)}else{var l=this.x.redSqr(),d=this.y.redSqr(),f=d.redSqr(),p=this.x.redAdd(d).redSqr().redISub(l).redISub(f);p=p.redIAdd(p);var h=l.redAdd(l).redIAdd(l),y=h.redSqr(),b=f.redIAdd(f);b=(b=b.redIAdd(b)).redIAdd(b),e=y.redISub(p).redISub(p),t=h.redMul(p.redISub(e)).redISub(b),n=(n=this.y.redMul(this.z)).redIAdd(n)}return this.curve.jpoint(e,t,n)},l.prototype._threeDbl=function(){var e,t,n;if(this.zOne){var r=this.x.redSqr(),o=this.y.redSqr(),i=o.redSqr(),a=this.x.redAdd(o).redSqr().redISub(r).redISub(i);a=a.redIAdd(a);var s=r.redAdd(r).redIAdd(r).redIAdd(this.curve.a),c=s.redSqr().redISub(a).redISub(a);e=c;var u=i.redIAdd(i);u=(u=u.redIAdd(u)).redIAdd(u),t=s.redMul(a.redISub(c)).redISub(u),n=this.y.redAdd(this.y)}else{var l=this.z.redSqr(),d=this.y.redSqr(),f=this.x.redMul(d),p=this.x.redSub(l).redMul(this.x.redAdd(l));p=p.redAdd(p).redIAdd(p);var h=f.redIAdd(f),y=(h=h.redIAdd(h)).redAdd(h);e=p.redSqr().redISub(y),n=this.y.redAdd(this.z).redSqr().redISub(d).redISub(l);var b=d.redSqr();b=(b=(b=b.redIAdd(b)).redIAdd(b)).redIAdd(b),t=p.redMul(h.redISub(e)).redISub(b)}return this.curve.jpoint(e,t,n)},l.prototype._dbl=function(){var e=this.curve.a,t=this.x,n=this.y,r=this.z,o=r.redSqr().redSqr(),i=t.redSqr(),a=n.redSqr(),s=i.redAdd(i).redIAdd(i).redIAdd(e.redMul(o)),c=t.redAdd(t),u=(c=c.redIAdd(c)).redMul(a),l=s.redSqr().redISub(u.redAdd(u)),d=u.redISub(l),f=a.redSqr();f=(f=(f=f.redIAdd(f)).redIAdd(f)).redIAdd(f);var p=s.redMul(d).redISub(f),h=n.redAdd(n).redMul(r);return this.curve.jpoint(l,p,h)},l.prototype.trpl=function(){if(!this.curve.zeroA)return this.dbl().add(this);var e=this.x.redSqr(),t=this.y.redSqr(),n=this.z.redSqr(),r=t.redSqr(),o=e.redAdd(e).redIAdd(e),i=o.redSqr(),a=this.x.redAdd(t).redSqr().redISub(e).redISub(r),s=(a=(a=(a=a.redIAdd(a)).redAdd(a).redIAdd(a)).redISub(i)).redSqr(),c=r.redIAdd(r);c=(c=(c=c.redIAdd(c)).redIAdd(c)).redIAdd(c);var u=o.redIAdd(a).redSqr().redISub(i).redISub(s).redISub(c),l=t.redMul(u);l=(l=l.redIAdd(l)).redIAdd(l);var d=this.x.redMul(s).redISub(l);d=(d=d.redIAdd(d)).redIAdd(d);var f=this.y.redMul(u.redMul(c.redISub(u)).redISub(a.redMul(s)));f=(f=(f=f.redIAdd(f)).redIAdd(f)).redIAdd(f);var p=this.z.redAdd(a).redSqr().redISub(n).redISub(s);return this.curve.jpoint(d,f,p)},l.prototype.mul=function(e,t){return e=new o(e,t),this.curve._wnafMul(this,e)},l.prototype.eq=function(e){if("affine"===e.type)return this.eq(e.toJ());if(this===e)return!0;var t=this.z.redSqr(),n=e.z.redSqr();if(0!==this.x.redMul(n).redISub(e.x.redMul(t)).cmpn(0))return!1;var r=t.redMul(this.z),o=n.redMul(e.z);return 0===this.y.redMul(o).redISub(e.y.redMul(r)).cmpn(0)},l.prototype.eqXToP=function(e){var t=this.z.redSqr(),n=e.toRed(this.curve.red).redMul(t);if(0===this.x.cmp(n))return!0;for(var r=e.clone(),o=this.curve.redN.redMul(t);;){if(r.iadd(this.curve.n),r.cmp(this.curve.p)>=0)return!1;if(n.redIAdd(o),0===this.x.cmp(n))return!0}},l.prototype.inspect=function(){return this.isInfinity()?"<EC JPoint Infinity>":"<EC JPoint x: "+this.x.toString(16,2)+" y: "+this.y.toString(16,2)+" z: "+this.z.toString(16,2)+">"},l.prototype.isInfinity=function(){return 0===this.z.cmpn(0)}},9211:function(e,t){"use strict";function n(e,t,n){var r;if(void 0===n&&(n={}),!t.codes){t.codes={};for(var o=0;o<t.chars.length;++o)t.codes[t.chars[o]]=o}if(!n.loose&&e.length*t.bits&7)throw new SyntaxError("Invalid padding");for(var i=e.length;"="===e[i-1];)if(--i,!(n.loose||(e.length-i)*t.bits&7))throw new SyntaxError("Invalid padding");for(var a=new(null!=(r=n.out)?r:Uint8Array)(i*t.bits/8|0),s=0,c=0,u=0,l=0;l<i;++l){var d=t.codes[e[l]];if(void 0===d)throw new SyntaxError("Invalid character "+e[l]);c=c<<t.bits|d,(s+=t.bits)>=8&&(s-=8,a[u++]=255&c>>s)}if(s>=t.bits||255&c<<8-s)throw new SyntaxError("Unexpected end of data");return a}function r(e,t,n){void 0===n&&(n={});for(var r=n.pad,o=void 0===r||r,i=(1<<t.bits)-1,a="",s=0,c=0,u=0;u<e.length;++u)for(c=c<<8|255&e[u],s+=8;s>t.bits;)s-=t.bits,a+=t.chars[i&c>>s];if(s&&(a+=t.chars[i&c<<t.bits-s]),o)for(;a.length*t.bits&7;)a+="=";return a}Object.defineProperty(t,"__esModule",{value:!0});var o={chars:"0123456789ABCDEF",bits:4},i={chars:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bits:5},a={chars:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bits:5},s={chars:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bits:6},c={chars:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bits:6},u={parse:function(e,t){return n(e.toUpperCase(),o,t)},stringify:function(e,t){return r(e,o,t)}},l={parse:function(e,t){return void 0===t&&(t={}),n(t.loose?e.toUpperCase().replace(/0/g,"O").replace(/1/g,"L").replace(/8/g,"B"):e,i,t)},stringify:function(e,t){return r(e,i,t)}},d={parse:function(e,t){return n(e,a,t)},stringify:function(e,t){return r(e,a,t)}},f={parse:function(e,t){return n(e,s,t)},stringify:function(e,t){return r(e,s,t)}},p={parse:function(e,t){return n(e,c,t)},stringify:function(e,t){return r(e,c,t)}},h={parse:n,stringify:r};t.base16=u,t.base32=l,t.base32hex=d,t.base64=f,t.base64url=p,t.codec=h},9404:function(e,t,n){!function(e,t){"use strict";function r(e,t){if(!e)throw new Error(t||"Assertion failed")}function o(e,t){e.super_=t;var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e}function i(e,t,n){if(i.isBN(e))return e;this.negative=0,this.words=null,this.length=0,this.red=null,null!==e&&("le"!==t&&"be"!==t||(n=t,t=10),this._init(e||0,t||10,n||"be"))}var a;"object"==typeof e?e.exports=i:t.BN=i,i.BN=i,i.wordSize=26;try{a="undefined"!=typeof window&&void 0!==window.Buffer?window.Buffer:n(7790).Buffer}catch(A){}function s(e,t){var n=e.charCodeAt(t);return n>=65&&n<=70?n-55:n>=97&&n<=102?n-87:n-48&15}function c(e,t,n){var r=s(e,n);return n-1>=t&&(r|=s(e,n-1)<<4),r}function u(e,t,n,r){for(var o=0,i=Math.min(e.length,n),a=t;a<i;a++){var s=e.charCodeAt(a)-48;o*=r,o+=s>=49?s-49+10:s>=17?s-17+10:s}return o}i.isBN=function(e){return e instanceof i||null!==e&&"object"==typeof e&&e.constructor.wordSize===i.wordSize&&Array.isArray(e.words)},i.max=function(e,t){return e.cmp(t)>0?e:t},i.min=function(e,t){return e.cmp(t)<0?e:t},i.prototype._init=function(e,t,n){if("number"==typeof e)return this._initNumber(e,t,n);if("object"==typeof e)return this._initArray(e,t,n);"hex"===t&&(t=16),r(t===(0|t)&&t>=2&&t<=36);var o=0;"-"===(e=e.toString().replace(/\s+/g,""))[0]&&(o++,this.negative=1),o<e.length&&(16===t?this._parseHex(e,o,n):(this._parseBase(e,t,o),"le"===n&&this._initArray(this.toArray(),t,n)))},i.prototype._initNumber=function(e,t,n){e<0&&(this.negative=1,e=-e),e<67108864?(this.words=[67108863&e],this.length=1):e<4503599627370496?(this.words=[67108863&e,e/67108864&67108863],this.length=2):(r(e<9007199254740992),this.words=[67108863&e,e/67108864&67108863,1],this.length=3),"le"===n&&this._initArray(this.toArray(),t,n)},i.prototype._initArray=function(e,t,n){if(r("number"==typeof e.length),e.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(e.length/3),this.words=new Array(this.length);for(var o=0;o<this.length;o++)this.words[o]=0;var i,a,s=0;if("be"===n)for(o=e.length-1,i=0;o>=0;o-=3)a=e[o]|e[o-1]<<8|e[o-2]<<16,this.words[i]|=a<<s&67108863,this.words[i+1]=a>>>26-s&67108863,(s+=24)>=26&&(s-=26,i++);else if("le"===n)for(o=0,i=0;o<e.length;o+=3)a=e[o]|e[o+1]<<8|e[o+2]<<16,this.words[i]|=a<<s&67108863,this.words[i+1]=a>>>26-s&67108863,(s+=24)>=26&&(s-=26,i++);return this.strip()},i.prototype._parseHex=function(e,t,n){this.length=Math.ceil((e.length-t)/6),this.words=new Array(this.length);for(var r=0;r<this.length;r++)this.words[r]=0;var o,i=0,a=0;if("be"===n)for(r=e.length-1;r>=t;r-=2)o=c(e,t,r)<<i,this.words[a]|=67108863&o,i>=18?(i-=18,a+=1,this.words[a]|=o>>>26):i+=8;else for(r=(e.length-t)%2==0?t+1:t;r<e.length;r+=2)o=c(e,t,r)<<i,this.words[a]|=67108863&o,i>=18?(i-=18,a+=1,this.words[a]|=o>>>26):i+=8;this.strip()},i.prototype._parseBase=function(e,t,n){this.words=[0],this.length=1;for(var r=0,o=1;o<=67108863;o*=t)r++;r--,o=o/t|0;for(var i=e.length-n,a=i%r,s=Math.min(i,i-a)+n,c=0,l=n;l<s;l+=r)c=u(e,l,l+r,t),this.imuln(o),this.words[0]+c<67108864?this.words[0]+=c:this._iaddn(c);if(0!==a){var d=1;for(c=u(e,l,e.length,t),l=0;l<a;l++)d*=t;this.imuln(d),this.words[0]+c<67108864?this.words[0]+=c:this._iaddn(c)}this.strip()},i.prototype.copy=function(e){e.words=new Array(this.length);for(var t=0;t<this.length;t++)e.words[t]=this.words[t];e.length=this.length,e.negative=this.negative,e.red=this.red},i.prototype.clone=function(){var e=new i(null);return this.copy(e),e},i.prototype._expand=function(e){for(;this.length<e;)this.words[this.length++]=0;return this},i.prototype.strip=function(){for(;this.length>1&&0===this.words[this.length-1];)this.length--;return this._normSign()},i.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},i.prototype.inspect=function(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"};var l=["","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],f=[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];function p(e,t,n){n.negative=t.negative^e.negative;var r=e.length+t.length|0;n.length=r,r=r-1|0;var o=0|e.words[0],i=0|t.words[0],a=o*i,s=67108863&a,c=a/67108864|0;n.words[0]=s;for(var u=1;u<r;u++){for(var l=c>>>26,d=67108863&c,f=Math.min(u,t.length-1),p=Math.max(0,u-e.length+1);p<=f;p++){var h=u-p|0;l+=(a=(o=0|e.words[h])*(i=0|t.words[p])+d)/67108864|0,d=67108863&a}n.words[u]=0|d,c=0|l}return 0!==c?n.words[u]=0|c:n.length--,n.strip()}i.prototype.toString=function(e,t){var n;if(t=0|t||1,16===(e=e||10)||"hex"===e){n="";for(var o=0,i=0,a=0;a<this.length;a++){var s=this.words[a],c=(16777215&(s<<o|i)).toString(16);i=s>>>24-o&16777215,(o+=2)>=26&&(o-=26,a--),n=0!==i||a!==this.length-1?l[6-c.length]+c+n:c+n}for(0!==i&&(n=i.toString(16)+n);n.length%t!==0;)n="0"+n;return 0!==this.negative&&(n="-"+n),n}if(e===(0|e)&&e>=2&&e<=36){var u=d[e],p=f[e];n="";var h=this.clone();for(h.negative=0;!h.isZero();){var y=h.modn(p).toString(e);n=(h=h.idivn(p)).isZero()?y+n:l[u-y.length]+y+n}for(this.isZero()&&(n="0"+n);n.length%t!==0;)n="0"+n;return 0!==this.negative&&(n="-"+n),n}r(!1,"Base should be between 2 and 36")},i.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&&r(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-e:e},i.prototype.toJSON=function(){return this.toString(16)},i.prototype.toBuffer=function(e,t){return r(void 0!==a),this.toArrayLike(a,e,t)},i.prototype.toArray=function(e,t){return this.toArrayLike(Array,e,t)},i.prototype.toArrayLike=function(e,t,n){var o=this.byteLength(),i=n||Math.max(1,o);r(o<=i,"byte array longer than desired length"),r(i>0,"Requested array length <= 0"),this.strip();var a,s,c="le"===t,u=new e(i),l=this.clone();if(c){for(s=0;!l.isZero();s++)a=l.andln(255),l.iushrn(8),u[s]=a;for(;s<i;s++)u[s]=0}else{for(s=0;s<i-o;s++)u[s]=0;for(s=0;!l.isZero();s++)a=l.andln(255),l.iushrn(8),u[i-s-1]=a}return u},Math.clz32?i.prototype._countBits=function(e){return 32-Math.clz32(e)}:i.prototype._countBits=function(e){var t=e,n=0;return t>=4096&&(n+=13,t>>>=13),t>=64&&(n+=7,t>>>=7),t>=8&&(n+=4,t>>>=4),t>=2&&(n+=2,t>>>=2),n+t},i.prototype._zeroBits=function(e){if(0===e)return 26;var t=e,n=0;return 8191&t||(n+=13,t>>>=13),127&t||(n+=7,t>>>=7),15&t||(n+=4,t>>>=4),3&t||(n+=2,t>>>=2),1&t||n++,n},i.prototype.bitLength=function(){var e=this.words[this.length-1],t=this._countBits(e);return 26*(this.length-1)+t},i.prototype.zeroBits=function(){if(this.isZero())return 0;for(var e=0,t=0;t<this.length;t++){var n=this._zeroBits(this.words[t]);if(e+=n,26!==n)break}return e},i.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},i.prototype.toTwos=function(e){return 0!==this.negative?this.abs().inotn(e).iaddn(1):this.clone()},i.prototype.fromTwos=function(e){return this.testn(e-1)?this.notn(e).iaddn(1).ineg():this.clone()},i.prototype.isNeg=function(){return 0!==this.negative},i.prototype.neg=function(){return this.clone().ineg()},i.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},i.prototype.iuor=function(e){for(;this.length<e.length;)this.words[this.length++]=0;for(var t=0;t<e.length;t++)this.words[t]=this.words[t]|e.words[t];return this.strip()},i.prototype.ior=function(e){return r(0===(this.negative|e.negative)),this.iuor(e)},i.prototype.or=function(e){return this.length>e.length?this.clone().ior(e):e.clone().ior(this)},i.prototype.uor=function(e){return this.length>e.length?this.clone().iuor(e):e.clone().iuor(this)},i.prototype.iuand=function(e){var t;t=this.length>e.length?e:this;for(var n=0;n<t.length;n++)this.words[n]=this.words[n]&e.words[n];return this.length=t.length,this.strip()},i.prototype.iand=function(e){return r(0===(this.negative|e.negative)),this.iuand(e)},i.prototype.and=function(e){return this.length>e.length?this.clone().iand(e):e.clone().iand(this)},i.prototype.uand=function(e){return this.length>e.length?this.clone().iuand(e):e.clone().iuand(this)},i.prototype.iuxor=function(e){var t,n;this.length>e.length?(t=this,n=e):(t=e,n=this);for(var r=0;r<n.length;r++)this.words[r]=t.words[r]^n.words[r];if(this!==t)for(;r<t.length;r++)this.words[r]=t.words[r];return this.length=t.length,this.strip()},i.prototype.ixor=function(e){return r(0===(this.negative|e.negative)),this.iuxor(e)},i.prototype.xor=function(e){return this.length>e.length?this.clone().ixor(e):e.clone().ixor(this)},i.prototype.uxor=function(e){return this.length>e.length?this.clone().iuxor(e):e.clone().iuxor(this)},i.prototype.inotn=function(e){r("number"==typeof e&&e>=0);var t=0|Math.ceil(e/26),n=e%26;this._expand(t),n>0&&t--;for(var o=0;o<t;o++)this.words[o]=67108863&~this.words[o];return n>0&&(this.words[o]=~this.words[o]&67108863>>26-n),this.strip()},i.prototype.notn=function(e){return this.clone().inotn(e)},i.prototype.setn=function(e,t){r("number"==typeof e&&e>=0);var n=e/26|0,o=e%26;return this._expand(n+1),this.words[n]=t?this.words[n]|1<<o:this.words[n]&~(1<<o),this.strip()},i.prototype.iadd=function(e){var t,n,r;if(0!==this.negative&&0===e.negative)return this.negative=0,t=this.isub(e),this.negative^=1,this._normSign();if(0===this.negative&&0!==e.negative)return e.negative=0,t=this.isub(e),e.negative=1,t._normSign();this.length>e.length?(n=this,r=e):(n=e,r=this);for(var o=0,i=0;i<r.length;i++)t=(0|n.words[i])+(0|r.words[i])+o,this.words[i]=67108863&t,o=t>>>26;for(;0!==o&&i<n.length;i++)t=(0|n.words[i])+o,this.words[i]=67108863&t,o=t>>>26;if(this.length=n.length,0!==o)this.words[this.length]=o,this.length++;else if(n!==this)for(;i<n.length;i++)this.words[i]=n.words[i];return this},i.prototype.add=function(e){var t;return 0!==e.negative&&0===this.negative?(e.negative=0,t=this.sub(e),e.negative^=1,t):0===e.negative&&0!==this.negative?(this.negative=0,t=e.sub(this),this.negative=1,t):this.length>e.length?this.clone().iadd(e):e.clone().iadd(this)},i.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 n,r,o=this.cmp(e);if(0===o)return this.negative=0,this.length=1,this.words[0]=0,this;o>0?(n=this,r=e):(n=e,r=this);for(var i=0,a=0;a<r.length;a++)i=(t=(0|n.words[a])-(0|r.words[a])+i)>>26,this.words[a]=67108863&t;for(;0!==i&&a<n.length;a++)i=(t=(0|n.words[a])+i)>>26,this.words[a]=67108863&t;if(0===i&&a<n.length&&n!==this)for(;a<n.length;a++)this.words[a]=n.words[a];return this.length=Math.max(this.length,a),n!==this&&(this.negative=1),this.strip()},i.prototype.sub=function(e){return this.clone().isub(e)};var h=function(e,t,n){var r,o,i,a=e.words,s=t.words,c=n.words,u=0,l=0|a[0],d=8191&l,f=l>>>13,p=0|a[1],h=8191&p,y=p>>>13,b=0|a[2],g=8191&b,w=b>>>13,v=0|a[3],m=8191&v,I=v>>>13,E=0|a[4],S=8191&E,O=E>>>13,A=0|a[5],T=8191&A,_=A>>>13,k=0|a[6],x=8191&k,P=k>>>13,M=0|a[7],C=8191&M,N=M>>>13,j=0|a[8],D=8191&j,R=j>>>13,L=0|a[9],B=8191&L,K=L>>>13,U=0|s[0],F=8191&U,W=U>>>13,G=0|s[1],z=8191&G,q=G>>>13,$=0|s[2],H=8191&$,Y=$>>>13,V=0|s[3],J=8191&V,X=V>>>13,Z=0|s[4],Q=8191&Z,ee=Z>>>13,te=0|s[5],ne=8191&te,re=te>>>13,oe=0|s[6],ie=8191&oe,ae=oe>>>13,se=0|s[7],ce=8191&se,ue=se>>>13,le=0|s[8],de=8191&le,fe=le>>>13,pe=0|s[9],he=8191&pe,ye=pe>>>13;n.negative=e.negative^t.negative,n.length=19;var be=(u+(r=Math.imul(d,F))|0)+((8191&(o=(o=Math.imul(d,W))+Math.imul(f,F)|0))<<13)|0;u=((i=Math.imul(f,W))+(o>>>13)|0)+(be>>>26)|0,be&=67108863,r=Math.imul(h,F),o=(o=Math.imul(h,W))+Math.imul(y,F)|0,i=Math.imul(y,W);var ge=(u+(r=r+Math.imul(d,z)|0)|0)+((8191&(o=(o=o+Math.imul(d,q)|0)+Math.imul(f,z)|0))<<13)|0;u=((i=i+Math.imul(f,q)|0)+(o>>>13)|0)+(ge>>>26)|0,ge&=67108863,r=Math.imul(g,F),o=(o=Math.imul(g,W))+Math.imul(w,F)|0,i=Math.imul(w,W),r=r+Math.imul(h,z)|0,o=(o=o+Math.imul(h,q)|0)+Math.imul(y,z)|0,i=i+Math.imul(y,q)|0;var we=(u+(r=r+Math.imul(d,H)|0)|0)+((8191&(o=(o=o+Math.imul(d,Y)|0)+Math.imul(f,H)|0))<<13)|0;u=((i=i+Math.imul(f,Y)|0)+(o>>>13)|0)+(we>>>26)|0,we&=67108863,r=Math.imul(m,F),o=(o=Math.imul(m,W))+Math.imul(I,F)|0,i=Math.imul(I,W),r=r+Math.imul(g,z)|0,o=(o=o+Math.imul(g,q)|0)+Math.imul(w,z)|0,i=i+Math.imul(w,q)|0,r=r+Math.imul(h,H)|0,o=(o=o+Math.imul(h,Y)|0)+Math.imul(y,H)|0,i=i+Math.imul(y,Y)|0;var ve=(u+(r=r+Math.imul(d,J)|0)|0)+((8191&(o=(o=o+Math.imul(d,X)|0)+Math.imul(f,J)|0))<<13)|0;u=((i=i+Math.imul(f,X)|0)+(o>>>13)|0)+(ve>>>26)|0,ve&=67108863,r=Math.imul(S,F),o=(o=Math.imul(S,W))+Math.imul(O,F)|0,i=Math.imul(O,W),r=r+Math.imul(m,z)|0,o=(o=o+Math.imul(m,q)|0)+Math.imul(I,z)|0,i=i+Math.imul(I,q)|0,r=r+Math.imul(g,H)|0,o=(o=o+Math.imul(g,Y)|0)+Math.imul(w,H)|0,i=i+Math.imul(w,Y)|0,r=r+Math.imul(h,J)|0,o=(o=o+Math.imul(h,X)|0)+Math.imul(y,J)|0,i=i+Math.imul(y,X)|0;var me=(u+(r=r+Math.imul(d,Q)|0)|0)+((8191&(o=(o=o+Math.imul(d,ee)|0)+Math.imul(f,Q)|0))<<13)|0;u=((i=i+Math.imul(f,ee)|0)+(o>>>13)|0)+(me>>>26)|0,me&=67108863,r=Math.imul(T,F),o=(o=Math.imul(T,W))+Math.imul(_,F)|0,i=Math.imul(_,W),r=r+Math.imul(S,z)|0,o=(o=o+Math.imul(S,q)|0)+Math.imul(O,z)|0,i=i+Math.imul(O,q)|0,r=r+Math.imul(m,H)|0,o=(o=o+Math.imul(m,Y)|0)+Math.imul(I,H)|0,i=i+Math.imul(I,Y)|0,r=r+Math.imul(g,J)|0,o=(o=o+Math.imul(g,X)|0)+Math.imul(w,J)|0,i=i+Math.imul(w,X)|0,r=r+Math.imul(h,Q)|0,o=(o=o+Math.imul(h,ee)|0)+Math.imul(y,Q)|0,i=i+Math.imul(y,ee)|0;var Ie=(u+(r=r+Math.imul(d,ne)|0)|0)+((8191&(o=(o=o+Math.imul(d,re)|0)+Math.imul(f,ne)|0))<<13)|0;u=((i=i+Math.imul(f,re)|0)+(o>>>13)|0)+(Ie>>>26)|0,Ie&=67108863,r=Math.imul(x,F),o=(o=Math.imul(x,W))+Math.imul(P,F)|0,i=Math.imul(P,W),r=r+Math.imul(T,z)|0,o=(o=o+Math.imul(T,q)|0)+Math.imul(_,z)|0,i=i+Math.imul(_,q)|0,r=r+Math.imul(S,H)|0,o=(o=o+Math.imul(S,Y)|0)+Math.imul(O,H)|0,i=i+Math.imul(O,Y)|0,r=r+Math.imul(m,J)|0,o=(o=o+Math.imul(m,X)|0)+Math.imul(I,J)|0,i=i+Math.imul(I,X)|0,r=r+Math.imul(g,Q)|0,o=(o=o+Math.imul(g,ee)|0)+Math.imul(w,Q)|0,i=i+Math.imul(w,ee)|0,r=r+Math.imul(h,ne)|0,o=(o=o+Math.imul(h,re)|0)+Math.imul(y,ne)|0,i=i+Math.imul(y,re)|0;var Ee=(u+(r=r+Math.imul(d,ie)|0)|0)+((8191&(o=(o=o+Math.imul(d,ae)|0)+Math.imul(f,ie)|0))<<13)|0;u=((i=i+Math.imul(f,ae)|0)+(o>>>13)|0)+(Ee>>>26)|0,Ee&=67108863,r=Math.imul(C,F),o=(o=Math.imul(C,W))+Math.imul(N,F)|0,i=Math.imul(N,W),r=r+Math.imul(x,z)|0,o=(o=o+Math.imul(x,q)|0)+Math.imul(P,z)|0,i=i+Math.imul(P,q)|0,r=r+Math.imul(T,H)|0,o=(o=o+Math.imul(T,Y)|0)+Math.imul(_,H)|0,i=i+Math.imul(_,Y)|0,r=r+Math.imul(S,J)|0,o=(o=o+Math.imul(S,X)|0)+Math.imul(O,J)|0,i=i+Math.imul(O,X)|0,r=r+Math.imul(m,Q)|0,o=(o=o+Math.imul(m,ee)|0)+Math.imul(I,Q)|0,i=i+Math.imul(I,ee)|0,r=r+Math.imul(g,ne)|0,o=(o=o+Math.imul(g,re)|0)+Math.imul(w,ne)|0,i=i+Math.imul(w,re)|0,r=r+Math.imul(h,ie)|0,o=(o=o+Math.imul(h,ae)|0)+Math.imul(y,ie)|0,i=i+Math.imul(y,ae)|0;var Se=(u+(r=r+Math.imul(d,ce)|0)|0)+((8191&(o=(o=o+Math.imul(d,ue)|0)+Math.imul(f,ce)|0))<<13)|0;u=((i=i+Math.imul(f,ue)|0)+(o>>>13)|0)+(Se>>>26)|0,Se&=67108863,r=Math.imul(D,F),o=(o=Math.imul(D,W))+Math.imul(R,F)|0,i=Math.imul(R,W),r=r+Math.imul(C,z)|0,o=(o=o+Math.imul(C,q)|0)+Math.imul(N,z)|0,i=i+Math.imul(N,q)|0,r=r+Math.imul(x,H)|0,o=(o=o+Math.imul(x,Y)|0)+Math.imul(P,H)|0,i=i+Math.imul(P,Y)|0,r=r+Math.imul(T,J)|0,o=(o=o+Math.imul(T,X)|0)+Math.imul(_,J)|0,i=i+Math.imul(_,X)|0,r=r+Math.imul(S,Q)|0,o=(o=o+Math.imul(S,ee)|0)+Math.imul(O,Q)|0,i=i+Math.imul(O,ee)|0,r=r+Math.imul(m,ne)|0,o=(o=o+Math.imul(m,re)|0)+Math.imul(I,ne)|0,i=i+Math.imul(I,re)|0,r=r+Math.imul(g,ie)|0,o=(o=o+Math.imul(g,ae)|0)+Math.imul(w,ie)|0,i=i+Math.imul(w,ae)|0,r=r+Math.imul(h,ce)|0,o=(o=o+Math.imul(h,ue)|0)+Math.imul(y,ce)|0,i=i+Math.imul(y,ue)|0;var Oe=(u+(r=r+Math.imul(d,de)|0)|0)+((8191&(o=(o=o+Math.imul(d,fe)|0)+Math.imul(f,de)|0))<<13)|0;u=((i=i+Math.imul(f,fe)|0)+(o>>>13)|0)+(Oe>>>26)|0,Oe&=67108863,r=Math.imul(B,F),o=(o=Math.imul(B,W))+Math.imul(K,F)|0,i=Math.imul(K,W),r=r+Math.imul(D,z)|0,o=(o=o+Math.imul(D,q)|0)+Math.imul(R,z)|0,i=i+Math.imul(R,q)|0,r=r+Math.imul(C,H)|0,o=(o=o+Math.imul(C,Y)|0)+Math.imul(N,H)|0,i=i+Math.imul(N,Y)|0,r=r+Math.imul(x,J)|0,o=(o=o+Math.imul(x,X)|0)+Math.imul(P,J)|0,i=i+Math.imul(P,X)|0,r=r+Math.imul(T,Q)|0,o=(o=o+Math.imul(T,ee)|0)+Math.imul(_,Q)|0,i=i+Math.imul(_,ee)|0,r=r+Math.imul(S,ne)|0,o=(o=o+Math.imul(S,re)|0)+Math.imul(O,ne)|0,i=i+Math.imul(O,re)|0,r=r+Math.imul(m,ie)|0,o=(o=o+Math.imul(m,ae)|0)+Math.imul(I,ie)|0,i=i+Math.imul(I,ae)|0,r=r+Math.imul(g,ce)|0,o=(o=o+Math.imul(g,ue)|0)+Math.imul(w,ce)|0,i=i+Math.imul(w,ue)|0,r=r+Math.imul(h,de)|0,o=(o=o+Math.imul(h,fe)|0)+Math.imul(y,de)|0,i=i+Math.imul(y,fe)|0;var Ae=(u+(r=r+Math.imul(d,he)|0)|0)+((8191&(o=(o=o+Math.imul(d,ye)|0)+Math.imul(f,he)|0))<<13)|0;u=((i=i+Math.imul(f,ye)|0)+(o>>>13)|0)+(Ae>>>26)|0,Ae&=67108863,r=Math.imul(B,z),o=(o=Math.imul(B,q))+Math.imul(K,z)|0,i=Math.imul(K,q),r=r+Math.imul(D,H)|0,o=(o=o+Math.imul(D,Y)|0)+Math.imul(R,H)|0,i=i+Math.imul(R,Y)|0,r=r+Math.imul(C,J)|0,o=(o=o+Math.imul(C,X)|0)+Math.imul(N,J)|0,i=i+Math.imul(N,X)|0,r=r+Math.imul(x,Q)|0,o=(o=o+Math.imul(x,ee)|0)+Math.imul(P,Q)|0,i=i+Math.imul(P,ee)|0,r=r+Math.imul(T,ne)|0,o=(o=o+Math.imul(T,re)|0)+Math.imul(_,ne)|0,i=i+Math.imul(_,re)|0,r=r+Math.imul(S,ie)|0,o=(o=o+Math.imul(S,ae)|0)+Math.imul(O,ie)|0,i=i+Math.imul(O,ae)|0,r=r+Math.imul(m,ce)|0,o=(o=o+Math.imul(m,ue)|0)+Math.imul(I,ce)|0,i=i+Math.imul(I,ue)|0,r=r+Math.imul(g,de)|0,o=(o=o+Math.imul(g,fe)|0)+Math.imul(w,de)|0,i=i+Math.imul(w,fe)|0;var Te=(u+(r=r+Math.imul(h,he)|0)|0)+((8191&(o=(o=o+Math.imul(h,ye)|0)+Math.imul(y,he)|0))<<13)|0;u=((i=i+Math.imul(y,ye)|0)+(o>>>13)|0)+(Te>>>26)|0,Te&=67108863,r=Math.imul(B,H),o=(o=Math.imul(B,Y))+Math.imul(K,H)|0,i=Math.imul(K,Y),r=r+Math.imul(D,J)|0,o=(o=o+Math.imul(D,X)|0)+Math.imul(R,J)|0,i=i+Math.imul(R,X)|0,r=r+Math.imul(C,Q)|0,o=(o=o+Math.imul(C,ee)|0)+Math.imul(N,Q)|0,i=i+Math.imul(N,ee)|0,r=r+Math.imul(x,ne)|0,o=(o=o+Math.imul(x,re)|0)+Math.imul(P,ne)|0,i=i+Math.imul(P,re)|0,r=r+Math.imul(T,ie)|0,o=(o=o+Math.imul(T,ae)|0)+Math.imul(_,ie)|0,i=i+Math.imul(_,ae)|0,r=r+Math.imul(S,ce)|0,o=(o=o+Math.imul(S,ue)|0)+Math.imul(O,ce)|0,i=i+Math.imul(O,ue)|0,r=r+Math.imul(m,de)|0,o=(o=o+Math.imul(m,fe)|0)+Math.imul(I,de)|0,i=i+Math.imul(I,fe)|0;var _e=(u+(r=r+Math.imul(g,he)|0)|0)+((8191&(o=(o=o+Math.imul(g,ye)|0)+Math.imul(w,he)|0))<<13)|0;u=((i=i+Math.imul(w,ye)|0)+(o>>>13)|0)+(_e>>>26)|0,_e&=67108863,r=Math.imul(B,J),o=(o=Math.imul(B,X))+Math.imul(K,J)|0,i=Math.imul(K,X),r=r+Math.imul(D,Q)|0,o=(o=o+Math.imul(D,ee)|0)+Math.imul(R,Q)|0,i=i+Math.imul(R,ee)|0,r=r+Math.imul(C,ne)|0,o=(o=o+Math.imul(C,re)|0)+Math.imul(N,ne)|0,i=i+Math.imul(N,re)|0,r=r+Math.imul(x,ie)|0,o=(o=o+Math.imul(x,ae)|0)+Math.imul(P,ie)|0,i=i+Math.imul(P,ae)|0,r=r+Math.imul(T,ce)|0,o=(o=o+Math.imul(T,ue)|0)+Math.imul(_,ce)|0,i=i+Math.imul(_,ue)|0,r=r+Math.imul(S,de)|0,o=(o=o+Math.imul(S,fe)|0)+Math.imul(O,de)|0,i=i+Math.imul(O,fe)|0;var ke=(u+(r=r+Math.imul(m,he)|0)|0)+((8191&(o=(o=o+Math.imul(m,ye)|0)+Math.imul(I,he)|0))<<13)|0;u=((i=i+Math.imul(I,ye)|0)+(o>>>13)|0)+(ke>>>26)|0,ke&=67108863,r=Math.imul(B,Q),o=(o=Math.imul(B,ee))+Math.imul(K,Q)|0,i=Math.imul(K,ee),r=r+Math.imul(D,ne)|0,o=(o=o+Math.imul(D,re)|0)+Math.imul(R,ne)|0,i=i+Math.imul(R,re)|0,r=r+Math.imul(C,ie)|0,o=(o=o+Math.imul(C,ae)|0)+Math.imul(N,ie)|0,i=i+Math.imul(N,ae)|0,r=r+Math.imul(x,ce)|0,o=(o=o+Math.imul(x,ue)|0)+Math.imul(P,ce)|0,i=i+Math.imul(P,ue)|0,r=r+Math.imul(T,de)|0,o=(o=o+Math.imul(T,fe)|0)+Math.imul(_,de)|0,i=i+Math.imul(_,fe)|0;var xe=(u+(r=r+Math.imul(S,he)|0)|0)+((8191&(o=(o=o+Math.imul(S,ye)|0)+Math.imul(O,he)|0))<<13)|0;u=((i=i+Math.imul(O,ye)|0)+(o>>>13)|0)+(xe>>>26)|0,xe&=67108863,r=Math.imul(B,ne),o=(o=Math.imul(B,re))+Math.imul(K,ne)|0,i=Math.imul(K,re),r=r+Math.imul(D,ie)|0,o=(o=o+Math.imul(D,ae)|0)+Math.imul(R,ie)|0,i=i+Math.imul(R,ae)|0,r=r+Math.imul(C,ce)|0,o=(o=o+Math.imul(C,ue)|0)+Math.imul(N,ce)|0,i=i+Math.imul(N,ue)|0,r=r+Math.imul(x,de)|0,o=(o=o+Math.imul(x,fe)|0)+Math.imul(P,de)|0,i=i+Math.imul(P,fe)|0;var Pe=(u+(r=r+Math.imul(T,he)|0)|0)+((8191&(o=(o=o+Math.imul(T,ye)|0)+Math.imul(_,he)|0))<<13)|0;u=((i=i+Math.imul(_,ye)|0)+(o>>>13)|0)+(Pe>>>26)|0,Pe&=67108863,r=Math.imul(B,ie),o=(o=Math.imul(B,ae))+Math.imul(K,ie)|0,i=Math.imul(K,ae),r=r+Math.imul(D,ce)|0,o=(o=o+Math.imul(D,ue)|0)+Math.imul(R,ce)|0,i=i+Math.imul(R,ue)|0,r=r+Math.imul(C,de)|0,o=(o=o+Math.imul(C,fe)|0)+Math.imul(N,de)|0,i=i+Math.imul(N,fe)|0;var Me=(u+(r=r+Math.imul(x,he)|0)|0)+((8191&(o=(o=o+Math.imul(x,ye)|0)+Math.imul(P,he)|0))<<13)|0;u=((i=i+Math.imul(P,ye)|0)+(o>>>13)|0)+(Me>>>26)|0,Me&=67108863,r=Math.imul(B,ce),o=(o=Math.imul(B,ue))+Math.imul(K,ce)|0,i=Math.imul(K,ue),r=r+Math.imul(D,de)|0,o=(o=o+Math.imul(D,fe)|0)+Math.imul(R,de)|0,i=i+Math.imul(R,fe)|0;var Ce=(u+(r=r+Math.imul(C,he)|0)|0)+((8191&(o=(o=o+Math.imul(C,ye)|0)+Math.imul(N,he)|0))<<13)|0;u=((i=i+Math.imul(N,ye)|0)+(o>>>13)|0)+(Ce>>>26)|0,Ce&=67108863,r=Math.imul(B,de),o=(o=Math.imul(B,fe))+Math.imul(K,de)|0,i=Math.imul(K,fe);var Ne=(u+(r=r+Math.imul(D,he)|0)|0)+((8191&(o=(o=o+Math.imul(D,ye)|0)+Math.imul(R,he)|0))<<13)|0;u=((i=i+Math.imul(R,ye)|0)+(o>>>13)|0)+(Ne>>>26)|0,Ne&=67108863;var je=(u+(r=Math.imul(B,he))|0)+((8191&(o=(o=Math.imul(B,ye))+Math.imul(K,he)|0))<<13)|0;return u=((i=Math.imul(K,ye))+(o>>>13)|0)+(je>>>26)|0,je&=67108863,c[0]=be,c[1]=ge,c[2]=we,c[3]=ve,c[4]=me,c[5]=Ie,c[6]=Ee,c[7]=Se,c[8]=Oe,c[9]=Ae,c[10]=Te,c[11]=_e,c[12]=ke,c[13]=xe,c[14]=Pe,c[15]=Me,c[16]=Ce,c[17]=Ne,c[18]=je,0!==u&&(c[19]=u,n.length++),n};function y(e,t,n){return(new b).mulp(e,t,n)}function b(e,t){this.x=e,this.y=t}Math.imul||(h=p),i.prototype.mulTo=function(e,t){var n,r=this.length+e.length;return n=10===this.length&&10===e.length?h(this,e,t):r<63?p(this,e,t):r<1024?function(e,t,n){n.negative=t.negative^e.negative,n.length=e.length+t.length;for(var r=0,o=0,i=0;i<n.length-1;i++){var a=o;o=0;for(var s=67108863&r,c=Math.min(i,t.length-1),u=Math.max(0,i-e.length+1);u<=c;u++){var l=i-u,d=(0|e.words[l])*(0|t.words[u]),f=67108863&d;s=67108863&(f=f+s|0),o+=(a=(a=a+(d/67108864|0)|0)+(f>>>26)|0)>>>26,a&=67108863}n.words[i]=s,r=a,a=o}return 0!==r?n.words[i]=r:n.length--,n.strip()}(this,e,t):y(this,e,t),n},b.prototype.makeRBT=function(e){for(var t=new Array(e),n=i.prototype._countBits(e)-1,r=0;r<e;r++)t[r]=this.revBin(r,n,e);return t},b.prototype.revBin=function(e,t,n){if(0===e||e===n-1)return e;for(var r=0,o=0;o<t;o++)r|=(1&e)<<t-o-1,e>>=1;return r},b.prototype.permute=function(e,t,n,r,o,i){for(var a=0;a<i;a++)r[a]=t[e[a]],o[a]=n[e[a]]},b.prototype.transform=function(e,t,n,r,o,i){this.permute(i,e,t,n,r,o);for(var a=1;a<o;a<<=1)for(var s=a<<1,c=Math.cos(2*Math.PI/s),u=Math.sin(2*Math.PI/s),l=0;l<o;l+=s)for(var d=c,f=u,p=0;p<a;p++){var h=n[l+p],y=r[l+p],b=n[l+p+a],g=r[l+p+a],w=d*b-f*g;g=d*g+f*b,b=w,n[l+p]=h+b,r[l+p]=y+g,n[l+p+a]=h-b,r[l+p+a]=y-g,p!==s&&(w=c*d-u*f,f=c*f+u*d,d=w)}},b.prototype.guessLen13b=function(e,t){var n=1|Math.max(t,e),r=1&n,o=0;for(n=n/2|0;n;n>>>=1)o++;return 1<<o+1+r},b.prototype.conjugate=function(e,t,n){if(!(n<=1))for(var r=0;r<n/2;r++){var o=e[r];e[r]=e[n-r-1],e[n-r-1]=o,o=t[r],t[r]=-t[n-r-1],t[n-r-1]=-o}},b.prototype.normalize13b=function(e,t){for(var n=0,r=0;r<t/2;r++){var o=8192*Math.round(e[2*r+1]/t)+Math.round(e[2*r]/t)+n;e[r]=67108863&o,n=o<67108864?0:o/67108864|0}return e},b.prototype.convert13b=function(e,t,n,o){for(var i=0,a=0;a<t;a++)i+=0|e[a],n[2*a]=8191&i,i>>>=13,n[2*a+1]=8191&i,i>>>=13;for(a=2*t;a<o;++a)n[a]=0;r(0===i),r(!(-8192&i))},b.prototype.stub=function(e){for(var t=new Array(e),n=0;n<e;n++)t[n]=0;return t},b.prototype.mulp=function(e,t,n){var r=2*this.guessLen13b(e.length,t.length),o=this.makeRBT(r),i=this.stub(r),a=new Array(r),s=new Array(r),c=new Array(r),u=new Array(r),l=new Array(r),d=new Array(r),f=n.words;f.length=r,this.convert13b(e.words,e.length,a,r),this.convert13b(t.words,t.length,u,r),this.transform(a,i,s,c,r,o),this.transform(u,i,l,d,r,o);for(var p=0;p<r;p++){var h=s[p]*l[p]-c[p]*d[p];c[p]=s[p]*d[p]+c[p]*l[p],s[p]=h}return this.conjugate(s,c,r),this.transform(s,c,f,i,r,o),this.conjugate(f,i,r),this.normalize13b(f,r),n.negative=e.negative^t.negative,n.length=e.length+t.length,n.strip()},i.prototype.mul=function(e){var t=new i(null);return t.words=new Array(this.length+e.length),this.mulTo(e,t)},i.prototype.mulf=function(e){var t=new i(null);return t.words=new Array(this.length+e.length),y(this,e,t)},i.prototype.imul=function(e){return this.clone().mulTo(e,this)},i.prototype.imuln=function(e){r("number"==typeof e),r(e<67108864);for(var t=0,n=0;n<this.length;n++){var o=(0|this.words[n])*e,i=(67108863&o)+(67108863&t);t>>=26,t+=o/67108864|0,t+=i>>>26,this.words[n]=67108863&i}return 0!==t&&(this.words[n]=t,this.length++),this.length=0===e?1:this.length,this},i.prototype.muln=function(e){return this.clone().imuln(e)},i.prototype.sqr=function(){return this.mul(this)},i.prototype.isqr=function(){return this.imul(this.clone())},i.prototype.pow=function(e){var t=function(e){for(var t=new Array(e.bitLength()),n=0;n<t.length;n++){var r=n/26|0,o=n%26;t[n]=(e.words[r]&1<<o)>>>o}return t}(e);if(0===t.length)return new i(1);for(var n=this,r=0;r<t.length&&0===t[r];r++,n=n.sqr());if(++r<t.length)for(var o=n.sqr();r<t.length;r++,o=o.sqr())0!==t[r]&&(n=n.mul(o));return n},i.prototype.iushln=function(e){r("number"==typeof e&&e>=0);var t,n=e%26,o=(e-n)/26,i=67108863>>>26-n<<26-n;if(0!==n){var a=0;for(t=0;t<this.length;t++){var s=this.words[t]&i,c=(0|this.words[t])-s<<n;this.words[t]=c|a,a=s>>>26-n}a&&(this.words[t]=a,this.length++)}if(0!==o){for(t=this.length-1;t>=0;t--)this.words[t+o]=this.words[t];for(t=0;t<o;t++)this.words[t]=0;this.length+=o}return this.strip()},i.prototype.ishln=function(e){return r(0===this.negative),this.iushln(e)},i.prototype.iushrn=function(e,t,n){var o;r("number"==typeof e&&e>=0),o=t?(t-t%26)/26:0;var i=e%26,a=Math.min((e-i)/26,this.length),s=67108863^67108863>>>i<<i,c=n;if(o-=a,o=Math.max(0,o),c){for(var u=0;u<a;u++)c.words[u]=this.words[u];c.length=a}if(0===a);else if(this.length>a)for(this.length-=a,u=0;u<this.length;u++)this.words[u]=this.words[u+a];else this.words[0]=0,this.length=1;var l=0;for(u=this.length-1;u>=0&&(0!==l||u>=o);u--){var d=0|this.words[u];this.words[u]=l<<26-i|d>>>i,l=d&s}return c&&0!==l&&(c.words[c.length++]=l),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},i.prototype.ishrn=function(e,t,n){return r(0===this.negative),this.iushrn(e,t,n)},i.prototype.shln=function(e){return this.clone().ishln(e)},i.prototype.ushln=function(e){return this.clone().iushln(e)},i.prototype.shrn=function(e){return this.clone().ishrn(e)},i.prototype.ushrn=function(e){return this.clone().iushrn(e)},i.prototype.testn=function(e){r("number"==typeof e&&e>=0);var t=e%26,n=(e-t)/26,o=1<<t;return!(this.length<=n)&&!!(this.words[n]&o)},i.prototype.imaskn=function(e){r("number"==typeof e&&e>=0);var t=e%26,n=(e-t)/26;if(r(0===this.negative,"imaskn works only with positive numbers"),this.length<=n)return this;if(0!==t&&n++,this.length=Math.min(n,this.length),0!==t){var o=67108863^67108863>>>t<<t;this.words[this.length-1]&=o}return 0===this.length&&(this.words[0]=0,this.length=1),this.strip()},i.prototype.maskn=function(e){return this.clone().imaskn(e)},i.prototype.iaddn=function(e){return r("number"==typeof e),r(e<67108864),e<0?this.isubn(-e):0!==this.negative?1===this.length&&(0|this.words[0])<e?(this.words[0]=e-(0|this.words[0]),this.negative=0,this):(this.negative=0,this.isubn(e),this.negative=1,this):this._iaddn(e)},i.prototype._iaddn=function(e){this.words[0]+=e;for(var t=0;t<this.length&&this.words[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},i.prototype.isubn=function(e){if(r("number"==typeof e),r(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<this.length&&this.words[t]<0;t++)this.words[t]+=67108864,this.words[t+1]-=1;return this.strip()},i.prototype.addn=function(e){return this.clone().iaddn(e)},i.prototype.subn=function(e){return this.clone().isubn(e)},i.prototype.iabs=function(){return this.negative=0,this},i.prototype.abs=function(){return this.clone().iabs()},i.prototype._ishlnsubmul=function(e,t,n){var o,i,a=e.length+n;this._expand(a);var s=0;for(o=0;o<e.length;o++){i=(0|this.words[o+n])+s;var c=(0|e.words[o])*t;s=((i-=67108863&c)>>26)-(c/67108864|0),this.words[o+n]=67108863&i}for(;o<this.length-n;o++)s=(i=(0|this.words[o+n])+s)>>26,this.words[o+n]=67108863&i;if(0===s)return this.strip();for(r(-1===s),s=0,o=0;o<this.length;o++)s=(i=-(0|this.words[o])+s)>>26,this.words[o]=67108863&i;return this.negative=1,this.strip()},i.prototype._wordDiv=function(e,t){var n=(this.length,e.length),r=this.clone(),o=e,a=0|o.words[o.length-1];0!==(n=26-this._countBits(a))&&(o=o.ushln(n),r.iushln(n),a=0|o.words[o.length-1]);var s,c=r.length-o.length;if("mod"!==t){(s=new i(null)).length=c+1,s.words=new Array(s.length);for(var u=0;u<s.length;u++)s.words[u]=0}var l=r.clone()._ishlnsubmul(o,1,c);0===l.negative&&(r=l,s&&(s.words[c]=1));for(var d=c-1;d>=0;d--){var f=67108864*(0|r.words[o.length+d])+(0|r.words[o.length+d-1]);for(f=Math.min(f/a|0,67108863),r._ishlnsubmul(o,f,d);0!==r.negative;)f--,r.negative=0,r._ishlnsubmul(o,1,d),r.isZero()||(r.negative^=1);s&&(s.words[d]=f)}return s&&s.strip(),r.strip(),"div"!==t&&0!==n&&r.iushrn(n),{div:s||null,mod:r}},i.prototype.divmod=function(e,t,n){return r(!e.isZero()),this.isZero()?{div:new i(0),mod:new i(0)}:0!==this.negative&&0===e.negative?(s=this.neg().divmod(e,t),"mod"!==t&&(o=s.div.neg()),"div"!==t&&(a=s.mod.neg(),n&&0!==a.negative&&a.iadd(e)),{div:o,mod:a}):0===this.negative&&0!==e.negative?(s=this.divmod(e.neg(),t),"mod"!==t&&(o=s.div.neg()),{div:o,mod:s.mod}):0!==(this.negative&e.negative)?(s=this.neg().divmod(e.neg(),t),"div"!==t&&(a=s.mod.neg(),n&&0!==a.negative&&a.isub(e)),{div:s.div,mod:a}):e.length>this.length||this.cmp(e)<0?{div:new i(0),mod:this}:1===e.length?"div"===t?{div:this.divn(e.words[0]),mod:null}:"mod"===t?{div:null,mod:new i(this.modn(e.words[0]))}:{div:this.divn(e.words[0]),mod:new i(this.modn(e.words[0]))}:this._wordDiv(e,t);var o,a,s},i.prototype.div=function(e){return this.divmod(e,"div",!1).div},i.prototype.mod=function(e){return this.divmod(e,"mod",!1).mod},i.prototype.umod=function(e){return this.divmod(e,"mod",!0).mod},i.prototype.divRound=function(e){var t=this.divmod(e);if(t.mod.isZero())return t.div;var n=0!==t.div.negative?t.mod.isub(e):t.mod,r=e.ushrn(1),o=e.andln(1),i=n.cmp(r);return i<0||1===o&&0===i?t.div:0!==t.div.negative?t.div.isubn(1):t.div.iaddn(1)},i.prototype.modn=function(e){r(e<=67108863);for(var t=(1<<26)%e,n=0,o=this.length-1;o>=0;o--)n=(t*n+(0|this.words[o]))%e;return n},i.prototype.idivn=function(e){r(e<=67108863);for(var t=0,n=this.length-1;n>=0;n--){var o=(0|this.words[n])+67108864*t;this.words[n]=o/e|0,t=o%e}return this.strip()},i.prototype.divn=function(e){return this.clone().idivn(e)},i.prototype.egcd=function(e){r(0===e.negative),r(!e.isZero());var t=this,n=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var o=new i(1),a=new i(0),s=new i(0),c=new i(1),u=0;t.isEven()&&n.isEven();)t.iushrn(1),n.iushrn(1),++u;for(var l=n.clone(),d=t.clone();!t.isZero();){for(var f=0,p=1;0===(t.words[0]&p)&&f<26;++f,p<<=1);if(f>0)for(t.iushrn(f);f-- >0;)(o.isOdd()||a.isOdd())&&(o.iadd(l),a.isub(d)),o.iushrn(1),a.iushrn(1);for(var h=0,y=1;0===(n.words[0]&y)&&h<26;++h,y<<=1);if(h>0)for(n.iushrn(h);h-- >0;)(s.isOdd()||c.isOdd())&&(s.iadd(l),c.isub(d)),s.iushrn(1),c.iushrn(1);t.cmp(n)>=0?(t.isub(n),o.isub(s),a.isub(c)):(n.isub(t),s.isub(o),c.isub(a))}return{a:s,b:c,gcd:n.iushln(u)}},i.prototype._invmp=function(e){r(0===e.negative),r(!e.isZero());var t=this,n=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var o,a=new i(1),s=new i(0),c=n.clone();t.cmpn(1)>0&&n.cmpn(1)>0;){for(var u=0,l=1;0===(t.words[0]&l)&&u<26;++u,l<<=1);if(u>0)for(t.iushrn(u);u-- >0;)a.isOdd()&&a.iadd(c),a.iushrn(1);for(var d=0,f=1;0===(n.words[0]&f)&&d<26;++d,f<<=1);if(d>0)for(n.iushrn(d);d-- >0;)s.isOdd()&&s.iadd(c),s.iushrn(1);t.cmp(n)>=0?(t.isub(n),a.isub(s)):(n.isub(t),s.isub(a))}return(o=0===t.cmpn(1)?a:s).cmpn(0)<0&&o.iadd(e),o},i.prototype.gcd=function(e){if(this.isZero())return e.abs();if(e.isZero())return this.abs();var t=this.clone(),n=e.clone();t.negative=0,n.negative=0;for(var r=0;t.isEven()&&n.isEven();r++)t.iushrn(1),n.iushrn(1);for(;;){for(;t.isEven();)t.iushrn(1);for(;n.isEven();)n.iushrn(1);var o=t.cmp(n);if(o<0){var i=t;t=n,n=i}else if(0===o||0===n.cmpn(1))break;t.isub(n)}return n.iushln(r)},i.prototype.invm=function(e){return this.egcd(e).a.umod(e)},i.prototype.isEven=function(){return!(1&this.words[0])},i.prototype.isOdd=function(){return!(1&~this.words[0])},i.prototype.andln=function(e){return this.words[0]&e},i.prototype.bincn=function(e){r("number"==typeof e);var t=e%26,n=(e-t)/26,o=1<<t;if(this.length<=n)return this._expand(n+1),this.words[n]|=o,this;for(var i=o,a=n;0!==i&&a<this.length;a++){var s=0|this.words[a];i=(s+=i)>>>26,s&=67108863,this.words[a]=s}return 0!==i&&(this.words[a]=i,this.length++),this},i.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},i.prototype.cmpn=function(e){var t,n=e<0;if(0!==this.negative&&!n)return-1;if(0===this.negative&&n)return 1;if(this.strip(),this.length>1)t=1;else{n&&(e=-e),r(e<=67108863,"Number is too big");var o=0|this.words[0];t=o===e?0:o<e?-1:1}return 0!==this.negative?0|-t:t},i.prototype.cmp=function(e){if(0!==this.negative&&0===e.negative)return-1;if(0===this.negative&&0!==e.negative)return 1;var t=this.ucmp(e);return 0!==this.negative?0|-t:t},i.prototype.ucmp=function(e){if(this.length>e.length)return 1;if(this.length<e.length)return-1;for(var t=0,n=this.length-1;n>=0;n--){var r=0|this.words[n],o=0|e.words[n];if(r!==o){r<o?t=-1:r>o&&(t=1);break}}return t},i.prototype.gtn=function(e){return 1===this.cmpn(e)},i.prototype.gt=function(e){return 1===this.cmp(e)},i.prototype.gten=function(e){return this.cmpn(e)>=0},i.prototype.gte=function(e){return this.cmp(e)>=0},i.prototype.ltn=function(e){return-1===this.cmpn(e)},i.prototype.lt=function(e){return-1===this.cmp(e)},i.prototype.lten=function(e){return this.cmpn(e)<=0},i.prototype.lte=function(e){return this.cmp(e)<=0},i.prototype.eqn=function(e){return 0===this.cmpn(e)},i.prototype.eq=function(e){return 0===this.cmp(e)},i.red=function(e){return new S(e)},i.prototype.toRed=function(e){return r(!this.red,"Already a number in reduction context"),r(0===this.negative,"red works only with positives"),e.convertTo(this)._forceRed(e)},i.prototype.fromRed=function(){return r(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},i.prototype._forceRed=function(e){return this.red=e,this},i.prototype.forceRed=function(e){return r(!this.red,"Already a number in reduction context"),this._forceRed(e)},i.prototype.redAdd=function(e){return r(this.red,"redAdd works only with red numbers"),this.red.add(this,e)},i.prototype.redIAdd=function(e){return r(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,e)},i.prototype.redSub=function(e){return r(this.red,"redSub works only with red numbers"),this.red.sub(this,e)},i.prototype.redISub=function(e){return r(this.red,"redISub works only with red numbers"),this.red.isub(this,e)},i.prototype.redShl=function(e){return r(this.red,"redShl works only with red numbers"),this.red.shl(this,e)},i.prototype.redMul=function(e){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.mul(this,e)},i.prototype.redIMul=function(e){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.imul(this,e)},i.prototype.redSqr=function(){return r(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},i.prototype.redISqr=function(){return r(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},i.prototype.redSqrt=function(){return r(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},i.prototype.redInvm=function(){return r(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},i.prototype.redNeg=function(){return r(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},i.prototype.redPow=function(e){return r(this.red&&!e.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,e)};var g={k256:null,p224:null,p192:null,p25519:null};function w(e,t){this.name=e,this.p=new i(t,16),this.n=this.p.bitLength(),this.k=new i(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function v(){w.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function m(){w.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function I(){w.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function E(){w.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function S(e){if("string"==typeof e){var t=i._prime(e);this.m=t.p,this.prime=t}else r(e.gtn(1),"modulus must be greater than 1"),this.m=e,this.prime=null}function O(e){S.call(this,e),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new i(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)}w.prototype._tmp=function(){var e=new i(null);return e.words=new Array(Math.ceil(this.n/13)),e},w.prototype.ireduce=function(e){var t,n=e;do{this.split(n,this.tmp),t=(n=(n=this.imulK(n)).iadd(this.tmp)).bitLength()}while(t>this.n);var r=t<this.n?-1:n.ucmp(this.p);return 0===r?(n.words[0]=0,n.length=1):r>0?n.isub(this.p):void 0!==n.strip?n.strip():n._strip(),n},w.prototype.split=function(e,t){e.iushrn(this.n,0,t)},w.prototype.imulK=function(e){return e.imul(this.k)},o(v,w),v.prototype.split=function(e,t){for(var n=4194303,r=Math.min(e.length,9),o=0;o<r;o++)t.words[o]=e.words[o];if(t.length=r,e.length<=9)return e.words[0]=0,void(e.length=1);var i=e.words[9];for(t.words[t.length++]=i&n,o=10;o<e.length;o++){var a=0|e.words[o];e.words[o-10]=(a&n)<<4|i>>>22,i=a}i>>>=22,e.words[o-10]=i,0===i&&e.length>10?e.length-=10:e.length-=9},v.prototype.imulK=function(e){e.words[e.length]=0,e.words[e.length+1]=0,e.length+=2;for(var t=0,n=0;n<e.length;n++){var r=0|e.words[n];t+=977*r,e.words[n]=67108863&t,t=64*r+(t/67108864|0)}return 0===e.words[e.length-1]&&(e.length--,0===e.words[e.length-1]&&e.length--),e},o(m,w),o(I,w),o(E,w),E.prototype.imulK=function(e){for(var t=0,n=0;n<e.length;n++){var r=19*(0|e.words[n])+t,o=67108863&r;r>>>=26,e.words[n]=o,t=r}return 0!==t&&(e.words[e.length++]=t),e},i._prime=function(e){if(g[e])return g[e];var t;if("k256"===e)t=new v;else if("p224"===e)t=new m;else if("p192"===e)t=new I;else{if("p25519"!==e)throw new Error("Unknown prime "+e);t=new E}return g[e]=t,t},S.prototype._verify1=function(e){r(0===e.negative,"red works only with positives"),r(e.red,"red works only with red numbers")},S.prototype._verify2=function(e,t){r(0===(e.negative|t.negative),"red works only with positives"),r(e.red&&e.red===t.red,"red works only with red numbers")},S.prototype.imod=function(e){return this.prime?this.prime.ireduce(e)._forceRed(this):e.umod(this.m)._forceRed(this)},S.prototype.neg=function(e){return e.isZero()?e.clone():this.m.sub(e)._forceRed(this)},S.prototype.add=function(e,t){this._verify2(e,t);var n=e.add(t);return n.cmp(this.m)>=0&&n.isub(this.m),n._forceRed(this)},S.prototype.iadd=function(e,t){this._verify2(e,t);var n=e.iadd(t);return n.cmp(this.m)>=0&&n.isub(this.m),n},S.prototype.sub=function(e,t){this._verify2(e,t);var n=e.sub(t);return n.cmpn(0)<0&&n.iadd(this.m),n._forceRed(this)},S.prototype.isub=function(e,t){this._verify2(e,t);var n=e.isub(t);return n.cmpn(0)<0&&n.iadd(this.m),n},S.prototype.shl=function(e,t){return this._verify1(e),this.imod(e.ushln(t))},S.prototype.imul=function(e,t){return this._verify2(e,t),this.imod(e.imul(t))},S.prototype.mul=function(e,t){return this._verify2(e,t),this.imod(e.mul(t))},S.prototype.isqr=function(e){return this.imul(e,e.clone())},S.prototype.sqr=function(e){return this.mul(e,e)},S.prototype.sqrt=function(e){if(e.isZero())return e.clone();var t=this.m.andln(3);if(r(t%2==1),3===t){var n=this.m.add(new i(1)).iushrn(2);return this.pow(e,n)}for(var o=this.m.subn(1),a=0;!o.isZero()&&0===o.andln(1);)a++,o.iushrn(1);r(!o.isZero());var s=new i(1).toRed(this),c=s.redNeg(),u=this.m.subn(1).iushrn(1),l=this.m.bitLength();for(l=new i(2*l*l).toRed(this);0!==this.pow(l,u).cmp(c);)l.redIAdd(c);for(var d=this.pow(l,o),f=this.pow(e,o.addn(1).iushrn(1)),p=this.pow(e,o),h=a;0!==p.cmp(s);){for(var y=p,b=0;0!==y.cmp(s);b++)y=y.redSqr();r(b<h);var g=this.pow(d,new i(1).iushln(h-b-1));f=f.redMul(g),d=g.redSqr(),p=p.redMul(d),h=b}return f},S.prototype.invm=function(e){var t=e._invmp(this.m);return 0!==t.negative?(t.negative=0,this.imod(t).redNeg()):this.imod(t)},S.prototype.pow=function(e,t){if(t.isZero())return new i(1).toRed(this);if(0===t.cmpn(1))return e.clone();var n=new Array(16);n[0]=new i(1).toRed(this),n[1]=e;for(var r=2;r<n.length;r++)n[r]=this.mul(n[r-1],e);var o=n[0],a=0,s=0,c=t.bitLength()%26;for(0===c&&(c=26),r=t.length-1;r>=0;r--){for(var u=t.words[r],l=c-1;l>=0;l--){var d=u>>l&1;o!==n[0]&&(o=this.sqr(o)),0!==d||0!==a?(a<<=1,a|=d,(4===++s||0===r&&0===l)&&(o=this.mul(o,n[a]),s=0,a=0)):s=0}c=26}return o},S.prototype.convertTo=function(e){var t=e.umod(this.m);return t===e?t.clone():t},S.prototype.convertFrom=function(e){var t=e.clone();return t.red=null,t},i.mont=function(e){return new O(e)},o(O,S),O.prototype.convertTo=function(e){return this.imod(e.ushln(this.shift))},O.prototype.convertFrom=function(e){var t=this.imod(e.mul(this.rinv));return t.red=null,t},O.prototype.imul=function(e,t){if(e.isZero()||t.isZero())return e.words[0]=0,e.length=1,e;var n=e.imul(t),r=n.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),o=n.isub(r).iushrn(this.shift),i=o;return o.cmp(this.m)>=0?i=o.isub(this.m):o.cmpn(0)<0&&(i=o.iadd(this.m)),i._forceRed(this)},O.prototype.mul=function(e,t){if(e.isZero()||t.isZero())return new i(0)._forceRed(this);var n=e.mul(t),r=n.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),o=n.isub(r).iushrn(this.shift),a=o;return o.cmp(this.m)>=0?a=o.isub(this.m):o.cmpn(0)<0&&(a=o.iadd(this.m)),a._forceRed(this)},O.prototype.invm=function(e){return this.imod(e._invmp(this.m).mul(this.r2))._forceRed(this)}}(e=n.nmd(e),this)},9420:function(e,t){"use strict";function n(e){switch(typeof e){case"function":case"object":return null==e?"null":Array.isArray(e)?"array":typeof e;case"string":return JSON.stringify(e);default:return String(e)}}function r(e,t){return function(n){return null!=n?e(n):"function"==typeof t?t():t}}function o(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return function(e){for(var r=0;r<t.length;++r)if(e===t[r])return e;var o="Expected ";1!==t.length&&(o+="one of: ");for(var i=0;i<t.length;++i)i>0&&(o+=" | "),o+=JSON.stringify(t[i]);throw o+=", got "+n(e),new TypeError(o)}}function i(e){if("string"!=typeof e)throw new TypeError("Expected a string, got "+n(e));return e}Object.defineProperty(t,"__esModule",{value:!0});var a=o(null),s=o(void 0);var c=r(a);function u(e,t,n){return e instanceof Error&&(null==e.insertStepAt&&(e.message+=" at ",e.insertStepAt=e.message.length),e.message=e.message.slice(0,e.insertStepAt)+t+e.message.slice(e.insertStepAt),e.insertStepAt+=n),e}function l(e){if("function"==typeof e)return function(t){if("object"!=typeof t||null==t)throw new TypeError("Expected an object, got "+n(t));for(var r={},o=Object.keys(t),i=0;i<o.length;++i){var a=o[i];if("__proto__"!==a)try{r[a]=e(t[a])}catch(s){throw u(s,"["+JSON.stringify(a)+"]",0)}}return r};var t=Object.keys(e);function r(r){return function(o){if("object"!=typeof o||null==o)throw new TypeError("Expected an object, got "+n(o));var i,a={};if(r){var s=Object.keys(o);for(i=0;i<s.length;++i){var c=s[i];"__proto__"!==c&&(a[c]=o[c])}}for(i=0;i<t.length;++i){var l=t[i];try{a[l]=e[l](o[l])}catch(d){throw u(d,"."+l,0)}}return a}}var o=r(!1);return o.shape=e,o.withRest=r(!0),o}var d=l;function f(e,t){return function(n){return p[h]>0?t(n):e(n)}}var p="object"==typeof globalThis&&null!=globalThis?globalThis:JSON,h="function"==typeof Symbol?Symbol.for("uncleaning"):"uncleaning",y=f(function(e){if("string"!=typeof e&&!(e instanceof Date))throw new TypeError("Expected a date string, got "+n(e));var t=new Date(e);if(null==t.toJSON())throw new TypeError("Invalid date format, got "+n(e));return t},function(e){return e.toISOString()});t.asArray=function(e){return function(t){if(!Array.isArray(t))throw new TypeError("Expected an array, got "+n(t));for(var r=[],o=0;o<t.length;++o)try{r[o]=e(t[o])}catch(i){throw u(i,"["+o+"]",0)}return r}},t.asBoolean=function(e){if("boolean"!=typeof e)throw new TypeError("Expected a boolean, got "+n(e));return e},t.asCodec=f,t.asDate=y,t.asEither=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return function(e){for(var n=0;n<t.length;n++)try{return t[n](e)}catch(r){if(n+1>=t.length)throw r}}},t.asJSON=function(e){return f(function(t){var n=JSON.parse(i(t));try{return e(n)}catch(r){throw u(r,"JSON.parse()",11)}},function(t){return JSON.stringify(e(t))})},t.asMap=d,t.asMaybe=function(e,t){return function(n){try{return e(n)}catch(r){return"function"==typeof t?t():t}}},t.asNone=c,t.asNull=a,t.asNumber=function(e){if("number"!=typeof e)throw new TypeError("Expected a number, got "+n(e));return e},t.asObject=l,t.asOptional=r,t.asString=i,t.asTuple=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return function(e){if(!Array.isArray(e))throw new TypeError("Expected an array, got "+n(e));for(var r=[],o=0;o<t.length;++o)try{r[o]=t[o](e[o])}catch(i){throw u(i,"["+o+"]")}return r}},t.asUndefined=s,t.asUnknown=function(e){return e},t.asValue=o,t.uncleaner=function(e){return function(t){null==p[h]&&Object.defineProperty(p,h,{value:0,writable:!0});try{return++p[h],e(t)}finally{--p[h]}}}},9495:function(e,t){"use strict";function n(e,t,n,r,o,i,a){try{var s=e[i](a),c=s.value}catch(u){return void n(u)}s.done?t(c):Promise.resolve(c).then(r,o)}function r(e){return function(){var t=this,r=arguments;return new Promise(function(o,i){var a=e.apply(t,r);function s(e){n(a,o,i,s,c,"next",e)}function c(e){n(a,o,i,s,c,"throw",e)}s(void 0)})}}function o(){return o=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},o.apply(this,arguments)}function i(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function a(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return i(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?i(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}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 s=function(e){for(var t=encodeURI(e),n=new Uint8Array(t.length),r=0,o=0;o<t.length;++o){var i=t.charCodeAt(o);37===i?(n[r++]=parseInt(t.slice(o+1,o+3),16),o+=2):n[r++]=i}return n.subarray(0,r)},c=function(e){for(var t="",n=0;n<e.length;++n){var r=e[n];t+="%"+(r>>4).toString(16)+(15&r).toString(16)}return decodeURIComponent(t)};function u(e){var t=e.body,n=void 0===t?"":t,o=e.headers,i=void 0===o?{}:o,a=e.status,u=void 0===a?200:a,d=Promise.resolve(n),f={headers:l(i),ok:u>=200&&u<300,status:u,arrayBuffer:function(){return r(function*(){return yield d.then(function(e){return"string"==typeof e?s(e).buffer:e})})()},json:function(){return r(function*(){return yield f.text().then(function(e){return JSON.parse(e)})})()},text:function(){return r(function*(){return yield d.then(function(e){return"string"==typeof e?e:c(new Uint8Array(e))})})()}};return f}function l(e){var t={forEach:function(t,n){for(var r=0,o=Object.keys(e);r<o.length;r++){var i=o[r];t.call(n,e[i],i)}},get:function(n){return t.has(n)?e[n]:null},has:function(t){return Object.prototype.hasOwnProperty.call(e,t)}};return t}t.zf=function(e){return function(){var t=r(function*(t,n){void 0===n&&(n={});var r=n,i=r.body,a=void 0===i?"":i,c=r.method,l=void 0===c?"GET":c,d=r.headers,f=void 0===d?{}:d,p=new URL(t),h=p.host,y={method:l,path:p.pathname+p.search,version:"HTTP/1.1",headers:o({},f,{host:h}),body:"string"==typeof a?s(a):new Uint8Array(a)};return u(yield e(y))});return function(e,n){return t.apply(this,arguments)}}()},t.WX=u,t.Ju=function(e){for(var t={},n=0,r=Object.keys(e);n<r.length;n++){var o=r[n];t[o.toUpperCase()]=e[o]}null==t.OPTIONS&&(t.OPTIONS=function(){return{status:204,headers:i}});var i={"content-length":"0",allow:Object.keys(t).join(", ")};return function(e){var n=t[e.method];return null!=n?n(e):{status:405,headers:i}}},t.bI=function(e,t){void 0===t&&(t=function(){return{status:404}});for(var n=[],r=0,o=Object.keys(e);r<o.length;r++){var i=o[r];n.push({regexp:new RegExp("^"+i+"$"),server:e[i]})}return function(e){for(var r,o=a(n);!(r=o()).done;){var i=r.value,s=i.regexp,c=i.server;if(s.test(e.path))return c(e)}return t(e)}},t.gx=function(e){return function(){var t=r(function*(t){var n=yield e(t),r=n.headers;return o({},n,{headers:o({},void 0===r?{}:r,{"Access-Control-Allow-Origin":"*","Access-Control-Allow-Headers":"Accept, Authorization, Content-Type","Access-Control-Allow-Methods":"DELETE, GET, OPTIONS, POST, PUT"})})});return function(e){return t.apply(this,arguments)}}()}},9939:function(e,t,n){"use strict";var r=n(9211);function o(e){throw new Error("makeNodeDisklet is not available on this platform")}function i(){throw new Error("makeReactNativeDisklet is not available on this platform")}function a(e,t,n,r,o,i,a){try{var s=e[i](a),c=s.value}catch(u){return void n(u)}s.done?t(c):Promise.resolve(c).then(r,o)}function s(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function s(e){a(i,r,o,s,c,"next",e)}function c(e){a(i,r,o,s,c,"throw",e)}s(void 0)})}}function c(){return c=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},c.apply(this,arguments)}function u(e){if(/^\//.test(e))throw new Error("Absolute paths are not supported");for(var t=e.split("/"),n=0,r=0;n<t.length;){var o=t[n++];if(".."===o?r--:"."!==o&&""!==o&&(t[r++]=o),r<0)throw new Error("Path would escape folder")}return t.slice(0,r).join("/")}function l(e){return""===e?e:e+"/"}function d(e){for(var t=[],n=0;n<e.length;++n){var r=e.key(n);null!=r&&t.push(r)}return t}function f(e,t){void 0===e&&(e=window.localStorage),void 0===t&&(t={});var n=null!=t.prefix?l(t.prefix):"/";return{delete:function(t){var r=u(t);null!=e.getItem(n+r)&&e.removeItem(n+r);for(var o=l(r),i=0,a=d(e);i<a.length;i++){var s=a[i];0===s.indexOf(n+o)&&e.removeItem(s)}return Promise.resolve()},getData:function(e){return this.getText(e).then(function(e){return r.base64.parse(e)})},getText:function(t){var r=u(t),o=e.getItem(n+r);return null==o?Promise.reject(new Error('Cannot load "'+r+'"')):Promise.resolve(o)},list:function(t){return s(function*(){void 0===t&&(t="");var r=u(t),o={};null!=e.getItem(n+r)&&(o[r]="file");for(var i=l(r),a=0,s=d(e);a<s.length;a++){var c=s[a];if(0===c.indexOf(n+i)){var f=c.indexOf("/",n.length+i.length);f<0?o[c.slice(n.length)]="file":o[c.slice(n.length,f)]="folder"}}return o})()},setData:function(e,t){return this.setText(e,r.base64.stringify(t))},setText:function(t,r){return"string"!=typeof r?Promise.reject(new TypeError("setText expects a string")):(e.setItem(n+u(t),r),Promise.resolve())}}}function p(e){return void 0===e&&(e={}),{delete:function(t){var n=u(t);null!=e["/"+n]&&delete e["/"+n];for(var r=l(n),o=0,i=Object.keys(e);o<i.length;o++){var a=i[o];0===a.indexOf("/"+r)&&delete e[a]}return Promise.resolve()},getData:function(t){var n=u(t),r=e["/"+n];return null==r?Promise.reject(new Error('Cannot load "'+n+'"')):"string"==typeof r?Promise.reject(new Error('"'+n+'" is a text file.')):Promise.resolve(r)},getText:function(t){var n=u(t),r=e["/"+n];return null==r?Promise.reject(new Error('Cannot load "'+n+'"')):"string"!=typeof r?Promise.reject(new Error('"'+n+'" is a binary file.')):Promise.resolve(r)},list:function(t){return s(function*(){void 0===t&&(t="");var n=u(t),r={};null!=e["/"+n]&&(r[n]="file");for(var o=l(n),i=0,a=Object.keys(e);i<a.length;i++){var s=a[i];if(0===s.indexOf("/"+o)){var c=s.indexOf("/",1+o.length);c<0?r[s.slice(1)]="file":r[s.slice(1,c)]="folder"}}return r})()},setData:function(t,n){var r=n,o=Uint8Array.from(r);return e["/"+u(t)]=o,Promise.resolve()},setText:function(t,n){return"string"!=typeof n?Promise.reject(new TypeError("setText expects a string")):(e["/"+u(t)]=n,Promise.resolve())}}}var h=function(){function e(e,t){this._disklet=e,this._path=t}var t=e.prototype;return t.delete=function(){return this._disklet.delete(this._path)},t.getData=function(){return this._disklet.getData(this._path)},t.getText=function(){return this._disklet.getText(this._path)},t.setData=function(e){return this._disklet.setData(this._path,e)},t.setText=function(e){return this._disklet.setText(this._path,e)},e}(),y=function(){function e(e,t){this._disklet=e,this._path=t}var t=e.prototype;return t.delete=function(){return this._disklet.delete(this._path)},t.file=function(e){return new h(this._disklet,this._path+"/"+e)},t.folder=function(t){return new e(this._disklet,this._path+"/"+t)},t.listFiles=function(){return this._disklet.list(this._path).then(function(e){return Object.keys(e).filter(function(t){return"file"===e[t]}).map(function(e){return e.replace(/^.*\//,"")})})},t.listFolders=function(){return this._disklet.list(this._path).then(function(e){return Object.keys(e).filter(function(t){return"folder"===e[t]}).map(function(e){return e.replace(/^.*\//,"")})})},e}();function b(e){return new y(e,".")}function g(e,t){for(var n=0,r=0;n<t.length;){var o=t[n++];if(".."===o?r--:"."!==o&&""!==o&&(t[r++]=o),r<0)throw new Error("Path would escape folder")}for(n=0;n<r;++n)e=e.folder(t[n]);return e}function w(e,t){return e.listFiles().then(function(n){return Promise.all(n.map(function(n){return t(e.file(n),n,e)}))})}function v(e,t){return e.listFolders().then(function(n){return Promise.all(n.map(function(n){return t(e.folder(n),n,e)}))})}function m(e,t){console.log(t+' "'+e+'"')}function I(e,t,n){var r=n.callback,o=void 0===r?m:r,i=n.verbose;(void 0!==i&&i||/set|delete/.test(t))&&o(e,t)}var E=function(){function e(e,t,n){this._file=e,this._path=t,this._opts=n}var t=e.prototype;return t.delete=function(){return I(this._path,"delete file",this._opts),this._file.delete()},t.getData=function(){return I(this._path,"get data",this._opts),this._file.getData()},t.getText=function(){return I(this._path,"get text",this._opts),this._file.getText()},t.setData=function(e){return I(this._path,"set data",this._opts),this._file.setData(e)},t.setText=function(e){return I(this._path,"set text",this._opts),this._file.setText(e)},t.getPath=function(){return this._path},e}(),S=function(){function e(e,t,n){this._folder=e,this._path=t,this._opts=n}var t=e.prototype;return t.delete=function(){return I(this._path,"delete folder",this._opts),this._folder.delete()},t.file=function(e){return new E(this._folder.file(e),this._path+e,this._opts)},t.folder=function(t){return new e(this._folder.folder(t),this._path+t+"/",this._opts)},t.listFiles=function(){return I(this._path,"list files",this._opts),this._folder.listFiles()},t.listFolders=function(){return I(this._path,"list folders",this._opts),this._folder.listFolders()},e}();function O(e,t){var n={},r=[];return e.forEach(function(e){/\._x_$/.test(e)?n[e]=!0:(n[e+"._x_"]=!0,r.push(e))}),t.forEach(function(e){n[e+"._x_"]||r.push(e)}),r}var A=function(){function e(e,t,n){this._master=e,this._fallback=t,this._whiteout=n}var t=e.prototype;return t.delete=function(){return Promise.all([this._whiteout.setData([]),this._master.delete().catch(function(e){return null})])},t.getData=function(){var e=this;return this._master.getData().catch(function(t){return e._whiteout.getData().then(function(e){throw new Error("File has been deleted")},function(t){return e._fallback.getData()})})},t.getText=function(){var e=this;return this._master.getText().catch(function(t){return e._whiteout.getData().then(function(e){throw new Error("File has been deleted")},function(t){return e._fallback.getText()})})},t.setData=function(e){return this._master.setData(e)},t.setText=function(e){return this._master.setText(e)},t.getPath=function(){throw new Error("Cannot call getPath on a Union Folder")},e}(),T=function(){function e(e,t){this._master=e,this._fallback=t}var t=e.prototype;return t.delete=function(){return Promise.all([w(this,function(e){return e.delete()}),v(this,function(e){return e.delete()})]).then(function(){})},t.file=function(e){return new A(this._master.file(e),this._fallback.file(e),this._master.file(e+"._x_"))},t.folder=function(t){return new e(this._master.folder(t),this._fallback.folder(t))},t.listFiles=function(){return Promise.all([this._master.listFiles(),this._fallback.listFiles()]).then(function(e){return O(e[0],e[1])})},t.listFolders=function(){return Promise.all([this._master.listFolders(),this._fallback.listFolders()]).then(function(e){return O(e[0],e[1])})},e}();function _(e,t){var n=l(u(t));return{delete:function(t){return e.delete(n+t)},getData:function(t){return e.getData(n+t)},getText:function(t){return e.getText(n+t)},list:function(t){return void 0===t&&(t="."),e.list(n+t).then(function(e){var t={};for(var r in e)t[r.replace(n,"")]=e[r];return t})},setData:function(t,r){return e.setData(n+t,r)},setText:function(t,r){return e.setText(n+t,r)}}}t.WR=function(e){return Object.keys(e).filter(function(t){return"file"===e[t]})},t.a8=function(e){return Object.keys(e).filter(function(t){return"folder"===e[t]})},t.cQ=p,t.mi=function(e,t){return{delete:function(n){return Promise.all([e.delete(n),t.delete(n)])},getData:function(n){return e.getData(n).catch(function(e){return t.getData(n)})},getText:function(n){return e.getText(n).catch(function(e){return t.getText(n)})},list:function(n){return Promise.all([e.list(n),t.list(n)]).then(function(e){var t=e[0];return c(e[1],t)})},setData:function(t,n){return e.setData(t,n)},setText:function(t,n){return e.setText(t,n)}}},t.my=_},9983:function(e){"use strict";!function(){var t=2147483647;function n(e){var t=[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],n=1779033703,r=3144134277,o=1013904242,i=2773480762,a=1359893119,s=2600822924,c=528734635,u=1541459225,l=new Array(64);function d(e){for(var d=0,f=e.length;f>=64;){var p,h,y,b,g,w=n,v=r,m=o,I=i,E=a,S=s,O=c,A=u;for(h=0;h<16;h++)y=d+4*h,l[h]=(255&e[y])<<24|(255&e[y+1])<<16|(255&e[y+2])<<8|255&e[y+3];for(h=16;h<64;h++)b=((p=l[h-2])>>>17|p<<15)^(p>>>19|p<<13)^p>>>10,g=((p=l[h-15])>>>7|p<<25)^(p>>>18|p<<14)^p>>>3,l[h]=(b+l[h-7]|0)+(g+l[h-16]|0)|0;for(h=0;h<64;h++)b=(((E>>>6|E<<26)^(E>>>11|E<<21)^(E>>>25|E<<7))+(E&S^~E&O)|0)+(A+(t[h]+l[h]|0)|0)|0,g=((w>>>2|w<<30)^(w>>>13|w<<19)^(w>>>22|w<<10))+(w&v^w&m^v&m)|0,A=O,O=S,S=E,E=I+b|0,I=m,m=v,v=w,w=b+g|0;n=n+w|0,r=r+v|0,o=o+m|0,i=i+I|0,a=a+E|0,s=s+S|0,c=c+O|0,u=u+A|0,d+=64,f-=64}}d(e);var f,p=e.length%64,h=e.length/536870912|0,y=e.length<<3,b=p<56?56:120,g=e.slice(e.length-p,e.length);for(g.push(128),f=p+1;f<b;f++)g.push(0);return g.push(h>>>24&255),g.push(h>>>16&255),g.push(h>>>8&255),g.push(h>>>0&255),g.push(y>>>24&255),g.push(y>>>16&255),g.push(y>>>8&255),g.push(y>>>0&255),d(g),[n>>>24&255,n>>>16&255,n>>>8&255,n>>>0&255,r>>>24&255,r>>>16&255,r>>>8&255,r>>>0&255,o>>>24&255,o>>>16&255,o>>>8&255,o>>>0&255,i>>>24&255,i>>>16&255,i>>>8&255,i>>>0&255,a>>>24&255,a>>>16&255,a>>>8&255,a>>>0&255,s>>>24&255,s>>>16&255,s>>>8&255,s>>>0&255,c>>>24&255,c>>>16&255,c>>>8&255,c>>>0&255,u>>>24&255,u>>>16&255,u>>>8&255,u>>>0&255]}function r(e,t,r){var o;e=e.length<=64?e:n(e);var i=64+t.length+4,a=new Array(i),s=new Array(64),c=[];for(o=0;o<64;o++)a[o]=54;for(o=0;o<e.length;o++)a[o]^=e[o];for(o=0;o<t.length;o++)a[64+o]=t[o];for(o=i-4;o<i;o++)a[o]=0;for(o=0;o<64;o++)s[o]=92;for(o=0;o<e.length;o++)s[o]^=e[o];function u(){for(var e=i-1;e>=i-4;e--){if(a[e]++,a[e]<=255)return;a[e]=0}}for(;r>=32;)u(),c=c.concat(n(s.concat(n(a)))),r-=32;return r>0&&(u(),c=c.concat(n(s.concat(n(a))).slice(0,r))),c}function o(e,t,n,r,o){var i;for(c(e,16*(2*n-1),o,0,16),i=0;i<2*n;i++)s(e,16*i,o,16),a(o,r),c(o,0,e,t+16*i,16);for(i=0;i<n;i++)c(e,t+2*i*16,e,16*i,16);for(i=0;i<n;i++)c(e,t+16*(2*i+1),e,16*(i+n),16)}function i(e,t){return e<<t|e>>>32-t}function a(e,t){c(e,0,t,0,16);for(var n=8;n>0;n-=2)t[4]^=i(t[0]+t[12],7),t[8]^=i(t[4]+t[0],9),t[12]^=i(t[8]+t[4],13),t[0]^=i(t[12]+t[8],18),t[9]^=i(t[5]+t[1],7),t[13]^=i(t[9]+t[5],9),t[1]^=i(t[13]+t[9],13),t[5]^=i(t[1]+t[13],18),t[14]^=i(t[10]+t[6],7),t[2]^=i(t[14]+t[10],9),t[6]^=i(t[2]+t[14],13),t[10]^=i(t[6]+t[2],18),t[3]^=i(t[15]+t[11],7),t[7]^=i(t[3]+t[15],9),t[11]^=i(t[7]+t[3],13),t[15]^=i(t[11]+t[7],18),t[1]^=i(t[0]+t[3],7),t[2]^=i(t[1]+t[0],9),t[3]^=i(t[2]+t[1],13),t[0]^=i(t[3]+t[2],18),t[6]^=i(t[5]+t[4],7),t[7]^=i(t[6]+t[5],9),t[4]^=i(t[7]+t[6],13),t[5]^=i(t[4]+t[7],18),t[11]^=i(t[10]+t[9],7),t[8]^=i(t[11]+t[10],9),t[9]^=i(t[8]+t[11],13),t[10]^=i(t[9]+t[8],18),t[12]^=i(t[15]+t[14],7),t[13]^=i(t[12]+t[15],9),t[14]^=i(t[13]+t[12],13),t[15]^=i(t[14]+t[13],18);for(n=0;n<16;++n)e[n]+=t[n]}function s(e,t,n,r){for(var o=0;o<r;o++)n[o]^=e[t+o]}function c(e,t,n,r,o){for(;o--;)n[r++]=e[t++]}function u(e){if(!e||"number"!=typeof e.length)return!1;for(var t=0;t<e.length;t++){if("number"!=typeof e[t])return!1;var n=parseInt(e[t]);if(n!=e[t]||n<0||n>=256)return!1}return!0}function l(e,t){var n=parseInt(e);if(e!=n)throw new Error("invalid "+t);return n}e.exports=function(e,n,i,a,d,f,p){if(!p)throw new Error("missing callback");if(i=l(i,"N"),a=l(a,"r"),d=l(d,"p"),f=l(f,"dkLen"),0===i||i&i-1)throw new Error("N must be power of 2");if(i>t/128/a)throw new Error("N too large");if(a>t/128/d)throw new Error("r too large");if(!u(e))throw new Error("password must be an array or buffer");if(!u(n))throw new Error("salt must be an array or buffer");for(var h=r(e,n,128*d*a),y=new Uint32Array(32*d*a),b=0;b<y.length;b++){var g=4*b;y[b]=(255&h[g+3])<<24|(255&h[g+2])<<16|(255&h[g+1])<<8|255&h[g+0]}var w,v,m=new Uint32Array(64*a),I=new Uint32Array(32*a*i),E=32*a,S=new Uint32Array(16),O=new Uint32Array(16),A=d*i*2,T=0,_=null,k=!1,x=0,P=0,M=parseInt(1e3/a),C="undefined"!=typeof setImmediate?setImmediate:setTimeout,N=function(){if(k)return p(new Error("cancelled"),T/A);switch(x){case 0:c(y,v=32*P*a,m,0,E),x=1,w=0;case 1:(n=i-w)>M&&(n=M);for(var t=0;t<n;t++)c(m,0,I,(w+t)*E,E),o(m,E,a,S,O);if(w+=n,T+=n,(u=parseInt(1e3*T/A))!==_){if(k=p(null,T/A))break;_=u}if(w<i)break;w=0,x=2;case 2:var n,u;for((n=i-w)>M&&(n=M),t=0;t<n;t++){var l=m[16*(2*a-1)]&i-1;s(I,l*E,m,E),o(m,E,a,S,O)}if(w+=n,T+=n,(u=parseInt(1e3*T/A))!==_){if(k=p(null,T/A))break;_=u}if(w<i)break;if(c(m,0,y,v,E),++P<d){x=0;break}for(h=[],t=0;t<y.length;t++)h.push(255&y[t]),h.push(y[t]>>8&255),h.push(y[t]>>16&255),h.push(y[t]>>24&255);var b=r(e,h,f);return p(null,1,b)}C(N)};N()}}()}},t={};function n(r){var o=t[r];if(void 0!==o)return o.exports;var i=t[r]={id:r,loaded:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.loaded=!0,i.exports}n.m=e,n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,{a:t}),t},n.d=function(e,t){for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.nmd=function(e){return e.paths=[],e.children||(e.children=[]),e},function(){var e;n.g.importScripts&&(e=n.g.location+"");var t=n.g.document;if(!e&&t&&(t.currentScript&&"SCRIPT"===t.currentScript.tagName.toUpperCase()&&(e=t.currentScript.src),!e)){var r=t.getElementsByTagName("script");if(r.length)for(var o=r.length-1;o>-1&&(!e||!/^http(s?):/.test(e));)e=r[o--].src}if(!e)throw new Error("Automatic publicPath is not supported in this browser");e=e.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),n.p=e}(),n.b="undefined"!=typeof document&&document.baseURI||self.location.href,function(){"use strict";function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e(t)}function t(t){var n=function(t,n){if("object"!=e(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var o=r.call(t,n||"default");if("object"!=e(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===n?String:Number)(t)}(t,"string");return"symbol"==e(n)?n:n+""}function r(e,n,r){return(n=t(n))in e?Object.defineProperty(e,n,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[n]=r,e}var o=n(7952),i=n.n(o),a=n(2723),s=n.n(a);function c(e,t,n){var r;if(void 0===n&&(n={}),!t.codes){t.codes={};for(var o=0;o<t.chars.length;++o)t.codes[t.chars[o]]=o}if(!n.loose&&e.length*t.bits&7)throw new SyntaxError("Invalid padding");for(var i=e.length;"="===e[i-1];)if(--i,!(n.loose||(e.length-i)*t.bits&7))throw new SyntaxError("Invalid padding");for(var a=new(null!=(r=n.out)?r:Uint8Array)(i*t.bits/8|0),s=0,c=0,u=0,l=0;l<i;++l){var d=t.codes[e[l]];if(void 0===d)throw new SyntaxError("Invalid character "+e[l]);c=c<<t.bits|d,(s+=t.bits)>=8&&(s-=8,a[u++]=255&c>>s)}if(s>=t.bits||255&c<<8-s)throw new SyntaxError("Unexpected end of data");return a}function u(e,t,n){void 0===n&&(n={});for(var r=n.pad,o=void 0===r||r,i=(1<<t.bits)-1,a="",s=0,c=0,u=0;u<e.length;++u)for(c=c<<8|255&e[u],s+=8;s>t.bits;)s-=t.bits,a+=t.chars[i&c>>s];if(s&&(a+=t.chars[i&c<<t.bits-s]),o)for(;a.length*t.bits&7;)a+="=";return a}var l={chars:"0123456789ABCDEF",bits:4},d={chars:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bits:5},f={chars:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bits:6},p=function(e,t){return c(e.toUpperCase(),l,t)},h=function(e,t){return u(e,l,t)},y=function(e,t){return void 0===t&&(t={}),c(t.loose?e.toUpperCase().replace(/0/g,"O").replace(/1/g,"L").replace(/8/g,"B"):e,d,t)},b=function(e,t){return u(e,d,t)},g=function(e,t){return c(e,f,t)},w=function(e,t){return u(e,f,t)},v=n(9495);const m=v.zf,I=v.WX,E=v.Ju,S=v.bI;v.gx;function O(){return O=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},O.apply(null,arguments)}var A="_yaob",T=1,_={};function k(e,t){Object.prototype.hasOwnProperty.call(e,A)?O(e[A],t):Object.defineProperty(e,A,{value:t})}function x(e){var t=e.prototype;if(!Object.prototype.hasOwnProperty.call(t,A)){k(t,{})}return e}function P(e){Object.prototype.hasOwnProperty.call(e,A)&&null!=e[A].localId||k(e,{localId:T++,bridges:[],listeners:{},watchers:{}});return e}function M(e){if(null==e[A])throw new TypeError("Not a bridgeable object");return P(e),e[A]}function C(e,t){null==t?t="":t+=".";for(var n=0,r=Object.getOwnPropertyNames(e);n<r.length;n++){var o=r[n],i=t+o;if(null!=_[i])throw new Error("A shared value named "+i+" already exists");_[i]=e[o],k(e[o],{shareId:i})}}function N(e,t){try{var n=R(e,t),r=L(e,n,t);return""!==n?{map:n,raw:r}:{raw:r}}catch(t){return j(e,t)}}function j(e,t){var n=R(e,t);return{map:n,raw:L(e,n,t),throw:!0}}function D(e,t,n,r){void 0===r&&(r=!1);var o=t.map,i=t.raw,a=null!=o?B(e,o,i,n,r):i;if(t.throw)throw a;return a}function R(e,t){switch(typeof t){case"boolean":case"number":case"string":return"";case"object":if(null===t)return"";if(t instanceof Date)return"d";if(t instanceof Error)return"e";if(t instanceof ArrayBuffer)return"ab";if(t instanceof Uint8Array)return"u8";if(t instanceof Map)return"M";if(t instanceof Set)return"S";if(null!=t[A])return null!=t[A].shareId?"s":"o";if(Array.isArray(t)){for(var n="",r=0;r<t.length;++r){var o=R(e,t[r]);if(""!==o&&""===n){n=[];for(var i=0;i<r;++i)n[i]=""}""!==n&&(n[r]=o)}return n}var a="";for(var s in t){var c=R(e,t[s]);""!==c&&(""===a&&(a={}),a[s]=c)}return a;case"undefined":return"u";case"function":return null!=t[A]&&null!=t[A].shareId?"s":"?";default:return"?"}}function L(e,t,n){switch(t){case"":return n;case"?":return typeof n;case"d":return n.toISOString();case"e":return function(e,t){var n=O({message:t.message,stack:t.stack},t),r=null;return t instanceof EvalError?r="EvalError":t instanceof RangeError?r="RangeError":t instanceof ReferenceError?r="ReferenceError":t instanceof SyntaxError?r="SyntaxError":t instanceof TypeError?r="TypeError":t instanceof URIError&&(r="URIError"),O({base:r},N(e,n))}(e,n);case"o":return e.getPackedId(n);case"s":return n[A].shareId;case"u":return null;case"ab":return w(new Uint8Array(n));case"u8":return w(n);case"M":return N(e,Array.from(n.entries()));case"S":return N(e,Array.from(n.values()));default:if(Array.isArray(t)){for(var r=[],o=0;o<t.length;++o)r[o]=L(e,t[o],n[o]);return r}var i={};for(var a in n)i[a]=a in t?L(e,t[a],n[a]):n[a];return i}}function B(e,t,n,r,o){switch(t){case"":return n;case"?":throw new TypeError("Unsupported value of type "+("string"==typeof n?n:"?")+" at "+r);case"d":return new Date(n);case"e":if("object"!=typeof n||null===n)throw new TypeError("Expecting an error description at "+r);return function(e,t,n){var r={EvalError:EvalError,RangeError:RangeError,ReferenceError:ReferenceError,SyntaxError:SyntaxError,TypeError:TypeError,URIError:URIError},o=new(null!=t.base&&r[t.base]||Error),i=D(e,t,n,!0);for(var a in i)o[a]=i[a];return o}(e,n,r);case"o":if(null===n)throw new TypeError("Closed bridge object at "+r);if("number"!=typeof n)throw new TypeError("Expecting a packedId at "+r);var i=e.getObject(-n);if(null==i)throw new RangeError("Invalid packedId "+n+" at "+r);return i;case"s":if("string"!=typeof n)throw new TypeError("Expecting a shareId at "+r);var a=_[n];if(null==a)throw new RangeError("Invalid shareId '"+n+"' at "+r);return a;case"u":return;case"ab":if("string"!=typeof n)throw new TypeError("Expecting a base64 string at "+r);return g(n).buffer;case"u8":if("string"!=typeof n)throw new TypeError("Expecting a base64 string at "+r);return g(n);case"M":if("object"!=typeof n||null===n)throw new TypeError("Expecting an Map description at "+r);return new Map(D(e,n,r));case"S":if("object"!=typeof n||null===n)throw new TypeError("Expecting an Set description at "+r);return new Set(D(e,n,r));default:if("object"!=typeof t||null===t)throw new TypeError("Invalid type information "+t+" at "+r);if("object"!=typeof n||null===n)throw new TypeError("Expecting an array or object at "+r);if(Array.isArray(t)){if(!Array.isArray(n))throw new TypeError("Expecting an array at "+r);for(var s=[],c=0;c<t.length;++c)!0===o&&"?"===t[c]||(s[c]=B(e,t[c],n[c],r+"["+c+"]",o));return s}var u={};for(var l in n)!0===o&&"?"===t[l]||(u[l]=l in t?B(e,t[l],n[l],r+"."+l,o):n[l]);return u}}var K={};function U(e,t,n){var r=M(e),o=r.closed,i=r.listeners;return o?function(){}:(null==i[t]?i[t]=[n]:i[t].push(n),function(){i[t]=i[t].filter(function(e){return e!==n})})}function F(e){var t=M(e),n=t.listeners.close;if(null!=n)for(var r=0;r<n.length;r++){z(e,n[r],void 0,!0)}t.closed=!0;for(var o=0,i=t.bridges;o<i.length;o++){i[o].emitClose(t.localId)}t.bridges=[],t.listeners={},t.watchers={}}function W(e,t,n){var r=M(e);if(r.closed)throw new Error("Cannot emit event on closed object");for(var o=0,i=r.bridges;o<i.length;o++){i[o].emitEvent(r.localId,t,n)}var a=r.listeners[t];if(null!=a)for(var s=0;s<a.length;s++){z(e,a[s],n,"error"!==t)}}function G(e,t){var n=M(e);if(n.closed)throw new Error("Cannot update closed object");for(var r=0,o=n.bridges;r<o.length;r++){o[r].markDirty(n.localId,t)}for(var i in null!=t&&null!=n.watchers[t]&&(n.watchers[t].data=K),n.watchers){var a=n.watchers[i];try{var s=e[i];if(s!==a.data){a.data=s;for(var c=0,u=a.fs;c<u.length;c++){z(e,u[c],a.data,!0)}}}catch(l){}}}function z(e,t,n,r){try{var o=t(n);r&&null!=o&&"function"==typeof o.then&&o.then(void 0,function(t){return W(e,"error",t)})}catch(i){r&&W(e,"error",i)}}var q={};function $(e,t,n){var r=!1,o={};for(var i in n)try{var a=t[i];a!==n[i]&&(r=!0,o[i]=N(e,a),n[i]=a)}catch(s){o[i]=j(e,s),n[i]=q}return{dirty:r,props:o}}function H(e,t){var n,r={},o=(n=t.localId,{localId:T++,bridges:[],listeners:{},watchers:{},remoteId:n,errors:{},props:{}});for(var i in r[A]={value:o},t.props)r[i]={enumerable:e.hideProperties.indexOf(i)<0,get:V(o,i)};for(var a=0,s=t.methods;a<s.length;a++){var c=s[a];r[c]={value:J(e,o,c)}}return Object.create(Object.prototype,r)}function Y(e,t,n){var r=t[A];for(var o in n)try{r.props[o]=D(e,n[o],o),r.errors[o]=!1}catch(i){r.props[o]=i,r.errors[o]=!0}}function V(e,t){return function(){if(e.errors[t])throw e.props[t];return e.props[t]}}function J(e,t,n){return function(){if(t.closed)return Promise.reject(new TypeError("Cannot call method '"+n+"' of closed proxy"));for(var r=arguments.length,o=new Array(r),i=0;i<r;i++)o[i]=arguments[i];return e.emitCall(t.remoteId,n,o)}}var X=function(){function e(e){var t=e.hideProperties,n=void 0===t?[]:t,r=e.sendMessage,o=e.throttleMs,i=void 0===o?0:o;this.hideProperties=n,this.sendMessage=r,this.throttleMs=i,this.proxies={},this.objects={},this.caches={},this.nextCallId=0,this.pendingCalls={},this.dirty={},this.message={},this.lastUpdate=0,this.sendPending=!1}var t=e.prototype;return t.close=function(e){for(var t in this.pendingCalls){this.pendingCalls[Number(t)].reject(e)}for(var n in this.proxies)F(this.proxies[Number(n)]);this.closed=!0},t.getObject=function(e){return e<0?this.proxies[-e]:this.objects[e]},t.getPackedId=function(e){var t=M(e);if(t.closed)return null;if(null!=t.remoteId&&null!=this.proxies[t.remoteId])return-t.remoteId;if(null==this.objects[t.localId]){this.objects[t.localId]=e;var n=function(e,t){for(var n={},r=Object.prototype,o=t;o!==r&&null!=o;o=Object.getPrototypeOf(o))for(var i=0,a=Object.getOwnPropertyNames(o);i<a.length;i++){var s=a[i];s===A||/^_/.test(s)||"constructor"===s||(n[s]=!0)}var c={},u=[],l={};for(var d in n)try{var f=t[d];"function"!=typeof f||null!=f[A]&&null!=f[A].shareId?(c[d]=f,l[d]=N(e,f)):u.push(d)}catch(p){c[d]=q,l[d]=j(e,p)}return{cache:c,create:{localId:M(t).localId,methods:u,props:l}}}(this,e),r=n.cache,o=n.create;this.caches[t.localId]=r,t.bridges.push(this),this.emitCreate(o,e)}return t.localId},t.markDirty=function(e,t){var n=this.caches[e];null!=t&&t in n&&(n[t]=q),this.dirty[e]={cache:n,object:this.objects[e]},this.wakeup()},t.emitClose=function(e){delete this.objects[e],delete this.caches[e],null==this.message.closed&&(this.message.closed=[]),this.message.closed.push(e),this.wakeup()},t.emitCreate=function(e,t){null==this.message.created&&(this.message.created=[]),this.message.created.push(e)},t.emitCall=function(e,t,n){var r=this,o=this.nextCallId++,i=O({callId:o,remoteId:e,name:t},N(this,n));return null==this.message.calls&&(this.message.calls=[]),this.message.calls.push(i),this.wakeup(),new Promise(function(e,n){r.pendingCalls[o]={name:t,resolve:e,reject:n}})},t.emitEvent=function(e,t,n){var r=O({localId:e,name:t},N(this,n));null==this.message.events&&(this.message.events=[]),this.message.events.push(r),this.wakeup()},t.emitReturn=function(e,t,n){var r=O({callId:e},t?j(this,n):N(this,n));null==this.message.returns&&(this.message.returns=[]),this.message.returns.push(r),this.wakeup()},t.handleMessage=function(e){var t=this;if(e.created){for(var n=0,r=e.created;n<r.length;n++){var o=r[n];this.proxies[o.localId]=H(this,o)}for(var i=0,a=e.created;i<a.length;i++){var s=a[i];Y(this,this.proxies[s.localId],s.props)}}if(e.changed){for(var c=0,u=e.changed;c<u.length;c++){var l=u[c],d=l.localId,f=l.props,p=this.proxies[d];if(null==p)throw new RangeError("Invalid localId "+d);Y(this,p,f)}for(var h=0,y=e.changed;h<y.length;h++){var b=y[h];G(this.proxies[b.localId])}}if(e.events)for(var g=0,w=e.events;g<w.length;g++){var v=w[g],m=v.localId,I=v.name,E=0===m?this:this.proxies[m];if(null!=E)try{W(E,I,D(this,v,I))}catch(R){W(E,"error",R)}}if(e.calls)for(var S=function(e,n){var r=n[e],o=r.callId,i=r.remoteId,a=r.name;try{var s=t.objects[i];if(null==s)throw new TypeError("Cannot call method '"+a+"' of closed proxy (remote)");if("function"!=typeof s[a])throw new TypeError("'"+a+"' is not a function");var c=D(t,r,a+".arguments");Promise.resolve(s[a].apply(s,c)).then(function(e){return t.emitReturn(o,!1,e)},function(e){return t.emitReturn(o,!0,e)})}catch(R){t.emitReturn(o,!0,R)}},O=0,A=e.calls;O<A.length;O++)S(O,A);if(e.returns)for(var T=0,_=e.returns;T<_.length;T++){var k=_[T],x=k.callId,P=this.pendingCalls[x];if(null==P)throw new RangeError("Invalid callId "+x);try{P.resolve(D(this,k,P.name+".return"))}catch(R){P.reject(R)}finally{delete this.pendingCalls[x]}}if(e.closed)for(var M=0,C=e.closed;M<C.length;M++){var N=C[M],j=this.proxies[N];if(null==j)return;delete this.proxies[N],F(j)}},t.sendNow=function(){if(!this.closed){for(var e in this.dirty){var t=Number(e),n=this.dirty[t],r=$(this,n.object,n.cache),o=r.dirty,i=r.props;if(o){var a={localId:t,props:i};null==this.message.changed&&(this.message.changed=[]),this.message.changed.push(a)}}var s=this.message;this.dirty={},this.message={},null==s.calls&&null==s.changed&&null==s.closed&&null==s.created&&null==s.events&&null==s.returns||this.sendMessage(s)}},t.wakeup=function(){var e=this;if(!this.sendPending){this.sendPending=!0;var t=this.lastUpdate+this.throttleMs-Date.now();setTimeout(function(){e.sendPending=!1,e.lastUpdate=Date.now(),e.sendNow()},t<0?0:t)}},e}();x(X);var Z=function(){function e(e){var t=this;this._state=new X(e),this._rootPromise=new Promise(function(e){return U(t._state,"root",e)})}var t=e.prototype;return t.handleMessage=function(e){this._state.handleMessage(e)},t.getRoot=function(){return this._rootPromise},t.sendRoot=function(e){this._state.emitEvent(0,"root",e)},t.close=function(e){this._state.close(e)},e}();var Q=function(e,t){return U(this,e,t)},ee=function(e,t){return function(e,t,n){var r=M(e),o=r.closed,i=r.watchers,a=e[t];return o?function(){}:(null==i[t]?i[t]={data:a,fs:[n]}:i[t].fs.push(n),function(){i[t].fs=i[t].fs.filter(function(e){return e!==n})})}(this,e,t)};C({onMethod:Q,watchMethod:ee});var te=function(){function e(){}var t=e.prototype;return t._close=function(){F(this)},t._emit=function(e,t){return W(this,e,t)},t._update=function(e){G(this,e)},e}(),ne=te.prototype;ne.on=Q,ne.watch=ee,x(te);var re=n(9939);n(9983);class oe{getFirstWalletInfo(e){return this.allKeys.find(t=>t.type===e)}getWalletInfo(e){return this.allKeys.find(t=>t.id===e)}listWalletIds(){return this.allKeys.map(e=>e.id)}}function ie(e){const t=e.length<10,n=!/[0-9]/.test(e),r=!/[a-z]/.test(e),o=!/[A-Z]/.test(e),i=(/[0-9]/.test(e)?10:0)+(/[A-Z]/.test(e)?26:0)+(/[a-z]/.test(e)?26:0)+(/[^0-9A-Za-z]/.test(e)?30:0);return{secondsToCrack:Math.pow(i,e.length)/1e6,tooShort:t,noNumber:n,noLowerCase:r,noUpperCase:o,passed:e.length>=16||!(t||n||o||r)}}function ae(e){const t=e.toLowerCase().replace(/[ \f\r\n\t\v]+/g," ").replace(/ $/,"").replace(/^ /,"");for(let n=0;n<t.length;++n){const e=t.charCodeAt(n);if(e<32||e>126)throw new Error("Bad characters in username")}return t}function se(e){let t,n=!1;const r={next:async()=>{if(null==t&&(t=await this.$internalStreamTransactions(e)),!n){const e=await t.next();if(!e.done)return e;F(t),n=!0}return{done:!0,value:void 0}},return:async()=>(null==t||n||(F(t),n=!0),{done:!0,value:void 0}),[Symbol.asyncIterator]:()=>r};return r}function ce(e){switch(typeof e){case"function":case"object":return null==e?"null":Array.isArray(e)?"array":typeof e;case"string":return JSON.stringify(e);default:return String(e)}}function ue(e,t){return function(n){return null!=n?e(n):"function"==typeof t?t():t}}function le(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return function(e){for(var n=0;n<t.length;++n)if(e===t[n])return e;var r="Expected ";1!==t.length&&(r+="one of: ");for(var o=0;o<t.length;++o)o>0&&(r+=" | "),r+=JSON.stringify(t[o]);throw r+=", got "+ce(e),new TypeError(r)}}function de(e){if("boolean"!=typeof e)throw new TypeError("Expected a boolean, got "+ce(e));return e}function fe(e){if("number"!=typeof e)throw new TypeError("Expected a number, got "+ce(e));return e}function pe(e){if("string"!=typeof e)throw new TypeError("Expected a string, got "+ce(e));return e}C(oe.prototype,"AccountSync"),C({checkPasswordRules:ie}),C({fixUsername:ae}),C({streamTransactions:se},"CurrencyWalletSync");var he=le(null);le(void 0);function ye(e){return e}ue(he);function be(e,t,n){return e instanceof Error&&(null==e.insertStepAt&&(e.message+=" at ",e.insertStepAt=e.message.length),e.message=e.message.slice(0,e.insertStepAt)+t+e.message.slice(e.insertStepAt),e.insertStepAt+=n),e}function ge(e){return function(t){if(!Array.isArray(t))throw new TypeError("Expected an array, got "+ce(t));for(var n=[],r=0;r<t.length;++r)try{n[r]=e(t[r])}catch(o){throw be(o,"["+r+"]",0)}return n}}function we(e){if("function"==typeof e)return function(t){if("object"!=typeof t||null==t)throw new TypeError("Expected an object, got "+ce(t));for(var n={},r=Object.keys(t),o=0;o<r.length;++o){var i=r[o];if("__proto__"!==i)try{n[i]=e(t[i])}catch(a){throw be(a,"["+JSON.stringify(i)+"]",0)}}return n};var t=Object.keys(e);function n(n){return function(r){if("object"!=typeof r||null==r)throw new TypeError("Expected an object, got "+ce(r));var o,i={};if(n){var a=Object.keys(r);for(o=0;o<a.length;++o){var s=a[o];"__proto__"!==s&&(i[s]=r[s])}}for(o=0;o<t.length;++o){var c=t[o];try{i[c]=e[c](r[c])}catch(u){throw be(u,"."+c,0)}}return i}}var r=n(!1);return r.shape=e,r.withRest=n(!0),r}function ve(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return function(e){for(var n=0;n<t.length;n++)try{return t[n](e)}catch(r){if(n+1>=t.length)throw r}}}function me(e,t){return function(n){try{return e(n)}catch(r){return"function"==typeof t?t():t}}}function Ie(e,t){return function(n){return Se[Oe]>0?t(n):e(n)}}function Ee(e){return function(t){null==Se[Oe]&&Object.defineProperty(Se,Oe,{value:0,writable:!0});try{return++Se[Oe],e(t)}finally{--Se[Oe]}}}var Se="object"==typeof globalThis&&null!=globalThis?globalThis:JSON,Oe="function"==typeof Symbol?Symbol.for("uncleaning"):"uncleaning",Ae=Ie(function(e){if("string"!=typeof e&&!(e instanceof Date))throw new TypeError("Expected a date string, got "+ce(e));var t=new Date(e);if(null==t.toJSON())throw new TypeError("Invalid date format, got "+ce(e));return t},function(e){return e.toISOString()});const Te=Ie(e=>p(pe(e)),e=>h(e).toLowerCase()),_e=Ie(e=>y(pe(e),{loose:!0}),e=>b(e,{pad:!1})),ke=Ie(e=>g(pe(e)),e=>w(e)),xe=we({voucherId:pe,activates:Ae,created:Ae,ip:pe,ipDescription:pe,deviceDescription:ue(pe)}),Pe=we({encryptionType:fe,data_base64:ke,iv_hex:Te}),Me=we({created:ue(Ae),data_base64:ke,encryptionType:fe,iv_hex:Te}),Ce=we({salt_hex:Te,n:fe,r:fe,p:fe}),Ne=we({loginRequest:ue(we({appId:pe}).withRest),publicKey:ke,timeout:ue(fe)}).withRest,je=we({publicKey:ke,box:Pe}),De=ge(ke),Re=we({data:ye,challengeId:ue(pe),deviceDescription:ue(pe),otp:ue(pe),syncToken:ue(pe),voucherId:ue(pe),voucherAuth:ue(ke),loginId:ue(ke),loginAuth:ue(ke),userId:ue(ke),passwordAuth:ue(ke),pin2Id:ue(ke),pin2Auth:ue(ke),recovery2Id:ue(ke),recovery2Auth:ue(De),loginIds:ue(ge(ke)),otpResetAuth:ue(pe),did:ue(pe),l1:ue(ke),lp1:ue(ke),lpin1:ue(ke),lra1:ue(ke),recoveryAuth:ue(ke)}),Le=we({results:ue(ye),status_code:fe,message:pe}),Be=we({otpTimeout:ue(fe,604800),otpKey:_e}),Ke=we({passwordAuth:ke,passwordAuthBox:Pe,passwordAuthSnrp:Ce,passwordBox:Pe,passwordKeySnrp:Ce}),Ue=we({pin2Id:ke}),Fe=we({pin2Id:ue(ke),pin2Auth:ue(ke),pin2Box:ue(Pe),pin2KeyBox:ue(Pe),pin2TextBox:Pe}),We=we({recovery2Id:ke}),Ge=we({recovery2Id:ke,recovery2Auth:De,recovery2Box:Pe,recovery2KeyBox:Pe,question2Box:Pe}),ze=we({loginAuthBox:Pe,loginAuth:ke}),qe=we({userId:ke,userTextBox:Pe}),$e=we({approvedVouchers:ue(ge(pe)),rejectedVouchers:ue(ge(pe))}),He=we({allowExisting:ue(de,!1),keyBoxes:ge(Pe),newSyncKeys:ue(ge(pe),()=>[])}),Ye=we({appId:pe,loginId:ke,parentBox:ue(Pe)}),Ve=we({challengeId:pe,challengeUri:pe}),Je=we({challengeId:pe,challengeUri:ue(pe)}),Xe=we({request:Ne,replies:ge(je)}),Ze=le(!0),Qe=we({appId:pe,created:Ae,loginId:ke,syncToken:ue(pe),children:ue(ge(e=>Qe(e))),parentBox:ue(Pe),otpKey:ue(ve(Ze,_e)),otpResetDate:ue(Ae),otpTimeout:ue(fe),passwordAuthBox:ue(Pe),passwordAuthSnrp:ue(Ce),passwordBox:ue(ve(Ze,Pe)),passwordKeySnrp:ue(Ce),pin2Box:ue(ve(Ze,Pe)),pin2KeyBox:ue(Pe),pin2TextBox:ue(Pe),question2Box:ue(Pe),recovery2Box:ue(ve(Ze,Pe)),recovery2KeyBox:ue(Pe),loginAuthBox:ue(Pe),userId:ue(ke),userTextBox:ue(Pe),pendingVouchers:ue(ge(xe),()=>[]),keyBoxes:ue(ge(Me)),mnemonicBox:ue(Pe),rootKeyBox:ue(Pe),syncKeyBox:ue(Pe)}),et=ge(we({loginId:ke,otpResetPending:ue(de,!1),pendingVouchers:ue(ge(xe),()=>[]),recovery2Corrupt:ue(de,!1)})),tt=we({login_id:ue(ke),otp_reset_auth:ue(pe),otp_timeout_date:ue(Ae),reason:ue(le("ip","otp"),"otp"),voucher_activates:ue(Ae),voucher_auth:ue(ke),voucher_id:ue(pe)}),nt=we({otpResetDate:Ae}),rt=we({wait_seconds:ue(fe)}),ot=we({question2Box:Pe}),it=we({loginId:ke,passwordAuthSnrp:ue(Ce),questionBox:ue(Pe),questionKeySnrp:ue(Ce),recoveryAuthSnrp:ue(Ce)}),at=Ee(Pe),st=Ee(je),ct=Ee(Ne),ut=Ee(Re),lt=Ee(Le),dt=Ee(Be),ft=Ee(Ke),pt=Ee(Ue),ht=Ee(Fe),yt=Ee(We),bt=Ee(Ge),gt=Ee(ze),wt=Ee(qe),vt=Ee($e),mt=Ee(He),It=Ee(Ye),Et=(Ee(Ve),Ee(Je),Ee(Xe)),St=Ee(Qe),Ot=Ee(et),At=Ee(tt),Tt=Ee(nt),_t=Ee(rt),kt=Ee(ot),xt=Ee(it),Pt=we(Pe),Mt=we({loginId:ke,voucherAuth:ke,voucherId:pe,created:Ae,activates:Ae,status:le("pending","approved","rejected"),ip:pe,ipDescription:pe,deviceDescription:ue(pe)}),Ct=we({appId:pe,created:ue(Ae,()=>new Date),loginId:ke,children:ue(ge(e=>Ct(e)),()=>[]),parentBox:ue(Pe),parentId:()=>{},otpKey:ue(_e),otpResetAuth:ue(pe),otpResetDate:ue(Ae),otpTimeout:ue(fe),passwordAuth:ue(ke),passwordAuthBox:ue(Pe),passwordAuthSnrp:ue(Ce),passwordBox:ue(Pe),passwordKeySnrp:ue(Ce),pin2Id:ue(ke),pin2Auth:ue(ke),pin2Box:ue(Pe),pin2KeyBox:ue(Pe),pin2TextBox:ue(Pe),recovery2Id:ue(ke),recovery2Auth:ue(De),question2Box:ue(Pe),recovery2Box:ue(Pe),recovery2KeyBox:ue(Pe),loginAuth:ue(ke),loginAuthBox:ue(Pe),userId:ue(ke),userTextBox:ue(Pe),keyBoxes:ue(ge(Me),()=>[]),mnemonicBox:ue(Pe),rootKeyBox:ue(Pe),syncKeyBox:ue(Pe),vouchers:ue(ge(Mt),()=>[]),pinBox:ue(Pe),pinId:ue(pe),pinKeyBox:ue(Pe)}),Nt=Ee(Ct),jt=Ee(Pt);var Dt=n(5364);const Rt=n.n(Dt)()("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),Lt={parse(e){return Rt.decode(e)},stringify(e){return Rt.encode(e)}},Bt={parse(e){const t=encodeURI(e),n=new Uint8Array(t.length);let r=0;for(let o=0;o<t.length;++o){const e=t.charCodeAt(o);37===e?(n[r++]=parseInt(t.slice(o+1,o+3),16),o+=2):n[r++]=e}return n.subarray(0,r)},stringify(e){let t="";for(let n=0;n<e.length;++n){const r=e[n];t+="%"+(r>>4).toString(16)+(15&r).toString(16)}return decodeURIComponent(t)}};function Kt(e,t="Login requires a CAPTCHA"){if(!(this instanceof Kt))throw new TypeError("Class constructor ChallengeError cannot be invoked without 'new'");var n;return function(e){n=new Error(e),Object.defineProperty(n,"constructor",{value:Kt,configurable:!0,writable:!0})}(t),n.name="ChallengeError",n.challengeId=e.challengeId,n.challengeUri=e.challengeUri,n}function Ut(e="Cannot reach the network"){if(!(this instanceof Ut))throw new TypeError("Class constructor NetworkError cannot be invoked without 'new'");var t;return function(e){t=new Error(e),Object.defineProperty(t,"constructor",{value:Ut,configurable:!0,writable:!0})}(e),t.name="NetworkError",t}function Ft(e="The application is too old. Please upgrade."){if(!(this instanceof Ft))throw new TypeError("Class constructor ObsoleteApiError cannot be invoked without 'new'");var t;return function(e){t=new Error(e),Object.defineProperty(t,"constructor",{value:Ft,configurable:!0,writable:!0})}(e),t.name="ObsoleteApiError",t}function Wt(e,t="Invalid OTP token"){if(!(this instanceof Wt))throw new TypeError("Class constructor OtpError cannot be invoked without 'new'");var n;!function(e){n=new Error(e),Object.defineProperty(n,"constructor",{value:Wt,configurable:!0,writable:!0})}(t),n.name="OtpError",n.reason="otp";const r=me(tt)(e);if(null!=r)return null!=r.login_id&&(n.loginId=w(r.login_id)),n.resetToken=r.otp_reset_auth,n.reason=r.reason,n.resetDate=r.otp_timeout_date,n.voucherActivates=r.voucher_activates,null!=r.voucher_auth&&(n.voucherAuth=w(r.voucher_auth)),n.voucherId=r.voucher_id,n}function Gt(e,t="Invalid password"){if(!(this instanceof Gt))throw new TypeError("Class constructor PasswordError cannot be invoked without 'new'");var n;!function(e){n=new Error(e),Object.defineProperty(n,"constructor",{value:Gt,configurable:!0,writable:!0})}(t),n.name="PasswordError";const r=me(rt)(e);if(null!=r)return n.wait=r.wait_seconds,n}function zt(e){if(!(this instanceof zt))throw new TypeError("Class constructor PinDisabledError cannot be invoked without 'new'");var t;return function(e){t=new Error(e),Object.defineProperty(t,"constructor",{value:zt,configurable:!0,writable:!0})}(e),t.name="PinDisabledError",t}function qt(e="Invalid username"){if(!(this instanceof qt))throw new TypeError("Class constructor UsernameError cannot be invoked without 'new'");var t;return function(e){t=new Error(e),Object.defineProperty(t,"constructor",{value:qt,configurable:!0,writable:!0})}(e),t.name="UsernameError",t}function $t(e){return function(t){if(t instanceof Error&&t.name===e){return t}}}$t("ChallengeError"),$t("DustSpendError");const Ht=$t("InsufficientFundsError"),Yt=($t("NetworkError"),$t("NoAmountSpecifiedError"),$t("ObsoleteApiError"),$t("OtpError")),Vt=$t("PasswordError"),Jt=$t("PinDisabledError"),Xt=$t("PendingFundsError"),Zt=($t("SameCurrencyError"),$t("SpendToSelfError"),$t("SwapAboveLimitError")),Qt=$t("SwapBelowLimitError"),en=$t("SwapCurrencyError"),tn=$t("SwapPermissionError"),nn=$t("SwapAddressError"),rn=$t("UsernameError");var on=n(3836);function an(e,t){const n=i().hmac(i().sha256,t);return Uint8Array.from(n.update(e).digest())}function sn(e){const t=i().sha256();return Uint8Array.from(t.update(e).digest())}function cn(e,t){const n=e.length;if(n!==t.length)return!1;let r=0;for(let o=0;o<n;++o)r|=e[o]^t[o];return 0===r}const un=n.n(on)().ModeOfOperation.cbc;function ln(e,t){const n=dn(e,t);return 0===n[n.length-1]?Bt.stringify(n.subarray(0,-1)):Bt.stringify(n)}function dn(e,t){if(0!==e.encryptionType)throw new Error("Unknown encryption type");const n=e.iv_hex,r=e.data_base64,o=new un(t,n).decrypt(r),i=1+o[0]+4,a=o[i-4]<<24|o[i-3]<<16|o[i-2]<<8|o[i-1],s=i+a+1,c=s+o[s-1],u=c+32;if(!cn(sn(o.subarray(0,c)),o.subarray(c,u)))throw new Error("Invalid checksum");if(!cn(pn(u),o.subarray(u)))throw new Error("Invalid PKCS7 padding");return o.subarray(i,i+a)}function fn(e,t,n){const r=31&e.random(1)[0],o=1+r+4,i=t.length,a=o+i+1,s=31&e.random(1)[0],c=a+s,u=c+32,l=pn(u),d=new Uint8Array(u+l.length);d.set(l,u),d[0]=r,d.set(e.random(r),1),d[o-4]=i>>24&255,d[o-3]=i>>16&255,d[o-2]=i>>8&255,d[o-1]=255&i,d.set(t,o),d[a-1]=s,d.set(e.random(s),a),d.set(sn(d.subarray(0,c)),c);const f=e.random(16);return{encryptionType:0,iv_hex:f,data_base64:new un(n,f).encrypt(d)}}function pn(e){const t=new Uint8Array(16-(15&e));for(let n=0;n<t.length;++n)t[n]=t.length;return t}function hn(e,t,n){const r=function(e,t){const n=i().hmac(i().sha1,t);return Uint8Array.from(n.update(e).digest())}(function(e){const t=Math.floor(e/4294967296);return new Uint8Array([t>>24&255,t>>16&255,t>>8&255,255&t,e>>24&255,e>>16&255,e>>8&255,255&e])}(t),e),o=15&r[19],a=((127&r[o])<<24|r[o+1]<<16|r[o+2]<<8|r[o+3]).toString();return(Array(n).join("0")+a).slice(-n)}function yn(e,t=Date.now()/1e3){return hn(e,t/30,6)}function bn(...e){return[].concat(...e.filter(e=>null!=e))}function gn(e,t){for(const n of Object.keys(t))Object.defineProperty(e,n,{writable:!0,configurable:!0,value:t[n]});return e}function wn(e,t,n=new Error(`Timeout of ${t}ms exceeded`)){return new Promise((r,o)=>{const i=setTimeout(()=>o(n),t);e.then(e=>{clearTimeout(i),r(e)},e=>{clearTimeout(i),o(e)})})}function vn(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function mn(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?vn(Object(n),!0).forEach(function(t){r(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):vn(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}async function In(e,t,n,r){const{loginServers:o}=e.props.state.login,i=Math.floor(255*Math.random());let a,s=new Error("No login servers available");for(let l=0;l<o.length;++l)try{const s=(i+l)%o.length;a=await En(e,o[s],t,n,r);break}catch(u){s=u}if(null==a)throw s;const{status:c}=a;return function(e){const t=Le(e);switch(t.status_code){case 0:return t.results;case 2:throw new qt("Account already exists on server");case 3:throw new qt("Account does not exist on server");case 4:case 5:throw new Gt(t.results);case 6:throw new Error("Invalid API key");case 8:throw new Wt(t.results);case 1e3:throw new Ft;default:{const e=me(Ve)(t.results);if(null!=e)throw new Kt(e);throw new Error(`Server error: ${t.message}`)}}}(await a.json().catch(()=>{throw new Error(`Invalid reply JSON, HTTP status ${c}`)}))}function En(e,t,n,r,o){const{state:i,io:a,log:s}=e.props,{apiKey:c,apiSecret:u,attestationToken:l}=i.login,d="GET"===n||null==o?void 0:JSON.stringify(ut(o));let f=`Token ${c}`;if(null!=u){const e=`${n}\n/api${r}\n${null!=d?d:""}`,t=an(Bt.parse(e),u);f=`HMAC ${c} ${w(t)}`}const p={body:d,method:n,headers:mn({"content-type":"application/json",accept:"application/json",authorization:f},null!=l?{"x-attestation-token":l}:{}),corsBypass:"never"},h=Date.now(),y=`${t}/api${r}`;return wn(a.fetch(y,p),3e4).then(e=>{const t=Date.now()-h;return s(`${n} ${y} returned ${e.status} in ${t}ms`),409===e.status&&s.crash("Login API conflict error",{path:r}),e},e=>{const t=Date.now()-h;throw s.error(`${n} ${y} failed in ${t}ms, ${String(e)}`),new Ut(`Could not reach the auth server: ${r}`)})}function Sn(e,t){const{io:n}=e.props,{loginId:r,loginKey:o}=t,i=n.random(32),a=fn(n,i,o);return{loginId:r,server:gt({loginAuth:i,loginAuthBox:a}),serverPath:"/v2/login/secret",stash:{loginAuthBox:a}}}function On(e,t=2e3){return e.props.output.scrypt.makeSnrp(t)}async function An(e,t,n){"string"==typeof t&&(t=Bt.parse(t));return(await e.props.output.scrypt.timeScrypt(t,n)).hash}const Tn={salt_hex:Uint8Array.from([181,134,95,251,159,167,179,191,228,178,56,77,71,206,131,30,226,42,74,157,92,52,199,239,125,33,70,124,199,88,248,27]),n:16384,r:1,p:1};function _n(e){return{username:e,appId:"",loginId:new Uint8Array(0),pendingVouchers:[]}}function kn(e,t){const{stashes:n}=e.props.state.login;for(const r of n)if(r.username===t)return r}function xn(e,t){const{stashes:n}=e.props.state.login;for(const r of n){const e=r,n=zn(e,e=>cn(e.loginId,t));if(null!=n)return{stashTree:e,stash:n}}throw new Error(`Cannot find stash '${w(t)}'`)}function Pn(e,t){const n=zn(e,e=>cn(e.loginId,t));if(null!=n)return n;throw new Error(`Cannot find child stash '${w(t)}'`)}const Mn={};function Cn(e,t){return null==Mn[t]&&(Mn[t]=An(e,t,Tn)),Mn[t]}async function Nn(e,t){const n=[],r=await e.list("logins").then(re.WR);for(const i of r)try{n.push(Dn(JSON.parse(await e.getText(i))))}catch(o){t.error(`Could not load ${i}: ${String(o)}`)}return n}async function jn(e,t){const{dispatch:n,io:r}=e.props,{appId:o,loginId:i}=t;if(""!==o)throw new Error("Cannot save a login without an appId.");if(null==i||32!==i.length)throw new Error("Invalid loginId");await r.disklet.setText(`logins/${Lt.stringify(i)}.json`,JSON.stringify(Rn(t))),n({type:"LOGIN_STASH_SAVED",payload:t})}const Dn=we({appId:pe,created:ue(Ae),lastLogin:ue(Ae),loginId:ke,otpKey:ue(_e),otpResetDate:ue(Ae),otpTimeout:ue(fe),pendingVouchers:ue(ge(xe),()=>[]),voucherId:ue(pe),voucherAuth:ue(ke),loginAuthBox:ue(Pe),parentBox:ue(Pe),passwordAuthBox:ue(Pe),passwordAuthSnrp:ue(Ce),passwordBox:ue(Pe),passwordKeySnrp:ue(Ce),pin2Key:ue(Ie(e=>{const t=pe(e);return"="!==e.slice(-1)?Lt.parse(t):g(t)},e=>w(e))),pin2TextBox:ue(Pe),recovery2Key:ue(ke),userId:ue(ke),username:ue(e=>ae(pe(e))),children:ue(ge(e=>Dn(e))),keyBoxes:ue(ge(Me)),mnemonicBox:ue(Pe),rootKeyBox:ue(Pe),syncKeyBox:ue(Pe),wipChange:ue(e=>Dn(e))}),Rn=Ee(Dn);function Ln(e,t){const n=t.endsWith(".duress")?t:t+".duress";return e.appId===n?e:zn(e,e=>e.appId===n)}function Bn(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Kn(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Bn(Object(n),!0).forEach(function(t){r(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Bn(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Un(e){if(null!=e.otpKey)return yn(e.otpKey)}function Fn(e,t){const{otp:n,otpKey:r}=t;return null!=n?n:null!=r?yn(y(r,{loose:!0})):null!=e.otpKey?yn(e.otpKey):void 0}function Wn(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Gn(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Wn(Object(n),!0).forEach(function(t){r(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Wn(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function zn(e,t){if(t(e))return e;const n=e;if(null!=n.children)for(const r of n.children){const e=zn(r,t);if(null!=e)return e}}function qn(e,t,n,r){if(t(e))return n(e);const o=null!=e.children?e.children.map(e=>qn(e,t,n,r)):[];return r(e,o)}function $n(e,t,n){const{children:r=[]}=e,{appId:o,created:i,loginId:a,loginAuthBox:s,userId:c,otpKey:u,otpResetDate:l,otpTimeout:d,pendingVouchers:f,parentBox:p,passwordAuthBox:h,passwordAuthSnrp:y,passwordBox:b,passwordKeySnrp:g,pin2TextBox:w,children:v=[],keyBoxes:m=[],mnemonicBox:I,rootKeyBox:E,syncKeyBox:S,syncToken:O}=n,A={appId:o,created:i,loginId:a,loginAuthBox:s,userId:c,otpKey:!0===u?e.otpKey:u,otpResetDate:l,otpTimeout:d,pendingVouchers:f,parentBox:p,passwordAuthBox:h,passwordAuthSnrp:y,passwordBox:!0===b?e.passwordBox:b,passwordKeySnrp:g,pin2TextBox:w,keyBoxes:m,mnemonicBox:I,rootKeyBox:E,syncKeyBox:S,syncToken:O};null!=e.lastLogin&&(A.lastLogin=e.lastLogin),null!=e.username&&(A.username=e.username),null!=e.userId&&null==A.userId&&(A.userId=e.userId),null!=n.pin2KeyBox&&(A.pin2Key=dn(n.pin2KeyBox,t)),null!=n.recovery2KeyBox&&(A.recovery2Key=dn(n.recovery2KeyBox,t)),null!=n.userTextBox&&(A.username=Bt.stringify(dn(n.userTextBox,t))),v.sort((e,t)=>e.created.valueOf()-t.created.valueOf()),A.children=v.map(e=>{const{appId:n,loginId:o,parentBox:i}=e;if(null==i)throw new Error("Key integrity violation: No parentBox on child login.");const a=dn(i,t),s=r.find(e=>cn(e.loginId,o));return $n(null!=s?s:{appId:n,loginId:o,pendingVouchers:[]},a,e)});for(const{loginId:T}of r){if(null==v.find(e=>cn(e.loginId,T)))throw new Error("The server has lost children!")}return A}function Hn(e,t,n){return qn(e,e=>e.appId===n.appId,e=>$n(e,t,n),(e,t)=>Gn(Gn({},e),{},{children:t,wipChange:void 0}))}function Yn(e,t){const{appId:n,created:r,lastLogin:o=new Date,loginId:i,otpKey:a,otpResetDate:s,otpTimeout:c,pendingVouchers:u,userId:l,username:d,children:f=[]}=e,p={appId:n,created:r,isRoot:null==e.parentBox,lastLogin:o,loginId:i,loginKey:t,otpKey:a,otpResetDate:s,otpTimeout:c,pendingVouchers:u,userId:l,username:d,children:[]};if(null!=e.loginAuthBox&&(p.loginAuth=dn(e.loginAuthBox,t)),null!=e.passwordAuthBox&&(null==p.userId&&(p.userId=i),p.passwordAuth=dn(e.passwordAuthBox,t)),null==p.loginAuth&&null==p.passwordAuth)throw new Error("No server authentication methods on login");return p.pin2Key=e.pin2Key,null!=e.pin2TextBox&&(p.pin=ln(e.pin2TextBox,t)),p.recovery2Key=e.recovery2Key,p.children=f.map(e=>{if(null==e.parentBox)throw new Error("Key integrity violation: No parentBox on child login.");return Yn(e,dn(e.parentBox,t))}),p}function Vn(e,t){return qn(e,e=>cn(e.loginId,t.loginId),e=>Yn(e,t.loginKey),(e,t)=>{const{appId:n,lastLogin:r=new Date,loginId:o,otpKey:i,pendingVouchers:a,username:s}=e;return{appId:n,children:t,isRoot:null==e.parentBox,lastLogin:r,loginId:o,loginKey:void 0,otpKey:i,pendingVouchers:a,username:s}})}function Jn(e,t){return qn(e,e=>e.appId===t,e=>e,(e,t)=>{const{appId:n,loginId:r,username:o}=e;return{appId:n,children:t,loginId:r,pendingVouchers:[],username:o}})}async function Xn(e,t,n,r,o,i){const{now:a=new Date}=r,{deviceDescription:s}=e.props.state.login.deviceInfo,c=Gn({challengeId:r.challengeId,otp:Fn(n,r),voucherId:n.voucherId,voucherAuth:n.voucherAuth},o);null!=s&&(c.deviceDescription=s);let u=Qe(await In(e,"POST","/v2/login",c).catch(r=>{const o=Yt(r);throw null!=o&&(0===n.loginId.length&&null!=o.loginId||null!=o.voucherId&&null!=o.voucherAuth)&&(null!=o.loginId&&(n.loginId=g(o.loginId)),null!=o.voucherAuth&&(n.voucherId=o.voucherId,n.voucherAuth=g(o.voucherAuth)),t.lastLogin=a,jn(e,t).catch(()=>{})),r}));const{loginId:l}=u,d=await i(u);if((t=Hn(t,d,u)).lastLogin=a,await jn(e,t),null==u.loginAuthBox){const{stash:t,stashTree:n}=xn(e,l),i=Sn(e,{loginId:l,loginKey:d}),a=Gn(Gn({},o),{},{otp:Fn(t,r),data:i.server});u=Qe(await In(e,"POST",i.serverPath,a)),await jn(e,Hn(n,d,u))}return{loginId:l,loginKey:d}}async function Zn(e,t,n){const{serverMethod:r="POST",serverPath:o}=n,{stashTree:i}=xn(e,n.loginId),{deviceDescription:a}=e.props.state.login.deviceInfo,s=qn(i,e=>cn(e.loginId,n.loginId),e=>Gn(Gn(Gn({},e),n.stash),{},{children:bn(e.children,n.stash.children),keyBoxes:bn(e.keyBoxes,n.stash.keyBoxes),wipChange:void 0}),(e,t)=>Gn(Gn({},e),{},{children:t,wipChange:void 0}));if(""!==o&&(i.wipChange=s,await jn(e,i)),""!==o){const s=nr(i,tr(i,t,n.loginId));null!=a&&(s.deviceDescription=a),s.data=n.server;try{await In(e,r,o,s)}catch(c){throw er(e,t).catch(()=>{}),c}}return await jn(e,s),s}async function Qn(e,t,n){for(const r of n)null!=r&&await Zn(e,t,r)}async function er(e,t){const{stashTree:n,stash:r}=xn(e,t.loginId),{syncToken:o}=r;if(null!=o)try{if(de(await In(e,"POST","/v2/sync",{loginId:r.loginId,syncToken:o})))return}catch(s){}const i=nr(n,t),a={now:n.lastLogin};await Xn(e,n,r,a,i,async()=>t.loginKey)}function tr(e,t,n){var r;if(cn(n,t.loginId))return t;const o=Pn(e,t.loginId),i=function e(t,r){for(const o of t){if(null==o.parentBox)continue;if(cn(o.loginId,n))return{loginId:o.loginId,loginKey:dn(o.parentBox,r)};const{children:t=[]}=o;if(0===t.length)continue;const i=e(t,dn(o.parentBox,r));if(null!=i)return i}}(null!==(r=null==o?void 0:o.children)&&void 0!==r?r:[],t.loginKey);if(null==i)throw new Error(`Cannot decrypt child login '${w(t.loginId)}'`);return i}function nr(e,t){const n=Pn(e,t.loginId),{loginAuthBox:r,otpKey:o,passwordAuthBox:i,syncToken:a,userId:s,voucherAuth:c,voucherId:u}=n,l=null!=o?yn(o):void 0;if(null!=r)return{loginAuth:dn(r,t.loginKey),loginId:t.loginId,otp:l,syncToken:a,voucherAuth:c,voucherId:u};if(null!=i&&null!=s)return{passwordAuth:dn(i,t.loginKey),userId:s,otp:l,syncToken:a,voucherAuth:c,voucherId:u};throw new Error("No server authentication methods available")}var rr=n(9112);rr.jG,rr.ZU,rr.CS,rr.ve,rr.q3,rr.FX,rr.yq,rr.w2,rr.CG,rr.Kr,rr.l3,rr.N0,rr.MH,rr.fs,rr.FA;const or=rr.NL;rr.Tb;function ir(e){return"Minified Redux error #"+e+"; visit https://redux.js.org/Errors?code="+e+" for the full message or use the non-minified dev environment for full errors. "}var ar="function"==typeof Symbol&&Symbol.observable||"@@observable",sr=function(){return Math.random().toString(36).substring(7).split("").join(".")},cr={INIT:"@@redux/INIT"+sr(),REPLACE:"@@redux/REPLACE"+sr(),PROBE_UNKNOWN_ACTION:function(){return"@@redux/PROBE_UNKNOWN_ACTION"+sr()}};function ur(e){if("object"!=typeof e||null===e)return!1;for(var t=e;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}function lr(e,t,n){var r;if("function"==typeof t&&"function"==typeof n||"function"==typeof n&&"function"==typeof arguments[3])throw new Error(ir(0));if("function"==typeof t&&void 0===n&&(n=t,t=void 0),void 0!==n){if("function"!=typeof n)throw new Error(ir(1));return n(lr)(e,t)}if("function"!=typeof e)throw new Error(ir(2));var o=e,i=t,a=[],s=a,c=!1;function u(){s===a&&(s=a.slice())}function l(){if(c)throw new Error(ir(3));return i}function d(e){if("function"!=typeof e)throw new Error(ir(4));if(c)throw new Error(ir(5));var t=!0;return u(),s.push(e),function(){if(t){if(c)throw new Error(ir(6));t=!1,u();var n=s.indexOf(e);s.splice(n,1),a=null}}}function f(e){if(!ur(e))throw new Error(ir(7));if(void 0===e.type)throw new Error(ir(8));if(c)throw new Error(ir(9));try{c=!0,i=o(i,e)}finally{c=!1}for(var t=a=s,n=0;n<t.length;n++){(0,t[n])()}return e}return f({type:cr.INIT}),(r={dispatch:f,subscribe:d,getState:l,replaceReducer:function(e){if("function"!=typeof e)throw new Error(ir(10));o=e,f({type:cr.REPLACE})}})[ar]=function(){var e,t=d;return(e={subscribe:function(e){if("object"!=typeof e||null===e)throw new Error(ir(11));function n(){e.next&&e.next(l())}return n(),{unsubscribe:t(n)}}})[ar]=function(){return this},e},r}function dr(e){function t(t){var n=void 0,r=void 0,o=!0,i=!1,a=!1,s=void 0,c=void 0,u=void 0;function l(){if(n){try{if(c){var e=c;s=void 0,c=void 0,u=void 0,e(((r=new Error("Pixie has been destroyed")).name="PixieShutdownError",r))}var t=n;n=void 0,t.destroy()}catch(r){d(r)}a=!0}var r}function d(e){a||t.onError(e),l()}function f(){i=!1,p()}function p(){for(;n&&o&&!i;){o=!1,i=!0;try{var e=n.update(r);e&&"function"==typeof e.then?e.then(f,d):i=!1}catch(t){d(t)}}}function h(){return s||(s=new Promise(function(e,t){u=e,c=t})),s}var y={onError:d,onOutput:function(e){a||t.onOutput(e)},get props(){return r},nextProps:h,waitFor:function(e){return new Promise(function(t,n){return function o(){try{var i=e(r);null!=i?t(i):h().then(o,n)}catch(a){n(a)}}()})}};try{n=function(e){return"function"==typeof e?{update:e,destroy:function(){}}:e}(e(y))}catch(b){d(b)}return{update:function(e){if(r=e,o=!0,u){var t=u;s=void 0,c=void 0,u=void 0,t(e)}p()},destroy:l}}return t.tame=!0,t.defaultOutput=e.defaultOutput,t}function fr(e){return e.tame?e:dr(e)}function pr(e,t,n){n(e)}var hr="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},yr=(function(){function e(e){this.value=e}function t(t){var n,r;function o(n,r){try{var a=t[n](r),s=a.value;s instanceof e?Promise.resolve(s.value).then(function(e){o("next",e)},function(e){o("throw",e)}):i(a.done?"return":"normal",a.value)}catch(c){i("throw",c)}}function i(e,t){switch(e){case"return":n.resolve({value:t,done:!0});break;case"throw":n.reject(t);break;default:n.resolve({value:t,done:!1})}(n=n.next)?o(n.key,n.arg):r=null}this._invoke=function(e,t){return new Promise(function(i,a){var s={key:e,arg:t,resolve:i,reject:a,next:null};r?r=r.next=s:(n=r=s,o(e,t))})},"function"!=typeof t.return&&(this.return=void 0)}"function"==typeof Symbol&&Symbol.asyncIterator&&(t.prototype[Symbol.asyncIterator]=function(){return this}),t.prototype.next=function(e){return this._invoke("next",e)},t.prototype.throw=function(e){return this._invoke("throw",e)},t.prototype.return=function(e){return this._invoke("return",e)}}(),function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}()),br=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e};function gr(e){}function wr(e){}function vr(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:gr,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:wr;return function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:pr,n=fr(e);function r(e){var r=e.onOutput,o=void 0,i=void 0,a=function(){var e=o;o=void 0,e&&e.destroy()},s={onError:function(n){a();try{t(n,i,e.onError)}catch(n){e.onError(n)}},onOutput:r};return{update:function(e){i=e,o||(o=n(s)),o.update(e)},destroy:a}}return r.tame=!0,r.defaultOutput=e.defaultOutput,r}(function(e){var t=fr(e);function n(n){var r=n.onError,o=void 0,i=e.defaultOutput,a=void 0,s=!0,c=!1,u=function(){for(;o&&s&&!c;)s=!1,c=!0,o.update(br({},a,{output:i})),c=!1},l={onError:r,onOutput:function(e){e!==i&&(i=e,s=!0,n.onOutput(e),u())}};return{update:function(e){a=e,s=!0,o||(o=t(l)),u()},destroy:function(){var e=o;o=void 0,e&&e.destroy()}}}return n.tame=!0,n.defaultOutput=e.defaultOutput,n}(e))({onError:t,onOutput:n})}function mr(e){var t={},n=Object.keys(e),r=Array.isArray(n),o=0;for(n=r?n:n[Symbol.iterator]();;){var i;if(r){if(o>=n.length)break;i=n[o++]}else{if((o=n.next()).done)break;i=o.value}var a=i;t[a]=e[a].defaultOutput}function s(n){var r=n.onError,o={},i={},a=br({},t),s=!1,c=function(){if(l){if(d>=u.length)return"break";f=u[d++]}else{if((d=u.next()).done)return"break";f=d.value}var t=f;if(o[t]={onError:r,onOutput:function(e){e!==a[t]&&((a=br({},a))[t]=e,n.onOutput(a))}},i[t]=fr(e[t])(o[t]),s)return"break"},u=Object.keys(e),l=Array.isArray(u),d=0;for(u=l?u:u[Symbol.iterator]();;){var f;if("break"===c())break}return{update:function(e){var t=Object.keys(i),n=Array.isArray(t),r=0;for(t=n?t:t[Symbol.iterator]();;){var o;if(n){if(r>=t.length)break;o=t[r++]}else{if((r=t.next()).done)break;o=r.value}if(i[o].update(e),s)return}},destroy:function(){s=!0;var e=Object.keys(i),t=Array.isArray(e),n=0;for(e=t?e:e[Symbol.iterator]();;){var r;if(t){if(n>=e.length)break;r=e[n++]}else{if((n=e.next()).done)break;r=n.value}i[r].destroy()}}}}return s.tame=!0,s.defaultOutput=t,s}function Ir(e,t){return function(){try{return e.apply(void 0,arguments)}catch(n){t(n)}}}function Er(e,t){if(e===t)return!0;if("object"!==(void 0===e?"undefined":hr(e)))return!1;if("object"!==(void 0===t?"undefined":hr(t)))return!1;if(!e||!t)return!1;var n=Object.getOwnPropertyNames(e);if(n.length!==Object.getOwnPropertyNames(t).length)return!1;var r=n,o=Array.isArray(r),i=0;for(r=o?r:r[Symbol.iterator]();;){var a;if(o){if(i>=r.length)break;a=r[i++]}else{if((i=r.next()).done)break;a=i.value}var s=a;if(!Object.prototype.hasOwnProperty.call(t,s)||e[s]!==t[s])return!1}return!0}function Sr(e,t){var n=fr(e);function r(e){var r=e.onError,o=e.onOutput,i=void 0,a=void 0,s=!1,c=Ir(t,r),u={onError:r,onOutput:o};return{update:function(e){var t=c(e);if(!s){var r=!Er(t,a);if(a=t,t){if(i||(i=n(u)),s)return;r&&i.update(t)}else i&&i.destroy(),i=void 0}},destroy:function(){s=!0,i&&i.destroy(),i=void 0}}}return r.tame=!0,r.defaultOutput=e.defaultOutput,r}function Or(e,t,n){var r=fr(e);function o(e){var o=e.onError,i={},a={},s=!1,c={},u=!1,l=!1,d=Ir(t,o),f=Ir(n,o),p=function(){if(s&&!u){s=!1;var t={},n=Object.keys(i),r=Array.isArray(n),o=0;for(n=r?n:n[Symbol.iterator]();;){var c;if(r){if(o>=n.length)break;c=n[o++]}else{if((o=n.next()).done)break;c=o.value}var l=c;t[l]=a[l]}a=t,e.onOutput(a)}};return{update:function(e){var t=d(e);if(!l&&t){u=!0;var n={},h=function(){if(b){if(g>=y.length)return"break";w=y[g++]}else{if((g=y.next()).done)return"break";w=g.value}var t=w,u=f(e,t);if(l)return{v:void 0};var d=!Er(u,c[t]);if(c[t]=u,u){if(!i[t]){if(i[t]=r({onError:o,onOutput:function(e){e!==a[t]&&(a[t]=e,s=!0,p())}}),l)return{v:void 0}}if(d&&i[t].update(u),l)return{v:void 0};n[t]=i[t]}};var y=t,b=Array.isArray(y),g=0;e:for(y=b?y:y[Symbol.iterator]();;){var w,v=h();if("break"===v)break e;if("object"===(void 0===v?"undefined":hr(v)))return v.v}var m=i;i=n;var I=Object.keys(m),E=Array.isArray(I),S=0;for(I=E?I:I[Symbol.iterator]();;){var O;if(E){if(S>=I.length)break;O=I[S++]}else{if((S=I.next()).done)break;O=S.value}var A=O;n[A]||(s=!0,m[A].destroy())}l||(u=!1,p())}},destroy:function(){l=!0;var e=Object.keys(i),t=Array.isArray(e),n=0;for(e=t?e:e[Symbol.iterator]();;){var r;if(t){if(n>=e.length)break;r=e[n++]}else{if((n=e.next()).done)break;r=n.value}var o=r;i[o]&&i[o].destroy()}}}}return o.tame=!0,o.defaultOutput={},o}!function(){function e(t,n){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.props=t}yr(e,[{key:"update",value:function(e,t){}},{key:"destroy",value:function(e,t){}}])}();var Ar={then:function(){}};function Tr(e){const t=new URL(e);if("http:"!==t.protocol&&"ws:"!==t.protocol||!function(e){if("localhost"===e)return!0;const t=function(e){const t=e.split(".");if(4!==t.length)return null;const n=[];for(const r of t){if(!/^\d{1,3}$/.test(r))return null;const e=Number(r);if(!Number.isInteger(e)||e<0||e>255)return null;if(r.length>1&&r.startsWith("0"))return null;n.push(e)}return n}(e);if(null==t)return!1;const[n,r]=t;return 127===n||(10===n||(192===n&&168===r||172===n&&r>=16&&r<=31))}(t.hostname)){if("https:"===t.protocol||"wss:"===t.protocol){if("localhost"===t.hostname)return;if(/^([A-Za-z0-9_-]+\.)*edge(test)?\.app$/.test(t.hostname))return}throw new Error(`Only *.edge.app, localhost, or private LAN addresses (http/ws) are valid login domain names, not ${t.hostname}`)}}function _r(e){const t=Ee(e);return{async load(t,n){try{return e(JSON.parse(await t.getText(n)))}catch(r){}},async save(e,n,r){await e.setText(n,JSON.stringify(t(r)))}}}const kr=e=>{if(null==e||"object"!=typeof e)throw new TypeError("Expected a JSON object");return e},xr="client.json",Pr=_r(we({clientId:ke,duressEnabled:me(de,!1),loginWaitTimestamps:me(we(fe),()=>({}))})),Mr="infoCache.json",Cr=we({corePlugins:we(kr),syncServers:ge(pe)}),Nr=_r(Cr);function jr(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Dr(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?jr(Object(n),!0).forEach(function(t){r(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):jr(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Rr(e,t,n){return function(){let r="";for(let e=0;e<arguments.length;++e){const t=arguments[e];e>0&&(r+=" "),"string"==typeof t?r+=t:t instanceof Error?r+=String(t):r+=JSON.stringify(t,null,2)}e({message:r,source:n,time:new Date,type:t})}}function Lr(e,t){const{onLog:n,crashReporter:r}=e;return gn(Rr(n,"info",t),{breadcrumb(e,o){const i=new Date;null!=r?r.logBreadcrumb({message:e,metadata:o,source:t,time:i}):(e=`${e} ${JSON.stringify(o,null,2)}`,n({message:e,source:t,time:i,type:"warn"}))},crash(e,o){const i=new Date;if(null!=r)r.logCrash({error:e,metadata:o,source:t,time:i});else{const r=`${String(e)} ${JSON.stringify(o,null,2)}`;n({message:r,source:t,time:i,type:"error"})}},warn:Rr(n,"warn",t),error:Rr(n,"error",t)})}const Br=Ie(e=>Lt.parse(pe(e)),e=>Lt.stringify(e)),Kr=_r(we({SNRP2:Ce,SNRP3:ue(Ce),SNRP4:ue(Ce),ERQ:ue(Pe)})),Ur=_r(we({EMK_LP2:Pe,EMK_LRA3:ue(Pe),ESyncKey:Pe,ELP1:Pe})),Fr=_r(we({TOTP:_e})),Wr=_r(we({pin2Key:Br})),Gr=_r(we({recovery2Key:Br})),zr=_r(we({userName:pe}));function qr(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function $r(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?qr(Object(n),!0).forEach(function(t){r(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):qr(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}const Hr={};let Yr=!1;const Vr=[],Jr=[];function Xr(){Yr=!0;for(const e of Jr)e()}function Zr(e,t,n={}){const{onError:r=()=>{}}=n;let o,i=!1;function a(){o=void 0,u.started&&(i=!0,new Promise(t=>t(e())).catch(r).then(c,c))}function s(e){i=!1,u.started&&(o=setTimeout(a,e))}function c(){s(t)}const u={started:!1,setDelay(e){t=e},start(e={}){const{wait:n}=e;u.started=!0,i||null!=o||("number"==typeof n?s(n):!0===n?s(t):a())},stop(){u.started=!1,null!=o&&(clearTimeout(o),o=void 0)}};return u}function Qr(e){return new Promise(t=>setTimeout(()=>t(e),e))}function eo(e,t){const n=to(e,t);if(null==n)throw new Error(`Cannot find a currency plugin for wallet type ${t}`);return n}function to(e,t){return Object.keys(e).find(n=>e[n].currencyInfo.walletType===t)}function no(e,t){const{dispatch:n,state:r}=e.props,o=r.plugins.currencyTools[t];if(null!=o)return o;const i=r.plugins.currency[t].makeCurrencyTools();return n({type:"CURRENCY_TOOLS_LOADED",payload:{pluginId:t,tools:i}}),i}const ro=we({dataKey:ke,syncKey:ke}),oo=Ee(ro);function io(e){const{io:t}=e.props;return{dataKey:t.random(32),syncKey:t.random(20)}}function ao(e,t,n){const r={delete(e){return n.delete(e)},async getData(e){const r=await n.getText(e);return dn(Pe(JSON.parse(r)),t)},async getText(e){const r=await n.getText(e);return ln(Pe(JSON.parse(r)),t)},list(e){return n.list(e)},setData(r,o){return n.setText(r,JSON.stringify(at(fn(e,Uint8Array.from(o),t))))},setText(e,t){return this.setData(e,Bt.parse(t))}};return P(r),r}function so(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function co(e,t){return(0,re.my)(e.disklet,"local/"+Lt.stringify(g(t)))}function uo(e,t){const{dataKey:n,syncKey:r}=t,o=(0,re.my)(e.disklet,"repos/"+Lt.stringify(sn(sn(r)))),i=(0,re.my)(o,"changes"),a=(0,re.my)(o,"data");return{dataKey:n,syncKey:r,baseDisklet:o,changesDisklet:i,dataDisklet:a,disklet:ao(e,n,(0,re.mi)(i,a))}}function lo(e){const t={lastSync:0,lastHash:void 0};return e.baseDisklet.getText("status.json").then(e=>function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?so(Object(n),!0).forEach(function(t){r(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):so(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}({lastSync:0},JSON.parse(e))).catch(()=>t)}async function fo(e,t){await Promise.all(Object.keys(t).map(n=>{const r=t[n];return null!=r?e.setText(n,JSON.stringify(at(r))):e.delete(n)}))}async function po(e,t,n){const{changesDisklet:r,dataDisklet:o,syncKey:i}=t,a=await ho(r).then(e=>Promise.all(e.map(async e=>({path:e,box:Pe(JSON.parse(await r.getText(e)))})))),s=h(i).toLowerCase(),c=await(()=>{if(0===a.length)return e.readRepo(s,n.lastHash);const t={};for(const e of a)t[e.path]=at(e.box);return e.updateRepo(s,n.lastHash,{changes:t})})(),{hash:u}=c,l={};for(const f of Object.keys(null!==(d=c.changes)&&void 0!==d?d:{})){var d;const e=c.changes[f];l[f]=null==e?null:Pe(e)}return await fo(o,l),await Promise.all(a.map(e=>r.delete(e.path))),n.lastSync=Date.now()/1e3,null!=u&&(n.lastHash=u),await t.baseDisklet.setText("status.json",JSON.stringify(n)),{status:n,changes:l}}async function ho(e,t="",n=100){const r=await e.list(t),o=Object.keys(r).filter(e=>"file"===r[e]),i=Object.keys(r).filter(e=>"folder"===r[e]);for(const a of i){if(o.length>=n)break;const t=n-o.length,r=await ho(e,a,t);o.push(...r.slice(0,t))}return o}function yo(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}const bo=3e4;async function go(e,t){const{dispatch:n,io:r,onError:o}=e.props,i=uo(r,ro(t.keys)),a=co(r,t.id);P(a);const s=await lo(i);n({type:"STORAGE_WALLET_ADDED",payload:{id:t.id,initialState:{localDisklet:a,paths:i,status:s,lastChanges:[]}}});const c=wo(e,t.id);s.lastSync>0?c.catch(n=>{const{syncKey:r}=t.keys,{lastHash:i}=s;e.props.log.error(`Could not sync ${String(r)} with last hash ${String(i)}: ${String(n)}`),o(n)}):await c}function wo(e,t){const{dispatch:n,syncClient:o,state:i}=e.props,{paths:a,status:s}=i.storageWallets[t];return po(o,a,function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?yo(Object(n),!0).forEach(function(t){r(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):yo(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}({},s)).then(({changes:e,status:r})=>(n({type:"STORAGE_WALLET_SYNCED",payload:{id:t,changes:Object.keys(e),status:r}}),Object.keys(e)))}async function vo(e){try{return{ok:!0,result:await e}}catch(t){return{ok:!1,error:t}}}var mo=n(5817);function Io(e){for(let t=e.length-1;t>0;t--){const n=Math.floor(Math.random()*(t+1));[e[t],e[n]]=[e[n],e[t]]}return e}function Eo(e,t){return e.storageWallets[t].paths.disklet}function So(e,t){return e.storageWallets[t].localDisklet}function Oo(e,t,n){const r=e.storageWallets[t].paths.dataKey;return Lt.stringify(an(Bt.parse(n),r))}const Ao=we({multiplier:pe,name:pe,symbol:ue(pe)}),To=we({currencyCode:pe,denominations:ge(Ao),displayName:pe,networkLocation:ue(kr)}),_o=we({enabled:ue(de,!0)}).withRest,ko=we({SortIndex:ue(fe,0),Archived:ue(de,!1),BitcoinSeed:Te,MK:Te,SyncKey:Te}).withRest,xo=we({id:pe,archived:ue(de),deleted:ue(de),hidden:ue(de),migratedFromWalletId:ue(pe),sortIndex:ue(fe)}),Po=we({userSettings:ue(we(kr),()=>({})),swapSettings:ue(we(_o),()=>({}))}).withRest,Mo=we({customTokens:ge(we({contractAddress:pe,currencyCode:pe,currencyName:pe,denomination:pe,denominations:ge(Ao),isVisible:ue(de,!0),multiplier:pe,walletType:ue(pe,"wallet:ethereum")}))}),Co=we({customTokens:we(we(To))});function No(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function jo(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?No(Object(n),!0).forEach(function(t){r(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):No(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}const Do=_r(ko),Ro=_r(xo),Lo=_r(Po),Bo=Po({}),Ko="PluginSettings.json";function Uo(e,t){for(const n of Object.keys(t))if(e[n]!==t[n])return!0;return!1}async function Fo(e,t){const n=e.props.state.accounts[t],{accountWalletInfo:r,accountWalletInfos:o}=n,i=await Promise.all(o.map(t=>async function(e){const t=[],n={},r=(0,re.WR)(await e.list("Wallets"));return await Promise.all(r.map(async r=>{const o=await Do.load(e,r);if(null==o)return;const i=Qo("wallet:bitcoin",jo(jo({},oo({dataKey:o.MK,syncKey:o.SyncKey})),{},{bitcoinKey:w(o.BitcoinSeed),format:"bip32"}),o.MK);t.push(i),n[i.id]={archived:o.Archived,deleted:!1,hidden:!1,migratedFromWalletId:void 0,sortIndex:o.SortIndex}})),{walletInfos:t,walletStates:n}}(Eo(e.props.state,t.id)))),a=await async function(e){const t={},n=(0,re.WR)(await e.list("Keys"));return await Promise.all(n.map(async n=>{const r=await Ro.load(e,n);if(null==r)return;const{id:o,archived:i,deleted:a,hidden:s,migratedFromWalletId:c,sortIndex:u}=r;t[o]={archived:i,deleted:a,hidden:s,sortIndex:u,migratedFromWalletId:c}})),t}(Eo(e.props.state,r.id)),s=[];for(const l of i)s.push(...l.walletInfos);const c=i.map(e=>e.walletStates),u=Object.assign({},...c,a);e.props.dispatch({type:"ACCOUNT_KEYS_LOADED",payload:{accountId:t,legacyWalletInfos:s,walletStates:u}})}async function Wo(e,t,n){const{accountWalletInfo:r,walletStates:o}=e.props.state.accounts[t],i=Eo(e.props.state,r.id),a={};for(const c of Object.keys(n))null==o[c]?a[c]=n[c]:Uo(o[c],n[c])&&(a[c]=jo(jo({},o[c]),n[c]));const s=Object.keys(a);s.length<1||(await Promise.all(s.map(async t=>{const{archived:n,deleted:o,hidden:s,migratedFromWalletId:c,sortIndex:u}=a[t],l=Oo(e.props.state,r.id,t);await Ro.save(i,`Keys/${l}.json`,{archived:n,deleted:o,hidden:s,id:t,migratedFromWalletId:c,sortIndex:u})})),e.props.dispatch({type:"ACCOUNT_CHANGED_WALLET_STATES",payload:{accountId:t,walletStates:jo(jo({},o),a)}}))}async function Go(e,t,n,r){var o;const{accountWalletInfo:i}=e.props.state.accounts[t],a=Eo(e.props.state,i.id),s=null!==(o=await Lo.load(a,Ko))&&void 0!==o?o:Bo;await Lo.save(a,Ko,jo(jo({},s),{},{userSettings:jo(jo({},e.props.state.accounts[t].userSettings),{},{[n]:r})})),e.props.dispatch({type:"ACCOUNT_PLUGIN_SETTINGS_CHANGED",payload:{accountId:t,pluginId:n,userSettings:jo({},r)}})}async function zo(e,t){const{accountWalletInfo:n}=e.props.state.accounts[t],r=Eo(e.props.state,n.id),o=await Lo.load(r,Ko),{userSettings:i,swapSettings:a}=null!=o?o:{userSettings:{},swapSettings:{}};e.props.dispatch({type:"ACCOUNT_PLUGIN_SETTINGS_LOADED",payload:{accountId:t,userSettings:i,swapSettings:a}})}function qo(e,t,n){for(const r of e.denominations)if(r.name===n)return r.multiplier;for(const r of Object.keys(t)){const e=t[r];for(const t of e.denominations)if(t.name===n)return t.multiplier}return"1"}function $o(e,t){return e.waitFor(e=>{if(null==e.state.currency.wallets[t])throw new Error(`Wallet id ${t} does not exist in this account`);const{engineFailure:n}=e.state.currency.wallets[t];if(null!=n)throw n;if(null!=e.output.currency.wallets[t])return e.output.currency.wallets[t].walletApi})}const Ho=we({id:pe,keys:kr,type:pe}),Yo=Ee(Ho);function Vo(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Jo(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Vo(Object(n),!0).forEach(function(t){r(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Vo(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Xo(e,t){return e.find(e=>e.type===t)}function Zo(e){return""===e?"account-repo:co.airbitz.wallet":`account-repo:${e}`}function Qo(e,t,n){const r=an(Bt.parse(e),null!=n?n:ro(t).dataKey);return{id:w(r),type:e,keys:t}}function ei(e,t,n,r=!1){e.props.log.breadcrumb("makeKeysKit",{});const{io:o}=e.props,i=n.map(e=>Jo({created:new Date},fn(o,Bt.parse(JSON.stringify(Yo(e))),t.loginKey))),a=[];for(const s of n){const e=me(ro)(s.keys);null!=e&&a.push(h(e.syncKey).toLowerCase())}return{loginId:t.loginId,server:mt({allowExisting:r,keyBoxes:i,newSyncKeys:a}),serverPath:"/v2/login/keys",stash:{keyBoxes:i}}}function ti(e){const t=[],n=new Map;for(const r of e){const{id:e,keys:o,type:i}=r;if(null==e||32!==g(e).length)throw new Error(`Key integrity violation: invalid id ${e}`);const a=n.get(e);if(null!=a){const n=t[a];if(n.type!==i)throw new Error(`Key integrity violation for ${e}: type ${i} does not match ${n.type}`);for(const t of Object.keys(o))if(null!=n.keys[t]&&n.keys[t]!==o[t])throw new Error(`Key integrity violation for ${e}: ${t} keys do not match`);t[a]={id:e,keys:Jo(Jo({},n.keys),o),type:i}}else n.set(e,t.length),t.push(r)}return t}function ni(e,t,n=new Map){const{appId:r,keyBoxes:o=[]}=e,i=[],{mnemonicBox:a,rootKeyBox:s}=e;if(null!=a&&null!=s){const e=dn(s,t),n={mnemonic:ln(a,an(e,Bt.parse("infoKey"))),rootKey:w(e)};i.push(Qo("wallet:bitid",n,e))}if(null!=e.syncKeyBox){const n=dn(e.syncKeyBox,t),o=Zo(r),a=oo({dataKey:t,syncKey:n});i.push(Qo(o,a,t))}const c=o.map(e=>{const r=Ho(JSON.parse(ln(e,t))),o=(i=e.created,a=n.get(r.id),null==i?a:null==a?i:new Date(Math.min(i.valueOf(),a.valueOf())));var i,a;return null!=o&&n.set(r.id,o),r});return ti([...i,...c]).map(e=>ri(e))}function ri(e){const{id:t,keys:n,type:r}=e,o={"wallet:bitcoin-bip44":{format:"bip44",coinType:0},"wallet:bitcoin-bip49":{format:"bip49",coinType:0},"wallet:bitcoincash-bip32":{format:"bip32"},"wallet:bitcoincash-bip44":{format:"bip44",coinType:145},"wallet:bitcoincash-bip44-testnet":{format:"bip44",coinType:1},"wallet:bitcoin-bip44-testnet":{format:"bip44",coinType:1},"wallet:bitcoin-bip49-testnet":{format:"bip49",coinType:1},"wallet:dash-bip44":{format:"bip44",coinType:5},"wallet:dogecoin-bip44":{format:"bip44",coinType:3},"wallet:litecoin-bip44":{format:"bip44",coinType:2},"wallet:litecoin-bip49":{format:"bip49",coinType:2},"wallet:feathercoin-bip49":{format:"bip49",coinType:8},"wallet:feathercoin-bip44":{format:"bip44",coinType:8},"wallet:qtum-bip44":{format:"bip44",coinType:2301},"wallet:ufo-bip49":{format:"bip49",coinType:202},"wallet:ufo-bip84":{format:"bip84",coinType:202},"wallet:zcoin-bip44":{format:"bip44",coinType:136},"wallet:bitcoin-testnet":{format:"bip32"},"wallet:bitcoin":{format:"bip32"},"wallet:bitcoincash-testnet":{format:"bip32"},"wallet:litecoin":{format:"bip32",coinType:2},"wallet:zcoin":{format:"bip32",coinType:136}};return null!=o[r]?{id:t,keys:Jo(Jo({},o[r]),n),type:r.replace(/-bip[0-9]+/,"")}:e}async function oi(e,t,n){const{importText:r,keyOptions:o,keys:i}=n;function a(n,r){return null!=r&&(n=Jo(Jo({},n),{},{imported:r})),ri(Qo(t,Jo(Jo({},oo(io(e))),n)))}if(null!=i)return a(i);const s=eo(e.props.state.plugins.currency,t),c=await no(e,s);if(null!=r){if(null==c.importPrivateKey)throw new Error("This wallet does not support importing keys");return a(await c.importPrivateKey(r,o),!0)}return a(await c.createPrivateKey(t,o),!1)}async function ii(e,t,n,r){const{enabledTokenIds:o,fiatCurrencyCode:i,migratedFromWalletId:a,name:s}=r,c=await $o(e,n);return null!=a&&await Wo(e,t,{[n]:{migratedFromWalletId:a}}),null!=s&&await c.renameWallet(s),null!=i&&await c.setFiatCurrencyCode(i),null!=o&&o.length>0&&await c.changeEnabledTokenIds(o),c}const ai=Tn;function si(e,t){return e+t}async function ci(e,t,n,r){return await async function(e,t,n,r){const{now:o=new Date}=r,{passwordBox:i,passwordKeySnrp:a,username:s}=t;if(null==i||null==a||null==s)throw new Error("Missing data for offline password login");const c=si(s,n),u=await An(e,c,a),l={loginId:t.loginId,loginKey:dn(i,u)};t.lastLogin=o,jn(e,t).catch(()=>{});const{log:d}=e.props;return er(e,l).catch(e=>d.error(e)),l}(e,t,n,r).catch(()=>async function(e,t,n,r){const{username:o}=t;if(null==o)throw new Error("Password login requires a username");const i=si(o,n),[a,s]=await Promise.all([Cn(e,o),An(e,i,ai)]),c={userId:a,passwordAuth:s};return await Xn(e,t,t,r,c,async t=>{const{passwordBox:n,passwordKeySnrp:r}=t;if(null==n||!0===n||null==r)throw new Error("Missing data for online password login");return dn(n,await An(e,i,r))})}(e,t,n,r))}async function ui(e,t,n,r){const o=si(n,r),{io:i}=e.props,[{passwordKeySnrp:a,passwordBox:s},{passwordAuth:c,passwordAuthBox:u}]=await Promise.all([On(e).then(async n=>{const r=await An(e,o,n);return{passwordKeySnrp:n,passwordBox:fn(i,t.loginKey,r)}}),An(e,o,ai).then(e=>({passwordAuth:e,passwordAuthBox:fn(i,e,t.loginKey)}))]);return{loginId:t.loginId,server:ft({passwordAuth:c,passwordAuthSnrp:ai,passwordKeySnrp:a,passwordBox:s,passwordAuthBox:u}),serverPath:"/v2/login/password",stash:{passwordKeySnrp:a,passwordBox:s,passwordAuthBox:u}}}function li(e,t){return an(null==t?Uint8Array.from([0]):Bt.parse(t),e)}function di(e,t){return an(Bt.parse(t),e)}function fi(e,t){if(null!=e.pin2Key)return e;const n=zn(e,e=>e.appId===t);return null!=(null==n?void 0:n.pin2Key)?n:void 0}async function pi(e,t,n,r,o){if(null==n.pin2Key)throw new zt("PIN login is not enabled for this account on this device");const{pin2Key:i}=n,a={pin2Id:li(i,t.username),pin2Auth:di(i,r)};return await Xn(e,t,n,o,a,async e=>{if(null==e.pin2Box||!0===e.pin2Box)throw new Error("Missing data for PIN v2 login");return dn(e.pin2Box,i)})}async function hi(e,t,n){const r=e.props.state.accounts[t],o=r.activeAppId.endsWith(".duress"),{loginTree:i,login:a,sessionKey:s}=r,{username:c}=r.stashTree;let{pin:u,enableLogin:l,forDuressAccount:d=!1}=n;if(null==l&&(l=null!=i.pin2Key||null!=u&&null==i.pin),null==u&&(u=a.pin),o&&!d)return await Qn(e,s,bi(e,i,c,l,!0)),void(null!=u&&await Qn(e,s,yi(e,i,c,u,!0,!0)));if(null==u){if(l)throw new Error("Please change your PIN in the settings area above before enabling.");return void(await Qn(e,s,wi(i,d||o)))}const f=yi(e,i,c,u,l,d||o);await Qn(e,s,f)}function yi(e,t,n,r,o,i){const a=[];i===t.appId.endsWith(".duress")&&a.push(gi(e,t,n,r,o));for(const s of t.children)a.push(...yi(e,s,n,r,o,i));return a}function bi(e,t,n,r,o){const i=[];o===t.appId.endsWith(".duress")&&i.push(function(e,t){const{loginId:n}=e;return{loginId:n,server:void 0,serverPath:"",stash:{fakePinDisabled:!t}}}(t,r));for(const a of t.children)i.push(...bi(e,a,n,r,o));return i}function gi(e,t,n,r,o){const{io:i}=e.props,a=fn(i,Bt.parse(r),t.loginKey);if(o){const{loginId:e,loginKey:o,pin2Key:s=i.random(32)}=t,c=fn(i,o,s),u=fn(i,s,o);return{loginId:e,server:ht({pin2Id:li(s,n),pin2Auth:di(s,r),pin2Box:c,pin2KeyBox:u,pin2TextBox:a}),serverPath:"/v2/login/pin2",stash:{pin2Key:s,pin2TextBox:a}}}return{loginId:t.loginId,server:ht({pin2Id:void 0,pin2Auth:void 0,pin2Box:void 0,pin2KeyBox:void 0,pin2TextBox:a}),serverPath:"/v2/login/pin2",stash:{pin2Key:void 0,pin2TextBox:a}}}function wi(e,t){const n=[];null!=t&&t!==e.appId.endsWith(".duress")||n.push(function(e){return{loginId:e.loginId,server:void 0,serverMethod:"DELETE",serverPath:"/v2/login/pin2",stash:{pin2Key:void 0}}}(e));for(const r of e.children)n.push(...wi(r,t));return n}function vi(e,t){return an(Bt.parse(t),e)}function mi(e,t){return t.map(t=>an(Bt.parse(t),e))}async function Ii(e,t,n,r){const o=e.props.state.accounts[t],{loginTree:i,sessionKey:a}=o,{username:s}=o.stashTree;if(null==s)throw new Error("Recovery login requires a username");const c=function(e,t,n,r,o){const{io:i}=e.props;if(!Array.isArray(r))throw new TypeError("Questions must be an array of strings");if(!Array.isArray(o))throw new TypeError("Answers must be an array of strings");const{loginId:a,loginKey:s,recovery2Key:c=i.random(32)}=t,u=fn(i,Bt.parse(JSON.stringify(Si(r))),c),l=fn(i,s,c),d=fn(i,c,s);return{loginId:a,server:bt({recovery2Id:vi(c,n),recovery2Auth:mi(c,o),recovery2Box:l,recovery2KeyBox:d,question2Box:u}),serverPath:"/v2/login/recovery2",stash:{recovery2Key:c}}}(e,i,s,n,r);await Zn(e,a,c)}const Ei=ge(pe),Si=Ee(Ei);function Oi(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Ai(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Oi(Object(n),!0).forEach(function(t){r(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Oi(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}async function Ti(e,t,n){var r,o,i,a;const{password:s,username:c}=n,{isRoot:u,loginId:l,passwordAuth:d}=t;if(null!=d&&null==s)throw new Error("A password is required to change the username");const f=function(e,t){const{loginId:n,pin2Key:r}=e;if(null!=r)return{loginId:n,server:pt({pin2Id:li(r,t)}),serverPath:"",stash:{}}}(t,c),p=function(e,t){const{loginId:n,recovery2Key:r}=e;if(null!=r)return{loginId:n,server:yt({recovery2Id:vi(r,t)}),serverPath:"",stash:{}}}(t,c);let h,y;if(null!=s&&(h=await ui(e,t,c,s)),u&&(y=await _i(e,t,c)),null!=h||null!=f||null!=p||null!=y)return{loginId:l,server:Ai(Ai(Ai(Ai({},null===(r=h)||void 0===r?void 0:r.server),null==f?void 0:f.server),null==p?void 0:p.server),null===(o=y)||void 0===o?void 0:o.server),serverPath:"/v2/login/username",stash:Ai(Ai(Ai(Ai({},null===(i=h)||void 0===i?void 0:i.stash),null==f?void 0:f.stash),null==p?void 0:p.stash),null===(a=y)||void 0===a?void 0:a.stash)}}async function _i(e,t,n){const{io:r}=e.props,{loginId:o,loginKey:i}=t,a=await Cn(e,n);return{loginId:o,server:wt({userId:a,userTextBox:fn(r,Bt.parse(n),i)}),serverPath:"",stash:{userId:a,username:n}}}function ki(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function xi(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?ki(Object(n),!0).forEach(function(t){r(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ki(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}async function Pi(e,t,n,r){var o,i,a,s,c,u,l,d;const{keyInfo:f,password:p,pin:h,username:y}=r,{io:b}=e.props;e.props.log.breadcrumb("makeCreateKit",{});const g=null==t,w=b.random(32),v=b.random(32),m={loginId:w,loginKey:v},I={appId:n,lastLogin:new Date,loginId:w,loginKey:v,isRoot:g,pendingVouchers:[],children:[]},E=Sn(e,I);let S,O,A,T,_;null!=f&&(S=ei(e,m,[f])),null!=t&&(O=fn(b,v,t.loginKey)),null!=p&&null!=y&&(A=await ui(e,I,y,p)),null!=h&&(T=gi(e,I,y,h,!0)),g&&null!=y&&(_=await _i(e,I,y));return{kit:{loginId:w,server:xi(xi(xi(xi(xi(xi({},It({appId:n,loginId:w,parentBox:O})),null===(o=S)||void 0===o?void 0:o.server),null===(i=A)||void 0===i?void 0:i.server),null===(a=T)||void 0===a?void 0:a.server),E.server),null===(s=_)||void 0===s?void 0:s.server),serverPath:"/v2/login/create",stash:xi(xi(xi(xi(xi({appId:n,loginId:w,parentBox:O},null===(c=S)||void 0===c?void 0:c.stash),null===(u=A)||void 0===u?void 0:u.stash),null===(l=T)||void 0===l?void 0:l.stash),E.stash),null===(d=_)||void 0===d?void 0:d.stash)},sessionKey:m}}async function Mi(e,t,n,r){const{log:o}=e.props,i=zn(t,e=>e.appId===r);if(null==i)return e.props.log.breadcrumb("createChildLogin",{}),await async function(e,t,n,r){let o;null!=t.pin2TextBox&&(o=ln(t.pin2TextBox,n.loginKey));const{kit:i}=await Pi(e,n,r,{keyInfo:Qo(Zo(r),oo(io(e))),pin:o,username:t.username}),a={loginId:n.loginId,server:i.server,serverPath:i.serverPath,stash:{children:[i.stash]}};return await Zn(e,n,a)}(e,t,n,r);const a=tr(t,n,i.loginId),s=ni(i,a.loginKey);o.warn(`Login: decrypted keys for user ${w(t.loginId)}`);const c=Zo(r);if(null==Xo(s,c)){e.props.log.breadcrumb("createAccountRepo",{});const t=ei(e,a,[Qo(c,oo(io(e)))]);return await Zn(e,n,t)}return t}async function Ci(e,t,n,r){const{pauseWallets:o=!1}=r,i=!0===r.duressMode?e.props.state.login.contextAppId+".duress":e.props.state.login.contextAppId,{log:a}=e.props;e.props.log.breadcrumb("makeAccount",{});const{stashTree:s}=xn(e,t.loginId);return await Mi(e,s,t,i),a.warn("Login: account exists for appId"),e.props.dispatch({type:"LOGIN",payload:{appId:i,loginType:n,pauseWallets:o,rootLoginId:s.loginId,sessionKey:t}}),await function(e,t){const n=e.waitFor(e=>{const n=e.state.accounts[t];if(null!=n.loadFailure)throw n.loadFailure;const r=e.output.accounts[t];if(null!=(null==r?void 0:r.accountApi))return r.accountApi});return n}(e,e.props.state.lastAccountId)}var Ni=n(6729);function ji(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Di(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?ji(Object(n),!0).forEach(function(t){r(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ji(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}const Ri=new(0,n.n(Ni)().ec)("secp256k1");function Li(e,t){const n=e.derive(Ri.keyFromPublic(t).getPublic()).toArray("be");return an(Uint8Array.from([0,0,0,1,...n]),Bt.parse("dataKey"))}function Bi(e,t){const{publicKey:n}=t,r=Li(e,n);return JSON.parse(ln(t.box,r))}function Ki(e,t,n){const r=Ri.genKeyPair({entropy:e.random(32)}),o=Li(r,t);return{publicKey:Uint8Array.from(r.getPublic().encodeCompressed()),box:fn(e,Bt.parse(JSON.stringify(n)),o)}}async function Ui(e,t,n=1e3){const{io:r}=e.props,{timeout:o=600}=t,i=Ri.genKeyPair({entropy:r.random(32)}),a=Uint8Array.from(i.getPublic().encodeCompressed()),s=Lt.stringify(sn(sn(a)).slice(0,10)),c={data:ct(Di(Di({},t),{},{publicKey:a,timeout:o}))};await In(e,"PUT",`/v2/lobby/${s}`,c);const[u,l]=(d={},[function(e,t){var n=d[e];return null==n&&(n=d[e]=function(){var e=[],t=!1;function n(){t&&(t=!1,e=e.slice())}return[function(t){n(),e.push(t);var r=!0;return function(){r&&(r=!1,n(),e.splice(e.indexOf(t),1))}},function(n){t=!0;for(var r=e,o=0;o<r.length;++o)r[o](n);t=!1}]}()),n[0](t)},function(e,t){var n=d[e];null!=n&&n[1](t)}]);var d;const f=[],p=Zr(async()=>{const t=Xe(await In(e,"GET","/v2/lobby/"+s));for(;f.length<t.replies.length;){const e=t.replies[f.length],n=Bi(i,e);l("reply",n),f.push(n)}},n,{onError(e){l("error",e)}});return p.start({wait:!1}),{close:()=>p.stop(),lobbyId:s,on:u,replies:f}}async function Fi(e,t){const n=Xe(await In(e,"GET","/v2/lobby/"+t)),{publicKey:r}=n.request,o=sn(sn(r)),i=Lt.parse(t);if(!cn(i,o.subarray(0,i.length)))throw new Error("Lobby ECDH integrity error");return n.request}async function Wi(e,t,n,r){const{io:o}=e.props,{publicKey:i}=n,a={data:st(Ki(o,i,r))};await In(e,"POST","/v2/lobby/"+t,a)}const Gi=we({appId:pe,loginKey:ke,loginStash:Dn});async function zi(e,t,n={}){function r(e){for(const t of a)t();s.state="error",s.error=e,G(s),F(s)}async function o(r){for(const e of a)e();const o=Gi(r),{username:i}=o.loginStash;s.state="started",s.username=i,G(s);const c=await async function(e,t,n,r){const{now:o=new Date}=r,{loginKey:i,loginStash:a}=t;e.props.log.breadcrumb("unpackAccount",{});const s=zn(a,e=>e.appId===n);if(null==s)throw new Error(`Cannot find requested appId: "${n}"`);try{const t=xn(e,s.loginId);s.voucherId=t.stash.voucherId,s.voucherAuth=t.stash.voucherAuth}catch(u){}a.lastLogin=o,await jn(e,a);const c={loginId:s.loginId,loginKey:i};return await er(e,c),await Ci(e,c,"edgeLogin",r)}(e,o,t,n);s.state="done",s.account=c,G(s),F(s)}const i=await Ui(e,{loginRequest:{appId:t}}),a=[i.close,i.on("error",function(e){s.error=e,G(s)}),i.on("reply",e=>{o(e).catch(r)})],s={id:i.lobbyId,cancelRequest:async function(){for(const e of a)e();s.state="closed",G(s),F(s)},watch:ee,state:"pending",account:void 0,error:void 0,username:void 0};return P(s)}const qi=Ee(Gi),$i=we({appName:pe,darkImageUrl:ue(pe),lightImageUrl:ue(pe),imageUrl:ue(pe)});async function Hi(e,t){try{const[n]=Io(e.props.state.infoServers),r=`${n}/v1/appIdInfo/${t}`,o=await e.props.io.fetch(r,{corsBypass:"never"});if(404===o.status)return{appName:t};if(!o.ok)throw new Error(`Fetching ${r} returned ${o.status}`);const i=$i(await o.json());return null==i.lightImageUrl&&(i.lightImageUrl=i.imageUrl),null==i.darkImageUrl&&(i.darkImageUrl=i.imageUrl),i}catch(n){return e.props.onError(n),{appName:t}}}async function Yi(e,t,n){const r=await Fi(e,n);let o;null!=r.loginRequest&&(o=await async function(e,t,n,r,o){e.props.log.breadcrumb("unpackLoginRequest",{});const i=await Hi(e,o),a={appId:o,displayName:i.appName,displayImageDarkUrl:i.darkImageUrl,displayImageLightUrl:i.lightImageUrl,approve(){return async function(e,t,n,r,o){const{sessionKey:i}=e.props.state.accounts[t];e.props.log.breadcrumb("approveLoginRequest",{}),await er(e,i);const{stashTree:a}=xn(e,i.loginId),s=await Mi(e,a,i,n),c=zn(s,e=>e.appId===n);if(null==c)throw new Error("Failed to create the requested login object");const u=tr(s,i,c.loginId),l=qi({appId:n,loginKey:u.loginKey,loginStash:Jn(s,n)});let d;await Wi(e,r,o,l);const f=e.props.output.accounts[t].accountApi;null!=f&&f.on("close",()=>{null!=d&&clearTimeout(d)}),d=setTimeout(()=>{d=void 0,er(e,i).then(()=>{d=setTimeout(()=>{d=void 0,er(e,i).catch(t=>e.props.onError(t))},2e4)}).catch(t=>e.props.onError(t))},1e4)}(e,t,o,n,r)},async close(){F(a)}};return P(a),a}(e,t,n,r,r.loginRequest.appId));const i={loginRequest:o};return P(i),i}var Vi=n(6001);function Ji(e){var t;const{currencyInfo:n,allTokens:r}=e;let o=e.tokenId;void 0===o&&null!=e.currencyCode&&e.currencyCode!==n.currencyCode&&(o=Object.keys(r).find(t=>r[t].currencyCode===e.currencyCode));const{currencyCode:i}=null==o?n:r[o];return{currencyCode:i,tokenId:null!==(t=o)&&void 0!==t?t:null}}function Xi(e){return null!=e.networkFee&&void 0===e.networkFee.tokenId&&(e.networkFee.tokenId=null),e}const Zi=e=>{null!=e.networkFees&&0!==e.networkFees.length||(e.networkFees=[{tokenId:e.tokenId,nativeAmount:e.networkFee}],null!=e.parentNetworkFee&&e.networkFees.push({tokenId:null,nativeAmount:e.parentNetworkFee}))};function Qi(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function ea(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Qi(Object(n),!0).forEach(function(t){r(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Qi(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}const ta=_r(Co),na=_r(Mo),ra="CustomTokens.json",oa=me(we({contractAddress:pe}));async function ia(e,t,n){const r=await no(e,t);if(null!=r.getTokenId)return await r.getTokenId(n);const o=function(e,t){for(const n of Object.keys(e.props.state.currency.wallets)){const r=e.props.output.currency.wallets[n];if(null!=(null==r?void 0:r.engine)&&e.props.state.currency.wallets[n].pluginId===t)return r.engine}}(e,t);if(null==o)throw new Error("A wallet must exist before adding tokens to a legacy currency plugin");if(null==o.addCustomToken)throw new Error(`${t} doesn't support tokens`);const i=ua(n);if(null==i)throw new Error("A token must have a contract address to be added to a legacy currency plugin");return await o.addCustomToken(ea(ea({},i),n)),aa(i.contractAddress)}function aa(e){return e.toLowerCase().replace(/^0x/,"")}function sa(e){const{currencyCode:t,displayName:n,denominations:r,networkLocation:o}=e,i=oa(o);return{currencyCode:t,currencyName:n,denominations:r,contractAddress:null==i?void 0:i.contractAddress}}function ca(e={}){const t=[];for(const n of Object.keys(e))t.push(sa(e[n]));return t}function ua(e){const{currencyCode:t,displayName:n,denominations:r,networkLocation:o}=e,i=oa(o);if(null!=i)return{currencyCode:t,currencyName:n,multiplier:r[0].multiplier,contractAddress:i.contractAddress}}async function la(e,t){const{dispatch:n,state:r}=e.props;await Promise.all(Object.keys(r.plugins.currency).map(async e=>{var o;const i=r.plugins.currency[e],a=null==i.getBuiltinTokens?function(e){const t={};for(const n of e){const{contractAddress:e}=n;null!=e&&(t[aa(e)]={currencyCode:n.currencyCode,denominations:n.denominations,displayName:n.currencyName,networkLocation:{contractAddress:n.contractAddress}})}return t}(null!==(o=i.currencyInfo.metaTokens)&&void 0!==o?o:[]):await i.getBuiltinTokens();n({type:"ACCOUNT_BUILTIN_TOKENS_LOADED",payload:{accountId:t,pluginId:e,tokens:a}})}))}async function da(e,t){const{dispatch:n,state:r}=e.props,{accountWalletInfo:o}=r.accounts[t],i=Eo(r,o.id),a=await ta.load(i,ra);if(null!=a){const{customTokens:e}=a;n({type:"ACCOUNT_CUSTOM_TOKENS_LOADED",payload:{accountId:t,customTokens:e}})}else{const r=await async function(e,t){const{state:n}=e.props,{accountWalletInfo:r}=n.accounts[t],o=Eo(n,r.id),i=await na.load(o,"Settings.json");if(null==i)return{};const a={};for(const s of i.customTokens){if(!s.isVisible)continue;const e=to(n.plugins.currency,s.walletType);if(null==e)continue;null==a[e]&&(a[e]={});const t=aa(s.contractAddress);a[e][t]={currencyCode:s.currencyCode,denominations:s.denominations,displayName:s.currencyName,networkLocation:{contractAddress:s.contractAddress}}}return a}(e,t);n({type:"ACCOUNT_CUSTOM_TOKENS_LOADED",payload:{accountId:t,customTokens:r}})}}function fa(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function pa(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?fa(Object(n),!0).forEach(function(t){r(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):fa(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function ha(e,t){const{id:n,type:r,keys:o}=e,i=me(ro)(o);if(null==i)throw new Error(`Wallet ${n} is not a splittable type`);const{dataKey:a,syncKey:s}=i,c=ba(an(Bt.parse(r),a),an(Bt.parse(t),a)),u=ba(g(n),c),l=ba(s,c.subarray(0,s.length)),d=r.replace(/wallet:/,"").replace("-",""),f=t.replace(/wallet:/,"").replace("-",""),p=oo({dataKey:a,syncKey:l});for(const h of Object.keys(o)){const e=h===d+"Key"?f+"Key":h;null==p[e]&&(p[e]=o[h])}return{id:w(u),keys:p,type:t}}async function ya(e,t,n,r,o){const i=e.props.state.accounts[t],{allWalletInfosFull:a,sessionKey:s}=i,c=e.props.state.plugins.currency,u=new Map;for(const h of r){const{walletType:e}=h;if(null==to(c,h.walletType))throw new Error(`Cannot find plugin for wallet type "${e}"`);if(u.has(e))throw new Error(`Duplicate wallet type "${e}"`);u.set(e,ha(n,e))}if("wallet:bitcoincash"===n.type&&u.has("wallet:bitcoinsv")){var l;const t=null===(l=e.props.output)||void 0===l||null===(l=l.currency)||void 0===l||null===(l=l.wallets[n.id])||void 0===l?void 0:l.walletApi;if(null==t)throw new Error(`Cannot find wallet ${n.id}`);await async function(e){const t={currencyCode:"BCH",tokenId:null},n=pa(pa({},t),{},{spendTargets:[{nativeAmount:"10000",otherParams:{script:{type:"replayProtection"}},publicAddress:""}],metadata:{},networkFeeOption:"high"}),r=await e.makeSpend(n),o=await e.signTx(r),i=await e.broadcastTx(o);await e.saveTx(i);const{publicAddress:a}=await e.getReceiveAddress(t),s=pa(pa({},t),{},{metadata:{name:"Replay Protection Tx",notes:"This transaction is to protect your BCH wallet from unintentionally spending BSV funds. Please wait for the transaction to confirm before making additional transactions using this BCH wallet."},networkFeeOption:"high",spendTargets:[{publicAddress:a,nativeAmount:"0"}]}),c=await e.getMaxSpendable(s);s.spendTargets[0].nativeAmount=c;const u=await e.makeSpend(s),l=await e.signTx(u),d=await e.broadcastTx(l);await e.saveTx(d)}(t)}const d=[],f=[];for(const h of u.values()){const e=a.find(e=>e.id===h.id);if(null==e)f.push(h);else if(e.archived||e.deleted)d.push(e);else if(o&&("wallet:bitcoincash"!==n.type||"wallet:bitcoinsv"!==h.type))throw new Error(`This wallet has already been split (${h.type})`)}if(d.length>0){const n={};for(const e of d)n[e.id]={archived:!1,deleted:!1,migratedFromWalletId:e.migratedFromWalletId};await Wo(e,t,n)}if(f.length>0){const t=ei(e,s,f,!0);await Zn(e,s,t)}const p=await Promise.all(r.map(async t=>{const n=u.get(t.walletType);if(null==n)throw new Error(`Missing wallet info for ${t.walletType}`);return await vo(async function(e,t,n){const r=await $o(e,t);null!=(null==n?void 0:n.name)&&await r.renameWallet(n.name).catch(t=>e.props.onError(t));null!=(null==n?void 0:n.fiatCurrencyCode)&&await r.setFiatCurrencyCode(n.fiatCurrencyCode).catch(t=>e.props.onError(t));return r}(e,n.id,null!=f.find(e=>e.type===t.walletType)?t:void 0))}));return p}function ba(e,t){if(e.length!==t.length)throw new Error(`Array lengths do not match: ${e.length}, ${t.length}`);const n=new Uint8Array(e.length);for(let r=0;r<e.length;++r)n[r]=e[r]^t[r];return n}function ga(e,t){const{id:n,type:r,keys:o}=t;return{id:n,type:r,keys:o,get disklet(){return Eo(e.props.state,n)},get localDisklet(){return So(e.props.state,n)},async sync(){await wo(e,n)}}}const wa={"[object Float32Array]":!0,"[object Float64Array]":!0,"[object Int16Array]":!0,"[object Int32Array]":!0,"[object Int8Array]":!0,"[object Uint16Array]":!0,"[object Uint32Array]":!0,"[object Uint8Array]":!0,"[object Uint8ClampedArray]":!0};function va(e,t){if(e===t)return!0;if("object"!=typeof e)return!1;if("object"!=typeof t)return!1;const n=Object.prototype.toString.call(e);return n===Object.prototype.toString.call(t)&&function(e,t,n){if("[object Object]"===n){if(Object.getPrototypeOf(e)!==Object.getPrototypeOf(t))return!1;const n=Object.getOwnPropertyNames(e);if(n.length!==Object.getOwnPropertyNames(t).length)return!1;for(const r of n)if(!Object.prototype.hasOwnProperty.call(t,r)||!va(e[r],t[r]))return!1;return!0}if("[object Array]"===n){if(e.length!==t.length)return!1;for(let n=0;n<e.length;++n)if(!va(e[n],t[n]))return!1;return!0}if("[object Date]"===n)return e.getTime()===t.getTime();if("[object Map]"===n)return function(e,t){if(e.size!==t.size)return!1;for(const[n,r]of e)if(!t.has(n)||t.get(n)!==r)return!1;return!0}(e,t);if(wa[n]){if(e.length!==t.length)return!1;for(let n=0;n<e.length;++n)if(e[n]!==t[n])return!1;return!0}return!1}(e,t,n)}let ma=500,Ia=3;const Ea=[];let Sa;function Oa(e){Ea.length<=0&&Aa();let t=!1;for(const n of Ea)if(n.id===e.id&&n.action===e.action){n.updateFunc=e.updateFunc,t=!0;break}t||Ea.push(e)}function Aa(){Sa=setTimeout(()=>{const e=Math.min(Ia,Ea.length);for(let t=0;t<e;t++){const e=Ea.shift();null!=e&&e.updateFunc()}Ea.length>0&&Aa()},ma)}function Ta(e,t){var n,r,o,i,a,s;const c={exchangeAmount:{}},{exchangeAmount:u={}}=c,l=null!==(n=e.exchangeAmount)&&void 0!==n?n:{},d=null!==(r=t.exchangeAmount)&&void 0!==r?r:{};for(const f of Object.keys(l))null!==d[f]&&(u[f]=l[f]);for(const f of Object.keys(d)){const e=d[f];null!=e&&(u[f]=e)}return null!==t.bizId&&(c.bizId=null!==(o=t.bizId)&&void 0!==o?o:e.bizId),null!==t.category&&(c.category=null!==(i=t.category)&&void 0!==i?i:e.category),null!==t.name&&(c.name=null!==(a=t.name)&&void 0!==a?a:e.name),null!==t.notes&&(c.notes=null!==(s=t.notes)&&void 0!==s?s:e.notes),c}const _a=we({bizId:ue(fe),category:ue(pe),exchangeAmount:ue(we(fe)),name:ue(pe),notes:ue(pe)}),ka=ve(pe,he),xa=le("high","standard","low"),Pa=we({orderId:ue(pe),orderUri:ue(pe),isEstimate:de,plugin:we({pluginId:pe,displayName:pe,supportEmail:ue(pe)}),payoutAddress:pe,payoutCurrencyCode:pe,payoutTokenId:ue(ka),payoutNativeAmount:pe,payoutWalletId:pe,refundAddress:ue(pe)});function Ma(e){const t=pe(e);if(!/^\d+$/.test(t))throw new Error("Expected an integer string");return t}const Ca=we({pluginId:pe,tokenId:ka,nativeAmount:ue(Ma)}),Na=we({fiatCurrencyCode:pe,fiatAmount:pe}),ja=we({pluginId:pe,displayName:pe,isDex:ue(de),orderUri:ue(pe),supportEmail:pe}),Da=ve(we({actionType:le("swap"),swapInfo:ja,orderId:ue(pe),orderUri:ue(pe),isEstimate:ue(de),canBePartial:ue(de),fromAsset:Ca,toAsset:Ca,payoutWalletId:pe,payoutAddress:pe,refundAddress:ue(pe)}),we({actionType:le("stake"),pluginId:pe,stakeAssets:ge(Ca)}),we({actionType:le("fiat"),orderId:pe,orderUri:ue(pe),isEstimate:de,fiatPlugin:we({providerId:pe,providerDisplayName:pe,supportEmail:ue(pe)}),payinAddress:ue(pe),payoutAddress:ue(pe),fiatAsset:Na,cryptoAsset:Ca}),we({actionType:le("tokenApproval"),tokenApproved:Ca,tokenContractAddress:pe,contractAddress:pe}),we({actionType:le("giftCard"),orderId:pe,orderUri:ue(pe),productId:ue(pe),quoteId:ue(pe),provider:we({providerId:pe,displayName:pe,supportEmail:ue(pe)}),card:we({name:pe,imageUrl:ue(pe),fiatAmount:pe,fiatCurrencyCode:pe}),redemption:ue(we({code:ue(pe),url:ue(pe)}))})),Ra=we({assetActionType:le("claim","claimOrder","stake","stakeNetworkFee","stakeOrder","unstake","unstakeNetworkFee","unstakeOrder","swap","swapNetworkFee","swapOrderPost","swapOrderFill","swapOrderCancel","buy","sell","sellNetworkFee","tokenApproval","transfer","transferNetworkFee","giftCard")}),La=ge(pe),Ba=we({enabledTokenIds:ge(pe),detectedTokenIds:ge(pe)}),Ka=we({walletSettings:ue(kr,()=>({}))}),Ua=we({assetAction:ue(Ra),metadata:e=>{const t=_a(e),{exchangeAmount:n={}}=t;for(const r of Object.keys(n))String(n[r]).includes("e")&&delete n[r];return t},nativeAmount:ue(pe),providerFeeSent:ue(pe)}),Fa=we({txid:pe,internal:de,creationDate:fe,currencies:function(e){const t=we(e);return Ie(e=>{const n=t(e),r=new Map;for(const t of Object.keys(n))r.set(t,n[t]);return r},e=>{const n={};return e.forEach((e,t)=>{n[t]=e}),t(n)})}(Ua),tokens:ue(function(e){const t=we(e);return Ie(e=>{const n=t(e),r=new Map;for(const t of Object.keys(n))r.set(""===t?null:t,n[t]);return r},e=>{const n={};return e.forEach((e,t)=>{n[null==t?"":t]=e}),t(n)})}(Ua),()=>new Map),deviceDescription:ue(pe),feeRateRequested:ue(ve(xa,kr)),feeRateUsed:ue(kr),payees:ue(ge(we({address:pe,amount:pe,currency:pe,tag:ue(pe)}))),savedAction:ue(Da),secret:ue(pe),swap:ue(Pa)}),Wa=we({airbitzFeeWanted:fe,meta:we({amountFeeAirBitzSatoshi:fe,balance:fe,fee:fe,amountCurrency:fe,bizId:fe,category:pe,name:pe,notes:pe,attributes:fe,amountSatoshi:fe,amountFeeMinersSatoshi:fe,airbitzFee:fe}),ntxid:pe,state:we({creationDate:fe,internal:de,malleableTxId:pe})}),Ga=we({seq:fe,address:pe,state:we({recycleable:ue(de,!0),creationDate:ue(fe,0)}),meta:we({amountSatoshi:ue(fe,0)}).withRest}),za=we(we({timestamp:fe,txidHash:pe})),qa=we({walletInfo:we({id:pe,keys:kr,type:pe})}),$a=we({checkpoint:ue(pe),subscribedAddresses:ue(ge(we({address:pe,checkpoint:ue(pe)})),()=>[])}),Ha=we({fiat:ue(pe),num:ue(fe)}),Ya=we({walletName:ve(pe,he)});var Va="redux-keto wrapper";function Ja(e,t,n){for(var r=Object.create(null),o=function(){var e=a[i],o=t(e);Object.defineProperty(r,e,{configurable:!0,enumerable:!0,get:function(){var t=this,r=t[Va];if(r.running[e]){var i=new ReferenceError("Reducer '"+e+"' depends on its own result");throw i.name="ReduxKetoCircularReferenceError",i}r.running[e]=!0;try{var a=o(r.state[e],r.action,n(r.next,t,e),n(r.prev,r.state,e));if(void 0===a)throw new TypeError("Reducer '"+e+"' returned undefined");return Object.defineProperty(t,e,{configurable:!0,enumerable:!0,writable:!1,value:a}),a}finally{r.running[e]=!1}}})},i=0,a=e;i<a.length;i+=1)o();return r}function Xa(e,t,n,r,o){var i=Object.create(e);return Object.defineProperty(i,Va,{configurable:!0,enumerable:!1,writable:!1,value:{state:t,action:n,next:r,prev:o,running:{}}}),i}function Za(e,t){if(void 0===e&&(e={}),null===t||null==t[Va])return t;for(var n=Object.keys(Object.getPrototypeOf(t)),r=Object.keys(e).length===n.length,o=0,i=n;o<i.length;o+=1){var a=i[o];Object.defineProperty(t,a,{configurable:!1,enumerable:!0,writable:!1,value:Za(e[a],t[a])}),t[a]!==e[a]&&(r=!1)}return r?e:(delete t[Va],t)}function Qa(e,t,n){return void 0!==e?e:t}function es(e,t){if(void 0===t&&(t=Qa),"object"!=typeof e||null===e)throw new TypeError("The reducer map must be an object.");for(var n=Object.keys(e),r=0,o=n;r<o.length;r+=1){var i=o[r];if("function"!=typeof e[i])throw new TypeError("Reducers must be functions.")}for(var a=Ja(n,function(t){return e[t]},t),s={},c=0,u=n;c<u.length;c+=1){var l=u[c];s[l]=e[l].defaultState}function d(e,t,n,r){void 0===e&&(e=s);var o=Xa(a,e,t,n,r);return void 0===n?Za(e,o):o}return d.defaultState=s,d}function ts(e,t){return e}function ns(e){return e}function rs(e,t,n){void 0===t&&(t=ts),void 0===n&&(n=ns);var r=e.defaultState;function o(o,i,a,s){void 0===o&&(o=r);var c=t(i,a),u=n(a),l=n(s);if(!c)return o;var d=e(o,c,u,l);return void 0===a?Za(o,d):d}return o.defaultState=r,o}function os(e,t,n){return{id:n,root:void 0!==e?e:t,get self(){return t[n]}}}var is={};function as(e,t,n){function r(r,o,i,a){void 0===r&&(r=is);var s=t(i),c=Xa(r===is||s!==t(a)?Ja(s,function(t){return e},n):Object.getPrototypeOf(r),r,o,i,a);return void 0===i?Za(r,c):c}return void 0===n&&(n=os),r.defaultState=is,r}function ss(){for(var e=arguments,t=arguments.length-1,n=arguments[t],r=[];t-- >0;)r[t]=e[t];if("function"!=typeof n)throw new TypeError("The reducer must be a function");for(var o=0,i=r;o<i.length;o+=1){if("function"!=typeof i[o])throw new TypeError("Each argument filter must be a function")}return function(e,t,o,i){void 0===e&&(e=n.defaultState);for(var a=void 0!==e,s=[],c=0;c<r.length;++c)s[c]=r[c](o),a&&s[c]!==r[c](i)&&(a=!1);return a?e:n.apply(void 0,s)}}function cs(e){const t={};for(const n of Object.keys(e)){t[e[n].currencyCode]=n}return t}function us(e={},t={},n,r){const o=[];for(const a of r){var i;const n=null!==(i=t[a])&&void 0!==i?i:e[a];null!=n&&o.push(n.currencyCode)}return o}function ls(e,t=[]){const n=new Set(t),r=[];for(const o of e)n.has(o)||(n.add(o),r.push(o));return r}function ds(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function fs(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?ds(Object(n),!0).forEach(function(t){r(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ds(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}const ps={},hs=[],ys={totalRatio:0},bs=es({accountId(e,t,n){if(null!=e)return e;for(const r of Object.keys(n.root.accounts)){const e=n.root.accounts[r];for(const t of Object.keys(e.walletInfos))if(t===n.id)return r}throw new Error(`Cannot find account for walletId ${n.id}`)},allEnabledTokenIds:ss(e=>e.root.accounts[e.self.accountId].alwaysEnabledTokenIds[e.self.pluginId],e=>e.self.enabledTokenIds,(e=[],t=[])=>ls([...e,...t])),pluginId:ss(e=>e.root.login.walletInfos[e.id].type,e=>e.root.plugins.currency,(e,t)=>eo(t,e)),paused(e,t,n){return null==e?n.root.accounts[n.self.accountId].pauseWallets:"CURRENCY_WALLET_CHANGED_PAUSED"===t.type?t.payload.paused:e},currencyInfo(e,t,n){if(null!=e)return e;const{pluginId:r}=n.self;return n.root.plugins.currency[r].currencyInfo},detectedTokenIds:ms((e=hs,t)=>{if("CURRENCY_WALLET_LOADED_TOKEN_FILE"===t.type)return t.payload.detectedTokenIds;if("CURRENCY_ENGINE_DETECTED_TOKENS"===t.type){const{detectedTokenIds:n}=t.payload;return ls([...e,...n])}return"CURRENCY_ENGINE_CLEARED"===t.type?[]:e}),enabledTokenIds:ms((e=hs,t)=>{if("CURRENCY_WALLET_LOADED_TOKEN_FILE"===t.type)return t.payload.enabledTokenIds;if("CURRENCY_WALLET_ENABLED_TOKENS_CHANGED"===t.type)return t.payload.enabledTokenIds;if("CURRENCY_ENGINE_DETECTED_TOKENS"===t.type){const{enablingTokenIds:n}=t.payload;return ls([...e,...n])}return e}),changeServiceSubscriptions(e=[],t){if("CURRENCY_ENGINE_UPDATE_CHANGE_SERVICE_SUBSCRIPTIONS"===t.type){return[...e.filter(e=>!t.payload.subscriptions.some(t=>t.address===e.address)),...t.payload.subscriptions]}return"CURRENCY_WALLET_LOADED_SUBSCRIBED_ADDRESSES"===t.type?t.payload.subscribedAddresses:e},tokenFileDirty(e=!1,t,n,r){switch(t.type){case"CURRENCY_WALLET_LOADED_TOKEN_FILE":case"CURRENCY_WALLET_SAVED_TOKEN_FILE":return!1;case"CURRENCY_ENGINE_CLEARED":case"CURRENCY_ENGINE_DETECTED_TOKENS":case"CURRENCY_WALLET_ENABLED_TOKENS_CHANGED":return n.self.detectedTokenIds!==r.self.detectedTokenIds||n.self.enabledTokenIds!==r.self.enabledTokenIds;default:return e}},tokenFileLoaded(e=!1,t){switch(t.type){case"CURRENCY_WALLET_LOADED_TOKEN_FILE":return!0;case"CURRENCY_ENGINE_CLEARED":return!1;default:return e}},walletSettings(e=ps,t){switch(t.type){case"CURRENCY_WALLET_LOADED_WALLET_SETTINGS_FILE":case"CURRENCY_WALLET_CHANGED_WALLET_SETTINGS":return t.payload.walletSettings;default:return e}},engineFailure(e=null,t){if("CURRENCY_ENGINE_FAILED"===t.type){const{error:e}=t.payload;return e instanceof Error?e:new Error(String(e))}return e},engineStarted(e=!1,t){return"CURRENCY_ENGINE_STARTED"===t.type||"CURRENCY_ENGINE_STOPPED"!==t.type&&e},fiat(e="",t){return"CURRENCY_WALLET_FIAT_CHANGED"===t.type?t.payload.fiatCurrencyCode:e},fiatLoaded(e=!1,t){return"CURRENCY_WALLET_FIAT_CHANGED"===t.type||e},files(e={},t){switch(t.type){case"CURRENCY_WALLET_FILE_CHANGED":{const{json:n,txidHash:r}=t.payload,o=fs({},e);return o[r]=n,o}case"CURRENCY_WALLET_FILES_LOADED":{const{files:n}=t.payload;return fs(fs({},e),n)}}return e},fileNames(e={},t){switch(t.type){case"CURRENCY_WALLET_FILE_NAMES_LOADED":{const{txFileNames:n}=t.payload;return fs(fs({},e),n)}case"CURRENCY_WALLET_FILE_CHANGED":{const{fileName:n,creationDate:r,txidHash:o}=t.payload;return(null==e[o]||r<e[o].creationDate)&&(e[o]={creationDate:r,fileName:n}),e}}return e},syncStatus(e=ys,t){switch(t.type){case"CURRENCY_ENGINE_CHANGED_SYNC_STATUS":return t.payload.status;case"CURRENCY_ENGINE_CLEARED":return ys}return e},balanceMap(e=new Map,t){if("CURRENCY_ENGINE_CHANGED_BALANCE"===t.type){const{balance:n,tokenId:r}=t.payload,o=new Map(e);return o.set(r,n),o}return e},balances:ss(e=>e.self.balanceMap,e=>e.self.currencyInfo,e=>e.root.accounts[e.self.accountId].allTokens[e.self.pluginId],(e,t,n)=>{const r={};for(const o of e.keys()){const i=e.get(o),{currencyCode:a}=null==o?t:n[o];null!=i&&(r[a]=i)}return r}),height(e=0,t){return"CURRENCY_ENGINE_CHANGED_HEIGHT"===t.type?t.payload.height:e},name(e=null,t){return"CURRENCY_WALLET_NAME_CHANGED"===t.type?t.payload.name:e},nameLoaded(e=!1,t){return"CURRENCY_WALLET_NAME_CHANGED"===t.type||e},seenTxCheckpoint(e=null,t){return"CURRENCY_ENGINE_SEEN_TX_CHECKPOINT_CHANGED"===t.type?t.payload.checkpoint:e},sortedTxidHashes:ss(e=>e.self.txidHashes,e=>Object.keys(e).sort((t,n)=>e[t].date>e[n].date?-1:e[t].date<e[n].date?1:0)),stakingStatus(e={stakedAmounts:[]},t){return"CURRENCY_ENGINE_CHANGED_STAKING"===t.type?t.payload.stakingStatus:e},txidHashes(e={},t){switch(t.type){case"CURRENCY_ENGINE_CHANGED_TXS":return gs(e,t.payload.txidHashes);case"CURRENCY_WALLET_FILE_NAMES_LOADED":{const{txFileNames:n}=t.payload,r={};for(const e of Object.keys(n))r[e]={date:n[e].creationDate};return gs(e,r)}}return e},txs(e={},t,n){switch(t.type){case"CHANGE_MERGE_TX":{const{tx:n}=t.payload,r=fs({},e);return r[n.txid]=n,r}case"CURRENCY_ENGINE_CHANGED_TXS":{const{txs:n}=t.payload,r=fs({},e);for(const e of n)r[e.txid]=vs(e,r[e.txid]);return r}case"CURRENCY_ENGINE_CLEARED":return{}}return e},unactivatedTokenIds(e=[],t){switch(t.type){case"CURRENCY_ENGINE_CHANGED_UNACTIVATED_TOKEN_IDS":return t.payload.unactivatedTokenIds;case"CURRENCY_ENGINE_CLEARED":return[]}return e},gotTxs(e=new Set,t){switch(t.type){case"CURRENCY_ENGINE_GOT_TXS":{const{tokenId:n}=t.payload,r=new Set(e);return r.add(n),r}case"CURRENCY_ENGINE_CLEARED":return new Set;default:return e}},walletInfo(e,t,n){return n.root.login.walletInfos[n.id]},publicWalletInfo(e=null,t){return"CURRENCY_WALLET_PUBLIC_INFO"===t.type?t.payload.walletInfo:e}});function gs(e,t){const n=fs({},e);for(const o of Object.keys(t)){var r;const e=n[o],i=t[o];n[o]=null==e?i:{date:Math.min(i.date,e.date),txid:null!==(r=i.txid)&&void 0!==r?r:e.txid}}return n}const ws=rs(bs,(e,t)=>/^CURRENCY_/.test(e.type)&&"payload"in e&&"object"==typeof e.payload&&"walletId"in e.payload&&e.payload.walletId===t.id?e:{type:"UPDATE_NEXT"});function vs(e,t){var n,r,o,i;const{confirmations:a="unconfirmed",isSend:s=(0,Vi.lt)(e.nativeAmount,"0"),tokenId:c=null}=e,u={blockHeight:e.blockHeight,chainAction:e.chainAction,chainAssetAction:new Map(null!==(n=null==t?void 0:t.chainAssetAction)&&void 0!==n?n:[]),confirmations:a,date:e.date,isSend:s,memos:e.memos,nativeAmount:new Map(null!==(r=null==t?void 0:t.nativeAmount)&&void 0!==r?r:[]),networkFee:new Map(null!==(o=null==t?void 0:t.networkFee)&&void 0!==o?o:[]),otherParams:e.otherParams,ourReceiveAddresses:e.ourReceiveAddresses,signedTx:e.signedTx,txid:e.txid};return u.nativeAmount.set(c,e.nativeAmount),u.networkFee.set(c,null!==(i=e.networkFee)&&void 0!==i?i:"0"),null!=e.feeRateUsed&&(u.feeRateUsed=e.feeRateUsed),null!=e.parentNetworkFee&&u.networkFee.set(null,String(e.parentNetworkFee)),null!=e.chainAssetAction&&u.chainAssetAction.set(c,e.chainAssetAction),u}function ms(e){return(t,n)=>{const r=e(t,n);return r===t?t:(r.sort((e,t)=>e===t?0:e>t?1:-1),null!=t&&va(r,t)?t:r)}}function Is(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Es(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Is(Object(n),!0).forEach(function(t){r(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Is(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}const Ss="publicKey.json",Os=_r(qa),As=mr({engine:e=>async()=>{const{state:t,walletId:n,walletState:r}=e.props,{accountId:o,pluginId:i,walletInfo:a}=r,s=t.plugins.currency[i],{currencyCode:c}=s.currencyInfo;try{var u,l;const t=Ou(e);await go(t,a);const{state:d}=e.props,f=So(d,a.id),p=function(e,t,n){return ao(n,e.storageWallets[t].paths.dataKey,e.storageWallets[t].localDisklet)}(d,a.id,e.props.io);await gc(e);const h=await no(t,i),y=await Ts(a,f,h);e.props.dispatch({type:"CURRENCY_WALLET_PUBLIC_INFO",payload:{walletInfo:y,walletId:n}});const{checkpoint:b,subscribedAddresses:g}=await async function(e){var t;const{dispatch:n,state:r,walletId:o}=e.props,i=Eo(r,o),a=await oc.load(i,Js),s=null!=a?a:{checkpoint:void 0,subscribedAddresses:[]},c=s.checkpoint,u=null!==(t=s.subscribedAddresses)&&void 0!==t?t:[];null!=c&&n({type:"CURRENCY_ENGINE_SEEN_TX_CHECKPOINT_CHANGED",payload:{checkpoint:c,walletId:o}});if(u.length>0){const e=u.map(({address:e,checkpoint:t})=>({address:e,checkpoint:t,status:"subscribing"}));n({type:"CURRENCY_WALLET_LOADED_SUBSCRIBED_ADDRESSES",payload:{subscribedAddresses:e,walletId:o}})}return{checkpoint:c,subscribedAddresses:u}}(e);await pc(e);const{hasWalletSettings:w=!1}=r.currencyInfo;w&&await hc(e);const v=d.accounts[o],m=await s.makeCurrencyEngine(y,{callbacks:Ps(e),seenTxCheckpoint:b,subscribedAddresses:g,log:Lr(e.props.logBackend,`${i}-${a.id.slice(0,2)}`),walletLocalDisklet:f,walletLocalEncryptedDisklet:p,customTokens:null!==(u=v.customTokens[i])&&void 0!==u?u:{},enabledTokenIds:e.props.walletState.allEnabledTokenIds,userSettings:null!==(l=v.userSettings[i])&&void 0!==l?l:{},walletSettings:e.props.walletState.walletSettings});e.onOutput(m);const I={currencyCode:c,tokenId:null},E=me(Ma)(m.getBalance(I));null!=E&&e.props.dispatch({type:"CURRENCY_ENGINE_CHANGED_BALANCE",payload:{balance:E,tokenId:null,walletId:n}});const S=m.getBlockHeight();e.props.dispatch({type:"CURRENCY_ENGINE_CHANGED_HEIGHT",payload:{height:S,walletId:n}}),null!=m.getStakingStatus&&await m.getStakingStatus().then(t=>{e.props.dispatch({type:"CURRENCY_ENGINE_CHANGED_STAKING",payload:{stakingStatus:t,walletId:n}})},t=>e.props.onError(t)),await dc(e),await fc(e),await wc(e)}catch(d){e.props.onError(d),e.props.dispatch({type:"CURRENCY_ENGINE_FAILED",payload:{error:d,walletId:n}})}return function(e){const{walletId:t}=e.props;let n;async function r(r){const o=function(e,t){return e.storageWallets[t].lastChanges}(r.state,t);o!==n&&(n=o,await async function(e,t){(t.includes(Xs)||t.includes(Vs))&&await pc(e);const{hasWalletSettings:n=!1}=e.props.walletState.currencyInfo;n&&t.includes(Qs)&&await hc(e);t.includes(Hs)&&await dc(e);t.includes(Zs)&&await fc(e);await gc(e),await wc(e)}(e,o))}function o(){e.nextProps().then(r).then(o,t=>{var n;(n=t)instanceof Error&&"PixieShutdownError"===n.name||(e.props.onError(t),o())})}o()}(e),await Ar},walletApi:e=>async()=>{const{walletOutput:t,walletState:n}=e.props;if(null==t)return;const{engine:r}=t,{nameLoaded:o,pluginId:i,publicWalletInfo:a}=n;if(null==r||null==a||!o)return;const s=await no(Ou(e),i),c=function(e,t,n,r){const o=Ou(e),{accountId:i,pluginId:a,walletInfo:s}=e.props.walletState,c=e.props.state.plugins.currency[a],{unsafeBroadcastTx:u=!1,unsafeMakeSpend:l=!1}=c.currencyInfo,d=ga(o,s),f=Ps(e),p={};if(null!=t.otherMethods)for(const y of Object.keys(t.otherMethods)){const e=t.otherMethods[y];"function"==typeof e&&(p[y]=e)}if(null!=t.otherMethodsWithKeys)for(const y of Object.keys(t.otherMethodsWithKeys)){const e=t.otherMethodsWithKeys[y];"function"==typeof e&&(p[y]=(...t)=>e(s.keys,...t))}P(p);const h={on:Q,watch:ee,get created(){return s.created},get disklet(){return d.disklet},get id(){return d.id},get imported(){return!0===s.imported},get localDisklet(){return d.localDisklet},publicWalletInfo:r,async sync(){await d.sync()},get type(){return d.type},get name(){return e.props.walletState.name},async renameWallet(t){await async function(e,t){const{dispatch:n,state:r,walletId:o}=e.props,i=Eo(r,o);await cc.save(i,Zs,{walletName:t}),n({type:"CURRENCY_WALLET_NAME_CHANGED",payload:{name:t,walletId:o}})}(e,t)},get fiatCurrencyCode(){return e.props.walletState.fiat},async setFiatCurrencyCode(t){await async function(e,t){const{dispatch:n,state:r,walletId:o}=e.props,i=Eo(r,o);if(!/^iso:/.test(t))throw new TypeError("Fiat currency codes must start with `iso:`");await sc.save(i,Hs,{fiat:t,num:void 0}),n({type:"CURRENCY_WALLET_FIAT_CHANGED",payload:{fiatCurrencyCode:t,walletId:o}})}(e,t)},get currencyConfig(){const{accountApi:t}=e.props.output.accounts[i];return t.currencyConfig[a]},get currencyInfo(){return c.currencyInfo},async denominationToNative(t,n){const r=qo(c.currencyInfo,e.props.state.accounts[i].allTokens[a],n);return(0,Vi.mul)(t,r)},async nativeToDenomination(t,n){const r=qo(c.currencyInfo,e.props.state.accounts[i].allTokens[a],n);return(0,Vi.div)(t,r,r.length)},get walletSettings(){return e.props.walletState.walletSettings},async changeWalletSettings(t){if(!0!==e.props.walletState.currencyInfo.hasWalletSettings)throw new Error("Wallet settings unsupported");await async function(e,t){const{dispatch:n,state:r,walletId:o}=e.props,i=Eo(r,o);await yc(i,t),n({type:"CURRENCY_WALLET_CHANGED_WALLET_SETTINGS",payload:{walletId:o,walletSettings:t}})}(e,t)},get balances(){return e.props.walletState.balances},get balanceMap(){return e.props.walletState.balanceMap},get blockHeight(){const{skipBlockHeight:t}=e.props.state;return t?0:e.props.walletState.height},get syncRatio(){return e.props.walletState.syncStatus.totalRatio},get syncStatus(){return e.props.walletState.syncStatus},get unactivatedTokenIds(){return e.props.walletState.unactivatedTokenIds},async changePaused(t){e.props.dispatch({type:"CURRENCY_WALLET_CHANGED_PAUSED",payload:{walletId:e.props.walletId,paused:t}})},get paused(){return e.props.walletState.paused},async changeEnabledTokenIds(t){var n;const{dispatch:r,walletId:o,walletState:i}=e.props,{accountId:a,pluginId:s}=i,c=null!==(n=e.props.state.accounts[a].allTokens[s])&&void 0!==n?n:{},u=ls(t).filter(e=>null!=c[e]),l=o.slice(0,2);e.props.log.warn(`enabledTokenIds: ${l} changeEnabledTokenIds`),r({type:"CURRENCY_WALLET_ENABLED_TOKENS_CHANGED",payload:{walletId:o,enabledTokenIds:u}})},get detectedTokenIds(){return e.props.walletState.detectedTokenIds},get enabledTokenIds(){return e.props.walletState.enabledTokenIds},async getNumTransactions(n){const r=Ji({allTokens:e.props.state.accounts[i].allTokens[a],currencyInfo:c.currencyInfo,tokenId:n.tokenId});return t.getNumTransactions(r)},async $internalStreamTransactions(n){const{afterDate:r,batchSize:i=10,beforeDate:a,firstBatchSize:s=i,searchString:c,spamThreshold:u="0",tokenId:l=null}=n,{currencyCode:d}=null==l?this.currencyInfo:this.currencyConfig.allTokens[l],p={currencyCode:d,tokenId:l};let h=e.props.walletState;if(!h.gotTxs.has(l)){const n=await t.getTransactions(p);f.onTransactionsChanged(n),e.props.dispatch({type:"CURRENCY_ENGINE_GOT_TXS",payload:{walletId:e.props.walletId,tokenId:l}}),h=e.props.walletState}const{files:y,sortedTxidHashes:b,txidHashes:g,txs:w}=h;let v=0,m=!0,I=0;return P({async next(){const t=m?s:i,n=[];for(;v<b.length&&n.length<t;){var d,f;if(v>=I){const n=b.slice(I,I+t).filter(e=>null==y[e]),r=await bc(e,n);Object.assign(y,r),I+=t}const i=b[v++],s=y[i],p=null!==(d=null==s?void 0:s.txid)&&void 0!==d?d:null===(f=g[i])||void 0===f?void 0:f.txid;if(null==p)continue;const h=w[p],m=null==h?void 0:h.nativeAmount.get(l),E=null==h?void 0:h.networkFee.get(l);if(null==h||null==m||null==E)continue;const S=zs(e,h,s,l);if(Zi(S),!js(o,S,c))continue;if(!Ns(S,r,a))continue;!(h.isSend||null!=S.assetAction||null!=S.chainAction||null!=S.chainAssetAction||null!=S.savedAction)&&(0,Vi.lt)((0,Vi.abs)(m),u)||n.push(S)}return m=!1,{done:0===n.length,value:n}}})},async getTransactions(t){const{endDate:n,startDate:r,searchString:o,spamThreshold:s}=t,u=Ji({allTokens:e.props.state.accounts[i].allTokens[a],currencyInfo:c.currencyInfo,tokenId:t.tokenId}),l=await h.$internalStreamTransactions(Ws(Ws({},u),{},{afterDate:r,beforeDate:n,searchString:o,spamThreshold:s})),d=[];for(;;){const e=await l.next();if(e.done)return d;d.push(...e.value)}},streamTransactions:se,async getAddresses(n){if(null!=t.getAddresses)return await t.getAddresses(n);{const r=Ji({allTokens:e.props.state.accounts[i].allTokens[a],currencyInfo:c.currencyInfo,tokenId:n.tokenId}),o=await t.getFreshAddress(Ws(Ws({},r),{},{forceIndex:n.forceIndex})),{publicAddress:s,legacyAddress:u,segwitAddress:l,nativeBalance:d,legacyNativeBalance:f,segwitNativeBalance:p}=o,h=[{addressType:"publicAddress",publicAddress:s,nativeBalance:d}];return null!=l&&h.unshift({addressType:"segwitAddress",publicAddress:l,nativeBalance:p}),null!=u&&h.push({addressType:"legacyAddress",publicAddress:u,nativeBalance:f}),h}},async getReceiveAddress(e){var t;const n=await this.getAddresses(e);if(n.length<1)throw new Error("No addresses available");const r=null!==(t=n.find(e=>"publicAddress"===e.addressType))&&void 0!==t?t:n[0],o={publicAddress:r.publicAddress,nativeBalance:r.nativeBalance,metadata:Gs,nativeAmount:"0"},i=n.find(e=>"segwitAddress"===e.addressType);null!=i&&(o.segwitAddress=i.publicAddress,o.segwitNativeBalance=i.nativeBalance);const a=n.find(e=>"legacyAddress"===e.addressType);return null!=a&&(o.legacyAddress=a.publicAddress,o.legacyNativeBalance=a.nativeBalance),o},async lockReceiveAddress(e){},async saveReceiveAddress(e){},async broadcastTx(e){const n=u?s.keys:void 0;return await t.broadcastTx(e,{privateKeys:n})},async getMaxSpendable(n){return await Us(n,c,t,e.props.state.accounts[i].allTokens[a],s)},async getPaymentProtocolInfo(e){if(null==t.getPaymentProtocolInfo)throw new Error("'getPaymentProtocolInfo' is not implemented on wallets of this type");return await t.getPaymentProtocolInfo(e)},async makeSpend(n){n=Ls(n,c.currencyInfo);const{assetAction:r,customNetworkFee:o,enableRbf:u,memos:d,metadata:f,networkFeeOption:p="standard",noUnconfirmed:h=!1,otherParams:y,pendingTxs:b,rbfTxid:g,savedAction:w,skipChecks:v,spendTargets:m=[],swapData:I}=n,E=Ji({allTokens:e.props.state.accounts[i].allTokens[a],currencyInfo:c.currencyInfo,tokenId:n.tokenId}),S=[],O=[];for(const e of m){const{memo:t,publicAddress:n,nativeAmount:r="0",otherParams:o={}}=e;null!=n&&(S.push({memo:t,nativeAmount:r,otherParams:o,publicAddress:n,uniqueIdentifier:t}),O.push({currencyCode:E.currencyCode,memo:t,nativeAmount:r,publicAddress:n,uniqueIdentifier:t}))}if(null!=n.privateKeys)throw new TypeError("Only sweepPrivateKeys takes private keys");const A=l?s.keys:void 0,T=await t.makeSpend(Ws(Ws({},E),{},{customNetworkFee:o,enableRbf:u,memos:d,metadata:f,networkFeeOption:p,noUnconfirmed:h,otherParams:y,pendingTxs:b,rbfTxid:g,skipChecks:v,spendTargets:S}),{privateKeys:A});return Zi(T),T.networkFeeOption=p,T.requestedCustomFee=o,T.spendTargets=O,T.currencyCode=E.currencyCode,T.tokenId=E.tokenId,null!=f&&(T.metadata=f),null!=I&&(T.swapData=Pa(I)),null!=w&&(T.savedAction=Da(w)),null!=r&&(T.assetAction=Ra(r)),null!=e.props.state.login.deviceInfo.deviceDescription&&(T.deviceDescription=e.props.state.login.deviceInfo.deviceDescription),T},async saveTx(n){if(null==e.props.walletState.txs[n.txid]){const{fileName:t,txFile:r}=await mc(e,n);await async function(e,t,n){const{state:r,walletId:o}=e.props,i=Eo(r,o);await ac.save(i,"transaction/"+t,n)}(e,t,r),f.onTransactions([{isNew:!0,transaction:n}])}else await vc(e,n.txid,n.tokenId,f);await t.saveTx(n)},async saveTxAction(t){const{txid:n,tokenId:r,assetAction:o,savedAction:i}=t;await vc(e,n,r,f,void 0,o,i)},async saveTxMetadata(t){const{txid:n,tokenId:r,metadata:o}=t;await vc(e,n,r,f,o)},async signBytes(e,n={}){const r=s.keys;if(null!=t.signBytes)return await t.signBytes(e,r,n);if("bitcoin"===a&&null!=t.signMessage)return await t.signMessage(w(e),r,n);throw new Error(`${a} doesn't support signBytes`)},async signMessage(e,n={}){if(null==t.signMessage)throw new Error(`${a} doesn't support signing messages`);const r=s.keys;return await t.signMessage(e,r,n)},async signTx(e){const n=s.keys;return await t.signTx(e,n)},async sweepPrivateKeys(e){if(null==t.sweepPrivateKeys)throw new Error("Sweeping this currency is not supported.");return await t.sweepPrivateKeys(e)},async accelerate(e){return null==t.accelerate?null:await t.accelerate(e)},get stakingStatus(){return e.props.walletState.stakingStatus},async dumpData(){return await t.dumpData()},async resyncBlockchain(){const n=e.props.walletId.slice(0,2);e.props.log.warn(`enabledTokenIds: ${n} resyncBlockchain`),o.props.dispatch({type:"CURRENCY_ENGINE_CLEARED",payload:{walletId:e.props.walletId}}),await t.resyncBlockchain(),W(h,"transactionsRemoved",void 0)},async split(e){return await ya(o,i,s,e,!1)},async encodeUri(t){return await n.encodeUri(t,ca(e.props.state.accounts[i].customTokens[a]))},async parseUri(t,r){const o=await n.parseUri(t,r,ca(e.props.state.accounts[i].customTokens[a]));if(void 0===o.tokenId){var s;const{tokenId:t=null}=Ji({allTokens:e.props.state.accounts[i].allTokens[a],currencyInfo:c.currencyInfo,currencyCode:null!==(s=o.currencyCode)&&void 0!==s?s:r});o.tokenId=t}return o},otherMethods:p};return P(h)}(e,r,s,a);return e.onOutput(c),await Ar},engineStarted:Sr(e=>{let t;return{update(){const{log:n,walletId:r,walletOutput:o,walletState:i}=e.props;if(null==o)return;const{engine:a,walletApi:s}=o;null!=s&&i.fiatLoaded&&!i.engineStarted&&null!=a&&null==t&&(n(`${r} startEngine`),e.props.dispatch({type:"CURRENCY_ENGINE_STARTED",payload:{walletId:r}}),t=Promise.resolve().then(()=>a.startEngine()).then(()=>{e.onOutput(!0)}).catch(t=>e.props.onError(t)))},destroy(){const{log:n,walletId:r,walletOutput:o}=e.props;if(null==o)return;const{engine:i}=o;null!=i&&null!=t&&(n(`${r} killEngine`),t.then(()=>i.killEngine()).catch(t=>e.props.onError(t)).then(()=>{e.onOutput(!1),e.props.dispatch({type:"CURRENCY_ENGINE_STOPPED",payload:{walletId:r}})}).catch(()=>{}))}}},e=>e.state.paused||e.walletState.paused?void 0:e),syncNetworkUpdate:Sr(e=>({async update(e){if(null==e.walletOutput)return;const{engine:t,engineStarted:n}=e.walletOutput;if(null==(null==t?void 0:t.syncNetwork)||!n)return;const{walletState:r}=e,{currencyInfo:o,walletInfo:i,publicWalletInfo:a}=r,s=!0===o.unsafeSyncNetwork&&null!=a?i.keys:void 0;for(const c of r.changeServiceSubscriptions)await t.syncNetwork({privateKeys:s,subscribeParam:{address:c.address,checkpoint:c.checkpoint,needsSync:"syncing"===c.status}});e.dispatch({type:"CURRENCY_ENGINE_UPDATE_CHANGE_SERVICE_SUBSCRIPTIONS",payload:{subscriptions:r.changeServiceSubscriptions.map(e=>Es(Es({},e),{},{status:"listening"})),walletId:e.walletId}})},destroy(){}}),e=>!e.state.paused&&!e.walletState.paused&&e.walletState.engineStarted&&e.walletState.changeServiceSubscriptions.some(e=>"syncing"===e.status||"synced"===e.status)?e:void 0),syncNetworkTask:Sr(e=>{const t=Zr(async()=>{if(null==e.props.walletOutput)return;const{engine:n,engineStarted:r}=e.props.walletOutput;if(null==(null==n?void 0:n.syncNetwork)||!r)return void t.stop();const{walletState:o}=e.props,{currencyInfo:i,walletInfo:a,publicWalletInfo:s}=o,c=!0===i.unsafeSyncNetwork&&null!=s?a.keys:void 0,u=await n.syncNetwork({privateKeys:c});t.setDelay(u)},1e4,{onError:t=>{e.props.log.error(t)}});return{update(e){if(null==e.walletOutput)return;const{engine:n,engineStarted:r}=e.walletOutput;null==(null==n?void 0:n.syncNetwork)||!r||null!=t&&t.started||t.start({wait:!1})},destroy(){null!=t&&t.stop()}}},e=>e.state.paused||e.walletState.paused||!e.walletState.engineStarted||!0===e.walletState.currencyInfo.usesChangeServer&&!e.walletState.changeServiceSubscriptions.some(e=>"avoiding"===e.status||"reconnecting"===e.status||"resubscribing"===e.status||"subscribingSlowly"===e.status)?void 0:e),syncTimer:Sr(e=>{const t=Zr(async function(){const{walletId:t}=e.props;await wo(Ou(e),t)},bo);return{update(){const{state:n,walletId:r,walletOutput:o}=e.props;null!=o&&null!=n.storageWallets[r]&&n.storageWallets[r].status.lastSync>0&&t.start({wait:bo*(1+Math.random())})},destroy(){t.stop()}}},e=>e.state.paused||e.walletState.paused?void 0:e),tokenSaver(e){let t=hs;return async function(){const{detectedTokenIds:n,enabledTokenIds:r,tokenFileDirty:o,tokenFileLoaded:i}=e.props.walletState;if(o&&i){const o=_s(r,t),i=_s(t,r),a=e.props.walletId.slice(0,2);e.props.log.warn(`enabledTokenIds: ${a} write to disk, add [${o}], remove [${i}]`),await async function(e,t,n){const{state:r,walletId:o}=e.props,i=Eo(r,o);await ic.save(i,Xs,{detectedTokenIds:t,enabledTokenIds:n})}(e,n,r).catch(t=>e.props.onError(t)),e.props.dispatch({type:"CURRENCY_WALLET_SAVED_TOKEN_FILE",payload:{walletId:e.props.walletId}}),await Qr(100)}t=r}},watcher(e){let t,n={},r=ps,o={},i=hs;return async()=>{var a,s;const{state:c,walletState:u,walletOutput:l}=e.props;if(null==u||null==l)return;const{engine:d,walletApi:f}=l,{accountId:p,pluginId:h}=u,y=c.accounts[p];t!==u&&null!=f&&G(f),t=u;const b=null!==(a=y.userSettings[h])&&void 0!==a?a:n;n!==b&&null!=d&&await d.changeUserSettings(b),n=b;const g=null!==(s=y.customTokens[h])&&void 0!==s?s:o;if(o!==g&&null!=d)if(null!=d.changeCustomTokens)await d.changeCustomTokens(g);else if(null!=d.addCustomToken)for(const t of Object.keys(g)){const n=g[t];if(n===o[t])continue;const r=ua(n);null!=r&&await d.addCustomToken(Es(Es({},r),n)).catch(t=>e.props.onError(t))}o=g;const{hasWalletSettings:w=!1}=u.currencyInfo,{walletSettings:v}=u;r!==v&&null!=(null==d?void 0:d.changeWalletSettings)&&w&&await d.changeWalletSettings(v).catch(t=>{e.props.onError(t)}),r=v;const{allEnabledTokenIds:m}=u;if(i!==m&&null!=d)if(null!=d.changeEnabledTokenIds)await d.changeEnabledTokenIds(m).catch(t=>e.props.onError(t));else if(null!=d.disableTokens&&null!=d.enableTokens){const t=us(y.builtinTokens[h],y.customTokens[h],u.currencyInfo,ls(i,m)),n=us(y.builtinTokens[h],y.customTokens[h],u.currencyInfo,ls(m,i));await d.disableTokens(t).catch(t=>e.props.onError(t)),await d.enableTokens(n).catch(t=>e.props.onError(t))}i=m}}});async function Ts(e,t,n){const r=await Os.load(t,Ss);if(null!=r&&(null==n.checkPublicKey||await n.checkPublicKey(r.walletInfo.keys)))return r.walletInfo;let o={};try{o=await n.derivePublicKey(e)}catch(a){}const i={id:e.id,type:e.type,keys:o};return Object.keys(o).length>0&&await Os.save(t,Ss,{walletInfo:i}),i}function _s(e,t){const n=new Set(t);return e.filter(e=>!n.has(e)).join(", ")}let ks=5e3;function xs(e,t){const{log:n,walletId:r}=e.props;let o=!1,i=0,a=[];return e=>{if(o)n(`throttledTxCallback delay, walletId: ${r}`),a.push(...e);else{const s=Date.now();s-i>ks?(i=s,t(e)):(n(`throttledTxCallback delay, walletId: ${r}`),o=!0,a=e,setTimeout(()=>{i=Date.now(),t(a),o=!1,a=[]},ks))}}}function Ps(e){const{walletId:t}=e.props;"narfavJN4rp9ZzYigcRj1i0vrU2OAGGp4+KksAksj54="===t&&(ks=25,Ia=99,ma=1);const n=xs(e,t=>{var n;null!=(null===(n=e.props.walletOutput)||void 0===n?void 0:n.walletApi)&&W(e.props.walletOutput.walletApi,"transactionsChanged",t)}),r=xs(e,t=>{var n;null!=(null===(n=e.props.walletOutput)||void 0===n?void 0:n.walletApi)&&W(e.props.walletOutput.walletApi,"newTransactions",t)}),o={onAddressesChecked(n){Oa({id:t,action:"onSyncStatusChanged",updateFunc:()=>{e.props.dispatch({type:"CURRENCY_ENGINE_CHANGED_SYNC_STATUS",payload:{status:{totalRatio:n},walletId:t}})}})},onNewTokens(n){Oa({id:t,action:"onNewTokens",updateFunc:()=>{const{detectedTokenIds:r,enabledTokenIds:o}=e.props.walletState,i=ls(n,[...r,...o]),a=_s(n,r),s=_s(r,n),c=t.slice(0,2);if(e.props.log.warn(`enabledTokenIds: ${c} engine detected tokens, add [${a}], remove [${s}]`),e.props.dispatch({type:"CURRENCY_ENGINE_DETECTED_TOKENS",payload:{detectedTokenIds:n,enablingTokenIds:i,walletId:t}}),i.length>0){var u;const t=null===(u=e.props)||void 0===u||null===(u=u.walletOutput)||void 0===u?void 0:u.walletApi;null!=t&&W(t,"enabledDetectedTokens",i)}}})},onUnactivatedTokenIdsChanged(n){Oa({id:t,action:"onUnactivatedTokenIdsChanged",updateFunc:()=>{e.props.dispatch({type:"CURRENCY_ENGINE_CHANGED_UNACTIVATED_TOKEN_IDS",payload:{unactivatedTokenIds:n,walletId:t}})}})},onBalanceChanged(t,n){const{accountId:r,currencyInfo:i,pluginId:a}=e.props.walletState,s=e.props.state.accounts[r].allTokens[a];if(t===i.currencyCode)o.onTokenBalanceChanged(null,n);else{const{tokenId:e}=Ji({allTokens:s,currencyInfo:i,currencyCode:t});null!=e&&o.onTokenBalanceChanged(e,n)}},onTokenBalanceChanged(n,r){const o=me(Ma)(r);null!=o?Oa({id:`${t}==${String(n)}`,action:"onTokenBalanceChanged",updateFunc:()=>{e.props.dispatch({type:"CURRENCY_ENGINE_CHANGED_BALANCE",payload:{balance:o,tokenId:n,walletId:t}})}}):e.props.onError(new Error(`Plugin sent bogus balance for ${String(n)}: "${r}"`))},onBlockHeightChanged(r){Oa({id:t,action:"onBlockHeightChanged",updateFunc:()=>{const{txs:o,files:i}=e.props.walletState,a=[];for(const n of Object.keys(o)){const s=o[n];if(Ms(s.confirmations)){const n=Oo(e.props.state,t,s.txid),o=zs(e,s,i[n],null,r);a.push(o)}}a.length>0&&n(a),e.props.dispatch({type:"CURRENCY_ENGINE_CHANGED_HEIGHT",payload:{height:r,walletId:t}})}})},onSeenTxCheckpoint(t){Ic(e,t).catch(t=>e.props.onError(t))},onStakingStatusChanged(n){Oa({id:t,action:"onStakingStatusChanged",updateFunc:()=>{e.props.dispatch({type:"CURRENCY_ENGINE_CHANGED_STAKING",payload:{stakingStatus:n,walletId:t}})}})},onSubscribeAddresses(n){var r;const o=n.map(e=>"string"==typeof e?{address:e,checkpoint:void 0}:e);Ic(e,null!==(r=e.props.walletState.seenTxCheckpoint)&&void 0!==r?r:void 0,o).catch(t=>e.props.onError(t));const i=o.map(({address:e,checkpoint:t})=>({address:e,status:"subscribing",checkpoint:t}));e.props.dispatch({type:"CURRENCY_ENGINE_UPDATE_CHANGE_SERVICE_SUBSCRIPTIONS",payload:{subscriptions:i,walletId:t}})},onSyncStatusChanged(n){Oa({id:t,action:"onSyncStatusChanged",updateFunc:()=>{e.props.dispatch({type:"CURRENCY_ENGINE_CHANGED_SYNC_STATUS",payload:{status:n,walletId:t}})}})},onTransactions(o){const{accountId:i,currencyInfo:a,pluginId:s}=e.props.walletState,c=e.props.state.accounts[i].allTokens[s];if(null==o||0===o.length)return;const u=[];for(const t of o){const n=t.transaction;if(Zi(n),"string"!=typeof n.txid||"number"!=typeof n.date||"string"!=typeof n.networkFee||"number"!=typeof n.blockHeight||"string"!=typeof n.nativeAmount||"object"!=typeof n.ourReceiveAddresses)return void e.props.onError(new Error(`Plugin sent bogus tx: ${JSON.stringify(n,null,2)}`));if(null==n.isSend&&(n.isSend=(0,Vi.lt)(n.nativeAmount,"0")),null==n.memos&&(n.memos=[]),void 0===n.tokenId){const{tokenId:e}=Ji({allTokens:c,currencyInfo:a,currencyCode:n.currencyCode});n.tokenId=null!=e?e:null}u.push(n)}const{state:l}=e.props,{txs:d}=e.props.walletState,f={},p=[],h=[];for(const n of o){const{isNew:r,transaction:o}=n,{txid:i}=o,a=vs(o,d[i]);if(va(a,d[i])&&null==o.metadata)continue;const s=Oo(l,t,i);null==e.props.walletState.fileNames[s]&&mc(e,o).catch(t=>e.props.onError(t));const{files:c}=e.props.walletState,u=zs(e,a,c[s],o.tokenId);r?h.push(u):p.push(u),f[s]={date:u.date,txid:i}}e.props.dispatch({type:"CURRENCY_ENGINE_CHANGED_TXS",payload:{txs:u,walletId:t,txidHashes:f}}),p.length>0&&n(p),h.length>0&&r(h)},onTransactionsChanged(e){o.onTransactions(e.map(e=>({isNew:!1,transaction:e})))},onAddressChanged(){null!=e.props.walletOutput.walletApi&&W(e.props.walletOutput.walletApi,"addressChanged",void 0)},onWcNewContractCall(t){null!=e.props.walletOutput.walletApi&&W(e.props.walletOutput.walletApi,"wcNewContractCall",t)},onTxidsChanged(){}};return o}const Ms=e=>"number"!=typeof e&&"confirmed"!==e&&"dropped"!==e&&"failed"!==e,Cs=(e,t,n=1)=>{if(e.blockHeight>0){const r=1+t-e.blockHeight;return r<=0?"syncing":r>=n?"confirmed":r}return e.blockHeight<0?"dropped":"unconfirmed"};function Ns(e,t=new Date(0),n=new Date){return 1e3*e.date>=t.valueOf()&&1e3*e.date<n.valueOf()}function js(e,t,n){var r;const o=e.props.state.currency;if(null==n||""===n)return!0;let i=n.toLowerCase().replace(".","").replace(",","");for(let c=0;c<i.length;c++)if("0"!==i[c]){i=i.substring(c);break}function a(e){return null!=e&&("string"==typeof e||"number"==typeof e)&&!!e.toString().toLowerCase().replace(".","").replace(",","").includes(i)}if(a(t.nativeAmount))return!0;if(null!=t.metadata){const{category:e="",name:n="",notes:r="",exchangeAmount:i={}}=t.metadata,s=null!=t.walletId?o.wallets[t.walletId]:void 0;if(a(e)||a(n)||a(r)||null!=s&&a(i[s.fiat]))return!0}if(null!=t.swapData){const{displayName:e="",pluginId:n=""}=t.swapData.plugin;if(a(e)||a(n))return!0}const s=null!==(r=t.savedAction)&&void 0!==r?r:t.chainAction;if(null!=s&&"swap"===s.actionType){const{pluginId:e}=s.toAsset,{pluginId:t}=s.fromAsset,{displayName:n,supportEmail:r}=s.swapInfo;if(a(t)||a(e)||a(n)||a(r))return!0}if(null!=t.spendTargets)for(const c of t.spendTargets){const{publicAddress:e="",memo:t=""}=c;if(a(e)||a(t))return!0}if(t.ourReceiveAddresses.length>0)for(const c of t.ourReceiveAddresses)if(a(c))return!0;return!!a(t.txid)}function Ds(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Rs(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Ds(Object(n),!0).forEach(function(t){r(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ds(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Ls(e,t){var n,r;const o=[],{memoType:i}=t;if("hex"===i||"number"===i||"text"===i)for(const c of e.spendTargets){var a;null!=c.memo?o.push({type:i,value:c.memo}):null!=c.uniqueIdentifier?o.push({type:i,value:c.uniqueIdentifier}):"string"==typeof(null===(a=c.otherParams)||void 0===a?void 0:a.uniqueIdentifier)&&o.push({type:i,value:c.otherParams.uniqueIdentifier})}for(const c of o)"hex"===c.type&&(c.value=c.value.replace(/^0x/i,""));const s=Rs(Rs({},e),{},{spendTargets:e.spendTargets.map(e=>Rs(Rs({},e),{},{memo:void 0,uniqueIdentifier:void 0})),memos:null!==(n=e.memos)&&void 0!==n?n:o});if(1===(null===(r=s.memos)||void 0===r?void 0:r.length)&&s.spendTargets.length>=1){const[e]=s.memos;if(e.type===t.memoType){const[t]=s.spendTargets;t.memo=e.value,t.uniqueIdentifier=e.value,t.otherParams=Rs(Rs({},t.otherParams),{},{uniqueIdenfitifer:e.value})}}return s}function Bs(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Ks(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Bs(Object(n),!0).forEach(function(t){r(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Bs(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}const Us=async(e,t,n,r,o)=>{var i;e=Ls(e,t.currencyInfo);const a=Ji({allTokens:r,currencyInfo:t.currencyInfo,tokenId:e.tokenId}),s=null!==(i=t.currencyInfo.unsafeMakeSpend)&&void 0!==i&&i;if("function"==typeof n.getMaxSpendable){const t=s?o.keys:void 0;return await n.getMaxSpendable(Ks(Ks({},e),a),{privateKeys:t})}const{networkFeeOption:c,customNetworkFee:u}=e,l=n.getBalance(a),d=e.spendTargets.map(e=>Ks(Ks({},e),{},{nativeAmount:"0"}));return await function t(r,i){const l=(0,Vi.sub)(i,r);if((0,Vi.lte)(l,"1"))return Promise.resolve(r);const f=(0,Vi.add)(r,(0,Vi.div)(l,"2"));d[0].nativeAmount=f;const p=s?o.keys:void 0;return n.makeSpend(Ks(Ks({},a),{},{spendTargets:d,networkFeeOption:c,customNetworkFee:u,memos:e.memos,otherParams:e.otherParams}),{privateKeys:p}).then(()=>t(f,i)).catch(()=>t(r,f))}("0",(0,Vi.add)(l,"1"))};function Fs(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Ws(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Fs(Object(n),!0).forEach(function(t){r(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Fs(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}const Gs={bizId:0,category:"",exchangeAmount:{},name:"",notes:""};function zs(e,t,n,r,o){var i,a,s;const c=e.props.walletId,{accountId:u,currencyInfo:l,pluginId:d}=e.props.walletState,f=e.props.state.accounts[u].allTokens[d],{currencyCode:p}=null==r?l:f[r],h=l.currencyCode,y=null!=o?o:e.props.walletState.height,b=Ms(t.confirmations)?Cs(t,y,l.requiredConfirmations):t.confirmations,g={chainAction:t.chainAction,chainAssetAction:t.chainAssetAction.get(r),blockHeight:t.blockHeight,confirmations:b,currencyCode:p,feeRateUsed:t.feeRateUsed,date:t.date,isSend:t.isSend,memos:t.memos,metadata:{},nativeAmount:null!==(i=t.nativeAmount.get(r))&&void 0!==i?i:"0",networkFee:null!==(a=t.networkFee.get(r))&&void 0!==a?a:"0",networkFees:[],otherParams:Ws({},t.otherParams),ourReceiveAddresses:t.ourReceiveAddresses,parentNetworkFee:h===p?void 0:null!==(s=t.networkFee.get(null))&&void 0!==s?s:"0",signedTx:t.signedTx,tokenId:r,txid:t.txid,walletId:c};if(null!=n){var w,v,m,I,E,S,O,A,T;n.creationDate<g.date&&(g.date=n.creationDate),g.metadata=Ta(null!==(w=null!==(v=null===(m=n.tokens.get(null))||void 0===m?void 0:m.metadata)&&void 0!==v?v:null===(I=n.currencies.get(h))||void 0===I?void 0:I.metadata)&&void 0!==w?w:{},null!==(E=null!==(S=null===(O=n.tokens.get(r))||void 0===O?void 0:O.metadata)&&void 0!==S?S:null===(A=n.currencies.get(p))||void 0===A?void 0:A.metadata)&&void 0!==E?E:{}),null!=n.feeRateRequested&&("string"==typeof n.feeRateRequested?g.networkFeeOption=n.feeRateRequested:(g.networkFeeOption="custom",g.requestedCustomFee=n.feeRateRequested)),null==g.feeRateUsed&&(g.feeRateUsed=n.feeRateUsed),null!=n.payees&&(g.spendTargets=n.payees.map(e=>({currencyCode:e.currency,memo:e.tag,nativeAmount:e.amount,publicAddress:e.address,uniqueIdentifier:e.tag})));const e=null===(T=n.tokens.get(r))||void 0===T?void 0:T.assetAction;null!=e&&(g.assetAction=e),null!=n.savedAction&&(g.savedAction=n.savedAction),null!=n.swap&&(g.swapData=n.swap),null!=n.secret&&(g.txSecret=n.secret),null!=n.deviceDescription&&(g.deviceDescription=n.deviceDescription)}return g}function qs(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function $s(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?qs(Object(n),!0).forEach(function(t){r(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):qs(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}const Hs="Currency.json",Ys="fixedLegacyFileNames.json",Vs="EnabledTokens.json",Js="seenTxCheckpoint.json",Xs="Tokens.json",Zs="WalletName.json",Qs="WalletSettings.json",ec=_r(Ga),tc=_r(za),nc=_r(La),rc=_r(Wa),oc=_r($a),ic=_r(Ba),ac=_r(Fa),sc=_r(Ha),cc=_r(Ya),uc=_r(Ka);function lc(e,t,n,r){var o;const i=e.currency.wallets[t].fileNames,a=Oo(e,t,n),{creationDate:s=Math.min(r,Date.now()/1e3)}=null!==(o=i[a])&&void 0!==o?o:{},c=`${s.toFixed(0)}-${a}.json`;return{creationDate:s,fileName:c,txidHash:a}}async function dc(e){const{dispatch:t,state:n,walletId:r}=e.props,o=Eo(n,r),i=await sc.load(o,Hs);let a="iso:USD";if(null!=i)if(null!=i.fiat)a=i.fiat;else if(null!=i.num){const e=(0,mo.ai)(`000${i.num}`.slice(-3));null!=e&&(a=`iso:${e.code}`)}t({type:"CURRENCY_WALLET_FIAT_CHANGED",payload:{fiatCurrencyCode:a,walletId:r}})}async function fc(e){const{dispatch:t,state:n,walletId:r}=e.props,o=Eo(n,r),i=await cc.load(o,Zs);let a=null;if(null==i||null==i.walletName){const{appIds:t=[]}=e.props.walletState.walletInfo,n=t.find(e=>""!==e);if(null!=n){const{appName:t}=await Hi(Ou(e),n);a=t}}else a=i.walletName;t({type:"CURRENCY_WALLET_NAME_CHANGED",payload:{name:"string"==typeof a?a:null,walletId:r}})}async function pc(e){const{dispatch:t,state:n,walletId:r}=e.props,o=Eo(n,r),i=await ic.load(o,Xs);if(null!=i){const n=r.slice(0,2);return e.props.log.warn(`enabledTokenIds: ${n} loaded modern file`),void t({type:"CURRENCY_WALLET_LOADED_TOKEN_FILE",payload:$s({walletId:e.props.walletId},i)})}const a=await nc.load(o,Vs);if(null!=a){const{accountId:n,currencyInfo:o,pluginId:i}=e.props.walletState,s=e.props.state.accounts[n],c=function(e={},t={},n,r){const o=cs(e),i=cs(t),a=[];for(const c of r){var s;const e=null!==(s=i[c])&&void 0!==s?s:o[c];null!=e&&a.push(e)}return a}(s.builtinTokens[i],s.customTokens[i],0,a),u=r.slice(0,2);return e.props.log.warn(`enabledTokenIds: ${u} loaded legacy file`),void t({type:"CURRENCY_WALLET_LOADED_TOKEN_FILE",payload:{walletId:e.props.walletId,detectedTokenIds:[],enabledTokenIds:c}})}const s=r.slice(0,2);e.props.log.warn(`enabledTokenIds: ${s} loaded neither file`),t({type:"CURRENCY_WALLET_LOADED_TOKEN_FILE",payload:{walletId:e.props.walletId,detectedTokenIds:[],enabledTokenIds:[]}})}async function hc(e){var t;const{dispatch:n,state:r,walletId:o}=e.props,i=Eo(r,o),a=await uc.load(i,Qs);n({type:"CURRENCY_WALLET_LOADED_WALLET_SETTINGS_FILE",payload:{walletId:o,walletSettings:null!==(t=null==a?void 0:a.walletSettings)&&void 0!==t?t:{}}})}async function yc(e,t){await uc.save(e,Qs,{walletSettings:t})}async function bc(e,t){const{dispatch:n,walletId:r}=e.props,o=Eo(e.props.state,r),i=e.props.walletState.currencyInfo.currencyCode,a=e.props.walletState.fileNames,s=e.props.walletState.fiat,c={};return await Promise.all(t.map(async e=>{if(null==a[e])return;const t=`Transactions/${a[e].fileName}`,n=await rc.load(o,t);null!=n&&(c[e]=function(e,t,n){const r={creationDate:e.state.creationDate,currencies:new Map,tokens:new Map,internal:e.state.internal,txid:e.state.malleableTxId},o={};return o[n]=e.meta.amountCurrency,r.currencies.set(t,{metadata:{bizId:e.meta.bizId,category:e.meta.category,exchangeAmount:o,name:e.meta.name,notes:e.meta.notes},providerFeeSent:e.meta.amountFeeAirBitzSatoshi.toFixed()}),r}(n,i,s))})),await Promise.all(t.map(async e=>{if(null==a[e])return;const t=`transaction/${a[e].fileName}`,n=await ac.load(o,t);null!=n&&(c[e]=n)})),n({type:"CURRENCY_WALLET_FILES_LOADED",payload:{files:c,walletId:r}}),c}async function gc(e){const{dispatch:t,state:n,walletId:r}=e.props,o=Eo(n,r),i=await async function(e,t,n){var r;const o=So(e,t),i=null!==(r=await tc.load(o,Ys))&&void 0!==r?r:{},a=(0,re.WR)(await n.list()),s={},c=[];for(let l=0;l<a.length;l++){const e=a[l],t=i[e];if(null!=t){const{timestamp:n,txidHash:r}=t;s[r]={creationDate:n,fileName:e}}else c.push(e)}const u=c.map(async r=>{const o=await rc.load(n,r);if(null==o)return;const{creationDate:a,malleableTxId:c}=o.state,u=r,l=Oo(e,t,c);s[l]={creationDate:a,fileName:u},i[u]={timestamp:a,txidHash:l}});return u.length>0&&(await Promise.all(u),await tc.save(o,Ys,i).catch(()=>{})),s}(n,r,(0,re.my)(o,"Transactions")),a=await(0,re.my)(o,"transaction").list();for(const s of(0,re.WR)(a)){const e=s.split(".json")[0].split("-"),[t,n]=e,r=parseInt(t);(null==i[n]||r<i[n].creationDate)&&(i[n]={creationDate:r,fileName:s})}t({type:"CURRENCY_WALLET_FILE_NAMES_LOADED",payload:{txFileNames:i,walletId:r}})}async function wc(e){var t;const{state:n,walletId:r}=e.props,o=Eo(n,r),i=[],a=(0,re.WR)(await o.list("Addresses"));await Promise.all(a.map(async e=>{const t=await ec.load(o,e);null!=t&&(""===t.address||t.state.recycleable||i.push(t.address))}));const s=null===(t=e.props.walletOutput)||void 0===t?void 0:t.engine;null!=s&&await s.addGapLimitAddresses(i)}async function vc(e,t,n,r,o,i,a){var s,c;const{dispatch:u,state:l,walletId:d}=e.props,f=Eo(l,d),{accountId:p,currencyInfo:h,pluginId:y}=e.props.walletState,b=e.props.state.accounts[p].allTokens[y],{currencyCode:g}=null==n?h:b[n],w=e.props.walletState.txs[t];if(null==w)throw new Error(`Setting metatdata for missing tx ${t}`);const{creationDate:v,fileName:m,txidHash:I}=lc(l,d,w.txid,w.date),E=await ac.load(f,`transaction/${m}`),S=$s($s({},E),{},{creationDate:v,currencies:new Map(null!==(s=null==E?void 0:E.currencies)&&void 0!==s?s:[]),internal:!0,tokens:new Map(null!==(c=null==E?void 0:E.tokens)&&void 0!==c?c:[]),txid:t}),O=$s($s({metadata:{}},S.currencies.get(g)),S.tokens.get(n));var A;(S.tokens.set(n,O),S.currencies.delete(g),null!=o)&&(O.metadata=Ta(null!==(A=O.metadata)&&void 0!==A?A:{},o));null!=i&&(O.assetAction=i),null!=a&&(S.savedAction=a),u({type:"CURRENCY_WALLET_FILE_CHANGED",payload:{creationDate:v,fileName:m,json:S,txid:t,txidHash:I,walletId:d}}),await ac.save(f,"transaction/"+m,S);const T=zs(e,w,S,n);r.onTransactions([{isNew:!1,transaction:T}])}async function mc(e,t){var n;const{dispatch:r,state:o,walletId:i}=e.props,{creationDate:a,fileName:s,txidHash:c}=lc(o,i,t.txid,t.date),u={txid:t.txid,internal:!0,creationDate:a,currencies:new Map,feeRateUsed:t.feeRateUsed,tokens:new Map,savedAction:t.savedAction,swap:t.swapData};return u.tokens.set(t.tokenId,{assetAction:t.assetAction,metadata:null!==(n=t.metadata)&&void 0!==n?n:{},nativeAmount:t.nativeAmount}),null!=t.networkFeeOption&&(u.feeRateRequested="custom"===t.networkFeeOption?t.requestedCustomFee:t.networkFeeOption),null!=t.spendTargets&&(u.payees=t.spendTargets.map(e=>({currency:e.currencyCode,address:e.publicAddress,amount:e.nativeAmount,tag:e.memo})),null!=t.deviceDescription&&(u.deviceDescription=t.deviceDescription)),"string"==typeof t.txSecret&&(u.secret=t.txSecret),r({type:"CURRENCY_WALLET_FILE_CHANGED",payload:{creationDate:a,fileName:s,json:u,txid:t.txid,txidHash:c,walletId:i}}),{fileName:s,txFile:u}}async function Ic(e,t,n){var r;const{dispatch:o,state:i,walletId:a}=e.props,s=Eo(i,a),c=await oc.load(s,Js),u={checkpoint:t,subscribedAddresses:null!==(r=null!=n?n:(null!=c?c:{checkpoint:void 0,subscribedAddresses:[]}).subscribedAddresses)&&void 0!==r?r:[]};null!=t&&o({type:"CURRENCY_ENGINE_SEEN_TX_CHECKPOINT_CHANGED",payload:{checkpoint:t,walletId:a}}),await oc.save(s,Js,u)}async function Ec(e,t,n){const{stashTree:r}=xn(e,t.loginId),{deviceDescription:o}=e.props.state.login.deviceInfo,i=nr(r,t);null!=o&&(i.deviceDescription=o),i.data=vt(n);const a=await In(e,"POST","/v2/login/vouchers",i),s=Hn(r,t.loginKey,Qe(a));return await jn(e,s)}function Sc(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(-1!==t.indexOf(r))continue;n[r]=e[r]}return n}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],-1===t.indexOf(n)&&{}.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}const Oc=["fromWallet","toWallet"];function Ac(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Tc(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Ac(Object(n),!0).forEach(function(t){r(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ac(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}async function _c(e,t,n,r={}){const{disabled:o={},noResponseMs:i,preferPluginId:a,promoCodes:s={},slowResponseMs:c=2e4}=r,{log:u,state:l}=e.props,d=l.accounts[t],{swapSettings:f,userSettings:p}=d,h=l.plugins.swap;u.warn("Requesting swap quotes for: ",Tc(Tc({},n),{},{fromWallet:n.fromWallet.id,toWallet:n.toWallet.id}),{preferPluginId:a,promoCodes:s});const y=new Set,b=[];for(const m of Object.keys(h)){var g,w;const{enabled:e=!0}=null!=f[m]?f[m]:{};e&&!o[m]&&(y.add(m),b.push(h[m].fetchSwapQuote(n,p[m],{infoPayload:null!==(g=null===(w=l.infoCache.corePlugins)||void 0===w?void 0:w[m])&&void 0!==g?g:{},promoCode:s[m]}).then(e=>{var t;Xi(e);const n=null!==(t=e.request)&&void 0!==t?t:{},{fromWallet:r,toWallet:o}=n,i=Sc(n,Oc),a=Tc(Tc({},e),{},{request:i});return y.delete(m),u.warn(`${m} gave swap quote:`,a),e},e=>{throw y.delete(m),u.warn(`${m} gave swap error: ${String(e)}`),xc(e)&&u.crash(`Unknown swap error: ${String(e)}`,{error:e,swapPluginId:m,request:{fromToken:String(n.fromTokenId),fromWalletType:n.fromWallet.type,toToken:String(n.toTokenId),toWalletType:n.toWallet.type,quoteFor:n.quoteFor}}),e})))}const v=function(e,t){return new Promise((n,r)=>{let o=!1;const i=[],a=[];let s=setTimeout(()=>{s=void 0,i.length>0&&(o=!0,n({results:i,errors:a}))},t);function c(){const t=i.length+a.length===e.length;t&&null!=s&&clearTimeout(s),(t||null==s&&i.length>0)&&(o=!0,i.length>0?n({results:i,errors:a}):r(a))}c();for(const t of e)t.then(e=>{o||(i.push(e),c())},e=>{o||(a.push(e),c())})})}(b,c).then(({results:e,errors:t})=>{for(const n of y)u.warn(`${n} gave swap timeout`);const o=function(e,t){const{preferPluginId:n,preferType:r,promoCodes:o}=t;return e.sort((e,t)=>{if("transfer"===e.pluginId)return-1;if("transfer"===t.pluginId)return 1;if(e.pluginId===n)return-1;if(t.pluginId===n)return 1;if(null!=r){const n=!0===e.swapInfo.isDex&&"DEX"===r||!0!==e.swapInfo.isDex&&"CEX"===r,o=!0===t.swapInfo.isDex&&"DEX"===r||!0!==t.swapInfo.isDex&&"CEX"===r;if(n&&!o)return-1;if(!n&&o)return 1}if(null!=o){const n=null!=o[e.pluginId],r=null!=o[t.pluginId];if(n&&!r)return-1;if(!n&&r)return 1}const{isEstimate:i=!0}=e,{isEstimate:a=!0}=t;if(!i&&a)return-1;if(i&&!a)return 1;const s=Number(e.toNativeAmount)/Number(e.fromNativeAmount),c=Number(t.toNativeAmount)/Number(t.fromNativeAmount);return s>c?-1:c>s?1:0})}(e,r);return u.warn(`${b.length} swap quotes requested, ${e.length} resolved, ${t.length} failed, sorted ${o.map(e=>e.pluginId).join(", ")}.`),e.map(e=>function(e,t,n){var r,o;const i=P({canBePartial:n.canBePartial,expirationDate:n.expirationDate,fromNativeAmount:n.fromNativeAmount,isEstimate:n.isEstimate,maxFulfillmentSeconds:n.maxFulfillmentSeconds,networkFee:n.networkFee,pluginId:n.pluginId,request:null!==(r=n.request)&&void 0!==r?r:t,swapInfo:null!==(o=n.swapInfo)&&void 0!==o?o:e[n.pluginId].swapInfo,toNativeAmount:n.toNativeAmount,minReceiveAmount:n.minReceiveAmount,async approve(e){return await n.approve(e)},async close(){await n.close(),F(i)}});return i}(h,n,e))},e=>{throw u.warn(`All ${b.length} swap quotes rejected.`),function(e){return e.reduce((e,t)=>{const n=kc(e)-kc(t);if(n>0)return e;if(n<0)return t;const r=Qt(e),o=Qt(t);if(null!=r&&null!=o)return(0,Vi.lt)(r.nativeMin,o.nativeMin)?r:o;const i=Zt(e),a=Zt(t);return null!=i&&null!=a?(0,Vi.gt)(i.nativeMax,a.nativeMax)?i:a:e})}(e)});return null==i?await v:await wn(v,i)}function kc(e){return null==e?0:null!=Ht(e)||null!=Xt(e)?6:null!=Qt(e)?5:null!=Zt(e)?4:null!=nn(e)?3.5:null!=tn(e)?3:null!=en(e)?2:1}function xc(e){return!(kc(e)>1)}const Pc=_r(we({name:pe})),Mc=_r(we({key:pe,data:pe}));function Cc(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Nc(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Cc(Object(n),!0).forEach(function(t){r(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Cc(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}let jc=0;const Dc=async(e,t,n,r={})=>{var o;const{keys:i,walletSettings:a={}}=r;if(null==i)throw new Error("No keys provided");const s="memorywallet-"+jc++,c={id:s,type:n,keys:i},u=await no(e,t.currencyInfo.pluginId),l=await u.derivePublicKey(c);c.keys=Nc(Nc({},l),c.keys);const d=Lr(e.props.logBackend,`${s}-${n}`);let f=new Map,p=[],h={totalRatio:0},y=!1;const b=Zr(async()=>{await Qr(1e3),y&&(G(T),y=!1)},0),g=e.props.state.plugins.currency[t.currencyInfo.pluginId],w={onAddressChanged:()=>{},onAddressesChecked(e){w.onSyncStatusChanged({totalRatio:e})},onNewTokens:e=>{const t=e.sort((e,t)=>e.localeCompare(t));if(p.length!==t.length)return p=t,void(y=!0);for(let n=0;n<t.length;n++)if(p[n]!==t[n])return p=t,void(y=!0)},onSeenTxCheckpoint:()=>{},onStakingStatusChanged:()=>{},onSubscribeAddresses:()=>{},onSyncStatusChanged(e){1!==h.totalRatio&&1===e.totalRatio&&(h=e,y=!0)},onTokenBalanceChanged:(e,t)=>{f.get(e)!==t&&(f=new Map(f),f.set(e,t),y=!0)},onTransactions:()=>{},onTransactionsChanged:()=>{},onTxidsChanged:()=>{},onUnactivatedTokenIdsChanged:()=>{},onWcNewContractCall:()=>{},onBlockHeightChanged:()=>{},onBalanceChanged:()=>{}},v=await g.makeCurrencyEngine(c,{callbacks:w,customTokens:Nc({},t.customTokens),enabledTokenIds:[...Object.keys(t.allTokens)],lightMode:!0,log:d,userSettings:Nc({},null!==(o=t.userSettings)&&void 0!==o?o:{}),walletSettings:a,walletLocalDisklet:(0,re.cQ)(),walletLocalEncryptedDisklet:(0,re.cQ)()}),{unsafeBroadcastTx:m=!1,unsafeMakeSpend:I=!1,unsafeSyncNetwork:E=!1}=g.currencyInfo,S=Nc({},i);let O;if(null!=v.syncNetwork){const t=async()=>{if(null!=v.syncNetwork){const e=await v.syncNetwork({privateKeys:E?S:void 0});O.setDelay(e)}else O.stop()};O=Zr(t,1e4,{onError:t=>{e.props.log.error(t)}}),O.start({wait:!1})}const A={};if(null!=v.otherMethods)for(const _ of Object.keys(v.otherMethods)){const e=v.otherMethods[_];"function"==typeof e&&(A[_]=e)}if(null!=v.otherMethodsWithKeys)for(const _ of Object.keys(v.otherMethodsWithKeys)){const e=v.otherMethodsWithKeys[_];"function"==typeof e&&(A[_]=(...t)=>e(c.keys,...t))}P(A);const T=P({watch:ee,get balanceMap(){return f},get detectedTokenIds(){return p},get syncRatio(){return h.totalRatio},get syncStatus(){return h},async changeEnabledTokenIds(e){null!=v.changeEnabledTokenIds&&await v.changeEnabledTokenIds(e)},async startEngine(){var e;await v.startEngine(),null===(e=O)||void 0===e||e.start({wait:!1})},async getMaxSpendable(e){return await Us(e,g,v,t.allTokens,c)},async makeSpend(e){return await v.makeSpend(e,I?S:void 0)},async signTx(e){return await v.signTx(e,S)},async broadcastTx(e){return await v.broadcastTx(e,m?S:void 0)},async saveTx(){},otherMethods:A,async close(){var e;d.warn("killing memory wallet"),null===(e=O)||void 0===e||e.stop(),F(T),await v.killEngine()}});return b.start({wait:!1}),T};function Rc(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Lc(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Rc(Object(n),!0).forEach(function(t){r(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Rc(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}const Bc={},Kc=[];class Uc extends te{constructor(e,t,n){super(),this._ai=e,this._accountId=t,this._pluginId=n;const{otherMethods:r}=e.props.state.plugins.currency[n];null!=r?(P(r),this.otherMethods=r):this.otherMethods={}}get currencyInfo(){return this._ai.props.state.plugins.currency[this._pluginId].currencyInfo}get allTokens(){const{state:e}=this._ai.props,{_accountId:t,_pluginId:n}=this;return e.accounts[t].allTokens[n]}get builtinTokens(){const{state:e}=this._ai.props,{_accountId:t,_pluginId:n}=this;return e.accounts[t].builtinTokens[n]}get customTokens(){var e;const{state:t}=this._ai.props,{_accountId:n,_pluginId:r}=this;return null!==(e=t.accounts[n].customTokens[r])&&void 0!==e?e:Bc}async getTokenDetails(e){const{_ai:t,_pluginId:n}=this,r=await no(t,n);return null==r.getTokenDetails?[]:await r.getTokenDetails(e)}async getTokenId(e){const{_ai:t,_pluginId:n}=this;return await ia(t,n,e)}async addCustomToken(e){const{_accountId:t,_ai:n,_pluginId:r}=this,o=await ia(n,r,e);return n.props.dispatch({type:"ACCOUNT_CUSTOM_TOKEN_ADDED",payload:{accountId:t,pluginId:r,tokenId:o,token:e}}),o}async changeCustomToken(e,t){const{_accountId:n,_ai:r,_pluginId:o}=this;if(null==r.props.state.accounts[n].customTokens[o][e])throw new Error(`There is no token with id "${e}"`);const i=await ia(r,o,t);if(r.props.dispatch({type:"ACCOUNT_CUSTOM_TOKEN_ADDED",payload:{accountId:n,pluginId:o,tokenId:i,token:t}}),i!==e){const{wallets:t}=r.props.state.currency;for(const a of Object.keys(t)){const s=t[a];if(s.accountId!==n||s.pluginId!==o||!s.enabledTokenIds.includes(e))continue;const c=a.slice(0,2);r.props.log.warn(`enabledTokenIds: ${c} changeCustomToken edited id`),r.props.dispatch({type:"CURRENCY_WALLET_ENABLED_TOKENS_CHANGED",payload:{walletId:a,enabledTokenIds:ls([...s.enabledTokenIds,i],[e])}})}r.props.dispatch({type:"ACCOUNT_CUSTOM_TOKEN_REMOVED",payload:{accountId:n,pluginId:o,tokenId:e}})}}async removeCustomToken(e){const{_accountId:t,_ai:n,_pluginId:r}=this;n.props.dispatch({type:"ACCOUNT_CUSTOM_TOKEN_REMOVED",payload:{accountId:t,pluginId:r,tokenId:e}})}get alwaysEnabledTokenIds(){var e;const{state:t}=this._ai.props,{_accountId:n,_pluginId:r}=this;return null!==(e=t.accounts[n].alwaysEnabledTokenIds[r])&&void 0!==e?e:Kc}async changeAlwaysEnabledTokenIds(e){const{_accountId:t,_ai:n,_pluginId:r}=this;n.props.dispatch({type:"ACCOUNT_ALWAYS_ENABLED_TOKENS_CHANGED",payload:{accountId:t,pluginId:r,tokenIds:e}})}get userSettings(){return this._ai.props.state.accounts[this._accountId].userSettings[this._pluginId]}async changeUserSettings(e){await Go(this._ai,this._accountId,this._pluginId,e)}async importKey(e,t={}){const n=await no(this._ai,this._pluginId);if(null==n.importPrivateKey)throw new Error("This wallet does not support importing keys");return Lc(Lc({},await n.importPrivateKey(e,t.keyOptions)),{},{imported:!0})}}class Fc extends te{constructor(e,t,n){super(),this._ai=e,this._accountId=t,this._pluginId=n}get enabled(){const{swapSettings:e}=this._ai.props.state.accounts[this._accountId],{enabled:t=!0}=null!=e[this._pluginId]?e[this._pluginId]:{};return t}get needsActivation(){var e,t;const n=this._ai.props.state.plugins.swap[this._pluginId];if(null==n.checkSettings)return!1;const r=null!==(e=this._ai.props.state.accounts[this._accountId].userSettings[this._pluginId])&&void 0!==e?e:{};return null!==(t=n.checkSettings(r).needsActivation)&&void 0!==t&&t}get swapInfo(){return this._ai.props.state.plugins.swap[this._pluginId].swapInfo}get userSettings(){return this._ai.props.state.accounts[this._accountId].userSettings[this._pluginId]}async changeEnabled(e){const t=this._ai.props.state.accounts[this._accountId];return await async function(e,t,n,r){var o;const{accountWalletInfo:i}=e.props.state.accounts[t],a=Eo(e.props.state,i.id),s=null!==(o=await Lo.load(a,Ko))&&void 0!==o?o:Bo;await Lo.save(a,Ko,jo(jo({},s),{},{swapSettings:jo(jo({},e.props.state.accounts[t].swapSettings),{},{[n]:r})})),e.props.dispatch({type:"ACCOUNT_SWAP_SETTINGS_CHANGED",payload:{accountId:t,pluginId:n,swapSettings:r}})}(this._ai,this._accountId,this._pluginId,Lc(Lc({},t.swapSettings[this._pluginId]),{},{enabled:e}))}async changeUserSettings(e){await Go(this._ai,this._accountId,this._pluginId,e)}}async function Wc(e,t,n){const{currency:r}=e.props.state.plugins,o=eo(r,t.type),{hasWalletSettings:i=!1}=r[o].currencyInfo;if(!i)return;const{io:a}=e.props,s=ro(t.keys),{disklet:c}=uo(a,s);await yc(c,n)}function Gc(e,t){let n=e.props.state.accounts[t];const r=()=>{const r=e.props.state.accounts[t];return null!=r&&(n=r),n},{accountWalletInfo:o,loginType:i}=r(),a={};for(const p of Object.keys(e.props.state.plugins.currency)){const n=new Uc(e,t,p);a[p]=n}const s={};for(const p of Object.keys(e.props.state.plugins.swap)){const n=new Fc(e,t,p);s[p]=n}const c=function(e,t){const{accountWalletInfo:n}=e.props.state.accounts[t],r=Eo(e.props.state,n.id),o=t=>Oo(e.props.state,n.id,t),i=e=>`Plugins/${o(e)}`,a=(e,t)=>`${i(e)}/${o(t)}.json`,s={async deleteItem(e,t){await r.delete(a(e,t))},async deleteStore(e){await r.delete(i(e))},async listItemIds(e){const t=[],n=(0,re.WR)(await r.list(i(e)));return await Promise.all(n.map(async e=>{const n=await Mc.load(r,e);null!=n&&t.push(n.key)})),t},async listStoreIds(){const e=[],t=(0,re.a8)(await r.list("Plugins"));return await Promise.all(t.map(async t=>{const n=await Pc.load(r,`${t}/Name.json`);null!=n&&e.push(n.name)})),e},async getItem(e,t){const n=await Mc.load(r,a(e,t));if(null==n)throw new Error(`No item named "${t}"`);return n.data},async setItem(e,t,n){const o=`${i(e)}/Name.json`,s=await Pc.load(r,o);if(null==s)await Pc.save(r,o,{name:e});else if(s.name!==e)throw new Error(`Warning: folder name doesn't match for ${e}`);await Mc.save(r,a(e,t),{key:t,data:n})}};return P(s),s}(e,t),u=ga(e,o);function l(){if(e.props.state.hideKeys)throw new Error("Not available when `hideKeys` is enabled")}let d=!1;const f={on:Q,watch:ee,get id(){return u.id},get type(){return u.type},get disklet(){return l(),u.disklet},get localDisklet(){return l(),u.localDisklet},async sync(){await u.sync()},get appId(){return r().login.appId},get created(){return r().login.created},async getLoginKey(){return l(),Lt.stringify(r().login.loginKey)},get lastLogin(){return r().login.lastLogin},get loggedIn(){return null!=e.props.state.accounts[t]},get recoveryKey(){l();const{login:e}=r();return null!=e.recovery2Key?Lt.stringify(e.recovery2Key):void 0},get rootLoginId(){l();const{loginTree:e}=r();return Lt.stringify(e.loginId)},get username(){const{loginTree:e}=r();return e.username},get canDuressLogin(){const{activeAppId:t}=r();if(e.props.state.clientInfo.duressEnabled)return d;const n=t.endsWith(".duress")?t:t+".duress",o=zn(r().loginTree,e=>e.appId===n);return null!=(null==o?void 0:o.pin2Key)},get isDuressAccount(){const{activeAppId:e}=r();return e.endsWith(".duress")},get currencyConfig(){return a},get swapConfig(){return s},get dataStore(){return c},get edgeLogin(){const{loginTree:e}=r();return null==e.loginKey},keyLogin:"keyLogin"===i,newAccount:"newAccount"===i,passwordLogin:"passwordLogin"===i,pinLogin:"pinLogin"===i,recoveryLogin:"recoveryLogin"===i,async changePassword(n){l(),this.isDuressAccount||await async function(e,t,n){const r=e.props.state.accounts[t],{loginTree:o,sessionKey:i}=r,{username:a}=r.stashTree;if(null==a)throw new Error("Password login requires a username");const s=await ui(e,o,a,n);await Zn(e,i,s)}(e,t,n)},async changePin(n){l(),e.props.log.breadcrumb("EdgeAccount.changePin",{});const{forDuressAccount:o=!1}=n,{activeAppId:i}=r(),a=i.endsWith(".duress")?i:i+".duress";var s;if(this.isDuressAccount&&o)return d=null!==(s=n.enableLogin)&&void 0!==s?s:null!=n.pin,e.props.dispatch({type:"UPDATE_NEXT"}),"";o&&await Mi(e,r().stashTree,r().sessionKey,a),await hi(e,t,n);const c=o?zn(r().login,e=>e.appId===a):r().login;if(null==c)throw new Error("Failed to find account.");return null!=c.pin2Key?Lt.stringify(c.pin2Key):""},async changeRecovery(n,o){if(l(),this.isDuressAccount)return"1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa";await Ii(e,t,n,o);const{loginTree:i}=r();if(null==i.recovery2Key)throw new Error("Missing recoveryKey");return Lt.stringify(i.recovery2Key)},async changeUsername(n){l(),n.username=ae(n.username),await async function(e,t,n){const{loginTree:r}=e.props.state.accounts[t],o=await Promise.all(function t(r){const o=[Ti(e,r,n)];for(const e of r.children)o.push(...t(e));return o}(r));await Qn(e,r,o)}(e,t,n)},async checkPassword(t){l();const{loginTree:n,stashTree:o}=r(),{loginKey:i}=n;return await async function(e,t,n,r){if(null!=r){const{passwordAuthBox:o,username:i}=t;if(null==o||null==i)return!1;const a=dn(o,r),s=si(i,n),c=await An(e,s,ai);for(let e=0;e<a.length;++e)if(c[e]!==a[e])return!1;return!0}{const{passwordBox:r,passwordKeySnrp:i,username:a}=t;if(null==r||null==i||null==a)throw new Error("Missing data for offline password login");const s=si(a,n),c=await An(e,s,i);try{return dn(r,c),!0}catch(o){return!1}}}(e,o,t,i)},async checkPin(t,n={}){l();const{login:o,loginTree:i}=r();return null!=o.pin&&null==n.forDuressAccount?t===o.pin:await async function(e,t,n,r){const{loginId:o,username:i}=t;if(null==i)return!1;const a=!0===r?t.appId+".duress":t.appId;if(e.props.state.clientInfo.duressEnabled)return!1;const{stashTree:s}=xn(e,o),c=!0===r?Ln(s,a):fi(s,a);if(null==c||null==c.pin2Key)throw new zt("No PIN set locally for this account");const{pin2Key:u}=c,l={pin2Id:li(u,i),pin2Auth:di(u,n),otp:Un(t)};return await In(e,"POST","/v2/login",l).then(e=>!0,e=>!1)}(e,i,t,n.forDuressAccount)},async getPin(){var e;const{login:t,loginTree:n}=r();return null!==(e=t.pin)&&void 0!==e?e:n.pin},async deletePassword(){l(),await async function(e,t){const{loginTree:n,sessionKey:r}=e.props.state.accounts[t],o={loginId:n.loginId,server:void 0,serverMethod:"DELETE",serverPath:"/v2/login/password",stash:{passwordAuthSnrp:void 0,passwordBox:void 0,passwordKeySnrp:void 0}};null!=n.loginAuth&&(o.stash.passwordAuthBox=void 0),await Zn(e,r,o)}(e,t)},async deletePin(){l();const n=e.props.state.clientInfo.duressEnabled;await async function(e,t,n){const{loginTree:r}=e.props.state.accounts[t],o=wi(r,n);await Qn(e,r,o)}(e,t,n)},async deleteRecovery(){l(),await async function(e,t){const{loginTree:n,sessionKey:r}=e.props.state.accounts[t],o={login:{recovery2Key:void 0},loginId:n.loginId,server:void 0,serverMethod:"DELETE",serverPath:"/v2/login/recovery2",stash:{recovery2Key:void 0}};await Zn(e,r,o)}(e,t)},get otpKey(){l();const{loginTree:e}=r();return null!=e.otpKey?b(e.otpKey,{pad:!1}):void 0},get otpResetDate(){l();const{loginTree:e}=r();return e.otpResetDate},async cancelOtpReset(){l(),await async function(e,t){const{loginTree:n,sessionKey:r}=e.props.state.accounts[t],{otpTimeout:o,otpKey:i}=n;if(null==o||null==i)throw new Error("Cannot cancel 2FA reset: 2FA is not enabled.");const a={loginId:n.loginId,server:dt({otpTimeout:o,otpKey:i}),serverPath:"/v2/login/otp",stash:{otpResetDate:void 0}};await Zn(e,r,a)}(e,t)},async enableOtp(n=604800){if(l(),this.isDuressAccount)return await async function(e,t){const{stashTree:n}=e.props.state.accounts[t],r=e.props.io.random(10);await jn(e,Kn(Kn({},n),{},{otpKey:r}))}(e,t);await async function(e,t,n){const{loginTree:r,sessionKey:o}=e.props.state.accounts[t],{otpKey:i=e.props.io.random(10)}=r,a={loginId:r.loginId,server:dt({otpKey:i,otpTimeout:n}),serverPath:"/v2/login/otp",stash:{otpKey:i,otpResetDate:void 0,otpTimeout:n}};await Zn(e,o,a)}(e,t,n)},async disableOtp(){if(l(),this.isDuressAccount)return await async function(e,t){const{stashTree:n}=e.props.state.accounts[t];await jn(e,Kn(Kn({},n),{},{otpKey:void 0}))}(e,t);await async function(e,t){const{loginTree:n,sessionKey:r}=e.props.state.accounts[t],o={loginId:n.loginId,server:void 0,serverMethod:"DELETE",serverPath:"/v2/login/otp",stash:{otpKey:void 0,otpResetDate:void 0,otpTimeout:void 0}};await Zn(e,r,o)}(e,t)},async repairOtp(n){l(),await async function(e,t,n){if(null==e.props.state.accounts[t])return;const{login:r}=e.props.state.accounts[t],{userId:o,passwordAuth:i}=r,{stashTree:a,stash:s}=xn(e,r.loginId);if(null==i||null==o)throw new Error("Cannot repair OTP: There is no password on this account");const c={userId:o,passwordAuth:i,otp:yn(n)},u={now:a.lastLogin};await Xn(e,a,s,u,c,async()=>r.loginKey)}(e,t,y(n,{loose:!0}))},get pendingVouchers(){const{login:e}=r();return e.pendingVouchers},async approveVoucher(t){const{loginTree:n}=r();return await Ec(e,n,{approvedVouchers:[t]})},async rejectVoucher(t){const{loginTree:n}=r();return await Ec(e,n,{rejectedVouchers:[t]})},async fetchLobby(n){return e.props.log.breadcrumb("EdgeAccount.fetchLobby",{}),l(),await Yi(e,t,n)},async deleteRemoteAccount(){const{loginTree:t}=r();this.isDuressAccount||await async function(e,t){const{stashTree:n}=xn(e,t.loginId),{deviceDescription:r}=e.props.state.login.deviceInfo,o=nr(n,t);null!=r&&(o.deviceDescription=r),await In(e,"POST","/v2/login/delete",o)}(e,t)},async logout(){e.props.dispatch({type:"LOGOUT",payload:{accountId:t}})},get allKeys(){return e.props.state.accounts[t].allWalletInfosClean},async changeWalletStates(n){await Wo(e,t,n)},async createWallet(t,n){const{login:o,sessionKey:i,stashTree:a}=r();e.props.log.breadcrumb("EdgeAccount.createWallet",{});const s=await oi(e,t,{keys:n}),c=tr(a,i,o.loginId);return await Zn(e,i,ei(e,c,[s])),s.id},getFirstWalletInfo:oe.prototype.getFirstWalletInfo,getWalletInfo:oe.prototype.getWalletInfo,listWalletIds:oe.prototype.listWalletIds,async splitWalletInfo(n,o){var i,a;const{allWalletInfosFull:s}=r(),c=s.find(e=>e.id===n);if(null==c)throw new Error(`Invalid wallet id ${n}`);const u=null===(i=e.props.output)||void 0===i||null===(i=i.currency)||void 0===i||null===(i=i.wallets[c.id])||void 0===i?void 0:i.walletApi;if("wallet:bitcoin"===c.type&&"bip49"===c.keys.format&&"wallet:bitcoincash"===o)throw new Error("Cannot split segwit-format Bitcoin wallets to Bitcoin Cash");const[l]=await ya(e,t,c,[{walletType:o,name:null!==(a=null==u?void 0:u.name)&&void 0!==a?a:void 0,fiatCurrencyCode:null==u?void 0:u.fiatCurrencyCode}],!0);if(l.ok)return l.result.id;throw l.error},async listSplittableWalletTypes(n){return await async function(e,t,n){const{allWalletInfosFull:r}=e.props.state.accounts[t],o=r.find(e=>e.id===n);if(null==o)throw new Error(`Invalid wallet id ${n}`);const i=to(e.props.state.plugins.currency,o.type);if(null==i)return[];const a=await no(e,i);return null==a.getSplittableTypes?[]:(await a.getSplittableTypes(o)).filter(e=>{const t=ha(o,e),n=r.find(e=>e.id===t.id);return null==n||n.archived||n.deleted})}(e,t,n)},async getDisplayPrivateKey(n){const r=zc(e,t,n),o=eo(e.props.state.plugins.currency,r.type),i=await no(e,o);if(null!=i.getDisplayPrivateKey)return await i.getDisplayPrivateKey(r);const{engine:a}=e.props.output.currency.wallets[n];if(null==a||null==a.getDisplayPrivateSeed)throw new Error("Wallet has not yet loaded");const s=await a.getDisplayPrivateSeed(r.keys);if(null==s)throw new Error("The engine failed to return a key");return s},async getDisplayPublicKey(n){const r=zc(e,t,n),o=eo(e.props.state.plugins.currency,r.type),i=await no(e,o);if(null!=i.getDisplayPublicKey){const t=co(e.props.io,n),o=await Ts(r,t,i);return await i.getDisplayPublicKey(o)}const{engine:a}=e.props.output.currency.wallets[n];if(null==a||null==a.getDisplayPublicSeed)throw new Error("Wallet has not yet loaded");const s=await a.getDisplayPublicSeed();if(null==s)throw new Error("The engine failed to return a key");return s},async getRawPrivateKey(n){return zc(e,t,n).keys},async getRawPublicKey(n){const r=zc(e,t,n),o=eo(e.props.state.plugins.currency,r.type),i=await no(e,o),a=co(e.props.io,n);return(await Ts(r,a,i)).keys},get activeWalletIds(){return e.props.state.accounts[t].activeWalletIds},get archivedWalletIds(){return e.props.state.accounts[t].archivedWalletIds},get hiddenWalletIds(){return e.props.state.accounts[t].hiddenWalletIds},get currencyWallets(){return e.props.output.accounts[t].currencyWallets},get currencyWalletErrors(){return e.props.state.accounts[t].currencyWalletErrors},async createCurrencyWallet(n,o={}){const{login:i,sessionKey:a,stashTree:s}=r();e.props.log.breadcrumb("EdgeAccount.createCurrencyWallet",{});const c=await oi(e,n,o);null!=o.walletSettings&&await Wc(e,c,o.walletSettings);const u=tr(s,a,i.loginId);return await Zn(e,a,ei(e,u,[c])),await ii(e,t,c.id,o)},async makeMemoryWallet(t,n={}){const r=Object.values(a).find(e=>e.currencyInfo.walletType===t);if(null==r)throw new Error("Invalid walletType");return await Dc(e,r,t,n)},async createCurrencyWallets(n){const{login:o,sessionKey:i,stashTree:a}=r();e.props.log.breadcrumb("EdgeAccount.makeMemoryWallet",{});const s=await Promise.all(n.map(async t=>await oi(e,t.walletType,t)));for(let t=0;t<s.length;t++){const{walletSettings:r}=n[t];null!=r&&await Wc(e,s[t],r)}const c=tr(a,i,o.loginId);return await Zn(e,i,ei(e,c,s)),await Promise.all(s.map(async(r,o)=>await vo(ii(e,t,r.id,n[o]))))},async waitForCurrencyWallet(e){return await new Promise((t,n)=>{const r=()=>{const r=this.currencyWallets[e];null!=r&&(t(r),o());const i=this.currencyWalletErrors[e];null!=i&&(n(i),o())},o=()=>{for(const e of i)e()},i=[this.watch("currencyWallets",r),this.watch("currencyWalletErrors",r)];r()})},async waitForAllWallets(){return await new Promise((e,t)=>{const n=()=>{if(null==this.activeWalletIds.find(e=>null==this.currencyWallets[e]&&null==this.currencyWalletErrors[e])){for(const e of r)e();e()}},r=[this.watch("activeWalletIds",n),this.watch("currencyWallets",n),this.watch("currencyWalletErrors",n)];n()})},async getActivationAssets({activateWalletId:n,activateTokenIds:r}){const{currencyWallets:o}=e.props.output.accounts[t],i=e.props.output.currency.wallets[n],{engine:a}=i;if(null==a)throw new Error(`Invalid wallet: ${n} not found`);if(null==a.engineGetActivationAssets)throw new Error(`getActivationAssets unsupported by walletId ${n}`);const s=await a.engineGetActivationAssets({currencyWallets:o,activateTokenIds:r});return s.assetOptions.forEach(e=>{var t;return e.tokenId=null!==(t=e.tokenId)&&void 0!==t?t:null}),s},async activateWallet(n){var r;const{activateWalletId:o,activateTokenIds:i,paymentInfo:a}=n,{currencyWallets:s}=e.props.output.accounts[t],c=e.props.output.currency.wallets[o],{engine:u}=c;if(null==u)throw new Error(`Invalid wallet: ${o} not found`);if(null==u.engineActivateWallet)throw new Error(`activateWallet unsupported by walletId ${o}`);const l=null!==(r=null==a?void 0:a.walletId)&&void 0!==r?r:"",d=s[l];if(null==d)throw new Error(`No wallet for walletId ${l}`);const f=await u.engineActivateWallet({activateTokenIds:i,paymentInfo:null!=a?{wallet:d,tokenId:a.tokenId}:void 0,paymentTokenId:null==a?void 0:a.tokenId,paymentWallet:d});return void 0===f.networkFee.tokenId&&(f.networkFee.tokenId=null),P(f)},async fetchSwapQuote(n,r){const[o,...i]=await _c(e,t,n,r);for(const e of i)e.close().catch(()=>{});if(null==o)throw new Error("No swap providers enabled");return o},async fetchSwapQuotes(n,r){return await _c(e,t,n,r)}};return P(f),f}function zc(e,t,n){const r=e.props.state.accounts[t].allWalletInfosFull.find(e=>e.id===n);if(null==r)throw new Error(`Invalid wallet: ${n} not found`);return r}function qc(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}function $c(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Hc(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?$c(Object(n),!0).forEach(function(t){r(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):$c(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}const Yc={},Vc={loginId:new Uint8Array,loginKey:new Uint8Array},Jc=es({accountWalletInfo:ss(e=>e.self.activeAppId,e=>e.self.allWalletInfosFull,(e,t)=>{const n=Zo(e),r=Xo(t,n);if(null==r)throw new Error(`Cannot find a "${n}" repo`);return r}),accountWalletInfos:ss(e=>e.self.activeAppId,e=>e.self.allWalletInfosFull,(e,t)=>{const n=[Zo(e)];return""===e&&n.push("account:repo:co.airbitz.wallet",""),t.filter(e=>n.includes(e.type))}),allWalletInfosFull:ss(e=>e.self.stashTree,e=>e.self.login,e=>e.self.legacyWalletInfos,e=>e.self.walletStates,(e,t,n,r)=>function(e,t,n,r){const o=new Map,i=new Map,a=[...n],s=Pn(e,t.loginId);for(const c of n){a.push(c);const e=i.get(c.id);null!=e?e.push(s.appId):i.set(c.id,[s.appId])}return function e(t,n){const r=ni(t,n,o);for(const o of r){a.push(o);const e=i.get(o.id);null!=e?e.push(t.appId):i.set(o.id,[t.appId])}for(const o of null!==(s=t.children)&&void 0!==s?s:[]){var s;null!=o.parentBox&&e(o,dn(o.parentBox,n))}}(s,t.loginKey),ti(a).map(e=>{var t,n,s;return Jo(Jo({appId:(s=null!==(t=i.get(e.id))&&void 0!==t?t:[],s[s.length-1]),appIds:null!==(n=i.get(e.id))&&void 0!==n?n:[],archived:!1,created:o.get(e.id),deleted:!1,hidden:!1,sortIndex:a.length,imported:e.keys.imported},r[e.id]),e)})}(e,t,n,r)),allWalletInfosClean:ss(e=>e.self.allWalletInfosFull,e=>e.map(e=>Hc(Hc({},e),{},{keys:{}}))),currencyWalletErrors(e={},t,n,r){var o;const{activeWalletIds:i}=n.self,a=n.root.currency.wallets;let s=i!==(null===(o=r.self)||void 0===o?void 0:o.activeWalletIds);const c={};for(const u of i){const t=a[u].engineFailure;null!=t&&(c[u]=t),c[u]!==e[u]&&(s=!0)}return s?c:e},currencyWalletIds:ss(e=>e.self.walletInfos,e=>e.root.plugins.currency,(e,t)=>Object.keys(e).filter(n=>{const r=e[n],o=to(t,r.type);return!r.deleted&&null!=o}).sort((t,n)=>{const r=e[t],o=e[n];return r.sortIndex-o.sortIndex})),activeWalletIds:ss(e=>e.self.walletInfos,e=>e.self.currencyWalletIds,e=>e.self.keysLoaded,(e,t,n)=>n?t.filter(t=>!e[t].archived):[]),archivedWalletIds:ss(e=>e.self.walletInfos,e=>e.self.currencyWalletIds,e=>e.self.keysLoaded,(e,t,n)=>n?t.filter(t=>e[t].archived):[]),hiddenWalletIds:ss(e=>e.self.walletInfos,e=>e.self.currencyWalletIds,e=>e.self.keysLoaded,(e,t,n)=>n?t.filter(t=>e[t].hidden):[]),keysLoaded(e=!1,t){return"ACCOUNT_KEYS_LOADED"===t.type||e},legacyWalletInfos(e=[],t){return"ACCOUNT_KEYS_LOADED"===t.type?t.payload.legacyWalletInfos:e},walletInfos:ss(e=>e.self.allWalletInfosFull,e=>{const t={};for(const n of e)t[n.id]=n;return t}),walletStates(e={},t){return"ACCOUNT_CHANGED_WALLET_STATES"===t.type||"ACCOUNT_KEYS_LOADED"===t.type?t.payload.walletStates:e},pauseWallets(e=!1,t){return"LOGIN"===t.type?t.payload.pauseWallets:e},activeAppId:(e="",t)=>"LOGIN"===t.type?t.payload.appId:e,loadFailure(e=null,t){if("ACCOUNT_LOAD_FAILED"===t.type){const{error:e}=t.payload;return e instanceof Error?e:new Error(String(e))}return e},login:ss(e=>e.self.activeAppId,e=>e.self.loginTree,(e,t)=>{const n=zn(t,t=>t.appId===e);if(null==n)throw new Error(`Internal error: cannot find login for ${e}`);return n}),loginTree:ss(e=>e.self.stashTree,e=>e.self.sessionKey,(e,t)=>Vn(e,t)),loginType(e="newAccount",t){return"LOGIN"===t.type?t.payload.loginType:e},rootLoginId(e=new Uint8Array(0),t){return"LOGIN"===t.type?t.payload.rootLoginId:e},sessionKey(e=Vc,t){return"LOGIN"===t.type?t.payload.sessionKey:e},stashTree:ss(e=>e.self.rootLoginId,e=>e.root.login.stashes,(e,t)=>{for(const n of t)if(cn(n.loginId,e))return n;throw new Error("There is no stash")}),allTokens(e={},t,n,r){const{builtinTokens:o,customTokens:i}=n.self;if(null==r.self||o!==r.self.builtinTokens||i!==r.self.customTokens){const t=Hc({},e);for(const e of Object.keys(n.root.plugins.currency))null!=r.self&&o[e]===r.self.builtinTokens[e]&&i[e]===r.self.customTokens[e]||(t[e]=Hc(Hc({},i[e]),o[e]));return t}return e},builtinTokens(e={},t){if("ACCOUNT_BUILTIN_TOKENS_LOADED"===t.type){const{pluginId:n,tokens:r}=t.payload;return Hc(Hc({},e),{},{[n]:r})}return e},customTokens(e=Yc,t){switch(t.type){case"ACCOUNT_CUSTOM_TOKENS_LOADED":{const{customTokens:e}=t.payload;return e}case"ACCOUNT_CUSTOM_TOKEN_ADDED":{var n;const{pluginId:r,tokenId:o,token:i}=t.payload,a=null!==(n=e[r])&&void 0!==n?n:{};if(va(a[o],i))return e;const s=Hc(Hc({},a),{},{[o]:i});return Hc(Hc({},e),{},{[r]:s})}case"ACCOUNT_CUSTOM_TOKEN_REMOVED":{var r;const{pluginId:n,tokenId:o}=t.payload,i=null!==(r=e[n])&&void 0!==r?r:{};if(null==i[o])return e;const{[o]:a}=i,s=Sc(i,[o].map(qc));return Hc(Hc({},e),{},{[n]:s})}}return e},alwaysEnabledTokenIds(e={},t){if("ACCOUNT_ALWAYS_ENABLED_TOKENS_CHANGED"===t.type){const{pluginId:n,tokenIds:r}=t.payload;return Hc(Hc({},e),{},{[n]:r})}return e},swapSettings(e={},t){switch(t.type){case"ACCOUNT_PLUGIN_SETTINGS_LOADED":return t.payload.swapSettings;case"ACCOUNT_SWAP_SETTINGS_CHANGED":{const{pluginId:n,swapSettings:r}=t.payload,o=Hc({},e);return o[n]=r,o}}return e},userSettings(e={},t){switch(t.type){case"ACCOUNT_PLUGIN_SETTINGS_CHANGED":{const{pluginId:n,userSettings:r}=t.payload,o=Hc({},e);return o[n]=r,o}case"ACCOUNT_PLUGIN_SETTINGS_LOADED":return t.payload.userSettings}return e}}),Xc=rs(Jc,(e,t)=>/^ACCOUNT_/.test(e.type)&&"payload"in e&&"object"==typeof e.payload&&"accountId"in e.payload&&e.payload.accountId===t.id||"LOGIN"===e.type&&t.root.lastAccountId===t.id?e:{type:"UPDATE_NEXT"});function Zc(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Qc(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Zc(Object(n),!0).forEach(function(t){r(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Zc(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}const eu=mr({accountApi(e){return{destroy(){e.props.state={accounts:{}};const{accountOutput:t}=e.props;if(null==t)return;const{accountApi:n}=t;if(null==n)return;G(n),F(n),F(n.dataStore);const{currencyConfig:r,swapConfig:o}=n;for(const e of Object.keys(r))F(r[e]);for(const e of Object.keys(o))F(o[e])},async update(){const t=Ou(e),{accountId:n,accountState:r,log:o}=e.props,{accountWalletInfos:i}=r;try{await async function(e){await e.waitFor(e=>{const{init:t,locked:n}=e.state.plugins;if(!n)return;const{currency:r,swap:o}=e.state.plugins,i=[];for(const a of Object.keys(t))!1!==t[a]&&null!=t[a]&&null==r[a]&&null==o[a]&&i.push(a);if(i.length>0)throw new Error("The following plugins are missing or failed to load: "+i.join(", "));return!0})}(t),await la(t,n),o.warn("Login: currency plugins exist"),await Promise.all(i.map(e=>go(t,e))),o.warn("Login: synced account repos"),await async function(){await Promise.all([Fo(t,n),da(t,n),zo(t,n)])}(),o.warn("Login: loaded files"),e.onOutput(Gc(t,n)),o.warn("Login: complete")}catch(a){e.props.dispatch({type:"ACCOUNT_LOAD_FAILED",payload:{accountId:n,error:a}})}return await Ar}}},syncTimer:Sr(e=>{const t=Zr(async function(){const t=Ou(e),{accountId:n,accountState:r}=e.props,{accountWalletInfos:o}=r;if(null==e.props.state.accounts[n])return;const i=await Promise.all(o.map(e=>wo(t,e.id))),a=[];for(const e of i)a.push(...e);a.length>0&&await Promise.all([zo(t,n),Fo(t,n)])},bo),n=Zr(async function(){const t=Ou(e),{accountId:n}=e.props;if(null==e.props.state.accounts[n])return;const{sessionKey:r}=e.props.state.accounts[n];await er(t,r)},bo,{onError(t){const n=Yt(t);null!=n&&e.props.onError(n)}});return{update(){var r;if(null==(null===(r=e.props.accountOutput)||void 0===r?void 0:r.accountApi))return;const{accountId:o}=e.props,{stashTree:i}=e.props.state.accounts[o],a=null!=i.wipChange?5e3:bo;t.setDelay(bo),n.setDelay(a),t.start({wait:bo*(1+Math.random())}),n.start({wait:a*(1+Math.random())})},destroy(){t.stop(),n.stop()}}},e=>e.state.paused?void 0:e),tokenSaver(e){let t=Yc;return async function(){const{accountId:n,accountState:r}=e.props,{customTokens:o}=r;o!==t&&t!==Yc&&(await async function(e,t){const{state:n}=e.props,{accountWalletInfo:r}=n.accounts[t],o=Eo(n,r.id),{customTokens:i}=e.props.state.accounts[t],a=await ta.load(o,ra);await ta.save(o,ra,ea(ea({},a),{},{customTokens:i}))}(Ou(e),n).catch(t=>e.props.onError(t)),await Qr(100)),t=o}},watcher(e){let t;return()=>{const{accountState:n,accountOutput:r}=e.props;if(null==n||null==r)return;const{accountApi:o}=r;if(null!=o&&G(o),t!==n&&(t=n,null!=o)){const{currencyConfig:e,swapConfig:t}=o;for(const n of Object.keys(e))G(e[n]);for(const n of Object.keys(t))G(t[n])}}},currencyWallets(e){let t;return()=>{const{accountOutput:n,accountState:r}=e.props,{activeWalletIds:o}=r;let i=t!==o;t=o;let a={};null!=(null==n?void 0:n.currencyWallets)&&(a=n.currencyWallets);const s={},{wallets:c}=e.props.output.currency;for(const e of o){var u;const t=null===(u=c[e])||void 0===u?void 0:u.walletApi;t!==a[e]&&(i=!0),null!=t&&(s[e]=t)}i&&e.onOutput(s)}}}),tu=Or(eu,e=>e.state.accountIds,(e,t)=>Qc(Qc({},e),{},{accountId:t,accountState:e.state.accounts[t],accountOutput:e.output.accounts[t]})),nu=["loginId"];function ru(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function ou(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?ru(Object(n),!0).forEach(function(t){r(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ru(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}class iu extends te{constructor(e){super(),this._lobby=e,this._cleanups=[e.close,e.on("reply",e=>G(this,"replies")),e.on("error",e=>W(this,"error",e))]}get lobbyId(){return this._lobby.lobbyId}get replies(){return this._lobby.replies}close(){this._cleanups.forEach(e=>e()),F(this)}}class au extends te{constructor(e){super(),this._ai=e}authRequest(e,t,n){return In(this._ai,e,t,n)}hashUsername(e){return Cn(this._ai,e)}async makeLobby(e,t=1e3){const n=await Ui(this._ai,e,t);return new iu(n)}fetchLobbyRequest(e){return Fi(this._ai,e)}async sendLobbyReply(e,t,n){await Wi(this._ai,e,t,n)}async syncRepo(e){const{io:t,syncClient:n}=this._ai.props,r=uo(t,{dataKey:new Uint8Array(0),syncKey:e});return await po(n,r,{lastSync:0,lastHash:void 0})}async getRepoDisklet(e,t){const{io:n}=this._ai.props,r=uo(n,{dataKey:t,syncKey:e});return P(r.disklet),r.disklet}}function su(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function cu(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?su(Object(n),!0).forEach(function(t){r(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):su(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function uu(e){const t=e.props.state.login.contextAppId,n=Lt.stringify(e.props.state.clientInfo.clientId),r=new au(e);let o;const i={on:Q,watch:ee,appId:t,clientId:n,async close(){e.props.close()},$internalStuff:r,fixUsername:ae,get localUsers(){return e.props.state.login.localUsers},async forgetAccount(t){const n=Lt.parse(t);for(const r of e.props.state.accountIds){if(cn(e.props.state.accounts[r].stashTree.loginId,n))throw new Error("Cannot remove logged-in user")}await async function(e,t){const{dispatch:n,io:r}=e.props,o=await r.disklet.list("logins").then(re.WR);for(const a of o)try{cn(Dn(JSON.parse(await r.disklet.getText(a))).loginId,t)&&await r.disklet.delete(a)}catch(i){}n({type:"LOGIN_STASH_DELETED",payload:t})}(e,n)},async fetchChallenge(){const t=await In(e,"POST","/v2/captcha/create",{}),{challengeId:n,challengeUri:r}=Ve(t);return{challengeId:n,challengeUri:r}},async usernameAvailable(t,n={}){const{challengeId:r}=n;return t=ae(t),await async function(e,t,n){const r={challengeId:n,userId:await Cn(e,t)};return await In(e,"POST","/v2/login",r).then(e=>!1).catch(e=>{if(null!=rn(e))return!0;throw e})}(e,t,r)},async createAccount(t){e.props.log.breadcrumb("EdgeContext.createAccount",{}),null!=t.username&&(t.username=ae(t.username));const n=await async function(e,t,n){const{challengeId:r,now:o=new Date}=t;e.props.log.breadcrumb("createLogin",{});const{kit:i,sessionKey:a}=await Pi(e,void 0,"",n),s={challengeId:r,data:i.server};return await In(e,"POST",i.serverPath,s),i.stash.lastLogin=o,await jn(e,i.stash),a}(e,t,t);return await Ci(e,n,"newAccount",t)},async loginWithKey(n,r,o={}){const{now:i=new Date,useLoginId:a=!1}=o,s=e.props.state.clientInfo.duressEnabled,c=a?xn(e,Lt.parse(n)).stashTree:kn(e,ae(n));if(null==c)throw new Error("User does not exist on this device");const u=zn(c,e=>e.appId===t);if(null==u)throw new Error(`Cannot find requested appId: "${t}"`);const l=t+".duress",d=zn(c,e=>e.appId===l);let f;try{f={loginId:u.loginId,loginKey:Lt.parse(r)},nr(c,f)}catch(p){if(!(p instanceof Error&&"Invalid checksum"===p.message))throw p;if(null==d)throw p;f={loginId:d.loginId,loginKey:Lt.parse(r)},nr(c,f)}return c.lastLogin=i,jn(e,c).catch(()=>{}),er(e,f).catch(t=>e.props.onError(t)),await Ci(e,f,"keyLogin",cu(cu({},o),{},{duressMode:s&&null!=(null==d?void 0:d.pin2Key)}))},async loginWithPassword(n,r,o={}){var i;e.props.log.breadcrumb("EdgeContext.loginWithPassword",{}),n=ae(n);const a=null!==(i=kn(e,n))&&void 0!==i?i:_n(n),s=await ci(e,a,r,o);if(e.props.state.clientInfo.duressEnabled){const r=t+".duress",i=kn(e,n);if(null==i)throw new Error("Missing stash after login with password");const a=zn(i,e=>e.appId===r);if(null!=(null==a?void 0:a.pin2Key)){const t=tr(i,s,a.loginId);return await Ci(e,t,"passwordLogin",cu(cu({},o),{},{duressMode:!0}))}}return await Ci(e,s,"passwordLogin",o)},checkPasswordRules:ie,async loginWithPIN(n,r,o={}){e.props.log.breadcrumb("EdgeContext.loginWithPIN",{});const{useLoginId:i=!1}=o,a=i?xn(e,Lt.parse(n)).stashTree:kn(e,ae(n));if(null==a)throw new Error("User does not exist on this device");const s=fi(a,t),c=t+".duress",u=zn(a,e=>e.appId===c);async function l(t,n){const i=null!=t.wipChange?await pi(e,t.wipChange,n,r,o).catch(async()=>await pi(e,t,n,r,o)):await pi(e,t,n,r,o);return await Ci(e,i,"pinLogin",o)}async function d(t,n){if(!0===n.fakePinDisabled)throw new zt("PIN login is not enabled for this account on this device");const i=await pi(e,t,n,r,o);return await Ci(e,i,"pinLogin",cu(cu({},o),{},{duressMode:!0}))}if(null==s){if(null==u)throw new zt("PIN login is not enabled for this account on this device");return await d(a,u)}if(null==(null==u?void 0:u.pin2Key))return await l(a,s);const f=e.props.state.clientInfo.duressEnabled,p=Lt.stringify(s.loginId),h=e.props.state.clientInfo.loginWaitTimestamps[p];if(null!=h&&h>Date.now())throw new Gt({wait_seconds:Math.ceil((h-Date.now())/1e3)});try{return f?await d(a,u):await l(a,s)}catch(b){if(null==Vt(b))throw b;try{const t=f?await l(a,s):await d(a,u);return f?await async function(){await Pr.save(e.props.io.disklet,xr,cu(cu({},e.props.state.clientInfo),{},{duressEnabled:!1})),e.props.dispatch({type:"LOGIN_DURESS_MODE_DISABLED"})}():await async function(){await Pr.save(e.props.io.disklet,xr,cu(cu({},e.props.state.clientInfo),{},{duressEnabled:!0})),e.props.dispatch({type:"LOGIN_DURESS_MODE_ENABLED"})}(),t}catch(g){var y;const t=[Vt(g),Vt(b)].reduce((e,t)=>{var n,r;return(null!==(n=null==e?void 0:e.wait)&&void 0!==n?n:0)>(null!==(r=null==t?void 0:t.wait)&&void 0!==r?r:0)?e:t}),n=1e3*(null!==(y=null==t?void 0:t.wait)&&void 0!==y?y:0);if(null!=t&&n>0){const r=Date.now()+n;throw await async function(t,n){await Pr.save(e.props.io.disklet,xr,cu(cu({},e.props.state.clientInfo),{},{loginWaitTimestamps:cu(cu({},e.props.state.clientInfo.loginWaitTimestamps),{},{[t]:n})})),e.props.dispatch({type:"LOGIN_WAIT_TIMESTAMP_UPDATED",payload:{loginId:t,timestamp:n}})}(p,r),t}if(null!=Jt(g))throw b;throw g}}},async loginWithRecovery2(t,n,r,o={}){e.props.log.breadcrumb("EdgeContext.loginWithRecovery2",{}),n=ae(n);const i=kn(e,n),a=await async function(e,t,n,r,o){const{username:i}=t;if(null==i)throw new Error("Recovery login requires a username");const a={recovery2Id:vi(n,i),recovery2Auth:mi(n,r)};return await Xn(e,t,t,o,a,async e=>{if(null==e.recovery2Box||!0===e.recovery2Box)throw new Error("Missing data for recovery v2 login");return dn(e.recovery2Box,n)})}(e,null!=i?i:_n(n),Lt.parse(t),r,o);return await Ci(e,a,"recoveryLogin",o)},async fetchRecovery2Questions(t,n){return n=ae(n),await async function(e,t,n){const r={recovery2Id:vi(t,n)},o=await In(e,"POST","/v2/login",r),{question2Box:i}=ot(o);if(null==i)throw new Error("Login has no recovery questions");return Ei(JSON.parse(ln(i,t)))}(e,Lt.parse(t),n)},async requestEdgeLogin(n){return e.props.log.breadcrumb("EdgeContext.requestEdgeLogin",{}),await zi(e,t,n)},async requestOtpReset(t,n){return t=ae(t),await async function(e,t,n){const r={userId:await Cn(e,t),otpResetAuth:n},o=await In(e,"DELETE","/v2/login/otp",r),{otpResetDate:i}=nt(o);return i}(e,t,n)},async fetchLoginMessages(){return await async function(e){const{stashes:t}=e.props.state.login,n={},r=[];for(const s of t){const{loginId:e,username:t}=s;null!=t&&(n[w(e)]=t,r.push(e))}const o={loginIds:r},i=await In(e,"POST","/v2/messages",o),a=[];for(const s of et(i)){const{loginId:e}=s,t=Sc(s,nu),r=w(e),o=n[r];null!=o&&a.push(ou(ou({},t),{},{loginId:r,username:o}))}return a}(e)},get paused(){return e.props.state.paused},async changePaused(t,n={}){const{secondsDelay:r=0}=n;null!=o&&(clearTimeout(o),o=void 0),e.props.state.paused!==t&&(0===r?e.props.dispatch({type:"PAUSE",payload:t}):o=setTimeout(()=>{o=void 0,e.props.dispatch({type:"PAUSE",payload:t})},1e3*r))},get logSettings(){return e.props.state.logSettings},async changeLogSettings(t){const n=cu(cu({},e.props.state.logSettings),t);e.props.dispatch({type:"CHANGE_LOG_SETTINGS",payload:n})},async setAttestationToken(t){e.props.dispatch({type:"SET_ATTESTATION_TOKEN",payload:t})}};return P(i),i}const lu=mr({api(e){return{destroy(){F(e.props.output.context.api)},update(){return e.onOutput(uu(e)),Ar}}},watcher(e){let t,n,r;return()=>{t===e.props.state.login.localUsers&&n===e.props.state.paused&&r===e.props.state.logSettings||(t=e.props.state.login.localUsers,n=e.props.state.paused,r=e.props.state.logSettings,null!=e.props.output.context.api&&G(e.props.output.context.api))}},infoFetcher:Sr(e=>{const t=Zr(async function(){const{dispatch:t,io:n}=e.props,{contextAppId:r,deviceInfo:o}=e.props.state.login,{appVersion:i,osType:a,osVersion:s}=o,[c]=Io(e.props.state.infoServers);let u;if(null!=a&&null!=s&&null!=i){const e=new URLSearchParams;e.set("appId",""!==r?r:"edge"),e.set("os",a),e.set("osVersion",s),e.set("appVersion",i),u=`${c}/v2/coreRollup?${e.toString()}`}else u=`${c}/v1/coreRollup`;const l=await fetch(u,{headers:{accept:"application/json"}});if(!l.ok)return;const d=await l.json(),f=Cr(d);t({type:"INFO_CACHE_FETCHED",payload:f}),await Nr.save(n.disklet,Mr,f)},6e5,{onError(t){e.props.onError(t)}});return{update(){t.started||t.start()},destroy(){t.stop()}}},e=>e.state.paused?void 0:e)});function du(e,t){if("object"!=typeof e||"object"!=typeof t||null==e||null==t)return e===t;const n=Array.isArray(e);if(n!==Array.isArray(t))return!1;if(n){if(e.length!==t.length)return!1;for(let n=0;n<e.length;++n)if(!du(e[n],t[n]))return!1;return!0}const r=Object.getOwnPropertyNames(e).filter(t=>void 0!==e[t]),o=Object.getOwnPropertyNames(t).filter(e=>void 0!==t[e]);if(r.length!==o.length)return!1;for(const i of r){if(!Object.prototype.hasOwnProperty.call(t,i))return!1;if(!du(e[i],t[i]))return!1}return!0}function fu(e,t,n,r,o,i){const{handleError:a,handleSend:s,localMethods:c}=i,u=Ee(n),l=Ee(r),d=async(e,t,n=null)=>{const r=l({jsonrpc:"2.0",result:void 0,error:{code:e,message:t,data:void 0},id:n});return await s(JSON.stringify(r))};let f=0;const p=new Map,h=new Map,y={};for(const b of Object.keys(t)){const{asParams:n,asResult:r}=t[b],i=Ee(n);y[b]=null==r?e=>{const t=u({jsonrpc:"2.0",method:b,params:i(e)});s(JSON.stringify(t)).catch(a)}:t=>{const n=f++,c=new Promise((e,t)=>{p.set(n,{asResult:r,resolve:e,reject:t})});o&&null!=e[b]&&null==e[b].asResult&&h.set(n,b);const l=u({jsonrpc:"2.0",method:b,params:i(t),id:n});return s(JSON.stringify(l)).catch(a),c}}return{handleClose:function(){for(const e of p.values())e.reject(new Error("JSON-RPC connection closed"))},handleMessage:function(t){let o;try{o=JSON.parse(t)}catch(f){return void d(-32700,`Parse error: ${pu(f)}`).catch(a)}const i=me(n)(o),u=me(r)(o);if(null!=i){const t=e[i.method];if(null==t)return void d(-32601,`Method not found: ${i.method}`).catch(a);if(null!=t.asResult&&null==i.id)return void d(-32600,"Invalid JSON-RPC request: missing id").catch(a);if(null==t.asResult&&null!=i.id)return void d(-32600,"Invalid JSON-RPC request: notification has an id").catch(a);let n;try{n=t.asParams(i.params)}catch(f){return void d(-32602,`Invalid params: ${pu(f)}`).catch(a)}const r=c[i.method](n);if(null!=t.asResult&&null!=(null==r?void 0:r.then)){const e=Ee(t.asResult);r.then(t=>{var n;const r=l({jsonrpc:"2.0",result:e(t),error:void 0,id:null!==(n=i.id)&&void 0!==n?n:null});s(JSON.stringify(r)).catch(a)},e=>{d(1,pu(e),i.id).catch(a)})}}else if(null!=u){const{error:t,id:n,result:r}=u;if("number"!=typeof n)return void d(-32603,`Cannot find id ${String(n)}`,n).catch(a);const o=p.get(n);if(null==o){const t=h.get(n);if(null==t)return void d(-32603,`Cannot find id ${String(n)}`,n).catch(a);let o;try{o=e[t].asParams(r)}catch(f){return void d(-32602,`Invalid params: ${pu(f)}`).catch(a)}return void c[t](o)}if(p.delete(n),null!=t)o.reject(new Error(t.message));else{const{asResult:e}=o;let t;try{t=e(r)}catch(f){o.reject(f)}o.resolve(t)}}else d(-32600,"Invalid JSON-RPC request / response").catch(a)},remoteMethods:y}}function pu(e){return e instanceof Error?e.message:String(e)}const hu=e=>{if(null===e)return e;if("string"==typeof e)return e;if("number"==typeof e&&Number.isInteger(e))return e;throw new TypeError("Expected a string or an integer")},yu=we({jsonrpc:le("2.0"),method:pe,params:ye,id:ue(hu)}),bu=we({jsonrpc:le("2.0"),result:ye,error:ue(we({code:fe,message:pe,data:ye})),id:hu}),gu=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return function(e){if(!Array.isArray(e))throw new TypeError("Expected an array, got "+ce(e));for(var n=[],r=0;r<t.length;++r)try{n[r]=t[r](e[r])}catch(o){throw be(o,"["+r+"]")}return n}}(pe,pe,ue(pe)),wu=le(-1,0,1,2),vu=function(e){const{serverMethods:t,clientMethods:n,asCall:r=yu,asReturn:o=bu,allowMultipleReturns:i=!1}=e;return{makeServerCodec(e){return fu(t,n,r,o,i,e)},makeClientCodec(e){return fu(n,t,r,o,i,e)}}}({serverMethods:{subscribe:{asParams:ge(gu),asResult:ge(wu)},unsubscribe:{asParams:ge(gu),asResult:le(void 0)}},clientMethods:{update:{asParams:gu},subLost:{asParams:gu}}});function mu(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Iu(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?mu(Object(n),!0).forEach(function(t){r(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):mu(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}const Eu=mr({wallets:Or(As,e=>e.state.currency.currencyWalletIds,(e,t)=>Iu(Iu({},e),{},{walletId:t,walletState:e.state.currency.wallets[t],walletOutput:e.output.currency.wallets[t]})),pluginUpdater(e){let t;return async()=>{const{infoCache:n,plugins:r}=e.props.state;if(t!==n){if(null!=t)for(const e of Object.keys(r.currency)){var o,i,a,s;const c=r.currency[e],u=null!==(o=null===(i=n.corePlugins)||void 0===i?void 0:i[e])&&void 0!==o?o:{},l=null!==(a=null===(s=t.corePlugins)||void 0===s?void 0:s[e])&&void 0!==a?a:{};null==c.updateInfoPayload||du(l,u)||await c.updateInfoPayload(u)}t=n}}},changeServiceManager(e){let t,n;return{async update(){var r,o;const{wallets:i}=e.props.state.currency;if(i===t)return;t=i;let{changeService:a,changeServiceConnected:s=!1}=null!==(r=e.props.output.currency.changeServiceManager)&&void 0!==r?r:{};const c=Object.entries(i).filter(([,e])=>e.changeServiceSubscriptions.some(e=>"avoiding"!==e.status));if(null==a&&c.length>0){const t=e.props.state.changeServers[0];a=function(e,t){let n,r,o=!1;!function s(){n=new WebSocket(e),n.binaryType="arraybuffer",n.addEventListener("message",e=>{i.handleMessage(e.data)}),n.addEventListener("close",()=>{a.connected=!1,i.handleClose(),t.handleDisconnect(),r=setTimeout(()=>{o||s()},5e3)}),n.addEventListener("error",e=>{console.error("changeServer websocket error:",e),n.close()}),n.addEventListener("open",()=>{a.connected=!0,t.handleConnect()})}();const i=vu.makeClientCodec({handleError(e){console.error("changeServer error:",e),n.close()},async handleSend(e){n.send(e)},localMethods:{update(e){t.handleChange(e)},subLost(e){t.handleSubLost(e)}}}),a={async subscribe(e){return await i.remoteMethods.subscribe(e)},async unsubscribe(e){await i.remoteMethods.unsubscribe(e)},close(){o=!0,null!=r&&(clearTimeout(r),r=void 0),n.close()},connected:!1};return a}(t,{handleChange([t,n,r]){const o=Object.entries(e.props.state.currency.wallets).filter(([,e])=>e.currencyInfo.pluginId===t&&e.changeServiceSubscriptions.some(e=>e.address===n));for(const[i,a]of o){const t=a.changeServiceSubscriptions.filter(e=>e.address===n&&"listening"===e.status).map(e=>Iu(Iu({},e),{},{status:"syncing",checkpoint:r}));e.props.dispatch({type:"CURRENCY_ENGINE_UPDATE_CHANGE_SERVICE_SUBSCRIPTIONS",payload:{walletId:i,subscriptions:t}})}},handleConnect(){const t=Object.entries(e.props.state.currency.wallets);for(const[n,r]of t){const t=r.changeServiceSubscriptions.filter(e=>"reconnecting"===e.status).map(e=>Iu(Iu({},e),{},{status:"subscribing"}));e.props.dispatch({type:"CURRENCY_ENGINE_UPDATE_CHANGE_SERVICE_SUBSCRIPTIONS",payload:{walletId:n,subscriptions:t}})}e.onOutput({changeService:a,changeServiceConnected:!0})},handleDisconnect(){const t=Object.entries(e.props.state.currency.wallets);for(const[n,r]of t){const t=r.changeServiceSubscriptions.filter(e=>"avoiding"!==e.status).map(e=>Iu(Iu({},e),{},{status:"reconnecting"}));e.props.dispatch({type:"CURRENCY_ENGINE_UPDATE_CHANGE_SERVICE_SUBSCRIPTIONS",payload:{walletId:n,subscriptions:t}})}e.onOutput({changeService:a,changeServiceConnected:!1})},handleSubLost([t,n]){const r=Object.entries(e.props.state.currency.wallets).filter(([,e])=>e.currencyInfo.pluginId===t&&e.changeServiceSubscriptions.some(e=>e.address===n)&&e.changeServiceSubscriptions.some(e=>"avoiding"!==e.status));for(const[o,i]of r){const t=i.changeServiceSubscriptions.filter(e=>"avoiding"!==e.status).map(e=>Iu(Iu({},e),{},{status:"subscribing"}));e.props.dispatch({type:"CURRENCY_ENGINE_UPDATE_CHANGE_SERVICE_SUBSCRIPTIONS",payload:{walletId:o,subscriptions:t}})}}}),e.onOutput({changeService:a,changeServiceConnected:!1})}if(null!=a&&0===c.length&&(a.close(),a=void 0,e.onOutput({changeService:a,changeServiceConnected:!1})),!0===(null===(o=a)||void 0===o?void 0:o.connected)&&s){const t=c.filter(([,e])=>e.changeServiceSubscriptions.some(e=>"subscribing"===e.status||"resubscribing"===e.status)),r=[],o=[];for(const[e,n]of t){if(n.paused)continue;const t=n.changeServiceSubscriptions.map(e=>[n.currencyInfo.pluginId,e.address,e.checkpoint]);if(0===t.length)continue;let i=o[o.length-1];(null==i||i.length+t.length>100)&&(o.push([]),i=o[o.length-1]),i.push(...t);for(let o=0;o<t.length;o++)r[r.length]={walletId:e,wallet:n}}n=setTimeout(()=>{n=void 0;const t=new Set(r.map(e=>e.walletId));for(const n of t){const t=e.props.state.currency.wallets[n];if(null==t)continue;const r=t.changeServiceSubscriptions.filter(e=>"subscribing"===e.status).map(e=>Iu(Iu({},e),{},{status:"subscribingSlowly"}));r.length>0&&e.props.dispatch({type:"CURRENCY_ENGINE_UPDATE_CHANGE_SERVICE_SUBSCRIPTIONS",payload:{walletId:n,subscriptions:r}})}},15e3);const i=[];try{for(const t of o){const n=await a.subscribe(t).catch(n=>(e.props.log(`Failed to subscribe: ${String(n)}`),t.map(()=>0)));i.push(...n)}}finally{clearTimeout(n),n=void 0}const s=new Map;for(let n=0;n<i.length;n++){const t=i[n],{walletId:o}=r[n],a=e.props.state.currency.wallets[o];if(null==a)continue;let c;switch(t){case-1:c="avoiding";break;case 0:c="resubscribing";break;case 1:c="synced";break;case 2:c="syncing"}const u=a.changeServiceSubscriptions.filter(e=>"subscribing"===e.status||"subscribingSlowly"===e.status||"resubscribing"===e.status).map(e=>Iu(Iu({},e),{},{status:c}));s.set(o,u)}const u=Array.from(s.entries());for(const[n,a]of u)e.props.dispatch({type:"CURRENCY_ENGINE_UPDATE_CHANGE_SERVICE_SUBSCRIPTIONS",payload:{walletId:n,subscriptions:a}})}},destroy(){null!=n&&clearTimeout(n)}}}});const Su=mr({makeSnrp:e=>()=>{const{io:t,log:n}=e.props;let r;return e.onOutput(async function(o){null==r&&(r=e.props.output.scrypt.timeScrypt(Bt.parse("1reallyJunkiePasswordToCheck"),{salt_hex:p("b5865ffb9fa7b3bfe4b2384d47ce831ee22a4a9d5c34c7ef7d21467cc758f81b"),n:16384,r:8,p:1}).then(e=>e.time));const i=await r,a=function(e,t,n){const r={salt_hex:e,n:16384,r:8,p:1};if(0===t)return r.n=131072,r.r=8,r.p=64,r;let o=t;const i=t/8;let a=(n-o)/i;a=a>0?a:0,a>0&&(a=0),a=Math.floor(a),r.r=8+a,o+=a*i;let s=14,c=(n-o)/o;c=c>0?c:0,c>3&&(c=3),c=Math.floor(c),s+=c>=0?c:0,o+=c*o,r.n=Math.pow(2,s);let u=(n-o)/o;return u=u>0?u:0,u>64&&(u=64),u=Math.floor(u),r.p=u>=1?u:1,o+=u*o,r}(t.random(32),i,o);return n(`snrp for ${o}ms target: ${a.n} ${a.r} ${a.p} based on ${i}ms benchmark`),a}),Ar},timeScrypt:e=>()=>{const{io:t,log:n}=e.props,r="undefined"!=typeof window&&null!=window.performance&&"function"==typeof window.performance.now?()=>window.performance.now():()=>Date.now();return e.onOutput(function(e){let t=Promise.resolve();return function(...n){const r=()=>e.apply(this,n),o=t.then(r,r);return t=o,o}}(function(e,o,i=32){const a=o.salt_hex,s=r();return n(`starting scrypt n=${o.n} r=${o.r} p=${o.p}`),t.scrypt(e,a,o.n,o.r,o.p,i).then(e=>{const t=r()-s;return n(`finished scrypt n=${o.n} r=${o.r} p=${o.p} in ${t}ms`),{hash:e,time:t}})})),Ar}}),Ou=e=>e,Au=mr({accounts:tu,context:lu,currency:Eu,scrypt:Su}),Tu=es({currencyWalletIds(e,t,n){if(1===n.accountIds.length){const e=n.accountIds[0];return n.accounts[e].activeWalletIds}const r=[];for(const o of n.accountIds)r.push(...n.accounts[o].activeWalletIds);return r},wallets:as(ws,e=>e.currency.currencyWalletIds)}),_u=es({apiKey(e="",t){return"INIT"===t.type?t.payload.apiKey:e},apiSecret(e=null,t){var n;return"INIT"===t.type?null!==(n=t.payload.apiSecret)&&void 0!==n?n:null:e},attestationToken(e=null,t){if("SET_ATTESTATION_TOKEN"!==t.type)return e;const n=t.payload;return null==n||""===n?null:n},contextAppId(e="",t){return"INIT"===t.type?t.payload.appId:e},deviceInfo(e={},t){if("INIT"===t.type){const{appVersion:e,deviceDescription:n,osType:r,osVersion:o}=t.payload;return{deviceDescription:null!=n?n:void 0,osType:r,osVersion:o,appVersion:e}}return e},localUsers:ss(e=>e.login.contextAppId,e=>e.login.stashes,e=>e.clientInfo,(e,t,n)=>t.map(function(t){const{lastLogin:r,loginId:o,recovery2Key:i,username:a}=t,s=zn(t,t=>t.appId===e),c=null!=s&&(null!=s.passwordAuthBox||null!=s.loginAuthBox),u=n.duressEnabled?Ln(t,e):void 0,l=null!=(null==u?void 0:u.pin2Key)&&!0===(null==u?void 0:u.fakePinDisabled),d=fi(t,e),f=!l&&null!=(null==d?void 0:d.pin2Key);return{keyLoginEnabled:c,lastLogin:r,loginId:Lt.stringify(o),pinLoginEnabled:f,recovery2Key:null!=i?Lt.stringify(i):void 0,username:a,voucherId:null!=s?s.voucherId:void 0}})),loginServers(e=[],t){return"INIT"===t.type?t.payload.loginServers:e},stashes(e=[],t){switch(t.type){case"INIT":return t.payload.stashes;case"LOGIN_STASH_DELETED":{const n=t.payload;return e.filter(e=>!cn(e.loginId,n))}case"LOGIN_STASH_SAVED":{const n=t.payload,r=e.filter(e=>!cn(e.loginId,n.loginId));return r.unshift(n),r}}return e},walletInfos(e,t,n){if(1===n.accountIds.length){const e=n.accountIds[0];return n.accounts[e].walletInfos}const r={};for(const o of n.accountIds){const e=n.accounts[o];for(const t of Object.keys(e.walletInfos)){const n=e.walletInfos[t];r[t]=n}}return r}});function ku(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function xu(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?ku(Object(n),!0).forEach(function(t){r(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ku(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}const Pu={init:{},locked:!1,currency:{},swap:{},currencyTools:{}};function Mu(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Cu(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Mu(Object(n),!0).forEach(function(t){r(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Mu(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}const Nu=function(e){for(var t=Object.keys(e),n={},r=0;r<t.length;r++){var o=t[r];0,"function"==typeof e[o]&&(n[o]=e[o])}var i,a=Object.keys(n);try{!function(e){Object.keys(e).forEach(function(t){var n=e[t];if(void 0===n(void 0,{type:cr.INIT}))throw new Error(ir(12));if(void 0===n(void 0,{type:cr.PROBE_UNKNOWN_ACTION()}))throw new Error(ir(13))})}(n)}catch(s){i=s}return function(e,t){if(void 0===e&&(e={}),i)throw i;for(var r=!1,o={},s=0;s<a.length;s++){var c=a[s],u=n[c],l=e[c],d=u(l,t);if(void 0===d){t&&t.type;throw new Error(ir(14))}o[c]=d,r=r||d!==l}return(r=r||a.length!==Object.keys(e).length)?o:e}}({lastChanges(e=[],t){if("STORAGE_WALLET_SYNCED"===t.type){const{changes:n}=t.payload;return n.length>0?n:e}return e},localDisklet(e=null){return e},paths(e=null){return e},status(e={lastSync:0,lastHash:void 0},t){return"STORAGE_WALLET_SYNCED"===t.type?t.payload.status:e}});function ju(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Du(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?ju(Object(n),!0).forEach(function(t){r(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ju(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}const Ru={sources:{},defaultLogLevel:"warn"},Lu={clientId:new Uint8Array(0),duressEnabled:!1,loginWaitTimestamps:{}},Bu=es({accountCount(e=0,t){return"LOGIN"===t.type?e+1:e},accountIds(e=[],t,n){switch(t.type){case"LOGIN":return[...e,n.lastAccountId];case"LOGOUT":{const{accountId:n}=t.payload,r=e.filter(e=>e!==n);if(r.length===e.length)throw new Error(`Login ${n} does not exist`);return r}case"CLOSE":return[]}return e},accounts:as(Xc,e=>e.accountIds),changeServers(e=[],t){return"INIT"===t.type?t.payload.changeServers:e},clientInfo(e=Lu,t){switch(t.type){case"INIT":return t.payload.clientInfo;case"LOGIN_DURESS_MODE_DISABLED":return Du(Du({},e),{},{duressEnabled:!1});case"LOGIN_DURESS_MODE_ENABLED":return Du(Du({},e),{},{duressEnabled:!0});case"LOGIN_WAIT_TIMESTAMP_UPDATED":return Du(Du({},e),{},{loginWaitTimestamps:Du(Du({},e.loginWaitTimestamps),{},{[t.payload.loginId]:t.payload.timestamp})})}return e},hideKeys(e=!0,t){return"INIT"===t.type?t.payload.hideKeys:e},infoCache(e={},t){switch(t.type){case"INIT":return t.payload.infoCache;case"INFO_CACHE_FETCHED":return t.payload}return e},infoServers(e=[],t){return"INIT"===t.type?t.payload.infoServers:e},lastAccountId(e,t,n){return`login${n.accountCount}`},logSettings(e=Ru,t){switch(t.type){case"INIT":return t.payload.logSettings;case"CHANGE_LOG_SETTINGS":return t.payload}return e},paused(e=!1,t){return"PAUSE"===t.type?t.payload:e},ready(e=!1,t){return"INIT"===t.type||e},skipBlockHeight(e=!1,t){return"INIT"===t.type?t.payload.skipBlockHeight:e},syncServers(e=[],t){return"INIT"===t.type?t.payload.syncServers:e},currency:Tu,login:_u,plugins:(e=Pu,t)=>{switch(t.type){case"CORE_PLUGINS_ADDED":{const n=xu(xu({},e),{},{currency:xu({},e.currency),swap:xu({},e.swap)});for(const e of Object.keys(t.payload)){const r=t.payload[e];null!=r?("currencyInfo"in r&&(null==r.currencyInfo.chainDisplayName&&(r.currencyInfo.chainDisplayName=r.currencyInfo.displayName),null==r.currencyInfo.assetDisplayName&&(r.currencyInfo.assetDisplayName=r.currencyInfo.displayName),n.currency[e]=r),"swapInfo"in r&&(n.swap[e]=r)):n.init=xu(xu({},n.init),{},{[e]:!1})}return n}case"CORE_PLUGINS_LOCKED":return xu(xu({},e),{},{locked:!0});case"CURRENCY_TOOLS_LOADED":{const n=xu({},e.currencyTools);return n[t.payload.pluginId]=t.payload.tools,xu(xu({},e),{},{currencyTools:n})}case"INIT":return xu(xu({},e),{},{init:t.payload.pluginsInit})}return e},storageWallets:function(e={},t){switch(t.type){case"STORAGE_WALLET_ADDED":{const{id:n,initialState:r}=t.payload,o=Cu({},e);return o[n]=Nu(r,{type:"UPDATE_NEXT"}),o}case"STORAGE_WALLET_SYNCED":{const{id:n}=t.payload;if(null!=e[n]){const r=Cu({},e);return r[n]=Nu(e[n],t),r}return e}}return e}});function Ku(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Uu(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Ku(Object(n),!0).forEach(function(t){r(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ku(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}let Fu=[];const Wu="object"==typeof window&&null!=window.__REDUX_DEVTOOLS_EXTENSION__?window.__REDUX_DEVTOOLS_EXTENSION__({name:"core"}):void 0;async function Gu(e,t,n){const{io:r}=e,{airbitzSupport:o=!1,apiSecret:i,appId:a="",appVersion:s,authServer:c,deviceDescription:u=null,changeServer:l,hideKeys:d=!1,infoServer:f,loginServer:p,osType:h,osVersion:y,plugins:b={},skipBlockHeight:g=!1,syncServer:w}=n;let{apiKey:v}=n;null!=v&&""!==v||(v="4248c1bf41e53b840a5fdb2c872dd3ade525e66d");const m=zu(c,["https://login1.edge.app","https://login2.edge.app"]),I=zu(l,["wss://change1.edge.app","wss://change2.edge.app"]),E=zu(f,["https://info1.edge.app","https://info2.edge.app"]),S=zu(p,m.map(e=>e.replace(/\/api$/,""))),O=zu(w,["https://sync-us1.edge.app","https://sync-us2.edge.app","https://sync-us3.edge.app","https://sync-us4.edge.app","https://sync-us5.edge.app","https://sync-us6.edge.app","https://sync-eu.edge.app"]),A=Uu(Uu({},Ru),n.logSettings);I.map(e=>Tr(e)),E.map(e=>Tr(e)),S.map(e=>Tr(e)),O.map(e=>Tr(e));const T=lr(Bu,Wu);var _,k;k=()=>{const e=T.getState();return e.ready?e.logSettings:A};const x=Lr(t=Dr(Dr({},_=t),{},{onLog:function(e){const{sources:t,defaultLogLevel:n}=k(),r=null!=t[e.source]?t[e.source]:n;switch(e.type){case"info":"info"===r&&_.onLog(e);break;case"warn":"info"!==r&&"warn"!==r||_.onLog(e);break;case"error":"silent"!==r&&_.onLog(e)}}}),"edge-core");let[P,M={},C]=await Promise.all([Pr.load(r.disklet,xr),Nr.load(r.disklet,Mr),Nn(r.disklet,x)]);if(o){const e=new Set;for(const{username:n}of C)null!=n&&e.add(n);const t=await async function(e,t){const n=[],r=await e.disklet.list("Accounts").then(re.a8);for(const o of r){const r=(0,re.my)(e.disklet,o),[i,a,s,c,u,l]=await Promise.all([await Kr.load(r,"CarePackage.json"),await Ur.load(r,"LoginPackage.json"),await Fr.load(r,"OtpKey.json"),await Wr.load(r,"Pin2Key.json"),await Gr.load(r,"Recovery2Key.json"),await zr.load(r,"UserName.json")]);if(null==l)continue;const d=ae(l.userName);if(t.has(d))continue;const f={appId:"",loginId:await e.scrypt(Bt.parse(d),Tn.salt_hex,Tn.n,Tn.r,Tn.p,32),pendingVouchers:[],username:d};null!=i&&null!=a&&(f.passwordKeySnrp=i.SNRP2,f.passwordBox=a.EMK_LP2,f.syncKeyBox=a.ESyncKey,f.passwordAuthBox=a.ELP1),null!=s&&(f.otpKey=s.TOTP),null!=c&&(f.pin2Key=c.pin2Key),null!=u&&(f.recovery2Key=u.recovery2Key),n.push(f)}return n}(r,e);C.push(...t)}null==P&&(P={clientId:r.random(16),duressEnabled:!1,loginWaitTimestamps:{}},await Pr.save(r.disklet,xr,P)),T.dispatch({type:"INIT",payload:{apiKey:v,apiSecret:i,appId:a,appVersion:s,osType:h,osVersion:y,changeServers:I,loginServers:S,infoCache:M,infoServers:E,syncServers:O,clientInfo:P,deviceDescription:u,hideKeys:d,logSettings:A,pluginsInit:b,skipBlockHeight:g,stashes:C}});const N=function(e,t,n,r,o){const{io:i,nativeIo:a}=e,s=$r($r({},i),{},{console:console});function c(e){const c={};for(const o of Object.keys(e)){const f=e[o],p=Lr(n,o),h=r[o];if(!1!==h&&null!=h)try{if("function"==typeof f){var u,l;const e={infoPayload:null!==(u=null===(l=t.corePlugins)||void 0===l?void 0:l[o])&&void 0!==u?u:{},initOptions:"object"==typeof h?h:{},io:s,log:p,nativeIo:a,pluginDisklet:(0,re.my)(i.disklet,"plugins/"+o)};c[o]=f(e)}else{if("object"!=typeof f||null==f)throw new TypeError("Plugins must be functions or objects, got "+typeof f);c[o]=f}}catch(d){p.error(d)}}o({type:"CORE_PLUGINS_ADDED",payload:c})}function u(){o({type:"CORE_PLUGINS_LOCKED",payload:r})}return c(Hr),Yr&&u(),Vr.push(c),Jr.push(u),()=>{Vr.filter(e=>e!==c),Jr.filter(e=>e!==u)}}(e,M,t,b,T.dispatch),j=or({log:x,fetch:(e,t)=>r.fetch(e,Uu(Uu({},t),{},{corsBypass:"never"})),edgeServers:{infoServers:E,syncServers:O}}),D={output:{}},R=function(e,t,n,r){var o=vr(t,n,r);o.update({dispatch:e.dispatch,output:void 0,state:e.getState()});var i=e.subscribe(function(){o.update({dispatch:e.dispatch,output:void 0,state:e.getState()})});return function(){i(),o.destroy()}}(T,Sr(Au,e=>Uu(Uu({},e),{},{close(){R(),N(),T.dispatch({type:"CLOSE"})},io:r,log:x,logBackend:t,onError:e=>{var t;null!=(null===(t=D.output.context)||void 0===t?void 0:t.api)&&W(D.output.context.api,"error",e)},syncClient:j})),e=>x.error(e),e=>D.output=e),L=D.output.context.api;return Fu.push(L),L}function zu(e,t){return"string"==typeof e?[e]:null!=e&&e.length>0?e:t}const qu=["children"];function $u(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Hu(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?$u(Object(n),!0).forEach(function(t){r(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):$u(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}class Yu{constructor(){this.lobbies=new Map,this.logins=[],this.repos=new Map}getLoginById(e){return this.logins.find(t=>cn(t.loginId,e))}getLoginByUserId(e){return this.logins.find(t=>null==t.userId?cn(t.loginId,e):cn(t.userId,e))}getLoginByPin2Id(e){return this.logins.find(t=>null!=t.pin2Id&&cn(t.pin2Id,e))}getLoginByRecovery2Id(e){return this.logins.find(t=>null!=t.recovery2Id&&cn(t.recovery2Id,e))}getLoginsByParent(e){return this.logins.filter(t=>t.parentId===e.loginId)}insertLogin(e){this.logins.push(e)}setupLogin(e){const{children:t}=e,n=Sc(e,qu);this.insertLogin(n);for(const r of t)r.parentId=e.loginId,this.setupLogin(r)}setupRepo(e,t){this.repos.set(e,t)}dumpLogin(e){const t=e=>Hu(Hu({},e),{},{children:this.getLoginsByParent(e).map(e=>t(e))});return t(e)}}function Vu(e,t){const n=e.getLoginsByParent(t).map(t=>Vu(e,t));return{appId:t.appId,created:t.created,loginId:t.loginId,children:n,parentBox:t.parentBox,passwordAuthBox:t.passwordAuthBox,passwordAuthSnrp:t.passwordAuthSnrp,passwordBox:t.passwordBox,passwordKeySnrp:t.passwordKeySnrp,pin2Box:t.pin2Box,pin2KeyBox:t.pin2KeyBox,pin2TextBox:t.pin2TextBox,question2Box:t.question2Box,recovery2Box:t.recovery2Box,recovery2KeyBox:t.recovery2KeyBox,otpKey:t.otpKey,otpResetDate:t.otpResetDate,otpTimeout:t.otpTimeout,pendingVouchers:Ju(t),loginAuthBox:t.loginAuthBox,userId:t.userId,userTextBox:t.userTextBox,keyBoxes:t.keyBoxes,mnemonicBox:t.mnemonicBox,rootKeyBox:t.rootKeyBox,syncKeyBox:t.syncKeyBox}}function Ju(e){return e.vouchers.filter(e=>"pending"===e.status).map(e=>({activates:e.activates,created:e.created,deviceDescription:e.deviceDescription,ip:e.ip,ipDescription:e.ipDescription,voucherId:e.voucherId}))}function Xu(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Zu(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Xu(Object(n),!0).forEach(function(t){r(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Xu(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}const Qu={code:0,httpStatus:200,message:"Success"},el={code:2,httpStatus:401,message:"Account already exists"},tl={code:3,httpStatus:401,message:"No account"},nl={code:4,httpStatus:401,message:"Invalid Password"},rl={code:8,httpStatus:401,message:"Invalid OTP"},ol={code:10,httpStatus:409,message:"Conflicting change"},il={code:0,httpStatus:201,message:"Account created"},al={code:1,httpStatus:401,message:"Invalid request"},sl={code:1,httpStatus:404,message:"Not found"},cl={code:3,httpStatus:404,message:"Not found"},ul={code:10,httpStatus:401,message:"A login with the same appId already exists"};function ll(e,t){try{return[e(t),{status:200}]}catch(n){return[void 0,fl(al,`Invalid request: ${String(n)}`)]}}function dl(e,t={}){const{status:n=200,headers:r={}}=t;return{status:n,headers:Zu({"content-type":"application/json"},r),body:JSON.stringify(e)}}function fl(e=Qu,t=e.message){const{code:n,httpStatus:r}=e;return dl(lt({status_code:n,message:t}),{status:r})}function pl(e,t=Qu,n=t.message){const{code:r,httpStatus:o}=t;return dl(lt({status_code:r,message:n,results:e}),{status:o})}function hl(e){return pl(_t({wait_seconds:e}),nl)}function yl(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function bl(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?yl(Object(n),!0).forEach(function(t){r(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):yl(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}const gl=e=>async t=>{const{json:n}=t,[r,o]=ll(Re,n);return null==r?o:await e(bl(bl({},t),{},{body:r,payload:r.data}))},wl=e=>async t=>{const{body:n,login:r}=t,{otp:o,voucherAuth:i,voucherId:a}=n,{otpKey:s}=r;if(null==s)return await e(t);if(null!=o&&function(e,t,n={}){const{now:r=Date.now()/1e3,spread:o=1}=n,i=r/30;if(t===hn(e,i,6))return!0;for(let a=1;a<=o;++a){if(t===hn(e,i-a,6))return!0;if(t===hn(e,i+a,6))return!0}return!1}(s,o,{spread:2}))return await e(t);if(null!=i&&null!=a){const n=r.vouchers.find(e=>e.voucherId===a);if(null!=n&&"approved"===n.status&&cn(i,n.voucherAuth))return await e(t)}r.otpResetAuth="Super secret reset token";const c={activates:new Date("2020-01-01T00:00:00Z"),created:new Date("2020-01-08T00:00:00Z"),deviceDescription:"A phone",ip:"localhost",ipDescription:"here",loginId:r.loginId,status:"pending",voucherAuth:Uint8Array.from([170,187]),voucherId:`voucher-${r.vouchers.length}`};return r.vouchers.push(c),function(e,t={}){const{reason:n="otp",voucher:r}=t;return pl(At({login_id:e.loginId,otp_reset_auth:e.otpResetAuth,otp_timeout_date:e.otpResetDate,reason:n,voucher_auth:null==r?void 0:r.voucherAuth,voucher_activates:null==r?void 0:r.activates,voucher_id:null==r?void 0:r.voucherId}),rl)}(r,{voucher:c})},vl=e=>fl(al),ml=(e,t=vl)=>n=>{const{db:r,body:o}=n,{loginAuth:i,loginId:a,passwordAuth:s,pin2Auth:c,pin2Id:u,recovery2Auth:l,recovery2Id:d,userId:f}=o;if(null!=a&&null!=i){const t=r.getLoginById(a);return null==t?fl(tl):null!=t.loginAuth&&cn(i,t.loginAuth)?wl(e)(bl(bl({},n),{},{login:t})):hl(0)}if(null!=f&&null!=s){const t=r.getLoginByUserId(f);return null==t?fl(tl):null!=t.passwordAuth&&cn(s,t.passwordAuth)?wl(e)(bl(bl({},n),{},{login:t})):hl(0)}if(null!=u&&null!=c){const t=r.getLoginByPin2Id(u);return null==t?fl(tl):null!=t.pin2Auth&&cn(c,t.pin2Auth)?wl(e)(bl(bl({},n),{},{login:t})):hl(0)}if(null!=d&&null!=l){const t=r.getLoginByRecovery2Id(d);if(null==t)return fl(tl);const o=t.recovery2Auth,i=l;if(null==o||i.length!==o.length)return hl(0);for(let e=0;e<i.length;++e)if(!cn(i[e],o[e]))return hl(0);return wl(e)(bl(bl({},n),{},{login:t}))}return t(n)},Il=ml(e=>{const{db:t,login:n}=e;return pl(St(Vu(t,n)))},e=>{const{db:t,json:n}=e,r=Re(n),{userId:o,passwordAuth:i,recovery2Id:a,recovery2Auth:s}=r;if(null!=o&&null==i){const e=t.getLoginByUserId(o);if(null==e)return fl(tl);const{loginId:n,passwordAuthSnrp:r=Tn}=e;return pl(xt({loginId:n,passwordAuthSnrp:r}))}if(null!=a&&null==s){const e=t.getLoginByRecovery2Id(a);if(null==e)return fl(tl);const{question2Box:n}=e;return null==n?fl(tl):pl(kt({question2Box:n}))}return fl(al)});function El(e,t){const{db:n,json:r}=e,o=new Date,[i,a]=ll(Re,r);if(null==i)return a;const[s,c]=ll(Ye,i.data);if(null==s)return c;const[u,l]=ll(ze,i.data);if(null==u)return l;if(null!=n.getLoginById(s.loginId))return fl(el);const d=me(He,()=>({allowExisting:!1,newSyncKeys:[],keyBoxes:[]}))(i.data);for(const p of d.newSyncKeys)n.repos.set(p,{});const f=bl(bl(bl(bl(bl(bl(bl({},s),u),{},{created:o,keyBoxes:d.keyBoxes.map(e=>bl(bl({},e),{},{created:o})),vouchers:[]},me(Be)(i.data)),me(Ke)(i.data)),me(Fe)(i.data)),me(Ge)(i.data)),me(qe)(i.data));if(null!=t){if(null!=n.getLoginsByParent(t).find(e=>e.appId===s.appId))return fl(ul);f.parentId=t.loginId}return n.insertLogin(f),fl(il,"Account created")}const Sl=ml(e=>El(e,e.login),e=>El(e)),Ol=ml(e=>{const{db:t,login:n,payload:r}=e,o=new Date,[i,a]=ll(He,r);if(null==i)return a;for(const s of i.newSyncKeys)t.repos.set(s,{});return n.keyBoxes=bn(n.keyBoxes,i.keyBoxes.map(e=>bl(bl({},e),{},{created:o}))),fl()}),Al=ml(e=>{const{login:t,payload:n}=e,[r,o]=ll(Be,n);return null==r?o:(t.otpKey=r.otpKey,t.otpTimeout=r.otpTimeout,t.otpResetDate=void 0,fl())}),Tl=ml(e=>{const{login:t}=e;return t.otpKey=void 0,t.otpResetAuth=void 0,t.otpResetDate=void 0,t.otpTimeout=void 0,fl()},e=>{const{db:t,json:n}=e,r=Re(n);if(null==r.userId||null==r.otpResetAuth)return fl(al);const o=t.getLoginByUserId(r.userId);if(null==o)return fl(tl);if(r.otpResetAuth!==o.otpResetAuth)return hl(0);const{otpKey:i,otpTimeout:a}=o;return null==i||null==a?fl(al,"OTP not setup for this account."):(null==o.otpResetDate&&(o.otpResetDate=new Date(Date.now()+1e3*a)),pl(Tt({otpResetDate:o.otpResetDate})))}),_l=ml(e=>{const{login:t}=e;return t.passwordAuth=void 0,t.passwordAuthBox=void 0,t.passwordAuthSnrp=void 0,t.passwordBox=void 0,t.passwordKeySnrp=void 0,fl()}),kl=ml(e=>{const{login:t,payload:n}=e,[r,o]=ll(Ke,n);return null==r?o:(t.passwordAuth=r.passwordAuth,t.passwordAuthBox=r.passwordAuthBox,t.passwordAuthSnrp=r.passwordAuthSnrp,t.passwordBox=r.passwordBox,t.passwordKeySnrp=r.passwordKeySnrp,fl())}),xl=ml(e=>{const{login:t}=e;return t.pin2Auth=void 0,t.pin2Box=void 0,t.pin2Id=void 0,t.pin2KeyBox=void 0,t.pin2TextBox=void 0,fl()}),Pl=ml(e=>{const{login:t,payload:n}=e,[r,o]=ll(Fe,n);return null==r?o:(t.pin2Auth=r.pin2Auth,t.pin2Box=r.pin2Box,t.pin2Id=r.pin2Id,t.pin2KeyBox=r.pin2KeyBox,t.pin2TextBox=r.pin2TextBox,fl())}),Ml=ml(e=>{const{login:t}=e;return t.question2Box=void 0,t.recovery2Auth=void 0,t.recovery2Box=void 0,t.recovery2Id=void 0,t.recovery2KeyBox=void 0,fl()}),Cl=ml(e=>{const{login:t,payload:n}=e,[r,o]=ll(Ge,n);return null==r?o:(t.question2Box=r.question2Box,t.recovery2Auth=r.recovery2Auth,t.recovery2Box=r.recovery2Box,t.recovery2Id=r.recovery2Id,t.recovery2KeyBox=r.recovery2KeyBox,fl())}),Nl=ml(e=>{const{db:t,login:n,payload:r}=e,[o,i]=ll(ze,r);return null==o?i:null!=n.loginAuth?fl(ol,"The secret-key login is already configured"):(n.loginAuth=o.loginAuth,n.loginAuthBox=o.loginAuthBox,pl(St(Vu(t,n))))}),jl=ml(async e=>{const{db:t,login:n,payload:r}=e,o=me(Ke)(r),i=me(Ue)(r),a=me(We)(r),s=me(qe)(r);if(null!=n.passwordAuth&&null==o)return fl(al,"Missing password payload");if(null!=n.pin2Auth&&null==i)return fl(al,"Missing pin2Id payload");if(null!=n.recovery2Auth&&null==a)return fl(al,"Missing recovery2Id payload");if(null==n.parentBox&&null==s)return fl(al,"Missing username payload");if(null!=o&&(n.passwordAuth=o.passwordAuth,n.passwordAuthBox=o.passwordAuthBox,n.passwordAuthSnrp=o.passwordAuthSnrp,n.passwordBox=o.passwordBox,n.passwordKeySnrp=o.passwordKeySnrp),null!=i){if(null==n.pin2Auth)return fl(al,"Login lacks pin2");if(null!=t.getLoginByPin2Id(i.pin2Id))return fl(ol);n.pin2Id=i.pin2Id}if(null!=a){if(null==n.recovery2Auth)return fl(al,"Login lacks recovery2");if(null!=t.getLoginByRecovery2Id(a.recovery2Id))return fl(ol);n.recovery2Id=a.recovery2Id}if(null!=s){if(null!=n.parentBox)return fl(al,"Only top-level logins can have usernames");if(null!=t.getLoginByUserId(s.userId))return fl(ol);n.userId=s.userId,n.userTextBox=s.userTextBox}return pl(St(Vu(t,n)))}),Dl=ml(async e=>{const{db:t,login:n,payload:r}=e,[o,i]=ll($e,r);if(null==o)return i;const{approvedVouchers:a=[],rejectedVouchers:s=[]}=o,c={};for(const u of a)c[u]="approved";for(const u of s)c[u]="rejected";for(const u of n.vouchers)null!=c[u.voucherId]&&(u.status=c[u.voucherId]);return pl(St(Vu(t,n)))}),Rl=e=>fl(cl,`Cannot find lobby ${e.lobbyId}`),Ll=(e,t=Rl)=>n=>{const{db:r,path:o}=n,i=o.split("/")[4],a=r.lobbies.get(i);return null!=a?e(bl(bl({},n),{},{lobby:a,lobbyId:i})):t(bl(bl({},n),{},{lobbyId:i}))},Bl=Ll(e=>fl(el,`Lobby ${e.lobbyId} already exists.`),e=>{const{db:t,json:n,lobbyId:r}=e,[o,i]=ll(Re,n);if(null==o)return i;const[a,s]=ll(Ne,o.data);if(null==a)return s;const{timeout:c=600}=a,u=new Date(Date.now()+1e3*c).toISOString();return t.lobbies.set(r,{request:a,replies:[],expires:u}),fl()}),Kl=Ll(e=>{const{json:t,lobby:n}=e,[r,o]=ll(Re,t);if(null==r)return o;const[i,a]=ll(je,r.data);return null==i?a:(n.replies.push(i),fl())}),Ul=Ll(e=>{const{lobby:t}=e;return pl(Et(t))}),Fl=Ll(e=>{const{db:t,lobbyId:n}=e;return t.lobbies.delete(n),fl()}),Wl=e=>t=>{const{db:n,path:r}=t,o=r.split("/")[4],i=n.repos.get(o);return null==i?dl({msg:"Hash not found"},{status:404}):e(bl(bl({},t),{},{repo:i}))},Gl=Wl(e=>{const{repo:t}=e;return dl({changes:jt(t)})}),zl=Wl(e=>{const{json:t,repo:n}=e,{changes:r}=ql(t);for(const o of Object.keys(r))n[o]=r[o];return dl({changes:jt(n),hash:"1111111111111111111111111111111111111111"})}),ql=we({changes:we(Pe)}),$l=S({"/api/v2/login/?":E({GET:gl(Il),POST:gl(Il)}),"/api/v2/login/create/?":E({POST:gl(Sl),PUT:gl(Sl)}),"/api/v2/login/keys/?":E({POST:gl(Ol)}),"/api/v2/login/otp/?":E({DELETE:gl(Tl),POST:gl(Al),PUT:gl(Al)}),"/api/v2/login/password/?":E({DELETE:gl(_l),POST:gl(kl),PUT:gl(kl)}),"/api/v2/login/pin2/?":E({DELETE:gl(xl),POST:gl(Pl),PUT:gl(Pl)}),"/api/v2/login/recovery2/?":E({DELETE:gl(Ml),POST:gl(Cl),PUT:gl(Cl)}),"/api/v2/login/secret/?":E({POST:gl(Nl)}),"/api/v2/login/username/?":E({POST:gl(jl)}),"/api/v2/login/vouchers/?":E({POST:gl(Dl)}),"/api/v2/messages/?":E({POST:gl(e=>{const{db:t,json:n}=e,[r,o]=ll(Re,n);if(null==r)return o;const{loginIds:i}=r;if(null==i)return fl(al);const a=[];for(const s of i){const e=t.getLoginById(s);null!=e&&a.push({loginId:s,otpResetPending:null!=e.otpResetDate,pendingVouchers:Ju(e),recovery2Corrupt:!1})}return pl(Ot(a))})}),"/api/v2/lobby/[^/]+/?":E({DELETE:gl(Fl),GET:gl(Ul),POST:gl(Kl),PUT:gl(Bl)}),"/api/v2/store/[^/]+/?":E({GET:Gl,POST:zl}),"/v1/edgeServers":E({GET:e=>dl({infoServers:["https://info-fake1.edge.app"],syncServers:["https://sync-fake1.edge.app","https://sync-fake2.edge.app","https://sync-fake3.edge.app"]})})},e=>fl(sl,`Unknown API endpoint ${e.path}`));function Hl(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Yl(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Hl(Object(n),!0).forEach(function(t){r(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Hl(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}async function Vl(e,t){const{lastLogin:n,server:r}=t,o=g(t.loginId),i=g(t.loginKey),a=Hn({appId:"",lastLogin:n,loginId:o,pendingVouchers:[],username:null==t.username?void 0:ae(t.username)},i,Qe(r)),s=`logins/${Lt.stringify(o)}.json`;await e.disklet.setText(s,JSON.stringify(Rn(a))).catch(()=>{})}async function Jl(e,t,n){const r=uo(e,{dataKey:new Uint8Array(0),syncKey:t});await fo(r.dataDisklet,n),await r.baseDisklet.setText("status.json",JSON.stringify({lastSync:1,lastHash:null}))}function Xl(e,t,n){const{io:r,nativeIo:o}=e,i=new Yu,a=function(e){const t=gn(n=>{if(t.offline)throw new Error("Fake network error");const r=n.body.byteLength>0?JSON.parse(Bt.stringify(new Uint8Array(n.body))):{};return $l(bl(bl({},n),{},{db:e,json:r}))},{offline:!1});return t}(i);for(const u of n){i.setupLogin(Ct(u.server));for(const e of Object.keys(u.repos))i.setupRepo(e,Pt(u.repos[e]))}const s=[],c={async close(){await Promise.all(s.map(e=>e.close())),F(c)},async makeEdgeContext(e){const{allowNetworkAccess:i=!1,cleanDevice:c=!1,extraFiles:u={}}=e,l=m(a),d=i?(e,t)=>function(e){try{const{hostname:t}=new URL(e);return/^(login|info|sync)[a-z0-9-]*\.edge(test)?\.app$/i.test(t)}catch(t){return!1}}(e)?l(e,t):r.fetch(e,t):l,f=Yl(Yl({},r),{},{disklet:(0,re.cQ)(),fetch:d});if(!c)for(const t of n){await Vl(f,t);for(const e of Object.keys(t.repos))await Jl(f,p(e),Pt(t.repos[e]))}if(null!=u)for(const t of Object.keys(u))await f.disklet.setText(t,u[t]);const h=await Gu({io:f,nativeIo:o},t,Yl({},e));return s.push(h),h},async goOffline(e=!0){a.offline=e},async dumpFakeUser(e){if(""!==e.appId)throw new Error("Only root logins are dumpable.");const t=Lt.parse(e.rootLoginId),n=Lt.parse(await e.getLoginKey()),r=i.getLoginById(t);if(null==r)throw new Error(`Cannot find user ${e.rootLoginId}`);const o=[];for(const i of e.allKeys){const t=await e.getRawPrivateKey(i.id);null!=t.syncKey&&o.push(h(g(t.syncKey)).toLowerCase())}const a={};for(const s of o){const e=i.repos.get(s);null!=e&&(a[s]=jt(e))}return{lastLogin:e.lastLogin,loginId:w(t),loginKey:w(n),repos:a,server:Nt(i.dumpLogin(r)),username:e.username}}};return P(c),c}function Zl(e){return function(t){return new Worker(e,t)}}var Ql=Zl(new URL(n(3437),n.b));const ed=Symbol("Comlink.proxy"),td=Symbol("Comlink.endpoint"),nd=Symbol("Comlink.releaseProxy"),rd=Symbol("Comlink.finalizer"),od=Symbol("Comlink.thrown"),id=e=>"object"==typeof e&&null!==e||"function"==typeof e,ad=new Map([["proxy",{canHandle:e=>id(e)&&e[ed],serialize(e){const{port1:t,port2:n}=new MessageChannel;return sd(e,t),[n,[n]]},deserialize(e){return e.start(),ud(e)}}],["throw",{canHandle:e=>id(e)&&od in e,serialize({value:e}){let t;return t=e instanceof Error?{isError:!0,value:{message:e.message,name:e.name,stack:e.stack}}:{isError:!1,value:e},[t,[]]},deserialize(e){if(e.isError)throw Object.assign(new Error(e.value.message),e.value);throw e.value}}]]);function sd(e,t=globalThis,n=["*"]){t.addEventListener("message",function r(o){if(!o||!o.data)return;if(!function(e,t){for(const n of e){if(t===n||"*"===n)return!0;if(n instanceof RegExp&&n.test(t))return!0}return!1}(n,o.origin))return void console.warn(`Invalid origin '${o.origin}' for comlink proxy`);const{id:i,type:a,path:s}=Object.assign({path:[]},o.data),c=(o.data.argumentList||[]).map(wd);let u;try{const t=s.slice(0,-1).reduce((e,t)=>e[t],e),n=s.reduce((e,t)=>e[t],e);switch(a){case"GET":u=n;break;case"SET":t[s.slice(-1)[0]]=wd(o.data.value),u=!0;break;case"APPLY":u=n.apply(t,c);break;case"CONSTRUCT":u=function(e){return Object.assign(e,{[ed]:!0})}(new n(...c));break;case"ENDPOINT":{const{port1:t,port2:n}=new MessageChannel;sd(e,n),u=function(e,t){return bd.set(e,t),e}(t,[t])}break;case"RELEASE":u=void 0;break;default:return}}catch(l){u={value:l,[od]:0}}Promise.resolve(u).catch(e=>({value:e,[od]:0})).then(n=>{const[o,s]=gd(n);t.postMessage(Object.assign(Object.assign({},o),{id:i}),s),"RELEASE"===a&&(t.removeEventListener("message",r),cd(t),rd in e&&"function"==typeof e[rd]&&e[rd]())}).catch(e=>{const[n,r]=gd({value:new TypeError("Unserializable return value"),[od]:0});t.postMessage(Object.assign(Object.assign({},n),{id:i}),r)})}),t.start&&t.start()}function cd(e){(function(e){return"MessagePort"===e.constructor.name})(e)&&e.close()}function ud(e,t){const n=new Map;return e.addEventListener("message",function(e){const{data:t}=e;if(!t||!t.id)return;const r=n.get(t.id);if(r)try{r(t)}finally{n.delete(t.id)}}),hd(e,n,[],t)}function ld(e){if(e)throw new Error("Proxy has been released and is not useable")}function dd(e){return vd(e,new Map,{type:"RELEASE"}).then(()=>{cd(e)})}const fd=new WeakMap,pd="FinalizationRegistry"in globalThis&&new FinalizationRegistry(e=>{const t=(fd.get(e)||0)-1;fd.set(e,t),0===t&&dd(e)});function hd(e,t,n=[],r=function(){}){let o=!1;const i=new Proxy(r,{get(r,a){if(ld(o),a===nd)return()=>{!function(e){pd&&pd.unregister(e)}(i),dd(e),t.clear(),o=!0};if("then"===a){if(0===n.length)return{then:()=>i};const r=vd(e,t,{type:"GET",path:n.map(e=>e.toString())}).then(wd);return r.then.bind(r)}return hd(e,t,[...n,a])},set(r,i,a){ld(o);const[s,c]=gd(a);return vd(e,t,{type:"SET",path:[...n,i].map(e=>e.toString()),value:s},c).then(wd)},apply(r,i,a){ld(o);const s=n[n.length-1];if(s===td)return vd(e,t,{type:"ENDPOINT"}).then(wd);if("bind"===s)return hd(e,t,n.slice(0,-1));const[c,u]=yd(a);return vd(e,t,{type:"APPLY",path:n.map(e=>e.toString()),argumentList:c},u).then(wd)},construct(r,i){ld(o);const[a,s]=yd(i);return vd(e,t,{type:"CONSTRUCT",path:n.map(e=>e.toString()),argumentList:a},s).then(wd)}});return function(e,t){const n=(fd.get(t)||0)+1;fd.set(t,n),pd&&pd.register(e,t,e)}(i,e),i}function yd(e){const t=e.map(gd);return[t.map(e=>e[0]),(n=t.map(e=>e[1]),Array.prototype.concat.apply([],n))];var n}const bd=new WeakMap;function gd(e){for(const[t,n]of ad)if(n.canHandle(e)){const[r,o]=n.serialize(e);return[{type:"HANDLER",name:t,value:r},o]}return[{type:"RAW",value:e},bd.get(e)||[]]}function wd(e){switch(e.type){case"HANDLER":return ad.get(e.name).deserialize(e.value);case"RAW":return e.value}}function vd(e,t,n,r){return new Promise(o=>{const i=new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-");t.set(i,o),e.start&&e.start(),e.postMessage(Object.assign({id:i},n),r)})}var md;!function(e){e.Loaded="Loaded"}(md||(md={}));const Id=async()=>{const e=ud(await(async()=>new Promise((e,t)=>{const n=new Ql({type:"module"});n.addEventListener("error",t),n.addEventListener("message",r=>{n.removeEventListener("error",t),r.data?.kind===md.Loaded?e(n):t(r)},{once:!0})}))());return{setupMixFetch:e.setupMixFetch,mixFetch:async(t,n)=>{const r=await e.mixFetch(t,n);if(!r)throw new Error("No response received");console.log({workerResponse:r});const{headers:o,status:i,statusText:a}=r,s=(e=>{const t=new Headers;return Object.keys(e).forEach(n=>{t.append(n,e[n])}),t})(o);if(r.body.blobUrl){const e=await(await fetch(r.body.blobUrl)).blob(),t=await e.arrayBuffer();return new Response(t,{headers:s,status:i,statusText:a})}const c=Object.values(r.body)[0];return new Response(c,{headers:s,status:i,statusText:a})},disconnectMixFetch:e.disconnectMixFetch}},Ed=async e=>{if(!window)throw new Error("`window` is not defined");return window.__mixFetchGlobal||(window.__mixFetchGlobal=await Id(),await window.__mixFetchGlobal.setupMixFetch(e),window.onunload=async()=>{window.__mixFetchGlobal&&await window.__mixFetchGlobal.disconnectMixFetch()}),window.__mixFetchGlobal},Sd={clientId:"edge-core-js-2026-03-10",preferredGateway:"5rXcNe2a44vXisK3uqLHCzpzvEwcnsijDMU7hg4fcYk8",preferredNetworkRequester:"5x6q9UfVHs5AohKMUqeivj7a556kVVy7QwoKige8xHxh.6CFoB3kJaDbYz6oafPJxNxNjzahpT2NtgtytcSyN9EvF@5rXcNe2a44vXisK3uqLHCzpzvEwcnsijDMU7hg4fcYk8",forceTls:!0,mixFetchOverride:{requestTimeoutMs:3e5}};let Od=null;async function Ad(e){if(null==Od){e("Initializing mixFetch...");const t=Ed(Sd);let n;t.catch(()=>{});const r=new Promise((e,t)=>{n=setTimeout(()=>{t(new Error("mixFetch setup timed out after 60000ms"))},6e4)});Od=Promise.race([t,r]).then(t=>(e("mixFetch initialized successfully"),t)).catch(async t=>{try{await(async()=>{if(!window)throw new Error("`window` is not defined");if(window.__mixFetchGlobal)return window.__mixFetchGlobal.disconnectMixFetch();throw new Error("mixFetch hasn't been setup")})()}catch(n){}throw delete window.__mixFetchGlobal,Od=null,e.error("mixFetch initialization failed:",t),t}).finally(()=>{clearTimeout(n)})}return(await Od).mixFetch}const Td=["allKeys","displayPrivateSeed","displayPublicSeed","keys","otpKey","loginKey","publicWalletInfo","recoveryKey"];function _d(e){const t=function(){const e={resolve(){},reject(){}};let t=0;if("undefined"!=typeof Map){const n=new Map;return{add(e){const r=++t;return n.set(r,e),r},grab(t){const r=n.get(t);return null==r?e:(n.delete(t),r)}}}const n={};return{add(e){const r=++t;return n[String(r)]=e,r},grab(t){const r=n[String(t)];return null==r?e:(delete n[String(t)],r)}}}();return{call(n,...r){return new Promise((o,i)=>{e(t.add({resolve:o,reject:i}),n,r)})},resolve(e,n){t.grab(e).resolve(n)},reject(e,n){t.grab(e).reject(new Error(n))}}}function kd(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function xd(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?kd(Object(n),!0).forEach(function(t){r(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):kd(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}const Pd=new Map,[Md,Cd]=null!=window.edgeCore?[_d((e,t,n)=>{window.edgeCore.call(e,t,JSON.stringify(n))}),new Z({hideProperties:Td,sendMessage(e){window.edgeCore.postMessage(JSON.stringify(e))},throttleMs:50})]:[_d((e,t,n)=>{window.webkit.messageHandlers.edgeCore.postMessage([e,t,n])}),new Z({hideProperties:Td,sendMessage(e){window.webkit.messageHandlers.edgeCore.postMessage([0,"postMessage",[JSON.stringify(e)]])},throttleMs:50})];function Nd(e){const{head:t}=window.document;if(null==t||0===e.length)return void Xr();let n=0;const r=()=>{++n>=e.length&&Xr()};for(const o of e){const e=document.createElement("script");e.addEventListener("error",r),e.addEventListener("load",r),e.charset="utf-8",e.defer=!0,e.src=o,t.appendChild(e)}}async function jd(e){const t=Lr(e,"react-native-io"),n=new(s())({hash:i().sha256,entropy:g(await Md.call("randomBytes",32))}),r=async(e,t={})=>{const{method:n="GET",headers:r={},body:o}=t,i=await Md.call("fetch",e,n,r,o instanceof ArrayBuffer?w(new Uint8Array(o)):o,o instanceof ArrayBuffer);return I({status:i.status,headers:i.headers,body:i.bodyIsBase64?g(i.body):i.body})},o={disklet:{delete(e){return Md.call("diskletDelete",Dd(e))},async getData(e){const t=await Md.call("diskletGetData",Dd(e));return g(t)},getText(e){return Md.call("diskletGetText",Dd(e))},list(e=""){return Md.call("diskletList",Dd(e))},setData(e,t){return Md.call("diskletSetData",Dd(e),w(t))},setText(e,t){return Md.call("diskletSetText",Dd(e),t)}},random:e=>n.generate(e),async scrypt(e,t,n,r,o,i){const a=await Md.call("scrypt",w(e),w(t),n,r,o,i);return g(a)},async fetch(e,n){var o;const{corsBypass:i="auto",privacy:a="none"}=null!=n?n:{};if("nym"===a){const r=await Ad(t);return await r(e,xd(xd({},n),{},{mode:"unsafe-ignore-cors"}),Sd)}if("always"===i)return await r(e,n);if("never"===i)return await window.fetch(e,n);const{protocol:s,host:c,pathname:u}=new URL(e),l=`${s}//${c}${u}`,d=null!==(o=Pd.get(l))&&void 0!==o?o:{windowSuccess:!1,nativeSuccess:!1};if(Pd.has(l)||Pd.set(l,d),!d.nativeSuccess)try{const t=await window.fetch(e,n);return d.windowSuccess=!0,t}catch(p){if(d.windowSuccess)throw p}const f=await r(e,n);return d.nativeSuccess=!0,f},async fetchCors(e,t={}){return await o.fetch(e,t)}};return o}function Dd(e){if(/^\//.test(e))throw new Error("Absolute paths are not supported");const t=e.split("/");let n=0,r=0;for(;n<t.length;){const e=t[n++];if(".."===e?r--:"."!==e&&""!==e&&(t[r++]=e),r<0)throw new Error("Path would escape folder")}return t.slice(0,r).join("/")}window.addEdgeCorePlugins=function(e){if(Yr)throw new Error("The Edge core plugin list has already been locked");for(const t of Object.keys(e))Hr[t]=e[t];for(const t of Vr)t(e)},window.nativeBridge=Md,window.reactBridge=Cd;const Rd=P({async makeEdgeContext(e,t,n,r){Nd(n);const o=await jd(t);return await Gu({io:o,nativeIo:e},t,r)},async makeFakeEdgeWorld(e,t,n,r=[]){Nd(n);return Xl({io:await jd(t),nativeIo:e},t,r)}});Cd.sendRoot(Rd)}()}();
|
|
2
|
+
!function(){var e={220:function(e,t,n){"use strict";var r=n(9404),o=n(7011),i=o.assert,a=o.cachedProperty,s=o.parseBytes;function c(e,t){this.eddsa=e,"object"!=typeof t&&(t=s(t)),Array.isArray(t)&&(t={R:t.slice(0,e.encodingLength),S:t.slice(e.encodingLength)}),i(t.R&&t.S,"Signature without R or S"),e.isPoint(t.R)&&(this._R=t.R),t.S instanceof r&&(this._S=t.S),this._Rencoded=Array.isArray(t.R)?t.R:t.Rencoded,this._Sencoded=Array.isArray(t.S)?t.S:t.Sencoded}a(c,"S",function(){return this.eddsa.decodeInt(this.Sencoded())}),a(c,"R",function(){return this.eddsa.decodePoint(this.Rencoded())}),a(c,"Rencoded",function(){return this.eddsa.encodePoint(this.R())}),a(c,"Sencoded",function(){return this.eddsa.encodeInt(this.S())}),c.prototype.toBytes=function(){return this.Rencoded().concat(this.Sencoded())},c.prototype.toHex=function(){return o.encode(this.toBytes(),"hex").toUpperCase()},e.exports=c},370:function(e,t,n){"use strict";var r=n(9404),o=n(6698),i=n(6677),a=n(7011);function s(e){i.call(this,"mont",e),this.a=new r(e.a,16).toRed(this.red),this.b=new r(e.b,16).toRed(this.red),this.i4=new r(4).toRed(this.red).redInvm(),this.two=new r(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}function c(e,t,n){i.BasePoint.call(this,e,"projective"),null===t&&null===n?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new r(t,16),this.z=new r(n,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}o(s,i),e.exports=s,s.prototype.validate=function(e){var t=e.normalize().x,n=t.redSqr(),r=n.redMul(t).redAdd(n.redMul(this.a)).redAdd(t);return 0===r.redSqrt().redSqr().cmp(r)},o(c,i.BasePoint),s.prototype.decodePoint=function(e,t){return this.point(a.toArray(e,t),1)},s.prototype.point=function(e,t){return new c(this,e,t)},s.prototype.pointFromJSON=function(e){return c.fromJSON(this,e)},c.prototype.precompute=function(){},c.prototype._encode=function(){return this.getX().toArray("be",this.curve.p.byteLength())},c.fromJSON=function(e,t){return new c(e,t[0],t[1]||e.one)},c.prototype.inspect=function(){return this.isInfinity()?"<EC Point Infinity>":"<EC Point x: "+this.x.fromRed().toString(16,2)+" z: "+this.z.fromRed().toString(16,2)+">"},c.prototype.isInfinity=function(){return 0===this.z.cmpn(0)},c.prototype.dbl=function(){var e=this.x.redAdd(this.z).redSqr(),t=this.x.redSub(this.z).redSqr(),n=e.redSub(t),r=e.redMul(t),o=n.redMul(t.redAdd(this.curve.a24.redMul(n)));return this.curve.point(r,o)},c.prototype.add=function(){throw new Error("Not supported on Montgomery curve")},c.prototype.diffAdd=function(e,t){var n=this.x.redAdd(this.z),r=this.x.redSub(this.z),o=e.x.redAdd(e.z),i=e.x.redSub(e.z).redMul(n),a=o.redMul(r),s=t.z.redMul(i.redAdd(a).redSqr()),c=t.x.redMul(i.redISub(a).redSqr());return this.curve.point(s,c)},c.prototype.mul=function(e){for(var t=e.clone(),n=this,r=this.curve.point(null,null),o=[];0!==t.cmpn(0);t.iushrn(1))o.push(t.andln(1));for(var i=o.length-1;i>=0;i--)0===o[i]?(n=n.diffAdd(r,this),r=r.dbl()):(r=n.diffAdd(r,this),n=n.dbl());return r},c.prototype.mulAdd=function(){throw new Error("Not supported on Montgomery curve")},c.prototype.jumlAdd=function(){throw new Error("Not supported on Montgomery curve")},c.prototype.eq=function(e){return 0===this.getX().cmp(e.getX())},c.prototype.normalize=function(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this},c.prototype.getX=function(){return this.normalize(),this.x.fromRed()}},480:function(e,t,n){"use strict";var r,o=t,i=n(7952),a=n(894),s=n(7011).assert;function c(e){"short"===e.type?this.curve=new a.short(e):"edwards"===e.type?this.curve=new a.edwards(e):this.curve=new a.mont(e),this.g=this.curve.g,this.n=this.curve.n,this.hash=e.hash,s(this.g.validate(),"Invalid curve"),s(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}function u(e,t){Object.defineProperty(o,e,{configurable:!0,enumerable:!0,get:function(){var n=new c(t);return Object.defineProperty(o,e,{configurable:!0,enumerable:!0,value:n}),n}})}o.PresetCurve=c,u("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:i.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),u("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:i.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),u("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:i.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),u("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:i.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"]}),u("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:i.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"]}),u("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:i.sha256,gRed:!1,g:["9"]}),u("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:i.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});try{r=n(4011)}catch(l){r=void 0}u("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:i.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",r]})},726:function(e){var t=e.exports=function(e,n){if("function"==typeof e||n)return t.by(e,n);for(var r={object:[],function:[],string:{},number:{},boolean:{},undefined:{}},o=[],i=0;i<e.length;i++){var a=e[i],s="__proto__"===a?r.objects:r[typeof a]||r.objects;Array.isArray(s)?s.indexOf(a)<0&&(s.push(a),o.push(a)):Object.hasOwnProperty.call(s,a)||(s[a]=!0,o.push(a))}return o};t.by=function(e,t){if("function"==typeof e){var n=t;t=e,e=n}for(var r=[],o=0;o<e.length;o++){for(var i=e[o],a=!1,s=0;s<r.length;s++){var c=r[s];if(t.call(r,i,c)){a=!0;break}}a||r.push(i)}return r}},894:function(e,t,n){"use strict";var r=t;r.base=n(6677),r.short=n(9188),r.mont=n(370),r.edwards=n(1298)},1200:function(e,t,n){"use strict";var r=n(9404),o=n(7011).assert;function i(e,t){this.ec=e,this.priv=null,this.pub=null,t.priv&&this._importPrivate(t.priv,t.privEnc),t.pub&&this._importPublic(t.pub,t.pubEnc)}e.exports=i,i.fromPublic=function(e,t,n){return t instanceof i?t:new i(e,{pub:t,pubEnc:n})},i.fromPrivate=function(e,t,n){return t instanceof i?t:new i(e,{priv:t,privEnc:n})},i.prototype.validate=function(){var e=this.getPublic();return e.isInfinity()?{result:!1,reason:"Invalid public key"}:e.validate()?e.mul(this.ec.curve.n).isInfinity()?{result:!0,reason:null}:{result:!1,reason:"Public key * N != O"}:{result:!1,reason:"Public key is not a point"}},i.prototype.getPublic=function(e,t){return"string"==typeof e&&(t=e,e=null),this.pub||(this.pub=this.ec.g.mul(this.priv)),t?this.pub.encode(t,e):this.pub},i.prototype.getPrivate=function(e){return"hex"===e?this.priv.toString(16,2):this.priv},i.prototype._importPrivate=function(e,t){this.priv=new r(e,t||16),this.priv=this.priv.umod(this.ec.curve.n)},i.prototype._importPublic=function(e,t){if(e.x||e.y)return"mont"===this.ec.curve.type?o(e.x,"Need x coordinate"):"short"!==this.ec.curve.type&&"edwards"!==this.ec.curve.type||o(e.x&&e.y,"Need both x and y coordinate"),void(this.pub=this.ec.curve.point(e.x,e.y));this.pub=this.ec.curve.decodePoint(e,t)},i.prototype.derive=function(e){return e.validate()||o(e.validate(),"public point not validated"),e.mul(this.priv).getX()},i.prototype.sign=function(e,t,n){return this.ec.sign(e,this,t,n)},i.prototype.verify=function(e,t){return this.ec.verify(e,t,this)},i.prototype.inspect=function(){return"<Key priv: "+(this.priv&&this.priv.toString(16,2))+" pub: "+(this.pub&&this.pub.inspect())+" >"}},1298:function(e,t,n){"use strict";var r=n(7011),o=n(9404),i=n(6698),a=n(6677),s=r.assert;function c(e){this.twisted=1!=(0|e.a),this.mOneA=this.twisted&&-1==(0|e.a),this.extended=this.mOneA,a.call(this,"edwards",e),this.a=new o(e.a,16).umod(this.red.m),this.a=this.a.toRed(this.red),this.c=new o(e.c,16).toRed(this.red),this.c2=this.c.redSqr(),this.d=new o(e.d,16).toRed(this.red),this.dd=this.d.redAdd(this.d),s(!this.twisted||0===this.c.fromRed().cmpn(1)),this.oneC=1==(0|e.c)}function u(e,t,n,r,i){a.BasePoint.call(this,e,"projective"),null===t&&null===n&&null===r?(this.x=this.curve.zero,this.y=this.curve.one,this.z=this.curve.one,this.t=this.curve.zero,this.zOne=!0):(this.x=new o(t,16),this.y=new o(n,16),this.z=r?new o(r,16):this.curve.one,this.t=i&&new o(i,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.t&&!this.t.red&&(this.t=this.t.toRed(this.curve.red)),this.zOne=this.z===this.curve.one,this.curve.extended&&!this.t&&(this.t=this.x.redMul(this.y),this.zOne||(this.t=this.t.redMul(this.z.redInvm()))))}i(c,a),e.exports=c,c.prototype._mulA=function(e){return this.mOneA?e.redNeg():this.a.redMul(e)},c.prototype._mulC=function(e){return this.oneC?e:this.c.redMul(e)},c.prototype.jpoint=function(e,t,n,r){return this.point(e,t,n,r)},c.prototype.pointFromX=function(e,t){(e=new o(e,16)).red||(e=e.toRed(this.red));var n=e.redSqr(),r=this.c2.redSub(this.a.redMul(n)),i=this.one.redSub(this.c2.redMul(this.d).redMul(n)),a=r.redMul(i.redInvm()),s=a.redSqrt();if(0!==s.redSqr().redSub(a).cmp(this.zero))throw new Error("invalid point");var c=s.fromRed().isOdd();return(t&&!c||!t&&c)&&(s=s.redNeg()),this.point(e,s)},c.prototype.pointFromY=function(e,t){(e=new o(e,16)).red||(e=e.toRed(this.red));var n=e.redSqr(),r=n.redSub(this.c2),i=n.redMul(this.d).redMul(this.c2).redSub(this.a),a=r.redMul(i.redInvm());if(0===a.cmp(this.zero)){if(t)throw new Error("invalid point");return this.point(this.zero,e)}var s=a.redSqrt();if(0!==s.redSqr().redSub(a).cmp(this.zero))throw new Error("invalid point");return s.fromRed().isOdd()!==t&&(s=s.redNeg()),this.point(s,e)},c.prototype.validate=function(e){if(e.isInfinity())return!0;e.normalize();var t=e.x.redSqr(),n=e.y.redSqr(),r=t.redMul(this.a).redAdd(n),o=this.c2.redMul(this.one.redAdd(this.d.redMul(t).redMul(n)));return 0===r.cmp(o)},i(u,a.BasePoint),c.prototype.pointFromJSON=function(e){return u.fromJSON(this,e)},c.prototype.point=function(e,t,n,r){return new u(this,e,t,n,r)},u.fromJSON=function(e,t){return new u(e,t[0],t[1],t[2])},u.prototype.inspect=function(){return this.isInfinity()?"<EC Point Infinity>":"<EC Point x: "+this.x.fromRed().toString(16,2)+" y: "+this.y.fromRed().toString(16,2)+" z: "+this.z.fromRed().toString(16,2)+">"},u.prototype.isInfinity=function(){return 0===this.x.cmpn(0)&&(0===this.y.cmp(this.z)||this.zOne&&0===this.y.cmp(this.curve.c))},u.prototype._extDbl=function(){var e=this.x.redSqr(),t=this.y.redSqr(),n=this.z.redSqr();n=n.redIAdd(n);var r=this.curve._mulA(e),o=this.x.redAdd(this.y).redSqr().redISub(e).redISub(t),i=r.redAdd(t),a=i.redSub(n),s=r.redSub(t),c=o.redMul(a),u=i.redMul(s),l=o.redMul(s),d=a.redMul(i);return this.curve.point(c,u,d,l)},u.prototype._projDbl=function(){var e,t,n,r,o,i,a=this.x.redAdd(this.y).redSqr(),s=this.x.redSqr(),c=this.y.redSqr();if(this.curve.twisted){var u=(r=this.curve._mulA(s)).redAdd(c);this.zOne?(e=a.redSub(s).redSub(c).redMul(u.redSub(this.curve.two)),t=u.redMul(r.redSub(c)),n=u.redSqr().redSub(u).redSub(u)):(o=this.z.redSqr(),i=u.redSub(o).redISub(o),e=a.redSub(s).redISub(c).redMul(i),t=u.redMul(r.redSub(c)),n=u.redMul(i))}else r=s.redAdd(c),o=this.curve._mulC(this.z).redSqr(),i=r.redSub(o).redSub(o),e=this.curve._mulC(a.redISub(r)).redMul(i),t=this.curve._mulC(r).redMul(s.redISub(c)),n=r.redMul(i);return this.curve.point(e,t,n)},u.prototype.dbl=function(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()},u.prototype._extAdd=function(e){var t=this.y.redSub(this.x).redMul(e.y.redSub(e.x)),n=this.y.redAdd(this.x).redMul(e.y.redAdd(e.x)),r=this.t.redMul(this.curve.dd).redMul(e.t),o=this.z.redMul(e.z.redAdd(e.z)),i=n.redSub(t),a=o.redSub(r),s=o.redAdd(r),c=n.redAdd(t),u=i.redMul(a),l=s.redMul(c),d=i.redMul(c),f=a.redMul(s);return this.curve.point(u,l,f,d)},u.prototype._projAdd=function(e){var t,n,r=this.z.redMul(e.z),o=r.redSqr(),i=this.x.redMul(e.x),a=this.y.redMul(e.y),s=this.curve.d.redMul(i).redMul(a),c=o.redSub(s),u=o.redAdd(s),l=this.x.redAdd(this.y).redMul(e.x.redAdd(e.y)).redISub(i).redISub(a),d=r.redMul(c).redMul(l);return this.curve.twisted?(t=r.redMul(u).redMul(a.redSub(this.curve._mulA(i))),n=c.redMul(u)):(t=r.redMul(u).redMul(a.redSub(i)),n=this.curve._mulC(c).redMul(u)),this.curve.point(d,t,n)},u.prototype.add=function(e){return this.isInfinity()?e:e.isInfinity()?this:this.curve.extended?this._extAdd(e):this._projAdd(e)},u.prototype.mul=function(e){return this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve._wnafMul(this,e)},u.prototype.mulAdd=function(e,t,n){return this.curve._wnafMulAdd(1,[this,t],[e,n],2,!1)},u.prototype.jmulAdd=function(e,t,n){return this.curve._wnafMulAdd(1,[this,t],[e,n],2,!0)},u.prototype.normalize=function(){if(this.zOne)return this;var e=this.z.redInvm();return this.x=this.x.redMul(e),this.y=this.y.redMul(e),this.t&&(this.t=this.t.redMul(e)),this.z=this.curve.one,this.zOne=!0,this},u.prototype.neg=function(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())},u.prototype.getX=function(){return this.normalize(),this.x.fromRed()},u.prototype.getY=function(){return this.normalize(),this.y.fromRed()},u.prototype.eq=function(e){return this===e||0===this.getX().cmp(e.getX())&&0===this.getY().cmp(e.getY())},u.prototype.eqXToP=function(e){var t=e.toRed(this.curve.red).redMul(this.z);if(0===this.x.cmp(t))return!0;for(var n=e.clone(),r=this.curve.redN.redMul(this.z);;){if(n.iadd(this.curve.n),n.cmp(this.curve.p)>=0)return!1;if(t.redIAdd(r),0===this.x.cmp(t))return!0}},u.prototype.toP=u.prototype.normalize,u.prototype.mixedAdd=u.prototype.add},1395:function(){},1636:function(e){"use strict";e.exports={rE:"6.5.4"}},1911:function(e,t,n){"use strict";var r=n(7426),o=n(7766);function i(){if(!(this instanceof i))return new i;o.call(this),this.h=[3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]}r.inherits(i,o),e.exports=i,i.blockSize=1024,i.outSize=384,i.hmacStrength=192,i.padLength=128,i.prototype._digest=function(e){return"hex"===e?r.toHex32(this.h.slice(0,12),"big"):r.split32(this.h.slice(0,12),"big")}},2287:function(e,t,n){"use strict";var r=n(7426),o=n(6166),i=n(6225),a=n(3349),s=r.sum32,c=r.sum32_4,u=r.sum32_5,l=i.ch32,d=i.maj32,f=i.s0_256,p=i.s1_256,h=i.g0_256,y=i.g1_256,b=o.BlockHash,g=[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];function w(){if(!(this instanceof w))return new w;b.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=g,this.W=new Array(64)}r.inherits(w,b),e.exports=w,w.blockSize=512,w.outSize=256,w.hmacStrength=192,w.padLength=64,w.prototype._update=function(e,t){for(var n=this.W,r=0;r<16;r++)n[r]=e[t+r];for(;r<n.length;r++)n[r]=c(y(n[r-2]),n[r-7],h(n[r-15]),n[r-16]);var o=this.h[0],i=this.h[1],b=this.h[2],g=this.h[3],w=this.h[4],v=this.h[5],m=this.h[6],I=this.h[7];for(a(this.k.length===n.length),r=0;r<n.length;r++){var E=u(I,p(w),l(w,v,m),this.k[r],n[r]),S=s(f(o),d(o,i,b));I=m,m=v,v=w,w=s(g,E),g=b,b=i,i=o,o=s(E,S)}this.h[0]=s(this.h[0],o),this.h[1]=s(this.h[1],i),this.h[2]=s(this.h[2],b),this.h[3]=s(this.h[3],g),this.h[4]=s(this.h[4],w),this.h[5]=s(this.h[5],v),this.h[6]=s(this.h[6],m),this.h[7]=s(this.h[7],I)},w.prototype._digest=function(e){return"hex"===e?r.toHex32(this.h,"big"):r.split32(this.h,"big")}},2723:function(e,t,n){"use strict";var r=n(7952),o=n(4367),i=n(3349);function a(e){if(!(this instanceof a))return new a(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=o.toArray(e.entropy,e.entropyEnc||"hex"),n=o.toArray(e.nonce,e.nonceEnc||"hex"),r=o.toArray(e.pers,e.persEnc||"hex");i(t.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(t,n,r)}e.exports=a,a.prototype._init=function(e,t,n){var r=e.concat(t).concat(n);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var o=0;o<this.V.length;o++)this.K[o]=0,this.V[o]=1;this._update(r),this._reseed=1,this.reseedInterval=281474976710656},a.prototype._hmac=function(){return new r.hmac(this.hash,this.K)},a.prototype._update=function(e){var t=this._hmac().update(this.V).update([0]);e&&(t=t.update(e)),this.K=t.digest(),this.V=this._hmac().update(this.V).digest(),e&&(this.K=this._hmac().update(this.V).update([1]).update(e).digest(),this.V=this._hmac().update(this.V).digest())},a.prototype.reseed=function(e,t,n,r){"string"!=typeof t&&(r=n,n=t,t=null),e=o.toArray(e,t),n=o.toArray(n,r),i(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(e.concat(n||[])),this._reseed=1},a.prototype.generate=function(e,t,n,r){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");"string"!=typeof t&&(r=n,n=t,t=null),n&&(n=o.toArray(n,r||"hex"),this._update(n));for(var i=[];i.length<e;)this.V=this._hmac().update(this.V).digest(),i=i.concat(this.V);var a=i.slice(0,e);return this._update(n),this._reseed++,o.encode(a,t)}},3349:function(e){function t(e,t){if(!e)throw new Error(t||"Assertion failed")}e.exports=t,t.equal=function(e,t,n){if(e!=t)throw new Error(n||"Assertion failed: "+e+" != "+t)}},3437:function(e,t,n){"use strict";e.exports=n.p+"fbcba1e9b05cb4dd9870.js"},3776:function(e){e.exports=function(e){for(var t={},n=e.length,r=e.charAt(0),o=0;o<e.length;o++)t[e.charAt(o)]=o;function i(e){if(0===e.length)return[];for(var o=[0],i=0;i<e.length;i++){var a=t[e[i]];if(void 0===a)return;for(var s=0,c=a;s<o.length;++s)c+=o[s]*n,o[s]=255&c,c>>=8;for(;c>0;)o.push(255&c),c>>=8}for(var u=0;e[u]===r&&u<e.length-1;++u)o.push(0);return o.reverse()}return{encode:function(t){if(0===t.length)return"";for(var r=[0],o=0;o<t.length;++o){for(var i=0,a=t[o];i<r.length;++i)a+=r[i]<<8,r[i]=a%n,a=a/n|0;for(;a>0;)r.push(a%n),a=a/n|0}for(var s="",c=0;0===t[c]&&c<t.length-1;++c)s+=e[0];for(var u=r.length-1;u>=0;--u)s+=e[r[u]];return s},decodeUnsafe:i,decode:function(e){var t=i(e);if(t)return t;throw new Error("Non-base"+n+" character")}}}},3836:function(e){"use strict";!function(){function t(e){return parseInt(e)===e}function n(e){if(!t(e.length))return!1;for(var n=0;n<e.length;n++)if(!t(e[n])||e[n]<0||e[n]>255)return!1;return!0}function r(e,r){if(e.buffer&&ArrayBuffer.isView(e)&&"Uint8Array"===e.name)return r&&(e=e.slice?e.slice():Array.prototype.slice.call(e)),e;if(Array.isArray(e)){if(!n(e))throw new Error("Array contains invalid value: "+e);return new Uint8Array(e)}if(t(e.length)&&n(e))return new Uint8Array(e);throw new Error("unsupported array-like object")}function o(e){return new Uint8Array(e)}function i(e,t,n,r,o){null==r&&null==o||(e=e.slice?e.slice(r,o):Array.prototype.slice.call(e,r,o)),t.set(e,n)}var a,s={toBytes:function(e){var t=[],n=0;for(e=encodeURI(e);n<e.length;){var o=e.charCodeAt(n++);37===o?(t.push(parseInt(e.substr(n,2),16)),n+=2):t.push(o)}return r(t)},fromBytes:function(e){for(var t=[],n=0;n<e.length;){var r=e[n];r<128?(t.push(String.fromCharCode(r)),n++):r>191&&r<224?(t.push(String.fromCharCode((31&r)<<6|63&e[n+1])),n+=2):(t.push(String.fromCharCode((15&r)<<12|(63&e[n+1])<<6|63&e[n+2])),n+=3)}return t.join("")}},c=(a="0123456789abcdef",{toBytes:function(e){for(var t=[],n=0;n<e.length;n+=2)t.push(parseInt(e.substr(n,2),16));return t},fromBytes:function(e){for(var t=[],n=0;n<e.length;n++){var r=e[n];t.push(a[(240&r)>>4]+a[15&r])}return t.join("")}}),u={16:10,24:12,32:14},l=[1,2,4,8,16,32,64,128,27,54,108,216,171,77,154,47,94,188,99,198,151,53,106,212,179,125,250,239,197,145],d=[99,124,119,123,242,107,111,197,48,1,103,43,254,215,171,118,202,130,201,125,250,89,71,240,173,212,162,175,156,164,114,192,183,253,147,38,54,63,247,204,52,165,229,241,113,216,49,21,4,199,35,195,24,150,5,154,7,18,128,226,235,39,178,117,9,131,44,26,27,110,90,160,82,59,214,179,41,227,47,132,83,209,0,237,32,252,177,91,106,203,190,57,74,76,88,207,208,239,170,251,67,77,51,133,69,249,2,127,80,60,159,168,81,163,64,143,146,157,56,245,188,182,218,33,16,255,243,210,205,12,19,236,95,151,68,23,196,167,126,61,100,93,25,115,96,129,79,220,34,42,144,136,70,238,184,20,222,94,11,219,224,50,58,10,73,6,36,92,194,211,172,98,145,149,228,121,231,200,55,109,141,213,78,169,108,86,244,234,101,122,174,8,186,120,37,46,28,166,180,198,232,221,116,31,75,189,139,138,112,62,181,102,72,3,246,14,97,53,87,185,134,193,29,158,225,248,152,17,105,217,142,148,155,30,135,233,206,85,40,223,140,161,137,13,191,230,66,104,65,153,45,15,176,84,187,22],f=[82,9,106,213,48,54,165,56,191,64,163,158,129,243,215,251,124,227,57,130,155,47,255,135,52,142,67,68,196,222,233,203,84,123,148,50,166,194,35,61,238,76,149,11,66,250,195,78,8,46,161,102,40,217,36,178,118,91,162,73,109,139,209,37,114,248,246,100,134,104,152,22,212,164,92,204,93,101,182,146,108,112,72,80,253,237,185,218,94,21,70,87,167,141,157,132,144,216,171,0,140,188,211,10,247,228,88,5,184,179,69,6,208,44,30,143,202,63,15,2,193,175,189,3,1,19,138,107,58,145,17,65,79,103,220,234,151,242,207,206,240,180,230,115,150,172,116,34,231,173,53,133,226,249,55,232,28,117,223,110,71,241,26,113,29,41,197,137,111,183,98,14,170,24,190,27,252,86,62,75,198,210,121,32,154,219,192,254,120,205,90,244,31,221,168,51,136,7,199,49,177,18,16,89,39,128,236,95,96,81,127,169,25,181,74,13,45,229,122,159,147,201,156,239,160,224,59,77,174,42,245,176,200,235,187,60,131,83,153,97,23,43,4,126,186,119,214,38,225,105,20,99,85,33,12,125],p=[3328402341,4168907908,4000806809,4135287693,4294111757,3597364157,3731845041,2445657428,1613770832,33620227,3462883241,1445669757,3892248089,3050821474,1303096294,3967186586,2412431941,528646813,2311702848,4202528135,4026202645,2992200171,2387036105,4226871307,1101901292,3017069671,1604494077,1169141738,597466303,1403299063,3832705686,2613100635,1974974402,3791519004,1033081774,1277568618,1815492186,2118074177,4126668546,2211236943,1748251740,1369810420,3521504564,4193382664,3799085459,2883115123,1647391059,706024767,134480908,2512897874,1176707941,2646852446,806885416,932615841,168101135,798661301,235341577,605164086,461406363,3756188221,3454790438,1311188841,2142417613,3933566367,302582043,495158174,1479289972,874125870,907746093,3698224818,3025820398,1537253627,2756858614,1983593293,3084310113,2108928974,1378429307,3722699582,1580150641,327451799,2790478837,3117535592,0,3253595436,1075847264,3825007647,2041688520,3059440621,3563743934,2378943302,1740553945,1916352843,2487896798,2555137236,2958579944,2244988746,3151024235,3320835882,1336584933,3992714006,2252555205,2588757463,1714631509,293963156,2319795663,3925473552,67240454,4269768577,2689618160,2017213508,631218106,1269344483,2723238387,1571005438,2151694528,93294474,1066570413,563977660,1882732616,4059428100,1673313503,2008463041,2950355573,1109467491,537923632,3858759450,4260623118,3218264685,2177748300,403442708,638784309,3287084079,3193921505,899127202,2286175436,773265209,2479146071,1437050866,4236148354,2050833735,3362022572,3126681063,840505643,3866325909,3227541664,427917720,2655997905,2749160575,1143087718,1412049534,999329963,193497219,2353415882,3354324521,1807268051,672404540,2816401017,3160301282,369822493,2916866934,3688947771,1681011286,1949973070,336202270,2454276571,201721354,1210328172,3093060836,2680341085,3184776046,1135389935,3294782118,965841320,831886756,3554993207,4068047243,3588745010,2345191491,1849112409,3664604599,26054028,2983581028,2622377682,1235855840,3630984372,2891339514,4092916743,3488279077,3395642799,4101667470,1202630377,268961816,1874508501,4034427016,1243948399,1546530418,941366308,1470539505,1941222599,2546386513,3421038627,2715671932,3899946140,1042226977,2521517021,1639824860,227249030,260737669,3765465232,2084453954,1907733956,3429263018,2420656344,100860677,4160157185,470683154,3261161891,1781871967,2924959737,1773779408,394692241,2579611992,974986535,664706745,3655459128,3958962195,731420851,571543859,3530123707,2849626480,126783113,865375399,765172662,1008606754,361203602,3387549984,2278477385,2857719295,1344809080,2782912378,59542671,1503764984,160008576,437062935,1707065306,3622233649,2218934982,3496503480,2185314755,697932208,1512910199,504303377,2075177163,2824099068,1841019862,739644986],h=[2781242211,2230877308,2582542199,2381740923,234877682,3184946027,2984144751,1418839493,1348481072,50462977,2848876391,2102799147,434634494,1656084439,3863849899,2599188086,1167051466,2636087938,1082771913,2281340285,368048890,3954334041,3381544775,201060592,3963727277,1739838676,4250903202,3930435503,3206782108,4149453988,2531553906,1536934080,3262494647,484572669,2923271059,1783375398,1517041206,1098792767,49674231,1334037708,1550332980,4098991525,886171109,150598129,2481090929,1940642008,1398944049,1059722517,201851908,1385547719,1699095331,1587397571,674240536,2704774806,252314885,3039795866,151914247,908333586,2602270848,1038082786,651029483,1766729511,3447698098,2682942837,454166793,2652734339,1951935532,775166490,758520603,3000790638,4004797018,4217086112,4137964114,1299594043,1639438038,3464344499,2068982057,1054729187,1901997871,2534638724,4121318227,1757008337,0,750906861,1614815264,535035132,3363418545,3988151131,3201591914,1183697867,3647454910,1265776953,3734260298,3566750796,3903871064,1250283471,1807470800,717615087,3847203498,384695291,3313910595,3617213773,1432761139,2484176261,3481945413,283769337,100925954,2180939647,4037038160,1148730428,3123027871,3813386408,4087501137,4267549603,3229630528,2315620239,2906624658,3156319645,1215313976,82966005,3747855548,3245848246,1974459098,1665278241,807407632,451280895,251524083,1841287890,1283575245,337120268,891687699,801369324,3787349855,2721421207,3431482436,959321879,1469301956,4065699751,2197585534,1199193405,2898814052,3887750493,724703513,2514908019,2696962144,2551808385,3516813135,2141445340,1715741218,2119445034,2872807568,2198571144,3398190662,700968686,3547052216,1009259540,2041044702,3803995742,487983883,1991105499,1004265696,1449407026,1316239930,504629770,3683797321,168560134,1816667172,3837287516,1570751170,1857934291,4014189740,2797888098,2822345105,2754712981,936633572,2347923833,852879335,1133234376,1500395319,3084545389,2348912013,1689376213,3533459022,3762923945,3034082412,4205598294,133428468,634383082,2949277029,2398386810,3913789102,403703816,3580869306,2297460856,1867130149,1918643758,607656988,4049053350,3346248884,1368901318,600565992,2090982877,2632479860,557719327,3717614411,3697393085,2249034635,2232388234,2430627952,1115438654,3295786421,2865522278,3633334344,84280067,33027830,303828494,2747425121,1600795957,4188952407,3496589753,2434238086,1486471617,658119965,3106381470,953803233,334231800,3005978776,857870609,3151128937,1890179545,2298973838,2805175444,3056442267,574365214,2450884487,550103529,1233637070,4289353045,2018519080,2057691103,2399374476,4166623649,2148108681,387583245,3664101311,836232934,3330556482,3100665960,3280093505,2955516313,2002398509,287182607,3413881008,4238890068,3597515707,975967766],y=[1671808611,2089089148,2006576759,2072901243,4061003762,1807603307,1873927791,3310653893,810573872,16974337,1739181671,729634347,4263110654,3613570519,2883997099,1989864566,3393556426,2191335298,3376449993,2106063485,4195741690,1508618841,1204391495,4027317232,2917941677,3563566036,2734514082,2951366063,2629772188,2767672228,1922491506,3227229120,3082974647,4246528509,2477669779,644500518,911895606,1061256767,4144166391,3427763148,878471220,2784252325,3845444069,4043897329,1905517169,3631459288,827548209,356461077,67897348,3344078279,593839651,3277757891,405286936,2527147926,84871685,2595565466,118033927,305538066,2157648768,3795705826,3945188843,661212711,2999812018,1973414517,152769033,2208177539,745822252,439235610,455947803,1857215598,1525593178,2700827552,1391895634,994932283,3596728278,3016654259,695947817,3812548067,795958831,2224493444,1408607827,3513301457,0,3979133421,543178784,4229948412,2982705585,1542305371,1790891114,3410398667,3201918910,961245753,1256100938,1289001036,1491644504,3477767631,3496721360,4012557807,2867154858,4212583931,1137018435,1305975373,861234739,2241073541,1171229253,4178635257,33948674,2139225727,1357946960,1011120188,2679776671,2833468328,1374921297,2751356323,1086357568,2408187279,2460827538,2646352285,944271416,4110742005,3168756668,3066132406,3665145818,560153121,271589392,4279952895,4077846003,3530407890,3444343245,202643468,322250259,3962553324,1608629855,2543990167,1154254916,389623319,3294073796,2817676711,2122513534,1028094525,1689045092,1575467613,422261273,1939203699,1621147744,2174228865,1339137615,3699352540,577127458,712922154,2427141008,2290289544,1187679302,3995715566,3100863416,339486740,3732514782,1591917662,186455563,3681988059,3762019296,844522546,978220090,169743370,1239126601,101321734,611076132,1558493276,3260915650,3547250131,2901361580,1655096418,2443721105,2510565781,3828863972,2039214713,3878868455,3359869896,928607799,1840765549,2374762893,3580146133,1322425422,2850048425,1823791212,1459268694,4094161908,3928346602,1706019429,2056189050,2934523822,135794696,3134549946,2022240376,628050469,779246638,472135708,2800834470,3032970164,3327236038,3894660072,3715932637,1956440180,522272287,1272813131,3185336765,2340818315,2323976074,1888542832,1044544574,3049550261,1722469478,1222152264,50660867,4127324150,236067854,1638122081,895445557,1475980887,3117443513,2257655686,3243809217,489110045,2662934430,3778599393,4162055160,2561878936,288563729,1773916777,3648039385,2391345038,2493985684,2612407707,505560094,2274497927,3911240169,3460925390,1442818645,678973480,3749357023,2358182796,2717407649,2306869641,219617805,3218761151,3862026214,1120306242,1756942440,1103331905,2578459033,762796589,252780047,2966125488,1425844308,3151392187,372911126],b=[1667474886,2088535288,2004326894,2071694838,4075949567,1802223062,1869591006,3318043793,808472672,16843522,1734846926,724270422,4278065639,3621216949,2880169549,1987484396,3402253711,2189597983,3385409673,2105378810,4210693615,1499065266,1195886990,4042263547,2913856577,3570689971,2728590687,2947541573,2627518243,2762274643,1920112356,3233831835,3082273397,4261223649,2475929149,640051788,909531756,1061110142,4160160501,3435941763,875846760,2779116625,3857003729,4059105529,1903268834,3638064043,825316194,353713962,67374088,3351728789,589522246,3284360861,404236336,2526454071,84217610,2593830191,117901582,303183396,2155911963,3806477791,3958056653,656894286,2998062463,1970642922,151591698,2206440989,741110872,437923380,454765878,1852748508,1515908788,2694904667,1381168804,993742198,3604373943,3014905469,690584402,3823320797,791638366,2223281939,1398011302,3520161977,0,3991743681,538992704,4244381667,2981218425,1532751286,1785380564,3419096717,3200178535,960056178,1246420628,1280103576,1482221744,3486468741,3503319995,4025428677,2863326543,4227536621,1128514950,1296947098,859002214,2240123921,1162203018,4193849577,33687044,2139062782,1347481760,1010582648,2678045221,2829640523,1364325282,2745433693,1077985408,2408548869,2459086143,2644360225,943212656,4126475505,3166494563,3065430391,3671750063,555836226,269496352,4294908645,4092792573,3537006015,3452783745,202118168,320025894,3974901699,1600119230,2543297077,1145359496,387397934,3301201811,2812801621,2122220284,1027426170,1684319432,1566435258,421079858,1936954854,1616945344,2172753945,1330631070,3705438115,572679748,707427924,2425400123,2290647819,1179044492,4008585671,3099120491,336870440,3739122087,1583276732,185277718,3688593069,3772791771,842159716,976899700,168435220,1229577106,101059084,606366792,1549591736,3267517855,3553849021,2897014595,1650632388,2442242105,2509612081,3840161747,2038008818,3890688725,3368567691,926374254,1835907034,2374863873,3587531953,1313788572,2846482505,1819063512,1448540844,4109633523,3941213647,1701162954,2054852340,2930698567,134748176,3132806511,2021165296,623210314,774795868,471606328,2795958615,3031746419,3334885783,3907527627,3722280097,1953799400,522133822,1263263126,3183336545,2341176845,2324333839,1886425312,1044267644,3048588401,1718004428,1212733584,50529542,4143317495,235803164,1633788866,892690282,1465383342,3115962473,2256965911,3250673817,488449850,2661202215,3789633753,4177007595,2560144171,286339874,1768537042,3654906025,2391705863,2492770099,2610673197,505291324,2273808917,3924369609,3469625735,1431699370,673740880,3755965093,2358021891,2711746649,2307489801,218961690,3217021541,3873845719,1111672452,1751693520,1094828930,2576986153,757954394,252645662,2964376443,1414855848,3149649517,370555436],g=[1374988112,2118214995,437757123,975658646,1001089995,530400753,2902087851,1273168787,540080725,2910219766,2295101073,4110568485,1340463100,3307916247,641025152,3043140495,3736164937,632953703,1172967064,1576976609,3274667266,2169303058,2370213795,1809054150,59727847,361929877,3211623147,2505202138,3569255213,1484005843,1239443753,2395588676,1975683434,4102977912,2572697195,666464733,3202437046,4035489047,3374361702,2110667444,1675577880,3843699074,2538681184,1649639237,2976151520,3144396420,4269907996,4178062228,1883793496,2403728665,2497604743,1383856311,2876494627,1917518562,3810496343,1716890410,3001755655,800440835,2261089178,3543599269,807962610,599762354,33778362,3977675356,2328828971,2809771154,4077384432,1315562145,1708848333,101039829,3509871135,3299278474,875451293,2733856160,92987698,2767645557,193195065,1080094634,1584504582,3178106961,1042385657,2531067453,3711829422,1306967366,2438237621,1908694277,67556463,1615861247,429456164,3602770327,2302690252,1742315127,2968011453,126454664,3877198648,2043211483,2709260871,2084704233,4169408201,0,159417987,841739592,504459436,1817866830,4245618683,260388950,1034867998,908933415,168810852,1750902305,2606453969,607530554,202008497,2472011535,3035535058,463180190,2160117071,1641816226,1517767529,470948374,3801332234,3231722213,1008918595,303765277,235474187,4069246893,766945465,337553864,1475418501,2943682380,4003061179,2743034109,4144047775,1551037884,1147550661,1543208500,2336434550,3408119516,3069049960,3102011747,3610369226,1113818384,328671808,2227573024,2236228733,3535486456,2935566865,3341394285,496906059,3702665459,226906860,2009195472,733156972,2842737049,294930682,1206477858,2835123396,2700099354,1451044056,573804783,2269728455,3644379585,2362090238,2564033334,2801107407,2776292904,3669462566,1068351396,742039012,1350078989,1784663195,1417561698,4136440770,2430122216,775550814,2193862645,2673705150,1775276924,1876241833,3475313331,3366754619,270040487,3902563182,3678124923,3441850377,1851332852,3969562369,2203032232,3868552805,2868897406,566021896,4011190502,3135740889,1248802510,3936291284,699432150,832877231,708780849,3332740144,899835584,1951317047,4236429990,3767586992,866637845,4043610186,1106041591,2144161806,395441711,1984812685,1139781709,3433712980,3835036895,2664543715,1282050075,3240894392,1181045119,2640243204,25965917,4203181171,4211818798,3009879386,2463879762,3910161971,1842759443,2597806476,933301370,1509430414,3943906441,3467192302,3076639029,3776767469,2051518780,2631065433,1441952575,404016761,1942435775,1408749034,1610459739,3745345300,2017778566,3400528769,3110650942,941896748,3265478751,371049330,3168937228,675039627,4279080257,967311729,135050206,3635733660,1683407248,2076935265,3576870512,1215061108,3501741890],w=[1347548327,1400783205,3273267108,2520393566,3409685355,4045380933,2880240216,2471224067,1428173050,4138563181,2441661558,636813900,4233094615,3620022987,2149987652,2411029155,1239331162,1730525723,2554718734,3781033664,46346101,310463728,2743944855,3328955385,3875770207,2501218972,3955191162,3667219033,768917123,3545789473,692707433,1150208456,1786102409,2029293177,1805211710,3710368113,3065962831,401639597,1724457132,3028143674,409198410,2196052529,1620529459,1164071807,3769721975,2226875310,486441376,2499348523,1483753576,428819965,2274680428,3075636216,598438867,3799141122,1474502543,711349675,129166120,53458370,2592523643,2782082824,4063242375,2988687269,3120694122,1559041666,730517276,2460449204,4042459122,2706270690,3446004468,3573941694,533804130,2328143614,2637442643,2695033685,839224033,1973745387,957055980,2856345839,106852767,1371368976,4181598602,1033297158,2933734917,1179510461,3046200461,91341917,1862534868,4284502037,605657339,2547432937,3431546947,2003294622,3182487618,2282195339,954669403,3682191598,1201765386,3917234703,3388507166,0,2198438022,1211247597,2887651696,1315723890,4227665663,1443857720,507358933,657861945,1678381017,560487590,3516619604,975451694,2970356327,261314535,3535072918,2652609425,1333838021,2724322336,1767536459,370938394,182621114,3854606378,1128014560,487725847,185469197,2918353863,3106780840,3356761769,2237133081,1286567175,3152976349,4255350624,2683765030,3160175349,3309594171,878443390,1988838185,3704300486,1756818940,1673061617,3403100636,272786309,1075025698,545572369,2105887268,4174560061,296679730,1841768865,1260232239,4091327024,3960309330,3497509347,1814803222,2578018489,4195456072,575138148,3299409036,446754879,3629546796,4011996048,3347532110,3252238545,4270639778,915985419,3483825537,681933534,651868046,2755636671,3828103837,223377554,2607439820,1649704518,3270937875,3901806776,1580087799,4118987695,3198115200,2087309459,2842678573,3016697106,1003007129,2802849917,1860738147,2077965243,164439672,4100872472,32283319,2827177882,1709610350,2125135846,136428751,3874428392,3652904859,3460984630,3572145929,3593056380,2939266226,824852259,818324884,3224740454,930369212,2801566410,2967507152,355706840,1257309336,4148292826,243256656,790073846,2373340630,1296297904,1422699085,3756299780,3818836405,457992840,3099667487,2135319889,77422314,1560382517,1945798516,788204353,1521706781,1385356242,870912086,325965383,2358957921,2050466060,2388260884,2313884476,4006521127,901210569,3990953189,1014646705,1503449823,1062597235,2031621326,3212035895,3931371469,1533017514,350174575,2256028891,2177544179,1052338372,741876788,1606591296,1914052035,213705253,2334669897,1107234197,1899603969,3725069491,2631447780,2422494913,1635502980,1893020342,1950903388,1120974935],v=[2807058932,1699970625,2764249623,1586903591,1808481195,1173430173,1487645946,59984867,4199882800,1844882806,1989249228,1277555970,3623636965,3419915562,1149249077,2744104290,1514790577,459744698,244860394,3235995134,1963115311,4027744588,2544078150,4190530515,1608975247,2627016082,2062270317,1507497298,2200818878,567498868,1764313568,3359936201,2305455554,2037970062,1047239e3,1910319033,1337376481,2904027272,2892417312,984907214,1243112415,830661914,861968209,2135253587,2011214180,2927934315,2686254721,731183368,1750626376,4246310725,1820824798,4172763771,3542330227,48394827,2404901663,2871682645,671593195,3254988725,2073724613,145085239,2280796200,2779915199,1790575107,2187128086,472615631,3029510009,4075877127,3802222185,4107101658,3201631749,1646252340,4270507174,1402811438,1436590835,3778151818,3950355702,3963161475,4020912224,2667994737,273792366,2331590177,104699613,95345982,3175501286,2377486676,1560637892,3564045318,369057872,4213447064,3919042237,1137477952,2658625497,1119727848,2340947849,1530455833,4007360968,172466556,266959938,516552836,0,2256734592,3980931627,1890328081,1917742170,4294704398,945164165,3575528878,958871085,3647212047,2787207260,1423022939,775562294,1739656202,3876557655,2530391278,2443058075,3310321856,547512796,1265195639,437656594,3121275539,719700128,3762502690,387781147,218828297,3350065803,2830708150,2848461854,428169201,122466165,3720081049,1627235199,648017665,4122762354,1002783846,2117360635,695634755,3336358691,4234721005,4049844452,3704280881,2232435299,574624663,287343814,612205898,1039717051,840019705,2708326185,793451934,821288114,1391201670,3822090177,376187827,3113855344,1224348052,1679968233,2361698556,1058709744,752375421,2431590963,1321699145,3519142200,2734591178,188127444,2177869557,3727205754,2384911031,3215212461,2648976442,2450346104,3432737375,1180849278,331544205,3102249176,4150144569,2952102595,2159976285,2474404304,766078933,313773861,2570832044,2108100632,1668212892,3145456443,2013908262,418672217,3070356634,2594734927,1852171925,3867060991,3473416636,3907448597,2614737639,919489135,164948639,2094410160,2997825956,590424639,2486224549,1723872674,3157750862,3399941250,3501252752,3625268135,2555048196,3673637356,1343127501,4130281361,3599595085,2957853679,1297403050,81781910,3051593425,2283490410,532201772,1367295589,3926170974,895287692,1953757831,1093597963,492483431,3528626907,1446242576,1192455638,1636604631,209336225,344873464,1015671571,669961897,3375740769,3857572124,2973530695,3747192018,1933530610,3464042516,935293895,3454686199,2858115069,1863638845,3683022916,4085369519,3292445032,875313188,1080017571,3279033885,621591778,1233856572,2504130317,24197544,3017672716,3835484340,3247465558,2220981195,3060847922,1551124588,1463996600],m=[4104605777,1097159550,396673818,660510266,2875968315,2638606623,4200115116,3808662347,821712160,1986918061,3430322568,38544885,3856137295,718002117,893681702,1654886325,2975484382,3122358053,3926825029,4274053469,796197571,1290801793,1184342925,3556361835,2405426947,2459735317,1836772287,1381620373,3196267988,1948373848,3764988233,3385345166,3263785589,2390325492,1480485785,3111247143,3780097726,2293045232,548169417,3459953789,3746175075,439452389,1362321559,1400849762,1685577905,1806599355,2174754046,137073913,1214797936,1174215055,3731654548,2079897426,1943217067,1258480242,529487843,1437280870,3945269170,3049390895,3313212038,923313619,679998e3,3215307299,57326082,377642221,3474729866,2041877159,133361907,1776460110,3673476453,96392454,878845905,2801699524,777231668,4082475170,2330014213,4142626212,2213296395,1626319424,1906247262,1846563261,562755902,3708173718,1040559837,3871163981,1418573201,3294430577,114585348,1343618912,2566595609,3186202582,1078185097,3651041127,3896688048,2307622919,425408743,3371096953,2081048481,1108339068,2216610296,0,2156299017,736970802,292596766,1517440620,251657213,2235061775,2933202493,758720310,265905162,1554391400,1532285339,908999204,174567692,1474760595,4002861748,2610011675,3234156416,3693126241,2001430874,303699484,2478443234,2687165888,585122620,454499602,151849742,2345119218,3064510765,514443284,4044981591,1963412655,2581445614,2137062819,19308535,1928707164,1715193156,4219352155,1126790795,600235211,3992742070,3841024952,836553431,1669664834,2535604243,3323011204,1243905413,3141400786,4180808110,698445255,2653899549,2989552604,2253581325,3252932727,3004591147,1891211689,2487810577,3915653703,4237083816,4030667424,2100090966,865136418,1229899655,953270745,3399679628,3557504664,4118925222,2061379749,3079546586,2915017791,983426092,2022837584,1607244650,2118541908,2366882550,3635996816,972512814,3283088770,1568718495,3499326569,3576539503,621982671,2895723464,410887952,2623762152,1002142683,645401037,1494807662,2595684844,1335535747,2507040230,4293295786,3167684641,367585007,3885750714,1865862730,2668221674,2960971305,2763173681,1059270954,2777952454,2724642869,1320957812,2194319100,2429595872,2815956275,77089521,3973773121,3444575871,2448830231,1305906550,4021308739,2857194700,2516901860,3518358430,1787304780,740276417,1699839814,1592394909,2352307457,2272556026,188821243,1729977011,3687994002,274084841,3594982253,3613494426,2701949495,4162096729,322734571,2837966542,1640576439,484830689,1202797690,3537852828,4067639125,349075736,3342319475,4157467219,4255800159,1030690015,1155237496,2951971274,1757691577,607398968,2738905026,499347990,3794078908,1011452712,227885567,2818666809,213114376,3034881240,1455525988,3414450555,850817237,1817998408,3092726480],I=[0,235474187,470948374,303765277,941896748,908933415,607530554,708780849,1883793496,2118214995,1817866830,1649639237,1215061108,1181045119,1417561698,1517767529,3767586992,4003061179,4236429990,4069246893,3635733660,3602770327,3299278474,3400528769,2430122216,2664543715,2362090238,2193862645,2835123396,2801107407,3035535058,3135740889,3678124923,3576870512,3341394285,3374361702,3810496343,3977675356,4279080257,4043610186,2876494627,2776292904,3076639029,3110650942,2472011535,2640243204,2403728665,2169303058,1001089995,899835584,666464733,699432150,59727847,226906860,530400753,294930682,1273168787,1172967064,1475418501,1509430414,1942435775,2110667444,1876241833,1641816226,2910219766,2743034109,2976151520,3211623147,2505202138,2606453969,2302690252,2269728455,3711829422,3543599269,3240894392,3475313331,3843699074,3943906441,4178062228,4144047775,1306967366,1139781709,1374988112,1610459739,1975683434,2076935265,1775276924,1742315127,1034867998,866637845,566021896,800440835,92987698,193195065,429456164,395441711,1984812685,2017778566,1784663195,1683407248,1315562145,1080094634,1383856311,1551037884,101039829,135050206,437757123,337553864,1042385657,807962610,573804783,742039012,2531067453,2564033334,2328828971,2227573024,2935566865,2700099354,3001755655,3168937228,3868552805,3902563182,4203181171,4102977912,3736164937,3501741890,3265478751,3433712980,1106041591,1340463100,1576976609,1408749034,2043211483,2009195472,1708848333,1809054150,832877231,1068351396,766945465,599762354,159417987,126454664,361929877,463180190,2709260871,2943682380,3178106961,3009879386,2572697195,2538681184,2236228733,2336434550,3509871135,3745345300,3441850377,3274667266,3910161971,3877198648,4110568485,4211818798,2597806476,2497604743,2261089178,2295101073,2733856160,2902087851,3202437046,2968011453,3936291284,3835036895,4136440770,4169408201,3535486456,3702665459,3467192302,3231722213,2051518780,1951317047,1716890410,1750902305,1113818384,1282050075,1584504582,1350078989,168810852,67556463,371049330,404016761,841739592,1008918595,775550814,540080725,3969562369,3801332234,4035489047,4269907996,3569255213,3669462566,3366754619,3332740144,2631065433,2463879762,2160117071,2395588676,2767645557,2868897406,3102011747,3069049960,202008497,33778362,270040487,504459436,875451293,975658646,675039627,641025152,2084704233,1917518562,1615861247,1851332852,1147550661,1248802510,1484005843,1451044056,933301370,967311729,733156972,632953703,260388950,25965917,328671808,496906059,1206477858,1239443753,1543208500,1441952575,2144161806,1908694277,1675577880,1842759443,3610369226,3644379585,3408119516,3307916247,4011190502,3776767469,4077384432,4245618683,2809771154,2842737049,3144396420,3043140495,2673705150,2438237621,2203032232,2370213795],E=[0,185469197,370938394,487725847,741876788,657861945,975451694,824852259,1483753576,1400783205,1315723890,1164071807,1950903388,2135319889,1649704518,1767536459,2967507152,3152976349,2801566410,2918353863,2631447780,2547432937,2328143614,2177544179,3901806776,3818836405,4270639778,4118987695,3299409036,3483825537,3535072918,3652904859,2077965243,1893020342,1841768865,1724457132,1474502543,1559041666,1107234197,1257309336,598438867,681933534,901210569,1052338372,261314535,77422314,428819965,310463728,3409685355,3224740454,3710368113,3593056380,3875770207,3960309330,4045380933,4195456072,2471224067,2554718734,2237133081,2388260884,3212035895,3028143674,2842678573,2724322336,4138563181,4255350624,3769721975,3955191162,3667219033,3516619604,3431546947,3347532110,2933734917,2782082824,3099667487,3016697106,2196052529,2313884476,2499348523,2683765030,1179510461,1296297904,1347548327,1533017514,1786102409,1635502980,2087309459,2003294622,507358933,355706840,136428751,53458370,839224033,957055980,605657339,790073846,2373340630,2256028891,2607439820,2422494913,2706270690,2856345839,3075636216,3160175349,3573941694,3725069491,3273267108,3356761769,4181598602,4063242375,4011996048,3828103837,1033297158,915985419,730517276,545572369,296679730,446754879,129166120,213705253,1709610350,1860738147,1945798516,2029293177,1239331162,1120974935,1606591296,1422699085,4148292826,4233094615,3781033664,3931371469,3682191598,3497509347,3446004468,3328955385,2939266226,2755636671,3106780840,2988687269,2198438022,2282195339,2501218972,2652609425,1201765386,1286567175,1371368976,1521706781,1805211710,1620529459,2105887268,1988838185,533804130,350174575,164439672,46346101,870912086,954669403,636813900,788204353,2358957921,2274680428,2592523643,2441661558,2695033685,2880240216,3065962831,3182487618,3572145929,3756299780,3270937875,3388507166,4174560061,4091327024,4006521127,3854606378,1014646705,930369212,711349675,560487590,272786309,457992840,106852767,223377554,1678381017,1862534868,1914052035,2031621326,1211247597,1128014560,1580087799,1428173050,32283319,182621114,401639597,486441376,768917123,651868046,1003007129,818324884,1503449823,1385356242,1333838021,1150208456,1973745387,2125135846,1673061617,1756818940,2970356327,3120694122,2802849917,2887651696,2637442643,2520393566,2334669897,2149987652,3917234703,3799141122,4284502037,4100872472,3309594171,3460984630,3545789473,3629546796,2050466060,1899603969,1814803222,1730525723,1443857720,1560382517,1075025698,1260232239,575138148,692707433,878443390,1062597235,243256656,91341917,409198410,325965383,3403100636,3252238545,3704300486,3620022987,3874428392,3990953189,4042459122,4227665663,2460449204,2578018489,2226875310,2411029155,3198115200,3046200461,2827177882,2743944855],S=[0,218828297,437656594,387781147,875313188,958871085,775562294,590424639,1750626376,1699970625,1917742170,2135253587,1551124588,1367295589,1180849278,1265195639,3501252752,3720081049,3399941250,3350065803,3835484340,3919042237,4270507174,4085369519,3102249176,3051593425,2734591178,2952102595,2361698556,2177869557,2530391278,2614737639,3145456443,3060847922,2708326185,2892417312,2404901663,2187128086,2504130317,2555048196,3542330227,3727205754,3375740769,3292445032,3876557655,3926170974,4246310725,4027744588,1808481195,1723872674,1910319033,2094410160,1608975247,1391201670,1173430173,1224348052,59984867,244860394,428169201,344873464,935293895,984907214,766078933,547512796,1844882806,1627235199,2011214180,2062270317,1507497298,1423022939,1137477952,1321699145,95345982,145085239,532201772,313773861,830661914,1015671571,731183368,648017665,3175501286,2957853679,2807058932,2858115069,2305455554,2220981195,2474404304,2658625497,3575528878,3625268135,3473416636,3254988725,3778151818,3963161475,4213447064,4130281361,3599595085,3683022916,3432737375,3247465558,3802222185,4020912224,4172763771,4122762354,3201631749,3017672716,2764249623,2848461854,2331590177,2280796200,2431590963,2648976442,104699613,188127444,472615631,287343814,840019705,1058709744,671593195,621591778,1852171925,1668212892,1953757831,2037970062,1514790577,1463996600,1080017571,1297403050,3673637356,3623636965,3235995134,3454686199,4007360968,3822090177,4107101658,4190530515,2997825956,3215212461,2830708150,2779915199,2256734592,2340947849,2627016082,2443058075,172466556,122466165,273792366,492483431,1047239e3,861968209,612205898,695634755,1646252340,1863638845,2013908262,1963115311,1446242576,1530455833,1277555970,1093597963,1636604631,1820824798,2073724613,1989249228,1436590835,1487645946,1337376481,1119727848,164948639,81781910,331544205,516552836,1039717051,821288114,669961897,719700128,2973530695,3157750862,2871682645,2787207260,2232435299,2283490410,2667994737,2450346104,3647212047,3564045318,3279033885,3464042516,3980931627,3762502690,4150144569,4199882800,3070356634,3121275539,2904027272,2686254721,2200818878,2384911031,2570832044,2486224549,3747192018,3528626907,3310321856,3359936201,3950355702,3867060991,4049844452,4234721005,1739656202,1790575107,2108100632,1890328081,1402811438,1586903591,1233856572,1149249077,266959938,48394827,369057872,418672217,1002783846,919489135,567498868,752375421,209336225,24197544,376187827,459744698,945164165,895287692,574624663,793451934,1679968233,1764313568,2117360635,1933530610,1343127501,1560637892,1243112415,1192455638,3704280881,3519142200,3336358691,3419915562,3907448597,3857572124,4075877127,4294704398,3029510009,3113855344,2927934315,2744104290,2159976285,2377486676,2594734927,2544078150],O=[0,151849742,303699484,454499602,607398968,758720310,908999204,1059270954,1214797936,1097159550,1517440620,1400849762,1817998408,1699839814,2118541908,2001430874,2429595872,2581445614,2194319100,2345119218,3034881240,3186202582,2801699524,2951971274,3635996816,3518358430,3399679628,3283088770,4237083816,4118925222,4002861748,3885750714,1002142683,850817237,698445255,548169417,529487843,377642221,227885567,77089521,1943217067,2061379749,1640576439,1757691577,1474760595,1592394909,1174215055,1290801793,2875968315,2724642869,3111247143,2960971305,2405426947,2253581325,2638606623,2487810577,3808662347,3926825029,4044981591,4162096729,3342319475,3459953789,3576539503,3693126241,1986918061,2137062819,1685577905,1836772287,1381620373,1532285339,1078185097,1229899655,1040559837,923313619,740276417,621982671,439452389,322734571,137073913,19308535,3871163981,4021308739,4104605777,4255800159,3263785589,3414450555,3499326569,3651041127,2933202493,2815956275,3167684641,3049390895,2330014213,2213296395,2566595609,2448830231,1305906550,1155237496,1607244650,1455525988,1776460110,1626319424,2079897426,1928707164,96392454,213114376,396673818,514443284,562755902,679998e3,865136418,983426092,3708173718,3557504664,3474729866,3323011204,4180808110,4030667424,3945269170,3794078908,2507040230,2623762152,2272556026,2390325492,2975484382,3092726480,2738905026,2857194700,3973773121,3856137295,4274053469,4157467219,3371096953,3252932727,3673476453,3556361835,2763173681,2915017791,3064510765,3215307299,2156299017,2307622919,2459735317,2610011675,2081048481,1963412655,1846563261,1729977011,1480485785,1362321559,1243905413,1126790795,878845905,1030690015,645401037,796197571,274084841,425408743,38544885,188821243,3613494426,3731654548,3313212038,3430322568,4082475170,4200115116,3780097726,3896688048,2668221674,2516901860,2366882550,2216610296,3141400786,2989552604,2837966542,2687165888,1202797690,1320957812,1437280870,1554391400,1669664834,1787304780,1906247262,2022837584,265905162,114585348,499347990,349075736,736970802,585122620,972512814,821712160,2595684844,2478443234,2293045232,2174754046,3196267988,3079546586,2895723464,2777952454,3537852828,3687994002,3234156416,3385345166,4142626212,4293295786,3841024952,3992742070,174567692,57326082,410887952,292596766,777231668,660510266,1011452712,893681702,1108339068,1258480242,1343618912,1494807662,1715193156,1865862730,1948373848,2100090966,2701949495,2818666809,3004591147,3122358053,2235061775,2352307457,2535604243,2653899549,3915653703,3764988233,4219352155,4067639125,3444575871,3294430577,3746175075,3594982253,836553431,953270745,600235211,718002117,367585007,484830689,133361907,251657213,2041877159,1891211689,1806599355,1654886325,1568718495,1418573201,1335535747,1184342925];function A(e){for(var t=[],n=0;n<e.length;n+=4)t.push(e[n]<<24|e[n+1]<<16|e[n+2]<<8|e[n+3]);return t}var T=function(e){if(!(this instanceof T))throw Error("AES must be instanitated with `new`");Object.defineProperty(this,"key",{value:r(e,!0)}),this._prepare()};T.prototype._prepare=function(){var e=u[this.key.length];if(null==e)throw new Error("invalid key size (must be 16, 24 or 32 bytes)");this._Ke=[],this._Kd=[];for(var t=0;t<=e;t++)this._Ke.push([0,0,0,0]),this._Kd.push([0,0,0,0]);var n,r=4*(e+1),o=this.key.length/4,i=A(this.key);for(t=0;t<o;t++)n=t>>2,this._Ke[n][t%4]=i[t],this._Kd[e-n][t%4]=i[t];for(var a,s=0,c=o;c<r;){if(a=i[o-1],i[0]^=d[a>>16&255]<<24^d[a>>8&255]<<16^d[255&a]<<8^d[a>>24&255]^l[s]<<24,s+=1,8!=o)for(t=1;t<o;t++)i[t]^=i[t-1];else{for(t=1;t<o/2;t++)i[t]^=i[t-1];a=i[o/2-1],i[o/2]^=d[255&a]^d[a>>8&255]<<8^d[a>>16&255]<<16^d[a>>24&255]<<24;for(t=o/2+1;t<o;t++)i[t]^=i[t-1]}for(t=0;t<o&&c<r;)f=c>>2,p=c%4,this._Ke[f][p]=i[t],this._Kd[e-f][p]=i[t++],c++}for(var f=1;f<e;f++)for(var p=0;p<4;p++)a=this._Kd[f][p],this._Kd[f][p]=I[a>>24&255]^E[a>>16&255]^S[a>>8&255]^O[255&a]},T.prototype.encrypt=function(e){if(16!=e.length)throw new Error("invalid plaintext size (must be 16 bytes)");for(var t=this._Ke.length-1,n=[0,0,0,0],r=A(e),i=0;i<4;i++)r[i]^=this._Ke[0][i];for(var a=1;a<t;a++){for(i=0;i<4;i++)n[i]=p[r[i]>>24&255]^h[r[(i+1)%4]>>16&255]^y[r[(i+2)%4]>>8&255]^b[255&r[(i+3)%4]]^this._Ke[a][i];r=n.slice()}var s,c=o(16);for(i=0;i<4;i++)s=this._Ke[t][i],c[4*i]=255&(d[r[i]>>24&255]^s>>24),c[4*i+1]=255&(d[r[(i+1)%4]>>16&255]^s>>16),c[4*i+2]=255&(d[r[(i+2)%4]>>8&255]^s>>8),c[4*i+3]=255&(d[255&r[(i+3)%4]]^s);return c},T.prototype.decrypt=function(e){if(16!=e.length)throw new Error("invalid ciphertext size (must be 16 bytes)");for(var t=this._Kd.length-1,n=[0,0,0,0],r=A(e),i=0;i<4;i++)r[i]^=this._Kd[0][i];for(var a=1;a<t;a++){for(i=0;i<4;i++)n[i]=g[r[i]>>24&255]^w[r[(i+3)%4]>>16&255]^v[r[(i+2)%4]>>8&255]^m[255&r[(i+1)%4]]^this._Kd[a][i];r=n.slice()}var s,c=o(16);for(i=0;i<4;i++)s=this._Kd[t][i],c[4*i]=255&(f[r[i]>>24&255]^s>>24),c[4*i+1]=255&(f[r[(i+3)%4]>>16&255]^s>>16),c[4*i+2]=255&(f[r[(i+2)%4]>>8&255]^s>>8),c[4*i+3]=255&(f[255&r[(i+1)%4]]^s);return c};var _=function(e){if(!(this instanceof _))throw Error("AES must be instanitated with `new`");this.description="Electronic Code Block",this.name="ecb",this._aes=new T(e)};_.prototype.encrypt=function(e){if((e=r(e)).length%16!=0)throw new Error("invalid plaintext size (must be multiple of 16 bytes)");for(var t=o(e.length),n=o(16),a=0;a<e.length;a+=16)i(e,n,0,a,a+16),i(n=this._aes.encrypt(n),t,a);return t},_.prototype.decrypt=function(e){if((e=r(e)).length%16!=0)throw new Error("invalid ciphertext size (must be multiple of 16 bytes)");for(var t=o(e.length),n=o(16),a=0;a<e.length;a+=16)i(e,n,0,a,a+16),i(n=this._aes.decrypt(n),t,a);return t};var k=function(e,t){if(!(this instanceof k))throw Error("AES must be instanitated with `new`");if(this.description="Cipher Block Chaining",this.name="cbc",t){if(16!=t.length)throw new Error("invalid initialation vector size (must be 16 bytes)")}else t=o(16);this._lastCipherblock=r(t,!0),this._aes=new T(e)};k.prototype.encrypt=function(e){if((e=r(e)).length%16!=0)throw new Error("invalid plaintext size (must be multiple of 16 bytes)");for(var t=o(e.length),n=o(16),a=0;a<e.length;a+=16){i(e,n,0,a,a+16);for(var s=0;s<16;s++)n[s]^=this._lastCipherblock[s];this._lastCipherblock=this._aes.encrypt(n),i(this._lastCipherblock,t,a)}return t},k.prototype.decrypt=function(e){if((e=r(e)).length%16!=0)throw new Error("invalid ciphertext size (must be multiple of 16 bytes)");for(var t=o(e.length),n=o(16),a=0;a<e.length;a+=16){i(e,n,0,a,a+16),n=this._aes.decrypt(n);for(var s=0;s<16;s++)t[a+s]=n[s]^this._lastCipherblock[s];i(e,this._lastCipherblock,0,a,a+16)}return t};var x=function(e,t,n){if(!(this instanceof x))throw Error("AES must be instanitated with `new`");if(this.description="Cipher Feedback",this.name="cfb",t){if(16!=t.length)throw new Error("invalid initialation vector size (must be 16 size)")}else t=o(16);n||(n=1),this.segmentSize=n,this._shiftRegister=r(t,!0),this._aes=new T(e)};x.prototype.encrypt=function(e){if(e.length%this.segmentSize!=0)throw new Error("invalid plaintext size (must be segmentSize bytes)");for(var t,n=r(e,!0),o=0;o<n.length;o+=this.segmentSize){t=this._aes.encrypt(this._shiftRegister);for(var a=0;a<this.segmentSize;a++)n[o+a]^=t[a];i(this._shiftRegister,this._shiftRegister,0,this.segmentSize),i(n,this._shiftRegister,16-this.segmentSize,o,o+this.segmentSize)}return n},x.prototype.decrypt=function(e){if(e.length%this.segmentSize!=0)throw new Error("invalid ciphertext size (must be segmentSize bytes)");for(var t,n=r(e,!0),o=0;o<n.length;o+=this.segmentSize){t=this._aes.encrypt(this._shiftRegister);for(var a=0;a<this.segmentSize;a++)n[o+a]^=t[a];i(this._shiftRegister,this._shiftRegister,0,this.segmentSize),i(e,this._shiftRegister,16-this.segmentSize,o,o+this.segmentSize)}return n};var P=function(e,t){if(!(this instanceof P))throw Error("AES must be instanitated with `new`");if(this.description="Output Feedback",this.name="ofb",t){if(16!=t.length)throw new Error("invalid initialation vector size (must be 16 bytes)")}else t=o(16);this._lastPrecipher=r(t,!0),this._lastPrecipherIndex=16,this._aes=new T(e)};P.prototype.encrypt=function(e){for(var t=r(e,!0),n=0;n<t.length;n++)16===this._lastPrecipherIndex&&(this._lastPrecipher=this._aes.encrypt(this._lastPrecipher),this._lastPrecipherIndex=0),t[n]^=this._lastPrecipher[this._lastPrecipherIndex++];return t},P.prototype.decrypt=P.prototype.encrypt;var M=function(e){if(!(this instanceof M))throw Error("Counter must be instanitated with `new`");0===e||e||(e=1),"number"==typeof e?(this._counter=o(16),this.setValue(e)):this.setBytes(e)};M.prototype.setValue=function(e){if("number"!=typeof e||parseInt(e)!=e)throw new Error("invalid counter value (must be an integer)");if(e>Number.MAX_SAFE_INTEGER)throw new Error("integer value out of safe range");for(var t=15;t>=0;--t)this._counter[t]=e%256,e=parseInt(e/256)},M.prototype.setBytes=function(e){if(16!=(e=r(e,!0)).length)throw new Error("invalid counter bytes size (must be 16 bytes)");this._counter=e},M.prototype.increment=function(){for(var e=15;e>=0;e--){if(255!==this._counter[e]){this._counter[e]++;break}this._counter[e]=0}};var C=function(e,t){if(!(this instanceof C))throw Error("AES must be instanitated with `new`");this.description="Counter",this.name="ctr",t instanceof M||(t=new M(t)),this._counter=t,this._remainingCounter=null,this._remainingCounterIndex=16,this._aes=new T(e)};C.prototype.encrypt=function(e){for(var t=r(e,!0),n=0;n<t.length;n++)16===this._remainingCounterIndex&&(this._remainingCounter=this._aes.encrypt(this._counter._counter),this._remainingCounterIndex=0,this._counter.increment()),t[n]^=this._remainingCounter[this._remainingCounterIndex++];return t},C.prototype.decrypt=C.prototype.encrypt;var N={AES:T,Counter:M,ModeOfOperation:{ecb:_,cbc:k,cfb:x,ofb:P,ctr:C},utils:{hex:c,utf8:s},padding:{pkcs7:{pad:function(e){var t=16-(e=r(e,!0)).length%16,n=o(e.length+t);i(e,n);for(var a=e.length;a<n.length;a++)n[a]=t;return n},strip:function(e){if((e=r(e,!0)).length<16)throw new Error("PKCS#7 invalid length");var t=e[e.length-1];if(t>16)throw new Error("PKCS#7 padding byte out of range");for(var n=e.length-t,a=0;a<t;a++)if(e[n+a]!==t)throw new Error("PKCS#7 invalid padding byte");var s=o(n);return i(e,s,0,0,n),s}}},_arrayTest:{coerceArray:r,createArray:o,copyArray:i}};e.exports=N}()},3917:function(e,t,n){"use strict";var r=n(7426),o=n(6166),i=n(6225),a=r.rotl32,s=r.sum32,c=r.sum32_5,u=i.ft_1,l=o.BlockHash,d=[1518500249,1859775393,2400959708,3395469782];function f(){if(!(this instanceof f))return new f;l.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=new Array(80)}r.inherits(f,l),e.exports=f,f.blockSize=512,f.outSize=160,f.hmacStrength=80,f.padLength=64,f.prototype._update=function(e,t){for(var n=this.W,r=0;r<16;r++)n[r]=e[t+r];for(;r<n.length;r++)n[r]=a(n[r-3]^n[r-8]^n[r-14]^n[r-16],1);var o=this.h[0],i=this.h[1],l=this.h[2],f=this.h[3],p=this.h[4];for(r=0;r<n.length;r++){var h=~~(r/20),y=c(a(o,5),u(h,i,l,f),p,n[r],d[h]);p=f,f=l,l=a(i,30),i=o,o=y}this.h[0]=s(this.h[0],o),this.h[1]=s(this.h[1],i),this.h[2]=s(this.h[2],l),this.h[3]=s(this.h[3],f),this.h[4]=s(this.h[4],p)},f.prototype._digest=function(e){return"hex"===e?r.toHex32(this.h,"big"):r.split32(this.h,"big")}},4011:function(e){e.exports={doubles:{step:4,points:[["e60fce93b59e9ec53011aabc21c23e97b2a31369b87a5ae9c44ee89e2a6dec0a","f7e3507399e595929db99f34f57937101296891e44d23f0be1f32cce69616821"],["8282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508","11f8a8098557dfe45e8256e830b60ace62d613ac2f7b17bed31b6eaff6e26caf"],["175e159f728b865a72f99cc6c6fc846de0b93833fd2222ed73fce5b551e5b739","d3506e0d9e3c79eba4ef97a51ff71f5eacb5955add24345c6efa6ffee9fed695"],["363d90d447b00c9c99ceac05b6262ee053441c7e55552ffe526bad8f83ff4640","4e273adfc732221953b445397f3363145b9a89008199ecb62003c7f3bee9de9"],["8b4b5f165df3c2be8c6244b5b745638843e4a781a15bcd1b69f79a55dffdf80c","4aad0a6f68d308b4b3fbd7813ab0da04f9e336546162ee56b3eff0c65fd4fd36"],["723cbaa6e5db996d6bf771c00bd548c7b700dbffa6c0e77bcb6115925232fcda","96e867b5595cc498a921137488824d6e2660a0653779494801dc069d9eb39f5f"],["eebfa4d493bebf98ba5feec812c2d3b50947961237a919839a533eca0e7dd7fa","5d9a8ca3970ef0f269ee7edaf178089d9ae4cdc3a711f712ddfd4fdae1de8999"],["100f44da696e71672791d0a09b7bde459f1215a29b3c03bfefd7835b39a48db0","cdd9e13192a00b772ec8f3300c090666b7ff4a18ff5195ac0fbd5cd62bc65a09"],["e1031be262c7ed1b1dc9227a4a04c017a77f8d4464f3b3852c8acde6e534fd2d","9d7061928940405e6bb6a4176597535af292dd419e1ced79a44f18f29456a00d"],["feea6cae46d55b530ac2839f143bd7ec5cf8b266a41d6af52d5e688d9094696d","e57c6b6c97dce1bab06e4e12bf3ecd5c981c8957cc41442d3155debf18090088"],["da67a91d91049cdcb367be4be6ffca3cfeed657d808583de33fa978bc1ec6cb1","9bacaa35481642bc41f463f7ec9780e5dec7adc508f740a17e9ea8e27a68be1d"],["53904faa0b334cdda6e000935ef22151ec08d0f7bb11069f57545ccc1a37b7c0","5bc087d0bc80106d88c9eccac20d3c1c13999981e14434699dcb096b022771c8"],["8e7bcd0bd35983a7719cca7764ca906779b53a043a9b8bcaeff959f43ad86047","10b7770b2a3da4b3940310420ca9514579e88e2e47fd68b3ea10047e8460372a"],["385eed34c1cdff21e6d0818689b81bde71a7f4f18397e6690a841e1599c43862","283bebc3e8ea23f56701de19e9ebf4576b304eec2086dc8cc0458fe5542e5453"],["6f9d9b803ecf191637c73a4413dfa180fddf84a5947fbc9c606ed86c3fac3a7","7c80c68e603059ba69b8e2a30e45c4d47ea4dd2f5c281002d86890603a842160"],["3322d401243c4e2582a2147c104d6ecbf774d163db0f5e5313b7e0e742d0e6bd","56e70797e9664ef5bfb019bc4ddaf9b72805f63ea2873af624f3a2e96c28b2a0"],["85672c7d2de0b7da2bd1770d89665868741b3f9af7643397721d74d28134ab83","7c481b9b5b43b2eb6374049bfa62c2e5e77f17fcc5298f44c8e3094f790313a6"],["948bf809b1988a46b06c9f1919413b10f9226c60f668832ffd959af60c82a0a","53a562856dcb6646dc6b74c5d1c3418c6d4dff08c97cd2bed4cb7f88d8c8e589"],["6260ce7f461801c34f067ce0f02873a8f1b0e44dfc69752accecd819f38fd8e8","bc2da82b6fa5b571a7f09049776a1ef7ecd292238051c198c1a84e95b2b4ae17"],["e5037de0afc1d8d43d8348414bbf4103043ec8f575bfdc432953cc8d2037fa2d","4571534baa94d3b5f9f98d09fb990bddbd5f5b03ec481f10e0e5dc841d755bda"],["e06372b0f4a207adf5ea905e8f1771b4e7e8dbd1c6a6c5b725866a0ae4fce725","7a908974bce18cfe12a27bb2ad5a488cd7484a7787104870b27034f94eee31dd"],["213c7a715cd5d45358d0bbf9dc0ce02204b10bdde2a3f58540ad6908d0559754","4b6dad0b5ae462507013ad06245ba190bb4850f5f36a7eeddff2c27534b458f2"],["4e7c272a7af4b34e8dbb9352a5419a87e2838c70adc62cddf0cc3a3b08fbd53c","17749c766c9d0b18e16fd09f6def681b530b9614bff7dd33e0b3941817dcaae6"],["fea74e3dbe778b1b10f238ad61686aa5c76e3db2be43057632427e2840fb27b6","6e0568db9b0b13297cf674deccb6af93126b596b973f7b77701d3db7f23cb96f"],["76e64113f677cf0e10a2570d599968d31544e179b760432952c02a4417bdde39","c90ddf8dee4e95cf577066d70681f0d35e2a33d2b56d2032b4b1752d1901ac01"],["c738c56b03b2abe1e8281baa743f8f9a8f7cc643df26cbee3ab150242bcbb891","893fb578951ad2537f718f2eacbfbbbb82314eef7880cfe917e735d9699a84c3"],["d895626548b65b81e264c7637c972877d1d72e5f3a925014372e9f6588f6c14b","febfaa38f2bc7eae728ec60818c340eb03428d632bb067e179363ed75d7d991f"],["b8da94032a957518eb0f6433571e8761ceffc73693e84edd49150a564f676e03","2804dfa44805a1e4d7c99cc9762808b092cc584d95ff3b511488e4e74efdf6e7"],["e80fea14441fb33a7d8adab9475d7fab2019effb5156a792f1a11778e3c0df5d","eed1de7f638e00771e89768ca3ca94472d155e80af322ea9fcb4291b6ac9ec78"],["a301697bdfcd704313ba48e51d567543f2a182031efd6915ddc07bbcc4e16070","7370f91cfb67e4f5081809fa25d40f9b1735dbf7c0a11a130c0d1a041e177ea1"],["90ad85b389d6b936463f9d0512678de208cc330b11307fffab7ac63e3fb04ed4","e507a3620a38261affdcbd9427222b839aefabe1582894d991d4d48cb6ef150"],["8f68b9d2f63b5f339239c1ad981f162ee88c5678723ea3351b7b444c9ec4c0da","662a9f2dba063986de1d90c2b6be215dbbea2cfe95510bfdf23cbf79501fff82"],["e4f3fb0176af85d65ff99ff9198c36091f48e86503681e3e6686fd5053231e11","1e63633ad0ef4f1c1661a6d0ea02b7286cc7e74ec951d1c9822c38576feb73bc"],["8c00fa9b18ebf331eb961537a45a4266c7034f2f0d4e1d0716fb6eae20eae29e","efa47267fea521a1a9dc343a3736c974c2fadafa81e36c54e7d2a4c66702414b"],["e7a26ce69dd4829f3e10cec0a9e98ed3143d084f308b92c0997fddfc60cb3e41","2a758e300fa7984b471b006a1aafbb18d0a6b2c0420e83e20e8a9421cf2cfd51"],["b6459e0ee3662ec8d23540c223bcbdc571cbcb967d79424f3cf29eb3de6b80ef","67c876d06f3e06de1dadf16e5661db3c4b3ae6d48e35b2ff30bf0b61a71ba45"],["d68a80c8280bb840793234aa118f06231d6f1fc67e73c5a5deda0f5b496943e8","db8ba9fff4b586d00c4b1f9177b0e28b5b0e7b8f7845295a294c84266b133120"],["324aed7df65c804252dc0270907a30b09612aeb973449cea4095980fc28d3d5d","648a365774b61f2ff130c0c35aec1f4f19213b0c7e332843967224af96ab7c84"],["4df9c14919cde61f6d51dfdbe5fee5dceec4143ba8d1ca888e8bd373fd054c96","35ec51092d8728050974c23a1d85d4b5d506cdc288490192ebac06cad10d5d"],["9c3919a84a474870faed8a9c1cc66021523489054d7f0308cbfc99c8ac1f98cd","ddb84f0f4a4ddd57584f044bf260e641905326f76c64c8e6be7e5e03d4fc599d"],["6057170b1dd12fdf8de05f281d8e06bb91e1493a8b91d4cc5a21382120a959e5","9a1af0b26a6a4807add9a2daf71df262465152bc3ee24c65e899be932385a2a8"],["a576df8e23a08411421439a4518da31880cef0fba7d4df12b1a6973eecb94266","40a6bf20e76640b2c92b97afe58cd82c432e10a7f514d9f3ee8be11ae1b28ec8"],["7778a78c28dec3e30a05fe9629de8c38bb30d1f5cf9a3a208f763889be58ad71","34626d9ab5a5b22ff7098e12f2ff580087b38411ff24ac563b513fc1fd9f43ac"],["928955ee637a84463729fd30e7afd2ed5f96274e5ad7e5cb09eda9c06d903ac","c25621003d3f42a827b78a13093a95eeac3d26efa8a8d83fc5180e935bcd091f"],["85d0fef3ec6db109399064f3a0e3b2855645b4a907ad354527aae75163d82751","1f03648413a38c0be29d496e582cf5663e8751e96877331582c237a24eb1f962"],["ff2b0dce97eece97c1c9b6041798b85dfdfb6d8882da20308f5404824526087e","493d13fef524ba188af4c4dc54d07936c7b7ed6fb90e2ceb2c951e01f0c29907"],["827fbbe4b1e880ea9ed2b2e6301b212b57f1ee148cd6dd28780e5e2cf856e241","c60f9c923c727b0b71bef2c67d1d12687ff7a63186903166d605b68baec293ec"],["eaa649f21f51bdbae7be4ae34ce6e5217a58fdce7f47f9aa7f3b58fa2120e2b3","be3279ed5bbbb03ac69a80f89879aa5a01a6b965f13f7e59d47a5305ba5ad93d"],["e4a42d43c5cf169d9391df6decf42ee541b6d8f0c9a137401e23632dda34d24f","4d9f92e716d1c73526fc99ccfb8ad34ce886eedfa8d8e4f13a7f7131deba9414"],["1ec80fef360cbdd954160fadab352b6b92b53576a88fea4947173b9d4300bf19","aeefe93756b5340d2f3a4958a7abbf5e0146e77f6295a07b671cdc1cc107cefd"],["146a778c04670c2f91b00af4680dfa8bce3490717d58ba889ddb5928366642be","b318e0ec3354028add669827f9d4b2870aaa971d2f7e5ed1d0b297483d83efd0"],["fa50c0f61d22e5f07e3acebb1aa07b128d0012209a28b9776d76a8793180eef9","6b84c6922397eba9b72cd2872281a68a5e683293a57a213b38cd8d7d3f4f2811"],["da1d61d0ca721a11b1a5bf6b7d88e8421a288ab5d5bba5220e53d32b5f067ec2","8157f55a7c99306c79c0766161c91e2966a73899d279b48a655fba0f1ad836f1"],["a8e282ff0c9706907215ff98e8fd416615311de0446f1e062a73b0610d064e13","7f97355b8db81c09abfb7f3c5b2515888b679a3e50dd6bd6cef7c73111f4cc0c"],["174a53b9c9a285872d39e56e6913cab15d59b1fa512508c022f382de8319497c","ccc9dc37abfc9c1657b4155f2c47f9e6646b3a1d8cb9854383da13ac079afa73"],["959396981943785c3d3e57edf5018cdbe039e730e4918b3d884fdff09475b7ba","2e7e552888c331dd8ba0386a4b9cd6849c653f64c8709385e9b8abf87524f2fd"],["d2a63a50ae401e56d645a1153b109a8fcca0a43d561fba2dbb51340c9d82b151","e82d86fb6443fcb7565aee58b2948220a70f750af484ca52d4142174dcf89405"],["64587e2335471eb890ee7896d7cfdc866bacbdbd3839317b3436f9b45617e073","d99fcdd5bf6902e2ae96dd6447c299a185b90a39133aeab358299e5e9faf6589"],["8481bde0e4e4d885b3a546d3e549de042f0aa6cea250e7fd358d6c86dd45e458","38ee7b8cba5404dd84a25bf39cecb2ca900a79c42b262e556d64b1b59779057e"],["13464a57a78102aa62b6979ae817f4637ffcfed3c4b1ce30bcd6303f6caf666b","69be159004614580ef7e433453ccb0ca48f300a81d0942e13f495a907f6ecc27"],["bc4a9df5b713fe2e9aef430bcc1dc97a0cd9ccede2f28588cada3a0d2d83f366","d3a81ca6e785c06383937adf4b798caa6e8a9fbfa547b16d758d666581f33c1"],["8c28a97bf8298bc0d23d8c749452a32e694b65e30a9472a3954ab30fe5324caa","40a30463a3305193378fedf31f7cc0eb7ae784f0451cb9459e71dc73cbef9482"],["8ea9666139527a8c1dd94ce4f071fd23c8b350c5a4bb33748c4ba111faccae0","620efabbc8ee2782e24e7c0cfb95c5d735b783be9cf0f8e955af34a30e62b945"],["dd3625faef5ba06074669716bbd3788d89bdde815959968092f76cc4eb9a9787","7a188fa3520e30d461da2501045731ca941461982883395937f68d00c644a573"],["f710d79d9eb962297e4f6232b40e8f7feb2bc63814614d692c12de752408221e","ea98e67232d3b3295d3b535532115ccac8612c721851617526ae47a9c77bfc82"]]},naf:{wnd:7,points:[["f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9","388f7b0f632de8140fe337e62a37f3566500a99934c2231b6cb9fd7584b8e672"],["2f8bde4d1a07209355b4a7250a5c5128e88b84bddc619ab7cba8d569b240efe4","d8ac222636e5e3d6d4dba9dda6c9c426f788271bab0d6840dca87d3aa6ac62d6"],["5cbdf0646e5db4eaa398f365f2ea7a0e3d419b7e0330e39ce92bddedcac4f9bc","6aebca40ba255960a3178d6d861a54dba813d0b813fde7b5a5082628087264da"],["acd484e2f0c7f65309ad178a9f559abde09796974c57e714c35f110dfc27ccbe","cc338921b0a7d9fd64380971763b61e9add888a4375f8e0f05cc262ac64f9c37"],["774ae7f858a9411e5ef4246b70c65aac5649980be5c17891bbec17895da008cb","d984a032eb6b5e190243dd56d7b7b365372db1e2dff9d6a8301d74c9c953c61b"],["f28773c2d975288bc7d1d205c3748651b075fbc6610e58cddeeddf8f19405aa8","ab0902e8d880a89758212eb65cdaf473a1a06da521fa91f29b5cb52db03ed81"],["d7924d4f7d43ea965a465ae3095ff41131e5946f3c85f79e44adbcf8e27e080e","581e2872a86c72a683842ec228cc6defea40af2bd896d3a5c504dc9ff6a26b58"],["defdea4cdb677750a420fee807eacf21eb9898ae79b9768766e4faa04a2d4a34","4211ab0694635168e997b0ead2a93daeced1f4a04a95c0f6cfb199f69e56eb77"],["2b4ea0a797a443d293ef5cff444f4979f06acfebd7e86d277475656138385b6c","85e89bc037945d93b343083b5a1c86131a01f60c50269763b570c854e5c09b7a"],["352bbf4a4cdd12564f93fa332ce333301d9ad40271f8107181340aef25be59d5","321eb4075348f534d59c18259dda3e1f4a1b3b2e71b1039c67bd3d8bcf81998c"],["2fa2104d6b38d11b0230010559879124e42ab8dfeff5ff29dc9cdadd4ecacc3f","2de1068295dd865b64569335bd5dd80181d70ecfc882648423ba76b532b7d67"],["9248279b09b4d68dab21a9b066edda83263c3d84e09572e269ca0cd7f5453714","73016f7bf234aade5d1aa71bdea2b1ff3fc0de2a887912ffe54a32ce97cb3402"],["daed4f2be3a8bf278e70132fb0beb7522f570e144bf615c07e996d443dee8729","a69dce4a7d6c98e8d4a1aca87ef8d7003f83c230f3afa726ab40e52290be1c55"],["c44d12c7065d812e8acf28d7cbb19f9011ecd9e9fdf281b0e6a3b5e87d22e7db","2119a460ce326cdc76c45926c982fdac0e106e861edf61c5a039063f0e0e6482"],["6a245bf6dc698504c89a20cfded60853152b695336c28063b61c65cbd269e6b4","e022cf42c2bd4a708b3f5126f16a24ad8b33ba48d0423b6efd5e6348100d8a82"],["1697ffa6fd9de627c077e3d2fe541084ce13300b0bec1146f95ae57f0d0bd6a5","b9c398f186806f5d27561506e4557433a2cf15009e498ae7adee9d63d01b2396"],["605bdb019981718b986d0f07e834cb0d9deb8360ffb7f61df982345ef27a7479","2972d2de4f8d20681a78d93ec96fe23c26bfae84fb14db43b01e1e9056b8c49"],["62d14dab4150bf497402fdc45a215e10dcb01c354959b10cfe31c7e9d87ff33d","80fc06bd8cc5b01098088a1950eed0db01aa132967ab472235f5642483b25eaf"],["80c60ad0040f27dade5b4b06c408e56b2c50e9f56b9b8b425e555c2f86308b6f","1c38303f1cc5c30f26e66bad7fe72f70a65eed4cbe7024eb1aa01f56430bd57a"],["7a9375ad6167ad54aa74c6348cc54d344cc5dc9487d847049d5eabb0fa03c8fb","d0e3fa9eca8726909559e0d79269046bdc59ea10c70ce2b02d499ec224dc7f7"],["d528ecd9b696b54c907a9ed045447a79bb408ec39b68df504bb51f459bc3ffc9","eecf41253136e5f99966f21881fd656ebc4345405c520dbc063465b521409933"],["49370a4b5f43412ea25f514e8ecdad05266115e4a7ecb1387231808f8b45963","758f3f41afd6ed428b3081b0512fd62a54c3f3afbb5b6764b653052a12949c9a"],["77f230936ee88cbbd73df930d64702ef881d811e0e1498e2f1c13eb1fc345d74","958ef42a7886b6400a08266e9ba1b37896c95330d97077cbbe8eb3c7671c60d6"],["f2dac991cc4ce4b9ea44887e5c7c0bce58c80074ab9d4dbaeb28531b7739f530","e0dedc9b3b2f8dad4da1f32dec2531df9eb5fbeb0598e4fd1a117dba703a3c37"],["463b3d9f662621fb1b4be8fbbe2520125a216cdfc9dae3debcba4850c690d45b","5ed430d78c296c3543114306dd8622d7c622e27c970a1de31cb377b01af7307e"],["f16f804244e46e2a09232d4aff3b59976b98fac14328a2d1a32496b49998f247","cedabd9b82203f7e13d206fcdf4e33d92a6c53c26e5cce26d6579962c4e31df6"],["caf754272dc84563b0352b7a14311af55d245315ace27c65369e15f7151d41d1","cb474660ef35f5f2a41b643fa5e460575f4fa9b7962232a5c32f908318a04476"],["2600ca4b282cb986f85d0f1709979d8b44a09c07cb86d7c124497bc86f082120","4119b88753c15bd6a693b03fcddbb45d5ac6be74ab5f0ef44b0be9475a7e4b40"],["7635ca72d7e8432c338ec53cd12220bc01c48685e24f7dc8c602a7746998e435","91b649609489d613d1d5e590f78e6d74ecfc061d57048bad9e76f302c5b9c61"],["754e3239f325570cdbbf4a87deee8a66b7f2b33479d468fbc1a50743bf56cc18","673fb86e5bda30fb3cd0ed304ea49a023ee33d0197a695d0c5d98093c536683"],["e3e6bd1071a1e96aff57859c82d570f0330800661d1c952f9fe2694691d9b9e8","59c9e0bba394e76f40c0aa58379a3cb6a5a2283993e90c4167002af4920e37f5"],["186b483d056a033826ae73d88f732985c4ccb1f32ba35f4b4cc47fdcf04aa6eb","3b952d32c67cf77e2e17446e204180ab21fb8090895138b4a4a797f86e80888b"],["df9d70a6b9876ce544c98561f4be4f725442e6d2b737d9c91a8321724ce0963f","55eb2dafd84d6ccd5f862b785dc39d4ab157222720ef9da217b8c45cf2ba2417"],["5edd5cc23c51e87a497ca815d5dce0f8ab52554f849ed8995de64c5f34ce7143","efae9c8dbc14130661e8cec030c89ad0c13c66c0d17a2905cdc706ab7399a868"],["290798c2b6476830da12fe02287e9e777aa3fba1c355b17a722d362f84614fba","e38da76dcd440621988d00bcf79af25d5b29c094db2a23146d003afd41943e7a"],["af3c423a95d9f5b3054754efa150ac39cd29552fe360257362dfdecef4053b45","f98a3fd831eb2b749a93b0e6f35cfb40c8cd5aa667a15581bc2feded498fd9c6"],["766dbb24d134e745cccaa28c99bf274906bb66b26dcf98df8d2fed50d884249a","744b1152eacbe5e38dcc887980da38b897584a65fa06cedd2c924f97cbac5996"],["59dbf46f8c94759ba21277c33784f41645f7b44f6c596a58ce92e666191abe3e","c534ad44175fbc300f4ea6ce648309a042ce739a7919798cd85e216c4a307f6e"],["f13ada95103c4537305e691e74e9a4a8dd647e711a95e73cb62dc6018cfd87b8","e13817b44ee14de663bf4bc808341f326949e21a6a75c2570778419bdaf5733d"],["7754b4fa0e8aced06d4167a2c59cca4cda1869c06ebadfb6488550015a88522c","30e93e864e669d82224b967c3020b8fa8d1e4e350b6cbcc537a48b57841163a2"],["948dcadf5990e048aa3874d46abef9d701858f95de8041d2a6828c99e2262519","e491a42537f6e597d5d28a3224b1bc25df9154efbd2ef1d2cbba2cae5347d57e"],["7962414450c76c1689c7b48f8202ec37fb224cf5ac0bfa1570328a8a3d7c77ab","100b610ec4ffb4760d5c1fc133ef6f6b12507a051f04ac5760afa5b29db83437"],["3514087834964b54b15b160644d915485a16977225b8847bb0dd085137ec47ca","ef0afbb2056205448e1652c48e8127fc6039e77c15c2378b7e7d15a0de293311"],["d3cc30ad6b483e4bc79ce2c9dd8bc54993e947eb8df787b442943d3f7b527eaf","8b378a22d827278d89c5e9be8f9508ae3c2ad46290358630afb34db04eede0a4"],["1624d84780732860ce1c78fcbfefe08b2b29823db913f6493975ba0ff4847610","68651cf9b6da903e0914448c6cd9d4ca896878f5282be4c8cc06e2a404078575"],["733ce80da955a8a26902c95633e62a985192474b5af207da6df7b4fd5fc61cd4","f5435a2bd2badf7d485a4d8b8db9fcce3e1ef8e0201e4578c54673bc1dc5ea1d"],["15d9441254945064cf1a1c33bbd3b49f8966c5092171e699ef258dfab81c045c","d56eb30b69463e7234f5137b73b84177434800bacebfc685fc37bbe9efe4070d"],["a1d0fcf2ec9de675b612136e5ce70d271c21417c9d2b8aaaac138599d0717940","edd77f50bcb5a3cab2e90737309667f2641462a54070f3d519212d39c197a629"],["e22fbe15c0af8ccc5780c0735f84dbe9a790badee8245c06c7ca37331cb36980","a855babad5cd60c88b430a69f53a1a7a38289154964799be43d06d77d31da06"],["311091dd9860e8e20ee13473c1155f5f69635e394704eaa74009452246cfa9b3","66db656f87d1f04fffd1f04788c06830871ec5a64feee685bd80f0b1286d8374"],["34c1fd04d301be89b31c0442d3e6ac24883928b45a9340781867d4232ec2dbdf","9414685e97b1b5954bd46f730174136d57f1ceeb487443dc5321857ba73abee"],["f219ea5d6b54701c1c14de5b557eb42a8d13f3abbcd08affcc2a5e6b049b8d63","4cb95957e83d40b0f73af4544cccf6b1f4b08d3c07b27fb8d8c2962a400766d1"],["d7b8740f74a8fbaab1f683db8f45de26543a5490bca627087236912469a0b448","fa77968128d9c92ee1010f337ad4717eff15db5ed3c049b3411e0315eaa4593b"],["32d31c222f8f6f0ef86f7c98d3a3335ead5bcd32abdd94289fe4d3091aa824bf","5f3032f5892156e39ccd3d7915b9e1da2e6dac9e6f26e961118d14b8462e1661"],["7461f371914ab32671045a155d9831ea8793d77cd59592c4340f86cbc18347b5","8ec0ba238b96bec0cbdddcae0aa442542eee1ff50c986ea6b39847b3cc092ff6"],["ee079adb1df1860074356a25aa38206a6d716b2c3e67453d287698bad7b2b2d6","8dc2412aafe3be5c4c5f37e0ecc5f9f6a446989af04c4e25ebaac479ec1c8c1e"],["16ec93e447ec83f0467b18302ee620f7e65de331874c9dc72bfd8616ba9da6b5","5e4631150e62fb40d0e8c2a7ca5804a39d58186a50e497139626778e25b0674d"],["eaa5f980c245f6f038978290afa70b6bd8855897f98b6aa485b96065d537bd99","f65f5d3e292c2e0819a528391c994624d784869d7e6ea67fb18041024edc07dc"],["78c9407544ac132692ee1910a02439958ae04877151342ea96c4b6b35a49f51","f3e0319169eb9b85d5404795539a5e68fa1fbd583c064d2462b675f194a3ddb4"],["494f4be219a1a77016dcd838431aea0001cdc8ae7a6fc688726578d9702857a5","42242a969283a5f339ba7f075e36ba2af925ce30d767ed6e55f4b031880d562c"],["a598a8030da6d86c6bc7f2f5144ea549d28211ea58faa70ebf4c1e665c1fe9b5","204b5d6f84822c307e4b4a7140737aec23fc63b65b35f86a10026dbd2d864e6b"],["c41916365abb2b5d09192f5f2dbeafec208f020f12570a184dbadc3e58595997","4f14351d0087efa49d245b328984989d5caf9450f34bfc0ed16e96b58fa9913"],["841d6063a586fa475a724604da03bc5b92a2e0d2e0a36acfe4c73a5514742881","73867f59c0659e81904f9a1c7543698e62562d6744c169ce7a36de01a8d6154"],["5e95bb399a6971d376026947f89bde2f282b33810928be4ded112ac4d70e20d5","39f23f366809085beebfc71181313775a99c9aed7d8ba38b161384c746012865"],["36e4641a53948fd476c39f8a99fd974e5ec07564b5315d8bf99471bca0ef2f66","d2424b1b1abe4eb8164227b085c9aa9456ea13493fd563e06fd51cf5694c78fc"],["336581ea7bfbbb290c191a2f507a41cf5643842170e914faeab27c2c579f726","ead12168595fe1be99252129b6e56b3391f7ab1410cd1e0ef3dcdcabd2fda224"],["8ab89816dadfd6b6a1f2634fcf00ec8403781025ed6890c4849742706bd43ede","6fdcef09f2f6d0a044e654aef624136f503d459c3e89845858a47a9129cdd24e"],["1e33f1a746c9c5778133344d9299fcaa20b0938e8acff2544bb40284b8c5fb94","60660257dd11b3aa9c8ed618d24edff2306d320f1d03010e33a7d2057f3b3b6"],["85b7c1dcb3cec1b7ee7f30ded79dd20a0ed1f4cc18cbcfcfa410361fd8f08f31","3d98a9cdd026dd43f39048f25a8847f4fcafad1895d7a633c6fed3c35e999511"],["29df9fbd8d9e46509275f4b125d6d45d7fbe9a3b878a7af872a2800661ac5f51","b4c4fe99c775a606e2d8862179139ffda61dc861c019e55cd2876eb2a27d84b"],["a0b1cae06b0a847a3fea6e671aaf8adfdfe58ca2f768105c8082b2e449fce252","ae434102edde0958ec4b19d917a6a28e6b72da1834aff0e650f049503a296cf2"],["4e8ceafb9b3e9a136dc7ff67e840295b499dfb3b2133e4ba113f2e4c0e121e5","cf2174118c8b6d7a4b48f6d534ce5c79422c086a63460502b827ce62a326683c"],["d24a44e047e19b6f5afb81c7ca2f69080a5076689a010919f42725c2b789a33b","6fb8d5591b466f8fc63db50f1c0f1c69013f996887b8244d2cdec417afea8fa3"],["ea01606a7a6c9cdd249fdfcfacb99584001edd28abbab77b5104e98e8e3b35d4","322af4908c7312b0cfbfe369f7a7b3cdb7d4494bc2823700cfd652188a3ea98d"],["af8addbf2b661c8a6c6328655eb96651252007d8c5ea31be4ad196de8ce2131f","6749e67c029b85f52a034eafd096836b2520818680e26ac8f3dfbcdb71749700"],["e3ae1974566ca06cc516d47e0fb165a674a3dabcfca15e722f0e3450f45889","2aeabe7e4531510116217f07bf4d07300de97e4874f81f533420a72eeb0bd6a4"],["591ee355313d99721cf6993ffed1e3e301993ff3ed258802075ea8ced397e246","b0ea558a113c30bea60fc4775460c7901ff0b053d25ca2bdeee98f1a4be5d196"],["11396d55fda54c49f19aa97318d8da61fa8584e47b084945077cf03255b52984","998c74a8cd45ac01289d5833a7beb4744ff536b01b257be4c5767bea93ea57a4"],["3c5d2a1ba39c5a1790000738c9e0c40b8dcdfd5468754b6405540157e017aa7a","b2284279995a34e2f9d4de7396fc18b80f9b8b9fdd270f6661f79ca4c81bd257"],["cc8704b8a60a0defa3a99a7299f2e9c3fbc395afb04ac078425ef8a1793cc030","bdd46039feed17881d1e0862db347f8cf395b74fc4bcdc4e940b74e3ac1f1b13"],["c533e4f7ea8555aacd9777ac5cad29b97dd4defccc53ee7ea204119b2889b197","6f0a256bc5efdf429a2fb6242f1a43a2d9b925bb4a4b3a26bb8e0f45eb596096"],["c14f8f2ccb27d6f109f6d08d03cc96a69ba8c34eec07bbcf566d48e33da6593","c359d6923bb398f7fd4473e16fe1c28475b740dd098075e6c0e8649113dc3a38"],["a6cbc3046bc6a450bac24789fa17115a4c9739ed75f8f21ce441f72e0b90e6ef","21ae7f4680e889bb130619e2c0f95a360ceb573c70603139862afd617fa9b9f"],["347d6d9a02c48927ebfb86c1359b1caf130a3c0267d11ce6344b39f99d43cc38","60ea7f61a353524d1c987f6ecec92f086d565ab687870cb12689ff1e31c74448"],["da6545d2181db8d983f7dcb375ef5866d47c67b1bf31c8cf855ef7437b72656a","49b96715ab6878a79e78f07ce5680c5d6673051b4935bd897fea824b77dc208a"],["c40747cc9d012cb1a13b8148309c6de7ec25d6945d657146b9d5994b8feb1111","5ca560753be2a12fc6de6caf2cb489565db936156b9514e1bb5e83037e0fa2d4"],["4e42c8ec82c99798ccf3a610be870e78338c7f713348bd34c8203ef4037f3502","7571d74ee5e0fb92a7a8b33a07783341a5492144cc54bcc40a94473693606437"],["3775ab7089bc6af823aba2e1af70b236d251cadb0c86743287522a1b3b0dedea","be52d107bcfa09d8bcb9736a828cfa7fac8db17bf7a76a2c42ad961409018cf7"],["cee31cbf7e34ec379d94fb814d3d775ad954595d1314ba8846959e3e82f74e26","8fd64a14c06b589c26b947ae2bcf6bfa0149ef0be14ed4d80f448a01c43b1c6d"],["b4f9eaea09b6917619f6ea6a4eb5464efddb58fd45b1ebefcdc1a01d08b47986","39e5c9925b5a54b07433a4f18c61726f8bb131c012ca542eb24a8ac07200682a"],["d4263dfc3d2df923a0179a48966d30ce84e2515afc3dccc1b77907792ebcc60e","62dfaf07a0f78feb30e30d6295853ce189e127760ad6cf7fae164e122a208d54"],["48457524820fa65a4f8d35eb6930857c0032acc0a4a2de422233eeda897612c4","25a748ab367979d98733c38a1fa1c2e7dc6cc07db2d60a9ae7a76aaa49bd0f77"],["dfeeef1881101f2cb11644f3a2afdfc2045e19919152923f367a1767c11cceda","ecfb7056cf1de042f9420bab396793c0c390bde74b4bbdff16a83ae09a9a7517"],["6d7ef6b17543f8373c573f44e1f389835d89bcbc6062ced36c82df83b8fae859","cd450ec335438986dfefa10c57fea9bcc521a0959b2d80bbf74b190dca712d10"],["e75605d59102a5a2684500d3b991f2e3f3c88b93225547035af25af66e04541f","f5c54754a8f71ee540b9b48728473e314f729ac5308b06938360990e2bfad125"],["eb98660f4c4dfaa06a2be453d5020bc99a0c2e60abe388457dd43fefb1ed620c","6cb9a8876d9cb8520609af3add26cd20a0a7cd8a9411131ce85f44100099223e"],["13e87b027d8514d35939f2e6892b19922154596941888336dc3563e3b8dba942","fef5a3c68059a6dec5d624114bf1e91aac2b9da568d6abeb2570d55646b8adf1"],["ee163026e9fd6fe017c38f06a5be6fc125424b371ce2708e7bf4491691e5764a","1acb250f255dd61c43d94ccc670d0f58f49ae3fa15b96623e5430da0ad6c62b2"],["b268f5ef9ad51e4d78de3a750c2dc89b1e626d43505867999932e5db33af3d80","5f310d4b3c99b9ebb19f77d41c1dee018cf0d34fd4191614003e945a1216e423"],["ff07f3118a9df035e9fad85eb6c7bfe42b02f01ca99ceea3bf7ffdba93c4750d","438136d603e858a3a5c440c38eccbaddc1d2942114e2eddd4740d098ced1f0d8"],["8d8b9855c7c052a34146fd20ffb658bea4b9f69e0d825ebec16e8c3ce2b526a1","cdb559eedc2d79f926baf44fb84ea4d44bcf50fee51d7ceb30e2e7f463036758"],["52db0b5384dfbf05bfa9d472d7ae26dfe4b851ceca91b1eba54263180da32b63","c3b997d050ee5d423ebaf66a6db9f57b3180c902875679de924b69d84a7b375"],["e62f9490d3d51da6395efd24e80919cc7d0f29c3f3fa48c6fff543becbd43352","6d89ad7ba4876b0b22c2ca280c682862f342c8591f1daf5170e07bfd9ccafa7d"],["7f30ea2476b399b4957509c88f77d0191afa2ff5cb7b14fd6d8e7d65aaab1193","ca5ef7d4b231c94c3b15389a5f6311e9daff7bb67b103e9880ef4bff637acaec"],["5098ff1e1d9f14fb46a210fada6c903fef0fb7b4a1dd1d9ac60a0361800b7a00","9731141d81fc8f8084d37c6e7542006b3ee1b40d60dfe5362a5b132fd17ddc0"],["32b78c7de9ee512a72895be6b9cbefa6e2f3c4ccce445c96b9f2c81e2778ad58","ee1849f513df71e32efc3896ee28260c73bb80547ae2275ba497237794c8753c"],["e2cb74fddc8e9fbcd076eef2a7c72b0ce37d50f08269dfc074b581550547a4f7","d3aa2ed71c9dd2247a62df062736eb0baddea9e36122d2be8641abcb005cc4a4"],["8438447566d4d7bedadc299496ab357426009a35f235cb141be0d99cd10ae3a8","c4e1020916980a4da5d01ac5e6ad330734ef0d7906631c4f2390426b2edd791f"],["4162d488b89402039b584c6fc6c308870587d9c46f660b878ab65c82c711d67e","67163e903236289f776f22c25fb8a3afc1732f2b84b4e95dbda47ae5a0852649"],["3fad3fa84caf0f34f0f89bfd2dcf54fc175d767aec3e50684f3ba4a4bf5f683d","cd1bc7cb6cc407bb2f0ca647c718a730cf71872e7d0d2a53fa20efcdfe61826"],["674f2600a3007a00568c1a7ce05d0816c1fb84bf1370798f1c69532faeb1a86b","299d21f9413f33b3edf43b257004580b70db57da0b182259e09eecc69e0d38a5"],["d32f4da54ade74abb81b815ad1fb3b263d82d6c692714bcff87d29bd5ee9f08f","f9429e738b8e53b968e99016c059707782e14f4535359d582fc416910b3eea87"],["30e4e670435385556e593657135845d36fbb6931f72b08cb1ed954f1e3ce3ff6","462f9bce619898638499350113bbc9b10a878d35da70740dc695a559eb88db7b"],["be2062003c51cc3004682904330e4dee7f3dcd10b01e580bf1971b04d4cad297","62188bc49d61e5428573d48a74e1c655b1c61090905682a0d5558ed72dccb9bc"],["93144423ace3451ed29e0fb9ac2af211cb6e84a601df5993c419859fff5df04a","7c10dfb164c3425f5c71a3f9d7992038f1065224f72bb9d1d902a6d13037b47c"],["b015f8044f5fcbdcf21ca26d6c34fb8197829205c7b7d2a7cb66418c157b112c","ab8c1e086d04e813744a655b2df8d5f83b3cdc6faa3088c1d3aea1454e3a1d5f"],["d5e9e1da649d97d89e4868117a465a3a4f8a18de57a140d36b3f2af341a21b52","4cb04437f391ed73111a13cc1d4dd0db1693465c2240480d8955e8592f27447a"],["d3ae41047dd7ca065dbf8ed77b992439983005cd72e16d6f996a5316d36966bb","bd1aeb21ad22ebb22a10f0303417c6d964f8cdd7df0aca614b10dc14d125ac46"],["463e2763d885f958fc66cdd22800f0a487197d0a82e377b49f80af87c897b065","bfefacdb0e5d0fd7df3a311a94de062b26b80c61fbc97508b79992671ef7ca7f"],["7985fdfd127c0567c6f53ec1bb63ec3158e597c40bfe747c83cddfc910641917","603c12daf3d9862ef2b25fe1de289aed24ed291e0ec6708703a5bd567f32ed03"],["74a1ad6b5f76e39db2dd249410eac7f99e74c59cb83d2d0ed5ff1543da7703e9","cc6157ef18c9c63cd6193d83631bbea0093e0968942e8c33d5737fd790e0db08"],["30682a50703375f602d416664ba19b7fc9bab42c72747463a71d0896b22f6da3","553e04f6b018b4fa6c8f39e7f311d3176290d0e0f19ca73f17714d9977a22ff8"],["9e2158f0d7c0d5f26c3791efefa79597654e7a2b2464f52b1ee6c1347769ef57","712fcdd1b9053f09003a3481fa7762e9ffd7c8ef35a38509e2fbf2629008373"],["176e26989a43c9cfeba4029c202538c28172e566e3c4fce7322857f3be327d66","ed8cc9d04b29eb877d270b4878dc43c19aefd31f4eee09ee7b47834c1fa4b1c3"],["75d46efea3771e6e68abb89a13ad747ecf1892393dfc4f1b7004788c50374da8","9852390a99507679fd0b86fd2b39a868d7efc22151346e1a3ca4726586a6bed8"],["809a20c67d64900ffb698c4c825f6d5f2310fb0451c869345b7319f645605721","9e994980d9917e22b76b061927fa04143d096ccc54963e6a5ebfa5f3f8e286c1"],["1b38903a43f7f114ed4500b4eac7083fdefece1cf29c63528d563446f972c180","4036edc931a60ae889353f77fd53de4a2708b26b6f5da72ad3394119daf408f9"]]}}},4367:function(e,t){"use strict";var n=t;function r(e){return 1===e.length?"0"+e:e}function o(e){for(var t="",n=0;n<e.length;n++)t+=r(e[n].toString(16));return t}n.toArray=function(e,t){if(Array.isArray(e))return e.slice();if(!e)return[];var n=[];if("string"!=typeof e){for(var r=0;r<e.length;r++)n[r]=0|e[r];return n}if("hex"===t){(e=e.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(e="0"+e);for(r=0;r<e.length;r+=2)n.push(parseInt(e[r]+e[r+1],16))}else for(r=0;r<e.length;r++){var o=e.charCodeAt(r),i=o>>8,a=255&o;i?n.push(i,a):n.push(a)}return n},n.zero2=r,n.toHex=o,n.encode=function(e,t){return"hex"===t?o(e):e}},4945:function(e,t){var n="undefined"!=typeof self?self:this,r=function(){function e(){this.fetch=!1,this.DOMException=n.DOMException}return e.prototype=n,new e}();!function(e){!function(t){var n="URLSearchParams"in e,r="Symbol"in e&&"iterator"in Symbol,o="FileReader"in e&&"Blob"in e&&function(){try{return new Blob,!0}catch(e){return!1}}(),i="FormData"in e,a="ArrayBuffer"in e;if(a)var s=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],c=ArrayBuffer.isView||function(e){return e&&s.indexOf(Object.prototype.toString.call(e))>-1};function u(e){if("string"!=typeof e&&(e=String(e)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(e))throw new TypeError("Invalid character in header field name");return e.toLowerCase()}function l(e){return"string"!=typeof e&&(e=String(e)),e}function d(e){var t={next:function(){var t=e.shift();return{done:void 0===t,value:t}}};return r&&(t[Symbol.iterator]=function(){return t}),t}function f(e){this.map={},e instanceof f?e.forEach(function(e,t){this.append(t,e)},this):Array.isArray(e)?e.forEach(function(e){this.append(e[0],e[1])},this):e&&Object.getOwnPropertyNames(e).forEach(function(t){this.append(t,e[t])},this)}function p(e){if(e.bodyUsed)return Promise.reject(new TypeError("Already read"));e.bodyUsed=!0}function h(e){return new Promise(function(t,n){e.onload=function(){t(e.result)},e.onerror=function(){n(e.error)}})}function y(e){var t=new FileReader,n=h(t);return t.readAsArrayBuffer(e),n}function b(e){if(e.slice)return e.slice(0);var t=new Uint8Array(e.byteLength);return t.set(new Uint8Array(e)),t.buffer}function g(){return this.bodyUsed=!1,this._initBody=function(e){var t;this._bodyInit=e,e?"string"==typeof e?this._bodyText=e:o&&Blob.prototype.isPrototypeOf(e)?this._bodyBlob=e:i&&FormData.prototype.isPrototypeOf(e)?this._bodyFormData=e:n&&URLSearchParams.prototype.isPrototypeOf(e)?this._bodyText=e.toString():a&&o&&((t=e)&&DataView.prototype.isPrototypeOf(t))?(this._bodyArrayBuffer=b(e.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):a&&(ArrayBuffer.prototype.isPrototypeOf(e)||c(e))?this._bodyArrayBuffer=b(e):this._bodyText=e=Object.prototype.toString.call(e):this._bodyText="",this.headers.get("content-type")||("string"==typeof e?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):n&&URLSearchParams.prototype.isPrototypeOf(e)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},o&&(this.blob=function(){var e=p(this);if(e)return e;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?p(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(y)}),this.text=function(){var e,t,n,r=p(this);if(r)return r;if(this._bodyBlob)return e=this._bodyBlob,t=new FileReader,n=h(t),t.readAsText(e),n;if(this._bodyArrayBuffer)return Promise.resolve(function(e){for(var t=new Uint8Array(e),n=new Array(t.length),r=0;r<t.length;r++)n[r]=String.fromCharCode(t[r]);return n.join("")}(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},i&&(this.formData=function(){return this.text().then(m)}),this.json=function(){return this.text().then(JSON.parse)},this}f.prototype.append=function(e,t){e=u(e),t=l(t);var n=this.map[e];this.map[e]=n?n+", "+t:t},f.prototype.delete=function(e){delete this.map[u(e)]},f.prototype.get=function(e){return e=u(e),this.has(e)?this.map[e]:null},f.prototype.has=function(e){return this.map.hasOwnProperty(u(e))},f.prototype.set=function(e,t){this.map[u(e)]=l(t)},f.prototype.forEach=function(e,t){for(var n in this.map)this.map.hasOwnProperty(n)&&e.call(t,this.map[n],n,this)},f.prototype.keys=function(){var e=[];return this.forEach(function(t,n){e.push(n)}),d(e)},f.prototype.values=function(){var e=[];return this.forEach(function(t){e.push(t)}),d(e)},f.prototype.entries=function(){var e=[];return this.forEach(function(t,n){e.push([n,t])}),d(e)},r&&(f.prototype[Symbol.iterator]=f.prototype.entries);var w=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function v(e,t){var n,r,o=(t=t||{}).body;if(e instanceof v){if(e.bodyUsed)throw new TypeError("Already read");this.url=e.url,this.credentials=e.credentials,t.headers||(this.headers=new f(e.headers)),this.method=e.method,this.mode=e.mode,this.signal=e.signal,o||null==e._bodyInit||(o=e._bodyInit,e.bodyUsed=!0)}else this.url=String(e);if(this.credentials=t.credentials||this.credentials||"same-origin",!t.headers&&this.headers||(this.headers=new f(t.headers)),this.method=(n=t.method||this.method||"GET",r=n.toUpperCase(),w.indexOf(r)>-1?r:n),this.mode=t.mode||this.mode||null,this.signal=t.signal||this.signal,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&o)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(o)}function m(e){var t=new FormData;return e.trim().split("&").forEach(function(e){if(e){var n=e.split("="),r=n.shift().replace(/\+/g," "),o=n.join("=").replace(/\+/g," ");t.append(decodeURIComponent(r),decodeURIComponent(o))}}),t}function I(e,t){t||(t={}),this.type="default",this.status=void 0===t.status?200:t.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in t?t.statusText:"OK",this.headers=new f(t.headers),this.url=t.url||"",this._initBody(e)}v.prototype.clone=function(){return new v(this,{body:this._bodyInit})},g.call(v.prototype),g.call(I.prototype),I.prototype.clone=function(){return new I(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new f(this.headers),url:this.url})},I.error=function(){var e=new I(null,{status:0,statusText:""});return e.type="error",e};var E=[301,302,303,307,308];I.redirect=function(e,t){if(-1===E.indexOf(t))throw new RangeError("Invalid status code");return new I(null,{status:t,headers:{location:e}})},t.DOMException=e.DOMException;try{new t.DOMException}catch(O){t.DOMException=function(e,t){this.message=e,this.name=t;var n=Error(e);this.stack=n.stack},t.DOMException.prototype=Object.create(Error.prototype),t.DOMException.prototype.constructor=t.DOMException}function S(e,n){return new Promise(function(r,i){var a=new v(e,n);if(a.signal&&a.signal.aborted)return i(new t.DOMException("Aborted","AbortError"));var s=new XMLHttpRequest;function c(){s.abort()}s.onload=function(){var e,t,n={status:s.status,statusText:s.statusText,headers:(e=s.getAllResponseHeaders()||"",t=new f,e.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach(function(e){var n=e.split(":"),r=n.shift().trim();if(r){var o=n.join(":").trim();t.append(r,o)}}),t)};n.url="responseURL"in s?s.responseURL:n.headers.get("X-Request-URL");var o="response"in s?s.response:s.responseText;r(new I(o,n))},s.onerror=function(){i(new TypeError("Network request failed"))},s.ontimeout=function(){i(new TypeError("Network request failed"))},s.onabort=function(){i(new t.DOMException("Aborted","AbortError"))},s.open(a.method,a.url,!0),"include"===a.credentials?s.withCredentials=!0:"omit"===a.credentials&&(s.withCredentials=!1),"responseType"in s&&o&&(s.responseType="blob"),a.headers.forEach(function(e,t){s.setRequestHeader(t,e)}),a.signal&&(a.signal.addEventListener("abort",c),s.onreadystatechange=function(){4===s.readyState&&a.signal.removeEventListener("abort",c)}),s.send(void 0===a._bodyInit?null:a._bodyInit)})}S.polyfill=!0,e.fetch||(e.fetch=S,e.Headers=f,e.Request=v,e.Response=I),t.Headers=f,t.Request=v,t.Response=I,t.fetch=S,Object.defineProperty(t,"__esModule",{value:!0})}({})}(r),r.fetch.ponyfill=!0,delete r.fetch.polyfill;var o=r;(t=o.fetch).default=o.fetch,t.fetch=o.fetch,t.Headers=o.Headers,t.Request=o.Request,t.Response=o.Response,e.exports=t},5037:function(e,t,n){var r;function o(e){this.rand=e}if(e.exports=function(e){return r||(r=new o(null)),r.generate(e)},e.exports.Rand=o,o.prototype.generate=function(e){return this._rand(e)},o.prototype._rand=function(e){if(this.rand.getBytes)return this.rand.getBytes(e);for(var t=new Uint8Array(e),n=0;n<t.length;n++)t[n]=this.rand.getByte();return t},"object"==typeof self)self.crypto&&self.crypto.getRandomValues?o.prototype._rand=function(e){var t=new Uint8Array(e);return self.crypto.getRandomValues(t),t}:self.msCrypto&&self.msCrypto.getRandomValues?o.prototype._rand=function(e){var t=new Uint8Array(e);return self.msCrypto.getRandomValues(t),t}:"object"==typeof window&&(o.prototype._rand=function(){throw new Error("Not implemented yet")});else try{var i=n(1395);if("function"!=typeof i.randomBytes)throw new Error("Not supported");o.prototype._rand=function(e){return i.randomBytes(e)}}catch(a){}},5364:function(e){"use strict";e.exports=function(e){if(e.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),n=0;n<t.length;n++)t[n]=255;for(var r=0;r<e.length;r++){var o=e.charAt(r),i=o.charCodeAt(0);if(255!==t[i])throw new TypeError(o+" is ambiguous");t[i]=r}var a=e.length,s=e.charAt(0),c=Math.log(a)/Math.log(256),u=Math.log(256)/Math.log(a);function l(e){if("string"!=typeof e)throw new TypeError("Expected String");if(0===e.length)return new Uint8Array;for(var n=0,r=0,o=0;e[n]===s;)r++,n++;for(var i=(e.length-n)*c+1>>>0,u=new Uint8Array(i);e[n];){var l=e.charCodeAt(n);if(l>255)return;var d=t[l];if(255===d)return;for(var f=0,p=i-1;(0!==d||f<o)&&-1!==p;p--,f++)d+=a*u[p]>>>0,u[p]=d%256>>>0,d=d/256>>>0;if(0!==d)throw new Error("Non-zero carry");o=f,n++}for(var h=i-o;h!==i&&0===u[h];)h++;for(var y=new Uint8Array(r+(i-h)),b=r;h!==i;)y[b++]=u[h++];return y}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 n=0,r=0,o=0,i=t.length;o!==i&&0===t[o];)o++,n++;for(var c=(i-o)*u+1>>>0,l=new Uint8Array(c);o!==i;){for(var d=t[o],f=0,p=c-1;(0!==d||f<r)&&-1!==p;p--,f++)d+=256*l[p]>>>0,l[p]=d%a>>>0,d=d/a>>>0;if(0!==d)throw new Error("Non-zero carry");r=f,o++}for(var h=c-r;h!==c&&0===l[h];)h++;for(var y=s.repeat(n);h<c;++h)y+=e.charAt(l[h]);return y},decodeUnsafe:l,decode:function(e){var t=l(e);if(t)return t;throw new Error("Non-base"+a+" character")}}}},5817:function(e,t,n){var r=n(6341),o=n(726),i=n(5949);t.ai=function(e){return r(i,function(t){return t.number===String(e)})}},5949:function(e){e.exports=[{code:"AED",number:"784",digits:2,currency:"UAE Dirham",countries:["United Arab Emirates (The)"]},{code:"AFN",number:"971",digits:2,currency:"Afghani",countries:["Afghanistan"]},{code:"ALL",number:"008",digits:2,currency:"Lek",countries:["Albania"]},{code:"AMD",number:"051",digits:2,currency:"Armenian Dram",countries:["Armenia"]},{code:"ANG",number:"532",digits:2,currency:"Netherlands Antillean Guilder",countries:["CuraçAo","Sint Maarten (Dutch Part)"]},{code:"AOA",number:"973",digits:2,currency:"Kwanza",countries:["Angola"]},{code:"ARS",number:"032",digits:2,currency:"Argentine Peso",countries:["Argentina"]},{code:"AUD",number:"036",digits:2,currency:"Australian Dollar",countries:["Australia","Christmas Island","Cocos (Keeling) Islands (The)","Heard Island And Mcdonald Islands","Kiribati","Nauru","Norfolk Island","Tuvalu"]},{code:"AWG",number:"533",digits:2,currency:"Aruban Florin",countries:["Aruba"]},{code:"AZN",number:"944",digits:2,currency:"Azerbaijan Manat",countries:["Azerbaijan"]},{code:"BAM",number:"977",digits:2,currency:"Convertible Mark",countries:["Bosnia And Herzegovina"]},{code:"BBD",number:"052",digits:2,currency:"Barbados Dollar",countries:["Barbados"]},{code:"BDT",number:"050",digits:2,currency:"Taka",countries:["Bangladesh"]},{code:"BGN",number:"975",digits:2,currency:"Bulgarian Lev",countries:["Bulgaria"]},{code:"BHD",number:"048",digits:3,currency:"Bahraini Dinar",countries:["Bahrain"]},{code:"BIF",number:"108",digits:0,currency:"Burundi Franc",countries:["Burundi"]},{code:"BMD",number:"060",digits:2,currency:"Bermudian Dollar",countries:["Bermuda"]},{code:"BND",number:"096",digits:2,currency:"Brunei Dollar",countries:["Brunei Darussalam"]},{code:"BOB",number:"068",digits:2,currency:"Boliviano",countries:["Bolivia (Plurinational State Of)"]},{code:"BOV",number:"984",digits:2,currency:"Mvdol",countries:["Bolivia (Plurinational State Of)"]},{code:"BRL",number:"986",digits:2,currency:"Brazilian Real",countries:["Brazil"]},{code:"BSD",number:"044",digits:2,currency:"Bahamian Dollar",countries:["Bahamas (The)"]},{code:"BTN",number:"064",digits:2,currency:"Ngultrum",countries:["Bhutan"]},{code:"BWP",number:"072",digits:2,currency:"Pula",countries:["Botswana"]},{code:"BYN",number:"933",digits:2,currency:"Belarusian Ruble",countries:["Belarus"]},{code:"BZD",number:"084",digits:2,currency:"Belize Dollar",countries:["Belize"]},{code:"CAD",number:"124",digits:2,currency:"Canadian Dollar",countries:["Canada"]},{code:"CDF",number:"976",digits:2,currency:"Congolese Franc",countries:["Congo (The Democratic Republic Of The)"]},{code:"CHE",number:"947",digits:2,currency:"WIR Euro",countries:["Switzerland"]},{code:"CHF",number:"756",digits:2,currency:"Swiss Franc",countries:["Liechtenstein","Switzerland"]},{code:"CHW",number:"948",digits:2,currency:"WIR Franc",countries:["Switzerland"]},{code:"CLF",number:"990",digits:4,currency:"Unidad de Fomento",countries:["Chile"]},{code:"CLP",number:"152",digits:0,currency:"Chilean Peso",countries:["Chile"]},{code:"CNY",number:"156",digits:2,currency:"Yuan Renminbi",countries:["China"]},{code:"COP",number:"170",digits:2,currency:"Colombian Peso",countries:["Colombia"]},{code:"COU",number:"970",digits:2,currency:"Unidad de Valor Real",countries:["Colombia"]},{code:"CRC",number:"188",digits:2,currency:"Costa Rican Colon",countries:["Costa Rica"]},{code:"CUC",number:"931",digits:2,currency:"Peso Convertible",countries:["Cuba"]},{code:"CUP",number:"192",digits:2,currency:"Cuban Peso",countries:["Cuba"]},{code:"CVE",number:"132",digits:2,currency:"Cabo Verde Escudo",countries:["Cabo Verde"]},{code:"CZK",number:"203",digits:2,currency:"Czech Koruna",countries:["Czechia"]},{code:"DJF",number:"262",digits:0,currency:"Djibouti Franc",countries:["Djibouti"]},{code:"DKK",number:"208",digits:2,currency:"Danish Krone",countries:["Denmark","Faroe Islands (The)","Greenland"]},{code:"DOP",number:"214",digits:2,currency:"Dominican Peso",countries:["Dominican Republic (The)"]},{code:"DZD",number:"012",digits:2,currency:"Algerian Dinar",countries:["Algeria"]},{code:"EGP",number:"818",digits:2,currency:"Egyptian Pound",countries:["Egypt"]},{code:"ERN",number:"232",digits:2,currency:"Nakfa",countries:["Eritrea"]},{code:"ETB",number:"230",digits:2,currency:"Ethiopian Birr",countries:["Ethiopia"]},{code:"EUR",number:"978",digits:2,currency:"Euro",countries:["Andorra","Austria","Belgium","Cyprus","Estonia","European Union","Finland","France","French Guiana","French Southern Territories (The)","Germany","Greece","Guadeloupe","Holy See (The)","Ireland","Italy","Latvia","Lithuania","Luxembourg","Malta","Martinique","Mayotte","Monaco","Montenegro","Netherlands (The)","Portugal","Réunion","Saint Barthélemy","Saint Martin (French Part)","Saint Pierre And Miquelon","San Marino","Slovakia","Slovenia","Spain","Åland Islands"]},{code:"FJD",number:"242",digits:2,currency:"Fiji Dollar",countries:["Fiji"]},{code:"FKP",number:"238",digits:2,currency:"Falkland Islands Pound",countries:["Falkland Islands (The) [Malvinas]"]},{code:"GBP",number:"826",digits:2,currency:"Pound Sterling",countries:["Guernsey","Isle Of Man","Jersey","United Kingdom Of Great Britain And Northern Ireland (The)"]},{code:"GEL",number:"981",digits:2,currency:"Lari",countries:["Georgia"]},{code:"GHS",number:"936",digits:2,currency:"Ghana Cedi",countries:["Ghana"]},{code:"GIP",number:"292",digits:2,currency:"Gibraltar Pound",countries:["Gibraltar"]},{code:"GMD",number:"270",digits:2,currency:"Dalasi",countries:["Gambia (The)"]},{code:"GNF",number:"324",digits:0,currency:"Guinean Franc",countries:["Guinea"]},{code:"GTQ",number:"320",digits:2,currency:"Quetzal",countries:["Guatemala"]},{code:"GYD",number:"328",digits:2,currency:"Guyana Dollar",countries:["Guyana"]},{code:"HKD",number:"344",digits:2,currency:"Hong Kong Dollar",countries:["Hong Kong"]},{code:"HNL",number:"340",digits:2,currency:"Lempira",countries:["Honduras"]},{code:"HRK",number:"191",digits:2,currency:"Kuna",countries:["Croatia"]},{code:"HTG",number:"332",digits:2,currency:"Gourde",countries:["Haiti"]},{code:"HUF",number:"348",digits:2,currency:"Forint",countries:["Hungary"]},{code:"IDR",number:"360",digits:2,currency:"Rupiah",countries:["Indonesia"]},{code:"ILS",number:"376",digits:2,currency:"New Israeli Sheqel",countries:["Israel"]},{code:"INR",number:"356",digits:2,currency:"Indian Rupee",countries:["Bhutan","India"]},{code:"IQD",number:"368",digits:3,currency:"Iraqi Dinar",countries:["Iraq"]},{code:"IRR",number:"364",digits:2,currency:"Iranian Rial",countries:["Iran (Islamic Republic Of)"]},{code:"ISK",number:"352",digits:0,currency:"Iceland Krona",countries:["Iceland"]},{code:"JMD",number:"388",digits:2,currency:"Jamaican Dollar",countries:["Jamaica"]},{code:"JOD",number:"400",digits:3,currency:"Jordanian Dinar",countries:["Jordan"]},{code:"JPY",number:"392",digits:0,currency:"Yen",countries:["Japan"]},{code:"KES",number:"404",digits:2,currency:"Kenyan Shilling",countries:["Kenya"]},{code:"KGS",number:"417",digits:2,currency:"Som",countries:["Kyrgyzstan"]},{code:"KHR",number:"116",digits:2,currency:"Riel",countries:["Cambodia"]},{code:"KMF",number:"174",digits:0,currency:"Comorian Franc ",countries:["Comoros (The)"]},{code:"KPW",number:"408",digits:2,currency:"North Korean Won",countries:["Korea (The Democratic People's Republic Of)"]},{code:"KRW",number:"410",digits:0,currency:"Won",countries:["Korea (The Republic Of)"]},{code:"KWD",number:"414",digits:3,currency:"Kuwaiti Dinar",countries:["Kuwait"]},{code:"KYD",number:"136",digits:2,currency:"Cayman Islands Dollar",countries:["Cayman Islands (The)"]},{code:"KZT",number:"398",digits:2,currency:"Tenge",countries:["Kazakhstan"]},{code:"LAK",number:"418",digits:2,currency:"Lao Kip",countries:["Lao People's Democratic Republic (The)"]},{code:"LBP",number:"422",digits:2,currency:"Lebanese Pound",countries:["Lebanon"]},{code:"LKR",number:"144",digits:2,currency:"Sri Lanka Rupee",countries:["Sri Lanka"]},{code:"LRD",number:"430",digits:2,currency:"Liberian Dollar",countries:["Liberia"]},{code:"LSL",number:"426",digits:2,currency:"Loti",countries:["Lesotho"]},{code:"LYD",number:"434",digits:3,currency:"Libyan Dinar",countries:["Libya"]},{code:"MAD",number:"504",digits:2,currency:"Moroccan Dirham",countries:["Morocco","Western Sahara"]},{code:"MDL",number:"498",digits:2,currency:"Moldovan Leu",countries:["Moldova (The Republic Of)"]},{code:"MGA",number:"969",digits:2,currency:"Malagasy Ariary",countries:["Madagascar"]},{code:"MKD",number:"807",digits:2,currency:"Denar",countries:["Macedonia (The Former Yugoslav Republic Of)"]},{code:"MMK",number:"104",digits:2,currency:"Kyat",countries:["Myanmar"]},{code:"MNT",number:"496",digits:2,currency:"Tugrik",countries:["Mongolia"]},{code:"MOP",number:"446",digits:2,currency:"Pataca",countries:["Macao"]},{code:"MRU",number:"929",digits:2,currency:"Ouguiya",countries:["Mauritania"]},{code:"MUR",number:"480",digits:2,currency:"Mauritius Rupee",countries:["Mauritius"]},{code:"MVR",number:"462",digits:2,currency:"Rufiyaa",countries:["Maldives"]},{code:"MWK",number:"454",digits:2,currency:"Malawi Kwacha",countries:["Malawi"]},{code:"MXN",number:"484",digits:2,currency:"Mexican Peso",countries:["Mexico"]},{code:"MXV",number:"979",digits:2,currency:"Mexican Unidad de Inversion (UDI)",countries:["Mexico"]},{code:"MYR",number:"458",digits:2,currency:"Malaysian Ringgit",countries:["Malaysia"]},{code:"MZN",number:"943",digits:2,currency:"Mozambique Metical",countries:["Mozambique"]},{code:"NAD",number:"516",digits:2,currency:"Namibia Dollar",countries:["Namibia"]},{code:"NGN",number:"566",digits:2,currency:"Naira",countries:["Nigeria"]},{code:"NIO",number:"558",digits:2,currency:"Cordoba Oro",countries:["Nicaragua"]},{code:"NOK",number:"578",digits:2,currency:"Norwegian Krone",countries:["Bouvet Island","Norway","Svalbard And Jan Mayen"]},{code:"NPR",number:"524",digits:2,currency:"Nepalese Rupee",countries:["Nepal"]},{code:"NZD",number:"554",digits:2,currency:"New Zealand Dollar",countries:["Cook Islands (The)","New Zealand","Niue","Pitcairn","Tokelau"]},{code:"OMR",number:"512",digits:3,currency:"Rial Omani",countries:["Oman"]},{code:"PAB",number:"590",digits:2,currency:"Balboa",countries:["Panama"]},{code:"PEN",number:"604",digits:2,currency:"Sol",countries:["Peru"]},{code:"PGK",number:"598",digits:2,currency:"Kina",countries:["Papua New Guinea"]},{code:"PHP",number:"608",digits:2,currency:"Philippine Piso",countries:["Philippines (The)"]},{code:"PKR",number:"586",digits:2,currency:"Pakistan Rupee",countries:["Pakistan"]},{code:"PLN",number:"985",digits:2,currency:"Zloty",countries:["Poland"]},{code:"PYG",number:"600",digits:0,currency:"Guarani",countries:["Paraguay"]},{code:"QAR",number:"634",digits:2,currency:"Qatari Rial",countries:["Qatar"]},{code:"RON",number:"946",digits:2,currency:"Romanian Leu",countries:["Romania"]},{code:"RSD",number:"941",digits:2,currency:"Serbian Dinar",countries:["Serbia"]},{code:"RUB",number:"643",digits:2,currency:"Russian Ruble",countries:["Russian Federation (The)"]},{code:"RWF",number:"646",digits:0,currency:"Rwanda Franc",countries:["Rwanda"]},{code:"SAR",number:"682",digits:2,currency:"Saudi Riyal",countries:["Saudi Arabia"]},{code:"SBD",number:"090",digits:2,currency:"Solomon Islands Dollar",countries:["Solomon Islands"]},{code:"SCR",number:"690",digits:2,currency:"Seychelles Rupee",countries:["Seychelles"]},{code:"SDG",number:"938",digits:2,currency:"Sudanese Pound",countries:["Sudan (The)"]},{code:"SEK",number:"752",digits:2,currency:"Swedish Krona",countries:["Sweden"]},{code:"SGD",number:"702",digits:2,currency:"Singapore Dollar",countries:["Singapore"]},{code:"SHP",number:"654",digits:2,currency:"Saint Helena Pound",countries:["Saint Helena, Ascension And Tristan Da Cunha"]},{code:"SLL",number:"694",digits:2,currency:"Leone",countries:["Sierra Leone"]},{code:"SOS",number:"706",digits:2,currency:"Somali Shilling",countries:["Somalia"]},{code:"SRD",number:"968",digits:2,currency:"Surinam Dollar",countries:["Suriname"]},{code:"SSP",number:"728",digits:2,currency:"South Sudanese Pound",countries:["South Sudan"]},{code:"STN",number:"930",digits:2,currency:"Dobra",countries:["Sao Tome And Principe"]},{code:"SVC",number:"222",digits:2,currency:"El Salvador Colon",countries:["El Salvador"]},{code:"SYP",number:"760",digits:2,currency:"Syrian Pound",countries:["Syrian Arab Republic"]},{code:"SZL",number:"748",digits:2,currency:"Lilangeni",countries:["Swaziland"]},{code:"THB",number:"764",digits:2,currency:"Baht",countries:["Thailand"]},{code:"TJS",number:"972",digits:2,currency:"Somoni",countries:["Tajikistan"]},{code:"TMT",number:"934",digits:2,currency:"Turkmenistan New Manat",countries:["Turkmenistan"]},{code:"TND",number:"788",digits:3,currency:"Tunisian Dinar",countries:["Tunisia"]},{code:"TOP",number:"776",digits:2,currency:"Pa'anga",countries:["Tonga"]},{code:"TRY",number:"949",digits:2,currency:"Turkish Lira",countries:["Turkey"]},{code:"TTD",number:"780",digits:2,currency:"Trinidad and Tobago Dollar",countries:["Trinidad And Tobago"]},{code:"TWD",number:"901",digits:2,currency:"New Taiwan Dollar",countries:["Taiwan (Province Of China)"]},{code:"TZS",number:"834",digits:2,currency:"Tanzanian Shilling",countries:["Tanzania, United Republic Of"]},{code:"UAH",number:"980",digits:2,currency:"Hryvnia",countries:["Ukraine"]},{code:"UGX",number:"800",digits:0,currency:"Uganda Shilling",countries:["Uganda"]},{code:"USD",number:"840",digits:2,currency:"US Dollar",countries:["American Samoa","Bonaire, Sint Eustatius And Saba","British Indian Ocean Territory (The)","Ecuador","El Salvador","Guam","Haiti","Marshall Islands (The)","Micronesia (Federated States Of)","Northern Mariana Islands (The)","Palau","Panama","Puerto Rico","Timor-Leste","Turks And Caicos Islands (The)","United States Minor Outlying Islands (The)","United States Of America (The)","Virgin Islands (British)","Virgin Islands (U.S.)"]},{code:"USN",number:"997",digits:2,currency:"US Dollar (Next day)",countries:["United States Of America (The)"]},{code:"UYI",number:"940",digits:0,currency:"Uruguay Peso en Unidades Indexadas (URUIURUI)",countries:["Uruguay"]},{code:"UYU",number:"858",digits:2,currency:"Peso Uruguayo",countries:["Uruguay"]},{code:"UZS",number:"860",digits:2,currency:"Uzbekistan Sum",countries:["Uzbekistan"]},{code:"VEF",number:"937",digits:2,currency:"Bolívar",countries:["Venezuela (Bolivarian Republic Of)"]},{code:"VND",number:"704",digits:0,currency:"Dong",countries:["Viet Nam"]},{code:"VUV",number:"548",digits:0,currency:"Vatu",countries:["Vanuatu"]},{code:"WST",number:"882",digits:2,currency:"Tala",countries:["Samoa"]},{code:"XAF",number:"950",digits:0,currency:"CFA Franc BEAC",countries:["Cameroon","Central African Republic (The)","Chad","Congo (The)","Equatorial Guinea","Gabon"]},{code:"XAG",number:"961",digits:0,currency:"Silver",countries:[]},{code:"XAU",number:"959",digits:0,currency:"Gold",countries:[]},{code:"XBA",number:"955",digits:0,currency:"Bond Markets Unit European Composite Unit (EURCO)",countries:[]},{code:"XBB",number:"956",digits:0,currency:"Bond Markets Unit European Monetary Unit (E.M.U.-6)",countries:[]},{code:"XBC",number:"957",digits:0,currency:"Bond Markets Unit European Unit of Account 9 (E.U.A.-9)",countries:[]},{code:"XBD",number:"958",digits:0,currency:"Bond Markets Unit European Unit of Account 17 (E.U.A.-17)",countries:[]},{code:"XCD",number:"951",digits:2,currency:"East Caribbean Dollar",countries:["Anguilla","Antigua And Barbuda","Dominica","Grenada","Montserrat","Saint Kitts And Nevis","Saint Lucia","Saint Vincent And The Grenadines"]},{code:"XDR",number:"960",digits:0,currency:"SDR (Special Drawing Right)",countries:["International Monetary Fund (Imf) "]},{code:"XOF",number:"952",digits:0,currency:"CFA Franc BCEAO",countries:["Benin","Burkina Faso","Côte d'Ivoire","Guinea-Bissau","Mali","Niger (The)","Senegal","Togo"]},{code:"XPD",number:"964",digits:0,currency:"Palladium",countries:[]},{code:"XPF",number:"953",digits:0,currency:"CFP Franc",countries:["French Polynesia","New Caledonia","Wallis And Futuna"]},{code:"XPT",number:"962",digits:0,currency:"Platinum",countries:[]},{code:"XSU",number:"994",digits:0,currency:"Sucre",countries:['Sistema Unitario De Compensacion Regional De Pagos "Sucre"']},{code:"XTS",number:"963",digits:0,currency:"Codes specifically reserved for testing purposes",countries:[]},{code:"XUA",number:"965",digits:0,currency:"ADB Unit of Account",countries:["Member Countries Of The African Development Bank Group"]},{code:"XXX",number:"999",digits:0,currency:"The codes assigned for transactions where no currency is involved",countries:[]},{code:"YER",number:"886",digits:2,currency:"Yemeni Rial",countries:["Yemen"]},{code:"ZAR",number:"710",digits:2,currency:"Rand",countries:["Lesotho","Namibia","South Africa"]},{code:"ZMW",number:"967",digits:2,currency:"Zambian Kwacha",countries:["Zambia"]},{code:"ZWL",number:"932",digits:2,currency:"Zimbabwe Dollar",countries:["Zimbabwe"]}]},6001:function(e,t,n){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.log10=t.toFixed=t.toBns=t.round=t.ceil=t.floor=t.max=t.abs=t.min=t.eq=t.gte=t.gt=t.lte=t.lt=t.div=t.sub=t.mul=t.add=void 0;const o=r(n(9404)),i=/^(-?\d*\.?\d*)e((?:\+|-)?\d+)$/;function a(e,t,n=10){if(10!==n&&16!==n)throw new Error("Unsupported base");let{x:r,y:i,shift:a}=h(e,t);const s=y(r)?16:10,c=y(i)?16:10;r=p(r),i=p(i);const u=new o.default(r,s),l=new o.default(i,c);let f=u.add(l).toString(n);return f=d(f,a),10===n?f:f.replace(/^(-)?/,"$10x")}function s(e,t,n=10){if(10!==n&&16!==n)throw new Error("Unsupported base");let{x:r,y:i,shift:a}=h(e,t);const s=y(r)?16:10,c=y(i)?16:10;r=p(r),i=p(i);const u=new o.default(r,s),l=new o.default(i,c);let f=u.mul(l).toString(n);return f=d(f,2*a),10===n?f:f.replace(/^(-)?/,"$10x")}function c(e,t){let{x:n,y:r}=h(e,t);const i=y(n)?16:10,a=y(r)?16:10;n=p(n),r=p(r);const s=new o.default(n,i),c=new o.default(r,a);return s.gt(c)}function u(e,t){let{x:n,y:r}=h(e,t);const i=y(n)?16:10,a=y(r)?16:10;n=p(n),r=p(r);const s=new o.default(n,i),c=new o.default(r,a);return s.gte(c)}function l(e){let t="number"==typeof e?e.toString():e.replace(/^\s+|\s+$/g,"");""!==t&&"."!==t||(t="0");const n=t.match(i);if(null!=n){t=function(e,t){const n=t>=0?"1"+"0".repeat(Math.abs(t)):`0.${"0".repeat(Math.abs(t)-1)}1`;return s(e,n)}(n[1],parseInt(n[2]))}return function(...e){for(const t of e){if(t.split(".").length-1>1)throw new Error(`Invalid number: more than one decimal point '${t}'`);if(t.split("-").length-1>1)throw new Error(`Invalid number: more than one negative sign '${t}'`);if(!/^-?(?:0x[0-9A-Fa-f]+|(?:\d+(?:\.\d*)?|\.\d+))$/.test(t))throw new Error(`Invalid number: non-number characters '${t}'`)}}(t),t}function d(e,t){if(0===t)return e;let n,r=!1;return"-"===e.slice(0,1)&&(r=!0,e=e.slice(1)),n=t>e.length?"0."+f("",t-e.length)+e:e.substr(0,e.length-t)+"."+e.substr(e.length-t,e.length),n=g(n),r&&(n=`-${n}`),n}function f(e,t){let n=e;for(let r=0;r<t;r++)n+="0";return n}function p(e){return e.replace("0x","")}function h(e,t,n){let r=l(e),o=l(t),i=r.indexOf("."),a=o.indexOf(".");const s=y(r),c=y(o);if(-1!==i&&(r=g(r),i=r.indexOf(".")),-1!==a&&(o=g(o),a=o.indexOf(".")),-1!==i||-1!==a||"number"==typeof n){if(s||c)throw new Error("Cannot operate on base16 float values");let e=0,t=0;-1!==i&&(e=r.length-i-1),-1!==a&&(t=o.length-a-1);const u=e>t?e:t;let l=0;"number"==typeof n&&(l=n),r=f(r.replace(".",""),u+l-e),o=f(o.replace(".",""),u-t);return{x:r,y:o,shift:u}}return{x:r,y:o,shift:0}}function y(e){const t=l(e);return!!(t.startsWith("0x")||t.startsWith("-0x")||t.toLowerCase().includes("a")||t.toLowerCase().includes("b")||t.toLowerCase().includes("c")||t.toLowerCase().includes("d")||t.toLowerCase().includes("e")||t.toLowerCase().includes("f"))}function b(e,t,n=0){var r,o;let i=l(t),s=!1,d="";i.includes("-")&&(s=!0,i=i.replace(/^-+/,""));const[f,p=""]=i.split("."),h=i.indexOf("."),y=-1!==h?h-n:i.length-n,b=f+p;if("round"===e){e=u(null!==(r=b[y])&&void 0!==r?r:"0","5")?"ceil":"floor"}const w=Math.max(b.length-y+1,0),v=new Array(w).join("0");let m=b.substring(0,y)+v;const I=c(b.substring(y),"0");if("ceil"===e&&I){const e="1"+v,t=(null!==(o=m.match(/^0+/))&&void 0!==o?o:[""])[0].length;m=new Array(t).join("0")+a(m,e)}const E=h+(m.length-b.length);return d=-1!==h?m.substring(0,E)+"."+m.substring(E):m,d=g(d),s&&"0"!==d&&(d="-"+d),d}function g(e){let t=e.replace(/^0+/,"");return t=t.replace(/^\.+/,"0."),t.includes(".")&&(t=t.replace(/0+$/,""),t=t.replace(/\.+$/,""),""===t&&(t="0")),""===t&&(t="0"),t}t.add=a,t.mul=s,t.sub=function(e,t,n=10){if(10!==n&&16!==n)throw new Error("Unsupported base");let{x:r,y:i,shift:a}=h(e,t);const s=y(r)?16:10,c=y(i)?16:10;r=p(r),i=p(i);const u=new o.default(r,s),l=new o.default(i,c);let f=u.sub(l).toString(n);return f=d(f,a),10===n?f:f.replace(/^(-)?/,"$10x")},t.div=function(e,t,n=0,r=10){if(10!==r&&n>0)throw new Error("Cannot operate on floating point hex values");if(10!==r&&16!==r)throw new Error("Unsupported base");let{x:i,y:a}=h(e,t,n);const s=y(i)?16:10,c=y(a)?16:10;i=p(i),a=p(a);const u=new o.default(i,s),l=new o.default(a,c);let f=u.div(l).toString(r);return f=d(f,n),10===r?f:f.replace(/^(-)?/,"$10x")},t.lt=function(e,t){let{x:n,y:r}=h(e,t);const i=y(n)?16:10,a=y(r)?16:10;n=p(n),r=p(r);const s=new o.default(n,i),c=new o.default(r,a);return s.lt(c)},t.lte=function(e,t){let{x:n,y:r}=h(e,t);const i=y(n)?16:10,a=y(r)?16:10;n=p(n),r=p(r);const s=new o.default(n,i),c=new o.default(r,a);return s.lte(c)},t.gt=c,t.gte=u,t.eq=function(e,t){let{x:n,y:r}=h(e,t);const i=y(n)?16:10,a=y(r)?16:10;n=p(n),r=p(r);const s=new o.default(n,i),c=new o.default(r,a);return s.eq(c)},t.min=function(e,t,n=10){let{x:r,y:i,shift:a}=h(e,t);const s=y(r)?16:10,c=y(i)?16:10;r=p(r),i=p(i);const u=new o.default(r,s),l=new o.default(i,c);let f;return f=u.lte(l)?u.toString(n):l.toString(n),f=d(f,a),10===n?f:f.replace(/^(-)?/,"$10x")},t.abs=function(e,t=10){if(10!==t&&16!==t)throw new Error("Unsupported base");let{x:n,shift:r}=h(e,"0");const i=y(e)?16:10;n=p(n);let a=new o.default(n,i).abs().toString(t);return a=d(a,r),10===t?a:a.replace(/^(-)?/,"$10x")},t.max=function(e,t,n=10){let{x:r,y:i,shift:a}=h(e,t);const s=y(r)?16:10,c=y(i)?16:10;r=p(r),i=p(i);const u=new o.default(r,s),l=new o.default(i,c);let f;return f=u.gte(l)?u.toString(n):l.toString(n),f=d(f,a),10===n?f:f.replace(/^(-)?/,"$10x")},t.floor=(e,t)=>b("floor",e,t),t.ceil=(e,t)=>b("ceil",e,t),t.round=(e,t)=>b("round",e,t),t.toBns=l,t.toFixed=function(e,t=2,n=8){let r=l(e),o=!1,i="";r.includes("-")&&(o=!0,r=r.replace(/^-+/,"")),r=g(r);const a=r.indexOf(".");if(-1===a)i=r+"."+f("",t);else{const e=r.length-a-1;i=e>n?r.substr(0,r.length-(e-n)):e<t?r+f("",t-e):r}return i=i.replace(/\.+$/,""),o&&"0"!==i&&(i="-"+i),i},t.log10=function(e){if(null===e.match(/^[0-1]+$/g))throw new Error("InvalidLogInputValue: Must be a power of 10");if(!e.startsWith("1"))throw new Error("InvalidLogInputValue: Must not have leading zeros");if((e.match(/1/g)||[]).length>1)throw new Error("InvalidLogInputValue: Must be power of 10.");return(e.match(/0/g)||[]).length}},6166:function(e,t,n){"use strict";var r=n(7426),o=n(3349);function i(){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=i,i.prototype.update=function(e,t){if(e=r.toArray(e,t),this.pending?this.pending=this.pending.concat(e):this.pending=e,this.pendingTotal+=e.length,this.pending.length>=this._delta8){var n=(e=this.pending).length%this._delta8;this.pending=e.slice(e.length-n,e.length),0===this.pending.length&&(this.pending=null),e=r.join32(e,0,e.length-n,this.endian);for(var o=0;o<e.length;o+=this._delta32)this._update(e,o,o+this._delta32)}return this},i.prototype.digest=function(e){return this.update(this._pad()),o(null===this.pending),this._digest(e)},i.prototype._pad=function(){var e=this.pendingTotal,t=this._delta8,n=t-(e+this.padLength)%t,r=new Array(n+this.padLength);r[0]=128;for(var o=1;o<n;o++)r[o]=0;if(e<<=3,"big"===this.endian){for(var i=8;i<this.padLength;i++)r[o++]=0;r[o++]=0,r[o++]=0,r[o++]=0,r[o++]=0,r[o++]=e>>>24&255,r[o++]=e>>>16&255,r[o++]=e>>>8&255,r[o++]=255&e}else for(r[o++]=255&e,r[o++]=e>>>8&255,r[o++]=e>>>16&255,r[o++]=e>>>24&255,r[o++]=0,r[o++]=0,r[o++]=0,r[o++]=0,i=8;i<this.padLength;i++)r[o++]=0;return r}},6225:function(e,t,n){"use strict";var r=n(7426).rotr32;function o(e,t,n){return e&t^~e&n}function i(e,t,n){return e&t^e&n^t&n}function a(e,t,n){return e^t^n}t.ft_1=function(e,t,n,r){return 0===e?o(t,n,r):1===e||3===e?a(t,n,r):2===e?i(t,n,r):void 0},t.ch32=o,t.maj32=i,t.p32=a,t.s0_256=function(e){return r(e,2)^r(e,13)^r(e,22)},t.s1_256=function(e){return r(e,6)^r(e,11)^r(e,25)},t.g0_256=function(e){return r(e,7)^r(e,18)^e>>>3},t.g1_256=function(e){return r(e,17)^r(e,19)^e>>>10}},6229:function(e,t,n){"use strict";t.sha1=n(3917),t.sha224=n(7714),t.sha256=n(2287),t.sha384=n(1911),t.sha512=n(7766)},6341:function(e){function t(e){return e}e.exports=function(e,n,r){n=n||t,r=r||e;for(var o=0,i=e.length;o<i;o+=1)if(n.call(r,e[o],o))return e[o]}},6661:function(e,t,n){"use strict";var r=n(7011),o=r.assert,i=r.parseBytes,a=r.cachedProperty;function s(e,t){this.eddsa=e,this._secret=i(t.secret),e.isPoint(t.pub)?this._pub=t.pub:this._pubBytes=i(t.pub)}s.fromPublic=function(e,t){return t instanceof s?t:new s(e,{pub:t})},s.fromSecret=function(e,t){return t instanceof s?t:new s(e,{secret:t})},s.prototype.secret=function(){return this._secret},a(s,"pubBytes",function(){return this.eddsa.encodePoint(this.pub())}),a(s,"pub",function(){return this._pubBytes?this.eddsa.decodePoint(this._pubBytes):this.eddsa.g.mul(this.priv())}),a(s,"privBytes",function(){var e=this.eddsa,t=this.hash(),n=e.encodingLength-1,r=t.slice(0,e.encodingLength);return r[0]&=248,r[n]&=127,r[n]|=64,r}),a(s,"priv",function(){return this.eddsa.decodeInt(this.privBytes())}),a(s,"hash",function(){return this.eddsa.hash().update(this.secret()).digest()}),a(s,"messagePrefix",function(){return this.hash().slice(this.eddsa.encodingLength)}),s.prototype.sign=function(e){return o(this._secret,"KeyPair can only verify"),this.eddsa.sign(e,this)},s.prototype.verify=function(e,t){return this.eddsa.verify(e,t,this)},s.prototype.getSecret=function(e){return o(this._secret,"KeyPair is public only"),r.encode(this.secret(),e)},s.prototype.getPublic=function(e){return r.encode(this.pubBytes(),e)},e.exports=s},6677:function(e,t,n){"use strict";var r=n(9404),o=n(7011),i=o.getNAF,a=o.getJSF,s=o.assert;function c(e,t){this.type=e,this.p=new r(t.p,16),this.red=t.prime?r.red(t.prime):r.mont(this.p),this.zero=new r(0).toRed(this.red),this.one=new r(1).toRed(this.red),this.two=new r(2).toRed(this.red),this.n=t.n&&new r(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 n=this.n&&this.p.div(this.n);!n||n.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}function u(e,t){this.curve=e,this.type=t,this.precomputed=null}e.exports=c,c.prototype.point=function(){throw new Error("Not implemented")},c.prototype.validate=function(){throw new Error("Not implemented")},c.prototype._fixedNafMul=function(e,t){s(e.precomputed);var n=e._getDoubles(),r=i(t,1,this._bitLength),o=(1<<n.step+1)-(n.step%2==0?2:1);o/=3;var a,c,u=[];for(a=0;a<r.length;a+=n.step){c=0;for(var l=a+n.step-1;l>=a;l--)c=(c<<1)+r[l];u.push(c)}for(var d=this.jpoint(null,null,null),f=this.jpoint(null,null,null),p=o;p>0;p--){for(a=0;a<u.length;a++)(c=u[a])===p?f=f.mixedAdd(n.points[a]):c===-p&&(f=f.mixedAdd(n.points[a].neg()));d=d.add(f)}return d.toP()},c.prototype._wnafMul=function(e,t){var n=4,r=e._getNAFPoints(n);n=r.wnd;for(var o=r.points,a=i(t,n,this._bitLength),c=this.jpoint(null,null,null),u=a.length-1;u>=0;u--){for(var l=0;u>=0&&0===a[u];u--)l++;if(u>=0&&l++,c=c.dblp(l),u<0)break;var d=a[u];s(0!==d),c="affine"===e.type?d>0?c.mixedAdd(o[d-1>>1]):c.mixedAdd(o[-d-1>>1].neg()):d>0?c.add(o[d-1>>1]):c.add(o[-d-1>>1].neg())}return"affine"===e.type?c.toP():c},c.prototype._wnafMulAdd=function(e,t,n,r,o){var s,c,u,l=this._wnafT1,d=this._wnafT2,f=this._wnafT3,p=0;for(s=0;s<r;s++){var h=(u=t[s])._getNAFPoints(e);l[s]=h.wnd,d[s]=h.points}for(s=r-1;s>=1;s-=2){var y=s-1,b=s;if(1===l[y]&&1===l[b]){var g=[t[y],null,null,t[b]];0===t[y].y.cmp(t[b].y)?(g[1]=t[y].add(t[b]),g[2]=t[y].toJ().mixedAdd(t[b].neg())):0===t[y].y.cmp(t[b].y.redNeg())?(g[1]=t[y].toJ().mixedAdd(t[b]),g[2]=t[y].add(t[b].neg())):(g[1]=t[y].toJ().mixedAdd(t[b]),g[2]=t[y].toJ().mixedAdd(t[b].neg()));var w=[-3,-1,-5,-7,0,7,5,1,3],v=a(n[y],n[b]);for(p=Math.max(v[0].length,p),f[y]=new Array(p),f[b]=new Array(p),c=0;c<p;c++){var m=0|v[0][c],I=0|v[1][c];f[y][c]=w[3*(m+1)+(I+1)],f[b][c]=0,d[y]=g}}else f[y]=i(n[y],l[y],this._bitLength),f[b]=i(n[b],l[b],this._bitLength),p=Math.max(f[y].length,p),p=Math.max(f[b].length,p)}var E=this.jpoint(null,null,null),S=this._wnafT4;for(s=p;s>=0;s--){for(var O=0;s>=0;){var A=!0;for(c=0;c<r;c++)S[c]=0|f[c][s],0!==S[c]&&(A=!1);if(!A)break;O++,s--}if(s>=0&&O++,E=E.dblp(O),s<0)break;for(c=0;c<r;c++){var T=S[c];0!==T&&(T>0?u=d[c][T-1>>1]:T<0&&(u=d[c][-T-1>>1].neg()),E="affine"===u.type?E.mixedAdd(u):E.add(u))}}for(s=0;s<r;s++)d[s]=null;return o?E:E.toP()},c.BasePoint=u,u.prototype.eq=function(){throw new Error("Not implemented")},u.prototype.validate=function(){return this.curve.validate(this)},c.prototype.decodePoint=function(e,t){e=o.toArray(e,t);var n=this.p.byteLength();if((4===e[0]||6===e[0]||7===e[0])&&e.length-1==2*n)return 6===e[0]?s(e[e.length-1]%2==0):7===e[0]&&s(e[e.length-1]%2==1),this.point(e.slice(1,1+n),e.slice(1+n,1+2*n));if((2===e[0]||3===e[0])&&e.length-1===n)return this.pointFromX(e.slice(1,1+n),3===e[0]);throw new Error("Unknown point format")},u.prototype.encodeCompressed=function(e){return this.encode(e,!0)},u.prototype._encode=function(e){var t=this.curve.p.byteLength(),n=this.getX().toArray("be",t);return e?[this.getY().isEven()?2:3].concat(n):[4].concat(n,this.getY().toArray("be",t))},u.prototype.encode=function(e,t){return o.encode(this._encode(t),e)},u.prototype.precompute=function(e){if(this.precomputed)return this;var t={doubles:null,naf:null,beta:null};return t.naf=this._getNAFPoints(8),t.doubles=this._getDoubles(4,e),t.beta=this._getBeta(),this.precomputed=t,this},u.prototype._hasDoubles=function(e){if(!this.precomputed)return!1;var t=this.precomputed.doubles;return!!t&&t.points.length>=Math.ceil((e.bitLength()+1)/t.step)},u.prototype._getDoubles=function(e,t){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var n=[this],r=this,o=0;o<t;o+=e){for(var i=0;i<e;i++)r=r.dbl();n.push(r)}return{step:e,points:n}},u.prototype._getNAFPoints=function(e){if(this.precomputed&&this.precomputed.naf)return this.precomputed.naf;for(var t=[this],n=(1<<e)-1,r=1===n?null:this.dbl(),o=1;o<n;o++)t[o]=t[o-1].add(r);return{wnd:e,points:t}},u.prototype._getBeta=function(){return null},u.prototype.dblp=function(e){for(var t=this,n=0;n<e;n++)t=t.dbl();return t}},6698:function(e){"function"==typeof Object.create?e.exports=function(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:e.exports=function(e,t){if(t){e.super_=t;var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e}}},6729:function(e,t,n){"use strict";var r=t;r.version=n(1636).rE,r.utils=n(7011),r.rand=n(5037),r.curve=n(894),r.curves=n(480),r.ec=n(7447),r.eddsa=n(8650)},6784:function(e,t,n){"use strict";var r=n(7426),o=n(6166),i=r.rotl32,a=r.sum32,s=r.sum32_3,c=r.sum32_4,u=o.BlockHash;function l(){if(!(this instanceof l))return new l;u.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.endian="little"}function d(e,t,n,r){return e<=15?t^n^r:e<=31?t&n|~t&r:e<=47?(t|~n)^r:e<=63?t&r|n&~r:t^(n|~r)}function f(e){return e<=15?0:e<=31?1518500249:e<=47?1859775393:e<=63?2400959708:2840853838}function p(e){return e<=15?1352829926:e<=31?1548603684:e<=47?1836072691:e<=63?2053994217:0}r.inherits(l,u),t.ripemd160=l,l.blockSize=512,l.outSize=160,l.hmacStrength=192,l.padLength=64,l.prototype._update=function(e,t){for(var n=this.h[0],r=this.h[1],o=this.h[2],u=this.h[3],l=this.h[4],w=n,v=r,m=o,I=u,E=l,S=0;S<80;S++){var O=a(i(c(n,d(S,r,o,u),e[h[S]+t],f(S)),b[S]),l);n=l,l=u,u=i(o,10),o=r,r=O,O=a(i(c(w,d(79-S,v,m,I),e[y[S]+t],p(S)),g[S]),E),w=E,E=I,I=i(m,10),m=v,v=O}O=s(this.h[1],o,I),this.h[1]=s(this.h[2],u,E),this.h[2]=s(this.h[3],l,w),this.h[3]=s(this.h[4],n,v),this.h[4]=s(this.h[0],r,m),this.h[0]=O},l.prototype._digest=function(e){return"hex"===e?r.toHex32(this.h,"little"):r.split32(this.h,"little")};var h=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],y=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],b=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],g=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]},7011:function(e,t,n){"use strict";var r=t,o=n(9404),i=n(3349),a=n(4367);r.assert=i,r.toArray=a.toArray,r.zero2=a.zero2,r.toHex=a.toHex,r.encode=a.encode,r.getNAF=function(e,t,n){var r=new Array(Math.max(e.bitLength(),n)+1);r.fill(0);for(var o=1<<t+1,i=e.clone(),a=0;a<r.length;a++){var s,c=i.andln(o-1);i.isOdd()?(s=c>(o>>1)-1?(o>>1)-c:c,i.isubn(s)):s=0,r[a]=s,i.iushrn(1)}return r},r.getJSF=function(e,t){var n=[[],[]];e=e.clone(),t=t.clone();for(var r,o=0,i=0;e.cmpn(-o)>0||t.cmpn(-i)>0;){var a,s,c=e.andln(3)+o&3,u=t.andln(3)+i&3;3===c&&(c=-1),3===u&&(u=-1),a=1&c?3!==(r=e.andln(7)+o&7)&&5!==r||2!==u?c:-c:0,n[0].push(a),s=1&u?3!==(r=t.andln(7)+i&7)&&5!==r||2!==c?u:-u:0,n[1].push(s),2*o===a+1&&(o=1-o),2*i===s+1&&(i=1-i),e.iushrn(1),t.iushrn(1)}return n},r.cachedProperty=function(e,t,n){var r="_"+t;e.prototype[t]=function(){return void 0!==this[r]?this[r]:this[r]=n.call(this)}},r.parseBytes=function(e){return"string"==typeof e?r.toArray(e,"hex"):e},r.intFromLE=function(e){return new o(e,"hex","le")}},7426:function(e,t,n){"use strict";var r=n(3349),o=n(6698);function i(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 c(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=o,t.toArray=function(e,t){if(Array.isArray(e))return e.slice();if(!e)return[];var n=[];if("string"==typeof e)if(t){if("hex"===t)for((e=e.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(e="0"+e),o=0;o<e.length;o+=2)n.push(parseInt(e[o]+e[o+1],16))}else for(var r=0,o=0;o<e.length;o++){var a=e.charCodeAt(o);a<128?n[r++]=a:a<2048?(n[r++]=a>>6|192,n[r++]=63&a|128):i(e,o)?(a=65536+((1023&a)<<10)+(1023&e.charCodeAt(++o)),n[r++]=a>>18|240,n[r++]=a>>12&63|128,n[r++]=a>>6&63|128,n[r++]=63&a|128):(n[r++]=a>>12|224,n[r++]=a>>6&63|128,n[r++]=63&a|128)}else for(o=0;o<e.length;o++)n[o]=0|e[o];return n},t.toHex=function(e){for(var t="",n=0;n<e.length;n++)t+=s(e[n].toString(16));return t},t.htonl=a,t.toHex32=function(e,t){for(var n="",r=0;r<e.length;r++){var o=e[r];"little"===t&&(o=a(o)),n+=c(o.toString(16))}return n},t.zero2=s,t.zero8=c,t.join32=function(e,t,n,o){var i=n-t;r(i%4==0);for(var a=new Array(i/4),s=0,c=t;s<a.length;s++,c+=4){var u;u="big"===o?e[c]<<24|e[c+1]<<16|e[c+2]<<8|e[c+3]:e[c+3]<<24|e[c+2]<<16|e[c+1]<<8|e[c],a[s]=u>>>0}return a},t.split32=function(e,t){for(var n=new Array(4*e.length),r=0,o=0;r<e.length;r++,o+=4){var i=e[r];"big"===t?(n[o]=i>>>24,n[o+1]=i>>>16&255,n[o+2]=i>>>8&255,n[o+3]=255&i):(n[o+3]=i>>>24,n[o+2]=i>>>16&255,n[o+1]=i>>>8&255,n[o]=255&i)}return n},t.rotr32=function(e,t){return e>>>t|e<<32-t},t.rotl32=function(e,t){return e<<t|e>>>32-t},t.sum32=function(e,t){return e+t>>>0},t.sum32_3=function(e,t,n){return e+t+n>>>0},t.sum32_4=function(e,t,n,r){return e+t+n+r>>>0},t.sum32_5=function(e,t,n,r,o){return e+t+n+r+o>>>0},t.sum64=function(e,t,n,r){var o=e[t],i=r+e[t+1]>>>0,a=(i<r?1:0)+n+o;e[t]=a>>>0,e[t+1]=i},t.sum64_hi=function(e,t,n,r){return(t+r>>>0<t?1:0)+e+n>>>0},t.sum64_lo=function(e,t,n,r){return t+r>>>0},t.sum64_4_hi=function(e,t,n,r,o,i,a,s){var c=0,u=t;return c+=(u=u+r>>>0)<t?1:0,c+=(u=u+i>>>0)<i?1:0,e+n+o+a+(c+=(u=u+s>>>0)<s?1:0)>>>0},t.sum64_4_lo=function(e,t,n,r,o,i,a,s){return t+r+i+s>>>0},t.sum64_5_hi=function(e,t,n,r,o,i,a,s,c,u){var l=0,d=t;return l+=(d=d+r>>>0)<t?1:0,l+=(d=d+i>>>0)<i?1:0,l+=(d=d+s>>>0)<s?1:0,e+n+o+a+c+(l+=(d=d+u>>>0)<u?1:0)>>>0},t.sum64_5_lo=function(e,t,n,r,o,i,a,s,c,u){return t+r+i+s+u>>>0},t.rotr64_hi=function(e,t,n){return(t<<32-n|e>>>n)>>>0},t.rotr64_lo=function(e,t,n){return(e<<32-n|t>>>n)>>>0},t.shr64_hi=function(e,t,n){return e>>>n},t.shr64_lo=function(e,t,n){return(e<<32-n|t>>>n)>>>0}},7447:function(e,t,n){"use strict";var r=n(9404),o=n(2723),i=n(7011),a=n(480),s=n(5037),c=i.assert,u=n(1200),l=n(8545);function d(e){if(!(this instanceof d))return new d(e);"string"==typeof e&&(c(Object.prototype.hasOwnProperty.call(a,e),"Unknown curve "+e),e=a[e]),e instanceof a.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}e.exports=d,d.prototype.keyPair=function(e){return new u(this,e)},d.prototype.keyFromPrivate=function(e,t){return u.fromPrivate(this,e,t)},d.prototype.keyFromPublic=function(e,t){return u.fromPublic(this,e,t)},d.prototype.genKeyPair=function(e){e||(e={});for(var t=new o({hash:this.hash,pers:e.pers,persEnc:e.persEnc||"utf8",entropy:e.entropy||s(this.hash.hmacStrength),entropyEnc:e.entropy&&e.entropyEnc||"utf8",nonce:this.n.toArray()}),n=this.n.byteLength(),i=this.n.sub(new r(2));;){var a=new r(t.generate(n));if(!(a.cmp(i)>0))return a.iaddn(1),this.keyFromPrivate(a)}},d.prototype._truncateToN=function(e,t){var n=8*e.byteLength()-this.n.bitLength();return n>0&&(e=e.ushrn(n)),!t&&e.cmp(this.n)>=0?e.sub(this.n):e},d.prototype.sign=function(e,t,n,i){"object"==typeof n&&(i=n,n=null),i||(i={}),t=this.keyFromPrivate(t,n),e=this._truncateToN(new r(e,16));for(var a=this.n.byteLength(),s=t.getPrivate().toArray("be",a),c=e.toArray("be",a),u=new o({hash:this.hash,entropy:s,nonce:c,pers:i.pers,persEnc:i.persEnc||"utf8"}),d=this.n.sub(new r(1)),f=0;;f++){var p=i.k?i.k(f):new r(u.generate(this.n.byteLength()));if(!((p=this._truncateToN(p,!0)).cmpn(1)<=0||p.cmp(d)>=0)){var h=this.g.mul(p);if(!h.isInfinity()){var y=h.getX(),b=y.umod(this.n);if(0!==b.cmpn(0)){var g=p.invm(this.n).mul(b.mul(t.getPrivate()).iadd(e));if(0!==(g=g.umod(this.n)).cmpn(0)){var w=(h.getY().isOdd()?1:0)|(0!==y.cmp(b)?2:0);return i.canonical&&g.cmp(this.nh)>0&&(g=this.n.sub(g),w^=1),new l({r:b,s:g,recoveryParam:w})}}}}}},d.prototype.verify=function(e,t,n,o){e=this._truncateToN(new r(e,16)),n=this.keyFromPublic(n,o);var i=(t=new l(t,"hex")).r,a=t.s;if(i.cmpn(1)<0||i.cmp(this.n)>=0)return!1;if(a.cmpn(1)<0||a.cmp(this.n)>=0)return!1;var s,c=a.invm(this.n),u=c.mul(e).umod(this.n),d=c.mul(i).umod(this.n);return this.curve._maxwellTrick?!(s=this.g.jmulAdd(u,n.getPublic(),d)).isInfinity()&&s.eqXToP(i):!(s=this.g.mulAdd(u,n.getPublic(),d)).isInfinity()&&0===s.getX().umod(this.n).cmp(i)},d.prototype.recoverPubKey=function(e,t,n,o){c((3&n)===n,"The recovery param is more than two bits"),t=new l(t,o);var i=this.n,a=new r(e),s=t.r,u=t.s,d=1&n,f=n>>1;if(s.cmp(this.curve.p.umod(this.curve.n))>=0&&f)throw new Error("Unable to find sencond key candinate");s=f?this.curve.pointFromX(s.add(this.curve.n),d):this.curve.pointFromX(s,d);var p=t.r.invm(i),h=i.sub(a).mul(p).umod(i),y=u.mul(p).umod(i);return this.g.mulAdd(h,s,y)},d.prototype.getKeyRecoveryParam=function(e,t,n,r){if(null!==(t=new l(t,r)).recoveryParam)return t.recoveryParam;for(var o=0;o<4;o++){var i;try{i=this.recoverPubKey(e,t,o)}catch(e){continue}if(i.eq(n))return o}throw new Error("Unable to find valid recovery factor")}},7714:function(e,t,n){"use strict";var r=n(7426),o=n(2287);function i(){if(!(this instanceof i))return new i;o.call(this),this.h=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]}r.inherits(i,o),e.exports=i,i.blockSize=512,i.outSize=224,i.hmacStrength=192,i.padLength=64,i.prototype._digest=function(e){return"hex"===e?r.toHex32(this.h.slice(0,7),"big"):r.split32(this.h.slice(0,7),"big")}},7766:function(e,t,n){"use strict";var r=n(7426),o=n(6166),i=n(3349),a=r.rotr64_hi,s=r.rotr64_lo,c=r.shr64_hi,u=r.shr64_lo,l=r.sum64,d=r.sum64_hi,f=r.sum64_lo,p=r.sum64_4_hi,h=r.sum64_4_lo,y=r.sum64_5_hi,b=r.sum64_5_lo,g=o.BlockHash,w=[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];function v(){if(!(this instanceof v))return new v;g.call(this),this.h=[1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209],this.k=w,this.W=new Array(160)}function m(e,t,n,r,o){var i=e&n^~e&o;return i<0&&(i+=4294967296),i}function I(e,t,n,r,o,i){var a=t&r^~t&i;return a<0&&(a+=4294967296),a}function E(e,t,n,r,o){var i=e&n^e&o^n&o;return i<0&&(i+=4294967296),i}function S(e,t,n,r,o,i){var a=t&r^t&i^r&i;return a<0&&(a+=4294967296),a}function O(e,t){var n=a(e,t,28)^a(t,e,2)^a(t,e,7);return n<0&&(n+=4294967296),n}function A(e,t){var n=s(e,t,28)^s(t,e,2)^s(t,e,7);return n<0&&(n+=4294967296),n}function T(e,t){var n=a(e,t,14)^a(e,t,18)^a(t,e,9);return n<0&&(n+=4294967296),n}function _(e,t){var n=s(e,t,14)^s(e,t,18)^s(t,e,9);return n<0&&(n+=4294967296),n}function k(e,t){var n=a(e,t,1)^a(e,t,8)^c(e,t,7);return n<0&&(n+=4294967296),n}function x(e,t){var n=s(e,t,1)^s(e,t,8)^u(e,t,7);return n<0&&(n+=4294967296),n}function P(e,t){var n=a(e,t,19)^a(t,e,29)^c(e,t,6);return n<0&&(n+=4294967296),n}function M(e,t){var n=s(e,t,19)^s(t,e,29)^u(e,t,6);return n<0&&(n+=4294967296),n}r.inherits(v,g),e.exports=v,v.blockSize=1024,v.outSize=512,v.hmacStrength=192,v.padLength=128,v.prototype._prepareBlock=function(e,t){for(var n=this.W,r=0;r<32;r++)n[r]=e[t+r];for(;r<n.length;r+=2){var o=P(n[r-4],n[r-3]),i=M(n[r-4],n[r-3]),a=n[r-14],s=n[r-13],c=k(n[r-30],n[r-29]),u=x(n[r-30],n[r-29]),l=n[r-32],d=n[r-31];n[r]=p(o,i,a,s,c,u,l,d),n[r+1]=h(o,i,a,s,c,u,l,d)}},v.prototype._update=function(e,t){this._prepareBlock(e,t);var n=this.W,r=this.h[0],o=this.h[1],a=this.h[2],s=this.h[3],c=this.h[4],u=this.h[5],p=this.h[6],h=this.h[7],g=this.h[8],w=this.h[9],v=this.h[10],k=this.h[11],x=this.h[12],P=this.h[13],M=this.h[14],C=this.h[15];i(this.k.length===n.length);for(var N=0;N<n.length;N+=2){var j=M,D=C,R=T(g,w),L=_(g,w),B=m(g,w,v,k,x),K=I(g,w,v,k,x,P),U=this.k[N],F=this.k[N+1],W=n[N],G=n[N+1],z=y(j,D,R,L,B,K,U,F,W,G),q=b(j,D,R,L,B,K,U,F,W,G);j=O(r,o),D=A(r,o),R=E(r,o,a,s,c),L=S(r,o,a,s,c,u);var $=d(j,D,R,L),H=f(j,D,R,L);M=x,C=P,x=v,P=k,v=g,k=w,g=d(p,h,z,q),w=f(h,h,z,q),p=c,h=u,c=a,u=s,a=r,s=o,r=d(z,q,$,H),o=f(z,q,$,H)}l(this.h,0,r,o),l(this.h,2,a,s),l(this.h,4,c,u),l(this.h,6,p,h),l(this.h,8,g,w),l(this.h,10,v,k),l(this.h,12,x,P),l(this.h,14,M,C)},v.prototype._digest=function(e){return"hex"===e?r.toHex32(this.h,"big"):r.split32(this.h,"big")}},7790:function(){},7952:function(e,t,n){var r=t;r.utils=n(7426),r.common=n(6166),r.sha=n(6229),r.ripemd=n(6784),r.hmac=n(8948),r.sha1=r.sha.sha1,r.sha256=r.sha.sha256,r.sha224=r.sha.sha224,r.sha384=r.sha.sha384,r.sha512=r.sha.sha512,r.ripemd160=r.ripemd.ripemd160},8545:function(e,t,n){"use strict";var r=n(9404),o=n(7011),i=o.assert;function a(e,t){if(e instanceof a)return e;this._importDER(e,t)||(i(e.r&&e.s,"Signature without r or s"),this.r=new r(e.r,16),this.s=new r(e.s,16),void 0===e.recoveryParam?this.recoveryParam=null:this.recoveryParam=e.recoveryParam)}function s(){this.place=0}function c(e,t){var n=e[t.place++];if(!(128&n))return n;var r=15&n;if(0===r||r>4)return!1;for(var o=0,i=0,a=t.place;i<r;i++,a++)o<<=8,o|=e[a],o>>>=0;return!(o<=127)&&(t.place=a,o)}function u(e){for(var t=0,n=e.length-1;!e[t]&&!(128&e[t+1])&&t<n;)t++;return 0===t?e:e.slice(t)}function l(e,t){if(t<128)e.push(t);else{var n=1+(Math.log(t)/Math.LN2>>>3);for(e.push(128|n);--n;)e.push(t>>>(n<<3)&255);e.push(t)}}e.exports=a,a.prototype._importDER=function(e,t){e=o.toArray(e,t);var n=new s;if(48!==e[n.place++])return!1;var i=c(e,n);if(!1===i)return!1;if(i+n.place!==e.length)return!1;if(2!==e[n.place++])return!1;var a=c(e,n);if(!1===a)return!1;var u=e.slice(n.place,a+n.place);if(n.place+=a,2!==e[n.place++])return!1;var l=c(e,n);if(!1===l)return!1;if(e.length!==l+n.place)return!1;var d=e.slice(n.place,l+n.place);if(0===u[0]){if(!(128&u[1]))return!1;u=u.slice(1)}if(0===d[0]){if(!(128&d[1]))return!1;d=d.slice(1)}return this.r=new r(u),this.s=new r(d),this.recoveryParam=null,!0},a.prototype.toDER=function(e){var t=this.r.toArray(),n=this.s.toArray();for(128&t[0]&&(t=[0].concat(t)),128&n[0]&&(n=[0].concat(n)),t=u(t),n=u(n);!(n[0]||128&n[1]);)n=n.slice(1);var r=[2];l(r,t.length),(r=r.concat(t)).push(2),l(r,n.length);var i=r.concat(n),a=[48];return l(a,i.length),a=a.concat(i),o.encode(a,e)}},8650:function(e,t,n){"use strict";var r=n(7952),o=n(480),i=n(7011),a=i.assert,s=i.parseBytes,c=n(6661),u=n(220);function l(e){if(a("ed25519"===e,"only tested with ed25519 so far"),!(this instanceof l))return new l(e);e=o[e].curve,this.curve=e,this.g=e.g,this.g.precompute(e.n.bitLength()+1),this.pointClass=e.point().constructor,this.encodingLength=Math.ceil(e.n.bitLength()/8),this.hash=r.sha512}e.exports=l,l.prototype.sign=function(e,t){e=s(e);var n=this.keyFromSecret(t),r=this.hashInt(n.messagePrefix(),e),o=this.g.mul(r),i=this.encodePoint(o),a=this.hashInt(i,n.pubBytes(),e).mul(n.priv()),c=r.add(a).umod(this.curve.n);return this.makeSignature({R:o,S:c,Rencoded:i})},l.prototype.verify=function(e,t,n){e=s(e),t=this.makeSignature(t);var r=this.keyFromPublic(n),o=this.hashInt(t.Rencoded(),r.pubBytes(),e),i=this.g.mul(t.S());return t.R().add(r.pub().mul(o)).eq(i)},l.prototype.hashInt=function(){for(var e=this.hash(),t=0;t<arguments.length;t++)e.update(arguments[t]);return i.intFromLE(e.digest()).umod(this.curve.n)},l.prototype.keyFromPublic=function(e){return c.fromPublic(this,e)},l.prototype.keyFromSecret=function(e){return c.fromSecret(this,e)},l.prototype.makeSignature=function(e){return e instanceof u?e:new u(this,e)},l.prototype.encodePoint=function(e){var t=e.getY().toArray("le",this.encodingLength);return t[this.encodingLength-1]|=e.getX().isOdd()?128:0,t},l.prototype.decodePoint=function(e){var t=(e=i.parseBytes(e)).length-1,n=e.slice(0,t).concat(-129&e[t]),r=!!(128&e[t]),o=i.intFromLE(n);return this.curve.pointFromY(o,r)},l.prototype.encodeInt=function(e){return e.toArray("le",this.encodingLength)},l.prototype.decodeInt=function(e){return i.intFromLE(e)},l.prototype.isPoint=function(e){return e instanceof this.pointClass}},8948:function(e,t,n){"use strict";var r=n(7426),o=n(3349);function i(e,t,n){if(!(this instanceof i))return new i(e,t,n);this.Hash=e,this.blockSize=e.blockSize/8,this.outSize=e.outSize/8,this.inner=null,this.outer=null,this._init(r.toArray(t,n))}e.exports=i,i.prototype._init=function(e){e.length>this.blockSize&&(e=(new this.Hash).update(e).digest()),o(e.length<=this.blockSize);for(var t=e.length;t<this.blockSize;t++)e.push(0);for(t=0;t<e.length;t++)e[t]^=54;for(this.inner=(new this.Hash).update(e),t=0;t<e.length;t++)e[t]^=106;this.outer=(new this.Hash).update(e)},i.prototype.update=function(e,t){return this.inner.update(e,t),this},i.prototype.digest=function(e){return this.outer.update(this.inner.digest()),this.outer.digest(e)}},9112:function(e,t,n){"use strict";var r=n(9420),o=n(4945),i=n(3776),a=n(7952),s=n(9211);function c(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var u=c(o),l=c(i),d=c(a);const f=/^[a-z0-9-_.]+(\/+[a-z0-9-_.]+)*$/i,p=/^[a-f0-9]{40}$/,h=r.asObject({infoServers:r.asOptional(r.asArray(r.asString)),syncServers:r.asOptional(r.asArray(r.asString))}),y=e=>{const t=r.asString(e);if(""===t)throw new TypeError("Expected non empty string");return t},b=e=>{const t=r.asString(e);if(!p.test(t))throw new TypeError(`Invalid sync key '${t}'`);return t},g=r.asObject({iv_hex:r.asString,encryptionType:r.asNumber,data_base64:r.asString}),w=r.asObject({success:r.asValue(!1),message:r.asString,stack:r.asOptional(r.asString)}),v=r.asEither(g,r.asNull),m=r.asObject(v),I=r.asObject({syncKey:b,hash:r.asOptional(y)}),E=r.asObject({hash:r.asOptional(r.asString),changes:m}),S=r.asObject({syncKey:b,hash:r.asOptional(y)}),O=r.asObject({changes:m}),A=r.asObject({hash:r.asString,changes:m}),T=r.asObject({syncKey:b}),_=r.asUndefined,k=()=>{};async function x(e,t,n={}){const{log:o=k,fetch:i=u.default}=n,{method:a,url:s,body:c,numbUrl:l=s,headers:d={}}=e,f=Date.now(),p=await i(s,{method:a,headers:{"Content-Type":"application/json",...d},body:JSON.stringify(c)}),h=Date.now()-f;o(`${a} ${l} returned ${p.status} in ${h}ms`);const y=await p.text();if(!p.ok)throw new Error(`Failed request ${a} ${l} failed ${p.status}: ${y}`);const b=r.asMaybe(w)(y);if(null!=b)throw new Error(`Failed request ${a} ${l} failed ${p.status}: ${b.message}`);return t(""!==y.trim()?JSON.parse(y):void 0)}const P=l.default("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),M=e=>{const t=C(C(s.base16.parse(e)));return P.encode(t)};function C(e){const t=d.default.sha256();return Uint8Array.from(t.update(e).digest())}class N extends Error{constructor(e="Cannot reach the network"){super(e),this.name="NetworkError"}}const j={infoServers:["https://info-eu1.edge.app","https://info-us1.edge.app"],syncServers:["https://sync-us1.edge.app","https://sync-us2.edge.app","https://sync-us3.edge.app","https://sync-us4.edge.app","https://sync-us5.edge.app","https://sync-us6.edge.app","https://sync-eu.edge.app"]};function D(e={}){const{log:t=()=>{}}=e,n={...j,...e.edgeServers},{edgeServersCacheTTL:r=6e5}=e,o=function(e,t){let n=Date.now()+t,r=e(void 0);return{get:()=>{if(Date.now()>n||null==r){n=Date.now()+t;const o=e(r);r=o}return r}}}((r={current:n})=>(r.current.infoServers.length>0&&async function(e,t={}){const{log:n=k,fetch:r=u.default}=t;let o=new Error("No info servers");for(const a of e){const[e,t]=["GET","/v1/edgeServers"],s=Date.now(),c=`${a}${t}`;try{const t=await r(c,{method:e,headers:{"Content-Type":"application/json"}}).catch(t=>{const r=Date.now()-s,o=`${e} ${c} failed in ${r}ms, ${String(t)}`;throw n(o),new N(o)}),{ok:o,status:i}=t,a=Date.now()-s,u=`${e} ${c} returned ${i} in ${a}ms`;if(!o)throw n(u),new N(u);n(u);const l=await t.text(),d=JSON.parse(l);return h(d)}catch(i){o=i;continue}}throw o}(r.current.infoServers,e).then(e=>{return r.current={...r.current,...e,infoServers:(t=e.infoServers,n=()=>j.infoServers,null!=t?t:n())};var t,n}).catch(async e=>{t(String(e))}),r),r);return{async getEdgeServers(){const{current:e}=await o.get();return e}}}function R(e,t){return null!=e?e:t()}t.jG=m,t.ZU=g,t.CS=h,t.ve=v,t.q3=I,t.FX=E,t.yq=y,t.w2=e=>{const t=r.asString(e);try{if(f.test(t))return function(e){if(/^\//.test(e))throw new Error("Absolute paths are not supported");const t=e.split("/");let n=0,r=0;for(;n<t.length;){const e=t[n++];if(".."===e?r--:"."!==e&&""!==e&&(t[r++]=e),r<0)throw new Error("Path would escape folder");if(0===r&&n===t.length)throw new Error("Path would evaluate to empty file name")}return t.slice(0,r).join("/")}(t)}catch(n){}throw new Error(`Invalid path '${t}'`)},t.CG=O,t.Kr=S,t.l3=A,t.N0=T,t.MH=_,t.fs=w,t.FA=b,t.NL=function(e={}){const t=D(e);async function n(){const{syncServers:e}=await t.getEdgeServers();return function(e){for(let t=e.length-1;t>0;t--){const n=Math.floor(Math.random()*(t+1));[e[t],e[n]]=[e[n],e[t]]}return e}(e)}return{async createRepo(t,r){const o=await n();let i=new Error(`Failed to create repo ${t}: empty sync server list`);for(const n of o){const o=`${n}/api/v2/store/${t}`,s=o.replace(t,`<${M(t)}>`);try{return await x({method:"PUT",url:o,numbUrl:s,headers:null!=r?{"X-API-Key":r}:{}},_,e)}catch(a){i=a}}throw i},async readRepo(t,r){const o=await n();let i=new Error(`Failed to read repo ${t}: empty sync server list`);for(const n of o){const o=`${n}/api/v2/store/${t}/${R(r,()=>"")}`,s=o.replace(t,`<${M(t)}>`);try{return await x({method:"GET",url:o,numbUrl:s},E,e)}catch(a){i=a}}throw i},async updateRepo(t,r,o){const i=await n();let a=new Error(`Failed to update repo ${t}: empty sync server list`);for(const n of i){const i=`${n}/api/v2/store/${t}/${R(r,()=>"")}`,c=i.replace(t,`<${M(t)}>`);try{return await x({method:"POST",url:i,numbUrl:c,body:o},A,e)}catch(s){a=s}}throw a}}},t.Tb=M},9188:function(e,t,n){"use strict";var r=n(7011),o=n(9404),i=n(6698),a=n(6677),s=r.assert;function c(e){a.call(this,"short",e),this.a=new o(e.a,16).toRed(this.red),this.b=new o(e.b,16).toRed(this.red),this.tinv=this.two.redInvm(),this.zeroA=0===this.a.fromRed().cmpn(0),this.threeA=0===this.a.fromRed().sub(this.p).cmpn(-3),this.endo=this._getEndomorphism(e),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}function u(e,t,n,r){a.BasePoint.call(this,e,"affine"),null===t&&null===n?(this.x=null,this.y=null,this.inf=!0):(this.x=new o(t,16),this.y=new o(n,16),r&&(this.x.forceRed(this.curve.red),this.y.forceRed(this.curve.red)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.inf=!1)}function l(e,t,n,r){a.BasePoint.call(this,e,"jacobian"),null===t&&null===n&&null===r?(this.x=this.curve.one,this.y=this.curve.one,this.z=new o(0)):(this.x=new o(t,16),this.y=new o(n,16),this.z=new o(r,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one}i(c,a),e.exports=c,c.prototype._getEndomorphism=function(e){if(this.zeroA&&this.g&&this.n&&1===this.p.modn(3)){var t,n;if(e.beta)t=new o(e.beta,16).toRed(this.red);else{var r=this._getEndoRoots(this.p);t=(t=r[0].cmp(r[1])<0?r[0]:r[1]).toRed(this.red)}if(e.lambda)n=new o(e.lambda,16);else{var i=this._getEndoRoots(this.n);0===this.g.mul(i[0]).x.cmp(this.g.x.redMul(t))?n=i[0]:(n=i[1],s(0===this.g.mul(n).x.cmp(this.g.x.redMul(t))))}return{beta:t,lambda:n,basis:e.basis?e.basis.map(function(e){return{a:new o(e.a,16),b:new o(e.b,16)}}):this._getEndoBasis(n)}}},c.prototype._getEndoRoots=function(e){var t=e===this.p?this.red:o.mont(e),n=new o(2).toRed(t).redInvm(),r=n.redNeg(),i=new o(3).toRed(t).redNeg().redSqrt().redMul(n);return[r.redAdd(i).fromRed(),r.redSub(i).fromRed()]},c.prototype._getEndoBasis=function(e){for(var t,n,r,i,a,s,c,u,l,d=this.n.ushrn(Math.floor(this.n.bitLength()/2)),f=e,p=this.n.clone(),h=new o(1),y=new o(0),b=new o(0),g=new o(1),w=0;0!==f.cmpn(0);){var v=p.div(f);u=p.sub(v.mul(f)),l=b.sub(v.mul(h));var m=g.sub(v.mul(y));if(!r&&u.cmp(d)<0)t=c.neg(),n=h,r=u.neg(),i=l;else if(r&&2===++w)break;c=u,p=f,f=u,b=h,h=l,g=y,y=m}a=u.neg(),s=l;var I=r.sqr().add(i.sqr());return a.sqr().add(s.sqr()).cmp(I)>=0&&(a=t,s=n),r.negative&&(r=r.neg(),i=i.neg()),a.negative&&(a=a.neg(),s=s.neg()),[{a:r,b:i},{a:a,b:s}]},c.prototype._endoSplit=function(e){var t=this.endo.basis,n=t[0],r=t[1],o=r.b.mul(e).divRound(this.n),i=n.b.neg().mul(e).divRound(this.n),a=o.mul(n.a),s=i.mul(r.a),c=o.mul(n.b),u=i.mul(r.b);return{k1:e.sub(a).sub(s),k2:c.add(u).neg()}},c.prototype.pointFromX=function(e,t){(e=new o(e,16)).red||(e=e.toRed(this.red));var n=e.redSqr().redMul(e).redIAdd(e.redMul(this.a)).redIAdd(this.b),r=n.redSqrt();if(0!==r.redSqr().redSub(n).cmp(this.zero))throw new Error("invalid point");var i=r.fromRed().isOdd();return(t&&!i||!t&&i)&&(r=r.redNeg()),this.point(e,r)},c.prototype.validate=function(e){if(e.inf)return!0;var t=e.x,n=e.y,r=this.a.redMul(t),o=t.redSqr().redMul(t).redIAdd(r).redIAdd(this.b);return 0===n.redSqr().redISub(o).cmpn(0)},c.prototype._endoWnafMulAdd=function(e,t,n){for(var r=this._endoWnafT1,o=this._endoWnafT2,i=0;i<e.length;i++){var a=this._endoSplit(t[i]),s=e[i],c=s._getBeta();a.k1.negative&&(a.k1.ineg(),s=s.neg(!0)),a.k2.negative&&(a.k2.ineg(),c=c.neg(!0)),r[2*i]=s,r[2*i+1]=c,o[2*i]=a.k1,o[2*i+1]=a.k2}for(var u=this._wnafMulAdd(1,r,o,2*i,n),l=0;l<2*i;l++)r[l]=null,o[l]=null;return u},i(u,a.BasePoint),c.prototype.point=function(e,t,n){return new u(this,e,t,n)},c.prototype.pointFromJSON=function(e,t){return u.fromJSON(this,e,t)},u.prototype._getBeta=function(){if(this.curve.endo){var e=this.precomputed;if(e&&e.beta)return e.beta;var t=this.curve.point(this.x.redMul(this.curve.endo.beta),this.y);if(e){var n=this.curve,r=function(e){return n.point(e.x.redMul(n.endo.beta),e.y)};e.beta=t,t.precomputed={beta:null,naf:e.naf&&{wnd:e.naf.wnd,points:e.naf.points.map(r)},doubles:e.doubles&&{step:e.doubles.step,points:e.doubles.points.map(r)}}}return t}},u.prototype.toJSON=function(){return this.precomputed?[this.x,this.y,this.precomputed&&{doubles:this.precomputed.doubles&&{step:this.precomputed.doubles.step,points:this.precomputed.doubles.points.slice(1)},naf:this.precomputed.naf&&{wnd:this.precomputed.naf.wnd,points:this.precomputed.naf.points.slice(1)}}]:[this.x,this.y]},u.fromJSON=function(e,t,n){"string"==typeof t&&(t=JSON.parse(t));var r=e.point(t[0],t[1],n);if(!t[2])return r;function o(t){return e.point(t[0],t[1],n)}var i=t[2];return r.precomputed={beta:null,doubles:i.doubles&&{step:i.doubles.step,points:[r].concat(i.doubles.points.map(o))},naf:i.naf&&{wnd:i.naf.wnd,points:[r].concat(i.naf.points.map(o))}},r},u.prototype.inspect=function(){return this.isInfinity()?"<EC Point Infinity>":"<EC Point x: "+this.x.fromRed().toString(16,2)+" y: "+this.y.fromRed().toString(16,2)+">"},u.prototype.isInfinity=function(){return this.inf},u.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 n=t.redSqr().redISub(this.x).redISub(e.x),r=t.redMul(this.x.redSub(n)).redISub(this.y);return this.curve.point(n,r)},u.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,n=this.x.redSqr(),r=e.redInvm(),o=n.redAdd(n).redIAdd(n).redIAdd(t).redMul(r),i=o.redSqr().redISub(this.x.redAdd(this.x)),a=o.redMul(this.x.redSub(i)).redISub(this.y);return this.curve.point(i,a)},u.prototype.getX=function(){return this.x.fromRed()},u.prototype.getY=function(){return this.y.fromRed()},u.prototype.mul=function(e){return e=new o(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)},u.prototype.mulAdd=function(e,t,n){var r=[this,t],o=[e,n];return this.curve.endo?this.curve._endoWnafMulAdd(r,o):this.curve._wnafMulAdd(1,r,o,2)},u.prototype.jmulAdd=function(e,t,n){var r=[this,t],o=[e,n];return this.curve.endo?this.curve._endoWnafMulAdd(r,o,!0):this.curve._wnafMulAdd(1,r,o,2,!0)},u.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))},u.prototype.neg=function(e){if(this.inf)return this;var t=this.curve.point(this.x,this.y.redNeg());if(e&&this.precomputed){var n=this.precomputed,r=function(e){return e.neg()};t.precomputed={naf:n.naf&&{wnd:n.naf.wnd,points:n.naf.points.map(r)},doubles:n.doubles&&{step:n.doubles.step,points:n.doubles.points.map(r)}}}return t},u.prototype.toJ=function(){return this.inf?this.curve.jpoint(null,null,null):this.curve.jpoint(this.x,this.y,this.curve.one)},i(l,a.BasePoint),c.prototype.jpoint=function(e,t,n){return new l(this,e,t,n)},l.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var e=this.z.redInvm(),t=e.redSqr(),n=this.x.redMul(t),r=this.y.redMul(t).redMul(e);return this.curve.point(n,r)},l.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},l.prototype.add=function(e){if(this.isInfinity())return e;if(e.isInfinity())return this;var t=e.z.redSqr(),n=this.z.redSqr(),r=this.x.redMul(t),o=e.x.redMul(n),i=this.y.redMul(t.redMul(e.z)),a=e.y.redMul(n.redMul(this.z)),s=r.redSub(o),c=i.redSub(a);if(0===s.cmpn(0))return 0!==c.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var u=s.redSqr(),l=u.redMul(s),d=r.redMul(u),f=c.redSqr().redIAdd(l).redISub(d).redISub(d),p=c.redMul(d.redISub(f)).redISub(i.redMul(l)),h=this.z.redMul(e.z).redMul(s);return this.curve.jpoint(f,p,h)},l.prototype.mixedAdd=function(e){if(this.isInfinity())return e.toJ();if(e.isInfinity())return this;var t=this.z.redSqr(),n=this.x,r=e.x.redMul(t),o=this.y,i=e.y.redMul(t).redMul(this.z),a=n.redSub(r),s=o.redSub(i);if(0===a.cmpn(0))return 0!==s.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var c=a.redSqr(),u=c.redMul(a),l=n.redMul(c),d=s.redSqr().redIAdd(u).redISub(l).redISub(l),f=s.redMul(l.redISub(d)).redISub(o.redMul(u)),p=this.z.redMul(a);return this.curve.jpoint(d,f,p)},l.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 n=this;for(t=0;t<e;t++)n=n.dbl();return n}var r=this.curve.a,o=this.curve.tinv,i=this.x,a=this.y,s=this.z,c=s.redSqr().redSqr(),u=a.redAdd(a);for(t=0;t<e;t++){var l=i.redSqr(),d=u.redSqr(),f=d.redSqr(),p=l.redAdd(l).redIAdd(l).redIAdd(r.redMul(c)),h=i.redMul(d),y=p.redSqr().redISub(h.redAdd(h)),b=h.redISub(y),g=p.redMul(b);g=g.redIAdd(g).redISub(f);var w=u.redMul(s);t+1<e&&(c=c.redMul(f)),i=y,s=w,u=g}return this.curve.jpoint(i,u.redMul(o),s)},l.prototype.dbl=function(){return this.isInfinity()?this:this.curve.zeroA?this._zeroDbl():this.curve.threeA?this._threeDbl():this._dbl()},l.prototype._zeroDbl=function(){var e,t,n;if(this.zOne){var r=this.x.redSqr(),o=this.y.redSqr(),i=o.redSqr(),a=this.x.redAdd(o).redSqr().redISub(r).redISub(i);a=a.redIAdd(a);var s=r.redAdd(r).redIAdd(r),c=s.redSqr().redISub(a).redISub(a),u=i.redIAdd(i);u=(u=u.redIAdd(u)).redIAdd(u),e=c,t=s.redMul(a.redISub(c)).redISub(u),n=this.y.redAdd(this.y)}else{var l=this.x.redSqr(),d=this.y.redSqr(),f=d.redSqr(),p=this.x.redAdd(d).redSqr().redISub(l).redISub(f);p=p.redIAdd(p);var h=l.redAdd(l).redIAdd(l),y=h.redSqr(),b=f.redIAdd(f);b=(b=b.redIAdd(b)).redIAdd(b),e=y.redISub(p).redISub(p),t=h.redMul(p.redISub(e)).redISub(b),n=(n=this.y.redMul(this.z)).redIAdd(n)}return this.curve.jpoint(e,t,n)},l.prototype._threeDbl=function(){var e,t,n;if(this.zOne){var r=this.x.redSqr(),o=this.y.redSqr(),i=o.redSqr(),a=this.x.redAdd(o).redSqr().redISub(r).redISub(i);a=a.redIAdd(a);var s=r.redAdd(r).redIAdd(r).redIAdd(this.curve.a),c=s.redSqr().redISub(a).redISub(a);e=c;var u=i.redIAdd(i);u=(u=u.redIAdd(u)).redIAdd(u),t=s.redMul(a.redISub(c)).redISub(u),n=this.y.redAdd(this.y)}else{var l=this.z.redSqr(),d=this.y.redSqr(),f=this.x.redMul(d),p=this.x.redSub(l).redMul(this.x.redAdd(l));p=p.redAdd(p).redIAdd(p);var h=f.redIAdd(f),y=(h=h.redIAdd(h)).redAdd(h);e=p.redSqr().redISub(y),n=this.y.redAdd(this.z).redSqr().redISub(d).redISub(l);var b=d.redSqr();b=(b=(b=b.redIAdd(b)).redIAdd(b)).redIAdd(b),t=p.redMul(h.redISub(e)).redISub(b)}return this.curve.jpoint(e,t,n)},l.prototype._dbl=function(){var e=this.curve.a,t=this.x,n=this.y,r=this.z,o=r.redSqr().redSqr(),i=t.redSqr(),a=n.redSqr(),s=i.redAdd(i).redIAdd(i).redIAdd(e.redMul(o)),c=t.redAdd(t),u=(c=c.redIAdd(c)).redMul(a),l=s.redSqr().redISub(u.redAdd(u)),d=u.redISub(l),f=a.redSqr();f=(f=(f=f.redIAdd(f)).redIAdd(f)).redIAdd(f);var p=s.redMul(d).redISub(f),h=n.redAdd(n).redMul(r);return this.curve.jpoint(l,p,h)},l.prototype.trpl=function(){if(!this.curve.zeroA)return this.dbl().add(this);var e=this.x.redSqr(),t=this.y.redSqr(),n=this.z.redSqr(),r=t.redSqr(),o=e.redAdd(e).redIAdd(e),i=o.redSqr(),a=this.x.redAdd(t).redSqr().redISub(e).redISub(r),s=(a=(a=(a=a.redIAdd(a)).redAdd(a).redIAdd(a)).redISub(i)).redSqr(),c=r.redIAdd(r);c=(c=(c=c.redIAdd(c)).redIAdd(c)).redIAdd(c);var u=o.redIAdd(a).redSqr().redISub(i).redISub(s).redISub(c),l=t.redMul(u);l=(l=l.redIAdd(l)).redIAdd(l);var d=this.x.redMul(s).redISub(l);d=(d=d.redIAdd(d)).redIAdd(d);var f=this.y.redMul(u.redMul(c.redISub(u)).redISub(a.redMul(s)));f=(f=(f=f.redIAdd(f)).redIAdd(f)).redIAdd(f);var p=this.z.redAdd(a).redSqr().redISub(n).redISub(s);return this.curve.jpoint(d,f,p)},l.prototype.mul=function(e,t){return e=new o(e,t),this.curve._wnafMul(this,e)},l.prototype.eq=function(e){if("affine"===e.type)return this.eq(e.toJ());if(this===e)return!0;var t=this.z.redSqr(),n=e.z.redSqr();if(0!==this.x.redMul(n).redISub(e.x.redMul(t)).cmpn(0))return!1;var r=t.redMul(this.z),o=n.redMul(e.z);return 0===this.y.redMul(o).redISub(e.y.redMul(r)).cmpn(0)},l.prototype.eqXToP=function(e){var t=this.z.redSqr(),n=e.toRed(this.curve.red).redMul(t);if(0===this.x.cmp(n))return!0;for(var r=e.clone(),o=this.curve.redN.redMul(t);;){if(r.iadd(this.curve.n),r.cmp(this.curve.p)>=0)return!1;if(n.redIAdd(o),0===this.x.cmp(n))return!0}},l.prototype.inspect=function(){return this.isInfinity()?"<EC JPoint Infinity>":"<EC JPoint x: "+this.x.toString(16,2)+" y: "+this.y.toString(16,2)+" z: "+this.z.toString(16,2)+">"},l.prototype.isInfinity=function(){return 0===this.z.cmpn(0)}},9211:function(e,t){"use strict";function n(e,t,n){var r;if(void 0===n&&(n={}),!t.codes){t.codes={};for(var o=0;o<t.chars.length;++o)t.codes[t.chars[o]]=o}if(!n.loose&&e.length*t.bits&7)throw new SyntaxError("Invalid padding");for(var i=e.length;"="===e[i-1];)if(--i,!(n.loose||(e.length-i)*t.bits&7))throw new SyntaxError("Invalid padding");for(var a=new(null!=(r=n.out)?r:Uint8Array)(i*t.bits/8|0),s=0,c=0,u=0,l=0;l<i;++l){var d=t.codes[e[l]];if(void 0===d)throw new SyntaxError("Invalid character "+e[l]);c=c<<t.bits|d,(s+=t.bits)>=8&&(s-=8,a[u++]=255&c>>s)}if(s>=t.bits||255&c<<8-s)throw new SyntaxError("Unexpected end of data");return a}function r(e,t,n){void 0===n&&(n={});for(var r=n.pad,o=void 0===r||r,i=(1<<t.bits)-1,a="",s=0,c=0,u=0;u<e.length;++u)for(c=c<<8|255&e[u],s+=8;s>t.bits;)s-=t.bits,a+=t.chars[i&c>>s];if(s&&(a+=t.chars[i&c<<t.bits-s]),o)for(;a.length*t.bits&7;)a+="=";return a}Object.defineProperty(t,"__esModule",{value:!0});var o={chars:"0123456789ABCDEF",bits:4},i={chars:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bits:5},a={chars:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bits:5},s={chars:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bits:6},c={chars:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bits:6},u={parse:function(e,t){return n(e.toUpperCase(),o,t)},stringify:function(e,t){return r(e,o,t)}},l={parse:function(e,t){return void 0===t&&(t={}),n(t.loose?e.toUpperCase().replace(/0/g,"O").replace(/1/g,"L").replace(/8/g,"B"):e,i,t)},stringify:function(e,t){return r(e,i,t)}},d={parse:function(e,t){return n(e,a,t)},stringify:function(e,t){return r(e,a,t)}},f={parse:function(e,t){return n(e,s,t)},stringify:function(e,t){return r(e,s,t)}},p={parse:function(e,t){return n(e,c,t)},stringify:function(e,t){return r(e,c,t)}},h={parse:n,stringify:r};t.base16=u,t.base32=l,t.base32hex=d,t.base64=f,t.base64url=p,t.codec=h},9404:function(e,t,n){!function(e,t){"use strict";function r(e,t){if(!e)throw new Error(t||"Assertion failed")}function o(e,t){e.super_=t;var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e}function i(e,t,n){if(i.isBN(e))return e;this.negative=0,this.words=null,this.length=0,this.red=null,null!==e&&("le"!==t&&"be"!==t||(n=t,t=10),this._init(e||0,t||10,n||"be"))}var a;"object"==typeof e?e.exports=i:t.BN=i,i.BN=i,i.wordSize=26;try{a="undefined"!=typeof window&&void 0!==window.Buffer?window.Buffer:n(7790).Buffer}catch(A){}function s(e,t){var n=e.charCodeAt(t);return n>=65&&n<=70?n-55:n>=97&&n<=102?n-87:n-48&15}function c(e,t,n){var r=s(e,n);return n-1>=t&&(r|=s(e,n-1)<<4),r}function u(e,t,n,r){for(var o=0,i=Math.min(e.length,n),a=t;a<i;a++){var s=e.charCodeAt(a)-48;o*=r,o+=s>=49?s-49+10:s>=17?s-17+10:s}return o}i.isBN=function(e){return e instanceof i||null!==e&&"object"==typeof e&&e.constructor.wordSize===i.wordSize&&Array.isArray(e.words)},i.max=function(e,t){return e.cmp(t)>0?e:t},i.min=function(e,t){return e.cmp(t)<0?e:t},i.prototype._init=function(e,t,n){if("number"==typeof e)return this._initNumber(e,t,n);if("object"==typeof e)return this._initArray(e,t,n);"hex"===t&&(t=16),r(t===(0|t)&&t>=2&&t<=36);var o=0;"-"===(e=e.toString().replace(/\s+/g,""))[0]&&(o++,this.negative=1),o<e.length&&(16===t?this._parseHex(e,o,n):(this._parseBase(e,t,o),"le"===n&&this._initArray(this.toArray(),t,n)))},i.prototype._initNumber=function(e,t,n){e<0&&(this.negative=1,e=-e),e<67108864?(this.words=[67108863&e],this.length=1):e<4503599627370496?(this.words=[67108863&e,e/67108864&67108863],this.length=2):(r(e<9007199254740992),this.words=[67108863&e,e/67108864&67108863,1],this.length=3),"le"===n&&this._initArray(this.toArray(),t,n)},i.prototype._initArray=function(e,t,n){if(r("number"==typeof e.length),e.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(e.length/3),this.words=new Array(this.length);for(var o=0;o<this.length;o++)this.words[o]=0;var i,a,s=0;if("be"===n)for(o=e.length-1,i=0;o>=0;o-=3)a=e[o]|e[o-1]<<8|e[o-2]<<16,this.words[i]|=a<<s&67108863,this.words[i+1]=a>>>26-s&67108863,(s+=24)>=26&&(s-=26,i++);else if("le"===n)for(o=0,i=0;o<e.length;o+=3)a=e[o]|e[o+1]<<8|e[o+2]<<16,this.words[i]|=a<<s&67108863,this.words[i+1]=a>>>26-s&67108863,(s+=24)>=26&&(s-=26,i++);return this.strip()},i.prototype._parseHex=function(e,t,n){this.length=Math.ceil((e.length-t)/6),this.words=new Array(this.length);for(var r=0;r<this.length;r++)this.words[r]=0;var o,i=0,a=0;if("be"===n)for(r=e.length-1;r>=t;r-=2)o=c(e,t,r)<<i,this.words[a]|=67108863&o,i>=18?(i-=18,a+=1,this.words[a]|=o>>>26):i+=8;else for(r=(e.length-t)%2==0?t+1:t;r<e.length;r+=2)o=c(e,t,r)<<i,this.words[a]|=67108863&o,i>=18?(i-=18,a+=1,this.words[a]|=o>>>26):i+=8;this.strip()},i.prototype._parseBase=function(e,t,n){this.words=[0],this.length=1;for(var r=0,o=1;o<=67108863;o*=t)r++;r--,o=o/t|0;for(var i=e.length-n,a=i%r,s=Math.min(i,i-a)+n,c=0,l=n;l<s;l+=r)c=u(e,l,l+r,t),this.imuln(o),this.words[0]+c<67108864?this.words[0]+=c:this._iaddn(c);if(0!==a){var d=1;for(c=u(e,l,e.length,t),l=0;l<a;l++)d*=t;this.imuln(d),this.words[0]+c<67108864?this.words[0]+=c:this._iaddn(c)}this.strip()},i.prototype.copy=function(e){e.words=new Array(this.length);for(var t=0;t<this.length;t++)e.words[t]=this.words[t];e.length=this.length,e.negative=this.negative,e.red=this.red},i.prototype.clone=function(){var e=new i(null);return this.copy(e),e},i.prototype._expand=function(e){for(;this.length<e;)this.words[this.length++]=0;return this},i.prototype.strip=function(){for(;this.length>1&&0===this.words[this.length-1];)this.length--;return this._normSign()},i.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},i.prototype.inspect=function(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"};var l=["","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],f=[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];function p(e,t,n){n.negative=t.negative^e.negative;var r=e.length+t.length|0;n.length=r,r=r-1|0;var o=0|e.words[0],i=0|t.words[0],a=o*i,s=67108863&a,c=a/67108864|0;n.words[0]=s;for(var u=1;u<r;u++){for(var l=c>>>26,d=67108863&c,f=Math.min(u,t.length-1),p=Math.max(0,u-e.length+1);p<=f;p++){var h=u-p|0;l+=(a=(o=0|e.words[h])*(i=0|t.words[p])+d)/67108864|0,d=67108863&a}n.words[u]=0|d,c=0|l}return 0!==c?n.words[u]=0|c:n.length--,n.strip()}i.prototype.toString=function(e,t){var n;if(t=0|t||1,16===(e=e||10)||"hex"===e){n="";for(var o=0,i=0,a=0;a<this.length;a++){var s=this.words[a],c=(16777215&(s<<o|i)).toString(16);i=s>>>24-o&16777215,(o+=2)>=26&&(o-=26,a--),n=0!==i||a!==this.length-1?l[6-c.length]+c+n:c+n}for(0!==i&&(n=i.toString(16)+n);n.length%t!==0;)n="0"+n;return 0!==this.negative&&(n="-"+n),n}if(e===(0|e)&&e>=2&&e<=36){var u=d[e],p=f[e];n="";var h=this.clone();for(h.negative=0;!h.isZero();){var y=h.modn(p).toString(e);n=(h=h.idivn(p)).isZero()?y+n:l[u-y.length]+y+n}for(this.isZero()&&(n="0"+n);n.length%t!==0;)n="0"+n;return 0!==this.negative&&(n="-"+n),n}r(!1,"Base should be between 2 and 36")},i.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&&r(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-e:e},i.prototype.toJSON=function(){return this.toString(16)},i.prototype.toBuffer=function(e,t){return r(void 0!==a),this.toArrayLike(a,e,t)},i.prototype.toArray=function(e,t){return this.toArrayLike(Array,e,t)},i.prototype.toArrayLike=function(e,t,n){var o=this.byteLength(),i=n||Math.max(1,o);r(o<=i,"byte array longer than desired length"),r(i>0,"Requested array length <= 0"),this.strip();var a,s,c="le"===t,u=new e(i),l=this.clone();if(c){for(s=0;!l.isZero();s++)a=l.andln(255),l.iushrn(8),u[s]=a;for(;s<i;s++)u[s]=0}else{for(s=0;s<i-o;s++)u[s]=0;for(s=0;!l.isZero();s++)a=l.andln(255),l.iushrn(8),u[i-s-1]=a}return u},Math.clz32?i.prototype._countBits=function(e){return 32-Math.clz32(e)}:i.prototype._countBits=function(e){var t=e,n=0;return t>=4096&&(n+=13,t>>>=13),t>=64&&(n+=7,t>>>=7),t>=8&&(n+=4,t>>>=4),t>=2&&(n+=2,t>>>=2),n+t},i.prototype._zeroBits=function(e){if(0===e)return 26;var t=e,n=0;return 8191&t||(n+=13,t>>>=13),127&t||(n+=7,t>>>=7),15&t||(n+=4,t>>>=4),3&t||(n+=2,t>>>=2),1&t||n++,n},i.prototype.bitLength=function(){var e=this.words[this.length-1],t=this._countBits(e);return 26*(this.length-1)+t},i.prototype.zeroBits=function(){if(this.isZero())return 0;for(var e=0,t=0;t<this.length;t++){var n=this._zeroBits(this.words[t]);if(e+=n,26!==n)break}return e},i.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},i.prototype.toTwos=function(e){return 0!==this.negative?this.abs().inotn(e).iaddn(1):this.clone()},i.prototype.fromTwos=function(e){return this.testn(e-1)?this.notn(e).iaddn(1).ineg():this.clone()},i.prototype.isNeg=function(){return 0!==this.negative},i.prototype.neg=function(){return this.clone().ineg()},i.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},i.prototype.iuor=function(e){for(;this.length<e.length;)this.words[this.length++]=0;for(var t=0;t<e.length;t++)this.words[t]=this.words[t]|e.words[t];return this.strip()},i.prototype.ior=function(e){return r(0===(this.negative|e.negative)),this.iuor(e)},i.prototype.or=function(e){return this.length>e.length?this.clone().ior(e):e.clone().ior(this)},i.prototype.uor=function(e){return this.length>e.length?this.clone().iuor(e):e.clone().iuor(this)},i.prototype.iuand=function(e){var t;t=this.length>e.length?e:this;for(var n=0;n<t.length;n++)this.words[n]=this.words[n]&e.words[n];return this.length=t.length,this.strip()},i.prototype.iand=function(e){return r(0===(this.negative|e.negative)),this.iuand(e)},i.prototype.and=function(e){return this.length>e.length?this.clone().iand(e):e.clone().iand(this)},i.prototype.uand=function(e){return this.length>e.length?this.clone().iuand(e):e.clone().iuand(this)},i.prototype.iuxor=function(e){var t,n;this.length>e.length?(t=this,n=e):(t=e,n=this);for(var r=0;r<n.length;r++)this.words[r]=t.words[r]^n.words[r];if(this!==t)for(;r<t.length;r++)this.words[r]=t.words[r];return this.length=t.length,this.strip()},i.prototype.ixor=function(e){return r(0===(this.negative|e.negative)),this.iuxor(e)},i.prototype.xor=function(e){return this.length>e.length?this.clone().ixor(e):e.clone().ixor(this)},i.prototype.uxor=function(e){return this.length>e.length?this.clone().iuxor(e):e.clone().iuxor(this)},i.prototype.inotn=function(e){r("number"==typeof e&&e>=0);var t=0|Math.ceil(e/26),n=e%26;this._expand(t),n>0&&t--;for(var o=0;o<t;o++)this.words[o]=67108863&~this.words[o];return n>0&&(this.words[o]=~this.words[o]&67108863>>26-n),this.strip()},i.prototype.notn=function(e){return this.clone().inotn(e)},i.prototype.setn=function(e,t){r("number"==typeof e&&e>=0);var n=e/26|0,o=e%26;return this._expand(n+1),this.words[n]=t?this.words[n]|1<<o:this.words[n]&~(1<<o),this.strip()},i.prototype.iadd=function(e){var t,n,r;if(0!==this.negative&&0===e.negative)return this.negative=0,t=this.isub(e),this.negative^=1,this._normSign();if(0===this.negative&&0!==e.negative)return e.negative=0,t=this.isub(e),e.negative=1,t._normSign();this.length>e.length?(n=this,r=e):(n=e,r=this);for(var o=0,i=0;i<r.length;i++)t=(0|n.words[i])+(0|r.words[i])+o,this.words[i]=67108863&t,o=t>>>26;for(;0!==o&&i<n.length;i++)t=(0|n.words[i])+o,this.words[i]=67108863&t,o=t>>>26;if(this.length=n.length,0!==o)this.words[this.length]=o,this.length++;else if(n!==this)for(;i<n.length;i++)this.words[i]=n.words[i];return this},i.prototype.add=function(e){var t;return 0!==e.negative&&0===this.negative?(e.negative=0,t=this.sub(e),e.negative^=1,t):0===e.negative&&0!==this.negative?(this.negative=0,t=e.sub(this),this.negative=1,t):this.length>e.length?this.clone().iadd(e):e.clone().iadd(this)},i.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 n,r,o=this.cmp(e);if(0===o)return this.negative=0,this.length=1,this.words[0]=0,this;o>0?(n=this,r=e):(n=e,r=this);for(var i=0,a=0;a<r.length;a++)i=(t=(0|n.words[a])-(0|r.words[a])+i)>>26,this.words[a]=67108863&t;for(;0!==i&&a<n.length;a++)i=(t=(0|n.words[a])+i)>>26,this.words[a]=67108863&t;if(0===i&&a<n.length&&n!==this)for(;a<n.length;a++)this.words[a]=n.words[a];return this.length=Math.max(this.length,a),n!==this&&(this.negative=1),this.strip()},i.prototype.sub=function(e){return this.clone().isub(e)};var h=function(e,t,n){var r,o,i,a=e.words,s=t.words,c=n.words,u=0,l=0|a[0],d=8191&l,f=l>>>13,p=0|a[1],h=8191&p,y=p>>>13,b=0|a[2],g=8191&b,w=b>>>13,v=0|a[3],m=8191&v,I=v>>>13,E=0|a[4],S=8191&E,O=E>>>13,A=0|a[5],T=8191&A,_=A>>>13,k=0|a[6],x=8191&k,P=k>>>13,M=0|a[7],C=8191&M,N=M>>>13,j=0|a[8],D=8191&j,R=j>>>13,L=0|a[9],B=8191&L,K=L>>>13,U=0|s[0],F=8191&U,W=U>>>13,G=0|s[1],z=8191&G,q=G>>>13,$=0|s[2],H=8191&$,Y=$>>>13,V=0|s[3],J=8191&V,X=V>>>13,Z=0|s[4],Q=8191&Z,ee=Z>>>13,te=0|s[5],ne=8191&te,re=te>>>13,oe=0|s[6],ie=8191&oe,ae=oe>>>13,se=0|s[7],ce=8191&se,ue=se>>>13,le=0|s[8],de=8191&le,fe=le>>>13,pe=0|s[9],he=8191&pe,ye=pe>>>13;n.negative=e.negative^t.negative,n.length=19;var be=(u+(r=Math.imul(d,F))|0)+((8191&(o=(o=Math.imul(d,W))+Math.imul(f,F)|0))<<13)|0;u=((i=Math.imul(f,W))+(o>>>13)|0)+(be>>>26)|0,be&=67108863,r=Math.imul(h,F),o=(o=Math.imul(h,W))+Math.imul(y,F)|0,i=Math.imul(y,W);var ge=(u+(r=r+Math.imul(d,z)|0)|0)+((8191&(o=(o=o+Math.imul(d,q)|0)+Math.imul(f,z)|0))<<13)|0;u=((i=i+Math.imul(f,q)|0)+(o>>>13)|0)+(ge>>>26)|0,ge&=67108863,r=Math.imul(g,F),o=(o=Math.imul(g,W))+Math.imul(w,F)|0,i=Math.imul(w,W),r=r+Math.imul(h,z)|0,o=(o=o+Math.imul(h,q)|0)+Math.imul(y,z)|0,i=i+Math.imul(y,q)|0;var we=(u+(r=r+Math.imul(d,H)|0)|0)+((8191&(o=(o=o+Math.imul(d,Y)|0)+Math.imul(f,H)|0))<<13)|0;u=((i=i+Math.imul(f,Y)|0)+(o>>>13)|0)+(we>>>26)|0,we&=67108863,r=Math.imul(m,F),o=(o=Math.imul(m,W))+Math.imul(I,F)|0,i=Math.imul(I,W),r=r+Math.imul(g,z)|0,o=(o=o+Math.imul(g,q)|0)+Math.imul(w,z)|0,i=i+Math.imul(w,q)|0,r=r+Math.imul(h,H)|0,o=(o=o+Math.imul(h,Y)|0)+Math.imul(y,H)|0,i=i+Math.imul(y,Y)|0;var ve=(u+(r=r+Math.imul(d,J)|0)|0)+((8191&(o=(o=o+Math.imul(d,X)|0)+Math.imul(f,J)|0))<<13)|0;u=((i=i+Math.imul(f,X)|0)+(o>>>13)|0)+(ve>>>26)|0,ve&=67108863,r=Math.imul(S,F),o=(o=Math.imul(S,W))+Math.imul(O,F)|0,i=Math.imul(O,W),r=r+Math.imul(m,z)|0,o=(o=o+Math.imul(m,q)|0)+Math.imul(I,z)|0,i=i+Math.imul(I,q)|0,r=r+Math.imul(g,H)|0,o=(o=o+Math.imul(g,Y)|0)+Math.imul(w,H)|0,i=i+Math.imul(w,Y)|0,r=r+Math.imul(h,J)|0,o=(o=o+Math.imul(h,X)|0)+Math.imul(y,J)|0,i=i+Math.imul(y,X)|0;var me=(u+(r=r+Math.imul(d,Q)|0)|0)+((8191&(o=(o=o+Math.imul(d,ee)|0)+Math.imul(f,Q)|0))<<13)|0;u=((i=i+Math.imul(f,ee)|0)+(o>>>13)|0)+(me>>>26)|0,me&=67108863,r=Math.imul(T,F),o=(o=Math.imul(T,W))+Math.imul(_,F)|0,i=Math.imul(_,W),r=r+Math.imul(S,z)|0,o=(o=o+Math.imul(S,q)|0)+Math.imul(O,z)|0,i=i+Math.imul(O,q)|0,r=r+Math.imul(m,H)|0,o=(o=o+Math.imul(m,Y)|0)+Math.imul(I,H)|0,i=i+Math.imul(I,Y)|0,r=r+Math.imul(g,J)|0,o=(o=o+Math.imul(g,X)|0)+Math.imul(w,J)|0,i=i+Math.imul(w,X)|0,r=r+Math.imul(h,Q)|0,o=(o=o+Math.imul(h,ee)|0)+Math.imul(y,Q)|0,i=i+Math.imul(y,ee)|0;var Ie=(u+(r=r+Math.imul(d,ne)|0)|0)+((8191&(o=(o=o+Math.imul(d,re)|0)+Math.imul(f,ne)|0))<<13)|0;u=((i=i+Math.imul(f,re)|0)+(o>>>13)|0)+(Ie>>>26)|0,Ie&=67108863,r=Math.imul(x,F),o=(o=Math.imul(x,W))+Math.imul(P,F)|0,i=Math.imul(P,W),r=r+Math.imul(T,z)|0,o=(o=o+Math.imul(T,q)|0)+Math.imul(_,z)|0,i=i+Math.imul(_,q)|0,r=r+Math.imul(S,H)|0,o=(o=o+Math.imul(S,Y)|0)+Math.imul(O,H)|0,i=i+Math.imul(O,Y)|0,r=r+Math.imul(m,J)|0,o=(o=o+Math.imul(m,X)|0)+Math.imul(I,J)|0,i=i+Math.imul(I,X)|0,r=r+Math.imul(g,Q)|0,o=(o=o+Math.imul(g,ee)|0)+Math.imul(w,Q)|0,i=i+Math.imul(w,ee)|0,r=r+Math.imul(h,ne)|0,o=(o=o+Math.imul(h,re)|0)+Math.imul(y,ne)|0,i=i+Math.imul(y,re)|0;var Ee=(u+(r=r+Math.imul(d,ie)|0)|0)+((8191&(o=(o=o+Math.imul(d,ae)|0)+Math.imul(f,ie)|0))<<13)|0;u=((i=i+Math.imul(f,ae)|0)+(o>>>13)|0)+(Ee>>>26)|0,Ee&=67108863,r=Math.imul(C,F),o=(o=Math.imul(C,W))+Math.imul(N,F)|0,i=Math.imul(N,W),r=r+Math.imul(x,z)|0,o=(o=o+Math.imul(x,q)|0)+Math.imul(P,z)|0,i=i+Math.imul(P,q)|0,r=r+Math.imul(T,H)|0,o=(o=o+Math.imul(T,Y)|0)+Math.imul(_,H)|0,i=i+Math.imul(_,Y)|0,r=r+Math.imul(S,J)|0,o=(o=o+Math.imul(S,X)|0)+Math.imul(O,J)|0,i=i+Math.imul(O,X)|0,r=r+Math.imul(m,Q)|0,o=(o=o+Math.imul(m,ee)|0)+Math.imul(I,Q)|0,i=i+Math.imul(I,ee)|0,r=r+Math.imul(g,ne)|0,o=(o=o+Math.imul(g,re)|0)+Math.imul(w,ne)|0,i=i+Math.imul(w,re)|0,r=r+Math.imul(h,ie)|0,o=(o=o+Math.imul(h,ae)|0)+Math.imul(y,ie)|0,i=i+Math.imul(y,ae)|0;var Se=(u+(r=r+Math.imul(d,ce)|0)|0)+((8191&(o=(o=o+Math.imul(d,ue)|0)+Math.imul(f,ce)|0))<<13)|0;u=((i=i+Math.imul(f,ue)|0)+(o>>>13)|0)+(Se>>>26)|0,Se&=67108863,r=Math.imul(D,F),o=(o=Math.imul(D,W))+Math.imul(R,F)|0,i=Math.imul(R,W),r=r+Math.imul(C,z)|0,o=(o=o+Math.imul(C,q)|0)+Math.imul(N,z)|0,i=i+Math.imul(N,q)|0,r=r+Math.imul(x,H)|0,o=(o=o+Math.imul(x,Y)|0)+Math.imul(P,H)|0,i=i+Math.imul(P,Y)|0,r=r+Math.imul(T,J)|0,o=(o=o+Math.imul(T,X)|0)+Math.imul(_,J)|0,i=i+Math.imul(_,X)|0,r=r+Math.imul(S,Q)|0,o=(o=o+Math.imul(S,ee)|0)+Math.imul(O,Q)|0,i=i+Math.imul(O,ee)|0,r=r+Math.imul(m,ne)|0,o=(o=o+Math.imul(m,re)|0)+Math.imul(I,ne)|0,i=i+Math.imul(I,re)|0,r=r+Math.imul(g,ie)|0,o=(o=o+Math.imul(g,ae)|0)+Math.imul(w,ie)|0,i=i+Math.imul(w,ae)|0,r=r+Math.imul(h,ce)|0,o=(o=o+Math.imul(h,ue)|0)+Math.imul(y,ce)|0,i=i+Math.imul(y,ue)|0;var Oe=(u+(r=r+Math.imul(d,de)|0)|0)+((8191&(o=(o=o+Math.imul(d,fe)|0)+Math.imul(f,de)|0))<<13)|0;u=((i=i+Math.imul(f,fe)|0)+(o>>>13)|0)+(Oe>>>26)|0,Oe&=67108863,r=Math.imul(B,F),o=(o=Math.imul(B,W))+Math.imul(K,F)|0,i=Math.imul(K,W),r=r+Math.imul(D,z)|0,o=(o=o+Math.imul(D,q)|0)+Math.imul(R,z)|0,i=i+Math.imul(R,q)|0,r=r+Math.imul(C,H)|0,o=(o=o+Math.imul(C,Y)|0)+Math.imul(N,H)|0,i=i+Math.imul(N,Y)|0,r=r+Math.imul(x,J)|0,o=(o=o+Math.imul(x,X)|0)+Math.imul(P,J)|0,i=i+Math.imul(P,X)|0,r=r+Math.imul(T,Q)|0,o=(o=o+Math.imul(T,ee)|0)+Math.imul(_,Q)|0,i=i+Math.imul(_,ee)|0,r=r+Math.imul(S,ne)|0,o=(o=o+Math.imul(S,re)|0)+Math.imul(O,ne)|0,i=i+Math.imul(O,re)|0,r=r+Math.imul(m,ie)|0,o=(o=o+Math.imul(m,ae)|0)+Math.imul(I,ie)|0,i=i+Math.imul(I,ae)|0,r=r+Math.imul(g,ce)|0,o=(o=o+Math.imul(g,ue)|0)+Math.imul(w,ce)|0,i=i+Math.imul(w,ue)|0,r=r+Math.imul(h,de)|0,o=(o=o+Math.imul(h,fe)|0)+Math.imul(y,de)|0,i=i+Math.imul(y,fe)|0;var Ae=(u+(r=r+Math.imul(d,he)|0)|0)+((8191&(o=(o=o+Math.imul(d,ye)|0)+Math.imul(f,he)|0))<<13)|0;u=((i=i+Math.imul(f,ye)|0)+(o>>>13)|0)+(Ae>>>26)|0,Ae&=67108863,r=Math.imul(B,z),o=(o=Math.imul(B,q))+Math.imul(K,z)|0,i=Math.imul(K,q),r=r+Math.imul(D,H)|0,o=(o=o+Math.imul(D,Y)|0)+Math.imul(R,H)|0,i=i+Math.imul(R,Y)|0,r=r+Math.imul(C,J)|0,o=(o=o+Math.imul(C,X)|0)+Math.imul(N,J)|0,i=i+Math.imul(N,X)|0,r=r+Math.imul(x,Q)|0,o=(o=o+Math.imul(x,ee)|0)+Math.imul(P,Q)|0,i=i+Math.imul(P,ee)|0,r=r+Math.imul(T,ne)|0,o=(o=o+Math.imul(T,re)|0)+Math.imul(_,ne)|0,i=i+Math.imul(_,re)|0,r=r+Math.imul(S,ie)|0,o=(o=o+Math.imul(S,ae)|0)+Math.imul(O,ie)|0,i=i+Math.imul(O,ae)|0,r=r+Math.imul(m,ce)|0,o=(o=o+Math.imul(m,ue)|0)+Math.imul(I,ce)|0,i=i+Math.imul(I,ue)|0,r=r+Math.imul(g,de)|0,o=(o=o+Math.imul(g,fe)|0)+Math.imul(w,de)|0,i=i+Math.imul(w,fe)|0;var Te=(u+(r=r+Math.imul(h,he)|0)|0)+((8191&(o=(o=o+Math.imul(h,ye)|0)+Math.imul(y,he)|0))<<13)|0;u=((i=i+Math.imul(y,ye)|0)+(o>>>13)|0)+(Te>>>26)|0,Te&=67108863,r=Math.imul(B,H),o=(o=Math.imul(B,Y))+Math.imul(K,H)|0,i=Math.imul(K,Y),r=r+Math.imul(D,J)|0,o=(o=o+Math.imul(D,X)|0)+Math.imul(R,J)|0,i=i+Math.imul(R,X)|0,r=r+Math.imul(C,Q)|0,o=(o=o+Math.imul(C,ee)|0)+Math.imul(N,Q)|0,i=i+Math.imul(N,ee)|0,r=r+Math.imul(x,ne)|0,o=(o=o+Math.imul(x,re)|0)+Math.imul(P,ne)|0,i=i+Math.imul(P,re)|0,r=r+Math.imul(T,ie)|0,o=(o=o+Math.imul(T,ae)|0)+Math.imul(_,ie)|0,i=i+Math.imul(_,ae)|0,r=r+Math.imul(S,ce)|0,o=(o=o+Math.imul(S,ue)|0)+Math.imul(O,ce)|0,i=i+Math.imul(O,ue)|0,r=r+Math.imul(m,de)|0,o=(o=o+Math.imul(m,fe)|0)+Math.imul(I,de)|0,i=i+Math.imul(I,fe)|0;var _e=(u+(r=r+Math.imul(g,he)|0)|0)+((8191&(o=(o=o+Math.imul(g,ye)|0)+Math.imul(w,he)|0))<<13)|0;u=((i=i+Math.imul(w,ye)|0)+(o>>>13)|0)+(_e>>>26)|0,_e&=67108863,r=Math.imul(B,J),o=(o=Math.imul(B,X))+Math.imul(K,J)|0,i=Math.imul(K,X),r=r+Math.imul(D,Q)|0,o=(o=o+Math.imul(D,ee)|0)+Math.imul(R,Q)|0,i=i+Math.imul(R,ee)|0,r=r+Math.imul(C,ne)|0,o=(o=o+Math.imul(C,re)|0)+Math.imul(N,ne)|0,i=i+Math.imul(N,re)|0,r=r+Math.imul(x,ie)|0,o=(o=o+Math.imul(x,ae)|0)+Math.imul(P,ie)|0,i=i+Math.imul(P,ae)|0,r=r+Math.imul(T,ce)|0,o=(o=o+Math.imul(T,ue)|0)+Math.imul(_,ce)|0,i=i+Math.imul(_,ue)|0,r=r+Math.imul(S,de)|0,o=(o=o+Math.imul(S,fe)|0)+Math.imul(O,de)|0,i=i+Math.imul(O,fe)|0;var ke=(u+(r=r+Math.imul(m,he)|0)|0)+((8191&(o=(o=o+Math.imul(m,ye)|0)+Math.imul(I,he)|0))<<13)|0;u=((i=i+Math.imul(I,ye)|0)+(o>>>13)|0)+(ke>>>26)|0,ke&=67108863,r=Math.imul(B,Q),o=(o=Math.imul(B,ee))+Math.imul(K,Q)|0,i=Math.imul(K,ee),r=r+Math.imul(D,ne)|0,o=(o=o+Math.imul(D,re)|0)+Math.imul(R,ne)|0,i=i+Math.imul(R,re)|0,r=r+Math.imul(C,ie)|0,o=(o=o+Math.imul(C,ae)|0)+Math.imul(N,ie)|0,i=i+Math.imul(N,ae)|0,r=r+Math.imul(x,ce)|0,o=(o=o+Math.imul(x,ue)|0)+Math.imul(P,ce)|0,i=i+Math.imul(P,ue)|0,r=r+Math.imul(T,de)|0,o=(o=o+Math.imul(T,fe)|0)+Math.imul(_,de)|0,i=i+Math.imul(_,fe)|0;var xe=(u+(r=r+Math.imul(S,he)|0)|0)+((8191&(o=(o=o+Math.imul(S,ye)|0)+Math.imul(O,he)|0))<<13)|0;u=((i=i+Math.imul(O,ye)|0)+(o>>>13)|0)+(xe>>>26)|0,xe&=67108863,r=Math.imul(B,ne),o=(o=Math.imul(B,re))+Math.imul(K,ne)|0,i=Math.imul(K,re),r=r+Math.imul(D,ie)|0,o=(o=o+Math.imul(D,ae)|0)+Math.imul(R,ie)|0,i=i+Math.imul(R,ae)|0,r=r+Math.imul(C,ce)|0,o=(o=o+Math.imul(C,ue)|0)+Math.imul(N,ce)|0,i=i+Math.imul(N,ue)|0,r=r+Math.imul(x,de)|0,o=(o=o+Math.imul(x,fe)|0)+Math.imul(P,de)|0,i=i+Math.imul(P,fe)|0;var Pe=(u+(r=r+Math.imul(T,he)|0)|0)+((8191&(o=(o=o+Math.imul(T,ye)|0)+Math.imul(_,he)|0))<<13)|0;u=((i=i+Math.imul(_,ye)|0)+(o>>>13)|0)+(Pe>>>26)|0,Pe&=67108863,r=Math.imul(B,ie),o=(o=Math.imul(B,ae))+Math.imul(K,ie)|0,i=Math.imul(K,ae),r=r+Math.imul(D,ce)|0,o=(o=o+Math.imul(D,ue)|0)+Math.imul(R,ce)|0,i=i+Math.imul(R,ue)|0,r=r+Math.imul(C,de)|0,o=(o=o+Math.imul(C,fe)|0)+Math.imul(N,de)|0,i=i+Math.imul(N,fe)|0;var Me=(u+(r=r+Math.imul(x,he)|0)|0)+((8191&(o=(o=o+Math.imul(x,ye)|0)+Math.imul(P,he)|0))<<13)|0;u=((i=i+Math.imul(P,ye)|0)+(o>>>13)|0)+(Me>>>26)|0,Me&=67108863,r=Math.imul(B,ce),o=(o=Math.imul(B,ue))+Math.imul(K,ce)|0,i=Math.imul(K,ue),r=r+Math.imul(D,de)|0,o=(o=o+Math.imul(D,fe)|0)+Math.imul(R,de)|0,i=i+Math.imul(R,fe)|0;var Ce=(u+(r=r+Math.imul(C,he)|0)|0)+((8191&(o=(o=o+Math.imul(C,ye)|0)+Math.imul(N,he)|0))<<13)|0;u=((i=i+Math.imul(N,ye)|0)+(o>>>13)|0)+(Ce>>>26)|0,Ce&=67108863,r=Math.imul(B,de),o=(o=Math.imul(B,fe))+Math.imul(K,de)|0,i=Math.imul(K,fe);var Ne=(u+(r=r+Math.imul(D,he)|0)|0)+((8191&(o=(o=o+Math.imul(D,ye)|0)+Math.imul(R,he)|0))<<13)|0;u=((i=i+Math.imul(R,ye)|0)+(o>>>13)|0)+(Ne>>>26)|0,Ne&=67108863;var je=(u+(r=Math.imul(B,he))|0)+((8191&(o=(o=Math.imul(B,ye))+Math.imul(K,he)|0))<<13)|0;return u=((i=Math.imul(K,ye))+(o>>>13)|0)+(je>>>26)|0,je&=67108863,c[0]=be,c[1]=ge,c[2]=we,c[3]=ve,c[4]=me,c[5]=Ie,c[6]=Ee,c[7]=Se,c[8]=Oe,c[9]=Ae,c[10]=Te,c[11]=_e,c[12]=ke,c[13]=xe,c[14]=Pe,c[15]=Me,c[16]=Ce,c[17]=Ne,c[18]=je,0!==u&&(c[19]=u,n.length++),n};function y(e,t,n){return(new b).mulp(e,t,n)}function b(e,t){this.x=e,this.y=t}Math.imul||(h=p),i.prototype.mulTo=function(e,t){var n,r=this.length+e.length;return n=10===this.length&&10===e.length?h(this,e,t):r<63?p(this,e,t):r<1024?function(e,t,n){n.negative=t.negative^e.negative,n.length=e.length+t.length;for(var r=0,o=0,i=0;i<n.length-1;i++){var a=o;o=0;for(var s=67108863&r,c=Math.min(i,t.length-1),u=Math.max(0,i-e.length+1);u<=c;u++){var l=i-u,d=(0|e.words[l])*(0|t.words[u]),f=67108863&d;s=67108863&(f=f+s|0),o+=(a=(a=a+(d/67108864|0)|0)+(f>>>26)|0)>>>26,a&=67108863}n.words[i]=s,r=a,a=o}return 0!==r?n.words[i]=r:n.length--,n.strip()}(this,e,t):y(this,e,t),n},b.prototype.makeRBT=function(e){for(var t=new Array(e),n=i.prototype._countBits(e)-1,r=0;r<e;r++)t[r]=this.revBin(r,n,e);return t},b.prototype.revBin=function(e,t,n){if(0===e||e===n-1)return e;for(var r=0,o=0;o<t;o++)r|=(1&e)<<t-o-1,e>>=1;return r},b.prototype.permute=function(e,t,n,r,o,i){for(var a=0;a<i;a++)r[a]=t[e[a]],o[a]=n[e[a]]},b.prototype.transform=function(e,t,n,r,o,i){this.permute(i,e,t,n,r,o);for(var a=1;a<o;a<<=1)for(var s=a<<1,c=Math.cos(2*Math.PI/s),u=Math.sin(2*Math.PI/s),l=0;l<o;l+=s)for(var d=c,f=u,p=0;p<a;p++){var h=n[l+p],y=r[l+p],b=n[l+p+a],g=r[l+p+a],w=d*b-f*g;g=d*g+f*b,b=w,n[l+p]=h+b,r[l+p]=y+g,n[l+p+a]=h-b,r[l+p+a]=y-g,p!==s&&(w=c*d-u*f,f=c*f+u*d,d=w)}},b.prototype.guessLen13b=function(e,t){var n=1|Math.max(t,e),r=1&n,o=0;for(n=n/2|0;n;n>>>=1)o++;return 1<<o+1+r},b.prototype.conjugate=function(e,t,n){if(!(n<=1))for(var r=0;r<n/2;r++){var o=e[r];e[r]=e[n-r-1],e[n-r-1]=o,o=t[r],t[r]=-t[n-r-1],t[n-r-1]=-o}},b.prototype.normalize13b=function(e,t){for(var n=0,r=0;r<t/2;r++){var o=8192*Math.round(e[2*r+1]/t)+Math.round(e[2*r]/t)+n;e[r]=67108863&o,n=o<67108864?0:o/67108864|0}return e},b.prototype.convert13b=function(e,t,n,o){for(var i=0,a=0;a<t;a++)i+=0|e[a],n[2*a]=8191&i,i>>>=13,n[2*a+1]=8191&i,i>>>=13;for(a=2*t;a<o;++a)n[a]=0;r(0===i),r(!(-8192&i))},b.prototype.stub=function(e){for(var t=new Array(e),n=0;n<e;n++)t[n]=0;return t},b.prototype.mulp=function(e,t,n){var r=2*this.guessLen13b(e.length,t.length),o=this.makeRBT(r),i=this.stub(r),a=new Array(r),s=new Array(r),c=new Array(r),u=new Array(r),l=new Array(r),d=new Array(r),f=n.words;f.length=r,this.convert13b(e.words,e.length,a,r),this.convert13b(t.words,t.length,u,r),this.transform(a,i,s,c,r,o),this.transform(u,i,l,d,r,o);for(var p=0;p<r;p++){var h=s[p]*l[p]-c[p]*d[p];c[p]=s[p]*d[p]+c[p]*l[p],s[p]=h}return this.conjugate(s,c,r),this.transform(s,c,f,i,r,o),this.conjugate(f,i,r),this.normalize13b(f,r),n.negative=e.negative^t.negative,n.length=e.length+t.length,n.strip()},i.prototype.mul=function(e){var t=new i(null);return t.words=new Array(this.length+e.length),this.mulTo(e,t)},i.prototype.mulf=function(e){var t=new i(null);return t.words=new Array(this.length+e.length),y(this,e,t)},i.prototype.imul=function(e){return this.clone().mulTo(e,this)},i.prototype.imuln=function(e){r("number"==typeof e),r(e<67108864);for(var t=0,n=0;n<this.length;n++){var o=(0|this.words[n])*e,i=(67108863&o)+(67108863&t);t>>=26,t+=o/67108864|0,t+=i>>>26,this.words[n]=67108863&i}return 0!==t&&(this.words[n]=t,this.length++),this.length=0===e?1:this.length,this},i.prototype.muln=function(e){return this.clone().imuln(e)},i.prototype.sqr=function(){return this.mul(this)},i.prototype.isqr=function(){return this.imul(this.clone())},i.prototype.pow=function(e){var t=function(e){for(var t=new Array(e.bitLength()),n=0;n<t.length;n++){var r=n/26|0,o=n%26;t[n]=(e.words[r]&1<<o)>>>o}return t}(e);if(0===t.length)return new i(1);for(var n=this,r=0;r<t.length&&0===t[r];r++,n=n.sqr());if(++r<t.length)for(var o=n.sqr();r<t.length;r++,o=o.sqr())0!==t[r]&&(n=n.mul(o));return n},i.prototype.iushln=function(e){r("number"==typeof e&&e>=0);var t,n=e%26,o=(e-n)/26,i=67108863>>>26-n<<26-n;if(0!==n){var a=0;for(t=0;t<this.length;t++){var s=this.words[t]&i,c=(0|this.words[t])-s<<n;this.words[t]=c|a,a=s>>>26-n}a&&(this.words[t]=a,this.length++)}if(0!==o){for(t=this.length-1;t>=0;t--)this.words[t+o]=this.words[t];for(t=0;t<o;t++)this.words[t]=0;this.length+=o}return this.strip()},i.prototype.ishln=function(e){return r(0===this.negative),this.iushln(e)},i.prototype.iushrn=function(e,t,n){var o;r("number"==typeof e&&e>=0),o=t?(t-t%26)/26:0;var i=e%26,a=Math.min((e-i)/26,this.length),s=67108863^67108863>>>i<<i,c=n;if(o-=a,o=Math.max(0,o),c){for(var u=0;u<a;u++)c.words[u]=this.words[u];c.length=a}if(0===a);else if(this.length>a)for(this.length-=a,u=0;u<this.length;u++)this.words[u]=this.words[u+a];else this.words[0]=0,this.length=1;var l=0;for(u=this.length-1;u>=0&&(0!==l||u>=o);u--){var d=0|this.words[u];this.words[u]=l<<26-i|d>>>i,l=d&s}return c&&0!==l&&(c.words[c.length++]=l),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},i.prototype.ishrn=function(e,t,n){return r(0===this.negative),this.iushrn(e,t,n)},i.prototype.shln=function(e){return this.clone().ishln(e)},i.prototype.ushln=function(e){return this.clone().iushln(e)},i.prototype.shrn=function(e){return this.clone().ishrn(e)},i.prototype.ushrn=function(e){return this.clone().iushrn(e)},i.prototype.testn=function(e){r("number"==typeof e&&e>=0);var t=e%26,n=(e-t)/26,o=1<<t;return!(this.length<=n)&&!!(this.words[n]&o)},i.prototype.imaskn=function(e){r("number"==typeof e&&e>=0);var t=e%26,n=(e-t)/26;if(r(0===this.negative,"imaskn works only with positive numbers"),this.length<=n)return this;if(0!==t&&n++,this.length=Math.min(n,this.length),0!==t){var o=67108863^67108863>>>t<<t;this.words[this.length-1]&=o}return 0===this.length&&(this.words[0]=0,this.length=1),this.strip()},i.prototype.maskn=function(e){return this.clone().imaskn(e)},i.prototype.iaddn=function(e){return r("number"==typeof e),r(e<67108864),e<0?this.isubn(-e):0!==this.negative?1===this.length&&(0|this.words[0])<e?(this.words[0]=e-(0|this.words[0]),this.negative=0,this):(this.negative=0,this.isubn(e),this.negative=1,this):this._iaddn(e)},i.prototype._iaddn=function(e){this.words[0]+=e;for(var t=0;t<this.length&&this.words[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},i.prototype.isubn=function(e){if(r("number"==typeof e),r(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<this.length&&this.words[t]<0;t++)this.words[t]+=67108864,this.words[t+1]-=1;return this.strip()},i.prototype.addn=function(e){return this.clone().iaddn(e)},i.prototype.subn=function(e){return this.clone().isubn(e)},i.prototype.iabs=function(){return this.negative=0,this},i.prototype.abs=function(){return this.clone().iabs()},i.prototype._ishlnsubmul=function(e,t,n){var o,i,a=e.length+n;this._expand(a);var s=0;for(o=0;o<e.length;o++){i=(0|this.words[o+n])+s;var c=(0|e.words[o])*t;s=((i-=67108863&c)>>26)-(c/67108864|0),this.words[o+n]=67108863&i}for(;o<this.length-n;o++)s=(i=(0|this.words[o+n])+s)>>26,this.words[o+n]=67108863&i;if(0===s)return this.strip();for(r(-1===s),s=0,o=0;o<this.length;o++)s=(i=-(0|this.words[o])+s)>>26,this.words[o]=67108863&i;return this.negative=1,this.strip()},i.prototype._wordDiv=function(e,t){var n=(this.length,e.length),r=this.clone(),o=e,a=0|o.words[o.length-1];0!==(n=26-this._countBits(a))&&(o=o.ushln(n),r.iushln(n),a=0|o.words[o.length-1]);var s,c=r.length-o.length;if("mod"!==t){(s=new i(null)).length=c+1,s.words=new Array(s.length);for(var u=0;u<s.length;u++)s.words[u]=0}var l=r.clone()._ishlnsubmul(o,1,c);0===l.negative&&(r=l,s&&(s.words[c]=1));for(var d=c-1;d>=0;d--){var f=67108864*(0|r.words[o.length+d])+(0|r.words[o.length+d-1]);for(f=Math.min(f/a|0,67108863),r._ishlnsubmul(o,f,d);0!==r.negative;)f--,r.negative=0,r._ishlnsubmul(o,1,d),r.isZero()||(r.negative^=1);s&&(s.words[d]=f)}return s&&s.strip(),r.strip(),"div"!==t&&0!==n&&r.iushrn(n),{div:s||null,mod:r}},i.prototype.divmod=function(e,t,n){return r(!e.isZero()),this.isZero()?{div:new i(0),mod:new i(0)}:0!==this.negative&&0===e.negative?(s=this.neg().divmod(e,t),"mod"!==t&&(o=s.div.neg()),"div"!==t&&(a=s.mod.neg(),n&&0!==a.negative&&a.iadd(e)),{div:o,mod:a}):0===this.negative&&0!==e.negative?(s=this.divmod(e.neg(),t),"mod"!==t&&(o=s.div.neg()),{div:o,mod:s.mod}):0!==(this.negative&e.negative)?(s=this.neg().divmod(e.neg(),t),"div"!==t&&(a=s.mod.neg(),n&&0!==a.negative&&a.isub(e)),{div:s.div,mod:a}):e.length>this.length||this.cmp(e)<0?{div:new i(0),mod:this}:1===e.length?"div"===t?{div:this.divn(e.words[0]),mod:null}:"mod"===t?{div:null,mod:new i(this.modn(e.words[0]))}:{div:this.divn(e.words[0]),mod:new i(this.modn(e.words[0]))}:this._wordDiv(e,t);var o,a,s},i.prototype.div=function(e){return this.divmod(e,"div",!1).div},i.prototype.mod=function(e){return this.divmod(e,"mod",!1).mod},i.prototype.umod=function(e){return this.divmod(e,"mod",!0).mod},i.prototype.divRound=function(e){var t=this.divmod(e);if(t.mod.isZero())return t.div;var n=0!==t.div.negative?t.mod.isub(e):t.mod,r=e.ushrn(1),o=e.andln(1),i=n.cmp(r);return i<0||1===o&&0===i?t.div:0!==t.div.negative?t.div.isubn(1):t.div.iaddn(1)},i.prototype.modn=function(e){r(e<=67108863);for(var t=(1<<26)%e,n=0,o=this.length-1;o>=0;o--)n=(t*n+(0|this.words[o]))%e;return n},i.prototype.idivn=function(e){r(e<=67108863);for(var t=0,n=this.length-1;n>=0;n--){var o=(0|this.words[n])+67108864*t;this.words[n]=o/e|0,t=o%e}return this.strip()},i.prototype.divn=function(e){return this.clone().idivn(e)},i.prototype.egcd=function(e){r(0===e.negative),r(!e.isZero());var t=this,n=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var o=new i(1),a=new i(0),s=new i(0),c=new i(1),u=0;t.isEven()&&n.isEven();)t.iushrn(1),n.iushrn(1),++u;for(var l=n.clone(),d=t.clone();!t.isZero();){for(var f=0,p=1;0===(t.words[0]&p)&&f<26;++f,p<<=1);if(f>0)for(t.iushrn(f);f-- >0;)(o.isOdd()||a.isOdd())&&(o.iadd(l),a.isub(d)),o.iushrn(1),a.iushrn(1);for(var h=0,y=1;0===(n.words[0]&y)&&h<26;++h,y<<=1);if(h>0)for(n.iushrn(h);h-- >0;)(s.isOdd()||c.isOdd())&&(s.iadd(l),c.isub(d)),s.iushrn(1),c.iushrn(1);t.cmp(n)>=0?(t.isub(n),o.isub(s),a.isub(c)):(n.isub(t),s.isub(o),c.isub(a))}return{a:s,b:c,gcd:n.iushln(u)}},i.prototype._invmp=function(e){r(0===e.negative),r(!e.isZero());var t=this,n=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var o,a=new i(1),s=new i(0),c=n.clone();t.cmpn(1)>0&&n.cmpn(1)>0;){for(var u=0,l=1;0===(t.words[0]&l)&&u<26;++u,l<<=1);if(u>0)for(t.iushrn(u);u-- >0;)a.isOdd()&&a.iadd(c),a.iushrn(1);for(var d=0,f=1;0===(n.words[0]&f)&&d<26;++d,f<<=1);if(d>0)for(n.iushrn(d);d-- >0;)s.isOdd()&&s.iadd(c),s.iushrn(1);t.cmp(n)>=0?(t.isub(n),a.isub(s)):(n.isub(t),s.isub(a))}return(o=0===t.cmpn(1)?a:s).cmpn(0)<0&&o.iadd(e),o},i.prototype.gcd=function(e){if(this.isZero())return e.abs();if(e.isZero())return this.abs();var t=this.clone(),n=e.clone();t.negative=0,n.negative=0;for(var r=0;t.isEven()&&n.isEven();r++)t.iushrn(1),n.iushrn(1);for(;;){for(;t.isEven();)t.iushrn(1);for(;n.isEven();)n.iushrn(1);var o=t.cmp(n);if(o<0){var i=t;t=n,n=i}else if(0===o||0===n.cmpn(1))break;t.isub(n)}return n.iushln(r)},i.prototype.invm=function(e){return this.egcd(e).a.umod(e)},i.prototype.isEven=function(){return!(1&this.words[0])},i.prototype.isOdd=function(){return!(1&~this.words[0])},i.prototype.andln=function(e){return this.words[0]&e},i.prototype.bincn=function(e){r("number"==typeof e);var t=e%26,n=(e-t)/26,o=1<<t;if(this.length<=n)return this._expand(n+1),this.words[n]|=o,this;for(var i=o,a=n;0!==i&&a<this.length;a++){var s=0|this.words[a];i=(s+=i)>>>26,s&=67108863,this.words[a]=s}return 0!==i&&(this.words[a]=i,this.length++),this},i.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},i.prototype.cmpn=function(e){var t,n=e<0;if(0!==this.negative&&!n)return-1;if(0===this.negative&&n)return 1;if(this.strip(),this.length>1)t=1;else{n&&(e=-e),r(e<=67108863,"Number is too big");var o=0|this.words[0];t=o===e?0:o<e?-1:1}return 0!==this.negative?0|-t:t},i.prototype.cmp=function(e){if(0!==this.negative&&0===e.negative)return-1;if(0===this.negative&&0!==e.negative)return 1;var t=this.ucmp(e);return 0!==this.negative?0|-t:t},i.prototype.ucmp=function(e){if(this.length>e.length)return 1;if(this.length<e.length)return-1;for(var t=0,n=this.length-1;n>=0;n--){var r=0|this.words[n],o=0|e.words[n];if(r!==o){r<o?t=-1:r>o&&(t=1);break}}return t},i.prototype.gtn=function(e){return 1===this.cmpn(e)},i.prototype.gt=function(e){return 1===this.cmp(e)},i.prototype.gten=function(e){return this.cmpn(e)>=0},i.prototype.gte=function(e){return this.cmp(e)>=0},i.prototype.ltn=function(e){return-1===this.cmpn(e)},i.prototype.lt=function(e){return-1===this.cmp(e)},i.prototype.lten=function(e){return this.cmpn(e)<=0},i.prototype.lte=function(e){return this.cmp(e)<=0},i.prototype.eqn=function(e){return 0===this.cmpn(e)},i.prototype.eq=function(e){return 0===this.cmp(e)},i.red=function(e){return new S(e)},i.prototype.toRed=function(e){return r(!this.red,"Already a number in reduction context"),r(0===this.negative,"red works only with positives"),e.convertTo(this)._forceRed(e)},i.prototype.fromRed=function(){return r(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},i.prototype._forceRed=function(e){return this.red=e,this},i.prototype.forceRed=function(e){return r(!this.red,"Already a number in reduction context"),this._forceRed(e)},i.prototype.redAdd=function(e){return r(this.red,"redAdd works only with red numbers"),this.red.add(this,e)},i.prototype.redIAdd=function(e){return r(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,e)},i.prototype.redSub=function(e){return r(this.red,"redSub works only with red numbers"),this.red.sub(this,e)},i.prototype.redISub=function(e){return r(this.red,"redISub works only with red numbers"),this.red.isub(this,e)},i.prototype.redShl=function(e){return r(this.red,"redShl works only with red numbers"),this.red.shl(this,e)},i.prototype.redMul=function(e){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.mul(this,e)},i.prototype.redIMul=function(e){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.imul(this,e)},i.prototype.redSqr=function(){return r(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},i.prototype.redISqr=function(){return r(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},i.prototype.redSqrt=function(){return r(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},i.prototype.redInvm=function(){return r(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},i.prototype.redNeg=function(){return r(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},i.prototype.redPow=function(e){return r(this.red&&!e.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,e)};var g={k256:null,p224:null,p192:null,p25519:null};function w(e,t){this.name=e,this.p=new i(t,16),this.n=this.p.bitLength(),this.k=new i(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function v(){w.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function m(){w.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function I(){w.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function E(){w.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function S(e){if("string"==typeof e){var t=i._prime(e);this.m=t.p,this.prime=t}else r(e.gtn(1),"modulus must be greater than 1"),this.m=e,this.prime=null}function O(e){S.call(this,e),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new i(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)}w.prototype._tmp=function(){var e=new i(null);return e.words=new Array(Math.ceil(this.n/13)),e},w.prototype.ireduce=function(e){var t,n=e;do{this.split(n,this.tmp),t=(n=(n=this.imulK(n)).iadd(this.tmp)).bitLength()}while(t>this.n);var r=t<this.n?-1:n.ucmp(this.p);return 0===r?(n.words[0]=0,n.length=1):r>0?n.isub(this.p):void 0!==n.strip?n.strip():n._strip(),n},w.prototype.split=function(e,t){e.iushrn(this.n,0,t)},w.prototype.imulK=function(e){return e.imul(this.k)},o(v,w),v.prototype.split=function(e,t){for(var n=4194303,r=Math.min(e.length,9),o=0;o<r;o++)t.words[o]=e.words[o];if(t.length=r,e.length<=9)return e.words[0]=0,void(e.length=1);var i=e.words[9];for(t.words[t.length++]=i&n,o=10;o<e.length;o++){var a=0|e.words[o];e.words[o-10]=(a&n)<<4|i>>>22,i=a}i>>>=22,e.words[o-10]=i,0===i&&e.length>10?e.length-=10:e.length-=9},v.prototype.imulK=function(e){e.words[e.length]=0,e.words[e.length+1]=0,e.length+=2;for(var t=0,n=0;n<e.length;n++){var r=0|e.words[n];t+=977*r,e.words[n]=67108863&t,t=64*r+(t/67108864|0)}return 0===e.words[e.length-1]&&(e.length--,0===e.words[e.length-1]&&e.length--),e},o(m,w),o(I,w),o(E,w),E.prototype.imulK=function(e){for(var t=0,n=0;n<e.length;n++){var r=19*(0|e.words[n])+t,o=67108863&r;r>>>=26,e.words[n]=o,t=r}return 0!==t&&(e.words[e.length++]=t),e},i._prime=function(e){if(g[e])return g[e];var t;if("k256"===e)t=new v;else if("p224"===e)t=new m;else if("p192"===e)t=new I;else{if("p25519"!==e)throw new Error("Unknown prime "+e);t=new E}return g[e]=t,t},S.prototype._verify1=function(e){r(0===e.negative,"red works only with positives"),r(e.red,"red works only with red numbers")},S.prototype._verify2=function(e,t){r(0===(e.negative|t.negative),"red works only with positives"),r(e.red&&e.red===t.red,"red works only with red numbers")},S.prototype.imod=function(e){return this.prime?this.prime.ireduce(e)._forceRed(this):e.umod(this.m)._forceRed(this)},S.prototype.neg=function(e){return e.isZero()?e.clone():this.m.sub(e)._forceRed(this)},S.prototype.add=function(e,t){this._verify2(e,t);var n=e.add(t);return n.cmp(this.m)>=0&&n.isub(this.m),n._forceRed(this)},S.prototype.iadd=function(e,t){this._verify2(e,t);var n=e.iadd(t);return n.cmp(this.m)>=0&&n.isub(this.m),n},S.prototype.sub=function(e,t){this._verify2(e,t);var n=e.sub(t);return n.cmpn(0)<0&&n.iadd(this.m),n._forceRed(this)},S.prototype.isub=function(e,t){this._verify2(e,t);var n=e.isub(t);return n.cmpn(0)<0&&n.iadd(this.m),n},S.prototype.shl=function(e,t){return this._verify1(e),this.imod(e.ushln(t))},S.prototype.imul=function(e,t){return this._verify2(e,t),this.imod(e.imul(t))},S.prototype.mul=function(e,t){return this._verify2(e,t),this.imod(e.mul(t))},S.prototype.isqr=function(e){return this.imul(e,e.clone())},S.prototype.sqr=function(e){return this.mul(e,e)},S.prototype.sqrt=function(e){if(e.isZero())return e.clone();var t=this.m.andln(3);if(r(t%2==1),3===t){var n=this.m.add(new i(1)).iushrn(2);return this.pow(e,n)}for(var o=this.m.subn(1),a=0;!o.isZero()&&0===o.andln(1);)a++,o.iushrn(1);r(!o.isZero());var s=new i(1).toRed(this),c=s.redNeg(),u=this.m.subn(1).iushrn(1),l=this.m.bitLength();for(l=new i(2*l*l).toRed(this);0!==this.pow(l,u).cmp(c);)l.redIAdd(c);for(var d=this.pow(l,o),f=this.pow(e,o.addn(1).iushrn(1)),p=this.pow(e,o),h=a;0!==p.cmp(s);){for(var y=p,b=0;0!==y.cmp(s);b++)y=y.redSqr();r(b<h);var g=this.pow(d,new i(1).iushln(h-b-1));f=f.redMul(g),d=g.redSqr(),p=p.redMul(d),h=b}return f},S.prototype.invm=function(e){var t=e._invmp(this.m);return 0!==t.negative?(t.negative=0,this.imod(t).redNeg()):this.imod(t)},S.prototype.pow=function(e,t){if(t.isZero())return new i(1).toRed(this);if(0===t.cmpn(1))return e.clone();var n=new Array(16);n[0]=new i(1).toRed(this),n[1]=e;for(var r=2;r<n.length;r++)n[r]=this.mul(n[r-1],e);var o=n[0],a=0,s=0,c=t.bitLength()%26;for(0===c&&(c=26),r=t.length-1;r>=0;r--){for(var u=t.words[r],l=c-1;l>=0;l--){var d=u>>l&1;o!==n[0]&&(o=this.sqr(o)),0!==d||0!==a?(a<<=1,a|=d,(4===++s||0===r&&0===l)&&(o=this.mul(o,n[a]),s=0,a=0)):s=0}c=26}return o},S.prototype.convertTo=function(e){var t=e.umod(this.m);return t===e?t.clone():t},S.prototype.convertFrom=function(e){var t=e.clone();return t.red=null,t},i.mont=function(e){return new O(e)},o(O,S),O.prototype.convertTo=function(e){return this.imod(e.ushln(this.shift))},O.prototype.convertFrom=function(e){var t=this.imod(e.mul(this.rinv));return t.red=null,t},O.prototype.imul=function(e,t){if(e.isZero()||t.isZero())return e.words[0]=0,e.length=1,e;var n=e.imul(t),r=n.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),o=n.isub(r).iushrn(this.shift),i=o;return o.cmp(this.m)>=0?i=o.isub(this.m):o.cmpn(0)<0&&(i=o.iadd(this.m)),i._forceRed(this)},O.prototype.mul=function(e,t){if(e.isZero()||t.isZero())return new i(0)._forceRed(this);var n=e.mul(t),r=n.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),o=n.isub(r).iushrn(this.shift),a=o;return o.cmp(this.m)>=0?a=o.isub(this.m):o.cmpn(0)<0&&(a=o.iadd(this.m)),a._forceRed(this)},O.prototype.invm=function(e){return this.imod(e._invmp(this.m).mul(this.r2))._forceRed(this)}}(e=n.nmd(e),this)},9420:function(e,t){"use strict";function n(e){switch(typeof e){case"function":case"object":return null==e?"null":Array.isArray(e)?"array":typeof e;case"string":return JSON.stringify(e);default:return String(e)}}function r(e,t){return function(n){return null!=n?e(n):"function"==typeof t?t():t}}function o(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return function(e){for(var r=0;r<t.length;++r)if(e===t[r])return e;var o="Expected ";1!==t.length&&(o+="one of: ");for(var i=0;i<t.length;++i)i>0&&(o+=" | "),o+=JSON.stringify(t[i]);throw o+=", got "+n(e),new TypeError(o)}}function i(e){if("string"!=typeof e)throw new TypeError("Expected a string, got "+n(e));return e}Object.defineProperty(t,"__esModule",{value:!0});var a=o(null),s=o(void 0);var c=r(a);function u(e,t,n){return e instanceof Error&&(null==e.insertStepAt&&(e.message+=" at ",e.insertStepAt=e.message.length),e.message=e.message.slice(0,e.insertStepAt)+t+e.message.slice(e.insertStepAt),e.insertStepAt+=n),e}function l(e){if("function"==typeof e)return function(t){if("object"!=typeof t||null==t)throw new TypeError("Expected an object, got "+n(t));for(var r={},o=Object.keys(t),i=0;i<o.length;++i){var a=o[i];if("__proto__"!==a)try{r[a]=e(t[a])}catch(s){throw u(s,"["+JSON.stringify(a)+"]",0)}}return r};var t=Object.keys(e);function r(r){return function(o){if("object"!=typeof o||null==o)throw new TypeError("Expected an object, got "+n(o));var i,a={};if(r){var s=Object.keys(o);for(i=0;i<s.length;++i){var c=s[i];"__proto__"!==c&&(a[c]=o[c])}}for(i=0;i<t.length;++i){var l=t[i];try{a[l]=e[l](o[l])}catch(d){throw u(d,"."+l,0)}}return a}}var o=r(!1);return o.shape=e,o.withRest=r(!0),o}var d=l;function f(e,t){return function(n){return p[h]>0?t(n):e(n)}}var p="object"==typeof globalThis&&null!=globalThis?globalThis:JSON,h="function"==typeof Symbol?Symbol.for("uncleaning"):"uncleaning",y=f(function(e){if("string"!=typeof e&&!(e instanceof Date))throw new TypeError("Expected a date string, got "+n(e));var t=new Date(e);if(null==t.toJSON())throw new TypeError("Invalid date format, got "+n(e));return t},function(e){return e.toISOString()});t.asArray=function(e){return function(t){if(!Array.isArray(t))throw new TypeError("Expected an array, got "+n(t));for(var r=[],o=0;o<t.length;++o)try{r[o]=e(t[o])}catch(i){throw u(i,"["+o+"]",0)}return r}},t.asBoolean=function(e){if("boolean"!=typeof e)throw new TypeError("Expected a boolean, got "+n(e));return e},t.asCodec=f,t.asDate=y,t.asEither=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return function(e){for(var n=0;n<t.length;n++)try{return t[n](e)}catch(r){if(n+1>=t.length)throw r}}},t.asJSON=function(e){return f(function(t){var n=JSON.parse(i(t));try{return e(n)}catch(r){throw u(r,"JSON.parse()",11)}},function(t){return JSON.stringify(e(t))})},t.asMap=d,t.asMaybe=function(e,t){return function(n){try{return e(n)}catch(r){return"function"==typeof t?t():t}}},t.asNone=c,t.asNull=a,t.asNumber=function(e){if("number"!=typeof e)throw new TypeError("Expected a number, got "+n(e));return e},t.asObject=l,t.asOptional=r,t.asString=i,t.asTuple=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return function(e){if(!Array.isArray(e))throw new TypeError("Expected an array, got "+n(e));for(var r=[],o=0;o<t.length;++o)try{r[o]=t[o](e[o])}catch(i){throw u(i,"["+o+"]")}return r}},t.asUndefined=s,t.asUnknown=function(e){return e},t.asValue=o,t.uncleaner=function(e){return function(t){null==p[h]&&Object.defineProperty(p,h,{value:0,writable:!0});try{return++p[h],e(t)}finally{--p[h]}}}},9495:function(e,t){"use strict";function n(e,t,n,r,o,i,a){try{var s=e[i](a),c=s.value}catch(u){return void n(u)}s.done?t(c):Promise.resolve(c).then(r,o)}function r(e){return function(){var t=this,r=arguments;return new Promise(function(o,i){var a=e.apply(t,r);function s(e){n(a,o,i,s,c,"next",e)}function c(e){n(a,o,i,s,c,"throw",e)}s(void 0)})}}function o(){return o=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},o.apply(this,arguments)}function i(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function a(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return i(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?i(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}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 s=function(e){for(var t=encodeURI(e),n=new Uint8Array(t.length),r=0,o=0;o<t.length;++o){var i=t.charCodeAt(o);37===i?(n[r++]=parseInt(t.slice(o+1,o+3),16),o+=2):n[r++]=i}return n.subarray(0,r)},c=function(e){for(var t="",n=0;n<e.length;++n){var r=e[n];t+="%"+(r>>4).toString(16)+(15&r).toString(16)}return decodeURIComponent(t)};function u(e){var t=e.body,n=void 0===t?"":t,o=e.headers,i=void 0===o?{}:o,a=e.status,u=void 0===a?200:a,d=Promise.resolve(n),f={headers:l(i),ok:u>=200&&u<300,status:u,arrayBuffer:function(){return r(function*(){return yield d.then(function(e){return"string"==typeof e?s(e).buffer:e})})()},json:function(){return r(function*(){return yield f.text().then(function(e){return JSON.parse(e)})})()},text:function(){return r(function*(){return yield d.then(function(e){return"string"==typeof e?e:c(new Uint8Array(e))})})()}};return f}function l(e){var t={forEach:function(t,n){for(var r=0,o=Object.keys(e);r<o.length;r++){var i=o[r];t.call(n,e[i],i)}},get:function(n){return t.has(n)?e[n]:null},has:function(t){return Object.prototype.hasOwnProperty.call(e,t)}};return t}t.zf=function(e){return function(){var t=r(function*(t,n){void 0===n&&(n={});var r=n,i=r.body,a=void 0===i?"":i,c=r.method,l=void 0===c?"GET":c,d=r.headers,f=void 0===d?{}:d,p=new URL(t),h=p.host,y={method:l,path:p.pathname+p.search,version:"HTTP/1.1",headers:o({},f,{host:h}),body:"string"==typeof a?s(a):new Uint8Array(a)};return u(yield e(y))});return function(e,n){return t.apply(this,arguments)}}()},t.WX=u,t.Ju=function(e){for(var t={},n=0,r=Object.keys(e);n<r.length;n++){var o=r[n];t[o.toUpperCase()]=e[o]}null==t.OPTIONS&&(t.OPTIONS=function(){return{status:204,headers:i}});var i={"content-length":"0",allow:Object.keys(t).join(", ")};return function(e){var n=t[e.method];return null!=n?n(e):{status:405,headers:i}}},t.bI=function(e,t){void 0===t&&(t=function(){return{status:404}});for(var n=[],r=0,o=Object.keys(e);r<o.length;r++){var i=o[r];n.push({regexp:new RegExp("^"+i+"$"),server:e[i]})}return function(e){for(var r,o=a(n);!(r=o()).done;){var i=r.value,s=i.regexp,c=i.server;if(s.test(e.path))return c(e)}return t(e)}},t.gx=function(e){return function(){var t=r(function*(t){var n=yield e(t),r=n.headers;return o({},n,{headers:o({},void 0===r?{}:r,{"Access-Control-Allow-Origin":"*","Access-Control-Allow-Headers":"Accept, Authorization, Content-Type","Access-Control-Allow-Methods":"DELETE, GET, OPTIONS, POST, PUT"})})});return function(e){return t.apply(this,arguments)}}()}},9939:function(e,t,n){"use strict";var r=n(9211);function o(e){throw new Error("makeNodeDisklet is not available on this platform")}function i(){throw new Error("makeReactNativeDisklet is not available on this platform")}function a(e,t,n,r,o,i,a){try{var s=e[i](a),c=s.value}catch(u){return void n(u)}s.done?t(c):Promise.resolve(c).then(r,o)}function s(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function s(e){a(i,r,o,s,c,"next",e)}function c(e){a(i,r,o,s,c,"throw",e)}s(void 0)})}}function c(){return c=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},c.apply(this,arguments)}function u(e){if(/^\//.test(e))throw new Error("Absolute paths are not supported");for(var t=e.split("/"),n=0,r=0;n<t.length;){var o=t[n++];if(".."===o?r--:"."!==o&&""!==o&&(t[r++]=o),r<0)throw new Error("Path would escape folder")}return t.slice(0,r).join("/")}function l(e){return""===e?e:e+"/"}function d(e){for(var t=[],n=0;n<e.length;++n){var r=e.key(n);null!=r&&t.push(r)}return t}function f(e,t){void 0===e&&(e=window.localStorage),void 0===t&&(t={});var n=null!=t.prefix?l(t.prefix):"/";return{delete:function(t){var r=u(t);null!=e.getItem(n+r)&&e.removeItem(n+r);for(var o=l(r),i=0,a=d(e);i<a.length;i++){var s=a[i];0===s.indexOf(n+o)&&e.removeItem(s)}return Promise.resolve()},getData:function(e){return this.getText(e).then(function(e){return r.base64.parse(e)})},getText:function(t){var r=u(t),o=e.getItem(n+r);return null==o?Promise.reject(new Error('Cannot load "'+r+'"')):Promise.resolve(o)},list:function(t){return s(function*(){void 0===t&&(t="");var r=u(t),o={};null!=e.getItem(n+r)&&(o[r]="file");for(var i=l(r),a=0,s=d(e);a<s.length;a++){var c=s[a];if(0===c.indexOf(n+i)){var f=c.indexOf("/",n.length+i.length);f<0?o[c.slice(n.length)]="file":o[c.slice(n.length,f)]="folder"}}return o})()},setData:function(e,t){return this.setText(e,r.base64.stringify(t))},setText:function(t,r){return"string"!=typeof r?Promise.reject(new TypeError("setText expects a string")):(e.setItem(n+u(t),r),Promise.resolve())}}}function p(e){return void 0===e&&(e={}),{delete:function(t){var n=u(t);null!=e["/"+n]&&delete e["/"+n];for(var r=l(n),o=0,i=Object.keys(e);o<i.length;o++){var a=i[o];0===a.indexOf("/"+r)&&delete e[a]}return Promise.resolve()},getData:function(t){var n=u(t),r=e["/"+n];return null==r?Promise.reject(new Error('Cannot load "'+n+'"')):"string"==typeof r?Promise.reject(new Error('"'+n+'" is a text file.')):Promise.resolve(r)},getText:function(t){var n=u(t),r=e["/"+n];return null==r?Promise.reject(new Error('Cannot load "'+n+'"')):"string"!=typeof r?Promise.reject(new Error('"'+n+'" is a binary file.')):Promise.resolve(r)},list:function(t){return s(function*(){void 0===t&&(t="");var n=u(t),r={};null!=e["/"+n]&&(r[n]="file");for(var o=l(n),i=0,a=Object.keys(e);i<a.length;i++){var s=a[i];if(0===s.indexOf("/"+o)){var c=s.indexOf("/",1+o.length);c<0?r[s.slice(1)]="file":r[s.slice(1,c)]="folder"}}return r})()},setData:function(t,n){var r=n,o=Uint8Array.from(r);return e["/"+u(t)]=o,Promise.resolve()},setText:function(t,n){return"string"!=typeof n?Promise.reject(new TypeError("setText expects a string")):(e["/"+u(t)]=n,Promise.resolve())}}}var h=function(){function e(e,t){this._disklet=e,this._path=t}var t=e.prototype;return t.delete=function(){return this._disklet.delete(this._path)},t.getData=function(){return this._disklet.getData(this._path)},t.getText=function(){return this._disklet.getText(this._path)},t.setData=function(e){return this._disklet.setData(this._path,e)},t.setText=function(e){return this._disklet.setText(this._path,e)},e}(),y=function(){function e(e,t){this._disklet=e,this._path=t}var t=e.prototype;return t.delete=function(){return this._disklet.delete(this._path)},t.file=function(e){return new h(this._disklet,this._path+"/"+e)},t.folder=function(t){return new e(this._disklet,this._path+"/"+t)},t.listFiles=function(){return this._disklet.list(this._path).then(function(e){return Object.keys(e).filter(function(t){return"file"===e[t]}).map(function(e){return e.replace(/^.*\//,"")})})},t.listFolders=function(){return this._disklet.list(this._path).then(function(e){return Object.keys(e).filter(function(t){return"folder"===e[t]}).map(function(e){return e.replace(/^.*\//,"")})})},e}();function b(e){return new y(e,".")}function g(e,t){for(var n=0,r=0;n<t.length;){var o=t[n++];if(".."===o?r--:"."!==o&&""!==o&&(t[r++]=o),r<0)throw new Error("Path would escape folder")}for(n=0;n<r;++n)e=e.folder(t[n]);return e}function w(e,t){return e.listFiles().then(function(n){return Promise.all(n.map(function(n){return t(e.file(n),n,e)}))})}function v(e,t){return e.listFolders().then(function(n){return Promise.all(n.map(function(n){return t(e.folder(n),n,e)}))})}function m(e,t){console.log(t+' "'+e+'"')}function I(e,t,n){var r=n.callback,o=void 0===r?m:r,i=n.verbose;(void 0!==i&&i||/set|delete/.test(t))&&o(e,t)}var E=function(){function e(e,t,n){this._file=e,this._path=t,this._opts=n}var t=e.prototype;return t.delete=function(){return I(this._path,"delete file",this._opts),this._file.delete()},t.getData=function(){return I(this._path,"get data",this._opts),this._file.getData()},t.getText=function(){return I(this._path,"get text",this._opts),this._file.getText()},t.setData=function(e){return I(this._path,"set data",this._opts),this._file.setData(e)},t.setText=function(e){return I(this._path,"set text",this._opts),this._file.setText(e)},t.getPath=function(){return this._path},e}(),S=function(){function e(e,t,n){this._folder=e,this._path=t,this._opts=n}var t=e.prototype;return t.delete=function(){return I(this._path,"delete folder",this._opts),this._folder.delete()},t.file=function(e){return new E(this._folder.file(e),this._path+e,this._opts)},t.folder=function(t){return new e(this._folder.folder(t),this._path+t+"/",this._opts)},t.listFiles=function(){return I(this._path,"list files",this._opts),this._folder.listFiles()},t.listFolders=function(){return I(this._path,"list folders",this._opts),this._folder.listFolders()},e}();function O(e,t){var n={},r=[];return e.forEach(function(e){/\._x_$/.test(e)?n[e]=!0:(n[e+"._x_"]=!0,r.push(e))}),t.forEach(function(e){n[e+"._x_"]||r.push(e)}),r}var A=function(){function e(e,t,n){this._master=e,this._fallback=t,this._whiteout=n}var t=e.prototype;return t.delete=function(){return Promise.all([this._whiteout.setData([]),this._master.delete().catch(function(e){return null})])},t.getData=function(){var e=this;return this._master.getData().catch(function(t){return e._whiteout.getData().then(function(e){throw new Error("File has been deleted")},function(t){return e._fallback.getData()})})},t.getText=function(){var e=this;return this._master.getText().catch(function(t){return e._whiteout.getData().then(function(e){throw new Error("File has been deleted")},function(t){return e._fallback.getText()})})},t.setData=function(e){return this._master.setData(e)},t.setText=function(e){return this._master.setText(e)},t.getPath=function(){throw new Error("Cannot call getPath on a Union Folder")},e}(),T=function(){function e(e,t){this._master=e,this._fallback=t}var t=e.prototype;return t.delete=function(){return Promise.all([w(this,function(e){return e.delete()}),v(this,function(e){return e.delete()})]).then(function(){})},t.file=function(e){return new A(this._master.file(e),this._fallback.file(e),this._master.file(e+"._x_"))},t.folder=function(t){return new e(this._master.folder(t),this._fallback.folder(t))},t.listFiles=function(){return Promise.all([this._master.listFiles(),this._fallback.listFiles()]).then(function(e){return O(e[0],e[1])})},t.listFolders=function(){return Promise.all([this._master.listFolders(),this._fallback.listFolders()]).then(function(e){return O(e[0],e[1])})},e}();function _(e,t){var n=l(u(t));return{delete:function(t){return e.delete(n+t)},getData:function(t){return e.getData(n+t)},getText:function(t){return e.getText(n+t)},list:function(t){return void 0===t&&(t="."),e.list(n+t).then(function(e){var t={};for(var r in e)t[r.replace(n,"")]=e[r];return t})},setData:function(t,r){return e.setData(n+t,r)},setText:function(t,r){return e.setText(n+t,r)}}}t.WR=function(e){return Object.keys(e).filter(function(t){return"file"===e[t]})},t.a8=function(e){return Object.keys(e).filter(function(t){return"folder"===e[t]})},t.cQ=p,t.mi=function(e,t){return{delete:function(n){return Promise.all([e.delete(n),t.delete(n)])},getData:function(n){return e.getData(n).catch(function(e){return t.getData(n)})},getText:function(n){return e.getText(n).catch(function(e){return t.getText(n)})},list:function(n){return Promise.all([e.list(n),t.list(n)]).then(function(e){var t=e[0];return c(e[1],t)})},setData:function(t,n){return e.setData(t,n)},setText:function(t,n){return e.setText(t,n)}}},t.my=_},9983:function(e){"use strict";!function(){var t=2147483647;function n(e){var t=[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],n=1779033703,r=3144134277,o=1013904242,i=2773480762,a=1359893119,s=2600822924,c=528734635,u=1541459225,l=new Array(64);function d(e){for(var d=0,f=e.length;f>=64;){var p,h,y,b,g,w=n,v=r,m=o,I=i,E=a,S=s,O=c,A=u;for(h=0;h<16;h++)y=d+4*h,l[h]=(255&e[y])<<24|(255&e[y+1])<<16|(255&e[y+2])<<8|255&e[y+3];for(h=16;h<64;h++)b=((p=l[h-2])>>>17|p<<15)^(p>>>19|p<<13)^p>>>10,g=((p=l[h-15])>>>7|p<<25)^(p>>>18|p<<14)^p>>>3,l[h]=(b+l[h-7]|0)+(g+l[h-16]|0)|0;for(h=0;h<64;h++)b=(((E>>>6|E<<26)^(E>>>11|E<<21)^(E>>>25|E<<7))+(E&S^~E&O)|0)+(A+(t[h]+l[h]|0)|0)|0,g=((w>>>2|w<<30)^(w>>>13|w<<19)^(w>>>22|w<<10))+(w&v^w&m^v&m)|0,A=O,O=S,S=E,E=I+b|0,I=m,m=v,v=w,w=b+g|0;n=n+w|0,r=r+v|0,o=o+m|0,i=i+I|0,a=a+E|0,s=s+S|0,c=c+O|0,u=u+A|0,d+=64,f-=64}}d(e);var f,p=e.length%64,h=e.length/536870912|0,y=e.length<<3,b=p<56?56:120,g=e.slice(e.length-p,e.length);for(g.push(128),f=p+1;f<b;f++)g.push(0);return g.push(h>>>24&255),g.push(h>>>16&255),g.push(h>>>8&255),g.push(h>>>0&255),g.push(y>>>24&255),g.push(y>>>16&255),g.push(y>>>8&255),g.push(y>>>0&255),d(g),[n>>>24&255,n>>>16&255,n>>>8&255,n>>>0&255,r>>>24&255,r>>>16&255,r>>>8&255,r>>>0&255,o>>>24&255,o>>>16&255,o>>>8&255,o>>>0&255,i>>>24&255,i>>>16&255,i>>>8&255,i>>>0&255,a>>>24&255,a>>>16&255,a>>>8&255,a>>>0&255,s>>>24&255,s>>>16&255,s>>>8&255,s>>>0&255,c>>>24&255,c>>>16&255,c>>>8&255,c>>>0&255,u>>>24&255,u>>>16&255,u>>>8&255,u>>>0&255]}function r(e,t,r){var o;e=e.length<=64?e:n(e);var i=64+t.length+4,a=new Array(i),s=new Array(64),c=[];for(o=0;o<64;o++)a[o]=54;for(o=0;o<e.length;o++)a[o]^=e[o];for(o=0;o<t.length;o++)a[64+o]=t[o];for(o=i-4;o<i;o++)a[o]=0;for(o=0;o<64;o++)s[o]=92;for(o=0;o<e.length;o++)s[o]^=e[o];function u(){for(var e=i-1;e>=i-4;e--){if(a[e]++,a[e]<=255)return;a[e]=0}}for(;r>=32;)u(),c=c.concat(n(s.concat(n(a)))),r-=32;return r>0&&(u(),c=c.concat(n(s.concat(n(a))).slice(0,r))),c}function o(e,t,n,r,o){var i;for(c(e,16*(2*n-1),o,0,16),i=0;i<2*n;i++)s(e,16*i,o,16),a(o,r),c(o,0,e,t+16*i,16);for(i=0;i<n;i++)c(e,t+2*i*16,e,16*i,16);for(i=0;i<n;i++)c(e,t+16*(2*i+1),e,16*(i+n),16)}function i(e,t){return e<<t|e>>>32-t}function a(e,t){c(e,0,t,0,16);for(var n=8;n>0;n-=2)t[4]^=i(t[0]+t[12],7),t[8]^=i(t[4]+t[0],9),t[12]^=i(t[8]+t[4],13),t[0]^=i(t[12]+t[8],18),t[9]^=i(t[5]+t[1],7),t[13]^=i(t[9]+t[5],9),t[1]^=i(t[13]+t[9],13),t[5]^=i(t[1]+t[13],18),t[14]^=i(t[10]+t[6],7),t[2]^=i(t[14]+t[10],9),t[6]^=i(t[2]+t[14],13),t[10]^=i(t[6]+t[2],18),t[3]^=i(t[15]+t[11],7),t[7]^=i(t[3]+t[15],9),t[11]^=i(t[7]+t[3],13),t[15]^=i(t[11]+t[7],18),t[1]^=i(t[0]+t[3],7),t[2]^=i(t[1]+t[0],9),t[3]^=i(t[2]+t[1],13),t[0]^=i(t[3]+t[2],18),t[6]^=i(t[5]+t[4],7),t[7]^=i(t[6]+t[5],9),t[4]^=i(t[7]+t[6],13),t[5]^=i(t[4]+t[7],18),t[11]^=i(t[10]+t[9],7),t[8]^=i(t[11]+t[10],9),t[9]^=i(t[8]+t[11],13),t[10]^=i(t[9]+t[8],18),t[12]^=i(t[15]+t[14],7),t[13]^=i(t[12]+t[15],9),t[14]^=i(t[13]+t[12],13),t[15]^=i(t[14]+t[13],18);for(n=0;n<16;++n)e[n]+=t[n]}function s(e,t,n,r){for(var o=0;o<r;o++)n[o]^=e[t+o]}function c(e,t,n,r,o){for(;o--;)n[r++]=e[t++]}function u(e){if(!e||"number"!=typeof e.length)return!1;for(var t=0;t<e.length;t++){if("number"!=typeof e[t])return!1;var n=parseInt(e[t]);if(n!=e[t]||n<0||n>=256)return!1}return!0}function l(e,t){var n=parseInt(e);if(e!=n)throw new Error("invalid "+t);return n}e.exports=function(e,n,i,a,d,f,p){if(!p)throw new Error("missing callback");if(i=l(i,"N"),a=l(a,"r"),d=l(d,"p"),f=l(f,"dkLen"),0===i||i&i-1)throw new Error("N must be power of 2");if(i>t/128/a)throw new Error("N too large");if(a>t/128/d)throw new Error("r too large");if(!u(e))throw new Error("password must be an array or buffer");if(!u(n))throw new Error("salt must be an array or buffer");for(var h=r(e,n,128*d*a),y=new Uint32Array(32*d*a),b=0;b<y.length;b++){var g=4*b;y[b]=(255&h[g+3])<<24|(255&h[g+2])<<16|(255&h[g+1])<<8|255&h[g+0]}var w,v,m=new Uint32Array(64*a),I=new Uint32Array(32*a*i),E=32*a,S=new Uint32Array(16),O=new Uint32Array(16),A=d*i*2,T=0,_=null,k=!1,x=0,P=0,M=parseInt(1e3/a),C="undefined"!=typeof setImmediate?setImmediate:setTimeout,N=function(){if(k)return p(new Error("cancelled"),T/A);switch(x){case 0:c(y,v=32*P*a,m,0,E),x=1,w=0;case 1:(n=i-w)>M&&(n=M);for(var t=0;t<n;t++)c(m,0,I,(w+t)*E,E),o(m,E,a,S,O);if(w+=n,T+=n,(u=parseInt(1e3*T/A))!==_){if(k=p(null,T/A))break;_=u}if(w<i)break;w=0,x=2;case 2:var n,u;for((n=i-w)>M&&(n=M),t=0;t<n;t++){var l=m[16*(2*a-1)]&i-1;s(I,l*E,m,E),o(m,E,a,S,O)}if(w+=n,T+=n,(u=parseInt(1e3*T/A))!==_){if(k=p(null,T/A))break;_=u}if(w<i)break;if(c(m,0,y,v,E),++P<d){x=0;break}for(h=[],t=0;t<y.length;t++)h.push(255&y[t]),h.push(y[t]>>8&255),h.push(y[t]>>16&255),h.push(y[t]>>24&255);var b=r(e,h,f);return p(null,1,b)}C(N)};N()}}()}},t={};function n(r){var o=t[r];if(void 0!==o)return o.exports;var i=t[r]={id:r,loaded:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.loaded=!0,i.exports}n.m=e,n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,{a:t}),t},n.d=function(e,t){for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.nmd=function(e){return e.paths=[],e.children||(e.children=[]),e},function(){var e;n.g.importScripts&&(e=n.g.location+"");var t=n.g.document;if(!e&&t&&(t.currentScript&&"SCRIPT"===t.currentScript.tagName.toUpperCase()&&(e=t.currentScript.src),!e)){var r=t.getElementsByTagName("script");if(r.length)for(var o=r.length-1;o>-1&&(!e||!/^http(s?):/.test(e));)e=r[o--].src}if(!e)throw new Error("Automatic publicPath is not supported in this browser");e=e.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),n.p=e}(),n.b="undefined"!=typeof document&&document.baseURI||self.location.href,function(){"use strict";function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e(t)}function t(t){var n=function(t,n){if("object"!=e(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var o=r.call(t,n||"default");if("object"!=e(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===n?String:Number)(t)}(t,"string");return"symbol"==e(n)?n:n+""}function r(e,n,r){return(n=t(n))in e?Object.defineProperty(e,n,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[n]=r,e}var o=n(7952),i=n.n(o),a=n(2723),s=n.n(a);function c(e,t,n){var r;if(void 0===n&&(n={}),!t.codes){t.codes={};for(var o=0;o<t.chars.length;++o)t.codes[t.chars[o]]=o}if(!n.loose&&e.length*t.bits&7)throw new SyntaxError("Invalid padding");for(var i=e.length;"="===e[i-1];)if(--i,!(n.loose||(e.length-i)*t.bits&7))throw new SyntaxError("Invalid padding");for(var a=new(null!=(r=n.out)?r:Uint8Array)(i*t.bits/8|0),s=0,c=0,u=0,l=0;l<i;++l){var d=t.codes[e[l]];if(void 0===d)throw new SyntaxError("Invalid character "+e[l]);c=c<<t.bits|d,(s+=t.bits)>=8&&(s-=8,a[u++]=255&c>>s)}if(s>=t.bits||255&c<<8-s)throw new SyntaxError("Unexpected end of data");return a}function u(e,t,n){void 0===n&&(n={});for(var r=n.pad,o=void 0===r||r,i=(1<<t.bits)-1,a="",s=0,c=0,u=0;u<e.length;++u)for(c=c<<8|255&e[u],s+=8;s>t.bits;)s-=t.bits,a+=t.chars[i&c>>s];if(s&&(a+=t.chars[i&c<<t.bits-s]),o)for(;a.length*t.bits&7;)a+="=";return a}var l={chars:"0123456789ABCDEF",bits:4},d={chars:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bits:5},f={chars:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bits:6},p=function(e,t){return c(e.toUpperCase(),l,t)},h=function(e,t){return u(e,l,t)},y=function(e,t){return void 0===t&&(t={}),c(t.loose?e.toUpperCase().replace(/0/g,"O").replace(/1/g,"L").replace(/8/g,"B"):e,d,t)},b=function(e,t){return u(e,d,t)},g=function(e,t){return c(e,f,t)},w=function(e,t){return u(e,f,t)},v=n(9495);const m=v.zf,I=v.WX,E=v.Ju,S=v.bI;v.gx;function O(){return O=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},O.apply(null,arguments)}var A="_yaob",T=1,_={};function k(e,t){Object.prototype.hasOwnProperty.call(e,A)?O(e[A],t):Object.defineProperty(e,A,{value:t})}function x(e){var t=e.prototype;if(!Object.prototype.hasOwnProperty.call(t,A)){k(t,{})}return e}function P(e){Object.prototype.hasOwnProperty.call(e,A)&&null!=e[A].localId||k(e,{localId:T++,bridges:[],listeners:{},watchers:{}});return e}function M(e){if(null==e[A])throw new TypeError("Not a bridgeable object");return P(e),e[A]}function C(e,t){null==t?t="":t+=".";for(var n=0,r=Object.getOwnPropertyNames(e);n<r.length;n++){var o=r[n],i=t+o;if(null!=_[i])throw new Error("A shared value named "+i+" already exists");_[i]=e[o],k(e[o],{shareId:i})}}function N(e,t){try{var n=R(e,t),r=L(e,n,t);return""!==n?{map:n,raw:r}:{raw:r}}catch(t){return j(e,t)}}function j(e,t){var n=R(e,t);return{map:n,raw:L(e,n,t),throw:!0}}function D(e,t,n,r){void 0===r&&(r=!1);var o=t.map,i=t.raw,a=null!=o?B(e,o,i,n,r):i;if(t.throw)throw a;return a}function R(e,t){switch(typeof t){case"boolean":case"number":case"string":return"";case"object":if(null===t)return"";if(t instanceof Date)return"d";if(t instanceof Error)return"e";if(t instanceof ArrayBuffer)return"ab";if(t instanceof Uint8Array)return"u8";if(t instanceof Map)return"M";if(t instanceof Set)return"S";if(null!=t[A])return null!=t[A].shareId?"s":"o";if(Array.isArray(t)){for(var n="",r=0;r<t.length;++r){var o=R(e,t[r]);if(""!==o&&""===n){n=[];for(var i=0;i<r;++i)n[i]=""}""!==n&&(n[r]=o)}return n}var a="";for(var s in t){var c=R(e,t[s]);""!==c&&(""===a&&(a={}),a[s]=c)}return a;case"undefined":return"u";case"function":return null!=t[A]&&null!=t[A].shareId?"s":"?";default:return"?"}}function L(e,t,n){switch(t){case"":return n;case"?":return typeof n;case"d":return n.toISOString();case"e":return function(e,t){var n=O({message:t.message,stack:t.stack},t),r=null;return t instanceof EvalError?r="EvalError":t instanceof RangeError?r="RangeError":t instanceof ReferenceError?r="ReferenceError":t instanceof SyntaxError?r="SyntaxError":t instanceof TypeError?r="TypeError":t instanceof URIError&&(r="URIError"),O({base:r},N(e,n))}(e,n);case"o":return e.getPackedId(n);case"s":return n[A].shareId;case"u":return null;case"ab":return w(new Uint8Array(n));case"u8":return w(n);case"M":return N(e,Array.from(n.entries()));case"S":return N(e,Array.from(n.values()));default:if(Array.isArray(t)){for(var r=[],o=0;o<t.length;++o)r[o]=L(e,t[o],n[o]);return r}var i={};for(var a in n)i[a]=a in t?L(e,t[a],n[a]):n[a];return i}}function B(e,t,n,r,o){switch(t){case"":return n;case"?":throw new TypeError("Unsupported value of type "+("string"==typeof n?n:"?")+" at "+r);case"d":return new Date(n);case"e":if("object"!=typeof n||null===n)throw new TypeError("Expecting an error description at "+r);return function(e,t,n){var r={EvalError:EvalError,RangeError:RangeError,ReferenceError:ReferenceError,SyntaxError:SyntaxError,TypeError:TypeError,URIError:URIError},o=new(null!=t.base&&r[t.base]||Error),i=D(e,t,n,!0);for(var a in i)o[a]=i[a];return o}(e,n,r);case"o":if(null===n)throw new TypeError("Closed bridge object at "+r);if("number"!=typeof n)throw new TypeError("Expecting a packedId at "+r);var i=e.getObject(-n);if(null==i)throw new RangeError("Invalid packedId "+n+" at "+r);return i;case"s":if("string"!=typeof n)throw new TypeError("Expecting a shareId at "+r);var a=_[n];if(null==a)throw new RangeError("Invalid shareId '"+n+"' at "+r);return a;case"u":return;case"ab":if("string"!=typeof n)throw new TypeError("Expecting a base64 string at "+r);return g(n).buffer;case"u8":if("string"!=typeof n)throw new TypeError("Expecting a base64 string at "+r);return g(n);case"M":if("object"!=typeof n||null===n)throw new TypeError("Expecting an Map description at "+r);return new Map(D(e,n,r));case"S":if("object"!=typeof n||null===n)throw new TypeError("Expecting an Set description at "+r);return new Set(D(e,n,r));default:if("object"!=typeof t||null===t)throw new TypeError("Invalid type information "+t+" at "+r);if("object"!=typeof n||null===n)throw new TypeError("Expecting an array or object at "+r);if(Array.isArray(t)){if(!Array.isArray(n))throw new TypeError("Expecting an array at "+r);for(var s=[],c=0;c<t.length;++c)!0===o&&"?"===t[c]||(s[c]=B(e,t[c],n[c],r+"["+c+"]",o));return s}var u={};for(var l in n)!0===o&&"?"===t[l]||(u[l]=l in t?B(e,t[l],n[l],r+"."+l,o):n[l]);return u}}var K={};function U(e,t,n){var r=M(e),o=r.closed,i=r.listeners;return o?function(){}:(null==i[t]?i[t]=[n]:i[t].push(n),function(){i[t]=i[t].filter(function(e){return e!==n})})}function F(e){var t=M(e),n=t.listeners.close;if(null!=n)for(var r=0;r<n.length;r++){z(e,n[r],void 0,!0)}t.closed=!0;for(var o=0,i=t.bridges;o<i.length;o++){i[o].emitClose(t.localId)}t.bridges=[],t.listeners={},t.watchers={}}function W(e,t,n){var r=M(e);if(r.closed)throw new Error("Cannot emit event on closed object");for(var o=0,i=r.bridges;o<i.length;o++){i[o].emitEvent(r.localId,t,n)}var a=r.listeners[t];if(null!=a)for(var s=0;s<a.length;s++){z(e,a[s],n,"error"!==t)}}function G(e,t){var n=M(e);if(n.closed)throw new Error("Cannot update closed object");for(var r=0,o=n.bridges;r<o.length;r++){o[r].markDirty(n.localId,t)}for(var i in null!=t&&null!=n.watchers[t]&&(n.watchers[t].data=K),n.watchers){var a=n.watchers[i];try{var s=e[i];if(s!==a.data){a.data=s;for(var c=0,u=a.fs;c<u.length;c++){z(e,u[c],a.data,!0)}}}catch(l){}}}function z(e,t,n,r){try{var o=t(n);r&&null!=o&&"function"==typeof o.then&&o.then(void 0,function(t){return W(e,"error",t)})}catch(i){r&&W(e,"error",i)}}var q={};function $(e,t,n){var r=!1,o={};for(var i in n)try{var a=t[i];a!==n[i]&&(r=!0,o[i]=N(e,a),n[i]=a)}catch(s){o[i]=j(e,s),n[i]=q}return{dirty:r,props:o}}function H(e,t){var n,r={},o=(n=t.localId,{localId:T++,bridges:[],listeners:{},watchers:{},remoteId:n,errors:{},props:{}});for(var i in r[A]={value:o},t.props)r[i]={enumerable:e.hideProperties.indexOf(i)<0,get:V(o,i)};for(var a=0,s=t.methods;a<s.length;a++){var c=s[a];r[c]={value:J(e,o,c)}}return Object.create(Object.prototype,r)}function Y(e,t,n){var r=t[A];for(var o in n)try{r.props[o]=D(e,n[o],o),r.errors[o]=!1}catch(i){r.props[o]=i,r.errors[o]=!0}}function V(e,t){return function(){if(e.errors[t])throw e.props[t];return e.props[t]}}function J(e,t,n){return function(){if(t.closed)return Promise.reject(new TypeError("Cannot call method '"+n+"' of closed proxy"));for(var r=arguments.length,o=new Array(r),i=0;i<r;i++)o[i]=arguments[i];return e.emitCall(t.remoteId,n,o)}}var X=function(){function e(e){var t=e.hideProperties,n=void 0===t?[]:t,r=e.sendMessage,o=e.throttleMs,i=void 0===o?0:o;this.hideProperties=n,this.sendMessage=r,this.throttleMs=i,this.proxies={},this.objects={},this.caches={},this.nextCallId=0,this.pendingCalls={},this.dirty={},this.message={},this.lastUpdate=0,this.sendPending=!1}var t=e.prototype;return t.close=function(e){for(var t in this.pendingCalls){this.pendingCalls[Number(t)].reject(e)}for(var n in this.proxies)F(this.proxies[Number(n)]);this.closed=!0},t.getObject=function(e){return e<0?this.proxies[-e]:this.objects[e]},t.getPackedId=function(e){var t=M(e);if(t.closed)return null;if(null!=t.remoteId&&null!=this.proxies[t.remoteId])return-t.remoteId;if(null==this.objects[t.localId]){this.objects[t.localId]=e;var n=function(e,t){for(var n={},r=Object.prototype,o=t;o!==r&&null!=o;o=Object.getPrototypeOf(o))for(var i=0,a=Object.getOwnPropertyNames(o);i<a.length;i++){var s=a[i];s===A||/^_/.test(s)||"constructor"===s||(n[s]=!0)}var c={},u=[],l={};for(var d in n)try{var f=t[d];"function"!=typeof f||null!=f[A]&&null!=f[A].shareId?(c[d]=f,l[d]=N(e,f)):u.push(d)}catch(p){c[d]=q,l[d]=j(e,p)}return{cache:c,create:{localId:M(t).localId,methods:u,props:l}}}(this,e),r=n.cache,o=n.create;this.caches[t.localId]=r,t.bridges.push(this),this.emitCreate(o,e)}return t.localId},t.markDirty=function(e,t){var n=this.caches[e];null!=t&&t in n&&(n[t]=q),this.dirty[e]={cache:n,object:this.objects[e]},this.wakeup()},t.emitClose=function(e){delete this.objects[e],delete this.caches[e],null==this.message.closed&&(this.message.closed=[]),this.message.closed.push(e),this.wakeup()},t.emitCreate=function(e,t){null==this.message.created&&(this.message.created=[]),this.message.created.push(e)},t.emitCall=function(e,t,n){var r=this,o=this.nextCallId++,i=O({callId:o,remoteId:e,name:t},N(this,n));return null==this.message.calls&&(this.message.calls=[]),this.message.calls.push(i),this.wakeup(),new Promise(function(e,n){r.pendingCalls[o]={name:t,resolve:e,reject:n}})},t.emitEvent=function(e,t,n){var r=O({localId:e,name:t},N(this,n));null==this.message.events&&(this.message.events=[]),this.message.events.push(r),this.wakeup()},t.emitReturn=function(e,t,n){var r=O({callId:e},t?j(this,n):N(this,n));null==this.message.returns&&(this.message.returns=[]),this.message.returns.push(r),this.wakeup()},t.handleMessage=function(e){var t=this;if(e.created){for(var n=0,r=e.created;n<r.length;n++){var o=r[n];this.proxies[o.localId]=H(this,o)}for(var i=0,a=e.created;i<a.length;i++){var s=a[i];Y(this,this.proxies[s.localId],s.props)}}if(e.changed){for(var c=0,u=e.changed;c<u.length;c++){var l=u[c],d=l.localId,f=l.props,p=this.proxies[d];if(null==p)throw new RangeError("Invalid localId "+d);Y(this,p,f)}for(var h=0,y=e.changed;h<y.length;h++){var b=y[h];G(this.proxies[b.localId])}}if(e.events)for(var g=0,w=e.events;g<w.length;g++){var v=w[g],m=v.localId,I=v.name,E=0===m?this:this.proxies[m];if(null!=E)try{W(E,I,D(this,v,I))}catch(R){W(E,"error",R)}}if(e.calls)for(var S=function(e,n){var r=n[e],o=r.callId,i=r.remoteId,a=r.name;try{var s=t.objects[i];if(null==s)throw new TypeError("Cannot call method '"+a+"' of closed proxy (remote)");if("function"!=typeof s[a])throw new TypeError("'"+a+"' is not a function");var c=D(t,r,a+".arguments");Promise.resolve(s[a].apply(s,c)).then(function(e){return t.emitReturn(o,!1,e)},function(e){return t.emitReturn(o,!0,e)})}catch(R){t.emitReturn(o,!0,R)}},O=0,A=e.calls;O<A.length;O++)S(O,A);if(e.returns)for(var T=0,_=e.returns;T<_.length;T++){var k=_[T],x=k.callId,P=this.pendingCalls[x];if(null==P)throw new RangeError("Invalid callId "+x);try{P.resolve(D(this,k,P.name+".return"))}catch(R){P.reject(R)}finally{delete this.pendingCalls[x]}}if(e.closed)for(var M=0,C=e.closed;M<C.length;M++){var N=C[M],j=this.proxies[N];if(null==j)return;delete this.proxies[N],F(j)}},t.sendNow=function(){if(!this.closed){for(var e in this.dirty){var t=Number(e),n=this.dirty[t],r=$(this,n.object,n.cache),o=r.dirty,i=r.props;if(o){var a={localId:t,props:i};null==this.message.changed&&(this.message.changed=[]),this.message.changed.push(a)}}var s=this.message;this.dirty={},this.message={},null==s.calls&&null==s.changed&&null==s.closed&&null==s.created&&null==s.events&&null==s.returns||this.sendMessage(s)}},t.wakeup=function(){var e=this;if(!this.sendPending){this.sendPending=!0;var t=this.lastUpdate+this.throttleMs-Date.now();setTimeout(function(){e.sendPending=!1,e.lastUpdate=Date.now(),e.sendNow()},t<0?0:t)}},e}();x(X);var Z=function(){function e(e){var t=this;this._state=new X(e),this._rootPromise=new Promise(function(e){return U(t._state,"root",e)})}var t=e.prototype;return t.handleMessage=function(e){this._state.handleMessage(e)},t.getRoot=function(){return this._rootPromise},t.sendRoot=function(e){this._state.emitEvent(0,"root",e)},t.close=function(e){this._state.close(e)},e}();var Q=function(e,t){return U(this,e,t)},ee=function(e,t){return function(e,t,n){var r=M(e),o=r.closed,i=r.watchers,a=e[t];return o?function(){}:(null==i[t]?i[t]={data:a,fs:[n]}:i[t].fs.push(n),function(){i[t].fs=i[t].fs.filter(function(e){return e!==n})})}(this,e,t)};C({onMethod:Q,watchMethod:ee});var te=function(){function e(){}var t=e.prototype;return t._close=function(){F(this)},t._emit=function(e,t){return W(this,e,t)},t._update=function(e){G(this,e)},e}(),ne=te.prototype;ne.on=Q,ne.watch=ee,x(te);var re=n(9939);n(9983);class oe{getFirstWalletInfo(e){return this.allKeys.find(t=>t.type===e)}getWalletInfo(e){return this.allKeys.find(t=>t.id===e)}listWalletIds(){return this.allKeys.map(e=>e.id)}}function ie(e){const t=e.length<10,n=!/[0-9]/.test(e),r=!/[a-z]/.test(e),o=!/[A-Z]/.test(e),i=(/[0-9]/.test(e)?10:0)+(/[A-Z]/.test(e)?26:0)+(/[a-z]/.test(e)?26:0)+(/[^0-9A-Za-z]/.test(e)?30:0);return{secondsToCrack:Math.pow(i,e.length)/1e6,tooShort:t,noNumber:n,noLowerCase:r,noUpperCase:o,passed:e.length>=16||!(t||n||o||r)}}function ae(e){const t=e.toLowerCase().replace(/[ \f\r\n\t\v]+/g," ").replace(/ $/,"").replace(/^ /,"");for(let n=0;n<t.length;++n){const e=t.charCodeAt(n);if(e<32||e>126)throw new Error("Bad characters in username")}return t}function se(e){let t,n=!1;const r={next:async()=>{if(null==t&&(t=await this.$internalStreamTransactions(e)),!n){const e=await t.next();if(!e.done)return e;F(t),n=!0}return{done:!0,value:void 0}},return:async()=>(null==t||n||(F(t),n=!0),{done:!0,value:void 0}),[Symbol.asyncIterator]:()=>r};return r}function ce(e){switch(typeof e){case"function":case"object":return null==e?"null":Array.isArray(e)?"array":typeof e;case"string":return JSON.stringify(e);default:return String(e)}}function ue(e,t){return function(n){return null!=n?e(n):"function"==typeof t?t():t}}function le(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return function(e){for(var n=0;n<t.length;++n)if(e===t[n])return e;var r="Expected ";1!==t.length&&(r+="one of: ");for(var o=0;o<t.length;++o)o>0&&(r+=" | "),r+=JSON.stringify(t[o]);throw r+=", got "+ce(e),new TypeError(r)}}function de(e){if("boolean"!=typeof e)throw new TypeError("Expected a boolean, got "+ce(e));return e}function fe(e){if("number"!=typeof e)throw new TypeError("Expected a number, got "+ce(e));return e}function pe(e){if("string"!=typeof e)throw new TypeError("Expected a string, got "+ce(e));return e}C(oe.prototype,"AccountSync"),C({checkPasswordRules:ie}),C({fixUsername:ae}),C({streamTransactions:se},"CurrencyWalletSync");var he=le(null);le(void 0);function ye(e){return e}ue(he);function be(e,t,n){return e instanceof Error&&(null==e.insertStepAt&&(e.message+=" at ",e.insertStepAt=e.message.length),e.message=e.message.slice(0,e.insertStepAt)+t+e.message.slice(e.insertStepAt),e.insertStepAt+=n),e}function ge(e){return function(t){if(!Array.isArray(t))throw new TypeError("Expected an array, got "+ce(t));for(var n=[],r=0;r<t.length;++r)try{n[r]=e(t[r])}catch(o){throw be(o,"["+r+"]",0)}return n}}function we(e){if("function"==typeof e)return function(t){if("object"!=typeof t||null==t)throw new TypeError("Expected an object, got "+ce(t));for(var n={},r=Object.keys(t),o=0;o<r.length;++o){var i=r[o];if("__proto__"!==i)try{n[i]=e(t[i])}catch(a){throw be(a,"["+JSON.stringify(i)+"]",0)}}return n};var t=Object.keys(e);function n(n){return function(r){if("object"!=typeof r||null==r)throw new TypeError("Expected an object, got "+ce(r));var o,i={};if(n){var a=Object.keys(r);for(o=0;o<a.length;++o){var s=a[o];"__proto__"!==s&&(i[s]=r[s])}}for(o=0;o<t.length;++o){var c=t[o];try{i[c]=e[c](r[c])}catch(u){throw be(u,"."+c,0)}}return i}}var r=n(!1);return r.shape=e,r.withRest=n(!0),r}function ve(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return function(e){for(var n=0;n<t.length;n++)try{return t[n](e)}catch(r){if(n+1>=t.length)throw r}}}function me(e,t){return function(n){try{return e(n)}catch(r){return"function"==typeof t?t():t}}}function Ie(e,t){return function(n){return Se[Oe]>0?t(n):e(n)}}function Ee(e){return function(t){null==Se[Oe]&&Object.defineProperty(Se,Oe,{value:0,writable:!0});try{return++Se[Oe],e(t)}finally{--Se[Oe]}}}var Se="object"==typeof globalThis&&null!=globalThis?globalThis:JSON,Oe="function"==typeof Symbol?Symbol.for("uncleaning"):"uncleaning",Ae=Ie(function(e){if("string"!=typeof e&&!(e instanceof Date))throw new TypeError("Expected a date string, got "+ce(e));var t=new Date(e);if(null==t.toJSON())throw new TypeError("Invalid date format, got "+ce(e));return t},function(e){return e.toISOString()});const Te=Ie(e=>p(pe(e)),e=>h(e).toLowerCase()),_e=Ie(e=>y(pe(e),{loose:!0}),e=>b(e,{pad:!1})),ke=Ie(e=>g(pe(e)),e=>w(e)),xe=we({voucherId:pe,activates:Ae,created:Ae,ip:pe,ipDescription:pe,deviceDescription:ue(pe)}),Pe=we({encryptionType:fe,data_base64:ke,iv_hex:Te}),Me=we({created:ue(Ae),data_base64:ke,encryptionType:fe,iv_hex:Te}),Ce=we({salt_hex:Te,n:fe,r:fe,p:fe}),Ne=we({loginRequest:ue(we({appId:pe}).withRest),publicKey:ke,timeout:ue(fe)}).withRest,je=we({publicKey:ke,box:Pe}),De=ge(ke),Re=we({data:ye,challengeId:ue(pe),deviceDescription:ue(pe),otp:ue(pe),syncToken:ue(pe),voucherId:ue(pe),voucherAuth:ue(ke),loginId:ue(ke),loginAuth:ue(ke),userId:ue(ke),passwordAuth:ue(ke),pin2Id:ue(ke),pin2Auth:ue(ke),recovery2Id:ue(ke),recovery2Auth:ue(De),loginIds:ue(ge(ke)),otpResetAuth:ue(pe),did:ue(pe),l1:ue(ke),lp1:ue(ke),lpin1:ue(ke),lra1:ue(ke),recoveryAuth:ue(ke)}),Le=we({results:ue(ye),status_code:fe,message:pe}),Be=we({otpTimeout:ue(fe,604800),otpKey:_e}),Ke=we({passwordAuth:ke,passwordAuthBox:Pe,passwordAuthSnrp:Ce,passwordBox:Pe,passwordKeySnrp:Ce}),Ue=we({pin2Id:ke}),Fe=we({pin2Id:ue(ke),pin2Auth:ue(ke),pin2Box:ue(Pe),pin2KeyBox:ue(Pe),pin2TextBox:Pe}),We=we({recovery2Id:ke}),Ge=we({recovery2Id:ke,recovery2Auth:De,recovery2Box:Pe,recovery2KeyBox:Pe,question2Box:Pe}),ze=we({loginAuthBox:Pe,loginAuth:ke}),qe=we({userId:ke,userTextBox:Pe}),$e=we({approvedVouchers:ue(ge(pe)),rejectedVouchers:ue(ge(pe))}),He=we({allowExisting:ue(de,!1),keyBoxes:ge(Pe),newSyncKeys:ue(ge(pe),()=>[])}),Ye=we({appId:pe,loginId:ke,parentBox:ue(Pe)}),Ve=we({challengeId:pe,challengeUri:pe}),Je=we({challengeId:pe,challengeUri:ue(pe)}),Xe=we({request:Ne,replies:ge(je)}),Ze=le(!0),Qe=we({appId:pe,created:Ae,loginId:ke,syncToken:ue(pe),children:ue(ge(e=>Qe(e))),parentBox:ue(Pe),otpKey:ue(ve(Ze,_e)),otpResetDate:ue(Ae),otpTimeout:ue(fe),passwordAuthBox:ue(Pe),passwordAuthSnrp:ue(Ce),passwordBox:ue(ve(Ze,Pe)),passwordKeySnrp:ue(Ce),pin2Box:ue(ve(Ze,Pe)),pin2KeyBox:ue(Pe),pin2TextBox:ue(Pe),question2Box:ue(Pe),recovery2Box:ue(ve(Ze,Pe)),recovery2KeyBox:ue(Pe),loginAuthBox:ue(Pe),userId:ue(ke),userTextBox:ue(Pe),pendingVouchers:ue(ge(xe),()=>[]),keyBoxes:ue(ge(Me)),mnemonicBox:ue(Pe),rootKeyBox:ue(Pe),syncKeyBox:ue(Pe)}),et=ge(we({loginId:ke,otpResetPending:ue(de,!1),pendingVouchers:ue(ge(xe),()=>[]),recovery2Corrupt:ue(de,!1)})),tt=we({login_id:ue(ke),otp_reset_auth:ue(pe),otp_timeout_date:ue(Ae),reason:ue(le("ip","otp"),"otp"),voucher_activates:ue(Ae),voucher_auth:ue(ke),voucher_id:ue(pe)}),nt=we({otpResetDate:Ae}),rt=we({wait_seconds:ue(fe)}),ot=we({question2Box:Pe}),it=we({loginId:ke,passwordAuthSnrp:ue(Ce),questionBox:ue(Pe),questionKeySnrp:ue(Ce),recoveryAuthSnrp:ue(Ce)}),at=Ee(Pe),st=Ee(je),ct=Ee(Ne),ut=Ee(Re),lt=Ee(Le),dt=Ee(Be),ft=Ee(Ke),pt=Ee(Ue),ht=Ee(Fe),yt=Ee(We),bt=Ee(Ge),gt=Ee(ze),wt=Ee(qe),vt=Ee($e),mt=Ee(He),It=Ee(Ye),Et=(Ee(Ve),Ee(Je),Ee(Xe)),St=Ee(Qe),Ot=Ee(et),At=Ee(tt),Tt=Ee(nt),_t=Ee(rt),kt=Ee(ot),xt=Ee(it),Pt=we(Pe),Mt=we({loginId:ke,voucherAuth:ke,voucherId:pe,created:Ae,activates:Ae,status:le("pending","approved","rejected"),ip:pe,ipDescription:pe,deviceDescription:ue(pe)}),Ct=we({appId:pe,created:ue(Ae,()=>new Date),loginId:ke,children:ue(ge(e=>Ct(e)),()=>[]),parentBox:ue(Pe),parentId:()=>{},otpKey:ue(_e),otpResetAuth:ue(pe),otpResetDate:ue(Ae),otpTimeout:ue(fe),passwordAuth:ue(ke),passwordAuthBox:ue(Pe),passwordAuthSnrp:ue(Ce),passwordBox:ue(Pe),passwordKeySnrp:ue(Ce),pin2Id:ue(ke),pin2Auth:ue(ke),pin2Box:ue(Pe),pin2KeyBox:ue(Pe),pin2TextBox:ue(Pe),recovery2Id:ue(ke),recovery2Auth:ue(De),question2Box:ue(Pe),recovery2Box:ue(Pe),recovery2KeyBox:ue(Pe),loginAuth:ue(ke),loginAuthBox:ue(Pe),userId:ue(ke),userTextBox:ue(Pe),keyBoxes:ue(ge(Me),()=>[]),mnemonicBox:ue(Pe),rootKeyBox:ue(Pe),syncKeyBox:ue(Pe),vouchers:ue(ge(Mt),()=>[]),pinBox:ue(Pe),pinId:ue(pe),pinKeyBox:ue(Pe)}),Nt=Ee(Ct),jt=Ee(Pt);var Dt=n(5364);const Rt=n.n(Dt)()("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),Lt={parse(e){return Rt.decode(e)},stringify(e){return Rt.encode(e)}},Bt={parse(e){const t=encodeURI(e),n=new Uint8Array(t.length);let r=0;for(let o=0;o<t.length;++o){const e=t.charCodeAt(o);37===e?(n[r++]=parseInt(t.slice(o+1,o+3),16),o+=2):n[r++]=e}return n.subarray(0,r)},stringify(e){let t="";for(let n=0;n<e.length;++n){const r=e[n];t+="%"+(r>>4).toString(16)+(15&r).toString(16)}return decodeURIComponent(t)}};function Kt(e,t="Login requires a CAPTCHA"){if(!(this instanceof Kt))throw new TypeError("Class constructor ChallengeError cannot be invoked without 'new'");var n;return function(e){n=new Error(e),Object.defineProperty(n,"constructor",{value:Kt,configurable:!0,writable:!0})}(t),n.name="ChallengeError",n.challengeId=e.challengeId,n.challengeUri=e.challengeUri,n}function Ut(e="Cannot reach the network"){if(!(this instanceof Ut))throw new TypeError("Class constructor NetworkError cannot be invoked without 'new'");var t;return function(e){t=new Error(e),Object.defineProperty(t,"constructor",{value:Ut,configurable:!0,writable:!0})}(e),t.name="NetworkError",t}function Ft(e="The application is too old. Please upgrade."){if(!(this instanceof Ft))throw new TypeError("Class constructor ObsoleteApiError cannot be invoked without 'new'");var t;return function(e){t=new Error(e),Object.defineProperty(t,"constructor",{value:Ft,configurable:!0,writable:!0})}(e),t.name="ObsoleteApiError",t}function Wt(e,t="Invalid OTP token"){if(!(this instanceof Wt))throw new TypeError("Class constructor OtpError cannot be invoked without 'new'");var n;!function(e){n=new Error(e),Object.defineProperty(n,"constructor",{value:Wt,configurable:!0,writable:!0})}(t),n.name="OtpError",n.reason="otp";const r=me(tt)(e);if(null!=r)return null!=r.login_id&&(n.loginId=w(r.login_id)),n.resetToken=r.otp_reset_auth,n.reason=r.reason,n.resetDate=r.otp_timeout_date,n.voucherActivates=r.voucher_activates,null!=r.voucher_auth&&(n.voucherAuth=w(r.voucher_auth)),n.voucherId=r.voucher_id,n}function Gt(e,t="Invalid password"){if(!(this instanceof Gt))throw new TypeError("Class constructor PasswordError cannot be invoked without 'new'");var n;!function(e){n=new Error(e),Object.defineProperty(n,"constructor",{value:Gt,configurable:!0,writable:!0})}(t),n.name="PasswordError";const r=me(rt)(e);if(null!=r)return n.wait=r.wait_seconds,n}function zt(e){if(!(this instanceof zt))throw new TypeError("Class constructor PinDisabledError cannot be invoked without 'new'");var t;return function(e){t=new Error(e),Object.defineProperty(t,"constructor",{value:zt,configurable:!0,writable:!0})}(e),t.name="PinDisabledError",t}function qt(e="Invalid username"){if(!(this instanceof qt))throw new TypeError("Class constructor UsernameError cannot be invoked without 'new'");var t;return function(e){t=new Error(e),Object.defineProperty(t,"constructor",{value:qt,configurable:!0,writable:!0})}(e),t.name="UsernameError",t}function $t(e){return function(t){if(t instanceof Error&&t.name===e){return t}}}$t("ChallengeError"),$t("DustSpendError");const Ht=$t("InsufficientFundsError"),Yt=($t("NetworkError"),$t("NoAmountSpecifiedError"),$t("ObsoleteApiError"),$t("OtpError")),Vt=$t("PasswordError"),Jt=$t("PinDisabledError"),Xt=$t("PendingFundsError"),Zt=($t("SameCurrencyError"),$t("SpendToSelfError"),$t("SwapAboveLimitError")),Qt=$t("SwapBelowLimitError"),en=$t("SwapCurrencyError"),tn=$t("SwapPermissionError"),nn=$t("SwapAddressError"),rn=$t("UsernameError");var on=n(3836);function an(e,t){const n=i().hmac(i().sha256,t);return Uint8Array.from(n.update(e).digest())}function sn(e){const t=i().sha256();return Uint8Array.from(t.update(e).digest())}function cn(e,t){const n=e.length;if(n!==t.length)return!1;let r=0;for(let o=0;o<n;++o)r|=e[o]^t[o];return 0===r}const un=n.n(on)().ModeOfOperation.cbc;function ln(e,t){const n=dn(e,t);return 0===n[n.length-1]?Bt.stringify(n.subarray(0,-1)):Bt.stringify(n)}function dn(e,t){if(0!==e.encryptionType)throw new Error("Unknown encryption type");const n=e.iv_hex,r=e.data_base64,o=new un(t,n).decrypt(r),i=1+o[0]+4,a=o[i-4]<<24|o[i-3]<<16|o[i-2]<<8|o[i-1],s=i+a+1,c=s+o[s-1],u=c+32;if(!cn(sn(o.subarray(0,c)),o.subarray(c,u)))throw new Error("Invalid checksum");if(!cn(pn(u),o.subarray(u)))throw new Error("Invalid PKCS7 padding");return o.subarray(i,i+a)}function fn(e,t,n){const r=31&e.random(1)[0],o=1+r+4,i=t.length,a=o+i+1,s=31&e.random(1)[0],c=a+s,u=c+32,l=pn(u),d=new Uint8Array(u+l.length);d.set(l,u),d[0]=r,d.set(e.random(r),1),d[o-4]=i>>24&255,d[o-3]=i>>16&255,d[o-2]=i>>8&255,d[o-1]=255&i,d.set(t,o),d[a-1]=s,d.set(e.random(s),a),d.set(sn(d.subarray(0,c)),c);const f=e.random(16);return{encryptionType:0,iv_hex:f,data_base64:new un(n,f).encrypt(d)}}function pn(e){const t=new Uint8Array(16-(15&e));for(let n=0;n<t.length;++n)t[n]=t.length;return t}function hn(e,t,n){const r=function(e,t){const n=i().hmac(i().sha1,t);return Uint8Array.from(n.update(e).digest())}(function(e){const t=Math.floor(e/4294967296);return new Uint8Array([t>>24&255,t>>16&255,t>>8&255,255&t,e>>24&255,e>>16&255,e>>8&255,255&e])}(t),e),o=15&r[19],a=((127&r[o])<<24|r[o+1]<<16|r[o+2]<<8|r[o+3]).toString();return(Array(n).join("0")+a).slice(-n)}function yn(e,t=Date.now()/1e3){return hn(e,t/30,6)}function bn(...e){return[].concat(...e.filter(e=>null!=e))}function gn(e,t){for(const n of Object.keys(t))Object.defineProperty(e,n,{writable:!0,configurable:!0,value:t[n]});return e}function wn(e,t,n=new Error(`Timeout of ${t}ms exceeded`)){return new Promise((r,o)=>{const i=setTimeout(()=>o(n),t);e.then(e=>{clearTimeout(i),r(e)},e=>{clearTimeout(i),o(e)})})}function vn(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function mn(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?vn(Object(n),!0).forEach(function(t){r(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):vn(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}async function In(e,t,n,r){const{loginServers:o}=e.props.state.login,i=Math.floor(255*Math.random());let a,s=new Error("No login servers available");for(let l=0;l<o.length;++l)try{const s=(i+l)%o.length;a=await En(e,o[s],t,n,r);break}catch(u){s=u}if(null==a)throw s;const{status:c}=a;return function(e){const t=Le(e);switch(t.status_code){case 0:return t.results;case 2:throw new qt("Account already exists on server");case 3:throw new qt("Account does not exist on server");case 4:case 5:throw new Gt(t.results);case 6:throw new Error("Invalid API key");case 8:throw new Wt(t.results);case 1e3:throw new Ft;default:{const e=me(Ve)(t.results);if(null!=e)throw new Kt(e);throw new Error(`Server error: ${t.message}`)}}}(await a.json().catch(()=>{throw new Error(`Invalid reply JSON, HTTP status ${c}`)}))}function En(e,t,n,r,o){const{state:i,io:a,log:s}=e.props,{apiKey:c,apiSecret:u,attestationToken:l}=i.login,d="GET"===n||null==o?void 0:JSON.stringify(ut(o));let f=`Token ${c}`;if(null!=u){const e=`${n}\n/api${r}\n${null!=d?d:""}`,t=an(Bt.parse(e),u);f=`HMAC ${c} ${w(t)}`}const p={body:d,method:n,headers:mn({"content-type":"application/json",accept:"application/json",authorization:f},null!=l?{"x-attestation-token":l}:{}),corsBypass:"never"},h=Date.now(),y=`${t}/api${r}`;return wn(a.fetch(y,p),3e4).then(e=>{const t=Date.now()-h;return s(`${n} ${y} returned ${e.status} in ${t}ms`),409===e.status&&s.crash("Login API conflict error",{path:r}),e},e=>{const t=Date.now()-h;throw s.error(`${n} ${y} failed in ${t}ms, ${String(e)}`),new Ut(`Could not reach the auth server: ${r}`)})}function Sn(e,t){const{io:n}=e.props,{loginId:r,loginKey:o}=t,i=n.random(32),a=fn(n,i,o);return{loginId:r,server:gt({loginAuth:i,loginAuthBox:a}),serverPath:"/v2/login/secret",stash:{loginAuthBox:a}}}function On(e,t=2e3){return e.props.output.scrypt.makeSnrp(t)}async function An(e,t,n){"string"==typeof t&&(t=Bt.parse(t));return(await e.props.output.scrypt.timeScrypt(t,n)).hash}const Tn={salt_hex:Uint8Array.from([181,134,95,251,159,167,179,191,228,178,56,77,71,206,131,30,226,42,74,157,92,52,199,239,125,33,70,124,199,88,248,27]),n:16384,r:1,p:1};function _n(e){return{username:e,appId:"",loginId:new Uint8Array(0),pendingVouchers:[]}}function kn(e,t){const{stashes:n}=e.props.state.login;for(const r of n)if(r.username===t)return r}function xn(e,t){const{stashes:n}=e.props.state.login;for(const r of n){const e=r,n=zn(e,e=>cn(e.loginId,t));if(null!=n)return{stashTree:e,stash:n}}throw new Error(`Cannot find stash '${w(t)}'`)}function Pn(e,t){const n=zn(e,e=>cn(e.loginId,t));if(null!=n)return n;throw new Error(`Cannot find child stash '${w(t)}'`)}const Mn={};function Cn(e,t){return null==Mn[t]&&(Mn[t]=An(e,t,Tn)),Mn[t]}async function Nn(e,t){const n=[],r=await e.list("logins").then(re.WR);for(const i of r)try{n.push(Dn(JSON.parse(await e.getText(i))))}catch(o){t.error(`Could not load ${i}: ${String(o)}`)}return n}async function jn(e,t){const{dispatch:n,io:r}=e.props,{appId:o,loginId:i}=t;if(""!==o)throw new Error("Cannot save a login without an appId.");if(null==i||32!==i.length)throw new Error("Invalid loginId");await r.disklet.setText(`logins/${Lt.stringify(i)}.json`,JSON.stringify(Rn(t))),n({type:"LOGIN_STASH_SAVED",payload:t})}const Dn=we({appId:pe,created:ue(Ae),lastLogin:ue(Ae),loginId:ke,otpKey:ue(_e),otpResetDate:ue(Ae),otpTimeout:ue(fe),pendingVouchers:ue(ge(xe),()=>[]),voucherId:ue(pe),voucherAuth:ue(ke),loginAuthBox:ue(Pe),parentBox:ue(Pe),passwordAuthBox:ue(Pe),passwordAuthSnrp:ue(Ce),passwordBox:ue(Pe),passwordKeySnrp:ue(Ce),pin2Key:ue(Ie(e=>{const t=pe(e);return"="!==e.slice(-1)?Lt.parse(t):g(t)},e=>w(e))),pin2TextBox:ue(Pe),recovery2Key:ue(ke),userId:ue(ke),username:ue(e=>ae(pe(e))),children:ue(ge(e=>Dn(e))),keyBoxes:ue(ge(Me)),mnemonicBox:ue(Pe),rootKeyBox:ue(Pe),syncKeyBox:ue(Pe),wipChange:ue(e=>Dn(e))}),Rn=Ee(Dn);function Ln(e,t){const n=t.endsWith(".duress")?t:t+".duress";return e.appId===n?e:zn(e,e=>e.appId===n)}function Bn(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Kn(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Bn(Object(n),!0).forEach(function(t){r(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Bn(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Un(e){if(null!=e.otpKey)return yn(e.otpKey)}function Fn(e,t){const{otp:n,otpKey:r}=t;return null!=n?n:null!=r?yn(y(r,{loose:!0})):null!=e.otpKey?yn(e.otpKey):void 0}function Wn(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Gn(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Wn(Object(n),!0).forEach(function(t){r(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Wn(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function zn(e,t){if(t(e))return e;const n=e;if(null!=n.children)for(const r of n.children){const e=zn(r,t);if(null!=e)return e}}function qn(e,t,n,r){if(t(e))return n(e);const o=null!=e.children?e.children.map(e=>qn(e,t,n,r)):[];return r(e,o)}function $n(e,t,n){const{children:r=[]}=e,{appId:o,created:i,loginId:a,loginAuthBox:s,userId:c,otpKey:u,otpResetDate:l,otpTimeout:d,pendingVouchers:f,parentBox:p,passwordAuthBox:h,passwordAuthSnrp:y,passwordBox:b,passwordKeySnrp:g,pin2TextBox:w,children:v=[],keyBoxes:m=[],mnemonicBox:I,rootKeyBox:E,syncKeyBox:S,syncToken:O}=n,A={appId:o,created:i,loginId:a,loginAuthBox:s,userId:c,otpKey:!0===u?e.otpKey:u,otpResetDate:l,otpTimeout:d,pendingVouchers:f,parentBox:p,passwordAuthBox:h,passwordAuthSnrp:y,passwordBox:!0===b?e.passwordBox:b,passwordKeySnrp:g,pin2TextBox:w,keyBoxes:m,mnemonicBox:I,rootKeyBox:E,syncKeyBox:S,syncToken:O};null!=e.lastLogin&&(A.lastLogin=e.lastLogin),null!=e.username&&(A.username=e.username),null!=e.userId&&null==A.userId&&(A.userId=e.userId),null!=n.pin2KeyBox&&(A.pin2Key=dn(n.pin2KeyBox,t)),null!=n.recovery2KeyBox&&(A.recovery2Key=dn(n.recovery2KeyBox,t)),null!=n.userTextBox&&(A.username=Bt.stringify(dn(n.userTextBox,t))),v.sort((e,t)=>e.created.valueOf()-t.created.valueOf()),A.children=v.map(e=>{const{appId:n,loginId:o,parentBox:i}=e;if(null==i)throw new Error("Key integrity violation: No parentBox on child login.");const a=dn(i,t),s=r.find(e=>cn(e.loginId,o));return $n(null!=s?s:{appId:n,loginId:o,pendingVouchers:[]},a,e)});for(const{loginId:T}of r){if(null==v.find(e=>cn(e.loginId,T)))throw new Error("The server has lost children!")}return A}function Hn(e,t,n){return qn(e,e=>e.appId===n.appId,e=>$n(e,t,n),(e,t)=>Gn(Gn({},e),{},{children:t,wipChange:void 0}))}function Yn(e,t){const{appId:n,created:r,lastLogin:o=new Date,loginId:i,otpKey:a,otpResetDate:s,otpTimeout:c,pendingVouchers:u,userId:l,username:d,children:f=[]}=e,p={appId:n,created:r,isRoot:null==e.parentBox,lastLogin:o,loginId:i,loginKey:t,otpKey:a,otpResetDate:s,otpTimeout:c,pendingVouchers:u,userId:l,username:d,children:[]};if(null!=e.loginAuthBox&&(p.loginAuth=dn(e.loginAuthBox,t)),null!=e.passwordAuthBox&&(null==p.userId&&(p.userId=i),p.passwordAuth=dn(e.passwordAuthBox,t)),null==p.loginAuth&&null==p.passwordAuth)throw new Error("No server authentication methods on login");return p.pin2Key=e.pin2Key,null!=e.pin2TextBox&&(p.pin=ln(e.pin2TextBox,t)),p.recovery2Key=e.recovery2Key,p.children=f.map(e=>{if(null==e.parentBox)throw new Error("Key integrity violation: No parentBox on child login.");return Yn(e,dn(e.parentBox,t))}),p}function Vn(e,t){return qn(e,e=>cn(e.loginId,t.loginId),e=>Yn(e,t.loginKey),(e,t)=>{const{appId:n,lastLogin:r=new Date,loginId:o,otpKey:i,pendingVouchers:a,username:s}=e;return{appId:n,children:t,isRoot:null==e.parentBox,lastLogin:r,loginId:o,loginKey:void 0,otpKey:i,pendingVouchers:a,username:s}})}function Jn(e,t){return qn(e,e=>e.appId===t,e=>e,(e,t)=>{const{appId:n,loginId:r,username:o}=e;return{appId:n,children:t,loginId:r,pendingVouchers:[],username:o}})}async function Xn(e,t,n,r,o,i){const{now:a=new Date}=r,{deviceDescription:s}=e.props.state.login.deviceInfo,c=Gn({challengeId:r.challengeId,otp:Fn(n,r),voucherId:n.voucherId,voucherAuth:n.voucherAuth},o);null!=s&&(c.deviceDescription=s);let u=Qe(await In(e,"POST","/v2/login",c).catch(r=>{const o=Yt(r);throw null!=o&&(0===n.loginId.length&&null!=o.loginId||null!=o.voucherId&&null!=o.voucherAuth)&&(null!=o.loginId&&(n.loginId=g(o.loginId)),null!=o.voucherAuth&&(n.voucherId=o.voucherId,n.voucherAuth=g(o.voucherAuth)),t.lastLogin=a,jn(e,t).catch(()=>{})),r}));const{loginId:l}=u,d=await i(u);if((t=Hn(t,d,u)).lastLogin=a,await jn(e,t),null==u.loginAuthBox){const{stash:t,stashTree:n}=xn(e,l),i=Sn(e,{loginId:l,loginKey:d}),a=Gn(Gn({},o),{},{otp:Fn(t,r),data:i.server});u=Qe(await In(e,"POST",i.serverPath,a)),await jn(e,Hn(n,d,u))}return{loginId:l,loginKey:d}}async function Zn(e,t,n){const{serverMethod:r="POST",serverPath:o}=n,{stashTree:i}=xn(e,n.loginId),{deviceDescription:a}=e.props.state.login.deviceInfo,s=qn(i,e=>cn(e.loginId,n.loginId),e=>Gn(Gn(Gn({},e),n.stash),{},{children:bn(e.children,n.stash.children),keyBoxes:bn(e.keyBoxes,n.stash.keyBoxes),wipChange:void 0}),(e,t)=>Gn(Gn({},e),{},{children:t,wipChange:void 0}));if(""!==o&&(i.wipChange=s,await jn(e,i)),""!==o){const s=nr(i,tr(i,t,n.loginId));null!=a&&(s.deviceDescription=a),s.data=n.server;try{await In(e,r,o,s)}catch(c){throw er(e,t).catch(()=>{}),c}}return await jn(e,s),s}async function Qn(e,t,n){for(const r of n)null!=r&&await Zn(e,t,r)}async function er(e,t){const{stashTree:n,stash:r}=xn(e,t.loginId),{syncToken:o}=r;if(null!=o)try{if(de(await In(e,"POST","/v2/sync",{loginId:r.loginId,syncToken:o})))return}catch(s){}const i=nr(n,t),a={now:n.lastLogin};await Xn(e,n,r,a,i,async()=>t.loginKey)}function tr(e,t,n){var r;if(cn(n,t.loginId))return t;const o=Pn(e,t.loginId),i=function e(t,r){for(const o of t){if(null==o.parentBox)continue;if(cn(o.loginId,n))return{loginId:o.loginId,loginKey:dn(o.parentBox,r)};const{children:t=[]}=o;if(0===t.length)continue;const i=e(t,dn(o.parentBox,r));if(null!=i)return i}}(null!==(r=null==o?void 0:o.children)&&void 0!==r?r:[],t.loginKey);if(null==i)throw new Error(`Cannot decrypt child login '${w(t.loginId)}'`);return i}function nr(e,t){const n=Pn(e,t.loginId),{loginAuthBox:r,otpKey:o,passwordAuthBox:i,syncToken:a,userId:s,voucherAuth:c,voucherId:u}=n,l=null!=o?yn(o):void 0;if(null!=r)return{loginAuth:dn(r,t.loginKey),loginId:t.loginId,otp:l,syncToken:a,voucherAuth:c,voucherId:u};if(null!=i&&null!=s)return{passwordAuth:dn(i,t.loginKey),userId:s,otp:l,syncToken:a,voucherAuth:c,voucherId:u};throw new Error("No server authentication methods available")}var rr=n(9112);rr.jG,rr.ZU,rr.CS,rr.ve,rr.q3,rr.FX,rr.yq,rr.w2,rr.CG,rr.Kr,rr.l3,rr.N0,rr.MH,rr.fs,rr.FA;const or=rr.NL;rr.Tb;function ir(e){return"Minified Redux error #"+e+"; visit https://redux.js.org/Errors?code="+e+" for the full message or use the non-minified dev environment for full errors. "}var ar="function"==typeof Symbol&&Symbol.observable||"@@observable",sr=function(){return Math.random().toString(36).substring(7).split("").join(".")},cr={INIT:"@@redux/INIT"+sr(),REPLACE:"@@redux/REPLACE"+sr(),PROBE_UNKNOWN_ACTION:function(){return"@@redux/PROBE_UNKNOWN_ACTION"+sr()}};function ur(e){if("object"!=typeof e||null===e)return!1;for(var t=e;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}function lr(e,t,n){var r;if("function"==typeof t&&"function"==typeof n||"function"==typeof n&&"function"==typeof arguments[3])throw new Error(ir(0));if("function"==typeof t&&void 0===n&&(n=t,t=void 0),void 0!==n){if("function"!=typeof n)throw new Error(ir(1));return n(lr)(e,t)}if("function"!=typeof e)throw new Error(ir(2));var o=e,i=t,a=[],s=a,c=!1;function u(){s===a&&(s=a.slice())}function l(){if(c)throw new Error(ir(3));return i}function d(e){if("function"!=typeof e)throw new Error(ir(4));if(c)throw new Error(ir(5));var t=!0;return u(),s.push(e),function(){if(t){if(c)throw new Error(ir(6));t=!1,u();var n=s.indexOf(e);s.splice(n,1),a=null}}}function f(e){if(!ur(e))throw new Error(ir(7));if(void 0===e.type)throw new Error(ir(8));if(c)throw new Error(ir(9));try{c=!0,i=o(i,e)}finally{c=!1}for(var t=a=s,n=0;n<t.length;n++){(0,t[n])()}return e}return f({type:cr.INIT}),(r={dispatch:f,subscribe:d,getState:l,replaceReducer:function(e){if("function"!=typeof e)throw new Error(ir(10));o=e,f({type:cr.REPLACE})}})[ar]=function(){var e,t=d;return(e={subscribe:function(e){if("object"!=typeof e||null===e)throw new Error(ir(11));function n(){e.next&&e.next(l())}return n(),{unsubscribe:t(n)}}})[ar]=function(){return this},e},r}function dr(e){function t(t){var n=void 0,r=void 0,o=!0,i=!1,a=!1,s=void 0,c=void 0,u=void 0;function l(){if(n){try{if(c){var e=c;s=void 0,c=void 0,u=void 0,e(((r=new Error("Pixie has been destroyed")).name="PixieShutdownError",r))}var t=n;n=void 0,t.destroy()}catch(r){d(r)}a=!0}var r}function d(e){a||t.onError(e),l()}function f(){i=!1,p()}function p(){for(;n&&o&&!i;){o=!1,i=!0;try{var e=n.update(r);e&&"function"==typeof e.then?e.then(f,d):i=!1}catch(t){d(t)}}}function h(){return s||(s=new Promise(function(e,t){u=e,c=t})),s}var y={onError:d,onOutput:function(e){a||t.onOutput(e)},get props(){return r},nextProps:h,waitFor:function(e){return new Promise(function(t,n){return function o(){try{var i=e(r);null!=i?t(i):h().then(o,n)}catch(a){n(a)}}()})}};try{n=function(e){return"function"==typeof e?{update:e,destroy:function(){}}:e}(e(y))}catch(b){d(b)}return{update:function(e){if(r=e,o=!0,u){var t=u;s=void 0,c=void 0,u=void 0,t(e)}p()},destroy:l}}return t.tame=!0,t.defaultOutput=e.defaultOutput,t}function fr(e){return e.tame?e:dr(e)}function pr(e,t,n){n(e)}var hr="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},yr=(function(){function e(e){this.value=e}function t(t){var n,r;function o(n,r){try{var a=t[n](r),s=a.value;s instanceof e?Promise.resolve(s.value).then(function(e){o("next",e)},function(e){o("throw",e)}):i(a.done?"return":"normal",a.value)}catch(c){i("throw",c)}}function i(e,t){switch(e){case"return":n.resolve({value:t,done:!0});break;case"throw":n.reject(t);break;default:n.resolve({value:t,done:!1})}(n=n.next)?o(n.key,n.arg):r=null}this._invoke=function(e,t){return new Promise(function(i,a){var s={key:e,arg:t,resolve:i,reject:a,next:null};r?r=r.next=s:(n=r=s,o(e,t))})},"function"!=typeof t.return&&(this.return=void 0)}"function"==typeof Symbol&&Symbol.asyncIterator&&(t.prototype[Symbol.asyncIterator]=function(){return this}),t.prototype.next=function(e){return this._invoke("next",e)},t.prototype.throw=function(e){return this._invoke("throw",e)},t.prototype.return=function(e){return this._invoke("return",e)}}(),function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}()),br=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e};function gr(e){}function wr(e){}function vr(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:gr,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:wr;return function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:pr,n=fr(e);function r(e){var r=e.onOutput,o=void 0,i=void 0,a=function(){var e=o;o=void 0,e&&e.destroy()},s={onError:function(n){a();try{t(n,i,e.onError)}catch(n){e.onError(n)}},onOutput:r};return{update:function(e){i=e,o||(o=n(s)),o.update(e)},destroy:a}}return r.tame=!0,r.defaultOutput=e.defaultOutput,r}(function(e){var t=fr(e);function n(n){var r=n.onError,o=void 0,i=e.defaultOutput,a=void 0,s=!0,c=!1,u=function(){for(;o&&s&&!c;)s=!1,c=!0,o.update(br({},a,{output:i})),c=!1},l={onError:r,onOutput:function(e){e!==i&&(i=e,s=!0,n.onOutput(e),u())}};return{update:function(e){a=e,s=!0,o||(o=t(l)),u()},destroy:function(){var e=o;o=void 0,e&&e.destroy()}}}return n.tame=!0,n.defaultOutput=e.defaultOutput,n}(e))({onError:t,onOutput:n})}function mr(e){var t={},n=Object.keys(e),r=Array.isArray(n),o=0;for(n=r?n:n[Symbol.iterator]();;){var i;if(r){if(o>=n.length)break;i=n[o++]}else{if((o=n.next()).done)break;i=o.value}var a=i;t[a]=e[a].defaultOutput}function s(n){var r=n.onError,o={},i={},a=br({},t),s=!1,c=function(){if(l){if(d>=u.length)return"break";f=u[d++]}else{if((d=u.next()).done)return"break";f=d.value}var t=f;if(o[t]={onError:r,onOutput:function(e){e!==a[t]&&((a=br({},a))[t]=e,n.onOutput(a))}},i[t]=fr(e[t])(o[t]),s)return"break"},u=Object.keys(e),l=Array.isArray(u),d=0;for(u=l?u:u[Symbol.iterator]();;){var f;if("break"===c())break}return{update:function(e){var t=Object.keys(i),n=Array.isArray(t),r=0;for(t=n?t:t[Symbol.iterator]();;){var o;if(n){if(r>=t.length)break;o=t[r++]}else{if((r=t.next()).done)break;o=r.value}if(i[o].update(e),s)return}},destroy:function(){s=!0;var e=Object.keys(i),t=Array.isArray(e),n=0;for(e=t?e:e[Symbol.iterator]();;){var r;if(t){if(n>=e.length)break;r=e[n++]}else{if((n=e.next()).done)break;r=n.value}i[r].destroy()}}}}return s.tame=!0,s.defaultOutput=t,s}function Ir(e,t){return function(){try{return e.apply(void 0,arguments)}catch(n){t(n)}}}function Er(e,t){if(e===t)return!0;if("object"!==(void 0===e?"undefined":hr(e)))return!1;if("object"!==(void 0===t?"undefined":hr(t)))return!1;if(!e||!t)return!1;var n=Object.getOwnPropertyNames(e);if(n.length!==Object.getOwnPropertyNames(t).length)return!1;var r=n,o=Array.isArray(r),i=0;for(r=o?r:r[Symbol.iterator]();;){var a;if(o){if(i>=r.length)break;a=r[i++]}else{if((i=r.next()).done)break;a=i.value}var s=a;if(!Object.prototype.hasOwnProperty.call(t,s)||e[s]!==t[s])return!1}return!0}function Sr(e,t){var n=fr(e);function r(e){var r=e.onError,o=e.onOutput,i=void 0,a=void 0,s=!1,c=Ir(t,r),u={onError:r,onOutput:o};return{update:function(e){var t=c(e);if(!s){var r=!Er(t,a);if(a=t,t){if(i||(i=n(u)),s)return;r&&i.update(t)}else i&&i.destroy(),i=void 0}},destroy:function(){s=!0,i&&i.destroy(),i=void 0}}}return r.tame=!0,r.defaultOutput=e.defaultOutput,r}function Or(e,t,n){var r=fr(e);function o(e){var o=e.onError,i={},a={},s=!1,c={},u=!1,l=!1,d=Ir(t,o),f=Ir(n,o),p=function(){if(s&&!u){s=!1;var t={},n=Object.keys(i),r=Array.isArray(n),o=0;for(n=r?n:n[Symbol.iterator]();;){var c;if(r){if(o>=n.length)break;c=n[o++]}else{if((o=n.next()).done)break;c=o.value}var l=c;t[l]=a[l]}a=t,e.onOutput(a)}};return{update:function(e){var t=d(e);if(!l&&t){u=!0;var n={},h=function(){if(b){if(g>=y.length)return"break";w=y[g++]}else{if((g=y.next()).done)return"break";w=g.value}var t=w,u=f(e,t);if(l)return{v:void 0};var d=!Er(u,c[t]);if(c[t]=u,u){if(!i[t]){if(i[t]=r({onError:o,onOutput:function(e){e!==a[t]&&(a[t]=e,s=!0,p())}}),l)return{v:void 0}}if(d&&i[t].update(u),l)return{v:void 0};n[t]=i[t]}};var y=t,b=Array.isArray(y),g=0;e:for(y=b?y:y[Symbol.iterator]();;){var w,v=h();if("break"===v)break e;if("object"===(void 0===v?"undefined":hr(v)))return v.v}var m=i;i=n;var I=Object.keys(m),E=Array.isArray(I),S=0;for(I=E?I:I[Symbol.iterator]();;){var O;if(E){if(S>=I.length)break;O=I[S++]}else{if((S=I.next()).done)break;O=S.value}var A=O;n[A]||(s=!0,m[A].destroy())}l||(u=!1,p())}},destroy:function(){l=!0;var e=Object.keys(i),t=Array.isArray(e),n=0;for(e=t?e:e[Symbol.iterator]();;){var r;if(t){if(n>=e.length)break;r=e[n++]}else{if((n=e.next()).done)break;r=n.value}var o=r;i[o]&&i[o].destroy()}}}}return o.tame=!0,o.defaultOutput={},o}!function(){function e(t,n){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.props=t}yr(e,[{key:"update",value:function(e,t){}},{key:"destroy",value:function(e,t){}}])}();var Ar={then:function(){}};function Tr(e){const t=new URL(e);if("http:"!==t.protocol&&"ws:"!==t.protocol||!function(e){if("localhost"===e)return!0;const t=function(e){const t=e.split(".");if(4!==t.length)return null;const n=[];for(const r of t){if(!/^\d{1,3}$/.test(r))return null;const e=Number(r);if(!Number.isInteger(e)||e<0||e>255)return null;if(r.length>1&&r.startsWith("0"))return null;n.push(e)}return n}(e);if(null==t)return!1;const[n,r]=t;return 127===n||(10===n||(192===n&&168===r||172===n&&r>=16&&r<=31))}(t.hostname)){if("https:"===t.protocol||"wss:"===t.protocol){if("localhost"===t.hostname)return;if(/^([A-Za-z0-9_-]+\.)*edge(test)?\.app$/.test(t.hostname))return}throw new Error(`Only *.edge.app, localhost, or private LAN addresses (http/ws) are valid login domain names, not ${t.hostname}`)}}function _r(e){const t=Ee(e);return{async load(t,n){try{return e(JSON.parse(await t.getText(n)))}catch(r){}},async save(e,n,r){await e.setText(n,JSON.stringify(t(r)))}}}const kr=e=>{if(null==e||"object"!=typeof e)throw new TypeError("Expected a JSON object");return e},xr="client.json",Pr=_r(we({clientId:ke,duressEnabled:me(de,!1),loginWaitTimestamps:me(we(fe),()=>({}))})),Mr="infoCache.json",Cr=we({corePlugins:we(kr),syncServers:ge(pe)}),Nr=_r(Cr);function jr(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Dr(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?jr(Object(n),!0).forEach(function(t){r(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):jr(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Rr(e,t,n){return function(){let r="";for(let e=0;e<arguments.length;++e){const t=arguments[e];e>0&&(r+=" "),"string"==typeof t?r+=t:t instanceof Error?r+=String(t):r+=JSON.stringify(t,null,2)}e({message:r,source:n,time:new Date,type:t})}}function Lr(e,t){const{onLog:n,crashReporter:r}=e;return gn(Rr(n,"info",t),{breadcrumb(e,o){const i=new Date;null!=r?r.logBreadcrumb({message:e,metadata:o,source:t,time:i}):(e=`${e} ${JSON.stringify(o,null,2)}`,n({message:e,source:t,time:i,type:"warn"}))},crash(e,o){const i=new Date;if(null!=r)r.logCrash({error:e,metadata:o,source:t,time:i});else{const r=`${String(e)} ${JSON.stringify(o,null,2)}`;n({message:r,source:t,time:i,type:"error"})}},warn:Rr(n,"warn",t),error:Rr(n,"error",t)})}const Br=Ie(e=>Lt.parse(pe(e)),e=>Lt.stringify(e)),Kr=_r(we({SNRP2:Ce,SNRP3:ue(Ce),SNRP4:ue(Ce),ERQ:ue(Pe)})),Ur=_r(we({EMK_LP2:Pe,EMK_LRA3:ue(Pe),ESyncKey:Pe,ELP1:Pe})),Fr=_r(we({TOTP:_e})),Wr=_r(we({pin2Key:Br})),Gr=_r(we({recovery2Key:Br})),zr=_r(we({userName:pe}));function qr(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function $r(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?qr(Object(n),!0).forEach(function(t){r(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):qr(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}const Hr={};let Yr=!1;const Vr=[],Jr=[];function Xr(){Yr=!0;for(const e of Jr)e()}function Zr(e,t,n={}){const{onError:r=()=>{}}=n;let o,i=!1;function a(){o=void 0,u.started&&(i=!0,new Promise(t=>t(e())).catch(r).then(c,c))}function s(e){i=!1,u.started&&(o=setTimeout(a,e))}function c(){s(t)}const u={started:!1,setDelay(e){t=e},start(e={}){const{wait:n}=e;u.started=!0,i||null!=o||("number"==typeof n?s(n):!0===n?s(t):a())},stop(){u.started=!1,null!=o&&(clearTimeout(o),o=void 0)}};return u}function Qr(e){return new Promise(t=>setTimeout(()=>t(e),e))}function eo(e,t){const n=to(e,t);if(null==n)throw new Error(`Cannot find a currency plugin for wallet type ${t}`);return n}function to(e,t){return Object.keys(e).find(n=>e[n].currencyInfo.walletType===t)}function no(e,t){const{dispatch:n,state:r}=e.props,o=r.plugins.currencyTools[t];if(null!=o)return o;const i=r.plugins.currency[t].makeCurrencyTools();return n({type:"CURRENCY_TOOLS_LOADED",payload:{pluginId:t,tools:i}}),i}const ro=we({dataKey:ke,syncKey:ke}),oo=Ee(ro);function io(e){const{io:t}=e.props;return{dataKey:t.random(32),syncKey:t.random(20)}}function ao(e,t,n){const r={delete(e){return n.delete(e)},async getData(e){const r=await n.getText(e);return dn(Pe(JSON.parse(r)),t)},async getText(e){const r=await n.getText(e);return ln(Pe(JSON.parse(r)),t)},list(e){return n.list(e)},setData(r,o){return n.setText(r,JSON.stringify(at(fn(e,Uint8Array.from(o),t))))},setText(e,t){return this.setData(e,Bt.parse(t))}};return P(r),r}function so(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function co(e,t){return(0,re.my)(e.disklet,"local/"+Lt.stringify(g(t)))}function uo(e,t){const{dataKey:n,syncKey:r}=t,o=(0,re.my)(e.disklet,"repos/"+Lt.stringify(sn(sn(r)))),i=(0,re.my)(o,"changes"),a=(0,re.my)(o,"data");return{dataKey:n,syncKey:r,baseDisklet:o,changesDisklet:i,dataDisklet:a,disklet:ao(e,n,(0,re.mi)(i,a))}}function lo(e){const t={lastSync:0,lastHash:void 0};return e.baseDisklet.getText("status.json").then(e=>function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?so(Object(n),!0).forEach(function(t){r(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):so(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}({lastSync:0},JSON.parse(e))).catch(()=>t)}async function fo(e,t){await Promise.all(Object.keys(t).map(n=>{const r=t[n];return null!=r?e.setText(n,JSON.stringify(at(r))):e.delete(n)}))}async function po(e,t,n){const{changesDisklet:r,dataDisklet:o,syncKey:i}=t,a=await ho(r).then(e=>Promise.all(e.map(async e=>({path:e,box:Pe(JSON.parse(await r.getText(e)))})))),s=h(i).toLowerCase(),c=await(()=>{if(0===a.length)return e.readRepo(s,n.lastHash);const t={};for(const e of a)t[e.path]=at(e.box);return e.updateRepo(s,n.lastHash,{changes:t})})(),{hash:u}=c,l={};for(const f of Object.keys(null!==(d=c.changes)&&void 0!==d?d:{})){var d;const e=c.changes[f];l[f]=null==e?null:Pe(e)}return await fo(o,l),await Promise.all(a.map(e=>r.delete(e.path))),n.lastSync=Date.now()/1e3,null!=u&&(n.lastHash=u),await t.baseDisklet.setText("status.json",JSON.stringify(n)),{status:n,changes:l}}async function ho(e,t="",n=100){const r=await e.list(t),o=Object.keys(r).filter(e=>"file"===r[e]),i=Object.keys(r).filter(e=>"folder"===r[e]);for(const a of i){if(o.length>=n)break;const t=n-o.length,r=await ho(e,a,t);o.push(...r.slice(0,t))}return o}function yo(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}const bo=3e4;async function go(e,t){const{dispatch:n,io:r,onError:o}=e.props,i=uo(r,ro(t.keys)),a=co(r,t.id);P(a);const s=await lo(i);n({type:"STORAGE_WALLET_ADDED",payload:{id:t.id,initialState:{localDisklet:a,paths:i,status:s,lastChanges:[]}}});const c=wo(e,t.id);s.lastSync>0?c.catch(n=>{const{syncKey:r}=t.keys,{lastHash:i}=s;e.props.log.error(`Could not sync ${String(r)} with last hash ${String(i)}: ${String(n)}`),o(n)}):await c}function wo(e,t){const{dispatch:n,syncClient:o,state:i}=e.props,{paths:a,status:s}=i.storageWallets[t];return po(o,a,function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?yo(Object(n),!0).forEach(function(t){r(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):yo(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}({},s)).then(({changes:e,status:r})=>(n({type:"STORAGE_WALLET_SYNCED",payload:{id:t,changes:Object.keys(e),status:r}}),Object.keys(e)))}async function vo(e){try{return{ok:!0,result:await e}}catch(t){return{ok:!1,error:t}}}var mo=n(5817);function Io(e){for(let t=e.length-1;t>0;t--){const n=Math.floor(Math.random()*(t+1));[e[t],e[n]]=[e[n],e[t]]}return e}function Eo(e,t){return e.storageWallets[t].paths.disklet}function So(e,t){return e.storageWallets[t].localDisklet}function Oo(e,t,n){const r=e.storageWallets[t].paths.dataKey;return Lt.stringify(an(Bt.parse(n),r))}const Ao=we({multiplier:pe,name:pe,symbol:ue(pe)}),To=we({currencyCode:pe,denominations:ge(Ao),displayName:pe,networkLocation:ue(kr)}),_o=we({enabled:ue(de,!0)}).withRest,ko=we({SortIndex:ue(fe,0),Archived:ue(de,!1),BitcoinSeed:Te,MK:Te,SyncKey:Te}).withRest,xo=we({id:pe,archived:ue(de),deleted:ue(de),hidden:ue(de),migratedFromWalletId:ue(pe),sortIndex:ue(fe)}),Po=we({userSettings:ue(we(kr),()=>({})),swapSettings:ue(we(_o),()=>({}))}).withRest,Mo=we({customTokens:ge(we({contractAddress:pe,currencyCode:pe,currencyName:pe,denomination:pe,denominations:ge(Ao),isVisible:ue(de,!0),multiplier:pe,walletType:ue(pe,"wallet:ethereum")}))}),Co=we({customTokens:we(we(To))});function No(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function jo(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?No(Object(n),!0).forEach(function(t){r(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):No(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}const Do=_r(ko),Ro=_r(xo),Lo=_r(Po),Bo=Po({}),Ko="PluginSettings.json";function Uo(e,t){for(const n of Object.keys(t))if(e[n]!==t[n])return!0;return!1}async function Fo(e,t){const n=e.props.state.accounts[t],{accountWalletInfo:r,accountWalletInfos:o}=n,i=await Promise.all(o.map(t=>async function(e){const t=[],n={},r=(0,re.WR)(await e.list("Wallets"));return await Promise.all(r.map(async r=>{const o=await Do.load(e,r);if(null==o)return;const i=Qo("wallet:bitcoin",jo(jo({},oo({dataKey:o.MK,syncKey:o.SyncKey})),{},{bitcoinKey:w(o.BitcoinSeed),format:"bip32"}),o.MK);t.push(i),n[i.id]={archived:o.Archived,deleted:!1,hidden:!1,migratedFromWalletId:void 0,sortIndex:o.SortIndex}})),{walletInfos:t,walletStates:n}}(Eo(e.props.state,t.id)))),a=await async function(e){const t={},n=(0,re.WR)(await e.list("Keys"));return await Promise.all(n.map(async n=>{const r=await Ro.load(e,n);if(null==r)return;const{id:o,archived:i,deleted:a,hidden:s,migratedFromWalletId:c,sortIndex:u}=r;t[o]={archived:i,deleted:a,hidden:s,sortIndex:u,migratedFromWalletId:c}})),t}(Eo(e.props.state,r.id)),s=[];for(const l of i)s.push(...l.walletInfos);const c=i.map(e=>e.walletStates),u=Object.assign({},...c,a);e.props.dispatch({type:"ACCOUNT_KEYS_LOADED",payload:{accountId:t,legacyWalletInfos:s,walletStates:u}})}async function Wo(e,t,n){const{accountWalletInfo:r,walletStates:o}=e.props.state.accounts[t],i=Eo(e.props.state,r.id),a={};for(const c of Object.keys(n))null==o[c]?a[c]=n[c]:Uo(o[c],n[c])&&(a[c]=jo(jo({},o[c]),n[c]));const s=Object.keys(a);s.length<1||(await Promise.all(s.map(async t=>{const{archived:n,deleted:o,hidden:s,migratedFromWalletId:c,sortIndex:u}=a[t],l=Oo(e.props.state,r.id,t);await Ro.save(i,`Keys/${l}.json`,{archived:n,deleted:o,hidden:s,id:t,migratedFromWalletId:c,sortIndex:u})})),e.props.dispatch({type:"ACCOUNT_CHANGED_WALLET_STATES",payload:{accountId:t,walletStates:jo(jo({},o),a)}}))}async function Go(e,t,n,r){var o;const{accountWalletInfo:i}=e.props.state.accounts[t],a=Eo(e.props.state,i.id),s=null!==(o=await Lo.load(a,Ko))&&void 0!==o?o:Bo;await Lo.save(a,Ko,jo(jo({},s),{},{userSettings:jo(jo({},e.props.state.accounts[t].userSettings),{},{[n]:r})})),e.props.dispatch({type:"ACCOUNT_PLUGIN_SETTINGS_CHANGED",payload:{accountId:t,pluginId:n,userSettings:jo({},r)}})}async function zo(e,t){const{accountWalletInfo:n}=e.props.state.accounts[t],r=Eo(e.props.state,n.id),o=await Lo.load(r,Ko),{userSettings:i,swapSettings:a}=null!=o?o:{userSettings:{},swapSettings:{}};e.props.dispatch({type:"ACCOUNT_PLUGIN_SETTINGS_LOADED",payload:{accountId:t,userSettings:i,swapSettings:a}})}function qo(e,t,n){for(const r of e.denominations)if(r.name===n)return r.multiplier;for(const r of Object.keys(t)){const e=t[r];for(const t of e.denominations)if(t.name===n)return t.multiplier}return"1"}function $o(e,t){return e.waitFor(e=>{if(null==e.state.currency.wallets[t])throw new Error(`Wallet id ${t} does not exist in this account`);const{engineFailure:n}=e.state.currency.wallets[t];if(null!=n)throw n;if(null!=e.output.currency.wallets[t])return e.output.currency.wallets[t].walletApi})}const Ho=we({id:pe,keys:kr,type:pe}),Yo=Ee(Ho);function Vo(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Jo(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Vo(Object(n),!0).forEach(function(t){r(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Vo(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Xo(e,t){return e.find(e=>e.type===t)}function Zo(e){return""===e?"account-repo:co.airbitz.wallet":`account-repo:${e}`}function Qo(e,t,n){const r=an(Bt.parse(e),null!=n?n:ro(t).dataKey);return{id:w(r),type:e,keys:t}}function ei(e,t,n,r=!1){e.props.log.breadcrumb("makeKeysKit",{});const{io:o}=e.props,i=n.map(e=>Jo({created:new Date},fn(o,Bt.parse(JSON.stringify(Yo(e))),t.loginKey))),a=[];for(const s of n){const e=me(ro)(s.keys);null!=e&&a.push(h(e.syncKey).toLowerCase())}return{loginId:t.loginId,server:mt({allowExisting:r,keyBoxes:i,newSyncKeys:a}),serverPath:"/v2/login/keys",stash:{keyBoxes:i}}}function ti(e){const t=[],n=new Map;for(const r of e){const{id:e,keys:o,type:i}=r;if(null==e||32!==g(e).length)throw new Error(`Key integrity violation: invalid id ${e}`);const a=n.get(e);if(null!=a){const n=t[a];if(n.type!==i)throw new Error(`Key integrity violation for ${e}: type ${i} does not match ${n.type}`);for(const t of Object.keys(o))if(null!=n.keys[t]&&n.keys[t]!==o[t])throw new Error(`Key integrity violation for ${e}: ${t} keys do not match`);t[a]={id:e,keys:Jo(Jo({},n.keys),o),type:i}}else n.set(e,t.length),t.push(r)}return t}function ni(e,t,n=new Map){const{appId:r,keyBoxes:o=[]}=e,i=[],{mnemonicBox:a,rootKeyBox:s}=e;if(null!=a&&null!=s){const e=dn(s,t),n={mnemonic:ln(a,an(e,Bt.parse("infoKey"))),rootKey:w(e)};i.push(Qo("wallet:bitid",n,e))}if(null!=e.syncKeyBox){const n=dn(e.syncKeyBox,t),o=Zo(r),a=oo({dataKey:t,syncKey:n});i.push(Qo(o,a,t))}const c=o.map(e=>{const r=Ho(JSON.parse(ln(e,t))),o=(i=e.created,a=n.get(r.id),null==i?a:null==a?i:new Date(Math.min(i.valueOf(),a.valueOf())));var i,a;return null!=o&&n.set(r.id,o),r});return ti([...i,...c]).map(e=>ri(e))}function ri(e){const{id:t,keys:n,type:r}=e,o={"wallet:bitcoin-bip44":{format:"bip44",coinType:0},"wallet:bitcoin-bip49":{format:"bip49",coinType:0},"wallet:bitcoincash-bip32":{format:"bip32"},"wallet:bitcoincash-bip44":{format:"bip44",coinType:145},"wallet:bitcoincash-bip44-testnet":{format:"bip44",coinType:1},"wallet:bitcoin-bip44-testnet":{format:"bip44",coinType:1},"wallet:bitcoin-bip49-testnet":{format:"bip49",coinType:1},"wallet:dash-bip44":{format:"bip44",coinType:5},"wallet:dogecoin-bip44":{format:"bip44",coinType:3},"wallet:litecoin-bip44":{format:"bip44",coinType:2},"wallet:litecoin-bip49":{format:"bip49",coinType:2},"wallet:feathercoin-bip49":{format:"bip49",coinType:8},"wallet:feathercoin-bip44":{format:"bip44",coinType:8},"wallet:qtum-bip44":{format:"bip44",coinType:2301},"wallet:ufo-bip49":{format:"bip49",coinType:202},"wallet:ufo-bip84":{format:"bip84",coinType:202},"wallet:zcoin-bip44":{format:"bip44",coinType:136},"wallet:bitcoin-testnet":{format:"bip32"},"wallet:bitcoin":{format:"bip32"},"wallet:bitcoincash-testnet":{format:"bip32"},"wallet:litecoin":{format:"bip32",coinType:2},"wallet:zcoin":{format:"bip32",coinType:136}};return null!=o[r]?{id:t,keys:Jo(Jo({},o[r]),n),type:r.replace(/-bip[0-9]+/,"")}:e}async function oi(e,t,n){const{importText:r,keyOptions:o,keys:i}=n;function a(n,r){return null!=r&&(n=Jo(Jo({},n),{},{imported:r})),ri(Qo(t,Jo(Jo({},oo(io(e))),n)))}if(null!=i)return a(i);const s=eo(e.props.state.plugins.currency,t),c=await no(e,s);if(null!=r){if(null==c.importPrivateKey)throw new Error("This wallet does not support importing keys");return a(await c.importPrivateKey(r,o),!0)}return a(await c.createPrivateKey(t,o),!1)}async function ii(e,t,n,r){const{enabledTokenIds:o,fiatCurrencyCode:i,migratedFromWalletId:a,name:s}=r,c=await $o(e,n);return null!=a&&await Wo(e,t,{[n]:{migratedFromWalletId:a}}),null!=s&&await c.renameWallet(s),null!=i&&await c.setFiatCurrencyCode(i),null!=o&&o.length>0&&await c.changeEnabledTokenIds(o),c}const ai=Tn;function si(e,t){return e+t}async function ci(e,t,n,r){return await async function(e,t,n,r){const{now:o=new Date}=r,{passwordBox:i,passwordKeySnrp:a,username:s}=t;if(null==i||null==a||null==s)throw new Error("Missing data for offline password login");const c=si(s,n),u=await An(e,c,a),l={loginId:t.loginId,loginKey:dn(i,u)};t.lastLogin=o,jn(e,t).catch(()=>{});const{log:d}=e.props;return er(e,l).catch(e=>d.error(e)),l}(e,t,n,r).catch(()=>async function(e,t,n,r){const{username:o}=t;if(null==o)throw new Error("Password login requires a username");const i=si(o,n),[a,s]=await Promise.all([Cn(e,o),An(e,i,ai)]),c={userId:a,passwordAuth:s};return await Xn(e,t,t,r,c,async t=>{const{passwordBox:n,passwordKeySnrp:r}=t;if(null==n||!0===n||null==r)throw new Error("Missing data for online password login");return dn(n,await An(e,i,r))})}(e,t,n,r))}async function ui(e,t,n,r){const o=si(n,r),{io:i}=e.props,[{passwordKeySnrp:a,passwordBox:s},{passwordAuth:c,passwordAuthBox:u}]=await Promise.all([On(e).then(async n=>{const r=await An(e,o,n);return{passwordKeySnrp:n,passwordBox:fn(i,t.loginKey,r)}}),An(e,o,ai).then(e=>({passwordAuth:e,passwordAuthBox:fn(i,e,t.loginKey)}))]);return{loginId:t.loginId,server:ft({passwordAuth:c,passwordAuthSnrp:ai,passwordKeySnrp:a,passwordBox:s,passwordAuthBox:u}),serverPath:"/v2/login/password",stash:{passwordKeySnrp:a,passwordBox:s,passwordAuthBox:u}}}function li(e,t){return an(null==t?Uint8Array.from([0]):Bt.parse(t),e)}function di(e,t){return an(Bt.parse(t),e)}function fi(e,t){if(null!=e.pin2Key)return e;const n=zn(e,e=>e.appId===t);return null!=(null==n?void 0:n.pin2Key)?n:void 0}async function pi(e,t,n,r,o){if(null==n.pin2Key)throw new zt("PIN login is not enabled for this account on this device");const{pin2Key:i}=n,a={pin2Id:li(i,t.username),pin2Auth:di(i,r)};return await Xn(e,t,n,o,a,async e=>{if(null==e.pin2Box||!0===e.pin2Box)throw new Error("Missing data for PIN v2 login");return dn(e.pin2Box,i)})}async function hi(e,t,n){const r=e.props.state.accounts[t],o=r.activeAppId.endsWith(".duress"),{loginTree:i,login:a,sessionKey:s}=r,{username:c}=r.stashTree;let{pin:u,enableLogin:l,forDuressAccount:d=!1}=n;if(null==l&&(l=null!=i.pin2Key||null!=u&&null==i.pin),null==u&&(u=a.pin),o&&!d)return await Qn(e,s,bi(e,i,c,l,!0)),void(null!=u&&await Qn(e,s,yi(e,i,c,u,!0,!0)));if(null==u){if(l)throw new Error("Please change your PIN in the settings area above before enabling.");return void(await Qn(e,s,wi(i,d||o)))}const f=yi(e,i,c,u,l,d||o);await Qn(e,s,f)}function yi(e,t,n,r,o,i){const a=[];i===t.appId.endsWith(".duress")&&a.push(gi(e,t,n,r,o));for(const s of t.children)a.push(...yi(e,s,n,r,o,i));return a}function bi(e,t,n,r,o){const i=[];o===t.appId.endsWith(".duress")&&i.push(function(e,t){const{loginId:n}=e;return{loginId:n,server:void 0,serverPath:"",stash:{fakePinDisabled:!t}}}(t,r));for(const a of t.children)i.push(...bi(e,a,n,r,o));return i}function gi(e,t,n,r,o){const{io:i}=e.props,a=fn(i,Bt.parse(r),t.loginKey);if(o){const{loginId:e,loginKey:o,pin2Key:s=i.random(32)}=t,c=fn(i,o,s),u=fn(i,s,o);return{loginId:e,server:ht({pin2Id:li(s,n),pin2Auth:di(s,r),pin2Box:c,pin2KeyBox:u,pin2TextBox:a}),serverPath:"/v2/login/pin2",stash:{pin2Key:s,pin2TextBox:a}}}return{loginId:t.loginId,server:ht({pin2Id:void 0,pin2Auth:void 0,pin2Box:void 0,pin2KeyBox:void 0,pin2TextBox:a}),serverPath:"/v2/login/pin2",stash:{pin2Key:void 0,pin2TextBox:a}}}function wi(e,t){const n=[];null!=t&&t!==e.appId.endsWith(".duress")||n.push(function(e){return{loginId:e.loginId,server:void 0,serverMethod:"DELETE",serverPath:"/v2/login/pin2",stash:{pin2Key:void 0}}}(e));for(const r of e.children)n.push(...wi(r,t));return n}function vi(e,t){return an(Bt.parse(t),e)}function mi(e,t){return t.map(t=>an(Bt.parse(t),e))}async function Ii(e,t,n,r){const o=e.props.state.accounts[t],{loginTree:i,sessionKey:a}=o,{username:s}=o.stashTree;if(null==s)throw new Error("Recovery login requires a username");const c=function(e,t,n,r,o){const{io:i}=e.props;if(!Array.isArray(r))throw new TypeError("Questions must be an array of strings");if(!Array.isArray(o))throw new TypeError("Answers must be an array of strings");const{loginId:a,loginKey:s,recovery2Key:c=i.random(32)}=t,u=fn(i,Bt.parse(JSON.stringify(Si(r))),c),l=fn(i,s,c),d=fn(i,c,s);return{loginId:a,server:bt({recovery2Id:vi(c,n),recovery2Auth:mi(c,o),recovery2Box:l,recovery2KeyBox:d,question2Box:u}),serverPath:"/v2/login/recovery2",stash:{recovery2Key:c}}}(e,i,s,n,r);await Zn(e,a,c)}const Ei=ge(pe),Si=Ee(Ei);function Oi(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Ai(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Oi(Object(n),!0).forEach(function(t){r(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Oi(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}async function Ti(e,t,n){var r,o,i,a;const{password:s,username:c}=n,{isRoot:u,loginId:l,passwordAuth:d}=t;if(null!=d&&null==s)throw new Error("A password is required to change the username");const f=function(e,t){const{loginId:n,pin2Key:r}=e;if(null!=r)return{loginId:n,server:pt({pin2Id:li(r,t)}),serverPath:"",stash:{}}}(t,c),p=function(e,t){const{loginId:n,recovery2Key:r}=e;if(null!=r)return{loginId:n,server:yt({recovery2Id:vi(r,t)}),serverPath:"",stash:{}}}(t,c);let h,y;if(null!=s&&(h=await ui(e,t,c,s)),u&&(y=await _i(e,t,c)),null!=h||null!=f||null!=p||null!=y)return{loginId:l,server:Ai(Ai(Ai(Ai({},null===(r=h)||void 0===r?void 0:r.server),null==f?void 0:f.server),null==p?void 0:p.server),null===(o=y)||void 0===o?void 0:o.server),serverPath:"/v2/login/username",stash:Ai(Ai(Ai(Ai({},null===(i=h)||void 0===i?void 0:i.stash),null==f?void 0:f.stash),null==p?void 0:p.stash),null===(a=y)||void 0===a?void 0:a.stash)}}async function _i(e,t,n){const{io:r}=e.props,{loginId:o,loginKey:i}=t,a=await Cn(e,n);return{loginId:o,server:wt({userId:a,userTextBox:fn(r,Bt.parse(n),i)}),serverPath:"",stash:{userId:a,username:n}}}function ki(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function xi(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?ki(Object(n),!0).forEach(function(t){r(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ki(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}async function Pi(e,t,n,r){var o,i,a,s,c,u,l,d;const{keyInfo:f,password:p,pin:h,username:y}=r,{io:b}=e.props;e.props.log.breadcrumb("makeCreateKit",{});const g=null==t,w=b.random(32),v=b.random(32),m={loginId:w,loginKey:v},I={appId:n,lastLogin:new Date,loginId:w,loginKey:v,isRoot:g,pendingVouchers:[],children:[]},E=Sn(e,I);let S,O,A,T,_;null!=f&&(S=ei(e,m,[f])),null!=t&&(O=fn(b,v,t.loginKey)),null!=p&&null!=y&&(A=await ui(e,I,y,p)),null!=h&&(T=gi(e,I,y,h,!0)),g&&null!=y&&(_=await _i(e,I,y));return{kit:{loginId:w,server:xi(xi(xi(xi(xi(xi({},It({appId:n,loginId:w,parentBox:O})),null===(o=S)||void 0===o?void 0:o.server),null===(i=A)||void 0===i?void 0:i.server),null===(a=T)||void 0===a?void 0:a.server),E.server),null===(s=_)||void 0===s?void 0:s.server),serverPath:"/v2/login/create",stash:xi(xi(xi(xi(xi({appId:n,loginId:w,parentBox:O},null===(c=S)||void 0===c?void 0:c.stash),null===(u=A)||void 0===u?void 0:u.stash),null===(l=T)||void 0===l?void 0:l.stash),E.stash),null===(d=_)||void 0===d?void 0:d.stash)},sessionKey:m}}async function Mi(e,t,n,r){const{log:o}=e.props,i=zn(t,e=>e.appId===r);if(null==i)return e.props.log.breadcrumb("createChildLogin",{}),await async function(e,t,n,r){let o;null!=t.pin2TextBox&&(o=ln(t.pin2TextBox,n.loginKey));const{kit:i}=await Pi(e,n,r,{keyInfo:Qo(Zo(r),oo(io(e))),pin:o,username:t.username}),a={loginId:n.loginId,server:i.server,serverPath:i.serverPath,stash:{children:[i.stash]}};return await Zn(e,n,a)}(e,t,n,r);const a=tr(t,n,i.loginId),s=ni(i,a.loginKey);o.warn(`Login: decrypted keys for user ${w(t.loginId)}`);const c=Zo(r);if(null==Xo(s,c)){e.props.log.breadcrumb("createAccountRepo",{});const t=ei(e,a,[Qo(c,oo(io(e)))]);return await Zn(e,n,t)}return t}async function Ci(e,t,n,r){const{pauseWallets:o=!1}=r,i=!0===r.duressMode?e.props.state.login.contextAppId+".duress":e.props.state.login.contextAppId,{log:a}=e.props;e.props.log.breadcrumb("makeAccount",{});const{stashTree:s}=xn(e,t.loginId);return await Mi(e,s,t,i),a.warn("Login: account exists for appId"),e.props.dispatch({type:"LOGIN",payload:{appId:i,loginType:n,pauseWallets:o,rootLoginId:s.loginId,sessionKey:t}}),await function(e,t){const n=e.waitFor(e=>{const n=e.state.accounts[t];if(null!=n.loadFailure)throw n.loadFailure;const r=e.output.accounts[t];if(null!=(null==r?void 0:r.accountApi))return r.accountApi});return n}(e,e.props.state.lastAccountId)}var Ni=n(6729);function ji(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Di(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?ji(Object(n),!0).forEach(function(t){r(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ji(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}const Ri=new(0,n.n(Ni)().ec)("secp256k1");function Li(e,t){const n=e.derive(Ri.keyFromPublic(t).getPublic()).toArray("be");return an(Uint8Array.from([0,0,0,1,...n]),Bt.parse("dataKey"))}function Bi(e,t){const{publicKey:n}=t,r=Li(e,n);return JSON.parse(ln(t.box,r))}function Ki(e,t,n){const r=Ri.genKeyPair({entropy:e.random(32)}),o=Li(r,t);return{publicKey:Uint8Array.from(r.getPublic().encodeCompressed()),box:fn(e,Bt.parse(JSON.stringify(n)),o)}}async function Ui(e,t,n=1e3){const{io:r}=e.props,{timeout:o=600}=t,i=Ri.genKeyPair({entropy:r.random(32)}),a=Uint8Array.from(i.getPublic().encodeCompressed()),s=Lt.stringify(sn(sn(a)).slice(0,10)),c={data:ct(Di(Di({},t),{},{publicKey:a,timeout:o}))};await In(e,"PUT",`/v2/lobby/${s}`,c);const[u,l]=(d={},[function(e,t){var n=d[e];return null==n&&(n=d[e]=function(){var e=[],t=!1;function n(){t&&(t=!1,e=e.slice())}return[function(t){n(),e.push(t);var r=!0;return function(){r&&(r=!1,n(),e.splice(e.indexOf(t),1))}},function(n){t=!0;for(var r=e,o=0;o<r.length;++o)r[o](n);t=!1}]}()),n[0](t)},function(e,t){var n=d[e];null!=n&&n[1](t)}]);var d;const f=[],p=Zr(async()=>{const t=Xe(await In(e,"GET","/v2/lobby/"+s));for(;f.length<t.replies.length;){const e=t.replies[f.length],n=Bi(i,e);l("reply",n),f.push(n)}},n,{onError(e){l("error",e)}});return p.start({wait:!1}),{close:()=>p.stop(),lobbyId:s,on:u,replies:f}}async function Fi(e,t){const n=Xe(await In(e,"GET","/v2/lobby/"+t)),{publicKey:r}=n.request,o=sn(sn(r)),i=Lt.parse(t);if(!cn(i,o.subarray(0,i.length)))throw new Error("Lobby ECDH integrity error");return n.request}async function Wi(e,t,n,r){const{io:o}=e.props,{publicKey:i}=n,a={data:st(Ki(o,i,r))};await In(e,"POST","/v2/lobby/"+t,a)}const Gi=we({appId:pe,loginKey:ke,loginStash:Dn});async function zi(e,t,n={}){function r(e){for(const t of a)t();s.state="error",s.error=e,G(s),F(s)}async function o(r){for(const e of a)e();const o=Gi(r),{username:i}=o.loginStash;s.state="started",s.username=i,G(s);const c=await async function(e,t,n,r){const{now:o=new Date}=r,{loginKey:i,loginStash:a}=t;e.props.log.breadcrumb("unpackAccount",{});const s=zn(a,e=>e.appId===n);if(null==s)throw new Error(`Cannot find requested appId: "${n}"`);try{const t=xn(e,s.loginId);s.voucherId=t.stash.voucherId,s.voucherAuth=t.stash.voucherAuth}catch(u){}a.lastLogin=o,await jn(e,a);const c={loginId:s.loginId,loginKey:i};return await er(e,c),await Ci(e,c,"edgeLogin",r)}(e,o,t,n);s.state="done",s.account=c,G(s),F(s)}const i=await Ui(e,{loginRequest:{appId:t}}),a=[i.close,i.on("error",function(e){s.error=e,G(s)}),i.on("reply",e=>{o(e).catch(r)})],s={id:i.lobbyId,cancelRequest:async function(){for(const e of a)e();s.state="closed",G(s),F(s)},watch:ee,state:"pending",account:void 0,error:void 0,username:void 0};return P(s)}const qi=Ee(Gi),$i=we({appName:pe,darkImageUrl:ue(pe),lightImageUrl:ue(pe),imageUrl:ue(pe)});async function Hi(e,t){try{const[n]=Io(e.props.state.infoServers),r=`${n}/v1/appIdInfo/${t}`,o=await e.props.io.fetch(r,{corsBypass:"never"});if(404===o.status)return{appName:t};if(!o.ok)throw new Error(`Fetching ${r} returned ${o.status}`);const i=$i(await o.json());return null==i.lightImageUrl&&(i.lightImageUrl=i.imageUrl),null==i.darkImageUrl&&(i.darkImageUrl=i.imageUrl),i}catch(n){return e.props.onError(n),{appName:t}}}async function Yi(e,t,n){const r=await Fi(e,n);let o;null!=r.loginRequest&&(o=await async function(e,t,n,r,o){e.props.log.breadcrumb("unpackLoginRequest",{});const i=await Hi(e,o),a={appId:o,displayName:i.appName,displayImageDarkUrl:i.darkImageUrl,displayImageLightUrl:i.lightImageUrl,approve(){return async function(e,t,n,r,o){const{sessionKey:i}=e.props.state.accounts[t];e.props.log.breadcrumb("approveLoginRequest",{}),await er(e,i);const{stashTree:a}=xn(e,i.loginId),s=await Mi(e,a,i,n),c=zn(s,e=>e.appId===n);if(null==c)throw new Error("Failed to create the requested login object");const u=tr(s,i,c.loginId),l=qi({appId:n,loginKey:u.loginKey,loginStash:Jn(s,n)});let d;await Wi(e,r,o,l);const f=e.props.output.accounts[t].accountApi;null!=f&&f.on("close",()=>{null!=d&&clearTimeout(d)}),d=setTimeout(()=>{d=void 0,er(e,i).then(()=>{d=setTimeout(()=>{d=void 0,er(e,i).catch(t=>e.props.onError(t))},2e4)}).catch(t=>e.props.onError(t))},1e4)}(e,t,o,n,r)},async close(){F(a)}};return P(a),a}(e,t,n,r,r.loginRequest.appId));const i={loginRequest:o};return P(i),i}var Vi=n(6001);function Ji(e){var t;const{currencyInfo:n,allTokens:r}=e;let o=e.tokenId;void 0===o&&null!=e.currencyCode&&e.currencyCode!==n.currencyCode&&(o=Object.keys(r).find(t=>r[t].currencyCode===e.currencyCode));const{currencyCode:i}=null==o?n:r[o];return{currencyCode:i,tokenId:null!==(t=o)&&void 0!==t?t:null}}function Xi(e){return null!=e.networkFee&&void 0===e.networkFee.tokenId&&(e.networkFee.tokenId=null),e}const Zi=e=>{null!=e.networkFees&&0!==e.networkFees.length||(e.networkFees=[{tokenId:e.tokenId,nativeAmount:e.networkFee}],null!=e.parentNetworkFee&&e.networkFees.push({tokenId:null,nativeAmount:e.parentNetworkFee}))};function Qi(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function ea(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Qi(Object(n),!0).forEach(function(t){r(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Qi(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}const ta=_r(Co),na=_r(Mo),ra="CustomTokens.json",oa=me(we({contractAddress:pe}));async function ia(e,t,n){const r=await no(e,t);if(null!=r.getTokenId)return await r.getTokenId(n);const o=function(e,t){for(const n of Object.keys(e.props.state.currency.wallets)){const r=e.props.output.currency.wallets[n];if(null!=(null==r?void 0:r.engine)&&e.props.state.currency.wallets[n].pluginId===t)return r.engine}}(e,t);if(null==o)throw new Error("A wallet must exist before adding tokens to a legacy currency plugin");if(null==o.addCustomToken)throw new Error(`${t} doesn't support tokens`);const i=ua(n);if(null==i)throw new Error("A token must have a contract address to be added to a legacy currency plugin");return await o.addCustomToken(ea(ea({},i),n)),aa(i.contractAddress)}function aa(e){return e.toLowerCase().replace(/^0x/,"")}function sa(e){const{currencyCode:t,displayName:n,denominations:r,networkLocation:o}=e,i=oa(o);return{currencyCode:t,currencyName:n,denominations:r,contractAddress:null==i?void 0:i.contractAddress}}function ca(e={}){const t=[];for(const n of Object.keys(e))t.push(sa(e[n]));return t}function ua(e){const{currencyCode:t,displayName:n,denominations:r,networkLocation:o}=e,i=oa(o);if(null!=i)return{currencyCode:t,currencyName:n,multiplier:r[0].multiplier,contractAddress:i.contractAddress}}async function la(e,t){const{dispatch:n,state:r}=e.props;await Promise.all(Object.keys(r.plugins.currency).map(async e=>{var o;const i=r.plugins.currency[e],a=null==i.getBuiltinTokens?function(e){const t={};for(const n of e){const{contractAddress:e}=n;null!=e&&(t[aa(e)]={currencyCode:n.currencyCode,denominations:n.denominations,displayName:n.currencyName,networkLocation:{contractAddress:n.contractAddress}})}return t}(null!==(o=i.currencyInfo.metaTokens)&&void 0!==o?o:[]):await i.getBuiltinTokens();n({type:"ACCOUNT_BUILTIN_TOKENS_LOADED",payload:{accountId:t,pluginId:e,tokens:a}})}))}async function da(e,t){const{dispatch:n,state:r}=e.props,{accountWalletInfo:o}=r.accounts[t],i=Eo(r,o.id),a=await ta.load(i,ra);if(null!=a){const{customTokens:e}=a;n({type:"ACCOUNT_CUSTOM_TOKENS_LOADED",payload:{accountId:t,customTokens:e}})}else{const r=await async function(e,t){const{state:n}=e.props,{accountWalletInfo:r}=n.accounts[t],o=Eo(n,r.id),i=await na.load(o,"Settings.json");if(null==i)return{};const a={};for(const s of i.customTokens){if(!s.isVisible)continue;const e=to(n.plugins.currency,s.walletType);if(null==e)continue;null==a[e]&&(a[e]={});const t=aa(s.contractAddress);a[e][t]={currencyCode:s.currencyCode,denominations:s.denominations,displayName:s.currencyName,networkLocation:{contractAddress:s.contractAddress}}}return a}(e,t);n({type:"ACCOUNT_CUSTOM_TOKENS_LOADED",payload:{accountId:t,customTokens:r}})}}function fa(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function pa(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?fa(Object(n),!0).forEach(function(t){r(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):fa(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function ha(e,t){const{id:n,type:r,keys:o}=e,i=me(ro)(o);if(null==i)throw new Error(`Wallet ${n} is not a splittable type`);const{dataKey:a,syncKey:s}=i,c=ba(an(Bt.parse(r),a),an(Bt.parse(t),a)),u=ba(g(n),c),l=ba(s,c.subarray(0,s.length)),d=r.replace(/wallet:/,"").replace("-",""),f=t.replace(/wallet:/,"").replace("-",""),p=oo({dataKey:a,syncKey:l});for(const h of Object.keys(o)){const e=h===d+"Key"?f+"Key":h;null==p[e]&&(p[e]=o[h])}return{id:w(u),keys:p,type:t}}async function ya(e,t,n,r,o){const i=e.props.state.accounts[t],{allWalletInfosFull:a,sessionKey:s}=i,c=e.props.state.plugins.currency,u=new Map;for(const h of r){const{walletType:e}=h;if(null==to(c,h.walletType))throw new Error(`Cannot find plugin for wallet type "${e}"`);if(u.has(e))throw new Error(`Duplicate wallet type "${e}"`);u.set(e,ha(n,e))}if("wallet:bitcoincash"===n.type&&u.has("wallet:bitcoinsv")){var l;const t=null===(l=e.props.output)||void 0===l||null===(l=l.currency)||void 0===l||null===(l=l.wallets[n.id])||void 0===l?void 0:l.walletApi;if(null==t)throw new Error(`Cannot find wallet ${n.id}`);await async function(e){const t={currencyCode:"BCH",tokenId:null},n=pa(pa({},t),{},{spendTargets:[{nativeAmount:"10000",otherParams:{script:{type:"replayProtection"}},publicAddress:""}],metadata:{},networkFeeOption:"high"}),r=await e.makeSpend(n),o=await e.signTx(r),i=await e.broadcastTx(o);await e.saveTx(i);const{publicAddress:a}=await e.getReceiveAddress(t),s=pa(pa({},t),{},{metadata:{name:"Replay Protection Tx",notes:"This transaction is to protect your BCH wallet from unintentionally spending BSV funds. Please wait for the transaction to confirm before making additional transactions using this BCH wallet."},networkFeeOption:"high",spendTargets:[{publicAddress:a,nativeAmount:"0"}]}),c=await e.getMaxSpendable(s);s.spendTargets[0].nativeAmount=c;const u=await e.makeSpend(s),l=await e.signTx(u),d=await e.broadcastTx(l);await e.saveTx(d)}(t)}const d=[],f=[];for(const h of u.values()){const e=a.find(e=>e.id===h.id);if(null==e)f.push(h);else if(e.archived||e.deleted)d.push(e);else if(o&&("wallet:bitcoincash"!==n.type||"wallet:bitcoinsv"!==h.type))throw new Error(`This wallet has already been split (${h.type})`)}if(d.length>0){const n={};for(const e of d)n[e.id]={archived:!1,deleted:!1,migratedFromWalletId:e.migratedFromWalletId};await Wo(e,t,n)}if(f.length>0){const t=ei(e,s,f,!0);await Zn(e,s,t)}const p=await Promise.all(r.map(async t=>{const n=u.get(t.walletType);if(null==n)throw new Error(`Missing wallet info for ${t.walletType}`);return await vo(async function(e,t,n){const r=await $o(e,t);null!=(null==n?void 0:n.name)&&await r.renameWallet(n.name).catch(t=>e.props.onError(t));null!=(null==n?void 0:n.fiatCurrencyCode)&&await r.setFiatCurrencyCode(n.fiatCurrencyCode).catch(t=>e.props.onError(t));return r}(e,n.id,null!=f.find(e=>e.type===t.walletType)?t:void 0))}));return p}function ba(e,t){if(e.length!==t.length)throw new Error(`Array lengths do not match: ${e.length}, ${t.length}`);const n=new Uint8Array(e.length);for(let r=0;r<e.length;++r)n[r]=e[r]^t[r];return n}function ga(e,t){const{id:n,type:r,keys:o}=t;return{id:n,type:r,keys:o,get disklet(){return Eo(e.props.state,n)},get localDisklet(){return So(e.props.state,n)},async sync(){await wo(e,n)}}}const wa={"[object Float32Array]":!0,"[object Float64Array]":!0,"[object Int16Array]":!0,"[object Int32Array]":!0,"[object Int8Array]":!0,"[object Uint16Array]":!0,"[object Uint32Array]":!0,"[object Uint8Array]":!0,"[object Uint8ClampedArray]":!0};function va(e,t){if(e===t)return!0;if("object"!=typeof e)return!1;if("object"!=typeof t)return!1;const n=Object.prototype.toString.call(e);return n===Object.prototype.toString.call(t)&&function(e,t,n){if("[object Object]"===n){if(Object.getPrototypeOf(e)!==Object.getPrototypeOf(t))return!1;const n=Object.getOwnPropertyNames(e);if(n.length!==Object.getOwnPropertyNames(t).length)return!1;for(const r of n)if(!Object.prototype.hasOwnProperty.call(t,r)||!va(e[r],t[r]))return!1;return!0}if("[object Array]"===n){if(e.length!==t.length)return!1;for(let n=0;n<e.length;++n)if(!va(e[n],t[n]))return!1;return!0}if("[object Date]"===n)return e.getTime()===t.getTime();if("[object Map]"===n)return function(e,t){if(e.size!==t.size)return!1;for(const[n,r]of e)if(!t.has(n)||t.get(n)!==r)return!1;return!0}(e,t);if(wa[n]){if(e.length!==t.length)return!1;for(let n=0;n<e.length;++n)if(e[n]!==t[n])return!1;return!0}return!1}(e,t,n)}let ma=500,Ia=3;const Ea=[];let Sa;function Oa(e){Ea.length<=0&&Aa();let t=!1;for(const n of Ea)if(n.id===e.id&&n.action===e.action){n.updateFunc=e.updateFunc,t=!0;break}t||Ea.push(e)}function Aa(){Sa=setTimeout(()=>{const e=Math.min(Ia,Ea.length);for(let t=0;t<e;t++){const e=Ea.shift();null!=e&&e.updateFunc()}Ea.length>0&&Aa()},ma)}function Ta(e,t){var n,r,o,i,a,s;const c={exchangeAmount:{}},{exchangeAmount:u={}}=c,l=null!==(n=e.exchangeAmount)&&void 0!==n?n:{},d=null!==(r=t.exchangeAmount)&&void 0!==r?r:{};for(const f of Object.keys(l))null!==d[f]&&(u[f]=l[f]);for(const f of Object.keys(d)){const e=d[f];null!=e&&(u[f]=e)}return null!==t.bizId&&(c.bizId=null!==(o=t.bizId)&&void 0!==o?o:e.bizId),null!==t.category&&(c.category=null!==(i=t.category)&&void 0!==i?i:e.category),null!==t.name&&(c.name=null!==(a=t.name)&&void 0!==a?a:e.name),null!==t.notes&&(c.notes=null!==(s=t.notes)&&void 0!==s?s:e.notes),c}const _a=we({bizId:ue(fe),category:ue(pe),exchangeAmount:ue(we(fe)),name:ue(pe),notes:ue(pe)}),ka=ve(pe,he),xa=le("high","standard","low"),Pa=we({orderId:ue(pe),orderUri:ue(pe),isEstimate:de,plugin:we({pluginId:pe,displayName:pe,supportEmail:ue(pe)}),payoutAddress:pe,payoutCurrencyCode:pe,payoutTokenId:ue(ka),payoutNativeAmount:pe,payoutWalletId:pe,refundAddress:ue(pe)});function Ma(e){const t=pe(e);if(!/^\d+$/.test(t))throw new Error("Expected an integer string");return t}const Ca=we({pluginId:pe,tokenId:ka,nativeAmount:ue(Ma)}),Na=we({fiatCurrencyCode:pe,fiatAmount:pe}),ja=we({pluginId:pe,displayName:pe,isDex:ue(de),orderUri:ue(pe),supportEmail:pe}),Da=ve(we({actionType:le("swap"),swapInfo:ja,orderId:ue(pe),orderUri:ue(pe),isEstimate:ue(de),canBePartial:ue(de),fromAsset:Ca,toAsset:Ca,payoutWalletId:pe,payoutAddress:pe,refundAddress:ue(pe)}),we({actionType:le("stake"),pluginId:pe,stakeAssets:ge(Ca)}),we({actionType:le("fiat"),orderId:pe,orderUri:ue(pe),isEstimate:de,fiatPlugin:we({providerId:pe,providerDisplayName:pe,supportEmail:ue(pe)}),payinAddress:ue(pe),payoutAddress:ue(pe),fiatAsset:Na,cryptoAsset:Ca}),we({actionType:le("tokenApproval"),tokenApproved:Ca,tokenContractAddress:pe,contractAddress:pe}),we({actionType:le("giftCard"),orderId:pe,orderUri:ue(pe),productId:ue(pe),quoteId:ue(pe),provider:we({providerId:pe,displayName:pe,supportEmail:ue(pe)}),card:we({name:pe,imageUrl:ue(pe),fiatAmount:pe,fiatCurrencyCode:pe}),redemption:ue(we({code:ue(pe),url:ue(pe)}))})),Ra=we({assetActionType:le("claim","claimOrder","stake","stakeNetworkFee","stakeOrder","unstake","unstakeNetworkFee","unstakeOrder","swap","swapNetworkFee","swapOrderPost","swapOrderFill","swapOrderCancel","buy","sell","sellNetworkFee","tokenApproval","transfer","transferNetworkFee","giftCard")}),La=ge(pe),Ba=we({enabledTokenIds:ge(pe),detectedTokenIds:ge(pe)}),Ka=we({walletSettings:ue(kr,()=>({}))}),Ua=we({assetAction:ue(Ra),metadata:e=>{const t=_a(e),{exchangeAmount:n={}}=t;for(const r of Object.keys(n))String(n[r]).includes("e")&&delete n[r];return t},nativeAmount:ue(pe),providerFeeSent:ue(pe)}),Fa=we({txid:pe,internal:de,creationDate:fe,currencies:function(e){const t=we(e);return Ie(e=>{const n=t(e),r=new Map;for(const t of Object.keys(n))r.set(t,n[t]);return r},e=>{const n={};return e.forEach((e,t)=>{n[t]=e}),t(n)})}(Ua),tokens:ue(function(e){const t=we(e);return Ie(e=>{const n=t(e),r=new Map;for(const t of Object.keys(n))r.set(""===t?null:t,n[t]);return r},e=>{const n={};return e.forEach((e,t)=>{n[null==t?"":t]=e}),t(n)})}(Ua),()=>new Map),deviceDescription:ue(pe),feeRateRequested:ue(ve(xa,kr)),feeRateUsed:ue(kr),payees:ue(ge(we({address:pe,amount:pe,currency:pe,tag:ue(pe)}))),savedAction:ue(Da),secret:ue(pe),swap:ue(Pa)}),Wa=we({airbitzFeeWanted:fe,meta:we({amountFeeAirBitzSatoshi:fe,balance:fe,fee:fe,amountCurrency:fe,bizId:fe,category:pe,name:pe,notes:pe,attributes:fe,amountSatoshi:fe,amountFeeMinersSatoshi:fe,airbitzFee:fe}),ntxid:pe,state:we({creationDate:fe,internal:de,malleableTxId:pe})}),Ga=we({seq:fe,address:pe,state:we({recycleable:ue(de,!0),creationDate:ue(fe,0)}),meta:we({amountSatoshi:ue(fe,0)}).withRest}),za=we(we({timestamp:fe,txidHash:pe})),qa=we({walletInfo:we({id:pe,keys:kr,type:pe})}),$a=we({checkpoint:ue(pe),subscribedAddresses:ue(ge(we({address:pe,checkpoint:ue(pe)})),()=>[])}),Ha=we({fiat:ue(pe),num:ue(fe)}),Ya=we({walletName:ve(pe,he)});var Va="redux-keto wrapper";function Ja(e,t,n){for(var r=Object.create(null),o=function(){var e=a[i],o=t(e);Object.defineProperty(r,e,{configurable:!0,enumerable:!0,get:function(){var t=this,r=t[Va];if(r.running[e]){var i=new ReferenceError("Reducer '"+e+"' depends on its own result");throw i.name="ReduxKetoCircularReferenceError",i}r.running[e]=!0;try{var a=o(r.state[e],r.action,n(r.next,t,e),n(r.prev,r.state,e));if(void 0===a)throw new TypeError("Reducer '"+e+"' returned undefined");return Object.defineProperty(t,e,{configurable:!0,enumerable:!0,writable:!1,value:a}),a}finally{r.running[e]=!1}}})},i=0,a=e;i<a.length;i+=1)o();return r}function Xa(e,t,n,r,o){var i=Object.create(e);return Object.defineProperty(i,Va,{configurable:!0,enumerable:!1,writable:!1,value:{state:t,action:n,next:r,prev:o,running:{}}}),i}function Za(e,t){if(void 0===e&&(e={}),null===t||null==t[Va])return t;for(var n=Object.keys(Object.getPrototypeOf(t)),r=Object.keys(e).length===n.length,o=0,i=n;o<i.length;o+=1){var a=i[o];Object.defineProperty(t,a,{configurable:!1,enumerable:!0,writable:!1,value:Za(e[a],t[a])}),t[a]!==e[a]&&(r=!1)}return r?e:(delete t[Va],t)}function Qa(e,t,n){return void 0!==e?e:t}function es(e,t){if(void 0===t&&(t=Qa),"object"!=typeof e||null===e)throw new TypeError("The reducer map must be an object.");for(var n=Object.keys(e),r=0,o=n;r<o.length;r+=1){var i=o[r];if("function"!=typeof e[i])throw new TypeError("Reducers must be functions.")}for(var a=Ja(n,function(t){return e[t]},t),s={},c=0,u=n;c<u.length;c+=1){var l=u[c];s[l]=e[l].defaultState}function d(e,t,n,r){void 0===e&&(e=s);var o=Xa(a,e,t,n,r);return void 0===n?Za(e,o):o}return d.defaultState=s,d}function ts(e,t){return e}function ns(e){return e}function rs(e,t,n){void 0===t&&(t=ts),void 0===n&&(n=ns);var r=e.defaultState;function o(o,i,a,s){void 0===o&&(o=r);var c=t(i,a),u=n(a),l=n(s);if(!c)return o;var d=e(o,c,u,l);return void 0===a?Za(o,d):d}return o.defaultState=r,o}function os(e,t,n){return{id:n,root:void 0!==e?e:t,get self(){return t[n]}}}var is={};function as(e,t,n){function r(r,o,i,a){void 0===r&&(r=is);var s=t(i),c=Xa(r===is||s!==t(a)?Ja(s,function(t){return e},n):Object.getPrototypeOf(r),r,o,i,a);return void 0===i?Za(r,c):c}return void 0===n&&(n=os),r.defaultState=is,r}function ss(){for(var e=arguments,t=arguments.length-1,n=arguments[t],r=[];t-- >0;)r[t]=e[t];if("function"!=typeof n)throw new TypeError("The reducer must be a function");for(var o=0,i=r;o<i.length;o+=1){if("function"!=typeof i[o])throw new TypeError("Each argument filter must be a function")}return function(e,t,o,i){void 0===e&&(e=n.defaultState);for(var a=void 0!==e,s=[],c=0;c<r.length;++c)s[c]=r[c](o),a&&s[c]!==r[c](i)&&(a=!1);return a?e:n.apply(void 0,s)}}function cs(e){const t={};for(const n of Object.keys(e)){t[e[n].currencyCode]=n}return t}function us(e={},t={},n,r){const o=[];for(const a of r){var i;const n=null!==(i=t[a])&&void 0!==i?i:e[a];null!=n&&o.push(n.currencyCode)}return o}function ls(e,t=[]){const n=new Set(t),r=[];for(const o of e)n.has(o)||(n.add(o),r.push(o));return r}function ds(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function fs(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?ds(Object(n),!0).forEach(function(t){r(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ds(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}const ps={},hs=[],ys={totalRatio:0},bs=es({accountId(e,t,n){if(null!=e)return e;for(const r of Object.keys(n.root.accounts)){const e=n.root.accounts[r];for(const t of Object.keys(e.walletInfos))if(t===n.id)return r}throw new Error(`Cannot find account for walletId ${n.id}`)},allEnabledTokenIds:ss(e=>e.root.accounts[e.self.accountId].alwaysEnabledTokenIds[e.self.pluginId],e=>e.self.enabledTokenIds,(e=[],t=[])=>ls([...e,...t])),pluginId:ss(e=>e.root.login.walletInfos[e.id].type,e=>e.root.plugins.currency,(e,t)=>eo(t,e)),paused(e,t,n){return null==e?n.root.accounts[n.self.accountId].pauseWallets:"CURRENCY_WALLET_CHANGED_PAUSED"===t.type?t.payload.paused:e},currencyInfo(e,t,n){if(null!=e)return e;const{pluginId:r}=n.self;return n.root.plugins.currency[r].currencyInfo},detectedTokenIds:ms((e=hs,t)=>{if("CURRENCY_WALLET_LOADED_TOKEN_FILE"===t.type)return t.payload.detectedTokenIds;if("CURRENCY_ENGINE_DETECTED_TOKENS"===t.type){const{detectedTokenIds:n}=t.payload;return ls([...e,...n])}return"CURRENCY_ENGINE_CLEARED"===t.type?[]:e}),enabledTokenIds:ms((e=hs,t)=>{if("CURRENCY_WALLET_LOADED_TOKEN_FILE"===t.type)return t.payload.enabledTokenIds;if("CURRENCY_WALLET_ENABLED_TOKENS_CHANGED"===t.type)return t.payload.enabledTokenIds;if("CURRENCY_ENGINE_DETECTED_TOKENS"===t.type){const{enablingTokenIds:n}=t.payload;return ls([...e,...n])}return e}),changeServiceSubscriptions(e=[],t){if("CURRENCY_ENGINE_UPDATE_CHANGE_SERVICE_SUBSCRIPTIONS"===t.type){return[...e.filter(e=>!t.payload.subscriptions.some(t=>t.address===e.address)),...t.payload.subscriptions]}return"CURRENCY_WALLET_LOADED_SUBSCRIBED_ADDRESSES"===t.type?t.payload.subscribedAddresses:e},tokenFileDirty(e=!1,t,n,r){switch(t.type){case"CURRENCY_WALLET_LOADED_TOKEN_FILE":case"CURRENCY_WALLET_SAVED_TOKEN_FILE":return!1;case"CURRENCY_ENGINE_CLEARED":case"CURRENCY_ENGINE_DETECTED_TOKENS":case"CURRENCY_WALLET_ENABLED_TOKENS_CHANGED":return n.self.detectedTokenIds!==r.self.detectedTokenIds||n.self.enabledTokenIds!==r.self.enabledTokenIds;default:return e}},tokenFileLoaded(e=!1,t){switch(t.type){case"CURRENCY_WALLET_LOADED_TOKEN_FILE":return!0;case"CURRENCY_ENGINE_CLEARED":return!1;default:return e}},walletSettings(e=ps,t){switch(t.type){case"CURRENCY_WALLET_LOADED_WALLET_SETTINGS_FILE":case"CURRENCY_WALLET_CHANGED_WALLET_SETTINGS":return t.payload.walletSettings;default:return e}},engineFailure(e=null,t){if("CURRENCY_ENGINE_FAILED"===t.type){const{error:e}=t.payload;return e instanceof Error?e:new Error(String(e))}return e},engineStarted(e=!1,t){return"CURRENCY_ENGINE_STARTED"===t.type||"CURRENCY_ENGINE_STOPPED"!==t.type&&e},fiat(e="",t){return"CURRENCY_WALLET_FIAT_CHANGED"===t.type?t.payload.fiatCurrencyCode:e},fiatLoaded(e=!1,t){return"CURRENCY_WALLET_FIAT_CHANGED"===t.type||e},files(e={},t){switch(t.type){case"CURRENCY_WALLET_FILE_CHANGED":{const{json:n,txidHash:r}=t.payload,o=fs({},e);return o[r]=n,o}case"CURRENCY_WALLET_FILES_LOADED":{const{files:n}=t.payload;return fs(fs({},e),n)}}return e},fileNames(e={},t){switch(t.type){case"CURRENCY_WALLET_FILE_NAMES_LOADED":{const{txFileNames:n}=t.payload;return fs(fs({},e),n)}case"CURRENCY_WALLET_FILE_CHANGED":{const{fileName:n,creationDate:r,txidHash:o}=t.payload;return(null==e[o]||r<e[o].creationDate)&&(e[o]={creationDate:r,fileName:n}),e}}return e},syncStatus(e=ys,t){switch(t.type){case"CURRENCY_ENGINE_CHANGED_SYNC_STATUS":return t.payload.status;case"CURRENCY_ENGINE_CLEARED":return ys}return e},balanceMap(e=new Map,t){if("CURRENCY_ENGINE_CHANGED_BALANCE"===t.type){const{balance:n,tokenId:r}=t.payload,o=new Map(e);return o.set(r,n),o}return e},balances:ss(e=>e.self.balanceMap,e=>e.self.currencyInfo,e=>e.root.accounts[e.self.accountId].allTokens[e.self.pluginId],(e,t,n)=>{const r={};for(const o of e.keys()){const i=e.get(o),{currencyCode:a}=null==o?t:n[o];null!=i&&(r[a]=i)}return r}),height(e=0,t){return"CURRENCY_ENGINE_CHANGED_HEIGHT"===t.type?t.payload.height:e},name(e=null,t){return"CURRENCY_WALLET_NAME_CHANGED"===t.type?t.payload.name:e},nameLoaded(e=!1,t){return"CURRENCY_WALLET_NAME_CHANGED"===t.type||e},seenTxCheckpoint(e=null,t){return"CURRENCY_ENGINE_SEEN_TX_CHECKPOINT_CHANGED"===t.type?t.payload.checkpoint:e},sortedTxidHashes:ss(e=>e.self.txidHashes,e=>Object.keys(e).sort((t,n)=>e[t].date>e[n].date?-1:e[t].date<e[n].date?1:0)),stakingStatus(e={stakedAmounts:[]},t){return"CURRENCY_ENGINE_CHANGED_STAKING"===t.type?t.payload.stakingStatus:e},txidHashes(e={},t){switch(t.type){case"CURRENCY_ENGINE_CHANGED_TXS":return gs(e,t.payload.txidHashes);case"CURRENCY_WALLET_FILE_NAMES_LOADED":{const{txFileNames:n}=t.payload,r={};for(const e of Object.keys(n))r[e]={date:n[e].creationDate};return gs(e,r)}}return e},txs(e={},t,n){switch(t.type){case"CHANGE_MERGE_TX":{const{tx:n}=t.payload,r=fs({},e);return r[n.txid]=n,r}case"CURRENCY_ENGINE_CHANGED_TXS":{const{txs:n}=t.payload,r=fs({},e);for(const e of n)r[e.txid]=vs(e,r[e.txid]);return r}case"CURRENCY_ENGINE_CLEARED":return{}}return e},unactivatedTokenIds(e=[],t){switch(t.type){case"CURRENCY_ENGINE_CHANGED_UNACTIVATED_TOKEN_IDS":return t.payload.unactivatedTokenIds;case"CURRENCY_ENGINE_CLEARED":return[]}return e},gotTxs(e=new Set,t){switch(t.type){case"CURRENCY_ENGINE_GOT_TXS":{const{tokenId:n}=t.payload,r=new Set(e);return r.add(n),r}case"CURRENCY_ENGINE_CLEARED":return new Set;default:return e}},walletInfo(e,t,n){return n.root.login.walletInfos[n.id]},publicWalletInfo(e=null,t){return"CURRENCY_WALLET_PUBLIC_INFO"===t.type?t.payload.walletInfo:e}});function gs(e,t){const n=fs({},e);for(const o of Object.keys(t)){var r;const e=n[o],i=t[o];n[o]=null==e?i:{date:Math.min(i.date,e.date),txid:null!==(r=i.txid)&&void 0!==r?r:e.txid}}return n}const ws=rs(bs,(e,t)=>/^CURRENCY_/.test(e.type)&&"payload"in e&&"object"==typeof e.payload&&"walletId"in e.payload&&e.payload.walletId===t.id?e:{type:"UPDATE_NEXT"});function vs(e,t){var n,r,o,i;const{confirmations:a="unconfirmed",isSend:s=(0,Vi.lt)(e.nativeAmount,"0"),tokenId:c=null}=e,u={blockHeight:e.blockHeight,chainAction:e.chainAction,chainAssetAction:new Map(null!==(n=null==t?void 0:t.chainAssetAction)&&void 0!==n?n:[]),confirmations:a,date:e.date,isSend:s,memos:e.memos,nativeAmount:new Map(null!==(r=null==t?void 0:t.nativeAmount)&&void 0!==r?r:[]),networkFee:new Map(null!==(o=null==t?void 0:t.networkFee)&&void 0!==o?o:[]),otherParams:e.otherParams,ourReceiveAddresses:e.ourReceiveAddresses,signedTx:e.signedTx,txid:e.txid};return u.nativeAmount.set(c,e.nativeAmount),u.networkFee.set(c,null!==(i=e.networkFee)&&void 0!==i?i:"0"),null!=e.feeRateUsed&&(u.feeRateUsed=e.feeRateUsed),null!=e.parentNetworkFee&&u.networkFee.set(null,String(e.parentNetworkFee)),null!=e.chainAssetAction&&u.chainAssetAction.set(c,e.chainAssetAction),u}function ms(e){return(t,n)=>{const r=e(t,n);return r===t?t:(r.sort((e,t)=>e===t?0:e>t?1:-1),null!=t&&va(r,t)?t:r)}}function Is(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Es(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Is(Object(n),!0).forEach(function(t){r(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Is(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}const Ss="publicKey.json",Os=_r(qa),As=mr({engine:e=>async()=>{const{state:t,walletId:n,walletState:r}=e.props,{accountId:o,pluginId:i,walletInfo:a}=r,s=t.plugins.currency[i],{currencyCode:c}=s.currencyInfo;try{var u,l;const t=Ou(e);await go(t,a);const{state:d}=e.props,f=So(d,a.id),p=function(e,t,n){return ao(n,e.storageWallets[t].paths.dataKey,e.storageWallets[t].localDisklet)}(d,a.id,e.props.io);await gc(e);const h=await no(t,i),y=await Ts(a,f,h);e.props.dispatch({type:"CURRENCY_WALLET_PUBLIC_INFO",payload:{walletInfo:y,walletId:n}});const{checkpoint:b,subscribedAddresses:g}=await async function(e){var t;const{dispatch:n,state:r,walletId:o}=e.props,i=Eo(r,o),a=await oc.load(i,Js),s=null!=a?a:{checkpoint:void 0,subscribedAddresses:[]},c=s.checkpoint,u=null!==(t=s.subscribedAddresses)&&void 0!==t?t:[];null!=c&&n({type:"CURRENCY_ENGINE_SEEN_TX_CHECKPOINT_CHANGED",payload:{checkpoint:c,walletId:o}});if(u.length>0){const e=u.map(({address:e,checkpoint:t})=>({address:e,checkpoint:t,status:"subscribing"}));n({type:"CURRENCY_WALLET_LOADED_SUBSCRIBED_ADDRESSES",payload:{subscribedAddresses:e,walletId:o}})}return{checkpoint:c,subscribedAddresses:u}}(e);await pc(e);const{hasWalletSettings:w=!1}=r.currencyInfo;w&&await hc(e);const v=d.accounts[o],m=await s.makeCurrencyEngine(y,{callbacks:Ps(e),seenTxCheckpoint:b,subscribedAddresses:g,log:Lr(e.props.logBackend,`${i}-${a.id.slice(0,2)}`),walletLocalDisklet:f,walletLocalEncryptedDisklet:p,customTokens:null!==(u=v.customTokens[i])&&void 0!==u?u:{},enabledTokenIds:e.props.walletState.allEnabledTokenIds,userSettings:null!==(l=v.userSettings[i])&&void 0!==l?l:{},walletSettings:e.props.walletState.walletSettings});e.onOutput(m);const I={currencyCode:c,tokenId:null},E=me(Ma)(m.getBalance(I));null!=E&&e.props.dispatch({type:"CURRENCY_ENGINE_CHANGED_BALANCE",payload:{balance:E,tokenId:null,walletId:n}});const S=m.getBlockHeight();e.props.dispatch({type:"CURRENCY_ENGINE_CHANGED_HEIGHT",payload:{height:S,walletId:n}}),null!=m.getStakingStatus&&await m.getStakingStatus().then(t=>{e.props.dispatch({type:"CURRENCY_ENGINE_CHANGED_STAKING",payload:{stakingStatus:t,walletId:n}})},t=>e.props.onError(t)),await dc(e),await fc(e),await wc(e)}catch(d){e.props.onError(d),e.props.dispatch({type:"CURRENCY_ENGINE_FAILED",payload:{error:d,walletId:n}})}return function(e){const{walletId:t}=e.props;let n;async function r(r){const o=function(e,t){return e.storageWallets[t].lastChanges}(r.state,t);o!==n&&(n=o,await async function(e,t){(t.includes(Xs)||t.includes(Vs))&&await pc(e);const{hasWalletSettings:n=!1}=e.props.walletState.currencyInfo;n&&t.includes(Qs)&&await hc(e);t.includes(Hs)&&await dc(e);t.includes(Zs)&&await fc(e);await gc(e),await wc(e)}(e,o))}function o(){e.nextProps().then(r).then(o,t=>{var n;(n=t)instanceof Error&&"PixieShutdownError"===n.name||(e.props.onError(t),o())})}o()}(e),await Ar},walletApi:e=>async()=>{const{walletOutput:t,walletState:n}=e.props;if(null==t)return;const{engine:r}=t,{nameLoaded:o,pluginId:i,publicWalletInfo:a}=n;if(null==r||null==a||!o)return;const s=await no(Ou(e),i),c=function(e,t,n,r){const o=Ou(e),{accountId:i,pluginId:a,walletInfo:s}=e.props.walletState,c=e.props.state.plugins.currency[a],{unsafeBroadcastTx:u=!1,unsafeMakeSpend:l=!1}=c.currencyInfo,d=ga(o,s),f=Ps(e),p={};if(null!=t.otherMethods)for(const y of Object.keys(t.otherMethods)){const e=t.otherMethods[y];"function"==typeof e&&(p[y]=e)}if(null!=t.otherMethodsWithKeys)for(const y of Object.keys(t.otherMethodsWithKeys)){const e=t.otherMethodsWithKeys[y];"function"==typeof e&&(p[y]=(...t)=>e(s.keys,...t))}P(p);const h={on:Q,watch:ee,get created(){return s.created},get disklet(){return d.disklet},get id(){return d.id},get imported(){return!0===s.imported},get localDisklet(){return d.localDisklet},publicWalletInfo:r,async sync(){await d.sync()},get type(){return d.type},get name(){return e.props.walletState.name},async renameWallet(t){await async function(e,t){const{dispatch:n,state:r,walletId:o}=e.props,i=Eo(r,o);await cc.save(i,Zs,{walletName:t}),n({type:"CURRENCY_WALLET_NAME_CHANGED",payload:{name:t,walletId:o}})}(e,t)},get fiatCurrencyCode(){return e.props.walletState.fiat},async setFiatCurrencyCode(t){await async function(e,t){const{dispatch:n,state:r,walletId:o}=e.props,i=Eo(r,o);if(!/^iso:/.test(t))throw new TypeError("Fiat currency codes must start with `iso:`");await sc.save(i,Hs,{fiat:t,num:void 0}),n({type:"CURRENCY_WALLET_FIAT_CHANGED",payload:{fiatCurrencyCode:t,walletId:o}})}(e,t)},get currencyConfig(){const{accountApi:t}=e.props.output.accounts[i];return t.currencyConfig[a]},get currencyInfo(){return c.currencyInfo},async denominationToNative(t,n){const r=qo(c.currencyInfo,e.props.state.accounts[i].allTokens[a],n);return(0,Vi.mul)(t,r)},async nativeToDenomination(t,n){const r=qo(c.currencyInfo,e.props.state.accounts[i].allTokens[a],n);return(0,Vi.div)(t,r,r.length)},get walletSettings(){return e.props.walletState.walletSettings},async changeWalletSettings(t){if(!0!==e.props.walletState.currencyInfo.hasWalletSettings)throw new Error("Wallet settings unsupported");await async function(e,t){const{dispatch:n,state:r,walletId:o}=e.props,i=Eo(r,o);await yc(i,t),n({type:"CURRENCY_WALLET_CHANGED_WALLET_SETTINGS",payload:{walletId:o,walletSettings:t}})}(e,t)},get balances(){return e.props.walletState.balances},get balanceMap(){return e.props.walletState.balanceMap},get blockHeight(){const{skipBlockHeight:t}=e.props.state;return t?0:e.props.walletState.height},get syncRatio(){return e.props.walletState.syncStatus.totalRatio},get syncStatus(){return e.props.walletState.syncStatus},get unactivatedTokenIds(){return e.props.walletState.unactivatedTokenIds},async changePaused(t){e.props.dispatch({type:"CURRENCY_WALLET_CHANGED_PAUSED",payload:{walletId:e.props.walletId,paused:t}})},get paused(){return e.props.walletState.paused},async changeEnabledTokenIds(t){var n;const{dispatch:r,walletId:o,walletState:i}=e.props,{accountId:a,pluginId:s}=i,c=null!==(n=e.props.state.accounts[a].allTokens[s])&&void 0!==n?n:{},u=ls(t).filter(e=>null!=c[e]),l=o.slice(0,2);e.props.log.warn(`enabledTokenIds: ${l} changeEnabledTokenIds`),r({type:"CURRENCY_WALLET_ENABLED_TOKENS_CHANGED",payload:{walletId:o,enabledTokenIds:u}})},get detectedTokenIds(){return e.props.walletState.detectedTokenIds},get enabledTokenIds(){return e.props.walletState.enabledTokenIds},async getNumTransactions(n){const r=Ji({allTokens:e.props.state.accounts[i].allTokens[a],currencyInfo:c.currencyInfo,tokenId:n.tokenId});return t.getNumTransactions(r)},async $internalStreamTransactions(n){const{afterDate:r,batchSize:i=10,beforeDate:a,firstBatchSize:s=i,searchString:c,spamThreshold:u="0",tokenId:l=null}=n,{currencyCode:d}=null==l?this.currencyInfo:this.currencyConfig.allTokens[l],p={currencyCode:d,tokenId:l};let h=e.props.walletState;if(!h.gotTxs.has(l)){const n=await t.getTransactions(p);f.onTransactionsChanged(n),e.props.dispatch({type:"CURRENCY_ENGINE_GOT_TXS",payload:{walletId:e.props.walletId,tokenId:l}}),h=e.props.walletState}const{files:y,sortedTxidHashes:b,txidHashes:g,txs:w}=h;let v=0,m=!0,I=0;return P({async next(){const t=m?s:i,n=[];for(;v<b.length&&n.length<t;){var d,f;if(v>=I){const n=b.slice(I,I+t).filter(e=>null==y[e]),r=await bc(e,n);Object.assign(y,r),I+=t}const i=b[v++],s=y[i],p=null!==(d=null==s?void 0:s.txid)&&void 0!==d?d:null===(f=g[i])||void 0===f?void 0:f.txid;if(null==p)continue;const h=w[p],m=null==h?void 0:h.nativeAmount.get(l),E=null==h?void 0:h.networkFee.get(l);if(null==h||null==m||null==E)continue;const S=zs(e,h,s,l);if(Zi(S),!js(o,S,c))continue;if(!Ns(S,r,a))continue;!(h.isSend||null!=S.assetAction||null!=S.chainAction||null!=S.chainAssetAction||null!=S.savedAction)&&(0,Vi.lt)((0,Vi.abs)(m),u)||n.push(S)}return m=!1,{done:0===n.length,value:n}}})},async getTransactions(t){const{endDate:n,startDate:r,searchString:o,spamThreshold:s}=t,u=Ji({allTokens:e.props.state.accounts[i].allTokens[a],currencyInfo:c.currencyInfo,tokenId:t.tokenId}),l=await h.$internalStreamTransactions(Ws(Ws({},u),{},{afterDate:r,beforeDate:n,searchString:o,spamThreshold:s})),d=[];for(;;){const e=await l.next();if(e.done)return d;d.push(...e.value)}},streamTransactions:se,async getAddresses(n){if(null!=t.getAddresses)return await t.getAddresses(n);{const r=Ji({allTokens:e.props.state.accounts[i].allTokens[a],currencyInfo:c.currencyInfo,tokenId:n.tokenId}),o=await t.getFreshAddress(Ws(Ws({},r),{},{forceIndex:n.forceIndex})),{publicAddress:s,legacyAddress:u,segwitAddress:l,nativeBalance:d,legacyNativeBalance:f,segwitNativeBalance:p}=o,h=[{addressType:"publicAddress",publicAddress:s,nativeBalance:d}];return null!=l&&h.unshift({addressType:"segwitAddress",publicAddress:l,nativeBalance:p}),null!=u&&h.push({addressType:"legacyAddress",publicAddress:u,nativeBalance:f}),h}},async getReceiveAddress(e){var t;const n=await this.getAddresses(e);if(n.length<1)throw new Error("No addresses available");const r=null!==(t=n.find(e=>"publicAddress"===e.addressType))&&void 0!==t?t:n[0],o={publicAddress:r.publicAddress,nativeBalance:r.nativeBalance,metadata:Gs,nativeAmount:"0"},i=n.find(e=>"segwitAddress"===e.addressType);null!=i&&(o.segwitAddress=i.publicAddress,o.segwitNativeBalance=i.nativeBalance);const a=n.find(e=>"legacyAddress"===e.addressType);return null!=a&&(o.legacyAddress=a.publicAddress,o.legacyNativeBalance=a.nativeBalance),o},async lockReceiveAddress(e){},async saveReceiveAddress(e){},async broadcastTx(e){const n=u?s.keys:void 0;return await t.broadcastTx(e,{privateKeys:n})},async getMaxSpendable(n){return await Us(n,c,t,e.props.state.accounts[i].allTokens[a],s)},async getPaymentProtocolInfo(e){if(null==t.getPaymentProtocolInfo)throw new Error("'getPaymentProtocolInfo' is not implemented on wallets of this type");return await t.getPaymentProtocolInfo(e)},async makeSpend(n){n=Ls(n,c.currencyInfo);const{assetAction:r,customNetworkFee:o,enableRbf:u,memos:d,metadata:f,networkFeeOption:p="standard",noUnconfirmed:h=!1,otherParams:y,pendingTxs:b,rbfTxid:g,savedAction:w,skipChecks:v,spendTargets:m=[],swapData:I}=n,E=Ji({allTokens:e.props.state.accounts[i].allTokens[a],currencyInfo:c.currencyInfo,tokenId:n.tokenId}),S=[],O=[];for(const e of m){const{memo:t,publicAddress:n,nativeAmount:r="0",otherParams:o={}}=e;null!=n&&(S.push({memo:t,nativeAmount:r,otherParams:o,publicAddress:n,uniqueIdentifier:t}),O.push({currencyCode:E.currencyCode,memo:t,nativeAmount:r,publicAddress:n,uniqueIdentifier:t}))}if(null!=n.privateKeys)throw new TypeError("Only sweepPrivateKeys takes private keys");const A=l?s.keys:void 0,T=await t.makeSpend(Ws(Ws({},E),{},{customNetworkFee:o,enableRbf:u,memos:d,metadata:f,networkFeeOption:p,noUnconfirmed:h,otherParams:y,pendingTxs:b,rbfTxid:g,skipChecks:v,spendTargets:S}),{privateKeys:A});return Zi(T),T.networkFeeOption=p,T.requestedCustomFee=o,T.spendTargets=O,T.currencyCode=E.currencyCode,T.tokenId=E.tokenId,null!=f&&(T.metadata=f),null!=I&&(T.swapData=Pa(I)),null!=w&&(T.savedAction=Da(w)),null!=r&&(T.assetAction=Ra(r)),null!=e.props.state.login.deviceInfo.deviceDescription&&(T.deviceDescription=e.props.state.login.deviceInfo.deviceDescription),T},async saveTx(n){if(null==e.props.walletState.txs[n.txid]){const{fileName:t,txFile:r}=await mc(e,n);await async function(e,t,n){const{state:r,walletId:o}=e.props,i=Eo(r,o);await ac.save(i,"transaction/"+t,n)}(e,t,r),f.onTransactions([{isNew:!0,transaction:n}])}else await vc(e,n.txid,n.tokenId,f);await t.saveTx(n)},async saveTxAction(t){const{txid:n,tokenId:r,assetAction:o,savedAction:i}=t;await vc(e,n,r,f,void 0,o,i)},async saveTxMetadata(t){const{txid:n,tokenId:r,metadata:o}=t;await vc(e,n,r,f,o)},async signBytes(e,n={}){const r=s.keys;if(null!=t.signBytes)return await t.signBytes(e,r,n);if("bitcoin"===a&&null!=t.signMessage)return await t.signMessage(w(e),r,n);throw new Error(`${a} doesn't support signBytes`)},async signMessage(e,n={}){if(null==t.signMessage)throw new Error(`${a} doesn't support signing messages`);const r=s.keys;return await t.signMessage(e,r,n)},async signTx(e){const n=s.keys;return await t.signTx(e,n)},async sweepPrivateKeys(e){if(null==t.sweepPrivateKeys)throw new Error("Sweeping this currency is not supported.");return await t.sweepPrivateKeys(e)},async accelerate(e){return null==t.accelerate?null:await t.accelerate(e)},get stakingStatus(){return e.props.walletState.stakingStatus},async dumpData(){return await t.dumpData()},async resyncBlockchain(){const n=e.props.walletId.slice(0,2);e.props.log.warn(`enabledTokenIds: ${n} resyncBlockchain`),o.props.dispatch({type:"CURRENCY_ENGINE_CLEARED",payload:{walletId:e.props.walletId}}),await t.resyncBlockchain(),W(h,"transactionsRemoved",void 0)},async split(e){return await ya(o,i,s,e,!1)},async encodeUri(t){return await n.encodeUri(t,ca(e.props.state.accounts[i].customTokens[a]))},async parseUri(t,r){const o=await n.parseUri(t,r,ca(e.props.state.accounts[i].customTokens[a]));if(void 0===o.tokenId){var s;const{tokenId:t=null}=Ji({allTokens:e.props.state.accounts[i].allTokens[a],currencyInfo:c.currencyInfo,currencyCode:null!==(s=o.currencyCode)&&void 0!==s?s:r});o.tokenId=t}return o},otherMethods:p};return P(h)}(e,r,s,a);return e.onOutput(c),await Ar},engineStarted:Sr(e=>{let t;return{update(){const{log:n,walletId:r,walletOutput:o,walletState:i}=e.props;if(null==o)return;const{engine:a,walletApi:s}=o;null!=s&&i.fiatLoaded&&!i.engineStarted&&null!=a&&null==t&&(n(`${r} startEngine`),e.props.dispatch({type:"CURRENCY_ENGINE_STARTED",payload:{walletId:r}}),t=Promise.resolve().then(()=>a.startEngine()).then(()=>{e.onOutput(!0)}).catch(t=>e.props.onError(t)))},destroy(){const{log:n,walletId:r,walletOutput:o}=e.props;if(null==o)return;const{engine:i}=o;null!=i&&null!=t&&(n(`${r} killEngine`),t.then(()=>i.killEngine()).catch(t=>e.props.onError(t)).then(()=>{e.onOutput(!1),e.props.dispatch({type:"CURRENCY_ENGINE_STOPPED",payload:{walletId:r}})}).catch(()=>{}))}}},e=>e.state.paused||e.walletState.paused?void 0:e),syncNetworkUpdate:Sr(e=>({async update(e){if(null==e.walletOutput)return;const{engine:t,engineStarted:n}=e.walletOutput;if(null==(null==t?void 0:t.syncNetwork)||!n)return;const{walletState:r}=e,{currencyInfo:o,walletInfo:i,publicWalletInfo:a}=r,s=!0===o.unsafeSyncNetwork&&null!=a?i.keys:void 0;for(const c of r.changeServiceSubscriptions)await t.syncNetwork({privateKeys:s,subscribeParam:{address:c.address,checkpoint:c.checkpoint,needsSync:"syncing"===c.status}});e.dispatch({type:"CURRENCY_ENGINE_UPDATE_CHANGE_SERVICE_SUBSCRIPTIONS",payload:{subscriptions:r.changeServiceSubscriptions.map(e=>Es(Es({},e),{},{status:"listening"})),walletId:e.walletId}})},destroy(){}}),e=>!e.state.paused&&!e.walletState.paused&&e.walletState.engineStarted&&e.walletState.changeServiceSubscriptions.some(e=>"syncing"===e.status||"synced"===e.status)?e:void 0),syncNetworkTask:Sr(e=>{const t=Zr(async()=>{if(null==e.props.walletOutput)return;const{engine:n,engineStarted:r}=e.props.walletOutput;if(null==(null==n?void 0:n.syncNetwork)||!r)return void t.stop();const{walletState:o}=e.props,{currencyInfo:i,walletInfo:a,publicWalletInfo:s}=o,c=!0===i.unsafeSyncNetwork&&null!=s?a.keys:void 0,u=await n.syncNetwork({privateKeys:c});t.setDelay(u)},1e4,{onError:t=>{e.props.log.error(t)}});return{update(e){if(null==e.walletOutput)return;const{engine:n,engineStarted:r}=e.walletOutput;null==(null==n?void 0:n.syncNetwork)||!r||null!=t&&t.started||t.start({wait:!1})},destroy(){null!=t&&t.stop()}}},e=>e.state.paused||e.walletState.paused||!e.walletState.engineStarted||!0===e.walletState.currencyInfo.usesChangeServer&&!e.walletState.changeServiceSubscriptions.some(e=>"avoiding"===e.status||"reconnecting"===e.status||"resubscribing"===e.status||"subscribingSlowly"===e.status)?void 0:e),syncTimer:Sr(e=>{const t=Zr(async function(){const{walletId:t}=e.props;await wo(Ou(e),t)},bo);return{update(){const{state:n,walletId:r,walletOutput:o}=e.props;null!=o&&null!=n.storageWallets[r]&&n.storageWallets[r].status.lastSync>0&&t.start({wait:bo*(1+Math.random())})},destroy(){t.stop()}}},e=>e.state.paused||e.walletState.paused?void 0:e),tokenSaver(e){let t=hs;return async function(){const{detectedTokenIds:n,enabledTokenIds:r,tokenFileDirty:o,tokenFileLoaded:i}=e.props.walletState;if(o&&i){const o=_s(r,t),i=_s(t,r),a=e.props.walletId.slice(0,2);e.props.log.warn(`enabledTokenIds: ${a} write to disk, add [${o}], remove [${i}]`),await async function(e,t,n){const{state:r,walletId:o}=e.props,i=Eo(r,o);await ic.save(i,Xs,{detectedTokenIds:t,enabledTokenIds:n})}(e,n,r).catch(t=>e.props.onError(t)),e.props.dispatch({type:"CURRENCY_WALLET_SAVED_TOKEN_FILE",payload:{walletId:e.props.walletId}}),await Qr(100)}t=r}},watcher(e){let t,n={},r=ps,o={},i=hs;return async()=>{var a,s;const{state:c,walletState:u,walletOutput:l}=e.props;if(null==u||null==l)return;const{engine:d,walletApi:f}=l,{accountId:p,pluginId:h}=u,y=c.accounts[p];t!==u&&null!=f&&G(f),t=u;const b=null!==(a=y.userSettings[h])&&void 0!==a?a:n;n!==b&&null!=d&&await d.changeUserSettings(b),n=b;const g=null!==(s=y.customTokens[h])&&void 0!==s?s:o;if(o!==g&&null!=d)if(null!=d.changeCustomTokens)await d.changeCustomTokens(g);else if(null!=d.addCustomToken)for(const t of Object.keys(g)){const n=g[t];if(n===o[t])continue;const r=ua(n);null!=r&&await d.addCustomToken(Es(Es({},r),n)).catch(t=>e.props.onError(t))}o=g;const{hasWalletSettings:w=!1}=u.currencyInfo,{walletSettings:v}=u;r!==v&&null!=(null==d?void 0:d.changeWalletSettings)&&w&&await d.changeWalletSettings(v).catch(t=>{e.props.onError(t)}),r=v;const{allEnabledTokenIds:m}=u;if(i!==m&&null!=d)if(null!=d.changeEnabledTokenIds)await d.changeEnabledTokenIds(m).catch(t=>e.props.onError(t));else if(null!=d.disableTokens&&null!=d.enableTokens){const t=us(y.builtinTokens[h],y.customTokens[h],u.currencyInfo,ls(i,m)),n=us(y.builtinTokens[h],y.customTokens[h],u.currencyInfo,ls(m,i));await d.disableTokens(t).catch(t=>e.props.onError(t)),await d.enableTokens(n).catch(t=>e.props.onError(t))}i=m}}});async function Ts(e,t,n){const r=await Os.load(t,Ss);if(null!=r&&(null==n.checkPublicKey||await n.checkPublicKey(r.walletInfo.keys)))return r.walletInfo;let o={};try{o=await n.derivePublicKey(e)}catch(a){}const i={id:e.id,type:e.type,keys:o};return Object.keys(o).length>0&&await Os.save(t,Ss,{walletInfo:i}),i}function _s(e,t){const n=new Set(t);return e.filter(e=>!n.has(e)).join(", ")}let ks=5e3;function xs(e,t){const{log:n,walletId:r}=e.props;let o=!1,i=0,a=[];return e=>{if(o)n(`throttledTxCallback delay, walletId: ${r}`),a.push(...e);else{const s=Date.now();s-i>ks?(i=s,t(e)):(n(`throttledTxCallback delay, walletId: ${r}`),o=!0,a=e,setTimeout(()=>{i=Date.now(),t(a),o=!1,a=[]},ks))}}}function Ps(e){const{walletId:t}=e.props;"narfavJN4rp9ZzYigcRj1i0vrU2OAGGp4+KksAksj54="===t&&(ks=25,Ia=99,ma=1);const n=xs(e,t=>{var n;null!=(null===(n=e.props.walletOutput)||void 0===n?void 0:n.walletApi)&&W(e.props.walletOutput.walletApi,"transactionsChanged",t)}),r=xs(e,t=>{var n;null!=(null===(n=e.props.walletOutput)||void 0===n?void 0:n.walletApi)&&W(e.props.walletOutput.walletApi,"newTransactions",t)}),o={onAddressesChecked(n){Oa({id:t,action:"onSyncStatusChanged",updateFunc:()=>{e.props.dispatch({type:"CURRENCY_ENGINE_CHANGED_SYNC_STATUS",payload:{status:{totalRatio:n},walletId:t}})}})},onNewTokens(n){Oa({id:t,action:"onNewTokens",updateFunc:()=>{const{detectedTokenIds:r,enabledTokenIds:o}=e.props.walletState,i=ls(n,[...r,...o]),a=_s(n,r),s=_s(r,n),c=t.slice(0,2);if(e.props.log.warn(`enabledTokenIds: ${c} engine detected tokens, add [${a}], remove [${s}]`),e.props.dispatch({type:"CURRENCY_ENGINE_DETECTED_TOKENS",payload:{detectedTokenIds:n,enablingTokenIds:i,walletId:t}}),i.length>0){var u;const t=null===(u=e.props)||void 0===u||null===(u=u.walletOutput)||void 0===u?void 0:u.walletApi;null!=t&&W(t,"enabledDetectedTokens",i)}}})},onUnactivatedTokenIdsChanged(n){Oa({id:t,action:"onUnactivatedTokenIdsChanged",updateFunc:()=>{e.props.dispatch({type:"CURRENCY_ENGINE_CHANGED_UNACTIVATED_TOKEN_IDS",payload:{unactivatedTokenIds:n,walletId:t}})}})},onBalanceChanged(t,n){const{accountId:r,currencyInfo:i,pluginId:a}=e.props.walletState,s=e.props.state.accounts[r].allTokens[a];if(t===i.currencyCode)o.onTokenBalanceChanged(null,n);else{const{tokenId:e}=Ji({allTokens:s,currencyInfo:i,currencyCode:t});null!=e&&o.onTokenBalanceChanged(e,n)}},onTokenBalanceChanged(n,r){const o=me(Ma)(r);null!=o?Oa({id:`${t}==${String(n)}`,action:"onTokenBalanceChanged",updateFunc:()=>{e.props.dispatch({type:"CURRENCY_ENGINE_CHANGED_BALANCE",payload:{balance:o,tokenId:n,walletId:t}})}}):e.props.onError(new Error(`Plugin sent bogus balance for ${String(n)}: "${r}"`))},onBlockHeightChanged(r){Oa({id:t,action:"onBlockHeightChanged",updateFunc:()=>{const{txs:o,files:i}=e.props.walletState,a=[];for(const n of Object.keys(o)){const s=o[n];if(Ms(s.confirmations)){const n=Oo(e.props.state,t,s.txid),o=zs(e,s,i[n],null,r);a.push(o)}}a.length>0&&n(a),e.props.dispatch({type:"CURRENCY_ENGINE_CHANGED_HEIGHT",payload:{height:r,walletId:t}})}})},onSeenTxCheckpoint(t){Ic(e,t).catch(t=>e.props.onError(t))},onStakingStatusChanged(n){Oa({id:t,action:"onStakingStatusChanged",updateFunc:()=>{e.props.dispatch({type:"CURRENCY_ENGINE_CHANGED_STAKING",payload:{stakingStatus:n,walletId:t}})}})},onSubscribeAddresses(n){var r;const o=n.map(e=>"string"==typeof e?{address:e,checkpoint:void 0}:e);Ic(e,null!==(r=e.props.walletState.seenTxCheckpoint)&&void 0!==r?r:void 0,o).catch(t=>e.props.onError(t));const i=o.map(({address:e,checkpoint:t})=>({address:e,status:"subscribing",checkpoint:t}));e.props.dispatch({type:"CURRENCY_ENGINE_UPDATE_CHANGE_SERVICE_SUBSCRIPTIONS",payload:{subscriptions:i,walletId:t}})},onSyncStatusChanged(n){Oa({id:t,action:"onSyncStatusChanged",updateFunc:()=>{e.props.dispatch({type:"CURRENCY_ENGINE_CHANGED_SYNC_STATUS",payload:{status:n,walletId:t}})}})},onTransactions(o){const{accountId:i,currencyInfo:a,pluginId:s}=e.props.walletState,c=e.props.state.accounts[i].allTokens[s];if(null==o||0===o.length)return;const u=[];for(const t of o){const n=t.transaction;if(Zi(n),"string"!=typeof n.txid||"number"!=typeof n.date||"string"!=typeof n.networkFee||"number"!=typeof n.blockHeight||"string"!=typeof n.nativeAmount||"object"!=typeof n.ourReceiveAddresses)return void e.props.onError(new Error(`Plugin sent bogus tx: ${JSON.stringify(n,null,2)}`));if(null==n.isSend&&(n.isSend=(0,Vi.lt)(n.nativeAmount,"0")),null==n.memos&&(n.memos=[]),void 0===n.tokenId){const{tokenId:e}=Ji({allTokens:c,currencyInfo:a,currencyCode:n.currencyCode});n.tokenId=null!=e?e:null}u.push(n)}const{state:l}=e.props,{txs:d}=e.props.walletState,f={},p=[],h=[];for(const n of o){const{isNew:r,transaction:o}=n,{txid:i}=o,a=vs(o,d[i]);if(va(a,d[i])&&null==o.metadata)continue;const s=Oo(l,t,i);null==e.props.walletState.fileNames[s]&&mc(e,o).catch(t=>e.props.onError(t));const{files:c}=e.props.walletState,u=zs(e,a,c[s],o.tokenId);r?h.push(u):p.push(u),f[s]={date:u.date,txid:i}}e.props.dispatch({type:"CURRENCY_ENGINE_CHANGED_TXS",payload:{txs:u,walletId:t,txidHashes:f}}),p.length>0&&n(p),h.length>0&&r(h)},onTransactionsChanged(e){o.onTransactions(e.map(e=>({isNew:!1,transaction:e})))},onAddressChanged(){null!=e.props.walletOutput.walletApi&&W(e.props.walletOutput.walletApi,"addressChanged",void 0)},onWcNewContractCall(t){null!=e.props.walletOutput.walletApi&&W(e.props.walletOutput.walletApi,"wcNewContractCall",t)},onTxidsChanged(){}};return o}const Ms=e=>"number"!=typeof e&&"confirmed"!==e&&"dropped"!==e&&"failed"!==e,Cs=(e,t,n=1)=>{if(e.blockHeight>0){const r=1+t-e.blockHeight;return r<=0?"syncing":r>=n?"confirmed":r}return e.blockHeight<0?"dropped":"unconfirmed"};function Ns(e,t=new Date(0),n=new Date){return 1e3*e.date>=t.valueOf()&&1e3*e.date<n.valueOf()}function js(e,t,n){var r;const o=e.props.state.currency;if(null==n||""===n)return!0;let i=n.toLowerCase().replace(".","").replace(",","");for(let c=0;c<i.length;c++)if("0"!==i[c]){i=i.substring(c);break}function a(e){return null!=e&&("string"==typeof e||"number"==typeof e)&&!!e.toString().toLowerCase().replace(".","").replace(",","").includes(i)}if(a(t.nativeAmount))return!0;if(null!=t.metadata){const{category:e="",name:n="",notes:r="",exchangeAmount:i={}}=t.metadata,s=null!=t.walletId?o.wallets[t.walletId]:void 0;if(a(e)||a(n)||a(r)||null!=s&&a(i[s.fiat]))return!0}if(null!=t.swapData){const{displayName:e="",pluginId:n=""}=t.swapData.plugin;if(a(e)||a(n))return!0}const s=null!==(r=t.savedAction)&&void 0!==r?r:t.chainAction;if(null!=s&&"swap"===s.actionType){const{pluginId:e}=s.toAsset,{pluginId:t}=s.fromAsset,{displayName:n,supportEmail:r}=s.swapInfo;if(a(t)||a(e)||a(n)||a(r))return!0}if(null!=t.spendTargets)for(const c of t.spendTargets){const{publicAddress:e="",memo:t=""}=c;if(a(e)||a(t))return!0}if(t.ourReceiveAddresses.length>0)for(const c of t.ourReceiveAddresses)if(a(c))return!0;return!!a(t.txid)}function Ds(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Rs(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Ds(Object(n),!0).forEach(function(t){r(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ds(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Ls(e,t){var n,r;const o=[],{memoType:i}=t;if("hex"===i||"number"===i||"text"===i)for(const c of e.spendTargets){var a;null!=c.memo?o.push({type:i,value:c.memo}):null!=c.uniqueIdentifier?o.push({type:i,value:c.uniqueIdentifier}):"string"==typeof(null===(a=c.otherParams)||void 0===a?void 0:a.uniqueIdentifier)&&o.push({type:i,value:c.otherParams.uniqueIdentifier})}for(const c of o)"hex"===c.type&&(c.value=c.value.replace(/^0x/i,""));const s=Rs(Rs({},e),{},{spendTargets:e.spendTargets.map(e=>Rs(Rs({},e),{},{memo:void 0,uniqueIdentifier:void 0})),memos:null!==(n=e.memos)&&void 0!==n?n:o});if(1===(null===(r=s.memos)||void 0===r?void 0:r.length)&&s.spendTargets.length>=1){const[e]=s.memos;if(e.type===t.memoType){const[t]=s.spendTargets;t.memo=e.value,t.uniqueIdentifier=e.value,t.otherParams=Rs(Rs({},t.otherParams),{},{uniqueIdenfitifer:e.value})}}return s}function Bs(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Ks(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Bs(Object(n),!0).forEach(function(t){r(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Bs(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}const Us=async(e,t,n,r,o)=>{var i;e=Ls(e,t.currencyInfo);const a=Ji({allTokens:r,currencyInfo:t.currencyInfo,tokenId:e.tokenId}),s=null!==(i=t.currencyInfo.unsafeMakeSpend)&&void 0!==i&&i;if("function"==typeof n.getMaxSpendable){const t=s?o.keys:void 0;return await n.getMaxSpendable(Ks(Ks({},e),a),{privateKeys:t})}const{networkFeeOption:c,customNetworkFee:u}=e,l=n.getBalance(a),d=e.spendTargets.map(e=>Ks(Ks({},e),{},{nativeAmount:"0"}));return await function t(r,i){const l=(0,Vi.sub)(i,r);if((0,Vi.lte)(l,"1"))return Promise.resolve(r);const f=(0,Vi.add)(r,(0,Vi.div)(l,"2"));d[0].nativeAmount=f;const p=s?o.keys:void 0;return n.makeSpend(Ks(Ks({},a),{},{spendTargets:d,networkFeeOption:c,customNetworkFee:u,memos:e.memos,otherParams:e.otherParams}),{privateKeys:p}).then(()=>t(f,i)).catch(()=>t(r,f))}("0",(0,Vi.add)(l,"1"))};function Fs(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Ws(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Fs(Object(n),!0).forEach(function(t){r(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Fs(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}const Gs={bizId:0,category:"",exchangeAmount:{},name:"",notes:""};function zs(e,t,n,r,o){var i,a,s;const c=e.props.walletId,{accountId:u,currencyInfo:l,pluginId:d}=e.props.walletState,f=e.props.state.accounts[u].allTokens[d],{currencyCode:p}=null==r?l:f[r],h=l.currencyCode,y=null!=o?o:e.props.walletState.height,b=Ms(t.confirmations)?Cs(t,y,l.requiredConfirmations):t.confirmations,g={chainAction:t.chainAction,chainAssetAction:t.chainAssetAction.get(r),blockHeight:t.blockHeight,confirmations:b,currencyCode:p,feeRateUsed:t.feeRateUsed,date:t.date,isSend:t.isSend,memos:t.memos,metadata:{},nativeAmount:null!==(i=t.nativeAmount.get(r))&&void 0!==i?i:"0",networkFee:null!==(a=t.networkFee.get(r))&&void 0!==a?a:"0",networkFees:[],otherParams:Ws({},t.otherParams),ourReceiveAddresses:t.ourReceiveAddresses,parentNetworkFee:h===p?void 0:null!==(s=t.networkFee.get(null))&&void 0!==s?s:"0",signedTx:t.signedTx,tokenId:r,txid:t.txid,walletId:c};if(null!=n){var w,v,m,I,E,S,O,A,T;n.creationDate<g.date&&(g.date=n.creationDate),g.metadata=Ta(null!==(w=null!==(v=null===(m=n.tokens.get(null))||void 0===m?void 0:m.metadata)&&void 0!==v?v:null===(I=n.currencies.get(h))||void 0===I?void 0:I.metadata)&&void 0!==w?w:{},null!==(E=null!==(S=null===(O=n.tokens.get(r))||void 0===O?void 0:O.metadata)&&void 0!==S?S:null===(A=n.currencies.get(p))||void 0===A?void 0:A.metadata)&&void 0!==E?E:{}),null!=n.feeRateRequested&&("string"==typeof n.feeRateRequested?g.networkFeeOption=n.feeRateRequested:(g.networkFeeOption="custom",g.requestedCustomFee=n.feeRateRequested)),null==g.feeRateUsed&&(g.feeRateUsed=n.feeRateUsed),null!=n.payees&&(g.spendTargets=n.payees.map(e=>({currencyCode:e.currency,memo:e.tag,nativeAmount:e.amount,publicAddress:e.address,uniqueIdentifier:e.tag})));const e=null===(T=n.tokens.get(r))||void 0===T?void 0:T.assetAction;null!=e&&(g.assetAction=e),null!=n.savedAction&&(g.savedAction=n.savedAction),null!=n.swap&&(g.swapData=n.swap),null!=n.secret&&(g.txSecret=n.secret),null!=n.deviceDescription&&(g.deviceDescription=n.deviceDescription)}return g}function qs(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function $s(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?qs(Object(n),!0).forEach(function(t){r(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):qs(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}const Hs="Currency.json",Ys="fixedLegacyFileNames.json",Vs="EnabledTokens.json",Js="seenTxCheckpoint.json",Xs="Tokens.json",Zs="WalletName.json",Qs="WalletSettings.json",ec=_r(Ga),tc=_r(za),nc=_r(La),rc=_r(Wa),oc=_r($a),ic=_r(Ba),ac=_r(Fa),sc=_r(Ha),cc=_r(Ya),uc=_r(Ka);function lc(e,t,n,r){var o;const i=e.currency.wallets[t].fileNames,a=Oo(e,t,n),{creationDate:s=Math.min(r,Date.now()/1e3)}=null!==(o=i[a])&&void 0!==o?o:{},c=`${s.toFixed(0)}-${a}.json`;return{creationDate:s,fileName:c,txidHash:a}}async function dc(e){const{dispatch:t,state:n,walletId:r}=e.props,o=Eo(n,r),i=await sc.load(o,Hs);let a="iso:USD";if(null!=i)if(null!=i.fiat)a=i.fiat;else if(null!=i.num){const e=(0,mo.ai)(`000${i.num}`.slice(-3));null!=e&&(a=`iso:${e.code}`)}t({type:"CURRENCY_WALLET_FIAT_CHANGED",payload:{fiatCurrencyCode:a,walletId:r}})}async function fc(e){const{dispatch:t,state:n,walletId:r}=e.props,o=Eo(n,r),i=await cc.load(o,Zs);let a=null;if(null==i||null==i.walletName){const{appIds:t=[]}=e.props.walletState.walletInfo,n=t.find(e=>""!==e);if(null!=n){const{appName:t}=await Hi(Ou(e),n);a=t}}else a=i.walletName;t({type:"CURRENCY_WALLET_NAME_CHANGED",payload:{name:"string"==typeof a?a:null,walletId:r}})}async function pc(e){const{dispatch:t,state:n,walletId:r}=e.props,o=Eo(n,r),i=await ic.load(o,Xs);if(null!=i){const n=r.slice(0,2);return e.props.log.warn(`enabledTokenIds: ${n} loaded modern file`),void t({type:"CURRENCY_WALLET_LOADED_TOKEN_FILE",payload:$s({walletId:e.props.walletId},i)})}const a=await nc.load(o,Vs);if(null!=a){const{accountId:n,currencyInfo:o,pluginId:i}=e.props.walletState,s=e.props.state.accounts[n],c=function(e={},t={},n,r){const o=cs(e),i=cs(t),a=[];for(const c of r){var s;const e=null!==(s=i[c])&&void 0!==s?s:o[c];null!=e&&a.push(e)}return a}(s.builtinTokens[i],s.customTokens[i],0,a),u=r.slice(0,2);return e.props.log.warn(`enabledTokenIds: ${u} loaded legacy file`),void t({type:"CURRENCY_WALLET_LOADED_TOKEN_FILE",payload:{walletId:e.props.walletId,detectedTokenIds:[],enabledTokenIds:c}})}const s=r.slice(0,2);e.props.log.warn(`enabledTokenIds: ${s} loaded neither file`),t({type:"CURRENCY_WALLET_LOADED_TOKEN_FILE",payload:{walletId:e.props.walletId,detectedTokenIds:[],enabledTokenIds:[]}})}async function hc(e){var t;const{dispatch:n,state:r,walletId:o}=e.props,i=Eo(r,o),a=await uc.load(i,Qs);n({type:"CURRENCY_WALLET_LOADED_WALLET_SETTINGS_FILE",payload:{walletId:o,walletSettings:null!==(t=null==a?void 0:a.walletSettings)&&void 0!==t?t:{}}})}async function yc(e,t){await uc.save(e,Qs,{walletSettings:t})}async function bc(e,t){const{dispatch:n,walletId:r}=e.props,o=Eo(e.props.state,r),i=e.props.walletState.currencyInfo.currencyCode,a=e.props.walletState.fileNames,s=e.props.walletState.fiat,c={};return await Promise.all(t.map(async e=>{if(null==a[e])return;const t=`Transactions/${a[e].fileName}`,n=await rc.load(o,t);null!=n&&(c[e]=function(e,t,n){const r={creationDate:e.state.creationDate,currencies:new Map,tokens:new Map,internal:e.state.internal,txid:e.state.malleableTxId},o={};return o[n]=e.meta.amountCurrency,r.currencies.set(t,{metadata:{bizId:e.meta.bizId,category:e.meta.category,exchangeAmount:o,name:e.meta.name,notes:e.meta.notes},providerFeeSent:e.meta.amountFeeAirBitzSatoshi.toFixed()}),r}(n,i,s))})),await Promise.all(t.map(async e=>{if(null==a[e])return;const t=`transaction/${a[e].fileName}`,n=await ac.load(o,t);null!=n&&(c[e]=n)})),n({type:"CURRENCY_WALLET_FILES_LOADED",payload:{files:c,walletId:r}}),c}async function gc(e){const{dispatch:t,state:n,walletId:r}=e.props,o=Eo(n,r),i=await async function(e,t,n){var r;const o=So(e,t),i=null!==(r=await tc.load(o,Ys))&&void 0!==r?r:{},a=(0,re.WR)(await n.list()),s={},c=[];for(let l=0;l<a.length;l++){const e=a[l],t=i[e];if(null!=t){const{timestamp:n,txidHash:r}=t;s[r]={creationDate:n,fileName:e}}else c.push(e)}const u=c.map(async r=>{const o=await rc.load(n,r);if(null==o)return;const{creationDate:a,malleableTxId:c}=o.state,u=r,l=Oo(e,t,c);s[l]={creationDate:a,fileName:u},i[u]={timestamp:a,txidHash:l}});return u.length>0&&(await Promise.all(u),await tc.save(o,Ys,i).catch(()=>{})),s}(n,r,(0,re.my)(o,"Transactions")),a=await(0,re.my)(o,"transaction").list();for(const s of(0,re.WR)(a)){const e=s.split(".json")[0].split("-"),[t,n]=e,r=parseInt(t);(null==i[n]||r<i[n].creationDate)&&(i[n]={creationDate:r,fileName:s})}t({type:"CURRENCY_WALLET_FILE_NAMES_LOADED",payload:{txFileNames:i,walletId:r}})}async function wc(e){var t;const{state:n,walletId:r}=e.props,o=Eo(n,r),i=[],a=(0,re.WR)(await o.list("Addresses"));await Promise.all(a.map(async e=>{const t=await ec.load(o,e);null!=t&&(""===t.address||t.state.recycleable||i.push(t.address))}));const s=null===(t=e.props.walletOutput)||void 0===t?void 0:t.engine;null!=s&&await s.addGapLimitAddresses(i)}async function vc(e,t,n,r,o,i,a){var s,c;const{dispatch:u,state:l,walletId:d}=e.props,f=Eo(l,d),{accountId:p,currencyInfo:h,pluginId:y}=e.props.walletState,b=e.props.state.accounts[p].allTokens[y],{currencyCode:g}=null==n?h:b[n],w=e.props.walletState.txs[t];if(null==w)throw new Error(`Setting metatdata for missing tx ${t}`);const{creationDate:v,fileName:m,txidHash:I}=lc(l,d,w.txid,w.date),E=await ac.load(f,`transaction/${m}`),S=$s($s({},E),{},{creationDate:v,currencies:new Map(null!==(s=null==E?void 0:E.currencies)&&void 0!==s?s:[]),internal:!0,tokens:new Map(null!==(c=null==E?void 0:E.tokens)&&void 0!==c?c:[]),txid:t}),O=$s($s({metadata:{}},S.currencies.get(g)),S.tokens.get(n));var A;(S.tokens.set(n,O),S.currencies.delete(g),null!=o)&&(O.metadata=Ta(null!==(A=O.metadata)&&void 0!==A?A:{},o));null!=i&&(O.assetAction=i),null!=a&&(S.savedAction=a),u({type:"CURRENCY_WALLET_FILE_CHANGED",payload:{creationDate:v,fileName:m,json:S,txid:t,txidHash:I,walletId:d}}),await ac.save(f,"transaction/"+m,S);const T=zs(e,w,S,n);r.onTransactions([{isNew:!1,transaction:T}])}async function mc(e,t){var n;const{dispatch:r,state:o,walletId:i}=e.props,{creationDate:a,fileName:s,txidHash:c}=lc(o,i,t.txid,t.date),u={txid:t.txid,internal:!0,creationDate:a,currencies:new Map,feeRateUsed:t.feeRateUsed,tokens:new Map,savedAction:t.savedAction,swap:t.swapData};return u.tokens.set(t.tokenId,{assetAction:t.assetAction,metadata:null!==(n=t.metadata)&&void 0!==n?n:{},nativeAmount:t.nativeAmount}),null!=t.networkFeeOption&&(u.feeRateRequested="custom"===t.networkFeeOption?t.requestedCustomFee:t.networkFeeOption),null!=t.spendTargets&&(u.payees=t.spendTargets.map(e=>({currency:e.currencyCode,address:e.publicAddress,amount:e.nativeAmount,tag:e.memo})),null!=t.deviceDescription&&(u.deviceDescription=t.deviceDescription)),"string"==typeof t.txSecret&&(u.secret=t.txSecret),r({type:"CURRENCY_WALLET_FILE_CHANGED",payload:{creationDate:a,fileName:s,json:u,txid:t.txid,txidHash:c,walletId:i}}),{fileName:s,txFile:u}}async function Ic(e,t,n){var r;const{dispatch:o,state:i,walletId:a}=e.props,s=Eo(i,a),c=await oc.load(s,Js),u={checkpoint:t,subscribedAddresses:null!==(r=null!=n?n:(null!=c?c:{checkpoint:void 0,subscribedAddresses:[]}).subscribedAddresses)&&void 0!==r?r:[]};null!=t&&o({type:"CURRENCY_ENGINE_SEEN_TX_CHECKPOINT_CHANGED",payload:{checkpoint:t,walletId:a}}),await oc.save(s,Js,u)}async function Ec(e,t,n){const{stashTree:r}=xn(e,t.loginId),{deviceDescription:o}=e.props.state.login.deviceInfo,i=nr(r,t);null!=o&&(i.deviceDescription=o),i.data=vt(n);const a=await In(e,"POST","/v2/login/vouchers",i),s=Hn(r,t.loginKey,Qe(a));return await jn(e,s)}function Sc(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(-1!==t.indexOf(r))continue;n[r]=e[r]}return n}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],-1===t.indexOf(n)&&{}.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}const Oc=["fromWallet","toWallet"];function Ac(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Tc(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Ac(Object(n),!0).forEach(function(t){r(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ac(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}async function _c(e,t,n,r={}){const{disabled:o={},noResponseMs:i,preferPluginId:a,promoCodes:s={},slowResponseMs:c=2e4}=r,{log:u,state:l}=e.props,d=l.accounts[t],{swapSettings:f,userSettings:p}=d,h=l.plugins.swap;u.warn("Requesting swap quotes for: ",Tc(Tc({},n),{},{fromWallet:n.fromWallet.id,toWallet:n.toWallet.id}),{preferPluginId:a,promoCodes:s});const y=new Set,b=[];for(const m of Object.keys(h)){var g,w;const{enabled:e=!0}=null!=f[m]?f[m]:{};e&&!o[m]&&(y.add(m),b.push(h[m].fetchSwapQuote(n,p[m],{infoPayload:null!==(g=null===(w=l.infoCache.corePlugins)||void 0===w?void 0:w[m])&&void 0!==g?g:{},promoCode:s[m]}).then(e=>{var t;Xi(e);const n=null!==(t=e.request)&&void 0!==t?t:{},{fromWallet:r,toWallet:o}=n,i=Sc(n,Oc),a=Tc(Tc({},e),{},{request:i});return y.delete(m),u.warn(`${m} gave swap quote:`,a),e},e=>{throw y.delete(m),u.warn(`${m} gave swap error: ${String(e)}`),xc(e)&&u.crash(`Unknown swap error: ${String(e)}`,{error:e,swapPluginId:m,request:{fromToken:String(n.fromTokenId),fromWalletType:n.fromWallet.type,toToken:String(n.toTokenId),toWalletType:n.toWallet.type,quoteFor:n.quoteFor}}),e})))}const v=function(e,t){return new Promise((n,r)=>{let o=!1;const i=[],a=[];let s=setTimeout(()=>{s=void 0,i.length>0&&(o=!0,n({results:i,errors:a}))},t);function c(){const t=i.length+a.length===e.length;t&&null!=s&&clearTimeout(s),(t||null==s&&i.length>0)&&(o=!0,i.length>0?n({results:i,errors:a}):r(a))}c();for(const t of e)t.then(e=>{o||(i.push(e),c())},e=>{o||(a.push(e),c())})})}(b,c).then(({results:e,errors:t})=>{for(const n of y)u.warn(`${n} gave swap timeout`);const o=function(e,t){const{preferPluginId:n,preferType:r,promoCodes:o}=t;return e.sort((e,t)=>{if("transfer"===e.pluginId)return-1;if("transfer"===t.pluginId)return 1;if(e.pluginId===n)return-1;if(t.pluginId===n)return 1;if(null!=r){const n=!0===e.swapInfo.isDex&&"DEX"===r||!0!==e.swapInfo.isDex&&"CEX"===r,o=!0===t.swapInfo.isDex&&"DEX"===r||!0!==t.swapInfo.isDex&&"CEX"===r;if(n&&!o)return-1;if(!n&&o)return 1}if(null!=o){const n=null!=o[e.pluginId],r=null!=o[t.pluginId];if(n&&!r)return-1;if(!n&&r)return 1}const{isEstimate:i=!0}=e,{isEstimate:a=!0}=t;if(!i&&a)return-1;if(i&&!a)return 1;const s=Number(e.toNativeAmount)/Number(e.fromNativeAmount),c=Number(t.toNativeAmount)/Number(t.fromNativeAmount);return s>c?-1:c>s?1:0})}(e,r);return u.warn(`${b.length} swap quotes requested, ${e.length} resolved, ${t.length} failed, sorted ${o.map(e=>e.pluginId).join(", ")}.`),e.map(e=>function(e,t,n){var r,o;const i=P({canBePartial:n.canBePartial,expirationDate:n.expirationDate,fromNativeAmount:n.fromNativeAmount,isEstimate:n.isEstimate,maxFulfillmentSeconds:n.maxFulfillmentSeconds,networkFee:n.networkFee,pluginId:n.pluginId,request:null!==(r=n.request)&&void 0!==r?r:t,swapInfo:null!==(o=n.swapInfo)&&void 0!==o?o:e[n.pluginId].swapInfo,toNativeAmount:n.toNativeAmount,minReceiveAmount:n.minReceiveAmount,async approve(e){return await n.approve(e)},async close(){await n.close(),F(i)}});return i}(h,n,e))},e=>{throw u.warn(`All ${b.length} swap quotes rejected.`),function(e){return e.reduce((e,t)=>{const n=kc(e)-kc(t);if(n>0)return e;if(n<0)return t;const r=Qt(e),o=Qt(t);if(null!=r&&null!=o)return(0,Vi.lt)(r.nativeMin,o.nativeMin)?r:o;const i=Zt(e),a=Zt(t);return null!=i&&null!=a?(0,Vi.gt)(i.nativeMax,a.nativeMax)?i:a:e})}(e)});return null==i?await v:await wn(v,i)}function kc(e){return null==e?0:null!=Ht(e)||null!=Xt(e)?6:null!=Qt(e)?5:null!=Zt(e)?4:null!=nn(e)?3.5:null!=tn(e)?3:null!=en(e)?2:1}function xc(e){return!(kc(e)>1)}const Pc=_r(we({name:pe})),Mc=_r(we({key:pe,data:pe}));function Cc(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Nc(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Cc(Object(n),!0).forEach(function(t){r(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Cc(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}let jc=0;const Dc=async(e,t,n,r={})=>{var o;const{keys:i,walletSettings:a={}}=r;if(null==i)throw new Error("No keys provided");const s="memorywallet-"+jc++,c={id:s,type:n,keys:i},u=await no(e,t.currencyInfo.pluginId),l=await u.derivePublicKey(c);c.keys=Nc(Nc({},l),c.keys);const d=Lr(e.props.logBackend,`${s}-${n}`);let f=new Map,p=[],h={totalRatio:0},y=!1;const b=Zr(async()=>{await Qr(1e3),y&&(G(T),y=!1)},0),g=e.props.state.plugins.currency[t.currencyInfo.pluginId],w={onAddressChanged:()=>{},onAddressesChecked(e){w.onSyncStatusChanged({totalRatio:e})},onNewTokens:e=>{const t=e.sort((e,t)=>e.localeCompare(t));if(p.length!==t.length)return p=t,void(y=!0);for(let n=0;n<t.length;n++)if(p[n]!==t[n])return p=t,void(y=!0)},onSeenTxCheckpoint:()=>{},onStakingStatusChanged:()=>{},onSubscribeAddresses:()=>{},onSyncStatusChanged(e){1!==h.totalRatio&&1===e.totalRatio&&(h=e,y=!0)},onTokenBalanceChanged:(e,t)=>{f.get(e)!==t&&(f=new Map(f),f.set(e,t),y=!0)},onTransactions:()=>{},onTransactionsChanged:()=>{},onTxidsChanged:()=>{},onUnactivatedTokenIdsChanged:()=>{},onWcNewContractCall:()=>{},onBlockHeightChanged:()=>{},onBalanceChanged:()=>{}},v=await g.makeCurrencyEngine(c,{callbacks:w,customTokens:Nc({},t.customTokens),enabledTokenIds:[...Object.keys(t.allTokens)],lightMode:!0,log:d,userSettings:Nc({},null!==(o=t.userSettings)&&void 0!==o?o:{}),walletSettings:a,walletLocalDisklet:(0,re.cQ)(),walletLocalEncryptedDisklet:(0,re.cQ)()}),{unsafeBroadcastTx:m=!1,unsafeMakeSpend:I=!1,unsafeSyncNetwork:E=!1}=g.currencyInfo,S=Nc({},i);let O;if(null!=v.syncNetwork){const t=async()=>{if(null!=v.syncNetwork){const e=await v.syncNetwork({privateKeys:E?S:void 0});O.setDelay(e)}else O.stop()};O=Zr(t,1e4,{onError:t=>{e.props.log.error(t)}}),O.start({wait:!1})}const A={};if(null!=v.otherMethods)for(const _ of Object.keys(v.otherMethods)){const e=v.otherMethods[_];"function"==typeof e&&(A[_]=e)}if(null!=v.otherMethodsWithKeys)for(const _ of Object.keys(v.otherMethodsWithKeys)){const e=v.otherMethodsWithKeys[_];"function"==typeof e&&(A[_]=(...t)=>e(c.keys,...t))}P(A);const T=P({watch:ee,get balanceMap(){return f},get detectedTokenIds(){return p},get syncRatio(){return h.totalRatio},get syncStatus(){return h},async changeEnabledTokenIds(e){null!=v.changeEnabledTokenIds&&await v.changeEnabledTokenIds(e)},async startEngine(){var e;await v.startEngine(),null===(e=O)||void 0===e||e.start({wait:!1})},async getMaxSpendable(e){return await Us(e,g,v,t.allTokens,c)},async makeSpend(e){return await v.makeSpend(e,I?S:void 0)},async signTx(e){return await v.signTx(e,S)},async broadcastTx(e){return await v.broadcastTx(e,m?S:void 0)},async saveTx(){},otherMethods:A,async close(){var e;d.warn("killing memory wallet"),null===(e=O)||void 0===e||e.stop(),F(T),await v.killEngine()}});return b.start({wait:!1}),T};function Rc(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Lc(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Rc(Object(n),!0).forEach(function(t){r(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Rc(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}const Bc={},Kc=[];class Uc extends te{constructor(e,t,n){super(),this._ai=e,this._accountId=t,this._pluginId=n;const{otherMethods:r}=e.props.state.plugins.currency[n];null!=r?(P(r),this.otherMethods=r):this.otherMethods={}}get currencyInfo(){return this._ai.props.state.plugins.currency[this._pluginId].currencyInfo}get allTokens(){const{state:e}=this._ai.props,{_accountId:t,_pluginId:n}=this;return e.accounts[t].allTokens[n]}get builtinTokens(){const{state:e}=this._ai.props,{_accountId:t,_pluginId:n}=this;return e.accounts[t].builtinTokens[n]}get customTokens(){var e;const{state:t}=this._ai.props,{_accountId:n,_pluginId:r}=this;return null!==(e=t.accounts[n].customTokens[r])&&void 0!==e?e:Bc}async getTokenDetails(e){const{_ai:t,_pluginId:n}=this,r=await no(t,n);return null==r.getTokenDetails?[]:await r.getTokenDetails(e)}async getTokenId(e){const{_ai:t,_pluginId:n}=this;return await ia(t,n,e)}async addCustomToken(e){const{_accountId:t,_ai:n,_pluginId:r}=this,o=await ia(n,r,e);return n.props.dispatch({type:"ACCOUNT_CUSTOM_TOKEN_ADDED",payload:{accountId:t,pluginId:r,tokenId:o,token:e}}),o}async changeCustomToken(e,t){const{_accountId:n,_ai:r,_pluginId:o}=this;if(null==r.props.state.accounts[n].customTokens[o][e])throw new Error(`There is no token with id "${e}"`);const i=await ia(r,o,t);if(r.props.dispatch({type:"ACCOUNT_CUSTOM_TOKEN_ADDED",payload:{accountId:n,pluginId:o,tokenId:i,token:t}}),i!==e){const{wallets:t}=r.props.state.currency;for(const a of Object.keys(t)){const s=t[a];if(s.accountId!==n||s.pluginId!==o||!s.enabledTokenIds.includes(e))continue;const c=a.slice(0,2);r.props.log.warn(`enabledTokenIds: ${c} changeCustomToken edited id`),r.props.dispatch({type:"CURRENCY_WALLET_ENABLED_TOKENS_CHANGED",payload:{walletId:a,enabledTokenIds:ls([...s.enabledTokenIds,i],[e])}})}r.props.dispatch({type:"ACCOUNT_CUSTOM_TOKEN_REMOVED",payload:{accountId:n,pluginId:o,tokenId:e}})}}async removeCustomToken(e){const{_accountId:t,_ai:n,_pluginId:r}=this;n.props.dispatch({type:"ACCOUNT_CUSTOM_TOKEN_REMOVED",payload:{accountId:t,pluginId:r,tokenId:e}})}get alwaysEnabledTokenIds(){var e;const{state:t}=this._ai.props,{_accountId:n,_pluginId:r}=this;return null!==(e=t.accounts[n].alwaysEnabledTokenIds[r])&&void 0!==e?e:Kc}async changeAlwaysEnabledTokenIds(e){const{_accountId:t,_ai:n,_pluginId:r}=this;n.props.dispatch({type:"ACCOUNT_ALWAYS_ENABLED_TOKENS_CHANGED",payload:{accountId:t,pluginId:r,tokenIds:e}})}get userSettings(){return this._ai.props.state.accounts[this._accountId].userSettings[this._pluginId]}async changeUserSettings(e){await Go(this._ai,this._accountId,this._pluginId,e)}async importKey(e,t={}){const n=await no(this._ai,this._pluginId);if(null==n.importPrivateKey)throw new Error("This wallet does not support importing keys");return Lc(Lc({},await n.importPrivateKey(e,t.keyOptions)),{},{imported:!0})}}class Fc extends te{constructor(e,t,n){super(),this._ai=e,this._accountId=t,this._pluginId=n}get enabled(){const{swapSettings:e}=this._ai.props.state.accounts[this._accountId],{enabled:t=!0}=null!=e[this._pluginId]?e[this._pluginId]:{};return t}get needsActivation(){var e,t;const n=this._ai.props.state.plugins.swap[this._pluginId];if(null==n.checkSettings)return!1;const r=null!==(e=this._ai.props.state.accounts[this._accountId].userSettings[this._pluginId])&&void 0!==e?e:{};return null!==(t=n.checkSettings(r).needsActivation)&&void 0!==t&&t}get swapInfo(){return this._ai.props.state.plugins.swap[this._pluginId].swapInfo}get userSettings(){return this._ai.props.state.accounts[this._accountId].userSettings[this._pluginId]}async changeEnabled(e){const t=this._ai.props.state.accounts[this._accountId];return await async function(e,t,n,r){var o;const{accountWalletInfo:i}=e.props.state.accounts[t],a=Eo(e.props.state,i.id),s=null!==(o=await Lo.load(a,Ko))&&void 0!==o?o:Bo;await Lo.save(a,Ko,jo(jo({},s),{},{swapSettings:jo(jo({},e.props.state.accounts[t].swapSettings),{},{[n]:r})})),e.props.dispatch({type:"ACCOUNT_SWAP_SETTINGS_CHANGED",payload:{accountId:t,pluginId:n,swapSettings:r}})}(this._ai,this._accountId,this._pluginId,Lc(Lc({},t.swapSettings[this._pluginId]),{},{enabled:e}))}async changeUserSettings(e){await Go(this._ai,this._accountId,this._pluginId,e)}}async function Wc(e,t,n){const{currency:r}=e.props.state.plugins,o=eo(r,t.type),{hasWalletSettings:i=!1}=r[o].currencyInfo;if(!i)return;const{io:a}=e.props,s=ro(t.keys),{disklet:c}=uo(a,s);await yc(c,n)}function Gc(e,t){let n=e.props.state.accounts[t];const r=()=>{const r=e.props.state.accounts[t];return null!=r&&(n=r),n},{accountWalletInfo:o,loginType:i}=r(),a={};for(const p of Object.keys(e.props.state.plugins.currency)){const n=new Uc(e,t,p);a[p]=n}const s={};for(const p of Object.keys(e.props.state.plugins.swap)){const n=new Fc(e,t,p);s[p]=n}const c=function(e,t){const{accountWalletInfo:n}=e.props.state.accounts[t],r=Eo(e.props.state,n.id),o=t=>Oo(e.props.state,n.id,t),i=e=>`Plugins/${o(e)}`,a=(e,t)=>`${i(e)}/${o(t)}.json`,s={async deleteItem(e,t){await r.delete(a(e,t))},async deleteStore(e){await r.delete(i(e))},async listItemIds(e){const t=[],n=(0,re.WR)(await r.list(i(e)));return await Promise.all(n.map(async e=>{const n=await Mc.load(r,e);null!=n&&t.push(n.key)})),t},async listStoreIds(){const e=[],t=(0,re.a8)(await r.list("Plugins"));return await Promise.all(t.map(async t=>{const n=await Pc.load(r,`${t}/Name.json`);null!=n&&e.push(n.name)})),e},async getItem(e,t){const n=await Mc.load(r,a(e,t));if(null==n)throw new Error(`No item named "${t}"`);return n.data},async setItem(e,t,n){const o=`${i(e)}/Name.json`,s=await Pc.load(r,o);if(null==s)await Pc.save(r,o,{name:e});else if(s.name!==e)throw new Error(`Warning: folder name doesn't match for ${e}`);await Mc.save(r,a(e,t),{key:t,data:n})}};return P(s),s}(e,t),u=ga(e,o);function l(){if(e.props.state.hideKeys)throw new Error("Not available when `hideKeys` is enabled")}let d=!1;const f={on:Q,watch:ee,get id(){return u.id},get type(){return u.type},get disklet(){return l(),u.disklet},get localDisklet(){return l(),u.localDisklet},async sync(){await u.sync()},get appId(){return r().login.appId},get created(){return r().login.created},async getLoginKey(){return l(),Lt.stringify(r().login.loginKey)},get lastLogin(){return r().login.lastLogin},get loggedIn(){return null!=e.props.state.accounts[t]},get recoveryKey(){l();const{login:e}=r();return null!=e.recovery2Key?Lt.stringify(e.recovery2Key):void 0},get rootLoginId(){l();const{loginTree:e}=r();return Lt.stringify(e.loginId)},get username(){const{loginTree:e}=r();return e.username},get canDuressLogin(){const{activeAppId:t}=r();if(e.props.state.clientInfo.duressEnabled)return d;const n=t.endsWith(".duress")?t:t+".duress",o=zn(r().loginTree,e=>e.appId===n);return null!=(null==o?void 0:o.pin2Key)},get isDuressAccount(){const{activeAppId:e}=r();return e.endsWith(".duress")},get currencyConfig(){return a},get swapConfig(){return s},get dataStore(){return c},get edgeLogin(){const{loginTree:e}=r();return null==e.loginKey},keyLogin:"keyLogin"===i,newAccount:"newAccount"===i,passwordLogin:"passwordLogin"===i,pinLogin:"pinLogin"===i,recoveryLogin:"recoveryLogin"===i,async changePassword(n){l(),this.isDuressAccount||await async function(e,t,n){const r=e.props.state.accounts[t],{loginTree:o,sessionKey:i}=r,{username:a}=r.stashTree;if(null==a)throw new Error("Password login requires a username");const s=await ui(e,o,a,n);await Zn(e,i,s)}(e,t,n)},async changePin(n){l(),e.props.log.breadcrumb("EdgeAccount.changePin",{});const{forDuressAccount:o=!1}=n,{activeAppId:i}=r(),a=i.endsWith(".duress")?i:i+".duress";var s;if(this.isDuressAccount&&o)return d=null!==(s=n.enableLogin)&&void 0!==s?s:null!=n.pin,e.props.dispatch({type:"UPDATE_NEXT"}),"";o&&await Mi(e,r().stashTree,r().sessionKey,a),await hi(e,t,n);const c=o?zn(r().login,e=>e.appId===a):r().login;if(null==c)throw new Error("Failed to find account.");return null!=c.pin2Key?Lt.stringify(c.pin2Key):""},async changeRecovery(n,o){if(l(),this.isDuressAccount)return"1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa";await Ii(e,t,n,o);const{loginTree:i}=r();if(null==i.recovery2Key)throw new Error("Missing recoveryKey");return Lt.stringify(i.recovery2Key)},async changeUsername(n){l(),n.username=ae(n.username),await async function(e,t,n){const{loginTree:r}=e.props.state.accounts[t],o=await Promise.all(function t(r){const o=[Ti(e,r,n)];for(const e of r.children)o.push(...t(e));return o}(r));await Qn(e,r,o)}(e,t,n)},async checkPassword(t){l();const{loginTree:n,stashTree:o}=r(),{loginKey:i}=n;return await async function(e,t,n,r){if(null!=r){const{passwordAuthBox:o,username:i}=t;if(null==o||null==i)return!1;const a=dn(o,r),s=si(i,n),c=await An(e,s,ai);for(let e=0;e<a.length;++e)if(c[e]!==a[e])return!1;return!0}{const{passwordBox:r,passwordKeySnrp:i,username:a}=t;if(null==r||null==i||null==a)throw new Error("Missing data for offline password login");const s=si(a,n),c=await An(e,s,i);try{return dn(r,c),!0}catch(o){return!1}}}(e,o,t,i)},async checkPin(t,n={}){l();const{login:o,loginTree:i}=r();return null!=o.pin&&null==n.forDuressAccount?t===o.pin:await async function(e,t,n,r){const{loginId:o,username:i}=t;if(null==i)return!1;const a=!0===r?t.appId+".duress":t.appId;if(e.props.state.clientInfo.duressEnabled)return!1;const{stashTree:s}=xn(e,o),c=!0===r?Ln(s,a):fi(s,a);if(null==c||null==c.pin2Key)throw new zt("No PIN set locally for this account");const{pin2Key:u}=c,l={pin2Id:li(u,i),pin2Auth:di(u,n),otp:Un(t)};return await In(e,"POST","/v2/login",l).then(e=>!0,e=>!1)}(e,i,t,n.forDuressAccount)},async getPin(){var e;const{login:t,loginTree:n}=r();return null!==(e=t.pin)&&void 0!==e?e:n.pin},async deletePassword(){l(),await async function(e,t){const{loginTree:n,sessionKey:r}=e.props.state.accounts[t],o={loginId:n.loginId,server:void 0,serverMethod:"DELETE",serverPath:"/v2/login/password",stash:{passwordAuthSnrp:void 0,passwordBox:void 0,passwordKeySnrp:void 0}};null!=n.loginAuth&&(o.stash.passwordAuthBox=void 0),await Zn(e,r,o)}(e,t)},async deletePin(){l();const n=e.props.state.clientInfo.duressEnabled;await async function(e,t,n){const{loginTree:r}=e.props.state.accounts[t],o=wi(r,n);await Qn(e,r,o)}(e,t,n)},async deleteRecovery(){l(),await async function(e,t){const{loginTree:n,sessionKey:r}=e.props.state.accounts[t],o={login:{recovery2Key:void 0},loginId:n.loginId,server:void 0,serverMethod:"DELETE",serverPath:"/v2/login/recovery2",stash:{recovery2Key:void 0}};await Zn(e,r,o)}(e,t)},get otpKey(){l();const{loginTree:e}=r();return null!=e.otpKey?b(e.otpKey,{pad:!1}):void 0},get otpResetDate(){l();const{loginTree:e}=r();return e.otpResetDate},async cancelOtpReset(){l(),await async function(e,t){const{loginTree:n,sessionKey:r}=e.props.state.accounts[t],{otpTimeout:o,otpKey:i}=n;if(null==o||null==i)throw new Error("Cannot cancel 2FA reset: 2FA is not enabled.");const a={loginId:n.loginId,server:dt({otpTimeout:o,otpKey:i}),serverPath:"/v2/login/otp",stash:{otpResetDate:void 0}};await Zn(e,r,a)}(e,t)},async enableOtp(n=604800){if(l(),this.isDuressAccount)return await async function(e,t){const{stashTree:n}=e.props.state.accounts[t],r=e.props.io.random(10);await jn(e,Kn(Kn({},n),{},{otpKey:r}))}(e,t);await async function(e,t,n){const{loginTree:r,sessionKey:o}=e.props.state.accounts[t],{otpKey:i=e.props.io.random(10)}=r,a={loginId:r.loginId,server:dt({otpKey:i,otpTimeout:n}),serverPath:"/v2/login/otp",stash:{otpKey:i,otpResetDate:void 0,otpTimeout:n}};await Zn(e,o,a)}(e,t,n)},async disableOtp(){if(l(),this.isDuressAccount)return await async function(e,t){const{stashTree:n}=e.props.state.accounts[t];await jn(e,Kn(Kn({},n),{},{otpKey:void 0}))}(e,t);await async function(e,t){const{loginTree:n,sessionKey:r}=e.props.state.accounts[t],o={loginId:n.loginId,server:void 0,serverMethod:"DELETE",serverPath:"/v2/login/otp",stash:{otpKey:void 0,otpResetDate:void 0,otpTimeout:void 0}};await Zn(e,r,o)}(e,t)},async repairOtp(n){l(),await async function(e,t,n){if(null==e.props.state.accounts[t])return;const{login:r}=e.props.state.accounts[t],{userId:o,passwordAuth:i}=r,{stashTree:a,stash:s}=xn(e,r.loginId);if(null==i||null==o)throw new Error("Cannot repair OTP: There is no password on this account");const c={userId:o,passwordAuth:i,otp:yn(n)},u={now:a.lastLogin};await Xn(e,a,s,u,c,async()=>r.loginKey)}(e,t,y(n,{loose:!0}))},get pendingVouchers(){const{login:e}=r();return e.pendingVouchers},async approveVoucher(t){const{loginTree:n}=r();return await Ec(e,n,{approvedVouchers:[t]})},async rejectVoucher(t){const{loginTree:n}=r();return await Ec(e,n,{rejectedVouchers:[t]})},async fetchLobby(n){return e.props.log.breadcrumb("EdgeAccount.fetchLobby",{}),l(),await Yi(e,t,n)},async deleteRemoteAccount(){const{loginTree:t}=r();this.isDuressAccount||await async function(e,t){const{stashTree:n}=xn(e,t.loginId),{deviceDescription:r}=e.props.state.login.deviceInfo,o=nr(n,t);null!=r&&(o.deviceDescription=r),await In(e,"POST","/v2/login/delete",o)}(e,t)},async logout(){e.props.dispatch({type:"LOGOUT",payload:{accountId:t}})},get allKeys(){return e.props.state.accounts[t].allWalletInfosClean},async changeWalletStates(n){await Wo(e,t,n)},async createWallet(t,n){const{login:o,sessionKey:i,stashTree:a}=r();e.props.log.breadcrumb("EdgeAccount.createWallet",{});const s=await oi(e,t,{keys:n}),c=tr(a,i,o.loginId);return await Zn(e,i,ei(e,c,[s])),s.id},getFirstWalletInfo:oe.prototype.getFirstWalletInfo,getWalletInfo:oe.prototype.getWalletInfo,listWalletIds:oe.prototype.listWalletIds,async splitWalletInfo(n,o){var i,a;const{allWalletInfosFull:s}=r(),c=s.find(e=>e.id===n);if(null==c)throw new Error(`Invalid wallet id ${n}`);const u=null===(i=e.props.output)||void 0===i||null===(i=i.currency)||void 0===i||null===(i=i.wallets[c.id])||void 0===i?void 0:i.walletApi;if("wallet:bitcoin"===c.type&&"bip49"===c.keys.format&&"wallet:bitcoincash"===o)throw new Error("Cannot split segwit-format Bitcoin wallets to Bitcoin Cash");const[l]=await ya(e,t,c,[{walletType:o,name:null!==(a=null==u?void 0:u.name)&&void 0!==a?a:void 0,fiatCurrencyCode:null==u?void 0:u.fiatCurrencyCode}],!0);if(l.ok)return l.result.id;throw l.error},async listSplittableWalletTypes(n){return await async function(e,t,n){const{allWalletInfosFull:r}=e.props.state.accounts[t],o=r.find(e=>e.id===n);if(null==o)throw new Error(`Invalid wallet id ${n}`);const i=to(e.props.state.plugins.currency,o.type);if(null==i)return[];const a=await no(e,i);return null==a.getSplittableTypes?[]:(await a.getSplittableTypes(o)).filter(e=>{const t=ha(o,e),n=r.find(e=>e.id===t.id);return null==n||n.archived||n.deleted})}(e,t,n)},async getDisplayPrivateKey(n){const r=zc(e,t,n),o=eo(e.props.state.plugins.currency,r.type),i=await no(e,o);if(null!=i.getDisplayPrivateKey)return await i.getDisplayPrivateKey(r);const{engine:a}=e.props.output.currency.wallets[n];if(null==a||null==a.getDisplayPrivateSeed)throw new Error("Wallet has not yet loaded");const s=await a.getDisplayPrivateSeed(r.keys);if(null==s)throw new Error("The engine failed to return a key");return s},async getDisplayPublicKey(n){const r=zc(e,t,n),o=eo(e.props.state.plugins.currency,r.type),i=await no(e,o);if(null!=i.getDisplayPublicKey){const t=co(e.props.io,n),o=await Ts(r,t,i);return await i.getDisplayPublicKey(o)}const{engine:a}=e.props.output.currency.wallets[n];if(null==a||null==a.getDisplayPublicSeed)throw new Error("Wallet has not yet loaded");const s=await a.getDisplayPublicSeed();if(null==s)throw new Error("The engine failed to return a key");return s},async getRawPrivateKey(n){return zc(e,t,n).keys},async getRawPublicKey(n){const r=zc(e,t,n),o=eo(e.props.state.plugins.currency,r.type),i=await no(e,o),a=co(e.props.io,n);return(await Ts(r,a,i)).keys},get activeWalletIds(){return e.props.state.accounts[t].activeWalletIds},get archivedWalletIds(){return e.props.state.accounts[t].archivedWalletIds},get hiddenWalletIds(){return e.props.state.accounts[t].hiddenWalletIds},get currencyWallets(){return e.props.output.accounts[t].currencyWallets},get currencyWalletErrors(){return e.props.state.accounts[t].currencyWalletErrors},async createCurrencyWallet(n,o={}){const{login:i,sessionKey:a,stashTree:s}=r();e.props.log.breadcrumb("EdgeAccount.createCurrencyWallet",{});const c=await oi(e,n,o);null!=o.walletSettings&&await Wc(e,c,o.walletSettings);const u=tr(s,a,i.loginId);return await Zn(e,a,ei(e,u,[c])),await ii(e,t,c.id,o)},async makeMemoryWallet(t,n={}){const r=Object.values(a).find(e=>e.currencyInfo.walletType===t);if(null==r)throw new Error("Invalid walletType");return await Dc(e,r,t,n)},async createCurrencyWallets(n){const{login:o,sessionKey:i,stashTree:a}=r();e.props.log.breadcrumb("EdgeAccount.makeMemoryWallet",{});const s=await Promise.all(n.map(async t=>await oi(e,t.walletType,t)));for(let t=0;t<s.length;t++){const{walletSettings:r}=n[t];null!=r&&await Wc(e,s[t],r)}const c=tr(a,i,o.loginId);return await Zn(e,i,ei(e,c,s)),await Promise.all(s.map(async(r,o)=>await vo(ii(e,t,r.id,n[o]))))},async waitForCurrencyWallet(e){return await new Promise((t,n)=>{const r=()=>{const r=this.currencyWallets[e];null!=r&&(t(r),o());const i=this.currencyWalletErrors[e];null!=i&&(n(i),o())},o=()=>{for(const e of i)e()},i=[this.watch("currencyWallets",r),this.watch("currencyWalletErrors",r)];r()})},async waitForAllWallets(){return await new Promise((e,t)=>{const n=()=>{if(null==this.activeWalletIds.find(e=>null==this.currencyWallets[e]&&null==this.currencyWalletErrors[e])){for(const e of r)e();e()}},r=[this.watch("activeWalletIds",n),this.watch("currencyWallets",n),this.watch("currencyWalletErrors",n)];n()})},async getActivationAssets({activateWalletId:n,activateTokenIds:r}){const{currencyWallets:o}=e.props.output.accounts[t],i=e.props.output.currency.wallets[n],{engine:a}=i;if(null==a)throw new Error(`Invalid wallet: ${n} not found`);if(null==a.engineGetActivationAssets)throw new Error(`getActivationAssets unsupported by walletId ${n}`);const s=await a.engineGetActivationAssets({currencyWallets:o,activateTokenIds:r});return s.assetOptions.forEach(e=>{var t;return e.tokenId=null!==(t=e.tokenId)&&void 0!==t?t:null}),s},async activateWallet(n){var r;const{activateWalletId:o,activateTokenIds:i,paymentInfo:a}=n,{currencyWallets:s}=e.props.output.accounts[t],c=e.props.output.currency.wallets[o],{engine:u}=c;if(null==u)throw new Error(`Invalid wallet: ${o} not found`);if(null==u.engineActivateWallet)throw new Error(`activateWallet unsupported by walletId ${o}`);const l=null!==(r=null==a?void 0:a.walletId)&&void 0!==r?r:"",d=s[l];if(null==d)throw new Error(`No wallet for walletId ${l}`);const f=await u.engineActivateWallet({activateTokenIds:i,paymentInfo:null!=a?{wallet:d,tokenId:a.tokenId}:void 0,paymentTokenId:null==a?void 0:a.tokenId,paymentWallet:d});return void 0===f.networkFee.tokenId&&(f.networkFee.tokenId=null),P(f)},async fetchSwapQuote(n,r){const[o,...i]=await _c(e,t,n,r);for(const e of i)e.close().catch(()=>{});if(null==o)throw new Error("No swap providers enabled");return o},async fetchSwapQuotes(n,r){return await _c(e,t,n,r)}};return P(f),f}function zc(e,t,n){const r=e.props.state.accounts[t].allWalletInfosFull.find(e=>e.id===n);if(null==r)throw new Error(`Invalid wallet: ${n} not found`);return r}function qc(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}function $c(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Hc(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?$c(Object(n),!0).forEach(function(t){r(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):$c(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}const Yc={},Vc={loginId:new Uint8Array,loginKey:new Uint8Array},Jc=es({accountWalletInfo:ss(e=>e.self.activeAppId,e=>e.self.allWalletInfosFull,(e,t)=>{const n=Zo(e),r=Xo(t,n);if(null==r)throw new Error(`Cannot find a "${n}" repo`);return r}),accountWalletInfos:ss(e=>e.self.activeAppId,e=>e.self.allWalletInfosFull,(e,t)=>{const n=[Zo(e)];return""===e&&n.push("account:repo:co.airbitz.wallet",""),t.filter(e=>n.includes(e.type))}),allWalletInfosFull:ss(e=>e.self.stashTree,e=>e.self.login,e=>e.self.legacyWalletInfos,e=>e.self.walletStates,(e,t,n,r)=>function(e,t,n,r){const o=new Map,i=new Map,a=[...n],s=Pn(e,t.loginId);for(const c of n){a.push(c);const e=i.get(c.id);null!=e?e.push(s.appId):i.set(c.id,[s.appId])}return function e(t,n){const r=ni(t,n,o);for(const o of r){a.push(o);const e=i.get(o.id);null!=e?e.push(t.appId):i.set(o.id,[t.appId])}for(const o of null!==(s=t.children)&&void 0!==s?s:[]){var s;null!=o.parentBox&&e(o,dn(o.parentBox,n))}}(s,t.loginKey),ti(a).map(e=>{var t,n,s;return Jo(Jo({appId:(s=null!==(t=i.get(e.id))&&void 0!==t?t:[],s[s.length-1]),appIds:null!==(n=i.get(e.id))&&void 0!==n?n:[],archived:!1,created:o.get(e.id),deleted:!1,hidden:!1,sortIndex:a.length,imported:e.keys.imported},r[e.id]),e)})}(e,t,n,r)),allWalletInfosClean:ss(e=>e.self.allWalletInfosFull,e=>e.map(e=>Hc(Hc({},e),{},{keys:{}}))),currencyWalletErrors(e={},t,n,r){var o;const{activeWalletIds:i}=n.self,a=n.root.currency.wallets;let s=i!==(null===(o=r.self)||void 0===o?void 0:o.activeWalletIds);const c={};for(const u of i){const t=a[u].engineFailure;null!=t&&(c[u]=t),c[u]!==e[u]&&(s=!0)}return s?c:e},currencyWalletIds:ss(e=>e.self.walletInfos,e=>e.root.plugins.currency,(e,t)=>Object.keys(e).filter(n=>{const r=e[n],o=to(t,r.type);return!r.deleted&&null!=o}).sort((t,n)=>{const r=e[t],o=e[n];return r.sortIndex-o.sortIndex})),activeWalletIds:ss(e=>e.self.walletInfos,e=>e.self.currencyWalletIds,e=>e.self.keysLoaded,(e,t,n)=>n?t.filter(t=>!e[t].archived):[]),archivedWalletIds:ss(e=>e.self.walletInfos,e=>e.self.currencyWalletIds,e=>e.self.keysLoaded,(e,t,n)=>n?t.filter(t=>e[t].archived):[]),hiddenWalletIds:ss(e=>e.self.walletInfos,e=>e.self.currencyWalletIds,e=>e.self.keysLoaded,(e,t,n)=>n?t.filter(t=>e[t].hidden):[]),keysLoaded(e=!1,t){return"ACCOUNT_KEYS_LOADED"===t.type||e},legacyWalletInfos(e=[],t){return"ACCOUNT_KEYS_LOADED"===t.type?t.payload.legacyWalletInfos:e},walletInfos:ss(e=>e.self.allWalletInfosFull,e=>{const t={};for(const n of e)t[n.id]=n;return t}),walletStates(e={},t){return"ACCOUNT_CHANGED_WALLET_STATES"===t.type||"ACCOUNT_KEYS_LOADED"===t.type?t.payload.walletStates:e},pauseWallets(e=!1,t){return"LOGIN"===t.type?t.payload.pauseWallets:e},activeAppId:(e="",t)=>"LOGIN"===t.type?t.payload.appId:e,loadFailure(e=null,t){if("ACCOUNT_LOAD_FAILED"===t.type){const{error:e}=t.payload;return e instanceof Error?e:new Error(String(e))}return e},login:ss(e=>e.self.activeAppId,e=>e.self.loginTree,(e,t)=>{const n=zn(t,t=>t.appId===e);if(null==n)throw new Error(`Internal error: cannot find login for ${e}`);return n}),loginTree:ss(e=>e.self.stashTree,e=>e.self.sessionKey,(e,t)=>Vn(e,t)),loginType(e="newAccount",t){return"LOGIN"===t.type?t.payload.loginType:e},rootLoginId(e=new Uint8Array(0),t){return"LOGIN"===t.type?t.payload.rootLoginId:e},sessionKey(e=Vc,t){return"LOGIN"===t.type?t.payload.sessionKey:e},stashTree:ss(e=>e.self.rootLoginId,e=>e.root.login.stashes,(e,t)=>{for(const n of t)if(cn(n.loginId,e))return n;throw new Error("There is no stash")}),allTokens(e={},t,n,r){const{builtinTokens:o,customTokens:i}=n.self;if(null==r.self||o!==r.self.builtinTokens||i!==r.self.customTokens){const t=Hc({},e);for(const e of Object.keys(n.root.plugins.currency))null!=r.self&&o[e]===r.self.builtinTokens[e]&&i[e]===r.self.customTokens[e]||(t[e]=Hc(Hc({},i[e]),o[e]));return t}return e},builtinTokens(e={},t){if("ACCOUNT_BUILTIN_TOKENS_LOADED"===t.type){const{pluginId:n,tokens:r}=t.payload;return Hc(Hc({},e),{},{[n]:r})}return e},customTokens(e=Yc,t){switch(t.type){case"ACCOUNT_CUSTOM_TOKENS_LOADED":{const{customTokens:e}=t.payload;return e}case"ACCOUNT_CUSTOM_TOKEN_ADDED":{var n;const{pluginId:r,tokenId:o,token:i}=t.payload,a=null!==(n=e[r])&&void 0!==n?n:{};if(va(a[o],i))return e;const s=Hc(Hc({},a),{},{[o]:i});return Hc(Hc({},e),{},{[r]:s})}case"ACCOUNT_CUSTOM_TOKEN_REMOVED":{var r;const{pluginId:n,tokenId:o}=t.payload,i=null!==(r=e[n])&&void 0!==r?r:{};if(null==i[o])return e;const{[o]:a}=i,s=Sc(i,[o].map(qc));return Hc(Hc({},e),{},{[n]:s})}}return e},alwaysEnabledTokenIds(e={},t){if("ACCOUNT_ALWAYS_ENABLED_TOKENS_CHANGED"===t.type){const{pluginId:n,tokenIds:r}=t.payload;return Hc(Hc({},e),{},{[n]:r})}return e},swapSettings(e={},t){switch(t.type){case"ACCOUNT_PLUGIN_SETTINGS_LOADED":return t.payload.swapSettings;case"ACCOUNT_SWAP_SETTINGS_CHANGED":{const{pluginId:n,swapSettings:r}=t.payload,o=Hc({},e);return o[n]=r,o}}return e},userSettings(e={},t){switch(t.type){case"ACCOUNT_PLUGIN_SETTINGS_CHANGED":{const{pluginId:n,userSettings:r}=t.payload,o=Hc({},e);return o[n]=r,o}case"ACCOUNT_PLUGIN_SETTINGS_LOADED":return t.payload.userSettings}return e}}),Xc=rs(Jc,(e,t)=>/^ACCOUNT_/.test(e.type)&&"payload"in e&&"object"==typeof e.payload&&"accountId"in e.payload&&e.payload.accountId===t.id||"LOGIN"===e.type&&t.root.lastAccountId===t.id?e:{type:"UPDATE_NEXT"});function Zc(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Qc(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Zc(Object(n),!0).forEach(function(t){r(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Zc(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}const eu=mr({accountApi(e){return{destroy(){e.props.state={accounts:{}};const{accountOutput:t}=e.props;if(null==t)return;const{accountApi:n}=t;if(null==n)return;G(n),F(n),F(n.dataStore);const{currencyConfig:r,swapConfig:o}=n;for(const e of Object.keys(r))F(r[e]);for(const e of Object.keys(o))F(o[e])},async update(){const t=Ou(e),{accountId:n,accountState:r,log:o}=e.props,{accountWalletInfos:i}=r;try{await async function(e){await e.waitFor(e=>{const{init:t,locked:n}=e.state.plugins;if(!n)return;const{currency:r,swap:o}=e.state.plugins,i=[];for(const a of Object.keys(t))!1!==t[a]&&null!=t[a]&&null==r[a]&&null==o[a]&&i.push(a);if(i.length>0)throw new Error("The following plugins are missing or failed to load: "+i.join(", "));return!0})}(t),await la(t,n),o.warn("Login: currency plugins exist"),await Promise.all(i.map(e=>go(t,e))),o.warn("Login: synced account repos"),await async function(){await Promise.all([Fo(t,n),da(t,n),zo(t,n)])}(),o.warn("Login: loaded files"),e.onOutput(Gc(t,n)),o.warn("Login: complete")}catch(a){e.props.dispatch({type:"ACCOUNT_LOAD_FAILED",payload:{accountId:n,error:a}})}return await Ar}}},syncTimer:Sr(e=>{const t=Zr(async function(){const t=Ou(e),{accountId:n,accountState:r}=e.props,{accountWalletInfos:o}=r;if(null==e.props.state.accounts[n])return;const i=await Promise.all(o.map(e=>wo(t,e.id))),a=[];for(const e of i)a.push(...e);a.length>0&&await Promise.all([zo(t,n),Fo(t,n)])},bo),n=Zr(async function(){const t=Ou(e),{accountId:n}=e.props;if(null==e.props.state.accounts[n])return;const{sessionKey:r}=e.props.state.accounts[n];await er(t,r)},bo,{onError(t){const n=Yt(t);null!=n&&e.props.onError(n)}});return{update(){var r;if(null==(null===(r=e.props.accountOutput)||void 0===r?void 0:r.accountApi))return;const{accountId:o}=e.props,{stashTree:i}=e.props.state.accounts[o],a=null!=i.wipChange?5e3:bo;t.setDelay(bo),n.setDelay(a),t.start({wait:bo*(1+Math.random())}),n.start({wait:a*(1+Math.random())})},destroy(){t.stop(),n.stop()}}},e=>e.state.paused?void 0:e),tokenSaver(e){let t=Yc;return async function(){const{accountId:n,accountState:r}=e.props,{customTokens:o}=r;o!==t&&t!==Yc&&(await async function(e,t){const{state:n}=e.props,{accountWalletInfo:r}=n.accounts[t],o=Eo(n,r.id),{customTokens:i}=e.props.state.accounts[t],a=await ta.load(o,ra);await ta.save(o,ra,ea(ea({},a),{},{customTokens:i}))}(Ou(e),n).catch(t=>e.props.onError(t)),await Qr(100)),t=o}},watcher(e){let t;return()=>{const{accountState:n,accountOutput:r}=e.props;if(null==n||null==r)return;const{accountApi:o}=r;if(null!=o&&G(o),t!==n&&(t=n,null!=o)){const{currencyConfig:e,swapConfig:t}=o;for(const n of Object.keys(e))G(e[n]);for(const n of Object.keys(t))G(t[n])}}},currencyWallets(e){let t;return()=>{const{accountOutput:n,accountState:r}=e.props,{activeWalletIds:o}=r;let i=t!==o;t=o;let a={};null!=(null==n?void 0:n.currencyWallets)&&(a=n.currencyWallets);const s={},{wallets:c}=e.props.output.currency;for(const e of o){var u;const t=null===(u=c[e])||void 0===u?void 0:u.walletApi;t!==a[e]&&(i=!0),null!=t&&(s[e]=t)}i&&e.onOutput(s)}}}),tu=Or(eu,e=>e.state.accountIds,(e,t)=>Qc(Qc({},e),{},{accountId:t,accountState:e.state.accounts[t],accountOutput:e.output.accounts[t]})),nu=["loginId"];function ru(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function ou(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?ru(Object(n),!0).forEach(function(t){r(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ru(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}class iu extends te{constructor(e){super(),this._lobby=e,this._cleanups=[e.close,e.on("reply",e=>G(this,"replies")),e.on("error",e=>W(this,"error",e))]}get lobbyId(){return this._lobby.lobbyId}get replies(){return this._lobby.replies}close(){this._cleanups.forEach(e=>e()),F(this)}}class au extends te{constructor(e){super(),this._ai=e}authRequest(e,t,n){return In(this._ai,e,t,n)}hashUsername(e){return Cn(this._ai,e)}async makeLobby(e,t=1e3){const n=await Ui(this._ai,e,t);return new iu(n)}fetchLobbyRequest(e){return Fi(this._ai,e)}async sendLobbyReply(e,t,n){await Wi(this._ai,e,t,n)}async syncRepo(e){const{io:t,syncClient:n}=this._ai.props,r=uo(t,{dataKey:new Uint8Array(0),syncKey:e});return await po(n,r,{lastSync:0,lastHash:void 0})}async getRepoDisklet(e,t){const{io:n}=this._ai.props,r=uo(n,{dataKey:t,syncKey:e});return P(r.disklet),r.disklet}}function su(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function cu(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?su(Object(n),!0).forEach(function(t){r(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):su(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function uu(e){const t=e.props.state.login.contextAppId,n=Lt.stringify(e.props.state.clientInfo.clientId),r=new au(e);let o;const i={on:Q,watch:ee,appId:t,clientId:n,async close(){e.props.close()},$internalStuff:r,fixUsername:ae,get localUsers(){return e.props.state.login.localUsers},async forgetAccount(t){const n=Lt.parse(t);for(const r of e.props.state.accountIds){if(cn(e.props.state.accounts[r].stashTree.loginId,n))throw new Error("Cannot remove logged-in user")}await async function(e,t){const{dispatch:n,io:r}=e.props,o=await r.disklet.list("logins").then(re.WR);for(const a of o)try{cn(Dn(JSON.parse(await r.disklet.getText(a))).loginId,t)&&await r.disklet.delete(a)}catch(i){}n({type:"LOGIN_STASH_DELETED",payload:t})}(e,n)},async fetchChallenge(){const t=await In(e,"POST","/v2/captcha/create",{}),{challengeId:n,challengeUri:r}=Ve(t);return{challengeId:n,challengeUri:r}},async usernameAvailable(t,n={}){const{challengeId:r}=n;return t=ae(t),await async function(e,t,n){const r={challengeId:n,userId:await Cn(e,t)};return await In(e,"POST","/v2/login",r).then(e=>!1).catch(e=>{if(null!=rn(e))return!0;throw e})}(e,t,r)},async createAccount(t){e.props.log.breadcrumb("EdgeContext.createAccount",{}),null!=t.username&&(t.username=ae(t.username));const n=await async function(e,t,n){const{challengeId:r,now:o=new Date}=t;e.props.log.breadcrumb("createLogin",{});const{kit:i,sessionKey:a}=await Pi(e,void 0,"",n),s={challengeId:r,data:i.server};return await In(e,"POST",i.serverPath,s),i.stash.lastLogin=o,await jn(e,i.stash),a}(e,t,t);return await Ci(e,n,"newAccount",t)},async loginWithKey(n,r,o={}){const{now:i=new Date,useLoginId:a=!1}=o,s=e.props.state.clientInfo.duressEnabled,c=a?xn(e,Lt.parse(n)).stashTree:kn(e,ae(n));if(null==c)throw new Error("User does not exist on this device");const u=zn(c,e=>e.appId===t);if(null==u)throw new Error(`Cannot find requested appId: "${t}"`);const l=t+".duress",d=zn(c,e=>e.appId===l);let f;try{f={loginId:u.loginId,loginKey:Lt.parse(r)},nr(c,f)}catch(p){if(!(p instanceof Error&&"Invalid checksum"===p.message))throw p;if(null==d)throw p;f={loginId:d.loginId,loginKey:Lt.parse(r)},nr(c,f)}return c.lastLogin=i,jn(e,c).catch(()=>{}),er(e,f).catch(t=>e.props.onError(t)),await Ci(e,f,"keyLogin",cu(cu({},o),{},{duressMode:s&&null!=(null==d?void 0:d.pin2Key)}))},async loginWithPassword(n,r,o={}){var i;e.props.log.breadcrumb("EdgeContext.loginWithPassword",{}),n=ae(n);const a=null!==(i=kn(e,n))&&void 0!==i?i:_n(n),s=await ci(e,a,r,o);if(e.props.state.clientInfo.duressEnabled){const r=t+".duress",i=kn(e,n);if(null==i)throw new Error("Missing stash after login with password");const a=zn(i,e=>e.appId===r);if(null!=(null==a?void 0:a.pin2Key)){const t=tr(i,s,a.loginId);return await Ci(e,t,"passwordLogin",cu(cu({},o),{},{duressMode:!0}))}}return await Ci(e,s,"passwordLogin",o)},checkPasswordRules:ie,async loginWithPIN(n,r,o={}){e.props.log.breadcrumb("EdgeContext.loginWithPIN",{});const{useLoginId:i=!1}=o,a=i?xn(e,Lt.parse(n)).stashTree:kn(e,ae(n));if(null==a)throw new Error("User does not exist on this device");const s=fi(a,t),c=t+".duress",u=zn(a,e=>e.appId===c);async function l(t,n){const i=null!=t.wipChange?await pi(e,t.wipChange,n,r,o).catch(async()=>await pi(e,t,n,r,o)):await pi(e,t,n,r,o);return await Ci(e,i,"pinLogin",o)}async function d(t,n){if(!0===n.fakePinDisabled)throw new zt("PIN login is not enabled for this account on this device");const i=await pi(e,t,n,r,o);return await Ci(e,i,"pinLogin",cu(cu({},o),{},{duressMode:!0}))}if(null==s){if(null==u)throw new zt("PIN login is not enabled for this account on this device");return await d(a,u)}if(null==(null==u?void 0:u.pin2Key))return await l(a,s);const f=e.props.state.clientInfo.duressEnabled,p=Lt.stringify(s.loginId),h=e.props.state.clientInfo.loginWaitTimestamps[p];if(null!=h&&h>Date.now())throw new Gt({wait_seconds:Math.ceil((h-Date.now())/1e3)});try{return f?await d(a,u):await l(a,s)}catch(b){if(null==Vt(b))throw b;try{const t=f?await l(a,s):await d(a,u);return f?await async function(){await Pr.save(e.props.io.disklet,xr,cu(cu({},e.props.state.clientInfo),{},{duressEnabled:!1})),e.props.dispatch({type:"LOGIN_DURESS_MODE_DISABLED"})}():await async function(){await Pr.save(e.props.io.disklet,xr,cu(cu({},e.props.state.clientInfo),{},{duressEnabled:!0})),e.props.dispatch({type:"LOGIN_DURESS_MODE_ENABLED"})}(),t}catch(g){var y;const t=[Vt(g),Vt(b)].reduce((e,t)=>{var n,r;return(null!==(n=null==e?void 0:e.wait)&&void 0!==n?n:0)>(null!==(r=null==t?void 0:t.wait)&&void 0!==r?r:0)?e:t}),n=1e3*(null!==(y=null==t?void 0:t.wait)&&void 0!==y?y:0);if(null!=t&&n>0){const r=Date.now()+n;throw await async function(t,n){await Pr.save(e.props.io.disklet,xr,cu(cu({},e.props.state.clientInfo),{},{loginWaitTimestamps:cu(cu({},e.props.state.clientInfo.loginWaitTimestamps),{},{[t]:n})})),e.props.dispatch({type:"LOGIN_WAIT_TIMESTAMP_UPDATED",payload:{loginId:t,timestamp:n}})}(p,r),t}if(null!=Jt(g))throw b;throw g}}},async loginWithRecovery2(t,n,r,o={}){e.props.log.breadcrumb("EdgeContext.loginWithRecovery2",{}),n=ae(n);const i=kn(e,n),a=await async function(e,t,n,r,o){const{username:i}=t;if(null==i)throw new Error("Recovery login requires a username");const a={recovery2Id:vi(n,i),recovery2Auth:mi(n,r)};return await Xn(e,t,t,o,a,async e=>{if(null==e.recovery2Box||!0===e.recovery2Box)throw new Error("Missing data for recovery v2 login");return dn(e.recovery2Box,n)})}(e,null!=i?i:_n(n),Lt.parse(t),r,o);return await Ci(e,a,"recoveryLogin",o)},async fetchRecovery2Questions(t,n){return n=ae(n),await async function(e,t,n){const r={recovery2Id:vi(t,n)},o=await In(e,"POST","/v2/login",r),{question2Box:i}=ot(o);if(null==i)throw new Error("Login has no recovery questions");return Ei(JSON.parse(ln(i,t)))}(e,Lt.parse(t),n)},async requestEdgeLogin(n){return e.props.log.breadcrumb("EdgeContext.requestEdgeLogin",{}),await zi(e,t,n)},async requestOtpReset(t,n){return t=ae(t),await async function(e,t,n){const r={userId:await Cn(e,t),otpResetAuth:n},o=await In(e,"DELETE","/v2/login/otp",r),{otpResetDate:i}=nt(o);return i}(e,t,n)},async fetchLoginMessages(){return await async function(e){const{stashes:t}=e.props.state.login,n={},r=[];for(const s of t){const{loginId:e,username:t}=s;null!=t&&(n[w(e)]=t,r.push(e))}const o={loginIds:r},i=await In(e,"POST","/v2/messages",o),a=[];for(const s of et(i)){const{loginId:e}=s,t=Sc(s,nu),r=w(e),o=n[r];null!=o&&a.push(ou(ou({},t),{},{loginId:r,username:o}))}return a}(e)},get paused(){return e.props.state.paused},async changePaused(t,n={}){const{secondsDelay:r=0}=n;null!=o&&(clearTimeout(o),o=void 0),e.props.state.paused!==t&&(0===r?e.props.dispatch({type:"PAUSE",payload:t}):o=setTimeout(()=>{o=void 0,e.props.dispatch({type:"PAUSE",payload:t})},1e3*r))},get logSettings(){return e.props.state.logSettings},async changeLogSettings(t){const n=cu(cu({},e.props.state.logSettings),t);e.props.dispatch({type:"CHANGE_LOG_SETTINGS",payload:n})},async setAttestationToken(t){e.props.dispatch({type:"SET_ATTESTATION_TOKEN",payload:t})}};return P(i),i}const lu=mr({api(e){return{destroy(){F(e.props.output.context.api)},update(){return e.onOutput(uu(e)),Ar}}},watcher(e){let t,n,r;return()=>{t===e.props.state.login.localUsers&&n===e.props.state.paused&&r===e.props.state.logSettings||(t=e.props.state.login.localUsers,n=e.props.state.paused,r=e.props.state.logSettings,null!=e.props.output.context.api&&G(e.props.output.context.api))}},infoFetcher:Sr(e=>{const t=Zr(async function(){const{dispatch:t,io:n}=e.props,{contextAppId:r,deviceInfo:o}=e.props.state.login,{appVersion:i,osType:a,osVersion:s}=o,[c]=Io(e.props.state.infoServers);let u;if(null!=a&&null!=s&&null!=i){const e=new URLSearchParams;e.set("appId",""!==r?r:"edge"),e.set("os",a),e.set("osVersion",s),e.set("appVersion",i),u=`${c}/v2/coreRollup?${e.toString()}`}else u=`${c}/v1/coreRollup`;const l=await fetch(u,{headers:{accept:"application/json"}});if(!l.ok)return;const d=await l.json(),f=Cr(d);t({type:"INFO_CACHE_FETCHED",payload:f}),await Nr.save(n.disklet,Mr,f)},6e5,{onError(t){e.props.onError(t)}});return{update(){t.started||t.start()},destroy(){t.stop()}}},e=>e.state.paused?void 0:e)});function du(e,t){if("object"!=typeof e||"object"!=typeof t||null==e||null==t)return e===t;const n=Array.isArray(e);if(n!==Array.isArray(t))return!1;if(n){if(e.length!==t.length)return!1;for(let n=0;n<e.length;++n)if(!du(e[n],t[n]))return!1;return!0}const r=Object.getOwnPropertyNames(e).filter(t=>void 0!==e[t]),o=Object.getOwnPropertyNames(t).filter(e=>void 0!==t[e]);if(r.length!==o.length)return!1;for(const i of r){if(!Object.prototype.hasOwnProperty.call(t,i))return!1;if(!du(e[i],t[i]))return!1}return!0}function fu(e,t,n,r,o,i){const{handleError:a,handleSend:s,localMethods:c}=i,u=Ee(n),l=Ee(r),d=async(e,t,n=null)=>{const r=l({jsonrpc:"2.0",result:void 0,error:{code:e,message:t,data:void 0},id:n});return await s(JSON.stringify(r))};let f=0;const p=new Map,h=new Map,y={};for(const b of Object.keys(t)){const{asParams:n,asResult:r}=t[b],i=Ee(n);y[b]=null==r?e=>{const t=u({jsonrpc:"2.0",method:b,params:i(e)});s(JSON.stringify(t)).catch(a)}:t=>{const n=f++,c=new Promise((e,t)=>{p.set(n,{asResult:r,resolve:e,reject:t})});o&&null!=e[b]&&null==e[b].asResult&&h.set(n,b);const l=u({jsonrpc:"2.0",method:b,params:i(t),id:n});return s(JSON.stringify(l)).catch(a),c}}return{handleClose:function(){for(const e of p.values())e.reject(new Error("JSON-RPC connection closed"))},handleMessage:function(t){let o;try{o=JSON.parse(t)}catch(f){return void d(-32700,`Parse error: ${pu(f)}`).catch(a)}const i=me(n)(o),u=me(r)(o);if(null!=i){const t=e[i.method];if(null==t)return void d(-32601,`Method not found: ${i.method}`).catch(a);if(null!=t.asResult&&null==i.id)return void d(-32600,"Invalid JSON-RPC request: missing id").catch(a);if(null==t.asResult&&null!=i.id)return void d(-32600,"Invalid JSON-RPC request: notification has an id").catch(a);let n;try{n=t.asParams(i.params)}catch(f){return void d(-32602,`Invalid params: ${pu(f)}`).catch(a)}const r=c[i.method](n);if(null!=t.asResult&&null!=(null==r?void 0:r.then)){const e=Ee(t.asResult);r.then(t=>{var n;const r=l({jsonrpc:"2.0",result:e(t),error:void 0,id:null!==(n=i.id)&&void 0!==n?n:null});s(JSON.stringify(r)).catch(a)},e=>{d(1,pu(e),i.id).catch(a)})}}else if(null!=u){const{error:t,id:n,result:r}=u;if("number"!=typeof n)return void d(-32603,`Cannot find id ${String(n)}`,n).catch(a);const o=p.get(n);if(null==o){const t=h.get(n);if(null==t)return void d(-32603,`Cannot find id ${String(n)}`,n).catch(a);let o;try{o=e[t].asParams(r)}catch(f){return void d(-32602,`Invalid params: ${pu(f)}`).catch(a)}return void c[t](o)}if(p.delete(n),null!=t)o.reject(new Error(t.message));else{const{asResult:e}=o;let t;try{t=e(r)}catch(f){o.reject(f)}o.resolve(t)}}else d(-32600,"Invalid JSON-RPC request / response").catch(a)},remoteMethods:y}}function pu(e){return e instanceof Error?e.message:String(e)}const hu=e=>{if(null===e)return e;if("string"==typeof e)return e;if("number"==typeof e&&Number.isInteger(e))return e;throw new TypeError("Expected a string or an integer")},yu=we({jsonrpc:le("2.0"),method:pe,params:ye,id:ue(hu)}),bu=we({jsonrpc:le("2.0"),result:ye,error:ue(we({code:fe,message:pe,data:ye})),id:hu}),gu=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return function(e){if(!Array.isArray(e))throw new TypeError("Expected an array, got "+ce(e));for(var n=[],r=0;r<t.length;++r)try{n[r]=t[r](e[r])}catch(o){throw be(o,"["+r+"]")}return n}}(pe,pe,ue(pe)),wu=le(-1,0,1,2),vu=function(e){const{serverMethods:t,clientMethods:n,asCall:r=yu,asReturn:o=bu,allowMultipleReturns:i=!1}=e;return{makeServerCodec(e){return fu(t,n,r,o,i,e)},makeClientCodec(e){return fu(n,t,r,o,i,e)}}}({serverMethods:{subscribe:{asParams:ge(gu),asResult:ge(wu)},unsubscribe:{asParams:ge(gu),asResult:le(void 0)}},clientMethods:{update:{asParams:gu},subLost:{asParams:gu}}});function mu(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Iu(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?mu(Object(n),!0).forEach(function(t){r(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):mu(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}const Eu=mr({wallets:Or(As,e=>e.state.currency.currencyWalletIds,(e,t)=>Iu(Iu({},e),{},{walletId:t,walletState:e.state.currency.wallets[t],walletOutput:e.output.currency.wallets[t]})),pluginUpdater(e){let t;return async()=>{const{infoCache:n,plugins:r}=e.props.state;if(t!==n){if(null!=t)for(const e of Object.keys(r.currency)){var o,i,a,s;const c=r.currency[e],u=null!==(o=null===(i=n.corePlugins)||void 0===i?void 0:i[e])&&void 0!==o?o:{},l=null!==(a=null===(s=t.corePlugins)||void 0===s?void 0:s[e])&&void 0!==a?a:{};null==c.updateInfoPayload||du(l,u)||await c.updateInfoPayload(u)}t=n}}},changeServiceManager(e){let t,n;return{async update(){var r,o;const{wallets:i}=e.props.state.currency;if(i===t)return;t=i;let{changeService:a,changeServiceConnected:s=!1}=null!==(r=e.props.output.currency.changeServiceManager)&&void 0!==r?r:{};const c=Object.entries(i).filter(([,e])=>e.changeServiceSubscriptions.some(e=>"avoiding"!==e.status));if(null==a&&c.length>0){const t=e.props.state.changeServers[0];a=function(e,t){let n,r,o=!1;!function s(){n=new WebSocket(e),n.binaryType="arraybuffer",n.addEventListener("message",e=>{i.handleMessage(e.data)}),n.addEventListener("close",()=>{a.connected=!1,i.handleClose(),t.handleDisconnect(),r=setTimeout(()=>{o||s()},5e3)}),n.addEventListener("error",e=>{console.error("changeServer websocket error:",e),n.close()}),n.addEventListener("open",()=>{a.connected=!0,t.handleConnect()})}();const i=vu.makeClientCodec({handleError(e){console.error("changeServer error:",e),n.close()},async handleSend(e){n.send(e)},localMethods:{update(e){t.handleChange(e)},subLost(e){t.handleSubLost(e)}}}),a={async subscribe(e){return await i.remoteMethods.subscribe(e)},async unsubscribe(e){await i.remoteMethods.unsubscribe(e)},close(){o=!0,null!=r&&(clearTimeout(r),r=void 0),n.close()},connected:!1};return a}(t,{handleChange([t,n,r]){const o=Object.entries(e.props.state.currency.wallets).filter(([,e])=>e.currencyInfo.pluginId===t&&e.changeServiceSubscriptions.some(e=>e.address===n));for(const[i,a]of o){const t=a.changeServiceSubscriptions.filter(e=>e.address===n&&"listening"===e.status).map(e=>Iu(Iu({},e),{},{status:"syncing",checkpoint:r}));e.props.dispatch({type:"CURRENCY_ENGINE_UPDATE_CHANGE_SERVICE_SUBSCRIPTIONS",payload:{walletId:i,subscriptions:t}})}},handleConnect(){const t=Object.entries(e.props.state.currency.wallets);for(const[n,r]of t){const t=r.changeServiceSubscriptions.filter(e=>"reconnecting"===e.status).map(e=>Iu(Iu({},e),{},{status:"subscribing"}));e.props.dispatch({type:"CURRENCY_ENGINE_UPDATE_CHANGE_SERVICE_SUBSCRIPTIONS",payload:{walletId:n,subscriptions:t}})}e.onOutput({changeService:a,changeServiceConnected:!0})},handleDisconnect(){const t=Object.entries(e.props.state.currency.wallets);for(const[n,r]of t){const t=r.changeServiceSubscriptions.filter(e=>"avoiding"!==e.status).map(e=>Iu(Iu({},e),{},{status:"reconnecting"}));e.props.dispatch({type:"CURRENCY_ENGINE_UPDATE_CHANGE_SERVICE_SUBSCRIPTIONS",payload:{walletId:n,subscriptions:t}})}e.onOutput({changeService:a,changeServiceConnected:!1})},handleSubLost([t,n]){const r=Object.entries(e.props.state.currency.wallets).filter(([,e])=>e.currencyInfo.pluginId===t&&e.changeServiceSubscriptions.some(e=>e.address===n)&&e.changeServiceSubscriptions.some(e=>"avoiding"!==e.status));for(const[o,i]of r){const t=i.changeServiceSubscriptions.filter(e=>"avoiding"!==e.status).map(e=>Iu(Iu({},e),{},{status:"subscribing"}));e.props.dispatch({type:"CURRENCY_ENGINE_UPDATE_CHANGE_SERVICE_SUBSCRIPTIONS",payload:{walletId:o,subscriptions:t}})}}}),e.onOutput({changeService:a,changeServiceConnected:!1})}if(null!=a&&0===c.length&&(a.close(),a=void 0,e.onOutput({changeService:a,changeServiceConnected:!1})),!0===(null===(o=a)||void 0===o?void 0:o.connected)&&s){const t=c.filter(([,e])=>e.changeServiceSubscriptions.some(e=>"subscribing"===e.status||"resubscribing"===e.status)),r=[],o=[];for(const[e,n]of t){if(n.paused)continue;const t=n.changeServiceSubscriptions.map(e=>[n.currencyInfo.pluginId,e.address,e.checkpoint]);if(0===t.length)continue;let i=o[o.length-1];(null==i||i.length+t.length>100)&&(o.push([]),i=o[o.length-1]),i.push(...t);for(let o=0;o<t.length;o++)r[r.length]={walletId:e,wallet:n}}n=setTimeout(()=>{n=void 0;const t=new Set(r.map(e=>e.walletId));for(const n of t){const t=e.props.state.currency.wallets[n];if(null==t)continue;const r=t.changeServiceSubscriptions.filter(e=>"subscribing"===e.status).map(e=>Iu(Iu({},e),{},{status:"subscribingSlowly"}));r.length>0&&e.props.dispatch({type:"CURRENCY_ENGINE_UPDATE_CHANGE_SERVICE_SUBSCRIPTIONS",payload:{walletId:n,subscriptions:r}})}},15e3);const i=[];try{for(const t of o){const n=await a.subscribe(t).catch(n=>(e.props.log(`Failed to subscribe: ${String(n)}`),t.map(()=>0)));i.push(...n)}}finally{clearTimeout(n),n=void 0}const s=new Map;for(let n=0;n<i.length;n++){const t=i[n],{walletId:o}=r[n],a=e.props.state.currency.wallets[o];if(null==a)continue;let c;switch(t){case-1:c="avoiding";break;case 0:c="resubscribing";break;case 1:c="synced";break;case 2:c="syncing"}const u=a.changeServiceSubscriptions.filter(e=>"subscribing"===e.status||"subscribingSlowly"===e.status||"resubscribing"===e.status).map(e=>Iu(Iu({},e),{},{status:c}));s.set(o,u)}const u=Array.from(s.entries());for(const[n,a]of u)e.props.dispatch({type:"CURRENCY_ENGINE_UPDATE_CHANGE_SERVICE_SUBSCRIPTIONS",payload:{walletId:n,subscriptions:a}})}},destroy(){null!=n&&clearTimeout(n)}}}});const Su=mr({makeSnrp:e=>()=>{const{io:t,log:n}=e.props;let r;return e.onOutput(async function(o){null==r&&(r=e.props.output.scrypt.timeScrypt(Bt.parse("1reallyJunkiePasswordToCheck"),{salt_hex:p("b5865ffb9fa7b3bfe4b2384d47ce831ee22a4a9d5c34c7ef7d21467cc758f81b"),n:16384,r:8,p:1}).then(e=>e.time));const i=await r,a=function(e,t,n){const r={salt_hex:e,n:16384,r:8,p:1};if(0===t)return r.n=131072,r.r=8,r.p=64,r;let o=t;const i=t/8;let a=(n-o)/i;a=a>0?a:0,a>0&&(a=0),a=Math.floor(a),r.r=8+a,o+=a*i;let s=14,c=(n-o)/o;c=c>0?c:0,c>3&&(c=3),c=Math.floor(c),s+=c>=0?c:0,o+=c*o,r.n=Math.pow(2,s);let u=(n-o)/o;return u=u>0?u:0,u>64&&(u=64),u=Math.floor(u),r.p=u>=1?u:1,o+=u*o,r}(t.random(32),i,o);return n(`snrp for ${o}ms target: ${a.n} ${a.r} ${a.p} based on ${i}ms benchmark`),a}),Ar},timeScrypt:e=>()=>{const{io:t,log:n}=e.props,r="undefined"!=typeof window&&null!=window.performance&&"function"==typeof window.performance.now?()=>window.performance.now():()=>Date.now();return e.onOutput(function(e){let t=Promise.resolve();return function(...n){const r=()=>e.apply(this,n),o=t.then(r,r);return t=o,o}}(function(e,o,i=32){const a=o.salt_hex,s=r();return n(`starting scrypt n=${o.n} r=${o.r} p=${o.p}`),t.scrypt(e,a,o.n,o.r,o.p,i).then(e=>{const t=r()-s;return n(`finished scrypt n=${o.n} r=${o.r} p=${o.p} in ${t}ms`),{hash:e,time:t}})})),Ar}}),Ou=e=>e,Au=mr({accounts:tu,context:lu,currency:Eu,scrypt:Su}),Tu=es({currencyWalletIds(e,t,n){if(1===n.accountIds.length){const e=n.accountIds[0];return n.accounts[e].activeWalletIds}const r=[];for(const o of n.accountIds)r.push(...n.accounts[o].activeWalletIds);return r},wallets:as(ws,e=>e.currency.currencyWalletIds)}),_u=es({apiKey(e="",t){return"INIT"===t.type?t.payload.apiKey:e},apiSecret(e=null,t){var n;return"INIT"===t.type?null!==(n=t.payload.apiSecret)&&void 0!==n?n:null:e},attestationToken(e=null,t){if("SET_ATTESTATION_TOKEN"!==t.type)return e;const n=t.payload;return null==n||""===n?null:n},contextAppId(e="",t){return"INIT"===t.type?t.payload.appId:e},deviceInfo(e={},t){if("INIT"===t.type){const{appVersion:e,deviceDescription:n,osType:r,osVersion:o}=t.payload;return{deviceDescription:null!=n?n:void 0,osType:r,osVersion:o,appVersion:e}}return e},localUsers:ss(e=>e.login.contextAppId,e=>e.login.stashes,e=>e.clientInfo,(e,t,n)=>t.map(function(t){const{lastLogin:r,loginId:o,recovery2Key:i,username:a}=t,s=zn(t,t=>t.appId===e),c=null!=s&&(null!=s.passwordAuthBox||null!=s.loginAuthBox),u=n.duressEnabled?Ln(t,e):void 0,l=null!=(null==u?void 0:u.pin2Key)&&!0===(null==u?void 0:u.fakePinDisabled),d=fi(t,e),f=!l&&null!=(null==d?void 0:d.pin2Key);return{keyLoginEnabled:c,lastLogin:r,loginId:Lt.stringify(o),pinLoginEnabled:f,recovery2Key:null!=i?Lt.stringify(i):void 0,username:a,voucherId:null!=s?s.voucherId:void 0}})),loginServers(e=[],t){return"INIT"===t.type?t.payload.loginServers:e},stashes(e=[],t){switch(t.type){case"INIT":return t.payload.stashes;case"LOGIN_STASH_DELETED":{const n=t.payload;return e.filter(e=>!cn(e.loginId,n))}case"LOGIN_STASH_SAVED":{const n=t.payload,r=e.filter(e=>!cn(e.loginId,n.loginId));return r.unshift(n),r}}return e},walletInfos(e,t,n){if(1===n.accountIds.length){const e=n.accountIds[0];return n.accounts[e].walletInfos}const r={};for(const o of n.accountIds){const e=n.accounts[o];for(const t of Object.keys(e.walletInfos)){const n=e.walletInfos[t];r[t]=n}}return r}});function ku(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function xu(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?ku(Object(n),!0).forEach(function(t){r(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ku(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}const Pu={init:{},locked:!1,currency:{},swap:{},currencyTools:{}};function Mu(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Cu(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Mu(Object(n),!0).forEach(function(t){r(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Mu(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}const Nu=function(e){for(var t=Object.keys(e),n={},r=0;r<t.length;r++){var o=t[r];0,"function"==typeof e[o]&&(n[o]=e[o])}var i,a=Object.keys(n);try{!function(e){Object.keys(e).forEach(function(t){var n=e[t];if(void 0===n(void 0,{type:cr.INIT}))throw new Error(ir(12));if(void 0===n(void 0,{type:cr.PROBE_UNKNOWN_ACTION()}))throw new Error(ir(13))})}(n)}catch(s){i=s}return function(e,t){if(void 0===e&&(e={}),i)throw i;for(var r=!1,o={},s=0;s<a.length;s++){var c=a[s],u=n[c],l=e[c],d=u(l,t);if(void 0===d){t&&t.type;throw new Error(ir(14))}o[c]=d,r=r||d!==l}return(r=r||a.length!==Object.keys(e).length)?o:e}}({lastChanges(e=[],t){if("STORAGE_WALLET_SYNCED"===t.type){const{changes:n}=t.payload;return n.length>0?n:e}return e},localDisklet(e=null){return e},paths(e=null){return e},status(e={lastSync:0,lastHash:void 0},t){return"STORAGE_WALLET_SYNCED"===t.type?t.payload.status:e}});function ju(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Du(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?ju(Object(n),!0).forEach(function(t){r(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ju(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}const Ru={sources:{},defaultLogLevel:"warn"},Lu={clientId:new Uint8Array(0),duressEnabled:!1,loginWaitTimestamps:{}},Bu=es({accountCount(e=0,t){return"LOGIN"===t.type?e+1:e},accountIds(e=[],t,n){switch(t.type){case"LOGIN":return[...e,n.lastAccountId];case"LOGOUT":{const{accountId:n}=t.payload,r=e.filter(e=>e!==n);if(r.length===e.length)throw new Error(`Login ${n} does not exist`);return r}case"CLOSE":return[]}return e},accounts:as(Xc,e=>e.accountIds),changeServers(e=[],t){return"INIT"===t.type?t.payload.changeServers:e},clientInfo(e=Lu,t){switch(t.type){case"INIT":return t.payload.clientInfo;case"LOGIN_DURESS_MODE_DISABLED":return Du(Du({},e),{},{duressEnabled:!1});case"LOGIN_DURESS_MODE_ENABLED":return Du(Du({},e),{},{duressEnabled:!0});case"LOGIN_WAIT_TIMESTAMP_UPDATED":return Du(Du({},e),{},{loginWaitTimestamps:Du(Du({},e.loginWaitTimestamps),{},{[t.payload.loginId]:t.payload.timestamp})})}return e},hideKeys(e=!0,t){return"INIT"===t.type?t.payload.hideKeys:e},infoCache(e={},t){switch(t.type){case"INIT":return t.payload.infoCache;case"INFO_CACHE_FETCHED":return t.payload}return e},infoServers(e=[],t){return"INIT"===t.type?t.payload.infoServers:e},lastAccountId(e,t,n){return`login${n.accountCount}`},logSettings(e=Ru,t){switch(t.type){case"INIT":return t.payload.logSettings;case"CHANGE_LOG_SETTINGS":return t.payload}return e},paused(e=!1,t){return"PAUSE"===t.type?t.payload:e},ready(e=!1,t){return"INIT"===t.type||e},skipBlockHeight(e=!1,t){return"INIT"===t.type?t.payload.skipBlockHeight:e},syncServers(e=[],t){return"INIT"===t.type?t.payload.syncServers:e},currency:Tu,login:_u,plugins:(e=Pu,t)=>{switch(t.type){case"CORE_PLUGINS_ADDED":{const n=xu(xu({},e),{},{currency:xu({},e.currency),swap:xu({},e.swap)});for(const e of Object.keys(t.payload)){const r=t.payload[e];null!=r?("currencyInfo"in r&&(null==r.currencyInfo.chainDisplayName&&(r.currencyInfo.chainDisplayName=r.currencyInfo.displayName),null==r.currencyInfo.assetDisplayName&&(r.currencyInfo.assetDisplayName=r.currencyInfo.displayName),n.currency[e]=r),"swapInfo"in r&&(n.swap[e]=r)):n.init=xu(xu({},n.init),{},{[e]:!1})}return n}case"CORE_PLUGINS_LOCKED":return xu(xu({},e),{},{locked:!0});case"CURRENCY_TOOLS_LOADED":{const n=xu({},e.currencyTools);return n[t.payload.pluginId]=t.payload.tools,xu(xu({},e),{},{currencyTools:n})}case"INIT":return xu(xu({},e),{},{init:t.payload.pluginsInit})}return e},storageWallets:function(e={},t){switch(t.type){case"STORAGE_WALLET_ADDED":{const{id:n,initialState:r}=t.payload,o=Cu({},e);return o[n]=Nu(r,{type:"UPDATE_NEXT"}),o}case"STORAGE_WALLET_SYNCED":{const{id:n}=t.payload;if(null!=e[n]){const r=Cu({},e);return r[n]=Nu(e[n],t),r}return e}}return e}});function Ku(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Uu(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Ku(Object(n),!0).forEach(function(t){r(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ku(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}let Fu=[];const Wu="object"==typeof window&&null!=window.__REDUX_DEVTOOLS_EXTENSION__?window.__REDUX_DEVTOOLS_EXTENSION__({name:"core"}):void 0;async function Gu(e,t,n){const{io:r}=e,{airbitzSupport:o=!1,apiSecret:i,appId:a="",appVersion:s,authServer:c,deviceDescription:u=null,changeServer:l,hideKeys:d=!1,infoServer:f,loginServer:p,osType:h,osVersion:y,plugins:b={},skipBlockHeight:g=!1,syncServer:w}=n;let{apiKey:v}=n;null!=v&&""!==v||(v="4248c1bf41e53b840a5fdb2c872dd3ade525e66d");const m=zu(c,["https://login1.edge.app","https://login2.edge.app"]),I=zu(l,["wss://change1.edge.app","wss://change2.edge.app"]),E=zu(f,["https://info1.edge.app","https://info2.edge.app"]),S=zu(p,m.map(e=>e.replace(/\/api$/,""))),O=zu(w,["https://sync-us1.edge.app","https://sync-us2.edge.app","https://sync-us3.edge.app","https://sync-us4.edge.app","https://sync-us5.edge.app","https://sync-us6.edge.app","https://sync-eu.edge.app"]),A=Uu(Uu({},Ru),n.logSettings);I.map(e=>Tr(e)),E.map(e=>Tr(e)),S.map(e=>Tr(e)),O.map(e=>Tr(e));const T=lr(Bu,Wu);var _,k;k=()=>{const e=T.getState();return e.ready?e.logSettings:A};const x=Lr(t=Dr(Dr({},_=t),{},{onLog:function(e){const{sources:t,defaultLogLevel:n}=k(),r=null!=t[e.source]?t[e.source]:n;switch(e.type){case"info":"info"===r&&_.onLog(e);break;case"warn":"info"!==r&&"warn"!==r||_.onLog(e);break;case"error":"silent"!==r&&_.onLog(e)}}}),"edge-core");let[P,M={},C]=await Promise.all([Pr.load(r.disklet,xr),Nr.load(r.disklet,Mr),Nn(r.disklet,x)]);if(o){const e=new Set;for(const{username:n}of C)null!=n&&e.add(n);const t=await async function(e,t){const n=[],r=await e.disklet.list("Accounts").then(re.a8);for(const o of r){const r=(0,re.my)(e.disklet,o),[i,a,s,c,u,l]=await Promise.all([await Kr.load(r,"CarePackage.json"),await Ur.load(r,"LoginPackage.json"),await Fr.load(r,"OtpKey.json"),await Wr.load(r,"Pin2Key.json"),await Gr.load(r,"Recovery2Key.json"),await zr.load(r,"UserName.json")]);if(null==l)continue;const d=ae(l.userName);if(t.has(d))continue;const f={appId:"",loginId:await e.scrypt(Bt.parse(d),Tn.salt_hex,Tn.n,Tn.r,Tn.p,32),pendingVouchers:[],username:d};null!=i&&null!=a&&(f.passwordKeySnrp=i.SNRP2,f.passwordBox=a.EMK_LP2,f.syncKeyBox=a.ESyncKey,f.passwordAuthBox=a.ELP1),null!=s&&(f.otpKey=s.TOTP),null!=c&&(f.pin2Key=c.pin2Key),null!=u&&(f.recovery2Key=u.recovery2Key),n.push(f)}return n}(r,e);C.push(...t)}null==P&&(P={clientId:r.random(16),duressEnabled:!1,loginWaitTimestamps:{}},await Pr.save(r.disklet,xr,P)),T.dispatch({type:"INIT",payload:{apiKey:v,apiSecret:i,appId:a,appVersion:s,osType:h,osVersion:y,changeServers:I,loginServers:S,infoCache:M,infoServers:E,syncServers:O,clientInfo:P,deviceDescription:u,hideKeys:d,logSettings:A,pluginsInit:b,skipBlockHeight:g,stashes:C}});const N=function(e,t,n,r,o){const{io:i,nativeIo:a}=e,s=$r($r({},i),{},{console:console});function c(e){const c={};for(const o of Object.keys(e)){const f=e[o],p=Lr(n,o),h=r[o];if(!1!==h&&null!=h)try{if("function"==typeof f){var u,l;const e={infoPayload:null!==(u=null===(l=t.corePlugins)||void 0===l?void 0:l[o])&&void 0!==u?u:{},initOptions:"object"==typeof h?h:{},io:s,log:p,nativeIo:a,pluginDisklet:(0,re.my)(i.disklet,"plugins/"+o)};c[o]=f(e)}else{if("object"!=typeof f||null==f)throw new TypeError("Plugins must be functions or objects, got "+typeof f);c[o]=f}}catch(d){p.error(d)}}o({type:"CORE_PLUGINS_ADDED",payload:c})}function u(){o({type:"CORE_PLUGINS_LOCKED",payload:r})}return c(Hr),Yr&&u(),Vr.push(c),Jr.push(u),()=>{Vr.filter(e=>e!==c),Jr.filter(e=>e!==u)}}(e,M,t,b,T.dispatch),j=or({log:x,fetch:(e,t)=>r.fetch(e,Uu(Uu({},t),{},{corsBypass:"never"})),edgeServers:{infoServers:E,syncServers:O}}),D={output:{}},R=function(e,t,n,r){var o=vr(t,n,r);o.update({dispatch:e.dispatch,output:void 0,state:e.getState()});var i=e.subscribe(function(){o.update({dispatch:e.dispatch,output:void 0,state:e.getState()})});return function(){i(),o.destroy()}}(T,Sr(Au,e=>Uu(Uu({},e),{},{close(){R(),N(),T.dispatch({type:"CLOSE"})},io:r,log:x,logBackend:t,onError:e=>{var t;null!=(null===(t=D.output.context)||void 0===t?void 0:t.api)&&W(D.output.context.api,"error",e)},syncClient:j})),e=>x.error(e),e=>D.output=e),L=D.output.context.api;return Fu.push(L),L}function zu(e,t){return"string"==typeof e?[e]:null!=e&&e.length>0?e:t}const qu=["children"];function $u(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Hu(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?$u(Object(n),!0).forEach(function(t){r(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):$u(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}class Yu{constructor(){this.lobbies=new Map,this.logins=[],this.repos=new Map}getLoginById(e){return this.logins.find(t=>cn(t.loginId,e))}getLoginByUserId(e){return this.logins.find(t=>null==t.userId?cn(t.loginId,e):cn(t.userId,e))}getLoginByPin2Id(e){return this.logins.find(t=>null!=t.pin2Id&&cn(t.pin2Id,e))}getLoginByRecovery2Id(e){return this.logins.find(t=>null!=t.recovery2Id&&cn(t.recovery2Id,e))}getLoginsByParent(e){return this.logins.filter(t=>t.parentId===e.loginId)}insertLogin(e){this.logins.push(e)}setupLogin(e){const{children:t}=e,n=Sc(e,qu);this.insertLogin(n);for(const r of t)r.parentId=e.loginId,this.setupLogin(r)}setupRepo(e,t){this.repos.set(e,t)}dumpLogin(e){const t=e=>Hu(Hu({},e),{},{children:this.getLoginsByParent(e).map(e=>t(e))});return t(e)}}function Vu(e,t){const n=e.getLoginsByParent(t).map(t=>Vu(e,t));return{appId:t.appId,created:t.created,loginId:t.loginId,children:n,parentBox:t.parentBox,passwordAuthBox:t.passwordAuthBox,passwordAuthSnrp:t.passwordAuthSnrp,passwordBox:t.passwordBox,passwordKeySnrp:t.passwordKeySnrp,pin2Box:t.pin2Box,pin2KeyBox:t.pin2KeyBox,pin2TextBox:t.pin2TextBox,question2Box:t.question2Box,recovery2Box:t.recovery2Box,recovery2KeyBox:t.recovery2KeyBox,otpKey:t.otpKey,otpResetDate:t.otpResetDate,otpTimeout:t.otpTimeout,pendingVouchers:Ju(t),loginAuthBox:t.loginAuthBox,userId:t.userId,userTextBox:t.userTextBox,keyBoxes:t.keyBoxes,mnemonicBox:t.mnemonicBox,rootKeyBox:t.rootKeyBox,syncKeyBox:t.syncKeyBox}}function Ju(e){return e.vouchers.filter(e=>"pending"===e.status).map(e=>({activates:e.activates,created:e.created,deviceDescription:e.deviceDescription,ip:e.ip,ipDescription:e.ipDescription,voucherId:e.voucherId}))}function Xu(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Zu(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Xu(Object(n),!0).forEach(function(t){r(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Xu(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}const Qu={code:0,httpStatus:200,message:"Success"},el={code:2,httpStatus:401,message:"Account already exists"},tl={code:3,httpStatus:401,message:"No account"},nl={code:4,httpStatus:401,message:"Invalid Password"},rl={code:8,httpStatus:401,message:"Invalid OTP"},ol={code:10,httpStatus:409,message:"Conflicting change"},il={code:0,httpStatus:201,message:"Account created"},al={code:1,httpStatus:401,message:"Invalid request"},sl={code:1,httpStatus:404,message:"Not found"},cl={code:3,httpStatus:404,message:"Not found"},ul={code:10,httpStatus:401,message:"A login with the same appId already exists"};function ll(e,t){try{return[e(t),{status:200}]}catch(n){return[void 0,fl(al,`Invalid request: ${String(n)}`)]}}function dl(e,t={}){const{status:n=200,headers:r={}}=t;return{status:n,headers:Zu({"content-type":"application/json"},r),body:JSON.stringify(e)}}function fl(e=Qu,t=e.message){const{code:n,httpStatus:r}=e;return dl(lt({status_code:n,message:t}),{status:r})}function pl(e,t=Qu,n=t.message){const{code:r,httpStatus:o}=t;return dl(lt({status_code:r,message:n,results:e}),{status:o})}function hl(e){return pl(_t({wait_seconds:e}),nl)}function yl(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function bl(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?yl(Object(n),!0).forEach(function(t){r(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):yl(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}const gl=e=>async t=>{const{json:n}=t,[r,o]=ll(Re,n);return null==r?o:await e(bl(bl({},t),{},{body:r,payload:r.data}))},wl=e=>async t=>{const{body:n,login:r}=t,{otp:o,voucherAuth:i,voucherId:a}=n,{otpKey:s}=r;if(null==s)return await e(t);if(null!=o&&function(e,t,n={}){const{now:r=Date.now()/1e3,spread:o=1}=n,i=r/30;if(t===hn(e,i,6))return!0;for(let a=1;a<=o;++a){if(t===hn(e,i-a,6))return!0;if(t===hn(e,i+a,6))return!0}return!1}(s,o,{spread:2}))return await e(t);if(null!=i&&null!=a){const n=r.vouchers.find(e=>e.voucherId===a);if(null!=n&&"approved"===n.status&&cn(i,n.voucherAuth))return await e(t)}r.otpResetAuth="Super secret reset token";const c={activates:new Date("2020-01-01T00:00:00Z"),created:new Date("2020-01-08T00:00:00Z"),deviceDescription:"A phone",ip:"localhost",ipDescription:"here",loginId:r.loginId,status:"pending",voucherAuth:Uint8Array.from([170,187]),voucherId:`voucher-${r.vouchers.length}`};return r.vouchers.push(c),function(e,t={}){const{reason:n="otp",voucher:r}=t;return pl(At({login_id:e.loginId,otp_reset_auth:e.otpResetAuth,otp_timeout_date:e.otpResetDate,reason:n,voucher_auth:null==r?void 0:r.voucherAuth,voucher_activates:null==r?void 0:r.activates,voucher_id:null==r?void 0:r.voucherId}),rl)}(r,{voucher:c})},vl=e=>fl(al),ml=(e,t=vl)=>n=>{const{db:r,body:o}=n,{loginAuth:i,loginId:a,passwordAuth:s,pin2Auth:c,pin2Id:u,recovery2Auth:l,recovery2Id:d,userId:f}=o;if(null!=a&&null!=i){const t=r.getLoginById(a);return null==t?fl(tl):null!=t.loginAuth&&cn(i,t.loginAuth)?wl(e)(bl(bl({},n),{},{login:t})):hl(0)}if(null!=f&&null!=s){const t=r.getLoginByUserId(f);return null==t?fl(tl):null!=t.passwordAuth&&cn(s,t.passwordAuth)?wl(e)(bl(bl({},n),{},{login:t})):hl(0)}if(null!=u&&null!=c){const t=r.getLoginByPin2Id(u);return null==t?fl(tl):null!=t.pin2Auth&&cn(c,t.pin2Auth)?wl(e)(bl(bl({},n),{},{login:t})):hl(0)}if(null!=d&&null!=l){const t=r.getLoginByRecovery2Id(d);if(null==t)return fl(tl);const o=t.recovery2Auth,i=l;if(null==o||i.length!==o.length)return hl(0);for(let e=0;e<i.length;++e)if(!cn(i[e],o[e]))return hl(0);return wl(e)(bl(bl({},n),{},{login:t}))}return t(n)},Il=ml(e=>{const{db:t,login:n}=e;return pl(St(Vu(t,n)))},e=>{const{db:t,json:n}=e,r=Re(n),{userId:o,passwordAuth:i,recovery2Id:a,recovery2Auth:s}=r;if(null!=o&&null==i){const e=t.getLoginByUserId(o);if(null==e)return fl(tl);const{loginId:n,passwordAuthSnrp:r=Tn}=e;return pl(xt({loginId:n,passwordAuthSnrp:r}))}if(null!=a&&null==s){const e=t.getLoginByRecovery2Id(a);if(null==e)return fl(tl);const{question2Box:n}=e;return null==n?fl(tl):pl(kt({question2Box:n}))}return fl(al)});function El(e,t){const{db:n,json:r}=e,o=new Date,[i,a]=ll(Re,r);if(null==i)return a;const[s,c]=ll(Ye,i.data);if(null==s)return c;const[u,l]=ll(ze,i.data);if(null==u)return l;if(null!=n.getLoginById(s.loginId))return fl(el);const d=me(He,()=>({allowExisting:!1,newSyncKeys:[],keyBoxes:[]}))(i.data);for(const p of d.newSyncKeys)n.repos.set(p,{});const f=bl(bl(bl(bl(bl(bl(bl({},s),u),{},{created:o,keyBoxes:d.keyBoxes.map(e=>bl(bl({},e),{},{created:o})),vouchers:[]},me(Be)(i.data)),me(Ke)(i.data)),me(Fe)(i.data)),me(Ge)(i.data)),me(qe)(i.data));if(null!=t){if(null!=n.getLoginsByParent(t).find(e=>e.appId===s.appId))return fl(ul);f.parentId=t.loginId}return n.insertLogin(f),fl(il,"Account created")}const Sl=ml(e=>El(e,e.login),e=>El(e)),Ol=ml(e=>{const{db:t,login:n,payload:r}=e,o=new Date,[i,a]=ll(He,r);if(null==i)return a;for(const s of i.newSyncKeys)t.repos.set(s,{});return n.keyBoxes=bn(n.keyBoxes,i.keyBoxes.map(e=>bl(bl({},e),{},{created:o}))),fl()}),Al=ml(e=>{const{login:t,payload:n}=e,[r,o]=ll(Be,n);return null==r?o:(t.otpKey=r.otpKey,t.otpTimeout=r.otpTimeout,t.otpResetDate=void 0,fl())}),Tl=ml(e=>{const{login:t}=e;return t.otpKey=void 0,t.otpResetAuth=void 0,t.otpResetDate=void 0,t.otpTimeout=void 0,fl()},e=>{const{db:t,json:n}=e,r=Re(n);if(null==r.userId||null==r.otpResetAuth)return fl(al);const o=t.getLoginByUserId(r.userId);if(null==o)return fl(tl);if(r.otpResetAuth!==o.otpResetAuth)return hl(0);const{otpKey:i,otpTimeout:a}=o;return null==i||null==a?fl(al,"OTP not setup for this account."):(null==o.otpResetDate&&(o.otpResetDate=new Date(Date.now()+1e3*a)),pl(Tt({otpResetDate:o.otpResetDate})))}),_l=ml(e=>{const{login:t}=e;return t.passwordAuth=void 0,t.passwordAuthBox=void 0,t.passwordAuthSnrp=void 0,t.passwordBox=void 0,t.passwordKeySnrp=void 0,fl()}),kl=ml(e=>{const{login:t,payload:n}=e,[r,o]=ll(Ke,n);return null==r?o:(t.passwordAuth=r.passwordAuth,t.passwordAuthBox=r.passwordAuthBox,t.passwordAuthSnrp=r.passwordAuthSnrp,t.passwordBox=r.passwordBox,t.passwordKeySnrp=r.passwordKeySnrp,fl())}),xl=ml(e=>{const{login:t}=e;return t.pin2Auth=void 0,t.pin2Box=void 0,t.pin2Id=void 0,t.pin2KeyBox=void 0,t.pin2TextBox=void 0,fl()}),Pl=ml(e=>{const{login:t,payload:n}=e,[r,o]=ll(Fe,n);return null==r?o:(t.pin2Auth=r.pin2Auth,t.pin2Box=r.pin2Box,t.pin2Id=r.pin2Id,t.pin2KeyBox=r.pin2KeyBox,t.pin2TextBox=r.pin2TextBox,fl())}),Ml=ml(e=>{const{login:t}=e;return t.question2Box=void 0,t.recovery2Auth=void 0,t.recovery2Box=void 0,t.recovery2Id=void 0,t.recovery2KeyBox=void 0,fl()}),Cl=ml(e=>{const{login:t,payload:n}=e,[r,o]=ll(Ge,n);return null==r?o:(t.question2Box=r.question2Box,t.recovery2Auth=r.recovery2Auth,t.recovery2Box=r.recovery2Box,t.recovery2Id=r.recovery2Id,t.recovery2KeyBox=r.recovery2KeyBox,fl())}),Nl=ml(e=>{const{db:t,login:n,payload:r}=e,[o,i]=ll(ze,r);return null==o?i:null!=n.loginAuth?fl(ol,"The secret-key login is already configured"):(n.loginAuth=o.loginAuth,n.loginAuthBox=o.loginAuthBox,pl(St(Vu(t,n))))}),jl=ml(async e=>{const{db:t,login:n,payload:r}=e,o=me(Ke)(r),i=me(Ue)(r),a=me(We)(r),s=me(qe)(r);if(null!=n.passwordAuth&&null==o)return fl(al,"Missing password payload");if(null!=n.pin2Auth&&null==i)return fl(al,"Missing pin2Id payload");if(null!=n.recovery2Auth&&null==a)return fl(al,"Missing recovery2Id payload");if(null==n.parentBox&&null==s)return fl(al,"Missing username payload");if(null!=o&&(n.passwordAuth=o.passwordAuth,n.passwordAuthBox=o.passwordAuthBox,n.passwordAuthSnrp=o.passwordAuthSnrp,n.passwordBox=o.passwordBox,n.passwordKeySnrp=o.passwordKeySnrp),null!=i){if(null==n.pin2Auth)return fl(al,"Login lacks pin2");if(null!=t.getLoginByPin2Id(i.pin2Id))return fl(ol);n.pin2Id=i.pin2Id}if(null!=a){if(null==n.recovery2Auth)return fl(al,"Login lacks recovery2");if(null!=t.getLoginByRecovery2Id(a.recovery2Id))return fl(ol);n.recovery2Id=a.recovery2Id}if(null!=s){if(null!=n.parentBox)return fl(al,"Only top-level logins can have usernames");if(null!=t.getLoginByUserId(s.userId))return fl(ol);n.userId=s.userId,n.userTextBox=s.userTextBox}return pl(St(Vu(t,n)))}),Dl=ml(async e=>{const{db:t,login:n,payload:r}=e,[o,i]=ll($e,r);if(null==o)return i;const{approvedVouchers:a=[],rejectedVouchers:s=[]}=o,c={};for(const u of a)c[u]="approved";for(const u of s)c[u]="rejected";for(const u of n.vouchers)null!=c[u.voucherId]&&(u.status=c[u.voucherId]);return pl(St(Vu(t,n)))}),Rl=e=>fl(cl,`Cannot find lobby ${e.lobbyId}`),Ll=(e,t=Rl)=>n=>{const{db:r,path:o}=n,i=o.split("/")[4],a=r.lobbies.get(i);return null!=a?e(bl(bl({},n),{},{lobby:a,lobbyId:i})):t(bl(bl({},n),{},{lobbyId:i}))},Bl=Ll(e=>fl(el,`Lobby ${e.lobbyId} already exists.`),e=>{const{db:t,json:n,lobbyId:r}=e,[o,i]=ll(Re,n);if(null==o)return i;const[a,s]=ll(Ne,o.data);if(null==a)return s;const{timeout:c=600}=a,u=new Date(Date.now()+1e3*c).toISOString();return t.lobbies.set(r,{request:a,replies:[],expires:u}),fl()}),Kl=Ll(e=>{const{json:t,lobby:n}=e,[r,o]=ll(Re,t);if(null==r)return o;const[i,a]=ll(je,r.data);return null==i?a:(n.replies.push(i),fl())}),Ul=Ll(e=>{const{lobby:t}=e;return pl(Et(t))}),Fl=Ll(e=>{const{db:t,lobbyId:n}=e;return t.lobbies.delete(n),fl()}),Wl=e=>t=>{const{db:n,path:r}=t,o=r.split("/")[4],i=n.repos.get(o);return null==i?dl({msg:"Hash not found"},{status:404}):e(bl(bl({},t),{},{repo:i}))},Gl=Wl(e=>{const{repo:t}=e;return dl({changes:jt(t)})}),zl=Wl(e=>{const{json:t,repo:n}=e,{changes:r}=ql(t);for(const o of Object.keys(r))n[o]=r[o];return dl({changes:jt(n),hash:"1111111111111111111111111111111111111111"})}),ql=we({changes:we(Pe)}),$l=S({"/api/v2/login/?":E({GET:gl(Il),POST:gl(Il)}),"/api/v2/login/create/?":E({POST:gl(Sl),PUT:gl(Sl)}),"/api/v2/login/keys/?":E({POST:gl(Ol)}),"/api/v2/login/otp/?":E({DELETE:gl(Tl),POST:gl(Al),PUT:gl(Al)}),"/api/v2/login/password/?":E({DELETE:gl(_l),POST:gl(kl),PUT:gl(kl)}),"/api/v2/login/pin2/?":E({DELETE:gl(xl),POST:gl(Pl),PUT:gl(Pl)}),"/api/v2/login/recovery2/?":E({DELETE:gl(Ml),POST:gl(Cl),PUT:gl(Cl)}),"/api/v2/login/secret/?":E({POST:gl(Nl)}),"/api/v2/login/username/?":E({POST:gl(jl)}),"/api/v2/login/vouchers/?":E({POST:gl(Dl)}),"/api/v2/messages/?":E({POST:gl(e=>{const{db:t,json:n}=e,[r,o]=ll(Re,n);if(null==r)return o;const{loginIds:i}=r;if(null==i)return fl(al);const a=[];for(const s of i){const e=t.getLoginById(s);null!=e&&a.push({loginId:s,otpResetPending:null!=e.otpResetDate,pendingVouchers:Ju(e),recovery2Corrupt:!1})}return pl(Ot(a))})}),"/api/v2/lobby/[^/]+/?":E({DELETE:gl(Fl),GET:gl(Ul),POST:gl(Kl),PUT:gl(Bl)}),"/api/v2/store/[^/]+/?":E({GET:Gl,POST:zl}),"/v1/edgeServers":E({GET:e=>dl({infoServers:["https://info-fake1.edge.app"],syncServers:["https://sync-fake1.edge.app","https://sync-fake2.edge.app","https://sync-fake3.edge.app"]})})},e=>fl(sl,`Unknown API endpoint ${e.path}`));function Hl(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Yl(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Hl(Object(n),!0).forEach(function(t){r(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Hl(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}async function Vl(e,t){const{lastLogin:n,server:r}=t,o=g(t.loginId),i=g(t.loginKey),a=Hn({appId:"",lastLogin:n,loginId:o,pendingVouchers:[],username:null==t.username?void 0:ae(t.username)},i,Qe(r)),s=`logins/${Lt.stringify(o)}.json`;await e.disklet.setText(s,JSON.stringify(Rn(a))).catch(()=>{})}async function Jl(e,t,n){const r=uo(e,{dataKey:new Uint8Array(0),syncKey:t});await fo(r.dataDisklet,n),await r.baseDisklet.setText("status.json",JSON.stringify({lastSync:1,lastHash:null}))}function Xl(e,t,n){const{io:r,nativeIo:o}=e,i=new Yu,a=function(e){const t=gn(n=>{if(t.offline)throw new Error("Fake network error");const r=n.body.byteLength>0?JSON.parse(Bt.stringify(new Uint8Array(n.body))):{};return $l(bl(bl({},n),{},{db:e,json:r}))},{offline:!1});return t}(i);for(const u of n){i.setupLogin(Ct(u.server));for(const e of Object.keys(u.repos))i.setupRepo(e,Pt(u.repos[e]))}const s=[],c={async close(){await Promise.all(s.map(e=>e.close())),F(c)},async makeEdgeContext(e){const{allowNetworkAccess:i=!1,cleanDevice:c=!1,extraFiles:u={}}=e,l=m(a),d=i?(e,t)=>function(e){try{const{hostname:t}=new URL(e);return/^(login|info|sync)[a-z0-9-]*\.edge(test)?\.app$/i.test(t)}catch(t){return!1}}(e)?l(e,t):r.fetch(e,t):l,f=Yl(Yl({},r),{},{disklet:(0,re.cQ)(),fetch:d});if(!c)for(const t of n){await Vl(f,t);for(const e of Object.keys(t.repos))await Jl(f,p(e),Pt(t.repos[e]))}if(null!=u)for(const t of Object.keys(u))await f.disklet.setText(t,u[t]);const h=await Gu({io:f,nativeIo:o},t,Yl({},e));return s.push(h),h},async goOffline(e=!0){a.offline=e},async dumpFakeUser(e){if(""!==e.appId)throw new Error("Only root logins are dumpable.");const t=Lt.parse(e.rootLoginId),n=Lt.parse(await e.getLoginKey()),r=i.getLoginById(t);if(null==r)throw new Error(`Cannot find user ${e.rootLoginId}`);const o=[];for(const i of e.allKeys){const t=await e.getRawPrivateKey(i.id);null!=t.syncKey&&o.push(h(g(t.syncKey)).toLowerCase())}const a={};for(const s of o){const e=i.repos.get(s);null!=e&&(a[s]=jt(e))}return{lastLogin:e.lastLogin,loginId:w(t),loginKey:w(n),repos:a,server:Nt(i.dumpLogin(r)),username:e.username}}};return P(c),c}function Zl(e){return function(t){return new Worker(e,t)}}var Ql=Zl(new URL(n(3437),n.b));const ed=Symbol("Comlink.proxy"),td=Symbol("Comlink.endpoint"),nd=Symbol("Comlink.releaseProxy"),rd=Symbol("Comlink.finalizer"),od=Symbol("Comlink.thrown"),id=e=>"object"==typeof e&&null!==e||"function"==typeof e,ad=new Map([["proxy",{canHandle:e=>id(e)&&e[ed],serialize(e){const{port1:t,port2:n}=new MessageChannel;return sd(e,t),[n,[n]]},deserialize(e){return e.start(),ud(e)}}],["throw",{canHandle:e=>id(e)&&od in e,serialize({value:e}){let t;return t=e instanceof Error?{isError:!0,value:{message:e.message,name:e.name,stack:e.stack}}:{isError:!1,value:e},[t,[]]},deserialize(e){if(e.isError)throw Object.assign(new Error(e.value.message),e.value);throw e.value}}]]);function sd(e,t=globalThis,n=["*"]){t.addEventListener("message",function r(o){if(!o||!o.data)return;if(!function(e,t){for(const n of e){if(t===n||"*"===n)return!0;if(n instanceof RegExp&&n.test(t))return!0}return!1}(n,o.origin))return void console.warn(`Invalid origin '${o.origin}' for comlink proxy`);const{id:i,type:a,path:s}=Object.assign({path:[]},o.data),c=(o.data.argumentList||[]).map(wd);let u;try{const t=s.slice(0,-1).reduce((e,t)=>e[t],e),n=s.reduce((e,t)=>e[t],e);switch(a){case"GET":u=n;break;case"SET":t[s.slice(-1)[0]]=wd(o.data.value),u=!0;break;case"APPLY":u=n.apply(t,c);break;case"CONSTRUCT":u=function(e){return Object.assign(e,{[ed]:!0})}(new n(...c));break;case"ENDPOINT":{const{port1:t,port2:n}=new MessageChannel;sd(e,n),u=function(e,t){return bd.set(e,t),e}(t,[t])}break;case"RELEASE":u=void 0;break;default:return}}catch(l){u={value:l,[od]:0}}Promise.resolve(u).catch(e=>({value:e,[od]:0})).then(n=>{const[o,s]=gd(n);t.postMessage(Object.assign(Object.assign({},o),{id:i}),s),"RELEASE"===a&&(t.removeEventListener("message",r),cd(t),rd in e&&"function"==typeof e[rd]&&e[rd]())}).catch(e=>{const[n,r]=gd({value:new TypeError("Unserializable return value"),[od]:0});t.postMessage(Object.assign(Object.assign({},n),{id:i}),r)})}),t.start&&t.start()}function cd(e){(function(e){return"MessagePort"===e.constructor.name})(e)&&e.close()}function ud(e,t){const n=new Map;return e.addEventListener("message",function(e){const{data:t}=e;if(!t||!t.id)return;const r=n.get(t.id);if(r)try{r(t)}finally{n.delete(t.id)}}),hd(e,n,[],t)}function ld(e){if(e)throw new Error("Proxy has been released and is not useable")}function dd(e){return vd(e,new Map,{type:"RELEASE"}).then(()=>{cd(e)})}const fd=new WeakMap,pd="FinalizationRegistry"in globalThis&&new FinalizationRegistry(e=>{const t=(fd.get(e)||0)-1;fd.set(e,t),0===t&&dd(e)});function hd(e,t,n=[],r=function(){}){let o=!1;const i=new Proxy(r,{get(r,a){if(ld(o),a===nd)return()=>{!function(e){pd&&pd.unregister(e)}(i),dd(e),t.clear(),o=!0};if("then"===a){if(0===n.length)return{then:()=>i};const r=vd(e,t,{type:"GET",path:n.map(e=>e.toString())}).then(wd);return r.then.bind(r)}return hd(e,t,[...n,a])},set(r,i,a){ld(o);const[s,c]=gd(a);return vd(e,t,{type:"SET",path:[...n,i].map(e=>e.toString()),value:s},c).then(wd)},apply(r,i,a){ld(o);const s=n[n.length-1];if(s===td)return vd(e,t,{type:"ENDPOINT"}).then(wd);if("bind"===s)return hd(e,t,n.slice(0,-1));const[c,u]=yd(a);return vd(e,t,{type:"APPLY",path:n.map(e=>e.toString()),argumentList:c},u).then(wd)},construct(r,i){ld(o);const[a,s]=yd(i);return vd(e,t,{type:"CONSTRUCT",path:n.map(e=>e.toString()),argumentList:a},s).then(wd)}});return function(e,t){const n=(fd.get(t)||0)+1;fd.set(t,n),pd&&pd.register(e,t,e)}(i,e),i}function yd(e){const t=e.map(gd);return[t.map(e=>e[0]),(n=t.map(e=>e[1]),Array.prototype.concat.apply([],n))];var n}const bd=new WeakMap;function gd(e){for(const[t,n]of ad)if(n.canHandle(e)){const[r,o]=n.serialize(e);return[{type:"HANDLER",name:t,value:r},o]}return[{type:"RAW",value:e},bd.get(e)||[]]}function wd(e){switch(e.type){case"HANDLER":return ad.get(e.name).deserialize(e.value);case"RAW":return e.value}}function vd(e,t,n,r){return new Promise(o=>{const i=new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-");t.set(i,o),e.start&&e.start(),e.postMessage(Object.assign({id:i},n),r)})}var md;!function(e){e.Loaded="Loaded"}(md||(md={}));const Id=async()=>{const e=ud(await(async()=>new Promise((e,t)=>{const n=new Ql({type:"module"});n.addEventListener("error",t),n.addEventListener("message",r=>{n.removeEventListener("error",t),r.data?.kind===md.Loaded?e(n):t(r)},{once:!0})}))());return{setupMixFetch:e.setupMixFetch,mixFetch:async(t,n)=>{const r=await e.mixFetch(t,n);if(!r)throw new Error("No response received");console.log({workerResponse:r});const{headers:o,status:i,statusText:a}=r,s=(e=>{const t=new Headers;return Object.keys(e).forEach(n=>{t.append(n,e[n])}),t})(o);if(r.body.blobUrl){const e=await(await fetch(r.body.blobUrl)).blob(),t=await e.arrayBuffer();return new Response(t,{headers:s,status:i,statusText:a})}const c=Object.values(r.body)[0];return new Response(c,{headers:s,status:i,statusText:a})},disconnectMixFetch:e.disconnectMixFetch}},Ed=async e=>{if(!window)throw new Error("`window` is not defined");return window.__mixFetchGlobal||(window.__mixFetchGlobal=await Id(),await window.__mixFetchGlobal.setupMixFetch(e),window.onunload=async()=>{window.__mixFetchGlobal&&await window.__mixFetchGlobal.disconnectMixFetch()}),window.__mixFetchGlobal},Sd={clientId:"edge-core-js-2026-03-10",preferredGateway:"5rXcNe2a44vXisK3uqLHCzpzvEwcnsijDMU7hg4fcYk8",preferredNetworkRequester:"5x6q9UfVHs5AohKMUqeivj7a556kVVy7QwoKige8xHxh.6CFoB3kJaDbYz6oafPJxNxNjzahpT2NtgtytcSyN9EvF@5rXcNe2a44vXisK3uqLHCzpzvEwcnsijDMU7hg4fcYk8",forceTls:!0,mixFetchOverride:{requestTimeoutMs:3e5}};const Od=function(e=()=>Date.now()){let t,n=null,r=0,o=3e4;return async function(i){if(null==n){if(e()<r){const n=r-e(),o=new Error(`mixFetch setup is cooling down for another ${Math.round(n/1e3)}s`);throw o.cause=t,o}i("Initializing mixFetch...");const a=Ed(Sd);let s;a.catch(()=>{});const c=new Promise((e,t)=>{s=setTimeout(()=>{t(new Error("mixFetch setup timed out after 60000ms"))},6e4)});n=Promise.race([a,c]).then(e=>(i("mixFetch initialized successfully"),e)).catch(a=>{throw n=null,t=a,r=e()+o,i.error(`mixFetch initialization failed (no retry for ${Math.round(o/1e3)}s):`,a),i.breadcrumb("mixFetch setup failed, cooling down",{cooldownMs:o}),o=Math.min(2*o,3e5),(async()=>{if(!window)throw new Error("`window` is not defined");if(window.__mixFetchGlobal)return window.__mixFetchGlobal.disconnectMixFetch();throw new Error("mixFetch hasn't been setup")})().catch(()=>{}),delete window.__mixFetchGlobal,a}).finally(()=>{clearTimeout(s)})}return(await n).mixFetch}}(),Ad=["allKeys","displayPrivateSeed","displayPublicSeed","keys","otpKey","loginKey","publicWalletInfo","recoveryKey"];function Td(e){const t=function(){const e={resolve(){},reject(){}};let t=0;if("undefined"!=typeof Map){const n=new Map;return{add(e){const r=++t;return n.set(r,e),r},grab(t){const r=n.get(t);return null==r?e:(n.delete(t),r)}}}const n={};return{add(e){const r=++t;return n[String(r)]=e,r},grab(t){const r=n[String(t)];return null==r?e:(delete n[String(t)],r)}}}();return{call(n,...r){return new Promise((o,i)=>{e(t.add({resolve:o,reject:i}),n,r)})},resolve(e,n){t.grab(e).resolve(n)},reject(e,n){t.grab(e).reject(new Error(n))}}}function _d(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function kd(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?_d(Object(n),!0).forEach(function(t){r(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):_d(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}const xd=new Map,[Pd,Md]=null!=window.edgeCore?[Td((e,t,n)=>{window.edgeCore.call(e,t,JSON.stringify(n))}),new Z({hideProperties:Ad,sendMessage(e){window.edgeCore.postMessage(JSON.stringify(e))},throttleMs:50})]:[Td((e,t,n)=>{window.webkit.messageHandlers.edgeCore.postMessage([e,t,n])}),new Z({hideProperties:Ad,sendMessage(e){window.webkit.messageHandlers.edgeCore.postMessage([0,"postMessage",[JSON.stringify(e)]])},throttleMs:50})];function Cd(e){const{head:t}=window.document;if(null==t||0===e.length)return void Xr();let n=0;const r=()=>{++n>=e.length&&Xr()};for(const o of e){const e=document.createElement("script");e.addEventListener("error",r),e.addEventListener("load",r),e.charset="utf-8",e.defer=!0,e.src=o,t.appendChild(e)}}async function Nd(e){const t=Lr(e,"react-native-io"),n=new(s())({hash:i().sha256,entropy:g(await Pd.call("randomBytes",32))}),r=async(e,t={})=>{const{method:n="GET",headers:r={},body:o}=t,i=await Pd.call("fetch",e,n,r,o instanceof ArrayBuffer?w(new Uint8Array(o)):o,o instanceof ArrayBuffer);return I({status:i.status,headers:i.headers,body:i.bodyIsBase64?g(i.body):i.body})},o={disklet:{delete(e){return Pd.call("diskletDelete",jd(e))},async getData(e){const t=await Pd.call("diskletGetData",jd(e));return g(t)},getText(e){return Pd.call("diskletGetText",jd(e))},list(e=""){return Pd.call("diskletList",jd(e))},setData(e,t){return Pd.call("diskletSetData",jd(e),w(t))},setText(e,t){return Pd.call("diskletSetText",jd(e),t)}},random:e=>n.generate(e),async scrypt(e,t,n,r,o,i){const a=await Pd.call("scrypt",w(e),w(t),n,r,o,i);return g(a)},async fetch(e,n){var o;const{corsBypass:i="auto",privacy:a="none"}=null!=n?n:{};if("nym"===a){const r=await Od(t);return await r(e,kd(kd({},n),{},{mode:"unsafe-ignore-cors"}),Sd)}if("always"===i)return await r(e,n);if("never"===i)return await window.fetch(e,n);const{protocol:s,host:c,pathname:u}=new URL(e),l=`${s}//${c}${u}`,d=null!==(o=xd.get(l))&&void 0!==o?o:{windowSuccess:!1,nativeSuccess:!1};if(xd.has(l)||xd.set(l,d),!d.nativeSuccess)try{const t=await window.fetch(e,n);return d.windowSuccess=!0,t}catch(p){if(d.windowSuccess)throw p}const f=await r(e,n);return d.nativeSuccess=!0,f},async fetchCors(e,t={}){return await o.fetch(e,t)}};return o}function jd(e){if(/^\//.test(e))throw new Error("Absolute paths are not supported");const t=e.split("/");let n=0,r=0;for(;n<t.length;){const e=t[n++];if(".."===e?r--:"."!==e&&""!==e&&(t[r++]=e),r<0)throw new Error("Path would escape folder")}return t.slice(0,r).join("/")}window.addEdgeCorePlugins=function(e){if(Yr)throw new Error("The Edge core plugin list has already been locked");for(const t of Object.keys(e))Hr[t]=e[t];for(const t of Vr)t(e)},window.nativeBridge=Pd,window.reactBridge=Md;const Dd=P({async makeEdgeContext(e,t,n,r){Cd(n);const o=await Nd(t);return await Gu({io:o,nativeIo:e},t,r)},async makeFakeEdgeWorld(e,t,n,r=[]){Cd(n);return Xl({io:await Nd(t),nativeIo:e},t,r)}});Md.sendRoot(Dd)}()}();
|