import { j as n } from "../../../../_virtual/jsx-runtime.js";
import c from "react";
import { Wrapper as r, DayNum as f, Event as D } from "./styles.js";
import { getIsToday as g } from "../../dateUtils.js";
import { getPrevMonth as l, getNextMonth as u } from "../calendar/utils.js";
const x = c.forwardRef(
  (t, d) => {
    const { disabled: a = !1 } = t;
    function h() {
      if (!a) {
        const e = l(t.currentMonth), i = u(t.currentMonth);
        t.day.getMonth() === e ? t.onChange(t.day, e) : t.day.getMonth() === i ? t.onChange(t.day, i) : t.onChange(t.day);
      }
    }
    function y() {
      return t.isStartDay && t.isEndDay;
    }
    return /* @__PURE__ */ n.jsx(
      r,
      {
        isInRange: t.isInRange && t.selection !== "single-date" && !y(),
        isStartDay: t.isStartDay,
        isEndDay: t.isEndDay,
        onClick: h,
        disabled: a,
        children: /* @__PURE__ */ n.jsxs(
          f,
          {
            ref: d || void 0,
            isStartEndDay: t.isStartDay || t.isEndDay,
            isToday: g(t.day),
            isCurrentMonth: t.day.getMonth() === t.currentMonth || t.currentMonth === 12,
            disabled: a,
            width: t.width,
            tabIndex: t.hasFocus ? 0 : -1,
            children: [
              /* @__PURE__ */ n.jsx("span", { children: t.day.getDate() }),
              t.hasEvent && /* @__PURE__ */ n.jsx(D, { isStartEnd: t.isStartDay || t.isEndDay })
            ]
          }
        )
      }
    );
  }
);
export {
  x as Day
};
