import React from 'react';
import i18n from 'ui-i18n';
import classnames from 'classnames';
import { getMatchRuleLabel, formatRelevanceScore, checkMatchRuleSummaryRelevance } from '@reltio/mdm-sdk';
import Tooltip from '@mui/material/Tooltip';
import { useMdmEntity, useMdmMetadata } from '../contexts/MdmModuleContext';
import { useStyles } from './styles';
export var RelevanceScoreBadge = function (_a) {
    var className = _a.className, matchRuleSummaries = _a.matchRuleSummaries;
    var styles = useStyles();
    var metadata = useMdmMetadata();
    var entity = useMdmEntity();
    var matchRuleSummaryWithBestScore = matchRuleSummaries === null || matchRuleSummaries === void 0 ? void 0 : matchRuleSummaries.filter(checkMatchRuleSummaryRelevance).sort(function (a, b) { return b.relevance - a.relevance; })[0];
    if (!matchRuleSummaryWithBestScore) {
        return null;
    }
    var matchRule = matchRuleSummaryWithBestScore.uri;
    var relevancePercentage = formatRelevanceScore(matchRuleSummaryWithBestScore);
    var tooltipTitle = i18n.text('Relevance score based on ${ruleName}', {
        ruleName: getMatchRuleLabel(metadata, entity.type, matchRule)
    });
    return (React.createElement(Tooltip, { title: tooltipTitle },
        React.createElement("div", { className: classnames(className, styles.badge) },
            relevancePercentage, ": ".concat(i18n.text('Relevance score')))));
};
