"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
var _a;
Object.defineProperty(exports, "__esModule", { value: true });
exports.RuleTypeRenderer = void 0;
var react_1 = __importDefault(require("react"));
var ui_i18n_1 = __importDefault(require("ui-i18n"));
var classnames_1 = __importDefault(require("classnames"));
var Info_1 = __importDefault(require("@mui/icons-material/Info"));
var mdm_sdk_1 = require("@reltio/mdm-sdk");
var withTooltip_1 = require("../../../../../HOCs/withTooltip");
var RuleTypeInfoButton_1 = require("../RuleTypeInfoButton");
var styles_1 = require("../../styles");
var SyncedValueHeight_1 = require("../SyncedValueHeight");
var RuleTypeRenderer_module_css_1 = __importDefault(require("./RuleTypeRenderer.module.css"));
var InfoIconWithTooltip = (0, withTooltip_1.withTooltip)(Info_1.default);
var PARTICIPATION_STATUS_MAP = (_a = {},
    Object.defineProperty(_a, mdm_sdk_1.ParticipationStatus.Pinned, {
        get: function () {
            return ui_i18n_1.default.text("Value survives because 'pin' flag is set. Survivorship not evaluated");
        },
        enumerable: false,
        configurable: true
    }),
    Object.defineProperty(_a, mdm_sdk_1.ParticipationStatus.Ignored, {
        get: function () {
            return ui_i18n_1.default.text("Value did not participate in survivorship evaluation because 'ignore' flag is set");
        },
        enumerable: false,
        configurable: true
    }),
    Object.defineProperty(_a, mdm_sdk_1.ParticipationStatus.EndDatedCrosswalk, {
        get: function () {
            return ui_i18n_1.default.text("Value did not participate in survivorship evaluation because it's crosswalk is end-dated");
        },
        enumerable: false,
        configurable: true
    }),
    Object.defineProperty(_a, mdm_sdk_1.ParticipationStatus.NotParticipating, {
        get: function () {
            return ui_i18n_1.default.text('Value did not participate in survivorship evaluation because another value was pinned or the source was ignored');
        },
        enumerable: false,
        configurable: true
    }),
    _a);
var RuleTypeRenderer = function (_a) {
    var ruleTypes = _a.value.ruleTypes;
    var commonStyles = (0, styles_1.useCommonStyles)();
    var renderStrategy = function (data) {
        var strategy = data.strategy, primaryAttributeUri = data.primaryAttributeUri, comparisonAttributeUri = data.comparisonAttributeUri, sourcesUriOrder = data.sourcesUriOrder;
        if (!strategy)
            return null;
        var showInfoIcon = sourcesUriOrder || primaryAttributeUri || comparisonAttributeUri;
        return (react_1.default.createElement("div", { className: RuleTypeRenderer_module_css_1.default.strategyItem },
            react_1.default.createElement("div", { className: RuleTypeRenderer_module_css_1.default.label }, strategy.label),
            showInfoIcon && (react_1.default.createElement(RuleTypeInfoButton_1.RuleTypeInfoButton, { info: {
                    sourcesUriOrder: sourcesUriOrder,
                    primaryAttributeUri: primaryAttributeUri,
                    comparisonAttributeUri: comparisonAttributeUri
                } }))));
    };
    var renderStatus = function (participationStatus) {
        var description = PARTICIPATION_STATUS_MAP[participationStatus];
        return (react_1.default.createElement("div", { className: RuleTypeRenderer_module_css_1.default.statusItem },
            ui_i18n_1.default.text('N/A'),
            description && react_1.default.createElement(InfoIconWithTooltip, { className: RuleTypeRenderer_module_css_1.default.infoIcon, tooltipTitle: description })));
    };
    var renderRuleType = function (item) {
        if (item.type === 'status') {
            return renderStatus(item.data);
        }
        return renderStrategy(item.data);
    };
    return (react_1.default.createElement("div", { className: (0, classnames_1.default)(RuleTypeRenderer_module_css_1.default.list, commonStyles.basicCell) }, ruleTypes.map(function (item) { return (react_1.default.createElement(SyncedValueHeight_1.ValueHeightConsumer, { key: item.valueUri, uri: item.valueUri }, renderRuleType(item))); })));
};
exports.RuleTypeRenderer = RuleTypeRenderer;
