import { jsx } from "react/jsx-runtime";
import { u as useFormContext, C as Controller } from "../../../index.esm-D7jRhDaG.js";
import BaseCheckbox from "../../vendor/Checkbox.js";
const Checkbox = ({
  name,
  label,
  value,
  helpText,
  error,
  required,
  ...otherProps
}) => {
  const {
    control,
    formState: { errors }
  } = useFormContext();
  return /* @__PURE__ */ jsx(
    Controller,
    {
      name,
      control,
      render: ({ field }) => {
        var _a;
        return /* @__PURE__ */ jsx(
          BaseCheckbox,
          {
            label,
            controlledChecked: Boolean(field.value),
            helpText,
            error: (error == null ? void 0 : error.message) ?? ((_a = errors[name]) == null ? void 0 : _a.message),
            required,
            ...otherProps,
            ...field,
            value: field.value
          }
        );
      }
    }
  );
};
export {
  Checkbox
};
//# sourceMappingURL=Checkbox.js.map
