import { jsx as ae } from "react/jsx-runtime";
import d, { createContext as At, useContext as Ht, useCallback as H, useRef as ye, useLayoutEffect as Zt, useState as pe, useEffect as Ue, useMemo as Ce } from "react";
import { c as Ae } from "./button-DBX_tvfJ.mjs";
import { l as jt } from "./chevron-left.es-UFhf3v35.mjs";
import { n as zt } from "./chevron-right.es-D7aVK4ER.mjs";
import { t as I, c as L, j as Ge, r as ce, u as Ee, g as qt, v as Rt, p as Ut, i as Gt, h as Kt, x as Lt, f as Vt, s as Jt, y as Qt, e as Ke } from "./format-DpkYPs7O.mjs";
function Xt(e, t, o = "long") {
  return new Intl.DateTimeFormat("en-US", {
    // Enforces engine to render the time. Without the option JavaScriptCore omits it.
    hour: "numeric",
    timeZone: e,
    timeZoneName: o
  }).format(t).split(/\s/g).slice(2).join(" ");
}
const en = {}, ie = {};
function ne(e, t) {
  try {
    const n = (en[e] ||= new Intl.DateTimeFormat("en-US", {
      timeZone: e,
      timeZoneName: "longOffset"
    }).format)(t).split("GMT")[1];
    return n in ie ? ie[n] : He(n, n.split(":"));
  } catch {
    if (e in ie) return ie[e];
    const o = e?.match(tn);
    return o ? He(e, o.slice(1)) : NaN;
  }
}
const tn = /([+-]\d\d):?(\d\d)?/;
function He(e, t) {
  const o = +(t[0] || 0), n = +(t[1] || 0), s = +(t[2] || 0) / 60;
  return ie[e] = o * 60 + n > 0 ? o * 60 + n + s : o * 60 - n - s;
}
class K extends Date {
  //#region static
  constructor(...t) {
    super(), t.length > 1 && typeof t[t.length - 1] == "string" && (this.timeZone = t.pop()), this.internal = /* @__PURE__ */ new Date(), isNaN(ne(this.timeZone, this)) ? this.setTime(NaN) : t.length ? typeof t[0] == "number" && (t.length === 1 || t.length === 2 && typeof t[1] != "number") ? this.setTime(t[0]) : typeof t[0] == "string" ? this.setTime(+new Date(t[0])) : t[0] instanceof Date ? this.setTime(+t[0]) : (this.setTime(+new Date(...t)), Le(this), Te(this)) : this.setTime(Date.now());
  }
  static tz(t, ...o) {
    return o.length ? new K(...o, t) : new K(Date.now(), t);
  }
  //#endregion
  //#region time zone
  withTimeZone(t) {
    return new K(+this, t);
  }
  getTimezoneOffset() {
    const t = -ne(this.timeZone, this);
    return t > 0 ? Math.floor(t) : Math.ceil(t);
  }
  //#endregion
  //#region time
  setTime(t) {
    return Date.prototype.setTime.apply(this, arguments), Te(this), +this;
  }
  //#endregion
  //#region date-fns integration
  [/* @__PURE__ */ Symbol.for("constructDateFrom")](t) {
    return new K(+new Date(t), this.timeZone);
  }
  //#endregion
}
const Ze = /^(get|set)(?!UTC)/;
Object.getOwnPropertyNames(Date.prototype).forEach((e) => {
  if (!Ze.test(e)) return;
  const t = e.replace(Ze, "$1UTC");
  K.prototype[t] && (e.startsWith("get") ? K.prototype[e] = function() {
    return this.internal[t]();
  } : (K.prototype[e] = function() {
    return Date.prototype[t].apply(this.internal, arguments), nn(this), +this;
  }, K.prototype[t] = function() {
    return Date.prototype[t].apply(this, arguments), Te(this), +this;
  }));
});
function Te(e) {
  e.internal.setTime(+e), e.internal.setUTCSeconds(e.internal.getUTCSeconds() - Math.round(-ne(e.timeZone, e) * 60));
}
function nn(e) {
  Date.prototype.setFullYear.call(e, e.internal.getUTCFullYear(), e.internal.getUTCMonth(), e.internal.getUTCDate()), Date.prototype.setHours.call(e, e.internal.getUTCHours(), e.internal.getUTCMinutes(), e.internal.getUTCSeconds(), e.internal.getUTCMilliseconds()), Le(e);
}
function Le(e) {
  const t = ne(e.timeZone, e), o = t > 0 ? Math.floor(t) : Math.ceil(t), n = /* @__PURE__ */ new Date(+e);
  n.setUTCHours(n.getUTCHours() - 1);
  const s = -(/* @__PURE__ */ new Date(+e)).getTimezoneOffset(), r = -(/* @__PURE__ */ new Date(+n)).getTimezoneOffset(), i = s - r, a = Date.prototype.getHours.apply(e) !== e.internal.getUTCHours();
  i && a && e.internal.setUTCMinutes(e.internal.getUTCMinutes() + i);
  const c = s - o;
  c && Date.prototype.setUTCMinutes.call(e, Date.prototype.getUTCMinutes.call(e) + c);
  const f = /* @__PURE__ */ new Date(+e);
  f.setUTCSeconds(0);
  const h = s > 0 ? f.getSeconds() : (f.getSeconds() - 60) % 60, l = Math.round(-(ne(e.timeZone, e) * 60)) % 60;
  (l || h) && (e.internal.setUTCSeconds(e.internal.getUTCSeconds() + l), Date.prototype.setUTCSeconds.call(e, Date.prototype.getUTCSeconds.call(e) + l + h));
  const u = ne(e.timeZone, e), p = u > 0 ? Math.floor(u) : Math.ceil(u), g = -(/* @__PURE__ */ new Date(+e)).getTimezoneOffset() - p, D = p !== o, O = g - c;
  if (D && O) {
    Date.prototype.setUTCMinutes.call(e, Date.prototype.getUTCMinutes.call(e) + O);
    const W = ne(e.timeZone, e), k = W > 0 ? Math.floor(W) : Math.ceil(W), S = p - k;
    S && (e.internal.setUTCMinutes(e.internal.getUTCMinutes() + S), Date.prototype.setUTCMinutes.call(e, Date.prototype.getUTCMinutes.call(e) + S));
  }
}
class F extends K {
  //#region static
  static tz(t, ...o) {
    return o.length ? new F(...o, t) : new F(Date.now(), t);
  }
  //#endregion
  //#region representation
  toISOString() {
    const [t, o, n] = this.tzComponents(), s = `${t}${o}:${n}`;
    return this.internal.toISOString().slice(0, -1) + s;
  }
  toString() {
    return `${this.toDateString()} ${this.toTimeString()}`;
  }
  toDateString() {
    const [t, o, n, s] = this.internal.toUTCString().split(" ");
    return `${t?.slice(0, -1)} ${n} ${o} ${s}`;
  }
  toTimeString() {
    const t = this.internal.toUTCString().split(" ")[4], [o, n, s] = this.tzComponents();
    return `${t} GMT${o}${n}${s} (${Xt(this.timeZone, this)})`;
  }
  toLocaleString(t, o) {
    return Date.prototype.toLocaleString.call(this, t, {
      ...o,
      timeZone: o?.timeZone || this.timeZone
    });
  }
  toLocaleDateString(t, o) {
    return Date.prototype.toLocaleDateString.call(this, t, {
      ...o,
      timeZone: o?.timeZone || this.timeZone
    });
  }
  toLocaleTimeString(t, o) {
    return Date.prototype.toLocaleTimeString.call(this, t, {
      ...o,
      timeZone: o?.timeZone || this.timeZone
    });
  }
  //#endregion
  //#region private
  tzComponents() {
    const t = this.getTimezoneOffset(), o = t > 0 ? "-" : "+", n = String(Math.floor(Math.abs(t) / 60)).padStart(2, "0"), s = String(Math.abs(t) % 60).padStart(2, "0");
    return [o, n, s];
  }
  //#endregion
  withTimeZone(t) {
    return new F(+this, t);
  }
  //#region date-fns integration
  [/* @__PURE__ */ Symbol.for("constructDateFrom")](t) {
    return new F(+new Date(t), this.timeZone);
  }
  //#endregion
}
var m;
(function(e) {
  e.Root = "root", e.Chevron = "chevron", e.Day = "day", e.DayButton = "day_button", e.CaptionLabel = "caption_label", e.Dropdowns = "dropdowns", e.Dropdown = "dropdown", e.DropdownRoot = "dropdown_root", e.Footer = "footer", e.MonthGrid = "month_grid", e.MonthCaption = "month_caption", e.MonthsDropdown = "months_dropdown", e.Month = "month", e.Months = "months", e.Nav = "nav", e.NextMonthButton = "button_next", e.PreviousMonthButton = "button_previous", e.Week = "week", e.Weeks = "weeks", e.Weekday = "weekday", e.Weekdays = "weekdays", e.WeekNumber = "week_number", e.WeekNumberHeader = "week_number_header", e.YearsDropdown = "years_dropdown";
})(m || (m = {}));
var T;
(function(e) {
  e.disabled = "disabled", e.hidden = "hidden", e.outside = "outside", e.focused = "focused", e.today = "today";
})(T || (T = {}));
var R;
(function(e) {
  e.range_end = "range_end", e.range_middle = "range_middle", e.range_start = "range_start", e.selected = "selected";
})(R || (R = {}));
var A;
(function(e) {
  e.weeks_before_enter = "weeks_before_enter", e.weeks_before_exit = "weeks_before_exit", e.weeks_after_enter = "weeks_after_enter", e.weeks_after_exit = "weeks_after_exit", e.caption_after_enter = "caption_after_enter", e.caption_after_exit = "caption_after_exit", e.caption_before_enter = "caption_before_enter", e.caption_before_exit = "caption_before_exit";
})(A || (A = {}));
function Ve(e, t, o) {
  const n = I(e, o?.in);
  if (isNaN(t)) return L(e, NaN);
  if (!t)
    return n;
  const s = n.getDate(), r = L(e, n.getTime());
  r.setMonth(n.getMonth() + t + 1, 0);
  const i = r.getDate();
  return s >= i ? r : (n.setFullYear(
    r.getFullYear(),
    r.getMonth(),
    s
  ), n);
}
function on(e, t, o) {
  return Ge(e, t * 7, o);
}
function sn(e, t, o) {
  return Ve(e, t * 12, o);
}
function rn(e, t) {
  let o, n = t?.in;
  return e.forEach((s) => {
    !n && typeof s == "object" && (n = L.bind(null, s));
    const r = I(s, n);
    (!o || o < r || isNaN(+r)) && (o = r);
  }), L(n, o || NaN);
}
function an(e, t) {
  let o, n = t?.in;
  return e.forEach((s) => {
    !n && typeof s == "object" && (n = L.bind(null, s));
    const r = I(s, n);
    (!o || o > r || isNaN(+r)) && (o = r);
  }), L(n, o || NaN);
}
function cn(e, t, o) {
  const [n, s] = ce(
    o?.in,
    e,
    t
  );
  return +Ee(n) == +Ee(s);
}
function fn(e, t, o) {
  const [n, s] = ce(
    o?.in,
    e,
    t
  ), r = n.getFullYear() - s.getFullYear(), i = n.getMonth() - s.getMonth();
  return r * 12 + i;
}
function ln(e, t) {
  const o = I(e, t?.in), n = o.getMonth();
  return o.setFullYear(o.getFullYear(), n + 1, 0), o.setHours(23, 59, 59, 999), o;
}
function dn(e, t) {
  const [o, n] = ce(e, t.start, t.end);
  return { start: o, end: n };
}
function un(e, t) {
  const { start: o, end: n } = dn(t?.in, e);
  let s = +o > +n;
  const r = s ? +o : +n, i = s ? n : o;
  i.setHours(0, 0, 0, 0), i.setDate(1);
  let a = 1;
  const c = [];
  for (; +i <= r; )
    c.push(L(o, i)), i.setMonth(i.getMonth() + a);
  return s ? c.reverse() : c;
}
function hn(e, t) {
  const o = I(e, t?.in);
  return o.setDate(1), o.setHours(0, 0, 0, 0), o;
}
function mn(e, t) {
  const o = I(e, t?.in), n = o.getFullYear();
  return o.setFullYear(n + 1, 0, 0), o.setHours(23, 59, 59, 999), o;
}
function Je(e, t) {
  const o = qt(), n = t?.weekStartsOn ?? t?.locale?.options?.weekStartsOn ?? o.weekStartsOn ?? o.locale?.options?.weekStartsOn ?? 0, s = I(e, t?.in), r = s.getDay(), i = (r < n ? -7 : 0) + 6 - (r - n);
  return s.setDate(s.getDate() + i), s.setHours(23, 59, 59, 999), s;
}
function yn(e, t) {
  return Je(e, { ...t, weekStartsOn: 1 });
}
function pn(e, t) {
  const o = I(e, t?.in), n = o.getFullYear(), s = o.getMonth(), r = L(o, 0);
  return r.setFullYear(n, s + 1, 0), r.setHours(0, 0, 0, 0), r.getDate();
}
function kn(e, t) {
  return I(e, t?.in).getMonth();
}
function Mn(e, t) {
  return I(e, t?.in).getFullYear();
}
function Dn(e, t) {
  return +I(e) > +I(t);
}
function bn(e, t) {
  return +I(e) < +I(t);
}
function wn(e, t, o) {
  const [n, s] = ce(
    o?.in,
    e,
    t
  );
  return n.getFullYear() === s.getFullYear() && n.getMonth() === s.getMonth();
}
function vn(e, t, o) {
  const [n, s] = ce(
    o?.in,
    e,
    t
  );
  return n.getFullYear() === s.getFullYear();
}
function On(e, t, o) {
  const n = I(e, o?.in), s = n.getFullYear(), r = n.getDate(), i = L(e, 0);
  i.setFullYear(s, t, 15), i.setHours(0, 0, 0, 0);
  const a = pn(i);
  return n.setMonth(t, Math.min(r, a)), n;
}
function gn(e, t, o) {
  const n = I(e, o?.in);
  return isNaN(+n) ? L(e, NaN) : (n.setFullYear(t), n);
}
const je = 5, _n = 4;
function Cn(e, t) {
  const o = t.startOfMonth(e), n = o.getDay() > 0 ? o.getDay() : 7, s = t.addDays(e, -n + 1), r = t.addDays(s, je * 7 - 1);
  return t.getMonth(e) === t.getMonth(r) ? je : _n;
}
function Qe(e, t) {
  const o = t.startOfMonth(e), n = o.getDay();
  return n === 1 ? o : n === 0 ? t.addDays(o, -6) : t.addDays(o, -1 * (n - 1));
}
function Wn(e, t) {
  const o = Qe(e, t), n = Cn(e, t);
  return t.addDays(o, n * 7 - 1);
}
class ee {
  /**
   * Creates an instance of `DateLib`.
   *
   * @param options Configuration options for the date library.
   * @param overrides Custom overrides for the date library functions.
   */
  constructor(t, o) {
    this.Date = Date, this.today = () => this.overrides?.today ? this.overrides.today() : this.options.timeZone ? F.tz(this.options.timeZone) : new this.Date(), this.newDate = (n, s, r) => this.overrides?.newDate ? this.overrides.newDate(n, s, r) : this.options.timeZone ? new F(n, s, r, this.options.timeZone) : new Date(n, s, r), this.addDays = (n, s) => this.overrides?.addDays ? this.overrides.addDays(n, s) : Ge(n, s), this.addMonths = (n, s) => this.overrides?.addMonths ? this.overrides.addMonths(n, s) : Ve(n, s), this.addWeeks = (n, s) => this.overrides?.addWeeks ? this.overrides.addWeeks(n, s) : on(n, s), this.addYears = (n, s) => this.overrides?.addYears ? this.overrides.addYears(n, s) : sn(n, s), this.differenceInCalendarDays = (n, s) => this.overrides?.differenceInCalendarDays ? this.overrides.differenceInCalendarDays(n, s) : Rt(n, s), this.differenceInCalendarMonths = (n, s) => this.overrides?.differenceInCalendarMonths ? this.overrides.differenceInCalendarMonths(n, s) : fn(n, s), this.eachMonthOfInterval = (n) => this.overrides?.eachMonthOfInterval ? this.overrides.eachMonthOfInterval(n) : un(n), this.endOfBroadcastWeek = (n) => this.overrides?.endOfBroadcastWeek ? this.overrides.endOfBroadcastWeek(n) : Wn(n, this), this.endOfISOWeek = (n) => this.overrides?.endOfISOWeek ? this.overrides.endOfISOWeek(n) : yn(n), this.endOfMonth = (n) => this.overrides?.endOfMonth ? this.overrides.endOfMonth(n) : ln(n), this.endOfWeek = (n, s) => this.overrides?.endOfWeek ? this.overrides.endOfWeek(n, s) : Je(n, this.options), this.endOfYear = (n) => this.overrides?.endOfYear ? this.overrides.endOfYear(n) : mn(n), this.format = (n, s, r) => {
      const i = this.overrides?.format ? this.overrides.format(n, s, this.options) : Ut(n, s, this.options);
      return this.options.numerals && this.options.numerals !== "latn" ? this.replaceDigits(i) : i;
    }, this.getISOWeek = (n) => this.overrides?.getISOWeek ? this.overrides.getISOWeek(n) : Gt(n), this.getMonth = (n, s) => this.overrides?.getMonth ? this.overrides.getMonth(n, this.options) : kn(n, this.options), this.getYear = (n, s) => this.overrides?.getYear ? this.overrides.getYear(n, this.options) : Mn(n, this.options), this.getWeek = (n, s) => this.overrides?.getWeek ? this.overrides.getWeek(n, this.options) : Kt(n, this.options), this.isAfter = (n, s) => this.overrides?.isAfter ? this.overrides.isAfter(n, s) : Dn(n, s), this.isBefore = (n, s) => this.overrides?.isBefore ? this.overrides.isBefore(n, s) : bn(n, s), this.isDate = (n) => this.overrides?.isDate ? this.overrides.isDate(n) : Lt(n), this.isSameDay = (n, s) => this.overrides?.isSameDay ? this.overrides.isSameDay(n, s) : cn(n, s), this.isSameMonth = (n, s) => this.overrides?.isSameMonth ? this.overrides.isSameMonth(n, s) : wn(n, s), this.isSameYear = (n, s) => this.overrides?.isSameYear ? this.overrides.isSameYear(n, s) : vn(n, s), this.max = (n) => this.overrides?.max ? this.overrides.max(n) : rn(n), this.min = (n) => this.overrides?.min ? this.overrides.min(n) : an(n), this.setMonth = (n, s) => this.overrides?.setMonth ? this.overrides.setMonth(n, s) : On(n, s), this.setYear = (n, s) => this.overrides?.setYear ? this.overrides.setYear(n, s) : gn(n, s), this.startOfBroadcastWeek = (n, s) => this.overrides?.startOfBroadcastWeek ? this.overrides.startOfBroadcastWeek(n, this) : Qe(n, this), this.startOfDay = (n) => this.overrides?.startOfDay ? this.overrides.startOfDay(n) : Ee(n), this.startOfISOWeek = (n) => this.overrides?.startOfISOWeek ? this.overrides.startOfISOWeek(n) : Vt(n), this.startOfMonth = (n) => this.overrides?.startOfMonth ? this.overrides.startOfMonth(n) : hn(n), this.startOfWeek = (n, s) => this.overrides?.startOfWeek ? this.overrides.startOfWeek(n, this.options) : Jt(n, this.options), this.startOfYear = (n) => this.overrides?.startOfYear ? this.overrides.startOfYear(n) : Qt(n), this.options = { locale: Ke, ...t }, this.overrides = o;
  }
  /**
   * Generates a mapping of Arabic digits (0-9) to the target numbering system
   * digits.
   *
   * @since 9.5.0
   * @returns A record mapping Arabic digits to the target numerals.
   */
  getDigitMap() {
    const { numerals: t = "latn" } = this.options, o = new Intl.NumberFormat("en-US", {
      numberingSystem: t
    }), n = {};
    for (let s = 0; s < 10; s++)
      n[s.toString()] = o.format(s);
    return n;
  }
  /**
   * Replaces Arabic digits in a string with the target numbering system digits.
   *
   * @since 9.5.0
   * @param input The string containing Arabic digits.
   * @returns The string with digits replaced.
   */
  replaceDigits(t) {
    const o = this.getDigitMap();
    return t.replace(/\d/g, (n) => o[n] || n);
  }
  /**
   * Formats a number using the configured numbering system.
   *
   * @since 9.5.0
   * @param value The number to format.
   * @returns The formatted number as a string.
   */
  formatNumber(t) {
    return this.replaceDigits(t.toString());
  }
}
const V = new ee();
class Xe {
  constructor(t, o, n = V) {
    this.date = t, this.displayMonth = o, this.outside = !!(o && !n.isSameMonth(t, o)), this.dateLib = n;
  }
  /**
   * Checks if this day is equal to another `CalendarDay`, considering both the
   * date and the displayed month.
   *
   * @param day The `CalendarDay` to compare with.
   * @returns `true` if the days are equal, otherwise `false`.
   */
  isEqualTo(t) {
    return this.dateLib.isSameDay(t.date, this.date) && this.dateLib.isSameMonth(t.displayMonth, this.displayMonth);
  }
}
class Nn {
  constructor(t, o) {
    this.date = t, this.weeks = o;
  }
}
class Sn {
  constructor(t, o) {
    this.days = o, this.weekNumber = t;
  }
}
function Q(e, t, o = !1, n = V) {
  let { from: s, to: r } = e;
  const { differenceInCalendarDays: i, isSameDay: a } = n;
  return s && r ? (i(r, s) < 0 && ([s, r] = [r, s]), i(t, s) >= (o ? 1 : 0) && i(r, t) >= (o ? 1 : 0)) : !o && r ? a(r, t) : !o && s ? a(s, t) : !1;
}
function et(e) {
  return !!(e && typeof e == "object" && "before" in e && "after" in e);
}
function Ye(e) {
  return !!(e && typeof e == "object" && "from" in e);
}
function tt(e) {
  return !!(e && typeof e == "object" && "after" in e);
}
function nt(e) {
  return !!(e && typeof e == "object" && "before" in e);
}
function ot(e) {
  return !!(e && typeof e == "object" && "dayOfWeek" in e);
}
function st(e, t) {
  return Array.isArray(e) && e.every(t.isDate);
}
function X(e, t, o = V) {
  const n = Array.isArray(t) ? t : [t], { isSameDay: s, differenceInCalendarDays: r, isAfter: i } = o;
  return n.some((a) => {
    if (typeof a == "boolean")
      return a;
    if (o.isDate(a))
      return s(e, a);
    if (st(a, o))
      return a.includes(e);
    if (Ye(a))
      return Q(a, e, !1, o);
    if (ot(a))
      return Array.isArray(a.dayOfWeek) ? a.dayOfWeek.includes(e.getDay()) : a.dayOfWeek === e.getDay();
    if (et(a)) {
      const c = r(a.before, e), f = r(a.after, e), h = c > 0, l = f < 0;
      return i(a.before, a.after) ? l && h : h || l;
    }
    return tt(a) ? r(e, a.after) > 0 : nt(a) ? r(a.before, e) > 0 : typeof a == "function" ? a(e) : !1;
  });
}
function En(e, t, o, n, s) {
  const { disabled: r, hidden: i, modifiers: a, showOutsideDays: c, broadcastCalendar: f, today: h } = t, { isSameDay: l, isSameMonth: u, startOfMonth: p, isBefore: w, endOfMonth: g, isAfter: D } = s, O = o && p(o), W = n && g(n), k = {
    [T.focused]: [],
    [T.outside]: [],
    [T.disabled]: [],
    [T.hidden]: [],
    [T.today]: []
  }, S = {};
  for (const y of e) {
    const { date: b, displayMonth: M } = y, _ = !!(M && !u(b, M)), Y = !!(O && w(b, O)), $ = !!(W && D(b, W)), P = !!(r && X(b, r, s)), Z = !!(i && X(b, i, s)) || Y || $ || // Broadcast calendar will show outside days as default
    !f && !c && _ || f && c === !1 && _, oe = l(b, h ?? s.today());
    _ && k.outside.push(y), P && k.disabled.push(y), Z && k.hidden.push(y), oe && k.today.push(y), a && Object.keys(a).forEach((se) => {
      const re = a?.[se];
      re && X(b, re, s) && (S[se] ? S[se].push(y) : S[se] = [y]);
    });
  }
  return (y) => {
    const b = {
      [T.focused]: !1,
      [T.disabled]: !1,
      [T.hidden]: !1,
      [T.outside]: !1,
      [T.today]: !1
    }, M = {};
    for (const _ in k) {
      const Y = k[_];
      b[_] = Y.some(($) => $ === y);
    }
    for (const _ in S)
      M[_] = S[_].some((Y) => Y === y);
    return {
      ...b,
      // custom modifiers should override all the previous ones
      ...M
    };
  };
}
function Tn(e, t, o = {}) {
  return Object.entries(e).filter(([, s]) => s === !0).reduce((s, [r]) => (o[r] ? s.push(o[r]) : t[T[r]] ? s.push(t[T[r]]) : t[R[r]] && s.push(t[R[r]]), s), [t[m.Day]]);
}
function Yn(e) {
  return d.createElement("button", { ...e });
}
function Bn(e) {
  return d.createElement("span", { ...e });
}
function xn(e) {
  const { size: t = 24, orientation: o = "left", className: n } = e;
  return d.createElement(
    "svg",
    { className: n, width: t, height: t, viewBox: "0 0 24 24" },
    o === "up" && d.createElement("polygon", { points: "6.77 17 12.5 11.43 18.24 17 20 15.28 12.5 8 5 15.28" }),
    o === "down" && d.createElement("polygon", { points: "6.77 8 12.5 13.57 18.24 8 20 9.72 12.5 17 5 9.72" }),
    o === "left" && d.createElement("polygon", { points: "16 18.112 9.81111111 12 16 5.87733333 14.0888889 4 6 12 14.0888889 20" }),
    o === "right" && d.createElement("polygon", { points: "8 18.112 14.18888889 12 8 5.87733333 9.91111111 4 18 12 9.91111111 20" })
  );
}
function Fn(e) {
  const { day: t, modifiers: o, ...n } = e;
  return d.createElement("td", { ...n });
}
function In(e) {
  const { day: t, modifiers: o, ...n } = e, s = d.useRef(null);
  return d.useEffect(() => {
    o.focused && s.current?.focus();
  }, [o.focused]), d.createElement("button", { ref: s, ...n });
}
function $n(e) {
  const { options: t, className: o, components: n, classNames: s, ...r } = e, i = [s[m.Dropdown], o].join(" "), a = t?.find(({ value: c }) => c === r.value);
  return d.createElement(
    "span",
    { "data-disabled": r.disabled, className: s[m.DropdownRoot] },
    d.createElement(n.Select, { className: i, ...r }, t?.map(({ value: c, label: f, disabled: h }) => d.createElement(n.Option, { key: c, value: c, disabled: h }, f))),
    d.createElement(
      "span",
      { className: s[m.CaptionLabel], "aria-hidden": !0 },
      a?.label,
      d.createElement(n.Chevron, { orientation: "down", size: 18, className: s[m.Chevron] })
    )
  );
}
function Pn(e) {
  return d.createElement("div", { ...e });
}
function An(e) {
  return d.createElement("div", { ...e });
}
function Hn(e) {
  const { calendarMonth: t, displayIndex: o, ...n } = e;
  return d.createElement("div", { ...n }, e.children);
}
function Zn(e) {
  const { calendarMonth: t, displayIndex: o, ...n } = e;
  return d.createElement("div", { ...n });
}
function jn(e) {
  return d.createElement("table", { ...e });
}
function zn(e) {
  return d.createElement("div", { ...e });
}
const rt = At(void 0);
function fe() {
  const e = Ht(rt);
  if (e === void 0)
    throw new Error("useDayPicker() must be used within a custom component.");
  return e;
}
function qn(e) {
  const { components: t } = fe();
  return d.createElement(t.Dropdown, { ...e });
}
function Rn(e) {
  const { onPreviousClick: t, onNextClick: o, previousMonth: n, nextMonth: s, ...r } = e, { components: i, classNames: a, labels: { labelPrevious: c, labelNext: f } } = fe(), h = H((u) => {
    s && o?.(u);
  }, [s, o]), l = H((u) => {
    n && t?.(u);
  }, [n, t]);
  return d.createElement(
    "nav",
    { ...r },
    d.createElement(
      i.PreviousMonthButton,
      { type: "button", className: a[m.PreviousMonthButton], tabIndex: n ? void 0 : -1, "aria-disabled": n ? void 0 : !0, "aria-label": c(n), onClick: l },
      d.createElement(i.Chevron, { disabled: n ? void 0 : !0, className: a[m.Chevron], orientation: "left" })
    ),
    d.createElement(
      i.NextMonthButton,
      { type: "button", className: a[m.NextMonthButton], tabIndex: s ? void 0 : -1, "aria-disabled": s ? void 0 : !0, "aria-label": f(s), onClick: h },
      d.createElement(i.Chevron, { disabled: s ? void 0 : !0, orientation: "right", className: a[m.Chevron] })
    )
  );
}
function Un(e) {
  const { components: t } = fe();
  return d.createElement(t.Button, { ...e });
}
function Gn(e) {
  return d.createElement("option", { ...e });
}
function Kn(e) {
  const { components: t } = fe();
  return d.createElement(t.Button, { ...e });
}
function Ln(e) {
  const { rootRef: t, ...o } = e;
  return d.createElement("div", { ...o, ref: t });
}
function Vn(e) {
  return d.createElement("select", { ...e });
}
function Jn(e) {
  const { week: t, ...o } = e;
  return d.createElement("tr", { ...o });
}
function Qn(e) {
  return d.createElement("th", { ...e });
}
function Xn(e) {
  return d.createElement(
    "thead",
    { "aria-hidden": !0 },
    d.createElement("tr", { ...e })
  );
}
function eo(e) {
  const { week: t, ...o } = e;
  return d.createElement("th", { ...o });
}
function to(e) {
  return d.createElement("th", { ...e });
}
function no(e) {
  return d.createElement("tbody", { ...e });
}
function oo(e) {
  const { components: t } = fe();
  return d.createElement(t.Dropdown, { ...e });
}
const so = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  Button: Yn,
  CaptionLabel: Bn,
  Chevron: xn,
  Day: Fn,
  DayButton: In,
  Dropdown: $n,
  DropdownNav: Pn,
  Footer: An,
  Month: Hn,
  MonthCaption: Zn,
  MonthGrid: jn,
  Months: zn,
  MonthsDropdown: qn,
  Nav: Rn,
  NextMonthButton: Un,
  Option: Gn,
  PreviousMonthButton: Kn,
  Root: Ln,
  Select: Vn,
  Week: Jn,
  WeekNumber: eo,
  WeekNumberHeader: to,
  Weekday: Qn,
  Weekdays: Xn,
  Weeks: no,
  YearsDropdown: oo
}, Symbol.toStringTag, { value: "Module" }));
function ro(e) {
  return {
    ...so,
    ...e
  };
}
function ao(e) {
  const t = {
    "data-mode": e.mode ?? void 0,
    "data-required": "required" in e ? e.required : void 0,
    "data-multiple-months": e.numberOfMonths && e.numberOfMonths > 1 || void 0,
    "data-week-numbers": e.showWeekNumber || void 0,
    "data-broadcast-calendar": e.broadcastCalendar || void 0,
    "data-nav-layout": e.navLayout || void 0
  };
  return Object.entries(e).forEach(([o, n]) => {
    o.startsWith("data-") && (t[o] = n);
  }), t;
}
function at() {
  const e = {};
  for (const t in m)
    e[m[t]] = `rdp-${m[t]}`;
  for (const t in T)
    e[T[t]] = `rdp-${T[t]}`;
  for (const t in R)
    e[R[t]] = `rdp-${R[t]}`;
  for (const t in A)
    e[A[t]] = `rdp-${A[t]}`;
  return e;
}
function it(e, t, o) {
  return (o ?? new ee(t)).format(e, "LLLL y");
}
const io = it;
function co(e, t, o) {
  return (o ?? new ee(t)).format(e, "d");
}
function fo(e, t = V) {
  return t.format(e, "LLLL");
}
function lo(e, t = V) {
  return e < 10 ? t.formatNumber(`0${e.toLocaleString()}`) : t.formatNumber(`${e.toLocaleString()}`);
}
function uo() {
  return "";
}
function ho(e, t, o) {
  return (o ?? new ee(t)).format(e, "cccccc");
}
function ct(e, t = V) {
  return t.format(e, "yyyy");
}
const mo = ct, yo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  formatCaption: it,
  formatDay: co,
  formatMonthCaption: io,
  formatMonthDropdown: fo,
  formatWeekNumber: lo,
  formatWeekNumberHeader: uo,
  formatWeekdayName: ho,
  formatYearCaption: mo,
  formatYearDropdown: ct
}, Symbol.toStringTag, { value: "Module" }));
function po(e) {
  return e?.formatMonthCaption && !e.formatCaption && (e.formatCaption = e.formatMonthCaption), e?.formatYearCaption && !e.formatYearDropdown && (e.formatYearDropdown = e.formatYearCaption), {
    ...yo,
    ...e
  };
}
function ko(e, t, o, n, s) {
  const { startOfMonth: r, startOfYear: i, endOfYear: a, eachMonthOfInterval: c, getMonth: f } = s;
  return c({
    start: i(e),
    end: a(e)
  }).map((u) => {
    const p = n.formatMonthDropdown(u, s), w = f(u), g = t && u < r(t) || o && u > r(o) || !1;
    return { value: w, label: p, disabled: g };
  });
}
function Mo(e, t = {}, o = {}) {
  let n = { ...t?.[m.Day] };
  return Object.entries(e).filter(([, s]) => s === !0).forEach(([s]) => {
    n = {
      ...n,
      ...o?.[s]
    };
  }), n;
}
function Do(e, t, o) {
  const n = e.today(), s = t ? e.startOfISOWeek(n) : e.startOfWeek(n), r = [];
  for (let i = 0; i < 7; i++) {
    const a = e.addDays(s, i);
    r.push(a);
  }
  return r;
}
function bo(e, t, o, n) {
  if (!e || !t)
    return;
  const { startOfYear: s, endOfYear: r, addYears: i, getYear: a, isBefore: c, isSameYear: f } = n, h = s(e), l = r(t), u = [];
  let p = h;
  for (; c(p, l) || f(p, l); )
    u.push(p), p = i(p, 1);
  return u.map((w) => {
    const g = o.formatYearDropdown(w, n);
    return {
      value: a(w),
      label: g,
      disabled: !1
    };
  });
}
function ft(e, t, o) {
  return (o ?? new ee(t)).format(e, "LLLL y");
}
const wo = ft;
function vo(e, t, o, n) {
  let s = (n ?? new ee(o)).format(e, "PPPP");
  return t?.today && (s = `Today, ${s}`), s;
}
function lt(e, t, o, n) {
  let s = (n ?? new ee(o)).format(e, "PPPP");
  return t.today && (s = `Today, ${s}`), t.selected && (s = `${s}, selected`), s;
}
const Oo = lt;
function go() {
  return "";
}
function _o(e) {
  return "Choose the Month";
}
function Co(e) {
  return "Go to the Next Month";
}
function Wo(e) {
  return "Go to the Previous Month";
}
function No(e, t, o) {
  return (o ?? new ee(t)).format(e, "cccc");
}
function So(e, t) {
  return `Week ${e}`;
}
function Eo(e) {
  return "Week Number";
}
function To(e) {
  return "Choose the Year";
}
const Yo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  labelCaption: wo,
  labelDay: Oo,
  labelDayButton: lt,
  labelGrid: ft,
  labelGridcell: vo,
  labelMonthDropdown: _o,
  labelNav: go,
  labelNext: Co,
  labelPrevious: Wo,
  labelWeekNumber: So,
  labelWeekNumberHeader: Eo,
  labelWeekday: No,
  labelYearDropdown: To
}, Symbol.toStringTag, { value: "Module" })), le = (e) => e instanceof HTMLElement ? e : null, We = (e) => [
  ...e.querySelectorAll("[data-animated-month]") ?? []
], Bo = (e) => le(e.querySelector("[data-animated-month]")), Ne = (e) => le(e.querySelector("[data-animated-caption]")), Se = (e) => le(e.querySelector("[data-animated-weeks]")), xo = (e) => le(e.querySelector("[data-animated-nav]")), Fo = (e) => le(e.querySelector("[data-animated-weekdays]"));
function Io(e, t, { classNames: o, months: n, focused: s, dateLib: r }) {
  const i = ye(null), a = ye(n), c = ye(!1);
  Zt(() => {
    const f = a.current;
    if (a.current = n, !t || !e.current || // safety check because the ref can be set to anything by consumers
    !(e.current instanceof HTMLElement) || // validation required for the animation to work as expected
    n.length === 0 || f.length === 0 || n.length !== f.length)
      return;
    const h = r.isSameMonth(n[0].date, f[0].date), l = r.isAfter(n[0].date, f[0].date), u = l ? o[A.caption_after_enter] : o[A.caption_before_enter], p = l ? o[A.weeks_after_enter] : o[A.weeks_before_enter], w = i.current, g = e.current.cloneNode(!0);
    if (g instanceof HTMLElement ? (We(g).forEach((k) => {
      if (!(k instanceof HTMLElement))
        return;
      const S = Bo(k);
      S && k.contains(S) && k.removeChild(S);
      const y = Ne(k);
      y && y.classList.remove(u);
      const b = Se(k);
      b && b.classList.remove(p);
    }), i.current = g) : i.current = null, c.current || h || // skip animation if a day is focused because it can cause issues to the animation and is better for a11y
    s)
      return;
    const D = w instanceof HTMLElement ? We(w) : [], O = We(e.current);
    if (O && O.every((W) => W instanceof HTMLElement) && D && D.every((W) => W instanceof HTMLElement)) {
      c.current = !0, e.current.style.isolation = "isolate";
      const W = xo(e.current);
      W && (W.style.zIndex = "1"), O.forEach((k, S) => {
        const y = D[S];
        if (!y)
          return;
        k.style.position = "relative", k.style.overflow = "hidden";
        const b = Ne(k);
        b && b.classList.add(u);
        const M = Se(k);
        M && M.classList.add(p);
        const _ = () => {
          c.current = !1, e.current && (e.current.style.isolation = ""), W && (W.style.zIndex = ""), b && b.classList.remove(u), M && M.classList.remove(p), k.style.position = "", k.style.overflow = "", k.contains(y) && k.removeChild(y);
        };
        y.style.pointerEvents = "none", y.style.position = "absolute", y.style.overflow = "hidden", y.setAttribute("aria-hidden", "true");
        const Y = Fo(y);
        Y && (Y.style.opacity = "0");
        const $ = Ne(y);
        $ && ($.classList.add(l ? o[A.caption_before_exit] : o[A.caption_after_exit]), $.addEventListener("animationend", _));
        const P = Se(y);
        P && P.classList.add(l ? o[A.weeks_before_exit] : o[A.weeks_after_exit]), k.insertBefore(y, k.firstChild);
      });
    }
  });
}
function $o(e, t, o, n) {
  const s = e[0], r = e[e.length - 1], { ISOWeek: i, fixedWeeks: a, broadcastCalendar: c } = o ?? {}, { addDays: f, differenceInCalendarDays: h, differenceInCalendarMonths: l, endOfBroadcastWeek: u, endOfISOWeek: p, endOfMonth: w, endOfWeek: g, isAfter: D, startOfBroadcastWeek: O, startOfISOWeek: W, startOfWeek: k } = n, S = c ? O(s, n) : i ? W(s) : k(s), y = c ? u(r) : i ? p(w(r)) : g(w(r)), b = h(y, S), M = l(r, s) + 1, _ = [];
  for (let P = 0; P <= b; P++) {
    const Z = f(S, P);
    if (t && D(Z, t))
      break;
    _.push(Z);
  }
  const $ = (c ? 35 : 42) * M;
  if (a && _.length < $) {
    const P = $ - _.length;
    for (let Z = 0; Z < P; Z++) {
      const oe = f(_[_.length - 1], 1);
      _.push(oe);
    }
  }
  return _;
}
function Po(e) {
  const t = [];
  return e.reduce((o, n) => {
    const s = n.weeks.reduce((r, i) => [...r, ...i.days], t);
    return [...o, ...s];
  }, t);
}
function Ao(e, t, o, n) {
  const { numberOfMonths: s = 1 } = o, r = [];
  for (let i = 0; i < s; i++) {
    const a = n.addMonths(e, i);
    if (t && a > t)
      break;
    r.push(a);
  }
  return r;
}
function ze(e, t, o, n) {
  const { month: s, defaultMonth: r, today: i = n.today(), numberOfMonths: a = 1 } = e;
  let c = s || r || i;
  const { differenceInCalendarMonths: f, addMonths: h, startOfMonth: l } = n;
  if (o && f(o, c) < a - 1) {
    const u = -1 * (a - 1);
    c = h(o, u);
  }
  return t && f(c, t) < 0 && (c = t), l(c);
}
function Ho(e, t, o, n) {
  const { addDays: s, endOfBroadcastWeek: r, endOfISOWeek: i, endOfMonth: a, endOfWeek: c, getISOWeek: f, getWeek: h, startOfBroadcastWeek: l, startOfISOWeek: u, startOfWeek: p } = n, w = e.reduce((g, D) => {
    const O = o.broadcastCalendar ? l(D, n) : o.ISOWeek ? u(D) : p(D), W = o.broadcastCalendar ? r(D) : o.ISOWeek ? i(a(D)) : c(a(D)), k = t.filter((M) => M >= O && M <= W), S = o.broadcastCalendar ? 35 : 42;
    if (o.fixedWeeks && k.length < S) {
      const M = t.filter((_) => {
        const Y = S - k.length;
        return _ > W && _ <= s(W, Y);
      });
      k.push(...M);
    }
    const y = k.reduce((M, _) => {
      const Y = o.ISOWeek ? f(_) : h(_), $ = M.find((Z) => Z.weekNumber === Y), P = new Xe(_, D, n);
      return $ ? $.days.push(P) : M.push(new Sn(Y, [P])), M;
    }, []), b = new Nn(D, y);
    return g.push(b), g;
  }, []);
  return o.reverseMonths ? w.reverse() : w;
}
function Zo(e, t) {
  let { startMonth: o, endMonth: n } = e;
  const { startOfYear: s, startOfDay: r, startOfMonth: i, endOfMonth: a, addYears: c, endOfYear: f, newDate: h, today: l } = t, { fromYear: u, toYear: p, fromMonth: w, toMonth: g } = e;
  !o && w && (o = w), !o && u && (o = t.newDate(u, 0, 1)), !n && g && (n = g), !n && p && (n = h(p, 11, 31));
  const D = e.captionLayout === "dropdown" || e.captionLayout === "dropdown-years";
  return o ? o = i(o) : u ? o = h(u, 0, 1) : !o && D && (o = s(c(e.today ?? l(), -100))), n ? n = a(n) : p ? n = h(p, 11, 31) : !n && D && (n = f(e.today ?? l())), [
    o && r(o),
    n && r(n)
  ];
}
function jo(e, t, o, n) {
  if (o.disableNavigation)
    return;
  const { pagedNavigation: s, numberOfMonths: r = 1 } = o, { startOfMonth: i, addMonths: a, differenceInCalendarMonths: c } = n, f = s ? r : 1, h = i(e);
  if (!t)
    return a(h, f);
  if (!(c(t, e) < r))
    return a(h, f);
}
function zo(e, t, o, n) {
  if (o.disableNavigation)
    return;
  const { pagedNavigation: s, numberOfMonths: r } = o, { startOfMonth: i, addMonths: a, differenceInCalendarMonths: c } = n, f = s ? r ?? 1 : 1, h = i(e);
  if (!t)
    return a(h, -f);
  if (!(c(h, t) <= 0))
    return a(h, -f);
}
function qo(e) {
  const t = [];
  return e.reduce((o, n) => [...o, ...n.weeks], t);
}
function ke(e, t) {
  const [o, n] = pe(e);
  return [t === void 0 ? o : t, n];
}
function Ro(e, t) {
  const [o, n] = Zo(e, t), { startOfMonth: s, endOfMonth: r } = t, i = ze(e, o, n, t), [a, c] = ke(
    i,
    // initialMonth is always computed from props.month if provided
    e.month ? i : void 0
  );
  Ue(() => {
    const b = ze(e, o, n, t);
    c(b);
  }, [e.timeZone]);
  const f = Ao(a, n, e, t), h = $o(f, e.endMonth ? r(e.endMonth) : void 0, e, t), l = Ho(f, h, e, t), u = qo(l), p = Po(l), w = zo(a, o, e, t), g = jo(a, n, e, t), { disableNavigation: D, onMonthChange: O } = e, W = (b) => u.some((M) => M.days.some((_) => _.isEqualTo(b))), k = (b) => {
    if (D)
      return;
    let M = s(b);
    o && M < s(o) && (M = s(o)), n && M > s(n) && (M = s(n)), c(M), O?.(M);
  };
  return {
    months: l,
    weeks: u,
    days: p,
    navStart: o,
    navEnd: n,
    previousMonth: w,
    nextMonth: g,
    goToMonth: k,
    goToDay: (b) => {
      W(b) || k(b.date);
    }
  };
}
var G;
(function(e) {
  e[e.Today = 0] = "Today", e[e.Selected = 1] = "Selected", e[e.LastFocused = 2] = "LastFocused", e[e.FocusedModifier = 3] = "FocusedModifier";
})(G || (G = {}));
function qe(e) {
  return !e[T.disabled] && !e[T.hidden] && !e[T.outside];
}
function Uo(e, t, o, n) {
  let s, r = -1;
  for (const i of e) {
    const a = t(i);
    qe(a) && (a[T.focused] && r < G.FocusedModifier ? (s = i, r = G.FocusedModifier) : n?.isEqualTo(i) && r < G.LastFocused ? (s = i, r = G.LastFocused) : o(i.date) && r < G.Selected ? (s = i, r = G.Selected) : a[T.today] && r < G.Today && (s = i, r = G.Today));
  }
  return s || (s = e.find((i) => qe(t(i)))), s;
}
function Go(e, t, o, n, s, r, i) {
  const { ISOWeek: a, broadcastCalendar: c } = r, { addDays: f, addMonths: h, addWeeks: l, addYears: u, endOfBroadcastWeek: p, endOfISOWeek: w, endOfWeek: g, max: D, min: O, startOfBroadcastWeek: W, startOfISOWeek: k, startOfWeek: S } = i;
  let b = {
    day: f,
    week: l,
    month: h,
    year: u,
    startOfWeek: (M) => c ? W(M, i) : a ? k(M) : S(M),
    endOfWeek: (M) => c ? p(M) : a ? w(M) : g(M)
  }[e](o, t === "after" ? 1 : -1);
  return t === "before" && n ? b = D([n, b]) : t === "after" && s && (b = O([s, b])), b;
}
function dt(e, t, o, n, s, r, i, a = 0) {
  if (a > 365)
    return;
  const c = Go(e, t, o.date, n, s, r, i), f = !!(r.disabled && X(c, r.disabled, i)), h = !!(r.hidden && X(c, r.hidden, i)), l = c, u = new Xe(c, l, i);
  return !f && !h ? u : dt(e, t, u, n, s, r, i, a + 1);
}
function Ko(e, t, o, n, s) {
  const { autoFocus: r } = e, [i, a] = pe(), c = Uo(t.days, o, n || (() => !1), i), [f, h] = pe(r ? c : void 0);
  return {
    isFocusTarget: (g) => !!c?.isEqualTo(g),
    setFocused: h,
    focused: f,
    blur: () => {
      a(f), h(void 0);
    },
    moveFocus: (g, D) => {
      if (!f)
        return;
      const O = dt(g, D, f, t.navStart, t.navEnd, e, s);
      O && (t.goToDay(O), h(O));
    }
  };
}
function Lo(e, t) {
  const { selected: o, required: n, onSelect: s } = e, [r, i] = ke(o, s ? o : void 0), a = s ? o : r, { isSameDay: c } = t, f = (p) => a?.some((w) => c(w, p)) ?? !1, { min: h, max: l } = e;
  return {
    selected: a,
    select: (p, w, g) => {
      let D = [...a ?? []];
      if (f(p)) {
        if (a?.length === h || n && a?.length === 1)
          return;
        D = a?.filter((O) => !c(O, p));
      } else
        a?.length === l ? D = [p] : D = [...D, p];
      return s || i(D), s?.(D, p, w, g), D;
    },
    isSelected: f
  };
}
function Vo(e, t, o = 0, n = 0, s = !1, r = V) {
  const { from: i, to: a } = t || {}, { isSameDay: c, isAfter: f, isBefore: h } = r;
  let l;
  if (!i && !a)
    l = { from: e, to: o > 0 ? void 0 : e };
  else if (i && !a)
    c(i, e) ? s ? l = { from: i, to: void 0 } : l = void 0 : h(e, i) ? l = { from: e, to: i } : l = { from: i, to: e };
  else if (i && a)
    if (c(i, e) && c(a, e))
      s ? l = { from: i, to: a } : l = void 0;
    else if (c(i, e))
      l = { from: i, to: o > 0 ? void 0 : e };
    else if (c(a, e))
      l = { from: e, to: o > 0 ? void 0 : e };
    else if (h(e, i))
      l = { from: e, to: a };
    else if (f(e, i))
      l = { from: i, to: e };
    else if (f(e, a))
      l = { from: i, to: e };
    else
      throw new Error("Invalid range");
  if (l?.from && l?.to) {
    const u = r.differenceInCalendarDays(l.to, l.from);
    n > 0 && u > n ? l = { from: e, to: void 0 } : o > 1 && u < o && (l = { from: e, to: void 0 });
  }
  return l;
}
function Jo(e, t, o = V) {
  const n = Array.isArray(t) ? t : [t];
  let s = e.from;
  const r = o.differenceInCalendarDays(e.to, e.from), i = Math.min(r, 6);
  for (let a = 0; a <= i; a++) {
    if (n.includes(s.getDay()))
      return !0;
    s = o.addDays(s, 1);
  }
  return !1;
}
function Re(e, t, o = V) {
  return Q(e, t.from, !1, o) || Q(e, t.to, !1, o) || Q(t, e.from, !1, o) || Q(t, e.to, !1, o);
}
function Qo(e, t, o = V) {
  const n = Array.isArray(t) ? t : [t];
  if (n.filter((a) => typeof a != "function").some((a) => typeof a == "boolean" ? a : o.isDate(a) ? Q(e, a, !1, o) : st(a, o) ? a.some((c) => Q(e, c, !1, o)) : Ye(a) ? a.from && a.to ? Re(e, { from: a.from, to: a.to }, o) : !1 : ot(a) ? Jo(e, a.dayOfWeek, o) : et(a) ? o.isAfter(a.before, a.after) ? Re(e, {
    from: o.addDays(a.after, 1),
    to: o.addDays(a.before, -1)
  }, o) : X(e.from, a, o) || X(e.to, a, o) : tt(a) || nt(a) ? X(e.from, a, o) || X(e.to, a, o) : !1))
    return !0;
  const i = n.filter((a) => typeof a == "function");
  if (i.length) {
    let a = e.from;
    const c = o.differenceInCalendarDays(e.to, e.from);
    for (let f = 0; f <= c; f++) {
      if (i.some((h) => h(a)))
        return !0;
      a = o.addDays(a, 1);
    }
  }
  return !1;
}
function Xo(e, t) {
  const { disabled: o, excludeDisabled: n, selected: s, required: r, onSelect: i } = e, [a, c] = ke(s, i ? s : void 0), f = i ? s : a;
  return {
    selected: f,
    select: (u, p, w) => {
      const { min: g, max: D } = e, O = u ? Vo(u, f, g, D, r, t) : void 0;
      return n && o && O?.from && O.to && Qo({ from: O.from, to: O.to }, o, t) && (O.from = u, O.to = void 0), i || c(O), i?.(O, u, p, w), O;
    },
    isSelected: (u) => f && Q(f, u, !1, t)
  };
}
function es(e, t) {
  const { selected: o, required: n, onSelect: s } = e, [r, i] = ke(o, s ? o : void 0), a = s ? o : r, { isSameDay: c } = t;
  return {
    selected: a,
    select: (l, u, p) => {
      let w = l;
      return !n && a && a && c(l, a) && (w = void 0), s || i(w), s?.(w, l, u, p), w;
    },
    isSelected: (l) => a ? c(a, l) : !1
  };
}
function ts(e, t) {
  const o = es(e, t), n = Lo(e, t), s = Xo(e, t);
  switch (e.mode) {
    case "single":
      return o;
    case "multiple":
      return n;
    case "range":
      return s;
    default:
      return;
  }
}
function ns(e) {
  let t = e;
  t.timeZone && (t = {
    ...e
  }, t.today && (t.today = new F(t.today, t.timeZone)), t.month && (t.month = new F(t.month, t.timeZone)), t.defaultMonth && (t.defaultMonth = new F(t.defaultMonth, t.timeZone)), t.startMonth && (t.startMonth = new F(t.startMonth, t.timeZone)), t.endMonth && (t.endMonth = new F(t.endMonth, t.timeZone)), t.mode === "single" && t.selected ? t.selected = new F(t.selected, t.timeZone) : t.mode === "multiple" && t.selected ? t.selected = t.selected?.map((v) => new F(v, t.timeZone)) : t.mode === "range" && t.selected && (t.selected = {
    from: t.selected.from ? new F(t.selected.from, t.timeZone) : void 0,
    to: t.selected.to ? new F(t.selected.to, t.timeZone) : void 0
  }));
  const { components: o, formatters: n, labels: s, dateLib: r, locale: i, classNames: a } = Ce(() => {
    const v = { ...Ke, ...t.locale };
    return {
      dateLib: new ee({
        locale: v,
        weekStartsOn: t.broadcastCalendar ? 1 : t.weekStartsOn,
        firstWeekContainsDate: t.firstWeekContainsDate,
        useAdditionalWeekYearTokens: t.useAdditionalWeekYearTokens,
        useAdditionalDayOfYearTokens: t.useAdditionalDayOfYearTokens,
        timeZone: t.timeZone,
        numerals: t.numerals
      }, t.dateLib),
      components: ro(t.components),
      formatters: po(t.formatters),
      labels: { ...Yo, ...t.labels },
      locale: v,
      classNames: { ...at(), ...t.classNames }
    };
  }, [
    t.locale,
    t.broadcastCalendar,
    t.weekStartsOn,
    t.firstWeekContainsDate,
    t.useAdditionalWeekYearTokens,
    t.useAdditionalDayOfYearTokens,
    t.timeZone,
    t.numerals,
    t.dateLib,
    t.components,
    t.formatters,
    t.labels,
    t.classNames
  ]), { captionLayout: c, mode: f, navLayout: h, numberOfMonths: l = 1, onDayBlur: u, onDayClick: p, onDayFocus: w, onDayKeyDown: g, onDayMouseEnter: D, onDayMouseLeave: O, onNextClick: W, onPrevClick: k, showWeekNumber: S, styles: y } = t, { formatCaption: b, formatDay: M, formatMonthDropdown: _, formatWeekNumber: Y, formatWeekNumberHeader: $, formatWeekdayName: P, formatYearDropdown: Z } = n, oe = Ro(t, r), { days: se, months: re, navStart: de, navEnd: Me, previousMonth: j, nextMonth: z, goToMonth: J } = oe, De = En(se, t, de, Me, r), { isSelected: be, select: we, selected: ue } = ts(t, r) ?? {}, { blur: Be, focused: xe, isFocusTarget: ut, moveFocus: Fe, setFocused: he } = Ko(t, oe, De, be ?? (() => !1), r), { labelDayButton: ht, labelGridcell: mt, labelGrid: yt, labelMonthDropdown: pt, labelNav: Ie, labelPrevious: kt, labelNext: Mt, labelWeekday: Dt, labelWeekNumber: bt, labelWeekNumberHeader: wt, labelYearDropdown: vt } = s, Ot = Ce(() => Do(r, t.ISOWeek), [r, t.ISOWeek]), $e = f !== void 0 || p !== void 0, ve = H(() => {
    j && (J(j), k?.(j));
  }, [j, J, k]), Oe = H(() => {
    z && (J(z), W?.(z));
  }, [J, z, W]), gt = H((v, E) => (C) => {
    C.preventDefault(), C.stopPropagation(), he(v), we?.(v.date, E, C), p?.(v.date, E, C);
  }, [we, p, he]), _t = H((v, E) => (C) => {
    he(v), w?.(v.date, E, C);
  }, [w, he]), Ct = H((v, E) => (C) => {
    Be(), u?.(v.date, E, C);
  }, [Be, u]), Wt = H((v, E) => (C) => {
    const te = {
      ArrowLeft: [
        C.shiftKey ? "month" : "day",
        t.dir === "rtl" ? "after" : "before"
      ],
      ArrowRight: [
        C.shiftKey ? "month" : "day",
        t.dir === "rtl" ? "before" : "after"
      ],
      ArrowDown: [C.shiftKey ? "year" : "week", "after"],
      ArrowUp: [C.shiftKey ? "year" : "week", "before"],
      PageUp: [C.shiftKey ? "year" : "month", "before"],
      PageDown: [C.shiftKey ? "year" : "month", "after"],
      Home: ["startOfWeek", "before"],
      End: ["endOfWeek", "after"]
    };
    if (te[C.key]) {
      C.preventDefault(), C.stopPropagation();
      const [q, me] = te[C.key];
      Fe(q, me);
    }
    g?.(v.date, E, C);
  }, [Fe, g, t.dir]), Nt = H((v, E) => (C) => {
    D?.(v.date, E, C);
  }, [D]), St = H((v, E) => (C) => {
    O?.(v.date, E, C);
  }, [O]), Et = H((v) => (E) => {
    const C = Number(E.target.value), te = r.setMonth(r.startOfMonth(v), C);
    J(te);
  }, [r, J]), Tt = H((v) => (E) => {
    const C = Number(E.target.value), te = r.setYear(r.startOfMonth(v), C);
    J(te);
  }, [r, J]), { className: Yt, style: Bt } = Ce(() => ({
    className: [a[m.Root], t.className].filter(Boolean).join(" "),
    style: { ...y?.[m.Root], ...t.style }
  }), [a, t.className, t.style, y]), xt = ao(t), Pe = ye(null);
  Io(Pe, !!t.animate, {
    classNames: a,
    months: re,
    focused: xe,
    dateLib: r
  });
  const Ft = {
    dayPickerProps: t,
    selected: ue,
    select: we,
    isSelected: be,
    months: re,
    nextMonth: z,
    previousMonth: j,
    goToMonth: J,
    getModifiers: De,
    components: o,
    classNames: a,
    styles: y,
    labels: s,
    formatters: n
  };
  return d.createElement(
    rt.Provider,
    { value: Ft },
    d.createElement(
      o.Root,
      { rootRef: t.animate ? Pe : void 0, className: Yt, style: Bt, dir: t.dir, id: t.id, lang: t.lang, nonce: t.nonce, title: t.title, role: t.role, "aria-label": t["aria-label"], ...xt },
      d.createElement(
        o.Months,
        { className: a[m.Months], style: y?.[m.Months] },
        !t.hideNavigation && !h && d.createElement(o.Nav, { "data-animated-nav": t.animate ? "true" : void 0, className: a[m.Nav], style: y?.[m.Nav], "aria-label": Ie(), onPreviousClick: ve, onNextClick: Oe, previousMonth: j, nextMonth: z }),
        re.map((v, E) => {
          const C = ko(v.date, de, Me, n, r), te = bo(de, Me, n, r);
          return d.createElement(
            o.Month,
            { "data-animated-month": t.animate ? "true" : void 0, className: a[m.Month], style: y?.[m.Month], key: E, displayIndex: E, calendarMonth: v },
            h === "around" && !t.hideNavigation && E === 0 && d.createElement(
              o.PreviousMonthButton,
              { type: "button", className: a[m.PreviousMonthButton], tabIndex: j ? void 0 : -1, "aria-disabled": j ? void 0 : !0, "aria-label": kt(j), onClick: ve, "data-animated-button": t.animate ? "true" : void 0 },
              d.createElement(o.Chevron, { disabled: j ? void 0 : !0, className: a[m.Chevron], orientation: t.dir === "rtl" ? "right" : "left" })
            ),
            d.createElement(o.MonthCaption, { "data-animated-caption": t.animate ? "true" : void 0, className: a[m.MonthCaption], style: y?.[m.MonthCaption], calendarMonth: v, displayIndex: E }, c?.startsWith("dropdown") ? d.createElement(
              o.DropdownNav,
              { className: a[m.Dropdowns], style: y?.[m.Dropdowns] },
              c === "dropdown" || c === "dropdown-months" ? d.createElement(o.MonthsDropdown, { className: a[m.MonthsDropdown], "aria-label": pt(), classNames: a, components: o, disabled: !!t.disableNavigation, onChange: Et(v.date), options: C, style: y?.[m.Dropdown], value: r.getMonth(v.date) }) : d.createElement("span", null, _(v.date, r)),
              c === "dropdown" || c === "dropdown-years" ? d.createElement(o.YearsDropdown, { className: a[m.YearsDropdown], "aria-label": vt(r.options), classNames: a, components: o, disabled: !!t.disableNavigation, onChange: Tt(v.date), options: te, style: y?.[m.Dropdown], value: r.getYear(v.date) }) : d.createElement("span", null, Z(v.date, r)),
              d.createElement("span", { role: "status", "aria-live": "polite", style: {
                border: 0,
                clip: "rect(0 0 0 0)",
                height: "1px",
                margin: "-1px",
                overflow: "hidden",
                padding: 0,
                position: "absolute",
                width: "1px",
                whiteSpace: "nowrap",
                wordWrap: "normal"
              } }, b(v.date, r.options, r))
            ) : d.createElement(o.CaptionLabel, { className: a[m.CaptionLabel], role: "status", "aria-live": "polite" }, b(v.date, r.options, r))),
            h === "around" && !t.hideNavigation && E === l - 1 && d.createElement(
              o.NextMonthButton,
              { type: "button", className: a[m.NextMonthButton], tabIndex: z ? void 0 : -1, "aria-disabled": z ? void 0 : !0, "aria-label": Mt(z), onClick: Oe, "data-animated-button": t.animate ? "true" : void 0 },
              d.createElement(o.Chevron, { disabled: z ? void 0 : !0, className: a[m.Chevron], orientation: t.dir === "rtl" ? "left" : "right" })
            ),
            E === l - 1 && h === "after" && !t.hideNavigation && d.createElement(o.Nav, { "data-animated-nav": t.animate ? "true" : void 0, className: a[m.Nav], style: y?.[m.Nav], "aria-label": Ie(), onPreviousClick: ve, onNextClick: Oe, previousMonth: j, nextMonth: z }),
            d.createElement(
              o.MonthGrid,
              { role: "grid", "aria-multiselectable": f === "multiple" || f === "range", "aria-label": yt(v.date, r.options, r) || void 0, className: a[m.MonthGrid], style: y?.[m.MonthGrid] },
              !t.hideWeekdays && d.createElement(
                o.Weekdays,
                { "data-animated-weekdays": t.animate ? "true" : void 0, className: a[m.Weekdays], style: y?.[m.Weekdays] },
                S && d.createElement(o.WeekNumberHeader, { "aria-label": wt(r.options), className: a[m.WeekNumberHeader], style: y?.[m.WeekNumberHeader], scope: "col" }, $()),
                Ot.map((q, me) => d.createElement(o.Weekday, { "aria-label": Dt(q, r.options, r), className: a[m.Weekday], key: me, style: y?.[m.Weekday], scope: "col" }, P(q, r.options, r)))
              ),
              d.createElement(o.Weeks, { "data-animated-weeks": t.animate ? "true" : void 0, className: a[m.Weeks], style: y?.[m.Weeks] }, v.weeks.map((q, me) => d.createElement(
                o.Week,
                { className: a[m.Week], key: q.weekNumber, style: y?.[m.Week], week: q },
                S && d.createElement(o.WeekNumber, { week: q, style: y?.[m.WeekNumber], "aria-label": bt(q.weekNumber, {
                  locale: i
                }), className: a[m.WeekNumber], scope: "row", role: "rowheader" }, Y(q.weekNumber, r)),
                q.days.map((B) => {
                  const { date: U } = B, N = De(B);
                  if (N[T.focused] = !N.hidden && !!xe?.isEqualTo(B), N[R.selected] = be?.(U) || N.selected, Ye(ue)) {
                    const { from: ge, to: _e } = ue;
                    N[R.range_start] = !!(ge && _e && r.isSameDay(U, ge)), N[R.range_end] = !!(ge && _e && r.isSameDay(U, _e)), N[R.range_middle] = Q(ue, U, !0, r);
                  }
                  const It = Mo(N, y, t.modifiersStyles), $t = Tn(N, a, t.modifiersClassNames), Pt = !$e && !N.hidden ? mt(U, N, r.options, r) : void 0;
                  return d.createElement(o.Day, { key: `${r.format(U, "yyyy-MM-dd")}_${r.format(B.displayMonth, "yyyy-MM")}`, day: B, modifiers: N, className: $t.join(" "), style: It, role: "gridcell", "aria-selected": N.selected || void 0, "aria-label": Pt, "data-day": r.format(U, "yyyy-MM-dd"), "data-month": B.outside ? r.format(U, "yyyy-MM") : void 0, "data-selected": N.selected || void 0, "data-disabled": N.disabled || void 0, "data-hidden": N.hidden || void 0, "data-outside": B.outside || void 0, "data-focused": N.focused || void 0, "data-today": N.today || void 0 }, !N.hidden && $e ? d.createElement(o.DayButton, { className: a[m.DayButton], style: y?.[m.DayButton], type: "button", day: B, modifiers: N, disabled: N.disabled || void 0, tabIndex: ut(B) ? 0 : -1, "aria-label": ht(U, N, r.options, r), onClick: gt(B, N), onBlur: Ct(B, N), onFocus: _t(B, N), onKeyDown: Wt(B, N), onMouseEnter: Nt(B, N), onMouseLeave: St(B, N) }, M(U, r.options, r)) : !N.hidden && M(B.date, r.options, r));
                })
              )))
            )
          );
        })
      ),
      t.footer && d.createElement(o.Footer, { className: a[m.Footer], style: y?.[m.Footer], role: "status", "aria-live": "polite" }, t.footer)
    )
  );
}
const os = "_root_bdmmk_3", ss = "_months_bdmmk_88", rs = "_month_bdmmk_88", as = "_day_button_bdmmk_96", is = "_day_bdmmk_96", cs = "_selected_bdmmk_105", fs = "_month_caption_bdmmk_111", ls = "_dropdown_root_bdmmk_120", ds = "_weekday_bdmmk_124", us = "_week_number_bdmmk_125", hs = "_range_middle_bdmmk_135", ms = "_disabled_bdmmk_144", ys = "_outside_bdmmk_153", ps = "_button_next_bdmmk_161", ks = "_button_previous_bdmmk_162", x = {
  root: os,
  months: ss,
  month: rs,
  day_button: as,
  day: is,
  selected: cs,
  month_caption: fs,
  dropdown_root: ls,
  weekday: ds,
  week_number: us,
  range_middle: hs,
  disabled: ms,
  outside: ys,
  button_next: ps,
  button_previous: ks
}, Ms = (e) => {
  const { firstElementRef: t, ...o } = e, n = at(), s = {
    ...x,
    root: `${n.root} ${x.root}`,
    day_button: `${n.day_button} ${x.day_button}`,
    day: `${n.day} ${x.day}`,
    weekday: `${n.weekday} ${x.weekday}`,
    week_number: `${n.week_number} ${x.week_number}`,
    month_caption: `${n.month_caption} ${x.month_caption}`,
    disabled: `${n.disabled} ${x.disabled}`,
    dropdown: `${n.dropdown} ${x.dropdown}`,
    years_dropdown: `${n.years_dropdown} ${x.years_dropdown}`,
    outside: `${n.outside} ${x.outside}`,
    dropdown_root: `${n.dropdown_root} ${x.dropdown_root}`,
    months: `${n.months} ${x.months}`,
    month: `${n.month} ${x.month}`,
    button_next: `${n.button_next} ${x.button_next}`,
    button_previous: `${n.button_previous} ${x.button_previous}`
  }, r = (/* @__PURE__ */ new Date()).getFullYear() - 10, i = (/* @__PURE__ */ new Date()).getFullYear() + 10, [a, c] = pe();
  return Ue(() => {
    o.mode === "single" && o.selected instanceof Date ? c(o.selected) : o.mode === "range" && o.selected && typeof o.selected == "object" && "from" in o.selected && o.selected.from instanceof Date && c(o.selected.from);
  }, [o.selected, o.mode]), /* @__PURE__ */ ae(
    ns,
    {
      weekStartsOn: 1,
      captionLayout: "dropdown-years",
      startMonth: new Date(r, 0),
      endMonth: new Date(i, 11),
      ...o,
      month: a,
      onMonthChange: c,
      classNames: s,
      navLayout: "around",
      components: {
        PreviousMonthButton: (f) => /* @__PURE__ */ ae(Ae, { ref: t, variant: "text", size: "sm", iconOnly: !0, ...f, children: /* @__PURE__ */ ae(jt, { size: "sm" }) }),
        NextMonthButton: (f) => /* @__PURE__ */ ae(Ae, { variant: "text", size: "sm", iconOnly: !0, ...f, children: /* @__PURE__ */ ae(zt, { size: "sm" }) })
      }
    }
  );
};
Ms.displayName = "Calendar";
export {
  Ms as C
};
//# sourceMappingURL=calendar-DDie8jSH.mjs.map
