"""Utility mixin for restoring default slider values."""

from __future__ import annotations


class ResetMixin:
    def reset_sliders(self):
        self.hue_min.set(self.DEFAULTS["hue_min"])
        self.hue_max.set(self.DEFAULTS["hue_max"])
        self.sat_min.set(self.DEFAULTS["sat_min"])
        self.val_min.set(self.DEFAULTS["val_min"])
        self.val_max.set(self.DEFAULTS["val_max"])
        self.alpha.set(self.DEFAULTS["alpha"])
        self.update_preview()
        try:
            default_hex = self._default_colour_hex()  # type: ignore[attr-defined]
        except Exception:
            default_hex = None
        if default_hex and hasattr(self, "_parse_hex_colour") and hasattr(self, "_update_selected_colour"):
            try:
                rgb = self._parse_hex_colour(default_hex)  # type: ignore[attr-defined]
            except Exception:
                rgb = None
            if rgb:
                try:
                    self._update_selected_colour(*rgb)  # type: ignore[arg-type,attr-defined]
                except Exception:
                    pass
        default_text = getattr(self, "status_default_text", None)
        if default_text is None:
            default_text = self._t("status.defaults_restored") if hasattr(self, "_t") else "Defaults restored."
        if hasattr(self, "status"):
            self.status.config(text=default_text)


__all__ = ["ResetMixin"]
