"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getTableHeadData = void 0;
var ramda_1 = require("ramda");
var DefaultHeadCellRenderer_1 = __importDefault(require("react-components/dist/Table/DefaultHeadCellRenderer/DefaultHeadCellRenderer"));
var withFilterAtBottom_1 = require("../HOCs/withFilterAtBottom");
var withFilter_1 = require("../HOCs/withFilter");
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 ? (0, withFilterAtBottom_1.withFilterAtBottom)(DefaultHeadCellRenderer_1.default) : _d;
        return ({
            id: id,
            label: label,
            description: description,
            sortable: sortable,
            resizable: resizable,
            draggable: draggable,
            initialWidth: initialWidth,
            minWidth: minWidth,
            autoResize: autoResize,
            renderer: (0, ramda_1.unless)(function () { return (0, ramda_1.isNil)(filters); }, (0, withFilter_1.withFilter)({
                dataTypeDefinition: dataTypeDefinition,
                filterable: filterable,
                filter: (0, ramda_1.prop)(id, filters),
                filterOptions: filterOptions,
                onFilter: onFilter
            }))(headCellRenderer)
        });
    });
};
exports.getTableHeadData = getTableHeadData;
