"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
    __setModuleDefault(result, mod);
    return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
var _a;
Object.defineProperty(exports, "__esModule", { value: true });
exports.SimpleRule = void 0;
var react_1 = __importStar(require("react"));
var ui_i18n_1 = __importDefault(require("ui-i18n"));
var Info_1 = __importDefault(require("@mui/icons-material/Info"));
var mdm_sdk_1 = require("@reltio/mdm-sdk");
var withTooltip_1 = require("../../../../../HOCs/withTooltip");
var types_1 = require("../../types");
var RuleTypeInfoButton_1 = require("../RuleTypeInfoButton");
var SimpleRule_module_css_1 = __importDefault(require("./SimpleRule.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 its 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 SimpleRule = function (_a) {
    var attributeType = _a.attributeType, attributeValue = _a.attributeValue, getRuleTypeData = _a.getRuleTypeData;
    var renderStrategy = (0, react_1.useCallback)(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: SimpleRule_module_css_1.default.strategyItem },
            react_1.default.createElement("div", { className: SimpleRule_module_css_1.default.label }, strategy.label),
            showInfoIcon && (react_1.default.createElement(RuleTypeInfoButton_1.RuleTypeInfoButton, { info: {
                    sourcesUriOrder: sourcesUriOrder,
                    primaryAttributeUri: primaryAttributeUri,
                    comparisonAttributeUri: comparisonAttributeUri
                } }))));
    }, []);
    var renderStatus = (0, react_1.useCallback)(function (participationStatus) {
        var description = PARTICIPATION_STATUS_MAP[participationStatus];
        return (react_1.default.createElement("div", { className: SimpleRule_module_css_1.default.statusItem },
            ui_i18n_1.default.text('N/A'),
            description && react_1.default.createElement(InfoIconWithTooltip, { className: SimpleRule_module_css_1.default.infoIcon, tooltipTitle: description })));
    }, []);
    var _b = getRuleTypeData(attributeType, attributeValue), type = _b.type, data = _b.data;
    return type === types_1.RuleItemType.Status ? renderStatus(data) : renderStrategy(data);
};
exports.SimpleRule = SimpleRule;
