import { jsx } from 'react/jsx-runtime';
import { forwardRef } from 'react';
import { Field, getIn } from 'formik';
import { dissoc } from 'ramda';
import { C as Checkbox } from '../Checkbox-C_Rd2-8Z.js';
import '../utils-BJnb9o5c.js';
import '../primitives/Checkbox.js';
import '../check-Cpkv29p1.js';
import '../createLucideIcon-C8ycilSN.js';
import '../index-BtkPdosV.js';
import '../index-CiyxEyB0.js';
import '../index-DNzunGHb.js';
import '../index-Cor698lu.js';
import '../index-DOzu5J1s.js';
import '../index-30QpKM0j.js';
import '../index-BYZaLNq1.js';
import '../index-yFgkK_AM.js';
import '../index-DhnfW8wQ.js';
import 'react-dom';
import '../primitives/Field.js';
import '../index-Bo3AAQJp.js';
import '../label-BgLSVt4u.js';
import '../separator-ByRsc-y-.js';

const FormikCheckbox = forwardRef(
  ({
    name,
    onCheckedChange: onCheckedChangeProp,
    onChange: onChangeProp,
    ...rest
  }, ref) => /* @__PURE__ */ jsx(Field, { name, children: ({ field, meta, form }) => {
    const { status = {}, setStatus } = form;
    const fieldStatus = getIn(status, name);
    return /* @__PURE__ */ jsx(
      Checkbox,
      {
        ref,
        checked: !!field.value,
        error: meta.touched ? meta.error || fieldStatus : "",
        name: field.name,
        onBlur: field.onBlur,
        onCheckedChange: (checked) => {
          setStatus(dissoc(name, status));
          form.setFieldValue(name, checked);
          onCheckedChangeProp?.(checked);
          onChangeProp?.();
        },
        ...rest
      }
    );
  } })
);
FormikCheckbox.displayName = "FormikCheckbox";

export { FormikCheckbox };
//# sourceMappingURL=Checkbox.js.map
