import React from 'react';
import classnames from 'classnames';
import { TableHeaderCell } from './table-header-cell';
import { jsx as _jsx } from "react/jsx-runtime";
export function TableHeader({
  tableModel,
  centerScrolled,
  scrollableRight,
  trClassName,
  thClassName,
  ThElement = TableHeaderCell,
  onColumnHeaderClick,
  tableContainerWidth,
  localizationText,
  size,
  tableRowTestId,
  tableHeaderCellTestId
}) {
  const headersGroups = tableModel.getHeaderGroups();
  return /*#__PURE__*/_jsx("thead", {
    className: classnames('react-table-thead', size),
    children: headersGroups.map(headerGroup => /*#__PURE__*/_jsx("tr", {
      className: classnames('react-table-tr', trClassName),
      "test-id": tableRowTestId,
      role: "row",
      children: headerGroup.headers.map((header, index) => {
        const isLastPinned = index === tableModel.getLeftVisibleLeafColumns().length - 1;
        return /*#__PURE__*/_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))
  });
}