import { __assign, __rest } from "tslib";
import React, { useContext } from 'react';
import classNames from 'classnames';
import { ConfigContext } from '../config-provider/config-context';
import { getPrefixCls } from '../_utils/general';
var ButtonGroup = React.forwardRef(function (props, ref) {
    var _a;
    var _b = props.size, size = _b === void 0 ? 'md' : _b, _c = props.btnType, btnType = _c === void 0 ? 'default' : _c, _d = props.disabled, disabled = _d === void 0 ? false : _d, _e = props.round, round = _e === void 0 ? false : _e, customisedCls = props.prefixCls, className = props.className, children = props.children, otherProps = __rest(props, ["size", "btnType", "disabled", "round", "prefixCls", "className", "children"]);
    var configContext = useContext(ConfigContext);
    var prefixCls = getPrefixCls('btn-group', configContext.prefixCls, customisedCls);
    var btnSize = props.size || configContext.componentSize || size;
    var cls = classNames(prefixCls, className, (_a = {},
        _a[prefixCls + "_round"] = round,
        _a[prefixCls + "_" + btnType] = btnType,
        _a));
    return (React.createElement("div", __assign({}, otherProps, { className: cls, ref: ref }), React.Children.map(children, function (child) {
        var childElement = child;
        var displayName = childElement.type.displayName;
        if (displayName === 'Button') {
            var childProps = {
                btnType: btnType,
                size: btnSize,
                disabled: 'disabled' in childElement.props ? childElement.props.disabled : disabled,
            };
            return React.cloneElement(childElement, childProps);
        }
        else {
            return child;
        }
    })));
});
ButtonGroup.displayName = 'ButtonGroup';
export default ButtonGroup;
//# sourceMappingURL=button-group.js.map