"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _chunkJWVNFAMTjs = require('./chunk-JWVNFAMT.js');var _chunkSMUCJQ7Ijs = require('./chunk-SMUCJQ7I.js');var _chunkYZ7FKLPSjs = require('./chunk-YZ7FKLPS.js');var _chunkDE4Q7XYVjs = require('./chunk-DE4Q7XYV.js');var _chunkK2FH3PY3js = require('./chunk-K2FH3PY3.js');var _chunkMBKDZBVUjs = require('./chunk-MBKDZBVU.js');var _chunk6RT4APSPjs = require('./chunk-6RT4APSP.js');var _react = require('react');var _authentication = require('@baseapp-frontend/authentication');var _displays = require('@baseapp-frontend/design-system/components/web/displays');var _material = require('@mui/material');var _reactrelay = require('react-relay');var _reactvirtuoso = require('react-virtuoso');var _jsxruntime = require('react/jsx-runtime');function b(e){"@babel/helpers - typeof";return b=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},b(e)}function T(e,r){var o=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter(function(d){return Object.getOwnPropertyDescriptor(e,d).enumerable})),o.push.apply(o,n)}return o}function C(e){for(var r=1;r<arguments.length;r++){var o=arguments[r]!=null?arguments[r]:{};r%2?T(Object(o),!0).forEach(function(n){oe(e,n,o[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(o)):T(Object(o)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(o,n))})}return e}function oe(e,r,o){return(r=te(r))in e?Object.defineProperty(e,r,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[r]=o,e}function te(e){var r=ne(e,"string");return b(r)=="symbol"?r:r+""}function ne(e,r){if(b(e)!="object"||!e)return e;var o=e[Symbol.toPrimitive];if(o!==void 0){var n=o.call(e,r||"default");if(b(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(e)}function ie(e,r){return le(e)||ue(e,r)||ae(e,r)||se()}function se(){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 ae(e,r){if(e){if(typeof e=="string")return D(e,r);var o={}.toString.call(e).slice(8,-1);return o==="Object"&&e.constructor&&(o=e.constructor.name),o==="Map"||o==="Set"?Array.from(e):o==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o)?D(e,r):void 0}}function D(e,r){(r==null||r>e.length)&&(r=e.length);for(var o=0,n=Array(r);o<r;o++)n[o]=e[o];return n}function ue(e,r){var o=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(o!=null){var n,d,f,c,m=[],v=!0,g=!1;try{if(f=(o=o.call(e)).next,r===0){if(Object(o)!==o)return;v=!1}else for(;!(v=(n=f.call(o)).done)&&(m.push(n.value),m.length!==r);v=!0);}catch(M){g=!0,d=M}finally{try{if(!v&&o.return!=null&&(c=o.return(),Object(c)!==c))return}finally{if(g)throw d}}return m}}function le(e){if(Array.isArray(e))return e}var be=function(r){var o,n,d,f,c=r.roomRef,m=r.VirtuosoProps,v=r.MessagesGroup,g=v===void 0?_chunkJWVNFAMTjs.a:v,M=r.MessagesGroupProps,I=M===void 0?{}:M,h=_reactrelay.usePaginationFragment.call(void 0, _chunkK2FH3PY3js.a,c),t=h.data,U=h.loadNext,k=h.isLoadingNext,O=h.hasNext,H=(o=t==null||(n=t.allMessages)===null||n===void 0?void 0:n.totalCount)!==null&&o!==void 0?o:0,V=_react.useRef.call(void 0, null),a=_react.useMemo.call(void 0, function(){var s;return(t==null||(s=t.allMessages)===null||s===void 0?void 0:s.edges.filter(function(i){return _optionalChain([i, 'optionalAccess', _2 => _2.node])}).map(function(i){return _optionalChain([i, 'optionalAccess', _3 => _3.node])}))||[]},[t==null||(d=t.allMessages)===null||d===void 0?void 0:d.edges]),S=Number(_optionalChain([a, 'optionalAccess', _4 => _4.length]))-1,x=Math.max(H-a.length,0),B=_authentication.useCurrentProfile.call(void 0, ),u=B.currentProfile,K=_chunkMBKDZBVUjs.a.call(void 0, ),X=K.id,z=_chunkDE4Q7XYVjs.b.call(void 0, ),W=ie(z,1),Y=W[0],q=function(){var i,p;if(!(t!=null&&(i=t.unreadMessages)!==null&&i!==void 0&&i.count))return null;var P=a.filter(function(l){return _optionalChain([l, 'optionalAccess', _5 => _5.messageType])===_chunk6RT4APSPjs.b.user});return(p=P.find(function(l,ee){var j,_=_optionalChain([P, 'optionalAccess', _6 => _6[ee+1]]),re=!!_;return(l==null||(j=l.profile)===null||j===void 0?void 0:j.id)!==_optionalChain([u, 'optionalAccess', _7 => _7.id])&&!(l!=null&&l.isRead)&&(!re||_optionalChain([_, 'optionalAccess', _8 => _8.isRead]))}))===null||p===void 0?void 0:p.id},w=_react.useMemo.call(void 0, q,[X,u]);_react.useEffect.call(void 0, function(){var s;((t==null||(s=t.unreadMessages)===null||s===void 0?void 0:s.count)!==0||t!=null&&t.unreadMessages.markedUnread)&&Y({variables:{input:{roomId:_optionalChain([t, 'optionalAccess', _9 => _9.id]),profileId:_optionalChain([u, 'optionalAccess', _10 => _10.id])}}})},[_optionalChain([t, 'optionalAccess', _11 => _11.id]),t==null||(f=t.unreadMessages)===null||f===void 0?void 0:f.count,u]),_chunkYZ7FKLPSjs.b.call(void 0, t.id,_optionalChain([u, 'optionalAccess', _12 => _12.id]));var J=function(){return k?_jsxruntime.jsx.call(void 0, _displays.LoadingState,{sx:{height:50},CircularProgressProps:{size:15},"aria-label":"loading more messages"}):_jsxruntime.jsx.call(void 0, _material.Box,{sx:{height:50}})},Q=function(){return a.length===0?null:_jsxruntime.jsx.call(void 0, "div",{className:"h-2"})},Z=_react.useCallback.call(void 0, function(s){var i=a.length-1-(s-x),p=a[i];return _jsxruntime.jsx.call(void 0, g,C({allMessages:a,message:p,messageIndex:i,isGroup:_optionalChain([t, 'optionalAccess', _13 => _13.isGroup]),allMessagesLastIndex:S,firstUnreadMessageId:w,hasNext:O},I))},[a,S,x,O,_optionalChain([t, 'optionalAccess', _14 => _14.isGroup]),w,g,I]);return _jsxruntime.jsx.call(void 0, _reactvirtuoso.Virtuoso,C({ref:V,firstItemIndex:x,style:{overflowX:"hidden"},initialTopMostItemIndex:S,data:a,itemContent:Z,startReached:function(){O&&U(_chunkSMUCJQ7Ijs.a)},components:{Header:J,Footer:Q},increaseViewportBy:{top:100,bottom:0},followOutput:"smooth"},m))},Re= exports.a =be;exports.a = Re;
//# sourceMappingURL=chunk-KKT2FASQ.js.map