/** @license MIT | @cube-dev/ui-kit v0.127.1 | Cube Dev Team */
import { tasty } from "@tenphi/tasty";
import { useRef } from "react";
import { jsx } from "react/jsx-runtime";
import { useCalendarCell } from "react-aria";

//#region src/components/other/Calendar/CalendarCell.tsx
const CalendarCellElement = tasty({
	as: "td",
	styles: {
		preset: "t3m",
		margin: 0,
		padding: "2bw right bottom"
	}
});
const CalendarButtonElement = tasty({ styles: {
	display: "grid",
	placeItems: "center",
	width: "3x",
	height: "3x",
	fill: {
		"": "#primary.0",
		":hover": "#primary.16",
		pressed: "#primary.10",
		selected: "#primary",
		"selected & :hover": "#primary-text",
		"selected & pressed": "#primary",
		"disabled | unavailable": "#primary.0"
	},
	color: {
		"": "#dark",
		selected: "#white",
		"disabled | unavailable": "#dark.30"
	},
	outline: {
		"": "1bw #primary-text.0",
		focused: "1bw #primary-text"
	},
	outlineOffset: .5,
	radius: true,
	cursor: "$pointer"
} });
function CalendarCell({ state, selectedRange, date }) {
	let ref = useRef(null);
	let { cellProps, buttonProps, isSelected, isPressed, isFocused, isInvalid, isOutsideVisibleRange, isDisabled, isUnavailable, formattedDate } = useCalendarCell({ date }, state, ref);
	const isFinalSelected = selectedRange ? date.compare(selectedRange.start) >= 0 && date.compare(selectedRange.end) <= 0 : isSelected;
	return /* @__PURE__ */ jsx(CalendarCellElement, {
		...cellProps,
		children: /* @__PURE__ */ jsx(CalendarButtonElement, {
			...buttonProps,
			ref,
			hidden: isOutsideVisibleRange,
			mods: {
				selected: isFinalSelected,
				pressed: isPressed,
				focused: isFocused,
				invalid: isInvalid,
				disabled: isDisabled,
				unavailable: isUnavailable
			},
			children: formattedDate
		})
	});
}

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