"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _reactNative = require("react-native");
var _react = require("react");
var _enumTabName = require("../../../../enums/enumTabName");
var _SearchResultItem = _interopRequireDefault(require("../../../../components/SearchResultItem/SearchResultItem"));
var _enums = require("../../../../enums");
var _hooks = require("../../../../hooks");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
const AmityUserSearchResultComponent = ({
  searchResult,
  onNextPage,
  pageId = _enums.PageID.WildCardPage
}) => {
  const searchType = _enumTabName.TabName.Users;
  const componentId = _enums.ComponentID.community_search_result;
  const {
    isExcluded
  } = (0, _hooks.useAmityComponent)({
    pageId,
    componentId
  });
  const styles = _reactNative.StyleSheet.create({
    container: {
      flex: 1
    }
  });
  const renderSearchResultItem = ({
    item
  }) => {
    return /*#__PURE__*/React.createElement(_SearchResultItem.default, {
      item: item,
      searchType: searchType,
      pageId: pageId,
      componentId: componentId
    });
  };
  if (isExcluded) return null;
  if (!(searchResult !== null && searchResult !== void 0 && searchResult.length)) return null;
  return /*#__PURE__*/React.createElement(_reactNative.View, {
    style: styles.container
  }, /*#__PURE__*/React.createElement(_reactNative.FlatList, {
    data: searchResult,
    renderItem: renderSearchResultItem,
    keyExtractor: (_, index) => index.toString(),
    onEndReached: () => {
      onNextPage && onNextPage();
    }
  }));
};
var _default = exports.default = /*#__PURE__*/(0, _react.memo)(AmityUserSearchResultComponent);
//# sourceMappingURL=UserSearchResult.js.map