import { __assign, __spreadArrays } from "tslib";
export function splitConnection(array) {
    var arr = array.map(function (v) { return v.label; });
    return arr.join(' / ');
}
export function getArrPath(array, last) {
    var newArr = [];
    for (var _i = 0, array_1 = array; _i < array_1.length; _i++) {
        var item = array_1[_i];
        var path = last ? last + " / " + item.label : item.label;
        var newItem = __assign(__assign({}, item), { path: path });
        if (item.children && item.children.length !== 0) {
            newItem.children = getArrPath(item.children, path);
        }
        newArr.push(newItem);
    }
    return newArr;
}
export function searchChange(arr, val) {
    var newArr = [];
    for (var _i = 0, arr_1 = arr; _i < arr_1.length; _i++) {
        var item = arr_1[_i];
        if (item.children && item.children.length !== 0) {
            var arr2 = searchChange(item.children, val);
            newArr = __spreadArrays(newArr, arr2);
        }
        if (item.path.indexOf(val) !== -1 &&
            (!item.children || item.children.length === 0)) {
            newArr.push({
                value: item.value,
                label: item.path
            });
        }
    }
    return newArr;
}
