import { cx as e } from "../../theme/tools.js";
import { useUiTranslation as t } from "../../i18n/useUiTranslation.js";
import { alignRecipe as n, body as r, bodyContained as i, cell as a, container as o, containerWithContainedBody as s, densityRecipe as c, emptyRow as l, header as u, headerCell as d, headerRow as f, hideBelowRecipe as p, primaryCell as m, primaryHeaderCell as h, row as g, rowEven as _, rowOdd as v, rowStateRecipe as y, singleLineCell as b, stickyHeader as x } from "./DataTable.css.js";
import { buildDataTableInlineTemplate as S } from "../../internal/data-table/layout.js";
import { forwardRef as C } from "react";
import { jsx as w, jsxs as T } from "react/jsx-runtime";
//#region src/components/data-table/DataTable.tsx
var E = (e) => e ?? "default", D = (e) => e ?? "default", O = (e) => e == null ? null : p({ minVisibleAt: e }), k = ({ columnCount: e, gridTemplateClassName: t, gridTemplateColumns: n }) => {
	if (t == null) return S(e, n);
}, A = ({ density: e, gridTemplateClassName: t }) => {
	let n = [c({ density: D(e) })];
	return t != null && n.push(t), n;
}, j = C(({ children: n, className: r, kind: i, bodyScrollMode: a = "page", classes: c, ariaLabel: l, ariaLabelledBy: u }, d) => {
	let { t: f } = t(), p;
	u ?? (p = l ?? f("common.table.label"));
	let m = a === "contained", h = null;
	return m && (h = s), /* @__PURE__ */ w("div", {
		ref: d,
		className: e(o({ kind: E(i) }), h, c?.container, r),
		role: "table",
		"aria-label": p,
		"aria-labelledby": u,
		"data-scroll-mode": a,
		children: n
	});
});
j.displayName = "DataTableRoot";
var M = ({ columns: t, kind: r, density: i, headerBehavior: a, headerClassName: o, gridTemplateClassName: s, gridTemplateColumns: c, classes: l }) => {
	let p = E(r), m = k({
		columnCount: t.length,
		gridTemplateClassName: s,
		gridTemplateColumns: c
	}), g = A({
		density: i,
		gridTemplateClassName: s
	}), _;
	a?.offsetTop != null && (_ = { top: a.offsetTop });
	let v = null;
	return a?.sticky === !0 && (v = x), /* @__PURE__ */ w("div", {
		className: e(u({ kind: p }), v, l?.header, o),
		style: _,
		role: "rowgroup",
		children: /* @__PURE__ */ w("div", {
			className: e(f, l?.headerRow, ...g),
			role: "row",
			style: m,
			children: t.map((t) => {
				let r = [d({ kind: p }), l?.headerCell], i = O(t.minVisibleAt);
				return i != null && r.push(i), t.className != null && r.push(t.className), t.isPrimary && r.push(h, l?.primaryHeaderCell), t.align != null && r.push(n({ align: t.align })), /* @__PURE__ */ w("div", {
					role: "columnheader",
					className: e(...r),
					children: t.header
				}, t.id);
			})
		})
	});
}, N = C(({ children: t, className: n, kind: a, bodyScrollMode: o = "page", classes: s }, c) => {
	let l = o === "contained", u = null;
	return l && (u = i), /* @__PURE__ */ w("div", {
		ref: c,
		className: e(r({ kind: E(a) }), u, s?.body, n),
		role: "rowgroup",
		"data-scroll-mode": o,
		children: t
	});
});
N.displayName = "DataTableBody";
var P = ({ row: t, index: r, columns: i, getRowId: o, kind: s, density: c, rowClassName: l, rowState: u, gridTemplateClassName: d, gridTemplateColumns: f, classes: p, style: h, cellMode: x = "normal" }) => {
	let S = E(s), C = k({
		columnCount: i.length,
		gridTemplateClassName: d,
		gridTemplateColumns: f
	}), T = [g({ kind: S }), p?.row], D = u?.(t, r);
	D != null && T.push(y({ state: D })), r % 2 == 0 ? T.push(_({ kind: S }), p?.rowEven) : T.push(v({ kind: S }), p?.rowOdd), T.push(...A({
		density: c,
		gridTemplateClassName: d
	}));
	let j = l?.(t, r);
	return j != null && T.push(j), /* @__PURE__ */ w("div", {
		role: "row",
		className: e(...T),
		style: {
			...C,
			...h
		},
		children: i.map((r) => {
			let i = [a({ kind: S }), p?.cell], o = O(r.minVisibleAt);
			return o != null && i.push(o), x === "singleLine" && i.push(b), r.className != null && i.push(r.className), r.isPrimary && i.push(m, p?.primaryCell), r.align != null && i.push(n({ align: r.align })), /* @__PURE__ */ w("div", {
				role: "cell",
				className: e(...i),
				children: r.cell(t)
			}, r.id);
		})
	}, o(t, r));
}, F = ({ emptyState: n, density: r, classes: i }) => {
	let { t: a } = t(), o = n ?? /* @__PURE__ */ w("div", {
		className: e("ysn84629 txvbqb9w txvbqb1bg3 txvbqb18dp", i?.emptyCell),
		children: a("common.table.empty")
	});
	return /* @__PURE__ */ w("div", {
		className: e(l, c({ density: D(r) }), i?.emptyRow),
		role: "row",
		children: /* @__PURE__ */ w("div", {
			role: "cell",
			children: o
		})
	});
}, I = ({ columns: e, rows: t, getRowId: n, emptyState: r, className: i, headerClassName: a, bodyClassName: o, rowClassName: s, gridTemplateClassName: c, gridTemplateColumns: l, kind: u, density: d, headerBehavior: f, bodyScrollMode: p = "page", rowState: m, classes: h, ariaLabel: g, ariaLabelledBy: _, bodyFooterNode: v }) => {
	let y;
	return y = t.length === 0 ? /* @__PURE__ */ w(F, {
		emptyState: r,
		density: d,
		classes: h
	}) : t.map((t, r) => /* @__PURE__ */ w(P, {
		row: t,
		index: r,
		columns: e,
		getRowId: n,
		kind: u,
		density: d,
		rowClassName: s,
		rowState: m,
		gridTemplateClassName: c,
		gridTemplateColumns: l,
		classes: h
	}, n(t, r))), /* @__PURE__ */ T(j, {
		className: i,
		kind: u,
		bodyScrollMode: p,
		classes: h,
		ariaLabel: g,
		ariaLabelledBy: _,
		children: [/* @__PURE__ */ w(M, {
			columns: e,
			kind: u,
			density: d,
			headerBehavior: f,
			headerClassName: a,
			gridTemplateClassName: c,
			gridTemplateColumns: l,
			classes: h
		}), /* @__PURE__ */ T(N, {
			className: o,
			kind: u,
			bodyScrollMode: p,
			classes: h,
			children: [y, v]
		})]
	});
};
//#endregion
export { I as DataTable, N as DataTableBody, F as DataTableEmptyRow, M as DataTableHeader, j as DataTableRoot, P as DataTableRow };

//# sourceMappingURL=DataTable.js.map