import { cn } from "./index3.js";
import { Pagination } from "./index404.js";
import { Checkbox } from "./index424.js";
import { TableBody, TableCell, TableHead, TableHeader, TableNamespace, TableRow } from "./index440.js";
import { useVirtualizer } from "./index450.js";
import { cva } from "class-variance-authority";
import { ArrowDown, ArrowUp, ChevronRight, ChevronsUpDown } from "lucide-react";
import * as React from "react";
import { jsx, jsxs } from "react/jsx-runtime";
import { flexRender, getCoreRowModel, getExpandedRowModel, getFilteredRowModel, getGroupedRowModel, getPaginationRowModel, getSortedRowModel, useReactTable } from "@tanstack/react-table";
//#region src/components/organisms/content/DataTable/DataTable.tsx
var dataTableVariants = cva("w-full", {
	variants: {
		/** Visual style for row separation */
		dividers: {
			/** Border line between rows */
			line: "",
			/** Alternating row background fills */
			alternating: ""
		},
		/** Table density */
		density: {
			default: "",
			compact: ""
		}
	},
	defaultVariants: {
		dividers: "line",
		density: "default"
	}
});
var dataTableContainerVariants = cva("", {
	variants: {
		/** Border radius configuration */
		rounded: {
			/** Rounded on all corners (default) */
			all: "rounded-xl",
			/** No rounding on any corner */
			none: "rounded-none",
			/** Only top corners rounded */
			top: "rounded-t-xl rounded-b-none",
			/** Only bottom corners rounded (for embedding in cards with headers) */
			bottom: "rounded-t-none rounded-b-xl"
		},
		/** Whether to show the outer border */
		bordered: {
			true: "border border-border",
			false: ""
		}
	},
	defaultVariants: {
		rounded: "all",
		bordered: true
	}
});
var dataTableRowVariants = cva("transition-colors duration-150 ease-out motion-reduce:transition-none", {
	variants: {
		dividers: {
			line: "border-b border-border",
			alternating: "border-0"
		},
		density: {
			default: "",
			compact: ""
		},
		isEven: {
			true: "",
			false: ""
		},
		isSelected: {
			true: "bg-muted dark:bg-accent shadow-[inset_3px_0_0_0_var(--color-primary)]",
			false: ""
		}
	},
	compoundVariants: [{
		dividers: "alternating",
		isEven: true,
		isSelected: false,
		className: "bg-muted"
	}, {
		dividers: "alternating",
		isEven: false,
		isSelected: false,
		className: "bg-background dark:bg-card"
	}],
	defaultVariants: {
		dividers: "line",
		density: "default",
		isEven: false,
		isSelected: false
	}
});
var dataTableCellVariants = cva("align-middle", {
	variants: { density: {
		default: "ps-4 pe-4 py-3 @md:ps-6 @md:pe-6 @md:py-4",
		compact: "ps-4 pe-4 py-3"
	} },
	defaultVariants: { density: "default" }
});
var dataTableHeaderCellVariants = cva("text-xs font-medium text-muted-foreground uppercase tracking-wide", {
	variants: { density: {
		default: "ps-4 pe-4 py-2 @md:ps-6 @md:pe-6 @md:py-3",
		compact: "ps-4 pe-4 py-2"
	} },
	defaultVariants: { density: "default" }
});
function createSelectColumn() {
	return {
		id: "select",
		header: ({ table }) => /* @__PURE__ */ jsx(Checkbox, {
			checked: table.getIsAllPageRowsSelected(),
			indeterminate: table.getIsSomePageRowsSelected() && !table.getIsAllPageRowsSelected(),
			onCheckedChange: (value) => table.toggleAllPageRowsSelected(!!value),
			"aria-label": "Select all",
			className: "translate-y-[2px]"
		}),
		cell: ({ row }) => /* @__PURE__ */ jsx(Checkbox, {
			checked: row.getIsSelected(),
			onCheckedChange: (value) => row.toggleSelected(!!value),
			"aria-label": "Select row",
			className: "translate-y-[2px]"
		}),
		enableSorting: false,
		enableHiding: false,
		size: 40
	};
}
function SortableHeader({ children, column, className }) {
	const sorted = column.getIsSorted();
	if (!column.getCanSort()) return /* @__PURE__ */ jsx("span", {
		className,
		children
	});
	return /* @__PURE__ */ jsxs("button", {
		type: "button",
		onClick: () => column.toggleSorting(sorted === "asc"),
		className: cn("flex items-center gap-1 text-start hover:text-foreground transition-colors duration-150 ease-out motion-reduce:transition-none -ms-1 ps-1 -me-1 pe-1 -my-0.5 py-0.5 rounded focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none active:scale-[0.97] motion-reduce:active:scale-100", className),
		children: [children, /* @__PURE__ */ jsxs("span", {
			className: "relative size-4",
			children: [
				/* @__PURE__ */ jsx(ArrowUp, { className: cn("absolute inset-0 size-4 text-quaternary-foreground transition-[opacity,transform] duration-200 ease-out motion-reduce:transition-none", sorted === "asc" ? "opacity-100 translate-y-0" : "opacity-0 -translate-y-1") }),
				/* @__PURE__ */ jsx(ArrowDown, { className: cn("absolute inset-0 size-4 text-quaternary-foreground transition-[opacity,transform] duration-200 ease-out motion-reduce:transition-none", sorted === "desc" ? "opacity-100 translate-y-0" : "opacity-0 translate-y-1") }),
				/* @__PURE__ */ jsx(ChevronsUpDown, { className: cn("absolute inset-0 size-4 transition-opacity duration-200 ease-out motion-reduce:transition-none", sorted ? "opacity-0" : "opacity-100 text-muted-foreground") })
			]
		})]
	});
}
function useDataTable({ columns, data, enableRowSelection = false, enableMultiRowSelection = true, rowSelection: controlledRowSelection, onRowSelectionChange, initialRowSelection = {}, showSelectAll = true, enableSorting = true, sortingMode = "client", sorting: controlledSorting, onSortingChange, initialSorting = [], enablePagination = false, paginationMode = "client", pagination: controlledPagination, onPaginationChange, pageCount: controlledPageCount, rowCount, pageSize = 10, initialPageIndex = 0, enableColumnFilters = false, filteringMode = "client", columnFilters: controlledColumnFilters, onColumnFiltersChange, initialColumnFilters = [], enableColumnVisibility = false, columnVisibility: controlledColumnVisibility, onColumnVisibilityChange, initialColumnVisibility = {}, enableGrouping = false, groupingMode = "client", grouping: controlledGrouping, onGroupingChange, initialGrouping = [], groupedColumnMode = false, expanded: controlledExpanded, onExpandedChange, initialExpanded = {}, getRowId, getSubRows }) {
	const defaultPaginationState = React.useMemo(() => ({
		pageIndex: initialPageIndex,
		pageSize
	}), [initialPageIndex, pageSize]);
	const [internalRowSelection, setInternalRowSelection] = React.useState(initialRowSelection);
	const [internalSorting, setInternalSorting] = React.useState(initialSorting);
	const [internalColumnFilters, setInternalColumnFilters] = React.useState(initialColumnFilters);
	const [internalColumnVisibility, setInternalColumnVisibility] = React.useState(initialColumnVisibility);
	const [internalPagination, setInternalPagination] = React.useState(defaultPaginationState);
	const [internalGrouping, setInternalGrouping] = React.useState(initialGrouping);
	const [internalExpanded, setInternalExpanded] = React.useState(initialExpanded);
	const rowSelection = controlledRowSelection ?? internalRowSelection;
	const sorting = controlledSorting ?? internalSorting;
	const columnFilters = controlledColumnFilters ?? internalColumnFilters;
	const columnVisibility = controlledColumnVisibility ?? internalColumnVisibility;
	const pagination = controlledPagination ?? internalPagination;
	const grouping = controlledGrouping ?? internalGrouping;
	const expanded = controlledExpanded ?? internalExpanded;
	const handleRowSelectionChange = React.useCallback((updater) => {
		if (controlledRowSelection === void 0) setInternalRowSelection(updater);
		onRowSelectionChange?.(updater);
	}, [controlledRowSelection, onRowSelectionChange]);
	const handleSortingChange = React.useCallback((updater) => {
		if (controlledSorting === void 0) setInternalSorting(updater);
		onSortingChange?.(updater);
	}, [controlledSorting, onSortingChange]);
	const handleColumnFiltersChange = React.useCallback((updater) => {
		if (controlledColumnFilters === void 0) setInternalColumnFilters(updater);
		onColumnFiltersChange?.(updater);
	}, [controlledColumnFilters, onColumnFiltersChange]);
	const handleColumnVisibilityChange = React.useCallback((updater) => {
		if (controlledColumnVisibility === void 0) setInternalColumnVisibility(updater);
		onColumnVisibilityChange?.(updater);
	}, [controlledColumnVisibility, onColumnVisibilityChange]);
	const handlePaginationChange = React.useCallback((updater) => {
		if (controlledPagination === void 0) setInternalPagination(updater);
		onPaginationChange?.(updater);
	}, [controlledPagination, onPaginationChange]);
	const handleGroupingChange = React.useCallback((updater) => {
		if (controlledGrouping === void 0) setInternalGrouping(updater);
		onGroupingChange?.(updater);
	}, [controlledGrouping, onGroupingChange]);
	const handleExpandedChange = React.useCallback((updater) => {
		if (controlledExpanded === void 0) setInternalExpanded(updater);
		onExpandedChange?.(updater);
	}, [controlledExpanded, onExpandedChange]);
	const tableColumns = React.useMemo(() => {
		if (enableRowSelection && showSelectAll) return [createSelectColumn(), ...columns];
		return columns;
	}, [
		columns,
		enableRowSelection,
		showSelectAll
	]);
	const manualPagination = paginationMode === "server";
	const manualSorting = sortingMode === "server";
	const manualFiltering = filteringMode === "server";
	const manualGrouping = groupingMode === "server";
	const pageCount = React.useMemo(() => {
		if (controlledPageCount !== void 0) return controlledPageCount;
		if (rowCount !== void 0 && pagination.pageSize > 0) return Math.ceil(rowCount / pagination.pageSize);
	}, [
		controlledPageCount,
		rowCount,
		pagination.pageSize
	]);
	const table = useReactTable({
		data,
		columns: tableColumns,
		state: {
			rowSelection,
			sorting,
			columnFilters,
			columnVisibility,
			pagination,
			grouping,
			expanded
		},
		enableRowSelection,
		enableMultiRowSelection,
		onRowSelectionChange: handleRowSelectionChange,
		enableSorting,
		manualSorting,
		onSortingChange: handleSortingChange,
		manualPagination,
		pageCount,
		onPaginationChange: handlePaginationChange,
		enableColumnFilters,
		manualFiltering,
		onColumnFiltersChange: handleColumnFiltersChange,
		enableHiding: enableColumnVisibility,
		onColumnVisibilityChange: handleColumnVisibilityChange,
		enableGrouping,
		manualGrouping,
		groupedColumnMode: groupedColumnMode || void 0,
		onGroupingChange: handleGroupingChange,
		onExpandedChange: handleExpandedChange,
		paginateExpandedRows: false,
		getSubRows: groupingMode === "server" ? getSubRows : void 0,
		getCoreRowModel: getCoreRowModel(),
		getSortedRowModel: enableSorting && sortingMode === "client" ? getSortedRowModel() : void 0,
		getFilteredRowModel: enableColumnFilters && filteringMode === "client" ? getFilteredRowModel() : void 0,
		getPaginationRowModel: enablePagination && paginationMode === "client" ? getPaginationRowModel() : void 0,
		getGroupedRowModel: enableGrouping && groupingMode === "client" ? getGroupedRowModel() : void 0,
		getExpandedRowModel: enableGrouping ? getExpandedRowModel() : void 0,
		getRowId
	});
	return {
		table,
		totalPages: table.getPageCount(),
		currentPage: pagination.pageIndex + 1,
		showPagination: enablePagination && paginationMode !== "none" && table.getPageCount() > 1
	};
}
function DataTable({ columns, data, enableRowSelection = false, enableMultiRowSelection = true, rowSelection: controlledRowSelection, onRowSelectionChange, initialRowSelection = {}, enableSorting = true, sortingMode = "client", sorting: controlledSorting, onSortingChange, initialSorting = [], enablePagination = false, paginationMode = "client", pagination: controlledPagination, onPaginationChange, pageCount: controlledPageCount, rowCount, pageSize = 10, initialPageIndex = 0, enableColumnFilters = false, filteringMode = "client", columnFilters: controlledColumnFilters, onColumnFiltersChange, initialColumnFilters = [], enableColumnVisibility = false, columnVisibility: controlledColumnVisibility, onColumnVisibilityChange, initialColumnVisibility = {}, enableGrouping = false, groupingMode = "client", grouping: controlledGrouping, onGroupingChange, initialGrouping = [], groupedColumnMode = false, expanded: controlledExpanded, onExpandedChange, initialExpanded = {}, getSubRows, paginationType = "page-default", paginationShape = "square", paginationLabel, getRowId, onRowClick, emptyState, className, caption, dividers = "line", density = "default", showSelectAll = true, renderControls, classNames, renderBody, renderRow, renderGroupHeader, maxHeight, stickyHeader = false, stickyFirstColumn = false, stickyLastColumn = false, loading: isLoading = false, loadingState, error, errorState, i18n, virtualization, rounded = "all", bordered = true }) {
	const { table, totalPages, currentPage, showPagination } = useDataTable({
		columns,
		data,
		enableRowSelection,
		enableMultiRowSelection,
		rowSelection: controlledRowSelection,
		onRowSelectionChange,
		initialRowSelection,
		showSelectAll,
		enableSorting,
		sortingMode,
		sorting: controlledSorting,
		onSortingChange,
		initialSorting,
		enablePagination,
		paginationMode,
		pagination: controlledPagination,
		onPaginationChange,
		pageCount: controlledPageCount,
		rowCount,
		pageSize,
		initialPageIndex,
		enableColumnFilters,
		filteringMode,
		columnFilters: controlledColumnFilters,
		onColumnFiltersChange,
		initialColumnFilters,
		enableColumnVisibility,
		columnVisibility: controlledColumnVisibility,
		onColumnVisibilityChange,
		initialColumnVisibility,
		enableGrouping,
		groupingMode,
		grouping: controlledGrouping,
		onGroupingChange,
		initialGrouping,
		groupedColumnMode,
		expanded: controlledExpanded,
		onExpandedChange,
		initialExpanded,
		getSubRows,
		getRowId
	});
	const tableContainerRef = React.useRef(null);
	const rows = table.getRowModel().rows;
	const isVirtualizationEnabled = virtualization?.enabled ?? false;
	const headerOffset = stickyHeader && isVirtualizationEnabled ? 40 : 0;
	const isGroupRow = React.useCallback((row) => {
		if (row.getIsGrouped()) return true;
		if (groupingMode === "server" && row.subRows.length > 0) return true;
		return false;
	}, [groupingMode]);
	const rowVirtualizer = useVirtualizer({
		count: isVirtualizationEnabled ? rows.length : 0,
		getScrollElement: () => tableContainerRef.current,
		estimateSize: (index) => {
			const row = rows[index];
			if (row && isGroupRow(row)) return virtualization?.estimatedGroupHeaderHeight ?? 48;
			return virtualization?.estimatedRowHeight ?? 50;
		},
		overscan: virtualization?.overscan ?? 5
	});
	const handleRowKeyDown = React.useCallback((row, e) => {
		if (e.key === "Enter" || e.key === " ") {
			e.preventDefault();
			onRowClick?.(row);
		}
	}, [onRowClick]);
	const renderCellContent = React.useCallback((cell, row) => {
		const isGroupedCell = cell.getIsGrouped();
		const isAggregatedCell = cell.getIsAggregated();
		const isPlaceholderCell = cell.getIsPlaceholder();
		if (isGroupedCell) return /* @__PURE__ */ jsxs("button", {
			type: "button",
			onClick: row.getToggleExpandedHandler(),
			className: "flex items-center gap-1.5 text-left font-medium group/expand rounded -ms-1 ps-1 -me-1 pe-1 -my-0.5 py-0.5 hover:text-foreground transition-colors duration-150 ease-out motion-reduce:transition-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none active:scale-[0.98] motion-reduce:active:scale-100",
			"aria-label": `${row.getIsExpanded() ? "Collapse" : "Expand"} ${String(cell.getValue() ?? "")} group`,
			"aria-expanded": row.getIsExpanded(),
			children: [
				/* @__PURE__ */ jsx(ChevronRight, { className: cn("h-4 w-4 flex-shrink-0 transition-transform duration-200 ease-out motion-reduce:transition-none", row.getIsExpanded() && "rotate-90") }),
				/* @__PURE__ */ jsx("span", { children: flexRender(cell.column.columnDef.cell, cell.getContext()) }),
				/* @__PURE__ */ jsxs("span", {
					className: "text-quaternary-foreground tabular-nums",
					children: [
						"(",
						row.subRows.length,
						")"
					]
				})
			]
		});
		if (isAggregatedCell) return flexRender(cell.column.columnDef.aggregatedCell ?? cell.column.columnDef.cell, cell.getContext());
		if (isPlaceholderCell) return null;
		return flexRender(cell.column.columnDef.cell, cell.getContext());
	}, []);
	return /* @__PURE__ */ jsxs("div", {
		"data-slot": "data-table",
		className: cn("@container", "space-y-4", className),
		children: [
			renderControls?.(table),
			/* @__PURE__ */ jsx("div", {
				ref: tableContainerRef,
				className: cn(dataTableContainerVariants({
					rounded,
					bordered
				}), maxHeight ? "overflow-auto" : "overflow-x-auto"),
				style: maxHeight ? { maxHeight } : void 0,
				children: /* @__PURE__ */ jsxs(TableNamespace, {
					disableOverflow: !!(maxHeight || stickyHeader || stickyFirstColumn || stickyLastColumn),
					className: cn(dataTableVariants({
						dividers,
						density
					}), classNames?.table),
					children: [
						caption && /* @__PURE__ */ jsx("caption", {
							className: "sr-only",
							children: caption
						}),
						/* @__PURE__ */ jsx(TableHeader, {
							className: cn(stickyHeader && "sticky top-0 z-10"),
							children: table.getHeaderGroups().map((headerGroup) => /* @__PURE__ */ jsx(TableRow, {
								className: cn("border-b border-border bg-muted hover:bg-muted", classNames?.headerRow),
								children: headerGroup.headers.map((header, headerIndex) => {
									const isFirstColumn = headerIndex === 0;
									const isLastColumn = headerIndex === headerGroup.headers.length - 1;
									const isSticky = stickyFirstColumn && isFirstColumn || stickyLastColumn && isLastColumn;
									const sortState = header.column.getIsSorted();
									const ariaSort = sortState ? sortState === "desc" ? "descending" : "ascending" : void 0;
									return /* @__PURE__ */ jsx(TableHead, {
										scope: "col",
										style: { width: header.getSize() !== 150 ? header.getSize() : void 0 },
										className: cn(dataTableHeaderCellVariants({ density }), "text-start", classNames?.headerCell, header.column.columnDef.meta?.headerClassName, stickyFirstColumn && isFirstColumn && "sticky left-0 z-20 bg-muted", stickyLastColumn && isLastColumn && "sticky right-0 z-20 bg-muted", stickyHeader && isSticky && "z-30"),
										"aria-sort": ariaSort,
										children: header.isPlaceholder ? null : typeof header.column.columnDef.header === "string" && header.column.getCanSort() ? /* @__PURE__ */ jsx(SortableHeader, {
											column: header.column,
											children: header.column.columnDef.header
										}) : flexRender(header.column.columnDef.header, header.getContext())
									}, header.id);
								})
							}, headerGroup.id))
						}),
						renderBody ? renderBody(table) : isVirtualizationEnabled && table.getRowModel().rows?.length ? /* @__PURE__ */ jsx(TableBody, {
							style: {
								display: "block",
								position: "relative",
								height: `${rowVirtualizer.getTotalSize() + headerOffset}px`
							},
							children: rowVirtualizer.getVirtualItems().map((virtualRow) => {
								const row = rows[virtualRow.index];
								const rowIsGroup = isGroupRow(row);
								const visibleColumnCount = row.getVisibleCells().length;
								if (rowIsGroup && renderGroupHeader) return /* @__PURE__ */ jsx(TableRow, {
									"data-state": row.getIsSelected() && "selected",
									ref: (node) => rowVirtualizer.measureElement(node),
									"data-index": virtualRow.index,
									className: cn(dataTableRowVariants({
										dividers,
										density,
										isEven: virtualRow.index % 2 === 1,
										isSelected: row.getIsSelected()
									}), "bg-muted", classNames?.row),
									style: {
										display: "table",
										position: "absolute",
										top: 0,
										left: 0,
										width: "100%",
										transform: `translateY(${virtualRow.start + headerOffset}px)`
									},
									children: renderGroupHeader(row, visibleColumnCount)
								}, row.id);
								return /* @__PURE__ */ jsx(TableRow, {
									"data-state": row.getIsSelected() && "selected",
									"aria-selected": row.getIsSelected() ? "true" : void 0,
									tabIndex: onRowClick ? 0 : void 0,
									onClick: onRowClick ? () => onRowClick(row) : void 0,
									onKeyDown: onRowClick ? (e) => handleRowKeyDown(row, e) : void 0,
									ref: (node) => rowVirtualizer.measureElement(node),
									"data-index": virtualRow.index,
									className: cn(dataTableRowVariants({
										dividers,
										density,
										isEven: virtualRow.index % 2 === 1,
										isSelected: row.getIsSelected()
									}), rowIsGroup && "bg-muted", onRowClick && "cursor-pointer hover:bg-muted focus-visible:bg-muted focus-visible:outline-none active:bg-accent/50 motion-reduce:active:bg-muted", classNames?.row),
									style: {
										display: "table",
										position: "absolute",
										top: 0,
										left: 0,
										width: "100%",
										transform: `translateY(${virtualRow.start + headerOffset}px)`
									},
									children: row.getVisibleCells().map((cell, cellIndex) => {
										const isFirstColumn = cellIndex === 0;
										const isLastColumn = cellIndex === row.getVisibleCells().length - 1;
										return /* @__PURE__ */ jsx(TableCell, {
											className: cn(dataTableCellVariants({ density }), classNames?.cell, cell.column.columnDef.meta?.cellClassName, stickyFirstColumn && isFirstColumn && "sticky left-0 z-20 bg-background dark:bg-card", stickyLastColumn && isLastColumn && "sticky right-0 z-20 bg-background dark:bg-card"),
											children: rowIsGroup ? renderCellContent(cell, row) : flexRender(cell.column.columnDef.cell, cell.getContext())
										}, cell.id);
									})
								}, row.id);
							})
						}) : /* @__PURE__ */ jsx(TableBody, { children: table.getRowModel().rows?.length ? renderRow ? table.getRowModel().rows.map((row) => renderRow(row)) : table.getRowModel().rows.map((row, index) => {
							const rowIsGroup = isGroupRow(row);
							const visibleColumnCount = row.getVisibleCells().length;
							if (rowIsGroup && renderGroupHeader) return /* @__PURE__ */ jsx(TableRow, {
								"data-state": row.getIsSelected() && "selected",
								className: cn(dataTableRowVariants({
									dividers,
									density,
									isEven: index % 2 === 1,
									isSelected: row.getIsSelected()
								}), "bg-muted", classNames?.row),
								children: renderGroupHeader(row, visibleColumnCount)
							}, row.id);
							return /* @__PURE__ */ jsx(TableRow, {
								"data-state": row.getIsSelected() && "selected",
								"aria-selected": row.getIsSelected() ? "true" : void 0,
								tabIndex: onRowClick ? 0 : void 0,
								onClick: onRowClick ? () => onRowClick(row) : void 0,
								onKeyDown: onRowClick ? (e) => handleRowKeyDown(row, e) : void 0,
								className: cn(dataTableRowVariants({
									dividers,
									density,
									isEven: index % 2 === 1,
									isSelected: row.getIsSelected()
								}), rowIsGroup && "bg-muted", onRowClick && "cursor-pointer hover:bg-muted focus-visible:bg-muted focus-visible:outline-none active:bg-accent/50 motion-reduce:active:bg-muted", classNames?.row),
								children: row.getVisibleCells().map((cell, cellIndex) => {
									const isFirstColumn = cellIndex === 0;
									const isLastColumn = cellIndex === row.getVisibleCells().length - 1;
									return /* @__PURE__ */ jsx(TableCell, {
										className: cn(dataTableCellVariants({ density }), classNames?.cell, cell.column.columnDef.meta?.cellClassName, stickyFirstColumn && isFirstColumn && "sticky left-0 z-20 bg-background dark:bg-card", stickyLastColumn && isLastColumn && "sticky right-0 z-20 bg-background dark:bg-card"),
										children: rowIsGroup ? renderCellContent(cell, row) : flexRender(cell.column.columnDef.cell, cell.getContext())
									}, cell.id);
								})
							}, row.id);
						}) : /* @__PURE__ */ jsx(TableRow, { children: /* @__PURE__ */ jsx(TableCell, {
							colSpan: table.getAllColumns().length,
							className: cn(dataTableCellVariants({ density }), "h-24 text-center text-muted-foreground"),
							"aria-live": isLoading || error ? "polite" : void 0,
							children: isLoading ? loadingState || i18n?.loading || "Loading..." : error ? errorState || error.message : emptyState || i18n?.noResults || "No results."
						}) }) })
					]
				})
			}),
			showPagination && /* @__PURE__ */ jsx(Pagination, {
				type: paginationType,
				shape: paginationShape,
				currentPage,
				totalPages,
				onPageChange: (page) => table.setPageIndex(page - 1),
				showPageNumbers: true,
				"aria-label": paginationLabel
			})
		]
	});
}
DataTable.displayName = "DataTable";
//#endregion
export { DataTable, SortableHeader, createSelectColumn, dataTableCellVariants, dataTableHeaderCellVariants, dataTableRowVariants, dataTableVariants, useDataTable };

//# sourceMappingURL=index451.js.map