/** @license MIT | @cube-dev/ui-kit v0.0.0-canary-e634e55 | Cube Dev Team */
import { tasty } from "../../../tasty/tasty.js";
import { CalendarCell } from "./CalendarCell.js";
import { jsx, jsxs } from "react/jsx-runtime";
import { useCalendarGrid, useLocale } from "react-aria";
import { getWeeksInMonth } from "@internationalized/date";

//#region src/components/other/Calendar/CalendarGrid.tsx
const TableElement = tasty({
	as: "table",
	styles: {
		borderCollapse: "collapse",
		HeadRow: { color: "#dark-04" }
	}
});
function CalendarGrid({ state, ...props }) {
	let { locale } = useLocale();
	let { gridProps, headerProps, weekDays } = useCalendarGrid(props, state);
	let weeksInMonth = getWeeksInMonth(state.visibleRange.start, locale);
	return /* @__PURE__ */ jsxs(TableElement, {
		...gridProps,
		children: [/* @__PURE__ */ jsx("thead", {
			"data-element": "Head",
			...headerProps,
			children: /* @__PURE__ */ jsx("tr", {
				"data-element": "HeadRow",
				children: weekDays.map((day, index) => /* @__PURE__ */ jsx("th", { children: day }, index))
			})
		}), /* @__PURE__ */ jsx("tbody", {
			"data-element": "Body",
			children: [...new Array(weeksInMonth).keys()].map((weekIndex) => /* @__PURE__ */ jsx("tr", {
				"data-element": "Row",
				children: state.getDatesInWeek(weekIndex).map((date, i) => date ? /* @__PURE__ */ jsx(CalendarCell, {
					state,
					date,
					selectedRange: props.selectedRange
				}, i) : /* @__PURE__ */ jsx("td", {}, i))
			}, weekIndex))
		})]
	});
}

//#endregion
export { CalendarGrid };
//# sourceMappingURL=CalendarGrid.js.map