"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.VideoFeed = void 0;
var _react = require("react");
var _utils = require("../../../../../utils");
var _Gallery = require("../../../../../components/Gallery");
var _useVideoFeed = require("./hooks/useVideoFeed");
const VideoFeed = exports.VideoFeed = /*#__PURE__*/(0, _react.forwardRef)(function VideoFeed({
  userId,
  isBrand,
  isUserLoading
}, ref) {
  const {
    navigation,
    videoFeedId,
    posts,
    isLoading,
    isLoadingFirstPage,
    isBlockedByMe,
    isPrivate,
    emptyConfig,
    privateConfig,
    privateInfoConfig,
    blockedConfig,
    blockedInfoConfig
  } = (0, _useVideoFeed.useVideoFeed)({
    userId,
    isBrand,
    isUserLoading,
    ref
  });
  if (isBlockedByMe) {
    return /*#__PURE__*/React.createElement(_Gallery.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.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.Gallery, {
    data: posts ?? [],
    keyExtractor: item => item.postId,
    isLoading: isLoadingFirstPage || isLoading,
    testID: videoFeedId,
    renderEmpty: () => /*#__PURE__*/React.createElement(_Gallery.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.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: (0, _utils.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