function _define_property(obj, key, value) {
    if (key in obj) {
        Object.defineProperty(obj, key, {
            value: value,
            enumerable: true,
            configurable: true,
            writable: true
        });
    } else {
        obj[key] = value;
    }
    return obj;
}
function _object_spread(target) {
    for(var i = 1; i < arguments.length; i++){
        var source = arguments[i] != null ? arguments[i] : {};
        var ownKeys = Object.keys(source);
        if (typeof Object.getOwnPropertySymbols === "function") {
            ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
                return Object.getOwnPropertyDescriptor(source, sym).enumerable;
            }));
        }
        ownKeys.forEach(function(key) {
            _define_property(target, key, source[key]);
        });
    }
    return target;
}
function _object_without_properties(source, excluded) {
    if (source == null) return {};
    var target = {}, sourceKeys, key, i;
    if (typeof Reflect !== "undefined" && Reflect.ownKeys) {
        sourceKeys = Reflect.ownKeys(source);
        for(i = 0; i < sourceKeys.length; i++){
            key = sourceKeys[i];
            if (excluded.indexOf(key) >= 0) continue;
            if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
            target[key] = source[key];
        }
        return target;
    }
    target = _object_without_properties_loose(source, excluded);
    if (Object.getOwnPropertySymbols) {
        sourceKeys = Object.getOwnPropertySymbols(source);
        for(i = 0; i < sourceKeys.length; i++){
            key = sourceKeys[i];
            if (excluded.indexOf(key) >= 0) continue;
            if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
            target[key] = source[key];
        }
    }
    return target;
}
function _object_without_properties_loose(source, excluded) {
    if (source == null) return {};
    var target = {}, sourceKeys = Object.getOwnPropertyNames(source), key, i;
    for(i = 0; i < sourceKeys.length; i++){
        key = sourceKeys[i];
        if (excluded.indexOf(key) >= 0) continue;
        if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
        target[key] = source[key];
    }
    return target;
}
import React from 'react';
import styled, { css } from 'styled-components';
import { caption } from '../../tokens';
/**
 * Размеры в ремах.
 */ export var badgeSizes = {
    l: {
        textMarginX: '0.25rem',
        textMarginLeftAfterContent: '0.25rem'
    },
    s: {
        textMarginX: '0.125rem',
        textMarginLeftAfterContent: '0.125rem'
    }
};
export var badgeRootSizes = {
    l: {
        height: '1.5rem',
        padding: '0.25rem',
        minWidth: '1.5rem',
        borderRadius: '0.75rem',
        fontSize: '0.75rem'
    },
    s: {
        height: '1rem',
        padding: '0.125rem',
        minWidth: '1rem',
        borderRadius: '0.5rem',
        fontSize: '0.625rem'
    }
};
var StyledText = styled.span.withConfig({
    displayName: "Badge__StyledText",
    componentId: "sc-4f989aef-0"
})([
    ""
]);
var StyledContent = styled.div.withConfig({
    displayName: "Badge__StyledContent",
    componentId: "sc-4f989aef-1"
})([
    "display:flex;"
]);
var StyledBadge = styled.div.withConfig({
    displayName: "Badge__StyledBadge",
    componentId: "sc-4f989aef-2"
})([
    "",
    ";display:inline-flex;align-items:center;box-sizing:border-box;justify-content:center;width:max-content;",
    ";"
], caption, function(param) {
    var size = param.size, circled = param.circled;
    return css([
        "",
        ";",
        " ",
        "{margin-left:",
        ";margin-right:",
        ";}",
        " ~ ",
        "{margin-left:",
        ";}"
    ], badgeRootSizes[size], circled && css([
        "width:",
        ";padding-left:0;padding-right:0;"
    ], badgeRootSizes[size].minWidth), StyledText, badgeSizes[size].textMarginX, badgeSizes[size].textMarginX, StyledContent, StyledText, badgeSizes[size].textMarginLeftAfterContent);
});
/**
 * Небольшая бирка для ячеек и карточек.
 * Компонент может отображаться в нескольких размерах и цветах, может содержать текст и/или иконку.
 */ export var Badge = function Badge(_0) {
    var _0_size = _0.size, size = _0_size === void 0 ? 'l' : _0_size, text = _0.text, contentLeft = _0.contentLeft, rest = _object_without_properties(_0, [
        "size",
        "text",
        "contentLeft"
    ]);
    return /*#__PURE__*/ React.createElement(StyledBadge, _object_spread({
        size: size
    }, rest), contentLeft && /*#__PURE__*/ React.createElement(StyledContent, null, contentLeft), text && /*#__PURE__*/ React.createElement(StyledText, null, text));
};
