"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.calculateDCRChanges = void 0;
var merge_1 = require("../../helpers/merge");
var calculateDCRChanges = function (metadata, changes, groupedObjects) {
    var mergedChanges = groupedObjects.reduce(function (mergedChanges, object) {
        var _a = (0, merge_1.mergeChanges)(metadata, changes, object.entity, object.relations), mergedEntityChanges = _a[0], mergedRelationsChanges = _a[1];
        return mergedChanges.concat(mergedEntityChanges).concat(mergedRelationsChanges);
    }, []);
    var changesCounts = mergedChanges.reduce(function (changesCounts, _a) {
        var operation = _a.operation;
        if (operation) {
            changesCounts[operation] = (changesCounts[operation] || 0) + 1;
        }
        return changesCounts;
    }, {});
    return changesCounts;
};
exports.calculateDCRChanges = calculateDCRChanges;
