"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.watchGraphUnit = void 0;
const Graph_1 = require("../Class/Graph");
const GRAPH_DEFAULT_EVENTS_1 = require("../constant/GRAPH_DEFAULT_EVENTS");
const callAll_1 = require("../util/call/callAll");
const watchGraphMergeEvent_1 = require("./graph/watchGraphMergeEvent");
const watchGraphPlugEvent_1 = require("./graph/watchGraphPlugEvent");
function watchGraphUnit(unit, events = GRAPH_DEFAULT_EVENTS_1.GRAPH_DEFAULT_EVENTS, callback) {
    let all = [];
    const watch_add_merge = events.includes('add_merge');
    const watch_remove_merge = events.includes('remove_merge');
    const watch_plug_pin = events.includes('plug_pin');
    const watch_unplug_pin = events.includes('unplug_pin');
    if (unit instanceof Graph_1.Graph) {
        if (watch_add_merge) {
            all.push((0, watchGraphMergeEvent_1.watchGraphMergeEvent)('add_merge', unit, callback));
        }
        if (watch_remove_merge) {
            all.push((0, watchGraphMergeEvent_1.watchGraphMergeEvent)('remove_merge', unit, callback));
        }
        if (watch_plug_pin) {
            all.push((0, watchGraphPlugEvent_1.watchGraphPlugEvent)('plug_pin', unit, callback));
        }
        if (watch_unplug_pin) {
            all.push((0, watchGraphPlugEvent_1.watchGraphPlugEvent)('unplug_pin', unit, callback));
        }
    }
    let unlisten = (0, callAll_1.callAll)(all);
    return unlisten;
}
exports.watchGraphUnit = watchGraphUnit;
//# sourceMappingURL=watchGraphUnit.js.map