import { jsx as e, jsxs as l } from "react/jsx-runtime";
import { j as S, d as T, e as A, f as I, g as z, h as F, a as P, c as L, k as N } from "./Heading-BMsylHxq.es.js";
import { createSlotRecipeContext as j } from "@chakra-ui/react";
import { useSlotRecipe as B } from "@chakra-ui/react/styled-system";
import { e as G } from "./extract-style-props-BdibuNZ7.es.js";
import { c, d as H } from "./useDateFormatter-9juUpmrj.es.js";
import { useContext as u } from "react";
import { $ as b } from "./Button-BjcDZ5eb.es.js";
import { e as _, c as w } from "./utils-B6pV5ewr.es.js";
import { $ as v } from "./Text-DOcU1ycg.es.js";
import { n as f, u as k } from "./normalize-messages-D5T4I93D.es.js";
import { $ as D } from "./context-DW7UvQ8z.es.js";
import { KeyboardArrowLeft as g, KeyboardArrowRight as y } from "@commercetools/nimbus-icons";
import { T as C } from "./text-CIb_VDvO.es.js";
import { Flex as V } from "@chakra-ui/react/flex";
import { S as M } from "./stack-CoNreM7B.es.js";
import { V as J } from "./visually-hidden-Dj5CT-u_.es.js";
import { I as p } from "./icon-button-CosIm3oY.es.js";
import { B as R } from "./box-DuBoAZvq.es.js";
const { withProvider: K, withContext: s } = /* @__PURE__ */ j({
  key: "calendar"
}), W = /* @__PURE__ */ K("div", "root"), q = /* @__PURE__ */ s("div", "header"), E = /* @__PURE__ */ s("div", "grids"), O = /* @__PURE__ */ s("div", "monthTitle"), Q = /* @__PURE__ */ s("table", "grid"), U = /* @__PURE__ */ s("thead", "gridHeader"), X = /* @__PURE__ */ s("th", "headerCell"), Z = /* @__PURE__ */ s("tbody", "gridBody"), ee = /* @__PURE__ */ s("td", "bodyCell"), te = {
  nextMonth: "Next month",
  nextYear: "Next year",
  previousMonth: "Previous month",
  previousYear: "Previous year"
}, oe = {
  nextMonth: "Nächsten Monat",
  nextYear: "Nächstes Jahr",
  previousMonth: "Letzten Monat",
  previousYear: "Letztes Jahr"
}, re = {
  nextMonth: "Próximo mes",
  nextYear: "Próximo año",
  previousMonth: "Mes anterior",
  previousYear: "Año anterior"
}, ae = {
  nextMonth: "Mois suivant",
  nextYear: "Année suivante",
  previousMonth: "Mois précédent",
  previousYear: "Année précédente"
}, ne = {
  nextMonth: "Próximo mês",
  nextYear: "Próximo ano",
  previousMonth: "Mês anterior",
  previousYear: "Ano anterior"
}, se = {
  en: /* @__PURE__ */ f(te),
  de: /* @__PURE__ */ f(oe),
  es: /* @__PURE__ */ f(re),
  "fr-FR": /* @__PURE__ */ f(ae),
  "pt-BR": /* @__PURE__ */ f(ne)
}, ie = ({
  children: i
}) => {
  const { locale: a } = D(), t = k(se), r = u(b), n = u(v), o = u(S), $ = {
    "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(c())), x = [
    new Intl.DateTimeFormat(a, {
      month: "long"
    }).format(o.visibleRange.start.toDate(c())),
    new Intl.DateTimeFormat(a, {
      month: "long"
    }).format(o.visibleRange.end.toDate(c()))
  ].join(" - "), h = new Intl.DateTimeFormat(a, {
    year: "numeric"
  }).format(o.focusedDate.toDate(c())), d = {
    month: { children: m },
    monthRange: { children: x },
    year: { children: h }
  };
  return /* @__PURE__ */ e(
    _,
    {
      values: [
        [
          b,
          {
            ...r,
            slots: {
              ...r && typeof r == "object" && "slots" in r ? r.slots : {},
              ...$
            }
          }
        ],
        [
          v,
          {
            ...n,
            slots: {
              ...n && typeof n == "object" && "slots" in n ? n.slots : {},
              ...d
            }
          }
        ]
      ],
      children: i
    }
  );
}, de = () => {
  const { locale: i } = D(), a = w(P), t = u(S), r = a?.visibleDuration?.months || 1, n = H(c()), o = r > 1;
  return /* @__PURE__ */ e(E, { children: Array.from({ length: r }, ($, m) => {
    const x = t.visibleRange.start.add({
      months: m
    }), h = new Intl.DateTimeFormat(i, {
      month: "long"
    }).format(x.toDate(c()));
    return /* @__PURE__ */ l(
      R,
      {
        width: r == 1 ? "full" : "auto",
        children: [
          o && /* @__PURE__ */ e(O, { children: h }),
          /* @__PURE__ */ e(Q, { asChild: !0, children: /* @__PURE__ */ l(T, { offset: { months: m }, weekdayStyle: "short", children: [
            /* @__PURE__ */ e(U, { asChild: !0, children: /* @__PURE__ */ e(A, { children: (d) => /* @__PURE__ */ e(X, { asChild: !0, children: /* @__PURE__ */ e(I, { children: d }) }) }) }),
            /* @__PURE__ */ e(Z, { asChild: !0, children: /* @__PURE__ */ e(z, { children: (d) => {
              const Y = d.compare(n) === 0;
              return /* @__PURE__ */ e(ee, { asChild: !0, "data-today": Y, children: /* @__PURE__ */ e(F, { date: d }) });
            } }) })
          ] }) })
        ]
      },
      h
    );
  }) });
}, ce = () => {
  const t = (w(P)?.visibleDuration?.months || 1) > 1;
  return /* @__PURE__ */ e(q, { children: /* @__PURE__ */ l(V, { children: [
    /* @__PURE__ */ l(M, { direction: "row", alignItems: "center", children: [
      /* @__PURE__ */ e(J, { children: /* @__PURE__ */ e(L, {}) }),
      /* @__PURE__ */ e(
        p,
        {
          slot: t ? "previous" : "previous-month",
          size: "xs",
          variant: "ghost",
          colorPalette: "primary",
          children: /* @__PURE__ */ e(g, {})
        }
      ),
      /* @__PURE__ */ e(
        C,
        {
          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(y, {})
        }
      )
    ] }),
    /* @__PURE__ */ e(R, { flexGrow: "1" }),
    /* @__PURE__ */ l(M, { direction: "row", alignItems: "center", children: [
      /* @__PURE__ */ e(
        p,
        {
          slot: "previous-year",
          size: "xs",
          variant: "ghost",
          colorPalette: "primary",
          children: /* @__PURE__ */ e(g, {})
        }
      ),
      /* @__PURE__ */ e(
        C,
        {
          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(y, {})
        }
      )
    ] })
  ] }) });
}, Ye = (i) => {
  const a = B({ key: "calendar" }), [t, r] = a.splitVariantProps(i), [n, o] = G(r);
  return /* @__PURE__ */ e(W, { ...t, ...n, asChild: !0, children: /* @__PURE__ */ e(N, { ...o, children: /* @__PURE__ */ l(ie, { children: [
    /* @__PURE__ */ e(ce, {}),
    /* @__PURE__ */ e(de, {})
  ] }) }) });
};
export {
  Ye as C
};
//# sourceMappingURL=calendar-lSoXK-yt.es.js.map
