import "./RangeCalendar.css";
import {CalendarGrid as $f06f4d5597ad704c$export$5bd780d491cfc46c, CalendarHeader as $f06f4d5597ad704c$export$9c75275274db0b56} from "./Calendar.mjs";
import {HeaderContext as $8e847109a6ab556d$export$e0e4026c12a8bdbb, HeadingContext as $8e847109a6ab556d$export$d688439359537581} from "./Content.mjs";
import {helpTextStyles as $9afd80978c252040$export$13b1fd5431595bf6} from "./Field.mjs";
import $6je1a$intlStringsmjs from "./intlStrings.mjs";
import {useSpectrumContextProps as $5ce63c423902f47d$export$764f6146fadd77f7} from "../../icons/useSpectrumContextProps.mjs";
import {jsx as $6je1a$jsx, jsxs as $6je1a$jsxs, Fragment as $6je1a$Fragment} from "react/jsx-runtime";
import {RangeCalendar as $6je1a$RangeCalendar} from "react-aria-components/RangeCalendar";
import {Provider as $6je1a$Provider} from "react-aria-components/slots";
import {createContext as $6je1a$createContext, forwardRef as $6je1a$forwardRef} from "react";
import {Text as $6je1a$Text} from "react-aria-components/Text";
import {useLocalizedStringFormatter as $6je1a$useLocalizedStringFormatter} from "react-aria/useLocalizedStringFormatter";


function $parcel$interopDefault(a) {
  return a && a.__esModule ? a.default : a;
}
/*
 * 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 $ecdee84c2f0ddfb5$export$233dd9682e1ad64b = /*#__PURE__*/ (0, $6je1a$createContext)(null);
const $ecdee84c2f0ddfb5$var$calendarStyles = function anonymous(props, overrides) {
    let rules = " ";
    let width = false;
    let maxWidth = 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;
        if (p[1] === "L") maxWidth = true;
        rules += p[0];
    }
    rules += ' sd12';
    if (props.isMultiMonth) rules += ' -_4DHzJc-e4mUs12';
    else rules += ' -_4DHzJc-0u6p5b12';
    rules += ' _ta12';
    rules += ' Uj12';
    rules += ' qj12';
    rules += ' __ca12';
    rules += ' -uq4sQ-Sp12';
    rules += ' -LnVzy-ZC12';
    if (props.isMultiMonth) rules += ' -cYDWLb-ZFFQGNb12';
    else rules += ' -cYDWLb-ZnqRBTd12';
    if (props.isMultiMonth) {
        if (!width) rules += ' ZJ12';
    } else if (!width) rules += ' ZRqDA2c12';
    if (props.isMultiMonth) {
        if (!maxWidth) rules += ' Le4mUs12';
    } else if (!maxWidth) rules += ' La12';
    return rules;
};
const $ecdee84c2f0ddfb5$export$a4f5c8b89d277a8d = /*#__PURE__*/ (0, $6je1a$forwardRef)(function RangeCalendar(props, ref) {
    [props, ref] = (0, $5ce63c423902f47d$export$764f6146fadd77f7)(props, ref, $ecdee84c2f0ddfb5$export$233dd9682e1ad64b);
    let { visibleMonths: visibleMonths = 1, errorMessage: errorMessage, UNSAFE_style: UNSAFE_style, UNSAFE_className: UNSAFE_className, styles: styles, ...otherProps } = props;
    let stringFormatter = (0, $6je1a$useLocalizedStringFormatter)((0, ($parcel$interopDefault($6je1a$intlStringsmjs))), '@react-spectrum/s2');
    let isMultiMonth = visibleMonths > 1;
    return /*#__PURE__*/ (0, $6je1a$jsx)((0, $6je1a$RangeCalendar), {
        ...otherProps,
        ref: ref,
        visibleDuration: {
            months: visibleMonths
        },
        style: {
            ...UNSAFE_style,
            '--num-calendars': visibleMonths
        },
        className: (UNSAFE_className || '') + $ecdee84c2f0ddfb5$var$calendarStyles({
            isMultiMonth: isMultiMonth
        }, styles),
        children: ({ isInvalid: isInvalid, isDisabled: isDisabled })=>{
            return /*#__PURE__*/ (0, $6je1a$jsxs)((0, $6je1a$Fragment), {
                children: [
                    /*#__PURE__*/ (0, $6je1a$jsx)((0, $6je1a$Provider), {
                        values: [
                            [
                                (0, $8e847109a6ab556d$export$e0e4026c12a8bdbb),
                                null
                            ],
                            [
                                (0, $8e847109a6ab556d$export$d688439359537581),
                                null
                            ]
                        ],
                        children: /*#__PURE__*/ (0, $6je1a$jsx)((0, $f06f4d5597ad704c$export$9c75275274db0b56), {})
                    }),
                    /*#__PURE__*/ (0, $6je1a$jsx)("div", {
                        className: " sd12 _tc12 Uj12 qj12 ed12",
                        children: Array.from({
                            length: visibleMonths
                        }).map((_, i)=>/*#__PURE__*/ (0, $6je1a$jsx)((0, $f06f4d5597ad704c$export$5bd780d491cfc46c), {
                                months: i
                            }, i))
                    }),
                    isInvalid && /*#__PURE__*/ (0, $6je1a$jsx)((0, $6je1a$Text), {
                        slot: "errorMessage",
                        className: (0, $9afd80978c252040$export$13b1fd5431595bf6)({
                            isInvalid: isInvalid,
                            isDisabled: isDisabled,
                            size: 'M'
                        }),
                        children: errorMessage || stringFormatter.format('calendar.invalidSelection', {
                            selectedCount: 2
                        })
                    })
                ]
            });
        }
    });
});


export {$ecdee84c2f0ddfb5$export$233dd9682e1ad64b as RangeCalendarContext, $ecdee84c2f0ddfb5$export$a4f5c8b89d277a8d as RangeCalendar};
//# sourceMappingURL=RangeCalendar.mjs.map
