import{a as U}from"./chunk-7IEQLNWT.mjs";import{a as B}from"./chunk-TFL6R5VQ.mjs";import{b as T}from"./chunk-2LS3YFBW.mjs";import{a as R}from"./chunk-HFEGUIQL.mjs";import{a as F}from"./chunk-REHN47VB.mjs";import{b as w}from"./chunk-ENGOMVJ6.mjs";import{a as k}from"./chunk-CP6O7NTO.mjs";import{b as _}from"./chunk-QM7X6D7F.mjs";import{a as x}from"./chunk-ZLICUXO6.mjs";import{useCallback as de,useRef as me}from"react";import{useCurrentProfile as fe}from"@baseapp-frontend/authentication";import{AvatarWithPlaceholder as pe}from"@baseapp-frontend/design-system/components/web/avatars";import{ArchiveIcon as ve,UnarchiveIcon as he,UnreadIcon as ge}from"@baseapp-frontend/design-system/components/web/icons";import{TypographyWithEllipsis as ye}from"@baseapp-frontend/design-system/components/web/typographies";import{Box as h,Badge as be,Typography as W}from"@mui/material";import{useFragment as g}from"react-relay";import{jsx as o,jsxs as y}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)}function D(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),t.push.apply(t,n)}return t}function ne(e){for(var r=1;r<arguments.length;r++){var t=arguments[r]!=null?arguments[r]:{};r%2?D(Object(t),!0).forEach(function(n){ae(e,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):D(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))})}return e}function ae(e,r,t){return(r=oe(r))in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function oe(e){var r=ie(e,"string");return m(r)=="symbol"?r:r+""}function ie(e,r){if(m(e)!="object"||!e)return e;var t=e[Symbol.toPrimitive];if(t!==void 0){var n=t.call(e,r||"default");if(m(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(e)}function $(e,r){return ce(e)||ue(e,r)||se(e,r)||le()}function le(){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 se(e,r){if(e){if(typeof e=="string")return E(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)?E(e,r):void 0}}function E(e,r){(r==null||r>e.length)&&(r=e.length);for(var t=0,n=Array(r);t<r;t++)n[t]=e[t];return n}function ue(e,r){var t=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(t!=null){var n,i,s,a,u=[],c=!0,d=!1;try{if(s=(t=t.call(e)).next,r===0){if(Object(t)!==t)return;c=!1}else for(;!(c=(n=s.call(t)).done)&&(u.push(n.value),u.length!==r);c=!0);}catch(f){d=!0,i=f}finally{try{if(!c&&t.return!=null&&(a=t.return(),Object(a)!==a))return}finally{if(d)throw i}}return u}}function ce(e){if(Array.isArray(e))return e}var Ce=function(r){var t,n,i,s,a=r.roomRef,u=r.isCardSelected,c=u===void 0?!1:u,d=r.handleClick,f=r.Badge,L=f===void 0?be:f,b=r.BadgeProps,N=b===void 0?{}:b,C=r.isInArchivedTab,p=C===void 0?!1:C,M=g(k,a),K=g(R,a),v=g(F,a),H=T(),X=$(H,1),q=X[0],z=function(te){te.stopPropagation(),d&&d()},G=me(null),J=fe(),l=J.currentProfile,P=_(K),Q=P.title,V=P.avatar,j=M.lastMessageTime,A=(t=M.lastMessage)===null||t===void 0?void 0:t.content,O=((n=v.unreadMessages)===null||n===void 0?void 0:n.markedUnread)||!!((i=v.unreadMessages)!==null&&i!==void 0&&i.count),Y=de(function(){q({variables:{input:{roomId:a.id,profileId:l?.id}}})},[a.id,l]),Z=w(),I=$(Z,2),ee=I[0],re=I[1];return o(x,{title:"Chat",offsetTop:-12,actions:[{disabled:re,icon:p?o(he,{}):o(ve,{}),label:p?"Unarchive Chat":"Archive Chat",onClick:function(){l!=null&&l.id&&ee({variables:{input:{roomId:a.id,profileId:l.id,archive:!p}}})},hasPermission:!0},{disabled:O,icon:o(ge,{}),label:"Mark as Unread",onClick:Y,hasPermission:!0,closeOnClick:!0}],showDeleteButton:!0,handleDeleteItem:function(){},isDeletingItem:!1,ref:G,children:y(U,{onClick:z,isCardSelected:c,showPointer:!!d,children:[o(pe,{sx:{alignSelf:"center",justifySelf:"center"},width:48,height:48,src:V}),y(h,{display:"grid",gridTemplateRows:"repeat(2, minmax(0, 1fr))",children:[o(ye,{variant:"subtitle2",children:Q}),A&&j?y(h,{display:"grid",gridTemplateColumns:"min-content min-content auto",alignItems:"center",children:[o(W,{variant:"caption",color:"text.secondary",noWrap:!0,children:B(j)}),o(h,{sx:{display:"inline-block",height:"6px",width:"6px",borderRadius:"50%",backgroundColor:"text.disabled",marginX:"8px"}}),o(W,{variant:"caption",color:"text.secondary",noWrap:!0,sx:{overflow:"hidden",textOverflow:"ellipsis"},children:A})]}):o("div",{})]}),o(L,ne({sx:{marginRight:"12px",justifySelf:"center",display:"flex",alignItems:"center"},badgeContent:((s=v.unreadMessages)===null||s===void 0?void 0:s.count)||"",color:"error",max:99,invisible:!O},N))]},"room-".concat(a.id))})},Re=Ce;export{Re as a};
//# sourceMappingURL=chunk-2APRFFWH.mjs.map