import { jsx as e, jsxs as c } from "react/jsx-runtime";
/* empty css              */
import { shift as H, offset as K } from "@floating-ui/dom";
import { format as O, getYear as T } from "date-fns";
import { forwardRef as V, useState as Y } from "react";
import y from "react-datepicker";
import q from "../../foundation/Icon/Generated/IconCaretLeft.es.js";
import G from "../../foundation/Icon/Generated/IconCaretLeftDouble.es.js";
import J from "../../foundation/Icon/Generated/IconCaretRight.es.js";
import Q from "../../foundation/Icon/Generated/IconCaretRightDouble.es.js";
import { IconSize as a } from "../../foundation/Icon/IconSize.es.js";
import { Validation as U } from "../../utilities/validation.es.js";
import { DatePickerTrigger as X } from "./DatePickerTrigger.es.js";
import { Button as i } from "../Button/Button.es.js";
import { ButtonStyle as o, ButtonSize as s, ButtonEmphasis as n } from "../Button/ButtonTypes.es.js";
const Z = y.default ?? y, _ = (d, r) => d === "single" ? r < /* @__PURE__ */ new Date() ? "past-date" : "future-date" : "range-day", $ = V(
  ({
    placeHolder: d = "Select a date",
    isClearable: r,
    shouldCloseOnSelect: D,
    onChange: f,
    onOpen: l,
    onClose: m,
    onBlur: h,
    onKeyDown: g,
    dateFormat: k = "MMM dd, yyyy",
    value: C,
    startDate: z,
    endDate: M,
    minDate: S,
    maxDate: x,
    validation: I = U.Default,
    customTrigger: P,
    customHeader: b,
    children: N,
    hasPopperArrow: R = !0,
    preventOpenOnFocus: W = !1,
    filterDate: B = () => !0,
    variant: p = "single",
    "data-test-id": j = "date-picker"
  }, v) => {
    const [u, w] = Y(!1);
    return /* @__PURE__ */ e("div", { "data-test-id": j, children: /* @__PURE__ */ e(
      Z,
      {
        calendarClassName: "tw-rounded-sm tw-border tw-border-line-x-strong react-datepicker-wrap",
        selected: C,
        startDate: z,
        endDate: M,
        minDate: S,
        maxDate: x,
        calendarStartDay: 1,
        onChange: f,
        onKeyDown: u ? void 0 : g,
        onBlur: h,
        selectsRange: p === "range",
        showPopperArrow: R,
        preventOpenOnFocus: W,
        filterDate: B,
        customInput: P ?? /* @__PURE__ */ e(
          X,
          {
            isCalendarOpen: u,
            isClearable: r,
            placeHolder: d,
            validation: I,
            onDateChanged: f
          }
        ),
        ref: v,
        formatWeekDay: (t) => t.slice(0, 1),
        isClearable: r,
        dateFormat: k,
        onCalendarClose: () => {
          w(!1), m == null || m();
        },
        onCalendarOpen: () => {
          w(!0), l == null || l();
        },
        shouldCloseOnSelect: D,
        dayClassName: (t) => _(p, t),
        popperProps: {
          strategy: "fixed"
        },
        popperModifiers: [H({ padding: 8 }), K(8)],
        renderCustomHeader: ({ date: t, decreaseMonth: L, increaseMonth: A, increaseYear: E, decreaseYear: F }) => /* @__PURE__ */ c("div", { className: "tw-flex tw-flex-col tw-gap-3", children: [
          b,
          /* @__PURE__ */ c("div", { className: "tw-flex tw-justify-between tw-pb-4 tw-px-0", children: [
            /* @__PURE__ */ e(
              i,
              {
                style: o.Default,
                size: s.Medium,
                onClick: F,
                emphasis: n.Weak,
                icon: /* @__PURE__ */ e(G, { size: a.Size20 })
              }
            ),
            /* @__PURE__ */ e(
              i,
              {
                style: o.Default,
                size: s.Medium,
                onClick: L,
                emphasis: n.Weak,
                icon: /* @__PURE__ */ e(q, { size: a.Size20 })
              }
            ),
            /* @__PURE__ */ c("p", { className: "tw-font-sans tw-font-semibold tw-grow tw-self-center", children: [
              O(t, "MMMM"),
              " ",
              T(t)
            ] }),
            /* @__PURE__ */ e(
              i,
              {
                style: o.Default,
                size: s.Medium,
                onClick: A,
                emphasis: n.Weak,
                icon: /* @__PURE__ */ e(J, { size: a.Size20 })
              }
            ),
            /* @__PURE__ */ e(
              i,
              {
                style: o.Default,
                size: s.Medium,
                onClick: E,
                emphasis: n.Weak,
                icon: /* @__PURE__ */ e(Q, { size: a.Size20 })
              }
            )
          ] })
        ] }),
        children: N
      }
    ) });
  }
);
$.displayName = "FondueDatePicker";
export {
  $ as DatePicker
};
//# sourceMappingURL=DatePicker.es.js.map
