
    kj                         d Z ddlmZmZmZ ddlmZmZ ddlm	Z	 ddl
mZmZmZ ddlmZ dd	lmZ d
eeee         ef         defdZ G d de	          ZdS )zE
This modules contains classes for creating conditional constraints.
    )OptionalSequenceUnion)Context	Parameter   )
Constraint)AllSetIsSet	Predicate)ConstraintViolated   )	make_reprargreturnc                     t          | t                    rt          |           S t          | t                    r| S t          | t                    r	t          |  S t          d          )Nz<`arg` should be a string, a list of strings or a `Predicate`)
isinstancestrr   r   r   r
   	TypeError)r   s    Y/home/agentuser/manim-venv/lib/python3.11/site-packages/cloup/constraints/_conditional.pyas_predicater      se    #s XSzz	C	#	# X
	C	"	" Xs|VWWW    c                       e Zd ZdZ	 ddeeee         ef         dede	e         fdZ
dedefd	Zd
ee         ddfdZd
ee         deddfdZdefdZdS )Ifaq  
    Checks one constraint or another depending on the truth value of the condition.

    .. versionadded:: 0.8.0
        you can now pass a sequence of parameter names as condition, which
        corresponds to the predicate ``AllSet(*param_names)``.

    :param condition:
        can be either an instance of ``Predicate`` or (more often) the name of a
        parameter or a list/tuple of parameters that must be all set for the
        condition to be true.
    :param then:
        a constraint checked if the condition is true.
    :param else_:
        an (optional) constraint checked if the condition is false.
    N	conditionthenelse_c                 J    t          |          | _        || _        || _        d S N)r   
_condition_then_else)selfr   r   r   s       r   __init__zIf.__init__+   s%     'y11



r   ctxr   c                     | j                             |          }| j                            |          }| j        r| j                            |          nd }| j        s| d| S | d| d| S )Nz if z, otherwise )r    descriptionr!   helpr"   )r#   r%   r   	then_help	else_helps        r   r(   zIf.help5   s    O//44	JOOC((	,0J@DJOOC(((D	z 	H00Y000GGYGGIGGGr   paramsc                     | j                             |           | j        r| j                            |           d S d S r   )r!   check_consistencyr"   )r#   r+   s     r   r-   zIf.check_consistency>   sH    
$$V,,,: 	1J((00000	1 	1r   c                 0   | j         } ||          }|r| j        n| j        }|d S 	 |                    ||           d S # t          $ rJ}|r|                    |          n|                    |          }t	          d| d| || |          d }~ww xY w)N)r%   zwhen z, )r%   
constraintr+   )r    r!   r"   check_valuesr   r'   negated_description)r#   r+   r%   r   condition_is_truebrancherrdescs           r   r0   zIf.check_valuesC   s    O	%IcNN0@dj>F
	C00000! 	 	 	 %8	%%c***22377 
 %%%%%%34   	s   A 
BABBc                     | j         r"t          | | j        | j        | j                   S t          | | j        | j                  S )N)r   r   )r   )r"   r   r    r!   )r#   s    r   __repr__zIf.__repr__U   sC    : 	WT4?4:VVVVtTZ@@@@r   r   )__name__
__module____qualname____doc__r   r   r   r   r	   r   r$   r   r(   r   r-   r0   r7    r   r   r   r      s        * '+	 hsmY67  
#	   H HC H H H H1(; 1 1 1 1 1
8I#6 W     $A# A A A A A Ar   r   N)r;   typingr   r   r   clickr   r   _corer	   
conditionsr
   r   r   
exceptionsr   _utilr   r   r   r   r<   r   r   <module>rC      s    - , , , , , , , , , $ $ $ $ $ $ $ $       0 0 0 0 0 0 0 0 0 0 * * * * * *      XeC#	9: Xy X X X X?A ?A ?A ?A ?A ?A ?A ?A ?A ?Ar   