import { jsx as e, jsxs as c } from "react/jsx-runtime";
import { b as R, c as T, $ as S, d as A, e as F, f as I, g as z, h as L, i as N } from "./Heading-C0SIgP_B.es.js";
import { createSlotRecipeContext as j } from "@chakra-ui/react";
import { j as B } from "./index-N3Xxo-X9.es.js";
import { useRecipe as G } from "@chakra-ui/react/styled-system";
import { e as H } from "./extract-style-props-CMyV-es-.es.js";
import { c as l, d as _ } from "./useDateFormatter-C0T2-xr7.es.js";
import { useContext as u } from "react";
import { $ as b } from "./Button-C9AKe3Kt.es.js";
import { e as k, c as P } from "./utils-CrjF8U_E.es.js";
import { $ } from "./Text-DOcU1ycg.es.js";
import { n as f, u as V } from "./normalize-messages-BN9BAFXe.es.js";
import { $ as w } from "./context-BfHy4NgG.es.js";
import { KeyboardArrowLeft as C, KeyboardArrowRight as v } from "@commercetools/nimbus-icons";
import { F as J } from "./flex-BqxAMF-7.es.js";
import { S as y } from "./stack-CoNreM7B.es.js";
import { V as K } from "./visually-hidden-DVHn3y3w.es.js";
import { I as p } from "./icon-button-DQaOMIAe.es.js";
import { T as M } from "./text-iTgAZrNO.es.js";
import { B as D } from "./box-DuBoAZvq.es.js";
const { withProvider: W, withContext: s } = /* @__PURE__ */ j({
  key: "nimbusRangeCalendar"
}), q = /* @__PURE__ */ W("div", "root"), E = /* @__PURE__ */ s("div", "header"), O = /* @__PURE__ */ s("div", "grids"), Q = /* @__PURE__ */ s("div", "monthTitle"), U = /* @__PURE__ */ s("table", "grid"), X = /* @__PURE__ */ s("thead", "gridHeader"), Z = /* @__PURE__ */ s("th", "headerCell"), ee = /* @__PURE__ */ s("tbody", "gridBody"), te = /* @__PURE__ */ s("td", "bodyCell"), oe = {
  nextMonth: "Next month",
  nextYear: "Next year",
  previousMonth: "Previous month",
  previousYear: "Previous year"
}, re = {
  nextMonth: "Nächsten Monat",
  nextYear: "Nächstes Jahr",
  previousMonth: "Letzten Monat",
  previousYear: "Letztes Jahr"
}, ae = {
  nextMonth: "Mes próximo",
  nextYear: "Año próximo",
  previousMonth: "Mes anterior",
  previousYear: "Año anterior"
}, ne = {
  nextMonth: "Mois suivant",
  nextYear: "Année suivante",
  previousMonth: "Mois précédent",
  previousYear: "Année précédente"
}, se = {
  nextMonth: "Próximo mês",
  nextYear: "Próximo ano",
  previousMonth: "Mês anterior",
  previousYear: "Ano anterior"
}, ie = {
  en: /* @__PURE__ */ f(oe),
  de: /* @__PURE__ */ f(re),
  es: /* @__PURE__ */ f(ae),
  "fr-FR": /* @__PURE__ */ f(ne),
  "pt-BR": /* @__PURE__ */ f(se)
}, de = ({
  children: i
}) => {
  const { locale: a } = w(), t = V(ie), r = u(b), n = u($), o = u(R), g = {
    "next-month": {
      onPress: () => o.focusNextSection(),
      "aria-label": t.format("nextMonth")
    },
    "previous-month": {
      onPress: () => o.focusPreviousSection(),
      "aria-label": t.format("previousMonth")
    },
    "next-year": {
      onPress: () => o.focusNextSection(!0),
      "aria-label": t.format("nextYear")
    },
    "previous-year": {
      onPress: () => o.focusPreviousSection(!0),
      "aria-label": t.format("previousYear")
    }
  }, m = new Intl.DateTimeFormat(a, {
    month: "long"
  }).format(o.focusedDate.toDate(l())), x = [
    new Intl.DateTimeFormat(a, {
      month: "long"
    }).format(o.visibleRange.start.toDate(l())),
    new Intl.DateTimeFormat(a, {
      month: "long"
    }).format(o.visibleRange.end.toDate(l()))
  ].join(" - "), h = new Intl.DateTimeFormat(a, {
    year: "numeric"
  }).format(o.focusedDate.toDate(l())), d = {
    month: { children: m },
    monthRange: { children: x },
    year: { children: h }
  };
  return /* @__PURE__ */ e(
    k,
    {
      values: [
        [
          b,
          {
            ...r,
            slots: {
              ...r && typeof r == "object" && "slots" in r ? r.slots : {},
              ...g
            }
          }
        ],
        [
          $,
          {
            ...n,
            slots: {
              ...n && typeof n == "object" && "slots" in n ? n.slots : {},
              ...d
            }
          }
        ]
      ],
      children: i
    }
  );
}, le = () => {
  const t = (P(S)?.visibleDuration?.months || 1) > 1;
  return /* @__PURE__ */ e(E, { children: /* @__PURE__ */ c(J, { children: [
    /* @__PURE__ */ c(y, { direction: "row", alignItems: "center", children: [
      /* @__PURE__ */ e(K, { children: /* @__PURE__ */ e(T, {}) }),
      /* @__PURE__ */ e(
        p,
        {
          slot: t ? "previous" : "previous-month",
          size: "xs",
          variant: "ghost",
          colorPalette: "primary",
          children: /* @__PURE__ */ e(C, {})
        }
      ),
      /* @__PURE__ */ e(
        M,
        {
          textStyle: "sm",
          fontWeight: "500",
          color: "neutral.11",
          width: t ? "4000" : "2000",
          textAlign: "center",
          "aria-hidden": "true",
          slot: t ? "monthRange" : "month"
        }
      ),
      /* @__PURE__ */ e(
        p,
        {
          slot: t ? "next" : "next-month",
          size: "xs",
          variant: "ghost",
          colorPalette: "primary",
          children: /* @__PURE__ */ e(v, {})
        }
      )
    ] }),
    /* @__PURE__ */ e(D, { flexGrow: "1" }),
    /* @__PURE__ */ c(y, { direction: "row", alignItems: "center", children: [
      /* @__PURE__ */ e(
        p,
        {
          slot: "previous-year",
          size: "xs",
          variant: "ghost",
          colorPalette: "primary",
          children: /* @__PURE__ */ e(C, {})
        }
      ),
      /* @__PURE__ */ e(
        M,
        {
          textStyle: "sm",
          fontWeight: "500",
          color: "neutral.11",
          width: "1400",
          textAlign: "center",
          "aria-hidden": "true",
          slot: "year"
        }
      ),
      /* @__PURE__ */ e(
        p,
        {
          slot: "next-year",
          size: "xs",
          variant: "ghost",
          colorPalette: "primary",
          children: /* @__PURE__ */ e(v, {})
        }
      )
    ] })
  ] }) });
}, ce = () => {
  const { locale: i } = w(), a = P(S), t = u(R), r = a?.visibleDuration?.months || 1, n = _(l()), o = r > 1;
  return /* @__PURE__ */ e(O, { children: Array.from({ length: r }, (g, m) => {
    const x = t.visibleRange.start.add({
      months: m
    }), h = new Intl.DateTimeFormat(i, {
      month: "long"
    }).format(x.toDate(l()));
    return /* @__PURE__ */ c(
      D,
      {
        width: r == 1 ? "full" : "auto",
        children: [
          o && /* @__PURE__ */ e(Q, { children: h }),
          /* @__PURE__ */ e(U, { asChild: !0, children: /* @__PURE__ */ c(A, { offset: { months: m }, weekdayStyle: "short", children: [
            /* @__PURE__ */ e(X, { asChild: !0, children: /* @__PURE__ */ e(F, { children: (d) => /* @__PURE__ */ e(Z, { asChild: !0, children: /* @__PURE__ */ e(I, { children: d }) }) }) }),
            /* @__PURE__ */ e(ee, { asChild: !0, children: /* @__PURE__ */ e(z, { children: (d) => {
              const Y = d.compare(n) === 0;
              return /* @__PURE__ */ e(te, { asChild: !0, "data-today": Y, children: /* @__PURE__ */ e(L, { date: d }) });
            } }) })
          ] }) })
        ]
      },
      h
    );
  }) });
}, fe = (i) => {
  const a = G({ recipe: B }), [t, r] = a.splitVariantProps(i), [n, o] = H(r);
  return /* @__PURE__ */ e(q, { ...t, ...n, asChild: !0, children: /* @__PURE__ */ e(N, { ...o, children: /* @__PURE__ */ c(de, { children: [
    /* @__PURE__ */ e(le, {}),
    /* @__PURE__ */ e(ce, {})
  ] }) }) });
};
fe.displayName = "RangeCalendar";
export {
  fe as R
};
//# sourceMappingURL=range-calendar-BkRTn3qu.es.js.map
