"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports["default"] = convertData;
var _cloneDeep = _interopRequireDefault(require("lodash/cloneDeep"));
var _isPlainObject = _interopRequireDefault(require("lodash/isPlainObject"));
function convertData(data) {
  var dataSource = [];
  var currentPage = 1;
  var totalCount = 0;
  if (Array.isArray(data)) {
    dataSource = data;
  } else if ((0, _isPlainObject["default"])(data)) {
    dataSource = data.data;
    currentPage = typeof data.currentPage !== "undefined" ? parseInt(data.currentPage, 10) : 1;
    totalCount = typeof data.totalCount !== "undefined" ? parseInt(data.totalCount, 10) : 0;
  }
  return {
    dataSource: dataSource ? (0, _cloneDeep["default"])(dataSource) : [],
    currentPage: currentPage,
    totalCount: totalCount
  };
}