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