import{a as R}from"./chunk-PLFI3MCM.mjs";import{a as A,b as T}from"./chunk-RTWSCIXD.mjs";import{a as I}from"./chunk-A2V5HV2W.mjs";import{b as _}from"./chunk-UWZVMVY3.mjs";import{a as w}from"./chunk-53ZWLU5C.mjs";import{useMemo as lr,useTransition as ur}from"react";import{useCurrentProfile as sr}from"@baseapp-frontend/authentication";import{AvatarButton as cr}from"@baseapp-frontend/design-system/components/web/buttons";import{LoadingState as fr}from"@baseapp-frontend/design-system/components/web/displays";import{NewGroupIcon as mr}from"@baseapp-frontend/design-system/components/web/icons";import{Searchbar as pr}from"@baseapp-frontend/design-system/components/web/inputs";import{Box as dr}from"@mui/material";import{useForm as hr}from"react-hook-form";import{Virtuoso as yr}from"react-virtuoso";import{jsx as i,jsxs as br}from"react/jsx-runtime";function h(r){"@babel/helpers - typeof";return h=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},h(r)}function N(r,t){var e=Object.keys(r);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(r);t&&(o=o.filter(function(l){return Object.getOwnPropertyDescriptor(r,l).enumerable})),e.push.apply(e,o)}return e}function g(r){for(var t=1;t<arguments.length;t++){var e=arguments[t]!=null?arguments[t]:{};t%2?N(Object(e),!0).forEach(function(o){Z(r,o,e[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(e)):N(Object(e)).forEach(function(o){Object.defineProperty(r,o,Object.getOwnPropertyDescriptor(e,o))})}return r}function Z(r,t,e){return(t=rr(t))in r?Object.defineProperty(r,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):r[t]=e,r}function rr(r){var t=tr(r,"string");return h(t)=="symbol"?t:t+""}function tr(r,t){if(h(r)!="object"||!r)return r;var e=r[Symbol.toPrimitive];if(e!==void 0){var o=e.call(r,t||"default");if(h(o)!="object")return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(r)}function er(r,t){return ar(r)||ir(r,t)||nr(r,t)||or()}function or(){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 nr(r,t){if(r){if(typeof r=="string")return D(r,t);var e={}.toString.call(r).slice(8,-1);return e==="Object"&&r.constructor&&(e=r.constructor.name),e==="Map"||e==="Set"?Array.from(r):e==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?D(r,t):void 0}}function D(r,t){(t==null||t>r.length)&&(t=r.length);for(var e=0,o=Array(t);e<t;e++)o[e]=r[e];return o}function ir(r,t){var e=r==null?null:typeof Symbol<"u"&&r[Symbol.iterator]||r["@@iterator"];if(e!=null){var o,l,f,m,u=[],s=!0,p=!1;try{if(f=(e=e.call(r)).next,t===0){if(Object(e)!==e)return;s=!1}else for(;!(s=(o=f.call(e)).done)&&(u.push(o.value),u.length!==t);s=!0);}catch(b){p=!0,l=b}finally{try{if(!s&&e.return!=null&&(m=e.return(),Object(m)!==m))return}finally{if(p)throw l}}return u}}function ar(r){if(Array.isArray(r))return r}var vr=function(t){var e=t.allProfilesRef,o=t.ChatRoomListItem,l=o===void 0?R:o,f=t.ChatRoomListItemProps,m=f===void 0?{}:f,u=t.Searchbar,s=u===void 0?pr:u,p=t.SearchbarProps,b=p===void 0?{}:p,S=t.VirtuosoProps,V=S===void 0?{}:S,$=t.onChatCreation,k=t.onGroupChatCreationButtonClicked,d=_(e),y=d.data.allProfiles,B=d.loadNext,E=d.isLoadingNext,F=d.hasNext,j=d.refetch,G=ur(),L=er(G,2),v=L[0],x=L[1],C=hr({defaultValues:{search:""}}),M=C.control,q=C.reset,H=C.watch,K=sr(),c=K.currentProfile,W=function(a){var P=a.target.value||"";x(function(){j({q:P})})},z=function(){x(function(){q(),j({q:""})})},O=lr(function(){return y?.edges.filter(function(n){return n?.node&&n.node.id!==c?.id}).map(function(n){return n?.node})||[]},[y,c?.id]),U=function(){return E?i(fr,{sx:{paddingTop:3,paddingBottom:1},CircularProgressProps:{size:15},"aria-label":"loading more profiles"}):i(dr,{sx:{paddingTop:3}})},J=function(a){return a?i(l,g({profile:a,onChatCreation:$},m)):null},Q=function(){var a=O.length===0,P=H("search");return!v&&P&&a?i(w,{}):!v&&a?i(I,{}):i(yr,g({data:O,itemContent:function(Cr,Y){return J(Y)},style:{scrollbarWidth:"none",maxHeight:"calc(100vh - 72px - 57px - 61px - 72px)"},components:{Footer:U},endReached:function(){F&&B(5)}},V))};return br(A,{children:[i(T,{children:i(s,g({name:"search",onChange:W,onClear:z,control:M,isPending:v},b))}),i(cr,{onClick:k,caption:"New Group",Icon:mr}),Q()]})},Vr=vr;export{Vr as a};
//# sourceMappingURL=chunk-TQUNEHJD.mjs.map