"""ProgressController class for managing ProgressBar updates."""

from .progress_bar import ProgressBar


class ProgressController:
    """
    Manages progress bar updates using ProgressBar.
    """

    def __init__(self, progress_bar: ProgressBar) -> None:
        """Initialize the ProgressController with a ProgressBar."""
        self._progress_bar = progress_bar

    def set_progress(self, step: int) -> None:
        """Sets the current progress to the provided step."""
        self._progress_bar.set_progress(step)

    def increment_progress(self, inc: int = 1) -> None:
        """Increments the progress by the given amount."""
        self._progress_bar.increment_progress(inc)

    def reset_progress(self, total_steps: int = 100) -> None:
        """Resets the progress bar to zero, optionally with new total_steps."""
        self._progress_bar.reset_progress(total_steps)

    def build_bar_text(self) -> str:
        """Builds and returns the text representation of the progress bar."""
        return self._progress_bar.build_bar_text()

    @property
    def total_steps(self) -> int:
        """Returns the total steps of the progress bar."""
        return self._progress_bar.total_steps

    @property
    def progress_bar(self) -> ProgressBar:
        """Allows direct access to the ProgressBar if needed."""
        return self._progress_bar

    @progress_bar.setter
    def progress_bar(self, p_bar: ProgressBar) -> None:
        """Sets a new ProgressBar instance."""
        self._progress_bar = p_bar
