import React from 'react';
import { useCreateWSRColumnBase } from '../../hooks/useCreateWSRColumnBase';
import { NestedTableFlatModeMainCell } from './NestedTableFlatModeMainCell';
import { useNestedTableActionCell } from './useNestedTableActionCell';
export function useFlatModeColumns(props) {
    const { state, actionCellProps, actionCellWidth, horizontalScroll } = props;
    const { toolbar } = state;
    const { selectedOrderedColumnsOrAll } = toolbar;
    const createWSRColumnBase = useCreateWSRColumnBase({ horizontalScroll, showFieldTypeIcons: toolbar.showFieldTypeIcons });
    const actionCellColumn = useNestedTableActionCell({
        state: state.flat,
        actionCellWidth,
        actionCellProps,
    });
    const mainColumn = {
        key: 'flat-mode-main-column',
        dataHook: 'flat-mode-main-column',
        title: '',
        width: '326px',
        ...state.mainColumn,
        style: undefined,
        render: ({ item }, rowNum) => (React.createElement(NestedTableFlatModeMainCell, { item: item, rowNum: rowNum })),
    };
    const passedColumns = selectedOrderedColumnsOrAll.map((column) => {
        const { id, sortable } = column;
        return {
            ...column,
            sortDescending: sortable && id ? state.query.sort.getIsSortDescending(id) : undefined,
            render: ({ item }, rowNum) => {
                return item.state.columns?.[id]?.(item.originalKeyedItem.item, rowNum);
            },
        };
    });
    return [
        ...[mainColumn, ...passedColumns].map((column, index, { length }) => {
            return {
                ...column,
                ...createWSRColumnBase(column, index, length),
            };
        }),
        ...(actionCellColumn ? [actionCellColumn] : []),
    ];
}
//# sourceMappingURL=useFlatModeColumns.js.map