import React, { forwardRef, } from 'react';
import { CollectionSectionHeader } from '../CollectionSectionHeader';
export const TableSectionRow = forwardRef(({ state, RegularTrElement, rowData, ...props }, ref) => {
    const { children, className, style } = props;
    const isSectionRow = state.isSectionRow(rowData);
    const regularTrElementProps = {
        ...props,
        rowData,
        className: className || '',
        children: children || [],
    };
    if (state.isInvisibleRow(rowData)) {
        return (React.createElement("tr", { ...props, ref: ref, className: className, style: {
                ...style,
                visibility: 'collapse',
            } }));
    }
    if (isSectionRow && Array.isArray(children) && children.length > 0) {
        const sectionWithCount = state.getSectionWithCount(rowData);
        if (!sectionWithCount) {
            return React.createElement(RegularTrElement, { ...regularTrElementProps });
        }
        return (React.createElement("tr", { ...props, ref: ref, className: className, style: {
                ...style,
                position: 'relative',
                cursor: 'default',
            }, "data-hook": "table-section-header-row" },
            React.createElement("th", { colSpan: children.length, scope: "rowgroup", style: { padding: '0px' } },
                React.createElement(CollectionSectionHeader, { section: sectionWithCount, biComponentType: "TableSections", skin: "neutral", dataHook: "table-section-header" }))));
    }
    return React.createElement(RegularTrElement, { ...regularTrElementProps });
});
//# sourceMappingURL=TableSectionRow.js.map