import { jsx as b, jsxs as j } from "react/jsx-runtime";
import c from "../../utils/classNames.js";
import { getVerticalAlignClassName as I, getHorizontalAlignClassName as L } from "./shared/getAlignClassName.js";
import T from "./shared/getCellContentOverflowClassName.js";
import { resolveAriaSpan as H, resolveAriaColIndex as D } from "./shared/resolveTableAria.js";
import { useOptionalTableInteractionContext as P } from "./context/TableInteractionContext.js";
import { useOptionalTableLayoutContext as $ } from "./context/TableLayoutContext.js";
import { useOptionalTableRenderConfigContext as q } from "./context/TableRenderConfigContext.js";
import { useOptionalTableSection as E, useTableRowContext as G } from "./context/TableStructureContext.js";
import { useOptionalTableRenderContext as J } from "./context/TableRenderContext.js";
const ne = (F) => {
  const {
    children: f,
    className: g,
    colSpan: h = 1,
    columnKey: t,
    horizontalAlign: M,
    overflow: y = "hidden",
    preventRowClick: m = !1,
    value: p,
    verticalAlign: W,
    ...x
  } = F, n = q(), o = J(), d = P(), i = $(), v = E(), a = G(), s = v === "body", r = v === "footer";
  if (!o || !n || !d || !i || o.columns.length === 0 || !s && !r || s && !a)
    return null;
  const N = t !== void 0 ? o.columnIndexByKey.get(t) : void 0, u = a?.nextColumnIndex(N, h) ?? N ?? -1;
  if (u < 0)
    return null;
  const e = o.columns[u], l = u + 1, B = l + (d.showSelectionColumn ? 1 : 0), w = M ?? e?.horizontalAlign, k = W ?? e?.verticalAlign, S = s && a?.rowData && n.cellClassName?.(
    a.rowData,
    o.columnDefinitionsByKey.get(e?.columnKey ?? t ?? "") ?? {
      key: e?.columnKey ?? t ?? String(l),
      label: e?.label ?? "",
      icon: e?.icon,
      filter: e?.filter,
      hideLabel: e?.hideLabel,
      width: e?.width,
      minResizeWidth: e?.minResizeWidth,
      maxResizeWidth: e?.maxResizeWidth,
      draggable: e?.draggable,
      resizeable: e?.resizeable,
      horizontalAlign: e?.horizontalAlign,
      className: void 0,
      headerClassName: e?.headerClassName,
      hideOnMobile: e?.hideOnMobile,
      sortable: e?.sortable
    },
    a.rowIndex,
    u
  ), z = i.stickyLeftColumnCount ?? 0, A = i.stickyRightColumnCount ?? 0, R = z > 0 && l <= z, O = A > 0 && l > o.columns.length - A, K = e?.mobileLabel ?? (typeof e?.label == "string" ? e.label : ""), C = (V) => {
    V.stopPropagation();
  };
  return r && (o.renderDraft.hasFooterCells = !0), n.isTableView ? /* @__PURE__ */ b(
    "div",
    {
      ...x,
      className: c(
        "table-cell",
        r && "table-footer-cell",
        s && R && "table-cell-sticky-left-column",
        s && O && "table-cell-sticky-right-column",
        r && i.stickyFooter && R && "table-footer-cell-sticky-left-column",
        r && i.stickyFooter && O && "table-footer-cell-sticky-right-column",
        L(w),
        I(k),
        e?.hideOnMobile && "table-hide-mobile",
        S,
        g
      ),
      "data-column": e?.columnKey ?? t ?? l,
      role: "cell",
      "aria-colindex": D(l, d.showSelectionColumn),
      "aria-colspan": H(h),
      onClick: m ? C : void 0,
      onKeyDown: m ? C : void 0,
      style: { gridColumn: `${B} / span ${h}`, gridRow: "1 / span 1" },
      children: /* @__PURE__ */ b("div", { className: c("table-cell-content", T(y)), children: p ?? f ?? "" })
    }
  ) : /* @__PURE__ */ j(
    "div",
    {
      ...x,
      className: c(
        "table-cell",
        n.cardClasses.cellClassName,
        L(w),
        I(k),
        e?.hideOnMobile && "table-hide-mobile",
        S,
        g
      ),
      "data-column": e?.columnKey ?? t ?? l,
      role: "cell",
      "aria-colindex": D(l, d.showSelectionColumn),
      onClick: m ? C : void 0,
      onKeyDown: m ? C : void 0,
      children: [
        K && /* @__PURE__ */ b("div", { className: c("table-cell-label", n.cardClasses.labelClassName), children: K }),
        /* @__PURE__ */ b(
          "div",
          {
            className: c(
              "table-cell-content",
              n.cardClasses.contentClassName,
              T(y)
            ),
            children: p ?? f ?? ""
          }
        )
      ]
    }
  );
};
export {
  ne as default
};
//# sourceMappingURL=TableColumn.js.map
