"use strict";
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
    if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
    return cooked;
};
var __assign = (this && this.__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;
};
var __rest = (this && this.__rest) || function (s, e) {
    var t = {};
    for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
        t[p] = s[p];
    if (s != null && typeof Object.getOwnPropertySymbols === "function")
        for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0)
            t[p[i]] = s[p[i]];
    return t;
};
Object.defineProperty(exports, "__esModule", { value: true });
var ColorHash = require("color-hash");
var assign = require("lodash/assign");
var memoize = require("lodash/memoize");
var React = require("react");
var styled_components_1 = require("styled-components");
var utils_1 = require("../utils");
var Grid_1 = require("./Grid");
var colorHash = new ColorHash();
var backgroundColor = memoize(function (text) { return colorHash.hex(text); });
var BaseBadge = styled_components_1.default(Grid_1.Box)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n\tborder-radius: ", ";\n\tdisplay: inline-block;\n\tmin-width: 40px;\n\ttext-align: center;\n"], ["\n\tborder-radius: ", ";\n\tdisplay: inline-block;\n\tmin-width: 40px;\n\ttext-align: center;\n"])), function (props) { return utils_1.px(props.theme.radius); });
exports.default = styled_components_1.withTheme(function (_a) {
    var small = _a.small, text = _a.text, theme = _a.theme, props = __rest(_a, ["small", "text", "theme"]);
    return (React.createElement(BaseBadge, __assign({ p: "3px 5px", fontSize: small ? 13 : 18 }, props, { color: props.color || '#fff', bg: utils_1.getColor(assign(props, { theme: theme }), 'bg', 'main') ||
            backgroundColor(text) }), text));
});
var templateObject_1;
