"use strict";
var __assign = (this && this.__assign) || function () {
    __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;
    };
    return __assign.apply(this, arguments);
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var react_1 = __importDefault(require("react"));
var ExpandedValueTooltip_1 = require("../../../ExpandedValueTooltip");
var HierarchicalAttributeTooltip_1 = require("../../../HierarchicalAttributeTooltip");
var ChipsCount_1 = __importDefault(require("../ChipsCount/ChipsCount"));
var FacetTitle_module_css_1 = __importDefault(require("./FacetTitle.module.css"));
var FacetTitle = function (_a) {
    var _b = _a.title, title = _b === void 0 ? '' : _b, _c = _a.chipLabel, chipLabel = _c === void 0 ? 0 : _c, onDelete = _a.onDelete, pathToTitle = _a.pathToTitle, onClick = _a.onClick;
    var isNested = Boolean(pathToTitle && pathToTitle.length > 2);
    var TooltipComponent = isNested ? HierarchicalAttributeTooltip_1.HierarchicalAttributeTooltip : ExpandedValueTooltip_1.ExpandedValueTooltip;
    var tooltipProps = isNested ? { pathToTitle: pathToTitle } : { value: title };
    return (react_1.default.createElement("div", { className: FacetTitle_module_css_1.default.container, onClick: onClick },
        isNested && (react_1.default.createElement(HierarchicalAttributeTooltip_1.HierarchicalAttributeTooltip, __assign({ placement: "bottom-start" }, tooltipProps),
            react_1.default.createElement("div", { className: FacetTitle_module_css_1.default.parent }, pathToTitle[pathToTitle.length - 2]))),
        react_1.default.createElement("div", { className: FacetTitle_module_css_1.default.titleContainer },
            react_1.default.createElement(TooltipComponent, __assign({ placement: "bottom-start" }, tooltipProps),
                react_1.default.createElement("span", { className: FacetTitle_module_css_1.default.title }, title)),
            chipLabel !== 0 && (react_1.default.createElement("div", { className: FacetTitle_module_css_1.default.chip },
                react_1.default.createElement(ChipsCount_1.default, { label: chipLabel, onDelete: onDelete }))))));
};
exports.default = FacetTitle;
