import { useCallback, useEffect, useState } from 'react';
import { useWixPatternsContainer, usePrivateCreateCollection, } from '@wix/bex-core/react';
import { PickerContentState } from '../../state';
export function useCreatePickerContentState() {
    const { createBILogger } = useWixPatternsContainer();
    const createCollection = usePrivateCreateCollection();
    return useCallback((params) => {
        const { events, initialSelect, modalState, ...collectionConfig } = params;
        const collection = createCollection({
            ...collectionConfig,
            queryName: modalState.queryName,
            paginationMode: modalState.paginationMode,
            useNewSelectAllLogic: true,
            fetchData: modalState.fetchData,
            limit: modalState.limit,
            events: {
                ...modalState.events,
                ...events,
            },
        }, {
            paginationModeRef: modalState._paginationModeRef,
        });
        return new PickerContentState({
            modalState,
            collection,
            createBILogger,
            events,
            initialSelect,
        });
    }, []);
}
export function usePickerContentState(params) {
    const createPickerContentState = useCreatePickerContentState();
    const [state] = useState(() => createPickerContentState(params));
    useEffect(() => {
        state.initialSelect = params.initialSelect;
    }, [params.initialSelect]);
    return state;
}
//# sourceMappingURL=usePickerContentState.js.map