'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var _tslib = require('../../../_virtual/_tslib.js');
var React = require('react');
var styles = require('../styles.js');
var index = require('../../../utils/index.js');
var AlertCircle = require('../../../icons/AlertCircle.js');
var Radio = require('./Radio.js');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var React__default = /*#__PURE__*/_interopDefaultLegacy(React);

function RadioButtonComponent(_a, ref) {
    var { id, name, label, value, checked, onChange = index.noop, disabled = false, hasError = false, errorText, assistText } = _a, props = _tslib.__rest(_a, ["id", "name", "label", "value", "checked", "onChange", "disabled", "hasError", "errorText", "assistText"]);
    const appendTestId = index.getId(props['data-testid']);
    const appendTrackId = index.getId(props['data-testid']);
    if (!id && label) {
        id = index.slugify(label);
    }
    return (React__default['default'].createElement(styles.CheckRadioInputGroupWrapper, null,
        React__default['default'].createElement(Radio.Radio, { id: id, ref: ref, name: name, value: value, checked: checked, disabled: disabled, "aria-checked": props['aria-checked'], onChange: onChange, "data-testid": appendTestId('radio'), "data-trackid": appendTrackId('radio'), "aria-label": props['aria-label'] || label, hasError: hasError, label: label }),
        hasError && errorText && (React__default['default'].createElement(styles.CheckRadioErrorArea, { "data-testid": appendTestId('error'), "data-trackid": appendTrackId('error') },
            React__default['default'].createElement(AlertCircle['default'], null),
            errorText)),
        assistText && !hasError && (React__default['default'].createElement(styles.CheckRadioHintArea, { "data-testid": appendTestId('assistText'), "data-trackid": appendTrackId('assistText') }, assistText))));
}
const RadioButton = React.forwardRef(RadioButtonComponent);

exports.RadioButton = RadioButton;
