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); }
import { View, TouchableOpacity } from 'react-native';
import { useStyles } from './styles';
import Avatar from '../../../../../components/Avatar';
import { Typography } from '../../../../../../core/components/Typography/Typography';
import MenuButton from '../../../../../elements/MenuButton';
import Skeleton from '../../../../../../core/components/Skeleton/Skeleton';
import MenuAction from '../../../../../elements/MenuAction';
import { useUserItem } from './hooks/useUserItem';
import { BrandBadge } from '../../../../../elements/BrandBadge';
export function UserItem({
  profileId,
  userId
}) {
  var _user$avatar;
  const {
    user,
    styles,
    actions,
    isMyItem,
    openBottomSheet,
    bottomSheetHeight,
    goToUserProfile
  } = useUserItem({
    userId,
    profileId
  });
  return /*#__PURE__*/React.createElement(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.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(View, {
    style: styles.nameContainer
  }, /*#__PURE__*/React.createElement(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, {
    accessible: true,
    accessibilityLabel: "Brand verified",
    width: 16,
    height: 16
  })), !isMyItem && /*#__PURE__*/React.createElement(MenuButton, {
    accessibilityLabel: `More options for ${user === null || user === void 0 ? void 0 : user.displayName}`,
    onPress: () => {
      openBottomSheet({
        height: bottomSheetHeight[actions.length],
        content: /*#__PURE__*/React.createElement(View, null, actions.map(action => /*#__PURE__*/React.createElement(MenuAction, _extends({
          gap: "small"
        }, action, {
          key: action.label
        }))))
      });
    }
  }));
}
function UserItemSkeleton() {
  const {
    styles
  } = useStyles();
  return /*#__PURE__*/React.createElement(Skeleton, {
    style: styles.container
  }, /*#__PURE__*/React.createElement(Skeleton.Circle, {
    width: 40,
    height: 40
  }), /*#__PURE__*/React.createElement(Skeleton.Line, {
    width: 140,
    height: 10
  }));
}
UserItem.Skeleton = UserItemSkeleton;
//# sourceMappingURL=UserItem.js.map