import{a as A}from"./chunk-A6BTMZPH.mjs";import{a as R,b as T,c as N}from"./chunk-RTWSCIXD.mjs";import{a as I}from"./chunk-A2V5HV2W.mjs";import{b as _}from"./chunk-ZCHJJU3B.mjs";import{a as w}from"./chunk-QVKZ2F6L.mjs";import{useMemo as sr,useTransition as cr}from"react";import{useCurrentProfile as fr}from"@baseapp-frontend/authentication";import{AvatarWithPlaceholder as mr}from"@baseapp-frontend/design-system/components/web/avatars";import{LoadingState as pr}from"@baseapp-frontend/design-system/components/web/displays";import{Searchbar as hr}from"@baseapp-frontend/design-system/components/web/inputs";import{Box as dr,Typography as yr}from"@mui/material";import vr from"next/image";import{useForm as br}from"react-hook-form";import{Virtuoso as gr}from"react-virtuoso";import{jsx as i,jsxs as V}from"react/jsx-runtime";function d(r){"@babel/helpers - typeof";return d=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},d(r)}function k(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 P(r){for(var t=1;t<arguments.length;t++){var e=arguments[t]!=null?arguments[t]:{};t%2?k(Object(e),!0).forEach(function(o){tr(r,o,e[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(e)):k(Object(e)).forEach(function(o){Object.defineProperty(r,o,Object.getOwnPropertyDescriptor(e,o))})}return r}function tr(r,t,e){return(t=er(t))in r?Object.defineProperty(r,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):r[t]=e,r}function er(r){var t=or(r,"string");return d(t)=="symbol"?t:t+""}function or(r,t){if(d(r)!="object"||!r)return r;var e=r[Symbol.toPrimitive];if(e!==void 0){var o=e.call(r,t||"default");if(d(o)!="object")return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(r)}function nr(r,t){return ur(r)||lr(r,t)||ar(r,t)||ir()}function ir(){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 ar(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 lr(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(v){p=!0,l=v}finally{try{if(!s&&e.return!=null&&(m=e.return(),Object(m)!==m))return}finally{if(p)throw l}}return u}}function ur(r){if(Array.isArray(r))return r}var Cr=function(t){var e=t.allProfilesRef,o=t.ChatRoomListItem,l=o===void 0?A:o,f=t.ChatRoomListItemProps,m=f===void 0?{}:f,u=t.Searchbar,s=u===void 0?hr:u,p=t.SearchbarProps,v=p===void 0?{}:p,S=t.VirtuosoProps,$=S===void 0?{}:S,E=t.onChatCreation,F=t.onGroupChatCreationButtonClicked,h=_(e),y=h.data.allProfiles,G=h.loadNext,B=h.isLoadingNext,M=h.hasNext,j=h.refetch,W=cr(),x=nr(W,2),b=x[0],L=x[1],g=br({defaultValues:{search:""}}),q=g.control,H=g.reset,K=g.watch,z=fr(),c=z.currentProfile,U=function(a){var C=a.target.value||"";L(function(){j({q:C})})},J=function(){L(function(){H(),j({q:""})})},O=sr(function(){return y?.edges.filter(function(n){return n?.node&&n.node.id!==c?.id}).map(function(n){return n?.node})||[]},[y,c?.id]),Q=function(){return B?i(pr,{sx:{paddingTop:3,paddingBottom:1},CircularProgressProps:{size:15},"aria-label":"loading more profiles"}):i(dr,{sx:{paddingTop:3}})},X=function(a){return a?i(l,P({profile:a,onChatCreation:E},m)):null},Y=function(){var a=O.length===0,C=K("search");return!b&&C&&a?i(w,{}):!b&&a?i(I,{}):i(gr,P({data:O,itemContent:function(Pr,rr){return X(rr)},style:{scrollbarWidth:"none",maxHeight:"calc(100vh - 72px - 57px - 61px - 72px)"},components:{Footer:Q},endReached:function(){M&&G(5)}},$))};return V(R,{children:[i(T,{children:i(s,P({name:"search",onChange:U,onClear:J,control:q,isPending:b},v))}),V(N,{onClick:F,children:[i(mr,{width:48,height:48,sx:{bgcolor:"primary.main",alignSelf:"flex-start",justifySelf:"center"},children:i(vr,{src:"/svg/avatar-group-chat.svg",alt:"Avatar Group Fallback",width:24,height:24})}),i(yr,{component:"span",variant:"subtitle2",sx:{alignSelf:"center"},children:"New Group"})]}),Y()]})},$r=Cr;export{$r as a};
//# sourceMappingURL=chunk-A23UIYHU.mjs.map