/**
 * ldesign v0.2.14
 * (c) 2022/11/2 16:16 built by swimly
 * @license MIT
 */

'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var helper = require('../../../chunks/helper.js');
var VueCompositionAPI = require('@vue/composition-api');
var components_table_props = require('../props.js');
var components_table_hooks_useTreeData = require('../hooks/useTreeData.js');
var components_table_hooks_useTreeSelect = require('../hooks/useTreeSelect.js');
var components_table_core_primaryTable = require('./primary-table.js');
var components_table_core_baseTable = require('./base-table.js');
require('@ldesign/icons-vue');
require('lodash/cloneDeep');
require('lodash/get');
require('../../../chunks/defineProperty-838e4192.js');
require('../../../chunks/get-5e1abd10.js');
require('../../../chunks/isArray-cd7357b9.js');
require('../../../chunks/isSymbol-a38a5184.js');
require('../../../chunks/isObjectLike-c22c7e3b.js');
require('../../../chunks/_commonjsHelpers-2e6815bd.js');
require('../../../chunks/isFunction-91acade7.js');
require('../../../chunks/log.js');
require('../../../chunks/utils3.js');
require('../../../chunks/isNumber-c4eb560e.js');
require('./tr.js');
require('lodash/isFunction');
require('lodash/upperFirst');
require('lodash/isString');
require('lodash/pick');
require('../../../hooks/use-lazy-load.js');
require('../../../chunks/observe.js');
require('../utils.js');
require('lodash/isObject');
require('../hooks/useFixed.js');
require('lodash/debounce');
require('../../../chunks/helper2.js');
require('../../../utils/dom.js');
require('vue');
require('raf');
require('../../../utils/easing.js');
require('../hooks/useClassName.js');
require('../../config-provider/useConfig.js');
require('../../config-provider/context.js');
require('lodash');
require('../../../chunks/zh_CN.js');
require('../hooks/useRowspanAndColspan.js');
require('./ellipsis.js');
require('../../../utils/render-node.js');
require('../../tooltip/index.js');
require('../../../utils/map-props.js');
require('../../../utils/with-install.js');
require('../../../config.js');
require('../../tooltip/tooltip.js');
require('../../popup/props.js');
require('../../popup/popup.js');
require('@popperjs/core');
require('../../../chunks/set-style.js');
require('../../../utils/helper.js');
require('lodash/camelCase');
require('../../config-provider/config-receiver.js');
require('lodash/mergeWith');
require('../../../utils/mixins.js');
require('../../popup/container.js');
require('../../tooltip/props.js');
require('../../../hooks/lnode.js');
require('lodash/isEmpty');
require('lodash/kebabCase');
require('../../../hooks/render-lnode.js');
require('../../../hooks/use-global-icon.js');
require('lodash/intersection');
require('../../../hooks/use-default-value.js');
require('lodash/omit');
require('../hooks/useColumnController.js');
require('../../checkbox/index.js');
require('../../checkbox/group.js');
require('../../../utils/event.js');
require('../../checkbox/checkbox.js');
require('../../checkbox/props.js');
require('../../dialog/plugin.js');
require('../../dialog/dialog.js');
require('lodash/isNumber');
require('lodash/throttle');
require('../../button/index.js');
require('../../button/button.js');
require('../../loading/index.js');
require('../../loading/loading.js');
require('../../../utils/transfer-dom.js');
require('../../loading/props.js');
require('../../loading/icon/gradient.js');
require('../../loading/plugin.js');
require('../../../utils/ripple.js');
require('../../button/props.js');
require('../../../hooks/use-destroy-onclose.js');
require('../../dialog/props.js');
require('../../dialog/mixins/action.js');
require('../../dialog/stack.js');
require('../hooks/useTableHeader.js');
require('../hooks/useMultiHeader.js');
require('../hooks/useRowExpand.js');
require('../hooks/useRowSelect.js');
require('../../radio/index.js');
require('../../radio/radio.js');
require('../../radio/props.js');
require('../../radio/group.js');
require('../../radio/radio-button.js');
require('../hooks/useSorter.js');
require('./sorter-button.js');
require('../hooks/useFilter.js');
require('./filter-controller.js');
require('lodash/lowerFirst');
require('../../popup/index.js');
require('../../input/index.js');
require('../../input/input.js');
require('../../input/props.js');
require('../../input/group.js');
require('../hooks/useDragSort.js');
require('sortablejs');
require('../hooks/useAsyncLoading.js');
require('../hooks/useEditableCell.js');
require('./editable-cell.js');
require('lodash/set');
require('../../form/model.js');
require('../../../chunks/_commonjsHelpers.js');
require('../hooks/useEditableRow.js');
require('../hooks/useStyle.js');
require('../../../hooks/use-common-classname.js');
require('../../../hooks/use-virtual-scroll.js');
require('../../affix/index.js');
require('../../affix/affix.js');
require('../../affix/props.js');
require('../hooks/useColumnResize.js');
require('../hooks/usePagination.js');
require('../../pagination/index.js');
require('../../pagination/pagination.js');
require('../../input-number/index.js');
require('../../input-number/input-number.js');
require('../../input-number/props.js');
require('../../input-number/hooks/use-input-number.js');
require('../../../hooks/use-vmodel.js');
require('../../../hooks/use-form-disabled.js');
require('../../select/index.js');
require('../../select/select.js');
require('lodash/isArray');
require('../../tag/index.js');
require('../../tag/tag.js');
require('../../tag/props.js');
require('../../tag/check-tag.js');
require('../../select-input/index.js');
require('../../select-input/select-input.js');
require('../../select-input/props.js');
require('../../select-input/hooks/use-single.js');
require('../../../hooks/use-config.js');
require('../../select-input/hooks/use-multiple.js');
require('../../tag-input/index.js');
require('../../tag-input/tag-input.js');
require('../../tag-input/props.js');
require('../../tag-input/hooks/use-tag-scroll.js');
require('../../tag-input/hooks/use-tag-list.js');
require('../../tag-input/hooks/use-hover.js');
require('../../tag-input/hooks/use-drag-sorter.js');
require('../../select-input/hooks/use-overlay-innerstyle.js');
require('../../common/fake-arrow.js');
require('../../select/option.js');
require('../../select/utils.js');
require('../../select/props.js');
require('../../select/select-panel.js');
require('../../select/hooks/use-select-options.js');
require('../../select/option-group.js');
require('../../input-adornment/index.js');
require('../../input-adornment/input-adornment.js');
require('../../input-adornment/props.js');
require('../../pagination/props.js');
require('../hooks/useAffix.js');
require('./tbody.js');
require('./thead.js');
require('./tfoot.js');

const PRIMARY_B_EVENTS = ["cell-click", "change", "page-change", "expand-change", "filter-change", "select-change", "sort-change", "data-change", "async-loading-click", "column-change", "column-controller-visible-change", "display-columns-change", "drag-sort", "row-edit", "row-validate", "validate"];
const PRIMARY_ALL_EVENTS = components_table_core_baseTable.BASE_TABLE_ALL_EVENTS.concat(PRIMARY_B_EVENTS);
var _EnhancedTable = VueCompositionAPI.defineComponent({
  name: "LEnhancedTable",
  props: {
    ...components_table_props.BaseTableProps,
    ...components_table_props.PrimaryTableProps,
    ...components_table_props.EnhancedTableProps
  },
  setup(props, context) {
    const enhancedTableRef = VueCompositionAPI.ref();
    const {
      store,
      dataSource,
      formatTreeColumn,
      swapData,
      ...treeInstanceFunctions
    } = components_table_hooks_useTreeData["default"](props, context);
    const treeDataMap = VueCompositionAPI.ref(store.value.treeDataMap);
    const {
      tIndeterminateSelectedRowKeys,
      onInnerSelectChange
    } = components_table_hooks_useTreeSelect["default"](props, treeDataMap);
    const getColumns = columns => {
      const arr = [];
      for (let i = 0, len = columns.length; i < len; i++) {
        var _item$children, _item$children2;
        let item = {
          ...columns[i]
        };
        item = formatTreeColumn(item);
        if ((_item$children = item.children) !== null && _item$children !== void 0 && _item$children.length) item.children = getColumns(item.children);
        if (!item.children || (_item$children2 = item.children) !== null && _item$children2 !== void 0 && _item$children2.length) arr.push(item);
      }
      return arr;
    };
    const tColumns = VueCompositionAPI.computed(() => {
      const isTreeData = !props.tree || !Object.keys(props.tree).length;
      return isTreeData ? props.columns : getColumns(props.columns);
    });
    const onDragSortChange = params => {
      var _props$onDragSort;
      if (props.beforeDragSort && !props.beforeDragSort(params)) return;
      swapData({
        current: params.current,
        target: params.target,
        currentIndex: params.currentIndex,
        targetIndex: params.targetIndex
      });
      (_props$onDragSort = props.onDragSort) === null || _props$onDragSort === void 0 ? void 0 : _props$onDragSort.call(props, params);
      context.emit("drag-sort", params);
    };
    return {
      store,
      dataSource,
      tColumns,
      tIndeterminateSelectedRowKeys,
      enhancedTableRef,
      onDragSortChange,
      onInnerSelectChange,
      ...treeInstanceFunctions
    };
  },
  methods: {
    getListener() {
      var _this = this;
      const listeners = {};
      PRIMARY_ALL_EVENTS.forEach(key => {
        listeners[key] = function () {
          for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
            args[_key] = arguments[_key];
          }
          _this.$emit(key, ...args);
          if (key === "display-columns-change") _this.$emit("update:displayColumns", ...args);
        };
      });
      return listeners;
    }
  },
  render() {
    const h = arguments[0];
    const props = {
      ...this.$options.propsData,
      data: this.dataSource,
      columns: this.tColumns,
      indeterminateSelectedRowKeys: this.tIndeterminateSelectedRowKeys,
      disableDataPage: Boolean(this.tree && Object.keys(this.tree).length)
    };
    const on = {
      ...this.getListener(),
      "select-change": this.onInnerSelectChange,
      "drag-sort": this.onDragSortChange
    };
    return h(components_table_core_primaryTable["default"], helper.helper([{
      "ref": "enhancedTableRef",
      "scopedSlots": this.$scopedSlots
    }, {
      "props": props
    }, {}, {
      "on": on
    }, {}, this.$attrs]));
  }
});

exports["default"] = _EnhancedTable;
//# sourceMappingURL=enhanced-table.js.map
