"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports["default"] = getCleanRowData;
var _isPlainObject = _interopRequireDefault(require("lodash/isPlainObject"));
var _forOwn = _interopRequireDefault(require("lodash/forOwn"));
var _isArray = _interopRequireDefault(require("lodash/isArray"));
function deepCopyExcept(data, callback) {
  var dest, i, shouldExcept, newValue;
  if ((0, _isPlainObject["default"])(data)) {
    dest = {};
    (0, _forOwn["default"])(data, function (value, key) {
      newValue = deepCopyExcept(value, callback);
      shouldExcept = callback(newValue, key);
      if (!shouldExcept) {
        dest[key] = newValue;
      }
    });
  } else if ((0, _isArray["default"])(data)) {
    dest = [];
    for (i = 0; i < data.length; i++) {
      newValue = deepCopyExcept(data[i], callback);
      shouldExcept = callback(newValue, i);
      if (!shouldExcept) {
        dest.push(newValue);
      }
    }
  } else {
    return data;
  }
  return dest;
}
;
function getCleanRowData(rowData) {
  if (rowData) {
    var blackList = ['__mode__', '__fields__', '__expand__'];
    return deepCopyExcept(rowData, function (value, key) {
      return blackList.indexOf(key) !== -1;
    });
  }
}