"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var arrays_1 = require("../utils/arrays");
var union_1 = require("../changes/union");
function changesInUnion(oldUnion, newUnion) {
    var changes = [];
    var oldTypes = oldUnion.getTypes();
    var newTypes = newUnion.getTypes();
    var oldTypenames = oldTypes.map(function (t) { return t.name; });
    var newTypenames = newTypes.map(function (t) { return t.name; });
    var added = arrays_1.diffArrays(newTypenames, oldTypenames).map(function (name) { return newTypes.find(function (t) { return t.name === name; }); });
    var removed = arrays_1.diffArrays(oldTypenames, newTypenames).map(function (name) { return oldTypes.find(function (t) { return t.name === name; }); });
    changes.push.apply(changes, added.map(function (type) { return union_1.unionMemberAdded(newUnion, type); }));
    changes.push.apply(changes, removed.map(function (type) { return union_1.unionMemberRemoved(oldUnion, type); }));
    return changes;
}
exports.changesInUnion = changesInUnion;
//# sourceMappingURL=union.js.map