"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _react = require("react");
var _reactNative = require("react-native");
var _enumUIKitID = require("../../../../enums/enumUIKitID");
var _hooks = require("../../../../hooks");
var _BehaviourProvider = require("../../../../providers/BehaviourProvider");
var _native = require("@react-navigation/native");
var _enums = require("../../../../enums");
var _icons = require("../../../../../core/assets/icons");
var _MenuAction = _interopRequireDefault(require("../../../../elements/MenuAction"));
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
const AmityCreatePostMenuComponent = ({
  pageId = _enumUIKitID.PageID.WildCardPage,
  componentId = _enumUIKitID.ComponentID.WildCardComponent
}) => {
  const navigation = (0, _native.useNavigation)();
  const {
    themeStyles
  } = (0, _hooks.useAmityComponent)({
    pageId,
    componentId
  });
  const {
    AmityCreatePostMenuComponentBehavior
  } = (0, _BehaviourProvider.useBehaviour)();
  const {
    hasStoryPermission
  } = (0, _hooks.useStoryPermission)();
  const styles = _reactNative.StyleSheet.create({
    container: {
      paddingVertical: 12,
      width: 200,
      backgroundColor: themeStyles.colors.background,
      borderRadius: 12
    },
    menu: {
      gap: 12,
      paddingVertical: 12,
      paddingHorizontal: 16,
      flexDirection: 'row',
      alignItems: 'center'
    }
  });
  const onPressCreatePost = (0, _react.useCallback)(postType => {
    var _postTypeHandlers$pos;
    const postTypeHandlers = {
      [_enums.AmityPostTargetSelectionPageType.post]: () => {
        if (AmityCreatePostMenuComponentBehavior.goToSelectPostTargetPage) {
          AmityCreatePostMenuComponentBehavior.goToSelectPostTargetPage({
            postType
          });
        }
        navigation.navigate('PostTargetSelection', {
          postType
        });
      },
      [_enums.AmityPostTargetSelectionPageType.story]: () => {
        if (AmityCreatePostMenuComponentBehavior.goToSelectStoryTargetPage) {
          AmityCreatePostMenuComponentBehavior.goToSelectStoryTargetPage();
        }
        navigation.navigate('StoryTargetSelection');
      },
      [_enums.AmityPostTargetSelectionPageType.poll]: () => {
        if (AmityCreatePostMenuComponentBehavior.goToSelectPollPostTargetPage) {
          AmityCreatePostMenuComponentBehavior.goToSelectPollPostTargetPage();
        }
        navigation.navigate('PollTargetSelection');
      },
      [_enums.AmityPostTargetSelectionPageType.livestream]: () => {
        if (AmityCreatePostMenuComponentBehavior.goToSelectLivestreamPostTargetPage) {
          AmityCreatePostMenuComponentBehavior.goToSelectLivestreamPostTargetPage();
        }
        navigation.navigate('LivestreamPostTargetSelection');
      }
    };
    (_postTypeHandlers$pos = postTypeHandlers[postType]) === null || _postTypeHandlers$pos === void 0 || _postTypeHandlers$pos.call(postTypeHandlers);
  }, [AmityCreatePostMenuComponentBehavior, navigation]);
  return /*#__PURE__*/React.createElement(_reactNative.View, {
    style: styles.container
  }, /*#__PURE__*/React.createElement(_MenuAction.default, {
    onPress: () => onPressCreatePost(_enums.AmityPostTargetSelectionPageType.post),
    style: styles.menu,
    label: "Post",
    iconProps: {
      xml: (0, _icons.post)()
    }
  }), hasStoryPermission && /*#__PURE__*/React.createElement(_MenuAction.default, {
    style: styles.menu,
    label: "Story",
    iconProps: {
      xml: (0, _icons.story)()
    },
    onPress: () => onPressCreatePost(_enums.AmityPostTargetSelectionPageType.story)
  }), /*#__PURE__*/React.createElement(_MenuAction.default, {
    style: styles.menu,
    label: "Poll",
    iconProps: {
      xml: (0, _icons.poll)()
    },
    onPress: () => onPressCreatePost(_enums.AmityPostTargetSelectionPageType.poll)
  }), /*#__PURE__*/React.createElement(_MenuAction.default, {
    style: styles.menu,
    label: "Livestream",
    iconProps: {
      xml: (0, _icons.livestream)()
    },
    onPress: () => onPressCreatePost(_enums.AmityPostTargetSelectionPageType.livestream)
  }));
};
var _default = exports.default = /*#__PURE__*/(0, _react.memo)(AmityCreatePostMenuComponent);
//# sourceMappingURL=CreatePostMenu.js.map