import { jsx as o } from "react/jsx-runtime";
import { useRef as p } from "react";
import f from "../../utils/classNames.js";
import w from "./render/footer/TableFooterContent.js";
import { useOptionalTableInteractionContext as x } from "./context/TableInteractionContext.js";
import { useOptionalTableLayoutContext as F } from "./context/TableLayoutContext.js";
import { useOptionalTableRenderConfigContext as T } from "./context/TableRenderConfigContext.js";
import { TableSectionContext as R, TableRowContext as v } from "./context/TableStructureContext.js";
import { useOptionalTableRenderContext as g } from "./context/TableRenderContext.js";
const L = (u) => {
  const { children: n, className: m, ...d } = u, l = T(), e = g(), a = x(), s = F(), t = p(0);
  if (t.current = 0, !l || !e || !a || !s || e.columns.length === 0 || !l.isTableView)
    return null;
  const C = e.columns.length + (a.showSelectionColumn ? 1 : 0), i = e.hasFooterCells !== !1, b = !i;
  return e.renderDraft.hasFooter = !0, e.renderDraft.hasFooterCells = !1, /* @__PURE__ */ o(
    "div",
    {
      ...d,
      className: f("table-footer", b && "table-footer-full-width"),
      role: "rowgroup",
      children: /* @__PURE__ */ o(
        "div",
        {
          className: f("table-row table-row-footer", m),
          role: "row",
          ref: s.tableFooterRowRef,
          children: i ? /* @__PURE__ */ o(R.Provider, { value: "footer", children: /* @__PURE__ */ o(
            v.Provider,
            {
              value: {
                nextColumnIndex: (r, c = 1) => {
                  if (r !== void 0 && r >= 0)
                    return t.current = r + c, r;
                  const h = t.current;
                  return t.current += c, h;
                },
                rowData: {},
                rowId: "__footer__",
                rowIndex: -1
              },
              children: n
            }
          ) }) : /* @__PURE__ */ o(w, { columnCount: C, content: n })
        }
      )
    }
  );
};
export {
  L as default
};
//# sourceMappingURL=TableFooter.js.map
