"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.UserItem = UserItem;
var _reactNative = require("react-native");
var _BrandBadge = require("../../../../../elements/BrandBadge");
var _styles = require("./styles");
var _Avatar = _interopRequireDefault(require("../../../../../components/Avatar"));
var _Typography = require("../../../../../../core/components/Typography/Typography");
var _Skeleton = _interopRequireDefault(require("../../../../../../core/components/Skeleton/Skeleton"));
var _hooks = require("../../../../../hooks");
var _native = require("@react-navigation/native");
var _BehaviourProvider = require("../../../../../providers/BehaviourProvider");
var _elements = require("../../elements");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
function UserItem({
  user
}) {
  var _user$avatar;
  const {
    styles
  } = (0, _styles.useStyles)();
  const {
    unBlockUser
  } = (0, _hooks.useBlockUser)();
  const {
    AmityBlockedUsersPageBehavior
  } = (0, _BehaviourProvider.useBehaviour)();
  const navigation = (0, _native.useNavigation)();
  const handleUnblock = () => {
    unBlockUser(user.userId, user.displayName);
  };
  return /*#__PURE__*/React.createElement(_reactNative.TouchableOpacity, {
    activeOpacity: 0.7,
    accessibilityRole: "button",
    accessibilityLabel: `View ${user.displayName}'s profile`,
    style: styles.container,
    onPress: () => {
      if (AmityBlockedUsersPageBehavior !== null && AmityBlockedUsersPageBehavior !== void 0 && AmityBlockedUsersPageBehavior.goToUserProfilePage) {
        AmityBlockedUsersPageBehavior.goToUserProfilePage({
          userId: user.userId
        });
      } else {
        navigation.navigate('UserProfile', {
          userId: user.userId
        });
      }
    }
  }, /*#__PURE__*/React.createElement(_Avatar.default.User, {
    userId: user.userId,
    imageStyle: styles.avatar,
    userName: user.displayName,
    uri: user.avatarCustomUrl ?? ((_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.displayName), user.isBrand && /*#__PURE__*/React.createElement(_BrandBadge.BrandBadge, {
    accessible: true,
    accessibilityLabel: "Brand verified",
    width: 16,
    height: 16
  })), /*#__PURE__*/React.createElement(_elements.UnblockUserButton, {
    accessibilityLabel: `Unblock ${user.displayName}`,
    onPress: handleUnblock
  }));
}
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