"""Utility for identifying Gemini models with built-in reasoning support."""

import re

# Compile once on import
_GEMINI_REASONING_RE = re.compile(
    r"""
    ^(?:models/)?           # optional models/ prefix
    gemini-                 # prefix
    (?:1\.5|2\.0|2\.5|3)-   # supported generations (added 3)
    (?:                     # variations with reasoning
        pro |               # pro
        flash(?:-lite)? |   # flash or flash-lite
        flash-thinking      # flash-thinking experimental
    )
    (?:-.+)?$               # optional suffix: -preview-05-06, -exp-01-21, etc.
    """,
    re.VERBOSE,
)


def is_gemini_reasoning_model(model_name: str) -> bool:
    """Check whether a Gemini model supports built-in thinking/reasoning traces.

    Parameters
    ----------
    model_name : str
        The Gemini model name (with or without ``models/`` prefix).

    Returns
    -------
    bool
        True if the model supports native thinking/reasoning.

    Examples
    --------
    >>> is_gemini_reasoning_model("gemini-2.5-pro-preview-05-06")
    True
    >>> is_gemini_reasoning_model("gemini-nano")
    False
    """
    return bool(_GEMINI_REASONING_RE.fullmatch(model_name))
