use std::io::Write;

use blizz_ui::render_prompt_layer;
use blizz_ui::{LayoutPanel, Renderer, WizardPromptRefs};

pub use blizz_ui::RenderContext;

use super::ui_controller::UiController;

// ── Top-level render ───────────────────────────────────────────────────────────

#[cfg(not(tarpaulin_include))]
pub fn render<W: Write>(renderer: &mut Renderer<W>, ui: &UiController) -> std::io::Result<()> {
  let tw = renderer.ctx().terminal_size.width;
  let mascot_panel = LayoutPanel {
    row: 0,
    column: 0,
    width: tw,
  };
  renderer.draw(&ui.mascot, mascot_panel)?;

  render_prompt_layer(
    renderer,
    WizardPromptRefs {
      question: &ui.question,
      entry: &ui.text_entry,
      selector: &ui.selector,
      hint: &ui.hint,
      timer_bar: &ui.timer_bar,
    },
  )?;

  Ok(())
}
