/**
 * ldesign v0.3.13
 * (c) 2023 ldesign
 * @license MIT
 */

import { _ as _defineProperty } from '../_chunks/dep-2db7b3ec.mjs';
import { defineComponent, toRefs, h, createVNode, mergeProps } from 'vue';
import { i as isString_1 } from '../_chunks/dep-876fb3ec.mjs';
import { i as isFunction_1 } from '../_chunks/dep-5717e263.mjs';
import { g as get_1 } from '../_chunks/dep-c81c0ee4.mjs';
import { useTNodeJSX } from '../hooks/tnode.mjs';
import { formatRowAttributes, formatRowClassNames } from './utils.mjs';
import { getColumnFixedStyles } from './hooks/useFixed.mjs';
import useRowspanAndColspan, { getCellKey } from './hooks/useRowspanAndColspan.mjs';
import useClassName from './hooks/useClassName.mjs';
import '../_chunks/dep-255303ba.mjs';
import '../_chunks/dep-eba0ea6e.mjs';
import '../_chunks/dep-469b4ae0.mjs';
import '../_chunks/dep-b57180d0.mjs';
import '../_chunks/dep-c8d7b6b4.mjs';
import '../_chunks/dep-3da99438.mjs';
import '../_chunks/dep-a8bcacea.mjs';
import '../_chunks/dep-0d3dd4b5.mjs';
import '../_chunks/dep-2bc37d52.mjs';
import '../_chunks/dep-bc1d737a.mjs';
import '../_chunks/dep-4d7a675b.mjs';
import '../_chunks/dep-2e7f59b1.mjs';
import '../_chunks/dep-855db8bc.mjs';
import '../_chunks/dep-42cc3015.mjs';
import '../_chunks/dep-406cd044.mjs';
import '../_chunks/dep-327559e8.mjs';
import '../_chunks/dep-b2235f26.mjs';
import '../_chunks/dep-8b989474.mjs';
import '../_chunks/dep-1372b2d3.mjs';
import '../_chunks/dep-9a85dac1.mjs';
import '../utils/render-tnode.mjs';
import '../_chunks/dep-888e80c4.mjs';
import '../_chunks/dep-334a4f6b.mjs';
import '../_chunks/dep-e5eb9f23.mjs';
import '../_chunks/dep-9fe2ef12.mjs';
import '../_chunks/dep-672e7d1a.mjs';
import '../_chunks/dep-1434aa15.mjs';
import '../_chunks/dep-9262ee2f.mjs';
import '../_chunks/dep-84acf3c2.mjs';
import '../_chunks/dep-b8d7992c.mjs';
import '../_chunks/dep-78847b2e.mjs';
import '../_chunks/dep-9b6cf76d.mjs';
import '../_chunks/dep-f709f709.mjs';
import '../_common/js/log/index.mjs';
import '../_common/js/log/log.mjs';
import '../_common/js/utils/getScrollbarWidth.mjs';
import '../_common/js/utils/helper.mjs';
import '../_chunks/dep-bf1e33c8.mjs';
import '../_chunks/dep-60fae668.mjs';
import '../_chunks/dep-ed5ebb35.mjs';
import '../_chunks/dep-3f21269a.mjs';
import '../utils/dom.mjs';
import '../utils/easing.mjs';
import '../hooks/useConfig.mjs';
import '../config-provider/useConfig.mjs';
import '../_chunks/dep-095107f7.mjs';
import '../_chunks/dep-c989dff3.mjs';
import '../_chunks/dep-9cf86cf1.mjs';
import '../_chunks/dep-a87f3e4c.mjs';
import '../_chunks/dep-1e566bb5.mjs';
import '../_chunks/dep-42a19209.mjs';
import '../_chunks/dep-8d3e9aa3.mjs';
import '../_chunks/dep-40d69a9c.mjs';
import '../_chunks/dep-dcc83161.mjs';
import '../_chunks/dep-0fc02184.mjs';
import '../_chunks/dep-f1994936.mjs';
import '../_chunks/dep-345e1be3.mjs';
import '../_common/js/global-config/default-config.mjs';
import '../_common/js/global-config/locale/zh_CN.mjs';
import '../_chunks/dep-9888611c.mjs';
import '../_chunks/dep-697a1365.mjs';
import '../config-provider/type.mjs';

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; }
var TFoot = defineComponent({
  name: "TFoot",
  props: {
    rowKey: String,
    isFixedHeader: Boolean,
    rowAndColFixedPosition: Map,
    footData: Array,
    columns: Array,
    rowAttributes: [Array, Object, Function],
    rowClassName: [Array, String, Object, Function],
    thWidthList: [Object],
    footerSummary: [String, Function],
    rowspanAndColspanInFooter: Function
  },
  setup: function setup(props, context) {
    var renderTNode = useTNodeJSX();
    var classnames = useClassName();
    var _toRefs = toRefs(props),
      footData = _toRefs.footData,
      columns = _toRefs.columns,
      rowKey = _toRefs.rowKey,
      rowspanAndColspanInFooter = _toRefs.rowspanAndColspanInFooter;
    var _useRowspanAndColspan = useRowspanAndColspan(footData, columns, rowKey, rowspanAndColspanInFooter),
      skipSpansMap = _useRowspanAndColspan.skipSpansMap;
    var renderTFootCell = function renderTFootCell(p) {
      var col = p.col,
        row = p.row;
      if (isFunction_1(col.foot)) return col.foot(h, p);
      if (isString_1(col.foot) && context.slots[col.foot]) return context.slots[col.foot](p) || col.foot;
      return col.foot || get_1(row, col.colKey);
    };
    return _objectSpread(_objectSpread({
      skipSpansMap: skipSpansMap
    }, classnames), {}, {
      renderTFootCell: renderTFootCell,
      renderTNode: renderTNode
    });
  },
  render: function render() {
    var _this$footData,
      _this = this;
    if (!this.columns) return null;
    var theadClasses = [this.tableFooterClasses.footer, _defineProperty({}, this.tableFooterClasses.fixed, this.isFixedHeader)];
    var footerDomList = (_this$footData = this.footData) === null || _this$footData === void 0 ? void 0 : _this$footData.map(function (row, rowIndex) {
      var trAttributes = formatRowAttributes(_this.rowAttributes, {
        row: row,
        rowIndex: rowIndex,
        type: "foot"
      });
      var customClasses = formatRowClassNames(_this.rowClassName, {
        row: row,
        rowIndex: rowIndex,
        type: "foot"
      }, _this.rowKey || "id");
      return createVNode("tr", mergeProps(trAttributes, {
        "key": rowIndex,
        "class": customClasses
      }), [_this.columns.map(function (col, colIndex) {
        var _this$thWidthList;
        var cellSpans = {};
        var spanState = null;
        if (_this.skipSpansMap.size) {
          var _spanState, _spanState2;
          var cellKey = getCellKey(row, _this.rowKey, col.colKey, colIndex);
          spanState = _this.skipSpansMap.get(cellKey) || {};
          ((_spanState = spanState) === null || _spanState === void 0 ? void 0 : _spanState.rowspan) > 1 && (cellSpans.rowspan = spanState.rowspan);
          ((_spanState2 = spanState) === null || _spanState2 === void 0 ? void 0 : _spanState2.colspan) > 1 && (cellSpans.colspan = spanState.colspan);
          if (spanState.skipped) return null;
        }
        var tdStyles = getColumnFixedStyles(col, colIndex, _this.rowAndColFixedPosition, _this.tableColFixedClasses);
        var style = _objectSpread({}, tdStyles.style);
        if ((_this$thWidthList = _this.thWidthList) !== null && _this$thWidthList !== void 0 && _this$thWidthList[col.colKey]) style.width = "".concat(_this.thWidthList[col.colKey], "px");
        return createVNode("td", mergeProps(_objectSpread({
          key: col.colKey
        }, cellSpans), {
          "class": tdStyles.classes,
          "style": style
        }), [_this.renderTFootCell({
          row: row,
          rowIndex: rowIndex,
          col: col,
          colIndex: colIndex
        })]);
      })]);
    });
    var footerSummary = this.renderTNode("footerSummary");
    if (!footerSummary && (!this.footData || !this.footData.length)) return null;
    return createVNode("tfoot", {
      "ref": "tFooterRef",
      "class": theadClasses
    }, [footerSummary && createVNode("tr", {
      "class": this.tableFullRowClasses.base
    }, [createVNode("td", {
      "colspan": this.columns.length
    }, [createVNode("div", {
      "class": this.tableFullRowClasses.innerFullElement
    }, [footerSummary])])]), footerDomList]);
  }
});

export { TFoot as default };
//# sourceMappingURL=tfoot.mjs.map
