require("./Calendar.css");
var $6e265ff388155b91$exports = require("./ActionButton.cjs");
var $6367bc87eb7d24ad$exports = require("./Content.cjs");
var $2061c83559b50a66$exports = require("./pressScale.cjs");
var $4f683da24e35b31a$exports = require("../icons/ChevronLeft.cjs");
var $f76eebe9b8ebc714$exports = require("../icons/ChevronRight.cjs");
var $a0b996a550bb0891$exports = require("./Field.cjs");
var $4526404114e78c80$exports = require("./intlStrings.cjs");
var $ac757a4c2bd72aee$exports = require("../icons/useSpectrumContextProps.cjs");
var $425Kz$reactjsxruntime = require("react/jsx-runtime");
var $425Kz$reactariacomponents = require("react-aria-components");
var $425Kz$internationalizeddate = require("@internationalized/date");
var $425Kz$react = require("react");
var $425Kz$reactariai18n = require("@react-aria/i18n");


function $parcel$interopDefault(a) {
  return a && a.__esModule ? a.default : a;
}

function $parcel$export(e, n, v, s) {
  Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
}

$parcel$export(module.exports, "CalendarContext", () => $e9e9a0d15c3364d7$export$3b805cea1f178355);
$parcel$export(module.exports, "Calendar", () => $e9e9a0d15c3364d7$export$e1aef45b828286de);
$parcel$export(module.exports, "CalendarButton", () => $e9e9a0d15c3364d7$export$adb29da0ac001538);
$parcel$export(module.exports, "CalendarHeading", () => $e9e9a0d15c3364d7$export$77af08ed164baa7);
$parcel$export(module.exports, "CalendarGrid", () => $e9e9a0d15c3364d7$export$5bd780d491cfc46c);
/*
 * Copyright 2024 Adobe. All rights reserved.
 * This file is licensed to you under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License. You may obtain a copy
 * of the License at http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software distributed under
 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
 * OF ANY KIND, either express or implied. See the License for the specific language
 * governing permissions and limitations under the License.
 */ 










const $e9e9a0d15c3364d7$export$3b805cea1f178355 = /*#__PURE__*/ (0, $425Kz$react.createContext)(null);
const $e9e9a0d15c3364d7$var$calendarStyles = function anonymous(props, overrides) {
    let rules = " ";
    let width = false;
    let matches = String(overrides || '').matchAll(/(?:^|\s)(J|G|I|H|_u|_v|_s|__A|_d|_J|z|y|B|A|_P|_9|W|_l|_A|_z|_6|Z|N|L)[^\s]+/g);
    for (let p of matches){
        if (p[1] === "Z") width = true;
        rules += p[0];
    }
    rules += ' sd12';
    rules += ' _ta12';
    rules += ' Uj12';
    rules += ' qj12';
    if (!width) rules += ' ZJ12';
    rules += ' __ca12';
    return rules;
};
const $e9e9a0d15c3364d7$var$headerStyles = " sd12 eb12 _Ce12 Za12";
const $e9e9a0d15c3364d7$var$headingStyles = " sd12 eb12 _Ce12 Jy12 Gy12 Iy12 Hy12 Za12";
const $e9e9a0d15c3364d7$var$titleStyles = " uk12 ucJ9TBTb12 ud3Euai12 uea12 ugb12 uhd12 uje12 u2NhKxcl12 uic12 -_6BNtrc-e12 vx12 xd12 _xa12 xX0cczbc12 _xX0cczba12 xfd12 _xfa12 xfX0cczbc12 _xfX0cczba12 _Fd12 _FnuYUweb12 po12 _Wa12 _ub12 _va12 _sa12 Na12";
const $e9e9a0d15c3364d7$var$headerCellStyles = " uk12 ucJ9TBTb12 ud3Euai12 uea12 ugb12 uhd12 uje12 u2NhKxcl12 uic12 -_6BNtrc-c12 vx12 xd12 _xa12 xX0cczbc12 _xX0cczba12 xfd12 _xfa12 xfX0cczbc12 _xfX0cczba12 _Fd12 _FnuYUweb12 po12 ri12 _Wa12 Sp12 Sbd12 Rp12 Rkd12 Qe12";
const $e9e9a0d15c3364d7$var$cellStyles = function anonymous(props) {
    let rules = " ";
    rules += ' _Le12';
    rules += ' -uq4sQ-Sp12';
    if (props.isFirstChild) rules += ' Sd12';
    else rules += ' Sp12';
    if (props.isLastChild) rules += ' Rd12';
    else rules += ' Rp12';
    if (props.isFirstWeek) rules += ' Td12';
    else rules += ' Tj12';
    rules += ' Qj12';
    rules += ' _Pc12';
    rules += ' ZC12';
    rules += ' Fx12';
    if (props.isOutsideMonth) rules += ' sk12';
    else rules += ' sd12';
    rules += ' eb12';
    rules += ' _Ca12';
    rules += ' __ca12';
    return rules;
};
const $e9e9a0d15c3364d7$var$cellInnerStyles = function anonymous(props) {
    let rules = " ";
    if (props.isFocusVisible) rules += ' _Lf12';
    else rules += ' _Le12';
    rules += ' Oh12';
    rules += ' Olc12';
    rules += ' _Mc12';
    if (props.isSelectionEnd) rules += ' _Kd12';
    else if (props.isSelectionStart) rules += ' _Kd12';
    else if (props.isSelected) {
        if (props.selectionMode === "range") rules += ' _Kb12';
        else if (props.selectionMode === "single") rules += ' _Kd12';
    } else if (props.isToday) rules += ' _Kd12';
    else rules += ' _Kb12';
    rules += ' Yd12';
    rules += ' Yle12';
    rules += ' Xb12';
    rules += ' Xlb12';
    rules += ' _2b12';
    rules += ' _2lb12';
    rules += ' _Pc12';
    rules += ' uk12';
    rules += ' ucJ9TBTb12';
    rules += ' ud3Euai12';
    rules += ' uea12';
    rules += ' ugb12';
    rules += ' uhd12';
    rules += ' uje12';
    rules += ' u2NhKxcl12';
    rules += ' uic12';
    rules += ' -_6BNtrc-c12';
    rules += ' vx12';
    rules += ' xb12';
    rules += ' _xa12';
    rules += ' _Fb12';
    rules += ' _FnuYUwec12';
    if (props.isDisabled) rules += ' pp12';
    else if (props.isSelectionEnd) rules += ' px12';
    else if (props.isSelectionStart) rules += ' px12';
    else if (props.isSelected) {
        if (props.selectionMode === "range") rules += ' pt12';
        else rules += ' px12';
    } else rules += ' pt12';
    if (props.isDisabled) rules += ' plc12';
    else if (props.isSelectionEnd) rules += ' ple12';
    else if (props.isSelectionStart) rules += ' ple12';
    else if (props.isSelected) rules += ' ple12';
    else if (props.isToday) rules += ' pla12';
    else rules += ' plb12';
    rules += ' ri12';
    rules += ' Za12';
    rules += ' Fx12';
    rules += ' og12';
    rules += ' ng12';
    rules += ' kg12';
    rules += ' jg12';
    rules += ' sd12';
    rules += ' eb12';
    rules += ' _Ca12';
    rules += ' _yb12';
    if (props.isSelectionEnd) {
        if (props.isInvalid) {
            if (props.isFocusVisible) {
                if (props.isUnavailable) rules += ' g7aei812';
                else rules += ' gYvV9s12';
            } else if (props.isPressed) rules += ' gYvV9s12';
            else if (props.isHovered) {
                if (props.isUnavailable) rules += ' g7aei812';
                else rules += ' gYvV9s12';
            } else rules += ' g7aei812';
        } else if (props.isDisabled) rules += ' g912';
        else if (props.isFocusVisible) rules += ' gUgARdd12';
        else if (props.isPressed) rules += ' gUgARdd12';
        else if (props.isHovered) rules += ' gUgARdd12';
        else rules += ' g5qAiPc12';
    } else if (props.isSelectionStart) {
        if (props.isInvalid) {
            if (props.isFocusVisible) {
                if (props.isUnavailable) rules += ' g7aei812';
                else rules += ' gYvV9s12';
            } else if (props.isPressed) rules += ' gYvV9s12';
            else if (props.isHovered) {
                if (props.isUnavailable) rules += ' g7aei812';
                else rules += ' gYvV9s12';
            } else rules += ' g7aei812';
        } else if (props.isDisabled) rules += ' g912';
        else if (props.isFocusVisible) rules += ' gUgARdd12';
        else if (props.isPressed) rules += ' gUgARdd12';
        else if (props.isHovered) rules += ' gUgARdd12';
        else rules += ' g5qAiPc12';
    } else if (props.isSelected) {
        if (props.selectionMode === "range") {
            if (props.isHovered) {
                if (props.isInvalid) {
                    if (props.isUnavailable) rules += ' g912';
                    else rules += ' gJj9Tpd12';
                } else rules += ' gNAacne12';
            }
        } else if (props.selectionMode === "single") {
            if (props.isInvalid) {
                if (props.isFocusVisible) rules += ' gYvV9s12';
                else if (props.isPressed) rules += ' gYvV9s12';
                else if (props.isHovered) rules += ' gYvV9s12';
                else rules += ' g7aei812';
            } else if (props.isDisabled) rules += ' g912';
            else if (props.isFocusVisible) rules += ' gUgARdd12';
            else if (props.isPressed) rules += ' gUgARdd12';
            else if (props.isHovered) rules += ' gUgARdd12';
            else rules += ' g5qAiPc12';
        }
    } else if (props.isToday) {
        if (props.isDisabled) rules += ' gH12';
        else {
            if (props.isPressed) rules += ' gw12';
            else if (props.isFocusVisible) rules += ' gw12';
            else if (props.isHovered) rules += ' gw12';
            else rules += ' gE12';
        }
    } else if (props.isDisabled) rules += ' g912';
    else if (props.isPressed) rules += ' gH12';
    else if (props.isHovered) {
        if (props.isUnavailable) rules += ' g912';
        else rules += ' gH12';
    } else rules += ' g912';
    if (props.isUnavailable) rules += ' gl912';
    else if (props.isSelectionEnd) rules += ' gle12';
    else if (props.isSelectionStart) rules += ' gle12';
    else if (props.isSelected) {
        if (props.selectionMode === "range") {
            if (props.isHovered) rules += ' gle12';
        } else if (props.selectionMode === "single") rules += ' gle12';
    } else if (props.isHovered) rules += ' gle12';
    else if (props.isToday) rules += ' glb12';
    else rules += ' gl912';
    return rules;
};
const $e9e9a0d15c3364d7$var$unavailableStyles = " _Pa12 WzErnCb12 _EjhYzGc12 _RjhYzGc12 FlAZvq12 _ZN7ydnb12 og12 ng12 kg12 jg12 g5ZbAob12";
const $e9e9a0d15c3364d7$var$selectionSpanStyles = function anonymous(props) {
    let rules = " ";
    rules += ' _Pa12';
    rules += ' _9a12';
    rules += ' Wr12';
    rules += ' _AOJNuv12';
    rules += ' _zr12';
    rules += ' _lr12';
    rules += ' _kc12';
    rules += ' hc12';
    rules += ' mc12';
    rules += ' lc12';
    rules += ' _ja12';
    if (props.isInvalid) rules += ' ip12';
    else rules += ' ix12';
    rules += ' ilb12';
    rules += ' og12';
    rules += ' kg12';
    rules += ' ng12';
    rules += ' jg12';
    if (props.isInvalid) rules += ' gZbQnx12';
    else rules += ' gG12';
    rules += ' gle12';
    rules += ' _yb12';
    return rules;
};
const $e9e9a0d15c3364d7$export$e1aef45b828286de = /*#__PURE__*/ (0, $425Kz$react.forwardRef)(function Calendar(props, ref) {
    [props, ref] = (0, $ac757a4c2bd72aee$exports.useSpectrumContextProps)(props, ref, $e9e9a0d15c3364d7$export$3b805cea1f178355);
    let { visibleMonths: visibleMonths = 1, errorMessage: errorMessage, UNSAFE_style: UNSAFE_style, UNSAFE_className: UNSAFE_className, styles: styles, ...otherProps } = props;
    let stringFormatter = (0, $425Kz$reactariai18n.useLocalizedStringFormatter)((0, ($parcel$interopDefault($4526404114e78c80$exports))), '@react-spectrum/s2');
    return /*#__PURE__*/ (0, $425Kz$reactjsxruntime.jsx)((0, $425Kz$reactariacomponents.Calendar), {
        ...otherProps,
        ref: ref,
        visibleDuration: {
            months: visibleMonths
        },
        style: UNSAFE_style,
        className: (UNSAFE_className || '') + $e9e9a0d15c3364d7$var$calendarStyles(null, styles),
        children: ({ isInvalid: isInvalid, isDisabled: isDisabled })=>{
            return /*#__PURE__*/ (0, $425Kz$reactjsxruntime.jsxs)((0, $425Kz$reactjsxruntime.Fragment), {
                children: [
                    /*#__PURE__*/ (0, $425Kz$reactjsxruntime.jsx)((0, $425Kz$reactariacomponents.Provider), {
                        values: [
                            [
                                (0, $6367bc87eb7d24ad$exports.HeaderContext),
                                null
                            ],
                            [
                                (0, $6367bc87eb7d24ad$exports.HeadingContext),
                                null
                            ]
                        ],
                        children: /*#__PURE__*/ (0, $425Kz$reactjsxruntime.jsxs)((0, $6367bc87eb7d24ad$exports.Header), {
                            styles: $e9e9a0d15c3364d7$var$headerStyles,
                            children: [
                                /*#__PURE__*/ (0, $425Kz$reactjsxruntime.jsx)($e9e9a0d15c3364d7$export$adb29da0ac001538, {
                                    slot: "previous",
                                    children: /*#__PURE__*/ (0, $425Kz$reactjsxruntime.jsx)((0, $4f683da24e35b31a$exports.default), {})
                                }),
                                /*#__PURE__*/ (0, $425Kz$reactjsxruntime.jsx)($e9e9a0d15c3364d7$export$77af08ed164baa7, {}),
                                /*#__PURE__*/ (0, $425Kz$reactjsxruntime.jsx)($e9e9a0d15c3364d7$export$adb29da0ac001538, {
                                    slot: "next",
                                    children: /*#__PURE__*/ (0, $425Kz$reactjsxruntime.jsx)((0, $f76eebe9b8ebc714$exports.default), {})
                                })
                            ]
                        })
                    }),
                    /*#__PURE__*/ (0, $425Kz$reactjsxruntime.jsx)("div", {
                        className: " sd12 _tc12 Uj12 qj12 Za12 ed12",
                        children: Array.from({
                            length: visibleMonths
                        }).map((_, i)=>/*#__PURE__*/ (0, $425Kz$reactjsxruntime.jsx)($e9e9a0d15c3364d7$export$5bd780d491cfc46c, {
                                months: i
                            }, i))
                    }),
                    isInvalid && /*#__PURE__*/ (0, $425Kz$reactjsxruntime.jsx)((0, $425Kz$reactariacomponents.Text), {
                        slot: "errorMessage",
                        className: (0, $a0b996a550bb0891$exports.helpTextStyles)({
                            isInvalid: isInvalid,
                            isDisabled: isDisabled,
                            size: 'M'
                        }),
                        children: errorMessage || stringFormatter.format('calendar.invalidSelection', {
                            selectedCount: 1
                        })
                    })
                ]
            });
        }
    });
});
const $e9e9a0d15c3364d7$export$5bd780d491cfc46c = (props)=>{
    let rangeCalendarProps = (0, $425Kz$reactariacomponents.useSlottedContext)((0, $425Kz$reactariacomponents.RangeCalendarContext));
    let calendarProps = (0, $425Kz$reactariacomponents.useSlottedContext)((0, $425Kz$reactariacomponents.CalendarContext));
    let firstDayOfWeek = rangeCalendarProps?.firstDayOfWeek ?? calendarProps?.firstDayOfWeek;
    // use isolation to start a new stacking context so that we can use zIndex -1 for the selection span.
    return /*#__PURE__*/ (0, $425Kz$reactjsxruntime.jsxs)((0, $425Kz$reactariacomponents.CalendarGrid), {
        className: " __na12 __oe12 _Bb12",
        offset: {
            months: props.months
        },
        children: [
            /*#__PURE__*/ (0, $425Kz$reactjsxruntime.jsx)((0, $425Kz$reactariacomponents.CalendarGridHeader), {
                className: "",
                children: (day)=>/*#__PURE__*/ (0, $425Kz$reactjsxruntime.jsx)($e9e9a0d15c3364d7$var$CalendarHeaderCell, {
                        children: day
                    })
            }),
            /*#__PURE__*/ (0, $425Kz$reactjsxruntime.jsx)((0, $425Kz$reactariacomponents.CalendarGridBody), {
                className: "",
                children: (date)=>/*#__PURE__*/ (0, $425Kz$reactjsxruntime.jsx)($e9e9a0d15c3364d7$var$CalendarCell, {
                        date: date,
                        firstDayOfWeek: firstDayOfWeek
                    })
            })
        ]
    });
};
const $e9e9a0d15c3364d7$export$77af08ed164baa7 = ()=>{
    let calendarStateContext = (0, $425Kz$react.useContext)((0, $425Kz$reactariacomponents.CalendarStateContext));
    let rangeCalendarStateContext = (0, $425Kz$react.useContext)((0, $425Kz$reactariacomponents.RangeCalendarStateContext));
    let { visibleRange: visibleRange, timeZone: timeZone } = calendarStateContext ?? rangeCalendarStateContext ?? {};
    let currentMonth = visibleRange?.start ?? visibleRange?.end;
    let monthFormatter = (0, $425Kz$reactariai18n.useDateFormatter)({
        month: 'long',
        year: 'numeric',
        era: currentMonth && currentMonth.calendar.identifier === 'gregory' && currentMonth.era === 'BC' ? 'short' : undefined,
        calendar: visibleRange?.start.calendar.identifier,
        timeZone: timeZone
    });
    let months = (0, $425Kz$react.useMemo)(()=>{
        if (!visibleRange) return [];
        let months = [];
        for(let i = visibleRange.start; i.compare(visibleRange.end) <= 0; i = i.add({
            months: 1
        })){
            // TODO: account for the first week possibly overlapping, like with a custom 454 calendar.
            // there has to be a better way to do this...
            if (i.month === visibleRange.start.month) i = i.add({
                weeks: 1
            });
            months.push(monthFormatter.format(i.toDate(timeZone)));
        }
        return months;
    }, [
        visibleRange,
        monthFormatter,
        timeZone
    ]);
    return /*#__PURE__*/ (0, $425Kz$reactjsxruntime.jsx)((0, $6367bc87eb7d24ad$exports.Heading), {
        styles: $e9e9a0d15c3364d7$var$headingStyles,
        children: months.map((month, i)=>{
            if (i === 0) return /*#__PURE__*/ (0, $425Kz$reactjsxruntime.jsx)((0, $425Kz$react.Fragment), {
                children: /*#__PURE__*/ (0, $425Kz$reactjsxruntime.jsx)("div", {
                    className: $e9e9a0d15c3364d7$var$titleStyles,
                    children: month
                })
            }, month);
            else return /*#__PURE__*/ (0, $425Kz$reactjsxruntime.jsxs)((0, $425Kz$react.Fragment), {
                children: [
                    /*#__PURE__*/ (0, $425Kz$reactjsxruntime.jsx)("div", {
                        className: " _6b12 ZC12"
                    }),
                    /*#__PURE__*/ (0, $425Kz$reactjsxruntime.jsx)("div", {
                        className: " _6b12 Zo12"
                    }),
                    /*#__PURE__*/ (0, $425Kz$reactjsxruntime.jsx)("div", {
                        className: " _6b12 ZC12"
                    }),
                    /*#__PURE__*/ (0, $425Kz$reactjsxruntime.jsx)("div", {
                        className: $e9e9a0d15c3364d7$var$titleStyles,
                        children: month
                    })
                ]
            }, month);
        })
    });
};
const $e9e9a0d15c3364d7$export$adb29da0ac001538 = (props1)=>{
    let { direction: direction } = (0, $425Kz$reactariai18n.useLocale)();
    return /*#__PURE__*/ (0, $425Kz$reactjsxruntime.jsx)("div", {
        className: function anonymous(props) {
            let rules = " ";
            if (props.direction === "rtl") {
                rules += ' -Z4Pn4c-a12';
                rules += ' __Ha12';
            }
            if (props.direction === "rtl") {
                rules += ' -_04Pn4c-a12';
                rules += ' __Ha12';
            }
            return rules;
        }({
            direction: direction
        }),
        children: /*#__PURE__*/ (0, $425Kz$reactjsxruntime.jsx)((0, $6e265ff388155b91$exports.ActionButton), {
            ...props1,
            isQuiet: true,
            children: props1.children
        })
    });
};
const $e9e9a0d15c3364d7$var$CalendarHeaderCell = (props)=>{
    return /*#__PURE__*/ (0, $425Kz$reactjsxruntime.jsx)((0, $425Kz$reactariacomponents.CalendarHeaderCell), {
        className: $e9e9a0d15c3364d7$var$headerCellStyles,
        children: props.children
    });
};
const $e9e9a0d15c3364d7$var$CalendarCell = (props)=>{
    let { locale: locale } = (0, $425Kz$reactariai18n.useLocale)();
    let firstDayOfWeek = props.firstDayOfWeek;
    // Calculate the day and week index based on the date.
    let { dayIndex: dayIndex, weekIndex: weekIndex } = $e9e9a0d15c3364d7$var$useWeekAndDayIndices(props.date, locale, firstDayOfWeek);
    let calendarStateContext = (0, $425Kz$react.useContext)((0, $425Kz$reactariacomponents.CalendarStateContext));
    let rangeCalendarStateContext = (0, $425Kz$react.useContext)((0, $425Kz$reactariacomponents.RangeCalendarStateContext));
    let state = calendarStateContext ?? rangeCalendarStateContext;
    let isFirstWeek = weekIndex === 0;
    let isFirstChild = dayIndex === 0;
    let isLastChild = dayIndex === 6;
    return /*#__PURE__*/ (0, $425Kz$reactjsxruntime.jsx)((0, $425Kz$reactariacomponents.CalendarCell), {
        date: props.date,
        className: (renderProps)=>$e9e9a0d15c3364d7$var$cellStyles({
                ...renderProps,
                isFirstChild: isFirstChild,
                isLastChild: isLastChild,
                isFirstWeek: isFirstWeek
            }),
        children: (renderProps)=>/*#__PURE__*/ (0, $425Kz$reactjsxruntime.jsx)($e9e9a0d15c3364d7$var$CalendarCellInner, {
                ...props,
                weekIndex: weekIndex,
                dayIndex: dayIndex,
                state: state,
                isRangeSelection: !!rangeCalendarStateContext,
                renderProps: renderProps
            })
    });
};
const $e9e9a0d15c3364d7$var$CalendarCellInner = (props)=>{
    let { weekIndex: weekIndex, dayIndex: dayIndex, date: date, renderProps: renderProps, state: state, isRangeSelection: isRangeSelection } = props;
    let { getDatesInWeek: getDatesInWeek } = state;
    let ref = (0, $425Kz$react.useRef)(null);
    let { isUnavailable: isUnavailable, formattedDate: formattedDate, isSelected: isSelected, isSelectionStart: isSelectionStart, isSelectionEnd: isSelectionEnd, isInvalid: isInvalid } = renderProps;
    // only apply the selection start/end styles if the start/end date is actually selectable (aka not unavailable)
    // or if the range is invalid and thus we still want to show the styles even if the start/end date is an unavailable one
    isSelectionStart = isSelectionStart && (!isUnavailable || isInvalid);
    isSelectionEnd = isSelectionEnd && (!isUnavailable || isInvalid);
    let startDate = (0, $425Kz$internationalizeddate.startOfMonth)(date);
    let datesInWeek = getDatesInWeek(weekIndex, startDate);
    let isDateInRange = (checkDate)=>{
        if (!('highlightedRange' in state) || !state.highlightedRange) return state.isSelected(checkDate);
        // if invalid, check if date is within the full range boundaries
        if (isInvalid) return checkDate.compare(state.highlightedRange.start) >= 0 && checkDate.compare(state.highlightedRange.end) <= 0;
        return state.isSelected(checkDate);
    };
    // Starting from the current day, find the first day before it in the current week that is not selected.
    // Then, the span of selected days is the current day minus the first unselected day.
    let firstUnselectedInRangeInWeek = datesInWeek.slice(0, dayIndex + 1).reverse().findIndex((date, i)=>{
        return date && i > 0 && (!isDateInRange(date) || date.month !== props.date.month);
    });
    let selectionSpan = -1;
    if (firstUnselectedInRangeInWeek > -1 && isSelected) selectionSpan = firstUnselectedInRangeInWeek - 1;
    else if (isSelected) selectionSpan = dayIndex;
    let prevDay = date.subtract({
        days: 1
    });
    let nextDay = date.add({
        days: 1
    });
    // when invalid, show background for all selected dates (including unavailable) to make continuous range appearance
    // when valid, only show background for available selected dates
    let isBackgroundStyleApplied = isSelected && isRangeSelection && (isInvalid || !isUnavailable) && (isDateInRange(prevDay) || nextDay.month === date.month && isDateInRange(nextDay));
    return /*#__PURE__*/ (0, $425Kz$reactjsxruntime.jsxs)("div", {
        className: " _Pc12 ZvFFGYc12 -_4Isswc-ZvFFGYc12 -Z_-ZC12",
        children: [
            /*#__PURE__*/ (0, $425Kz$reactjsxruntime.jsxs)("div", {
                ref: ref,
                style: (0, $2061c83559b50a66$exports.pressScale)(ref, {})(renderProps),
                className: $e9e9a0d15c3364d7$var$cellInnerStyles({
                    ...renderProps,
                    isSelectionStart: isSelectionStart,
                    isSelectionEnd: isSelectionEnd,
                    selectionMode: isRangeSelection ? 'range' : 'single'
                }),
                children: [
                    /*#__PURE__*/ (0, $425Kz$reactjsxruntime.jsx)("div", {
                        children: formattedDate
                    }),
                    isUnavailable && /*#__PURE__*/ (0, $425Kz$reactjsxruntime.jsx)("div", {
                        className: $e9e9a0d15c3364d7$var$unavailableStyles,
                        role: "presentation"
                    })
                ]
            }),
            isBackgroundStyleApplied && /*#__PURE__*/ (0, $425Kz$reactjsxruntime.jsx)("div", {
                style: {
                    '--selection-span': selectionSpan
                },
                className: $e9e9a0d15c3364d7$var$selectionSpanStyles({
                    isInvalid: isInvalid
                }),
                role: "presentation"
            })
        ]
    });
};
/**
 * Calculate the week index (0-based) and day index (0-based) for a given date within a month in a calendar.
 * @param date - The date to calculate indices for.
 * @param locale - The locale string (e.g., 'en-US', 'fr-FR', 'hi-IN-u-ca-indian').
 * @param firstDayOfWeek - Optional override for the first day of the week ('sun', 'mon', 'tue', etc.).
 * @returns Object with weekIndex and dayIndex.
 */ function $e9e9a0d15c3364d7$var$useWeekAndDayIndices(date, locale, firstDayOfWeek) {
    let { dayIndex: dayIndex, weekIndex: weekIndex } = (0, $425Kz$react.useMemo)(()=>{
        // Get the day index within the week (0-6)
        const dayIndex = (0, $425Kz$internationalizeddate.getDayOfWeek)(date, locale, firstDayOfWeek);
        const monthStart = (0, $425Kz$internationalizeddate.startOfMonth)(date);
        // Calculate the week index by finding which week this date falls into
        // within the month's calendar grid
        const monthStartDayOfWeek = (0, $425Kz$internationalizeddate.getDayOfWeek)(monthStart, locale, firstDayOfWeek);
        const dayOfMonth = date.day;
        const weekIndex = Math.floor((dayOfMonth + monthStartDayOfWeek - 1) / 7);
        return {
            weekIndex: weekIndex,
            dayIndex: dayIndex
        };
    }, [
        date,
        locale,
        firstDayOfWeek
    ]);
    return {
        dayIndex: dayIndex,
        weekIndex: weekIndex
    };
}


//# sourceMappingURL=Calendar.cjs.map
