o
    e                     @   s   d dl mZ d dlmZmZmZmZmZ edeeeef  Z	edddG dd dZ
edddG dd	 d	ZedddG d
d dZdS )    )	dataclass)ListDictAnyNewTypeOptionalStoreT)frozeneqc                   @   sT   e Zd ZU dZeed< ee ed< eed< e	dede
eeef  defddZdS )	IndexSelectiona  
    An IndexSelection represents the state of an Altair
    point selection (as constructed by alt.selection_point())
    when neither the fields nor encodings arguments are specified.

    The value field is a list of zero-based indices into the
    selected dataset.

    Note: These indices only apply to the input DataFrame
    for charts that do not include aggregations (e.g. a scatter chart).
    namevaluestoresignalc                 C   s>   |du rg }n| di  dg }dd |D }t| ||dS )a  
        Construct an IndexSelection from the raw Vega signal and dataset values.

        Parameters
        ----------
        name: str
            The selection's name
        signal: dict or None
            The value of the Vega signal corresponding to the selection
        store: list
            The value of the Vega dataset corresponding to the selection.
            This dataset is named "{name}_store" in the Vega view.

        Returns
        -------
        IndexSelection
        NvlPointorc                 S   s   g | ]}|d  d qS )Z_vgsid_    ).0pr   r   FD:\Projects\ConvertPro\env\Lib\site-packages\altair/utils/selection.py
<listcomp>3   s    z,IndexSelection.from_vega.<locals>.<listcomp>r   r   r   )getr   )r   r   r   indicespointsr   r   r   	from_vega   s
   zIndexSelection.from_vegaN)__name__
__module____qualname____doc__str__annotations__r   intr   staticmethodr   r   dictr   r   r   r   r   r   
   s   
 (r   c                   @   s\   e Zd ZU dZeed< eeeef  ed< e	ed< e
dedeeeef  de	fddZdS )	PointSelectiona  
    A PointSelection represents the state of an Altair
    point selection (as constructed by alt.selection_point())
    when the fields or encodings arguments are specified.

    The value field is a list of dicts of the form:
        [{"dim1": 1, "dim2": "A"}, {"dim1": 2, "dim2": "BB"}]

    where "dim1" and "dim2" are dataset columns and the dict values
    correspond to the specific selected values.
    r   r   r   r   c                 C   s0   |du rg }n
| di  dg }t| ||dS )a  
        Construct a PointSelection from the raw Vega signal and dataset values.

        Parameters
        ----------
        name: str
            The selection's name
        signal: dict or None
            The value of the Vega signal corresponding to the selection
        store: list
            The value of the Vega dataset corresponding to the selection.
            This dataset is named "{name}_store" in the Vega view.

        Returns
        -------
        PointSelection
        Nr   r   r   )r   r&   )r   r   r   r   r   r   r   r   I   s   zPointSelection.from_vegaN)r   r   r   r    r!   r"   r   r   r   r   r$   r   r%   r   r   r   r   r   r&   7   s   
 (r&   c                   @   sX   e Zd ZU dZeed< eeef ed< eed< e	dede
eeef  defddZdS )	IntervalSelectionaR  
    An IntervalSelection represents the state of an Altair
    interval selection (as constructed by alt.selection_interval()).

    The value field is a dict of the form:
        {"dim1": [0, 10], "dim2": ["A", "BB", "CCC"]}

    where "dim1" and "dim2" are dataset columns and the dict values
    correspond to the selected range.
    r   r   r   r   c                 C   s   |du ri }t | ||dS )a  
        Construct an IntervalSelection from the raw Vega signal and dataset values.

        Parameters
        ----------
        name: str
            The selection's name
        signal: dict or None
            The value of the Vega signal corresponding to the selection
        store: list
            The value of the Vega dataset corresponding to the selection.
            This dataset is named "{name}_store" in the Vega view.

        Returns
        -------
        PointSelection
        Nr   )r'   )r   r   r   r   r   r   r   t   s   zIntervalSelection.from_vegaN)r   r   r   r    r!   r"   r   listr   r$   r   r   r   r   r   r   r'   c   s   
 (r'   N)dataclassesr   typingr   r   r   r   r   r!   r   r   r&   r'   r   r   r   r   <module>   s    

,
+