import _defineProperty from '@babel/runtime/helpers/defineProperty';
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
import 'react';
import { useFormikContext, useField, getIn } from 'formik';
import { dissoc } from 'ramda';
import Radio from '../Radio.js';
import { jsx } from 'react/jsx-runtime';
import 'classnames';
import '../Label.js';
import '@bigbinary/neeto-icons/Help';
import '../Button.js';
import 'react-router-dom';
import '../Spinner.js';
import '../Tooltip.js';
import '@tippyjs/react';
import 'tippy.js';
import '@bigbinary/neeto-hotkeys';
import '../overlayManager.js';
import '@babel/runtime/helpers/classCallCheck';
import '@babel/runtime/helpers/createClass';
import '@bigbinary/neeto-cist';
import 'qs';
import '../index-DyUNP5G9.js';
import '@babel/runtime/helpers/toConsumableArray';
import 'dayjs';
import 'dayjs/plugin/localeData';
import 'dayjs/plugin/utc';
import 'dayjs/plugin/weekday';
import 'dayjs/plugin/weekOfYear';
import 'i18next';
import '../usePrefersReducedMotion-n4ZJtExQ.js';
import '../Popover.js';
import '../Typography.js';
import '../useId-Jj9hXm-g.js';
import '../index-QWVp_Xt6.js';
import '../en-Dmu3B4Vs.js';

var _excluded = ["label", "name", "className"];
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
var RadioGroup = function RadioGroup(_ref) {
  var label = _ref.label,
    name = _ref.name,
    _ref$className = _ref.className,
    className = _ref$className === void 0 ? "" : _ref$className,
    props = _objectWithoutProperties(_ref, _excluded);
  var _useFormikContext = useFormikContext(),
    setFieldValue = _useFormikContext.setFieldValue,
    _useFormikContext$sta = _useFormikContext.status,
    status = _useFormikContext$sta === void 0 ? {} : _useFormikContext$sta,
    setStatus = _useFormikContext.setStatus;
  var _useField = useField({
      name: name
    }),
    _useField2 = _slicedToArray(_useField, 2),
    field = _useField2[0],
    meta = _useField2[1];
  var fieldStatus = getIn(status, name);
  var fieldProps = _objectSpread(_objectSpread({}, field), {}, {
    onChange: function onChange(event) {
      setStatus(dissoc(name, status));
      setFieldValue(name, event.target.value);
    }
  });
  return /*#__PURE__*/jsx(Radio, _objectSpread({
    error: meta.touched ? meta.error || fieldStatus : ""
  }, _objectSpread(_objectSpread({
    className: className,
    label: label
  }, fieldProps), props)));
};
RadioGroup.Item = Radio.Item;

export { RadioGroup as default };
//# sourceMappingURL=Radio.js.map
