import { jsx as s } from "@emotion/react/jsx-runtime";
import W from "clsx";
import { forwardRef as b } from "react";
import { DAYS_OF_WEEK_PICKER_CLASSES as o } from "./constants.js";
import { useDaysOfWeekPicker as P } from "./hooks/useDaysOfWeekPicker.js";
import { DaysOfWeekPickerSkeletonStyled as _, DaysOfWeekPickerRootStyled as C, DayButtonStyled as w } from "./slots/DaysOfWeekPickerSlots.js";
const h = b(
  (r, l) => {
    const {
      value: i,
      onChange: n,
      disabledDays: c = [],
      disabled: d = !1,
      readOnly: t = !1,
      size: f,
      className: k,
      multiple: m = !0
    } = r, {
      currentSize: u,
      isSkeleton: D,
      daysOfWeek: S,
      handleDayClick: y,
      isDaySelected: p,
      isDayDisabled: O,
      ownerState: a
    } = P({
      value: i,
      onChange: n,
      disabledDays: c,
      disabled: d,
      readOnly: t,
      size: f,
      multiple: m
    });
    return D ? /* @__PURE__ */ s(
      _,
      {
        ownerState: a,
        ...process.env.NODE_ENV !== "production" ? { "data-testid": "SkeletonDaysOfWeekPicker" } : {}
      }
    ) : /* @__PURE__ */ s(
      C,
      {
        ownerState: a,
        className: W(k, o.root),
        ref: l,
        children: S.map((e) => {
          const v = p(e.value), E = O(e.value), N = {
            ...a,
            selected: v,
            day: e.value,
            readOnly: t
          };
          return /* @__PURE__ */ s(
            w,
            {
              ownerState: N,
              onClick: t ? void 0 : () => y(e.value),
              disabled: E && !t,
              size: u,
              label: e.label,
              className: o.dayButton,
              ...process.env.NODE_ENV !== "production" ? { "data-testid": `day-${e.value}` } : {}
            },
            e.value
          );
        })
      }
    );
  }
);
h.displayName = "DaysOfWeekPicker";
export {
  h as DaysOfWeekPicker
};
