/** @license MIT | @cube-dev/ui-kit v0.123.0 | Cube Dev Team */
import { _Title } from "../../content/Title.js";
import { useProviderProps } from "../../../provider.js";
import { Space } from "../../layout/Space.js";
import { LeftIcon } from "../../../icons/LeftIcon.js";
import { RightIcon } from "../../../icons/RightIcon.js";
import { Button } from "../../actions/index.js";
import { CalendarGrid } from "./CalendarGrid.js";
import { tasty } from "@tenphi/tasty";
import { forwardRef, useImperativeHandle, useRef } from "react";
import { jsx, jsxs } from "react/jsx-runtime";
import { useCalendar, useLocale } from "react-aria";
import { createDOMRef } from "@react-spectrum/utils";
import { useCalendarState } from "react-stately";
import { createCalendar } from "@internationalized/date";

//#region src/components/other/Calendar/Calendar.tsx
const CalendarElement = tasty({ styles: {
	padding: "1x",
	gap: "1x"
} });
const CalendarHeaderElement = tasty({ styles: {
	display: "flex",
	placeContent: "center space-between",
	placeItems: "center",
	gap: "1.5x"
} });
function Calendar(props, ref) {
	props = useProviderProps(props);
	let { locale } = useLocale();
	let state = useCalendarState({
		...props,
		locale,
		createCalendar
	});
	let domRef = useRef(null);
	useImperativeHandle(ref, () => ({
		...createDOMRef(domRef),
		focus() {
			state.setFocused(true);
		}
	}));
	let { calendarProps, prevButtonProps, nextButtonProps, title } = useCalendar(props, state);
	return /* @__PURE__ */ jsxs(CalendarElement, {
		...calendarProps,
		children: [/* @__PURE__ */ jsxs(CalendarHeaderElement, { children: [/* @__PURE__ */ jsx(_Title, {
			level: 6,
			preset: "h6",
			children: title
		}), /* @__PURE__ */ jsxs(Space, {
			gap: ".5x",
			children: [/* @__PURE__ */ jsx(Button, {
				size: "xsmall",
				...prevButtonProps,
				icon: /* @__PURE__ */ jsx(LeftIcon, {})
			}), /* @__PURE__ */ jsx(Button, {
				size: "xsmall",
				...nextButtonProps,
				icon: /* @__PURE__ */ jsx(RightIcon, {})
			})]
		})] }), /* @__PURE__ */ jsx(CalendarGrid, {
			state,
			selectedRange: props.selectedRange
		})]
	});
}
const _Calendar = forwardRef(Calendar);
_Calendar.displayName = "Calendar";

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