import{a as O}from"./chunk-4QFQAY4C.mjs";import{a as W}from"./chunk-V22MQ5FT.mjs";import{a as $,b as H}from"./chunk-UVLIKUIF.mjs";import{a as M}from"./chunk-HJ3UWYSU.mjs";import{b as F}from"./chunk-K4NCOIN3.mjs";import{a as L}from"./chunk-O5PFQIB5.mjs";import{a as N}from"./chunk-K5BDVSIZ.mjs";import{a as T,c as E,e as G}from"./chunk-AZ65ECT7.mjs";import{Suspense as Oe,useRef as je,useState as xe}from"react";import{useCurrentProfile as ke}from"@baseapp-frontend/authentication";import{CircledAvatar as Be}from"@baseapp-frontend/design-system/components/web/avatars";import{LoadingState as K}from"@baseapp-frontend/design-system/components/web/displays";import{TypographyWithEllipsis as _e}from"@baseapp-frontend/design-system/components/web/typographies";import{Box as f,Typography as q,useTheme as Ae}from"@mui/material";import{ConnectionHandler as we,usePaginationFragment as Ie,usePreloadedQuery as Re}from"react-relay";import{Virtuoso as De}from"react-virtuoso";import{jsx as n,jsxs as c,Fragment as z}from"react/jsx-runtime";function m(e){"@babel/helpers - typeof";return m=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},m(e)}var pe=["onBackButtonClicked"];function fe(e,r){if(e==null)return{};var t,o,a=me(e,r);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(o=0;o<l.length;o++)t=l[o],r.indexOf(t)===-1&&{}.propertyIsEnumerable.call(e,t)&&(a[t]=e[t])}return a}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 V(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);r&&(o=o.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),t.push.apply(t,o)}return t}function j(e){for(var r=1;r<arguments.length;r++){var t=arguments[r]!=null?arguments[r]:{};r%2?V(Object(t),!0).forEach(function(o){ve(e,o,t[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):V(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 m(r)=="symbol"?r:r+""}function be(e,r){if(m(e)!="object"||!e)return e;var t=e[Symbol.toPrimitive];if(t!==void 0){var o=t.call(e,r||"default");if(m(o)!="object")return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(e)}function ge(e,r){return Se(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,a,l,d,p=[],u=!0,v=!1;try{if(l=(t=t.call(e)).next,r===0){if(Object(t)!==t)return;u=!1}else for(;!(u=(o=l.call(t)).done)&&(p.push(o.value),p.length!==r);u=!0);}catch(y){v=!0,a=y}finally{try{if(!u&&t.return!=null&&(d=t.return(),Object(d)!==d))return}finally{if(v)throw a}}return p}}function Se(e){if(Array.isArray(e))return e}var Te=function(r){var t,o=r.onBackButtonClicked,a=r.onEditButtonClicked,l=r.queryRef,d=r.ProfileCard,p=d===void 0?W:d,u=r.ProfileCardProps,v=u===void 0?{}:u,y=r.VirtuosoProps,U=y===void 0?{}:y,J=Re(L,l),i=J.chatRoom,X=ke(),C=X.currentProfile,x=T(i),Y=x.avatar,Z=x.title,k=Ae(),B=(t=C?.id)!==null&&t!==void 0?t:"",ee=i!=null&&i.id?[we.getConnectionID(i.id,"ChatRoom_participants")]:[];F({profileId:B,connections:ee,onRemoval:o});var b=Ie(N,i),S=b.data,re=b.loadNext,te=b.isLoadingNext,oe=b.hasNext,g=S?.participants,_=G(g),A=_.isAdmin,ne=_.isSoleAdmin,ie=function(){return te?n(K,{sx:{paddingTop:3,paddingBottom:1},CircularProgressProps:{size:15},"aria-label":"loading more profiles"}):n(f,{sx:{paddingTop:3}})},ae=xe(void 0),w=ge(ae,2),h=w[0],I=w[1],R=je(void 0),le=function(s,D){I(s),R.current=D},ue=function(){I(void 0),R.current=void 0},de=function(s){return s.node?n(p,j({groupMember:s.node,initiateRemoval:le,hasAdminPermissions:A},v)):null},se=function(){return n(De,j({data:g?.edges,itemContent:function(D,ce){return de(ce)},style:{scrollbarWidth:"none"},components:{Footer:ie},endReached:function(){oe&&re(5)}},U))};return c(z,{children:[n(M,{profileId:B,roomId:i?.id,open:!!h,removingParticipantId:h??"",onClose:ue,isSoleAdmin:ne}),n(O,{onBackButtonClicked:o,onEditButtonClicked:a,shouldDisplayEditButton:A}),c(f,{sx:{display:"grid",gridTemplateRows:"auto 1fr"},children:[c($,{children:[n(Be,{src:Y,width:144,height:144,hasError:!1}),c(H,{children:[n(_e,{variant:"subtitle1",color:"text.primary",children:Z}),n(q,{variant:"body2",color:"text.secondary",children:E(i?.participantsCount)})]})]}),c(f,{sx:{display:"grid",gridTemplateRows:"auto 1fr"},children:[n(f,{role:"list","aria-label":"group members",children:n(q,{variant:"subtitle2",color:"text.primary",sx:{padding:k.spacing(2),borderBottom:"1px solid ".concat(k.palette.divider)},children:"Members"})}),n(f,{height:"100%",width:"100%",children:se()})]})]})]})},Ee=function(r){var t=r.onBackButtonClicked,o=fe(r,pe);return n(Oe,{fallback:c(z,{children:[n(O,{onBackButtonClicked:t,shouldDisplayEditButton:!1}),n(K,{})]}),children:n(Te,j({onBackButtonClicked:t},o))})},Je=Ee;export{Je as a};
//# sourceMappingURL=chunk-OUEU5U7E.mjs.map