'use strict';

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

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

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

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

function CheckboxGroup(_a) {
    var { value, options, onChange, name, groupLabel, orientation = 'row', id, hasError = false, errorText, disabled = false, assistText } = _a, props = _tslib.__rest(_a, ["value", "options", "onChange", "name", "groupLabel", "orientation", "id", "hasError", "errorText", "disabled", "assistText"]);
    const appendTestId = index.getId(props['data-testid']);
    const appendTrackId = index.getId(props['data-trackid']);
    return (React__default['default'].createElement(styles.CheckRadioInputGroupWrapper, null,
        groupLabel && (React__default['default'].createElement(styles.CheckRadioGroupLabel, { "data-testid": appendTestId('group-label'), "data-trackid": appendTrackId('group-label') }, groupLabel)),
        options && (React__default['default'].createElement(styles.CheckRadioGroupWrapper, { orientation: orientation }, options.map((buttonProps) => (React__default['default'].createElement(CheckboxInput.CheckboxInput, { key: buttonProps.value, label: buttonProps.label, value: buttonProps.value, id: buttonProps.id, name: name, hasError: hasError, disabled: disabled || buttonProps.disabled, onChange: onChange, "data-testid": appendTestId(buttonProps['data-testid']), "data-trackid": appendTrackId(buttonProps['data-trackid']), "aria-label": buttonProps.label, indeterminate: buttonProps.indeterminate, checked: buttonProps.checked }))))),
        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))));
}

exports.CheckboxGroup = CheckboxGroup;
