github.com/ylsGit/go-ethereum@v1.6.5/internal/jsre/deps/web3.js (about)

     1  require=(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
     2  module.exports=[
     3    {
     4      "constant": true,
     5      "inputs": [
     6        {
     7          "name": "_owner",
     8          "type": "address"
     9        }
    10      ],
    11      "name": "name",
    12      "outputs": [
    13        {
    14          "name": "o_name",
    15          "type": "bytes32"
    16        }
    17      ],
    18      "type": "function"
    19    },
    20    {
    21      "constant": true,
    22      "inputs": [
    23        {
    24          "name": "_name",
    25          "type": "bytes32"
    26        }
    27      ],
    28      "name": "owner",
    29      "outputs": [
    30        {
    31          "name": "",
    32          "type": "address"
    33        }
    34      ],
    35      "type": "function"
    36    },
    37    {
    38      "constant": true,
    39      "inputs": [
    40        {
    41          "name": "_name",
    42          "type": "bytes32"
    43        }
    44      ],
    45      "name": "content",
    46      "outputs": [
    47        {
    48          "name": "",
    49          "type": "bytes32"
    50        }
    51      ],
    52      "type": "function"
    53    },
    54    {
    55      "constant": true,
    56      "inputs": [
    57        {
    58          "name": "_name",
    59          "type": "bytes32"
    60        }
    61      ],
    62      "name": "addr",
    63      "outputs": [
    64        {
    65          "name": "",
    66          "type": "address"
    67        }
    68      ],
    69      "type": "function"
    70    },
    71    {
    72      "constant": false,
    73      "inputs": [
    74        {
    75          "name": "_name",
    76          "type": "bytes32"
    77        }
    78      ],
    79      "name": "reserve",
    80      "outputs": [],
    81      "type": "function"
    82    },
    83    {
    84      "constant": true,
    85      "inputs": [
    86        {
    87          "name": "_name",
    88          "type": "bytes32"
    89        }
    90      ],
    91      "name": "subRegistrar",
    92      "outputs": [
    93        {
    94          "name": "",
    95          "type": "address"
    96        }
    97      ],
    98      "type": "function"
    99    },
   100    {
   101      "constant": false,
   102      "inputs": [
   103        {
   104          "name": "_name",
   105          "type": "bytes32"
   106        },
   107        {
   108          "name": "_newOwner",
   109          "type": "address"
   110        }
   111      ],
   112      "name": "transfer",
   113      "outputs": [],
   114      "type": "function"
   115    },
   116    {
   117      "constant": false,
   118      "inputs": [
   119        {
   120          "name": "_name",
   121          "type": "bytes32"
   122        },
   123        {
   124          "name": "_registrar",
   125          "type": "address"
   126        }
   127      ],
   128      "name": "setSubRegistrar",
   129      "outputs": [],
   130      "type": "function"
   131    },
   132    {
   133      "constant": false,
   134      "inputs": [],
   135      "name": "Registrar",
   136      "outputs": [],
   137      "type": "function"
   138    },
   139    {
   140      "constant": false,
   141      "inputs": [
   142        {
   143          "name": "_name",
   144          "type": "bytes32"
   145        },
   146        {
   147          "name": "_a",
   148          "type": "address"
   149        },
   150        {
   151          "name": "_primary",
   152          "type": "bool"
   153        }
   154      ],
   155      "name": "setAddress",
   156      "outputs": [],
   157      "type": "function"
   158    },
   159    {
   160      "constant": false,
   161      "inputs": [
   162        {
   163          "name": "_name",
   164          "type": "bytes32"
   165        },
   166        {
   167          "name": "_content",
   168          "type": "bytes32"
   169        }
   170      ],
   171      "name": "setContent",
   172      "outputs": [],
   173      "type": "function"
   174    },
   175    {
   176      "constant": false,
   177      "inputs": [
   178        {
   179          "name": "_name",
   180          "type": "bytes32"
   181        }
   182      ],
   183      "name": "disown",
   184      "outputs": [],
   185      "type": "function"
   186    },
   187    {
   188      "anonymous": false,
   189      "inputs": [
   190        {
   191          "indexed": true,
   192          "name": "_name",
   193          "type": "bytes32"
   194        },
   195        {
   196          "indexed": false,
   197          "name": "_winner",
   198          "type": "address"
   199        }
   200      ],
   201      "name": "AuctionEnded",
   202      "type": "event"
   203    },
   204    {
   205      "anonymous": false,
   206      "inputs": [
   207        {
   208          "indexed": true,
   209          "name": "_name",
   210          "type": "bytes32"
   211        },
   212        {
   213          "indexed": false,
   214          "name": "_bidder",
   215          "type": "address"
   216        },
   217        {
   218          "indexed": false,
   219          "name": "_value",
   220          "type": "uint256"
   221        }
   222      ],
   223      "name": "NewBid",
   224      "type": "event"
   225    },
   226    {
   227      "anonymous": false,
   228      "inputs": [
   229        {
   230          "indexed": true,
   231          "name": "name",
   232          "type": "bytes32"
   233        }
   234      ],
   235      "name": "Changed",
   236      "type": "event"
   237    },
   238    {
   239      "anonymous": false,
   240      "inputs": [
   241        {
   242          "indexed": true,
   243          "name": "name",
   244          "type": "bytes32"
   245        },
   246        {
   247          "indexed": true,
   248          "name": "addr",
   249          "type": "address"
   250        }
   251      ],
   252      "name": "PrimaryChanged",
   253      "type": "event"
   254    }
   255  ]
   256  
   257  },{}],2:[function(require,module,exports){
   258  module.exports=[
   259    {
   260      "constant": true,
   261      "inputs": [
   262        {
   263          "name": "_name",
   264          "type": "bytes32"
   265        }
   266      ],
   267      "name": "owner",
   268      "outputs": [
   269        {
   270          "name": "",
   271          "type": "address"
   272        }
   273      ],
   274      "type": "function"
   275    },
   276    {
   277      "constant": false,
   278      "inputs": [
   279        {
   280          "name": "_name",
   281          "type": "bytes32"
   282        },
   283        {
   284          "name": "_refund",
   285          "type": "address"
   286        }
   287      ],
   288      "name": "disown",
   289      "outputs": [],
   290      "type": "function"
   291    },
   292    {
   293      "constant": true,
   294      "inputs": [
   295        {
   296          "name": "_name",
   297          "type": "bytes32"
   298        }
   299      ],
   300      "name": "addr",
   301      "outputs": [
   302        {
   303          "name": "",
   304          "type": "address"
   305        }
   306      ],
   307      "type": "function"
   308    },
   309    {
   310      "constant": false,
   311      "inputs": [
   312        {
   313          "name": "_name",
   314          "type": "bytes32"
   315        }
   316      ],
   317      "name": "reserve",
   318      "outputs": [],
   319      "type": "function"
   320    },
   321    {
   322      "constant": false,
   323      "inputs": [
   324        {
   325          "name": "_name",
   326          "type": "bytes32"
   327        },
   328        {
   329          "name": "_newOwner",
   330          "type": "address"
   331        }
   332      ],
   333      "name": "transfer",
   334      "outputs": [],
   335      "type": "function"
   336    },
   337    {
   338      "constant": false,
   339      "inputs": [
   340        {
   341          "name": "_name",
   342          "type": "bytes32"
   343        },
   344        {
   345          "name": "_a",
   346          "type": "address"
   347        }
   348      ],
   349      "name": "setAddr",
   350      "outputs": [],
   351      "type": "function"
   352    },
   353    {
   354      "anonymous": false,
   355      "inputs": [
   356        {
   357          "indexed": true,
   358          "name": "name",
   359          "type": "bytes32"
   360        }
   361      ],
   362      "name": "Changed",
   363      "type": "event"
   364    }
   365  ]
   366  
   367  },{}],3:[function(require,module,exports){
   368  module.exports=[
   369    {
   370      "constant": false,
   371      "inputs": [
   372        {
   373          "name": "from",
   374          "type": "bytes32"
   375        },
   376        {
   377          "name": "to",
   378          "type": "address"
   379        },
   380        {
   381          "name": "value",
   382          "type": "uint256"
   383        }
   384      ],
   385      "name": "transfer",
   386      "outputs": [],
   387      "type": "function"
   388    },
   389    {
   390      "constant": false,
   391      "inputs": [
   392        {
   393          "name": "from",
   394          "type": "bytes32"
   395        },
   396        {
   397          "name": "to",
   398          "type": "address"
   399        },
   400        {
   401          "name": "indirectId",
   402          "type": "bytes32"
   403        },
   404        {
   405          "name": "value",
   406          "type": "uint256"
   407        }
   408      ],
   409      "name": "icapTransfer",
   410      "outputs": [],
   411      "type": "function"
   412    },
   413    {
   414      "constant": false,
   415      "inputs": [
   416        {
   417          "name": "to",
   418          "type": "bytes32"
   419        }
   420      ],
   421      "name": "deposit",
   422      "outputs": [],
   423      "payable": true,
   424      "type": "function"
   425    },
   426    {
   427      "anonymous": false,
   428      "inputs": [
   429        {
   430          "indexed": true,
   431          "name": "from",
   432          "type": "address"
   433        },
   434        {
   435          "indexed": false,
   436          "name": "value",
   437          "type": "uint256"
   438        }
   439      ],
   440      "name": "AnonymousDeposit",
   441      "type": "event"
   442    },
   443    {
   444      "anonymous": false,
   445      "inputs": [
   446        {
   447          "indexed": true,
   448          "name": "from",
   449          "type": "address"
   450        },
   451        {
   452          "indexed": true,
   453          "name": "to",
   454          "type": "bytes32"
   455        },
   456        {
   457          "indexed": false,
   458          "name": "value",
   459          "type": "uint256"
   460        }
   461      ],
   462      "name": "Deposit",
   463      "type": "event"
   464    },
   465    {
   466      "anonymous": false,
   467      "inputs": [
   468        {
   469          "indexed": true,
   470          "name": "from",
   471          "type": "bytes32"
   472        },
   473        {
   474          "indexed": true,
   475          "name": "to",
   476          "type": "address"
   477        },
   478        {
   479          "indexed": false,
   480          "name": "value",
   481          "type": "uint256"
   482        }
   483      ],
   484      "name": "Transfer",
   485      "type": "event"
   486    },
   487    {
   488      "anonymous": false,
   489      "inputs": [
   490        {
   491          "indexed": true,
   492          "name": "from",
   493          "type": "bytes32"
   494        },
   495        {
   496          "indexed": true,
   497          "name": "to",
   498          "type": "address"
   499        },
   500        {
   501          "indexed": false,
   502          "name": "indirectId",
   503          "type": "bytes32"
   504        },
   505        {
   506          "indexed": false,
   507          "name": "value",
   508          "type": "uint256"
   509        }
   510      ],
   511      "name": "IcapTransfer",
   512      "type": "event"
   513    }
   514  ]
   515  
   516  },{}],4:[function(require,module,exports){
   517  var f = require('./formatters');
   518  var SolidityType = require('./type');
   519  
   520  /**
   521   * SolidityTypeAddress is a prootype that represents address type
   522   * It matches:
   523   * address
   524   * address[]
   525   * address[4]
   526   * address[][]
   527   * address[3][]
   528   * address[][6][], ...
   529   */
   530  var SolidityTypeAddress = function () {
   531      this._inputFormatter = f.formatInputInt;
   532      this._outputFormatter = f.formatOutputAddress;
   533  };
   534  
   535  SolidityTypeAddress.prototype = new SolidityType({});
   536  SolidityTypeAddress.prototype.constructor = SolidityTypeAddress;
   537  
   538  SolidityTypeAddress.prototype.isType = function (name) {
   539      return !!name.match(/address(\[([0-9]*)\])?/);
   540  };
   541  
   542  module.exports = SolidityTypeAddress;
   543  
   544  },{"./formatters":9,"./type":14}],5:[function(require,module,exports){
   545  var f = require('./formatters');
   546  var SolidityType = require('./type');
   547  
   548  /**
   549   * SolidityTypeBool is a prootype that represents bool type
   550   * It matches:
   551   * bool
   552   * bool[]
   553   * bool[4]
   554   * bool[][]
   555   * bool[3][]
   556   * bool[][6][], ...
   557   */
   558  var SolidityTypeBool = function () {
   559      this._inputFormatter = f.formatInputBool;
   560      this._outputFormatter = f.formatOutputBool;
   561  };
   562  
   563  SolidityTypeBool.prototype = new SolidityType({});
   564  SolidityTypeBool.prototype.constructor = SolidityTypeBool;
   565  
   566  SolidityTypeBool.prototype.isType = function (name) {
   567      return !!name.match(/^bool(\[([0-9]*)\])*$/);
   568  };
   569  
   570  module.exports = SolidityTypeBool;
   571  
   572  },{"./formatters":9,"./type":14}],6:[function(require,module,exports){
   573  var f = require('./formatters');
   574  var SolidityType = require('./type');
   575  
   576  /**
   577   * SolidityTypeBytes is a prototype that represents the bytes type.
   578   * It matches:
   579   * bytes
   580   * bytes[]
   581   * bytes[4]
   582   * bytes[][]
   583   * bytes[3][]
   584   * bytes[][6][], ...
   585   * bytes32
   586   * bytes8[4]
   587   * bytes[3][]
   588   */
   589  var SolidityTypeBytes = function () {
   590      this._inputFormatter = f.formatInputBytes;
   591      this._outputFormatter = f.formatOutputBytes;
   592  };
   593  
   594  SolidityTypeBytes.prototype = new SolidityType({});
   595  SolidityTypeBytes.prototype.constructor = SolidityTypeBytes;
   596  
   597  SolidityTypeBytes.prototype.isType = function (name) {
   598      return !!name.match(/^bytes([0-9]{1,})(\[([0-9]*)\])*$/);
   599  };
   600  
   601  module.exports = SolidityTypeBytes;
   602  
   603  },{"./formatters":9,"./type":14}],7:[function(require,module,exports){
   604  /*
   605      This file is part of web3.js.
   606  
   607      web3.js is free software: you can redistribute it and/or modify
   608      it under the terms of the GNU Lesser General Public License as published by
   609      the Free Software Foundation, either version 3 of the License, or
   610      (at your option) any later version.
   611  
   612      web3.js is distributed in the hope that it will be useful,
   613      but WITHOUT ANY WARRANTY; without even the implied warranty of
   614      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   615      GNU Lesser General Public License for more details.
   616  
   617      You should have received a copy of the GNU Lesser General Public License
   618      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
   619  */
   620  /**
   621   * @file coder.js
   622   * @author Marek Kotewicz <marek@ethdev.com>
   623   * @date 2015
   624   */
   625  
   626  var f = require('./formatters');
   627  
   628  var SolidityTypeAddress = require('./address');
   629  var SolidityTypeBool = require('./bool');
   630  var SolidityTypeInt = require('./int');
   631  var SolidityTypeUInt = require('./uint');
   632  var SolidityTypeDynamicBytes = require('./dynamicbytes');
   633  var SolidityTypeString = require('./string');
   634  var SolidityTypeReal = require('./real');
   635  var SolidityTypeUReal = require('./ureal');
   636  var SolidityTypeBytes = require('./bytes');
   637  
   638  var isDynamic = function (solidityType, type) {
   639     return solidityType.isDynamicType(type) ||
   640            solidityType.isDynamicArray(type);
   641  };
   642  
   643  /**
   644   * SolidityCoder prototype should be used to encode/decode solidity params of any type
   645   */
   646  var SolidityCoder = function (types) {
   647      this._types = types;
   648  };
   649  
   650  /**
   651   * This method should be used to transform type to SolidityType
   652   *
   653   * @method _requireType
   654   * @param {String} type
   655   * @returns {SolidityType}
   656   * @throws {Error} throws if no matching type is found
   657   */
   658  SolidityCoder.prototype._requireType = function (type) {
   659      var solidityType = this._types.filter(function (t) {
   660          return t.isType(type);
   661      })[0];
   662  
   663      if (!solidityType) {
   664          throw Error('invalid solidity type!: ' + type);
   665      }
   666  
   667      return solidityType;
   668  };
   669  
   670  /**
   671   * Should be used to encode plain param
   672   *
   673   * @method encodeParam
   674   * @param {String} type
   675   * @param {Object} plain param
   676   * @return {String} encoded plain param
   677   */
   678  SolidityCoder.prototype.encodeParam = function (type, param) {
   679      return this.encodeParams([type], [param]);
   680  };
   681  
   682  /**
   683   * Should be used to encode list of params
   684   *
   685   * @method encodeParams
   686   * @param {Array} types
   687   * @param {Array} params
   688   * @return {String} encoded list of params
   689   */
   690  SolidityCoder.prototype.encodeParams = function (types, params) {
   691      var solidityTypes = this.getSolidityTypes(types);
   692  
   693      var encodeds = solidityTypes.map(function (solidityType, index) {
   694          return solidityType.encode(params[index], types[index]);
   695      });
   696  
   697      var dynamicOffset = solidityTypes.reduce(function (acc, solidityType, index) {
   698          var staticPartLength = solidityType.staticPartLength(types[index]);
   699          var roundedStaticPartLength = Math.floor((staticPartLength + 31) / 32) * 32;
   700  
   701          return acc + (isDynamic(solidityTypes[index], types[index]) ?
   702              32 :
   703              roundedStaticPartLength);
   704      }, 0);
   705  
   706      var result = this.encodeMultiWithOffset(types, solidityTypes, encodeds, dynamicOffset);
   707  
   708      return result;
   709  };
   710  
   711  SolidityCoder.prototype.encodeMultiWithOffset = function (types, solidityTypes, encodeds, dynamicOffset) {
   712      var result = "";
   713      var self = this;
   714  
   715      types.forEach(function (type, i) {
   716          if (isDynamic(solidityTypes[i], types[i])) {
   717              result += f.formatInputInt(dynamicOffset).encode();
   718              var e = self.encodeWithOffset(types[i], solidityTypes[i], encodeds[i], dynamicOffset);
   719              dynamicOffset += e.length / 2;
   720          } else {
   721              // don't add length to dynamicOffset. it's already counted
   722              result += self.encodeWithOffset(types[i], solidityTypes[i], encodeds[i], dynamicOffset);
   723          }
   724  
   725          // TODO: figure out nested arrays
   726      });
   727  
   728      types.forEach(function (type, i) {
   729          if (isDynamic(solidityTypes[i], types[i])) {
   730              var e = self.encodeWithOffset(types[i], solidityTypes[i], encodeds[i], dynamicOffset);
   731              dynamicOffset += e.length / 2;
   732              result += e;
   733          }
   734      });
   735      return result;
   736  };
   737  
   738  // TODO: refactor whole encoding!
   739  SolidityCoder.prototype.encodeWithOffset = function (type, solidityType, encoded, offset) {
   740      var self = this;
   741      if (solidityType.isDynamicArray(type)) {
   742          return (function () {
   743              // offset was already set
   744              var nestedName = solidityType.nestedName(type);
   745              var nestedStaticPartLength = solidityType.staticPartLength(nestedName);
   746              var result = encoded[0];
   747  
   748              (function () {
   749                  var previousLength = 2; // in int
   750                  if (solidityType.isDynamicArray(nestedName)) {
   751                      for (var i = 1; i < encoded.length; i++) {
   752                          previousLength += +(encoded[i - 1])[0] || 0;
   753                          result += f.formatInputInt(offset + i * nestedStaticPartLength + previousLength * 32).encode();
   754                      }
   755                  }
   756              })();
   757  
   758              // first element is length, skip it
   759              (function () {
   760                  for (var i = 0; i < encoded.length - 1; i++) {
   761                      var additionalOffset = result / 2;
   762                      result += self.encodeWithOffset(nestedName, solidityType, encoded[i + 1], offset +  additionalOffset);
   763                  }
   764              })();
   765  
   766              return result;
   767          })();
   768  
   769      } else if (solidityType.isStaticArray(type)) {
   770          return (function () {
   771              var nestedName = solidityType.nestedName(type);
   772              var nestedStaticPartLength = solidityType.staticPartLength(nestedName);
   773              var result = "";
   774  
   775  
   776              if (solidityType.isDynamicArray(nestedName)) {
   777                  (function () {
   778                      var previousLength = 0; // in int
   779                      for (var i = 0; i < encoded.length; i++) {
   780                          // calculate length of previous item
   781                          previousLength += +(encoded[i - 1] || [])[0] || 0;
   782                          result += f.formatInputInt(offset + i * nestedStaticPartLength + previousLength * 32).encode();
   783                      }
   784                  })();
   785              }
   786  
   787              (function () {
   788                  for (var i = 0; i < encoded.length; i++) {
   789                      var additionalOffset = result / 2;
   790                      result += self.encodeWithOffset(nestedName, solidityType, encoded[i], offset + additionalOffset);
   791                  }
   792              })();
   793  
   794              return result;
   795          })();
   796      }
   797  
   798      return encoded;
   799  };
   800  
   801  /**
   802   * Should be used to decode bytes to plain param
   803   *
   804   * @method decodeParam
   805   * @param {String} type
   806   * @param {String} bytes
   807   * @return {Object} plain param
   808   */
   809  SolidityCoder.prototype.decodeParam = function (type, bytes) {
   810      return this.decodeParams([type], bytes)[0];
   811  };
   812  
   813  /**
   814   * Should be used to decode list of params
   815   *
   816   * @method decodeParam
   817   * @param {Array} types
   818   * @param {String} bytes
   819   * @return {Array} array of plain params
   820   */
   821  SolidityCoder.prototype.decodeParams = function (types, bytes) {
   822      var solidityTypes = this.getSolidityTypes(types);
   823      var offsets = this.getOffsets(types, solidityTypes);
   824  
   825      return solidityTypes.map(function (solidityType, index) {
   826          return solidityType.decode(bytes, offsets[index],  types[index], index);
   827      });
   828  };
   829  
   830  SolidityCoder.prototype.getOffsets = function (types, solidityTypes) {
   831      var lengths =  solidityTypes.map(function (solidityType, index) {
   832          return solidityType.staticPartLength(types[index]);
   833      });
   834  
   835      for (var i = 1; i < lengths.length; i++) {
   836           // sum with length of previous element
   837          lengths[i] += lengths[i - 1];
   838      }
   839  
   840      return lengths.map(function (length, index) {
   841          // remove the current length, so the length is sum of previous elements
   842          var staticPartLength = solidityTypes[index].staticPartLength(types[index]);
   843          return length - staticPartLength;
   844      });
   845  };
   846  
   847  SolidityCoder.prototype.getSolidityTypes = function (types) {
   848      var self = this;
   849      return types.map(function (type) {
   850          return self._requireType(type);
   851      });
   852  };
   853  
   854  var coder = new SolidityCoder([
   855      new SolidityTypeAddress(),
   856      new SolidityTypeBool(),
   857      new SolidityTypeInt(),
   858      new SolidityTypeUInt(),
   859      new SolidityTypeDynamicBytes(),
   860      new SolidityTypeBytes(),
   861      new SolidityTypeString(),
   862      new SolidityTypeReal(),
   863      new SolidityTypeUReal()
   864  ]);
   865  
   866  module.exports = coder;
   867  
   868  },{"./address":4,"./bool":5,"./bytes":6,"./dynamicbytes":8,"./formatters":9,"./int":10,"./real":12,"./string":13,"./uint":15,"./ureal":16}],8:[function(require,module,exports){
   869  var f = require('./formatters');
   870  var SolidityType = require('./type');
   871  
   872  var SolidityTypeDynamicBytes = function () {
   873      this._inputFormatter = f.formatInputDynamicBytes;
   874      this._outputFormatter = f.formatOutputDynamicBytes;
   875  };
   876  
   877  SolidityTypeDynamicBytes.prototype = new SolidityType({});
   878  SolidityTypeDynamicBytes.prototype.constructor = SolidityTypeDynamicBytes;
   879  
   880  SolidityTypeDynamicBytes.prototype.isType = function (name) {
   881      return !!name.match(/^bytes(\[([0-9]*)\])*$/);
   882  };
   883  
   884  SolidityTypeDynamicBytes.prototype.isDynamicType = function () {
   885      return true;
   886  };
   887  
   888  module.exports = SolidityTypeDynamicBytes;
   889  
   890  },{"./formatters":9,"./type":14}],9:[function(require,module,exports){
   891  /*
   892      This file is part of web3.js.
   893  
   894      web3.js is free software: you can redistribute it and/or modify
   895      it under the terms of the GNU Lesser General Public License as published by
   896      the Free Software Foundation, either version 3 of the License, or
   897      (at your option) any later version.
   898  
   899      web3.js is distributed in the hope that it will be useful,
   900      but WITHOUT ANY WARRANTY; without even the implied warranty of
   901      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   902      GNU Lesser General Public License for more details.
   903  
   904      You should have received a copy of the GNU Lesser General Public License
   905      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
   906  */
   907  /**
   908   * @file formatters.js
   909   * @author Marek Kotewicz <marek@ethdev.com>
   910   * @date 2015
   911   */
   912  
   913  var BigNumber = require('bignumber.js');
   914  var utils = require('../utils/utils');
   915  var c = require('../utils/config');
   916  var SolidityParam = require('./param');
   917  
   918  
   919  /**
   920   * Formats input value to byte representation of int
   921   * If value is negative, return it's two's complement
   922   * If the value is floating point, round it down
   923   *
   924   * @method formatInputInt
   925   * @param {String|Number|BigNumber} value that needs to be formatted
   926   * @returns {SolidityParam}
   927   */
   928  var formatInputInt = function (value) {
   929      BigNumber.config(c.ETH_BIGNUMBER_ROUNDING_MODE);
   930      var result = utils.padLeft(utils.toTwosComplement(value).toString(16), 64);
   931      return new SolidityParam(result);
   932  };
   933  
   934  /**
   935   * Formats input bytes
   936   *
   937   * @method formatInputBytes
   938   * @param {String}
   939   * @returns {SolidityParam}
   940   */
   941  var formatInputBytes = function (value) {
   942      var result = utils.toHex(value).substr(2);
   943      var l = Math.floor((result.length + 63) / 64);
   944      result = utils.padRight(result, l * 64);
   945      return new SolidityParam(result);
   946  };
   947  
   948  /**
   949   * Formats input bytes
   950   *
   951   * @method formatDynamicInputBytes
   952   * @param {String}
   953   * @returns {SolidityParam}
   954   */
   955  var formatInputDynamicBytes = function (value) {
   956      var result = utils.toHex(value).substr(2);
   957      var length = result.length / 2;
   958      var l = Math.floor((result.length + 63) / 64);
   959      result = utils.padRight(result, l * 64);
   960      return new SolidityParam(formatInputInt(length).value + result);
   961  };
   962  
   963  /**
   964   * Formats input value to byte representation of string
   965   *
   966   * @method formatInputString
   967   * @param {String}
   968   * @returns {SolidityParam}
   969   */
   970  var formatInputString = function (value) {
   971      var result = utils.fromUtf8(value).substr(2);
   972      var length = result.length / 2;
   973      var l = Math.floor((result.length + 63) / 64);
   974      result = utils.padRight(result, l * 64);
   975      return new SolidityParam(formatInputInt(length).value + result);
   976  };
   977  
   978  /**
   979   * Formats input value to byte representation of bool
   980   *
   981   * @method formatInputBool
   982   * @param {Boolean}
   983   * @returns {SolidityParam}
   984   */
   985  var formatInputBool = function (value) {
   986      var result = '000000000000000000000000000000000000000000000000000000000000000' + (value ?  '1' : '0');
   987      return new SolidityParam(result);
   988  };
   989  
   990  /**
   991   * Formats input value to byte representation of real
   992   * Values are multiplied by 2^m and encoded as integers
   993   *
   994   * @method formatInputReal
   995   * @param {String|Number|BigNumber}
   996   * @returns {SolidityParam}
   997   */
   998  var formatInputReal = function (value) {
   999      return formatInputInt(new BigNumber(value).times(new BigNumber(2).pow(128)));
  1000  };
  1001  
  1002  /**
  1003   * Check if input value is negative
  1004   *
  1005   * @method signedIsNegative
  1006   * @param {String} value is hex format
  1007   * @returns {Boolean} true if it is negative, otherwise false
  1008   */
  1009  var signedIsNegative = function (value) {
  1010      return (new BigNumber(value.substr(0, 1), 16).toString(2).substr(0, 1)) === '1';
  1011  };
  1012  
  1013  /**
  1014   * Formats right-aligned output bytes to int
  1015   *
  1016   * @method formatOutputInt
  1017   * @param {SolidityParam} param
  1018   * @returns {BigNumber} right-aligned output bytes formatted to big number
  1019   */
  1020  var formatOutputInt = function (param) {
  1021      var value = param.staticPart() || "0";
  1022  
  1023      // check if it's negative number
  1024      // it it is, return two's complement
  1025      if (signedIsNegative(value)) {
  1026          return new BigNumber(value, 16).minus(new BigNumber('ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff', 16)).minus(1);
  1027      }
  1028      return new BigNumber(value, 16);
  1029  };
  1030  
  1031  /**
  1032   * Formats right-aligned output bytes to uint
  1033   *
  1034   * @method formatOutputUInt
  1035   * @param {SolidityParam}
  1036   * @returns {BigNumeber} right-aligned output bytes formatted to uint
  1037   */
  1038  var formatOutputUInt = function (param) {
  1039      var value = param.staticPart() || "0";
  1040      return new BigNumber(value, 16);
  1041  };
  1042  
  1043  /**
  1044   * Formats right-aligned output bytes to real
  1045   *
  1046   * @method formatOutputReal
  1047   * @param {SolidityParam}
  1048   * @returns {BigNumber} input bytes formatted to real
  1049   */
  1050  var formatOutputReal = function (param) {
  1051      return formatOutputInt(param).dividedBy(new BigNumber(2).pow(128));
  1052  };
  1053  
  1054  /**
  1055   * Formats right-aligned output bytes to ureal
  1056   *
  1057   * @method formatOutputUReal
  1058   * @param {SolidityParam}
  1059   * @returns {BigNumber} input bytes formatted to ureal
  1060   */
  1061  var formatOutputUReal = function (param) {
  1062      return formatOutputUInt(param).dividedBy(new BigNumber(2).pow(128));
  1063  };
  1064  
  1065  /**
  1066   * Should be used to format output bool
  1067   *
  1068   * @method formatOutputBool
  1069   * @param {SolidityParam}
  1070   * @returns {Boolean} right-aligned input bytes formatted to bool
  1071   */
  1072  var formatOutputBool = function (param) {
  1073      return param.staticPart() === '0000000000000000000000000000000000000000000000000000000000000001' ? true : false;
  1074  };
  1075  
  1076  /**
  1077   * Should be used to format output bytes
  1078   *
  1079   * @method formatOutputBytes
  1080   * @param {SolidityParam} left-aligned hex representation of string
  1081   * @param {String} name type name
  1082   * @returns {String} hex string
  1083   */
  1084  var formatOutputBytes = function (param, name) {
  1085      var matches = name.match(/^bytes([0-9]*)/);
  1086      var size = parseInt(matches[1]);
  1087      return '0x' + param.staticPart().slice(0, 2 * size);
  1088  };
  1089  
  1090  /**
  1091   * Should be used to format output bytes
  1092   *
  1093   * @method formatOutputDynamicBytes
  1094   * @param {SolidityParam} left-aligned hex representation of string
  1095   * @returns {String} hex string
  1096   */
  1097  var formatOutputDynamicBytes = function (param) {
  1098      var length = (new BigNumber(param.dynamicPart().slice(0, 64), 16)).toNumber() * 2;
  1099      return '0x' + param.dynamicPart().substr(64, length);
  1100  };
  1101  
  1102  /**
  1103   * Should be used to format output string
  1104   *
  1105   * @method formatOutputString
  1106   * @param {SolidityParam} left-aligned hex representation of string
  1107   * @returns {String} ascii string
  1108   */
  1109  var formatOutputString = function (param) {
  1110      var length = (new BigNumber(param.dynamicPart().slice(0, 64), 16)).toNumber() * 2;
  1111      return utils.toUtf8(param.dynamicPart().substr(64, length));
  1112  };
  1113  
  1114  /**
  1115   * Should be used to format output address
  1116   *
  1117   * @method formatOutputAddress
  1118   * @param {SolidityParam} right-aligned input bytes
  1119   * @returns {String} address
  1120   */
  1121  var formatOutputAddress = function (param) {
  1122      var value = param.staticPart();
  1123      return "0x" + value.slice(value.length - 40, value.length);
  1124  };
  1125  
  1126  module.exports = {
  1127      formatInputInt: formatInputInt,
  1128      formatInputBytes: formatInputBytes,
  1129      formatInputDynamicBytes: formatInputDynamicBytes,
  1130      formatInputString: formatInputString,
  1131      formatInputBool: formatInputBool,
  1132      formatInputReal: formatInputReal,
  1133      formatOutputInt: formatOutputInt,
  1134      formatOutputUInt: formatOutputUInt,
  1135      formatOutputReal: formatOutputReal,
  1136      formatOutputUReal: formatOutputUReal,
  1137      formatOutputBool: formatOutputBool,
  1138      formatOutputBytes: formatOutputBytes,
  1139      formatOutputDynamicBytes: formatOutputDynamicBytes,
  1140      formatOutputString: formatOutputString,
  1141      formatOutputAddress: formatOutputAddress
  1142  };
  1143  
  1144  },{"../utils/config":18,"../utils/utils":20,"./param":11,"bignumber.js":"bignumber.js"}],10:[function(require,module,exports){
  1145  var f = require('./formatters');
  1146  var SolidityType = require('./type');
  1147  
  1148  /**
  1149   * SolidityTypeInt is a prootype that represents int type
  1150   * It matches:
  1151   * int
  1152   * int[]
  1153   * int[4]
  1154   * int[][]
  1155   * int[3][]
  1156   * int[][6][], ...
  1157   * int32
  1158   * int64[]
  1159   * int8[4]
  1160   * int256[][]
  1161   * int[3][]
  1162   * int64[][6][], ...
  1163   */
  1164  var SolidityTypeInt = function () {
  1165      this._inputFormatter = f.formatInputInt;
  1166      this._outputFormatter = f.formatOutputInt;
  1167  };
  1168  
  1169  SolidityTypeInt.prototype = new SolidityType({});
  1170  SolidityTypeInt.prototype.constructor = SolidityTypeInt;
  1171  
  1172  SolidityTypeInt.prototype.isType = function (name) {
  1173      return !!name.match(/^int([0-9]*)?(\[([0-9]*)\])*$/);
  1174  };
  1175  
  1176  module.exports = SolidityTypeInt;
  1177  
  1178  },{"./formatters":9,"./type":14}],11:[function(require,module,exports){
  1179  /*
  1180      This file is part of web3.js.
  1181  
  1182      web3.js is free software: you can redistribute it and/or modify
  1183      it under the terms of the GNU Lesser General Public License as published by
  1184      the Free Software Foundation, either version 3 of the License, or
  1185      (at your option) any later version.
  1186  
  1187      web3.js is distributed in the hope that it will be useful,
  1188      but WITHOUT ANY WARRANTY; without even the implied warranty of
  1189      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  1190      GNU Lesser General Public License for more details.
  1191  
  1192      You should have received a copy of the GNU Lesser General Public License
  1193      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  1194  */
  1195  /** 
  1196   * @file param.js
  1197   * @author Marek Kotewicz <marek@ethdev.com>
  1198   * @date 2015
  1199   */
  1200  
  1201  var utils = require('../utils/utils');
  1202  
  1203  /**
  1204   * SolidityParam object prototype.
  1205   * Should be used when encoding, decoding solidity bytes
  1206   */
  1207  var SolidityParam = function (value, offset) {
  1208      this.value = value || '';
  1209      this.offset = offset; // offset in bytes
  1210  };
  1211  
  1212  /**
  1213   * This method should be used to get length of params's dynamic part
  1214   * 
  1215   * @method dynamicPartLength
  1216   * @returns {Number} length of dynamic part (in bytes)
  1217   */
  1218  SolidityParam.prototype.dynamicPartLength = function () {
  1219      return this.dynamicPart().length / 2;
  1220  };
  1221  
  1222  /**
  1223   * This method should be used to create copy of solidity param with different offset
  1224   *
  1225   * @method withOffset
  1226   * @param {Number} offset length in bytes
  1227   * @returns {SolidityParam} new solidity param with applied offset
  1228   */
  1229  SolidityParam.prototype.withOffset = function (offset) {
  1230      return new SolidityParam(this.value, offset);
  1231  };
  1232  
  1233  /**
  1234   * This method should be used to combine solidity params together
  1235   * eg. when appending an array
  1236   *
  1237   * @method combine
  1238   * @param {SolidityParam} param with which we should combine
  1239   * @param {SolidityParam} result of combination
  1240   */
  1241  SolidityParam.prototype.combine = function (param) {
  1242      return new SolidityParam(this.value + param.value); 
  1243  };
  1244  
  1245  /**
  1246   * This method should be called to check if param has dynamic size.
  1247   * If it has, it returns true, otherwise false
  1248   *
  1249   * @method isDynamic
  1250   * @returns {Boolean}
  1251   */
  1252  SolidityParam.prototype.isDynamic = function () {
  1253      return this.offset !== undefined;
  1254  };
  1255  
  1256  /**
  1257   * This method should be called to transform offset to bytes
  1258   *
  1259   * @method offsetAsBytes
  1260   * @returns {String} bytes representation of offset
  1261   */
  1262  SolidityParam.prototype.offsetAsBytes = function () {
  1263      return !this.isDynamic() ? '' : utils.padLeft(utils.toTwosComplement(this.offset).toString(16), 64);
  1264  };
  1265  
  1266  /**
  1267   * This method should be called to get static part of param
  1268   *
  1269   * @method staticPart
  1270   * @returns {String} offset if it is a dynamic param, otherwise value
  1271   */
  1272  SolidityParam.prototype.staticPart = function () {
  1273      if (!this.isDynamic()) {
  1274          return this.value; 
  1275      } 
  1276      return this.offsetAsBytes();
  1277  };
  1278  
  1279  /**
  1280   * This method should be called to get dynamic part of param
  1281   *
  1282   * @method dynamicPart
  1283   * @returns {String} returns a value if it is a dynamic param, otherwise empty string
  1284   */
  1285  SolidityParam.prototype.dynamicPart = function () {
  1286      return this.isDynamic() ? this.value : '';
  1287  };
  1288  
  1289  /**
  1290   * This method should be called to encode param
  1291   *
  1292   * @method encode
  1293   * @returns {String}
  1294   */
  1295  SolidityParam.prototype.encode = function () {
  1296      return this.staticPart() + this.dynamicPart();
  1297  };
  1298  
  1299  /**
  1300   * This method should be called to encode array of params
  1301   *
  1302   * @method encodeList
  1303   * @param {Array[SolidityParam]} params
  1304   * @returns {String}
  1305   */
  1306  SolidityParam.encodeList = function (params) {
  1307      
  1308      // updating offsets
  1309      var totalOffset = params.length * 32;
  1310      var offsetParams = params.map(function (param) {
  1311          if (!param.isDynamic()) {
  1312              return param;
  1313          }
  1314          var offset = totalOffset;
  1315          totalOffset += param.dynamicPartLength();
  1316          return param.withOffset(offset);
  1317      });
  1318  
  1319      // encode everything!
  1320      return offsetParams.reduce(function (result, param) {
  1321          return result + param.dynamicPart();
  1322      }, offsetParams.reduce(function (result, param) {
  1323          return result + param.staticPart();
  1324      }, ''));
  1325  };
  1326  
  1327  
  1328  
  1329  module.exports = SolidityParam;
  1330  
  1331  
  1332  },{"../utils/utils":20}],12:[function(require,module,exports){
  1333  var f = require('./formatters');
  1334  var SolidityType = require('./type');
  1335  
  1336  /**
  1337   * SolidityTypeReal is a prootype that represents real type
  1338   * It matches:
  1339   * real
  1340   * real[]
  1341   * real[4]
  1342   * real[][]
  1343   * real[3][]
  1344   * real[][6][], ...
  1345   * real32
  1346   * real64[]
  1347   * real8[4]
  1348   * real256[][]
  1349   * real[3][]
  1350   * real64[][6][], ...
  1351   */
  1352  var SolidityTypeReal = function () {
  1353      this._inputFormatter = f.formatInputReal;
  1354      this._outputFormatter = f.formatOutputReal;
  1355  };
  1356  
  1357  SolidityTypeReal.prototype = new SolidityType({});
  1358  SolidityTypeReal.prototype.constructor = SolidityTypeReal;
  1359  
  1360  SolidityTypeReal.prototype.isType = function (name) {
  1361      return !!name.match(/real([0-9]*)?(\[([0-9]*)\])?/);
  1362  };
  1363  
  1364  module.exports = SolidityTypeReal;
  1365  
  1366  },{"./formatters":9,"./type":14}],13:[function(require,module,exports){
  1367  var f = require('./formatters');
  1368  var SolidityType = require('./type');
  1369  
  1370  var SolidityTypeString = function () {
  1371      this._inputFormatter = f.formatInputString;
  1372      this._outputFormatter = f.formatOutputString;
  1373  };
  1374  
  1375  SolidityTypeString.prototype = new SolidityType({});
  1376  SolidityTypeString.prototype.constructor = SolidityTypeString;
  1377  
  1378  SolidityTypeString.prototype.isType = function (name) {
  1379      return !!name.match(/^string(\[([0-9]*)\])*$/);
  1380  };
  1381  
  1382  SolidityTypeString.prototype.isDynamicType = function () {
  1383      return true;
  1384  };
  1385  
  1386  module.exports = SolidityTypeString;
  1387  
  1388  },{"./formatters":9,"./type":14}],14:[function(require,module,exports){
  1389  var f = require('./formatters');
  1390  var SolidityParam = require('./param');
  1391  
  1392  /**
  1393   * SolidityType prototype is used to encode/decode solidity params of certain type
  1394   */
  1395  var SolidityType = function (config) {
  1396      this._inputFormatter = config.inputFormatter;
  1397      this._outputFormatter = config.outputFormatter;
  1398  };
  1399  
  1400  /**
  1401   * Should be used to determine if this SolidityType do match given name
  1402   *
  1403   * @method isType
  1404   * @param {String} name
  1405   * @return {Bool} true if type match this SolidityType, otherwise false
  1406   */
  1407  SolidityType.prototype.isType = function (name) {
  1408      throw "this method should be overrwritten for type " + name;
  1409  };
  1410  
  1411  /**
  1412   * Should be used to determine what is the length of static part in given type
  1413   *
  1414   * @method staticPartLength
  1415   * @param {String} name
  1416   * @return {Number} length of static part in bytes
  1417   */
  1418  SolidityType.prototype.staticPartLength = function (name) {
  1419      // If name isn't an array then treat it like a single element array.
  1420      return (this.nestedTypes(name) || ['[1]'])
  1421          .map(function (type) {
  1422              // the length of the nested array
  1423              return parseInt(type.slice(1, -1), 10) || 1;
  1424          })
  1425          .reduce(function (previous, current) {
  1426              return previous * current;
  1427          // all basic types are 32 bytes long
  1428          }, 32);
  1429  };
  1430  
  1431  /**
  1432   * Should be used to determine if type is dynamic array
  1433   * eg:
  1434   * "type[]" => true
  1435   * "type[4]" => false
  1436   *
  1437   * @method isDynamicArray
  1438   * @param {String} name
  1439   * @return {Bool} true if the type is dynamic array
  1440   */
  1441  SolidityType.prototype.isDynamicArray = function (name) {
  1442      var nestedTypes = this.nestedTypes(name);
  1443      return !!nestedTypes && !nestedTypes[nestedTypes.length - 1].match(/[0-9]{1,}/g);
  1444  };
  1445  
  1446  /**
  1447   * Should be used to determine if type is static array
  1448   * eg:
  1449   * "type[]" => false
  1450   * "type[4]" => true
  1451   *
  1452   * @method isStaticArray
  1453   * @param {String} name
  1454   * @return {Bool} true if the type is static array
  1455   */
  1456  SolidityType.prototype.isStaticArray = function (name) {
  1457      var nestedTypes = this.nestedTypes(name);
  1458      return !!nestedTypes && !!nestedTypes[nestedTypes.length - 1].match(/[0-9]{1,}/g);
  1459  };
  1460  
  1461  /**
  1462   * Should return length of static array
  1463   * eg.
  1464   * "int[32]" => 32
  1465   * "int256[14]" => 14
  1466   * "int[2][3]" => 3
  1467   * "int" => 1
  1468   * "int[1]" => 1
  1469   * "int[]" => 1
  1470   *
  1471   * @method staticArrayLength
  1472   * @param {String} name
  1473   * @return {Number} static array length
  1474   */
  1475  SolidityType.prototype.staticArrayLength = function (name) {
  1476      var nestedTypes = this.nestedTypes(name);
  1477      if (nestedTypes) {
  1478         return parseInt(nestedTypes[nestedTypes.length - 1].match(/[0-9]{1,}/g) || 1);
  1479      }
  1480      return 1;
  1481  };
  1482  
  1483  /**
  1484   * Should return nested type
  1485   * eg.
  1486   * "int[32]" => "int"
  1487   * "int256[14]" => "int256"
  1488   * "int[2][3]" => "int[2]"
  1489   * "int" => "int"
  1490   * "int[]" => "int"
  1491   *
  1492   * @method nestedName
  1493   * @param {String} name
  1494   * @return {String} nested name
  1495   */
  1496  SolidityType.prototype.nestedName = function (name) {
  1497      // remove last [] in name
  1498      var nestedTypes = this.nestedTypes(name);
  1499      if (!nestedTypes) {
  1500          return name;
  1501      }
  1502  
  1503      return name.substr(0, name.length - nestedTypes[nestedTypes.length - 1].length);
  1504  };
  1505  
  1506  /**
  1507   * Should return true if type has dynamic size by default
  1508   * such types are "string", "bytes"
  1509   *
  1510   * @method isDynamicType
  1511   * @param {String} name
  1512   * @return {Bool} true if is dynamic, otherwise false
  1513   */
  1514  SolidityType.prototype.isDynamicType = function () {
  1515      return false;
  1516  };
  1517  
  1518  /**
  1519   * Should return array of nested types
  1520   * eg.
  1521   * "int[2][3][]" => ["[2]", "[3]", "[]"]
  1522   * "int[] => ["[]"]
  1523   * "int" => null
  1524   *
  1525   * @method nestedTypes
  1526   * @param {String} name
  1527   * @return {Array} array of nested types
  1528   */
  1529  SolidityType.prototype.nestedTypes = function (name) {
  1530      // return list of strings eg. "[]", "[3]", "[]", "[2]"
  1531      return name.match(/(\[[0-9]*\])/g);
  1532  };
  1533  
  1534  /**
  1535   * Should be used to encode the value
  1536   *
  1537   * @method encode
  1538   * @param {Object} value
  1539   * @param {String} name
  1540   * @return {String} encoded value
  1541   */
  1542  SolidityType.prototype.encode = function (value, name) {
  1543      var self = this;
  1544      if (this.isDynamicArray(name)) {
  1545  
  1546          return (function () {
  1547              var length = value.length;                          // in int
  1548              var nestedName = self.nestedName(name);
  1549  
  1550              var result = [];
  1551              result.push(f.formatInputInt(length).encode());
  1552  
  1553              value.forEach(function (v) {
  1554                  result.push(self.encode(v, nestedName));
  1555              });
  1556  
  1557              return result;
  1558          })();
  1559  
  1560      } else if (this.isStaticArray(name)) {
  1561  
  1562          return (function () {
  1563              var length = self.staticArrayLength(name);          // in int
  1564              var nestedName = self.nestedName(name);
  1565  
  1566              var result = [];
  1567              for (var i = 0; i < length; i++) {
  1568                  result.push(self.encode(value[i], nestedName));
  1569              }
  1570  
  1571              return result;
  1572          })();
  1573  
  1574      }
  1575  
  1576      return this._inputFormatter(value, name).encode();
  1577  };
  1578  
  1579  /**
  1580   * Should be used to decode value from bytes
  1581   *
  1582   * @method decode
  1583   * @param {String} bytes
  1584   * @param {Number} offset in bytes
  1585   * @param {String} name type name
  1586   * @returns {Object} decoded value
  1587   */
  1588  SolidityType.prototype.decode = function (bytes, offset, name) {
  1589      var self = this;
  1590  
  1591      if (this.isDynamicArray(name)) {
  1592  
  1593          return (function () {
  1594              var arrayOffset = parseInt('0x' + bytes.substr(offset * 2, 64)); // in bytes
  1595              var length = parseInt('0x' + bytes.substr(arrayOffset * 2, 64)); // in int
  1596              var arrayStart = arrayOffset + 32; // array starts after length; // in bytes
  1597  
  1598              var nestedName = self.nestedName(name);
  1599              var nestedStaticPartLength = self.staticPartLength(nestedName);  // in bytes
  1600              var roundedNestedStaticPartLength = Math.floor((nestedStaticPartLength + 31) / 32) * 32;
  1601              var result = [];
  1602  
  1603              for (var i = 0; i < length * roundedNestedStaticPartLength; i += roundedNestedStaticPartLength) {
  1604                  result.push(self.decode(bytes, arrayStart + i, nestedName));
  1605              }
  1606  
  1607              return result;
  1608          })();
  1609  
  1610      } else if (this.isStaticArray(name)) {
  1611  
  1612          return (function () {
  1613              var length = self.staticArrayLength(name);                      // in int
  1614              var arrayStart = offset;                                        // in bytes
  1615  
  1616              var nestedName = self.nestedName(name);
  1617              var nestedStaticPartLength = self.staticPartLength(nestedName); // in bytes
  1618              var roundedNestedStaticPartLength = Math.floor((nestedStaticPartLength + 31) / 32) * 32;
  1619              var result = [];
  1620  
  1621              for (var i = 0; i < length * roundedNestedStaticPartLength; i += roundedNestedStaticPartLength) {
  1622                  result.push(self.decode(bytes, arrayStart + i, nestedName));
  1623              }
  1624  
  1625              return result;
  1626          })();
  1627      } else if (this.isDynamicType(name)) {
  1628  
  1629          return (function () {
  1630              var dynamicOffset = parseInt('0x' + bytes.substr(offset * 2, 64));      // in bytes
  1631              var length = parseInt('0x' + bytes.substr(dynamicOffset * 2, 64));      // in bytes
  1632              var roundedLength = Math.floor((length + 31) / 32);                     // in int
  1633              var param = new SolidityParam(bytes.substr(dynamicOffset * 2, ( 1 + roundedLength) * 64), 0);
  1634              return self._outputFormatter(param, name);
  1635          })();
  1636      }
  1637  
  1638      var length = this.staticPartLength(name);
  1639      var param = new SolidityParam(bytes.substr(offset * 2, length * 2));
  1640      return this._outputFormatter(param, name);
  1641  };
  1642  
  1643  module.exports = SolidityType;
  1644  
  1645  },{"./formatters":9,"./param":11}],15:[function(require,module,exports){
  1646  var f = require('./formatters');
  1647  var SolidityType = require('./type');
  1648  
  1649  /**
  1650   * SolidityTypeUInt is a prootype that represents uint type
  1651   * It matches:
  1652   * uint
  1653   * uint[]
  1654   * uint[4]
  1655   * uint[][]
  1656   * uint[3][]
  1657   * uint[][6][], ...
  1658   * uint32
  1659   * uint64[]
  1660   * uint8[4]
  1661   * uint256[][]
  1662   * uint[3][]
  1663   * uint64[][6][], ...
  1664   */
  1665  var SolidityTypeUInt = function () {
  1666      this._inputFormatter = f.formatInputInt;
  1667      this._outputFormatter = f.formatOutputUInt;
  1668  };
  1669  
  1670  SolidityTypeUInt.prototype = new SolidityType({});
  1671  SolidityTypeUInt.prototype.constructor = SolidityTypeUInt;
  1672  
  1673  SolidityTypeUInt.prototype.isType = function (name) {
  1674      return !!name.match(/^uint([0-9]*)?(\[([0-9]*)\])*$/);
  1675  };
  1676  
  1677  module.exports = SolidityTypeUInt;
  1678  
  1679  },{"./formatters":9,"./type":14}],16:[function(require,module,exports){
  1680  var f = require('./formatters');
  1681  var SolidityType = require('./type');
  1682  
  1683  /**
  1684   * SolidityTypeUReal is a prootype that represents ureal type
  1685   * It matches:
  1686   * ureal
  1687   * ureal[]
  1688   * ureal[4]
  1689   * ureal[][]
  1690   * ureal[3][]
  1691   * ureal[][6][], ...
  1692   * ureal32
  1693   * ureal64[]
  1694   * ureal8[4]
  1695   * ureal256[][]
  1696   * ureal[3][]
  1697   * ureal64[][6][], ...
  1698   */
  1699  var SolidityTypeUReal = function () {
  1700      this._inputFormatter = f.formatInputReal;
  1701      this._outputFormatter = f.formatOutputUReal;
  1702  };
  1703  
  1704  SolidityTypeUReal.prototype = new SolidityType({});
  1705  SolidityTypeUReal.prototype.constructor = SolidityTypeUReal;
  1706  
  1707  SolidityTypeUReal.prototype.isType = function (name) {
  1708      return !!name.match(/^ureal([0-9]*)?(\[([0-9]*)\])*$/);
  1709  };
  1710  
  1711  module.exports = SolidityTypeUReal;
  1712  
  1713  },{"./formatters":9,"./type":14}],17:[function(require,module,exports){
  1714  'use strict';
  1715  
  1716  // go env doesn't have and need XMLHttpRequest
  1717  if (typeof XMLHttpRequest === 'undefined') {
  1718      exports.XMLHttpRequest = {};
  1719  } else {
  1720      exports.XMLHttpRequest = XMLHttpRequest; // jshint ignore:line
  1721  }
  1722  
  1723  
  1724  },{}],18:[function(require,module,exports){
  1725  /*
  1726      This file is part of web3.js.
  1727  
  1728      web3.js is free software: you can redistribute it and/or modify
  1729      it under the terms of the GNU Lesser General Public License as published by
  1730      the Free Software Foundation, either version 3 of the License, or
  1731      (at your option) any later version.
  1732  
  1733      web3.js is distributed in the hope that it will be useful,
  1734      but WITHOUT ANY WARRANTY; without even the implied warranty of
  1735      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  1736      GNU Lesser General Public License for more details.
  1737  
  1738      You should have received a copy of the GNU Lesser General Public License
  1739      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  1740  */
  1741  /** @file config.js
  1742   * @authors:
  1743   *   Marek Kotewicz <marek@ethdev.com>
  1744   * @date 2015
  1745   */
  1746  
  1747  /**
  1748   * Utils
  1749   * 
  1750   * @module utils
  1751   */
  1752  
  1753  /**
  1754   * Utility functions
  1755   * 
  1756   * @class [utils] config
  1757   * @constructor
  1758   */
  1759  
  1760  
  1761  /// required to define ETH_BIGNUMBER_ROUNDING_MODE
  1762  var BigNumber = require('bignumber.js');
  1763  
  1764  var ETH_UNITS = [
  1765      'wei',
  1766      'kwei',
  1767      'Mwei',
  1768      'Gwei',
  1769      'szabo',
  1770      'finney',
  1771      'femtoether',
  1772      'picoether',
  1773      'nanoether',
  1774      'microether',
  1775      'milliether',
  1776      'nano',
  1777      'micro',
  1778      'milli',
  1779      'ether',
  1780      'grand',
  1781      'Mether',
  1782      'Gether',
  1783      'Tether',
  1784      'Pether',
  1785      'Eether',
  1786      'Zether',
  1787      'Yether',
  1788      'Nether',
  1789      'Dether',
  1790      'Vether',
  1791      'Uether'
  1792  ];
  1793  
  1794  module.exports = {
  1795      ETH_PADDING: 32,
  1796      ETH_SIGNATURE_LENGTH: 4,
  1797      ETH_UNITS: ETH_UNITS,
  1798      ETH_BIGNUMBER_ROUNDING_MODE: { ROUNDING_MODE: BigNumber.ROUND_DOWN },
  1799      ETH_POLLING_TIMEOUT: 1000/2,
  1800      defaultBlock: 'latest',
  1801      defaultAccount: undefined
  1802  };
  1803  
  1804  
  1805  },{"bignumber.js":"bignumber.js"}],19:[function(require,module,exports){
  1806  /*
  1807      This file is part of web3.js.
  1808  
  1809      web3.js is free software: you can redistribute it and/or modify
  1810      it under the terms of the GNU Lesser General Public License as published by
  1811      the Free Software Foundation, either version 3 of the License, or
  1812      (at your option) any later version.
  1813  
  1814      web3.js is distributed in the hope that it will be useful,
  1815      but WITHOUT ANY WARRANTY; without even the implied warranty of
  1816      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  1817      GNU Lesser General Public License for more details.
  1818  
  1819      You should have received a copy of the GNU Lesser General Public License
  1820      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  1821  */
  1822  /** 
  1823   * @file sha3.js
  1824   * @author Marek Kotewicz <marek@ethdev.com>
  1825   * @date 2015
  1826   */
  1827  
  1828  var CryptoJS = require('crypto-js');
  1829  var sha3 = require('crypto-js/sha3');
  1830  
  1831  module.exports = function (value, options) {
  1832      if (options && options.encoding === 'hex') {
  1833          if (value.length > 2 && value.substr(0, 2) === '0x') {
  1834              value = value.substr(2);
  1835          }
  1836          value = CryptoJS.enc.Hex.parse(value);
  1837      }
  1838  
  1839      return sha3(value, {
  1840          outputLength: 256
  1841      }).toString();
  1842  };
  1843  
  1844  
  1845  },{"crypto-js":59,"crypto-js/sha3":80}],20:[function(require,module,exports){
  1846  /*
  1847      This file is part of web3.js.
  1848  
  1849      web3.js is free software: you can redistribute it and/or modify
  1850      it under the terms of the GNU Lesser General Public License as published by
  1851      the Free Software Foundation, either version 3 of the License, or
  1852      (at your option) any later version.
  1853  
  1854      web3.js is distributed in the hope that it will be useful,
  1855      but WITHOUT ANY WARRANTY; without even the implied warranty of
  1856      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  1857      GNU Lesser General Public License for more details.
  1858  
  1859      You should have received a copy of the GNU Lesser General Public License
  1860      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  1861  */
  1862  /**
  1863   * @file utils.js
  1864   * @author Marek Kotewicz <marek@ethdev.com>
  1865   * @date 2015
  1866   */
  1867  
  1868  /**
  1869   * Utils
  1870   *
  1871   * @module utils
  1872   */
  1873  
  1874  /**
  1875   * Utility functions
  1876   *
  1877   * @class [utils] utils
  1878   * @constructor
  1879   */
  1880  
  1881  
  1882  var BigNumber = require('bignumber.js');
  1883  var sha3 = require('./sha3.js');
  1884  var utf8 = require('utf8');
  1885  
  1886  var unitMap = {
  1887      'noether':      '0',    
  1888      'wei':          '1',
  1889      'kwei':         '1000',
  1890      'Kwei':         '1000',
  1891      'babbage':      '1000',
  1892      'femtoether':   '1000',
  1893      'mwei':         '1000000',
  1894      'Mwei':         '1000000',
  1895      'lovelace':     '1000000',
  1896      'picoether':    '1000000',
  1897      'gwei':         '1000000000',
  1898      'Gwei':         '1000000000',
  1899      'shannon':      '1000000000',
  1900      'nanoether':    '1000000000',
  1901      'nano':         '1000000000',
  1902      'szabo':        '1000000000000',
  1903      'microether':   '1000000000000',
  1904      'micro':        '1000000000000',
  1905      'finney':       '1000000000000000',
  1906      'milliether':    '1000000000000000',
  1907      'milli':         '1000000000000000',
  1908      'ether':        '1000000000000000000',
  1909      'kether':       '1000000000000000000000',
  1910      'grand':        '1000000000000000000000',
  1911      'mether':       '1000000000000000000000000',
  1912      'gether':       '1000000000000000000000000000',
  1913      'tether':       '1000000000000000000000000000000'
  1914  };
  1915  
  1916  /**
  1917   * Should be called to pad string to expected length
  1918   *
  1919   * @method padLeft
  1920   * @param {String} string to be padded
  1921   * @param {Number} characters that result string should have
  1922   * @param {String} sign, by default 0
  1923   * @returns {String} right aligned string
  1924   */
  1925  var padLeft = function (string, chars, sign) {
  1926      return new Array(chars - string.length + 1).join(sign ? sign : "0") + string;
  1927  };
  1928  
  1929  /**
  1930   * Should be called to pad string to expected length
  1931   *
  1932   * @method padRight
  1933   * @param {String} string to be padded
  1934   * @param {Number} characters that result string should have
  1935   * @param {String} sign, by default 0
  1936   * @returns {String} right aligned string
  1937   */
  1938  var padRight = function (string, chars, sign) {
  1939      return string + (new Array(chars - string.length + 1).join(sign ? sign : "0"));
  1940  };
  1941  
  1942  /**
  1943   * Should be called to get utf8 from it's hex representation
  1944   *
  1945   * @method toUtf8
  1946   * @param {String} string in hex
  1947   * @returns {String} ascii string representation of hex value
  1948   */
  1949  var toUtf8 = function(hex) {
  1950  // Find termination
  1951      var str = "";
  1952      var i = 0, l = hex.length;
  1953      if (hex.substring(0, 2) === '0x') {
  1954          i = 2;
  1955      }
  1956      for (; i < l; i+=2) {
  1957          var code = parseInt(hex.substr(i, 2), 16);
  1958          if (code === 0)
  1959              break;
  1960          str += String.fromCharCode(code);
  1961      }
  1962  
  1963      return utf8.decode(str);
  1964  };
  1965  
  1966  /**
  1967   * Should be called to get ascii from it's hex representation
  1968   *
  1969   * @method toAscii
  1970   * @param {String} string in hex
  1971   * @returns {String} ascii string representation of hex value
  1972   */
  1973  var toAscii = function(hex) {
  1974  // Find termination
  1975      var str = "";
  1976      var i = 0, l = hex.length;
  1977      if (hex.substring(0, 2) === '0x') {
  1978          i = 2;
  1979      }
  1980      for (; i < l; i+=2) {
  1981          var code = parseInt(hex.substr(i, 2), 16);
  1982          str += String.fromCharCode(code);
  1983      }
  1984  
  1985      return str;
  1986  };
  1987  
  1988  /**
  1989   * Should be called to get hex representation (prefixed by 0x) of utf8 string
  1990   *
  1991   * @method fromUtf8
  1992   * @param {String} string
  1993   * @param {Number} optional padding
  1994   * @returns {String} hex representation of input string
  1995   */
  1996  var fromUtf8 = function(str) {
  1997      str = utf8.encode(str);
  1998      var hex = "";
  1999      for(var i = 0; i < str.length; i++) {
  2000          var code = str.charCodeAt(i);
  2001          if (code === 0)
  2002              break;
  2003          var n = code.toString(16);
  2004          hex += n.length < 2 ? '0' + n : n;
  2005      }
  2006  
  2007      return "0x" + hex;
  2008  };
  2009  
  2010  /**
  2011   * Should be called to get hex representation (prefixed by 0x) of ascii string
  2012   *
  2013   * @method fromAscii
  2014   * @param {String} string
  2015   * @param {Number} optional padding
  2016   * @returns {String} hex representation of input string
  2017   */
  2018  var fromAscii = function(str) {
  2019      var hex = "";
  2020      for(var i = 0; i < str.length; i++) {
  2021          var code = str.charCodeAt(i);
  2022          var n = code.toString(16);
  2023          hex += n.length < 2 ? '0' + n : n;
  2024      }
  2025  
  2026      return "0x" + hex;
  2027  };
  2028  
  2029  /**
  2030   * Should be used to create full function/event name from json abi
  2031   *
  2032   * @method transformToFullName
  2033   * @param {Object} json-abi
  2034   * @return {String} full fnction/event name
  2035   */
  2036  var transformToFullName = function (json) {
  2037      if (json.name.indexOf('(') !== -1) {
  2038          return json.name;
  2039      }
  2040  
  2041      var typeName = json.inputs.map(function(i){return i.type; }).join();
  2042      return json.name + '(' + typeName + ')';
  2043  };
  2044  
  2045  /**
  2046   * Should be called to get display name of contract function
  2047   *
  2048   * @method extractDisplayName
  2049   * @param {String} name of function/event
  2050   * @returns {String} display name for function/event eg. multiply(uint256) -> multiply
  2051   */
  2052  var extractDisplayName = function (name) {
  2053      var length = name.indexOf('(');
  2054      return length !== -1 ? name.substr(0, length) : name;
  2055  };
  2056  
  2057  /// @returns overloaded part of function/event name
  2058  var extractTypeName = function (name) {
  2059      /// TODO: make it invulnerable
  2060      var length = name.indexOf('(');
  2061      return length !== -1 ? name.substr(length + 1, name.length - 1 - (length + 1)).replace(' ', '') : "";
  2062  };
  2063  
  2064  /**
  2065   * Converts value to it's decimal representation in string
  2066   *
  2067   * @method toDecimal
  2068   * @param {String|Number|BigNumber}
  2069   * @return {String}
  2070   */
  2071  var toDecimal = function (value) {
  2072      return toBigNumber(value).toNumber();
  2073  };
  2074  
  2075  /**
  2076   * Converts value to it's hex representation
  2077   *
  2078   * @method fromDecimal
  2079   * @param {String|Number|BigNumber}
  2080   * @return {String}
  2081   */
  2082  var fromDecimal = function (value) {
  2083      var number = toBigNumber(value);
  2084      var result = number.toString(16);
  2085  
  2086      return number.lessThan(0) ? '-0x' + result.substr(1) : '0x' + result;
  2087  };
  2088  
  2089  /**
  2090   * Auto converts any given value into it's hex representation.
  2091   *
  2092   * And even stringifys objects before.
  2093   *
  2094   * @method toHex
  2095   * @param {String|Number|BigNumber|Object}
  2096   * @return {String}
  2097   */
  2098  var toHex = function (val) {
  2099      /*jshint maxcomplexity: 8 */
  2100  
  2101      if (isBoolean(val))
  2102          return fromDecimal(+val);
  2103  
  2104      if (isBigNumber(val))
  2105          return fromDecimal(val);
  2106  
  2107      if (isObject(val))
  2108          return fromUtf8(JSON.stringify(val));
  2109  
  2110      // if its a negative number, pass it through fromDecimal
  2111      if (isString(val)) {
  2112          if (val.indexOf('-0x') === 0)
  2113              return fromDecimal(val);
  2114          else if(val.indexOf('0x') === 0)
  2115              return val;
  2116          else if (!isFinite(val))
  2117              return fromAscii(val);
  2118      }
  2119  
  2120      return fromDecimal(val);
  2121  };
  2122  
  2123  /**
  2124   * Returns value of unit in Wei
  2125   *
  2126   * @method getValueOfUnit
  2127   * @param {String} unit the unit to convert to, default ether
  2128   * @returns {BigNumber} value of the unit (in Wei)
  2129   * @throws error if the unit is not correct:w
  2130   */
  2131  var getValueOfUnit = function (unit) {
  2132      unit = unit ? unit.toLowerCase() : 'ether';
  2133      var unitValue = unitMap[unit];
  2134      if (unitValue === undefined) {
  2135          throw new Error('This unit doesn\'t exists, please use the one of the following units' + JSON.stringify(unitMap, null, 2));
  2136      }
  2137      return new BigNumber(unitValue, 10);
  2138  };
  2139  
  2140  /**
  2141   * Takes a number of wei and converts it to any other ether unit.
  2142   *
  2143   * Possible units are:
  2144   *   SI Short   SI Full        Effigy       Other
  2145   * - kwei       femtoether     babbage
  2146   * - mwei       picoether      lovelace
  2147   * - gwei       nanoether      shannon      nano
  2148   * - --         microether     szabo        micro
  2149   * - --         milliether     finney       milli
  2150   * - ether      --             --
  2151   * - kether                    --           grand
  2152   * - mether
  2153   * - gether
  2154   * - tether
  2155   *
  2156   * @method fromWei
  2157   * @param {Number|String} number can be a number, number string or a HEX of a decimal
  2158   * @param {String} unit the unit to convert to, default ether
  2159   * @return {String|Object} When given a BigNumber object it returns one as well, otherwise a number
  2160  */
  2161  var fromWei = function(number, unit) {
  2162      var returnValue = toBigNumber(number).dividedBy(getValueOfUnit(unit));
  2163  
  2164      return isBigNumber(number) ? returnValue : returnValue.toString(10);
  2165  };
  2166  
  2167  /**
  2168   * Takes a number of a unit and converts it to wei.
  2169   *
  2170   * Possible units are:
  2171   *   SI Short   SI Full        Effigy       Other
  2172   * - kwei       femtoether     babbage
  2173   * - mwei       picoether      lovelace
  2174   * - gwei       nanoether      shannon      nano
  2175   * - --         microether     szabo        micro
  2176   * - --         microether     szabo        micro
  2177   * - --         milliether     finney       milli
  2178   * - ether      --             --
  2179   * - kether                    --           grand
  2180   * - mether
  2181   * - gether
  2182   * - tether
  2183   *
  2184   * @method toWei
  2185   * @param {Number|String|BigNumber} number can be a number, number string or a HEX of a decimal
  2186   * @param {String} unit the unit to convert from, default ether
  2187   * @return {String|Object} When given a BigNumber object it returns one as well, otherwise a number
  2188  */
  2189  var toWei = function(number, unit) {
  2190      var returnValue = toBigNumber(number).times(getValueOfUnit(unit));
  2191  
  2192      return isBigNumber(number) ? returnValue : returnValue.toString(10);
  2193  };
  2194  
  2195  /**
  2196   * Takes an input and transforms it into an bignumber
  2197   *
  2198   * @method toBigNumber
  2199   * @param {Number|String|BigNumber} a number, string, HEX string or BigNumber
  2200   * @return {BigNumber} BigNumber
  2201  */
  2202  var toBigNumber = function(number) {
  2203      /*jshint maxcomplexity:5 */
  2204      number = number || 0;
  2205      if (isBigNumber(number))
  2206          return number;
  2207  
  2208      if (isString(number) && (number.indexOf('0x') === 0 || number.indexOf('-0x') === 0)) {
  2209          return new BigNumber(number.replace('0x',''), 16);
  2210      }
  2211  
  2212      return new BigNumber(number.toString(10), 10);
  2213  };
  2214  
  2215  /**
  2216   * Takes and input transforms it into bignumber and if it is negative value, into two's complement
  2217   *
  2218   * @method toTwosComplement
  2219   * @param {Number|String|BigNumber}
  2220   * @return {BigNumber}
  2221   */
  2222  var toTwosComplement = function (number) {
  2223      var bigNumber = toBigNumber(number).round();
  2224      if (bigNumber.lessThan(0)) {
  2225          return new BigNumber("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", 16).plus(bigNumber).plus(1);
  2226      }
  2227      return bigNumber;
  2228  };
  2229  
  2230  /**
  2231   * Checks if the given string is strictly an address
  2232   *
  2233   * @method isStrictAddress
  2234   * @param {String} address the given HEX adress
  2235   * @return {Boolean}
  2236  */
  2237  var isStrictAddress = function (address) {
  2238      return /^0x[0-9a-f]{40}$/i.test(address);
  2239  };
  2240  
  2241  /**
  2242   * Checks if the given string is an address
  2243   *
  2244   * @method isAddress
  2245   * @param {String} address the given HEX adress
  2246   * @return {Boolean}
  2247  */
  2248  var isAddress = function (address) {
  2249      if (!/^(0x)?[0-9a-f]{40}$/i.test(address)) {
  2250          // check if it has the basic requirements of an address
  2251          return false;
  2252      } else if (/^(0x)?[0-9a-f]{40}$/.test(address) || /^(0x)?[0-9A-F]{40}$/.test(address)) {
  2253          // If it's all small caps or all all caps, return true
  2254          return true;
  2255      } else {
  2256          // Otherwise check each case
  2257          return isChecksumAddress(address);
  2258      }
  2259  };
  2260  
  2261  
  2262  
  2263  /**
  2264   * Checks if the given string is a checksummed address
  2265   *
  2266   * @method isChecksumAddress
  2267   * @param {String} address the given HEX adress
  2268   * @return {Boolean}
  2269  */
  2270  var isChecksumAddress = function (address) {    
  2271      // Check each case
  2272      address = address.replace('0x','');
  2273      var addressHash = sha3(address.toLowerCase());
  2274  
  2275      for (var i = 0; i < 40; i++ ) { 
  2276          // the nth letter should be uppercase if the nth digit of casemap is 1
  2277          if ((parseInt(addressHash[i], 16) > 7 && address[i].toUpperCase() !== address[i]) || (parseInt(addressHash[i], 16) <= 7 && address[i].toLowerCase() !== address[i])) {
  2278              return false;
  2279          }
  2280      }
  2281      return true;    
  2282  };
  2283  
  2284  
  2285  
  2286  /**
  2287   * Makes a checksum address
  2288   *
  2289   * @method toChecksumAddress
  2290   * @param {String} address the given HEX adress
  2291   * @return {String}
  2292  */
  2293  var toChecksumAddress = function (address) { 
  2294      if (typeof address === 'undefined') return '';
  2295  
  2296      address = address.toLowerCase().replace('0x','');
  2297      var addressHash = sha3(address);
  2298      var checksumAddress = '0x';
  2299  
  2300      for (var i = 0; i < address.length; i++ ) { 
  2301          // If ith character is 9 to f then make it uppercase 
  2302          if (parseInt(addressHash[i], 16) > 7) {
  2303            checksumAddress += address[i].toUpperCase();
  2304          } else {
  2305              checksumAddress += address[i];
  2306          }
  2307      }
  2308      return checksumAddress;
  2309  };
  2310  
  2311  /**
  2312   * Transforms given string to valid 20 bytes-length addres with 0x prefix
  2313   *
  2314   * @method toAddress
  2315   * @param {String} address
  2316   * @return {String} formatted address
  2317   */
  2318  var toAddress = function (address) {
  2319      if (isStrictAddress(address)) {
  2320          return address;
  2321      }
  2322  
  2323      if (/^[0-9a-f]{40}$/.test(address)) {
  2324          return '0x' + address;
  2325      }
  2326  
  2327      return '0x' + padLeft(toHex(address).substr(2), 40);
  2328  };
  2329  
  2330  /**
  2331   * Returns true if object is BigNumber, otherwise false
  2332   *
  2333   * @method isBigNumber
  2334   * @param {Object}
  2335   * @return {Boolean}
  2336   */
  2337  var isBigNumber = function (object) {
  2338      return object instanceof BigNumber ||
  2339          (object && object.constructor && object.constructor.name === 'BigNumber');
  2340  };
  2341  
  2342  /**
  2343   * Returns true if object is string, otherwise false
  2344   *
  2345   * @method isString
  2346   * @param {Object}
  2347   * @return {Boolean}
  2348   */
  2349  var isString = function (object) {
  2350      return typeof object === 'string' ||
  2351          (object && object.constructor && object.constructor.name === 'String');
  2352  };
  2353  
  2354  /**
  2355   * Returns true if object is function, otherwise false
  2356   *
  2357   * @method isFunction
  2358   * @param {Object}
  2359   * @return {Boolean}
  2360   */
  2361  var isFunction = function (object) {
  2362      return typeof object === 'function';
  2363  };
  2364  
  2365  /**
  2366   * Returns true if object is Objet, otherwise false
  2367   *
  2368   * @method isObject
  2369   * @param {Object}
  2370   * @return {Boolean}
  2371   */
  2372  var isObject = function (object) {
  2373      return typeof object === 'object';
  2374  };
  2375  
  2376  /**
  2377   * Returns true if object is boolean, otherwise false
  2378   *
  2379   * @method isBoolean
  2380   * @param {Object}
  2381   * @return {Boolean}
  2382   */
  2383  var isBoolean = function (object) {
  2384      return typeof object === 'boolean';
  2385  };
  2386  
  2387  /**
  2388   * Returns true if object is array, otherwise false
  2389   *
  2390   * @method isArray
  2391   * @param {Object}
  2392   * @return {Boolean}
  2393   */
  2394  var isArray = function (object) {
  2395      return object instanceof Array;
  2396  };
  2397  
  2398  /**
  2399   * Returns true if given string is valid json object
  2400   *
  2401   * @method isJson
  2402   * @param {String}
  2403   * @return {Boolean}
  2404   */
  2405  var isJson = function (str) {
  2406      try {
  2407          return !!JSON.parse(str);
  2408      } catch (e) {
  2409          return false;
  2410      }
  2411  };
  2412  
  2413  module.exports = {
  2414      padLeft: padLeft,
  2415      padRight: padRight,
  2416      toHex: toHex,
  2417      toDecimal: toDecimal,
  2418      fromDecimal: fromDecimal,
  2419      toUtf8: toUtf8,
  2420      toAscii: toAscii,
  2421      fromUtf8: fromUtf8,
  2422      fromAscii: fromAscii,
  2423      transformToFullName: transformToFullName,
  2424      extractDisplayName: extractDisplayName,
  2425      extractTypeName: extractTypeName,
  2426      toWei: toWei,
  2427      fromWei: fromWei,
  2428      toBigNumber: toBigNumber,
  2429      toTwosComplement: toTwosComplement,
  2430      toAddress: toAddress,
  2431      isBigNumber: isBigNumber,
  2432      isStrictAddress: isStrictAddress,
  2433      isAddress: isAddress,
  2434      isChecksumAddress: isChecksumAddress,
  2435      toChecksumAddress: toChecksumAddress,
  2436      isFunction: isFunction,
  2437      isString: isString,
  2438      isObject: isObject,
  2439      isBoolean: isBoolean,
  2440      isArray: isArray,
  2441      isJson: isJson
  2442  };
  2443  
  2444  },{"./sha3.js":19,"bignumber.js":"bignumber.js","utf8":85}],21:[function(require,module,exports){
  2445  module.exports={
  2446      "version": "0.18.1"
  2447  }
  2448  
  2449  },{}],22:[function(require,module,exports){
  2450  /*
  2451      This file is part of web3.js.
  2452  
  2453      web3.js is free software: you can redistribute it and/or modify
  2454      it under the terms of the GNU Lesser General Public License as published by
  2455      the Free Software Foundation, either version 3 of the License, or
  2456      (at your option) any later version.
  2457  
  2458      web3.js is distributed in the hope that it will be useful,
  2459      but WITHOUT ANY WARRANTY; without even the implied warranty of
  2460      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  2461      GNU Lesser General Public License for more details.
  2462  
  2463      You should have received a copy of the GNU Lesser General Public License
  2464      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  2465  */
  2466  /**
  2467   * @file web3.js
  2468   * @authors:
  2469   *   Jeffrey Wilcke <jeff@ethdev.com>
  2470   *   Marek Kotewicz <marek@ethdev.com>
  2471   *   Marian Oancea <marian@ethdev.com>
  2472   *   Fabian Vogelsteller <fabian@ethdev.com>
  2473   *   Gav Wood <g@ethdev.com>
  2474   * @date 2014
  2475   */
  2476  
  2477  var RequestManager = require('./web3/requestmanager');
  2478  var Iban = require('./web3/iban');
  2479  var Eth = require('./web3/methods/eth');
  2480  var DB = require('./web3/methods/db');
  2481  var Shh = require('./web3/methods/shh');
  2482  var Net = require('./web3/methods/net');
  2483  var Personal = require('./web3/methods/personal');
  2484  var Swarm = require('./web3/methods/swarm');
  2485  var Settings = require('./web3/settings');
  2486  var version = require('./version.json');
  2487  var utils = require('./utils/utils');
  2488  var sha3 = require('./utils/sha3');
  2489  var extend = require('./web3/extend');
  2490  var Batch = require('./web3/batch');
  2491  var Property = require('./web3/property');
  2492  var HttpProvider = require('./web3/httpprovider');
  2493  var IpcProvider = require('./web3/ipcprovider');
  2494  var BigNumber = require('bignumber.js');
  2495  
  2496  
  2497  
  2498  function Web3 (provider) {
  2499      this._requestManager = new RequestManager(provider);
  2500      this.currentProvider = provider;
  2501      this.eth = new Eth(this);
  2502      this.db = new DB(this);
  2503      this.shh = new Shh(this);
  2504      this.net = new Net(this);
  2505      this.personal = new Personal(this);
  2506      this.bzz = new Swarm(this);
  2507      this.settings = new Settings();
  2508      this.version = {
  2509          api: version.version
  2510      };
  2511      this.providers = {
  2512          HttpProvider: HttpProvider,
  2513          IpcProvider: IpcProvider
  2514      };
  2515      this._extend = extend(this);
  2516      this._extend({
  2517          properties: properties()
  2518      });
  2519  }
  2520  
  2521  // expose providers on the class
  2522  Web3.providers = {
  2523      HttpProvider: HttpProvider,
  2524      IpcProvider: IpcProvider
  2525  };
  2526  
  2527  Web3.prototype.setProvider = function (provider) {
  2528      this._requestManager.setProvider(provider);
  2529      this.currentProvider = provider;
  2530  };
  2531  
  2532  Web3.prototype.reset = function (keepIsSyncing) {
  2533      this._requestManager.reset(keepIsSyncing);
  2534      this.settings = new Settings();
  2535  };
  2536  
  2537  Web3.prototype.BigNumber = BigNumber;
  2538  Web3.prototype.toHex = utils.toHex;
  2539  Web3.prototype.toAscii = utils.toAscii;
  2540  Web3.prototype.toUtf8 = utils.toUtf8;
  2541  Web3.prototype.fromAscii = utils.fromAscii;
  2542  Web3.prototype.fromUtf8 = utils.fromUtf8;
  2543  Web3.prototype.toDecimal = utils.toDecimal;
  2544  Web3.prototype.fromDecimal = utils.fromDecimal;
  2545  Web3.prototype.toBigNumber = utils.toBigNumber;
  2546  Web3.prototype.toWei = utils.toWei;
  2547  Web3.prototype.fromWei = utils.fromWei;
  2548  Web3.prototype.isAddress = utils.isAddress;
  2549  Web3.prototype.isChecksumAddress = utils.isChecksumAddress;
  2550  Web3.prototype.toChecksumAddress = utils.toChecksumAddress;
  2551  Web3.prototype.isIBAN = utils.isIBAN;
  2552  
  2553  
  2554  Web3.prototype.sha3 = function(string, options) {
  2555      return '0x' + sha3(string, options);
  2556  };
  2557  
  2558  /**
  2559   * Transforms direct icap to address
  2560   */
  2561  Web3.prototype.fromICAP = function (icap) {
  2562      var iban = new Iban(icap);
  2563      return iban.address();
  2564  };
  2565  
  2566  var properties = function () {
  2567      return [
  2568          new Property({
  2569              name: 'version.node',
  2570              getter: 'web3_clientVersion'
  2571          }),
  2572          new Property({
  2573              name: 'version.network',
  2574              getter: 'net_version',
  2575              inputFormatter: utils.toDecimal
  2576          }),
  2577          new Property({
  2578              name: 'version.ethereum',
  2579              getter: 'eth_protocolVersion',
  2580              inputFormatter: utils.toDecimal
  2581          }),
  2582          new Property({
  2583              name: 'version.whisper',
  2584              getter: 'shh_version',
  2585              inputFormatter: utils.toDecimal
  2586          })
  2587      ];
  2588  };
  2589  
  2590  Web3.prototype.isConnected = function(){
  2591      return (this.currentProvider && this.currentProvider.isConnected());
  2592  };
  2593  
  2594  Web3.prototype.createBatch = function () {
  2595      return new Batch(this);
  2596  };
  2597  
  2598  module.exports = Web3;
  2599  
  2600  
  2601  },{"./utils/sha3":19,"./utils/utils":20,"./version.json":21,"./web3/batch":24,"./web3/extend":28,"./web3/httpprovider":32,"./web3/iban":33,"./web3/ipcprovider":34,"./web3/methods/db":37,"./web3/methods/eth":38,"./web3/methods/net":39,"./web3/methods/personal":40,"./web3/methods/shh":41,"./web3/methods/swarm":42,"./web3/property":45,"./web3/requestmanager":46,"./web3/settings":47,"bignumber.js":"bignumber.js"}],23:[function(require,module,exports){
  2602  /*
  2603      This file is part of web3.js.
  2604  
  2605      web3.js is free software: you can redistribute it and/or modify
  2606      it under the terms of the GNU Lesser General Public License as published by
  2607      the Free Software Foundation, either version 3 of the License, or
  2608      (at your option) any later version.
  2609  
  2610      web3.js is distributed in the hope that it will be useful,
  2611      but WITHOUT ANY WARRANTY; without even the implied warranty of
  2612      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  2613      GNU Lesser General Public License for more details.
  2614  
  2615      You should have received a copy of the GNU Lesser General Public License
  2616      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  2617  */
  2618  /** 
  2619   * @file allevents.js
  2620   * @author Marek Kotewicz <marek@ethdev.com>
  2621   * @date 2014
  2622   */
  2623  
  2624  var sha3 = require('../utils/sha3');
  2625  var SolidityEvent = require('./event');
  2626  var formatters = require('./formatters');
  2627  var utils = require('../utils/utils');
  2628  var Filter = require('./filter');
  2629  var watches = require('./methods/watches');
  2630  
  2631  var AllSolidityEvents = function (requestManager, json, address) {
  2632      this._requestManager = requestManager;
  2633      this._json = json;
  2634      this._address = address;
  2635  };
  2636  
  2637  AllSolidityEvents.prototype.encode = function (options) {
  2638      options = options || {};
  2639      var result = {};
  2640  
  2641      ['fromBlock', 'toBlock'].filter(function (f) {
  2642          return options[f] !== undefined;
  2643      }).forEach(function (f) {
  2644          result[f] = formatters.inputBlockNumberFormatter(options[f]);
  2645      });
  2646  
  2647      result.address = this._address;
  2648  
  2649      return result;
  2650  };
  2651  
  2652  AllSolidityEvents.prototype.decode = function (data) {
  2653      data.data = data.data || '';
  2654      data.topics = data.topics || [];
  2655  
  2656      var eventTopic = data.topics[0].slice(2);
  2657      var match = this._json.filter(function (j) {
  2658          return eventTopic === sha3(utils.transformToFullName(j));
  2659      })[0];
  2660  
  2661      if (!match) { // cannot find matching event?
  2662          console.warn('cannot find event for log');
  2663          return data;
  2664      }
  2665  
  2666      var event = new SolidityEvent(this._requestManager, match, this._address);
  2667      return event.decode(data);
  2668  };
  2669  
  2670  AllSolidityEvents.prototype.execute = function (options, callback) {
  2671  
  2672      if (utils.isFunction(arguments[arguments.length - 1])) {
  2673          callback = arguments[arguments.length - 1];
  2674          if(arguments.length === 1)
  2675              options = null;
  2676      }
  2677  
  2678      var o = this.encode(options);
  2679      var formatter = this.decode.bind(this);
  2680      return new Filter(this._requestManager, o, watches.eth(), formatter, callback);
  2681  };
  2682  
  2683  AllSolidityEvents.prototype.attachToContract = function (contract) {
  2684      var execute = this.execute.bind(this);
  2685      contract.allEvents = execute;
  2686  };
  2687  
  2688  module.exports = AllSolidityEvents;
  2689  
  2690  
  2691  },{"../utils/sha3":19,"../utils/utils":20,"./event":27,"./filter":29,"./formatters":30,"./methods/watches":43}],24:[function(require,module,exports){
  2692  /*
  2693      This file is part of web3.js.
  2694  
  2695      web3.js is free software: you can redistribute it and/or modify
  2696      it under the terms of the GNU Lesser General Public License as published by
  2697      the Free Software Foundation, either version 3 of the License, or
  2698      (at your option) any later version.
  2699  
  2700      web3.js is distributed in the hope that it will be useful,
  2701      but WITHOUT ANY WARRANTY; without even the implied warranty of
  2702      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  2703      GNU Lesser General Public License for more details.
  2704  
  2705      You should have received a copy of the GNU Lesser General Public License
  2706      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  2707  */
  2708  /** 
  2709   * @file batch.js
  2710   * @author Marek Kotewicz <marek@ethdev.com>
  2711   * @date 2015
  2712   */
  2713  
  2714  var Jsonrpc = require('./jsonrpc');
  2715  var errors = require('./errors');
  2716  
  2717  var Batch = function (web3) {
  2718      this.requestManager = web3._requestManager;
  2719      this.requests = [];
  2720  };
  2721  
  2722  /**
  2723   * Should be called to add create new request to batch request
  2724   *
  2725   * @method add
  2726   * @param {Object} jsonrpc requet object
  2727   */
  2728  Batch.prototype.add = function (request) {
  2729      this.requests.push(request);
  2730  };
  2731  
  2732  /**
  2733   * Should be called to execute batch request
  2734   *
  2735   * @method execute
  2736   */
  2737  Batch.prototype.execute = function () {
  2738      var requests = this.requests;
  2739      this.requestManager.sendBatch(requests, function (err, results) {
  2740          results = results || [];
  2741          requests.map(function (request, index) {
  2742              return results[index] || {};
  2743          }).forEach(function (result, index) {
  2744              if (requests[index].callback) {
  2745  
  2746                  if (!Jsonrpc.isValidResponse(result)) {
  2747                      return requests[index].callback(errors.InvalidResponse(result));
  2748                  }
  2749  
  2750                  requests[index].callback(null, (requests[index].format ? requests[index].format(result.result) : result.result));
  2751              }
  2752          });
  2753      }); 
  2754  };
  2755  
  2756  module.exports = Batch;
  2757  
  2758  
  2759  },{"./errors":26,"./jsonrpc":35}],25:[function(require,module,exports){
  2760  /*
  2761      This file is part of web3.js.
  2762  
  2763      web3.js is free software: you can redistribute it and/or modify
  2764      it under the terms of the GNU Lesser General Public License as published by
  2765      the Free Software Foundation, either version 3 of the License, or
  2766      (at your option) any later version.
  2767  
  2768      web3.js is distributed in the hope that it will be useful,
  2769      but WITHOUT ANY WARRANTY; without even the implied warranty of
  2770      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  2771      GNU Lesser General Public License for more details.
  2772  
  2773      You should have received a copy of the GNU Lesser General Public License
  2774      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  2775  */
  2776  /**
  2777   * @file contract.js
  2778   * @author Marek Kotewicz <marek@ethdev.com>
  2779   * @date 2014
  2780   */
  2781  
  2782  var utils = require('../utils/utils');
  2783  var coder = require('../solidity/coder');
  2784  var SolidityEvent = require('./event');
  2785  var SolidityFunction = require('./function');
  2786  var AllEvents = require('./allevents');
  2787  
  2788  /**
  2789   * Should be called to encode constructor params
  2790   *
  2791   * @method encodeConstructorParams
  2792   * @param {Array} abi
  2793   * @param {Array} constructor params
  2794   */
  2795  var encodeConstructorParams = function (abi, params) {
  2796      return abi.filter(function (json) {
  2797          return json.type === 'constructor' && json.inputs.length === params.length;
  2798      }).map(function (json) {
  2799          return json.inputs.map(function (input) {
  2800              return input.type;
  2801          });
  2802      }).map(function (types) {
  2803          return coder.encodeParams(types, params);
  2804      })[0] || '';
  2805  };
  2806  
  2807  /**
  2808   * Should be called to add functions to contract object
  2809   *
  2810   * @method addFunctionsToContract
  2811   * @param {Contract} contract
  2812   * @param {Array} abi
  2813   */
  2814  var addFunctionsToContract = function (contract) {
  2815      contract.abi.filter(function (json) {
  2816          return json.type === 'function';
  2817      }).map(function (json) {
  2818          return new SolidityFunction(contract._eth, json, contract.address);
  2819      }).forEach(function (f) {
  2820          f.attachToContract(contract);
  2821      });
  2822  };
  2823  
  2824  /**
  2825   * Should be called to add events to contract object
  2826   *
  2827   * @method addEventsToContract
  2828   * @param {Contract} contract
  2829   * @param {Array} abi
  2830   */
  2831  var addEventsToContract = function (contract) {
  2832      var events = contract.abi.filter(function (json) {
  2833          return json.type === 'event';
  2834      });
  2835  
  2836      var All = new AllEvents(contract._eth._requestManager, events, contract.address);
  2837      All.attachToContract(contract);
  2838  
  2839      events.map(function (json) {
  2840          return new SolidityEvent(contract._eth._requestManager, json, contract.address);
  2841      }).forEach(function (e) {
  2842          e.attachToContract(contract);
  2843      });
  2844  };
  2845  
  2846  
  2847  /**
  2848   * Should be called to check if the contract gets properly deployed on the blockchain.
  2849   *
  2850   * @method checkForContractAddress
  2851   * @param {Object} contract
  2852   * @param {Function} callback
  2853   * @returns {Undefined}
  2854   */
  2855  var checkForContractAddress = function(contract, callback){
  2856      var count = 0,
  2857          callbackFired = false;
  2858  
  2859      // wait for receipt
  2860      var filter = contract._eth.filter('latest', function(e){
  2861          if (!e && !callbackFired) {
  2862              count++;
  2863  
  2864              // stop watching after 50 blocks (timeout)
  2865              if (count > 50) {
  2866  
  2867                  filter.stopWatching(function() {});
  2868                  callbackFired = true;
  2869  
  2870                  if (callback)
  2871                      callback(new Error('Contract transaction couldn\'t be found after 50 blocks'));
  2872                  else
  2873                      throw new Error('Contract transaction couldn\'t be found after 50 blocks');
  2874  
  2875  
  2876              } else {
  2877  
  2878                  contract._eth.getTransactionReceipt(contract.transactionHash, function(e, receipt){
  2879                      if(receipt && !callbackFired) {
  2880  
  2881                          contract._eth.getCode(receipt.contractAddress, function(e, code){
  2882                              /*jshint maxcomplexity: 6 */
  2883  
  2884                              if(callbackFired || !code)
  2885                                  return;
  2886  
  2887                              filter.stopWatching(function() {});
  2888                              callbackFired = true;
  2889  
  2890                              if(code.length > 3) {
  2891  
  2892                                  // console.log('Contract code deployed!');
  2893  
  2894                                  contract.address = receipt.contractAddress;
  2895  
  2896                                  // attach events and methods again after we have
  2897                                  addFunctionsToContract(contract);
  2898                                  addEventsToContract(contract);
  2899  
  2900                                  // call callback for the second time
  2901                                  if(callback)
  2902                                      callback(null, contract);
  2903  
  2904                              } else {
  2905                                  if(callback)
  2906                                      callback(new Error('The contract code couldn\'t be stored, please check your gas amount.'));
  2907                                  else
  2908                                      throw new Error('The contract code couldn\'t be stored, please check your gas amount.');
  2909                              }
  2910                          });
  2911                      }
  2912                  });
  2913              }
  2914          }
  2915      });
  2916  };
  2917  
  2918  /**
  2919   * Should be called to create new ContractFactory instance
  2920   *
  2921   * @method ContractFactory
  2922   * @param {Array} abi
  2923   */
  2924  var ContractFactory = function (eth, abi) {
  2925      this.eth = eth;
  2926      this.abi = abi;
  2927  
  2928      /**
  2929       * Should be called to create new contract on a blockchain
  2930       *
  2931       * @method new
  2932       * @param {Any} contract constructor param1 (optional)
  2933       * @param {Any} contract constructor param2 (optional)
  2934       * @param {Object} contract transaction object (required)
  2935       * @param {Function} callback
  2936       * @returns {Contract} returns contract instance
  2937       */
  2938      this.new = function () {
  2939          var contract = new Contract(this.eth, this.abi);
  2940  
  2941          // parse arguments
  2942          var options = {}; // required!
  2943          var callback;
  2944  
  2945          var args = Array.prototype.slice.call(arguments);
  2946          if (utils.isFunction(args[args.length - 1])) {
  2947              callback = args.pop();
  2948          }
  2949  
  2950          var last = args[args.length - 1];
  2951          if (utils.isObject(last) && !utils.isArray(last)) {
  2952              options = args.pop();
  2953          }
  2954  
  2955          if (options.value > 0) {
  2956              var constructorAbi = abi.filter(function (json) {
  2957                  return json.type === 'constructor' && json.inputs.length === args.length;
  2958              })[0] || {};
  2959  
  2960              if (!constructorAbi.payable) {
  2961                  throw new Error('Cannot send value to non-payable constructor');
  2962              }
  2963          }
  2964  
  2965          var bytes = encodeConstructorParams(this.abi, args);
  2966          options.data += bytes;
  2967  
  2968          if (callback) {
  2969  
  2970              // wait for the contract address adn check if the code was deployed
  2971              this.eth.sendTransaction(options, function (err, hash) {
  2972                  if (err) {
  2973                      callback(err);
  2974                  } else {
  2975                      // add the transaction hash
  2976                      contract.transactionHash = hash;
  2977  
  2978                      // call callback for the first time
  2979                      callback(null, contract);
  2980  
  2981                      checkForContractAddress(contract, callback);
  2982                  }
  2983              });
  2984          } else {
  2985              var hash = this.eth.sendTransaction(options);
  2986              // add the transaction hash
  2987              contract.transactionHash = hash;
  2988              checkForContractAddress(contract);
  2989          }
  2990  
  2991          return contract;
  2992      };
  2993  
  2994      this.new.getData = this.getData.bind(this);
  2995  };
  2996  
  2997  /**
  2998   * Should be called to create new ContractFactory
  2999   *
  3000   * @method contract
  3001   * @param {Array} abi
  3002   * @returns {ContractFactory} new contract factory
  3003   */
  3004  //var contract = function (abi) {
  3005      //return new ContractFactory(abi);
  3006  //};
  3007  
  3008  
  3009  
  3010  /**
  3011   * Should be called to get access to existing contract on a blockchain
  3012   *
  3013   * @method at
  3014   * @param {Address} contract address (required)
  3015   * @param {Function} callback {optional)
  3016   * @returns {Contract} returns contract if no callback was passed,
  3017   * otherwise calls callback function (err, contract)
  3018   */
  3019  ContractFactory.prototype.at = function (address, callback) {
  3020      var contract = new Contract(this.eth, this.abi, address);
  3021  
  3022      // this functions are not part of prototype,
  3023      // because we dont want to spoil the interface
  3024      addFunctionsToContract(contract);
  3025      addEventsToContract(contract);
  3026  
  3027      if (callback) {
  3028          callback(null, contract);
  3029      }
  3030      return contract;
  3031  };
  3032  
  3033  /**
  3034   * Gets the data, which is data to deploy plus constructor params
  3035   *
  3036   * @method getData
  3037   */
  3038  ContractFactory.prototype.getData = function () {
  3039      var options = {}; // required!
  3040      var args = Array.prototype.slice.call(arguments);
  3041  
  3042      var last = args[args.length - 1];
  3043      if (utils.isObject(last) && !utils.isArray(last)) {
  3044          options = args.pop();
  3045      }
  3046  
  3047      var bytes = encodeConstructorParams(this.abi, args);
  3048      options.data += bytes;
  3049  
  3050      return options.data;
  3051  };
  3052  
  3053  /**
  3054   * Should be called to create new contract instance
  3055   *
  3056   * @method Contract
  3057   * @param {Array} abi
  3058   * @param {Address} contract address
  3059   */
  3060  var Contract = function (eth, abi, address) {
  3061      this._eth = eth;
  3062      this.transactionHash = null;
  3063      this.address = address;
  3064      this.abi = abi;
  3065  };
  3066  
  3067  module.exports = ContractFactory;
  3068  
  3069  },{"../solidity/coder":7,"../utils/utils":20,"./allevents":23,"./event":27,"./function":31}],26:[function(require,module,exports){
  3070  /*
  3071      This file is part of web3.js.
  3072  
  3073      web3.js is free software: you can redistribute it and/or modify
  3074      it under the terms of the GNU Lesser General Public License as published by
  3075      the Free Software Foundation, either version 3 of the License, or
  3076      (at your option) any later version.
  3077  
  3078      web3.js is distributed in the hope that it will be useful,
  3079      but WITHOUT ANY WARRANTY; without even the implied warranty of
  3080      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  3081      GNU Lesser General Public License for more details.
  3082  
  3083      You should have received a copy of the GNU Lesser General Public License
  3084      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  3085  */
  3086  /** 
  3087   * @file errors.js
  3088   * @author Marek Kotewicz <marek@ethdev.com>
  3089   * @date 2015
  3090   */
  3091  
  3092  module.exports = {
  3093      InvalidNumberOfParams: function () {
  3094          return new Error('Invalid number of input parameters');
  3095      },
  3096      InvalidConnection: function (host){
  3097          return new Error('CONNECTION ERROR: Couldn\'t connect to node '+ host +'.');
  3098      },
  3099      InvalidProvider: function () {
  3100          return new Error('Provider not set or invalid');
  3101      },
  3102      InvalidResponse: function (result){
  3103          var message = !!result && !!result.error && !!result.error.message ? result.error.message : 'Invalid JSON RPC response: ' + JSON.stringify(result);
  3104          return new Error(message);
  3105      },
  3106      ConnectionTimeout: function (ms){
  3107          return new Error('CONNECTION TIMEOUT: timeout of ' + ms + ' ms achived');
  3108      }
  3109  };
  3110  
  3111  },{}],27:[function(require,module,exports){
  3112  /*
  3113      This file is part of web3.js.
  3114  
  3115      web3.js is free software: you can redistribute it and/or modify
  3116      it under the terms of the GNU Lesser General Public License as published by
  3117      the Free Software Foundation, either version 3 of the License, or
  3118      (at your option) any later version.
  3119  
  3120      web3.js is distributed in the hope that it will be useful,
  3121      but WITHOUT ANY WARRANTY; without even the implied warranty of
  3122      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  3123      GNU Lesser General Public License for more details.
  3124  
  3125      You should have received a copy of the GNU Lesser General Public License
  3126      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  3127  */
  3128  /** 
  3129   * @file event.js
  3130   * @author Marek Kotewicz <marek@ethdev.com>
  3131   * @date 2014
  3132   */
  3133  
  3134  var utils = require('../utils/utils');
  3135  var coder = require('../solidity/coder');
  3136  var formatters = require('./formatters');
  3137  var sha3 = require('../utils/sha3');
  3138  var Filter = require('./filter');
  3139  var watches = require('./methods/watches');
  3140  
  3141  /**
  3142   * This prototype should be used to create event filters
  3143   */
  3144  var SolidityEvent = function (requestManager, json, address) {
  3145      this._requestManager = requestManager;
  3146      this._params = json.inputs;
  3147      this._name = utils.transformToFullName(json);
  3148      this._address = address;
  3149      this._anonymous = json.anonymous;
  3150  };
  3151  
  3152  /**
  3153   * Should be used to get filtered param types
  3154   *
  3155   * @method types
  3156   * @param {Bool} decide if returned typed should be indexed
  3157   * @return {Array} array of types
  3158   */
  3159  SolidityEvent.prototype.types = function (indexed) {
  3160      return this._params.filter(function (i) {
  3161          return i.indexed === indexed;
  3162      }).map(function (i) {
  3163          return i.type;
  3164      });
  3165  };
  3166  
  3167  /**
  3168   * Should be used to get event display name
  3169   *
  3170   * @method displayName
  3171   * @return {String} event display name
  3172   */
  3173  SolidityEvent.prototype.displayName = function () {
  3174      return utils.extractDisplayName(this._name);
  3175  };
  3176  
  3177  /**
  3178   * Should be used to get event type name
  3179   *
  3180   * @method typeName
  3181   * @return {String} event type name
  3182   */
  3183  SolidityEvent.prototype.typeName = function () {
  3184      return utils.extractTypeName(this._name);
  3185  };
  3186  
  3187  /**
  3188   * Should be used to get event signature
  3189   *
  3190   * @method signature
  3191   * @return {String} event signature
  3192   */
  3193  SolidityEvent.prototype.signature = function () {
  3194      return sha3(this._name);
  3195  };
  3196  
  3197  /**
  3198   * Should be used to encode indexed params and options to one final object
  3199   * 
  3200   * @method encode
  3201   * @param {Object} indexed
  3202   * @param {Object} options
  3203   * @return {Object} everything combined together and encoded
  3204   */
  3205  SolidityEvent.prototype.encode = function (indexed, options) {
  3206      indexed = indexed || {};
  3207      options = options || {};
  3208      var result = {};
  3209  
  3210      ['fromBlock', 'toBlock'].filter(function (f) {
  3211          return options[f] !== undefined;
  3212      }).forEach(function (f) {
  3213          result[f] = formatters.inputBlockNumberFormatter(options[f]);
  3214      });
  3215  
  3216      result.topics = [];
  3217  
  3218      result.address = this._address;
  3219      if (!this._anonymous) {
  3220          result.topics.push('0x' + this.signature());
  3221      }
  3222  
  3223      var indexedTopics = this._params.filter(function (i) {
  3224          return i.indexed === true;
  3225      }).map(function (i) {
  3226          var value = indexed[i.name];
  3227          if (value === undefined || value === null) {
  3228              return null;
  3229          }
  3230          
  3231          if (utils.isArray(value)) {
  3232              return value.map(function (v) {
  3233                  return '0x' + coder.encodeParam(i.type, v);
  3234              });
  3235          }
  3236          return '0x' + coder.encodeParam(i.type, value);
  3237      });
  3238  
  3239      result.topics = result.topics.concat(indexedTopics);
  3240  
  3241      return result;
  3242  };
  3243  
  3244  /**
  3245   * Should be used to decode indexed params and options
  3246   *
  3247   * @method decode
  3248   * @param {Object} data
  3249   * @return {Object} result object with decoded indexed && not indexed params
  3250   */
  3251  SolidityEvent.prototype.decode = function (data) {
  3252   
  3253      data.data = data.data || '';
  3254      data.topics = data.topics || [];
  3255  
  3256      var argTopics = this._anonymous ? data.topics : data.topics.slice(1);
  3257      var indexedData = argTopics.map(function (topics) { return topics.slice(2); }).join("");
  3258      var indexedParams = coder.decodeParams(this.types(true), indexedData); 
  3259  
  3260      var notIndexedData = data.data.slice(2);
  3261      var notIndexedParams = coder.decodeParams(this.types(false), notIndexedData);
  3262      
  3263      var result = formatters.outputLogFormatter(data);
  3264      result.event = this.displayName();
  3265      result.address = data.address;
  3266  
  3267      result.args = this._params.reduce(function (acc, current) {
  3268          acc[current.name] = current.indexed ? indexedParams.shift() : notIndexedParams.shift();
  3269          return acc;
  3270      }, {});
  3271  
  3272      delete result.data;
  3273      delete result.topics;
  3274  
  3275      return result;
  3276  };
  3277  
  3278  /**
  3279   * Should be used to create new filter object from event
  3280   *
  3281   * @method execute
  3282   * @param {Object} indexed
  3283   * @param {Object} options
  3284   * @return {Object} filter object
  3285   */
  3286  SolidityEvent.prototype.execute = function (indexed, options, callback) {
  3287  
  3288      if (utils.isFunction(arguments[arguments.length - 1])) {
  3289          callback = arguments[arguments.length - 1];
  3290          if(arguments.length === 2)
  3291              options = null;
  3292          if(arguments.length === 1) {
  3293              options = null;
  3294              indexed = {};
  3295          }
  3296      }
  3297      
  3298      var o = this.encode(indexed, options);
  3299      var formatter = this.decode.bind(this);
  3300      return new Filter(this._requestManager, o, watches.eth(), formatter, callback);
  3301  };
  3302  
  3303  /**
  3304   * Should be used to attach event to contract object
  3305   *
  3306   * @method attachToContract
  3307   * @param {Contract}
  3308   */
  3309  SolidityEvent.prototype.attachToContract = function (contract) {
  3310      var execute = this.execute.bind(this);
  3311      var displayName = this.displayName();
  3312      if (!contract[displayName]) {
  3313          contract[displayName] = execute;
  3314      }
  3315      contract[displayName][this.typeName()] = this.execute.bind(this, contract);
  3316  };
  3317  
  3318  module.exports = SolidityEvent;
  3319  
  3320  
  3321  },{"../solidity/coder":7,"../utils/sha3":19,"../utils/utils":20,"./filter":29,"./formatters":30,"./methods/watches":43}],28:[function(require,module,exports){
  3322  var formatters = require('./formatters');
  3323  var utils = require('./../utils/utils');
  3324  var Method = require('./method');
  3325  var Property = require('./property');
  3326  
  3327  // TODO: refactor, so the input params are not altered.
  3328  // it's necessary to make same 'extension' work with multiple providers
  3329  var extend = function (web3) {
  3330      /* jshint maxcomplexity:5 */
  3331      var ex = function (extension) {
  3332  
  3333          var extendedObject;
  3334          if (extension.property) {
  3335              if (!web3[extension.property]) {
  3336                  web3[extension.property] = {};
  3337              }
  3338              extendedObject = web3[extension.property];
  3339          } else {
  3340              extendedObject = web3;
  3341          }
  3342  
  3343          if (extension.methods) {
  3344              extension.methods.forEach(function (method) {
  3345                  method.attachToObject(extendedObject);
  3346                  method.setRequestManager(web3._requestManager);
  3347              });
  3348          }
  3349  
  3350          if (extension.properties) {
  3351              extension.properties.forEach(function (property) {
  3352                  property.attachToObject(extendedObject);
  3353                  property.setRequestManager(web3._requestManager);
  3354              });
  3355          }
  3356      };
  3357  
  3358      ex.formatters = formatters; 
  3359      ex.utils = utils;
  3360      ex.Method = Method;
  3361      ex.Property = Property;
  3362  
  3363      return ex;
  3364  };
  3365  
  3366  
  3367  
  3368  module.exports = extend;
  3369  
  3370  
  3371  },{"./../utils/utils":20,"./formatters":30,"./method":36,"./property":45}],29:[function(require,module,exports){
  3372  /*
  3373      This file is part of web3.js.
  3374  
  3375      web3.js is free software: you can redistribute it and/or modify
  3376      it under the terms of the GNU Lesser General Public License as published by
  3377      the Free Software Foundation, either version 3 of the License, or
  3378      (at your option) any later version.
  3379  
  3380      web3.js is distributed in the hope that it will be useful,
  3381      but WITHOUT ANY WARRANTY; without even the implied warranty of
  3382      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  3383      GNU Lesser General Public License for more details.
  3384  
  3385      You should have received a copy of the GNU Lesser General Public License
  3386      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  3387  */
  3388  /** @file filter.js
  3389   * @authors:
  3390   *   Jeffrey Wilcke <jeff@ethdev.com>
  3391   *   Marek Kotewicz <marek@ethdev.com>
  3392   *   Marian Oancea <marian@ethdev.com>
  3393   *   Fabian Vogelsteller <fabian@ethdev.com>
  3394   *   Gav Wood <g@ethdev.com>
  3395   * @date 2014
  3396   */
  3397  
  3398  var formatters = require('./formatters');
  3399  var utils = require('../utils/utils');
  3400  
  3401  /**
  3402  * Converts a given topic to a hex string, but also allows null values.
  3403  *
  3404  * @param {Mixed} value
  3405  * @return {String}
  3406  */
  3407  var toTopic = function(value){
  3408  
  3409      if(value === null || typeof value === 'undefined')
  3410          return null;
  3411  
  3412      value = String(value);
  3413  
  3414      if(value.indexOf('0x') === 0)
  3415          return value;
  3416      else
  3417          return utils.fromUtf8(value);
  3418  };
  3419  
  3420  /// This method should be called on options object, to verify deprecated properties && lazy load dynamic ones
  3421  /// @param should be string or object
  3422  /// @returns options string or object
  3423  var getOptions = function (options) {
  3424  
  3425      if (utils.isString(options)) {
  3426          return options;
  3427      }
  3428  
  3429      options = options || {};
  3430  
  3431      // make sure topics, get converted to hex
  3432      options.topics = options.topics || [];
  3433      options.topics = options.topics.map(function(topic){
  3434          return (utils.isArray(topic)) ? topic.map(toTopic) : toTopic(topic);
  3435      });
  3436  
  3437      return {
  3438          topics: options.topics,
  3439          from: options.from,
  3440          to: options.to,
  3441          address: options.address,
  3442          fromBlock: formatters.inputBlockNumberFormatter(options.fromBlock),
  3443          toBlock: formatters.inputBlockNumberFormatter(options.toBlock)
  3444      };
  3445  };
  3446  
  3447  /**
  3448  Adds the callback and sets up the methods, to iterate over the results.
  3449  
  3450  @method getLogsAtStart
  3451  @param {Object} self
  3452  @param {funciton}
  3453  */
  3454  var getLogsAtStart = function(self, callback){
  3455      // call getFilterLogs for the first watch callback start
  3456      if (!utils.isString(self.options)) {
  3457          self.get(function (err, messages) {
  3458              // don't send all the responses to all the watches again... just to self one
  3459              if (err) {
  3460                  callback(err);
  3461              }
  3462  
  3463              if(utils.isArray(messages)) {
  3464                  messages.forEach(function (message) {
  3465                      callback(null, message);
  3466                  });
  3467              }
  3468          });
  3469      }
  3470  };
  3471  
  3472  /**
  3473  Adds the callback and sets up the methods, to iterate over the results.
  3474  
  3475  @method pollFilter
  3476  @param {Object} self
  3477  */
  3478  var pollFilter = function(self) {
  3479  
  3480      var onMessage = function (error, messages) {
  3481          if (error) {
  3482              return self.callbacks.forEach(function (callback) {
  3483                  callback(error);
  3484              });
  3485          }
  3486  
  3487          if(utils.isArray(messages)) {
  3488              messages.forEach(function (message) {
  3489                  message = self.formatter ? self.formatter(message) : message;
  3490                  self.callbacks.forEach(function (callback) {
  3491                      callback(null, message);
  3492                  });
  3493              });
  3494          }
  3495      };
  3496  
  3497      self.requestManager.startPolling({
  3498          method: self.implementation.poll.call,
  3499          params: [self.filterId],
  3500      }, self.filterId, onMessage, self.stopWatching.bind(self));
  3501  
  3502  };
  3503  
  3504  var Filter = function (requestManager, options, methods, formatter, callback, filterCreationErrorCallback) {
  3505      var self = this;
  3506      var implementation = {};
  3507      methods.forEach(function (method) {
  3508          method.setRequestManager(requestManager);
  3509          method.attachToObject(implementation);
  3510      });
  3511      this.requestManager = requestManager;
  3512      this.options = getOptions(options);
  3513      this.implementation = implementation;
  3514      this.filterId = null;
  3515      this.callbacks = [];
  3516      this.getLogsCallbacks = [];
  3517      this.pollFilters = [];
  3518      this.formatter = formatter;
  3519      this.implementation.newFilter(this.options, function(error, id){
  3520          if(error) {
  3521              self.callbacks.forEach(function(cb){
  3522                  cb(error);
  3523              });
  3524              filterCreationErrorCallback(error);
  3525          } else {
  3526              self.filterId = id;
  3527  
  3528              // check if there are get pending callbacks as a consequence
  3529              // of calling get() with filterId unassigned.
  3530              self.getLogsCallbacks.forEach(function (cb){
  3531                  self.get(cb);
  3532              });
  3533              self.getLogsCallbacks = [];
  3534  
  3535              // get filter logs for the already existing watch calls
  3536              self.callbacks.forEach(function(cb){
  3537                  getLogsAtStart(self, cb);
  3538              });
  3539              if(self.callbacks.length > 0)
  3540                  pollFilter(self);
  3541  
  3542              // start to watch immediately
  3543              if(typeof callback === 'function') {
  3544                  return self.watch(callback);
  3545              }
  3546          }
  3547      });
  3548  
  3549      return this;
  3550  };
  3551  
  3552  Filter.prototype.watch = function (callback) {
  3553      this.callbacks.push(callback);
  3554  
  3555      if(this.filterId) {
  3556          getLogsAtStart(this, callback);
  3557          pollFilter(this);
  3558      }
  3559  
  3560      return this;
  3561  };
  3562  
  3563  Filter.prototype.stopWatching = function (callback) {
  3564      this.requestManager.stopPolling(this.filterId);
  3565      this.callbacks = [];
  3566      // remove filter async
  3567      if (callback) {
  3568          this.implementation.uninstallFilter(this.filterId, callback);
  3569      } else {
  3570          return this.implementation.uninstallFilter(this.filterId);
  3571      }
  3572  };
  3573  
  3574  Filter.prototype.get = function (callback) {
  3575      var self = this;
  3576      if (utils.isFunction(callback)) {
  3577          if (this.filterId === null) {
  3578              // If filterId is not set yet, call it back
  3579              // when newFilter() assigns it.
  3580              this.getLogsCallbacks.push(callback);
  3581          } else {
  3582              this.implementation.getLogs(this.filterId, function(err, res){
  3583                  if (err) {
  3584                      callback(err);
  3585                  } else {
  3586                      callback(null, res.map(function (log) {
  3587                          return self.formatter ? self.formatter(log) : log;
  3588                      }));
  3589                  }
  3590              });
  3591          }
  3592      } else {
  3593          if (this.filterId === null) {
  3594              throw new Error('Filter ID Error: filter().get() can\'t be chained synchronous, please provide a callback for the get() method.');
  3595          }
  3596          var logs = this.implementation.getLogs(this.filterId);
  3597          return logs.map(function (log) {
  3598              return self.formatter ? self.formatter(log) : log;
  3599          });
  3600      }
  3601  
  3602      return this;
  3603  };
  3604  
  3605  module.exports = Filter;
  3606  
  3607  
  3608  },{"../utils/utils":20,"./formatters":30}],30:[function(require,module,exports){
  3609  /*
  3610      This file is part of web3.js.
  3611  
  3612      web3.js is free software: you can redistribute it and/or modify
  3613      it under the terms of the GNU Lesser General Public License as published by
  3614      the Free Software Foundation, either version 3 of the License, or
  3615      (at your option) any later version.
  3616  
  3617      web3.js is distributed in the hope that it will be useful,
  3618      but WITHOUT ANY WARRANTY; without even the implied warranty of
  3619      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  3620      GNU Lesser General Public License for more details.
  3621  
  3622      You should have received a copy of the GNU Lesser General Public License
  3623      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  3624  */
  3625  /**
  3626   * @file formatters.js
  3627   * @author Marek Kotewicz <marek@ethdev.com>
  3628   * @author Fabian Vogelsteller <fabian@ethdev.com>
  3629   * @date 2015
  3630   */
  3631  
  3632  var utils = require('../utils/utils');
  3633  var config = require('../utils/config');
  3634  var Iban = require('./iban');
  3635  
  3636  /**
  3637   * Should the format output to a big number
  3638   *
  3639   * @method outputBigNumberFormatter
  3640   * @param {String|Number|BigNumber}
  3641   * @returns {BigNumber} object
  3642   */
  3643  var outputBigNumberFormatter = function (number) {
  3644      return utils.toBigNumber(number);
  3645  };
  3646  
  3647  var isPredefinedBlockNumber = function (blockNumber) {
  3648      return blockNumber === 'latest' || blockNumber === 'pending' || blockNumber === 'earliest';
  3649  };
  3650  
  3651  var inputDefaultBlockNumberFormatter = function (blockNumber) {
  3652      if (blockNumber === undefined) {
  3653          return config.defaultBlock;
  3654      }
  3655      return inputBlockNumberFormatter(blockNumber);
  3656  };
  3657  
  3658  var inputBlockNumberFormatter = function (blockNumber) {
  3659      if (blockNumber === undefined) {
  3660          return undefined;
  3661      } else if (isPredefinedBlockNumber(blockNumber)) {
  3662          return blockNumber;
  3663      }
  3664      return utils.toHex(blockNumber);
  3665  };
  3666  
  3667  /**
  3668   * Formats the input of a transaction and converts all values to HEX
  3669   *
  3670   * @method inputCallFormatter
  3671   * @param {Object} transaction options
  3672   * @returns object
  3673  */
  3674  var inputCallFormatter = function (options){
  3675  
  3676      options.from = options.from || config.defaultAccount;
  3677  
  3678      if (options.from) {
  3679          options.from = inputAddressFormatter(options.from);
  3680      }
  3681  
  3682      if (options.to) { // it might be contract creation
  3683          options.to = inputAddressFormatter(options.to);
  3684      }
  3685  
  3686      ['gasPrice', 'gas', 'value', 'nonce'].filter(function (key) {
  3687          return options[key] !== undefined;
  3688      }).forEach(function(key){
  3689          options[key] = utils.fromDecimal(options[key]);
  3690      });
  3691  
  3692      return options;
  3693  };
  3694  
  3695  /**
  3696   * Formats the input of a transaction and converts all values to HEX
  3697   *
  3698   * @method inputTransactionFormatter
  3699   * @param {Object} transaction options
  3700   * @returns object
  3701  */
  3702  var inputTransactionFormatter = function (options){
  3703  
  3704      options.from = options.from || config.defaultAccount;
  3705      options.from = inputAddressFormatter(options.from);
  3706  
  3707      if (options.to) { // it might be contract creation
  3708          options.to = inputAddressFormatter(options.to);
  3709      }
  3710  
  3711      ['gasPrice', 'gas', 'value', 'nonce'].filter(function (key) {
  3712          return options[key] !== undefined;
  3713      }).forEach(function(key){
  3714          options[key] = utils.fromDecimal(options[key]);
  3715      });
  3716  
  3717      return options;
  3718  };
  3719  
  3720  /**
  3721   * Formats the output of a transaction to its proper values
  3722   *
  3723   * @method outputTransactionFormatter
  3724   * @param {Object} tx
  3725   * @returns {Object}
  3726  */
  3727  var outputTransactionFormatter = function (tx){
  3728      if(tx.blockNumber !== null)
  3729          tx.blockNumber = utils.toDecimal(tx.blockNumber);
  3730      if(tx.transactionIndex !== null)
  3731          tx.transactionIndex = utils.toDecimal(tx.transactionIndex);
  3732      tx.nonce = utils.toDecimal(tx.nonce);
  3733      tx.gas = utils.toDecimal(tx.gas);
  3734      tx.gasPrice = utils.toBigNumber(tx.gasPrice);
  3735      tx.value = utils.toBigNumber(tx.value);
  3736      return tx;
  3737  };
  3738  
  3739  /**
  3740   * Formats the output of a transaction receipt to its proper values
  3741   *
  3742   * @method outputTransactionReceiptFormatter
  3743   * @param {Object} receipt
  3744   * @returns {Object}
  3745  */
  3746  var outputTransactionReceiptFormatter = function (receipt){
  3747      if(receipt.blockNumber !== null)
  3748          receipt.blockNumber = utils.toDecimal(receipt.blockNumber);
  3749      if(receipt.transactionIndex !== null)
  3750          receipt.transactionIndex = utils.toDecimal(receipt.transactionIndex);
  3751      receipt.cumulativeGasUsed = utils.toDecimal(receipt.cumulativeGasUsed);
  3752      receipt.gasUsed = utils.toDecimal(receipt.gasUsed);
  3753  
  3754      if(utils.isArray(receipt.logs)) {
  3755          receipt.logs = receipt.logs.map(function(log){
  3756              return outputLogFormatter(log);
  3757          });
  3758      }
  3759  
  3760      return receipt;
  3761  };
  3762  
  3763  /**
  3764   * Formats the output of a block to its proper values
  3765   *
  3766   * @method outputBlockFormatter
  3767   * @param {Object} block
  3768   * @returns {Object}
  3769  */
  3770  var outputBlockFormatter = function(block) {
  3771  
  3772      // transform to number
  3773      block.gasLimit = utils.toDecimal(block.gasLimit);
  3774      block.gasUsed = utils.toDecimal(block.gasUsed);
  3775      block.size = utils.toDecimal(block.size);
  3776      block.timestamp = utils.toDecimal(block.timestamp);
  3777      if(block.number !== null)
  3778          block.number = utils.toDecimal(block.number);
  3779  
  3780      block.difficulty = utils.toBigNumber(block.difficulty);
  3781      block.totalDifficulty = utils.toBigNumber(block.totalDifficulty);
  3782  
  3783      if (utils.isArray(block.transactions)) {
  3784          block.transactions.forEach(function(item){
  3785              if(!utils.isString(item))
  3786                  return outputTransactionFormatter(item);
  3787          });
  3788      }
  3789  
  3790      return block;
  3791  };
  3792  
  3793  /**
  3794   * Formats the output of a log
  3795   *
  3796   * @method outputLogFormatter
  3797   * @param {Object} log object
  3798   * @returns {Object} log
  3799  */
  3800  var outputLogFormatter = function(log) {
  3801      if(log.blockNumber !== null)
  3802          log.blockNumber = utils.toDecimal(log.blockNumber);
  3803      if(log.transactionIndex !== null)
  3804          log.transactionIndex = utils.toDecimal(log.transactionIndex);
  3805      if(log.logIndex !== null)
  3806          log.logIndex = utils.toDecimal(log.logIndex);
  3807  
  3808      return log;
  3809  };
  3810  
  3811  /**
  3812   * Formats the input of a whisper post and converts all values to HEX
  3813   *
  3814   * @method inputPostFormatter
  3815   * @param {Object} transaction object
  3816   * @returns {Object}
  3817  */
  3818  var inputPostFormatter = function(post) {
  3819  
  3820      // post.payload = utils.toHex(post.payload);
  3821      post.ttl = utils.fromDecimal(post.ttl);
  3822      post.workToProve = utils.fromDecimal(post.workToProve);
  3823      post.priority = utils.fromDecimal(post.priority);
  3824  
  3825      // fallback
  3826      if (!utils.isArray(post.topics)) {
  3827          post.topics = post.topics ? [post.topics] : [];
  3828      }
  3829  
  3830      // format the following options
  3831      post.topics = post.topics.map(function(topic){
  3832          // convert only if not hex
  3833          return (topic.indexOf('0x') === 0) ? topic : utils.fromUtf8(topic);
  3834      });
  3835  
  3836      return post;
  3837  };
  3838  
  3839  /**
  3840   * Formats the output of a received post message
  3841   *
  3842   * @method outputPostFormatter
  3843   * @param {Object}
  3844   * @returns {Object}
  3845   */
  3846  var outputPostFormatter = function(post){
  3847  
  3848      post.expiry = utils.toDecimal(post.expiry);
  3849      post.sent = utils.toDecimal(post.sent);
  3850      post.ttl = utils.toDecimal(post.ttl);
  3851      post.workProved = utils.toDecimal(post.workProved);
  3852      // post.payloadRaw = post.payload;
  3853      // post.payload = utils.toAscii(post.payload);
  3854  
  3855      // if (utils.isJson(post.payload)) {
  3856      //     post.payload = JSON.parse(post.payload);
  3857      // }
  3858  
  3859      // format the following options
  3860      if (!post.topics) {
  3861          post.topics = [];
  3862      }
  3863      post.topics = post.topics.map(function(topic){
  3864          return utils.toAscii(topic);
  3865      });
  3866  
  3867      return post;
  3868  };
  3869  
  3870  var inputAddressFormatter = function (address) {
  3871      var iban = new Iban(address);
  3872      if (iban.isValid() && iban.isDirect()) {
  3873          return '0x' + iban.address();
  3874      } else if (utils.isStrictAddress(address)) {
  3875          return address;
  3876      } else if (utils.isAddress(address)) {
  3877          return '0x' + address;
  3878      }
  3879      throw new Error('invalid address');
  3880  };
  3881  
  3882  
  3883  var outputSyncingFormatter = function(result) {
  3884  
  3885      result.startingBlock = utils.toDecimal(result.startingBlock);
  3886      result.currentBlock = utils.toDecimal(result.currentBlock);
  3887      result.highestBlock = utils.toDecimal(result.highestBlock);
  3888      if (result.knownStates) {
  3889          result.knownStates = utils.toDecimal(result.knownStates);
  3890          result.pulledStates = utils.toDecimal(result.pulledStates);
  3891      }
  3892  
  3893      return result;
  3894  };
  3895  
  3896  module.exports = {
  3897      inputDefaultBlockNumberFormatter: inputDefaultBlockNumberFormatter,
  3898      inputBlockNumberFormatter: inputBlockNumberFormatter,
  3899      inputCallFormatter: inputCallFormatter,
  3900      inputTransactionFormatter: inputTransactionFormatter,
  3901      inputAddressFormatter: inputAddressFormatter,
  3902      inputPostFormatter: inputPostFormatter,
  3903      outputBigNumberFormatter: outputBigNumberFormatter,
  3904      outputTransactionFormatter: outputTransactionFormatter,
  3905      outputTransactionReceiptFormatter: outputTransactionReceiptFormatter,
  3906      outputBlockFormatter: outputBlockFormatter,
  3907      outputLogFormatter: outputLogFormatter,
  3908      outputPostFormatter: outputPostFormatter,
  3909      outputSyncingFormatter: outputSyncingFormatter
  3910  };
  3911  
  3912  
  3913  },{"../utils/config":18,"../utils/utils":20,"./iban":33}],31:[function(require,module,exports){
  3914  /*
  3915      This file is part of web3.js.
  3916  
  3917      web3.js is free software: you can redistribute it and/or modify
  3918      it under the terms of the GNU Lesser General Public License as published by
  3919      the Free Software Foundation, either version 3 of the License, or
  3920      (at your option) any later version.
  3921  
  3922      web3.js is distributed in the hope that it will be useful,
  3923      but WITHOUT ANY WARRANTY; without even the implied warranty of
  3924      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  3925      GNU Lesser General Public License for more details.
  3926  
  3927      You should have received a copy of the GNU Lesser General Public License
  3928      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  3929  */
  3930  /**
  3931   * @file function.js
  3932   * @author Marek Kotewicz <marek@ethdev.com>
  3933   * @date 2015
  3934   */
  3935  
  3936  var coder = require('../solidity/coder');
  3937  var utils = require('../utils/utils');
  3938  var formatters = require('./formatters');
  3939  var sha3 = require('../utils/sha3');
  3940  
  3941  /**
  3942   * This prototype should be used to call/sendTransaction to solidity functions
  3943   */
  3944  var SolidityFunction = function (eth, json, address) {
  3945      this._eth = eth;
  3946      this._inputTypes = json.inputs.map(function (i) {
  3947          return i.type;
  3948      });
  3949      this._outputTypes = json.outputs.map(function (i) {
  3950          return i.type;
  3951      });
  3952      this._constant = json.constant;
  3953      this._payable = json.payable;
  3954      this._name = utils.transformToFullName(json);
  3955      this._address = address;
  3956  };
  3957  
  3958  SolidityFunction.prototype.extractCallback = function (args) {
  3959      if (utils.isFunction(args[args.length - 1])) {
  3960          return args.pop(); // modify the args array!
  3961      }
  3962  };
  3963  
  3964  SolidityFunction.prototype.extractDefaultBlock = function (args) {
  3965      if (args.length > this._inputTypes.length && !utils.isObject(args[args.length -1])) {
  3966          return formatters.inputDefaultBlockNumberFormatter(args.pop()); // modify the args array!
  3967      }
  3968  };
  3969  
  3970  /**
  3971   * Should be used to create payload from arguments
  3972   *
  3973   * @method toPayload
  3974   * @param {Array} solidity function params
  3975   * @param {Object} optional payload options
  3976   */
  3977  SolidityFunction.prototype.toPayload = function (args) {
  3978      var options = {};
  3979      if (args.length > this._inputTypes.length && utils.isObject(args[args.length -1])) {
  3980          options = args[args.length - 1];
  3981      }
  3982      options.to = this._address;
  3983      options.data = '0x' + this.signature() + coder.encodeParams(this._inputTypes, args);
  3984      return options;
  3985  };
  3986  
  3987  /**
  3988   * Should be used to get function signature
  3989   *
  3990   * @method signature
  3991   * @return {String} function signature
  3992   */
  3993  SolidityFunction.prototype.signature = function () {
  3994      return sha3(this._name).slice(0, 8);
  3995  };
  3996  
  3997  
  3998  SolidityFunction.prototype.unpackOutput = function (output) {
  3999      if (!output) {
  4000          return;
  4001      }
  4002  
  4003      output = output.length >= 2 ? output.slice(2) : output;
  4004      var result = coder.decodeParams(this._outputTypes, output);
  4005      return result.length === 1 ? result[0] : result;
  4006  };
  4007  
  4008  /**
  4009   * Calls a contract function.
  4010   *
  4011   * @method call
  4012   * @param {...Object} Contract function arguments
  4013   * @param {function} If the last argument is a function, the contract function
  4014   *   call will be asynchronous, and the callback will be passed the
  4015   *   error and result.
  4016   * @return {String} output bytes
  4017   */
  4018  SolidityFunction.prototype.call = function () {
  4019      var args = Array.prototype.slice.call(arguments).filter(function (a) {return a !== undefined; });
  4020      var callback = this.extractCallback(args);
  4021      var defaultBlock = this.extractDefaultBlock(args);
  4022      var payload = this.toPayload(args);
  4023  
  4024  
  4025      if (!callback) {
  4026          var output = this._eth.call(payload, defaultBlock);
  4027          return this.unpackOutput(output);
  4028      }
  4029  
  4030      var self = this;
  4031      this._eth.call(payload, defaultBlock, function (error, output) {
  4032          if (error) return callback(error, null);
  4033  
  4034          var unpacked = null;
  4035          try {
  4036              unpacked = self.unpackOutput(output);
  4037          }
  4038          catch (e) {
  4039              error = e;
  4040          }
  4041  
  4042          callback(error, unpacked);
  4043      });
  4044  };
  4045  
  4046  /**
  4047   * Should be used to sendTransaction to solidity function
  4048   *
  4049   * @method sendTransaction
  4050   */
  4051  SolidityFunction.prototype.sendTransaction = function () {
  4052      var args = Array.prototype.slice.call(arguments).filter(function (a) {return a !== undefined; });
  4053      var callback = this.extractCallback(args);
  4054      var payload = this.toPayload(args);
  4055  
  4056      if (payload.value > 0 && !this._payable) {
  4057          throw new Error('Cannot send value to non-payable function');
  4058      }
  4059  
  4060      if (!callback) {
  4061          return this._eth.sendTransaction(payload);
  4062      }
  4063  
  4064      this._eth.sendTransaction(payload, callback);
  4065  };
  4066  
  4067  /**
  4068   * Should be used to estimateGas of solidity function
  4069   *
  4070   * @method estimateGas
  4071   */
  4072  SolidityFunction.prototype.estimateGas = function () {
  4073      var args = Array.prototype.slice.call(arguments);
  4074      var callback = this.extractCallback(args);
  4075      var payload = this.toPayload(args);
  4076  
  4077      if (!callback) {
  4078          return this._eth.estimateGas(payload);
  4079      }
  4080  
  4081      this._eth.estimateGas(payload, callback);
  4082  };
  4083  
  4084  /**
  4085   * Return the encoded data of the call
  4086   *
  4087   * @method getData
  4088   * @return {String} the encoded data
  4089   */
  4090  SolidityFunction.prototype.getData = function () {
  4091      var args = Array.prototype.slice.call(arguments);
  4092      var payload = this.toPayload(args);
  4093  
  4094      return payload.data;
  4095  };
  4096  
  4097  /**
  4098   * Should be used to get function display name
  4099   *
  4100   * @method displayName
  4101   * @return {String} display name of the function
  4102   */
  4103  SolidityFunction.prototype.displayName = function () {
  4104      return utils.extractDisplayName(this._name);
  4105  };
  4106  
  4107  /**
  4108   * Should be used to get function type name
  4109   *
  4110   * @method typeName
  4111   * @return {String} type name of the function
  4112   */
  4113  SolidityFunction.prototype.typeName = function () {
  4114      return utils.extractTypeName(this._name);
  4115  };
  4116  
  4117  /**
  4118   * Should be called to get rpc requests from solidity function
  4119   *
  4120   * @method request
  4121   * @returns {Object}
  4122   */
  4123  SolidityFunction.prototype.request = function () {
  4124      var args = Array.prototype.slice.call(arguments);
  4125      var callback = this.extractCallback(args);
  4126      var payload = this.toPayload(args);
  4127      var format = this.unpackOutput.bind(this);
  4128  
  4129      return {
  4130          method: this._constant ? 'eth_call' : 'eth_sendTransaction',
  4131          callback: callback,
  4132          params: [payload],
  4133          format: format
  4134      };
  4135  };
  4136  
  4137  /**
  4138   * Should be called to execute function
  4139   *
  4140   * @method execute
  4141   */
  4142  SolidityFunction.prototype.execute = function () {
  4143      var transaction = !this._constant;
  4144  
  4145      // send transaction
  4146      if (transaction) {
  4147          return this.sendTransaction.apply(this, Array.prototype.slice.call(arguments));
  4148      }
  4149  
  4150      // call
  4151      return this.call.apply(this, Array.prototype.slice.call(arguments));
  4152  };
  4153  
  4154  /**
  4155   * Should be called to attach function to contract
  4156   *
  4157   * @method attachToContract
  4158   * @param {Contract}
  4159   */
  4160  SolidityFunction.prototype.attachToContract = function (contract) {
  4161      var execute = this.execute.bind(this);
  4162      execute.request = this.request.bind(this);
  4163      execute.call = this.call.bind(this);
  4164      execute.sendTransaction = this.sendTransaction.bind(this);
  4165      execute.estimateGas = this.estimateGas.bind(this);
  4166      execute.getData = this.getData.bind(this);
  4167      var displayName = this.displayName();
  4168      if (!contract[displayName]) {
  4169          contract[displayName] = execute;
  4170      }
  4171      contract[displayName][this.typeName()] = execute; // circular!!!!
  4172  };
  4173  
  4174  module.exports = SolidityFunction;
  4175  
  4176  
  4177  },{"../solidity/coder":7,"../utils/sha3":19,"../utils/utils":20,"./formatters":30}],32:[function(require,module,exports){
  4178  /*
  4179      This file is part of web3.js.
  4180  
  4181      web3.js is free software: you can redistribute it and/or modify
  4182      it under the terms of the GNU Lesser General Public License as published by
  4183      the Free Software Foundation, either version 3 of the License, or
  4184      (at your option) any later version.
  4185  
  4186      web3.js is distributed in the hope that it will be useful,
  4187      but WITHOUT ANY WARRANTY; without even the implied warranty of
  4188      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  4189      GNU Lesser General Public License for more details.
  4190  
  4191      You should have received a copy of the GNU Lesser General Public License
  4192      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  4193  */
  4194  /** @file httpprovider.js
  4195   * @authors:
  4196   *   Marek Kotewicz <marek@ethdev.com>
  4197   *   Marian Oancea <marian@ethdev.com>
  4198   *   Fabian Vogelsteller <fabian@ethdev.com>
  4199   * @date 2015
  4200   */
  4201  
  4202  "use strict";
  4203  
  4204  var errors = require('./errors');
  4205  
  4206  // workaround to use httpprovider in different envs
  4207  // var XMLHttpRequest; // jshint ignore: line
  4208  
  4209  // browser
  4210  if (typeof window !== 'undefined' && window.XMLHttpRequest) {
  4211      XMLHttpRequest = window.XMLHttpRequest; // jshint ignore: line
  4212  // node
  4213  } else {
  4214      XMLHttpRequest = require('xmlhttprequest').XMLHttpRequest; // jshint ignore: line
  4215  }
  4216  
  4217  var XHR2 = require('xhr2'); // jshint ignore: line
  4218  
  4219  /**
  4220   * HttpProvider should be used to send rpc calls over http
  4221   */
  4222  var HttpProvider = function (host, timeout) {
  4223      this.host = host || 'http://localhost:8545';
  4224      this.timeout = timeout || 0;
  4225  };
  4226  
  4227  /**
  4228   * Should be called to prepare new XMLHttpRequest
  4229   *
  4230   * @method prepareRequest
  4231   * @param {Boolean} true if request should be async
  4232   * @return {XMLHttpRequest} object
  4233   */
  4234  HttpProvider.prototype.prepareRequest = function (async) {
  4235      var request;
  4236  
  4237      if (async) {
  4238        request = new XHR2();
  4239        request.timeout = this.timeout;
  4240      }else {
  4241        request = new XMLHttpRequest();
  4242      }
  4243  
  4244      request.open('POST', this.host, async);
  4245      request.setRequestHeader('Content-Type','application/json');
  4246      return request;
  4247  };
  4248  
  4249  /**
  4250   * Should be called to make sync request
  4251   *
  4252   * @method send
  4253   * @param {Object} payload
  4254   * @return {Object} result
  4255   */
  4256  HttpProvider.prototype.send = function (payload) {
  4257      var request = this.prepareRequest(false);
  4258  
  4259      try {
  4260          request.send(JSON.stringify(payload));
  4261      } catch(error) {
  4262          throw errors.InvalidConnection(this.host);
  4263      }
  4264  
  4265      var result = request.responseText;
  4266  
  4267      try {
  4268          result = JSON.parse(result);
  4269      } catch(e) {
  4270          throw errors.InvalidResponse(request.responseText);
  4271      }
  4272  
  4273      return result;
  4274  };
  4275  
  4276  /**
  4277   * Should be used to make async request
  4278   *
  4279   * @method sendAsync
  4280   * @param {Object} payload
  4281   * @param {Function} callback triggered on end with (err, result)
  4282   */
  4283  HttpProvider.prototype.sendAsync = function (payload, callback) {
  4284      var request = this.prepareRequest(true);
  4285  
  4286      request.onreadystatechange = function() {
  4287          if (request.readyState === 4 && request.timeout !== 1) {
  4288              var result = request.responseText;
  4289              var error = null;
  4290  
  4291              try {
  4292                  result = JSON.parse(result);
  4293              } catch(e) {
  4294                  error = errors.InvalidResponse(request.responseText);
  4295              }
  4296  
  4297              callback(error, result);
  4298          }
  4299      };
  4300  
  4301      request.ontimeout = function() {
  4302        callback(errors.ConnectionTimeout(this.timeout));
  4303      };
  4304  
  4305      try {
  4306          request.send(JSON.stringify(payload));
  4307      } catch(error) {
  4308          callback(errors.InvalidConnection(this.host));
  4309      }
  4310  };
  4311  
  4312  /**
  4313   * Synchronously tries to make Http request
  4314   *
  4315   * @method isConnected
  4316   * @return {Boolean} returns true if request haven't failed. Otherwise false
  4317   */
  4318  HttpProvider.prototype.isConnected = function() {
  4319      try {
  4320          this.send({
  4321              id: 9999999999,
  4322              jsonrpc: '2.0',
  4323              method: 'net_listening',
  4324              params: []
  4325          });
  4326          return true;
  4327      } catch(e) {
  4328          return false;
  4329      }
  4330  };
  4331  
  4332  module.exports = HttpProvider;
  4333  
  4334  },{"./errors":26,"xhr2":86,"xmlhttprequest":17}],33:[function(require,module,exports){
  4335  /*
  4336      This file is part of web3.js.
  4337  
  4338      web3.js is free software: you can redistribute it and/or modify
  4339      it under the terms of the GNU Lesser General Public License as published by
  4340      the Free Software Foundation, either version 3 of the License, or
  4341      (at your option) any later version.
  4342  
  4343      web3.js is distributed in the hope that it will be useful,
  4344      but WITHOUT ANY WARRANTY; without even the implied warranty of
  4345      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  4346      GNU Lesser General Public License for more details.
  4347  
  4348      You should have received a copy of the GNU Lesser General Public License
  4349      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  4350  */
  4351  /** 
  4352   * @file iban.js
  4353   * @author Marek Kotewicz <marek@ethdev.com>
  4354   * @date 2015
  4355   */
  4356  
  4357  var BigNumber = require('bignumber.js');
  4358  
  4359  var padLeft = function (string, bytes) {
  4360      var result = string;
  4361      while (result.length < bytes * 2) {
  4362          result = '0' + result;
  4363      }
  4364      return result;
  4365  };
  4366  
  4367  /**
  4368   * Prepare an IBAN for mod 97 computation by moving the first 4 chars to the end and transforming the letters to
  4369   * numbers (A = 10, B = 11, ..., Z = 35), as specified in ISO13616.
  4370   *
  4371   * @method iso13616Prepare
  4372   * @param {String} iban the IBAN
  4373   * @returns {String} the prepared IBAN
  4374   */
  4375  var iso13616Prepare = function (iban) {
  4376      var A = 'A'.charCodeAt(0);
  4377      var Z = 'Z'.charCodeAt(0);
  4378  
  4379      iban = iban.toUpperCase();
  4380      iban = iban.substr(4) + iban.substr(0,4);
  4381  
  4382      return iban.split('').map(function(n){
  4383          var code = n.charCodeAt(0);
  4384          if (code >= A && code <= Z){
  4385              // A = 10, B = 11, ... Z = 35
  4386              return code - A + 10;
  4387          } else {
  4388              return n;
  4389          }
  4390      }).join('');
  4391  };
  4392  
  4393  /**
  4394   * Calculates the MOD 97 10 of the passed IBAN as specified in ISO7064.
  4395   *
  4396   * @method mod9710
  4397   * @param {String} iban
  4398   * @returns {Number}
  4399   */
  4400  var mod9710 = function (iban) {
  4401      var remainder = iban,
  4402          block;
  4403  
  4404      while (remainder.length > 2){
  4405          block = remainder.slice(0, 9);
  4406          remainder = parseInt(block, 10) % 97 + remainder.slice(block.length);
  4407      }
  4408  
  4409      return parseInt(remainder, 10) % 97;
  4410  };
  4411  
  4412  /**
  4413   * This prototype should be used to create iban object from iban correct string
  4414   *
  4415   * @param {String} iban
  4416   */
  4417  var Iban = function (iban) {
  4418      this._iban = iban;
  4419  };
  4420  
  4421  /**
  4422   * This method should be used to create iban object from ethereum address
  4423   *
  4424   * @method fromAddress
  4425   * @param {String} address
  4426   * @return {Iban} the IBAN object
  4427   */
  4428  Iban.fromAddress = function (address) {
  4429      var asBn = new BigNumber(address, 16);
  4430      var base36 = asBn.toString(36);
  4431      var padded = padLeft(base36, 15);
  4432      return Iban.fromBban(padded.toUpperCase());
  4433  };
  4434  
  4435  /**
  4436   * Convert the passed BBAN to an IBAN for this country specification.
  4437   * Please note that <i>"generation of the IBAN shall be the exclusive responsibility of the bank/branch servicing the account"</i>.
  4438   * This method implements the preferred algorithm described in http://en.wikipedia.org/wiki/International_Bank_Account_Number#Generating_IBAN_check_digits
  4439   *
  4440   * @method fromBban
  4441   * @param {String} bban the BBAN to convert to IBAN
  4442   * @returns {Iban} the IBAN object
  4443   */
  4444  Iban.fromBban = function (bban) {
  4445      var countryCode = 'XE';
  4446  
  4447      var remainder = mod9710(iso13616Prepare(countryCode + '00' + bban));
  4448      var checkDigit = ('0' + (98 - remainder)).slice(-2);
  4449  
  4450      return new Iban(countryCode + checkDigit + bban);
  4451  };
  4452  
  4453  /**
  4454   * Should be used to create IBAN object for given institution and identifier
  4455   *
  4456   * @method createIndirect
  4457   * @param {Object} options, required options are "institution" and "identifier"
  4458   * @return {Iban} the IBAN object
  4459   */
  4460  Iban.createIndirect = function (options) {
  4461      return Iban.fromBban('ETH' + options.institution + options.identifier);
  4462  };
  4463  
  4464  /**
  4465   * Thos method should be used to check if given string is valid iban object
  4466   *
  4467   * @method isValid
  4468   * @param {String} iban string
  4469   * @return {Boolean} true if it is valid IBAN
  4470   */
  4471  Iban.isValid = function (iban) {
  4472      var i = new Iban(iban);
  4473      return i.isValid();
  4474  };
  4475  
  4476  /**
  4477   * Should be called to check if iban is correct
  4478   *
  4479   * @method isValid
  4480   * @returns {Boolean} true if it is, otherwise false
  4481   */
  4482  Iban.prototype.isValid = function () {
  4483      return /^XE[0-9]{2}(ETH[0-9A-Z]{13}|[0-9A-Z]{30,31})$/.test(this._iban) &&
  4484          mod9710(iso13616Prepare(this._iban)) === 1;
  4485  };
  4486  
  4487  /**
  4488   * Should be called to check if iban number is direct
  4489   *
  4490   * @method isDirect
  4491   * @returns {Boolean} true if it is, otherwise false
  4492   */
  4493  Iban.prototype.isDirect = function () {
  4494      return this._iban.length === 34 || this._iban.length === 35;
  4495  };
  4496  
  4497  /**
  4498   * Should be called to check if iban number if indirect
  4499   *
  4500   * @method isIndirect
  4501   * @returns {Boolean} true if it is, otherwise false
  4502   */
  4503  Iban.prototype.isIndirect = function () {
  4504      return this._iban.length === 20;
  4505  };
  4506  
  4507  /**
  4508   * Should be called to get iban checksum
  4509   * Uses the mod-97-10 checksumming protocol (ISO/IEC 7064:2003)
  4510   *
  4511   * @method checksum
  4512   * @returns {String} checksum
  4513   */
  4514  Iban.prototype.checksum = function () {
  4515      return this._iban.substr(2, 2);
  4516  };
  4517  
  4518  /**
  4519   * Should be called to get institution identifier
  4520   * eg. XREG
  4521   *
  4522   * @method institution
  4523   * @returns {String} institution identifier
  4524   */
  4525  Iban.prototype.institution = function () {
  4526      return this.isIndirect() ? this._iban.substr(7, 4) : '';
  4527  };
  4528  
  4529  /**
  4530   * Should be called to get client identifier within institution
  4531   * eg. GAVOFYORK
  4532   *
  4533   * @method client
  4534   * @returns {String} client identifier
  4535   */
  4536  Iban.prototype.client = function () {
  4537      return this.isIndirect() ? this._iban.substr(11) : '';
  4538  };
  4539  
  4540  /**
  4541   * Should be called to get client direct address
  4542   *
  4543   * @method address
  4544   * @returns {String} client direct address
  4545   */
  4546  Iban.prototype.address = function () {
  4547      if (this.isDirect()) {
  4548          var base36 = this._iban.substr(4);
  4549          var asBn = new BigNumber(base36, 36);
  4550          return padLeft(asBn.toString(16), 20);
  4551      } 
  4552  
  4553      return '';
  4554  };
  4555  
  4556  Iban.prototype.toString = function () {
  4557      return this._iban;
  4558  };
  4559  
  4560  module.exports = Iban;
  4561  
  4562  
  4563  },{"bignumber.js":"bignumber.js"}],34:[function(require,module,exports){
  4564  /*
  4565      This file is part of web3.js.
  4566  
  4567      web3.js is free software: you can redistribute it and/or modify
  4568      it under the terms of the GNU Lesser General Public License as published by
  4569      the Free Software Foundation, either version 3 of the License, or
  4570      (at your option) any later version.
  4571  
  4572      web3.js is distributed in the hope that it will be useful,
  4573      but WITHOUT ANY WARRANTY; without even the implied warranty of
  4574      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  4575      GNU Lesser General Public License for more details.
  4576  
  4577      You should have received a copy of the GNU Lesser General Public License
  4578      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  4579  */
  4580  /** @file ipcprovider.js
  4581   * @authors:
  4582   *   Fabian Vogelsteller <fabian@ethdev.com>
  4583   * @date 2015
  4584   */
  4585  
  4586  "use strict";
  4587  
  4588  var utils = require('../utils/utils');
  4589  var errors = require('./errors');
  4590  
  4591  
  4592  var IpcProvider = function (path, net) {
  4593      var _this = this;
  4594      this.responseCallbacks = {};
  4595      this.path = path;
  4596      
  4597      this.connection = net.connect({path: this.path});
  4598  
  4599      this.connection.on('error', function(e){
  4600          console.error('IPC Connection Error', e);
  4601          _this._timeout();
  4602      });
  4603  
  4604      this.connection.on('end', function(){
  4605          _this._timeout();
  4606      }); 
  4607  
  4608  
  4609      // LISTEN FOR CONNECTION RESPONSES
  4610      this.connection.on('data', function(data) {
  4611          /*jshint maxcomplexity: 6 */
  4612  
  4613          _this._parseResponse(data.toString()).forEach(function(result){
  4614  
  4615              var id = null;
  4616  
  4617              // get the id which matches the returned id
  4618              if(utils.isArray(result)) {
  4619                  result.forEach(function(load){
  4620                      if(_this.responseCallbacks[load.id])
  4621                          id = load.id;
  4622                  });
  4623              } else {
  4624                  id = result.id;
  4625              }
  4626  
  4627              // fire the callback
  4628              if(_this.responseCallbacks[id]) {
  4629                  _this.responseCallbacks[id](null, result);
  4630                  delete _this.responseCallbacks[id];
  4631              }
  4632          });
  4633      });
  4634  };
  4635  
  4636  /**
  4637  Will parse the response and make an array out of it.
  4638  
  4639  @method _parseResponse
  4640  @param {String} data
  4641  */
  4642  IpcProvider.prototype._parseResponse = function(data) {
  4643      var _this = this,
  4644          returnValues = [];
  4645      
  4646      // DE-CHUNKER
  4647      var dechunkedData = data
  4648          .replace(/\}[\n\r]?\{/g,'}|--|{') // }{
  4649          .replace(/\}\][\n\r]?\[\{/g,'}]|--|[{') // }][{
  4650          .replace(/\}[\n\r]?\[\{/g,'}|--|[{') // }[{
  4651          .replace(/\}\][\n\r]?\{/g,'}]|--|{') // }]{
  4652          .split('|--|');
  4653  
  4654      dechunkedData.forEach(function(data){
  4655  
  4656          // prepend the last chunk
  4657          if(_this.lastChunk)
  4658              data = _this.lastChunk + data;
  4659  
  4660          var result = null;
  4661  
  4662          try {
  4663              result = JSON.parse(data);
  4664  
  4665          } catch(e) {
  4666  
  4667              _this.lastChunk = data;
  4668  
  4669              // start timeout to cancel all requests
  4670              clearTimeout(_this.lastChunkTimeout);
  4671              _this.lastChunkTimeout = setTimeout(function(){
  4672                  _this._timeout();
  4673                  throw errors.InvalidResponse(data);
  4674              }, 1000 * 15);
  4675  
  4676              return;
  4677          }
  4678  
  4679          // cancel timeout and set chunk to null
  4680          clearTimeout(_this.lastChunkTimeout);
  4681          _this.lastChunk = null;
  4682  
  4683          if(result)
  4684              returnValues.push(result);
  4685      });
  4686  
  4687      return returnValues;
  4688  };
  4689  
  4690  
  4691  /**
  4692  Get the adds a callback to the responseCallbacks object,
  4693  which will be called if a response matching the response Id will arrive.
  4694  
  4695  @method _addResponseCallback
  4696  */
  4697  IpcProvider.prototype._addResponseCallback = function(payload, callback) {
  4698      var id = payload.id || payload[0].id;
  4699      var method = payload.method || payload[0].method;
  4700  
  4701      this.responseCallbacks[id] = callback;
  4702      this.responseCallbacks[id].method = method;
  4703  };
  4704  
  4705  /**
  4706  Timeout all requests when the end/error event is fired
  4707  
  4708  @method _timeout
  4709  */
  4710  IpcProvider.prototype._timeout = function() {
  4711      for(var key in this.responseCallbacks) {
  4712          if(this.responseCallbacks.hasOwnProperty(key)){
  4713              this.responseCallbacks[key](errors.InvalidConnection('on IPC'));
  4714              delete this.responseCallbacks[key];
  4715          }
  4716      }
  4717  };
  4718  
  4719  
  4720  /**
  4721  Check if the current connection is still valid.
  4722  
  4723  @method isConnected
  4724  */
  4725  IpcProvider.prototype.isConnected = function() {
  4726      var _this = this;
  4727  
  4728      // try reconnect, when connection is gone
  4729      if(!_this.connection.writable)
  4730          _this.connection.connect({path: _this.path});
  4731  
  4732      return !!this.connection.writable;
  4733  };
  4734  
  4735  IpcProvider.prototype.send = function (payload) {
  4736  
  4737      if(this.connection.writeSync) {
  4738          var result;
  4739  
  4740          // try reconnect, when connection is gone
  4741          if(!this.connection.writable)
  4742              this.connection.connect({path: this.path});
  4743  
  4744          var data = this.connection.writeSync(JSON.stringify(payload));
  4745  
  4746          try {
  4747              result = JSON.parse(data);
  4748          } catch(e) {
  4749              throw errors.InvalidResponse(data);                
  4750          }
  4751  
  4752          return result;
  4753  
  4754      } else {
  4755          throw new Error('You tried to send "'+ payload.method +'" synchronously. Synchronous requests are not supported by the IPC provider.');
  4756      }
  4757  };
  4758  
  4759  IpcProvider.prototype.sendAsync = function (payload, callback) {
  4760      // try reconnect, when connection is gone
  4761      if(!this.connection.writable)
  4762          this.connection.connect({path: this.path});
  4763  
  4764  
  4765      this.connection.write(JSON.stringify(payload));
  4766      this._addResponseCallback(payload, callback);
  4767  };
  4768  
  4769  module.exports = IpcProvider;
  4770  
  4771  
  4772  },{"../utils/utils":20,"./errors":26}],35:[function(require,module,exports){
  4773  /*
  4774      This file is part of web3.js.
  4775  
  4776      web3.js is free software: you can redistribute it and/or modify
  4777      it under the terms of the GNU Lesser General Public License as published by
  4778      the Free Software Foundation, either version 3 of the License, or
  4779      (at your option) any later version.
  4780  
  4781      web3.js is distributed in the hope that it will be useful,
  4782      but WITHOUT ANY WARRANTY; without even the implied warranty of
  4783      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  4784      GNU Lesser General Public License for more details.
  4785  
  4786      You should have received a copy of the GNU Lesser General Public License
  4787      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  4788  */
  4789  /** @file jsonrpc.js
  4790   * @authors:
  4791   *   Marek Kotewicz <marek@ethdev.com>
  4792   *   Aaron Kumavis <aaron@kumavis.me>
  4793   * @date 2015
  4794   */
  4795  
  4796  // Initialize Jsonrpc as a simple object with utility functions.
  4797  var Jsonrpc = {
  4798      messageId: 0
  4799  };
  4800  
  4801  /**
  4802   * Should be called to valid json create payload object
  4803   *
  4804   * @method toPayload
  4805   * @param {Function} method of jsonrpc call, required
  4806   * @param {Array} params, an array of method params, optional
  4807   * @returns {Object} valid jsonrpc payload object
  4808   */
  4809  Jsonrpc.toPayload = function (method, params) {
  4810      if (!method)
  4811          console.error('jsonrpc method should be specified!');
  4812  
  4813      // advance message ID
  4814      Jsonrpc.messageId++;
  4815  
  4816      return {
  4817          jsonrpc: '2.0',
  4818          id: Jsonrpc.messageId,
  4819          method: method,
  4820          params: params || []
  4821      };
  4822  };
  4823  
  4824  /**
  4825   * Should be called to check if jsonrpc response is valid
  4826   *
  4827   * @method isValidResponse
  4828   * @param {Object}
  4829   * @returns {Boolean} true if response is valid, otherwise false
  4830   */
  4831  Jsonrpc.isValidResponse = function (response) {
  4832      return Array.isArray(response) ? response.every(validateSingleMessage) : validateSingleMessage(response);
  4833  
  4834      function validateSingleMessage(message){
  4835        return !!message &&
  4836          !message.error &&
  4837          message.jsonrpc === '2.0' &&
  4838          typeof message.id === 'number' &&
  4839          message.result !== undefined; // only undefined is not valid json object
  4840      }
  4841  };
  4842  
  4843  /**
  4844   * Should be called to create batch payload object
  4845   *
  4846   * @method toBatchPayload
  4847   * @param {Array} messages, an array of objects with method (required) and params (optional) fields
  4848   * @returns {Array} batch payload
  4849   */
  4850  Jsonrpc.toBatchPayload = function (messages) {
  4851      return messages.map(function (message) {
  4852          return Jsonrpc.toPayload(message.method, message.params);
  4853      });
  4854  };
  4855  
  4856  module.exports = Jsonrpc;
  4857  
  4858  
  4859  },{}],36:[function(require,module,exports){
  4860  /*
  4861      This file is part of web3.js.
  4862  
  4863      web3.js is free software: you can redistribute it and/or modify
  4864      it under the terms of the GNU Lesser General Public License as published by
  4865      the Free Software Foundation, either version 3 of the License, or
  4866      (at your option) any later version.
  4867  
  4868      web3.js is distributed in the hope that it will be useful,
  4869      but WITHOUT ANY WARRANTY; without even the implied warranty of
  4870      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  4871      GNU Lesser General Public License for more details.
  4872  
  4873      You should have received a copy of the GNU Lesser General Public License
  4874      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  4875  */
  4876  /**
  4877   * @file method.js
  4878   * @author Marek Kotewicz <marek@ethdev.com>
  4879   * @date 2015
  4880   */
  4881  
  4882  var utils = require('../utils/utils');
  4883  var errors = require('./errors');
  4884  
  4885  var Method = function (options) {
  4886      this.name = options.name;
  4887      this.call = options.call;
  4888      this.params = options.params || 0;
  4889      this.inputFormatter = options.inputFormatter;
  4890      this.outputFormatter = options.outputFormatter;
  4891      this.requestManager = null;
  4892  };
  4893  
  4894  Method.prototype.setRequestManager = function (rm) {
  4895      this.requestManager = rm;
  4896  };
  4897  
  4898  /**
  4899   * Should be used to determine name of the jsonrpc method based on arguments
  4900   *
  4901   * @method getCall
  4902   * @param {Array} arguments
  4903   * @return {String} name of jsonrpc method
  4904   */
  4905  Method.prototype.getCall = function (args) {
  4906      return utils.isFunction(this.call) ? this.call(args) : this.call;
  4907  };
  4908  
  4909  /**
  4910   * Should be used to extract callback from array of arguments. Modifies input param
  4911   *
  4912   * @method extractCallback
  4913   * @param {Array} arguments
  4914   * @return {Function|Null} callback, if exists
  4915   */
  4916  Method.prototype.extractCallback = function (args) {
  4917      if (utils.isFunction(args[args.length - 1])) {
  4918          return args.pop(); // modify the args array!
  4919      }
  4920  };
  4921  
  4922  /**
  4923   * Should be called to check if the number of arguments is correct
  4924   * 
  4925   * @method validateArgs
  4926   * @param {Array} arguments
  4927   * @throws {Error} if it is not
  4928   */
  4929  Method.prototype.validateArgs = function (args) {
  4930      if (args.length !== this.params) {
  4931          throw errors.InvalidNumberOfParams();
  4932      }
  4933  };
  4934  
  4935  /**
  4936   * Should be called to format input args of method
  4937   * 
  4938   * @method formatInput
  4939   * @param {Array}
  4940   * @return {Array}
  4941   */
  4942  Method.prototype.formatInput = function (args) {
  4943      if (!this.inputFormatter) {
  4944          return args;
  4945      }
  4946  
  4947      return this.inputFormatter.map(function (formatter, index) {
  4948          return formatter ? formatter(args[index]) : args[index];
  4949      });
  4950  };
  4951  
  4952  /**
  4953   * Should be called to format output(result) of method
  4954   *
  4955   * @method formatOutput
  4956   * @param {Object}
  4957   * @return {Object}
  4958   */
  4959  Method.prototype.formatOutput = function (result) {
  4960      return this.outputFormatter && result ? this.outputFormatter(result) : result;
  4961  };
  4962  
  4963  /**
  4964   * Should create payload from given input args
  4965   *
  4966   * @method toPayload
  4967   * @param {Array} args
  4968   * @return {Object}
  4969   */
  4970  Method.prototype.toPayload = function (args) {
  4971      var call = this.getCall(args);
  4972      var callback = this.extractCallback(args);
  4973      var params = this.formatInput(args);
  4974      this.validateArgs(params);
  4975  
  4976      return {
  4977          method: call,
  4978          params: params,
  4979          callback: callback
  4980      };
  4981  };
  4982  
  4983  Method.prototype.attachToObject = function (obj) {
  4984      var func = this.buildCall();
  4985      func.call = this.call; // TODO!!! that's ugly. filter.js uses it
  4986      var name = this.name.split('.');
  4987      if (name.length > 1) {
  4988          obj[name[0]] = obj[name[0]] || {};
  4989          obj[name[0]][name[1]] = func;
  4990      } else {
  4991          obj[name[0]] = func; 
  4992      }
  4993  };
  4994  
  4995  Method.prototype.buildCall = function() {
  4996      var method = this;
  4997      var send = function () {
  4998          var payload = method.toPayload(Array.prototype.slice.call(arguments));
  4999          if (payload.callback) {
  5000              return method.requestManager.sendAsync(payload, function (err, result) {
  5001                  payload.callback(err, method.formatOutput(result));
  5002              });
  5003          }
  5004          return method.formatOutput(method.requestManager.send(payload));
  5005      };
  5006      send.request = this.request.bind(this);
  5007      return send;
  5008  };
  5009  
  5010  /**
  5011   * Should be called to create pure JSONRPC request which can be used in batch request
  5012   *
  5013   * @method request
  5014   * @param {...} params
  5015   * @return {Object} jsonrpc request
  5016   */
  5017  Method.prototype.request = function () {
  5018      var payload = this.toPayload(Array.prototype.slice.call(arguments));
  5019      payload.format = this.formatOutput.bind(this);
  5020      return payload;
  5021  };
  5022  
  5023  module.exports = Method;
  5024  
  5025  
  5026  },{"../utils/utils":20,"./errors":26}],37:[function(require,module,exports){
  5027  /*
  5028      This file is part of web3.js.
  5029  
  5030      web3.js is free software: you can redistribute it and/or modify
  5031      it under the terms of the GNU Lesser General Public License as published by
  5032      the Free Software Foundation, either version 3 of the License, or
  5033      (at your option) any later version.
  5034  
  5035      web3.js is distributed in the hope that it will be useful,
  5036      but WITHOUT ANY WARRANTY; without even the implied warranty of
  5037      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  5038      GNU Lesser General Public License for more details.
  5039  
  5040      You should have received a copy of the GNU Lesser General Public License
  5041      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  5042  */
  5043  /** @file db.js
  5044   * @authors:
  5045   *   Marek Kotewicz <marek@ethdev.com>
  5046   * @date 2015
  5047   */
  5048  
  5049  var Method = require('../method');
  5050  
  5051  var DB = function (web3) {
  5052      this._requestManager = web3._requestManager;
  5053  
  5054      var self = this;
  5055      
  5056      methods().forEach(function(method) { 
  5057          method.attachToObject(self);
  5058          method.setRequestManager(web3._requestManager);
  5059      });
  5060  };
  5061  
  5062  var methods = function () {
  5063      var putString = new Method({
  5064          name: 'putString',
  5065          call: 'db_putString',
  5066          params: 3
  5067      });
  5068  
  5069      var getString = new Method({
  5070          name: 'getString',
  5071          call: 'db_getString',
  5072          params: 2
  5073      });
  5074  
  5075      var putHex = new Method({
  5076          name: 'putHex',
  5077          call: 'db_putHex',
  5078          params: 3
  5079      });
  5080  
  5081      var getHex = new Method({
  5082          name: 'getHex',
  5083          call: 'db_getHex',
  5084          params: 2
  5085      });
  5086  
  5087      return [
  5088          putString, getString, putHex, getHex
  5089      ];
  5090  };
  5091  
  5092  module.exports = DB;
  5093  
  5094  },{"../method":36}],38:[function(require,module,exports){
  5095  /*
  5096      This file is part of web3.js.
  5097  
  5098      web3.js is free software: you can redistribute it and/or modify
  5099      it under the terms of the GNU Lesser General Public License as published by
  5100      the Free Software Foundation, either version 3 of the License, or
  5101      (at your option) any later version.
  5102  
  5103      web3.js is distributed in the hope that it will be useful,
  5104      but WITHOUT ANY WARRANTY; without even the implied warranty of
  5105      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  5106      GNU Lesser General Public License for more details.
  5107  
  5108      You should have received a copy of the GNU Lesser General Public License
  5109      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  5110  */
  5111  /**
  5112   * @file eth.js
  5113   * @author Marek Kotewicz <marek@ethdev.com>
  5114   * @author Fabian Vogelsteller <fabian@ethdev.com>
  5115   * @date 2015
  5116   */
  5117  
  5118  "use strict";
  5119  
  5120  var formatters = require('../formatters');
  5121  var utils = require('../../utils/utils');
  5122  var Method = require('../method');
  5123  var Property = require('../property');
  5124  var c = require('../../utils/config');
  5125  var Contract = require('../contract');
  5126  var watches = require('./watches');
  5127  var Filter = require('../filter');
  5128  var IsSyncing = require('../syncing');
  5129  var namereg = require('../namereg');
  5130  var Iban = require('../iban');
  5131  var transfer = require('../transfer');
  5132  
  5133  var blockCall = function (args) {
  5134      return (utils.isString(args[0]) && args[0].indexOf('0x') === 0) ? "eth_getBlockByHash" : "eth_getBlockByNumber";
  5135  };
  5136  
  5137  var transactionFromBlockCall = function (args) {
  5138      return (utils.isString(args[0]) && args[0].indexOf('0x') === 0) ? 'eth_getTransactionByBlockHashAndIndex' : 'eth_getTransactionByBlockNumberAndIndex';
  5139  };
  5140  
  5141  var uncleCall = function (args) {
  5142      return (utils.isString(args[0]) && args[0].indexOf('0x') === 0) ? 'eth_getUncleByBlockHashAndIndex' : 'eth_getUncleByBlockNumberAndIndex';
  5143  };
  5144  
  5145  var getBlockTransactionCountCall = function (args) {
  5146      return (utils.isString(args[0]) && args[0].indexOf('0x') === 0) ? 'eth_getBlockTransactionCountByHash' : 'eth_getBlockTransactionCountByNumber';
  5147  };
  5148  
  5149  var uncleCountCall = function (args) {
  5150      return (utils.isString(args[0]) && args[0].indexOf('0x') === 0) ? 'eth_getUncleCountByBlockHash' : 'eth_getUncleCountByBlockNumber';
  5151  };
  5152  
  5153  function Eth(web3) {
  5154      this._requestManager = web3._requestManager;
  5155  
  5156      var self = this;
  5157  
  5158      methods().forEach(function(method) { 
  5159          method.attachToObject(self);
  5160          method.setRequestManager(self._requestManager);
  5161      });
  5162  
  5163      properties().forEach(function(p) { 
  5164          p.attachToObject(self);
  5165          p.setRequestManager(self._requestManager);
  5166      });
  5167  
  5168  
  5169      this.iban = Iban;
  5170      this.sendIBANTransaction = transfer.bind(null, this);
  5171  }
  5172  
  5173  Object.defineProperty(Eth.prototype, 'defaultBlock', {
  5174      get: function () {
  5175          return c.defaultBlock;
  5176      },
  5177      set: function (val) {
  5178          c.defaultBlock = val;
  5179          return val;
  5180      }
  5181  });
  5182  
  5183  Object.defineProperty(Eth.prototype, 'defaultAccount', {
  5184      get: function () {
  5185          return c.defaultAccount;
  5186      },
  5187      set: function (val) {
  5188          c.defaultAccount = val;
  5189          return val;
  5190      }
  5191  });
  5192  
  5193  var methods = function () {
  5194      var getBalance = new Method({
  5195          name: 'getBalance',
  5196          call: 'eth_getBalance',
  5197          params: 2,
  5198          inputFormatter: [formatters.inputAddressFormatter, formatters.inputDefaultBlockNumberFormatter],
  5199          outputFormatter: formatters.outputBigNumberFormatter
  5200      });
  5201  
  5202      var getStorageAt = new Method({
  5203          name: 'getStorageAt',
  5204          call: 'eth_getStorageAt',
  5205          params: 3,
  5206          inputFormatter: [null, utils.toHex, formatters.inputDefaultBlockNumberFormatter]
  5207      });
  5208  
  5209      var getCode = new Method({
  5210          name: 'getCode',
  5211          call: 'eth_getCode',
  5212          params: 2,
  5213          inputFormatter: [formatters.inputAddressFormatter, formatters.inputDefaultBlockNumberFormatter]
  5214      });
  5215  
  5216      var getBlock = new Method({
  5217          name: 'getBlock',
  5218          call: blockCall,
  5219          params: 2,
  5220          inputFormatter: [formatters.inputBlockNumberFormatter, function (val) { return !!val; }],
  5221          outputFormatter: formatters.outputBlockFormatter
  5222      });
  5223  
  5224      var getUncle = new Method({
  5225          name: 'getUncle',
  5226          call: uncleCall,
  5227          params: 2,
  5228          inputFormatter: [formatters.inputBlockNumberFormatter, utils.toHex],
  5229          outputFormatter: formatters.outputBlockFormatter,
  5230  
  5231      });
  5232  
  5233      var getCompilers = new Method({
  5234          name: 'getCompilers',
  5235          call: 'eth_getCompilers',
  5236          params: 0
  5237      });
  5238  
  5239      var getBlockTransactionCount = new Method({
  5240          name: 'getBlockTransactionCount',
  5241          call: getBlockTransactionCountCall,
  5242          params: 1,
  5243          inputFormatter: [formatters.inputBlockNumberFormatter],
  5244          outputFormatter: utils.toDecimal
  5245      });
  5246  
  5247      var getBlockUncleCount = new Method({
  5248          name: 'getBlockUncleCount',
  5249          call: uncleCountCall,
  5250          params: 1,
  5251          inputFormatter: [formatters.inputBlockNumberFormatter],
  5252          outputFormatter: utils.toDecimal
  5253      });
  5254  
  5255      var getTransaction = new Method({
  5256          name: 'getTransaction',
  5257          call: 'eth_getTransactionByHash',
  5258          params: 1,
  5259          outputFormatter: formatters.outputTransactionFormatter
  5260      });
  5261  
  5262      var getTransactionFromBlock = new Method({
  5263          name: 'getTransactionFromBlock',
  5264          call: transactionFromBlockCall,
  5265          params: 2,
  5266          inputFormatter: [formatters.inputBlockNumberFormatter, utils.toHex],
  5267          outputFormatter: formatters.outputTransactionFormatter
  5268      });
  5269  
  5270      var getTransactionReceipt = new Method({
  5271          name: 'getTransactionReceipt',
  5272          call: 'eth_getTransactionReceipt',
  5273          params: 1,
  5274          outputFormatter: formatters.outputTransactionReceiptFormatter
  5275      });
  5276  
  5277      var getTransactionCount = new Method({
  5278          name: 'getTransactionCount',
  5279          call: 'eth_getTransactionCount',
  5280          params: 2,
  5281          inputFormatter: [null, formatters.inputDefaultBlockNumberFormatter],
  5282          outputFormatter: utils.toDecimal
  5283      });
  5284  
  5285      var sendRawTransaction = new Method({
  5286          name: 'sendRawTransaction',
  5287          call: 'eth_sendRawTransaction',
  5288          params: 1,
  5289          inputFormatter: [null]
  5290      });
  5291  
  5292      var sendTransaction = new Method({
  5293          name: 'sendTransaction',
  5294          call: 'eth_sendTransaction',
  5295          params: 1,
  5296          inputFormatter: [formatters.inputTransactionFormatter]
  5297      });
  5298  
  5299      var sign = new Method({
  5300          name: 'sign',
  5301          call: 'eth_sign',
  5302          params: 2,
  5303          inputFormatter: [formatters.inputAddressFormatter, null]
  5304      });
  5305  
  5306      var call = new Method({
  5307          name: 'call',
  5308          call: 'eth_call',
  5309          params: 2,
  5310          inputFormatter: [formatters.inputCallFormatter, formatters.inputDefaultBlockNumberFormatter]
  5311      });
  5312  
  5313      var estimateGas = new Method({
  5314          name: 'estimateGas',
  5315          call: 'eth_estimateGas',
  5316          params: 1,
  5317          inputFormatter: [formatters.inputCallFormatter],
  5318          outputFormatter: utils.toDecimal
  5319      });
  5320  
  5321      var compileSolidity = new Method({
  5322          name: 'compile.solidity',
  5323          call: 'eth_compileSolidity',
  5324          params: 1
  5325      });
  5326  
  5327      var compileLLL = new Method({
  5328          name: 'compile.lll',
  5329          call: 'eth_compileLLL',
  5330          params: 1
  5331      });
  5332  
  5333      var compileSerpent = new Method({
  5334          name: 'compile.serpent',
  5335          call: 'eth_compileSerpent',
  5336          params: 1
  5337      });
  5338  
  5339      var submitWork = new Method({
  5340          name: 'submitWork',
  5341          call: 'eth_submitWork',
  5342          params: 3
  5343      });
  5344  
  5345      var getWork = new Method({
  5346          name: 'getWork',
  5347          call: 'eth_getWork',
  5348          params: 0
  5349      });
  5350  
  5351      return [
  5352          getBalance,
  5353          getStorageAt,
  5354          getCode,
  5355          getBlock,
  5356          getUncle,
  5357          getCompilers,
  5358          getBlockTransactionCount,
  5359          getBlockUncleCount,
  5360          getTransaction,
  5361          getTransactionFromBlock,
  5362          getTransactionReceipt,
  5363          getTransactionCount,
  5364          call,
  5365          estimateGas,
  5366          sendRawTransaction,
  5367          sendTransaction,
  5368          sign,
  5369          compileSolidity,
  5370          compileLLL,
  5371          compileSerpent,
  5372          submitWork,
  5373          getWork
  5374      ];
  5375  };
  5376  
  5377  
  5378  var properties = function () {
  5379      return [
  5380          new Property({
  5381              name: 'coinbase',
  5382              getter: 'eth_coinbase'
  5383          }),
  5384          new Property({
  5385              name: 'mining',
  5386              getter: 'eth_mining'
  5387          }),
  5388          new Property({
  5389              name: 'hashrate',
  5390              getter: 'eth_hashrate',
  5391              outputFormatter: utils.toDecimal
  5392          }),
  5393          new Property({
  5394              name: 'syncing',
  5395              getter: 'eth_syncing',
  5396              outputFormatter: formatters.outputSyncingFormatter
  5397          }),
  5398          new Property({
  5399              name: 'gasPrice',
  5400              getter: 'eth_gasPrice',
  5401              outputFormatter: formatters.outputBigNumberFormatter
  5402          }),
  5403          new Property({
  5404              name: 'accounts',
  5405              getter: 'eth_accounts'
  5406          }),
  5407          new Property({
  5408              name: 'blockNumber',
  5409              getter: 'eth_blockNumber',
  5410              outputFormatter: utils.toDecimal
  5411          }),
  5412          new Property({
  5413              name: 'protocolVersion',
  5414              getter: 'eth_protocolVersion'
  5415          })
  5416      ];
  5417  };
  5418  
  5419  Eth.prototype.contract = function (abi) {
  5420      var factory = new Contract(this, abi);
  5421      return factory;
  5422  };
  5423  
  5424  Eth.prototype.filter = function (fil, callback) {
  5425      return new Filter(this._requestManager, fil, watches.eth(), formatters.outputLogFormatter, callback);
  5426  };
  5427  
  5428  Eth.prototype.namereg = function () {
  5429      return this.contract(namereg.global.abi).at(namereg.global.address);
  5430  };
  5431  
  5432  Eth.prototype.icapNamereg = function () {
  5433      return this.contract(namereg.icap.abi).at(namereg.icap.address);
  5434  };
  5435  
  5436  Eth.prototype.isSyncing = function (callback) {
  5437      return new IsSyncing(this._requestManager, callback);
  5438  };
  5439  
  5440  module.exports = Eth;
  5441  
  5442  
  5443  },{"../../utils/config":18,"../../utils/utils":20,"../contract":25,"../filter":29,"../formatters":30,"../iban":33,"../method":36,"../namereg":44,"../property":45,"../syncing":48,"../transfer":49,"./watches":43}],39:[function(require,module,exports){
  5444  /*
  5445      This file is part of web3.js.
  5446  
  5447      web3.js is free software: you can redistribute it and/or modify
  5448      it under the terms of the GNU Lesser General Public License as published by
  5449      the Free Software Foundation, either version 3 of the License, or
  5450      (at your option) any later version.
  5451  
  5452      web3.js is distributed in the hope that it will be useful,
  5453      but WITHOUT ANY WARRANTY; without even the implied warranty of
  5454      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  5455      GNU Lesser General Public License for more details.
  5456  
  5457      You should have received a copy of the GNU Lesser General Public License
  5458      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  5459  */
  5460  /** @file eth.js
  5461   * @authors:
  5462   *   Marek Kotewicz <marek@ethdev.com>
  5463   * @date 2015
  5464   */
  5465  
  5466  var utils = require('../../utils/utils');
  5467  var Property = require('../property');
  5468  
  5469  var Net = function (web3) {
  5470      this._requestManager = web3._requestManager;
  5471  
  5472      var self = this;
  5473  
  5474      properties().forEach(function(p) { 
  5475          p.attachToObject(self);
  5476          p.setRequestManager(web3._requestManager);
  5477      });
  5478  };
  5479  
  5480  /// @returns an array of objects describing web3.eth api properties
  5481  var properties = function () {
  5482      return [
  5483          new Property({
  5484              name: 'listening',
  5485              getter: 'net_listening'
  5486          }),
  5487          new Property({
  5488              name: 'peerCount',
  5489              getter: 'net_peerCount',
  5490              outputFormatter: utils.toDecimal
  5491          })
  5492      ];
  5493  };
  5494  
  5495  module.exports = Net;
  5496  
  5497  },{"../../utils/utils":20,"../property":45}],40:[function(require,module,exports){
  5498  /*
  5499      This file is part of web3.js.
  5500  
  5501      web3.js is free software: you can redistribute it and/or modify
  5502      it under the terms of the GNU Lesser General Public License as published by
  5503      the Free Software Foundation, either version 3 of the License, or
  5504      (at your option) any later version.
  5505  
  5506      web3.js is distributed in the hope that it will be useful,
  5507      but WITHOUT ANY WARRANTY; without even the implied warranty of
  5508      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  5509      GNU Lesser General Public License for more details.
  5510  
  5511      You should have received a copy of the GNU Lesser General Public License
  5512      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  5513  */
  5514  /**
  5515   * @file eth.js
  5516   * @author Marek Kotewicz <marek@ethdev.com>
  5517   * @author Fabian Vogelsteller <fabian@ethdev.com>
  5518   * @date 2015
  5519   */
  5520  
  5521  "use strict";
  5522  
  5523  var Method = require('../method');
  5524  var Property = require('../property');
  5525  var formatters = require('../formatters');
  5526  
  5527  function Personal(web3) {
  5528      this._requestManager = web3._requestManager;
  5529  
  5530      var self = this;
  5531  
  5532      methods().forEach(function(method) {
  5533          method.attachToObject(self);
  5534          method.setRequestManager(self._requestManager);
  5535      });
  5536  
  5537      properties().forEach(function(p) {
  5538          p.attachToObject(self);
  5539          p.setRequestManager(self._requestManager);
  5540      });
  5541  }
  5542  
  5543  var methods = function () {
  5544      var newAccount = new Method({
  5545          name: 'newAccount',
  5546          call: 'personal_newAccount',
  5547          params: 1,
  5548          inputFormatter: [null]
  5549      });
  5550  
  5551      var unlockAccount = new Method({
  5552          name: 'unlockAccount',
  5553          call: 'personal_unlockAccount',
  5554          params: 3,
  5555          inputFormatter: [formatters.inputAddressFormatter, null, null]
  5556      });
  5557  
  5558      var sendTransaction = new Method({
  5559          name: 'sendTransaction',
  5560          call: 'personal_sendTransaction',
  5561          params: 2,
  5562          inputFormatter: [formatters.inputTransactionFormatter, null]
  5563      });
  5564  
  5565      var lockAccount = new Method({
  5566          name: 'lockAccount',
  5567          call: 'personal_lockAccount',
  5568          params: 1,
  5569          inputFormatter: [formatters.inputAddressFormatter]
  5570      });
  5571  
  5572      return [
  5573          newAccount,
  5574          unlockAccount,
  5575          sendTransaction,
  5576          lockAccount
  5577      ];
  5578  };
  5579  
  5580  var properties = function () {
  5581      return [
  5582          new Property({
  5583              name: 'listAccounts',
  5584              getter: 'personal_listAccounts'
  5585          })
  5586      ];
  5587  };
  5588  
  5589  
  5590  module.exports = Personal;
  5591  
  5592  },{"../formatters":30,"../method":36,"../property":45}],41:[function(require,module,exports){
  5593  /*
  5594      This file is part of web3.js.
  5595  
  5596      web3.js is free software: you can redistribute it and/or modify
  5597      it under the terms of the GNU Lesser General Public License as published by
  5598      the Free Software Foundation, either version 3 of the License, or
  5599      (at your option) any later version.
  5600  
  5601      web3.js is distributed in the hope that it will be useful,
  5602      but WITHOUT ANY WARRANTY; without even the implied warranty of
  5603      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  5604      GNU Lesser General Public License for more details.
  5605  
  5606      You should have received a copy of the GNU Lesser General Public License
  5607      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  5608  */
  5609  /** @file shh.js
  5610   * @authors:
  5611   *   Marek Kotewicz <marek@ethdev.com>
  5612   * @date 2015
  5613   */
  5614  
  5615  var Method = require('../method');
  5616  var formatters = require('../formatters');
  5617  var Filter = require('../filter');
  5618  var watches = require('./watches');
  5619  
  5620  var Shh = function (web3) {
  5621      this._requestManager = web3._requestManager;
  5622  
  5623      var self = this;
  5624  
  5625      methods().forEach(function(method) { 
  5626          method.attachToObject(self);
  5627          method.setRequestManager(self._requestManager);
  5628      });
  5629  };
  5630  
  5631  Shh.prototype.filter = function (fil, callback) {
  5632      return new Filter(this._requestManager, fil, watches.shh(), formatters.outputPostFormatter, callback);
  5633  };
  5634  
  5635  var methods = function () { 
  5636  
  5637      var post = new Method({
  5638          name: 'post', 
  5639          call: 'shh_post', 
  5640          params: 1,
  5641          inputFormatter: [formatters.inputPostFormatter]
  5642      });
  5643  
  5644      var newIdentity = new Method({
  5645          name: 'newIdentity',
  5646          call: 'shh_newIdentity',
  5647          params: 0
  5648      });
  5649  
  5650      var hasIdentity = new Method({
  5651          name: 'hasIdentity',
  5652          call: 'shh_hasIdentity',
  5653          params: 1
  5654      });
  5655  
  5656      var newGroup = new Method({
  5657          name: 'newGroup',
  5658          call: 'shh_newGroup',
  5659          params: 0
  5660      });
  5661  
  5662      var addToGroup = new Method({
  5663          name: 'addToGroup',
  5664          call: 'shh_addToGroup',
  5665          params: 0
  5666      });
  5667  
  5668      return [
  5669          post,
  5670          newIdentity,
  5671          hasIdentity,
  5672          newGroup,
  5673          addToGroup
  5674      ];
  5675  };
  5676  
  5677  module.exports = Shh;
  5678  
  5679  
  5680  },{"../filter":29,"../formatters":30,"../method":36,"./watches":43}],42:[function(require,module,exports){
  5681  /*
  5682      This file is part of web3.js.
  5683  
  5684      web3.js is free software: you can redistribute it and/or modify
  5685      it under the terms of the GNU Lesser General Public License as published by
  5686      the Free Software Foundation, either version 3 of the License, or
  5687      (at your option) any later version.
  5688  
  5689      web3.js is distributed in the hope that it will be useful,
  5690      but WITHOUT ANY WARRANTY; without even the implied warranty of
  5691      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  5692      GNU Lesser General Public License for more details.
  5693  
  5694      You should have received a copy of the GNU Lesser General Public License
  5695      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  5696  */
  5697  /**
  5698   * @file bzz.js
  5699   * @author Alex Beregszaszi <alex@rtfs.hu>
  5700   * @date 2016
  5701   *
  5702   * Reference: https://github.com/ethereum/go-ethereum/blob/swarm/internal/web3ext/web3ext.go#L33
  5703   */
  5704  
  5705  "use strict";
  5706  
  5707  var Method = require('../method');
  5708  var Property = require('../property');
  5709  
  5710  function Swarm(web3) {
  5711      this._requestManager = web3._requestManager;
  5712  
  5713      var self = this;
  5714  
  5715      methods().forEach(function(method) {
  5716          method.attachToObject(self);
  5717          method.setRequestManager(self._requestManager);
  5718      });
  5719  
  5720      properties().forEach(function(p) {
  5721          p.attachToObject(self);
  5722          p.setRequestManager(self._requestManager);
  5723      });
  5724  }
  5725  
  5726  var methods = function () {
  5727      var blockNetworkRead = new Method({
  5728          name: 'blockNetworkRead',
  5729          call: 'bzz_blockNetworkRead',
  5730          params: 1,
  5731          inputFormatter: [null]
  5732      });
  5733  
  5734      var syncEnabled = new Method({
  5735          name: 'syncEnabled',
  5736          call: 'bzz_syncEnabled',
  5737          params: 1,
  5738          inputFormatter: [null]
  5739      });
  5740  
  5741      var swapEnabled = new Method({
  5742          name: 'swapEnabled',
  5743          call: 'bzz_swapEnabled',
  5744          params: 1,
  5745          inputFormatter: [null]
  5746      });
  5747  
  5748      var download = new Method({
  5749          name: 'download',
  5750          call: 'bzz_download',
  5751          params: 2,
  5752          inputFormatter: [null, null]
  5753      });
  5754  
  5755      var upload = new Method({
  5756          name: 'upload',
  5757          call: 'bzz_upload',
  5758          params: 2,
  5759          inputFormatter: [null, null]
  5760      });
  5761  
  5762      var retrieve = new Method({
  5763          name: 'retrieve',
  5764          call: 'bzz_retrieve',
  5765          params: 1,
  5766          inputFormatter: [null]
  5767      });
  5768  
  5769      var store = new Method({
  5770          name: 'store',
  5771          call: 'bzz_store',
  5772          params: 2,
  5773          inputFormatter: [null, null]
  5774      });
  5775  
  5776      var get = new Method({
  5777          name: 'get',
  5778          call: 'bzz_get',
  5779          params: 1,
  5780          inputFormatter: [null]
  5781      });
  5782  
  5783      var put = new Method({
  5784          name: 'put',
  5785          call: 'bzz_put',
  5786          params: 2,
  5787          inputFormatter: [null, null]
  5788      });
  5789  
  5790      var modify = new Method({
  5791          name: 'modify',
  5792          call: 'bzz_modify',
  5793          params: 4,
  5794          inputFormatter: [null, null, null, null]
  5795      });
  5796  
  5797      return [
  5798          blockNetworkRead,
  5799          syncEnabled,
  5800          swapEnabled,
  5801          download,
  5802          upload,
  5803          retrieve,
  5804          store,
  5805          get,
  5806          put,
  5807          modify
  5808      ];
  5809  };
  5810  
  5811  var properties = function () {
  5812      return [
  5813          new Property({
  5814              name: 'hive',
  5815              getter: 'bzz_hive'
  5816          }),
  5817          new Property({
  5818              name: 'info',
  5819              getter: 'bzz_info'
  5820          })
  5821      ];
  5822  };
  5823  
  5824  
  5825  module.exports = Swarm;
  5826  
  5827  },{"../method":36,"../property":45}],43:[function(require,module,exports){
  5828  /*
  5829      This file is part of web3.js.
  5830  
  5831      web3.js is free software: you can redistribute it and/or modify
  5832      it under the terms of the GNU Lesser General Public License as published by
  5833      the Free Software Foundation, either version 3 of the License, or
  5834      (at your option) any later version.
  5835  
  5836      web3.js is distributed in the hope that it will be useful,
  5837      but WITHOUT ANY WARRANTY; without even the implied warranty of
  5838      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  5839      GNU Lesser General Public License for more details.
  5840  
  5841      You should have received a copy of the GNU Lesser General Public License
  5842      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  5843  */
  5844  /** @file watches.js
  5845   * @authors:
  5846   *   Marek Kotewicz <marek@ethdev.com>
  5847   * @date 2015
  5848   */
  5849  
  5850  var Method = require('../method');
  5851  
  5852  /// @returns an array of objects describing web3.eth.filter api methods
  5853  var eth = function () {
  5854      var newFilterCall = function (args) {
  5855          var type = args[0];
  5856  
  5857          switch(type) {
  5858              case 'latest':
  5859                  args.shift();
  5860                  this.params = 0;
  5861                  return 'eth_newBlockFilter';
  5862              case 'pending':
  5863                  args.shift();
  5864                  this.params = 0;
  5865                  return 'eth_newPendingTransactionFilter';
  5866              default:
  5867                  return 'eth_newFilter';
  5868          }
  5869      };
  5870  
  5871      var newFilter = new Method({
  5872          name: 'newFilter',
  5873          call: newFilterCall,
  5874          params: 1
  5875      });
  5876  
  5877      var uninstallFilter = new Method({
  5878          name: 'uninstallFilter',
  5879          call: 'eth_uninstallFilter',
  5880          params: 1
  5881      });
  5882  
  5883      var getLogs = new Method({
  5884          name: 'getLogs',
  5885          call: 'eth_getFilterLogs',
  5886          params: 1
  5887      });
  5888  
  5889      var poll = new Method({
  5890          name: 'poll',
  5891          call: 'eth_getFilterChanges',
  5892          params: 1
  5893      });
  5894  
  5895      return [
  5896          newFilter,
  5897          uninstallFilter,
  5898          getLogs,
  5899          poll
  5900      ];
  5901  };
  5902  
  5903  /// @returns an array of objects describing web3.shh.watch api methods
  5904  var shh = function () {
  5905      var newFilter = new Method({
  5906          name: 'newFilter',
  5907          call: 'shh_newFilter',
  5908          params: 1
  5909      });
  5910  
  5911      var uninstallFilter = new Method({
  5912          name: 'uninstallFilter',
  5913          call: 'shh_uninstallFilter',
  5914          params: 1
  5915      });
  5916  
  5917      var getLogs = new Method({
  5918          name: 'getLogs',
  5919          call: 'shh_getMessages',
  5920          params: 1
  5921      });
  5922  
  5923      var poll = new Method({
  5924          name: 'poll',
  5925          call: 'shh_getFilterChanges',
  5926          params: 1
  5927      });
  5928  
  5929      return [
  5930          newFilter,
  5931          uninstallFilter,
  5932          getLogs,
  5933          poll
  5934      ];
  5935  };
  5936  
  5937  module.exports = {
  5938      eth: eth,
  5939      shh: shh
  5940  };
  5941  
  5942  
  5943  },{"../method":36}],44:[function(require,module,exports){
  5944  /*
  5945      This file is part of web3.js.
  5946  
  5947      web3.js is free software: you can redistribute it and/or modify
  5948      it under the terms of the GNU Lesser General Public License as published by
  5949      the Free Software Foundation, either version 3 of the License, or
  5950      (at your option) any later version.
  5951  
  5952      web3.js is distributed in the hope that it will be useful,
  5953      but WITHOUT ANY WARRANTY; without even the implied warranty of
  5954      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  5955      GNU Lesser General Public License for more details.
  5956  
  5957      You should have received a copy of the GNU Lesser General Public License
  5958      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  5959  */
  5960  /** 
  5961   * @file namereg.js
  5962   * @author Marek Kotewicz <marek@ethdev.com>
  5963   * @date 2015
  5964   */
  5965  
  5966  var globalRegistrarAbi = require('../contracts/GlobalRegistrar.json');
  5967  var icapRegistrarAbi= require('../contracts/ICAPRegistrar.json');
  5968  
  5969  var globalNameregAddress = '0xc6d9d2cd449a754c494264e1809c50e34d64562b';
  5970  var icapNameregAddress = '0xa1a111bc074c9cfa781f0c38e63bd51c91b8af00';
  5971  
  5972  module.exports = {
  5973      global: {
  5974          abi: globalRegistrarAbi,
  5975          address: globalNameregAddress
  5976      },
  5977      icap: {
  5978          abi: icapRegistrarAbi,
  5979          address: icapNameregAddress
  5980      }
  5981  };
  5982  
  5983  
  5984  },{"../contracts/GlobalRegistrar.json":1,"../contracts/ICAPRegistrar.json":2}],45:[function(require,module,exports){
  5985  /*
  5986      This file is part of web3.js.
  5987  
  5988      web3.js is free software: you can redistribute it and/or modify
  5989      it under the terms of the GNU Lesser General Public License as published by
  5990      the Free Software Foundation, either version 3 of the License, or
  5991      (at your option) any later version.
  5992  
  5993      web3.js is distributed in the hope that it will be useful,
  5994      but WITHOUT ANY WARRANTY; without even the implied warranty of
  5995      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  5996      GNU Lesser General Public License for more details.
  5997  
  5998      You should have received a copy of the GNU Lesser General Public License
  5999      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  6000  */
  6001  /**
  6002   * @file property.js
  6003   * @author Fabian Vogelsteller <fabian@frozeman.de>
  6004   * @author Marek Kotewicz <marek@ethdev.com>
  6005   * @date 2015
  6006   */
  6007  
  6008  var utils = require('../utils/utils');
  6009  
  6010  var Property = function (options) {
  6011      this.name = options.name;
  6012      this.getter = options.getter;
  6013      this.setter = options.setter;
  6014      this.outputFormatter = options.outputFormatter;
  6015      this.inputFormatter = options.inputFormatter;
  6016      this.requestManager = null;
  6017  };
  6018  
  6019  Property.prototype.setRequestManager = function (rm) {
  6020      this.requestManager = rm;
  6021  };
  6022  
  6023  /**
  6024   * Should be called to format input args of method
  6025   *
  6026   * @method formatInput
  6027   * @param {Array}
  6028   * @return {Array}
  6029   */
  6030  Property.prototype.formatInput = function (arg) {
  6031      return this.inputFormatter ? this.inputFormatter(arg) : arg;
  6032  };
  6033  
  6034  /**
  6035   * Should be called to format output(result) of method
  6036   *
  6037   * @method formatOutput
  6038   * @param {Object}
  6039   * @return {Object}
  6040   */
  6041  Property.prototype.formatOutput = function (result) {
  6042      return this.outputFormatter && result !== null && result !== undefined ? this.outputFormatter(result) : result;
  6043  };
  6044  
  6045  /**
  6046   * Should be used to extract callback from array of arguments. Modifies input param
  6047   *
  6048   * @method extractCallback
  6049   * @param {Array} arguments
  6050   * @return {Function|Null} callback, if exists
  6051   */
  6052  Property.prototype.extractCallback = function (args) {
  6053      if (utils.isFunction(args[args.length - 1])) {
  6054          return args.pop(); // modify the args array!
  6055      }
  6056  };
  6057  
  6058  
  6059  /**
  6060   * Should attach function to method
  6061   *
  6062   * @method attachToObject
  6063   * @param {Object}
  6064   * @param {Function}
  6065   */
  6066  Property.prototype.attachToObject = function (obj) {
  6067      var proto = {
  6068          get: this.buildGet(),
  6069          enumerable: true
  6070      };
  6071  
  6072      var names = this.name.split('.');
  6073      var name = names[0];
  6074      if (names.length > 1) {
  6075          obj[names[0]] = obj[names[0]] || {};
  6076          obj = obj[names[0]];
  6077          name = names[1];
  6078      }
  6079  
  6080      Object.defineProperty(obj, name, proto);
  6081      obj[asyncGetterName(name)] = this.buildAsyncGet();
  6082  };
  6083  
  6084  var asyncGetterName = function (name) {
  6085      return 'get' + name.charAt(0).toUpperCase() + name.slice(1);
  6086  };
  6087  
  6088  Property.prototype.buildGet = function () {
  6089      var property = this;
  6090      return function get() {
  6091          return property.formatOutput(property.requestManager.send({
  6092              method: property.getter
  6093          }));
  6094      };
  6095  };
  6096  
  6097  Property.prototype.buildAsyncGet = function () {
  6098      var property = this;
  6099      var get = function (callback) {
  6100          property.requestManager.sendAsync({
  6101              method: property.getter
  6102          }, function (err, result) {
  6103              callback(err, property.formatOutput(result));
  6104          });
  6105      };
  6106      get.request = this.request.bind(this);
  6107      return get;
  6108  };
  6109  
  6110  /**
  6111   * Should be called to create pure JSONRPC request which can be used in batch request
  6112   *
  6113   * @method request
  6114   * @param {...} params
  6115   * @return {Object} jsonrpc request
  6116   */
  6117  Property.prototype.request = function () {
  6118      var payload = {
  6119          method: this.getter,
  6120          params: [],
  6121          callback: this.extractCallback(Array.prototype.slice.call(arguments))
  6122      };
  6123      payload.format = this.formatOutput.bind(this);
  6124      return payload;
  6125  };
  6126  
  6127  module.exports = Property;
  6128  
  6129  
  6130  },{"../utils/utils":20}],46:[function(require,module,exports){
  6131  /*
  6132      This file is part of web3.js.
  6133  
  6134      web3.js is free software: you can redistribute it and/or modify
  6135      it under the terms of the GNU Lesser General Public License as published by
  6136      the Free Software Foundation, either version 3 of the License, or
  6137      (at your option) any later version.
  6138  
  6139      web3.js is distributed in the hope that it will be useful,
  6140      but WITHOUT ANY WARRANTY; without even the implied warranty of
  6141      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  6142      GNU Lesser General Public License for more details.
  6143  
  6144      You should have received a copy of the GNU Lesser General Public License
  6145      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  6146  */
  6147  /** 
  6148   * @file requestmanager.js
  6149   * @author Jeffrey Wilcke <jeff@ethdev.com>
  6150   * @author Marek Kotewicz <marek@ethdev.com>
  6151   * @author Marian Oancea <marian@ethdev.com>
  6152   * @author Fabian Vogelsteller <fabian@ethdev.com>
  6153   * @author Gav Wood <g@ethdev.com>
  6154   * @date 2014
  6155   */
  6156  
  6157  var Jsonrpc = require('./jsonrpc');
  6158  var utils = require('../utils/utils');
  6159  var c = require('../utils/config');
  6160  var errors = require('./errors');
  6161  
  6162  /**
  6163   * It's responsible for passing messages to providers
  6164   * It's also responsible for polling the ethereum node for incoming messages
  6165   * Default poll timeout is 1 second
  6166   * Singleton
  6167   */
  6168  var RequestManager = function (provider) {
  6169      this.provider = provider;
  6170      this.polls = {};
  6171      this.timeout = null;
  6172  };
  6173  
  6174  /**
  6175   * Should be used to synchronously send request
  6176   *
  6177   * @method send
  6178   * @param {Object} data
  6179   * @return {Object}
  6180   */
  6181  RequestManager.prototype.send = function (data) {
  6182      if (!this.provider) {
  6183          console.error(errors.InvalidProvider());
  6184          return null;
  6185      }
  6186  
  6187      var payload = Jsonrpc.toPayload(data.method, data.params);
  6188      var result = this.provider.send(payload);
  6189  
  6190      if (!Jsonrpc.isValidResponse(result)) {
  6191          throw errors.InvalidResponse(result);
  6192      }
  6193  
  6194      return result.result;
  6195  };
  6196  
  6197  /**
  6198   * Should be used to asynchronously send request
  6199   *
  6200   * @method sendAsync
  6201   * @param {Object} data
  6202   * @param {Function} callback
  6203   */
  6204  RequestManager.prototype.sendAsync = function (data, callback) {
  6205      if (!this.provider) {
  6206          return callback(errors.InvalidProvider());
  6207      }
  6208  
  6209      var payload = Jsonrpc.toPayload(data.method, data.params);
  6210      this.provider.sendAsync(payload, function (err, result) {
  6211          if (err) {
  6212              return callback(err);
  6213          }
  6214          
  6215          if (!Jsonrpc.isValidResponse(result)) {
  6216              return callback(errors.InvalidResponse(result));
  6217          }
  6218  
  6219          callback(null, result.result);
  6220      });
  6221  };
  6222  
  6223  /**
  6224   * Should be called to asynchronously send batch request
  6225   *
  6226   * @method sendBatch
  6227   * @param {Array} batch data
  6228   * @param {Function} callback
  6229   */
  6230  RequestManager.prototype.sendBatch = function (data, callback) {
  6231      if (!this.provider) {
  6232          return callback(errors.InvalidProvider());
  6233      }
  6234  
  6235      var payload = Jsonrpc.toBatchPayload(data);
  6236  
  6237      this.provider.sendAsync(payload, function (err, results) {
  6238          if (err) {
  6239              return callback(err);
  6240          }
  6241  
  6242          if (!utils.isArray(results)) {
  6243              return callback(errors.InvalidResponse(results));
  6244          }
  6245  
  6246          callback(err, results);
  6247      }); 
  6248  };
  6249  
  6250  /**
  6251   * Should be used to set provider of request manager
  6252   *
  6253   * @method setProvider
  6254   * @param {Object}
  6255   */
  6256  RequestManager.prototype.setProvider = function (p) {
  6257      this.provider = p;
  6258  };
  6259  
  6260  /**
  6261   * Should be used to start polling
  6262   *
  6263   * @method startPolling
  6264   * @param {Object} data
  6265   * @param {Number} pollId
  6266   * @param {Function} callback
  6267   * @param {Function} uninstall
  6268   *
  6269   * @todo cleanup number of params
  6270   */
  6271  RequestManager.prototype.startPolling = function (data, pollId, callback, uninstall) {
  6272      this.polls[pollId] = {data: data, id: pollId, callback: callback, uninstall: uninstall};
  6273  
  6274  
  6275      // start polling
  6276      if (!this.timeout) {
  6277          this.poll();
  6278      }
  6279  };
  6280  
  6281  /**
  6282   * Should be used to stop polling for filter with given id
  6283   *
  6284   * @method stopPolling
  6285   * @param {Number} pollId
  6286   */
  6287  RequestManager.prototype.stopPolling = function (pollId) {
  6288      delete this.polls[pollId];
  6289  
  6290      // stop polling
  6291      if(Object.keys(this.polls).length === 0 && this.timeout) {
  6292          clearTimeout(this.timeout);
  6293          this.timeout = null;
  6294      }
  6295  };
  6296  
  6297  /**
  6298   * Should be called to reset the polling mechanism of the request manager
  6299   *
  6300   * @method reset
  6301   */
  6302  RequestManager.prototype.reset = function (keepIsSyncing) {
  6303      /*jshint maxcomplexity:5 */
  6304  
  6305      for (var key in this.polls) {
  6306          // remove all polls, except sync polls,
  6307          // they need to be removed manually by calling syncing.stopWatching()
  6308          if(!keepIsSyncing || key.indexOf('syncPoll_') === -1) {
  6309              this.polls[key].uninstall();
  6310              delete this.polls[key];
  6311          }
  6312      }
  6313  
  6314      // stop polling
  6315      if(Object.keys(this.polls).length === 0 && this.timeout) {
  6316          clearTimeout(this.timeout);
  6317          this.timeout = null;
  6318      }
  6319  };
  6320  
  6321  /**
  6322   * Should be called to poll for changes on filter with given id
  6323   *
  6324   * @method poll
  6325   */
  6326  RequestManager.prototype.poll = function () {
  6327      /*jshint maxcomplexity: 6 */
  6328      this.timeout = setTimeout(this.poll.bind(this), c.ETH_POLLING_TIMEOUT);
  6329  
  6330      if (Object.keys(this.polls).length === 0) {
  6331          return;
  6332      }
  6333  
  6334      if (!this.provider) {
  6335          console.error(errors.InvalidProvider());
  6336          return;
  6337      }
  6338  
  6339      var pollsData = [];
  6340      var pollsIds = [];
  6341      for (var key in this.polls) {
  6342          pollsData.push(this.polls[key].data);
  6343          pollsIds.push(key);
  6344      }
  6345  
  6346      if (pollsData.length === 0) {
  6347          return;
  6348      }
  6349  
  6350      var payload = Jsonrpc.toBatchPayload(pollsData);
  6351      
  6352      // map the request id to they poll id
  6353      var pollsIdMap = {};
  6354      payload.forEach(function(load, index){
  6355          pollsIdMap[load.id] = pollsIds[index];
  6356      });
  6357  
  6358  
  6359      var self = this;
  6360      this.provider.sendAsync(payload, function (error, results) {
  6361  
  6362  
  6363          // TODO: console log?
  6364          if (error) {
  6365              return;
  6366          }
  6367  
  6368          if (!utils.isArray(results)) {
  6369              throw errors.InvalidResponse(results);
  6370          }
  6371          results.map(function (result) {
  6372              var id = pollsIdMap[result.id];
  6373  
  6374              // make sure the filter is still installed after arrival of the request
  6375              if (self.polls[id]) {
  6376                  result.callback = self.polls[id].callback;
  6377                  return result;
  6378              } else
  6379                  return false;
  6380          }).filter(function (result) {
  6381              return !!result; 
  6382          }).filter(function (result) {
  6383              var valid = Jsonrpc.isValidResponse(result);
  6384              if (!valid) {
  6385                  result.callback(errors.InvalidResponse(result));
  6386              }
  6387              return valid;
  6388          }).forEach(function (result) {
  6389              result.callback(null, result.result);
  6390          });
  6391      });
  6392  };
  6393  
  6394  module.exports = RequestManager;
  6395  
  6396  
  6397  },{"../utils/config":18,"../utils/utils":20,"./errors":26,"./jsonrpc":35}],47:[function(require,module,exports){
  6398  
  6399  
  6400  var Settings = function () {
  6401      this.defaultBlock = 'latest';
  6402      this.defaultAccount = undefined;
  6403  };
  6404  
  6405  module.exports = Settings;
  6406  
  6407  
  6408  },{}],48:[function(require,module,exports){
  6409  /*
  6410      This file is part of web3.js.
  6411  
  6412      web3.js is free software: you can redistribute it and/or modify
  6413      it under the terms of the GNU Lesser General Public License as published by
  6414      the Free Software Foundation, either version 3 of the License, or
  6415      (at your option) any later version.
  6416  
  6417      web3.js is distributed in the hope that it will be useful,
  6418      but WITHOUT ANY WARRANTY; without even the implied warranty of
  6419      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  6420      GNU Lesser General Public License for more details.
  6421  
  6422      You should have received a copy of the GNU Lesser General Public License
  6423      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  6424  */
  6425  /** @file syncing.js
  6426   * @authors:
  6427   *   Fabian Vogelsteller <fabian@ethdev.com>
  6428   * @date 2015
  6429   */
  6430  
  6431  var formatters = require('./formatters');
  6432  var utils = require('../utils/utils');
  6433  
  6434  var count = 1;
  6435  
  6436  /**
  6437  Adds the callback and sets up the methods, to iterate over the results.
  6438  
  6439  @method pollSyncing
  6440  @param {Object} self
  6441  */
  6442  var pollSyncing = function(self) {
  6443  
  6444      var onMessage = function (error, sync) {
  6445          if (error) {
  6446              return self.callbacks.forEach(function (callback) {
  6447                  callback(error);
  6448              });
  6449          }
  6450  
  6451          if(utils.isObject(sync) && sync.startingBlock)
  6452              sync = formatters.outputSyncingFormatter(sync);
  6453  
  6454          self.callbacks.forEach(function (callback) {
  6455              if (self.lastSyncState !== sync) {
  6456                  
  6457                  // call the callback with true first so the app can stop anything, before receiving the sync data
  6458                  if(!self.lastSyncState && utils.isObject(sync))
  6459                      callback(null, true);
  6460                  
  6461                  // call on the next CPU cycle, so the actions of the sync stop can be processes first
  6462                  setTimeout(function() {
  6463                      callback(null, sync);
  6464                  }, 0);
  6465                  
  6466                  self.lastSyncState = sync;
  6467              }
  6468          });
  6469      };
  6470  
  6471      self.requestManager.startPolling({
  6472          method: 'eth_syncing',
  6473          params: [],
  6474      }, self.pollId, onMessage, self.stopWatching.bind(self));
  6475  
  6476  };
  6477  
  6478  var IsSyncing = function (requestManager, callback) {
  6479      this.requestManager = requestManager;
  6480      this.pollId = 'syncPoll_'+ count++;
  6481      this.callbacks = [];
  6482      this.addCallback(callback);
  6483      this.lastSyncState = false;
  6484      pollSyncing(this);
  6485  
  6486      return this;
  6487  };
  6488  
  6489  IsSyncing.prototype.addCallback = function (callback) {
  6490      if(callback)
  6491          this.callbacks.push(callback);
  6492      return this;
  6493  };
  6494  
  6495  IsSyncing.prototype.stopWatching = function () {
  6496      this.requestManager.stopPolling(this.pollId);
  6497      this.callbacks = [];
  6498  };
  6499  
  6500  module.exports = IsSyncing;
  6501  
  6502  
  6503  },{"../utils/utils":20,"./formatters":30}],49:[function(require,module,exports){
  6504  /*
  6505      This file is part of web3.js.
  6506  
  6507      web3.js is free software: you can redistribute it and/or modify
  6508      it under the terms of the GNU Lesser General Public License as published by
  6509      the Free Software Foundation, either version 3 of the License, or
  6510      (at your option) any later version.
  6511  
  6512      web3.js is distributed in the hope that it will be useful,
  6513      but WITHOUT ANY WARRANTY; without even the implied warranty of
  6514      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  6515      GNU Lesser General Public License for more details.
  6516  
  6517      You should have received a copy of the GNU Lesser General Public License
  6518      along with web3.js.  If not, see <http://www.gnu.org/licenses/>.
  6519  */
  6520  /** 
  6521   * @file transfer.js
  6522   * @author Marek Kotewicz <marek@ethdev.com>
  6523   * @date 2015
  6524   */
  6525  
  6526  var Iban = require('./iban');
  6527  var exchangeAbi = require('../contracts/SmartExchange.json');
  6528  
  6529  /**
  6530   * Should be used to make Iban transfer
  6531   *
  6532   * @method transfer
  6533   * @param {String} from
  6534   * @param {String} to iban
  6535   * @param {Value} value to be tranfered
  6536   * @param {Function} callback, callback
  6537   */
  6538  var transfer = function (eth, from, to, value, callback) {
  6539      var iban = new Iban(to); 
  6540      if (!iban.isValid()) {
  6541          throw new Error('invalid iban address');
  6542      }
  6543  
  6544      if (iban.isDirect()) {
  6545          return transferToAddress(eth, from, iban.address(), value, callback);
  6546      }
  6547      
  6548      if (!callback) {
  6549          var address = eth.icapNamereg().addr(iban.institution());
  6550          return deposit(eth, from, address, value, iban.client());
  6551      }
  6552  
  6553      eth.icapNamereg().addr(iban.institution(), function (err, address) {
  6554          return deposit(eth, from, address, value, iban.client(), callback);
  6555      });
  6556      
  6557  };
  6558  
  6559  /**
  6560   * Should be used to transfer funds to certain address
  6561   *
  6562   * @method transferToAddress
  6563   * @param {String} from
  6564   * @param {String} to
  6565   * @param {Value} value to be tranfered
  6566   * @param {Function} callback, callback
  6567   */
  6568  var transferToAddress = function (eth, from, to, value, callback) {
  6569      return eth.sendTransaction({
  6570          address: to,
  6571          from: from,
  6572          value: value
  6573      }, callback);
  6574  };
  6575  
  6576  /**
  6577   * Should be used to deposit funds to generic Exchange contract (must implement deposit(bytes32) method!)
  6578   *
  6579   * @method deposit
  6580   * @param {String} from
  6581   * @param {String} to
  6582   * @param {Value} value to be transfered
  6583   * @param {String} client unique identifier
  6584   * @param {Function} callback, callback
  6585   */
  6586  var deposit = function (eth, from, to, value, client, callback) {
  6587      var abi = exchangeAbi;
  6588      return eth.contract(abi).at(to).deposit(client, {
  6589          from: from,
  6590          value: value
  6591      }, callback);
  6592  };
  6593  
  6594  module.exports = transfer;
  6595  
  6596  
  6597  },{"../contracts/SmartExchange.json":3,"./iban":33}],50:[function(require,module,exports){
  6598  
  6599  },{}],51:[function(require,module,exports){
  6600  ;(function (root, factory, undef) {
  6601  	if (typeof exports === "object") {
  6602  		// CommonJS
  6603  		module.exports = exports = factory(require("./core"), require("./enc-base64"), require("./md5"), require("./evpkdf"), require("./cipher-core"));
  6604  	}
  6605  	else if (typeof define === "function" && define.amd) {
  6606  		// AMD
  6607  		define(["./core", "./enc-base64", "./md5", "./evpkdf", "./cipher-core"], factory);
  6608  	}
  6609  	else {
  6610  		// Global (browser)
  6611  		factory(root.CryptoJS);
  6612  	}
  6613  }(this, function (CryptoJS) {
  6614  
  6615  	(function () {
  6616  	    // Shortcuts
  6617  	    var C = CryptoJS;
  6618  	    var C_lib = C.lib;
  6619  	    var BlockCipher = C_lib.BlockCipher;
  6620  	    var C_algo = C.algo;
  6621  
  6622  	    // Lookup tables
  6623  	    var SBOX = [];
  6624  	    var INV_SBOX = [];
  6625  	    var SUB_MIX_0 = [];
  6626  	    var SUB_MIX_1 = [];
  6627  	    var SUB_MIX_2 = [];
  6628  	    var SUB_MIX_3 = [];
  6629  	    var INV_SUB_MIX_0 = [];
  6630  	    var INV_SUB_MIX_1 = [];
  6631  	    var INV_SUB_MIX_2 = [];
  6632  	    var INV_SUB_MIX_3 = [];
  6633  
  6634  	    // Compute lookup tables
  6635  	    (function () {
  6636  	        // Compute double table
  6637  	        var d = [];
  6638  	        for (var i = 0; i < 256; i++) {
  6639  	            if (i < 128) {
  6640  	                d[i] = i << 1;
  6641  	            } else {
  6642  	                d[i] = (i << 1) ^ 0x11b;
  6643  	            }
  6644  	        }
  6645  
  6646  	        // Walk GF(2^8)
  6647  	        var x = 0;
  6648  	        var xi = 0;
  6649  	        for (var i = 0; i < 256; i++) {
  6650  	            // Compute sbox
  6651  	            var sx = xi ^ (xi << 1) ^ (xi << 2) ^ (xi << 3) ^ (xi << 4);
  6652  	            sx = (sx >>> 8) ^ (sx & 0xff) ^ 0x63;
  6653  	            SBOX[x] = sx;
  6654  	            INV_SBOX[sx] = x;
  6655  
  6656  	            // Compute multiplication
  6657  	            var x2 = d[x];
  6658  	            var x4 = d[x2];
  6659  	            var x8 = d[x4];
  6660  
  6661  	            // Compute sub bytes, mix columns tables
  6662  	            var t = (d[sx] * 0x101) ^ (sx * 0x1010100);
  6663  	            SUB_MIX_0[x] = (t << 24) | (t >>> 8);
  6664  	            SUB_MIX_1[x] = (t << 16) | (t >>> 16);
  6665  	            SUB_MIX_2[x] = (t << 8)  | (t >>> 24);
  6666  	            SUB_MIX_3[x] = t;
  6667  
  6668  	            // Compute inv sub bytes, inv mix columns tables
  6669  	            var t = (x8 * 0x1010101) ^ (x4 * 0x10001) ^ (x2 * 0x101) ^ (x * 0x1010100);
  6670  	            INV_SUB_MIX_0[sx] = (t << 24) | (t >>> 8);
  6671  	            INV_SUB_MIX_1[sx] = (t << 16) | (t >>> 16);
  6672  	            INV_SUB_MIX_2[sx] = (t << 8)  | (t >>> 24);
  6673  	            INV_SUB_MIX_3[sx] = t;
  6674  
  6675  	            // Compute next counter
  6676  	            if (!x) {
  6677  	                x = xi = 1;
  6678  	            } else {
  6679  	                x = x2 ^ d[d[d[x8 ^ x2]]];
  6680  	                xi ^= d[d[xi]];
  6681  	            }
  6682  	        }
  6683  	    }());
  6684  
  6685  	    // Precomputed Rcon lookup
  6686  	    var RCON = [0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36];
  6687  
  6688  	    /**
  6689  	     * AES block cipher algorithm.
  6690  	     */
  6691  	    var AES = C_algo.AES = BlockCipher.extend({
  6692  	        _doReset: function () {
  6693  	            // Skip reset of nRounds has been set before and key did not change
  6694  	            if (this._nRounds && this._keyPriorReset === this._key) {
  6695  	                return;
  6696  	            }
  6697  
  6698  	            // Shortcuts
  6699  	            var key = this._keyPriorReset = this._key;
  6700  	            var keyWords = key.words;
  6701  	            var keySize = key.sigBytes / 4;
  6702  
  6703  	            // Compute number of rounds
  6704  	            var nRounds = this._nRounds = keySize + 6;
  6705  
  6706  	            // Compute number of key schedule rows
  6707  	            var ksRows = (nRounds + 1) * 4;
  6708  
  6709  	            // Compute key schedule
  6710  	            var keySchedule = this._keySchedule = [];
  6711  	            for (var ksRow = 0; ksRow < ksRows; ksRow++) {
  6712  	                if (ksRow < keySize) {
  6713  	                    keySchedule[ksRow] = keyWords[ksRow];
  6714  	                } else {
  6715  	                    var t = keySchedule[ksRow - 1];
  6716  
  6717  	                    if (!(ksRow % keySize)) {
  6718  	                        // Rot word
  6719  	                        t = (t << 8) | (t >>> 24);
  6720  
  6721  	                        // Sub word
  6722  	                        t = (SBOX[t >>> 24] << 24) | (SBOX[(t >>> 16) & 0xff] << 16) | (SBOX[(t >>> 8) & 0xff] << 8) | SBOX[t & 0xff];
  6723  
  6724  	                        // Mix Rcon
  6725  	                        t ^= RCON[(ksRow / keySize) | 0] << 24;
  6726  	                    } else if (keySize > 6 && ksRow % keySize == 4) {
  6727  	                        // Sub word
  6728  	                        t = (SBOX[t >>> 24] << 24) | (SBOX[(t >>> 16) & 0xff] << 16) | (SBOX[(t >>> 8) & 0xff] << 8) | SBOX[t & 0xff];
  6729  	                    }
  6730  
  6731  	                    keySchedule[ksRow] = keySchedule[ksRow - keySize] ^ t;
  6732  	                }
  6733  	            }
  6734  
  6735  	            // Compute inv key schedule
  6736  	            var invKeySchedule = this._invKeySchedule = [];
  6737  	            for (var invKsRow = 0; invKsRow < ksRows; invKsRow++) {
  6738  	                var ksRow = ksRows - invKsRow;
  6739  
  6740  	                if (invKsRow % 4) {
  6741  	                    var t = keySchedule[ksRow];
  6742  	                } else {
  6743  	                    var t = keySchedule[ksRow - 4];
  6744  	                }
  6745  
  6746  	                if (invKsRow < 4 || ksRow <= 4) {
  6747  	                    invKeySchedule[invKsRow] = t;
  6748  	                } else {
  6749  	                    invKeySchedule[invKsRow] = INV_SUB_MIX_0[SBOX[t >>> 24]] ^ INV_SUB_MIX_1[SBOX[(t >>> 16) & 0xff]] ^
  6750  	                                               INV_SUB_MIX_2[SBOX[(t >>> 8) & 0xff]] ^ INV_SUB_MIX_3[SBOX[t & 0xff]];
  6751  	                }
  6752  	            }
  6753  	        },
  6754  
  6755  	        encryptBlock: function (M, offset) {
  6756  	            this._doCryptBlock(M, offset, this._keySchedule, SUB_MIX_0, SUB_MIX_1, SUB_MIX_2, SUB_MIX_3, SBOX);
  6757  	        },
  6758  
  6759  	        decryptBlock: function (M, offset) {
  6760  	            // Swap 2nd and 4th rows
  6761  	            var t = M[offset + 1];
  6762  	            M[offset + 1] = M[offset + 3];
  6763  	            M[offset + 3] = t;
  6764  
  6765  	            this._doCryptBlock(M, offset, this._invKeySchedule, INV_SUB_MIX_0, INV_SUB_MIX_1, INV_SUB_MIX_2, INV_SUB_MIX_3, INV_SBOX);
  6766  
  6767  	            // Inv swap 2nd and 4th rows
  6768  	            var t = M[offset + 1];
  6769  	            M[offset + 1] = M[offset + 3];
  6770  	            M[offset + 3] = t;
  6771  	        },
  6772  
  6773  	        _doCryptBlock: function (M, offset, keySchedule, SUB_MIX_0, SUB_MIX_1, SUB_MIX_2, SUB_MIX_3, SBOX) {
  6774  	            // Shortcut
  6775  	            var nRounds = this._nRounds;
  6776  
  6777  	            // Get input, add round key
  6778  	            var s0 = M[offset]     ^ keySchedule[0];
  6779  	            var s1 = M[offset + 1] ^ keySchedule[1];
  6780  	            var s2 = M[offset + 2] ^ keySchedule[2];
  6781  	            var s3 = M[offset + 3] ^ keySchedule[3];
  6782  
  6783  	            // Key schedule row counter
  6784  	            var ksRow = 4;
  6785  
  6786  	            // Rounds
  6787  	            for (var round = 1; round < nRounds; round++) {
  6788  	                // Shift rows, sub bytes, mix columns, add round key
  6789  	                var t0 = SUB_MIX_0[s0 >>> 24] ^ SUB_MIX_1[(s1 >>> 16) & 0xff] ^ SUB_MIX_2[(s2 >>> 8) & 0xff] ^ SUB_MIX_3[s3 & 0xff] ^ keySchedule[ksRow++];
  6790  	                var t1 = SUB_MIX_0[s1 >>> 24] ^ SUB_MIX_1[(s2 >>> 16) & 0xff] ^ SUB_MIX_2[(s3 >>> 8) & 0xff] ^ SUB_MIX_3[s0 & 0xff] ^ keySchedule[ksRow++];
  6791  	                var t2 = SUB_MIX_0[s2 >>> 24] ^ SUB_MIX_1[(s3 >>> 16) & 0xff] ^ SUB_MIX_2[(s0 >>> 8) & 0xff] ^ SUB_MIX_3[s1 & 0xff] ^ keySchedule[ksRow++];
  6792  	                var t3 = SUB_MIX_0[s3 >>> 24] ^ SUB_MIX_1[(s0 >>> 16) & 0xff] ^ SUB_MIX_2[(s1 >>> 8) & 0xff] ^ SUB_MIX_3[s2 & 0xff] ^ keySchedule[ksRow++];
  6793  
  6794  	                // Update state
  6795  	                s0 = t0;
  6796  	                s1 = t1;
  6797  	                s2 = t2;
  6798  	                s3 = t3;
  6799  	            }
  6800  
  6801  	            // Shift rows, sub bytes, add round key
  6802  	            var t0 = ((SBOX[s0 >>> 24] << 24) | (SBOX[(s1 >>> 16) & 0xff] << 16) | (SBOX[(s2 >>> 8) & 0xff] << 8) | SBOX[s3 & 0xff]) ^ keySchedule[ksRow++];
  6803  	            var t1 = ((SBOX[s1 >>> 24] << 24) | (SBOX[(s2 >>> 16) & 0xff] << 16) | (SBOX[(s3 >>> 8) & 0xff] << 8) | SBOX[s0 & 0xff]) ^ keySchedule[ksRow++];
  6804  	            var t2 = ((SBOX[s2 >>> 24] << 24) | (SBOX[(s3 >>> 16) & 0xff] << 16) | (SBOX[(s0 >>> 8) & 0xff] << 8) | SBOX[s1 & 0xff]) ^ keySchedule[ksRow++];
  6805  	            var t3 = ((SBOX[s3 >>> 24] << 24) | (SBOX[(s0 >>> 16) & 0xff] << 16) | (SBOX[(s1 >>> 8) & 0xff] << 8) | SBOX[s2 & 0xff]) ^ keySchedule[ksRow++];
  6806  
  6807  	            // Set output
  6808  	            M[offset]     = t0;
  6809  	            M[offset + 1] = t1;
  6810  	            M[offset + 2] = t2;
  6811  	            M[offset + 3] = t3;
  6812  	        },
  6813  
  6814  	        keySize: 256/32
  6815  	    });
  6816  
  6817  	    /**
  6818  	     * Shortcut functions to the cipher's object interface.
  6819  	     *
  6820  	     * @example
  6821  	     *
  6822  	     *     var ciphertext = CryptoJS.AES.encrypt(message, key, cfg);
  6823  	     *     var plaintext  = CryptoJS.AES.decrypt(ciphertext, key, cfg);
  6824  	     */
  6825  	    C.AES = BlockCipher._createHelper(AES);
  6826  	}());
  6827  
  6828  
  6829  	return CryptoJS.AES;
  6830  
  6831  }));
  6832  },{"./cipher-core":52,"./core":53,"./enc-base64":54,"./evpkdf":56,"./md5":61}],52:[function(require,module,exports){
  6833  ;(function (root, factory) {
  6834  	if (typeof exports === "object") {
  6835  		// CommonJS
  6836  		module.exports = exports = factory(require("./core"));
  6837  	}
  6838  	else if (typeof define === "function" && define.amd) {
  6839  		// AMD
  6840  		define(["./core"], factory);
  6841  	}
  6842  	else {
  6843  		// Global (browser)
  6844  		factory(root.CryptoJS);
  6845  	}
  6846  }(this, function (CryptoJS) {
  6847  
  6848  	/**
  6849  	 * Cipher core components.
  6850  	 */
  6851  	CryptoJS.lib.Cipher || (function (undefined) {
  6852  	    // Shortcuts
  6853  	    var C = CryptoJS;
  6854  	    var C_lib = C.lib;
  6855  	    var Base = C_lib.Base;
  6856  	    var WordArray = C_lib.WordArray;
  6857  	    var BufferedBlockAlgorithm = C_lib.BufferedBlockAlgorithm;
  6858  	    var C_enc = C.enc;
  6859  	    var Utf8 = C_enc.Utf8;
  6860  	    var Base64 = C_enc.Base64;
  6861  	    var C_algo = C.algo;
  6862  	    var EvpKDF = C_algo.EvpKDF;
  6863  
  6864  	    /**
  6865  	     * Abstract base cipher template.
  6866  	     *
  6867  	     * @property {number} keySize This cipher's key size. Default: 4 (128 bits)
  6868  	     * @property {number} ivSize This cipher's IV size. Default: 4 (128 bits)
  6869  	     * @property {number} _ENC_XFORM_MODE A constant representing encryption mode.
  6870  	     * @property {number} _DEC_XFORM_MODE A constant representing decryption mode.
  6871  	     */
  6872  	    var Cipher = C_lib.Cipher = BufferedBlockAlgorithm.extend({
  6873  	        /**
  6874  	         * Configuration options.
  6875  	         *
  6876  	         * @property {WordArray} iv The IV to use for this operation.
  6877  	         */
  6878  	        cfg: Base.extend(),
  6879  
  6880  	        /**
  6881  	         * Creates this cipher in encryption mode.
  6882  	         *
  6883  	         * @param {WordArray} key The key.
  6884  	         * @param {Object} cfg (Optional) The configuration options to use for this operation.
  6885  	         *
  6886  	         * @return {Cipher} A cipher instance.
  6887  	         *
  6888  	         * @static
  6889  	         *
  6890  	         * @example
  6891  	         *
  6892  	         *     var cipher = CryptoJS.algo.AES.createEncryptor(keyWordArray, { iv: ivWordArray });
  6893  	         */
  6894  	        createEncryptor: function (key, cfg) {
  6895  	            return this.create(this._ENC_XFORM_MODE, key, cfg);
  6896  	        },
  6897  
  6898  	        /**
  6899  	         * Creates this cipher in decryption mode.
  6900  	         *
  6901  	         * @param {WordArray} key The key.
  6902  	         * @param {Object} cfg (Optional) The configuration options to use for this operation.
  6903  	         *
  6904  	         * @return {Cipher} A cipher instance.
  6905  	         *
  6906  	         * @static
  6907  	         *
  6908  	         * @example
  6909  	         *
  6910  	         *     var cipher = CryptoJS.algo.AES.createDecryptor(keyWordArray, { iv: ivWordArray });
  6911  	         */
  6912  	        createDecryptor: function (key, cfg) {
  6913  	            return this.create(this._DEC_XFORM_MODE, key, cfg);
  6914  	        },
  6915  
  6916  	        /**
  6917  	         * Initializes a newly created cipher.
  6918  	         *
  6919  	         * @param {number} xformMode Either the encryption or decryption transormation mode constant.
  6920  	         * @param {WordArray} key The key.
  6921  	         * @param {Object} cfg (Optional) The configuration options to use for this operation.
  6922  	         *
  6923  	         * @example
  6924  	         *
  6925  	         *     var cipher = CryptoJS.algo.AES.create(CryptoJS.algo.AES._ENC_XFORM_MODE, keyWordArray, { iv: ivWordArray });
  6926  	         */
  6927  	        init: function (xformMode, key, cfg) {
  6928  	            // Apply config defaults
  6929  	            this.cfg = this.cfg.extend(cfg);
  6930  
  6931  	            // Store transform mode and key
  6932  	            this._xformMode = xformMode;
  6933  	            this._key = key;
  6934  
  6935  	            // Set initial values
  6936  	            this.reset();
  6937  	        },
  6938  
  6939  	        /**
  6940  	         * Resets this cipher to its initial state.
  6941  	         *
  6942  	         * @example
  6943  	         *
  6944  	         *     cipher.reset();
  6945  	         */
  6946  	        reset: function () {
  6947  	            // Reset data buffer
  6948  	            BufferedBlockAlgorithm.reset.call(this);
  6949  
  6950  	            // Perform concrete-cipher logic
  6951  	            this._doReset();
  6952  	        },
  6953  
  6954  	        /**
  6955  	         * Adds data to be encrypted or decrypted.
  6956  	         *
  6957  	         * @param {WordArray|string} dataUpdate The data to encrypt or decrypt.
  6958  	         *
  6959  	         * @return {WordArray} The data after processing.
  6960  	         *
  6961  	         * @example
  6962  	         *
  6963  	         *     var encrypted = cipher.process('data');
  6964  	         *     var encrypted = cipher.process(wordArray);
  6965  	         */
  6966  	        process: function (dataUpdate) {
  6967  	            // Append
  6968  	            this._append(dataUpdate);
  6969  
  6970  	            // Process available blocks
  6971  	            return this._process();
  6972  	        },
  6973  
  6974  	        /**
  6975  	         * Finalizes the encryption or decryption process.
  6976  	         * Note that the finalize operation is effectively a destructive, read-once operation.
  6977  	         *
  6978  	         * @param {WordArray|string} dataUpdate The final data to encrypt or decrypt.
  6979  	         *
  6980  	         * @return {WordArray} The data after final processing.
  6981  	         *
  6982  	         * @example
  6983  	         *
  6984  	         *     var encrypted = cipher.finalize();
  6985  	         *     var encrypted = cipher.finalize('data');
  6986  	         *     var encrypted = cipher.finalize(wordArray);
  6987  	         */
  6988  	        finalize: function (dataUpdate) {
  6989  	            // Final data update
  6990  	            if (dataUpdate) {
  6991  	                this._append(dataUpdate);
  6992  	            }
  6993  
  6994  	            // Perform concrete-cipher logic
  6995  	            var finalProcessedData = this._doFinalize();
  6996  
  6997  	            return finalProcessedData;
  6998  	        },
  6999  
  7000  	        keySize: 128/32,
  7001  
  7002  	        ivSize: 128/32,
  7003  
  7004  	        _ENC_XFORM_MODE: 1,
  7005  
  7006  	        _DEC_XFORM_MODE: 2,
  7007  
  7008  	        /**
  7009  	         * Creates shortcut functions to a cipher's object interface.
  7010  	         *
  7011  	         * @param {Cipher} cipher The cipher to create a helper for.
  7012  	         *
  7013  	         * @return {Object} An object with encrypt and decrypt shortcut functions.
  7014  	         *
  7015  	         * @static
  7016  	         *
  7017  	         * @example
  7018  	         *
  7019  	         *     var AES = CryptoJS.lib.Cipher._createHelper(CryptoJS.algo.AES);
  7020  	         */
  7021  	        _createHelper: (function () {
  7022  	            function selectCipherStrategy(key) {
  7023  	                if (typeof key == 'string') {
  7024  	                    return PasswordBasedCipher;
  7025  	                } else {
  7026  	                    return SerializableCipher;
  7027  	                }
  7028  	            }
  7029  
  7030  	            return function (cipher) {
  7031  	                return {
  7032  	                    encrypt: function (message, key, cfg) {
  7033  	                        return selectCipherStrategy(key).encrypt(cipher, message, key, cfg);
  7034  	                    },
  7035  
  7036  	                    decrypt: function (ciphertext, key, cfg) {
  7037  	                        return selectCipherStrategy(key).decrypt(cipher, ciphertext, key, cfg);
  7038  	                    }
  7039  	                };
  7040  	            };
  7041  	        }())
  7042  	    });
  7043  
  7044  	    /**
  7045  	     * Abstract base stream cipher template.
  7046  	     *
  7047  	     * @property {number} blockSize The number of 32-bit words this cipher operates on. Default: 1 (32 bits)
  7048  	     */
  7049  	    var StreamCipher = C_lib.StreamCipher = Cipher.extend({
  7050  	        _doFinalize: function () {
  7051  	            // Process partial blocks
  7052  	            var finalProcessedBlocks = this._process(!!'flush');
  7053  
  7054  	            return finalProcessedBlocks;
  7055  	        },
  7056  
  7057  	        blockSize: 1
  7058  	    });
  7059  
  7060  	    /**
  7061  	     * Mode namespace.
  7062  	     */
  7063  	    var C_mode = C.mode = {};
  7064  
  7065  	    /**
  7066  	     * Abstract base block cipher mode template.
  7067  	     */
  7068  	    var BlockCipherMode = C_lib.BlockCipherMode = Base.extend({
  7069  	        /**
  7070  	         * Creates this mode for encryption.
  7071  	         *
  7072  	         * @param {Cipher} cipher A block cipher instance.
  7073  	         * @param {Array} iv The IV words.
  7074  	         *
  7075  	         * @static
  7076  	         *
  7077  	         * @example
  7078  	         *
  7079  	         *     var mode = CryptoJS.mode.CBC.createEncryptor(cipher, iv.words);
  7080  	         */
  7081  	        createEncryptor: function (cipher, iv) {
  7082  	            return this.Encryptor.create(cipher, iv);
  7083  	        },
  7084  
  7085  	        /**
  7086  	         * Creates this mode for decryption.
  7087  	         *
  7088  	         * @param {Cipher} cipher A block cipher instance.
  7089  	         * @param {Array} iv The IV words.
  7090  	         *
  7091  	         * @static
  7092  	         *
  7093  	         * @example
  7094  	         *
  7095  	         *     var mode = CryptoJS.mode.CBC.createDecryptor(cipher, iv.words);
  7096  	         */
  7097  	        createDecryptor: function (cipher, iv) {
  7098  	            return this.Decryptor.create(cipher, iv);
  7099  	        },
  7100  
  7101  	        /**
  7102  	         * Initializes a newly created mode.
  7103  	         *
  7104  	         * @param {Cipher} cipher A block cipher instance.
  7105  	         * @param {Array} iv The IV words.
  7106  	         *
  7107  	         * @example
  7108  	         *
  7109  	         *     var mode = CryptoJS.mode.CBC.Encryptor.create(cipher, iv.words);
  7110  	         */
  7111  	        init: function (cipher, iv) {
  7112  	            this._cipher = cipher;
  7113  	            this._iv = iv;
  7114  	        }
  7115  	    });
  7116  
  7117  	    /**
  7118  	     * Cipher Block Chaining mode.
  7119  	     */
  7120  	    var CBC = C_mode.CBC = (function () {
  7121  	        /**
  7122  	         * Abstract base CBC mode.
  7123  	         */
  7124  	        var CBC = BlockCipherMode.extend();
  7125  
  7126  	        /**
  7127  	         * CBC encryptor.
  7128  	         */
  7129  	        CBC.Encryptor = CBC.extend({
  7130  	            /**
  7131  	             * Processes the data block at offset.
  7132  	             *
  7133  	             * @param {Array} words The data words to operate on.
  7134  	             * @param {number} offset The offset where the block starts.
  7135  	             *
  7136  	             * @example
  7137  	             *
  7138  	             *     mode.processBlock(data.words, offset);
  7139  	             */
  7140  	            processBlock: function (words, offset) {
  7141  	                // Shortcuts
  7142  	                var cipher = this._cipher;
  7143  	                var blockSize = cipher.blockSize;
  7144  
  7145  	                // XOR and encrypt
  7146  	                xorBlock.call(this, words, offset, blockSize);
  7147  	                cipher.encryptBlock(words, offset);
  7148  
  7149  	                // Remember this block to use with next block
  7150  	                this._prevBlock = words.slice(offset, offset + blockSize);
  7151  	            }
  7152  	        });
  7153  
  7154  	        /**
  7155  	         * CBC decryptor.
  7156  	         */
  7157  	        CBC.Decryptor = CBC.extend({
  7158  	            /**
  7159  	             * Processes the data block at offset.
  7160  	             *
  7161  	             * @param {Array} words The data words to operate on.
  7162  	             * @param {number} offset The offset where the block starts.
  7163  	             *
  7164  	             * @example
  7165  	             *
  7166  	             *     mode.processBlock(data.words, offset);
  7167  	             */
  7168  	            processBlock: function (words, offset) {
  7169  	                // Shortcuts
  7170  	                var cipher = this._cipher;
  7171  	                var blockSize = cipher.blockSize;
  7172  
  7173  	                // Remember this block to use with next block
  7174  	                var thisBlock = words.slice(offset, offset + blockSize);
  7175  
  7176  	                // Decrypt and XOR
  7177  	                cipher.decryptBlock(words, offset);
  7178  	                xorBlock.call(this, words, offset, blockSize);
  7179  
  7180  	                // This block becomes the previous block
  7181  	                this._prevBlock = thisBlock;
  7182  	            }
  7183  	        });
  7184  
  7185  	        function xorBlock(words, offset, blockSize) {
  7186  	            // Shortcut
  7187  	            var iv = this._iv;
  7188  
  7189  	            // Choose mixing block
  7190  	            if (iv) {
  7191  	                var block = iv;
  7192  
  7193  	                // Remove IV for subsequent blocks
  7194  	                this._iv = undefined;
  7195  	            } else {
  7196  	                var block = this._prevBlock;
  7197  	            }
  7198  
  7199  	            // XOR blocks
  7200  	            for (var i = 0; i < blockSize; i++) {
  7201  	                words[offset + i] ^= block[i];
  7202  	            }
  7203  	        }
  7204  
  7205  	        return CBC;
  7206  	    }());
  7207  
  7208  	    /**
  7209  	     * Padding namespace.
  7210  	     */
  7211  	    var C_pad = C.pad = {};
  7212  
  7213  	    /**
  7214  	     * PKCS #5/7 padding strategy.
  7215  	     */
  7216  	    var Pkcs7 = C_pad.Pkcs7 = {
  7217  	        /**
  7218  	         * Pads data using the algorithm defined in PKCS #5/7.
  7219  	         *
  7220  	         * @param {WordArray} data The data to pad.
  7221  	         * @param {number} blockSize The multiple that the data should be padded to.
  7222  	         *
  7223  	         * @static
  7224  	         *
  7225  	         * @example
  7226  	         *
  7227  	         *     CryptoJS.pad.Pkcs7.pad(wordArray, 4);
  7228  	         */
  7229  	        pad: function (data, blockSize) {
  7230  	            // Shortcut
  7231  	            var blockSizeBytes = blockSize * 4;
  7232  
  7233  	            // Count padding bytes
  7234  	            var nPaddingBytes = blockSizeBytes - data.sigBytes % blockSizeBytes;
  7235  
  7236  	            // Create padding word
  7237  	            var paddingWord = (nPaddingBytes << 24) | (nPaddingBytes << 16) | (nPaddingBytes << 8) | nPaddingBytes;
  7238  
  7239  	            // Create padding
  7240  	            var paddingWords = [];
  7241  	            for (var i = 0; i < nPaddingBytes; i += 4) {
  7242  	                paddingWords.push(paddingWord);
  7243  	            }
  7244  	            var padding = WordArray.create(paddingWords, nPaddingBytes);
  7245  
  7246  	            // Add padding
  7247  	            data.concat(padding);
  7248  	        },
  7249  
  7250  	        /**
  7251  	         * Unpads data that had been padded using the algorithm defined in PKCS #5/7.
  7252  	         *
  7253  	         * @param {WordArray} data The data to unpad.
  7254  	         *
  7255  	         * @static
  7256  	         *
  7257  	         * @example
  7258  	         *
  7259  	         *     CryptoJS.pad.Pkcs7.unpad(wordArray);
  7260  	         */
  7261  	        unpad: function (data) {
  7262  	            // Get number of padding bytes from last byte
  7263  	            var nPaddingBytes = data.words[(data.sigBytes - 1) >>> 2] & 0xff;
  7264  
  7265  	            // Remove padding
  7266  	            data.sigBytes -= nPaddingBytes;
  7267  	        }
  7268  	    };
  7269  
  7270  	    /**
  7271  	     * Abstract base block cipher template.
  7272  	     *
  7273  	     * @property {number} blockSize The number of 32-bit words this cipher operates on. Default: 4 (128 bits)
  7274  	     */
  7275  	    var BlockCipher = C_lib.BlockCipher = Cipher.extend({
  7276  	        /**
  7277  	         * Configuration options.
  7278  	         *
  7279  	         * @property {Mode} mode The block mode to use. Default: CBC
  7280  	         * @property {Padding} padding The padding strategy to use. Default: Pkcs7
  7281  	         */
  7282  	        cfg: Cipher.cfg.extend({
  7283  	            mode: CBC,
  7284  	            padding: Pkcs7
  7285  	        }),
  7286  
  7287  	        reset: function () {
  7288  	            // Reset cipher
  7289  	            Cipher.reset.call(this);
  7290  
  7291  	            // Shortcuts
  7292  	            var cfg = this.cfg;
  7293  	            var iv = cfg.iv;
  7294  	            var mode = cfg.mode;
  7295  
  7296  	            // Reset block mode
  7297  	            if (this._xformMode == this._ENC_XFORM_MODE) {
  7298  	                var modeCreator = mode.createEncryptor;
  7299  	            } else /* if (this._xformMode == this._DEC_XFORM_MODE) */ {
  7300  	                var modeCreator = mode.createDecryptor;
  7301  
  7302  	                // Keep at least one block in the buffer for unpadding
  7303  	                this._minBufferSize = 1;
  7304  	            }
  7305  	            this._mode = modeCreator.call(mode, this, iv && iv.words);
  7306  	        },
  7307  
  7308  	        _doProcessBlock: function (words, offset) {
  7309  	            this._mode.processBlock(words, offset);
  7310  	        },
  7311  
  7312  	        _doFinalize: function () {
  7313  	            // Shortcut
  7314  	            var padding = this.cfg.padding;
  7315  
  7316  	            // Finalize
  7317  	            if (this._xformMode == this._ENC_XFORM_MODE) {
  7318  	                // Pad data
  7319  	                padding.pad(this._data, this.blockSize);
  7320  
  7321  	                // Process final blocks
  7322  	                var finalProcessedBlocks = this._process(!!'flush');
  7323  	            } else /* if (this._xformMode == this._DEC_XFORM_MODE) */ {
  7324  	                // Process final blocks
  7325  	                var finalProcessedBlocks = this._process(!!'flush');
  7326  
  7327  	                // Unpad data
  7328  	                padding.unpad(finalProcessedBlocks);
  7329  	            }
  7330  
  7331  	            return finalProcessedBlocks;
  7332  	        },
  7333  
  7334  	        blockSize: 128/32
  7335  	    });
  7336  
  7337  	    /**
  7338  	     * A collection of cipher parameters.
  7339  	     *
  7340  	     * @property {WordArray} ciphertext The raw ciphertext.
  7341  	     * @property {WordArray} key The key to this ciphertext.
  7342  	     * @property {WordArray} iv The IV used in the ciphering operation.
  7343  	     * @property {WordArray} salt The salt used with a key derivation function.
  7344  	     * @property {Cipher} algorithm The cipher algorithm.
  7345  	     * @property {Mode} mode The block mode used in the ciphering operation.
  7346  	     * @property {Padding} padding The padding scheme used in the ciphering operation.
  7347  	     * @property {number} blockSize The block size of the cipher.
  7348  	     * @property {Format} formatter The default formatting strategy to convert this cipher params object to a string.
  7349  	     */
  7350  	    var CipherParams = C_lib.CipherParams = Base.extend({
  7351  	        /**
  7352  	         * Initializes a newly created cipher params object.
  7353  	         *
  7354  	         * @param {Object} cipherParams An object with any of the possible cipher parameters.
  7355  	         *
  7356  	         * @example
  7357  	         *
  7358  	         *     var cipherParams = CryptoJS.lib.CipherParams.create({
  7359  	         *         ciphertext: ciphertextWordArray,
  7360  	         *         key: keyWordArray,
  7361  	         *         iv: ivWordArray,
  7362  	         *         salt: saltWordArray,
  7363  	         *         algorithm: CryptoJS.algo.AES,
  7364  	         *         mode: CryptoJS.mode.CBC,
  7365  	         *         padding: CryptoJS.pad.PKCS7,
  7366  	         *         blockSize: 4,
  7367  	         *         formatter: CryptoJS.format.OpenSSL
  7368  	         *     });
  7369  	         */
  7370  	        init: function (cipherParams) {
  7371  	            this.mixIn(cipherParams);
  7372  	        },
  7373  
  7374  	        /**
  7375  	         * Converts this cipher params object to a string.
  7376  	         *
  7377  	         * @param {Format} formatter (Optional) The formatting strategy to use.
  7378  	         *
  7379  	         * @return {string} The stringified cipher params.
  7380  	         *
  7381  	         * @throws Error If neither the formatter nor the default formatter is set.
  7382  	         *
  7383  	         * @example
  7384  	         *
  7385  	         *     var string = cipherParams + '';
  7386  	         *     var string = cipherParams.toString();
  7387  	         *     var string = cipherParams.toString(CryptoJS.format.OpenSSL);
  7388  	         */
  7389  	        toString: function (formatter) {
  7390  	            return (formatter || this.formatter).stringify(this);
  7391  	        }
  7392  	    });
  7393  
  7394  	    /**
  7395  	     * Format namespace.
  7396  	     */
  7397  	    var C_format = C.format = {};
  7398  
  7399  	    /**
  7400  	     * OpenSSL formatting strategy.
  7401  	     */
  7402  	    var OpenSSLFormatter = C_format.OpenSSL = {
  7403  	        /**
  7404  	         * Converts a cipher params object to an OpenSSL-compatible string.
  7405  	         *
  7406  	         * @param {CipherParams} cipherParams The cipher params object.
  7407  	         *
  7408  	         * @return {string} The OpenSSL-compatible string.
  7409  	         *
  7410  	         * @static
  7411  	         *
  7412  	         * @example
  7413  	         *
  7414  	         *     var openSSLString = CryptoJS.format.OpenSSL.stringify(cipherParams);
  7415  	         */
  7416  	        stringify: function (cipherParams) {
  7417  	            // Shortcuts
  7418  	            var ciphertext = cipherParams.ciphertext;
  7419  	            var salt = cipherParams.salt;
  7420  
  7421  	            // Format
  7422  	            if (salt) {
  7423  	                var wordArray = WordArray.create([0x53616c74, 0x65645f5f]).concat(salt).concat(ciphertext);
  7424  	            } else {
  7425  	                var wordArray = ciphertext;
  7426  	            }
  7427  
  7428  	            return wordArray.toString(Base64);
  7429  	        },
  7430  
  7431  	        /**
  7432  	         * Converts an OpenSSL-compatible string to a cipher params object.
  7433  	         *
  7434  	         * @param {string} openSSLStr The OpenSSL-compatible string.
  7435  	         *
  7436  	         * @return {CipherParams} The cipher params object.
  7437  	         *
  7438  	         * @static
  7439  	         *
  7440  	         * @example
  7441  	         *
  7442  	         *     var cipherParams = CryptoJS.format.OpenSSL.parse(openSSLString);
  7443  	         */
  7444  	        parse: function (openSSLStr) {
  7445  	            // Parse base64
  7446  	            var ciphertext = Base64.parse(openSSLStr);
  7447  
  7448  	            // Shortcut
  7449  	            var ciphertextWords = ciphertext.words;
  7450  
  7451  	            // Test for salt
  7452  	            if (ciphertextWords[0] == 0x53616c74 && ciphertextWords[1] == 0x65645f5f) {
  7453  	                // Extract salt
  7454  	                var salt = WordArray.create(ciphertextWords.slice(2, 4));
  7455  
  7456  	                // Remove salt from ciphertext
  7457  	                ciphertextWords.splice(0, 4);
  7458  	                ciphertext.sigBytes -= 16;
  7459  	            }
  7460  
  7461  	            return CipherParams.create({ ciphertext: ciphertext, salt: salt });
  7462  	        }
  7463  	    };
  7464  
  7465  	    /**
  7466  	     * A cipher wrapper that returns ciphertext as a serializable cipher params object.
  7467  	     */
  7468  	    var SerializableCipher = C_lib.SerializableCipher = Base.extend({
  7469  	        /**
  7470  	         * Configuration options.
  7471  	         *
  7472  	         * @property {Formatter} format The formatting strategy to convert cipher param objects to and from a string. Default: OpenSSL
  7473  	         */
  7474  	        cfg: Base.extend({
  7475  	            format: OpenSSLFormatter
  7476  	        }),
  7477  
  7478  	        /**
  7479  	         * Encrypts a message.
  7480  	         *
  7481  	         * @param {Cipher} cipher The cipher algorithm to use.
  7482  	         * @param {WordArray|string} message The message to encrypt.
  7483  	         * @param {WordArray} key The key.
  7484  	         * @param {Object} cfg (Optional) The configuration options to use for this operation.
  7485  	         *
  7486  	         * @return {CipherParams} A cipher params object.
  7487  	         *
  7488  	         * @static
  7489  	         *
  7490  	         * @example
  7491  	         *
  7492  	         *     var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key);
  7493  	         *     var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key, { iv: iv });
  7494  	         *     var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key, { iv: iv, format: CryptoJS.format.OpenSSL });
  7495  	         */
  7496  	        encrypt: function (cipher, message, key, cfg) {
  7497  	            // Apply config defaults
  7498  	            cfg = this.cfg.extend(cfg);
  7499  
  7500  	            // Encrypt
  7501  	            var encryptor = cipher.createEncryptor(key, cfg);
  7502  	            var ciphertext = encryptor.finalize(message);
  7503  
  7504  	            // Shortcut
  7505  	            var cipherCfg = encryptor.cfg;
  7506  
  7507  	            // Create and return serializable cipher params
  7508  	            return CipherParams.create({
  7509  	                ciphertext: ciphertext,
  7510  	                key: key,
  7511  	                iv: cipherCfg.iv,
  7512  	                algorithm: cipher,
  7513  	                mode: cipherCfg.mode,
  7514  	                padding: cipherCfg.padding,
  7515  	                blockSize: cipher.blockSize,
  7516  	                formatter: cfg.format
  7517  	            });
  7518  	        },
  7519  
  7520  	        /**
  7521  	         * Decrypts serialized ciphertext.
  7522  	         *
  7523  	         * @param {Cipher} cipher The cipher algorithm to use.
  7524  	         * @param {CipherParams|string} ciphertext The ciphertext to decrypt.
  7525  	         * @param {WordArray} key The key.
  7526  	         * @param {Object} cfg (Optional) The configuration options to use for this operation.
  7527  	         *
  7528  	         * @return {WordArray} The plaintext.
  7529  	         *
  7530  	         * @static
  7531  	         *
  7532  	         * @example
  7533  	         *
  7534  	         *     var plaintext = CryptoJS.lib.SerializableCipher.decrypt(CryptoJS.algo.AES, formattedCiphertext, key, { iv: iv, format: CryptoJS.format.OpenSSL });
  7535  	         *     var plaintext = CryptoJS.lib.SerializableCipher.decrypt(CryptoJS.algo.AES, ciphertextParams, key, { iv: iv, format: CryptoJS.format.OpenSSL });
  7536  	         */
  7537  	        decrypt: function (cipher, ciphertext, key, cfg) {
  7538  	            // Apply config defaults
  7539  	            cfg = this.cfg.extend(cfg);
  7540  
  7541  	            // Convert string to CipherParams
  7542  	            ciphertext = this._parse(ciphertext, cfg.format);
  7543  
  7544  	            // Decrypt
  7545  	            var plaintext = cipher.createDecryptor(key, cfg).finalize(ciphertext.ciphertext);
  7546  
  7547  	            return plaintext;
  7548  	        },
  7549  
  7550  	        /**
  7551  	         * Converts serialized ciphertext to CipherParams,
  7552  	         * else assumed CipherParams already and returns ciphertext unchanged.
  7553  	         *
  7554  	         * @param {CipherParams|string} ciphertext The ciphertext.
  7555  	         * @param {Formatter} format The formatting strategy to use to parse serialized ciphertext.
  7556  	         *
  7557  	         * @return {CipherParams} The unserialized ciphertext.
  7558  	         *
  7559  	         * @static
  7560  	         *
  7561  	         * @example
  7562  	         *
  7563  	         *     var ciphertextParams = CryptoJS.lib.SerializableCipher._parse(ciphertextStringOrParams, format);
  7564  	         */
  7565  	        _parse: function (ciphertext, format) {
  7566  	            if (typeof ciphertext == 'string') {
  7567  	                return format.parse(ciphertext, this);
  7568  	            } else {
  7569  	                return ciphertext;
  7570  	            }
  7571  	        }
  7572  	    });
  7573  
  7574  	    /**
  7575  	     * Key derivation function namespace.
  7576  	     */
  7577  	    var C_kdf = C.kdf = {};
  7578  
  7579  	    /**
  7580  	     * OpenSSL key derivation function.
  7581  	     */
  7582  	    var OpenSSLKdf = C_kdf.OpenSSL = {
  7583  	        /**
  7584  	         * Derives a key and IV from a password.
  7585  	         *
  7586  	         * @param {string} password The password to derive from.
  7587  	         * @param {number} keySize The size in words of the key to generate.
  7588  	         * @param {number} ivSize The size in words of the IV to generate.
  7589  	         * @param {WordArray|string} salt (Optional) A 64-bit salt to use. If omitted, a salt will be generated randomly.
  7590  	         *
  7591  	         * @return {CipherParams} A cipher params object with the key, IV, and salt.
  7592  	         *
  7593  	         * @static
  7594  	         *
  7595  	         * @example
  7596  	         *
  7597  	         *     var derivedParams = CryptoJS.kdf.OpenSSL.execute('Password', 256/32, 128/32);
  7598  	         *     var derivedParams = CryptoJS.kdf.OpenSSL.execute('Password', 256/32, 128/32, 'saltsalt');
  7599  	         */
  7600  	        execute: function (password, keySize, ivSize, salt) {
  7601  	            // Generate random salt
  7602  	            if (!salt) {
  7603  	                salt = WordArray.random(64/8);
  7604  	            }
  7605  
  7606  	            // Derive key and IV
  7607  	            var key = EvpKDF.create({ keySize: keySize + ivSize }).compute(password, salt);
  7608  
  7609  	            // Separate key and IV
  7610  	            var iv = WordArray.create(key.words.slice(keySize), ivSize * 4);
  7611  	            key.sigBytes = keySize * 4;
  7612  
  7613  	            // Return params
  7614  	            return CipherParams.create({ key: key, iv: iv, salt: salt });
  7615  	        }
  7616  	    };
  7617  
  7618  	    /**
  7619  	     * A serializable cipher wrapper that derives the key from a password,
  7620  	     * and returns ciphertext as a serializable cipher params object.
  7621  	     */
  7622  	    var PasswordBasedCipher = C_lib.PasswordBasedCipher = SerializableCipher.extend({
  7623  	        /**
  7624  	         * Configuration options.
  7625  	         *
  7626  	         * @property {KDF} kdf The key derivation function to use to generate a key and IV from a password. Default: OpenSSL
  7627  	         */
  7628  	        cfg: SerializableCipher.cfg.extend({
  7629  	            kdf: OpenSSLKdf
  7630  	        }),
  7631  
  7632  	        /**
  7633  	         * Encrypts a message using a password.
  7634  	         *
  7635  	         * @param {Cipher} cipher The cipher algorithm to use.
  7636  	         * @param {WordArray|string} message The message to encrypt.
  7637  	         * @param {string} password The password.
  7638  	         * @param {Object} cfg (Optional) The configuration options to use for this operation.
  7639  	         *
  7640  	         * @return {CipherParams} A cipher params object.
  7641  	         *
  7642  	         * @static
  7643  	         *
  7644  	         * @example
  7645  	         *
  7646  	         *     var ciphertextParams = CryptoJS.lib.PasswordBasedCipher.encrypt(CryptoJS.algo.AES, message, 'password');
  7647  	         *     var ciphertextParams = CryptoJS.lib.PasswordBasedCipher.encrypt(CryptoJS.algo.AES, message, 'password', { format: CryptoJS.format.OpenSSL });
  7648  	         */
  7649  	        encrypt: function (cipher, message, password, cfg) {
  7650  	            // Apply config defaults
  7651  	            cfg = this.cfg.extend(cfg);
  7652  
  7653  	            // Derive key and other params
  7654  	            var derivedParams = cfg.kdf.execute(password, cipher.keySize, cipher.ivSize);
  7655  
  7656  	            // Add IV to config
  7657  	            cfg.iv = derivedParams.iv;
  7658  
  7659  	            // Encrypt
  7660  	            var ciphertext = SerializableCipher.encrypt.call(this, cipher, message, derivedParams.key, cfg);
  7661  
  7662  	            // Mix in derived params
  7663  	            ciphertext.mixIn(derivedParams);
  7664  
  7665  	            return ciphertext;
  7666  	        },
  7667  
  7668  	        /**
  7669  	         * Decrypts serialized ciphertext using a password.
  7670  	         *
  7671  	         * @param {Cipher} cipher The cipher algorithm to use.
  7672  	         * @param {CipherParams|string} ciphertext The ciphertext to decrypt.
  7673  	         * @param {string} password The password.
  7674  	         * @param {Object} cfg (Optional) The configuration options to use for this operation.
  7675  	         *
  7676  	         * @return {WordArray} The plaintext.
  7677  	         *
  7678  	         * @static
  7679  	         *
  7680  	         * @example
  7681  	         *
  7682  	         *     var plaintext = CryptoJS.lib.PasswordBasedCipher.decrypt(CryptoJS.algo.AES, formattedCiphertext, 'password', { format: CryptoJS.format.OpenSSL });
  7683  	         *     var plaintext = CryptoJS.lib.PasswordBasedCipher.decrypt(CryptoJS.algo.AES, ciphertextParams, 'password', { format: CryptoJS.format.OpenSSL });
  7684  	         */
  7685  	        decrypt: function (cipher, ciphertext, password, cfg) {
  7686  	            // Apply config defaults
  7687  	            cfg = this.cfg.extend(cfg);
  7688  
  7689  	            // Convert string to CipherParams
  7690  	            ciphertext = this._parse(ciphertext, cfg.format);
  7691  
  7692  	            // Derive key and other params
  7693  	            var derivedParams = cfg.kdf.execute(password, cipher.keySize, cipher.ivSize, ciphertext.salt);
  7694  
  7695  	            // Add IV to config
  7696  	            cfg.iv = derivedParams.iv;
  7697  
  7698  	            // Decrypt
  7699  	            var plaintext = SerializableCipher.decrypt.call(this, cipher, ciphertext, derivedParams.key, cfg);
  7700  
  7701  	            return plaintext;
  7702  	        }
  7703  	    });
  7704  	}());
  7705  
  7706  
  7707  }));
  7708  },{"./core":53}],53:[function(require,module,exports){
  7709  ;(function (root, factory) {
  7710  	if (typeof exports === "object") {
  7711  		// CommonJS
  7712  		module.exports = exports = factory();
  7713  	}
  7714  	else if (typeof define === "function" && define.amd) {
  7715  		// AMD
  7716  		define([], factory);
  7717  	}
  7718  	else {
  7719  		// Global (browser)
  7720  		root.CryptoJS = factory();
  7721  	}
  7722  }(this, function () {
  7723  
  7724  	/**
  7725  	 * CryptoJS core components.
  7726  	 */
  7727  	var CryptoJS = CryptoJS || (function (Math, undefined) {
  7728  	    /*
  7729  	     * Local polyfil of Object.create
  7730  	     */
  7731  	    var create = Object.create || (function () {
  7732  	        function F() {};
  7733  
  7734  	        return function (obj) {
  7735  	            var subtype;
  7736  
  7737  	            F.prototype = obj;
  7738  
  7739  	            subtype = new F();
  7740  
  7741  	            F.prototype = null;
  7742  
  7743  	            return subtype;
  7744  	        };
  7745  	    }())
  7746  
  7747  	    /**
  7748  	     * CryptoJS namespace.
  7749  	     */
  7750  	    var C = {};
  7751  
  7752  	    /**
  7753  	     * Library namespace.
  7754  	     */
  7755  	    var C_lib = C.lib = {};
  7756  
  7757  	    /**
  7758  	     * Base object for prototypal inheritance.
  7759  	     */
  7760  	    var Base = C_lib.Base = (function () {
  7761  
  7762  
  7763  	        return {
  7764  	            /**
  7765  	             * Creates a new object that inherits from this object.
  7766  	             *
  7767  	             * @param {Object} overrides Properties to copy into the new object.
  7768  	             *
  7769  	             * @return {Object} The new object.
  7770  	             *
  7771  	             * @static
  7772  	             *
  7773  	             * @example
  7774  	             *
  7775  	             *     var MyType = CryptoJS.lib.Base.extend({
  7776  	             *         field: 'value',
  7777  	             *
  7778  	             *         method: function () {
  7779  	             *         }
  7780  	             *     });
  7781  	             */
  7782  	            extend: function (overrides) {
  7783  	                // Spawn
  7784  	                var subtype = create(this);
  7785  
  7786  	                // Augment
  7787  	                if (overrides) {
  7788  	                    subtype.mixIn(overrides);
  7789  	                }
  7790  
  7791  	                // Create default initializer
  7792  	                if (!subtype.hasOwnProperty('init') || this.init === subtype.init) {
  7793  	                    subtype.init = function () {
  7794  	                        subtype.$super.init.apply(this, arguments);
  7795  	                    };
  7796  	                }
  7797  
  7798  	                // Initializer's prototype is the subtype object
  7799  	                subtype.init.prototype = subtype;
  7800  
  7801  	                // Reference supertype
  7802  	                subtype.$super = this;
  7803  
  7804  	                return subtype;
  7805  	            },
  7806  
  7807  	            /**
  7808  	             * Extends this object and runs the init method.
  7809  	             * Arguments to create() will be passed to init().
  7810  	             *
  7811  	             * @return {Object} The new object.
  7812  	             *
  7813  	             * @static
  7814  	             *
  7815  	             * @example
  7816  	             *
  7817  	             *     var instance = MyType.create();
  7818  	             */
  7819  	            create: function () {
  7820  	                var instance = this.extend();
  7821  	                instance.init.apply(instance, arguments);
  7822  
  7823  	                return instance;
  7824  	            },
  7825  
  7826  	            /**
  7827  	             * Initializes a newly created object.
  7828  	             * Override this method to add some logic when your objects are created.
  7829  	             *
  7830  	             * @example
  7831  	             *
  7832  	             *     var MyType = CryptoJS.lib.Base.extend({
  7833  	             *         init: function () {
  7834  	             *             // ...
  7835  	             *         }
  7836  	             *     });
  7837  	             */
  7838  	            init: function () {
  7839  	            },
  7840  
  7841  	            /**
  7842  	             * Copies properties into this object.
  7843  	             *
  7844  	             * @param {Object} properties The properties to mix in.
  7845  	             *
  7846  	             * @example
  7847  	             *
  7848  	             *     MyType.mixIn({
  7849  	             *         field: 'value'
  7850  	             *     });
  7851  	             */
  7852  	            mixIn: function (properties) {
  7853  	                for (var propertyName in properties) {
  7854  	                    if (properties.hasOwnProperty(propertyName)) {
  7855  	                        this[propertyName] = properties[propertyName];
  7856  	                    }
  7857  	                }
  7858  
  7859  	                // IE won't copy toString using the loop above
  7860  	                if (properties.hasOwnProperty('toString')) {
  7861  	                    this.toString = properties.toString;
  7862  	                }
  7863  	            },
  7864  
  7865  	            /**
  7866  	             * Creates a copy of this object.
  7867  	             *
  7868  	             * @return {Object} The clone.
  7869  	             *
  7870  	             * @example
  7871  	             *
  7872  	             *     var clone = instance.clone();
  7873  	             */
  7874  	            clone: function () {
  7875  	                return this.init.prototype.extend(this);
  7876  	            }
  7877  	        };
  7878  	    }());
  7879  
  7880  	    /**
  7881  	     * An array of 32-bit words.
  7882  	     *
  7883  	     * @property {Array} words The array of 32-bit words.
  7884  	     * @property {number} sigBytes The number of significant bytes in this word array.
  7885  	     */
  7886  	    var WordArray = C_lib.WordArray = Base.extend({
  7887  	        /**
  7888  	         * Initializes a newly created word array.
  7889  	         *
  7890  	         * @param {Array} words (Optional) An array of 32-bit words.
  7891  	         * @param {number} sigBytes (Optional) The number of significant bytes in the words.
  7892  	         *
  7893  	         * @example
  7894  	         *
  7895  	         *     var wordArray = CryptoJS.lib.WordArray.create();
  7896  	         *     var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607]);
  7897  	         *     var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607], 6);
  7898  	         */
  7899  	        init: function (words, sigBytes) {
  7900  	            words = this.words = words || [];
  7901  
  7902  	            if (sigBytes != undefined) {
  7903  	                this.sigBytes = sigBytes;
  7904  	            } else {
  7905  	                this.sigBytes = words.length * 4;
  7906  	            }
  7907  	        },
  7908  
  7909  	        /**
  7910  	         * Converts this word array to a string.
  7911  	         *
  7912  	         * @param {Encoder} encoder (Optional) The encoding strategy to use. Default: CryptoJS.enc.Hex
  7913  	         *
  7914  	         * @return {string} The stringified word array.
  7915  	         *
  7916  	         * @example
  7917  	         *
  7918  	         *     var string = wordArray + '';
  7919  	         *     var string = wordArray.toString();
  7920  	         *     var string = wordArray.toString(CryptoJS.enc.Utf8);
  7921  	         */
  7922  	        toString: function (encoder) {
  7923  	            return (encoder || Hex).stringify(this);
  7924  	        },
  7925  
  7926  	        /**
  7927  	         * Concatenates a word array to this word array.
  7928  	         *
  7929  	         * @param {WordArray} wordArray The word array to append.
  7930  	         *
  7931  	         * @return {WordArray} This word array.
  7932  	         *
  7933  	         * @example
  7934  	         *
  7935  	         *     wordArray1.concat(wordArray2);
  7936  	         */
  7937  	        concat: function (wordArray) {
  7938  	            // Shortcuts
  7939  	            var thisWords = this.words;
  7940  	            var thatWords = wordArray.words;
  7941  	            var thisSigBytes = this.sigBytes;
  7942  	            var thatSigBytes = wordArray.sigBytes;
  7943  
  7944  	            // Clamp excess bits
  7945  	            this.clamp();
  7946  
  7947  	            // Concat
  7948  	            if (thisSigBytes % 4) {
  7949  	                // Copy one byte at a time
  7950  	                for (var i = 0; i < thatSigBytes; i++) {
  7951  	                    var thatByte = (thatWords[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
  7952  	                    thisWords[(thisSigBytes + i) >>> 2] |= thatByte << (24 - ((thisSigBytes + i) % 4) * 8);
  7953  	                }
  7954  	            } else {
  7955  	                // Copy one word at a time
  7956  	                for (var i = 0; i < thatSigBytes; i += 4) {
  7957  	                    thisWords[(thisSigBytes + i) >>> 2] = thatWords[i >>> 2];
  7958  	                }
  7959  	            }
  7960  	            this.sigBytes += thatSigBytes;
  7961  
  7962  	            // Chainable
  7963  	            return this;
  7964  	        },
  7965  
  7966  	        /**
  7967  	         * Removes insignificant bits.
  7968  	         *
  7969  	         * @example
  7970  	         *
  7971  	         *     wordArray.clamp();
  7972  	         */
  7973  	        clamp: function () {
  7974  	            // Shortcuts
  7975  	            var words = this.words;
  7976  	            var sigBytes = this.sigBytes;
  7977  
  7978  	            // Clamp
  7979  	            words[sigBytes >>> 2] &= 0xffffffff << (32 - (sigBytes % 4) * 8);
  7980  	            words.length = Math.ceil(sigBytes / 4);
  7981  	        },
  7982  
  7983  	        /**
  7984  	         * Creates a copy of this word array.
  7985  	         *
  7986  	         * @return {WordArray} The clone.
  7987  	         *
  7988  	         * @example
  7989  	         *
  7990  	         *     var clone = wordArray.clone();
  7991  	         */
  7992  	        clone: function () {
  7993  	            var clone = Base.clone.call(this);
  7994  	            clone.words = this.words.slice(0);
  7995  
  7996  	            return clone;
  7997  	        },
  7998  
  7999  	        /**
  8000  	         * Creates a word array filled with random bytes.
  8001  	         *
  8002  	         * @param {number} nBytes The number of random bytes to generate.
  8003  	         *
  8004  	         * @return {WordArray} The random word array.
  8005  	         *
  8006  	         * @static
  8007  	         *
  8008  	         * @example
  8009  	         *
  8010  	         *     var wordArray = CryptoJS.lib.WordArray.random(16);
  8011  	         */
  8012  	        random: function (nBytes) {
  8013  	            var words = [];
  8014  
  8015  	            var r = (function (m_w) {
  8016  	                var m_w = m_w;
  8017  	                var m_z = 0x3ade68b1;
  8018  	                var mask = 0xffffffff;
  8019  
  8020  	                return function () {
  8021  	                    m_z = (0x9069 * (m_z & 0xFFFF) + (m_z >> 0x10)) & mask;
  8022  	                    m_w = (0x4650 * (m_w & 0xFFFF) + (m_w >> 0x10)) & mask;
  8023  	                    var result = ((m_z << 0x10) + m_w) & mask;
  8024  	                    result /= 0x100000000;
  8025  	                    result += 0.5;
  8026  	                    return result * (Math.random() > .5 ? 1 : -1);
  8027  	                }
  8028  	            });
  8029  
  8030  	            for (var i = 0, rcache; i < nBytes; i += 4) {
  8031  	                var _r = r((rcache || Math.random()) * 0x100000000);
  8032  
  8033  	                rcache = _r() * 0x3ade67b7;
  8034  	                words.push((_r() * 0x100000000) | 0);
  8035  	            }
  8036  
  8037  	            return new WordArray.init(words, nBytes);
  8038  	        }
  8039  	    });
  8040  
  8041  	    /**
  8042  	     * Encoder namespace.
  8043  	     */
  8044  	    var C_enc = C.enc = {};
  8045  
  8046  	    /**
  8047  	     * Hex encoding strategy.
  8048  	     */
  8049  	    var Hex = C_enc.Hex = {
  8050  	        /**
  8051  	         * Converts a word array to a hex string.
  8052  	         *
  8053  	         * @param {WordArray} wordArray The word array.
  8054  	         *
  8055  	         * @return {string} The hex string.
  8056  	         *
  8057  	         * @static
  8058  	         *
  8059  	         * @example
  8060  	         *
  8061  	         *     var hexString = CryptoJS.enc.Hex.stringify(wordArray);
  8062  	         */
  8063  	        stringify: function (wordArray) {
  8064  	            // Shortcuts
  8065  	            var words = wordArray.words;
  8066  	            var sigBytes = wordArray.sigBytes;
  8067  
  8068  	            // Convert
  8069  	            var hexChars = [];
  8070  	            for (var i = 0; i < sigBytes; i++) {
  8071  	                var bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
  8072  	                hexChars.push((bite >>> 4).toString(16));
  8073  	                hexChars.push((bite & 0x0f).toString(16));
  8074  	            }
  8075  
  8076  	            return hexChars.join('');
  8077  	        },
  8078  
  8079  	        /**
  8080  	         * Converts a hex string to a word array.
  8081  	         *
  8082  	         * @param {string} hexStr The hex string.
  8083  	         *
  8084  	         * @return {WordArray} The word array.
  8085  	         *
  8086  	         * @static
  8087  	         *
  8088  	         * @example
  8089  	         *
  8090  	         *     var wordArray = CryptoJS.enc.Hex.parse(hexString);
  8091  	         */
  8092  	        parse: function (hexStr) {
  8093  	            // Shortcut
  8094  	            var hexStrLength = hexStr.length;
  8095  
  8096  	            // Convert
  8097  	            var words = [];
  8098  	            for (var i = 0; i < hexStrLength; i += 2) {
  8099  	                words[i >>> 3] |= parseInt(hexStr.substr(i, 2), 16) << (24 - (i % 8) * 4);
  8100  	            }
  8101  
  8102  	            return new WordArray.init(words, hexStrLength / 2);
  8103  	        }
  8104  	    };
  8105  
  8106  	    /**
  8107  	     * Latin1 encoding strategy.
  8108  	     */
  8109  	    var Latin1 = C_enc.Latin1 = {
  8110  	        /**
  8111  	         * Converts a word array to a Latin1 string.
  8112  	         *
  8113  	         * @param {WordArray} wordArray The word array.
  8114  	         *
  8115  	         * @return {string} The Latin1 string.
  8116  	         *
  8117  	         * @static
  8118  	         *
  8119  	         * @example
  8120  	         *
  8121  	         *     var latin1String = CryptoJS.enc.Latin1.stringify(wordArray);
  8122  	         */
  8123  	        stringify: function (wordArray) {
  8124  	            // Shortcuts
  8125  	            var words = wordArray.words;
  8126  	            var sigBytes = wordArray.sigBytes;
  8127  
  8128  	            // Convert
  8129  	            var latin1Chars = [];
  8130  	            for (var i = 0; i < sigBytes; i++) {
  8131  	                var bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
  8132  	                latin1Chars.push(String.fromCharCode(bite));
  8133  	            }
  8134  
  8135  	            return latin1Chars.join('');
  8136  	        },
  8137  
  8138  	        /**
  8139  	         * Converts a Latin1 string to a word array.
  8140  	         *
  8141  	         * @param {string} latin1Str The Latin1 string.
  8142  	         *
  8143  	         * @return {WordArray} The word array.
  8144  	         *
  8145  	         * @static
  8146  	         *
  8147  	         * @example
  8148  	         *
  8149  	         *     var wordArray = CryptoJS.enc.Latin1.parse(latin1String);
  8150  	         */
  8151  	        parse: function (latin1Str) {
  8152  	            // Shortcut
  8153  	            var latin1StrLength = latin1Str.length;
  8154  
  8155  	            // Convert
  8156  	            var words = [];
  8157  	            for (var i = 0; i < latin1StrLength; i++) {
  8158  	                words[i >>> 2] |= (latin1Str.charCodeAt(i) & 0xff) << (24 - (i % 4) * 8);
  8159  	            }
  8160  
  8161  	            return new WordArray.init(words, latin1StrLength);
  8162  	        }
  8163  	    };
  8164  
  8165  	    /**
  8166  	     * UTF-8 encoding strategy.
  8167  	     */
  8168  	    var Utf8 = C_enc.Utf8 = {
  8169  	        /**
  8170  	         * Converts a word array to a UTF-8 string.
  8171  	         *
  8172  	         * @param {WordArray} wordArray The word array.
  8173  	         *
  8174  	         * @return {string} The UTF-8 string.
  8175  	         *
  8176  	         * @static
  8177  	         *
  8178  	         * @example
  8179  	         *
  8180  	         *     var utf8String = CryptoJS.enc.Utf8.stringify(wordArray);
  8181  	         */
  8182  	        stringify: function (wordArray) {
  8183  	            try {
  8184  	                return decodeURIComponent(escape(Latin1.stringify(wordArray)));
  8185  	            } catch (e) {
  8186  	                throw new Error('Malformed UTF-8 data');
  8187  	            }
  8188  	        },
  8189  
  8190  	        /**
  8191  	         * Converts a UTF-8 string to a word array.
  8192  	         *
  8193  	         * @param {string} utf8Str The UTF-8 string.
  8194  	         *
  8195  	         * @return {WordArray} The word array.
  8196  	         *
  8197  	         * @static
  8198  	         *
  8199  	         * @example
  8200  	         *
  8201  	         *     var wordArray = CryptoJS.enc.Utf8.parse(utf8String);
  8202  	         */
  8203  	        parse: function (utf8Str) {
  8204  	            return Latin1.parse(unescape(encodeURIComponent(utf8Str)));
  8205  	        }
  8206  	    };
  8207  
  8208  	    /**
  8209  	     * Abstract buffered block algorithm template.
  8210  	     *
  8211  	     * The property blockSize must be implemented in a concrete subtype.
  8212  	     *
  8213  	     * @property {number} _minBufferSize The number of blocks that should be kept unprocessed in the buffer. Default: 0
  8214  	     */
  8215  	    var BufferedBlockAlgorithm = C_lib.BufferedBlockAlgorithm = Base.extend({
  8216  	        /**
  8217  	         * Resets this block algorithm's data buffer to its initial state.
  8218  	         *
  8219  	         * @example
  8220  	         *
  8221  	         *     bufferedBlockAlgorithm.reset();
  8222  	         */
  8223  	        reset: function () {
  8224  	            // Initial values
  8225  	            this._data = new WordArray.init();
  8226  	            this._nDataBytes = 0;
  8227  	        },
  8228  
  8229  	        /**
  8230  	         * Adds new data to this block algorithm's buffer.
  8231  	         *
  8232  	         * @param {WordArray|string} data The data to append. Strings are converted to a WordArray using UTF-8.
  8233  	         *
  8234  	         * @example
  8235  	         *
  8236  	         *     bufferedBlockAlgorithm._append('data');
  8237  	         *     bufferedBlockAlgorithm._append(wordArray);
  8238  	         */
  8239  	        _append: function (data) {
  8240  	            // Convert string to WordArray, else assume WordArray already
  8241  	            if (typeof data == 'string') {
  8242  	                data = Utf8.parse(data);
  8243  	            }
  8244  
  8245  	            // Append
  8246  	            this._data.concat(data);
  8247  	            this._nDataBytes += data.sigBytes;
  8248  	        },
  8249  
  8250  	        /**
  8251  	         * Processes available data blocks.
  8252  	         *
  8253  	         * This method invokes _doProcessBlock(offset), which must be implemented by a concrete subtype.
  8254  	         *
  8255  	         * @param {boolean} doFlush Whether all blocks and partial blocks should be processed.
  8256  	         *
  8257  	         * @return {WordArray} The processed data.
  8258  	         *
  8259  	         * @example
  8260  	         *
  8261  	         *     var processedData = bufferedBlockAlgorithm._process();
  8262  	         *     var processedData = bufferedBlockAlgorithm._process(!!'flush');
  8263  	         */
  8264  	        _process: function (doFlush) {
  8265  	            // Shortcuts
  8266  	            var data = this._data;
  8267  	            var dataWords = data.words;
  8268  	            var dataSigBytes = data.sigBytes;
  8269  	            var blockSize = this.blockSize;
  8270  	            var blockSizeBytes = blockSize * 4;
  8271  
  8272  	            // Count blocks ready
  8273  	            var nBlocksReady = dataSigBytes / blockSizeBytes;
  8274  	            if (doFlush) {
  8275  	                // Round up to include partial blocks
  8276  	                nBlocksReady = Math.ceil(nBlocksReady);
  8277  	            } else {
  8278  	                // Round down to include only full blocks,
  8279  	                // less the number of blocks that must remain in the buffer
  8280  	                nBlocksReady = Math.max((nBlocksReady | 0) - this._minBufferSize, 0);
  8281  	            }
  8282  
  8283  	            // Count words ready
  8284  	            var nWordsReady = nBlocksReady * blockSize;
  8285  
  8286  	            // Count bytes ready
  8287  	            var nBytesReady = Math.min(nWordsReady * 4, dataSigBytes);
  8288  
  8289  	            // Process blocks
  8290  	            if (nWordsReady) {
  8291  	                for (var offset = 0; offset < nWordsReady; offset += blockSize) {
  8292  	                    // Perform concrete-algorithm logic
  8293  	                    this._doProcessBlock(dataWords, offset);
  8294  	                }
  8295  
  8296  	                // Remove processed words
  8297  	                var processedWords = dataWords.splice(0, nWordsReady);
  8298  	                data.sigBytes -= nBytesReady;
  8299  	            }
  8300  
  8301  	            // Return processed words
  8302  	            return new WordArray.init(processedWords, nBytesReady);
  8303  	        },
  8304  
  8305  	        /**
  8306  	         * Creates a copy of this object.
  8307  	         *
  8308  	         * @return {Object} The clone.
  8309  	         *
  8310  	         * @example
  8311  	         *
  8312  	         *     var clone = bufferedBlockAlgorithm.clone();
  8313  	         */
  8314  	        clone: function () {
  8315  	            var clone = Base.clone.call(this);
  8316  	            clone._data = this._data.clone();
  8317  
  8318  	            return clone;
  8319  	        },
  8320  
  8321  	        _minBufferSize: 0
  8322  	    });
  8323  
  8324  	    /**
  8325  	     * Abstract hasher template.
  8326  	     *
  8327  	     * @property {number} blockSize The number of 32-bit words this hasher operates on. Default: 16 (512 bits)
  8328  	     */
  8329  	    var Hasher = C_lib.Hasher = BufferedBlockAlgorithm.extend({
  8330  	        /**
  8331  	         * Configuration options.
  8332  	         */
  8333  	        cfg: Base.extend(),
  8334  
  8335  	        /**
  8336  	         * Initializes a newly created hasher.
  8337  	         *
  8338  	         * @param {Object} cfg (Optional) The configuration options to use for this hash computation.
  8339  	         *
  8340  	         * @example
  8341  	         *
  8342  	         *     var hasher = CryptoJS.algo.SHA256.create();
  8343  	         */
  8344  	        init: function (cfg) {
  8345  	            // Apply config defaults
  8346  	            this.cfg = this.cfg.extend(cfg);
  8347  
  8348  	            // Set initial values
  8349  	            this.reset();
  8350  	        },
  8351  
  8352  	        /**
  8353  	         * Resets this hasher to its initial state.
  8354  	         *
  8355  	         * @example
  8356  	         *
  8357  	         *     hasher.reset();
  8358  	         */
  8359  	        reset: function () {
  8360  	            // Reset data buffer
  8361  	            BufferedBlockAlgorithm.reset.call(this);
  8362  
  8363  	            // Perform concrete-hasher logic
  8364  	            this._doReset();
  8365  	        },
  8366  
  8367  	        /**
  8368  	         * Updates this hasher with a message.
  8369  	         *
  8370  	         * @param {WordArray|string} messageUpdate The message to append.
  8371  	         *
  8372  	         * @return {Hasher} This hasher.
  8373  	         *
  8374  	         * @example
  8375  	         *
  8376  	         *     hasher.update('message');
  8377  	         *     hasher.update(wordArray);
  8378  	         */
  8379  	        update: function (messageUpdate) {
  8380  	            // Append
  8381  	            this._append(messageUpdate);
  8382  
  8383  	            // Update the hash
  8384  	            this._process();
  8385  
  8386  	            // Chainable
  8387  	            return this;
  8388  	        },
  8389  
  8390  	        /**
  8391  	         * Finalizes the hash computation.
  8392  	         * Note that the finalize operation is effectively a destructive, read-once operation.
  8393  	         *
  8394  	         * @param {WordArray|string} messageUpdate (Optional) A final message update.
  8395  	         *
  8396  	         * @return {WordArray} The hash.
  8397  	         *
  8398  	         * @example
  8399  	         *
  8400  	         *     var hash = hasher.finalize();
  8401  	         *     var hash = hasher.finalize('message');
  8402  	         *     var hash = hasher.finalize(wordArray);
  8403  	         */
  8404  	        finalize: function (messageUpdate) {
  8405  	            // Final message update
  8406  	            if (messageUpdate) {
  8407  	                this._append(messageUpdate);
  8408  	            }
  8409  
  8410  	            // Perform concrete-hasher logic
  8411  	            var hash = this._doFinalize();
  8412  
  8413  	            return hash;
  8414  	        },
  8415  
  8416  	        blockSize: 512/32,
  8417  
  8418  	        /**
  8419  	         * Creates a shortcut function to a hasher's object interface.
  8420  	         *
  8421  	         * @param {Hasher} hasher The hasher to create a helper for.
  8422  	         *
  8423  	         * @return {Function} The shortcut function.
  8424  	         *
  8425  	         * @static
  8426  	         *
  8427  	         * @example
  8428  	         *
  8429  	         *     var SHA256 = CryptoJS.lib.Hasher._createHelper(CryptoJS.algo.SHA256);
  8430  	         */
  8431  	        _createHelper: function (hasher) {
  8432  	            return function (message, cfg) {
  8433  	                return new hasher.init(cfg).finalize(message);
  8434  	            };
  8435  	        },
  8436  
  8437  	        /**
  8438  	         * Creates a shortcut function to the HMAC's object interface.
  8439  	         *
  8440  	         * @param {Hasher} hasher The hasher to use in this HMAC helper.
  8441  	         *
  8442  	         * @return {Function} The shortcut function.
  8443  	         *
  8444  	         * @static
  8445  	         *
  8446  	         * @example
  8447  	         *
  8448  	         *     var HmacSHA256 = CryptoJS.lib.Hasher._createHmacHelper(CryptoJS.algo.SHA256);
  8449  	         */
  8450  	        _createHmacHelper: function (hasher) {
  8451  	            return function (message, key) {
  8452  	                return new C_algo.HMAC.init(hasher, key).finalize(message);
  8453  	            };
  8454  	        }
  8455  	    });
  8456  
  8457  	    /**
  8458  	     * Algorithm namespace.
  8459  	     */
  8460  	    var C_algo = C.algo = {};
  8461  
  8462  	    return C;
  8463  	}(Math));
  8464  
  8465  
  8466  	return CryptoJS;
  8467  
  8468  }));
  8469  },{}],54:[function(require,module,exports){
  8470  ;(function (root, factory) {
  8471  	if (typeof exports === "object") {
  8472  		// CommonJS
  8473  		module.exports = exports = factory(require("./core"));
  8474  	}
  8475  	else if (typeof define === "function" && define.amd) {
  8476  		// AMD
  8477  		define(["./core"], factory);
  8478  	}
  8479  	else {
  8480  		// Global (browser)
  8481  		factory(root.CryptoJS);
  8482  	}
  8483  }(this, function (CryptoJS) {
  8484  
  8485  	(function () {
  8486  	    // Shortcuts
  8487  	    var C = CryptoJS;
  8488  	    var C_lib = C.lib;
  8489  	    var WordArray = C_lib.WordArray;
  8490  	    var C_enc = C.enc;
  8491  
  8492  	    /**
  8493  	     * Base64 encoding strategy.
  8494  	     */
  8495  	    var Base64 = C_enc.Base64 = {
  8496  	        /**
  8497  	         * Converts a word array to a Base64 string.
  8498  	         *
  8499  	         * @param {WordArray} wordArray The word array.
  8500  	         *
  8501  	         * @return {string} The Base64 string.
  8502  	         *
  8503  	         * @static
  8504  	         *
  8505  	         * @example
  8506  	         *
  8507  	         *     var base64String = CryptoJS.enc.Base64.stringify(wordArray);
  8508  	         */
  8509  	        stringify: function (wordArray) {
  8510  	            // Shortcuts
  8511  	            var words = wordArray.words;
  8512  	            var sigBytes = wordArray.sigBytes;
  8513  	            var map = this._map;
  8514  
  8515  	            // Clamp excess bits
  8516  	            wordArray.clamp();
  8517  
  8518  	            // Convert
  8519  	            var base64Chars = [];
  8520  	            for (var i = 0; i < sigBytes; i += 3) {
  8521  	                var byte1 = (words[i >>> 2]       >>> (24 - (i % 4) * 8))       & 0xff;
  8522  	                var byte2 = (words[(i + 1) >>> 2] >>> (24 - ((i + 1) % 4) * 8)) & 0xff;
  8523  	                var byte3 = (words[(i + 2) >>> 2] >>> (24 - ((i + 2) % 4) * 8)) & 0xff;
  8524  
  8525  	                var triplet = (byte1 << 16) | (byte2 << 8) | byte3;
  8526  
  8527  	                for (var j = 0; (j < 4) && (i + j * 0.75 < sigBytes); j++) {
  8528  	                    base64Chars.push(map.charAt((triplet >>> (6 * (3 - j))) & 0x3f));
  8529  	                }
  8530  	            }
  8531  
  8532  	            // Add padding
  8533  	            var paddingChar = map.charAt(64);
  8534  	            if (paddingChar) {
  8535  	                while (base64Chars.length % 4) {
  8536  	                    base64Chars.push(paddingChar);
  8537  	                }
  8538  	            }
  8539  
  8540  	            return base64Chars.join('');
  8541  	        },
  8542  
  8543  	        /**
  8544  	         * Converts a Base64 string to a word array.
  8545  	         *
  8546  	         * @param {string} base64Str The Base64 string.
  8547  	         *
  8548  	         * @return {WordArray} The word array.
  8549  	         *
  8550  	         * @static
  8551  	         *
  8552  	         * @example
  8553  	         *
  8554  	         *     var wordArray = CryptoJS.enc.Base64.parse(base64String);
  8555  	         */
  8556  	        parse: function (base64Str) {
  8557  	            // Shortcuts
  8558  	            var base64StrLength = base64Str.length;
  8559  	            var map = this._map;
  8560  	            var reverseMap = this._reverseMap;
  8561  
  8562  	            if (!reverseMap) {
  8563  	                    reverseMap = this._reverseMap = [];
  8564  	                    for (var j = 0; j < map.length; j++) {
  8565  	                        reverseMap[map.charCodeAt(j)] = j;
  8566  	                    }
  8567  	            }
  8568  
  8569  	            // Ignore padding
  8570  	            var paddingChar = map.charAt(64);
  8571  	            if (paddingChar) {
  8572  	                var paddingIndex = base64Str.indexOf(paddingChar);
  8573  	                if (paddingIndex !== -1) {
  8574  	                    base64StrLength = paddingIndex;
  8575  	                }
  8576  	            }
  8577  
  8578  	            // Convert
  8579  	            return parseLoop(base64Str, base64StrLength, reverseMap);
  8580  
  8581  	        },
  8582  
  8583  	        _map: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='
  8584  	    };
  8585  
  8586  	    function parseLoop(base64Str, base64StrLength, reverseMap) {
  8587  	      var words = [];
  8588  	      var nBytes = 0;
  8589  	      for (var i = 0; i < base64StrLength; i++) {
  8590  	          if (i % 4) {
  8591  	              var bits1 = reverseMap[base64Str.charCodeAt(i - 1)] << ((i % 4) * 2);
  8592  	              var bits2 = reverseMap[base64Str.charCodeAt(i)] >>> (6 - (i % 4) * 2);
  8593  	              words[nBytes >>> 2] |= (bits1 | bits2) << (24 - (nBytes % 4) * 8);
  8594  	              nBytes++;
  8595  	          }
  8596  	      }
  8597  	      return WordArray.create(words, nBytes);
  8598  	    }
  8599  	}());
  8600  
  8601  
  8602  	return CryptoJS.enc.Base64;
  8603  
  8604  }));
  8605  },{"./core":53}],55:[function(require,module,exports){
  8606  ;(function (root, factory) {
  8607  	if (typeof exports === "object") {
  8608  		// CommonJS
  8609  		module.exports = exports = factory(require("./core"));
  8610  	}
  8611  	else if (typeof define === "function" && define.amd) {
  8612  		// AMD
  8613  		define(["./core"], factory);
  8614  	}
  8615  	else {
  8616  		// Global (browser)
  8617  		factory(root.CryptoJS);
  8618  	}
  8619  }(this, function (CryptoJS) {
  8620  
  8621  	(function () {
  8622  	    // Shortcuts
  8623  	    var C = CryptoJS;
  8624  	    var C_lib = C.lib;
  8625  	    var WordArray = C_lib.WordArray;
  8626  	    var C_enc = C.enc;
  8627  
  8628  	    /**
  8629  	     * UTF-16 BE encoding strategy.
  8630  	     */
  8631  	    var Utf16BE = C_enc.Utf16 = C_enc.Utf16BE = {
  8632  	        /**
  8633  	         * Converts a word array to a UTF-16 BE string.
  8634  	         *
  8635  	         * @param {WordArray} wordArray The word array.
  8636  	         *
  8637  	         * @return {string} The UTF-16 BE string.
  8638  	         *
  8639  	         * @static
  8640  	         *
  8641  	         * @example
  8642  	         *
  8643  	         *     var utf16String = CryptoJS.enc.Utf16.stringify(wordArray);
  8644  	         */
  8645  	        stringify: function (wordArray) {
  8646  	            // Shortcuts
  8647  	            var words = wordArray.words;
  8648  	            var sigBytes = wordArray.sigBytes;
  8649  
  8650  	            // Convert
  8651  	            var utf16Chars = [];
  8652  	            for (var i = 0; i < sigBytes; i += 2) {
  8653  	                var codePoint = (words[i >>> 2] >>> (16 - (i % 4) * 8)) & 0xffff;
  8654  	                utf16Chars.push(String.fromCharCode(codePoint));
  8655  	            }
  8656  
  8657  	            return utf16Chars.join('');
  8658  	        },
  8659  
  8660  	        /**
  8661  	         * Converts a UTF-16 BE string to a word array.
  8662  	         *
  8663  	         * @param {string} utf16Str The UTF-16 BE string.
  8664  	         *
  8665  	         * @return {WordArray} The word array.
  8666  	         *
  8667  	         * @static
  8668  	         *
  8669  	         * @example
  8670  	         *
  8671  	         *     var wordArray = CryptoJS.enc.Utf16.parse(utf16String);
  8672  	         */
  8673  	        parse: function (utf16Str) {
  8674  	            // Shortcut
  8675  	            var utf16StrLength = utf16Str.length;
  8676  
  8677  	            // Convert
  8678  	            var words = [];
  8679  	            for (var i = 0; i < utf16StrLength; i++) {
  8680  	                words[i >>> 1] |= utf16Str.charCodeAt(i) << (16 - (i % 2) * 16);
  8681  	            }
  8682  
  8683  	            return WordArray.create(words, utf16StrLength * 2);
  8684  	        }
  8685  	    };
  8686  
  8687  	    /**
  8688  	     * UTF-16 LE encoding strategy.
  8689  	     */
  8690  	    C_enc.Utf16LE = {
  8691  	        /**
  8692  	         * Converts a word array to a UTF-16 LE string.
  8693  	         *
  8694  	         * @param {WordArray} wordArray The word array.
  8695  	         *
  8696  	         * @return {string} The UTF-16 LE string.
  8697  	         *
  8698  	         * @static
  8699  	         *
  8700  	         * @example
  8701  	         *
  8702  	         *     var utf16Str = CryptoJS.enc.Utf16LE.stringify(wordArray);
  8703  	         */
  8704  	        stringify: function (wordArray) {
  8705  	            // Shortcuts
  8706  	            var words = wordArray.words;
  8707  	            var sigBytes = wordArray.sigBytes;
  8708  
  8709  	            // Convert
  8710  	            var utf16Chars = [];
  8711  	            for (var i = 0; i < sigBytes; i += 2) {
  8712  	                var codePoint = swapEndian((words[i >>> 2] >>> (16 - (i % 4) * 8)) & 0xffff);
  8713  	                utf16Chars.push(String.fromCharCode(codePoint));
  8714  	            }
  8715  
  8716  	            return utf16Chars.join('');
  8717  	        },
  8718  
  8719  	        /**
  8720  	         * Converts a UTF-16 LE string to a word array.
  8721  	         *
  8722  	         * @param {string} utf16Str The UTF-16 LE string.
  8723  	         *
  8724  	         * @return {WordArray} The word array.
  8725  	         *
  8726  	         * @static
  8727  	         *
  8728  	         * @example
  8729  	         *
  8730  	         *     var wordArray = CryptoJS.enc.Utf16LE.parse(utf16Str);
  8731  	         */
  8732  	        parse: function (utf16Str) {
  8733  	            // Shortcut
  8734  	            var utf16StrLength = utf16Str.length;
  8735  
  8736  	            // Convert
  8737  	            var words = [];
  8738  	            for (var i = 0; i < utf16StrLength; i++) {
  8739  	                words[i >>> 1] |= swapEndian(utf16Str.charCodeAt(i) << (16 - (i % 2) * 16));
  8740  	            }
  8741  
  8742  	            return WordArray.create(words, utf16StrLength * 2);
  8743  	        }
  8744  	    };
  8745  
  8746  	    function swapEndian(word) {
  8747  	        return ((word << 8) & 0xff00ff00) | ((word >>> 8) & 0x00ff00ff);
  8748  	    }
  8749  	}());
  8750  
  8751  
  8752  	return CryptoJS.enc.Utf16;
  8753  
  8754  }));
  8755  },{"./core":53}],56:[function(require,module,exports){
  8756  ;(function (root, factory, undef) {
  8757  	if (typeof exports === "object") {
  8758  		// CommonJS
  8759  		module.exports = exports = factory(require("./core"), require("./sha1"), require("./hmac"));
  8760  	}
  8761  	else if (typeof define === "function" && define.amd) {
  8762  		// AMD
  8763  		define(["./core", "./sha1", "./hmac"], factory);
  8764  	}
  8765  	else {
  8766  		// Global (browser)
  8767  		factory(root.CryptoJS);
  8768  	}
  8769  }(this, function (CryptoJS) {
  8770  
  8771  	(function () {
  8772  	    // Shortcuts
  8773  	    var C = CryptoJS;
  8774  	    var C_lib = C.lib;
  8775  	    var Base = C_lib.Base;
  8776  	    var WordArray = C_lib.WordArray;
  8777  	    var C_algo = C.algo;
  8778  	    var MD5 = C_algo.MD5;
  8779  
  8780  	    /**
  8781  	     * This key derivation function is meant to conform with EVP_BytesToKey.
  8782  	     * www.openssl.org/docs/crypto/EVP_BytesToKey.html
  8783  	     */
  8784  	    var EvpKDF = C_algo.EvpKDF = Base.extend({
  8785  	        /**
  8786  	         * Configuration options.
  8787  	         *
  8788  	         * @property {number} keySize The key size in words to generate. Default: 4 (128 bits)
  8789  	         * @property {Hasher} hasher The hash algorithm to use. Default: MD5
  8790  	         * @property {number} iterations The number of iterations to perform. Default: 1
  8791  	         */
  8792  	        cfg: Base.extend({
  8793  	            keySize: 128/32,
  8794  	            hasher: MD5,
  8795  	            iterations: 1
  8796  	        }),
  8797  
  8798  	        /**
  8799  	         * Initializes a newly created key derivation function.
  8800  	         *
  8801  	         * @param {Object} cfg (Optional) The configuration options to use for the derivation.
  8802  	         *
  8803  	         * @example
  8804  	         *
  8805  	         *     var kdf = CryptoJS.algo.EvpKDF.create();
  8806  	         *     var kdf = CryptoJS.algo.EvpKDF.create({ keySize: 8 });
  8807  	         *     var kdf = CryptoJS.algo.EvpKDF.create({ keySize: 8, iterations: 1000 });
  8808  	         */
  8809  	        init: function (cfg) {
  8810  	            this.cfg = this.cfg.extend(cfg);
  8811  	        },
  8812  
  8813  	        /**
  8814  	         * Derives a key from a password.
  8815  	         *
  8816  	         * @param {WordArray|string} password The password.
  8817  	         * @param {WordArray|string} salt A salt.
  8818  	         *
  8819  	         * @return {WordArray} The derived key.
  8820  	         *
  8821  	         * @example
  8822  	         *
  8823  	         *     var key = kdf.compute(password, salt);
  8824  	         */
  8825  	        compute: function (password, salt) {
  8826  	            // Shortcut
  8827  	            var cfg = this.cfg;
  8828  
  8829  	            // Init hasher
  8830  	            var hasher = cfg.hasher.create();
  8831  
  8832  	            // Initial values
  8833  	            var derivedKey = WordArray.create();
  8834  
  8835  	            // Shortcuts
  8836  	            var derivedKeyWords = derivedKey.words;
  8837  	            var keySize = cfg.keySize;
  8838  	            var iterations = cfg.iterations;
  8839  
  8840  	            // Generate key
  8841  	            while (derivedKeyWords.length < keySize) {
  8842  	                if (block) {
  8843  	                    hasher.update(block);
  8844  	                }
  8845  	                var block = hasher.update(password).finalize(salt);
  8846  	                hasher.reset();
  8847  
  8848  	                // Iterations
  8849  	                for (var i = 1; i < iterations; i++) {
  8850  	                    block = hasher.finalize(block);
  8851  	                    hasher.reset();
  8852  	                }
  8853  
  8854  	                derivedKey.concat(block);
  8855  	            }
  8856  	            derivedKey.sigBytes = keySize * 4;
  8857  
  8858  	            return derivedKey;
  8859  	        }
  8860  	    });
  8861  
  8862  	    /**
  8863  	     * Derives a key from a password.
  8864  	     *
  8865  	     * @param {WordArray|string} password The password.
  8866  	     * @param {WordArray|string} salt A salt.
  8867  	     * @param {Object} cfg (Optional) The configuration options to use for this computation.
  8868  	     *
  8869  	     * @return {WordArray} The derived key.
  8870  	     *
  8871  	     * @static
  8872  	     *
  8873  	     * @example
  8874  	     *
  8875  	     *     var key = CryptoJS.EvpKDF(password, salt);
  8876  	     *     var key = CryptoJS.EvpKDF(password, salt, { keySize: 8 });
  8877  	     *     var key = CryptoJS.EvpKDF(password, salt, { keySize: 8, iterations: 1000 });
  8878  	     */
  8879  	    C.EvpKDF = function (password, salt, cfg) {
  8880  	        return EvpKDF.create(cfg).compute(password, salt);
  8881  	    };
  8882  	}());
  8883  
  8884  
  8885  	return CryptoJS.EvpKDF;
  8886  
  8887  }));
  8888  },{"./core":53,"./hmac":58,"./sha1":77}],57:[function(require,module,exports){
  8889  ;(function (root, factory, undef) {
  8890  	if (typeof exports === "object") {
  8891  		// CommonJS
  8892  		module.exports = exports = factory(require("./core"), require("./cipher-core"));
  8893  	}
  8894  	else if (typeof define === "function" && define.amd) {
  8895  		// AMD
  8896  		define(["./core", "./cipher-core"], factory);
  8897  	}
  8898  	else {
  8899  		// Global (browser)
  8900  		factory(root.CryptoJS);
  8901  	}
  8902  }(this, function (CryptoJS) {
  8903  
  8904  	(function (undefined) {
  8905  	    // Shortcuts
  8906  	    var C = CryptoJS;
  8907  	    var C_lib = C.lib;
  8908  	    var CipherParams = C_lib.CipherParams;
  8909  	    var C_enc = C.enc;
  8910  	    var Hex = C_enc.Hex;
  8911  	    var C_format = C.format;
  8912  
  8913  	    var HexFormatter = C_format.Hex = {
  8914  	        /**
  8915  	         * Converts the ciphertext of a cipher params object to a hexadecimally encoded string.
  8916  	         *
  8917  	         * @param {CipherParams} cipherParams The cipher params object.
  8918  	         *
  8919  	         * @return {string} The hexadecimally encoded string.
  8920  	         *
  8921  	         * @static
  8922  	         *
  8923  	         * @example
  8924  	         *
  8925  	         *     var hexString = CryptoJS.format.Hex.stringify(cipherParams);
  8926  	         */
  8927  	        stringify: function (cipherParams) {
  8928  	            return cipherParams.ciphertext.toString(Hex);
  8929  	        },
  8930  
  8931  	        /**
  8932  	         * Converts a hexadecimally encoded ciphertext string to a cipher params object.
  8933  	         *
  8934  	         * @param {string} input The hexadecimally encoded string.
  8935  	         *
  8936  	         * @return {CipherParams} The cipher params object.
  8937  	         *
  8938  	         * @static
  8939  	         *
  8940  	         * @example
  8941  	         *
  8942  	         *     var cipherParams = CryptoJS.format.Hex.parse(hexString);
  8943  	         */
  8944  	        parse: function (input) {
  8945  	            var ciphertext = Hex.parse(input);
  8946  	            return CipherParams.create({ ciphertext: ciphertext });
  8947  	        }
  8948  	    };
  8949  	}());
  8950  
  8951  
  8952  	return CryptoJS.format.Hex;
  8953  
  8954  }));
  8955  },{"./cipher-core":52,"./core":53}],58:[function(require,module,exports){
  8956  ;(function (root, factory) {
  8957  	if (typeof exports === "object") {
  8958  		// CommonJS
  8959  		module.exports = exports = factory(require("./core"));
  8960  	}
  8961  	else if (typeof define === "function" && define.amd) {
  8962  		// AMD
  8963  		define(["./core"], factory);
  8964  	}
  8965  	else {
  8966  		// Global (browser)
  8967  		factory(root.CryptoJS);
  8968  	}
  8969  }(this, function (CryptoJS) {
  8970  
  8971  	(function () {
  8972  	    // Shortcuts
  8973  	    var C = CryptoJS;
  8974  	    var C_lib = C.lib;
  8975  	    var Base = C_lib.Base;
  8976  	    var C_enc = C.enc;
  8977  	    var Utf8 = C_enc.Utf8;
  8978  	    var C_algo = C.algo;
  8979  
  8980  	    /**
  8981  	     * HMAC algorithm.
  8982  	     */
  8983  	    var HMAC = C_algo.HMAC = Base.extend({
  8984  	        /**
  8985  	         * Initializes a newly created HMAC.
  8986  	         *
  8987  	         * @param {Hasher} hasher The hash algorithm to use.
  8988  	         * @param {WordArray|string} key The secret key.
  8989  	         *
  8990  	         * @example
  8991  	         *
  8992  	         *     var hmacHasher = CryptoJS.algo.HMAC.create(CryptoJS.algo.SHA256, key);
  8993  	         */
  8994  	        init: function (hasher, key) {
  8995  	            // Init hasher
  8996  	            hasher = this._hasher = new hasher.init();
  8997  
  8998  	            // Convert string to WordArray, else assume WordArray already
  8999  	            if (typeof key == 'string') {
  9000  	                key = Utf8.parse(key);
  9001  	            }
  9002  
  9003  	            // Shortcuts
  9004  	            var hasherBlockSize = hasher.blockSize;
  9005  	            var hasherBlockSizeBytes = hasherBlockSize * 4;
  9006  
  9007  	            // Allow arbitrary length keys
  9008  	            if (key.sigBytes > hasherBlockSizeBytes) {
  9009  	                key = hasher.finalize(key);
  9010  	            }
  9011  
  9012  	            // Clamp excess bits
  9013  	            key.clamp();
  9014  
  9015  	            // Clone key for inner and outer pads
  9016  	            var oKey = this._oKey = key.clone();
  9017  	            var iKey = this._iKey = key.clone();
  9018  
  9019  	            // Shortcuts
  9020  	            var oKeyWords = oKey.words;
  9021  	            var iKeyWords = iKey.words;
  9022  
  9023  	            // XOR keys with pad constants
  9024  	            for (var i = 0; i < hasherBlockSize; i++) {
  9025  	                oKeyWords[i] ^= 0x5c5c5c5c;
  9026  	                iKeyWords[i] ^= 0x36363636;
  9027  	            }
  9028  	            oKey.sigBytes = iKey.sigBytes = hasherBlockSizeBytes;
  9029  
  9030  	            // Set initial values
  9031  	            this.reset();
  9032  	        },
  9033  
  9034  	        /**
  9035  	         * Resets this HMAC to its initial state.
  9036  	         *
  9037  	         * @example
  9038  	         *
  9039  	         *     hmacHasher.reset();
  9040  	         */
  9041  	        reset: function () {
  9042  	            // Shortcut
  9043  	            var hasher = this._hasher;
  9044  
  9045  	            // Reset
  9046  	            hasher.reset();
  9047  	            hasher.update(this._iKey);
  9048  	        },
  9049  
  9050  	        /**
  9051  	         * Updates this HMAC with a message.
  9052  	         *
  9053  	         * @param {WordArray|string} messageUpdate The message to append.
  9054  	         *
  9055  	         * @return {HMAC} This HMAC instance.
  9056  	         *
  9057  	         * @example
  9058  	         *
  9059  	         *     hmacHasher.update('message');
  9060  	         *     hmacHasher.update(wordArray);
  9061  	         */
  9062  	        update: function (messageUpdate) {
  9063  	            this._hasher.update(messageUpdate);
  9064  
  9065  	            // Chainable
  9066  	            return this;
  9067  	        },
  9068  
  9069  	        /**
  9070  	         * Finalizes the HMAC computation.
  9071  	         * Note that the finalize operation is effectively a destructive, read-once operation.
  9072  	         *
  9073  	         * @param {WordArray|string} messageUpdate (Optional) A final message update.
  9074  	         *
  9075  	         * @return {WordArray} The HMAC.
  9076  	         *
  9077  	         * @example
  9078  	         *
  9079  	         *     var hmac = hmacHasher.finalize();
  9080  	         *     var hmac = hmacHasher.finalize('message');
  9081  	         *     var hmac = hmacHasher.finalize(wordArray);
  9082  	         */
  9083  	        finalize: function (messageUpdate) {
  9084  	            // Shortcut
  9085  	            var hasher = this._hasher;
  9086  
  9087  	            // Compute HMAC
  9088  	            var innerHash = hasher.finalize(messageUpdate);
  9089  	            hasher.reset();
  9090  	            var hmac = hasher.finalize(this._oKey.clone().concat(innerHash));
  9091  
  9092  	            return hmac;
  9093  	        }
  9094  	    });
  9095  	}());
  9096  
  9097  
  9098  }));
  9099  },{"./core":53}],59:[function(require,module,exports){
  9100  ;(function (root, factory, undef) {
  9101  	if (typeof exports === "object") {
  9102  		// CommonJS
  9103  		module.exports = exports = factory(require("./core"), require("./x64-core"), require("./lib-typedarrays"), require("./enc-utf16"), require("./enc-base64"), require("./md5"), require("./sha1"), require("./sha256"), require("./sha224"), require("./sha512"), require("./sha384"), require("./sha3"), require("./ripemd160"), require("./hmac"), require("./pbkdf2"), require("./evpkdf"), require("./cipher-core"), require("./mode-cfb"), require("./mode-ctr"), require("./mode-ctr-gladman"), require("./mode-ofb"), require("./mode-ecb"), require("./pad-ansix923"), require("./pad-iso10126"), require("./pad-iso97971"), require("./pad-zeropadding"), require("./pad-nopadding"), require("./format-hex"), require("./aes"), require("./tripledes"), require("./rc4"), require("./rabbit"), require("./rabbit-legacy"));
  9104  	}
  9105  	else if (typeof define === "function" && define.amd) {
  9106  		// AMD
  9107  		define(["./core", "./x64-core", "./lib-typedarrays", "./enc-utf16", "./enc-base64", "./md5", "./sha1", "./sha256", "./sha224", "./sha512", "./sha384", "./sha3", "./ripemd160", "./hmac", "./pbkdf2", "./evpkdf", "./cipher-core", "./mode-cfb", "./mode-ctr", "./mode-ctr-gladman", "./mode-ofb", "./mode-ecb", "./pad-ansix923", "./pad-iso10126", "./pad-iso97971", "./pad-zeropadding", "./pad-nopadding", "./format-hex", "./aes", "./tripledes", "./rc4", "./rabbit", "./rabbit-legacy"], factory);
  9108  	}
  9109  	else {
  9110  		// Global (browser)
  9111  		root.CryptoJS = factory(root.CryptoJS);
  9112  	}
  9113  }(this, function (CryptoJS) {
  9114  
  9115  	return CryptoJS;
  9116  
  9117  }));
  9118  },{"./aes":51,"./cipher-core":52,"./core":53,"./enc-base64":54,"./enc-utf16":55,"./evpkdf":56,"./format-hex":57,"./hmac":58,"./lib-typedarrays":60,"./md5":61,"./mode-cfb":62,"./mode-ctr":64,"./mode-ctr-gladman":63,"./mode-ecb":65,"./mode-ofb":66,"./pad-ansix923":67,"./pad-iso10126":68,"./pad-iso97971":69,"./pad-nopadding":70,"./pad-zeropadding":71,"./pbkdf2":72,"./rabbit":74,"./rabbit-legacy":73,"./rc4":75,"./ripemd160":76,"./sha1":77,"./sha224":78,"./sha256":79,"./sha3":80,"./sha384":81,"./sha512":82,"./tripledes":83,"./x64-core":84}],60:[function(require,module,exports){
  9119  ;(function (root, factory) {
  9120  	if (typeof exports === "object") {
  9121  		// CommonJS
  9122  		module.exports = exports = factory(require("./core"));
  9123  	}
  9124  	else if (typeof define === "function" && define.amd) {
  9125  		// AMD
  9126  		define(["./core"], factory);
  9127  	}
  9128  	else {
  9129  		// Global (browser)
  9130  		factory(root.CryptoJS);
  9131  	}
  9132  }(this, function (CryptoJS) {
  9133  
  9134  	(function () {
  9135  	    // Check if typed arrays are supported
  9136  	    if (typeof ArrayBuffer != 'function') {
  9137  	        return;
  9138  	    }
  9139  
  9140  	    // Shortcuts
  9141  	    var C = CryptoJS;
  9142  	    var C_lib = C.lib;
  9143  	    var WordArray = C_lib.WordArray;
  9144  
  9145  	    // Reference original init
  9146  	    var superInit = WordArray.init;
  9147  
  9148  	    // Augment WordArray.init to handle typed arrays
  9149  	    var subInit = WordArray.init = function (typedArray) {
  9150  	        // Convert buffers to uint8
  9151  	        if (typedArray instanceof ArrayBuffer) {
  9152  	            typedArray = new Uint8Array(typedArray);
  9153  	        }
  9154  
  9155  	        // Convert other array views to uint8
  9156  	        if (
  9157  	            typedArray instanceof Int8Array ||
  9158  	            (typeof Uint8ClampedArray !== "undefined" && typedArray instanceof Uint8ClampedArray) ||
  9159  	            typedArray instanceof Int16Array ||
  9160  	            typedArray instanceof Uint16Array ||
  9161  	            typedArray instanceof Int32Array ||
  9162  	            typedArray instanceof Uint32Array ||
  9163  	            typedArray instanceof Float32Array ||
  9164  	            typedArray instanceof Float64Array
  9165  	        ) {
  9166  	            typedArray = new Uint8Array(typedArray.buffer, typedArray.byteOffset, typedArray.byteLength);
  9167  	        }
  9168  
  9169  	        // Handle Uint8Array
  9170  	        if (typedArray instanceof Uint8Array) {
  9171  	            // Shortcut
  9172  	            var typedArrayByteLength = typedArray.byteLength;
  9173  
  9174  	            // Extract bytes
  9175  	            var words = [];
  9176  	            for (var i = 0; i < typedArrayByteLength; i++) {
  9177  	                words[i >>> 2] |= typedArray[i] << (24 - (i % 4) * 8);
  9178  	            }
  9179  
  9180  	            // Initialize this word array
  9181  	            superInit.call(this, words, typedArrayByteLength);
  9182  	        } else {
  9183  	            // Else call normal init
  9184  	            superInit.apply(this, arguments);
  9185  	        }
  9186  	    };
  9187  
  9188  	    subInit.prototype = WordArray;
  9189  	}());
  9190  
  9191  
  9192  	return CryptoJS.lib.WordArray;
  9193  
  9194  }));
  9195  },{"./core":53}],61:[function(require,module,exports){
  9196  ;(function (root, factory) {
  9197  	if (typeof exports === "object") {
  9198  		// CommonJS
  9199  		module.exports = exports = factory(require("./core"));
  9200  	}
  9201  	else if (typeof define === "function" && define.amd) {
  9202  		// AMD
  9203  		define(["./core"], factory);
  9204  	}
  9205  	else {
  9206  		// Global (browser)
  9207  		factory(root.CryptoJS);
  9208  	}
  9209  }(this, function (CryptoJS) {
  9210  
  9211  	(function (Math) {
  9212  	    // Shortcuts
  9213  	    var C = CryptoJS;
  9214  	    var C_lib = C.lib;
  9215  	    var WordArray = C_lib.WordArray;
  9216  	    var Hasher = C_lib.Hasher;
  9217  	    var C_algo = C.algo;
  9218  
  9219  	    // Constants table
  9220  	    var T = [];
  9221  
  9222  	    // Compute constants
  9223  	    (function () {
  9224  	        for (var i = 0; i < 64; i++) {
  9225  	            T[i] = (Math.abs(Math.sin(i + 1)) * 0x100000000) | 0;
  9226  	        }
  9227  	    }());
  9228  
  9229  	    /**
  9230  	     * MD5 hash algorithm.
  9231  	     */
  9232  	    var MD5 = C_algo.MD5 = Hasher.extend({
  9233  	        _doReset: function () {
  9234  	            this._hash = new WordArray.init([
  9235  	                0x67452301, 0xefcdab89,
  9236  	                0x98badcfe, 0x10325476
  9237  	            ]);
  9238  	        },
  9239  
  9240  	        _doProcessBlock: function (M, offset) {
  9241  	            // Swap endian
  9242  	            for (var i = 0; i < 16; i++) {
  9243  	                // Shortcuts
  9244  	                var offset_i = offset + i;
  9245  	                var M_offset_i = M[offset_i];
  9246  
  9247  	                M[offset_i] = (
  9248  	                    (((M_offset_i << 8)  | (M_offset_i >>> 24)) & 0x00ff00ff) |
  9249  	                    (((M_offset_i << 24) | (M_offset_i >>> 8))  & 0xff00ff00)
  9250  	                );
  9251  	            }
  9252  
  9253  	            // Shortcuts
  9254  	            var H = this._hash.words;
  9255  
  9256  	            var M_offset_0  = M[offset + 0];
  9257  	            var M_offset_1  = M[offset + 1];
  9258  	            var M_offset_2  = M[offset + 2];
  9259  	            var M_offset_3  = M[offset + 3];
  9260  	            var M_offset_4  = M[offset + 4];
  9261  	            var M_offset_5  = M[offset + 5];
  9262  	            var M_offset_6  = M[offset + 6];
  9263  	            var M_offset_7  = M[offset + 7];
  9264  	            var M_offset_8  = M[offset + 8];
  9265  	            var M_offset_9  = M[offset + 9];
  9266  	            var M_offset_10 = M[offset + 10];
  9267  	            var M_offset_11 = M[offset + 11];
  9268  	            var M_offset_12 = M[offset + 12];
  9269  	            var M_offset_13 = M[offset + 13];
  9270  	            var M_offset_14 = M[offset + 14];
  9271  	            var M_offset_15 = M[offset + 15];
  9272  
  9273  	            // Working varialbes
  9274  	            var a = H[0];
  9275  	            var b = H[1];
  9276  	            var c = H[2];
  9277  	            var d = H[3];
  9278  
  9279  	            // Computation
  9280  	            a = FF(a, b, c, d, M_offset_0,  7,  T[0]);
  9281  	            d = FF(d, a, b, c, M_offset_1,  12, T[1]);
  9282  	            c = FF(c, d, a, b, M_offset_2,  17, T[2]);
  9283  	            b = FF(b, c, d, a, M_offset_3,  22, T[3]);
  9284  	            a = FF(a, b, c, d, M_offset_4,  7,  T[4]);
  9285  	            d = FF(d, a, b, c, M_offset_5,  12, T[5]);
  9286  	            c = FF(c, d, a, b, M_offset_6,  17, T[6]);
  9287  	            b = FF(b, c, d, a, M_offset_7,  22, T[7]);
  9288  	            a = FF(a, b, c, d, M_offset_8,  7,  T[8]);
  9289  	            d = FF(d, a, b, c, M_offset_9,  12, T[9]);
  9290  	            c = FF(c, d, a, b, M_offset_10, 17, T[10]);
  9291  	            b = FF(b, c, d, a, M_offset_11, 22, T[11]);
  9292  	            a = FF(a, b, c, d, M_offset_12, 7,  T[12]);
  9293  	            d = FF(d, a, b, c, M_offset_13, 12, T[13]);
  9294  	            c = FF(c, d, a, b, M_offset_14, 17, T[14]);
  9295  	            b = FF(b, c, d, a, M_offset_15, 22, T[15]);
  9296  
  9297  	            a = GG(a, b, c, d, M_offset_1,  5,  T[16]);
  9298  	            d = GG(d, a, b, c, M_offset_6,  9,  T[17]);
  9299  	            c = GG(c, d, a, b, M_offset_11, 14, T[18]);
  9300  	            b = GG(b, c, d, a, M_offset_0,  20, T[19]);
  9301  	            a = GG(a, b, c, d, M_offset_5,  5,  T[20]);
  9302  	            d = GG(d, a, b, c, M_offset_10, 9,  T[21]);
  9303  	            c = GG(c, d, a, b, M_offset_15, 14, T[22]);
  9304  	            b = GG(b, c, d, a, M_offset_4,  20, T[23]);
  9305  	            a = GG(a, b, c, d, M_offset_9,  5,  T[24]);
  9306  	            d = GG(d, a, b, c, M_offset_14, 9,  T[25]);
  9307  	            c = GG(c, d, a, b, M_offset_3,  14, T[26]);
  9308  	            b = GG(b, c, d, a, M_offset_8,  20, T[27]);
  9309  	            a = GG(a, b, c, d, M_offset_13, 5,  T[28]);
  9310  	            d = GG(d, a, b, c, M_offset_2,  9,  T[29]);
  9311  	            c = GG(c, d, a, b, M_offset_7,  14, T[30]);
  9312  	            b = GG(b, c, d, a, M_offset_12, 20, T[31]);
  9313  
  9314  	            a = HH(a, b, c, d, M_offset_5,  4,  T[32]);
  9315  	            d = HH(d, a, b, c, M_offset_8,  11, T[33]);
  9316  	            c = HH(c, d, a, b, M_offset_11, 16, T[34]);
  9317  	            b = HH(b, c, d, a, M_offset_14, 23, T[35]);
  9318  	            a = HH(a, b, c, d, M_offset_1,  4,  T[36]);
  9319  	            d = HH(d, a, b, c, M_offset_4,  11, T[37]);
  9320  	            c = HH(c, d, a, b, M_offset_7,  16, T[38]);
  9321  	            b = HH(b, c, d, a, M_offset_10, 23, T[39]);
  9322  	            a = HH(a, b, c, d, M_offset_13, 4,  T[40]);
  9323  	            d = HH(d, a, b, c, M_offset_0,  11, T[41]);
  9324  	            c = HH(c, d, a, b, M_offset_3,  16, T[42]);
  9325  	            b = HH(b, c, d, a, M_offset_6,  23, T[43]);
  9326  	            a = HH(a, b, c, d, M_offset_9,  4,  T[44]);
  9327  	            d = HH(d, a, b, c, M_offset_12, 11, T[45]);
  9328  	            c = HH(c, d, a, b, M_offset_15, 16, T[46]);
  9329  	            b = HH(b, c, d, a, M_offset_2,  23, T[47]);
  9330  
  9331  	            a = II(a, b, c, d, M_offset_0,  6,  T[48]);
  9332  	            d = II(d, a, b, c, M_offset_7,  10, T[49]);
  9333  	            c = II(c, d, a, b, M_offset_14, 15, T[50]);
  9334  	            b = II(b, c, d, a, M_offset_5,  21, T[51]);
  9335  	            a = II(a, b, c, d, M_offset_12, 6,  T[52]);
  9336  	            d = II(d, a, b, c, M_offset_3,  10, T[53]);
  9337  	            c = II(c, d, a, b, M_offset_10, 15, T[54]);
  9338  	            b = II(b, c, d, a, M_offset_1,  21, T[55]);
  9339  	            a = II(a, b, c, d, M_offset_8,  6,  T[56]);
  9340  	            d = II(d, a, b, c, M_offset_15, 10, T[57]);
  9341  	            c = II(c, d, a, b, M_offset_6,  15, T[58]);
  9342  	            b = II(b, c, d, a, M_offset_13, 21, T[59]);
  9343  	            a = II(a, b, c, d, M_offset_4,  6,  T[60]);
  9344  	            d = II(d, a, b, c, M_offset_11, 10, T[61]);
  9345  	            c = II(c, d, a, b, M_offset_2,  15, T[62]);
  9346  	            b = II(b, c, d, a, M_offset_9,  21, T[63]);
  9347  
  9348  	            // Intermediate hash value
  9349  	            H[0] = (H[0] + a) | 0;
  9350  	            H[1] = (H[1] + b) | 0;
  9351  	            H[2] = (H[2] + c) | 0;
  9352  	            H[3] = (H[3] + d) | 0;
  9353  	        },
  9354  
  9355  	        _doFinalize: function () {
  9356  	            // Shortcuts
  9357  	            var data = this._data;
  9358  	            var dataWords = data.words;
  9359  
  9360  	            var nBitsTotal = this._nDataBytes * 8;
  9361  	            var nBitsLeft = data.sigBytes * 8;
  9362  
  9363  	            // Add padding
  9364  	            dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
  9365  
  9366  	            var nBitsTotalH = Math.floor(nBitsTotal / 0x100000000);
  9367  	            var nBitsTotalL = nBitsTotal;
  9368  	            dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = (
  9369  	                (((nBitsTotalH << 8)  | (nBitsTotalH >>> 24)) & 0x00ff00ff) |
  9370  	                (((nBitsTotalH << 24) | (nBitsTotalH >>> 8))  & 0xff00ff00)
  9371  	            );
  9372  	            dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = (
  9373  	                (((nBitsTotalL << 8)  | (nBitsTotalL >>> 24)) & 0x00ff00ff) |
  9374  	                (((nBitsTotalL << 24) | (nBitsTotalL >>> 8))  & 0xff00ff00)
  9375  	            );
  9376  
  9377  	            data.sigBytes = (dataWords.length + 1) * 4;
  9378  
  9379  	            // Hash final blocks
  9380  	            this._process();
  9381  
  9382  	            // Shortcuts
  9383  	            var hash = this._hash;
  9384  	            var H = hash.words;
  9385  
  9386  	            // Swap endian
  9387  	            for (var i = 0; i < 4; i++) {
  9388  	                // Shortcut
  9389  	                var H_i = H[i];
  9390  
  9391  	                H[i] = (((H_i << 8)  | (H_i >>> 24)) & 0x00ff00ff) |
  9392  	                       (((H_i << 24) | (H_i >>> 8))  & 0xff00ff00);
  9393  	            }
  9394  
  9395  	            // Return final computed hash
  9396  	            return hash;
  9397  	        },
  9398  
  9399  	        clone: function () {
  9400  	            var clone = Hasher.clone.call(this);
  9401  	            clone._hash = this._hash.clone();
  9402  
  9403  	            return clone;
  9404  	        }
  9405  	    });
  9406  
  9407  	    function FF(a, b, c, d, x, s, t) {
  9408  	        var n = a + ((b & c) | (~b & d)) + x + t;
  9409  	        return ((n << s) | (n >>> (32 - s))) + b;
  9410  	    }
  9411  
  9412  	    function GG(a, b, c, d, x, s, t) {
  9413  	        var n = a + ((b & d) | (c & ~d)) + x + t;
  9414  	        return ((n << s) | (n >>> (32 - s))) + b;
  9415  	    }
  9416  
  9417  	    function HH(a, b, c, d, x, s, t) {
  9418  	        var n = a + (b ^ c ^ d) + x + t;
  9419  	        return ((n << s) | (n >>> (32 - s))) + b;
  9420  	    }
  9421  
  9422  	    function II(a, b, c, d, x, s, t) {
  9423  	        var n = a + (c ^ (b | ~d)) + x + t;
  9424  	        return ((n << s) | (n >>> (32 - s))) + b;
  9425  	    }
  9426  
  9427  	    /**
  9428  	     * Shortcut function to the hasher's object interface.
  9429  	     *
  9430  	     * @param {WordArray|string} message The message to hash.
  9431  	     *
  9432  	     * @return {WordArray} The hash.
  9433  	     *
  9434  	     * @static
  9435  	     *
  9436  	     * @example
  9437  	     *
  9438  	     *     var hash = CryptoJS.MD5('message');
  9439  	     *     var hash = CryptoJS.MD5(wordArray);
  9440  	     */
  9441  	    C.MD5 = Hasher._createHelper(MD5);
  9442  
  9443  	    /**
  9444  	     * Shortcut function to the HMAC's object interface.
  9445  	     *
  9446  	     * @param {WordArray|string} message The message to hash.
  9447  	     * @param {WordArray|string} key The secret key.
  9448  	     *
  9449  	     * @return {WordArray} The HMAC.
  9450  	     *
  9451  	     * @static
  9452  	     *
  9453  	     * @example
  9454  	     *
  9455  	     *     var hmac = CryptoJS.HmacMD5(message, key);
  9456  	     */
  9457  	    C.HmacMD5 = Hasher._createHmacHelper(MD5);
  9458  	}(Math));
  9459  
  9460  
  9461  	return CryptoJS.MD5;
  9462  
  9463  }));
  9464  },{"./core":53}],62:[function(require,module,exports){
  9465  ;(function (root, factory, undef) {
  9466  	if (typeof exports === "object") {
  9467  		// CommonJS
  9468  		module.exports = exports = factory(require("./core"), require("./cipher-core"));
  9469  	}
  9470  	else if (typeof define === "function" && define.amd) {
  9471  		// AMD
  9472  		define(["./core", "./cipher-core"], factory);
  9473  	}
  9474  	else {
  9475  		// Global (browser)
  9476  		factory(root.CryptoJS);
  9477  	}
  9478  }(this, function (CryptoJS) {
  9479  
  9480  	/**
  9481  	 * Cipher Feedback block mode.
  9482  	 */
  9483  	CryptoJS.mode.CFB = (function () {
  9484  	    var CFB = CryptoJS.lib.BlockCipherMode.extend();
  9485  
  9486  	    CFB.Encryptor = CFB.extend({
  9487  	        processBlock: function (words, offset) {
  9488  	            // Shortcuts
  9489  	            var cipher = this._cipher;
  9490  	            var blockSize = cipher.blockSize;
  9491  
  9492  	            generateKeystreamAndEncrypt.call(this, words, offset, blockSize, cipher);
  9493  
  9494  	            // Remember this block to use with next block
  9495  	            this._prevBlock = words.slice(offset, offset + blockSize);
  9496  	        }
  9497  	    });
  9498  
  9499  	    CFB.Decryptor = CFB.extend({
  9500  	        processBlock: function (words, offset) {
  9501  	            // Shortcuts
  9502  	            var cipher = this._cipher;
  9503  	            var blockSize = cipher.blockSize;
  9504  
  9505  	            // Remember this block to use with next block
  9506  	            var thisBlock = words.slice(offset, offset + blockSize);
  9507  
  9508  	            generateKeystreamAndEncrypt.call(this, words, offset, blockSize, cipher);
  9509  
  9510  	            // This block becomes the previous block
  9511  	            this._prevBlock = thisBlock;
  9512  	        }
  9513  	    });
  9514  
  9515  	    function generateKeystreamAndEncrypt(words, offset, blockSize, cipher) {
  9516  	        // Shortcut
  9517  	        var iv = this._iv;
  9518  
  9519  	        // Generate keystream
  9520  	        if (iv) {
  9521  	            var keystream = iv.slice(0);
  9522  
  9523  	            // Remove IV for subsequent blocks
  9524  	            this._iv = undefined;
  9525  	        } else {
  9526  	            var keystream = this._prevBlock;
  9527  	        }
  9528  	        cipher.encryptBlock(keystream, 0);
  9529  
  9530  	        // Encrypt
  9531  	        for (var i = 0; i < blockSize; i++) {
  9532  	            words[offset + i] ^= keystream[i];
  9533  	        }
  9534  	    }
  9535  
  9536  	    return CFB;
  9537  	}());
  9538  
  9539  
  9540  	return CryptoJS.mode.CFB;
  9541  
  9542  }));
  9543  },{"./cipher-core":52,"./core":53}],63:[function(require,module,exports){
  9544  ;(function (root, factory, undef) {
  9545  	if (typeof exports === "object") {
  9546  		// CommonJS
  9547  		module.exports = exports = factory(require("./core"), require("./cipher-core"));
  9548  	}
  9549  	else if (typeof define === "function" && define.amd) {
  9550  		// AMD
  9551  		define(["./core", "./cipher-core"], factory);
  9552  	}
  9553  	else {
  9554  		// Global (browser)
  9555  		factory(root.CryptoJS);
  9556  	}
  9557  }(this, function (CryptoJS) {
  9558  
  9559  	/** @preserve
  9560  	 * Counter block mode compatible with  Dr Brian Gladman fileenc.c
  9561  	 * derived from CryptoJS.mode.CTR
  9562  	 * Jan Hruby jhruby.web@gmail.com
  9563  	 */
  9564  	CryptoJS.mode.CTRGladman = (function () {
  9565  	    var CTRGladman = CryptoJS.lib.BlockCipherMode.extend();
  9566  
  9567  		function incWord(word)
  9568  		{
  9569  			if (((word >> 24) & 0xff) === 0xff) { //overflow
  9570  			var b1 = (word >> 16)&0xff;
  9571  			var b2 = (word >> 8)&0xff;
  9572  			var b3 = word & 0xff;
  9573  
  9574  			if (b1 === 0xff) // overflow b1
  9575  			{
  9576  			b1 = 0;
  9577  			if (b2 === 0xff)
  9578  			{
  9579  				b2 = 0;
  9580  				if (b3 === 0xff)
  9581  				{
  9582  					b3 = 0;
  9583  				}
  9584  				else
  9585  				{
  9586  					++b3;
  9587  				}
  9588  			}
  9589  			else
  9590  			{
  9591  				++b2;
  9592  			}
  9593  			}
  9594  			else
  9595  			{
  9596  			++b1;
  9597  			}
  9598  
  9599  			word = 0;
  9600  			word += (b1 << 16);
  9601  			word += (b2 << 8);
  9602  			word += b3;
  9603  			}
  9604  			else
  9605  			{
  9606  			word += (0x01 << 24);
  9607  			}
  9608  			return word;
  9609  		}
  9610  
  9611  		function incCounter(counter)
  9612  		{
  9613  			if ((counter[0] = incWord(counter[0])) === 0)
  9614  			{
  9615  				// encr_data in fileenc.c from  Dr Brian Gladman's counts only with DWORD j < 8
  9616  				counter[1] = incWord(counter[1]);
  9617  			}
  9618  			return counter;
  9619  		}
  9620  
  9621  	    var Encryptor = CTRGladman.Encryptor = CTRGladman.extend({
  9622  	        processBlock: function (words, offset) {
  9623  	            // Shortcuts
  9624  	            var cipher = this._cipher
  9625  	            var blockSize = cipher.blockSize;
  9626  	            var iv = this._iv;
  9627  	            var counter = this._counter;
  9628  
  9629  	            // Generate keystream
  9630  	            if (iv) {
  9631  	                counter = this._counter = iv.slice(0);
  9632  
  9633  	                // Remove IV for subsequent blocks
  9634  	                this._iv = undefined;
  9635  	            }
  9636  
  9637  				incCounter(counter);
  9638  
  9639  				var keystream = counter.slice(0);
  9640  	            cipher.encryptBlock(keystream, 0);
  9641  
  9642  	            // Encrypt
  9643  	            for (var i = 0; i < blockSize; i++) {
  9644  	                words[offset + i] ^= keystream[i];
  9645  	            }
  9646  	        }
  9647  	    });
  9648  
  9649  	    CTRGladman.Decryptor = Encryptor;
  9650  
  9651  	    return CTRGladman;
  9652  	}());
  9653  
  9654  
  9655  
  9656  
  9657  	return CryptoJS.mode.CTRGladman;
  9658  
  9659  }));
  9660  },{"./cipher-core":52,"./core":53}],64:[function(require,module,exports){
  9661  ;(function (root, factory, undef) {
  9662  	if (typeof exports === "object") {
  9663  		// CommonJS
  9664  		module.exports = exports = factory(require("./core"), require("./cipher-core"));
  9665  	}
  9666  	else if (typeof define === "function" && define.amd) {
  9667  		// AMD
  9668  		define(["./core", "./cipher-core"], factory);
  9669  	}
  9670  	else {
  9671  		// Global (browser)
  9672  		factory(root.CryptoJS);
  9673  	}
  9674  }(this, function (CryptoJS) {
  9675  
  9676  	/**
  9677  	 * Counter block mode.
  9678  	 */
  9679  	CryptoJS.mode.CTR = (function () {
  9680  	    var CTR = CryptoJS.lib.BlockCipherMode.extend();
  9681  
  9682  	    var Encryptor = CTR.Encryptor = CTR.extend({
  9683  	        processBlock: function (words, offset) {
  9684  	            // Shortcuts
  9685  	            var cipher = this._cipher
  9686  	            var blockSize = cipher.blockSize;
  9687  	            var iv = this._iv;
  9688  	            var counter = this._counter;
  9689  
  9690  	            // Generate keystream
  9691  	            if (iv) {
  9692  	                counter = this._counter = iv.slice(0);
  9693  
  9694  	                // Remove IV for subsequent blocks
  9695  	                this._iv = undefined;
  9696  	            }
  9697  	            var keystream = counter.slice(0);
  9698  	            cipher.encryptBlock(keystream, 0);
  9699  
  9700  	            // Increment counter
  9701  	            counter[blockSize - 1] = (counter[blockSize - 1] + 1) | 0
  9702  
  9703  	            // Encrypt
  9704  	            for (var i = 0; i < blockSize; i++) {
  9705  	                words[offset + i] ^= keystream[i];
  9706  	            }
  9707  	        }
  9708  	    });
  9709  
  9710  	    CTR.Decryptor = Encryptor;
  9711  
  9712  	    return CTR;
  9713  	}());
  9714  
  9715  
  9716  	return CryptoJS.mode.CTR;
  9717  
  9718  }));
  9719  },{"./cipher-core":52,"./core":53}],65:[function(require,module,exports){
  9720  ;(function (root, factory, undef) {
  9721  	if (typeof exports === "object") {
  9722  		// CommonJS
  9723  		module.exports = exports = factory(require("./core"), require("./cipher-core"));
  9724  	}
  9725  	else if (typeof define === "function" && define.amd) {
  9726  		// AMD
  9727  		define(["./core", "./cipher-core"], factory);
  9728  	}
  9729  	else {
  9730  		// Global (browser)
  9731  		factory(root.CryptoJS);
  9732  	}
  9733  }(this, function (CryptoJS) {
  9734  
  9735  	/**
  9736  	 * Electronic Codebook block mode.
  9737  	 */
  9738  	CryptoJS.mode.ECB = (function () {
  9739  	    var ECB = CryptoJS.lib.BlockCipherMode.extend();
  9740  
  9741  	    ECB.Encryptor = ECB.extend({
  9742  	        processBlock: function (words, offset) {
  9743  	            this._cipher.encryptBlock(words, offset);
  9744  	        }
  9745  	    });
  9746  
  9747  	    ECB.Decryptor = ECB.extend({
  9748  	        processBlock: function (words, offset) {
  9749  	            this._cipher.decryptBlock(words, offset);
  9750  	        }
  9751  	    });
  9752  
  9753  	    return ECB;
  9754  	}());
  9755  
  9756  
  9757  	return CryptoJS.mode.ECB;
  9758  
  9759  }));
  9760  },{"./cipher-core":52,"./core":53}],66:[function(require,module,exports){
  9761  ;(function (root, factory, undef) {
  9762  	if (typeof exports === "object") {
  9763  		// CommonJS
  9764  		module.exports = exports = factory(require("./core"), require("./cipher-core"));
  9765  	}
  9766  	else if (typeof define === "function" && define.amd) {
  9767  		// AMD
  9768  		define(["./core", "./cipher-core"], factory);
  9769  	}
  9770  	else {
  9771  		// Global (browser)
  9772  		factory(root.CryptoJS);
  9773  	}
  9774  }(this, function (CryptoJS) {
  9775  
  9776  	/**
  9777  	 * Output Feedback block mode.
  9778  	 */
  9779  	CryptoJS.mode.OFB = (function () {
  9780  	    var OFB = CryptoJS.lib.BlockCipherMode.extend();
  9781  
  9782  	    var Encryptor = OFB.Encryptor = OFB.extend({
  9783  	        processBlock: function (words, offset) {
  9784  	            // Shortcuts
  9785  	            var cipher = this._cipher
  9786  	            var blockSize = cipher.blockSize;
  9787  	            var iv = this._iv;
  9788  	            var keystream = this._keystream;
  9789  
  9790  	            // Generate keystream
  9791  	            if (iv) {
  9792  	                keystream = this._keystream = iv.slice(0);
  9793  
  9794  	                // Remove IV for subsequent blocks
  9795  	                this._iv = undefined;
  9796  	            }
  9797  	            cipher.encryptBlock(keystream, 0);
  9798  
  9799  	            // Encrypt
  9800  	            for (var i = 0; i < blockSize; i++) {
  9801  	                words[offset + i] ^= keystream[i];
  9802  	            }
  9803  	        }
  9804  	    });
  9805  
  9806  	    OFB.Decryptor = Encryptor;
  9807  
  9808  	    return OFB;
  9809  	}());
  9810  
  9811  
  9812  	return CryptoJS.mode.OFB;
  9813  
  9814  }));
  9815  },{"./cipher-core":52,"./core":53}],67:[function(require,module,exports){
  9816  ;(function (root, factory, undef) {
  9817  	if (typeof exports === "object") {
  9818  		// CommonJS
  9819  		module.exports = exports = factory(require("./core"), require("./cipher-core"));
  9820  	}
  9821  	else if (typeof define === "function" && define.amd) {
  9822  		// AMD
  9823  		define(["./core", "./cipher-core"], factory);
  9824  	}
  9825  	else {
  9826  		// Global (browser)
  9827  		factory(root.CryptoJS);
  9828  	}
  9829  }(this, function (CryptoJS) {
  9830  
  9831  	/**
  9832  	 * ANSI X.923 padding strategy.
  9833  	 */
  9834  	CryptoJS.pad.AnsiX923 = {
  9835  	    pad: function (data, blockSize) {
  9836  	        // Shortcuts
  9837  	        var dataSigBytes = data.sigBytes;
  9838  	        var blockSizeBytes = blockSize * 4;
  9839  
  9840  	        // Count padding bytes
  9841  	        var nPaddingBytes = blockSizeBytes - dataSigBytes % blockSizeBytes;
  9842  
  9843  	        // Compute last byte position
  9844  	        var lastBytePos = dataSigBytes + nPaddingBytes - 1;
  9845  
  9846  	        // Pad
  9847  	        data.clamp();
  9848  	        data.words[lastBytePos >>> 2] |= nPaddingBytes << (24 - (lastBytePos % 4) * 8);
  9849  	        data.sigBytes += nPaddingBytes;
  9850  	    },
  9851  
  9852  	    unpad: function (data) {
  9853  	        // Get number of padding bytes from last byte
  9854  	        var nPaddingBytes = data.words[(data.sigBytes - 1) >>> 2] & 0xff;
  9855  
  9856  	        // Remove padding
  9857  	        data.sigBytes -= nPaddingBytes;
  9858  	    }
  9859  	};
  9860  
  9861  
  9862  	return CryptoJS.pad.Ansix923;
  9863  
  9864  }));
  9865  },{"./cipher-core":52,"./core":53}],68:[function(require,module,exports){
  9866  ;(function (root, factory, undef) {
  9867  	if (typeof exports === "object") {
  9868  		// CommonJS
  9869  		module.exports = exports = factory(require("./core"), require("./cipher-core"));
  9870  	}
  9871  	else if (typeof define === "function" && define.amd) {
  9872  		// AMD
  9873  		define(["./core", "./cipher-core"], factory);
  9874  	}
  9875  	else {
  9876  		// Global (browser)
  9877  		factory(root.CryptoJS);
  9878  	}
  9879  }(this, function (CryptoJS) {
  9880  
  9881  	/**
  9882  	 * ISO 10126 padding strategy.
  9883  	 */
  9884  	CryptoJS.pad.Iso10126 = {
  9885  	    pad: function (data, blockSize) {
  9886  	        // Shortcut
  9887  	        var blockSizeBytes = blockSize * 4;
  9888  
  9889  	        // Count padding bytes
  9890  	        var nPaddingBytes = blockSizeBytes - data.sigBytes % blockSizeBytes;
  9891  
  9892  	        // Pad
  9893  	        data.concat(CryptoJS.lib.WordArray.random(nPaddingBytes - 1)).
  9894  	             concat(CryptoJS.lib.WordArray.create([nPaddingBytes << 24], 1));
  9895  	    },
  9896  
  9897  	    unpad: function (data) {
  9898  	        // Get number of padding bytes from last byte
  9899  	        var nPaddingBytes = data.words[(data.sigBytes - 1) >>> 2] & 0xff;
  9900  
  9901  	        // Remove padding
  9902  	        data.sigBytes -= nPaddingBytes;
  9903  	    }
  9904  	};
  9905  
  9906  
  9907  	return CryptoJS.pad.Iso10126;
  9908  
  9909  }));
  9910  },{"./cipher-core":52,"./core":53}],69:[function(require,module,exports){
  9911  ;(function (root, factory, undef) {
  9912  	if (typeof exports === "object") {
  9913  		// CommonJS
  9914  		module.exports = exports = factory(require("./core"), require("./cipher-core"));
  9915  	}
  9916  	else if (typeof define === "function" && define.amd) {
  9917  		// AMD
  9918  		define(["./core", "./cipher-core"], factory);
  9919  	}
  9920  	else {
  9921  		// Global (browser)
  9922  		factory(root.CryptoJS);
  9923  	}
  9924  }(this, function (CryptoJS) {
  9925  
  9926  	/**
  9927  	 * ISO/IEC 9797-1 Padding Method 2.
  9928  	 */
  9929  	CryptoJS.pad.Iso97971 = {
  9930  	    pad: function (data, blockSize) {
  9931  	        // Add 0x80 byte
  9932  	        data.concat(CryptoJS.lib.WordArray.create([0x80000000], 1));
  9933  
  9934  	        // Zero pad the rest
  9935  	        CryptoJS.pad.ZeroPadding.pad(data, blockSize);
  9936  	    },
  9937  
  9938  	    unpad: function (data) {
  9939  	        // Remove zero padding
  9940  	        CryptoJS.pad.ZeroPadding.unpad(data);
  9941  
  9942  	        // Remove one more byte -- the 0x80 byte
  9943  	        data.sigBytes--;
  9944  	    }
  9945  	};
  9946  
  9947  
  9948  	return CryptoJS.pad.Iso97971;
  9949  
  9950  }));
  9951  },{"./cipher-core":52,"./core":53}],70:[function(require,module,exports){
  9952  ;(function (root, factory, undef) {
  9953  	if (typeof exports === "object") {
  9954  		// CommonJS
  9955  		module.exports = exports = factory(require("./core"), require("./cipher-core"));
  9956  	}
  9957  	else if (typeof define === "function" && define.amd) {
  9958  		// AMD
  9959  		define(["./core", "./cipher-core"], factory);
  9960  	}
  9961  	else {
  9962  		// Global (browser)
  9963  		factory(root.CryptoJS);
  9964  	}
  9965  }(this, function (CryptoJS) {
  9966  
  9967  	/**
  9968  	 * A noop padding strategy.
  9969  	 */
  9970  	CryptoJS.pad.NoPadding = {
  9971  	    pad: function () {
  9972  	    },
  9973  
  9974  	    unpad: function () {
  9975  	    }
  9976  	};
  9977  
  9978  
  9979  	return CryptoJS.pad.NoPadding;
  9980  
  9981  }));
  9982  },{"./cipher-core":52,"./core":53}],71:[function(require,module,exports){
  9983  ;(function (root, factory, undef) {
  9984  	if (typeof exports === "object") {
  9985  		// CommonJS
  9986  		module.exports = exports = factory(require("./core"), require("./cipher-core"));
  9987  	}
  9988  	else if (typeof define === "function" && define.amd) {
  9989  		// AMD
  9990  		define(["./core", "./cipher-core"], factory);
  9991  	}
  9992  	else {
  9993  		// Global (browser)
  9994  		factory(root.CryptoJS);
  9995  	}
  9996  }(this, function (CryptoJS) {
  9997  
  9998  	/**
  9999  	 * Zero padding strategy.
 10000  	 */
 10001  	CryptoJS.pad.ZeroPadding = {
 10002  	    pad: function (data, blockSize) {
 10003  	        // Shortcut
 10004  	        var blockSizeBytes = blockSize * 4;
 10005  
 10006  	        // Pad
 10007  	        data.clamp();
 10008  	        data.sigBytes += blockSizeBytes - ((data.sigBytes % blockSizeBytes) || blockSizeBytes);
 10009  	    },
 10010  
 10011  	    unpad: function (data) {
 10012  	        // Shortcut
 10013  	        var dataWords = data.words;
 10014  
 10015  	        // Unpad
 10016  	        var i = data.sigBytes - 1;
 10017  	        while (!((dataWords[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff)) {
 10018  	            i--;
 10019  	        }
 10020  	        data.sigBytes = i + 1;
 10021  	    }
 10022  	};
 10023  
 10024  
 10025  	return CryptoJS.pad.ZeroPadding;
 10026  
 10027  }));
 10028  },{"./cipher-core":52,"./core":53}],72:[function(require,module,exports){
 10029  ;(function (root, factory, undef) {
 10030  	if (typeof exports === "object") {
 10031  		// CommonJS
 10032  		module.exports = exports = factory(require("./core"), require("./sha1"), require("./hmac"));
 10033  	}
 10034  	else if (typeof define === "function" && define.amd) {
 10035  		// AMD
 10036  		define(["./core", "./sha1", "./hmac"], factory);
 10037  	}
 10038  	else {
 10039  		// Global (browser)
 10040  		factory(root.CryptoJS);
 10041  	}
 10042  }(this, function (CryptoJS) {
 10043  
 10044  	(function () {
 10045  	    // Shortcuts
 10046  	    var C = CryptoJS;
 10047  	    var C_lib = C.lib;
 10048  	    var Base = C_lib.Base;
 10049  	    var WordArray = C_lib.WordArray;
 10050  	    var C_algo = C.algo;
 10051  	    var SHA1 = C_algo.SHA1;
 10052  	    var HMAC = C_algo.HMAC;
 10053  
 10054  	    /**
 10055  	     * Password-Based Key Derivation Function 2 algorithm.
 10056  	     */
 10057  	    var PBKDF2 = C_algo.PBKDF2 = Base.extend({
 10058  	        /**
 10059  	         * Configuration options.
 10060  	         *
 10061  	         * @property {number} keySize The key size in words to generate. Default: 4 (128 bits)
 10062  	         * @property {Hasher} hasher The hasher to use. Default: SHA1
 10063  	         * @property {number} iterations The number of iterations to perform. Default: 1
 10064  	         */
 10065  	        cfg: Base.extend({
 10066  	            keySize: 128/32,
 10067  	            hasher: SHA1,
 10068  	            iterations: 1
 10069  	        }),
 10070  
 10071  	        /**
 10072  	         * Initializes a newly created key derivation function.
 10073  	         *
 10074  	         * @param {Object} cfg (Optional) The configuration options to use for the derivation.
 10075  	         *
 10076  	         * @example
 10077  	         *
 10078  	         *     var kdf = CryptoJS.algo.PBKDF2.create();
 10079  	         *     var kdf = CryptoJS.algo.PBKDF2.create({ keySize: 8 });
 10080  	         *     var kdf = CryptoJS.algo.PBKDF2.create({ keySize: 8, iterations: 1000 });
 10081  	         */
 10082  	        init: function (cfg) {
 10083  	            this.cfg = this.cfg.extend(cfg);
 10084  	        },
 10085  
 10086  	        /**
 10087  	         * Computes the Password-Based Key Derivation Function 2.
 10088  	         *
 10089  	         * @param {WordArray|string} password The password.
 10090  	         * @param {WordArray|string} salt A salt.
 10091  	         *
 10092  	         * @return {WordArray} The derived key.
 10093  	         *
 10094  	         * @example
 10095  	         *
 10096  	         *     var key = kdf.compute(password, salt);
 10097  	         */
 10098  	        compute: function (password, salt) {
 10099  	            // Shortcut
 10100  	            var cfg = this.cfg;
 10101  
 10102  	            // Init HMAC
 10103  	            var hmac = HMAC.create(cfg.hasher, password);
 10104  
 10105  	            // Initial values
 10106  	            var derivedKey = WordArray.create();
 10107  	            var blockIndex = WordArray.create([0x00000001]);
 10108  
 10109  	            // Shortcuts
 10110  	            var derivedKeyWords = derivedKey.words;
 10111  	            var blockIndexWords = blockIndex.words;
 10112  	            var keySize = cfg.keySize;
 10113  	            var iterations = cfg.iterations;
 10114  
 10115  	            // Generate key
 10116  	            while (derivedKeyWords.length < keySize) {
 10117  	                var block = hmac.update(salt).finalize(blockIndex);
 10118  	                hmac.reset();
 10119  
 10120  	                // Shortcuts
 10121  	                var blockWords = block.words;
 10122  	                var blockWordsLength = blockWords.length;
 10123  
 10124  	                // Iterations
 10125  	                var intermediate = block;
 10126  	                for (var i = 1; i < iterations; i++) {
 10127  	                    intermediate = hmac.finalize(intermediate);
 10128  	                    hmac.reset();
 10129  
 10130  	                    // Shortcut
 10131  	                    var intermediateWords = intermediate.words;
 10132  
 10133  	                    // XOR intermediate with block
 10134  	                    for (var j = 0; j < blockWordsLength; j++) {
 10135  	                        blockWords[j] ^= intermediateWords[j];
 10136  	                    }
 10137  	                }
 10138  
 10139  	                derivedKey.concat(block);
 10140  	                blockIndexWords[0]++;
 10141  	            }
 10142  	            derivedKey.sigBytes = keySize * 4;
 10143  
 10144  	            return derivedKey;
 10145  	        }
 10146  	    });
 10147  
 10148  	    /**
 10149  	     * Computes the Password-Based Key Derivation Function 2.
 10150  	     *
 10151  	     * @param {WordArray|string} password The password.
 10152  	     * @param {WordArray|string} salt A salt.
 10153  	     * @param {Object} cfg (Optional) The configuration options to use for this computation.
 10154  	     *
 10155  	     * @return {WordArray} The derived key.
 10156  	     *
 10157  	     * @static
 10158  	     *
 10159  	     * @example
 10160  	     *
 10161  	     *     var key = CryptoJS.PBKDF2(password, salt);
 10162  	     *     var key = CryptoJS.PBKDF2(password, salt, { keySize: 8 });
 10163  	     *     var key = CryptoJS.PBKDF2(password, salt, { keySize: 8, iterations: 1000 });
 10164  	     */
 10165  	    C.PBKDF2 = function (password, salt, cfg) {
 10166  	        return PBKDF2.create(cfg).compute(password, salt);
 10167  	    };
 10168  	}());
 10169  
 10170  
 10171  	return CryptoJS.PBKDF2;
 10172  
 10173  }));
 10174  },{"./core":53,"./hmac":58,"./sha1":77}],73:[function(require,module,exports){
 10175  ;(function (root, factory, undef) {
 10176  	if (typeof exports === "object") {
 10177  		// CommonJS
 10178  		module.exports = exports = factory(require("./core"), require("./enc-base64"), require("./md5"), require("./evpkdf"), require("./cipher-core"));
 10179  	}
 10180  	else if (typeof define === "function" && define.amd) {
 10181  		// AMD
 10182  		define(["./core", "./enc-base64", "./md5", "./evpkdf", "./cipher-core"], factory);
 10183  	}
 10184  	else {
 10185  		// Global (browser)
 10186  		factory(root.CryptoJS);
 10187  	}
 10188  }(this, function (CryptoJS) {
 10189  
 10190  	(function () {
 10191  	    // Shortcuts
 10192  	    var C = CryptoJS;
 10193  	    var C_lib = C.lib;
 10194  	    var StreamCipher = C_lib.StreamCipher;
 10195  	    var C_algo = C.algo;
 10196  
 10197  	    // Reusable objects
 10198  	    var S  = [];
 10199  	    var C_ = [];
 10200  	    var G  = [];
 10201  
 10202  	    /**
 10203  	     * Rabbit stream cipher algorithm.
 10204  	     *
 10205  	     * This is a legacy version that neglected to convert the key to little-endian.
 10206  	     * This error doesn't affect the cipher's security,
 10207  	     * but it does affect its compatibility with other implementations.
 10208  	     */
 10209  	    var RabbitLegacy = C_algo.RabbitLegacy = StreamCipher.extend({
 10210  	        _doReset: function () {
 10211  	            // Shortcuts
 10212  	            var K = this._key.words;
 10213  	            var iv = this.cfg.iv;
 10214  
 10215  	            // Generate initial state values
 10216  	            var X = this._X = [
 10217  	                K[0], (K[3] << 16) | (K[2] >>> 16),
 10218  	                K[1], (K[0] << 16) | (K[3] >>> 16),
 10219  	                K[2], (K[1] << 16) | (K[0] >>> 16),
 10220  	                K[3], (K[2] << 16) | (K[1] >>> 16)
 10221  	            ];
 10222  
 10223  	            // Generate initial counter values
 10224  	            var C = this._C = [
 10225  	                (K[2] << 16) | (K[2] >>> 16), (K[0] & 0xffff0000) | (K[1] & 0x0000ffff),
 10226  	                (K[3] << 16) | (K[3] >>> 16), (K[1] & 0xffff0000) | (K[2] & 0x0000ffff),
 10227  	                (K[0] << 16) | (K[0] >>> 16), (K[2] & 0xffff0000) | (K[3] & 0x0000ffff),
 10228  	                (K[1] << 16) | (K[1] >>> 16), (K[3] & 0xffff0000) | (K[0] & 0x0000ffff)
 10229  	            ];
 10230  
 10231  	            // Carry bit
 10232  	            this._b = 0;
 10233  
 10234  	            // Iterate the system four times
 10235  	            for (var i = 0; i < 4; i++) {
 10236  	                nextState.call(this);
 10237  	            }
 10238  
 10239  	            // Modify the counters
 10240  	            for (var i = 0; i < 8; i++) {
 10241  	                C[i] ^= X[(i + 4) & 7];
 10242  	            }
 10243  
 10244  	            // IV setup
 10245  	            if (iv) {
 10246  	                // Shortcuts
 10247  	                var IV = iv.words;
 10248  	                var IV_0 = IV[0];
 10249  	                var IV_1 = IV[1];
 10250  
 10251  	                // Generate four subvectors
 10252  	                var i0 = (((IV_0 << 8) | (IV_0 >>> 24)) & 0x00ff00ff) | (((IV_0 << 24) | (IV_0 >>> 8)) & 0xff00ff00);
 10253  	                var i2 = (((IV_1 << 8) | (IV_1 >>> 24)) & 0x00ff00ff) | (((IV_1 << 24) | (IV_1 >>> 8)) & 0xff00ff00);
 10254  	                var i1 = (i0 >>> 16) | (i2 & 0xffff0000);
 10255  	                var i3 = (i2 << 16)  | (i0 & 0x0000ffff);
 10256  
 10257  	                // Modify counter values
 10258  	                C[0] ^= i0;
 10259  	                C[1] ^= i1;
 10260  	                C[2] ^= i2;
 10261  	                C[3] ^= i3;
 10262  	                C[4] ^= i0;
 10263  	                C[5] ^= i1;
 10264  	                C[6] ^= i2;
 10265  	                C[7] ^= i3;
 10266  
 10267  	                // Iterate the system four times
 10268  	                for (var i = 0; i < 4; i++) {
 10269  	                    nextState.call(this);
 10270  	                }
 10271  	            }
 10272  	        },
 10273  
 10274  	        _doProcessBlock: function (M, offset) {
 10275  	            // Shortcut
 10276  	            var X = this._X;
 10277  
 10278  	            // Iterate the system
 10279  	            nextState.call(this);
 10280  
 10281  	            // Generate four keystream words
 10282  	            S[0] = X[0] ^ (X[5] >>> 16) ^ (X[3] << 16);
 10283  	            S[1] = X[2] ^ (X[7] >>> 16) ^ (X[5] << 16);
 10284  	            S[2] = X[4] ^ (X[1] >>> 16) ^ (X[7] << 16);
 10285  	            S[3] = X[6] ^ (X[3] >>> 16) ^ (X[1] << 16);
 10286  
 10287  	            for (var i = 0; i < 4; i++) {
 10288  	                // Swap endian
 10289  	                S[i] = (((S[i] << 8)  | (S[i] >>> 24)) & 0x00ff00ff) |
 10290  	                       (((S[i] << 24) | (S[i] >>> 8))  & 0xff00ff00);
 10291  
 10292  	                // Encrypt
 10293  	                M[offset + i] ^= S[i];
 10294  	            }
 10295  	        },
 10296  
 10297  	        blockSize: 128/32,
 10298  
 10299  	        ivSize: 64/32
 10300  	    });
 10301  
 10302  	    function nextState() {
 10303  	        // Shortcuts
 10304  	        var X = this._X;
 10305  	        var C = this._C;
 10306  
 10307  	        // Save old counter values
 10308  	        for (var i = 0; i < 8; i++) {
 10309  	            C_[i] = C[i];
 10310  	        }
 10311  
 10312  	        // Calculate new counter values
 10313  	        C[0] = (C[0] + 0x4d34d34d + this._b) | 0;
 10314  	        C[1] = (C[1] + 0xd34d34d3 + ((C[0] >>> 0) < (C_[0] >>> 0) ? 1 : 0)) | 0;
 10315  	        C[2] = (C[2] + 0x34d34d34 + ((C[1] >>> 0) < (C_[1] >>> 0) ? 1 : 0)) | 0;
 10316  	        C[3] = (C[3] + 0x4d34d34d + ((C[2] >>> 0) < (C_[2] >>> 0) ? 1 : 0)) | 0;
 10317  	        C[4] = (C[4] + 0xd34d34d3 + ((C[3] >>> 0) < (C_[3] >>> 0) ? 1 : 0)) | 0;
 10318  	        C[5] = (C[5] + 0x34d34d34 + ((C[4] >>> 0) < (C_[4] >>> 0) ? 1 : 0)) | 0;
 10319  	        C[6] = (C[6] + 0x4d34d34d + ((C[5] >>> 0) < (C_[5] >>> 0) ? 1 : 0)) | 0;
 10320  	        C[7] = (C[7] + 0xd34d34d3 + ((C[6] >>> 0) < (C_[6] >>> 0) ? 1 : 0)) | 0;
 10321  	        this._b = (C[7] >>> 0) < (C_[7] >>> 0) ? 1 : 0;
 10322  
 10323  	        // Calculate the g-values
 10324  	        for (var i = 0; i < 8; i++) {
 10325  	            var gx = X[i] + C[i];
 10326  
 10327  	            // Construct high and low argument for squaring
 10328  	            var ga = gx & 0xffff;
 10329  	            var gb = gx >>> 16;
 10330  
 10331  	            // Calculate high and low result of squaring
 10332  	            var gh = ((((ga * ga) >>> 17) + ga * gb) >>> 15) + gb * gb;
 10333  	            var gl = (((gx & 0xffff0000) * gx) | 0) + (((gx & 0x0000ffff) * gx) | 0);
 10334  
 10335  	            // High XOR low
 10336  	            G[i] = gh ^ gl;
 10337  	        }
 10338  
 10339  	        // Calculate new state values
 10340  	        X[0] = (G[0] + ((G[7] << 16) | (G[7] >>> 16)) + ((G[6] << 16) | (G[6] >>> 16))) | 0;
 10341  	        X[1] = (G[1] + ((G[0] << 8)  | (G[0] >>> 24)) + G[7]) | 0;
 10342  	        X[2] = (G[2] + ((G[1] << 16) | (G[1] >>> 16)) + ((G[0] << 16) | (G[0] >>> 16))) | 0;
 10343  	        X[3] = (G[3] + ((G[2] << 8)  | (G[2] >>> 24)) + G[1]) | 0;
 10344  	        X[4] = (G[4] + ((G[3] << 16) | (G[3] >>> 16)) + ((G[2] << 16) | (G[2] >>> 16))) | 0;
 10345  	        X[5] = (G[5] + ((G[4] << 8)  | (G[4] >>> 24)) + G[3]) | 0;
 10346  	        X[6] = (G[6] + ((G[5] << 16) | (G[5] >>> 16)) + ((G[4] << 16) | (G[4] >>> 16))) | 0;
 10347  	        X[7] = (G[7] + ((G[6] << 8)  | (G[6] >>> 24)) + G[5]) | 0;
 10348  	    }
 10349  
 10350  	    /**
 10351  	     * Shortcut functions to the cipher's object interface.
 10352  	     *
 10353  	     * @example
 10354  	     *
 10355  	     *     var ciphertext = CryptoJS.RabbitLegacy.encrypt(message, key, cfg);
 10356  	     *     var plaintext  = CryptoJS.RabbitLegacy.decrypt(ciphertext, key, cfg);
 10357  	     */
 10358  	    C.RabbitLegacy = StreamCipher._createHelper(RabbitLegacy);
 10359  	}());
 10360  
 10361  
 10362  	return CryptoJS.RabbitLegacy;
 10363  
 10364  }));
 10365  },{"./cipher-core":52,"./core":53,"./enc-base64":54,"./evpkdf":56,"./md5":61}],74:[function(require,module,exports){
 10366  ;(function (root, factory, undef) {
 10367  	if (typeof exports === "object") {
 10368  		// CommonJS
 10369  		module.exports = exports = factory(require("./core"), require("./enc-base64"), require("./md5"), require("./evpkdf"), require("./cipher-core"));
 10370  	}
 10371  	else if (typeof define === "function" && define.amd) {
 10372  		// AMD
 10373  		define(["./core", "./enc-base64", "./md5", "./evpkdf", "./cipher-core"], factory);
 10374  	}
 10375  	else {
 10376  		// Global (browser)
 10377  		factory(root.CryptoJS);
 10378  	}
 10379  }(this, function (CryptoJS) {
 10380  
 10381  	(function () {
 10382  	    // Shortcuts
 10383  	    var C = CryptoJS;
 10384  	    var C_lib = C.lib;
 10385  	    var StreamCipher = C_lib.StreamCipher;
 10386  	    var C_algo = C.algo;
 10387  
 10388  	    // Reusable objects
 10389  	    var S  = [];
 10390  	    var C_ = [];
 10391  	    var G  = [];
 10392  
 10393  	    /**
 10394  	     * Rabbit stream cipher algorithm
 10395  	     */
 10396  	    var Rabbit = C_algo.Rabbit = StreamCipher.extend({
 10397  	        _doReset: function () {
 10398  	            // Shortcuts
 10399  	            var K = this._key.words;
 10400  	            var iv = this.cfg.iv;
 10401  
 10402  	            // Swap endian
 10403  	            for (var i = 0; i < 4; i++) {
 10404  	                K[i] = (((K[i] << 8)  | (K[i] >>> 24)) & 0x00ff00ff) |
 10405  	                       (((K[i] << 24) | (K[i] >>> 8))  & 0xff00ff00);
 10406  	            }
 10407  
 10408  	            // Generate initial state values
 10409  	            var X = this._X = [
 10410  	                K[0], (K[3] << 16) | (K[2] >>> 16),
 10411  	                K[1], (K[0] << 16) | (K[3] >>> 16),
 10412  	                K[2], (K[1] << 16) | (K[0] >>> 16),
 10413  	                K[3], (K[2] << 16) | (K[1] >>> 16)
 10414  	            ];
 10415  
 10416  	            // Generate initial counter values
 10417  	            var C = this._C = [
 10418  	                (K[2] << 16) | (K[2] >>> 16), (K[0] & 0xffff0000) | (K[1] & 0x0000ffff),
 10419  	                (K[3] << 16) | (K[3] >>> 16), (K[1] & 0xffff0000) | (K[2] & 0x0000ffff),
 10420  	                (K[0] << 16) | (K[0] >>> 16), (K[2] & 0xffff0000) | (K[3] & 0x0000ffff),
 10421  	                (K[1] << 16) | (K[1] >>> 16), (K[3] & 0xffff0000) | (K[0] & 0x0000ffff)
 10422  	            ];
 10423  
 10424  	            // Carry bit
 10425  	            this._b = 0;
 10426  
 10427  	            // Iterate the system four times
 10428  	            for (var i = 0; i < 4; i++) {
 10429  	                nextState.call(this);
 10430  	            }
 10431  
 10432  	            // Modify the counters
 10433  	            for (var i = 0; i < 8; i++) {
 10434  	                C[i] ^= X[(i + 4) & 7];
 10435  	            }
 10436  
 10437  	            // IV setup
 10438  	            if (iv) {
 10439  	                // Shortcuts
 10440  	                var IV = iv.words;
 10441  	                var IV_0 = IV[0];
 10442  	                var IV_1 = IV[1];
 10443  
 10444  	                // Generate four subvectors
 10445  	                var i0 = (((IV_0 << 8) | (IV_0 >>> 24)) & 0x00ff00ff) | (((IV_0 << 24) | (IV_0 >>> 8)) & 0xff00ff00);
 10446  	                var i2 = (((IV_1 << 8) | (IV_1 >>> 24)) & 0x00ff00ff) | (((IV_1 << 24) | (IV_1 >>> 8)) & 0xff00ff00);
 10447  	                var i1 = (i0 >>> 16) | (i2 & 0xffff0000);
 10448  	                var i3 = (i2 << 16)  | (i0 & 0x0000ffff);
 10449  
 10450  	                // Modify counter values
 10451  	                C[0] ^= i0;
 10452  	                C[1] ^= i1;
 10453  	                C[2] ^= i2;
 10454  	                C[3] ^= i3;
 10455  	                C[4] ^= i0;
 10456  	                C[5] ^= i1;
 10457  	                C[6] ^= i2;
 10458  	                C[7] ^= i3;
 10459  
 10460  	                // Iterate the system four times
 10461  	                for (var i = 0; i < 4; i++) {
 10462  	                    nextState.call(this);
 10463  	                }
 10464  	            }
 10465  	        },
 10466  
 10467  	        _doProcessBlock: function (M, offset) {
 10468  	            // Shortcut
 10469  	            var X = this._X;
 10470  
 10471  	            // Iterate the system
 10472  	            nextState.call(this);
 10473  
 10474  	            // Generate four keystream words
 10475  	            S[0] = X[0] ^ (X[5] >>> 16) ^ (X[3] << 16);
 10476  	            S[1] = X[2] ^ (X[7] >>> 16) ^ (X[5] << 16);
 10477  	            S[2] = X[4] ^ (X[1] >>> 16) ^ (X[7] << 16);
 10478  	            S[3] = X[6] ^ (X[3] >>> 16) ^ (X[1] << 16);
 10479  
 10480  	            for (var i = 0; i < 4; i++) {
 10481  	                // Swap endian
 10482  	                S[i] = (((S[i] << 8)  | (S[i] >>> 24)) & 0x00ff00ff) |
 10483  	                       (((S[i] << 24) | (S[i] >>> 8))  & 0xff00ff00);
 10484  
 10485  	                // Encrypt
 10486  	                M[offset + i] ^= S[i];
 10487  	            }
 10488  	        },
 10489  
 10490  	        blockSize: 128/32,
 10491  
 10492  	        ivSize: 64/32
 10493  	    });
 10494  
 10495  	    function nextState() {
 10496  	        // Shortcuts
 10497  	        var X = this._X;
 10498  	        var C = this._C;
 10499  
 10500  	        // Save old counter values
 10501  	        for (var i = 0; i < 8; i++) {
 10502  	            C_[i] = C[i];
 10503  	        }
 10504  
 10505  	        // Calculate new counter values
 10506  	        C[0] = (C[0] + 0x4d34d34d + this._b) | 0;
 10507  	        C[1] = (C[1] + 0xd34d34d3 + ((C[0] >>> 0) < (C_[0] >>> 0) ? 1 : 0)) | 0;
 10508  	        C[2] = (C[2] + 0x34d34d34 + ((C[1] >>> 0) < (C_[1] >>> 0) ? 1 : 0)) | 0;
 10509  	        C[3] = (C[3] + 0x4d34d34d + ((C[2] >>> 0) < (C_[2] >>> 0) ? 1 : 0)) | 0;
 10510  	        C[4] = (C[4] + 0xd34d34d3 + ((C[3] >>> 0) < (C_[3] >>> 0) ? 1 : 0)) | 0;
 10511  	        C[5] = (C[5] + 0x34d34d34 + ((C[4] >>> 0) < (C_[4] >>> 0) ? 1 : 0)) | 0;
 10512  	        C[6] = (C[6] + 0x4d34d34d + ((C[5] >>> 0) < (C_[5] >>> 0) ? 1 : 0)) | 0;
 10513  	        C[7] = (C[7] + 0xd34d34d3 + ((C[6] >>> 0) < (C_[6] >>> 0) ? 1 : 0)) | 0;
 10514  	        this._b = (C[7] >>> 0) < (C_[7] >>> 0) ? 1 : 0;
 10515  
 10516  	        // Calculate the g-values
 10517  	        for (var i = 0; i < 8; i++) {
 10518  	            var gx = X[i] + C[i];
 10519  
 10520  	            // Construct high and low argument for squaring
 10521  	            var ga = gx & 0xffff;
 10522  	            var gb = gx >>> 16;
 10523  
 10524  	            // Calculate high and low result of squaring
 10525  	            var gh = ((((ga * ga) >>> 17) + ga * gb) >>> 15) + gb * gb;
 10526  	            var gl = (((gx & 0xffff0000) * gx) | 0) + (((gx & 0x0000ffff) * gx) | 0);
 10527  
 10528  	            // High XOR low
 10529  	            G[i] = gh ^ gl;
 10530  	        }
 10531  
 10532  	        // Calculate new state values
 10533  	        X[0] = (G[0] + ((G[7] << 16) | (G[7] >>> 16)) + ((G[6] << 16) | (G[6] >>> 16))) | 0;
 10534  	        X[1] = (G[1] + ((G[0] << 8)  | (G[0] >>> 24)) + G[7]) | 0;
 10535  	        X[2] = (G[2] + ((G[1] << 16) | (G[1] >>> 16)) + ((G[0] << 16) | (G[0] >>> 16))) | 0;
 10536  	        X[3] = (G[3] + ((G[2] << 8)  | (G[2] >>> 24)) + G[1]) | 0;
 10537  	        X[4] = (G[4] + ((G[3] << 16) | (G[3] >>> 16)) + ((G[2] << 16) | (G[2] >>> 16))) | 0;
 10538  	        X[5] = (G[5] + ((G[4] << 8)  | (G[4] >>> 24)) + G[3]) | 0;
 10539  	        X[6] = (G[6] + ((G[5] << 16) | (G[5] >>> 16)) + ((G[4] << 16) | (G[4] >>> 16))) | 0;
 10540  	        X[7] = (G[7] + ((G[6] << 8)  | (G[6] >>> 24)) + G[5]) | 0;
 10541  	    }
 10542  
 10543  	    /**
 10544  	     * Shortcut functions to the cipher's object interface.
 10545  	     *
 10546  	     * @example
 10547  	     *
 10548  	     *     var ciphertext = CryptoJS.Rabbit.encrypt(message, key, cfg);
 10549  	     *     var plaintext  = CryptoJS.Rabbit.decrypt(ciphertext, key, cfg);
 10550  	     */
 10551  	    C.Rabbit = StreamCipher._createHelper(Rabbit);
 10552  	}());
 10553  
 10554  
 10555  	return CryptoJS.Rabbit;
 10556  
 10557  }));
 10558  },{"./cipher-core":52,"./core":53,"./enc-base64":54,"./evpkdf":56,"./md5":61}],75:[function(require,module,exports){
 10559  ;(function (root, factory, undef) {
 10560  	if (typeof exports === "object") {
 10561  		// CommonJS
 10562  		module.exports = exports = factory(require("./core"), require("./enc-base64"), require("./md5"), require("./evpkdf"), require("./cipher-core"));
 10563  	}
 10564  	else if (typeof define === "function" && define.amd) {
 10565  		// AMD
 10566  		define(["./core", "./enc-base64", "./md5", "./evpkdf", "./cipher-core"], factory);
 10567  	}
 10568  	else {
 10569  		// Global (browser)
 10570  		factory(root.CryptoJS);
 10571  	}
 10572  }(this, function (CryptoJS) {
 10573  
 10574  	(function () {
 10575  	    // Shortcuts
 10576  	    var C = CryptoJS;
 10577  	    var C_lib = C.lib;
 10578  	    var StreamCipher = C_lib.StreamCipher;
 10579  	    var C_algo = C.algo;
 10580  
 10581  	    /**
 10582  	     * RC4 stream cipher algorithm.
 10583  	     */
 10584  	    var RC4 = C_algo.RC4 = StreamCipher.extend({
 10585  	        _doReset: function () {
 10586  	            // Shortcuts
 10587  	            var key = this._key;
 10588  	            var keyWords = key.words;
 10589  	            var keySigBytes = key.sigBytes;
 10590  
 10591  	            // Init sbox
 10592  	            var S = this._S = [];
 10593  	            for (var i = 0; i < 256; i++) {
 10594  	                S[i] = i;
 10595  	            }
 10596  
 10597  	            // Key setup
 10598  	            for (var i = 0, j = 0; i < 256; i++) {
 10599  	                var keyByteIndex = i % keySigBytes;
 10600  	                var keyByte = (keyWords[keyByteIndex >>> 2] >>> (24 - (keyByteIndex % 4) * 8)) & 0xff;
 10601  
 10602  	                j = (j + S[i] + keyByte) % 256;
 10603  
 10604  	                // Swap
 10605  	                var t = S[i];
 10606  	                S[i] = S[j];
 10607  	                S[j] = t;
 10608  	            }
 10609  
 10610  	            // Counters
 10611  	            this._i = this._j = 0;
 10612  	        },
 10613  
 10614  	        _doProcessBlock: function (M, offset) {
 10615  	            M[offset] ^= generateKeystreamWord.call(this);
 10616  	        },
 10617  
 10618  	        keySize: 256/32,
 10619  
 10620  	        ivSize: 0
 10621  	    });
 10622  
 10623  	    function generateKeystreamWord() {
 10624  	        // Shortcuts
 10625  	        var S = this._S;
 10626  	        var i = this._i;
 10627  	        var j = this._j;
 10628  
 10629  	        // Generate keystream word
 10630  	        var keystreamWord = 0;
 10631  	        for (var n = 0; n < 4; n++) {
 10632  	            i = (i + 1) % 256;
 10633  	            j = (j + S[i]) % 256;
 10634  
 10635  	            // Swap
 10636  	            var t = S[i];
 10637  	            S[i] = S[j];
 10638  	            S[j] = t;
 10639  
 10640  	            keystreamWord |= S[(S[i] + S[j]) % 256] << (24 - n * 8);
 10641  	        }
 10642  
 10643  	        // Update counters
 10644  	        this._i = i;
 10645  	        this._j = j;
 10646  
 10647  	        return keystreamWord;
 10648  	    }
 10649  
 10650  	    /**
 10651  	     * Shortcut functions to the cipher's object interface.
 10652  	     *
 10653  	     * @example
 10654  	     *
 10655  	     *     var ciphertext = CryptoJS.RC4.encrypt(message, key, cfg);
 10656  	     *     var plaintext  = CryptoJS.RC4.decrypt(ciphertext, key, cfg);
 10657  	     */
 10658  	    C.RC4 = StreamCipher._createHelper(RC4);
 10659  
 10660  	    /**
 10661  	     * Modified RC4 stream cipher algorithm.
 10662  	     */
 10663  	    var RC4Drop = C_algo.RC4Drop = RC4.extend({
 10664  	        /**
 10665  	         * Configuration options.
 10666  	         *
 10667  	         * @property {number} drop The number of keystream words to drop. Default 192
 10668  	         */
 10669  	        cfg: RC4.cfg.extend({
 10670  	            drop: 192
 10671  	        }),
 10672  
 10673  	        _doReset: function () {
 10674  	            RC4._doReset.call(this);
 10675  
 10676  	            // Drop
 10677  	            for (var i = this.cfg.drop; i > 0; i--) {
 10678  	                generateKeystreamWord.call(this);
 10679  	            }
 10680  	        }
 10681  	    });
 10682  
 10683  	    /**
 10684  	     * Shortcut functions to the cipher's object interface.
 10685  	     *
 10686  	     * @example
 10687  	     *
 10688  	     *     var ciphertext = CryptoJS.RC4Drop.encrypt(message, key, cfg);
 10689  	     *     var plaintext  = CryptoJS.RC4Drop.decrypt(ciphertext, key, cfg);
 10690  	     */
 10691  	    C.RC4Drop = StreamCipher._createHelper(RC4Drop);
 10692  	}());
 10693  
 10694  
 10695  	return CryptoJS.RC4;
 10696  
 10697  }));
 10698  },{"./cipher-core":52,"./core":53,"./enc-base64":54,"./evpkdf":56,"./md5":61}],76:[function(require,module,exports){
 10699  ;(function (root, factory) {
 10700  	if (typeof exports === "object") {
 10701  		// CommonJS
 10702  		module.exports = exports = factory(require("./core"));
 10703  	}
 10704  	else if (typeof define === "function" && define.amd) {
 10705  		// AMD
 10706  		define(["./core"], factory);
 10707  	}
 10708  	else {
 10709  		// Global (browser)
 10710  		factory(root.CryptoJS);
 10711  	}
 10712  }(this, function (CryptoJS) {
 10713  
 10714  	/** @preserve
 10715  	(c) 2012 by Cédric Mesnil. All rights reserved.
 10716  
 10717  	Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
 10718  
 10719  	    - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
 10720  	    - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
 10721  
 10722  	THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 10723  	*/
 10724  
 10725  	(function (Math) {
 10726  	    // Shortcuts
 10727  	    var C = CryptoJS;
 10728  	    var C_lib = C.lib;
 10729  	    var WordArray = C_lib.WordArray;
 10730  	    var Hasher = C_lib.Hasher;
 10731  	    var C_algo = C.algo;
 10732  
 10733  	    // Constants table
 10734  	    var _zl = WordArray.create([
 10735  	        0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15,
 10736  	        7,  4, 13,  1, 10,  6, 15,  3, 12,  0,  9,  5,  2, 14, 11,  8,
 10737  	        3, 10, 14,  4,  9, 15,  8,  1,  2,  7,  0,  6, 13, 11,  5, 12,
 10738  	        1,  9, 11, 10,  0,  8, 12,  4, 13,  3,  7, 15, 14,  5,  6,  2,
 10739  	        4,  0,  5,  9,  7, 12,  2, 10, 14,  1,  3,  8, 11,  6, 15, 13]);
 10740  	    var _zr = WordArray.create([
 10741  	        5, 14,  7,  0,  9,  2, 11,  4, 13,  6, 15,  8,  1, 10,  3, 12,
 10742  	        6, 11,  3,  7,  0, 13,  5, 10, 14, 15,  8, 12,  4,  9,  1,  2,
 10743  	        15,  5,  1,  3,  7, 14,  6,  9, 11,  8, 12,  2, 10,  0,  4, 13,
 10744  	        8,  6,  4,  1,  3, 11, 15,  0,  5, 12,  2, 13,  9,  7, 10, 14,
 10745  	        12, 15, 10,  4,  1,  5,  8,  7,  6,  2, 13, 14,  0,  3,  9, 11]);
 10746  	    var _sl = WordArray.create([
 10747  	         11, 14, 15, 12,  5,  8,  7,  9, 11, 13, 14, 15,  6,  7,  9,  8,
 10748  	        7, 6,   8, 13, 11,  9,  7, 15,  7, 12, 15,  9, 11,  7, 13, 12,
 10749  	        11, 13,  6,  7, 14,  9, 13, 15, 14,  8, 13,  6,  5, 12,  7,  5,
 10750  	          11, 12, 14, 15, 14, 15,  9,  8,  9, 14,  5,  6,  8,  6,  5, 12,
 10751  	        9, 15,  5, 11,  6,  8, 13, 12,  5, 12, 13, 14, 11,  8,  5,  6 ]);
 10752  	    var _sr = WordArray.create([
 10753  	        8,  9,  9, 11, 13, 15, 15,  5,  7,  7,  8, 11, 14, 14, 12,  6,
 10754  	        9, 13, 15,  7, 12,  8,  9, 11,  7,  7, 12,  7,  6, 15, 13, 11,
 10755  	        9,  7, 15, 11,  8,  6,  6, 14, 12, 13,  5, 14, 13, 13,  7,  5,
 10756  	        15,  5,  8, 11, 14, 14,  6, 14,  6,  9, 12,  9, 12,  5, 15,  8,
 10757  	        8,  5, 12,  9, 12,  5, 14,  6,  8, 13,  6,  5, 15, 13, 11, 11 ]);
 10758  
 10759  	    var _hl =  WordArray.create([ 0x00000000, 0x5A827999, 0x6ED9EBA1, 0x8F1BBCDC, 0xA953FD4E]);
 10760  	    var _hr =  WordArray.create([ 0x50A28BE6, 0x5C4DD124, 0x6D703EF3, 0x7A6D76E9, 0x00000000]);
 10761  
 10762  	    /**
 10763  	     * RIPEMD160 hash algorithm.
 10764  	     */
 10765  	    var RIPEMD160 = C_algo.RIPEMD160 = Hasher.extend({
 10766  	        _doReset: function () {
 10767  	            this._hash  = WordArray.create([0x67452301, 0xEFCDAB89, 0x98BADCFE, 0x10325476, 0xC3D2E1F0]);
 10768  	        },
 10769  
 10770  	        _doProcessBlock: function (M, offset) {
 10771  
 10772  	            // Swap endian
 10773  	            for (var i = 0; i < 16; i++) {
 10774  	                // Shortcuts
 10775  	                var offset_i = offset + i;
 10776  	                var M_offset_i = M[offset_i];
 10777  
 10778  	                // Swap
 10779  	                M[offset_i] = (
 10780  	                    (((M_offset_i << 8)  | (M_offset_i >>> 24)) & 0x00ff00ff) |
 10781  	                    (((M_offset_i << 24) | (M_offset_i >>> 8))  & 0xff00ff00)
 10782  	                );
 10783  	            }
 10784  	            // Shortcut
 10785  	            var H  = this._hash.words;
 10786  	            var hl = _hl.words;
 10787  	            var hr = _hr.words;
 10788  	            var zl = _zl.words;
 10789  	            var zr = _zr.words;
 10790  	            var sl = _sl.words;
 10791  	            var sr = _sr.words;
 10792  
 10793  	            // Working variables
 10794  	            var al, bl, cl, dl, el;
 10795  	            var ar, br, cr, dr, er;
 10796  
 10797  	            ar = al = H[0];
 10798  	            br = bl = H[1];
 10799  	            cr = cl = H[2];
 10800  	            dr = dl = H[3];
 10801  	            er = el = H[4];
 10802  	            // Computation
 10803  	            var t;
 10804  	            for (var i = 0; i < 80; i += 1) {
 10805  	                t = (al +  M[offset+zl[i]])|0;
 10806  	                if (i<16){
 10807  		            t +=  f1(bl,cl,dl) + hl[0];
 10808  	                } else if (i<32) {
 10809  		            t +=  f2(bl,cl,dl) + hl[1];
 10810  	                } else if (i<48) {
 10811  		            t +=  f3(bl,cl,dl) + hl[2];
 10812  	                } else if (i<64) {
 10813  		            t +=  f4(bl,cl,dl) + hl[3];
 10814  	                } else {// if (i<80) {
 10815  		            t +=  f5(bl,cl,dl) + hl[4];
 10816  	                }
 10817  	                t = t|0;
 10818  	                t =  rotl(t,sl[i]);
 10819  	                t = (t+el)|0;
 10820  	                al = el;
 10821  	                el = dl;
 10822  	                dl = rotl(cl, 10);
 10823  	                cl = bl;
 10824  	                bl = t;
 10825  
 10826  	                t = (ar + M[offset+zr[i]])|0;
 10827  	                if (i<16){
 10828  		            t +=  f5(br,cr,dr) + hr[0];
 10829  	                } else if (i<32) {
 10830  		            t +=  f4(br,cr,dr) + hr[1];
 10831  	                } else if (i<48) {
 10832  		            t +=  f3(br,cr,dr) + hr[2];
 10833  	                } else if (i<64) {
 10834  		            t +=  f2(br,cr,dr) + hr[3];
 10835  	                } else {// if (i<80) {
 10836  		            t +=  f1(br,cr,dr) + hr[4];
 10837  	                }
 10838  	                t = t|0;
 10839  	                t =  rotl(t,sr[i]) ;
 10840  	                t = (t+er)|0;
 10841  	                ar = er;
 10842  	                er = dr;
 10843  	                dr = rotl(cr, 10);
 10844  	                cr = br;
 10845  	                br = t;
 10846  	            }
 10847  	            // Intermediate hash value
 10848  	            t    = (H[1] + cl + dr)|0;
 10849  	            H[1] = (H[2] + dl + er)|0;
 10850  	            H[2] = (H[3] + el + ar)|0;
 10851  	            H[3] = (H[4] + al + br)|0;
 10852  	            H[4] = (H[0] + bl + cr)|0;
 10853  	            H[0] =  t;
 10854  	        },
 10855  
 10856  	        _doFinalize: function () {
 10857  	            // Shortcuts
 10858  	            var data = this._data;
 10859  	            var dataWords = data.words;
 10860  
 10861  	            var nBitsTotal = this._nDataBytes * 8;
 10862  	            var nBitsLeft = data.sigBytes * 8;
 10863  
 10864  	            // Add padding
 10865  	            dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
 10866  	            dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = (
 10867  	                (((nBitsTotal << 8)  | (nBitsTotal >>> 24)) & 0x00ff00ff) |
 10868  	                (((nBitsTotal << 24) | (nBitsTotal >>> 8))  & 0xff00ff00)
 10869  	            );
 10870  	            data.sigBytes = (dataWords.length + 1) * 4;
 10871  
 10872  	            // Hash final blocks
 10873  	            this._process();
 10874  
 10875  	            // Shortcuts
 10876  	            var hash = this._hash;
 10877  	            var H = hash.words;
 10878  
 10879  	            // Swap endian
 10880  	            for (var i = 0; i < 5; i++) {
 10881  	                // Shortcut
 10882  	                var H_i = H[i];
 10883  
 10884  	                // Swap
 10885  	                H[i] = (((H_i << 8)  | (H_i >>> 24)) & 0x00ff00ff) |
 10886  	                       (((H_i << 24) | (H_i >>> 8))  & 0xff00ff00);
 10887  	            }
 10888  
 10889  	            // Return final computed hash
 10890  	            return hash;
 10891  	        },
 10892  
 10893  	        clone: function () {
 10894  	            var clone = Hasher.clone.call(this);
 10895  	            clone._hash = this._hash.clone();
 10896  
 10897  	            return clone;
 10898  	        }
 10899  	    });
 10900  
 10901  
 10902  	    function f1(x, y, z) {
 10903  	        return ((x) ^ (y) ^ (z));
 10904  
 10905  	    }
 10906  
 10907  	    function f2(x, y, z) {
 10908  	        return (((x)&(y)) | ((~x)&(z)));
 10909  	    }
 10910  
 10911  	    function f3(x, y, z) {
 10912  	        return (((x) | (~(y))) ^ (z));
 10913  	    }
 10914  
 10915  	    function f4(x, y, z) {
 10916  	        return (((x) & (z)) | ((y)&(~(z))));
 10917  	    }
 10918  
 10919  	    function f5(x, y, z) {
 10920  	        return ((x) ^ ((y) |(~(z))));
 10921  
 10922  	    }
 10923  
 10924  	    function rotl(x,n) {
 10925  	        return (x<<n) | (x>>>(32-n));
 10926  	    }
 10927  
 10928  
 10929  	    /**
 10930  	     * Shortcut function to the hasher's object interface.
 10931  	     *
 10932  	     * @param {WordArray|string} message The message to hash.
 10933  	     *
 10934  	     * @return {WordArray} The hash.
 10935  	     *
 10936  	     * @static
 10937  	     *
 10938  	     * @example
 10939  	     *
 10940  	     *     var hash = CryptoJS.RIPEMD160('message');
 10941  	     *     var hash = CryptoJS.RIPEMD160(wordArray);
 10942  	     */
 10943  	    C.RIPEMD160 = Hasher._createHelper(RIPEMD160);
 10944  
 10945  	    /**
 10946  	     * Shortcut function to the HMAC's object interface.
 10947  	     *
 10948  	     * @param {WordArray|string} message The message to hash.
 10949  	     * @param {WordArray|string} key The secret key.
 10950  	     *
 10951  	     * @return {WordArray} The HMAC.
 10952  	     *
 10953  	     * @static
 10954  	     *
 10955  	     * @example
 10956  	     *
 10957  	     *     var hmac = CryptoJS.HmacRIPEMD160(message, key);
 10958  	     */
 10959  	    C.HmacRIPEMD160 = Hasher._createHmacHelper(RIPEMD160);
 10960  	}(Math));
 10961  
 10962  
 10963  	return CryptoJS.RIPEMD160;
 10964  
 10965  }));
 10966  },{"./core":53}],77:[function(require,module,exports){
 10967  ;(function (root, factory) {
 10968  	if (typeof exports === "object") {
 10969  		// CommonJS
 10970  		module.exports = exports = factory(require("./core"));
 10971  	}
 10972  	else if (typeof define === "function" && define.amd) {
 10973  		// AMD
 10974  		define(["./core"], factory);
 10975  	}
 10976  	else {
 10977  		// Global (browser)
 10978  		factory(root.CryptoJS);
 10979  	}
 10980  }(this, function (CryptoJS) {
 10981  
 10982  	(function () {
 10983  	    // Shortcuts
 10984  	    var C = CryptoJS;
 10985  	    var C_lib = C.lib;
 10986  	    var WordArray = C_lib.WordArray;
 10987  	    var Hasher = C_lib.Hasher;
 10988  	    var C_algo = C.algo;
 10989  
 10990  	    // Reusable object
 10991  	    var W = [];
 10992  
 10993  	    /**
 10994  	     * SHA-1 hash algorithm.
 10995  	     */
 10996  	    var SHA1 = C_algo.SHA1 = Hasher.extend({
 10997  	        _doReset: function () {
 10998  	            this._hash = new WordArray.init([
 10999  	                0x67452301, 0xefcdab89,
 11000  	                0x98badcfe, 0x10325476,
 11001  	                0xc3d2e1f0
 11002  	            ]);
 11003  	        },
 11004  
 11005  	        _doProcessBlock: function (M, offset) {
 11006  	            // Shortcut
 11007  	            var H = this._hash.words;
 11008  
 11009  	            // Working variables
 11010  	            var a = H[0];
 11011  	            var b = H[1];
 11012  	            var c = H[2];
 11013  	            var d = H[3];
 11014  	            var e = H[4];
 11015  
 11016  	            // Computation
 11017  	            for (var i = 0; i < 80; i++) {
 11018  	                if (i < 16) {
 11019  	                    W[i] = M[offset + i] | 0;
 11020  	                } else {
 11021  	                    var n = W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16];
 11022  	                    W[i] = (n << 1) | (n >>> 31);
 11023  	                }
 11024  
 11025  	                var t = ((a << 5) | (a >>> 27)) + e + W[i];
 11026  	                if (i < 20) {
 11027  	                    t += ((b & c) | (~b & d)) + 0x5a827999;
 11028  	                } else if (i < 40) {
 11029  	                    t += (b ^ c ^ d) + 0x6ed9eba1;
 11030  	                } else if (i < 60) {
 11031  	                    t += ((b & c) | (b & d) | (c & d)) - 0x70e44324;
 11032  	                } else /* if (i < 80) */ {
 11033  	                    t += (b ^ c ^ d) - 0x359d3e2a;
 11034  	                }
 11035  
 11036  	                e = d;
 11037  	                d = c;
 11038  	                c = (b << 30) | (b >>> 2);
 11039  	                b = a;
 11040  	                a = t;
 11041  	            }
 11042  
 11043  	            // Intermediate hash value
 11044  	            H[0] = (H[0] + a) | 0;
 11045  	            H[1] = (H[1] + b) | 0;
 11046  	            H[2] = (H[2] + c) | 0;
 11047  	            H[3] = (H[3] + d) | 0;
 11048  	            H[4] = (H[4] + e) | 0;
 11049  	        },
 11050  
 11051  	        _doFinalize: function () {
 11052  	            // Shortcuts
 11053  	            var data = this._data;
 11054  	            var dataWords = data.words;
 11055  
 11056  	            var nBitsTotal = this._nDataBytes * 8;
 11057  	            var nBitsLeft = data.sigBytes * 8;
 11058  
 11059  	            // Add padding
 11060  	            dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
 11061  	            dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = Math.floor(nBitsTotal / 0x100000000);
 11062  	            dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = nBitsTotal;
 11063  	            data.sigBytes = dataWords.length * 4;
 11064  
 11065  	            // Hash final blocks
 11066  	            this._process();
 11067  
 11068  	            // Return final computed hash
 11069  	            return this._hash;
 11070  	        },
 11071  
 11072  	        clone: function () {
 11073  	            var clone = Hasher.clone.call(this);
 11074  	            clone._hash = this._hash.clone();
 11075  
 11076  	            return clone;
 11077  	        }
 11078  	    });
 11079  
 11080  	    /**
 11081  	     * Shortcut function to the hasher's object interface.
 11082  	     *
 11083  	     * @param {WordArray|string} message The message to hash.
 11084  	     *
 11085  	     * @return {WordArray} The hash.
 11086  	     *
 11087  	     * @static
 11088  	     *
 11089  	     * @example
 11090  	     *
 11091  	     *     var hash = CryptoJS.SHA1('message');
 11092  	     *     var hash = CryptoJS.SHA1(wordArray);
 11093  	     */
 11094  	    C.SHA1 = Hasher._createHelper(SHA1);
 11095  
 11096  	    /**
 11097  	     * Shortcut function to the HMAC's object interface.
 11098  	     *
 11099  	     * @param {WordArray|string} message The message to hash.
 11100  	     * @param {WordArray|string} key The secret key.
 11101  	     *
 11102  	     * @return {WordArray} The HMAC.
 11103  	     *
 11104  	     * @static
 11105  	     *
 11106  	     * @example
 11107  	     *
 11108  	     *     var hmac = CryptoJS.HmacSHA1(message, key);
 11109  	     */
 11110  	    C.HmacSHA1 = Hasher._createHmacHelper(SHA1);
 11111  	}());
 11112  
 11113  
 11114  	return CryptoJS.SHA1;
 11115  
 11116  }));
 11117  },{"./core":53}],78:[function(require,module,exports){
 11118  ;(function (root, factory, undef) {
 11119  	if (typeof exports === "object") {
 11120  		// CommonJS
 11121  		module.exports = exports = factory(require("./core"), require("./sha256"));
 11122  	}
 11123  	else if (typeof define === "function" && define.amd) {
 11124  		// AMD
 11125  		define(["./core", "./sha256"], factory);
 11126  	}
 11127  	else {
 11128  		// Global (browser)
 11129  		factory(root.CryptoJS);
 11130  	}
 11131  }(this, function (CryptoJS) {
 11132  
 11133  	(function () {
 11134  	    // Shortcuts
 11135  	    var C = CryptoJS;
 11136  	    var C_lib = C.lib;
 11137  	    var WordArray = C_lib.WordArray;
 11138  	    var C_algo = C.algo;
 11139  	    var SHA256 = C_algo.SHA256;
 11140  
 11141  	    /**
 11142  	     * SHA-224 hash algorithm.
 11143  	     */
 11144  	    var SHA224 = C_algo.SHA224 = SHA256.extend({
 11145  	        _doReset: function () {
 11146  	            this._hash = new WordArray.init([
 11147  	                0xc1059ed8, 0x367cd507, 0x3070dd17, 0xf70e5939,
 11148  	                0xffc00b31, 0x68581511, 0x64f98fa7, 0xbefa4fa4
 11149  	            ]);
 11150  	        },
 11151  
 11152  	        _doFinalize: function () {
 11153  	            var hash = SHA256._doFinalize.call(this);
 11154  
 11155  	            hash.sigBytes -= 4;
 11156  
 11157  	            return hash;
 11158  	        }
 11159  	    });
 11160  
 11161  	    /**
 11162  	     * Shortcut function to the hasher's object interface.
 11163  	     *
 11164  	     * @param {WordArray|string} message The message to hash.
 11165  	     *
 11166  	     * @return {WordArray} The hash.
 11167  	     *
 11168  	     * @static
 11169  	     *
 11170  	     * @example
 11171  	     *
 11172  	     *     var hash = CryptoJS.SHA224('message');
 11173  	     *     var hash = CryptoJS.SHA224(wordArray);
 11174  	     */
 11175  	    C.SHA224 = SHA256._createHelper(SHA224);
 11176  
 11177  	    /**
 11178  	     * Shortcut function to the HMAC's object interface.
 11179  	     *
 11180  	     * @param {WordArray|string} message The message to hash.
 11181  	     * @param {WordArray|string} key The secret key.
 11182  	     *
 11183  	     * @return {WordArray} The HMAC.
 11184  	     *
 11185  	     * @static
 11186  	     *
 11187  	     * @example
 11188  	     *
 11189  	     *     var hmac = CryptoJS.HmacSHA224(message, key);
 11190  	     */
 11191  	    C.HmacSHA224 = SHA256._createHmacHelper(SHA224);
 11192  	}());
 11193  
 11194  
 11195  	return CryptoJS.SHA224;
 11196  
 11197  }));
 11198  },{"./core":53,"./sha256":79}],79:[function(require,module,exports){
 11199  ;(function (root, factory) {
 11200  	if (typeof exports === "object") {
 11201  		// CommonJS
 11202  		module.exports = exports = factory(require("./core"));
 11203  	}
 11204  	else if (typeof define === "function" && define.amd) {
 11205  		// AMD
 11206  		define(["./core"], factory);
 11207  	}
 11208  	else {
 11209  		// Global (browser)
 11210  		factory(root.CryptoJS);
 11211  	}
 11212  }(this, function (CryptoJS) {
 11213  
 11214  	(function (Math) {
 11215  	    // Shortcuts
 11216  	    var C = CryptoJS;
 11217  	    var C_lib = C.lib;
 11218  	    var WordArray = C_lib.WordArray;
 11219  	    var Hasher = C_lib.Hasher;
 11220  	    var C_algo = C.algo;
 11221  
 11222  	    // Initialization and round constants tables
 11223  	    var H = [];
 11224  	    var K = [];
 11225  
 11226  	    // Compute constants
 11227  	    (function () {
 11228  	        function isPrime(n) {
 11229  	            var sqrtN = Math.sqrt(n);
 11230  	            for (var factor = 2; factor <= sqrtN; factor++) {
 11231  	                if (!(n % factor)) {
 11232  	                    return false;
 11233  	                }
 11234  	            }
 11235  
 11236  	            return true;
 11237  	        }
 11238  
 11239  	        function getFractionalBits(n) {
 11240  	            return ((n - (n | 0)) * 0x100000000) | 0;
 11241  	        }
 11242  
 11243  	        var n = 2;
 11244  	        var nPrime = 0;
 11245  	        while (nPrime < 64) {
 11246  	            if (isPrime(n)) {
 11247  	                if (nPrime < 8) {
 11248  	                    H[nPrime] = getFractionalBits(Math.pow(n, 1 / 2));
 11249  	                }
 11250  	                K[nPrime] = getFractionalBits(Math.pow(n, 1 / 3));
 11251  
 11252  	                nPrime++;
 11253  	            }
 11254  
 11255  	            n++;
 11256  	        }
 11257  	    }());
 11258  
 11259  	    // Reusable object
 11260  	    var W = [];
 11261  
 11262  	    /**
 11263  	     * SHA-256 hash algorithm.
 11264  	     */
 11265  	    var SHA256 = C_algo.SHA256 = Hasher.extend({
 11266  	        _doReset: function () {
 11267  	            this._hash = new WordArray.init(H.slice(0));
 11268  	        },
 11269  
 11270  	        _doProcessBlock: function (M, offset) {
 11271  	            // Shortcut
 11272  	            var H = this._hash.words;
 11273  
 11274  	            // Working variables
 11275  	            var a = H[0];
 11276  	            var b = H[1];
 11277  	            var c = H[2];
 11278  	            var d = H[3];
 11279  	            var e = H[4];
 11280  	            var f = H[5];
 11281  	            var g = H[6];
 11282  	            var h = H[7];
 11283  
 11284  	            // Computation
 11285  	            for (var i = 0; i < 64; i++) {
 11286  	                if (i < 16) {
 11287  	                    W[i] = M[offset + i] | 0;
 11288  	                } else {
 11289  	                    var gamma0x = W[i - 15];
 11290  	                    var gamma0  = ((gamma0x << 25) | (gamma0x >>> 7))  ^
 11291  	                                  ((gamma0x << 14) | (gamma0x >>> 18)) ^
 11292  	                                   (gamma0x >>> 3);
 11293  
 11294  	                    var gamma1x = W[i - 2];
 11295  	                    var gamma1  = ((gamma1x << 15) | (gamma1x >>> 17)) ^
 11296  	                                  ((gamma1x << 13) | (gamma1x >>> 19)) ^
 11297  	                                   (gamma1x >>> 10);
 11298  
 11299  	                    W[i] = gamma0 + W[i - 7] + gamma1 + W[i - 16];
 11300  	                }
 11301  
 11302  	                var ch  = (e & f) ^ (~e & g);
 11303  	                var maj = (a & b) ^ (a & c) ^ (b & c);
 11304  
 11305  	                var sigma0 = ((a << 30) | (a >>> 2)) ^ ((a << 19) | (a >>> 13)) ^ ((a << 10) | (a >>> 22));
 11306  	                var sigma1 = ((e << 26) | (e >>> 6)) ^ ((e << 21) | (e >>> 11)) ^ ((e << 7)  | (e >>> 25));
 11307  
 11308  	                var t1 = h + sigma1 + ch + K[i] + W[i];
 11309  	                var t2 = sigma0 + maj;
 11310  
 11311  	                h = g;
 11312  	                g = f;
 11313  	                f = e;
 11314  	                e = (d + t1) | 0;
 11315  	                d = c;
 11316  	                c = b;
 11317  	                b = a;
 11318  	                a = (t1 + t2) | 0;
 11319  	            }
 11320  
 11321  	            // Intermediate hash value
 11322  	            H[0] = (H[0] + a) | 0;
 11323  	            H[1] = (H[1] + b) | 0;
 11324  	            H[2] = (H[2] + c) | 0;
 11325  	            H[3] = (H[3] + d) | 0;
 11326  	            H[4] = (H[4] + e) | 0;
 11327  	            H[5] = (H[5] + f) | 0;
 11328  	            H[6] = (H[6] + g) | 0;
 11329  	            H[7] = (H[7] + h) | 0;
 11330  	        },
 11331  
 11332  	        _doFinalize: function () {
 11333  	            // Shortcuts
 11334  	            var data = this._data;
 11335  	            var dataWords = data.words;
 11336  
 11337  	            var nBitsTotal = this._nDataBytes * 8;
 11338  	            var nBitsLeft = data.sigBytes * 8;
 11339  
 11340  	            // Add padding
 11341  	            dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
 11342  	            dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = Math.floor(nBitsTotal / 0x100000000);
 11343  	            dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = nBitsTotal;
 11344  	            data.sigBytes = dataWords.length * 4;
 11345  
 11346  	            // Hash final blocks
 11347  	            this._process();
 11348  
 11349  	            // Return final computed hash
 11350  	            return this._hash;
 11351  	        },
 11352  
 11353  	        clone: function () {
 11354  	            var clone = Hasher.clone.call(this);
 11355  	            clone._hash = this._hash.clone();
 11356  
 11357  	            return clone;
 11358  	        }
 11359  	    });
 11360  
 11361  	    /**
 11362  	     * Shortcut function to the hasher's object interface.
 11363  	     *
 11364  	     * @param {WordArray|string} message The message to hash.
 11365  	     *
 11366  	     * @return {WordArray} The hash.
 11367  	     *
 11368  	     * @static
 11369  	     *
 11370  	     * @example
 11371  	     *
 11372  	     *     var hash = CryptoJS.SHA256('message');
 11373  	     *     var hash = CryptoJS.SHA256(wordArray);
 11374  	     */
 11375  	    C.SHA256 = Hasher._createHelper(SHA256);
 11376  
 11377  	    /**
 11378  	     * Shortcut function to the HMAC's object interface.
 11379  	     *
 11380  	     * @param {WordArray|string} message The message to hash.
 11381  	     * @param {WordArray|string} key The secret key.
 11382  	     *
 11383  	     * @return {WordArray} The HMAC.
 11384  	     *
 11385  	     * @static
 11386  	     *
 11387  	     * @example
 11388  	     *
 11389  	     *     var hmac = CryptoJS.HmacSHA256(message, key);
 11390  	     */
 11391  	    C.HmacSHA256 = Hasher._createHmacHelper(SHA256);
 11392  	}(Math));
 11393  
 11394  
 11395  	return CryptoJS.SHA256;
 11396  
 11397  }));
 11398  },{"./core":53}],80:[function(require,module,exports){
 11399  ;(function (root, factory, undef) {
 11400  	if (typeof exports === "object") {
 11401  		// CommonJS
 11402  		module.exports = exports = factory(require("./core"), require("./x64-core"));
 11403  	}
 11404  	else if (typeof define === "function" && define.amd) {
 11405  		// AMD
 11406  		define(["./core", "./x64-core"], factory);
 11407  	}
 11408  	else {
 11409  		// Global (browser)
 11410  		factory(root.CryptoJS);
 11411  	}
 11412  }(this, function (CryptoJS) {
 11413  
 11414  	(function (Math) {
 11415  	    // Shortcuts
 11416  	    var C = CryptoJS;
 11417  	    var C_lib = C.lib;
 11418  	    var WordArray = C_lib.WordArray;
 11419  	    var Hasher = C_lib.Hasher;
 11420  	    var C_x64 = C.x64;
 11421  	    var X64Word = C_x64.Word;
 11422  	    var C_algo = C.algo;
 11423  
 11424  	    // Constants tables
 11425  	    var RHO_OFFSETS = [];
 11426  	    var PI_INDEXES  = [];
 11427  	    var ROUND_CONSTANTS = [];
 11428  
 11429  	    // Compute Constants
 11430  	    (function () {
 11431  	        // Compute rho offset constants
 11432  	        var x = 1, y = 0;
 11433  	        for (var t = 0; t < 24; t++) {
 11434  	            RHO_OFFSETS[x + 5 * y] = ((t + 1) * (t + 2) / 2) % 64;
 11435  
 11436  	            var newX = y % 5;
 11437  	            var newY = (2 * x + 3 * y) % 5;
 11438  	            x = newX;
 11439  	            y = newY;
 11440  	        }
 11441  
 11442  	        // Compute pi index constants
 11443  	        for (var x = 0; x < 5; x++) {
 11444  	            for (var y = 0; y < 5; y++) {
 11445  	                PI_INDEXES[x + 5 * y] = y + ((2 * x + 3 * y) % 5) * 5;
 11446  	            }
 11447  	        }
 11448  
 11449  	        // Compute round constants
 11450  	        var LFSR = 0x01;
 11451  	        for (var i = 0; i < 24; i++) {
 11452  	            var roundConstantMsw = 0;
 11453  	            var roundConstantLsw = 0;
 11454  
 11455  	            for (var j = 0; j < 7; j++) {
 11456  	                if (LFSR & 0x01) {
 11457  	                    var bitPosition = (1 << j) - 1;
 11458  	                    if (bitPosition < 32) {
 11459  	                        roundConstantLsw ^= 1 << bitPosition;
 11460  	                    } else /* if (bitPosition >= 32) */ {
 11461  	                        roundConstantMsw ^= 1 << (bitPosition - 32);
 11462  	                    }
 11463  	                }
 11464  
 11465  	                // Compute next LFSR
 11466  	                if (LFSR & 0x80) {
 11467  	                    // Primitive polynomial over GF(2): x^8 + x^6 + x^5 + x^4 + 1
 11468  	                    LFSR = (LFSR << 1) ^ 0x71;
 11469  	                } else {
 11470  	                    LFSR <<= 1;
 11471  	                }
 11472  	            }
 11473  
 11474  	            ROUND_CONSTANTS[i] = X64Word.create(roundConstantMsw, roundConstantLsw);
 11475  	        }
 11476  	    }());
 11477  
 11478  	    // Reusable objects for temporary values
 11479  	    var T = [];
 11480  	    (function () {
 11481  	        for (var i = 0; i < 25; i++) {
 11482  	            T[i] = X64Word.create();
 11483  	        }
 11484  	    }());
 11485  
 11486  	    /**
 11487  	     * SHA-3 hash algorithm.
 11488  	     */
 11489  	    var SHA3 = C_algo.SHA3 = Hasher.extend({
 11490  	        /**
 11491  	         * Configuration options.
 11492  	         *
 11493  	         * @property {number} outputLength
 11494  	         *   The desired number of bits in the output hash.
 11495  	         *   Only values permitted are: 224, 256, 384, 512.
 11496  	         *   Default: 512
 11497  	         */
 11498  	        cfg: Hasher.cfg.extend({
 11499  	            outputLength: 512
 11500  	        }),
 11501  
 11502  	        _doReset: function () {
 11503  	            var state = this._state = []
 11504  	            for (var i = 0; i < 25; i++) {
 11505  	                state[i] = new X64Word.init();
 11506  	            }
 11507  
 11508  	            this.blockSize = (1600 - 2 * this.cfg.outputLength) / 32;
 11509  	        },
 11510  
 11511  	        _doProcessBlock: function (M, offset) {
 11512  	            // Shortcuts
 11513  	            var state = this._state;
 11514  	            var nBlockSizeLanes = this.blockSize / 2;
 11515  
 11516  	            // Absorb
 11517  	            for (var i = 0; i < nBlockSizeLanes; i++) {
 11518  	                // Shortcuts
 11519  	                var M2i  = M[offset + 2 * i];
 11520  	                var M2i1 = M[offset + 2 * i + 1];
 11521  
 11522  	                // Swap endian
 11523  	                M2i = (
 11524  	                    (((M2i << 8)  | (M2i >>> 24)) & 0x00ff00ff) |
 11525  	                    (((M2i << 24) | (M2i >>> 8))  & 0xff00ff00)
 11526  	                );
 11527  	                M2i1 = (
 11528  	                    (((M2i1 << 8)  | (M2i1 >>> 24)) & 0x00ff00ff) |
 11529  	                    (((M2i1 << 24) | (M2i1 >>> 8))  & 0xff00ff00)
 11530  	                );
 11531  
 11532  	                // Absorb message into state
 11533  	                var lane = state[i];
 11534  	                lane.high ^= M2i1;
 11535  	                lane.low  ^= M2i;
 11536  	            }
 11537  
 11538  	            // Rounds
 11539  	            for (var round = 0; round < 24; round++) {
 11540  	                // Theta
 11541  	                for (var x = 0; x < 5; x++) {
 11542  	                    // Mix column lanes
 11543  	                    var tMsw = 0, tLsw = 0;
 11544  	                    for (var y = 0; y < 5; y++) {
 11545  	                        var lane = state[x + 5 * y];
 11546  	                        tMsw ^= lane.high;
 11547  	                        tLsw ^= lane.low;
 11548  	                    }
 11549  
 11550  	                    // Temporary values
 11551  	                    var Tx = T[x];
 11552  	                    Tx.high = tMsw;
 11553  	                    Tx.low  = tLsw;
 11554  	                }
 11555  	                for (var x = 0; x < 5; x++) {
 11556  	                    // Shortcuts
 11557  	                    var Tx4 = T[(x + 4) % 5];
 11558  	                    var Tx1 = T[(x + 1) % 5];
 11559  	                    var Tx1Msw = Tx1.high;
 11560  	                    var Tx1Lsw = Tx1.low;
 11561  
 11562  	                    // Mix surrounding columns
 11563  	                    var tMsw = Tx4.high ^ ((Tx1Msw << 1) | (Tx1Lsw >>> 31));
 11564  	                    var tLsw = Tx4.low  ^ ((Tx1Lsw << 1) | (Tx1Msw >>> 31));
 11565  	                    for (var y = 0; y < 5; y++) {
 11566  	                        var lane = state[x + 5 * y];
 11567  	                        lane.high ^= tMsw;
 11568  	                        lane.low  ^= tLsw;
 11569  	                    }
 11570  	                }
 11571  
 11572  	                // Rho Pi
 11573  	                for (var laneIndex = 1; laneIndex < 25; laneIndex++) {
 11574  	                    // Shortcuts
 11575  	                    var lane = state[laneIndex];
 11576  	                    var laneMsw = lane.high;
 11577  	                    var laneLsw = lane.low;
 11578  	                    var rhoOffset = RHO_OFFSETS[laneIndex];
 11579  
 11580  	                    // Rotate lanes
 11581  	                    if (rhoOffset < 32) {
 11582  	                        var tMsw = (laneMsw << rhoOffset) | (laneLsw >>> (32 - rhoOffset));
 11583  	                        var tLsw = (laneLsw << rhoOffset) | (laneMsw >>> (32 - rhoOffset));
 11584  	                    } else /* if (rhoOffset >= 32) */ {
 11585  	                        var tMsw = (laneLsw << (rhoOffset - 32)) | (laneMsw >>> (64 - rhoOffset));
 11586  	                        var tLsw = (laneMsw << (rhoOffset - 32)) | (laneLsw >>> (64 - rhoOffset));
 11587  	                    }
 11588  
 11589  	                    // Transpose lanes
 11590  	                    var TPiLane = T[PI_INDEXES[laneIndex]];
 11591  	                    TPiLane.high = tMsw;
 11592  	                    TPiLane.low  = tLsw;
 11593  	                }
 11594  
 11595  	                // Rho pi at x = y = 0
 11596  	                var T0 = T[0];
 11597  	                var state0 = state[0];
 11598  	                T0.high = state0.high;
 11599  	                T0.low  = state0.low;
 11600  
 11601  	                // Chi
 11602  	                for (var x = 0; x < 5; x++) {
 11603  	                    for (var y = 0; y < 5; y++) {
 11604  	                        // Shortcuts
 11605  	                        var laneIndex = x + 5 * y;
 11606  	                        var lane = state[laneIndex];
 11607  	                        var TLane = T[laneIndex];
 11608  	                        var Tx1Lane = T[((x + 1) % 5) + 5 * y];
 11609  	                        var Tx2Lane = T[((x + 2) % 5) + 5 * y];
 11610  
 11611  	                        // Mix rows
 11612  	                        lane.high = TLane.high ^ (~Tx1Lane.high & Tx2Lane.high);
 11613  	                        lane.low  = TLane.low  ^ (~Tx1Lane.low  & Tx2Lane.low);
 11614  	                    }
 11615  	                }
 11616  
 11617  	                // Iota
 11618  	                var lane = state[0];
 11619  	                var roundConstant = ROUND_CONSTANTS[round];
 11620  	                lane.high ^= roundConstant.high;
 11621  	                lane.low  ^= roundConstant.low;;
 11622  	            }
 11623  	        },
 11624  
 11625  	        _doFinalize: function () {
 11626  	            // Shortcuts
 11627  	            var data = this._data;
 11628  	            var dataWords = data.words;
 11629  	            var nBitsTotal = this._nDataBytes * 8;
 11630  	            var nBitsLeft = data.sigBytes * 8;
 11631  	            var blockSizeBits = this.blockSize * 32;
 11632  
 11633  	            // Add padding
 11634  	            dataWords[nBitsLeft >>> 5] |= 0x1 << (24 - nBitsLeft % 32);
 11635  	            dataWords[((Math.ceil((nBitsLeft + 1) / blockSizeBits) * blockSizeBits) >>> 5) - 1] |= 0x80;
 11636  	            data.sigBytes = dataWords.length * 4;
 11637  
 11638  	            // Hash final blocks
 11639  	            this._process();
 11640  
 11641  	            // Shortcuts
 11642  	            var state = this._state;
 11643  	            var outputLengthBytes = this.cfg.outputLength / 8;
 11644  	            var outputLengthLanes = outputLengthBytes / 8;
 11645  
 11646  	            // Squeeze
 11647  	            var hashWords = [];
 11648  	            for (var i = 0; i < outputLengthLanes; i++) {
 11649  	                // Shortcuts
 11650  	                var lane = state[i];
 11651  	                var laneMsw = lane.high;
 11652  	                var laneLsw = lane.low;
 11653  
 11654  	                // Swap endian
 11655  	                laneMsw = (
 11656  	                    (((laneMsw << 8)  | (laneMsw >>> 24)) & 0x00ff00ff) |
 11657  	                    (((laneMsw << 24) | (laneMsw >>> 8))  & 0xff00ff00)
 11658  	                );
 11659  	                laneLsw = (
 11660  	                    (((laneLsw << 8)  | (laneLsw >>> 24)) & 0x00ff00ff) |
 11661  	                    (((laneLsw << 24) | (laneLsw >>> 8))  & 0xff00ff00)
 11662  	                );
 11663  
 11664  	                // Squeeze state to retrieve hash
 11665  	                hashWords.push(laneLsw);
 11666  	                hashWords.push(laneMsw);
 11667  	            }
 11668  
 11669  	            // Return final computed hash
 11670  	            return new WordArray.init(hashWords, outputLengthBytes);
 11671  	        },
 11672  
 11673  	        clone: function () {
 11674  	            var clone = Hasher.clone.call(this);
 11675  
 11676  	            var state = clone._state = this._state.slice(0);
 11677  	            for (var i = 0; i < 25; i++) {
 11678  	                state[i] = state[i].clone();
 11679  	            }
 11680  
 11681  	            return clone;
 11682  	        }
 11683  	    });
 11684  
 11685  	    /**
 11686  	     * Shortcut function to the hasher's object interface.
 11687  	     *
 11688  	     * @param {WordArray|string} message The message to hash.
 11689  	     *
 11690  	     * @return {WordArray} The hash.
 11691  	     *
 11692  	     * @static
 11693  	     *
 11694  	     * @example
 11695  	     *
 11696  	     *     var hash = CryptoJS.SHA3('message');
 11697  	     *     var hash = CryptoJS.SHA3(wordArray);
 11698  	     */
 11699  	    C.SHA3 = Hasher._createHelper(SHA3);
 11700  
 11701  	    /**
 11702  	     * Shortcut function to the HMAC's object interface.
 11703  	     *
 11704  	     * @param {WordArray|string} message The message to hash.
 11705  	     * @param {WordArray|string} key The secret key.
 11706  	     *
 11707  	     * @return {WordArray} The HMAC.
 11708  	     *
 11709  	     * @static
 11710  	     *
 11711  	     * @example
 11712  	     *
 11713  	     *     var hmac = CryptoJS.HmacSHA3(message, key);
 11714  	     */
 11715  	    C.HmacSHA3 = Hasher._createHmacHelper(SHA3);
 11716  	}(Math));
 11717  
 11718  
 11719  	return CryptoJS.SHA3;
 11720  
 11721  }));
 11722  },{"./core":53,"./x64-core":84}],81:[function(require,module,exports){
 11723  ;(function (root, factory, undef) {
 11724  	if (typeof exports === "object") {
 11725  		// CommonJS
 11726  		module.exports = exports = factory(require("./core"), require("./x64-core"), require("./sha512"));
 11727  	}
 11728  	else if (typeof define === "function" && define.amd) {
 11729  		// AMD
 11730  		define(["./core", "./x64-core", "./sha512"], factory);
 11731  	}
 11732  	else {
 11733  		// Global (browser)
 11734  		factory(root.CryptoJS);
 11735  	}
 11736  }(this, function (CryptoJS) {
 11737  
 11738  	(function () {
 11739  	    // Shortcuts
 11740  	    var C = CryptoJS;
 11741  	    var C_x64 = C.x64;
 11742  	    var X64Word = C_x64.Word;
 11743  	    var X64WordArray = C_x64.WordArray;
 11744  	    var C_algo = C.algo;
 11745  	    var SHA512 = C_algo.SHA512;
 11746  
 11747  	    /**
 11748  	     * SHA-384 hash algorithm.
 11749  	     */
 11750  	    var SHA384 = C_algo.SHA384 = SHA512.extend({
 11751  	        _doReset: function () {
 11752  	            this._hash = new X64WordArray.init([
 11753  	                new X64Word.init(0xcbbb9d5d, 0xc1059ed8), new X64Word.init(0x629a292a, 0x367cd507),
 11754  	                new X64Word.init(0x9159015a, 0x3070dd17), new X64Word.init(0x152fecd8, 0xf70e5939),
 11755  	                new X64Word.init(0x67332667, 0xffc00b31), new X64Word.init(0x8eb44a87, 0x68581511),
 11756  	                new X64Word.init(0xdb0c2e0d, 0x64f98fa7), new X64Word.init(0x47b5481d, 0xbefa4fa4)
 11757  	            ]);
 11758  	        },
 11759  
 11760  	        _doFinalize: function () {
 11761  	            var hash = SHA512._doFinalize.call(this);
 11762  
 11763  	            hash.sigBytes -= 16;
 11764  
 11765  	            return hash;
 11766  	        }
 11767  	    });
 11768  
 11769  	    /**
 11770  	     * Shortcut function to the hasher's object interface.
 11771  	     *
 11772  	     * @param {WordArray|string} message The message to hash.
 11773  	     *
 11774  	     * @return {WordArray} The hash.
 11775  	     *
 11776  	     * @static
 11777  	     *
 11778  	     * @example
 11779  	     *
 11780  	     *     var hash = CryptoJS.SHA384('message');
 11781  	     *     var hash = CryptoJS.SHA384(wordArray);
 11782  	     */
 11783  	    C.SHA384 = SHA512._createHelper(SHA384);
 11784  
 11785  	    /**
 11786  	     * Shortcut function to the HMAC's object interface.
 11787  	     *
 11788  	     * @param {WordArray|string} message The message to hash.
 11789  	     * @param {WordArray|string} key The secret key.
 11790  	     *
 11791  	     * @return {WordArray} The HMAC.
 11792  	     *
 11793  	     * @static
 11794  	     *
 11795  	     * @example
 11796  	     *
 11797  	     *     var hmac = CryptoJS.HmacSHA384(message, key);
 11798  	     */
 11799  	    C.HmacSHA384 = SHA512._createHmacHelper(SHA384);
 11800  	}());
 11801  
 11802  
 11803  	return CryptoJS.SHA384;
 11804  
 11805  }));
 11806  },{"./core":53,"./sha512":82,"./x64-core":84}],82:[function(require,module,exports){
 11807  ;(function (root, factory, undef) {
 11808  	if (typeof exports === "object") {
 11809  		// CommonJS
 11810  		module.exports = exports = factory(require("./core"), require("./x64-core"));
 11811  	}
 11812  	else if (typeof define === "function" && define.amd) {
 11813  		// AMD
 11814  		define(["./core", "./x64-core"], factory);
 11815  	}
 11816  	else {
 11817  		// Global (browser)
 11818  		factory(root.CryptoJS);
 11819  	}
 11820  }(this, function (CryptoJS) {
 11821  
 11822  	(function () {
 11823  	    // Shortcuts
 11824  	    var C = CryptoJS;
 11825  	    var C_lib = C.lib;
 11826  	    var Hasher = C_lib.Hasher;
 11827  	    var C_x64 = C.x64;
 11828  	    var X64Word = C_x64.Word;
 11829  	    var X64WordArray = C_x64.WordArray;
 11830  	    var C_algo = C.algo;
 11831  
 11832  	    function X64Word_create() {
 11833  	        return X64Word.create.apply(X64Word, arguments);
 11834  	    }
 11835  
 11836  	    // Constants
 11837  	    var K = [
 11838  	        X64Word_create(0x428a2f98, 0xd728ae22), X64Word_create(0x71374491, 0x23ef65cd),
 11839  	        X64Word_create(0xb5c0fbcf, 0xec4d3b2f), X64Word_create(0xe9b5dba5, 0x8189dbbc),
 11840  	        X64Word_create(0x3956c25b, 0xf348b538), X64Word_create(0x59f111f1, 0xb605d019),
 11841  	        X64Word_create(0x923f82a4, 0xaf194f9b), X64Word_create(0xab1c5ed5, 0xda6d8118),
 11842  	        X64Word_create(0xd807aa98, 0xa3030242), X64Word_create(0x12835b01, 0x45706fbe),
 11843  	        X64Word_create(0x243185be, 0x4ee4b28c), X64Word_create(0x550c7dc3, 0xd5ffb4e2),
 11844  	        X64Word_create(0x72be5d74, 0xf27b896f), X64Word_create(0x80deb1fe, 0x3b1696b1),
 11845  	        X64Word_create(0x9bdc06a7, 0x25c71235), X64Word_create(0xc19bf174, 0xcf692694),
 11846  	        X64Word_create(0xe49b69c1, 0x9ef14ad2), X64Word_create(0xefbe4786, 0x384f25e3),
 11847  	        X64Word_create(0x0fc19dc6, 0x8b8cd5b5), X64Word_create(0x240ca1cc, 0x77ac9c65),
 11848  	        X64Word_create(0x2de92c6f, 0x592b0275), X64Word_create(0x4a7484aa, 0x6ea6e483),
 11849  	        X64Word_create(0x5cb0a9dc, 0xbd41fbd4), X64Word_create(0x76f988da, 0x831153b5),
 11850  	        X64Word_create(0x983e5152, 0xee66dfab), X64Word_create(0xa831c66d, 0x2db43210),
 11851  	        X64Word_create(0xb00327c8, 0x98fb213f), X64Word_create(0xbf597fc7, 0xbeef0ee4),
 11852  	        X64Word_create(0xc6e00bf3, 0x3da88fc2), X64Word_create(0xd5a79147, 0x930aa725),
 11853  	        X64Word_create(0x06ca6351, 0xe003826f), X64Word_create(0x14292967, 0x0a0e6e70),
 11854  	        X64Word_create(0x27b70a85, 0x46d22ffc), X64Word_create(0x2e1b2138, 0x5c26c926),
 11855  	        X64Word_create(0x4d2c6dfc, 0x5ac42aed), X64Word_create(0x53380d13, 0x9d95b3df),
 11856  	        X64Word_create(0x650a7354, 0x8baf63de), X64Word_create(0x766a0abb, 0x3c77b2a8),
 11857  	        X64Word_create(0x81c2c92e, 0x47edaee6), X64Word_create(0x92722c85, 0x1482353b),
 11858  	        X64Word_create(0xa2bfe8a1, 0x4cf10364), X64Word_create(0xa81a664b, 0xbc423001),
 11859  	        X64Word_create(0xc24b8b70, 0xd0f89791), X64Word_create(0xc76c51a3, 0x0654be30),
 11860  	        X64Word_create(0xd192e819, 0xd6ef5218), X64Word_create(0xd6990624, 0x5565a910),
 11861  	        X64Word_create(0xf40e3585, 0x5771202a), X64Word_create(0x106aa070, 0x32bbd1b8),
 11862  	        X64Word_create(0x19a4c116, 0xb8d2d0c8), X64Word_create(0x1e376c08, 0x5141ab53),
 11863  	        X64Word_create(0x2748774c, 0xdf8eeb99), X64Word_create(0x34b0bcb5, 0xe19b48a8),
 11864  	        X64Word_create(0x391c0cb3, 0xc5c95a63), X64Word_create(0x4ed8aa4a, 0xe3418acb),
 11865  	        X64Word_create(0x5b9cca4f, 0x7763e373), X64Word_create(0x682e6ff3, 0xd6b2b8a3),
 11866  	        X64Word_create(0x748f82ee, 0x5defb2fc), X64Word_create(0x78a5636f, 0x43172f60),
 11867  	        X64Word_create(0x84c87814, 0xa1f0ab72), X64Word_create(0x8cc70208, 0x1a6439ec),
 11868  	        X64Word_create(0x90befffa, 0x23631e28), X64Word_create(0xa4506ceb, 0xde82bde9),
 11869  	        X64Word_create(0xbef9a3f7, 0xb2c67915), X64Word_create(0xc67178f2, 0xe372532b),
 11870  	        X64Word_create(0xca273ece, 0xea26619c), X64Word_create(0xd186b8c7, 0x21c0c207),
 11871  	        X64Word_create(0xeada7dd6, 0xcde0eb1e), X64Word_create(0xf57d4f7f, 0xee6ed178),
 11872  	        X64Word_create(0x06f067aa, 0x72176fba), X64Word_create(0x0a637dc5, 0xa2c898a6),
 11873  	        X64Word_create(0x113f9804, 0xbef90dae), X64Word_create(0x1b710b35, 0x131c471b),
 11874  	        X64Word_create(0x28db77f5, 0x23047d84), X64Word_create(0x32caab7b, 0x40c72493),
 11875  	        X64Word_create(0x3c9ebe0a, 0x15c9bebc), X64Word_create(0x431d67c4, 0x9c100d4c),
 11876  	        X64Word_create(0x4cc5d4be, 0xcb3e42b6), X64Word_create(0x597f299c, 0xfc657e2a),
 11877  	        X64Word_create(0x5fcb6fab, 0x3ad6faec), X64Word_create(0x6c44198c, 0x4a475817)
 11878  	    ];
 11879  
 11880  	    // Reusable objects
 11881  	    var W = [];
 11882  	    (function () {
 11883  	        for (var i = 0; i < 80; i++) {
 11884  	            W[i] = X64Word_create();
 11885  	        }
 11886  	    }());
 11887  
 11888  	    /**
 11889  	     * SHA-512 hash algorithm.
 11890  	     */
 11891  	    var SHA512 = C_algo.SHA512 = Hasher.extend({
 11892  	        _doReset: function () {
 11893  	            this._hash = new X64WordArray.init([
 11894  	                new X64Word.init(0x6a09e667, 0xf3bcc908), new X64Word.init(0xbb67ae85, 0x84caa73b),
 11895  	                new X64Word.init(0x3c6ef372, 0xfe94f82b), new X64Word.init(0xa54ff53a, 0x5f1d36f1),
 11896  	                new X64Word.init(0x510e527f, 0xade682d1), new X64Word.init(0x9b05688c, 0x2b3e6c1f),
 11897  	                new X64Word.init(0x1f83d9ab, 0xfb41bd6b), new X64Word.init(0x5be0cd19, 0x137e2179)
 11898  	            ]);
 11899  	        },
 11900  
 11901  	        _doProcessBlock: function (M, offset) {
 11902  	            // Shortcuts
 11903  	            var H = this._hash.words;
 11904  
 11905  	            var H0 = H[0];
 11906  	            var H1 = H[1];
 11907  	            var H2 = H[2];
 11908  	            var H3 = H[3];
 11909  	            var H4 = H[4];
 11910  	            var H5 = H[5];
 11911  	            var H6 = H[6];
 11912  	            var H7 = H[7];
 11913  
 11914  	            var H0h = H0.high;
 11915  	            var H0l = H0.low;
 11916  	            var H1h = H1.high;
 11917  	            var H1l = H1.low;
 11918  	            var H2h = H2.high;
 11919  	            var H2l = H2.low;
 11920  	            var H3h = H3.high;
 11921  	            var H3l = H3.low;
 11922  	            var H4h = H4.high;
 11923  	            var H4l = H4.low;
 11924  	            var H5h = H5.high;
 11925  	            var H5l = H5.low;
 11926  	            var H6h = H6.high;
 11927  	            var H6l = H6.low;
 11928  	            var H7h = H7.high;
 11929  	            var H7l = H7.low;
 11930  
 11931  	            // Working variables
 11932  	            var ah = H0h;
 11933  	            var al = H0l;
 11934  	            var bh = H1h;
 11935  	            var bl = H1l;
 11936  	            var ch = H2h;
 11937  	            var cl = H2l;
 11938  	            var dh = H3h;
 11939  	            var dl = H3l;
 11940  	            var eh = H4h;
 11941  	            var el = H4l;
 11942  	            var fh = H5h;
 11943  	            var fl = H5l;
 11944  	            var gh = H6h;
 11945  	            var gl = H6l;
 11946  	            var hh = H7h;
 11947  	            var hl = H7l;
 11948  
 11949  	            // Rounds
 11950  	            for (var i = 0; i < 80; i++) {
 11951  	                // Shortcut
 11952  	                var Wi = W[i];
 11953  
 11954  	                // Extend message
 11955  	                if (i < 16) {
 11956  	                    var Wih = Wi.high = M[offset + i * 2]     | 0;
 11957  	                    var Wil = Wi.low  = M[offset + i * 2 + 1] | 0;
 11958  	                } else {
 11959  	                    // Gamma0
 11960  	                    var gamma0x  = W[i - 15];
 11961  	                    var gamma0xh = gamma0x.high;
 11962  	                    var gamma0xl = gamma0x.low;
 11963  	                    var gamma0h  = ((gamma0xh >>> 1) | (gamma0xl << 31)) ^ ((gamma0xh >>> 8) | (gamma0xl << 24)) ^ (gamma0xh >>> 7);
 11964  	                    var gamma0l  = ((gamma0xl >>> 1) | (gamma0xh << 31)) ^ ((gamma0xl >>> 8) | (gamma0xh << 24)) ^ ((gamma0xl >>> 7) | (gamma0xh << 25));
 11965  
 11966  	                    // Gamma1
 11967  	                    var gamma1x  = W[i - 2];
 11968  	                    var gamma1xh = gamma1x.high;
 11969  	                    var gamma1xl = gamma1x.low;
 11970  	                    var gamma1h  = ((gamma1xh >>> 19) | (gamma1xl << 13)) ^ ((gamma1xh << 3) | (gamma1xl >>> 29)) ^ (gamma1xh >>> 6);
 11971  	                    var gamma1l  = ((gamma1xl >>> 19) | (gamma1xh << 13)) ^ ((gamma1xl << 3) | (gamma1xh >>> 29)) ^ ((gamma1xl >>> 6) | (gamma1xh << 26));
 11972  
 11973  	                    // W[i] = gamma0 + W[i - 7] + gamma1 + W[i - 16]
 11974  	                    var Wi7  = W[i - 7];
 11975  	                    var Wi7h = Wi7.high;
 11976  	                    var Wi7l = Wi7.low;
 11977  
 11978  	                    var Wi16  = W[i - 16];
 11979  	                    var Wi16h = Wi16.high;
 11980  	                    var Wi16l = Wi16.low;
 11981  
 11982  	                    var Wil = gamma0l + Wi7l;
 11983  	                    var Wih = gamma0h + Wi7h + ((Wil >>> 0) < (gamma0l >>> 0) ? 1 : 0);
 11984  	                    var Wil = Wil + gamma1l;
 11985  	                    var Wih = Wih + gamma1h + ((Wil >>> 0) < (gamma1l >>> 0) ? 1 : 0);
 11986  	                    var Wil = Wil + Wi16l;
 11987  	                    var Wih = Wih + Wi16h + ((Wil >>> 0) < (Wi16l >>> 0) ? 1 : 0);
 11988  
 11989  	                    Wi.high = Wih;
 11990  	                    Wi.low  = Wil;
 11991  	                }
 11992  
 11993  	                var chh  = (eh & fh) ^ (~eh & gh);
 11994  	                var chl  = (el & fl) ^ (~el & gl);
 11995  	                var majh = (ah & bh) ^ (ah & ch) ^ (bh & ch);
 11996  	                var majl = (al & bl) ^ (al & cl) ^ (bl & cl);
 11997  
 11998  	                var sigma0h = ((ah >>> 28) | (al << 4))  ^ ((ah << 30)  | (al >>> 2)) ^ ((ah << 25) | (al >>> 7));
 11999  	                var sigma0l = ((al >>> 28) | (ah << 4))  ^ ((al << 30)  | (ah >>> 2)) ^ ((al << 25) | (ah >>> 7));
 12000  	                var sigma1h = ((eh >>> 14) | (el << 18)) ^ ((eh >>> 18) | (el << 14)) ^ ((eh << 23) | (el >>> 9));
 12001  	                var sigma1l = ((el >>> 14) | (eh << 18)) ^ ((el >>> 18) | (eh << 14)) ^ ((el << 23) | (eh >>> 9));
 12002  
 12003  	                // t1 = h + sigma1 + ch + K[i] + W[i]
 12004  	                var Ki  = K[i];
 12005  	                var Kih = Ki.high;
 12006  	                var Kil = Ki.low;
 12007  
 12008  	                var t1l = hl + sigma1l;
 12009  	                var t1h = hh + sigma1h + ((t1l >>> 0) < (hl >>> 0) ? 1 : 0);
 12010  	                var t1l = t1l + chl;
 12011  	                var t1h = t1h + chh + ((t1l >>> 0) < (chl >>> 0) ? 1 : 0);
 12012  	                var t1l = t1l + Kil;
 12013  	                var t1h = t1h + Kih + ((t1l >>> 0) < (Kil >>> 0) ? 1 : 0);
 12014  	                var t1l = t1l + Wil;
 12015  	                var t1h = t1h + Wih + ((t1l >>> 0) < (Wil >>> 0) ? 1 : 0);
 12016  
 12017  	                // t2 = sigma0 + maj
 12018  	                var t2l = sigma0l + majl;
 12019  	                var t2h = sigma0h + majh + ((t2l >>> 0) < (sigma0l >>> 0) ? 1 : 0);
 12020  
 12021  	                // Update working variables
 12022  	                hh = gh;
 12023  	                hl = gl;
 12024  	                gh = fh;
 12025  	                gl = fl;
 12026  	                fh = eh;
 12027  	                fl = el;
 12028  	                el = (dl + t1l) | 0;
 12029  	                eh = (dh + t1h + ((el >>> 0) < (dl >>> 0) ? 1 : 0)) | 0;
 12030  	                dh = ch;
 12031  	                dl = cl;
 12032  	                ch = bh;
 12033  	                cl = bl;
 12034  	                bh = ah;
 12035  	                bl = al;
 12036  	                al = (t1l + t2l) | 0;
 12037  	                ah = (t1h + t2h + ((al >>> 0) < (t1l >>> 0) ? 1 : 0)) | 0;
 12038  	            }
 12039  
 12040  	            // Intermediate hash value
 12041  	            H0l = H0.low  = (H0l + al);
 12042  	            H0.high = (H0h + ah + ((H0l >>> 0) < (al >>> 0) ? 1 : 0));
 12043  	            H1l = H1.low  = (H1l + bl);
 12044  	            H1.high = (H1h + bh + ((H1l >>> 0) < (bl >>> 0) ? 1 : 0));
 12045  	            H2l = H2.low  = (H2l + cl);
 12046  	            H2.high = (H2h + ch + ((H2l >>> 0) < (cl >>> 0) ? 1 : 0));
 12047  	            H3l = H3.low  = (H3l + dl);
 12048  	            H3.high = (H3h + dh + ((H3l >>> 0) < (dl >>> 0) ? 1 : 0));
 12049  	            H4l = H4.low  = (H4l + el);
 12050  	            H4.high = (H4h + eh + ((H4l >>> 0) < (el >>> 0) ? 1 : 0));
 12051  	            H5l = H5.low  = (H5l + fl);
 12052  	            H5.high = (H5h + fh + ((H5l >>> 0) < (fl >>> 0) ? 1 : 0));
 12053  	            H6l = H6.low  = (H6l + gl);
 12054  	            H6.high = (H6h + gh + ((H6l >>> 0) < (gl >>> 0) ? 1 : 0));
 12055  	            H7l = H7.low  = (H7l + hl);
 12056  	            H7.high = (H7h + hh + ((H7l >>> 0) < (hl >>> 0) ? 1 : 0));
 12057  	        },
 12058  
 12059  	        _doFinalize: function () {
 12060  	            // Shortcuts
 12061  	            var data = this._data;
 12062  	            var dataWords = data.words;
 12063  
 12064  	            var nBitsTotal = this._nDataBytes * 8;
 12065  	            var nBitsLeft = data.sigBytes * 8;
 12066  
 12067  	            // Add padding
 12068  	            dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
 12069  	            dataWords[(((nBitsLeft + 128) >>> 10) << 5) + 30] = Math.floor(nBitsTotal / 0x100000000);
 12070  	            dataWords[(((nBitsLeft + 128) >>> 10) << 5) + 31] = nBitsTotal;
 12071  	            data.sigBytes = dataWords.length * 4;
 12072  
 12073  	            // Hash final blocks
 12074  	            this._process();
 12075  
 12076  	            // Convert hash to 32-bit word array before returning
 12077  	            var hash = this._hash.toX32();
 12078  
 12079  	            // Return final computed hash
 12080  	            return hash;
 12081  	        },
 12082  
 12083  	        clone: function () {
 12084  	            var clone = Hasher.clone.call(this);
 12085  	            clone._hash = this._hash.clone();
 12086  
 12087  	            return clone;
 12088  	        },
 12089  
 12090  	        blockSize: 1024/32
 12091  	    });
 12092  
 12093  	    /**
 12094  	     * Shortcut function to the hasher's object interface.
 12095  	     *
 12096  	     * @param {WordArray|string} message The message to hash.
 12097  	     *
 12098  	     * @return {WordArray} The hash.
 12099  	     *
 12100  	     * @static
 12101  	     *
 12102  	     * @example
 12103  	     *
 12104  	     *     var hash = CryptoJS.SHA512('message');
 12105  	     *     var hash = CryptoJS.SHA512(wordArray);
 12106  	     */
 12107  	    C.SHA512 = Hasher._createHelper(SHA512);
 12108  
 12109  	    /**
 12110  	     * Shortcut function to the HMAC's object interface.
 12111  	     *
 12112  	     * @param {WordArray|string} message The message to hash.
 12113  	     * @param {WordArray|string} key The secret key.
 12114  	     *
 12115  	     * @return {WordArray} The HMAC.
 12116  	     *
 12117  	     * @static
 12118  	     *
 12119  	     * @example
 12120  	     *
 12121  	     *     var hmac = CryptoJS.HmacSHA512(message, key);
 12122  	     */
 12123  	    C.HmacSHA512 = Hasher._createHmacHelper(SHA512);
 12124  	}());
 12125  
 12126  
 12127  	return CryptoJS.SHA512;
 12128  
 12129  }));
 12130  },{"./core":53,"./x64-core":84}],83:[function(require,module,exports){
 12131  ;(function (root, factory, undef) {
 12132  	if (typeof exports === "object") {
 12133  		// CommonJS
 12134  		module.exports = exports = factory(require("./core"), require("./enc-base64"), require("./md5"), require("./evpkdf"), require("./cipher-core"));
 12135  	}
 12136  	else if (typeof define === "function" && define.amd) {
 12137  		// AMD
 12138  		define(["./core", "./enc-base64", "./md5", "./evpkdf", "./cipher-core"], factory);
 12139  	}
 12140  	else {
 12141  		// Global (browser)
 12142  		factory(root.CryptoJS);
 12143  	}
 12144  }(this, function (CryptoJS) {
 12145  
 12146  	(function () {
 12147  	    // Shortcuts
 12148  	    var C = CryptoJS;
 12149  	    var C_lib = C.lib;
 12150  	    var WordArray = C_lib.WordArray;
 12151  	    var BlockCipher = C_lib.BlockCipher;
 12152  	    var C_algo = C.algo;
 12153  
 12154  	    // Permuted Choice 1 constants
 12155  	    var PC1 = [
 12156  	        57, 49, 41, 33, 25, 17, 9,  1,
 12157  	        58, 50, 42, 34, 26, 18, 10, 2,
 12158  	        59, 51, 43, 35, 27, 19, 11, 3,
 12159  	        60, 52, 44, 36, 63, 55, 47, 39,
 12160  	        31, 23, 15, 7,  62, 54, 46, 38,
 12161  	        30, 22, 14, 6,  61, 53, 45, 37,
 12162  	        29, 21, 13, 5,  28, 20, 12, 4
 12163  	    ];
 12164  
 12165  	    // Permuted Choice 2 constants
 12166  	    var PC2 = [
 12167  	        14, 17, 11, 24, 1,  5,
 12168  	        3,  28, 15, 6,  21, 10,
 12169  	        23, 19, 12, 4,  26, 8,
 12170  	        16, 7,  27, 20, 13, 2,
 12171  	        41, 52, 31, 37, 47, 55,
 12172  	        30, 40, 51, 45, 33, 48,
 12173  	        44, 49, 39, 56, 34, 53,
 12174  	        46, 42, 50, 36, 29, 32
 12175  	    ];
 12176  
 12177  	    // Cumulative bit shift constants
 12178  	    var BIT_SHIFTS = [1,  2,  4,  6,  8,  10, 12, 14, 15, 17, 19, 21, 23, 25, 27, 28];
 12179  
 12180  	    // SBOXes and round permutation constants
 12181  	    var SBOX_P = [
 12182  	        {
 12183  	            0x0: 0x808200,
 12184  	            0x10000000: 0x8000,
 12185  	            0x20000000: 0x808002,
 12186  	            0x30000000: 0x2,
 12187  	            0x40000000: 0x200,
 12188  	            0x50000000: 0x808202,
 12189  	            0x60000000: 0x800202,
 12190  	            0x70000000: 0x800000,
 12191  	            0x80000000: 0x202,
 12192  	            0x90000000: 0x800200,
 12193  	            0xa0000000: 0x8200,
 12194  	            0xb0000000: 0x808000,
 12195  	            0xc0000000: 0x8002,
 12196  	            0xd0000000: 0x800002,
 12197  	            0xe0000000: 0x0,
 12198  	            0xf0000000: 0x8202,
 12199  	            0x8000000: 0x0,
 12200  	            0x18000000: 0x808202,
 12201  	            0x28000000: 0x8202,
 12202  	            0x38000000: 0x8000,
 12203  	            0x48000000: 0x808200,
 12204  	            0x58000000: 0x200,
 12205  	            0x68000000: 0x808002,
 12206  	            0x78000000: 0x2,
 12207  	            0x88000000: 0x800200,
 12208  	            0x98000000: 0x8200,
 12209  	            0xa8000000: 0x808000,
 12210  	            0xb8000000: 0x800202,
 12211  	            0xc8000000: 0x800002,
 12212  	            0xd8000000: 0x8002,
 12213  	            0xe8000000: 0x202,
 12214  	            0xf8000000: 0x800000,
 12215  	            0x1: 0x8000,
 12216  	            0x10000001: 0x2,
 12217  	            0x20000001: 0x808200,
 12218  	            0x30000001: 0x800000,
 12219  	            0x40000001: 0x808002,
 12220  	            0x50000001: 0x8200,
 12221  	            0x60000001: 0x200,
 12222  	            0x70000001: 0x800202,
 12223  	            0x80000001: 0x808202,
 12224  	            0x90000001: 0x808000,
 12225  	            0xa0000001: 0x800002,
 12226  	            0xb0000001: 0x8202,
 12227  	            0xc0000001: 0x202,
 12228  	            0xd0000001: 0x800200,
 12229  	            0xe0000001: 0x8002,
 12230  	            0xf0000001: 0x0,
 12231  	            0x8000001: 0x808202,
 12232  	            0x18000001: 0x808000,
 12233  	            0x28000001: 0x800000,
 12234  	            0x38000001: 0x200,
 12235  	            0x48000001: 0x8000,
 12236  	            0x58000001: 0x800002,
 12237  	            0x68000001: 0x2,
 12238  	            0x78000001: 0x8202,
 12239  	            0x88000001: 0x8002,
 12240  	            0x98000001: 0x800202,
 12241  	            0xa8000001: 0x202,
 12242  	            0xb8000001: 0x808200,
 12243  	            0xc8000001: 0x800200,
 12244  	            0xd8000001: 0x0,
 12245  	            0xe8000001: 0x8200,
 12246  	            0xf8000001: 0x808002
 12247  	        },
 12248  	        {
 12249  	            0x0: 0x40084010,
 12250  	            0x1000000: 0x4000,
 12251  	            0x2000000: 0x80000,
 12252  	            0x3000000: 0x40080010,
 12253  	            0x4000000: 0x40000010,
 12254  	            0x5000000: 0x40084000,
 12255  	            0x6000000: 0x40004000,
 12256  	            0x7000000: 0x10,
 12257  	            0x8000000: 0x84000,
 12258  	            0x9000000: 0x40004010,
 12259  	            0xa000000: 0x40000000,
 12260  	            0xb000000: 0x84010,
 12261  	            0xc000000: 0x80010,
 12262  	            0xd000000: 0x0,
 12263  	            0xe000000: 0x4010,
 12264  	            0xf000000: 0x40080000,
 12265  	            0x800000: 0x40004000,
 12266  	            0x1800000: 0x84010,
 12267  	            0x2800000: 0x10,
 12268  	            0x3800000: 0x40004010,
 12269  	            0x4800000: 0x40084010,
 12270  	            0x5800000: 0x40000000,
 12271  	            0x6800000: 0x80000,
 12272  	            0x7800000: 0x40080010,
 12273  	            0x8800000: 0x80010,
 12274  	            0x9800000: 0x0,
 12275  	            0xa800000: 0x4000,
 12276  	            0xb800000: 0x40080000,
 12277  	            0xc800000: 0x40000010,
 12278  	            0xd800000: 0x84000,
 12279  	            0xe800000: 0x40084000,
 12280  	            0xf800000: 0x4010,
 12281  	            0x10000000: 0x0,
 12282  	            0x11000000: 0x40080010,
 12283  	            0x12000000: 0x40004010,
 12284  	            0x13000000: 0x40084000,
 12285  	            0x14000000: 0x40080000,
 12286  	            0x15000000: 0x10,
 12287  	            0x16000000: 0x84010,
 12288  	            0x17000000: 0x4000,
 12289  	            0x18000000: 0x4010,
 12290  	            0x19000000: 0x80000,
 12291  	            0x1a000000: 0x80010,
 12292  	            0x1b000000: 0x40000010,
 12293  	            0x1c000000: 0x84000,
 12294  	            0x1d000000: 0x40004000,
 12295  	            0x1e000000: 0x40000000,
 12296  	            0x1f000000: 0x40084010,
 12297  	            0x10800000: 0x84010,
 12298  	            0x11800000: 0x80000,
 12299  	            0x12800000: 0x40080000,
 12300  	            0x13800000: 0x4000,
 12301  	            0x14800000: 0x40004000,
 12302  	            0x15800000: 0x40084010,
 12303  	            0x16800000: 0x10,
 12304  	            0x17800000: 0x40000000,
 12305  	            0x18800000: 0x40084000,
 12306  	            0x19800000: 0x40000010,
 12307  	            0x1a800000: 0x40004010,
 12308  	            0x1b800000: 0x80010,
 12309  	            0x1c800000: 0x0,
 12310  	            0x1d800000: 0x4010,
 12311  	            0x1e800000: 0x40080010,
 12312  	            0x1f800000: 0x84000
 12313  	        },
 12314  	        {
 12315  	            0x0: 0x104,
 12316  	            0x100000: 0x0,
 12317  	            0x200000: 0x4000100,
 12318  	            0x300000: 0x10104,
 12319  	            0x400000: 0x10004,
 12320  	            0x500000: 0x4000004,
 12321  	            0x600000: 0x4010104,
 12322  	            0x700000: 0x4010000,
 12323  	            0x800000: 0x4000000,
 12324  	            0x900000: 0x4010100,
 12325  	            0xa00000: 0x10100,
 12326  	            0xb00000: 0x4010004,
 12327  	            0xc00000: 0x4000104,
 12328  	            0xd00000: 0x10000,
 12329  	            0xe00000: 0x4,
 12330  	            0xf00000: 0x100,
 12331  	            0x80000: 0x4010100,
 12332  	            0x180000: 0x4010004,
 12333  	            0x280000: 0x0,
 12334  	            0x380000: 0x4000100,
 12335  	            0x480000: 0x4000004,
 12336  	            0x580000: 0x10000,
 12337  	            0x680000: 0x10004,
 12338  	            0x780000: 0x104,
 12339  	            0x880000: 0x4,
 12340  	            0x980000: 0x100,
 12341  	            0xa80000: 0x4010000,
 12342  	            0xb80000: 0x10104,
 12343  	            0xc80000: 0x10100,
 12344  	            0xd80000: 0x4000104,
 12345  	            0xe80000: 0x4010104,
 12346  	            0xf80000: 0x4000000,
 12347  	            0x1000000: 0x4010100,
 12348  	            0x1100000: 0x10004,
 12349  	            0x1200000: 0x10000,
 12350  	            0x1300000: 0x4000100,
 12351  	            0x1400000: 0x100,
 12352  	            0x1500000: 0x4010104,
 12353  	            0x1600000: 0x4000004,
 12354  	            0x1700000: 0x0,
 12355  	            0x1800000: 0x4000104,
 12356  	            0x1900000: 0x4000000,
 12357  	            0x1a00000: 0x4,
 12358  	            0x1b00000: 0x10100,
 12359  	            0x1c00000: 0x4010000,
 12360  	            0x1d00000: 0x104,
 12361  	            0x1e00000: 0x10104,
 12362  	            0x1f00000: 0x4010004,
 12363  	            0x1080000: 0x4000000,
 12364  	            0x1180000: 0x104,
 12365  	            0x1280000: 0x4010100,
 12366  	            0x1380000: 0x0,
 12367  	            0x1480000: 0x10004,
 12368  	            0x1580000: 0x4000100,
 12369  	            0x1680000: 0x100,
 12370  	            0x1780000: 0x4010004,
 12371  	            0x1880000: 0x10000,
 12372  	            0x1980000: 0x4010104,
 12373  	            0x1a80000: 0x10104,
 12374  	            0x1b80000: 0x4000004,
 12375  	            0x1c80000: 0x4000104,
 12376  	            0x1d80000: 0x4010000,
 12377  	            0x1e80000: 0x4,
 12378  	            0x1f80000: 0x10100
 12379  	        },
 12380  	        {
 12381  	            0x0: 0x80401000,
 12382  	            0x10000: 0x80001040,
 12383  	            0x20000: 0x401040,
 12384  	            0x30000: 0x80400000,
 12385  	            0x40000: 0x0,
 12386  	            0x50000: 0x401000,
 12387  	            0x60000: 0x80000040,
 12388  	            0x70000: 0x400040,
 12389  	            0x80000: 0x80000000,
 12390  	            0x90000: 0x400000,
 12391  	            0xa0000: 0x40,
 12392  	            0xb0000: 0x80001000,
 12393  	            0xc0000: 0x80400040,
 12394  	            0xd0000: 0x1040,
 12395  	            0xe0000: 0x1000,
 12396  	            0xf0000: 0x80401040,
 12397  	            0x8000: 0x80001040,
 12398  	            0x18000: 0x40,
 12399  	            0x28000: 0x80400040,
 12400  	            0x38000: 0x80001000,
 12401  	            0x48000: 0x401000,
 12402  	            0x58000: 0x80401040,
 12403  	            0x68000: 0x0,
 12404  	            0x78000: 0x80400000,
 12405  	            0x88000: 0x1000,
 12406  	            0x98000: 0x80401000,
 12407  	            0xa8000: 0x400000,
 12408  	            0xb8000: 0x1040,
 12409  	            0xc8000: 0x80000000,
 12410  	            0xd8000: 0x400040,
 12411  	            0xe8000: 0x401040,
 12412  	            0xf8000: 0x80000040,
 12413  	            0x100000: 0x400040,
 12414  	            0x110000: 0x401000,
 12415  	            0x120000: 0x80000040,
 12416  	            0x130000: 0x0,
 12417  	            0x140000: 0x1040,
 12418  	            0x150000: 0x80400040,
 12419  	            0x160000: 0x80401000,
 12420  	            0x170000: 0x80001040,
 12421  	            0x180000: 0x80401040,
 12422  	            0x190000: 0x80000000,
 12423  	            0x1a0000: 0x80400000,
 12424  	            0x1b0000: 0x401040,
 12425  	            0x1c0000: 0x80001000,
 12426  	            0x1d0000: 0x400000,
 12427  	            0x1e0000: 0x40,
 12428  	            0x1f0000: 0x1000,
 12429  	            0x108000: 0x80400000,
 12430  	            0x118000: 0x80401040,
 12431  	            0x128000: 0x0,
 12432  	            0x138000: 0x401000,
 12433  	            0x148000: 0x400040,
 12434  	            0x158000: 0x80000000,
 12435  	            0x168000: 0x80001040,
 12436  	            0x178000: 0x40,
 12437  	            0x188000: 0x80000040,
 12438  	            0x198000: 0x1000,
 12439  	            0x1a8000: 0x80001000,
 12440  	            0x1b8000: 0x80400040,
 12441  	            0x1c8000: 0x1040,
 12442  	            0x1d8000: 0x80401000,
 12443  	            0x1e8000: 0x400000,
 12444  	            0x1f8000: 0x401040
 12445  	        },
 12446  	        {
 12447  	            0x0: 0x80,
 12448  	            0x1000: 0x1040000,
 12449  	            0x2000: 0x40000,
 12450  	            0x3000: 0x20000000,
 12451  	            0x4000: 0x20040080,
 12452  	            0x5000: 0x1000080,
 12453  	            0x6000: 0x21000080,
 12454  	            0x7000: 0x40080,
 12455  	            0x8000: 0x1000000,
 12456  	            0x9000: 0x20040000,
 12457  	            0xa000: 0x20000080,
 12458  	            0xb000: 0x21040080,
 12459  	            0xc000: 0x21040000,
 12460  	            0xd000: 0x0,
 12461  	            0xe000: 0x1040080,
 12462  	            0xf000: 0x21000000,
 12463  	            0x800: 0x1040080,
 12464  	            0x1800: 0x21000080,
 12465  	            0x2800: 0x80,
 12466  	            0x3800: 0x1040000,
 12467  	            0x4800: 0x40000,
 12468  	            0x5800: 0x20040080,
 12469  	            0x6800: 0x21040000,
 12470  	            0x7800: 0x20000000,
 12471  	            0x8800: 0x20040000,
 12472  	            0x9800: 0x0,
 12473  	            0xa800: 0x21040080,
 12474  	            0xb800: 0x1000080,
 12475  	            0xc800: 0x20000080,
 12476  	            0xd800: 0x21000000,
 12477  	            0xe800: 0x1000000,
 12478  	            0xf800: 0x40080,
 12479  	            0x10000: 0x40000,
 12480  	            0x11000: 0x80,
 12481  	            0x12000: 0x20000000,
 12482  	            0x13000: 0x21000080,
 12483  	            0x14000: 0x1000080,
 12484  	            0x15000: 0x21040000,
 12485  	            0x16000: 0x20040080,
 12486  	            0x17000: 0x1000000,
 12487  	            0x18000: 0x21040080,
 12488  	            0x19000: 0x21000000,
 12489  	            0x1a000: 0x1040000,
 12490  	            0x1b000: 0x20040000,
 12491  	            0x1c000: 0x40080,
 12492  	            0x1d000: 0x20000080,
 12493  	            0x1e000: 0x0,
 12494  	            0x1f000: 0x1040080,
 12495  	            0x10800: 0x21000080,
 12496  	            0x11800: 0x1000000,
 12497  	            0x12800: 0x1040000,
 12498  	            0x13800: 0x20040080,
 12499  	            0x14800: 0x20000000,
 12500  	            0x15800: 0x1040080,
 12501  	            0x16800: 0x80,
 12502  	            0x17800: 0x21040000,
 12503  	            0x18800: 0x40080,
 12504  	            0x19800: 0x21040080,
 12505  	            0x1a800: 0x0,
 12506  	            0x1b800: 0x21000000,
 12507  	            0x1c800: 0x1000080,
 12508  	            0x1d800: 0x40000,
 12509  	            0x1e800: 0x20040000,
 12510  	            0x1f800: 0x20000080
 12511  	        },
 12512  	        {
 12513  	            0x0: 0x10000008,
 12514  	            0x100: 0x2000,
 12515  	            0x200: 0x10200000,
 12516  	            0x300: 0x10202008,
 12517  	            0x400: 0x10002000,
 12518  	            0x500: 0x200000,
 12519  	            0x600: 0x200008,
 12520  	            0x700: 0x10000000,
 12521  	            0x800: 0x0,
 12522  	            0x900: 0x10002008,
 12523  	            0xa00: 0x202000,
 12524  	            0xb00: 0x8,
 12525  	            0xc00: 0x10200008,
 12526  	            0xd00: 0x202008,
 12527  	            0xe00: 0x2008,
 12528  	            0xf00: 0x10202000,
 12529  	            0x80: 0x10200000,
 12530  	            0x180: 0x10202008,
 12531  	            0x280: 0x8,
 12532  	            0x380: 0x200000,
 12533  	            0x480: 0x202008,
 12534  	            0x580: 0x10000008,
 12535  	            0x680: 0x10002000,
 12536  	            0x780: 0x2008,
 12537  	            0x880: 0x200008,
 12538  	            0x980: 0x2000,
 12539  	            0xa80: 0x10002008,
 12540  	            0xb80: 0x10200008,
 12541  	            0xc80: 0x0,
 12542  	            0xd80: 0x10202000,
 12543  	            0xe80: 0x202000,
 12544  	            0xf80: 0x10000000,
 12545  	            0x1000: 0x10002000,
 12546  	            0x1100: 0x10200008,
 12547  	            0x1200: 0x10202008,
 12548  	            0x1300: 0x2008,
 12549  	            0x1400: 0x200000,
 12550  	            0x1500: 0x10000000,
 12551  	            0x1600: 0x10000008,
 12552  	            0x1700: 0x202000,
 12553  	            0x1800: 0x202008,
 12554  	            0x1900: 0x0,
 12555  	            0x1a00: 0x8,
 12556  	            0x1b00: 0x10200000,
 12557  	            0x1c00: 0x2000,
 12558  	            0x1d00: 0x10002008,
 12559  	            0x1e00: 0x10202000,
 12560  	            0x1f00: 0x200008,
 12561  	            0x1080: 0x8,
 12562  	            0x1180: 0x202000,
 12563  	            0x1280: 0x200000,
 12564  	            0x1380: 0x10000008,
 12565  	            0x1480: 0x10002000,
 12566  	            0x1580: 0x2008,
 12567  	            0x1680: 0x10202008,
 12568  	            0x1780: 0x10200000,
 12569  	            0x1880: 0x10202000,
 12570  	            0x1980: 0x10200008,
 12571  	            0x1a80: 0x2000,
 12572  	            0x1b80: 0x202008,
 12573  	            0x1c80: 0x200008,
 12574  	            0x1d80: 0x0,
 12575  	            0x1e80: 0x10000000,
 12576  	            0x1f80: 0x10002008
 12577  	        },
 12578  	        {
 12579  	            0x0: 0x100000,
 12580  	            0x10: 0x2000401,
 12581  	            0x20: 0x400,
 12582  	            0x30: 0x100401,
 12583  	            0x40: 0x2100401,
 12584  	            0x50: 0x0,
 12585  	            0x60: 0x1,
 12586  	            0x70: 0x2100001,
 12587  	            0x80: 0x2000400,
 12588  	            0x90: 0x100001,
 12589  	            0xa0: 0x2000001,
 12590  	            0xb0: 0x2100400,
 12591  	            0xc0: 0x2100000,
 12592  	            0xd0: 0x401,
 12593  	            0xe0: 0x100400,
 12594  	            0xf0: 0x2000000,
 12595  	            0x8: 0x2100001,
 12596  	            0x18: 0x0,
 12597  	            0x28: 0x2000401,
 12598  	            0x38: 0x2100400,
 12599  	            0x48: 0x100000,
 12600  	            0x58: 0x2000001,
 12601  	            0x68: 0x2000000,
 12602  	            0x78: 0x401,
 12603  	            0x88: 0x100401,
 12604  	            0x98: 0x2000400,
 12605  	            0xa8: 0x2100000,
 12606  	            0xb8: 0x100001,
 12607  	            0xc8: 0x400,
 12608  	            0xd8: 0x2100401,
 12609  	            0xe8: 0x1,
 12610  	            0xf8: 0x100400,
 12611  	            0x100: 0x2000000,
 12612  	            0x110: 0x100000,
 12613  	            0x120: 0x2000401,
 12614  	            0x130: 0x2100001,
 12615  	            0x140: 0x100001,
 12616  	            0x150: 0x2000400,
 12617  	            0x160: 0x2100400,
 12618  	            0x170: 0x100401,
 12619  	            0x180: 0x401,
 12620  	            0x190: 0x2100401,
 12621  	            0x1a0: 0x100400,
 12622  	            0x1b0: 0x1,
 12623  	            0x1c0: 0x0,
 12624  	            0x1d0: 0x2100000,
 12625  	            0x1e0: 0x2000001,
 12626  	            0x1f0: 0x400,
 12627  	            0x108: 0x100400,
 12628  	            0x118: 0x2000401,
 12629  	            0x128: 0x2100001,
 12630  	            0x138: 0x1,
 12631  	            0x148: 0x2000000,
 12632  	            0x158: 0x100000,
 12633  	            0x168: 0x401,
 12634  	            0x178: 0x2100400,
 12635  	            0x188: 0x2000001,
 12636  	            0x198: 0x2100000,
 12637  	            0x1a8: 0x0,
 12638  	            0x1b8: 0x2100401,
 12639  	            0x1c8: 0x100401,
 12640  	            0x1d8: 0x400,
 12641  	            0x1e8: 0x2000400,
 12642  	            0x1f8: 0x100001
 12643  	        },
 12644  	        {
 12645  	            0x0: 0x8000820,
 12646  	            0x1: 0x20000,
 12647  	            0x2: 0x8000000,
 12648  	            0x3: 0x20,
 12649  	            0x4: 0x20020,
 12650  	            0x5: 0x8020820,
 12651  	            0x6: 0x8020800,
 12652  	            0x7: 0x800,
 12653  	            0x8: 0x8020000,
 12654  	            0x9: 0x8000800,
 12655  	            0xa: 0x20800,
 12656  	            0xb: 0x8020020,
 12657  	            0xc: 0x820,
 12658  	            0xd: 0x0,
 12659  	            0xe: 0x8000020,
 12660  	            0xf: 0x20820,
 12661  	            0x80000000: 0x800,
 12662  	            0x80000001: 0x8020820,
 12663  	            0x80000002: 0x8000820,
 12664  	            0x80000003: 0x8000000,
 12665  	            0x80000004: 0x8020000,
 12666  	            0x80000005: 0x20800,
 12667  	            0x80000006: 0x20820,
 12668  	            0x80000007: 0x20,
 12669  	            0x80000008: 0x8000020,
 12670  	            0x80000009: 0x820,
 12671  	            0x8000000a: 0x20020,
 12672  	            0x8000000b: 0x8020800,
 12673  	            0x8000000c: 0x0,
 12674  	            0x8000000d: 0x8020020,
 12675  	            0x8000000e: 0x8000800,
 12676  	            0x8000000f: 0x20000,
 12677  	            0x10: 0x20820,
 12678  	            0x11: 0x8020800,
 12679  	            0x12: 0x20,
 12680  	            0x13: 0x800,
 12681  	            0x14: 0x8000800,
 12682  	            0x15: 0x8000020,
 12683  	            0x16: 0x8020020,
 12684  	            0x17: 0x20000,
 12685  	            0x18: 0x0,
 12686  	            0x19: 0x20020,
 12687  	            0x1a: 0x8020000,
 12688  	            0x1b: 0x8000820,
 12689  	            0x1c: 0x8020820,
 12690  	            0x1d: 0x20800,
 12691  	            0x1e: 0x820,
 12692  	            0x1f: 0x8000000,
 12693  	            0x80000010: 0x20000,
 12694  	            0x80000011: 0x800,
 12695  	            0x80000012: 0x8020020,
 12696  	            0x80000013: 0x20820,
 12697  	            0x80000014: 0x20,
 12698  	            0x80000015: 0x8020000,
 12699  	            0x80000016: 0x8000000,
 12700  	            0x80000017: 0x8000820,
 12701  	            0x80000018: 0x8020820,
 12702  	            0x80000019: 0x8000020,
 12703  	            0x8000001a: 0x8000800,
 12704  	            0x8000001b: 0x0,
 12705  	            0x8000001c: 0x20800,
 12706  	            0x8000001d: 0x820,
 12707  	            0x8000001e: 0x20020,
 12708  	            0x8000001f: 0x8020800
 12709  	        }
 12710  	    ];
 12711  
 12712  	    // Masks that select the SBOX input
 12713  	    var SBOX_MASK = [
 12714  	        0xf8000001, 0x1f800000, 0x01f80000, 0x001f8000,
 12715  	        0x0001f800, 0x00001f80, 0x000001f8, 0x8000001f
 12716  	    ];
 12717  
 12718  	    /**
 12719  	     * DES block cipher algorithm.
 12720  	     */
 12721  	    var DES = C_algo.DES = BlockCipher.extend({
 12722  	        _doReset: function () {
 12723  	            // Shortcuts
 12724  	            var key = this._key;
 12725  	            var keyWords = key.words;
 12726  
 12727  	            // Select 56 bits according to PC1
 12728  	            var keyBits = [];
 12729  	            for (var i = 0; i < 56; i++) {
 12730  	                var keyBitPos = PC1[i] - 1;
 12731  	                keyBits[i] = (keyWords[keyBitPos >>> 5] >>> (31 - keyBitPos % 32)) & 1;
 12732  	            }
 12733  
 12734  	            // Assemble 16 subkeys
 12735  	            var subKeys = this._subKeys = [];
 12736  	            for (var nSubKey = 0; nSubKey < 16; nSubKey++) {
 12737  	                // Create subkey
 12738  	                var subKey = subKeys[nSubKey] = [];
 12739  
 12740  	                // Shortcut
 12741  	                var bitShift = BIT_SHIFTS[nSubKey];
 12742  
 12743  	                // Select 48 bits according to PC2
 12744  	                for (var i = 0; i < 24; i++) {
 12745  	                    // Select from the left 28 key bits
 12746  	                    subKey[(i / 6) | 0] |= keyBits[((PC2[i] - 1) + bitShift) % 28] << (31 - i % 6);
 12747  
 12748  	                    // Select from the right 28 key bits
 12749  	                    subKey[4 + ((i / 6) | 0)] |= keyBits[28 + (((PC2[i + 24] - 1) + bitShift) % 28)] << (31 - i % 6);
 12750  	                }
 12751  
 12752  	                // Since each subkey is applied to an expanded 32-bit input,
 12753  	                // the subkey can be broken into 8 values scaled to 32-bits,
 12754  	                // which allows the key to be used without expansion
 12755  	                subKey[0] = (subKey[0] << 1) | (subKey[0] >>> 31);
 12756  	                for (var i = 1; i < 7; i++) {
 12757  	                    subKey[i] = subKey[i] >>> ((i - 1) * 4 + 3);
 12758  	                }
 12759  	                subKey[7] = (subKey[7] << 5) | (subKey[7] >>> 27);
 12760  	            }
 12761  
 12762  	            // Compute inverse subkeys
 12763  	            var invSubKeys = this._invSubKeys = [];
 12764  	            for (var i = 0; i < 16; i++) {
 12765  	                invSubKeys[i] = subKeys[15 - i];
 12766  	            }
 12767  	        },
 12768  
 12769  	        encryptBlock: function (M, offset) {
 12770  	            this._doCryptBlock(M, offset, this._subKeys);
 12771  	        },
 12772  
 12773  	        decryptBlock: function (M, offset) {
 12774  	            this._doCryptBlock(M, offset, this._invSubKeys);
 12775  	        },
 12776  
 12777  	        _doCryptBlock: function (M, offset, subKeys) {
 12778  	            // Get input
 12779  	            this._lBlock = M[offset];
 12780  	            this._rBlock = M[offset + 1];
 12781  
 12782  	            // Initial permutation
 12783  	            exchangeLR.call(this, 4,  0x0f0f0f0f);
 12784  	            exchangeLR.call(this, 16, 0x0000ffff);
 12785  	            exchangeRL.call(this, 2,  0x33333333);
 12786  	            exchangeRL.call(this, 8,  0x00ff00ff);
 12787  	            exchangeLR.call(this, 1,  0x55555555);
 12788  
 12789  	            // Rounds
 12790  	            for (var round = 0; round < 16; round++) {
 12791  	                // Shortcuts
 12792  	                var subKey = subKeys[round];
 12793  	                var lBlock = this._lBlock;
 12794  	                var rBlock = this._rBlock;
 12795  
 12796  	                // Feistel function
 12797  	                var f = 0;
 12798  	                for (var i = 0; i < 8; i++) {
 12799  	                    f |= SBOX_P[i][((rBlock ^ subKey[i]) & SBOX_MASK[i]) >>> 0];
 12800  	                }
 12801  	                this._lBlock = rBlock;
 12802  	                this._rBlock = lBlock ^ f;
 12803  	            }
 12804  
 12805  	            // Undo swap from last round
 12806  	            var t = this._lBlock;
 12807  	            this._lBlock = this._rBlock;
 12808  	            this._rBlock = t;
 12809  
 12810  	            // Final permutation
 12811  	            exchangeLR.call(this, 1,  0x55555555);
 12812  	            exchangeRL.call(this, 8,  0x00ff00ff);
 12813  	            exchangeRL.call(this, 2,  0x33333333);
 12814  	            exchangeLR.call(this, 16, 0x0000ffff);
 12815  	            exchangeLR.call(this, 4,  0x0f0f0f0f);
 12816  
 12817  	            // Set output
 12818  	            M[offset] = this._lBlock;
 12819  	            M[offset + 1] = this._rBlock;
 12820  	        },
 12821  
 12822  	        keySize: 64/32,
 12823  
 12824  	        ivSize: 64/32,
 12825  
 12826  	        blockSize: 64/32
 12827  	    });
 12828  
 12829  	    // Swap bits across the left and right words
 12830  	    function exchangeLR(offset, mask) {
 12831  	        var t = ((this._lBlock >>> offset) ^ this._rBlock) & mask;
 12832  	        this._rBlock ^= t;
 12833  	        this._lBlock ^= t << offset;
 12834  	    }
 12835  
 12836  	    function exchangeRL(offset, mask) {
 12837  	        var t = ((this._rBlock >>> offset) ^ this._lBlock) & mask;
 12838  	        this._lBlock ^= t;
 12839  	        this._rBlock ^= t << offset;
 12840  	    }
 12841  
 12842  	    /**
 12843  	     * Shortcut functions to the cipher's object interface.
 12844  	     *
 12845  	     * @example
 12846  	     *
 12847  	     *     var ciphertext = CryptoJS.DES.encrypt(message, key, cfg);
 12848  	     *     var plaintext  = CryptoJS.DES.decrypt(ciphertext, key, cfg);
 12849  	     */
 12850  	    C.DES = BlockCipher._createHelper(DES);
 12851  
 12852  	    /**
 12853  	     * Triple-DES block cipher algorithm.
 12854  	     */
 12855  	    var TripleDES = C_algo.TripleDES = BlockCipher.extend({
 12856  	        _doReset: function () {
 12857  	            // Shortcuts
 12858  	            var key = this._key;
 12859  	            var keyWords = key.words;
 12860  
 12861  	            // Create DES instances
 12862  	            this._des1 = DES.createEncryptor(WordArray.create(keyWords.slice(0, 2)));
 12863  	            this._des2 = DES.createEncryptor(WordArray.create(keyWords.slice(2, 4)));
 12864  	            this._des3 = DES.createEncryptor(WordArray.create(keyWords.slice(4, 6)));
 12865  	        },
 12866  
 12867  	        encryptBlock: function (M, offset) {
 12868  	            this._des1.encryptBlock(M, offset);
 12869  	            this._des2.decryptBlock(M, offset);
 12870  	            this._des3.encryptBlock(M, offset);
 12871  	        },
 12872  
 12873  	        decryptBlock: function (M, offset) {
 12874  	            this._des3.decryptBlock(M, offset);
 12875  	            this._des2.encryptBlock(M, offset);
 12876  	            this._des1.decryptBlock(M, offset);
 12877  	        },
 12878  
 12879  	        keySize: 192/32,
 12880  
 12881  	        ivSize: 64/32,
 12882  
 12883  	        blockSize: 64/32
 12884  	    });
 12885  
 12886  	    /**
 12887  	     * Shortcut functions to the cipher's object interface.
 12888  	     *
 12889  	     * @example
 12890  	     *
 12891  	     *     var ciphertext = CryptoJS.TripleDES.encrypt(message, key, cfg);
 12892  	     *     var plaintext  = CryptoJS.TripleDES.decrypt(ciphertext, key, cfg);
 12893  	     */
 12894  	    C.TripleDES = BlockCipher._createHelper(TripleDES);
 12895  	}());
 12896  
 12897  
 12898  	return CryptoJS.TripleDES;
 12899  
 12900  }));
 12901  },{"./cipher-core":52,"./core":53,"./enc-base64":54,"./evpkdf":56,"./md5":61}],84:[function(require,module,exports){
 12902  ;(function (root, factory) {
 12903  	if (typeof exports === "object") {
 12904  		// CommonJS
 12905  		module.exports = exports = factory(require("./core"));
 12906  	}
 12907  	else if (typeof define === "function" && define.amd) {
 12908  		// AMD
 12909  		define(["./core"], factory);
 12910  	}
 12911  	else {
 12912  		// Global (browser)
 12913  		factory(root.CryptoJS);
 12914  	}
 12915  }(this, function (CryptoJS) {
 12916  
 12917  	(function (undefined) {
 12918  	    // Shortcuts
 12919  	    var C = CryptoJS;
 12920  	    var C_lib = C.lib;
 12921  	    var Base = C_lib.Base;
 12922  	    var X32WordArray = C_lib.WordArray;
 12923  
 12924  	    /**
 12925  	     * x64 namespace.
 12926  	     */
 12927  	    var C_x64 = C.x64 = {};
 12928  
 12929  	    /**
 12930  	     * A 64-bit word.
 12931  	     */
 12932  	    var X64Word = C_x64.Word = Base.extend({
 12933  	        /**
 12934  	         * Initializes a newly created 64-bit word.
 12935  	         *
 12936  	         * @param {number} high The high 32 bits.
 12937  	         * @param {number} low The low 32 bits.
 12938  	         *
 12939  	         * @example
 12940  	         *
 12941  	         *     var x64Word = CryptoJS.x64.Word.create(0x00010203, 0x04050607);
 12942  	         */
 12943  	        init: function (high, low) {
 12944  	            this.high = high;
 12945  	            this.low = low;
 12946  	        }
 12947  
 12948  	        /**
 12949  	         * Bitwise NOTs this word.
 12950  	         *
 12951  	         * @return {X64Word} A new x64-Word object after negating.
 12952  	         *
 12953  	         * @example
 12954  	         *
 12955  	         *     var negated = x64Word.not();
 12956  	         */
 12957  	        // not: function () {
 12958  	            // var high = ~this.high;
 12959  	            // var low = ~this.low;
 12960  
 12961  	            // return X64Word.create(high, low);
 12962  	        // },
 12963  
 12964  	        /**
 12965  	         * Bitwise ANDs this word with the passed word.
 12966  	         *
 12967  	         * @param {X64Word} word The x64-Word to AND with this word.
 12968  	         *
 12969  	         * @return {X64Word} A new x64-Word object after ANDing.
 12970  	         *
 12971  	         * @example
 12972  	         *
 12973  	         *     var anded = x64Word.and(anotherX64Word);
 12974  	         */
 12975  	        // and: function (word) {
 12976  	            // var high = this.high & word.high;
 12977  	            // var low = this.low & word.low;
 12978  
 12979  	            // return X64Word.create(high, low);
 12980  	        // },
 12981  
 12982  	        /**
 12983  	         * Bitwise ORs this word with the passed word.
 12984  	         *
 12985  	         * @param {X64Word} word The x64-Word to OR with this word.
 12986  	         *
 12987  	         * @return {X64Word} A new x64-Word object after ORing.
 12988  	         *
 12989  	         * @example
 12990  	         *
 12991  	         *     var ored = x64Word.or(anotherX64Word);
 12992  	         */
 12993  	        // or: function (word) {
 12994  	            // var high = this.high | word.high;
 12995  	            // var low = this.low | word.low;
 12996  
 12997  	            // return X64Word.create(high, low);
 12998  	        // },
 12999  
 13000  	        /**
 13001  	         * Bitwise XORs this word with the passed word.
 13002  	         *
 13003  	         * @param {X64Word} word The x64-Word to XOR with this word.
 13004  	         *
 13005  	         * @return {X64Word} A new x64-Word object after XORing.
 13006  	         *
 13007  	         * @example
 13008  	         *
 13009  	         *     var xored = x64Word.xor(anotherX64Word);
 13010  	         */
 13011  	        // xor: function (word) {
 13012  	            // var high = this.high ^ word.high;
 13013  	            // var low = this.low ^ word.low;
 13014  
 13015  	            // return X64Word.create(high, low);
 13016  	        // },
 13017  
 13018  	        /**
 13019  	         * Shifts this word n bits to the left.
 13020  	         *
 13021  	         * @param {number} n The number of bits to shift.
 13022  	         *
 13023  	         * @return {X64Word} A new x64-Word object after shifting.
 13024  	         *
 13025  	         * @example
 13026  	         *
 13027  	         *     var shifted = x64Word.shiftL(25);
 13028  	         */
 13029  	        // shiftL: function (n) {
 13030  	            // if (n < 32) {
 13031  	                // var high = (this.high << n) | (this.low >>> (32 - n));
 13032  	                // var low = this.low << n;
 13033  	            // } else {
 13034  	                // var high = this.low << (n - 32);
 13035  	                // var low = 0;
 13036  	            // }
 13037  
 13038  	            // return X64Word.create(high, low);
 13039  	        // },
 13040  
 13041  	        /**
 13042  	         * Shifts this word n bits to the right.
 13043  	         *
 13044  	         * @param {number} n The number of bits to shift.
 13045  	         *
 13046  	         * @return {X64Word} A new x64-Word object after shifting.
 13047  	         *
 13048  	         * @example
 13049  	         *
 13050  	         *     var shifted = x64Word.shiftR(7);
 13051  	         */
 13052  	        // shiftR: function (n) {
 13053  	            // if (n < 32) {
 13054  	                // var low = (this.low >>> n) | (this.high << (32 - n));
 13055  	                // var high = this.high >>> n;
 13056  	            // } else {
 13057  	                // var low = this.high >>> (n - 32);
 13058  	                // var high = 0;
 13059  	            // }
 13060  
 13061  	            // return X64Word.create(high, low);
 13062  	        // },
 13063  
 13064  	        /**
 13065  	         * Rotates this word n bits to the left.
 13066  	         *
 13067  	         * @param {number} n The number of bits to rotate.
 13068  	         *
 13069  	         * @return {X64Word} A new x64-Word object after rotating.
 13070  	         *
 13071  	         * @example
 13072  	         *
 13073  	         *     var rotated = x64Word.rotL(25);
 13074  	         */
 13075  	        // rotL: function (n) {
 13076  	            // return this.shiftL(n).or(this.shiftR(64 - n));
 13077  	        // },
 13078  
 13079  	        /**
 13080  	         * Rotates this word n bits to the right.
 13081  	         *
 13082  	         * @param {number} n The number of bits to rotate.
 13083  	         *
 13084  	         * @return {X64Word} A new x64-Word object after rotating.
 13085  	         *
 13086  	         * @example
 13087  	         *
 13088  	         *     var rotated = x64Word.rotR(7);
 13089  	         */
 13090  	        // rotR: function (n) {
 13091  	            // return this.shiftR(n).or(this.shiftL(64 - n));
 13092  	        // },
 13093  
 13094  	        /**
 13095  	         * Adds this word with the passed word.
 13096  	         *
 13097  	         * @param {X64Word} word The x64-Word to add with this word.
 13098  	         *
 13099  	         * @return {X64Word} A new x64-Word object after adding.
 13100  	         *
 13101  	         * @example
 13102  	         *
 13103  	         *     var added = x64Word.add(anotherX64Word);
 13104  	         */
 13105  	        // add: function (word) {
 13106  	            // var low = (this.low + word.low) | 0;
 13107  	            // var carry = (low >>> 0) < (this.low >>> 0) ? 1 : 0;
 13108  	            // var high = (this.high + word.high + carry) | 0;
 13109  
 13110  	            // return X64Word.create(high, low);
 13111  	        // }
 13112  	    });
 13113  
 13114  	    /**
 13115  	     * An array of 64-bit words.
 13116  	     *
 13117  	     * @property {Array} words The array of CryptoJS.x64.Word objects.
 13118  	     * @property {number} sigBytes The number of significant bytes in this word array.
 13119  	     */
 13120  	    var X64WordArray = C_x64.WordArray = Base.extend({
 13121  	        /**
 13122  	         * Initializes a newly created word array.
 13123  	         *
 13124  	         * @param {Array} words (Optional) An array of CryptoJS.x64.Word objects.
 13125  	         * @param {number} sigBytes (Optional) The number of significant bytes in the words.
 13126  	         *
 13127  	         * @example
 13128  	         *
 13129  	         *     var wordArray = CryptoJS.x64.WordArray.create();
 13130  	         *
 13131  	         *     var wordArray = CryptoJS.x64.WordArray.create([
 13132  	         *         CryptoJS.x64.Word.create(0x00010203, 0x04050607),
 13133  	         *         CryptoJS.x64.Word.create(0x18191a1b, 0x1c1d1e1f)
 13134  	         *     ]);
 13135  	         *
 13136  	         *     var wordArray = CryptoJS.x64.WordArray.create([
 13137  	         *         CryptoJS.x64.Word.create(0x00010203, 0x04050607),
 13138  	         *         CryptoJS.x64.Word.create(0x18191a1b, 0x1c1d1e1f)
 13139  	         *     ], 10);
 13140  	         */
 13141  	        init: function (words, sigBytes) {
 13142  	            words = this.words = words || [];
 13143  
 13144  	            if (sigBytes != undefined) {
 13145  	                this.sigBytes = sigBytes;
 13146  	            } else {
 13147  	                this.sigBytes = words.length * 8;
 13148  	            }
 13149  	        },
 13150  
 13151  	        /**
 13152  	         * Converts this 64-bit word array to a 32-bit word array.
 13153  	         *
 13154  	         * @return {CryptoJS.lib.WordArray} This word array's data as a 32-bit word array.
 13155  	         *
 13156  	         * @example
 13157  	         *
 13158  	         *     var x32WordArray = x64WordArray.toX32();
 13159  	         */
 13160  	        toX32: function () {
 13161  	            // Shortcuts
 13162  	            var x64Words = this.words;
 13163  	            var x64WordsLength = x64Words.length;
 13164  
 13165  	            // Convert
 13166  	            var x32Words = [];
 13167  	            for (var i = 0; i < x64WordsLength; i++) {
 13168  	                var x64Word = x64Words[i];
 13169  	                x32Words.push(x64Word.high);
 13170  	                x32Words.push(x64Word.low);
 13171  	            }
 13172  
 13173  	            return X32WordArray.create(x32Words, this.sigBytes);
 13174  	        },
 13175  
 13176  	        /**
 13177  	         * Creates a copy of this word array.
 13178  	         *
 13179  	         * @return {X64WordArray} The clone.
 13180  	         *
 13181  	         * @example
 13182  	         *
 13183  	         *     var clone = x64WordArray.clone();
 13184  	         */
 13185  	        clone: function () {
 13186  	            var clone = Base.clone.call(this);
 13187  
 13188  	            // Clone "words" array
 13189  	            var words = clone.words = this.words.slice(0);
 13190  
 13191  	            // Clone each X64Word object
 13192  	            var wordsLength = words.length;
 13193  	            for (var i = 0; i < wordsLength; i++) {
 13194  	                words[i] = words[i].clone();
 13195  	            }
 13196  
 13197  	            return clone;
 13198  	        }
 13199  	    });
 13200  	}());
 13201  
 13202  
 13203  	return CryptoJS;
 13204  
 13205  }));
 13206  },{"./core":53}],85:[function(require,module,exports){
 13207  /*! https://mths.be/utf8js v2.1.2 by @mathias */
 13208  ;(function(root) {
 13209  
 13210  	// Detect free variables `exports`
 13211  	var freeExports = typeof exports == 'object' && exports;
 13212  
 13213  	// Detect free variable `module`
 13214  	var freeModule = typeof module == 'object' && module &&
 13215  		module.exports == freeExports && module;
 13216  
 13217  	// Detect free variable `global`, from Node.js or Browserified code,
 13218  	// and use it as `root`
 13219  	var freeGlobal = typeof global == 'object' && global;
 13220  	if (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal) {
 13221  		root = freeGlobal;
 13222  	}
 13223  
 13224  	/*--------------------------------------------------------------------------*/
 13225  
 13226  	var stringFromCharCode = String.fromCharCode;
 13227  
 13228  	// Taken from https://mths.be/punycode
 13229  	function ucs2decode(string) {
 13230  		var output = [];
 13231  		var counter = 0;
 13232  		var length = string.length;
 13233  		var value;
 13234  		var extra;
 13235  		while (counter < length) {
 13236  			value = string.charCodeAt(counter++);
 13237  			if (value >= 0xD800 && value <= 0xDBFF && counter < length) {
 13238  				// high surrogate, and there is a next character
 13239  				extra = string.charCodeAt(counter++);
 13240  				if ((extra & 0xFC00) == 0xDC00) { // low surrogate
 13241  					output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000);
 13242  				} else {
 13243  					// unmatched surrogate; only append this code unit, in case the next
 13244  					// code unit is the high surrogate of a surrogate pair
 13245  					output.push(value);
 13246  					counter--;
 13247  				}
 13248  			} else {
 13249  				output.push(value);
 13250  			}
 13251  		}
 13252  		return output;
 13253  	}
 13254  
 13255  	// Taken from https://mths.be/punycode
 13256  	function ucs2encode(array) {
 13257  		var length = array.length;
 13258  		var index = -1;
 13259  		var value;
 13260  		var output = '';
 13261  		while (++index < length) {
 13262  			value = array[index];
 13263  			if (value > 0xFFFF) {
 13264  				value -= 0x10000;
 13265  				output += stringFromCharCode(value >>> 10 & 0x3FF | 0xD800);
 13266  				value = 0xDC00 | value & 0x3FF;
 13267  			}
 13268  			output += stringFromCharCode(value);
 13269  		}
 13270  		return output;
 13271  	}
 13272  
 13273  	function checkScalarValue(codePoint) {
 13274  		if (codePoint >= 0xD800 && codePoint <= 0xDFFF) {
 13275  			throw Error(
 13276  				'Lone surrogate U+' + codePoint.toString(16).toUpperCase() +
 13277  				' is not a scalar value'
 13278  			);
 13279  		}
 13280  	}
 13281  	/*--------------------------------------------------------------------------*/
 13282  
 13283  	function createByte(codePoint, shift) {
 13284  		return stringFromCharCode(((codePoint >> shift) & 0x3F) | 0x80);
 13285  	}
 13286  
 13287  	function encodeCodePoint(codePoint) {
 13288  		if ((codePoint & 0xFFFFFF80) == 0) { // 1-byte sequence
 13289  			return stringFromCharCode(codePoint);
 13290  		}
 13291  		var symbol = '';
 13292  		if ((codePoint & 0xFFFFF800) == 0) { // 2-byte sequence
 13293  			symbol = stringFromCharCode(((codePoint >> 6) & 0x1F) | 0xC0);
 13294  		}
 13295  		else if ((codePoint & 0xFFFF0000) == 0) { // 3-byte sequence
 13296  			checkScalarValue(codePoint);
 13297  			symbol = stringFromCharCode(((codePoint >> 12) & 0x0F) | 0xE0);
 13298  			symbol += createByte(codePoint, 6);
 13299  		}
 13300  		else if ((codePoint & 0xFFE00000) == 0) { // 4-byte sequence
 13301  			symbol = stringFromCharCode(((codePoint >> 18) & 0x07) | 0xF0);
 13302  			symbol += createByte(codePoint, 12);
 13303  			symbol += createByte(codePoint, 6);
 13304  		}
 13305  		symbol += stringFromCharCode((codePoint & 0x3F) | 0x80);
 13306  		return symbol;
 13307  	}
 13308  
 13309  	function utf8encode(string) {
 13310  		var codePoints = ucs2decode(string);
 13311  		var length = codePoints.length;
 13312  		var index = -1;
 13313  		var codePoint;
 13314  		var byteString = '';
 13315  		while (++index < length) {
 13316  			codePoint = codePoints[index];
 13317  			byteString += encodeCodePoint(codePoint);
 13318  		}
 13319  		return byteString;
 13320  	}
 13321  
 13322  	/*--------------------------------------------------------------------------*/
 13323  
 13324  	function readContinuationByte() {
 13325  		if (byteIndex >= byteCount) {
 13326  			throw Error('Invalid byte index');
 13327  		}
 13328  
 13329  		var continuationByte = byteArray[byteIndex] & 0xFF;
 13330  		byteIndex++;
 13331  
 13332  		if ((continuationByte & 0xC0) == 0x80) {
 13333  			return continuationByte & 0x3F;
 13334  		}
 13335  
 13336  		// If we end up here, it’s not a continuation byte
 13337  		throw Error('Invalid continuation byte');
 13338  	}
 13339  
 13340  	function decodeSymbol() {
 13341  		var byte1;
 13342  		var byte2;
 13343  		var byte3;
 13344  		var byte4;
 13345  		var codePoint;
 13346  
 13347  		if (byteIndex > byteCount) {
 13348  			throw Error('Invalid byte index');
 13349  		}
 13350  
 13351  		if (byteIndex == byteCount) {
 13352  			return false;
 13353  		}
 13354  
 13355  		// Read first byte
 13356  		byte1 = byteArray[byteIndex] & 0xFF;
 13357  		byteIndex++;
 13358  
 13359  		// 1-byte sequence (no continuation bytes)
 13360  		if ((byte1 & 0x80) == 0) {
 13361  			return byte1;
 13362  		}
 13363  
 13364  		// 2-byte sequence
 13365  		if ((byte1 & 0xE0) == 0xC0) {
 13366  			byte2 = readContinuationByte();
 13367  			codePoint = ((byte1 & 0x1F) << 6) | byte2;
 13368  			if (codePoint >= 0x80) {
 13369  				return codePoint;
 13370  			} else {
 13371  				throw Error('Invalid continuation byte');
 13372  			}
 13373  		}
 13374  
 13375  		// 3-byte sequence (may include unpaired surrogates)
 13376  		if ((byte1 & 0xF0) == 0xE0) {
 13377  			byte2 = readContinuationByte();
 13378  			byte3 = readContinuationByte();
 13379  			codePoint = ((byte1 & 0x0F) << 12) | (byte2 << 6) | byte3;
 13380  			if (codePoint >= 0x0800) {
 13381  				checkScalarValue(codePoint);
 13382  				return codePoint;
 13383  			} else {
 13384  				throw Error('Invalid continuation byte');
 13385  			}
 13386  		}
 13387  
 13388  		// 4-byte sequence
 13389  		if ((byte1 & 0xF8) == 0xF0) {
 13390  			byte2 = readContinuationByte();
 13391  			byte3 = readContinuationByte();
 13392  			byte4 = readContinuationByte();
 13393  			codePoint = ((byte1 & 0x07) << 0x12) | (byte2 << 0x0C) |
 13394  				(byte3 << 0x06) | byte4;
 13395  			if (codePoint >= 0x010000 && codePoint <= 0x10FFFF) {
 13396  				return codePoint;
 13397  			}
 13398  		}
 13399  
 13400  		throw Error('Invalid UTF-8 detected');
 13401  	}
 13402  
 13403  	var byteArray;
 13404  	var byteCount;
 13405  	var byteIndex;
 13406  	function utf8decode(byteString) {
 13407  		byteArray = ucs2decode(byteString);
 13408  		byteCount = byteArray.length;
 13409  		byteIndex = 0;
 13410  		var codePoints = [];
 13411  		var tmp;
 13412  		while ((tmp = decodeSymbol()) !== false) {
 13413  			codePoints.push(tmp);
 13414  		}
 13415  		return ucs2encode(codePoints);
 13416  	}
 13417  
 13418  	/*--------------------------------------------------------------------------*/
 13419  
 13420  	var utf8 = {
 13421  		'version': '2.1.2',
 13422  		'encode': utf8encode,
 13423  		'decode': utf8decode
 13424  	};
 13425  
 13426  	// Some AMD build optimizers, like r.js, check for specific condition patterns
 13427  	// like the following:
 13428  	if (
 13429  		typeof define == 'function' &&
 13430  		typeof define.amd == 'object' &&
 13431  		define.amd
 13432  	) {
 13433  		define(function() {
 13434  			return utf8;
 13435  		});
 13436  	}	else if (freeExports && !freeExports.nodeType) {
 13437  		if (freeModule) { // in Node.js or RingoJS v0.8.0+
 13438  			freeModule.exports = utf8;
 13439  		} else { // in Narwhal or RingoJS v0.7.0-
 13440  			var object = {};
 13441  			var hasOwnProperty = object.hasOwnProperty;
 13442  			for (var key in utf8) {
 13443  				hasOwnProperty.call(utf8, key) && (freeExports[key] = utf8[key]);
 13444  			}
 13445  		}
 13446  	} else { // in Rhino or a web browser
 13447  		root.utf8 = utf8;
 13448  	}
 13449  
 13450  }(this));
 13451  
 13452  },{}],86:[function(require,module,exports){
 13453  module.exports = XMLHttpRequest;
 13454  
 13455  },{}],"bignumber.js":[function(require,module,exports){
 13456  /*! bignumber.js v2.0.7 https://github.com/MikeMcl/bignumber.js/LICENCE */
 13457  
 13458  ;(function (global) {
 13459      'use strict';
 13460  
 13461      /*
 13462        bignumber.js v2.0.7
 13463        A JavaScript library for arbitrary-precision arithmetic.
 13464        https://github.com/MikeMcl/bignumber.js
 13465        Copyright (c) 2015 Michael Mclaughlin <M8ch88l@gmail.com>
 13466        MIT Expat Licence
 13467      */
 13468  
 13469  
 13470      var BigNumber, crypto, parseNumeric,
 13471          isNumeric = /^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,
 13472          mathceil = Math.ceil,
 13473          mathfloor = Math.floor,
 13474          notBool = ' not a boolean or binary digit',
 13475          roundingMode = 'rounding mode',
 13476          tooManyDigits = 'number type has more than 15 significant digits',
 13477          ALPHABET = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_',
 13478          BASE = 1e14,
 13479          LOG_BASE = 14,
 13480          MAX_SAFE_INTEGER = 0x1fffffffffffff,         // 2^53 - 1
 13481          // MAX_INT32 = 0x7fffffff,                   // 2^31 - 1
 13482          POWS_TEN = [1, 10, 100, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11, 1e12, 1e13],
 13483          SQRT_BASE = 1e7,
 13484  
 13485          /*
 13486           * The limit on the value of DECIMAL_PLACES, TO_EXP_NEG, TO_EXP_POS, MIN_EXP, MAX_EXP, and
 13487           * the arguments to toExponential, toFixed, toFormat, and toPrecision, beyond which an
 13488           * exception is thrown (if ERRORS is true).
 13489           */
 13490          MAX = 1E9;                                   // 0 to MAX_INT32
 13491  
 13492  
 13493      /*
 13494       * Create and return a BigNumber constructor.
 13495       */
 13496      function another(configObj) {
 13497          var div,
 13498  
 13499              // id tracks the caller function, so its name can be included in error messages.
 13500              id = 0,
 13501              P = BigNumber.prototype,
 13502              ONE = new BigNumber(1),
 13503  
 13504  
 13505              /********************************* EDITABLE DEFAULTS **********************************/
 13506  
 13507  
 13508              /*
 13509               * The default values below must be integers within the inclusive ranges stated.
 13510               * The values can also be changed at run-time using BigNumber.config.
 13511               */
 13512  
 13513              // The maximum number of decimal places for operations involving division.
 13514              DECIMAL_PLACES = 20,                     // 0 to MAX
 13515  
 13516              /*
 13517               * The rounding mode used when rounding to the above decimal places, and when using
 13518               * toExponential, toFixed, toFormat and toPrecision, and round (default value).
 13519               * UP         0 Away from zero.
 13520               * DOWN       1 Towards zero.
 13521               * CEIL       2 Towards +Infinity.
 13522               * FLOOR      3 Towards -Infinity.
 13523               * HALF_UP    4 Towards nearest neighbour. If equidistant, up.
 13524               * HALF_DOWN  5 Towards nearest neighbour. If equidistant, down.
 13525               * HALF_EVEN  6 Towards nearest neighbour. If equidistant, towards even neighbour.
 13526               * HALF_CEIL  7 Towards nearest neighbour. If equidistant, towards +Infinity.
 13527               * HALF_FLOOR 8 Towards nearest neighbour. If equidistant, towards -Infinity.
 13528               */
 13529              ROUNDING_MODE = 4,                       // 0 to 8
 13530  
 13531              // EXPONENTIAL_AT : [TO_EXP_NEG , TO_EXP_POS]
 13532  
 13533              // The exponent value at and beneath which toString returns exponential notation.
 13534              // Number type: -7
 13535              TO_EXP_NEG = -7,                         // 0 to -MAX
 13536  
 13537              // The exponent value at and above which toString returns exponential notation.
 13538              // Number type: 21
 13539              TO_EXP_POS = 21,                         // 0 to MAX
 13540  
 13541              // RANGE : [MIN_EXP, MAX_EXP]
 13542  
 13543              // The minimum exponent value, beneath which underflow to zero occurs.
 13544              // Number type: -324  (5e-324)
 13545              MIN_EXP = -1e7,                          // -1 to -MAX
 13546  
 13547              // The maximum exponent value, above which overflow to Infinity occurs.
 13548              // Number type:  308  (1.7976931348623157e+308)
 13549              // For MAX_EXP > 1e7, e.g. new BigNumber('1e100000000').plus(1) may be slow.
 13550              MAX_EXP = 1e7,                           // 1 to MAX
 13551  
 13552              // Whether BigNumber Errors are ever thrown.
 13553              ERRORS = true,                           // true or false
 13554  
 13555              // Change to intValidatorNoErrors if ERRORS is false.
 13556              isValidInt = intValidatorWithErrors,     // intValidatorWithErrors/intValidatorNoErrors
 13557  
 13558              // Whether to use cryptographically-secure random number generation, if available.
 13559              CRYPTO = false,                          // true or false
 13560  
 13561              /*
 13562               * The modulo mode used when calculating the modulus: a mod n.
 13563               * The quotient (q = a / n) is calculated according to the corresponding rounding mode.
 13564               * The remainder (r) is calculated as: r = a - n * q.
 13565               *
 13566               * UP        0 The remainder is positive if the dividend is negative, else is negative.
 13567               * DOWN      1 The remainder has the same sign as the dividend.
 13568               *             This modulo mode is commonly known as 'truncated division' and is
 13569               *             equivalent to (a % n) in JavaScript.
 13570               * FLOOR     3 The remainder has the same sign as the divisor (Python %).
 13571               * HALF_EVEN 6 This modulo mode implements the IEEE 754 remainder function.
 13572               * EUCLID    9 Euclidian division. q = sign(n) * floor(a / abs(n)).
 13573               *             The remainder is always positive.
 13574               *
 13575               * The truncated division, floored division, Euclidian division and IEEE 754 remainder
 13576               * modes are commonly used for the modulus operation.
 13577               * Although the other rounding modes can also be used, they may not give useful results.
 13578               */
 13579              MODULO_MODE = 1,                         // 0 to 9
 13580  
 13581              // The maximum number of significant digits of the result of the toPower operation.
 13582              // If POW_PRECISION is 0, there will be unlimited significant digits.
 13583              POW_PRECISION = 100,                     // 0 to MAX
 13584  
 13585              // The format specification used by the BigNumber.prototype.toFormat method.
 13586              FORMAT = {
 13587                  decimalSeparator: '.',
 13588                  groupSeparator: ',',
 13589                  groupSize: 3,
 13590                  secondaryGroupSize: 0,
 13591                  fractionGroupSeparator: '\xA0',      // non-breaking space
 13592                  fractionGroupSize: 0
 13593              };
 13594  
 13595  
 13596          /******************************************************************************************/
 13597  
 13598  
 13599          // CONSTRUCTOR
 13600  
 13601  
 13602          /*
 13603           * The BigNumber constructor and exported function.
 13604           * Create and return a new instance of a BigNumber object.
 13605           *
 13606           * n {number|string|BigNumber} A numeric value.
 13607           * [b] {number} The base of n. Integer, 2 to 64 inclusive.
 13608           */
 13609          function BigNumber( n, b ) {
 13610              var c, e, i, num, len, str,
 13611                  x = this;
 13612  
 13613              // Enable constructor usage without new.
 13614              if ( !( x instanceof BigNumber ) ) {
 13615  
 13616                  // 'BigNumber() constructor call without new: {n}'
 13617                  if (ERRORS) raise( 26, 'constructor call without new', n );
 13618                  return new BigNumber( n, b );
 13619              }
 13620  
 13621              // 'new BigNumber() base not an integer: {b}'
 13622              // 'new BigNumber() base out of range: {b}'
 13623              if ( b == null || !isValidInt( b, 2, 64, id, 'base' ) ) {
 13624  
 13625                  // Duplicate.
 13626                  if ( n instanceof BigNumber ) {
 13627                      x.s = n.s;
 13628                      x.e = n.e;
 13629                      x.c = ( n = n.c ) ? n.slice() : n;
 13630                      id = 0;
 13631                      return;
 13632                  }
 13633  
 13634                  if ( ( num = typeof n == 'number' ) && n * 0 == 0 ) {
 13635                      x.s = 1 / n < 0 ? ( n = -n, -1 ) : 1;
 13636  
 13637                      // Fast path for integers.
 13638                      if ( n === ~~n ) {
 13639                          for ( e = 0, i = n; i >= 10; i /= 10, e++ );
 13640                          x.e = e;
 13641                          x.c = [n];
 13642                          id = 0;
 13643                          return;
 13644                      }
 13645  
 13646                      str = n + '';
 13647                  } else {
 13648                      if ( !isNumeric.test( str = n + '' ) ) return parseNumeric( x, str, num );
 13649                      x.s = str.charCodeAt(0) === 45 ? ( str = str.slice(1), -1 ) : 1;
 13650                  }
 13651              } else {
 13652                  b = b | 0;
 13653                  str = n + '';
 13654  
 13655                  // Ensure return value is rounded to DECIMAL_PLACES as with other bases.
 13656                  // Allow exponential notation to be used with base 10 argument.
 13657                  if ( b == 10 ) {
 13658                      x = new BigNumber( n instanceof BigNumber ? n : str );
 13659                      return round( x, DECIMAL_PLACES + x.e + 1, ROUNDING_MODE );
 13660                  }
 13661  
 13662                  // Avoid potential interpretation of Infinity and NaN as base 44+ values.
 13663                  // Any number in exponential form will fail due to the [Ee][+-].
 13664                  if ( ( num = typeof n == 'number' ) && n * 0 != 0 ||
 13665                    !( new RegExp( '^-?' + ( c = '[' + ALPHABET.slice( 0, b ) + ']+' ) +
 13666                      '(?:\\.' + c + ')?$',b < 37 ? 'i' : '' ) ).test(str) ) {
 13667                      return parseNumeric( x, str, num, b );
 13668                  }
 13669  
 13670                  if (num) {
 13671                      x.s = 1 / n < 0 ? ( str = str.slice(1), -1 ) : 1;
 13672  
 13673                      if ( ERRORS && str.replace( /^0\.0*|\./, '' ).length > 15 ) {
 13674  
 13675                          // 'new BigNumber() number type has more than 15 significant digits: {n}'
 13676                          raise( id, tooManyDigits, n );
 13677                      }
 13678  
 13679                      // Prevent later check for length on converted number.
 13680                      num = false;
 13681                  } else {
 13682                      x.s = str.charCodeAt(0) === 45 ? ( str = str.slice(1), -1 ) : 1;
 13683                  }
 13684  
 13685                  str = convertBase( str, 10, b, x.s );
 13686              }
 13687  
 13688              // Decimal point?
 13689              if ( ( e = str.indexOf('.') ) > -1 ) str = str.replace( '.', '' );
 13690  
 13691              // Exponential form?
 13692              if ( ( i = str.search( /e/i ) ) > 0 ) {
 13693  
 13694                  // Determine exponent.
 13695                  if ( e < 0 ) e = i;
 13696                  e += +str.slice( i + 1 );
 13697                  str = str.substring( 0, i );
 13698              } else if ( e < 0 ) {
 13699  
 13700                  // Integer.
 13701                  e = str.length;
 13702              }
 13703  
 13704              // Determine leading zeros.
 13705              for ( i = 0; str.charCodeAt(i) === 48; i++ );
 13706  
 13707              // Determine trailing zeros.
 13708              for ( len = str.length; str.charCodeAt(--len) === 48; );
 13709              str = str.slice( i, len + 1 );
 13710  
 13711              if (str) {
 13712                  len = str.length;
 13713  
 13714                  // Disallow numbers with over 15 significant digits if number type.
 13715                  // 'new BigNumber() number type has more than 15 significant digits: {n}'
 13716                  if ( num && ERRORS && len > 15 ) raise( id, tooManyDigits, x.s * n );
 13717  
 13718                  e = e - i - 1;
 13719  
 13720                   // Overflow?
 13721                  if ( e > MAX_EXP ) {
 13722  
 13723                      // Infinity.
 13724                      x.c = x.e = null;
 13725  
 13726                  // Underflow?
 13727                  } else if ( e < MIN_EXP ) {
 13728  
 13729                      // Zero.
 13730                      x.c = [ x.e = 0 ];
 13731                  } else {
 13732                      x.e = e;
 13733                      x.c = [];
 13734  
 13735                      // Transform base
 13736  
 13737                      // e is the base 10 exponent.
 13738                      // i is where to slice str to get the first element of the coefficient array.
 13739                      i = ( e + 1 ) % LOG_BASE;
 13740                      if ( e < 0 ) i += LOG_BASE;
 13741  
 13742                      if ( i < len ) {
 13743                          if (i) x.c.push( +str.slice( 0, i ) );
 13744  
 13745                          for ( len -= LOG_BASE; i < len; ) {
 13746                              x.c.push( +str.slice( i, i += LOG_BASE ) );
 13747                          }
 13748  
 13749                          str = str.slice(i);
 13750                          i = LOG_BASE - str.length;
 13751                      } else {
 13752                          i -= len;
 13753                      }
 13754  
 13755                      for ( ; i--; str += '0' );
 13756                      x.c.push( +str );
 13757                  }
 13758              } else {
 13759  
 13760                  // Zero.
 13761                  x.c = [ x.e = 0 ];
 13762              }
 13763  
 13764              id = 0;
 13765          }
 13766  
 13767  
 13768          // CONSTRUCTOR PROPERTIES
 13769  
 13770  
 13771          BigNumber.another = another;
 13772  
 13773          BigNumber.ROUND_UP = 0;
 13774          BigNumber.ROUND_DOWN = 1;
 13775          BigNumber.ROUND_CEIL = 2;
 13776          BigNumber.ROUND_FLOOR = 3;
 13777          BigNumber.ROUND_HALF_UP = 4;
 13778          BigNumber.ROUND_HALF_DOWN = 5;
 13779          BigNumber.ROUND_HALF_EVEN = 6;
 13780          BigNumber.ROUND_HALF_CEIL = 7;
 13781          BigNumber.ROUND_HALF_FLOOR = 8;
 13782          BigNumber.EUCLID = 9;
 13783  
 13784  
 13785          /*
 13786           * Configure infrequently-changing library-wide settings.
 13787           *
 13788           * Accept an object or an argument list, with one or many of the following properties or
 13789           * parameters respectively:
 13790           *
 13791           *   DECIMAL_PLACES  {number}  Integer, 0 to MAX inclusive
 13792           *   ROUNDING_MODE   {number}  Integer, 0 to 8 inclusive
 13793           *   EXPONENTIAL_AT  {number|number[]}  Integer, -MAX to MAX inclusive or
 13794           *                                      [integer -MAX to 0 incl., 0 to MAX incl.]
 13795           *   RANGE           {number|number[]}  Non-zero integer, -MAX to MAX inclusive or
 13796           *                                      [integer -MAX to -1 incl., integer 1 to MAX incl.]
 13797           *   ERRORS          {boolean|number}   true, false, 1 or 0
 13798           *   CRYPTO          {boolean|number}   true, false, 1 or 0
 13799           *   MODULO_MODE     {number}           0 to 9 inclusive
 13800           *   POW_PRECISION   {number}           0 to MAX inclusive
 13801           *   FORMAT          {object}           See BigNumber.prototype.toFormat
 13802           *      decimalSeparator       {string}
 13803           *      groupSeparator         {string}
 13804           *      groupSize              {number}
 13805           *      secondaryGroupSize     {number}
 13806           *      fractionGroupSeparator {string}
 13807           *      fractionGroupSize      {number}
 13808           *
 13809           * (The values assigned to the above FORMAT object properties are not checked for validity.)
 13810           *
 13811           * E.g.
 13812           * BigNumber.config(20, 4) is equivalent to
 13813           * BigNumber.config({ DECIMAL_PLACES : 20, ROUNDING_MODE : 4 })
 13814           *
 13815           * Ignore properties/parameters set to null or undefined.
 13816           * Return an object with the properties current values.
 13817           */
 13818          BigNumber.config = function () {
 13819              var v, p,
 13820                  i = 0,
 13821                  r = {},
 13822                  a = arguments,
 13823                  o = a[0],
 13824                  has = o && typeof o == 'object'
 13825                    ? function () { if ( o.hasOwnProperty(p) ) return ( v = o[p] ) != null; }
 13826                    : function () { if ( a.length > i ) return ( v = a[i++] ) != null; };
 13827  
 13828              // DECIMAL_PLACES {number} Integer, 0 to MAX inclusive.
 13829              // 'config() DECIMAL_PLACES not an integer: {v}'
 13830              // 'config() DECIMAL_PLACES out of range: {v}'
 13831              if ( has( p = 'DECIMAL_PLACES' ) && isValidInt( v, 0, MAX, 2, p ) ) {
 13832                  DECIMAL_PLACES = v | 0;
 13833              }
 13834              r[p] = DECIMAL_PLACES;
 13835  
 13836              // ROUNDING_MODE {number} Integer, 0 to 8 inclusive.
 13837              // 'config() ROUNDING_MODE not an integer: {v}'
 13838              // 'config() ROUNDING_MODE out of range: {v}'
 13839              if ( has( p = 'ROUNDING_MODE' ) && isValidInt( v, 0, 8, 2, p ) ) {
 13840                  ROUNDING_MODE = v | 0;
 13841              }
 13842              r[p] = ROUNDING_MODE;
 13843  
 13844              // EXPONENTIAL_AT {number|number[]}
 13845              // Integer, -MAX to MAX inclusive or [integer -MAX to 0 inclusive, 0 to MAX inclusive].
 13846              // 'config() EXPONENTIAL_AT not an integer: {v}'
 13847              // 'config() EXPONENTIAL_AT out of range: {v}'
 13848              if ( has( p = 'EXPONENTIAL_AT' ) ) {
 13849  
 13850                  if ( isArray(v) ) {
 13851                      if ( isValidInt( v[0], -MAX, 0, 2, p ) && isValidInt( v[1], 0, MAX, 2, p ) ) {
 13852                          TO_EXP_NEG = v[0] | 0;
 13853                          TO_EXP_POS = v[1] | 0;
 13854                      }
 13855                  } else if ( isValidInt( v, -MAX, MAX, 2, p ) ) {
 13856                      TO_EXP_NEG = -( TO_EXP_POS = ( v < 0 ? -v : v ) | 0 );
 13857                  }
 13858              }
 13859              r[p] = [ TO_EXP_NEG, TO_EXP_POS ];
 13860  
 13861              // RANGE {number|number[]} Non-zero integer, -MAX to MAX inclusive or
 13862              // [integer -MAX to -1 inclusive, integer 1 to MAX inclusive].
 13863              // 'config() RANGE not an integer: {v}'
 13864              // 'config() RANGE cannot be zero: {v}'
 13865              // 'config() RANGE out of range: {v}'
 13866              if ( has( p = 'RANGE' ) ) {
 13867  
 13868                  if ( isArray(v) ) {
 13869                      if ( isValidInt( v[0], -MAX, -1, 2, p ) && isValidInt( v[1], 1, MAX, 2, p ) ) {
 13870                          MIN_EXP = v[0] | 0;
 13871                          MAX_EXP = v[1] | 0;
 13872                      }
 13873                  } else if ( isValidInt( v, -MAX, MAX, 2, p ) ) {
 13874                      if ( v | 0 ) MIN_EXP = -( MAX_EXP = ( v < 0 ? -v : v ) | 0 );
 13875                      else if (ERRORS) raise( 2, p + ' cannot be zero', v );
 13876                  }
 13877              }
 13878              r[p] = [ MIN_EXP, MAX_EXP ];
 13879  
 13880              // ERRORS {boolean|number} true, false, 1 or 0.
 13881              // 'config() ERRORS not a boolean or binary digit: {v}'
 13882              if ( has( p = 'ERRORS' ) ) {
 13883  
 13884                  if ( v === !!v || v === 1 || v === 0 ) {
 13885                      id = 0;
 13886                      isValidInt = ( ERRORS = !!v ) ? intValidatorWithErrors : intValidatorNoErrors;
 13887                  } else if (ERRORS) {
 13888                      raise( 2, p + notBool, v );
 13889                  }
 13890              }
 13891              r[p] = ERRORS;
 13892  
 13893              // CRYPTO {boolean|number} true, false, 1 or 0.
 13894              // 'config() CRYPTO not a boolean or binary digit: {v}'
 13895              // 'config() crypto unavailable: {crypto}'
 13896              if ( has( p = 'CRYPTO' ) ) {
 13897  
 13898                  if ( v === !!v || v === 1 || v === 0 ) {
 13899                      CRYPTO = !!( v && crypto && typeof crypto == 'object' );
 13900                      if ( v && !CRYPTO && ERRORS ) raise( 2, 'crypto unavailable', crypto );
 13901                  } else if (ERRORS) {
 13902                      raise( 2, p + notBool, v );
 13903                  }
 13904              }
 13905              r[p] = CRYPTO;
 13906  
 13907              // MODULO_MODE {number} Integer, 0 to 9 inclusive.
 13908              // 'config() MODULO_MODE not an integer: {v}'
 13909              // 'config() MODULO_MODE out of range: {v}'
 13910              if ( has( p = 'MODULO_MODE' ) && isValidInt( v, 0, 9, 2, p ) ) {
 13911                  MODULO_MODE = v | 0;
 13912              }
 13913              r[p] = MODULO_MODE;
 13914  
 13915              // POW_PRECISION {number} Integer, 0 to MAX inclusive.
 13916              // 'config() POW_PRECISION not an integer: {v}'
 13917              // 'config() POW_PRECISION out of range: {v}'
 13918              if ( has( p = 'POW_PRECISION' ) && isValidInt( v, 0, MAX, 2, p ) ) {
 13919                  POW_PRECISION = v | 0;
 13920              }
 13921              r[p] = POW_PRECISION;
 13922  
 13923              // FORMAT {object}
 13924              // 'config() FORMAT not an object: {v}'
 13925              if ( has( p = 'FORMAT' ) ) {
 13926  
 13927                  if ( typeof v == 'object' ) {
 13928                      FORMAT = v;
 13929                  } else if (ERRORS) {
 13930                      raise( 2, p + ' not an object', v );
 13931                  }
 13932              }
 13933              r[p] = FORMAT;
 13934  
 13935              return r;
 13936          };
 13937  
 13938  
 13939          /*
 13940           * Return a new BigNumber whose value is the maximum of the arguments.
 13941           *
 13942           * arguments {number|string|BigNumber}
 13943           */
 13944          BigNumber.max = function () { return maxOrMin( arguments, P.lt ); };
 13945  
 13946  
 13947          /*
 13948           * Return a new BigNumber whose value is the minimum of the arguments.
 13949           *
 13950           * arguments {number|string|BigNumber}
 13951           */
 13952          BigNumber.min = function () { return maxOrMin( arguments, P.gt ); };
 13953  
 13954  
 13955          /*
 13956           * Return a new BigNumber with a random value equal to or greater than 0 and less than 1,
 13957           * and with dp, or DECIMAL_PLACES if dp is omitted, decimal places (or less if trailing
 13958           * zeros are produced).
 13959           *
 13960           * [dp] {number} Decimal places. Integer, 0 to MAX inclusive.
 13961           *
 13962           * 'random() decimal places not an integer: {dp}'
 13963           * 'random() decimal places out of range: {dp}'
 13964           * 'random() crypto unavailable: {crypto}'
 13965           */
 13966          BigNumber.random = (function () {
 13967              var pow2_53 = 0x20000000000000;
 13968  
 13969              // Return a 53 bit integer n, where 0 <= n < 9007199254740992.
 13970              // Check if Math.random() produces more than 32 bits of randomness.
 13971              // If it does, assume at least 53 bits are produced, otherwise assume at least 30 bits.
 13972              // 0x40000000 is 2^30, 0x800000 is 2^23, 0x1fffff is 2^21 - 1.
 13973              var random53bitInt = (Math.random() * pow2_53) & 0x1fffff
 13974                ? function () { return mathfloor( Math.random() * pow2_53 ); }
 13975                : function () { return ((Math.random() * 0x40000000 | 0) * 0x800000) +
 13976                    (Math.random() * 0x800000 | 0); };
 13977  
 13978              return function (dp) {
 13979                  var a, b, e, k, v,
 13980                      i = 0,
 13981                      c = [],
 13982                      rand = new BigNumber(ONE);
 13983  
 13984                  dp = dp == null || !isValidInt( dp, 0, MAX, 14 ) ? DECIMAL_PLACES : dp | 0;
 13985                  k = mathceil( dp / LOG_BASE );
 13986  
 13987                  if (CRYPTO) {
 13988  
 13989                      // Browsers supporting crypto.getRandomValues.
 13990                      if ( crypto && crypto.getRandomValues ) {
 13991  
 13992                          a = crypto.getRandomValues( new Uint32Array( k *= 2 ) );
 13993  
 13994                          for ( ; i < k; ) {
 13995  
 13996                              // 53 bits:
 13997                              // ((Math.pow(2, 32) - 1) * Math.pow(2, 21)).toString(2)
 13998                              // 11111 11111111 11111111 11111111 11100000 00000000 00000000
 13999                              // ((Math.pow(2, 32) - 1) >>> 11).toString(2)
 14000                              //                                     11111 11111111 11111111
 14001                              // 0x20000 is 2^21.
 14002                              v = a[i] * 0x20000 + (a[i + 1] >>> 11);
 14003  
 14004                              // Rejection sampling:
 14005                              // 0 <= v < 9007199254740992
 14006                              // Probability that v >= 9e15, is
 14007                              // 7199254740992 / 9007199254740992 ~= 0.0008, i.e. 1 in 1251
 14008                              if ( v >= 9e15 ) {
 14009                                  b = crypto.getRandomValues( new Uint32Array(2) );
 14010                                  a[i] = b[0];
 14011                                  a[i + 1] = b[1];
 14012                              } else {
 14013  
 14014                                  // 0 <= v <= 8999999999999999
 14015                                  // 0 <= (v % 1e14) <= 99999999999999
 14016                                  c.push( v % 1e14 );
 14017                                  i += 2;
 14018                              }
 14019                          }
 14020                          i = k / 2;
 14021  
 14022                      // Node.js supporting crypto.randomBytes.
 14023                      } else if ( crypto && crypto.randomBytes ) {
 14024  
 14025                          // buffer
 14026                          a = crypto.randomBytes( k *= 7 );
 14027  
 14028                          for ( ; i < k; ) {
 14029  
 14030                              // 0x1000000000000 is 2^48, 0x10000000000 is 2^40
 14031                              // 0x100000000 is 2^32, 0x1000000 is 2^24
 14032                              // 11111 11111111 11111111 11111111 11111111 11111111 11111111
 14033                              // 0 <= v < 9007199254740992
 14034                              v = ( ( a[i] & 31 ) * 0x1000000000000 ) + ( a[i + 1] * 0x10000000000 ) +
 14035                                    ( a[i + 2] * 0x100000000 ) + ( a[i + 3] * 0x1000000 ) +
 14036                                    ( a[i + 4] << 16 ) + ( a[i + 5] << 8 ) + a[i + 6];
 14037  
 14038                              if ( v >= 9e15 ) {
 14039                                  crypto.randomBytes(7).copy( a, i );
 14040                              } else {
 14041  
 14042                                  // 0 <= (v % 1e14) <= 99999999999999
 14043                                  c.push( v % 1e14 );
 14044                                  i += 7;
 14045                              }
 14046                          }
 14047                          i = k / 7;
 14048                      } else if (ERRORS) {
 14049                          raise( 14, 'crypto unavailable', crypto );
 14050                      }
 14051                  }
 14052  
 14053                  // Use Math.random: CRYPTO is false or crypto is unavailable and ERRORS is false.
 14054                  if (!i) {
 14055  
 14056                      for ( ; i < k; ) {
 14057                          v = random53bitInt();
 14058                          if ( v < 9e15 ) c[i++] = v % 1e14;
 14059                      }
 14060                  }
 14061  
 14062                  k = c[--i];
 14063                  dp %= LOG_BASE;
 14064  
 14065                  // Convert trailing digits to zeros according to dp.
 14066                  if ( k && dp ) {
 14067                      v = POWS_TEN[LOG_BASE - dp];
 14068                      c[i] = mathfloor( k / v ) * v;
 14069                  }
 14070  
 14071                  // Remove trailing elements which are zero.
 14072                  for ( ; c[i] === 0; c.pop(), i-- );
 14073  
 14074                  // Zero?
 14075                  if ( i < 0 ) {
 14076                      c = [ e = 0 ];
 14077                  } else {
 14078  
 14079                      // Remove leading elements which are zero and adjust exponent accordingly.
 14080                      for ( e = -1 ; c[0] === 0; c.shift(), e -= LOG_BASE);
 14081  
 14082                      // Count the digits of the first element of c to determine leading zeros, and...
 14083                      for ( i = 1, v = c[0]; v >= 10; v /= 10, i++);
 14084  
 14085                      // adjust the exponent accordingly.
 14086                      if ( i < LOG_BASE ) e -= LOG_BASE - i;
 14087                  }
 14088  
 14089                  rand.e = e;
 14090                  rand.c = c;
 14091                  return rand;
 14092              };
 14093          })();
 14094  
 14095  
 14096          // PRIVATE FUNCTIONS
 14097  
 14098  
 14099          // Convert a numeric string of baseIn to a numeric string of baseOut.
 14100          function convertBase( str, baseOut, baseIn, sign ) {
 14101              var d, e, k, r, x, xc, y,
 14102                  i = str.indexOf( '.' ),
 14103                  dp = DECIMAL_PLACES,
 14104                  rm = ROUNDING_MODE;
 14105  
 14106              if ( baseIn < 37 ) str = str.toLowerCase();
 14107  
 14108              // Non-integer.
 14109              if ( i >= 0 ) {
 14110                  k = POW_PRECISION;
 14111  
 14112                  // Unlimited precision.
 14113                  POW_PRECISION = 0;
 14114                  str = str.replace( '.', '' );
 14115                  y = new BigNumber(baseIn);
 14116                  x = y.pow( str.length - i );
 14117                  POW_PRECISION = k;
 14118  
 14119                  // Convert str as if an integer, then restore the fraction part by dividing the
 14120                  // result by its base raised to a power.
 14121                  y.c = toBaseOut( toFixedPoint( coeffToString( x.c ), x.e ), 10, baseOut );
 14122                  y.e = y.c.length;
 14123              }
 14124  
 14125              // Convert the number as integer.
 14126              xc = toBaseOut( str, baseIn, baseOut );
 14127              e = k = xc.length;
 14128  
 14129              // Remove trailing zeros.
 14130              for ( ; xc[--k] == 0; xc.pop() );
 14131              if ( !xc[0] ) return '0';
 14132  
 14133              if ( i < 0 ) {
 14134                  --e;
 14135              } else {
 14136                  x.c = xc;
 14137                  x.e = e;
 14138  
 14139                  // sign is needed for correct rounding.
 14140                  x.s = sign;
 14141                  x = div( x, y, dp, rm, baseOut );
 14142                  xc = x.c;
 14143                  r = x.r;
 14144                  e = x.e;
 14145              }
 14146  
 14147              d = e + dp + 1;
 14148  
 14149              // The rounding digit, i.e. the digit to the right of the digit that may be rounded up.
 14150              i = xc[d];
 14151              k = baseOut / 2;
 14152              r = r || d < 0 || xc[d + 1] != null;
 14153  
 14154              r = rm < 4 ? ( i != null || r ) && ( rm == 0 || rm == ( x.s < 0 ? 3 : 2 ) )
 14155                         : i > k || i == k &&( rm == 4 || r || rm == 6 && xc[d - 1] & 1 ||
 14156                           rm == ( x.s < 0 ? 8 : 7 ) );
 14157  
 14158              if ( d < 1 || !xc[0] ) {
 14159  
 14160                  // 1^-dp or 0.
 14161                  str = r ? toFixedPoint( '1', -dp ) : '0';
 14162              } else {
 14163                  xc.length = d;
 14164  
 14165                  if (r) {
 14166  
 14167                      // Rounding up may mean the previous digit has to be rounded up and so on.
 14168                      for ( --baseOut; ++xc[--d] > baseOut; ) {
 14169                          xc[d] = 0;
 14170  
 14171                          if ( !d ) {
 14172                              ++e;
 14173                              xc.unshift(1);
 14174                          }
 14175                      }
 14176                  }
 14177  
 14178                  // Determine trailing zeros.
 14179                  for ( k = xc.length; !xc[--k]; );
 14180  
 14181                  // E.g. [4, 11, 15] becomes 4bf.
 14182                  for ( i = 0, str = ''; i <= k; str += ALPHABET.charAt( xc[i++] ) );
 14183                  str = toFixedPoint( str, e );
 14184              }
 14185  
 14186              // The caller will add the sign.
 14187              return str;
 14188          }
 14189  
 14190  
 14191          // Perform division in the specified base. Called by div and convertBase.
 14192          div = (function () {
 14193  
 14194              // Assume non-zero x and k.
 14195              function multiply( x, k, base ) {
 14196                  var m, temp, xlo, xhi,
 14197                      carry = 0,
 14198                      i = x.length,
 14199                      klo = k % SQRT_BASE,
 14200                      khi = k / SQRT_BASE | 0;
 14201  
 14202                  for ( x = x.slice(); i--; ) {
 14203                      xlo = x[i] % SQRT_BASE;
 14204                      xhi = x[i] / SQRT_BASE | 0;
 14205                      m = khi * xlo + xhi * klo;
 14206                      temp = klo * xlo + ( ( m % SQRT_BASE ) * SQRT_BASE ) + carry;
 14207                      carry = ( temp / base | 0 ) + ( m / SQRT_BASE | 0 ) + khi * xhi;
 14208                      x[i] = temp % base;
 14209                  }
 14210  
 14211                  if (carry) x.unshift(carry);
 14212  
 14213                  return x;
 14214              }
 14215  
 14216              function compare( a, b, aL, bL ) {
 14217                  var i, cmp;
 14218  
 14219                  if ( aL != bL ) {
 14220                      cmp = aL > bL ? 1 : -1;
 14221                  } else {
 14222  
 14223                      for ( i = cmp = 0; i < aL; i++ ) {
 14224  
 14225                          if ( a[i] != b[i] ) {
 14226                              cmp = a[i] > b[i] ? 1 : -1;
 14227                              break;
 14228                          }
 14229                      }
 14230                  }
 14231                  return cmp;
 14232              }
 14233  
 14234              function subtract( a, b, aL, base ) {
 14235                  var i = 0;
 14236  
 14237                  // Subtract b from a.
 14238                  for ( ; aL--; ) {
 14239                      a[aL] -= i;
 14240                      i = a[aL] < b[aL] ? 1 : 0;
 14241                      a[aL] = i * base + a[aL] - b[aL];
 14242                  }
 14243  
 14244                  // Remove leading zeros.
 14245                  for ( ; !a[0] && a.length > 1; a.shift() );
 14246              }
 14247  
 14248              // x: dividend, y: divisor.
 14249              return function ( x, y, dp, rm, base ) {
 14250                  var cmp, e, i, more, n, prod, prodL, q, qc, rem, remL, rem0, xi, xL, yc0,
 14251                      yL, yz,
 14252                      s = x.s == y.s ? 1 : -1,
 14253                      xc = x.c,
 14254                      yc = y.c;
 14255  
 14256                  // Either NaN, Infinity or 0?
 14257                  if ( !xc || !xc[0] || !yc || !yc[0] ) {
 14258  
 14259                      return new BigNumber(
 14260  
 14261                        // Return NaN if either NaN, or both Infinity or 0.
 14262                        !x.s || !y.s || ( xc ? yc && xc[0] == yc[0] : !yc ) ? NaN :
 14263  
 14264                          // Return ±0 if x is ±0 or y is ±Infinity, or return ±Infinity as y is ±0.
 14265                          xc && xc[0] == 0 || !yc ? s * 0 : s / 0
 14266                      );
 14267                  }
 14268  
 14269                  q = new BigNumber(s);
 14270                  qc = q.c = [];
 14271                  e = x.e - y.e;
 14272                  s = dp + e + 1;
 14273  
 14274                  if ( !base ) {
 14275                      base = BASE;
 14276                      e = bitFloor( x.e / LOG_BASE ) - bitFloor( y.e / LOG_BASE );
 14277                      s = s / LOG_BASE | 0;
 14278                  }
 14279  
 14280                  // Result exponent may be one less then the current value of e.
 14281                  // The coefficients of the BigNumbers from convertBase may have trailing zeros.
 14282                  for ( i = 0; yc[i] == ( xc[i] || 0 ); i++ );
 14283                  if ( yc[i] > ( xc[i] || 0 ) ) e--;
 14284  
 14285                  if ( s < 0 ) {
 14286                      qc.push(1);
 14287                      more = true;
 14288                  } else {
 14289                      xL = xc.length;
 14290                      yL = yc.length;
 14291                      i = 0;
 14292                      s += 2;
 14293  
 14294                      // Normalise xc and yc so highest order digit of yc is >= base / 2.
 14295  
 14296                      n = mathfloor( base / ( yc[0] + 1 ) );
 14297  
 14298                      // Not necessary, but to handle odd bases where yc[0] == ( base / 2 ) - 1.
 14299                      // if ( n > 1 || n++ == 1 && yc[0] < base / 2 ) {
 14300                      if ( n > 1 ) {
 14301                          yc = multiply( yc, n, base );
 14302                          xc = multiply( xc, n, base );
 14303                          yL = yc.length;
 14304                          xL = xc.length;
 14305                      }
 14306  
 14307                      xi = yL;
 14308                      rem = xc.slice( 0, yL );
 14309                      remL = rem.length;
 14310  
 14311                      // Add zeros to make remainder as long as divisor.
 14312                      for ( ; remL < yL; rem[remL++] = 0 );
 14313                      yz = yc.slice();
 14314                      yz.unshift(0);
 14315                      yc0 = yc[0];
 14316                      if ( yc[1] >= base / 2 ) yc0++;
 14317                      // Not necessary, but to prevent trial digit n > base, when using base 3.
 14318                      // else if ( base == 3 && yc0 == 1 ) yc0 = 1 + 1e-15;
 14319  
 14320                      do {
 14321                          n = 0;
 14322  
 14323                          // Compare divisor and remainder.
 14324                          cmp = compare( yc, rem, yL, remL );
 14325  
 14326                          // If divisor < remainder.
 14327                          if ( cmp < 0 ) {
 14328  
 14329                              // Calculate trial digit, n.
 14330  
 14331                              rem0 = rem[0];
 14332                              if ( yL != remL ) rem0 = rem0 * base + ( rem[1] || 0 );
 14333  
 14334                              // n is how many times the divisor goes into the current remainder.
 14335                              n = mathfloor( rem0 / yc0 );
 14336  
 14337                              //  Algorithm:
 14338                              //  1. product = divisor * trial digit (n)
 14339                              //  2. if product > remainder: product -= divisor, n--
 14340                              //  3. remainder -= product
 14341                              //  4. if product was < remainder at 2:
 14342                              //    5. compare new remainder and divisor
 14343                              //    6. If remainder > divisor: remainder -= divisor, n++
 14344  
 14345                              if ( n > 1 ) {
 14346  
 14347                                  // n may be > base only when base is 3.
 14348                                  if (n >= base) n = base - 1;
 14349  
 14350                                  // product = divisor * trial digit.
 14351                                  prod = multiply( yc, n, base );
 14352                                  prodL = prod.length;
 14353                                  remL = rem.length;
 14354  
 14355                                  // Compare product and remainder.
 14356                                  // If product > remainder.
 14357                                  // Trial digit n too high.
 14358                                  // n is 1 too high about 5% of the time, and is not known to have
 14359                                  // ever been more than 1 too high.
 14360                                  while ( compare( prod, rem, prodL, remL ) == 1 ) {
 14361                                      n--;
 14362  
 14363                                      // Subtract divisor from product.
 14364                                      subtract( prod, yL < prodL ? yz : yc, prodL, base );
 14365                                      prodL = prod.length;
 14366                                      cmp = 1;
 14367                                  }
 14368                              } else {
 14369  
 14370                                  // n is 0 or 1, cmp is -1.
 14371                                  // If n is 0, there is no need to compare yc and rem again below,
 14372                                  // so change cmp to 1 to avoid it.
 14373                                  // If n is 1, leave cmp as -1, so yc and rem are compared again.
 14374                                  if ( n == 0 ) {
 14375  
 14376                                      // divisor < remainder, so n must be at least 1.
 14377                                      cmp = n = 1;
 14378                                  }
 14379  
 14380                                  // product = divisor
 14381                                  prod = yc.slice();
 14382                                  prodL = prod.length;
 14383                              }
 14384  
 14385                              if ( prodL < remL ) prod.unshift(0);
 14386  
 14387                              // Subtract product from remainder.
 14388                              subtract( rem, prod, remL, base );
 14389                              remL = rem.length;
 14390  
 14391                               // If product was < remainder.
 14392                              if ( cmp == -1 ) {
 14393  
 14394                                  // Compare divisor and new remainder.
 14395                                  // If divisor < new remainder, subtract divisor from remainder.
 14396                                  // Trial digit n too low.
 14397                                  // n is 1 too low about 5% of the time, and very rarely 2 too low.
 14398                                  while ( compare( yc, rem, yL, remL ) < 1 ) {
 14399                                      n++;
 14400  
 14401                                      // Subtract divisor from remainder.
 14402                                      subtract( rem, yL < remL ? yz : yc, remL, base );
 14403                                      remL = rem.length;
 14404                                  }
 14405                              }
 14406                          } else if ( cmp === 0 ) {
 14407                              n++;
 14408                              rem = [0];
 14409                          } // else cmp === 1 and n will be 0
 14410  
 14411                          // Add the next digit, n, to the result array.
 14412                          qc[i++] = n;
 14413  
 14414                          // Update the remainder.
 14415                          if ( rem[0] ) {
 14416                              rem[remL++] = xc[xi] || 0;
 14417                          } else {
 14418                              rem = [ xc[xi] ];
 14419                              remL = 1;
 14420                          }
 14421                      } while ( ( xi++ < xL || rem[0] != null ) && s-- );
 14422  
 14423                      more = rem[0] != null;
 14424  
 14425                      // Leading zero?
 14426                      if ( !qc[0] ) qc.shift();
 14427                  }
 14428  
 14429                  if ( base == BASE ) {
 14430  
 14431                      // To calculate q.e, first get the number of digits of qc[0].
 14432                      for ( i = 1, s = qc[0]; s >= 10; s /= 10, i++ );
 14433                      round( q, dp + ( q.e = i + e * LOG_BASE - 1 ) + 1, rm, more );
 14434  
 14435                  // Caller is convertBase.
 14436                  } else {
 14437                      q.e = e;
 14438                      q.r = +more;
 14439                  }
 14440  
 14441                  return q;
 14442              };
 14443          })();
 14444  
 14445  
 14446          /*
 14447           * Return a string representing the value of BigNumber n in fixed-point or exponential
 14448           * notation rounded to the specified decimal places or significant digits.
 14449           *
 14450           * n is a BigNumber.
 14451           * i is the index of the last digit required (i.e. the digit that may be rounded up).
 14452           * rm is the rounding mode.
 14453           * caller is caller id: toExponential 19, toFixed 20, toFormat 21, toPrecision 24.
 14454           */
 14455          function format( n, i, rm, caller ) {
 14456              var c0, e, ne, len, str;
 14457  
 14458              rm = rm != null && isValidInt( rm, 0, 8, caller, roundingMode )
 14459                ? rm | 0 : ROUNDING_MODE;
 14460  
 14461              if ( !n.c ) return n.toString();
 14462              c0 = n.c[0];
 14463              ne = n.e;
 14464  
 14465              if ( i == null ) {
 14466                  str = coeffToString( n.c );
 14467                  str = caller == 19 || caller == 24 && ne <= TO_EXP_NEG
 14468                    ? toExponential( str, ne )
 14469                    : toFixedPoint( str, ne );
 14470              } else {
 14471                  n = round( new BigNumber(n), i, rm );
 14472  
 14473                  // n.e may have changed if the value was rounded up.
 14474                  e = n.e;
 14475  
 14476                  str = coeffToString( n.c );
 14477                  len = str.length;
 14478  
 14479                  // toPrecision returns exponential notation if the number of significant digits
 14480                  // specified is less than the number of digits necessary to represent the integer
 14481                  // part of the value in fixed-point notation.
 14482  
 14483                  // Exponential notation.
 14484                  if ( caller == 19 || caller == 24 && ( i <= e || e <= TO_EXP_NEG ) ) {
 14485  
 14486                      // Append zeros?
 14487                      for ( ; len < i; str += '0', len++ );
 14488                      str = toExponential( str, e );
 14489  
 14490                  // Fixed-point notation.
 14491                  } else {
 14492                      i -= ne;
 14493                      str = toFixedPoint( str, e );
 14494  
 14495                      // Append zeros?
 14496                      if ( e + 1 > len ) {
 14497                          if ( --i > 0 ) for ( str += '.'; i--; str += '0' );
 14498                      } else {
 14499                          i += e - len;
 14500                          if ( i > 0 ) {
 14501                              if ( e + 1 == len ) str += '.';
 14502                              for ( ; i--; str += '0' );
 14503                          }
 14504                      }
 14505                  }
 14506              }
 14507  
 14508              return n.s < 0 && c0 ? '-' + str : str;
 14509          }
 14510  
 14511  
 14512          // Handle BigNumber.max and BigNumber.min.
 14513          function maxOrMin( args, method ) {
 14514              var m, n,
 14515                  i = 0;
 14516  
 14517              if ( isArray( args[0] ) ) args = args[0];
 14518              m = new BigNumber( args[0] );
 14519  
 14520              for ( ; ++i < args.length; ) {
 14521                  n = new BigNumber( args[i] );
 14522  
 14523                  // If any number is NaN, return NaN.
 14524                  if ( !n.s ) {
 14525                      m = n;
 14526                      break;
 14527                  } else if ( method.call( m, n ) ) {
 14528                      m = n;
 14529                  }
 14530              }
 14531  
 14532              return m;
 14533          }
 14534  
 14535  
 14536          /*
 14537           * Return true if n is an integer in range, otherwise throw.
 14538           * Use for argument validation when ERRORS is true.
 14539           */
 14540          function intValidatorWithErrors( n, min, max, caller, name ) {
 14541              if ( n < min || n > max || n != truncate(n) ) {
 14542                  raise( caller, ( name || 'decimal places' ) +
 14543                    ( n < min || n > max ? ' out of range' : ' not an integer' ), n );
 14544              }
 14545  
 14546              return true;
 14547          }
 14548  
 14549  
 14550          /*
 14551           * Strip trailing zeros, calculate base 10 exponent and check against MIN_EXP and MAX_EXP.
 14552           * Called by minus, plus and times.
 14553           */
 14554          function normalise( n, c, e ) {
 14555              var i = 1,
 14556                  j = c.length;
 14557  
 14558               // Remove trailing zeros.
 14559              for ( ; !c[--j]; c.pop() );
 14560  
 14561              // Calculate the base 10 exponent. First get the number of digits of c[0].
 14562              for ( j = c[0]; j >= 10; j /= 10, i++ );
 14563  
 14564              // Overflow?
 14565              if ( ( e = i + e * LOG_BASE - 1 ) > MAX_EXP ) {
 14566  
 14567                  // Infinity.
 14568                  n.c = n.e = null;
 14569  
 14570              // Underflow?
 14571              } else if ( e < MIN_EXP ) {
 14572  
 14573                  // Zero.
 14574                  n.c = [ n.e = 0 ];
 14575              } else {
 14576                  n.e = e;
 14577                  n.c = c;
 14578              }
 14579  
 14580              return n;
 14581          }
 14582  
 14583  
 14584          // Handle values that fail the validity test in BigNumber.
 14585          parseNumeric = (function () {
 14586              var basePrefix = /^(-?)0([xbo])/i,
 14587                  dotAfter = /^([^.]+)\.$/,
 14588                  dotBefore = /^\.([^.]+)$/,
 14589                  isInfinityOrNaN = /^-?(Infinity|NaN)$/,
 14590                  whitespaceOrPlus = /^\s*\+|^\s+|\s+$/g;
 14591  
 14592              return function ( x, str, num, b ) {
 14593                  var base,
 14594                      s = num ? str : str.replace( whitespaceOrPlus, '' );
 14595  
 14596                  // No exception on ±Infinity or NaN.
 14597                  if ( isInfinityOrNaN.test(s) ) {
 14598                      x.s = isNaN(s) ? null : s < 0 ? -1 : 1;
 14599                  } else {
 14600                      if ( !num ) {
 14601  
 14602                          // basePrefix = /^(-?)0([xbo])(?=\w[\w.]*$)/i
 14603                          s = s.replace( basePrefix, function ( m, p1, p2 ) {
 14604                              base = ( p2 = p2.toLowerCase() ) == 'x' ? 16 : p2 == 'b' ? 2 : 8;
 14605                              return !b || b == base ? p1 : m;
 14606                          });
 14607  
 14608                          if (b) {
 14609                              base = b;
 14610  
 14611                              // E.g. '1.' to '1', '.1' to '0.1'
 14612                              s = s.replace( dotAfter, '$1' ).replace( dotBefore, '0.$1' );
 14613                          }
 14614  
 14615                          if ( str != s ) return new BigNumber( s, base );
 14616                      }
 14617  
 14618                      // 'new BigNumber() not a number: {n}'
 14619                      // 'new BigNumber() not a base {b} number: {n}'
 14620                      if (ERRORS) raise( id, 'not a' + ( b ? ' base ' + b : '' ) + ' number', str );
 14621                      x.s = null;
 14622                  }
 14623  
 14624                  x.c = x.e = null;
 14625                  id = 0;
 14626              }
 14627          })();
 14628  
 14629  
 14630          // Throw a BigNumber Error.
 14631          function raise( caller, msg, val ) {
 14632              var error = new Error( [
 14633                  'new BigNumber',     // 0
 14634                  'cmp',               // 1
 14635                  'config',            // 2
 14636                  'div',               // 3
 14637                  'divToInt',          // 4
 14638                  'eq',                // 5
 14639                  'gt',                // 6
 14640                  'gte',               // 7
 14641                  'lt',                // 8
 14642                  'lte',               // 9
 14643                  'minus',             // 10
 14644                  'mod',               // 11
 14645                  'plus',              // 12
 14646                  'precision',         // 13
 14647                  'random',            // 14
 14648                  'round',             // 15
 14649                  'shift',             // 16
 14650                  'times',             // 17
 14651                  'toDigits',          // 18
 14652                  'toExponential',     // 19
 14653                  'toFixed',           // 20
 14654                  'toFormat',          // 21
 14655                  'toFraction',        // 22
 14656                  'pow',               // 23
 14657                  'toPrecision',       // 24
 14658                  'toString',          // 25
 14659                  'BigNumber'          // 26
 14660              ][caller] + '() ' + msg + ': ' + val );
 14661  
 14662              error.name = 'BigNumber Error';
 14663              id = 0;
 14664              throw error;
 14665          }
 14666  
 14667  
 14668          /*
 14669           * Round x to sd significant digits using rounding mode rm. Check for over/under-flow.
 14670           * If r is truthy, it is known that there are more digits after the rounding digit.
 14671           */
 14672          function round( x, sd, rm, r ) {
 14673              var d, i, j, k, n, ni, rd,
 14674                  xc = x.c,
 14675                  pows10 = POWS_TEN;
 14676  
 14677              // if x is not Infinity or NaN...
 14678              if (xc) {
 14679  
 14680                  // rd is the rounding digit, i.e. the digit after the digit that may be rounded up.
 14681                  // n is a base 1e14 number, the value of the element of array x.c containing rd.
 14682                  // ni is the index of n within x.c.
 14683                  // d is the number of digits of n.
 14684                  // i is the index of rd within n including leading zeros.
 14685                  // j is the actual index of rd within n (if < 0, rd is a leading zero).
 14686                  out: {
 14687  
 14688                      // Get the number of digits of the first element of xc.
 14689                      for ( d = 1, k = xc[0]; k >= 10; k /= 10, d++ );
 14690                      i = sd - d;
 14691  
 14692                      // If the rounding digit is in the first element of xc...
 14693                      if ( i < 0 ) {
 14694                          i += LOG_BASE;
 14695                          j = sd;
 14696                          n = xc[ ni = 0 ];
 14697  
 14698                          // Get the rounding digit at index j of n.
 14699                          rd = n / pows10[ d - j - 1 ] % 10 | 0;
 14700                      } else {
 14701                          ni = mathceil( ( i + 1 ) / LOG_BASE );
 14702  
 14703                          if ( ni >= xc.length ) {
 14704  
 14705                              if (r) {
 14706  
 14707                                  // Needed by sqrt.
 14708                                  for ( ; xc.length <= ni; xc.push(0) );
 14709                                  n = rd = 0;
 14710                                  d = 1;
 14711                                  i %= LOG_BASE;
 14712                                  j = i - LOG_BASE + 1;
 14713                              } else {
 14714                                  break out;
 14715                              }
 14716                          } else {
 14717                              n = k = xc[ni];
 14718  
 14719                              // Get the number of digits of n.
 14720                              for ( d = 1; k >= 10; k /= 10, d++ );
 14721  
 14722                              // Get the index of rd within n.
 14723                              i %= LOG_BASE;
 14724  
 14725                              // Get the index of rd within n, adjusted for leading zeros.
 14726                              // The number of leading zeros of n is given by LOG_BASE - d.
 14727                              j = i - LOG_BASE + d;
 14728  
 14729                              // Get the rounding digit at index j of n.
 14730                              rd = j < 0 ? 0 : n / pows10[ d - j - 1 ] % 10 | 0;
 14731                          }
 14732                      }
 14733  
 14734                      r = r || sd < 0 ||
 14735  
 14736                      // Are there any non-zero digits after the rounding digit?
 14737                      // The expression  n % pows10[ d - j - 1 ]  returns all digits of n to the right
 14738                      // of the digit at j, e.g. if n is 908714 and j is 2, the expression gives 714.
 14739                        xc[ni + 1] != null || ( j < 0 ? n : n % pows10[ d - j - 1 ] );
 14740  
 14741                      r = rm < 4
 14742                        ? ( rd || r ) && ( rm == 0 || rm == ( x.s < 0 ? 3 : 2 ) )
 14743                        : rd > 5 || rd == 5 && ( rm == 4 || r || rm == 6 &&
 14744  
 14745                          // Check whether the digit to the left of the rounding digit is odd.
 14746                          ( ( i > 0 ? j > 0 ? n / pows10[ d - j ] : 0 : xc[ni - 1] ) % 10 ) & 1 ||
 14747                            rm == ( x.s < 0 ? 8 : 7 ) );
 14748  
 14749                      if ( sd < 1 || !xc[0] ) {
 14750                          xc.length = 0;
 14751  
 14752                          if (r) {
 14753  
 14754                              // Convert sd to decimal places.
 14755                              sd -= x.e + 1;
 14756  
 14757                              // 1, 0.1, 0.01, 0.001, 0.0001 etc.
 14758                              xc[0] = pows10[ sd % LOG_BASE ];
 14759                              x.e = -sd || 0;
 14760                          } else {
 14761  
 14762                              // Zero.
 14763                              xc[0] = x.e = 0;
 14764                          }
 14765  
 14766                          return x;
 14767                      }
 14768  
 14769                      // Remove excess digits.
 14770                      if ( i == 0 ) {
 14771                          xc.length = ni;
 14772                          k = 1;
 14773                          ni--;
 14774                      } else {
 14775                          xc.length = ni + 1;
 14776                          k = pows10[ LOG_BASE - i ];
 14777  
 14778                          // E.g. 56700 becomes 56000 if 7 is the rounding digit.
 14779                          // j > 0 means i > number of leading zeros of n.
 14780                          xc[ni] = j > 0 ? mathfloor( n / pows10[ d - j ] % pows10[j] ) * k : 0;
 14781                      }
 14782  
 14783                      // Round up?
 14784                      if (r) {
 14785  
 14786                          for ( ; ; ) {
 14787  
 14788                              // If the digit to be rounded up is in the first element of xc...
 14789                              if ( ni == 0 ) {
 14790  
 14791                                  // i will be the length of xc[0] before k is added.
 14792                                  for ( i = 1, j = xc[0]; j >= 10; j /= 10, i++ );
 14793                                  j = xc[0] += k;
 14794                                  for ( k = 1; j >= 10; j /= 10, k++ );
 14795  
 14796                                  // if i != k the length has increased.
 14797                                  if ( i != k ) {
 14798                                      x.e++;
 14799                                      if ( xc[0] == BASE ) xc[0] = 1;
 14800                                  }
 14801  
 14802                                  break;
 14803                              } else {
 14804                                  xc[ni] += k;
 14805                                  if ( xc[ni] != BASE ) break;
 14806                                  xc[ni--] = 0;
 14807                                  k = 1;
 14808                              }
 14809                          }
 14810                      }
 14811  
 14812                      // Remove trailing zeros.
 14813                      for ( i = xc.length; xc[--i] === 0; xc.pop() );
 14814                  }
 14815  
 14816                  // Overflow? Infinity.
 14817                  if ( x.e > MAX_EXP ) {
 14818                      x.c = x.e = null;
 14819  
 14820                  // Underflow? Zero.
 14821                  } else if ( x.e < MIN_EXP ) {
 14822                      x.c = [ x.e = 0 ];
 14823                  }
 14824              }
 14825  
 14826              return x;
 14827          }
 14828  
 14829  
 14830          // PROTOTYPE/INSTANCE METHODS
 14831  
 14832  
 14833          /*
 14834           * Return a new BigNumber whose value is the absolute value of this BigNumber.
 14835           */
 14836          P.absoluteValue = P.abs = function () {
 14837              var x = new BigNumber(this);
 14838              if ( x.s < 0 ) x.s = 1;
 14839              return x;
 14840          };
 14841  
 14842  
 14843          /*
 14844           * Return a new BigNumber whose value is the value of this BigNumber rounded to a whole
 14845           * number in the direction of Infinity.
 14846           */
 14847          P.ceil = function () {
 14848              return round( new BigNumber(this), this.e + 1, 2 );
 14849          };
 14850  
 14851  
 14852          /*
 14853           * Return
 14854           * 1 if the value of this BigNumber is greater than the value of BigNumber(y, b),
 14855           * -1 if the value of this BigNumber is less than the value of BigNumber(y, b),
 14856           * 0 if they have the same value,
 14857           * or null if the value of either is NaN.
 14858           */
 14859          P.comparedTo = P.cmp = function ( y, b ) {
 14860              id = 1;
 14861              return compare( this, new BigNumber( y, b ) );
 14862          };
 14863  
 14864  
 14865          /*
 14866           * Return the number of decimal places of the value of this BigNumber, or null if the value
 14867           * of this BigNumber is ±Infinity or NaN.
 14868           */
 14869          P.decimalPlaces = P.dp = function () {
 14870              var n, v,
 14871                  c = this.c;
 14872  
 14873              if ( !c ) return null;
 14874              n = ( ( v = c.length - 1 ) - bitFloor( this.e / LOG_BASE ) ) * LOG_BASE;
 14875  
 14876              // Subtract the number of trailing zeros of the last number.
 14877              if ( v = c[v] ) for ( ; v % 10 == 0; v /= 10, n-- );
 14878              if ( n < 0 ) n = 0;
 14879  
 14880              return n;
 14881          };
 14882  
 14883  
 14884          /*
 14885           *  n / 0 = I
 14886           *  n / N = N
 14887           *  n / I = 0
 14888           *  0 / n = 0
 14889           *  0 / 0 = N
 14890           *  0 / N = N
 14891           *  0 / I = 0
 14892           *  N / n = N
 14893           *  N / 0 = N
 14894           *  N / N = N
 14895           *  N / I = N
 14896           *  I / n = I
 14897           *  I / 0 = I
 14898           *  I / N = N
 14899           *  I / I = N
 14900           *
 14901           * Return a new BigNumber whose value is the value of this BigNumber divided by the value of
 14902           * BigNumber(y, b), rounded according to DECIMAL_PLACES and ROUNDING_MODE.
 14903           */
 14904          P.dividedBy = P.div = function ( y, b ) {
 14905              id = 3;
 14906              return div( this, new BigNumber( y, b ), DECIMAL_PLACES, ROUNDING_MODE );
 14907          };
 14908  
 14909  
 14910          /*
 14911           * Return a new BigNumber whose value is the integer part of dividing the value of this
 14912           * BigNumber by the value of BigNumber(y, b).
 14913           */
 14914          P.dividedToIntegerBy = P.divToInt = function ( y, b ) {
 14915              id = 4;
 14916              return div( this, new BigNumber( y, b ), 0, 1 );
 14917          };
 14918  
 14919  
 14920          /*
 14921           * Return true if the value of this BigNumber is equal to the value of BigNumber(y, b),
 14922           * otherwise returns false.
 14923           */
 14924          P.equals = P.eq = function ( y, b ) {
 14925              id = 5;
 14926              return compare( this, new BigNumber( y, b ) ) === 0;
 14927          };
 14928  
 14929  
 14930          /*
 14931           * Return a new BigNumber whose value is the value of this BigNumber rounded to a whole
 14932           * number in the direction of -Infinity.
 14933           */
 14934          P.floor = function () {
 14935              return round( new BigNumber(this), this.e + 1, 3 );
 14936          };
 14937  
 14938  
 14939          /*
 14940           * Return true if the value of this BigNumber is greater than the value of BigNumber(y, b),
 14941           * otherwise returns false.
 14942           */
 14943          P.greaterThan = P.gt = function ( y, b ) {
 14944              id = 6;
 14945              return compare( this, new BigNumber( y, b ) ) > 0;
 14946          };
 14947  
 14948  
 14949          /*
 14950           * Return true if the value of this BigNumber is greater than or equal to the value of
 14951           * BigNumber(y, b), otherwise returns false.
 14952           */
 14953          P.greaterThanOrEqualTo = P.gte = function ( y, b ) {
 14954              id = 7;
 14955              return ( b = compare( this, new BigNumber( y, b ) ) ) === 1 || b === 0;
 14956  
 14957          };
 14958  
 14959  
 14960          /*
 14961           * Return true if the value of this BigNumber is a finite number, otherwise returns false.
 14962           */
 14963          P.isFinite = function () {
 14964              return !!this.c;
 14965          };
 14966  
 14967  
 14968          /*
 14969           * Return true if the value of this BigNumber is an integer, otherwise return false.
 14970           */
 14971          P.isInteger = P.isInt = function () {
 14972              return !!this.c && bitFloor( this.e / LOG_BASE ) > this.c.length - 2;
 14973          };
 14974  
 14975  
 14976          /*
 14977           * Return true if the value of this BigNumber is NaN, otherwise returns false.
 14978           */
 14979          P.isNaN = function () {
 14980              return !this.s;
 14981          };
 14982  
 14983  
 14984          /*
 14985           * Return true if the value of this BigNumber is negative, otherwise returns false.
 14986           */
 14987          P.isNegative = P.isNeg = function () {
 14988              return this.s < 0;
 14989          };
 14990  
 14991  
 14992          /*
 14993           * Return true if the value of this BigNumber is 0 or -0, otherwise returns false.
 14994           */
 14995          P.isZero = function () {
 14996              return !!this.c && this.c[0] == 0;
 14997          };
 14998  
 14999  
 15000          /*
 15001           * Return true if the value of this BigNumber is less than the value of BigNumber(y, b),
 15002           * otherwise returns false.
 15003           */
 15004          P.lessThan = P.lt = function ( y, b ) {
 15005              id = 8;
 15006              return compare( this, new BigNumber( y, b ) ) < 0;
 15007          };
 15008  
 15009  
 15010          /*
 15011           * Return true if the value of this BigNumber is less than or equal to the value of
 15012           * BigNumber(y, b), otherwise returns false.
 15013           */
 15014          P.lessThanOrEqualTo = P.lte = function ( y, b ) {
 15015              id = 9;
 15016              return ( b = compare( this, new BigNumber( y, b ) ) ) === -1 || b === 0;
 15017          };
 15018  
 15019  
 15020          /*
 15021           *  n - 0 = n
 15022           *  n - N = N
 15023           *  n - I = -I
 15024           *  0 - n = -n
 15025           *  0 - 0 = 0
 15026           *  0 - N = N
 15027           *  0 - I = -I
 15028           *  N - n = N
 15029           *  N - 0 = N
 15030           *  N - N = N
 15031           *  N - I = N
 15032           *  I - n = I
 15033           *  I - 0 = I
 15034           *  I - N = N
 15035           *  I - I = N
 15036           *
 15037           * Return a new BigNumber whose value is the value of this BigNumber minus the value of
 15038           * BigNumber(y, b).
 15039           */
 15040          P.minus = P.sub = function ( y, b ) {
 15041              var i, j, t, xLTy,
 15042                  x = this,
 15043                  a = x.s;
 15044  
 15045              id = 10;
 15046              y = new BigNumber( y, b );
 15047              b = y.s;
 15048  
 15049              // Either NaN?
 15050              if ( !a || !b ) return new BigNumber(NaN);
 15051  
 15052              // Signs differ?
 15053              if ( a != b ) {
 15054                  y.s = -b;
 15055                  return x.plus(y);
 15056              }
 15057  
 15058              var xe = x.e / LOG_BASE,
 15059                  ye = y.e / LOG_BASE,
 15060                  xc = x.c,
 15061                  yc = y.c;
 15062  
 15063              if ( !xe || !ye ) {
 15064  
 15065                  // Either Infinity?
 15066                  if ( !xc || !yc ) return xc ? ( y.s = -b, y ) : new BigNumber( yc ? x : NaN );
 15067  
 15068                  // Either zero?
 15069                  if ( !xc[0] || !yc[0] ) {
 15070  
 15071                      // Return y if y is non-zero, x if x is non-zero, or zero if both are zero.
 15072                      return yc[0] ? ( y.s = -b, y ) : new BigNumber( xc[0] ? x :
 15073  
 15074                        // IEEE 754 (2008) 6.3: n - n = -0 when rounding to -Infinity
 15075                        ROUNDING_MODE == 3 ? -0 : 0 );
 15076                  }
 15077              }
 15078  
 15079              xe = bitFloor(xe);
 15080              ye = bitFloor(ye);
 15081              xc = xc.slice();
 15082  
 15083              // Determine which is the bigger number.
 15084              if ( a = xe - ye ) {
 15085  
 15086                  if ( xLTy = a < 0 ) {
 15087                      a = -a;
 15088                      t = xc;
 15089                  } else {
 15090                      ye = xe;
 15091                      t = yc;
 15092                  }
 15093  
 15094                  t.reverse();
 15095  
 15096                  // Prepend zeros to equalise exponents.
 15097                  for ( b = a; b--; t.push(0) );
 15098                  t.reverse();
 15099              } else {
 15100  
 15101                  // Exponents equal. Check digit by digit.
 15102                  j = ( xLTy = ( a = xc.length ) < ( b = yc.length ) ) ? a : b;
 15103  
 15104                  for ( a = b = 0; b < j; b++ ) {
 15105  
 15106                      if ( xc[b] != yc[b] ) {
 15107                          xLTy = xc[b] < yc[b];
 15108                          break;
 15109                      }
 15110                  }
 15111              }
 15112  
 15113              // x < y? Point xc to the array of the bigger number.
 15114              if (xLTy) t = xc, xc = yc, yc = t, y.s = -y.s;
 15115  
 15116              b = ( j = yc.length ) - ( i = xc.length );
 15117  
 15118              // Append zeros to xc if shorter.
 15119              // No need to add zeros to yc if shorter as subtract only needs to start at yc.length.
 15120              if ( b > 0 ) for ( ; b--; xc[i++] = 0 );
 15121              b = BASE - 1;
 15122  
 15123              // Subtract yc from xc.
 15124              for ( ; j > a; ) {
 15125  
 15126                  if ( xc[--j] < yc[j] ) {
 15127                      for ( i = j; i && !xc[--i]; xc[i] = b );
 15128                      --xc[i];
 15129                      xc[j] += BASE;
 15130                  }
 15131  
 15132                  xc[j] -= yc[j];
 15133              }
 15134  
 15135              // Remove leading zeros and adjust exponent accordingly.
 15136              for ( ; xc[0] == 0; xc.shift(), --ye );
 15137  
 15138              // Zero?
 15139              if ( !xc[0] ) {
 15140  
 15141                  // Following IEEE 754 (2008) 6.3,
 15142                  // n - n = +0  but  n - n = -0  when rounding towards -Infinity.
 15143                  y.s = ROUNDING_MODE == 3 ? -1 : 1;
 15144                  y.c = [ y.e = 0 ];
 15145                  return y;
 15146              }
 15147  
 15148              // No need to check for Infinity as +x - +y != Infinity && -x - -y != Infinity
 15149              // for finite x and y.
 15150              return normalise( y, xc, ye );
 15151          };
 15152  
 15153  
 15154          /*
 15155           *   n % 0 =  N
 15156           *   n % N =  N
 15157           *   n % I =  n
 15158           *   0 % n =  0
 15159           *  -0 % n = -0
 15160           *   0 % 0 =  N
 15161           *   0 % N =  N
 15162           *   0 % I =  0
 15163           *   N % n =  N
 15164           *   N % 0 =  N
 15165           *   N % N =  N
 15166           *   N % I =  N
 15167           *   I % n =  N
 15168           *   I % 0 =  N
 15169           *   I % N =  N
 15170           *   I % I =  N
 15171           *
 15172           * Return a new BigNumber whose value is the value of this BigNumber modulo the value of
 15173           * BigNumber(y, b). The result depends on the value of MODULO_MODE.
 15174           */
 15175          P.modulo = P.mod = function ( y, b ) {
 15176              var q, s,
 15177                  x = this;
 15178  
 15179              id = 11;
 15180              y = new BigNumber( y, b );
 15181  
 15182              // Return NaN if x is Infinity or NaN, or y is NaN or zero.
 15183              if ( !x.c || !y.s || y.c && !y.c[0] ) {
 15184                  return new BigNumber(NaN);
 15185  
 15186              // Return x if y is Infinity or x is zero.
 15187              } else if ( !y.c || x.c && !x.c[0] ) {
 15188                  return new BigNumber(x);
 15189              }
 15190  
 15191              if ( MODULO_MODE == 9 ) {
 15192  
 15193                  // Euclidian division: q = sign(y) * floor(x / abs(y))
 15194                  // r = x - qy    where  0 <= r < abs(y)
 15195                  s = y.s;
 15196                  y.s = 1;
 15197                  q = div( x, y, 0, 3 );
 15198                  y.s = s;
 15199                  q.s *= s;
 15200              } else {
 15201                  q = div( x, y, 0, MODULO_MODE );
 15202              }
 15203  
 15204              return x.minus( q.times(y) );
 15205          };
 15206  
 15207  
 15208          /*
 15209           * Return a new BigNumber whose value is the value of this BigNumber negated,
 15210           * i.e. multiplied by -1.
 15211           */
 15212          P.negated = P.neg = function () {
 15213              var x = new BigNumber(this);
 15214              x.s = -x.s || null;
 15215              return x;
 15216          };
 15217  
 15218  
 15219          /*
 15220           *  n + 0 = n
 15221           *  n + N = N
 15222           *  n + I = I
 15223           *  0 + n = n
 15224           *  0 + 0 = 0
 15225           *  0 + N = N
 15226           *  0 + I = I
 15227           *  N + n = N
 15228           *  N + 0 = N
 15229           *  N + N = N
 15230           *  N + I = N
 15231           *  I + n = I
 15232           *  I + 0 = I
 15233           *  I + N = N
 15234           *  I + I = I
 15235           *
 15236           * Return a new BigNumber whose value is the value of this BigNumber plus the value of
 15237           * BigNumber(y, b).
 15238           */
 15239          P.plus = P.add = function ( y, b ) {
 15240              var t,
 15241                  x = this,
 15242                  a = x.s;
 15243  
 15244              id = 12;
 15245              y = new BigNumber( y, b );
 15246              b = y.s;
 15247  
 15248              // Either NaN?
 15249              if ( !a || !b ) return new BigNumber(NaN);
 15250  
 15251              // Signs differ?
 15252               if ( a != b ) {
 15253                  y.s = -b;
 15254                  return x.minus(y);
 15255              }
 15256  
 15257              var xe = x.e / LOG_BASE,
 15258                  ye = y.e / LOG_BASE,
 15259                  xc = x.c,
 15260                  yc = y.c;
 15261  
 15262              if ( !xe || !ye ) {
 15263  
 15264                  // Return ±Infinity if either ±Infinity.
 15265                  if ( !xc || !yc ) return new BigNumber( a / 0 );
 15266  
 15267                  // Either zero?
 15268                  // Return y if y is non-zero, x if x is non-zero, or zero if both are zero.
 15269                  if ( !xc[0] || !yc[0] ) return yc[0] ? y : new BigNumber( xc[0] ? x : a * 0 );
 15270              }
 15271  
 15272              xe = bitFloor(xe);
 15273              ye = bitFloor(ye);
 15274              xc = xc.slice();
 15275  
 15276              // Prepend zeros to equalise exponents. Faster to use reverse then do unshifts.
 15277              if ( a = xe - ye ) {
 15278                  if ( a > 0 ) {
 15279                      ye = xe;
 15280                      t = yc;
 15281                  } else {
 15282                      a = -a;
 15283                      t = xc;
 15284                  }
 15285  
 15286                  t.reverse();
 15287                  for ( ; a--; t.push(0) );
 15288                  t.reverse();
 15289              }
 15290  
 15291              a = xc.length;
 15292              b = yc.length;
 15293  
 15294              // Point xc to the longer array, and b to the shorter length.
 15295              if ( a - b < 0 ) t = yc, yc = xc, xc = t, b = a;
 15296  
 15297              // Only start adding at yc.length - 1 as the further digits of xc can be ignored.
 15298              for ( a = 0; b; ) {
 15299                  a = ( xc[--b] = xc[b] + yc[b] + a ) / BASE | 0;
 15300                  xc[b] %= BASE;
 15301              }
 15302  
 15303              if (a) {
 15304                  xc.unshift(a);
 15305                  ++ye;
 15306              }
 15307  
 15308              // No need to check for zero, as +x + +y != 0 && -x + -y != 0
 15309              // ye = MAX_EXP + 1 possible
 15310              return normalise( y, xc, ye );
 15311          };
 15312  
 15313  
 15314          /*
 15315           * Return the number of significant digits of the value of this BigNumber.
 15316           *
 15317           * [z] {boolean|number} Whether to count integer-part trailing zeros: true, false, 1 or 0.
 15318           */
 15319          P.precision = P.sd = function (z) {
 15320              var n, v,
 15321                  x = this,
 15322                  c = x.c;
 15323  
 15324              // 'precision() argument not a boolean or binary digit: {z}'
 15325              if ( z != null && z !== !!z && z !== 1 && z !== 0 ) {
 15326                  if (ERRORS) raise( 13, 'argument' + notBool, z );
 15327                  if ( z != !!z ) z = null;
 15328              }
 15329  
 15330              if ( !c ) return null;
 15331              v = c.length - 1;
 15332              n = v * LOG_BASE + 1;
 15333  
 15334              if ( v = c[v] ) {
 15335  
 15336                  // Subtract the number of trailing zeros of the last element.
 15337                  for ( ; v % 10 == 0; v /= 10, n-- );
 15338  
 15339                  // Add the number of digits of the first element.
 15340                  for ( v = c[0]; v >= 10; v /= 10, n++ );
 15341              }
 15342  
 15343              if ( z && x.e + 1 > n ) n = x.e + 1;
 15344  
 15345              return n;
 15346          };
 15347  
 15348  
 15349          /*
 15350           * Return a new BigNumber whose value is the value of this BigNumber rounded to a maximum of
 15351           * dp decimal places using rounding mode rm, or to 0 and ROUNDING_MODE respectively if
 15352           * omitted.
 15353           *
 15354           * [dp] {number} Decimal places. Integer, 0 to MAX inclusive.
 15355           * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.
 15356           *
 15357           * 'round() decimal places out of range: {dp}'
 15358           * 'round() decimal places not an integer: {dp}'
 15359           * 'round() rounding mode not an integer: {rm}'
 15360           * 'round() rounding mode out of range: {rm}'
 15361           */
 15362          P.round = function ( dp, rm ) {
 15363              var n = new BigNumber(this);
 15364  
 15365              if ( dp == null || isValidInt( dp, 0, MAX, 15 ) ) {
 15366                  round( n, ~~dp + this.e + 1, rm == null ||
 15367                    !isValidInt( rm, 0, 8, 15, roundingMode ) ? ROUNDING_MODE : rm | 0 );
 15368              }
 15369  
 15370              return n;
 15371          };
 15372  
 15373  
 15374          /*
 15375           * Return a new BigNumber whose value is the value of this BigNumber shifted by k places
 15376           * (powers of 10). Shift to the right if n > 0, and to the left if n < 0.
 15377           *
 15378           * k {number} Integer, -MAX_SAFE_INTEGER to MAX_SAFE_INTEGER inclusive.
 15379           *
 15380           * If k is out of range and ERRORS is false, the result will be ±0 if k < 0, or ±Infinity
 15381           * otherwise.
 15382           *
 15383           * 'shift() argument not an integer: {k}'
 15384           * 'shift() argument out of range: {k}'
 15385           */
 15386          P.shift = function (k) {
 15387              var n = this;
 15388              return isValidInt( k, -MAX_SAFE_INTEGER, MAX_SAFE_INTEGER, 16, 'argument' )
 15389  
 15390                // k < 1e+21, or truncate(k) will produce exponential notation.
 15391                ? n.times( '1e' + truncate(k) )
 15392                : new BigNumber( n.c && n.c[0] && ( k < -MAX_SAFE_INTEGER || k > MAX_SAFE_INTEGER )
 15393                  ? n.s * ( k < 0 ? 0 : 1 / 0 )
 15394                  : n );
 15395          };
 15396  
 15397  
 15398          /*
 15399           *  sqrt(-n) =  N
 15400           *  sqrt( N) =  N
 15401           *  sqrt(-I) =  N
 15402           *  sqrt( I) =  I
 15403           *  sqrt( 0) =  0
 15404           *  sqrt(-0) = -0
 15405           *
 15406           * Return a new BigNumber whose value is the square root of the value of this BigNumber,
 15407           * rounded according to DECIMAL_PLACES and ROUNDING_MODE.
 15408           */
 15409          P.squareRoot = P.sqrt = function () {
 15410              var m, n, r, rep, t,
 15411                  x = this,
 15412                  c = x.c,
 15413                  s = x.s,
 15414                  e = x.e,
 15415                  dp = DECIMAL_PLACES + 4,
 15416                  half = new BigNumber('0.5');
 15417  
 15418              // Negative/NaN/Infinity/zero?
 15419              if ( s !== 1 || !c || !c[0] ) {
 15420                  return new BigNumber( !s || s < 0 && ( !c || c[0] ) ? NaN : c ? x : 1 / 0 );
 15421              }
 15422  
 15423              // Initial estimate.
 15424              s = Math.sqrt( +x );
 15425  
 15426              // Math.sqrt underflow/overflow?
 15427              // Pass x to Math.sqrt as integer, then adjust the exponent of the result.
 15428              if ( s == 0 || s == 1 / 0 ) {
 15429                  n = coeffToString(c);
 15430                  if ( ( n.length + e ) % 2 == 0 ) n += '0';
 15431                  s = Math.sqrt(n);
 15432                  e = bitFloor( ( e + 1 ) / 2 ) - ( e < 0 || e % 2 );
 15433  
 15434                  if ( s == 1 / 0 ) {
 15435                      n = '1e' + e;
 15436                  } else {
 15437                      n = s.toExponential();
 15438                      n = n.slice( 0, n.indexOf('e') + 1 ) + e;
 15439                  }
 15440  
 15441                  r = new BigNumber(n);
 15442              } else {
 15443                  r = new BigNumber( s + '' );
 15444              }
 15445  
 15446              // Check for zero.
 15447              // r could be zero if MIN_EXP is changed after the this value was created.
 15448              // This would cause a division by zero (x/t) and hence Infinity below, which would cause
 15449              // coeffToString to throw.
 15450              if ( r.c[0] ) {
 15451                  e = r.e;
 15452                  s = e + dp;
 15453                  if ( s < 3 ) s = 0;
 15454  
 15455                  // Newton-Raphson iteration.
 15456                  for ( ; ; ) {
 15457                      t = r;
 15458                      r = half.times( t.plus( div( x, t, dp, 1 ) ) );
 15459  
 15460                      if ( coeffToString( t.c   ).slice( 0, s ) === ( n =
 15461                           coeffToString( r.c ) ).slice( 0, s ) ) {
 15462  
 15463                          // The exponent of r may here be one less than the final result exponent,
 15464                          // e.g 0.0009999 (e-4) --> 0.001 (e-3), so adjust s so the rounding digits
 15465                          // are indexed correctly.
 15466                          if ( r.e < e ) --s;
 15467                          n = n.slice( s - 3, s + 1 );
 15468  
 15469                          // The 4th rounding digit may be in error by -1 so if the 4 rounding digits
 15470                          // are 9999 or 4999 (i.e. approaching a rounding boundary) continue the
 15471                          // iteration.
 15472                          if ( n == '9999' || !rep && n == '4999' ) {
 15473  
 15474                              // On the first iteration only, check to see if rounding up gives the
 15475                              // exact result as the nines may infinitely repeat.
 15476                              if ( !rep ) {
 15477                                  round( t, t.e + DECIMAL_PLACES + 2, 0 );
 15478  
 15479                                  if ( t.times(t).eq(x) ) {
 15480                                      r = t;
 15481                                      break;
 15482                                  }
 15483                              }
 15484  
 15485                              dp += 4;
 15486                              s += 4;
 15487                              rep = 1;
 15488                          } else {
 15489  
 15490                              // If rounding digits are null, 0{0,4} or 50{0,3}, check for exact
 15491                              // result. If not, then there are further digits and m will be truthy.
 15492                              if ( !+n || !+n.slice(1) && n.charAt(0) == '5' ) {
 15493  
 15494                                  // Truncate to the first rounding digit.
 15495                                  round( r, r.e + DECIMAL_PLACES + 2, 1 );
 15496                                  m = !r.times(r).eq(x);
 15497                              }
 15498  
 15499                              break;
 15500                          }
 15501                      }
 15502                  }
 15503              }
 15504  
 15505              return round( r, r.e + DECIMAL_PLACES + 1, ROUNDING_MODE, m );
 15506          };
 15507  
 15508  
 15509          /*
 15510           *  n * 0 = 0
 15511           *  n * N = N
 15512           *  n * I = I
 15513           *  0 * n = 0
 15514           *  0 * 0 = 0
 15515           *  0 * N = N
 15516           *  0 * I = N
 15517           *  N * n = N
 15518           *  N * 0 = N
 15519           *  N * N = N
 15520           *  N * I = N
 15521           *  I * n = I
 15522           *  I * 0 = N
 15523           *  I * N = N
 15524           *  I * I = I
 15525           *
 15526           * Return a new BigNumber whose value is the value of this BigNumber times the value of
 15527           * BigNumber(y, b).
 15528           */
 15529          P.times = P.mul = function ( y, b ) {
 15530              var c, e, i, j, k, m, xcL, xlo, xhi, ycL, ylo, yhi, zc,
 15531                  base, sqrtBase,
 15532                  x = this,
 15533                  xc = x.c,
 15534                  yc = ( id = 17, y = new BigNumber( y, b ) ).c;
 15535  
 15536              // Either NaN, ±Infinity or ±0?
 15537              if ( !xc || !yc || !xc[0] || !yc[0] ) {
 15538  
 15539                  // Return NaN if either is NaN, or one is 0 and the other is Infinity.
 15540                  if ( !x.s || !y.s || xc && !xc[0] && !yc || yc && !yc[0] && !xc ) {
 15541                      y.c = y.e = y.s = null;
 15542                  } else {
 15543                      y.s *= x.s;
 15544  
 15545                      // Return ±Infinity if either is ±Infinity.
 15546                      if ( !xc || !yc ) {
 15547                          y.c = y.e = null;
 15548  
 15549                      // Return ±0 if either is ±0.
 15550                      } else {
 15551                          y.c = [0];
 15552                          y.e = 0;
 15553                      }
 15554                  }
 15555  
 15556                  return y;
 15557              }
 15558  
 15559              e = bitFloor( x.e / LOG_BASE ) + bitFloor( y.e / LOG_BASE );
 15560              y.s *= x.s;
 15561              xcL = xc.length;
 15562              ycL = yc.length;
 15563  
 15564              // Ensure xc points to longer array and xcL to its length.
 15565              if ( xcL < ycL ) zc = xc, xc = yc, yc = zc, i = xcL, xcL = ycL, ycL = i;
 15566  
 15567              // Initialise the result array with zeros.
 15568              for ( i = xcL + ycL, zc = []; i--; zc.push(0) );
 15569  
 15570              base = BASE;
 15571              sqrtBase = SQRT_BASE;
 15572  
 15573              for ( i = ycL; --i >= 0; ) {
 15574                  c = 0;
 15575                  ylo = yc[i] % sqrtBase;
 15576                  yhi = yc[i] / sqrtBase | 0;
 15577  
 15578                  for ( k = xcL, j = i + k; j > i; ) {
 15579                      xlo = xc[--k] % sqrtBase;
 15580                      xhi = xc[k] / sqrtBase | 0;
 15581                      m = yhi * xlo + xhi * ylo;
 15582                      xlo = ylo * xlo + ( ( m % sqrtBase ) * sqrtBase ) + zc[j] + c;
 15583                      c = ( xlo / base | 0 ) + ( m / sqrtBase | 0 ) + yhi * xhi;
 15584                      zc[j--] = xlo % base;
 15585                  }
 15586  
 15587                  zc[j] = c;
 15588              }
 15589  
 15590              if (c) {
 15591                  ++e;
 15592              } else {
 15593                  zc.shift();
 15594              }
 15595  
 15596              return normalise( y, zc, e );
 15597          };
 15598  
 15599  
 15600          /*
 15601           * Return a new BigNumber whose value is the value of this BigNumber rounded to a maximum of
 15602           * sd significant digits using rounding mode rm, or ROUNDING_MODE if rm is omitted.
 15603           *
 15604           * [sd] {number} Significant digits. Integer, 1 to MAX inclusive.
 15605           * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.
 15606           *
 15607           * 'toDigits() precision out of range: {sd}'
 15608           * 'toDigits() precision not an integer: {sd}'
 15609           * 'toDigits() rounding mode not an integer: {rm}'
 15610           * 'toDigits() rounding mode out of range: {rm}'
 15611           */
 15612          P.toDigits = function ( sd, rm ) {
 15613              var n = new BigNumber(this);
 15614              sd = sd == null || !isValidInt( sd, 1, MAX, 18, 'precision' ) ? null : sd | 0;
 15615              rm = rm == null || !isValidInt( rm, 0, 8, 18, roundingMode ) ? ROUNDING_MODE : rm | 0;
 15616              return sd ? round( n, sd, rm ) : n;
 15617          };
 15618  
 15619  
 15620          /*
 15621           * Return a string representing the value of this BigNumber in exponential notation and
 15622           * rounded using ROUNDING_MODE to dp fixed decimal places.
 15623           *
 15624           * [dp] {number} Decimal places. Integer, 0 to MAX inclusive.
 15625           * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.
 15626           *
 15627           * 'toExponential() decimal places not an integer: {dp}'
 15628           * 'toExponential() decimal places out of range: {dp}'
 15629           * 'toExponential() rounding mode not an integer: {rm}'
 15630           * 'toExponential() rounding mode out of range: {rm}'
 15631           */
 15632          P.toExponential = function ( dp, rm ) {
 15633              return format( this,
 15634                dp != null && isValidInt( dp, 0, MAX, 19 ) ? ~~dp + 1 : null, rm, 19 );
 15635          };
 15636  
 15637  
 15638          /*
 15639           * Return a string representing the value of this BigNumber in fixed-point notation rounding
 15640           * to dp fixed decimal places using rounding mode rm, or ROUNDING_MODE if rm is omitted.
 15641           *
 15642           * Note: as with JavaScript's number type, (-0).toFixed(0) is '0',
 15643           * but e.g. (-0.00001).toFixed(0) is '-0'.
 15644           *
 15645           * [dp] {number} Decimal places. Integer, 0 to MAX inclusive.
 15646           * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.
 15647           *
 15648           * 'toFixed() decimal places not an integer: {dp}'
 15649           * 'toFixed() decimal places out of range: {dp}'
 15650           * 'toFixed() rounding mode not an integer: {rm}'
 15651           * 'toFixed() rounding mode out of range: {rm}'
 15652           */
 15653          P.toFixed = function ( dp, rm ) {
 15654              return format( this, dp != null && isValidInt( dp, 0, MAX, 20 )
 15655                ? ~~dp + this.e + 1 : null, rm, 20 );
 15656          };
 15657  
 15658  
 15659          /*
 15660           * Return a string representing the value of this BigNumber in fixed-point notation rounded
 15661           * using rm or ROUNDING_MODE to dp decimal places, and formatted according to the properties
 15662           * of the FORMAT object (see BigNumber.config).
 15663           *
 15664           * FORMAT = {
 15665           *      decimalSeparator : '.',
 15666           *      groupSeparator : ',',
 15667           *      groupSize : 3,
 15668           *      secondaryGroupSize : 0,
 15669           *      fractionGroupSeparator : '\xA0',    // non-breaking space
 15670           *      fractionGroupSize : 0
 15671           * };
 15672           *
 15673           * [dp] {number} Decimal places. Integer, 0 to MAX inclusive.
 15674           * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.
 15675           *
 15676           * 'toFormat() decimal places not an integer: {dp}'
 15677           * 'toFormat() decimal places out of range: {dp}'
 15678           * 'toFormat() rounding mode not an integer: {rm}'
 15679           * 'toFormat() rounding mode out of range: {rm}'
 15680           */
 15681          P.toFormat = function ( dp, rm ) {
 15682              var str = format( this, dp != null && isValidInt( dp, 0, MAX, 21 )
 15683                ? ~~dp + this.e + 1 : null, rm, 21 );
 15684  
 15685              if ( this.c ) {
 15686                  var i,
 15687                      arr = str.split('.'),
 15688                      g1 = +FORMAT.groupSize,
 15689                      g2 = +FORMAT.secondaryGroupSize,
 15690                      groupSeparator = FORMAT.groupSeparator,
 15691                      intPart = arr[0],
 15692                      fractionPart = arr[1],
 15693                      isNeg = this.s < 0,
 15694                      intDigits = isNeg ? intPart.slice(1) : intPart,
 15695                      len = intDigits.length;
 15696  
 15697                  if (g2) i = g1, g1 = g2, g2 = i, len -= i;
 15698  
 15699                  if ( g1 > 0 && len > 0 ) {
 15700                      i = len % g1 || g1;
 15701                      intPart = intDigits.substr( 0, i );
 15702  
 15703                      for ( ; i < len; i += g1 ) {
 15704                          intPart += groupSeparator + intDigits.substr( i, g1 );
 15705                      }
 15706  
 15707                      if ( g2 > 0 ) intPart += groupSeparator + intDigits.slice(i);
 15708                      if (isNeg) intPart = '-' + intPart;
 15709                  }
 15710  
 15711                  str = fractionPart
 15712                    ? intPart + FORMAT.decimalSeparator + ( ( g2 = +FORMAT.fractionGroupSize )
 15713                      ? fractionPart.replace( new RegExp( '\\d{' + g2 + '}\\B', 'g' ),
 15714                        '$&' + FORMAT.fractionGroupSeparator )
 15715                      : fractionPart )
 15716                    : intPart;
 15717              }
 15718  
 15719              return str;
 15720          };
 15721  
 15722  
 15723          /*
 15724           * Return a string array representing the value of this BigNumber as a simple fraction with
 15725           * an integer numerator and an integer denominator. The denominator will be a positive
 15726           * non-zero value less than or equal to the specified maximum denominator. If a maximum
 15727           * denominator is not specified, the denominator will be the lowest value necessary to
 15728           * represent the number exactly.
 15729           *
 15730           * [md] {number|string|BigNumber} Integer >= 1 and < Infinity. The maximum denominator.
 15731           *
 15732           * 'toFraction() max denominator not an integer: {md}'
 15733           * 'toFraction() max denominator out of range: {md}'
 15734           */
 15735          P.toFraction = function (md) {
 15736              var arr, d0, d2, e, exp, n, n0, q, s,
 15737                  k = ERRORS,
 15738                  x = this,
 15739                  xc = x.c,
 15740                  d = new BigNumber(ONE),
 15741                  n1 = d0 = new BigNumber(ONE),
 15742                  d1 = n0 = new BigNumber(ONE);
 15743  
 15744              if ( md != null ) {
 15745                  ERRORS = false;
 15746                  n = new BigNumber(md);
 15747                  ERRORS = k;
 15748  
 15749                  if ( !( k = n.isInt() ) || n.lt(ONE) ) {
 15750  
 15751                      if (ERRORS) {
 15752                          raise( 22,
 15753                            'max denominator ' + ( k ? 'out of range' : 'not an integer' ), md );
 15754                      }
 15755  
 15756                      // ERRORS is false:
 15757                      // If md is a finite non-integer >= 1, round it to an integer and use it.
 15758                      md = !k && n.c && round( n, n.e + 1, 1 ).gte(ONE) ? n : null;
 15759                  }
 15760              }
 15761  
 15762              if ( !xc ) return x.toString();
 15763              s = coeffToString(xc);
 15764  
 15765              // Determine initial denominator.
 15766              // d is a power of 10 and the minimum max denominator that specifies the value exactly.
 15767              e = d.e = s.length - x.e - 1;
 15768              d.c[0] = POWS_TEN[ ( exp = e % LOG_BASE ) < 0 ? LOG_BASE + exp : exp ];
 15769              md = !md || n.cmp(d) > 0 ? ( e > 0 ? d : n1 ) : n;
 15770  
 15771              exp = MAX_EXP;
 15772              MAX_EXP = 1 / 0;
 15773              n = new BigNumber(s);
 15774  
 15775              // n0 = d1 = 0
 15776              n0.c[0] = 0;
 15777  
 15778              for ( ; ; )  {
 15779                  q = div( n, d, 0, 1 );
 15780                  d2 = d0.plus( q.times(d1) );
 15781                  if ( d2.cmp(md) == 1 ) break;
 15782                  d0 = d1;
 15783                  d1 = d2;
 15784                  n1 = n0.plus( q.times( d2 = n1 ) );
 15785                  n0 = d2;
 15786                  d = n.minus( q.times( d2 = d ) );
 15787                  n = d2;
 15788              }
 15789  
 15790              d2 = div( md.minus(d0), d1, 0, 1 );
 15791              n0 = n0.plus( d2.times(n1) );
 15792              d0 = d0.plus( d2.times(d1) );
 15793              n0.s = n1.s = x.s;
 15794              e *= 2;
 15795  
 15796              // Determine which fraction is closer to x, n0/d0 or n1/d1
 15797              arr = div( n1, d1, e, ROUNDING_MODE ).minus(x).abs().cmp(
 15798                    div( n0, d0, e, ROUNDING_MODE ).minus(x).abs() ) < 1
 15799                      ? [ n1.toString(), d1.toString() ]
 15800                      : [ n0.toString(), d0.toString() ];
 15801  
 15802              MAX_EXP = exp;
 15803              return arr;
 15804          };
 15805  
 15806  
 15807          /*
 15808           * Return the value of this BigNumber converted to a number primitive.
 15809           */
 15810          P.toNumber = function () {
 15811              var x = this;
 15812  
 15813              // Ensure zero has correct sign.
 15814              return +x || ( x.s ? x.s * 0 : NaN );
 15815          };
 15816  
 15817  
 15818          /*
 15819           * Return a BigNumber whose value is the value of this BigNumber raised to the power n.
 15820           * If n is negative round according to DECIMAL_PLACES and ROUNDING_MODE.
 15821           * If POW_PRECISION is not 0, round to POW_PRECISION using ROUNDING_MODE.
 15822           *
 15823           * n {number} Integer, -9007199254740992 to 9007199254740992 inclusive.
 15824           * (Performs 54 loop iterations for n of 9007199254740992.)
 15825           *
 15826           * 'pow() exponent not an integer: {n}'
 15827           * 'pow() exponent out of range: {n}'
 15828           */
 15829          P.toPower = P.pow = function (n) {
 15830              var k, y,
 15831                  i = mathfloor( n < 0 ? -n : +n ),
 15832                  x = this;
 15833  
 15834              // Pass ±Infinity to Math.pow if exponent is out of range.
 15835              if ( !isValidInt( n, -MAX_SAFE_INTEGER, MAX_SAFE_INTEGER, 23, 'exponent' ) &&
 15836                ( !isFinite(n) || i > MAX_SAFE_INTEGER && ( n /= 0 ) ||
 15837                  parseFloat(n) != n && !( n = NaN ) ) ) {
 15838                  return new BigNumber( Math.pow( +x, n ) );
 15839              }
 15840  
 15841              // Truncating each coefficient array to a length of k after each multiplication equates
 15842              // to truncating significant digits to POW_PRECISION + [28, 41], i.e. there will be a
 15843              // minimum of 28 guard digits retained. (Using + 1.5 would give [9, 21] guard digits.)
 15844              k = POW_PRECISION ? mathceil( POW_PRECISION / LOG_BASE + 2 ) : 0;
 15845              y = new BigNumber(ONE);
 15846  
 15847              for ( ; ; ) {
 15848  
 15849                  if ( i % 2 ) {
 15850                      y = y.times(x);
 15851                      if ( !y.c ) break;
 15852                      if ( k && y.c.length > k ) y.c.length = k;
 15853                  }
 15854  
 15855                  i = mathfloor( i / 2 );
 15856                  if ( !i ) break;
 15857  
 15858                  x = x.times(x);
 15859                  if ( k && x.c && x.c.length > k ) x.c.length = k;
 15860              }
 15861  
 15862              if ( n < 0 ) y = ONE.div(y);
 15863              return k ? round( y, POW_PRECISION, ROUNDING_MODE ) : y;
 15864          };
 15865  
 15866  
 15867          /*
 15868           * Return a string representing the value of this BigNumber rounded to sd significant digits
 15869           * using rounding mode rm or ROUNDING_MODE. If sd is less than the number of digits
 15870           * necessary to represent the integer part of the value in fixed-point notation, then use
 15871           * exponential notation.
 15872           *
 15873           * [sd] {number} Significant digits. Integer, 1 to MAX inclusive.
 15874           * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.
 15875           *
 15876           * 'toPrecision() precision not an integer: {sd}'
 15877           * 'toPrecision() precision out of range: {sd}'
 15878           * 'toPrecision() rounding mode not an integer: {rm}'
 15879           * 'toPrecision() rounding mode out of range: {rm}'
 15880           */
 15881          P.toPrecision = function ( sd, rm ) {
 15882              return format( this, sd != null && isValidInt( sd, 1, MAX, 24, 'precision' )
 15883                ? sd | 0 : null, rm, 24 );
 15884          };
 15885  
 15886  
 15887          /*
 15888           * Return a string representing the value of this BigNumber in base b, or base 10 if b is
 15889           * omitted. If a base is specified, including base 10, round according to DECIMAL_PLACES and
 15890           * ROUNDING_MODE. If a base is not specified, and this BigNumber has a positive exponent
 15891           * that is equal to or greater than TO_EXP_POS, or a negative exponent equal to or less than
 15892           * TO_EXP_NEG, return exponential notation.
 15893           *
 15894           * [b] {number} Integer, 2 to 64 inclusive.
 15895           *
 15896           * 'toString() base not an integer: {b}'
 15897           * 'toString() base out of range: {b}'
 15898           */
 15899          P.toString = function (b) {
 15900              var str,
 15901                  n = this,
 15902                  s = n.s,
 15903                  e = n.e;
 15904  
 15905              // Infinity or NaN?
 15906              if ( e === null ) {
 15907  
 15908                  if (s) {
 15909                      str = 'Infinity';
 15910                      if ( s < 0 ) str = '-' + str;
 15911                  } else {
 15912                      str = 'NaN';
 15913                  }
 15914              } else {
 15915                  str = coeffToString( n.c );
 15916  
 15917                  if ( b == null || !isValidInt( b, 2, 64, 25, 'base' ) ) {
 15918                      str = e <= TO_EXP_NEG || e >= TO_EXP_POS
 15919                        ? toExponential( str, e )
 15920                        : toFixedPoint( str, e );
 15921                  } else {
 15922                      str = convertBase( toFixedPoint( str, e ), b | 0, 10, s );
 15923                  }
 15924  
 15925                  if ( s < 0 && n.c[0] ) str = '-' + str;
 15926              }
 15927  
 15928              return str;
 15929          };
 15930  
 15931  
 15932          /*
 15933           * Return a new BigNumber whose value is the value of this BigNumber truncated to a whole
 15934           * number.
 15935           */
 15936          P.truncated = P.trunc = function () {
 15937              return round( new BigNumber(this), this.e + 1, 1 );
 15938          };
 15939  
 15940  
 15941  
 15942          /*
 15943           * Return as toString, but do not accept a base argument.
 15944           */
 15945          P.valueOf = P.toJSON = function () {
 15946              return this.toString();
 15947          };
 15948  
 15949  
 15950          // Aliases for BigDecimal methods.
 15951          //P.add = P.plus;         // P.add included above
 15952          //P.subtract = P.minus;   // P.sub included above
 15953          //P.multiply = P.times;   // P.mul included above
 15954          //P.divide = P.div;
 15955          //P.remainder = P.mod;
 15956          //P.compareTo = P.cmp;
 15957          //P.negate = P.neg;
 15958  
 15959  
 15960          if ( configObj != null ) BigNumber.config(configObj);
 15961  
 15962          return BigNumber;
 15963      }
 15964  
 15965  
 15966      // PRIVATE HELPER FUNCTIONS
 15967  
 15968  
 15969      function bitFloor(n) {
 15970          var i = n | 0;
 15971          return n > 0 || n === i ? i : i - 1;
 15972      }
 15973  
 15974  
 15975      // Return a coefficient array as a string of base 10 digits.
 15976      function coeffToString(a) {
 15977          var s, z,
 15978              i = 1,
 15979              j = a.length,
 15980              r = a[0] + '';
 15981  
 15982          for ( ; i < j; ) {
 15983              s = a[i++] + '';
 15984              z = LOG_BASE - s.length;
 15985              for ( ; z--; s = '0' + s );
 15986              r += s;
 15987          }
 15988  
 15989          // Determine trailing zeros.
 15990          for ( j = r.length; r.charCodeAt(--j) === 48; );
 15991          return r.slice( 0, j + 1 || 1 );
 15992      }
 15993  
 15994  
 15995      // Compare the value of BigNumbers x and y.
 15996      function compare( x, y ) {
 15997          var a, b,
 15998              xc = x.c,
 15999              yc = y.c,
 16000              i = x.s,
 16001              j = y.s,
 16002              k = x.e,
 16003              l = y.e;
 16004  
 16005          // Either NaN?
 16006          if ( !i || !j ) return null;
 16007  
 16008          a = xc && !xc[0];
 16009          b = yc && !yc[0];
 16010  
 16011          // Either zero?
 16012          if ( a || b ) return a ? b ? 0 : -j : i;
 16013  
 16014          // Signs differ?
 16015          if ( i != j ) return i;
 16016  
 16017          a = i < 0;
 16018          b = k == l;
 16019  
 16020          // Either Infinity?
 16021          if ( !xc || !yc ) return b ? 0 : !xc ^ a ? 1 : -1;
 16022  
 16023          // Compare exponents.
 16024          if ( !b ) return k > l ^ a ? 1 : -1;
 16025  
 16026          j = ( k = xc.length ) < ( l = yc.length ) ? k : l;
 16027  
 16028          // Compare digit by digit.
 16029          for ( i = 0; i < j; i++ ) if ( xc[i] != yc[i] ) return xc[i] > yc[i] ^ a ? 1 : -1;
 16030  
 16031          // Compare lengths.
 16032          return k == l ? 0 : k > l ^ a ? 1 : -1;
 16033      }
 16034  
 16035  
 16036      /*
 16037       * Return true if n is a valid number in range, otherwise false.
 16038       * Use for argument validation when ERRORS is false.
 16039       * Note: parseInt('1e+1') == 1 but parseFloat('1e+1') == 10.
 16040       */
 16041      function intValidatorNoErrors( n, min, max ) {
 16042          return ( n = truncate(n) ) >= min && n <= max;
 16043      }
 16044  
 16045  
 16046      function isArray(obj) {
 16047          return Object.prototype.toString.call(obj) == '[object Array]';
 16048      }
 16049  
 16050  
 16051      /*
 16052       * Convert string of baseIn to an array of numbers of baseOut.
 16053       * Eg. convertBase('255', 10, 16) returns [15, 15].
 16054       * Eg. convertBase('ff', 16, 10) returns [2, 5, 5].
 16055       */
 16056      function toBaseOut( str, baseIn, baseOut ) {
 16057          var j,
 16058              arr = [0],
 16059              arrL,
 16060              i = 0,
 16061              len = str.length;
 16062  
 16063          for ( ; i < len; ) {
 16064              for ( arrL = arr.length; arrL--; arr[arrL] *= baseIn );
 16065              arr[ j = 0 ] += ALPHABET.indexOf( str.charAt( i++ ) );
 16066  
 16067              for ( ; j < arr.length; j++ ) {
 16068  
 16069                  if ( arr[j] > baseOut - 1 ) {
 16070                      if ( arr[j + 1] == null ) arr[j + 1] = 0;
 16071                      arr[j + 1] += arr[j] / baseOut | 0;
 16072                      arr[j] %= baseOut;
 16073                  }
 16074              }
 16075          }
 16076  
 16077          return arr.reverse();
 16078      }
 16079  
 16080  
 16081      function toExponential( str, e ) {
 16082          return ( str.length > 1 ? str.charAt(0) + '.' + str.slice(1) : str ) +
 16083            ( e < 0 ? 'e' : 'e+' ) + e;
 16084      }
 16085  
 16086  
 16087      function toFixedPoint( str, e ) {
 16088          var len, z;
 16089  
 16090          // Negative exponent?
 16091          if ( e < 0 ) {
 16092  
 16093              // Prepend zeros.
 16094              for ( z = '0.'; ++e; z += '0' );
 16095              str = z + str;
 16096  
 16097          // Positive exponent
 16098          } else {
 16099              len = str.length;
 16100  
 16101              // Append zeros.
 16102              if ( ++e > len ) {
 16103                  for ( z = '0', e -= len; --e; z += '0' );
 16104                  str += z;
 16105              } else if ( e < len ) {
 16106                  str = str.slice( 0, e ) + '.' + str.slice(e);
 16107              }
 16108          }
 16109  
 16110          return str;
 16111      }
 16112  
 16113  
 16114      function truncate(n) {
 16115          n = parseFloat(n);
 16116          return n < 0 ? mathceil(n) : mathfloor(n);
 16117      }
 16118  
 16119  
 16120      // EXPORT
 16121  
 16122  
 16123      BigNumber = another();
 16124  
 16125      // AMD.
 16126      if ( typeof define == 'function' && define.amd ) {
 16127          define( function () { return BigNumber; } );
 16128  
 16129      // Node and other environments that support module.exports.
 16130      } else if ( typeof module != 'undefined' && module.exports ) {
 16131          module.exports = BigNumber;
 16132          if ( !crypto ) try { crypto = require('crypto'); } catch (e) {}
 16133  
 16134      // Browser.
 16135      } else {
 16136          global.BigNumber = BigNumber;
 16137      }
 16138  })(this);
 16139  
 16140  },{"crypto":50}],"web3":[function(require,module,exports){
 16141  var Web3 = require('./lib/web3');
 16142  
 16143  // dont override global variable
 16144  if (typeof window !== 'undefined' && typeof window.Web3 === 'undefined') {
 16145      window.Web3 = Web3;
 16146  }
 16147  
 16148  module.exports = Web3;
 16149  
 16150  },{"./lib/web3":22}]},{},["web3"])
 16151  //# sourceMappingURL=web3.js.map