//! Progress bar display using indicatif.
//!
//! Provides lightweight wrappers around [`indicatif`] progress bars for
//! the embedding pipeline phases. Used only when stderr is a TTY and
//! `--profile` is not active.

use indicatif::{ProgressBar, ProgressStyle};
use std::time::Duration;

/// Create a spinner for indeterminate phases (model load, walk).
///
/// The spinner auto-ticks at 80 ms intervals and displays `msg` alongside
/// the animation. Call [`ProgressBar::finish_with_message`] or
/// [`ProgressBar::finish`] to stop it.
pub fn spinner(msg: &str) -> ProgressBar {
    let pb = ProgressBar::new_spinner();
    pb.set_style(
        ProgressStyle::with_template("{spinner:.cyan} {msg}")
            .unwrap()
            .tick_chars("⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏"),
    );
    pb.set_message(msg.to_string());
    pb.enable_steady_tick(Duration::from_millis(80));
    pb
}
