jcc-stream-utils
Version:
Toolkit of crossing chain from Stream chain to SWTC chain
33 lines • 443 kB
JavaScript
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.jcc_stream_utils=e():t.jcc_stream_utils=e()}(window,function(){return r={},t.m=e=[function(t,e,r){function n(t){var e=[],r=0;for(t.length%2&&(e.push(String.fromCharCode(parseInt(t.substring(0,1),16))),r=1);r<t.length;r+=2)e.push(String.fromCharCode(parseInt(t.substring(r,r+2),16)));return e.join("")}function i(t){for(var e=new Array(t.length),r=0;r<e.length;r+=1)e[r]=t.charCodeAt(r);return e}function s(t){return 1e3*(t+946684800)}function o(t){return t instanceof Date&&(t=t.getTime()),Math.round(t/1e3)-946684800}e.time={fromStream:s,toStream:o},e.trace=function(t,e){return function(){e(arguments)}},e.arraySet=function(t,e){for(var r=new Array(t),n=0;n<t;n++)r[n]=e;return r},e.hexToString=n,e.hexToArray=function(t){return i(n(t))},e.stringToArray=i,e.stringToHex=function(t){for(var e="",r=0;r<t.length;r++){var n=t.charCodeAt(r);e+=n<16?"0"+n.toString(16):n.toString(16)}return e},e.chunkString=function(t,e,r){var n=[],i=0,s=t.length;for(r&&(i=t.length%e)&&n.push(t.slice(0,i));i<s;i+=e)n.push(t.slice(i,e+i));return n},e.assert=function(t,e){if(!t)throw new Error("Assertion failed"+(e?": "+e:"."))},e.arrayUnique=function(t){for(var e={},r=[],n=0,i=t.length;n<i;n++){var s=t[n];e[s]||(r.push(s),e[s]=!0)}return r},e.toTimestamp=s,e.fromTimestamp=o,e.sjcl=r(53),e.jsbn=r(54)},function(t,e){var r=Object.prototype.hasOwnProperty,n=Object.prototype.toString;function i(t){if(!t||"[object Object]"!==n.call(t)||t.nodeType||t.setInterval)return!1;var e,i=r.call(t,"constructor"),s=r.call(t.constructor.prototype,"isPrototypeOf");if(t.constructor&&!i&&!s)return!1;for(e in t);return void 0===e||r.call(t,e)}t.exports=function t(e,r){var n,s,o,a,c,f,u=e||{},h=1,d=arguments.length,l=!1;for("boolean"==typeof u&&(l=u,u=r||{},h=2),"object"!=typeof u&&"function"!=typeof u&&(u={});h<d;h++)if(null!=(n=arguments[h]))for(s in n)o=u[s],u!==(a=n[s])&&(l&&a&&(i(a)||(c=Array.isArray(a)))?(f=c?(c=!1,o&&Array.isArray(o)?o:[]):o&&i(o)?o:{},u[s]=t(l,f,a)):void 0!==a&&(u[s]=a));return u}},function(t,e,r){"use strict";var n=e;n.version=r(101).version,n.utils=r(102),n.rand=r(45),n.curve=r(24),n.curves=r(107),n.ec=r(109),n.eddsa=r(113)},function(t,e,r){var n=r(0),i=r(18),s=r(1),o=n.jsbn.BigInteger,a=r(19).UInt,c=r(9).Base,f=s(function(){this._value=NaN,this._version_byte=void 0,this._update()},a);f.width=20,f.prototype=s({},a.prototype),(f.prototype.constructor=f).ACCOUNT_ZERO="v3DE1Hz18piSsckSvzQ3ba79hVXGkLq9Ed",f.ACCOUNT_ONE="vU2gkSzi1HevUJrT6HAobXvyBuAoTM5qp8";var u=f.HEX_ZERO="0000000000000000000000000000000000000000",h=f.HEX_ONE="0000000000000000000000000000000000000001";f.STR_ZERO=n.hexToString(u),f.STR_ONE=n.hexToString(h),f.prototype.set_version=function(t){return this._version_byte=t,this},f.prototype.get_version=function(){return this._version_byte},f.prototype.parse_json=function(t){return i.accounts&&t in i.accounts&&(t=i.accounts[t].account),"number"!=typeof t||isNaN(t)?"string"!=typeof t?this._value=NaN:"v"===t[0]?(this._value=c.decode_check(c.VER_ACCOUNT_ID,t),this._version_byte=c.VER_ACCOUNT_ID):this.parse_hex(t):(this._value=new o(String(t)),this._version_byte=c.VER_ACCOUNT_ID),this._update(),this},f.prototype.parse_generic=function(t){return a.prototype.parse_generic.call(this,t),isNaN(this._value)&&"string"==typeof t&&t[0]===v&&(this._value=c.decode_check(c.VER_ACCOUNT_ID,t)),this._update(),this},f.prototype.to_json=function(t){if(t=t||{},this._value instanceof o){if("number"!=typeof this._version_byte)return this.to_hex();var e=c.encode_check(this._version_byte,this.to_bytes());return t.gateways&&e in t.gateways&&(e=t.gateways[e]),e}return NaN},e.UInt160=f},function(t,e,r){(function(t){!function(t,e){"use strict";function r(t,e){if(!t)throw new Error(e||"Assertion failed")}function n(t,e){function r(){}t.super_=e,r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}function i(t,e,r){if(null!==t&&"object"==typeof t&&Array.isArray(t.words))return t;this.sign=!1,this.words=null,this.length=0,"le"!==e&&"be"!==e||(r=e,e=10),(this.red=null)!==t&&this._init(t||0,e||10,r||"be")}function s(t,e,r){for(var n=0,i=Math.min(t.length,r),s=e;s<i;s++){var o=t.charCodeAt(s)-48;n<<=4,n|=49<=o&&o<=54?o-49+10:17<=o&&o<=22?o-17+10:15&o}return n}function o(t,e,r,n){for(var i=0,s=Math.min(t.length,r),o=e;o<s;o++){var a=t.charCodeAt(o)-48;i*=n,i+=49<=a?a-49+10:17<=a?a-17+10:a}return i}"object"==typeof t?t.exports=i:e.BN=i,(i.BN=i).wordSize=26,i.max=function(t,e){return 0<t.cmp(e)?t:e},i.min=function(t,e){return t.cmp(e)<0?t:e},i.prototype._init=function(t,e,n){if("number"==typeof t)return this._initNumber(t,e,n);if("object"==typeof t)return this._initArray(t,e,n);"hex"===e&&(e=16),r(e===(0|e)&&2<=e&&e<=36);var i=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&i++,16===e?this._parseHex(t,i):this._parseBase(t,e,i),"-"===t[0]&&(this.sign=!0),this.strip(),"le"===n&&this._initArray(this.toArray(),e,n)},i.prototype._initNumber=function(t,e,n){t<0&&(this.sign=!0,t=-t),t<67108864?(this.words=[67108863&t],this.length=1):t<4503599627370496?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(r(t<9007199254740992),this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===n&&this._initArray(this.toArray(),e,n)},i.prototype._initArray=function(t,e,n){if(r("number"==typeof t.length),t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var i=0;i<this.length;i++)this.words[i]=0;var s=0;if("be"===n){i=t.length-1;for(var o=0;0<=i;i-=3){var a=t[i]|t[i-1]<<8|t[i-2]<<16;this.words[o]|=a<<s&67108863,this.words[o+1]=a>>>26-s&67108863,26<=(s+=24)&&(s-=26,o++)}}else if("le"===n)for(i=0,o=0;i<t.length;i+=3)a=t[i]|t[i+1]<<8|t[i+2]<<16,this.words[o]|=a<<s&67108863,this.words[o+1]=a>>>26-s&67108863,26<=(s+=24)&&(s-=26,o++);return this.strip()},i.prototype._parseHex=function(t,e){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var r=0;r<this.length;r++)this.words[r]=0;for(var n=0,i=(r=t.length-6,0);e<=r;r-=6){var o=s(t,r,r+6);this.words[i]|=o<<n&67108863,this.words[i+1]|=o>>>26-n&4194303,26<=(n+=24)&&(n-=26,i++)}r+6!==e&&(o=s(t,e,r+6),this.words[i]|=o<<n&67108863,this.words[i+1]|=o>>>26-n&4194303),this.strip()},i.prototype._parseBase=function(t,e,r){this.words=[0];for(var n=0,i=this.length=1;i<=67108863;i*=e)n++;n--,i=i/e|0;for(var s=t.length-r,a=s%n,c=Math.min(s,s-a)+r,f=0,u=r;u<c;u+=n)f=o(t,u,u+n,e),this.imuln(i),this.words[0]+f<67108864?this.words[0]+=f:this._iaddn(f);if(0!=a){var h=1;for(f=o(t,u,t.length,e),u=0;u<a;u++)h*=e;this.imuln(h),this.words[0]+f<67108864?this.words[0]+=f:this._iaddn(f)}},i.prototype.copy=function(t){t.words=new Array(this.length);for(var e=0;e<this.length;e++)t.words[e]=this.words[e];t.length=this.length,t.sign=this.sign,t.red=this.red},i.prototype.clone=function(){var t=new i(null);return this.copy(t),t},i.prototype.strip=function(){for(;1<this.length&&0===this.words[this.length-1];)this.length--;return this._normSign()},i.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.sign=!1),this},i.prototype.inspect=function(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"};var a=["","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"],c=[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 u(t){for(var e=new Array(t.bitLength()),r=0;r<e.length;r++){var n=r/26|0,i=r%26;e[r]=(t.words[n]&1<<i)>>>i}return e}i.prototype.toString=function(t,e){if(e=0|e||1,16===(t=t||10)||"hex"===t){for(var n="",i=0,s=0,o=0;o<this.length;o++){var u=this.words[o],h=(16777215&(u<<i|s)).toString(16);n=0!=(s=u>>>24-i&16777215)||o!==this.length-1?a[6-h.length]+h+n:h+n,26<=(i+=2)&&(i-=26,o--)}for(0!==s&&(n=s.toString(16)+n);n.length%e!=0;)n="0"+n;return this.sign&&(n="-"+n),n}if(t===(0|t)&&2<=t&&t<=36){var d=c[t],l=f[t],p=(n="",this.clone());for(p.sign=!1;0!==p.cmpn(0);){var b=p.modn(l).toString(t);n=0!==(p=p.idivn(l)).cmpn(0)?a[d-b.length]+b+n:b+n}for(0===this.cmpn(0)&&(n="0"+n);n.length%e!=0;)n="0"+n;return this.sign&&(n="-"+n),n}r(!1,"Base should be between 2 and 36")},i.prototype.toJSON=function(){return this.toString(16)},i.prototype.toArray=function(t,e){this.strip();var n="le"===t,i=new Array(this.byteLength());i[0]=0;var s=this.clone();if(n)for(o=0;0!==s.cmpn(0);o++)a=s.andln(255),s.iushrn(8),i[o]=a;else for(var o=0;0!==s.cmpn(0);o++){var a=s.andln(255);s.iushrn(8),i[i.length-o-1]=a}if(e)for(r(i.length<=e,"byte array longer than desired length");i.length<e;)n?i.push(0):i.unshift(0);return i},i.prototype._countBits=Math.clz32?function(t){return 32-Math.clz32(t)}:function(t){var e=t,r=0;return 4096<=e&&(r+=13,e>>>=13),64<=e&&(r+=7,e>>>=7),8<=e&&(r+=4,e>>>=4),2<=e&&(r+=2,e>>>=2),r+e},i.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,r=0;return 0==(8191&e)&&(r+=13,e>>>=13),0==(127&e)&&(r+=7,e>>>=7),0==(15&e)&&(r+=4,e>>>=4),0==(3&e)&&(r+=2,e>>>=2),0==(1&e)&&r++,r},i.prototype.bitLength=function(){var t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e},i.prototype.zeroBits=function(){if(0===this.cmpn(0))return 0;for(var t=0,e=0;e<this.length;e++){var r=this._zeroBits(this.words[e]);if(t+=r,26!==r)break}return t},i.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},i.prototype.neg=function(){if(0===this.cmpn(0))return this.clone();var t=this.clone();return t.sign=!this.sign,t},i.prototype.iuor=function(t){for(;this.length<t.length;)this.words[this.length++]=0;for(var e=0;e<t.length;e++)this.words[e]=this.words[e]|t.words[e];return this.strip()},i.prototype.ior=function(t){return r(!this.sign&&!t.sign),this.iuor(t)},i.prototype.or=function(t){return this.length>t.length?this.clone().ior(t):t.clone().ior(this)},i.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},i.prototype.iuand=function(t){var e;e=this.length>t.length?t:this;for(var r=0;r<e.length;r++)this.words[r]=this.words[r]&t.words[r];return this.length=e.length,this.strip()},i.prototype.iand=function(t){return r(!this.sign&&!t.sign),this.iuand(t)},i.prototype.and=function(t){return this.length>t.length?this.clone().iand(t):t.clone().iand(this)},i.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},i.prototype.iuxor=function(t){var e,r;r=this.length>t.length?(e=this,t):(e=t,this);for(var n=0;n<r.length;n++)this.words[n]=e.words[n]^r.words[n];if(this!==e)for(;n<e.length;n++)this.words[n]=e.words[n];return this.length=e.length,this.strip()},i.prototype.ixor=function(t){return r(!this.sign&&!t.sign),this.iuxor(t)},i.prototype.xor=function(t){return this.length>t.length?this.clone().ixor(t):t.clone().ixor(this)},i.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},i.prototype.setn=function(t,e){r("number"==typeof t&&0<=t);for(var n=t/26|0,i=t%26;this.length<=n;)this.words[this.length++]=0;return this.words[n]=e?this.words[n]|1<<i:this.words[n]&~(1<<i),this.strip()},i.prototype.iadd=function(t){if(this.sign&&!t.sign){this.sign=!1;var e=this.isub(t);return this.sign=!this.sign,this._normSign()}if(!this.sign&&t.sign)return t.sign=!1,e=this.isub(t),t.sign=!0,e._normSign();var r,n;n=this.length>t.length?(r=this,t):(r=t,this);for(var i=0,s=0;s<n.length;s++)e=r.words[s]+n.words[s]+i,this.words[s]=67108863&e,i=e>>>26;for(;0!==i&&s<r.length;s++)e=r.words[s]+i,this.words[s]=67108863&e,i=e>>>26;if(this.length=r.length,0!==i)this.words[this.length]=i,this.length++;else if(r!==this)for(;s<r.length;s++)this.words[s]=r.words[s];return this},i.prototype.add=function(t){if(t.sign&&!this.sign){t.sign=!1;var e=this.sub(t);return t.sign=!0,e}return t.sign||!this.sign?this.length>t.length?this.clone().iadd(t):t.clone().iadd(this):(this.sign=!1,e=t.sub(this),this.sign=!0,e)},i.prototype.isub=function(t){if(t.sign){t.sign=!1;var e=this.iadd(t);return t.sign=!0,e._normSign()}if(this.sign)return this.sign=!1,this.iadd(t),this.sign=!0,this._normSign();var r,n,i=this.cmp(t);if(0===i)return this.sign=!1,this.length=1,this.words[0]=0,this;n=0<i?(r=this,t):(r=t,this);for(var s=0,o=0;o<n.length;o++)s=(e=r.words[o]-n.words[o]+s)>>26,this.words[o]=67108863&e;for(;0!==s&&o<r.length;o++)s=(e=r.words[o]+s)>>26,this.words[o]=67108863&e;if(0===s&&o<r.length&&r!==this)for(;o<r.length;o++)this.words[o]=r.words[o];return this.length=Math.max(this.length,o),r!==this&&(this.sign=!0),this.strip()},i.prototype.sub=function(t){return this.clone().isub(t)},i.prototype._smallMulTo=function(t,e){e.sign=t.sign!==this.sign,e.length=this.length+t.length;for(var r=0,n=0;n<e.length-1;n++){for(var i=r>>>26,s=67108863&r,o=Math.min(n,t.length-1),a=Math.max(0,n-this.length+1);a<=o;a++){var c=n-a,f=(0|this.words[c])*(0|t.words[a]),u=67108863&f;s=67108863&(u=u+s|0),i=(i=i+(f/67108864|0)|0)+(u>>>26)|0}e.words[n]=s,r=i}return 0!==r?e.words[n]=r:e.length--,e.strip()},i.prototype._bigMulTo=function(t,e){e.sign=t.sign!==this.sign,e.length=this.length+t.length;for(var r=0,n=0,i=0;i<e.length-1;i++){var s=n;n=0;for(var o=67108863&r,a=Math.min(i,t.length-1),c=Math.max(0,i-this.length+1);c<=a;c++){var f=i-c,u=(0|this.words[f])*(0|t.words[c]),h=67108863&u;o=67108863&(h=h+o|0),n+=(s=(s=s+(u/67108864|0)|0)+(h>>>26)|0)>>>26,s&=67108863}e.words[i]=o,r=s,s=n}return 0!==r?e.words[i]=r:e.length--,e.strip()},i.prototype.mulTo=function(t,e){return this.length+t.length<63?this._smallMulTo(t,e):this._bigMulTo(t,e)},i.prototype.mul=function(t){var e=new i(null);return e.words=new Array(this.length+t.length),this.mulTo(t,e)},i.prototype.imul=function(t){if(0===this.cmpn(0)||0===t.cmpn(0))return this.words[0]=0,this.length=1,this;var e=this.length,r=t.length;this.sign=t.sign!==this.sign,this.length=this.length+t.length,this.words[this.length-1]=0;for(var n=this.length-2;0<=n;n--){for(var i=0,s=0,o=Math.min(n,r-1),a=Math.max(0,n-e+1);a<=o;a++){var c=n-a,f=this.words[c]*t.words[a],u=67108863&f;i+=f/67108864|0,s=67108863&(u+=s),i+=u>>>26}this.words[n]=s,this.words[n+1]+=i,i=0}for(i=0,c=1;c<this.length;c++){var h=this.words[c]+i;this.words[c]=67108863&h,i=h>>>26}return this.strip()},i.prototype.imuln=function(t){r("number"==typeof t);for(var e=0,n=0;n<this.length;n++){var i=this.words[n]*t,s=(67108863&i)+(67108863&e);e>>=26,e+=i/67108864|0,e+=s>>>26,this.words[n]=67108863&s}return 0!==e&&(this.words[n]=e,this.length++),this},i.prototype.muln=function(t){return this.clone().imuln(t)},i.prototype.sqr=function(){return this.mul(this)},i.prototype.isqr=function(){return this.mul(this)},i.prototype.pow=function(t){var e=u(t);if(0===e.length)return new i(1);for(var r=this,n=0;n<e.length&&0===e[n];n++,r=r.sqr());if(++n<e.length)for(var s=r.sqr();n<e.length;n++,s=s.sqr())0!==e[n]&&(r=r.mul(s));return r},i.prototype.iushln=function(t){r("number"==typeof t&&0<=t);var e=t%26,n=(t-e)/26,i=67108863>>>26-e<<26-e;if(0!=e){for(var s=0,o=0;o<this.length;o++){var a=this.words[o]&i,c=this.words[o]-a<<e;this.words[o]=c|s,s=a>>>26-e}s&&(this.words[o]=s,this.length++)}if(0!=n){for(o=this.length-1;0<=o;o--)this.words[o+n]=this.words[o];for(o=0;o<n;o++)this.words[o]=0;this.length+=n}return this.strip()},i.prototype.ishln=function(t){return r(!this.sign),this.iushln(t)},i.prototype.iushrn=function(t,e,n){var i;r("number"==typeof t&&0<=t),i=e?(e-e%26)/26:0;var s=t%26,o=Math.min((t-s)/26,this.length),a=67108863^67108863>>>s<<s,c=n;if(i-=o,i=Math.max(0,i),c){for(var f=0;f<o;f++)c.words[f]=this.words[f];c.length=o}if(0===o);else if(this.length>o)for(this.length-=o,f=0;f<this.length;f++)this.words[f]=this.words[f+o];else this.words[0]=0,this.length=1;var u=0;for(f=this.length-1;0<=f&&(0!==u||i<=f);f--){var h=this.words[f];this.words[f]=u<<26-s|h>>>s,u=h&a}return c&&0!==u&&(c.words[c.length++]=u),0===this.length&&(this.words[0]=0,this.length=1),this.strip(),this},i.prototype.ishrn=function(t,e,n){return r(!this.sign),this.iushrn(t,e,n)},i.prototype.shln=function(t){return this.clone().ishln(t)},i.prototype.ushln=function(t){return this.clone().iushln(t)},i.prototype.shrn=function(t){return this.clone().ishrn(t)},i.prototype.ushrn=function(t){return this.clone().iushrn(t)},i.prototype.testn=function(t){r("number"==typeof t&&0<=t);var e=t%26,n=(t-e)/26,i=1<<e;return!(this.length<=n||!(this.words[n]&i))},i.prototype.imaskn=function(t){r("number"==typeof t&&0<=t);var e=t%26,n=(t-e)/26;if(r(!this.sign,"imaskn works only with positive numbers"),0!=e&&n++,this.length=Math.min(n,this.length),0!=e){var i=67108863^67108863>>>e<<e;this.words[this.length-1]&=i}return this.strip()},i.prototype.maskn=function(t){return this.clone().imaskn(t)},i.prototype.iaddn=function(t){return r("number"==typeof t),t<0?this.isubn(-t):this.sign?(1===this.length&&this.words[0]<t?(this.words[0]=t-this.words[0],this.sign=!1):(this.sign=!1,this.isubn(t),this.sign=!0),this):this._iaddn(t)},i.prototype._iaddn=function(t){this.words[0]+=t;for(var e=0;e<this.length&&67108864<=this.words[e];e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},i.prototype.isubn=function(t){if(r("number"==typeof t),t<0)return this.iaddn(-t);if(this.sign)return this.sign=!1,this.iaddn(t),this.sign=!0,this;this.words[0]-=t;for(var e=0;e<this.length&&this.words[e]<0;e++)this.words[e]+=67108864,this.words[e+1]-=1;return this.strip()},i.prototype.addn=function(t){return this.clone().iaddn(t)},i.prototype.subn=function(t){return this.clone().isubn(t)},i.prototype.iabs=function(){return this.sign=!1,this},i.prototype.abs=function(){return this.clone().iabs()},i.prototype._ishlnsubmul=function(t,e,n){var i=t.length+n;if(this.words.length<i){for(var s=new Array(i),o=0;o<this.length;o++)s[o]=this.words[o];this.words=s}else o=this.length;for(this.length=Math.max(this.length,i);o<this.length;o++)this.words[o]=0;var a=0;for(o=0;o<t.length;o++){var c=this.words[o+n]+a,f=t.words[o]*e;a=((c-=67108863&f)>>26)-(f/67108864|0),this.words[o+n]=67108863&c}for(;o<this.length-n;o++)a=(c=this.words[o+n]+a)>>26,this.words[o+n]=67108863&c;if(0===a)return this.strip();for(r(-1===a),o=a=0;o<this.length;o++)a=(c=-this.words[o]+a)>>26,this.words[o]=67108863&c;return this.sign=!0,this.strip()},i.prototype._wordDiv=function(t,e){var r=(this.length,t.length),n=this.clone(),s=t,o=s.words[s.length-1];0!=(r=26-this._countBits(o))&&(s=s.ushln(r),n.iushln(r),o=s.words[s.length-1]);var a,c=n.length-s.length;if("mod"!==e){(a=new i(null)).length=1+c,a.words=new Array(a.length);for(var f=0;f<a.length;f++)a.words[f]=0}var u=n.clone()._ishlnsubmul(s,1,c);u.sign||(n=u,a&&(a.words[c]=1));for(var h=c-1;0<=h;h--){var d=67108864*n.words[s.length+h]+n.words[s.length+h-1];for(d=Math.min(d/o|0,67108863),n._ishlnsubmul(s,d,h);n.sign;)d--,n.sign=!1,n._ishlnsubmul(s,1,h),0!==n.cmpn(0)&&(n.sign=!n.sign);a&&(a.words[h]=d)}return a&&a.strip(),n.strip(),"div"!==e&&0!=r&&n.iushrn(r),{div:a||null,mod:n}},i.prototype.divmod=function(t,e,n){if(r(0!==t.cmpn(0)),this.sign&&!t.sign){var s=this.neg().divmod(t,e);return"mod"!==e&&(o=s.div.neg()),"div"!==e&&(a=s.mod.neg(),n&&a.neg&&(a=a.add(t))),{div:o,mod:a}}var o,a;return!this.sign&&t.sign?(s=this.divmod(t.neg(),e),"mod"!==e&&(o=s.div.neg()),{div:o,mod:s.mod}):this.sign&&t.sign?(s=this.neg().divmod(t.neg(),e),"div"!==e&&(a=s.mod.neg(),n&&a.neg&&(a=a.isub(t))),{div:s.div,mod:a}):t.length>this.length||this.cmp(t)<0?{div:new i(0),mod:this}:1===t.length?"div"===e?{div:this.divn(t.words[0]),mod:null}:"mod"===e?{div:null,mod:new i(this.modn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new i(this.modn(t.words[0]))}:this._wordDiv(t,e)},i.prototype.div=function(t){return this.divmod(t,"div",!1).div},i.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},i.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},i.prototype.divRound=function(t){var e=this.divmod(t);if(0===e.mod.cmpn(0))return e.div;var r=e.div.sign?e.mod.isub(t):e.mod,n=t.ushrn(1),i=t.andln(1),s=r.cmp(n);return s<0||1===i&&0===s?e.div:e.div.sign?e.div.isubn(1):e.div.iaddn(1)},i.prototype.modn=function(t){r(t<=67108863);for(var e=(1<<26)%t,n=0,i=this.length-1;0<=i;i--)n=(e*n+this.words[i])%t;return n},i.prototype.idivn=function(t){r(t<=67108863);for(var e=0,n=this.length-1;0<=n;n--){var i=this.words[n]+67108864*e;this.words[n]=i/t|0,e=i%t}return this.strip()},i.prototype.divn=function(t){return this.clone().idivn(t)},i.prototype.egcd=function(t){r(!t.sign),r(0!==t.cmpn(0));var e=this,n=t.clone();e=e.sign?e.umod(t):e.clone();for(var s=new i(1),o=new i(0),a=new i(0),c=new i(1),f=0;e.isEven()&&n.isEven();)e.iushrn(1),n.iushrn(1),++f;for(var u=n.clone(),h=e.clone();0!==e.cmpn(0);){for(;e.isEven();)e.iushrn(1),s.isEven()&&o.isEven()?(s.iushrn(1),o.iushrn(1)):(s.iadd(u).iushrn(1),o.isub(h).iushrn(1));for(;n.isEven();)n.iushrn(1),a.isEven()&&c.isEven()?(a.iushrn(1),c.iushrn(1)):(a.iadd(u).iushrn(1),c.isub(h).iushrn(1));0<=e.cmp(n)?(e.isub(n),s.isub(a),o.isub(c)):(n.isub(e),a.isub(s),c.isub(o))}return{a:a,b:c,gcd:n.iushln(f)}},i.prototype._invmp=function(t){r(!t.sign),r(0!==t.cmpn(0));var e=this,n=t.clone();e=e.sign?e.umod(t):e.clone();for(var s,o=new i(1),a=new i(0),c=n.clone();0<e.cmpn(1)&&0<n.cmpn(1);){for(;e.isEven();)e.iushrn(1),o.isEven()?o.iushrn(1):o.iadd(c).iushrn(1);for(;n.isEven();)n.iushrn(1),a.isEven()?a.iushrn(1):a.iadd(c).iushrn(1);0<=e.cmp(n)?(e.isub(n),o.isub(a)):(n.isub(e),a.isub(o))}return(s=0===e.cmpn(1)?o:a).cmpn(0)<0&&s.iadd(t),s},i.prototype.gcd=function(t){if(0===this.cmpn(0))return t.clone();if(0===t.cmpn(0))return this.clone();var e=this.clone(),r=t.clone();e.sign=!1,r.sign=!1;for(var n=0;e.isEven()&&r.isEven();n++)e.iushrn(1),r.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;r.isEven();)r.iushrn(1);var i=e.cmp(r);if(i<0){var s=e;e=r,r=s}else if(0===i||0===r.cmpn(1))break;e.isub(r)}return r.iushln(n)},i.prototype.invm=function(t){return this.egcd(t).a.umod(t)},i.prototype.isEven=function(){return 0==(1&this.words[0])},i.prototype.isOdd=function(){return 1==(1&this.words[0])},i.prototype.andln=function(t){return this.words[0]&t},i.prototype.bincn=function(t){r("number"==typeof t);var e=t%26,n=(t-e)/26,i=1<<e;if(this.length<=n){for(var s=this.length;s<1+n;s++)this.words[s]=0;return this.words[n]|=i,this.length=1+n,this}var o=i;for(s=n;0!==o&&s<this.length;s++){var a=this.words[s];o=(a+=o)>>>26,a&=67108863,this.words[s]=a}return 0!==o&&(this.words[s]=o,this.length++),this},i.prototype.cmpn=function(t){var e,r=t<0;if(r&&(t=-t),this.sign&&!r)return-1;if(!this.sign&&r)return 1;if(t&=67108863,this.strip(),1<this.length)e=1;else{var n=this.words[0];e=n===t?0:n<t?-1:1}return this.sign&&(e=-e),e},i.prototype.cmp=function(t){if(this.sign&&!t.sign)return-1;if(!this.sign&&t.sign)return 1;var e=this.ucmp(t);return this.sign?-e:e},i.prototype.ucmp=function(t){if(this.length>t.length)return 1;if(this.length<t.length)return-1;for(var e=0,r=this.length-1;0<=r;r--){var n=this.words[r],i=t.words[r];if(n!==i){n<i?e=-1:i<n&&(e=1);break}}return e},i.red=function(t){return new y(t)},i.prototype.toRed=function(t){return r(!this.red,"Already a number in reduction context"),r(!this.sign,"red works only with positives"),t.convertTo(this)._forceRed(t)},i.prototype.fromRed=function(){return r(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},i.prototype._forceRed=function(t){return this.red=t,this},i.prototype.forceRed=function(t){return r(!this.red,"Already a number in reduction context"),this._forceRed(t)},i.prototype.redAdd=function(t){return r(this.red,"redAdd works only with red numbers"),this.red.add(this,t)},i.prototype.redIAdd=function(t){return r(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},i.prototype.redSub=function(t){return r(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},i.prototype.redISub=function(t){return r(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},i.prototype.redShl=function(t){return r(this.red,"redShl works only with red numbers"),this.red.ushl(this,t)},i.prototype.redMul=function(t){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},i.prototype.redIMul=function(t){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},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(t){return r(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var h={k256:null,p224:null,p192:null,p25519:null};function d(t,e){this.name=t,this.p=new i(e,16),this.n=this.p.bitLength(),this.k=new i(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function l(){d.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function p(){d.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function b(){d.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function _(){d.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function y(t){if("string"==typeof t){var e=i._prime(t);this.m=e.p,this.prime=e}else this.m=t,this.prime=null}function v(t){y.call(this,t),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)}d.prototype._tmp=function(){var t=new i(null);return t.words=new Array(Math.ceil(this.n/13)),t},d.prototype.ireduce=function(t){for(var e,r=t;this.split(r,this.tmp),(e=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength())>this.n;);var n=e<this.n?-1:r.ucmp(this.p);return 0===n?(r.words[0]=0,r.length=1):0<n?r.isub(this.p):r.strip(),r},d.prototype.split=function(t,e){t.iushrn(this.n,0,e)},d.prototype.imulK=function(t){return t.imul(this.k)},n(l,d),l.prototype.split=function(t,e){for(var r=Math.min(t.length,9),n=0;n<r;n++)e.words[n]=t.words[n];if(e.length=r,t.length<=9)return t.words[0]=0,void(t.length=1);var i=t.words[9];for(e.words[e.length++]=4194303&i,n=10;n<t.length;n++){var s=t.words[n];t.words[n-10]=(4194303&s)<<4|i>>>22,i=s}t.words[n-10]=i>>>22,t.length-=9},l.prototype.imulK=function(t){var e;t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var r=0,n=0;n<t.length;n++){var i=t.words[n];e=64*i,e+=(r+=977*i)/67108864|0,r&=67108863,t.words[n]=r,r=e}return 0===t.words[t.length-1]&&(t.length--,0===t.words[t.length-1]&&t.length--),t},n(p,d),n(b,d),n(_,d),_.prototype.imulK=function(t){for(var e=0,r=0;r<t.length;r++){var n=19*t.words[r]+e,i=67108863&n;n>>>=26,t.words[r]=i,e=n}return 0!==e&&(t.words[t.length++]=e),t},i._prime=function(t){if(h[t])return h[t];var e;if("k256"===t)e=new l;else if("p224"===t)e=new p;else if("p192"===t)e=new b;else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new _}return h[t]=e},y.prototype._verify1=function(t){r(!t.sign,"red works only with positives"),r(t.red,"red works only with red numbers")},y.prototype._verify2=function(t,e){r(!t.sign&&!e.sign,"red works only with positives"),r(t.red&&t.red===e.red,"red works only with red numbers")},y.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):t.umod(this.m)._forceRed(this)},y.prototype.neg=function(t){var e=t.clone();return e.sign=!e.sign,e.iadd(this.m)._forceRed(this)},y.prototype.add=function(t,e){this._verify2(t,e);var r=t.add(e);return 0<=r.cmp(this.m)&&r.isub(this.m),r._forceRed(this)},y.prototype.iadd=function(t,e){this._verify2(t,e);var r=t.iadd(e);return 0<=r.cmp(this.m)&&r.isub(this.m),r},y.prototype.sub=function(t,e){this._verify2(t,e);var r=t.sub(e);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},y.prototype.isub=function(t,e){this._verify2(t,e);var r=t.isub(e);return r.cmpn(0)<0&&r.iadd(this.m),r},y.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},y.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},y.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},y.prototype.isqr=function(t){return this.imul(t,t)},y.prototype.sqr=function(t){return this.mul(t,t)},y.prototype.sqrt=function(t){if(0===t.cmpn(0))return t.clone();var e=this.m.andln(3);if(r(e%2==1),3===e){var n=this.m.add(new i(1)).iushrn(2);return this.pow(t,n)}for(var s=this.m.subn(1),o=0;0!==s.cmpn(0)&&0===s.andln(1);)o++,s.iushrn(1);r(0!==s.cmpn(0));var a=new i(1).toRed(this),c=a.redNeg(),f=this.m.subn(1).iushrn(1),u=this.m.bitLength();for(u=new i(2*u*u).toRed(this);0!==this.pow(u,f).cmp(c);)u.redIAdd(c);for(var h=this.pow(u,s),d=this.pow(t,s.addn(1).iushrn(1)),l=this.pow(t,s),p=o;0!==l.cmp(a);){for(var b=l,_=0;0!==b.cmp(a);_++)b=b.redSqr();r(_<p);var y=this.pow(h,new i(1).iushln(p-_-1));d=d.redMul(y),h=y.redSqr(),l=l.redMul(h),p=_}return d},y.prototype.invm=function(t){var e=t._invmp(this.m);return e.sign?(e.sign=!1,this.imod(e).redNeg()):this.imod(e)},y.prototype.pow=function(t,e){var r=u(e);if(0===r.length)return new i(1);for(var n=t,s=0;s<r.length&&0===r[s];s++,n=this.sqr(n));if(++s<r.length)for(var o=this.sqr(n);s<r.length;s++,o=this.sqr(o))0!==r[s]&&(n=this.mul(n,o));return n},y.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},y.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},i.mont=function(t){return new v(t)},n(v,y),v.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},v.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},v.prototype.imul=function(t,e){if(0===t.cmpn(0)||0===e.cmpn(0))return t.words[0]=0,t.length=1,t;var r=t.imul(e),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),s=i;return 0<=i.cmp(this.m)?s=i.isub(this.m):i.cmpn(0)<0&&(s=i.iadd(this.m)),s._forceRed(this)},v.prototype.mul=function(t,e){if(0===t.cmpn(0)||0===e.cmpn(0))return new i(0)._forceRed(this);var r=t.mul(e),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),s=r.isub(n).iushrn(this.shift),o=s;return 0<=s.cmp(this.m)?o=s.isub(this.m):s.cmpn(0)<0&&(o=s.iadd(this.m)),o._forceRed(this)},v.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(t,this)}).call(this,r(35)(t))},function(t,e,r){(function(t){var n=Object.getOwnPropertyDescriptors||function(t){for(var e=Object.keys(t),r={},n=0;n<e.length;n++)r[e[n]]=Object.getOwnPropertyDescriptor(t,e[n]);return r},i=/%[sdj%]/g;e.format=function(t){if(!y(t)){for(var e=[],r=0;r<arguments.length;r++)e.push(a(arguments[r]));return e.join(" ")}r=1;for(var n=arguments,s=n.length,o=String(t).replace(i,function(t){if("%%"===t)return"%";if(s<=r)return t;switch(t){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(t){return"[Circular]"}default:return t}}),c=n[r];r<s;c=n[++r])b(c)||!g(c)?o+=" "+c:o+=" "+a(c);return o},e.deprecate=function(r,n){if(void 0!==t&&!0===t.noDeprecation)return r;if(void 0===t)return function(){return e.deprecate(r,n).apply(this,arguments)};var i=!1;return function(){if(!i){if(t.throwDeprecation)throw new Error(n);t.traceDeprecation,i=!0}return r.apply(this,arguments)}};var s,o={};function a(t,r){var n={seen:[],stylize:f};return 3<=arguments.length&&(n.depth=arguments[2]),4<=arguments.length&&(n.colors=arguments[3]),p(r)?n.showHidden=r:r&&e._extend(n,r),v(n.showHidden)&&(n.showHidden=!1),v(n.depth)&&(n.depth=2),v(n.colors)&&(n.colors=!1),v(n.customInspect)&&(n.customInspect=!0),n.colors&&(n.stylize=c),u(n,t,n.depth)}function c(t,e){var r=a.styles[e];return r?"["+a.colors[r][0]+"m"+t+"["+a.colors[r][1]+"m":t}function f(t,e){return t}function u(t,r,n){if(t.customInspect&&r&&S(r.inspect)&&r.inspect!==e.inspect&&(!r.constructor||r.constructor.prototype!==r)){var i=r.inspect(n,t);return y(i)||(i=u(t,i,n)),i}var s=function(t,e){if(v(e))return t.stylize("undefined","undefined");if(y(e)){var r="'"+JSON.stringify(e).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return t.stylize(r,"string")}return _(e)?t.stylize(""+e,"number"):p(e)?t.stylize(""+e,"boolean"):b(e)?t.stylize("null","null"):void 0}(t,r);if(s)return s;var o=Object.keys(r),a=function(t){var e={};return o.forEach(function(t,r){e[t]=!0}),e}();if(t.showHidden&&(o=Object.getOwnPropertyNames(r)),A(r)&&(0<=o.indexOf("message")||0<=o.indexOf("description")))return h(r);if(0===o.length){if(S(r)){var c=r.name?": "+r.name:"";return t.stylize("[Function"+c+"]","special")}if(m(r))return t.stylize(RegExp.prototype.toString.call(r),"regexp");if(w(r))return t.stylize(Date.prototype.toString.call(r),"date");if(A(r))return h(r)}var f,g="",E=!1,T=["{","}"];return l(r)&&(E=!0,T=["[","]"]),S(r)&&(g=" [Function"+(r.name?": "+r.name:"")+"]"),m(r)&&(g=" "+RegExp.prototype.toString.call(r)),w(r)&&(g=" "+Date.prototype.toUTCString.call(r)),A(r)&&(g=" "+h(r)),0!==o.length||E&&0!=r.length?n<0?m(r)?t.stylize(RegExp.prototype.toString.call(r),"regexp"):t.stylize("[Object]","special"):(t.seen.push(r),f=E?function(t,e,r,n,i){for(var s=[],o=0,a=e.length;o<a;++o)x(e,String(o))?s.push(d(t,e,r,n,String(o),!0)):s.push("");return i.forEach(function(i){i.match(/^\d+$/)||s.push(d(t,e,r,n,i,!0))}),s}(t,r,n,a,o):o.map(function(e){return d(t,r,n,a,e,E)}),t.seen.pop(),function(t,e,r){return 60<t.reduce(function(t,e){return e.indexOf("\n"),t+e.replace(/\u001b\[\d\d?m/g,"").length+1},0)?r[0]+(""===e?"":e+"\n ")+" "+t.join(",\n ")+" "+r[1]:r[0]+e+" "+t.join(", ")+" "+r[1]}(f,g,T)):T[0]+g+T[1]}function h(t){return"["+Error.prototype.toString.call(t)+"]"}function d(t,e,r,n,i,s){var o,a,c;if((c=Object.getOwnPropertyDescriptor(e,i)||{value:e[i]}).get?a=c.set?t.stylize("[Getter/Setter]","special"):t.stylize("[Getter]","special"):c.set&&(a=t.stylize("[Setter]","special")),x(n,i)||(o="["+i+"]"),a||(t.seen.indexOf(c.value)<0?-1<(a=b(r)?u(t,c.value,null):u(t,c.value,r-1)).indexOf("\n")&&(a=s?a.split("\n").map(function(t){return" "+t}).join("\n").substr(2):"\n"+a.split("\n").map(function(t){return" "+t}).join("\n")):a=t.stylize("[Circular]","special")),v(o)){if(s&&i.match(/^\d+$/))return a;o=(o=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(o=o.substr(1,o.length-2),t.stylize(o,"name")):(o=o.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),t.stylize(o,"string"))}return o+": "+a}function l(t){return Array.isArray(t)}function p(t){return"boolean"==typeof t}function b(t){return null===t}function _(t){return"number"==typeof t}function y(t){return"string"==typeof t}function v(t){return void 0===t}function m(t){return g(t)&&"[object RegExp]"===E(t)}function g(t){return"object"==typeof t&&null!==t}function w(t){return g(t)&&"[object Date]"===E(t)}function A(t){return g(t)&&("[object Error]"===E(t)||t instanceof Error)}function S(t){return"function"==typeof t}function E(t){return Object.prototype.toString.call(t)}function x(t,e){return Object.prototype.hasOwnProperty.call(t,e)}e.debuglog=function(r){return v(s)&&(s=t.env.NODE_DEBUG||""),r=r.toUpperCase(),o[r]||(new RegExp("\\b"+r+"\\b","i").test(s)?(t.pid,o[r]=function(){e.format.apply(e,arguments)}):o[r]=function(){}),o[r]},(e.inspect=a).colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},a.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},e.isArray=l,e.isBoolean=p,e.isNull=b,e.isNullOrUndefined=function(t){return null==t},e.isNumber=_,e.isString=y,e.isSymbol=function(t){return"symbol"==typeof t},e.isUndefined=v,e.isRegExp=m,e.isObject=g,e.isDate=w,e.isError=A,e.isFunction=S,e.isPrimitive=function(t){return null===t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||"symbol"==typeof t||void 0===t},e.isBuffer=r(62),e.log=function(){},e.inherits=r(12),e._extend=function(t,e){if(!e||!g(e))return t;for(var r=Object.keys(e),n=r.length;n--;)t[r[n]]=e[r[n]];return t};var T="undefined"!=typeof Symbol?Symbol("util.promisify.custom"):void 0;function j(t,e){if(!t){var r=new Error("Promise was rejected with a falsy value");r.reason=t,t=r}return e(t)}e.promisify=function(t){if("function"!=typeof t)throw new TypeError('The "original" argument must be of type Function');if(T&&t[T]){var e;if("function"!=typeof(e=t[T]))throw new TypeError('The "util.promisify.custom" argument must be of type Function');return Object.defineProperty(e,T,{value:e,enumerable:!1,writable:!1,configurable:!0}),e}function e(){for(var e,r,n=new Promise(function(t,n){e=t,r=n}),i=[],s=0;s<arguments.length;s++)i.push(arguments[s]);i.push(function(t,n){t?r(t):e(n)});try{t.apply(this,i)}catch(n){r(n)}return n}return Object.setPrototypeOf(e,Object.getPrototypeOf(t)),T&&Object.defineProperty(e,T,{value:e,enumerable:!1,writable:!1,configurable:!0}),Object.defineProperties(e,n(t))},e.promisify.custom=T,e.callbackify=function(e){if("function"!=typeof e)throw new TypeError('The "original" argument must be of type Function');function r(){for(var r=[],n=0;n<arguments.length;n++)r.push(arguments[n]);var i=r.pop();if("function"!=typeof i)throw new TypeError("The last argument must be of type Function");function s(){return i.apply(o,arguments)}var o=this;e.apply(this,r).then(function(e){t.nextTick(s,null,e)},function(e){t.nextTick(j,e,s)})}return Object.setPrototypeOf(r,Object.getPrototypeOf(e)),Object.defineProperties(r,n(e)),r}}).call(this,r(27))},function(t,e,r){var n=r(1),i=r(0),s=(i.sjcl.bn,i.jsbn.BigInteger),o=r(3).UInt160,a=r(28).Seed,c=r(21).Currency;function f(){this._value=new s,this._offset=0,this._is_native=!0,this._is_negative=!1,this._currency=new c,this._issuer=new o}var u={currency_xns:0,currency_one:1,xns_precision:6,bi_5:new s("5"),bi_7:new s("7"),bi_10:new s("10"),bi_1e14:new s(String(1e14)),bi_1e16:new s(String(1e16)),bi_1e17:new s(String(1e17)),bi_1e32:new s("100000000000000000000000000000000"),bi_man_max_value:new s("9999999999999999"),bi_man_min_value:new s("1000000000000000"),bi_xns_max:new s("9000000000000000000"),bi_xns_min:new s("-9000000000000000000"),bi_xns_unit:new s("1000000"),cMinOffset:-96,cMaxOffset:80,max_value:"9999999999999999e80"};n(f,u),e.consts=u,f.text_full_rewrite=function(t){return f.from_json(t).to_text_full()},f.json_rewrite=function(t){return f.from_json(t).to_json()},f.from_number=function(t){return(new f).parse_number(t)},f.from_json=function(t){return(new f).parse_json(t)},f.from_quality=function(t,e,r,n){return(new f).parse_quality(t,e,r,n)},f.from_human=function(t,e){return(new f).parse_human(t,e)},f.is_valid=function(t){return f.from_json(t).is_valid()},f.is_valid_full=function(t){return f.from_json(t).is_valid_full()},f.NaN=function(){var t=new f;return t._value=NaN,t},f.prototype.abs=function(){return this.clone(this.is_negative())},f.prototype.add=function(t){var e;if(t=f.from_json(t),this.is_comparable(t))if(t.is_zero())e=this;else if(this.is_zero())(e=t.clone())._is_native=this._is_native,e._currency=this._currency,e._issuer=this._issuer;else if(this._is_native){e=new f;var r=this._is_negative?this._value.negate():this._value,n=t._is_negative?t._value.negate():t._value,i=r.add(n);e._is_negative=i.compareTo(s.ZERO)<0,e._value=e._is_negative?i.negate():i,e._currency=this._currency,e._issuer=this._issuer}else{r=this._is_negative?this._value.negate():this._value;for(var o=this._offset,a=(n=t._is_negative?t._value.negate():t._value,t._offset);o<a;)r=r.divide(f.bi_10),o+=1;for(;a<o;)n=n.divide(f.bi_10),a+=1;(e=new f)._is_native=!1,e._offset=o,e._value=r.add(n),e._is_negative=e._value.compareTo(s.ZERO)<0,e._is_negative&&(e._value=e._value.negate()),e._currency=this._currency,e._issuer=this._issuer,e.canonicalize()}else e=f.NaN();return e},f.prototype.subtract=function(t){return this.add(f.from_json(t).negate())},f.prototype.multiply=function(t){var e;if(t=f.from_json(t),this.is_zero())e=this;else if(t.is_zero())(e=this.clone())._value=s.ZERO;else{var r=this._value,n=this._offset,i=t._value,o=t._offset;if(this.is_native())for(;r.compareTo(f.bi_man_min_value)<0;)r=r.multiply(f.bi_10),n-=1;if(t.is_native())for(;i.compareTo(f.bi_man_min_value)<0;)i=i.multiply(f.bi_10),o-=1;(e=new f)._offset=n+o+14,e._value=r.multiply(i).divide(f.bi_1e14).add(f.bi_7),e._is_native=this._is_native,e._is_negative=this._is_negative!==t._is_negative,e._currency=this._currency,e._issuer=this._issuer,e.canonicalize()}return e},f.prototype.divide=function(t){var e;if((t=f.from_json(t)).is_zero())throw new Error("divide by zero");if(this.is_zero())e=this;else{if(!this.is_valid())throw new Error("Invalid dividend");if(!t.is_valid())throw new Error("Invalid divisor");var r=this;if(r.is_native())for(r=r.clone();r._value.compareTo(f.bi_man_min_value)<0;)r._value=r._value.multiply(f.bi_10),r._offset-=1;var n=t;if(n.is_native())for(n=n.clone();n._value.compareTo(f.bi_man_min_value)<0;)n._value=n._value.multiply(f.bi_10),n._offset-=1;(e=new f)._offset=r._offset-n._offset-17,e._value=r._value.multiply(f.bi_1e17).divide(n._value).add(f.bi_5),e._is_native=r._is_native,e._is_negative=r._is_negative!==n._is_negative,e._currency=r._currency,e._issuer=r._issuer,e.canonicalize()}return e},f.prototype.ratio_human=function(t,e){e=n({},e);var r=this;return t="number"==typeof t&&parseInt(t,10)===t?f.from_json(String(t)+".0"):f.from_json(t),t=f.from_json(t),r.is_valid()&&t.is_valid()?t.is_zero()?f.NaN():(e.reference_date&&(t=t.applyInterest(e.reference_date)),t._is_native&&((r=r.clone())._value=r._value.multiply(f.bi_xns_unit),r.canonicalize()),r.divide(t)):f.NaN()},f.prototype.product_human=function(t,e){if(e=e||{},t="number"==typeof t&&parseInt(t,10)===t?f.from_json(String(t)+".0"):f.from_json(t),!this.is_valid()||!t.is_valid())return f.NaN();e.reference_date&&(t=t.applyInterest(e.reference_date));var r=this.multiply(t);return t._is_native&&(r._value=r._value.divide(f.bi_xns_unit),r.canonicalize()),r},f.prototype._invert=function(){return this._value=f.bi_1e32.divide(this._value),this._offset=-32-this._offset,this.canonicalize(),this},f.prototype.invert=function(){return this.copy()._invert()},f.prototype.canonicalize=function(){if(this._value instanceof s)if(this._is_native)if(this._value.equals(s.ZERO))this._offset=0,this._is_negative=!1;else{for(;this._offset<0;)this._value=this._value.divide(f.bi_10),this._offset+=1;for(;0<this._offset;)this._value=this._value.multiply(f.bi_10),this._offset-=1}else if(this.is_zero())this._offset=-100,this._is_negative=!1;else{for(;this._value.compareTo(f.bi_man_min_value)<0;)this._value=this._value.multiply(f.bi_10),this._offset-=1;for(;0<this._value.compareTo(f.bi_man_max_value);)this._value=this._value.divide(f.bi_10),this._offset+=1}return this},f.prototype.clone=function(t){return this.copyTo(new f,t)},f.prototype.compareTo=function(t){var e;return t=f.from_json(t),this.is_comparable(t)?this._is_negative!==t._is_negative?e=this._is_negative?-1:1:this._value.equals(s.ZERO)?e=t._value.equals(s.ZERO)?0:-1:t._value.equals(s.ZERO)?e=1:!this._is_native&&this._offset>t._offset?e=this._is_negative?-1:1:!this._is_native&&this._offset<t._offset?e=this._is_negative?1:-1:0<(e=this._value.compareTo(t._value))?e=this._is_negative?-1:1:e<0&&(e=this._is_negative?1:-1):e=f.NaN(),e},f.prototype.copyTo=function(t,e){return"object"==typeof this._value?this._value.copyTo(t._value):t._value=this._value,t._offset=this._offset,t._is_native=this._is_native,t._is_negative=e?!this._is_negative:this._is_negative,t._currency=this._currency,t._issuer=this._issuer,t.is_zero()&&(t._is_negative=!1),t},f.prototype.currency=function(){return this._currency},f.prototype.equals=function(t,e){return"string"==typeof t?this.equals(f.from_json(t)):!!(this.is_valid()&&t.is_valid()&&this._is_native===t._is_native&&this._value.equals(t._value)&&this._offset===t._offset&&this._is_negative===t._is_negative&&(this._is_native||this._currency.equals(t._currency)&&(e||this._issuer.equals(t._issuer))))},f.prototype.is_comparable=function(t){return this._value instanceof s&&t._value instanceof s&&this._is_native===t._is_native},f.prototype.is_native=function(){return this._is_native},f.prototype.is_negative=function(){return this._value instanceof s&&this._is_negative},f.prototype.is_positive=function(){return!this.is_zero()&&!this.is_negative()},f.prototype.is_valid=function(){return this._value instanceof s},f.prototype.is_valid_full=function(){return this.is_valid()&&this._currency.is_valid()&&this._issuer.is_valid()},f.prototype.is_zero=function(){return this._value instanceof s&&this._value.equals(s.ZERO)},f.prototype.issuer=function(){return this._issuer},f.prototype.negate=function(){return this.clone("NEGATE")},f.prototype.invert=function(){var t=this.clone();return t._value=s.ONE,t._offset=0,t._is_negative=!1,t.canonicalize(),t.ratio_human(this)},f.human_RE_hex=/^\s*(-)?(\d+)(?:\.(\d*))?\s*([a-fA-F0-9]{40})\s*$/,f.human_RE=/^\s*([A-z]{3}|[0-9]{3})?\s*(-)?(\d+)(?:\.(\d*))?\s*([A-z]{3}|[0-9]{3})?\s*$/,f.prototype.parse_human=function(t,e){var r,n,i;e=e||{};var o=null,a=String(t).match(f.human_RE_hex);if(a&&5===a.length&&a[4]&&(r=a[2],n=a[3]||"",i=a[4],this._is_negative=Boolean(a[1])),void 0===r&&void 0===i){var c=String(t).match(f.human_RE);c&&(i=c[5]||c[1]||"STM",r=c[5]&&c[1]?c[1]+""+c[3]:c[3]||"0",n=c[4]||"",this._is_negative=Boolean(c[2]))}if(r){if(i=i.toUpperCase(),this._value=new s(r),this.set_currency(i),"STM"===i){for(n=n.slice(0,6);n.length<6;)n+="0";this._is_native=!0,this._value=this._value.multiply(f.bi_xns_unit).add(new s(n))}else{o=(n=n.replace(/0+$/,"")).length,this._is_native=!1;var u=f.bi_10.clone().pow(o);this._value=this._value.multiply(u).add(new s(n)),this._offset=-o,this.canonicalize()}if(e.reference_date&&this._currency.has_interest()){var h=this._currency.get_interest_at(e.reference_date),d=f.from_json(h+"/1/1");if(d.is_valid()){var l=this.divide(d);this._value=l._value,this._offset=l._offset}}}else this._value=NaN;return this},f.prototype.parse_issuer=function(t){return this._issuer=o.from_json(t),this},f.prototype.parse_quality=function(t,e,r,n){n=n||{};var i=c.from_json(n.base_currency);if(this._is_negative=!1,this._value=new s(t.substring(t.length-14),16),this._offset=parseInt(t.substring(t.length-16,t.length-14),16)-100,this._currency=c.from_json(e),this._issuer=o.from_json(r),this._is_native=this._currency.is_native(),!n.stm_as_drops&&i.is_valid()&&i.is_native()&&(n.inverse?this._offset-=6:this._offset+=6),n.inverse&&this._invert(),this.canonicalize(),n.reference_date&&i.is_valid()&&i.has_interest()){var a=i.get_interest_at(n.reference_date),u=f.from_json(a+"/1/1");if(u.is_valid()){var h=this.divide(u);this._value=h._value,this._offset=h._offset}}return this},f.prototype.parse_number=function(t){return this._is_native=!1,this._currency=c.from_json(1),this._issuer=o.from_json(1),this._is_negative=t<0,this._value=new s(String(this._is_negative?-t:t)),this._offset=0,this.canonicalize(),this},f.prototype.parse_json=function(t){switch(typeof t){case"string":var e=t.match(/^([^\/]+)\/([^\/]+)(?:\/(.+))?$/);e?(this._currency=c.from_json(e[2]),e[3]?this._issuer=o.from_json(e[3]):this._issuer=o.from_json("1"),this.parse_value(e[1])):(this.parse_native(t),this._currency=c.from_json("0"),this._issuer=o.from_json("0"));break;case"number":this.parse_json(String(t));break;case"object":if(null===t)break;t instanceof f?t.copyTo(this):t.hasOwnProperty("value")&&(this._currency.parse_json(t.currency,!0),"string"==typeof t.issuer&&this._issuer.parse_json(t.issuer),this.parse_value(t.value));break;default:this._value=NaN}return this},f.prototype.parse_native=function(t){var e;if("string"==typeof t&&(e=t.match(/^(-?)(\d*)(\.\d{0,6})?$/)),e){if(void 0===e[3])this._value=new s(e[2]);else{var r=new s(e[2]).multiply(f.bi_xns_unit),n=new s(e[3]).multiply(new s(String(Math.pow(10,1+f.xns_precision-e[3].length))));this._value=r.add(n)}this._is_native=!0,this._offset=0,this._is_negative=!!e[1]&&0!==this._value.compareTo(s.ZERO),0<this._value.compareTo(f.bi_xns_max)&&(this._value=NaN)}else this._value=NaN;return this},f.prototype.parse_value=function(t){switch(this._is_native=!1,typeof t){case"number":this._is_negative=t<0,this._value=new s(Math.abs(t)),this._offset=0,this.canonicalize();break;case"string":var e=t.match(/^(-?)(\d+)$/),r=!e&&t.match(/^(-?)(\d*)\.(\d*)$/),n=!n&&t.match(/^(-?)(\d*)e(-?\d+)$/);if(n)this._value=new s(n[2]),this._offset=parseInt(n[3]),this._is_negative=!!n[1],this.canonicalize();else if(r){var i=new s(r[2]),o=new s(r[3]),a=r[3].length;this._value=i.multiply(f.bi_10.clone().pow(a)).add(o),this._offset=-a,this._is_negative=!!r[1],this.canonicalize()}else e?(this._value=new s(e[2]),this._offset=0,this._is_negative=!!e[1],this.canonicalize()):this._value=NaN;break;default:this._value=t instanceof s?t:NaN}return this},f.prototype.set_currency=function(t){return this._currency=c.from_json(t),this._is_native=this._currency.is_native(),this},f.prototype.set_issuer=function(t){return this._issuer=t instanceof o?t:o.from_json(t),this},f.prototype.to_number=function(t){var e=this.to_text(t);return"string"==typeof e?Number(e):e},f.prototype.to_text=function(t){var e=NaN;if(this._is_native)this.is_valid()&&this._value.compareTo(f.bi_xns_max)<=0&&(e=this._value.toString());else if(this.is_zero())e="0";else if(this._offset&&(this._offset<-25||-4<this._offset))e=this._value.toString()+"e"+this._offset;else{var r="000000000000000000000000000"+this._value.toString()+"00000000000000000000000",n=r.substring(0,this._offset+43),i=r.substring(this._offset+43),s=n.match(/[1-9].*$/),o=i.match(/[1-9]0*$/);e=(s?s[0]:"0")+(o?"."+i.substring(0,1+i.length-o[0].length):"")}return!t&&"number"==typeof e&&isNaN(e)?e="0":this._is_negative&&(e="-"+e),e},f.prototype.applyInterest=function(t){if(!this._currency.has_interest())return this;var e=this._currency.get_interest_at(t),r=f.from_json(String(e)+"/1/1");return r.is_valid()?this.multiply(r):void 0},f.prototype.to_human=function(t){if(t=t||{},!this.is_valid())return"";void 0===t.signed&&(t.signed=!0),void 0===t.group_sep&&(t.group_sep=!0),t.group_width=t.group_width||3;var e=this;t.reference_date&&(e=this.applyInterest(t.reference_date));for(var r=e._is_native?f.xns_precision:-e._offset,n=f.bi_10.clone().pow(r),s=e._value.divide(n).toString(),o=e._value.mod(n).toString();o.length<r;)o="0"+o;if(s=s.replace(/^0*/,""),(o=o.replace(/0*$/,"")).length||!t.skip_empty_fraction){if("number"==typeof t.precision&&(0===t.precision&&53<=o.charCodeAt(0)&&(s=(Number(s)+1).toString()),o=o.slice(0,t.precision)),"number"==typeof t.max_sig_digits){var a=0==+s,c=a?0:s.length,u=(c+=(a?o.replace(/^0*/,""):o).length)-t.max_sig_digits;u=Math.max(u,0),0<(u=Math.min(u,o.length))&&(o=o.slice(0,-u))}if("number"==typeof t.min_precision)for(;o.length<t.min_precision;)o+="0"}t.group_sep&&("string"!=typeof t.group_sep&&(t.group_sep=","),s=i.chunkString(s,t.group_width,!0).join(t.group_sep));var h="";return t.signed&&this._is_negative&&("string"!=typeof t.signed&&(t.signed="-"),h+=t.signed),(h+=s.length?s:"0")+(o.length?"."+o:"")},f.prototype.to_human_full=function(t){t=t||{};var e=this.to_human(t),r=this._currency.to_human(),n=this._issuer.to_json(t),i=i=this.is_native()?e+"/"+r:e+"/"+r+"/"+n;return i},f.prototype.to_json=function(){var t;if(this._is_native)t=this.to_text();else{var e={value:this.to_text(),currency:this._currency.has_interest()?this._currency.to_hex():this._currency.to_json()};this._issuer.is_valid()&&(e.issuer=this._issuer.to_json()),t=e}return t},f.prototype.to_text_full=function(t){return this._value instanceof s?this._is_native?this.to_human()+"/STM":this.to_text()+"/"+this._currency.to_json()+"/"+this._issuer.to_json(t):NaN},f.prototype.not_equals_why=function(t,e){if("string"==typeof t)return this.not_equals_why(f.from_json(t));if(!(t instanceof f))return"Not an Amount";var r=!1;if(this.is_valid()&&t.is_valid())if(this._is_native!==t._is_native)r="Native mismatch.";else{var n=this._is_native?"STM":"Non-STM";this._value.equals(t._value)&&this._offset===t._offset?this._is_negative!==t._is_negative?r=n+" sign differs.":this._is_native||(this._currency.equals(t._currency)?e||this._issuer.equals(t._issuer)||(r="Non-STM issuer differs: "+t._issuer.to_json()+"/"+this._issuer.to_json()):r="Non-STM currency differs."):r=n+" value differs."}else r="Invalid amount.";return r},e.Amount=f,e.Currency=c,e.Seed=a,e.UInt160=o},function(t,e,r){"use strict";var n=r(10),i=r(12);function s(t){return(t>>>24|t>>>8&65280|t<<8&16711680|(255&t)<<24)>>>0}function o(t){return 1===t.length?"0"+t:t}function a(t){return 7===t.length?"0"+t:6===t.length?"00"+t:5===t.length?"000"+t:4===t.length?"0000"+t:3===t.length?"00000"+t:2===t.length?"000000"+t:1===t.length?"0000000"+t:t}e.inherits=i,e.toArray=function(t,e){if(Array.isArray(t))return t.slice();if(!t)return[];var r,n,i=[];if("string"==typeof t)if(e){if("hex"===e)for((t=t.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(t="0"+t),o=0;o<t.length;o+=2)i.push(parseInt(t[o]+t[o+1],16))}else for(var s=0,o=0;o<t.length;o++){var a=t.charCodeAt(o);a<128?i[s++]=a:a<2048?(i[s++]=a>>6|192,i[s++]=63&a|128):(n=o,55296!=(64512&(r=t).charCodeAt(n))||n<0||n+1>=r.length||56320!=(64512&r.charCodeAt(n+1))?i[s++]=a>>12|224:(a=65536+((1023&a)<<10)+(1023&t.charCodeAt(++o)),i[s++]=a>>18|240,i[s++]=a>>12&63|128),i[s++]=a>>6&63|128,i[s++]=63&a|128)}else for(o=0;o<t.length;o++)i[o]=0|t[o];return i},e.toHex=function(t){for(var e="",r=0;r<t.length;r++)e+=o(t[r].toString(16));return e},e.htonl=s,e.toHex32=function(t,e){for(var r="",n=0;n<t.length;n++){var i=t[n];"little"===e&&(i=s(i)),r+=a(i.toString(16))}return r},e.zero2=o,e.zero8=a,e.join32=function(t,e,r,i){var s=r-e;n(s%4==0);for(var o=new Array(s/4),a=0,c=e;a<o.length;a++,c+=4){var f;f="big"===i?t[c]<<24|t[c+1]<<16|t[c+2]<<8|t[c+3]:t[c+3]<<24|t[c+2]<<16|t[c+1]<<8|t[c],o[a]=f>>>0}return o},e.split32=function(t,e){for(var r=new Array(4*t.length),n=0,i=0;n<t.length;n++,i+=4){var s=t[n];"big"===e?(r[i]=s>>>24,r[i+1]=s>>>16&255,r[i+2]=s>>>8&255,r[i+3]=255&s):(r[i+3]=s>>>24,r[i+2]=s>>>16&255,r[i+1]=s>>>8&255,r[i]=255&s)}return r},e.rotr32=function(t,e){return t>>>e|t<<32-e},e.rotl32=function(t,e){return t<<e|t>>>32-e},e.sum32=function(t,e){return t+e>>>0},e.sum32_3=function(t,e,r){return t+e+r>>>0},e.sum32_4=function(t,e,r,n){return t+e+r+n>>>0},e.sum32_5=function(t,e,r,n,i){return t+e+r+n+i>>>0},e.sum64=function(t,e,r,n){var i=t[e],s=n+t[e+1]>>>0,o=(s<n?1:0)+r+i;t[e]=o>>>0,t[e+1]=s},e.sum64_hi=function(t,e,r,n){return(e+n>>>0<e?1:0)+t+r>>>0},e.sum64_lo=function(t,e,r,n){return e+n>>>0},e.sum64_4_hi=function(t,e,r,n,i,s,o,a){var c=0,f=e;return c+=(f=f+n>>>0)<e?1:0,c+=(f=f+s>>>0)<s?1:0,t+r+i+o+(c+=(f=f+a>>>0)<a?1:0)>>>0},e.sum64_4_lo=function(t,e,r,n,i,s,o,a){return e+n+s+a>>>0},e.sum64_5_hi=function(t,e,r,n,i,s,o,a,c,f){var u=0,h=e;return u+=(h=h+n>>>0)<e?1:0,u+=(h=h+s>>>0)<s?1:0,u+=(h=h+a>>>0)<a?1:0,t+r+i+o+c+(u+=(h=h+f>>>0)<f?1:0)>>>0},e.sum64_5_lo=function(t,e,r,n,i,s,o,a,c,f){return e+n+s+a+f>>>0},e.rotr64_hi=function(t,e,r){return(e<<32-r|t>>>r)>>>0},e.rotr64_lo=function(t,e,r){return(t<<32-r|e>>>r)>>>0},e.shr64_hi=function(t,e,r){return t>>>r},e.shr64_lo=function(t,e,r){return(t<<32-r|e>>>r)>>>0}},function(t,e,r){"use strict";var n,i="object"==typeof Reflect?Reflect:null,s=i&&"function"==typeof i.apply?i.apply:function(t,e,r){return Function.prototype.apply.call(t,e,r)};n=i&&"function"==typeof i.ownKeys?i.ownKeys:Object.getOwnPropertySymbols?function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:function(t){return Object.getOwnPropertyNames(t)};var o=Number.isNaN||function(t){return t!=t};function a(){a.init.call(this)}((t.exports=a).EventEmitter=a).prototype._events=void 0,a.prototype._eventsCount=0,a.prototype._maxListeners=void 0;var c=10;function f(t){return void 0===t._maxListeners?a.defaultMaxListeners:t._maxListeners}function u(t,e,r,n){var i,s,o;if("function"!=typeof r)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof r);if(void 0===(s=t._events)?(s=t._events=Object.create(null),t._eventsCount=0):(void 0!==s.newListener&&(t.emit("newListener",e,r.listener?r.listener:r),s=t._events),o=s[e]),void 0===o)o=s[e]=r,++t._eventsCount;else if("function"==typeof o?o=s[e]=n?[r,o]:[o,r]:n?o.unshift(r):o.push(r),0<(i=f(t))&&o.length>i&&!o.warned){o.warned=!0;var a=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");a.name="MaxListenersExceededWarning",a.emitter=t,a.type=e,a.count=o.length,console&&console.warn}return t}function h(t,e,r){var n={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},i=function(){for(var t=[],e=0;e<arguments.length;e++)t.push(arguments[e]);this.fired||(this.target.removeListener(this.type,this.wrapFn),this.fired=!0,s(this.listener,this.target,t))}.bind(n);return i.listener=r,n.wrapFn=i}function d(t,e,r){var n=t._events;if(void 0===n)return[];var i=n[e];return void 0===i?[]:"function"==typeof i?r?[i.listener||i]:[i]:r?function(t){for(var e=new Array(t.length),r=0;r<e.length;++r)e[r]=t[r].listener||t[r];return e}(i):p(i,i.length)}function l(t){var e=this._events;if(void 0!==e){var r=e[t];if("function"==typeof r)return 1;if(void 0!==r)return r.length}return 0}function p(t,e){for(var r=new Array(e),n=0;n<e;++n)r[n]=t[n];return r}Object.defineProperty(a,"defaultMaxListeners",{enumerable:!0,get:function(){return c},set:function(t){if("number"!=typeof t||t<0||o(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");c=t}}),a.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},a.prototype.setMaxListeners=function(t){if("number"!=typeof t||t<0||o(t))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+t+".");return this._maxListeners=t,this},a.prototype.getMaxListeners=function(){return f(this)},a.prototype.emit=function(t){for(var e=[],r=1;r<arguments.length;r++)e.push(arguments[r]);var n="error"===t,i=this._events;if(void 0!==i)n=n&&void 0===i.error;else if(!n)return!1;if(n){var o;if(0<e.length&&(o=e[0]),o instanceof Error)throw o;var a=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw a.context=o,a}var c=i[t];if(void 0===c)return!1;if("function"==typeof c)s(c,this,e);else{var f=c.length,u=p(c,f);for(r=0;r<f;++r)s(u[r],this,e)}return!0},a.prototype.on=a.prototype.addListener=function(t,e){return u(this,t,e,!1)},a.prototype.prependListener=function(t,e){return u(this,t,e,!0)},a.prototype.once=function(t,e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e);return this.on(t,h(this,t,e)),this},a.prototype.prependOnceListener=function(t,e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e);return this.prependListener(t,h(this,t,e)),this},a.prototype.off=a.prototype.removeListener=function(t,e){var r,n,i,s,o;if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e);if(void 0===(n=this._events))return this;if(void 0===(r=n[t]))return this;if(r===e||r.listener===e)0==--this._eventsCount?this._events=Object.create(null):(delete n[t],n.removeListener&&this.emit("removeListener",t,r.listener||e));else if("function"!=typeof r){for(i=-1,s=r.length-1;0<=s;s--)if(r[s]===e||r[s].listener===e){o=r[s].listener,i=s;break}if(i<0)return this;0===i?r.shift():function(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}(r,i),1===r.length&&(n[t]=r[0]),void 0!==n.removeListener&&this.emit("removeListener",t,o||e)}return this},a.prototype.removeAllListeners=function(t){var e,r,n;if(void 0===(r=this._events))return this;if(void 0===r.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==r[t]&&(0==--this._eventsCount?this._events=Object.create(null):delete r[t]),this;if(0===arguments.length){var i,s=Object.keys(r);for(n=0;n<s.length;++n)"removeListener"!==(i=s[n])&&this.removeAllListeners(i);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(e=r[t]))this.removeListener(t,e);else if(void 0!==e)for(n=e.length-1;0<=n;n--)this.removeListener(t,e[n]);return this},a.prototype.listeners=function(t){return d(this,t,!0)},a.prototype.rawListeners=function(t){return d(this,t,!1)},a.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):l.call(t,e)},a.prototype.listenerCount=l,a.prototype.eventNames=function(){return 0<this._eventsCount?n(this._events):[]}},function(t,e,r){var n=r(0).sjcl,i=r(0),s=r(1),o=i.jsbn.BigInteger,a={},c=a.alphabets={stream:"vpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1turAxyz",tipple:"VPShNAF39wBUDnEGHJKLM4pQrsT7RWXYZ2bcdeCg65jkm8ofqi1tuvaxyz",bitcoin:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"};function f(t){return n.codec.bytes.fromBits(n.hash.sha256.hash(n.codec.bytes.toBits(t)))}s(a,{VER_NONE:1,VER_NODE_PUBLIC:28,VER_NODE_PRIVATE:32,VER_ACCOUNT_ID:0,VER_ACCOUNT_PUBLIC:35,VER_ACCOUNT_PRIVATE:34,VER_FAMILY_GENERATOR:41,VER_FAMILY_SEED:33}),a.encode=function(t,e){for(var r=c[e||"stream"],n=new o(String(r.length)),i=new o,s=new o,a=new o(t),f=[];0<a.compareTo(o.ZERO);)a.divRemTo(n,i,s),i.copyTo(a),f.push(r[s.intValue()]);for(var u=0;u!==t.length&&!t[u];u+=1)f.push(r[0]);return f.reverse().join("")},a.decode=function(t,e){if("string"==typeof t){var r,n=c[e||"stream"],s=new o(String(n.length)),a=new o;for(r=0;r!==t.length&&t[r]===n[0];r+=1);for(;r!==t.length;r+=1){var f=n.indexOf(t[r]);if(f<0)return;var u=new o;u.fromInt(f),a=a.multiply(s).add(u)}for(var h=a.toByteArray().map(function(t){return t?t<0?256+t:t:0}),d=0;d!==h.length&&!h[d];)d+=1;d&&(h=h.slice(d));for(var l=0;l!==t.length&&t[l]===n[0];)l+=1;return[].concat(i.arraySet(l,0),h)}},a.verify_checksum=function(t){for(var e=function(t){return f(f(t))}(t.slice(0,-4)).slice(0,4),r=t.slice(-4),n=!0,i=0;i<4;i++)if(e[i]!==r[i]){n=!1;break}return n},a.encode_check=function(t,e,r){var n=[].concat(t,e),i=f(f(n)).slice(0,4);return a.encode([].concat(n,i),r)},a.decode_check=function(t,e,r){var n=a.decode(e,r);if(!n||n.length<5)return NaN;if("number"==typeof t&&n[0]!==t)return NaN;if(Array.isArray(t)){for(var i=!1,s=0,c=t.length;s<c;s++)i|=t[s]===n[0];if(!i)return NaN}return a.verify_checksum(n)?(n[0]=0,new o(n.slice(0,-4),256)):NaN},e.Base=a},function(t,e){(t.exports=function(t,e){if(!t)throw new Error(e||"Assertion failed")}).equal=function(t,e,r){if(t!=e)throw new Error(r||"Assertion failed: "+t+" != "+e)}},function(t,e,r){var n=e;n.utils=r(7),n.common=r(17),n.sha=r(95),n.ripemd=r(99),n.hmac=r(100),n.sha1=n.sha.sha1,n.sha256=n.sha.sha256,n.sha224=n.sha.sha224,n.sha384=n.sha.sha384,n.sha512=n.sha.sha512,n.ripemd160=n.ripemd.ripemd160},function(t,e){"function"==typeof Object.create?t.exports=function(t,e){t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}})}:t.exports=function(t,e){function r(){}t.super_=e,r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}},function(t,e,r){"use strict";(function(e){var n=r(63);
/*!
* The buffer module from node.js, for the browser.
*
* @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
* @license MIT
*/function i(t,e){if(t===e)return 0;for(var r=t.length,n=e.length,i=0,s=Math.min(r,n);i<s;++i)if(t[i]!==e[i]){r=t[i],n=e[i];break}return r<n?-1:n<r?1:0}function s(t){return e.Buffer&&"function"==typeof e.Buffer.isBuffer?e.Buffer.isBuffer(t):!(null==t||!t._isBuffer)}var o=r(5),a=Object.prototype.hasOwnProperty,c=Array.prototype.slice,f="foo"===function(){}.name;function u(t){return Object.prototype.toString.call(t)}function h(t){return!s(t)&&"function"==typeof e.ArrayBuffer&&("function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(t):!!t&&(t instanceof DataView||!!(t.buffer&&t.buffer instanceof ArrayBuffer)))}var d=t.exports=v,l=/\s*function\s+([^\(\s]*)\s*/;function p(t){if(o.isFunction(t)){if(f)return t.name;var e=t.toString().match(l);return e&&e[1]}}function b(t,e){return"string"==typeof t?t.length<e?t:t.slice(0,e):t}function _(t){if(f||!o.isFunction(t))return o.inspect(t);var e=p(t);return"[Function"+(e?": "+e:"")+"]"}function y(t,e,r,n,i){throw new d.AssertionError({message:r,actual:t,expected:e,operator:n,stackStartFunction:i})}function v(t,e){t||y(t,!0,e,"==",d.ok)}function m(t,e,r,n){if(t===e)return!0;if(s(t)&&s(e))return 0===i(t,e);if(o.isDate(t)&&o.isDate(e))return t.getTime()===e.getTime();if(o.isRegExp(t)&&o.isRegExp(e))return t.source===e.source&&t.global===e.global&&t.multiline===e.multiline&&t.lastIndex===e.lastIndex&&t.ignoreCase===e.ignoreCase;if(null!==t&&"object"==typeof t||null!==e&&"object"==typeof e){if(h(t)&&h(e)&&u(t)===u(e)&&!(t instanceof Float32Array||t instanceof Float64Array))return 0===i(new Uint8Array(t.buffer),new Uint8Array(e.buffer));if(s(t)!==s(e))return!1;var a=(n=n||{actual:[],expected:[]}).actual.indexOf(t);return-1!==a&&a===n.expected.indexOf(e)||(n.actual.push(t),n.expected.push(e),function(t,e,r,n){if(null==t||null==e)return!1;if(o.isPrimitive(t)||o.isPrimitive(e))return t===e;if(r&&Object.getPrototypeOf(t)!==Object.getPrototypeOf(e))return!1;var i=g(t),s=g(e);if(i&&!s||!i&&s)return!1;if(i)return m(t=c.call(t),e=c.call(e),r);var a,f,u=S(t),h=S(e);if(u.length!==h.length)return!1;for(u.sort(),h.sort(),f=u.length-1;0<=f;f--)if(u[f]!==h[f])return!1;for(f=u.length-1;0<=f;f--)if(!m(t[a=u[f]],e[a],r,n))return!1;return!0}(t,e,r,n))}return r?t===e:t==e}function g(t){return"[object Arguments]"==Object.prototype.toString.call(t)}function w(t,e){if(!t||!e)return!1;if("[object RegExp]"==Object.prototype.toString.call(e))return e.test(t);try{if(t instanceof e)return!0}catch(t){}return!Error.isPrototypeOf(e)&&!0===e.call({},t)}function A(t,e,r,n){var i;if("function"!=typeof e)throw new TypeError('"block" argument must be a function');"string"==typeof r&&(n=r,r=null),i=function(t){var e;try{t()}catch(t){e=t}return e}(e),n=(r&&r.name?" ("+r.name+").":".")+(n?" "+n:"."),t&&!i&&y(i,r,"Missing expected exception"+n);var s="string"==typeof n,a=!t&&i&&!r;if((!t&&o.isError(i)&&s&&w(i,r)||a)&&y(i,r,"Got unwanted exception"+n),t&&i&&r&&!w(i,r)||!t&&i)throw i}d.AssertionError=function(t){this.name="AssertionError",this.actual=t.actual,this.expected=t.expected,this.operator=t.operator,t.message?(this.message=t.message,this.generatedMessage=!1):(this.message=function(t){return b(_(t.actual),128)+" "+t.operator+" "+b(_(t.expected),128)}(this),this.generatedMessage=!0);var e=t.stackStartFunction||y;if(Error.captureStackTrace)Error.captureStackTrace(this,e);else{var r=new Error;if(r.stack){var n=r.stack,i=p(e),s=n.indexOf("\n"+i);if(0<=s){var o=n.indexOf("\n",s+1);n=n.substring(o+1)}this.stack=n}}},o.inherits(d.AssertionError,Error),d.fail=y,d.ok=v,d.equal=function(t,e,r){t!=e&&y(t,e,r,"==",d.equal)},d.notEqual=function(t,e,r){t==e&&y(t,e,r,"!=",d.notEqual)},d.deepEqual=function(t,e,r){m(t,e,!1)||y(t,e,r,"deepEqual",d.deepEqual)},d.deepStrictEqual=function(t,e,r){m(t,e,!0)||y(t,e,r,"deepStrictEqual",d.deepStrictEqual)},d.notDeepEqual=function(t,e,r){m(t,e,!1)&&y(t,e,r,"notDeepEqual",d.notDeepEqual)},d.notDeepStrictEqual=function t(e,r,n){m(e,r,!0)&&y(e,r,n,"notDeepStrictEqual",t)},d.strictEqual=function(t,e,r){t!==e&&y(t,e,r,"===",d.strictEqual)},d.notStrictEqual=function(t,e,r){t===e&&y(t,e,r,"!==",d.notStrictEqual)},d.throws=function(t,e,r){A(!0,t,e,r)},d.doesNotThrow=function(t,e,r){A(!1,t,e,r)},d.ifError=function(t){if(t)throw t},d.strict=n(function t(e,r){e||y(e,!0,r,"==",t)},d,{equal:d.strictEqual,deepEqual:d.deepStrictEqual,notEqual:d.notStrictEqual,notDeepEqual:d.notDeepStrictEqual}),d.strict.strict=d.strict;var S=Object.keys||function(t){var e=[];for(var r in t)a.call(t,r)&&e.push(r);return e}}).call(this,r(14))},function(t,e){var r;r=function(){return this}();try{r=r||new Function("return this")()}catch(t){"object"==typeof window&&(r=window)}t.exports=r},function(t,e,r){var n=r(0),i=r(1),s=r(19).UInt,o=i(function(){this._value=NaN},s);o.width=32,o.prototype=i({},s.prototype);var a=(o.prototype.constructor=o).HEX_ZERO="0000000000000000000000000000000000000000000000000000000000000000",c=o.HEX_ONE="0000000000000000000000000000000000000000000000000000000000000001";o.STR_ZERO=n.hexToString(a),o.STR_ONE=n.hexToString(c),e.UInt256=o},function(t,e,r){var n=r(8).EventEmitter,i=r(5),s=r(0),o=r(0).sjcl,a=r(6).Amount,c=r(6).Currency,f=r(6).UInt160,u=r(28).Seed,h=r(37).SerializedObject,d=r(22).StreamError,l=r(78),p=r(18);function b(t){n.call(this);var e=this;t=t||{},this.remote=t,this.tx_json={Flags:0},this._secret=void 0,this._build_path=!1,this._maxFee=this.remote.max_fee,this.state="unsubmitted",this.finalized=!1,this.previousSigningHash=void 0,this.submitIndex=void 0,this.canonical="object"!=typeof t||Boolean(t.canonical_signing),this.submittedIDs=[],this.once("success",function(t){e.finalize(t),e.setState("validated"),e.emit("cleanup",t)}),this.once("error",function(t){e.finalize(t),e.setState("failed"),e.emit("cleanup",t)}),this.once("submitted",function(){e.setState("submitted")}),this.once("proposed",function(){e.setState("pending")})}i.inherits(b,n),b.fee_units={default:10},b.flags={Universal:{FullyCanonicalSig:2147483648},AccountSet:{RequireDestTag:65536,OptionalDestTag:131072,RequireAuth:262144,OptionalAuth:524288,DisallowSTM:1048576,AllowSTM:2097152},TrustSet:{SetAuth:65536,NoStream:131072,SetNoStream:131072,ClearNoStream:262144,SetFreeze:1048576,ClearFreeze:2097152},OfferCreate:{Passive:65536,ImmediateOrCancel:131072,FillOrKill:262144,Sell:524288},Payment:{NoStreamDirect:65536,PartialPayment:131072,LimitQuality:262144}},b.set_clear_flags={AccountSet:{asfRequireDest:1,asfRequireAuth:2,asfDisallowSTM:3,asfDisableMaster:4,asfNoFreeze:6,asfGlobalFreeze:7}},b.MEMO_TYPES={},b.formats=r(30).tx,b.prototype.consts={telLOCAL_ERROR:-399,temMALFORMED:-299,tefFAILURE:-199,terRETRY:-99,tesSUCCESS:0,tecCLAIMED:100},b.from_json=function(t){return(new b).parseJson(t)},b.prototype.parseJson=function(t){return this.tx_json=t,this},b.prototype.isTelLocal=function(t){return t>=this.consts.telLOCAL_ERROR&&t<this.consts.temMALFORMED},b.prototype.isTemMalformed=function(t){return t>=this.consts.temMALFORMED&&t<this.consts.tefFAILURE},b.prototype.isTefFailure=function(t){return t>=this.consts.tefFAILURE&&t<this.consts.terRETRY},b.prototype.isTerRetry=function(t){return t>=this.consts.terRETRY&&t<this.consts.tesSUCCESS},b.prototype.isTepSuccess=function(t){return t>=this.consts.tesSUCCESS},b.prototype.isTecClaimed=function(t){return t>=this.consts.tecCLAIMED},b.prototype.isRejected=function(t){return this.isTelLocal(t)||this.isTemMalformed(t)||this.isTefFailure(t)},b.prototype.setState=function(t){this.state!==t&&(this.state=t,this.emit("state",t),this.emit("save"))},b.prototype.finalize=function(t){return this.finalized=!0,this.result?(this.result.ledger_index=t.ledger_index,this.result.ledger_hash=t.ledger_hash):(this.result=t,this.result.tx_json=this.tx_json),this},b.prototype._accountSecret=function(t){return this.remote.secrets[t]},b.prototype._getFeeUnits=b.prototype.feeUnits=function(){return b.fee_units.default},b.prototype._computeFee=function(){for(var t=this.remote._servers,e=[],r=0;r<t.length;r++){var n=t[r];n._connected&&e.push(Number(n._computeFee(this)))}switch(e.length){case 0:return;case 1:return String(e[0])}e.sort(function(t,e){return e<t?1:t<e?-1:0});var i=Math.floor(e.length/2),s=e.length%2==0?Math.floor(.5+(e[i]+e[i-1])/2):e[i];return String(s)},b.prototype.complete=function(){if(this.remote&&!this.remote.trusted&&!this.remote.local_signing)return this.emit("error",new d("tejServerUntrusted","Attempt to give secret to untrusted server")),!1;if(!this._secret&&!(this._secret=this._accountSecret(this.tx_json.Account)))return this.emit("error",new d("tejSecretUnknown","Missing secret")),!1;if(void 0===this.tx_json.SigningPubKey)try{var t=u.from_json(this._secret).get_key(this.tx_json.Account);this.tx_json.SigningPubKey=t.to_hex_pub()}catch(t){return this.emit("error",new d("tejSecretInvalid","Invalid secret")),!1}if(!this.remote||void 0!==this.tx_json.Fee||!this.remote.local_fee&&this.remote.trusted||(this.tx_json.Fee=this._computeFee()))return Number(this.tx_json.Fee)>this._maxFee?(this.emit("error",new d("tejMaxFeeExceeded","Max fee exceeded")),!1):(this.remote&&this.remote.local_signing&&this.canonical&&(this.tx_json.Flags|=b.flags.Universal.FullyCanonicalSig,this.tx_json.Flags=this.tx_json.Flags>>>0),this.tx_json);this.emit("error",new d("tejUnconnected"))},b.prototype.serialize=function(){return h.from_json(this.tx_json)},b.prototype.signingHash=function(){return this.hash(p.testnet?"HASH_TX_SIGN_TESTNET":"HASH_TX_SIGN")},b.prototype.hash=function(t,e){if("string"==typeof t){if(void 0===l[t])throw new Error("Unknown hashing prefix requested.");t=l[t]}else t=t||l.HASH_TX_ID;var r=h.from_json(this.tx_json).hash(t);return e?r:r.to_hex()},b.prototype.sign=function(t){t="function"==typeof t?t:function(){};var e=u.from_json(this._secret),r=this.tx_json.TxnSignature;delete this.tx_json.TxnSignature;var n=this.signingHash();if(r&&n===this.previousSigningHash)return this.tx_json.TxnSignature=r,t(),this;var i=e.get_key(this.tx_json.Account).sign(n,0),s=o.codec.hex.fromBits(i).toUpperCase();return this.tx_json.TxnSignature=s,this.previousSigningHash=n,t(),this},b.prototype.addId=function(t){-1===this.submittedIDs.indexOf(t)&&(this.submittedIDs.unshift(t),this.emit("signed",t),this.emit("save"))},b.prototype.findId=function(t){for(var e,r=0;r<this.submittedIDs.length&&!(e=t[this.submittedIDs[r]]);r++);return e},b.prototype.buildPath=function(t){return this._build_path=t,this},b.prototype.destinationTag=function(t){return void 0!==t&&(this.tx_json.DestinationTag=t),this},b.prototype.invoiceID=function(t){if("string"==typeof t){for(;t.length<64;)t+="0";this.tx_json.InvoiceID=t}return this},b.prototype.clientID=function(t){return"string"==typeof t&&(this._clientID=t),this},b.prototype.lastLedger=function(t){return"number"==typeof t&&isFinite(t)&&(this._setLastLedger=!0,this.tx_json.LastLedgerSequence=t),this},b._pathRewrite=function(t){if(Array.isArray(t))return t.map(function(t){var e={};return t.hasOwnProperty("account")&&(e.account=f.json_rewrite(t.account)),t.hasOwnProperty("issuer")&&(e.issuer=f.json_rewrite(t.issuer)),t.hasOwnProperty("currency")&&(e.currency=c.json_rewrite(t.currency)),t.hasOwnProperty("type_hex")&&(e.type_hex=t.type_hex),e})},b.prototype.pathAdd=function(t){return Array.isArray(t)&&(this.tx_json.Paths=this.tx_json.Paths||[],this.tx_json.Paths.push(b._pathRewrite(t))),this},b.prototype.paths=function(t){if(Array.isArray(t))for(var e=0,r=t.length;e<r;e++)this.pathAdd(t[e]);return this},b.prototype.secret=function(t){return this._secret=t,this},b.prototype.sendMax=function(t){return t&&(this.tx_json.SendMax=a.json_rewrite(t)),this},b.prototype.sourceTag=function(t){return t&&(this.tx_json.SourceTag=t),this},b.prototype.transferRate=function(t){if(this.tx_json.TransferRate=Number(t),this.tx_json.TransferRate<1e9)throw new Error("invalidTransferRate");return this},b.prototype.setFlags=function(t){if(void 0===t)return this;if("number"==typeof t)return this.tx_json.Flags=t,this;for(var e=Array.isArray(t)?t:Array.prototype.slice.call(arguments),r=b.flags[this.tx_json.TransactionType]||{},n=0,i=e.length;n<i;n++){var s=e[n];if(!r.hasOwnProperty(s))return this.emit("error",new d("tejInvalidFlag"));this.tx_json.Flags+=r[s]}return this},b.prototype.addMemo=function(t,e){if(!/(undefined|string)/.test(typeof t))throw new Error("MemoType must be a string");if(!/(undefined|string)/.test(typeof e))throw new Error("MemoData must be a string");function r(t){return o.codec.hex.fromBits(o.codec.utf8String.toBits(t))}var n={};return t&&(b.MEMO_TYPES[t]?n.MemoType=b.MEMO_TYPES[t]:n.MemoType=r(t)),e&&(n.MemoData=r(e)),this.tx_json.Memos=(this.tx_json.Memos||[]).concat({Memo:n}),this},b.prototype.accountSet=function(t,e,r){if("object"==typeof t){var n=t;t=n.source||n.from||n.account,e=n.set_flag||n.set,r=n.clear_flag||n.clear}if(!f.is_valid(t))throw new Error("Source address invalid");this.tx_json.TransactionType="AccountSet",this.tx_json.Account=f.json_rewrite(t);var i=b.set_clear_flags.AccountSet;function s(t){return"number"==typeof t?t:i[t]||i["asf"+t]}return(e=e&&s(e))&&(this.tx_json.SetFlag=e),(r=r&&s(r))&&(this.tx_json.ClearFlag=r),this},b.prototype.claim=function(t,e,r,n){if("object"==typeof t){var i=t;n=i.signature,r=i.public_key,e=i.generator,t=i.source||i.from||i.account}return this.tx_json.TransactionType="Claim",this.tx_json.Generator=e,this.tx_json.PublicKey=r,this.tx_json.Signature=n,this},b.prototype.offerCancel=function(t,e){if("object"==typeof t){var r=t;e=r.sequence,t=r.source||r.from||r.account}if(!f.is_valid(t))throw new Error("Source address invalid");return this.tx_json.TransactionType="OfferCancel",this.tx_json.Account=f.json_rewrite(t),this.tx_json.OfferSequence=Number(e),this},b.prototype.offerCreate=function(t,e,r,n,i){if("object"==typeof t){var o=t;i=o.cancel_sequence,n=o.expiration,r=o.taker_gets||o.sell,e=o.taker_pays||o.buy,t=o.source||o.from||o.account}if(!f.is_valid(t))throw new Error("Source address invalid");return this.tx_json.TransactionType="OfferCreate",this.tx_json.Account=f.json_rewrite(t),this.tx_json.TakerPays=a.json_rewrite(e),this.tx_json.TakerGets=a.json_rewrite(r),n&&(this.tx_json.Expiration=s.time.toStream(n)),i&&(this.tx_json.OfferSequence=Number(i)),this},b.prototype.setRegularKey=function(t,e){if("object"==typeof t){var r=t;t=r.address||r.account||r.from,e=r.regular_key}if(!f.is_valid(t))throw new Error("Source address invalid");if(!f.is_valid(e))throw new Error("RegularKey must be a valid Stream Address (a Hash160 of the public key)");return this.tx_json.TransactionType="SetRegularKey",this.tx_json.Account=f.json_rewrite(t),this.tx_json.RegularKey=f.json_rewrite(e),this},b.prototype.payment=function(t,e,r){if("object"==typeof t){var n=t;r=n.amount,e=n.destination||n.to,t=n.source||n.from||n.account}if(!f.is_valid(t))throw new Error("Payment source address invalid");if(!f.is_valid(e))throw new Error("Payment destination address invalid");return this.tx_json.TransactionType="Payment",this.tx_json.Account=f.json_rewrite(t),this.tx_json.Amount=a.json_rewrite(r),this.tx_json.Destination=f.json_rewrite(e),this},b.prototype.trustSet=b.prototype.streamLineSet=function(t,e,r,n){if("object"==typeof t){var i=t;n=i.quality_out,r=i.quality_in,e=i.limit,t=i.source||i.from||i.account}if(!f.is_valid(t))throw new Error("Source address invalid");return this.tx_json.TransactionType="TrustSet",this.tx_json.Account=f.json_rewrite(t),void 0!==e&&(this.tx_json.LimitAmount=a.json_rewrite(e)),r&&(this.tx_json.QualityIn=r),n&&(this.tx_json.QualityOut=n),this},b.prototype.submit=function(t){var e=this;this.callback="function"==typeof t?t:function(){},this._errorHandler=function(t,r){t instanceof d||(t=new d(t,r)),e.callback(t)},this._successHandler=function(t){e.callback(null,t)},this.on("error",function(){});var r=this.tx_json.Account;return f.is_valid(r)?(this.remote.account(r).submit(this),this):this.emit("error",new d("tejInvalidAccount","Account is missing or invalid"))},b.prototype.abort=function(t){t="function"==typeof t?t:function(){},this.finalized||(this.once("final",t),this.emit("abort"))},b.prototype.summary=function(){return b.summary.call(this)},b.summary=function(){var t={tx_json:this.tx_json,clientID:this._clientID,submittedIDs:this.submittedIDs,submissionAttempts:this.attempts,submitIndex:this.submitIndex,initialSubmitIndex:this.initialSubmitIndex,lastLedgerSequence:this.lastLedgerSequence,state:this.state,server:this._server?this._server._opts.url:void 0,finalized:this.finalized};return this.result&&(t.result={engine_result:this.result.engine_result,engine_result_message:this.result.engine_result_message,ledger_hash:this.result.ledger_hash,ledger_index:this.result.ledger_index,transaction_hash:this.result.tx_json.hash}),t},e.Transaction=b},function(t,e,r){"use strict";var n=r(7),i=r(10);function s(){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}(e.BlockHash=s).prototype.update=function(t,e){if(t=n.toArray(t,e),this.pending?this.pending=this.pending.concat(t):this.pending=t,this.pendingTotal+=t.length,this.pending.length>=this._delta8){var r=(t=this.pending).length%this._delta8;this.pending=t.slice(t.length-r,t.length),0===this.pending.length&&(this.pending=null),t=n.join32(t,0,t.length-r,this.endian);for(var i=0;i<t.length;i+=this._delta32)this._update(t,i,i+this._delta32)}return this},s.prototype.digest=function(t){return this.update(this._pad()),i(null===this.pending),this._digest(t)},s.prototype._pad=function(){var t=this.pendingTotal,e=this._delta8,r=e-(t+this.padLength)%e,n=new Array(r+this.padLength);n[0]=128;for(var i=1;i<r;i++)n[i]=0;if(t<<=3,"big"===this.endian){for(var s=8;s<this.padLength;s++)n[i++]=0;n[i++]=0,n[i++]=0,n[i++]=0,n[i++]=0,n[i++]=t>>>24&255,n[i++]=t>>>16&255,n[i++]=t>>>8&255,n[i++]=255&t}else for(n[i++]=255&t,n[i++]=t>>>8&255,n[i++]=t>>>16&255,n[i++]=t>>>24&255,n[i++]=0,n[i++]=0,n[i++]=0,n[i++]=0,s=8;s<this.padLength;s++)n[i++]=0;return n}},function(t,e,r){var n=r(1),i=t.exports={load:function(t){return n(i,t),i}}},function(t,e,r){function n(){this._value=NaN,this._update()}var i=r(0),s=i.sjcl,o=r(18),a=i.jsbn.BigInteger;n.json_rewrite=function(t,e){return this.from_json(t).to_json(e)},n.from_generic=function(t){return t instanceof this?t.clone():(new this).parse_generic(t)},n.from_hex=function(t){return t instanceof this?t.clone():(new this).parse_hex(t)},n.from_json=function(t){return t instanceof this?t.clone():(new this).parse_json(t)},n.from_bits=function(t){return t instanceof this?t.clone():(new this).parse_bits(t)},n.from_bytes=function(t){return t instanceof this?t.clone():(new this).parse_bytes(t)},n.from_bn=function(t){return t instanceof this?t.clone():(new this).parse_bn(t)},n.from_number=function(t){return t instanceof this?t.clone():(new this).parse_number(t)},n.is_valid=function(t){return this.from_json(t).is_valid()},n.prototype.clone=function(){return this.copyTo(new this.constructor)},n.prototype.copyTo=function(t){return t._value=this._value,"function"==typeof t._update&&t._update(),t},n.prototype.equals=function(t){return this._value instanceof a&&t._value instanceof a&&this._value.equals(t._value)},n.prototype.is_valid=function(){return this._value instanceof a},n.prototype.is_zero=function(){return this._value.equals(a.ZERO)},n.prototype._update=function(){},n.prototype.parse_generic=function(t){switch(o.accounts&&t in o.accounts&&(t=o.accounts[t].account),t){case void 0:case"0":case this.constructor.STR_ZERO:case this.constructor.ACCOUNT_ZERO:case this.constructor.HEX_ZERO:this._value=a.valueOf();break;case"1":case this.constructor.STR_ONE:case this.constructor.ACCOUNT_ONE:case this.constructor.HEX_ONE:this._value=new a([1]);break;default:"string"!=typeof t?this._value=NaN:this.constructor.width===t.length?this._value=new a(i.stringToArray(t),256):2*this.constructor.width===t.length?this._value=new a(t,16):this._value=NaN}return this._update(),this},n.prototype.parse_hex=function(t){return"string"==typeof t&&t.length===2*this.constructor.width?this._value=new a(t,16):this._value=NaN,this._update(),this},n.prototype.parse_bits=function(t){if(s.bitArray.bitLength(t)!==8*this.constructor.width)this._value=NaN;else{var e=s.codec.bytes.fromBits(t);this.parse_bytes(e)}return this._update(),this},n.prototype.parse_bytes=function(t){return Array.isArray(t)&&t.length===this.constructor.width?this._value=new a([0].concat(t),256):this._value=NaN,this._update(),this},n.prototype.parse_json=n.prototype.parse_hex,n.prototype.parse_bn=function(t){if(t instanceof s.bn&&t.bitLength()<=8*this.constructor.width){var e=s.codec.bytes.fromBits(t.toBits());this._value=new a(e,256)}else this._value=NaN;return this._update(),this},n.prototype.parse_number=function(t){return this._value=NaN,"number"==typeof t&&isFinite(t)&&0<=t&&(this._value=new a(String(t))),this._update(),this},n.prototype.to_bytes=function(){if(!(this._value instanceof a))return null;var t=this._value.toByteArray();t=t.map(function(t){return(t+256)%256});var e=this.constructor.width;for(t=t.slice(-e);t.length<e;)t.unshift(0);return t},n.prototype.to_json=n.prototype.to_hex=function(){if(!(this._value instanceof a))return null;var t=this.to_bytes();return s.codec.hex.fromBits(s.codec.bytes.toBits(t)).toUpperCase()},n.prototype.to_bits=function(){if(!(this._value instanceof a))return null;var t=this.to_bytes();return s.codec.bytes.toBits(t)},n.prototype.to_bn=function(){if(!(this._value instanceof a))return null;var t=this.to_bits();return s.bn.fromBits(t)},e.UInt=n},function(t,e,r){var n=r(5),i=r(34),s=r(8).EventEmitter,o=r(6).Amount,a=r(16).Transaction,c=r(23).internal.sub("server");function f(t,e){s.call(this);var r=this;if("string"==typeof e){var n=i.parse(e);e={host:n.hostname,port:n.port,secure:"ws:"!==n.protocol}}if("object"!=typeof e)throw new TypeError("Server configuration is not an Object");if(!f.domainRE.test(e.host))throw new Error('Server host is malformed, use "host" and "port" server configuration');if(!(e.port=Number(e.port)))throw new TypeError("Server port must be a number");if(e.port<1||65535<e.port)throw new TypeError('Server "port" must be an integer in range 1-65535');function o(){var t=r._checkActivity.bind(r);r._activityInterval=setInterval(t,1e3)}"boolean"!=typeof e.secure&&(e.secure=!0),this._remote=t,this._opts=e,this._ws=void 0,this._connected=!1,this._shouldConnect=!1,this._state="offline",this._id=0,this._retry=0,this._requests={},this._load_base=256,this._load_factor=256,this._fee=10,this._fee_ref=10,this._fee_base=10,this._reserve_base=void 0,this._reserve_inc=void 0,this._fee_cushion=this._remote.fee_cushion,this._lastLedgerIndex=NaN,this._lastLedgerClose=NaN,this._score=0,this._scoreWeights={ledgerclose:5,response:1},this._pubkey_node="",this._url=this._opts.url=(this._opts.secure?"wss://":"ws://")+this._opts.host+":"+this._opts.port,this.on("message",function(t){r._handleMessage(t)}),this.on("response_subscribe",function(t){r._handleResponseSubscribe(t)}),this.on("disconnect",function(){clearInterval(r._activityInterval),r.once("ledger_closed",o)}),this.once("ledger_closed",o),this._remote.on("ledger_closed",function(t){r._updateScore("ledgerclose",t)}),this.on("response_ping",function(t,e){r._updateScore("response",e)}),this.on("load_changed",function(t){r._updateScore("loadchange",t)}),this.on("connect",function(){if(!r._pubkey_node){r.on("response_server_info",function(t){try{r._pubkey_node=t.info.pubkey_node}catch(t){}});var t=r._remote.requestServerInfo();t.on("error",function(){}),r._request(t)}})}n.inherits(f,s),f.domainRE=/^(?=.{1,255}$)[0-9A-Za-z](?:(?:[0-9A-Za-z]|[-_]){0,61}[0-9A-Za-z])?(?:\.[0-9A-Za-z](?:(?:[0-9A-Za-z]|[-_]){0,61}[0-9A-Za-z])?)*\.?$/,f.onlineStates=["syncing","tracking","proposing","validating","full"],f.websocketConstructor=function(){return r(79)},f.prototype._setState=function(t){if(t!==this._state)switch(this._remote.trace&&c.info(this.getServerID(),"set_state:",t),this._state=t,this.emit("state",t),t){case"online":this._connected=!0,this._retry=0,this.emit("connect");break;case"offline":this._connected=!1,this.emit("disconnect")}},f.prototype._checkActivity=function(){if(this.isConnected()&&!isNaN(this._lastLedgerClose)){var t=Date.now()-this._lastLedgerClose;25e3<t&&(this._remote.trace&&c.info(this.getServerID(),"reconnect: activity delta:",t),this.reconnect())}},f.prototype._updateScore=function(t,e){if(this.isConnected()){var r=this._scoreWeights[t]||1;switch(t){case"ledgerclose":0<(n=e.ledger_index-this._lastLedgerIndex)&&(this._score+=r*n);break;case"response":var n=Math.floor((Date.now()-e.time)/200);this._score+=r*n;break;case"loadchange":this._fee=Number(this._computeFee(10))}1e3<this._score&&(this._remote.trace&&c.info(this.getServerID(),"reconnect: score:",this._score),this.reconnect())}},f.prototype.getRemoteAddress=f.prototype._remoteAddress=function(){var t;try{t=this._ws._socket.remoteAddress}catch(t){}return t},f.prototype.getHostID=f.prototype.getServerID=function(){return this._url+" ("+(this._pubkey_node?this._pubkey_node:"")+")"},f.prototype.disconnect=function(){var t=this;this.isConnected()?(this._lastLedgerIndex=NaN,this._lastLedgerClose=NaN,this._score=0,this._shouldConnect=!1,this._setState("offline"),this._ws&&this._ws.close()):this.once("socket_open",function(){t.disconnect()})},f.prototype.reconnect=function(){var t=this;function e(){t._shouldConnect=!0,t._retry=0,t.connect()}this._ws&&this._shouldConnect&&(this.isConnected()?(this.once("disconnect",e),this.disconnect()):e())},f.prototype.connect=function(){var t=this,e=f.websocketConstructor();if(!e)throw new Error("No websocket support detected!");if(!this.isConnected()){this._ws&&this._ws.close(),this._remote.trace&&c.info(this.getServerID(),"connect");var r=this._ws=new e(this._opts.url);this._shouldConnect=!0,t.emit("connecting"),r.onmessage=function(e){t.emit("message",e.data)},r.onopen=function(){r===t._ws&&(t.emit("socket_open"),t._request(t._remote._serverPrepareSubscribe(t)))},r.onerror=function(e){r===t._ws&&(t.emit("socket_error"),t._remote.trace&&c.info(t.getServerID(),"onerror:",e.data||e),t._handleClose())},r.onclose=function(){r===t._ws&&(t._remote.trace&&c.info(t.getServerID(),"onclose:",r.readyState),t._handleClose())}}},f.prototype._retryConnect=function(){var t=this;this._retry+=1;var e=this._retry<40?50:this._retry<100?1e3:this._retry<160?1e4:3e4;this._retryTimer=setTimeout(function(){t._shouldConnect&&(t._remote.trace&&c.info(t.getServerID(),"retry",t._retry),t.connect())},e)},f.prototype._handleClose=function(){var t=this._ws;t.onopen=t.onerror=t.onclose=t.onmessage=function(){},this.emit("socket_close"),this._setState("offline"),this._shouldConnect&&this._retryConnect()},f.prototype._handleMessage=function(t){try{t=JSON.parse(t)}catch(t){}if(f.isValidMessage(t))switch(t.type){case"ledgerClosed":this._handleLedgerClosed(t);break;case"serverStatus":this._handleServerStatus(t);break;case"response":this._handleResponse(t);break;case"path_find":this._handlePathFind(t)}else this.emit("unexpected",t)},f.prototype._handleLedgerClosed=function(t){this._lastLedgerIndex=t.ledger_index,this._lastLedgerClose=Date.now(),this.emit("ledger_closed",t)},f.prototype._handleServerStatus=function(t){var e=~f.onlineStates.indexOf(t.server_status);this._setState(e?"online":"offline"),f.isLoadStatus(t)&&(this.emit("load",t,this),this._remote.emit("load",t,this),t.load_base===this._load_base&&t.load_factor===this._load_factor||(this._load_base=t.load_base,this._load_factor=t.load_factor,this.emit("load_changed",t,this),this._remote.emit("load_changed",t,this)))},f.prototype._handleResponse=function(t){var e=this._requests[t.id];if(delete this._requests[t.id],e)if("success"===t.status){this._remote.trace&&c.info(this.getServerID(),"response:",t);var r=e.message.command,n=t.result,i="response_"+r;e.emit("success",n),[this,this._remote].forEach(function(r){r.emit(i,n,e,t)})}else t.error&&(this._remote.trace&&c.info(this.getServerID(),"error:",t),e.emit("error",{error:"remoteError",error_message:"Remote reported an error.",remote:t}));else this._remote.trace&&c.info(this.getServerID(),"UNEXPECTED:",t)},f.prototype._handlePathFind=function(t){this._remote.trace&&c.info(this.getServerID(),"path_find:",t)},f.prototype._handleResponseSubscribe=function(t){if(!this._remote._allow_partial_history&&!f.hasFullLedgerHistory(t))return this.reconnect();t.pubkey_node&&(this._pubkey_node=t.pubkey_node),f.isLoadStatus(t)&&(this._load_base=t.load_base||256,this._load_factor=t.load_factor||256,this._fee_ref=t.fee_ref||10,this._fee_base=t.fee_base||10,this._reserve_base=t.reserve_base,this._reserve_inc=t.reserve_inc),~f.onlineStates.indexOf(t.server_status)&&this._setState("online")},f.hasFullLedgerHistory=function(t){return"object"==typeof t&&"full"===t.server_status&&"string"==typeof t.validated_ledgers&&2===t.validated_ledgers.split("-").length},f.isValidMessage=function(t){return"object"==typeof t&&"string"==typeof t.type},f.isLoadStatus=function(t){return"object"==typeof t&&"number"==typeof t.load_base&&"number"==typeof t.load_factor},f.prototype._sendMessage=function(t){this._ws&&(this._remote.trace&&c.info(this.getServerID(),"request:",t),this._ws.send(JSON.stringify(t)))},f.prototype._request=function(t){var e=this;if(this._ws){t.server=this,t.message.id=this._id,t.time=Date.now(),this._requests[t.message.id]=t,this._id++;var r=1===this._ws.readyState,n=t&&"subscribe"===t.message.command;this.isConnected()||r&&n?i():this.once("connect",i)}else this._remote.trace&&c.info(this.getServerID(),"request: DROPPING:",t.message);function i(){e._sendMessage(t.message)}},f.prototype.isConnected=f.prototype._isConnected=function(){return this._connected},f.prototype._computeFee=function(t){var e;if(t instanceof a)e=t._getFeeUnits();else{if("number"!=typeof t)throw new Error("Invalid argument");e=t}return this._feeTx(e).to_json()},f.prototype._feeTx=function(t){var e=this._feeTxUnit();return o.from_json(String(Math.ceil(t*e)))},f.prototype._feeTxUnit=function(){var t=this._fee_base/this._fee_ref;return(t*=this._load_factor/this._load_base)*this._fee_cushion},f.prototype._reserve=function(t){var e=o.from_json(String(this._reserve_base)),r=o.from_json(String(this._reserve_inc)),n=t||0;if(n<0)throw new Error("Owner count must not be negative.");return e.add(r.product_human(n))},e.Server=f},function(t,e,r){var n=r(1),i=r(3).UInt160,s=r(0),o=r(69).Float,a=n(function(){this._value=NaN,this._update()},i);a.prototype=n({},i.prototype),(a.prototype.constructor=a).HEX_CURRENCY_BAD="00000000000000000000000053544D0000000000",a.prototype.human_RE=/^\s*([a-zA-Z0-9]{3})(\s*-\s*[- \w]+)?(\s*\(-?\d+\.?\d*%pa\))?\s*$/,a.from_json=function(t,e){return t instanceof this?t.clone():(new this).parse_json(t,e)},a.from_human=function(t,e){return(new a).parse_human(t,e)},a.prototype.parse_json=function(t,e){switch(this._value=NaN,typeof t){case"string":if(!t||/^(0|STM)$/.test(t)){e?this.parse_hex(a.HEX_CURRENCY_BAD):this.parse_hex(a.HEX_ZERO);break}var r=String(t).match(this.human_RE);if(r){var n=r[1],i=(r[3]||"").match(/(-?\d+\.?\d+)/);n=n.toUpperCase();var c=s.arraySet(20,0);if(i){c[0]=1,c[1]=255&n.charCodeAt(0),c[2]=255&n.charCodeAt(1),c[3]=255&n.charCodeAt(2),i=parseFloat(i[0]);for(var f=31536e3/Math.log(1+i/100),u=o.toIEEE754Double(f),h=0;h<=u.length;h++)c[8+h]=255&u[h]}else c[12]=255&n.charCodeAt(0),c[13]=255&n.charCodeAt(1),c[14]=255&n.charCodeAt(2);this.parse_bytes(c)}else this.parse_hex(t);break;case"number":isNaN(t)||this.parse_number(t);break;case"object":t instanceof a&&(this._value=t.copyTo({})._value,this._update())}return this},a.prototype.parse_human=function(t){return this.parse_json(t)},a.prototype._update=function(){var t=this.to_bytes(),e=!0;if(!t)return"STM";this._native=!1,this._type=-1,this._interest_start=NaN,this._interest_period=NaN,this._iso_code="";for(var r=0;r<20;r++)e=e&&(12===r||13===r||14===r||0===t[r]);e?(this._iso_code=String.fromCharCode(t[12])+String.fromCharCode(t[13])+String.fromCharCode(t[14]),"\0\0\0"===this._iso_code&&(this._native=!0,this._iso_code="STM"),this._type=0):1===t[0]&&(this._iso_code=String.fromCharCode(t[1])+String.fromCharCode(t[2])+String.fromCharCode(t[3]),this._type=1,this._interest_start=(t[4]<<24)+(t[5]<<16)+(t[6]<<8)+t[7],this._interest_period=o.fromIEEE754Double(t.slice(8,16)))},a.prototype.is_native=function(){return this._native},a.prototype.has_interest=function(){return 1===this._type&&!isNaN(this._interest_start)&&!isNaN(this._interest_period)},a.prototype.get_interest_at=function(t,e){return this.has_interest?((t=t||this._interest_start+31536e3)instanceof Date&&(t=s.fromTimestamp(t.getTime())),Math.exp((t-this._interest_start)/this._interest_period)):0},a.prototype.get_interest_percentage_at=function(t,e){var r=100*(r=this.get_interest_at(t,e))-100,n=e?Math.pow(10,e):100;return Math.round(r*n)/n},a.prototype.to_json=function(t){if(!this.is_valid())return"STM";var e,r=(t=t||{})&&t.full_name?" - "+t.full_name:"";if(t.force_hex||!/^[A-Z0-9]{3}$/.test(this._iso_code)||this.has_interest())if(!t.force_hex&&this.has_interest()){var n=t?t.decimals:void 0;e=this._iso_code+r+" ("+this.get_interest_percentage_at(this._interest_start+31536e3,n)+"%pa)"}else(e=this.to_hex())===a.HEX_ONE&&(e=1);else e=this._iso_code+r;return e},a.prototype.to_human=function(t){return this.to_json(t)},a.prototype.get_iso=function(){return this._iso_code},e.Currency=a},function(t,e,r){var n=r(5),i=r(1);function s(t,e){switch(typeof t){case"object":i(this,t);break;case"string":this.result=t,this.result_message=e}var r;this.engine_result=this.result=this.result||this.engine_result||this.error||"Error",this.engine_result_message=this.result_message=this.result_message||this.engine_result_message||this.error_message||"Error",this.result_message=this.message=this.result_message,Error.captureStackTrace?Error.captureStackTrace(this,t||this):(r=(new Error).stack)&&(this.stack=r)}n.inherits(s,Error),s.prototype.name="StreamError",e.StreamError=s},function(t,e){function r(t){t?Array.isArray(t)?this._namespace=t:this._namespace=[""+t]:this._namespace=[],this._prefix=this._namespace.concat([""]).join(": ")}r.prototype.sub=function(t){var e=this._namespace.slice();t&&"string"==typeof t&&e.push(t);var n=new r(e);return n._setParent(this),n},r.prototype._setParent=function(t){this._parent=t},r.makeLevel=function(t){return function(){var t=Array.prototype.slice.call(arguments);t[0]=this._prefix+t[0],r.engine.logObject.apply(r,t)}},r.prototype.debug=r.makeLevel(1),r.prototype.info=r.makeLevel(2),r.prototype.warn=r.makeLevel(3),r.prototype.error=r.makeLevel(4);var n={logObject:function(t){var e=Array.prototype.slice.call(arguments,1);(e=e.map(function(t){return JSON.stringify(t,null,2)})).unshift(t),e.unshift("["+(new Date).toISOString()+"]")}};r.engine={logObject:function(){}},console&&console.log&&(r.engine=n),t.exports=new r,t.exports.internal=t.exports.sub(),t.exports.Log=r},function(t,e,r){"use strict";var n=e;n.base=r(103),n.short=r(104),n.mont=r(105),n.edwards=r(106)},function(t,e,r){"use strict";var n=r(4),i=r(13);e.bytesToHex=function(t){return t.map(function(t){var e=t.toString(16).toUpperCase();return 1<e.length?e:"0"+e}).join("")},e.hexToBytes=function(t){return i(t.length%2==0),new n(t,16).toArray(null,t.length/2)}},function(t,e){t.exports=function(t){var e,r=t.sjcl,n=(e={stream:"vpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1turAxyz",bitcoin:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"},{encode_base:function(t,n){for(var i=e[n||"stream"],s=new r.bn(i.length),o=r.bn.fromBits(r.codec.bytes.toBits(t)),a=[];o.greaterEquals(s);){var c=o.mod(s);a.push(i[c.limbs[0]]),o=o.div(s)}a.push(i[o.limbs[0]]);for(var f=0;f!=t.length&&!t[f];f+=1)a.push(i[0]);return a.reverse().join("")},decode_base:function(t,n){for(var i,s=e[n||"stream"],o=new r.bn(s.length),a=new r.bn(0);i!=t.length&&t[i]===s[0];)i+=1;for(i=0;i!=t.length;i+=1){var c=s.indexOf(t[i]);if(c<0)return null;a=a.mul(o).addM(c)}for(var f=r.codec.bytes.fromBits(a.toBits()).reverse();0===f[f.length-1];)f.pop();for(i=0;t[i]===s[0];i++)f.push(0);return f.reverse(),f},encode_base_check:function(t,e,r){var s=[].concat(t,e),o=i(i(s)).slice(0,4);return n.encode_base([].concat(s,o),r)},decode_base_check:function(t,e,r){var s=n.decode_base(e,r);if(!s||s[0]!==t||s.length<5)return NaN;var o,a=i(i(s.slice(0,-4))).slice(0,4),c=s.slice(-4);for(o=0;4!=o;o+=1)if(a[o]!==c[o])return NaN;return s.slice(1,-4)}});function i(t){return r.codec.bytes.fromBits(r.hash.sha256.hash(r.codec.bytes.toBits(t)))}return n}},function(t,e){var r,n,i=t.exports={};function s(){throw new Error("setTimeout has not been defined")}function o(){throw new Error("clearTimeout has not been defined")}function a(t){if(r===setTimeout)return setTimeout(t,0);if((r===s||!r)&&setTimeout)return r=setTimeout,setTimeout(t,0);try{return r(t,0)}catch(e){try{return r.call(null,t,0)}catch(e){return r.call(this,t,0)}}}!function(){try{r="function"==typeof setTimeout?setTimeout:s}catch(t){r=s}try{n="function"==typeof clearTimeout?clearTimeout:o}catch(t){n=o}}();var c,f=[],u=!1,h=-1;function d(){u&&c&&(u=!1,c.length?f=c.concat(f):h=-1,f.length&&l())}function l(){if(!u){var t=a(d);u=!0;for(var e=f.length;e;){for(c=f,f=[];++h<e;)c&&c[h].run();h=-1,e=f.length}c=null,u=!1,function(t){if(n===clearTimeout)return clearTimeout(t);if((n===o||!n)&&clearTimeout)return n=clearTimeout,clearTimeout(t);try{n(t)}catch(e){try{return n.call(null,t)}catch(e){return n.call(this,t)}}}(t)}}function p(t,e){this.fun=t,this.array=e}function b(){}i.nextTick=function(t){var e=new Array(arguments.length-1);if(1<arguments.length)for(var r=1;r<arguments.length;r++)e[r-1]=arguments[r];f.push(new p(t,e)),1!==f.length||u||a(l)},p.prototype.run=function(){this.fun.apply(null,this.array)},i.title="browser",i.browser=!0,i.env={},i.argv=[],i.version="",i.versions={},i.on=b,i.addListener=b,i.once=b,i.off=b,i.removeListener=b,i.removeAllListeners=b,i.emit=b,i.prependListener=b,i.prependOnceListener=b,i.listeners=function(t){return[]},i.binding=function(t){throw new Error("process.binding is not supported")},i.cwd=function(){return"/"},i.chdir=function(t){throw new Error("process.chdir is not supported")},i.umask=function(){return 0}},function(t,e,r){var n=r(1),i=r(0),s=i.sjcl,o=i.jsbn.BigInteger,a=r(9).Base,c=r(19).UInt,f=(r(15).UInt256,r(3).UInt160),u=r(68).KeyPair,h=n(function(){this._curve=s.ecc.curves.c256,this._value=NaN},c);function d(t,e){return[].concat(t,e>>24,e>>16&255,e>>8&255,255&e)}function l(t){return s.bitArray.bitSlice(s.hash.sha512.hash(s.codec.bytes.toBits(t)),0,256)}h.width=16,h.prototype=n({},c.prototype),(h.prototype.constructor=h).prototype.parse_json=function(t){return"string"==typeof t&&t.length?"s"===t[0]?this._value=a.decode_check(a.VER_FAMILY_SEED,t):/^[0-9a-fA-f]{32}$/.test(t)?this.parse_hex(t):this.parse_passphrase(t):this._value=NaN,this},h.prototype.parse_passphrase=function(t){if("string"!=typeof t)throw new Error("Passphrase must be a string");var e=s.hash.sha512.hash(s.codec.utf8String.toBits(t)),r=s.bitArray.bitSlice(e,0,128);return this.parse_bits(r),this},h.prototype.to_json=function(){return this._value instanceof o?a.encode_check(a.VER_FAMILY_SEED,this.to_bytes()):NaN},h.prototype.get_key=function(t){var e,r,n,i=0;if(!this.is_valid())throw new Error("Cannot generate keys from invalid seed!");t&&("number"==typeof t?i=t:e=f.from_json(t));for(var o,a,c=this._curve,h=0;r=s.bn.fromBits(l(d(this.to_bytes(),h))),h++,!c.r.greaterEquals(r););n=c.G.mult(r);var p=1e3;do{for(h=0;o=s.bn.fromBits(l(d(d(n.toBytesCompressed(),i),h))),h++,!c.r.greaterEquals(o););if(i++,o=o.add(r).mod(c.r),a=u.from_bn_secret(o),--p<=0)throw new Error("Too many loops looking for KeyPair yielding "+e.to_json()+" from "+this.to_json())}while(e&&!a.get_address().equals(e));return a},e.Seed=h},function(t,e,r){!function(t){"use strict";var e="undefined"!=typeof Uint8Array?Uint8Array:Array,r="+".charCodeAt(0),n="/".charCodeAt(0),i="0".charCodeAt(0),s="a".charCodeAt(0),o="A".charCodeAt(0),a="-".charCodeAt(0),c="_".charCodeAt(0);function f(t){var e=t.charCodeAt(0);return e===r||e===a?62:e===n||e===c?63:e<i?-1:e<i+10?e-i+26+26:e<o+26?e-o:e<s+26?e-s+26:void 0}t.toByteArray=function(t){var r,n,i,s,o;if(0<t.length%4)throw new Error("Invalid string. Length must be a multiple of 4");var a=t.length;s="="===t.charAt(a-2)?2:"="===t.charAt(a-1)?1:0,o=new e(3*t.length/4-s),n=0<s?t.length-4:t.length;var c=0;function u(t){o[c++]=t}for(r=0;r<n;r+=4,3)u((16711680&(i=f(t.charAt(r))<<18|f(t.charAt(r+1))<<12|f(t.charAt(r+2))<<6|f(t.charAt(r+3))))>>16),u((65280&i)>>8),u(255&i);return 2==s?u(255&(i=f(t.charAt(r))<<2|f(t.charAt(r+1))>>4)):1==s&&(u((i=f(t.charAt(r))<<10|f(t.charAt(r+1))<<4|f(t.charAt(r+2))>>2)>>8&255),u(255&i)),o},t.fromByteArray=function(t){var e,r,n,i,s=t.length%3,o="";function a(t){return"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(t)}for(e=0,n=t.length-s;e<n;e+=3)o+=a((i=r=(t[e]<<16)+(t[e+1]<<8)+t[e+2])>>18&63)+a(i>>12&63)+a(i>>6&63)+a(63&i);switch(s){case 1:o+=a((r=t[t.length-1])>>2),o+=a(r<<4&63),o+="==";break;case 2:o+=a((r=(t[t.length-2]<<8)+t[t.length-1])>>10),o+=a(r>>4&63),o+=a(r<<2&63),o+="="}return o}}(e)},function(t,e){e.types=[void 0,"Int16","Int32","Int64","Hash128","Hash256","Amount","VL","Account",void 0,void 0,void 0,void 0,void 0,"Object","Array","Int8","Hash160","PathSet","Vector256"];var r=e.fields={1:{1:"LedgerEntryType",2:"TransactionType"},2:{2:"Flags",3:"SourceTag",4:"Sequence",5:"PreviousTxnLgrSeq",6:"LedgerSequence",7:"CloseTime",8:"ParentCloseTime",9:"SigningTime",10:"Expiration",11:"TransferRate",12:"WalletSize",13:"OwnerCount",14:"DestinationTag",16:"HighQualityIn",17:"HighQualityOut",18:"LowQualityIn",19:"LowQualityOut",20:"QualityIn",21:"QualityOut",22:"StampEscrow",23:"BondAmount",24:"LoadFee",25:"OfferSequence",26:"FirstLedgerSequence",27:"LastLedgerSequence",28:"TransactionIndex",29:"OperationLimit",30:"ReferenceFeeUnits",31:"ReserveBase",32:"ReserveIncrement",33:"SetFlag",34:"ClearFlag"},3:{1:"IndexNext",2:"IndexPrevious",3:"BookNode",4:"OwnerNode",5:"BaseFee",6:"ExchangeRate",7:"LowNode",8:"HighNode"},4:{1:"EmailHash"},5:{1:"LedgerHash",2:"ParentHash",3:"TransactionHash",4:"AccountHash",5:"PreviousTxnID",6:"LedgerIndex",7:"WalletLocator",8:"RootIndex",9:"AccountTxnID",16:"BookDirectory",17:"InvoiceID",18:"Nickname",19:"Feature"},6:{1:"Amount",2:"Balance",3:"LimitAmount",4:"TakerPays",5:"TakerGets",6:"LowLimit",7:"HighLimit",8:"Fee",9:"SendMax",16:"MinimumOffer",17:"StreamEscrow",18:"DeliveredAmount"},7:{1:"PublicKey",2:"MessageKey",3:"SigningPubKey",4:"TxnSignature",5:"Generator",6:"Signature",7:"Domain",8:"FundCode",9:"RemoveCode",10:"ExpireCode",11:"CreateCode",12:"MemoType",13:"MemoData"},8:{1:"Account",2:"Owner",3:"Destination",4:"Issuer",7:"Target",8:"RegularKey"},14:{1:void 0,2:"TransactionMetaData",3:"CreatedNode",4:"DeletedNode",5:"ModifiedNode",6:"PreviousFields",7:"FinalFields",8:"NewFields",9:"TemplateEntry",10:"Memo"},15:{1:void 0,2:"SigningAccounts",3:"TxnSignatures",4:"Signatures",5:"Template",6:"Necessary",7:"Sufficient",8:"AffectedNodes",9:"Memos"},16:{1:"CloseResolution",2:"TemplateEntryType",3:"TransactionResult"},17:{1:"TakerPaysCurrency",2:"TakerPaysIssuer",3:"TakerGetsCurrency",4:"TakerGetsIssuer"},18:{1:"Paths"},19:{1:"Indexes",2:"Hashes",3:"Features"}},n=e.fieldsInverseMap={};Object.keys(r).forEach(function(t){Object.keys(r[t]).forEach(function(e){n[r[t][e]]=[Number(t),Number(e)]})});var i=e.REQUIRED=0,s=e.OPTIONAL=1,o=e.DEFAULT=2,a=[["TransactionType",i],["Flags",s],["SourceTag",s],["LastLedgerSequence",s],["Account",i],["Sequence",i],["Fee",i],["OperationLimit",s],["SigningPubKey",i],["TxnSignature",s]];e.tx={AccountSet:[3].concat(a,[["EmailHash",s],["WalletLocator",s],["WalletSize",s],["MessageKey",s],["Domain",s],["TransferRate",s]]),TrustSet:[20].concat(a,[["LimitAmount",s],["QualityIn",s],["QualityOut",s]]),OfferCreate:[7].concat(a,[["TakerPays",i],["TakerGets",i],["Expiration",s]]),OfferCancel:[8].concat(a,[["OfferSequence",i]]),SetRegularKey:[5].concat(a,[["RegularKey",i]]),Payment:[0].concat(a,[["Destination",i],["Amount",i],["SendMax",s],["Paths",o],["InvoiceID",s],["DestinationTag",s]]),Contract:[9].concat(a,[["Expiration",i],["BondAmount",i],["StampEscrow",i],["StreamEscrow",i],["CreateCode",s],["FundCode",s],["RemoveCode",s],["ExpireCode",s]]),RemoveContract:[10].concat(a,[["Target",i]]),EnableFeature:[100].concat(a,[["Feature",i]]),SetFee:[101].concat(a,[["Features",i],["BaseFee",i],["ReferenceFeeUnits",i],["ReserveBase",i],["ReserveIncrement",i]])};var c=[["LedgerIndex",s],["LedgerEntryType",i],["Flags",i]];e.ledger={AccountRoot:[97].concat(c,[["Sequence",i],["PreviousTxnLgrSeq",i],["TransferRate",s],["WalletSize",s],["OwnerCount",i],["EmailHash",s],["PreviousTxnID",i],["AccountTxnID",s],["WalletLocator",s],["Balance",i],["MessageKey",s],["Domain",s],["Account",i],["RegularKey",s]]),Contract:[99].concat(c,[["PreviousTxnLgrSeq",i],["Expiration",i],["BondAmount",i],["PreviousTxnID",i],["Balance",i],["FundCode",s],["RemoveCode",s],["ExpireCode",s],["CreateCode",s],["Account",i],["Owner",i],["Issuer",i]]),DirectoryNode:[100].concat(c,[["IndexNext",s],["IndexPrevious",s],["ExchangeRate",s],["RootIndex",i],["Owner",s],["TakerPaysCurrency",s],["TakerPaysIssuer",s],["TakerGetsCurrency",s],["TakerGetsIssuer",s],["Indexes",i]]),EnabledFeatures:[102].concat(c,[["Features",i]]),FeeSettings:[115].concat(c,[["ReferenceFeeUnits",i],["ReserveBase",i],["ReserveIncrement",i],["BaseFee",i],["LedgerIndex",s]]),GeneratorMap:[103].concat(c,[["Generator",i]]),LedgerHashes:[104].concat(c,[["LedgerEntryType",i],["Flags",i],["FirstLedgerSequence",s],["LastLedgerSequence",s],["LedgerIndex",s],["Hashes",i]]),Nickname:[110].concat(c,[["LedgerEntryType",i],["Flags",i],["LedgerIndex",s],["MinimumOffer",s],["Account",i]]),Offer:[111].concat(c,[["LedgerEntryType",i],["Flags",i],["Sequence",i],["PreviousTxnLgrSeq",i],["Expiration",s],["BookNode",i],["OwnerNode",i],["PreviousTxnID",i],["LedgerIndex",s],["BookDirectory",i],["TakerPays",i],["TakerGets",i],["Account",i]]),VStreamState:[114].concat(c,[["LedgerEntryType",i],["Flags",i],["PreviousTxnLgrSeq",i],["HighQualityIn",s],["HighQualityOut",s],["LowQualityIn",s],["LowQualityOut",s],["LowNode",s],["HighNode",s],["PreviousTxnID",i],["LedgerIndex",s],["Balance",i],["LowLimit",i],["HighLimit",i]])},e.metadata=[["TransactionIndex",i],["TransactionResult",i],["AffectedNodes",i]],e.ter={tesSUCCESS:0,tecCLAIM:100,tecPATH_PARTIAL:101,tecUNFUNDED_ADD:102,tecUNFUNDED_OFFER:103,tecUNFUNDED_PAYMENT:104,tecFAILED_PROCESSING:105,tecDIR_FULL:121,tecINSUF_RESERVE_LINE:122,tecINSUF_RESERVE_OFFER:123,tecNO_DST:124,tecNO_DST_INSUF_STM:125,tecNO_LINE_INSUF_RESERVE:126,tecNO_LINE_REDUNDANT:127,tecPATH_DRY:128,tecUNFUNDED:129,tecMASTER_DISABLED:130,tecNO_REGULAR_KEY:131,tecOWNERS:132}},function(t,e,r){var n;!function(){"use strict";var i,s=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,o=Math.ceil,a=Math.floor,c="[BigNumber Error] ",f=c+"Number primitive has more than 15 significant digits: ",u=1e14,h=14,d=9007199254740991,l=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],p=1e7,b=1e9;function _(t){var e=0|t;return 0<t||t===e?e:e-1}function y(t){for(var e,r,n=1,i=t.length,s=t[0]+"";n<i;){for(e=t[n++]+"",r=h-e.length;r--;e="0"+e);s+=e}for(i=s.length;48===s.charCodeAt(--i););return s.slice(0,i+1||1)}function v(t,e){var r,n,i=t.c,s=e.c,o=t.s,a=e.s,c=t.e,f=e.e;if(!o||!a)return null;if(r=i&&!i[0],n=s&&!s[0],r||n)return r?n?0:-a:o;if(o!=a)return o;if(r=o<0,n=c==f,!i||!s)return n?0:!i^r?1:-1;if(!n)return f<c^r?1:-1;for(a=(c=i.length)<(f=s.length)?c:f,o=0;o<a;o++)if(i[o]!=s[o])return i[o]>s[o]^r?1:-1;return c==f?0:f<c^r?1:-1}function m(t,e,r,n){if(t<e||r<t||t!==a(t))throw Error(c+(n||"Argument")+("number"==typeof t?t<e||r<t?" out of range: ":" not an integer: ":" not a primitive number: ")+String(t))}function g(t){var e=t.c.length-1;return _(t.e/h)==e&&t.c[e]%2!=0}function w(t,e){return(1<t.length?t.charAt(0)+"."+t.slice(1):t)+(e<0?"e":"e+")+e}function A(t,e,r){var n,i;if(e<0){for(i=r+".";++e;i+=r);t=i+t}else if(++e>(n=t.length)){for(i=r,e-=n;--e;i+=r);t+=i}else e<n&&(t=t.slice(0,e)+"."+t.slice(e));return t}(i=function t(e){var r,n,i,S,E,x,T,j,k,I,O,R=V.prototype={constructor:V,toString:null,valueOf:null},M=new V(1),q=20,B=4,C=-7,N=21,P=-1e7,L=1e7,D=!1,F=1,z=0,U={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:" ",suffix:""},H="0123456789abcdefghijklmnopqrstuvwxyz";function V(t,e){var r,o,c,u,l,p,b,_,y=this;if(!(y instanceof V))return new V(t,e);if(null==e){if(t&&!0===t._isBigNumber)return y.s=t.s,void(!t.c||t.e>L?y.c=y.e=null:t.e<P?y.c=[y.e=0]:(y.e=t.e,y.c=t.c.slice()));if((p="number"==typeof t)&&0*t==0){if(y.s=1/t<0?(t=-t,-1):1,t===~~t){for(u=0,l=t;10<=l;l/=10,u++);return void(L<u?y.c=y.e=null:(y.e=u,y.c=[t]))}_=String(t)}else{if(!s.test(_=String(t)))return i(y,_,p);y.s=45==_.charCodeAt(0)?(_=_.slice(1),-1):1}-1<(u=_.indexOf("."))&&(_=_.replace(".","")),0<(l=_.search(/e/i))?(u<0&&(u=l),u+=+_.slice(l+1),_=_.substring(0,l)):u<0&&(u=_.length)}else{if(m(e,2,H.length,"Base"),10==e)return $(y=new V(t),q+y.e+1,B);if(_=String(t),p="number"==typeof t){if(0*t!=0)return i(y,_,p,e);if(y.s=1/t<0?(_=_.slice(1),-1):1,V.DEBUG&&15<_.replace(/^0\.0*|\./,"").length)throw Error(f+t)}else y.s=45===_.charCodeAt(0)?(_=_.slice(1),-1):1;for(r=H.slice(0,e),u=l=0,b=_.length;l<b;l++)if(r.indexOf(o=_.charAt(l))<0){if("."==o){if(u<l){u=b;continue}}else if(!c&&(_==_.toUpperCase()&&(_=_.toLowerCase())||_==_.toLowerCase()&&(_=_.toUpperCase()))){c=!0,l=-1,u=0;continue}return i(y,String(t),p,e)}p=!1,-1<(u=(_=n(_,e,10,y.s)).indexOf("."))?_=_.replace(".",""):u=_.length}for(l=0;48===_.charCodeAt(l);l++);for(b=_.length;48===_.charCodeAt(--b););if(_=_.slice(l,++b)){if(b-=l,p&&V.DEBUG&&15<b&&(d<t||t!==a(t)))throw Error(f+y.s*t);if((u=u-l-1)>L)y.c=y.e=null;else if(u<P)y.c=[y.e=0];else{if(y.e=u,y.c=[],l=(u+1)%h,u<0&&(l+=h),l<b){for(l&&y.c.push(+_.slice(0,l)),b-=h;l<b;)y.c.push(+_.slice(l,l+=h));l=h-(_=_.slice(l)).length}else l-=b;for(;l--;_+="0");y.c.push(+_)}}else y.c=[y.e=0]}function G(t,e,r,n){for(var i,s,o=[0],a=0,c=t.length;a<c;){for(s=o.length;s--;o[s]*=e);for(o[0]+=n.indexOf(t.charAt(a++)),i=0;i<o.length;i++)o[i]>r-1&&(null==o[i+1]&&(o[i+1]=0),o[i+1]+=o[i]/r|0,o[i]%=r)}return o.reverse()}function K(t,e,r){var n,i,s,o,a=0,c=t.length,f=e%p,u=e/p|0;for(t=t.slice();c--;)a=((i=f*(s=t[c]%p)+(n=u*s+(o=t[c]/p|0)*f)%p*p+a)/r|0)+(n/p|0)+u*o,t[c]=i%r;return a&&(t=[a].concat(t)),t}function X(t,e,r,n){var i,s;if(r!=n)s=n<r?1:-1;else for(i=s=0;i<r;i++)if(t[i]!=e[i]){s=t[i]>e[i]?1:-1;break}return s}function Y(t,e,r,n){for(var i=0;r--;)t[r]-=i,i=t[r]<e[r]?1:0,t[r]=i*n+t[r]-e[r];for(;!t[0]&&1<t.length;t.splice(0,1));}function J(t,e,r,n){var i,s,o,a,c;if(null==r?r=B:m(r,0,8),!t.c)return t.toString();if(i=t.c[0],o=t.e,null==e)c=y(t.c),c=1==n||2==n&&(o<=C||N<=o)?w(c,o):A(c,o,"0");else if(s=(t=$(new V(t),e,r)).e,a=(c=y(t.c)).length,1==n||2==n&&(e<=s||s<=C)){for(;a<e;c+="0",a++);c=w(c,s)}else if(e-=o,c=A(c,s,"0"),a<s+1){if(0<--e)for(c+=".";e--;c+="0");}else if(0<(e+=s-a))for(s+1==a&&(c+=".");e--;c+="0");return t.s<0&&i?"-"+c:c}function Z(t,e){for(var r,n=1,i=new V(t[0]);n<t.length;n++){if(!(r=new V(t[n])).s){i=r;break}e.call(i,r)&&(i=r)}return i}function W(t,e,r){for(var n=1,i=e.length;!e[--i];e.pop());for(i=e[0];10<=i;i/=10,n++);return(r=n+r*h-1)>L?t.c=t.e=null:r<P?t.c=[t.e=0]:(t.e=r,t.c=e),t}function $(t,e,r,n){var i,s,c,f,d,p,b,_=t.c,y=l;if(_){t:{for(i=1,f=_[0];10<=f;f/=10,i++);if((s=e-i)<0)s+=h,c=e,b=(d=_[p=0])/y[i-c-1]%10|0;else if((p=o((s+1)/h))>=_.length){if(!n)break t;for(;_.length<=p;_.push(0));d=b=0,c=(s%=h)-h+(i=1)}else{for(d=f=_[p],i=1;10<=f;f/=10,i++);b=(c=(s%=h)-h+i)<0?0:d/y[i-c-1]%10|0}if(n=n||e<0||null!=_[p+1]||(c<0?d:d%y[i-c-1]),n=r<4?(b||n)&&(0==r||r==(t.s<0?3:2)):5<b||5==b&&(4==r||n||6==r&&(0<s?0<c?d/y[i-c]:0:_[p-1])%10&1||r==(t.s<0?8:7)),e<1||!_[0])return _.length=0,n?(e-=t.e+1,_[0]=y[(h-e%h)%h],t.e=-e||0):_[0]=t.e=0,t;if(0==s?(_.length=p,f=1,p--):(_.length=p+1,f=y[h-s],_[p]=0<c?a(d/y[i-c]%y[c])*f:0),n)for(;;){if(0==p){for(s=1,c=_[0];10<=c;c/=10,s++);for(c=_[0]+=f,f=1;10<=c;c/=10,f++);s!=f&&(t.e++,_[0]==u&&(_[0]=1));break}if(_[p]+=f,_[p]!=u)break;_[p--]=0,f=1}for(s=_.length;0===_[--s];_.pop());}t.e>L?t.c=t.e=null:t.e<P&&(t.c=[t.e=0])}return t}function Q(t){var e,r=t.e;return null===r?t.toString():(e=y(t.c),e=r<=C||N<=r?w(e,r):A(e,r,"0"),t.s<0?"-"+e:e)}return V.clone=t,V.ROUND_UP=0,V.ROUND_DOWN=1,V.ROUND_CEIL=2,V.ROUND_FLOOR=3,V.ROUND_HALF_UP=4,V.ROUND_HALF_DOWN=5,V.ROUND_HALF_EVEN=6,V.ROUND_HALF_CEIL=7,V.ROUND_HALF_FLOOR=8,V.EUCLID=9,V.config=V.set=function(t){var e,r;if(null!=t){if("object"!=typeof t)throw Error(c+"Object expected: "+t);if(t.hasOwnProperty(e="DECIMAL_PLACES")&&(m(r=t[e],0,b,e),q=r),t.hasOwnProperty(e="ROUNDING_MODE")&&(m(r=t[e],0,8,e),B=r),t.hasOwnProperty(e="EXPONENTIAL_AT")&&((r=t[e])&&r.pop?(m(r[0],-b,0,e),m(r[1],0,b,e),C=r[0],N=r[1]):(m(r,-b,b,e),C=-(N=r<0?-r:r))),t.hasOwnProperty(e="RANGE"))if((r=t[e])&&r.pop)m(r[0],-b,-1,e),m(r[1],1,b,e),P=r[0],L=r[1];else{if(m(r,-b,b,e),!r)throw Error(c+e+" cannot be zero: "+r);P=-(L=r<0?-r:r)}if(t.hasOwnProperty(e="CRYPTO")){if((r=t[e])!==!!r)throw Error(c+e+" not true or false: "+r);if(r){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw D=!r,Error(c+"crypto unavailable");D=r}else D=r}if(t.hasOwnProperty(e="MODULO_MODE")&&(m(r=t[e],0,9,e),F=r),t.hasOwnProperty(e="POW_PRECISION")&&(m(r=t[e],0,b,e),z=r),t.hasOwnProperty(e="FORMAT")){if("object"!=typeof(r=t[e]))throw Error(c+e+" not an object: "+r);U=r}if(t.hasOwnProperty(e="ALPHABET")){if("string"!=typeof(r=t[e])||/^.$|[+-.\s]|(.).*\1/.test(r))throw Error(c+e+" invalid: "+r);H=r}}return{DECIMAL_PLACES:q,ROUNDING_MODE:B,EXPONENTIAL_AT:[C,N],RANGE:[P,L],CRYPTO:D,MODULO_MODE:F,POW_PRECISION:z,FORMAT:U,ALPHABET:H}},V.isBigNumber=function(t){if(!t||!0!==t._isBigNumber)return!1;if(!V.DEBUG)return!0;var e,r,n=t.c,i=t.e,s=t.s;t:if("[object Array]"=={}.toString.call(n)){if((1===s||-1===s)&&-b<=i&&i<=b&&i===a(i)){if(0===n[0]){if(0===i&&1===n.length)return!0;break t}if((e=(i+1)%h)<1&&(e+=h),String(n[0]).length==e){for(e=0;e<n.length;e++)if((r=n[e])<0||u<=r||r!==a(r))break t;if(0!==r)return!0}}}else if(null===n&&null===i&&(null===s||1===s||-1===s))return!0;throw Error(c+"Invalid BigNumber: "+t)},V.maximum=V.max=function(){return Z(arguments,R.lt)},V.minimum=V.min=function(){return Z(arguments,R.gt)},V.random=(S=9007199254740992,E=Math.random()*S&2097151?function(){return a(Math.random()*S)}:function(){return 8388608*(1073741824*Math.random()|0)+(8388608*Math.random()|0)},function(t){var e,r,n,i,s,f=0,u=[],d=new V(M);if(null==t?t=q:m(t,0,b),i=o(t/h),D)if(crypto.getRandomValues){for(e=crypto.getRandomValues(new Uint32Array(i*=2));f<i;)9e15<=(s=131072*e[f]+(e[f+1]>>>11))?(r=crypto.getRandomValues(new Uint32Array(2)),e[f]=r[0],e[f+1]=r[1]):(u.push(s%1e14),f+=2);f=i/2}else{if(!crypto.randomBytes)throw D=!1,Error(c+"crypto unavailable");for(e=crypto.randomBytes(i*=7);f<i;)9e15<=(s=281474976710656*(31&e[f])+1099511627776*e[f+1]+4294967296*e[f+2]+16777216*e[f+3]+(e[f+4]<<16)+(e[f+5]<<8)+e[f+6])?crypto.randomBytes(7).copy(e,f):(u.push(s%1e14),f+=7);f=i/7}if(!D)for(;f<i;)(s=E())<9e15&&(u[f++]=s%1e14);for(i=u[--f],t%=h,i&&t&&(s=l[h-t],u[f]=a(i/s)*s);0===u[f];u.pop(),f--);if(f<0)u=[n=0];else{for(n=-1;0===u[0];u.splice(0,1),n-=h);for(f=1,s=u[0];10<=s;s/=10,f++);f<h&&(n-=h-f)}return d.e=n,d.c=u,d}),V.sum=function(){for(var t=1,e=arguments,r=new V(e[0]);t<e.length;)r=r.plus(e[t++]);return r},x="0123456789",n=function(t,e,n,i,s){var o,a,c,f,u,h,d,l,p=t.indexOf("."),b=q,_=B;for(0<=p&&(f=z,z=0,t=t.replace(".",""),h=(l=new V(e)).pow(t.length-p),z=f,l.c=G(A(y(h.c),h.e,"0"),10,n,x),l.e=l.c.length),c=f=(d=G(t,e,n,s?(o=H,x):(o=x,H))).length;0==d[--f];d.pop());if(!d[0])return o.charAt(0);if(p<0?--c:(h.c=d,h.e=c,h.s=i,d=(h=r(h,l,b,_,n)).c,u=h.r,c=h.e),p=d[a=c+b+1],f=n/2,u=u||a<0||null!=d[a+1],u=_<4?(null!=p||u)&&(0==_||_==(h.s<0?3:2)):f<p||p==f&&(4==_||u||6==_&&1&d[a-1]||_==(h.s<0?8:7)),a<1||!d[0])t=u?A(o.charAt(1),-b,o.charAt(0)):o.charAt(0);else{if(d.length=a,u)for(--n;++d[--a]>n;)d[a]=0,a||(++c,d=[1].concat(d));for(f=d.length;!d[--f];);for(p=0,t="";p<=f;t+=o.charAt(d[p++]));t=A(t,c,o.charAt(0))}return t},r=function(t,e,r,n,i){var s,o,c,f,d,l,p,b,y,v,m,g,w,A,S,E,x,T=t.s==e.s?1:-1,j=t.c,k=e.c;if(!(j&&j[0]&&k&&k[0]))return new V(t.s&&e.s&&(j?!k||j[0]!=k[0]:k)?j&&0==j[0]||!k?0*T:T/0:NaN);for(y=(b=new V(T)).c=[],T=r+(o=t.e-e.e)+1,i||(i=u,o=_(t.e/h)-_(e.e/h),T=T/h|0),c=0;k[c]==(j[c]||0);c++);if(k[c]>(j[c]||0)&&o--,T<0)y.push(1),f=!0;else{for(A=j.length,E=k.length,T+=2,1<(d=a(i/(k[c=0]+1)))&&(k=K(k,d,i),j=K(j,d,i),E=k.length,A=j.length),w=E,m=(v=j.slice(0,E)).length;m<E;v[m++]=0);x=k.slice(),x=[0].concat(x),S=k[0],k[1]>=i/2&&S++;do{if(d=0,(s=X(k,v,E,m))<0){if(g=v[0],E!=m&&(g=g*i+(v[1]||0)),1<(d=a(g/S)))for(i<=d&&(d=i-1),p=(l=K(k,d,i)).length,m=v.length;1==X(l,v,p,m);)d--,Y(l,E<p?x:k,p,i),p=l.length,s=1;else 0==d&&(s=d=1),p=(l=k.slice()).length;if(p<m&&(l=[0].concat(l)),Y(v,l,m,i),m=v.length,-1==s)for(;X(k,v,E,m)<1;)d++,Y(v,E<m?x:k,m,i),m=v.length}else 0===s&&(d++,v=[0]);y[c++]=d,v[0]?v[m++]=j[w]||0:(v=[j[w]],m=1)}while((w++<A||null!=v[0])&&T--);f=null!=v[0],y[0]||y.splice(0,1)}if(i==u){for(c=1,T=y[0];10<=T;T/=10,c++);$(b,r+(b.e=c+o*h-1)+1,n,f)}else b.e=o,b.r=+f;return b},T=/^(-?)0([xbo])(?=\w[\w.]*$)/i,j=/^([^.]+)\.$/,k=/^\.([^.]+)$/,I=/^-?(Infinity|NaN)$/,O=/^\s*\+(?=[\w.])|^\s+|\s+$/g,i=function(t,e,r,n){var i,s=r?e:e.replace(O,"");if(I.test(s))t.s=isNaN(s)?null:s<0?-1:1;else{if(!r&&(s=s.replace(T,function(t,e,r){return i="x"==(r=r.toLowerCase())?16:"b"==r?2:8,n&&n!=i?t:e}),n&&(i=n,s=s.replace(j,"$1").replace(k,"0.$1")),e!=s))return new V(s,i);if(V.DEBUG)throw Error(c+"Not a"+(n?" base "+n:"")+" number: "+e);t.s=null}t.c=t.e=null},R.absoluteValue=R.abs=function(){var t=new V(this);return t.s<0&&(t.s=1),t},R.comparedTo=function(t,e){return v(this,new V(t,e))},R.decimalPlaces=R.dp=function(t,e){var r,n,i;if(null!=t)return m(t,0,b),null==e?e=B:m(e,0,8),$(new V(this),t+this.e+1,e);if(!(r=this.c))return null;if(n=((i=r.length-1)-_(this.e/h))*h,i=r[i])for(;i%10==0;i/=10,n--);return n<0&&(n=0),n},R.dividedBy=R.div=function(t,e){return r(this,new V(t,e),q,B)},R.dividedToIntegerBy=R.idiv=function(t,e){return r(this,new V(t,e),0,1)},R.exponentiatedBy=R.pow=function(t,e){var r,n,i,s,f,u,d,l,p=this;if((t=new V(t)).c&&!t.isInteger())throw Error(c+"Exponent not an integer: "+Q(t));if(null!=e&&(e=new V(e)),f=14<t.e,!p.c||!p.c[0]||1==p.c[0]&&!p.e&&1==p.c.length||!t.c||!t.c[0])return l=new V(Math.pow(+Q(p),f?2-g(t):+Q(t))),e?l.mod(e):l;if(u=t.s<0,e){if(e.c?!e.c[0]:!e.s)return new V(NaN);(n=!u&&p.isInteger()&&e.isInteger())&&(p=p.mod(e))}else{if(9<t.e&&(0<p.e||p.e<-1||(0==p.e?1<p.c[0]||f&&24e7<=p.c[1]:p.c[0]<8e13||f&&p.c[0]<=9999975e7)))return s=p.s<0&&g(t)?-0:0,-1<p.e&&(s=1/s),new V(u?1/s:s);z&&(s=o(z/h+2))}for(d=f?(r=new V(.5),u&&(t.s=1),g(t)):(i=Math.abs(+Q(t)))%2,l=new V(M);;){if(d){if(!(l=l.times(p)).c)break;s?l.c.length>s&&(l.c.length=s):n&&(l=l.mod(e))}if(i){if(0===(i=a(i/2)))break;d=i%2}else if($(t=t.times(r),t.e+1,1),14<t.e)d=g(t);else{if(0==(i=+Q(t)))break;d=i%2}p=p.times(p),s?p.c&&p.c.length>s&&(p.c.length=s):n&&(p=p.mod(e))}return n?l:(u&&(l=M.div(l)),e?l.mod(e):s?$(l,z,B,void 0):l)},R.integerValue=function(t){var e=new V(this);return null==t?t=B:m(t,0,8),$(e,e.e+1,t)},R.isEqualTo=R.eq=function(t,e){return 0===v(this,new V(t,e))},R.isFinite=function(){return!!this.c},R.isGreaterThan=R.gt=function(t,e){return 0<v(this,new V(t,e))},R.isGreaterThanOrEqualTo=R.gte=function(t,e){return 1===(e=v(this,new V(t,e)))||0===e},R.isInteger=function(){return!!this.c&&_(this.e/h)>this.c.length-2},R.isLessThan=R.lt=function(t,e){return v(this,new V(t,e))<0},R.isLessThanOrEqualTo=R.lte=function(t,e){return-1===(e=v(this,new V(t,e)))||0===e},R.isNaN=function(){return!this.s},R.isNegative=function(){return this.s<0},R.isPositive=function(){return 0<this.s},R.isZero=function(){return!!this.c&&0==this.c[0]},R.minus=function(t,e){var r,n,i,s,o=this,a=o.s;if(e=(t=new V(t,e)).s,!a||!e)return new V(NaN);if(a!=e)return t.s=-e,o.plus(t);var c=o.e/h,f=t.e/h,d=o.c,l=t.c;if(!c||!f){if(!d||!l)return d?(t.s=-e,t):new V(l?o:NaN);if(!d[0]||!l[0])return l[0]?(t.s=-e,t):new V(d[0]?o:3==B?-0:0)}if(c=_(c),f=_(f),d=d.slice(),a=c-f){for((i=(s=a<0)?(a=-a,d):(f=c,l)).reverse(),e=a;e--;i.push(0));i.reverse()}else for(n=(s=(a=d.length)<(e=l.length))?a:e,a=e=0;e<n;e++)if(d[e]!=l[e]){s=d[e]<l[e];break}if(s&&(i=d,d=l,l=i,t.s=-t.s),0<(e=(n=l.length)-(r=d.length)))for(;e--;d[r++]=0);for(e=u-1;a<n;){if(d[--n]<l[n]){for(r=n;r&&!d[--r];d[r]=e);--d[r],d[n]+=u}d[n]-=l[n]}for(;0==d[0];d.splice(0,1),--f);return d[0]?W(t,d,f):(t.s=3==B?-1:1,t.c=[t.e=0],t)},R.modulo=R.mod=function(t,e){var n,i,s=this;return t=new V(t,e),!s.c||!t.s||t.c&&!t.c[0]?new V(NaN):!t.c||s.c&&!s.c[0]?new V(s):(9==F?(i=t.s,t.s=1,n=r(s,t,0,3),t.s=i,n.s*=i):n=r(s,t,0,F),(t=s.minus(n.times(t))).c[0]||1!=F||(t.s=s.s),t)},R.multipliedBy=R.times=function(t,e){var r,n,i,s,o,a,c,f,d,l,b,y,v,m,g,w=this,A=w.c,S=(t=new V(t,e)).c;if(!(A&&S&&A[0]&&S[0]))return!w.s||!t.s||A&&!A[0]&&!S||S&&!S[0]&&!A?t.c=t.e=t.s=null:(t.s*=w.s,A&&S?(t.c=[0],t.e=0):t.c=t.e=null),t;for(n=_(w.e/h)+_(t.e/h),t.s*=w.s,(c=A.length)<(l=S.length)&&(v=A,A=S,S=v,i=c,c=l,l=i),i=c+l,v=[];i--;v.push(0));for(m=u,g=p,i=l;0<=--i;){for(r=0,b=S[i]%g,y=S[i]/g|0,s=i+(o=c);i<s;)r=((f=b*(f=A[--o]%g)+(a=y*f+(d=A[o]/g|0)*b)%g*g+v[s]+r)/m|0)+(a/g|0)+y*d,v[s--]=f%m;v[s]=r}return r?++n:v.splice(0,1),W(t,v,n)},R.negated=function(){var t=new V(this);return t.s=-t.s||null,t},R.plus=function(t,e){var r,n=this,i=n.s;if(e=(t=new V(t,e)).s,!i||!e)return new V(NaN);if(i!=e)return t.s=-e,n.minus(t);var s=n.e/h,o=t.e/h,a=n.c,c=t.c;if(!s||!o){if(!a||!c)return new V(i/0);if(!a[0]||!c[0])return c[0]?t:new V(a[0]?n:0*i)}if(s=_(s),o=_(o),a=a.slice(),i=s-o){for((r=0<i?(o=s,c):(i=-i,a)).reverse();i--;r.push(0));r.reverse()}for((i=a.length)-(e=c.length)<0&&(r=c,c=a,a=r,e=i),i=0;e;)i=(a[--e]=a[e]+c[e]+i)/u|0,a[e]=u===a[e]?0:a[e]%u;return i&&(a=[i].concat(a),++o),W(t,a,o)},R.precision=R.sd=function(t,e){var r,n,i;if(null!=t&&t!==!!t)return m(t,1,b),null==e?e=B:m(e,0,8),$(new V(this),t,e);if(!(r=this.c))return null;if(n=(i=r.length-1)*h+1,i=r[i]){for(;i%10==0;i/=10,n--);for(i=r[0];10<=i;i/=10,n++);}return t&&this.e+1>n&&(n=this.e+1),n},R.shiftedBy=function(t){return m(t,-d,d),this.times("1e"+t)},R.squareRoot=R.sqrt=function(){var t,e,n,i,s,o=this,a=o.c,c=o.s,f=o.e,u=q+4,h=new V("0.5");if(1!==c||!a||!a[0])return new V(!c||c<0&&(!a||a[0])?NaN:a?o:1/0);if((n=0==(c=Math.sqrt(+Q(o)))||c==1/0?(((e=y(a)).length+f)%2==0&&(e+="0"),c=Math.sqrt(+e),f=_((f+1)/2)-(f<0||f%2),new V(e=c==1/0?"1e"+f:(e=c.toExponential()).slice(0,e.indexOf("e")+1)+f)):new V(c+"")).c[0])for((c=(f=n.e)+u)<3&&(c=0);;)if(s=n,n=h.times(s.plus(r(o,s,u,1))),y(s.c).slice(0,c)===(e=y(n.c)).slice(0,c)){if(n.e<f&&--c,"9999"!=(e=e.slice(c-3,c+1))&&(i||"4999"!=e)){+e&&(+e.slice(1)||"5"!=e.charAt(0))||($(n,n.e+q+2,1),t=!n.times(n).eq(o));break}if(!i&&($(s,s.e+q+2,0),s.times(s).eq(o))){n=s;break}u+=4,c+=4,i=1}return $(n,n.e+q+1,B,t)},R.toExponential=function(t,e){return null!=t&&(m(t,0,b),t++),J(this,t,e,1)},R.toFixed=function(t,e){return null!=t&&(m(t,0,b),t=t+this.e+1),J(this,t,e)},R.toFormat=function(t,e,r){var n;if(null==r)null!=t&&e&&"object"==typeof e?(r=e,e=null):t&&"object"==typeof t?(r=t,t=e=null):r=U;else if("object"!=typeof r)throw Error(c+"Argument not an object: "+r);if(n=this.toFixed(t,e),this.c){var i,s=n.split("."),o=+r.groupSize,a=+r.secondaryGroupSize,f=r.groupSeparator||"",u=s[0],h=s[1],d=this.s<0,l=d?u.slice(1):u,p=l.length;if(a&&(i=o,o=a,p-=a=i),0<o&&0<p){for(i=p%o||o,u=l.substr(0,i);i<p;i+=o)u+=f+l.substr(i,o);0<a&&(u+=f+l.slice(i)),d&&(u="-"+u)}n=h?u+(r.decimalSeparator||"")+((a=+r.fractionGroupSize)?h.replace(new RegExp("\\d{"+a+"}\\B","g"),"$&"+(r.fractionGroupSeparator||"")):h):u}return(r.prefix||"")+n+(r.suffix||"")},R.toFraction=function(t){var e,n,i,s,o,a,f,u,d,p,b,_,v=this,m=v.c;if(null!=t&&(!(f=new V(t)).isInteger()&&(f.c||1!==f.s)||f.lt(M)))throw Error(c+"Argument "+(f.isInteger()?"out of range: ":"not an integer: ")+Q(f));if(!m)return new V(v);for(e=new V(M),d=n=new V(M),i=u=new V(M),_=y(m),o=e.e=_.length-v.e-1,e.c[0]=l[(a=o%h)<0?h+a:a],t=!t||0<f.comparedTo(e)?0<o?e:d:f,a=L,L=1/0,f=new V(_),u.c[0]=0;p=r(f,e,0,1),1!=(s=n.plus(p.times(i))).comparedTo(t);)n=i,i=s,d=u.plus(p.times(s=d)),u=s,e=f.minus(p.times(s=e)),f=s;return s=r(t.minus(n),i,0,1),u=u.plus(s.times(d)),n=n.plus(s.times(i)),u.s=d.s=v.s,b=r(d,i,o*=2,B).minus(v).abs().comparedTo(r(u,n,o,B).minus(v).abs())<1?[d,i]:[u,n],L=a,b},R.toNumber=function(){return+Q(this)},R.toPrecision=function(t,e){return null!=t&&m(t,1,b),J(this,t,e,2)},R.toString=function(t){var e,r=this,i=r.s,s=r.e;return null===s?i?(e="Infinity",i<0&&(e="-"+e)):e="NaN":(e=null==t?s<=C||N<=s?w(y(r.c),s):A(y(r.c),s,"0"):10===t?A(y((r=$(new V(r),q+s+1,B)).c),r.e,"0"):(m(t,2,H.length,"Base"),n(A(y(r.c),s,"0"),10,t,i,!0)),i<0&&r.c[0]&&(e="-"+e)),e},R.valueOf=R.toJSON=function(){return Q(this)},R._isBigNumber=!0,null!=e&&V.set(e),V}()).default=i.BigNumber=i,void 0===(n=function(){return i}.call(e,r,e,t))||(t.exports=n)}()},function(t,e,r){"use strict";function n(t){return!Number.isNaN(i.Base.decode_check(33,t))}Object.defineProperty(e,"__esModule",{value:!0});var i=r(9),s=r(3),o=r(55);e.isValidSecret=n,e.isValidAddress=function(t){return s.UInt160.is_valid(String(t))},e.createWallet=function(){return o.generate()},e.getAddress=function(t){return n(t)?new o(t).getAddress().value:null}},function(t,e,r){!function(){function e(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function r(){return 1}function n(t){if(!(this instanceof n))return new n(t);"number"==typeof t&&(t={max:t}),t=t||{},this._max=t.max,(!this._max||"number"!=typeof this._max||this._max<=0)&&(this._max=1/0),this._lengthCalculator=t.length||r,"function"!=typeof this._lengthCalculator&&(this._lengthCalculator=r),this._allowStale=t.stale||!1,this._maxAge=t.maxAge||null,this._dispose=t.dispose,this.reset()}function i(t,e,r){var n=t._cache[e];return n&&(t._maxAge&&Date.now()-n.now>t._maxAge?(a(t,n),t._allowStale||(n=void 0)):r&&function(t,e){o(t,e),e.lu=t._mru++,t._maxAge&&(e.now=Date.now()),t._lruList[e.lu]=e}(t,n),n=n&&n.value),n}function s(t){for(;t._lru<t._mru&&t._length>t._max;)a(t,t._lruList[t._lru])}function o(t,e){for(delete t._lruList[e.lu];t._lru<t._mru&&!t._lruList[t._lru];)t._lru++}function a(t,e){e&&(t._dispose&&t._dispose(e.key,e.value),t._length-=e.length,t._itemCount--,delete t._cache[e.key],o(t,e))}function c(t,e,r,n,i){this.key=t,this.value=e,this.lu=r,this.length=n,this.now=i}t.exports?t.exports=n:this.LRUCache=n,Object.defineProperty(n.prototype,"max",{set:function(t){(!t||"number"!=typeof t||t<=0)&&(t=1/0),this._max=t,this._length>this._max&&s(this)},get:function(){return this._max},enumerable:!0}),Object.defineProperty(n.prototype,"lengthCalculator",{set:function(t){if("function"!=typeof t)for(var e in this._lengthCalculator=r,this._length=this._itemCount,this._cache)this._cache[e].length=1;else for(var e in this._lengthCalculator=t,this._length=0,this._cache)this._cache[e].length=this._lengthCalculator(this._cache[e].value),this._length+=this._cache[e].length;this._length>this._max&&s(this)},get:function(){return this._lengthCalculator},enumerable:!0}),Object.defineProperty(n.prototype,"length",{get:function(){return this._length},enumerable:!0}),Object.defineProperty(n.prototype,"itemCount",{get:function(){return this._itemCount},enumerable:!0}),n.prototype.forEach=function(t,e){e=e||this;for(var r=0,n=this._mru-1;0<=n&&r<this._itemCount;n--)if(this._lruList[n]){r++;var i=this._lruList[n];this._maxAge&&Date.now()-i.now>this._maxAge&&(a(this,i),this._allowStale||(i=void 0)),i&&t.call(e,i.value,i.key,this)}},n.prototype.keys=function(){for(var t=new Array(this._itemCount),e=0,r=this._mru-1;0<=r&&e<this._itemCount;r--)if(this._lruList[r]){var n=this._lruList[r];t[e++]=n.key}return t},n.prototype.values=function(){for(var t=new Array(this._itemCount),e=0,r=this._mru-1;0<=r&&e<this._itemCount;r--)if(this._lruList[r]){var n=this._lruList[r];t[e++]=n.value}return t},n.prototype.reset=function(){if(this._dispose&&this._cache)for(var t in this._cache)this._dispose(t,this._cache[t].value);this._cache=Object.create(null),this._lruList=Object.create(null),this._mru=0,this._lru=0,this._length=0,this._itemCount=0},n.prototype.dump=function(){return this._cache},n.prototype.dumpLru=function(){return this._lruList},n.prototype.set=function(t,r){if(e(this._cache,t))return this._dispose&&this._dispose(t,this._cache[t].value),this._maxAge&&(this._cache[t].now=Date.now()),this._cache[t].value=r,this.get(t),!0;var n=this._lengthCalculator(r),i=this._maxAge?Date.now():0,o=new c(t,r,this._mru++,n,i);return o.length>this._max?(this._dispose&&this._dispose(t,r),!1):(this._length+=o.length,this._lruList[o.lu]=this._cache[t]=o,this._itemCount++,this._length>this._max&&s(this),!0)},n.prototype.has=function(t){if(!e(this._cache,t))return!1;var r=this._cache[t];return!(this._maxAge&&Date.now()-r.now>this._maxAge)},n.prototype.get=function(t){return i(this,t,!0)},n.prototype.peek=function(t){return i(this,t,!1)},n.prototype.pop=function(){var t=this._lruList[this._lru];return a(this,t),t||null},n.prototype.del=function(t){a(this,this._cache[t])}}()},function(t,e,r){"use strict";var n=r(64),i=r(65);function s(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null}e.parse=m,e.resolve=function(t,e){return m(t,!1,!0).resolve(e)},e.resolveObject=function(t,e){return t?m(t,!1,!0).resolveObject(e):e},e.format=function(t){return i.isString(t)&&(t=m(t)),t instanceof s?t.format():s.prototype.format.call(t)},e.Url=s;var o=/^([a-z0-9.+-]+:)/i,a=/:[0-9]*$/,c=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,f=["{","}","|","\\","^","`"].concat(["<",">",'"',"`"," ","\r","\n","\t"]),u=["'"].concat(f),h=["%","/","?",";","#"].concat(u),d=["/","?","#"],l=/^[+a-z0-9A-Z_-]{0,63}$/,p=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,b={javascript:!0,"javascript:":!0},_={javascript:!0,"javascript:":!0},y={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},v=r(36);function m(t,e,r){if(t&&i.isObject(t)&&t instanceof s)return t;var n=new s;return n.parse(t,e,r),n}s.prototype.parse=function(t,e,r){if(!i.isString(t))throw new TypeError("Parameter 'url' must be a string, not "+typeof t);var s=t.indexOf("?"),a=-1!==s&&s<t.indexOf("#")?"?":"#",f=t.split(a);f[0]=f[0].replace(/\\/g,"/");var m=t=f.join(a);if(m=m.trim(),!r&&1===t.split("#").length){var g=c.exec(m);if(g)return this.path=m,this.href=m,this.pathname=g[1],g[2]?(this.search=g[2],this.query=e?v.parse(this.search.substr(1)):this.search.substr(1)):e&&(this.search="",this.query={}),this}var w=o.exec(m);if(w){var A=(w=w[0]).toLowerCase();this.protocol=A,m=m.substr(w.length)}if(r||w||m.match(/^\/\/[^@\/]+@[^@\/]+/)){var S="//"===m.substr(0,2);!S||w&&_[w]||(m=m.substr(2),this.slashes=!0)}if(!_[w]&&(S||w&&!y[w])){for(var E,x,T=-1,j=0;j<d.length;j++)-1!==(k=m.indexOf(d[j]))&&(-1===T||k<T)&&(T=k);for(-1!==(x=-1===T?m.lastIndexOf("@"):m.lastIndexOf("@",T))&&(E=m.slice(0,x),m=m.slice(x+1),this.auth=decodeURIComponent(E)),T=-1,j=0;j<h.length;j++){var k;-1!==(k=m.indexOf(h[j]))&&(-1===T||k<T)&&(T=k)}-1===T&&(T=m.length),this.host=m.slice(0,T),m=m.slice(T),this.parseHost(),this.hostname=this.hostname||"";var I="["===this.hostname[0]&&"]"===this.hostname[this.hostname.length-1];if(!I)for(var O=this.hostname.split(/\./),R=(j=0,O.length);j<R;j++){var M=O[j];if(M&&!M.match(l)){for(var q="",B=0,C=M.length;B<C;B++)127<M.charCodeAt(B)?q+="x":q+=M[B];if(!q.match(l)){var N=O.slice(0,j),P=O.slice(j+1),L=M.match(p);L&&(N.push(L[1]),P.unshift(L[2])),P.length&&(m="/"+P.join(".")+m),this.hostname=N.join(".");break}}}255<this.hostname.length?this.hostname="":this.hostname=this.hostname.toLowerCase(),I||(this.hostname=n.toASCII(this.hostname));var D=this.port?":"+this.port:"",F=this.hostname||"";this.host=F+D,this.href+=this.host,I&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),"/"!==m[0]&&(m="/"+m))}if(!b[A])for(j=0,R=u.length;j<R;j++){var z=u[j];if(-1!==m.indexOf(z)){var U=encodeURIComponent(z);U===z&&(U=escape(z)),m=m.split(z).join(U)}}var H=m.indexOf("#");-1!==H&&(this.hash=m.substr(H),m=m.slice(0,H));var V=m.indexOf("?");if(-1!==V?(this.search=m.substr(V),this.query=m.substr(V+1),e&&(this.query=v.parse(this.query)),m=m.slice(0,V)):e&&(this.search="",this.query={}),m&&(this.pathname=m),y[A]&&this.hostname&&!this.pathname&&(this.pathname="/"),this.pathname||this.search){D=this.pathname||"";var G=this.search||"";this.path=D+G}return this.href=this.format(),this},s.prototype.format=function(){var t=this.auth||"";t&&(t=(t=encodeURIComponent(t)).replace(/%3A/i,":"),t+="@");var e=this.protocol||"",r=this.pathname||"",n=this.hash||"",s=!1,o="";this.host?s=t+this.host:this.hostname&&(s=t+(-1===this.hostname.indexOf(":")?this.hostname:"["+this.hostname+"]"),this.port&&(s+=":"+this.port)),this.query&&i.isObject(this.query)&&Object.keys(this.query).length&&(o=v.stringify(this.query));var a=this.search||o&&"?"+o||"";return e&&":"!==e.substr(-1)&&(e+=":"),this.slashes||(!e||y[e])&&!1!==s?(s="//"+(s||""),r&&"/"!==r.charAt(0)&&(r="/"+r)):s=s||"",n&&"#"!==n.charAt(0)&&(n="#"+n),a&&"?"!==a.charAt(0)&&(a="?"+a),e+s+(r=r.replace(/[?#]/g,function(t){return encodeURIComponent(t)}))+(a=a.replace("#","%23"))+n},s.prototype.resolve=function(t){return this.resolveObject(m(t,!1,!0)).format()},s.prototype.resolveObject=function(t){if(i.isString(t)){var e=new s;e.parse(t,!1,!0),t=e}for(var r=new s,n=Object.keys(this),o=0;o<n.length;o++){var a=n[o];r[a]=this[a]}if(r.hash=t.hash,""===t.href)return r.href=r.format(),r;if(t.slashes&&!t.protocol){for(var c=Object.keys(t),f=0;f<c.length;f++){var u=c[f];"protocol"!==u&&(r[u]=t[u])}return y[r.protocol]&&r.hostname&&!r.pathname&&(r.path=r.pathname="/"),r.href=r.format(),r}if(t.protocol&&t.protocol!==r.protocol){if(!y[t.protocol]){for(var h=Object.keys(t),d=0;d<h.length;d++){var l=h[d];r[l]=t[l]}return r.href=r.format(),r}if(r.protocol=t.protocol,t.host||_[t.protocol])r.pathname=t.pathname;else{for(var p=(t.pathname||"").split("/");p.length&&!(t.host=p.shift()););t.host||(t.host=""),t.hostname||(t.hostname=""),""!==p[0]&&p.unshift(""),p.length<2&&p.unshift(""),r.pathname=p.join("/")}if(r.search=t.search,r.query=t.query,r.host=t.host||"",r.auth=t.auth,r.hostname=t.hostname||t.host,r.port=t.port,r.pathname||r.search){var b=r.pathname||"",v=r.search||"";r.path=b+v}return r.slashes=r.slashes||t.slashes,r.href=r.format(),r}var m=r.pathname&&"/"===r.pathname.charAt(0),g=t.host||t.pathname&&"/"===t.pathname.charAt(0),w=g||m||r.host&&t.pathname,A=w,S=r.pathname&&r.pathname.split("/")||[],E=(p=t.pathname&&t.pathname.split("/")||[],r.protocol&&!y[r.protocol]);if(E&&(r.hostname="",r.port=null,r.host&&(""===S[0]?S[0]=r.host:S.unshift(r.host)),r.host="",t.protocol&&(t.hostname=null,t.port=null,t.host&&(""===p[0]?p[0]=t.host:p.unshift(t.host)),t.host=null),w=w&&(""===p[0]||""===S[0])),g)r.host=t.host||""===t.host?t.host:r.host,r.hostname=t.hostname||""===t.hostname?t.hostname:r.hostname,r.search=t.search,r.query=t.query,S=p;else if(p.length)(S=S||[]).pop(),S=S.concat(p),r.search=t.search,r.query=t.query;else if(!i.isNullOrUndefined(t.search))return E&&(r.hostname=r.host=S.shift(),(I=!!(r.host&&0<r.host.indexOf("@"))&&r.host.split("@"))&&(r.auth=I.shift(),r.host=r.hostname=I.shift())),r.search=t.search,r.query=t.query,i.isNull(r.pathname)&&i.isNull(r.search)||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.href=r.format(),r;if(!S.length)return r.pathname=null,r.search?r.path="/"+r.search:r.path=null,r.href=r.format(),r;for(var x=S.slice(-1)[0],T=(r.host||t.host||1<S.length)&&("."===x||".."===x)||""===x,j=0,k=S.length;0<=k;k--)"."===(x=S[k])?S.splice(k,1):".."===x?(S.splice(k,1),j++):j&&(S.splice(k,1),j--);if(!w&&!A)for(;j--;)S.unshift("..");!w||""===S[0]||S[0]&&"/"===S[0].charAt(0)||S.unshift(""),T&&"/"!==S.join("/").substr(-1)&&S.push("");var I,O=""===S[0]||S[0]&&"/"===S[0].charAt(0);return E&&(r.hostname=r.host=O?"":S.length?S.shift():"",(I=!!(r.host&&0<r.host.indexOf("@"))&&r.host.split("@"))&&(r.auth=I.shift(),r.host=r.hostname=I.shift())),(w=w||r.host&&S.length)&&!O&&S.unshift(""),S.length?r.pathname=S.join("/"):(r.pathname=null,r.path=null),i.isNull(r.pathname)&&i.isNull(r.search)||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.auth=t.auth||r.auth,r.slashes=r.slashes||t.slashes,r.href=r.format(),r},s.prototype.parseHost=function(){var t=this.host,e=a.exec(t);e&&(":"!==(e=e[0])&&(this.port=e.substr(1)),t=t.substr(0,t.length-e.length)),t&&(this.hostname=t)}},function(t,e){t.exports=function(t){return t.webpackPolyfill||(t.deprecate=function(){},t.paths=[],t.children||(t.children=[]),Object.defineProperty(t,"loaded",{enumerable:!0,get:function(){return t.l}}),Object.defineProperty(t,"id",{enumerable:!0,get:function(){return t.i}}),t.webpackPolyfill=1),t}},function(t,e,r){"use strict";e.decode=e.parse=r(66),e.encode=e.stringify=r(67)},function(t,e,r){(function(t){var n=r(13),i=r(1),s=r(30),o=r(72),a=(r(15).UInt256,r(74).Crypt),c=r(0),f=c.sjcl,u=c.jsbn.BigInteger,h={};Object.keys(s.tx).forEach(function(t){h[s.tx[t][0]]=t});var d={};Object.keys(s.ledger).forEach(function(t){d[s.ledger[t][0]]=t});var l={};function p(e){if(Array.isArray(e)||t&&t.isBuffer(e))this.buffer=e;else if("string"==typeof e)this.buffer=f.codec.bytes.fromBits(f.codec.hex.toBits(e));else{if(e)throw new Error("Invalid buffer passed.");this.buffer=[]}this.pointer=0}function b(t){return function(e){var r=this.pointer,n=r+e;if(n>this.buffer.length)throw new Error("Buffer length exceeded");var i=this.buffer.slice(r,n);return t&&(this.pointer=n),i}}Object.keys(s.ter).forEach(function(t){l[s.ter[t]]=t}),p.from_json=function(t){t=i({},t);var e,r=new p;if("number"==typeof t.TransactionType&&(t.TransactionType=p.lookup_type_tx(t.TransactionType),!t.TransactionType))throw new Error("Transaction type ID is invalid.");if("number"==typeof t.LedgerEntryType&&(t.LedgerEntryType=p.lookup_type_le(t.LedgerEntryType),!t.LedgerEntryType))throw new Error("LedgerEntryType ID is invalid.");if("string"==typeof t.TransactionType){if(e=s.tx[t.TransactionType],!Array.isArray(e))throw new Error("Transaction type is invalid");e=e.slice(),t.TransactionType=e.shift()}else if("string"==typeof t.LedgerEntryType){if(e=s.ledger[t.LedgerEntryType],!Array.isArray(e))throw new Error("LedgerEntryType is invalid");e=e.slice(),t.LedgerEntryType=e.shift()}else{if("object"!=typeof t.AffectedNodes)throw new Error("Object to be serialized must contain either TransactionType, LedgerEntryType or AffectedNodes.");e=s.metadata}return p.check_no_missing_fields(e,t),r.serialize(e,t),r},p.check_no_missing_fields=function(t,e){for(var r,n=[],i=t.length-1;0<=i;i--){var o=t[i],a=o[0],c=o[1];s.REQUIRED===c&&void 0===e[a]&&n.push(a)}if(0<n.length)throw r=void 0!==e.TransactionType?p.lookup_type_tx(e.TransactionType):null!=e.LedgerEntryType?p.lookup_type_le(e.LedgerEntryType):"TransactionMetaData",new Error(r+" is missing fields: "+JSON.stringify(n))},p.prototype.append=function(t){t instanceof p&&(t=t.buffer),this.buffer=this.buffer.concat(t),this.pointer+=t.length},p.prototype.resetPointer=function(){this.pointer=0},p.prototype.read=b(!0),p.prototype.peek=b(!1),p.prototype.to_bits=function(){return f.codec.bytes.toBits(this.buffer)},p.prototype.to_hex=function(){return f.codec.hex.fromBits(this.to_bits()).toUpperCase()},p.prototype.to_json=function(){var t=this.pointer;this.resetPointer();for(var e={};this.pointer<this.buffer.length;){var r=o.parse(this),n=r[0],i=r[1];e[n]=p.jsonify_structure(i,n)}return this.pointer=t,e},p.jsonify_structure=function(t,e){var r;switch(typeof t){case"number":switch(e){case"LedgerEntryType":r=d[t];break;case"TransactionResult":r=l[t];break;case"TransactionType":r=h[t];break;default:r=t}break;case"object":if(null===t)break;if("function"==typeof t.to_json)r=t.to_json();else if(t instanceof u)r=t.toString(16).toUpperCase();else{r=new t.constructor;for(var n=Object.keys(t),i=0,s=n.length;i<s;i++){var o=n[i];r[o]=p.jsonify_structure(t[o],o)}}break;default:r=t}return r},p.prototype.serialize=function(t,e){o.Object.serialize(this,e,!0)},p.prototype.signing_hash=p.prototype.hash=function(t){var e=new p;void 0!==t&&o.Int32.serialize(e,t),e.append(this.buffer);var r=f.codec.bytes.toBits(e.buffer);return a.hashSha512Half(r)},p.prototype.serialize_field=function(t,e){var r=t[0],n=t[1];if(t[2],o[t[3]],void 0!==e[r])try{o.serialize(this,r,e[r])}catch(t){throw t.message='Error serializing "'+r+'": '+t.message,t}else if(n===s.REQUIRED)throw new Error("Missing required field "+r)},p.get_field_header=function(t,e){var r=[0];return 15<t?r.push(255&t):r[0]+=(15&t)<<4,15<e?r.push(255&e):r[0]+=15&e,r},p.sort_typedef=function(t){return n(Array.isArray(t)),t.sort(function(t,e){return t[3]!==e[3]?o[t[3]].id-o[e[3]].id:t[2]-e[2]})},p.lookup_type_tx=function(t){return n.strictEqual(typeof t,"number"),h[t]},p.lookup_type_le=function(t){return n("number"==typeof t),d[t]},e.SerializedObject=p}).call(this,r(38).Buffer)},function(t,e,r){"use strict";(function(t){
/*!
* The buffer module from node.js, for the browser.
*
* @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
* @license MIT
*/
var n=r(29),i=r(70),s=r(71);function o(){return c.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function a(t,e){if(o()<e)throw new RangeError("Invalid typed array length");return c.TYPED_ARRAY_SUPPORT?(t=new Uint8Array(e)).__proto__=c.prototype:(null===t&&(t=new c(e)),t.length=e),t}function c(t,e,r){if(!(c.TYPED_ARRAY_SUPPORT||this instanceof c))return new c(t,e,r);if("number"!=typeof t)return f(this,t,e,r);if("string"==typeof e)throw new Error("If encoding is specified then the first argument must be a string");return h(this,t)}function f(t,e,r,n){if("number"==typeof e)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&e instanceof ArrayBuffer?function(t,e,r,n){if(e.byteLength,r<0||e.byteLength<r)throw new RangeError("'offset' is out of bounds");if(e.byteLength<r+(n||0))throw new RangeError("'length' is out of bounds");return e=void 0===r&&void 0===n?new Uint8Array(e):void 0===n?new Uint8Array(e,r):new Uint8Array(e,r,n),c.TYPED_ARRAY_SUPPORT?(t=e).__proto__=c.prototype:t=d(t,e),t}(t,e,r,n):"string"==typeof e?function(t,e,r){if("string"==typeof r&&""!==r||(r="utf8"),!c.isEncoding(r))throw new TypeError('"encoding" must be a valid string encoding');var n=0|p(e,r),i=(t=a(t,n)).write(e,r);return i!==n&&(t=t.slice(0,i)),t}(t,e,r):function(t,e){if(c.isBuffer(e)){var r=0|l(e.length);return 0===(t=a(t,r)).length||e.copy(t,0,0,r),t}if(e){if("undefined"!=typeof ArrayBuffer&&e.buffer instanceof ArrayBuffer||"length"in e)return"number"!=typeof e.length||function(t){return t!=t}(e.length)?a(t,0):d(t,e);if("Buffer"===e.type&&s(e.data))return d(t,e.data)}throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(t,e)}function u(t){if("number"!=typeof t)throw new TypeError('"size" argument must be a number');if(t<0)throw new RangeError('"size" argument must not be negative')}function h(t,e){if(u(e),t=a(t,e<0?0:0|l(e)),!c.TYPED_ARRAY_SUPPORT)for(var r=0;r<e;++r)t[r]=0;return t}function d(t,e){var r=e.length<0?0:0|l(e.length);t=a(t,r);for(var n=0;n<r;n+=1)t[n]=255&e[n];return t}function l(t){if(t>=o())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o().toString(16)+" bytes");return 0|t}function p(t,e){if(c.isBuffer(t))return t.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;"string"!=typeof t&&(t=""+t);var r=t.length;if(0===r)return 0;for(var n=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return N(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return P(t).length;default:if(n)return N(t).length;e=(""+e).toLowerCase(),n=!0}}function b(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function _(t,e,r,n,i){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):2147483647<r?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(i)return-1;r=t.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof e&&(e=c.from(e,n)),c.isBuffer(e))return 0===e.length?-1:y(t,e,r,n,i);if("number"==typeof e)return e&=255,c.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):y(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function y(t,e,r,n,i){var s,o=1,a=t.length,c=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;a/=o=2,c/=2,r/=2}function f(t,e){return 1===o?t[e]:t.readUInt16BE(e*o)}if(i){var u=-1;for(s=r;s<a;s++)if(f(t,s)===f(e,-1===u?0:s-u)){if(-1===u&&(u=s),s-u+1===c)return u*o}else-1!==u&&(s-=s-u),u=-1}else for(a<r+c&&(r=a-c),s=r;0<=s;s--){for(var h=!0,d=0;d<c;d++)if(f(t,s+d)!==f(e,d)){h=!1;break}if(h)return s}return-1}function v(t,e,r,n){r=Number(r)||0;var i=t.length-r;n?i<(n=Number(n))&&(n=i):n=i;var s=e.length;if(s%2!=0)throw new TypeError("Invalid hex string");s/2<n&&(n=s/2);for(var o=0;o<n;++o){var a=parseInt(e.substr(2*o,2),16);if(isNaN(a))return o;t[r+o]=a}return o}function m(t,e,r,n){return L(function(t){for(var e=[],r=0;r<t.length;++r)e.push(255&t.charCodeAt(r));return e}(e),t,r,n)}function g(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function w(t,e,r){r=Math.min(t.length,r);for(var n=[],i=e;i<r;){var s,o,a,c,f=t[i],u=null,h=239<f?4:223<f?3:191<f?2:1;if(i+h<=r)switch(h){case 1:f<128&&(u=f);break;case 2:128==(192&(s=t[i+1]))&&127<(c=(31&f)<<6|63&s)&&(u=c);break;case 3:s=t[i+1],o=t[i+2],128==(192&s)&&128==(192&o)&&2047<(c=(15&f)<<12|(63&s)<<6|63&o)&&(c<55296||57343<c)&&(u=c);break;case 4:s=t[i+1],o=t[i+2],a=t[i+3],128==(192&s)&&128==(192&o)&&128==(192&a)&&65535<(c=(15&f)<<18|(63&s)<<12|(63&o)<<6|63&a)&&c<1114112&&(u=c)}null===u?(u=65533,h=1):65535<u&&(u-=65536,n.push(u>>>10&1023|55296),u=56320|1023&u),n.push(u),i+=h}return function(t){var e=t.length;if(e<=A)return String.fromCharCode.apply(String,t);for(var r="",n=0;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=A));return r}(n)}e.Buffer=c,e.SlowBuffer=function(t){return+t!=t&&(t=0),c.alloc(+t)},e.INSPECT_MAX_BYTES=50,c.TYPED_ARRAY_SUPPORT=void 0!==t.TYPED_ARRAY_SUPPORT?t.TYPED_ARRAY_SUPPORT:function(){try{var t=new Uint8Array(1);return t.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===t.foo()&&"function"==typeof t.subarray&&0===t.subarray(1,1).byteLength}catch(t){return!1}}(),e.kMaxLength=o(),c.poolSize=8192,c._augment=function(t){return t.__proto__=c.prototype,t},c.from=function(t,e,r){return f(null,t,e,r)},c.TYPED_ARRAY_SUPPORT&&(c.prototype.__proto__=Uint8Array.prototype,c.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&c[Symbol.species]===c&&Object.defineProperty(c,Symbol.species,{value:null,configurable:!0})),c.alloc=function(t,e,r){return function(t,e,r,n){return u(e),e<=0?a(t,e):void 0!==r?"string"==typeof n?a(t,e).fill(r,n):a(t,e).fill(r):a(t,e)}(null,t,e,r)},c.allocUnsafe=function(t){return h(null,t)},c.allocUnsafeSlow=function(t){return h(null,t)},c.isBuffer=function(t){return!(null==t||!t._isBuffer)},c.compare=function(t,e){if(!c.isBuffer(t)||!c.isBuffer(e))throw new TypeError("Arguments must be Buffers");if(t===e)return 0;for(var r=t.length,n=e.length,i=0,s=Math.min(r,n);i<s;++i)if(t[i]!==e[i]){r=t[i],n=e[i];break}return r<n?-1:n<r?1:0},c.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},c.concat=function(t,e){if(!s(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return c.alloc(0);var r;if(void 0===e)for(r=e=0;r<t.length;++r)e+=t[r].length;var n=c.allocUnsafe(e),i=0;for(r=0;r<t.length;++r){var o=t[r];if(!c.isBuffer(o))throw new TypeError('"list" argument must be an Array of Buffers');o.copy(n,i),i+=o.length}return n},c.byteLength=p,c.prototype._isBuffer=!0,c.prototype.swap16=function(){var t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var e=0;e<t;e+=2)b(this,e,e+1);return this},c.prototype.swap32=function(){var t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var e=0;e<t;e+=4)b(this,e,e+3),b(this,e+1,e+2);return this},c.prototype.swap64=function(){var t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var e=0;e<t;e+=8)b(this,e,e+7),b(this,e+1,e+6),b(this,e+2,e+5),b(this,e+3,e+4);return this},c.prototype.toString=function(){var t=0|this.length;return 0==t?"":0===arguments.length?w(this,0,t):function(t,e,r){var n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t=t||"utf8";;)switch(t){case"hex":return x(this,e,r);case"utf8":case"utf-8":return w(this,e,r);case"ascii":return S(this,e,r);case"latin1":case"binary":return E(this,e,r);case"base64":return g(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return T(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},c.prototype.equals=function(t){if(!c.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===c.compare(this,t)},c.prototype.inspect=function(){var t="",r=e.INSPECT_MAX_BYTES;return 0<this.length&&(t=this.toString("hex",0,r).match(/.{2}/g).join(" "),this.length>r&&(t+=" ... ")),"<Buffer "+t+">"},c.prototype.compare=function(t,e,r,n,i){if(!c.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),e<0||r>t.length||n<0||i>this.length)throw new RangeError("out of range index");if(i<=n&&r<=e)return 0;if(i<=n)return-1;if(r<=e)return 1;if(this===t)return 0;for(var s=(i>>>=0)-(n>>>=0),o=(r>>>=0)-(e>>>=0),a=Math.min(s,o),f=this.slice(n,i),u=t.slice(e,r),h=0;h<a;++h)if(f[h]!==u[h]){s=f[h],o=u[h];break}return s<o?-1:o<s?1:0},c.prototype.includes=function(t,e,r){return-1!==this.indexOf(t,e,r)},c.prototype.indexOf=function(t,e,r){return _(this,t,e,r,!0)},c.prototype.lastIndexOf=function(t,e,r){return _(this,t,e,r,!1)},c.prototype.write=function(t,e,r,n){if(void 0===e)n="utf8",r=this.length,e=0;else if(void 0===r&&"string"==typeof e)n=e,r=this.length,e=0;else{if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e|=0,isFinite(r)?(r|=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var i=this.length-e;if((void 0===r||i<r)&&(r=i),0<t.length&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n=n||"utf8";for(var s,o,a,c,f,u,h=!1;;)switch(n){case"hex":return v(this,t,e,r);case"utf8":case"utf-8":return f=e,u=r,L(N(t,this.length-f),this,f,u);case"ascii":return m(this,t,e,r);case"latin1":case"binary":return m(this,t,e,r);case"base64":return this,a=e,c=r,L(P(t),this,a,c);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return s=e,o=r,L(function(t,e){for(var r,n,i,s=[],o=0;o<t.length&&!((e-=2)<0);++o)n=(r=t.charCodeAt(o))>>8,i=r%256,s.push(i),s.push(n);return s}(t,this.length-s),this,s,o);default:if(h)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),h=!0}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var A=4096;function S(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;i<r;++i)n+=String.fromCharCode(127&t[i]);return n}function E(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;i<r;++i)n+=String.fromCharCode(t[i]);return n}function x(t,e,r){var n=t.length;(!e||e<0)&&(e=0),(!r||r<0||n<r)&&(r=n);for(var i="",s=e;s<r;++s)i+=C(t[s]);return i}function T(t,e,r){for(var n=t.slice(e,r),i="",s=0;s<n.length;s+=2)i+=String.fromCharCode(n[s]+256*n[s+1]);return i}function j(t,e,r){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(r<t+e)throw new RangeError("Trying to access beyond buffer length")}function k(t,e,r,n,i,s){if(!c.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(i<e||e<s)throw new RangeError('"value" argument is out of bounds');if(r+n>t.length)throw new RangeError("Index out of range")}function I(t,e,r,n){e<0&&(e=65535+e+1);for(var i=0,s=Math.min(t.length-r,2);i<s;++i)t[r+i]=(e&255<<8*(n?i:1-i))>>>8*(n?i:1-i)}function O(t,e,r,n){e<0&&(e=4294967295+e+1);for(var i=0,s=Math.min(t.length-r,4);i<s;++i)t[r+i]=e>>>8*(n?i:3-i)&255}function R(t,e,r,n){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function M(t,e,r,n,s){return s||R(t,0,r,4),i.write(t,e,r,n,23,4),r+4}function q(t,e,r,n,s){return s||R(t,0,r,8),i.write(t,e,r,n,52,8),r+8}c.prototype.slice=function(t,e){var r,n=this.length;if((t=~~t)<0?(t+=n)<0&&(t=0):n<t&&(t=n),(e=void 0===e?n:~~e)<0?(e+=n)<0&&(e=0):n<e&&(e=n),e<t&&(e=t),c.TYPED_ARRAY_SUPPORT)(r=this.subarray(t,e)).__proto__=c.prototype;else{var i=e-t;r=new c(i,void 0);for(var s=0;s<i;++s)r[s]=this[s+t]}return r},c.prototype.readUIntLE=function(t,e,r){t|=0,e|=0,r||j(t,e,this.length);for(var n=this[t],i=1,s=0;++s<e&&(i*=256);)n+=this[t+s]*i;return n},c.prototype.readUIntBE=function(t,e,r){t|=0,e|=0,r||j(t,e,this.length);for(var n=this[t+--e],i=1;0<e&&(i*=256);)n+=this[t+--e]*i;return n},c.prototype.readUInt8=function(t,e){return e||j(t,1,this.length),this[t]},c.prototype.readUInt16LE=function(t,e){return e||j(t,2,this.length),this[t]|this[t+1]<<8},c.prototype.readUInt16BE=function(t,e){return e||j(t,2,this.length),this[t]<<8|this[t+1]},c.prototype.readUInt32LE=function(t,e){return e||j(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},c.prototype.readUInt32BE=function(t,e){return e||j(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},c.prototype.readIntLE=function(t,e,r){t|=0,e|=0,r||j(t,e,this.length);for(var n=this[t],i=1,s=0;++s<e&&(i*=256);)n+=this[t+s]*i;return(i*=128)<=n&&(n-=Math.pow(2,8*e)),n},c.prototype.readIntBE=function(t,e,r){t|=0,e|=0,r||j(t,e,this.length);for(var n=e,i=1,s=this[t+--n];0<n&&(i*=256);)s+=this[t+--n]*i;return(i*=128)<=s&&(s-=Math.pow(2,8*e)),s},c.prototype.readInt8=function(t,e){return e||j(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},c.prototype.readInt16LE=function(t,e){e||j(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},c.prototype.readInt16BE=function(t,e){e||j(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},c.prototype.readInt32LE=function(t,e){return e||j(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},c.prototype.readInt32BE=function(t,e){return e||j(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},c.prototype.readFloatLE=function(t,e){return e||j(t,4,this.length),i.read(this,t,!0,23,4)},c.prototype.readFloatBE=function(t,e){return e||j(t,4,this.length),i.read(this,t,!1,23,4)},c.prototype.readDoubleLE=function(t,e){return e||j(t,8,this.length),i.read(this,t,!0,52,8)},c.prototype.readDoubleBE=function(t,e){return e||j(t,8,this.length),i.read(this,t,!1,52,8)},c.prototype.writeUIntLE=function(t,e,r,n){t=+t,e|=0,r|=0,n||k(this,t,e,r,Math.pow(2,8*r)-1,0);var i=1,s=0;for(this[e]=255&t;++s<r&&(i*=256);)this[e+s]=t/i&255;return e+r},c.prototype.writeUIntBE=function(t,e,r,n){t=+t,e|=0,r|=0,n||k(this,t,e,r,Math.pow(2,8*r)-1,0);var i=r-1,s=1;for(this[e+i]=255&t;0<=--i&&(s*=256);)this[e+i]=t/s&255;return e+r},c.prototype.writeUInt8=function(t,e,r){return t=+t,e|=0,r||k(this,t,e,1,255,0),c.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=255&t,e+1},c.prototype.writeUInt16LE=function(t,e,r){return t=+t,e|=0,r||k(this,t,e,2,65535,0),c.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):I(this,t,e,!0),e+2},c.prototype.writeUInt16BE=function(t,e,r){return t=+t,e|=0,r||k(this,t,e,2,65535,0),c.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):I(this,t,e,!1),e+2},c.prototype.writeUInt32LE=function(t,e,r){return t=+t,e|=0,r||k(this,t,e,4,4294967295,0),c.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t):O(this,t,e,!0),e+4},c.prototype.writeUInt32BE=function(t,e,r){return t=+t,e|=0,r||k(this,t,e,4,4294967295,0),c.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):O(this,t,e,!1),e+4},c.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e|=0,!n){var i=Math.pow(2,8*r-1);k(this,t,e,r,i-1,-i)}var s=0,o=1,a=0;for(this[e]=255&t;++s<r&&(o*=256);)t<0&&0===a&&0!==this[e+s-1]&&(a=1),this[e+s]=(t/o>>0)-a&255;return e+r},c.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e|=0,!n){var i=Math.pow(2,8*r-1);k(this,t,e,r,i-1,-i)}var s=r-1,o=1,a=0;for(this[e+s]=255&t;0<=--s&&(o*=256);)t<0&&0===a&&0!==this[e+s+1]&&(a=1),this[e+s]=(t/o>>0)-a&255;return e+r},c.prototype.writeInt8=function(t,e,r){return t=+t,e|=0,r||k(this,t,e,1,127,-128),c.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[e]=255&t,e+1},c.prototype.writeInt16LE=function(t,e,r){return t=+t,e|=0,r||k(this,t,e,2,32767,-32768),c.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):I(this,t,e,!0),e+2},c.prototype.writeInt16BE=function(t,e,r){return t=+t,e|=0,r||k(this,t,e,2,32767,-32768),c.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):I(this,t,e,!1),e+2},c.prototype.writeInt32LE=function(t,e,r){return t=+t,e|=0,r||k(this,t,e,4,2147483647,-2147483648),c.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):O(this,t,e,!0),e+4},c.prototype.writeInt32BE=function(t,e,r){return t=+t,e|=0,r||k(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),c.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):O(this,t,e,!1),e+4},c.prototype.writeFloatLE=function(t,e,r){return M(this,t,e,!0,r)},c.prototype.writeFloatBE=function(t,e,r){return M(this,t,e,!1,r)},c.prototype.writeDoubleLE=function(t,e,r){return q(this,t,e,!0,r)},c.prototype.writeDoubleBE=function(t,e,r){return q(this,t,e,!1,r)},c.prototype.copy=function(t,e,r,n){if(r=r||0,n||0===n||(n=this.length),e>=t.length&&(e=t.length),e=e||0,0<n&&n<r&&(n=r),n===r)return 0;if(0===t.length||0===this.length)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e<n-r&&(n=t.length-e+r);var i,s=n-r;if(this===t&&r<e&&e<n)for(i=s-1;0<=i;--i)t[i+e]=this[i+r];else if(s<1e3||!c.TYPED_ARRAY_SUPPORT)for(i=0;i<s;++i)t[i+e]=this[i+r];else Uint8Array.prototype.set.call(t,this.subarray(r,r+s),e);return s},c.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),1===t.length){var i=t.charCodeAt(0);i<256&&(t=i)}if(void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!c.isEncoding(n))throw new TypeError("Unknown encoding: "+n)}else"number"==typeof t&&(t&=255);if(e<0||this.length<e||this.length<r)throw new RangeError("Out of range index");if(r<=e)return this;var s;if(e>>>=0,r=void 0===r?this.length:r>>>0,"number"==typeof(t=t||0))for(s=e;s<r;++s)this[s]=t;else{var o=c.isBuffer(t)?t:N(new c(t,n).toString()),a=o.length;for(s=0;s<r-e;++s)this[s+e]=o[s%a]}return this};var B=/[^+\/0-9A-Za-z-_]/g;function C(t){return t<16?"0"+t.toString(16):t.toString(16)}function N(t,e){var r;e=e||1/0;for(var n=t.length,i=null,s=[],o=0;o<n;++o){if(55295<(r=t.charCodeAt(o))&&r<57344){if(!i){if(56319<r){-1<(e-=3)&&s.push(239,191,189);continue}if(o+1===n){-1<(e-=3)&&s.push(239,191,189);continue}i=r;continue}if(r<56320){-1<(e-=3)&&s.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&-1<(e-=3)&&s.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;s.push(r)}else if(r<2048){if((e-=2)<0)break;s.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;s.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;s.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return s}function P(t){return n.toByteArray(function(t){if((t=function(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}(t).replace(B,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function L(t,e,r,n){for(var i=0;i<n&&!(i+r>=e.length||i>=t.length);++i)e[i+r]=t[i];return i}}).call(this,r(14))},function(t,e,r){var n=r(8).EventEmitter,i=r(5),s=r(3).UInt160,o=r(21).Currency,a=r(22).StreamError,c=r(20).Server;function f(t,e){n.call(this),this.remote=t,this.requested=!1,this.message={command:e,id:void 0}}i.inherits(f,n),f.prototype.broadcast=function(){var t=this.remote.getConnectedServers();return this.request(t),t.length},f.prototype.request=function(t,e){return this.requested||("function"==typeof t&&(e=t),this.requested=!0,this.on("error",function(){}),this.emit("request",this.remote),Array.isArray(t)?t.forEach(function(t){this.setServer(t),this.remote.request(this)},this):this.remote.request(this),this.callback(e)),this},f.prototype.callback=function(t,e,r){var n=this;if("function"!=typeof t)return this;var i=!1;return this.once(e||"success",function(e){i||(i=!0,t.call(n,null,e))}),this.once(r||"error",function(e){i||(i=!0,e instanceof a||(e=new a(e)),t.call(n,e))}),this.request(),this},f.prototype.timeout=function(t,e){var r=this;if(!this.requested)return this.once("request",function(){r.timeout(t,e)});var n=this.emit,i=!1,s=setTimeout(function(){i=!0,"function"==typeof e&&e(),n.call(r,"timeout")},t);return this.emit=function(){i||(clearTimeout(s),n.apply(r,arguments))},this},f.prototype.setServer=function(t){var e=null;switch(typeof t){case"object":e=t;break;case"string":for(var r,n=this.remote._servers,i=0;r=n[i];i++)if(r._url===t){e=r;break}}return e instanceof c&&(this.server=e),this},f.prototype.buildPath=function(t){if(this.remote.local_signing)throw new Error("`build_path` is completely ignored when doing local signing as `Paths` is a component of the signed blob. The `tx_blob` is signed,sealed and delivered, and the txn unmodified after");return t?this.message.build_path=!0:delete this.message.build_path,this},f.prototype.ledgerChoose=function(t){return t?this.message.ledger_index=this.remote._ledger_current_index:this.message.ledger_hash=this.remote._ledger_hash,this},f.prototype.ledgerHash=function(t){return this.message.ledger_hash=t,this},f.prototype.ledgerIndex=function(t){return this.message.ledger_index=t,this},f.prototype.ledgerSelect=function(t){switch(t){case"current":case"closed":case"validated":this.message.ledger_index=t;break;default:isNaN(t)?this.message.ledger_hash=t:(t=Number(t))&&(this.message.ledger_index=t)}return this},f.prototype.accountRoot=function(t){return this.message.account_root=s.json_rewrite(t),this},f.prototype.index=function(t){return this.message.index=t,this},f.prototype.offerId=function(t,e){return this.message.offer={account:s.json_rewrite(t),seq:e},this},f.prototype.offerIndex=function(t){return this.message.offer=t,this},f.prototype.secret=function(t){return t&&(this.message.secret=t),this},f.prototype.txHash=function(t){return this.message.tx_hash=t,this},f.prototype.txJson=function(t){return this.message.tx_json=t,this},f.prototype.txBlob=function(t){return this.message.tx_blob=t,this},f.prototype.streamState=function(t,e,r){return this.message.stream_state={currency:r,accounts:[s.json_rewrite(t),s.json_rewrite(e)]},this},f.prototype.setAccounts=f.prototype.accounts=function(t,e){Array.isArray(t)||(t=[t]);var r=t.map(function(t){return s.json_rewrite(t)});return e?this.message.accounts_proposed=r:this.message.accounts=r,this},f.prototype.addAccount=function(t,e){if(Array.isArray(t))return t.forEach(this.addAccount,this),this;var r=s.json_rewrite(t);return!0===e?this.message.accounts_proposed=(this.message.accounts_proposed||[]).concat(r):this.message.accounts=(this.message.accounts||[]).concat(r),this},f.prototype.setAccountsProposed=f.prototype.rtAccounts=f.prototype.accountsProposed=function(t){return this.accounts(t,!0)},f.prototype.addAccountProposed=function(t){return Array.isArray(t)?(t.forEach(this.addAccountProposed,this),this):this.addAccount(t,!0)},f.prototype.setBooks=f.prototype.books=function(t,e){this.message.books=[];for(var r=0,n=t.length;r<n;r++){var i=t[r];this.addBook(i,e)}return this},f.prototype.addBook=function(t,e){if(Array.isArray(t))return t.forEach(this.addBook,this),this;var r={};return["taker_gets","taker_pays"].forEach(function(e){if(!t[e])throw new Error("Missing "+e);var n=r[e]={currency:o.json_rewrite(t[e].currency,{force_hex:!0})};o.from_json(n.currency).is_native()||(n.issuer=s.json_rewrite(t[e].issuer))}),"boolean"!=typeof e?r.snapshot=!0:e?r.snapshot=!0:delete r.snapshot,t.both&&(r.both=!0),this.message.books=(this.message.books||[]).concat(r),this},f.prototype.addStream=function(t,e){if(Array.isArray(e))switch(t){case"accounts":this.addAccount(e);break;case"accounts_proposed":this.addAccountProposed(e);break;case"books":this.addBook(e)}else if(1<arguments.length){for(arg in arguments)this.addStream(arguments[arg]);return}return Array.isArray(this.message.streams)||(this.message.streams=[]),-1===this.message.streams.indexOf(t)&&this.message.streams.push(t),this},e.Request=f},function(t,e,r){var n=r(41),i=r(5),s=r(1),o=r(8).EventEmitter,a=(r(6).Amount,r(3).UInt160),c=r(82).TransactionManager,f=r(0).sjcl,u=r(9).Base;function h(t,e){o.call(this);var r=this;return this._remote=t,this._account=a.from_json(e),this._account_id=this._account.to_json(),this._subs=0,this._entry={},this.on("newListener",function(t,e){~h.subscribeEvents.indexOf(t)&&(!r._subs&&r._remote._connected&&r._remote.request_subscribe().add_account(r._account_id).broadcast(),r._subs+=1)}),this.on("removeListener",function(t,e){~h.subscribeEvents.indexOf(t)&&(r._subs-=1,!r._subs&&r._remote._connected&&r._remote.request_unsubscribe().add_account(r._account_id).broadcast())}),this._remote.on("prepare_subscribe",function(t){r._account.is_valid()&&r._subs&&t.add_account(r._account_id)}),this.on("transaction",function(t){if(t.mmeta){var e=!1;t.mmeta.each(function(t){t.fields.Account===r._account_id&&"AccountRoot"===t.entryType&&(s(r._entry,t.fieldsNew,t.fieldsFinal),e=!0)}),e&&r.emit("entry",r._entry)}}),this._transactionManager=new c(this),this}i.inherits(h,o),h.subscribeEvents=["transaction","entry"],h.prototype.toJson=function(){return this._account.to_json()},h.prototype.isValid=function(){return this._account.is_valid()},h.prototype.getInfo=function(t){return this._remote.request_account_info(this._account_id,t)},h.prototype.entry=function(t){var e=this;return t="function"==typeof t?t:function(){},this.getInfo(function(r,n){r?t(r):(s(e._entry,n.account_data),e.emit("entry",e._entry),t(null,n))}),this},h.prototype.getNextSequence=function(t){return t="function"==typeof t?t:function(){},this.getInfo(function(e,r){!function(t){return t&&"object"==typeof t&&"object"==typeof t.remote&&"actNotFound"===t.remote.error}(e)?e?t(e):t(null,r.account_data.Sequence):t(null,1)}),this},h.prototype.lines=function(t){var e=this;return t="function"==typeof t?t:function(){},this._remote.requestAccountLines(this._account_id,function(r,n){r?t(r):(e._lines=n.lines,e.emit("lines",e._lines),t(null,n))}),this},h.prototype.line=function(t,e,r){return r="function"==typeof r?r:function(){},this.lines(function(n,i){if(n)return r(n);var s;t:for(var o=0;o<i.lines.length;o++){var a=i.lines[o];if(a.account===e&&a.currency===t){s=a;break t}}r(null,s)}),this},h.prototype.notify=h.prototype.notifyTx=function(t){if(this._subs){this.emit("transaction",t);var e=t.transaction.Account;if(e){var r=e===this._account_id;this.emit(r?"transaction-outbound":"transaction-inbound",t)}}},h.prototype.submit=function(t){this._transactionManager.submit(t)},h.prototype.publicKeyIsActive=function(t,e){var r,i=this;try{r=h._publicKeyToAddress(t)}catch(t){return e(t)}var s=[function(t){i.getInfo(function(e,r){e&&e.remote&&"actNotFound"===e.remote.error?t(null,null):t(e,r)})},function(t,e){if(t){var n=t.account_data;n.RegularKey&&n.RegularKey===r?e(null,!0):n.Account===r&&0==(1048576&n.Flags)?e(null,!0):e(null,!1)}else r===i._account_id?e(null,!0):e(null,!1)}];n.waterfall(s,e)},h._publicKeyToAddress=function(t){if(a.is_valid(t))return t;if(/^[0-9a-fA-F]+$/.test(t))return e=t,r=f.codec.hex.toBits(e),n=f.hash.ripemd160.hash(f.hash.sha256.hash(r)),(i=a.from_bits(n)).set_version(u.VER_ACCOUNT_ID),i.to_json();throw new Error("Public key is invalid. Must be a UInt160 or a hex string");var e,r,n,i},e.Account=h},function(t,e,r){(function(r,n){var i;
/*!
* async
* https://github.com/caolan/async
*
* Copyright 2010-2014 Caolan McMahon
* Released under the MIT license
*/
/*!
* async
* https://github.com/caolan/async
*
* Copyright 2010-2014 Caolan McMahon
* Released under the MIT license
*/!function(){var s,o,a={};function c(t){var e=!1;return function(){if(e)throw new Error("Callback was already called.");e=!0,t.apply(s,arguments)}}function f(t,e){if(t.forEach)return t.forEach(e);for(var r=0;r<t.length;r+=1)e(t[r],r,t)}function u(t,e){if(t.map)return t.map(e);var r=[];return f(t,function(t,n,i){r.push(e(t,n,i))}),r}function h(t){if(Object.keys)return Object.keys(t);var e=[];for(var r in t)t.hasOwnProperty(r)&&e.push(r);return e}null!=(s=this)&&(o=s.async),a.noConflict=function(){return s.async=o,a};var d=Object.prototype.toString,l=Array.isArray||function(t){return"[object Array]"===d.call(t)};function p(t){return function(){var e=Array.prototype.slice.call(arguments);return t.apply(null,[a.each].concat(e))}}function b(t){return function(){var e=Array.prototype.slice.call(arguments);return t.apply(null,[a.eachSeries].concat(e))}}function _(t,e,r,n){if(e=u(e,function(t,e){return{index:e,value:t}}),n){var i=[];t(e,function(t,e){r(t.value,function(r,n){i[t.index]=n,e(r)})},function(t){n(t,i)})}else t(e,function(t,e){r(t.value,function(t){e(t)})})}void 0!==r&&r.nextTick?(a.nextTick=r.nextTick,a.setImmediate=void 0!==n?function(t){n(t)}:a.nextTick):(a.nextTick="function"==typeof n?function(t){n(t)}:function(t){setTimeout(t,0)},a.setImmediate=a.nextTick),a.each=function(t,e,r){if(r=r||function(){},!t.length)return r();var n=0;function i(e){e?(r(e),r=function(){}):(n+=1)>=t.length&&r()}f(t,function(t){e(t,c(i))})},a.forEach=a.each,a.eachSeries=function(t,e,r){if(r=r||function(){},!t.length)return r();var n=0,i=function(){e(t[n],function(e){e?(r(e),r=function(){}):(n+=1)>=t.length?r():i()})};i()},a.forEachSeries=a.eachSeries,a.eachLimit=function(t,e,r,n){y(e).apply(null,[t,r,n])},a.forEachLimit=a.eachLimit;var y=function(t){return function(e,r,n){if(n=n||function(){},!e.length||t<=0)return n();var i=0,s=0,o=0;!function a(){if(i>=e.length)return n();for(;o<t&&s<e.length;)o+=1,r(e[(s+=1)-1],function(t){t?(n(t),n=function(){}):(o-=1,(i+=1)>=e.length?n():a())})}()}};a.map=p(_),a.mapSeries=b(_),a.mapLimit=function(t,e,r,n){return v(e)(t,r,n)};var v=function(t){return function(t,e){return function(){var r=Array.prototype.slice.call(arguments);return e.apply(null,[y(t)].concat(r))}}(t,_)};function m(t,e,r,n){var i=[];t(e=u(e,function(t,e){return{index:e,value:t}}),function(t,e){r(t.value,function(r){r&&i.push(t),e()})},function(t){n(u(i.sort(function(t,e){return t.index-e.index}),function(t){return t.value}))})}function g(t,e,r,n){var i=[];t(e=u(e,function(t,e){return{index:e,value:t}}),function(t,e){r(t.value,function(r){r||i.push(t),e()})},function(t){n(u(i.sort(function(t,e){return t.index-e.index}),function(t){return t.value}))})}function w(t,e,r,n){t(e,function(t,e){r(t,function(r){r?(n(t),n=function(){}):e()})},function(t){n()})}function A(t,e,r){if(r=r||function(){},l(e))t.map(e,function(t,e){t&&t(function(t){var r=Array.prototype.slice.call(arguments,1);r.length<=1&&(r=r[0]),e.call(null,t,r)})},r);else{var n={};t.each(h(e),function(t,r){e[t](function(e){var i=Array.prototype.slice.call(arguments,1);i.length<=1&&(i=i[0]),n[t]=i,r(e)})},function(t){r(t,n)})}}function S(t,e,r,n){var i=[];t(e,function(t,e){r(t,function(t,r){i=i.concat(r||[]),e(t)})},function(t){n(t,i)})}function E(t){return function(e){var r=Array.prototype.slice.call(arguments,1);e.apply(null,r.concat([function(e){var r=Array.prototype.slice.call(arguments,1);"undefined"!=typeof console&&(e?console.error:console[t]&&f(r,function(t){}))}]))}}function x(t,e){function r(){var r=this,n=Array.prototype.slice.call(arguments),i=n.pop();return t(e,function(t,e){t.apply(r,n.concat([e]))},i)}if(2<arguments.length){var n=Array.prototype.slice.call(arguments,2);return r.apply(this,n)}return r}a.reduce=function(t,e,r,n){a.eachSeries(t,function(t,n){r(e,t,function(t,r){e=r,n(t)})},function(t){n(t,e)})},a.inject=a.reduce,a.foldl=a.reduce,a.reduceRight=function(t,e,r,n){var i=u(t,function(t){return t}).reverse();a.reduce(i,e,r,n)},a.foldr=a.reduceRight,a.filter=p(m),a.filterSeries=b(m),a.select=a.filter,a.selectSeries=a.filterSeries,a.reject=p(g),a.rejectSeries=b(g),a.detect=p(w),a.detectSeries=b(w),a.some=function(t,e,r){a.each(t,function(t,n){e(t,function(t){t&&(r(!0),r=function(){}),n()})},function(t){r(!1)})},a.any=a.some,a.every=function(t,e,r){a.each(t,function(t,n){e(t,function(t){t||(r(!1),r=function(){}),n()})},function(t){r(!0)})},a.all=a.every,a.sortBy=function(t,e,r){a.map(t,function(t,r){e(t,function(e,n){e?r(e):r(null,{value:t,criteria:n})})},function(t,e){if(t)return r(t);r(null,u(e.sort(function(t,e){var r=t.criteria,n=e.criteria;return r<n?-1:n<r?1:0}),function(t){return t.value}))})},a.auto=function(t,e){e=e||function(){};var r=h(t),n=r.length;if(!n)return e();function i(t){c.unshift(t)}function s(){n--,f(c.slice(0),function(t){t()})}var o={},c=[];i(function(){if(!n){var t=e;e=function(){},t(null,o)}}),f(r,function(r){function n(t){var n=Array.prototype.slice.call(arguments,1);if(n.length<=1&&(n=n[0]),t){var i={};f(h(o),function(t){i[t]=o[t]}),i[r]=n,e(t,i),e=function(){}}else o[r]=n,a.setImmediate(s)}function u(){return function(t,e,r){return t.reduce?t.reduce(e,r):(f(t,function(t,n,i){r=e(r,t)}),r)}(p,function(t,e){return t&&o.hasOwnProperty(e)},!0)&&!o.hasOwnProperty(r)}var d=l(t[r])?t[r]:[t[r]],p=d.slice(0,Math.abs(d.length-1))||[];if(u())d[d.length-1](n,o);else{var b=function(){u()&&(function(t){for(var e=0;e<c.length;e+=1)if(c[e]===t)return c.splice(e,1)}(b),d[d.length-1](n,o))};i(b)}})},a.retry=function(t,e,r){var n=[];function i(i,s){function o(t,e){return function(r){t(function(t,n){r(!t||e,{err:t,result:n})},s)}}for(;t;)n.push(o(e,!(t-=1)));a.series(n,function(t,e){e=e[e.length-1],(i||r)(e.err,e.result)})}return"function"==typeof t&&(r=e,e=t,t=5),t=parseInt(t,10)||5,r?i():i},a.waterfall=function(t,e){if(e=e||function(){},!l(t)){var r=new Error("First argument to waterfall must be an array of functions");return e(r)}if(!t.length)return e();var n=function(t){return function(r){if(r)e.apply(null,arguments),e=function(){};else{var i=Array.prototype.slice.call(arguments,1),s=t.next();s?i.push(n(s)):i.push(e),a.setImmediate(function(){t.apply(null,i)})}}};n(a.iterator(t))()},a.parallel=function(t,e){A({map:a.map,each:a.each},t,e)},a.parallelLimit=function(t,e,r){A({map:v(e),each:y(e)},t,r)},a.series=function(t,e){if(e=e||function(){},l(t))a.mapSeries(t,function(t,e){t&&t(function(t){var r=Array.prototype.slice.call(arguments,1);r.length<=1&&(r=r[0]),e.call(null,t,r)})},e);else{var r={};a.eachSeries(h(t),function(e,n){t[e](function(t){var i=Array.prototype.slice.call(arguments,1);i.length<=1&&(i=i[0]),r[e]=i,n(t)})},function(t){e(t,r)})}},a.iterator=function(t){var e=function(r){var n=function(){return t.length&&t[r].apply(null,arguments),n.next()};return n.next=function(){return r<t.length-1?e(r+1):null},n};return e(0)},a.apply=function(t){var e=Array.prototype.slice.call(arguments,1);return function(){return t.apply(null,e.concat(Array.prototype.slice.call(arguments)))}},a.concat=p(S),a.concatSeries=b(S),a.whilst=function(t,e,r){t()?e(function(n){if(n)return r(n);a.whilst(t,e,r)}):r()},a.doWhilst=function(t,e,r){t(function(n){if(n)return r(n);var i=Array.prototype.slice.call(arguments,1);e.apply(null,i)?a.doWhilst(t,e,r):r()})},a.until=function(t,e,r){t()?r():e(function(n){if(n)return r(n);a.until(t,e,r)})},a.doUntil=function(t,e,r){t(function(n){if(n)return r(n);var i=Array.prototype.slice.call(arguments,1);e.apply(null,i)?r():a.doUntil(t,e,r)})},a.queue=function(t,e){function r(t,e,r,n){if(t.started||(t.started=!0),l(e)||(e=[e]),0==e.length)return a.setImmediate(function(){t.drain&&t.drain()});f(e,function(e){var i={data:e,callback:"function"==typeof n?n:null};r?t.tasks.unshift(i):t.tasks.push(i),t.saturated&&t.tasks.length===t.concurrency&&t.saturated(),a.setImmediate(t.process)})}void 0===e&&(e=1);var n=0,i={tasks:[],concurrency:e,saturated:null,empty:null,drain:null,started:!1,paused:!1,push:function(t,e){r(i,t,!1,e)},kill:function(){i.drain=null,i.tasks=[]},unshift:function(t,e){r(i,t,!0,e)},process:function(){if(!i.paused&&n<i.concurrency&&i.tasks.length){var e=i.tasks.shift();i.empty&&0===i.tasks.length&&i.empty(),n+=1;var r=c(function(){n-=1,e.callback&&e.callback.apply(e,arguments),i.drain&&i.tasks.length+n===0&&i.drain(),i.process()});t(e.data,r)}},length:function(){return i.tasks.length},running:function(){return n},idle:function(){return i.tasks.length+n===0},pause:function(){!0!==i.paused&&(i.paused=!0,i.process())},resume:function(){!1!==i.paused&&(i.paused=!1,i.process())}};return i},a.cargo=function(t,e){var r=!1,n=[],i={tasks:n,payload:e,saturated:null,empty:null,drain:null,drained:!0,push:function(t,r){l(t)||(t=[t]),f(t,function(t){n.push({data:t,callback:"function"==typeof r?r:null}),i.drained=!1,i.saturated&&n.length===e&&i.saturated()}),a.setImmediate(i.process)},process:function s(){if(!r){if(0===n.length)return i.drain&&!i.drained&&i.drain(),void(i.drained=!0);var o="number"==typeof e?n.splice(0,e):n.splice(0,n.length),a=u(o,function(t){return t.data});i.empty&&i.empty(),r=!0,t(a,function(){r=!1;var t=arguments;f(o,function(e){e.callback&&e.callback.apply(null,t)}),s()})}},length:function(){return n.length},running:function(){return r}};return i},a.log=E("log"),a.dir=E("dir"),a.memoize=function(t,e){var r={},n={};function i(){var i=Array.prototype.slice.call(arguments),s=i.pop(),o=e.apply(null,i);o in r?a.nextTick(function(){s.apply(null,r[o])}):o in n?n[o].push(s):(n[o]=[s],t.apply(null,i.concat([function(){r[o]=arguments;var t=n[o];delete n[o];for(var e=0,i=t.length;e<i;e++)t[e].apply(null,arguments)}])))}return e=e||function(t){return t},i.memo=r,i.unmemoized=t,i},a.unmemoize=function(t){return function(){return(t.unmemoized||t).apply(null,arguments)}},a.times=function(t,e,r){for(var n=[],i=0;i<t;i++)n.push(i);return a.map(n,e,r)},a.timesSeries=function(t,e,r){for(var n=[],i=0;i<t;i++)n.push(i);return a.mapSeries(n,e,r)},a.seq=function(){var t=arguments;return function(){var e=this,r=Array.prototype.slice.call(arguments),n=r.pop();a.reduce(t,r,function(t,r,n){r.apply(e,t.concat([function(){var t=arguments[0],e=Array.prototype.slice.call(arguments,1);n(t,e)}]))},function(t,r){n.apply(e,[t].concat(r))})}},a.compose=function(){return a.seq.apply(null,Array.prototype.reverse.call(arguments))},a.applyEach=p(x),a.applyEachSeries=b(x),a.forever=function(t,e){!function r(n){if(n){if(e)return e(n);throw n}t(r)}()},t.exports?t.exports=a:void 0===(i=function(){return a}.apply(e,[]))||(t.exports=i)}()}).call(this,r(27),r(80).setImmediate)},function(t,e,r){"use strict";e.__esModule=!0,e.default=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}},function(t,e,r){"use strict";e.__esModule=!0;var n,i=(n=r(91))&&n.__esModule?n:{default:n};function s(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),(0,i.default)(t,n.key,n)}}e.default=function(t,e,r){return e&&s(t.prototype,e),r&&s(t,r),t}},function(t,e,r){"use strict";(function(e){var n=s(r(42)),i=s(r(43));function s(t){return t&&t.__esModule?t:{default:t}}function o(t){return c.sha256().update(t).digest()}var a=r(45),c=r(11),f=new(r(2).ec)("secp256k1"),u=r(116),h=r(25).hexToBytes,d=r(25).bytesToHex,l=r(118),p=r(129),b=r(130),_=((0,i.default)(y,[{key:"_encode",value:function(t,r){var n=function(t,e){var r=l.create(1+e.length);return r[0]=t,l.copy(e,r,1,0,e.length),r}(t,r),i=function(t,e){var r=l.create(t.length+e.length);return l.copy(t,r),l.copy(e,r,t.length,0,e.length),r}(n,e.from(o(o(n)).slice(0,4)));return this._base58.encode(i)}},{key:"_decode",value:function(t,e){var r=this._base58.decode(e);if(!r||r[0]!==t||r.length<5)throw new Error("invalid input size");for(var n=o(o(r.slice(0,-4))).slice(0,4),i=r.slice(-4),s=0;4!==s;s+=1)if(n[s]!==i[s])throw new Error("invalid checksum");return r.slice(1,-4)}},{key:"generateSeed",value:function(){var t=a(16);return this._encode(this._SEED_PREFIX,t)}},{key:"deriveKeyPair",value:function(t){var e="00"+function(t){var e=f.curve.n,r=u.ScalarMultiple(t),n=f.g.mul(r);return u.ScalarMultiple(n.encodeCompressed(),0).add(r).mod(e)}(this._decode(this._SEED_PREFIX,t)).toString(16,64).toUpperCase(),r=d(f.keyFromPrivate(e.slice(2)).getPublic().encodeCompressed());return{privateKey:e,publicKey:r}}},{key:"deriveAddress",value:function(t){var r=o(h(t)),n=e.from(c.ripemd160().update(r).digest());return this._encode(this._ACCOUNT_PREFIX,n)}},{key:"checkAddress",value:function(t){try{return this._decode(this._ACCOUNT_PREFIX,t),!0}catch(t){return!1}}},{key:"convertAddressToBytes",value:function(t){try{return this._decode(this._ACCOUNT_PREFIX,t)}catch(t){throw new Error("convert address to bytes in error")}}},{key:"convertBytesToAddress",value:function(t){try{return this._encode(this._ACCOUNT_PREFIX,t)}catch(t){throw new Error("convert bytes to address in error")}}}]),y);function y(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"swt";(0,n.default)(this,y);var e=p.find(function(e){return e.currency.toLowerCase()===t.toLowerCase()});if(!e)throw new Error("config of "+t+" is empty");this._SEED_PREFIX=e.SEED_PREFIX,this._ACCOUNT_PREFIX=e.ACCOUNT_PREFIX,this._base58=b(e.ACCOUNT_ALPHABET)}t.exports=_}).call(this,r(38).Buffer)},function(t,e,r){var n;function i(t){this.rand=t}if(t.exports=function(t){return(n=n||new i(null)).generate(t)},(t.exports.Rand=i).prototype.generate=function(t){return this._rand(t)},i.prototype._rand=function(t){if(this.rand.getBytes)return this.rand.getBytes(t);for(var e=new Uint8Array(t),r=0;r<e.length;r++)e[r]=this.rand.getByte();return e},"object"==typeof self)self.crypto&&self.crypto.getRandomValues?i.prototype._rand=function(t){var e=new Uint8Array(t);return self.crypto.getRandomValues(e),e}:self.msCrypto&&self.msCrypto.getRandomValues?i.prototype._rand=function(t){var e=new Uint8Array(t);return self.msCrypto.getRandomValues(e),e}:"object"==typeof window&&(i.prototype._rand=function(){throw new Error("Not implemented yet")});else try{var s=r(94);if("function"!=typeof s.randomBytes)throw new Error("Not supported");i.prototype._rand=function(t){return s.randomBytes(t)}}catch(t){}},function(t,e,r){"use strict";var n=r(7).rotr32;function i(t,e,r){return t&e^~t&r}function s(t,e,r){return t&e^t&r^e&r}function o(t,e,r){return t^e^r}e.ft_1=function(t,e,r,n){return 0===t?i(e,r,n):1===t||3===t?o(e,r,n):2===t?s(e,r,n):void 0},e.ch32=i,e.maj32=s,e.p32=o,e.s0_256=function(t){return n(t,2)^n(t,13)^n(t,22)},e.s1_256=function(t){return n(t,6)^n(t,11)^n(t,25)},e.g0_256=function(t){return n(t,7)^n(t,18)^t>>>3},e.g1_256=function(t){return n(t,17)^n(t,19)^t>>>10}},function(t,e,r){"use strict";var n=r(7),i=r(17),s=r(46),o=r(10),a=n.sum32,c=n.sum32_4,f=n.sum32_5,u=s.ch32,h=s.maj32,d=s.s0_256,l=s.s1_256,p=s.g0_256,b=s.g1_256,_=i.BlockHash,y=[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 v(){if(!(this instanceof v))return new v;_.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=y,this.W=new Array(64)}n.inherits(v,_),(t.exports=v).blockSize=512,v.outSize=256,v.hmacStrength=192,v.padLength=64,v.prototype._update=function(t,e){for(var r=this.W,n=0;n<16;n++)r[n]=t[e+n];for(;n<r.length;n++)r[n]=c(b(r[n-2]),r[n-7],p(r[n-15]),r[n-16]);var i=this.h[0],s=this.h[1],_=this.h[2],y=this.h[3],v=this.h[4],m=this.h[5],g=this.h[6],w=this.h[7];for(o(this.k.length===r.length),n=0;n<r.length;n++){var A=f(w,l(v),u(v,m,g),this.k[n],r[n]),S=a(d(i),h(i,s,_));w=g,g=m,m=v,v=a(y,A),y=_,_=s,s=i,i=a(A,S)}this.h[0]=a(this.h[0],i),this.h[1]=a(this.h[1],s),this.h[2]=a(this.h[2],_),this.h[3]=a(this.h[3],y),this.h[4]=a(this.h[4],v),this.h[5]=a(this.h[5],m),this.h[6]=a(this.h[6],g),this.h[7]=a(this.h[7],w)},v.prototype._digest=function(t){return"hex"===t?n.toHex32(this.h,"big"):n.split32(this.h,"big")}},function(t,e,r){"use strict";var n=r(7),i=r(17),s=r(10),o=n.rotr64_hi,a=n.rotr64_lo,c=n.shr64_hi,f=n.shr64_lo,u=n.sum64,h=n.sum64_hi,d=n.sum64_lo,l=n.sum64_4_hi,p=n.sum64_4_lo,b=n.sum64_5_hi,_=n.sum64_5_lo,y=i.BlockHash,v=[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 m(){if(!(this instanceof m))return new m;y.call(this),this.h=[1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209],this.k=v,this.W=new Array(160)}function g(t,e,r,n,i){var s=t&r^~t&i;return s<0&&(s+=4294967296),s}function w(t,e,r,n,i,s){var o=e&n^~e&s;return o<0&&(o+=4294967296),o}function A(t,e,r,n,i){var s=t&r^t&i^r&i;return s<0&&(s+=4294967296),s}function S(t,e,r,n,i,s){var o=e&n^e&s^n&s;return o<0&&(o+=4294967296),o}function E(t,e){var r=o(t,e,28)^o(e,t,2)^o(e,t,7);return r<0&&(r+=4294967296),r}function x(t,e){var r=a(t,e,28)^a(e,t,2)^a(e,t,7);return r<0&&(r+=4294967296),r}function T(t,e){var r=o(t,e,14)^o(t,e,18)^o(e,t,9);return r<0&&(r+=4294967296),r}function j(t,e){var r=a(t,e,14)^a(t,e,18)^a(e,t,9);return r<0&&(r+=4294967296),r}function k(t,e){var r=o(t,e,1)^o(t,e,8)^c(t,e,7);return r<0&&(r+=4294967296),r}function I(t,e){var r=a(t,e,1)^a(t,e,8)^f(t,e,7);return r<0&&(r+=4294967296),r}function O(t,e){var r=o(t,e,19)^o(e,t,29)^c(t,e,6);return r<0&&(r+=4294967296),r}function R(t,e){var r=a(t,e,19)^a(e,t,29)^f(t,e,6);return r<0&&(r+=4294967296),r}n.inherits(m,y),(t.exports=m).blockSize=1024,m.outSize=512,m.hmacStrength=192,m.padLength=128,m.prototype._prepareBlock=function(t,e){for(var r=this.W,n=0;n<32;n++)r[n]=t[e+n];for(;n<r.length;n+=2){var i=O(r[n-4],r[n-3]),s=R(r[n-4],r[n-3]),o=r[n-14],a=r[n-13],c=k(r[n-30],r[n-29]),f=I(r[n-30],r[n-29]),u=r[n-32],h=r[n-31];r[n]=l(i,s,o,a,c,f,u,h),r[n+1]=p(i,s,o,a,c,f,u,h)}},m.prototype._update=function(t,e){this._prepareBlock(t,e);var r=this.W,n=this.h[0],i=this.h[1],o=this.h[2],a=this.h[3],c=this.h[4],f=this.h[5],l=this.h[6],p=this.h[7],y=this.h[8],v=this.h[9],m=this.h[10],k=this.h[11],I=this.h[12],O=this.h[13],R=this.h[14],M=this.h[15];s(this.k.length===r.length);for(var q=0;q<r.length;q+=2){var B=R,C=M,N=T(y,v),P=j(y,v),L=g(y,0,m,0,I),D=w(0,v,0,k,0,O),F=this.k[q],z=this.k[q+1],U=r[q],H=r[q+1],V=b(B,C,N,P,L,D,F,z,U,H),G=_(B,C,N,P,L,D,F,z,U,H);B=E(n,i),C=x(n,i),N=A(n,0,o,0,c),P=S(0,i,0,a,0,f);var K=h(B,C,N,P),X=d(B,C,N,P);R=I,M=O,I=m,O=k,m=y,k=v,y=h(l,p,V,G),v=d(p,p,V,G),l=c,p=f,c=o,f=a,o=n,a=i,n=h(V,G,K,X),i=d(V,G,K,X)}u(this.h,0,n,i),u(this.h,2,o,a),u(this.h,4,c,f),u(this.h,6,l,p),u(this.h,8,y,v),u(this.h,10,m,k),u(this.h,12,I,O),u(this.h,14,R,M)},m.prototype._digest=function(t){return"hex"===t?n.toHex32(this.h,"big"):n.split32(this.h,"big")}},function(t,e,r){"use strict";var n=e;function i(t){return 1===t.length?"0"+t:t}function s(t){for(var e="",r=0;r<t.length;r++)e+=i(t[r].toString(16));return e}n.toArray=function(t,e){if(Array.isArray(t))return t.slice();if(!t)return[];var r=[];if("string"!=typeof t){for(var n=0;n<t.length;n++)r[n]=0|t[n];return r}if("hex"===e)for((t=t.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(t="0"+t),n=0;n<t.length;n+=2)r.push(parseInt(t[n]+t[n+1],16));else for(n=0;n<t.length;n++){var i=t.charCodeAt(n),s=i>>8,o=255&i;s?r.push(s,o):r.push(o)}return r},n.zero2=i,n.toHex=s,n.encode=function(t,e){return"hex"===e?s(t):t}},function(t,e){var r,n;t.exports=r={},n="undefined"==typeof WeakMap?null:new WeakMap,r.get=n?function(t){var e=n.get(t.buffer);return e||n.set(t.buffer,e=new DataView(t.buffer,0)),e}:function(t){return new DataView(t.buffer,0)}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=r(52);e.StreamFingate=n.default,e.default=n.default},function(t,e,r){"use strict";var n=this&&this.__decorate||function(t,e,r,n){var i,s=arguments.length,o=s<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(t,e,r,n);else for(var a=t.length-1;0<=a;a--)(i=t[a])&&(o=(s<3?i(o):3<s?i(e,r,o):i(e,r))||o);return 3<s&&o&&Object.defineProperty(e,r,o),o},i=this&&this.__param||function(t,e){return function(r,n){e(r,n,t)}},s=this&&this.__awaiter||function(t,e,r,n){return new(r=r||Promise)(function(i,s){function o(t){try{c(n.next(t))}catch(t){s(t)}}function a(t){try{c(n.throw(t))}catch(t){s(t)}}function c(t){t.done?i(t.value):new r(function(e){e(t.value)}).then(o,a)}c((n=n.apply(t,e||[])).next())})},o=this&&this.__generator||function(t,e){var r,n,i,s,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(s){return function(a){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;o;)try{if(r=1,n&&(i=2&s[0]?n.return:s[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,s[1])).done)return i;switch(n=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,n=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!(i=0<(i=o.trys).length&&i[i.length-1])&&(6===s[0]||2===s[0])){o=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){o.label=s[1];break}if(6===s[0]&&o.label<i[1]){o.label=i[1],i=s;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(s);break}i[2]&&o.ops.pop(),o.trys.pop();continue}s=e.call(t,o)}catch(t){s=[6,t],n=0}finally{r=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,a])}}};Object.defineProperty(e,"__esModule",{value:!0});var a=r(31),c=r(32),f=r(60),u=r(87),h=(Object.defineProperty(d.prototype,"trace",{set:function(t){this._trace=t},enumerable:!0,configurable:!0}),Object.defineProperty(d.prototype,"trusted",{set:function(t){this._trusted=t},enumerable:!0,configurable:!0}),Object.defineProperty(d.prototype,"localSign",{set:function(t){this._localSign=t},enumerable:!0,configurable:!0}),Object.defineProperty(d.prototype,"ping",{set:function(t){this._ping=t},enumerable:!0,configurable:!0}),Object.defineProperty(d.prototype,"currency",{set:function(t){this._currency=t},enumerable:!0,configurable:!0}),Object.defineProperty(d.prototype,"remote",{get:function(){return this._remote},enumerable:!0,configurable:!0}),d.isValidAddress=function(t){return c.isValidAddress(t)},d.isValidSecret=function(t){return c.isValidSecret(t)},d.getAddress=function(t){return c.getAddress(t)},d.prototype.init=function(){var t={local_signing:this._localSign,ping:this._ping,servers:[this._server],trace:this._trace,trusted:this._trusted};return this._remote=new f.Remote(t,!0),this},d.prototype.connect=function(){return this._remote.connect(),this},d.prototype.disconnect=function(){return this._remote.disconnect(),this},d.prototype.getBalance=function(t){var e=this;return new Promise(function(r,n){e._remote.requestAccountInfo({account:t},function(t,i){if(t)return n(t);var s=new a.default(i.account_data.Balance).dividedBy(Math.pow(10,e._decimals));return r(s.toString(10))})})},d.prototype.transfer=function(t,e,r,n){return s(this,void 0,void 0,function(){var i=this;return o(this,function(s){return[2,new Promise(function(s,o){var c,f=d.getAddress(t);if(i._currency!==i._native)return o(new Error("Only support transfer STM for now."));c=(c=new a.default(r).multipliedBy(Math.pow(10,i._decimals))).toString(10),i._remote.setSecret(f,t);var u=i._remote.createTransaction("Payment",{account:f,amount:c,destination:e});u.addMemo(encodeURI("memo"),encodeURI(JSON.stringify(n))),u.lastLedger(i._remote._ledger_current_index+3),u.submit(function(t,e){return t?o(t):"tesSUCCESS"===e.engine_result?s(e.tx_json.hash):o(new Error(e.engine_result_message))})})]})})},n([u.validate,i(0,u.isValidStreamSecret),i(1,u.isValidStreamAddress),i(2,u.isValidAmount),i(3,u.isValidMemo)],d.prototype,"transfer",null),d);function d(t){this.version="0.1.1",this._remote=null,this._trace=!1,this._trusted=!0,this._localSign=!0,this._ping=10,this._server=null,this._currency="STM",this._native="STM",this._decimals=6,this._server=t}e.default=h},function(t,e,r){"use strict";var n,i={cipher:{},hash:{},keyexchange:{},mode:{},misc:{},codec:{},exception:{corrupt:function(t){this.toString=function(){return"CORRUPT: "+this.message},this.message=t},invalid:function(t){this.toString=function(){return"INVALID: "+this.message},this.message=t},bug:function(t){this.toString=function(){return"BUG: "+this.message},this.message=t},notReady:function(t){this.toString=function(){return"NOT READY: "+this.message},this.message=t}}};function s(t){this.m=t,this.mt=t.limbs.length,this.mt2=2*this.mt,this.mp=t.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<<t.radix-15)-1}function o(t,e){var r=t.r.bitLength();return{r:i.bn.fromBits(i.bitArray.bitSlice(e,0,r)),s:i.bn.fromBits(i.bitArray.bitSlice(e,r,i.bitArray.bitLength(e)))}}function a(t,e,r,s,o){var a,c=t.r,f=t.field.modulus,u=1&(o&=3),h=o>>1;n=n||f.add(1).div(4);var d,l=(a=h?e.add(c):e).mul(a).mul(a).add(t.a.mul(a)).add(t.b).mod(f).powermodMontgomery(n,f),p=l.mod(2).equals(0);d=p&&!u||!p&&u?l:f.sub(l);var b=new i.ecc.point(t,a,d);if(!b.isValidPoint())throw new i.exception.corrupt("point R. Not a valid point on the curve. Cannot recover public key");var _=i.bn.fromBits(s),y=new i.bn(0).sub(_).mod(c),v=e.inverseMod(c),m=b.mult2(r,y,t.G).mult(v);if(!m.isValidPoint())throw new i.exception.corrupt("public_key_point. Not a valid point on the curve. Cannot recover public key");if(!function(t,e,r,n,s){var o=t.r;if(new i.bn(1).greaterEquals(r)||r.greaterEquals(new i.bn(o)))return!1;if(new i.bn(1).greaterEquals(n)||n.greaterEquals(new i.bn(o)))return!1;var a=n.inverseMod(o),c=e.mul(a).mod(o),f=r.mul(a).mod(o),u=t.G.mult2(c,f,s);return r.equals(u.x.mod(o))}(t,_,e,r,m))throw new i.exception.corrupt("cannot recover public key");return m}t.exports&&(t.exports=i),i.cipher.aes=function(t){this._tables[0][0][0]||this._precompute();var e,r,n,s,o,a=this._tables[0][4],c=this._tables[1],f=t.length,u=1;if(4!==f&&6!==f&&8!==f)throw new i.exception.invalid("invalid aes key size");for(this._key=[s=t.slice(0),o=[]],e=f;e<4*f+28;e++)n=s[e-1],(e%f==0||8===f&&e%f==4)&&(n=a[n>>>24]<<24^a[n>>16&255]<<16^a[n>>8&255]<<8^a[255&n],e%f==0&&(n=n<<8^n>>>24^u<<24,u=u<<1^283*(u>>7))),s[e]=s[e-f]^n;for(r=0;e;r++,e--)n=s[3&r?e:e-4],o[r]=e<=4||r<4?n:c[0][a[n>>>24]]^c[1][a[n>>16&255]]^c[2][a[n>>8&255]]^c[3][a[255&n]]},i.cipher.aes.prototype={encrypt:function(t){return this._crypt(t,0)},decrypt:function(t){return this._crypt(t,1)},_tables:[[[],[],[],[],[]],[[],[],[],[],[]]],_precompute:function(){var t,e,r,n,i,s,o,a,c=this._tables[0],f=this._tables[1],u=c[4],h=f[4],d=[],l=[];for(t=0;t<256;t++)l[(d[t]=t<<1^283*(t>>7))^t]=t;for(e=r=0;!u[e];e^=n||1,r=l[r]||1)for(s=(s=r^r<<1^r<<2^r<<3^r<<4)>>8^255&s^99,a=16843009*d[i=d[n=d[h[u[e]=s]=e]]]^65537*i^257*n^16843008*e,o=257*d[s]^16843008*s,t=0;t<4;t++)c[t][e]=o=o<<24^o>>>8,f[t][s]=a=a<<24^a>>>8;for(t=0;t<5;t++)c[t]=c[t].slice(0),f[t]=f[t].slice(0)},_crypt:function(t,e){if(4!==t.length)throw new i.exception.invalid("invalid aes block size");var r,n,s,o,a=this._key[e],c=t[0]^a[0],f=t[e?3:1]^a[1],u=t[2]^a[2],h=t[e?1:3]^a[3],d=a.length/4-2,l=4,p=[0,0,0,0],b=this._tables[e],_=b[0],y=b[1],v=b[2],m=b[3],g=b[4];for(o=0;o<d;o++)r=_[c>>>24]^y[f>>16&255]^v[u>>8&255]^m[255&h]^a[l],n=_[f>>>24]^y[u>>16&255]^v[h>>8&255]^m[255&c]^a[l+1],s=_[u>>>24]^y[h>>16&255]^v[c>>8&255]^m[255&f]^a[l+2],h=_[h>>>24]^y[c>>16&255]^v[f>>8&255]^m[255&u]^a[l+3],l+=4,c=r,f=n,u=s;for(o=0;o<4;o++)p[e?3&-o:o]=g[c>>>24]<<24^g[f>>16&255]<<16^g[u>>8&255]<<8^g[255&h]^a[l++],r=c,c=f,f=u,u=h,h=r;return p}},i.bitArray={bitSlice:function(t,e,r){return t=i.bitArray._shiftRight(t.slice(e/32),32-(31&e)).slice(1),void 0===r?t:i.bitArray.clamp(t,r-e)},extract:function(t,e,r){var n=Math.floor(-e-r&31);return(-32&(e+r-1^e)?t[e/32|0]<<32-n^t[e/32+1|0]>>>n:t[e/32|0]>>>n)&(1<<r)-1},concat:function(t,e){if(0===t.length||0===e.length)return t.concat(e);var r=t[t.length-1],n=i.bitArray.getPartial(r);return 32===n?t.concat(e):i.bitArray._shiftRight(e,n,0|r,t.slice(0,t.length-1))},bitLength:function(t){var e,r=t.length;return 0===r?0:(e=t[r-1],32*(r-1)+i.bitArray.getPartial(e))},clamp:function(t,e){if(32*t.length<e)return t;var r=(t=t.slice(0,Math.ceil(e/32))).length;return e&=31,0<r&&e&&(t[r-1]=i.bitArray.partial(e,t[r-1]&2147483648>>e-1,1)),t},partial:function(t,e,r){return 32===t?e:(r?0|e:e<<32-t)+1099511627776*t},getPartial:function(t){return Math.round(t/1099511627776)||32},equal:function(t,e){if(i.bitArray.bitLength(t)!==i.bitArray.bitLength(e))return!1;var r,n=0;for(r=0;r<t.length;r++)n|=t[r]^e[r];return 0===n},_shiftRight:function(t,e,r,n){var s,o,a;for(void 0===n&&(n=[]);32<=e;e-=32)n.push(r),r=0;if(0===e)return n.concat(t);for(s=0;s<t.length;s++)n.push(r|t[s]>>>e),r=t[s]<<32-e;return o=t.length?t[t.length-1]:0,a=i.bitArray.getPartial(o),n.push(i.bitArray.partial(e+a&31,32<e+a?r:n.pop(),1)),n},_xor4:function(t,e){return[t[0]^e[0],t[1]^e[1],t[2]^e[2],t[3]^e[3]]}},i.codec.utf8String={fromBits:function(t){var e,r,n="",s=i.bitArray.bitLength(t);for(e=0;e<s/8;e++)0==(3&e)&&(r=t[e/4]),n+=String.fromCharCode(r>>>24),r<<=8;return decodeURIComponent(escape(n))},toBits:function(t){t=unescape(encodeURIComponent(t));var e,r=[],n=0;for(e=0;e<t.length;e++)n=n<<8|t.charCodeAt(e),3==(3&e)&&(r.push(n),n=0);return 3&e&&r.push(i.bitArray.partial(8*(3&e),n)),r}},i.codec.hex={fromBits:function(t){var e,r="";for(e=0;e<t.length;e++)r+=(0xf00000000000+(0|t[e])).toString(16).substr(4);return r.substr(0,i.bitArray.bitLength(t)/4)},toBits:function(t){var e,r,n=[];for(r=(t=t.replace(/\s|0x/g,"")).length,t+="00000000",e=0;e<t.length;e+=8)n.push(0^parseInt(t.substr(e,8),16));return i.bitArray.clamp(n,4*r)}},i.codec.base64={_chars:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",fromBits:function(t,e,r){var n,s="",o=0,a=i.codec.base64._chars,c=0,f=i.bitArray.bitLength(t);for(r&&(a=a.substr(0,62)+"-_"),n=0;6*s.length<f;)s+=a.charAt((c^t[n]>>>o)>>>26),o<6?(c=t[n]<<6-o,o+=26,n++):(c<<=6,o-=6);for(;3&s.length&&!e;)s+="=";return s},toBits:function(t,e){t=t.replace(/\s|=/g,"");var r,n,s=[],o=0,a=i.codec.base64._chars,c=0;for(e&&(a=a.substr(0,62)+"-_"),r=0;r<t.length;r++){if((n=a.indexOf(t.charAt(r)))<0)throw new i.exception.invalid("this isn't base64!");26<o?(o-=26,s.push(c^n>>>o),c=n<<32-o):c^=n<<32-(o+=6)}return 56&o&&s.push(i.bitArray.partial(56&o,c,1)),s}},i.codec.base64url={fromBits:function(t){return i.codec.base64.fromBits(t,1,1)},toBits:function(t){return i.codec.base64.toBits(t,1)}},i.codec.bytes={fromBits:function(t){var e,r,n=[],s=i.bitArray.bitLength(t);for(e=0;e<s/8;e++)0==(3&e)&&(r=t[e/4]),n.push(r>>>24),r<<=8;return n},toBits:function(t){var e,r=[],n=0;for(e=0;e<t.length;e++)n=n<<8|t[e],3==(3&e)&&(r.push(n),n=0);return 3&e&&r.push(i.bitArray.partial(8*(3&e),n)),r}},i.hash.sha256=function(t){this._key[0]||this._precompute(),t?(this._h=t._h.slice(0),this._buffer=t._buffer.slice(0),this._length=t._length):this.reset()},i.hash.sha256.hash=function(t){return(new i.hash.sha256).update(t).finalize()},i.hash.sha256.prototype={blockSize:512,reset:function(){return this._h=this._init.slice(0),this._buffer=[],this._length=0,this},update:function(t){"string"==typeof t&&(t=i.codec.utf8String.toBits(t));var e,r=this._buffer=i.bitArray.concat(this._buffer,t),n=this._length,s=this._length=n+i.bitArray.bitLength(t);for(e=512+n&-512;e<=s;e+=512)this._block(r.splice(0,16));return this},finalize:function(){var t,e=this._buffer,r=this._h;for(t=(e=i.bitArray.concat(e,[i.bitArray.partial(1,1)])).length+2;15&t;t++)e.push(0);for(e.push(Math.floor(this._length/4294967296)),e.push(0|this._length);e.length;)this._block(e.splice(0,16));return this.reset(),r},_init:[],_key:[],_precompute:function(){var t,e=0,r=2;function n(t){return 4294967296*(t-Math.floor(t))|0}t:for(;e<64;r++){for(t=2;t*t<=r;t++)if(r%t==0)continue t;e<8&&(this._init[e]=n(Math.pow(r,.5))),this._key[e]=n(Math.pow(r,1/3)),e++}},_block:function(t){var e,r,n,i,s=t.slice(0),o=this._h,a=this._key,c=o[0],f=o[1],u=o[2],h=o[3],d=o[4],l=o[5],p=o[6],b=o[7];for(e=0;e<64;e++)r=(r=e<16?s[e]:(n=s[e+1&15],i=s[e+14&15],s[15&e]=(n>>>7^n>>>18^n>>>3^n<<25^n<<14)+(i>>>17^i>>>19^i>>>10^i<<15^i<<13)+s[15&e]+s[e+9&15]|0))+b+(d>>>6^d>>>11^d>>>25^d<<26^d<<21^d<<7)+(p^d&(l^p))+a[e],b=p,p=l,l=d,d=h+r|0,h=u,u=f,c=r+((f=c)&u^h&(f^u))+(f>>>2^f>>>13^f>>>22^f<<30^f<<19^f<<10)|0;o[0]=o[0]+c|0,o[1]=o[1]+f|0,o[2]=o[2]+u|0,o[3]=o[3]+h|0,o[4]=o[4]+d|0,o[5]=o[5]+l|0,o[6]=o[6]+p|0,o[7]=o[7]+b|0}},i.hash.sha512=function(t){this._key[0]||this._precompute(),t?(this._h=t._h.slice(0),this._buffer=t._buffer.slice(0),this._length=t._length):this.reset()},i.hash.sha512.hash=function(t){return(new i.hash.sha512).update(t).finalize()},i.hash.sha512.prototype={blockSize:1024,reset:function(){return this._h=this._init.slice(0),this._buffer=[],this._length=0,this},update:function(t){"string"==typeof t&&(t=i.codec.utf8String.toBits(t));var e,r=this._buffer=i.bitArray.concat(this._buffer,t),n=this._length,s=this._length=n+i.bitArray.bitLength(t);for(e=1024+n&-1024;e<=s;e+=1024)this._block(r.splice(0,32));return this},finalize:function(){var t,e=this._buffer,r=this._h;for(t=(e=i.bitArray.concat(e,[i.bitArray.partial(1,1)])).length+4;31&t;t++)e.push(0);for(e.push(0),e.push(0),e.push(Math.floor(this._length/4294967296)),e.push(0|this._length);e.length;)this._block(e.splice(0,32));return this.reset(),r},_init:[],_initr:[12372232,13281083,9762859,1914609,15106769,4090911,4308331,8266105],_key:[],_keyr:[2666018,15689165,5061423,9034684,4764984,380953,1658779,7176472,197186,7368638,14987916,16757986,8096111,1480369,13046325,6891156,15813330,5187043,9229749,11312229,2818677,10937475,4324308,1135541,6741931,11809296,16458047,15666916,11046850,698149,229999,945776,13774844,2541862,12856045,9810911,11494366,7844520,15576806,8533307,15795044,4337665,16291729,5553712,15684120,6662416,7413802,12308920,13816008,4303699,9366425,10176680,13195875,4295371,6546291,11712675,15708924,1519456,15772530,6568428,6495784,8568297,13007125,7492395,2515356,12632583,14740254,7262584,1535930,13146278,16321966,1853211,294276,13051027,13221564,1051980,4080310,6651434,14088940,4675607],_precompute:function(){var t,e=0,r=2;function n(t){return 4294967296*(t-Math.floor(t))|0}function i(t){return 1099511627776*(t-Math.floor(t))&255}t:for(;e<80;r++){for(t=2;t*t<=r;t++)if(r%t==0)continue t;e<8&&(this._init[2*e]=n(Math.pow(r,.5)),this._init[2*e+1]=i(Math.pow(r,.5))<<24|this._initr[e]),this._key[2*e]=n(Math.pow(r,1/3)),this._key[2*e+1]=i(Math.pow(r,1/3))<<24|this._keyr[e],e++}},_block:function(t){var e,r,n,i=t.slice(0),s=this._h,o=this._key,a=s[0],c=s[1],f=s[2],u=s[3],h=s[4],d=s[5],l=s[6],p=s[7],b=s[8],_=s[9],y=s[10],v=s[11],m=s[12],g=s[13],w=s[14],A=s[15],S=a,E=c,x=f,T=u,j=h,k=d,I=l,O=p,R=b,M=_,q=y,B=v,C=m,N=g,P=w,L=A;for(e=0;e<80;e++){if(e<16)r=i[2*e],n=i[2*e+1];else{var D=i[2*(e-15)],F=i[2*(e-15)+1],z=(F<<31|D>>>1)^(F<<24|D>>>8)^D>>>7,U=(D<<31|F>>>1)^(D<<24|F>>>8)^(D<<25|F>>>7),H=i[2*(e-2)],V=i[2*(e-2)+1],G=(V<<13|H>>>19)^(H<<3|V>>>29)^H>>>6,K=(H<<13|V>>>19)^(V<<3|H>>>29)^(H<<26|V>>>6),X=i[2*(e-7)],Y=i[2*(e-7)+1],J=i[2*(e-16)],Z=i[2*(e-16)+1];r=z+X+((n=U+Y)>>>0<U>>>0?1:0),r+=G+((n+=K)>>>0<K>>>0?1:0),r+=J+((n+=Z)>>>0<Z>>>0?1:0)}i[2*e]=r|=0,i[2*e+1]=n|=0;var W=R&q^~R&C,$=M&B^~M&N,Q=S&x^S&j^x&j,tt=E&T^E&k^T&k,et=(E<<4|S>>>28)^(S<<30|E>>>2)^(S<<25|E>>>7),rt=(S<<4|E>>>28)^(E<<30|S>>>2)^(E<<25|S>>>7),nt=(M<<18|R>>>14)^(M<<14|R>>>18)^(R<<23|M>>>9),it=(R<<18|M>>>14)^(R<<14|M>>>18)^(M<<23|R>>>9),st=o[2*e],ot=o[2*e+1],at=L+it,ct=P+nt+(at>>>0<L>>>0?1:0);ct+=W+((at+=$)>>>0<$>>>0?1:0),ct+=st+((at+=ot)>>>0<ot>>>0?1:0);var ft=rt+tt;P=C,L=N,C=q,N=B,q=R,B=M,R=I+(ct+=r+((at+=n)>>>0<n>>>0?1:0))+((M=O+at|0)>>>0<O>>>0?1:0)|0,I=j,O=k,j=x,k=T,x=S,T=E,S=ct+(et+Q+(ft>>>0<rt>>>0?1:0))+((E=at+ft|0)>>>0<at>>>0?1:0)|0}c=s[1]=c+E|0,s[0]=a+S+(c>>>0<E>>>0?1:0)|0,u=s[3]=u+T|0,s[2]=f+x+(u>>>0<T>>>0?1:0)|0,d=s[5]=d+k|0,s[4]=h+j+(d>>>0<k>>>0?1:0)|0,p=s[7]=p+O|0,s[6]=l+I+(p>>>0<O>>>0?1:0)|0,_=s[9]=_+M|0,s[8]=b+R+(_>>>0<M>>>0?1:0)|0,v=s[11]=v+B|0,s[10]=y+q+(v>>>0<B>>>0?1:0)|0,g=s[13]=g+N|0,s[12]=m+C+(g>>>0<N>>>0?1:0)|0,A=s[15]=A+L|0,s[14]=w+P+(A>>>0<L>>>0?1:0)|0}},i.hash.sha1=function(t){t?(this._h=t._h.slice(0),this._buffer=t._buffer.slice(0),this._length=t._length):this.reset()},i.hash.sha1.hash=function(t){return(new i.hash.sha1).update(t).finalize()},i.hash.sha1.prototype={blockSize:512,reset:function(){return this._h=this._init.slice(0),this._buffer=[],this._length=0,this},update:function(t){"string"==typeof t&&(t=i.codec.utf8String.toBits(t));var e,r=this._buffer=i.bitArray.concat(this._buffer,t),n=this._length,s=this._length=n+i.bitArray.bitLength(t);for(e=this.blockSize+n&-this.blockSize;e<=s;e+=this.blockSize)this._block(r.splice(0,16));return this},finalize:function(){var t,e=this._buffer,r=this._h;for(t=(e=i.bitArray.concat(e,[i.bitArray.partial(1,1)])).length+2;15&t;t++)e.push(0);for(e.push(Math.floor(this._length/4294967296)),e.push(0|this._length);e.length;)this._block(e.splice(0,16));return this.reset(),r},_init:[1732584193,4023233417,2562383102,271733878,3285377520],_key:[1518500249,1859775393,2400959708,3395469782],_f:function(t,e,r,n){return t<=19?e&r|~e&n:t<=39?e^r^n:t<=59?e&r|e&n|r&n:t<=79?e^r^n:void 0},_S:function(t,e){return e<<t|e>>>32-t},_block:function(t){var e,r,n,i,s,o,a,c=t.slice(0),f=this._h;for(this._key,n=f[0],i=f[1],s=f[2],o=f[3],a=f[4],e=0;e<=79;e++)16<=e&&(c[e]=this._S(1,c[e-3]^c[e-8]^c[e-14]^c[e-16])),r=this._S(5,n)+this._f(e,i,s,o)+a+c[e]+this._key[Math.floor(e/20)]|0,a=o,o=s,s=this._S(30,i),i=n,n=r;f[0]=f[0]+n|0,f[1]=f[1]+i|0,f[2]=f[2]+s|0,f[3]=f[3]+o|0,f[4]=f[4]+a|0}},i.mode.ccm={name:"ccm",encrypt:function(t,e,r,n,s){var o,a,c=e.slice(0),f=i.bitArray,u=f.bitLength(r)/8,h=f.bitLength(c)/8;if(s=s||64,n=n||[],u<7)throw new i.exception.invalid("ccm: iv must be at least 7 bytes");for(o=2;o<4&&h>>>8*o;o++);return o<15-u&&(o=15-u),r=f.clamp(r,8*(15-o)),a=i.mode.ccm._computeTag(t,e,r,n,s,o),c=i.mode.ccm._ctrMode(t,c,r,a,s,o),f.concat(c.data,c.tag)},decrypt:function(t,e,r,n,s){s=s||64,n=n||[];var o,a,c=i.bitArray,f=c.bitLength(r)/8,u=c.bitLength(e),h=c.clamp(e,u-s),d=c.bitSlice(e,u-s);if(u=(u-s)/8,f<7)throw new i.exception.invalid("ccm: iv must be at least 7 bytes");for(o=2;o<4&&u>>>8*o;o++);if(o<15-f&&(o=15-f),r=c.clamp(r,8*(15-o)),h=i.mode.ccm._ctrMode(t,h,r,d,s,o),a=i.mode.ccm._computeTag(t,h.data,r,n,s,o),!c.equal(h.tag,a))throw new i.exception.corrupt("ccm: tag doesn't match");return h.data},_computeTag:function(t,e,r,n,s,o){var a,c,f,u=[],h=i.bitArray,d=h._xor4;if((s/=8)%2||s<4||16<s)throw new i.exception.invalid("ccm: invalid tag length");if(4294967295<n.length||4294967295<e.length)throw new i.exception.bug("ccm: can't deal with 4GiB or more data");if(a=[h.partial(8,(n.length?64:0)|s-2<<2|o-1)],(a=h.concat(a,r))[3]|=h.bitLength(e)/8,a=t.encrypt(a),n.length)for((c=h.bitLength(n)/8)<=65279?u=[h.partial(16,c)]:c<=4294967295&&(u=h.concat([h.partial(16,65534)],[c])),u=h.concat(u,n),f=0;f<u.length;f+=4)a=t.encrypt(d(a,u.slice(f,f+4).concat([0,0,0])));for(f=0;f<e.length;f+=4)a=t.encrypt(d(a,e.slice(f,f+4).concat([0,0,0])));return h.clamp(a,8*s)},_ctrMode:function(t,e,r,n,s,o){var a,c,f,u=i.bitArray,h=u._xor4,d=e.length,l=u.bitLength(e);if(f=u.concat([u.partial(8,o-1)],r).concat([0,0,0]).slice(0,4),n=u.bitSlice(h(n,t.encrypt(f)),0,s),!d)return{tag:n,data:[]};for(c=0;c<d;c+=4)f[3]++,a=t.encrypt(f),e[c]^=a[0],e[c+1]^=a[1],e[c+2]^=a[2],e[c+3]^=a[3];return{tag:n,data:u.clamp(e,l)}}},i.misc.hmac=function(t,e){this._hash=e=e||i.hash.sha256;var r,n=[[],[]],s=e.prototype.blockSize/32;for(this._baseHash=[new e,new e],t.length>s&&(t=e.hash(t)),r=0;r<s;r++)n[0][r]=909522486^t[r],n[1][r]=1549556828^t[r];this._baseHash[0].update(n[0]),this._baseHash[1].update(n[1])},i.misc.hmac.prototype.encrypt=i.misc.hmac.prototype.mac=function(t){var e=new this._hash(this._baseHash[0]).update(t).finalize();return new this._hash(this._baseHash[1]).update(e).finalize()},i.misc.pbkdf2=function(t,e,r,n,s){if(r=r||1e3,n<0||r<0)throw i.exception.invalid("invalid params to pbkdf2");"string"==typeof t&&(t=i.codec.utf8String.toBits(t));var o,a,c,f,u,h=new(s=s||i.misc.hmac)(t),d=[],l=i.bitArray;for(u=1;32*d.length<(n||1);u++){for(o=a=h.encrypt(l.concat(e,[u])),c=1;c<r;c++)for(a=h.encrypt(a),f=0;f<a.length;f++)o[f]^=a[f];d=d.concat(o)}return n&&(d=l.clamp(d,n)),d},i.prng=function(t){this._pools=[new i.hash.sha256],this._poolEntropy=[0],this._reseedCount=0,this._robins={},this._eventId=0,this._collectorIds={},this._collectorIdNext=0,this._strength=0,this._poolStrength=0,this._nextReseed=0,this._key=[0,0,0,0,0,0,0,0],this._counter=[0,0,0,0],this._cipher=void 0,this._defaultParanoia=t,this._collectorsStarted=!1,this._callbacks={progress:{},seeded:{}},this._callbackI=0,this._NOT_READY=0,this._READY=1,this._REQUIRES_RESEED=2,this._MAX_WORDS_PER_BURST=65536,this._PARANOIA_LEVELS=[0,48,64,96,128,192,256,384,512,768,1024],this._MILLISECONDS_PER_RESEED=3e4,this._BITS_PER_RESEED=80},i.prng.prototype={randomWords:function(t,e){var r,n,s=[],o=this.isReady(e);if(o===this._NOT_READY)throw new i.exception.notReady("generator isn't seeded");for(o&this._REQUIRES_RESEED&&this._reseedFromPools(!(o&this._READY)),r=0;r<t;r+=4)(r+1)%this._MAX_WORDS_PER_BURST==0&&this._gate(),n=this._gen4words(),s.push(n[0],n[1],n[2],n[3]);return this._gate(),s.slice(0,t)},setDefaultParanoia:function(t){this._defaultParanoia=t},addEntropy:function(t,e,r){r=r||"user";var n,s,o,a=(new Date).valueOf(),c=this._robins[r],f=this.isReady(),u=0;switch(void 0===(n=this._collectorIds[r])&&(n=this._collectorIds[r]=this._collectorIdNext++),void 0===c&&(c=this._robins[r]=0),this._robins[r]=(this._robins[r]+1)%this._pools.length,typeof t){case"number":void 0===e&&(e=1),this._pools[c].update([n,this._eventId++,1,e,a,1,0|t]);break;case"object":var h=Object.prototype.toString.call(t);if("[object Uint32Array]"===h){for(o=[],s=0;s<t.length;s++)o.push(t[s]);t=o}else for("[object Array]"!==h&&(u=1),s=0;s<t.length&&!u;s++)"number"!=typeof t[s]&&(u=1);if(!u){if(void 0===e)for(s=e=0;s<t.length;s++)for(o=t[s];0<o;)e++,o>>>=1;this._pools[c].update([n,this._eventId++,2,e,a,t.length].concat(t))}break;case"string":void 0===e&&(e=t.length),this._pools[c].update([n,this._eventId++,3,e,a,t.length]),this._pools[c].update(t);break;default:u=1}if(u)throw new i.exception.bug("random: addEntropy only supports number, array of numbers or string");this._poolEntropy[c]+=e,this._poolStrength+=e,f===this._NOT_READY&&(this.isReady()!==this._NOT_READY&&this._fireEvent("seeded",Math.max(this._strength,this._poolStrength)),this._fireEvent("progress",this.getProgress()))},isReady:function(t){var e=this._PARANOIA_LEVELS[void 0!==t?t:this._defaultParanoia];return this._strength&&this._strength>=e?this._poolEntropy[0]>this._BITS_PER_RESEED&&(new Date).valueOf()>this._nextReseed?this._REQUIRES_RESEED|this._READY:this._READY:this._poolStrength>=e?this._REQUIRES_RESEED|this._NOT_READY:this._NOT_READY},getProgress:function(t){var e=this._PARANOIA_LEVELS[t||this._defaultParanoia];return this._strength>=e?1:this._poolStrength>e?1:this._poolStrength/e},startCollectors:function(){if(!this._collectorsStarted){if(window.addEventListener)window.addEventListener("load",this._loadTimeCollector,!1),window.addEventListener("mousemove",this._mouseCollector,!1);else{if(!document.attachEvent)throw new i.exception.bug("can't attach event");document.attachEvent("onload",this._loadTimeCollector),document.attachEvent("onmousemove",this._mouseCollector)}this._collectorsStarted=!0}},stopCollectors:function(){this._collectorsStarted&&(window.removeEventListener?(window.removeEventListener("load",this._loadTimeCollector,!1),window.removeEventListener("mousemove",this._mouseCollector,!1)):window.detachEvent&&(window.detachEvent("onload",this._loadTimeCollector),window.detachEvent("onmousemove",this._mouseCollector)),this._collectorsStarted=!1)},addEventListener:function(t,e){this._callbacks[t][this._callbackI++]=e},removeEventListener:function(t,e){var r,n,i=this._callbacks[t],s=[];for(n in i)i.hasOwnProperty(n)&&i[n]===e&&s.push(n);for(r=0;r<s.length;r++)delete i[n=s[r]]},_gen4words:function(){for(var t=0;t<4&&(this._counter[t]=this._counter[t]+1|0,!this._counter[t]);t++);return this._cipher.encrypt(this._counter)},_gate:function(){this._key=this._gen4words().concat(this._gen4words()),this._cipher=new i.cipher.aes(this._key)},_reseed:function(t){this._key=i.hash.sha256.hash(this._key.concat(t)),this._cipher=new i.cipher.aes(this._key);for(var e=0;e<4&&(this._counter[e]=this._counter[e]+1|0,!this._counter[e]);e++);},_reseedFromPools:function(t){var e,r=[],n=0;for(this._nextReseed=r[0]=(new Date).valueOf()+this._MILLISECONDS_PER_RESEED,e=0;e<16;e++)r.push(4294967296*Math.random()|0);for(e=0;e<this._pools.length&&(r=r.concat(this._pools[e].finalize()),n+=this._poolEntropy[e],this._poolEntropy[e]=0,t||!(this._reseedCount&1<<e));e++);this._reseedCount>=1<<this._pools.length&&(this._pools.push(new i.hash.sha256),this._poolEntropy.push(0)),this._poolStrength-=n,n>this._strength&&(this._strength=n),this._reseedCount++,this._reseed(r)},_mouseCollector:function(t){var e=t.x||t.clientX||t.offsetX||0,r=t.y||t.clientY||t.offsetY||0;i.random.addEntropy([e,r],2,"mouse")},_loadTimeCollector:function(t){i.random.addEntropy((new Date).valueOf(),2,"loadtime")},_fireEvent:function(t,e){var r,n=i.random._callbacks[t],s=[];for(r in n)n.hasOwnProperty(r)&&s.push(n[r]);for(r=0;r<s.length;r++)s[r](e)}},i.random=new i.prng(6),function(){try{var t=new Uint32Array(32);crypto.getRandomValues(t),i.random.addEntropy(t,1024,"crypto.getRandomValues")}catch(t){}}(),i.json={defaults:{v:1,iter:1e3,ks:128,ts:64,mode:"ccm",adata:"",cipher:"aes"},encrypt:function(t,e,r,n){r=r||{},n=n||{};var s,o,a,c=i.json,f=c._add({iv:i.random.randomWords(4,0)},c.defaults);if(c._add(f,r),a=f.adata,"string"==typeof f.salt&&(f.salt=i.codec.base64.toBits(f.salt)),"string"==typeof f.iv&&(f.iv=i.codec.base64.toBits(f.iv)),!i.mode[f.mode]||!i.cipher[f.cipher]||"string"==typeof t&&f.iter<=100||64!==f.ts&&96!==f.ts&&128!==f.ts||128!==f.ks&&192!==f.ks&&256!==f.ks||f.iv.length<2||4<f.iv.length)throw new i.exception.invalid("json encrypt: invalid parameters");return"string"==typeof t?(t=(s=i.misc.cachedPbkdf2(t,f)).key.slice(0,f.ks/32),f.salt=s.salt):i.ecc&&t instanceof i.ecc.elGamal.publicKey&&(s=t.kem(),f.kemtag=s.tag,t=s.key.slice(0,f.ks/32)),"string"==typeof e&&(e=i.codec.utf8String.toBits(e)),"string"==typeof a&&(a=i.codec.utf8String.toBits(a)),o=new i.cipher[f.cipher](t),c._add(n,f),n.key=t,f.ct=i.mode[f.mode].encrypt(o,e,f.iv,a,f.ts),c.encode(f)},decrypt:function(t,e,r,n){r=r||{},n=n||{};var s,o,a,c=i.json,f=c._add(c._add(c._add({},c.defaults),c.decode(e)),r,!0),u=f.adata;if("string"==typeof f.salt&&(f.salt=i.codec.base64.toBits(f.salt)),"string"==typeof f.iv&&(f.iv=i.codec.base64.toBits(f.iv)),!i.mode[f.mode]||!i.cipher[f.cipher]||"string"==typeof t&&f.iter<=100||64!==f.ts&&96!==f.ts&&128!==f.ts||128!==f.ks&&192!==f.ks&&256!==f.ks||!f.iv||f.iv.length<2||4<f.iv.length)throw new i.exception.invalid("json decrypt: invalid parameters");return"string"==typeof t?(t=(o=i.misc.cachedPbkdf2(t,f)).key.slice(0,f.ks/32),f.salt=o.salt):i.ecc&&t instanceof i.ecc.elGamal.secretKey&&(t=t.unkem(i.codec.base64.toBits(f.kemtag)).slice(0,f.ks/32)),"string"==typeof u&&(u=i.codec.utf8String.toBits(u)),a=new i.cipher[f.cipher](t),s=i.mode[f.mode].decrypt(a,f.ct,f.iv,u,f.ts),c._add(n,f),n.key=t,i.codec.utf8String.fromBits(s)},encode:function(t){var e,r="{",n="";for(e in t)if(t.hasOwnProperty(e)){if(!e.match(/^[a-z0-9]+$/i))throw new i.exception.invalid("json encode: invalid property name");switch(r+=n+'"'+e+'":',n=",",typeof t[e]){case"number":case"boolean":r+=t[e];break;case"string":r+='"'+escape(t[e])+'"';break;case"object":r+='"'+i.codec.base64.fromBits(t[e],0)+'"';break;default:throw new i.exception.bug("json encode: unsupported type")}}return r+"}"},decode:function(t){if(!(t=t.replace(/\s/g,"")).match(/^\{.*\}$/))throw new i.exception.invalid("json decode: this isn't json!");var e,r,n=t.replace(/^\{|\}$/g,"").split(/,/),s={};for(e=0;e<n.length;e++){if(!(r=n[e].match(/^(?:(["']?)([a-z][a-z0-9]*)\1):(?:(\d+)|"([a-z0-9+\/%*_.@=\-]*)")$/i)))throw new i.exception.invalid("json decode: this isn't json!");r[3]?s[r[2]]=parseInt(r[3],10):s[r[2]]=r[2].match(/^(ct|salt|iv)$/)?i.codec.base64.toBits(r[4]):unescape(r[4])}return s},_add:function(t,e,r){if(void 0===t&&(t={}),void 0===e)return t;var n;for(n in e)if(e.hasOwnProperty(n)){if(r&&void 0!==t[n]&&t[n]!==e[n])throw new i.exception.invalid("required parameter overridden");t[n]=e[n]}return t},_subtract:function(t,e){var r,n={};for(r in t)t.hasOwnProperty(r)&&t[r]!==e[r]&&(n[r]=t[r]);return n},_filter:function(t,e){var r,n={};for(r=0;r<e.length;r++)void 0!==t[e[r]]&&(n[e[r]]=t[e[r]]);return n}},i.encrypt=i.json.encrypt,i.decrypt=i.json.decrypt,i.misc._pbkdf2Cache={},i.misc.cachedPbkdf2=function(t,e){var r,n,s,o,a=i.misc._pbkdf2Cache;return o=(e=e||{}).iter||1e3,(r=(n=a[t]=a[t]||{})[o]=n[o]||{firstSalt:e.salt&&e.salt.length?e.salt.slice(0):i.random.randomWords(2,0)})[s=void 0===e.salt?r.firstSalt:e.salt]=r[s]||i.misc.pbkdf2(t,s,e.iter),{key:r[s].slice(0),salt:s.slice(0)}},i.bn=function(t){this.initWith(t)},i.bn.prototype={radix:24,maxMul:8,_class:i.bn,copy:function(){return new this._class(this)},initWith:function(t){var e,r=0;switch(typeof t){case"object":this.limbs=t.limbs.slice(0);break;case"number":this.limbs=[t],this.normalize();break;case"string":for(t=t.replace(/^0x/,""),this.limbs=[],e=this.radix/4,r=0;r<t.length;r+=e)this.limbs.push(parseInt(t.substring(Math.max(t.length-r-e,0),t.length-r),16));break;default:this.limbs=[0]}return this},equals:function(t){"number"==typeof t&&(t=new this._class(t));var e,r=0;for(this.fullReduce(),t.fullReduce(),e=0;e<this.limbs.length||e<t.limbs.length;e++)r|=this.getLimb(e)^t.getLimb(e);return 0===r},getLimb:function(t){return t>=this.limbs.length?0:this.limbs[t]},greaterEquals:function(t){"number"==typeof t&&(t=new this._class(t));var e,r,n,i=0,s=0;for(e=Math.max(this.limbs.length,t.limbs.length)-1;0<=e;e--)i|=(r=this.getLimb(e))-(n=t.getLimb(e))&~(s|=n-r&~i);return(s|~i)>>>31},toString:function(){this.fullReduce();var t,e,r="",n=this.limbs;for(t=0;t<this.limbs.length;t++){for(e=n[t].toString(16);t<this.limbs.length-1&&e.length<6;)e="0"+e;r=e+r}return"0x"+r},addM:function(t){"object"!=typeof t&&(t=new this._class(t));var e,r=this.limbs,n=t.limbs;for(e=r.length;e<n.length;e++)r[e]=0;for(e=0;e<n.length;e++)r[e]+=n[e];return this},doubleM:function(){var t,e,r=0,n=this.radix,i=this.radixMask,s=this.limbs;for(t=0;t<s.length;t++)e=(e=s[t])+e+r,s[t]=e&i,r=e>>n;return r&&s.push(r),this},halveM:function(){var t,e,r=0,n=this.radix,i=this.limbs;for(t=i.length-1;0<=t;t--)e=i[t],i[t]=e+r>>1,r=(1&e)<<n;return i[i.length-1]||i.pop(),this},subM:function(t){"object"!=typeof t&&(t=new this._class(t));var e,r=this.limbs,n=t.limbs;for(e=r.length;e<n.length;e++)r[e]=0;for(e=0;e<n.length;e++)r[e]-=n[e];return this},mod:function(t){var e=!this.greaterEquals(new i.bn(0));t=new i.bn(t).normalize();var r=new i.bn(this).normalize(),n=0;for(e&&(r=new i.bn(0).subM(r).normalize());r.greaterEquals(t);n++)t.doubleM();for(e&&(r=t.sub(r).normalize());0<n;n--)t.halveM(),r.greaterEquals(t)&&r.subM(t).normalize();return r.trim()},inverseMod:function(t){var e,r,n=new i.bn(1),s=new i.bn(0),o=new i.bn(this),a=new i.bn(t),c=1;if(!(1&t.limbs[0]))throw new i.exception.invalid("inverseMod: p must be odd");do{for(1&o.limbs[0]&&(o.greaterEquals(a)||(e=o,o=a,a=e,e=n,n=s,s=e),o.subM(a),o.normalize(),n.greaterEquals(s)||n.addM(t),n.subM(s)),o.halveM(),1&n.limbs[0]&&n.addM(t),n.normalize(),n.halveM(),r=c=0;r<o.limbs.length;r++)c|=o.limbs[r]}while(c);if(!a.equals(1))throw new i.exception.invalid("inverseMod: p and x must be relatively prime");return s},add:function(t){return this.copy().addM(t)},sub:function(t){return this.copy().subM(t)},mul:function(t){"number"==typeof t&&(t=new this._class(t));var e,r,n,i=this.limbs,s=t.limbs,o=i.length,a=s.length,c=new this._class,f=c.limbs,u=this.maxMul;for(e=0;e<this.limbs.length+t.limbs.length+1;e++)f[e]=0;for(e=0;e<o;e++){for(n=i[e],r=0;r<a;r++)f[e+r]+=n*s[r];--u||(u=this.maxMul,c.cnormalize())}return c.cnormalize().reduce()},square:function(){return this.mul(this)},power:function(t){"number"==typeof t?t=[t]:void 0!==t.limbs&&(t=t.normalize().limbs);var e,r,n=new this._class(1),i=this;for(e=0;e<t.length;e++)for(r=0;r<this.radix;r++)t[e]&1<<r&&(n=n.mul(i)),i=i.square();return n},mulmod:function(t,e){return this.mod(e).mul(t.mod(e)).mod(e)},powermod:function(t,e){for(var r=new i.bn(1),n=new i.bn(this),s=new i.bn(t);1&s.limbs[0]&&(r=r.mulmod(n,e)),s.halveM(),!s.equals(0);)n=n.mulmod(n,e);return r.normalize().reduce()},trim:function(){for(var t,e=this.limbs;t=e.pop(),e.length&&0===t;);return e.push(t),this},reduce:function(){return this},fullReduce:function(){return this.normalize()},normalize:function(){var t,e,r=0,n=(this.placeVal,this.ipv),i=this.limbs,s=i.length,o=this.radixMask;for(t=0;t<s||0!==r&&-1!==r;t++)r=((e=(i[t]||0)+r)-(i[t]=e&o))*n;return-1===r&&(i[t-1]-=this.placeVal),this},cnormalize:function(){var t,e,r=0,n=this.ipv,i=this.limbs,s=i.length,o=this.radixMask;for(t=0;t<s-1;t++)r=((e=i[t]+r)-(i[t]=e&o))*n;return i[t]+=r,this},toBits:function(t){this.fullReduce(),t=t||this.exponent||this.bitLength();var e=Math.floor((t-1)/24),r=i.bitArray,n=(t+7&-8)%this.radix||this.radix,s=[r.partial(n,this.getLimb(e))];for(e--;0<=e;e--)s=r.concat(s,[r.partial(Math.min(this.radix,t),this.getLimb(e))]),t-=this.radix;return s},bitLength:function(){this.fullReduce();for(var t=this.radix*(this.limbs.length-1),e=this.limbs[this.limbs.length-1];e;e>>>=1)t++;return t+7&-8}},i.bn.fromBits=function(t){var e=new this,r=[],n=i.bitArray,s=this.prototype,o=Math.min(this.bitLength||4294967296,n.bitLength(t)),a=o%s.radix||s.radix;for(r[0]=n.extract(t,0,a);a<o;a+=s.radix)r.unshift(n.extract(t,a,s.radix));return e.limbs=r,e},i.bn.prototype.ipv=1/(i.bn.prototype.placeVal=Math.pow(2,i.bn.prototype.radix)),i.bn.prototype.radixMask=(1<<i.bn.prototype.radix)-1,i.bn.pseudoMersennePrime=function(t,e){function r(t){this.initWith(t)}var n,s,o,a=r.prototype=new i.bn;for(o=a.modOffset=Math.ceil(s=t/a.radix),a.exponent=t,a.offset=[],a.factor=[],a.minOffset=o,a.fullMask=0,a.fullOffset=[],a.fullFactor=[],a.modulus=r.modulus=new i.bn(Math.pow(2,t)),a.fullMask=0|-Math.pow(2,t%a.radix),n=0;n<e.length;n++)a.offset[n]=Math.floor(e[n][0]/a.radix-s),a.fullOffset[n]=Math.ceil(e[n][0]/a.radix-s),a.factor[n]=e[n][1]*Math.pow(.5,t-e[n][0]+a.offset[n]*a.radix),a.fullFactor[n]=e[n][1]*Math.pow(.5,t-e[n][0]+a.fullOffset[n]*a.radix),a.modulus.addM(new i.bn(Math.pow(2,e[n][0])*e[n][1])),a.minOffset=Math.min(a.minOffset,-a.offset[n]);return a._class=r,a.modulus.cnormalize(),a.reduce=function(){var t,e,r,n,i=this.modOffset,s=this.limbs,o=this.offset,a=this.offset.length,c=this.factor;for(t=this.minOffset;s.length>i;){for(r=s.pop(),n=s.length,e=0;e<a;e++)s[n+o[e]]-=c[e]*r;--t||(s.push(0),this.cnormalize(),t=this.minOffset)}return this.cnormalize(),this},a._strongReduce=-1===a.fullMask?a.reduce:function(){var t,e,r=this.limbs,n=r.length-1;if(this.reduce(),n==this.modOffset-1){for(e=r[n]&this.fullMask,r[n]-=e,t=0;t<this.fullOffset.length;t++)r[n+this.fullOffset[t]]-=this.fullFactor[t]*e;this.normalize()}},a.fullReduce=function(){var t,e;for(this._strongReduce(),this.addM(this.modulus),this.addM(this.modulus),this.normalize(),this._strongReduce(),e=this.limbs.length;e<this.modOffset;e++)this.limbs[e]=0;for(t=this.greaterEquals(this.modulus),e=0;e<this.limbs.length;e++)this.limbs[e]-=this.modulus.limbs[e]*t;return this.cnormalize(),this},a.inverse=function(){return this.power(this.modulus.sub(2))},r.fromBits=i.bn.fromBits,r},i.bn.prime={p127:i.bn.pseudoMersennePrime(127,[[0,-1]]),p25519:i.bn.pseudoMersennePrime(255,[[0,-19]]),p192:i.bn.pseudoMersennePrime(192,[[0,-1],[64,-1]]),p224:i.bn.pseudoMersennePrime(224,[[0,1],[96,-1]]),p256:i.bn.pseudoMersennePrime(256,[[0,-1],[96,1],[192,1],[224,-1]]),p384:i.bn.pseudoMersennePrime(384,[[0,-1],[32,1],[96,-1],[128,-1]]),p521:i.bn.pseudoMersennePrime(521,[[0,-1]])},i.bn.random=function(t,e){"object"!=typeof t&&(t=new i.bn(t));for(var r,n,s=t.limbs.length,o=t.limbs[s-1]+1,a=new i.bn;;){for(;(r=i.random.randomWords(s,e))[s-1]<0&&(r[s-1]+=4294967296),Math.floor(r[s-1]/o)===Math.floor(4294967296/o););for(r[s-1]%=o,n=0;n<s-1;n++)r[n]&=t.radixMask;if(a.limbs=r,!a.greaterEquals(t))return a}},i.ecc={},i.ecc.point=function(t,e,r){void 0===e?this.isIdentity=!0:(e instanceof i.bn&&(e=new t.field(e)),r instanceof i.bn&&(r=new t.field(r)),this.x=e,this.y=r,this.isIdentity=!1),this.curve=t},i.ecc.point.prototype={toJac:function(){return new i.ecc.pointJac(this.curve,this.x,this.y,new this.curve.field(1))},mult:function(t){return this.toJac().mult(t,this).toAffine()},mult2:function(t,e,r){return this.toJac().mult2(t,this,e,r).toAffine()},multiples:function(){var t,e,r;if(void 0===this._multiples)for(r=this.toJac().doubl(),t=this._multiples=[new i.ecc.point(this.curve),this,r.toAffine()],e=3;e<16;e++)r=r.add(this),t.push(r.toAffine());return this._multiples},isValid:function(){return this.y.square().equals(this.curve.b.add(this.x.mul(this.curve.a.add(this.x.square()))))},toBits:function(){return i.bitArray.concat(this.x.toBits(),this.y.toBits())}},i.ecc.pointJac=function(t,e,r,n){void 0===e?this.isIdentity=!0:(this.x=e,this.y=r,this.z=n,this.isIdentity=!1),this.curve=t},i.ecc.pointJac.prototype={add:function(t){var e,r,n,s,o,a,c,f,u,h,d,l=this;if(l.curve!==t.curve)throw"sjcl.ecc.add(): Points must be on the same curve to add them!";return l.isIdentity?t.toJac():t.isIdentity?l:(e=l.z.square(),(r=t.x.mul(e).subM(l.x)).equals(0)?l.y.equals(t.y.mul(e.mul(l.z)))?l.doubl():new i.ecc.pointJac(l.curve):(n=t.y.mul(e.mul(l.z)).subM(l.y),s=r.square(),o=n.square(),a=r.square().mul(r).addM(l.x.add(l.x).mul(s)),c=o.subM(a),f=l.x.mul(s).subM(c).mul(n),u=l.y.mul(r.square().mul(r)),h=f.subM(u),d=l.z.mul(r),new i.ecc.pointJac(this.curve,c,h,d)))},doubl:function(){if(this.isIdentity)return this;var t=this.y.square(),e=t.mul(this.x.mul(4)),r=t.square().mul(8),n=this.z.square(),s=this.x.sub(n).mul(3).mul(this.x.add(n)),o=s.square().subM(e).subM(e),a=e.sub(o).mul(s).subM(r),c=this.y.add(this.y).mul(this.z);return new i.ecc.pointJac(this.curve,o,a,c)},toAffine:function(){if(this.isIdentity||this.z.equals(0))return new i.ecc.point(this.curve);var t=this.z.inverse(),e=t.square();return new i.ecc.point(this.curve,this.x.mul(e).fullReduce(),this.y.mul(e.mul(t)).fullReduce())},mult:function(t,e){"number"==typeof t?t=[t]:void 0!==t.limbs&&(t=t.normalize().limbs);var r,n,s=new i.ecc.point(this.curve).toJac(),o=e.multiples();for(r=t.length-1;0<=r;r--)for(n=i.bn.prototype.radix-4;0<=n;n-=4)s=s.doubl().doubl().doubl().doubl().add(o[t[r]>>n&15]);return s},mult2:function(t,e,r,n){"number"==typeof t?t=[t]:void 0!==t.limbs&&(t=t.normalize().limbs),"number"==typeof r?r=[r]:void 0!==r.limbs&&(r=r.normalize().limbs);var s,o,a,c,f=new i.ecc.point(this.curve).toJac(),u=e.multiples(),h=n.multiples();for(s=Math.max(t.length,r.length)-1;0<=s;s--)for(a=0|t[s],c=0|r[s],o=i.bn.prototype.radix-4;0<=o;o-=4)f=f.doubl().doubl().doubl().doubl().add(u[a>>o&15]).add(h[c>>o&15]);return f},isValid:function(){var t=this.z.square(),e=t.square(),r=e.mul(t);return this.y.square().equals(this.curve.b.mul(r).add(this.x.mul(this.curve.a.mul(e).add(this.x.square()))))}},i.ecc.curve=function(t,e,r,n,s,o){this.field=t,this.r=t.prototype.modulus.sub(e),this.a=new t(r),this.b=new t(n),this.G=new i.ecc.point(this,new t(s),new t(o))},i.ecc.curve.prototype.fromBits=function(t){var e=i.bitArray,r=this.field.prototype.exponent+7&-8,n=new i.ecc.point(this,this.field.fromBits(e.bitSlice(t,0,r)),this.field.fromBits(e.bitSlice(t,r,2*r)));if(!n.isValid())throw new i.exception.corrupt("not on the curve!");return n},i.ecc.curves={c192:new i.ecc.curve(i.bn.prime.p192,"0x662107c8eb94364e4b2dd7ce",-3,"0x64210519e59c80e70fa7e9ab72243049feb8deecc146b9b1","0x188da80eb03090f67cbf20eb43a18800f4ff0afd82ff1012","0x07192b95ffc8da78631011ed6b24cdd573f977a11e794811"),c224:new i.ecc.curve(i.bn.prime.p224,"0xe95c1f470fc1ec22d6baa3a3d5c4",-3,"0xb4050a850c04b3abf54132565044b0b7d7bfd8ba270b39432355ffb4","0xb70e0cbd6bb4bf7f321390b94a03c1d356c21122343280d6115c1d21","0xbd376388b5f723fb4c22dfe6cd4375a05a07476444d5819985007e34"),c256:new i.ecc.curve(i.bn.prime.p256,"0x4319055358e8617b0c46353d039cdaae",-3,"0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b","0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296","0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5"),c384:new i.ecc.curve(i.bn.prime.p384,"0x389cb27e0bc8d21fa7e5f24cb74f58851313e696333ad68c",-3,"0xb3312fa7e23ee7e4988e056be3f82d19181d9c6efe8141120314088f5013875ac656398d8a2ed19d2a85c8edd3ec2aef","0xaa87ca22be8b05378eb1c71ef320ad746e1d3b628ba79b9859f741e082542a385502f25dbf55296c3a545e3872760ab7","0x3617de4a96262c6f5d9e98bf9292dc29f8f41dbd289a147ce9da3113b5f0b8c00a60b1ce1d7e819d7a431d7c90ea0e5f")},i.ecc._dh=function(t){i.ecc[t]={publicKey:function(t,e){this._curve=t,this._curveBitLength=t.r.bitLength(),e instanceof Array?this._point=t.fromBits(e):this._point=e,this.get=function(){var t=this._point.toBits(),e=i.bitArray.bitLength(t);return{x:i.bitArray.bitSlice(t,0,e/2),y:i.bitArray.bitSlice(t,e/2)}}},secretKey:function(t,e){this._curve=t,this._curveBitLength=t.r.bitLength(),this._exponent=e,this.get=function(){return this._exponent.toBits()}},generateKeys:function(e,r,n){if(void 0===e&&(e=256),"number"==typeof e&&void 0===(e=i.ecc.curves["c"+e]))throw new i.exception.invalid("no such curve");void 0===n&&(n=i.bn.random(e.r,r));var s=e.G.mult(n);return{pub:new i.ecc[t].publicKey(e,s),sec:new i.ecc[t].secretKey(e,n)}}}},i.ecc._dh("elGamal"),i.ecc.elGamal.publicKey.prototype={kem:function(t){var e=i.bn.random(this._curve.r,t),r=this._curve.G.mult(e).toBits();return{key:i.hash.sha256.hash(this._point.mult(e).toBits()),tag:r}}},i.ecc.elGamal.secretKey.prototype={unkem:function(t){return i.hash.sha256.hash(this._curve.fromBits(t).mult(this._exponent).toBits())},dh:function(t){return i.hash.sha256.hash(t._point.mult(this._exponent).toBits())}},i.ecc._dh("ecdsa"),i.ecc.ecdsa.secretKey.prototype={sign:function(t,e,r,n){i.bitArray.bitLength(t)>this._curveBitLength&&(t=i.bitArray.clamp(t,this._curveBitLength));var s=this._curve.r,o=s.bitLength(),a=n||i.bn.random(s.sub(1),e).add(1),c=this._curve.G.mult(a).x.mod(s),f=i.bn.fromBits(t).add(c.mul(this._exponent)),u=r?f.inverseMod(s).mul(a).mod(s):f.mul(a.inverseMod(s)).mod(s);return i.bitArray.concat(c.toBits(o),u.toBits(o))}},i.ecc.ecdsa.publicKey.prototype={verify:function(t,e,r){i.bitArray.bitLength(t)>this._curveBitLength&&(t=i.bitArray.clamp(t,this._curveBitLength));var n=i.bitArray,s=this._curve.r,o=this._curveBitLength,a=i.bn.fromBits(n.bitSlice(e,0,o)),c=i.bn.fromBits(n.bitSlice(e,o,2*o)),f=r?c:c.inverseMod(s),u=i.bn.fromBits(t).mul(f).mod(s),h=a.mul(f).mod(s),d=this._curve.G.mult2(u,h,this._point).x;if(a.equals(0)||c.equals(0)||a.greaterEquals(s)||c.greaterEquals(s)||!d.equals(a)){if(void 0===r)return this.verify(t,e,!0);throw new i.exception.corrupt("signature didn't check out")}return!0}},i.keyexchange.srp={makeVerifier:function(t,e,r,n){var s;return s=i.keyexchange.srp.makeX(t,e,r),s=i.bn.fromBits(s),n.g.powermod(s,n.N)},makeX:function(t,e,r){var n=i.hash.sha1.hash(t+":"+e);return i.hash.sha1.hash(i.bitArray.concat(r,n))},knownGroup:function(t){return"string"!=typeof t&&(t=t.toString()),i.keyexchange.srp._didInitKnownGroups||i.keyexchange.srp._initKnownGroups(),i.keyexchange.srp._knownGroups[t]},_didInitKnownGroups:!1,_initKnownGroups:function(){var t,e,r;for(t=0;t<i.keyexchange.srp._knownGroupSizes.length;t++)e=i.keyexchange.srp._knownGroupSizes[t].toString(),(r=i.keyexchange.srp._knownGroups[e]).N=new i.bn(r.N),r.g=new i.bn(r.g);i.keyexchange.srp._didInitKnownGroups=!0},_knownGroupSizes:[1024,1536,2048],_knownGroups:{1024:{N:"EEAF0AB9ADB38DD69C33F80AFA8FC5E86072618775FF3C0B9EA2314C9C256576D674DF7496EA81D3383B4813D692C6E0E0D5D8E250B98BE48E495C1D6089DAD15DC7D7B46154D6B6CE8EF4AD69B15D4982559B297BCF1885C529F566660E57EC68EDBC3C05726CC02FD4CBF4976EAA9AFD5138FE8376435B9FC61D2FC0EB06E3",g:2},1536:{N:"9DEF3CAFB939277AB1F12A8617A47BBBDBA51DF499AC4C80BEEEA9614B19CC4D5F4F5F556E27CBDE51C6A94BE4607A291558903BA0D0F84380B655BB9A22E8DCDF028A7CEC67F0D08134B1C8B97989149B609E0BE3BAB63D47548381DBC5B1FC764E3F4B53DD9DA1158BFD3E2B9C8CF56EDF019539349627DB2FD53D24B7C48665772E437D6C7F8CE442734AF7CCB7AE837C264AE3A9BEB87F8A2FE9B8B5292E5A021FFF5E91479E8CE7A28C2442C6F315180F93499A234DCF76E3FED135F9BB",g:2},2048:{N:"AC6BDB41324A9A9BF166DE5E1389582FAF72B6651987EE07FC3192943DB56050A37329CBB4A099ED8193E0757767A13DD52312AB4B03310DCD7F48A9DA04FD50E8083969EDB767B0CF6095179A163AB3661A05FBD5FAAAE82918A9962F0B93B855F97993EC975EEAA80D740ADBF4FF747359D041D5C33EA71D281E446B14773BCA97B43A23FB801676BD207A436C6481F1D2B9078717461A5B9D32E688F87748544523B524B0D57D5EA77A2775D2ECFA032CFBDBF52FB3786160279004E57AE6AF874E7303CE53299CCC041C7BC308D82A5698F3A8D0C38271AE35F8E9DBFBB694B5C803D89F7AE435DE236D525F54759B65E372FCD68EF20FA7111F9E4AFF73",g:2}}},i.ecc.point.prototype.isValidPoint=function(){var t=this,e=t.curve.field.modulus;return!(t.isIdentity||new i.bn(1).greaterEquals(t.x)&&!t.x.equals(1)||t.x.greaterEquals(e.sub(1))&&!t.x.equals(1)||new i.bn(1).greaterEquals(t.y)&&!t.y.equals(1)||t.y.greaterEquals(e.sub(1))&&!t.y.equals(1)||!t.isOnCurve())},i.ecc.point.prototype.isOnCurve=function(){var t=this,e=(t.curve.r,t.curve.a),r=t.curve.b,n=t.curve.field.modulus,i=t.y.mul(t.y).mod(n),s=t.x.mul(t.x).mul(t.x).add(e.mul(t.x)).add(r).mod(n);return i.equals(s)},i.ecc.point.prototype.toString=function(){return"("+this.x.toString()+", "+this.y.toString()+")"},i.ecc.pointJac.prototype.toString=function(){return"("+this.x.toString()+", "+this.y.toString()+", "+this.z.toString()+")"},i.ecc.curves.c256=new i.ecc.curve(i.bn.pseudoMersennePrime(256,[[0,-1],[4,-1],[6,-1],[7,-1],[8,-1],[9,-1],[32,-1]]),"0x14551231950b75fc4402da1722fc9baee",0,7,"0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8"),i.ecc.pointJac.prototype.add=function(t){var e=this;if(e.curve!==t.curve)throw"sjcl.ecc.add(): Points must be on the same curve to add them!";if(e.isIdentity)return t.toJac();if(t.isIdentity)return e;var r=e.z.square(),n=t.x.mul(r).subM(e.x),s=t.y.mul(e.z).mul(r);if(n.equals(0))return e.y.equals(t.y.mul(r.mul(e.z)))?e.doubl():new i.ecc.pointJac(e.curve);var o=n.square(),a=o.copy().doubleM().doubleM(),c=n.mul(a),f=s.sub(e.y).doubleM(),u=e.x.mul(a),h=f.square().subM(c).subM(u.copy().doubleM()),d=f.mul(u.sub(h)).subM(e.y.mul(c).doubleM()),l=e.z.add(n).square().subM(r).subM(o);return new i.ecc.pointJac(this.curve,h,d,l)},i.ecc.pointJac.prototype.doubl=function(){if(this.isIdentity)return this;var t=this.x.square(),e=this.y.square(),r=e.square(),n=this.x.add(e).square().subM(t).subM(r).doubleM(),s=t.mul(3),o=s.square().sub(n.copy().doubleM()),a=s.mul(n.sub(o)).subM(r.doubleM().doubleM().doubleM()),c=this.z.mul(this.y).doubleM();return new i.ecc.pointJac(this.curve,o,a,c)},i.ecc.point.prototype.toBytesCompressed=function(){return["0x0"==this.y.mod(2).toString()?2:3].concat(i.codec.bytes.fromBits(this.x.toBits()))},function(){i.hash.ripemd160=function(t){t?(this._h=t._h.slice(0),this._buffer=t._buffer.slice(0),this._length=t._length):this.reset()},i.hash.ripemd160.hash=function(t){return(new i.hash.ripemd160).update(t).finalize()},i.hash.ripemd160.prototype={reset:function(){return this._h=t.slice(0),this._buffer=[],this._length=0,this},update:function(t){"string"==typeof t&&(t=i.codec.utf8String.toBits(t));var e,r=this._buffer=i.bitArray.concat(this._buffer,t),n=this._length,s=this._length=n+i.bitArray.bitLength(t);for(e=512+n&-512;e<=s;e+=512){for(var o=r.splice(0,16),a=0;a<16;++a)o[a]=_(o[a]);y.call(this,o)}return this},finalize:function(){var t=i.bitArray.concat(this._buffer,[i.bitArray.partial(1,1)]),e=(this._length+1)%512,r=(448<e?512:448)-e%448,n=r%32;for(0<n&&(t=i.bitArray.concat(t,[i.bitArray.partial(n,0)]));32<=r;r-=32)t.push(0);for(t.push(_(0|this._length)),t.push(_(Math.floor(this._length/4294967296)));t.length;){for(var s=t.splice(0,16),o=0;o<16;++o)s[o]=_(s[o]);y.call(this,s)}var a=this._h;for(this.reset(),o=0;o<5;++o)a[o]=_(a[o]);return a}};for(var t=[1732584193,4023233417,2562383102,271733878,3285377520],e=[0,1518500249,1859775393,2400959708,2840853838],r=[1352829926,1548603684,1836072691,2053994217,0],n=4;0<=n;--n)for(var s=1;s<16;++s)e.splice(n,0,e[n]),r.splice(n,0,r[n]);var o=[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],a=[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],c=[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],f=[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];function u(t,e,r){return t^e^r}function h(t,e,r){return t&e|~t&r}function d(t,e,r){return(t|~e)^r}function l(t,e,r){return t&r|e&~r}function p(t,e,r){return t^(e|~r)}function b(t,e){return t<<e|t>>>32-e}function _(t){return(255&t)<<24|(65280&t)<<8|(t&255<<16)>>>8|(t&255<<24)>>>24}function y(t){for(var n,i=this._h[0],s=this._h[1],_=this._h[2],y=this._h[3],v=this._h[4],m=this._h[0],g=this._h[1],w=this._h[2],A=this._h[3],S=this._h[4],E=0;E<16;++E)n=b(i+u(s,_,y)+t[o[E]]+e[E],c[E])+v,i=v,v=y,y=b(_,10),_=s,s=n,n=b(m+p(g,w,A)+t[a[E]]+r[E],f[E])+S,m=S,S=A,A=b(w,10),w=g,g=n;for(;E<32;++E)n=b(i+h(s,_,y)+t[o[E]]+e[E],c[E])+v,i=v,v=y,y=b(_,10),_=s,s=n,n=b(m+l(g,w,A)+t[a[E]]+r[E],f[E])+S,m=S,S=A,A=b(w,10),w=g,g=n;for(;E<48;++E)n=b(i+d(s,_,y)+t[o[E]]+e[E],c[E])+v,i=v,v=y,y=b(_,10),_=s,s=n,n=b(m+d(g,w,A)+t[a[E]]+r[E],f[E])+S,m=S,S=A,A=b(w,10),w=g,g=n;for(;E<64;++E)n=b(i+l(s,_,y)+t[o[E]]+e[E],c[E])+v,i=v,v=y,y=b(_,10),_=s,s=n,n=b(m+h(g,w,A)+t[a[E]]+r[E],f[E])+S,m=S,S=A,A=b(w,10),w=g,g=n;for(;E<80;++E)n=b(i+p(s,_,y)+t[o[E]]+e[E],c[E])+v,i=v,v=y,y=b(_,10),_=s,s=n,n=b(m+u(g,w,A)+t[a[E]]+r[E],f[E])+S,m=S,S=A,A=b(w,10),w=g,g=n;n=this._h[1]+_+A,this._h[1]=this._h[2]+y+S,this._h[2]=this._h[3]+v+m,this._h[3]=this._h[4]+i+g,this._h[4]=this._h[0]+s+w,this._h[0]=n}}(),i.bn.ZERO=new i.bn(0),i.bn.prototype.divRem=function(t){"object"!=typeof t&&(t=new this._class(t));var e=this.abs(),r=t.abs(),n=new this._class(0),s=0;if(!e.greaterEquals(r))return[new i.bn(0),this.copy()];if(e.equals(r))return[new i.bn(1),new i.bn(0)];for(;e.greaterEquals(r);s++)r.doubleM();for(;0<s;s--)n.doubleM(),r.halveM(),e.greaterEquals(r)&&(n.addM(1),e.subM(t).normalize());return[n,e]},i.bn.prototype.divRound=function(t){var e=this.divRem(t),r=e[0];return e[1].doubleM().greaterEquals(t)&&r.addM(1),r},i.bn.prototype.div=function(t){return this.divRem(t)[0]},i.bn.prototype.sign=function(){return this.greaterEquals(i.bn.ZERO)?1:-1},i.bn.prototype.neg=function(){return i.bn.ZERO.sub(this)},i.bn.prototype.abs=function(){return-1===this.sign()?this.neg():this},i.bn.prototype.shiftRight=function(t){if("number"!=typeof t)throw new Error("shiftRight expects a number");if((t=+t)<0)return this.shiftLeft(t);for(var e=new i.bn(this);t>=this.radix;)e.limbs.shift(),t-=this.radix;for(;t--;)e.halveM();return e},i.bn.prototype.shiftLeft=function(t){if("number"!=typeof t)throw new Error("shiftLeft expects a number");if((t=+t)<0)return this.shiftRight(t);for(var e=new i.bn(this);t>=this.radix;)e.limbs.unshift(0),t-=this.radix;for(;t--;)e.doubleM();return e},i.bn.prototype.toNumber=function(){return 0|this.limbs[0]},i.bn.prototype.testBit=function(t){var e=Math.floor(t/this.radix),r=t%this.radix;return e>=this.limbs.length?0:this.limbs[e]>>>r&1},i.bn.prototype.setBitM=function(t){for(var e=Math.floor(t/this.radix),r=t%this.radix;e>=this.limbs.length;)this.limbs.push(0);return this.limbs[e]|=1<<r,this.cnormalize(),this},i.bn.prototype.modInt=function(t){return this.toNumber()%t},i.bn.prototype.invDigit=function(){var t=1+this.radixMask;if(this.limbs.length<1)return 0;var e=this.limbs[0];if(0==(1&e))return 0;var r=3&e;return 0<(r=(r=(r=(r=r*(2-(15&e)*r)&15)*(2-(255&e)*r)&255)*(2-((65535&e)*r&65535))&65535)*(2-e*r%t)%t)?t-r:-r},i.bn.prototype.am=function(t,e,r,n,i,s){for(var o=4095&e,a=e>>12;0<=--s;){var c=4095&this.limbs[t],f=this.limbs[t++]>>12,u=a*c+f*o;i=((c=o*c+((4095&u)<<12)+r.limbs[n]+i)>>24)+(u>>12)+a*f,r.limbs[n++]=16777215&c}return i},s.prototype.reduce=function(t){for(var e=t.radixMask+1;t.limbs.length<=this.mt2;)t.limbs[t.limbs.length]=0;for(var r=0;r<this.mt;++r){var n=32767&t.limbs[r],i=n*this.mpl+((n*this.mph+(t.limbs[r]>>15)*this.mpl&this.um)<<15)&t.radixMask;for(n=r+this.mt,t.limbs[n]+=this.m.am(0,i,t,r,0,this.mt);t.limbs[n]>=e;)t.limbs[n]-=e,t.limbs[++n]++}return t.trim(),(t=t.shiftRight(this.mt*this.m.radix)).greaterEquals(this.m)&&(t=t.sub(this.m)),t.trim().normalize().reduce()},s.prototype.square=function(t){return this.reduce(t.square())},s.prototype.multiply=function(t,e){return this.reduce(t.mul(e))},s.prototype.convert=function(t){return t.abs().shiftLeft(this.mt*this.m.radix).mod(this.m)},s.prototype.revert=function(t){return this.reduce(t.copy())},i.bn.prototype.powermodMontgomery=function(t,e){var r,n=t.bitLength(),i=new this._class(1);if(n<=0)return i;if(r=n<18?1:n<48?3:n<144?4:n<768?5:6,n<8||!e.testBit(0))return this.powermod(t,e);var o=new s(e);t.trim().normalize();var a=new Array,c=3,f=r-1,u=(1<<r)-1;if(a[1]=o.convert(this),1<r)for(var h=o.square(a[1]);c<=u;)a[c]=o.multiply(h,a[c-2]),c+=2;var d,l,p=t.limbs.length-1,b=!0,_=new this._class;for(n=function(t){var e,r=1;return 0!=(e=t>>>16)&&(t=e,r+=16),0!=(e=t>>8)&&(t=e,r+=8),0!=(e=t>>4)&&(t=e,r+=4),0!=(e=t>>2)&&(t=e,r+=2),0!=(e=t>>1)&&(t=e,r+=1),r}(t.limbs[p])-1;0<=p;){for(f<=n?d=t.limbs[p]>>n-f&u:(d=(t.limbs[p]&(1<<n+1)-1)<<f-n,0<p&&(d|=t.limbs[p-1]>>this.radix+n-f)),c=r;0==(1&d);)d>>=1,--c;if((n-=c)<0&&(n+=this.radix,--p),b)i=a[d].copy(),b=!1;else{for(;1<c;)_=o.square(i),i=o.square(_),c-=2;_=0<c?o.square(i):(l=i,i=_,l),i=o.multiply(_,a[d])}for(;0<=p&&0==(t.limbs[p]&1<<n);)l=i,i=_=o.square(i),_=l,--n<0&&(n=this.radix-1,--p)}return o.revert(i)},i.ecc.ecdsa.secretKey.prototype.sign=function(t,e,r){var n,s=this._curve.r,o=s.bitLength();n="object"==typeof r&&0<r.length&&"number"==typeof r[0]?r:"string"==typeof r&&/^[0-9a-fA-F]+$/.test(r)?i.bn.fromBits(i.codec.hex.toBits(r)):i.bn.random(s.sub(1),e).add(1);var a=this._curve.G.mult(n).x.mod(s),c=i.bn.fromBits(t).add(a.mul(this._exponent)).mul(n.inverseMod(s)).mod(s);return i.bitArray.concat(a.toBits(o),c.toBits(o))},i.ecc.ecdsa.publicKey.prototype.verify=function(t,e){var r=i.bitArray,n=this._curve.r,s=n.bitLength(),o=i.bn.fromBits(r.bitSlice(e,0,s)),a=i.bn.fromBits(r.bitSlice(e,s,2*s)),c=a.inverseMod(n),f=i.bn.fromBits(t).mul(c).mod(n),u=o.mul(c).mod(n),h=this._curve.G.mult2(f,u,this._point).x;if(o.equals(0)||a.equals(0)||o.greaterEquals(n)||a.greaterEquals(n)||!h.equals(o))throw new i.exception.corrupt("signature didn't check out");return!0},i.ecc.ecdsa.secretKey.prototype.canonicalizeSignature=function(t){var e=i.bitArray,r=this._curve.r,n=r.bitLength(),s=i.bn.fromBits(e.bitSlice(t,0,n)),o=i.bn.fromBits(e.bitSlice(t,n,2*n));return r.copy().halveM().greaterEquals(o)||(o=r.sub(o)),e.concat(s.toBits(n),o.toBits(n))},i.ecc.ecdsa.secretKey.prototype.signDER=function(t,e){return this.encodeDER(this.sign(t,e))},i.ecc.ecdsa.secretKey.prototype.encodeDER=function(t){for(var e=i.bitArray,r=this._curve.r.bitLength(),n=i.codec.bytes.fromBits(e.bitSlice(t,0,r)),s=i.codec.bytes.fromBits(e.bitSlice(t,r,2*r));!n[0]&&n.length;)n.shift();for(;!s[0]&&s.length;)s.shift();128&n[0]&&n.unshift(0),128&s[0]&&s.unshift(0);var o=[].concat(48,4+n.length+s.length,2,n.length,n,2,s.length,s);return i.codec.bytes.toBits(o)},i.ecc.ecdsa.secretKey.prototype.signWithRecoverablePublicKey=function(t,e,r){var n;if(!("object"==typeof t&&0<t.length&&"number"==typeof t[0]))throw new i.exception.invalid("hash. Must be a bitArray");n=t;var s=this.sign(n,e,r),c=this.canonicalizeSignature(s),f=o(this._curve,c),u=this._curve.G.mult(i.bn.fromBits(this.get())),h=function(t,e,r,n,s){for(var o=s.toBits(),c=0;c<4;c++){var f;try{f=a(t,e,r,n,c)}catch(t){continue}if(i.bitArray.equal(f.toBits(),o))return c}throw new i.exception.bug("unable to calculate recovery factor from signature")}(this._curve,f.r,f.s,n,u)+27;return i.bitArray.concat([h],c)},i.ecc.ecdsa.publicKey.recoverFromSignature=function(t,e,r){if(!e||e instanceof i.ecc.curve)throw new i.exception.invalid("must supply hash and signature to recover public key");var n,s;if(r=r||i.ecc.curves.c256,!("object"==typeof t&&0<t.length&&"number"==typeof t[0]))throw new i.exception.invalid("hash. Must be a bitArray");if(n=t,!("object"==typeof e&&0<e.length&&"number"==typeof e[0]))throw new i.exception.invalid("signature. Must be a bitArray");var c=(s=e)[0]-27;if(c<0||3<c)throw new i.exception.invalid("signature. Signature must be generated with algorithm that prepends the recovery factor in order to recover the public key");var f=o(r,s.slice(1)),u=a(r,f.r,f.s,n,c);return new i.ecc.ecdsa.publicKey(r,u)},i.bn.prototype.jacobi=function(t){if(-1!==(t=new i.bn(t)).sign()){if(this.equals(0))return 0;if(this.equals(1))return 1;for(var e=0,r=0;!this.testBit(r);)r++;var n=this.shiftRight(r);if(0==(1&r))e=1;else{var s=t.modInt(8);1===s||7===s?e=1:3!==s&&5!==s||(e=-1)}return 3===t.modInt(4)&&3===n.modInt(4)&&(e=-e),n.equals(1)?e:e*t.mod(n).jacobi(n)}}},function(t,e){var r;function n(t,e,r){null!=t&&("number"==typeof t?this.fromNumber(t,e,r):null==e&&"string"!=typeof t?this.fromString(t,256):this.fromString(t,e))}function i(){return new n(null)}r="undefined"!=typeof navigator&&"Microsoft Internet Explorer"==navigator.appName?(n.prototype.am=function(t,e,r,n,i,s){for(var o=32767&e,a=e>>15;0<=--s;){var c=32767&this[t],f=this[t++]>>15,u=a*c+f*o;i=((c=o*c+((32767&u)<<15)+r[n]+(1073741823&i))>>>30)+(u>>>15)+a*f+(i>>>30),r[n++]=1073741823&c}return i},30):"undefined"!=typeof navigator&&"Netscape"!=navigator.appName?(n.prototype.am=function(t,e,r,n,i,s){for(;0<=--s;){var o=e*this[t++]+r[n]+i;i=Math.floor(o/67108864),r[n++]=67108863&o}return i},26):(n.prototype.am=function(t,e,r,n,i,s){for(var o=16383&e,a=e>>14;0<=--s;){var c=16383&this[t],f=this[t++]>>14,u=a*c+f*o;i=((c=o*c+((16383&u)<<14)+r[n]+i)>>28)+(u>>14)+a*f,r[n++]=268435455&c}return i},28),n.prototype.DB=r,n.prototype.DM=(1<<r)-1,n.prototype.DV=1<<r,n.prototype.FV=Math.pow(2,52),n.prototype.F1=52-r,n.prototype.F2=2*r-52;var s,o,a="0123456789abcdefghijklmnopqrstuvwxyz",c=new Array;for(s="0".charCodeAt(0),o=0;o<=9;++o)c[s++]=o;for(s="a".charCodeAt(0),o=10;o<36;++o)c[s++]=o;for(s="A".charCodeAt(0),o=10;o<36;++o)c[s++]=o;function f(t){return a.charAt(t)}function u(t,e){var r=c[t.charCodeAt(e)];return null==r?-1:r}function h(t){var e=i();return e.fromInt(t),e}function d(t){var e,r=1;return 0!=(e=t>>>16)&&(t=e,r+=16),0!=(e=t>>8)&&(t=e,r+=8),0!=(e=t>>4)&&(t=e,r+=4),0!=(e=t>>2)&&(t=e,r+=2),0!=(e=t>>1)&&(t=e,r+=1),r}function l(t){this.m=t}function p(t){this.m=t,this.mp=t.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<<t.DB-15)-1,this.mt2=2*t.t}function b(t,e){return t&e}function _(t,e){return t|e}function y(t,e){return t^e}function v(t,e){return t&~e}function m(t){if(0==t)return-1;var e=0;return 0==(65535&t)&&(t>>=16,e+=16),0==(255&t)&&(t>>=8,e+=8),0==(15&t)&&(t>>=4,e+=4),0==(3&t)&&(t>>=2,e+=2),0==(1&t)&&++e,e}function g(t){for(var e=0;0!=t;)t&=t-1,++e;return e}function w(){}function A(t){return t}function S(t){this.r2=i(),this.q3=i(),n.ONE.dlShiftTo(2*t.t,this.r2),this.mu=this.r2.divide(t),this.m=t}l.prototype.convert=function(t){return t.s<0||0<=t.compareTo(this.m)?t.mod(this.m):t},l.prototype.revert=function(t){return t},l.prototype.reduce=function(t){t.divRemTo(this.m,null,t)},l.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r),this.reduce(r)},l.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},p.prototype.convert=function(t){var e=i();return t.abs().dlShiftTo(this.m.t,e),e.divRemTo(this.m,null,e),t.s<0&&0<e.compareTo(n.ZERO)&&this.m.subTo(e,e),e},p.prototype.revert=function(t){var e=i();return t.copyTo(e),this.reduce(e),e},p.prototype.reduce=function(t){for(;t.t<=this.mt2;)t[t.t++]=0;for(var e=0;e<this.m.t;++e){var r=32767&t[e],n=r*this.mpl+((r*this.mph+(t[e]>>15)*this.mpl&this.um)<<15)&t.DM;for(t[r=e+this.m.t]+=this.m.am(0,n,t,e,0,this.m.t);t[r]>=t.DV;)t[r]-=t.DV,t[++r]++}t.clamp(),t.drShiftTo(this.m.t,t),0<=t.compareTo(this.m)&&t.subTo(this.m,t)},p.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r),this.reduce(r)},p.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},w.prototype.convert=A,w.prototype.revert=A,w.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r)},w.prototype.sqrTo=function(t,e){t.squareTo(e)},S.prototype.convert=function(t){if(t.s<0||t.t>2*this.m.t)return t.mod(this.m);if(t.compareTo(this.m)<0)return t;var e=i();return t.copyTo(e),this.reduce(e),e},S.prototype.revert=function(t){return t},S.prototype.reduce=function(t){for(t.drShiftTo(this.m.t-1,this.r2),t.t>this.m.t+1&&(t.t=this.m.t+1,t.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);t.compareTo(this.r2)<0;)t.dAddOffset(1,this.m.t+1);for(t.subTo(this.r2,t);0<=t.compareTo(this.m);)t.subTo(this.m,t)},S.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r),this.reduce(r)},S.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)};var E=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],x=(1<<26)/E[E.length-1];n.prototype.chunkSize=function(t){return Math.floor(Math.LN2*this.DB/Math.log(t))},n.prototype.toRadix=function(t){if(null==t&&(t=10),0==this.signum()||t<2||36<t)return"0";var e=this.chunkSize(t),r=Math.pow(t,e),n=h(r),s=i(),o=i(),a="";for(this.divRemTo(n,s,o);0<s.signum();)a=(r+o.intValue()).toString(t).substr(1)+a,s.divRemTo(n,s,o);return o.intValue().toString(t)+a},n.prototype.fromRadix=function(t,e){this.fromInt(0),null==e&&(e=10);for(var r=this.chunkSize(e),i=Math.pow(e,r),s=!1,o=0,a=0,c=0;c<t.length;++c){var f=u(t,c);f<0?"-"==t.charAt(c)&&0==this.signum()&&(s=!0):(a=e*a+f,++o>=r&&(this.dMultiply(i),this.dAddOffset(a,0),a=o=0))}0<o&&(this.dMultiply(Math.pow(e,o)),this.dAddOffset(a,0)),s&&n.ZERO.subTo(this,this)},n.prototype.fromNumber=function(t,e,r){if("number"==typeof e)if(t<2)this.fromInt(1);else for(this.fromNumber(t,r),this.testBit(t-1)||this.bitwiseTo(n.ONE.shiftLeft(t-1),_,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(e);)this.dAddOffset(2,0),this.bitLength()>t&&this.subTo(n.ONE.shiftLeft(t-1),this);else{var i=new Array,s=7&t;i.length=1+(t>>3),e.nextBytes(i),0<s?i[0]&=(1<<s)-1:i[0]=0,this.fromString(i,256)}},n.prototype.bitwiseTo=function(t,e,r){var n,i,s=Math.min(t.t,this.t);for(n=0;n<s;++n)r[n]=e(this[n],t[n]);if(t.t<this.t){for(i=t.s&this.DM,n=s;n<this.t;++n)r[n]=e(this[n],i);r.t=this.t}else{for(i=this.s&this.DM,n=s;n<t.t;++n)r[n]=e(i,t[n]);r.t=t.t}r.s=e(this.s,t.s),r.clamp()},n.prototype.changeBit=function(t,e){var r=n.ONE.shiftLeft(t);return this.bitwiseTo(r,e,r),r},n.prototype.addTo=function(t,e){for(var r=0,n=0,i=Math.min(t.t,this.t);r<i;)n+=this[r]+t[r],e[r++]=n&this.DM,n>>=this.DB;if(t.t<this.t){for(n+=t.s;r<this.t;)n+=this[r],e[r++]=n&this.DM,n>>=this.DB;n+=this.s}else{for(n+=this.s;r<t.t;)n+=t[r],e[r++]=n&this.DM,n>>=this.DB;n+=t.s}e.s=n<0?-1:0,0<n?e[r++]=n:n<-1&&(e[r++]=this.DV+n),e.t=r,e.clamp()},n.prototype.dMultiply=function(t){this[this.t]=this.am(0,t-1,this,0,0,this.t),++this.t,this.clamp()},n.prototype.dAddOffset=function(t,e){if(0!=t){for(;this.t<=e;)this[this.t++]=0;for(this[e]+=t;this[e]>=this.DV;)this[e]-=this.DV,++e>=this.t&&(this[this.t++]=0),++this[e]}},n.prototype.multiplyLowerTo=function(t,e,r){var n,i=Math.min(this.t+t.t,e);for(r.s=0,r.t=i;0<i;)r[--i]=0;for(n=r.t-this.t;i<n;++i)r[i+this.t]=this.am(0,t[i],r,i,0,this.t);for(n=Math.min(t.t,e);i<n;++i)this.am(0,t[i],r,i,0,e-i);r.clamp()},n.prototype.multiplyUpperTo=function(t,e,r){--e;var n=r.t=this.t+t.t-e;for(r.s=0;0<=--n;)r[n]=0;for(n=Math.max(e-this.t,0);n<t.t;++n)r[this.t+n-e]=this.am(e-n,t[n],r,0,0,this.t+n-e);r.clamp(),r.drShiftTo(1,r)},n.prototype.modInt=function(t){if(t<=0)return 0;var e=this.DV%t,r=this.s<0?t-1:0;if(0<this.t)if(0==e)r=this[0]%t;else for(var n=this.t-1;0<=n;--n)r=(e*r+this[n])%t;return r},n.prototype.millerRabin=function(t){var e=this.subtract(n.ONE),r=e.getLowestSetBit();if(r<=0)return!1;var s=e.shiftRight(r);E.length<(t=t+1>>1)&&(t=E.length);for(var o=i(),a=0;a<t;++a){o.fromInt(E[Math.floor(Math.random()*E.length)]);var c=o.modPow(s,this);if(0!=c.compareTo(n.ONE)&&0!=c.compareTo(e)){for(var f=1;f++<r&&0!=c.compareTo(e);)if(0==(c=c.modPowInt(2,this)).compareTo(n.ONE))return!1;if(0!=c.compareTo(e))return!1}}return!0},n.prototype.copyTo=function(t){for(var e=this.t-1;0<=e;--e)t[e]=this[e];t.t=this.t,t.s=this.s},n.prototype.fromInt=function(t){this.t=1,this.s=t<0?-1:0,0<t?this[0]=t:t<-1?this[0]=t+this.DV:this.t=0},n.prototype.fromString=function(t,e){var r;if(16==e)r=4;else if(8==e)r=3;else if(256==e)r=8;else if(2==e)r=1;else if(32==e)r=5;else{if(4!=e)return void this.fromRadix(t,e);r=2}this.t=0,this.s=0;for(var i=t.length,s=!1,o=0;0<=--i;){var a=8==r?255&t[i]:u(t,i);a<0?"-"==t.charAt(i)&&(s=!0):(s=!1,0==o?this[this.t++]=a:o+r>this.DB?(this[this.t-1]|=(a&(1<<this.DB-o)-1)<<o,this[this.t++]=a>>this.DB-o):this[this.t-1]|=a<<o,(o+=r)>=this.DB&&(o-=this.DB))}8==r&&0!=(128&t[0])&&(this.s=-1,0<o&&(this[this.t-1]|=(1<<this.DB-o)-1<<o)),this.clamp(),s&&n.ZERO.subTo(this,this)},n.prototype.clamp=function(){for(var t=this.s&this.DM;0<this.t&&this[this.t-1]==t;)--this.t},n.prototype.dlShiftTo=function(t,e){var r;for(r=this.t-1;0<=r;--r)e[r+t]=this[r];for(r=t-1;0<=r;--r)e[r]=0;e.t=this.t+t,e.s=this.s},n.prototype.drShiftTo=function(t,e){for(var r=t;r<this.t;++r)e[r-t]=this[r];e.t=Math.max(this.t-t,0),e.s=this.s},n.prototype.lShiftTo=function(t,e){var r,n=t%this.DB,i=this.DB-n,s=(1<<i)-1,o=Math.floor(t/this.DB),a=this.s<<n&this.DM;for(r=this.t-1;0<=r;--r)e[r+o+1]=this[r]>>i|a,a=(this[r]&s)<<n;for(r=o-1;0<=r;--r)e[r]=0;e[o]=a,e.t=this.t+o+1,e.s=this.s,e.clamp()},n.prototype.rShiftTo=function(t,e){e.s=this.s;var r=Math.floor(t/this.DB);if(r>=this.t)e.t=0;else{var n=t%this.DB,i=this.DB-n,s=(1<<n)-1;e[0]=this[r]>>n;for(var o=r+1;o<this.t;++o)e[o-r-1]|=(this[o]&s)<<i,e[o-r]=this[o]>>n;0<n&&(e[this.t-r-1]|=(this.s&s)<<i),e.t=this.t-r,e.clamp()}},n.prototype.subTo=function(t,e){for(var r=0,n=0,i=Math.min(t.t,this.t);r<i;)n+=this[r]-t[r],e[r++]=n&this.DM,n>>=this.DB;if(t.t<this.t){for(n-=t.s;r<this.t;)n+=this[r],e[r++]=n&this.DM,n>>=this.DB;n+=this.s}else{for(n+=this.s;r<t.t;)n-=t[r],e[r++]=n&this.DM,n>>=this.DB;n-=t.s}e.s=n<0?-1:0,n<-1?e[r++]=this.DV+n:0<n&&(e[r++]=n),e.t=r,e.clamp()},n.prototype.multiplyTo=function(t,e){var r=this.abs(),i=t.abs(),s=r.t;for(e.t=s+i.t;0<=--s;)e[s]=0;for(s=0;s<i.t;++s)e[s+r.t]=r.am(0,i[s],e,s,0,r.t);e.s=0,e.clamp(),this.s!=t.s&&n.ZERO.subTo(e,e)},n.prototype.squareTo=function(t){for(var e=this.abs(),r=t.t=2*e.t;0<=--r;)t[r]=0;for(r=0;r<e.t-1;++r){var n=e.am(r,e[r],t,2*r,0,1);(t[r+e.t]+=e.am(r+1,2*e[r],t,2*r+1,n,e.t-r-1))>=e.DV&&(t[r+e.t]-=e.DV,t[r+e.t+1]=1)}0<t.t&&(t[t.t-1]+=e.am(r,e[r],t,2*r,0,1)),t.s=0,t.clamp()},n.prototype.divRemTo=function(t,e,r){var s=t.abs();if(!(s.t<=0)){var o=this.abs();if(o.t<s.t)return null!=e&&e.fromInt(0),void(null!=r&&this.copyTo(r));null==r&&(r=i());var a=i(),c=this.s,f=t.s,u=this.DB-d(s[s.t-1]);0<u?(s.lShiftTo(u,a),o.lShiftTo(u,r)):(s.copyTo(a),o.copyTo(r));var h=a.t,l=a[h-1];if(0!=l){var p=l*(1<<this.F1)+(1<h?a[h-2]>>this.F2:0),b=this.FV/p,_=(1<<this.F1)/p,y=1<<this.F2,v=r.t,m=v-h,g=null==e?i():e;for(a.dlShiftTo(m,g),0<=r.compareTo(g)&&(r[r.t++]=1,r.subTo(g,r)),n.ONE.dlShiftTo(h,g),g.subTo(a,a);a.t<h;)a[a.t++]=0;for(;0<=--m;){var w=r[--v]==l?this.DM:Math.floor(r[v]*b+(r[v-1]+y)*_);if((r[v]+=a.am(0,w,r,m,0,h))<w)for(a.dlShiftTo(m,g),r.subTo(g,r);r[v]<--w;)r.subTo(g,r)}null!=e&&(r.drShiftTo(h,e),c!=f&&n.ZERO.subTo(e,e)),r.t=h,r.clamp(),0<u&&r.rShiftTo(u,r),c<0&&n.ZERO.subTo(r,r)}}},n.prototype.invDigit=function(){if(this.t<1)return 0;var t=this[0];if(0==(1&t))return 0;var e=3&t;return 0<(e=(e=(e=(e=e*(2-(15&t)*e)&15)*(2-(255&t)*e)&255)*(2-((65535&t)*e&65535))&65535)*(2-t*e%this.DV)%this.DV)?this.DV-e:-e},n.prototype.isEven=function(){return 0==(0<this.t?1&this[0]:this.s)},n.prototype.exp=function(t,e){if(4294967295<t||t<1)return n.ONE;var r=i(),s=i(),o=e.convert(this),a=d(t)-1;for(o.copyTo(r);0<=--a;)if(e.sqrTo(r,s),0<(t&1<<a))e.mulTo(s,o,r);else{var c=r;r=s,s=c}return e.revert(r)},n.prototype.toString=function(t){if(this.s<0)return"-"+this.negate().toString(t);var e;if(16==t)e=4;else if(8==t)e=3;else if(2==t)e=1;else if(32==t)e=5;else{if(4!=t)return this.toRadix(t);e=2}var r,n=(1<<e)-1,i=!1,s="",o=this.t,a=this.DB-o*this.DB%e;if(0<o--)for(a<this.DB&&0<(r=this[o]>>a)&&(i=!0,s=f(r));0<=o;)a<e?(r=(this[o]&(1<<a)-1)<<e-a,r|=this[--o]>>(a+=this.DB-e)):(r=this[o]>>(a-=e)&n,a<=0&&(a+=this.DB,--o)),0<r&&(i=!0),i&&(s+=f(r));return i?s:"0"},n.prototype.negate=function(){var t=i();return n.ZERO.subTo(this,t),t},n.prototype.abs=function(){return this.s<0?this.negate():this},n.prototype.compareTo=function(t){var e=this.s-t.s;if(0!=e)return e;var r=this.t;if(0!=(e=r-t.t))return this.s<0?-e:e;for(;0<=--r;)if(0!=(e=this[r]-t[r]))return e;return 0},n.prototype.bitLength=function(){return this.t<=0?0:this.DB*(this.t-1)+d(this[this.t-1]^this.s&this.DM)},n.prototype.mod=function(t){var e=i();return this.abs().divRemTo(t,null,e),this.s<0&&0<e.compareTo(n.ZERO)&&t.subTo(e,e),e},n.prototype.modPowInt=function(t,e){var r;return r=t<256||e.isEven()?new l(e):new p(e),this.exp(t,r)},n.prototype.clone=function(){var t=i();return this.copyTo(t),t},n.prototype.intValue=function(){if(this.s<0){if(1==this.t)return this[0]-this.DV;if(0==this.t)return-1}else{if(1==this.t)return this[0];if(0==this.t)return 0}return(this[1]&(1<<32-this.DB)-1)<<this.DB|this[0]},n.prototype.byteValue=function(){return 0==this.t?this.s:this[0]<<24>>24},n.prototype.shortValue=function(){return 0==this.t?this.s:this[0]<<16>>16},n.prototype.signum=function(){return this.s<0?-1:this.t<=0||1==this.t&&this[0]<=0?0:1},n.prototype.toByteArray=function(){var t=this.t,e=new Array;e[0]=this.s;var r,n=this.DB-t*this.DB%8,i=0;if(0<t--)for(n<this.DB&&(r=this[t]>>n)!=(this.s&this.DM)>>n&&(e[i++]=r|this.s<<this.DB-n);0<=t;)n<8?(r=(this[t]&(1<<n)-1)<<8-n,r|=this[--t]>>(n+=this.DB-8)):(r=this[t]>>(n-=8)&255,n<=0&&(n+=this.DB,--t)),0!=(128&r)&&(r|=-256),0==i&&(128&this.s)!=(128&r)&&++i,(0<i||r!=this.s)&&(e[i++]=r);return e},n.prototype.equals=function(t){return 0==this.compareTo(t)},n.prototype.min=function(t){return this.compareTo(t)<0?this:t},n.prototype.max=function(t){return 0<this.compareTo(t)?this:t},n.prototype.and=function(t){var e=i();return this.bitwiseTo(t,b,e),e},n.prototype.or=function(t){var e=i();return this.bitwiseTo(t,_,e),e},n.prototype.xor=function(t){var e=i();return this.bitwiseTo(t,y,e),e},n.prototype.andNot=function(t){var e=i();return this.bitwiseTo(t,v,e),e},n.prototype.not=function(){for(var t=i(),e=0;e<this.t;++e)t[e]=this.DM&~this[e];return t.t=this.t,t.s=~this.s,t},n.prototype.shiftLeft=function(t){var e=i();return t<0?this.rShiftTo(-t,e):this.lShiftTo(t,e),e},n.prototype.shiftRight=function(t){var e=i();return t<0?this.lShiftTo(-t,e):this.rShiftTo(t,e),e},n.prototype.getLowestSetBit=function(){for(var t=0;t<this.t;++t)if(0!=this[t])return t*this.DB+m(this[t]);return this.s<0?this.t*this.DB:-1},n.prototype.bitCount=function(){for(var t=0,e=this.s&this.DM,r=0;r<this.t;++r)t+=g(this[r]^e);return t},n.prototype.testBit=function(t){var e=Math.floor(t/this.DB);return e>=this.t?0!=this.s:0!=(this[e]&1<<t%this.DB)},n.prototype.setBit=function(t){return this.changeBit(t,_)},n.prototype.clearBit=function(t){return this.changeBit(t,v)},n.prototype.flipBit=function(t){return this.changeBit(t,y)},n.prototype.add=function(t){var e=i();return this.addTo(t,e),e},n.prototype.subtract=function(t){var e=i();return this.subTo(t,e),e},n.prototype.multiply=function(t){var e=i();return this.multiplyTo(t,e),e},n.prototype.divide=function(t){var e=i();return this.divRemTo(t,e,null),e},n.prototype.remainder=function(t){var e=i();return this.divRemTo(t,null,e),e},n.prototype.divideAndRemainder=function(t){var e=i(),r=i();return this.divRemTo(t,e,r),new Array(e,r)},n.prototype.modPow=function(t,e){var r,n,s=t.bitLength(),o=h(1);if(s<=0)return o;r=s<18?1:s<48?3:s<144?4:s<768?5:6,n=s<8?new l(e):e.isEven()?new S(e):new p(e);var a=new Array,c=3,f=r-1,u=(1<<r)-1;if(a[1]=n.convert(this),1<r){var b=i();for(n.sqrTo(a[1],b);c<=u;)a[c]=i(),n.mulTo(b,a[c-2],a[c]),c+=2}var _,y,v=t.t-1,m=!0,g=i();for(s=d(t[v])-1;0<=v;){for(f<=s?_=t[v]>>s-f&u:(_=(t[v]&(1<<s+1)-1)<<f-s,0<v&&(_|=t[v-1]>>this.DB+s-f)),c=r;0==(1&_);)_>>=1,--c;if((s-=c)<0&&(s+=this.DB,--v),m)a[_].copyTo(o),m=!1;else{for(;1<c;)n.sqrTo(o,g),n.sqrTo(g,o),c-=2;0<c?n.sqrTo(o,g):(y=o,o=g,g=y),n.mulTo(g,a[_],o)}for(;0<=v&&0==(t[v]&1<<s);)n.sqrTo(o,g),y=o,o=g,g=y,--s<0&&(s=this.DB-1,--v)}return n.revert(o)},n.prototype.modInverse=function(t){var e=t.isEven();if(this.isEven()&&e||0==t.signum())return n.ZERO;for(var r=t.clone(),i=this.clone(),s=h(1),o=h(0),a=h(0),c=h(1);0!=r.signum();){for(;r.isEven();)r.rShiftTo(1,r),e?(s.isEven()&&o.isEven()||(s.addTo(this,s),o.subTo(t,o)),s.rShiftTo(1,s)):o.isEven()||o.subTo(t,o),o.rShiftTo(1,o);for(;i.isEven();)i.rShiftTo(1,i),e?(a.isEven()&&c.isEven()||(a.addTo(this,a),c.subTo(t,c)),a.rShiftTo(1,a)):c.isEven()||c.subTo(t,c),c.rShiftTo(1,c);0<=r.compareTo(i)?(r.subTo(i,r),e&&s.subTo(a,s),o.subTo(c,o)):(i.subTo(r,i),e&&a.subTo(s,a),c.subTo(o,c))}return 0!=i.compareTo(n.ONE)?n.ZERO:0<=c.compareTo(t)?c.subtract(t):c.signum()<0?(c.addTo(t,c),c.signum()<0?c.add(t):c):c},n.prototype.pow=function(t){return this.exp(t,new w)},n.prototype.gcd=function(t){var e=this.s<0?this.negate():this.clone(),r=t.s<0?t.negate():t.clone();if(e.compareTo(r)<0){var n=e;e=r,r=n}var i=e.getLowestSetBit(),s=r.getLowestSetBit();if(s<0)return e;for(i<s&&(s=i),0<s&&(e.rShiftTo(s,e),r.rShiftTo(s,r));0<e.signum();)0<(i=e.getLowestSetBit())&&e.rShiftTo(i,e),0<(i=r.getLowestSetBit())&&r.rShiftTo(i,r),0<=e.compareTo(r)?(e.subTo(r,e),e.rShiftTo(1,e)):(r.subTo(e,r),r.rShiftTo(1,r));return 0<s&&r.lShiftTo(s,r),r},n.prototype.isProbablePrime=function(t){var e,r=this.abs();if(1==r.t&&r[0]<=E[E.length-1]){for(e=0;e<E.length;++e)if(r[0]==E[e])return!0;return!1}if(r.isEven())return!1;for(e=1;e<E.length;){for(var n=E[e],i=e+1;i<E.length&&n<x;)n*=E[i++];for(n=r.modInt(n);e<i;)if(n%E[e++]==0)return!1}return r.millerRabin(t)},n.prototype.square=function(){var t=i();return this.squareTo(t),t},n.ZERO=h(0),n.ONE=h(1),n.valueOf=i,e.BigInteger=n},function(t,e,r){var n=r(0).sjcl,i=r(56)({sjcl:n});t.exports=i},function(t,e,r){t.exports=function(t){var e=t.sjcl,n=r(26)({sjcl:t.sjcl}),i=r(57)({sjcl:t.sjcl}),s=r(58)({sjcl:t.sjcl}),o=r(59)({sjcl:t.sjcl});function a(t){return e.bitArray.bitSlice(e.hash.sha512.hash(e.codec.bytes.toBits(t)),0,256)}function c(t,e){return[].concat(t,e>>24,e>>16&255,e>>8&255,255&e)}function f(t){if(this.secret=t,!this.secret)throw"Invalid secret."}return f.prototype={getPrivateKey:function(t){return n.decode_base_check(33,this.secret)},getPrivateGenerator:function(t){for(var r=0;privateGenerator=e.bn.fromBits(a(c(t,r))),r++,!e.ecc.curves.c256.r.greaterEquals(privateGenerator););return privateGenerator},getPublicGenerator:function(){var t=this.getPrivateKey(this.secret),e=this.getPrivateGenerator(t);return o.fromPrivateGenerator(e)},getPublicKey:function(t){for(var r,n=0;r=e.bn.fromBits(a(c(c(t.toBytesCompressed(),0),n))),n++,!e.ecc.curves.c256.r.greaterEquals(r););return e.ecc.curves.c256.G.mult(r).toJac().add(t).toAffine()},getAddress:function(){var t=this.getPrivateKey(this.secret),e=this.getPrivateGenerator(t),r=o.fromPrivateGenerator(e).value,n=this.getPublicKey(r);return s.fromPublicKey(n)}},f.getRandom=function(){return new f(i.getRandom().value)},f.generate=function(){var t=i.getRandom().value;return{address:new f(t).getAddress().value,secret:t}},f}},function(t,e,r){t.exports=function(t){var e=t.sjcl,n=r(26)({sjcl:e});function i(t){this.value=t}return i.fromBytes=function(t){return new i(n.encode_base_check(33,t))},i.getRandom=function(){for(var t=0;t<8;t++)e.random.addEntropy(Math.random(),32,"Math.random()");var r=e.codec.bytes.fromBits(e.random.randomWords(4));return i.fromBytes(r)},i}},function(t,e,r){t.exports=function(t){var e=t.sjcl,n=r(26)({sjcl:e});function i(t){this.value=t}return i.fromPublicKey=function(t){var r=e.codec.bytes.fromBits(function(t){return e.hash.ripemd160.hash(e.hash.sha256.hash(t))}(e.codec.bytes.toBits(t.toBytesCompressed())));return new this(n.encode_base_check(0,r))},i}},function(t,e){t.exports=function(t){var e=t.sjcl;function r(t){if(!(t instanceof e.ecc.point))throw new Error("eccPoint must be a sjcl.ecc.point");this.value=t}return r.fromPrivateGenerator=function(t){return new this(e.ecc.curves.c256.G.mult(t))},r.prototype={toString:function(){return this.value.toString()}},r}},function(t,e,r){e.Remote=r(61).Remote,e.Request=r(39).Request,e.Account=r(40).Account,e.Transaction=r(16).Transaction,e.Server=r(20).Server,["Remote","Request","Transaction","Account","Server"].forEach(function(t){var r=e[t];Object.keys(r.prototype).forEach(function(t){var e=/([A-Z]{1})[a-z]+/g;if(e.test(t)){var n=t.replace(e,function(t){return"_"+t.toLowerCase()});r.prototype[n]=r.prototype[t]}})})},function(t,e,r){var n=r(8).EventEmitter,i=r(5),s=r(13),o=r(33),a=r(20).Server,c=r(39).Request,f=(a=r(20).Server,r(6).Amount),u=r(21).Currency,h=r(3).UInt160,d=r(16).Transaction,l=r(40).Account,p=r(84).Meta,b=r(85).OrderBook,_=r(86).PathFind,y=r(37).SerializedObject,v=r(22).StreamError,m=r(0),g=r(0).sjcl,w=r(18),A=r(23).internal.sub("remote");function S(t,e){n.call(this);var r=this;if(t=t||{},this.trusted=Boolean(t.trusted),this.state="offline",this._server_fatal=!1,this._allow_partial_history="boolean"!=typeof t.allow_partial_history||t.allow_partial_history,this.local_sequence=Boolean(t.local_sequence),this.local_fee="boolean"!=typeof t.local_fee||t.local_fee,this.local_signing="boolean"!=typeof t.local_signing||t.local_signing,this.canonical_signing="boolean"!=typeof t.canonical_signing||t.canonical_signing,this.fee_cushion="number"==typeof t.fee_cushion?t.fee_cushion:1.2,this.max_fee="number"==typeof t.max_fee?t.max_fee:1/0,this._ledger_current_index=void 0,this._ledger_hash=void 0,this._ledger_time=void 0,this._stand_alone=void 0,this._testnet=void 0,this.trace=Boolean(t.trace),this._transaction_subs=0,this._connection_count=0,this._connected=!1,this._should_connect=!0,this._submission_timeout=1e3*("number"==typeof t.submission_timeout?t.submission_timeout:20),this._received_tx=o({max:100}),this._cur_path_find=null,this.local_signing&&(this.local_sequence=!0,this.local_fee=!0),this._servers=[],this._primary_server=void 0,this.accounts={},this._accounts={},this._books={},this.secrets={},this.ledgers={current:{account_root:{}}},"number"!=typeof this._submission_timeout)throw new TypeError('Remote "submission_timeout" configuration is not a Number');if("number"!=typeof this.max_fee)throw new TypeError('Remote "max_fee" configuration is not a Number');if("number"!=typeof this.fee_cushion)throw new TypeError('Remote "fee_cushion" configuration is not a Number');if(!/^(undefined|boolean)$/.test(typeof t.trace))throw new TypeError('Remote "trace" configuration is not a Boolean');if("boolean"!=typeof this.local_signing)throw new TypeError('Remote "local_signing" configuration is not a Boolean');if("boolean"!=typeof this.local_fee)throw new TypeError('Remote "local_fee" configuration is not a Boolean');if("boolean"!=typeof this.local_sequence)throw new TypeError('Remote "local_sequence" configuration is not a Boolean');if(!/^(undefined|number)$/.test(typeof t.ping))throw new TypeError('Remote "ping" configuration is not a Number');if(!/^(undefined|object)$/.test(typeof t.storage))throw new TypeError('Remote "storage" configuration is not an Object');!t.hasOwnProperty("servers")&&t.hasOwnProperty("websocket_ip")&&(t.servers=[{host:t.websocket_ip,port:t.websocket_port,secure:t.websocket_ssl,trusted:t.trusted}]),(t.servers||[]).forEach(function(t){r.addServer(t)});var i=t.maxListeners||t.max_listeners||0;function s(){r.reconnect()}this._servers.concat(this).forEach(function(t){t instanceof n&&t.setMaxListeners(i)}),this.on("newListener",function(t,e){"transaction_all"===t&&(!r._transaction_subs&&r.isConnected()&&r.request_subscribe("transactions").request(),r._transaction_subs+=1)}),this.on("removeListener",function(t,e){"transaction_all"===t&&(r._transaction_subs-=1,!r._transaction_subs&&r.isConnected()&&r.request_unsubscribe("transactions").request())}),t.storage&&(this.storage=t.storage,this.once("connect",this.getPendingTransactions.bind(this))),t.ping&&this.on("connect",function(){r._pingInterval=setInterval(function(){var t=r.requestPing();t.on("error",function(){}),t.broadcast()},1e3*t.ping)}),"undefined"!=typeof window&&(window.addEventListener?window.addEventListener("online",s):window.attachEvent&&window.attachEvent("ononline",s))}i.inherits(S,n),S.flags={account_root:{PasswordSpent:65536,RequireDestTag:131072,RequireAuth:262144,DisallowSTM:524288,DisableMaster:1048576},offer:{Passive:65536,Sell:131072},state:{LowReserve:65536,HighReserve:131072,LowAuth:262144,HighAuth:524288,LowNoStream:1048576,HighNoStream:2097152}},S.from_config=function(t,e){var r=new S("string"==typeof t?w.servers[t]:t,e);return w.accounts&&Object.keys(w.accounts).forEach(function(t){var e=w.accounts[t];"object"==typeof e&&e.secret&&(r.setSecret(t,e.secret),r.setSecret(e.account,e.secret))}),r},S.isValidMessage=function(t){return"object"==typeof t&&"string"==typeof t.type},S.isValidLedgerData=function(t){return"object"==typeof t&&"number"==typeof t.fee_base&&"number"==typeof t.fee_ref&&"string"==typeof t.ledger_hash&&"number"==typeof t.ledger_index&&"number"==typeof t.ledger_time&&"number"==typeof t.reserve_base&&"number"==typeof t.reserve_inc},S.isValidLoadStatus=function(t){return"number"==typeof t.load_base&&"number"==typeof t.load_factor},S.prototype._setState=function(t){if(this.state!==t)switch(this.trace&&A.info("set_state:",t),this.state=t,this.emit("state",t),t){case"online":this._online_state="open",this._connected=!0,this.emit("connect"),this.emit("connected");break;case"offline":this._online_state="closed",this._connected=!1,this.emit("disconnect"),this.emit("disconnected")}},S.prototype.setServerFatal=function(){this._server_fatal=!0},S.prototype.setTrace=function(t){return this.trace=void 0===t||t,this},S.prototype._trace=function(){this.trace&&A.info.apply(A,arguments)},S.prototype.setSecret=function(t,e){this.secrets[t]=e},S.prototype.getPendingTransactions=function(){var t=this;function e(e){if("object"==typeof e){var r=t.transaction();r.parseJson(e.tx_json),r.clientID(e.clientID),Object.keys(e).forEach(function(t){switch(t){case"secret":case"submittedIDs":case"submitIndex":r[t]=e[t]}}),r.submit()}}this.storage.getPendingTransactions(function(t,r){!t&&Array.isArray(r)&&r.forEach(e)})},S.prototype.addServer=function(t){var e=this,r=new a(this,t);return r.on("message",function(t){e._handleMessage(t,r)}),r.on("connect",function(){e._connection_count+=1,t.primary&&e._setPrimaryServer(r),1===e._connection_count&&e._setState("online"),e._connection_count===e._servers.length&&e.emit("ready")}),r.on("disconnect",function(){e._connection_count--,0===e._connection_count&&e._setState("offline")}),this._servers.push(r),this},S.prototype.reconnect=function(){if(this._should_connect)return A.info("reconnecting"),this._servers.forEach(function(t){t.reconnect()}),this},S.prototype.connect=function(t){if(!this._servers.length)throw new Error("No servers available.");switch(typeof t){case"undefined":break;case"function":this.once("connect",t);break;default:if(!Boolean(t))return this.disconnect()}return this._should_connect=!0,this._servers.forEach(function(t){t.connect()}),this},S.prototype.disconnect=function(t){if(!this._servers.length)throw new Error("No servers available, not disconnecting");return t="function"==typeof t?t:function(){},this.isConnected()?(this._should_connect=!1,this.once("disconnect",t),this._servers.forEach(function(t){t.disconnect()}),this._set_state("offline")):t(),this},S.prototype._handleMessage=function(t,e){try{t=JSON.parse(t)}catch(t){}if(S.isValidMessage(t))switch(t.type){case"ledgerClosed":this._handleLedgerClosed(t,e);break;case"serverStatus":this._handleServerStatus(t,e);break;case"transaction":this._handleTransaction(t,e);break;case"path_find":this._handlePathFind(t,e);break;default:this.trace&&A.info(t.type+": ",t)}else this.emit("error",new v("remoteUnexpected","Unexpected response from remote"))},S.prototype._handleLedgerClosed=function(t,e){var r=this;if(S.isValidLedgerData(t)){var n=t.ledger_index>=this._ledger_current_index;(isNaN(this._ledger_current_index)||n)&&(this._ledger_time=t.ledger_time,this._ledger_hash=t.ledger_hash,this._ledger_current_index=t.ledger_index+1,this.isConnected()?this.emit("ledger_closed",t,e):this.once("connect",function(){r.emit("ledger_closed",t,e)}))}},S.prototype._handleServerStatus=function(t,e){this.emit("server_status",t,e)},S.prototype._handleTransaction=function(t,e){var r=this,n=t.transaction.hash;if(!this._received_tx.get(n)){t.validated&&this._received_tx.set(n,!0),this.trace&&A.info("tx:",t);var i=t.meta||t.metadata;i?(t.mmeta=new p(i),t.mmeta.getAffectedAccounts().forEach(s.bind(this._accounts)),t.mmeta.getAffectedBooks().forEach(s.bind(this._books))):["Account","Destination"].forEach(function(e){s.call(r._accounts,t.transaction[e])}),this.emit("transaction",t,e),this.emit("transaction_all",t,e)}function s(e){var r=this[e];r&&"function"==typeof r.notify&&r.notify(t)}},S.prototype._handlePathFind=function(t,e){this._cur_path_find&&this._cur_path_find.notify_update(t),this.emit("path_find_all",t,e)},S.prototype.getLedgerHash=function(){return this._ledger_hash},S.prototype._setPrimaryServer=S.prototype.setPrimaryServer=function(t){this._primary_server&&(this._primary_server._primary=!1),this._primary_server=t,this._primary_server._primary=!0},S.prototype.isConnected=function(){return this._connected},S.prototype.getConnectedServers=function(){for(var t=[],e=0;e<this._servers.length;e++)this._servers[e].isConnected()&&t.push(this._servers[e]);return t},S.prototype._getServer=S.prototype.getServer=function(){if(this._primary_server&&this._primary_server.isConnected())return this._primary_server;if(!this._servers.length)return null;var t=this.getConnectedServers();if(0===t.length||!t[0])return null;for(var e=t[0],r=e._score+e._fee,n=1;n<t.length;n++){var i=t[n],s=i._score+i._fee;s<r&&(e=i,r=s)}return e},S.prototype.request=function(t){if("string"==typeof t){if(/^request_/.test(t)||(t="request_"+t),"function"!=typeof this[t])throw new Error("Command does not exist: "+t);var e=Array.prototype.slice.call(arguments,1);return this[t].apply(this,e)}if(!(t instanceof c))throw new Error("Argument is not a Request");if(this._servers.length)if(this.isConnected())if(null===t.server)t.emit("error",new Error("Server does not exist"));else{var r=t.server||this.getServer();r?r._request(t):t.emit("error",new Error("No servers available"))}else this.once("connect",this.request.bind(this,t));else t.emit("error",new Error("No servers available"))},S.prototype.ping=S.prototype.requestPing=function(t,e){var r=new c(this,"ping");switch(typeof t){case"function":e=t;break;case"string":r.setServer(t)}var n=Date.now();return r.once("success",function(){r.emit("pong",Date.now()-n)}),r.callback(e,"pong"),r},S.prototype.requestServerInfo=function(t){return new c(this,"server_info").callback(t)},S.prototype.requestLedger=function(t,e){var r=new c(this,"ledger");switch(typeof t){case"undefined":break;case"function":e=t;break;case"object":Object.keys(t).forEach(function(e){switch(e){case"full":case"expand":case"transactions":case"accounts":r.message[e]=!0;break;case"ledger_index":case"ledger_hash":r.message[e]=t[e]}},t);break;default:r.ledgerSelect(t)}return r.callback(e),r},S.prototype.requestLedgerClosed=S.prototype.requestLedgerHash=function(t){return new c(this,"ledger_closed").callback(t)},S.prototype.requestLedgerHeader=function(t){return new c(this,"ledger_header").callback(t)},S.prototype.requestLedgerCurrent=function(t){return new c(this,"ledger_current").callback(t)},S.prototype.requestLedgerEntry=function(t,e){var r=this,n=new c(this,"ledger_entry");return"function"==typeof t&&(e=t),"account_root"===t&&(n.request_default=n.request,n.request=function(){var e=!0;if(!r._ledger_hash&&"account_root"===t){var i=r.ledgers.current.account_root;i=i||(r.ledgers.current.account_root={});var s=r.ledgers.current.account_root[n.message.account_root];if(s)n.emit("success",{node:s}),e=!1;else switch(t){case"account_root":n.once("success",function(t){r.ledgers.current.account_root[t.node.Account]=t.node})}}e&&n.request_default()}),n.callback(e),n},S.prototype.requestSubscribe=function(t,e){var r=new c(this,"subscribe");return t&&(r.message.streams=Array.isArray(t)?t:[t]),r.callback(e),r},S.prototype.requestUnsubscribe=function(t,e){var r=new c(this,"unsubscribe");return t&&(r.message.streams=Array.isArray(t)?t:[t]),r.callback(e),r},S.prototype.requestTransactionEntry=function(t,e,r){var n=new c(this,"transaction_entry");switch(n.txHash(t),typeof e){case"string":case"number":n.ledgerSelect(e);break;case"undefined":case"function":n.ledgerIndex("validated"),r=e;break;default:throw new Error("Invalid ledger_hash type")}return n.callback(r),n},S.prototype.requestTransaction=S.prototype.requestTx=function(t,e){var r=new c(this,"tx");return r.message.transaction=t,r.callback(e),r},S.accountRequest=function(t,e,r,n,i,s){if("object"==typeof e){var o=e;s=r,n=o.ledger,r=o.account_index||o.accountIndex,e=o.accountID||o.account,i=o.peer}var a=arguments[arguments.length-1];"function"==typeof a&&(s=a);var f=new c(this,t);return e=h.json_rewrite(e),f.message.ident=e,f.message.account=e,"number"==typeof r&&(f.message.index=r),/^(undefined|function)$/.test(typeof n)||f.ledgerChoose(n),/^(undefined|function)$/.test(typeof i)||(f.message.peer=h.json_rewrite(i)),f.callback(s),f},S.prototype.requestAccountInfo=function(t,e){var r=Array.prototype.concat.apply(["account_info"],arguments);return S.accountRequest.apply(this,r)},S.prototype.requestAccountCurrencies=function(t,e){var r=Array.prototype.concat.apply(["account_currencies"],arguments);return S.accountRequest.apply(this,r)},S.prototype.requestAccountLines=function(t,e,r,n,i){var s=Array.prototype.concat.apply(["account_lines"],arguments);return S.accountRequest.apply(this,s)},S.prototype.requestAccountOffers=function(t,e,r,n){var i=Array.prototype.concat.apply(["account_offers"],arguments);return S.accountRequest.apply(this,i)},S.prototype.requestAccountTransactions=S.prototype.requestAccountTx=function(t,e){var r=new c(this,"account_tx");return void 0!==t.min_ledger&&(t.ledger_index_min=t.min_ledger),void 0!==t.max_ledger&&(t.ledger_index_max=t.max_ledger),t.binary&&void 0===t.parseBinary&&(t.parseBinary=!0),Object.keys(t).forEach(function(t){switch(t){case"account":case"ledger_index_min":case"ledger_index_max":case"binary":case"count":case"descending":case"offset":case"limit":case"forward":case"marker":r.message[t]=this[t]}},t),r.once("success",function(e){t.parseBinary&&(e.transactions=e.transactions.map(S.parseBinaryTransaction)),r.emit("transactions",e)}),r.callback(e,"transactions"),r},S.parseBinaryTransaction=function(t){var e={validated:t.validated};return e.meta=new y(t.meta).to_json(),e.tx=new y(t.tx_blob).to_json(),e.tx.ledger_index=t.ledger_index,e.tx.hash=d.from_json(e.tx).hash(),e},S.prototype.requestTransactionHistory=S.prototype.requestTxHistory=function(t,e){var r=new c(this,"tx_history");return r.message.start=t,r.callback(e),r},S.prototype.requestBookOffers=function(t,e,r,n){var i=arguments[arguments.length-1];if(t.hasOwnProperty("gets")||t.hasOwnProperty("taker_gets")){var s=t;n=e,r=s.taker,e=s.pays||s.taker_pays,t=s.gets||s.taker_gets}"function"==typeof i&&(n=i);var o=new c(this,"book_offers");return o.message.taker_gets={currency:u.json_rewrite(t.currency,{force_hex:!0})},u.from_json(o.message.taker_gets.currency).is_native()||(o.message.taker_gets.issuer=h.json_rewrite(t.issuer)),o.message.taker_pays={currency:u.json_rewrite(e.currency,{force_hex:!0})},u.from_json(o.message.taker_pays.currency).is_native()||(o.message.taker_pays.issuer=h.json_rewrite(e.issuer)),o.message.taker=r||h.ACCOUNT_ONE,o.callback(n),o},S.prototype.requestWalletAccounts=function(t,e){m.assert(this.trusted);var r=new c(this,"wallet_accounts");return r.message.seed=t,r.callback(e),r},S.prototype.requestSign=function(t,e,r){m.assert(this.trusted);var n=new c(this,"sign");return n.message.secret=t,n.message.tx_json=e,n.callback(r),n},S.prototype.requestSubmit=function(t){return new c(this,"submit").callback(t)},S.prototype._serverPrepareSubscribe=function(t,e){var r=this,n=["ledger","server"];"function"==typeof t&&(e=t),this._transaction_subs&&n.push("transactions");var i=this.requestSubscribe(n);return i.on("error",function(t){r.trace&&A.info("Initial server subscribe failed",t)}),i.once("success",function(e){if(r._stand_alone=!!e.stand_alone,r._testnet=!!e.testnet,"string"==typeof e.random){for(var n=e.random.match(/[0-9A-F]{8}/gi);n&&n.length;)g.random.addEntropy(parseInt(n.pop(),16));r.emit("random",m.hexToArray(e.random))}r._handleLedgerClosed(e,t),r.emit("subscribed")}),r.emit("prepare_subscribe",i),i.callback(e,"subscribed"),i},S.prototype.ledgerAccept=S.prototype.requestLedgerAccept=function(t){if(this._stand_alone){var e=new c(this,"ledger_accept");return this.once("ledger_closed",function(t){e.emit("ledger_closed",t)}),e.callback(t,"ledger_closed"),e.request(),this}this.emit("error",new v("notStandAlone"))},S.accountRootRequest=function(t,e,r,n,i){"object"==typeof r&&(i=n,n=r.ledger,r=r.account);var s=arguments[arguments.length-1];"function"==typeof s&&(i=s);var o=this.requestLedgerEntry("account_root");return o.accountRoot(r),o.ledgerChoose(n),o.once("success",function(r){o.emit(t,e(r))}),o.callback(i,t),o},S.prototype.requestAccountBalance=function(t,e,r){var n=Array.prototype.concat.apply(["account_balance",function(t){return f.from_json(t.node.Balance)}],arguments);return S.accountRootRequest.apply(this,n)},S.prototype.requestAccountFlags=function(t,e,r){var n=Array.prototype.concat.apply(["account_flags",function(t){return t.node.Flags}],arguments);return S.accountRootRequest.apply(this,n)},S.prototype.requestOwnerCount=function(t,e,r){var n=Array.prototype.concat.apply(["owner_count",function(t){return t.node.OwnerCount}],arguments);return S.accountRootRequest.apply(this,n)},S.prototype.getAccount=function(t){return this._accounts[h.json_rewrite(t)]},S.prototype.addAccount=function(t){var e=new l(this,t);return e.isValid()&&(this._accounts[t]=e),e},S.prototype.account=S.prototype.findAccount=function(t){return this.getAccount(t)||this.addAccount(t)},S.prototype.pathFind=S.prototype.createPathFind=function(t,e,r,n){if("object"==typeof t){var i=t;n=i.src_currencies,r=i.dst_amount,e=i.dst_account,t=i.src_account}var s=new _(this,t,e,r,n);return this._cur_path_find&&this._cur_path_find.notify_superceded(),s.create(),this._cur_path_find=s},S.prepareTrade=function(t,e){return t+(u.from_json(t).is_native()?"":"/"+e)},S.prototype.book=S.prototype.createOrderBook=function(t,e,r,n){if("object"==typeof t){var i=t;n=i.issuer_pays,r=i.currency_pays,e=i.issuer_gets,t=i.currency_gets}var s=S.prepareTrade(t,e)+":"+S.prepareTrade(r,n);if(this._books.hasOwnProperty(s))return this._books[s];var o=new b(this,t,e,r,n,s);return o.is_valid()&&(this._books[s]=o),o},S.prototype.accountSeq=S.prototype.getAccountSequence=function(t,e){t=h.json_rewrite(t);var r=this.accounts[t];if(r){var n=r.seq,i={ADVANCE:1,REWIND:-1}[e.toUpperCase()]||0;return r.seq+=i,n}},S.prototype.setAccountSequence=S.prototype.setAccountSeq=function(t,e){t=h.json_rewrite(t),this.accounts.hasOwnProperty(t)||(this.accounts[t]={}),this.accounts[t].seq=e},S.prototype.accountSeqCache=function(t,e,r){if("object"==typeof t){var n=t;r=e,e=n.ledger,t=n.account}this.accounts.hasOwnProperty(t)||(this.accounts[t]={});var i=this.accounts[t],s=i.caching_seq_request;return s||((s=this.requestLedgerEntry("account_root")).accountRoot(t),s.ledgerChoose(e),s.once("success",function(t){delete i.caching_seq_request;var e=t.node.Sequence;i.seq=e,s.emit("success_account_seq_cache",t)}),s.once("error",function(t){delete i.caching_seq_request,s.emit("error_account_seq_cache",t)}),i.caching_seq_request=s),s.callback(r,"success_account_seq_cache","error_account_seq_cache"),s},S.prototype.dirtyAccountRoot=function(t){t=h.json_rewrite(t),delete this.ledgers.current.account_root[t]},S.prototype.requestStreamBalance=function(t,e,r,n,i){if("object"==typeof t){var s=t;i=e,n=s.ledger,r=s.currency,e=s.issuer,t=s.account}var o=this.requestLedgerEntry("stream_state");return o.streamState(t,e,r),o.ledgerChoose(n),o.once("success",function(r){var n=r.node,i=f.from_json(n.LowLimit),s=f.from_json(n.HighLimit),a=f.from_json(n.Balance),c=h.from_json(t).equals(s.issuer());o.emit("stream_state",{account_balance:(c?a.negate():a.clone()).parse_issuer(t),peer_balance:(c?a.clone():a.negate()).parse_issuer(e),account_limit:(c?s:i).clone().parse_issuer(e),peer_limit:(c?i:s).clone().parse_issuer(t),account_quality_in:c?n.HighQualityIn:n.LowQualityIn,peer_quality_in:c?n.LowQualityIn:n.HighQualityIn,account_quality_out:c?n.HighQualityOut:n.LowQualityOut,peer_quality_out:c?n.LowQualityOut:n.HighQualityOut})}),o.callback(i,"stream_state"),o},S.prepareCurrencies=function(t){var e={};return t.hasOwnProperty("issuer")&&(e.issuer=h.json_rewrite(t.issuer)),t.hasOwnProperty("currency")&&(e.currency=u.json_rewrite(t.currency,{force_hex:!0})),e},S.prototype.requestStreamPathFind=function(t,e,r,n,i){if("object"==typeof t){var s=t;i=e,n=s.src_currencies,r=s.dst_amount,e=s.dst_account,t=s.src_account}var o=new c(this,"stream_path_find");return o.message.source_account=h.json_rewrite(t),o.message.destination_account=h.json_rewrite(e),o.message.destination_amount=f.json_rewrite(r),n&&(o.message.source_currencies=n.map(S.prepareCurrencies)),o.callback(i),o},S.prototype.requestPathFindCreate=function(t,e,r,n,i){if("object"==typeof t){var s=t;i=e,n=s.src_currencies,r=s.dst_amount,e=s.dst_account,t=s.src_account}var o=new c(this,"path_find");return o.message.subcommand="create",o.message.source_account=h.json_rewrite(t),o.message.destination_account=h.json_rewrite(e),o.message.destination_amount=f.json_rewrite(r),n&&(o.message.source_currencies=n.map(S.prepareCurrencies)),o.callback(i),o},S.prototype.requestPathFindClose=function(t){var e=new c(this,"path_find");return e.message.subcommand="close",e.callback(t),e},S.prototype.requestUnlList=function(t){return new c(this,"unl_list").callback(t)},S.prototype.requestUnlAdd=function(t,e,r){var n=new c(this,"unl_add");return n.message.node=t,e&&(n.message.comment=void 0),n.callback(r),n},S.prototype.requestUnlDelete=function(t,e){var r=new c(this,"unl_delete");return r.message.node=t,r.callback(e),r},S.prototype.requestPeers=function(t){return new c(this,"peers").callback(t)},S.prototype.requestConnect=function(t,e,r){var n=new c(this,"connect");return n.message.ip=t,e&&(n.message.port=e),n.callback(r),n},S.prototype.transaction=S.prototype.createTransaction=function(t,e){if(0===arguments.length)return new d(this);s.strictEqual(typeof t,"string","TransactionType must be a string"),s.strictEqual(typeof e,"object","Transaction options must be an object");var r=new d(this),n={payment:"payment",accountset:"accountSet",trustset:"trustSet",offercreate:"offerCreate",offercancel:"offerCancel",setregularkey:"setRegularKey",sign:"sign"}[t.toLowerCase()];if(!n)throw new Error("Invalid transaction type: "+t);return r[n](e)},S.prototype.feeTx=function(t){var e=this.getServer();if(!e)throw new Error("No connected servers");return e._feeTx(t)},S.prototype.feeTxUnit=function(){var t=this.getServer();if(!t)throw new Error("No connected servers");return t._feeTxUnit()},S.prototype.reserve=function(t){var e=this.getServer();if(!e)throw new Error("No connected servers");return e._reserve(t)},e.Remote=S},function(t,e){t.exports=function(t){return t&&"object"==typeof t&&"function"==typeof t.copy&&"function"==typeof t.fill&&"function"==typeof t.readUInt8}},function(t,e,r){"use strict";
/*
object-assign
(c) Sindre Sorhus
@license MIT
*/var n=Object.getOwnPropertySymbols,i=Object.prototype.hasOwnProperty,s=Object.prototype.propertyIsEnumerable;t.exports=function(){try{if(!Object.assign)return!1;var t=new String("abc");if(t[5]="de","5"===Object.getOwnPropertyNames(t)[0])return!1;for(var e={},r=0;r<10;r++)e["_"+String.fromCharCode(r)]=r;if("0123456789"!==Object.getOwnPropertyNames(e).map(function(t){return e[t]}).join(""))return!1;var n={};return"abcdefghijklmnopqrst".split("").forEach(function(t){n[t]=t}),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},n)).join("")}catch(t){return!1}}()?Object.assign:function(t,e){for(var r,o,a=function(t){if(null==t)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(t)}(t),c=1;c<arguments.length;c++){for(var f in r=Object(arguments[c]))i.call(r,f)&&(a[f]=r[f]);if(n){o=n(r);for(var u=0;u<o.length;u++)s.call(r,o[u])&&(a[o[u]]=r[o[u]])}}return a}},function(t,e,r){(function(t,n){var i;/*! https://mths.be/punycode v1.4.1 by @mathias */!function(){e&&e.nodeType,t&&t.nodeType;var s="object"==typeof n&&n;s.global!==s&&s.window!==s&&s.self;var o,a=2147483647,c=36,f=1,u=26,h=38,d=700,l=72,p=128,b="-",_=/^xn--/,y=/[^\x20-\x7E]/,v=/[\x2E\u3002\uFF0E\uFF61]/g,m={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},g=c-f,w=Math.floor,A=String.fromCharCode;function S(t){throw new RangeError(m[t])}function E(t,e){for(var r=t.length,n=[];r--;)n[r]=e(t[r]);return n}function x(t,e){var r=t.split("@"),n="";return 1<r.length&&(n=r[0]+"@",t=r[1]),n+E((t=t.replace(v,".")).split("."),e).join(".")}function T(t){for(var e,r,n=[],i=0,s=t.length;i<s;)55296<=(e=t.charCodeAt(i++))&&e<=56319&&i<s?56320==(64512&(r=t.charCodeAt(i++)))?n.push(((1023&e)<<10)+(1023&r)+65536):(n.push(e),i--):n.push(e);return n}function j(t){return E(t,function(t){var e="";return 65535<t&&(e+=A((t-=65536)>>>10&1023|55296),t=56320|1023&t),e+A(t)}).join("")}function k(t,e){return t+22+75*(t<26)-((0!=e)<<5)}function I(t,e,r){var n=0;for(t=r?w(t/d):t>>1,t+=w(t/e);g*u>>1<t;n+=c)t=w(t/g);return w(n+(g+1)*t/(t+h))}function O(t){var e,r,n,i,s,o,h,d,_,y,v,m=[],g=t.length,A=0,E=p,x=l;for((r=t.lastIndexOf(b))<0&&(r=0),n=0;n<r;++n)128<=t.charCodeAt(n)&&S("not-basic"),m.push(t.charCodeAt(n));for(i=0<r?r+1:0;i<g;){for(s=A,o=1,h=c;g<=i&&S("invalid-input"),v=t.charCodeAt(i++),(c<=(d=v-48<10?v-22:v-65<26?v-65:v-97<26?v-97:c)||d>w((a-A)/o))&&S("overflow"),A+=d*o,!(d<(_=h<=x?f:x+u<=h?u:h-x));h+=c)o>w(a/(y=c-_))&&S("overflow"),o*=y;x=I(A-s,e=m.length+1,0==s),w(A/e)>a-E&&S("overflow"),E+=w(A/e),A%=e,m.splice(A++,0,E)}return j(m)}function R(t){var e,r,n,i,s,o,h,d,_,y,v,m,g,E,x,j=[];for(m=(t=T(t)).length,e=p,s=l,o=r=0;o<m;++o)(v=t[o])<128&&j.push(A(v));for(n=i=j.length,i&&j.push(b);n<m;){for(h=a,o=0;o<m;++o)e<=(v=t[o])&&v<h&&(h=v);for(h-e>w((a-r)/(g=n+1))&&S("overflow"),r+=(h-e)*g,e=h,o=0;o<m;++o)if((v=t[o])<e&&++r>a&&S("overflow"),v==e){for(d=r,_=c;!(d<(y=_<=s?f:s+u<=_?u:_-s));_+=c)x=d-y,E=c-y,j.push(A(k(y+x%E,0))),d=w(x/E);j.push(A(k(d,0))),s=I(r,g,n==i),r=0,++n}++r,++e}return j.join("")}o={version:"1.4.1",ucs2:{decode:T,encode:j},decode:O,encode:R,toASCII:function(t){return x(t,function(t){return y.test(t)?"xn--"+R(t):t})},toUnicode:function(t){return x(t,function(t){return _.test(t)?O(t.slice(4).toLowerCase()):t})}},void 0===(i=function(){return o}.call(e,r,e,t))||(t.exports=i)}()}).call(this,r(35)(t),r(14))},function(t,e,r){"use strict";t.exports={isString:function(t){return"string"==typeof t},isObject:function(t){return"object"==typeof t&&null!==t},isNull:function(t){return null===t},isNullOrUndefined:function(t){return null==t}}},function(t,e,r){"use strict";t.exports=function(t,e,r,i){e=e||"&",r=r||"=";var s={};if("string"!=typeof t||0===t.length)return s;var o=/\+/g;t=t.split(e);var a=1e3;i&&"number"==typeof i.maxKeys&&(a=i.maxKeys);var c,f,u=t.length;0<a&&a<u&&(u=a);for(var h=0;h<u;++h){var d,l,p,b,_=t[h].replace(o,"%20"),y=_.indexOf(r);l=0<=y?(d=_.substr(0,y),_.substr(y+1)):(d=_,""),p=decodeURIComponent(d),b=decodeURIComponent(l),c=s,f=p,Object.prototype.hasOwnProperty.call(c,f)?n(s[p])?s[p].push(b):s[p]=[s[p],b]:s[p]=b}return s};var n=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)}},function(t,e,r){"use strict";function n(t){switch(typeof t){case"string":return t;case"boolean":return t?"true":"false";case"number":return isFinite(t)?t:"";default:return""}}t.exports=function(t,e,r,a){return e=e||"&",r=r||"=",null===t&&(t=void 0),"object"==typeof t?s(o(t),function(o){var a=encodeURIComponent(n(o))+r;return i(t[o])?s(t[o],function(t){return a+encodeURIComponent(n(t))}).join(e):a+encodeURIComponent(n(t[o]))}).join(e):a?encodeURIComponent(n(a))+r+encodeURIComponent(n(t)):""};var i=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)};function s(t,e){if(t.map)return t.map(e);for(var r=[],n=0;n<t.length;n++)r.push(e(t[n],n));return r}var o=Object.keys||function(t){var e=[];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.push(r);return e}},function(t,e,r){var n=r(0).sjcl,i=r(3).UInt160,s=r(15).UInt256,o=r(9).Base;function a(){this._curve=n.ecc.curves.c256,this._secret=null,this._pubkey=null}a.from_bn_secret=function(t){return t instanceof this?t.clone():(new this).parse_bn_secret(t)},a.prototype.parse_bn_secret=function(t){return this._secret=new n.ecc.ecdsa.secretKey(n.ecc.curves.c256,t),this},a.prototype._pub=function(){var t=this._curve;if(!this._pubkey&&this._secret){var e=this._secret._exponent;this._pubkey=new n.ecc.ecdsa.publicKey(t,t.G.mult(e))}return this._pubkey},a.prototype._pub_bits=function(){var t=this._pub();if(!t)return null;var e=t._point,r=e.y.mod(2).equals(0);return n.bitArray.concat([n.bitArray.partial(8,r?2:3)],e.x.toBits(this._curve.r.bitLength()))},a.prototype.to_hex_pub=function(){var t=this._pub_bits();return t?n.codec.hex.fromBits(t).toUpperCase():null},a.prototype.get_address=function(){var t=this._pub_bits();if(!t)return null;var e=function(t){return n.hash.ripemd160.hash(n.hash.sha256.hash(t))}(t),r=i.from_bits(e);return r.set_version(o.VER_ACCOUNT_ID),r},a.prototype.sign=function(t){t=s.from_json(t);var e=this._secret.sign(t.to_bits(),0);return e=this._secret.canonicalizeSignature(e),this._secret.encodeDER(e)},e.KeyPair=a},function(t,e){var r=e.Float={};r.toIEEE754=function(t,e,r){var n,i,s,o=(1<<e-1)-1;if(isNaN(t))i=(1<<o)-1,s=1,n=0;else if(t===1/0||t===-1/0)i=(1<<o)-1,n=t<(s=0)?1:0;else if(0===t)n=1/t==-1/(s=i=0)?1:0;else if(n=t<0,(t=Math.abs(t))>=Math.pow(2,1-o)){var a=Math.min(Math.floor(Math.log(t)/Math.LN2),o);i=a+o,s=t*Math.pow(2,r-a)-Math.pow(2,r)}else i=0,s=t/Math.pow(2,1-o-r);var c,f=[];for(c=r;c;c-=1)f.push(s%2?1:0),s=Math.floor(s/2);for(c=e;c;c-=1)f.push(i%2?1:0),i=Math.floor(i/2);f.push(n?1:0),f.reverse();for(var u=f.join(""),h=[];u.length;)h.push(parseInt(u.substring(0,8),2)),u=u.substring(8);return h},r.fromIEEE754=function(t,e,r){for(var n=[],i=t.length;i;i-=1)for(var s=t[i-1],o=8;o;o-=1)n.push(s%2?1:0),s>>=1;n.reverse();var a=n.join(""),c=(1<<e-1)-1,f=parseInt(a.substring(0,1),2)?-1:1,u=parseInt(a.substring(1,1+e),2),h=parseInt(a.substring(1+e),2);return u===(1<<e)-1?0!==h?NaN:1/0*f:0<u?f*Math.pow(2,u-c)*(1+h/Math.pow(2,r)):0!==h?f*Math.pow(2,-(c-1))*(h/Math.pow(2,r)):0*f},r.fromIEEE754Double=function(t){return r.fromIEEE754(t,11,52)},r.toIEEE754Double=function(t){return r.toIEEE754(t,11,52)},r.fromIEEE754Single=function(t){return r.fromIEEE754(t,8,23)},r.toIEEE754Single=function(t){return r.toIEEE754(t,8,23)},r.toIEEE754DoubleString=function(t){return e.toIEEE754Double(t).map(function(t){for(t=t.toString(2);t.length<8;t="0"+t);return t}).join("").replace(/(.)(.{11})(.{52})/,"$1 $2 $3")}},function(t,e){e.read=function(t,e,r,n,i){var s,o,a=8*i-n-1,c=(1<<a)-1,f=c>>1,u=-7,h=r?i-1:0,d=r?-1:1,l=t[e+h];for(h+=d,s=l&(1<<-u)-1,l>>=-u,u+=a;0<u;s=256*s+t[e+h],h+=d,u-=8);for(o=s&(1<<-u)-1,s>>=-u,u+=n;0<u;o=256*o+t[e+h],h+=d,u-=8);if(0===s)s=1-f;else{if(s===c)return o?NaN:1/0*(l?-1:1);o+=Math.pow(2,n),s-=f}return(l?-1:1)*o*Math.pow(2,s-n)},e.write=function(t,e,r,n,i,s){var o,a,c,f=8*s-i-1,u=(1<<f)-1,h=u>>1,d=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,l=n?0:s-1,p=n?1:-1,b=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,o=u):(o=Math.floor(Math.log(e)/Math.LN2),e*(c=Math.pow(2,-o))<1&&(o--,c*=2),2<=(e+=1<=o+h?d/c:d*Math.pow(2,1-h))*c&&(o++,c/=2),u<=o+h?(a=0,o=u):1<=o+h?(a=(e*c-1)*Math.pow(2,i),o+=h):(a=e*Math.pow(2,h-1)*Math.pow(2,i),o=0));8<=i;t[r+l]=255&a,l+=p,a/=256,i-=8);for(o=o<<i|a,f+=i;0<f;t[r+l]=255&o,l+=p,o/=256,f-=8);t[r+l-p]|=128*b}},function(t,e){var r={}.toString;t.exports=Array.isArray||function(t){return"[object Array]"==r.call(t)}},function(t,e,r){function n(t){s(this,t)}var i=r(13),s=r(1),o=r(30),a=r(0),c=a.sjcl,f=r(73).UInt128,u=r(3).UInt160,h=r(15).UInt256,d=r(9).Base,l=r(6),p=l.Amount,b=l.Currency,_=c.codec.hex,y=c.codec.bytes,v=a.jsbn.BigInteger;function m(t){return"number"==typeof t&&isFinite(t)}function g(t){return"string"==typeof t}function w(t,e,r){var i=y.fromBits(_.toBits(e));r||n.serialize_varint(t,i.length),t.append(i)}function A(t,e,r){if(!m(e))throw new Error("Value is not a number",r);if(e<0||e>=Math.pow(256,r))throw new Error("Value out of bounds");for(var n=[],i=0;i<r;i++)n.unshift(e>>>8*i&255);t.append(n)}function S(t,e){var r=0;if(4<e)throw new Error("This function only supports up to four bytes.");for(var n=0;n<e;n++)r+=t.read(1)[0]<<8*(e-n-1);return r>>>0}n.serialize_varint=function(t,e){if(e<0)throw new Error("Variable integers are unsigned.");if(e<=192)t.append([e]);else if(e<=12480)e-=193,t.append([193+(e>>>8),255&e]);else{if(!(e<=918744))throw new Error("Variable integer overflow.");e-=12481,t.append([241+(e>>>16),e>>>8&255,255&e])}},n.prototype.parse_varint=function(t){var e,r=t.read(1)[0];if(254<r)throw new Error("Invalid varint length indicator");return r<=192?e=r:r<=240?e=193+256*(r-193)+t.read(1)[0]:r<=254&&(e=12481+65536*(r-241)+256*t.read(1)[0]+t.read(1)[0]),e};var E=e.Int8=new n({serialize:function(t,e){A(t,e,1)},parse:function(t){return S(t,1)}});E.id=16,(e.Int16=new n({serialize:function(t,e){A(t,e,2)},parse:function(t){return S(t,2)}})).id=1,(e.Int32=new n({serialize:function(t,e){A(t,e,4)},parse:function(t){return S(t,4)}})).id=2,(e.Int64=new n({serialize:function(t,e){var r;if(m(e)){if((e=Math.floor(e))<0)throw new Error("Negative value for unsigned Int64 is invalid.");r=new v(String(e),10)}else if(g(e)){if(!function(t){return g(t)&&/^[0-9A-F]{0,16}$/i.test(t)}(e))throw new Error("Not a valid hex Int64.");r=new v(e,16)}else{if(!(e instanceof v))throw new Error("Invalid type for Int64");if(e.compareTo(v.ZERO)<0)throw new Error("Negative value for unsigned Int64 is invalid.");r=e}var n=r.toString(16);if(16<n.length)throw new Error("Int64 is too large");for(;n.length<16;)n="0"+n;w(t,n,!0)},parse:function(t){var e=t.read(8),r=new v([0].concat(e),256);return i(r instanceof v),r}})).id=3,(e.Hash128=new n({serialize:function(t,e){var r=f.from_json(e);if(!r.is_valid())throw new Error("Invalid Hash128");w(t,r.to_hex(),!0)},parse:function(t){return f.from_bytes(t.read(16))}})).id=4;var x=e.Hash256=new n({serialize:function(t,e){var r=h.from_json(e);if(!r.is_valid())throw new Error("Invalid Hash256");w(t,r.to_hex(),!0)},parse:function(t){return h.from_bytes(t.read(32))}});x.id=5;var T=e.Hash160=new n({serialize:function(t,e){var r=u.from_json(e);if(!r.is_valid())throw new Error("Invalid Hash160");w(t,r.to_hex(),!0)},parse:function(t){return u.from_bytes(t.read(20))}});T.id=17;var j=new n({serialize:function(t,e,r){var n=e.to_bytes();if(!n)throw new Error("Tried to serialize invalid/unimplemented currency type.");t.append(n)},parse:function(t){var e=t.read(20);return b.from_bytes(e)}});function k(t,r,n){var i=o.fieldsInverseMap[r],s=i[0],a=i[1],c=(s<16?s<<4:0)|(a<16?a:0);"LedgerEntryType"===r&&"string"==typeof n&&(n=o.ledger[n][0]),"TransactionResult"===r&&"string"==typeof n&&(n=o.ter[n]),E.serialize(t,c),16<=s&&E.serialize(t,s),16<=a&&E.serialize(t,a);var f=e[o.types[s]];try{f.serialize(t,n)}catch(t){throw t.message+=" ("+r+")",t}}function I(t){var r=t.read(1)[0],n=r>>4;0===n&&(n=t.read(1)[0]);var s=e[o.types[n]];i(s,"Unknown type - header byte is 0x"+r.toString(16));var a=15&r,c=c=0==a?o.fields[n][t.read(1)[0]]:o.fields[n][a];return i(c,"Unknown field - header byte is 0x"+r.toString(16)),[c,s.parse(t)]}(e.Amount=new n({serialize:function(t,e){var r=p.from_json(e);if(!r.is_valid())throw new Error("Not a valid Amount object.");var n=a.arraySet(8,0);if(r.is_native()){var i=r._value.toString(16);if(16<i.length)throw new Error("Value out of bounds");for(;i.length<16;)i="0"+i;(n=y.fromBits(_.toBits(i)))[0]&=63,r.is_negative()||(n[0]|=64)}else{var s=0,o=0;s|=1<<31,r.is_zero()||(r.is_negative()||(s|=1<<30),s|=(97+r._offset&255)<<22,s|=4194303&r._value.shiftRight(32).intValue(),o=4294967295&r._value.intValue()),n=c.codec.bytes.fromBits([s,o])}if(t.append(n),!r.is_native()){var f=r.currency();j.serialize(t,f,!0),t.append(r.issuer().to_bytes())}},parse:function(t){for(var e=new p,r=t.read(8),n=!(127&r[0]),i=1;i<8;i++)n=n&&!r[i];if(128&r[0]){var s=j.parse(t),o=t.read(20),a=u.from_bytes(o);a.set_version(d.VER_ACCOUNT_ID);var c=((63&r[0])<<2)+(r[1]>>>6)-97,f=r.slice(1);f[0]&=63;var h=new v(f,256);if(h.equals(v.ZERO)&&!n)throw new Error("Invalid zero representation");e._value=h,e._offset=c,e._currency=s,e._issuer=a,e._is_native=!1}else{var l=r.slice();l[0]&=63,e._value=new v(l,256),e._is_native=!0}return e._is_negative=!(n||64&r[0]),e}})).id=6,(e.VariableLength=e.VL=new n({serialize:function(t,e){if("string"!=typeof e)throw new Error("Unknown datatype.");w(t,e)},parse:function(t){var e=this.parse_varint(t);return function(t){return c.codec.hex.fromBits(c.codec.bytes.toBits(t)).toUpperCase()}(t.read(e))}})).id=7,(e.Account=new n({serialize:function(t,e){var r=u.from_json(e);if(!r.is_valid())throw new Error("Invalid account!");w(t,r.to_hex())},parse:function(t){var e=this.parse_varint(t);if(20!==e)throw new Error("Non-standard-length account ID");var r=u.from_bytes(t.read(e));return r.set_version(d.VER_ACCOUNT_ID),r}})).id=8,(e.PathSet=new n({typeBoundary:255,typeEnd:0,typeAccount:1,typeCurrency:16,typeIssuer:32,serialize:function(t,e){for(var r=0,n=e.length;r<n;r++){r&&E.serialize(t,this.typeBoundary);for(var i=0,s=e[r].length;i<s;i++){var o=e[r][i],a=0;if(o.account&&(a|=this.typeAccount),o.currency&&(a|=this.typeCurrency),o.issuer&&(a|=this.typeIssuer),E.serialize(t,a),o.account&&t.append(u.from_json(o.account).to_bytes()),o.currency){var c=b.from_json(o.currency,o.non_native);j.serialize(t,c)}o.issuer&&t.append(u.from_json(o.issuer).to_bytes())}}E.serialize(t,this.typeEnd)},parse:function(t){for(var e,r=[],n=[];(e=t.read(1)[0])!==this.typeEnd;)if(e!==this.typeBoundary){var i={};if(e&this.typeAccount&&(i.account=T.parse(t),i.account.set_version(d.VER_ACCOUNT_ID)),e&this.typeCurrency&&(i.currency=j.parse(t),"STM"!==i.currency.to_json()||i.currency.is_native()||(i.non_native=!0)),e&this.typeIssuer&&(i.issuer=T.parse(t),i.issuer.set_version(d.VER_ACCOUNT_ID)),!(i.account||i.currency||i.issuer))throw new Error("Invalid path entry");n.push(i)}else n&&r.push(n),n=[];return n&&r.push(n),r}})).id=18,(e.Vector256=new n({serialize:function(t,e){n.serialize_varint(t,32*e.length);for(var r=0,i=e.length;r<i;r++)x.serialize(t,e[r])},parse:function(t){for(var e=this.parse_varint(t),r=[],n=0;n<e/32;n++)r.push(x.parse(t));return r}})).id=19,e.serialize=e.serialize_whatever=k,e.parse=e.parse_whatever=I,(e.Object=new n({serialize:function(t,e,r){var n=Object.keys(e);(n=n.filter(function(t){return t[0]!==t[0].toLowerCase()})).forEach(function(t){if(void 0===o.fieldsInverseMap[t])throw new Error('JSON contains unknown field: "'+t+'"')}),n=n.sort(function(t,e){var r=o.fieldsInverseMap[t],n=r[0],i=r[1],s=o.fieldsInverseMap[e],a=s[0],c=s[1];return n!==a?n-a:i-c});for(var i=0;i<n.length;i++)k(t,n[i],e[n[i]]);r||E.serialize(t,225)},parse:function(t){for(var e={};225!==t.peek(1)[0];){var r=I(t);e[r[0]]=r[1]}return t.read(1),e}})).id=14,(e.Array=new n({serialize:function(t,e){for(var r=0,n=e.length;r<n;r++){var i=Object.keys(e[r]);if(1!==i.length)throw Error("Cannot serialize an array containing non-single-key objects");var s=i[0];k(t,s,e[r][s])}E.serialize(t,241)},parse:function(t){for(var e=[];241!==t.peek(1)[0];){var r=I(t),n={};n[r[0]]=r[1],e.push(n)}return t.read(1),e}})).id=15},function(t,e,r){var n=r(0),i=r(1),s=r(19).UInt,o=i(function(){this._value=NaN},s);o.width=16,o.prototype=i({},s.prototype);var a=(o.prototype.constructor=o).HEX_ZERO="00000000000000000000000000000000",c=o.HEX_ONE="00000000000000000000000000000000";o.STR_ZERO=n.hexToString(a),o.STR_ONE=n.hexToString(c),e.UInt128=o},function(t,e,r){var n=r(0).sjcl,i=r(9).Base,s=r(28).Seed,o=r(3).UInt160,a=r(15).UInt256,c=r(75),f=(r(36),r(1)),u=(r(34),{}),h={cipher:"aes",mode:"ccm",ts:64,ks:256,iter:1e3};function d(t,e){var r=e<<3;"string"==typeof t&&(t=n.codec.utf8String.toBits(t));for(var i=0,s=[];n.bitArray.bitLength(s)<r;){var o=n.hash.sha512.hash(n.bitArray.concat([i],t));s=n.bitArray.concat(s,o),i++}return n.bitArray.clamp(s,r)}function l(t){for(var e=0;e<8;e++)n.random.addEntropy(Math.random(),32,"Math.random()");return n.random.randomWords(t)}u.derive=function(t,e,r,i,s){var o;o="login"===e?["id","crypt"]:["unlock"];var a,f=new n.bn(String(t.exponent)),u=new n.bn(String(t.modulus)),h=new n.bn(String(t.alpha)),l=["PAKDF_1_0_0",t.host.length,t.host,r.length,r,e.length,e].join(":")+":",p=d(l,Math.ceil(Math.min(7+u.bitLength()>>>3,256)/8)),b=n.codec.hex.fromBits(p),_=new n.bn(String(b)).setBitM(0),y=d([l,i.length,i].join(":")+":",7+u.bitLength()>>>3),v=n.codec.hex.fromBits(y),m=new n.bn(String(v)).mod(u);for(1!==m.jacobi(u)&&(m=m.mul(h).mod(u));1!==(a=n.bn.random(u,0)).jacobi(u););var g=a.powermodMontgomery(_.mul(f),u),w=m.mulmod(g,u),A=n.codec.hex.fromBits(w.toBits());c.post(t.url).send({info:l,signreq:A}).end(function(e,r){if(e||!r)return s(new Error("Could not query PAKDF server "+t.host));var i=r.body||r.text?JSON.parse(r.text):{};if("success"!==i.result)return s(new Error("Could not query PAKDF server "+t.host));var c=new n.bn(String(i.signres)),f=a.inverseMod(u),h=c.mulmod(f,u).toBits(),d={};o.forEach(function(t){d[t]=function(t,e){var r=new n.misc.hmac(t,n.hash.sha512);return n.codec.hex.fromBits(n.bitArray.bitSlice(r.encrypt(e),0,256))}(h,t)}),s(null,d)})},u.encrypt=function(t,e){t=n.codec.hex.toBits(t);var r=f(!0,{},h),i=JSON.parse(n.encrypt(t,e,r)),s=[n.bitArray.partial(8,0)],o=n.codec.base64.toBits(i.iv),a=n.codec.base64.toBits(i.ct),c=n.bitArray.concat(s,o);return c=n.bitArray.concat(c,a),n.codec.base64.fromBits(c)},u.decrypt=function(t,e){t=n.codec.hex.toBits(t);var r=n.codec.base64.toBits(e),i=n.bitArray.extract(r,0,8);if(0!==i)throw new Error("Unsupported encryption version: "+i);var s=f(!0,{},h,{iv:n.codec.base64.fromBits(n.bitArray.bitSlice(r,8,136)),ct:n.codec.base64.fromBits(n.bitArray.bitSlice(r,136))});return n.decrypt(t,JSON.stringify(s))},u.isValidAddress=function(t){return o.is_valid(t)},u.createSecret=function(t){return n.codec.hex.fromBits(l(t))},u.createMaster=function(){return i.encode_check(33,n.codec.bytes.fromBits(l(4)))},u.getAddress=function(t){return s.from_json(t).get_key().get_address().to_json()},u.hashSha512=function(t){return n.codec.hex.fromBits(n.hash.sha512.hash(t))},u.hashSha512Half=function(t){return a.from_hex(u.hashSha512(t).substr(0,64))},u.signString=function(t,e){var r=new n.misc.hmac(n.codec.hex.toBits(t),n.hash.sha512);return n.codec.hex.fromBits(r.mac(e))},u.deriveRecoveryEncryptionKeyFromSecret=function(t){var e=s.from_json(t).to_bits(),r=new n.misc.hmac(e,n.hash.sha512).mac("stream/hmac/recovery_encryption_key/v1");return r=n.bitArray.bitSlice(r,0,256),n.codec.hex.fromBits(r)},u.base64ToBase64Url=function(t){return t.replace(/\+/g,"-").replace(/\//g,"_").replace(/[=]+$/,"")},u.base64UrlToBase64=function(t){for(t=t.replace(/-/g,"+").replace(/_/g,"/");t.length%4;)t+="=";return t},e.Crypt=u},function(t,e,r){var n=r(76),i=r(77),s="undefined"==typeof window?this:window;function o(){}var a="".trim?function(t){return t.trim()}:function(t){return t.replace(/(^\s*|\s*$)/g,"")};function c(t){return t===Object(t)}function f(t){if(!c(t))return t;var e=[];for(var r in t)null!=t[r]&&e.push(encodeURIComponent(r)+"="+encodeURIComponent(t[r]));return e.join("&")}function u(t){for(var e,r={},n=t.split("&"),i=0,s=n.length;i<s;++i)e=n[i].split("="),r[decodeURIComponent(e[0])]=decodeURIComponent(e[1]);return r}function h(t,e){this.req=t,this.xhr=this.req.xhr,this.text=this.xhr.responseText,this.setStatusProperties(this.xhr.status),this.header=this.headers=function(t){var e,r,n,i,s=t.split(/\r?\n/),o={};s.pop();for(var c=0,f=s.length;c<f;++c)e=(r=s[c]).indexOf(":"),n=r.slice(0,e).toLowerCase(),i=a(r.slice(e+1)),o[n]=i;return o}(this.xhr.getAllResponseHeaders()),this.header["content-type"]=this.xhr.getResponseHeader("content-type"),this.setHeaderProperties(this.header),this.body="HEAD"!=this.req.method?this.parseBody(this.text):null}function d(t,e){var r=this;n.call(this),this._query=this._query||[],this.method=t,this.url=e,this.header={},this._header={},this.on("end",function(){var e=new h(r);"HEAD"==t&&(e.text=null),r.callback(null,e)})}function l(t,e){return"function"==typeof e?new d("GET",t).end(e):1==arguments.length?new d("GET",t):new d(t,e)}l.serializeObject=f,l.parseString=u,l.types={html:"text/html",json:"application/json",xml:"application/xml",urlencoded:"application/x-www-form-urlencoded",form:"application/x-www-form-urlencoded","form-data":"application/x-www-form-urlencoded"},l.serialize={"application/x-www-form-urlencoded":f,"application/json":JSON.stringify},l.parse={"application/x-www-form-urlencoded":u,"application/json":JSON.parse},h.prototype.get=function(t){return this.header[t.toLowerCase()]},h.prototype.setHeaderProperties=function(t){var e=this.header["content-type"]||"";this.type=e.split(/ *; */).shift();var r=i(e.split(/ *; */),function(t,e){var r=e.split(/ *= */),n=r.shift(),i=r.shift();return n&&i&&(t[n]=i),t},{});for(var n in r)this[n]=r[n]},h.prototype.parseBody=function(t){var e=l.parse[this.type];return e?e(t):null},h.prototype.setStatusProperties=function(t){var e=t/100|0;this.status=t,this.statusType=e,this.info=1==e,this.ok=2==e,this.clientError=4==e,this.serverError=5==e,this.error=(4==e||5==e)&&this.toError(),this.accepted=202==t,this.noContent=204==t||1223==t,this.badRequest=400==t,this.unauthorized=401==t,this.notAcceptable=406==t,this.notFound=404==t,this.forbidden=403==t},h.prototype.toError=function(){var t=this.req,e=t.method,r=t.url,n="cannot "+e+" "+r+" ("+this.status+")",i=new Error(n);return i.status=this.status,i.method=e,i.url=r,i},l.Response=h,n(d.prototype),d.prototype.use=function(t){return t(this),this},d.prototype.timeout=function(t){return this._timeout=t,this},d.prototype.clearTimeout=function(){return this._timeout=0,clearTimeout(this._timer),this},d.prototype.abort=function(){if(!this.aborted)return this.aborted=!0,this.xhr.abort(),this.clearTimeout(),this.emit("abort"),this},d.prototype.set=function(t,e){if(c(t)){for(var r in t)this.set(r,t[r]);return this}return this._header[t.toLowerCase()]=e,this.header[t]=e,this},d.prototype.getHeader=function(t){return this._header[t.toLowerCase()]},d.prototype.type=function(t){return this.set("Content-Type",l.types[t]||t),this},d.prototype.accept=function(t){return this.set("Accept",l.types[t]||t),this},d.prototype.auth=function(t,e){var r=btoa(t+":"+e);return this.set("Authorization","Basic "+r),this},d.prototype.query=function(t){return"string"!=typeof t&&(t=f(t)),t&&this._query.push(t),this},d.prototype.field=function(t,e){return this._formData||(this._formData=new FormData),this._formData.append(t,e),this},d.prototype.attach=function(t,e,r){return this._formData||(this._formData=new FormData),this._formData.append(t,e,r),this},d.prototype.send=function(t){var e=c(t),r=this.getHeader("Content-Type");if(e&&c(this._data))for(var n in t)this._data[n]=t[n];else"string"==typeof t?(r||this.type("form"),r=this.getHeader("Content-Type"),this._data="application/x-www-form-urlencoded"==r?this._data?this._data+"&"+t:t:(this._data||"")+t):this._data=t;return e&&(r||this.type("json")),this},d.prototype.callback=function(t,e){var r=this._callback;return 2==r.length?r(t,e):t?this.emit("error",t):void r(e)},d.prototype.crossDomainError=function(){var t=new Error("Origin is not allowed by Access-Control-Allow-Origin");t.crossDomain=!0,this.callback(t)},d.prototype.timeoutError=function(){var t=this._timeout,e=new Error("timeout of "+t+"ms exceeded");e.timeout=t,this.callback(e)},d.prototype.withCredentials=function(){return this._withCredentials=!0,this},d.prototype.end=function(t){var e=this,r=this.xhr=function(){if(s.XMLHttpRequest&&("file:"!=s.location.protocol||!s.ActiveXObject))return new XMLHttpRequest;try{return new ActiveXObject("Microsoft.XMLHTTP")}catch(t){}try{return new ActiveXObject("Msxml2.XMLHTTP.6.0")}catch(t){}try{return new ActiveXObject("Msxml2.XMLHTTP.3.0")}catch(t){}try{return new ActiveXObject("Msxml2.XMLHTTP")}catch(t){}return!1}(),n=this._query.join("&"),i=this._timeout,a=this._formData||this._data;if(this._callback=t||o,r.onreadystatechange=function(){if(4==r.readyState)return 0==r.status?e.aborted?e.timeoutError():e.crossDomainError():void e.emit("end")},r.upload&&(r.upload.onprogress=function(t){t.percent=t.loaded/t.total*100,e.emit("progress",t)}),i&&!this._timer&&(this._timer=setTimeout(function(){e.abort()},i)),n&&(n=l.serializeObject(n),this.url+=~this.url.indexOf("?")?"&"+n:"?"+n),r.open(this.method,this.url,!0),this._withCredentials&&(r.withCredentials=!0),"GET"!=this.method&&"HEAD"!=this.method&&"string"!=typeof a&&!function(t){switch({}.toString.call(t)){case"[object File]":case"[object Blob]":case"[object FormData]":return!0;default:return!1}}(a)){var c=l.serialize[this.getHeader("Content-Type")];c&&(a=c(a))}for(var f in this.header)null!=this.header[f]&&r.setRequestHeader(f,this.header[f]);return this.emit("request",this),r.send(a),this},l.Request=d,l.get=function(t,e,r){var n=l("GET",t);return"function"==typeof e&&(r=e,e=null),e&&n.query(e),r&&n.end(r),n},l.head=function(t,e,r){var n=l("HEAD",t);return"function"==typeof e&&(r=e,e=null),e&&n.send(e),r&&n.end(r),n},l.del=function(t,e){var r=l("DELETE",t);return e&&r.end(e),r},l.patch=function(t,e,r){var n=l("PATCH",t);return"function"==typeof e&&(r=e,e=null),e&&n.send(e),r&&n.end(r),n},l.post=function(t,e,r){var n=l("POST",t);return"function"==typeof e&&(r=e,e=null),e&&n.send(e),r&&n.end(r),n},l.put=function(t,e,r){var n=l("PUT",t);return"function"==typeof e&&(r=e,e=null),e&&n.send(e),r&&n.end(r),n},t.exports=l},function(t,e){function r(t){if(t)return function(t){for(var e in r.prototype)t[e]=r.prototype[e];return t}(t)}(t.exports=r).prototype.on=r.prototype.addEventListener=function(t,e){return this._callbacks=this._callbacks||{},(this._callbacks[t]=this._callbacks[t]||[]).push(e),this},r.prototype.once=function(t,e){var r=this;function n(){r.off(t,n),e.apply(this,arguments)}return this._callbacks=this._callbacks||{},n.fn=e,this.on(t,n),this},r.prototype.off=r.prototype.removeListener=r.prototype.removeAllListeners=r.prototype.removeEventListener=function(t,e){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var r,n=this._callbacks[t];if(!n)return this;if(1==arguments.length)return delete this._callbacks[t],this;for(var i=0;i<n.length;i++)if((r=n[i])===e||r.fn===e){n.splice(i,1);break}return this},r.prototype.emit=function(t){this._callbacks=this._callbacks||{};var e=[].slice.call(arguments,1),r=this._callbacks[t];if(r)for(var n=0,i=(r=r.slice(0)).length;n<i;++n)r[n].apply(this,e);return this},r.prototype.listeners=function(t){return this._callbacks=this._callbacks||{},this._callbacks[t]||[]},r.prototype.hasListeners=function(t){return!!this.listeners(t).length}},function(t,e){t.exports=function(t,e,r){for(var n=0,i=t.length,s=3==arguments.length?r:t[n++];n<i;)s=e.call(null,s,t[n],++n,t);return s}},function(t,e){e.HASH_TX_ID=1415073280,e.HASH_TX_NODE=1397638144,e.HASH_INNER_NODE=1296649728,e.HASH_LEAF_NODE=1296846336,e.HASH_TX_SIGN=1398036480,e.HASH_TX_SIGN_TESTNET=1937012736},function(t,e){var r=function(){return this}(),n=r.WebSocket||r.MozWebSocket;function i(t,e,r){return e?new n(t,e):new n(t)}t.exports=n?i:null,n&&(i.prototype=n.prototype)},function(t,e,r){(function(t){var n=void 0!==t&&t||"undefined"!=typeof self&&self||window,i=Function.prototype.apply;function s(t,e){this._id=t,this._clearFn=e}e.setTimeout=function(){return new s(i.call(setTimeout,n,arguments),clearTimeout)},e.setInterval=function(){return new s(i.call(setInterval,n,arguments),clearInterval)},e.clearTimeout=e.clearInterval=function(t){t&&t.close()},s.prototype.unref=s.prototype.ref=function(){},s.prototype.close=function(){this._clearFn.call(n,this._id)},e.enroll=function(t,e){clearTimeout(t._idleTimeoutId),t._idleTimeout=e},e.unenroll=function(t){clearTimeout(t._idleTimeoutId),t._idleTimeout=-1},e._unrefActive=e.active=function(t){clearTimeout(t._idleTimeoutId);var e=t._idleTimeout;0<=e&&(t._idleTimeoutId=setTimeout(function(){t._onTimeout&&t._onTimeout()},e))},r(81),e.setImmediate="undefined"!=typeof self&&self.setImmediate||void 0!==t&&t.setImmediate||this&&this.setImmediate,e.clearImmediate="undefined"!=typeof self&&self.clearImmediate||void 0!==t&&t.clearImmediate||this&&this.clearImmediate}).call(this,r(14))},function(t,e,r){(function(t,e){!function(t,r){"use strict";if(!t.setImmediate){var n,i,s,o,a=1,c={},f=!1,u=t.document,h=Object.getPrototypeOf&&Object.getPrototypeOf(t);h=h&&h.setTimeout?h:t,n="[object process]"==={}.toString.call(t.process)?function(t){e.nextTick(function(){l(t)})}:function(){if(t.postMessage&&!t.importScripts){var e=!0,r=t.onmessage;return t.onmessage=function(){e=!1},t.postMessage("","*"),t.onmessage=r,e}}()?(o="setImmediate$"+Math.random()+"$",t.addEventListener?t.addEventListener("message",p,!1):t.attachEvent("onmessage",p),function(e){t.postMessage(o+e,"*")}):t.MessageChannel?((s=new MessageChannel).port1.onmessage=function(t){l(t.data)},function(t){s.port2.postMessage(t)}):u&&"onreadystatechange"in u.createElement("script")?(i=u.documentElement,function(t){var e=u.createElement("script");e.onreadystatechange=function(){l(t),e.onreadystatechange=null,i.removeChild(e),e=null},i.appendChild(e)}):function(t){setTimeout(l,0,t)},h.setImmediate=function(t){"function"!=typeof t&&(t=new Function(""+t));for(var e=new Array(arguments.length-1),r=0;r<e.length;r++)e[r]=arguments[r+1];var i={callback:t,args:e};return c[a]=i,n(a),a++},h.clearImmediate=d}function d(t){delete c[t]}function l(t){if(f)setTimeout(l,0,t);else{var e=c[t];if(e){f=!0;try{!function(t){var e=t.callback,n=t.args;switch(n.length){case 0:e();break;case 1:e(n[0]);break;case 2:e(n[0],n[1]);break;case 3:e(n[0],n[1],n[2]);break;default:e.apply(r,n)}}(e)}finally{d(t),f=!1}}}}function p(e){e.source===t&&"string"==typeof e.data&&0===e.data.indexOf(o)&&l(+e.data.slice(o.length))}}("undefined"==typeof self?void 0===t?this:t:self)}).call(this,r(14),r(27))},function(t,e,r){var n=r(5),i=r(8).EventEmitter,s=r(16).Transaction,o=r(22).StreamError,a=r(83).TransactionQueue,c=r(23).internal.sub("transactionmanager");function f(t){i.call(this);var e=this;function r(t){var r=f.normalizeTransaction(t),n=r.tx_json.Sequence,i=r.tx_json.hash;if(r.validated){e._pending.addReceivedSequence(n);var o=e._pending.getSubmission(i);e._remote.trace&&c.info("transaction received:",r.tx_json),o instanceof s?o.emit("success",r):e._pending.addReceivedId(i,r)}}function n(t){e._pending.forEach(function(e){switch(t.ledger_index-e.submitIndex){case 8:e.emit("lost",t);break;case 4:e.emit("missing",t)}})}function o(t){if(t="function"==typeof t?t:function(){},!e._pending.length)return t();var i={account:e._accountID,ledger_index_min:-1,ledger_index_max:-1,binary:!0,parseBinary:!0,limit:100,filter:"outbound"};e._remote.requestAccountTx(i,function(i,s){!i&&Array.isArray(s.transactions)&&s.transactions.forEach(r),e._remote.on("ledger_closed",n),e._loadSequence(e._resubmit.bind(e)),t()}),e.emit("reconnect")}this._account=t,this._accountID=t._account_id,this._remote=t._remote,this._nextSequence=void 0,this._maxFee=this._remote.max_fee,this._submissionTimeout=this._remote._submission_timeout,this._pending=new a,this._loadSequence(),this._account.on("transaction-outbound",r),this._remote.on("load_changed",this._adjustFees.bind(this)),this._remote.on("ledger_closed",n),this._remote.on("disconnect",function(){e._remote.once("connect",o),e._remote.removeListener("ledger_closed",n)}),this._remote.storage&&this.on("save",function(t){e._remote.storage.saveTransaction(t.summary())})}n.inherits(f,i),f.normalizeTransaction=function(t){var e={};return Object.keys(t).forEach(function(r){e[r]=t[r]}),t.engine_result||((e={engine_result:t.meta.TransactionResult,tx_json:t.tx,hash:t.tx.hash,ledger_index:t.tx.ledger_index,meta:t.meta,type:"transaction",validated:!0}).result=e.engine_result,e.result_message=e.engine_result_message),e.metadata||(e.metadata=e.meta),e.tx_json||(e.tx_json=e.transaction),delete e.transaction,delete e.mmeta,delete e.meta,e},f.prototype._adjustFees=function(t){var e=this;this._remote.local_fee&&this._pending.forEach(function(t){var r=t.tx_json.Fee,n=t._computeFee();Number(n)>e._maxFee?t.once("presubmit",function(){t.emit("error","tejMaxFeeExceeded")}):(t.tx_json.Fee=n,t.emit("fee_adjusted",r,n),e._remote.trace&&c.info("fee adjusted:",t.tx_json,r,n))})},f.prototype._fillSequence=function(t,e){var r=this;this._loadSequence(function(n,i){if("number"!=typeof i)return e(new Error("Failed to fetch account transaction sequence"));var s=t.tx_json.Sequence-i,o=0;!function n(i){i>=t.tx_json.Sequence||function(e,n){var i=r._remote.transaction();i.account_set(r._accountID),i.tx_json.Sequence=e,i.once("submitted",n),t._secret&&i.secret(t._secret),i.submit()}(i,function(){++o==s?e():n(i+1)})}(i)})},f.prototype._loadSequence=function(t){var e=this;this._account.getNextSequence(function(r,n){"number"==typeof n?(e._nextSequence=n,e.emit("sequence_loaded",n),"function"==typeof t&&t(r,n)):setTimeout(function(){e._loadSequence(t)},3e3)})},f.prototype._resubmit=function(t,e){var r=this;e=e?[e]:this._pending,t=Number(t)||0,this._waitLedgers(t,function(){!function t(n){var i=e[n];i instanceof s&&(i.once("submitted",function(s){i.emit("resubmitted",s),r._loadSequence(),++n<e.length&&t(n)}),function(t){if(t&&!t.finalized){var e=t.findId(r._pending._idCache);if(r._remote.trace&&c.info("resubmit:",t.tx_json),e)return t.emit("success",e);for(;r._pending.hasSequence(t.tx_json.Sequence);)t.tx_json.Sequence+=1,r._remote.trace&&c.info("incrementing sequence:",t.tx_json);r._request(t)}}(i))}(0)})},f.prototype._waitLedgers=function(t,e){if(t<1)return e();var r=this,n=0;this._remote.on("ledger_closed",function i(){++n<t||(r._remote.removeListener("ledger_closed",i),e())})},f.prototype._request=function(t){var e=this,r=this._remote;if(10<t.attempts)return t.emit("error",new o("tejAttemptsExceeded"));if(0<t.attempts&&!r.local_signing)return t.emit("error",new o("tejLocalSigningRequired","It is not possible to resubmit transactions automatically safely without synthesizing the transactionID locally. See `local_signing` config option"));if(t.emit("presubmit"),!t.finalized){r.trace&&c.info("submit transaction:",t.tx_json);var n=r.requestSubmit();return n.once("error",s),n.once("success",s),t.submitIndex=this._remote._ledger_current_index,0===t.attempts&&(t.initialSubmitIndex=t.submitIndex),t._setLastLedger||(t.tx_json.LastLedgerSequence=t.submitIndex+8),t.lastLedgerSequence=t.tx_json.LastLedgerSequence,r.local_signing?t.sign(a):a(),n}function i(r){t.finalized||(f._isTooBusy(r)?e._resubmit(1,t):(e._nextSequence--,t.emit("error",r)))}function s(o){if(!t.finalized)switch(o.tx_json&&o.tx_json.hash&&t.addId(o.tx_json.hash),o.result=o.engine_result||"",t.result=o,t.responses+=1,r.trace&&c.info("submit response:",o),t.emit("submitted",o),o.result.slice(0,3)){case"tes":!function(e){t.finalized||(e.rejected=t.isRejected(e.engine_result_code),t.emit("proposed",e))}(o);break;case"tec":!function(e){t.finalized||t.emit("error",e)}(o);break;case"ter":t.finalized||e._fillSequence(t,function(){e._resubmit(1,t)});break;case"tef":!function(r){if(!t.finalized)switch(r.engine_result){case"tefPAST_SEQ":e._resubmit(1,t);break;case"tefALREADY":t.responses===t.submissions?t.emit("error",r):n.once("success",s);break;default:t.emit("error",r)}}(o);break;case"tel":!function(r){t.finalized||(e._remote.local_fee&&"telINSUF_FEE_P"===r.engine_result?e._resubmit(2,t):i(r))}(o);break;default:i(o)}}function a(){r.local_signing?(n.tx_blob(t.serialize().to_hex()),t.addId(t.hash())):(n.build_path(t._build_path),n.secret(t._secret),n.tx_json(t.tx_json)),t._server&&(n.server=t._server),t.finalized||(n.timeout(e._submissionTimeout,u),t.submissions=n.broadcast(),t.attempts++,t.emit("postsubmit"))}function u(){t.finalized||(t.emit("timeout"),r._connected&&(r.trace&&c.info("timeout:",t.tx_json),e._resubmit(3,t)))}},f._isNoOp=function(t){return"object"==typeof t&&"object"==typeof t.tx_json&&"AccountSet"===t.tx_json.TransactionType&&0===t.tx_json.Flags},f._isRemoteError=function(t){return"object"==typeof t&&"remoteError"===t.error&&"object"==typeof t.remote},f._isNotFound=function(t){return f._isRemoteError(t)&&/^(txnNotFound|transactionNotFound)$/.test(t.remote.error)},f._isTooBusy=function(t){return f._isRemoteError(t)&&"tooBusy"===t.remote.error},f.prototype.submit=function(t){var e=this,r=this._remote;"number"==typeof this._nextSequence?t.finalized||(t.once("cleanup",function(n){e._pending.remove(t),t.emit("final",n),r.trace&&c.info("transaction finalized:",t.tx_json,e._pending.getLength())}),t.on("save",function(){e.emit("save",t)}),t.once("error",function(e){t._errorHandler(e)}),t.once("success",function(e){t._successHandler(e)}),t.once("abort",function(){t.emit("error",new o("tejAbort","Transaction aborted"))}),"number"!=typeof t.tx_json.Sequence&&(t.tx_json.Sequence=this._nextSequence++),t.complete()?(t.attempts=0,t.submissions=0,t.responses=0,this._pending.push(t),this._request(t)):this._nextSequence--):this.once("sequence_loaded",this.submit.bind(this,t))},e.TransactionManager=f},function(t,e,r){var n=r(33),i=r(16).Transaction;function s(){this._queue=[],this._idCache=n(),this._sequenceCache=n()}s.prototype.addReceivedSequence=function(t){this._sequenceCache.set(String(t),!0)},s.prototype.hasSequence=function(t){return this._sequenceCache.has(String(t))},s.prototype.addReceivedId=function(t,e){this._idCache.set(t,e)},s.prototype.getReceived=function(t){return this._idCache.get(t)},s.prototype.getSubmission=function(t){for(var e,r=void 0,n=0;e=this._queue[n];n++)if(~e.submittedIDs.indexOf(t)){r=e;break}return r},s.prototype.remove=function(t){var e=this._queue.length;if("string"==typeof t&&(t=this.getSubmission(t)),t instanceof i)for(;e--;)if(this._queue[e]===t){this._queue.splice(e,1);break}},s.prototype.push=function(t){this._queue.push(t)},s.prototype.forEach=function(t){this._queue.forEach(t)},s.prototype.length=s.prototype.getLength=function(){return this._queue.length},e.TransactionQueue=s},function(t,e,r){var n=r(1),i=r(0),s=r(3).UInt160,o=r(6).Amount;function a(t){if(this.nodes=[],"object"!=typeof t)throw new TypeError("Missing metadata");if(!Array.isArray(t.AffectedNodes))throw new TypeError("Metadata missing AffectedNodes");t.AffectedNodes.forEach(this.addNode,this)}a.nodeTypes=["CreatedNode","ModifiedNode","DeletedNode"],a.amountFieldsAffectingIssuer=["LowLimit","HighLimit","TakerPays","TakerGets"],a.prototype.getNodeType=function(t){for(var e=null,r=0;r<a.nodeTypes.length;r++){var n=a.nodeTypes[r];if(t.hasOwnProperty(n)){e=n;break}}return e},a.prototype.addNode=function(t){this._affectedAccounts=void 0,this._affectedBooks=void 0;var e={};(e.nodeType=this.getNodeType(t))&&(t=t[e.nodeType],e.diffType=e.nodeType,e.entryType=t.LedgerEntryType,e.ledgerIndex=t.LedgerIndex,e.fields=n({},t.PreviousFields,t.NewFields,t.FinalFields),e.fieldsPrev=t.PreviousFields||{},e.fieldsNew=t.NewFields||{},e.fieldsFinal=t.FinalFields||{},this.nodes.push(e))},a.prototype.getNodes=function(t){return"object"==typeof t?this.nodes.filter(function(e){return!(t.nodeType&&t.nodeType!==e.nodeType||t.entryType&&t.entryType!==e.entryType||t.bookKey&&t.bookKey!==e.bookKey)}):this.nodes},["forEach","map","filter","every","some","reduce"].forEach(function(t){a.prototype[t]=function(){return Array.prototype[t].apply(this.nodes,arguments)}}),a.prototype.each=a.prototype.forEach,a.prototype.getAffectedAccounts=function(t){if(this._affectedAccounts)return this._affectedAccounts;for(var e=[],r=0;r<this.nodes.length;r++){var n=this.nodes[r],c="CreatedNode"===n.nodeType?n.fieldsNew:n.fieldsFinal;for(var f in c){var u=c[f];if("string"==typeof u&&s.is_valid(u))e.push(u);else if(~a.amountFieldsAffectingIssuer.indexOf(f)){var h=o.from_json(u).issuer();h.is_valid()&&!h.is_zero()&&e.push(h.to_json())}}}return this._affectedAccounts=i.arrayUnique(e),this._affectedAccounts},a.prototype.getAffectedBooks=function(){if(this._affectedBooks)return this._affectedBooks;for(var t=[],e=0;e<this.nodes.length;e++){var r=this.nodes[e];if("Offer"===r.entryType){var n=o.from_json(r.fields.TakerGets),s=o.from_json(r.fields.TakerPays),a=n.currency().to_json(),c=s.currency().to_json();"STM"!==a&&(a+="/"+n.issuer().to_json()),"STM"!==c&&(c+="/"+s.issuer().to_json());var f=a+":"+c;r.bookKey=f,t.push(f)}}return this._affectedBooks=i.arrayUnique(t),this._affectedBooks},e.Meta=a},function(t,e,r){var n=r(5),i=r(1),s=r(13),o=r(41),a=r(8).EventEmitter,c=r(6).Amount,f=r(3).UInt160,u=r(21).Currency,h=r(23).internal.sub("orderbook");function d(t,e,r,n,i,s){a.call(this);var o=this;function c(t,e){if(~d.EVENTS.indexOf(e))switch(t){case"add":1==++o._listeners&&o.subscribe();break;case"remove":0==--o._listeners&&o.unsubscribe()}}function f(t){o.updateFundedAmounts(t)}function h(t){o.updateTransferRate(t)}return this._remote=t,this._currencyGets=u.from_json(e),this._issuerGets=r,this._currencyPays=u.from_json(n),this._issuerPays=i,this._key=s,this._subscribed=!1,this._shouldSubscribe=!0,this._listeners=0,this._offers=[],this._ownerFunds={},this._offerCounts={},this._ownerOffersTotal={},this._ownerFundsUnadjusted={},this._synchronized=!1,this.on("newListener",function(t){c("add",t)}),this.on("removeListener",function(t){c("remove",t)}),this.on("unsubscribe",function(){o.resetCache(),o._remote.removeListener("transaction",f),o._remote.removeListener("transaction",h)}),this._remote.once("prepare_subscribe",function(){o.subscribe()}),this._remote.on("disconnect",function(){o.resetCache(),o._remote.once("prepare_subscribe",function(){o.subscribe()})}),this._remote.on("transaction",f),this._remote.on("transaction",h),this}n.inherits(d,a),d.EVENTS=["transaction","model","trade","offer"],d.DEFAULT_TRANSFER_RATE=1e9,d.IOU_SUFFIX="/000/vvvvvvvvvvvvvvvvvvvvBZbvji",d.prototype.isValid=d.prototype.is_valid=function(){return this._currencyPays&&this._currencyPays.is_valid()&&(this._currencyPays.is_native()||f.is_valid(this._issuerPays))&&this._currencyGets&&this._currencyGets.is_valid()&&(this._currencyGets.is_native()||f.is_valid(this._issuerGets))&&!(this._currencyPays.is_native()&&this._currencyGets.is_native())},d.prototype.subscribe=function(){var t=this;if(this._shouldSubscribe){this._remote.trace&&h.info("subscribing",this._key);var e=[function(e){t.requestTransferRate(e)},function(e){t.requestOffers(e)},function(e){t.subscribeTransactions(e)}];o.series(e,function(t){})}},d.prototype.unsubscribe=function(){var t=this;this._remote.trace&&h.info("unsubscribing",this._key),this._subscribed=!1,this._shouldSubscribe=!1,d.EVENTS.forEach(function(e){0<t.listeners(e).length&&t.removeAllListeners(e)}),this.emit("unsubscribe")},d.prototype.resetCache=function(){this._ownerFunds={},this._offerCounts={},this._ownerOffersTotal={},this._synchronized=!1},d.prototype.hasCachedFunds=function(t){return s(f.is_valid(t),"Account is invalid"),void 0!==this._ownerFunds[t]},d.prototype.addCachedFunds=function(t,e){s(f.is_valid(t),"Account is invalid"),s(!isNaN(e),"Funded amount is invalid"),this._ownerFundsUnadjusted[t]=e,this._ownerFunds[t]=this.applyTransferRate(e)},d.prototype.getUnadjustedOwnerFunds=function(t){return s(f.is_valid(t),"Account is invalid"),this._ownerFundsUnadjusted[t]},d.prototype.getCachedFunds=function(t){return s(f.is_valid(t),"Account is invalid"),this._ownerFunds[t]},d.prototype.removeCachedFunds=function(t){s(f.is_valid(t),"Account is invalid"),this._ownerFunds[t]=void 0},d.prototype.getOfferCount=function(t){return s(f.is_valid(t),"Account is invalid"),this._offerCounts[t]||0},d.prototype.incrementOfferCount=function(t){s(f.is_valid(t),"Account is invalid");var e=(this._offerCounts[t]||0)+1;return this._offerCounts[t]=e},d.prototype.decrementOfferCount=function(t){s(f.is_valid(t),"Account is invalid");var e=(this._offerCounts[t]||1)-1;return this._offerCounts[t]=e},d.prototype.applyTransferRate=function(t,e){return s(!isNaN(t),"Balance is invalid"),this._currencyGets.is_native()?t:(void 0===e&&(e=this._issuerTransferRate),s(!isNaN(e),"Transfer rate is invalid"),e===d.DEFAULT_TRANSFER_RATE?t:c.from_json(t+"/USD/vvvvvvvvvvvvvvvvvvvvBZbvji").divide(e).multiply(c.from_json(d.DEFAULT_TRANSFER_RATE)).to_json().value)},d.prototype.requestTransferRate=function(t){var e=this,r=this._issuerGets;return this.once("transfer_rate",function(e){"function"==typeof t&&t(null,e)}),this._currencyGets.is_native()?this.emit("transfer_rate",d.DEFAULT_TRANSFER_RATE):this._issuerTransferRate?this.emit("transfer_rate",this._issuerTransferRate):void this._remote.requestAccountInfo(r,function(r,n){if(r)return t(r);var i=n.account_data.TransferRate||d.DEFAULT_TRANSFER_RATE;e._issuerTransferRate=i,e.emit("transfer_rate",i)})},d.prototype.setFundedAmount=function(t){s.strictEqual(typeof t,"object","Offer is invalid"),s(!isNaN(this.getCachedFunds(t.Account)),"Funds is invalid");var e=c.from_json(this._currencyGets.is_native()?this.getCachedFunds(t.Account):this.getCachedFunds(t.Account)+d.IOU_SUFFIX),r=this.getOwnerOfferTotal(t.Account),n=c.from_json(t.TakerGets).add(r);if(t.owner_funds=this.getUnadjustedOwnerFunds(t.Account),t.is_fully_funded=0<=e.compareTo(n),t.is_fully_funded)return t.taker_gets_funded=c.from_json(t.TakerGets).to_text(),t.taker_pays_funded=c.from_json(t.TakerPays).to_text(),t;if(r.compareTo(e)<0){var i=e.subtract(r),o=this._currencyPays.is_native()?t.TakerPays:t.TakerPays.value,a=c.from_json(o+d.IOU_SUFFIX),f=this._currencyGets.is_native()?t.TakerGets:t.TakerGets.value,u=c.from_json(f+d.IOU_SUFFIX),h=a.divide(u),l=c.from_json(i.to_text()+d.IOU_SUFFIX).multiply(h);t.taker_gets_funded=i.to_text(),t.taker_pays_funded=this._currencyPays.is_native()?String(parseInt(l.to_json().value,10)):l.to_json().value}else t.taker_gets_funded="0",t.taker_pays_funded="0";return t},d.prototype.addOwnerOfferTotal=function(t,e){s(f.is_valid(t),"Account is invalid");var r=this.getOwnerOfferTotal(t).add(c.from_json(e));return this._ownerOffersTotal[t]=r},d.prototype.subtractOwnerOfferTotal=function(t,e){s(f.is_valid(t),"Account is invalid");var r=this.getOwnerOfferTotal(t).subtract(c.from_json(e));return this._ownerOffersTotal[t]=r,s(!r.is_negative(),"Offer total cannot be negative"),r},d.prototype.getOwnerOfferTotal=function(t){s(f.is_valid(t),"Account is invalid");var e=this._ownerOffersTotal[t];return e||(this._currencyGets.is_native()?c.from_json("0"):c.from_json("0"+d.IOU_SUFFIX))},d.prototype.resetOwnerOfferTotal=function(t){var e;return e=this._currencyGets.is_native()?c.from_json("0"):c.from_json("0"+d.IOU_SUFFIX),this._ownerOffersTotal[t]=e},d.prototype.requestFundedAmount=function(t,e){s(f.is_valid(t),"Account is invalid"),s.strictEqual(typeof e,"function","Callback is invalid");var r=this;r._remote.trace&&h.info("requesting funds",t);var n=[];this._currencyGets.is_native()?n.push(function(e){r._remote.requestAccountInfo(t,function(t,r){t?e(t):e(null,String(r.account_data.Balance))})}):(n.push(this.requestTransferRate.bind(this)),n.push(function(e){r._remote.requestAccountLines(t,void 0,"VALIDATED",r._issuerGets).request(function(t,n){if(t)return e(t);for(var i,s=r._currencyGets.to_json(),o="0",a=0;i=n.lines[a];a++)if(i.currency===s){o=i.balance;break}e(null,o)})})),o.parallel(n,function(n,i){if(n)return r._remote.trace&&h.info("failed to request funds",n),e(n);var s,o;r._remote.trace&&h.info("requested funds",t,i),o=r._currencyGets.is_native()?s=i[0]:(s=i[1],r.applyTransferRate(s,i[0])),e(null,o)})},d.prototype.getBalanceChange=function(t){var e={account:void 0,balance:void 0};switch(t.entryType){case"AccountRoot":e.account=t.fields.Account,e.balance=t.fieldsFinal.Balance;break;case"VStreamState":t.fields.HighLimit.issuer===this._issuerGets?(e.account=t.fields.LowLimit.issuer,e.balance=t.fieldsFinal.Balance.value):t.fields.LowLimit.issuer===this._issuerGets&&(e.account=t.fields.HighLimit.issuer,e.balance=c.from_json(t.fieldsFinal.Balance).negate().to_json().value)}return e.isValid=!isNaN(e.balance)&&f.is_valid(e.account),e},d.prototype.isBalanceChange=function(t){return!(!(t.fields&&t.fields.Balance&&t.fieldsPrev&&t.fieldsFinal&&t.fieldsPrev.Balance&&t.fieldsFinal.Balance)||(this._currencyGets.is_native()?isNaN(t.fields.Balance):t.fields.Balance.currency!==this._currencyGets.to_json()||t.fields.HighLimit.issuer!==this._issuerGets&&t.fields.LowLimit.issuer!==this._issuerGets))},d.prototype.updateFundedAmounts=function(t){var e=this;if(t.mmeta.getAffectedAccounts().some(function(t){return e.hasCachedFunds(t)})){if(!this._currencyGets.is_native()&&!this._issuerTransferRate)return e._remote.trace&&h.info("waiting for transfer rate"),this.once("transfer_rate",function(){e.updateFundedAmounts(t)}),void this.requestTransferRate();for(var r=t.mmeta.getNodes({nodeType:"ModifiedNode",entryType:this._currencyGets.is_native()?"AccountRoot":"VStreamState"}),n=0;n<r.length;n++){var i=r[n];if(this.isBalanceChange(i)){var s=this.getBalanceChange(i);s.isValid&&this.hasCachedFunds(s.account)&&(this.addCachedFunds(s.account,s.balance),this.updateOfferFunds(s.account))}}}},d.prototype.updateTransferRate=function(t){var e=this;t.mmeta.getAffectedAccounts().some(function(t){return t===e._issuerGets})},d.prototype.setOffers=function(t){s(Array.isArray(t),""),this.resetCache();for(var e=0,r=t.length;e<r;e++){var n=t[e];n.hasOwnProperty("owner_funds")&&this.addCachedFunds(n.Account,n.owner_funds),this.setFundedAmount(n),this.incrementOfferCount(n.Account),this.addOwnerOfferTotal(n.Account,n.TakerGets),this._offers.push(n)}},d.prototype.requestOffers=function(t){var e=this;if("function"!=typeof t&&(t=function(){}),!this._shouldSubscribe)return t(new Error("Should not request offers"));this._remote.trace&&h.info("requesting offers",this._key);var r=this._remote.requestBookOffers(this.toJSON());return r.once("success",function(r){var n=r.offers;if(!Array.isArray(n))return t(new Error("Invalid response"));e._remote.trace&&h.info("requested offers",e._key,"offers: "+n.length),e._offers=[],e.setOffers(n),e._synchronized=!0,e.emit("model",e._offers),t(null,e._offers)}),r.once("error",function(r){e._remote.trace&&h.info("failed to request offers",e._key,r),t(r)}),r.request(),r},d.prototype.subscribeTransactions=function(t){var e=this;if("function"!=typeof t&&(t=function(){}),!this._shouldSubscribe)return t("Should not subscribe");this._remote.trace&&h.info("subscribing to transactions");var r=this._remote.requestSubscribe();return r.addStream("transactions"),r.once("success",function(r){e._remote.trace&&h.info("subscribed to transactions"),e._subscribed=!0,t(null,r)}),r.once("error",function(r){e._remote.trace&&h.info("failed to subscribe to transactions",e._key,r),t(r)}),r.request(),r},d.prototype.offers=d.prototype.getOffers=function(t){return s.strictEqual(typeof t,"function","Callback missing"),this._synchronized?t(null,this._offers):this.once("model",function(e){t(null,e)}),this},d.prototype.offersSync=d.prototype.getOffersSync=function(){return this._offers},d.prototype.insertOffer=function(t){this._remote.trace&&h.info("inserting offer",this._key,t.fields);var e=t.fields;e.index=t.ledgerIndex;for(var r={reference_date:new Date},n=c.from_json(e.TakerPays).ratio_human(t.fields.TakerGets,r),i=0,s=this._offers.length;i<s;i++){var o=this._offers[i],a=c.from_json(o.TakerPays).ratio_human(o.TakerGets,r);if(n.compareTo(a)<=0){this._offers.splice(i,0,e);break}i===s-1&&this._offers.push(e)}this._offers.length||this._offers.push(e),this.updateOfferFunds(e.Account),this.emit("offer_added",e)},d.prototype.modifyOffer=function(t,e,r){this._remote.trace&&(e?h.info("deleting offer",this._key,t.fields):h.info("modifying offer",this._key,t.fields));for(var n=0;n<this._offers.length;n++){var s=this._offers[n];if(s.index===t.ledgerIndex){if(e)this.subtractOwnerOfferTotal(s.Account,s.TakerGets),this._offers.splice(n,1),this.emit("offer_removed",s);else{var o=i({},s);i(s,t.fieldsFinal),this.updateOfferFunds(s.Account),this.emit("offer_changed",o,s)}break}}},d.prototype.updateOfferFunds=function(t){s(f.is_valid(t),"Account is invalid"),this._remote.trace&&h.info("updating offer funds",this._key,t),this.resetOwnerOfferTotal(t);for(var e=0;e<this._offers.length;e++){var r=this._offers[e];if(r.Account===t){var n="/USD/vvvvvvvvvvvvvvvvvvvvBZbvji",o=i({},r),a=c.from_json(r.taker_gets_funded+n);this.setFundedAmount(r),this.addOwnerOfferTotal(r.Account,r.TakerGets),a.equals(c.from_json(r.taker_gets_funded+n))||(this.emit("offer_changed",o,r),this.emit("offer_funds_changed",r,o.taker_gets_funded,r.taker_gets_funded))}}},d.prototype.notify=function(t){var e=this;if(this._subscribed){var r=t.mmeta.getNodes({entryType:"Offer",bookKey:this._key});if(!(r.length<1)){this._remote.trace&&h.info("notifying",this._key,t.transaction.hash);var n=c.from_json("0"+(u.from_json(this._currencyGets).is_native()?"":"/"+this._currencyGets+"/"+this._issuerGets)),i=c.from_json("0"+(u.from_json(this._currencyPays).is_native()?"":"/"+this._currencyPays+"/"+this._issuerPays));o.eachSeries(r,function(r,s){var o="DeletedNode"===r.nodeType,a="OfferCancel"===t.transaction.TransactionType;switch(r.nodeType){case"DeletedNode":case"ModifiedNode":var c=t.transaction.owner_funds;e.modifyOffer(r,o,c),a||(n=n.add(r.fieldsPrev.TakerGets),i=i.add(r.fieldsPrev.TakerPays),o?e.decrementOfferCount(r.fields.Account)<1&&e.removeCachedFunds(r.fields.Account):(n=n.subtract(r.fieldsFinal.TakerGets),i=i.subtract(r.fieldsFinal.TakerPays))),s();break;case"CreatedNode":if(e.incrementOfferCount(r.fields.Account),c=t.transaction.owner_funds,!isNaN(c))return e.addCachedFunds(r.fields.Account,c),e.insertOffer(r),s();e.requestFundedAmount(r.fields.Account,function(t,n){t||(e.addCachedFunds(r.fields.Account,n),e.insertOffer(r)),s()})}},function(){e.emit("transaction",t),e.emit("model",e._offers),n.is_zero()||e.emit("trade",i,n)})}}},d.prototype.toJSON=d.prototype.to_json=function(){var t={taker_gets:{currency:this._currencyGets.to_hex()},taker_pays:{currency:this._currencyPays.to_hex()}};return this._currencyGets.is_native()||(t.taker_gets.issuer=this._issuerGets),this._currencyPays.is_native()||(t.taker_pays.issuer=this._issuerPays),t},e.OrderBook=d},function(t,e,r){var n=r(8).EventEmitter,i=r(5),s=r(6).Amount;function o(t,e,r,i,s){n.call(this),this.remote=t,this.src_account=e,this.dst_account=r,this.dst_amount=i,this.src_currencies=s}r(1),i.inherits(o,n),o.prototype.create=function(){var t=this;this.remote.request_path_find_create(this.src_account,this.dst_account,this.dst_amount,this.src_currencies,function(e,r){e?t.emit("error",e):t.notify_update(r)}).request()},o.prototype.close=function(){this.remote.request_path_find_close().request(),this.emit("end"),this.emit("close")},o.prototype.notify_update=function(t){var e=t.source_account,r=t.destination_account,n=s.from_json(t.destination_amount);this.src_account===e&&this.dst_account===r&&this.dst_amount.equals(n)&&this.emit("update",t)},o.prototype.notify_superceded=function(){this.emit("end"),this.emit("superceded")},e.PathFind=o},function(t,e,r){"use strict";function n(t,e,r,n){t[a]=t[a]||{},t[a][e]=t[a][e]||{},t[a][e].params=t[a][e].params||[],t[a][e].params[r]=n}Object.defineProperty(e,"__esModule",{value:!0});var i=r(31),s=r(88),o=r(32),a=Symbol(),c=Symbol(),f=Symbol(),u=Symbol(),h=Symbol();e.isValidStreamAddress=function(t,e,r){n(t,e,r,c)},e.isValidStreamSecret=function(t,e,r){n(t,e,r,u)},e.isValidMemo=function(t,e,r){n(t,e,r,f)},e.isValidAmount=function(t,e,r){n(t,e,r,h)},e.validate=function(t,e,r){var n=r.value;r.value=function(){var r=t[a][e].params;if(Array.isArray(r))for(var d=r.length,l=0;l<d;l++){var p=r[l],b=arguments[l];switch(p){case c:if(!o.isValidAddress(b))throw new Error(b+" is invalid stream address.");break;case u:if(!o.isValidSecret(b))throw new Error(b+" is invalid stream secret.");break;case h:var _=new i.default(b);if(!i.default.isBigNumber(_)||!_.isGreaterThan(0))throw new Error(b+" is invalid amount.");break;case f:if(!s.isValidAddress(b.jtaddress))throw new Error(b.jtaddress+" is invalid jingtum address in memo.")}}return n.apply(this,arguments)}}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=r(89);e.isValidAddress=function(t,e){return void 0===e&&(e="swt"),n.Wallet.isValidAddress(t,e)},e.isValidSecret=function(t,e){return void 0===e&&(e="swt"),n.Wallet.isValidSecret(t,e)},e.getAddress=function(t,e){void 0===e&&(e="swt");try{return n.Wallet.fromSecret(t,e).address}catch(t){return null}},e.createWallet=function(t){return void 0===t&&(t="swt"),n.Wallet.generate(t)}},function(t,e,r){"use strict";var n=r(90),i=r(44);t.exports={Wallet:n,KeyPair:i}},function(t,e,r){"use strict";var n=s(r(42)),i=s(r(43));function s(t){return t&&t.__esModule?t:{default:t}}function o(t){return h.sha512().update(t).digest().slice(0,32)}var a=r(44),c=r(2).ec("secp256k1"),f=r(25).hexToBytes,u=r(25).bytesToHex,h=r(11),d=((0,i.default)(l,[{key:"address",value:function(){return this._keypairs?this._kp.deriveAddress(this._keypairs.publicKey):null}},{key:"secret",value:function(){return this._keypairs?this._secret:null}},{key:"toJson",value:function(){return this._keypairs?{secret:this.secret(),address:this.address()}:null}},{key:"getPublicKey",value:function(){return this._keypairs?this._keypairs.publicKey:null}},{key:"sign",value:function(t){if(!t)return null;if(!this._keypairs)return null;var e=this._keypairs.privateKey;return u(c.sign(o(t),f(e),{canonical:!0}).toDER())}},{key:"verify",value:function(t,e){if(!this._keypairs)return null;var r=this.getPublicKey();return c.verify(o(t),e,f(r))}},{key:"signTx",value:function(t){if(!t)return null;if(!this._keypairs)return null;var e=this._keypairs.privateKey;return u(c.sign(t,f(e),{canonical:!0}).toDER())}},{key:"verifyTx",value:function(t,e){if(!this._keypairs)return null;var r=this.getPublicKey();return c.verify(t,e,f(r))}}],[{key:"generate",value:function(t){var e=new a(0<arguments.length&&void 0!==t?t:"swt"),r=e.generateSeed(),n=e.deriveKeyPair(r);return{secret:r,address:e.deriveAddress(n.publicKey)}}},{key:"fromSecret",value:function(t,e){var r=1<arguments.length&&void 0!==e?e:"swt";try{var n=new a(r),i=n.deriveKeyPair(t);return{secret:t,address:n.deriveAddress(i.publicKey)}}catch(t){return null}}},{key:"isValidAddress",value:function(t,e){return new a(1<arguments.length&&void 0!==e?e:"swt").checkAddress(t)}},{key:"isValidSecret",value:function(t,e){var r=1<arguments.length&&void 0!==e?e:"swt";try{return new a(r).deriveKeyPair(t),!0}catch(t){return!1}}}]),l);function l(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"swt";(0,n.default)(this,l);try{this._kp=new a(e),this._keypairs=this._kp.deriveKeyPair(t),this._secret=t}catch(t){this._keypairs=null,this._secret=null}}t.exports=d},function(t,e,r){t.exports={default:r(92),__esModule:!0}},function(t,e,r){var n=r(93);t.exports=function(t,e,r){return n.setDesc(t,e,r)}},function(t,e){var r=Object;t.exports={create:r.create,getProto:r.getPrototypeOf,isEnum:{}.propertyIsEnumerable,getDesc:r.getOwnPropertyDescriptor,setDesc:r.defineProperty,setDescs:r.defineProperties,getKeys:r.keys,getNames:r.getOwnPropertyNames,getSymbols:r.getOwnPropertySymbols,each:[].forEach}},function(t,e){},function(t,e,r){"use strict";e.sha1=r(96),e.sha224=r(97),e.sha256=r(47),e.sha384=r(98),e.sha512=r(48)},function(t,e,r){"use strict";var n=r(7),i=r(17),s=r(46),o=n.rotl32,a=n.sum32,c=n.sum32_5,f=s.ft_1,u=i.BlockHash,h=[1518500249,1859775393,2400959708,3395469782];function d(){if(!(this instanceof d))return new d;u.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=new Array(80)}n.inherits(d,u),(t.exports=d).blockSize=512,d.outSize=160,d.hmacStrength=80,d.padLength=64,d.prototype._update=function(t,e){for(var r=this.W,n=0;n<16;n++)r[n]=t[e+n];for(;n<r.length;n++)r[n]=o(r[n-3]^r[n-8]^r[n-14]^r[n-16],1);var i=this.h[0],s=this.h[1],u=this.h[2],d=this.h[3],l=this.h[4];for(n=0;n<r.length;n++){var p=~~(n/20),b=c(o(i,5),f(p,s,u,d),l,r[n],h[p]);l=d,d=u,u=o(s,30),s=i,i=b}this.h[0]=a(this.h[0],i),this.h[1]=a(this.h[1],s),this.h[2]=a(this.h[2],u),this.h[3]=a(this.h[3],d),this.h[4]=a(this.h[4],l)},d.prototype._digest=function(t){return"hex"===t?n.toHex32(this.h,"big"):n.split32(this.h,"big")}},function(t,e,r){"use strict";var n=r(7),i=r(47);function s(){if(!(this instanceof s))return new s;i.call(this),this.h=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]}n.inherits(s,i),(t.exports=s).blockSize=512,s.outSize=224,s.hmacStrength=192,s.padLength=64,s.prototype._digest=function(t){return"hex"===t?n.toHex32(this.h.slice(0,7),"big"):n.split32(this.h.slice(0,7),"big")}},function(t,e,r){"use strict";var n=r(7),i=r(48);function s(){if(!(this instanceof s))return new s;i.call(this),this.h=[3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]}n.inherits(s,i),(t.exports=s).blockSize=1024,s.outSize=384,s.hmacStrength=192,s.padLength=128,s.prototype._digest=function(t){return"hex"===t?n.toHex32(this.h.slice(0,12),"big"):n.split32(this.h.slice(0,12),"big")}},function(t,e,r){"use strict";var n=r(7),i=r(17),s=n.rotl32,o=n.sum32,a=n.sum32_3,c=n.sum32_4,f=i.BlockHash;function u(){if(!(this instanceof u))return new u;f.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.endian="little"}function h(t,e,r,n){return t<=15?e^r^n:t<=31?e&r|~e&n:t<=47?(e|~r)^n:t<=63?e&n|r&~n:e^(r|~n)}function d(t){return t<=15?0:t<=31?1518500249:t<=47?1859775393:t<=63?2400959708:2840853838}function l(t){return t<=15?1352829926:t<=31?1548603684:t<=47?1836072691:t<=63?2053994217:0}n.inherits(u,f),(e.ripemd160=u).blockSize=512,u.outSize=160,u.hmacStrength=192,u.padLength=64,u.prototype._update=function(t,e){for(var r=this.h[0],n=this.h[1],i=this.h[2],f=this.h[3],u=this.h[4],v=r,m=n,g=i,w=f,A=u,S=0;S<80;S++){var E=o(s(c(r,h(S,n,i,f),t[p[S]+e],d(S)),_[S]),u);r=u,u=f,f=s(i,10),i=n,n=E,E=o(s(c(v,h(79-S,m,g,w),t[b[S]+e],l(S)),y[S]),A),v=A,A=w,w=s(g,10),g=m,m=E}E=a(this.h[1],i,w),this.h[1]=a(this.h[2],f,A),this.h[2]=a(this.h[3],u,v),this.h[3]=a(this.h[4],r,m),this.h[4]=a(this.h[0],n,g),this.h[0]=E},u.prototype._digest=function(t){return"hex"===t?n.toHex32(this.h,"little"):n.split32(this.h,"little")};var p=[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],b=[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],_=[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],y=[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]},function(t,e,r){"use strict";var n=r(7),i=r(10);function s(t,e,r){if(!(this instanceof s))return new s(t,e,r);this.Hash=t,this.blockSize=t.blockSize/8,this.outSize=t.outSize/8,this.inner=null,this.outer=null,this._init(n.toArray(e,r))}(t.exports=s).prototype._init=function(t){t.length>this.blockSize&&(t=(new this.Hash).update(t).digest()),i(t.length<=this.blockSize);for(var e=t.length;e<this.blockSize;e++)t.push(0);for(e=0;e<t.length;e++)t[e]^=54;for(this.inner=(new this.Hash).update(t),e=0;e<t.length;e++)t[e]^=106;this.outer=(new this.Hash).update(t)},s.prototype.update=function(t,e){return this.inner.update(t,e),this},s.prototype.digest=function(t){return this.outer.update(this.inner.digest()),this.outer.digest(t)}},function(t){t.exports={_args:[["elliptic@6.4.1","/Users/musheng/jccdex/jcc-stream-utils"]],_from:"elliptic@6.4.1",_id:"elliptic@6.4.1",_inBundle:!1,_integrity:"sha512-BsXLz5sqX8OHcsh7CqBMztyXARmGQ3LWPtGjJi6DiJHq5C/qvi9P3OqgswKSDftbu8+IoI/QDTAm2fFnQ9SZSQ==",_location:"/jcc_jingtum_base_lib/elliptic",_phantomChildren:{},_requested:{type:"version",registry:!0,raw:"elliptic@6.4.1",name:"elliptic",escapedName:"elliptic",rawSpec:"6.4.1",saveSpec:null,fetchSpec:"6.4.1"},_requiredBy:["/jcc_jingtum_base_lib"],_resolved:"https://registry.npmjs.org/elliptic/-/elliptic-6.4.1.tgz",_spec:"6.4.1",_where:"/Users/musheng/jccdex/jcc-stream-utils",author:{name:"Fedor Indutny",email:"fedor@indutny.com"},bugs:{url:"https://github.com/indutny/elliptic/issues"},dependencies:{"bn.js":"^4.4.0",brorand:"^1.0.1","hash.js":"^1.0.0","hmac-drbg":"^1.0.0",inherits:"^2.0.1","minimalistic-assert":"^1.0.0","minimalistic-crypto-utils":"^1.0.0"},description:"EC cryptography",devDependencies:{brfs:"^1.4.3",coveralls:"^2.11.3",grunt:"^0.4.5","grunt-browserify":"^5.0.0","grunt-cli":"^1.2.0","grunt-contrib-connect":"^1.0.0","grunt-contrib-copy":"^1.0.0","grunt-contrib-uglify":"^1.0.1","grunt-mocha-istanbul":"^3.0.1","grunt-saucelabs":"^8.6.2",istanbul:"^0.4.2",jscs:"^2.9.0",jshint:"^2.6.0",mocha:"^2.1.0"},files:["lib"],homepage:"https://github.com/indutny/elliptic",keywords:["EC","Elliptic","curve","Cryptography"],license:"MIT",main:"lib/elliptic.js",name:"elliptic",repository:{type:"git",url:"git+ssh://git@github.com/indutny/elliptic.git"},scripts:{jscs:"jscs benchmarks/*.js lib/*.js lib/**/*.js lib/**/**/*.js test/index.js",jshint:"jscs benchmarks/*.js lib/*.js lib/**/*.js lib/**/**/*.js test/index.js",lint:"npm run jscs && npm run jshint",test:"npm run lint && npm run unit",unit:"istanbul test _mocha --reporter=spec test/index.js",version:"grunt dist && git add dist/"},version:"6.4.1"}},function(t,e,r){"use strict";var n=e,i=r(4),s=r(10),o=r(49);n.assert=s,n.toArray=o.toArray,n.zero2=o.zero2,n.toHex=o.toHex,n.encode=o.encode,n.getNAF=function(t,e){for(var r=[],n=1<<e+1,i=t.clone();0<=i.cmpn(1);){var s;if(i.isOdd()){var o=i.andln(n-1);s=(n>>1)-1<o?(n>>1)-o:o,i.isubn(s)}else s=0;r.push(s);for(var a=0!==i.cmpn(0)&&0===i.andln(n-1)?e+1:1,c=1;c<a;c++)r.push(0);i.iushrn(a)}return r},n.getJSF=function(t,e){var r=[[],[]];t=t.clone(),e=e.clone();for(var n=0,i=0;0<t.cmpn(-n)||0<e.cmpn(-i);){var s,o,a,c=t.andln(3)+n&3,f=e.andln(3)+i&3;3===c&&(c=-1),3===f&&(f=-1),s=0==(1&c)?0:3!=(a=t.andln(7)+n&7)&&5!==a||2!==f?c:-c,r[0].push(s),o=0==(1&f)?0:3!=(a=e.andln(7)+i&7)&&5!==a||2!==c?f:-f,r[1].push(o),2*n===s+1&&(n=1-n),2*i===o+1&&(i=1-i),t.iushrn(1),e.iushrn(1)}return r},n.cachedProperty=function(t,e,r){var n="_"+e;t.prototype[e]=function(){return void 0!==this[n]?this[n]:this[n]=r.call(this)}},n.parseBytes=function(t){return"string"==typeof t?n.toArray(t,"hex"):t},n.intFromLE=function(t){return new i(t,"hex","le")}},function(t,e,r){"use strict";var n=r(4),i=r(2).utils,s=i.getNAF,o=i.getJSF,a=i.assert;function c(t,e){this.type=t,this.p=new n(e.p,16),this.red=e.prime?n.red(e.prime):n.mont(this.p),this.zero=new n(0).toRed(this.red),this.one=new n(1).toRed(this.red),this.two=new n(2).toRed(this.red),this.n=e.n&&new n(e.n,16),this.g=e.g&&this.pointFromJSON(e.g,e.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4);var r=this.n&&this.p.div(this.n);!r||0<r.cmpn(100)?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}function f(t,e){this.curve=t,this.type=e,this.precomputed=null}(t.exports=c).prototype.point=function(){throw new Error("Not implemented")},c.prototype.validate=function(){throw new Error("Not implemented")},c.prototype._fixedNafMul=function(t,e){a(t.precomputed);var r=t._getDoubles(),n=s(e,1),i=(1<<r.step+1)-(r.step%2==0?2:1);i/=3;for(var o=[],c=0;c<n.length;c+=r.step){var f=0;for(e=c+r.step-1;c<=e;e--)f=(f<<1)+n[e];o.push(f)}for(var u=this.jpoint(null,null,null),h=this.jpoint(null,null,null),d=i;0<d;d--){for(c=0;c<o.length;c++)(f=o[c])===d?h=h.mixedAdd(r.points[c]):f===-d&&(h=h.mixedAdd(r.points[c].neg()));u=u.add(h)}return u.toP()},c.prototype._wnafMul=function(t,e){var r=4,n=t._getNAFPoints(r);r=n.wnd;for(var i=n.points,o=s(e,r),c=this.jpoint(null,null,null),f=o.length-1;0<=f;f--){for(e=0;0<=f&&0===o[f];f--)e++;if(0<=f&&e++,c=c.dblp(e),f<0)break;var u=o[f];a(0!==u),c="affine"===t.type?0<u?c.mixedAdd(i[u-1>>1]):c.mixedAdd(i[-u-1>>1].neg()):0<u?c.add(i[u-1>>1]):c.add(i[-u-1>>1].neg())}return"affine"===t.type?c.toP():c},c.prototype._wnafMulAdd=function(t,e,r,n,i){for(var a=this._wnafT1,c=this._wnafT2,f=this._wnafT3,u=0,h=0;h<n;h++){var d=(x=e[h])._getNAFPoints(t);a[h]=d.wnd,c[h]=d.points}for(h=n-1;1<=h;h-=2){var l=h-1,p=h;if(1===a[l]&&1===a[p]){var b=[e[l],null,null,e[p]];0===e[l].y.cmp(e[p].y)?(b[1]=e[l].add(e[p]),b[2]=e[l].toJ().mixedAdd(e[p].neg())):0===e[l].y.cmp(e[p].y.redNeg())?(b[1]=e[l].toJ().mixedAdd(e[p]),b[2]=e[l].add(e[p].neg())):(b[1]=e[l].toJ().mixedAdd(e[p]),b[2]=e[l].toJ().mixedAdd(e[p].neg()));var _=[-3,-1,-5,-7,0,7,5,1,3],y=o(r[l],r[p]);u=Math.max(y[0].length,u),f[l]=new Array(u),f[p]=new Array(u);for(var v=0;v<u;v++){var m=0|y[0][v],g=0|y[1][v];f[l][v]=_[3*(1+m)+(1+g)],f[p][v]=0,c[l]=b}}else f[l]=s(r[l],a[l]),f[p]=s(r[p],a[p]),u=Math.max(f[l].length,u),u=Math.max(f[p].length,u)}var w=this.jpoint(null,null,null),A=this._wnafT4;for(h=u;0<=h;h--){for(var S=0;0<=h;){var E=!0;for(v=0;v<n;v++)A[v]=0|f[v][h],0!==A[v]&&(E=!1);if(!E)break;S++,h--}if(0<=h&&S++,w=w.dblp(S),h<0)break;for(v=0;v<n;v++){var x,T=A[v];0!==T&&(0<T?x=c[v][T-1>>1]:T<0&&(x=c[v][-T-1>>1].neg()),w="affine"===x.type?w.mixedAdd(x):w.add(x))}}for(h=0;h<n;h++)c[h]=null;return i?w:w.toP()},(c.BasePoint=f).prototype.eq=function(){throw new Error("Not implemented")},f.prototype.validate=function(){return this.curve.validate(this)},c.prototype.decodePoint=function(t,e){t=i.toArray(t,e);var r=this.p.byteLength();if((4===t[0]||6===t[0]||7===t[0])&&t.length-1==2*r)return 6===t[0]?a(t[t.length-1]%2==0):7===t[0]&&a(t[t.length-1]%2==1),this.point(t.slice(1,1+r),t.slice(1+r,1+2*r));if((2===t[0]||3===t[0])&&t.length-1===r)return this.pointFromX(t.slice(1,1+r),3===t[0]);throw new Error("Unknown point format")},f.prototype.encodeCompressed=function(t){return this.encode(t,!0)},f.prototype._encode=function(t){var e=this.curve.p.byteLength(),r=this.getX().toArray("be",e);return t?[this.getY().isEven()?2:3].concat(r):[4].concat(r,this.getY().toArray("be",e))},f.prototype.encode=function(t,e){return i.encode(this._encode(e),t)},f.prototype.precompute=function(t){if(this.precomputed)return this;var e={doubles:null,naf:null,beta:null};return e.naf=this._getNAFPoints(8),e.doubles=this._getDoubles(4,t),e.beta=this._getBeta(),this.precomputed=e,this},f.prototype._hasDoubles=function(t){if(!this.precomputed)return!1;var e=this.precomputed.doubles;return!!e&&e.points.length>=Math.ceil((t.bitLength()+1)/e.step)},f.prototype._getDoubles=function(t,e){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var r=[this],n=this,i=0;i<e;i+=t){for(var s=0;s<t;s++)n=n.dbl();r.push(n)}return{step:t,points:r}},f.prototype._getNAFPoints=function(t){if(this.precomputed&&this.precomputed.naf)return this.precomputed.naf;for(var e=[this],r=(1<<t)-1,n=1==r?null:this.dbl(),i=1;i<r;i++)e[i]=e[i-1].add(n);return{wnd:t,points:e}},f.prototype._getBeta=function(){return null},f.prototype.dblp=function(t){for(var e=this,r=0;r<t;r++)e=e.dbl();return e}},function(t,e,r){"use strict";var n=r(24),i=r(2),s=r(4),o=r(12),a=n.base,c=i.utils.assert;function f(t){a.call(this,"short",t),this.a=new s(t.a,16).toRed(this.red),this.b=new s(t.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(t),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}function u(t,e,r,n){a.BasePoint.call(this,t,"affine"),null===e&&null===r?(this.x=null,this.y=null,this.inf=!0):(this.x=new s(e,16),this.y=new s(r,16),n&&(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 h(t,e,r,n){a.BasePoint.call(this,t,"jacobian"),null===e&&null===r&&null===n?(this.x=this.curve.one,this.y=this.curve.one,this.z=new s(0)):(this.x=new s(e,16),this.y=new s(r,16),this.z=new s(n,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}o(f,a),(t.exports=f).prototype._getEndomorphism=function(t){if(this.zeroA&&this.g&&this.n&&1===this.p.modn(3)){var e,r;if(t.beta)e=new s(t.beta,16).toRed(this.red);else{var n=this._getEndoRoots(this.p);e=(e=n[0].cmp(n[1])<0?n[0]:n[1]).toRed(this.red)}if(t.lambda)r=new s(t.lambda,16);else{var i=this._getEndoRoots(this.n);0===this.g.mul(i[0]).x.cmp(this.g.x.redMul(e))?r=i[0]:(r=i[1],c(0===this.g.mul(r).x.cmp(this.g.x.redMul(e))))}return{beta:e,lambda:r,basis:t.basis?t.basis.map(function(t){return{a:new s(t.a,16),b:new s(t.b,16)}}):this._getEndoBasis(r)}}},f.prototype._getEndoRoots=function(t){var e=t===this.p?this.red:s.mont(t),r=new s(2).toRed(e).redInvm(),n=r.redNeg(),i=new s(3).toRed(e).redNeg().redSqrt().redMul(r);return[n.redAdd(i).fromRed(),n.redSub(i).fromRed()]},f.prototype._getEndoBasis=function(t){for(var e,r,n,i,o,a,c,f,u,h=this.n.ushrn(Math.floor(this.n.bitLength()/2)),d=t,l=this.n.clone(),p=new s(1),b=new s(0),_=new s(0),y=new s(1),v=0;0!==d.cmpn(0);){var m=l.div(d);f=l.sub(m.mul(d)),u=_.sub(m.mul(p));var g=y.sub(m.mul(b));if(!n&&f.cmp(h)<0)e=c.neg(),r=p,n=f.neg(),i=u;else if(n&&2==++v)break;l=d,d=c=f,_=p,p=u,y=b,b=g}o=f.neg(),a=u;var w=n.sqr().add(i.sqr());return 0<=o.sqr().add(a.sqr()).cmp(w)&&(o=e,a=r),n.negative&&(n=n.neg(),i=i.neg()),o.negative&&(o=o.neg(),a=a.neg()),[{a:n,b:i},{a:o,b:a}]},f.prototype._endoSplit=function(t){var e=this.endo.basis,r=e[0],n=e[1],i=n.b.mul(t).divRound(this.n),s=r.b.neg().mul(t).divRound(this.n),o=i.mul(r.a),a=s.mul(n.a),c=i.mul(r.b),f=s.mul(n.b);return{k1:t.sub(o).sub(a),k2:c.add(f).neg()}},f.prototype.pointFromX=function(t,e){(t=new s(t,16)).red||(t=t.toRed(this.red));var r=t.redSqr().redMul(t).redIAdd(t.redMul(this.a)).redIAdd(this.b),n=r.redSqrt();if(0!==n.redSqr().redSub(r).cmp(this.zero))throw new Error("invalid point");var i=n.fromRed().isOdd();return(e&&!i||!e&&i)&&(n=n.redNeg()),this.point(t,n)},f.prototype.validate=function(t){if(t.inf)return!0;var e=t.x,r=t.y,n=this.a.redMul(e),i=e.redSqr().redMul(e).redIAdd(n).redIAdd(this.b);return 0===r.redSqr().redISub(i).cmpn(0)},f.prototype._endoWnafMulAdd=function(t,e,r){for(var n=this._endoWnafT1,i=this._endoWnafT2,s=0;s<t.length;s++){var o=this._endoSplit(e[s]),a=t[s],c=a._getBeta();o.k1.negative&&(o.k1.ineg(),a=a.neg(!0)),o.k2.negative&&(o.k2.ineg(),c=c.neg(!0)),n[2*s]=a,n[2*s+1]=c,i[2*s]=o.k1,i[2*s+1]=o.k2}for(var f=this._wnafMulAdd(1,n,i,2*s,r),u=0;u<2*s;u++)n[u]=null,i[u]=null;return f},o(u,a.BasePoint),f.prototype.point=function(t,e,r){return new u(this,t,e,r)},f.prototype.pointFromJSON=function(t,e){return u.fromJSON(this,t,e)},u.prototype._getBeta=function(){if(this.curve.endo){var t=this.precomputed;if(t&&t.beta)return t.beta;var e=this.curve.point(this.x.redMul(this.curve.endo.beta),this.y);if(t){var r=this.curve,n=function(t){return r.point(t.x.redMul(r.endo.beta),t.y)};(t.beta=e).precomputed={beta:null,naf:t.naf&&{wnd:t.naf.wnd,points:t.naf.points.map(n)},doubles:t.doubles&&{step:t.doubles.step,points:t.doubles.points.map(n)}}}return e}},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(t,e,r){"string"==typeof e&&(e=JSON.parse(e));var n=t.point(e[0],e[1],r);if(!e[2])return n;function i(e){return t.point(e[0],e[1],r)}var s=e[2];return n.precomputed={beta:null,doubles:s.doubles&&{step:s.doubles.step,points:[n].concat(s.doubles.points.map(i))},naf:s.naf&&{wnd:s.naf.wnd,points:[n].concat(s.naf.points.map(i))}},n},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(t){if(this.inf)return t;if(t.inf)return this;if(this.eq(t))return this.dbl();if(this.neg().eq(t))return this.curve.point(null,null);if(0===this.x.cmp(t.x))return this.curve.point(null,null);var e=this.y.redSub(t.y);0!==e.cmpn(0)&&(e=e.redMul(this.x.redSub(t.x).redInvm()));var r=e.redSqr().redISub(this.x).redISub(t.x),n=e.redMul(this.x.redSub(r)).redISub(this.y);return this.curve.point(r,n)},u.prototype.dbl=function(){if(this.inf)return this;var t=this.y.redAdd(this.y);if(0===t.cmpn(0))return this.curve.point(null,null);var e=this.curve.a,r=this.x.redSqr(),n=t.redInvm(),i=r.redAdd(r).redIAdd(r).redIAdd(e).redMul(n),s=i.redSqr().redISub(this.x.redAdd(this.x)),o=i.redMul(this.x.redSub(s)).redISub(this.y);return this.curve.point(s,o)},u.prototype.getX=function(){return this.x.fromRed()},u.prototype.getY=function(){return this.y.fromRed()},u.prototype.mul=function(t){return t=new s(t,16),this._hasDoubles(t)?this.curve._fixedNafMul(this,t):this.curve.endo?this.curve._endoWnafMulAdd([this],[t]):this.curve._wnafMul(this,t)},u.prototype.mulAdd=function(t,e,r){var n=[this,e],i=[t,r];return this.curve.endo?this.curve._endoWnafMulAdd(n,i):this.curve._wnafMulAdd(1,n,i,2)},u.prototype.jmulAdd=function(t,e,r){var n=[this,e],i=[t,r];return this.curve.endo?this.curve._endoWnafMulAdd(n,i,!0):this.curve._wnafMulAdd(1,n,i,2,!0)},u.prototype.eq=function(t){return this===t||this.inf===t.inf&&(this.inf||0===this.x.cmp(t.x)&&0===this.y.cmp(t.y))},u.prototype.neg=function(t){if(this.inf)return this;var e=this.curve.point(this.x,this.y.redNeg());if(t&&this.precomputed){var r=this.precomputed,n=function(t){return t.neg()};e.precomputed={naf:r.naf&&{wnd:r.naf.wnd,points:r.naf.points.map(n)},doubles:r.doubles&&{step:r.doubles.step,points:r.doubles.points.map(n)}}}return e},u.prototype.toJ=function(){return this.inf?this.curve.jpoint(null,null,null):this.curve.jpoint(this.x,this.y,this.curve.one)},o(h,a.BasePoint),f.prototype.jpoint=function(t,e,r){return new h(this,t,e,r)},h.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var t=this.z.redInvm(),e=t.redSqr(),r=this.x.redMul(e),n=this.y.redMul(e).redMul(t);return this.curve.point(r,n)},h.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},h.prototype.add=function(t){if(this.isInfinity())return t;if(t.isInfinity())return this;var e=t.z.redSqr(),r=this.z.redSqr(),n=this.x.redMul(e),i=t.x.redMul(r),s=this.y.redMul(e.redMul(t.z)),o=t.y.redMul(r.redMul(this.z)),a=n.redSub(i),c=s.redSub(o);if(0===a.cmpn(0))return 0!==c.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var f=a.redSqr(),u=f.redMul(a),h=n.redMul(f),d=c.redSqr().redIAdd(u).redISub(h).redISub(h),l=c.redMul(h.redISub(d)).redISub(s.redMul(u)),p=this.z.redMul(t.z).redMul(a);return this.curve.jpoint(d,l,p)},h.prototype.mixedAdd=function(t){if(this.isInfinity())return t.toJ();if(t.isInfinity())return this;var e=this.z.redSqr(),r=this.x,n=t.x.redMul(e),i=this.y,s=t.y.redMul(e).redMul(this.z),o=r.redSub(n),a=i.redSub(s);if(0===o.cmpn(0))return 0!==a.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var c=o.redSqr(),f=c.redMul(o),u=r.redMul(c),h=a.redSqr().redIAdd(f).redISub(u).redISub(u),d=a.redMul(u.redISub(h)).redISub(i.redMul(f)),l=this.z.redMul(o);return this.curve.jpoint(h,d,l)},h.prototype.dblp=function(t){if(0===t)return this;if(this.isInfinity())return this;if(!t)return this.dbl();if(this.curve.zeroA||this.curve.threeA){for(var e=this,r=0;r<t;r++)e=e.dbl();return e}var n=this.curve.a,i=this.curve.tinv,s=this.x,o=this.y,a=this.z,c=a.redSqr().redSqr(),f=o.redAdd(o);for(r=0;r<t;r++){var u=s.redSqr(),h=f.redSqr(),d=h.redSqr(),l=u.redAdd(u).redIAdd(u).redIAdd(n.redMul(c)),p=s.redMul(h),b=l.redSqr().redISub(p.redAdd(p)),_=p.redISub(b),y=l.redMul(_);y=y.redIAdd(y).redISub(d);var v=f.redMul(a);r+1<t&&(c=c.redMul(d)),s=b,a=v,f=y}return this.curve.jpoint(s,f.redMul(i),a)},h.prototype.dbl=function(){return this.isInfinity()?this:this.curve.zeroA?this._zeroDbl():this.curve.threeA?this._threeDbl():this._dbl()},h.prototype._zeroDbl=function(){var t,e,r;if(this.zOne){var n=this.x.redSqr(),i=this.y.redSqr(),s=i.redSqr(),o=this.x.redAdd(i).redSqr().redISub(n).redISub(s);o=o.redIAdd(o);var a=n.redAdd(n).redIAdd(n),c=a.redSqr().redISub(o).redISub(o),f=s.redIAdd(s);f=(f=f.redIAdd(f)).redIAdd(f),t=c,e=a.redMul(o.redISub(c)).redISub(f),r=this.y.redAdd(this.y)}else{var u=this.x.redSqr(),h=this.y.redSqr(),d=h.redSqr(),l=this.x.redAdd(h).redSqr().redISub(u).redISub(d);l=l.redIAdd(l);var p=u.redAdd(u).redIAdd(u),b=p.redSqr(),_=d.redIAdd(d);_=(_=_.redIAdd(_)).redIAdd(_),t=b.redISub(l).redISub(l),e=p.redMul(l.redISub(t)).redISub(_),r=(r=this.y.redMul(this.z)).redIAdd(r)}return this.curve.jpoint(t,e,r)},h.prototype._threeDbl=function(){var t,e,r;if(this.zOne){var n=this.x.redSqr(),i=this.y.redSqr(),s=i.redSqr(),o=this.x.redAdd(i).redSqr().redISub(n).redISub(s);o=o.redIAdd(o);var a=n.redAdd(n).redIAdd(n).redIAdd(this.curve.a),c=a.redSqr().redISub(o).redISub(o);t=c;var f=s.redIAdd(s);f=(f=f.redIAdd(f)).redIAdd(f),e=a.redMul(o.redISub(c)).redISub(f),r=this.y.redAdd(this.y)}else{var u=this.z.redSqr(),h=this.y.redSqr(),d=this.x.redMul(h),l=this.x.redSub(u).redMul(this.x.redAdd(u));l=l.redAdd(l).redIAdd(l);var p=d.redIAdd(d),b=(p=p.redIAdd(p)).redAdd(p);t=l.redSqr().redISub(b),r=this.y.redAdd(this.z).redSqr().redISub(h).redISub(u);var _=h.redSqr();_=(_=(_=_.redIAdd(_)).redIAdd(_)).redIAdd(_),e=l.redMul(p.redISub(t)).redISub(_)}return this.curve.jpoint(t,e,r)},h.prototype._dbl=function(){var t=this.curve.a,e=this.x,r=this.y,n=this.z,i=n.redSqr().redSqr(),s=e.redSqr(),o=r.redSqr(),a=s.redAdd(s).redIAdd(s).redIAdd(t.redMul(i)),c=e.redAdd(e),f=(c=c.redIAdd(c)).redMul(o),u=a.redSqr().redISub(f.redAdd(f)),h=f.redISub(u),d=o.redSqr();d=(d=(d=d.redIAdd(d)).redIAdd(d)).redIAdd(d);var l=a.redMul(h).redISub(d),p=r.redAdd(r).redMul(n);return this.curve.jpoint(u,l,p)},h.prototype.trpl=function(){if(!this.curve.zeroA)return this.dbl().add(this);var t=this.x.redSqr(),e=this.y.redSqr(),r=this.z.redSqr(),n=e.redSqr(),i=t.redAdd(t).redIAdd(t),s=i.redSqr(),o=this.x.redAdd(e).redSqr().redISub(t).redISub(n),a=(o=(o=(o=o.redIAdd(o)).redAdd(o).redIAdd(o)).redISub(s)).redSqr(),c=n.redIAdd(n);c=(c=(c=c.redIAdd(c)).redIAdd(c)).redIAdd(c);var f=i.redIAdd(o).redSqr().redISub(s).redISub(a).redISub(c),u=e.redMul(f);u=(u=u.redIAdd(u)).redIAdd(u);var h=this.x.redMul(a).redISub(u);h=(h=h.redIAdd(h)).redIAdd(h);var d=this.y.redMul(f.redMul(c.redISub(f)).redISub(o.redMul(a)));d=(d=(d=d.redIAdd(d)).redIAdd(d)).redIAdd(d);var l=this.z.redAdd(o).redSqr().redISub(r).redISub(a);return this.curve.jpoint(h,d,l)},h.prototype.mul=function(t,e){return t=new s(t,e),this.curve._wnafMul(this,t)},h.prototype.eq=function(t){if("affine"===t.type)return this.eq(t.toJ());if(this===t)return!0;var e=this.z.redSqr(),r=t.z.redSqr();if(0!==this.x.redMul(r).redISub(t.x.redMul(e)).cmpn(0))return!1;var n=e.redMul(this.z),i=r.redMul(t.z);return 0===this.y.redMul(i).redISub(t.y.redMul(n)).cmpn(0)},h.prototype.eqXToP=function(t){var e=this.z.redSqr(),r=t.toRed(this.curve.red).redMul(e);if(0===this.x.cmp(r))return!0;for(var n=t.clone(),i=this.curve.redN.redMul(e);;){if(n.iadd(this.curve.n),0<=n.cmp(this.curve.p))return!1;if(r.redIAdd(i),0===this.x.cmp(r))return!0}},h.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)+">"},h.prototype.isInfinity=function(){return 0===this.z.cmpn(0)}},function(t,e,r){"use strict";var n=r(24),i=r(4),s=r(12),o=n.base,a=r(2).utils;function c(t){o.call(this,"mont",t),this.a=new i(t.a,16).toRed(this.red),this.b=new i(t.b,16).toRed(this.red),this.i4=new i(4).toRed(this.red).redInvm(),this.two=new i(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}function f(t,e,r){o.BasePoint.call(this,t,"projective"),null===e&&null===r?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new i(e,16),this.z=new i(r,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}s(c,o),(t.exports=c).prototype.validate=function(t){var e=t.normalize().x,r=e.redSqr(),n=r.redMul(e).redAdd(r.redMul(this.a)).redAdd(e);return 0===n.redSqrt().redSqr().cmp(n)},s(f,o.BasePoint),c.prototype.decodePoint=function(t,e){return this.point(a.toArray(t,e),1)},c.prototype.point=function(t,e){return new f(this,t,e)},c.prototype.pointFromJSON=function(t){return f.fromJSON(this,t)},f.prototype.precompute=function(){},f.prototype._encode=function(){return this.getX().toArray("be",this.curve.p.byteLength())},f.fromJSON=function(t,e){return new f(t,e[0],e[1]||t.one)},f.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)+">"},f.prototype.isInfinity=function(){return 0===this.z.cmpn(0)},f.prototype.dbl=function(){var t=this.x.redAdd(this.z).redSqr(),e=this.x.redSub(this.z).redSqr(),r=t.redSub(e),n=t.redMul(e),i=r.redMul(e.redAdd(this.curve.a24.redMul(r)));return this.curve.point(n,i)},f.prototype.add=function(){throw new Error("Not supported on Montgomery curve")},f.prototype.diffAdd=function(t,e){var r=this.x.redAdd(this.z),n=this.x.redSub(this.z),i=t.x.redAdd(t.z),s=t.x.redSub(t.z).redMul(r),o=i.redMul(n),a=e.z.redMul(s.redAdd(o).redSqr()),c=e.x.redMul(s.redISub(o).redSqr());return this.curve.point(a,c)},f.prototype.mul=function(t){for(var e=t.clone(),r=this,n=this.curve.point(null,null),i=[];0!==e.cmpn(0);e.iushrn(1))i.push(e.andln(1));for(var s=i.length-1;0<=s;s--)0===i[s]?(r=r.diffAdd(n,this),n=n.dbl()):(n=r.diffAdd(n,this),r=r.dbl());return n},f.prototype.mulAdd=function(){throw new Error("Not supported on Montgomery curve")},f.prototype.jumlAdd=function(){throw new Error("Not supported on Montgomery curve")},f.prototype.eq=function(t){return 0===this.getX().cmp(t.getX())},f.prototype.normalize=function(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this},f.prototype.getX=function(){return this.normalize(),this.x.fromRed()}},function(t,e,r){"use strict";var n=r(24),i=r(2),s=r(4),o=r(12),a=n.base,c=i.utils.assert;function f(t){this.twisted=1!=(0|t.a),this.mOneA=this.twisted&&-1==(0|t.a),this.extended=this.mOneA,a.call(this,"edwards",t),this.a=new s(t.a,16).umod(this.red.m),this.a=this.a.toRed(this.red),this.c=new s(t.c,16).toRed(this.red),this.c2=this.c.redSqr(),this.d=new s(t.d,16).toRed(this.red),this.dd=this.d.redAdd(this.d),c(!this.twisted||0===this.c.fromRed().cmpn(1)),this.oneC=1==(0|t.c)}function u(t,e,r,n,i){a.BasePoint.call(this,t,"projective"),null===e&&null===r&&null===n?(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 s(e,16),this.y=new s(r,16),this.z=n?new s(n,16):this.curve.one,this.t=i&&new s(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()))))}o(f,a),(t.exports=f).prototype._mulA=function(t){return this.mOneA?t.redNeg():this.a.redMul(t)},f.prototype._mulC=function(t){return this.oneC?t:this.c.redMul(t)},f.prototype.jpoint=function(t,e,r,n){return this.point(t,e,r,n)},f.prototype.pointFromX=function(t,e){(t=new s(t,16)).red||(t=t.toRed(this.red));var r=t.redSqr(),n=this.c2.redSub(this.a.redMul(r)),i=this.one.redSub(this.c2.redMul(this.d).redMul(r)),o=n.redMul(i.redInvm()),a=o.redSqrt();if(0!==a.redSqr().redSub(o).cmp(this.zero))throw new Error("invalid point");var c=a.fromRed().isOdd();return(e&&!c||!e&&c)&&(a=a.redNeg()),this.point(t,a)},f.prototype.pointFromY=function(t,e){(t=new s(t,16)).red||(t=t.toRed(this.red));var r=t.redSqr(),n=r.redSub(this.c2),i=r.redMul(this.d).redMul(this.c2).redSub(this.a),o=n.redMul(i.redInvm());if(0===o.cmp(this.zero)){if(e)throw new Error("invalid point");return this.point(this.zero,t)}var a=o.redSqrt();if(0!==a.redSqr().redSub(o).cmp(this.zero))throw new Error("invalid point");return a.fromRed().isOdd()!==e&&(a=a.redNeg()),this.point(a,t)},f.prototype.validate=function(t){if(t.isInfinity())return!0;t.normalize();var e=t.x.redSqr(),r=t.y.redSqr(),n=e.redMul(this.a).redAdd(r),i=this.c2.redMul(this.one.redAdd(this.d.redMul(e).redMul(r)));return 0===n.cmp(i)},o(u,a.BasePoint),f.prototype.pointFromJSON=function(t){return u.fromJSON(this,t)},f.prototype.point=function(t,e,r,n){return new u(this,t,e,r,n)},u.fromJSON=function(t,e){return new u(t,e[0],e[1],e[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 t=this.x.redSqr(),e=this.y.redSqr(),r=this.z.redSqr();r=r.redIAdd(r);var n=this.curve._mulA(t),i=this.x.redAdd(this.y).redSqr().redISub(t).redISub(e),s=n.redAdd(e),o=s.redSub(r),a=n.redSub(e),c=i.redMul(o),f=s.redMul(a),u=i.redMul(a),h=o.redMul(s);return this.curve.point(c,f,h,u)},u.prototype._projDbl=function(){var t,e,r,n=this.x.redAdd(this.y).redSqr(),i=this.x.redSqr(),s=this.y.redSqr();if(this.curve.twisted){var o=(f=this.curve._mulA(i)).redAdd(s);if(this.zOne)t=n.redSub(i).redSub(s).redMul(o.redSub(this.curve.two)),e=o.redMul(f.redSub(s)),r=o.redSqr().redSub(o).redSub(o);else{var a=this.z.redSqr(),c=o.redSub(a).redISub(a);t=n.redSub(i).redISub(s).redMul(c),e=o.redMul(f.redSub(s)),r=o.redMul(c)}}else{var f=i.redAdd(s);a=this.curve._mulC(this.z).redSqr(),c=f.redSub(a).redSub(a),t=this.curve._mulC(n.redISub(f)).redMul(c),e=this.curve._mulC(f).redMul(i.redISub(s)),r=f.redMul(c)}return this.curve.point(t,e,r)},u.prototype.dbl=function(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()},u.prototype._extAdd=function(t){var e=this.y.redSub(this.x).redMul(t.y.redSub(t.x)),r=this.y.redAdd(this.x).redMul(t.y.redAdd(t.x)),n=this.t.redMul(this.curve.dd).redMul(t.t),i=this.z.redMul(t.z.redAdd(t.z)),s=r.redSub(e),o=i.redSub(n),a=i.redAdd(n),c=r.redAdd(e),f=s.redMul(o),u=a.redMul(c),h=s.redMul(c),d=o.redMul(a);return this.curve.point(f,u,d,h)},u.prototype._projAdd=function(t){var e,r,n=this.z.redMul(t.z),i=n.redSqr(),s=this.x.redMul(t.x),o=this.y.redMul(t.y),a=this.curve.d.redMul(s).redMul(o),c=i.redSub(a),f=i.redAdd(a),u=this.x.redAdd(this.y).redMul(t.x.redAdd(t.y)).redISub(s).redISub(o),h=n.redMul(c).redMul(u);return r=this.curve.twisted?(e=n.redMul(f).redMul(o.redSub(this.curve._mulA(s))),c.redMul(f)):(e=n.redMul(f).redMul(o.redSub(s)),this.curve._mulC(c).redMul(f)),this.curve.point(h,e,r)},u.prototype.add=function(t){return this.isInfinity()?t:t.isInfinity()?this:this.curve.extended?this._extAdd(t):this._projAdd(t)},u.prototype.mul=function(t){return this._hasDoubles(t)?this.curve._fixedNafMul(this,t):this.curve._wnafMul(this,t)},u.prototype.mulAdd=function(t,e,r){return this.curve._wnafMulAdd(1,[this,e],[t,r],2,!1)},u.prototype.jmulAdd=function(t,e,r){return this.curve._wnafMulAdd(1,[this,e],[t,r],2,!0)},u.prototype.normalize=function(){if(this.zOne)return this;var t=this.z.redInvm();return this.x=this.x.redMul(t),this.y=this.y.redMul(t),this.t&&(this.t=this.t.redMul(t)),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(t){return this===t||0===this.getX().cmp(t.getX())&&0===this.getY().cmp(t.getY())},u.prototype.eqXToP=function(t){var e=t.toRed(this.curve.red).redMul(this.z);if(0===this.x.cmp(e))return!0;for(var r=t.clone(),n=this.curve.redN.redMul(this.z);;){if(r.iadd(this.curve.n),0<=r.cmp(this.curve.p))return!1;if(e.redIAdd(n),0===this.x.cmp(e))return!0}},u.prototype.toP=u.prototype.normalize,u.prototype.mixedAdd=u.prototype.add},function(t,e,r){"use strict";var n,i=e,s=r(11),o=r(2),a=o.utils.assert;function c(t){"short"===t.type?this.curve=new o.curve.short(t):"edwards"===t.type?this.curve=new o.curve.edwards(t):this.curve=new o.curve.mont(t),this.g=this.curve.g,this.n=this.curve.n,this.hash=t.hash,a(this.g.validate(),"Invalid curve"),a(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}function f(t,e){Object.defineProperty(i,t,{configurable:!0,enumerable:!0,get:function(){var r=new c(e);return Object.defineProperty(i,t,{configurable:!0,enumerable:!0,value:r}),r}})}i.PresetCurve=c,f("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:s.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),f("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:s.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),f("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:s.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),f("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:s.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"]}),f("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:s.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"]}),f("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:s.sha256,gRed:!1,g:["9"]}),f("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:s.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});try{n=r(108)}catch(t){n=void 0}f("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:s.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",n]})},function(t,e){t.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"]]}}},function(t,e,r){"use strict";var n=r(4),i=r(110),s=r(2),o=s.utils.assert,a=r(111),c=r(112);function f(t){if(!(this instanceof f))return new f(t);"string"==typeof t&&(o(s.curves.hasOwnProperty(t),"Unknown curve "+t),t=s.curves[t]),t instanceof s.curves.PresetCurve&&(t={curve:t}),this.curve=t.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=t.curve.g,this.g.precompute(t.curve.n.bitLength()+1),this.hash=t.hash||t.curve.hash}(t.exports=f).prototype.keyPair=function(t){return new a(this,t)},f.prototype.keyFromPrivate=function(t,e){return a.fromPrivate(this,t,e)},f.prototype.keyFromPublic=function(t,e){return a.fromPublic(this,t,e)},f.prototype.genKeyPair=function(t){t=t||{};for(var e=new i({hash:this.hash,pers:t.pers,persEnc:t.persEnc||"utf8",entropy:t.entropy||s.rand(this.hash.hmacStrength),entropyEnc:t.entropy&&t.entropyEnc||"utf8",nonce:this.n.toArray()}),r=this.n.byteLength(),o=this.n.sub(new n(2));;){var a=new n(e.generate(r));if(!(0<a.cmp(o)))return a.iaddn(1),this.keyFromPrivate(a)}},f.prototype._truncateToN=function(t,e){var r=8*t.byteLength()-this.n.bitLength();return 0<r&&(t=t.ushrn(r)),!e&&0<=t.cmp(this.n)?t.sub(this.n):t},f.prototype.sign=function(t,e,r,s){"object"==typeof r&&(s=r,r=null),s=s||{},e=this.keyFromPrivate(e,r),t=this._truncateToN(new n(t,16));for(var o=this.n.byteLength(),a=e.getPrivate().toArray("be",o),f=t.toArray("be",o),u=new i({hash:this.hash,entropy:a,nonce:f,pers:s.pers,persEnc:s.persEnc||"utf8"}),h=this.n.sub(new n(1)),d=0;;d++){var l=s.k?s.k(d):new n(u.generate(this.n.byteLength()));if(!((l=this._truncateToN(l,!0)).cmpn(1)<=0||0<=l.cmp(h))){var p=this.g.mul(l);if(!p.isInfinity()){var b=p.getX(),_=b.umod(this.n);if(0!==_.cmpn(0)){var y=l.invm(this.n).mul(_.mul(e.getPrivate()).iadd(t));if(0!==(y=y.umod(this.n)).cmpn(0)){var v=(p.getY().isOdd()?1:0)|(0!==b.cmp(_)?2:0);return s.canonical&&0<y.cmp(this.nh)&&(y=this.n.sub(y),v^=1),new c({r:_,s:y,recoveryParam:v})}}}}}},f.prototype.verify=function(t,e,r,i){t=this._truncateToN(new n(t,16)),r=this.keyFromPublic(r,i);var s=(e=new c(e,"hex")).r,o=e.s;if(s.cmpn(1)<0||0<=s.cmp(this.n))return!1;if(o.cmpn(1)<0||0<=o.cmp(this.n))return!1;var a,f=o.invm(this.n),u=f.mul(t).umod(this.n),h=f.mul(s).umod(this.n);return this.curve._maxwellTrick?!(a=this.g.jmulAdd(u,r.getPublic(),h)).isInfinity()&&a.eqXToP(s):!(a=this.g.mulAdd(u,r.getPublic(),h)).isInfinity()&&0===a.getX().umod(this.n).cmp(s)},f.prototype.recoverPubKey=function(t,e,r,i){o((3&r)===r,"The recovery param is more than two bits"),e=new c(e,i);var s=this.n,a=new n(t),f=e.r,u=e.s,h=1&r,d=r>>1;if(0<=f.cmp(this.curve.p.umod(this.curve.n))&&d)throw new Error("Unable to find sencond key candinate");f=d?this.curve.pointFromX(f.add(this.curve.n),h):this.curve.pointFromX(f,h);var l=e.r.invm(s),p=s.sub(a).mul(l).umod(s),b=u.mul(l).umod(s);return this.g.mulAdd(p,f,b)},f.prototype.getKeyRecoveryParam=function(t,e,r,n){if(null!==(e=new c(e,n)).recoveryParam)return e.recoveryParam;for(var i=0;i<4;i++){var s;try{s=this.recoverPubKey(t,e,i)}catch(t){continue}if(s.eq(r))return i}throw new Error("Unable to find valid recovery factor")}},function(t,e,r){"use strict";var n=r(11),i=r(49),s=r(10);function o(t){if(!(this instanceof o))return new o(t);this.hash=t.hash,this.predResist=!!t.predResist,this.outLen=this.hash.outSize,this.minEntropy=t.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var e=i.toArray(t.entropy,t.entropyEnc||"hex"),r=i.toArray(t.nonce,t.nonceEnc||"hex"),n=i.toArray(t.pers,t.persEnc||"hex");s(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(e,r,n)}(t.exports=o).prototype._init=function(t,e,r){var n=t.concat(e).concat(r);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var i=0;i<this.V.length;i++)this.K[i]=0,this.V[i]=1;this._update(n),this._reseed=1,this.reseedInterval=281474976710656},o.prototype._hmac=function(){return new n.hmac(this.hash,this.K)},o.prototype._update=function(t){var e=this._hmac().update(this.V).update([0]);t&&(e=e.update(t)),this.K=e.digest(),this.V=this._hmac().update(this.V).digest(),t&&(this.K=this._hmac().update(this.V).update([1]).update(t).digest(),this.V=this._hmac().update(this.V).digest())},o.prototype.reseed=function(t,e,r,n){"string"!=typeof e&&(n=r,r=e,e=null),t=i.toArray(t,e),r=i.toArray(r,n),s(t.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(t.concat(r||[])),this._reseed=1},o.prototype.generate=function(t,e,r,n){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");"string"!=typeof e&&(n=r,r=e,e=null),r&&(r=i.toArray(r,n||"hex"),this._update(r));for(var s=[];s.length<t;)this.V=this._hmac().update(this.V).digest(),s=s.concat(this.V);var o=s.slice(0,t);return this._update(r),this._reseed++,i.encode(o,e)}},function(t,e,r){"use strict";var n=r(4),i=r(2).utils.assert;function s(t,e){this.ec=t,this.priv=null,this.pub=null,e.priv&&this._importPrivate(e.priv,e.privEnc),e.pub&&this._importPublic(e.pub,e.pubEnc)}(t.exports=s).fromPublic=function(t,e,r){return e instanceof s?e:new s(t,{pub:e,pubEnc:r})},s.fromPrivate=function(t,e,r){return e instanceof s?e:new s(t,{priv:e,privEnc:r})},s.prototype.validate=function(){var t=this.getPublic();return t.isInfinity()?{result:!1,reason:"Invalid public key"}:t.validate()?t.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"}},s.prototype.getPublic=function(t,e){return"string"==typeof t&&(e=t,t=null),this.pub||(this.pub=this.ec.g.mul(this.priv)),e?this.pub.encode(e,t):this.pub},s.prototype.getPrivate=function(t){return"hex"===t?this.priv.toString(16,2):this.priv},s.prototype._importPrivate=function(t,e){this.priv=new n(t,e||16),this.priv=this.priv.umod(this.ec.curve.n)},s.prototype._importPublic=function(t,e){if(t.x||t.y)return"mont"===this.ec.curve.type?i(t.x,"Need x coordinate"):"short"!==this.ec.curve.type&&"edwards"!==this.ec.curve.type||i(t.x&&t.y,"Need both x and y coordinate"),void(this.pub=this.ec.curve.point(t.x,t.y));this.pub=this.ec.curve.decodePoint(t,e)},s.prototype.derive=function(t){return t.mul(this.priv).getX()},s.prototype.sign=function(t,e,r){return this.ec.sign(t,this,e,r)},s.prototype.verify=function(t,e){return this.ec.verify(t,e,this)},s.prototype.inspect=function(){return"<Key priv: "+(this.priv&&this.priv.toString(16,2))+" pub: "+(this.pub&&this.pub.inspect())+" >"}},function(t,e,r){"use strict";var n=r(4),i=r(2).utils,s=i.assert;function o(t,e){if(t instanceof o)return t;this._importDER(t,e)||(s(t.r&&t.s,"Signature without r or s"),this.r=new n(t.r,16),this.s=new n(t.s,16),void 0===t.recoveryParam?this.recoveryParam=null:this.recoveryParam=t.recoveryParam)}function a(){this.place=0}function c(t,e){var r=t[e.place++];if(!(128&r))return r;for(var n=15&r,i=0,s=0,o=e.place;s<n;s++,o++)i<<=8,i|=t[o];return e.place=o,i}function f(t){for(var e=0,r=t.length-1;!t[e]&&!(128&t[e+1])&&e<r;)e++;return 0===e?t:t.slice(e)}function u(t,e){if(e<128)t.push(e);else{var r=1+(Math.log(e)/Math.LN2>>>3);for(t.push(128|r);--r;)t.push(e>>>(r<<3)&255);t.push(e)}}(t.exports=o).prototype._importDER=function(t,e){t=i.toArray(t,e);var r=new a;if(48!==t[r.place++])return!1;if(c(t,r)+r.place!==t.length)return!1;if(2!==t[r.place++])return!1;var s=c(t,r),o=t.slice(r.place,s+r.place);if(r.place+=s,2!==t[r.place++])return!1;var f=c(t,r);if(t.length!==f+r.place)return!1;var u=t.slice(r.place,f+r.place);return 0===o[0]&&128&o[1]&&(o=o.slice(1)),0===u[0]&&128&u[1]&&(u=u.slice(1)),this.r=new n(o),this.s=new n(u),!(this.recoveryParam=null)},o.prototype.toDER=function(t){var e=this.r.toArray(),r=this.s.toArray();for(128&e[0]&&(e=[0].concat(e)),128&r[0]&&(r=[0].concat(r)),e=f(e),r=f(r);!(r[0]||128&r[1]);)r=r.slice(1);var n=[2];u(n,e.length),(n=n.concat(e)).push(2),u(n,r.length);var s=n.concat(r),o=[48];return u(o,s.length),o=o.concat(s),i.encode(o,t)}},function(t,e,r){"use strict";var n=r(11),i=r(2),s=i.utils,o=s.assert,a=s.parseBytes,c=r(114),f=r(115);function u(t){if(o("ed25519"===t,"only tested with ed25519 so far"),!(this instanceof u))return new u(t);t=i.curves[t].curve,this.curve=t,this.g=t.g,this.g.precompute(t.n.bitLength()+1),this.pointClass=t.point().constructor,this.encodingLength=Math.ceil(t.n.bitLength()/8),this.hash=n.sha512}(t.exports=u).prototype.sign=function(t,e){t=a(t);var r=this.keyFromSecret(e),n=this.hashInt(r.messagePrefix(),t),i=this.g.mul(n),s=this.encodePoint(i),o=this.hashInt(s,r.pubBytes(),t).mul(r.priv()),c=n.add(o).umod(this.curve.n);return this.makeSignature({R:i,S:c,Rencoded:s})},u.prototype.verify=function(t,e,r){t=a(t),e=this.makeSignature(e);var n=this.keyFromPublic(r),i=this.hashInt(e.Rencoded(),n.pubBytes(),t),s=this.g.mul(e.S());return e.R().add(n.pub().mul(i)).eq(s)},u.prototype.hashInt=function(){for(var t=this.hash(),e=0;e<arguments.length;e++)t.update(arguments[e]);return s.intFromLE(t.digest()).umod(this.curve.n)},u.prototype.keyFromPublic=function(t){return c.fromPublic(this,t)},u.prototype.keyFromSecret=function(t){return c.fromSecret(this,t)},u.prototype.makeSignature=function(t){return t instanceof f?t:new f(this,t)},u.prototype.encodePoint=function(t){var e=t.getY().toArray("le",this.encodingLength);return e[this.encodingLength-1]|=t.getX().isOdd()?128:0,e},u.prototype.decodePoint=function(t){var e=(t=s.parseBytes(t)).length-1,r=t.slice(0,e).concat(-129&t[e]),n=0!=(128&t[e]),i=s.intFromLE(r);return this.curve.pointFromY(i,n)},u.prototype.encodeInt=function(t){return t.toArray("le",this.encodingLength)},u.prototype.decodeInt=function(t){return s.intFromLE(t)},u.prototype.isPoint=function(t){return t instanceof this.pointClass}},function(t,e,r){"use strict";var n=r(2).utils,i=n.assert,s=n.parseBytes,o=n.cachedProperty;function a(t,e){this.eddsa=t,this._secret=s(e.secret),t.isPoint(e.pub)?this._pub=e.pub:this._pubBytes=s(e.pub)}a.fromPublic=function(t,e){return e instanceof a?e:new a(t,{pub:e})},a.fromSecret=function(t,e){return e instanceof a?e:new a(t,{secret:e})},a.prototype.secret=function(){return this._secret},o(a,"pubBytes",function(){return this.eddsa.encodePoint(this.pub())}),o(a,"pub",function(){return this._pubBytes?this.eddsa.decodePoint(this._pubBytes):this.eddsa.g.mul(this.priv())}),o(a,"privBytes",function(){var t=this.eddsa,e=this.hash(),r=t.encodingLength-1,n=e.slice(0,t.encodingLength);return n[0]&=248,n[r]&=127,n[r]|=64,n}),o(a,"priv",function(){return this.eddsa.decodeInt(this.privBytes())}),o(a,"hash",function(){return this.eddsa.hash().update(this.secret()).digest()}),o(a,"messagePrefix",function(){return this.hash().slice(this.eddsa.encodingLength)}),a.prototype.sign=function(t){return i(this._secret,"KeyPair can only verify"),this.eddsa.sign(t,this)},a.prototype.verify=function(t,e){return this.eddsa.verify(t,e,this)},a.prototype.getSecret=function(t){return i(this._secret,"KeyPair is public only"),n.encode(this.secret(),t)},a.prototype.getPublic=function(t){return n.encode(this.pubBytes(),t)},t.exports=a},function(t,e,r){"use strict";var n=r(4),i=r(2).utils,s=i.assert,o=i.cachedProperty,a=i.parseBytes;function c(t,e){this.eddsa=t,"object"!=typeof e&&(e=a(e)),Array.isArray(e)&&(e={R:e.slice(0,t.encodingLength),S:e.slice(t.encodingLength)}),s(e.R&&e.S,"Signature without R or S"),t.isPoint(e.R)&&(this._R=e.R),e.S instanceof n&&(this._S=e.S),this._Rencoded=Array.isArray(e.R)?e.R:e.Rencoded,this._Sencoded=Array.isArray(e.S)?e.S:e.Sencoded}o(c,"S",function(){return this.eddsa.decodeInt(this.Sencoded())}),o(c,"R",function(){return this.eddsa.decodePoint(this.Rencoded())}),o(c,"Rencoded",function(){return this.eddsa.encodePoint(this.R())}),o(c,"Sencoded",function(){return this.eddsa.encodeInt(this.S())}),c.prototype.toBytes=function(){return this.Rencoded().concat(this.Sencoded())},c.prototype.toHex=function(){return i.encode(this.toBytes(),"hex").toUpperCase()},t.exports=c},function(t,e,r){"use strict";var n=new(r(2).ec)("secp256k1"),i=r(117);t.exports={ScalarMultiple:function(t,e){for(var r=n.curve.n,s=0;s<=4294967295;s++){var o=(new i).add(t);void 0!==e&&o.addU32(e),o.addU32(s);var a=o.first256BN();if(0<a.cmpn(0)&&a.cmp(r)<0)return a}throw new Error("impossible space search)")}}},function(t,e,r){"use strict";var n=r(11),i=r(4);function s(){this.hash=n.sha512()}s.prototype.add=function(t){return this.hash.update(t),this},s.prototype.addU32=function(t){return this.add([t>>>24&255,t>>>16&255,t>>>8&255,255&t])},s.prototype.finish=function(){return this.hash.digest()},s.prototype.first256=function(){return this.finish().slice(0,32)},s.prototype.first256BN=function(){return new i(this.first256())},t.exports=s},function(t,e,r){var n={};function i(t,e){for(var r in t)e[r]=t[r]}(t.exports=n).from=r(119),n.to=r(120),n.is=r(122),n.subarray=r(123),n.join=r(124),n.copy=r(125),n.create=r(126),i(r(127),n),i(r(128),n)},function(t,e,r){t.exports=function(t,e){return Array.isArray(t)?new Uint8Array(t):i[e||"utf8"](t)};var n=r(29),i={hex:function(t){for(var e=t.length/2,r=new Uint8Array(e),n="",i=0,s=t.length;i<s;++i)n+=t.charAt(i),0<i&&i%2==1&&(r[i>>>1]=parseInt(n,16),n="");return r},utf8:function(t){for(var e,r=[],n=0,i=t.length;n<i;++n)!1!==(e=o(t,n))&&(e<128?r[r.length]=e:s(r,e));return new Uint8Array(r)},base64:function(t){return new Uint8Array(n.toByteArray(t))}};function s(t,e){for(var r,n,i,s=e,o=0;++o,s>>>=1;);for(n|=[0,0,192,224,240,248,252][r=0|Math.ceil((o-1)/5)],o=7-(i=[0,0,3,4,5,6,7][r])+6*(r-1);o;)n|=+!!(e&1<<o)<<7-i,++i%8==0&&(t[t.length]=n,n=128,i=2),--o;i&&(n|=+!!(1&e)<<7-i,t[t.length]=n)}function o(t,e){e=e||0;var r,n,i=t.charCodeAt(e);if(55296<=i&&i<=56319){if(r=t.charCodeAt(e+1),n=i,isNaN(r))throw new Error("High surrogate not followed by low surrogate");return 1024*(n-55296)+(r-56320)+65536}return!(56320<=i&&i<=57343)&&i}},function(t,e,r){t.exports=function(t,e){return s[e||"utf8"](t)};var n=r(29),i=r(121),s={hex:function(t){for(var e,r="",n=0,i=t.length;n<i;++n)r+=((240&(e=t[n]))>>>4).toString(16),r+=(15&e).toString(16);return r},utf8:function(t){return i(t)},base64:function(t){return n.fromByteArray(t)}}},function(t,e){t.exports=function(t,e,s){e=void 0===e?0:e,s=void 0===s?t.length:s;var f,u,h=0,d=0;for(n.length=r.length=0;h<t.length;)u=t[h],!d&&128&u?(d+=f=a(u),f<8&&(n[n.length]=u&o[6-f])):d?(n[n.length]=u&o[6],!--d&&n.length&&(r[r.length]=i(c(n)),n.length=0)):r[r.length]=i(u),++h;return n.length&&!d&&(r[r.length]=i(c(n)),n.length=0),r.join("")};var r=[],n=[],i=String.fromCharCode,s=[64,32,16,8,4,2,1],o=[0,1,3,7,15,31,63,127];function a(t){for(var e=0;e<7&&t&s[e];++e);return e}function c(t){for(var e=0,r=0,n=t.length;r<n;++r)e|=t[r]<<6*(n-r-1);return e}},function(t,e){t.exports=function(t){return t instanceof Uint8Array}},function(t,e){t.exports=function(t,e,r){return t.subarray(e||0,r||t.length)}},function(t,e){t.exports=function(t,e){if(!t.length)return new Uint8Array(0);for(var r=void 0!==e?e:function(t){for(var e=0,r=0,n=t.length;r<n;++r)e+=t[r].byteLength;return e}(t),n=new Uint8Array(r),i=t[0],s=i.length,o=0,a=0,c=0;c<r;)a!==s?n[c++]=i[a++]:(a=0,s=(i=t[++o])&&i.length);return n}},function(t,e){t.exports=function(t,e,n,i,s){if(n=arguments.length<3?0:n,i=arguments.length<4?0:i,(s=arguments.length<5?t.length:s)!==i&&0!==e.length&&0!==t.length)return s>t.length&&(s=t.length),e.length-n<s-i&&(s=e.length-n+i),t.buffer===e.buffer?function(t,e,n,i,s){for(var o=s+i,a=new Uint8Array(r.call(t,i,o)),c=0;i<o;++i,++c)e[n++]=a[c]}(t,e,n,i,s):function(t,e,r,n,i){for(var s=i-n+r,o=r,a=n;o<s;++o,++a)e[o]=t[a]}(t,e,n,i,s)};var r=[].slice},function(t,e){t.exports=function(t){return new Uint8Array(t)}},function(t,e,r){t.exports={readUInt8:function(t,e){return t[e]},readInt8:function(t,e){var r=t[e];return r<128?r:r-256},readUInt16LE:function(t,e){return n.get(t).getUint16(e+t.byteOffset,!0)},readUInt32LE:function(t,e){return n.get(t).getUint32(e+t.byteOffset,!0)},readInt16LE:function(t,e){return n.get(t).getInt16(e+t.byteOffset,!0)},readInt32LE:function(t,e){return n.get(t).getInt32(e+t.byteOffset,!0)},readFloatLE:function(t,e){return n.get(t).getFloat32(e+t.byteOffset,!0)},readDoubleLE:function(t,e){return n.get(t).getFloat64(e+t.byteOffset,!0)},readUInt16BE:function(t,e){return n.get(t).getUint16(e+t.byteOffset,!1)},readUInt32BE:function(t,e){return n.get(t).getUint32(e+t.byteOffset,!1)},readInt16BE:function(t,e){return n.get(t).getInt16(e+t.byteOffset,!1)},readInt32BE:function(t,e){return n.get(t).getInt32(e+t.byteOffset,!1)},readFloatBE:function(t,e){return n.get(t).getFloat32(e+t.byteOffset,!1)},readDoubleBE:function(t,e){return n.get(t).getFloat64(e+t.byteOffset,!1)}};var n=r(50)},function(t,e,r){t.exports={writeUInt8:function(t,e,r){return t[r]=e},writeInt8:function(t,e,r){return t[r]=e<0?e+256:e},writeUInt16LE:function(t,e,r){return n.get(t).setUint16(r+t.byteOffset,e,!0)},writeUInt32LE:function(t,e,r){return n.get(t).setUint32(r+t.byteOffset,e,!0)},writeInt16LE:function(t,e,r){return n.get(t).setInt16(r+t.byteOffset,e,!0)},writeInt32LE:function(t,e,r){return n.get(t).setInt32(r+t.byteOffset,e,!0)},writeFloatLE:function(t,e,r){return n.get(t).setFloat32(r+t.byteOffset,e,!0)},writeDoubleLE:function(t,e,r){return n.get(t).setFloat64(r+t.byteOffset,e,!0)},writeUInt16BE:function(t,e,r){return n.get(t).setUint16(r+t.byteOffset,e,!1)},writeUInt32BE:function(t,e,r){return n.get(t).setUint32(r+t.byteOffset,e,!1)},writeInt16BE:function(t,e,r){return n.get(t).setInt16(r+t.byteOffset,e,!1)},writeInt32BE:function(t,e,r){return n.get(t).setInt32(r+t.byteOffset,e,!1)},writeFloatBE:function(t,e,r){return n.get(t).setFloat32(r+t.byteOffset,e,!1)},writeDoubleBE:function(t,e,r){return n.get(t).setFloat64(r+t.byteOffset,e,!1)}};var n=r(50)},function(t,e,r){"use strict";t.exports=[{currency:"SWT",ACCOUNT_ALPHABET:"jpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65rkm8oFqi1tuvAxyz",SEED_PREFIX:33,ACCOUNT_PREFIX:0,ACCOUNT_ZERO:"jjjjjjjjjjjjjjjjjjjjjhoLvTp",ACCOUNT_ONE:"jjjjjjjjjjjjjjjjjjjjBZbvri",fee:10},{currency:"BWT",ACCOUNT_ALPHABET:"bpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2jcdeCg65rkm8oFqi1tuvAxyz",SEED_PREFIX:33,ACCOUNT_PREFIX:0,ACCOUNT_ZERO:"bbbbbbbbbbbbbbbbbbbbbhoLvTp",ACCOUNT_ONE:"bbbbbbbbbbbbbbbbbbbbBZjvri",fee:10}]},function(t,e){t.exports=function(t){for(var e={},r=t.length,n=t.charAt(0),i=0;i<t.length;i++)e[t.charAt(i)]=i;function s(t){if(0===t.length)return[];for(var i=[0],s=0;s<t.length;s++){var o=e[t[s]];if(void 0===o)return;for(var a=0,c=o;a<i.length;++a)c+=i[a]*r,i[a]=255&c,c>>=8;for(;0<c;)i.push(255&c),c>>=8}for(var f=0;t[f]===n&&f<t.length-1;++f)i.push(0);return i.reverse()}return{encode:function(e){if(0===e.length)return"";for(var n=[0],i=0;i<e.length;++i){for(var s=0,o=e[i];s<n.length;++s)o+=n[s]<<8,n[s]=o%r,o=o/r|0;for(;0<o;)n.push(o%r),o=o/r|0}for(var a="",c=0;0===e[c]&&c<e.length-1;++c)a+=t[0];for(var f=n.length-1;0<=f;--f)a+=t[n[f]];return a},decodeUnsafe:s,decode:function(t){var e=s(t);if(e)return e;throw new Error("Non-base"+r+" character")}}}}],t.c=r,t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:n})},t.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},t.t=function(e,r){if(1&r&&(e=t(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(t.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var i in e)t.d(n,i,function(t){return e[t]}.bind(null,i));return n},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},t.p="",t(t.s=51);function t(n){if(r[n])return r[n].exports;var i=r[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,t),i.l=!0,i.exports}var e,r});