import{a as H}from"./chunk-277752KE.mjs";import{a as F}from"./chunk-E4U3HX2E.mjs";import{a as x}from"./chunk-4QFQAY4C.mjs";import{a as W,b as V}from"./chunk-UVLIKUIF.mjs";import{a as $}from"./chunk-6NM6GRN3.mjs";import{a as N}from"./chunk-O5PFQIB5.mjs";import{b as M}from"./chunk-U2QNMZ5J.mjs";import{a as G}from"./chunk-K5BDVSIZ.mjs";import{a as E,c as L}from"./chunk-QM7X6D7F.mjs";import{Suspense as Se,useRef as _e,useState as je}from"react";import{useCurrentProfile as xe}from"@baseapp-frontend/authentication";import{CircledAvatar as Be}from"@baseapp-frontend/design-system/components/web/avatars";import{LoadingState as z}from"@baseapp-frontend/design-system/components/web/displays";import{TypographyWithEllipsis as ke}from"@baseapp-frontend/design-system/components/web/typographies";import{Box as g,Typography as K,useTheme as Re}from"@mui/material";import{ConnectionHandler as we,usePaginationFragment as Ae,usePreloadedQuery as Ie}from"react-relay";import{Virtuoso as Te}from"react-virtuoso";import{jsx as n,jsxs as m,Fragment as U}from"react/jsx-runtime";function h(e){"@babel/helpers - typeof";return h=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(r){return typeof r}:function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},h(e)}var pe=["onBackButtonClicked"];function fe(e,r){if(e==null)return{};var t,o,l=me(e,r);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(e);for(o=0;o<d.length;o++)t=d[o],r.indexOf(t)===-1&&{}.propertyIsEnumerable.call(e,t)&&(l[t]=e[t])}return l}function me(e,r){if(e==null)return{};var t={};for(var o in e)if({}.hasOwnProperty.call(e,o)){if(r.indexOf(o)!==-1)continue;t[o]=e[o]}return t}function Q(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);r&&(o=o.filter(function(l){return Object.getOwnPropertyDescriptor(e,l).enumerable})),t.push.apply(t,o)}return t}function B(e){for(var r=1;r<arguments.length;r++){var t=arguments[r]!=null?arguments[r]:{};r%2?Q(Object(t),!0).forEach(function(o){ve(e,o,t[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):Q(Object(t)).forEach(function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(t,o))})}return e}function ve(e,r,t){return(r=ye(r))in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function ye(e){var r=be(e,"string");return h(r)=="symbol"?r:r+""}function be(e,r){if(h(e)!="object"||!e)return e;var t=e[Symbol.toPrimitive];if(t!==void 0){var o=t.call(e,r||"default");if(h(o)!="object")return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(e)}function ge(e,r){return Oe(e)||Ce(e,r)||Pe(e,r)||he()}function he(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Pe(e,r){if(e){if(typeof e=="string")return q(e,r);var t={}.toString.call(e).slice(8,-1);return t==="Object"&&e.constructor&&(t=e.constructor.name),t==="Map"||t==="Set"?Array.from(e):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?q(e,r):void 0}}function q(e,r){(r==null||r>e.length)&&(r=e.length);for(var t=0,o=Array(r);t<r;t++)o[t]=e[t];return o}function Ce(e,r){var t=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(t!=null){var o,l,d,v,c=[],s=!0,y=!1;try{if(d=(t=t.call(e)).next,r===0){if(Object(t)!==t)return;s=!1}else for(;!(s=(o=d.call(t)).done)&&(c.push(o.value),c.length!==r);s=!0);}catch(O){y=!0,l=O}finally{try{if(!s&&t.return!=null&&(v=t.return(),Object(v)!==v))return}finally{if(y)throw l}}return c}}function Oe(e){if(Array.isArray(e))return e}var De=function(r){var t,o,l=r.onBackButtonClicked,d=r.onEditButtonClicked,v=r.queryRef,c=r.ProfileCard,s=c===void 0?H:c,y=r.ProfileCardProps,O=y===void 0?{}:y,k=r.VirtuosoProps,J=k===void 0?{}:k,X=Ie(N,v),a=X.chatRoom,Y=xe(),S=Y.currentProfile,R=E(a),Z=R.avatar,ee=R.title,w=Re(),p=(t=S?.id)!==null&&t!==void 0?t:"",re=a!=null&&a.id?[we.getConnectionID(a.id,"ChatRoom_participants")]:[];M({profileId:p,connections:re,onRemoval:l});var P=Ae(G,a),_=P.data,te=P.loadNext,oe=P.isLoadingNext,ne=P.hasNext,f=_?.participants,j=f?.edges.find(function(u){var i;return p&&(u==null||(i=u.node)===null||i===void 0||(i=i.profile)===null||i===void 0?void 0:i.id)===p}),A=(j==null||(o=j.node)===null||o===void 0?void 0:o.role)===F.admin,ie=function(){return oe?n(z,{sx:{paddingTop:3,paddingBottom:1},CircularProgressProps:{size:15},"aria-label":"loading more profiles"}):n(g,{sx:{paddingTop:3}})},ae=je(void 0),I=ge(ae,2),C=I[0],T=I[1],b=_e(void 0),le=function(i,D){T(i),b.current=D},ue=function(){T(void 0),b.current=void 0},de=function(i){return i.node?n(s,B({groupMember:i.node,initiateRemoval:le,hasAdminPermissions:A},O)):null},ce=function(){return n(Te,B({data:f?.edges,itemContent:function(D,se){return de(se)},style:{scrollbarWidth:"none"},components:{Footer:ie},endReached:function(){ne&&te(5)}},J))};return m(U,{children:[n($,{profileId:p,roomId:a?.id,open:!!C,removingParticipantId:C,removingParticipantName:b.current,onClose:ue,title:p===C?void 0:"Remove ".concat(b.current,"?"),content:p===C?void 0:"Are you sure you want to remove ".concat(b.current,"? This cannot be undone.")}),n(x,{onBackButtonClicked:l,onEditButtonClicked:d,shouldDisplayEditButton:A}),m(g,{sx:{display:"grid",gridTemplateRows:"auto 1fr"},children:[m(W,{children:[n(Be,{src:Z,width:144,height:144,hasError:!1}),m(V,{children:[n(ke,{variant:"subtitle1",color:"text.primary",children:ee}),n(K,{variant:"body2",color:"text.secondary",children:L(a?.participantsCount)})]})]}),m(g,{sx:{display:"grid",gridTemplateRows:"auto 1fr"},children:[n(g,{role:"list","aria-label":"group members",children:n(K,{variant:"subtitle2",color:"text.primary",sx:{padding:w.spacing(2),borderBottom:"1px solid ".concat(w.palette.divider)},children:"Members"})}),n(g,{height:"100%",width:"100%",children:ce()})]})]})]})},Ee=function(r){var t=r.onBackButtonClicked,o=fe(r,pe);return n(Se,{fallback:m(U,{children:[n(x,{onBackButtonClicked:t,shouldDisplayEditButton:!1}),n(z,{})]}),children:n(De,B({onBackButtonClicked:t},o))})},Xe=Ee;export{Xe as a};
//# sourceMappingURL=chunk-V6YDWOU7.mjs.map