export function toViewModel(input) {
  const total = Math.max(Number(input.total_area_ha ?? 0), 0);
  const completed = Math.max(Number(input.completed_area_ha ?? 0), 0);
  const faults = input.faults ?? [];
  return { mode: input.mode ?? 'MANUAL', system: faults.length ? 'ALERT' : 'NORMAL', speed_mps: Number(input.speed_mps ?? 0), progress_percent: total === 0 ? 0 : Math.min(100, Math.round(completed / total * 100)), alerts: faults.map((code) => ({ code, severity: 'critical' })) };
}
