"use strict";Object.defineProperty(exports, "__esModule", {value: true});

var _chunkCGB4EL7Gjs = require('./chunk-CGB4EL7G.js');


var _chunkMYK6UC2Rjs = require('./chunk-MYK6UC2R.js');


var _chunkAC4K7IORjs = require('./chunk-AC4K7IOR.js');



var _chunkMYGO2IQXjs = require('./chunk-MYGO2IQX.js');


var _chunk5V5EREDJjs = require('./chunk-5V5EREDJ.js');

// tmp-babel/messages/web/GroupChatDetails/ProfileCard/index.js
var _authentication = require('@baseapp-frontend/authentication');
var _avatars = require('@baseapp-frontend/design-system/components/web/avatars');
var _icons = require('@baseapp-frontend/design-system/components/web/icons');
var _popovers = require('@baseapp-frontend/design-system/components/web/popovers');
var _common = require('@baseapp-frontend/design-system/hooks/common');
var _material = require('@mui/material');
var _reactrelay = require('react-relay');
var _jsxruntime = require('react/jsx-runtime');
var ProfileCard = function ProfileCard2(_ref) {
  var hasAdminPermissions = _ref.hasAdminPermissions, groupMember = _ref.groupMember, initiateRemoval = _ref.initiateRemoval;
  var _useFragment = _reactrelay.useFragment.call(void 0, _chunk5V5EREDJjs.ProfileItemFragment, groupMember.profile), id = _useFragment.id, image = _useFragment.image, name = _useFragment.name, urlPath = _useFragment.urlPath;
  var showUrlPath = !!(urlPath !== null && urlPath !== void 0 && urlPath.path);
  var showAdminLabel = (groupMember === null || groupMember === void 0 ? void 0 : groupMember.role) === _chunkMYGO2IQXjs.CHAT_ROOM_PARTICIPANT_ROLES.admin;
  var showMenu = hasAdminPermissions;
  var _useCurrentProfile = _authentication.useCurrentProfile.call(void 0, ), currentProfile = _useCurrentProfile.currentProfile;
  var popover = _common.usePopover.call(void 0, );
  var isMe = (currentProfile === null || currentProfile === void 0 ? void 0 : currentProfile.id) === id;
  var handleRemoveClicked = function handleRemoveClicked2() {
    popover.onClose();
    initiateRemoval(id, name);
  };
  var renderMenuItems = function renderMenuItems2() {
    if (isMe) {
      return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkMYK6UC2Rjs.MemberOptionsMenu_default, {
        isMe,
        onViewProfileClicked: popover.onClose,
        onRemoveClicked: handleRemoveClicked
      });
    }
    if (!isMe && hasAdminPermissions) {
      return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkCGB4EL7Gjs.AdminOptionsMenu_default, {
        onViewProfileClicked: popover.onClose,
        onToggleAdminClicked: popover.onClose,
        onRemoveClicked: handleRemoveClicked
      });
    }
    return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkMYK6UC2Rjs.MemberOptionsMenu_default, {
      isMe,
      onViewProfileClicked: popover.onClose,
      onRemoveClicked: handleRemoveClicked
    });
  };
  return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunkAC4K7IORjs.MainContainer, {
    children: [/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _avatars.AvatarWithPlaceholder, {
      width: 48,
      height: 48,
      src: image === null || image === void 0 ? void 0 : image.url,
      sx: {
        alignSelf: "center",
        justifySelf: "center"
      }
    }), /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _material.Box, {
      sx: {
        display: "grid",
        gridTemplateRows: "repeat(2, minmax(0, 1fr))"
      },
      children: [/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Typography, {
        variant: "subtitle2",
        children: name
      }), /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _material.Box, {
        sx: {
          alignItems: "center",
          display: "grid",
          gridTemplateColumns: "min-content min-content min-content"
        },
        children: [/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Typography, {
          variant: "caption",
          color: "text.secondary",
          children: showUrlPath && "@".concat(urlPath.path)
        }), showAdminLabel && showUrlPath && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Box, {
          sx: {
            display: "inline-block",
            height: "6px",
            width: "6px",
            borderRadius: "50%",
            backgroundColor: "text.disabled",
            marginX: "8px"
          }
        }), /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Typography, {
          variant: "caption",
          color: "primary.light",
          children: showAdminLabel && _chunkMYGO2IQXjs.ADMIN_LABEL
        })]
      })]
    }), showMenu ? /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _material.Box, {
      children: [/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.IconButton, {
        onClick: popover.onOpen,
        "aria-label": "Show admin options",
        children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _icons.ThreeDotsIcon, {
          sx: {
            fontSize: "24px"
          }
        })
      }), /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _popovers.Popover, {
        open: popover.open,
        onClose: popover.onClose,
        children: renderMenuItems()
      })]
    }) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Box, {})]
  }, "profile-".concat(id));
};
var ProfileCard_default = ProfileCard;



exports.ProfileCard_default = ProfileCard_default;
//# sourceMappingURL=chunk-DIWHVA2B.js.map