"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.TableHeader = TableHeader;
var _react = _interopRequireDefault(require("react"));
var _classnames = _interopRequireDefault(require("classnames"));
var _tableHeaderCell = require("./table-header-cell");
var _jsxRuntime = require("react/jsx-runtime");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
function TableHeader({
  tableModel,
  centerScrolled,
  scrollableRight,
  trClassName,
  thClassName,
  ThElement = _tableHeaderCell.TableHeaderCell,
  onColumnHeaderClick,
  tableContainerWidth,
  localizationText,
  size,
  tableRowTestId,
  tableHeaderCellTestId
}) {
  const headersGroups = tableModel.getHeaderGroups();
  return /*#__PURE__*/(0, _jsxRuntime.jsx)("thead", {
    className: (0, _classnames.default)('react-table-thead', size),
    children: headersGroups.map(headerGroup => /*#__PURE__*/(0, _jsxRuntime.jsx)("tr", {
      className: (0, _classnames.default)('react-table-tr', trClassName),
      "test-id": tableRowTestId,
      role: "row",
      children: headerGroup.headers.map((header, index) => {
        const isLastPinned = index === tableModel.getLeftVisibleLeafColumns().length - 1;
        return /*#__PURE__*/(0, _jsxRuntime.jsx)(ThElement, {
          isLeft: header.column.getIsPinned() === 'left',
          isLastPinned: isLastPinned,
          shouldShowPinnedShadow: isLastPinned && centerScrolled,
          isRight: header.column.getIsPinned() === 'right',
          shouldShowRightPinnedShadow: scrollableRight,
          header: header,
          tableContainerWidth: tableContainerWidth,
          thClassName: thClassName,
          onColumnHeaderClick: onColumnHeaderClick,
          localizationText: localizationText,
          columnIndex: index,
          tableHeaderCellTestId: tableHeaderCellTestId
        }, header.id);
      })
    }, headerGroup.id))
  });
}