var _a;
import React from 'react';
import i18n from 'ui-i18n';
import classnames from 'classnames';
import InfoIcon from '@mui/icons-material/Info';
import { ParticipationStatus } from '@reltio/mdm-sdk';
import { withTooltip } from '../../../../../HOCs/withTooltip';
import { RuleTypeInfoButton } from '../RuleTypeInfoButton';
import { useCommonStyles } from '../../styles';
import { ValueHeightConsumer } from '../SyncedValueHeight';
import styles from './RuleTypeRenderer.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 it's 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 RuleTypeRenderer = function (_a) {
    var ruleTypes = _a.value.ruleTypes;
    var commonStyles = 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.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 = 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 renderRuleType = function (item) {
        if (item.type === 'status') {
            return renderStatus(item.data);
        }
        return renderStrategy(item.data);
    };
    return (React.createElement("div", { className: classnames(styles.list, commonStyles.basicCell) }, ruleTypes.map(function (item) { return (React.createElement(ValueHeightConsumer, { key: item.valueUri, uri: item.valueUri }, renderRuleType(item))); })));
};
