var __assign = (this && this.__assign) || function () {
    __assign = Object.assign || function(t) {
        for (var s, i = 1, n = arguments.length; i < n; i++) {
            s = arguments[i];
            for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
                t[p] = s[p];
        }
        return t;
    };
    return __assign.apply(this, arguments);
};
import React, { Children, forwardRef } from 'react';
import cls from 'classnames';
import { Button as FusionButton } from '@alifd/next';
import hoist from '../../utils/hoist';
var ExtendedButton = function (props, ref) {
    var _a, _b;
    var className = props.className, children = props.children;
    var count = Children.count(children);
    if (count === 1 && (((_a = children === null || children === void 0 ? void 0 : children.type) === null || _a === void 0 ? void 0 : _a.displayName) === 'Config(Icon)' || ((_b = children === null || children === void 0 ? void 0 : children.type) === null || _b === void 0 ? void 0 : _b.displayName) === 'Icon')) {
        return (React.createElement(FusionButton, __assign({}, __assign(__assign({}, props), { ref: ref, className: cls('isOnlyIcon', className) })), children));
    }
    return React.createElement(FusionButton, __assign({}, __assign(__assign({}, props), { ref: ref, className: className })), children);
};
var Button = hoist(forwardRef(ExtendedButton), FusionButton);
export default Button;
export var ButtonGroup = Button.Group;
