import { __assign, __rest } from "tslib";
import React, { useContext } from 'react';
import classNames from 'classnames';
import warning from '../_utils/warning';
import { ConfigContext } from '../config-provider/config-context';
import { getPrefixCls } from '../_utils/general';
var Badge = function (props) {
    var _a, _b;
    var count = props.count, _c = props.color, color = _c === void 0 ? '#f2453d' : _c, _d = props.max, max = _d === void 0 ? 99 : _d, _e = props.dot, dot = _e === void 0 ? false : _e, _f = props.processing, processing = _f === void 0 ? false : _f, _g = props.showZero, showZero = _g === void 0 ? false : _g, customisedCls = props.prefixCls, title = props.title, className = props.className, badgeStyle = props.badgeStyle, children = props.children, otherProps = __rest(props, ["count", "color", "max", "dot", "processing", "showZero", "prefixCls", "title", "className", "badgeStyle", "children"]);
    var configContext = useContext(ConfigContext);
    var prefixCls = getPrefixCls('badge', configContext.prefixCls, customisedCls);
    var cls = classNames(prefixCls, className, (_a = {}, _a[prefixCls + "_no-wrap"] = !children, _a));
    var dotCls = classNames(prefixCls + "__dot", (_b = {}, _b[prefixCls + "__dot_wave"] = processing, _b));
    warning(!dot && processing, 'only dot badge has the processing effect');
    var renderCount = function () {
        if (typeof count === 'number' || typeof count === 'string') {
            if (count === 0 && !showZero) {
                return null;
            }
            return (React.createElement("sup", { title: title, className: prefixCls + "__count", style: __assign({ backgroundColor: color }, badgeStyle) }, typeof count === 'number' && count > max ? max + "+" : count));
        }
        else {
            return React.createElement("span", { className: prefixCls + "__custom" }, count);
        }
    };
    return (React.createElement("span", __assign({}, otherProps, { className: cls }),
        children,
        dot ? (React.createElement("sup", { title: title, className: dotCls, style: __assign({ backgroundColor: color }, badgeStyle) })) : (renderCount())));
};
Badge.displayName = 'Badge';
export default Badge;
//# sourceMappingURL=index.js.map