import{a as w}from"./chunk-5VMYZ2JZ.mjs";import{a as D}from"./chunk-FN2XJEBZ.mjs";import{a as _}from"./chunk-A5QFDUFT.mjs";import{useCallback as W,useMemo as X}from"react";import{useCurrentProfile as q}from"@baseapp-frontend/authentication";import{AvatarWithPlaceholder as z}from"@baseapp-frontend/design-system/components/web/avatars";import{Box as M,Typography as J}from"@mui/material";import{DateTime as T}from"luxon";import{jsx as d,jsxs as E}from"react/jsx-runtime";function m(r){"@babel/helpers - typeof";return m=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},m(r)}function $(r,e){var i=Object.keys(r);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(r);e&&(o=o.filter(function(v){return Object.getOwnPropertyDescriptor(r,v).enumerable})),i.push.apply(i,o)}return i}function k(r){for(var e=1;e<arguments.length;e++){var i=arguments[e]!=null?arguments[e]:{};e%2?$(Object(i),!0).forEach(function(o){B(r,o,i[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(i)):$(Object(i)).forEach(function(o){Object.defineProperty(r,o,Object.getOwnPropertyDescriptor(i,o))})}return r}function B(r,e,i){return(e=K(e))in r?Object.defineProperty(r,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[e]=i,r}function K(r){var e=H(r,"string");return m(e)=="symbol"?e:e+""}function H(r,e){if(m(r)!="object"||!r)return r;var i=r[Symbol.toPrimitive];if(i!==void 0){var o=i.call(r,e||"default");if(m(o)!="object")return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(r)}var Q=function(e){var i,o,v,t=e.allMessages,O=e.allMessagesLastIndex,n=e.message,p=e.messageIndex,P=e.isGroup,x=P===void 0?!1:P,h=e.MessageItem,G=h===void 0?w:h,j=e.MessageItemProps,A=j===void 0?{}:j,F=q(),c=F.currentProfile,C=W(function(f){var l,u,s=t?.[f],a=t?.[f-1],b=(a==null||(l=a.profile)===null||l===void 0?void 0:l.id)!==(s==null||(u=s.profile)===null||u===void 0?void 0:u.id),R=T.fromISO(a?.created).diff(T.fromISO(s?.created),"minutes"),U=R.minutes,L=U>_;return b||!a||L?d(D,{date:s?.created}):null},[t]),g=X(function(){var f,l,u=t?.[p],s=t?.[p+1],a=(s==null||(f=s.profile)===null||f===void 0?void 0:f.id)!==(u==null||(l=u.profile)===null||l===void 0?void 0:l.id),b=O===0;return!!(a||b)},[t,O,p]),S=c?.id===(n==null||(i=n.profile)===null||i===void 0?void 0:i.id),y=S?"flex-end":"flex-start",I=g&&!S,N=I&&x;return n?E(M,{sx:{display:"flex",flexDirection:"row",alignSelf:y,width:"100%"},children:[I&&d(M,{paddingRight:"12px",children:d(z,{className:"self-start justify-self-center",width:32,height:32,src:n==null||(o=n.profile)===null||o===void 0||(o=o.image)===null||o===void 0?void 0:o.url,sx:{border:"none"}})}),E(M,{sx:{display:"flex",ml:g?0:5.5,alignSelf:y,alignItems:y,flexDirection:"column",width:"100%"},children:[N&&d(J,{variant:"subtitle2",color:"text.primary",marginBottom:1/2,children:n==null||(v=n.profile)===null||v===void 0?void 0:v.name}),d(G,k({messageRef:n,isGroup:x,isFirstGroupedMessage:g},A)),C(p)]})]}):null},ne=Q;export{ne as a};
//# sourceMappingURL=chunk-Y3R2ODXU.mjs.map