import { jsx as t, jsxs as k } from "react/jsx-runtime";
import T from "../checkbox/Checkbox.js";
import h from "../../utils/classNames.js";
import { getVerticalAlignClassName as N } from "./shared/getAlignClassName.js";
import { useOptionalTableInteractionContext as v } from "./context/TableInteractionContext.js";
import { useOptionalTableSection as I, useTableBodyContext as A } from "./context/TableStructureContext.js";
import { useOptionalTableRenderContext as O } from "./context/TableRenderContext.js";
import { useOptionalTableRenderConfigContext as V } from "./context/TableRenderConfigContext.js";
const B = (r) => {
  const { isSelected: c, onToggleSelection: s, selectionCheckboxVerticalAlignment: i } = r;
  return /* @__PURE__ */ t(
    "div",
    {
      className: h(
        "table-cell table-selection-cell",
        N(i)
      ),
      role: "cell",
      "aria-colindex": 1,
      style: { gridColumn: "1 / span 1", gridRow: "1 / span 1" },
      onClick: (n) => n.stopPropagation(),
      onKeyDown: (n) => n.stopPropagation(),
      children: /* @__PURE__ */ t("div", { className: "table-selection-control", children: /* @__PURE__ */ t(T, { checked: c, onChange: s }) })
    }
  );
}, q = (r) => {
  const { children: c, className: s, id: i, noHover: n, selectable: m = !1, sticky: b, ...x } = r, g = V(), e = O(), o = v(), f = I(), p = A();
  if (!e || !g || !o || e.columns.length === 0 || f !== "body" || !p)
    return null;
  const a = p.nextRowIndex(), l = i ?? `group-${a}`, u = m && o.selectableRowIdSet.has(l), C = u && o.selectedRowIdSet.has(l), d = o.showSelectionColumn && u, S = e.columns.length + (o.showSelectionColumn && !d ? 1 : 0), y = !!e.renderDraft.bodyMaxHeight, R = d && /* @__PURE__ */ t(
    B,
    {
      isSelected: C,
      onToggleSelection: () => o.onToggleRowSelection?.(l),
      selectionCheckboxVerticalAlignment: g.selectionCheckboxVerticalAlignment
    }
  ), w = /* @__PURE__ */ k(
    "div",
    {
      ...x,
      className: h(
        "table-row",
        "table-row-group",
        d && "table-row-group-selectable",
        b && "table-row-group-sticky",
        b && y && "table-row-sticky-in-container",
        C && "table-row-selected",
        n && "table-row-no-hover",
        s
      ),
      "data-index": a,
      "data-row-id": String(l),
      role: "row",
      children: [
        R,
        /* @__PURE__ */ t("div", { className: "table-cell table-group-cell", role: "cell", "aria-colspan": S, children: /* @__PURE__ */ t("div", { className: "table-cell-content", children: c }) })
      ]
    }
  );
  return e.renderDraft.bodyRows.push({
    rowId: l,
    rowIndex: a,
    kind: "group",
    selectable: m,
    render: () => w
  }), e.isRegisteringBodyRows ? null : w;
};
export {
  q as default
};
//# sourceMappingURL=TableGroupRow.js.map
