"use strict";
// @ts-nocheck
exports.__esModule = true;
exports.TagBase = exports.cnTagBase = exports.tagBasePropViewDefault = exports.tagBasePropView = exports.tagBasePropGroup = exports.tagBasePropGroupStringValue = exports.tagBasePropGroupNumberValue = exports.tagBasePropSizeDefault = exports.tagBasePropSize = void 0;
var tslib_1 = require("tslib");
require("./TagBase.css");
var react_1 = (0, tslib_1.__importDefault)(require("react"));
var IconClose_1 = require("../../icons/IconClose/IconClose");
var bem_1 = require("../../utils/bem");
var getSizeByMap_1 = require("../../utils/getSizeByMap");
var PropsWithAsAttributes_1 = require("../../utils/types/PropsWithAsAttributes");
exports.tagBasePropSize = ['m', 'xs', 's', 'l'];
exports.tagBasePropSizeDefault = exports.tagBasePropSize[0];
exports.tagBasePropGroupNumberValue = [1, 2, 3, 4, 5, 6, 7, 8, 9];
exports.tagBasePropGroupStringValue = ['1', '2', '3', '4', '5', '6', '7', '8', '9'];
exports.tagBasePropGroup = (0, tslib_1.__spreadArray)((0, tslib_1.__spreadArray)([], (0, tslib_1.__read)(exports.tagBasePropGroupNumberValue), false), (0, tslib_1.__read)(exports.tagBasePropGroupStringValue), false);
exports.tagBasePropView = ['stroked', 'filled', 'theme', 'label'];
exports.tagBasePropViewDefault = exports.tagBasePropView[0];
exports.cnTagBase = (0, bem_1.cn)('TagBase');
var sizeMap = {
    xs: 'xs',
    s: 'xxs',
    m: 'xs',
    l: 's'
};
exports.TagBase = (0, PropsWithAsAttributes_1.forwardRefWithAs)(function (props, ref) {
    var _a;
    var _b = props.size, size = _b === void 0 ? exports.tagBasePropSizeDefault : _b, color = props.color, _c = props.as, as = _c === void 0 ? 'div' : _c, label = props.label, className = props.className, group = props.group, _d = props.view, view = _d === void 0 ? exports.tagBasePropViewDefault : _d, onCancel = props.onCancel, Icon = props.icon, iconSize = props.iconSize, withAction = props.withAction, colorBorder = props.colorBorder, otherProps = (0, tslib_1.__rest)(props, ["size", "color", "as", "label", "className", "group", "view", "onCancel", "icon", "iconSize", "withAction", "colorBorder"]);
    var Tag = as;
    var withCancel = typeof onCancel === 'function';
    var withIcon = !!Icon;
    var IconCloseSize = (0, getSizeByMap_1.getSizeByMap)(sizeMap, size);
    var IconSize = (0, getSizeByMap_1.getSizeByMap)(sizeMap, size, iconSize);
    return (react_1["default"].createElement(Tag, (0, tslib_1.__assign)({}, otherProps, { className: (0, exports.cnTagBase)({
            color: color,
            size: size,
            view: view,
            withCancel: withCancel,
            withIcon: withIcon,
            group: group,
            withAction: withAction
        }, [className]), ref: ref, style: colorBorder && (_a = {},
            _a['--tag-border-color'] = "".concat(colorBorder),
            _a) }), withCancel || Icon ? (react_1["default"].createElement(react_1["default"].Fragment, null,
        withCancel && (react_1["default"].createElement("button", { className: (0, exports.cnTagBase)('CancelButton'), type: "button", onClick: onCancel },
            react_1["default"].createElement(IconClose_1.IconClose, { className: (0, exports.cnTagBase)('CancelIcon'), size: IconCloseSize }))),
        Icon && (react_1["default"].createElement("span", { className: (0, exports.cnTagBase)('IconWrapper') },
            react_1["default"].createElement(Icon, { size: IconSize, className: (0, exports.cnTagBase)('Icon') }))),
        react_1["default"].createElement("span", { className: (0, exports.cnTagBase)('Label') }, label))) : (label)));
});
