var __assign = (this && this.__assign) || function () {
    __assign = Object.assign || function(t) {
        for (var s, i = 1, n = arguments.length; i < n; i++) {
            s = arguments[i];
            for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
                t[p] = s[p];
        }
        return t;
    };
    return __assign.apply(this, arguments);
};
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
    if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
        if (ar || !(i in from)) {
            if (!ar) ar = Array.prototype.slice.call(from, 0, i);
            ar[i] = from[i];
        }
    }
    return to.concat(ar || Array.prototype.slice.call(from));
};
import { chain, curry, has } from 'ramda';
var isGroupEntry = has('values');
var flattenEntry = curry(function (depth, entry) {
    return isGroupEntry(entry)
        ? __spreadArray([
            { label: entry.label, depth: depth, isGroup: true }
        ], chain(flattenEntry(depth + 1), entry.values), true) : __assign(__assign({}, entry), { depth: depth });
});
export var flattenGroupedEntries = chain(flattenEntry(0));
export var findEntryByValue = curry(function (entries, _value) { return entries.find(function (_a) {
    var isGroup = _a.isGroup, value = _a.value;
    return !isGroup && value === _value;
}); });
