import {
  ChatRoomHeader_default
} from "./chunk-NTL6UKFW.mjs";
import {
  SendMessage_default
} from "./chunk-5UKRBX56.mjs";
import {
  MessagesList_default
} from "./chunk-RF4R4BKX.mjs";
import {
  ChatBodyContainer,
  ChatRoomContainer
} from "./chunk-FVQ556CN.mjs";
import {
  ChatRoomQuery
} from "./chunk-H3SPRIHC.mjs";

// tmp-babel/messages/web/ChatRoom/index.js
import { Suspense } from "react";
import { LoadingState } from "@baseapp-frontend/design-system/components/web/displays";
import { Box } from "@mui/material";
import { useLazyLoadQuery } from "react-relay";
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
function _typeof(o) {
  "@babel/helpers - typeof";
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o2) {
    return typeof o2;
  } : function(o2) {
    return o2 && "function" == typeof Symbol && o2.constructor === Symbol && o2 !== Symbol.prototype ? "symbol" : typeof o2;
  }, _typeof(o);
}
function ownKeys(e, r) {
  var t = Object.keys(e);
  if (Object.getOwnPropertySymbols) {
    var o = Object.getOwnPropertySymbols(e);
    r && (o = o.filter(function(r2) {
      return Object.getOwnPropertyDescriptor(e, r2).enumerable;
    })), t.push.apply(t, o);
  }
  return t;
}
function _objectSpread(e) {
  for (var r = 1; r < arguments.length; r++) {
    var t = null != arguments[r] ? arguments[r] : {};
    r % 2 ? ownKeys(Object(t), true).forEach(function(r2) {
      _defineProperty(e, r2, t[r2]);
    }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r2) {
      Object.defineProperty(e, r2, Object.getOwnPropertyDescriptor(t, r2));
    });
  }
  return e;
}
function _defineProperty(e, r, t) {
  return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
}
function _toPropertyKey(t) {
  var i = _toPrimitive(t, "string");
  return "symbol" == _typeof(i) ? i : i + "";
}
function _toPrimitive(t, r) {
  if ("object" != _typeof(t) || !t) return t;
  var e = t[Symbol.toPrimitive];
  if (void 0 !== e) {
    var i = e.call(t, r || "default");
    if ("object" != _typeof(i)) return i;
    throw new TypeError("@@toPrimitive must return a primitive value.");
  }
  return ("string" === r ? String : Number)(t);
}
var ChatRoom = function ChatRoom2(_ref) {
  var roomId = _ref.roomId, _ref$MessagesList = _ref.MessagesList, MessagesList = _ref$MessagesList === void 0 ? MessagesList_default : _ref$MessagesList, _ref$MessagesListProp = _ref.MessagesListProps, MessagesListProps = _ref$MessagesListProp === void 0 ? {} : _ref$MessagesListProp, _ref$SendMessage = _ref.SendMessage, SendMessage = _ref$SendMessage === void 0 ? SendMessage_default : _ref$SendMessage, _ref$SendMessageProps = _ref.SendMessageProps, SendMessageProps = _ref$SendMessageProps === void 0 ? {} : _ref$SendMessageProps, onDisplayGroupDetailsClicked = _ref.onDisplayGroupDetailsClicked;
  var _useLazyLoadQuery = useLazyLoadQuery(ChatRoomQuery, {
    roomId
  }, {
    fetchPolicy: "store-and-network",
    fetchKey: roomId
  }), chatRoom = _useLazyLoadQuery.chatRoom;
  if (!chatRoom) {
    return /* @__PURE__ */ _jsx("div", {
      children: "Chat room not found"
    });
  }
  return /* @__PURE__ */ _jsxs(ChatRoomContainer, {
    children: [/* @__PURE__ */ _jsx(ChatRoomHeader_default, {
      isArchived: !!chatRoom.isArchived,
      participantsCount: chatRoom.participantsCount,
      roomTitleRef: chatRoom,
      onDisplayGroupDetailsClicked,
      roomId
    }), /* @__PURE__ */ _jsxs(ChatBodyContainer, {
      children: [/* @__PURE__ */ _jsx(MessagesList, _objectSpread({
        roomRef: chatRoom
      }, MessagesListProps)), /* @__PURE__ */ _jsx(Box, {
        paddingRight: 2,
        children: /* @__PURE__ */ _jsx(SendMessage, _objectSpread({
          roomId
        }, SendMessageProps))
      })]
    })]
  });
};
var SuspendedChatRoom = function SuspendedChatRoom2(props) {
  return /* @__PURE__ */ _jsx(Suspense, {
    fallback: /* @__PURE__ */ _jsx(LoadingState, {}),
    children: /* @__PURE__ */ _jsx(ChatRoom, _objectSpread({}, props))
  });
};
var ChatRoom_default = SuspendedChatRoom;

export {
  ChatRoom_default
};
//# sourceMappingURL=chunk-4E5FWVUW.mjs.map