import { o as Wn, r as Ue } from "./rolldown-runtime.js";
import { i as _n, n as Tn, t as En } from "./vendor/react.js";
import { _ as ie, a as Dt, c as Yn, d as jn, f as kt, g as te, h as Bn, i as de, l as Pn, m as In, n as Mt, o as Fn, p as An, r as wt, s as $n, t as F, u as xt } from "./format.js";
import { a as Nt, i as zn, n as Hn, r as Ot, t as Rn } from "./isSameMonth.js";
import { t as Zn } from "./isBefore.js";
import { t as Ke } from "./calendar.js";
import { t as Re } from "./chevron-left.js";
import { t as Ze } from "./chevron-right.js";
import { t as qn } from "./clock.js";
import { t as fe } from "./Button.js";
import { t as j } from "./utils.js";
import { n as Me, r as we, t as xe } from "./popover2.js";
function Gn(e, t, n) {
  return Nt(e, t * 12, n);
}
function Un(e, t) {
  let n, o = t?.in;
  return e.forEach((r) => {
    !o && typeof r == "object" && (o = ie.bind(null, r));
    const s = te(r, o);
    (!n || n < s || isNaN(+s)) && (n = s);
  }), ie(o, n || NaN);
}
function Kn(e, t) {
  let n, o = t?.in;
  return e.forEach((r) => {
    !o && typeof r == "object" && (o = ie.bind(null, r));
    const s = te(r, o);
    (!n || n > s || isNaN(+s)) && (n = s);
  }), ie(o, n || NaN);
}
function Ct(e, t, n) {
  const [o, r] = kt(n?.in, e, t), s = o.getFullYear() - r.getFullYear(), i = o.getMonth() - r.getMonth();
  return s * 12 + i;
}
function Vn(e, t) {
  const { start: n, end: o } = Ot(t?.in, e);
  let r = +n > +o;
  const s = r ? +n : +o, i = r ? o : n;
  i.setHours(0, 0, 0, 0), i.setDate(1);
  let a = t?.step ?? 1;
  if (!a) return [];
  a < 0 && (a = -a, r = !r);
  const l = [];
  for (; +i <= s; )
    l.push(ie(n, i)), i.setMonth(i.getMonth() + a);
  return r ? l.reverse() : l;
}
function Jn(e, t) {
  const n = te(e, t?.in), o = n.getFullYear();
  return n.setFullYear(o + 1, 0, 0), n.setHours(23, 59, 59, 999), n;
}
function Xn(e, t) {
  const { start: n, end: o } = Ot(t?.in, e);
  let r = +n > +o;
  const s = r ? +n : +o, i = r ? o : n;
  i.setHours(0, 0, 0, 0), i.setMonth(0, 1);
  let a = t?.step ?? 1;
  if (!a) return [];
  a < 0 && (a = -a, r = !r);
  const l = [];
  for (; +i <= s; )
    l.push(ie(n, i)), i.setFullYear(i.getFullYear() + a);
  return r ? l.reverse() : l;
}
function Qn(e, t) {
  return Dt(e, {
    ...t,
    weekStartsOn: 1
  });
}
function Ln(e, t) {
  const n = te(e, t?.in), o = n.getFullYear(), r = n.getMonth(), s = ie(n, 0);
  return s.setFullYear(o, r + 1, 0), s.setHours(0, 0, 0, 0), s.getDate();
}
function eo(e, t) {
  return te(e, t?.in).getMonth();
}
function to(e, t) {
  return te(e, t?.in).getFullYear();
}
function no(e, t) {
  return +te(e) > +te(t);
}
function oo(e, t, n) {
  const [o, r] = kt(n?.in, e, t);
  return o.getFullYear() === r.getFullYear();
}
function ro(e, t, n) {
  const o = te(e, n?.in), r = o.getFullYear(), s = o.getDate(), i = ie(n?.in || e, 0);
  i.setFullYear(r, t, 15), i.setHours(0, 0, 0, 0);
  const a = Ln(i);
  return o.setMonth(t, Math.min(s, a)), o;
}
function so(e, t, n) {
  const o = te(e, n?.in);
  return isNaN(+o) ? ie(n?.in || e, NaN) : (o.setFullYear(t), o);
}
function ao(e, t, n = "long") {
  return new Intl.DateTimeFormat("en-US", {
    hour: "numeric",
    timeZone: e,
    timeZoneName: n
  }).format(t).split(/\s/g).slice(2).join(" ");
}
var io = {}, ue = {};
function le(e, t) {
  try {
    const n = (io[e] ||= new Intl.DateTimeFormat("en-US", {
      timeZone: e,
      timeZoneName: "longOffset"
    }).format)(t).split("GMT")[1];
    return n in ue ? ue[n] : ft(n, n.split(":"));
  } catch {
    if (e in ue) return ue[e];
    const n = e?.match(lo);
    return n ? ft(e, n.slice(1)) : NaN;
  }
}
var lo = /([+-]\d\d):?(\d\d)?/;
function ft(e, t) {
  const n = +(t[0] || 0), o = +(t[1] || 0), r = +(t[2] || 0) / 60;
  return ue[e] = n * 60 + o > 0 ? n * 60 + o + r : n * 60 - o - r;
}
var he = class me extends Date {
  constructor(...t) {
    super(), t.length > 1 && typeof t[t.length - 1] == "string" && (this.timeZone = t.pop()), this.internal = /* @__PURE__ */ new Date(), isNaN(le(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)), St(this, NaN), qe(this)) : this.setTime(Date.now());
  }
  static tz(t, ...n) {
    return n.length ? new me(...n, t) : new me(Date.now(), t);
  }
  withTimeZone(t) {
    return new me(+this, t);
  }
  getTimezoneOffset() {
    const t = -le(this.timeZone, this);
    return t > 0 ? Math.floor(t) : Math.ceil(t);
  }
  setTime(t) {
    return Date.prototype.setTime.apply(this, arguments), qe(this), +this;
  }
  [/* @__PURE__ */ Symbol.for("constructDateFrom")](t) {
    return new me(+new Date(t), this.timeZone);
  }
}, dt = /^(get|set)(?!UTC)/;
Object.getOwnPropertyNames(Date.prototype).forEach((e) => {
  if (!dt.test(e)) return;
  const t = e.replace(dt, "$1UTC");
  he.prototype[t] && (e.startsWith("get") ? he.prototype[e] = function() {
    return this.internal[t]();
  } : (he.prototype[e] = function() {
    return Date.prototype[t].apply(this.internal, arguments), co(this), +this;
  }, he.prototype[t] = function() {
    return Date.prototype[t].apply(this, arguments), qe(this), +this;
  }));
});
function qe(e) {
  e.internal.setTime(+e), e.internal.setUTCSeconds(e.internal.getUTCSeconds() - Math.round(-le(e.timeZone, e) * 60));
}
function co(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()), St(e);
}
function St(e) {
  const t = le(e.timeZone, e), n = t > 0 ? Math.floor(t) : Math.ceil(t), o = /* @__PURE__ */ new Date(+e);
  o.setUTCHours(o.getUTCHours() - 1);
  const r = -(/* @__PURE__ */ new Date(+e)).getTimezoneOffset(), s = r - -(/* @__PURE__ */ new Date(+o)).getTimezoneOffset(), i = Date.prototype.getHours.apply(e) !== e.internal.getUTCHours();
  s && i && e.internal.setUTCMinutes(e.internal.getUTCMinutes() + s);
  const a = r - n;
  a && Date.prototype.setUTCMinutes.call(e, Date.prototype.getUTCMinutes.call(e) + a);
  const l = /* @__PURE__ */ new Date(+e);
  l.setUTCSeconds(0);
  const f = r > 0 ? l.getSeconds() : (l.getSeconds() - 60) % 60, u = Math.round(-(le(e.timeZone, e) * 60)) % 60;
  (u || f) && (e.internal.setUTCSeconds(e.internal.getUTCSeconds() + u), Date.prototype.setUTCSeconds.call(e, Date.prototype.getUTCSeconds.call(e) + u + f));
  const d = le(e.timeZone, e), g = d > 0 ? Math.floor(d) : Math.ceil(d), h = -(/* @__PURE__ */ new Date(+e)).getTimezoneOffset() - g, p = g !== n, D = h - a;
  if (p && D) {
    Date.prototype.setUTCMinutes.call(e, Date.prototype.getUTCMinutes.call(e) + D);
    const b = le(e.timeZone, e), C = g - (b > 0 ? Math.floor(b) : Math.ceil(b));
    C && (e.internal.setUTCMinutes(e.internal.getUTCMinutes() + C), Date.prototype.setUTCMinutes.call(e, Date.prototype.getUTCMinutes.call(e) + C));
  }
}
var V = class ye extends he {
  static tz(t, ...n) {
    return n.length ? new ye(...n, t) : new ye(Date.now(), t);
  }
  toISOString() {
    const [t, n, o] = this.tzComponents(), r = `${t}${n}:${o}`;
    return this.internal.toISOString().slice(0, -1) + r;
  }
  toString() {
    return `${this.toDateString()} ${this.toTimeString()}`;
  }
  toDateString() {
    const [t, n, o, r] = this.internal.toUTCString().split(" ");
    return `${t?.slice(0, -1)} ${o} ${n} ${r}`;
  }
  toTimeString() {
    const t = this.internal.toUTCString().split(" ")[4], [n, o, r] = this.tzComponents();
    return `${t} GMT${n}${o}${r} (${ao(this.timeZone, this)})`;
  }
  toLocaleString(t, n) {
    return Date.prototype.toLocaleString.call(this, t, {
      ...n,
      timeZone: n?.timeZone || this.timeZone
    });
  }
  toLocaleDateString(t, n) {
    return Date.prototype.toLocaleDateString.call(this, t, {
      ...n,
      timeZone: n?.timeZone || this.timeZone
    });
  }
  toLocaleTimeString(t, n) {
    return Date.prototype.toLocaleTimeString.call(this, t, {
      ...n,
      timeZone: n?.timeZone || this.timeZone
    });
  }
  tzComponents() {
    const t = this.getTimezoneOffset();
    return [
      t > 0 ? "-" : "+",
      String(Math.floor(Math.abs(t) / 60)).padStart(2, "0"),
      String(Math.abs(t) % 60).padStart(2, "0")
    ];
  }
  withTimeZone(t) {
    return new ye(+this, t);
  }
  [/* @__PURE__ */ Symbol.for("constructDateFrom")](t) {
    return new ye(+new Date(t), this.timeZone);
  }
}, ut = 5, fo = 4;
function uo(e, t) {
  const n = t.startOfMonth(e), o = n.getDay() > 0 ? n.getDay() : 7, r = t.addDays(e, -o + 1), s = t.addDays(r, ut * 7 - 1);
  return t.getMonth(e) === t.getMonth(s) ? ut : fo;
}
function Wt(e, t) {
  const n = t.startOfMonth(e), o = n.getDay();
  return o === 1 ? n : o === 0 ? t.addDays(n, -6) : t.addDays(n, -1 * (o - 1));
}
function ho(e, t) {
  const n = Wt(e, t), o = uo(e, t);
  return t.addDays(n, o * 7 - 1);
}
var _t = {
  ...de,
  labels: {
    labelDayButton: (e, t, n, o) => {
      let r;
      o && typeof o.format == "function" ? r = o.format.bind(o) : r = (i, a) => F(i, a, {
        locale: de,
        ...n
      });
      let s = r(e, "PPPP");
      return t.today && (s = `Today, ${s}`), t.selected && (s = `${s}, selected`), s;
    },
    labelMonthDropdown: "Choose the Month",
    labelNext: "Go to the Next Month",
    labelPrevious: "Go to the Previous Month",
    labelWeekNumber: (e) => `Week ${e}`,
    labelYearDropdown: "Choose the Year",
    labelGrid: (e, t, n) => {
      let o;
      return n && typeof n.format == "function" ? o = n.format.bind(n) : o = (r, s) => F(r, s, {
        locale: de,
        ...t
      }), o(e, "LLLL yyyy");
    },
    labelGridcell: (e, t, n, o) => {
      let r;
      o && typeof o.format == "function" ? r = o.format.bind(o) : r = (i, a) => F(i, a, {
        locale: de,
        ...n
      });
      let s = r(e, "PPPP");
      return t?.today && (s = `Today, ${s}`), s;
    },
    labelNav: "Navigation bar",
    labelWeekNumberHeader: "Week Number",
    labelWeekday: (e, t, n) => {
      let o;
      return n && typeof n.format == "function" ? o = n.format.bind(n) : o = (r, s) => F(r, s, {
        locale: de,
        ...t
      }), o(e, "cccc");
    }
  }
}, ne = class Ge {
  constructor(t, n) {
    this.Date = Date, this.today = () => this.overrides?.today ? this.overrides.today() : this.options.timeZone ? V.tz(this.options.timeZone) : new this.Date(), this.newDate = (o, r, s) => this.overrides?.newDate ? this.overrides.newDate(o, r, s) : this.options.timeZone ? new V(o, r, s, this.options.timeZone) : new Date(o, r, s), this.addDays = (o, r) => this.overrides?.addDays ? this.overrides.addDays(o, r) : Bn(o, r), this.addMonths = (o, r) => this.overrides?.addMonths ? this.overrides.addMonths(o, r) : Nt(o, r), this.addWeeks = (o, r) => this.overrides?.addWeeks ? this.overrides.addWeeks(o, r) : Pn(o, r), this.addYears = (o, r) => this.overrides?.addYears ? this.overrides.addYears(o, r) : Gn(o, r), this.differenceInCalendarDays = (o, r) => this.overrides?.differenceInCalendarDays ? this.overrides.differenceInCalendarDays(o, r) : xt(o, r), this.differenceInCalendarMonths = (o, r) => this.overrides?.differenceInCalendarMonths ? this.overrides.differenceInCalendarMonths(o, r) : Ct(o, r), this.eachMonthOfInterval = (o) => this.overrides?.eachMonthOfInterval ? this.overrides.eachMonthOfInterval(o) : Vn(o), this.eachYearOfInterval = (o) => {
      const r = this.overrides?.eachYearOfInterval ? this.overrides.eachYearOfInterval(o) : Xn(o), s = new Set(r.map((a) => this.getYear(a)));
      if (s.size === r.length) return r;
      const i = [];
      return s.forEach((a) => {
        i.push(new Date(a, 0, 1));
      }), i;
    }, this.endOfBroadcastWeek = (o) => this.overrides?.endOfBroadcastWeek ? this.overrides.endOfBroadcastWeek(o) : ho(o, this), this.endOfISOWeek = (o) => this.overrides?.endOfISOWeek ? this.overrides.endOfISOWeek(o) : Qn(o), this.endOfMonth = (o) => this.overrides?.endOfMonth ? this.overrides.endOfMonth(o) : zn(o), this.endOfWeek = (o, r) => this.overrides?.endOfWeek ? this.overrides.endOfWeek(o, r) : Dt(o, this.options), this.endOfYear = (o) => this.overrides?.endOfYear ? this.overrides.endOfYear(o) : Jn(o), this.format = (o, r, s) => {
      const i = this.overrides?.format ? this.overrides.format(o, r, this.options) : F(o, r, this.options);
      return this.options.numerals && this.options.numerals !== "latn" ? this.replaceDigits(i) : i;
    }, this.getISOWeek = (o) => this.overrides?.getISOWeek ? this.overrides.getISOWeek(o) : wt(o), this.getMonth = (o, r) => this.overrides?.getMonth ? this.overrides.getMonth(o, this.options) : eo(o, this.options), this.getYear = (o, r) => this.overrides?.getYear ? this.overrides.getYear(o, this.options) : to(o, this.options), this.getWeek = (o, r) => this.overrides?.getWeek ? this.overrides.getWeek(o, this.options) : Mt(o, this.options), this.isAfter = (o, r) => this.overrides?.isAfter ? this.overrides.isAfter(o, r) : no(o, r), this.isBefore = (o, r) => this.overrides?.isBefore ? this.overrides.isBefore(o, r) : Zn(o, r), this.isDate = (o) => this.overrides?.isDate ? this.overrides.isDate(o) : $n(o), this.isSameDay = (o, r) => this.overrides?.isSameDay ? this.overrides.isSameDay(o, r) : Yn(o, r), this.isSameMonth = (o, r) => this.overrides?.isSameMonth ? this.overrides.isSameMonth(o, r) : Rn(o, r), this.isSameYear = (o, r) => this.overrides?.isSameYear ? this.overrides.isSameYear(o, r) : oo(o, r), this.max = (o) => this.overrides?.max ? this.overrides.max(o) : Un(o), this.min = (o) => this.overrides?.min ? this.overrides.min(o) : Kn(o), this.setMonth = (o, r) => this.overrides?.setMonth ? this.overrides.setMonth(o, r) : ro(o, r), this.setYear = (o, r) => this.overrides?.setYear ? this.overrides.setYear(o, r) : so(o, r), this.startOfBroadcastWeek = (o, r) => this.overrides?.startOfBroadcastWeek ? this.overrides.startOfBroadcastWeek(o, this) : Wt(o, this), this.startOfDay = (o) => this.overrides?.startOfDay ? this.overrides.startOfDay(o) : jn(o), this.startOfISOWeek = (o) => this.overrides?.startOfISOWeek ? this.overrides.startOfISOWeek(o) : An(o), this.startOfMonth = (o) => this.overrides?.startOfMonth ? this.overrides.startOfMonth(o) : Hn(o), this.startOfWeek = (o, r) => this.overrides?.startOfWeek ? this.overrides.startOfWeek(o, this.options) : In(o, this.options), this.startOfYear = (o) => this.overrides?.startOfYear ? this.overrides.startOfYear(o) : Fn(o), this.options = {
      locale: _t,
      ...t
    }, this.overrides = n;
  }
  getDigitMap() {
    const { numerals: t = "latn" } = this.options, n = new Intl.NumberFormat("en-US", { numberingSystem: t }), o = {};
    for (let r = 0; r < 10; r++) o[r.toString()] = n.format(r);
    return o;
  }
  replaceDigits(t) {
    const n = this.getDigitMap();
    return t.replace(/\d/g, (o) => n[o] || o);
  }
  formatNumber(t) {
    return this.replaceDigits(t.toString());
  }
  getMonthYearOrder() {
    const t = this.options.locale?.code;
    return t && Ge.yearFirstLocales.has(t) ? "year-first" : "month-first";
  }
  formatMonthYear(t) {
    const { locale: n, timeZone: o, numerals: r } = this.options, s = n?.code;
    if (s && Ge.yearFirstLocales.has(s)) try {
      return new Intl.DateTimeFormat(s, {
        month: "long",
        year: "numeric",
        timeZone: o,
        numberingSystem: r
      }).format(t);
    } catch {
    }
    const i = this.getMonthYearOrder() === "year-first" ? "y LLLL" : "LLLL y";
    return this.format(t, i);
  }
};
ne.yearFirstLocales = /* @__PURE__ */ new Set([
  "eu",
  "hu",
  "ja",
  "ja-Hira",
  "ja-JP",
  "ko",
  "ko-KR",
  "lt",
  "lt-LT",
  "lv",
  "lv-LV",
  "mn",
  "mn-MN",
  "zh",
  "zh-CN",
  "zh-HK",
  "zh-TW"
]);
var oe = new ne(), Tt = class {
  constructor(e, t, n = oe) {
    this.date = e, this.displayMonth = t, this.outside = !!(t && !n.isSameMonth(e, t)), this.dateLib = n, this.isoDate = n.format(e, "yyyy-MM-dd"), this.displayMonthId = n.format(t, "yyyy-MM"), this.dateMonthId = n.format(e, "yyyy-MM");
  }
  isEqualTo(e) {
    return this.dateLib.isSameDay(e.date, this.date) && this.dateLib.isSameMonth(e.displayMonth, this.displayMonth);
  }
}, mo = class {
  constructor(e, t) {
    this.date = e, this.weeks = t;
  }
}, yo = class {
  constructor(e, t) {
    this.days = t, this.weekNumber = e;
  }
}, c = /* @__PURE__ */ Wn(_n(), 1);
function po(e) {
  return c.createElement("button", { ...e });
}
function bo(e) {
  return c.createElement("span", { ...e });
}
function go(e) {
  const { size: t = 24, orientation: n = "left", className: o } = e;
  return c.createElement("svg", {
    className: o,
    width: t,
    height: t,
    viewBox: "0 0 24 24"
  }, n === "up" && c.createElement("polygon", { points: "6.77 17 12.5 11.43 18.24 17 20 15.28 12.5 8 5 15.28" }), n === "down" && c.createElement("polygon", { points: "6.77 8 12.5 13.57 18.24 8 20 9.72 12.5 17 5 9.72" }), n === "left" && c.createElement("polygon", { points: "16 18.112 9.81111111 12 16 5.87733333 14.0888889 4 6 12 14.0888889 20" }), n === "right" && c.createElement("polygon", { points: "8 18.112 14.18888889 12 8 5.87733333 9.91111111 4 18 12 9.91111111 20" }));
}
function vo(e) {
  const { day: t, modifiers: n, ...o } = e;
  return c.createElement("td", { ...o });
}
function Do(e) {
  const { day: t, modifiers: n, ...o } = e, r = c.useRef(null);
  return c.useEffect(() => {
    n.focused && r.current?.focus();
  }, [n.focused]), c.createElement("button", {
    ref: r,
    ...o
  });
}
var v;
(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";
})(v || (v = {}));
var I;
(function(e) {
  e.disabled = "disabled", e.hidden = "hidden", e.outside = "outside", e.focused = "focused", e.today = "today";
})(I || (I = {}));
var L;
(function(e) {
  e.range_end = "range_end", e.range_middle = "range_middle", e.range_start = "range_start", e.selected = "selected";
})(L || (L = {}));
var U;
(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";
})(U || (U = {}));
function ko(e) {
  const { options: t, className: n, components: o, classNames: r, ...s } = e, i = [r[v.Dropdown], n].join(" "), a = t?.find(({ value: l }) => l === s.value);
  return c.createElement("span", {
    "data-disabled": s.disabled,
    className: r[v.DropdownRoot]
  }, c.createElement(o.Select, {
    className: i,
    ...s
  }, t?.map(({ value: l, label: f, disabled: u }) => c.createElement(o.Option, {
    key: l,
    value: l,
    disabled: u
  }, f))), c.createElement("span", {
    className: r[v.CaptionLabel],
    "aria-hidden": !0
  }, a?.label, c.createElement(o.Chevron, {
    orientation: "down",
    size: 18,
    className: r[v.Chevron]
  })));
}
function Mo(e) {
  return c.createElement("div", { ...e });
}
function wo(e) {
  return c.createElement("div", { ...e });
}
function xo(e) {
  const { calendarMonth: t, displayIndex: n, ...o } = e;
  return c.createElement("div", { ...o }, e.children);
}
function No(e) {
  const { calendarMonth: t, displayIndex: n, ...o } = e;
  return c.createElement("div", { ...o });
}
function Oo(e) {
  return c.createElement("table", { ...e });
}
function Co(e) {
  return c.createElement("div", { ...e });
}
var Et = (0, c.createContext)(void 0);
function ge() {
  const e = (0, c.useContext)(Et);
  if (e === void 0) throw new Error("useDayPicker() must be used within a custom component.");
  return e;
}
function So(e) {
  const { components: t } = ge();
  return c.createElement(t.Dropdown, { ...e });
}
function Wo(e) {
  const { onPreviousClick: t, onNextClick: n, previousMonth: o, nextMonth: r, ...s } = e, { components: i, classNames: a, labels: { labelPrevious: l, labelNext: f } } = ge(), u = (0, c.useCallback)((g) => {
    r && n?.(g);
  }, [r, n]), d = (0, c.useCallback)((g) => {
    o && t?.(g);
  }, [o, t]);
  return c.createElement("nav", { ...s }, c.createElement(i.PreviousMonthButton, {
    type: "button",
    className: a[v.PreviousMonthButton],
    tabIndex: o ? void 0 : -1,
    "aria-disabled": o ? void 0 : !0,
    "aria-label": l(o),
    onClick: d
  }, c.createElement(i.Chevron, {
    disabled: o ? void 0 : !0,
    className: a[v.Chevron],
    orientation: "left"
  })), c.createElement(i.NextMonthButton, {
    type: "button",
    className: a[v.NextMonthButton],
    tabIndex: r ? void 0 : -1,
    "aria-disabled": r ? void 0 : !0,
    "aria-label": f(r),
    onClick: u
  }, c.createElement(i.Chevron, {
    disabled: r ? void 0 : !0,
    orientation: "right",
    className: a[v.Chevron]
  })));
}
function _o(e) {
  const { components: t } = ge();
  return c.createElement(t.Button, { ...e });
}
function To(e) {
  return c.createElement("option", { ...e });
}
function Eo(e) {
  const { components: t } = ge();
  return c.createElement(t.Button, { ...e });
}
function Yo(e) {
  const { rootRef: t, ...n } = e;
  return c.createElement("div", {
    ...n,
    ref: t
  });
}
function jo(e) {
  return c.createElement("select", { ...e });
}
function Bo(e) {
  const { week: t, ...n } = e;
  return c.createElement("tr", { ...n });
}
function Po(e) {
  return c.createElement("th", { ...e });
}
function Io(e) {
  return c.createElement("thead", { "aria-hidden": !0 }, c.createElement("tr", { ...e }));
}
function Fo(e) {
  const { week: t, ...n } = e;
  return c.createElement("th", { ...n });
}
function Ao(e) {
  return c.createElement("th", { ...e });
}
function $o(e) {
  return c.createElement("tbody", { ...e });
}
function zo(e) {
  const { components: t } = ge();
  return c.createElement(t.Dropdown, { ...e });
}
var Ho = /* @__PURE__ */ Ue({
  Button: () => po,
  CaptionLabel: () => bo,
  Chevron: () => go,
  Day: () => vo,
  DayButton: () => Do,
  Dropdown: () => ko,
  DropdownNav: () => Mo,
  Footer: () => wo,
  Month: () => xo,
  MonthCaption: () => No,
  MonthGrid: () => Oo,
  Months: () => Co,
  MonthsDropdown: () => So,
  Nav: () => Wo,
  NextMonthButton: () => _o,
  Option: () => To,
  PreviousMonthButton: () => Eo,
  Root: () => Yo,
  Select: () => jo,
  Week: () => Bo,
  WeekNumber: () => Fo,
  WeekNumberHeader: () => Ao,
  Weekday: () => Po,
  Weekdays: () => Io,
  Weeks: () => $o,
  YearsDropdown: () => zo
});
function se(e, t, n = !1, o = oe) {
  let { from: r, to: s } = e;
  const { differenceInCalendarDays: i, isSameDay: a } = o;
  return r && s ? (i(s, r) < 0 && ([r, s] = [s, r]), i(t, r) >= (n ? 1 : 0) && i(s, t) >= (n ? 1 : 0)) : !n && s ? a(s, t) : !n && r ? a(r, t) : !1;
}
function Ve(e) {
  return !!(e && typeof e == "object" && "before" in e && "after" in e);
}
function Ne(e) {
  return !!(e && typeof e == "object" && "from" in e);
}
function Je(e) {
  return !!(e && typeof e == "object" && "after" in e);
}
function Xe(e) {
  return !!(e && typeof e == "object" && "before" in e);
}
function Yt(e) {
  return !!(e && typeof e == "object" && "dayOfWeek" in e);
}
function jt(e, t) {
  return Array.isArray(e) && e.every(t.isDate);
}
function ae(e, t, n = oe) {
  const o = Array.isArray(t) ? t : [t], { isSameDay: r, differenceInCalendarDays: s, isAfter: i } = n;
  return o.some((a) => {
    if (typeof a == "boolean") return a;
    if (n.isDate(a)) return r(e, a);
    if (jt(a, n)) return a.some((l) => r(e, l));
    if (Ne(a)) return se(a, e, !1, n);
    if (Yt(a))
      return Array.isArray(a.dayOfWeek) ? a.dayOfWeek.includes(e.getDay()) : a.dayOfWeek === e.getDay();
    if (Ve(a)) {
      const l = s(a.before, e), f = s(a.after, e), u = l > 0, d = f < 0;
      return i(a.before, a.after) ? d && u : u || d;
    }
    return Je(a) ? s(e, a.after) > 0 : Xe(a) ? s(a.before, e) > 0 : typeof a == "function" ? a(e) : !1;
  });
}
function Ro(e, t, n, o, r) {
  const { disabled: s, hidden: i, modifiers: a, showOutsideDays: l, broadcastCalendar: f, today: u = r.today() } = t, { isSameDay: d, isSameMonth: g, startOfMonth: h, isBefore: p, endOfMonth: D, isAfter: b } = r, C = n && h(n), w = o && D(o), k = {
    [I.focused]: [],
    [I.outside]: [],
    [I.disabled]: [],
    [I.hidden]: [],
    [I.today]: []
  }, M = {};
  for (const S of e) {
    const { date: m, displayMonth: B } = S, Y = !!(B && !g(m, B)), P = !!(C && p(m, C)), R = !!(w && b(m, w)), A = !!(s && ae(m, s, r)), H = !!(i && ae(m, i, r)) || P || R || !f && !l && Y || f && l === !1 && Y, O = d(m, u);
    Y && k.outside.push(S), A && k.disabled.push(S), H && k.hidden.push(S), O && k.today.push(S), a && Object.keys(a).forEach((T) => {
      const $ = a?.[T];
      $ && ae(m, $, r) && (M[T] ? M[T].push(S) : M[T] = [S]);
    });
  }
  return (S) => {
    const m = {
      [I.focused]: !1,
      [I.disabled]: !1,
      [I.hidden]: !1,
      [I.outside]: !1,
      [I.today]: !1
    }, B = {};
    for (const Y in k) m[Y] = k[Y].some((P) => P === S);
    for (const Y in M) B[Y] = M[Y].some((P) => P === S);
    return {
      ...m,
      ...B
    };
  };
}
function Zo(e, t, n = {}) {
  return Object.entries(e).filter(([, o]) => o === !0).reduce((o, [r]) => (n[r] ? o.push(n[r]) : t[I[r]] ? o.push(t[I[r]]) : t[L[r]] && o.push(t[L[r]]), o), [t[v.Day]]);
}
function qo(e) {
  return {
    ...Ho,
    ...e
  };
}
function Go(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(([n, o]) => {
    n.startsWith("data-") && (t[n] = o);
  }), t;
}
function Bt() {
  const e = {};
  for (const t in v) e[v[t]] = `rdp-${v[t]}`;
  for (const t in I) e[I[t]] = `rdp-${I[t]}`;
  for (const t in L) e[L[t]] = `rdp-${L[t]}`;
  for (const t in U) e[U[t]] = `rdp-${U[t]}`;
  return e;
}
function Pt(e, t, n) {
  return (n ?? new ne(t)).formatMonthYear(e);
}
var Uo = Pt;
function Ko(e, t, n) {
  return (n ?? new ne(t)).format(e, "d");
}
function Vo(e, t = oe) {
  return t.format(e, "LLLL");
}
function Jo(e, t, n) {
  return (n ?? new ne(t)).format(e, "cccccc");
}
function Xo(e, t = oe) {
  return e < 10 ? t.formatNumber(`0${e.toLocaleString()}`) : t.formatNumber(`${e.toLocaleString()}`);
}
function Qo() {
  return "";
}
function It(e, t = oe) {
  return t.format(e, "yyyy");
}
var Lo = It, er = /* @__PURE__ */ Ue({
  formatCaption: () => Pt,
  formatDay: () => Ko,
  formatMonthCaption: () => Uo,
  formatMonthDropdown: () => Vo,
  formatWeekNumber: () => Xo,
  formatWeekNumberHeader: () => Qo,
  formatWeekdayName: () => Jo,
  formatYearCaption: () => Lo,
  formatYearDropdown: () => It
});
function tr(e) {
  return e?.formatMonthCaption && !e.formatCaption && (e.formatCaption = e.formatMonthCaption), e?.formatYearCaption && !e.formatYearDropdown && (e.formatYearDropdown = e.formatYearCaption), {
    ...er,
    ...e
  };
}
function Qe(e, t, n, o) {
  let r = (o ?? new ne(n)).format(e, "PPPP");
  return t.today && (r = `Today, ${r}`), t.selected && (r = `${r}, selected`), r;
}
var nr = Qe;
function Le(e, t, n) {
  return (n ?? new ne(t)).formatMonthYear(e);
}
var or = Le;
function Ft(e, t, n, o) {
  let r = (o ?? new ne(n)).format(e, "PPPP");
  return t?.today && (r = `Today, ${r}`), r;
}
function At(e) {
  return "Choose the Month";
}
function $t() {
  return "";
}
var rr = "Go to the Next Month";
function zt(e, t) {
  return rr;
}
function Ht(e) {
  return "Go to the Previous Month";
}
function Rt(e, t, n) {
  return (n ?? new ne(t)).format(e, "cccc");
}
function Zt(e, t) {
  return `Week ${e}`;
}
function qt(e) {
  return "Week Number";
}
function Gt(e) {
  return "Choose the Year";
}
var sr = /* @__PURE__ */ Ue({
  labelCaption: () => or,
  labelDay: () => nr,
  labelDayButton: () => Qe,
  labelGrid: () => Le,
  labelGridcell: () => Ft,
  labelMonthDropdown: () => At,
  labelNav: () => $t,
  labelNext: () => zt,
  labelPrevious: () => Ht,
  labelWeekNumber: () => Zt,
  labelWeekNumberHeader: () => qt,
  labelWeekday: () => Rt,
  labelYearDropdown: () => Gt
}), Q = (e, t, n) => t || (n ? typeof n == "function" ? n : (...o) => n : e);
function ar(e, t) {
  const n = t.locale?.labels ?? {};
  return {
    ...sr,
    ...e ?? {},
    labelDayButton: Q(Qe, e?.labelDayButton, n.labelDayButton),
    labelMonthDropdown: Q(At, e?.labelMonthDropdown, n.labelMonthDropdown),
    labelNext: Q(zt, e?.labelNext, n.labelNext),
    labelPrevious: Q(Ht, e?.labelPrevious, n.labelPrevious),
    labelWeekNumber: Q(Zt, e?.labelWeekNumber, n.labelWeekNumber),
    labelYearDropdown: Q(Gt, e?.labelYearDropdown, n.labelYearDropdown),
    labelGrid: Q(Le, e?.labelGrid, n.labelGrid),
    labelGridcell: Q(Ft, e?.labelGridcell, n.labelGridcell),
    labelNav: Q($t, e?.labelNav, n.labelNav),
    labelWeekNumberHeader: Q(qt, e?.labelWeekNumberHeader, n.labelWeekNumberHeader),
    labelWeekday: Q(Rt, e?.labelWeekday, n.labelWeekday)
  };
}
function ir(e, t, n, o, r) {
  const { startOfMonth: s, startOfYear: i, endOfYear: a, eachMonthOfInterval: l, getMonth: f } = r;
  return l({
    start: i(e),
    end: a(e)
  }).map((u) => {
    const d = o.formatMonthDropdown(u, r);
    return {
      value: f(u),
      label: d,
      disabled: t && u < s(t) || n && u > s(n) || !1
    };
  });
}
function lr(e, t = {}, n = {}) {
  let o = { ...t?.[v.Day] };
  return Object.entries(e).filter(([, r]) => r === !0).forEach(([r]) => {
    o = {
      ...o,
      ...n?.[r]
    };
  }), o;
}
function cr(e, t, n, o) {
  const r = o ?? e.today(), s = n ? e.startOfBroadcastWeek(r, e) : t ? e.startOfISOWeek(r) : e.startOfWeek(r), i = [];
  for (let a = 0; a < 7; a++) {
    const l = e.addDays(s, a);
    i.push(l);
  }
  return i;
}
function fr(e, t, n, o, r = !1) {
  if (!e || !t) return;
  const { startOfYear: s, endOfYear: i, eachYearOfInterval: a, getYear: l } = o, f = a({
    start: s(e),
    end: i(t)
  });
  return r && f.reverse(), f.map((u) => {
    const d = n.formatYearDropdown(u, o);
    return {
      value: l(u),
      label: d,
      disabled: !1
    };
  });
}
function dr(e, t = {}) {
  const { weekStartsOn: n, locale: o } = t, r = n ?? o?.options?.weekStartsOn ?? 0, s = (a) => {
    const l = typeof a == "number" || typeof a == "string" ? new Date(a) : a;
    return new V(l.getFullYear(), l.getMonth(), l.getDate(), 12, 0, 0, e);
  }, i = (a) => {
    const l = s(a);
    return new Date(l.getFullYear(), l.getMonth(), l.getDate(), 0, 0, 0, 0);
  };
  return {
    today: () => s(V.tz(e)),
    newDate: (a, l, f) => new V(a, l, f, 12, 0, 0, e),
    startOfDay: (a) => s(a),
    startOfWeek: (a, l) => {
      const f = s(a), u = l?.weekStartsOn ?? r, d = (f.getDay() - u + 7) % 7;
      return f.setDate(f.getDate() - d), f;
    },
    startOfISOWeek: (a) => {
      const l = s(a), f = (l.getDay() - 1 + 7) % 7;
      return l.setDate(l.getDate() - f), l;
    },
    startOfMonth: (a) => {
      const l = s(a);
      return l.setDate(1), l;
    },
    startOfYear: (a) => {
      const l = s(a);
      return l.setMonth(0, 1), l;
    },
    endOfWeek: (a, l) => {
      const f = s(a), u = (((l?.weekStartsOn ?? r) + 6) % 7 - f.getDay() + 7) % 7;
      return f.setDate(f.getDate() + u), f;
    },
    endOfISOWeek: (a) => {
      const l = s(a), f = (7 - l.getDay()) % 7;
      return l.setDate(l.getDate() + f), l;
    },
    endOfMonth: (a) => {
      const l = s(a);
      return l.setMonth(l.getMonth() + 1, 0), l;
    },
    endOfYear: (a) => {
      const l = s(a);
      return l.setMonth(11, 31), l;
    },
    eachMonthOfInterval: (a) => {
      const l = s(a.start), f = s(a.end), u = [], d = new V(l.getFullYear(), l.getMonth(), 1, 12, 0, 0, e), g = f.getFullYear() * 12 + f.getMonth();
      for (; d.getFullYear() * 12 + d.getMonth() <= g; )
        u.push(new V(d, e)), d.setMonth(d.getMonth() + 1, 1);
      return u;
    },
    addDays: (a, l) => {
      const f = s(a);
      return f.setDate(f.getDate() + l), f;
    },
    addWeeks: (a, l) => {
      const f = s(a);
      return f.setDate(f.getDate() + l * 7), f;
    },
    addMonths: (a, l) => {
      const f = s(a);
      return f.setMonth(f.getMonth() + l), f;
    },
    addYears: (a, l) => {
      const f = s(a);
      return f.setFullYear(f.getFullYear() + l), f;
    },
    eachYearOfInterval: (a) => {
      const l = s(a.start), f = s(a.end), u = [], d = new V(l.getFullYear(), 0, 1, 12, 0, 0, e);
      for (; d.getFullYear() <= f.getFullYear(); )
        u.push(new V(d, e)), d.setFullYear(d.getFullYear() + 1, 0, 1);
      return u;
    },
    getWeek: (a, l) => Mt(i(a), {
      weekStartsOn: l?.weekStartsOn ?? r,
      firstWeekContainsDate: l?.firstWeekContainsDate ?? o?.options?.firstWeekContainsDate ?? 1
    }),
    getISOWeek: (a) => wt(i(a)),
    differenceInCalendarDays: (a, l) => xt(i(a), i(l)),
    differenceInCalendarMonths: (a, l) => Ct(i(a), i(l))
  };
}
var ve = (e) => e instanceof HTMLElement ? e : null, Fe = (e) => [...e.querySelectorAll("[data-animated-month]") ?? []], ur = (e) => ve(e.querySelector("[data-animated-month]")), Ae = (e) => ve(e.querySelector("[data-animated-caption]")), $e = (e) => ve(e.querySelector("[data-animated-weeks]")), hr = (e) => ve(e.querySelector("[data-animated-nav]")), mr = (e) => ve(e.querySelector("[data-animated-weekdays]"));
function yr(e, t, { classNames: n, months: o, focused: r, dateLib: s }) {
  const i = (0, c.useRef)(null), a = (0, c.useRef)(o), l = (0, c.useRef)(!1);
  (0, c.useLayoutEffect)(() => {
    const f = a.current;
    if (a.current = o, !t || !e.current || !(e.current instanceof HTMLElement) || o.length === 0 || f.length === 0 || o.length !== f.length) return;
    const u = s.isSameMonth(o[0].date, f[0].date), d = s.isAfter(o[0].date, f[0].date), g = d ? n[U.caption_after_enter] : n[U.caption_before_enter], h = d ? n[U.weeks_after_enter] : n[U.weeks_before_enter], p = i.current, D = e.current.cloneNode(!0);
    if (D instanceof HTMLElement ? (Fe(D).forEach((w) => {
      if (!(w instanceof HTMLElement)) return;
      const k = ur(w);
      k && w.contains(k) && w.removeChild(k);
      const M = Ae(w);
      M && M.classList.remove(g);
      const S = $e(w);
      S && S.classList.remove(h);
    }), i.current = D) : i.current = null, l.current || u || r) return;
    const b = p instanceof HTMLElement ? Fe(p) : [], C = Fe(e.current);
    if (C?.every((w) => w instanceof HTMLElement) && b && b.every((w) => w instanceof HTMLElement)) {
      l.current = !0;
      const w = [];
      e.current.style.isolation = "isolate";
      const k = hr(e.current);
      k && (k.style.zIndex = "1"), C.forEach((M, S) => {
        const m = b[S];
        if (!m) return;
        M.style.position = "relative", M.style.overflow = "hidden";
        const B = Ae(M);
        B && B.classList.add(g);
        const Y = $e(M);
        Y && Y.classList.add(h);
        const P = () => {
          l.current = !1, e.current && (e.current.style.isolation = ""), k && (k.style.zIndex = ""), B && B.classList.remove(g), Y && Y.classList.remove(h), M.style.position = "", M.style.overflow = "", M.contains(m) && M.removeChild(m);
        };
        w.push(P), m.style.pointerEvents = "none", m.style.position = "absolute", m.style.overflow = "hidden", m.setAttribute("aria-hidden", "true");
        const R = mr(m);
        R && (R.style.opacity = "0");
        const A = Ae(m);
        A && (A.classList.add(d ? n[U.caption_before_exit] : n[U.caption_after_exit]), A.addEventListener("animationend", P));
        const H = $e(m);
        H && H.classList.add(d ? n[U.weeks_before_exit] : n[U.weeks_after_exit]), M.insertBefore(m, M.firstChild);
      });
    }
  });
}
function pr(e, t, n, o) {
  const r = e[0], s = e[e.length - 1], { ISOWeek: i, fixedWeeks: a, broadcastCalendar: l } = n ?? {}, { addDays: f, differenceInCalendarDays: u, differenceInCalendarMonths: d, endOfBroadcastWeek: g, endOfISOWeek: h, endOfMonth: p, endOfWeek: D, isAfter: b, startOfBroadcastWeek: C, startOfISOWeek: w, startOfWeek: k } = o, M = l ? C(r, o) : i ? w(r) : k(r), S = l ? g(s) : i ? h(p(s)) : D(p(s)), m = t && (l ? g(t) : i ? h(t) : D(t)), B = u(m && b(S, m) ? m : S, M), Y = d(s, r) + 1, P = [];
  for (let A = 0; A <= B; A++) {
    const H = f(M, A);
    P.push(H);
  }
  const R = (l ? 35 : 42) * Y;
  if (a && P.length < R) {
    const A = R - P.length;
    for (let H = 0; H < A; H++) {
      const O = f(P[P.length - 1], 1);
      P.push(O);
    }
  }
  return P;
}
function br(e) {
  const t = [];
  return e.reduce((n, o) => {
    const r = o.weeks.reduce((s, i) => s.concat(i.days.slice()), t.slice());
    return n.concat(r.slice());
  }, t.slice());
}
function gr(e, t, n, o) {
  const { numberOfMonths: r = 1 } = n, s = [];
  for (let i = 0; i < r; i++) {
    const a = o.addMonths(e, i);
    if (t && a > t) break;
    s.push(a);
  }
  return s;
}
function ht(e, t, n, o) {
  const { month: r, defaultMonth: s, today: i = o.today(), numberOfMonths: a = 1 } = e;
  let l = r || s || i;
  const { differenceInCalendarMonths: f, addMonths: u, startOfMonth: d } = o;
  return n && f(n, l) < a - 1 && (l = u(n, -1 * (a - 1))), t && f(l, t) < 0 && (l = t), d(l);
}
function vr(e, t, n, o) {
  const { addDays: r, endOfBroadcastWeek: s, endOfISOWeek: i, endOfMonth: a, endOfWeek: l, getISOWeek: f, getWeek: u, startOfBroadcastWeek: d, startOfISOWeek: g, startOfWeek: h } = o, p = e.reduce((D, b) => {
    const C = n.broadcastCalendar ? d(b, o) : n.ISOWeek ? g(b) : h(b), w = n.broadcastCalendar ? s(b) : n.ISOWeek ? i(a(b)) : l(a(b)), k = t.filter((m) => m >= C && m <= w), M = n.broadcastCalendar ? 35 : 42;
    if (n.fixedWeeks && k.length < M) {
      const m = t.filter((B) => {
        const Y = M - k.length;
        return B > w && B <= r(w, Y);
      });
      k.push(...m);
    }
    const S = new mo(b, k.reduce((m, B) => {
      const Y = n.ISOWeek ? f(B) : u(B), P = m.find((A) => A.weekNumber === Y), R = new Tt(B, b, o);
      return P ? P.days.push(R) : m.push(new yo(Y, [R])), m;
    }, []));
    return D.push(S), D;
  }, []);
  return n.reverseMonths ? p.reverse() : p;
}
function Dr(e, t) {
  let { startMonth: n, endMonth: o } = e;
  const { startOfYear: r, startOfDay: s, startOfMonth: i, endOfMonth: a, addYears: l, endOfYear: f, newDate: u, today: d } = t, { fromYear: g, toYear: h, fromMonth: p, toMonth: D } = e;
  !n && p && (n = p), !n && g && (n = t.newDate(g, 0, 1)), !o && D && (o = D), !o && h && (o = u(h, 11, 31));
  const b = e.captionLayout === "dropdown" || e.captionLayout === "dropdown-years";
  return n ? n = i(n) : g ? n = u(g, 0, 1) : !n && b && (n = r(l(e.today ?? d(), -100))), o ? o = a(o) : h ? o = u(h, 11, 31) : !o && b && (o = f(e.today ?? d())), [n && s(n), o && s(o)];
}
function kr(e, t, n, o) {
  if (n.disableNavigation) return;
  const { pagedNavigation: r, numberOfMonths: s = 1 } = n, { startOfMonth: i, addMonths: a, differenceInCalendarMonths: l } = o, f = r ? s : 1, u = i(e);
  if (!t) return a(u, f);
  if (!(l(t, e) < s))
    return a(u, f);
}
function Mr(e, t, n, o) {
  if (n.disableNavigation) return;
  const { pagedNavigation: r, numberOfMonths: s } = n, { startOfMonth: i, addMonths: a, differenceInCalendarMonths: l } = o, f = r ? s ?? 1 : 1, u = i(e);
  if (!t) return a(u, -f);
  if (!(l(u, t) <= 0))
    return a(u, -f);
}
function wr(e) {
  return e.reduce((t, n) => t.concat(n.weeks.slice()), [].slice());
}
function Oe(e, t) {
  const [n, o] = (0, c.useState)(e);
  return [t === void 0 ? n : t, o];
}
function xr(e, t) {
  const [n, o] = Dr(e, t), { startOfMonth: r, endOfMonth: s } = t, i = ht(e, n, o, t), [a, l] = Oe(i, e.month ? i : void 0);
  (0, c.useEffect)(() => {
    l(ht(e, n, o, t));
  }, [e.timeZone]);
  const { months: f, weeks: u, days: d, previousMonth: g, nextMonth: h } = (0, c.useMemo)(() => {
    const k = gr(a, o, { numberOfMonths: e.numberOfMonths }, t), M = vr(k, pr(k, e.endMonth ? s(e.endMonth) : void 0, {
      ISOWeek: e.ISOWeek,
      fixedWeeks: e.fixedWeeks,
      broadcastCalendar: e.broadcastCalendar
    }, t), {
      broadcastCalendar: e.broadcastCalendar,
      fixedWeeks: e.fixedWeeks,
      ISOWeek: e.ISOWeek,
      reverseMonths: e.reverseMonths
    }, t);
    return {
      months: M,
      weeks: wr(M),
      days: br(M),
      previousMonth: Mr(a, n, e, t),
      nextMonth: kr(a, o, e, t)
    };
  }, [
    t,
    a.getTime(),
    o?.getTime(),
    n?.getTime(),
    e.disableNavigation,
    e.broadcastCalendar,
    e.endMonth?.getTime(),
    e.fixedWeeks,
    e.ISOWeek,
    e.numberOfMonths,
    e.pagedNavigation,
    e.reverseMonths
  ]), { disableNavigation: p, onMonthChange: D } = e, b = (k) => u.some((M) => M.days.some((S) => S.isEqualTo(k))), C = (k) => {
    if (p) return;
    let M = r(k);
    n && M < r(n) && (M = r(n)), o && M > r(o) && (M = r(o)), l(M), D?.(M);
  };
  return {
    months: f,
    weeks: u,
    days: d,
    navStart: n,
    navEnd: o,
    previousMonth: g,
    nextMonth: h,
    goToMonth: C,
    goToDay: (k) => {
      b(k) || C(k.date);
    }
  };
}
var ee;
(function(e) {
  e[e.Today = 0] = "Today", e[e.Selected = 1] = "Selected", e[e.LastFocused = 2] = "LastFocused", e[e.FocusedModifier = 3] = "FocusedModifier";
})(ee || (ee = {}));
function mt(e) {
  return !e[I.disabled] && !e[I.hidden] && !e[I.outside];
}
function Nr(e, t, n, o) {
  let r, s = -1;
  for (const i of e) {
    const a = t(i);
    mt(a) && (a[I.focused] && s < ee.FocusedModifier ? (r = i, s = ee.FocusedModifier) : o?.isEqualTo(i) && s < ee.LastFocused ? (r = i, s = ee.LastFocused) : n(i.date) && s < ee.Selected ? (r = i, s = ee.Selected) : a[I.today] && s < ee.Today && (r = i, s = ee.Today));
  }
  return r || (r = e.find((i) => mt(t(i)))), r;
}
function Or(e, t, n, o, r, s, i) {
  const { ISOWeek: a, broadcastCalendar: l } = s, { addDays: f, addMonths: u, addWeeks: d, addYears: g, endOfBroadcastWeek: h, endOfISOWeek: p, endOfWeek: D, max: b, min: C, startOfBroadcastWeek: w, startOfISOWeek: k, startOfWeek: M } = i;
  let S = {
    day: f,
    week: d,
    month: u,
    year: g,
    startOfWeek: (m) => l ? w(m, i) : a ? k(m) : M(m),
    endOfWeek: (m) => l ? h(m) : a ? p(m) : D(m)
  }[e](n, t === "after" ? 1 : -1);
  return t === "before" && o ? S = b([o, S]) : t === "after" && r && (S = C([r, S])), S;
}
function Ut(e, t, n, o, r, s, i, a = 0) {
  if (a > 365) return;
  const l = Or(e, t, n.date, o, r, s, i), f = !!(s.disabled && ae(l, s.disabled, i)), u = !!(s.hidden && ae(l, s.hidden, i)), d = new Tt(l, l, i);
  return !f && !u ? d : Ut(e, t, d, o, r, s, i, a + 1);
}
function Cr(e, t, n, o, r) {
  const { autoFocus: s } = e, [i, a] = (0, c.useState)(), l = Nr(t.days, n, o || (() => !1), i), [f, u] = (0, c.useState)(s ? l : void 0);
  return {
    isFocusTarget: (p) => !!l?.isEqualTo(p),
    setFocused: u,
    focused: f,
    blur: () => {
      a(f), u(void 0);
    },
    moveFocus: (p, D) => {
      if (!f) return;
      const b = Ut(p, D, f, t.navStart, t.navEnd, e, r);
      b && (e.disableNavigation && !t.days.some((C) => C.isEqualTo(b)) || (t.goToDay(b), u(b)));
    }
  };
}
function Sr(e, t) {
  const { selected: n, required: o, onSelect: r } = e, [s, i] = Oe(n, r ? n : void 0), a = r ? n : s, { isSameDay: l } = t, f = (h) => a?.some((p) => l(p, h)) ?? !1, { min: u, max: d } = e;
  return {
    selected: a,
    select: (h, p, D) => {
      let b = [...a ?? []];
      if (f(h)) {
        if (a?.length === u || o && a?.length === 1) return;
        b = a?.filter((C) => !l(C, h));
      } else a?.length === d ? b = [h] : b = [...b, h];
      return r || i(b), r?.(b, h, p, D), b;
    },
    isSelected: f
  };
}
function Wr(e, t, n = 0, o = 0, r = !1, s = oe) {
  const { from: i, to: a } = t || {}, { isSameDay: l, isAfter: f, isBefore: u } = s;
  let d;
  if (!i && !a) d = {
    from: e,
    to: n > 0 ? void 0 : e
  };
  else if (i && !a) l(i, e) ? n === 0 ? d = {
    from: i,
    to: e
  } : r ? d = {
    from: i,
    to: void 0
  } : d = void 0 : u(e, i) ? d = {
    from: e,
    to: i
  } : d = {
    from: i,
    to: e
  };
  else if (i && a) if (l(i, e) && l(a, e)) r ? d = {
    from: i,
    to: a
  } : d = void 0;
  else if (l(i, e)) d = {
    from: i,
    to: n > 0 ? void 0 : e
  };
  else if (l(a, e)) d = {
    from: e,
    to: n > 0 ? void 0 : e
  };
  else if (u(e, i)) d = {
    from: e,
    to: a
  };
  else if (f(e, i)) d = {
    from: i,
    to: e
  };
  else if (f(e, a)) d = {
    from: i,
    to: e
  };
  else throw new Error("Invalid range");
  if (d?.from && d?.to) {
    const g = s.differenceInCalendarDays(d.to, d.from);
    o > 0 && g > o ? d = {
      from: e,
      to: void 0
    } : n > 1 && g < n && (d = {
      from: e,
      to: void 0
    });
  }
  return d;
}
function _r(e, t, n = oe) {
  const o = Array.isArray(t) ? t : [t];
  let r = e.from;
  const s = n.differenceInCalendarDays(e.to, e.from), i = Math.min(s, 6);
  for (let a = 0; a <= i; a++) {
    if (o.includes(r.getDay())) return !0;
    r = n.addDays(r, 1);
  }
  return !1;
}
function yt(e, t, n = oe) {
  return se(e, t.from, !1, n) || se(e, t.to, !1, n) || se(t, e.from, !1, n) || se(t, e.to, !1, n);
}
function Tr(e, t, n = oe) {
  const o = Array.isArray(t) ? t : [t];
  if (o.filter((s) => typeof s != "function").some((s) => typeof s == "boolean" ? s : n.isDate(s) ? se(e, s, !1, n) : jt(s, n) ? s.some((i) => se(e, i, !1, n)) : Ne(s) ? s.from && s.to ? yt(e, {
    from: s.from,
    to: s.to
  }, n) : !1 : Yt(s) ? _r(e, s.dayOfWeek, n) : Ve(s) ? n.isAfter(s.before, s.after) ? yt(e, {
    from: n.addDays(s.after, 1),
    to: n.addDays(s.before, -1)
  }, n) : ae(e.from, s, n) || ae(e.to, s, n) : Je(s) || Xe(s) ? ae(e.from, s, n) || ae(e.to, s, n) : !1)) return !0;
  const r = o.filter((s) => typeof s == "function");
  if (r.length) {
    let s = e.from;
    const i = n.differenceInCalendarDays(e.to, e.from);
    for (let a = 0; a <= i; a++) {
      if (r.some((l) => l(s))) return !0;
      s = n.addDays(s, 1);
    }
  }
  return !1;
}
function Er(e, t) {
  const { disabled: n, excludeDisabled: o, resetOnSelect: r, selected: s, required: i, onSelect: a } = e, [l, f] = Oe(s, a ? s : void 0), u = a ? s : l;
  return {
    selected: u,
    select: (h, p, D) => {
      const { min: b, max: C } = e;
      let w;
      if (h) {
        const k = u?.from, M = u?.to, S = !!k && !!M, m = !!k && !!M && t.isSameDay(k, M) && t.isSameDay(h, k);
        r && (S || !u?.from) ? !i && m ? w = void 0 : w = {
          from: h,
          to: void 0
        } : w = Wr(h, u, b, C, i, t);
      }
      return o && n && w?.from && w.to && Tr({
        from: w.from,
        to: w.to
      }, n, t) && (w.from = h, w.to = void 0), a || f(w), a?.(w, h, p, D), w;
    },
    isSelected: (h) => u && se(u, h, !1, t)
  };
}
function Yr(e, t) {
  const { selected: n, required: o, onSelect: r } = e, [s, i] = Oe(n, r ? n : void 0), a = r ? n : s, { isSameDay: l } = t;
  return {
    selected: a,
    select: (d, g, h) => {
      let p = d;
      return !o && a && a && l(d, a) && (p = void 0), r || i(p), r?.(p, d, g, h), p;
    },
    isSelected: (d) => a ? l(a, d) : !1
  };
}
function jr(e, t) {
  const n = Yr(e, t), o = Sr(e, t), r = Er(e, t);
  switch (e.mode) {
    case "single":
      return n;
    case "multiple":
      return o;
    case "range":
      return r;
    default:
      return;
  }
}
function G(e, t) {
  return e instanceof V && e.timeZone === t ? e : new V(e, t);
}
function ce(e, t, n) {
  if (!n) return G(e, t);
  const o = G(e, t), r = new V(o.getFullYear(), o.getMonth(), o.getDate(), 12, 0, 0, t);
  return new Date(r.getTime());
}
function pt(e, t, n) {
  return typeof e == "boolean" || typeof e == "function" ? e : e instanceof Date ? ce(e, t, n) : Array.isArray(e) ? e.map((o) => o instanceof Date ? ce(o, t, n) : o) : Ne(e) ? {
    ...e,
    from: e.from ? G(e.from, t) : e.from,
    to: e.to ? G(e.to, t) : e.to
  } : Ve(e) ? {
    before: ce(e.before, t, n),
    after: ce(e.after, t, n)
  } : Je(e) ? { after: ce(e.after, t, n) } : Xe(e) ? { before: ce(e.before, t, n) } : e;
}
function ze(e, t, n) {
  return e && (Array.isArray(e) ? e.map((o) => pt(o, t, n)) : pt(e, t, n));
}
function Ce(e) {
  let t = e;
  const n = t.timeZone;
  if (n && (t = {
    ...e,
    timeZone: n
  }, t.today && (t.today = G(t.today, n)), t.month && (t.month = G(t.month, n)), t.defaultMonth && (t.defaultMonth = G(t.defaultMonth, n)), t.startMonth && (t.startMonth = G(t.startMonth, n)), t.endMonth && (t.endMonth = G(t.endMonth, n)), t.mode === "single" && t.selected ? t.selected = G(t.selected, n) : t.mode === "multiple" && t.selected ? t.selected = t.selected?.map((N) => G(N, n)) : t.mode === "range" && t.selected && (t.selected = {
    from: t.selected.from ? G(t.selected.from, n) : t.selected.from,
    to: t.selected.to ? G(t.selected.to, n) : t.selected.to
  }), t.disabled !== void 0 && (t.disabled = ze(t.disabled, n)), t.hidden !== void 0 && (t.hidden = ze(t.hidden, n)), t.modifiers)) {
    const N = {};
    Object.keys(t.modifiers).forEach((_) => {
      N[_] = ze(t.modifiers?.[_], n);
    }), t.modifiers = N;
  }
  const { components: o, formatters: r, labels: s, dateLib: i, locale: a, classNames: l } = (0, c.useMemo)(() => {
    const N = {
      ..._t,
      ...t.locale
    }, _ = t.broadcastCalendar ? 1 : t.weekStartsOn, x = t.noonSafe && t.timeZone ? dr(t.timeZone, {
      weekStartsOn: _,
      locale: N
    }) : void 0, E = t.dateLib && x ? {
      ...x,
      ...t.dateLib
    } : t.dateLib ?? x, K = new ne({
      locale: N,
      weekStartsOn: _,
      firstWeekContainsDate: t.firstWeekContainsDate,
      useAdditionalWeekYearTokens: t.useAdditionalWeekYearTokens,
      useAdditionalDayOfYearTokens: t.useAdditionalDayOfYearTokens,
      timeZone: t.timeZone,
      numerals: t.numerals
    }, E);
    return {
      dateLib: K,
      components: qo(t.components),
      formatters: tr(t.formatters),
      labels: ar(t.labels, K.options),
      locale: N,
      classNames: {
        ...Bt(),
        ...t.classNames
      }
    };
  }, [
    t.locale,
    t.broadcastCalendar,
    t.weekStartsOn,
    t.firstWeekContainsDate,
    t.useAdditionalWeekYearTokens,
    t.useAdditionalDayOfYearTokens,
    t.timeZone,
    t.numerals,
    t.dateLib,
    t.noonSafe,
    t.components,
    t.formatters,
    t.labels,
    t.classNames
  ]);
  t.today || (t = {
    ...t,
    today: i.today()
  });
  const { captionLayout: f, mode: u, navLayout: d, numberOfMonths: g = 1, onDayBlur: h, onDayClick: p, onDayFocus: D, onDayKeyDown: b, onDayMouseEnter: C, onDayMouseLeave: w, onNextClick: k, onPrevClick: M, showWeekNumber: S, styles: m } = t, { formatCaption: B, formatDay: Y, formatMonthDropdown: P, formatWeekNumber: R, formatWeekNumberHeader: A, formatWeekdayName: H, formatYearDropdown: O } = r, T = xr(t, i), { days: $, months: Z, navStart: q, navEnd: _e, previousMonth: J, nextMonth: X, goToMonth: re } = T, Te = Ro($, t, q, _e, i), { isSelected: Ee, select: Ye, selected: De } = jr(t, i) ?? {}, { blur: rt, focused: st, isFocusTarget: tn, moveFocus: at, setFocused: ke } = Cr(t, T, Te, Ee ?? (() => !1), i), { labelDayButton: nn, labelGridcell: on, labelGrid: rn, labelMonthDropdown: sn, labelNav: it, labelPrevious: an, labelNext: ln, labelWeekday: cn, labelWeekNumber: fn, labelWeekNumberHeader: dn, labelYearDropdown: un } = s, hn = (0, c.useMemo)(() => cr(i, t.ISOWeek, t.broadcastCalendar, t.today), [
    i,
    t.ISOWeek,
    t.broadcastCalendar,
    t.today
  ]), lt = u !== void 0 || p !== void 0, je = (0, c.useCallback)(() => {
    J && (re(J), M?.(J));
  }, [
    J,
    re,
    M
  ]), Be = (0, c.useCallback)(() => {
    X && (re(X), k?.(X));
  }, [
    re,
    X,
    k
  ]), mn = (0, c.useCallback)((N, _) => (x) => {
    x.preventDefault(), x.stopPropagation(), ke(N), !_.disabled && (Ye?.(N.date, _, x), p?.(N.date, _, x));
  }, [
    Ye,
    p,
    ke
  ]), yn = (0, c.useCallback)((N, _) => (x) => {
    ke(N), D?.(N.date, _, x);
  }, [D, ke]), pn = (0, c.useCallback)((N, _) => (x) => {
    rt(), h?.(N.date, _, x);
  }, [rt, h]), bn = (0, c.useCallback)((N, _) => (x) => {
    const E = {
      ArrowLeft: [x.shiftKey ? "month" : "day", t.dir === "rtl" ? "after" : "before"],
      ArrowRight: [x.shiftKey ? "month" : "day", t.dir === "rtl" ? "before" : "after"],
      ArrowDown: [x.shiftKey ? "year" : "week", "after"],
      ArrowUp: [x.shiftKey ? "year" : "week", "before"],
      PageUp: [x.shiftKey ? "year" : "month", "before"],
      PageDown: [x.shiftKey ? "year" : "month", "after"],
      Home: ["startOfWeek", "before"],
      End: ["endOfWeek", "after"]
    };
    if (E[x.key]) {
      x.preventDefault(), x.stopPropagation();
      const [K, W] = E[x.key];
      at(K, W);
    }
    b?.(N.date, _, x);
  }, [
    at,
    b,
    t.dir
  ]), gn = (0, c.useCallback)((N, _) => (x) => {
    C?.(N.date, _, x);
  }, [C]), vn = (0, c.useCallback)((N, _) => (x) => {
    w?.(N.date, _, x);
  }, [w]), Dn = (0, c.useCallback)((N) => (_) => {
    const x = Number(_.target.value);
    re(i.setMonth(i.startOfMonth(N), x));
  }, [i, re]), kn = (0, c.useCallback)((N) => (_) => {
    const x = Number(_.target.value);
    re(i.setYear(i.startOfMonth(N), x));
  }, [i, re]), { className: Mn, style: wn } = (0, c.useMemo)(() => ({
    className: [l[v.Root], t.className].filter(Boolean).join(" "),
    style: {
      ...m?.[v.Root],
      ...t.style
    }
  }), [
    l,
    t.className,
    t.style,
    m
  ]), xn = Go(t), ct = (0, c.useRef)(null);
  yr(ct, !!t.animate, {
    classNames: l,
    months: Z,
    focused: st,
    dateLib: i
  });
  const Nn = {
    dayPickerProps: t,
    selected: De,
    select: Ye,
    isSelected: Ee,
    months: Z,
    nextMonth: X,
    previousMonth: J,
    goToMonth: re,
    getModifiers: Te,
    components: o,
    classNames: l,
    styles: m,
    labels: s,
    formatters: r
  };
  return c.createElement(Et.Provider, { value: Nn }, c.createElement(o.Root, {
    rootRef: t.animate ? ct : void 0,
    className: Mn,
    style: wn,
    dir: t.dir,
    id: t.id,
    lang: t.lang ?? a.code,
    nonce: t.nonce,
    title: t.title,
    role: t.role,
    "aria-label": t["aria-label"],
    "aria-labelledby": t["aria-labelledby"],
    ...xn
  }, c.createElement(o.Months, {
    className: l[v.Months],
    style: m?.[v.Months]
  }, !t.hideNavigation && !d && c.createElement(o.Nav, {
    "data-animated-nav": t.animate ? "true" : void 0,
    className: l[v.Nav],
    style: m?.[v.Nav],
    "aria-label": it(),
    onPreviousClick: je,
    onNextClick: Be,
    previousMonth: J,
    nextMonth: X
  }), Z.map((N, _) => c.createElement(o.Month, {
    "data-animated-month": t.animate ? "true" : void 0,
    className: l[v.Month],
    style: m?.[v.Month],
    key: _,
    displayIndex: _,
    calendarMonth: N
  }, d === "around" && !t.hideNavigation && _ === 0 && c.createElement(o.PreviousMonthButton, {
    type: "button",
    className: l[v.PreviousMonthButton],
    tabIndex: J ? void 0 : -1,
    "aria-disabled": J ? void 0 : !0,
    "aria-label": an(J),
    onClick: je,
    "data-animated-button": t.animate ? "true" : void 0
  }, c.createElement(o.Chevron, {
    disabled: J ? void 0 : !0,
    className: l[v.Chevron],
    orientation: t.dir === "rtl" ? "right" : "left"
  })), c.createElement(o.MonthCaption, {
    "data-animated-caption": t.animate ? "true" : void 0,
    className: l[v.MonthCaption],
    style: m?.[v.MonthCaption],
    calendarMonth: N,
    displayIndex: _
  }, f?.startsWith("dropdown") ? c.createElement(o.DropdownNav, {
    className: l[v.Dropdowns],
    style: m?.[v.Dropdowns]
  }, (() => {
    const x = f === "dropdown" || f === "dropdown-months" ? c.createElement(o.MonthsDropdown, {
      key: "month",
      className: l[v.MonthsDropdown],
      "aria-label": sn(),
      classNames: l,
      components: o,
      disabled: !!t.disableNavigation,
      onChange: Dn(N.date),
      options: ir(N.date, q, _e, r, i),
      style: m?.[v.Dropdown],
      value: i.getMonth(N.date)
    }) : c.createElement("span", { key: "month" }, P(N.date, i)), E = f === "dropdown" || f === "dropdown-years" ? c.createElement(o.YearsDropdown, {
      key: "year",
      className: l[v.YearsDropdown],
      "aria-label": un(i.options),
      classNames: l,
      components: o,
      disabled: !!t.disableNavigation,
      onChange: kn(N.date),
      options: fr(q, _e, r, i, !!t.reverseYears),
      style: m?.[v.Dropdown],
      value: i.getYear(N.date)
    }) : c.createElement("span", { key: "year" }, O(N.date, i));
    return i.getMonthYearOrder() === "year-first" ? [E, x] : [x, E];
  })(), c.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(N.date, i.options, i))) : c.createElement(o.CaptionLabel, {
    className: l[v.CaptionLabel],
    role: "status",
    "aria-live": "polite"
  }, B(N.date, i.options, i))), d === "around" && !t.hideNavigation && _ === g - 1 && c.createElement(o.NextMonthButton, {
    type: "button",
    className: l[v.NextMonthButton],
    tabIndex: X ? void 0 : -1,
    "aria-disabled": X ? void 0 : !0,
    "aria-label": ln(X),
    onClick: Be,
    "data-animated-button": t.animate ? "true" : void 0
  }, c.createElement(o.Chevron, {
    disabled: X ? void 0 : !0,
    className: l[v.Chevron],
    orientation: t.dir === "rtl" ? "left" : "right"
  })), _ === g - 1 && d === "after" && !t.hideNavigation && c.createElement(o.Nav, {
    "data-animated-nav": t.animate ? "true" : void 0,
    className: l[v.Nav],
    style: m?.[v.Nav],
    "aria-label": it(),
    onPreviousClick: je,
    onNextClick: Be,
    previousMonth: J,
    nextMonth: X
  }), c.createElement(o.MonthGrid, {
    role: "grid",
    "aria-multiselectable": u === "multiple" || u === "range",
    "aria-label": rn(N.date, i.options, i) || void 0,
    className: l[v.MonthGrid],
    style: m?.[v.MonthGrid]
  }, !t.hideWeekdays && c.createElement(o.Weekdays, {
    "data-animated-weekdays": t.animate ? "true" : void 0,
    className: l[v.Weekdays],
    style: m?.[v.Weekdays]
  }, S && c.createElement(o.WeekNumberHeader, {
    "aria-label": dn(i.options),
    className: l[v.WeekNumberHeader],
    style: m?.[v.WeekNumberHeader],
    scope: "col"
  }, A()), hn.map((x) => c.createElement(o.Weekday, {
    "aria-label": cn(x, i.options, i),
    className: l[v.Weekday],
    key: String(x),
    style: m?.[v.Weekday],
    scope: "col"
  }, H(x, i.options, i)))), c.createElement(o.Weeks, {
    "data-animated-weeks": t.animate ? "true" : void 0,
    className: l[v.Weeks],
    style: m?.[v.Weeks]
  }, N.weeks.map((x) => c.createElement(o.Week, {
    className: l[v.Week],
    key: x.weekNumber,
    style: m?.[v.Week],
    week: x
  }, S && c.createElement(o.WeekNumber, {
    week: x,
    style: m?.[v.WeekNumber],
    "aria-label": fn(x.weekNumber, { locale: a }),
    className: l[v.WeekNumber],
    scope: "row",
    role: "rowheader"
  }, R(x.weekNumber, i)), x.days.map((E) => {
    const { date: K } = E, W = Te(E);
    if (W[I.focused] = !W.hidden && !!st?.isEqualTo(E), W[L.selected] = Ee?.(K) || W.selected, Ne(De)) {
      const { from: Pe, to: Ie } = De;
      W[L.range_start] = !!(Pe && Ie && i.isSameDay(K, Pe)), W[L.range_end] = !!(Pe && Ie && i.isSameDay(K, Ie)), W[L.range_middle] = se(De, K, !0, i);
    }
    const On = lr(W, m, t.modifiersStyles), Cn = Zo(W, l, t.modifiersClassNames), Sn = !lt && !W.hidden ? on(K, W, i.options, i) : void 0;
    return c.createElement(o.Day, {
      key: `${E.isoDate}_${E.displayMonthId}`,
      day: E,
      modifiers: W,
      className: Cn.join(" "),
      style: On,
      role: "gridcell",
      "aria-selected": W.selected || void 0,
      "aria-label": Sn,
      "data-day": E.isoDate,
      "data-month": E.outside ? E.dateMonthId : void 0,
      "data-selected": W.selected || void 0,
      "data-disabled": W.disabled || void 0,
      "data-hidden": W.hidden || void 0,
      "data-outside": E.outside || void 0,
      "data-focused": W.focused || void 0,
      "data-today": W.today || void 0
    }, !W.hidden && lt ? c.createElement(o.DayButton, {
      className: l[v.DayButton],
      style: m?.[v.DayButton],
      type: "button",
      day: E,
      modifiers: W,
      disabled: !W.focused && W.disabled || void 0,
      "aria-disabled": W.focused && W.disabled || void 0,
      tabIndex: tn(E) ? 0 : -1,
      "aria-label": nn(K, W, i.options, i),
      onClick: mn(E, W),
      onBlur: pn(E, W),
      onFocus: yn(E, W),
      onKeyDown: bn(E, W),
      onMouseEnter: gn(E, W),
      onMouseLeave: vn(E, W)
    }, Y(K, i.options, i)) : !W.hidden && Y(E.date, i.options, i));
  })))))))), t.footer && c.createElement(o.Footer, {
    className: l[v.Footer],
    style: m?.[v.Footer],
    role: "status",
    "aria-live": "polite"
  }, t.footer)));
}
var y = En(), z = Bt(), be = "bg-primary text-primary-foreground hover:bg-primary/90 hover:text-primary-foreground", bt = "size-[26px] flex items-center justify-center rounded-[10px] shadow-sm hover:bg-accent p-0 select-none transition-[color,background-color,transform] duration-200 ease-smooth motion-reduce:transition-none active:scale-[0.90] motion-reduce:active:scale-100", et = "inline-flex items-center gap-2 h-9 rounded-xl border border-input bg-background text-sm font-normal shadow-xs transition-[color,background-color,border-color,box-shadow,transform] duration-200 ease-smooth motion-reduce:transition-none active:scale-[0.98] motion-reduce:active:scale-100", tt = "hover:bg-accent focus-visible:outline-none focus-visible:bg-background focus-visible:border-ring focus-visible:shadow-[0px_0px_0px_3px_rgba(161,161,170,0.5)]", gt = "w-full min-h-[44px] py-2.5 px-3 text-sm font-normal rounded-md transition-[color,background-color,transform] duration-200 ease-smooth motion-reduce:transition-none active:scale-[0.97] motion-reduce:active:scale-100";
function Kt({ orientation: e }) {
  return e === "left" ? /* @__PURE__ */ (0, y.jsx)(Re, { className: "size-4" }) : /* @__PURE__ */ (0, y.jsx)(Ze, { className: "size-4" });
}
Kt.displayName = "DatePickerChevron";
var Se = { formatWeekdayName: (e) => F(e, "EEEEEE") };
function We(e, t, n) {
  return c.useMemo(() => {
    const o = [];
    if (e && o.push((r) => r < e), t && o.push((r) => r > t), n && (typeof n == "function" ? o.push(n) : o.push((r) => n.some((s) => s.toDateString() === r.toDateString()))), o.length !== 0)
      return (r) => o.some((s) => s(r));
  }, [
    e,
    t,
    n
  ]);
}
function He(e) {
  if (!e) return {
    hours: 12,
    minutes: 0
  };
  const [t, n] = e.split(":").map(Number);
  return {
    hours: t,
    minutes: n
  };
}
function Vt({ className: e, day: t, modifiers: n, ...o }) {
  const r = c.useRef(null);
  c.useEffect(() => {
    n.focused && r.current?.focus();
  }, [n.focused]);
  const s = n.selected && !n.range_start && !n.range_end && !n.range_middle, i = n.range_start, a = n.range_end, l = n.range_middle, f = n.today, u = n.outside, d = n.disabled;
  return /* @__PURE__ */ (0, y.jsx)("span", {
    className: j("relative flex items-center justify-center size-8", l && "bg-accent", i && !a && "bg-linear-to-l from-accent to-transparent", a && !i && "bg-linear-to-r from-accent to-transparent", i && a && "bg-transparent"),
    children: /* @__PURE__ */ (0, y.jsx)("button", {
      ref: r,
      type: "button",
      "data-day": t.date.toLocaleDateString(),
      "data-selected": s,
      "data-range-start": i,
      "data-range-end": a,
      "data-range-middle": l,
      disabled: d,
      className: j("relative flex items-center justify-center size-8 rounded-md text-sm font-normal transition-[color,background-color,transform] duration-200 ease-smooth motion-reduce:transition-none select-none active:scale-[0.92] motion-reduce:active:scale-100", "text-card-foreground hover:bg-accent hover:text-accent-foreground", u && "text-muted-foreground", f && !s && !i && !a && !l && be, s && be, (i || a) && be, l && "bg-transparent text-accent-foreground rounded-none hover:bg-accent/80", d && "text-muted-foreground cursor-not-allowed hover:bg-transparent", z.day, e),
      ...o
    })
  });
}
function nt({ showNav: e = !1, isRange: t = !1 } = {}) {
  return {
    root: j("w-fit", z.root),
    months: j(t ? "flex gap-2 flex-row relative" : "flex flex-col relative", z.months),
    month: j("flex flex-col w-full gap-4", z.month),
    nav: e ? j("flex items-center gap-1 w-full absolute top-0 inset-x-0 justify-between", z.nav) : j("hidden", z.nav),
    button_previous: e ? j(bt, z.button_previous) : void 0,
    button_next: e ? j(bt, z.button_next) : void 0,
    month_caption: e ? j("flex items-center justify-center h-[26px] pt-1", z.month_caption) : j("hidden", z.month_caption),
    caption_label: e ? j("text-sm font-medium select-none text-foreground", z.caption_label) : void 0,
    table: "w-full border-collapse",
    weekdays: j("flex", z.weekdays),
    weekday: j("text-muted-foreground font-normal text-xs w-8 flex items-center justify-center py-0.5", z.weekday),
    week: j("flex w-full mt-2", z.week),
    day: j("relative p-0 text-center select-none", z.day),
    outside: j("text-muted-foreground", z.outside),
    disabled: j("text-muted-foreground cursor-not-allowed", z.disabled),
    hidden: j("invisible", z.hidden),
    range_start: "rounded-l-md",
    range_middle: "rounded-none",
    range_end: "rounded-r-md"
  };
}
var Jt = nt(), Br = nt({ showNav: !0 }), Pr = nt({
  showNav: !0,
  isRange: !0
}), Xt = {
  DayButton: Vt,
  Chevron: Kt
}, Qt = { DayButton: Vt };
function Lt({ value: e, onChange: t, placeholder: n = "Pick a date", disabled: o = !1, className: r, dateFormat: s = "MMM d, yyyy", minDate: i, maxDate: a, disabledDates: l, dir: f = "ltr" }) {
  const [u, d] = c.useState(!1), [g, h] = c.useState(e || /* @__PURE__ */ new Date());
  c.useEffect(() => {
    u && h(e || /* @__PURE__ */ new Date());
  }, [u, e]);
  const p = (b) => {
    t?.(b), d(!1);
  }, D = We(i, a, l);
  return /* @__PURE__ */ (0, y.jsxs)(xe, {
    open: u,
    onOpenChange: d,
    children: [/* @__PURE__ */ (0, y.jsxs)(we, {
      disabled: o,
      className: j(et, "px-3", tt, e ? "text-foreground" : "text-muted-foreground", o && "opacity-50 cursor-not-allowed", r),
      children: [/* @__PURE__ */ (0, y.jsx)(Ke, { className: "size-4 shrink-0" }), /* @__PURE__ */ (0, y.jsx)("span", {
        className: "truncate leading-5",
        children: e ? F(e, s) : n
      })]
    }), /* @__PURE__ */ (0, y.jsx)(Me, {
      align: f === "rtl" ? "end" : "start",
      sideOffset: 4,
      className: "w-auto p-0 rounded-xl border-0 shadow-sm",
      children: /* @__PURE__ */ (0, y.jsx)(Ce, {
        mode: "single",
        selected: e,
        onSelect: p,
        month: g,
        onMonthChange: h,
        disabled: D,
        showOutsideDays: !0,
        weekStartsOn: 0,
        dir: f,
        className: "p-3",
        classNames: Br,
        formatters: Se,
        components: Xt
      })
    })]
  });
}
function Ir({ value: e, onChange: t, placeholder: n = "Pick a date", disabled: o = !1, className: r, dateFormat: s = "MMM d, yyyy", minDate: i, maxDate: a, disabledDates: l, dir: f = "ltr" }) {
  const [u, d] = c.useState(!1), [g, h] = c.useState(e?.from || /* @__PURE__ */ new Date());
  c.useEffect(() => {
    u && h(e?.from || /* @__PURE__ */ new Date());
  }, [u, e]);
  const p = (w) => {
    t?.(w), w?.from && w?.to && d(!1);
  }, D = We(i, a, l), b = e?.from || e?.to, C = () => e?.from ? e?.to ? `${F(e.from, s)} - ${F(e.to, s)}` : F(e.from, s) : n;
  return /* @__PURE__ */ (0, y.jsxs)(xe, {
    open: u,
    onOpenChange: d,
    children: [/* @__PURE__ */ (0, y.jsxs)(we, {
      disabled: o,
      className: j(et, "px-4", tt, b ? "text-foreground" : "text-muted-foreground", o && "opacity-50 cursor-not-allowed", r),
      children: [/* @__PURE__ */ (0, y.jsx)(Ke, { className: "size-4 shrink-0" }), /* @__PURE__ */ (0, y.jsx)("span", {
        className: "truncate leading-5",
        children: C()
      })]
    }), /* @__PURE__ */ (0, y.jsx)(Me, {
      align: f === "rtl" ? "end" : "start",
      sideOffset: 4,
      className: "w-auto p-0 rounded-xl border-0 shadow-sm",
      children: /* @__PURE__ */ (0, y.jsx)(Ce, {
        mode: "range",
        selected: e,
        onSelect: p,
        month: g,
        onMonthChange: h,
        numberOfMonths: 2,
        disabled: D,
        showOutsideDays: !0,
        weekStartsOn: 0,
        dir: f,
        className: "p-3",
        classNames: Pr,
        formatters: Se,
        components: Xt
      })
    })]
  });
}
function Fr({ value: e, onChange: t, placeholder: n = "Select time", disabled: o = !1, className: r, minTime: s, maxTime: i, minuteStep: a = 5, dir: l = "ltr", use24Hour: f = !0 }) {
  const [u, d] = c.useState(!1), [g, h] = c.useState(e), p = l === "rtl", { hours: D, minutes: b } = He(g);
  c.useEffect(() => {
    u && h(e);
  }, [u, e]);
  const C = c.useMemo(() => f ? Array.from({ length: 24 }, (O, T) => T) : Array.from({ length: 12 }, (O, T) => T + 1), [f]), w = c.useMemo(() => Array.from({ length: Math.ceil(60 / a) }, (O, T) => T * a), [a]), k = c.useCallback((O, T) => {
    const $ = O * 60 + T;
    if (s) {
      const [Z, q] = s.split(":").map(Number);
      if ($ < Z * 60 + q) return !0;
    }
    if (i) {
      const [Z, q] = i.split(":").map(Number);
      if ($ > Z * 60 + q) return !0;
    }
    return !1;
  }, [s, i]), M = (O) => {
    h(`${O.toString().padStart(2, "0")}:${b.toString().padStart(2, "0")}`);
  }, S = (O) => {
    h(`${D.toString().padStart(2, "0")}:${O.toString().padStart(2, "0")}`);
  }, m = () => {
    t?.(g), d(!1);
  }, B = () => {
    h(e), d(!1);
  }, Y = () => {
    const O = /* @__PURE__ */ new Date(), T = O.getHours(), $ = Math.floor(O.getMinutes() / a) * a;
    h(`${T.toString().padStart(2, "0")}:${$.toString().padStart(2, "0")}`);
  }, P = (O) => {
    if (!O) return n;
    if (f) return O;
    const { hours: T, minutes: $ } = He(O), Z = T >= 12 ? "PM" : "AM";
    return `${T % 12 || 12}:${$.toString().padStart(2, "0")} ${Z}`;
  }, R = !!e, A = c.useRef(null), H = c.useRef(null);
  return c.useEffect(() => {
    if (u) {
      const O = g || e, { hours: T, minutes: $ } = O ? He(O) : {
        hours: 12,
        minutes: 0
      };
      setTimeout(() => {
        if (A.current) {
          const Z = f ? T : (T % 12 || 12) - 1, q = A.current.children[Z];
          q && q.scrollIntoView({
            block: "center",
            behavior: "instant"
          });
        }
        if (H.current) {
          const Z = Math.floor($ / a), q = H.current.children[Z];
          q && q.scrollIntoView({
            block: "center",
            behavior: "instant"
          });
        }
      }, 0);
    }
  }, [
    u,
    g,
    e,
    f,
    a
  ]), /* @__PURE__ */ (0, y.jsxs)(xe, {
    open: u,
    onOpenChange: d,
    children: [/* @__PURE__ */ (0, y.jsxs)(we, {
      disabled: o,
      className: j(et, "px-3", tt, R ? "text-foreground" : "text-muted-foreground", o && "opacity-50 cursor-not-allowed", r),
      children: [/* @__PURE__ */ (0, y.jsx)(qn, { className: "size-4 shrink-0" }), /* @__PURE__ */ (0, y.jsx)("span", {
        className: "truncate leading-5",
        children: P(e)
      })]
    }), /* @__PURE__ */ (0, y.jsx)(Me, {
      align: p ? "end" : "start",
      sideOffset: 4,
      className: "w-[280px] max-w-[calc(100vw-2rem)] p-0 rounded-xl border-0 shadow-sm",
      children: /* @__PURE__ */ (0, y.jsxs)("div", {
        className: "flex flex-col",
        dir: l,
        children: [/* @__PURE__ */ (0, y.jsxs)("div", {
          className: "px-4 py-4 flex flex-col gap-3",
          children: [/* @__PURE__ */ (0, y.jsxs)("div", {
            className: "flex items-start gap-3",
            children: [/* @__PURE__ */ (0, y.jsx)("div", {
              className: "flex-1",
              children: /* @__PURE__ */ (0, y.jsx)("div", {
                role: "status",
                "aria-live": "polite",
                className: "flex h-10 w-full rounded-lg border border-input bg-background px-3 py-2 text-sm text-foreground shadow-xs items-center justify-center font-medium",
                children: g ? P(g) : "Select time"
              })
            }), /* @__PURE__ */ (0, y.jsx)(fe, {
              variant: "secondary",
              className: "shrink-0",
              onClick: Y,
              children: "Now"
            })]
          }), /* @__PURE__ */ (0, y.jsxs)("div", {
            className: "flex gap-2",
            children: [
              /* @__PURE__ */ (0, y.jsxs)("div", {
                className: "flex-1 flex flex-col",
                children: [/* @__PURE__ */ (0, y.jsx)("div", {
                  className: "text-xs font-normal text-muted-foreground text-center mb-2",
                  children: p ? "ساعة" : "Hour"
                }), /* @__PURE__ */ (0, y.jsx)("div", {
                  ref: A,
                  role: "listbox",
                  "aria-label": p ? "ساعة" : "Hour",
                  className: "h-[200px] overflow-y-auto scrollbar-thin scrollbar-thumb-border-tertiary scrollbar-track-transparent",
                  children: C.map((O) => {
                    const T = f ? O === D : O === (D % 12 || 12), $ = k(O, b);
                    return /* @__PURE__ */ (0, y.jsx)("button", {
                      type: "button",
                      role: "option",
                      "aria-selected": T,
                      disabled: $,
                      onClick: () => M(O),
                      className: j(gt, "hover:bg-accent hover:text-accent-foreground", T && be, $ && "text-muted-foreground cursor-not-allowed hover:bg-transparent"),
                      children: O.toString().padStart(2, "0")
                    }, O);
                  })
                })]
              }),
              /* @__PURE__ */ (0, y.jsx)("div", {
                className: "flex items-center justify-center text-2xl font-bold text-muted-foreground pt-6",
                children: ":"
              }),
              /* @__PURE__ */ (0, y.jsxs)("div", {
                className: "flex-1 flex flex-col",
                children: [/* @__PURE__ */ (0, y.jsx)("div", {
                  className: "text-xs font-normal text-muted-foreground text-center mb-2",
                  children: p ? "دقيقة" : "Min"
                }), /* @__PURE__ */ (0, y.jsx)("div", {
                  ref: H,
                  role: "listbox",
                  "aria-label": p ? "دقيقة" : "Minutes",
                  className: "h-[200px] overflow-y-auto scrollbar-thin scrollbar-thumb-border-tertiary scrollbar-track-transparent",
                  children: w.map((O) => {
                    const T = O === b, $ = k(D, O);
                    return /* @__PURE__ */ (0, y.jsx)("button", {
                      type: "button",
                      role: "option",
                      "aria-selected": T,
                      disabled: $,
                      onClick: () => S(O),
                      className: j(gt, "hover:bg-accent hover:text-accent-foreground", T && be, $ && "text-muted-foreground cursor-not-allowed hover:bg-transparent"),
                      children: O.toString().padStart(2, "0")
                    }, O);
                  })
                })]
              })
            ]
          })]
        }), /* @__PURE__ */ (0, y.jsxs)("div", {
          className: "flex gap-3 p-4 border-t border-border",
          children: [/* @__PURE__ */ (0, y.jsx)(fe, {
            variant: "secondary",
            className: "flex-1",
            onClick: B,
            children: p ? "إلغاء" : "Cancel"
          }), /* @__PURE__ */ (0, y.jsx)(fe, {
            variant: "primary",
            className: "flex-1",
            onClick: m,
            children: p ? "تطبيق" : "Apply"
          })]
        })]
      })
    })]
  });
}
function ot({ open: e, onOpenChange: t, disabled: n = !1, className: o, dir: r = "ltr", triggerLabel: s, month: i, onMonthChange: a, displayContent: l, onToday: f, onApply: u, onCancel: d, children: g }) {
  const h = r === "rtl", p = () => a((b) => new Date(b.getFullYear(), b.getMonth() - 1, 1)), D = () => a((b) => new Date(b.getFullYear(), b.getMonth() + 1, 1));
  return /* @__PURE__ */ (0, y.jsxs)(xe, {
    open: e,
    onOpenChange: t,
    children: [/* @__PURE__ */ (0, y.jsxs)(we, {
      disabled: n,
      className: j("inline-flex items-center gap-1.5 px-2.5 py-1 rounded-lg bg-muted text-sm font-medium transition-colors duration-200 ease-smooth motion-reduce:transition-none", "hover:bg-surface-1 focus-visible:outline-none", "focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-border", "text-foreground", n && "opacity-50 cursor-not-allowed", e && "ring-2 ring-offset-2 ring-border", o),
      children: [/* @__PURE__ */ (0, y.jsx)("span", {
        className: "px-0.5",
        children: s
      }), /* @__PURE__ */ (0, y.jsx)(Ke, { className: "size-3.5 text-foreground" })]
    }), /* @__PURE__ */ (0, y.jsx)(Me, {
      align: h ? "end" : "start",
      sideOffset: 8,
      className: "w-[328px] max-w-[calc(100vw-2rem)] p-0 rounded-xl border border-border shadow-xl",
      children: /* @__PURE__ */ (0, y.jsxs)("div", {
        className: "flex flex-col",
        dir: r,
        children: [/* @__PURE__ */ (0, y.jsxs)("div", {
          className: "px-6 py-5 flex flex-col gap-3",
          children: [
            /* @__PURE__ */ (0, y.jsxs)("div", {
              className: "flex items-center justify-between pb-1",
              children: [
                /* @__PURE__ */ (0, y.jsx)("button", {
                  type: "button",
                  onClick: p,
                  "aria-label": "Previous month",
                  className: "p-1.5 rounded-md hover:bg-muted text-muted-foreground transition-colors duration-200 ease-smooth motion-reduce:transition-none",
                  children: h ? /* @__PURE__ */ (0, y.jsx)(Ze, { className: "size-5" }) : /* @__PURE__ */ (0, y.jsx)(Re, { className: "size-5" })
                }),
                /* @__PURE__ */ (0, y.jsxs)("div", {
                  className: "flex items-center gap-2",
                  children: [/* @__PURE__ */ (0, y.jsx)("span", {
                    className: "text-base font-semibold text-secondary-foreground",
                    children: F(i, "MMMM")
                  }), /* @__PURE__ */ (0, y.jsx)("span", {
                    className: "text-base font-semibold text-secondary-foreground",
                    children: F(i, "yyyy")
                  })]
                }),
                /* @__PURE__ */ (0, y.jsx)("button", {
                  type: "button",
                  onClick: D,
                  "aria-label": "Next month",
                  className: "p-1.5 rounded-md hover:bg-muted text-muted-foreground transition-colors duration-200 ease-smooth motion-reduce:transition-none",
                  children: h ? /* @__PURE__ */ (0, y.jsx)(Re, { className: "size-5" }) : /* @__PURE__ */ (0, y.jsx)(Ze, { className: "size-5" })
                })
              ]
            }),
            /* @__PURE__ */ (0, y.jsxs)("div", {
              className: "flex items-start gap-3",
              children: [/* @__PURE__ */ (0, y.jsx)("div", {
                className: "flex h-10 w-full flex-1 rounded-lg border border-border bg-background px-3 py-2 text-base text-foreground shadow-sm",
                children: l
              }), /* @__PURE__ */ (0, y.jsx)(fe, {
                variant: "secondary",
                className: "shrink-0",
                onClick: f,
                children: "Today"
              })]
            }),
            g
          ]
        }), /* @__PURE__ */ (0, y.jsxs)("div", {
          className: "flex gap-3 p-4 border-t border-border",
          children: [/* @__PURE__ */ (0, y.jsx)(fe, {
            variant: "secondary",
            className: "flex-1",
            onClick: d,
            children: "Cancel"
          }), /* @__PURE__ */ (0, y.jsx)(fe, {
            appearance: "gradient",
            variant: "primary",
            className: "flex-1",
            onClick: u,
            children: "Apply"
          })]
        })]
      })
    })]
  });
}
ot.displayName = "DateFilterPopoverBase";
function Ar({ value: e, onChange: t, placeholder: n = "Select date", disabled: o = !1, className: r, dateFormat: s = "d/M/yyyy", minDate: i, maxDate: a, disabledDates: l, dir: f = "ltr" }) {
  const [u, d] = c.useState(!1), [g, h] = c.useState(e || /* @__PURE__ */ new Date()), [p, D] = c.useState(e);
  c.useEffect(() => {
    u && (D(e), h(e || /* @__PURE__ */ new Date()));
  }, [u, e]);
  const b = We(i, a, l);
  return /* @__PURE__ */ (0, y.jsx)(ot, {
    open: u,
    onOpenChange: d,
    disabled: o,
    className: r,
    dir: f,
    triggerLabel: e ? F(e, s) : n,
    month: g,
    onMonthChange: h,
    displayContent: p ? F(p, s) : /* @__PURE__ */ (0, y.jsx)("span", {
      className: "text-muted-foreground",
      children: "Select date"
    }),
    onToday: () => {
      const C = /* @__PURE__ */ new Date();
      D(C), h(C);
    },
    onApply: () => {
      t?.(p), d(!1);
    },
    onCancel: () => {
      D(e), d(!1);
    },
    children: /* @__PURE__ */ (0, y.jsx)(Ce, {
      mode: "single",
      selected: p,
      onSelect: D,
      month: g,
      onMonthChange: h,
      disabled: b,
      showOutsideDays: !0,
      weekStartsOn: 1,
      dir: f,
      className: "p-0",
      classNames: Jt,
      formatters: Se,
      components: Qt
    })
  });
}
function $r({ value: e, onChange: t, placeholder: n = "Select dates", disabled: o = !1, className: r, dateFormat: s = "d/M/yyyy", minDate: i, maxDate: a, disabledDates: l, dir: f = "ltr" }) {
  const [u, d] = c.useState(!1), [g, h] = c.useState(e?.from || /* @__PURE__ */ new Date()), [p, D] = c.useState(e);
  c.useEffect(() => {
    u && (D(e), h(e?.from || /* @__PURE__ */ new Date()));
  }, [u, e]);
  const b = We(i, a, l), C = () => e?.from ? e?.to ? `${F(e.from, s)} - ${F(e.to, s)}` : F(e.from, s) : n, w = () => p?.from ? p?.to ? `${F(p.from, s)} - ${F(p.to, s)}` : F(p.from, s) : "Select dates";
  return /* @__PURE__ */ (0, y.jsx)(ot, {
    open: u,
    onOpenChange: d,
    disabled: o,
    className: r,
    dir: f,
    triggerLabel: C(),
    month: g,
    onMonthChange: h,
    displayContent: p?.from ? w() : /* @__PURE__ */ (0, y.jsx)("span", {
      className: "text-muted-foreground",
      children: "Select dates"
    }),
    onToday: () => {
      const k = /* @__PURE__ */ new Date();
      D({
        from: k,
        to: k
      }), h(k);
    },
    onApply: () => {
      t?.(p), d(!1);
    },
    onCancel: () => {
      D(e), d(!1);
    },
    children: /* @__PURE__ */ (0, y.jsx)(Ce, {
      mode: "range",
      selected: p,
      onSelect: D,
      month: g,
      onMonthChange: h,
      disabled: b,
      showOutsideDays: !0,
      weekStartsOn: 1,
      dir: f,
      className: "p-0",
      classNames: Jt,
      formatters: Se,
      components: Qt
    })
  });
}
Lt.displayName = "DatePicker";
Ir.displayName = "DateRangePicker";
Fr.displayName = "TimePicker";
Ar.displayName = "DateFilterButton";
$r.displayName = "DateRangeFilterButton";
var zr = Tn();
function Hr(e) {
  return { onChange: (t) => {
    e.dispatchEvent(new CustomEvent("change", {
      detail: t,
      bubbles: !0,
      composed: !0
    }));
  } };
}
function Rr(e) {
  const { _hostElement: t, ...n } = e, o = c.useMemo(() => t ? Hr(t) : {}, [t]);
  return c.createElement(Lt, {
    ...n,
    ...o
  });
}
var pe = {
  value: "string",
  placeholder: "string",
  disabled: "boolean",
  className: "string",
  dateFormat: "string",
  minDate: "string",
  maxDate: "string",
  disabledDates: "json",
  dir: "string"
};
function vt(e, t) {
  if (e !== null)
    switch (t) {
      case "number":
        return Number(e);
      case "boolean":
        return e !== "false" && e !== "0";
      case "json":
        try {
          return JSON.parse(e);
        } catch {
          return e;
        }
      default:
        return e;
    }
}
var en = class extends HTMLElement {
  _root = null;
  _childrenContainer = null;
  _props = {};
  _initialized = !1;
  connectedCallback() {
    setTimeout(() => this._initialize(), 0);
  }
  _initialize() {
    if (this._initialized) return;
    this._initialized = !0;
    const e = [];
    for (const n of Array.from(this.childNodes))
      n.nodeType === Node.TEXT_NODE && !n.textContent?.trim() || e.push(n);
    const t = document.createElement("div");
    for (t.style.display = "contents", this._childrenContainer = document.createElement("div"), this._childrenContainer.style.display = "contents", e.forEach((n) => this._childrenContainer.appendChild(n)); this.firstChild; ) this.removeChild(this.firstChild);
    this.appendChild(t), this._root = (0, zr.createRoot)(t), this._render();
  }
  disconnectedCallback() {
    this._root?.unmount(), this._root = null;
  }
  attributeChangedCallback(e, t, n) {
    this._render();
  }
  static get observedAttributes() {
    return Object.keys(pe).map((e) => e.replace(/([A-Z])/g, "-$1").toLowerCase());
  }
  _setProp(e, t) {
    const n = pe[e] || "string";
    this._props[e] = this._parseValue(t, n), this._render();
  }
  _parseValue(e, t) {
    if (t === "boolean" && typeof e == "boolean" || t === "number" && typeof e == "number" || t === "string" && typeof e == "string") return e;
    if (typeof e == "string") switch (t) {
      case "boolean":
        return e !== "false" && e !== "0" && e !== "";
      case "number":
        return Number(e);
      case "json":
        try {
          return JSON.parse(e);
        } catch {
          return e;
        }
      default:
        return e;
    }
    return e;
  }
  _getProp(e) {
    if (e in this._props) return this._props[e];
    const t = e.replace(/([A-Z])/g, "-$1").toLowerCase(), n = pe[e] || "string";
    return vt(this.getAttribute(t), n);
  }
  _render() {
    if (!this._root) return;
    const e = {};
    for (const [n, o] of Object.entries(pe)) if (n in this._props) e[n] = this._props[n];
    else {
      const r = n.replace(/([A-Z])/g, "-$1").toLowerCase();
      e[n] = vt(this.getAttribute(r), o);
    }
    const t = c.createElement(Rr, {
      ...e,
      _hostElement: this
    });
    this._root.render(t);
  }
};
for (const e of Object.keys(pe)) Object.defineProperty(en.prototype, e, {
  get() {
    return this._getProp(e);
  },
  set(t) {
    this._setProp(e, t);
  },
  enumerable: !0,
  configurable: !0
});
typeof customElements < "u" && !customElements.get("hf-date-picker") && customElements.define("hf-date-picker", en);
export {
  en as DatePickerWC,
  en as default
};

//# sourceMappingURL=hf-date-picker.js.map