import type { ComponentStatus } from '../domain/types';
import type { ServiceControlState } from '../ui';

export function serviceControlState(
  component: ComponentStatus | undefined,
  checking: boolean,
): ServiceControlState {
  if (checking) return 'checking';
  if (!component) return 'missing';
  if (component.state === 'error') return 'error';
  if (component.running) return 'running';
  if (component.installed) return 'stopped';
  return 'missing';
}

