import React__default, { forwardRef, useContext, useMemo, useRef, useState, useImperativeHandle, useCallback } from "react";
import debounce_1 from "../../../../../../lodash@4.17.21/node_modules/lodash/debounce.js";
import throttle_1 from "../../../../../../lodash@4.17.21/node_modules/lodash/throttle.js";
import Tween from "../../../../../../b-tween@0.3.3/node_modules/b-tween/dist/b-tween.es.js";
import { isObject, isArray } from "../_util/is.js";
import cs from "../_util/classNames.js";
import Spin from "../Spin/index.js";
import THead from "./thead/index.js";
import TBody from "./tbody/index.js";
import Tfoot from "./tfoot/index.js";
import Pagination from "../Pagination/pagination.js";
import { on, off } from "../_util/dom.js";
import { ConfigContext } from "../ConfigProvider/index.js";
import { deepCloneData, getOriginData, getScrollBarHeight, getScrollBarWidth } from "./utils.js";
import ColGroup from "./colgroup.js";
import useExpand from "./hooks/useExpand.js";
import useRowSelection from "./hooks/useRowSelection.js";
import useComponent from "./hooks/useComponent.js";
import useStickyOffsets from "./hooks/useStickyOffsets.js";
import useStickyClassNames from "./hooks/useStickyClassNames.js";
import useColumns from "./hooks/useColumns.js";
import useUpdate from "../_util/hooks/useUpdate.js";
import ResizeObserver from "../_util/resizeObserver.js";
import useMergeProps from "../_util/hooks/useMergeProps.js";
import useIsomorphicLayoutEffect from "../_util/hooks/useIsomorphicLayoutEffect.js";
import { pickDataAttributes } from "../_util/pick.js";
import { jsx, jsxs, Fragment } from "../../../../../../@emotion_react@11.10.4_3toe27fv7etiytxb5kxc7fxaw4/node_modules/@emotion/react/jsx-runtime/dist/emotion-react-jsx-runtime.browser.esm.js";
var __assign = globalThis && globalThis.__assign || function() {
  __assign = Object.assign || function(t) {
    for (var s, i = 1, n = arguments.length; i < n; i++) {
      s = arguments[i];
      for (var p in s)
        if (Object.prototype.hasOwnProperty.call(s, p))
          t[p] = s[p];
    }
    return t;
  };
  return __assign.apply(this, arguments);
};
var __read = globalThis && globalThis.__read || function(o, n) {
  var m = typeof Symbol === "function" && o[Symbol.iterator];
  if (!m)
    return o;
  var i = m.call(o), r, ar = [], e;
  try {
    while ((n === void 0 || n-- > 0) && !(r = i.next()).done)
      ar.push(r.value);
  } catch (error) {
    e = {
      error
    };
  } finally {
    try {
      if (r && !r.done && (m = i["return"]))
        m.call(i);
    } finally {
      if (e)
        throw e.error;
    }
  }
  return ar;
};
var defaultProps = {
  showHeader: true,
  border: true,
  hover: true,
  rowKey: "key",
  pagePosition: "br",
  childrenColumnName: "children",
  indentSize: 15,
  showSorterTooltip: true
};
function Table(baseProps, ref) {
  var _a, _b;
  var _c, _d;
  var _e = useContext(ConfigContext), getPrefixCls = _e.getPrefixCls, loadingElement = _e.loadingElement, ctxSize = _e.size, tablePagination = _e.tablePagination, renderEmpty = _e.renderEmpty, componentConfig = _e.componentConfig, rtl = _e.rtl;
  var props = useMergeProps(baseProps, defaultProps, componentConfig === null || componentConfig === void 0 ? void 0 : componentConfig.Table);
  var mergePagination = useMergeProps(isObject(baseProps === null || baseProps === void 0 ? void 0 : baseProps.pagination) ? baseProps === null || baseProps === void 0 ? void 0 : baseProps.pagination : {}, isObject((_c = componentConfig === null || componentConfig === void 0 ? void 0 : componentConfig.Table) === null || _c === void 0 ? void 0 : _c.pagination) ? (_d = componentConfig === null || componentConfig === void 0 ? void 0 : componentConfig.Table) === null || _d === void 0 ? void 0 : _d.pagination : {}, tablePagination || {});
  var style = props.style, className = props.className, components = props.components, border = props.border, borderCell = props.borderCell, _f = props.columns, columns = _f === void 0 ? [] : _f, _g = props.data, data = _g === void 0 ? [] : _g, scroll = props.scroll, noDataElement = props.noDataElement, showHeader = props.showHeader, stripe = props.stripe, hover = props.hover, pagination = props.pagination, onChange = props.onChange, pagePosition = props.pagePosition, childrenColumnName = props.childrenColumnName, indentSize = props.indentSize, rowSelection = props.rowSelection, tableLayoutFixed = props.tableLayoutFixed, footer = props.footer, virtualized = props.virtualized, renderPagination = props.renderPagination, summary = props.summary, rowKey = props.rowKey;
  var clonedData = useMemo(function() {
    return deepCloneData(data, childrenColumnName);
  }, [data, childrenColumnName]);
  var prefixCls = getPrefixCls("table");
  var size = props.size || (["default", "middle", "small"].indexOf(ctxSize) > -1 ? ctxSize : "default");
  var refTableHead = useRef(null);
  var refTableBody = useRef(null);
  var refTableFoot = useRef(null);
  var refTable = useRef(null);
  var refTableNF = useRef(null);
  var lastScrollLeft = useRef(0);
  var scrollbarChanged = useRef(false);
  var _h = getDefaultFiltersAndSorter(columns), currentFilters = _h.currentFilters, currentSorter = _h.currentSorter;
  var _j = __read(useState(1), 2), currentPage = _j[0], setCurrentPage = _j[1];
  var _k = __read(useState(mergePagination.pageSize || mergePagination.defaultPageSize || 10), 2), innerPageSize = _k[0], setInnerPageSize = _k[1];
  var _l = __read(useState(currentFilters), 2), filters = _l[0], setFilters = _l[1];
  var _m = __read(useState(currentSorter), 2), sorter = _m[0], setSorter = _m[1];
  var _o = __read(useState(0), 2), tableViewWidth = _o[0], setTableViewWidth = _o[1];
  var _p = __read(useColumns(props), 2), groupColumns = _p[0], flattenColumns = _p[1];
  var stickyOffsets = useStickyOffsets(flattenColumns);
  var _q = __read(useStickyClassNames(groupColumns, flattenColumns, prefixCls), 2), groupStickyClassNames = _q[0], stickyClassNames = _q[1];
  var _r = useComponent(components), ComponentTable = _r.ComponentTable, ComponentBodyWrapper = _r.ComponentBodyWrapper, ComponentHeaderWrapper = _r.ComponentHeaderWrapper;
  var getRowKey = useMemo(function() {
    if (typeof rowKey === "function") {
      return function(record) {
        return rowKey(getOriginData(record));
      };
    }
    return function(record) {
      return record[rowKey];
    };
  }, [rowKey]);
  function getDefaultFiltersAndSorter(columns2) {
    var currentFilters2 = {};
    var currentSorter2 = {};
    function travel(columns3) {
      if (columns3 && columns3.length > 0) {
        columns3.forEach(function(column, index) {
          var innerDataIndex = column.dataIndex === void 0 ? index : column.dataIndex;
          if (!column[childrenColumnName]) {
            if (column.defaultFilters) {
              currentFilters2[innerDataIndex] = column.defaultFilters;
            }
            if (column.filteredValue) {
              currentFilters2[innerDataIndex] = column.filteredValue;
            }
            if (column.defaultSortOrder) {
              currentSorter2.field = innerDataIndex;
              currentSorter2.direction = column.defaultSortOrder;
            }
            if (column.sortOrder) {
              currentSorter2.field = innerDataIndex;
              currentSorter2.direction = column.sortOrder;
            }
          } else {
            travel(column[childrenColumnName]);
          }
        });
      }
    }
    travel(columns2);
    return {
      currentFilters: currentFilters2,
      currentSorter: currentSorter2
    };
  }
  var controlledFilter = useMemo(function() {
    var flattenFilteredValueColumns = flattenColumns.filter(function(column) {
      return "filteredValue" in column;
    });
    var newFilters = {};
    if (flattenFilteredValueColumns.length) {
      flattenFilteredValueColumns.forEach(function(column, index) {
        var innerDataIndex = column.dataIndex === void 0 ? index : column.dataIndex;
        if (innerDataIndex !== void 0) {
          newFilters[innerDataIndex] = column.filteredValue;
        }
      });
    }
    return newFilters;
  }, [flattenColumns]);
  var controlledSorter = useMemo(function() {
    var flattenSortOrderColumns = flattenColumns.filter(function(column2) {
      return "sortOrder" in column2;
    });
    var length = flattenSortOrderColumns.length;
    while (length--) {
      var column = flattenSortOrderColumns[length];
      if (column.sortOrder || length === 0) {
        return {
          field: column.dataIndex,
          direction: column.sortOrder
        };
      }
    }
    return null;
  }, [flattenColumns]);
  var innerSorter = controlledSorter || sorter || {};
  var innerFilters = useMemo(function() {
    return Object.keys(controlledFilter).length ? controlledFilter : filters;
  }, [filters, controlledFilter]);
  function onSort(direction, field) {
    var newSorter = {
      field,
      direction
    };
    !controlledSorter && setSorter(newSorter);
    var newProcessedData = getProcessedData(newSorter, innerFilters);
    var currentData = getPageData(newProcessedData);
    onChange && onChange(getPaginationProps(newProcessedData), newSorter, innerFilters, {
      currentData: getOriginData(currentData),
      action: "sort"
    });
  }
  function sorterFn(sorter2, direction) {
    if (typeof sorter2 !== "function") {
      return;
    }
    return function(a, b) {
      var result = sorter2(a, b);
      return direction === "descend" ? -result : result;
    };
  }
  function onHandleFilter(column, filter) {
    var _a2;
    var newFilters = __assign(__assign({}, innerFilters), (_a2 = {}, _a2[column.dataIndex] = filter, _a2));
    var mergedFilters = __assign(__assign({}, newFilters), controlledFilter);
    if (isArray(filter) && filter.length) {
      setFilters(mergedFilters);
      var newProcessedData = getProcessedData(innerSorter, newFilters);
      var currentData = getPageData(newProcessedData);
      onChange && onChange(getPaginationProps(newProcessedData), innerSorter, newFilters, {
        currentData: getOriginData(currentData),
        action: "filter"
      });
    } else if (isArray(filter) && !filter.length) {
      onHandleFilterReset(column);
    }
  }
  function onHandleFilterReset(_a2) {
    var dataIndex = _a2.dataIndex;
    var newFilters = __assign({}, innerFilters);
    delete newFilters[dataIndex];
    setFilters(newFilters);
    var newProcessedData = getProcessedData(innerSorter, newFilters);
    var currentData = getPageData(newProcessedData);
    onChange && onChange(getPaginationProps(newProcessedData), innerSorter, newFilters, {
      currentData: getOriginData(currentData),
      action: "filter"
    });
  }
  var hasFixedColumnLeft = !!flattenColumns.find(function(c) {
    return c.fixed === "left";
  });
  var hasFixedColumnRight = !!flattenColumns.find(function(c) {
    return c.fixed === "right";
  });
  var hasFixedColumn = hasFixedColumnLeft || hasFixedColumnRight;
  function getProcessedData(sorter2, filters2) {
    var _data = (clonedData || []).slice();
    Object.keys(filters2).forEach(function(field) {
      if (filters2[field] && filters2[field].length) {
        var column_1 = getColumnByDataIndex(field);
        if (column_1 && typeof column_1.onFilter === "function") {
          _data = _data.filter(function(row) {
            return filters2[field].reduce(function(pre, cur) {
              return pre || column_1.onFilter(cur, row);
            }, false);
          });
        }
      }
    });
    var column = getColumnByDataIndex(sorter2.field);
    var getSortData = function(d) {
      return d.slice().sort(sorterFn(column.sorter, sorter2.direction)).map(function(item) {
        var _a2;
        if (isArray(item[childrenColumnName])) {
          return __assign(__assign({}, item), (_a2 = {}, _a2[childrenColumnName] = getSortData(item[childrenColumnName]), _a2));
        }
        return item;
      });
    };
    if (sorter2.direction && column && typeof column.sorter === "function") {
      return getSortData(_data);
    }
    return _data;
  }
  var processedData = getProcessedData(innerSorter, innerFilters);
  function getPaginationProps(_processedData) {
    if (_processedData === void 0) {
      _processedData = processedData;
    }
    var pageSize = mergePagination.pageSize || innerPageSize || 10;
    var paginationSize = size === "middle" ? "default" : size;
    var selectPopupPosition = "top";
    if (pagePosition === "tl" || pagePosition === "bl") {
      selectPopupPosition = "bottom";
    } else {
      selectPopupPosition = "top";
    }
    var total = isArray(_processedData) ? _processedData.length : 0;
    var current = Math.ceil(total / pageSize) < currentPage ? 1 : currentPage;
    if (current !== currentPage) {
      setCurrentPage(current);
    }
    var paginationProps2 = {
      size: paginationSize,
      total,
      pageSize,
      current,
      selectProps: {
        triggerProps: {
          position: selectPopupPosition
        }
      }
    };
    if (typeof pagination === "object" && pagination.selectProps) {
      paginationProps2.selectProps = __assign(__assign({}, paginationProps2.selectProps), pagination.selectProps);
    }
    if (isObject(pagination)) {
      paginationProps2 = __assign(__assign({}, paginationProps2), pagination);
    }
    if (isObject(mergePagination)) {
      paginationProps2 = __assign(__assign({}, paginationProps2), mergePagination);
    }
    paginationProps2.onChange = onPaginationChange;
    return paginationProps2;
  }
  var paginationProps = getPaginationProps();
  var pageData = getPageData();
  function getPageData(currentData, _paginationProps) {
    if (currentData === void 0) {
      currentData = processedData;
    }
    if (_paginationProps === void 0) {
      _paginationProps = paginationProps;
    }
    var _a2 = _paginationProps.current, current = _a2 === void 0 ? 0 : _a2, _b2 = _paginationProps.pageSize, pageSize = _b2 === void 0 ? 10 : _b2;
    if (pagination === false) {
      return currentData;
    }
    if (isObject(pagination) && data.length <= pageSize) {
      return currentData;
    }
    return currentData.slice((current - 1) * pageSize, current * pageSize);
  }
  var throttleResizeHandler = debounce_1(resizeHandler, 100);
  var fixedHeader = !!(scroll && scroll.y);
  var summaryNode = summary === null || summary === void 0 ? void 0 : summary(getOriginData(processedData));
  var fixedFooterPosition = summary && React__default.isValidElement(summaryNode) && summaryNode.props.fixed;
  var fixedFooter = fixedHeader && fixedFooterPosition;
  useIsomorphicLayoutEffect(function() {
    resizeHandler();
    on(window, "resize", throttleResizeHandler);
    var tableHead = refTableHead.current;
    var tableBody = refTableBody.current;
    var tableFoot = refTableFoot.current;
    if (tableBody) {
      on(tableBody, "scroll", tableScrollHandler);
    }
    var theadScrollContainer = tableHead && tableHead.parentNode;
    if (tableHead) {
      if (theadScrollContainer) {
        on(theadScrollContainer, "scroll", tableScrollHandler);
      }
    }
    if (tableFoot) {
      on(tableFoot, "scroll", tableScrollHandler);
    }
    return function() {
      off(window, "resize", throttleResizeHandler);
      if (tableBody) {
        off(tableBody, "scroll", tableScrollHandler);
      }
      if (theadScrollContainer) {
        off(theadScrollContainer, "scroll", tableScrollHandler);
      }
      if (tableFoot) {
        off(tableFoot, "scroll", tableScrollHandler);
      }
    };
  }, [hasFixedColumnLeft, hasFixedColumnRight, scroll === null || scroll === void 0 ? void 0 : scroll.x, flattenColumns.length]);
  useUpdate(function() {
    var _a2 = getPaginationProps(data), total = _a2.total, pageSize = _a2.pageSize;
    var maxPageNum = Math.ceil(total / pageSize);
    if (maxPageNum < currentPage) {
      setCurrentPage(1);
    }
  }, [data === null || data === void 0 ? void 0 : data.length]);
  useUpdate(function() {
    setFixedColumnClassNames();
  }, [data, hasFixedColumnLeft, hasFixedColumnRight]);
  useImperativeHandle(ref, function() {
    return {
      getRootDomElement
    };
  });
  function getRootDomElement() {
    return refTable.current;
  }
  function resizeHandler() {
    setFixedColumnClassNames();
    var root = getRootDomElement();
    if (root && (hasFixedColumn || scroll && scroll.x)) {
      var ele = root.querySelector("." + prefixCls + "-body") || root.querySelector("." + prefixCls + "-content-inner");
      var tableViewWidth_1 = ele.clientWidth;
      setTableViewWidth(tableViewWidth_1);
    }
  }
  var setPositionClassNames = useCallback(throttle_1(function() {
    var table = refTable.current;
    var tbody2 = fixedHeader ? refTableBody.current : refTableNF.current && refTableNF.current.parentNode;
    if (tbody2) {
      var scrollLeft = rtl ? -tbody2.scrollLeft : tbody2.scrollLeft;
      var alignLeft = scrollLeft === 0;
      var alignRight = scrollLeft + 1 >= tbody2.children[0].getBoundingClientRect().width - tbody2.getBoundingClientRect().width;
      if (alignLeft && alignRight) {
        setFixedColumnsClassList(table.classList, prefixCls + "-scroll-position-both");
      } else if (alignLeft) {
        setFixedColumnsClassList(table.classList, prefixCls + "-scroll-position-" + (rtl ? "right" : "left"));
      } else if (alignRight) {
        setFixedColumnsClassList(table.classList, prefixCls + "-scroll-position-" + (rtl ? "left" : "right"));
      } else {
        setFixedColumnsClassList(table.classList, prefixCls + "-scroll-position-middle");
      }
    } else {
      table && resetTableClassName(table.classList);
    }
  }, 100), [refTable.current, refTableBody.current]);
  function setFixedColumnClassNames() {
    if (hasFixedColumn || scroll && isObject(scroll) && scroll.x) {
      var table = refTable.current;
      if (table) {
        if (hasFixedColumnLeft) {
          setTableFixedClassName(table.classList, prefixCls + "-has-fixed-col-left");
        }
        if (hasFixedColumnRight) {
          setTableFixedClassName(table.classList, prefixCls + "-has-fixed-col-right");
        }
      }
      setPositionClassNames();
    }
  }
  function setTableFixedClassName(tableClassList, className2) {
    if (!tableClassList.contains(className2)) {
      tableClassList.add(className2);
    }
  }
  function resetTableClassName(classList) {
    classList.remove(prefixCls + "-scroll-position-both");
    classList.remove(prefixCls + "-scroll-position-left");
    classList.remove(prefixCls + "-scroll-position-right");
    classList.remove(prefixCls + "-scroll-position-middle");
  }
  function setFixedColumnsClassList(classList, className2) {
    if (!classList.contains(className2)) {
      resetTableClassName(classList);
      classList.add(className2);
    }
  }
  var _s = useRowSelection(props, pageData, clonedData, getRowKey), selectedRowKeys = _s.selectedRowKeys, indeterminateKeys = _s.indeterminateKeys, onCheckAll = _s.onCheckAll, onCheck = _s.onCheck, onCheckRadio = _s.onCheckRadio, setSelectedRowKeys = _s.setSelectedRowKeys, allSelectedRowKeys = _s.allSelectedRowKeys, flattenData = _s.flattenData;
  function getColumnByDataIndex(dataIndex) {
    return flattenColumns.find(function(column, index) {
      if (column.dataIndex !== void 0) {
        return column.dataIndex === dataIndex;
      }
      return Number(dataIndex) === index;
    });
  }
  function onPaginationChange(current, pageSize) {
    setCurrentPage(current);
    setInnerPageSize(pageSize);
    if (current !== currentPage) {
      scrollToTop();
    }
    if (rowSelection && !rowSelection.checkCrossPage && selectedRowKeys.length) {
      setSelectedRowKeys([]);
      rowSelection.onChange && rowSelection.onChange([], []);
    }
    var newPaginationProps = __assign(__assign({}, getPaginationProps()), {
      current,
      pageSize
    });
    onChange && onChange(newPaginationProps, innerSorter, innerFilters, {
      currentData: getPageData(processedData, newPaginationProps),
      action: "paginate"
    });
    mergePagination.onChange && mergePagination.onChange(current, pageSize);
  }
  function scrollToTop() {
    var tableBody = refTableBody.current;
    if (!tableBody) {
      return;
    }
    var scrollTop = refTableBody.current.scrollTop;
    var tween = new Tween({
      from: {
        scrollTop
      },
      to: {
        scrollTop: 0
      },
      easing: "quintInOut",
      duration: 300,
      onUpdate: function(keys) {
        refTableBody.current.scrollTop = keys.scrollTop;
      }
    });
    tween.start();
  }
  function tableScrollHandler(e) {
    var target = e.target;
    var tbody2 = refTableBody.current;
    var theadScrollContainer = refTableHead.current && refTableHead.current.parentNode;
    var tfoot = refTableFoot.current;
    if (target.scrollLeft !== lastScrollLeft.current) {
      if (theadScrollContainer) {
        theadScrollContainer.scrollLeft = target.scrollLeft;
      }
      if (tbody2) {
        tbody2.scrollLeft = target.scrollLeft;
      }
      if (tfoot) {
        tfoot.scrollLeft = target.scrollLeft;
      }
      setFixedColumnClassNames();
    }
    lastScrollLeft.current = e.target.scrollLeft;
  }
  function tableScrollHandlerNF(e) {
    var target = e.target;
    var table = refTableNF.current;
    if (target.scrollLeft !== lastScrollLeft.current) {
      table.scrollLeft = target.scrollLeft;
      setFixedColumnClassNames();
    }
    lastScrollLeft.current = e.target.scrollLeft;
  }
  var _t = __read(useExpand(props, flattenData, getRowKey), 2), expandedRowKeys = _t[0], onClickExpandBtn = _t[1];
  var scrollStyleY = {};
  var scrollStyleX = {};
  if (scroll) {
    if (scroll.x && (typeof scroll.x === "number" || typeof scroll.x === "string")) {
      scrollStyleX = {
        width: scroll.x
      };
    }
    if (scroll.y && (typeof scroll.y === "number" || typeof scroll.y === "string")) {
      scrollStyleY = {
        maxHeight: scroll.y
      };
    }
  }
  function setScrollBarStyle() {
    var wrapper = refTableHead.current && refTableHead.current.parentNode;
    var scrollBarHeight = getScrollBarHeight(wrapper);
    if (scrollBarHeight && scrollBarHeight > 0) {
      wrapper.style.marginBottom = "-" + scrollBarHeight + "px";
      wrapper.style.paddingBottom = "0px";
      if (refTableFoot.current) {
        refTableFoot.current.style.marginBottom = "-" + scrollBarHeight + "px";
        refTableFoot.current.style.paddingBottom = "0px";
      }
    }
    setTimeout(function() {
      var scrollWrapper = refTableBody.current;
      var scrollBarWidth = getScrollBarWidth(scrollWrapper);
      if (scrollBarWidth) {
        scrollbarChanged.current = true;
        if (wrapper) {
          wrapper.style.overflowY = "scroll";
        }
        if (refTableFoot.current) {
          refTableFoot.current.style.overflowY = "scroll";
        }
      } else if (wrapper && scrollbarChanged.current) {
        scrollbarChanged.current = false;
        wrapper.style.overflowY = "auto";
        if (refTableFoot.current) {
          refTableFoot.current.style.overflowY = "auto";
        }
      }
    });
  }
  var theadNode = /* @__PURE__ */ jsx(THead, {
    ...__assign({}, props, {
      sorter: innerSorter,
      selectedRowKeys,
      currentFilters: innerFilters,
      onCheckAll,
      onSort,
      data: pageData,
      onHandleFilter,
      onHandleFilterReset,
      prefixCls,
      allSelectedRowKeys,
      groupColumns,
      stickyOffsets,
      groupStickyClassNames
    })
  });
  function renderThead() {
    var maxContentWidth = isObject(scroll) && scroll.x === "max-content";
    return fixedHeader || virtualized ? /* @__PURE__ */ jsx(ComponentHeaderWrapper, {
      className: prefixCls + "-header",
      children: /* @__PURE__ */ jsxs(ComponentTable, {
        ref: refTableHead,
        style: maxContentWidth ? {} : scrollStyleX,
        children: [/* @__PURE__ */ jsx(ColGroup, {
          columns: flattenColumns,
          prefixCls
        }), theadNode]
      })
    }) : theadNode;
  }
  var footerNode = summaryNode && /* @__PURE__ */ jsx(Tfoot, {
    prefixCls,
    summary,
    data: pageData,
    columns: flattenColumns,
    stickyOffsets,
    stickyClassNames
  });
  var tbodyNode = /* @__PURE__ */ jsx(TBody, {
    ...__assign({}, props, {
      selectedRowKeys,
      indeterminateKeys,
      expandedRowKeys,
      onCheck,
      onCheckRadio,
      onClickExpandBtn,
      columns: flattenColumns,
      data: pageData,
      prefixCls,
      hasFixedColumn,
      tableViewWidth,
      indentSize,
      noDataElement: noDataElement || renderEmpty("Table"),
      currentSorter: innerSorter,
      stickyOffsets,
      stickyClassNames,
      getRowKey,
      saveVirtualWrapperRef: function(ref2) {
        if (virtualized) {
          refTableBody.current = ref2;
        }
      }
    })
  });
  var tbody = !virtualized && !fixedFooter ? /* @__PURE__ */ jsxs(Fragment, {
    children: [tbodyNode, footerNode]
  }) : tbodyNode;
  function renderTbody() {
    return /* @__PURE__ */ jsx(ResizeObserver, {
      onResize: setScrollBarStyle,
      children: fixedHeader && !virtualized ? /* @__PURE__ */ jsx(ComponentBodyWrapper, {
        ref: refTableBody,
        className: prefixCls + "-body",
        style: scrollStyleY,
        children: /* @__PURE__ */ jsxs(ComponentTable, {
          style: scrollStyleX,
          children: [/* @__PURE__ */ jsx(ColGroup, {
            columns: flattenColumns,
            prefixCls
          }), tbody]
        })
      }) : tbody
    });
  }
  function renderTable() {
    var scrollStyle = {};
    if (scroll && isObject(scroll) && scroll.x) {
      scrollStyle = {
        width: scroll.x
      };
    }
    var summaryTableNode = /* @__PURE__ */ jsx("div", {
      className: prefixCls + "-tfoot",
      ref: refTableFoot,
      children: /* @__PURE__ */ jsxs(ComponentTable, {
        style: scrollStyle,
        children: [/* @__PURE__ */ jsx(ColGroup, {
          columns: flattenColumns,
          prefixCls
        }), footerNode]
      })
    });
    var summaryFixedTop = summaryNode && fixedHeader && fixedFooterPosition === "top";
    var summaryFixedBottom = summaryNode && fixedHeader && fixedFooterPosition === "bottom";
    var body = /* @__PURE__ */ jsxs(Fragment, {
      children: [showHeader ? renderThead() : null, summaryFixedTop && summaryTableNode, renderTbody(), summaryFixedBottom && summaryTableNode]
    });
    return /* @__PURE__ */ jsxs(Fragment, {
      children: [/* @__PURE__ */ jsx("div", {
        className: prefixCls + "-container",
        children: /* @__PURE__ */ jsx("div", {
          className: prefixCls + "-content-scroll",
          children: /* @__PURE__ */ jsx("div", {
            className: prefixCls + "-content-inner",
            onScroll: !fixedHeader ? tableScrollHandlerNF : void 0,
            children: fixedHeader || virtualized ? body : /* @__PURE__ */ jsxs(ComponentTable, {
              ref: refTableNF,
              style: scrollStyle,
              children: [/* @__PURE__ */ jsx(ColGroup, {
                prefixCls,
                columns: flattenColumns
              }), body]
            })
          })
        })
      }), typeof footer === "function" && /* @__PURE__ */ jsx("div", {
        className: prefixCls + "-footer",
        children: footer(pageData)
      })]
    });
  }
  if (!columns.length) {
    return null;
  }
  var showWrapperBorder = isObject(border) ? border.wrapper : border;
  var showCellBorder = isObject(border) ? border.cell : borderCell;
  var showHeaderCellBorder = isObject(border) ? border.cell || border.headerCell : borderCell;
  var showBodyCellBorder = isObject(border) ? border.cell || border.bodyCell : borderCell;
  var classNames = cs(prefixCls, prefixCls + "-size-" + size, (_a = {}, _a[prefixCls + "-border"] = showWrapperBorder, _a[prefixCls + "-border-cell"] = showCellBorder, _a[prefixCls + "-border-header-cell"] = !showCellBorder && showHeaderCellBorder, _a[prefixCls + "-border-body-cell"] = !showCellBorder && showBodyCellBorder, _a[prefixCls + "-stripe"] = stripe, _a[prefixCls + "-hover"] = hover, _a[prefixCls + "-type-radio"] = rowSelection && rowSelection.type === "radio", _a[prefixCls + "-layout-fixed"] = tableLayoutFixed || scroll && (scroll.x || scroll.y) || columns.find(function(col) {
    return col.ellipsis;
  }), _a[prefixCls + "-fixed-column"] = hasFixedColumn, _a[prefixCls + "-virtualized"] = virtualized, _a[prefixCls + "-rtl"] = rtl, _a), className);
  var isPaginationTop = pagePosition === "tl" || pagePosition === "tr" || pagePosition === "topCenter";
  var paginationClassName = cs(prefixCls + "-pagination", (_b = {}, _b[prefixCls + "-pagination-left"] = pagePosition === "tl" || pagePosition === "bl", _b[prefixCls + "-pagination-center"] = pagePosition === "topCenter" || pagePosition === "bottomCenter", _b[prefixCls + "-pagination-top"] = isPaginationTop, _b));
  var loading = props.loading;
  if (typeof loading === "boolean") {
    loading = {
      loading
    };
  }
  var customPagination = typeof renderPagination === "function";
  var paginationEle = customPagination ? renderPagination(/* @__PURE__ */ jsx(Pagination, {
    ...__assign({}, paginationProps)
  })) : /* @__PURE__ */ jsx("div", {
    className: paginationClassName,
    children: /* @__PURE__ */ jsx(Pagination, {
      ...__assign({}, paginationProps)
    })
  });
  return /* @__PURE__ */ jsx("div", {
    ...__assign({
      ref: refTable,
      style,
      className: classNames
    }, pickDataAttributes(props)),
    children: /* @__PURE__ */ jsxs(Spin, {
      ...__assign({
        element: loadingElement || /* @__PURE__ */ jsx(Spin, {})
      }, loading),
      children: [pagination !== false && pageData.length !== 0 && isPaginationTop && paginationEle, renderTable(), pagination !== false && pageData.length !== 0 && !isPaginationTop && paginationEle]
    })
  });
}
var TableComponent = forwardRef(Table);
TableComponent.displayName = "Table";
const Table$1 = TableComponent;
export {
  Table$1 as default
};
//# sourceMappingURL=table.js.map
