/** Jedna 15min buňka pro dashboardové grafy (minulost + plán). */
export type SlotData = {
  interval_start: string
  pv_power_w: number | null
  battery_power_w: number | null
  /** Plánovaný výkon baterie (W) – budoucí sloty. */
  battery_setpoint_w: number | null
  grid_power_w: number | null
  /** Plánovaný výkon sítě (W) – budoucí sloty. */
  grid_setpoint_w: number | null
  /** Fyzický režim Deye pro slot (PASSIVE/SELL/CHARGE) z plánu. */
  deye_physical_mode: 'PASSIVE' | 'SELL' | 'CHARGE' | null
  /** Záměr exportu z LP (NONE / PV_SURPLUS / BATTERY_SELL). */
  export_mode?: 'NONE' | 'PV_SURPLUS' | 'BATTERY_SELL' | null
  export_limit_w?: number | null
  load_power_w: number | null
  gen_port_power_w: number | null
  pv_a_forecast_w: number | null
  pv_b_forecast_w: number | null
  /** Korigovaný součet FVE forecastu (W). */
  pv_forecast_corrected_w?: number | null
  load_baseline_w: number | null
  ev1_setpoint_w: number | null
  ev2_setpoint_w: number | null
  heat_pump_setpoint_w: number | null
  /** Z plánu (`heat_pump_enabled`); pro StatePanel TČ. */
  heat_pump_enabled: boolean | null
  battery_soc_target_pct: number | null
  buy_price: number | null
  sell_price: number | null
  /** Provozní režim pro RegimeBar (kód z operating_mode_def). */
  regime_code: string | null
  /** Budoucí segment – zobrazit jako plán (světlejší). */
  regime_is_planned: boolean
  /** SoC % skutečnost (telemetrie / audit). */
  soc_actual_pct: number | null
  /** SoC % z plánu. */
  soc_plan_pct: number | null
  /** TUV °C skutečnost. */
  tuv_actual_c: number | null
  /** TUV °C cíl z plánu (zjednodušeně při běhu TČ). */
  tuv_plan_c: number | null
}

export type ChartAreaLike = {
  left: number
  right: number
  top: number
  bottom: number
}

export type ForecastDayTotal = {
  date: string
  label: string
  kwh: number
}

export type NegPriceItem = {
  interval_start: string
  buy: number | null
  sell: number | null
}

/** Živé metriky pro horní karty (5s poll / WebSocket; nezávislé na slots[]). */
export type LiveMetrics = {
  pv_w: number | null
  load_w: number | null
  grid_w: number | null
  bat_soc: number | null
  bat_w: number | null
}

export type NotificationLevel = 'success' | 'info' | 'warning' | 'error'

export type NotificationAction = 'connect_ev' | 'replan' | 'import_prices' | 'switch_auto'

/** Odpověď GET /api/v1/sites/{id}/notifications */
export type Notification = {
  id: string
  level: NotificationLevel
  title: string
  body: string
  /** Minuty do události (zobrazí se „za Xh Ymin“). */
  eta_minutes?: number | null
  action?: NotificationAction | null
}

export type TelemetryWsPayload = {
  type: string
  site_id: number
  ts?: string
  pv_power_w?: number | null
  battery_soc_pct?: number | null
  battery_power_w?: number | null
  grid_power_w?: number | null
  load_power_w?: number | null
  gen_port_power_w?: number | null
}
