"""
Helper utilities for font sizing and text fitting presentation logic.
"""

from ..utils.constants import has_text_fitting

FONT_FITTING_MODE_LABELS = {
    'FIT_WIDTH': "Fit Width",
    'FIT_HEIGHT': "Fit Height",
    'FIT_BOTH': "Fit Width & Height",
    'FIT_CONTAIN': "Fit Contain",
}


def font_size_ui_state(props):
    """
    Determine whether the manual font size control should be enabled and what
    status message to show based on the current text fitting configuration.

    Returns:
        tuple(bool, str): (is_manual_enabled, status_message)
    """
    fitting_available = bool(has_text_fitting())
    fitting_enabled = fitting_available and bool(getattr(props, "enable_text_fitting", False))

    if not fitting_enabled:
        return True, ""

    mode = getattr(props, "text_fitting_mode", "")
    mode_label = FONT_FITTING_MODE_LABELS.get(mode, mode.replace("_", " ").title() if mode else "Auto")
    return False, f"Auto-sized via Text Fitting ({mode_label})"
