"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _react = require("react");
var _reactNative = require("react-native");
var _hooks = require("../../hooks");
var _enums = require("../../enums");
var _reactNativeSvg = require("react-native-svg");
var _icons = require("../../../core/assets/icons");
const CategoryRowImage = ({
  avatarFileId,
  pageId = _enums.PageID.WildCardPage,
  componentId = _enums.ComponentID.WildCardComponent
}) => {
  const elementId = _enums.ElementID.category_row_image;
  const {
    getImage
  } = (0, _hooks.useFile)();
  const {
    themeStyles,
    isExcluded
  } = (0, _hooks.useAmityElement)({
    pageId,
    componentId,
    elementId
  });
  const [imageUri, setImageUri] = (0, _react.useState)(null);
  const styles = _reactNative.StyleSheet.create({
    contianer: {
      color: themeStyles === null || themeStyles === void 0 ? void 0 : themeStyles.colors.base,
      height: 40,
      width: 40,
      borderRadius: 40
    },
    placeholder: {
      width: '100%',
      height: '100%',
      borderRadius: 40,
      justifyContent: 'center',
      alignItems: 'center',
      // TODO: fix color
      backgroundColor: themeStyles.colors.primaryShade2
    },
    image: {
      overflow: 'hidden',
      width: '100%',
      height: '100%'
    }
  });
  (0, _react.useEffect)(() => {
    if (!avatarFileId) return;
    const fetchImage = async () => {
      const image = await getImage({
        fileId: avatarFileId
      });
      if (image) {
        setImageUri(image);
      }
    };
    fetchImage();
  }, [avatarFileId, getImage]);
  if (isExcluded) return null;
  return /*#__PURE__*/React.createElement(_reactNative.View, {
    style: styles.contianer
  }, avatarFileId && imageUri ? /*#__PURE__*/React.createElement(_reactNative.Image, {
    source: {
      uri: imageUri
    },
    style: styles.image,
    resizeMode: "cover"
  }) : /*#__PURE__*/React.createElement(_reactNative.View, {
    style: styles.placeholder
  }, /*#__PURE__*/React.createElement(_reactNativeSvg.SvgXml, {
    xml: (0, _icons.category)(),
    color: themeStyles === null || themeStyles === void 0 ? void 0 : themeStyles.colors.primaryShade2
  })));
};
var _default = exports.default = /*#__PURE__*/(0, _react.memo)(CategoryRowImage);
//# sourceMappingURL=CategoryRowImage.js.map