"use strict";
var __read = (this && this.__read) || function (o, n) {
    var m = typeof Symbol === "function" && o[Symbol.iterator];
    if (!m) return o;
    var i = m.call(o), r, ar = [], e;
    try {
        while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
    }
    catch (error) { e = { error: error }; }
    finally {
        try {
            if (r && !r.done && (m = i["return"])) m.call(i);
        }
        finally { if (e) throw e.error; }
    }
    return ar;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var re_reselect_1 = __importDefault(require("re-reselect"));
var get_chart_id_1 = require("../../../../state/selectors/get_chart_id");
var tree_1 = require("./tree");
exports.getFlatHierarchy = re_reselect_1.default([tree_1.getTree], function (tree) { return flatHierarchy(tree); })(get_chart_id_1.getChartIdSelector);
function flatHierarchy(tree, orderedList) {
    if (orderedList === void 0) { orderedList = []; }
    for (var i = 0; i < tree.length; i++) {
        var branch = tree[i];
        var _a = __read(branch, 2), key = _a[0], arrayNode = _a[1];
        var children = arrayNode.children, depth = arrayNode.depth, value = arrayNode.value;
        if (key !== null) {
            orderedList.push([key, depth, value]);
        }
        if (children.length > 0) {
            flatHierarchy(children, orderedList);
        }
    }
    return orderedList;
}
//# sourceMappingURL=get_flat_hierarchy.js.map