"""
This type stub file was generated by pyright.
"""

from collections.abc import Sequence
from dataclasses import dataclass
from typing import Any, Callable, Final, Generic, Literal, TYPE_CHECKING, TypeVar, overload
from typing_extensions import TypeAlias
from streamlit.elements.lib.utils import Key, LabelVisibility
from streamlit.proto.ButtonGroup_pb2 import ButtonGroup as ButtonGroupProto
from streamlit.runtime.metrics_util import gather_metrics
from streamlit.runtime.state import WidgetArgs, WidgetCallback, WidgetKwargs
from streamlit.type_util import T
from streamlit.dataframe_util import OptionSequence
from streamlit.delta_generator import DeltaGenerator

if TYPE_CHECKING:
    ...
V = TypeVar("V")
_THUMB_ICONS: Final = ...
_FACES_ICONS: Final = ...
_NUMBER_STARS: Final = ...
_STAR_ICON: Final = ...
_SELECTED_STAR_ICON: Final = ...
SelectionMode: TypeAlias = Literal["single", "multi"]
@dataclass
class _MultiSelectSerde(Generic[T]):
    """Only meant to be used internally for the button_group element.

    This serde is inspired by the MultiSelectSerde from multiselect.py. That serde has
    been updated since then to support the accept_new_options parameter, which is not
    required by the button_group element. If this changes again at some point,
    the two elements can share the same serde again.
    """
    options: Sequence[T]
    default_value: list[int] = ...
    def serialize(self, value: list[T]) -> list[int]:
        ...
    
    def deserialize(self, ui_value: list[int] | None, widget_id: str = ...) -> list[T]:
        ...
    


class _SingleSelectSerde(Generic[T]):
    """Only meant to be used internally for the button_group element.

    Uses the ButtonGroup's _MultiSelectSerde under-the-hood, but accepts a single
    index value and deserializes to a single index value.
    This is because button_group can be single and multi select, but we use the same
    proto for both and, thus, map single values to a list of values and a receiving
    value wrapped in a list to a single value.

    When a default_value is provided is provided, the option corresponding to the
    index is serialized/deserialized.
    """
    def __init__(self, option_indices: Sequence[T], default_value: list[int] | None = ...) -> None:
        ...
    
    def serialize(self, value: T | None) -> list[int]:
        ...
    
    def deserialize(self, ui_value: list[int] | None, widget_id: str = ...) -> T | None:
        ...
    


class ButtonGroupSerde(Generic[T]):
    """A serde that can handle both single and multi select options.

    It uses the same proto to wire the data, so that we can send and receive
    single values via a list. We have different serdes for both cases though so
    that when setting / getting the value via session_state, it is mapped correctly.
    So for single select, the value will be a single value and for multi select, it will
    be a list of values.
    """
    def __init__(self, options: Sequence[T], default_values: list[int], type: Literal["single", "multi"]) -> None:
        ...
    
    def serialize(self, value: T | list[T] | None) -> list[int]:
        ...
    
    def deserialize(self, ui_value: list[int] | None, widget_id: str = ...) -> list[T] | T | None:
        ...
    


def get_mapped_options(feedback_option: Literal["thumbs", "faces", "stars"]) -> tuple[list[ButtonGroupProto.Option], list[int]]:
    ...

class ButtonGroupMixin:
    @overload
    def feedback(self, options: Literal["thumbs"] = ..., *, key: Key | None = ..., disabled: bool = ..., on_change: WidgetCallback | None = ..., args: WidgetArgs | None = ..., kwargs: WidgetKwargs | None = ...) -> Literal[0, 1] | None:
        ...
    
    @overload
    def feedback(self, options: Literal["faces", "stars"] = ..., *, key: Key | None = ..., disabled: bool = ..., on_change: WidgetCallback | None = ..., args: WidgetArgs | None = ..., kwargs: WidgetKwargs | None = ...) -> Literal[0, 1, 2, 3, 4] | None:
        ...
    
    @gather_metrics("feedback")
    def feedback(self, options: Literal["thumbs", "faces", "stars"] = ..., *, key: Key | None = ..., disabled: bool = ..., on_change: WidgetCallback | None = ..., args: WidgetArgs | None = ..., kwargs: WidgetKwargs | None = ...) -> int | None:
        """Display a feedback widget.

        A feedback widget is an icon-based button group available in three
        styles, as described in ``options``. It is commonly used in chat and AI
        apps to allow users to rate responses.

        Parameters
        ----------
        options: "thumbs", "faces", or "stars"
            The feedback options displayed to the user. ``options`` can be one
            of the following:

            - ``"thumbs"`` (default): Streamlit displays a thumb-up and
              thumb-down button group.
            - ``"faces"``: Streamlit displays a row of five buttons with
              facial expressions depicting increasing satisfaction from left to
              right.
            - ``"stars"``: Streamlit displays a row of star icons, allowing the
              user to select a rating from one to five stars.

        key : str or int
            An optional string or integer to use as the unique key for the widget.
            If this is omitted, a key will be generated for the widget
            based on its content. No two widgets may have the same key.

        disabled : bool
            An optional boolean that disables the feedback widget if set
            to ``True``. The default is ``False``.

        on_change : callable
            An optional callback invoked when this feedback widget's value
            changes.

        args : tuple
            An optional tuple of args to pass to the callback.

        kwargs : dict
            An optional dict of kwargs to pass to the callback.

        Returns
        -------
        int or None
            An integer indicating the user's selection, where ``0`` is the
            lowest feedback. Higher values indicate more positive feedback.
            If no option was selected, the widget returns ``None``.

            - For ``options="thumbs"``, a return value of ``0`` indicates
              thumbs-down, and ``1`` indicates thumbs-up.
            - For ``options="faces"`` and ``options="stars"``, return values
              range from ``0`` (least satisfied) to ``4`` (most satisfied).

        Examples
        --------
        Display a feedback widget with stars, and show the selected sentiment:

        >>> import streamlit as st
        >>>
        >>> sentiment_mapping = ["one", "two", "three", "four", "five"]
        >>> selected = st.feedback("stars")
        >>> if selected is not None:
        >>>     st.markdown(f"You selected {sentiment_mapping[selected]} star(s).")

        .. output ::
            https://doc-feedback-stars.streamlit.app/
            height: 200px

        Display a feedback widget with thumbs, and show the selected sentiment:

        >>> import streamlit as st
        >>>
        >>> sentiment_mapping = [":material/thumb_down:", ":material/thumb_up:"]
        >>> selected = st.feedback("thumbs")
        >>> if selected is not None:
        >>>     st.markdown(f"You selected: {sentiment_mapping[selected]}")

        .. output ::
            https://doc-feedback-thumbs.streamlit.app/
            height: 200px

        """
        ...
    
    @overload
    def pills(self, label: str, options: OptionSequence[V], *, selection_mode: Literal["single"] = ..., default: V | None = ..., format_func: Callable[[Any], str] | None = ..., key: Key | None = ..., help: str | None = ..., on_change: WidgetCallback | None = ..., args: WidgetArgs | None = ..., kwargs: WidgetKwargs | None = ..., disabled: bool = ..., label_visibility: LabelVisibility = ...) -> V | None:
        ...
    
    @overload
    def pills(self, label: str, options: OptionSequence[V], *, selection_mode: Literal["multi"], default: Sequence[V] | V | None = ..., format_func: Callable[[Any], str] | None = ..., key: Key | None = ..., help: str | None = ..., on_change: WidgetCallback | None = ..., args: WidgetArgs | None = ..., kwargs: WidgetKwargs | None = ..., disabled: bool = ..., label_visibility: LabelVisibility = ...) -> list[V]:
        ...
    
    @gather_metrics("pills")
    def pills(self, label: str, options: OptionSequence[V], *, selection_mode: Literal["single", "multi"] = ..., default: Sequence[V] | V | None = ..., format_func: Callable[[Any], str] | None = ..., key: Key | None = ..., help: str | None = ..., on_change: WidgetCallback | None = ..., args: WidgetArgs | None = ..., kwargs: WidgetKwargs | None = ..., disabled: bool = ..., label_visibility: LabelVisibility = ...) -> list[V] | V | None:
        r"""Display a pills widget.

        A pills widget is similar to a ``st.selectbox`` or ``st.multiselect``
        where the ``options`` are displayed as pill-buttons instead of a
        drop-down list.

        Parameters
        ----------
        label: str
            A short label explaining to the user what this widget is for.
            The label can optionally contain GitHub-flavored Markdown of the
            following types: Bold, Italics, Strikethroughs, Inline Code, Links,
            and Images. Images display like icons, with a max height equal to
            the font height.

            Unsupported Markdown elements are unwrapped so only their children
            (text contents) render. Display unsupported elements as literal
            characters by backslash-escaping them. E.g.,
            ``"1\. Not an ordered list"``.

            See the ``body`` parameter of |st.markdown|_ for additional,
            supported Markdown directives.

            For accessibility reasons, you should never set an empty label, but
            you can hide it with ``label_visibility`` if needed. In the future,
            we may disallow empty labels by raising an exception.

            .. |st.markdown| replace:: ``st.markdown``
            .. _st.markdown: https://docs.streamlit.io/develop/api-reference/text/st.markdown

        options: Iterable of V
            Labels for the select options in an ``Iterable``. This can be a
            ``list``, ``set``, or anything supported by ``st.dataframe``. If
            ``options`` is dataframe-like, the first column will be used. Each
            label will be cast to ``str`` internally by default and can
            optionally contain GitHub-flavored Markdown, including the Markdown
            directives described in the ``body`` parameter of ``st.markdown``.

        selection_mode: "single" or "multi"
            The selection mode for the widget. If this is ``"single"``
            (default), only one option can be selected. If this is ``"multi"``,
            multiple options can be selected.

        default: Iterable of V, V, or None
            The value of the widget when it first renders. If the
            ``selection_mode`` is ``multi``, this can be a list of values, a
            single value, or ``None``. If the ``selection_mode`` is
            ``"single"``, this can be a single value or ``None``.

        format_func: function
            Function to modify the display of the options. It receives
            the raw option as an argument and should output the label to be
            shown for that option. This has no impact on the return value of
            the command. The output can optionally contain GitHub-flavored
            Markdown, including the Markdown directives described in the
            ``body`` parameter of ``st.markdown``.

        key: str or int
            An optional string or integer to use as the unique key for the widget.
            If this is omitted, a key will be generated for the widget
            based on its content. Multiple widgets of the same type may
            not share the same key.

        help: str or None
            A tooltip that gets displayed next to the widget label. Streamlit
            only displays the tooltip when ``label_visibility="visible"``. If
            this is ``None`` (default), no tooltip is displayed.

            The tooltip can optionally contain GitHub-flavored Markdown,
            including the Markdown directives described in the ``body``
            parameter of ``st.markdown``.

        on_change: callable
            An optional callback invoked when this widget's value changes.

        args: tuple
            An optional tuple of args to pass to the callback.

        kwargs: dict
            An optional dict of kwargs to pass to the callback.

        disabled: bool
            An optional boolean that disables the widget if set to ``True``.
            The default is ``False``.

        label_visibility: "visible", "hidden", or "collapsed"
            The visibility of the label. The default is ``"visible"``. If this
            is ``"hidden"``, Streamlit displays an empty spacer instead of the
            label, which can help keep the widget alligned with other widgets.
            If this is ``"collapsed"``, Streamlit displays no label or spacer.

        Returns
        -------
        list of V, V, or None
            If the ``selection_mode`` is ``multi``, this is a list of selected
            options or an empty list. If the ``selection_mode`` is
            ``"single"``, this is a selected option or ``None``.

        Examples
        --------
        **Example 1: Multi-select pills**

        Display a multi-select pills widget, and show the selection:

        >>> import streamlit as st
        >>>
        >>> options = ["North", "East", "South", "West"]
        >>> selection = st.pills("Directions", options, selection_mode="multi")
        >>> st.markdown(f"Your selected options: {selection}.")

        .. output::
           https://doc-pills-multi.streamlit.app/
           height: 200px

        **Example 2: Single-select pills with icons**

        Display a single-select pills widget with icons:

        >>> import streamlit as st
        >>>
        >>> option_map = {
        ...     0: ":material/add:",
        ...     1: ":material/zoom_in:",
        ...     2: ":material/zoom_out:",
        ...     3: ":material/zoom_out_map:",
        ... }
        >>> selection = st.pills(
        ...     "Tool",
        ...     options=option_map.keys(),
        ...     format_func=lambda option: option_map[option],
        ...     selection_mode="single",
        ... )
        >>> st.write(
        ...     "Your selected option: "
        ...     f"{None if selection is None else option_map[selection]}"
        ... )

        .. output::
           https://doc-pills-single.streamlit.app/
           height: 200px

        """
        ...
    
    @overload
    def segmented_control(self, label: str, options: OptionSequence[V], *, selection_mode: Literal["single"] = ..., default: V | None = ..., format_func: Callable[[Any], str] | None = ..., key: str | int | None = ..., help: str | None = ..., on_change: WidgetCallback | None = ..., args: WidgetArgs | None = ..., kwargs: WidgetKwargs | None = ..., disabled: bool = ..., label_visibility: LabelVisibility = ...) -> V | None:
        ...
    
    @overload
    def segmented_control(self, label: str, options: OptionSequence[V], *, selection_mode: Literal["multi"], default: Sequence[V] | V | None = ..., format_func: Callable[[Any], str] | None = ..., key: str | int | None = ..., help: str | None = ..., on_change: WidgetCallback | None = ..., args: WidgetArgs | None = ..., kwargs: WidgetKwargs | None = ..., disabled: bool = ..., label_visibility: LabelVisibility = ...) -> list[V]:
        ...
    
    @gather_metrics("segmented_control")
    def segmented_control(self, label: str, options: OptionSequence[V], *, selection_mode: Literal["single", "multi"] = ..., default: Sequence[V] | V | None = ..., format_func: Callable[[Any], str] | None = ..., key: str | int | None = ..., help: str | None = ..., on_change: WidgetCallback | None = ..., args: WidgetArgs | None = ..., kwargs: WidgetKwargs | None = ..., disabled: bool = ..., label_visibility: LabelVisibility = ...) -> list[V] | V | None:
        r"""Display a segmented control widget.

        A segmented control widget is a linear set of segments where each of
        the passed ``options`` functions like a toggle button.

        Parameters
        ----------
        label : str
            A short label explaining to the user what this widget is for.
            The label can optionally contain GitHub-flavored Markdown of the
            following types: Bold, Italics, Strikethroughs, Inline Code, Links,
            and Images. Images display like icons, with a max height equal to
            the font height.

            Unsupported Markdown elements are unwrapped so only their children
            (text contents) render. Display unsupported elements as literal
            characters by backslash-escaping them. E.g.,
            ``"1\. Not an ordered list"``.

            See the ``body`` parameter of |st.markdown|_ for additional,
            supported Markdown directives.

            For accessibility reasons, you should never set an empty label, but
            you can hide it with ``label_visibility`` if needed. In the future,
            we may disallow empty labels by raising an exception.

            .. |st.markdown| replace:: ``st.markdown``
            .. _st.markdown: https://docs.streamlit.io/develop/api-reference/text/st.markdown

        options: Iterable of V
            Labels for the select options in an ``Iterable``. This can be a
            ``list``, ``set``, or anything supported by ``st.dataframe``. If
            ``options`` is dataframe-like, the first column will be used. Each
            label will be cast to ``str`` internally by default and can
            optionally contain GitHub-flavored Markdown, including the Markdown
            directives described in the ``body`` parameter of ``st.markdown``.

        selection_mode: "single" or "multi"
            The selection mode for the widget. If this is ``"single"``
            (default), only one option can be selected. If this is ``"multi"``,
            multiple options can be selected.

        default: Iterable of V, V, or None
            The value of the widget when it first renders. If the
            ``selection_mode`` is ``multi``, this can be a list of values, a
            single value, or ``None``. If the ``selection_mode`` is
            ``"single"``, this can be a single value or ``None``.

        format_func: function
            Function to modify the display of the options. It receives
            the raw option as an argument and should output the label to be
            shown for that option. This has no impact on the return value of
            the command. The output can optionally contain GitHub-flavored
            Markdown, including the Markdown directives described in the
            ``body`` parameter of ``st.markdown``.

        key: str or int
            An optional string or integer to use as the unique key for the widget.
            If this is omitted, a key will be generated for the widget
            based on its content. Multiple widgets of the same type may
            not share the same key.

        help: str or None
            A tooltip that gets displayed next to the widget label. Streamlit
            only displays the tooltip when ``label_visibility="visible"``. If
            this is ``None`` (default), no tooltip is displayed.

            The tooltip can optionally contain GitHub-flavored Markdown,
            including the Markdown directives described in the ``body``
            parameter of ``st.markdown``.

        on_change: callable
            An optional callback invoked when this widget's value changes.

        args: tuple
            An optional tuple of args to pass to the callback.

        kwargs: dict
            An optional dict of kwargs to pass to the callback.

        disabled: bool
            An optional boolean that disables the widget if set to ``True``.
            The default is ``False``.

        label_visibility: "visible", "hidden", or "collapsed"
            The visibility of the label. The default is ``"visible"``. If this
            is ``"hidden"``, Streamlit displays an empty spacer instead of the
            label, which can help keep the widget alligned with other widgets.
            If this is ``"collapsed"``, Streamlit displays no label or spacer.

        Returns
        -------
        list of V, V, or None
            If the ``selection_mode`` is ``multi``, this is a list of selected
            options or an empty list. If the ``selection_mode`` is
            ``"single"``, this is a selected option or ``None``.

        Examples
        --------
        **Example 1: Multi-select segmented control**

        Display a multi-select segmented control widget, and show the
        selection:

        >>> import streamlit as st
        >>>
        >>> options = ["North", "East", "South", "West"]
        >>> selection = st.segmented_control(
        ...     "Directions", options, selection_mode="multi"
        ... )
        >>> st.markdown(f"Your selected options: {selection}.")

        .. output::
           https://doc-segmented-control-multi.streamlit.app/
           height: 200px

        **Example 2: Single-select segmented control with icons**

        Display a single-select segmented control widget with icons:

        >>> import streamlit as st
        >>>
        >>> option_map = {
        ...     0: ":material/add:",
        ...     1: ":material/zoom_in:",
        ...     2: ":material/zoom_out:",
        ...     3: ":material/zoom_out_map:",
        ... }
        >>> selection = st.segmented_control(
        ...     "Tool",
        ...     options=option_map.keys(),
        ...     format_func=lambda option: option_map[option],
        ...     selection_mode="single",
        ... )
        >>> st.write(
        ...     "Your selected option: "
        ...     f"{None if selection is None else option_map[selection]}"
        ... )

        .. output::
           https://doc-segmented-control-single.streamlit.app/
           height: 200px

        """
        ...
    
    @property
    def dg(self) -> DeltaGenerator:
        """Get our DeltaGenerator."""
        ...
    


