"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _react = require("react");
var _reactNative = require("react-native");
var _RecommenedCommunityItems = require("./RecommenedCommunityItems/RecommenedCommunityItems");
var _styles = require("./styles");
var _enums = require("../../../../enums");
var _hooks = require("../../../../hooks");
var _ExploreProvider = require("../../../../providers/ExploreProvider");
var _native = require("@react-navigation/native");
const AmityRecommendedCommunityComponent = ({
  pageId = _enums.PageID.WildCardPage,
  componentId = _enums.ComponentID.WildCardComponent
}) => {
  const elementId = _enums.ElementID.explore_recommended_title;
  const navigation = (0, _native.useNavigation)();
  const {
    config,
    accessibilityId
  } = (0, _hooks.useAmityElement)({
    pageId,
    componentId,
    elementId
  });
  const styles = (0, _styles.useStyles)();
  const {
    recommendedCommunities
  } = (0, _ExploreProvider.useExplore)();
  const onPressCommunity = (0, _react.useCallback)(({
    communityId
  }) => {
    navigation.navigate('CommunityProfilePage', {
      communityId
    });
  }, [navigation]);
  return /*#__PURE__*/React.createElement(_reactNative.View, {
    testID: accessibilityId
  }, /*#__PURE__*/React.createElement(_reactNative.Text, {
    style: styles.headerText
  }, (config === null || config === void 0 ? void 0 : config.text) || 'Recommended for you'), /*#__PURE__*/React.createElement(_reactNative.FlatList, {
    horizontal: true,
    data: recommendedCommunities,
    renderItem: ({
      item
    }) => /*#__PURE__*/React.createElement(_reactNative.Pressable, {
      onPress: () => onPressCommunity({
        communityId: item.communityId
      })
    }, /*#__PURE__*/React.createElement(_RecommenedCommunityItems.RecommendedCommunityItem, {
      pageId: pageId,
      community: item
    })),
    keyExtractor: item => item.communityId,
    contentContainerStyle: styles.listContainer
  }));
};
var _default = exports.default = /*#__PURE__*/(0, _react.memo)(AmityRecommendedCommunityComponent);
//# sourceMappingURL=RecommendedCommunities.js.map