"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _reactNative = require("react-native");
var _react = require("react");
var _enums = require("../../../../enums");
var _hooks = require("../../../../hooks");
var _styles = require("./styles");
var _reactNativeSvg = require("react-native-svg");
var _icons = require("../../../../../core/assets/icons");
const AmityMediaAttachmentComponent = ({
  onPressCamera,
  onPressImage,
  onPressVideo,
  chosenMediaType,
  onHeightChange
}) => {
  var _themeStyles$colors, _themeStyles$colors2, _themeStyles$colors3;
  const pageId = _enums.PageID.post_composer_page;
  const componentId = _enums.ComponentID.media_attachment;
  const {
    accessibilityId,
    themeStyles,
    isExcluded
  } = (0, _hooks.useAmityComponent)({
    pageId,
    componentId
  });
  const cameraElement = (0, _hooks.useAmityElement)({
    pageId,
    componentId,
    elementId: _enums.ElementID.camera_button
  });
  const imageElement = (0, _hooks.useAmityElement)({
    pageId,
    componentId,
    elementId: _enums.ElementID.image_button
  });
  const videoElement = (0, _hooks.useAmityElement)({
    pageId,
    componentId,
    elementId: _enums.ElementID.video_button
  });
  const styles = (0, _styles.useStyles)(themeStyles);
  const animatedBottom = (0, _react.useRef)(new _reactNative.Animated.Value(-100)).current;
  const showMediaAttachments = (0, _react.useCallback)(() => {
    _reactNative.Animated.timing(animatedBottom, {
      toValue: 0,
      duration: 300,
      easing: _reactNative.Easing.ease,
      useNativeDriver: false
    }).start();
  }, [animatedBottom]);
  const hideMediaAttachments = (0, _react.useCallback)(() => {
    _reactNative.Animated.timing(animatedBottom, {
      toValue: -100,
      duration: 300,
      easing: _reactNative.Easing.ease,
      useNativeDriver: false
    }).start();
  }, [animatedBottom]);
  (0, _react.useEffect)(() => {
    showMediaAttachments();
    return () => hideMediaAttachments();
  }, [hideMediaAttachments, showMediaAttachments]);
  if (isExcluded) return null;
  return /*#__PURE__*/React.createElement(_reactNative.Animated.View, {
    testID: accessibilityId,
    accessibilityLabel: accessibilityId,
    style: [styles.container, {
      bottom: animatedBottom
    }],
    onLayout: e => onHeightChange === null || onHeightChange === void 0 ? void 0 : onHeightChange(e.nativeEvent.layout.height)
  }, /*#__PURE__*/React.createElement(_reactNative.View, {
    style: styles.handleBar
  }), /*#__PURE__*/React.createElement(_reactNative.View, {
    style: styles.buttonsContainer
  }, !cameraElement.isExcluded && /*#__PURE__*/React.createElement(_reactNative.Pressable, {
    testID: cameraElement.accessibilityId,
    accessibilityLabel: cameraElement.accessibilityId,
    onPress: onPressCamera
  }, /*#__PURE__*/React.createElement(_reactNative.View, {
    style: styles.iconContainer
  }, /*#__PURE__*/React.createElement(_reactNativeSvg.SvgXml, {
    xml: (0, _icons.camera)(),
    width: 24,
    height: 24,
    color: themeStyles === null || themeStyles === void 0 || (_themeStyles$colors = themeStyles.colors) === null || _themeStyles$colors === void 0 ? void 0 : _themeStyles$colors.base
  }))), !imageElement.isExcluded && (!chosenMediaType || chosenMediaType === _enums.mediaAttachment.image) && /*#__PURE__*/React.createElement(_reactNative.Pressable, {
    testID: imageElement.accessibilityId,
    accessibilityLabel: imageElement.accessibilityId,
    onPress: onPressImage
  }, /*#__PURE__*/React.createElement(_reactNative.View, {
    style: styles.iconContainer
  }, /*#__PURE__*/React.createElement(_reactNativeSvg.SvgXml, {
    xml: (0, _icons.photo)(),
    width: 24,
    height: 24,
    color: themeStyles === null || themeStyles === void 0 || (_themeStyles$colors2 = themeStyles.colors) === null || _themeStyles$colors2 === void 0 ? void 0 : _themeStyles$colors2.base
  }))), !videoElement.isExcluded && (!chosenMediaType || chosenMediaType === _enums.mediaAttachment.video) && /*#__PURE__*/React.createElement(_reactNative.Pressable, {
    testID: videoElement.accessibilityId,
    accessibilityLabel: videoElement.accessibilityId,
    onPress: onPressVideo
  }, /*#__PURE__*/React.createElement(_reactNative.View, {
    style: styles.iconContainer
  }, /*#__PURE__*/React.createElement(_reactNativeSvg.SvgXml, {
    xml: (0, _icons.video)(),
    width: 24,
    height: 24,
    color: themeStyles === null || themeStyles === void 0 || (_themeStyles$colors3 = themeStyles.colors) === null || _themeStyles$colors3 === void 0 ? void 0 : _themeStyles$colors3.base
  })))));
};
var _default = exports.default = /*#__PURE__*/(0, _react.memo)(AmityMediaAttachmentComponent);
//# sourceMappingURL=MediaAttachment.js.map