"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ContextIndicator = void 0;
const jsx_runtime_1 = require("react/jsx-runtime");
const uikit_1 = require("@gravity-ui/uikit");
const cn_1 = require("../../../utils/cn.js");
const utils_1 = require("./utils.js");
require("./ContextIndicator.css");
const b = (0, cn_1.block)('context-indicator');
const ContextIndicator = (props) => {
    const { className, qa, orientation = 'horizontal', reversed = false, tooltipContent } = props;
    const percentage = props.type === 'number'
        ? Math.round((props.usedContext / props.maxContext) * 100)
        : props.usedContext;
    const clampedPercentage = Math.min(Math.max(percentage, 0), 100);
    const content = ((0, jsx_runtime_1.jsxs)("div", { className: b('container', { orientation, reversed }, className), "data-qa": qa, children: [(0, jsx_runtime_1.jsx)("div", { className: b('progress'), style: {
                    '--percentage': clampedPercentage,
                    '--progress-color': (0, utils_1.getProgressColor)(clampedPercentage),
                }, children: (0, jsx_runtime_1.jsx)("div", { className: b('inner') }) }), (0, jsx_runtime_1.jsx)("div", { className: b('value'), children: clampedPercentage })] }));
    if (tooltipContent) {
        return (0, jsx_runtime_1.jsx)(uikit_1.Tooltip, { content: tooltipContent, children: content });
    }
    return content;
};
exports.ContextIndicator = ContextIndicator;
//# sourceMappingURL=index.js.map
