"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 });
exports.EntityOption = void 0;
var react_1 = __importDefault(require("react"));
var ui_i18n_1 = __importDefault(require("ui-i18n"));
var classnames_1 = __importDefault(require("classnames"));
var MenuItem_1 = __importDefault(require("@mui/material/MenuItem"));
var EntityTypeIcon_1 = require("../../../EntityTypeIcon");
var ExpandedValueTooltip_1 = require("../../../ExpandedValueTooltip");
var styles_1 = require("./styles");
var EntityOption = function (_a) {
    var innerRef = _a.innerRef, innerProps = _a.innerProps, selectOption = _a.selectOption, data = _a.data, isFocused = _a.isFocused;
    var styles = (0, styles_1.useStyles)();
    var uri = data.uri, entityType = data.entityType, label = data.label, secondaryLabel = data.secondaryLabel;
    if (uri !== '') {
        return (react_1.default.createElement(MenuItem_1.default, __assign({ className: (0, classnames_1.default)(styles.entityContainer, { focused: isFocused }), ref: innerRef, key: uri, onClick: function () { return selectOption({ label: label, uri: uri, entityType: entityType }); } }, innerProps),
            react_1.default.createElement(EntityTypeIcon_1.EntityTypeIcon, { className: styles.entityAvatar, entityType: entityType }),
            react_1.default.createElement(ExpandedValueTooltip_1.ExpandedValueTooltip, { value: "".concat(label).concat(secondaryLabel ? ', ' + secondaryLabel : '') },
                react_1.default.createElement("span", { className: styles.entityLabel },
                    label,
                    secondaryLabel && react_1.default.createElement("span", { className: styles.entitySecondaryLabel },
                        ", ",
                        secondaryLabel)))));
    }
    else {
        return (react_1.default.createElement(MenuItem_1.default, __assign({ className: styles.entityContainer, ref: innerRef, key: uri }, innerProps, { disabled: true }),
            react_1.default.createElement("span", { className: styles.emptyEntityLabel }, ui_i18n_1.default.text('No results found'))));
    }
};
exports.EntityOption = EntityOption;
