import { useImperativeHandle } from 'react';
import { FeedDataTypeEnum, FeedSourceEnum } from '@amityco/ts-sdk-react-native';
import { useNavigation } from '@react-navigation/native';
import { useAmityComponent, useAmityElement } from '../../../../../../hooks';
import { ComponentID, ElementID, PageID } from '../../../../../../enums';
import { useFeedState } from '../../../hooks/useFeedState';
import useUserFeed from '../../../../../../hooks/collections/post/useUserFeed';
export function useVideoFeed({
  userId,
  isBrand,
  isUserLoading,
  ref
}) {
  const navigation = useNavigation();
  const {
    isBlockedByMe,
    isPrivate,
    feedEnabled
  } = useFeedState({
    userId,
    isBrand,
    isUserLoading
  });
  const pageId = PageID.user_profile_page;
  const componentId = ComponentID.user_video_feed;
  const {
    accessibilityId: videoFeedId
  } = useAmityComponent({
    pageId,
    componentId
  });
  const {
    config: emptyConfig
  } = useAmityElement({
    pageId,
    componentId,
    elementId: ElementID.empty_user_video_feed
  });
  const {
    config: privateConfig
  } = useAmityElement({
    pageId,
    componentId,
    elementId: ElementID.private_user_video_feed
  });
  const {
    config: privateInfoConfig
  } = useAmityElement({
    pageId,
    componentId,
    elementId: ElementID.private_user_video_feed_info
  });
  const {
    config: blockedConfig
  } = useAmityElement({
    pageId,
    componentId,
    elementId: ElementID.blocked_user_video_feed
  });
  const {
    config: blockedInfoConfig
  } = useAmityElement({
    pageId,
    componentId,
    elementId: ElementID.blocked_user_video_feed_info
  });
  const {
    posts,
    hasMore,
    loadMore,
    isLoading,
    isLoadingFirstPage
  } = useUserFeed({
    userId,
    enabled: feedEnabled,
    feedSources: [FeedSourceEnum.User],
    dataTypes: [FeedDataTypeEnum.Video]
  });
  useImperativeHandle(ref, () => ({
    loadMore: () => hasMore && !isLoading && !isLoadingFirstPage && (loadMore === null || loadMore === void 0 ? void 0 : loadMore()),
    loading: isLoadingFirstPage || isLoading
  }), [hasMore, isLoadingFirstPage, loadMore, isLoading]);
  return {
    navigation,
    videoFeedId,
    posts,
    isLoading,
    isLoadingFirstPage,
    isBlockedByMe,
    isPrivate,
    emptyConfig,
    privateConfig,
    privateInfoConfig,
    blockedConfig,
    blockedInfoConfig
  };
}
//# sourceMappingURL=useVideoFeed.js.map