"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.mergeMapper = void 0;
var object_merger_1 = require("./object-merger");
function mergeIntoExisting(dataStore, item) {
    var existing = dataStore.get(item.id);
    if (existing) {
        try {
            var diff = object_merger_1.objectMerger.deepMerge(existing, item);
            return { current: existing, diff: diff };
        }
        catch (e) {
            // eslint-disable-next-line no-console
            console.error('failed to merge item update to existing', item, existing);
            e.params = { existing: existing, item: item };
            throw e;
        }
    }
    return { current: item };
}
exports.mergeMapper = { mergeIntoExisting: mergeIntoExisting };
//# sourceMappingURL=merge-mapper.js.map