"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.UserItem = UserItem;
var _reactNative = require("react-native");
var _styles = require("./styles");
var _Avatar = _interopRequireDefault(require("../../../../../components/Avatar"));
var _Typography = require("../../../../../../core/components/Typography/Typography");
var _MenuButton = _interopRequireDefault(require("../../../../../elements/MenuButton"));
var _Skeleton = _interopRequireDefault(require("../../../../../../core/components/Skeleton/Skeleton"));
var _MenuAction = _interopRequireDefault(require("../../../../../elements/MenuAction"));
var _useUserItem = require("./hooks/useUserItem");
var _BrandBadge = require("../../../../../elements/BrandBadge");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
function UserItem({
  profileId,
  userId
}) {
  var _user$avatar;
  const {
    user,
    styles,
    actions,
    isMyItem,
    openBottomSheet,
    bottomSheetHeight,
    goToUserProfile
  } = (0, _useUserItem.useUserItem)({
    userId,
    profileId
  });
  return /*#__PURE__*/React.createElement(_reactNative.TouchableOpacity, {
    activeOpacity: 0.7,
    accessibilityRole: "button",
    accessibilityLabel: `View ${user === null || user === void 0 ? void 0 : user.displayName}'s profile`,
    style: styles.container,
    onPress: goToUserProfile
  }, /*#__PURE__*/React.createElement(_Avatar.default.User, {
    shouldRedirectToUserProfile: true,
    userId: user === null || user === void 0 ? void 0 : user.userId,
    imageStyle: styles.avatar,
    userName: user === null || user === void 0 ? void 0 : user.displayName,
    uri: (user === null || user === void 0 ? void 0 : user.avatarCustomUrl) ?? (user === null || user === void 0 || (_user$avatar = user.avatar) === null || _user$avatar === void 0 ? void 0 : _user$avatar.fileUrl)
  }), /*#__PURE__*/React.createElement(_reactNative.View, {
    style: styles.nameContainer
  }, /*#__PURE__*/React.createElement(_Typography.Typography.BodyBold, {
    numberOfLines: 1,
    ellipsizeMode: "tail",
    style: styles.displayName
  }, user === null || user === void 0 ? void 0 : user.displayName), (user === null || user === void 0 ? void 0 : user.isBrand) && /*#__PURE__*/React.createElement(_BrandBadge.BrandBadge, {
    accessible: true,
    accessibilityLabel: "Brand verified",
    width: 16,
    height: 16
  })), !isMyItem && /*#__PURE__*/React.createElement(_MenuButton.default, {
    accessibilityLabel: `More options for ${user === null || user === void 0 ? void 0 : user.displayName}`,
    onPress: () => {
      openBottomSheet({
        height: bottomSheetHeight[actions.length],
        content: /*#__PURE__*/React.createElement(_reactNative.View, null, actions.map(action => /*#__PURE__*/React.createElement(_MenuAction.default, _extends({
          gap: "small"
        }, action, {
          key: action.label
        }))))
      });
    }
  }));
}
function UserItemSkeleton() {
  const {
    styles
  } = (0, _styles.useStyles)();
  return /*#__PURE__*/React.createElement(_Skeleton.default, {
    style: styles.container
  }, /*#__PURE__*/React.createElement(_Skeleton.default.Circle, {
    width: 40,
    height: 40
  }), /*#__PURE__*/React.createElement(_Skeleton.default.Line, {
    width: 140,
    height: 10
  }));
}
UserItem.Skeleton = UserItemSkeleton;
//# sourceMappingURL=UserItem.js.map