import { jsx as e, jsxs as N } from "react/jsx-runtime";
import { useState as c, useMemo as F, useCallback as b, useEffect as K } from "react";
import { t as m } from "../global.module.js";
import { B as L, a as T } from "../tools/icons.js";
import { g as D, c as A, s as E, a as V, j as W, l as _, b as u } from "../tools/tools.js";
import { f as q } from "../lite.js";
const k = /* @__PURE__ */ new Date(), z = function(w) {
  const {
    as: M = "div",
    className: h,
    dropOldClass: v,
    locale: l,
    onDateClick: i,
    selectedDate: d,
    style: C,
    variables: g,
    ...P
  } = w, [o, S] = c(k.getFullYear()), [n, B] = c(k.getMonth()), [R, x] = c(
    D(o, n, [], 6, 1, void 0, d, l, !1, "month")
  ), [p, y] = c(null), Y = F(() => {
    const a = A(!v && "card card-body border-0 p-0", h), t = E((r, s) => ({ tKey: V(s) }), g, C);
    return {
      className: a,
      style: t
    };
  }, [h, v, C, g]), f = b(
    (a) => {
      const t = new Date(o + a, n);
      S(t.getFullYear()), B(t.getMonth());
    },
    [n, o]
  ), j = b(
    (a, t, r) => {
      const s = { ...a, active: !0 };
      x((O) => W(s, t, r, O)), p ? (i == null || i({ date: _(p, s.date) }), y(null)) : y(s.date);
    },
    [i, p]
  );
  return K(() => {
    x(
      D(o, n, [], 6, 1, void 0, d, l, !1, "month")
    );
  }, [n, o, l, d]), /* @__PURE__ */ e(M, { ...P, ...Y, children: /* @__PURE__ */ N("div", { className: "list-group border-0 row-gap-1 px-3", children: [
    /* @__PURE__ */ N("div", { className: "row align-items-center position-relative text-center mb-2", children: [
      /* @__PURE__ */ e("div", { className: "col px-1", onClick: () => f(-1), children: /* @__PURE__ */ e(
        "div",
        {
          className: u(
            null,
            "user-select-none list-group-item list-group-item-action border-0 px-0 py-1 rounded text-secondary",
            m.brlCursorPointer
          ),
          children: /* @__PURE__ */ e(L, {})
        }
      ) }),
      /* @__PURE__ */ e("div", { className: "col px-1" }),
      /* @__PURE__ */ e("div", { className: "col px-1" }),
      /* @__PURE__ */ e("div", { className: "col px-1", onClick: () => f(1), children: /* @__PURE__ */ e(
        "div",
        {
          className: u(
            null,
            "user-select-none list-group-item list-group-item-action border-0 px-0 py-1 rounded text-secondary",
            m.brlCursorPointer
          ),
          children: /* @__PURE__ */ e(T, {})
        }
      ) }),
      /* @__PURE__ */ e("div", { className: "position-absolute top-50 start-50 translate-middle w-auto text-nowrap", children: q(new Date(o, n), "yyyy", {
        locale: l
      }) })
    ] }),
    R.rows.map((a, t) => /* @__PURE__ */ e("div", { className: "row text-center", children: a.map((r, s) => /* @__PURE__ */ e("div", { className: "col px-1", onClick: () => j(r, t, s), children: /* @__PURE__ */ e(
      "div",
      {
        className: u(
          null,
          "position-relative list-group-item list-group-item-action px-0 py-1 rounded border-0",
          m.brlCursorPointer,
          r.active && "active"
        ),
        children: r.value
      }
    ) }, r.value)) }, t))
  ] }) });
};
z.displayName = "BRL.DateRangePickerMonth";
export {
  z as D
};
//# sourceMappingURL=date-range-picker-month.js.map
