"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const jsxRuntime = require("react/jsx-runtime");
const errorMessage = require("@hookform/error-message");
const reactHookForm = require("react-hook-form");
;/* empty css                                                                                                                                                                                        */
;/* empty css                                                                                                                                                                                         */
;/* empty css                                                                                                                                                                                                 */
;/* empty css                                                                                                                                                                                            */
;/* empty css                                                                                                                                                                                            */
require("clsx");
const styles = require("../../utils/styles.cjs");
const Input = require("../../node_modules/.pnpm/@mantine_core@7.15.2_patch_hash_jclkxeaefn6uz54h34k3r3yjsq_@mantine_hooks@7.15.2_react@18.3.1_szqfuioo5damkjdixckhzmwycq/node_modules/@mantine/core/esm/components/Input/Input.cjs");
const Rating = require("../../node_modules/.pnpm/@mantine_core@7.15.2_patch_hash_jclkxeaefn6uz54h34k3r3yjsq_@mantine_hooks@7.15.2_react@18.3.1_szqfuioo5damkjdixckhzmwycq/node_modules/@mantine/core/esm/components/Rating/Rating.cjs");
const FormRatingInput = ({
  name,
  label,
  withAsterisk,
  rules,
  wrapperProps,
  ...rest
}) => {
  const { control, formState, getFieldState } = reactHookForm.useFormContext();
  const { error } = getFieldState(name, formState);
  return /* @__PURE__ */ jsxRuntime.jsx(
    reactHookForm.Controller,
    {
      name,
      control,
      rules,
      render: ({ field: { onChange, value } }) => {
        return /* @__PURE__ */ jsxRuntime.jsx(
          Input.Input.Wrapper,
          {
            error: error ? /* @__PURE__ */ jsxRuntime.jsx(errorMessage.ErrorMessage, { errors: formState.errors, name }) : void 0,
            label,
            withAsterisk,
            ...wrapperProps,
            styles: styles.mergeStylesList([
              () => ({
                label: {
                  marginBottom: 10
                },
                error: {
                  marginTop: 8
                }
              }),
              (wrapperProps == null ? void 0 : wrapperProps.styles) || {}
            ]),
            children: /* @__PURE__ */ jsxRuntime.jsx(Rating.Rating, { onChange, value, ...rest })
          }
        );
      }
    }
  );
};
exports.FormRatingInput = FormRatingInput;
