"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.useImageFeed = useImageFeed;
var _react = require("react");
var _tsSdkReactNative = require("@amityco/ts-sdk-react-native");
var _native = require("@react-navigation/native");
var _hooks = require("../../../../../../hooks");
var _enums = require("../../../../../../enums");
var _useFeedState = require("../../../hooks/useFeedState");
var _useUserFeed = _interopRequireDefault(require("../../../../../../hooks/collections/post/useUserFeed"));
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
function useImageFeed({
  userId,
  isBrand,
  isUserLoading,
  ref
}) {
  const navigation = (0, _native.useNavigation)();
  const {
    isBlockedByMe,
    isPrivate,
    feedEnabled
  } = (0, _useFeedState.useFeedState)({
    userId,
    isBrand,
    isUserLoading
  });
  const pageId = _enums.PageID.user_profile_page;
  const componentId = _enums.ComponentID.user_image_feed;
  const {
    accessibilityId: imageFeedId
  } = (0, _hooks.useAmityComponent)({
    pageId,
    componentId
  });
  const {
    config: emptyConfig
  } = (0, _hooks.useAmityElement)({
    pageId,
    componentId,
    elementId: _enums.ElementID.empty_user_image_feed
  });
  const {
    config: privateConfig
  } = (0, _hooks.useAmityElement)({
    pageId,
    componentId,
    elementId: _enums.ElementID.private_user_image_feed
  });
  const {
    config: privateInfoConfig
  } = (0, _hooks.useAmityElement)({
    pageId,
    componentId,
    elementId: _enums.ElementID.private_user_image_feed_info
  });
  const {
    config: blockedConfig
  } = (0, _hooks.useAmityElement)({
    pageId,
    componentId,
    elementId: _enums.ElementID.blocked_user_image_feed
  });
  const {
    config: blockedInfoConfig
  } = (0, _hooks.useAmityElement)({
    pageId,
    componentId,
    elementId: _enums.ElementID.blocked_user_image_feed_info
  });
  const {
    posts,
    hasMore,
    loadMore,
    isLoading,
    isLoadingFirstPage
  } = (0, _useUserFeed.default)({
    userId,
    enabled: feedEnabled,
    feedSources: [_tsSdkReactNative.FeedSourceEnum.User],
    dataTypes: [_tsSdkReactNative.FeedDataTypeEnum.Image]
  });
  (0, _react.useImperativeHandle)(ref, () => ({
    loadMore: () => hasMore && !isLoading && !isLoadingFirstPage && (loadMore === null || loadMore === void 0 ? void 0 : loadMore()),
    loading: isLoadingFirstPage || isLoading
  }), [hasMore, isLoadingFirstPage, loadMore, isLoading]);
  return {
    navigation,
    imageFeedId,
    posts,
    isLoading,
    isLoadingFirstPage,
    isBlockedByMe,
    isPrivate,
    emptyConfig,
    privateConfig,
    privateInfoConfig,
    blockedConfig,
    blockedInfoConfig
  };
}
//# sourceMappingURL=useImageFeed.js.map