'use strict';

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

var vue = require('vue');
var index = require('../Cell/index.cjs');
var TableContext = require('../context/TableContext.cjs');
var fixUtil = require('../utils/fixUtil.cjs');
var valueUtil = require('../utils/valueUtil.cjs');
var DragHandle = require('./DragHandle.cjs');

var HeaderRow = /* @__PURE__ */ vue.defineComponent({
  name: "HeaderRow",
  props: ["cells", "stickyOffsets", "flattenColumns", "rowComponent", "cellComponent", "index", "customHeaderRow"],
  setup(props) {
    const tableContext = TableContext.useInjectTable();
    return () => {
      const {
        prefixCls,
        direction
      } = tableContext;
      const {
        cells,
        stickyOffsets,
        flattenColumns,
        rowComponent: RowComponent,
        cellComponent: CellComponent,
        customHeaderRow,
        index: index$1
      } = props;
      let rowProps;
      if (customHeaderRow) {
        rowProps = customHeaderRow(cells.map((cell) => cell.column), index$1);
      }
      const columnsKey = valueUtil.getColumnsKey(cells.map((cell) => cell.column));
      return vue.createVNode(RowComponent, rowProps, {
        default: () => [cells.map((cell, cellIndex) => {
          const {
            column
          } = cell;
          const fixedInfo = fixUtil.getCellFixedInfo(cell.colStart, cell.colEnd, flattenColumns, stickyOffsets, direction);
          let additionalProps;
          if (column && column.customHeaderCell)
            additionalProps = cell.column.customHeaderCell(column);
          const col = column;
          return vue.createVNode(index.default, {
            ...cell,
            "cellType": "header",
            "ellipsis": column.ellipsis,
            "align": column.align,
            "component": CellComponent,
            "prefixCls": prefixCls,
            "key": columnsKey[cellIndex],
            ...fixedInfo,
            "additionalProps": additionalProps,
            "rowType": "header",
            "column": column
          }, {
            default: () => column.title,
            dragHandle: () => col.resizable ? vue.createVNode(DragHandle.default, {
              "prefixCls": prefixCls,
              "width": col.width,
              "minWidth": col.minWidth,
              "maxWidth": col.maxWidth,
              "column": col
            }, null) : null
          });
        })]
      });
    };
  }
});

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