// ExploreContext.tsx
import { createContext, useContext } from 'react';
import { useRecommendedCommunities, useTrendingCommunities, useCategories } from '../hooks';
const ExploreContext = /*#__PURE__*/createContext(undefined);
export const ExploreProvider = ({
  children
}) => {
  const {
    onJoinCommunity: onJoinRecommendedCommunity,
    refresh: refreshRecommendedCommunities,
    communities: recommendedCommunities,
    loading: isLoadingRecommendedCommunities,
    error: recommendedCommunitiesError
  } = useRecommendedCommunities();
  const {
    refresh: refreshTrendingCommunities,
    communities: trendingCommunities,
    loading: isLoadingTrendingCommunities,
    error: trendingCommunitiesError
  } = useTrendingCommunities();
  const {
    refresh: refreshCategories,
    categories,
    loading: isLoadingCategories,
    hasMore: hasMoreCategories,
    error: categoriesError
  } = useCategories();
  const refresh = () => {
    refreshRecommendedCommunities();
    refreshTrendingCommunities();
    refreshCategories();
  };
  return /*#__PURE__*/React.createElement(ExploreContext.Provider, {
    value: {
      refresh,
      recommendedCommunities,
      trendingCommunities,
      categories,
      isLoading: isLoadingCategories || isLoadingRecommendedCommunities || isLoadingTrendingCommunities,
      isCategoryEmpty: !isLoadingCategories && (categories === null || categories === void 0 ? void 0 : categories.length) === 0,
      isRecommendedCommunitiesEmpty: !isLoadingRecommendedCommunities && (recommendedCommunities === null || recommendedCommunities === void 0 ? void 0 : recommendedCommunities.length) === 0,
      isTrendingCommunitiesEmpty: !isLoadingTrendingCommunities && (trendingCommunities === null || trendingCommunities === void 0 ? void 0 : trendingCommunities.length) === 0,
      hasMoreCategories,
      isAllError: categoriesError && recommendedCommunitiesError && trendingCommunitiesError,
      isAllCommunitiesError: recommendedCommunitiesError && trendingCommunitiesError,
      onJoinRecommendedCommunity
    }
  }, children);
};
export const useExplore = () => {
  const context = useContext(ExploreContext);
  if (context === undefined) {
    throw new Error('useExplore must be used within an ExploreProvider');
  }
  return context;
};
//# sourceMappingURL=ExploreProvider.js.map