"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 debug_1 = require("../../../debug");
const fromSpec_1 = require("../../../spec/fromSpec");
const _specs_1 = __importDefault(require("../../../system/_specs"));
const system_1 = require("../../util/system");
const spec = {
    id: '47119174-5dcb-11ea-8a04-4b0a14d0ad1a',
    name: 'sum next n',
    units: {
        add: {
            id: '6fe452f2-2ec1-4ee2-887d-751c3697e6bf',
        },
        decrement: {
            id: '4d67d2e4-8b06-4e15-8243-99be8e4be5d3',
        },
        gt0: {
            id: '6f4ac2fa-e9bd-4c0e-8bda-75976f3e4e58',
        },
        loop2: {
            id: 'eee90e0f-522d-4ac4-a0f1-abf5d69a4e26',
            output: {
                finala: {
                    ignored: true,
                },
                finalb: {
                    ignored: true,
                },
                localb: {
                    ignored: true,
                },
            },
            input: {
                initb: {
                    constant: true,
                    data: '0',
                },
            },
        },
    },
    merges: {
        0: {
            add: {
                output: {
                    'a + b': true,
                },
            },
            loop2: {
                input: {
                    'next b': true,
                },
            },
        },
        1: {
            loop2: {
                output: {
                    locala: true,
                },
            },
            gt0: {
                input: {
                    a: true,
                },
            },
        },
        2: {
            loop2: {
                input: {
                    test: true,
                },
            },
            gt0: {
                output: {
                    'a > 0': true,
                },
            },
        },
        3: {
            loop2: {
                output: {
                    currenta: true,
                },
            },
            decrement: {
                input: {
                    a: true,
                },
            },
        },
        4: {
            loop2: {
                input: {
                    'next a': true,
                },
            },
            decrement: {
                output: {
                    'a - 1': true,
                },
            },
        },
        5: {
            loop2: {
                output: {
                    currentb: true,
                },
            },
            add: {
                input: {
                    b: true,
                },
            },
        },
    },
    metadata: {
        icon: null,
        description: 'no description',
    },
    inputs: {
        a: {
            name: 'a',
            plug: {
                0: {
                    unitId: 'add',
                    pinId: 'a',
                },
            },
        },
        n: {
            name: 'n',
            plug: {
                0: {
                    unitId: 'loop2',
                    pinId: 'inita',
                },
            },
        },
    },
    outputs: {
        sum: {
            name: 'sum',
            plug: { 0: { mergeId: '0' } },
        },
    },
};
const SumNextN = (0, fromSpec_1.fromSpec)(spec, _specs_1.default);
const sumNextN = new SumNextN(system_1.system);
false && (0, debug_1.watchUnitAndLog)(sumNextN);
false && (0, debug_1.watchGraphAndLog)(sumNextN);
false && (0, debug_1.watchGraphAndLog)(sumNextN.getUnit('nstringbuilderfrom'));
sumNextN.play();
sumNextN.push('n', 0);
assert_1.default.equal(sumNextN.take('sum'), undefined);
assert_1.default.equal(sumNextN.peakInput('n'), undefined);
sumNextN.push('n', 1);
assert_1.default.equal(sumNextN.take('sum'), undefined);
sumNextN.push('a', 0);
assert_1.default.equal(sumNextN.peakInput('n'), 1);
assert_1.default.equal(sumNextN.take('sum'), 0);
assert_1.default.equal(sumNextN.take('sum'), undefined);
assert_1.default.equal(sumNextN.peakInput('a'), undefined);
assert_1.default.equal(sumNextN.peakInput('n'), undefined);
//# sourceMappingURL=SumNextN.js.map