"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.ImageFeed = void 0;
var _react = require("react");
var _utils = require("../../../../../utils");
var _Gallery = require("../../../../../components/Gallery");
var _useImageFeed = require("./hooks/useImageFeed");
const ImageFeed = exports.ImageFeed = /*#__PURE__*/(0, _react.forwardRef)(function ImageFeed({
  userId,
  isBrand,
  isUserLoading
}, ref) {
  const {
    navigation,
    imageFeedId,
    posts,
    isLoading,
    isLoadingFirstPage,
    isBlockedByMe,
    isPrivate,
    emptyConfig,
    privateConfig,
    privateInfoConfig,
    blockedConfig,
    blockedInfoConfig
  } = (0, _useImageFeed.useImageFeed)({
    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: imageFeedId,
    renderEmpty: () => /*#__PURE__*/React.createElement(_Gallery.Gallery.Empty, {
      title: emptyConfig === null || emptyConfig === void 0 ? void 0 : emptyConfig.text,
      icon: "image"
    }),
    renderItem: ({
      item
    }) => {
      var _item$getImageInfo;
      return /*#__PURE__*/React.createElement(_Gallery.Gallery.Item, {
        uri: (0, _utils.getFileUrlWithSize)((_item$getImageInfo = item.getImageInfo()) === null || _item$getImageInfo === void 0 ? void 0 : _item$getImageInfo.fileUrl, 'medium'),
        onPress: () => {
          var _item$getImageInfo2;
          navigation.navigate('ImageViewer', {
            images: [{
              uri: (0, _utils.getFileUrlWithSize)((_item$getImageInfo2 = item.getImageInfo()) === null || _item$getImageInfo2 === void 0 ? void 0 : _item$getImageInfo2.fileUrl, 'large')
            }]
          });
        }
      });
    }
  });
});
//# sourceMappingURL=ImageFeed.js.map