import type { State } from '../types' ; import * as Types from './types' ; export const getRobotSessions = ( state , robotName ) => state . sessions [ robotName ] ?. robotSessions ?? null ; export const getRobotSessionById = ( state , robotName , sessionId ) => { return ( getRobotSessions ( state , robotName ) || { } ) [ sessionId ] ?? null ; } ; export function getRobotSessionOfType ( state , robotName , sessionType ) { const sessionsById = getRobotSessions ( state , robotName ) || { } ; const foundSessionId = Object . keys ( sessionsById ) . find ( id => sessionsById [ id ] . sessionType === sessionType ) ?? null ; return foundSessionId ? sessionsById [ foundSessionId ] : null ; }