import { jsx as i } from "react/jsx-runtime";
import { useId as j, useRef as E } from "react";
import M from "../../utils/classNames.js";
import "../../utils/init/initConfig.js";
import V from "./render/header/TableDraggableHeaderCell.js";
import q from "./render/header/TableStaticHeaderCell.js";
import { useOptionalTableInteractionContext as B } from "./context/TableInteractionContext.js";
import { useOptionalTableLayoutContext as F } from "./context/TableLayoutContext.js";
import { useOptionalTableRenderConfigContext as G } from "./context/TableRenderConfigContext.js";
import { useOptionalTableSection as J, useTableHeaderRowContext as Q } from "./context/TableStructureContext.js";
import { useOptionalTableRenderContext as U } from "./context/TableRenderContext.js";
const ae = (m) => {
  const {
    children: u,
    className: c,
    colSpan: C = 1,
    columnKey: d,
    draggable: b,
    filter: h,
    headerClassName: p,
    hideLabel: f,
    hideOnMobile: g,
    horizontalAlign: R,
    icon: y,
    label: S,
    maxResizeWidth: x,
    mobileLabel: z,
    minResizeWidth: w,
    resizeable: T,
    rowSpan: K = 1,
    sortable: O,
    verticalAlign: k,
    width: L,
    ...D
  } = m, t = U(), r = G(), n = B(), o = F(), H = J(), N = Q(), a = j();
  if (E(!1), !t || !r || !n || !o || H !== "header")
    return null;
  const A = N?.row ?? 1;
  if (t.renderDraft.headerColumns.push({
    id: a,
    columnKey: d,
    label: S ?? u ?? "",
    icon: y,
    filter: h,
    hideLabel: f,
    width: L,
    mobileLabel: z,
    horizontalAlign: R,
    verticalAlign: k,
    headerClassName: M(c, p),
    hideOnMobile: g,
    sortable: O,
    draggable: b,
    resizeable: T,
    minResizeWidth: w,
    maxResizeWidth: x,
    row: A,
    colSpan: C,
    rowSpan: K
  }), !r.isTableView)
    return null;
  const l = t.header, e = l?.columns.find((P) => String(P.key) === a);
  if (!l || !e)
    return null;
  const I = !!e.columnKey && e.colSpan === 1 && e.columnKey !== o.lastResizableColumnKey && e.resizeable === !0 && !!o.onColumnResizeStart, W = !!e.columnKey && e.colSpan === 1 && (o.draggableColumnKeys?.length ?? 0) > 1 && e.draggable === !0 && !!o.onColumnDragEnd, v = !!e.columnKey && o.resettableColumnKeys?.has(e.columnKey), s = {
    column: e,
    header: l,
    htmlAttributes: D,
    hasResettableWidth: v,
    isResizable: I,
    onColumnResizeReset: o.onColumnResizeReset,
    onColumnResizeStart: o.onColumnResizeStart,
    onSortChange: n.onSortChange,
    showSelectionColumn: n.showSelectionColumn,
    stickyLeftColumnCount: o.stickyLeftColumnCount,
    stickyRightColumnCount: o.stickyRightColumnCount
  };
  return W ? /* @__PURE__ */ i(V, { ...s }) : /* @__PURE__ */ i(q, { ...s });
};
export {
  ae as default
};
//# sourceMappingURL=TableHeaderColumn.js.map
