var _excluded = ["title", "decoratorProps"],
  _excluded2 = ["title", "dataIndex", "cell", "htmlTitle", "sortable", "width", "align", "alignHeader", "filters", "filterMode", "filterMenuProps", "lock", "resizable", "colSpan"];
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
var initializeColumn = function initializeColumn(item) {
  var title = item.title,
    _item$decoratorProps = item.decoratorProps,
    decoratorProps = _item$decoratorProps === void 0 ? {} : _item$decoratorProps,
    children = _objectWithoutProperties(item, _excluded);
  // 将Table.Column属性和组件FormItem属性通过decoratorProps统一传入，再分别赋值
  var columnTitle = decoratorProps.title,
    dataIndex = decoratorProps.dataIndex,
    cell = decoratorProps.cell,
    htmlTitle = decoratorProps.htmlTitle,
    sortable = decoratorProps.sortable,
    width = decoratorProps.width,
    align = decoratorProps.align,
    alignHeader = decoratorProps.alignHeader,
    filters = decoratorProps.filters,
    filterMode = decoratorProps.filterMode,
    filterMenuProps = decoratorProps.filterMenuProps,
    lock = decoratorProps.lock,
    resizable = decoratorProps.resizable,
    colSpan = decoratorProps.colSpan,
    formItemDecoratorProps = _objectWithoutProperties(decoratorProps, _excluded2);
  var columnProperties = {
    title: title !== null && title !== void 0 ? title : columnTitle,
    dataIndex: dataIndex,
    cell: cell,
    htmlTitle: htmlTitle,
    sortable: sortable,
    width: width,
    align: align,
    alignHeader: alignHeader,
    filters: filters,
    filterMode: filterMode,
    filterMenuProps: filterMenuProps,
    lock: lock,
    resizable: resizable,
    colSpan: colSpan
  };
  return {
    component: 'ArrayTable.Column',
    props: columnProperties,
    children: [_objectSpread(_objectSpread({}, children), {}, {
      decoratorProps: formItemDecoratorProps
    })]
  };
};
var initializeItems = function initializeItems(items) {
  if (items) {
    var _items$children;
    return _objectSpread(_objectSpread({}, items), {}, {
      name: 'items',
      children: (_items$children = items.children) === null || _items$children === void 0 ? void 0 : _items$children.map(function (item) {
        return initializeColumn(item);
      })
    });
  }
  return items;
};
var initialize = function initialize(item) {
  var _item$props = item.props,
    props = _item$props === void 0 ? {} : _item$props,
    items = item.items;
  return _objectSpread(_objectSpread({}, item), {}, {
    props: _objectSpread({
      pagination: {
        pageSize: 10
      }
    }, props),
    items: items ? initializeItems(items) : {}
  });
};
export default initialize;