var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
    if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
        if (ar || !(i in from)) {
            if (!ar) ar = Array.prototype.slice.call(from, 0, i);
            ar[i] = from[i];
        }
    }
    return to.concat(ar || Array.prototype.slice.call(from));
};
import { equals, map, pipe, prop, reject } from 'ramda';
import { isDataTenantEntity, isEntityUri } from '@reltio/mdm-sdk';
var isEntity = function (response) { return (response === null || response === void 0 ? void 0 : response.uri) && isEntityUri(response.uri); };
var getWinnerUriFromMergeResponses = function (responses) { var _a; return (_a = responses.find(isEntity)) === null || _a === void 0 ? void 0 : _a.uri; };
export var getWinnerLosersUrisFromMergeResponses = function (entity, entities, responses) {
    var winnerUri = getWinnerUriFromMergeResponses(responses);
    if (winnerUri) {
        var losersUris = pipe(reject(isDataTenantEntity), map(prop('uri')), reject(equals(winnerUri)))(__spreadArray([entity], entities, true));
        return { winnerUri: winnerUri, losersUris: losersUris };
    }
};
