"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.useExplore = exports.ExploreProvider = void 0;
var _react = require("react");
var _hooks = require("../hooks");
// ExploreContext.tsx

const ExploreContext = /*#__PURE__*/(0, _react.createContext)(undefined);
const ExploreProvider = ({
  children
}) => {
  const {
    onJoinCommunity: onJoinRecommendedCommunity,
    refresh: refreshRecommendedCommunities,
    communities: recommendedCommunities,
    loading: isLoadingRecommendedCommunities,
    error: recommendedCommunitiesError
  } = (0, _hooks.useRecommendedCommunities)();
  const {
    refresh: refreshTrendingCommunities,
    communities: trendingCommunities,
    loading: isLoadingTrendingCommunities,
    error: trendingCommunitiesError
  } = (0, _hooks.useTrendingCommunities)();
  const {
    refresh: refreshCategories,
    categories,
    loading: isLoadingCategories,
    hasMore: hasMoreCategories,
    error: categoriesError
  } = (0, _hooks.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);
};
exports.ExploreProvider = ExploreProvider;
const useExplore = () => {
  const context = (0, _react.useContext)(ExploreContext);
  if (context === undefined) {
    throw new Error('useExplore must be used within an ExploreProvider');
  }
  return context;
};
exports.useExplore = useExplore;
//# sourceMappingURL=ExploreProvider.js.map