(function (factory) {
    if (typeof module === "object" && typeof module.exports === "object") {
        var v = factory(require, exports);
        if (v !== undefined) module.exports = v;
    }
    else if (typeof define === "function" && define.amd) {
        define(["require", "exports", "tslib", "react", "../../RadioButton", "./RadioGroupContext"], factory);
    }
})(function (require, exports) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var tslib_1 = require("tslib");
    var react_1 = (0, tslib_1.__importStar)(require("react"));
    var RadioButton_1 = (0, tslib_1.__importDefault)(require("../../RadioButton"));
    var RadioGroupContext_1 = require("./RadioGroupContext");
    var RadioGroupOption = function (props) {
        var label = props.label, name = props.name, value = props.value, isDisabled = props.isDisabled, isError = props.isError, className = props.className, children = props.children;
        var _a = (0, react_1.useContext)(RadioGroupContext_1.RadioGroupContext), groupValue = _a.groupValue, onClick = _a.onClick, onChange = _a.onChange;
        if (children) {
            return (0, react_1.cloneElement)(children, (0, tslib_1.__assign)((0, tslib_1.__assign)({}, children.props), { isChecked: children.props.value === groupValue, isError: children.props.value !== groupValue && isError, onChange: onChange, onClick: onClick, name: name, isDisabled: children.props.isDisabled || isDisabled }));
        }
        return (react_1.default.createElement(RadioButton_1.default, { isChecked: value === groupValue, name: name, isDisabled: isDisabled, isError: value !== groupValue && isError, label: label, value: value, onChange: onChange, onClick: onClick, className: className }));
    };
    exports.default = RadioGroupOption;
});
