import { isNullOrUndefined } from '@coveo/bueno';
import { createSelector } from '@reduxjs/toolkit';
import { totalEntriesRecommendationSelector } from '../pagination/pagination-selectors.js';
export const numberOfRecommendationsSelector = createSelector((state, slotId) => state.recommendations
    ? state.recommendations[slotId]?.products.length || 0
    : 0, (len) => len);
export const moreRecommendationsAvailableSelector = createSelector((state, slotId) => ({
    total: totalEntriesRecommendationSelector(state, slotId),
    current: numberOfRecommendationsSelector(state, slotId),
}), ({ current, total }) => current < total);
export const isLoadingSelector = createSelector((state, slotId) => state.recommendations ? state.recommendations[slotId]?.isLoading : false, (isLoading) => (isNullOrUndefined(isLoading) ? false : isLoading));
