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 StrengthIndicator = React.forwardRef(function (props, ref) {
    var _a = props.current, current = _a === void 0 ? 0 : _a, _b = props.blocks, blocks = _b === void 0 ? 3 : _b, _c = props.colors, colors = _c === void 0 ? ['#f44336', '#ff9800', '#52c41a'] : _c, className = props.className, customisedCls = props.prefixCls, otherProps = __rest(props, ["current", "blocks", "colors", "className", "prefixCls"]);
    var configContext = useContext(ConfigContext);
    var prefixCls = getPrefixCls('strength-indicator', configContext.prefixCls, customisedCls);
    var cls = classNames(prefixCls, className);
    var displayLabels = Array.isArray(props.labels)
        ? props.labels
        : ['Weak', 'Medium', 'Strong'];
    return (React.createElement("div", __assign({}, otherProps, { className: cls, ref: ref }), Array.from(new Array(blocks)).map(function (item, idx) {
        var _a;
        var itemCls = classNames(prefixCls + "__item", (_a = {},
            _a[prefixCls + "__item_active"] = idx < current,
            _a));
        var bgColor = idx < current ? colors[current - 1] : undefined;
        return (React.createElement("div", { key: idx, className: itemCls },
            React.createElement("div", { className: prefixCls + "__inner", style: { backgroundColor: bgColor } }),
            'labels' in props && (React.createElement("div", { className: prefixCls + "__label" }, displayLabels[idx]))));
    })));
});
StrengthIndicator.displayName = 'StrengthIndicator';
export default StrengthIndicator;
//# sourceMappingURL=index.js.map