import { jsx } from 'react/jsx-runtime';
import React__default from 'react';
import { cn } from '../../../utils/cn.js';
import { useGanttContext } from './GanttChart.js';
import { getDayOffset } from './GanttChart.utils.js';
import { getDaysBetween } from '../../../utils/dateUtils.js';

const GanttGroupBar = React__default.memo(({ row, top }) => {
    const { theme, dayWidth, rangeStart, rowHeight } = useGanttContext();
    if (row.taskCount === 0)
        return null;
    const offset = getDayOffset(row.earliestStart, rangeStart);
    const span = getDaysBetween(row.earliestStart, row.latestEnd);
    const left = offset * dayWidth;
    const width = span * dayWidth;
    const barHeight = 6;
    return (jsx("div", { className: cn(theme.groupBarStyle), style: {
            left,
            width: Math.max(width, dayWidth),
            top: top + rowHeight - barHeight - 4,
            height: barHeight,
            backgroundColor: row.group.color,
        } }));
});

export { GanttGroupBar };
