import { jsx as e, jsxs as y, Fragment as z } from "@emotion/react/jsx-runtime";
import { useFormContext as E, Controller as H } from "react-hook-form";
import M from "@mui/material/utils/useId";
import { getPropDataTestId as L } from "../../../test/getNameDataTestId.js";
import { useComponentSize as P } from "../../../hooks/useComponentSize/index.js";
import { Label as T } from "../../Label/Label.js";
import { HelperError as j } from "../../HelperError/HelperError.js";
import { NumberInput as v } from "../../NumberInput/NumberInput.js";
import { RHFNumberInputSlots as w } from "./slots/RHFNumberInputEnum.js";
import { RHF_NUMBER_INPUT_KEY_COMPONENT as A } from "./constants.js";
import { RootStyled as O } from "./slots/RHFNumberInputSlots.js";
const Z = (n) => {
  const {
    name: s,
    max: a,
    min: i,
    step: l,
    disabled: d,
    size: o = "medium",
    variant: p = "outlined",
    label: m,
    symbol: c,
    mandatory: f,
    mandatoryMessage: u,
    helperMessage: g,
    startAdornment: h,
    endAdornment: S,
    ...b
  } = n, { control: F } = E(), { currentSize: C } = P(o), I = {
    iconSize: C
  }, t = M();
  return /* @__PURE__ */ e(
    O,
    {
      ownerState: { ...I },
      ...L(A, w.root),
      children: /* @__PURE__ */ e(
        H,
        {
          name: s,
          control: F,
          render: ({ field: { value: N, onChange: x }, fieldState: { error: r }, formState: { isSubmitting: R } }) => /* @__PURE__ */ y(z, { children: [
            m && /* @__PURE__ */ e(
              T,
              {
                htmlFor: t,
                label: m,
                symbol: c,
                mandatory: f,
                mandatoryMessage: u,
                helperMessage: g,
                size: o
              }
            ),
            /* @__PURE__ */ e(
              v,
              {
                id: t,
                size: o,
                step: l,
                max: a,
                min: i,
                value: N,
                onChange: (B, _) => {
                  x(_);
                },
                variant: p,
                disabled: d || R,
                startAdornment: h,
                endAdornment: S,
                error: !!r,
                ...b
              }
            ),
            r?.message && /* @__PURE__ */ e(j, { htmlFor: t, size: o, message: r.message })
          ] })
        }
      )
    }
  );
};
export {
  Z as RHFNumberInput
};
