
    ˀh                        d dl mZ d dlmZmZ d dlmZ d dlm	Z	m
Z
 d dlmZ d dlmZ erd dlmZ d dlmZ d d	lmZ  G d
 d      Z G d de      Z G d d      Z G d de      Zy)    )annotations)TYPE_CHECKINGAnyN)parse_into_expression,parse_predicates_constraints_into_expression	wrap_expr)Expr)Iterable)IntoExpr)PyExprc                       e Zd ZdZddZddZy)Whenz
    Utility class for the `when-then-otherwise` expression.

    Represents the initial state of the expression after `pl.when(...)` is called.

    In this state, `then` must be called to continue to finish the expression.
    c                    || _         y N)_when)selfwhens     p/var/www/html/wine-match-dev/backend/winematch-backend/venv/lib/python3.12/site-packages/polars/expr/whenthen.py__init__zWhen.__init__   	    
    c                `    t        |      }t        | j                  j                  |            S aR  
        Attach a statement to the corresponding condition.

        Parameters
        ----------
        statement
            The statement to apply if the corresponding condition is true.
            Accepts expression input. Strings are parsed as column names, other
            non-expression inputs are parsed as literals.
        )r   Thenr   thenr   	statementstatement_pyexprs      r   r   z	When.then    s(     1;DJJOO$4566r   N)r   r   returnNone)r   r   r    r   __name__
__module____qualname____doc__r   r    r   r   r   r      s    7r   r   c                  X    e Zd ZdZddZed	d       Zed
d       Z	 	 	 	 	 	 ddZ	ddZ
y)r   z
    Utility class for the `when-then-otherwise` expression.

    Represents the state of the expression after `pl.when(...).then(...)` is called.
    c                    || _         y r   )_then)r   r   s     r   r   zThen.__init__6   r   r   c                    t        |      S r   r   clspyexprs     r   _from_pyexprzThen._from_pyexpr9         r   c                r    | j                   j                  t        j                  d       j                        S r   )r*   	otherwiseFlit_pyexprr   s    r   r5   zThen._pyexpr=   s%    zz##AEE$K$7$788r   c                `    t        |i |}t        | j                  j                  |            S )ao  
        Add a condition to the `when-then-otherwise` expression.

        Parameters
        ----------
        predicates
            Condition(s) that must be met in order to apply the subsequent statement.
            Accepts one or more boolean expressions, which are implicitly combined with
            `&`. String input is parsed as a column name.
        constraints
            Apply conditions as `col_name = value` keyword arguments that are treated as
            equality matches, such as `x = 123`. As with the predicates parameter,
            multiple conditions are implicitly combined using `&`.
        )r   ChainedWhenr*   r   r   
predicatesconstraintscondition_pyexprs       r   r   z	Then.whenA   s6    & H
&
 4::??+;<==r   c                `    t        |      }t        | j                  j                  |            S aO  
        Define a default for the `when-then-otherwise` expression.

        Parameters
        ----------
        statement
            The statement to apply if all conditions are false.
            Accepts expression input. Strings are parsed as column names, other
            non-expression inputs are parsed as literals.
        )r   r	   r*   r2   r   s      r   r2   zThen.otherwiseY   s*     1;--.>?@@r   N)r   r   r    r!   r.   r   r    r
   r    r   r:   zIntoExpr | Iterable[IntoExpr]r;   r   r    r8   r   r   r    r
   r#   r$   r%   r&   r   classmethodr/   propertyr5   r   r2   r'   r   r   r   r   /   s[     ! ! 9 9>2> > 
	>0Ar   r   c                       e Zd ZdZddZddZy)r8   z
    Utility class for the `when-then-otherwise` expression.

    Represents the state of the expression after an additional `when` is called.

    In this state, `then` must be called to continue to finish the expression.
    c                    || _         y r   )_chained_when)r   chained_whens     r   r   zChainedWhen.__init__q   
    )r   c                `    t        |      }t        | j                  j                  |            S r   )r   ChainedThenrH   r   r   s      r   r   zChainedWhen.thent   s,     1;4--223CDEEr   N)rI   r   r    r!   )r   r   r    rL   r"   r'   r   r   r8   r8   h   s    *Fr   r8   c                  X    e Zd ZdZddZed	d       Zed
d       Z	 	 	 	 	 	 ddZ	ddZ
y)rL   z
    Utility class for the `when-then-otherwise` expression.

    Represents the state of the expression after an additional `then` is called.
    c                    || _         y r   )_chained_then)r   chained_thens     r   r   zChainedThen.__init__   rJ   r   c                    t        |      S r   r   r,   s     r   r/   zChainedThen._from_pyexpr   r0   r   c                r    | j                   j                  t        j                  d       j                        S r   )rO   r2   r3   r4   r5   r6   s    r   r5   zChainedThen._pyexpr   s'    !!++AEE$K,?,?@@r   c                `    t        |i |}t        | j                  j                  |            S )au  
        Add another condition to the `when-then-otherwise` expression.

        Parameters
        ----------
        predicates
            Condition(s) that must be met in order to apply the subsequent statement.
            Accepts one or more boolean expressions, which are implicitly combined with
            `&`. String input is parsed as a column name.
        constraints
            Apply conditions as `col_name = value` keyword arguments that are treated as
            equality matches, such as `x = 123`. As with the predicates parameter,
            multiple conditions are implicitly combined using `&`.
        )r   r8   rO   r   r9   s       r   r   zChainedThen.when   s:    & H
&
 4--223CDEEr   c                `    t        |      }t        | j                  j                  |            S r>   )r   r	   rO   r2   r   s      r   r2   zChainedThen.otherwise   s,     1;++556FGHHr   N)rP   r   r    r!   r?   r@   rA   rB   rC   r'   r   r   rL   rL      sa    * ! ! A AF2F F 
	F0Ir   rL   )
__future__r   typingr   r   polars.functions	functionsr3   polars._utils.parser   r   polars._utils.wrapr	   polars.expr.exprr
   collections.abcr   polars._typingr   polars.polarsr   r   r   r8   rL   r'   r   r   <module>r_      sZ    " %  ) !('$7 766A4 6ArF F66I$ 6Ir   