"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const assert_1 = __importDefault(require("assert"));
const Graph_1 = require("../../Class/Graph");
const debug_1 = require("../../debug");
const _ids_1 = require("../../system/_ids");
const system_1 = require("../util/system");
const spec = system_1.system.emptySpec();
const composition0 = new Graph_1.Graph(spec, {}, system_1.system);
false && (0, debug_1.watchUnitAndLog)(composition0);
false && (0, debug_1.watchGraphAndLog)(composition0);
const id0 = 'id0';
const id1 = 'id1';
const id2 = 'id2';
composition0.play();
composition0.addUnitSpec(id0, {
    unit: {
        id: _ids_1.ID_IDENTITY,
        input: {
            a: {
                data: '0',
            },
        },
        output: {},
    },
});
composition0.addUnitSpec(id1, {
    unit: {
        id: _ids_1.ID_IDENTITY,
    },
});
composition0.addUnitSpec(id2, {
    unit: {
        id: _ids_1.ID_IDENTITY,
    },
});
composition0.addMerge({
    [id0]: {
        output: {
            a: true,
        },
    },
    [id1]: {
        input: {
            a: true,
        },
    },
    [id2]: {
        input: {
            a: true,
        },
    },
}, 'merge0');
composition0.addMerge({
    [id1]: {
        output: {
            a: true,
        },
    },
    [id0]: {
        input: {
            a: true,
        },
    },
}, 'merge1');
assert_1.default.equal(composition0.getUnit(id0).peakOutput('a'), 0);
assert_1.default.equal(composition0.getUnit(id0).peakInput('a'), 0);
assert_1.default.equal(composition0.getUnit(id1).peakOutput('a'), 0);
assert_1.default.equal(composition0.getUnit(id1).peakInput('a'), 0);
assert_1.default.equal(composition0.getUnit(id2).peakOutput('a'), 0);
assert_1.default.equal(composition0.getUnit(id2).peakInput('a'), 0);
const spec0 = system_1.system.emptySpec();
const composition1 = new Graph_1.Graph(spec0, {}, system_1.system);
composition1.play();
const id3 = 'id3';
const id4 = 'id4';
composition1.addUnitSpec(id3, { unit: { id: _ids_1.ID_IDENTITY } });
composition1.addUnitSpec(id4, { unit: { id: _ids_1.ID_IDENTITY } });
composition1.addMerge({
    [id3]: {
        output: {
            a: true,
        },
    },
    [id4]: {
        input: {
            a: true,
        },
    },
}, '0');
const identity3 = composition1.getUnit(id3);
const identity4 = composition1.getUnit(id4);
identity3.push('a', 1);
identity3.push('a', 2);
identity3.push('a', 3);
identity3.push('a', 4);
composition1.addMerge({
    [id3]: {
        input: {
            a: true,
        },
    },
    [id4]: {
        output: {
            a: true,
        },
    },
}, '0');
const spec1 = system_1.system.emptySpec();
const composition2 = new Graph_1.Graph(spec1, {}, system_1.system);
composition2.play();
composition2.addUnitSpec(id0, { unit: { id: _ids_1.ID_IDENTITY } });
composition2.addUnitSpec(id1, { unit: { id: _ids_1.ID_IDENTITY } });
composition2.addUnitSpec(id2, { unit: { id: _ids_1.ID_IDENTITY } });
composition2.addMerge({
    [id0]: {
        output: {
            a: true,
        },
    },
    [id1]: {
        output: {
            a: true,
        },
    },
    [id2]: {
        input: {
            a: true,
        },
    },
}, 'merge0');
composition2.setUnitInputData(id1, 'a', 0);
composition2.setUnitOutputIgnored(id1, 'a', true);
composition2.setUnitInputData(id0, 'a', 0);
const UNIT_ID_FILTER = 'UNIT_ID_FILTER';
const UNIT_ID_TRUE = 'UNIT_ID_TRUE';
const spec2 = system_1.system.emptySpec();
const composition4 = new Graph_1.Graph(spec2, {}, system_1.system);
false && (0, debug_1.watchUnitAndLog)(composition4);
false && (0, debug_1.watchGraphAndLog)(composition4);
composition4.play();
composition4.addUnitSpec(UNIT_ID_FILTER, {
    unit: {
        id: _ids_1.ID_FILTER,
        output: {
            a: {
                ignored: true,
            },
            i: {
                ignored: true,
            },
            test: {
                ignored: true,
            },
        },
    },
});
composition4.addUnitSpec(UNIT_ID_TRUE, {
    unit: { id: _ids_1.ID_TRUE },
});
const filter = composition4.getUnit(UNIT_ID_FILTER);
const _true = composition4.getUnit(UNIT_ID_TRUE);
filter.push('a', [0, 1, 2]);
composition4.addMerge({
    [UNIT_ID_FILTER]: {
        output: {
            'a[i]': true,
        },
    },
    [UNIT_ID_TRUE]: {
        input: {
            any: true,
        },
    },
}, '0');
composition4.addMerge({
    [UNIT_ID_FILTER]: {
        input: {
            test: true,
        },
    },
    [UNIT_ID_TRUE]: {
        output: {
            true: true,
        },
    },
}, '1');
assert_1.default.deepEqual(filter.peak('b'), [0, 1, 2]);
//# sourceMappingURL=merge.js.map