import { useMemo } from 'react';
import { useIsMobile } from './useIsMobile';
export function useCollectionTableResize({ columns, horizontalScroll, userResizeProps, columnSizesState, }) {
    const experimentEnabled = columnSizesState?.isResizeExperimentEnabled ?? false;
    const isMobile = useIsMobile();
    const areAllColumnsPixelWidth = useMemo(() => columns.every((col) => col.width?.toString().match(/^\d+px$/)), [columns]);
    const isResizable = experimentEnabled &&
        !isMobile &&
        !!horizontalScroll &&
        areAllColumnsPixelWidth;
    const resizePlaceholderColumn = useMemo(() => ({ title: '', width: '100%', render: () => null }), []);
    const tableResizeProps = isResizable
        ? {
            ...userResizeProps,
            minColumnWidth: userResizeProps?.minColumnWidth ?? 74,
            onColumnResizeEnd(columnId, endWidth, event) {
                columnSizesState?.updateColumnWidth(columnId, Number(endWidth));
                userResizeProps?.onColumnResizeEnd?.(columnId, endWidth, event);
            },
        }
        : undefined;
    return {
        isResizable,
        tableResizeProps,
        resizePlaceholderColumn,
    };
}
//# sourceMappingURL=useCollectionTableResize.js.map