import { isNil, prop, unless } from 'ramda';
import DefaultHeadCellRenderer from 'react-components/dist/Table/DefaultHeadCellRenderer/DefaultHeadCellRenderer';
import { withFilterAtBottom } from '../HOCs/withFilterAtBottom';
import { withFilter } from '../HOCs/withFilter';
export var getTableHeadData = function (columnsData, filters, onFilter) {
    return columnsData.map(function (_a) {
        var id = _a.id, label = _a.label, description = _a.description, sortable = _a.sortable, _b = _a.filterable, filterable = _b === void 0 ? true : _b, resizable = _a.resizable, draggable = _a.draggable, _c = _a.autoResize, autoResize = _c === void 0 ? true : _c, initialWidth = _a.initialWidth, minWidth = _a.minWidth, dataTypeDefinition = _a.dataTypeDefinition, filterOptions = _a.filterOptions, _d = _a.headCellRenderer, headCellRenderer = _d === void 0 ? withFilterAtBottom(DefaultHeadCellRenderer) : _d;
        return ({
            id: id,
            label: label,
            description: description,
            sortable: sortable,
            resizable: resizable,
            draggable: draggable,
            initialWidth: initialWidth,
            minWidth: minWidth,
            autoResize: autoResize,
            renderer: unless(function () { return isNil(filters); }, withFilter({
                dataTypeDefinition: dataTypeDefinition,
                filterable: filterable,
                filter: prop(id, filters),
                filterOptions: filterOptions,
                onFilter: onFilter
            }))(headCellRenderer)
        });
    });
};
