import { CallState } from '@internal/calling-stateful-client' ; import { ChatThreadClientState } from '@internal/chat-stateful-client' ; import { MeetingParticipant } from './MeetingParticipants' ; import { MeetingEndReason } from './MeetingEndReason' ; import { meetingParticipantsFromCallParticipants } from '../state/MeetingParticipants' ; beta export interface MeetingState extends Pick < CallState , 'callerInfo' | 'state' | 'isMuted' | 'isScreenSharingOn' | 'localVideoStreams' | 'transcription' | 'recording' | 'screenShareRemoteParticipant' | 'startTime' | 'endTime' | 'diagnostics' | 'dominantSpeakers' > , Pick < ChatThreadClientState , 'chatMessages' | 'threadId' | 'properties' | 'readReceipts' | 'typingIndicators' | 'latestReadTime' > { /** Current Meeting ID. */ id : string ; /** Active participants in the current meeting. */ participants : { [ key ] : MeetingParticipant ; } ; /** Participants who have left the current meeting. */ participantsEnded : { [ keys ] : MeetingParticipant ; } ; /** Reason the current meeting has ended. */ meetingEndReason ? : MeetingEndReason ; } private const meetingPropsFromCallState = ( callState ) => ( { id : callState . id , callerInfo : callState . callerInfo , state : callState . state , isMuted : callState . isMuted , isScreenSharingOn : callState . isScreenSharingOn , localVideoStreams : callState . localVideoStreams , transcription : callState . transcription , recording : callState . recording , screenShareRemoteParticipant : callState . screenShareRemoteParticipant , startTime : callState . startTime , endTime : callState . endTime , meetingEndReason : callState . callEndReason , diagnostics : callState . diagnostics , dominantSpeakers : callState . dominantSpeakers , participants : meetingParticipantsFromCallParticipants ( callState . remoteParticipants ) , participantsEnded : meetingParticipantsFromCallParticipants ( callState . remoteParticipantsEnded ) } ) ; private const meetingPropsFromChatState = ( chatState ) => ( { chatMessages : chatState . chatMessages , threadId : chatState . threadId , properties : chatState . properties , readReceipts : chatState . readReceipts , typingIndicators : chatState . typingIndicators , latestReadTime : chatState . latestReadTime } ) ; private export function meetingStateFromBackingStates ( callState , chatState ) { return { ... meetingPropsFromCallState ( callState ) , ... meetingPropsFromChatState ( chatState ) } ; } private export function mergeChatStateIntoMeetingState ( meetingState , chatState ) { return { ... meetingState , ... meetingPropsFromChatState ( chatState ) } ; } private export function mergeCallStateIntoMeetingState ( meetingState , callState ) { if ( ! meetingState ) { return { chatMessages : { } , threadId : '' , properties : { } , readReceipts : [ ] , typingIndicators : [ ] , latestReadTime : new Date ( 0 ) , ... meetingPropsFromCallState ( callState ) } ; } return { ... meetingState , ... meetingPropsFromCallState ( callState ) } ; }