'use client'; import dayjs from 'dayjs'; import timezonePlugin from 'dayjs/plugin/timezone.js'; import utcPlugin from 'dayjs/plugin/utc.js'; import { jsx, jsxs, Fragment } from 'react/jsx-runtime'; import { c } from 'react/compiler-runtime'; import { createContext, useContext, useRef, useState, useEffect } from 'react'; import cx from 'clsx'; import { factory, InputBase, useProps, useResolvedStylesApi, createVarsResolver, getSize, useStyles, UnstyledButton, getFontSize, getSpacing, Box, AccordionChevron, useInputProps, CloseButton, Modal, Input, Popover, ActionIcon, CheckIcon } from '@mantine/core'; import { useUncontrolled, useDisclosure, clamp, useDidUpdate, useMergedRef } from '@mantine/hooks'; function defaultDateFormatter({ type, date, locale, format, labelSeparator }) { const formatDate = (value) => dayjs(value).locale(locale).format(format); if (type === "default") { return date === null ? "" : formatDate(date); } if (type === "multiple") { return date.map(formatDate).join(", "); } if (type === "range" && Array.isArray(date)) { if (date[0] && date[1]) { return `${formatDate(date[0])} ${labelSeparator} ${formatDate(date[1])}`; } if (date[0]) { return `${formatDate(date[0])} ${labelSeparator} `; } return ""; } return ""; } function getFormattedDate({ formatter, ...others }) { return (formatter || defaultDateFormatter)(others); } function getNextIndex({ direction, levelIndex, rowIndex, cellIndex, size }) { switch (direction) { case "up": if (levelIndex === 0 && rowIndex === 0) { return null; } if (rowIndex === 0) { return { levelIndex: levelIndex - 1, rowIndex: cellIndex <= size[levelIndex - 1][size[levelIndex - 1].length - 1] - 1 ? size[levelIndex - 1].length - 1 : size[levelIndex - 1].length - 2, cellIndex }; } return { levelIndex, rowIndex: rowIndex - 1, cellIndex }; case "down": if (rowIndex === size[levelIndex].length - 1) { return { levelIndex: levelIndex + 1, rowIndex: 0, cellIndex }; } if (rowIndex === size[levelIndex].length - 2 && cellIndex >= size[levelIndex][size[levelIndex].length - 1]) { return { levelIndex: levelIndex + 1, rowIndex: 0, cellIndex }; } return { levelIndex, rowIndex: rowIndex + 1, cellIndex }; case "left": if (levelIndex === 0 && rowIndex === 0 && cellIndex === 0) { return null; } if (rowIndex === 0 && cellIndex === 0) { return { levelIndex: levelIndex - 1, rowIndex: size[levelIndex - 1].length - 1, cellIndex: size[levelIndex - 1][size[levelIndex - 1].length - 1] - 1 }; } if (cellIndex === 0) { return { levelIndex, rowIndex: rowIndex - 1, cellIndex: size[levelIndex][rowIndex - 1] - 1 }; } return { levelIndex, rowIndex, cellIndex: cellIndex - 1 }; case "right": if (rowIndex === size[levelIndex].length - 1 && cellIndex === size[levelIndex][rowIndex] - 1) { return { levelIndex: levelIndex + 1, rowIndex: 0, cellIndex: 0 }; } if (cellIndex === size[levelIndex][rowIndex] - 1) { return { levelIndex, rowIndex: rowIndex + 1, cellIndex: 0 }; } return { levelIndex, rowIndex, cellIndex: cellIndex + 1 }; default: return { levelIndex, rowIndex, cellIndex }; } } function focusOnNextFocusableControl({ controlsRef, direction, levelIndex, rowIndex, cellIndex, size }) { const nextIndex = getNextIndex({ direction, size, rowIndex, cellIndex, levelIndex }); if (!nextIndex) { return; } const controlToFocus = controlsRef.current?.[nextIndex.levelIndex]?.[nextIndex.rowIndex]?.[nextIndex.cellIndex]; if (!controlToFocus) { return; } if (controlToFocus.disabled || controlToFocus.getAttribute("data-hidden") || controlToFocus.getAttribute("data-outside")) { focusOnNextFocusableControl({ controlsRef, direction, levelIndex: nextIndex.levelIndex, cellIndex: nextIndex.cellIndex, rowIndex: nextIndex.rowIndex, size }); } else { controlToFocus.focus(); } } function getDirection(key) { switch (key) { case "ArrowDown": return "down"; case "ArrowUp": return "up"; case "ArrowRight": return "right"; case "ArrowLeft": return "left"; default: return null; } } function getControlsSize(controlsRef) { return controlsRef.current?.map((column) => column.map((row) => row.length)); } function handleControlKeyDown({ controlsRef, levelIndex, rowIndex, cellIndex, event }) { const direction = getDirection(event.key); if (direction) { event.preventDefault(); const size = getControlsSize(controlsRef); focusOnNextFocusableControl({ controlsRef, direction, levelIndex, rowIndex, cellIndex, size }); } } function assignTime(originalDate, resultDate) { if (!originalDate || !resultDate) { return resultDate; } const hours = originalDate.getHours(); const minutes = originalDate.getMinutes(); const seconds = originalDate.getSeconds(); const ms = originalDate.getMilliseconds(); const result = new Date(resultDate); result.setHours(hours); result.setMinutes(minutes); result.setSeconds(seconds); result.setMilliseconds(ms); return result; } dayjs.extend(utcPlugin); dayjs.extend(timezonePlugin); function getTimezoneOffset(date, timezone) { if (timezone) { return dayjs(date).tz(timezone).utcOffset() + date.getTimezoneOffset(); } return 0; } const updateTimezone = (date, timezone, direction) => { if (!date) { return null; } if (!timezone) { return date; } let offset = getTimezoneOffset(date, timezone); if (direction === "remove") { offset *= -1; } return dayjs(date).add(offset, "minutes").toDate(); }; function shiftTimezone(direction, date, timezone, disabled) { if (disabled || !date) { return date; } if (Array.isArray(date)) { return date.map((d) => updateTimezone(d, timezone, direction)); } return updateTimezone(date, timezone, direction); } function getDefaultClampedDate({ minDate, maxDate, timezone }) { const today = shiftTimezone("add", /* @__PURE__ */ new Date(), timezone); if (!minDate && !maxDate) { return today; } if (minDate && dayjs(today).isBefore(minDate)) { return minDate; } if (maxDate && dayjs(today).isAfter(maxDate)) { return maxDate; } return today; } const DATES_PROVIDER_DEFAULT_SETTINGS = { locale: "en", timezone: null, firstDayOfWeek: 1, weekendDays: [0, 6], labelSeparator: "\u2013", consistentWeeks: false }; const DatesProviderContext = createContext(DATES_PROVIDER_DEFAULT_SETTINGS); function DatesProvider(t0) { const $ = c(5); const { settings, children } = t0; let t1; if ($[0] !== settings) { t1 = { ...DATES_PROVIDER_DEFAULT_SETTINGS, ...settings }; $[0] = settings; $[1] = t1; } else { t1 = $[1]; } let t2; if ($[2] !== t1 || $[3] !== children) { t2 = /* @__PURE__ */ jsx(DatesProviderContext.Provider, { value: t1, children }); $[2] = t1; $[3] = children; $[4] = t2; } else { t2 = $[4]; } return t2; } function useDatesContext() { const $ = c(17); const ctx = useContext(DatesProviderContext); let t0; if ($[0] !== ctx.locale) { t0 = (input) => input || ctx.locale; $[0] = ctx.locale; $[1] = t0; } else { t0 = $[1]; } const getLocale = t0; let t1; if ($[2] !== ctx.timezone) { t1 = (input_0) => input_0 || ctx.timezone || void 0; $[2] = ctx.timezone; $[3] = t1; } else { t1 = $[3]; } const getTimezone = t1; let t2; if ($[4] !== ctx.firstDayOfWeek) { t2 = (input_1) => typeof input_1 === "number" ? input_1 : ctx.firstDayOfWeek; $[4] = ctx.firstDayOfWeek; $[5] = t2; } else { t2 = $[5]; } const getFirstDayOfWeek = t2; let t3; if ($[6] !== ctx.weekendDays) { t3 = (input_2) => Array.isArray(input_2) ? input_2 : ctx.weekendDays; $[6] = ctx.weekendDays; $[7] = t3; } else { t3 = $[7]; } const getWeekendDays = t3; let t4; if ($[8] !== ctx.labelSeparator) { t4 = (input_3) => typeof input_3 === "string" ? input_3 : ctx.labelSeparator; $[8] = ctx.labelSeparator; $[9] = t4; } else { t4 = $[9]; } const getLabelSeparator = t4; let t5; if ($[10] !== ctx || $[11] !== getLocale || $[12] !== getTimezone || $[13] !== getFirstDayOfWeek || $[14] !== getWeekendDays || $[15] !== getLabelSeparator) { t5 = { ...ctx, getLocale, getTimezone, getFirstDayOfWeek, getWeekendDays, getLabelSeparator }; $[10] = ctx; $[11] = getLocale; $[12] = getTimezone; $[13] = getFirstDayOfWeek; $[14] = getWeekendDays; $[15] = getLabelSeparator; $[16] = t5; } else { t5 = $[16]; } return t5; } function formatValue(value, type) { if (type === "range" && Array.isArray(value)) { const [startDate, endDate] = value; if (!startDate) { return ""; } if (!endDate) { return `${startDate.toISOString()} \u2013`; } return `${startDate.toISOString()} \u2013 ${endDate.toISOString()}`; } if (type === "multiple" && Array.isArray(value)) { return value.map((date) => date?.toISOString()).filter(Boolean).join(", "); } if (!Array.isArray(value) && value) { return value.toISOString(); } return ""; } function HiddenDatesInput(t0) { const $ = c(7); const { value, type, name, form } = t0; let t1; if ($[0] !== value || $[1] !== type) { t1 = formatValue(value, type); $[0] = value; $[1] = type; $[2] = t1; } else { t1 = $[2]; } let t2; if ($[3] !== t1 || $[4] !== name || $[5] !== form) { t2 = /* @__PURE__ */ jsx("input", { type: "hidden", value: t1, name, form }); $[3] = t1; $[4] = name; $[5] = form; $[6] = t2; } else { t2 = $[6]; } return t2; } HiddenDatesInput.displayName = "@mantine/dates/HiddenDatesInput"; var classes$a = {"input":"m_468e7eda"}; const defaultProps$o = {}; const TimeInputImpl = (_props, ref) => { const $ = c(39); const props = useProps("TimeInput", defaultProps$o, _props); let classNames; let styles; let minTime; let maxTime; let withSeconds; let unstyled; let value; let others; let onChange; if ($[0] !== props) { const { classNames: t02, styles: t12, unstyled: t22, vars, withSeconds: t32, minTime: t42, maxTime: t52, value: t62, onChange: t72, ...t8 } = props; classNames = t02; styles = t12; unstyled = t22; withSeconds = t32; minTime = t42; maxTime = t52; value = t62; onChange = t72; others = t8; $[0] = props; $[1] = classNames; $[2] = styles; $[3] = minTime; $[4] = maxTime; $[5] = withSeconds; $[6] = unstyled; $[7] = value; $[8] = others; $[9] = onChange; } else { classNames = $[1]; styles = $[2]; minTime = $[3]; maxTime = $[4]; withSeconds = $[5]; unstyled = $[6]; value = $[7]; others = $[8]; onChange = $[9]; } let t0; if ($[10] !== classNames || $[11] !== styles || $[12] !== props) { t0 = { classNames, styles, props }; $[10] = classNames; $[11] = styles; $[12] = props; $[13] = t0; } else { t0 = $[13]; } const { resolvedClassNames, resolvedStyles } = useResolvedStylesApi( t0 ); let t1; if ($[14] !== minTime || $[15] !== maxTime || $[16] !== withSeconds) { t1 = (val) => { if (minTime !== void 0 || maxTime !== void 0) { const [hours, minutes, seconds] = val.split(":").map(Number); if (minTime) { const [minHours, minMinutes, minSeconds] = minTime.split(":").map(Number); if (hours < minHours || hours === minHours && minutes < minMinutes || withSeconds && hours === minHours && minutes === minMinutes && seconds < minSeconds) { return -1; } } if (maxTime) { const [maxHours, maxMinutes, maxSeconds] = maxTime.split(":").map(Number); if (hours > maxHours || hours === maxHours && minutes > maxMinutes || withSeconds && hours === maxHours && minutes === maxMinutes && seconds > maxSeconds) { return 1; } } } return 0; }; $[14] = minTime; $[15] = maxTime; $[16] = withSeconds; $[17] = t1; } else { t1 = $[17]; } const checkIfTimeLimitExceeded = t1; let t2; if ($[18] !== props.onBlur || $[19] !== props.onChange || $[20] !== minTime || $[21] !== maxTime || $[22] !== checkIfTimeLimitExceeded) { t2 = (event) => { props.onBlur?.(event); if (minTime !== void 0 || maxTime !== void 0) { const val_0 = event.currentTarget.value; if (val_0) { const check = checkIfTimeLimitExceeded(val_0); if (check === 1) { event.currentTarget.value = maxTime; props.onChange?.(event); } else { if (check === -1) { event.currentTarget.value = minTime; props.onChange?.(event); } } } } }; $[18] = props.onBlur; $[19] = props.onChange; $[20] = minTime; $[21] = maxTime; $[22] = checkIfTimeLimitExceeded; $[23] = t2; } else { t2 = $[23]; } const onTimeBlur = t2; const t3 = resolvedClassNames?.input; let t4; if ($[24] !== t3) { t4 = cx(classes$a.input, t3); $[24] = t3; $[25] = t4; } else { t4 = $[25]; } let t5; if ($[26] !== resolvedClassNames || $[27] !== t4) { t5 = { ...resolvedClassNames, input: t4 }; $[26] = resolvedClassNames; $[27] = t4; $[28] = t5; } else { t5 = $[28]; } const t6 = withSeconds ? 1 : 60; let t7; if ($[29] !== t5 || $[30] !== resolvedStyles || $[31] !== unstyled || $[32] !== ref || $[33] !== value || $[34] !== others || $[35] !== t6 || $[36] !== onChange || $[37] !== onTimeBlur) { t7 = /* @__PURE__ */ jsx( InputBase, { classNames: t5, styles: resolvedStyles, unstyled, ref, value, ...others, step: t6, onChange, onBlur: onTimeBlur, type: "time", __staticSelector: "TimeInput" } ); $[29] = t5; $[30] = resolvedStyles; $[31] = unstyled; $[32] = ref; $[33] = value; $[34] = others; $[35] = t6; $[36] = onChange; $[37] = onTimeBlur; $[38] = t7; } else { t7 = $[38]; } return t7; }; const TimeInput = factory(TimeInputImpl); TimeInput.classes = InputBase.classes; TimeInput.displayName = "@mantine/dates/TimeInput"; var classes$9 = {"day":"m_396ce5cb"}; const defaultProps$n = {}; const varsResolver$3 = createVarsResolver((_, { size }) => ({ day: { "--day-size": getSize(size, "day-size") } })); const Day = factory((_props, ref) => { const props = useProps("Day", defaultProps$n, _props); const { classNames, className, style, styles, unstyled, vars, date, disabled, __staticSelector, weekend, outside, selected, renderDay, inRange, firstInRange, lastInRange, hidden, static: isStatic, highlightToday, ...others } = props; const getStyles = useStyles({ name: __staticSelector || "Day", classes: classes$9, props, className, style, classNames, styles, unstyled, vars, varsResolver: varsResolver$3, rootSelector: "day" }); const ctx = useDatesContext(); return /* @__PURE__ */ jsx( UnstyledButton, { ...getStyles("day", { style: hidden ? { display: "none" } : void 0 }), component: isStatic ? "div" : "button", ref, disabled, "data-today": dayjs(date).isSame(shiftTimezone("add", /* @__PURE__ */ new Date(), ctx.getTimezone()), "day") || void 0, "data-hidden": hidden || void 0, "data-highlight-today": highlightToday || void 0, "data-disabled": disabled || void 0, "data-weekend": !disabled && !outside && weekend || void 0, "data-outside": !disabled && outside || void 0, "data-selected": !disabled && selected || void 0, "data-in-range": inRange && !disabled || void 0, "data-first-in-range": firstInRange && !disabled || void 0, "data-last-in-range": lastInRange && !disabled || void 0, "data-static": isStatic || void 0, unstyled, ...others, children: renderDay?.(date) || date.getDate() } ); }); Day.classes = classes$9; Day.displayName = "@mantine/dates/Day"; function getWeekdayNames({ locale, format = "dd", firstDayOfWeek = 1 }) { const baseDate = dayjs().day(firstDayOfWeek); const labels = []; for (let i = 0; i < 7; i += 1) { if (typeof format === "string") { labels.push(dayjs(baseDate).add(i, "days").locale(locale).format(format)); } else { labels.push(format(dayjs(baseDate).add(i, "days").toDate())); } } return labels; } var classes$8 = {"weekday":"m_18a3eca"}; const defaultProps$m = {}; const varsResolver$2 = createVarsResolver((_, { size }) => ({ weekdaysRow: { "--wr-fz": getFontSize(size), "--wr-spacing": getSpacing(size) } })); const WeekdaysRowImpl = (_props, ref) => { const $ = c(39); const props = useProps("WeekdaysRow", defaultProps$m, _props); let t0; let __staticSelector; let className; let style; let classNames; let styles; let unstyled; let vars; let locale; let firstDayOfWeek; let weekdayFormat; let others; if ($[0] !== props) { ({ classNames, className, style, styles, unstyled, vars, locale, firstDayOfWeek, weekdayFormat, cellComponent: t0, __staticSelector, ...others } = props); $[0] = props; $[1] = t0; $[2] = __staticSelector; $[3] = className; $[4] = style; $[5] = classNames; $[6] = styles; $[7] = unstyled; $[8] = vars; $[9] = locale; $[10] = firstDayOfWeek; $[11] = weekdayFormat; $[12] = others; } else { t0 = $[1]; __staticSelector = $[2]; className = $[3]; style = $[4]; classNames = $[5]; styles = $[6]; unstyled = $[7]; vars = $[8]; locale = $[9]; firstDayOfWeek = $[10]; weekdayFormat = $[11]; others = $[12]; } const CellComponent = t0 === void 0 ? "th" : t0; const t1 = __staticSelector || "WeekdaysRow"; let t2; if ($[13] !== t1 || $[14] !== props || $[15] !== className || $[16] !== style || $[17] !== classNames || $[18] !== styles || $[19] !== unstyled || $[20] !== vars) { t2 = { name: t1, classes: classes$8, props, className, style, classNames, styles, unstyled, vars, varsResolver: varsResolver$2, rootSelector: "weekdaysRow" }; $[13] = t1; $[14] = props; $[15] = className; $[16] = style; $[17] = classNames; $[18] = styles; $[19] = unstyled; $[20] = vars; $[21] = t2; } else { t2 = $[21]; } const getStyles = useStyles( t2 ); const ctx = useDatesContext(); let t3; if ($[22] !== ctx || $[23] !== locale || $[24] !== firstDayOfWeek || $[25] !== weekdayFormat || $[26] !== CellComponent || $[27] !== getStyles) { let t42; if ($[29] !== CellComponent || $[30] !== getStyles) { t42 = (weekday, index) => /* @__PURE__ */ jsx(CellComponent, { ...getStyles("weekday"), children: weekday }, index); $[29] = CellComponent; $[30] = getStyles; $[31] = t42; } else { t42 = $[31]; } t3 = getWeekdayNames({ locale: ctx.getLocale(locale), format: weekdayFormat, firstDayOfWeek: ctx.getFirstDayOfWeek(firstDayOfWeek) }).map( t42 ); $[22] = ctx; $[23] = locale; $[24] = firstDayOfWeek; $[25] = weekdayFormat; $[26] = CellComponent; $[27] = getStyles; $[28] = t3; } else { t3 = $[28]; } const weekdays = t3; let t4; if ($[32] !== getStyles) { t4 = getStyles("weekdaysRow"); $[32] = getStyles; $[33] = t4; } else { t4 = $[33]; } let t5; if ($[34] !== ref || $[35] !== t4 || $[36] !== others || $[37] !== weekdays) { t5 = /* @__PURE__ */ jsx(Box, { component: "tr", ref, ...t4, ...others, children: weekdays }); $[34] = ref; $[35] = t4; $[36] = others; $[37] = weekdays; $[38] = t5; } else { t5 = $[38]; } return t5; }; const WeekdaysRow = factory(WeekdaysRowImpl); WeekdaysRow.classes = classes$8; WeekdaysRow.displayName = "@mantine/dates/WeekdaysRow"; function getEndOfWeek(date, firstDayOfWeek = 1) { const value = new Date(date); const lastDayOfWeek = firstDayOfWeek === 0 ? 6 : firstDayOfWeek - 1; while (value.getDay() !== lastDayOfWeek) { value.setDate(value.getDate() + 1); } return value; } function getStartOfWeek(date, firstDayOfWeek = 1) { const value = new Date(date); while (value.getDay() !== firstDayOfWeek) { value.setDate(value.getDate() - 1); } return value; } function getMonthDays({ month, firstDayOfWeek = 1, consistentWeeks }) { const currentMonth = month.getMonth(); const startOfMonth = new Date(month.getFullYear(), currentMonth, 1); const endOfMonth = new Date(month.getFullYear(), month.getMonth() + 1, 0); const endDate = getEndOfWeek(endOfMonth, firstDayOfWeek); const date = getStartOfWeek(startOfMonth, firstDayOfWeek); const weeks = []; while (date <= endDate) { const days = []; for (let i = 0; i < 7; i += 1) { days.push(new Date(date)); date.setDate(date.getDate() + 1); } weeks.push(days); } if (consistentWeeks && weeks.length < 6) { const lastWeek = weeks[weeks.length - 1]; const lastDay = lastWeek[lastWeek.length - 1]; const nextDay = new Date(lastDay); nextDay.setDate(nextDay.getDate() + 1); while (weeks.length < 6) { const days = []; for (let i = 0; i < 7; i += 1) { days.push(new Date(nextDay)); nextDay.setDate(nextDay.getDate() + 1); } weeks.push(days); } } return weeks; } function isSameMonth(date, comparison) { return date.getFullYear() === comparison.getFullYear() && date.getMonth() === comparison.getMonth(); } function isAfterMinDate(date, minDate) { return minDate instanceof Date ? dayjs(date).isAfter(dayjs(minDate).subtract(1, "day"), "day") : true; } function isBeforeMaxDate(date, maxDate) { return maxDate instanceof Date ? dayjs(date).isBefore(dayjs(maxDate).add(1, "day"), "day") : true; } function getDateInTabOrder(dates, minDate, maxDate, getDateControlProps, excludeDate, hideOutsideDates, month) { const enabledDates = dates.flat().filter( (date) => isBeforeMaxDate(date, maxDate) && isAfterMinDate(date, minDate) && !excludeDate?.(date) && !getDateControlProps?.(date)?.disabled && (!hideOutsideDates || isSameMonth(date, month)) ); const selectedDate = enabledDates.find((date) => getDateControlProps?.(date)?.selected); if (selectedDate) { return selectedDate; } const currentDate = enabledDates.find((date) => dayjs().isSame(date, "date")); if (currentDate) { return currentDate; } return enabledDates[0]; } var classes$7 = {"month":"m_cc9820d3","monthCell":"m_8f457cd5"}; const defaultProps$l = { withCellSpacing: true }; const Month = factory((_props, ref) => { const props = useProps("Month", defaultProps$l, _props); const { classNames, className, style, styles, unstyled, vars, __staticSelector, locale, firstDayOfWeek, weekdayFormat, month, weekendDays, getDayProps, excludeDate, minDate, maxDate, renderDay, hideOutsideDates, hideWeekdays, getDayAriaLabel, static: isStatic, __getDayRef, __onDayKeyDown, __onDayClick, __onDayMouseEnter, __preventFocus, __stopPropagation, withCellSpacing, size, highlightToday, ...others } = props; const getStyles = useStyles({ name: __staticSelector || "Month", classes: classes$7, props, className, style, classNames, styles, unstyled, vars, rootSelector: "month" }); const ctx = useDatesContext(); const dates = getMonthDays({ month, firstDayOfWeek: ctx.getFirstDayOfWeek(firstDayOfWeek), consistentWeeks: ctx.consistentWeeks }); const dateInTabOrder = getDateInTabOrder( dates, minDate, maxDate, getDayProps, excludeDate, hideOutsideDates, month ); const { resolvedClassNames, resolvedStyles } = useResolvedStylesApi({ classNames, styles, props }); const rows = dates.map((row, rowIndex) => { const cells = row.map((date, cellIndex) => { const outside = !isSameMonth(date, month); const ariaLabel = getDayAriaLabel?.(date) || dayjs(date).locale(locale || ctx.locale).format("D MMMM YYYY"); const dayProps = getDayProps?.(date); const isDateInTabOrder = dayjs(date).isSame(dateInTabOrder, "date"); return /* @__PURE__ */ jsx( "td", { ...getStyles("monthCell"), "data-with-spacing": withCellSpacing || void 0, children: /* @__PURE__ */ jsx( Day, { __staticSelector: __staticSelector || "Month", classNames: resolvedClassNames, styles: resolvedStyles, unstyled, "data-mantine-stop-propagation": __stopPropagation || void 0, highlightToday, renderDay, date, size, weekend: ctx.getWeekendDays(weekendDays).includes(date.getDay()), outside, hidden: hideOutsideDates ? outside : false, "aria-label": ariaLabel, static: isStatic, disabled: excludeDate?.(date) || !isBeforeMaxDate(date, maxDate) || !isAfterMinDate(date, minDate), ref: (node) => __getDayRef?.(rowIndex, cellIndex, node), ...dayProps, onKeyDown: (event) => { dayProps?.onKeyDown?.(event); __onDayKeyDown?.(event, { rowIndex, cellIndex, date }); }, onMouseEnter: (event) => { dayProps?.onMouseEnter?.(event); __onDayMouseEnter?.(event, date); }, onClick: (event) => { dayProps?.onClick?.(event); __onDayClick?.(event, date); }, onMouseDown: (event) => { dayProps?.onMouseDown?.(event); __preventFocus && event.preventDefault(); }, tabIndex: __preventFocus || !isDateInTabOrder ? -1 : 0 } ) }, date.toString() ); }); return /* @__PURE__ */ jsx("tr", { ...getStyles("monthRow"), children: cells }, rowIndex); }); return /* @__PURE__ */ jsxs(Box, { component: "table", ...getStyles("month"), size, ref, ...others, children: [ !hideWeekdays && /* @__PURE__ */ jsx("thead", { ...getStyles("monthThead"), children: /* @__PURE__ */ jsx( WeekdaysRow, { __staticSelector: __staticSelector || "Month", locale, firstDayOfWeek, weekdayFormat, size, classNames: resolvedClassNames, styles: resolvedStyles, unstyled } ) }), /* @__PURE__ */ jsx("tbody", { ...getStyles("monthTbody"), children: rows }) ] }); }); Month.classes = classes$7; Month.displayName = "@mantine/dates/Month"; var classes$6 = {"pickerControl":"m_dc6a3c71"}; const defaultProps$k = {}; const varsResolver$1 = createVarsResolver((_, { size }) => ({ pickerControl: { "--dpc-fz": getFontSize(size), "--dpc-size": getSize(size, "dpc-size") } })); const PickerControlImpl = (_props, ref) => { const $ = c(36); const props = useProps("PickerControl", defaultProps$k, _props); let __staticSelector; let className; let style; let classNames; let styles; let unstyled; let vars; let selected; let disabled; let inRange; let firstInRange; let lastInRange; let others; if ($[0] !== props) { ({ classNames, className, style, styles, unstyled, vars, firstInRange, lastInRange, inRange, __staticSelector, selected, disabled, ...others } = props); $[0] = props; $[1] = __staticSelector; $[2] = className; $[3] = style; $[4] = classNames; $[5] = styles; $[6] = unstyled; $[7] = vars; $[8] = selected; $[9] = disabled; $[10] = inRange; $[11] = firstInRange; $[12] = lastInRange; $[13] = others; } else { __staticSelector = $[1]; className = $[2]; style = $[3]; classNames = $[4]; styles = $[5]; unstyled = $[6]; vars = $[7]; selected = $[8]; disabled = $[9]; inRange = $[10]; firstInRange = $[11]; lastInRange = $[12]; others = $[13]; } const t0 = __staticSelector || "PickerControl"; let t1; if ($[14] !== t0 || $[15] !== props || $[16] !== className || $[17] !== style || $[18] !== classNames || $[19] !== styles || $[20] !== unstyled || $[21] !== vars) { t1 = { name: t0, classes: classes$6, props, className, style, classNames, styles, unstyled, vars, varsResolver: varsResolver$1, rootSelector: "pickerControl" }; $[14] = t0; $[15] = props; $[16] = className; $[17] = style; $[18] = classNames; $[19] = styles; $[20] = unstyled; $[21] = vars; $[22] = t1; } else { t1 = $[22]; } const getStyles = useStyles( t1 ); let t2; if ($[23] !== getStyles) { t2 = getStyles("pickerControl"); $[23] = getStyles; $[24] = t2; } else { t2 = $[24]; } const t3 = selected && !disabled || void 0; const t4 = disabled || void 0; const t5 = inRange && !disabled && !selected || void 0; const t6 = firstInRange && !disabled || void 0; const t7 = lastInRange && !disabled || void 0; let t8; if ($[25] !== t2 || $[26] !== ref || $[27] !== unstyled || $[28] !== t3 || $[29] !== t4 || $[30] !== t5 || $[31] !== t6 || $[32] !== t7 || $[33] !== disabled || $[34] !== others) { t8 = /* @__PURE__ */ jsx( UnstyledButton, { ...t2, ref, unstyled, "data-picker-control": true, "data-selected": t3, "data-disabled": t4, "data-in-range": t5, "data-first-in-range": t6, "data-last-in-range": t7, disabled, ...others } ); $[25] = t2; $[26] = ref; $[27] = unstyled; $[28] = t3; $[29] = t4; $[30] = t5; $[31] = t6; $[32] = t7; $[33] = disabled; $[34] = others; $[35] = t8; } else { t8 = $[35]; } return t8; }; const PickerControl = factory(PickerControlImpl); PickerControl.classes = classes$6; PickerControl.displayName = "@mantine/dates/PickerControl"; function isYearDisabled(year, minDate, maxDate) { if (!minDate && !maxDate) { return false; } if (minDate && dayjs(year).isBefore(minDate, "year")) { return true; } if (maxDate && dayjs(year).isAfter(maxDate, "year")) { return true; } return false; } function getYearInTabOrder(years, minDate, maxDate, getYearControlProps) { const enabledYears = years.flat().filter( (year) => !isYearDisabled(year, minDate, maxDate) && !getYearControlProps?.(year)?.disabled ); const selectedYear = enabledYears.find((year) => getYearControlProps?.(year)?.selected); if (selectedYear) { return selectedYear; } const currentYear = enabledYears.find((year) => dayjs().isSame(year, "year")); if (currentYear) { return currentYear; } return enabledYears[0]; } function getYearsData(decade) { const year = decade.getFullYear(); const rounded = year - year % 10; let currentYearIndex = 0; const results = [[], [], [], []]; for (let i = 0; i < 4; i += 1) { const max = i === 3 ? 1 : 3; for (let j = 0; j < max; j += 1) { results[i].push(new Date(rounded + currentYearIndex, 0)); currentYearIndex += 1; } } return results; } var classes$5 = {"yearsList":"m_9206547b","yearsListCell":"m_c5a19c7d"}; const defaultProps$j = { yearsListFormat: "YYYY", withCellSpacing: true }; const YearsList = factory((_props, ref) => { const props = useProps("YearsList", defaultProps$j, _props); const { classNames, className, style, styles, unstyled, vars, decade, yearsListFormat, locale, minDate, maxDate, getYearControlProps, __staticSelector, __getControlRef, __onControlKeyDown, __onControlClick, __onControlMouseEnter, __preventFocus, __stopPropagation, withCellSpacing, size, ...others } = props; const getStyles = useStyles({ name: __staticSelector || "YearsList", classes: classes$5, props, className, style, classNames, styles, unstyled, vars, rootSelector: "yearsList" }); const ctx = useDatesContext(); const years = getYearsData(decade); const yearInTabOrder = getYearInTabOrder(years, minDate, maxDate, getYearControlProps); const rows = years.map((yearsRow, rowIndex) => { const cells = yearsRow.map((year, cellIndex) => { const controlProps = getYearControlProps?.(year); const isYearInTabOrder = dayjs(year).isSame(yearInTabOrder, "year"); return /* @__PURE__ */ jsx( "td", { ...getStyles("yearsListCell"), "data-with-spacing": withCellSpacing || void 0, children: /* @__PURE__ */ jsx( PickerControl, { ...getStyles("yearsListControl"), size, unstyled, "data-mantine-stop-propagation": __stopPropagation || void 0, disabled: isYearDisabled(year, minDate, maxDate), ref: (node) => __getControlRef?.(rowIndex, cellIndex, node), ...controlProps, onKeyDown: (event) => { controlProps?.onKeyDown?.(event); __onControlKeyDown?.(event, { rowIndex, cellIndex, date: year }); }, onClick: (event) => { controlProps?.onClick?.(event); __onControlClick?.(event, year); }, onMouseEnter: (event) => { controlProps?.onMouseEnter?.(event); __onControlMouseEnter?.(event, year); }, onMouseDown: (event) => { controlProps?.onMouseDown?.(event); __preventFocus && event.preventDefault(); }, tabIndex: __preventFocus || !isYearInTabOrder ? -1 : 0, children: dayjs(year).locale(ctx.getLocale(locale)).format(yearsListFormat) } ) }, cellIndex ); }); return /* @__PURE__ */ jsx("tr", { ...getStyles("yearsListRow"), children: cells }, rowIndex); }); return /* @__PURE__ */ jsx(Box, { component: "table", ref, size, ...getStyles("yearsList"), ...others, children: /* @__PURE__ */ jsx("tbody", { children: rows }) }); }); YearsList.classes = classes$5; YearsList.displayName = "@mantine/dates/YearsList"; function isMonthDisabled(month, minDate, maxDate) { if (!minDate && !maxDate) { return false; } if (minDate && dayjs(month).isBefore(minDate, "month")) { return true; } if (maxDate && dayjs(month).isAfter(maxDate, "month")) { return true; } return false; } function getMonthInTabOrder(months, minDate, maxDate, getMonthControlProps) { const enabledMonths = months.flat().filter( (month) => !isMonthDisabled(month, minDate, maxDate) && !getMonthControlProps?.(month)?.disabled ); const selectedMonth = enabledMonths.find((month) => getMonthControlProps?.(month)?.selected); if (selectedMonth) { return selectedMonth; } const currentMonth = enabledMonths.find((month) => dayjs().isSame(month, "month")); if (currentMonth) { return currentMonth; } return enabledMonths[0]; } function getMonthsData(year) { const startOfYear = dayjs(year).startOf("year").toDate(); const results = [[], [], [], []]; let currentMonthIndex = 0; for (let i = 0; i < 4; i += 1) { for (let j = 0; j < 3; j += 1) { results[i].push(dayjs(startOfYear).add(currentMonthIndex, "months").toDate()); currentMonthIndex += 1; } } return results; } var classes$4 = {"monthsList":"m_2a6c32d","monthsListCell":"m_fe27622f"}; const defaultProps$i = { monthsListFormat: "MMM", withCellSpacing: true }; const MonthsList = factory((_props, ref) => { const props = useProps("MonthsList", defaultProps$i, _props); const { classNames, className, style, styles, unstyled, vars, __staticSelector, year, monthsListFormat, locale, minDate, maxDate, getMonthControlProps, __getControlRef, __onControlKeyDown, __onControlClick, __onControlMouseEnter, __preventFocus, __stopPropagation, withCellSpacing, size, ...others } = props; const getStyles = useStyles({ name: __staticSelector || "MonthsList", classes: classes$4, props, className, style, classNames, styles, unstyled, vars, rootSelector: "monthsList" }); const ctx = useDatesContext(); const months = getMonthsData(year); const monthInTabOrder = getMonthInTabOrder(months, minDate, maxDate, getMonthControlProps); const rows = months.map((monthsRow, rowIndex) => { const cells = monthsRow.map((month, cellIndex) => { const controlProps = getMonthControlProps?.(month); const isMonthInTabOrder = dayjs(month).isSame(monthInTabOrder, "month"); return /* @__PURE__ */ jsx( "td", { ...getStyles("monthsListCell"), "data-with-spacing": withCellSpacing || void 0, children: /* @__PURE__ */ jsx( PickerControl, { ...getStyles("monthsListControl"), size, unstyled, __staticSelector: __staticSelector || "MonthsList", "data-mantine-stop-propagation": __stopPropagation || void 0, disabled: isMonthDisabled(month, minDate, maxDate), ref: (node) => __getControlRef?.(rowIndex, cellIndex, node), ...controlProps, onKeyDown: (event) => { controlProps?.onKeyDown?.(event); __onControlKeyDown?.(event, { rowIndex, cellIndex, date: month }); }, onClick: (event) => { controlProps?.onClick?.(event); __onControlClick?.(event, month); }, onMouseEnter: (event) => { controlProps?.onMouseEnter?.(event); __onControlMouseEnter?.(event, month); }, onMouseDown: (event) => { controlProps?.onMouseDown?.(event); __preventFocus && event.preventDefault(); }, tabIndex: __preventFocus || !isMonthInTabOrder ? -1 : 0, children: dayjs(month).locale(ctx.getLocale(locale)).format(monthsListFormat) } ) }, cellIndex ); }); return /* @__PURE__ */ jsx("tr", { ...getStyles("monthsListRow"), children: cells }, rowIndex); }); return /* @__PURE__ */ jsx(Box, { component: "table", ref, size, ...getStyles("monthsList"), ...others, children: /* @__PURE__ */ jsx("tbody", { children: rows }) }); }); MonthsList.classes = classes$4; MonthsList.displayName = "@mantine/dates/MonthsList"; var classes$3 = {"calendarHeader":"m_730a79ed","calendarHeaderLevel":"m_f6645d97","calendarHeaderControl":"m_2351eeb0","calendarHeaderControlIcon":"m_367dc749"}; const defaultProps$h = { nextDisabled: false, previousDisabled: false, hasNextLevel: true, withNext: true, withPrevious: true }; const varsResolver = createVarsResolver((_, { size }) => ({ calendarHeader: { "--dch-control-size": getSize(size, "dch-control-size"), "--dch-fz": getFontSize(size) } })); const CalendarHeader = factory((_props, ref) => { const props = useProps("CalendarHeader", defaultProps$h, _props); const { classNames, className, style, styles, unstyled, vars, nextIcon, previousIcon, nextLabel, previousLabel, onNext, onPrevious, onLevelClick, label, nextDisabled, previousDisabled, hasNextLevel, levelControlAriaLabel, withNext, withPrevious, __staticSelector, __preventFocus, __stopPropagation, ...others } = props; const getStyles = useStyles({ name: __staticSelector || "CalendarHeader", classes: classes$3, props, className, style, classNames, styles, unstyled, vars, varsResolver, rootSelector: "calendarHeader" }); const preventFocus = __preventFocus ? (event) => event.preventDefault() : void 0; return /* @__PURE__ */ jsxs(Box, { ...getStyles("calendarHeader"), ref, ...others, children: [ withPrevious && /* @__PURE__ */ jsx( UnstyledButton, { ...getStyles("calendarHeaderControl"), "data-direction": "previous", "aria-label": previousLabel, onClick: onPrevious, unstyled, onMouseDown: preventFocus, disabled: previousDisabled, "data-disabled": previousDisabled || void 0, tabIndex: __preventFocus || previousDisabled ? -1 : 0, "data-mantine-stop-propagation": __stopPropagation || void 0, children: previousIcon || /* @__PURE__ */ jsx( AccordionChevron, { ...getStyles("calendarHeaderControlIcon"), "data-direction": "previous", size: "45%" } ) } ), /* @__PURE__ */ jsx( UnstyledButton, { component: hasNextLevel ? "button" : "div", ...getStyles("calendarHeaderLevel"), onClick: hasNextLevel ? onLevelClick : void 0, unstyled, onMouseDown: hasNextLevel ? preventFocus : void 0, disabled: !hasNextLevel, "data-static": !hasNextLevel || void 0, "aria-label": levelControlAriaLabel, tabIndex: __preventFocus || !hasNextLevel ? -1 : 0, "data-mantine-stop-propagation": __stopPropagation || void 0, children: label } ), withNext && /* @__PURE__ */ jsx( UnstyledButton, { ...getStyles("calendarHeaderControl"), "data-direction": "next", "aria-label": nextLabel, onClick: onNext, unstyled, onMouseDown: preventFocus, disabled: nextDisabled, "data-disabled": nextDisabled || void 0, tabIndex: __preventFocus || nextDisabled ? -1 : 0, "data-mantine-stop-propagation": __stopPropagation || void 0, children: nextIcon || /* @__PURE__ */ jsx( AccordionChevron, { ...getStyles("calendarHeaderControlIcon"), "data-direction": "next", size: "45%" } ) } ) ] }); }); CalendarHeader.classes = classes$3; CalendarHeader.displayName = "@mantine/dates/CalendarHeader"; function getDecadeRange(decade) { const years = getYearsData(decade); return [years[0][0], years[3][0]]; } const defaultProps$g = { decadeLabelFormat: "YYYY" }; const DecadeLevel = factory((_props, ref) => { const props = useProps("DecadeLevel", defaultProps$g, _props); const { // YearsList settings decade, locale, minDate, maxDate, yearsListFormat, getYearControlProps, __getControlRef, __onControlKeyDown, __onControlClick, __onControlMouseEnter, withCellSpacing, // CalendarHeader settings __preventFocus, nextIcon, previousIcon, nextLabel, previousLabel, onNext, onPrevious, nextDisabled, previousDisabled, levelControlAriaLabel, withNext, withPrevious, // Other props decadeLabelFormat, classNames, styles, unstyled, __staticSelector, __stopPropagation, size, ...others } = props; const ctx = useDatesContext(); const [startOfDecade, endOfDecade] = getDecadeRange(decade); const stylesApiProps = { __staticSelector: __staticSelector || "DecadeLevel", classNames, styles, unstyled, size }; const _nextDisabled = typeof nextDisabled === "boolean" ? nextDisabled : maxDate ? !dayjs(endOfDecade).endOf("year").isBefore(maxDate) : false; const _previousDisabled = typeof previousDisabled === "boolean" ? previousDisabled : minDate ? !dayjs(startOfDecade).startOf("year").isAfter(minDate) : false; const formatDecade = (date, format) => dayjs(date).locale(locale || ctx.locale).format(format); return /* @__PURE__ */ jsxs(Box, { "data-decade-level": true, size, ref, ...others, children: [ /* @__PURE__ */ jsx( CalendarHeader, { label: typeof decadeLabelFormat === "function" ? decadeLabelFormat(startOfDecade, endOfDecade) : `${formatDecade(startOfDecade, decadeLabelFormat)} \u2013 ${formatDecade( endOfDecade, decadeLabelFormat )}`, __preventFocus, __stopPropagation, nextIcon, previousIcon, nextLabel, previousLabel, onNext, onPrevious, nextDisabled: _nextDisabled, previousDisabled: _previousDisabled, hasNextLevel: false, levelControlAriaLabel, withNext, withPrevious, ...stylesApiProps } ), /* @__PURE__ */ jsx( YearsList, { decade, locale, minDate, maxDate, yearsListFormat, getYearControlProps, __getControlRef, __onControlKeyDown, __onControlClick, __onControlMouseEnter, __preventFocus, __stopPropagation, withCellSpacing, ...stylesApiProps } ) ] }); }); DecadeLevel.classes = { ...YearsList.classes, ...CalendarHeader.classes }; DecadeLevel.displayName = "@mantine/dates/DecadeLevel"; const defaultProps$f = { yearLabelFormat: "YYYY" }; const YearLevel = factory((_props, ref) => { const props = useProps("YearLevel", defaultProps$f, _props); const { // MonthsList settings year, locale, minDate, maxDate, monthsListFormat, getMonthControlProps, __getControlRef, __onControlKeyDown, __onControlClick, __onControlMouseEnter, withCellSpacing, // CalendarHeader settings __preventFocus, nextIcon, previousIcon, nextLabel, previousLabel, onNext, onPrevious, onLevelClick, nextDisabled, previousDisabled, hasNextLevel, levelControlAriaLabel, withNext, withPrevious, // Other props yearLabelFormat, __staticSelector, __stopPropagation, size, classNames, styles, unstyled, ...others } = props; const ctx = useDatesContext(); const stylesApiProps = { __staticSelector: __staticSelector || "YearLevel", classNames, styles, unstyled, size }; const _nextDisabled = typeof nextDisabled === "boolean" ? nextDisabled : maxDate ? !dayjs(year).endOf("year").isBefore(maxDate) : false; const _previousDisabled = typeof previousDisabled === "boolean" ? previousDisabled : minDate ? !dayjs(year).startOf("year").isAfter(minDate) : false; return /* @__PURE__ */ jsxs(Box, { "data-year-level": true, size, ref, ...others, children: [ /* @__PURE__ */ jsx( CalendarHeader, { label: typeof yearLabelFormat === "function" ? yearLabelFormat(year) : dayjs(year).locale(locale || ctx.locale).format(yearLabelFormat), __preventFocus, __stopPropagation, nextIcon, previousIcon, nextLabel, previousLabel, onNext, onPrevious, onLevelClick, nextDisabled: _nextDisabled, previousDisabled: _previousDisabled, hasNextLevel, levelControlAriaLabel, withNext, withPrevious, ...stylesApiProps } ), /* @__PURE__ */ jsx( MonthsList, { year, locale, minDate, maxDate, monthsListFormat, getMonthControlProps, __getControlRef, __onControlKeyDown, __onControlClick, __onControlMouseEnter, __preventFocus, __stopPropagation, withCellSpacing, ...stylesApiProps } ) ] }); }); YearLevel.classes = { ...CalendarHeader.classes, ...MonthsList.classes }; YearLevel.displayName = "@mantine/dates/YearLevel"; const defaultProps$e = { monthLabelFormat: "MMMM YYYY" }; const MonthLevel = factory((_props, ref) => { const props = useProps("MonthLevel", defaultProps$e, _props); const { // Month settings month, locale, firstDayOfWeek, weekdayFormat, weekendDays, getDayProps, excludeDate, minDate, maxDate, renderDay, hideOutsideDates, hideWeekdays, getDayAriaLabel, __getDayRef, __onDayKeyDown, __onDayClick, __onDayMouseEnter, withCellSpacing, highlightToday, // CalendarHeader settings __preventFocus, __stopPropagation, nextIcon, previousIcon, nextLabel, previousLabel, onNext, onPrevious, onLevelClick, nextDisabled, previousDisabled, hasNextLevel, levelControlAriaLabel, withNext, withPrevious, // Other props monthLabelFormat, classNames, styles, unstyled, __staticSelector, size, static: isStatic, ...others } = props; const ctx = useDatesContext(); const stylesApiProps = { __staticSelector: __staticSelector || "MonthLevel", classNames, styles, unstyled, size }; const _nextDisabled = typeof nextDisabled === "boolean" ? nextDisabled : maxDate ? !dayjs(month).endOf("month").isBefore(maxDate) : false; const _previousDisabled = typeof previousDisabled === "boolean" ? previousDisabled : minDate ? !dayjs(month).startOf("month").isAfter(minDate) : false; return /* @__PURE__ */ jsxs(Box, { "data-month-level": true, size, ref, ...others, children: [ /* @__PURE__ */ jsx( CalendarHeader, { label: typeof monthLabelFormat === "function" ? monthLabelFormat(month) : dayjs(month).locale(locale || ctx.locale).format(monthLabelFormat), __preventFocus, __stopPropagation, nextIcon, previousIcon, nextLabel, previousLabel, onNext, onPrevious, onLevelClick, nextDisabled: _nextDisabled, previousDisabled: _previousDisabled, hasNextLevel, levelControlAriaLabel, withNext, withPrevious, ...stylesApiProps } ), /* @__PURE__ */ jsx( Month, { month, locale, firstDayOfWeek, weekdayFormat, weekendDays, getDayProps, excludeDate, minDate, maxDate, renderDay, hideOutsideDates, hideWeekdays, getDayAriaLabel, __getDayRef, __onDayKeyDown, __onDayClick, __onDayMouseEnter, __preventFocus, __stopPropagation, static: isStatic, withCellSpacing, highlightToday, ...stylesApiProps } ) ] }); }); MonthLevel.classes = { ...Month.classes, ...CalendarHeader.classes }; MonthLevel.displayName = "@mantine/dates/MonthLevel"; var classes$2 = {"levelsGroup":"m_30b26e33"}; const defaultProps$d = {}; const LevelsGroupImpl = (_props, ref) => { const $ = c(24); const props = useProps("LevelsGroup", defaultProps$d, _props); let __staticSelector; let className; let style; let classNames; let styles; let unstyled; let vars; let others; if ($[0] !== props) { ({ classNames, className, style, styles, unstyled, vars, __staticSelector, ...others } = props); $[0] = props; $[1] = __staticSelector; $[2] = className; $[3] = style; $[4] = classNames; $[5] = styles; $[6] = unstyled; $[7] = vars; $[8] = others; } else { __staticSelector = $[1]; className = $[2]; style = $[3]; classNames = $[4]; styles = $[5]; unstyled = $[6]; vars = $[7]; others = $[8]; } const t0 = __staticSelector || "LevelsGroup"; let t1; if ($[9] !== t0 || $[10] !== props || $[11] !== className || $[12] !== style || $[13] !== classNames || $[14] !== styles || $[15] !== unstyled || $[16] !== vars) { t1 = { name: t0, classes: classes$2, props, className, style, classNames, styles, unstyled, vars, rootSelector: "levelsGroup" }; $[9] = t0; $[10] = props; $[11] = className; $[12] = style; $[13] = classNames; $[14] = styles; $[15] = unstyled; $[16] = vars; $[17] = t1; } else { t1 = $[17]; } const getStyles = useStyles( t1 ); let t2; if ($[18] !== getStyles) { t2 = getStyles("levelsGroup"); $[18] = getStyles; $[19] = t2; } else { t2 = $[19]; } let t3; if ($[20] !== ref || $[21] !== t2 || $[22] !== others) { t3 = /* @__PURE__ */ jsx(Box, { ref, ...t2, ...others }); $[20] = ref; $[21] = t2; $[22] = others; $[23] = t3; } else { t3 = $[23]; } return t3; }; const LevelsGroup = factory(LevelsGroupImpl); LevelsGroup.classes = classes$2; LevelsGroup.displayName = "@mantine/dates/LevelsGroup"; const defaultProps$c = { numberOfColumns: 1 }; const DecadeLevelGroupImpl = (_props, ref) => { const $ = c(38); const props = useProps("DecadeLevelGroup", defaultProps$c, _props); let numberOfColumns; let decade; let size; let yearsListFormat; let decadeLabelFormat; let __onControlClick; let __onControlMouseEnter; let levelControlAriaLabel; let locale; let minDate; let maxDate; let __preventFocus; let __stopPropagation; let nextIcon; let previousIcon; let nextLabel; let previousLabel; let onNext; let onPrevious; let nextDisabled; let previousDisabled; let getYearControlProps; let __staticSelector; let classNames; let styles; let unstyled; let withCellSpacing; let others; if ($[0] !== props) { const { decade: t02, locale: t12, minDate: t2, maxDate: t3, yearsListFormat: t4, getYearControlProps: t5, __onControlClick: t6, __onControlMouseEnter: t7, withCellSpacing: t8, __preventFocus: t9, nextIcon: t10, previousIcon: t11, nextLabel: t122, previousLabel: t13, onNext: t14, onPrevious: t15, nextDisabled: t16, previousDisabled: t17, classNames: t18, styles: t19, unstyled: t20, __staticSelector: t21, __stopPropagation: t22, numberOfColumns: t23, levelControlAriaLabel: t24, decadeLabelFormat: t25, size: t26, vars, ...t27 } = props; decade = t02; locale = t12; minDate = t2; maxDate = t3; yearsListFormat = t4; getYearControlProps = t5; __onControlClick = t6; __onControlMouseEnter = t7; withCellSpacing = t8; __preventFocus = t9; nextIcon = t10; previousIcon = t11; nextLabel = t122; previousLabel = t13; onNext = t14; onPrevious = t15; nextDisabled = t16; previousDisabled = t17; classNames = t18; styles = t19; unstyled = t20; __staticSelector = t21; __stopPropagation = t22; numberOfColumns = t23; levelControlAriaLabel = t24; decadeLabelFormat = t25; size = t26; others = t27; $[0] = props; $[1] = numberOfColumns; $[2] = decade; $[3] = size; $[4] = yearsListFormat; $[5] = decadeLabelFormat; $[6] = __onControlClick; $[7] = __onControlMouseEnter; $[8] = levelControlAriaLabel; $[9] = locale; $[10] = minDate; $[11] = maxDate; $[12] = __preventFocus; $[13] = __stopPropagation; $[14] = nextIcon; $[15] = previousIcon; $[16] = nextLabel; $[17] = previousLabel; $[18] = onNext; $[19] = onPrevious; $[20] = nextDisabled; $[21] = previousDisabled; $[22] = getYearControlProps; $[23] = __staticSelector; $[24] = classNames; $[25] = styles; $[26] = unstyled; $[27] = withCellSpacing; $[28] = others; } else { numberOfColumns = $[1]; decade = $[2]; size = $[3]; yearsListFormat = $[4]; decadeLabelFormat = $[5]; __onControlClick = $[6]; __onControlMouseEnter = $[7]; levelControlAriaLabel = $[8]; locale = $[9]; minDate = $[10]; maxDate = $[11]; __preventFocus = $[12]; __stopPropagation = $[13]; nextIcon = $[14]; previousIcon = $[15]; nextLabel = $[16]; previousLabel = $[17]; onNext = $[18]; onPrevious = $[19]; nextDisabled = $[20]; previousDisabled = $[21]; getYearControlProps = $[22]; __staticSelector = $[23]; classNames = $[24]; styles = $[25]; unstyled = $[26]; withCellSpacing = $[27]; others = $[28]; } const controlsRef = useRef([]); const decades = Array(numberOfColumns).fill( 0 ).map( (_, decadeIndex) => { const currentDecade = dayjs(decade).add( decadeIndex * 10, "years" ).toDate(); return /* @__PURE__ */ jsx( DecadeLevel, { size, yearsListFormat, decade: currentDecade, withNext: decadeIndex === numberOfColumns - 1, withPrevious: decadeIndex === 0, decadeLabelFormat, __onControlClick, __onControlMouseEnter, __onControlKeyDown: (event, payload) => handleControlKeyDown( { levelIndex: decadeIndex, rowIndex: payload.rowIndex, cellIndex: payload.cellIndex, event, controlsRef } ), __getControlRef: (rowIndex, cellIndex, node) => { if (!Array.isArray(controlsRef.current[decadeIndex])) { controlsRef.current[decadeIndex] = []; } if (!Array.isArray(controlsRef.current[decadeIndex][rowIndex])) { controlsRef.current[decadeIndex][rowIndex] = []; } controlsRef.current[decadeIndex][rowIndex][cellIndex] = node; }, levelControlAriaLabel: typeof levelControlAriaLabel === "function" ? levelControlAriaLabel(currentDecade) : levelControlAriaLabel, locale, minDate, maxDate, __preventFocus, __stopPropagation, nextIcon, previousIcon, nextLabel, previousLabel, onNext, onPrevious, nextDisabled, previousDisabled, getYearControlProps, __staticSelector: __staticSelector || "DecadeLevelGroup", classNames, styles, unstyled, withCellSpacing }, decadeIndex ); } ); const t0 = __staticSelector || "DecadeLevelGroup"; let t1; if ($[29] !== classNames || $[30] !== styles || $[31] !== t0 || $[32] !== ref || $[33] !== size || $[34] !== unstyled || $[35] !== others || $[36] !== decades) { t1 = /* @__PURE__ */ jsx( LevelsGroup, { classNames, styles, __staticSelector: t0, ref, size, unstyled, ...others, children: decades } ); $[29] = classNames; $[30] = styles; $[31] = t0; $[32] = ref; $[33] = size; $[34] = unstyled; $[35] = others; $[36] = decades; $[37] = t1; } else { t1 = $[37]; } return t1; }; const DecadeLevelGroup = factory(DecadeLevelGroupImpl); DecadeLevelGroup.classes = { ...LevelsGroup.classes, ...DecadeLevel.classes }; DecadeLevelGroup.displayName = "@mantine/dates/DecadeLevelGroup"; const defaultProps$b = { numberOfColumns: 1 }; const YearLevelGroupImpl = (_props, ref) => { const $ = c(40); const props = useProps("YearLevelGroup", defaultProps$b, _props); let numberOfColumns; let year; let size; let monthsListFormat; let yearLabelFormat; let __stopPropagation; let __onControlClick; let __onControlMouseEnter; let levelControlAriaLabel; let locale; let minDate; let maxDate; let __preventFocus; let nextIcon; let previousIcon; let nextLabel; let previousLabel; let onNext; let onPrevious; let onLevelClick; let nextDisabled; let previousDisabled; let hasNextLevel; let getMonthControlProps; let classNames; let styles; let unstyled; let __staticSelector; let withCellSpacing; let others; if ($[0] !== props) { const { year: t02, locale: t12, minDate: t2, maxDate: t3, monthsListFormat: t4, getMonthControlProps: t5, __onControlClick: t6, __onControlMouseEnter: t7, withCellSpacing: t8, __preventFocus: t9, nextIcon: t10, previousIcon: t11, nextLabel: t122, previousLabel: t13, onNext: t14, onPrevious: t15, onLevelClick: t16, nextDisabled: t17, previousDisabled: t18, hasNextLevel: t19, classNames: t20, styles: t21, unstyled: t22, __staticSelector: t23, __stopPropagation: t24, numberOfColumns: t25, levelControlAriaLabel: t26, yearLabelFormat: t27, size: t28, vars, ...t29 } = props; year = t02; locale = t12; minDate = t2; maxDate = t3; monthsListFormat = t4; getMonthControlProps = t5; __onControlClick = t6; __onControlMouseEnter = t7; withCellSpacing = t8; __preventFocus = t9; nextIcon = t10; previousIcon = t11; nextLabel = t122; previousLabel = t13; onNext = t14; onPrevious = t15; onLevelClick = t16; nextDisabled = t17; previousDisabled = t18; hasNextLevel = t19; classNames = t20; styles = t21; unstyled = t22; __staticSelector = t23; __stopPropagation = t24; numberOfColumns = t25; levelControlAriaLabel = t26; yearLabelFormat = t27; size = t28; others = t29; $[0] = props; $[1] = numberOfColumns; $[2] = year; $[3] = size; $[4] = monthsListFormat; $[5] = yearLabelFormat; $[6] = __stopPropagation; $[7] = __onControlClick; $[8] = __onControlMouseEnter; $[9] = levelControlAriaLabel; $[10] = locale; $[11] = minDate; $[12] = maxDate; $[13] = __preventFocus; $[14] = nextIcon; $[15] = previousIcon; $[16] = nextLabel; $[17] = previousLabel; $[18] = onNext; $[19] = onPrevious; $[20] = onLevelClick; $[21] = nextDisabled; $[22] = previousDisabled; $[23] = hasNextLevel; $[24] = getMonthControlProps; $[25] = classNames; $[26] = styles; $[27] = unstyled; $[28] = __staticSelector; $[29] = withCellSpacing; $[30] = others; } else { numberOfColumns = $[1]; year = $[2]; size = $[3]; monthsListFormat = $[4]; yearLabelFormat = $[5]; __stopPropagation = $[6]; __onControlClick = $[7]; __onControlMouseEnter = $[8]; levelControlAriaLabel = $[9]; locale = $[10]; minDate = $[11]; maxDate = $[12]; __preventFocus = $[13]; nextIcon = $[14]; previousIcon = $[15]; nextLabel = $[16]; previousLabel = $[17]; onNext = $[18]; onPrevious = $[19]; onLevelClick = $[20]; nextDisabled = $[21]; previousDisabled = $[22]; hasNextLevel = $[23]; getMonthControlProps = $[24]; classNames = $[25]; styles = $[26]; unstyled = $[27]; __staticSelector = $[28]; withCellSpacing = $[29]; others = $[30]; } const controlsRef = useRef([]); const years = Array(numberOfColumns).fill( 0 ).map( (_, yearIndex) => { const currentYear = dayjs(year).add(yearIndex, "years").toDate(); return /* @__PURE__ */ jsx( YearLevel, { size, monthsListFormat, year: currentYear, withNext: yearIndex === numberOfColumns - 1, withPrevious: yearIndex === 0, yearLabelFormat, __stopPropagation, __onControlClick, __onControlMouseEnter, __onControlKeyDown: (event, payload) => handleControlKeyDown( { levelIndex: yearIndex, rowIndex: payload.rowIndex, cellIndex: payload.cellIndex, event, controlsRef } ), __getControlRef: (rowIndex, cellIndex, node) => { if (!Array.isArray(controlsRef.current[yearIndex])) { controlsRef.current[yearIndex] = []; } if (!Array.isArray(controlsRef.current[yearIndex][rowIndex])) { controlsRef.current[yearIndex][rowIndex] = []; } controlsRef.current[yearIndex][rowIndex][cellIndex] = node; }, levelControlAriaLabel: typeof levelControlAriaLabel === "function" ? levelControlAriaLabel(currentYear) : levelControlAriaLabel, locale, minDate, maxDate, __preventFocus, nextIcon, previousIcon, nextLabel, previousLabel, onNext, onPrevious, onLevelClick, nextDisabled, previousDisabled, hasNextLevel, getMonthControlProps, classNames, styles, unstyled, __staticSelector: __staticSelector || "YearLevelGroup", withCellSpacing }, yearIndex ); } ); const t0 = __staticSelector || "YearLevelGroup"; let t1; if ($[31] !== classNames || $[32] !== styles || $[33] !== t0 || $[34] !== ref || $[35] !== size || $[36] !== unstyled || $[37] !== others || $[38] !== years) { t1 = /* @__PURE__ */ jsx( LevelsGroup, { classNames, styles, __staticSelector: t0, ref, size, unstyled, ...others, children: years } ); $[31] = classNames; $[32] = styles; $[33] = t0; $[34] = ref; $[35] = size; $[36] = unstyled; $[37] = others; $[38] = years; $[39] = t1; } else { t1 = $[39]; } return t1; }; const YearLevelGroup = factory(YearLevelGroupImpl); YearLevelGroup.classes = { ...YearLevel.classes, ...LevelsGroup.classes }; YearLevelGroup.displayName = "@mantine/dates/YearLevelGroup"; const defaultProps$a = { numberOfColumns: 1 }; const MonthLevelGroupImpl = (_props, ref) => { const $ = c(48); const props = useProps("MonthLevelGroup", defaultProps$a, _props); let numberOfColumns; let month; let monthLabelFormat; let __stopPropagation; let __onDayClick; let __onDayMouseEnter; let levelControlAriaLabel; let locale; let firstDayOfWeek; let weekdayFormat; let weekendDays; let getDayProps; let excludeDate; let minDate; let maxDate; let renderDay; let hideOutsideDates; let hideWeekdays; let getDayAriaLabel; let __preventFocus; let nextIcon; let previousIcon; let nextLabel; let previousLabel; let onNext; let onPrevious; let onLevelClick; let nextDisabled; let previousDisabled; let hasNextLevel; let classNames; let styles; let unstyled; let __staticSelector; let size; let isStatic; let withCellSpacing; let highlightToday; let others; if ($[0] !== props) { const { month: t02, locale: t12, firstDayOfWeek: t2, weekdayFormat: t3, weekendDays: t4, getDayProps: t5, excludeDate: t6, minDate: t7, maxDate: t8, renderDay: t9, hideOutsideDates: t10, hideWeekdays: t11, getDayAriaLabel: t122, __onDayClick: t13, __onDayMouseEnter: t14, withCellSpacing: t15, highlightToday: t16, __preventFocus: t17, nextIcon: t18, previousIcon: t19, nextLabel: t20, previousLabel: t21, onNext: t22, onPrevious: t23, onLevelClick: t24, nextDisabled: t25, previousDisabled: t26, hasNextLevel: t27, classNames: t28, styles: t29, unstyled: t30, numberOfColumns: t31, levelControlAriaLabel: t32, monthLabelFormat: t33, __staticSelector: t34, __stopPropagation: t35, size: t36, static: t37, vars, ...t38 } = props; month = t02; locale = t12; firstDayOfWeek = t2; weekdayFormat = t3; weekendDays = t4; getDayProps = t5; excludeDate = t6; minDate = t7; maxDate = t8; renderDay = t9; hideOutsideDates = t10; hideWeekdays = t11; getDayAriaLabel = t122; __onDayClick = t13; __onDayMouseEnter = t14; withCellSpacing = t15; highlightToday = t16; __preventFocus = t17; nextIcon = t18; previousIcon = t19; nextLabel = t20; previousLabel = t21; onNext = t22; onPrevious = t23; onLevelClick = t24; nextDisabled = t25; previousDisabled = t26; hasNextLevel = t27; classNames = t28; styles = t29; unstyled = t30; numberOfColumns = t31; levelControlAriaLabel = t32; monthLabelFormat = t33; __staticSelector = t34; __stopPropagation = t35; size = t36; isStatic = t37; others = t38; $[0] = props; $[1] = numberOfColumns; $[2] = month; $[3] = monthLabelFormat; $[4] = __stopPropagation; $[5] = __onDayClick; $[6] = __onDayMouseEnter; $[7] = levelControlAriaLabel; $[8] = locale; $[9] = firstDayOfWeek; $[10] = weekdayFormat; $[11] = weekendDays; $[12] = getDayProps; $[13] = excludeDate; $[14] = minDate; $[15] = maxDate; $[16] = renderDay; $[17] = hideOutsideDates; $[18] = hideWeekdays; $[19] = getDayAriaLabel; $[20] = __preventFocus; $[21] = nextIcon; $[22] = previousIcon; $[23] = nextLabel; $[24] = previousLabel; $[25] = onNext; $[26] = onPrevious; $[27] = onLevelClick; $[28] = nextDisabled; $[29] = previousDisabled; $[30] = hasNextLevel; $[31] = classNames; $[32] = styles; $[33] = unstyled; $[34] = __staticSelector; $[35] = size; $[36] = isStatic; $[37] = withCellSpacing; $[38] = highlightToday; $[39] = others; } else { numberOfColumns = $[1]; month = $[2]; monthLabelFormat = $[3]; __stopPropagation = $[4]; __onDayClick = $[5]; __onDayMouseEnter = $[6]; levelControlAriaLabel = $[7]; locale = $[8]; firstDayOfWeek = $[9]; weekdayFormat = $[10]; weekendDays = $[11]; getDayProps = $[12]; excludeDate = $[13]; minDate = $[14]; maxDate = $[15]; renderDay = $[16]; hideOutsideDates = $[17]; hideWeekdays = $[18]; getDayAriaLabel = $[19]; __preventFocus = $[20]; nextIcon = $[21]; previousIcon = $[22]; nextLabel = $[23]; previousLabel = $[24]; onNext = $[25]; onPrevious = $[26]; onLevelClick = $[27]; nextDisabled = $[28]; previousDisabled = $[29]; hasNextLevel = $[30]; classNames = $[31]; styles = $[32]; unstyled = $[33]; __staticSelector = $[34]; size = $[35]; isStatic = $[36]; withCellSpacing = $[37]; highlightToday = $[38]; others = $[39]; } const daysRefs = useRef([]); const months = Array(numberOfColumns).fill( 0 ).map( (_, monthIndex) => { const currentMonth = dayjs(month).add(monthIndex, "months").toDate(); return /* @__PURE__ */ jsx( MonthLevel, { month: currentMonth, withNext: monthIndex === numberOfColumns - 1, withPrevious: monthIndex === 0, monthLabelFormat, __stopPropagation, __onDayClick, __onDayMouseEnter, __onDayKeyDown: (event, payload) => handleControlKeyDown( { levelIndex: monthIndex, rowIndex: payload.rowIndex, cellIndex: payload.cellIndex, event, controlsRef: daysRefs } ), __getDayRef: (rowIndex, cellIndex, node) => { if (!Array.isArray(daysRefs.current[monthIndex])) { daysRefs.current[monthIndex] = []; } if (!Array.isArray(daysRefs.current[monthIndex][rowIndex])) { daysRefs.current[monthIndex][rowIndex] = []; } daysRefs.current[monthIndex][rowIndex][cellIndex] = node; }, levelControlAriaLabel: typeof levelControlAriaLabel === "function" ? levelControlAriaLabel(currentMonth) : levelControlAriaLabel, locale, firstDayOfWeek, weekdayFormat, weekendDays, getDayProps, excludeDate, minDate, maxDate, renderDay, hideOutsideDates, hideWeekdays, getDayAriaLabel, __preventFocus, nextIcon, previousIcon, nextLabel, previousLabel, onNext, onPrevious, onLevelClick, nextDisabled, previousDisabled, hasNextLevel, classNames, styles, unstyled, __staticSelector: __staticSelector || "MonthLevelGroup", size, static: isStatic, withCellSpacing, highlightToday }, monthIndex ); } ); const t0 = __staticSelector || "MonthLevelGroup"; let t1; if ($[40] !== classNames || $[41] !== styles || $[42] !== t0 || $[43] !== ref || $[44] !== size || $[45] !== others || $[46] !== months) { t1 = /* @__PURE__ */ jsx( LevelsGroup, { classNames, styles, __staticSelector: t0, ref, size, ...others, children: months } ); $[40] = classNames; $[41] = styles; $[42] = t0; $[43] = ref; $[44] = size; $[45] = others; $[46] = months; $[47] = t1; } else { t1 = $[47]; } return t1; }; const MonthLevelGroup = factory(MonthLevelGroupImpl); MonthLevelGroup.classes = { ...LevelsGroup.classes, ...MonthLevel.classes }; MonthLevelGroup.displayName = "@mantine/dates/MonthLevelGroup"; var classes$1 = {"input":"m_6fa5e2aa"}; const defaultProps$9 = {}; const PickerInputBase = factory((_props, ref) => { const { inputProps, wrapperProps, placeholder, classNames, styles, unstyled, popoverProps, modalProps, dropdownType, children, formattedValue, dropdownHandlers, dropdownOpened, onClick, clearable, onClear, clearButtonProps, rightSection, shouldClear, readOnly, disabled, value, name, form, type, ...others } = useInputProps("PickerInputBase", defaultProps$9, _props); const _rightSection = rightSection || (clearable && shouldClear && !readOnly && !disabled ? /* @__PURE__ */ jsx( CloseButton, { variant: "transparent", onClick: onClear, unstyled, size: inputProps.size || "sm", ...clearButtonProps } ) : null); const handleClose = () => { const isInvalidRangeValue = type === "range" && Array.isArray(value) && value[0] && !value[1]; if (isInvalidRangeValue) { onClear(); } dropdownHandlers.close(); }; return /* @__PURE__ */ jsxs(Fragment, { children: [ dropdownType === "modal" && !readOnly && /* @__PURE__ */ jsx( Modal, { opened: dropdownOpened, onClose: handleClose, withCloseButton: false, size: "auto", "data-dates-modal": true, unstyled, ...modalProps, children } ), /* @__PURE__ */ jsx(Input.Wrapper, { ...wrapperProps, children: /* @__PURE__ */ jsxs( Popover, { position: "bottom-start", opened: dropdownOpened, trapFocus: true, returnFocus: true, unstyled, ...popoverProps, disabled: popoverProps?.disabled || dropdownType === "modal" || readOnly, onClose: () => { popoverProps?.onClose?.(); handleClose(); }, children: [ /* @__PURE__ */ jsx(Popover.Target, { children: /* @__PURE__ */ jsx( Input, { "aria-label": formattedValue || placeholder, "data-dates-input": true, "data-read-only": readOnly || void 0, disabled, component: "button", type: "button", multiline: true, onClick: (event) => { onClick?.(event); dropdownHandlers.toggle(); }, rightSection: _rightSection, ...inputProps, ref, classNames: { ...classNames, input: cx(classes$1.input, classNames?.input) }, ...others, children: formattedValue || /* @__PURE__ */ jsx( Input.Placeholder, { error: inputProps.error, unstyled, className: classNames?.placeholder, style: styles?.placeholder, children: placeholder } ) } ) }), /* @__PURE__ */ jsx(Popover.Dropdown, { "data-dates-dropdown": true, children }) ] } ) }), /* @__PURE__ */ jsx(HiddenDatesInput, { value, name, form, type }) ] }); }); PickerInputBase.classes = classes$1; PickerInputBase.displayName = "@mantine/dates/PickerInputBase"; const getEmptyValue = (type) => type === "range" ? [null, null] : type === "multiple" ? [] : null; function useUncontrolledDates(t0) { const $ = c(26); const { type, value, defaultValue, onChange, applyTimezone: t1 } = t0; const applyTimezone = t1 === void 0 ? true : t1; const storedType = useRef(type); const ctx = useDatesContext(); let t2; if ($[0] !== ctx || $[1] !== applyTimezone || $[2] !== value) { t2 = shiftTimezone("add", value, ctx.getTimezone(), !applyTimezone); $[0] = ctx; $[1] = applyTimezone; $[2] = value; $[3] = t2; } else { t2 = $[3]; } let t3; if ($[4] !== ctx || $[5] !== applyTimezone || $[6] !== defaultValue) { t3 = shiftTimezone("add", defaultValue, ctx.getTimezone(), !applyTimezone); $[4] = ctx; $[5] = applyTimezone; $[6] = defaultValue; $[7] = t3; } else { t3 = $[7]; } let t4; if ($[8] !== type) { t4 = getEmptyValue(type); $[8] = type; $[9] = t4; } else { t4 = $[9]; } let t5; if ($[10] !== onChange || $[11] !== ctx || $[12] !== applyTimezone) { t5 = (newDate) => { onChange?.(shiftTimezone("remove", newDate, ctx.getTimezone(), !applyTimezone)); }; $[10] = onChange; $[11] = ctx; $[12] = applyTimezone; $[13] = t5; } else { t5 = $[13]; } let t6; if ($[14] !== t2 || $[15] !== t3 || $[16] !== t4 || $[17] !== t5) { t6 = { value: t2, defaultValue: t3, finalValue: t4, onChange: t5 }; $[14] = t2; $[15] = t3; $[16] = t4; $[17] = t5; $[18] = t6; } else { t6 = $[18]; } const [_value, _setValue, controlled] = useUncontrolled( t6 ); let _finalValue = _value; if (storedType.current !== type) { storedType.current = type; if (value === void 0) { let t72; if ($[19] !== defaultValue || $[20] !== type) { t72 = defaultValue !== void 0 ? defaultValue : getEmptyValue(type); $[19] = defaultValue; $[20] = type; $[21] = t72; } else { t72 = $[21]; } _finalValue = t72; _setValue(_finalValue); } else { if (process.env.NODE_ENV === "development") { bb0: switch (type) { case "default": { if (value !== null && typeof value !== "string") { console.error( "[@mantine/dates/use-uncontrolled-dates] Value must be type of `null` or `string`" ); } break bb0; } case "multiple": { if (!(value instanceof Array)) { console.error( "[@mantine/dates/use-uncontrolled-dates] Value must be type of `string[]`" ); } break bb0; } case "range": { if (!(value instanceof Array) || value.length !== 2) { console.error( "[@mantine/dates/use-uncontrolled-dates] Value must be type of `[string, string]`" ); } } } } } } let t7; if ($[22] !== _finalValue || $[23] !== _setValue || $[24] !== controlled) { t7 = [_finalValue, _setValue, controlled]; $[22] = _finalValue; $[23] = _setValue; $[24] = controlled; $[25] = t7; } else { t7 = $[25]; } return t7; } function isInRange(date, range) { const _range = [...range].sort((a, b) => a.getTime() - b.getTime()); return dayjs(_range[0]).startOf("day").subtract(1, "ms").isBefore(date) && dayjs(_range[1]).endOf("day").add(1, "ms").isAfter(date); } function useDatesState({ type, level, value, defaultValue, onChange, allowSingleDateInRange, allowDeselect, onMouseLeave, applyTimezone = true }) { const [_value, setValue] = useUncontrolledDates({ type, value, defaultValue, onChange, applyTimezone }); const [pickedDate, setPickedDate] = useState( type === "range" ? _value[0] && !_value[1] ? _value[0] : null : null ); const [hoveredDate, setHoveredDate] = useState(null); const onDateChange = (date) => { if (type === "range") { if (pickedDate instanceof Date && !_value[1]) { if (dayjs(date).isSame(pickedDate, level) && !allowSingleDateInRange) { setPickedDate(null); setHoveredDate(null); setValue([null, null]); return; } const result = [date, pickedDate]; result.sort((a, b) => a.getTime() - b.getTime()); setValue(result); setHoveredDate(null); setPickedDate(null); return; } if (_value[0] && !_value[1] && dayjs(date).isSame(_value[0], level) && !allowSingleDateInRange) { setPickedDate(null); setHoveredDate(null); setValue([null, null]); return; } setValue([date, null]); setHoveredDate(null); setPickedDate(date); return; } if (type === "multiple") { if (_value.some((selected) => dayjs(selected).isSame(date, level))) { setValue(_value.filter((selected) => !dayjs(selected).isSame(date, level))); } else { setValue([..._value, date]); } return; } if (_value && allowDeselect && dayjs(date).isSame(_value, level)) { setValue(null); } else { setValue(date); } }; const isDateInRange = (date) => { if (pickedDate instanceof Date && hoveredDate instanceof Date) { return isInRange(date, [hoveredDate, pickedDate]); } if (_value[0] instanceof Date && _value[1] instanceof Date) { return isInRange(date, _value); } return false; }; const onRootMouseLeave = type === "range" ? (event) => { onMouseLeave?.(event); setHoveredDate(null); } : onMouseLeave; const isFirstInRange = (date) => { if (!(_value[0] instanceof Date)) { return false; } if (dayjs(date).isSame(_value[0], level)) { return !(hoveredDate && dayjs(hoveredDate).isBefore(_value[0])); } return false; }; const isLastInRange = (date) => { if (_value[1] instanceof Date) { return dayjs(date).isSame(_value[1], level); } if (!(_value[0] instanceof Date) || !hoveredDate) { return false; } return dayjs(hoveredDate).isBefore(_value[0]) && dayjs(date).isSame(_value[0], level); }; const getControlProps = (date) => { if (type === "range") { return { selected: _value.some( (selection) => selection && dayjs(selection).isSame(date, level) ), inRange: isDateInRange(date), firstInRange: isFirstInRange(date), lastInRange: isLastInRange(date), "data-autofocus": !!_value[0] && dayjs(_value[0]).isSame(date, level) || void 0 }; } if (type === "multiple") { return { selected: _value.some( (selection) => selection && dayjs(selection).isSame(date, level) ), "data-autofocus": !!_value[0] && dayjs(_value[0]).isSame(date, level) || void 0 }; } const selected = dayjs(_value).isSame(date, level); return { selected, "data-autofocus": selected || void 0 }; }; const onHoveredDateChange = type === "range" && pickedDate ? setHoveredDate : () => { }; useEffect(() => { if (type === "range" && !_value[0] && !_value[1]) { setPickedDate(null); } }, [value]); return { onDateChange, onRootMouseLeave, onHoveredDateChange, getControlProps, _value, setValue }; } function useDatesInput(t0) { const $ = c(30); const { type, value, defaultValue, onChange, locale, format, closeOnChange, sortDates, labelSeparator, valueFormatter } = t0; const ctx = useDatesContext(); const [dropdownOpened, dropdownHandlers] = useDisclosure(false); let t1; if ($[0] !== type || $[1] !== value || $[2] !== defaultValue || $[3] !== onChange) { t1 = { type, value, defaultValue, onChange }; $[0] = type; $[1] = value; $[2] = defaultValue; $[3] = onChange; $[4] = t1; } else { t1 = $[4]; } const [_value, _setValue] = useUncontrolledDates( t1 ); let t2; if ($[5] !== ctx || $[6] !== locale || $[7] !== labelSeparator || $[8] !== type || $[9] !== _value || $[10] !== format || $[11] !== valueFormatter) { t2 = getFormattedDate( { type, date: _value, locale: ctx.getLocale(locale), format, labelSeparator: ctx.getLabelSeparator(labelSeparator), formatter: valueFormatter } ); $[5] = ctx; $[6] = locale; $[7] = labelSeparator; $[8] = type; $[9] = _value; $[10] = format; $[11] = valueFormatter; $[12] = t2; } else { t2 = $[12]; } const formattedValue = t2; let t3; if ($[13] !== closeOnChange || $[14] !== type || $[15] !== dropdownHandlers || $[16] !== sortDates || $[17] !== _setValue) { t3 = (val) => { if (closeOnChange) { if (type === "default") { dropdownHandlers.close(); } if (type === "range" && val[0] && val[1]) { dropdownHandlers.close(); } } if (sortDates && type === "multiple") { _setValue([...val].sort((a, b) => a.getTime() - b.getTime())); } else { _setValue(val); } }; $[13] = closeOnChange; $[14] = type; $[15] = dropdownHandlers; $[16] = sortDates; $[17] = _setValue; $[18] = t3; } else { t3 = $[18]; } const setValue = t3; let t4; if ($[19] !== setValue || $[20] !== type) { t4 = () => setValue(type === "range" ? [null, null] : type === "multiple" ? [] : null); $[19] = setValue; $[20] = type; $[21] = t4; } else { t4 = $[21]; } const onClear = t4; const shouldClear = type === "range" ? !!_value[0] : type === "multiple" ? _value.length > 0 : _value !== null; let t5; if ($[22] !== _value || $[23] !== setValue || $[24] !== onClear || $[25] !== shouldClear || $[26] !== formattedValue || $[27] !== dropdownOpened || $[28] !== dropdownHandlers) { t5 = { _value, setValue, onClear, shouldClear, formattedValue, dropdownOpened, dropdownHandlers }; $[22] = _value; $[23] = setValue; $[24] = onClear; $[25] = shouldClear; $[26] = formattedValue; $[27] = dropdownOpened; $[28] = dropdownHandlers; $[29] = t5; } else { t5 = $[29]; } return t5; } function levelToNumber(level, fallback) { if (!level) { return fallback || 0; } return level === "month" ? 0 : level === "year" ? 1 : 2; } function levelNumberToLevel(levelNumber) { return levelNumber === 0 ? "month" : levelNumber === 1 ? "year" : "decade"; } function clampLevel(level, minLevel, maxLevel) { return levelNumberToLevel( clamp( levelToNumber(level, 0), levelToNumber(minLevel, 0), levelToNumber(maxLevel, 2) ) ); } const defaultProps$8 = { maxLevel: "decade", minLevel: "month", __updateDateOnYearSelect: true, __updateDateOnMonthSelect: true }; const Calendar = factory((_props, ref) => { const props = useProps("Calendar", defaultProps$8, _props); const { vars, // CalendarLevel props maxLevel, minLevel, defaultLevel, level, onLevelChange, date, defaultDate, onDateChange, numberOfColumns, columnsToScroll, ariaLabels, onYearSelect, onMonthSelect, onYearMouseEnter, onMonthMouseEnter, __updateDateOnYearSelect, __updateDateOnMonthSelect, // MonthLevelGroup props firstDayOfWeek, weekdayFormat, weekendDays, getDayProps, excludeDate, renderDay, hideOutsideDates, hideWeekdays, getDayAriaLabel, monthLabelFormat, nextIcon, previousIcon, __onDayClick, __onDayMouseEnter, withCellSpacing, highlightToday, // YearLevelGroup props monthsListFormat, getMonthControlProps, yearLabelFormat, // DecadeLevelGroup props yearsListFormat, getYearControlProps, decadeLabelFormat, // Other props classNames, styles, unstyled, minDate, maxDate, locale, __staticSelector, size, __preventFocus, __stopPropagation, onNextDecade, onPreviousDecade, onNextYear, onPreviousYear, onNextMonth, onPreviousMonth, static: isStatic, __timezoneApplied, ...others } = props; const { resolvedClassNames, resolvedStyles } = useResolvedStylesApi({ classNames, styles, props }); const [_level, setLevel] = useUncontrolled({ value: level ? clampLevel(level, minLevel, maxLevel) : void 0, defaultValue: defaultLevel ? clampLevel(defaultLevel, minLevel, maxLevel) : void 0, finalValue: clampLevel(void 0, minLevel, maxLevel), onChange: onLevelChange }); const [_date, setDate] = useUncontrolledDates({ type: "default", value: date, defaultValue: defaultDate, onChange: onDateChange, applyTimezone: !__timezoneApplied }); const stylesApiProps = { __staticSelector: __staticSelector || "Calendar", styles: resolvedStyles, classNames: resolvedClassNames, unstyled, size }; const ctx = useDatesContext(); const _columnsToScroll = columnsToScroll || numberOfColumns || 1; const currentDate = _date || shiftTimezone("add", /* @__PURE__ */ new Date(), ctx.getTimezone()); const handleNextMonth = () => { const nextDate = dayjs(currentDate).add(_columnsToScroll, "month").toDate(); onNextMonth?.(nextDate); setDate(nextDate); }; const handlePreviousMonth = () => { const nextDate = dayjs(currentDate).subtract(_columnsToScroll, "month").toDate(); onPreviousMonth?.(nextDate); setDate(nextDate); }; const handleNextYear = () => { const nextDate = dayjs(currentDate).add(_columnsToScroll, "year").toDate(); onNextYear?.(nextDate); setDate(nextDate); }; const handlePreviousYear = () => { const nextDate = dayjs(currentDate).subtract(_columnsToScroll, "year").toDate(); onPreviousYear?.(nextDate); setDate(nextDate); }; const handleNextDecade = () => { const nextDate = dayjs(currentDate).add(10 * _columnsToScroll, "year").toDate(); onNextDecade?.(nextDate); setDate(nextDate); }; const handlePreviousDecade = () => { const nextDate = dayjs(currentDate).subtract(10 * _columnsToScroll, "year").toDate(); onPreviousDecade?.(nextDate); setDate(nextDate); }; return /* @__PURE__ */ jsxs(Box, { ref, size, "data-calendar": true, ...others, children: [ _level === "month" && /* @__PURE__ */ jsx( MonthLevelGroup, { month: currentDate, minDate, maxDate, firstDayOfWeek, weekdayFormat, weekendDays, getDayProps, excludeDate, renderDay, hideOutsideDates, hideWeekdays, getDayAriaLabel, onNext: handleNextMonth, onPrevious: handlePreviousMonth, hasNextLevel: maxLevel !== "month", onLevelClick: () => setLevel("year"), numberOfColumns, locale, levelControlAriaLabel: ariaLabels?.monthLevelControl, nextLabel: ariaLabels?.nextMonth, nextIcon, previousLabel: ariaLabels?.previousMonth, previousIcon, monthLabelFormat, __onDayClick, __onDayMouseEnter, __preventFocus, __stopPropagation, static: isStatic, withCellSpacing, highlightToday, ...stylesApiProps } ), _level === "year" && /* @__PURE__ */ jsx( YearLevelGroup, { year: currentDate, numberOfColumns, minDate, maxDate, monthsListFormat, getMonthControlProps, locale, onNext: handleNextYear, onPrevious: handlePreviousYear, hasNextLevel: maxLevel !== "month" && maxLevel !== "year", onLevelClick: () => setLevel("decade"), levelControlAriaLabel: ariaLabels?.yearLevelControl, nextLabel: ariaLabels?.nextYear, nextIcon, previousLabel: ariaLabels?.previousYear, previousIcon, yearLabelFormat, __onControlMouseEnter: onMonthMouseEnter, __onControlClick: (_event, payload) => { __updateDateOnMonthSelect && setDate(payload); setLevel(clampLevel("month", minLevel, maxLevel)); onMonthSelect?.(payload); }, __preventFocus, __stopPropagation, withCellSpacing, ...stylesApiProps } ), _level === "decade" && /* @__PURE__ */ jsx( DecadeLevelGroup, { decade: currentDate, minDate, maxDate, yearsListFormat, getYearControlProps, locale, onNext: handleNextDecade, onPrevious: handlePreviousDecade, numberOfColumns, nextLabel: ariaLabels?.nextDecade, nextIcon, previousLabel: ariaLabels?.previousDecade, previousIcon, decadeLabelFormat, __onControlMouseEnter: onYearMouseEnter, __onControlClick: (_event, payload) => { __updateDateOnYearSelect && setDate(payload); setLevel(clampLevel("year", minLevel, maxLevel)); onYearSelect?.(payload); }, __preventFocus, __stopPropagation, withCellSpacing, ...stylesApiProps } ) ] }); }); Calendar.classes = { ...DecadeLevelGroup.classes, ...YearLevelGroup.classes, ...MonthLevelGroup.classes }; Calendar.displayName = "@mantine/dates/Calendar"; function pickCalendarProps(props) { const { maxLevel, minLevel, defaultLevel, level, onLevelChange, nextIcon, previousIcon, date, defaultDate, onDateChange, numberOfColumns, columnsToScroll, ariaLabels, onYearSelect, onMonthSelect, onYearMouseEnter, onMonthMouseEnter, onNextMonth, onPreviousMonth, onNextYear, onPreviousYear, onNextDecade, onPreviousDecade, withCellSpacing, highlightToday, __updateDateOnYearSelect, __updateDateOnMonthSelect, // MonthLevelGroup props firstDayOfWeek, weekdayFormat, weekendDays, getDayProps, excludeDate, renderDay, hideOutsideDates, hideWeekdays, getDayAriaLabel, monthLabelFormat, // YearLevelGroup props monthsListFormat, getMonthControlProps, yearLabelFormat, // DecadeLevelGroup props yearsListFormat, getYearControlProps, decadeLabelFormat, // External picker props allowSingleDateInRange, allowDeselect, // Other props minDate, maxDate, locale, ...others } = props; return { calendarProps: { maxLevel, minLevel, defaultLevel, level, onLevelChange, nextIcon, previousIcon, date, defaultDate, onDateChange, numberOfColumns, columnsToScroll, ariaLabels, onYearSelect, onMonthSelect, onYearMouseEnter, onMonthMouseEnter, onNextMonth, onPreviousMonth, onNextYear, onPreviousYear, onNextDecade, onPreviousDecade, withCellSpacing, highlightToday, __updateDateOnYearSelect, __updateDateOnMonthSelect, // MonthLevelGroup props firstDayOfWeek, weekdayFormat, weekendDays, getDayProps, excludeDate, renderDay, hideOutsideDates, hideWeekdays, getDayAriaLabel, monthLabelFormat, // YearLevelGroup props monthsListFormat, getMonthControlProps, yearLabelFormat, // DecadeLevelGroup props yearsListFormat, getYearControlProps, decadeLabelFormat, // External picker props allowSingleDateInRange, allowDeselect, // Other props minDate, maxDate, locale }, others }; } const defaultProps$7 = { type: "default" }; const YearPicker = factory((_props, ref) => { const props = useProps("YearPicker", defaultProps$7, _props); const { classNames, styles, vars, type, defaultValue, value, onChange, __staticSelector, getYearControlProps, allowSingleDateInRange, allowDeselect, onMouseLeave, onYearSelect, __updateDateOnYearSelect, __timezoneApplied, ...others } = props; const { onDateChange, onRootMouseLeave, onHoveredDateChange, getControlProps } = useDatesState({ type, level: "year", allowDeselect, allowSingleDateInRange, value, defaultValue, onChange, onMouseLeave, applyTimezone: !__timezoneApplied }); const { resolvedClassNames, resolvedStyles } = useResolvedStylesApi({ classNames, styles, props }); const ctx = useDatesContext(); return /* @__PURE__ */ jsx( Calendar, { ref, minLevel: "decade", __updateDateOnYearSelect: __updateDateOnYearSelect ?? false, __staticSelector: __staticSelector || "YearPicker", onMouseLeave: onRootMouseLeave, onYearMouseEnter: (_event, date) => onHoveredDateChange(date), onYearSelect: (date) => { onDateChange(date); onYearSelect?.(date); }, getYearControlProps: (date) => ({ ...getControlProps(date), ...getYearControlProps?.(date) }), classNames: resolvedClassNames, styles: resolvedStyles, ...others, date: shiftTimezone("add", others.date, ctx.getTimezone(), __timezoneApplied), __timezoneApplied: true } ); }); YearPicker.classes = Calendar.classes; YearPicker.displayName = "@mantine/dates/YearPicker"; const defaultProps$6 = { type: "default" }; const MonthPicker = factory((_props, ref) => { const props = useProps("MonthPicker", defaultProps$6, _props); const { classNames, styles, vars, type, defaultValue, value, onChange, __staticSelector, getMonthControlProps, allowSingleDateInRange, allowDeselect, onMouseLeave, onMonthSelect, __updateDateOnMonthSelect, __timezoneApplied, onLevelChange, ...others } = props; const { onDateChange, onRootMouseLeave, onHoveredDateChange, getControlProps } = useDatesState({ type, level: "month", allowDeselect, allowSingleDateInRange, value, defaultValue, onChange, onMouseLeave, applyTimezone: !__timezoneApplied }); const { resolvedClassNames, resolvedStyles } = useResolvedStylesApi({ classNames, styles, props }); const ctx = useDatesContext(); return /* @__PURE__ */ jsx( Calendar, { ref, minLevel: "year", __updateDateOnMonthSelect: __updateDateOnMonthSelect ?? false, __staticSelector: __staticSelector || "MonthPicker", onMouseLeave: onRootMouseLeave, onMonthMouseEnter: (_event, date) => onHoveredDateChange(date), onMonthSelect: (date) => { onDateChange(date); onMonthSelect?.(date); }, getMonthControlProps: (date) => ({ ...getControlProps(date), ...getMonthControlProps?.(date) }), classNames: resolvedClassNames, styles: resolvedStyles, onLevelChange, ...others, date: shiftTimezone("add", others.date, ctx.getTimezone(), __timezoneApplied) } ); }); MonthPicker.classes = Calendar.classes; MonthPicker.displayName = "@mantine/dates/MonthPicker"; const defaultProps$5 = { type: "default", defaultLevel: "month", numberOfColumns: 1 }; const DatePicker = factory((_props, ref) => { const props = useProps("DatePicker", defaultProps$5, _props); const { classNames, styles, vars, type, defaultValue, value, onChange, __staticSelector, getDayProps, allowSingleDateInRange, allowDeselect, onMouseLeave, numberOfColumns, hideOutsideDates, __onDayMouseEnter, __onDayClick, __timezoneApplied, ...others } = props; const { onDateChange, onRootMouseLeave, onHoveredDateChange, getControlProps } = useDatesState({ type, level: "day", allowDeselect, allowSingleDateInRange, value, defaultValue, onChange, onMouseLeave, applyTimezone: !__timezoneApplied }); const { resolvedClassNames, resolvedStyles } = useResolvedStylesApi({ classNames, styles, props }); const ctx = useDatesContext(); return /* @__PURE__ */ jsx( Calendar, { ref, minLevel: "month", classNames: resolvedClassNames, styles: resolvedStyles, __staticSelector: __staticSelector || "DatePicker", onMouseLeave: onRootMouseLeave, numberOfColumns, hideOutsideDates: hideOutsideDates ?? numberOfColumns !== 1, __onDayMouseEnter: (_event, date) => { onHoveredDateChange(date); __onDayMouseEnter?.(_event, date); }, __onDayClick: (_event, date) => { onDateChange(date); __onDayClick?.(_event, date); }, getDayProps: (date) => ({ ...getControlProps(date), ...getDayProps?.(date) }), ...others, date: shiftTimezone("add", others.date, ctx.getTimezone(), __timezoneApplied), __timezoneApplied: true } ); }); DatePicker.classes = Calendar.classes; DatePicker.displayName = "@mantine/dates/DatePicker"; function dateStringParser(dateString, timezone) { if (dateString === null) { return null; } const date = shiftTimezone("add", new Date(dateString), timezone); if (Number.isNaN(date.getTime()) || !dateString) { return null; } return date; } function isDateValid({ date, maxDate, minDate }) { if (date == null) { return false; } if (Number.isNaN(date.getTime())) { return false; } if (maxDate && dayjs(date).isAfter(maxDate, "date")) { return false; } if (minDate && dayjs(date).isBefore(minDate, "date")) { return false; } return true; } const defaultProps$4 = { valueFormat: "MMMM D, YYYY", fixOnBlur: true, preserveTime: true }; const DateInput = factory((_props, ref) => { const props = useInputProps("DateInput", defaultProps$4, _props); const { inputProps, wrapperProps, value, defaultValue, onChange, clearable, clearButtonProps, popoverProps, getDayProps, locale, valueFormat, dateParser, minDate, maxDate, fixOnBlur, onFocus, onBlur, onClick, readOnly, name, form, rightSection, unstyled, classNames, styles, allowDeselect, preserveTime, date, defaultDate, onDateChange, ...rest } = props; const [dropdownOpened, setDropdownOpened] = useState(false); const { calendarProps, others } = pickCalendarProps(rest); const ctx = useDatesContext(); const defaultDateParser = (val) => { const parsedDate = dayjs(val, valueFormat, ctx.getLocale(locale)).toDate(); return Number.isNaN(parsedDate.getTime()) ? dateStringParser(val, ctx.getTimezone()) : parsedDate; }; const _dateParser = dateParser || defaultDateParser; const _allowDeselect = allowDeselect !== void 0 ? allowDeselect : clearable; const formatValue = (val) => val ? dayjs(val).locale(ctx.getLocale(locale)).format(valueFormat) : ""; const [_value, setValue, controlled] = useUncontrolledDates({ type: "default", value, defaultValue, onChange }); const [_date, setDate] = useUncontrolledDates({ type: "default", value: date, defaultValue: defaultValue || defaultDate, onChange: onDateChange }); useEffect(() => { if (controlled) { setDate(value); } }, [controlled, value]); const [inputValue, setInputValue] = useState(formatValue(_value)); useEffect(() => { setInputValue(formatValue(_value)); }, [ctx.getLocale(locale)]); const handleInputChange = (event) => { const val = event.currentTarget.value; setInputValue(val); setDropdownOpened(true); if (val.trim() === "" && clearable) { setValue(null); } else { const dateValue = _dateParser(val); if (isDateValid({ date: dateValue, minDate, maxDate })) { setValue(dateValue); setDate(dateValue); } } }; const handleInputBlur = (event) => { onBlur?.(event); setDropdownOpened(false); fixOnBlur && setInputValue(formatValue(_value)); }; const handleInputFocus = (event) => { onFocus?.(event); setDropdownOpened(true); }; const handleInputClick = (event) => { onClick?.(event); setDropdownOpened(true); }; const _getDayProps = (day) => ({ ...getDayProps?.(day), selected: dayjs(_value).isSame(day, "day"), onClick: () => { const valueWithTime = preserveTime ? assignTime(_value, day) : day; const val = clearable && _allowDeselect ? dayjs(_value).isSame(day, "day") ? null : valueWithTime : valueWithTime; setValue(val); !controlled && setInputValue(formatValue(val)); setDropdownOpened(false); } }); const _rightSection = rightSection || (clearable && _value && !readOnly ? /* @__PURE__ */ jsx( CloseButton, { variant: "transparent", onMouseDown: (event) => event.preventDefault(), tabIndex: -1, onClick: () => { setValue(null); !controlled && setInputValue(""); setDropdownOpened(false); }, unstyled, size: inputProps.size || "sm", ...clearButtonProps } ) : null); useDidUpdate(() => { _value !== void 0 && !dropdownOpened && setInputValue(formatValue(_value)); }, [_value]); return /* @__PURE__ */ jsxs(Fragment, { children: [ /* @__PURE__ */ jsx(Input.Wrapper, { ...wrapperProps, __staticSelector: "DateInput", children: /* @__PURE__ */ jsxs( Popover, { opened: dropdownOpened, trapFocus: false, position: "bottom-start", disabled: readOnly, withRoles: false, unstyled, ...popoverProps, children: [ /* @__PURE__ */ jsx(Popover.Target, { children: /* @__PURE__ */ jsx( Input, { "data-dates-input": true, "data-read-only": readOnly || void 0, autoComplete: "off", ref, value: inputValue, onChange: handleInputChange, onBlur: handleInputBlur, onFocus: handleInputFocus, onClick: handleInputClick, readOnly, rightSection: _rightSection, ...inputProps, ...others, __staticSelector: "DateInput" } ) }), /* @__PURE__ */ jsx(Popover.Dropdown, { onMouseDown: (event) => event.preventDefault(), "data-dates-dropdown": true, children: /* @__PURE__ */ jsx( Calendar, { __staticSelector: "DateInput", __timezoneApplied: true, ...calendarProps, classNames, styles, unstyled, __preventFocus: true, minDate, maxDate, locale, getDayProps: _getDayProps, size: inputProps.size, date: _date, onDateChange: setDate } ) }) ] } ) }), /* @__PURE__ */ jsx(HiddenDatesInput, { name, form, value: _value, type: "default" }) ] }); }); DateInput.classes = { ...Input.classes, ...Calendar.classes }; DateInput.displayName = "@mantine/dates/DateInput"; var classes = {"timeWrapper":"m_208d2562","timeInput":"m_62ee059"}; const defaultProps$3 = { dropdownType: "popover" }; const DateTimePicker = factory((_props, ref) => { const props = useProps("DateTimePicker", defaultProps$3, _props); const { value, defaultValue, onChange, valueFormat, locale, classNames, styles, unstyled, timeInputProps, submitButtonProps, withSeconds, level, defaultLevel, size, variant, dropdownType, vars, minDate, maxDate, ...rest } = props; const getStyles = useStyles({ name: "DateTimePicker", classes, props, classNames, styles, unstyled, vars }); const { resolvedClassNames, resolvedStyles } = useResolvedStylesApi({ classNames, styles, props }); const _valueFormat = valueFormat || (withSeconds ? "DD/MM/YYYY HH:mm:ss" : "DD/MM/YYYY HH:mm"); const timeInputRef = useRef(); const timeInputRefMerged = useMergedRef(timeInputRef, timeInputProps?.ref); const { calendarProps: { allowSingleDateInRange, ...calendarProps }, others } = pickCalendarProps(rest); const ctx = useDatesContext(); const [_value, setValue] = useUncontrolledDates({ type: "default", value, defaultValue, onChange }); const formatTime = (dateValue) => dateValue ? dayjs(dateValue).format(withSeconds ? "HH:mm:ss" : "HH:mm") : ""; const [timeValue, setTimeValue] = useState(formatTime(_value)); const [currentLevel, setCurrentLevel] = useState(level || defaultLevel || "month"); const [dropdownOpened, dropdownHandlers] = useDisclosure(false); const formattedValue = _value ? dayjs(_value).locale(ctx.getLocale(locale)).format(_valueFormat) : ""; const handleTimeChange = (event) => { timeInputProps?.onChange?.(event); const val = event.currentTarget.value; setTimeValue(val); if (val) { const [hours, minutes, seconds] = val.split(":").map(Number); const timeDate = shiftTimezone("add", /* @__PURE__ */ new Date(), ctx.getTimezone()); timeDate.setHours(hours); timeDate.setMinutes(minutes); timeDate.setSeconds(seconds || 0); setValue(assignTime(timeDate, _value || shiftTimezone("add", /* @__PURE__ */ new Date(), ctx.getTimezone()))); } }; const handleDateChange = (date) => { if (date) { setValue(assignTime(_value, date)); } timeInputRef.current?.focus(); }; const handleTimeInputKeyDown = (event) => { timeInputProps?.onKeyDown?.(event); if (event.key === "Enter") { event.preventDefault(); dropdownHandlers.close(); } }; useDidUpdate(() => { if (!dropdownOpened) { setTimeValue(formatTime(_value)); } }, [_value, dropdownOpened]); useDidUpdate(() => { if (dropdownOpened) { setCurrentLevel("month"); } }, [dropdownOpened]); const minTime = minDate ? dayjs(minDate).format("HH:mm:ss") : null; const maxTime = maxDate ? dayjs(maxDate).format("HH:mm:ss") : null; const __stopPropagation = dropdownType === "popover"; return /* @__PURE__ */ jsxs( PickerInputBase, { formattedValue, dropdownOpened, dropdownHandlers, classNames: resolvedClassNames, styles: resolvedStyles, unstyled, ref, onClear: () => setValue(null), shouldClear: !!_value, value: _value, size, variant, dropdownType, ...others, type: "default", __staticSelector: "DateTimePicker", children: [ /* @__PURE__ */ jsx( DatePicker, { ...calendarProps, maxDate, minDate, size, variant, type: "default", value: _value, defaultDate: _value, onChange: handleDateChange, locale, classNames: resolvedClassNames, styles: resolvedStyles, unstyled, __staticSelector: "DateTimePicker", __stopPropagation, level, defaultLevel, onLevelChange: (_level) => { setCurrentLevel(_level); calendarProps.onLevelChange?.(_level); }, __timezoneApplied: true } ), currentLevel === "month" && /* @__PURE__ */ jsxs("div", { ...getStyles("timeWrapper"), children: [ /* @__PURE__ */ jsx( TimeInput, { value: timeValue, withSeconds, ref: timeInputRefMerged, unstyled, minTime: _value && minDate && _value.toDateString() === minDate.toDateString() ? minTime != null ? minTime : void 0 : void 0, maxTime: _value && maxDate && _value.toDateString() === maxDate.toDateString() ? maxTime != null ? maxTime : void 0 : void 0, ...timeInputProps, ...getStyles("timeInput", { className: timeInputProps?.className, style: timeInputProps?.style }), onChange: handleTimeChange, onKeyDown: handleTimeInputKeyDown, size, "data-mantine-stop-propagation": __stopPropagation || void 0 } ), /* @__PURE__ */ jsx( ActionIcon, { variant: "default", size: `input-${size || "sm"}`, ...getStyles("submitButton", { className: submitButtonProps?.className, style: submitButtonProps?.style }), unstyled, "data-mantine-stop-propagation": __stopPropagation || void 0, children: /* @__PURE__ */ jsx(CheckIcon, { size: "30%" }), ...submitButtonProps, onClick: (event) => { submitButtonProps?.onClick?.(event); dropdownHandlers.close(); } } ) ] }) ] } ); }); DateTimePicker.classes = { ...classes, ...PickerInputBase.classes, ...DatePicker.classes }; DateTimePicker.displayName = "@mantine/dates/DateTimePicker"; const defaultProps$2 = { type: "default", valueFormat: "YYYY", closeOnChange: true, sortDates: true, dropdownType: "popover" }; const YearPickerInput = factory( (_props, ref) => { const props = useProps("YearPickerInput", defaultProps$2, _props); const { type, value, defaultValue, onChange, valueFormat, labelSeparator, locale, classNames, styles, unstyled, closeOnChange, size, variant, dropdownType, sortDates, minDate, maxDate, vars, valueFormatter, ...rest } = props; const { resolvedClassNames, resolvedStyles } = useResolvedStylesApi({ classNames, styles, props }); const { calendarProps, others } = pickCalendarProps(rest); const ctx = useDatesContext(); const { _value, setValue, formattedValue, dropdownHandlers, dropdownOpened, onClear, shouldClear } = useDatesInput({ type, value, defaultValue, onChange, locale, format: valueFormat, labelSeparator, closeOnChange, sortDates, valueFormatter }); return /* @__PURE__ */ jsx( PickerInputBase, { formattedValue, dropdownOpened, dropdownHandlers, classNames: resolvedClassNames, styles: resolvedStyles, unstyled, ref, onClear, shouldClear, value: _value, size, variant, dropdownType, ...others, type, __staticSelector: "YearPickerInput", children: /* @__PURE__ */ jsx( YearPicker, { ...calendarProps, size, variant, type, value: _value, defaultDate: Array.isArray(_value) ? _value[0] || getDefaultClampedDate({ maxDate, minDate, timezone: ctx.getTimezone() }) : _value || getDefaultClampedDate({ maxDate, minDate, timezone: ctx.getTimezone() }), onChange: setValue, locale, classNames: resolvedClassNames, styles: resolvedStyles, unstyled, __staticSelector: "YearPickerInput", __stopPropagation: dropdownType === "popover", minDate, maxDate, date: shiftTimezone("add", calendarProps.date, ctx.getTimezone()), __timezoneApplied: true } ) } ); } ); YearPickerInput.classes = { ...PickerInputBase.classes, ...YearPicker.classes }; YearPickerInput.displayName = "@mantine/dates/YearPickerInput"; const defaultProps$1 = { type: "default", valueFormat: "MMMM YYYY", closeOnChange: true, sortDates: true, dropdownType: "popover" }; const MonthPickerInput = factory( (_props, ref) => { const props = useProps("MonthPickerInput", defaultProps$1, _props); const { type, value, defaultValue, onChange, valueFormat, labelSeparator, locale, classNames, styles, unstyled, closeOnChange, size, variant, dropdownType, sortDates, minDate, maxDate, vars, valueFormatter, ...rest } = props; const { resolvedClassNames, resolvedStyles } = useResolvedStylesApi({ classNames, styles, props }); const { calendarProps, others } = pickCalendarProps(rest); const { _value, setValue, formattedValue, dropdownHandlers, dropdownOpened, onClear, shouldClear } = useDatesInput({ type, value, defaultValue, onChange, locale, format: valueFormat, labelSeparator, closeOnChange, sortDates, valueFormatter }); const ctx = useDatesContext(); return /* @__PURE__ */ jsx( PickerInputBase, { formattedValue, dropdownOpened, dropdownHandlers, classNames: resolvedClassNames, styles: resolvedStyles, unstyled, ref, onClear, shouldClear, value: _value, size, variant, dropdownType, ...others, type, __staticSelector: "MonthPickerInput", children: /* @__PURE__ */ jsx( MonthPicker, { ...calendarProps, date: shiftTimezone("add", calendarProps.date, ctx.getTimezone()), size, variant, type, value: _value, defaultDate: Array.isArray(_value) ? _value[0] || getDefaultClampedDate({ maxDate, minDate }) : _value || getDefaultClampedDate({ maxDate, minDate }), onChange: setValue, locale, classNames: resolvedClassNames, styles: resolvedStyles, unstyled, __staticSelector: "MonthPickerInput", __stopPropagation: dropdownType === "popover", minDate, maxDate, __timezoneApplied: true } ) } ); } ); MonthPickerInput.classes = { ...PickerInputBase.classes, ...MonthPicker.classes }; MonthPickerInput.displayName = "@mantine/dates/MonthPickerInput"; const defaultProps = { type: "default", valueFormat: "MMMM D, YYYY", closeOnChange: true, sortDates: true, dropdownType: "popover" }; const DatePickerInput = factory( (_props, ref) => { const props = useProps("DatePickerInput", defaultProps, _props); const { type, value, defaultValue, onChange, valueFormat, labelSeparator, locale, classNames, styles, unstyled, closeOnChange, size, variant, dropdownType, sortDates, minDate, maxDate, vars, defaultDate, valueFormatter, ...rest } = props; const { resolvedClassNames, resolvedStyles } = useResolvedStylesApi({ classNames, styles, props }); const { calendarProps, others } = pickCalendarProps(rest); const { _value, setValue, formattedValue, dropdownHandlers, dropdownOpened, onClear, shouldClear } = useDatesInput({ type, value, defaultValue, onChange, locale, format: valueFormat, labelSeparator, closeOnChange, sortDates, valueFormatter }); const _defaultDate = Array.isArray(_value) ? _value[0] || defaultDate : _value || defaultDate; const ctx = useDatesContext(); return /* @__PURE__ */ jsx( PickerInputBase, { formattedValue, dropdownOpened, dropdownHandlers, classNames: resolvedClassNames, styles: resolvedStyles, unstyled, ref, onClear, shouldClear, value: _value, size, variant, dropdownType, ...others, type, __staticSelector: "DatePickerInput", children: /* @__PURE__ */ jsx( DatePicker, { ...calendarProps, size, variant, type, value: _value, defaultDate: _defaultDate || getDefaultClampedDate({ maxDate, minDate, timezone: ctx.getTimezone() }), onChange: setValue, locale, classNames: resolvedClassNames, styles: resolvedStyles, unstyled, __staticSelector: "DatePickerInput", __stopPropagation: dropdownType === "popover", minDate, maxDate, date: shiftTimezone("add", calendarProps.date, ctx.getTimezone()), __timezoneApplied: true } ) } ); } ); DatePickerInput.classes = { ...PickerInputBase.classes, ...DatePicker.classes }; DatePickerInput.displayName = "@mantine/dates/DatePickerInput"; export { Calendar, CalendarHeader, DATES_PROVIDER_DEFAULT_SETTINGS, DateInput, DatePicker, DatePickerInput, DateTimePicker, DatesProvider, Day, DecadeLevel, DecadeLevelGroup, HiddenDatesInput, LevelsGroup, Month, MonthLevel, MonthLevelGroup, MonthPicker, MonthPickerInput, MonthsList, PickerControl, PickerInputBase, TimeInput, WeekdaysRow, YearLevel, YearLevelGroup, YearPicker, YearPickerInput, YearsList, assignTime, getDefaultClampedDate, getEndOfWeek, getFormattedDate, getMonthDays, getStartOfWeek, handleControlKeyDown, isSameMonth, pickCalendarProps, shiftTimezone, useDatesContext };