import {
  MainContainer
} from "./chunk-6ZD4XEXS.mjs";
import {
  ProfileItemFragment
} from "./chunk-YTT7MYZX.mjs";

// tmp-babel/messages/web/GroupChatEdit/AddMemberCard/index.js
import { AvatarWithPlaceholder } from "@baseapp-frontend/design-system/components/web/avatars";
import { Box, Checkbox, Typography } from "@mui/material";
import { useFragment } from "react-relay";
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
var AddMemberCard = function AddMemberCard2(_ref) {
  var profile = _ref.profile, handleAddMember = _ref.handleAddMember, handleRemoveMember = _ref.handleRemoveMember, _ref$isBeingAdded = _ref.isBeingAdded, isBeingAdded = _ref$isBeingAdded === void 0 ? false : _ref$isBeingAdded, _ref$isExistingMember = _ref.isExistingMember, isExistingMember = _ref$isExistingMember === void 0 ? false : _ref$isExistingMember;
  var _useFragment = useFragment(ProfileItemFragment, profile), id = _useFragment.id, image = _useFragment.image, name = _useFragment.name, urlPath = _useFragment.urlPath;
  var handleCheckboxChange = function handleCheckboxChange2(event) {
    var target = event.target;
    if (target.checked) {
      handleAddMember(profile);
    } else {
      handleRemoveMember(profile);
    }
  };
  var getCaptionText = function getCaptionText2() {
    if (isExistingMember) {
      return "Already added to the group";
    }
    if (urlPath !== null && urlPath !== void 0 && urlPath.path) {
      return "@".concat(urlPath.path);
    }
    return "";
  };
  return /* @__PURE__ */ _jsxs(MainContainer, {
    children: [/* @__PURE__ */ _jsx(AvatarWithPlaceholder, {
      width: 48,
      height: 48,
      src: image === null || image === void 0 ? void 0 : image.url,
      sx: {
        alignSelf: "center",
        justifySelf: "center"
      }
    }), /* @__PURE__ */ _jsxs(Box, {
      sx: {
        display: "grid",
        gridTemplateRows: "repeat(2, minmax(0, 1fr))"
      },
      children: [/* @__PURE__ */ _jsx(Typography, {
        variant: "subtitle2",
        color: !isExistingMember ? "text.primary" : "text.disabled",
        children: name
      }), /* @__PURE__ */ _jsx(Typography, {
        variant: "caption",
        color: !isExistingMember ? "text.secondary" : "text.disabled",
        sx: {
          fontStyle: !isExistingMember ? "normal" : "italic"
        },
        children: getCaptionText()
      })]
    }), !isExistingMember && /* @__PURE__ */ _jsx(Checkbox, {
      checked: isBeingAdded,
      onChange: handleCheckboxChange
    })]
  }, "chat-room-item-".concat(id));
};
var AddMemberCard_default = AddMemberCard;

export {
  AddMemberCard_default
};
//# sourceMappingURL=chunk-7KWOCW5S.mjs.map