'use strict';

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

var vue = require('vue');
require('../../../../utils/index.cjs');
require('../../../../vue-components/index.cjs');
var useSelection = require('./useSelection.cjs');
var constant = require('../../../../vue-components/vc-table/src/constant.cjs');
var log = require('../../../../utils/log.cjs');

function fillSlots(columns, contextSlots) {
  const $slots = contextSlots.value;
  return columns.map((column) => {
    var _a;
    if (column === useSelection.SELECTION_COLUMN || column === constant.EXPAND_COLUMN)
      return column;
    const cloneColumn = {
      ...column
    };
    const {
      slots = {}
    } = cloneColumn;
    cloneColumn.__originColumn__ = column;
    log.devWarning(!("slots" in cloneColumn), "Table", "`column.slots` is deprecated. Please use `v-slot:headerCell` `v-slot:bodyCell` instead.");
    Object.keys(slots).forEach((key) => {
      const name = slots[key];
      if (cloneColumn[key] === void 0 && $slots[name])
        cloneColumn[key] = $slots[name];
    });
    if (contextSlots.value.headerCell && !((_a = column.slots) == null ? void 0 : _a.title)) {
      cloneColumn.title = vue.renderSlot(contextSlots.value, "headerCell", {
        title: column.title,
        column
      }, () => [column.title]);
    }
    if ("children" in cloneColumn && Array.isArray(cloneColumn.children))
      cloneColumn.children = fillSlots(cloneColumn.children, contextSlots);
    return cloneColumn;
  });
}
function useColumns(contextSlots) {
  const filledColumns = (columns) => fillSlots(columns, contextSlots);
  return [filledColumns];
}

exports.default = useColumns;
//# sourceMappingURL=useColumns.cjs.map
