import { forwardRef } from 'react';
import { getFileUrlWithSize } from '../../../../../utils';
import { Gallery } from '../../../../../components/Gallery';
import { useImageFeed } from './hooks/useImageFeed';
export const ImageFeed = /*#__PURE__*/forwardRef(function ImageFeed({
  userId,
  isBrand,
  isUserLoading
}, ref) {
  const {
    navigation,
    imageFeedId,
    posts,
    isLoading,
    isLoadingFirstPage,
    isBlockedByMe,
    isPrivate,
    emptyConfig,
    privateConfig,
    privateInfoConfig,
    blockedConfig,
    blockedInfoConfig
  } = useImageFeed({
    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: imageFeedId,
    renderEmpty: () => /*#__PURE__*/React.createElement(Gallery.Empty, {
      title: emptyConfig === null || emptyConfig === void 0 ? void 0 : emptyConfig.text,
      icon: "image"
    }),
    renderItem: ({
      item
    }) => {
      var _item$getImageInfo;
      return /*#__PURE__*/React.createElement(Gallery.Item, {
        uri: 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: getFileUrlWithSize((_item$getImageInfo2 = item.getImageInfo()) === null || _item$getImageInfo2 === void 0 ? void 0 : _item$getImageInfo2.fileUrl, 'large')
            }]
          });
        }
      });
    }
  });
});
//# sourceMappingURL=ImageFeed.js.map