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

var _chunkQYYH56EQjs = require('./chunk-QYYH56EQ.js');


var _chunkQ2PREGE6js = require('./chunk-Q2PREGE6.js');




var _chunk3525Z2QRjs = require('./chunk-3525Z2QR.js');


var _chunkPSM4BT5Ujs = require('./chunk-PSM4BT5U.js');


var _chunkKF5LIZENjs = require('./chunk-KF5LIZEN.js');


var _chunk4GYPIEOQjs = require('./chunk-4GYPIEOQ.js');


var _chunk4TAG75BZjs = require('./chunk-4TAG75BZ.js');


var _chunkG2BI7PE4js = require('./chunk-G2BI7PE4.js');


var _chunkM4XNAJAZjs = require('./chunk-M4XNAJAZ.js');


var _chunkDTIR4DVOjs = require('./chunk-DTIR4DVO.js');

// tmp-babel/messages/web/ChatRoomsComponent/index.js
var _react = require('react');
var _web = require('@baseapp-frontend/design-system/hooks/web');
var _reactrelay = require('react-relay');
var _jsxruntime = require('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);
}
function _slicedToArray(r, e) {
  return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
}
function _nonIterableRest() {
  throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
function _unsupportedIterableToArray(r, a) {
  if (r) {
    if ("string" == typeof r) return _arrayLikeToArray(r, a);
    var t = {}.toString.call(r).slice(8, -1);
    return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
  }
}
function _arrayLikeToArray(r, a) {
  (null == a || a > r.length) && (a = r.length);
  for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
  return n;
}
function _iterableToArrayLimit(r, l) {
  var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
  if (null != t) {
    var e, n, i, u, a = [], f = true, o = false;
    try {
      if (i = (t = t.call(r)).next, 0 === l) {
        if (Object(t) !== t) return;
        f = false;
      } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = true) ;
    } catch (r2) {
      o = true, n = r2;
    } finally {
      try {
        if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return;
      } finally {
        if (o) throw n;
      }
    }
    return a;
  }
}
function _arrayWithHoles(r) {
  if (Array.isArray(r)) return r;
}
var ChatRoomsComponent = function ChatRoomsComponent2(_ref) {
  var chatRoomsQueryData = _ref.chatRoomsQueryData, settings = _ref.settings, _ref$AllChatRoomsList = _ref.AllChatRoomsListComponent, AllChatRoomsListComponent = _ref$AllChatRoomsList === void 0 ? _chunk4GYPIEOQjs.AllChatRoomsList_default : _ref$AllChatRoomsList, _ref$AllChatRoomsList2 = _ref.AllChatRoomsListComponentProps, AllChatRoomsListComponentProps = _ref$AllChatRoomsList2 === void 0 ? {} : _ref$AllChatRoomsList2, _ref$GroupChatCreateC = _ref.GroupChatCreateComponent, GroupChatCreateComponent = _ref$GroupChatCreateC === void 0 ? _chunkPSM4BT5Ujs.GroupChatCreate_default : _ref$GroupChatCreateC, _ref$GroupChatCreateC2 = _ref.GroupChatCreateComponentProps, GroupChatCreateComponentProps = _ref$GroupChatCreateC2 === void 0 ? {} : _ref$GroupChatCreateC2, _ref$GroupChatDetails = _ref.GroupChatDetailsComponent, GroupChatDetailsComponent = _ref$GroupChatDetails === void 0 ? _chunkKF5LIZENjs.GroupChatDetails_default : _ref$GroupChatDetails, _ref$GroupChatDetails2 = _ref.GroupChatDetailsComponentProps, GroupChatDetailsComponentProps = _ref$GroupChatDetails2 === void 0 ? {} : _ref$GroupChatDetails2, _ref$GroupChatEditCom = _ref.GroupChatEditComponent, GroupChatEditComponent = _ref$GroupChatEditCom === void 0 ? _chunkQ2PREGE6js.GroupChatEdit_default : _ref$GroupChatEditCom, _ref$GroupChatEditCom2 = _ref.GroupChatEditComponentProps, GroupChatEditComponentProps = _ref$GroupChatEditCom2 === void 0 ? {} : _ref$GroupChatEditCom2, _ref$SingleChatCreate = _ref.SingleChatCreateComponent, SingleChatCreateComponent = _ref$SingleChatCreate === void 0 ? _chunkQYYH56EQjs.SingleChatCreate_default : _ref$SingleChatCreate, _ref$SingleChatCreate2 = _ref.SingleChatCreateComponentProps, SingleChatCreateComponentProps = _ref$SingleChatCreate2 === void 0 ? {} : _ref$SingleChatCreate2;
  var isUpToMd = _web.useResponsive.call(void 0, "up", "md");
  var _useState = _react.useState.call(void 0, _chunkG2BI7PE4js.LEFT_PANEL_CONTENT.chatRoomList), _useState2 = _slicedToArray(_useState, 2), leftPanelContent = _useState2[0], setLeftPanelContent = _useState2[1];
  var _useQueryLoader = _reactrelay.useQueryLoader.call(void 0, _chunkM4XNAJAZjs.GroupDetailsQuery), _useQueryLoader2 = _slicedToArray(_useQueryLoader, 2), groupDetailsQueryRef = _useQueryLoader2[0], loadGroupDetailsQuery = _useQueryLoader2[1];
  var _useChatRoom = _chunkDTIR4DVOjs.useChatRoom_default.call(void 0, ), selectedRoom = _useChatRoom.id;
  var displayGroupDetails = function displayGroupDetails2() {
    if (selectedRoom) {
      setLeftPanelContent(_chunkG2BI7PE4js.LEFT_PANEL_CONTENT.groupDetails);
      loadGroupDetailsQuery({
        roomId: selectedRoom
      }, {
        fetchPolicy: "network-only"
      });
    }
  };
  var shouldRenderLeftPanel = isUpToMd || leftPanelContent !== _chunkG2BI7PE4js.LEFT_PANEL_CONTENT.chatRoomList || !selectedRoom;
  var shouldRenderRightPanel = isUpToMd || leftPanelContent === _chunkG2BI7PE4js.LEFT_PANEL_CONTENT.chatRoomList && !!selectedRoom;
  var renderLeftPanelContent = function renderLeftPanelContent2() {
    switch (leftPanelContent) {
      case _chunkG2BI7PE4js.LEFT_PANEL_CONTENT.createGroupChat:
        return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, GroupChatCreateComponent, _objectSpread({
          allProfilesRef: chatRoomsQueryData,
          onValidSubmission: function onValidSubmission() {
            return setLeftPanelContent(_chunkG2BI7PE4js.LEFT_PANEL_CONTENT.chatRoomList);
          },
          onBackButtonClicked: function onBackButtonClicked() {
            return setLeftPanelContent(_chunkG2BI7PE4js.LEFT_PANEL_CONTENT.createChat);
          }
        }, GroupChatCreateComponentProps));
      case _chunkG2BI7PE4js.LEFT_PANEL_CONTENT.editGroupChat:
        if (!groupDetailsQueryRef) return null;
        return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, GroupChatEditComponent, _objectSpread({
          onCancellation: function onCancellation() {
            return setLeftPanelContent(_chunkG2BI7PE4js.LEFT_PANEL_CONTENT.groupDetails);
          },
          onRemovalFromGroup: function onRemovalFromGroup() {
            return setLeftPanelContent(_chunkG2BI7PE4js.LEFT_PANEL_CONTENT.chatRoomList);
          },
          onValidSubmission: function onValidSubmission() {
            return setLeftPanelContent(_chunkG2BI7PE4js.LEFT_PANEL_CONTENT.groupDetails);
          },
          queryRef: groupDetailsQueryRef,
          roomId: selectedRoom,
          allProfilesRef: chatRoomsQueryData
        }, GroupChatEditComponentProps));
      case _chunkG2BI7PE4js.LEFT_PANEL_CONTENT.groupDetails:
        if (!groupDetailsQueryRef) return null;
        return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, GroupChatDetailsComponent, _objectSpread({
          queryRef: groupDetailsQueryRef,
          onBackButtonClicked: function onBackButtonClicked() {
            return setLeftPanelContent(_chunkG2BI7PE4js.LEFT_PANEL_CONTENT.chatRoomList);
          },
          onEditButtonClicked: function onEditButtonClicked() {
            return setLeftPanelContent(_chunkG2BI7PE4js.LEFT_PANEL_CONTENT.editGroupChat);
          }
        }, GroupChatDetailsComponentProps));
      case _chunkG2BI7PE4js.LEFT_PANEL_CONTENT.createChat:
        return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, SingleChatCreateComponent, _objectSpread({
          allProfilesRef: chatRoomsQueryData,
          onHeaderClick: function onHeaderClick() {
            return setLeftPanelContent(_chunkG2BI7PE4js.LEFT_PANEL_CONTENT.chatRoomList);
          },
          onChatCreation: function onChatCreation() {
            return setLeftPanelContent(_chunkG2BI7PE4js.LEFT_PANEL_CONTENT.chatRoomList);
          },
          onGroupChatCreationButtonClicked: function onGroupChatCreationButtonClicked() {
            return setLeftPanelContent(_chunkG2BI7PE4js.LEFT_PANEL_CONTENT.createGroupChat);
          }
        }, SingleChatCreateComponentProps));
      default:
        return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, AllChatRoomsListComponent, _objectSpread({
          targetRef: chatRoomsQueryData,
          onHeaderClick: function onHeaderClick() {
            return setLeftPanelContent(_chunkG2BI7PE4js.LEFT_PANEL_CONTENT.createChat);
          }
        }, AllChatRoomsListComponentProps));
    }
  };
  var renderRightPanelContent = function renderRightPanelContent2() {
    if (!selectedRoom) return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", {});
    return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk4TAG75BZjs.ChatRoom_default, {
      roomId: selectedRoom,
      onDisplayGroupDetailsClicked: displayGroupDetails
    });
  };
  return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _chunk3525Z2QRjs.ChatRoomsContainer, {
    themeLayout: settings.themeLayout,
    children: [shouldRenderLeftPanel && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3525Z2QRjs.ChatRoomsListContainer, {
      hide: !shouldRenderLeftPanel,
      children: renderLeftPanelContent()
    }), shouldRenderRightPanel && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunk3525Z2QRjs.ChatRoomContainer, {
      hide: !shouldRenderRightPanel,
      children: renderRightPanelContent()
    })]
  });
};
var ChatRoomsComponent_default = ChatRoomsComponent;



exports.ChatRoomsComponent_default = ChatRoomsComponent_default;
//# sourceMappingURL=chunk-WHVMHWSR.js.map