import { jsx as e, jsxs as s, Fragment as d } from "@emotion/react/jsx-runtime";
import { forwardRef as C, useId as v } from "react";
import { useModuleSkeleton as w } from "@m4l/core";
import { useComponentSize as N } from "../../../../hooks/useComponentSize/index.js";
import { RadioRootStyled as g, MUIRadioStyled as A, InlineTextStyled as O, SkeletonStyled as c } from "./slots/styled.js";
import { getComponentSlotRoot as T } from "../../../../utils/getComponentSlotRoot.js";
import { RADIO_CLASSES as D, RADIO_KEY_COMPONENT as E } from "./constants.js";
import F from "clsx";
import { getOptionLabelColor as M } from "../../../../utils/getOptionLabelColor.js";
import { Icon as m } from "@m4l/base";
import { ActionsRadioButtonUncheckDuotone as _, ActionsRadioButtonCheckFill as j } from "@m4l/icons";
const Q = C(
  (p, S) => {
    const {
      className: u,
      size: f = "medium",
      disabled: o,
      color: b = "default",
      error: t,
      checked: i = !1,
      inlineText: r,
      onChange: h,
      value: R,
      id: k,
      ...x
    } = p, { currentSize: l } = N(f), I = w(), y = T(E), z = v(), n = k || z, a = {
      disabled: o,
      color: b,
      error: t,
      size: l,
      checked: i
    };
    return /* @__PURE__ */ e(
      g,
      {
        ownerState: { ...a },
        className: F(u, y),
        children: I ? /* @__PURE__ */ s(d, { children: [
          /* @__PURE__ */ e(c, { variant: "rounded", className: D.skeleton }),
          r ? /* @__PURE__ */ e(
            c,
            {
              variant: "rectangular",
              className: "radioSkeletonInlineText"
            }
          ) : null
        ] }) : /* @__PURE__ */ s(d, { children: [
          /* @__PURE__ */ e(
            A,
            {
              ref: S,
              id: n,
              ownerState: { ...a },
              disableRipple: !0,
              checked: i,
              checkedIcon: /* @__PURE__ */ e(
                m,
                {
                  src: /* @__PURE__ */ e(j, {}),
                  size: l,
                  color: o ? "text.disabled" : t ? "error.enabled" : "primary.enabled"
                }
              ),
              icon: /* @__PURE__ */ e(
                m,
                {
                  src: /* @__PURE__ */ e(_, {}),
                  size: l,
                  color: o ? "text.disabled" : t ? "error.enabled" : "text.secondary"
                }
              ),
              disabled: o,
              inputProps: {
                "aria-invalid": t ? "true" : void 0,
                // 'aria-label': value+ '',
                "aria-label": "Select row",
                ...r && { "aria-labelledby": `${n}-label` }
              },
              value: R,
              onChange: h,
              ...x
            }
          ),
          r && /* @__PURE__ */ e(
            O,
            {
              id: `${n}-label`,
              component: "label",
              htmlFor: n,
              variant: "bodyStandard",
              color: M(i, o),
              ownerState: { ...a },
              size: l,
              disabled: o,
              ellipsis: !0,
              children: r
            }
          )
        ] })
      }
    );
  }
);
export {
  Q as Radio
};
