import React, { forwardRef, useMemo, } from 'react';
import { VirtualTableRepeater, } from '../VirtualGridRepeater/VirtualTableRepeater';
import { VirtualGridStateProvider } from '../VirtualGridRepeater/VirtualGridStateContext';
import { NestedTableRow } from './NestedTableRow';
import { useNestedModeColumns } from './useNestedModeColumns';
import { useFlatModeColumns } from './useFlatModeColumns';
import { NestedTablePlaceholderStatesRow } from './NestedTablePlaceholderStatesRow';
export function useModeTableProps(props) {
    const { state: wrapperState, horizontalScroll, actionCellWidth, actionCellProps, dragAndDrop, } = props;
    const { isFlatMode } = wrapperState;
    const state = isFlatMode ? wrapperState.flat : wrapperState.nested;
    const key = wrapperState.isFlatMode.toString();
    const BodyElementType = useMemo(() => ({ children }) => (React.createElement(VirtualGridStateProvider, { key: key, value: state.virtual },
        React.createElement(VirtualTableRepeater, null, children))), [state, key]);
    const TrElementType = useMemo(() => isFlatMode
        ? undefined
        : forwardRef((props, ref) => props.rowData.item.originalKeyedItem ? (React.createElement(NestedTableRow, { ref: ref, ...props, item: props.rowData.item, dragAndDrop: dragAndDrop })) : (React.createElement(NestedTablePlaceholderStatesRow, { ref: ref, ...props, item: props.rowData.item }))), [isFlatMode, dragAndDrop]);
    const nestedColumns = useNestedModeColumns({
        state: wrapperState,
        horizontalScroll,
        actionCellWidth,
        actionCellProps,
        dragAndDrop,
    });
    const flatColumns = useFlatModeColumns({
        state: wrapperState,
        horizontalScroll,
        actionCellWidth,
        actionCellProps,
    });
    return {
        state,
        key,
        BodyElementType,
        TrElementType,
        columns: isFlatMode ? flatColumns : nestedColumns,
    };
}
//# sourceMappingURL=useModeTableProps.js.map