var _a;
import React, { useCallback } from 'react';
import i18n from 'ui-i18n';
import InfoIcon from '@mui/icons-material/Info';
import { ParticipationStatus } from '@reltio/mdm-sdk';
import { withTooltip } from '../../../../../HOCs/withTooltip';
import { RuleItemType } from '../../types';
import { RuleTypeInfoButton } from '../RuleTypeInfoButton';
import styles from './SimpleRule.module.css';
var InfoIconWithTooltip = withTooltip(InfoIcon);
var PARTICIPATION_STATUS_MAP = (_a = {},
    Object.defineProperty(_a, ParticipationStatus.Pinned, {
        get: function () {
            return i18n.text("Value survives because 'pin' flag is set. Survivorship not evaluated");
        },
        enumerable: false,
        configurable: true
    }),
    Object.defineProperty(_a, ParticipationStatus.Ignored, {
        get: function () {
            return i18n.text("Value did not participate in survivorship evaluation because 'ignore' flag is set");
        },
        enumerable: false,
        configurable: true
    }),
    Object.defineProperty(_a, ParticipationStatus.EndDatedCrosswalk, {
        get: function () {
            return i18n.text('Value did not participate in survivorship evaluation because its crosswalk is end-dated');
        },
        enumerable: false,
        configurable: true
    }),
    Object.defineProperty(_a, ParticipationStatus.NotParticipating, {
        get: function () {
            return i18n.text('Value did not participate in survivorship evaluation because another value was pinned or the source was ignored');
        },
        enumerable: false,
        configurable: true
    }),
    _a);
export var SimpleRule = function (_a) {
    var attributeType = _a.attributeType, attributeValue = _a.attributeValue, getRuleTypeData = _a.getRuleTypeData;
    var renderStrategy = 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.createElement("div", { className: styles.strategyItem },
            React.createElement("div", { className: styles.label }, strategy.label),
            showInfoIcon && (React.createElement(RuleTypeInfoButton, { info: {
                    sourcesUriOrder: sourcesUriOrder,
                    primaryAttributeUri: primaryAttributeUri,
                    comparisonAttributeUri: comparisonAttributeUri
                } }))));
    }, []);
    var renderStatus = useCallback(function (participationStatus) {
        var description = PARTICIPATION_STATUS_MAP[participationStatus];
        return (React.createElement("div", { className: styles.statusItem },
            i18n.text('N/A'),
            description && React.createElement(InfoIconWithTooltip, { className: styles.infoIcon, tooltipTitle: description })));
    }, []);
    var _b = getRuleTypeData(attributeType, attributeValue), type = _b.type, data = _b.data;
    return type === RuleItemType.Status ? renderStatus(data) : renderStrategy(data);
};
