"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _react = require("react");
var _styles = require("./styles");
var _TopSearchBar = _interopRequireDefault(require("../../features/search/components/TopSearchBar"));
var _reactNativeSafeAreaContext = require("react-native-safe-area-context");
var _hooks = require("../../hooks");
var _enumTabName = require("../../enums/enumTabName");
var _enums = require("../../enums");
var _NoSearchResult = _interopRequireDefault(require("../../components/NoSearchResult/NoSearchResult"));
var _CommunitySearchResult = _interopRequireDefault(require("../../components/CommunitySearchResult/CommunitySearchResult"));
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
const AmityMyCommunitiesSearchPage = () => {
  const pageId = _enums.PageID.social_global_search_page;
  const {
    isExcluded,
    themeStyles
  } = (0, _hooks.useAmityPage)({
    pageId
  });
  const styles = (0, _styles.useStyles)(themeStyles);
  const [searchValue, setSearchValue] = (0, _react.useState)(null);
  const searchType = _enumTabName.TabName.MyCommunities;
  const {
    searchResult,
    onNextMyCommunityPage,
    isLoading
  } = (0, _hooks.useAmityGlobalSearchViewModel)(searchValue, searchType);
  if (isExcluded) return null;
  return /*#__PURE__*/React.createElement(_reactNativeSafeAreaContext.SafeAreaView, {
    style: styles.container
  }, /*#__PURE__*/React.createElement(_TopSearchBar.default, {
    searchType: searchType,
    setSearchValue: setSearchValue
  }), !isLoading && (searchResult === null || searchResult === void 0 ? void 0 : searchResult.length) === 0 ? /*#__PURE__*/React.createElement(_NoSearchResult.default, null) : /*#__PURE__*/React.createElement(_CommunitySearchResult.default, {
    pageId: pageId,
    isFirstTimeLoading: isLoading && !searchResult,
    isLoading: isLoading,
    communities: searchResult,
    onNextPage: onNextMyCommunityPage
  }));
};
var _default = exports.default = /*#__PURE__*/(0, _react.memo)(AmityMyCommunitiesSearchPage);
//# sourceMappingURL=index.js.map