import { ActivityIndicator, Alert, Animated, Image, KeyboardAvoidingView, Linking, Platform, Text, TouchableOpacity, TouchableWithoutFeedback, View } from 'react-native';
import LinearGradient from 'react-native-linear-gradient';
import { memo, useCallback, useRef, useState } from 'react';
import { useConfigImageUri, useStory } from '../../../../hooks';
import { useStyles } from '../styles';
import Video from 'react-native-video';
import { seenIcon, storyCircleCreatePlusIcon, storyCommentIcon, storyHyperLinkIcon, storyLikeIcon, storyLikedIcon, storyThreedotsMenu } from '../../../../../core/assets/icons/xml';
import { trash } from '../../../../../core/assets/icons';
import { SvgXml } from 'react-native-svg';
import Modal from 'react-native-modalbox';
import { ComponentID, ElementID, PageID } from '../../../../enums';
import useConfig from '../../../../hooks/useConfig';
import BottomSheet from '@devvie/bottom-sheet';
import CommentList from '../../../../components/Social/CommentList/CommentList';
import { StoryRepository } from '@amityco/ts-sdk-react-native';
import { useTimeDifference } from '../../../../../core/hooks/useTimeDifference';
import { STORY_DEFAULT_DURATION } from '../../../../../core/constants';
import GestureRecognizer from 'react-native-swipe-gestures';
import uiSlice from '../../../../../core/stores/slices/uiSlice';
import { LoadingOverlay } from '../../../../components/legacy/LoadingOverlay';
import Toast from '../../../../components/legacy/Toast/Toast';
import { Typography } from '../../../../../core/components/Typography/Typography';
import { useTheme } from 'react-native-paper';
import { useUIKitDispatch } from '../../../../../core/stores/store';
import { informative } from '../../../../../core/assets/icons/toast';
import { close as closeIcon } from '../../../../../core/assets/icons';
import { SafeAreaView } from 'react-native-safe-area-context';
const AmityViewStoryItem = ({
  communityAvatar,
  communityData,
  storyData,
  hasStoryImpressionPermission,
  close,
  onClose,
  setCurrent,
  current,
  hasStoryPermission,
  onPressAvatar,
  onPressCommunityName,
  onNavigateToUser
}) => {
  var _currentStory$items$, _getUiKitConfig, _getUiKitConfig2, _getUiKitConfig3, _getUiKitConfig4, _currentStory$imageDa, _currentStory$videoDa, _currentStory$imageDa2, _currentStory$data, _currentStory$data2, _currentStory$data3, _currentStory$videoDa2, _currentStory$data4, _currentStory$data5, _currentStory$data6, _currentStory$data7;
  const styles = useStyles();
  const theme = useTheme();
  const {
    getUiKitConfig
  } = useConfig();
  const progress = useRef(new Animated.Value(0)).current;
  const sheetRef = useRef(null);
  const {
    handleReaction
  } = useStory();
  const currentStory = storyData[current];
  const storyHyperLink = (currentStory === null || currentStory === void 0 || (_currentStory$items$ = currentStory.items[0]) === null || _currentStory$items$ === void 0 ? void 0 : _currentStory$items$.data) || undefined;
  const timeDifference = useTimeDifference(currentStory === null || currentStory === void 0 ? void 0 : currentStory.createdAt, true);
  const reachCount = (currentStory === null || currentStory === void 0 ? void 0 : currentStory.reach) ?? 0;
  const reactionsCounts = (currentStory === null || currentStory === void 0 ? void 0 : currentStory.reactionsCount) ?? 0;
  const commentsCounts = (currentStory === null || currentStory === void 0 ? void 0 : currentStory.commentsCount) ?? 0;
  const myReactions = currentStory === null || currentStory === void 0 ? void 0 : currentStory.myReactions;
  const [pressed, setPressed] = useState(false);
  const [muted, setMuted] = useState(false);
  const [storyDuration, setStoryDuration] = useState(STORY_DEFAULT_DURATION);
  const [currentSeek, setCurrentSeek] = useState(0);
  const [totalReaction, setTotalReaction] = useState(reactionsCounts);
  const [isLiked, setIsLiked] = useState((myReactions === null || myReactions === void 0 ? void 0 : myReactions.length) > 0);
  const [openCommentSheet, setOpenCommentSheet] = useState(false);
  const [load, setLoad] = useState(true);
  const [loading, setLoading] = useState(false);
  const dispatch = useUIKitDispatch();
  const {
    showToastMessage
  } = uiSlice.actions;
  const storyViewerBgColor = ((_getUiKitConfig = getUiKitConfig({
    page: PageID.StoryPage,
    component: ComponentID.WildCardComponent,
    element: ElementID.StoryImpressionBtn
  })) === null || _getUiKitConfig === void 0 ? void 0 : _getUiKitConfig.background_color) ?? '#2b2b2b';
  const storyCommentBgColor = ((_getUiKitConfig2 = getUiKitConfig({
    page: PageID.StoryPage,
    component: ComponentID.WildCardComponent,
    element: ElementID.StoryCommentBtn
  })) === null || _getUiKitConfig2 === void 0 ? void 0 : _getUiKitConfig2.background_color) ?? '#2b2b2b';
  const storyReactionBgColor = ((_getUiKitConfig3 = getUiKitConfig({
    element: ElementID.StoryRing,
    component: ComponentID.WildCardComponent,
    page: PageID.StoryPage
  })) === null || _getUiKitConfig3 === void 0 ? void 0 : _getUiKitConfig3.background_color) ?? '#2b2b2b';
  const storyPlusBgColor = ((_getUiKitConfig4 = getUiKitConfig({
    page: PageID.StoryPage,
    component: ComponentID.WildCardComponent,
    element: ElementID.StoryHyperLinkBtn
  })) === null || _getUiKitConfig4 === void 0 ? void 0 : _getUiKitConfig4.background_color) ?? '#ffffff';
  const muteIcon = useConfigImageUri({
    configPath: {
      page: PageID.StoryPage,
      component: ComponentID.WildCardComponent,
      element: ElementID.SpeakerBtn
    },
    configKey: 'mute_icon'
  });
  const unmuteIcon = useConfigImageUri({
    configPath: {
      page: PageID.StoryPage,
      component: ComponentID.WildCardComponent,
      element: ElementID.SpeakerBtn
    },
    configKey: 'unmute_icon'
  });
  const handleLoadVideo = data => {
    setStoryDuration(data.duration * 1000);
  };
  const next = useCallback(() => {
    setCurrentSeek(0);
    setLoad(true);
    if (current !== storyData.length - 1) {
      let data = [...storyData];
      data[current].finish = 1;
      setCurrent(current + 1);
      progress.setValue(0);
    } else {
      close('next');
    }
  }, [close, current, progress, setCurrent, setLoad, storyData]);
  const startAnimation = useCallback(() => {
    Animated.timing(progress, {
      toValue: 1,
      duration: storyDuration - currentSeek * 1000,
      useNativeDriver: false
    }).start(({
      finished
    }) => {
      if (finished) {
        next();
      }
    });
  }, [currentSeek, next, progress, storyDuration]);
  const start = useCallback(() => {
    setLoad(false);
    startAnimation();
  }, [setLoad, startAnimation]);
  const previous = useCallback(() => {
    setCurrentSeek(0);
    setLoad(true);
    if (current - 1 >= 0) {
      let data = [...storyData];
      data[current].finish = 0;
      setCurrent(current - 1);
      progress.setValue(0);
    } else {
      close('previous');
    }
  }, [close, current, progress, setCurrent, storyData]);
  const onPressComment = useCallback(() => {
    progress.stopAnimation(() => setPressed(true));
    return setOpenCommentSheet(true);
  }, [progress]);
  const onPressReaction = useCallback(() => {
    if (communityData !== null && communityData !== void 0 && communityData.isJoined) {
      handleReaction({
        targetId: currentStory === null || currentStory === void 0 ? void 0 : currentStory.storyId,
        reactionName: 'like',
        isLiked
      });
      setTotalReaction(prev => isLiked ? prev - 1 : prev + 1);
      setIsLiked(prev => !prev);
      return;
    }
    progress.stopAnimation(() => setPressed(true));
    Alert.alert('Join community to interact with all stories', null, [{
      text: 'OK',
      onPress: () => {
        startAnimation();
        setPressed(false);
      }
    }]);
  }, [communityData === null || communityData === void 0 ? void 0 : communityData.isJoined, currentStory === null || currentStory === void 0 ? void 0 : currentStory.storyId, handleReaction, isLiked, progress, startAnimation]);
  const onCloseBottomSheet = useCallback(() => {
    startAnimation();
    setPressed(false);
  }, [startAnimation]);
  const onClosedCommentSheet = useCallback(() => {
    setOpenCommentSheet(false);
    startAnimation();
    setPressed(false);
  }, [startAnimation]);
  const onNavigateFromComment = useCallback(userId => {
    onClosedCommentSheet();
    onNavigateToUser && onNavigateToUser(userId);
  }, [onClosedCommentSheet, onNavigateToUser]);
  const deleteStory = useCallback(async () => {
    setLoading(true);
    try {
      current > 0 && previous();
      const deleted = await StoryRepository.softDeleteStory(currentStory === null || currentStory === void 0 ? void 0 : currentStory.storyId);
      if (deleted) {
        current === 0 && previous();
        dispatch(showToastMessage({
          toastMessage: 'Story deleted',
          isSuccessToast: true
        }));
      }
    } catch (err) {
      dispatch(showToastMessage({
        toastMessage: 'Failed to delete story. Please try again.',
        isSuccessToast: false
      }));
    } finally {
      var _sheetRef$current;
      setLoading(false);
      sheetRef === null || sheetRef === void 0 || (_sheetRef$current = sheetRef.current) === null || _sheetRef$current === void 0 || _sheetRef$current.close();
    }
  }, [current, currentStory === null || currentStory === void 0 ? void 0 : currentStory.storyId, dispatch, previous, showToastMessage]);
  const onPressDelete = useCallback(() => {
    Alert.alert('Delete this story?', "This story will be permanently deleted. You'll no longer to see and find this story", [{
      text: 'Cancel',
      onPress: () => {
        var _sheetRef$current2;
        return sheetRef === null || sheetRef === void 0 || (_sheetRef$current2 = sheetRef.current) === null || _sheetRef$current2 === void 0 ? void 0 : _sheetRef$current2.close();
      }
    }, {
      text: 'Delete',
      style: 'destructive',
      onPress: deleteStory
    }]);
  }, [deleteStory]);
  const onPressHyperLink = useCallback(async () => {
    var _storyHyperLink$url;
    currentStory === null || currentStory === void 0 || currentStory.analytics.markLinkAsClicked();
    const hyperlinkUrl = storyHyperLink !== null && storyHyperLink !== void 0 && (_storyHyperLink$url = storyHyperLink.url) !== null && _storyHyperLink$url !== void 0 && _storyHyperLink$url.includes('http') ? storyHyperLink === null || storyHyperLink === void 0 ? void 0 : storyHyperLink.url : `https://${storyHyperLink === null || storyHyperLink === void 0 ? void 0 : storyHyperLink.url}`;
    await Linking.openURL('https://google.com');
    const supported = await Linking.canOpenURL(hyperlinkUrl);
    if (supported) {
      await Linking.openURL(hyperlinkUrl);
    } else {
      Alert.alert(`Cannot open : ${hyperlinkUrl}`);
    }
  }, [currentStory === null || currentStory === void 0 ? void 0 : currentStory.analytics, storyHyperLink === null || storyHyperLink === void 0 ? void 0 : storyHyperLink.url]);
  const onPressMenu = useCallback(() => {
    var _sheetRef$current3;
    progress.stopAnimation(() => setPressed(true));
    (_sheetRef$current3 = sheetRef.current) === null || _sheetRef$current3 === void 0 || _sheetRef$current3.open();
  }, [progress]);
  const onPressMenuButtonFailed = useCallback(() => {
    progress.stopAnimation(() => setPressed(true));
    Alert.alert('Failed to upload story', 'Would you like to discard uploading?', [{
      text: 'Cancel',
      onPress: () => {
        var _sheetRef$current4;
        return sheetRef === null || sheetRef === void 0 || (_sheetRef$current4 = sheetRef.current) === null || _sheetRef$current4 === void 0 ? void 0 : _sheetRef$current4.close();
      }
    }, {
      text: 'Delete',
      style: 'destructive',
      onPress: deleteStory
    }]);
  }, [deleteStory, progress]);
  const isFailedImageUpload = (currentStory === null || currentStory === void 0 ? void 0 : currentStory.dataType) === 'image' && ((currentStory === null || currentStory === void 0 ? void 0 : currentStory.syncState) === 'error' || (currentStory === null || currentStory === void 0 ? void 0 : currentStory.syncState) === 'syncing' || !(currentStory !== null && currentStory !== void 0 && (_currentStory$imageDa = currentStory.imageData) !== null && _currentStory$imageDa !== void 0 && _currentStory$imageDa.fileUrl));
  const isFailedVideoUpload = (currentStory === null || currentStory === void 0 ? void 0 : currentStory.dataType) === 'video' && ((currentStory === null || currentStory === void 0 ? void 0 : currentStory.syncState) === 'error' || (currentStory === null || currentStory === void 0 ? void 0 : currentStory.syncState) === 'syncing' || !(currentStory !== null && currentStory !== void 0 && (_currentStory$videoDa = currentStory.videoData) !== null && _currentStory$videoDa !== void 0 && _currentStory$videoDa.fileUrl));
  const imageUri = (currentStory === null || currentStory === void 0 || (_currentStory$imageDa2 = currentStory.imageData) === null || _currentStory$imageDa2 === void 0 ? void 0 : _currentStory$imageDa2.fileUrl) || (typeof (currentStory === null || currentStory === void 0 || (_currentStory$data = currentStory.data) === null || _currentStory$data === void 0 ? void 0 : _currentStory$data.fileData) === 'string' ? currentStory === null || currentStory === void 0 || (_currentStory$data2 = currentStory.data) === null || _currentStory$data2 === void 0 ? void 0 : _currentStory$data2.fileData : '');
  return /*#__PURE__*/React.createElement(View, {
    style: [styles.container]
  }, (currentStory === null || currentStory === void 0 ? void 0 : currentStory.dataType) === 'image' && (currentStory === null || currentStory === void 0 || (_currentStory$data3 = currentStory.data) === null || _currentStory$data3 === void 0 ? void 0 : _currentStory$data3.imageDisplayMode) !== 'fill' && /*#__PURE__*/React.createElement(Image, {
    source: {
      uri: imageUri
    },
    style: styles.blurredBackground,
    resizeMode: "cover",
    blurRadius: 20
  }), /*#__PURE__*/React.createElement(SafeAreaView, null, /*#__PURE__*/React.createElement(View, {
    style: styles.backgroundContainer
  }, (currentStory === null || currentStory === void 0 ? void 0 : currentStory.dataType) === 'video' ? /*#__PURE__*/React.createElement(Video, {
    onLoadStart: () => setLoad(true),
    onProgress: ({
      currentTime
    }) => setCurrentSeek(currentTime),
    source: {
      uri: (currentStory === null || currentStory === void 0 || (_currentStory$videoDa2 = currentStory.videoData) === null || _currentStory$videoDa2 === void 0 ? void 0 : _currentStory$videoDa2.fileUrl) || (typeof (currentStory === null || currentStory === void 0 || (_currentStory$data4 = currentStory.data) === null || _currentStory$data4 === void 0 ? void 0 : _currentStory$data4.fileData) === 'string' ? currentStory === null || currentStory === void 0 || (_currentStory$data5 = currentStory.data) === null || _currentStory$data5 === void 0 ? void 0 : _currentStory$data5.fileData : '')
    },
    style: styles.video,
    resizeMode: "contain",
    controls: false,
    onReadyForDisplay: () => start(),
    paused: pressed,
    onLoad: handleLoadVideo,
    muted: muted
  }) : (currentStory === null || currentStory === void 0 ? void 0 : currentStory.dataType) === 'image' ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Image, {
    onLoadStart: () => setLoad(true),
    onLoadEnd: () => start(),
    source: {
      uri: imageUri
    },
    style: [styles.image,
    // eslint-disable-next-line react-native/no-inline-styles
    isFailedImageUpload && {
      opacity: 0.6
    }],
    resizeMode: (currentStory === null || currentStory === void 0 || (_currentStory$data6 = currentStory.data) === null || _currentStory$data6 === void 0 ? void 0 : _currentStory$data6.imageDisplayMode) === 'fill' ? 'cover' : 'contain'
  }), (currentStory === null || currentStory === void 0 || (_currentStory$data7 = currentStory.data) === null || _currentStory$data7 === void 0 ? void 0 : _currentStory$data7.imageDisplayMode) === 'fill' && /*#__PURE__*/React.createElement(LinearGradient, {
    colors: ['rgba(0, 0, 0, 0.4)', 'transparent', 'rgba(0, 0, 0, 0.4)'],
    start: {
      x: 0,
      y: 0
    },
    end: {
      x: 0,
      y: 1
    },
    style: styles.storyGradient
  })) : null, load && /*#__PURE__*/React.createElement(View, {
    style: styles.spinnerContainer
  }, /*#__PURE__*/React.createElement(ActivityIndicator, {
    size: "large",
    color: 'white'
  })))), /*#__PURE__*/React.createElement(GestureRecognizer, {
    onSwipeUp: onPressComment,
    style: styles.flexCol
  }, /*#__PURE__*/React.createElement(View, {
    style: [styles.animationBarContainer]
  }, storyData.map((story, index) => {
    return /*#__PURE__*/React.createElement(View, {
      key: story.storyId,
      style: [styles.animationBackground]
    }, /*#__PURE__*/React.createElement(Animated.View, {
      style: [
      // eslint-disable-next-line react-native/no-inline-styles
      {
        flex: current === index ? progress : storyData[index].finish,
        height: 2,
        backgroundColor: 'white'
      }]
    }));
  })), /*#__PURE__*/React.createElement(View, {
    style: [styles.userContainer]
  }, /*#__PURE__*/React.createElement(View, {
    style: styles.flexRowCenter
  }, /*#__PURE__*/React.createElement(TouchableOpacity, {
    onPress: () => {
      onPressAvatar && onPressAvatar();
    },
    hitSlop: 10
  }, /*#__PURE__*/React.createElement(Image, {
    style: [styles.avatarImage],
    source: {
      uri: communityAvatar
    }
  }), hasStoryPermission && /*#__PURE__*/React.createElement(SvgXml, {
    height: 12,
    width: 12,
    style: styles.storyCreateIcon,
    xml: storyCircleCreatePlusIcon(storyPlusBgColor)
  })), /*#__PURE__*/React.createElement(View, null, /*#__PURE__*/React.createElement(Text, {
    onPress: () => onPressCommunityName && onPressCommunityName(),
    style: styles.avatarText
  }, communityData === null || communityData === void 0 ? void 0 : communityData.displayName), /*#__PURE__*/React.createElement(View, {
    style: styles.flexRowCenter
  }, /*#__PURE__*/React.createElement(Text, {
    style: [styles.avatarSubText,
    // eslint-disable-next-line react-native/no-inline-styles
    {
      marginLeft: 10
    }]
  }, timeDifference, " .", ' '), /*#__PURE__*/React.createElement(Text, {
    style: styles.avatarSubText
  }, "By ", currentStory === null || currentStory === void 0 ? void 0 : currentStory.creator.displayName)))), /*#__PURE__*/React.createElement(View, {
    style: styles.closeIconContainer
  }, /*#__PURE__*/React.createElement(View, {
    style: styles.menuCloseContaier
  }, hasStoryPermission && /*#__PURE__*/React.createElement(TouchableOpacity, {
    hitSlop: 5,
    style: styles.threeDotsMenu,
    onPress: onPressMenu
  }, /*#__PURE__*/React.createElement(SvgXml, {
    xml: storyThreedotsMenu(),
    width: "25",
    height: "25"
  })), /*#__PURE__*/React.createElement(TouchableOpacity, {
    hitSlop: 5,
    onPress: () => onClose()
  }, /*#__PURE__*/React.createElement(SvgXml, {
    xml: closeIcon(),
    width: "28",
    height: "28",
    color: "white"
  }))))), /*#__PURE__*/React.createElement(View, {
    style: styles.pressContainer
  }, /*#__PURE__*/React.createElement(TouchableWithoutFeedback, {
    onPressIn: () => progress.stopAnimation(),
    onLongPress: () => setPressed(true),
    delayLongPress: 300,
    onPressOut: () => {
      setPressed(false);
      startAnimation();
    },
    onPress: () => {
      if (!pressed) {
        previous();
      }
    }
  }, /*#__PURE__*/React.createElement(View, {
    style: styles.flex
  })), /*#__PURE__*/React.createElement(TouchableWithoutFeedback, {
    onPressIn: () => progress.stopAnimation(),
    onLongPress: () => setPressed(true),
    delayLongPress: 300,
    onPressOut: () => {
      setPressed(false);
      startAnimation();
    },
    onPress: () => {
      if (!pressed) {
        next();
      }
    }
  }, /*#__PURE__*/React.createElement(View, {
    style: styles.flex
  }))), storyHyperLink && /*#__PURE__*/React.createElement(TouchableOpacity, {
    style: styles.hyperlinkContainer,
    onPress: onPressHyperLink
  }, /*#__PURE__*/React.createElement(SvgXml, {
    xml: storyHyperLinkIcon(theme.colors.primary),
    width: "20",
    height: "20"
  }), /*#__PURE__*/React.createElement(Typography.Body, {
    style: styles.hyperlinkText
  }, storyHyperLink.customText || storyHyperLink.url)), (currentStory === null || currentStory === void 0 ? void 0 : currentStory.dataType) === 'video' && /*#__PURE__*/React.createElement(TouchableOpacity, {
    style: styles.muteBtn,
    onPress: () => setMuted(prev => !prev)
  }, /*#__PURE__*/React.createElement(Image, {
    source: muted ? muteIcon : unmuteIcon,
    style: styles.muteIcon
  }))), (isFailedImageUpload || isFailedVideoUpload) && hasStoryPermission ? /*#__PURE__*/React.createElement(View, {
    style: styles.errorContainer
  }, /*#__PURE__*/React.createElement(View, {
    style: styles.errorContainerLeft
  }, /*#__PURE__*/React.createElement(SvgXml, {
    xml: informative('white'),
    width: "20",
    height: "20"
  }), /*#__PURE__*/React.createElement(Typography.Body, {
    style: styles.errorText
  }, "Failed to upload story")), /*#__PURE__*/React.createElement(TouchableOpacity, {
    hitSlop: 5,
    style: styles.threeDotsMenu,
    onPress: onPressMenuButtonFailed
  }, /*#__PURE__*/React.createElement(SvgXml, {
    xml: storyThreedotsMenu(),
    width: "20",
    height: "20"
  }))) : /*#__PURE__*/React.createElement(View, {
    style: styles.footer
  }, hasStoryImpressionPermission ? /*#__PURE__*/React.createElement(TouchableOpacity, {
    style: [styles.seenContainer, {
      backgroundColor: storyViewerBgColor
    }]
  }, /*#__PURE__*/React.createElement(SvgXml, {
    xml: seenIcon(),
    width: "25",
    height: "25"
  }), /*#__PURE__*/React.createElement(Text, {
    style: styles.seen
  }, reachCount)) : /*#__PURE__*/React.createElement(View, {
    style: styles.seenContainer
  }), /*#__PURE__*/React.createElement(View, {
    style: styles.seenContainer
  }, /*#__PURE__*/React.createElement(TouchableOpacity, {
    style: [styles.iconContainer, {
      backgroundColor: storyCommentBgColor
    }],
    onPress: onPressComment
  }, /*#__PURE__*/React.createElement(SvgXml, {
    xml: storyCommentIcon(),
    width: "25",
    height: "25"
  }), /*#__PURE__*/React.createElement(Text, {
    style: styles.seen
  }, commentsCounts)), /*#__PURE__*/React.createElement(TouchableOpacity, {
    style: [styles.iconContainer, {
      backgroundColor: storyReactionBgColor
    }],
    onPress: onPressReaction
  }, /*#__PURE__*/React.createElement(SvgXml, {
    xml: isLiked ? storyLikedIcon : storyLikeIcon,
    width: "25",
    height: "25"
  }), /*#__PURE__*/React.createElement(Text, {
    style: styles.seen
  }, totalReaction)))), openCommentSheet && /*#__PURE__*/React.createElement(Modal, {
    style: styles.bottomSheet,
    isOpen: openCommentSheet,
    onClosed: onClosedCommentSheet,
    position: "bottom",
    swipeToClose: true,
    swipeArea: 250,
    backButtonClose: true,
    coverScreen: true
  }, /*#__PURE__*/React.createElement(KeyboardAvoidingView, {
    behavior: Platform.OS === 'ios' ? 'padding' : 'height',
    style: styles.commentBottomSheet
  }, /*#__PURE__*/React.createElement(View, {
    style: styles.handleBar
  }), /*#__PURE__*/React.createElement(Text, {
    style: styles.commentTitle
  }, "Comments"), /*#__PURE__*/React.createElement(View, {
    style: styles.horizontalSperator
  }), /*#__PURE__*/React.createElement(CommentList, {
    postId: currentStory === null || currentStory === void 0 ? void 0 : currentStory.storyId,
    postType: "story",
    disabledComment: !(communityData !== null && communityData !== void 0 && communityData.allowCommentInStory),
    disabledInteraction: !(communityData !== null && communityData !== void 0 && communityData.isJoined),
    onNavigate: onNavigateFromComment,
    withAvatar: true
  }))), /*#__PURE__*/React.createElement(BottomSheet, {
    ref: sheetRef,
    onClose: onCloseBottomSheet,
    closeOnDragDown: true,
    height: 120,
    style: styles.deleteBottomSheet
  }, /*#__PURE__*/React.createElement(View, {
    style: styles.deleteBottomSheet
  }, /*#__PURE__*/React.createElement(TouchableOpacity, {
    style: styles.deleteBtn,
    onPress: onPressDelete
  }, /*#__PURE__*/React.createElement(SvgXml, {
    xml: trash(),
    width: 24,
    height: 24
  }), /*#__PURE__*/React.createElement(Text, {
    style: styles.deleteStoryTxt
  }, "Delete story")))), /*#__PURE__*/React.createElement(LoadingOverlay, {
    isLoading: loading
  }), /*#__PURE__*/React.createElement(Toast, null));
};
export default /*#__PURE__*/memo(AmityViewStoryItem);
//# sourceMappingURL=AmityViewStoryItem.js.map