import { forwardRef } from 'react';
import { getFileUrlWithSize } from '../../../../../utils';
import { Gallery } from '../../../../../components/Gallery';
import { useVideoFeed } from './hooks/useVideoFeed';
export const VideoFeed = /*#__PURE__*/forwardRef(function VideoFeed({
  userId,
  isBrand,
  isUserLoading
}, ref) {
  const {
    navigation,
    videoFeedId,
    posts,
    isLoading,
    isLoadingFirstPage,
    isBlockedByMe,
    isPrivate,
    emptyConfig,
    privateConfig,
    privateInfoConfig,
    blockedConfig,
    blockedInfoConfig
  } = useVideoFeed({
    userId,
    isBrand,
    isUserLoading,
    ref
  });
  if (isBlockedByMe) {
    return /*#__PURE__*/React.createElement(Gallery.Empty, {
      icon: "block",
      title: blockedConfig === null || blockedConfig === void 0 ? void 0 : blockedConfig.text,
      description: blockedInfoConfig === null || blockedInfoConfig === void 0 ? void 0 : blockedInfoConfig.text
    });
  }
  if (isPrivate) {
    return /*#__PURE__*/React.createElement(Gallery.Empty, {
      icon: "private",
      title: privateConfig === null || privateConfig === void 0 ? void 0 : privateConfig.text,
      description: privateInfoConfig === null || privateInfoConfig === void 0 ? void 0 : privateInfoConfig.text
    });
  }
  return /*#__PURE__*/React.createElement(Gallery, {
    data: posts ?? [],
    keyExtractor: item => item.postId,
    isLoading: isLoadingFirstPage || isLoading,
    testID: videoFeedId,
    renderEmpty: () => /*#__PURE__*/React.createElement(Gallery.Empty, {
      title: emptyConfig === null || emptyConfig === void 0 ? void 0 : emptyConfig.text,
      icon: "video"
    }),
    renderItem: ({
      item
    }) => {
      var _item$getVideoInfo, _item$getVideoThumbna;
      return /*#__PURE__*/React.createElement(Gallery.Item, {
        timestamp: (_item$getVideoInfo = item.getVideoInfo()) === null || _item$getVideoInfo === void 0 || (_item$getVideoInfo = _item$getVideoInfo.attributes) === null || _item$getVideoInfo === void 0 || (_item$getVideoInfo = _item$getVideoInfo.metadata) === null || _item$getVideoInfo === void 0 || (_item$getVideoInfo = _item$getVideoInfo.video) === null || _item$getVideoInfo === void 0 ? void 0 : _item$getVideoInfo.duration,
        uri: getFileUrlWithSize((_item$getVideoThumbna = item.getVideoThumbnailInfo()) === null || _item$getVideoThumbna === void 0 ? void 0 : _item$getVideoThumbna.fileUrl, 'medium'),
        onPress: () => navigation.navigate('VideoPlayer', {
          source: item.getVideoInfo().fileUrl
        })
      });
    }
  });
});
//# sourceMappingURL=VideoFeed.js.map